pixifact 0.1.3 → 0.1.5
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 +3 -3
- package/dist/builtin-scenes/CenterContainer.d.ts +13 -0
- package/dist/builtin-scenes/CenterContainer.js +71 -0
- package/dist/builtin-scenes/CenterContainer.scene +3 -0
- package/dist/builtin-scenes/CenterContainer.ts +77 -0
- package/dist/builtin-scenes/Control.d.ts +44 -0
- package/dist/builtin-scenes/Control.js +206 -0
- package/dist/builtin-scenes/Control.scene +3 -0
- package/dist/builtin-scenes/Control.ts +233 -0
- package/dist/builtin-scenes/FlexItem.d.ts +45 -0
- package/dist/builtin-scenes/FlexItem.js +164 -0
- package/dist/builtin-scenes/FlexItem.scene +3 -0
- package/dist/builtin-scenes/FlexItem.ts +180 -0
- package/dist/builtin-scenes/FlexLayout.d.ts +29 -0
- package/dist/builtin-scenes/FlexLayout.js +358 -0
- package/dist/builtin-scenes/FlexLayout.scene +3 -0
- package/dist/builtin-scenes/FlexLayout.ts +409 -0
- package/dist/builtin-scenes/HBoxContainer.d.ts +15 -0
- package/dist/builtin-scenes/HBoxContainer.js +70 -0
- package/dist/builtin-scenes/HBoxContainer.scene +3 -0
- package/dist/builtin-scenes/HBoxContainer.ts +75 -0
- package/dist/builtin-scenes/MarginContainer.d.ts +23 -0
- package/dist/builtin-scenes/MarginContainer.js +131 -0
- package/dist/builtin-scenes/MarginContainer.scene +3 -0
- package/dist/builtin-scenes/MarginContainer.ts +139 -0
- package/dist/builtin-scenes/VBoxContainer.d.ts +15 -0
- package/dist/builtin-scenes/VBoxContainer.js +70 -0
- package/dist/builtin-scenes/VBoxContainer.scene +3 -0
- package/dist/builtin-scenes/VBoxContainer.ts +75 -0
- package/dist/builtin-scenes/controlLayout.d.ts +57 -0
- package/dist/builtin-scenes/controlLayout.js +202 -0
- package/dist/builtin-scenes/controlLayout.ts +270 -0
- package/dist/compiler/builtinScenes.d.ts +14 -0
- package/dist/compiler/builtinScenes.js +62 -0
- package/dist/compiler/compileScenes.js +126 -19
- package/dist/compiler/decorators.js +3 -0
- package/dist/compiler/index.d.ts +1 -0
- package/dist/compiler/index.js +1 -0
- package/dist/compiler/sceneAssetPair.js +19 -0
- package/dist/compiler/sceneRuntime.d.ts +5 -4
- package/dist/compiler/scriptInterfaceExtractor.d.ts +5 -0
- package/dist/compiler/scriptInterfaceExtractor.js +214 -8
- package/dist/compiler/spec.d.ts +2 -0
- package/dist/compiler/templateParser.js +4 -3
- package/dist/compiler/templateSerializer.js +2 -1
- package/dist/compiler/typescriptCompiler.js +87 -13
- package/dist/compiler-node/builtinSceneAssets.d.ts +8 -0
- package/dist/compiler-node/builtinSceneAssets.js +57 -0
- package/dist/compiler-node/index.d.ts +1 -0
- package/dist/compiler-node/index.js +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +24 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.js +2 -5
- package/dist/{authoring/ProjectConfig.d.ts → project/index.d.ts} +7 -0
- package/dist/{authoring/ProjectConfig.js → project/index.js} +22 -0
- package/dist/runtime/Group.d.ts +18 -0
- package/dist/runtime/Group.js +45 -0
- package/dist/runtime/index.d.ts +1 -9
- package/dist/runtime/index.js +1 -9
- package/package.json +4 -26
- package/dist/authoring/ActionRegistry.d.ts +0 -10
- package/dist/authoring/ActionRegistry.js +0 -26
- package/dist/authoring/ComponentPalette.d.ts +0 -16
- package/dist/authoring/ComponentPalette.js +0 -50
- package/dist/authoring/DesignToken.d.ts +0 -16
- package/dist/authoring/DesignToken.js +0 -33
- package/dist/authoring/DiffModel.d.ts +0 -10
- package/dist/authoring/DiffModel.js +0 -104
- package/dist/authoring/InspectorModel.d.ts +0 -27
- package/dist/authoring/InspectorModel.js +0 -139
- package/dist/authoring/LogicGraph.d.ts +0 -66
- package/dist/authoring/LogicGraph.js +0 -184
- package/dist/authoring/OverrideJournal.d.ts +0 -18
- package/dist/authoring/OverrideJournal.js +0 -23
- package/dist/authoring/PreferenceMemory.d.ts +0 -21
- package/dist/authoring/PreferenceMemory.js +0 -39
- package/dist/authoring/RuntimePreview.d.ts +0 -11
- package/dist/authoring/RuntimePreview.js +0 -25
- package/dist/authoring/SceneDocument.d.ts +0 -74
- package/dist/authoring/SceneDocument.js +0 -332
- package/dist/authoring/SceneProjectState.d.ts +0 -20
- package/dist/authoring/SceneProjectState.js +0 -8
- package/dist/authoring/SceneSelection.d.ts +0 -11
- package/dist/authoring/SceneSelection.js +0 -1
- package/dist/authoring/index.d.ts +0 -13
- package/dist/authoring/index.js +0 -13
- package/dist/commands/Command.d.ts +0 -63
- package/dist/commands/Command.js +0 -1
- package/dist/commands/CommandStack.d.ts +0 -14
- package/dist/commands/CommandStack.js +0 -45
- package/dist/commands/applyCommand.d.ts +0 -23
- package/dist/commands/applyCommand.js +0 -316
- package/dist/commands/index.d.ts +0 -4
- package/dist/commands/index.js +0 -4
- package/dist/commands/utils.d.ts +0 -17
- package/dist/commands/utils.js +0 -77
- package/dist/commands/validateCommand.d.ts +0 -12
- package/dist/commands/validateCommand.js +0 -285
- package/dist/nodes/Input.d.ts +0 -91
- package/dist/nodes/Input.js +0 -352
- package/dist/nodes/Textarea.d.ts +0 -10
- package/dist/nodes/Textarea.js +0 -38
- package/dist/nodes/components/Button.d.ts +0 -8
- package/dist/nodes/components/Button.js +0 -45
- package/dist/nodes/components/InputField.d.ts +0 -12
- package/dist/nodes/components/InputField.js +0 -53
- package/dist/nodes/components/ProgressBar.d.ts +0 -14
- package/dist/nodes/components/ProgressBar.js +0 -66
- package/dist/nodes/components/ScrollRect.d.ts +0 -23
- package/dist/nodes/components/ScrollRect.js +0 -108
- package/dist/nodes/components/Selectable.d.ts +0 -32
- package/dist/nodes/components/Selectable.js +0 -153
- package/dist/nodes/components/index.d.ts +0 -5
- package/dist/nodes/components/index.js +0 -5
- package/dist/nodes/graphics/Graphic.d.ts +0 -14
- package/dist/nodes/graphics/Graphic.js +0 -47
- package/dist/nodes/graphics/ImageGraphic.d.ts +0 -9
- package/dist/nodes/graphics/ImageGraphic.js +0 -42
- package/dist/nodes/graphics/RoundedRectGraphic.d.ts +0 -13
- package/dist/nodes/graphics/RoundedRectGraphic.js +0 -65
- package/dist/nodes/graphics/TextGraphic.d.ts +0 -13
- package/dist/nodes/graphics/TextGraphic.js +0 -70
- package/dist/nodes/graphics/index.d.ts +0 -4
- package/dist/nodes/graphics/index.js +0 -4
- package/dist/nodes/index.d.ts +0 -3
- package/dist/nodes/index.js +0 -3
- package/dist/runtime/Application.d.ts +0 -15
- package/dist/runtime/Application.js +0 -67
- package/dist/runtime/GameObject.d.ts +0 -100
- package/dist/runtime/GameObject.js +0 -297
- package/dist/runtime/GameObjectEvent.d.ts +0 -52
- package/dist/runtime/GameObjectEvent.js +0 -38
- package/dist/runtime/Transform.d.ts +0 -32
- package/dist/runtime/Transform.js +0 -157
- package/dist/runtime/component/Component.d.ts +0 -13
- package/dist/runtime/component/Component.js +0 -13
- package/dist/runtime/component/ComponentRegistry.d.ts +0 -49
- package/dist/runtime/component/ComponentRegistry.js +0 -25
- package/dist/runtime/component/Flex.d.ts +0 -6
- package/dist/runtime/component/Flex.js +0 -15
- package/dist/runtime/component/FlexGroup.d.ts +0 -26
- package/dist/runtime/component/FlexGroup.js +0 -136
- package/dist/runtime/component/GridLayout.d.ts +0 -47
- package/dist/runtime/component/GridLayout.js +0 -129
- package/dist/runtime/component/Layout.d.ts +0 -104
- package/dist/runtime/component/Layout.js +0 -248
- package/dist/runtime/component/decorators.d.ts +0 -4
- package/dist/runtime/component/decorators.js +0 -52
- package/dist/runtime/component/index.d.ts +0 -7
- package/dist/runtime/component/index.js +0 -7
- package/dist/runtime/graphics/index.d.ts +0 -11
- package/dist/runtime/graphics/index.js +0 -29
- package/dist/runtime/group/index.d.ts +0 -39
- package/dist/runtime/group/index.js +0 -102
- package/dist/runtime/image/Image.d.ts +0 -19
- package/dist/runtime/image/Image.js +0 -60
- package/dist/runtime/image/NineSliceImage.d.ts +0 -23
- package/dist/runtime/image/NineSliceImage.js +0 -64
- package/dist/runtime/image/index.d.ts +0 -2
- package/dist/runtime/image/index.js +0 -2
- package/dist/runtime/label/Label.d.ts +0 -11
- package/dist/runtime/label/Label.js +0 -26
- package/dist/runtime/label/LabelStyle.d.ts +0 -3
- package/dist/runtime/label/LabelStyle.js +0 -3
- package/dist/runtime/label/index.d.ts +0 -2
- package/dist/runtime/label/index.js +0 -2
- package/dist/runtime/utils/index.d.ts +0 -1
- package/dist/runtime/utils/index.js +0 -1
- package/dist/runtime/utils/onlyOnceQueueMicrotask.d.ts +0 -1
- package/dist/runtime/utils/onlyOnceQueueMicrotask.js +0 -12
- package/dist/runtime/utils/setProps.d.ts +0 -10
- package/dist/runtime/utils/setProps.js +0 -17
- package/dist/scene/dsl.d.ts +0 -25
- package/dist/scene/dsl.js +0 -112
- package/dist/scene/index.d.ts +0 -5
- package/dist/scene/index.js +0 -5
- package/dist/scene/instantiate.d.ts +0 -8
- package/dist/scene/instantiate.js +0 -208
- package/dist/scene/nodesDsl.d.ts +0 -42
- package/dist/scene/nodesDsl.js +0 -169
- package/dist/scene/spec.d.ts +0 -100
- package/dist/scene/spec.js +0 -1
- package/dist/scene/templates.d.ts +0 -21
- package/dist/scene/templates.js +0 -239
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
function hasNumberValue(record, value) {
|
|
2
|
-
return typeof value === 'number' && !!record && Object.values(record).includes(value);
|
|
3
|
-
}
|
|
4
|
-
export function validateDesignTokenValue(tokens, target, prop, value) {
|
|
5
|
-
if (!tokens) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
if ((prop === 'color' || prop.toLowerCase().includes('color')) && !hasNumberValue(tokens.colors, value)) {
|
|
9
|
-
return {
|
|
10
|
-
target,
|
|
11
|
-
value,
|
|
12
|
-
message: `${target} uses color ${String(value)} outside design tokens.`,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
if ((prop === 'radius' || prop.toLowerCase().includes('radius')) && !hasNumberValue(tokens.radius, value)) {
|
|
16
|
-
return {
|
|
17
|
-
target,
|
|
18
|
-
value,
|
|
19
|
-
message: `${target} uses radius ${String(value)} outside design tokens.`,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
if ((prop === 'x' || prop === 'y' || prop === 'width' || prop === 'height') && typeof value === 'number' && tokens.spacing) {
|
|
23
|
-
const spacingValues = Object.values(tokens.spacing);
|
|
24
|
-
if (spacingValues.length > 0 && !spacingValues.some((spacing) => value % spacing === 0)) {
|
|
25
|
-
return {
|
|
26
|
-
target,
|
|
27
|
-
value,
|
|
28
|
-
message: `${target} uses ${prop}=${value}, which does not align to spacing tokens.`,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { SceneCommand } from "../commands/index.js";
|
|
2
|
-
import type { SceneSpec } from "../scene/index.js";
|
|
3
|
-
export interface DiffEntry {
|
|
4
|
-
target: string;
|
|
5
|
-
before: unknown;
|
|
6
|
-
after: unknown;
|
|
7
|
-
command: SceneCommand;
|
|
8
|
-
}
|
|
9
|
-
export declare function diffCommand(scene: SceneSpec, command: SceneCommand): DiffEntry[];
|
|
10
|
-
export declare function diffCommands(scene: SceneSpec, commands: SceneCommand[]): DiffEntry[];
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { findComponent, findNode } from "../commands/utils.js";
|
|
2
|
-
function formatTarget(parts) {
|
|
3
|
-
return parts.filter(Boolean).join('.');
|
|
4
|
-
}
|
|
5
|
-
export function diffCommand(scene, command) {
|
|
6
|
-
switch (command.op) {
|
|
7
|
-
case 'setNodeProp': {
|
|
8
|
-
const node = findNode(scene, command.node)?.node;
|
|
9
|
-
return [{
|
|
10
|
-
target: formatTarget([command.node, command.prop]),
|
|
11
|
-
before: node?.[command.prop],
|
|
12
|
-
after: command.value,
|
|
13
|
-
command,
|
|
14
|
-
}];
|
|
15
|
-
}
|
|
16
|
-
case 'setTransform': {
|
|
17
|
-
const node = findNode(scene, command.node)?.node;
|
|
18
|
-
return Object.entries(command.values).map(([key, value]) => ({
|
|
19
|
-
target: formatTarget([command.node, 'transform', key]),
|
|
20
|
-
before: node?.transform?.[key],
|
|
21
|
-
after: value,
|
|
22
|
-
command,
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
case 'setNodeData': {
|
|
26
|
-
const node = findNode(scene, command.node)?.node;
|
|
27
|
-
const data = node && node.kind === command.field
|
|
28
|
-
? node[command.field]
|
|
29
|
-
: undefined;
|
|
30
|
-
return [{
|
|
31
|
-
target: formatTarget([command.node, command.field, command.prop]),
|
|
32
|
-
before: data?.[command.prop],
|
|
33
|
-
after: command.value,
|
|
34
|
-
command,
|
|
35
|
-
}];
|
|
36
|
-
}
|
|
37
|
-
case 'setComponentProp': {
|
|
38
|
-
const node = findNode(scene, command.node)?.node;
|
|
39
|
-
const component = node ? findComponent(node, command.component)?.component : undefined;
|
|
40
|
-
return [{
|
|
41
|
-
target: formatTarget([command.node, command.component, command.prop]),
|
|
42
|
-
before: component?.props?.[command.prop],
|
|
43
|
-
after: command.value,
|
|
44
|
-
command,
|
|
45
|
-
}];
|
|
46
|
-
}
|
|
47
|
-
case 'addComponent':
|
|
48
|
-
return [{
|
|
49
|
-
target: formatTarget([command.node, command.component.id ?? command.component.type]),
|
|
50
|
-
before: undefined,
|
|
51
|
-
after: command.component,
|
|
52
|
-
command,
|
|
53
|
-
}];
|
|
54
|
-
case 'removeComponent': {
|
|
55
|
-
const node = findNode(scene, command.node)?.node;
|
|
56
|
-
const component = node ? findComponent(node, command.component)?.component : undefined;
|
|
57
|
-
return [{
|
|
58
|
-
target: formatTarget([command.node, command.component]),
|
|
59
|
-
before: component,
|
|
60
|
-
after: undefined,
|
|
61
|
-
command,
|
|
62
|
-
}];
|
|
63
|
-
}
|
|
64
|
-
case 'createNode':
|
|
65
|
-
return [{
|
|
66
|
-
target: formatTarget([command.parent ?? 'root', command.node.id ?? command.node.key ?? command.node.name]),
|
|
67
|
-
before: undefined,
|
|
68
|
-
after: command.node,
|
|
69
|
-
command,
|
|
70
|
-
}];
|
|
71
|
-
case 'deleteNode': {
|
|
72
|
-
const node = findNode(scene, command.node)?.node;
|
|
73
|
-
return [{
|
|
74
|
-
target: command.node,
|
|
75
|
-
before: node,
|
|
76
|
-
after: undefined,
|
|
77
|
-
command,
|
|
78
|
-
}];
|
|
79
|
-
}
|
|
80
|
-
case 'reparentNode': {
|
|
81
|
-
const node = findNode(scene, command.node);
|
|
82
|
-
return [{
|
|
83
|
-
target: formatTarget([command.node, 'parent']),
|
|
84
|
-
before: node?.parent?.key ?? node?.parent?.id ?? node?.parent?.name,
|
|
85
|
-
after: command.parent ?? 'root',
|
|
86
|
-
command,
|
|
87
|
-
}];
|
|
88
|
-
}
|
|
89
|
-
case 'reorderNode': {
|
|
90
|
-
const node = findNode(scene, command.node);
|
|
91
|
-
return [{
|
|
92
|
-
target: formatTarget([command.node, 'index']),
|
|
93
|
-
before: node?.index,
|
|
94
|
-
after: command.index,
|
|
95
|
-
command,
|
|
96
|
-
}];
|
|
97
|
-
}
|
|
98
|
-
case 'batch':
|
|
99
|
-
return diffCommands(scene, command.commands);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export function diffCommands(scene, commands) {
|
|
103
|
-
return commands.flatMap((command) => diffCommand(scene, command));
|
|
104
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ComponentSchema, PropSchema } from "../runtime/index.js";
|
|
2
|
-
import type { NodeSpec, SceneSpec } from "../scene/index.js";
|
|
3
|
-
export interface InspectorFieldModel {
|
|
4
|
-
key: string;
|
|
5
|
-
label: string;
|
|
6
|
-
type: string;
|
|
7
|
-
value: unknown;
|
|
8
|
-
schema?: PropSchema;
|
|
9
|
-
}
|
|
10
|
-
export interface InspectorComponentModel {
|
|
11
|
-
id?: string;
|
|
12
|
-
type: string;
|
|
13
|
-
displayName: string;
|
|
14
|
-
schema?: ComponentSchema;
|
|
15
|
-
fields: InspectorFieldModel[];
|
|
16
|
-
}
|
|
17
|
-
export interface InspectorNodeModel {
|
|
18
|
-
id?: string;
|
|
19
|
-
key?: string;
|
|
20
|
-
role?: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
kind: NodeSpec['kind'];
|
|
23
|
-
transform: InspectorFieldModel[];
|
|
24
|
-
display: InspectorComponentModel[];
|
|
25
|
-
components: InspectorComponentModel[];
|
|
26
|
-
}
|
|
27
|
-
export declare function buildInspectorModel(scene: SceneSpec, nodeLocator: string): InspectorNodeModel | undefined;
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { ComponentRegistry } from "../runtime/index.js";
|
|
2
|
-
import { findNode } from "../commands/utils.js";
|
|
3
|
-
const transformFields = [
|
|
4
|
-
'x',
|
|
5
|
-
'y',
|
|
6
|
-
'width',
|
|
7
|
-
'height',
|
|
8
|
-
'anchorX',
|
|
9
|
-
'anchorY',
|
|
10
|
-
'scaleX',
|
|
11
|
-
'scaleY',
|
|
12
|
-
'rotation',
|
|
13
|
-
];
|
|
14
|
-
function buildTransformFields(node) {
|
|
15
|
-
const transform = node.transform ?? {};
|
|
16
|
-
return transformFields.map((key) => ({
|
|
17
|
-
key,
|
|
18
|
-
label: key,
|
|
19
|
-
type: 'number',
|
|
20
|
-
value: transform[key],
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
function field(key, type, value, schema) {
|
|
24
|
-
return {
|
|
25
|
-
key,
|
|
26
|
-
label: key,
|
|
27
|
-
type,
|
|
28
|
-
value,
|
|
29
|
-
schema,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function enumSchema(key, options) {
|
|
33
|
-
return {
|
|
34
|
-
key,
|
|
35
|
-
type: 'enum',
|
|
36
|
-
options,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function buildDisplayModel(node) {
|
|
40
|
-
switch (node.kind) {
|
|
41
|
-
case 'image':
|
|
42
|
-
return [{
|
|
43
|
-
type: 'node.image',
|
|
44
|
-
displayName: 'Image',
|
|
45
|
-
fields: [
|
|
46
|
-
field('mode', 'enum', node.image?.mode, enumSchema('mode', ['sprite', 'nineSlice'])),
|
|
47
|
-
field('src', 'string', node.image?.src),
|
|
48
|
-
field('tint', 'color', node.image?.tint),
|
|
49
|
-
field('leftWidth', 'number', node.image?.leftWidth),
|
|
50
|
-
field('rightWidth', 'number', node.image?.rightWidth),
|
|
51
|
-
field('topHeight', 'number', node.image?.topHeight),
|
|
52
|
-
field('bottomHeight', 'number', node.image?.bottomHeight),
|
|
53
|
-
],
|
|
54
|
-
}];
|
|
55
|
-
case 'text':
|
|
56
|
-
return [{
|
|
57
|
-
type: 'node.text',
|
|
58
|
-
displayName: 'Text',
|
|
59
|
-
fields: [
|
|
60
|
-
field('value', 'string', node.text?.value),
|
|
61
|
-
field('color', 'color', node.text?.color),
|
|
62
|
-
field('fontSize', 'number', node.text?.fontSize),
|
|
63
|
-
field('fontFamily', 'string', Array.isArray(node.text?.fontFamily) ? node.text.fontFamily.join(',') : node.text?.fontFamily),
|
|
64
|
-
field('fontWeight', 'enum', node.text?.fontWeight, enumSchema('fontWeight', ['normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900'])),
|
|
65
|
-
field('center', 'boolean', node.text?.center),
|
|
66
|
-
],
|
|
67
|
-
}];
|
|
68
|
-
case 'input':
|
|
69
|
-
return [{
|
|
70
|
-
type: 'node.input',
|
|
71
|
-
displayName: 'Input',
|
|
72
|
-
fields: [
|
|
73
|
-
field('value', 'string', node.input?.value),
|
|
74
|
-
field('backgroundColor', 'color', node.input?.backgroundColor),
|
|
75
|
-
field('borderColor', 'color', node.input?.borderColor),
|
|
76
|
-
field('borderSize', 'number', node.input?.borderSize),
|
|
77
|
-
field('textColor', 'string', node.input?.textColor),
|
|
78
|
-
field('fontSize', 'number', node.input?.fontSize),
|
|
79
|
-
field('fontFamily', 'string', Array.isArray(node.input?.fontFamily) ? node.input.fontFamily.join(',') : node.input?.fontFamily),
|
|
80
|
-
field('paddingLeft', 'number', node.input?.paddingLeft),
|
|
81
|
-
field('paddingRight', 'number', node.input?.paddingRight),
|
|
82
|
-
field('paddingTop', 'number', node.input?.paddingTop),
|
|
83
|
-
field('paddingBottom', 'number', node.input?.paddingBottom),
|
|
84
|
-
],
|
|
85
|
-
}];
|
|
86
|
-
case 'shape':
|
|
87
|
-
return [{
|
|
88
|
-
type: 'node.shape',
|
|
89
|
-
displayName: 'Shape',
|
|
90
|
-
fields: [
|
|
91
|
-
field('type', 'enum', node.shape?.type, enumSchema('type', ['rect', 'roundedRect'])),
|
|
92
|
-
field('color', 'color', node.shape?.color),
|
|
93
|
-
field('fillAlpha', 'number', node.shape?.fillAlpha),
|
|
94
|
-
field('radius', 'number', node.shape?.radius),
|
|
95
|
-
field('strokeColor', 'color', node.shape?.strokeColor),
|
|
96
|
-
field('strokeWidth', 'number', node.shape?.strokeWidth),
|
|
97
|
-
field('strokeAlpha', 'number', node.shape?.strokeAlpha),
|
|
98
|
-
],
|
|
99
|
-
}];
|
|
100
|
-
case 'container':
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function buildComponentFields(component, schema) {
|
|
105
|
-
return (schema?.props ?? []).filter((prop) => !prop.hidden).map((prop) => ({
|
|
106
|
-
key: prop.key,
|
|
107
|
-
label: prop.key,
|
|
108
|
-
type: prop.type,
|
|
109
|
-
value: component.props?.[prop.key] ?? prop.default,
|
|
110
|
-
schema: prop,
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
function buildComponentModel(component) {
|
|
114
|
-
const schema = ComponentRegistry.get(component.type);
|
|
115
|
-
return {
|
|
116
|
-
id: component.id,
|
|
117
|
-
type: component.type,
|
|
118
|
-
displayName: schema?.displayName ?? component.type,
|
|
119
|
-
schema,
|
|
120
|
-
fields: buildComponentFields(component, schema),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
export function buildInspectorModel(scene, nodeLocator) {
|
|
124
|
-
const located = findNode(scene, nodeLocator);
|
|
125
|
-
if (!located) {
|
|
126
|
-
return undefined;
|
|
127
|
-
}
|
|
128
|
-
const node = located.node;
|
|
129
|
-
return {
|
|
130
|
-
id: node.id,
|
|
131
|
-
key: node.key,
|
|
132
|
-
role: node.role,
|
|
133
|
-
name: node.name,
|
|
134
|
-
kind: node.kind,
|
|
135
|
-
transform: buildTransformFields(node),
|
|
136
|
-
display: buildDisplayModel(node),
|
|
137
|
-
components: (node.components ?? []).map(buildComponentModel),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { SceneSpec } from "../scene/index.js";
|
|
2
|
-
import type { ActionSpec } from "./ActionRegistry.js";
|
|
3
|
-
export type LogicValue = {
|
|
4
|
-
kind: 'const';
|
|
5
|
-
value: unknown;
|
|
6
|
-
} | {
|
|
7
|
-
kind: 'state';
|
|
8
|
-
path: string;
|
|
9
|
-
} | {
|
|
10
|
-
kind: 'payload';
|
|
11
|
-
path: string;
|
|
12
|
-
};
|
|
13
|
-
export type LogicConditionOperator = 'eq' | 'neq' | 'lt' | 'lte' | 'gt' | 'gte' | 'truthy' | 'falsy';
|
|
14
|
-
export interface LogicConditionSpec {
|
|
15
|
-
left: LogicValue;
|
|
16
|
-
op: LogicConditionOperator;
|
|
17
|
-
right?: LogicValue;
|
|
18
|
-
}
|
|
19
|
-
export type LogicStepSpec = {
|
|
20
|
-
id: string;
|
|
21
|
-
type: 'condition';
|
|
22
|
-
condition: LogicConditionSpec;
|
|
23
|
-
} | {
|
|
24
|
-
id: string;
|
|
25
|
-
type: 'setState';
|
|
26
|
-
path: string;
|
|
27
|
-
value: LogicValue;
|
|
28
|
-
} | {
|
|
29
|
-
id: string;
|
|
30
|
-
type: 'setNodeVisible';
|
|
31
|
-
node: string;
|
|
32
|
-
visible: boolean;
|
|
33
|
-
} | {
|
|
34
|
-
id: string;
|
|
35
|
-
type: 'emitAction';
|
|
36
|
-
action: string;
|
|
37
|
-
} | {
|
|
38
|
-
id: string;
|
|
39
|
-
type: 'comment';
|
|
40
|
-
text: string;
|
|
41
|
-
};
|
|
42
|
-
export interface LogicFlowSpec {
|
|
43
|
-
id: string;
|
|
44
|
-
action: string;
|
|
45
|
-
name?: string;
|
|
46
|
-
description?: string;
|
|
47
|
-
steps: LogicStepSpec[];
|
|
48
|
-
}
|
|
49
|
-
export interface LogicGraphSpec {
|
|
50
|
-
version: 1;
|
|
51
|
-
type: 'pixifact.logicGraph';
|
|
52
|
-
flows: LogicFlowSpec[];
|
|
53
|
-
}
|
|
54
|
-
export interface LogicValidationContext {
|
|
55
|
-
actions?: readonly ActionSpec[];
|
|
56
|
-
scene?: SceneSpec;
|
|
57
|
-
}
|
|
58
|
-
export interface LogicValidationResult {
|
|
59
|
-
ok: boolean;
|
|
60
|
-
errors: string[];
|
|
61
|
-
}
|
|
62
|
-
export declare function createLogicGraph(flows?: LogicFlowSpec[]): LogicGraphSpec;
|
|
63
|
-
export declare function createUseInventoryItemFlow(): LogicFlowSpec;
|
|
64
|
-
export declare function validateLogicGraph(graph: LogicGraphSpec, context?: LogicValidationContext): LogicValidationResult;
|
|
65
|
-
export declare function compileLogicGraphToTypescript(graph: LogicGraphSpec): string;
|
|
66
|
-
export declare function summarizeLogicGraphForAi(graph: LogicGraphSpec | undefined): string;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { findNode } from "../commands/utils.js";
|
|
2
|
-
import { actionExists } from "./ActionRegistry.js";
|
|
3
|
-
export function createLogicGraph(flows = []) {
|
|
4
|
-
return {
|
|
5
|
-
version: 1,
|
|
6
|
-
type: 'pixifact.logicGraph',
|
|
7
|
-
flows,
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export function createUseInventoryItemFlow() {
|
|
11
|
-
return {
|
|
12
|
-
id: 'flow-useInventoryItem',
|
|
13
|
-
action: 'useInventoryItem',
|
|
14
|
-
name: 'Use Inventory Item',
|
|
15
|
-
description: 'Decrease item quantity and remove empty inventory slots.',
|
|
16
|
-
steps: [
|
|
17
|
-
{
|
|
18
|
-
id: 'hasQuantity',
|
|
19
|
-
type: 'condition',
|
|
20
|
-
condition: {
|
|
21
|
-
left: { kind: 'state', path: 'selectedItem.quantity' },
|
|
22
|
-
op: 'gt',
|
|
23
|
-
right: { kind: 'const', value: 0 },
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: 'decreaseQuantity',
|
|
28
|
-
type: 'setState',
|
|
29
|
-
path: 'selectedItem.quantity',
|
|
30
|
-
value: { kind: 'state', path: 'selectedItem.quantity - 1' },
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
id: 'removeEmptySlot',
|
|
34
|
-
type: 'comment',
|
|
35
|
-
text: 'When quantity reaches zero, remove or hide the inventory slot in game code.',
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function validateValue(value, errors, target) {
|
|
41
|
-
if (value.kind !== 'const' && !value.path) {
|
|
42
|
-
errors.push(`${target} requires a path.`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function validateStep(step, flow, context, errors) {
|
|
46
|
-
if (!step.id) {
|
|
47
|
-
errors.push(`Logic flow "${flow.id}" contains a step without id.`);
|
|
48
|
-
}
|
|
49
|
-
switch (step.type) {
|
|
50
|
-
case 'condition':
|
|
51
|
-
validateValue(step.condition.left, errors, `${step.id}.condition.left`);
|
|
52
|
-
if (step.condition.op !== 'truthy' && step.condition.op !== 'falsy' && !step.condition.right) {
|
|
53
|
-
errors.push(`${step.id}.condition.right is required for ${step.condition.op}.`);
|
|
54
|
-
}
|
|
55
|
-
if (step.condition.right) {
|
|
56
|
-
validateValue(step.condition.right, errors, `${step.id}.condition.right`);
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case 'setState':
|
|
60
|
-
if (!step.path) {
|
|
61
|
-
errors.push(`${step.id}.path is required.`);
|
|
62
|
-
}
|
|
63
|
-
validateValue(step.value, errors, `${step.id}.value`);
|
|
64
|
-
break;
|
|
65
|
-
case 'setNodeVisible':
|
|
66
|
-
if (context.scene && !findNode(context.scene, step.node)) {
|
|
67
|
-
errors.push(`${step.id} references missing node "${step.node}".`);
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
case 'emitAction':
|
|
71
|
-
if (context.actions && !actionExists(context.actions, step.action)) {
|
|
72
|
-
errors.push(`${step.id} emits undeclared action "${step.action}".`);
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
case 'comment':
|
|
76
|
-
if (!step.text) {
|
|
77
|
-
errors.push(`${step.id}.text is required.`);
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export function validateLogicGraph(graph, context = {}) {
|
|
83
|
-
const errors = [];
|
|
84
|
-
if (graph.type !== 'pixifact.logicGraph') {
|
|
85
|
-
errors.push('Logic graph type must be "pixifact.logicGraph".');
|
|
86
|
-
}
|
|
87
|
-
const flowIds = new Set();
|
|
88
|
-
for (const flow of graph.flows) {
|
|
89
|
-
if (!flow.id) {
|
|
90
|
-
errors.push('Logic flow id is required.');
|
|
91
|
-
}
|
|
92
|
-
if (flowIds.has(flow.id)) {
|
|
93
|
-
errors.push(`Duplicate logic flow id "${flow.id}".`);
|
|
94
|
-
}
|
|
95
|
-
flowIds.add(flow.id);
|
|
96
|
-
if (context.actions && !actionExists(context.actions, flow.action)) {
|
|
97
|
-
errors.push(`Logic flow "${flow.id}" references undeclared action "${flow.action}".`);
|
|
98
|
-
}
|
|
99
|
-
for (const step of flow.steps) {
|
|
100
|
-
validateStep(step, flow, context, errors);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
ok: errors.length === 0,
|
|
105
|
-
errors,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function accessPath(root, path) {
|
|
109
|
-
if (path.includes(' - ') || path.includes(' + ')) {
|
|
110
|
-
const [left, operator, right] = path.split(/\s+/);
|
|
111
|
-
const numeric = Number(right);
|
|
112
|
-
if ((operator === '-' || operator === '+') && Number.isFinite(numeric)) {
|
|
113
|
-
return `(${accessPath(root, left)} ${operator} ${JSON.stringify(numeric)})`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return `${root}${path.split('.').map((part) => `[${JSON.stringify(part)}]`).join('')}`;
|
|
117
|
-
}
|
|
118
|
-
function compileValue(value) {
|
|
119
|
-
switch (value.kind) {
|
|
120
|
-
case 'const':
|
|
121
|
-
return JSON.stringify(value.value);
|
|
122
|
-
case 'state':
|
|
123
|
-
return accessPath('context.state', value.path);
|
|
124
|
-
case 'payload':
|
|
125
|
-
return accessPath('payload', value.path);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function compileCondition(condition) {
|
|
129
|
-
const left = compileValue(condition.left);
|
|
130
|
-
const right = condition.right ? compileValue(condition.right) : undefined;
|
|
131
|
-
switch (condition.op) {
|
|
132
|
-
case 'truthy':
|
|
133
|
-
return `Boolean(${left})`;
|
|
134
|
-
case 'falsy':
|
|
135
|
-
return `!Boolean(${left})`;
|
|
136
|
-
case 'eq':
|
|
137
|
-
return `${left} === ${right}`;
|
|
138
|
-
case 'neq':
|
|
139
|
-
return `${left} !== ${right}`;
|
|
140
|
-
case 'lt':
|
|
141
|
-
return `${left} < ${right}`;
|
|
142
|
-
case 'lte':
|
|
143
|
-
return `${left} <= ${right}`;
|
|
144
|
-
case 'gt':
|
|
145
|
-
return `${left} > ${right}`;
|
|
146
|
-
case 'gte':
|
|
147
|
-
return `${left} >= ${right}`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
function compileStep(step) {
|
|
151
|
-
switch (step.type) {
|
|
152
|
-
case 'condition':
|
|
153
|
-
return ` if (!(${compileCondition(step.condition)})) return;`;
|
|
154
|
-
case 'setState':
|
|
155
|
-
return ` ${accessPath('context.state', step.path)} = ${compileValue(step.value)};`;
|
|
156
|
-
case 'setNodeVisible':
|
|
157
|
-
return ` context.setNodeVisible?.(${JSON.stringify(step.node)}, ${JSON.stringify(step.visible)});`;
|
|
158
|
-
case 'emitAction':
|
|
159
|
-
return ` context.emit?.(${JSON.stringify(step.action)});`;
|
|
160
|
-
case 'comment':
|
|
161
|
-
return ` // ${step.text.replaceAll('\n', ' ')}`;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
export function compileLogicGraphToTypescript(graph) {
|
|
165
|
-
const handlers = graph.flows.map((flow) => {
|
|
166
|
-
const steps = flow.steps.map(compileStep).join('\n');
|
|
167
|
-
return ` ${JSON.stringify(flow.action)}(context: LogicRuntimeContext, payload: Record<string, unknown> = {}) {\n${steps}\n },`;
|
|
168
|
-
}).join('\n');
|
|
169
|
-
return `export interface LogicRuntimeContext {
|
|
170
|
-
state: Record<string, unknown>;
|
|
171
|
-
emit?: (action: string, payload?: unknown) => void;
|
|
172
|
-
setNodeVisible?: (node: string, visible: boolean) => void;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export const logicHandlers = {
|
|
176
|
-
${handlers}
|
|
177
|
-
};
|
|
178
|
-
`;
|
|
179
|
-
}
|
|
180
|
-
export function summarizeLogicGraphForAi(graph) {
|
|
181
|
-
return (graph?.flows ?? [])
|
|
182
|
-
.map((flow) => `- ${flow.action}: ${flow.steps.map((step) => step.type).join(' -> ')}`)
|
|
183
|
-
.join('\n');
|
|
184
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface LockSpec {
|
|
2
|
-
target: 'transform' | 'component' | 'nodeData';
|
|
3
|
-
node: string;
|
|
4
|
-
field?: string;
|
|
5
|
-
component?: string;
|
|
6
|
-
prop: string;
|
|
7
|
-
reason?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface OverrideSpec {
|
|
10
|
-
source: 'manual' | 'agent';
|
|
11
|
-
target: string;
|
|
12
|
-
before: unknown;
|
|
13
|
-
after: unknown;
|
|
14
|
-
reason?: string;
|
|
15
|
-
timestamp: number;
|
|
16
|
-
}
|
|
17
|
-
export declare function lockKey(lock: Omit<LockSpec, 'reason'>): string;
|
|
18
|
-
export declare function isLocked(locks: readonly LockSpec[] | undefined, candidate: Omit<LockSpec, 'reason'>): boolean;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export function lockKey(lock) {
|
|
2
|
-
if (lock.target === 'transform') {
|
|
3
|
-
return `${lock.node}.transform.${lock.prop}`;
|
|
4
|
-
}
|
|
5
|
-
if (lock.target === 'nodeData') {
|
|
6
|
-
return `${lock.node}.${lock.field}.${lock.prop}`;
|
|
7
|
-
}
|
|
8
|
-
return `${lock.node}.${lock.component}.${lock.prop}`;
|
|
9
|
-
}
|
|
10
|
-
export function isLocked(locks, candidate) {
|
|
11
|
-
return (locks ?? []).some((lock) => {
|
|
12
|
-
if (lock.target !== candidate.target || lock.node !== candidate.node || lock.prop !== candidate.prop) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
if (candidate.target === 'component') {
|
|
16
|
-
return lock.component === candidate.component;
|
|
17
|
-
}
|
|
18
|
-
if (candidate.target === 'nodeData') {
|
|
19
|
-
return lock.field === candidate.field;
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { OverrideSpec } from "./OverrideJournal.js";
|
|
2
|
-
export interface PreferenceMemory {
|
|
3
|
-
id: string;
|
|
4
|
-
context: string;
|
|
5
|
-
pattern: string;
|
|
6
|
-
before?: unknown;
|
|
7
|
-
after: unknown;
|
|
8
|
-
reason?: string;
|
|
9
|
-
confidence: number;
|
|
10
|
-
enabled?: boolean;
|
|
11
|
-
source?: 'manual' | 'imported' | 'agent';
|
|
12
|
-
}
|
|
13
|
-
export interface MemorySuggestion {
|
|
14
|
-
id: string;
|
|
15
|
-
memory: PreferenceMemory;
|
|
16
|
-
sourceOverride: OverrideSpec;
|
|
17
|
-
}
|
|
18
|
-
export declare function createMemorySuggestion(override: OverrideSpec): MemorySuggestion | undefined;
|
|
19
|
-
export declare function createMemorySuggestions(overrides: readonly OverrideSpec[]): MemorySuggestion[];
|
|
20
|
-
export declare function summarizeMemoryForAgent(memory: readonly PreferenceMemory[]): string;
|
|
21
|
-
export declare function enabledMemory(memory: readonly PreferenceMemory[]): PreferenceMemory[];
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
function propFromTarget(target) {
|
|
2
|
-
const parts = target.split('.');
|
|
3
|
-
return parts.at(-1) ?? target;
|
|
4
|
-
}
|
|
5
|
-
export function createMemorySuggestion(override) {
|
|
6
|
-
if (override.source !== 'manual') {
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
const prop = propFromTarget(override.target);
|
|
10
|
-
return {
|
|
11
|
-
id: `suggestion-${override.timestamp}-${override.target}`,
|
|
12
|
-
sourceOverride: override,
|
|
13
|
-
memory: {
|
|
14
|
-
id: `memory-${override.timestamp}-${override.target}`,
|
|
15
|
-
context: override.target,
|
|
16
|
-
pattern: `When editing ${override.target}, prefer ${prop}=${JSON.stringify(override.after)}.`,
|
|
17
|
-
before: override.before,
|
|
18
|
-
after: override.after,
|
|
19
|
-
reason: override.reason,
|
|
20
|
-
confidence: 0.5,
|
|
21
|
-
enabled: true,
|
|
22
|
-
source: 'manual',
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
export function createMemorySuggestions(overrides) {
|
|
27
|
-
return overrides
|
|
28
|
-
.map(createMemorySuggestion)
|
|
29
|
-
.filter((suggestion) => !!suggestion);
|
|
30
|
-
}
|
|
31
|
-
export function summarizeMemoryForAgent(memory) {
|
|
32
|
-
return memory
|
|
33
|
-
.filter((item) => item.enabled !== false)
|
|
34
|
-
.map((item) => `- ${item.pattern}`)
|
|
35
|
-
.join('\n');
|
|
36
|
-
}
|
|
37
|
-
export function enabledMemory(memory) {
|
|
38
|
-
return memory.filter((item) => item.enabled !== false);
|
|
39
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Group } from "../runtime/index.js";
|
|
2
|
-
import type { Component } from "../runtime/index.js";
|
|
3
|
-
import type { InstantiateContext, SceneSpec } from "../scene/index.js";
|
|
4
|
-
export interface RuntimePreview {
|
|
5
|
-
root: Group;
|
|
6
|
-
nodes: Map<string, Group>;
|
|
7
|
-
components: Map<string, Component>;
|
|
8
|
-
resolveNode(runtimeNode: Group): string | undefined;
|
|
9
|
-
}
|
|
10
|
-
export declare function createRuntimePreview(scene: SceneSpec, parent?: Group, context?: InstantiateContext): RuntimePreview;
|
|
11
|
-
export declare function destroyRuntimePreview(preview?: RuntimePreview): void;
|