pixi-solid 0.0.19 → 0.0.21
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 +37 -19
- package/dist/component-creation.js +59 -0
- package/dist/component-creation.js.map +1 -0
- package/dist/pixi-components.js +2 -48
- package/dist/pixi-components.js.map +1 -1
- package/dist/pixi-stage.js +1 -1
- package/dist/pixi-stage.js.map +1 -1
- package/dist/renderer.js.map +1 -1
- package/dist/types/component-creation.d.ts +36 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/pixi-components.d.ts +24 -50
- package/dist/types/renderer.d.ts +2 -2
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -5,35 +5,53 @@ A custom renderer for [PixiJS](https://pixijs.com/) that lets you build your sce
|
|
|
5
5
|
[](https://www.npmjs.com/package/pixi-solid)
|
|
6
6
|
[](https://github.com/your-username/pixi-solid/blob/main/LICENSE)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
- 💙 Lightweight and flexible SolidJS library for creating PixiJS applications.
|
|
9
|
+
- 🎁 Provides a set of custom SolidJS components that create PixiJS objects instead of HTML elements.
|
|
10
|
+
- 📦 Supports all PixiJS objects, such as Filter, Container, Sprite, Graphics, Text, etc.
|
|
11
|
+
- 🧑💻 The convenience and speed of SolidJS stores and signals to manage state.
|
|
12
|
+
- ✨ All events emitted by PixiJS objects are supported.
|
|
13
|
+
- 😎 No limitations. Break out of SolidJS any time and interact directly with PixiJS.
|
|
14
|
+
- 💫 Useful helper utilities included.
|
|
15
|
+
- 🤩 Full Typescript support for type safety and auto completion.
|
|
9
16
|
|
|
10
|
-
|
|
17
|
+
---
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
- **SolidJS:** A declarative, performant, and reactive JavaScript library for building user interfaces.
|
|
19
|
+
### Install
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npm i pixi-solid pixi.js solid-js
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Peer dependencies of
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"pixi.js": "^8.14.3",
|
|
30
|
+
"solid-js": "^1.9.10"
|
|
31
|
+
}
|
|
32
|
+
```
|
|
18
33
|
|
|
19
|
-
|
|
20
|
-
In these cases you may want to create an imperative component and update it every frame with the `onTick` method and then wrap it inside a `<Container />` component as an easy way of packaging it.
|
|
34
|
+
---
|
|
21
35
|
|
|
22
|
-
|
|
36
|
+
### Why combine SolidJS with PixiJS?
|
|
23
37
|
|
|
24
|
-
|
|
38
|
+
- **Declarative PixiJS scene graph**: Using SolidJS's JSX templating means we get declarative control over the scene graph. No longer necessary to imperatively add and remove children.
|
|
25
39
|
|
|
26
|
-
|
|
40
|
+
- **Lifecycle hooks in our PixiJS components**: SolidJS rendering PixiJS components means we can take advantage of the built in lifecycle methods in SolidJS `onMount` and `onCleanup` as well as few extra custom hooks so we can automatically subscribe and unsubscribe from the ticker.
|
|
27
41
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
- **Shared State and Reactivity**: Pixi Solid leverages SolidJS's reactivity system to automatically update PixiJS components when SolidJS signals or stores change. So your HTML and PixiJS graphics can stay in sync effortlessly.
|
|
43
|
+
|
|
44
|
+
- **Combine the best of both worlds**: Pixi Solid makes it easy to use HTML elements alongside a PixiJS canvas, allowing you to create rich user interfaces that combine the strengths of both technologies.
|
|
45
|
+
|
|
46
|
+
- **Composability**: Pixi Solid components can be easily composed together to create complex scenes and animations out of reusable components.
|
|
47
|
+
|
|
48
|
+
- **SolidJS is a thin wrapper**: While Pixi Solid provides a nice abstraction over PixiJS it provides access to all the properties and events of PixiJS objects.
|
|
49
|
+
|
|
50
|
+
- **SolidJS is really fast**: SolidJs is on of the fatsest front-end frameworks out there so the overhead is very minimal.
|
|
51
|
+
|
|
52
|
+
- **SolidJS is fully featured**: It has stores, signals, suspense, error boundaries, resource fetching and more. It's a great feature set for simple or complex applications and you won't have to reach for other libraries to manage templating or state.
|
|
35
53
|
|
|
36
|
-
|
|
54
|
+
---
|
|
37
55
|
|
|
38
56
|
### Basic Usage
|
|
39
57
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { splitProps, createRenderEffect, on } from "solid-js";
|
|
2
|
+
import { PIXI_SOLID_EVENT_HANDLER_NAMES } from "./pixi-events.js";
|
|
3
|
+
import { insert, setProp } from "./renderer.js";
|
|
4
|
+
const SOLID_PROP_KEYS = ["ref", "as", "children"];
|
|
5
|
+
const applyProps = (instance, props, defer) => {
|
|
6
|
+
for (const key in props) {
|
|
7
|
+
if (key === "as") continue;
|
|
8
|
+
if (key === "ref") {
|
|
9
|
+
createRenderEffect(() => {
|
|
10
|
+
props[key](instance);
|
|
11
|
+
});
|
|
12
|
+
} else if (key === "children") {
|
|
13
|
+
if (!("addChild" in instance)) {
|
|
14
|
+
throw new Error(`Cannot set children on non-container instance.`);
|
|
15
|
+
}
|
|
16
|
+
createRenderEffect(() => {
|
|
17
|
+
insert(instance, () => props.children);
|
|
18
|
+
});
|
|
19
|
+
} else if (defer) {
|
|
20
|
+
createRenderEffect(
|
|
21
|
+
on(
|
|
22
|
+
() => props[key],
|
|
23
|
+
() => {
|
|
24
|
+
setProp(instance, key, props[key]);
|
|
25
|
+
},
|
|
26
|
+
{ defer }
|
|
27
|
+
)
|
|
28
|
+
);
|
|
29
|
+
} else {
|
|
30
|
+
createRenderEffect(() => {
|
|
31
|
+
setProp(instance, key, props[key]);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const createContainerComponent = (PixiClass) => {
|
|
37
|
+
return (props) => {
|
|
38
|
+
const [runtimeProps, initialisationProps] = splitProps(props, [
|
|
39
|
+
...SOLID_PROP_KEYS,
|
|
40
|
+
...PIXI_SOLID_EVENT_HANDLER_NAMES
|
|
41
|
+
]);
|
|
42
|
+
const instance = props.as || new PixiClass(initialisationProps);
|
|
43
|
+
applyProps(instance, initialisationProps, true);
|
|
44
|
+
applyProps(instance, runtimeProps);
|
|
45
|
+
return instance;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
const createLeafComponent = (PixiClass) => {
|
|
49
|
+
return (props) => {
|
|
50
|
+
return createContainerComponent(PixiClass)(props);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
SOLID_PROP_KEYS,
|
|
55
|
+
applyProps,
|
|
56
|
+
createContainerComponent,
|
|
57
|
+
createLeafComponent
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=component-creation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-creation.js","sources":["../src/component-creation.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { createRenderEffect, on, splitProps } from \"solid-js\";\nimport type { PixiEventHandlerMap } from \"./pixi-events\";\nimport { PIXI_SOLID_EVENT_HANDLER_NAMES } from \"./pixi-events\";\nimport { insert, setProp } from \"./renderer\";\n\n/**\n * Prop definition for components that CAN have children\n */\nexport type ContainerProps<Component> = PixiEventHandlerMap & {\n ref?: Ref<Component>;\n as?: Component;\n children?: JSX.Element;\n};\n\n/**\n * Prop definition for components that CANNOT have children\n */\nexport type LeafProps<Component> = Omit<ContainerProps<Component>, \"children\">;\n\n/**\n * Prop definition for filter components\n */\nexport type FilterProps<Component> = {\n ref?: Ref<Component>;\n as?: Component;\n};\n\n// Keys that are specific to Solid components and not Pixi props\nexport const SOLID_PROP_KEYS = [\"ref\", \"as\", \"children\"] as const;\n\n/**\n * Apply's the props to a Pixi instance with subsriptions to maintain reactivity.\n *\n * @param instance The Pixi instance we want to apply props to.\n * @param props The props object.\n * @param defer Defers the createRenderEffect so the props aren't set on the first run.\n * This is useful because setting initialisation props can have unintended side effects.\n * Notibly in AnimatedSprite, if we set the textures roperty after instantiation it will stop the instance from playing.\n */\nexport const applyProps = <\n InstanceType extends Pixi.Container,\n OptionsType extends ContainerProps<InstanceType>,\n>(\n instance: InstanceType,\n props: OptionsType,\n defer?: boolean,\n) => {\n for (const key in props) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n } else if (key === \"children\") {\n if (!(\"addChild\" in instance)) {\n throw new Error(`Cannot set children on non-container instance.`);\n }\n createRenderEffect(() => {\n insert(instance, () => props.children);\n });\n } else if (defer) {\n createRenderEffect(\n on(\n () => props[key as keyof typeof props],\n () => {\n setProp(instance, key, props[key as keyof typeof props]);\n },\n { defer },\n ),\n );\n } else {\n createRenderEffect(() => {\n setProp(instance, key, props[key as keyof typeof props]);\n });\n }\n }\n};\n\nexport const createContainerComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (\n props: Omit<OptionsType, \"children\"> & ContainerProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, [\n ...SOLID_PROP_KEYS,\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n applyProps(instance, initialisationProps, true);\n applyProps(instance, runtimeProps);\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createLeafComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (\n props: Omit<OptionsType, \"children\"> & LeafProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n return createContainerComponent<InstanceType, OptionsType>(PixiClass)(props);\n };\n};\n\nexport const createFilterComponent = <InstanceType extends Pixi.Filter, OptionsType extends object>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (props: OptionsType & FilterProps<InstanceType>): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, [\"ref\", \"as\"]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n for (const key in initialisationProps) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n } else if (key === \"children\") {\n throw new Error(`Cannot set children on non-container instance.`);\n } else {\n createRenderEffect(\n on(\n () => props[key as keyof typeof initialisationProps],\n () => {\n (instance as any)[key] = initialisationProps[key];\n },\n { defer: true },\n ),\n );\n }\n }\n\n for (const key in runtimeProps) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n }\n }\n\n return instance as InstanceType & JSX.Element;\n };\n};\n"],"names":[],"mappings":";;;AA8BO,MAAM,kBAAkB,CAAC,OAAO,MAAM,UAAU;AAWhD,MAAM,aAAa,CAIxB,UACA,OACA,UACG;AACH,aAAW,OAAO,OAAO;AACvB,QAAI,QAAQ,KAAM;AAElB,QAAI,QAAQ,OAAO;AACjB,yBAAmB,MAAM;AAEtB,cAAM,GAAG,EAAoC,QAAQ;AAAA,MACxD,CAAC;AAAA,IACH,WAAW,QAAQ,YAAY;AAC7B,UAAI,EAAE,cAAc,WAAW;AAC7B,cAAM,IAAI,MAAM,gDAAgD;AAAA,MAClE;AACA,yBAAmB,MAAM;AACvB,eAAO,UAAU,MAAM,MAAM,QAAQ;AAAA,MACvC,CAAC;AAAA,IACH,WAAW,OAAO;AAChB;AAAA,QACE;AAAA,UACE,MAAM,MAAM,GAAyB;AAAA,UACrC,MAAM;AACJ,oBAAQ,UAAU,KAAK,MAAM,GAAyB,CAAC;AAAA,UACzD;AAAA,UACA,EAAE,MAAA;AAAA,QAAM;AAAA,MACV;AAAA,IAEJ,OAAO;AACL,yBAAmB,MAAM;AACvB,gBAAQ,UAAU,KAAK,MAAM,GAAyB,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,2BAA2B,CAItC,cACG;AACH,SAAO,CACL,UAC+B;AAC/B,UAAM,CAAC,cAAc,mBAAmB,IAAI,WAAW,OAAO;AAAA,MAC5D,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAED,UAAM,WAAW,MAAM,MAAM,IAAI,UAAU,mBAA0B;AAErE,eAAW,UAAU,qBAAqB,IAAI;AAC9C,eAAW,UAAU,YAAY;AAEjC,WAAO;AAAA,EACT;AACF;AAEO,MAAM,sBAAsB,CAIjC,cACG;AACH,SAAO,CACL,UAC+B;AAC/B,WAAO,yBAAoD,SAAS,EAAE,KAAK;AAAA,EAC7E;AACF;"}
|
package/dist/pixi-components.js
CHANGED
|
@@ -1,49 +1,5 @@
|
|
|
1
1
|
import { RenderContainer as RenderContainer$1, RenderLayer as RenderLayer$1, AnimatedSprite as AnimatedSprite$1, BitmapText as BitmapText$1, Container as Container$1, Graphics as Graphics$1, HTMLText as HTMLText$1, MeshPlane as MeshPlane$1, MeshRope as MeshRope$1, NineSliceSprite as NineSliceSprite$1, ParticleContainer as ParticleContainer$1, PerspectiveMesh as PerspectiveMesh$1, Sprite as Sprite$1, Text as Text$1, TilingSprite as TilingSprite$1 } from "pixi.js";
|
|
2
|
-
import {
|
|
3
|
-
import { PIXI_SOLID_EVENT_HANDLER_NAMES } from "./pixi-events.js";
|
|
4
|
-
import { insert, setProp } from "./renderer.js";
|
|
5
|
-
const SOLID_PROP_KEYS = ["ref", "as", "children"];
|
|
6
|
-
const applyProps = (instance, props, defer) => {
|
|
7
|
-
for (const key in props) {
|
|
8
|
-
if (key === "as") continue;
|
|
9
|
-
if (key === "ref") {
|
|
10
|
-
createRenderEffect(() => {
|
|
11
|
-
props[key](instance);
|
|
12
|
-
});
|
|
13
|
-
} else if (key === "children") {
|
|
14
|
-
if (!("addChild" in instance)) {
|
|
15
|
-
throw new Error(`Cannot set children on non-container instance.`);
|
|
16
|
-
}
|
|
17
|
-
createRenderEffect(() => {
|
|
18
|
-
insert(instance, () => props.children);
|
|
19
|
-
});
|
|
20
|
-
} else if (defer) {
|
|
21
|
-
createRenderEffect(on(() => props[key], () => {
|
|
22
|
-
setProp(instance, key, props[key]);
|
|
23
|
-
}, {
|
|
24
|
-
defer
|
|
25
|
-
}));
|
|
26
|
-
} else {
|
|
27
|
-
createRenderEffect(() => {
|
|
28
|
-
setProp(instance, key, props[key]);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const createContainerComponent = (PixiClass) => {
|
|
34
|
-
return (props) => {
|
|
35
|
-
const [runtimeProps, initialisationProps] = splitProps(props, [...SOLID_PROP_KEYS, ...PIXI_SOLID_EVENT_HANDLER_NAMES]);
|
|
36
|
-
const instance = props.as || new PixiClass(initialisationProps);
|
|
37
|
-
applyProps(instance, initialisationProps, true);
|
|
38
|
-
applyProps(instance, runtimeProps);
|
|
39
|
-
return instance;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
const createLeafComponent = (PixiClass) => {
|
|
43
|
-
return (props) => {
|
|
44
|
-
return createContainerComponent(PixiClass)(props);
|
|
45
|
-
};
|
|
46
|
-
};
|
|
2
|
+
import { createLeafComponent, createContainerComponent } from "./component-creation.js";
|
|
47
3
|
const AnimatedSprite = createLeafComponent(AnimatedSprite$1);
|
|
48
4
|
const BitmapText = createLeafComponent(BitmapText$1);
|
|
49
5
|
const Container = createContainerComponent(Container$1);
|
|
@@ -72,10 +28,8 @@ export {
|
|
|
72
28
|
PerspectiveMesh,
|
|
73
29
|
RenderContainer,
|
|
74
30
|
RenderLayer,
|
|
75
|
-
SOLID_PROP_KEYS,
|
|
76
31
|
Sprite,
|
|
77
32
|
Text,
|
|
78
|
-
TilingSprite
|
|
79
|
-
applyProps
|
|
33
|
+
TilingSprite
|
|
80
34
|
};
|
|
81
35
|
//# sourceMappingURL=pixi-components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixi-components.js","sources":["../src/pixi-components.tsx"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport {\n AnimatedSprite as PixiAnimatedSprite,\n BitmapText as PixiBitmapText,\n Container as PixiContainer,\n Graphics as PixiGraphics,\n HTMLText as PixiHTMLText,\n MeshPlane as PixiMeshPlane,\n MeshRope as PixiMeshRope,\n NineSliceSprite as PixiNineSliceSprite,\n ParticleContainer as PixiParticleContainer,\n PerspectiveMesh as PixiPerspectiveMesh,\n RenderContainer as PixiRenderContainer,\n RenderLayer as PixiRenderLayer,\n Sprite as PixiSprite,\n Text as PixiText,\n TilingSprite as PixiTilingSprite,\n} from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { createRenderEffect, on, splitProps } from \"solid-js\";\nimport type { PixiEventHandlerMap } from \"./pixi-events\";\n\nimport { PIXI_SOLID_EVENT_HANDLER_NAMES } from \"./pixi-events\";\nimport { insert, setProp } from \"./renderer\";\n\n/**\n * Prop definition for components that CAN have children\n */\nexport type ContainerProps<Component> = PixiEventHandlerMap & {\n ref?: Ref<Component>;\n as?: Component;\n children?: JSX.Element;\n};\n\n/**\n * Prop definition for components that CANNOT have children\n */\nexport type LeafProps<Component> = Omit<ContainerProps<Component>, \"children\">;\n\n// Keys that are specific to Solid components and not Pixi props\nexport const SOLID_PROP_KEYS = [\"ref\", \"as\", \"children\"] as const;\n\n/**\n * Apply's the props to a Pixi instance with subsriptions to maintain reactivity.\n *\n * @param instance The Pixi instance we want to apply props to.\n * @param props The props object.\n * @param defer Defers the createRenderEffect so the props aren't set on the first run.\n * This is useful because setting initialisation props can have unintended side effects.\n * Notibly in AnimatedSprite, if we set the textures roperty after instantiation it will stop the instance from playing.\n */\nexport const applyProps = <InstanceType extends PixiContainer, OptionsType extends ContainerProps<InstanceType>>(\n instance: InstanceType,\n props: OptionsType,\n defer?: boolean\n) => {\n for (const key in props) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n } else if (key === \"children\") {\n if (!(\"addChild\" in instance)) {\n throw new Error(`Cannot set children on non-container instance.`);\n }\n createRenderEffect(() => {\n insert(instance, () => props.children);\n });\n } else if (defer) {\n createRenderEffect(\n on(\n () => props[key as keyof typeof props],\n () => {\n setProp(instance, key, props[key as keyof typeof props]);\n },\n { defer }\n )\n );\n } else {\n createRenderEffect(() => {\n setProp(instance, key, props[key as keyof typeof props]);\n });\n }\n }\n};\n\nconst createContainerComponent = <InstanceType extends PixiContainer, OptionsType extends object>(\n PixiClass: new (props: OptionsType) => InstanceType\n) => {\n return (props: Omit<OptionsType, \"children\"> & ContainerProps<InstanceType>): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, [\n ...SOLID_PROP_KEYS,\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n applyProps(instance, initialisationProps, true);\n applyProps(instance, runtimeProps);\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nconst createLeafComponent = <InstanceType extends PixiContainer, OptionsType extends object>(\n PixiClass: new (props: OptionsType) => InstanceType\n) => {\n return (props: Omit<OptionsType, \"children\"> & LeafProps<InstanceType>): InstanceType & JSX.Element => {\n return createContainerComponent<InstanceType, OptionsType>(PixiClass)(props);\n };\n};\n\n/**\n * A SolidJS component that renders a `PIXI.AnimatedSprite`.\n */\nexport const AnimatedSprite = createLeafComponent<PixiAnimatedSprite, Pixi.AnimatedSpriteOptions>(PixiAnimatedSprite);\n/**\n * A SolidJS component that renders a `PIXI.BitmapText`.\n */\nexport const BitmapText = createLeafComponent<PixiBitmapText, Pixi.TextOptions>(PixiBitmapText);\n/**\n * A SolidJS component that renders a `PIXI.Container`.\n */\nexport const Container = createContainerComponent<PixiContainer, Pixi.ContainerOptions>(PixiContainer);\n/**\n * A SolidJS component that renders a `PIXI.Graphics`.\n * Use a ref to access the underlying graphics instance and draw with it.\n */\nexport const Graphics = createLeafComponent<PixiGraphics, Pixi.GraphicsOptions>(PixiGraphics);\n/**\n * A SolidJS component that renders a `PIXI.HTMLText`.\n */\nexport const HTMLText = createLeafComponent<PixiHTMLText, Pixi.HTMLTextOptions>(PixiHTMLText);\n\n/**\n * A SolidJS component that renders a `PIXI.MeshPlane`.\n */\nexport const MeshPlane = createLeafComponent<PixiMeshPlane, Pixi.MeshPlaneOptions>(PixiMeshPlane);\n\n/**\n * A SolidJS component that renders a `PIXI.MeshRope`.\n */\nexport const MeshRope = createLeafComponent<PixiMeshRope, Pixi.MeshRopeOptions>(PixiMeshRope);\n\n/**\n * A SolidJS component that renders a `PIXI.NineSliceSprite`.\n */\nexport const NineSliceSprite = createLeafComponent<PixiNineSliceSprite, Pixi.NineSliceSpriteOptions>(\n PixiNineSliceSprite\n);\n\n/**\n * A SolidJS component that renders a `PIXI.ParticleContainer`.\n *\n * Particles should be added and removed from this component imperatively. Please see the docs for a reference example.\n */\nexport const ParticleContainer = createLeafComponent<PixiParticleContainer, Pixi.ParticleContainerOptions>(\n PixiParticleContainer\n);\n\n/**\n * A SolidJS component that renders a `PIXI.PerspectiveMesh`.\n */\nexport const PerspectiveMesh = createLeafComponent<PixiPerspectiveMesh, Pixi.PerspectivePlaneOptions>(\n PixiPerspectiveMesh\n);\n\n/**\n * A SolidJS component that renders a `PIXI.RenderContainer`.\n */\nexport const RenderContainer = createContainerComponent<PixiRenderContainer, Pixi.RenderContainerOptions>(\n PixiRenderContainer\n);\n\n/**\n * A SolidJS component that renders a `PIXI.RenderLayer`.\n */\nexport const RenderLayer = createContainerComponent<PixiRenderLayer, Pixi.RenderLayerOptions>(PixiRenderLayer);\n\n/**\n * A SolidJS component that renders a `PIXI.Sprite`.\n */\nexport const Sprite = createLeafComponent<PixiSprite, Pixi.SpriteOptions>(PixiSprite);\n/**\n * A SolidJS component that renders a `PIXI.Text`.\n */\nexport const Text = createLeafComponent<PixiText, Pixi.CanvasTextOptions>(PixiText);\n\n/**\n * A SolidJS component that renders a `PIXI.TilingSprite`.\n */\nexport const TilingSprite = createLeafComponent<PixiTilingSprite, Pixi.TilingSpriteOptions>(PixiTilingSprite);\n\n// export const MeshGeometry = createLeafComponent<PixiMeshGeometry, Pixi.MeshGeometryOptions>(PixiMeshGeometry);\n\n// export const NineSliceGeometry = createLeafComponent<PixiNineSliceGeometry, Pixi.NineSliceGeometryOptions>(\n// PixiNineSliceGeometry\n// );\n\n// export const Particle = createLeafComponent<PixiParticle, Pixi.ParticleOptions>(PixiParticle);\n\n// export const PerspectivePlaneGeometry = createLeafComponent<\n// PixiPerspectivePlaneGeometry,\n// Pixi.PerspectivePlaneGeometryOptions\n// >(PixiPerspectivePlaneGeometry);\n\n// export const PlaneGeometry = createLeafComponent<PixiPlaneGeometry, Pixi.PlaneGeometryOptions>(PixiPlaneGeometry);\n\n// export const RopeGeometry = createLeafComponent<PixiRopeGeometry, Pixi.RopeGeometryOptions>(PixiRopeGeometry);\n\n// TODO: Do we need a component for the Culler. It needs to interact with the stage directly.\n// export const Culler = createLeafComponent<PixiCuller, Pixi.Culler>(PixiCuller);\n"],"names":["SOLID_PROP_KEYS","applyProps","instance","props","defer","key","createRenderEffect","Error","insert","children","on","setProp","createContainerComponent","PixiClass","runtimeProps","initialisationProps","splitProps","PIXI_SOLID_EVENT_HANDLER_NAMES","as","createLeafComponent","AnimatedSprite","PixiAnimatedSprite","BitmapText","PixiBitmapText","Container","PixiContainer","Graphics","PixiGraphics","HTMLText","PixiHTMLText","MeshPlane","PixiMeshPlane","MeshRope","PixiMeshRope","NineSliceSprite","PixiNineSliceSprite","ParticleContainer","PixiParticleContainer","PerspectiveMesh","PixiPerspectiveMesh","RenderContainer","PixiRenderContainer","RenderLayer","PixiRenderLayer","Sprite","PixiSprite","Text","PixiText","TilingSprite","PixiTilingSprite"],"mappings":";;;;AAwCO,MAAMA,kBAAkB,CAAC,OAAO,MAAM,UAAU;AAWhD,MAAMC,aAAa,CACxBC,UACAC,OACAC,UACG;AACH,aAAWC,OAAOF,OAAO;AACvB,QAAIE,QAAQ,KAAM;AAElB,QAAIA,QAAQ,OAAO;AACjBC,yBAAmB,MAAM;AAEtBH,cAAME,GAAG,EAAoCH,QAAQ;AAAA,MACxD,CAAC;AAAA,IACH,WAAWG,QAAQ,YAAY;AAC7B,UAAI,EAAE,cAAcH,WAAW;AAC7B,cAAM,IAAIK,MAAM,gDAAgD;AAAA,MAClE;AACAD,yBAAmB,MAAM;AACvBE,eAAON,UAAU,MAAMC,MAAMM,QAAQ;AAAA,MACvC,CAAC;AAAA,IACH,WAAWL,OAAO;AAChBE,yBACEI,GACE,MAAMP,MAAME,GAAyB,GACrC,MAAM;AACJM,gBAAQT,UAAUG,KAAKF,MAAME,GAAyB,CAAC;AAAA,MACzD,GACA;AAAA,QAAED;AAAAA,MAAAA,CACJ,CACF;AAAA,IACF,OAAO;AACLE,yBAAmB,MAAM;AACvBK,gBAAQT,UAAUG,KAAKF,MAAME,GAAyB,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEA,MAAMO,2BAA2B,CAC/BC,cACG;AACH,SAAO,CAACV,UAAoG;AAC1G,UAAM,CAACW,cAAcC,mBAAmB,IAAIC,WAAWb,OAAO,CAC5D,GAAGH,iBACH,GAAGiB,8BAA8B,CAClC;AAED,UAAMf,WAAWC,MAAMe,MAAM,IAAIL,UAAUE,mBAA0B;AAErEd,eAAWC,UAAUa,qBAAqB,IAAI;AAC9Cd,eAAWC,UAAUY,YAAY;AAEjC,WAAOZ;AAAAA,EACT;AACF;AAEA,MAAMiB,sBAAsB,CAC1BN,cACG;AACH,SAAO,CAACV,UAA+F;AACrG,WAAOS,yBAAoDC,SAAS,EAAEV,KAAK;AAAA,EAC7E;AACF;AAKO,MAAMiB,iBAAiBD,oBAAoEE,gBAAkB;AAI7G,MAAMC,aAAaH,oBAAsDI,YAAc;AAIvF,MAAMC,YAAYZ,yBAA+Da,WAAa;AAK9F,MAAMC,WAAWP,oBAAwDQ,UAAY;AAIrF,MAAMC,WAAWT,oBAAwDU,UAAY;AAKrF,MAAMC,YAAYX,oBAA0DY,WAAa;AAKzF,MAAMC,WAAWb,oBAAwDc,UAAY;AAKrF,MAAMC,kBAAkBf,oBAC7BgB,iBACF;AAOO,MAAMC,oBAAoBjB,oBAC/BkB,mBACF;AAKO,MAAMC,kBAAkBnB,oBAC7BoB,iBACF;AAKO,MAAMC,kBAAkB5B,yBAC7B6B,iBACF;AAKO,MAAMC,cAAc9B,yBAAmE+B,aAAe;AAKtG,MAAMC,SAASzB,oBAAoD0B,QAAU;AAI7E,MAAMC,OAAO3B,oBAAsD4B,MAAQ;AAK3E,MAAMC,eAAe7B,oBAAgE8B,cAAgB;"}
|
|
1
|
+
{"version":3,"file":"pixi-components.js","sources":["../src/pixi-components.tsx"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport {\n AnimatedSprite as PixiAnimatedSprite,\n BitmapText as PixiBitmapText,\n Container as PixiContainer,\n Graphics as PixiGraphics,\n HTMLText as PixiHTMLText,\n MeshPlane as PixiMeshPlane,\n MeshRope as PixiMeshRope,\n NineSliceSprite as PixiNineSliceSprite,\n ParticleContainer as PixiParticleContainer,\n PerspectiveMesh as PixiPerspectiveMesh,\n RenderContainer as PixiRenderContainer,\n RenderLayer as PixiRenderLayer,\n Sprite as PixiSprite,\n Text as PixiText,\n TilingSprite as PixiTilingSprite,\n} from \"pixi.js\";\nimport { createContainerComponent, createLeafComponent } from \"./component-creation\";\n\n/**\n * A SolidJS component that renders a `PIXI.AnimatedSprite`.\n */\nexport const AnimatedSprite = createLeafComponent<PixiAnimatedSprite, Pixi.AnimatedSpriteOptions>(PixiAnimatedSprite);\n/**\n * A SolidJS component that renders a `PIXI.BitmapText`.\n */\nexport const BitmapText = createLeafComponent<PixiBitmapText, Pixi.TextOptions>(PixiBitmapText);\n/**\n * A SolidJS component that renders a `PIXI.Container`.\n */\nexport const Container = createContainerComponent<PixiContainer, Pixi.ContainerOptions>(PixiContainer);\n/**\n * A SolidJS component that renders a `PIXI.Graphics`.\n * Use a ref to access the underlying graphics instance and draw with it.\n */\nexport const Graphics = createLeafComponent<PixiGraphics, Pixi.GraphicsOptions>(PixiGraphics);\n/**\n * A SolidJS component that renders a `PIXI.HTMLText`.\n */\nexport const HTMLText = createLeafComponent<PixiHTMLText, Pixi.HTMLTextOptions>(PixiHTMLText);\n\n/**\n * A SolidJS component that renders a `PIXI.MeshPlane`.\n */\nexport const MeshPlane = createLeafComponent<PixiMeshPlane, Pixi.MeshPlaneOptions>(PixiMeshPlane);\n\n/**\n * A SolidJS component that renders a `PIXI.MeshRope`.\n */\nexport const MeshRope = createLeafComponent<PixiMeshRope, Pixi.MeshRopeOptions>(PixiMeshRope);\n\n/**\n * A SolidJS component that renders a `PIXI.NineSliceSprite`.\n */\nexport const NineSliceSprite = createLeafComponent<PixiNineSliceSprite, Pixi.NineSliceSpriteOptions>(\n PixiNineSliceSprite\n);\n\n/**\n * A SolidJS component that renders a `PIXI.ParticleContainer`.\n *\n * Particles should be added and removed from this component imperatively. Please see the docs for a reference example.\n */\nexport const ParticleContainer = createLeafComponent<PixiParticleContainer, Pixi.ParticleContainerOptions>(\n PixiParticleContainer\n);\n\n/**\n * A SolidJS component that renders a `PIXI.PerspectiveMesh`.\n */\nexport const PerspectiveMesh = createLeafComponent<PixiPerspectiveMesh, Pixi.PerspectivePlaneOptions>(\n PixiPerspectiveMesh\n);\n\n/**\n * A SolidJS component that renders a `PIXI.RenderContainer`.\n */\nexport const RenderContainer = createContainerComponent<PixiRenderContainer, Pixi.RenderContainerOptions>(\n PixiRenderContainer\n);\n\n/**\n * A SolidJS component that renders a `PIXI.RenderLayer`.\n */\nexport const RenderLayer = createContainerComponent<PixiRenderLayer, Pixi.RenderLayerOptions>(PixiRenderLayer);\n\n/**\n * A SolidJS component that renders a `PIXI.Sprite`.\n */\nexport const Sprite = createLeafComponent<PixiSprite, Pixi.SpriteOptions>(PixiSprite);\n/**\n * A SolidJS component that renders a `PIXI.Text`.\n */\nexport const Text = createLeafComponent<PixiText, Pixi.CanvasTextOptions>(PixiText);\n\n/**\n * A SolidJS component that renders a `PIXI.TilingSprite`.\n */\nexport const TilingSprite = createLeafComponent<PixiTilingSprite, Pixi.TilingSpriteOptions>(PixiTilingSprite);\n\n// export const MeshGeometry = createLeafComponent<PixiMeshGeometry, Pixi.MeshGeometryOptions>(PixiMeshGeometry);\n\n// export const NineSliceGeometry = createLeafComponent<PixiNineSliceGeometry, Pixi.NineSliceGeometryOptions>(\n// PixiNineSliceGeometry\n// );\n\n// export const Particle = createLeafComponent<PixiParticle, Pixi.ParticleOptions>(PixiParticle);\n\n// export const PerspectivePlaneGeometry = createLeafComponent<\n// PixiPerspectivePlaneGeometry,\n// Pixi.PerspectivePlaneGeometryOptions\n// >(PixiPerspectivePlaneGeometry);\n\n// export const PlaneGeometry = createLeafComponent<PixiPlaneGeometry, Pixi.PlaneGeometryOptions>(PixiPlaneGeometry);\n\n// export const RopeGeometry = createLeafComponent<PixiRopeGeometry, Pixi.RopeGeometryOptions>(PixiRopeGeometry);\n\n// TODO: Do we need a component for the Culler. It needs to interact with the stage directly.\n// export const Culler = createLeafComponent<PixiCuller, Pixi.Culler>(PixiCuller);\n"],"names":["AnimatedSprite","createLeafComponent","PixiAnimatedSprite","BitmapText","PixiBitmapText","Container","createContainerComponent","PixiContainer","Graphics","PixiGraphics","HTMLText","PixiHTMLText","MeshPlane","PixiMeshPlane","MeshRope","PixiMeshRope","NineSliceSprite","PixiNineSliceSprite","ParticleContainer","PixiParticleContainer","PerspectiveMesh","PixiPerspectiveMesh","RenderContainer","PixiRenderContainer","RenderLayer","PixiRenderLayer","Sprite","PixiSprite","Text","PixiText","TilingSprite","PixiTilingSprite"],"mappings":";;AAuBO,MAAMA,iBAAiBC,oBAAoEC,gBAAkB;AAI7G,MAAMC,aAAaF,oBAAsDG,YAAc;AAIvF,MAAMC,YAAYC,yBAA+DC,WAAa;AAK9F,MAAMC,WAAWP,oBAAwDQ,UAAY;AAIrF,MAAMC,WAAWT,oBAAwDU,UAAY;AAKrF,MAAMC,YAAYX,oBAA0DY,WAAa;AAKzF,MAAMC,WAAWb,oBAAwDc,UAAY;AAKrF,MAAMC,kBAAkBf,oBAC7BgB,iBACF;AAOO,MAAMC,oBAAoBjB,oBAC/BkB,mBACF;AAKO,MAAMC,kBAAkBnB,oBAC7BoB,iBACF;AAKO,MAAMC,kBAAkBhB,yBAC7BiB,iBACF;AAKO,MAAMC,cAAclB,yBAAmEmB,aAAe;AAKtG,MAAMC,SAASzB,oBAAoD0B,QAAU;AAI7E,MAAMC,OAAO3B,oBAAsD4B,MAAQ;AAK3E,MAAMC,eAAe7B,oBAAgE8B,cAAgB;"}
|
package/dist/pixi-stage.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo } from "solid-js/web";
|
|
2
|
+
import { applyProps } from "./component-creation.js";
|
|
2
3
|
import { getPixiApp } from "./pixi-application.js";
|
|
3
|
-
import { applyProps } from "./pixi-components.js";
|
|
4
4
|
const PixiStage = (props) => {
|
|
5
5
|
const pixiApp = getPixiApp();
|
|
6
6
|
applyProps(pixiApp.stage, props);
|
package/dist/pixi-stage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pixi-stage.js","sources":["../src/pixi-stage.tsx"],"sourcesContent":["import type { Container, ContainerOptions } from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport {
|
|
1
|
+
{"version":3,"file":"pixi-stage.js","sources":["../src/pixi-stage.tsx"],"sourcesContent":["import type { Container, ContainerOptions } from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { applyProps } from \"./component-creation\";\nimport { getPixiApp } from \"./pixi-application\";\nimport type { PixiEventHandlerMap } from \"./pixi-events\";\n\nexport type PixiStageProps = PixiEventHandlerMap &\n Omit<ContainerOptions, \"children\"> & {\n ref?: Ref<Container>;\n children?: JSX.Element;\n };\n\n/**\n * PixiStage\n *\n * The root container for rendering Pixi display objects. This component\n * uses the application stage (`pixiApp.stage`) as the mount point and\n * applies props and event handlers to it.\n *\n * Props:\n * - `ref` (optional): receives the stage container reference.\n * - Event handler props (e.g. `onpointerdown`) are forwarded to the stage.\n * - Any other container options supported by Pixi may be passed.\n *\n * Children passed to `PixiStage` are inserted into the application stage.\n */\nexport const PixiStage = (props: PixiStageProps): JSX.Element => {\n const pixiApp = getPixiApp();\n\n applyProps(pixiApp.stage, props);\n\n return <>{pixiApp.stage}</>;\n};\n"],"names":["PixiStage","props","pixiApp","getPixiApp","applyProps","stage","_$memo"],"mappings":";;;AA0BO,MAAMA,YAAYA,CAACC,UAAuC;AAC/D,QAAMC,UAAUC,WAAAA;AAEhBC,aAAWF,QAAQG,OAAOJ,KAAK;AAE/B,SAAAK,KAAA,MAAUJ,QAAQG,KAAK;AACzB;"}
|
package/dist/renderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sources":["../src/renderer.tsx"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"renderer.js","sources":["../src/renderer.tsx"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { Text as PixiText } from \"pixi.js\";\nimport { createRenderer } from \"solid-js/universal\";\nimport type { PIXI_EVENT_NAMES, PixiEventHandlerMap } from \"./pixi-events\";\nimport { PIXI_EVENT_HANDLER_NAME_SET } from \"./pixi-events\";\n\nexport const {\n effect,\n memo,\n createComponent,\n createElement,\n createTextNode,\n insertNode,\n insert,\n setProp,\n mergeProps,\n use,\n render,\n spread,\n} = createRenderer<Pixi.Container>({\n createElement(name: string) {\n // This function is for lowercase string tags like `<container />`.\n // To support tree-shaking, we require users to import components\n // directly and use them with an uppercase name like `<Container />`,\n // which does not call this function.\n throw new Error(\n `Cannot create element \"${name}\". Please import components directly from 'pixi-solid' and use them with a capital letter.`\n );\n },\n createTextNode(value) {\n return new PixiText({ text: value });\n },\n replaceText(textNode: PixiText, value) {\n textNode.text = value;\n },\n setProperty(node, name, value, prev) {\n // Check for event listeners and handle them appropriately.\n if (PIXI_EVENT_HANDLER_NAME_SET.has(name as keyof PixiEventHandlerMap)) {\n // Remove the 'on' prefix to get the actual event name.\n const eventName = name.slice(2) as (typeof PIXI_EVENT_NAMES)[number];\n\n if (prev) {\n node.removeEventListener(eventName, prev as any);\n }\n node.addEventListener(eventName, value as any);\n return;\n }\n\n if (name in node) {\n (node as any)[name] = value;\n return;\n }\n },\n insertNode(parent, node, anchor) {\n // RenderLayer uses `attach` instead of `addChild`.\n if (\"attach\" in parent && typeof parent.attach === \"function\") {\n parent.attach(node);\n // Note: `attach` does not support anchoring, so we ignore the anchor.\n return;\n }\n\n if (!(\"addChildAt\" in parent) || !(\"addChild\" in parent) || typeof parent.addChild !== \"function\") {\n throw new Error(\"Parent does not support children.\");\n }\n\n if (anchor) {\n parent.addChildAt(node, parent.children.indexOf(anchor));\n } else {\n parent.addChild(node);\n }\n },\n isTextNode(node) {\n return node instanceof PixiText;\n },\n removeNode(_, node) {\n node.removeFromParent();\n node.destroy({ children: true });\n },\n getParentNode(node) {\n return node?.parent ?? undefined;\n },\n getFirstChild(node) {\n return node.children?.[0];\n },\n getNextSibling(node) {\n if (!node.parent) return undefined;\n const index = node.parent.children.indexOf(node);\n // Return the next child if it exists, otherwise undefined.\n return index > -1 ? node.parent.children[index + 1] : undefined;\n },\n});\n"],"names":["effect","memo","createComponent","createElement","createTextNode","insertNode","insert","setProp","mergeProps","use","render","spread","createRenderer","name","Error","value","PixiText","text","replaceText","textNode","setProperty","node","prev","PIXI_EVENT_HANDLER_NAME_SET","has","eventName","slice","removeEventListener","addEventListener","parent","anchor","attach","addChild","addChildAt","children","indexOf","isTextNode","removeNode","_","removeFromParent","destroy","getParentNode","undefined","getFirstChild","getNextSibling","index"],"mappings":";;;AAMO,MAAM;AAAA,EACXA;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACF,IAAIC,eAA+B;AAAA,EACjCT,cAAcU,MAAc;AAK1B,UAAM,IAAIC,MACR,0BAA0BD,IAAI,4FAChC;AAAA,EACF;AAAA,EACAT,eAAeW,OAAO;AACpB,WAAO,IAAIC,KAAS;AAAA,MAAEC,MAAMF;AAAAA,IAAAA,CAAO;AAAA,EACrC;AAAA,EACAG,YAAYC,UAAoBJ,OAAO;AACrCI,aAASF,OAAOF;AAAAA,EAClB;AAAA,EACAK,YAAYC,MAAMR,MAAME,OAAOO,MAAM;AAEnC,QAAIC,4BAA4BC,IAAIX,IAAiC,GAAG;AAEtE,YAAMY,YAAYZ,KAAKa,MAAM,CAAC;AAE9B,UAAIJ,MAAM;AACRD,aAAKM,oBAAoBF,WAAWH,IAAW;AAAA,MACjD;AACAD,WAAKO,iBAAiBH,WAAWV,KAAY;AAC7C;AAAA,IACF;AAEA,QAAIF,QAAQQ,MAAM;AACfA,WAAaR,IAAI,IAAIE;AACtB;AAAA,IACF;AAAA,EACF;AAAA,EACAV,WAAWwB,QAAQR,MAAMS,QAAQ;AAE/B,QAAI,YAAYD,UAAU,OAAOA,OAAOE,WAAW,YAAY;AAC7DF,aAAOE,OAAOV,IAAI;AAElB;AAAA,IACF;AAEA,QAAI,EAAE,gBAAgBQ,WAAW,EAAE,cAAcA,WAAW,OAAOA,OAAOG,aAAa,YAAY;AACjG,YAAM,IAAIlB,MAAM,mCAAmC;AAAA,IACrD;AAEA,QAAIgB,QAAQ;AACVD,aAAOI,WAAWZ,MAAMQ,OAAOK,SAASC,QAAQL,MAAM,CAAC;AAAA,IACzD,OAAO;AACLD,aAAOG,SAASX,IAAI;AAAA,IACtB;AAAA,EACF;AAAA,EACAe,WAAWf,MAAM;AACf,WAAOA,gBAAgBL;AAAAA,EACzB;AAAA,EACAqB,WAAWC,GAAGjB,MAAM;AAClBA,SAAKkB,iBAAAA;AACLlB,SAAKmB,QAAQ;AAAA,MAAEN,UAAU;AAAA,IAAA,CAAM;AAAA,EACjC;AAAA,EACAO,cAAcpB,MAAM;AAClB,WAAOA,MAAMQ,UAAUa;AAAAA,EACzB;AAAA,EACAC,cAActB,MAAM;AAClB,WAAOA,KAAKa,WAAW,CAAC;AAAA,EAC1B;AAAA,EACAU,eAAevB,MAAM;AACnB,QAAI,CAACA,KAAKQ,OAAQ,QAAOa;AACzB,UAAMG,QAAQxB,KAAKQ,OAAOK,SAASC,QAAQd,IAAI;AAE/C,WAAOwB,QAAQ,KAAKxB,KAAKQ,OAAOK,SAASW,QAAQ,CAAC,IAAIH;AAAAA,EACxD;AACF,CAAC;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type * as Pixi from "pixi.js";
|
|
2
|
+
import type { JSX, Ref } from "solid-js";
|
|
3
|
+
import type { PixiEventHandlerMap } from "./pixi-events";
|
|
4
|
+
/**
|
|
5
|
+
* Prop definition for components that CAN have children
|
|
6
|
+
*/
|
|
7
|
+
export type ContainerProps<Component> = PixiEventHandlerMap & {
|
|
8
|
+
ref?: Ref<Component>;
|
|
9
|
+
as?: Component;
|
|
10
|
+
children?: JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Prop definition for components that CANNOT have children
|
|
14
|
+
*/
|
|
15
|
+
export type LeafProps<Component> = Omit<ContainerProps<Component>, "children">;
|
|
16
|
+
/**
|
|
17
|
+
* Prop definition for filter components
|
|
18
|
+
*/
|
|
19
|
+
export type FilterProps<Component> = {
|
|
20
|
+
ref?: Ref<Component>;
|
|
21
|
+
as?: Component;
|
|
22
|
+
};
|
|
23
|
+
export declare const SOLID_PROP_KEYS: readonly ["ref", "as", "children"];
|
|
24
|
+
/**
|
|
25
|
+
* Apply's the props to a Pixi instance with subsriptions to maintain reactivity.
|
|
26
|
+
*
|
|
27
|
+
* @param instance The Pixi instance we want to apply props to.
|
|
28
|
+
* @param props The props object.
|
|
29
|
+
* @param defer Defers the createRenderEffect so the props aren't set on the first run.
|
|
30
|
+
* This is useful because setting initialisation props can have unintended side effects.
|
|
31
|
+
* Notibly in AnimatedSprite, if we set the textures roperty after instantiation it will stop the instance from playing.
|
|
32
|
+
*/
|
|
33
|
+
export declare const applyProps: <InstanceType extends Pixi.Container, OptionsType extends ContainerProps<InstanceType>>(instance: InstanceType, props: OptionsType, defer?: boolean) => void;
|
|
34
|
+
export declare const createContainerComponent: <InstanceType extends Pixi.Container, OptionsType extends object>(PixiClass: new (props: OptionsType) => InstanceType) => (props: Omit<OptionsType, "children"> & ContainerProps<InstanceType>) => InstanceType & JSX.Element;
|
|
35
|
+
export declare const createLeafComponent: <InstanceType extends Pixi.Container, OptionsType extends object>(PixiClass: new (props: OptionsType) => InstanceType) => (props: Omit<OptionsType, "children"> & LeafProps<InstanceType>) => InstanceType & JSX.Element;
|
|
36
|
+
export declare const createFilterComponent: <InstanceType extends Pixi.Filter, OptionsType extends object>(PixiClass: new (props: OptionsType) => InstanceType) => (props: OptionsType & FilterProps<InstanceType>) => InstanceType & JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
export type { ContainerProps, LeafProps } from "./component-creation";
|
|
1
2
|
export { onResize } from "./on-resize";
|
|
2
3
|
export type { PixiApplicationProps } from "./pixi-application";
|
|
3
4
|
export { delay, getPixiApp, getTicker, onTick, PixiApplication, TickerProvider, } from "./pixi-application";
|
|
4
5
|
export { PixiCanvas } from "./pixi-canvas";
|
|
5
|
-
export type { ContainerProps, LeafProps } from "./pixi-components";
|
|
6
6
|
export { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, NineSliceSprite, ParticleContainer, PerspectiveMesh, RenderContainer, RenderLayer, Sprite, Text, TilingSprite, } from "./pixi-components";
|
|
7
7
|
export type { PixiEventHandlerMap } from "./pixi-events";
|
|
8
8
|
export { PIXI_EVENT_NAMES, PIXI_SOLID_EVENT_HANDLER_NAMES } from "./pixi-events";
|
|
@@ -1,102 +1,76 @@
|
|
|
1
1
|
import type * as Pixi from "pixi.js";
|
|
2
|
-
import { Container as PixiContainer } from "pixi.js";
|
|
3
|
-
import type { JSX, Ref } from "solid-js";
|
|
4
|
-
import type { PixiEventHandlerMap } from "./pixi-events";
|
|
5
|
-
/**
|
|
6
|
-
* Prop definition for components that CAN have children
|
|
7
|
-
*/
|
|
8
|
-
export type ContainerProps<Component> = PixiEventHandlerMap & {
|
|
9
|
-
ref?: Ref<Component>;
|
|
10
|
-
as?: Component;
|
|
11
|
-
children?: JSX.Element;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Prop definition for components that CANNOT have children
|
|
15
|
-
*/
|
|
16
|
-
export type LeafProps<Component> = Omit<ContainerProps<Component>, "children">;
|
|
17
|
-
export declare const SOLID_PROP_KEYS: readonly ["ref", "as", "children"];
|
|
18
|
-
/**
|
|
19
|
-
* Apply's the props to a Pixi instance with subsriptions to maintain reactivity.
|
|
20
|
-
*
|
|
21
|
-
* @param instance The Pixi instance we want to apply props to.
|
|
22
|
-
* @param props The props object.
|
|
23
|
-
* @param defer Defers the createRenderEffect so the props aren't set on the first run.
|
|
24
|
-
* This is useful because setting initialisation props can have unintended side effects.
|
|
25
|
-
* Notibly in AnimatedSprite, if we set the textures roperty after instantiation it will stop the instance from playing.
|
|
26
|
-
*/
|
|
27
|
-
export declare const applyProps: <InstanceType extends PixiContainer, OptionsType extends ContainerProps<InstanceType>>(instance: InstanceType, props: OptionsType, defer?: boolean) => void;
|
|
28
2
|
/**
|
|
29
3
|
* A SolidJS component that renders a `PIXI.AnimatedSprite`.
|
|
30
4
|
*/
|
|
31
|
-
export declare const AnimatedSprite: (props: Omit<Pixi.AnimatedSpriteOptions, "children"> & LeafProps<Pixi.AnimatedSprite>) => Pixi.AnimatedSprite & JSX.Element;
|
|
5
|
+
export declare const AnimatedSprite: (props: Omit<Pixi.AnimatedSpriteOptions, "children"> & import("./component-creation").LeafProps<Pixi.AnimatedSprite>) => Pixi.AnimatedSprite & import("solid-js").JSX.Element;
|
|
32
6
|
/**
|
|
33
7
|
* A SolidJS component that renders a `PIXI.BitmapText`.
|
|
34
8
|
*/
|
|
35
|
-
export declare const BitmapText: (props: Omit<Pixi.TextOptions<Pixi.TextStyle, Pixi.TextStyleOptions>, "children"> & LeafProps<Pixi.BitmapText>) => Pixi.BitmapText & JSX.Element;
|
|
9
|
+
export declare const BitmapText: (props: Omit<Pixi.TextOptions<Pixi.TextStyle, Pixi.TextStyleOptions>, "children"> & import("./component-creation").LeafProps<Pixi.BitmapText>) => Pixi.BitmapText & import("solid-js").JSX.Element;
|
|
36
10
|
/**
|
|
37
11
|
* A SolidJS component that renders a `PIXI.Container`.
|
|
38
12
|
*/
|
|
39
|
-
export declare const Container: (props: Omit<Pixi.ContainerOptions<Pixi.ContainerChild>, "children"> & PixiEventHandlerMap & {
|
|
40
|
-
ref?: Ref<Pixi.Container<Pixi.ContainerChild>> | undefined;
|
|
13
|
+
export declare const Container: (props: Omit<Pixi.ContainerOptions<Pixi.ContainerChild>, "children"> & import("./pixi-events").PixiEventHandlerMap & {
|
|
14
|
+
ref?: import("solid-js").Ref<Pixi.Container<Pixi.ContainerChild>> | undefined;
|
|
41
15
|
as?: Pixi.Container<Pixi.ContainerChild> | undefined;
|
|
42
|
-
children?: JSX.Element;
|
|
43
|
-
}) => Pixi.Container<Pixi.ContainerChild> & JSX.Element;
|
|
16
|
+
children?: import("solid-js").JSX.Element;
|
|
17
|
+
}) => Pixi.Container<Pixi.ContainerChild> & import("solid-js").JSX.Element;
|
|
44
18
|
/**
|
|
45
19
|
* A SolidJS component that renders a `PIXI.Graphics`.
|
|
46
20
|
* Use a ref to access the underlying graphics instance and draw with it.
|
|
47
21
|
*/
|
|
48
|
-
export declare const Graphics: (props: Omit<Pixi.GraphicsOptions, "children"> & LeafProps<Pixi.Graphics>) => Pixi.Graphics & JSX.Element;
|
|
22
|
+
export declare const Graphics: (props: Omit<Pixi.GraphicsOptions, "children"> & import("./component-creation").LeafProps<Pixi.Graphics>) => Pixi.Graphics & import("solid-js").JSX.Element;
|
|
49
23
|
/**
|
|
50
24
|
* A SolidJS component that renders a `PIXI.HTMLText`.
|
|
51
25
|
*/
|
|
52
|
-
export declare const HTMLText: (props: Omit<Pixi.HTMLTextOptions, "children"> & LeafProps<Pixi.HTMLText>) => Pixi.HTMLText & JSX.Element;
|
|
26
|
+
export declare const HTMLText: (props: Omit<Pixi.HTMLTextOptions, "children"> & import("./component-creation").LeafProps<Pixi.HTMLText>) => Pixi.HTMLText & import("solid-js").JSX.Element;
|
|
53
27
|
/**
|
|
54
28
|
* A SolidJS component that renders a `PIXI.MeshPlane`.
|
|
55
29
|
*/
|
|
56
|
-
export declare const MeshPlane: (props: Omit<Pixi.MeshPlaneOptions, "children"> & LeafProps<Pixi.MeshPlane>) => Pixi.MeshPlane & JSX.Element;
|
|
30
|
+
export declare const MeshPlane: (props: Omit<Pixi.MeshPlaneOptions, "children"> & import("./component-creation").LeafProps<Pixi.MeshPlane>) => Pixi.MeshPlane & import("solid-js").JSX.Element;
|
|
57
31
|
/**
|
|
58
32
|
* A SolidJS component that renders a `PIXI.MeshRope`.
|
|
59
33
|
*/
|
|
60
|
-
export declare const MeshRope: (props: Omit<Pixi.MeshRopeOptions, "children"> & LeafProps<Pixi.MeshRope>) => Pixi.MeshRope & JSX.Element;
|
|
34
|
+
export declare const MeshRope: (props: Omit<Pixi.MeshRopeOptions, "children"> & import("./component-creation").LeafProps<Pixi.MeshRope>) => Pixi.MeshRope & import("solid-js").JSX.Element;
|
|
61
35
|
/**
|
|
62
36
|
* A SolidJS component that renders a `PIXI.NineSliceSprite`.
|
|
63
37
|
*/
|
|
64
|
-
export declare const NineSliceSprite: (props: Omit<Pixi.NineSliceSpriteOptions, "children"> & LeafProps<Pixi.NineSliceSprite>) => Pixi.NineSliceSprite & JSX.Element;
|
|
38
|
+
export declare const NineSliceSprite: (props: Omit<Pixi.NineSliceSpriteOptions, "children"> & import("./component-creation").LeafProps<Pixi.NineSliceSprite>) => Pixi.NineSliceSprite & import("solid-js").JSX.Element;
|
|
65
39
|
/**
|
|
66
40
|
* A SolidJS component that renders a `PIXI.ParticleContainer`.
|
|
67
41
|
*
|
|
68
42
|
* Particles should be added and removed from this component imperatively. Please see the docs for a reference example.
|
|
69
43
|
*/
|
|
70
|
-
export declare const ParticleContainer: (props: Omit<Pixi.ParticleContainerOptions, "children"> & LeafProps<Pixi.ParticleContainer>) => Pixi.ParticleContainer & JSX.Element;
|
|
44
|
+
export declare const ParticleContainer: (props: Omit<Pixi.ParticleContainerOptions, "children"> & import("./component-creation").LeafProps<Pixi.ParticleContainer>) => Pixi.ParticleContainer & import("solid-js").JSX.Element;
|
|
71
45
|
/**
|
|
72
46
|
* A SolidJS component that renders a `PIXI.PerspectiveMesh`.
|
|
73
47
|
*/
|
|
74
|
-
export declare const PerspectiveMesh: (props: Omit<Pixi.PerspectivePlaneOptions, "children"> & LeafProps<Pixi.PerspectiveMesh>) => Pixi.PerspectiveMesh & JSX.Element;
|
|
48
|
+
export declare const PerspectiveMesh: (props: Omit<Pixi.PerspectivePlaneOptions, "children"> & import("./component-creation").LeafProps<Pixi.PerspectiveMesh>) => Pixi.PerspectiveMesh & import("solid-js").JSX.Element;
|
|
75
49
|
/**
|
|
76
50
|
* A SolidJS component that renders a `PIXI.RenderContainer`.
|
|
77
51
|
*/
|
|
78
|
-
export declare const RenderContainer: (props: Omit<Pixi.RenderContainerOptions, "children"> & PixiEventHandlerMap & {
|
|
79
|
-
ref?: Ref<Pixi.RenderContainer> | undefined;
|
|
52
|
+
export declare const RenderContainer: (props: Omit<Pixi.RenderContainerOptions, "children"> & import("./pixi-events").PixiEventHandlerMap & {
|
|
53
|
+
ref?: import("solid-js").Ref<Pixi.RenderContainer> | undefined;
|
|
80
54
|
as?: Pixi.RenderContainer | undefined;
|
|
81
|
-
children?: JSX.Element;
|
|
82
|
-
}) => Pixi.RenderContainer & JSX.Element;
|
|
55
|
+
children?: import("solid-js").JSX.Element;
|
|
56
|
+
}) => Pixi.RenderContainer & import("solid-js").JSX.Element;
|
|
83
57
|
/**
|
|
84
58
|
* A SolidJS component that renders a `PIXI.RenderLayer`.
|
|
85
59
|
*/
|
|
86
|
-
export declare const RenderLayer: (props: Omit<Pixi.RenderLayerOptions, "children"> & PixiEventHandlerMap & {
|
|
87
|
-
ref?: Ref<Pixi.RenderLayer> | undefined;
|
|
60
|
+
export declare const RenderLayer: (props: Omit<Pixi.RenderLayerOptions, "children"> & import("./pixi-events").PixiEventHandlerMap & {
|
|
61
|
+
ref?: import("solid-js").Ref<Pixi.RenderLayer> | undefined;
|
|
88
62
|
as?: Pixi.RenderLayer | undefined;
|
|
89
|
-
children?: JSX.Element;
|
|
90
|
-
}) => Pixi.RenderLayer & JSX.Element;
|
|
63
|
+
children?: import("solid-js").JSX.Element;
|
|
64
|
+
}) => Pixi.RenderLayer & import("solid-js").JSX.Element;
|
|
91
65
|
/**
|
|
92
66
|
* A SolidJS component that renders a `PIXI.Sprite`.
|
|
93
67
|
*/
|
|
94
|
-
export declare const Sprite: (props: Omit<Pixi.SpriteOptions, "children"> & LeafProps<Pixi.Sprite>) => Pixi.Sprite & JSX.Element;
|
|
68
|
+
export declare const Sprite: (props: Omit<Pixi.SpriteOptions, "children"> & import("./component-creation").LeafProps<Pixi.Sprite>) => Pixi.Sprite & import("solid-js").JSX.Element;
|
|
95
69
|
/**
|
|
96
70
|
* A SolidJS component that renders a `PIXI.Text`.
|
|
97
71
|
*/
|
|
98
|
-
export declare const Text: (props: Omit<Pixi.CanvasTextOptions, "children"> & LeafProps<Pixi.Text>) => Pixi.Text & JSX.Element;
|
|
72
|
+
export declare const Text: (props: Omit<Pixi.CanvasTextOptions, "children"> & import("./component-creation").LeafProps<Pixi.Text>) => Pixi.Text & import("solid-js").JSX.Element;
|
|
99
73
|
/**
|
|
100
74
|
* A SolidJS component that renders a `PIXI.TilingSprite`.
|
|
101
75
|
*/
|
|
102
|
-
export declare const TilingSprite: (props: Omit<Pixi.TilingSpriteOptions, "children"> & LeafProps<Pixi.TilingSprite>) => Pixi.TilingSprite & JSX.Element;
|
|
76
|
+
export declare const TilingSprite: (props: Omit<Pixi.TilingSpriteOptions, "children"> & import("./component-creation").LeafProps<Pixi.TilingSprite>) => Pixi.TilingSprite & import("solid-js").JSX.Element;
|
package/dist/types/renderer.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const effect: <T>(fn: (prev?: T) => T, init?: T) => void, memo: <T>(fn: () => T, equal: boolean) => () => T, createComponent: <T>(Comp: (props: T) =>
|
|
1
|
+
import type * as Pixi from "pixi.js";
|
|
2
|
+
export declare const effect: <T>(fn: (prev?: T) => T, init?: T) => void, memo: <T>(fn: () => T, equal: boolean) => () => T, createComponent: <T>(Comp: (props: T) => Pixi.Container<Pixi.ContainerChild>, props: T) => Pixi.Container<Pixi.ContainerChild>, createElement: (tag: string) => Pixi.Container<Pixi.ContainerChild>, createTextNode: (value: string) => Pixi.Container<Pixi.ContainerChild>, insertNode: (parent: Pixi.Container<Pixi.ContainerChild>, node: Pixi.Container<Pixi.ContainerChild>, anchor?: Pixi.Container<Pixi.ContainerChild> | undefined) => void, insert: <T>(parent: any, accessor: T | (() => T), marker?: any | null, initial?: any) => Pixi.Container<Pixi.ContainerChild>, setProp: <T>(node: Pixi.Container<Pixi.ContainerChild>, name: string, value: T, prev?: T | undefined) => T, mergeProps: (...sources: unknown[]) => unknown, use: <A, T>(fn: (element: Pixi.Container<Pixi.ContainerChild>, arg: A) => T, element: Pixi.Container<Pixi.ContainerChild>, arg: A) => T, render: (code: () => Pixi.Container<Pixi.ContainerChild>, node: Pixi.Container<Pixi.ContainerChild>) => () => void, spread: <T>(node: any, accessor: (() => T) | T, skipChildren?: boolean) => void;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixi-solid",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.21",
|
|
5
5
|
"description": "A library to write PixiJS applications with SolidJS",
|
|
6
6
|
"author": "Luke Thompson",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"homepage": "https://lukecarlthompson.github.io/pixi-solid/",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "https://github.com/LukeCarlThompson/pixi-solid"
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"build": "vite build && tsc --project tsconfig.build.json --emitDeclarationOnly",
|
|
37
38
|
"build:docs": "typedoc --options typedoc.config.js",
|
|
38
39
|
"preview": "vite preview",
|
|
39
|
-
"preinstall": "npx only-allow pnpm"
|
|
40
|
+
"preinstall": "npx only-allow pnpm",
|
|
41
|
+
"test": "echo \"A dummy test\""
|
|
40
42
|
}
|
|
41
43
|
}
|