pixifact 0.1.3 → 0.1.4
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
package/dist/scene/nodesDsl.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/scene/spec.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/scene/spec.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
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[];
|
package/dist/scene/templates.js
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
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
|
-
}
|