pixi-solid 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PixiApplication, TickerProvider, usePixiApp, useTick, useTicker } from "./pixi-application.js";
1
+ import { PixiApplication, TickerProvider, useDelay, usePixiApp, useTick, useTicker } from "./pixi-application.js";
2
2
  import { PixiCanvas } from "./pixi-canvas.js";
3
3
  import { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, MeshSimple, NineSliceSprite, ParticleContainer, PerspectiveMesh, RenderContainer, RenderLayer, Sprite, Text, TilingSprite } from "./pixi-components.js";
4
4
  import { PIXI_EVENT_NAMES, PIXI_SOLID_EVENT_HANDLER_NAMES } from "./pixi-events.js";
@@ -27,6 +27,7 @@ export {
27
27
  Text,
28
28
  TickerProvider,
29
29
  TilingSprite,
30
+ useDelay,
30
31
  usePixiApp,
31
32
  useResize,
32
33
  useTick,
@@ -85,9 +85,30 @@ const useTick = (tickerCallback) => {
85
85
  ticker.remove(tickerCallback);
86
86
  });
87
87
  };
88
+ const useDelay = async (delayMs, callback) => {
89
+ const ticker = useContext(TickerContext);
90
+ if (!ticker) {
91
+ throw new Error("useDelay must be used within a PixiApplication or a TickerProvider");
92
+ }
93
+ let timeDelayed = 0;
94
+ let resolvePromise;
95
+ const promise = new Promise((resolve) => {
96
+ resolvePromise = resolve;
97
+ });
98
+ const internalCallback = () => {
99
+ timeDelayed += ticker.deltaMS;
100
+ if (timeDelayed < delayMs) return;
101
+ callback?.();
102
+ resolvePromise();
103
+ };
104
+ ticker.add(internalCallback);
105
+ await promise;
106
+ ticker.remove(internalCallback);
107
+ };
88
108
  export {
89
109
  PixiApplication,
90
110
  TickerProvider,
111
+ useDelay,
91
112
  usePixiApp,
92
113
  useTick,
93
114
  useTicker
@@ -1 +1 @@
1
- {"version":3,"file":"pixi-application.js","sources":["../src/pixi-application.tsx"],"sourcesContent":["import type { ApplicationOptions, Ticker, TickerCallback } from \"pixi.js\";\nimport { Application } from \"pixi.js\";\nimport type { JSX, ParentProps, Ref } from \"solid-js\";\nimport { createContext, createEffect, createResource, onCleanup, Show, splitProps, useContext } from \"solid-js\";\n\nconst PixiAppContext = createContext<Application>();\nconst TickerContext = createContext<Ticker>();\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 usePixiApp = () => {\n const app = useContext(PixiAppContext);\n if (!app) {\n throw new Error(\"usePixiApp 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 `usePixiApp`, `useTick`, and `useTicker`.\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\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 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 onCleanup(() => {\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}>{props.children}</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 `useTick` and `useTicker` 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 * useTicker\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 useTicker = (): Ticker => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\"useTicker must be used within a PixiApplication or a TickerProvider\");\n }\n return ticker;\n};\n\n/**\n * useTick\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 useTick = (tickerCallback: TickerCallback<Ticker>): void => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\"useTick must be used within a PixiApplication or a TickerProvider\");\n }\n\n ticker.add(tickerCallback);\n onCleanup(() => {\n ticker.remove(tickerCallback);\n });\n};\n"],"names":["PixiAppContext","createContext","TickerContext","usePixiApp","app","useContext","Error","PixiApplication","props","initialisationProps","splitProps","appResource","createResource","Application","init","autoDensity","resolution","Math","min","window","devicePixelRatio","sharedTicker","createEffect","ref","ticker","autoStart","start","onCleanup","destroy","children","_$createComponent","Show","when","Provider","value","TickerProvider","useTicker","useTick","tickerCallback","add","remove"],"mappings":";;;AAKA,MAAMA,iBAAiBC,cAAAA;AACvB,MAAMC,gBAAgBD,cAAAA;AASf,MAAME,aAAaA,MAAM;AAC9B,QAAMC,MAAMC,WAAWL,cAAc;AACrC,MAAI,CAACI,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;AAIrE,QAAM,CAACG,WAAW,IAAIC,eAAe,YAAY;AAC/C,UAAMR,MAAM,IAAIS,YAAAA;AAChB,UAAMT,IAAIU,KAAK;AAAA,MACbC,aAAa;AAAA,MACbC,YAAYC,KAAKC,IAAIC,OAAOC,kBAAkB,CAAC;AAAA,MAC/CC,cAAc;AAAA,MACd,GAAGZ;AAAAA,IAAAA,CACJ;AAED,WAAOL;AAAAA,EACT,CAAC;AAEDkB,eAAa,MAAM;AACjB,UAAMlB,MAAMO,YAAAA;AACZ,QAAIP,KAAK;AACP,UAAII,MAAMe,KAAK;AAEZf,cAAMe,IAAsCnB,GAAG;AAAA,MAClD;AAKAA,UAAIoB,OAAOC,YAAY;AACvBrB,UAAIoB,OAAOE,MAAAA;AAEXC,gBAAU,MAAM;AACdvB,YAAIwB,QAAQ,MAAM;AAAA,UAAEC,UAAU;AAAA,QAAA,CAAM;AAAA,MACtC,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,SAAAC,gBACGC,MAAI;AAAA,IAAA,IAACC,OAAI;AAAA,aAAErB,YAAAA;AAAAA,IAAa;AAAA,IAAAkB,UACrBzB,CAAAA,QAAG0B,gBACF9B,eAAeiC,UAAQ;AAAA,MAAA,IAACC,QAAK;AAAA,eAAE9B,IAAAA;AAAAA,MAAK;AAAA,MAAA,IAAAyB,WAAA;AAAA,eAAAC,gBAClC5B,cAAc+B,UAAQ;AAAA,UAAA,IAACC,QAAK;AAAA,mBAAE9B,MAAMoB;AAAAA,UAAM;AAAA,UAAA,IAAAK,WAAA;AAAA,mBAAGrB,MAAMqB;AAAAA,UAAQ;AAAA,QAAA,CAAA;AAAA,MAAA;AAAA,IAAA,CAAA;AAAA,EAAA,CAE/D;AAGP;AAUO,MAAMM,iBAAiBA,CAAC3B,UAA+B;AAC5D,SAAAsB,gBAAQ5B,cAAc+B,UAAQ;AAAA,IAAA,IAACC,QAAK;AAAA,aAAE1B,MAAMgB;AAAAA,IAAM;AAAA,IAAA,IAAAK,WAAA;AAAA,aAAGrB,MAAMqB;AAAAA,IAAQ;AAAA,EAAA,CAAA;AACrE;AAYO,MAAMO,YAAYA,MAAc;AACrC,QAAMZ,SAASnB,WAAWH,aAAa;AACvC,MAAI,CAACsB,QAAQ;AACX,UAAM,IAAIlB,MAAM,qEAAqE;AAAA,EACvF;AACA,SAAOkB;AACT;AAgBO,MAAMa,UAAUA,CAACC,mBAAiD;AACvE,QAAMd,SAASnB,WAAWH,aAAa;AAEvC,MAAI,CAACsB,QAAQ;AACX,UAAM,IAAIlB,MAAM,mEAAmE;AAAA,EACrF;AAEAkB,SAAOe,IAAID,cAAc;AACzBX,YAAU,MAAM;AACdH,WAAOgB,OAAOF,cAAc;AAAA,EAC9B,CAAC;AACH;"}
1
+ {"version":3,"file":"pixi-application.js","sources":["../src/pixi-application.tsx"],"sourcesContent":["import type { ApplicationOptions, Ticker, TickerCallback } from \"pixi.js\";\nimport { Application } from \"pixi.js\";\nimport type { JSX, ParentProps, Ref } from \"solid-js\";\nimport { createContext, createEffect, createResource, onCleanup, Show, splitProps, useContext } from \"solid-js\";\n\nconst PixiAppContext = createContext<Application>();\nconst TickerContext = createContext<Ticker>();\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 usePixiApp = () => {\n const app = useContext(PixiAppContext);\n if (!app) {\n throw new Error(\"usePixiApp 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 `usePixiApp`, `useTick`, and `useTicker`.\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\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 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 onCleanup(() => {\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}>{props.children}</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 `useTick` and `useTicker` 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 * useTicker\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 useTicker = (): Ticker => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\"useTicker must be used within a PixiApplication or a TickerProvider\");\n }\n return ticker;\n};\n\n/**\n * useTick\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 useTick = (tickerCallback: TickerCallback<Ticker>): void => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\"useTick must be used within a PixiApplication or a TickerProvider\");\n }\n\n ticker.add(tickerCallback);\n onCleanup(() => {\n ticker.remove(tickerCallback);\n });\n};\n\n/**\n * Delay until a given number of milliseconds has passed on the application ticker.\n *\n * It is guaranteed to be in sync with the ticker and uses accumulated deltaMs not an external time measurement.\n *\n * Simply await for it to resolve if in an async context or pass in a callback function.\n * It's not recommended to use both techniques at once.\n *\n * @param delayMs - Number of milliseconds to wait (measured in the ticker's time units).\n *\n * @param callback - Optional callback function that will fire when the delayMs time has passed.\n *\n * @returns A Promise that resolves once the ticker's time has advanced by `delayMs`.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n *\n * @note It will not resolve or fire the callback if the ticker is paused or stopped.\n *\n */\nexport const useDelay = async (delayMs: number, callback?: () => void): Promise<void> => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\"useDelay must be used within a PixiApplication or a TickerProvider\");\n }\n\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 callback?.();\n resolvePromise();\n };\n\n ticker.add(internalCallback);\n\n await promise;\n\n ticker.remove(internalCallback);\n};\n"],"names":["PixiAppContext","createContext","TickerContext","usePixiApp","app","useContext","Error","PixiApplication","props","initialisationProps","splitProps","appResource","createResource","Application","init","autoDensity","resolution","Math","min","window","devicePixelRatio","sharedTicker","createEffect","ref","ticker","autoStart","start","onCleanup","destroy","children","_$createComponent","Show","when","Provider","value","TickerProvider","useTicker","useTick","tickerCallback","add","remove","useDelay","delayMs","callback","timeDelayed","resolvePromise","promise","Promise","resolve","internalCallback","deltaMS"],"mappings":"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"}
@@ -1,5 +1,5 @@
1
1
  export type { PixiApplicationProps } from "./pixi-application";
2
- export { PixiApplication, TickerProvider, usePixiApp, useTick, useTicker, } from "./pixi-application";
2
+ export { PixiApplication, TickerProvider, useDelay, usePixiApp, useTick, useTicker, } from "./pixi-application";
3
3
  export { PixiCanvas } from "./pixi-canvas";
4
4
  export type { ContainerProps, LeafProps } from "./pixi-components";
5
5
  export { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, MeshSimple, NineSliceSprite, ParticleContainer, PerspectiveMesh, RenderContainer, RenderLayer, Sprite, Text, TilingSprite, } from "./pixi-components";
@@ -65,3 +65,23 @@ export declare const useTicker: () => Ticker;
65
65
  *
66
66
  */
67
67
  export declare const useTick: (tickerCallback: TickerCallback<Ticker>) => void;
68
+ /**
69
+ * Delay until a given number of milliseconds has passed on the application ticker.
70
+ *
71
+ * It is guaranteed to be in sync with the ticker and uses accumulated deltaMs not an external time measurement.
72
+ *
73
+ * Simply await for it to resolve if in an async context or pass in a callback function.
74
+ * It's not recommended to use both techniques at once.
75
+ *
76
+ * @param delayMs - Number of milliseconds to wait (measured in the ticker's time units).
77
+ *
78
+ * @param callback - Optional callback function that will fire when the delayMs time has passed.
79
+ *
80
+ * @returns A Promise that resolves once the ticker's time has advanced by `delayMs`.
81
+ *
82
+ * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.
83
+ *
84
+ * @note It will not resolve or fire the callback if the ticker is paused or stopped.
85
+ *
86
+ */
87
+ export declare const useDelay: (delayMs: number, callback?: () => void) => Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pixi-solid",
3
3
  "private": false,
4
- "version": "0.0.15",
4
+ "version": "0.0.16",
5
5
  "description": "A library to write PixiJS applications with SolidJS",
6
6
  "author": "Luke Thompson",
7
7
  "license": "MIT",