pixifact 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/authoring/ActionRegistry.d.ts +10 -0
- package/dist/authoring/ActionRegistry.js +26 -0
- package/dist/authoring/ComponentPalette.d.ts +16 -0
- package/dist/authoring/ComponentPalette.js +50 -0
- package/dist/authoring/DesignToken.d.ts +16 -0
- package/dist/authoring/DesignToken.js +33 -0
- package/dist/authoring/DiffModel.d.ts +10 -0
- package/dist/authoring/DiffModel.js +104 -0
- package/dist/authoring/InspectorModel.d.ts +27 -0
- package/dist/authoring/InspectorModel.js +139 -0
- package/dist/authoring/LogicGraph.d.ts +66 -0
- package/dist/authoring/LogicGraph.js +184 -0
- package/dist/authoring/OverrideJournal.d.ts +18 -0
- package/dist/authoring/OverrideJournal.js +23 -0
- package/dist/authoring/PreferenceMemory.d.ts +21 -0
- package/dist/authoring/PreferenceMemory.js +39 -0
- package/dist/authoring/ProjectConfig.d.ts +20 -0
- package/dist/authoring/ProjectConfig.js +78 -0
- package/dist/authoring/RuntimePreview.d.ts +11 -0
- package/dist/authoring/RuntimePreview.js +25 -0
- package/dist/authoring/SceneDocument.d.ts +74 -0
- package/dist/authoring/SceneDocument.js +332 -0
- package/dist/authoring/SceneProjectState.d.ts +20 -0
- package/dist/authoring/SceneProjectState.js +8 -0
- package/dist/authoring/SceneSelection.d.ts +11 -0
- package/dist/authoring/SceneSelection.js +1 -0
- package/dist/authoring/index.d.ts +13 -0
- package/dist/authoring/index.js +13 -0
- package/dist/commands/Command.d.ts +63 -0
- package/dist/commands/Command.js +1 -0
- package/dist/commands/CommandStack.d.ts +14 -0
- package/dist/commands/CommandStack.js +45 -0
- package/dist/commands/applyCommand.d.ts +23 -0
- package/dist/commands/applyCommand.js +316 -0
- package/dist/commands/index.d.ts +4 -0
- package/dist/commands/index.js +4 -0
- package/dist/commands/utils.d.ts +17 -0
- package/dist/commands/utils.js +77 -0
- package/dist/commands/validateCommand.d.ts +12 -0
- package/dist/commands/validateCommand.js +285 -0
- package/dist/compiler/commands/index.d.ts +109 -0
- package/dist/compiler/commands/index.js +492 -0
- package/dist/compiler/compileScenes.d.ts +11 -0
- package/dist/compiler/compileScenes.js +220 -0
- package/dist/compiler/decorators.d.ts +6 -0
- package/dist/compiler/decorators.js +79 -0
- package/dist/compiler/eventRuntime.d.ts +8 -0
- package/dist/compiler/eventRuntime.js +29 -0
- package/dist/compiler/index.d.ts +14 -0
- package/dist/compiler/index.js +14 -0
- package/dist/compiler/pixiNodeSchema.d.ts +39 -0
- package/dist/compiler/pixiNodeSchema.js +267 -0
- package/dist/compiler/sceneAssetPair.d.ts +11 -0
- package/dist/compiler/sceneAssetPair.js +92 -0
- package/dist/compiler/scenePartValidation.d.ts +6 -0
- package/dist/compiler/scenePartValidation.js +24 -0
- package/dist/compiler/sceneRuntime.d.ts +13 -0
- package/dist/compiler/sceneRuntime.js +22 -0
- package/dist/compiler/sceneValidation.d.ts +48 -0
- package/dist/compiler/sceneValidation.js +383 -0
- package/dist/compiler/scriptInterfaceExtractor.d.ts +6 -0
- package/dist/compiler/scriptInterfaceExtractor.js +258 -0
- package/dist/compiler/slotRuntime.d.ts +3 -0
- package/dist/compiler/slotRuntime.js +17 -0
- package/dist/compiler/spec.d.ts +95 -0
- package/dist/compiler/spec.js +1 -0
- package/dist/compiler/templateParser.d.ts +2 -0
- package/dist/compiler/templateParser.js +302 -0
- package/dist/compiler/templateSerializer.d.ts +2 -0
- package/dist/compiler/templateSerializer.js +101 -0
- package/dist/compiler/typescriptCompiler.d.ts +2 -0
- package/dist/compiler/typescriptCompiler.js +494 -0
- package/dist/compiler-node/index.d.ts +2 -0
- package/dist/compiler-node/index.js +2 -0
- package/dist/compiler-node/vite.d.ts +8 -0
- package/dist/compiler-node/vite.js +21 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/nodes/Input.d.ts +91 -0
- package/dist/nodes/Input.js +352 -0
- package/dist/nodes/Textarea.d.ts +10 -0
- package/dist/nodes/Textarea.js +38 -0
- package/dist/nodes/components/Button.d.ts +8 -0
- package/dist/nodes/components/Button.js +45 -0
- package/dist/nodes/components/InputField.d.ts +12 -0
- package/dist/nodes/components/InputField.js +53 -0
- package/dist/nodes/components/ProgressBar.d.ts +14 -0
- package/dist/nodes/components/ProgressBar.js +66 -0
- package/dist/nodes/components/ScrollRect.d.ts +23 -0
- package/dist/nodes/components/ScrollRect.js +108 -0
- package/dist/nodes/components/Selectable.d.ts +32 -0
- package/dist/nodes/components/Selectable.js +153 -0
- package/dist/nodes/components/index.d.ts +5 -0
- package/dist/nodes/components/index.js +5 -0
- package/dist/nodes/graphics/Graphic.d.ts +14 -0
- package/dist/nodes/graphics/Graphic.js +47 -0
- package/dist/nodes/graphics/ImageGraphic.d.ts +9 -0
- package/dist/nodes/graphics/ImageGraphic.js +42 -0
- package/dist/nodes/graphics/RoundedRectGraphic.d.ts +13 -0
- package/dist/nodes/graphics/RoundedRectGraphic.js +65 -0
- package/dist/nodes/graphics/TextGraphic.d.ts +13 -0
- package/dist/nodes/graphics/TextGraphic.js +70 -0
- package/dist/nodes/graphics/index.d.ts +4 -0
- package/dist/nodes/graphics/index.js +4 -0
- package/dist/nodes/index.d.ts +3 -0
- package/dist/nodes/index.js +3 -0
- package/dist/runtime/Application.d.ts +15 -0
- package/dist/runtime/Application.js +67 -0
- package/dist/runtime/GameObject.d.ts +100 -0
- package/dist/runtime/GameObject.js +297 -0
- package/dist/runtime/GameObjectEvent.d.ts +52 -0
- package/dist/runtime/GameObjectEvent.js +38 -0
- package/dist/runtime/Transform.d.ts +32 -0
- package/dist/runtime/Transform.js +157 -0
- package/dist/runtime/component/Component.d.ts +13 -0
- package/dist/runtime/component/Component.js +13 -0
- package/dist/runtime/component/ComponentRegistry.d.ts +49 -0
- package/dist/runtime/component/ComponentRegistry.js +25 -0
- package/dist/runtime/component/Flex.d.ts +6 -0
- package/dist/runtime/component/Flex.js +15 -0
- package/dist/runtime/component/FlexGroup.d.ts +26 -0
- package/dist/runtime/component/FlexGroup.js +136 -0
- package/dist/runtime/component/GridLayout.d.ts +47 -0
- package/dist/runtime/component/GridLayout.js +129 -0
- package/dist/runtime/component/Layout.d.ts +104 -0
- package/dist/runtime/component/Layout.js +248 -0
- package/dist/runtime/component/decorators.d.ts +4 -0
- package/dist/runtime/component/decorators.js +52 -0
- package/dist/runtime/component/index.d.ts +7 -0
- package/dist/runtime/component/index.js +7 -0
- package/dist/runtime/graphics/index.d.ts +11 -0
- package/dist/runtime/graphics/index.js +29 -0
- package/dist/runtime/group/index.d.ts +39 -0
- package/dist/runtime/group/index.js +102 -0
- package/dist/runtime/image/Image.d.ts +19 -0
- package/dist/runtime/image/Image.js +60 -0
- package/dist/runtime/image/NineSliceImage.d.ts +23 -0
- package/dist/runtime/image/NineSliceImage.js +64 -0
- package/dist/runtime/image/index.d.ts +2 -0
- package/dist/runtime/image/index.js +2 -0
- package/dist/runtime/index.d.ts +9 -0
- package/dist/runtime/index.js +9 -0
- package/dist/runtime/label/Label.d.ts +11 -0
- package/dist/runtime/label/Label.js +26 -0
- package/dist/runtime/label/LabelStyle.d.ts +3 -0
- package/dist/runtime/label/LabelStyle.js +3 -0
- package/dist/runtime/label/index.d.ts +2 -0
- package/dist/runtime/label/index.js +2 -0
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +1 -0
- package/dist/runtime/utils/onlyOnceQueueMicrotask.d.ts +1 -0
- package/dist/runtime/utils/onlyOnceQueueMicrotask.js +12 -0
- package/dist/runtime/utils/setProps.d.ts +10 -0
- package/dist/runtime/utils/setProps.js +17 -0
- package/dist/scene/dsl.d.ts +25 -0
- package/dist/scene/dsl.js +112 -0
- package/dist/scene/index.d.ts +5 -0
- package/dist/scene/index.js +5 -0
- package/dist/scene/instantiate.d.ts +8 -0
- package/dist/scene/instantiate.js +208 -0
- package/dist/scene/nodesDsl.d.ts +42 -0
- package/dist/scene/nodesDsl.js +169 -0
- package/dist/scene/spec.d.ts +100 -0
- package/dist/scene/spec.js +1 -0
- package/dist/scene/templates.d.ts +21 -0
- package/dist/scene/templates.js +239 -0
- package/package.json +90 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { access, mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { defaultSceneSourceRoots, generatedSceneModuleImport, generatedSceneModulePath, isIgnoredSceneSourceDirectory, normalizeSceneAssetId, pairedSceneScriptPath, resolveSceneReference, sceneClassAlias, sceneLocalName, toPosixPath, } from './sceneAssetPair.js';
|
|
5
|
+
import { extractSceneScriptInterface } from './scriptInterfaceExtractor.js';
|
|
6
|
+
import { findMissingScenePartReferences } from './scenePartValidation.js';
|
|
7
|
+
import { parseSceneTemplate } from './templateParser.js';
|
|
8
|
+
import { compileSceneTemplateToTs } from './typescriptCompiler.js';
|
|
9
|
+
export class CompileSceneError extends Error {
|
|
10
|
+
scene;
|
|
11
|
+
source;
|
|
12
|
+
constructor(message, scene, source) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.scene = scene;
|
|
15
|
+
this.source = source;
|
|
16
|
+
this.name = 'CompileSceneError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export async function compileScenes(options) {
|
|
20
|
+
const projectRoot = typeof options.projectRoot === 'string'
|
|
21
|
+
? options.projectRoot
|
|
22
|
+
: fileURLToPath(options.projectRoot);
|
|
23
|
+
const generatedDir = path.resolve(projectRoot, options.generatedDir ?? '.pixifact/generated');
|
|
24
|
+
const scenePaths = await collectSceneAssetIds(projectRoot, options.sourceRoots);
|
|
25
|
+
await mkdir(generatedDir, { recursive: true });
|
|
26
|
+
const templates = new Map();
|
|
27
|
+
for (const scenePath of scenePaths) {
|
|
28
|
+
const source = await readFile(path.resolve(projectRoot, scenePath), 'utf8');
|
|
29
|
+
try {
|
|
30
|
+
const template = parseSceneTemplate(source);
|
|
31
|
+
assertSceneLocalName(scenePath, template);
|
|
32
|
+
const descriptor = await readPairedSceneScript(projectRoot, scenePath, template);
|
|
33
|
+
template.interface = descriptor.interface;
|
|
34
|
+
templates.set(scenePath, normalizeSceneReferences(scenePath, template));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new CompileSceneError(error instanceof Error ? error.message : String(error), scenePath, source);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const registryImports = [];
|
|
41
|
+
for (const scenePath of scenePaths) {
|
|
42
|
+
const template = templates.get(scenePath);
|
|
43
|
+
if (!template) {
|
|
44
|
+
throw new Error(`Missing parsed template for ${scenePath}.`);
|
|
45
|
+
}
|
|
46
|
+
const outputFile = generatedSceneModulePath(scenePath);
|
|
47
|
+
const generatedFile = path.join(generatedDir, outputFile);
|
|
48
|
+
const generatedFileDir = path.dirname(generatedFile);
|
|
49
|
+
const code = compileSceneTemplateToTs(template, {
|
|
50
|
+
registrationPath: scenePath,
|
|
51
|
+
scriptImport: {
|
|
52
|
+
exportName: template.name,
|
|
53
|
+
localName: sceneClassAlias(scenePath),
|
|
54
|
+
source: importSourceFor(path.resolve(projectRoot, pairedSceneScriptPath(scenePath)), generatedFileDir),
|
|
55
|
+
},
|
|
56
|
+
sceneImports: sceneImportsFor(template, templates, projectRoot, generatedFileDir),
|
|
57
|
+
sceneClassAliases: sceneClassAliasesFor(template),
|
|
58
|
+
sceneInterfaces: sceneInterfacesFor(template, templates),
|
|
59
|
+
textureImports: textureImportsFor(template, projectRoot, generatedFileDir),
|
|
60
|
+
});
|
|
61
|
+
await mkdir(path.dirname(generatedFile), { recursive: true });
|
|
62
|
+
await writeFile(generatedFile, code);
|
|
63
|
+
registryImports.push(`import ${JSON.stringify(generatedSceneModuleImport(scenePath))};`);
|
|
64
|
+
}
|
|
65
|
+
await writeFile(path.join(generatedDir, 'scenes.generated.ts'), `${registryImports.join('\n')}\n`);
|
|
66
|
+
}
|
|
67
|
+
async function collectSceneAssetIds(projectRoot, sourceRoots = defaultSceneSourceRoots) {
|
|
68
|
+
const scenes = [];
|
|
69
|
+
for (const sourceRoot of sourceRoots) {
|
|
70
|
+
const absoluteRoot = path.resolve(projectRoot, sourceRoot);
|
|
71
|
+
if (!await exists(absoluteRoot)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
await collectScenesInDirectory(projectRoot, absoluteRoot, scenes);
|
|
75
|
+
}
|
|
76
|
+
return scenes.sort();
|
|
77
|
+
}
|
|
78
|
+
async function collectScenesInDirectory(projectRoot, directory, scenes) {
|
|
79
|
+
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
80
|
+
if (entry.isDirectory()) {
|
|
81
|
+
if (!isIgnoredSceneSourceDirectory(entry.name)) {
|
|
82
|
+
await collectScenesInDirectory(projectRoot, path.join(directory, entry.name), scenes);
|
|
83
|
+
}
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (entry.isFile() && entry.name.endsWith('.scene')) {
|
|
87
|
+
scenes.push(normalizeSceneAssetId(toPosixPath(path.relative(projectRoot, path.join(directory, entry.name)))));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function exists(filePath) {
|
|
92
|
+
try {
|
|
93
|
+
await access(filePath);
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function assertSceneLocalName(scenePath, template) {
|
|
101
|
+
const expected = sceneLocalName(scenePath);
|
|
102
|
+
if (template.name !== expected) {
|
|
103
|
+
throw new Error(`Scene "${scenePath}" name "${template.name}" must match file basename "${expected}".`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async function readPairedSceneScript(projectRoot, scenePath, template) {
|
|
107
|
+
const scriptPath = pairedSceneScriptPath(scenePath);
|
|
108
|
+
const absoluteScriptPath = path.resolve(projectRoot, scriptPath);
|
|
109
|
+
if (!await exists(absoluteScriptPath)) {
|
|
110
|
+
throw new Error(`Scene "${scenePath}" requires paired script "${scriptPath}".`);
|
|
111
|
+
}
|
|
112
|
+
const descriptor = extractSceneScriptInterface(await readFile(absoluteScriptPath, 'utf8'), absoluteScriptPath, { scene: scenePath });
|
|
113
|
+
if (descriptor.className !== template.name) {
|
|
114
|
+
throw new Error(`Scene "${scenePath}" name "${template.name}" must match @scene class "${descriptor.className}".`);
|
|
115
|
+
}
|
|
116
|
+
const missingPart = findMissingScenePartReferences(template, descriptor.parts)[0];
|
|
117
|
+
if (missingPart) {
|
|
118
|
+
throw new Error(scenePartReferenceError(scenePath, missingPart.property, missingPart.id));
|
|
119
|
+
}
|
|
120
|
+
return descriptor;
|
|
121
|
+
}
|
|
122
|
+
function scenePartReferenceError(scenePath, property, id) {
|
|
123
|
+
return `Scene "${scenePath}" @part "${property}" references missing node id "${id}".`;
|
|
124
|
+
}
|
|
125
|
+
function normalizeSceneReferences(scenePath, template) {
|
|
126
|
+
const next = structuredClone(template);
|
|
127
|
+
function visit(node) {
|
|
128
|
+
if (node.kind === 'slotOutlet') {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (node.kind === 'pixi') {
|
|
132
|
+
node.children.forEach(visit);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
node.scene = resolveSceneReference(scenePath, node.scene);
|
|
136
|
+
for (const children of Object.values(node.slots)) {
|
|
137
|
+
children.forEach(visit);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
next.children.forEach(visit);
|
|
141
|
+
return next;
|
|
142
|
+
}
|
|
143
|
+
function sceneImportsFor(template, templates, projectRoot, generatedFileDir) {
|
|
144
|
+
return [...collectSceneInstancePaths(template.children)]
|
|
145
|
+
.sort()
|
|
146
|
+
.map((scenePath) => {
|
|
147
|
+
const sceneTemplate = templates.get(scenePath);
|
|
148
|
+
if (!sceneTemplate) {
|
|
149
|
+
throw new Error(`Scene "${template.name}" references unknown Scene "${scenePath}".`);
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
exportName: sceneTemplate.name,
|
|
153
|
+
localName: sceneClassAlias(scenePath),
|
|
154
|
+
source: importSourceFor(path.resolve(projectRoot, pairedSceneScriptPath(scenePath)), generatedFileDir),
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function sceneClassAliasesFor(template) {
|
|
159
|
+
return Object.fromEntries([...collectSceneInstancePaths(template.children)].map((scenePath) => [scenePath, sceneClassAlias(scenePath)]));
|
|
160
|
+
}
|
|
161
|
+
function sceneInterfacesFor(template, templates) {
|
|
162
|
+
return Object.fromEntries([...collectSceneInstancePaths(template.children)].map((scenePath) => {
|
|
163
|
+
const sceneTemplate = templates.get(scenePath);
|
|
164
|
+
if (!sceneTemplate) {
|
|
165
|
+
throw new Error(`Scene "${template.name}" references unknown Scene "${scenePath}".`);
|
|
166
|
+
}
|
|
167
|
+
return [scenePath, sceneTemplate.interface];
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
function importSourceFor(sourcePath, generatedFileDir) {
|
|
171
|
+
const source = path.relative(generatedFileDir, sourcePath).replaceAll(path.sep, '/').replace(/\.ts$/, '');
|
|
172
|
+
return source.startsWith('.') ? source : `./${source}`;
|
|
173
|
+
}
|
|
174
|
+
function textureImportsFor(template, projectRoot, generatedFileDir) {
|
|
175
|
+
const textures = new Set();
|
|
176
|
+
for (const child of template.children) {
|
|
177
|
+
collectTextureReferences(child, textures);
|
|
178
|
+
}
|
|
179
|
+
return Object.fromEntries([...textures].map((texture) => {
|
|
180
|
+
const normalized = texture.replace(/^\.\/+/, '').replace(/^\/+/, '');
|
|
181
|
+
const assetPath = path.resolve(projectRoot, normalized);
|
|
182
|
+
const source = path.relative(generatedFileDir, assetPath).replaceAll(path.sep, '/');
|
|
183
|
+
return [texture, `${source.startsWith('.') ? source : `./${source}`}?url`];
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
function collectSceneInstancePaths(nodes, scenePaths = new Set()) {
|
|
187
|
+
for (const node of nodes) {
|
|
188
|
+
if (node.kind === 'slotOutlet') {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (node.kind === 'pixi') {
|
|
192
|
+
collectSceneInstancePaths(node.children, scenePaths);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
scenePaths.add(node.scene);
|
|
196
|
+
for (const children of Object.values(node.slots)) {
|
|
197
|
+
collectSceneInstancePaths(children, scenePaths);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return scenePaths;
|
|
201
|
+
}
|
|
202
|
+
function collectTextureReferences(node, textures) {
|
|
203
|
+
if (node.kind === 'slotOutlet') {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (node.kind === 'pixi') {
|
|
207
|
+
if (typeof node.props.texture === 'string') {
|
|
208
|
+
textures.add(node.props.texture);
|
|
209
|
+
}
|
|
210
|
+
for (const child of node.children) {
|
|
211
|
+
collectTextureReferences(child, textures);
|
|
212
|
+
}
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
for (const children of Object.values(node.slots)) {
|
|
216
|
+
for (const child of children) {
|
|
217
|
+
collectTextureReferences(child, textures);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SceneClassDecorator, SceneEventDecoratorOptions, SceneMemberDecorator, ScenePartDecoratorOptions, ScenePropDecoratorOptions, SceneSlotDecoratorOptions } from './spec.js';
|
|
2
|
+
export declare function scene(): SceneClassDecorator;
|
|
3
|
+
export declare function prop(options: ScenePropDecoratorOptions): SceneMemberDecorator;
|
|
4
|
+
export declare function event(_options?: SceneEventDecoratorOptions): SceneMemberDecorator;
|
|
5
|
+
export declare function slot(options?: SceneSlotDecoratorOptions): SceneMemberDecorator;
|
|
6
|
+
export declare function part(options?: ScenePartDecoratorOptions): SceneMemberDecorator;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { mountSceneClass } from './sceneRuntime.js';
|
|
2
|
+
const metadataByConstructor = new WeakMap();
|
|
3
|
+
export function scene() {
|
|
4
|
+
return ((constructor) => {
|
|
5
|
+
const SceneClass = class extends constructor {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
const result = mountSceneClass(this, SceneClass);
|
|
9
|
+
const metadata = sceneMetadata(constructor);
|
|
10
|
+
for (const [property, id] of metadata.parts) {
|
|
11
|
+
Object.defineProperty(this, property, {
|
|
12
|
+
configurable: true,
|
|
13
|
+
enumerable: false,
|
|
14
|
+
value: result.parts[id],
|
|
15
|
+
writable: true,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
for (const [property, slotName] of metadata.slots) {
|
|
19
|
+
Object.defineProperty(this, property, {
|
|
20
|
+
configurable: true,
|
|
21
|
+
enumerable: false,
|
|
22
|
+
value: result.slots[slotName],
|
|
23
|
+
writable: false,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
for (const [property, propOptions] of metadata.props) {
|
|
27
|
+
if (propOptions.default !== undefined) {
|
|
28
|
+
this[property] = propOptions.default;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const ready = this.onMounted;
|
|
32
|
+
if (ready) {
|
|
33
|
+
ready.call(this);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(SceneClass, 'name', { value: constructor.name });
|
|
38
|
+
return SceneClass;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function prop(options) {
|
|
42
|
+
return ((target, propertyKey) => {
|
|
43
|
+
sceneMetadata(target.constructor).props.set(memberName(propertyKey), options);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function event(_options = {}) {
|
|
47
|
+
return noopMemberDecorator;
|
|
48
|
+
}
|
|
49
|
+
export function slot(options = {}) {
|
|
50
|
+
return ((target, propertyKey) => {
|
|
51
|
+
const property = memberName(propertyKey);
|
|
52
|
+
sceneMetadata(target.constructor).slots.set(property, options.name ?? property);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export function part(options = {}) {
|
|
56
|
+
return ((target, propertyKey) => {
|
|
57
|
+
const property = memberName(propertyKey);
|
|
58
|
+
sceneMetadata(target.constructor).parts.set(property, options.id ?? property);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const noopMemberDecorator = (() => undefined);
|
|
62
|
+
function sceneMetadata(constructor) {
|
|
63
|
+
let metadata = metadataByConstructor.get(constructor);
|
|
64
|
+
if (!metadata) {
|
|
65
|
+
metadata = {
|
|
66
|
+
parts: new Map(),
|
|
67
|
+
props: new Map(),
|
|
68
|
+
slots: new Map(),
|
|
69
|
+
};
|
|
70
|
+
metadataByConstructor.set(constructor, metadata);
|
|
71
|
+
}
|
|
72
|
+
return metadata;
|
|
73
|
+
}
|
|
74
|
+
function memberName(propertyKey) {
|
|
75
|
+
if (typeof propertyKey === 'symbol') {
|
|
76
|
+
throw new Error('Pixifact scene decorators require string member names.');
|
|
77
|
+
}
|
|
78
|
+
return propertyKey;
|
|
79
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type SceneEventListener<TPayload = void> = TPayload extends void ? () => void : (payload: TPayload) => void;
|
|
2
|
+
export interface SceneEvent<TPayload = void> {
|
|
3
|
+
connect(listener: SceneEventListener<TPayload>): () => void;
|
|
4
|
+
emit(...args: TPayload extends void ? [] : [TPayload]): void;
|
|
5
|
+
}
|
|
6
|
+
export type SceneActions = Record<string, (() => void) | undefined>;
|
|
7
|
+
export declare function createEvent<TPayload = void>(): SceneEvent<TPayload>;
|
|
8
|
+
export declare function connectSceneEvent(event: SceneEvent, actionName: string, owner: object, actions?: SceneActions): () => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function createEvent() {
|
|
2
|
+
const listeners = new Set();
|
|
3
|
+
return {
|
|
4
|
+
connect(listener) {
|
|
5
|
+
listeners.add(listener);
|
|
6
|
+
return () => {
|
|
7
|
+
listeners.delete(listener);
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
emit(...args) {
|
|
11
|
+
for (const listener of listeners) {
|
|
12
|
+
listener(...args);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function connectSceneEvent(event, actionName, owner, actions = {}) {
|
|
18
|
+
const action = actions[actionName];
|
|
19
|
+
if (action) {
|
|
20
|
+
return event.connect(action);
|
|
21
|
+
}
|
|
22
|
+
const ownerAction = owner[actionName];
|
|
23
|
+
if (typeof ownerAction === 'function') {
|
|
24
|
+
return event.connect(() => {
|
|
25
|
+
ownerAction.call(owner);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
throw new Error(`Scene action "${actionName}" was not found.`);
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './commands/index.js';
|
|
2
|
+
export * from './decorators.js';
|
|
3
|
+
export * from './eventRuntime.js';
|
|
4
|
+
export * from './pixiNodeSchema.js';
|
|
5
|
+
export * from './spec.js';
|
|
6
|
+
export * from './scriptInterfaceExtractor.js';
|
|
7
|
+
export * from './sceneRuntime.js';
|
|
8
|
+
export * from './sceneAssetPair.js';
|
|
9
|
+
export * from './scenePartValidation.js';
|
|
10
|
+
export * from './sceneValidation.js';
|
|
11
|
+
export * from './slotRuntime.js';
|
|
12
|
+
export * from './templateParser.js';
|
|
13
|
+
export * from './templateSerializer.js';
|
|
14
|
+
export * from './typescriptCompiler.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './commands/index.js';
|
|
2
|
+
export * from './decorators.js';
|
|
3
|
+
export * from './eventRuntime.js';
|
|
4
|
+
export * from './pixiNodeSchema.js';
|
|
5
|
+
export * from './spec.js';
|
|
6
|
+
export * from './scriptInterfaceExtractor.js';
|
|
7
|
+
export * from './sceneRuntime.js';
|
|
8
|
+
export * from './sceneAssetPair.js';
|
|
9
|
+
export * from './scenePartValidation.js';
|
|
10
|
+
export * from './sceneValidation.js';
|
|
11
|
+
export * from './slotRuntime.js';
|
|
12
|
+
export * from './templateParser.js';
|
|
13
|
+
export * from './templateSerializer.js';
|
|
14
|
+
export * from './typescriptCompiler.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SceneTemplatePrimitiveType, SceneTemplateValue } from './spec.js';
|
|
2
|
+
export type PixiSceneNodeType = Extract<SceneTemplatePrimitiveType, 'Container' | 'Sprite' | 'NineSliceSprite' | 'TilingSprite' | 'Text' | 'BitmapText' | 'HTMLText' | 'Graphics'>;
|
|
3
|
+
export type PixiSceneFieldType = 'string' | 'number' | 'boolean' | 'color' | 'enum';
|
|
4
|
+
export type PixiScenePropGroup = 'transform' | 'display' | 'sprite' | 'nineSlice' | 'tiling' | 'text' | 'graphics';
|
|
5
|
+
export interface PixiSceneFieldSchema {
|
|
6
|
+
key: string;
|
|
7
|
+
type: PixiSceneFieldType;
|
|
8
|
+
options?: readonly (string | number)[];
|
|
9
|
+
}
|
|
10
|
+
export interface PixiSceneNodeSchema {
|
|
11
|
+
type: PixiSceneNodeType;
|
|
12
|
+
acceptsChildren: boolean;
|
|
13
|
+
defaults: Record<string, SceneTemplateValue>;
|
|
14
|
+
groups: Partial<Record<PixiScenePropGroup, readonly string[]>>;
|
|
15
|
+
}
|
|
16
|
+
export declare const pixiSceneTransformProps: readonly ["x", "y", "width", "height", "scaleX", "scaleY", "rotation", "pivotX", "pivotY", "skewX", "skewY"];
|
|
17
|
+
export declare const pixiSceneDisplayProps: readonly ["alpha", "visible", "zIndex", "eventMode", "cursor", "label"];
|
|
18
|
+
export declare const pixiSceneSpriteProps: readonly ["texture", "anchorX", "anchorY", "tint"];
|
|
19
|
+
export declare const pixiSceneNineSliceProps: readonly ["leftWidth", "rightWidth", "topHeight", "bottomHeight"];
|
|
20
|
+
export declare const pixiSceneTilingProps: readonly ["tilePositionX", "tilePositionY", "tileScaleX", "tileScaleY", "tileRotation"];
|
|
21
|
+
export declare const pixiSceneTextProps: readonly ["text", "fontSize", "fontFamily", "fontWeight", "fill"];
|
|
22
|
+
export declare const pixiSceneGraphicsProps: readonly ["shape", "radius", "fill", "fillAlpha", "strokeColor", "strokeWidth", "strokeAlpha"];
|
|
23
|
+
export declare const pixiSceneTextStyleProps: readonly ["fontSize", "fontFamily", "fontWeight", "fill"];
|
|
24
|
+
export declare const pixiSceneSpriteLikeProps: readonly ["texture", "anchorX", "anchorY", "tint", "leftWidth", "rightWidth", "topHeight", "bottomHeight", "tilePositionX", "tilePositionY", "tileScaleX", "tileScaleY", "tileRotation"];
|
|
25
|
+
export declare const pixiSceneKnownProps: readonly ["x", "y", "width", "height", "scaleX", "scaleY", "rotation", "pivotX", "pivotY", "skewX", "skewY", "alpha", "visible", "zIndex", "eventMode", "cursor", "label", "texture", "anchorX", "anchorY", "tint", "leftWidth", "rightWidth", "topHeight", "bottomHeight", "tilePositionX", "tilePositionY", "tileScaleX", "tileScaleY", "tileRotation", "text", "fontSize", "fontFamily", "fontWeight", "fill", "shape", "radius", "fill", "fillAlpha", "strokeColor", "strokeWidth", "strokeAlpha"];
|
|
26
|
+
export declare const pixiSceneAddableNodeTypes: readonly ["Container", "Sprite", "NineSliceSprite", "TilingSprite", "Text", "BitmapText", "HTMLText", "Graphics"];
|
|
27
|
+
export declare const pixiSceneNodePropGroupOrder: readonly ["sprite", "nineSlice", "tiling", "text", "graphics"];
|
|
28
|
+
export declare function pixiSceneNodeSchema(type: PixiSceneNodeType): PixiSceneNodeSchema;
|
|
29
|
+
export declare function isPixiSceneNodeType(type: SceneTemplatePrimitiveType): type is PixiSceneNodeType;
|
|
30
|
+
export declare function pixiSceneNodeDefaults(type: PixiSceneNodeType): {
|
|
31
|
+
[x: string]: SceneTemplateValue;
|
|
32
|
+
};
|
|
33
|
+
export declare function pixiSceneNodeAcceptsChildren(type: SceneTemplatePrimitiveType): boolean;
|
|
34
|
+
export declare function pixiSceneNodePropKeys(type: PixiSceneNodeType): string[];
|
|
35
|
+
export declare function pixiSceneNodePropGroups(type: PixiSceneNodeType): {
|
|
36
|
+
group: "text" | "sprite" | "nineSlice" | "tiling" | "graphics";
|
|
37
|
+
fields: readonly string[];
|
|
38
|
+
}[];
|
|
39
|
+
export declare function pixiSceneFieldSchema(key: string): PixiSceneFieldSchema | undefined;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
export const pixiSceneTransformProps = [
|
|
2
|
+
'x',
|
|
3
|
+
'y',
|
|
4
|
+
'width',
|
|
5
|
+
'height',
|
|
6
|
+
'scaleX',
|
|
7
|
+
'scaleY',
|
|
8
|
+
'rotation',
|
|
9
|
+
'pivotX',
|
|
10
|
+
'pivotY',
|
|
11
|
+
'skewX',
|
|
12
|
+
'skewY',
|
|
13
|
+
];
|
|
14
|
+
export const pixiSceneDisplayProps = [
|
|
15
|
+
'alpha',
|
|
16
|
+
'visible',
|
|
17
|
+
'zIndex',
|
|
18
|
+
'eventMode',
|
|
19
|
+
'cursor',
|
|
20
|
+
'label',
|
|
21
|
+
];
|
|
22
|
+
export const pixiSceneSpriteProps = [
|
|
23
|
+
'texture',
|
|
24
|
+
'anchorX',
|
|
25
|
+
'anchorY',
|
|
26
|
+
'tint',
|
|
27
|
+
];
|
|
28
|
+
export const pixiSceneNineSliceProps = [
|
|
29
|
+
'leftWidth',
|
|
30
|
+
'rightWidth',
|
|
31
|
+
'topHeight',
|
|
32
|
+
'bottomHeight',
|
|
33
|
+
];
|
|
34
|
+
export const pixiSceneTilingProps = [
|
|
35
|
+
'tilePositionX',
|
|
36
|
+
'tilePositionY',
|
|
37
|
+
'tileScaleX',
|
|
38
|
+
'tileScaleY',
|
|
39
|
+
'tileRotation',
|
|
40
|
+
];
|
|
41
|
+
export const pixiSceneTextProps = [
|
|
42
|
+
'text',
|
|
43
|
+
'fontSize',
|
|
44
|
+
'fontFamily',
|
|
45
|
+
'fontWeight',
|
|
46
|
+
'fill',
|
|
47
|
+
];
|
|
48
|
+
export const pixiSceneGraphicsProps = [
|
|
49
|
+
'shape',
|
|
50
|
+
'radius',
|
|
51
|
+
'fill',
|
|
52
|
+
'fillAlpha',
|
|
53
|
+
'strokeColor',
|
|
54
|
+
'strokeWidth',
|
|
55
|
+
'strokeAlpha',
|
|
56
|
+
];
|
|
57
|
+
export const pixiSceneTextStyleProps = [
|
|
58
|
+
'fontSize',
|
|
59
|
+
'fontFamily',
|
|
60
|
+
'fontWeight',
|
|
61
|
+
'fill',
|
|
62
|
+
];
|
|
63
|
+
export const pixiSceneSpriteLikeProps = [
|
|
64
|
+
...pixiSceneSpriteProps,
|
|
65
|
+
...pixiSceneNineSliceProps,
|
|
66
|
+
...pixiSceneTilingProps,
|
|
67
|
+
];
|
|
68
|
+
export const pixiSceneKnownProps = [
|
|
69
|
+
...pixiSceneTransformProps,
|
|
70
|
+
...pixiSceneDisplayProps,
|
|
71
|
+
...pixiSceneSpriteLikeProps,
|
|
72
|
+
...pixiSceneTextProps,
|
|
73
|
+
...pixiSceneGraphicsProps,
|
|
74
|
+
];
|
|
75
|
+
export const pixiSceneAddableNodeTypes = [
|
|
76
|
+
'Container',
|
|
77
|
+
'Sprite',
|
|
78
|
+
'NineSliceSprite',
|
|
79
|
+
'TilingSprite',
|
|
80
|
+
'Text',
|
|
81
|
+
'BitmapText',
|
|
82
|
+
'HTMLText',
|
|
83
|
+
'Graphics',
|
|
84
|
+
];
|
|
85
|
+
export const pixiSceneNodePropGroupOrder = [
|
|
86
|
+
'sprite',
|
|
87
|
+
'nineSlice',
|
|
88
|
+
'tiling',
|
|
89
|
+
'text',
|
|
90
|
+
'graphics',
|
|
91
|
+
];
|
|
92
|
+
const pixiSceneFieldSchemas = {
|
|
93
|
+
x: { key: 'x', type: 'number' },
|
|
94
|
+
y: { key: 'y', type: 'number' },
|
|
95
|
+
width: { key: 'width', type: 'number' },
|
|
96
|
+
height: { key: 'height', type: 'number' },
|
|
97
|
+
scaleX: { key: 'scaleX', type: 'number' },
|
|
98
|
+
scaleY: { key: 'scaleY', type: 'number' },
|
|
99
|
+
rotation: { key: 'rotation', type: 'number' },
|
|
100
|
+
pivotX: { key: 'pivotX', type: 'number' },
|
|
101
|
+
pivotY: { key: 'pivotY', type: 'number' },
|
|
102
|
+
skewX: { key: 'skewX', type: 'number' },
|
|
103
|
+
skewY: { key: 'skewY', type: 'number' },
|
|
104
|
+
alpha: { key: 'alpha', type: 'number' },
|
|
105
|
+
visible: { key: 'visible', type: 'boolean' },
|
|
106
|
+
zIndex: { key: 'zIndex', type: 'number' },
|
|
107
|
+
eventMode: { key: 'eventMode', type: 'enum', options: ['none', 'passive', 'auto', 'static', 'dynamic'] },
|
|
108
|
+
cursor: { key: 'cursor', type: 'enum', options: ['default', 'pointer', 'text', 'grab', 'grabbing'] },
|
|
109
|
+
label: { key: 'label', type: 'string' },
|
|
110
|
+
texture: { key: 'texture', type: 'string' },
|
|
111
|
+
anchorX: { key: 'anchorX', type: 'number' },
|
|
112
|
+
anchorY: { key: 'anchorY', type: 'number' },
|
|
113
|
+
tint: { key: 'tint', type: 'color' },
|
|
114
|
+
leftWidth: { key: 'leftWidth', type: 'number' },
|
|
115
|
+
rightWidth: { key: 'rightWidth', type: 'number' },
|
|
116
|
+
topHeight: { key: 'topHeight', type: 'number' },
|
|
117
|
+
bottomHeight: { key: 'bottomHeight', type: 'number' },
|
|
118
|
+
tilePositionX: { key: 'tilePositionX', type: 'number' },
|
|
119
|
+
tilePositionY: { key: 'tilePositionY', type: 'number' },
|
|
120
|
+
tileScaleX: { key: 'tileScaleX', type: 'number' },
|
|
121
|
+
tileScaleY: { key: 'tileScaleY', type: 'number' },
|
|
122
|
+
tileRotation: { key: 'tileRotation', type: 'number' },
|
|
123
|
+
text: { key: 'text', type: 'string' },
|
|
124
|
+
fontSize: { key: 'fontSize', type: 'number' },
|
|
125
|
+
fontFamily: { key: 'fontFamily', type: 'string' },
|
|
126
|
+
fontWeight: { key: 'fontWeight', type: 'enum', options: [400, 500, 600, 700, '400', '500', '600', '700', 'bold'] },
|
|
127
|
+
fill: { key: 'fill', type: 'color' },
|
|
128
|
+
shape: { key: 'shape', type: 'enum', options: ['roundRect', 'rect'] },
|
|
129
|
+
radius: { key: 'radius', type: 'number' },
|
|
130
|
+
fillAlpha: { key: 'fillAlpha', type: 'number' },
|
|
131
|
+
strokeColor: { key: 'strokeColor', type: 'color' },
|
|
132
|
+
strokeWidth: { key: 'strokeWidth', type: 'number' },
|
|
133
|
+
strokeAlpha: { key: 'strokeAlpha', type: 'number' },
|
|
134
|
+
};
|
|
135
|
+
const pixiSceneNodeSchemas = {
|
|
136
|
+
Container: {
|
|
137
|
+
type: 'Container',
|
|
138
|
+
acceptsChildren: true,
|
|
139
|
+
defaults: {
|
|
140
|
+
width: 100,
|
|
141
|
+
height: 100,
|
|
142
|
+
},
|
|
143
|
+
groups: {},
|
|
144
|
+
},
|
|
145
|
+
Sprite: {
|
|
146
|
+
type: 'Sprite',
|
|
147
|
+
acceptsChildren: false,
|
|
148
|
+
defaults: {
|
|
149
|
+
width: 96,
|
|
150
|
+
height: 96,
|
|
151
|
+
},
|
|
152
|
+
groups: {
|
|
153
|
+
sprite: pixiSceneSpriteProps,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
NineSliceSprite: {
|
|
157
|
+
type: 'NineSliceSprite',
|
|
158
|
+
acceptsChildren: false,
|
|
159
|
+
defaults: {
|
|
160
|
+
width: 160,
|
|
161
|
+
height: 80,
|
|
162
|
+
leftWidth: 10,
|
|
163
|
+
rightWidth: 10,
|
|
164
|
+
topHeight: 10,
|
|
165
|
+
bottomHeight: 10,
|
|
166
|
+
},
|
|
167
|
+
groups: {
|
|
168
|
+
sprite: pixiSceneSpriteProps,
|
|
169
|
+
nineSlice: pixiSceneNineSliceProps,
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
TilingSprite: {
|
|
173
|
+
type: 'TilingSprite',
|
|
174
|
+
acceptsChildren: false,
|
|
175
|
+
defaults: {
|
|
176
|
+
width: 160,
|
|
177
|
+
height: 96,
|
|
178
|
+
tileScaleX: 1,
|
|
179
|
+
tileScaleY: 1,
|
|
180
|
+
},
|
|
181
|
+
groups: {
|
|
182
|
+
sprite: pixiSceneSpriteProps,
|
|
183
|
+
tiling: pixiSceneTilingProps,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
Text: {
|
|
187
|
+
type: 'Text',
|
|
188
|
+
acceptsChildren: false,
|
|
189
|
+
defaults: {
|
|
190
|
+
text: 'Text',
|
|
191
|
+
width: 120,
|
|
192
|
+
height: 28,
|
|
193
|
+
fontSize: 16,
|
|
194
|
+
fill: 0x111827,
|
|
195
|
+
},
|
|
196
|
+
groups: {
|
|
197
|
+
text: pixiSceneTextProps,
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
BitmapText: {
|
|
201
|
+
type: 'BitmapText',
|
|
202
|
+
acceptsChildren: false,
|
|
203
|
+
defaults: {
|
|
204
|
+
text: 'Text',
|
|
205
|
+
width: 120,
|
|
206
|
+
height: 28,
|
|
207
|
+
fontSize: 16,
|
|
208
|
+
fill: 0x111827,
|
|
209
|
+
},
|
|
210
|
+
groups: {
|
|
211
|
+
text: pixiSceneTextProps,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
HTMLText: {
|
|
215
|
+
type: 'HTMLText',
|
|
216
|
+
acceptsChildren: false,
|
|
217
|
+
defaults: {
|
|
218
|
+
text: 'Text',
|
|
219
|
+
width: 120,
|
|
220
|
+
height: 28,
|
|
221
|
+
fontSize: 16,
|
|
222
|
+
fill: 0x111827,
|
|
223
|
+
},
|
|
224
|
+
groups: {
|
|
225
|
+
text: pixiSceneTextProps,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
Graphics: {
|
|
229
|
+
type: 'Graphics',
|
|
230
|
+
acceptsChildren: false,
|
|
231
|
+
defaults: {
|
|
232
|
+
shape: 'roundRect',
|
|
233
|
+
width: 100,
|
|
234
|
+
height: 60,
|
|
235
|
+
radius: 8,
|
|
236
|
+
fill: 0xe5e7eb,
|
|
237
|
+
},
|
|
238
|
+
groups: {
|
|
239
|
+
graphics: pixiSceneGraphicsProps,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
export function pixiSceneNodeSchema(type) {
|
|
244
|
+
return pixiSceneNodeSchemas[type];
|
|
245
|
+
}
|
|
246
|
+
export function isPixiSceneNodeType(type) {
|
|
247
|
+
return pixiSceneAddableNodeTypes.includes(type);
|
|
248
|
+
}
|
|
249
|
+
export function pixiSceneNodeDefaults(type) {
|
|
250
|
+
return { ...pixiSceneNodeSchemas[type].defaults };
|
|
251
|
+
}
|
|
252
|
+
export function pixiSceneNodeAcceptsChildren(type) {
|
|
253
|
+
return isPixiSceneNodeType(type) && pixiSceneNodeSchemas[type].acceptsChildren;
|
|
254
|
+
}
|
|
255
|
+
export function pixiSceneNodePropKeys(type) {
|
|
256
|
+
return Object.values(pixiSceneNodeSchemas[type].groups).flat();
|
|
257
|
+
}
|
|
258
|
+
export function pixiSceneNodePropGroups(type) {
|
|
259
|
+
const groups = pixiSceneNodeSchemas[type].groups;
|
|
260
|
+
return pixiSceneNodePropGroupOrder.flatMap((group) => {
|
|
261
|
+
const fields = groups[group];
|
|
262
|
+
return fields ? [{ group, fields }] : [];
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
export function pixiSceneFieldSchema(key) {
|
|
266
|
+
return pixiSceneFieldSchemas[key];
|
|
267
|
+
}
|