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,169 @@
|
|
|
1
|
+
import { component, container, shape, text } from "./dsl.js";
|
|
2
|
+
export function buttonScene(name, options = {}) {
|
|
3
|
+
const key = options.key ?? options.id ?? 'button';
|
|
4
|
+
const width = options.width ?? 120;
|
|
5
|
+
const height = options.height ?? 36;
|
|
6
|
+
const background = `${key}Bg`;
|
|
7
|
+
const components = [
|
|
8
|
+
component('ui.Button', {
|
|
9
|
+
targetGraphic: background,
|
|
10
|
+
...(options.onClick ? { onClick: options.onClick } : {}),
|
|
11
|
+
}, `${key}Button`),
|
|
12
|
+
];
|
|
13
|
+
return container(name, {
|
|
14
|
+
id: options.id,
|
|
15
|
+
key,
|
|
16
|
+
role: options.role ?? 'button',
|
|
17
|
+
x: options.x,
|
|
18
|
+
y: options.y,
|
|
19
|
+
width,
|
|
20
|
+
height,
|
|
21
|
+
components,
|
|
22
|
+
children: [
|
|
23
|
+
shape('背景', {
|
|
24
|
+
id: background,
|
|
25
|
+
key: background,
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
type: 'roundedRect',
|
|
29
|
+
color: options.color ?? 0x2563eb,
|
|
30
|
+
radius: options.radius ?? 6,
|
|
31
|
+
}),
|
|
32
|
+
text('文字', {
|
|
33
|
+
id: `${key}Label`,
|
|
34
|
+
key: `${key}Label`,
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
value: options.label ?? '按钮',
|
|
38
|
+
color: options.textColor ?? 0xffffff,
|
|
39
|
+
fontSize: 14,
|
|
40
|
+
center: true,
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export function progressBarScene(name, options = {}) {
|
|
46
|
+
const key = options.key ?? options.id ?? 'progressBar';
|
|
47
|
+
const width = options.width ?? 180;
|
|
48
|
+
const height = options.height ?? 18;
|
|
49
|
+
const min = options.min ?? 0;
|
|
50
|
+
const max = options.max ?? 1;
|
|
51
|
+
const value = options.value ?? 0.5;
|
|
52
|
+
const range = max - min;
|
|
53
|
+
const normalized = range === 0 ? 0 : Math.min(1, Math.max(0, (value - min) / range));
|
|
54
|
+
const fillNode = `${key}Fill`;
|
|
55
|
+
return container(name, {
|
|
56
|
+
id: options.id,
|
|
57
|
+
key,
|
|
58
|
+
role: options.role ?? 'progress-bar',
|
|
59
|
+
x: options.x,
|
|
60
|
+
y: options.y,
|
|
61
|
+
width,
|
|
62
|
+
height,
|
|
63
|
+
components: [
|
|
64
|
+
component('ui.ProgressBar', {
|
|
65
|
+
value,
|
|
66
|
+
min,
|
|
67
|
+
max,
|
|
68
|
+
fillNode,
|
|
69
|
+
}, `${key}Progress`),
|
|
70
|
+
],
|
|
71
|
+
children: [
|
|
72
|
+
shape('背景', {
|
|
73
|
+
id: `${key}Bg`,
|
|
74
|
+
key: `${key}Bg`,
|
|
75
|
+
width,
|
|
76
|
+
height,
|
|
77
|
+
type: 'roundedRect',
|
|
78
|
+
color: options.backgroundColor ?? 0xe2e8f0,
|
|
79
|
+
radius: options.radius ?? 9,
|
|
80
|
+
}),
|
|
81
|
+
shape('填充', {
|
|
82
|
+
id: fillNode,
|
|
83
|
+
key: fillNode,
|
|
84
|
+
width: width * normalized,
|
|
85
|
+
height,
|
|
86
|
+
type: 'roundedRect',
|
|
87
|
+
color: options.fillColor ?? 0x22c55e,
|
|
88
|
+
radius: options.radius ?? 9,
|
|
89
|
+
}),
|
|
90
|
+
],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function scrollViewScene(name, options = {}) {
|
|
94
|
+
const key = options.key ?? options.id ?? 'scrollView';
|
|
95
|
+
const width = options.width ?? 220;
|
|
96
|
+
const height = options.height ?? 160;
|
|
97
|
+
const contentHeight = options.contentHeight ?? 320;
|
|
98
|
+
const viewport = `${key}Viewport`;
|
|
99
|
+
const content = `${key}Content`;
|
|
100
|
+
return container(name, {
|
|
101
|
+
id: options.id,
|
|
102
|
+
key,
|
|
103
|
+
role: options.role ?? 'scroll-view',
|
|
104
|
+
x: options.x,
|
|
105
|
+
y: options.y,
|
|
106
|
+
width,
|
|
107
|
+
height,
|
|
108
|
+
components: [
|
|
109
|
+
component('ui.ScrollRect', {
|
|
110
|
+
viewport,
|
|
111
|
+
content,
|
|
112
|
+
contentHeight,
|
|
113
|
+
wheelSensitivity: options.wheelSensitivity ?? 1,
|
|
114
|
+
dragEnabled: options.dragEnabled ?? true,
|
|
115
|
+
}, `${key}Scroll`),
|
|
116
|
+
],
|
|
117
|
+
children: [
|
|
118
|
+
shape('背景', {
|
|
119
|
+
id: `${key}Bg`,
|
|
120
|
+
key: `${key}Bg`,
|
|
121
|
+
width,
|
|
122
|
+
height,
|
|
123
|
+
type: 'roundedRect',
|
|
124
|
+
color: 0xf8fafc,
|
|
125
|
+
radius: 8,
|
|
126
|
+
strokeColor: 0xcbd5e1,
|
|
127
|
+
strokeWidth: 1,
|
|
128
|
+
}),
|
|
129
|
+
container('视口', {
|
|
130
|
+
id: viewport,
|
|
131
|
+
key: viewport,
|
|
132
|
+
role: 'scroll-viewport',
|
|
133
|
+
width,
|
|
134
|
+
height,
|
|
135
|
+
children: [
|
|
136
|
+
container('内容', {
|
|
137
|
+
id: content,
|
|
138
|
+
key: content,
|
|
139
|
+
role: 'scroll-content',
|
|
140
|
+
width,
|
|
141
|
+
height: contentHeight,
|
|
142
|
+
children: [
|
|
143
|
+
shape('内容背景', {
|
|
144
|
+
id: `${key}ContentBg`,
|
|
145
|
+
key: `${key}ContentBg`,
|
|
146
|
+
width,
|
|
147
|
+
height: contentHeight,
|
|
148
|
+
type: 'roundedRect',
|
|
149
|
+
color: 0xffffff,
|
|
150
|
+
radius: 8,
|
|
151
|
+
}),
|
|
152
|
+
text('内容提示', {
|
|
153
|
+
id: `${key}Hint`,
|
|
154
|
+
key: `${key}Hint`,
|
|
155
|
+
x: 16,
|
|
156
|
+
y: 16,
|
|
157
|
+
width: width - 32,
|
|
158
|
+
height: 24,
|
|
159
|
+
value: '滚动内容',
|
|
160
|
+
color: 0x334155,
|
|
161
|
+
fontSize: 14,
|
|
162
|
+
}),
|
|
163
|
+
],
|
|
164
|
+
}),
|
|
165
|
+
],
|
|
166
|
+
}),
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export type ComponentRefSpec = string | {
|
|
2
|
+
node?: string;
|
|
3
|
+
component: string;
|
|
4
|
+
};
|
|
5
|
+
export interface RectTransformSpec {
|
|
6
|
+
x?: number;
|
|
7
|
+
y?: number;
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
anchorX?: number;
|
|
11
|
+
anchorY?: number;
|
|
12
|
+
scaleX?: number;
|
|
13
|
+
scaleY?: number;
|
|
14
|
+
rotation?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ComponentSpec {
|
|
17
|
+
id?: string;
|
|
18
|
+
type: string;
|
|
19
|
+
props?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export type SceneNodeKind = 'container' | 'image' | 'text' | 'input' | 'shape';
|
|
22
|
+
export interface BaseNodeSpec {
|
|
23
|
+
id?: string;
|
|
24
|
+
key?: string;
|
|
25
|
+
role?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
kind: SceneNodeKind;
|
|
28
|
+
transform?: RectTransformSpec;
|
|
29
|
+
components?: ComponentSpec[];
|
|
30
|
+
}
|
|
31
|
+
export interface ContainerNodeSpec extends BaseNodeSpec {
|
|
32
|
+
kind: 'container';
|
|
33
|
+
children?: NodeSpec[];
|
|
34
|
+
}
|
|
35
|
+
export interface ImageNodeSpec extends BaseNodeSpec {
|
|
36
|
+
kind: 'image';
|
|
37
|
+
image?: {
|
|
38
|
+
mode?: 'sprite' | 'nineSlice';
|
|
39
|
+
src?: string;
|
|
40
|
+
tint?: number;
|
|
41
|
+
leftWidth?: number;
|
|
42
|
+
rightWidth?: number;
|
|
43
|
+
topHeight?: number;
|
|
44
|
+
bottomHeight?: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export interface TextNodeSpec extends BaseNodeSpec {
|
|
48
|
+
kind: 'text';
|
|
49
|
+
text?: {
|
|
50
|
+
value?: string;
|
|
51
|
+
color?: number;
|
|
52
|
+
fontSize?: number;
|
|
53
|
+
fontFamily?: string | string[];
|
|
54
|
+
fontWeight?: string;
|
|
55
|
+
center?: boolean;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface InputNodeSpec extends BaseNodeSpec {
|
|
59
|
+
kind: 'input';
|
|
60
|
+
input?: {
|
|
61
|
+
value?: string;
|
|
62
|
+
backgroundColor?: number;
|
|
63
|
+
borderColor?: number;
|
|
64
|
+
borderSize?: number;
|
|
65
|
+
textColor?: string;
|
|
66
|
+
fontSize?: number;
|
|
67
|
+
fontFamily?: string | string[];
|
|
68
|
+
paddingLeft?: number;
|
|
69
|
+
paddingRight?: number;
|
|
70
|
+
paddingTop?: number;
|
|
71
|
+
paddingBottom?: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface ShapeNodeSpec extends BaseNodeSpec {
|
|
75
|
+
kind: 'shape';
|
|
76
|
+
shape?: {
|
|
77
|
+
type?: 'rect' | 'roundedRect';
|
|
78
|
+
color?: number;
|
|
79
|
+
fillAlpha?: number;
|
|
80
|
+
radius?: number;
|
|
81
|
+
strokeColor?: number;
|
|
82
|
+
strokeWidth?: number;
|
|
83
|
+
strokeAlpha?: number;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export type NodeSpec = ContainerNodeSpec | ImageNodeSpec | TextNodeSpec | InputNodeSpec | ShapeNodeSpec;
|
|
87
|
+
export interface SceneSpec {
|
|
88
|
+
version: number;
|
|
89
|
+
type: 'scene';
|
|
90
|
+
name: string;
|
|
91
|
+
root: ContainerNodeSpec;
|
|
92
|
+
}
|
|
93
|
+
export interface InstantiateContext {
|
|
94
|
+
actions?: Record<string, (...args: unknown[]) => void>;
|
|
95
|
+
}
|
|
96
|
+
export interface InstantiateResult<T = unknown> {
|
|
97
|
+
root: T;
|
|
98
|
+
nodes: Map<string, T>;
|
|
99
|
+
components: Map<string, unknown>;
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SceneCommand } from "../commands/index.js";
|
|
2
|
+
import type { NodeSpec } from "./spec.js";
|
|
3
|
+
export interface InventoryTemplateOptions {
|
|
4
|
+
parent?: string;
|
|
5
|
+
keyPrefix?: string;
|
|
6
|
+
columns?: number;
|
|
7
|
+
rows?: number;
|
|
8
|
+
x?: number;
|
|
9
|
+
y?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function inventoryPanelNode(options?: InventoryTemplateOptions): NodeSpec;
|
|
12
|
+
export declare function createInventoryPanelCommands(options?: InventoryTemplateOptions): SceneCommand[];
|
|
13
|
+
export type SceneTemplateKind = 'button' | 'progressBar' | 'scrollView' | 'loginForm';
|
|
14
|
+
export interface SceneTemplateAddOptions {
|
|
15
|
+
kind: SceneTemplateKind | string;
|
|
16
|
+
parent?: string;
|
|
17
|
+
key: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function sceneTemplateNode(options: SceneTemplateAddOptions): NodeSpec;
|
|
21
|
+
export declare function createSceneTemplateCommands(options: SceneTemplateAddOptions): SceneCommand[];
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { buttonScene, progressBarScene, scrollViewScene } from "./nodesDsl.js";
|
|
2
|
+
import { container, input, shape, text } from "./dsl.js";
|
|
3
|
+
function inventorySlot(keyPrefix, index, x, y) {
|
|
4
|
+
const slotKey = `${keyPrefix}Slot${index + 1}`;
|
|
5
|
+
return container(`格子 ${index + 1}`, {
|
|
6
|
+
id: slotKey,
|
|
7
|
+
key: slotKey,
|
|
8
|
+
role: 'inventory-slot',
|
|
9
|
+
x,
|
|
10
|
+
y,
|
|
11
|
+
width: 104,
|
|
12
|
+
height: 120,
|
|
13
|
+
children: [
|
|
14
|
+
shape('背景', {
|
|
15
|
+
id: `${slotKey}Bg`,
|
|
16
|
+
key: `${slotKey}Bg`,
|
|
17
|
+
width: 104,
|
|
18
|
+
height: 120,
|
|
19
|
+
type: 'roundedRect',
|
|
20
|
+
color: 0xffffff,
|
|
21
|
+
radius: 8,
|
|
22
|
+
strokeColor: 0xcbd5e1,
|
|
23
|
+
strokeWidth: 1,
|
|
24
|
+
}),
|
|
25
|
+
shape('图标', {
|
|
26
|
+
id: `${slotKey}Icon`,
|
|
27
|
+
key: `${slotKey}Icon`,
|
|
28
|
+
role: 'item-icon',
|
|
29
|
+
x: 12,
|
|
30
|
+
y: 10,
|
|
31
|
+
width: 80,
|
|
32
|
+
height: 64,
|
|
33
|
+
type: 'roundedRect',
|
|
34
|
+
color: 0xe2e8f0,
|
|
35
|
+
radius: 6,
|
|
36
|
+
}),
|
|
37
|
+
text('数量', {
|
|
38
|
+
id: `${slotKey}Quantity`,
|
|
39
|
+
key: `${slotKey}Quantity`,
|
|
40
|
+
role: 'item-quantity',
|
|
41
|
+
x: 64,
|
|
42
|
+
y: 56,
|
|
43
|
+
width: 28,
|
|
44
|
+
height: 20,
|
|
45
|
+
value: 'x1',
|
|
46
|
+
color: 0x334155,
|
|
47
|
+
fontSize: 12,
|
|
48
|
+
fontWeight: '700',
|
|
49
|
+
center: true,
|
|
50
|
+
}),
|
|
51
|
+
buttonScene('使用按钮', {
|
|
52
|
+
id: `${slotKey}UseButton`,
|
|
53
|
+
key: `${slotKey}UseButton`,
|
|
54
|
+
role: 'item-use-button',
|
|
55
|
+
x: 12,
|
|
56
|
+
y: 84,
|
|
57
|
+
width: 80,
|
|
58
|
+
height: 26,
|
|
59
|
+
label: '使用',
|
|
60
|
+
color: 0x2563eb,
|
|
61
|
+
textColor: 0xffffff,
|
|
62
|
+
radius: 6,
|
|
63
|
+
onClick: 'useInventoryItem',
|
|
64
|
+
}),
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export function inventoryPanelNode(options = {}) {
|
|
69
|
+
const keyPrefix = options.keyPrefix ?? 'inventory';
|
|
70
|
+
const columns = options.columns ?? 4;
|
|
71
|
+
const rows = options.rows ?? 3;
|
|
72
|
+
const children = [
|
|
73
|
+
shape('背景', {
|
|
74
|
+
id: `${keyPrefix}PanelBg`,
|
|
75
|
+
key: `${keyPrefix}PanelBg`,
|
|
76
|
+
width: 512,
|
|
77
|
+
height: 480,
|
|
78
|
+
type: 'roundedRect',
|
|
79
|
+
color: 0xf8fafc,
|
|
80
|
+
radius: 12,
|
|
81
|
+
strokeColor: 0x94a3b8,
|
|
82
|
+
strokeWidth: 1,
|
|
83
|
+
strokeAlpha: 0.6,
|
|
84
|
+
}),
|
|
85
|
+
text('标题', {
|
|
86
|
+
id: `${keyPrefix}Title`,
|
|
87
|
+
key: `${keyPrefix}Title`,
|
|
88
|
+
role: 'panel-title',
|
|
89
|
+
x: 24,
|
|
90
|
+
y: 18,
|
|
91
|
+
width: 360,
|
|
92
|
+
height: 30,
|
|
93
|
+
value: '背包',
|
|
94
|
+
color: 0x172033,
|
|
95
|
+
fontSize: 22,
|
|
96
|
+
fontWeight: '800',
|
|
97
|
+
}),
|
|
98
|
+
];
|
|
99
|
+
for (let row = 0; row < rows; row++) {
|
|
100
|
+
for (let col = 0; col < columns; col++) {
|
|
101
|
+
children.push(inventorySlot(keyPrefix, row * columns + col, 24 + col * 116, 66 + row * 132));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return container('背包面板', {
|
|
105
|
+
id: `${keyPrefix}Panel`,
|
|
106
|
+
key: `${keyPrefix}Panel`,
|
|
107
|
+
role: 'inventory-panel',
|
|
108
|
+
x: options.x ?? 80,
|
|
109
|
+
y: options.y ?? 48,
|
|
110
|
+
width: 512,
|
|
111
|
+
height: 480,
|
|
112
|
+
children,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export function createInventoryPanelCommands(options = {}) {
|
|
116
|
+
return [{
|
|
117
|
+
op: 'createNode',
|
|
118
|
+
parent: options.parent,
|
|
119
|
+
node: inventoryPanelNode(options),
|
|
120
|
+
}];
|
|
121
|
+
}
|
|
122
|
+
function loginFormNode(options) {
|
|
123
|
+
const key = options.key;
|
|
124
|
+
return container('登录表单', {
|
|
125
|
+
id: key,
|
|
126
|
+
key,
|
|
127
|
+
role: 'login-form',
|
|
128
|
+
x: 40,
|
|
129
|
+
y: 28,
|
|
130
|
+
width: 280,
|
|
131
|
+
height: 220,
|
|
132
|
+
children: [
|
|
133
|
+
shape('背景', {
|
|
134
|
+
id: `${key}Card`,
|
|
135
|
+
key: `${key}Card`,
|
|
136
|
+
width: 280,
|
|
137
|
+
height: 220,
|
|
138
|
+
type: 'roundedRect',
|
|
139
|
+
color: 0xffffff,
|
|
140
|
+
radius: 10,
|
|
141
|
+
strokeColor: 0xcbd5e1,
|
|
142
|
+
strokeWidth: 1,
|
|
143
|
+
}),
|
|
144
|
+
text('标题', {
|
|
145
|
+
id: `${key}Title`,
|
|
146
|
+
key: `${key}Title`,
|
|
147
|
+
x: 24,
|
|
148
|
+
y: 20,
|
|
149
|
+
width: 232,
|
|
150
|
+
height: 32,
|
|
151
|
+
value: options.label ?? '登录',
|
|
152
|
+
color: 0x111827,
|
|
153
|
+
fontSize: 24,
|
|
154
|
+
fontWeight: '700',
|
|
155
|
+
}),
|
|
156
|
+
input('用户名', {
|
|
157
|
+
id: `${key}Username`,
|
|
158
|
+
key: `${key}Username`,
|
|
159
|
+
x: 24,
|
|
160
|
+
y: 72,
|
|
161
|
+
width: 232,
|
|
162
|
+
height: 36,
|
|
163
|
+
value: '',
|
|
164
|
+
backgroundColor: 0xffffff,
|
|
165
|
+
borderColor: 0x94a3b8,
|
|
166
|
+
borderSize: 1,
|
|
167
|
+
fontSize: 16,
|
|
168
|
+
}),
|
|
169
|
+
input('密码', {
|
|
170
|
+
id: `${key}Password`,
|
|
171
|
+
key: `${key}Password`,
|
|
172
|
+
x: 24,
|
|
173
|
+
y: 120,
|
|
174
|
+
width: 232,
|
|
175
|
+
height: 36,
|
|
176
|
+
value: '',
|
|
177
|
+
backgroundColor: 0xffffff,
|
|
178
|
+
borderColor: 0x94a3b8,
|
|
179
|
+
borderSize: 1,
|
|
180
|
+
fontSize: 16,
|
|
181
|
+
}),
|
|
182
|
+
buttonScene('提交按钮', {
|
|
183
|
+
id: `${key}Submit`,
|
|
184
|
+
key: `${key}Submit`,
|
|
185
|
+
x: 24,
|
|
186
|
+
y: 172,
|
|
187
|
+
width: 232,
|
|
188
|
+
height: 36,
|
|
189
|
+
label: options.label ?? '登录',
|
|
190
|
+
color: 0x2563eb,
|
|
191
|
+
radius: 6,
|
|
192
|
+
}),
|
|
193
|
+
],
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
export function sceneTemplateNode(options) {
|
|
197
|
+
switch (options.kind) {
|
|
198
|
+
case 'button':
|
|
199
|
+
return buttonScene(options.label ?? '按钮', {
|
|
200
|
+
id: options.key,
|
|
201
|
+
key: options.key,
|
|
202
|
+
width: 120,
|
|
203
|
+
height: 36,
|
|
204
|
+
label: options.label ?? '按钮',
|
|
205
|
+
color: 0x2563eb,
|
|
206
|
+
radius: 6,
|
|
207
|
+
});
|
|
208
|
+
case 'progressBar':
|
|
209
|
+
return progressBarScene(options.label ?? '进度条', {
|
|
210
|
+
id: options.key,
|
|
211
|
+
key: options.key,
|
|
212
|
+
width: 180,
|
|
213
|
+
height: 18,
|
|
214
|
+
value: 0.5,
|
|
215
|
+
});
|
|
216
|
+
case 'scrollView':
|
|
217
|
+
return scrollViewScene(options.label ?? '滚动视图', {
|
|
218
|
+
id: options.key,
|
|
219
|
+
key: options.key,
|
|
220
|
+
width: 220,
|
|
221
|
+
height: 160,
|
|
222
|
+
contentHeight: 320,
|
|
223
|
+
});
|
|
224
|
+
case 'loginForm':
|
|
225
|
+
return loginFormNode({
|
|
226
|
+
key: options.key,
|
|
227
|
+
label: options.label,
|
|
228
|
+
});
|
|
229
|
+
default:
|
|
230
|
+
throw new Error(`Unknown template kind "${options.kind}".`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
export function createSceneTemplateCommands(options) {
|
|
234
|
+
return [{
|
|
235
|
+
op: 'createNode',
|
|
236
|
+
parent: options.parent,
|
|
237
|
+
node: sceneTemplateNode(options),
|
|
238
|
+
}];
|
|
239
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pixifact",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Pixif semantic framework for 2D UI and lightweight game scenes.",
|
|
5
|
+
"packageManager": "bun@1.3.13",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/"
|
|
12
|
+
],
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/hxg2050/pixifact.git",
|
|
16
|
+
"directory": "packages/pixifact"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"pixif",
|
|
20
|
+
"pixifact",
|
|
21
|
+
"game-editor",
|
|
22
|
+
"pixijs",
|
|
23
|
+
"scene",
|
|
24
|
+
"runtime"
|
|
25
|
+
],
|
|
26
|
+
"author": "youxia <243802688@qq.com>",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "bun scripts/clean-dist.mjs && bunx --no-install tsc -p tsconfig.build.json && bun scripts/fix-dist-esm-imports.mjs"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js",
|
|
38
|
+
"require": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./runtime": {
|
|
41
|
+
"types": "./dist/runtime/index.d.ts",
|
|
42
|
+
"import": "./dist/runtime/index.js",
|
|
43
|
+
"require": "./dist/runtime/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./nodes": {
|
|
46
|
+
"types": "./dist/nodes/index.d.ts",
|
|
47
|
+
"import": "./dist/nodes/index.js",
|
|
48
|
+
"require": "./dist/nodes/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./scene": {
|
|
51
|
+
"types": "./dist/scene/index.d.ts",
|
|
52
|
+
"import": "./dist/scene/index.js",
|
|
53
|
+
"require": "./dist/scene/index.js"
|
|
54
|
+
},
|
|
55
|
+
"./compiler": {
|
|
56
|
+
"types": "./dist/compiler/index.d.ts",
|
|
57
|
+
"import": "./dist/compiler/index.js",
|
|
58
|
+
"require": "./dist/compiler/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./compiler-node": {
|
|
61
|
+
"types": "./dist/compiler-node/index.d.ts",
|
|
62
|
+
"import": "./dist/compiler-node/index.js",
|
|
63
|
+
"require": "./dist/compiler-node/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./authoring": {
|
|
66
|
+
"types": "./dist/authoring/index.d.ts",
|
|
67
|
+
"import": "./dist/authoring/index.js",
|
|
68
|
+
"require": "./dist/authoring/index.js"
|
|
69
|
+
},
|
|
70
|
+
"./commands": {
|
|
71
|
+
"types": "./dist/commands/index.d.ts",
|
|
72
|
+
"import": "./dist/commands/index.js",
|
|
73
|
+
"require": "./dist/commands/index.js"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"pixi.js": ">=8.3.0"
|
|
78
|
+
},
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"@math.gl/core": "^4.0.1",
|
|
81
|
+
"eventemitter3": "^5.0.1",
|
|
82
|
+
"typescript": "^5.3.3"
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
86
|
+
"@types/node": "^25.9.1",
|
|
87
|
+
"rollup": "^4.9.4",
|
|
88
|
+
"tslib": "^2.6.2"
|
|
89
|
+
}
|
|
90
|
+
}
|