pixi-solid 0.0.30 → 0.0.31

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.
@@ -1,5 +1,6 @@
1
1
  import { splitProps, createRenderEffect, on } from "solid-js";
2
- import { PIXI_SOLID_EVENT_HANDLER_NAMES } from "./pixi-events.js";
2
+ import { PIXI_SOLID_EVENT_HANDLER_NAMES } from "./event-names.js";
3
+ import { POINT_PROP_AXIS_NAMES } from "./point-property-names.js";
3
4
  import { insert, setProp } from "./renderer.js";
4
5
  const SOLID_PROP_KEYS = ["ref", "as", "children"];
5
6
  const applyProps = (instance, props, defer) => {
@@ -37,7 +38,8 @@ const createContainerComponent = (PixiClass) => {
37
38
  return (props) => {
38
39
  const [runtimeProps, initialisationProps] = splitProps(props, [
39
40
  ...SOLID_PROP_KEYS,
40
- ...PIXI_SOLID_EVENT_HANDLER_NAMES
41
+ ...PIXI_SOLID_EVENT_HANDLER_NAMES,
42
+ ...POINT_PROP_AXIS_NAMES
41
43
  ]);
42
44
  const instance = props.as || new PixiClass(initialisationProps);
43
45
  applyProps(instance, initialisationProps, true);
@@ -1 +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;"}
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 \"./event-names\";\nimport { PIXI_SOLID_EVENT_HANDLER_NAMES } from \"./event-names\";\nimport type { PointAxisPropName } from \"./point-property-names\";\nimport { POINT_PROP_AXIS_NAMES } from \"./point-property-names\";\nimport { insert, setProp } from \"./renderer\";\n\n/**\n * Prop definition for components that CAN have children\n */\nexport type ContainerProps<Component> = PixiEventHandlerMap &\n PointAxisProps & {\n ref?: Ref<Component>;\n as?: Component;\n children?: JSX.Element;\n };\n\nexport type PointAxisProps = Partial<Record<PointAxisPropName, number>>;\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 ...POINT_PROP_AXIS_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":";;;;AAmCO,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,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;"}
@@ -72,4 +72,4 @@ export {
72
72
  PIXI_EVENT_NAMES,
73
73
  PIXI_SOLID_EVENT_HANDLER_NAMES
74
74
  };
75
- //# sourceMappingURL=pixi-events.js.map
75
+ //# sourceMappingURL=event-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-names.js","sources":["../src/event-names.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport type { FederatedEventEmitterTypes } from \"pixi.js\";\n\nexport const PIXI_EVENT_NAMES: (keyof FederatedEventEmitterTypes)[] = [\n \"click\",\n \"mousedown\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseout\",\n \"mouseover\",\n \"mouseup\",\n \"mouseupoutside\",\n \"pointercancel\",\n \"pointerdown\",\n \"pointerenter\",\n \"pointerleave\",\n \"pointermove\",\n \"pointerout\",\n \"pointerover\",\n \"pointertap\",\n \"pointerup\",\n \"pointerupoutside\",\n \"rightclick\",\n \"rightdown\",\n \"rightup\",\n \"rightupoutside\",\n \"tap\",\n \"touchcancel\",\n \"touchend\",\n \"touchendoutside\",\n \"touchmove\",\n \"touchstart\",\n \"wheel\",\n \"globalmousemove\",\n \"globalpointermove\",\n \"globaltouchmove\",\n \"clickcapture\",\n \"mousedowncapture\",\n \"mouseentercapture\",\n \"mouseleavecapture\",\n \"mousemovecapture\",\n \"mouseoutcapture\",\n \"mouseovercapture\",\n \"mouseupcapture\",\n \"mouseupoutsidecapture\",\n \"pointercancelcapture\",\n \"pointerdowncapture\",\n \"pointerentercapture\",\n \"pointerleavecapture\",\n \"pointermovecapture\",\n \"pointeroutcapture\",\n \"pointerovercapture\",\n \"pointertapcapture\",\n \"pointerupcapture\",\n \"pointerupoutsidecapture\",\n \"rightclickcapture\",\n \"rightdowncapture\",\n \"rightupcapture\",\n \"rightupoutsidecapture\",\n \"tapcapture\",\n \"touchcancelcapture\",\n \"touchendcapture\",\n \"touchendoutsidecapture\",\n \"touchmovecapture\",\n \"touchstartcapture\",\n \"wheelcapture\",\n] as const;\n\nexport const PIXI_SOLID_EVENT_HANDLER_NAMES = PIXI_EVENT_NAMES.map(\n (eventName) => `on${eventName}` as const,\n);\n\nexport type PixiEventHandlerMap = {\n [K in (typeof PIXI_EVENT_NAMES)[number] as `on${K}`]?:\n | null\n | ((...args: FederatedEventEmitterTypes[K]) => void);\n};\n\nexport const PIXI_EVENT_HANDLER_NAME_SET: Set<string> = new Set(PIXI_SOLID_EVENT_HANDLER_NAMES);\n\n/**\n * This is a type-safe check that ensures `PIXI_EVENT_NAMES` includes every key from Pixi's `AllFederatedEventMap` type.\n * It will cause a build error if any event names are missing.\n */\ntype MissingKeys = Exclude<keyof FederatedEventEmitterTypes, (typeof PIXI_EVENT_NAMES)[number]>;\ntype AllEventsAreHandled = MissingKeys extends never\n ? true\n : `Error: Missing event keys: ${MissingKeys}`;\nconst allEventsAreHandled: AllEventsAreHandled = true;\nvoid allEventsAreHandled;\n"],"names":[],"mappings":"AAGO,MAAM,mBAAyD;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,iCAAiC,iBAAiB;AAAA,EAC7D,CAAC,cAAc,KAAK,SAAS;AAC/B;AAQO,MAAM,8BAA2C,IAAI,IAAI,8BAA8B;"}
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { PIXI_EVENT_NAMES, PIXI_SOLID_EVENT_HANDLER_NAMES } from "./event-names.js";
1
2
  import { onResize } from "./on-resize.js";
2
3
  import { PixiApplication, TickerProvider, createAsyncDelay, delay, getPixiApp, getTicker, onTick, usePixiScreen } from "./pixi-application.js";
3
4
  import { PixiCanvas } from "./pixi-canvas.js";
4
5
  import { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, NineSliceSprite, ParticleContainer, PerspectiveMesh, RenderContainer, RenderLayer, Sprite, Text, TilingSprite } from "./pixi-components.js";
5
- import { PIXI_EVENT_NAMES, PIXI_SOLID_EVENT_HANDLER_NAMES } from "./pixi-events.js";
6
6
  import { PixiStage } from "./pixi-stage.js";
7
7
  export {
8
8
  AnimatedSprite,
@@ -1,6 +1,6 @@
1
1
  import { createComponent } from "solid-js/web";
2
2
  import { Application } from "pixi.js";
3
- import { createContext, useContext, splitProps, createResource, createEffect, onCleanup, Show, batch } from "solid-js";
3
+ import { useContext, createContext, onCleanup, splitProps, createResource, createEffect, on, Show, batch } from "solid-js";
4
4
  import { createMutable } from "solid-js/store";
5
5
  const PixiAppContext = createContext();
6
6
  const TickerContext = createContext();
@@ -26,12 +26,7 @@ const PixiApplication = (props) => {
26
26
  });
27
27
  const [appResource] = createResource(async () => {
28
28
  const app = new Application();
29
- await app.init({
30
- autoDensity: true,
31
- resolution: Math.min(window.devicePixelRatio, 2),
32
- sharedTicker: true,
33
- ...initialisationProps
34
- });
29
+ await app.init(initialisationProps);
35
30
  return app;
36
31
  });
37
32
  const updatePixiScreenStore = (screen) => {
@@ -46,7 +41,7 @@ const PixiApplication = (props) => {
46
41
  pixiScreenDimensions.y = screen.y;
47
42
  });
48
43
  };
49
- createEffect(() => {
44
+ createEffect(on(appResource, () => {
50
45
  const app = appResource();
51
46
  if (app) {
52
47
  if (props.ref) {
@@ -66,7 +61,7 @@ const PixiApplication = (props) => {
66
61
  });
67
62
  });
68
63
  }
69
- });
64
+ }));
70
65
  return createComponent(Show, {
71
66
  get when() {
72
67
  return appResource();
@@ -1 +1 @@
1
- {"version":3,"file":"pixi-application.js","sources":["../src/pixi-application.tsx"],"sourcesContent":["import type { ApplicationOptions, Rectangle, Ticker, TickerCallback } from \"pixi.js\";\nimport { Application } from \"pixi.js\";\nimport type { JSX, ParentProps, Ref } from \"solid-js\";\nimport { batch, createContext, createEffect, createResource, onCleanup, Show, splitProps, useContext } from \"solid-js\";\nimport { createMutable } from \"solid-js/store\";\n\nexport type PixiScreenDimensions = {\n width: number;\n height: number;\n left: number;\n right: number;\n bottom: number;\n top: number;\n x: number;\n y: number;\n};\n\nconst PixiAppContext = createContext<Application>();\nconst TickerContext = createContext<Ticker>();\nconst PixiScreenContext = createContext<Readonly<PixiScreenDimensions>>();\n\n/**\n * A custom SolidJS hook to access the root PIXI.Application instance.\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n *\n * @returns The PIXI.Application instance provided by the `PixiApplication` component.\n * @throws Will throw an error if used outside of a `PixiApplication` context provider.\n */\nexport const getPixiApp = () => {\n const app = useContext(PixiAppContext);\n if (!app) {\n throw new Error(\"getPixiApp must be used within a PixiApplication\");\n }\n return app;\n};\n\n/**\n * Props for the `PixiApplication` component. It extends the PIXI.ApplicationOptions\n * to allow passing configuration directly to the Pixi.js Application constructor,\n * but omits properties that are handled by the component itself.\n */\nexport type PixiApplicationProps = Partial<Omit<ApplicationOptions, \"children\" | \"resizeTo\">> & {\n ref?: Ref<Application>;\n children?: JSX.Element;\n};\n\n/**\n * A SolidJS component that creates and manages a PIXI.Application instance.\n * It provides the application instance through context to be used by child components\n * and custom hooks like `getPixiApp`, `onTick`, and `getTicker`.\n *\n * This component should only be used once in your application.\n *\n * @param props The properties to configure the Pixi.js Application.\n *\n */\nexport const PixiApplication = (props: PixiApplicationProps) => {\n const [, initialisationProps] = splitProps(props, [\"ref\", \"children\"]);\n const pixiScreenDimensions = createMutable<PixiScreenDimensions>({\n width: 800,\n height: 600,\n left: 0,\n right: 800,\n top: 0,\n bottom: 600,\n x: 0,\n y: 0,\n });\n\n // TODO: Split props into initialisation props and runtime props\n\n const [appResource] = createResource(async () => {\n const app = new Application();\n await app.init({\n autoDensity: true,\n resolution: Math.min(window.devicePixelRatio, 2),\n sharedTicker: true,\n ...initialisationProps,\n });\n\n return app;\n });\n\n const updatePixiScreenStore = (screen: Rectangle) => {\n batch(() => {\n pixiScreenDimensions.width = screen.width;\n pixiScreenDimensions.height = screen.height;\n pixiScreenDimensions.left = screen.x;\n pixiScreenDimensions.top = screen.y;\n pixiScreenDimensions.right = screen.x + screen.width;\n pixiScreenDimensions.bottom = screen.y + screen.height;\n pixiScreenDimensions.x = screen.x;\n pixiScreenDimensions.y = screen.y;\n });\n };\n\n createEffect(() => {\n const app = appResource();\n if (app) {\n if (props.ref) {\n // Solid converts the ref prop to a callback function\n (props.ref as unknown as (arg: any) => void)(app);\n }\n\n // TODO: Go through the other props that can be set at runtime and apply them here\n // e.g. backgroundColor => app.renderer.backgroundColor, etc.\n\n app.ticker.autoStart = false;\n app.ticker.start();\n\n updatePixiScreenStore(app.renderer.screen);\n\n const handleResize = () => {\n updatePixiScreenStore(app.renderer.screen);\n };\n\n app.renderer.addListener(\"resize\", handleResize);\n\n onCleanup(() => {\n app.renderer.removeListener(\"resize\", handleResize);\n app.destroy(true, { children: true });\n });\n }\n });\n\n return (\n <Show when={appResource()}>\n {(app) => (\n <PixiAppContext.Provider value={app()}>\n <TickerContext.Provider value={app().ticker}>\n <PixiScreenContext.Provider value={pixiScreenDimensions}>{props.children}</PixiScreenContext.Provider>\n </TickerContext.Provider>\n </PixiAppContext.Provider>\n )}\n </Show>\n );\n};\n\nexport type TickerProviderProps = ParentProps<{ ticker: Ticker }>;\n\n/**\n * This is only required if you want a ticker without the Application.\n * It provides context for the `onTick` and `getTicker` hooks so we can run tests that use them without having to instantate a Pixi Application.\n *\n * You need to pass in the ticker instance you want to use so it can be manually controled form the outside for testing.\n */\nexport const TickerProvider = (props: TickerProviderProps) => {\n return <TickerContext.Provider value={props.ticker}>{props.children}</TickerContext.Provider>;\n};\n\n/**\n * getTicker\n *\n * A custom SolidJS hook that provides access to the PIXI.Application's shared Ticker instance.\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n * Or a descendant of `TickerProvider` if being used for testing without an application.\n *\n * @returns The PIXI.Ticker instance from the application context.\n * @throws Will throw an error if used outside of a `PixiApplication` or `TickerProvider` context.\n */\nexport const getTicker = (): Ticker => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\"getTicker must be used within a PixiApplication or a TickerProvider\");\n }\n return ticker;\n};\n\n/**\n * onTick\n *\n * A custom SolidJS hook that registers a callback function to be executed on every frame\n * of the PIXI.Application's ticker. The callback is automatically removed when the\n * component or hook's owning computation is cleaned up.\n *\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n * Or a descendant of `TickerProvider` if being used for testing without an application.\n *\n * @param tickerCallback - The function to call on each ticker update. It receives\n * the `PIXI.Ticker` instance as its argument.\n *\n */\nexport const onTick = (tickerCallback: TickerCallback<Ticker>): void => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\"onTick must be used within a PixiApplication or a TickerProvider\");\n }\n\n ticker.add(tickerCallback);\n onCleanup(() => {\n ticker.remove(tickerCallback);\n });\n};\n\nconst asyncDelay = async (ticker: Ticker, delayMs: number) => {\n let timeDelayed = 0;\n\n let resolvePromise: (value: void | PromiseLike<void>) => void;\n\n const promise = new Promise<void>((resolve) => {\n resolvePromise = resolve;\n });\n\n const internalCallback = () => {\n timeDelayed += ticker.deltaMS;\n if (timeDelayed < delayMs) return;\n resolvePromise();\n };\n\n ticker.add(internalCallback);\n\n await promise;\n\n ticker.remove(internalCallback);\n};\n\n/**\n * Create a delay function that waits until a given number of milliseconds has passed on the current Ticker context before resolving.\n *\n * This function must be called inside a `PixiApplication` or `TickerProvider` context.\n *\n * @returns An async function we can await to delay events in sync with time passed on the Ticker.\n *\n * Simply await for it to resolve in an async context.\n *\n * @note It will not resolve if the ticker is paused or stopped.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n */\nexport const createAsyncDelay = (): ((delayMs: number) => Promise<void>) => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\n \"`createDelay` must be used within a PixiApplication or a TickerProvider. The returned `delay` function can be called in an async context but `createDelay` must be called in a synchronous scope within a PixiApplication or a TickerProvider\"\n );\n }\n const delayWithTicker = (delayMs: number) => asyncDelay(ticker, delayMs);\n\n return delayWithTicker;\n};\n\n/**\n * Runs a callback when a given number of milliseconds has passed on the ticker.\n *\n * It is guaranteed to be in sync with the shared ticker and uses accumulated deltaMs not an external time measurement.\n *\n * @param delayMs - Number of milliseconds to wait (measured in the ticker's time units).\n *\n * @param callback - A callback function that will fire when the delayMs time has passed.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n *\n * @note It will not run the callback if the ticker is paused or stopped.\n *\n */\nexport const delay = (delayMs: number, callback?: () => void): void => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\n \"`createDelay` must be used within a PixiApplication or a TickerProvider. The returned `delay` function can be called in an async context but `createDelay` must be called in a synchronous scope within a PixiApplication or a TickerProvider\"\n );\n }\n\n let timeDelayed = 0;\n\n const internalCallback = () => {\n timeDelayed += ticker.deltaMS;\n if (timeDelayed < delayMs) return;\n callback?.();\n ticker.remove(internalCallback);\n };\n\n ticker.add(internalCallback);\n};\n\n/**\n * A hook that provides the current dimensions of the Pixi application's screen as a reactive object.\n * The properties of the returned object will update automatically when the screen size changes and can be subscribed to reactively.\n *\n * @returns An object containing the width and height of the Pixi screen.\n * @throws Will throw an error if not used within a `<PixiApplication>` component.\n */\nexport const usePixiScreen = (): Readonly<PixiScreenDimensions> => {\n const pixiScreen = useContext(PixiScreenContext);\n if (!pixiScreen) {\n throw new Error(\"usePixiScreen must be used within a PixiApplication\");\n }\n return pixiScreen;\n};\n"],"names":["PixiAppContext","createContext","TickerContext","PixiScreenContext","getPixiApp","app","useContext","Error","PixiApplication","props","initialisationProps","splitProps","pixiScreenDimensions","createMutable","width","height","left","right","top","bottom","x","y","appResource","createResource","Application","init","autoDensity","resolution","Math","min","window","devicePixelRatio","sharedTicker","updatePixiScreenStore","screen","batch","createEffect","ref","ticker","autoStart","start","renderer","handleResize","addListener","onCleanup","removeListener","destroy","children","_$createComponent","Show","when","Provider","value","TickerProvider","getTicker","onTick","tickerCallback","add","remove","asyncDelay","delayMs","timeDelayed","resolvePromise","promise","Promise","resolve","internalCallback","deltaMS","createAsyncDelay","delayWithTicker","delay","callback","usePixiScreen","pixiScreen"],"mappings":";;;;AAiBA,MAAMA,iBAAiBC,cAAAA;AACvB,MAAMC,gBAAgBD,cAAAA;AACtB,MAAME,oBAAoBF,cAAAA;AASnB,MAAMG,aAAaA,MAAM;AAC9B,QAAMC,MAAMC,WAAWN,cAAc;AACrC,MAAI,CAACK,KAAK;AACR,UAAM,IAAIE,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAOF;AACT;AAsBO,MAAMG,kBAAkBA,CAACC,UAAgC;AAC9D,QAAM,CAAA,EAAGC,mBAAmB,IAAIC,WAAWF,OAAO,CAAC,OAAO,UAAU,CAAC;AACrE,QAAMG,uBAAuBC,cAAoC;AAAA,IAC/DC,OAAO;AAAA,IACPC,QAAQ;AAAA,IACRC,MAAM;AAAA,IACNC,OAAO;AAAA,IACPC,KAAK;AAAA,IACLC,QAAQ;AAAA,IACRC,GAAG;AAAA,IACHC,GAAG;AAAA,EAAA,CACJ;AAID,QAAM,CAACC,WAAW,IAAIC,eAAe,YAAY;AAC/C,UAAMlB,MAAM,IAAImB,YAAAA;AAChB,UAAMnB,IAAIoB,KAAK;AAAA,MACbC,aAAa;AAAA,MACbC,YAAYC,KAAKC,IAAIC,OAAOC,kBAAkB,CAAC;AAAA,MAC/CC,cAAc;AAAA,MACd,GAAGtB;AAAAA,IAAAA,CACJ;AAED,WAAOL;AAAAA,EACT,CAAC;AAED,QAAM4B,wBAAwBA,CAACC,WAAsB;AACnDC,UAAM,MAAM;AACVvB,2BAAqBE,QAAQoB,OAAOpB;AACpCF,2BAAqBG,SAASmB,OAAOnB;AACrCH,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/B,MACR,+OACF;AAAA,EACF;AACA,QAAM8D,kBAAkBA,CAACT,YAAoBD,WAAWrB,QAAQsB,OAAO;AAEvE,SAAOS;AACT;AAgBO,MAAMC,QAAQA,CAACV,SAAiBW,aAAgC;AACrE,QAAMjC,SAAShC,WAAWJ,aAAa;AACvC,MAAI,CAACoC,QAAQ;AACX,UAAM,IAAI/B,MACR,+OACF;AAAA,EACF;AAEA,MAAIsD,cAAc;AAElB,QAAMK,mBAAmBA,MAAM;AAC7BL,mBAAevB,OAAO6B;AACtB,QAAIN,cAAcD,QAAS;AAC3BW,eAAAA;AACAjC,WAAOoB,OAAOQ,gBAAgB;AAAA,EAChC;AAEA5B,SAAOmB,IAAIS,gBAAgB;AAC7B;AASO,MAAMM,gBAAgBA,MAAsC;AACjE,QAAMC,aAAanE,WAAWH,iBAAiB;AAC/C,MAAI,CAACsE,YAAY;AACf,UAAM,IAAIlE,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAOkE;AACT;"}
1
+ {"version":3,"file":"pixi-application.js","sources":["../src/pixi-application.tsx"],"sourcesContent":["import type { ApplicationOptions, Rectangle, Ticker, TickerCallback } from \"pixi.js\";\nimport { Application } from \"pixi.js\";\nimport type { JSX, ParentProps, Ref } from \"solid-js\";\nimport {\n batch,\n createContext,\n createEffect,\n createResource,\n on,\n onCleanup,\n Show,\n splitProps,\n useContext,\n} from \"solid-js\";\nimport { createMutable } from \"solid-js/store\";\n\nexport type PixiScreenDimensions = {\n width: number;\n height: number;\n left: number;\n right: number;\n bottom: number;\n top: number;\n x: number;\n y: number;\n};\n\nconst PixiAppContext = createContext<Application>();\nconst TickerContext = createContext<Ticker>();\nconst PixiScreenContext = createContext<Readonly<PixiScreenDimensions>>();\n\n/**\n * A custom SolidJS hook to access the root PIXI.Application instance.\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n *\n * @returns The PIXI.Application instance provided by the `PixiApplication` component.\n * @throws Will throw an error if used outside of a `PixiApplication` context provider.\n */\nexport const getPixiApp = () => {\n const app = useContext(PixiAppContext);\n if (!app) {\n throw new Error(\"getPixiApp must be used within a PixiApplication\");\n }\n return app;\n};\n\n/**\n * Props for the `PixiApplication` component. It extends the PIXI.ApplicationOptions\n * to allow passing configuration directly to the Pixi.js Application constructor,\n * but omits properties that are handled by the component itself.\n */\nexport type PixiApplicationProps = Partial<Omit<ApplicationOptions, \"children\" | \"resizeTo\">> & {\n ref?: Ref<Application>;\n children?: JSX.Element;\n};\n\n/**\n * A SolidJS component that creates and manages a PIXI.Application instance.\n * It provides the application instance through context to be used by child components\n * and custom hooks like `getPixiApp`, `onTick`, and `getTicker`.\n *\n * This component should only be used once in your application.\n *\n * @param props The properties to configure the Pixi.js Application.\n *\n */\nexport const PixiApplication = (props: PixiApplicationProps) => {\n const [, initialisationProps] = splitProps(props, [\"ref\", \"children\"]);\n const pixiScreenDimensions = createMutable<PixiScreenDimensions>({\n width: 800,\n height: 600,\n left: 0,\n right: 800,\n top: 0,\n bottom: 600,\n x: 0,\n y: 0,\n });\n\n const [appResource] = createResource(async () => {\n const app = new Application();\n await app.init(initialisationProps);\n\n return app;\n });\n\n const updatePixiScreenStore = (screen: Rectangle) => {\n batch(() => {\n pixiScreenDimensions.width = screen.width;\n pixiScreenDimensions.height = screen.height;\n pixiScreenDimensions.left = screen.x;\n pixiScreenDimensions.top = screen.y;\n pixiScreenDimensions.right = screen.x + screen.width;\n pixiScreenDimensions.bottom = screen.y + screen.height;\n pixiScreenDimensions.x = screen.x;\n pixiScreenDimensions.y = screen.y;\n });\n };\n\n createEffect(\n on(appResource, () => {\n const app = appResource();\n if (app) {\n if (props.ref) {\n // Solid converts the ref prop to a callback function\n (props.ref as unknown as (arg: any) => void)(app);\n }\n\n app.ticker.autoStart = false;\n app.ticker.start();\n\n updatePixiScreenStore(app.renderer.screen);\n\n const handleResize = () => {\n updatePixiScreenStore(app.renderer.screen);\n };\n\n app.renderer.addListener(\"resize\", handleResize);\n\n onCleanup(() => {\n app.renderer.removeListener(\"resize\", handleResize);\n app.destroy(true, { children: true });\n });\n }\n })\n );\n\n return (\n <Show when={appResource()}>\n {(app) => (\n <PixiAppContext.Provider value={app()}>\n <TickerContext.Provider value={app().ticker}>\n <PixiScreenContext.Provider value={pixiScreenDimensions}>{props.children}</PixiScreenContext.Provider>\n </TickerContext.Provider>\n </PixiAppContext.Provider>\n )}\n </Show>\n );\n};\n\nexport type TickerProviderProps = ParentProps<{ ticker: Ticker }>;\n\n/**\n * This is only required if you want a ticker without the Application.\n * It provides context for the `onTick` and `getTicker` hooks so we can run tests that use them without having to instantate a Pixi Application.\n *\n * You need to pass in the ticker instance you want to use so it can be manually controled form the outside for testing.\n */\nexport const TickerProvider = (props: TickerProviderProps) => {\n return <TickerContext.Provider value={props.ticker}>{props.children}</TickerContext.Provider>;\n};\n\n/**\n * getTicker\n *\n * A custom SolidJS hook that provides access to the PIXI.Application's shared Ticker instance.\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n * Or a descendant of `TickerProvider` if being used for testing without an application.\n *\n * @returns The PIXI.Ticker instance from the application context.\n * @throws Will throw an error if used outside of a `PixiApplication` or `TickerProvider` context.\n */\nexport const getTicker = (): Ticker => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\"getTicker must be used within a PixiApplication or a TickerProvider\");\n }\n return ticker;\n};\n\n/**\n * onTick\n *\n * A custom SolidJS hook that registers a callback function to be executed on every frame\n * of the PIXI.Application's ticker. The callback is automatically removed when the\n * component or hook's owning computation is cleaned up.\n *\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n * Or a descendant of `TickerProvider` if being used for testing without an application.\n *\n * @param tickerCallback - The function to call on each ticker update. It receives\n * the `PIXI.Ticker` instance as its argument.\n *\n */\nexport const onTick = (tickerCallback: TickerCallback<Ticker>): void => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\"onTick must be used within a PixiApplication or a TickerProvider\");\n }\n\n ticker.add(tickerCallback);\n onCleanup(() => {\n ticker.remove(tickerCallback);\n });\n};\n\nconst asyncDelay = async (ticker: Ticker, delayMs: number) => {\n // TODO: Make this abortable.\n let timeDelayed = 0;\n\n let resolvePromise: (value: void | PromiseLike<void>) => void;\n\n const promise = new Promise<void>((resolve) => {\n resolvePromise = resolve;\n });\n\n const internalCallback = () => {\n timeDelayed += ticker.deltaMS;\n if (timeDelayed < delayMs) return;\n resolvePromise();\n };\n\n ticker.add(internalCallback);\n\n await promise;\n\n ticker.remove(internalCallback);\n};\n\n/**\n * Create a delay function that waits until a given number of milliseconds has passed on the current Ticker context before resolving.\n *\n * This function must be called inside a `PixiApplication` or `TickerProvider` context.\n *\n * @returns An async function we can await to delay events in sync with time passed on the Ticker.\n *\n * Simply await for it to resolve in an async context.\n *\n * @note It will not resolve if the ticker is paused or stopped.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n */\nexport const createAsyncDelay = (): ((delayMs: number) => Promise<void>) => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\n \"`createDelay` must be used within a PixiApplication or a TickerProvider. The returned `delay` function can be called in an async context but `createDelay` must be called in a synchronous scope within a PixiApplication or a TickerProvider\"\n );\n }\n const delayWithTicker = (delayMs: number) => asyncDelay(ticker, delayMs);\n\n return delayWithTicker;\n};\n\n/**\n * Runs a callback when a given number of milliseconds has passed on the ticker.\n *\n * It is guaranteed to be in sync with the shared ticker and uses accumulated deltaMs not an external time measurement.\n *\n * @param delayMs - Number of milliseconds to wait (measured in the ticker's time units).\n *\n * @param callback - A callback function that will fire when the delayMs time has passed.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n *\n * @note It will not run the callback if the ticker is paused or stopped.\n *\n */\nexport const delay = (delayMs: number, callback?: () => void): void => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\n \"`createDelay` must be used within a PixiApplication or a TickerProvider. The returned `delay` function can be called in an async context but `createDelay` must be called in a synchronous scope within a PixiApplication or a TickerProvider\"\n );\n }\n\n let timeDelayed = 0;\n\n const internalCallback = () => {\n timeDelayed += ticker.deltaMS;\n if (timeDelayed < delayMs) return;\n callback?.();\n ticker.remove(internalCallback);\n };\n\n ticker.add(internalCallback);\n};\n\n/**\n * A hook that provides the current dimensions of the Pixi application's screen as a reactive object.\n * The properties of the returned object will update automatically when the screen size changes and can be subscribed to reactively.\n *\n * @returns An object containing the width and height of the Pixi screen.\n * @throws Will throw an error if not used within a `<PixiApplication>` component.\n */\nexport const usePixiScreen = (): Readonly<PixiScreenDimensions> => {\n const pixiScreen = useContext(PixiScreenContext);\n if (!pixiScreen) {\n throw new Error(\"usePixiScreen must be used within a PixiApplication\");\n }\n return pixiScreen;\n};\n"],"names":["PixiAppContext","createContext","TickerContext","PixiScreenContext","getPixiApp","app","useContext","Error","PixiApplication","props","initialisationProps","splitProps","pixiScreenDimensions","createMutable","width","height","left","right","top","bottom","x","y","appResource","createResource","Application","init","updatePixiScreenStore","screen","batch","createEffect","on","ref","ticker","autoStart","start","renderer","handleResize","addListener","onCleanup","removeListener","destroy","children","_$createComponent","Show","when","Provider","value","TickerProvider","getTicker","onTick","tickerCallback","add","remove","asyncDelay","delayMs","timeDelayed","resolvePromise","promise","Promise","resolve","internalCallback","deltaMS","createAsyncDelay","delayWithTicker","delay","callback","usePixiScreen","pixiScreen"],"mappings":";;;;AA2BA,MAAMA,iBAAiBC,cAAAA;AACvB,MAAMC,gBAAgBD,cAAAA;AACtB,MAAME,oBAAoBF,cAAAA;AASnB,MAAMG,aAAaA,MAAM;AAC9B,QAAMC,MAAMC,WAAWN,cAAc;AACrC,MAAI,CAACK,KAAK;AACR,UAAM,IAAIE,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAOF;AACT;AAsBO,MAAMG,kBAAkBA,CAACC,UAAgC;AAC9D,QAAM,CAAA,EAAGC,mBAAmB,IAAIC,WAAWF,OAAO,CAAC,OAAO,UAAU,CAAC;AACrE,QAAMG,uBAAuBC,cAAoC;AAAA,IAC/DC,OAAO;AAAA,IACPC,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;AAE5D,MAAIC,cAAc;AAElB,MAAIC;AAEJ,QAAMC,UAAU,IAAIC,QAAeC,CAAAA,YAAY;AAC7CH,qBAAiBG;AAAAA,EACnB,CAAC;AAED,QAAMC,mBAAmBA,MAAM;AAC7BL,mBAAevB,OAAO6B;AACtB,QAAIN,cAAcD,QAAS;AAC3BE,mBAAAA;AAAAA,EACF;AAEAxB,SAAOmB,IAAIS,gBAAgB;AAE3B,QAAMH;AAENzB,SAAOoB,OAAOQ,gBAAgB;AAChC;AAeO,MAAME,mBAAmBA,MAA4C;AAC1E,QAAM9B,SAAS1B,WAAWJ,aAAa;AAEvC,MAAI,CAAC8B,QAAQ;AACX,UAAM,IAAIzB,MACR,+OACF;AAAA,EACF;AACA,QAAMwD,kBAAkBA,CAACT,YAAoBD,WAAWrB,QAAQsB,OAAO;AAEvE,SAAOS;AACT;AAgBO,MAAMC,QAAQA,CAACV,SAAiBW,aAAgC;AACrE,QAAMjC,SAAS1B,WAAWJ,aAAa;AACvC,MAAI,CAAC8B,QAAQ;AACX,UAAM,IAAIzB,MACR,+OACF;AAAA,EACF;AAEA,MAAIgD,cAAc;AAElB,QAAMK,mBAAmBA,MAAM;AAC7BL,mBAAevB,OAAO6B;AACtB,QAAIN,cAAcD,QAAS;AAC3BW,eAAAA;AACAjC,WAAOoB,OAAOQ,gBAAgB;AAAA,EAChC;AAEA5B,SAAOmB,IAAIS,gBAAgB;AAC7B;AASO,MAAMM,gBAAgBA,MAAsC;AACjE,QAAMC,aAAa7D,WAAWH,iBAAiB;AAC/C,MAAI,CAACgE,YAAY;AACf,UAAM,IAAI5D,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO4D;AACT;"}
@@ -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 { 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;"}
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 type { PixiEventHandlerMap } from \"./event-names\";\nimport { getPixiApp } from \"./pixi-application\";\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;"}
@@ -0,0 +1,38 @@
1
+ const POINT_PROP_NAMES = [
2
+ "position",
3
+ "scale",
4
+ "pivot",
5
+ "skew",
6
+ "anchor",
7
+ "tilePosition",
8
+ "tileScale"
9
+ ];
10
+ const POINT_PROP_NAMES_SET = new Set(POINT_PROP_NAMES);
11
+ const POINT_PROP_AXIS_NAMES = [
12
+ "positionX",
13
+ "positionY",
14
+ "scaleX",
15
+ "scaleY",
16
+ "pivotX",
17
+ "pivotY",
18
+ "skewX",
19
+ "skewY",
20
+ "anchorX",
21
+ "anchorY",
22
+ "tilePositionX",
23
+ "tilePositionY",
24
+ "tileScaleX",
25
+ "tileScaleY"
26
+ ];
27
+ const POINT_PROP_AXIS_NAMES_SET = new Set(POINT_PROP_AXIS_NAMES);
28
+ const ALL_VALID_PROP_NAMES_SET = /* @__PURE__ */ new Set([
29
+ ...POINT_PROP_NAMES_SET,
30
+ ...POINT_PROP_AXIS_NAMES_SET
31
+ ]);
32
+ export {
33
+ ALL_VALID_PROP_NAMES_SET,
34
+ POINT_PROP_AXIS_NAMES,
35
+ POINT_PROP_AXIS_NAMES_SET,
36
+ POINT_PROP_NAMES_SET
37
+ };
38
+ //# sourceMappingURL=point-property-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"point-property-names.js","sources":["../src/point-property-names.ts"],"sourcesContent":["const POINT_PROP_NAMES = [\n \"position\",\n \"scale\",\n \"pivot\",\n \"skew\",\n \"anchor\",\n \"tilePosition\",\n \"tileScale\",\n] as const;\n\nexport const POINT_PROP_NAMES_SET: Set<string> = new Set(POINT_PROP_NAMES);\n\nexport const POINT_PROP_AXIS_NAMES = [\n \"positionX\",\n \"positionY\",\n \"scaleX\",\n \"scaleY\",\n \"pivotX\",\n \"pivotY\",\n \"skewX\",\n \"skewY\",\n \"anchorX\",\n \"anchorY\",\n \"tilePositionX\",\n \"tilePositionY\",\n \"tileScaleX\",\n \"tileScaleY\",\n] as const;\n\nexport type PointAxisPropName = (typeof POINT_PROP_AXIS_NAMES)[number];\n\nexport const POINT_PROP_AXIS_NAMES_SET: Set<string> = new Set(POINT_PROP_AXIS_NAMES);\n\nexport const ALL_VALID_PROP_NAMES_SET: Set<string> = new Set([\n ...POINT_PROP_NAMES_SET,\n ...POINT_PROP_AXIS_NAMES_SET,\n]);\n"],"names":[],"mappings":"AAAA,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,uBAAoC,IAAI,IAAI,gBAAgB;AAElE,MAAM,wBAAwB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIO,MAAM,4BAAyC,IAAI,IAAI,qBAAqB;AAE5E,MAAM,+CAA4C,IAAI;AAAA,EAC3D,GAAG;AAAA,EACH,GAAG;AACL,CAAC;"}
package/dist/renderer.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Text } from "pixi.js";
2
2
  import { createRenderer } from "solid-js/universal";
3
- import { PIXI_EVENT_HANDLER_NAME_SET } from "./pixi-events.js";
3
+ import { isEventProperty, setEventProperty } from "./set-event-property.js";
4
+ import { isPointProperty, setPointProperty } from "./set-point-property.js";
4
5
  const {
5
6
  effect,
6
7
  memo,
@@ -27,17 +28,16 @@ const {
27
28
  textNode.text = value;
28
29
  },
29
30
  setProperty(node, name, value, prev) {
31
+ if (isPointProperty(name)) {
32
+ setPointProperty(node, name, value);
33
+ return;
34
+ }
30
35
  if (name in node) {
31
36
  node[name] = value;
32
37
  return;
33
38
  }
34
- if (PIXI_EVENT_HANDLER_NAME_SET.has(name)) {
35
- const eventName = name.slice(2);
36
- if (prev) {
37
- node.removeEventListener(eventName, prev);
38
- }
39
- node.addEventListener(eventName, value);
40
- return;
39
+ if (isEventProperty(name)) {
40
+ setEventProperty(node, name, value, prev);
41
41
  }
42
42
  },
43
43
  insertNode(parent2, node, anchor) {
@@ -1 +1 @@
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 if (name in node) {\n (node as any)[name] = value;\n return;\n }\n\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 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 // RenderLayer uses `detach` instead of `removeChild`.\n if (\"detach\" in parent && typeof parent.detach === \"function\") {\n parent.detach(node);\n return;\n }\n\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","_","detach","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,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AMQ,UAAUc;AAAAA,EACzB;AAAA,EACAC,cAAcvB,MAAM;AAClB,WAAOA,KAAKa,WAAW,CAAC;AAAA,EAC1B;AAAA,EACAW,eAAexB,MAAM;AACnB,QAAI,CAACA,KAAKQ,OAAQ,QAAOc;AACzB,UAAMG,QAAQzB,KAAKQ,OAAOK,SAASC,QAAQd,IAAI;AAE/C,WAAOyB,QAAQ,KAAKzB,KAAKQ,OAAOK,SAASY,QAAQ,CAAC,IAAIH;AAAAA,EACxD;AACF,CAAC;"}
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 { isEventProperty, setEventProperty } from \"./set-event-property\";\nimport { isPointProperty, setPointProperty } from \"./set-point-property\";\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 if (isPointProperty(name)) {\n setPointProperty(node, name, value);\n return;\n }\n\n if (name in node) {\n (node as any)[name] = value;\n return;\n }\n\n if (isEventProperty(name)) {\n setEventProperty(node, name, value, prev);\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 // RenderLayer uses `detach` instead of `removeChild`.\n if (\"detach\" in parent && typeof parent.detach === \"function\") {\n parent.detach(node);\n return;\n }\n\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","isPointProperty","setPointProperty","isEventProperty","setEventProperty","parent","anchor","attach","addChild","addChildAt","children","indexOf","isTextNode","removeNode","_","detach","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;AACnC,QAAIC,gBAAgBV,IAAI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KAAKM,OAAOK,SAASY,QAAQ,CAAC,IAAIH;AAAAA,EACxD;AACF,CAAC;"}
@@ -0,0 +1,14 @@
1
+ import { PIXI_EVENT_HANDLER_NAME_SET } from "./event-names.js";
2
+ const isEventProperty = (name) => PIXI_EVENT_HANDLER_NAME_SET.has(name);
3
+ const setEventProperty = (node, name, eventHandler, prevEventHandler) => {
4
+ const eventName = name.slice(2);
5
+ if (prevEventHandler) {
6
+ node.removeEventListener(eventName, prevEventHandler);
7
+ }
8
+ node.addEventListener(eventName, eventHandler);
9
+ };
10
+ export {
11
+ isEventProperty,
12
+ setEventProperty
13
+ };
14
+ //# sourceMappingURL=set-event-property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-event-property.js","sources":["../src/set-event-property.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport type { PIXI_EVENT_NAMES } from \"./event-names\";\nimport { PIXI_EVENT_HANDLER_NAME_SET } from \"./event-names\";\n\nexport const isEventProperty = (name: string): boolean => PIXI_EVENT_HANDLER_NAME_SET.has(name);\n\nexport const setEventProperty = (\n node: Pixi.Container,\n name: string,\n eventHandler: any,\n prevEventHandler?: any,\n): void => {\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 (prevEventHandler) {\n node.removeEventListener(eventName, prevEventHandler);\n }\n node.addEventListener(eventName, eventHandler);\n};\n"],"names":[],"mappings":";AAIO,MAAM,kBAAkB,CAAC,SAA0B,4BAA4B,IAAI,IAAI;AAEvF,MAAM,mBAAmB,CAC9B,MACA,MACA,cACA,qBACS;AAET,QAAM,YAAY,KAAK,MAAM,CAAC;AAE9B,MAAI,kBAAkB;AACpB,SAAK,oBAAoB,WAAW,gBAAgB;AAAA,EACtD;AACA,OAAK,iBAAiB,WAAW,YAAY;AAC/C;"}
@@ -0,0 +1,22 @@
1
+ import { ALL_VALID_PROP_NAMES_SET, POINT_PROP_NAMES_SET, POINT_PROP_AXIS_NAMES_SET } from "./point-property-names.js";
2
+ const isPointProperty = (propName) => ALL_VALID_PROP_NAMES_SET.has(propName);
3
+ const setPointProperty = (node, name, value) => {
4
+ if (typeof value === "object" && value !== null) {
5
+ node[name].set(value.x, value.y);
6
+ return;
7
+ }
8
+ if (typeof value === "number") {
9
+ if (POINT_PROP_NAMES_SET.has(name)) {
10
+ node[name].set(value);
11
+ } else if (POINT_PROP_AXIS_NAMES_SET.has(name)) {
12
+ const axisName = name[name.length - 1].toLowerCase();
13
+ const propertyName = name.slice(0, -1);
14
+ node[propertyName][axisName] = value;
15
+ }
16
+ }
17
+ };
18
+ export {
19
+ isPointProperty,
20
+ setPointProperty
21
+ };
22
+ //# sourceMappingURL=set-point-property.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-point-property.js","sources":["../src/set-point-property.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport {\n ALL_VALID_PROP_NAMES_SET,\n POINT_PROP_AXIS_NAMES_SET,\n POINT_PROP_NAMES_SET,\n} from \"./point-property-names\";\n\nexport const isPointProperty = (propName: string): boolean =>\n ALL_VALID_PROP_NAMES_SET.has(propName);\n\nexport const setPointProperty = <T>(node: Pixi.Container, name: string, value: T): void => {\n if (typeof value === \"object\" && value !== null) {\n (node as any)[name].set((value as any).x, (value as any).y);\n return;\n }\n\n if (typeof value === \"number\") {\n if (POINT_PROP_NAMES_SET.has(name)) {\n (node as any)[name].set(value);\n } else if (POINT_PROP_AXIS_NAMES_SET.has(name)) {\n const axisName = name[name.length - 1].toLowerCase();\n const propertyName = name.slice(0, -1);\n (node as any)[propertyName][axisName] = value;\n }\n }\n};\n"],"names":[],"mappings":";AAOO,MAAM,kBAAkB,CAAC,aAC9B,yBAAyB,IAAI,QAAQ;AAEhC,MAAM,mBAAmB,CAAI,MAAsB,MAAc,UAAmB;AACzF,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC9C,SAAa,IAAI,EAAE,IAAK,MAAc,GAAI,MAAc,CAAC;AAC1D;AAAA,EACF;AAEA,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,qBAAqB,IAAI,IAAI,GAAG;AACjC,WAAa,IAAI,EAAE,IAAI,KAAK;AAAA,IAC/B,WAAW,0BAA0B,IAAI,IAAI,GAAG;AAC9C,YAAM,WAAW,KAAK,KAAK,SAAS,CAAC,EAAE,YAAA;AACvC,YAAM,eAAe,KAAK,MAAM,GAAG,EAAE;AACpC,WAAa,YAAY,EAAE,QAAQ,IAAI;AAAA,IAC1C;AAAA,EACF;AACF;"}
@@ -1,14 +1,16 @@
1
1
  import type * as Pixi from "pixi.js";
2
2
  import type { JSX, Ref } from "solid-js";
3
- import type { PixiEventHandlerMap } from "./pixi-events";
3
+ import type { PixiEventHandlerMap } from "./event-names";
4
+ import type { PointAxisPropName } from "./point-property-names";
4
5
  /**
5
6
  * Prop definition for components that CAN have children
6
7
  */
7
- export type ContainerProps<Component> = PixiEventHandlerMap & {
8
+ export type ContainerProps<Component> = PixiEventHandlerMap & PointAxisProps & {
8
9
  ref?: Ref<Component>;
9
10
  as?: Component;
10
11
  children?: JSX.Element;
11
12
  };
13
+ export type PointAxisProps = Partial<Record<PointAxisPropName, number>>;
12
14
  /**
13
15
  * Prop definition for components that CANNOT have children
14
16
  */
@@ -4,4 +4,4 @@ export declare const PIXI_SOLID_EVENT_HANDLER_NAMES: ("onclick" | "onmousedown"
4
4
  export type PixiEventHandlerMap = {
5
5
  [K in (typeof PIXI_EVENT_NAMES)[number] as `on${K}`]?: null | ((...args: FederatedEventEmitterTypes[K]) => void);
6
6
  };
7
- export declare const PIXI_EVENT_HANDLER_NAME_SET: Readonly<Set<(typeof PIXI_SOLID_EVENT_HANDLER_NAMES)[number]>>;
7
+ export declare const PIXI_EVENT_HANDLER_NAME_SET: Set<string>;
@@ -1,10 +1,11 @@
1
1
  export type { ContainerProps, LeafProps } from "./component-creation";
2
+ export type { PixiEventHandlerMap } from "./event-names";
3
+ export { PIXI_EVENT_NAMES, PIXI_SOLID_EVENT_HANDLER_NAMES } from "./event-names";
2
4
  export { onResize } from "./on-resize";
3
5
  export type { PixiApplicationProps, PixiScreenDimensions } from "./pixi-application";
4
6
  export { createAsyncDelay, delay, getPixiApp, getTicker, onTick, PixiApplication, TickerProvider, usePixiScreen, } from "./pixi-application";
5
7
  export { PixiCanvas } from "./pixi-canvas";
6
8
  export { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, NineSliceSprite, ParticleContainer, PerspectiveMesh, RenderContainer, RenderLayer, Sprite, Text, TilingSprite, } from "./pixi-components";
7
- export type { PixiEventHandlerMap } from "./pixi-events";
8
- export { PIXI_EVENT_NAMES, PIXI_SOLID_EVENT_HANDLER_NAMES } from "./pixi-events";
9
9
  export type { PixiStageProps } from "./pixi-stage";
10
10
  export { PixiStage } from "./pixi-stage";
11
+ export type { PointAxisPropName } from "./point-property-names";
@@ -10,7 +10,7 @@ export declare const BitmapText: (props: Omit<Pixi.TextOptions<Pixi.TextStyle, P
10
10
  /**
11
11
  * A SolidJS component that renders a `PIXI.Container`.
12
12
  */
13
- export declare const Container: (props: Omit<Pixi.ContainerOptions<Pixi.ContainerChild>, "children"> & import("./pixi-events").PixiEventHandlerMap & {
13
+ export declare const Container: (props: Omit<Pixi.ContainerOptions<Pixi.ContainerChild>, "children"> & import("./event-names").PixiEventHandlerMap & Partial<Record<"positionX" | "positionY" | "scaleX" | "scaleY" | "pivotX" | "pivotY" | "skewX" | "skewY" | "anchorX" | "anchorY" | "tilePositionX" | "tilePositionY" | "tileScaleX" | "tileScaleY", number>> & {
14
14
  ref?: import("solid-js").Ref<Pixi.Container<Pixi.ContainerChild>> | undefined;
15
15
  as?: Pixi.Container<Pixi.ContainerChild> | undefined;
16
16
  children?: import("solid-js").JSX.Element;
@@ -49,7 +49,7 @@ export declare const PerspectiveMesh: (props: Omit<Pixi.PerspectivePlaneOptions,
49
49
  /**
50
50
  * A SolidJS component that renders a `PIXI.RenderContainer`.
51
51
  */
52
- export declare const RenderContainer: (props: Omit<Pixi.RenderContainerOptions, "children"> & import("./pixi-events").PixiEventHandlerMap & {
52
+ export declare const RenderContainer: (props: Omit<Pixi.RenderContainerOptions, "children"> & import("./event-names").PixiEventHandlerMap & Partial<Record<"positionX" | "positionY" | "scaleX" | "scaleY" | "pivotX" | "pivotY" | "skewX" | "skewY" | "anchorX" | "anchorY" | "tilePositionX" | "tilePositionY" | "tileScaleX" | "tileScaleY", number>> & {
53
53
  ref?: import("solid-js").Ref<Pixi.RenderContainer> | undefined;
54
54
  as?: Pixi.RenderContainer | undefined;
55
55
  children?: import("solid-js").JSX.Element;
@@ -57,7 +57,7 @@ export declare const RenderContainer: (props: Omit<Pixi.RenderContainerOptions,
57
57
  /**
58
58
  * A SolidJS component that renders a `PIXI.RenderLayer`.
59
59
  */
60
- export declare const RenderLayer: (props: Omit<Pixi.RenderLayerOptions, "children"> & import("./pixi-events").PixiEventHandlerMap & {
60
+ export declare const RenderLayer: (props: Omit<Pixi.RenderLayerOptions, "children"> & import("./event-names").PixiEventHandlerMap & Partial<Record<"positionX" | "positionY" | "scaleX" | "scaleY" | "pivotX" | "pivotY" | "skewX" | "skewY" | "anchorX" | "anchorY" | "tilePositionX" | "tilePositionY" | "tileScaleX" | "tileScaleY", number>> & {
61
61
  ref?: import("solid-js").Ref<Pixi.RenderLayer> | undefined;
62
62
  as?: Pixi.RenderLayer | undefined;
63
63
  children?: import("solid-js").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import type { Container, ContainerOptions } from "pixi.js";
2
2
  import type { JSX, Ref } from "solid-js";
3
- import type { PixiEventHandlerMap } from "./pixi-events";
3
+ import type { PixiEventHandlerMap } from "./event-names";
4
4
  export type PixiStageProps = PixiEventHandlerMap & Omit<ContainerOptions, "children"> & {
5
5
  ref?: Ref<Container>;
6
6
  children?: JSX.Element;
@@ -0,0 +1,5 @@
1
+ export declare const POINT_PROP_NAMES_SET: Set<string>;
2
+ export declare const POINT_PROP_AXIS_NAMES: readonly ["positionX", "positionY", "scaleX", "scaleY", "pivotX", "pivotY", "skewX", "skewY", "anchorX", "anchorY", "tilePositionX", "tilePositionY", "tileScaleX", "tileScaleY"];
3
+ export type PointAxisPropName = (typeof POINT_PROP_AXIS_NAMES)[number];
4
+ export declare const POINT_PROP_AXIS_NAMES_SET: Set<string>;
5
+ export declare const ALL_VALID_PROP_NAMES_SET: Set<string>;
@@ -0,0 +1,3 @@
1
+ import type * as Pixi from "pixi.js";
2
+ export declare const isEventProperty: (name: string) => boolean;
3
+ export declare const setEventProperty: (node: Pixi.Container, name: string, eventHandler: any, prevEventHandler?: any) => void;
@@ -0,0 +1,3 @@
1
+ import type * as Pixi from "pixi.js";
2
+ export declare const isPointProperty: (propName: string) => boolean;
3
+ export declare const setPointProperty: <T>(node: Pixi.Container, name: string, value: T) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pixi-solid",
3
3
  "private": false,
4
- "version": "0.0.30",
4
+ "version": "0.0.31",
5
5
  "description": "A library to write PixiJS applications with SolidJS",
6
6
  "author": "Luke Thompson",
7
7
  "license": "MIT",
@@ -35,7 +35,6 @@
35
35
  "dev": "vite",
36
36
  "prebuild": "rm -rf dist",
37
37
  "build": "vite build && tsc --project tsconfig.build.json --emitDeclarationOnly",
38
- "build:docs": "typedoc --options typedoc.config.js",
39
38
  "preview": "vite preview",
40
39
  "preinstall": "npx only-allow pnpm",
41
40
  "test": "echo \"A dummy test\""
@@ -1 +0,0 @@
1
- {"version":3,"file":"pixi-events.js","sources":["../src/pixi-events.ts"],"sourcesContent":["import type { FederatedEventEmitterTypes } from \"pixi.js\";\n\nexport const PIXI_EVENT_NAMES: (keyof FederatedEventEmitterTypes)[] = [\n \"click\",\n \"mousedown\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseout\",\n \"mouseover\",\n \"mouseup\",\n \"mouseupoutside\",\n \"pointercancel\",\n \"pointerdown\",\n \"pointerenter\",\n \"pointerleave\",\n \"pointermove\",\n \"pointerout\",\n \"pointerover\",\n \"pointertap\",\n \"pointerup\",\n \"pointerupoutside\",\n \"rightclick\",\n \"rightdown\",\n \"rightup\",\n \"rightupoutside\",\n \"tap\",\n \"touchcancel\",\n \"touchend\",\n \"touchendoutside\",\n \"touchmove\",\n \"touchstart\",\n \"wheel\",\n \"globalmousemove\",\n \"globalpointermove\",\n \"globaltouchmove\",\n \"clickcapture\",\n \"mousedowncapture\",\n \"mouseentercapture\",\n \"mouseleavecapture\",\n \"mousemovecapture\",\n \"mouseoutcapture\",\n \"mouseovercapture\",\n \"mouseupcapture\",\n \"mouseupoutsidecapture\",\n \"pointercancelcapture\",\n \"pointerdowncapture\",\n \"pointerentercapture\",\n \"pointerleavecapture\",\n \"pointermovecapture\",\n \"pointeroutcapture\",\n \"pointerovercapture\",\n \"pointertapcapture\",\n \"pointerupcapture\",\n \"pointerupoutsidecapture\",\n \"rightclickcapture\",\n \"rightdowncapture\",\n \"rightupcapture\",\n \"rightupoutsidecapture\",\n \"tapcapture\",\n \"touchcancelcapture\",\n \"touchendcapture\",\n \"touchendoutsidecapture\",\n \"touchmovecapture\",\n \"touchstartcapture\",\n \"wheelcapture\",\n] as const;\n\nexport const PIXI_SOLID_EVENT_HANDLER_NAMES = PIXI_EVENT_NAMES.map(\n (eventName) => `on${eventName}` as const,\n);\n\nexport type PixiEventHandlerMap = {\n [K in (typeof PIXI_EVENT_NAMES)[number] as `on${K}`]?:\n | null\n | ((...args: FederatedEventEmitterTypes[K]) => void);\n};\n\nexport const PIXI_EVENT_HANDLER_NAME_SET: Readonly<\n Set<(typeof PIXI_SOLID_EVENT_HANDLER_NAMES)[number]>\n> = new Set(PIXI_SOLID_EVENT_HANDLER_NAMES);\n\n/**\n * This is a type-safe check that ensures `PIXI_EVENT_NAMES` includes every key from Pixi's `AllFederatedEventMap` type.\n * It will cause a build error if any event names are missing.\n */\ntype MissingKeys = Exclude<keyof FederatedEventEmitterTypes, (typeof PIXI_EVENT_NAMES)[number]>;\ntype AllEventsAreHandled = MissingKeys extends never\n ? true\n : `Error: Missing event keys: ${MissingKeys}`;\nconst allEventsAreHandled: AllEventsAreHandled = true;\nvoid allEventsAreHandled;\n"],"names":[],"mappings":"AAEO,MAAM,mBAAyD;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,iCAAiC,iBAAiB;AAAA,EAC7D,CAAC,cAAc,KAAK,SAAS;AAC/B;AAQO,MAAM,8BAET,IAAI,IAAI,8BAA8B;"}