This commit is contained in:
syuilo 2025-08-27 12:40:11 +09:00
parent ee96f77ef2
commit c5bb881438
2 changed files with 9 additions and 9 deletions

View File

@ -4,11 +4,11 @@
*/ */
import { utils, values } from '@syuilo/aiscript'; import { utils, values } from '@syuilo/aiscript';
import { genId } from '@/utility/id.js';
import { ref } from 'vue'; import { ref } from 'vue';
import type { Ref } from 'vue';
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import { assertStringAndIsIn } from './common.js'; import { assertStringAndIsIn } from './common.js';
import type { Ref } from 'vue';
import { genId } from '@/utility/id.js';
const ALIGNS = ['left', 'center', 'right'] as const; const ALIGNS = ['left', 'center', 'right'] as const;
const FONTS = ['serif', 'sans-serif', 'monospace'] as const; const FONTS = ['serif', 'sans-serif', 'monospace'] as const;
@ -21,16 +21,15 @@ type BorderStyle = (typeof BORDER_STYLES)[number];
export type AsUiComponentBase = { export type AsUiComponentBase = {
id: string; id: string;
hidden?: boolean; hidden?: boolean;
children?: AsUiComponent['id'][];
}; };
export type AsUiRoot = AsUiComponentBase & { export type AsUiRoot = AsUiComponentBase & {
type: 'root'; type: 'root';
children: AsUiComponent['id'][];
}; };
export type AsUiContainer = AsUiComponentBase & { export type AsUiContainer = AsUiComponentBase & {
type: 'container'; type: 'container';
children?: AsUiComponent['id'][];
align?: Align; align?: Align;
bgColor?: string; bgColor?: string;
fgColor?: string; fgColor?: string;
@ -123,7 +122,6 @@ export type AsUiSelect = AsUiComponentBase & {
export type AsUiFolder = AsUiComponentBase & { export type AsUiFolder = AsUiComponentBase & {
type: 'folder'; type: 'folder';
children?: AsUiComponent['id'][];
title?: string; title?: string;
opened?: boolean; opened?: boolean;
}; };

View File

@ -82,10 +82,10 @@ const logs = ref<{
text: string; text: string;
print: boolean; print: boolean;
}[]>([]); }[]>([]);
const root = ref<AsUiRoot>(); const root = ref<AsUiRoot | undefined>();
const components = ref<Ref<AsUiComponent>[]>([]); const components = ref<Ref<AsUiComponent>[]>([]);
const uiKey = ref(0); const uiKey = ref(0);
const uiInspectorOpenedComponents = ref(new Map<string, boolean>); const uiInspectorOpenedComponents = ref(new Map<AsUiComponent | Ref<AsUiComponent>, boolean>);
const saved = miLocalStorage.getItem('scratchpad'); const saved = miLocalStorage.getItem('scratchpad');
if (saved) { if (saved) {
@ -186,11 +186,13 @@ const headerActions = computed(() => []);
const headerTabs = computed(() => []); const headerTabs = computed(() => []);
const showns = computed(() => { const showns = computed(() => {
if (root.value == null) return new Set<string>();
const result = new Set<string>(); const result = new Set<string>();
(function addChildrenToResult(c: AsUiComponent) { (function addChildrenToResult(c: AsUiComponent) {
result.add(c.id); result.add(c.id);
if (c.children) { const children = c.children;
const childComponents = components.value.filter(v => c.children.includes(v.value.id)); if (children) {
const childComponents = components.value.filter(v => children.includes(v.value.id));
for (const child of childComponents) { for (const child of childComponents) {
addChildrenToResult(child.value); addChildrenToResult(child.value);
} }