pixifact 0.2.2 → 0.3.0
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/dist/compiler/pixiNodeSchema.d.ts +2 -2
- package/dist/compiler/pixiNodeSchema.js +10 -0
- package/dist/compiler/sceneValidation.js +1 -1
- package/dist/compiler/scriptInterfaceExtractor.js +6 -0
- package/dist/compiler/spec.d.ts +1 -1
- package/dist/compiler/templateParser.js +1 -0
- package/dist/compiler/typescriptCompiler.js +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SceneTemplatePrimitiveType, SceneTemplateValue } from './spec.js';
|
|
2
|
-
export type PixiSceneNodeType = Extract<SceneTemplatePrimitiveType, 'Container' | 'Sprite' | 'NineSliceSprite' | 'TilingSprite' | 'Text' | 'BitmapText' | 'HTMLText' | 'Graphics' | 'Rect' | 'Image' | 'NineImage' | 'TileImage' | 'GridContainer' | 'HBoxContainer' | 'ScrollContainer' | 'VBoxContainer'>;
|
|
2
|
+
export type PixiSceneNodeType = Extract<SceneTemplatePrimitiveType, 'Group' | 'Container' | 'Sprite' | 'NineSliceSprite' | 'TilingSprite' | 'Text' | 'BitmapText' | 'HTMLText' | 'Graphics' | 'Rect' | 'Image' | 'NineImage' | 'TileImage' | 'GridContainer' | 'HBoxContainer' | 'ScrollContainer' | 'VBoxContainer'>;
|
|
3
3
|
export type PixiSceneFieldType = 'string' | 'number' | 'boolean' | 'color' | 'enum';
|
|
4
4
|
export type PixiScenePropGroup = 'transform' | 'display' | 'sprite' | 'nineSlice' | 'tiling' | 'text' | 'graphics' | 'stack' | 'props';
|
|
5
5
|
export interface PixiSceneFieldSchema {
|
|
@@ -33,7 +33,7 @@ export declare const pixiSceneScrollProps: readonly ["direction", "scrollX", "sc
|
|
|
33
33
|
export declare const pixiSceneTextStyleProps: readonly ["fontSize", "fontFamily", "fontWeight", "fill"];
|
|
34
34
|
export declare const pixiSceneSpriteLikeProps: readonly ["texture", "anchorX", "anchorY", "tint", "texture", "fit", "anchorX", "anchorY", "tint", "texture", "leftWidth", "rightWidth", "topHeight", "bottomHeight", "anchorX", "anchorY", "tint", "texture", "tilePositionX", "tilePositionY", "tileScaleX", "tileScaleY", "tileRotation", "anchorX", "anchorY", "tint", "leftWidth", "rightWidth", "topHeight", "bottomHeight", "tilePositionX", "tilePositionY", "tileScaleX", "tileScaleY", "tileRotation"];
|
|
35
35
|
export declare const pixiSceneKnownProps: readonly ["x", "y", "width", "height", "scaleX", "scaleY", "rotation", "pivotX", "pivotY", "skewX", "skewY", "left", "right", "top", "bottom", "horizontal", "vertical", "alpha", "visible", "zIndex", "eventMode", "cursor", "label", "texture", "anchorX", "anchorY", "tint", "texture", "fit", "anchorX", "anchorY", "tint", "texture", "leftWidth", "rightWidth", "topHeight", "bottomHeight", "anchorX", "anchorY", "tint", "texture", "tilePositionX", "tilePositionY", "tileScaleX", "tileScaleY", "tileRotation", "anchorX", "anchorY", "tint", "leftWidth", "rightWidth", "topHeight", "bottomHeight", "tilePositionX", "tilePositionY", "tileScaleX", "tileScaleY", "tileRotation", "text", "fontSize", "fontFamily", "fontWeight", "fill", "shape", "radius", "fill", "fillAlpha", "strokeColor", "strokeWidth", "strokeAlpha", "fillColor", "fillAlpha", "strokeColor", "strokeAlpha", "strokeWidth", "radius", "columns", "gap", "gapX", "gapY", "alignX", "alignY", "justify", "direction", "scrollX", "scrollY"];
|
|
36
|
-
export declare const pixiSceneAddableNodeTypes: readonly ["GridContainer", "HBoxContainer", "ScrollContainer", "VBoxContainer", "Container", "Sprite", "NineSliceSprite", "TilingSprite", "Text", "BitmapText", "HTMLText", "Graphics", "Rect", "Image", "NineImage", "TileImage"];
|
|
36
|
+
export declare const pixiSceneAddableNodeTypes: readonly ["Group", "GridContainer", "HBoxContainer", "ScrollContainer", "VBoxContainer", "Container", "Sprite", "NineSliceSprite", "TilingSprite", "Text", "BitmapText", "HTMLText", "Graphics", "Rect", "Image", "NineImage", "TileImage"];
|
|
37
37
|
export declare const pixiSceneNodePropGroupOrder: readonly ["stack", "sprite", "nineSlice", "tiling", "text", "graphics", "props"];
|
|
38
38
|
export declare function pixiSceneNodeSchema(type: PixiSceneNodeType): PixiSceneNodeSchema;
|
|
39
39
|
export declare function isPixiSceneNodeType(type: SceneTemplatePrimitiveType): type is PixiSceneNodeType;
|
|
@@ -155,6 +155,7 @@ export const pixiSceneKnownProps = [
|
|
|
155
155
|
...pixiSceneScrollProps,
|
|
156
156
|
];
|
|
157
157
|
export const pixiSceneAddableNodeTypes = [
|
|
158
|
+
'Group',
|
|
158
159
|
'GridContainer',
|
|
159
160
|
'HBoxContainer',
|
|
160
161
|
'ScrollContainer',
|
|
@@ -243,6 +244,15 @@ const pixiSceneFieldSchemas = {
|
|
|
243
244
|
scrollY: { key: 'scrollY', type: 'number' },
|
|
244
245
|
};
|
|
245
246
|
const pixiSceneNodeSchemas = {
|
|
247
|
+
Group: {
|
|
248
|
+
type: 'Group',
|
|
249
|
+
acceptsChildren: true,
|
|
250
|
+
defaults: {
|
|
251
|
+
width: 100,
|
|
252
|
+
height: 100,
|
|
253
|
+
},
|
|
254
|
+
groups: {},
|
|
255
|
+
},
|
|
246
256
|
Container: {
|
|
247
257
|
type: 'Container',
|
|
248
258
|
acceptsChildren: true,
|
|
@@ -149,7 +149,7 @@ function validatePixiNode(node, path, existingAssets) {
|
|
|
149
149
|
prop: 'children',
|
|
150
150
|
expected: 'no child nodes',
|
|
151
151
|
actual: `${node.children.length} ${node.children.length === 1 ? 'child node' : 'child nodes'}`,
|
|
152
|
-
hint: `${node.type} is a leaf drawing node. Wrap it and sibling content in a Container or Group
|
|
152
|
+
hint: `${node.type} is a leaf drawing node. Wrap it and sibling content in a <Container> or <Group>.`,
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
const knownProps = new Set([
|
|
@@ -28,6 +28,9 @@ function extractSceneScriptClasses(source, fileName, options) {
|
|
|
28
28
|
}
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
|
+
if (isSceneClass && sceneConstructorHasParameters(statement)) {
|
|
32
|
+
throw new Error(`@scene class "${className}" must not declare constructor parameters. Use @prop() or an explicit method after construction.`);
|
|
33
|
+
}
|
|
31
34
|
const props = {};
|
|
32
35
|
const events = {};
|
|
33
36
|
const slots = {};
|
|
@@ -258,6 +261,9 @@ function hasSceneDecorator(node) {
|
|
|
258
261
|
}
|
|
259
262
|
return true;
|
|
260
263
|
}
|
|
264
|
+
function sceneConstructorHasParameters(node) {
|
|
265
|
+
return node.members.some((member) => ts.isConstructorDeclaration(member) && member.parameters.length > 0);
|
|
266
|
+
}
|
|
261
267
|
function parentClassNameOf(node) {
|
|
262
268
|
const heritage = node.heritageClauses?.find((item) => item.token === ts.SyntaxKind.ExtendsKeyword);
|
|
263
269
|
const parent = heritage?.types[0]?.expression;
|
package/dist/compiler/spec.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SceneTemplatePrimitiveType = 'Container' | 'Sprite' | 'Text' | 'Graphics' | 'Rect' | 'Image' | 'NineImage' | 'TileImage' | 'BitmapText' | 'HTMLText' | 'Mesh' | 'NineSliceSprite' | 'TilingSprite' | 'DOMContainer' | 'GridContainer' | 'HBoxContainer' | 'ScrollContainer' | 'VBoxContainer';
|
|
1
|
+
export type SceneTemplatePrimitiveType = 'Group' | 'Container' | 'Sprite' | 'Text' | 'Graphics' | 'Rect' | 'Image' | 'NineImage' | 'TileImage' | 'BitmapText' | 'HTMLText' | 'Mesh' | 'NineSliceSprite' | 'TilingSprite' | 'DOMContainer' | 'GridContainer' | 'HBoxContainer' | 'ScrollContainer' | 'VBoxContainer';
|
|
2
2
|
export type SceneTemplateScalarValue = string | number | boolean;
|
|
3
3
|
export type SceneTemplateStructValue = Record<string, SceneTemplateScalarValue>;
|
|
4
4
|
export type SceneTemplateValue = SceneTemplateScalarValue | SceneTemplateStructValue;
|
|
@@ -6,7 +6,7 @@ const spriteProps = new Set(pixiSceneSpriteLikeProps);
|
|
|
6
6
|
const graphicsProps = new Set(pixiSceneGraphicsProps);
|
|
7
7
|
const rectProps = new Set(pixiSceneRectProps);
|
|
8
8
|
const textStyleProps = new Set(pixiSceneTextStyleProps);
|
|
9
|
-
const runtimeNodeTypes = new Set(['GridContainer', 'HBoxContainer', 'ScrollContainer', 'VBoxContainer', 'Rect', 'Image', 'NineImage', 'TileImage']);
|
|
9
|
+
const runtimeNodeTypes = new Set(['Group', 'GridContainer', 'HBoxContainer', 'ScrollContainer', 'VBoxContainer', 'Rect', 'Image', 'NineImage', 'TileImage']);
|
|
10
10
|
const runtimeNodeProps = new Set(['columns', 'gap', 'gapX', 'gapY', 'alignX', 'alignY', 'justify', 'direction', 'scrollX', 'scrollY']);
|
|
11
11
|
export function compileSceneTemplateToTs(template, options = {}) {
|
|
12
12
|
const context = new CompileContext(template, options);
|
|
@@ -77,7 +77,7 @@ class CompileContext {
|
|
|
77
77
|
...[...this.#imports].filter((item) => item !== 'Container').sort(),
|
|
78
78
|
...[...this.#pixiImports].sort(),
|
|
79
79
|
])];
|
|
80
|
-
const runtimeImports = ['Group', ...[...this.#pixiRuntimeImports].sort()];
|
|
80
|
+
const runtimeImports = [...new Set(['Group', ...[...this.#pixiRuntimeImports].sort()])];
|
|
81
81
|
const lines = [`import { ${imports.join(', ')} } from 'pixi.js';`, `import { ${runtimeImports.join(', ')} } from 'pixifact/runtime';`];
|
|
82
82
|
for (const [texture, variable] of this.#textureImportEntries()) {
|
|
83
83
|
lines.push(`import ${variable} from ${JSON.stringify(this.options.textureImports?.[texture])};`);
|