pixi-solid 0.1.22 → 1.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +186 -0
  2. package/LICENSE +21 -0
  3. package/README.md +22 -8
  4. package/dist/components/bind-props/bind-children.js.map +1 -1
  5. package/dist/components/bind-props/bind-props.js +6 -0
  6. package/dist/components/bind-props/bind-props.js.map +1 -1
  7. package/dist/components/bind-props/point-property-names.js.map +1 -1
  8. package/dist/components/bind-props/set-point-property.js.map +1 -1
  9. package/dist/components/component-factories.js.map +1 -1
  10. package/dist/{types/index.d.ts → index.d.ts} +1 -2
  11. package/dist/index.js +2 -2
  12. package/dist/on-resize.js.map +1 -1
  13. package/dist/on-tick.js.map +1 -1
  14. package/dist/{types/pixi-application → pixi-application}/context.d.ts +2 -4
  15. package/dist/pixi-application/context.js +2 -1
  16. package/dist/pixi-application/context.js.map +1 -1
  17. package/dist/pixi-application/get-pixi-app.js +1 -1
  18. package/dist/pixi-application/get-pixi-app.js.map +1 -1
  19. package/dist/pixi-application/get-renderer.d.ts +8 -0
  20. package/dist/pixi-application/get-renderer.js +18 -0
  21. package/dist/pixi-application/get-renderer.js.map +1 -0
  22. package/dist/pixi-application/get-ticker.d.ts +8 -0
  23. package/dist/pixi-application/get-ticker.js +4 -8
  24. package/dist/pixi-application/get-ticker.js.map +1 -1
  25. package/dist/{types/pixi-application → pixi-application}/index.d.ts +2 -1
  26. package/dist/pixi-application/pixi-application-provider.js +17 -14
  27. package/dist/pixi-application/pixi-application-provider.js.map +1 -1
  28. package/dist/pixi-application/pixi-application.js.map +1 -1
  29. package/dist/pixi-canvas.js.map +1 -1
  30. package/dist/use-pixi-screen/pixi-screen-store.js.map +1 -1
  31. package/dist/use-pixi-screen/use-pixi-screen.d.ts +10 -0
  32. package/dist/use-pixi-screen/use-pixi-screen.js +6 -7
  33. package/dist/use-pixi-screen/use-pixi-screen.js.map +1 -1
  34. package/dist/{types → utils}/delay.d.ts +3 -2
  35. package/dist/{delay.js → utils/delay.js} +3 -3
  36. package/dist/utils/delay.js.map +1 -0
  37. package/dist/utils/index.d.ts +7 -0
  38. package/dist/utils/index.js +3 -2
  39. package/dist/utils/object-fit.d.ts +51 -0
  40. package/dist/utils/object-fit.js +160 -22
  41. package/dist/utils/object-fit.js.map +1 -1
  42. package/dist/utils/smooth-damp.js.map +1 -1
  43. package/dist/utils/spring.js.map +1 -1
  44. package/package.json +7 -5
  45. package/pixi-solid-logo.png +0 -0
  46. package/dist/delay.js.map +0 -1
  47. package/dist/types/benchmarks/container-prop-updates/container-prop-updates.bench.d.ts +0 -1
  48. package/dist/types/benchmarks/point-property-lookup/point-property-lookup.bench.d.ts +0 -1
  49. package/dist/types/benchmarks/point-property-lookup/point-property-lookup.variant.d.ts +0 -2
  50. package/dist/types/benchmarks/set-event-property/set-event-property.bench.d.ts +0 -1
  51. package/dist/types/benchmarks/set-event-property/set-event-property.variant.d.ts +0 -3
  52. package/dist/types/benchmarks/set-prop-assignment/set-prop-assignment.bench.d.ts +0 -1
  53. package/dist/types/benchmarks/set-prop-assignment/set-prop-assignment.variant.d.ts +0 -3
  54. package/dist/types/components/bind-props/bind-children.test.d.ts +0 -1
  55. package/dist/types/components/bind-props/bind-props.test.d.ts +0 -1
  56. package/dist/types/components/component-factories.test.d.ts +0 -1
  57. package/dist/types/components/components.test.d.ts +0 -1
  58. package/dist/types/components/spread-signal-props.test.d.ts +0 -1
  59. package/dist/types/on-resize.test.d.ts +0 -1
  60. package/dist/types/pixi-application/get-ticker.d.ts +0 -12
  61. package/dist/types/testing/index.d.ts +0 -3
  62. package/dist/types/testing/pixi-renderer-mock.d.ts +0 -24
  63. package/dist/types/testing/test-root.d.ts +0 -9
  64. package/dist/types/testing/test-root.test.d.ts +0 -1
  65. package/dist/types/use-pixi-screen/use-pixi-screen.d.ts +0 -11
  66. package/dist/types/use-pixi-screen/use-pixi-screen.test.d.ts +0 -1
  67. package/dist/types/utils/index.d.ts +0 -5
  68. package/dist/types/utils/object-fit.d.ts +0 -12
  69. /package/dist/{types/components → components}/bind-props/bind-children.d.ts +0 -0
  70. /package/dist/{types/components → components}/bind-props/bind-props.d.ts +0 -0
  71. /package/dist/{types/components → components}/bind-props/event-names.d.ts +0 -0
  72. /package/dist/{types/components → components}/bind-props/index.d.ts +0 -0
  73. /package/dist/{types/components → components}/bind-props/is-event-property.d.ts +0 -0
  74. /package/dist/{types/components → components}/bind-props/point-property-names.d.ts +0 -0
  75. /package/dist/{types/components → components}/bind-props/set-point-property.d.ts +0 -0
  76. /package/dist/{types/components → components}/component-factories.d.ts +0 -0
  77. /package/dist/{types/components → components}/components.d.ts +0 -0
  78. /package/dist/{types/components → components}/index.d.ts +0 -0
  79. /package/dist/{types/on-resize.d.ts → on-resize.d.ts} +0 -0
  80. /package/dist/{types/on-tick.d.ts → on-tick.d.ts} +0 -0
  81. /package/dist/{types/pixi-application → pixi-application}/get-pixi-app.d.ts +0 -0
  82. /package/dist/{types/pixi-application → pixi-application}/pixi-application-provider.d.ts +0 -0
  83. /package/dist/{types/pixi-application → pixi-application}/pixi-application.d.ts +0 -0
  84. /package/dist/{types/pixi-canvas.d.ts → pixi-canvas.d.ts} +0 -0
  85. /package/dist/{types/use-pixi-screen → use-pixi-screen}/index.d.ts +0 -0
  86. /package/dist/{types/use-pixi-screen → use-pixi-screen}/pixi-screen-store.d.ts +0 -0
  87. /package/dist/{types/utils → utils}/smooth-damp.d.ts +0 -0
  88. /package/dist/{types/utils → utils}/spring.d.ts +0 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,186 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ - ✅ Added for new features.
9
+ - ⚙️ Changed for changes in existing functionality.
10
+ - 😵 Deprecated for soon-to-be removed features.
11
+ - 💀 Removed for now removed features.
12
+ - 🐞 Fixed for any bug fixes.
13
+
14
+ ## 1.0.0-rc.0
15
+
16
+ - No public changes yet
17
+ - Added some more tests
18
+ - Updated the docs
19
+
20
+ ## 0.2.0
21
+
22
+ - ⚙️ Moved `delay` and `createAsyncDelay` exports from main `pixi-solid` package to `pixi-solid/utils`. Update imports from `import { delay, createAsyncDelay } from "pixi-solid"` to `import { delay, createAsyncDelay } from "pixi-solid/utils"`.
23
+ - ✅ Added `ObjectFitContainer` component for scaling and positioning children with object-fit style layout control.
24
+ - ✅ Added `getRenderer` hook to access the root Pixi Renderer instance.
25
+ - ✅ Enhanced `objectFit` function to add support for custom positioning, local bounds handling, and additional fit modes including `"none"`.
26
+
27
+ ## 0.1.22
28
+
29
+ - 🐞 Fixed a the behaviour in `onResize` to make it always fire at the expected times.
30
+
31
+ ## 0.1.21
32
+
33
+ - 🐞 Fixed a regression where type inference was broken for the `Graphics` `ref` prop.
34
+
35
+ ## 0.1.20
36
+
37
+ - ⚙️ Updated README structure with dedicated install, basic usage, and docs sections.
38
+ - ⚙️ Added an expanded TSX usage example in README.
39
+ - ⚙️ Updated README peer dependency examples to explicit compatible ranges.
40
+
41
+ ## 0.1.19
42
+
43
+ - ⚙️ Use more specific peer dependency range
44
+ - Improved test helpers and refactored tests
45
+ - Use dependency overrides for the monorepo instead of having per package versions
46
+
47
+ ## 0.1.18
48
+
49
+ - ✅ Added `PixiSolidEventHandlerName` union type to exports.
50
+ - 💀 Removed `PixiEventHandlerMap` type from exports.
51
+ - 💀 Removed `PIXI_EVENT_NAMES` and `PIXI_SOLID_EVENT_HANDLER_NAMES` constants from exports.
52
+ - Renamed internal event types.
53
+
54
+ ## 0.1.17
55
+
56
+ - 🐞 Fixed a race condition which could cause inconsistent screen dimensions when the `onResize` hook and the `usePixiScreen` hook are used together.
57
+
58
+ ## 0.1.16
59
+
60
+ - ⚙️ Changed the `AnimatedSprite` component to use the nearest ticker context instead of the Pixi `Ticker.shared` for the `autoUpdate` functionality.
61
+
62
+ ## 0.1.15
63
+
64
+ - 🐞 Fixed the types for leaf components by removing the `TilingSprite` specific props `tilePosition` and `tileScale` from the prop types.
65
+
66
+ ## 0.1.14
67
+
68
+ - ✅ Adds an optional ticker priority argument to the `onTick` hook.
69
+
70
+ ## 0.1.13
71
+
72
+ - 🐞 Fix usePixiScreen hook not being reactive on all values.
73
+
74
+ ## 0.1.12
75
+
76
+ - 🐞 Fixed component destroy behaviour to be managed by the components own lifecycle rather than in the bind children function.
77
+ Fixes a bug where children would not be destroyed if a `PixiCanvas` was unmounted.
78
+
79
+ ## 0.1.11
80
+
81
+ - 🐞 `PixiApplicationProvider` now only destroys the app instance on unmount if it created it.
82
+
83
+ ## 0.1.10
84
+
85
+ - 🐞 Fixed event handler reactivity where handlers bound through spread props were not properly unregistered when updated.
86
+ - 🐞 Fixed component prop reactivity if a signal is spread into a component with dynamic properties.
87
+
88
+ ## 0.1.9
89
+
90
+ - 🐞 Fixed components that have initial arguments that aren't exposed as public properties on the instance.
91
+
92
+ ## 0.1.8
93
+
94
+ - Refactored prop binding to improve performance and added benchmark tests.
95
+
96
+ ## 0.1.7
97
+
98
+ - 🐞 Fix timing of ref assignment to be consistent with SolidJS.
99
+ Ref's are meant to be assigned before the element is added to the scene and `onMount` should be used to reference elements after they are added to the scene.
100
+ Reverts the change in `0.1.4`.
101
+
102
+ ## 0.1.5
103
+
104
+ - 🐞 Fix context loss in ref callback function scope.
105
+
106
+ ## 0.1.4
107
+
108
+ - 🐞 Fix timing of ref callback to make sure the object is added to the scene before the ref is set.
109
+
110
+ ## 0.1.3
111
+
112
+ - ✅ Improved error handling for invalid children.
113
+
114
+ ## 0.1.2
115
+
116
+ - Cleanup
117
+
118
+ ## 0.1.1
119
+
120
+ - Internal refactor to remove the universal renderer
121
+
122
+ ## 0.1.0
123
+
124
+ #### ✅ Added
125
+
126
+ - Added `PixiApplicationProvider` component that can be ued to instantiate the Pixi Application allowing the hooks and utilites to work within it's scope.
127
+ - Added option to abort an async delay early by passing in an abort signal.
128
+
129
+ #### ⚙️ Changed
130
+
131
+ - Changed the `PixiCanvas` component to not require a `PixiApplication` as a wrapper.
132
+ It uses the context from the `PixiApplicationProvider` if available or it will instantiate it's own Pixi Application if an existing one isn't found.
133
+
134
+ #### 💀 Removed
135
+
136
+ - Removed the `PixiApplication` component as it's purpose can be solved in a more flexible way.
137
+
138
+ #### 🐞 Fixed
139
+
140
+ - Fixed the `RenderLayer` children from not being removed properly.
141
+
142
+ ## 0.0.36
143
+
144
+ #### 💀 Removed
145
+
146
+ - Removed the `PixiStage` component as it provided little value and was a bit of a nuisance.
147
+ The pixi stage component can be accessed from the `getPixiApp` context if required.
148
+
149
+ #### ✅ Added
150
+
151
+ - Added a utility type `PixiComponentProps` that is useful for extending custom component props that users want to pass through.
152
+
153
+ ## 0.0.33
154
+
155
+ #### ⚙️ Changed
156
+
157
+ - Added defaults for the `PixiApplication` back in. Set `autoDensity` to `true` and `resolution` to use `window.devicePixelRatio` by default.
158
+
159
+ ## 0.0.32
160
+
161
+ #### ✅ Added
162
+
163
+ - Added default styles to the `canvas` element to stop select on long press on touch sreens.
164
+
165
+ ## 0.0.31
166
+
167
+ #### ✅ Added
168
+
169
+ - Added support for granular control of PixiJS point properties directly as JSX props (e.g., `positionX`, `scaleY`, `pivotX`).
170
+
171
+ #### ⚙️ Changed
172
+
173
+ - Changed `PixiApplication` component to allow all standard `ApplicationOptions` to be passed directly as props during initialization and removed opinionated defaults.
174
+
175
+ ## 0.0.31
176
+
177
+ #### ✅ Added
178
+
179
+ - Added a `useSmoothDamp` hook for smoothly dampening a numeric value towards a target over time, synchronized with the PixiJS ticker.
180
+ - Added a `useSpring` hook for creating spring-based animations for numeric values, synchronized with the PixiJS ticker.
181
+
182
+ ## 0.0.30
183
+
184
+ #### ✅ Added
185
+
186
+ - Added a `usePixiScreen` hook that returns the Pixi Screen dimensions as a reactive store that can be subscribed to.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Luke Carl Thompson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,18 +1,25 @@
1
+ <div align="center">
2
+ <img src="./pixi-solid-logo.png" alt="Pixi-Solid Logo" width="200" />
3
+
4
+ [![NPM Version](https://img.shields.io/npm/v/pixi-solid.svg)](https://www.npmjs.com/package/pixi-solid)
5
+ [![License](https://img.shields.io/npm/l/pixi-solid.svg)](./LICENSE)
6
+ [![CI](https://github.com/LukeCarlThompson/pixi-solid/actions/workflows/ci.yml/badge.svg)](https://github.com/LukeCarlThompson/pixi-solid/actions)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-6.0-blue)](https://www.typescriptlang.org/)
8
+
9
+ </div>
10
+
1
11
  # Pixi-Solid
2
12
 
3
13
  A custom renderer for [PixiJS](https://pixijs.com/) that lets you build your scene with [SolidJS](https://www.solidjs.com/) JSX components and its fine-grained signals based reactivity.
4
14
 
5
- [![NPM Version](https://img.shields.io/npm/v/pixi-solid.svg)](https://www.npmjs.com/package/pixi-solid)
6
- [![License](https://img.shields.io/npm/l/pixi-solid.svg)](https://github.com/your-username/pixi-solid/blob/main/LICENSE)
7
-
8
15
  - 💙 Lightweight and flexible SolidJS library for creating PixiJS applications.
9
16
  - 🎁 Provides a set of custom SolidJS components that create PixiJS objects instead of HTML elements.
10
17
  - 💪 Supports all PixiJS features.
11
18
  - 🥳 The convenience and speed of SolidJS stores and signals to manage state.
12
19
  - ✨ All events emitted by PixiJS objects are supported.
13
20
  - 😎 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.
21
+ - 💫 Useful helper utilities for animations, layout, and async timing.
22
+ - 🤩 Full TypeScript support with strict type safety and auto completion throughout the API.
16
23
 
17
24
  ## Install
18
25
 
@@ -56,9 +63,11 @@ export const DemoApp = () => {
56
63
  };
57
64
  ```
58
65
 
59
- ## Documentation and examples
66
+ ## Next Steps
60
67
 
61
- Check out the [documentation site 🧑‍💻](https://lukecarlthompson.github.io/pixi-solid/) for more comprehensive information and live examples.
68
+ - **New to Pixi Solid?** Check out the [Getting Started guide](https://lukecarlthompson.github.io/pixi-solid/docs/getting-started/project-setup/) to set up your first project.
69
+ - **Explore features** like responsive layout with [`ObjectFitContainer`](https://lukecarlthompson.github.io/pixi-solid/docs/utils/object-fit-container/), animations with [`useSpring`](https://lukecarlthompson.github.io/pixi-solid/docs/utils/use-spring/) and ticker-synced delays.
70
+ - **Browse live examples** in the [documentation site](https://lukecarlthompson.github.io/pixi-solid/).
62
71
 
63
72
  ## Why combine SolidJS with PixiJS?
64
73
 
@@ -78,9 +87,14 @@ Check out the [documentation site 🧑‍💻](https://lukecarlthompson.github.i
78
87
 
79
88
  - **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.
80
89
 
90
+ ## Quick Links
91
+
92
+ - 📖 **[Full Documentation](https://lukecarlthompson.github.io/pixi-solid/)** — Components, hooks, utilities, and examples
93
+ - 🐛 **[GitHub Issues](https://github.com/LukeCarlThompson/pixi-solid/issues)** — Report bugs or request features
94
+
81
95
  ## Contributing
82
96
 
83
- Contributions are welcome! This project is still in its early stages, so feel free to open an issue to report a bug, suggest a feature, or submit a pull request.
97
+ Contributions are welcome! Feel free to open an issue to report a bug, suggest a feature, or submit a pull request.
84
98
 
85
99
  ## License
86
100
 
@@ -1 +1 @@
1
- {"version":3,"file":"bind-children.js","names":[],"sources":["../../../src/components/bind-props/bind-children.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { children as resolveChildren, createRenderEffect } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\n\nexport class InvalidChildTypeError extends Error {\n constructor(cause: Error) {\n super(\n \"Invalid pixi-solid child type. Children must be pixi-solid or PixiJS element. Did you accidentally pass an invalid child to a pixi-solid parent?\",\n { cause },\n );\n this.name = \"InvalidChildTypeError\";\n }\n}\n\nexport const bindChildrenToContainer = (parent: Pixi.Container, children?: JSX.Element): void => {\n const resolvedChildren = resolveChildren(() => children);\n\n const canAddChild = \"addChildAt\" in parent;\n\n if (!canAddChild) {\n throw new Error(\"Parent does not support children.\");\n }\n\n createRenderEffect(() => {\n const nextChildren = resolvedChildren.toArray().filter(Boolean) as unknown as Pixi.Container[];\n\n try {\n for (let i = 0; i < nextChildren.length; i += 1) {\n parent.addChildAt(nextChildren[i], i);\n }\n } catch (error) {\n if (error instanceof Error) {\n console.error(\"Invalid children\", nextChildren);\n throw new InvalidChildTypeError(error);\n } else {\n throw error;\n }\n }\n });\n};\n\nexport const bindChildrenToRenderLayer = (\n parent: Pixi.RenderLayer,\n children?: JSX.Element,\n): void => {\n const resolvedChildren = resolveChildren(() => children);\n\n createRenderEffect((prevChildren: Pixi.Container[] | undefined) => {\n const nextChildren = resolvedChildren.toArray().filter(Boolean) as unknown as Pixi.Container[];\n\n try {\n if (prevChildren) {\n for (let i = 0; i < prevChildren.length; i += 1) {\n const child = prevChildren[i];\n if (nextChildren.includes(child)) continue;\n\n parent.detach(child);\n }\n }\n\n for (let i = 0; i < nextChildren.length; i += 1) {\n parent.attach(nextChildren[i]);\n }\n } catch (error) {\n if (error instanceof Error) {\n console.error(\"Invalid children\", nextChildren);\n throw new InvalidChildTypeError(error);\n } else {\n throw error;\n }\n }\n\n return nextChildren;\n });\n};\n"],"mappings":";;AAIA,IAAa,wBAAb,cAA2C,MAAM;CAC/C,YAAY,OAAc;AACxB,QACE,oJACA,EAAE,OAAO,CACV;AACD,OAAK,OAAO;;;AAIhB,IAAa,2BAA2B,QAAwB,eAAiC;CAC/F,MAAM,mBAAmB,eAAsB,WAAS;AAIxD,KAAI,EAFgB,gBAAgB,QAGlC,OAAM,IAAI,MAAM,oCAAoC;AAGtD,0BAAyB;EACvB,MAAM,eAAe,iBAAiB,SAAS,CAAC,OAAO,QAAQ;AAE/D,MAAI;AACF,QAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,EAC5C,QAAO,WAAW,aAAa,IAAI,EAAE;WAEhC,OAAO;AACd,OAAI,iBAAiB,OAAO;AAC1B,YAAQ,MAAM,oBAAoB,aAAa;AAC/C,UAAM,IAAI,sBAAsB,MAAM;SAEtC,OAAM;;GAGV;;AAGJ,IAAa,6BACX,QACA,eACS;CACT,MAAM,mBAAmB,eAAsB,WAAS;AAExD,qBAAoB,iBAA+C;EACjE,MAAM,eAAe,iBAAiB,SAAS,CAAC,OAAO,QAAQ;AAE/D,MAAI;AACF,OAAI,aACF,MAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,GAAG;IAC/C,MAAM,QAAQ,aAAa;AAC3B,QAAI,aAAa,SAAS,MAAM,CAAE;AAElC,WAAO,OAAO,MAAM;;AAIxB,QAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,EAC5C,QAAO,OAAO,aAAa,GAAG;WAEzB,OAAO;AACd,OAAI,iBAAiB,OAAO;AAC1B,YAAQ,MAAM,oBAAoB,aAAa;AAC/C,UAAM,IAAI,sBAAsB,MAAM;SAEtC,OAAM;;AAIV,SAAO;GACP"}
1
+ {"version":3,"file":"bind-children.js","names":[],"sources":["../../../src/components/bind-props/bind-children.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { children as resolveChildren, createRenderEffect } from \"solid-js\";\nimport type { JSX } from \"solid-js\";\n\nexport class InvalidChildTypeError extends Error {\n constructor(cause: Error) {\n super(\n \"Invalid pixi-solid child type. Children must be pixi-solid or PixiJS element. Did you accidentally pass an invalid child to a pixi-solid parent?\",\n { cause },\n );\n this.name = \"InvalidChildTypeError\";\n }\n}\n\nexport const bindChildrenToContainer = (parent: Pixi.Container, children?: JSX.Element): void => {\n const resolvedChildren = resolveChildren(() => children);\n\n const canAddChild = \"addChildAt\" in parent;\n\n if (!canAddChild) {\n throw new Error(\"Parent does not support children.\");\n }\n\n createRenderEffect(() => {\n const nextChildren = resolvedChildren.toArray().filter(Boolean) as unknown as Pixi.Container[];\n\n try {\n for (let i = 0; i < nextChildren.length; i += 1) {\n parent.addChildAt(nextChildren[i], i);\n }\n } catch (error) {\n if (error instanceof Error) {\n console.error(\"Invalid children\", nextChildren);\n throw new InvalidChildTypeError(error);\n } else {\n throw error;\n }\n }\n });\n};\n\nexport const bindChildrenToRenderLayer = (\n parent: Pixi.RenderLayer,\n children?: JSX.Element,\n): void => {\n const resolvedChildren = resolveChildren(() => children);\n\n createRenderEffect((prevChildren: Pixi.Container[] | undefined) => {\n const nextChildren = resolvedChildren.toArray().filter(Boolean) as unknown as Pixi.Container[];\n\n try {\n if (prevChildren) {\n for (let i = 0; i < prevChildren.length; i += 1) {\n const child = prevChildren[i];\n if (nextChildren.includes(child)) continue;\n\n parent.detach(child);\n }\n }\n\n for (let i = 0; i < nextChildren.length; i += 1) {\n parent.attach(nextChildren[i]);\n }\n } catch (error) {\n if (error instanceof Error) {\n console.error(\"Invalid children\", nextChildren);\n throw new InvalidChildTypeError(error);\n } else {\n throw error;\n }\n }\n\n return nextChildren;\n });\n};\n"],"mappings":";;AAIA,IAAa,wBAAb,cAA2C,MAAM;CAC/C,YAAY,OAAc;EACxB,MACE,oJACA,EAAE,OAAO,CACV;EACD,KAAK,OAAO;;;AAIhB,IAAa,2BAA2B,QAAwB,eAAiC;CAC/F,MAAM,mBAAmB,eAAsB,WAAS;CAIxD,IAAI,EAFgB,gBAAgB,SAGlC,MAAM,IAAI,MAAM,oCAAoC;CAGtD,yBAAyB;EACvB,MAAM,eAAe,iBAAiB,SAAS,CAAC,OAAO,QAAQ;EAE/D,IAAI;GACF,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,GAC5C,OAAO,WAAW,aAAa,IAAI,EAAE;WAEhC,OAAO;GACd,IAAI,iBAAiB,OAAO;IAC1B,QAAQ,MAAM,oBAAoB,aAAa;IAC/C,MAAM,IAAI,sBAAsB,MAAM;UAEtC,MAAM;;GAGV;;AAGJ,IAAa,6BACX,QACA,eACS;CACT,MAAM,mBAAmB,eAAsB,WAAS;CAExD,oBAAoB,iBAA+C;EACjE,MAAM,eAAe,iBAAiB,SAAS,CAAC,OAAO,QAAQ;EAE/D,IAAI;GACF,IAAI,cACF,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,GAAG;IAC/C,MAAM,QAAQ,aAAa;IAC3B,IAAI,aAAa,SAAS,MAAM,EAAE;IAElC,OAAO,OAAO,MAAM;;GAIxB,KAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,GAC5C,OAAO,OAAO,aAAa,GAAG;WAEzB,OAAO;GACd,IAAI,iBAAiB,OAAO;IAC1B,QAAQ,MAAM,oBAAoB,aAAa;IAC/C,MAAM,IAAI,sBAAsB,MAAM;UAEtC,MAAM;;EAIV,OAAO;GACP"}
@@ -12,6 +12,12 @@ import { createRenderEffect, on, onCleanup } from "solid-js";
12
12
  * @param props The props object.
13
13
  */
14
14
  var bindRuntimeProps = (instance, props) => {
15
+ /**
16
+ * Outer createRenderEffect runs when the props object itself changes.
17
+ * For example if a signal is spread into the props, the outer createRenderEffect will run whenever the signal changes because the props object will be a new reference.
18
+ *
19
+ * The inner createRenderEffects will then set the individual props on the instance and these effects only run if that specific property changes.
20
+ */
15
21
  createRenderEffect(() => {
16
22
  for (const key in props) {
17
23
  if (key === "as") continue;
@@ -1 +1 @@
1
- {"version":3,"file":"bind-props.js","names":[],"sources":["../../../src/components/bind-props/bind-props.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { createRenderEffect, onCleanup, on } from \"solid-js\";\n\nimport type { ContainerProps } from \"../component-factories\";\n\nimport { bindChildrenToContainer, bindChildrenToRenderLayer } from \"./bind-children\";\nimport { isEventProperty } from \"./is-event-property\";\nimport {\n isPointProperty,\n setPointProperty,\n isPointAxisProperty,\n setPointAxisProperty,\n} from \"./set-point-property\";\n\n/**\n * Binds the props to a Pixi instance with subscriptions to maintain reactivity.\n *\n * This is specifically for the runtime props that can't be set at initialisation. These props will be set on the Pixi instance immediately after it is created but before rendering.\n *\n * @param instance The Pixi instance we want to bind the props to.\n * @param props The props object.\n */\nexport const bindRuntimeProps = <\n InstanceType extends Pixi.Container,\n OptionsType extends ContainerProps<InstanceType>,\n>(\n instance: InstanceType,\n props: OptionsType,\n): void => {\n createRenderEffect(() => {\n for (const key in props) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n (props[key] as unknown as (arg: any) => void)(instance);\n\n continue;\n } else if (key === \"children\") {\n if (\"attach\" in instance && \"detach\" in instance) {\n bindChildrenToRenderLayer(instance as unknown as Pixi.RenderLayer, props.children);\n } else {\n bindChildrenToContainer(instance, props.children);\n }\n\n continue;\n }\n\n if (isPointProperty(key)) {\n createRenderEffect(() => setPointProperty(instance, key, props[key]));\n\n continue;\n }\n\n if (isPointAxisProperty(key)) {\n createRenderEffect(() => setPointAxisProperty(instance, key, props[key]));\n continue;\n }\n\n if (isEventProperty(key)) {\n createRenderEffect(() => {\n const eventName = key.slice(2);\n const eventHandler = props[key];\n\n if (eventHandler) {\n instance.on(eventName, eventHandler as any);\n onCleanup(() => {\n instance.off(eventName, eventHandler as any);\n });\n }\n });\n\n continue;\n }\n\n if (key in instance) {\n createRenderEffect(() => ((instance as any)[key] = props[key]));\n continue;\n }\n }\n });\n};\n\n/**\n * Binds the props to a Pixi instance with subscriptions to maintain reactivity.\n *\n * This is specifically for the initialisation props that can be set at the time of instance creation. These props will be passed into the Pixi class during instantiation but won't be set on the instance until they are changed again. This is to avoid side effects that can be caused by setting certain props after the instance is created, such as the AnimatedSprite's `textures` prop which stops the animation if it was already instantiated with `autoplay: true`.\n *\n * @param instance The Pixi instance we want to bind the props to.\n * @param props The props object.\n */\nexport const bindInitialisationProps = <\n InstanceType extends Pixi.Container,\n OptionsType extends ContainerProps<InstanceType>,\n>(\n instance: InstanceType,\n props: OptionsType,\n): void => {\n createRenderEffect<boolean>((defer) => {\n for (const key in props) {\n if (isPointProperty(key)) {\n createRenderEffect(\n on(\n () => props[key],\n () => {\n return setPointProperty(instance, key, props[key]);\n },\n { defer },\n ),\n );\n\n continue;\n }\n\n if (key in instance) {\n createRenderEffect(\n on(\n () => props[key],\n () => {\n (instance as any)[key] = props[key];\n },\n { defer },\n ),\n );\n }\n }\n\n return false;\n }, true);\n\n /**\n * Do not throw an error here for invalid prop names because there are some initialisation props that are not available as public properties. We want to allow users to pass these props but not try to set them on the instance.\n */\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,IAAa,oBAIX,UACA,UACS;AACT,0BAAyB;AACvB,OAAK,MAAM,OAAO,OAAO;AACvB,OAAI,QAAQ,KAAM;AAElB,OAAI,QAAQ,OAAO;AAChB,UAAM,KAAuC,SAAS;AAEvD;cACS,QAAQ,YAAY;AAC7B,QAAI,YAAY,YAAY,YAAY,SACtC,2BAA0B,UAAyC,MAAM,SAAS;QAElF,yBAAwB,UAAU,MAAM,SAAS;AAGnD;;AAGF,OAAI,gBAAgB,IAAI,EAAE;AACxB,6BAAyB,iBAAiB,UAAU,KAAK,MAAM,KAAK,CAAC;AAErE;;AAGF,OAAI,oBAAoB,IAAI,EAAE;AAC5B,6BAAyB,qBAAqB,UAAU,KAAK,MAAM,KAAK,CAAC;AACzE;;AAGF,OAAI,gBAAgB,IAAI,EAAE;AACxB,6BAAyB;KACvB,MAAM,YAAY,IAAI,MAAM,EAAE;KAC9B,MAAM,eAAe,MAAM;AAE3B,SAAI,cAAc;AAChB,eAAS,GAAG,WAAW,aAAoB;AAC3C,sBAAgB;AACd,gBAAS,IAAI,WAAW,aAAoB;QAC5C;;MAEJ;AAEF;;AAGF,OAAI,OAAO,UAAU;AACnB,6BAA0B,SAAkB,OAAO,MAAM,KAAM;AAC/D;;;GAGJ;;;;;;;;;;AAWJ,IAAa,2BAIX,UACA,UACS;AACT,qBAA6B,UAAU;AACrC,OAAK,MAAM,OAAO,OAAO;AACvB,OAAI,gBAAgB,IAAI,EAAE;AACxB,uBACE,SACQ,MAAM,YACN;AACJ,YAAO,iBAAiB,UAAU,KAAK,MAAM,KAAK;OAEpD,EAAE,OAAO,CACV,CACF;AAED;;AAGF,OAAI,OAAO,SACT,oBACE,SACQ,MAAM,YACN;AACH,aAAiB,OAAO,MAAM;MAEjC,EAAE,OAAO,CACV,CACF;;AAIL,SAAO;IACN,KAAK"}
1
+ {"version":3,"file":"bind-props.js","names":[],"sources":["../../../src/components/bind-props/bind-props.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { createRenderEffect, onCleanup, on } from \"solid-js\";\n\nimport type { ContainerProps } from \"../component-factories\";\n\nimport { bindChildrenToContainer, bindChildrenToRenderLayer } from \"./bind-children\";\nimport { isEventProperty } from \"./is-event-property\";\nimport {\n isPointProperty,\n setPointProperty,\n isPointAxisProperty,\n setPointAxisProperty,\n} from \"./set-point-property\";\n\n/**\n * Binds the props to a Pixi instance with subscriptions to maintain reactivity.\n *\n * This is specifically for the runtime props that can't be set at initialisation. These props will be set on the Pixi instance immediately after it is created but before rendering.\n *\n * @param instance The Pixi instance we want to bind the props to.\n * @param props The props object.\n */\nexport const bindRuntimeProps = <\n InstanceType extends Pixi.Container,\n OptionsType extends ContainerProps<InstanceType>,\n>(\n instance: InstanceType,\n props: OptionsType,\n): void => {\n /**\n * Outer createRenderEffect runs when the props object itself changes.\n * For example if a signal is spread into the props, the outer createRenderEffect will run whenever the signal changes because the props object will be a new reference.\n *\n * The inner createRenderEffects will then set the individual props on the instance and these effects only run if that specific property changes.\n */\n createRenderEffect(() => {\n for (const key in props) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n (props[key] as unknown as (arg: any) => void)(instance);\n\n continue;\n } else if (key === \"children\") {\n if (\"attach\" in instance && \"detach\" in instance) {\n bindChildrenToRenderLayer(instance as unknown as Pixi.RenderLayer, props.children);\n } else {\n bindChildrenToContainer(instance, props.children);\n }\n\n continue;\n }\n\n if (isPointProperty(key)) {\n createRenderEffect(() => setPointProperty(instance, key, props[key]));\n\n continue;\n }\n\n if (isPointAxisProperty(key)) {\n createRenderEffect(() => setPointAxisProperty(instance, key, props[key]));\n continue;\n }\n\n if (isEventProperty(key)) {\n createRenderEffect(() => {\n const eventName = key.slice(2);\n const eventHandler = props[key];\n\n if (eventHandler) {\n instance.on(eventName, eventHandler as any);\n onCleanup(() => {\n instance.off(eventName, eventHandler as any);\n });\n }\n });\n\n continue;\n }\n\n if (key in instance) {\n createRenderEffect(() => ((instance as any)[key] = props[key]));\n continue;\n }\n }\n });\n};\n\n/**\n * Binds the props to a Pixi instance with subscriptions to maintain reactivity.\n *\n * This is specifically for the initialisation props that can be set at the time of instance creation. These props will be passed into the Pixi class during instantiation but won't be set on the instance until they are changed again. This is to avoid side effects that can be caused by setting certain props after the instance is created, such as the AnimatedSprite's `textures` prop which stops the animation if it was already instantiated with `autoplay: true`.\n *\n * @param instance The Pixi instance we want to bind the props to.\n * @param props The props object.\n */\nexport const bindInitialisationProps = <\n InstanceType extends Pixi.Container,\n OptionsType extends ContainerProps<InstanceType>,\n>(\n instance: InstanceType,\n props: OptionsType,\n): void => {\n createRenderEffect<boolean>((defer) => {\n for (const key in props) {\n if (isPointProperty(key)) {\n createRenderEffect(\n on(\n () => props[key],\n () => {\n return setPointProperty(instance, key, props[key]);\n },\n { defer },\n ),\n );\n\n continue;\n }\n\n if (key in instance) {\n createRenderEffect(\n on(\n () => props[key],\n () => {\n (instance as any)[key] = props[key];\n },\n { defer },\n ),\n );\n }\n }\n\n return false;\n }, true);\n\n /**\n * Do not throw an error here for invalid prop names because there are some initialisation props that are not available as public properties. We want to allow users to pass these props but not try to set them on the instance.\n */\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,IAAa,oBAIX,UACA,UACS;;;;;;;CAOT,yBAAyB;EACvB,KAAK,MAAM,OAAO,OAAO;GACvB,IAAI,QAAQ,MAAM;GAElB,IAAI,QAAQ,OAAO;IACjB,MAAO,KAAuC,SAAS;IAEvD;UACK,IAAI,QAAQ,YAAY;IAC7B,IAAI,YAAY,YAAY,YAAY,UACtC,0BAA0B,UAAyC,MAAM,SAAS;SAElF,wBAAwB,UAAU,MAAM,SAAS;IAGnD;;GAGF,IAAI,gBAAgB,IAAI,EAAE;IACxB,yBAAyB,iBAAiB,UAAU,KAAK,MAAM,KAAK,CAAC;IAErE;;GAGF,IAAI,oBAAoB,IAAI,EAAE;IAC5B,yBAAyB,qBAAqB,UAAU,KAAK,MAAM,KAAK,CAAC;IACzE;;GAGF,IAAI,gBAAgB,IAAI,EAAE;IACxB,yBAAyB;KACvB,MAAM,YAAY,IAAI,MAAM,EAAE;KAC9B,MAAM,eAAe,MAAM;KAE3B,IAAI,cAAc;MAChB,SAAS,GAAG,WAAW,aAAoB;MAC3C,gBAAgB;OACd,SAAS,IAAI,WAAW,aAAoB;QAC5C;;MAEJ;IAEF;;GAGF,IAAI,OAAO,UAAU;IACnB,yBAA0B,SAAkB,OAAO,MAAM,KAAM;IAC/D;;;GAGJ;;;;;;;;;;AAWJ,IAAa,2BAIX,UACA,UACS;CACT,oBAA6B,UAAU;EACrC,KAAK,MAAM,OAAO,OAAO;GACvB,IAAI,gBAAgB,IAAI,EAAE;IACxB,mBACE,SACQ,MAAM,YACN;KACJ,OAAO,iBAAiB,UAAU,KAAK,MAAM,KAAK;OAEpD,EAAE,OAAO,CACV,CACF;IAED;;GAGF,IAAI,OAAO,UACT,mBACE,SACQ,MAAM,YACN;IACJ,SAAkB,OAAO,MAAM;MAEjC,EAAE,OAAO,CACV,CACF;;EAIL,OAAO;IACN,KAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"point-property-names.js","names":[],"sources":["../../../src/components/bind-props/point-property-names.ts"],"sourcesContent":["// Common point properties available on all Container-based components\nexport const COMMON_POINT_PROP_NAMES = [\"position\", \"scale\", \"pivot\", \"skew\"] as const;\n\nexport type CommonPointPropName = (typeof COMMON_POINT_PROP_NAMES)[number];\n\n// Anchor properties only available on Sprite-like components (Sprite, Text, etc.)\nexport const ANCHOR_POINT_PROP_NAMES = [\"anchor\"] as const;\n\nexport type AnchorPointPropName = (typeof ANCHOR_POINT_PROP_NAMES)[number];\n\n// Tiling properties only available on TilingSprite\nexport const TILING_POINT_PROP_NAMES = [\"tilePosition\", \"tileScale\"] as const;\n\nexport type TilingPointPropName = (typeof TILING_POINT_PROP_NAMES)[number];\n\n// All point properties (for runtime checking)\nexport const POINT_PROP_NAMES = [\n ...COMMON_POINT_PROP_NAMES,\n ...ANCHOR_POINT_PROP_NAMES,\n ...TILING_POINT_PROP_NAMES,\n] as const;\n\nexport type PointPropName = (typeof POINT_PROP_NAMES)[number];\n\nexport const POINT_PROP_NAMES_SET: Set<string> = new Set(POINT_PROP_NAMES);\n\n// Common axis properties available on all Container-based components\nexport const COMMON_POINT_PROP_AXIS_NAMES = [\n \"positionX\",\n \"positionY\",\n \"scaleX\",\n \"scaleY\",\n \"pivotX\",\n \"pivotY\",\n \"skewX\",\n \"skewY\",\n] as const;\n\nexport type CommonPointAxisPropName = (typeof COMMON_POINT_PROP_AXIS_NAMES)[number];\n\n// Anchor axis properties only available on Sprite-like components\nexport const ANCHOR_POINT_PROP_AXIS_NAMES = [\"anchorX\", \"anchorY\"] as const;\n\nexport type AnchorPointAxisPropName = (typeof ANCHOR_POINT_PROP_AXIS_NAMES)[number];\n\n// Tiling axis properties only available on TilingSprite\nexport const TILING_POINT_PROP_AXIS_NAMES = [\n \"tilePositionX\",\n \"tilePositionY\",\n \"tileScaleX\",\n \"tileScaleY\",\n] as const;\n\nexport type TilingPointAxisPropName = (typeof TILING_POINT_PROP_AXIS_NAMES)[number];\n\n// All axis properties (for runtime checking)\nexport const POINT_PROP_AXIS_NAMES = [\n ...COMMON_POINT_PROP_AXIS_NAMES,\n ...ANCHOR_POINT_PROP_AXIS_NAMES,\n ...TILING_POINT_PROP_AXIS_NAMES,\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\nexport const POINT_PROP_AXIS_MAP = POINT_PROP_AXIS_NAMES.reduce((map, name) => {\n const axisName = name[name.length - 1].toLowerCase() as \"x\" | \"y\";\n const propertyName = name.slice(0, -1);\n map.set(name, { propertyName, axisName });\n return map;\n}, new Map<string, { propertyName: string; axisName: \"x\" | \"y\" }>());\n"],"mappings":";AACA,IAAa,0BAA0B;CAAC;CAAY;CAAS;CAAS;CAAO;AAK7E,IAAa,0BAA0B,CAAC,SAAS;AAKjD,IAAa,0BAA0B,CAAC,gBAAgB,YAAY;AAKpE,IAAa,mBAAmB;CAC9B,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAID,IAAa,uBAAoC,IAAI,IAAI,iBAAiB;AAG1E,IAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAKD,IAAa,+BAA+B,CAAC,WAAW,UAAU;AAKlE,IAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACD;AAKD,IAAa,wBAAwB;CACnC,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAID,IAAa,4BAAyC,IAAI,IAAI,sBAAsB;AAE/B,IAAI,IAAI,CAC3D,GAAG,sBACH,GAAG,0BACJ,CAAC;AAEF,IAAa,sBAAsB,sBAAsB,QAAQ,KAAK,SAAS;CAC7E,MAAM,WAAW,KAAK,KAAK,SAAS,GAAG,aAAa;CACpD,MAAM,eAAe,KAAK,MAAM,GAAG,GAAG;AACtC,KAAI,IAAI,MAAM;EAAE;EAAc;EAAU,CAAC;AACzC,QAAO;mBACN,IAAI,KAA4D,CAAC"}
1
+ {"version":3,"file":"point-property-names.js","names":[],"sources":["../../../src/components/bind-props/point-property-names.ts"],"sourcesContent":["// Common point properties available on all Container-based components\nexport const COMMON_POINT_PROP_NAMES = [\"position\", \"scale\", \"pivot\", \"skew\"] as const;\n\nexport type CommonPointPropName = (typeof COMMON_POINT_PROP_NAMES)[number];\n\n// Anchor properties only available on Sprite-like components (Sprite, Text, etc.)\nexport const ANCHOR_POINT_PROP_NAMES = [\"anchor\"] as const;\n\nexport type AnchorPointPropName = (typeof ANCHOR_POINT_PROP_NAMES)[number];\n\n// Tiling properties only available on TilingSprite\nexport const TILING_POINT_PROP_NAMES = [\"tilePosition\", \"tileScale\"] as const;\n\nexport type TilingPointPropName = (typeof TILING_POINT_PROP_NAMES)[number];\n\n// All point properties (for runtime checking)\nexport const POINT_PROP_NAMES = [\n ...COMMON_POINT_PROP_NAMES,\n ...ANCHOR_POINT_PROP_NAMES,\n ...TILING_POINT_PROP_NAMES,\n] as const;\n\nexport type PointPropName = (typeof POINT_PROP_NAMES)[number];\n\nexport const POINT_PROP_NAMES_SET: Set<string> = new Set(POINT_PROP_NAMES);\n\n// Common axis properties available on all Container-based components\nexport const COMMON_POINT_PROP_AXIS_NAMES = [\n \"positionX\",\n \"positionY\",\n \"scaleX\",\n \"scaleY\",\n \"pivotX\",\n \"pivotY\",\n \"skewX\",\n \"skewY\",\n] as const;\n\nexport type CommonPointAxisPropName = (typeof COMMON_POINT_PROP_AXIS_NAMES)[number];\n\n// Anchor axis properties only available on Sprite-like components\nexport const ANCHOR_POINT_PROP_AXIS_NAMES = [\"anchorX\", \"anchorY\"] as const;\n\nexport type AnchorPointAxisPropName = (typeof ANCHOR_POINT_PROP_AXIS_NAMES)[number];\n\n// Tiling axis properties only available on TilingSprite\nexport const TILING_POINT_PROP_AXIS_NAMES = [\n \"tilePositionX\",\n \"tilePositionY\",\n \"tileScaleX\",\n \"tileScaleY\",\n] as const;\n\nexport type TilingPointAxisPropName = (typeof TILING_POINT_PROP_AXIS_NAMES)[number];\n\n// All axis properties (for runtime checking)\nexport const POINT_PROP_AXIS_NAMES = [\n ...COMMON_POINT_PROP_AXIS_NAMES,\n ...ANCHOR_POINT_PROP_AXIS_NAMES,\n ...TILING_POINT_PROP_AXIS_NAMES,\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\nexport const POINT_PROP_AXIS_MAP = POINT_PROP_AXIS_NAMES.reduce((map, name) => {\n const axisName = name[name.length - 1].toLowerCase() as \"x\" | \"y\";\n const propertyName = name.slice(0, -1);\n map.set(name, { propertyName, axisName });\n return map;\n}, new Map<string, { propertyName: string; axisName: \"x\" | \"y\" }>());\n"],"mappings":";AACA,IAAa,0BAA0B;CAAC;CAAY;CAAS;CAAS;CAAO;AAK7E,IAAa,0BAA0B,CAAC,SAAS;AAKjD,IAAa,0BAA0B,CAAC,gBAAgB,YAAY;AAKpE,IAAa,mBAAmB;CAC9B,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAID,IAAa,uBAAoC,IAAI,IAAI,iBAAiB;AAG1E,IAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAKD,IAAa,+BAA+B,CAAC,WAAW,UAAU;AAKlE,IAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACD;AAKD,IAAa,wBAAwB;CACnC,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAID,IAAa,4BAAyC,IAAI,IAAI,sBAAsB;AAE/B,IAAI,IAAI,CAC3D,GAAG,sBACH,GAAG,0BACJ,CAAC;AAEF,IAAa,sBAAsB,sBAAsB,QAAQ,KAAK,SAAS;CAC7E,MAAM,WAAW,KAAK,KAAK,SAAS,GAAG,aAAa;CACpD,MAAM,eAAe,KAAK,MAAM,GAAG,GAAG;CACtC,IAAI,IAAI,MAAM;EAAE;EAAc;EAAU,CAAC;CACzC,OAAO;mBACN,IAAI,KAA4D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"set-point-property.js","names":[],"sources":["../../../src/components/bind-props/set-point-property.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\n\nimport {\n POINT_PROP_NAMES_SET,\n POINT_PROP_AXIS_MAP,\n POINT_PROP_AXIS_NAMES_SET,\n} from \"./point-property-names\";\nimport type { PointAxisPropName, PointPropName } from \"./point-property-names\";\n\nexport const isPointProperty = (propName: string): propName is PointPropName =>\n POINT_PROP_NAMES_SET.has(propName);\n\nexport const setPointProperty = <T>(node: Pixi.Container, name: PointPropName, value: T): void => {\n if (typeof value === \"number\") {\n (node as any)[name].set(value);\n return;\n }\n\n (node as any)[name].set((value as any).x, (value as any).y);\n};\n\nexport const isPointAxisProperty = (propName: string): propName is PointAxisPropName =>\n POINT_PROP_AXIS_NAMES_SET.has(propName);\n\nexport const setPointAxisProperty = <T>(\n node: Pixi.Container,\n name: PointAxisPropName,\n value: T,\n): void => {\n const axisInfo = POINT_PROP_AXIS_MAP.get(name);\n if (axisInfo) {\n (node as any)[axisInfo.propertyName][axisInfo.axisName] = value;\n }\n};\n"],"mappings":";;AASA,IAAa,mBAAmB,aAC9B,qBAAqB,IAAI,SAAS;AAEpC,IAAa,oBAAuB,MAAsB,MAAqB,UAAmB;AAChG,KAAI,OAAO,UAAU,UAAU;AAC5B,OAAa,MAAM,IAAI,MAAM;AAC9B;;AAGD,MAAa,MAAM,IAAK,MAAc,GAAI,MAAc,EAAE;;AAG7D,IAAa,uBAAuB,aAClC,0BAA0B,IAAI,SAAS;AAEzC,IAAa,wBACX,MACA,MACA,UACS;CACT,MAAM,WAAW,oBAAoB,IAAI,KAAK;AAC9C,KAAI,SACD,MAAa,SAAS,cAAc,SAAS,YAAY"}
1
+ {"version":3,"file":"set-point-property.js","names":[],"sources":["../../../src/components/bind-props/set-point-property.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\n\nimport {\n POINT_PROP_NAMES_SET,\n POINT_PROP_AXIS_MAP,\n POINT_PROP_AXIS_NAMES_SET,\n} from \"./point-property-names\";\nimport type { PointAxisPropName, PointPropName } from \"./point-property-names\";\n\nexport const isPointProperty = (propName: string): propName is PointPropName =>\n POINT_PROP_NAMES_SET.has(propName);\n\nexport const setPointProperty = <T>(node: Pixi.Container, name: PointPropName, value: T): void => {\n if (typeof value === \"number\") {\n (node as any)[name].set(value);\n return;\n }\n\n (node as any)[name].set((value as any).x, (value as any).y);\n};\n\nexport const isPointAxisProperty = (propName: string): propName is PointAxisPropName =>\n POINT_PROP_AXIS_NAMES_SET.has(propName);\n\nexport const setPointAxisProperty = <T>(\n node: Pixi.Container,\n name: PointAxisPropName,\n value: T,\n): void => {\n const axisInfo = POINT_PROP_AXIS_MAP.get(name);\n if (axisInfo) {\n (node as any)[axisInfo.propertyName][axisInfo.axisName] = value;\n }\n};\n"],"mappings":";;AASA,IAAa,mBAAmB,aAC9B,qBAAqB,IAAI,SAAS;AAEpC,IAAa,oBAAuB,MAAsB,MAAqB,UAAmB;CAChG,IAAI,OAAO,UAAU,UAAU;EAC7B,KAAc,MAAM,IAAI,MAAM;EAC9B;;CAGF,KAAc,MAAM,IAAK,MAAc,GAAI,MAAc,EAAE;;AAG7D,IAAa,uBAAuB,aAClC,0BAA0B,IAAI,SAAS;AAEzC,IAAa,wBACX,MACA,MACA,UACS;CACT,MAAM,WAAW,oBAAoB,IAAI,KAAK;CAC9C,IAAI,UACF,KAAc,SAAS,cAAc,SAAS,YAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"component-factories.js","names":[],"sources":["../../src/components/component-factories.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { createRenderEffect, on, splitProps, onCleanup } from \"solid-js\";\n\nimport { getTicker } from \"../pixi-application\";\n\nimport { bindInitialisationProps, bindRuntimeProps } from \"./bind-props\";\nimport type { PixiSolidEventHandlerMap } from \"./bind-props/event-names\";\nimport { PIXI_SOLID_EVENT_HANDLER_NAMES } from \"./bind-props/event-names\";\nimport type {\n CommonPointAxisPropName,\n AnchorPointAxisPropName,\n TilingPointAxisPropName,\n} from \"./bind-props/point-property-names\";\nimport {\n COMMON_POINT_PROP_AXIS_NAMES,\n ANCHOR_POINT_PROP_AXIS_NAMES,\n TILING_POINT_PROP_AXIS_NAMES,\n} from \"./bind-props/point-property-names\";\n\n/**\n * Common point axis properties available on all Container-based components\n */\nexport type CommonPointAxisProps = Partial<Record<CommonPointAxisPropName, number>>;\n\n/**\n * Anchor point axis properties available on Sprite-like components\n */\nexport type AnchorPointAxisProps = Partial<Record<AnchorPointAxisPropName, number>>;\n\n/**\n * Tiling point axis properties available on TilingSprite\n */\nexport type TilingPointAxisProps = Partial<Record<TilingPointAxisPropName, number>>;\n\n/**\n * This is a utility type useful for extending the props of custom components to allow props to be passed through to the underlying Pixi instance.\n *\n * If you don't require them all it's recommended to narrow the type by using Pick or Omit the props to only allow the ones you need.\n *\n * @example PixiComponentProps<Pixi.SpriteOptions>.\n */\nexport type PixiComponentProps<\n ComponentOptions extends Pixi.ContainerOptions = Pixi.ContainerOptions,\n> = PixiSolidEventHandlerMap & CommonPointAxisProps & Omit<ComponentOptions, \"children\">;\n\ntype RefAsProps<Component> = {\n ref?: Ref<Component>;\n as?: Component;\n};\n\ntype PixiComponent<Props, Instance> = (props: Props) => Instance & JSX.Element;\n\n/**\n * Prop definition for basic Container components (position, scale, pivot, skew only)\n */\nexport type ContainerProps<Component> = PixiSolidEventHandlerMap &\n CommonPointAxisProps &\n RefAsProps<Component> & {\n children?: JSX.Element;\n };\n\n/**\n * Prop definition for components that cannot have children\n */\nexport type LeafProps<Component> = PixiSolidEventHandlerMap &\n CommonPointAxisProps &\n RefAsProps<Component>;\n\n/**\n * Prop definition for Sprite-like components (includes anchor properties)\n */\nexport type SpriteProps<Component> = PixiSolidEventHandlerMap &\n CommonPointAxisProps &\n AnchorPointAxisProps &\n RefAsProps<Component>;\n\nexport type AnimatedSpriteProps<Component> = SpriteProps<Component> &\n Pick<Pixi.AnimatedSpriteOptions, \"autoUpdate\">;\n\ntype AnimatedSpriteLike = Pixi.Container & {\n autoUpdate: boolean;\n update: (ticker: Pixi.Ticker) => void;\n};\n\n/**\n * Prop definition for TilingSprite (includes anchor and tiling properties)\n */\nexport type TilingSpriteProps<Component> = PixiSolidEventHandlerMap &\n CommonPointAxisProps &\n AnchorPointAxisProps &\n TilingPointAxisProps &\n RefAsProps<Component>;\n\n/**\n * Prop definition for filter components\n */\nexport type FilterProps<Component> = RefAsProps<Component>;\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// Combined keys for splitting props\nconst CONTAINER_RUNTIME_KEYS = [\n ...SOLID_PROP_KEYS,\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ...COMMON_POINT_PROP_AXIS_NAMES,\n] as const;\n\n// Sprite components don't accept \"children\" since they can't have children\nconst SPRITE_RUNTIME_KEYS = [\n \"ref\",\n \"as\",\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ...COMMON_POINT_PROP_AXIS_NAMES,\n ...ANCHOR_POINT_PROP_AXIS_NAMES,\n] as const;\n\nconst TILING_SPRITE_RUNTIME_KEYS = [\n \"ref\",\n \"as\",\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ...COMMON_POINT_PROP_AXIS_NAMES,\n ...ANCHOR_POINT_PROP_AXIS_NAMES,\n ...TILING_POINT_PROP_AXIS_NAMES,\n] as const;\n\nexport const createContainerComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<Omit<OptionsType, \"children\"> & ContainerProps<InstanceType>, InstanceType> => {\n return (props): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, CONTAINER_RUNTIME_KEYS);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n bindInitialisationProps(instance, initialisationProps);\n bindRuntimeProps(instance, runtimeProps);\n\n onCleanup(() => {\n if (\"attach\" in instance) {\n // Means it's a render layer so we don't want to destroy children as they are managed elsewhere in the tree.\n instance.destroy({ children: false });\n } else {\n instance.destroy({ children: true });\n }\n });\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): PixiComponent<Omit<OptionsType, \"children\"> & LeafProps<InstanceType>, InstanceType> => {\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 createSpriteComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<Omit<OptionsType, \"children\"> & SpriteProps<InstanceType>, InstanceType> => {\n return (\n props: Omit<OptionsType, \"children\"> & SpriteProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, SPRITE_RUNTIME_KEYS);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n bindInitialisationProps(instance, initialisationProps);\n bindRuntimeProps(instance, runtimeProps);\n\n onCleanup(() => {\n instance.destroy({ children: true });\n });\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createAnimatedSpriteComponent = <\n InstanceType extends AnimatedSpriteLike,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<\n Omit<OptionsType, \"children\"> & AnimatedSpriteProps<InstanceType>,\n InstanceType\n> => {\n return (\n props: Omit<OptionsType, \"children\"> & AnimatedSpriteProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n // Specifically separate `autoUpdate` as we handle it manually below.\n const [runtimeProps, update, initialisationProps] = splitProps(props, SPRITE_RUNTIME_KEYS, [\n \"autoUpdate\",\n ]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n // Set this to false to override Pixi's default shared ticker behaviour.\n instance.autoUpdate = false;\n\n createRenderEffect(\n on(\n () => update.autoUpdate,\n (autoUpdate) => {\n const updateInstance = (ticker: Pixi.Ticker) => {\n instance.update(ticker);\n };\n\n if (autoUpdate !== false) {\n const ticker = getTicker();\n ticker.add(updateInstance);\n onCleanup(() => {\n ticker.remove(updateInstance);\n });\n }\n },\n ),\n );\n\n bindInitialisationProps(instance, initialisationProps);\n bindRuntimeProps(instance, runtimeProps);\n\n onCleanup(() => {\n instance.destroy({ children: true });\n });\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createTilingSpriteComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<Omit<OptionsType, \"children\"> & TilingSpriteProps<InstanceType>, InstanceType> => {\n return (\n props: Omit<OptionsType, \"children\"> & TilingSpriteProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, TILING_SPRITE_RUNTIME_KEYS);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n bindInitialisationProps(instance, initialisationProps);\n bindRuntimeProps(instance, runtimeProps);\n\n onCleanup(() => {\n instance.destroy({ children: true });\n });\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createFilterComponent = <InstanceType extends Pixi.Filter, OptionsType extends object>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<OptionsType & FilterProps<InstanceType>, InstanceType> => {\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 onCleanup(() => {\n instance.destroy();\n });\n\n return instance as InstanceType & JSX.Element;\n };\n};\n"],"mappings":";;;;;AAuGA,IAAM,yBAAyB;CAC7B,GAAG;EAJ2B;EAAO;EAAM;EAIxC;CACH,GAAG;CACH,GAAG;CACJ;AAGD,IAAM,sBAAsB;CAC1B;CACA;CACA,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,IAAM,6BAA6B;CACjC;CACA;CACA,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,IAAa,4BAIX,cAC8F;AAC9F,SAAQ,UAAsC;EAC5C,MAAM,CAAC,cAAc,uBAAuB,WAAW,OAAO,uBAAuB;EAErF,MAAM,WAAW,MAAM,MAAM,IAAI,UAAU,oBAA2B;AAEtE,0BAAwB,UAAU,oBAAoB;AACtD,mBAAiB,UAAU,aAAa;AAExC,kBAAgB;AACd,OAAI,YAAY,SAEd,UAAS,QAAQ,EAAE,UAAU,OAAO,CAAC;OAErC,UAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;IAEtC;AAEF,SAAO;;;AAIX,IAAa,uBAIX,cACyF;AACzF,SACE,UAC+B;AAC/B,SAAO,yBAAoD,UAAU,CAAC,MAAM;;;AAIhF,IAAa,yBAIX,cAC2F;AAC3F,SACE,UAC+B;EAC/B,MAAM,CAAC,cAAc,uBAAuB,WAAW,OAAO,oBAAoB;EAElF,MAAM,WAAW,MAAM,MAAM,IAAI,UAAU,oBAA2B;AAEtE,0BAAwB,UAAU,oBAAoB;AACtD,mBAAiB,UAAU,aAAa;AAExC,kBAAgB;AACd,YAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;IACpC;AAEF,SAAO;;;AAIX,IAAa,iCAIX,cAIG;AACH,SACE,UAC+B;EAE/B,MAAM,CAAC,cAAc,QAAQ,uBAAuB,WAAW,OAAO,qBAAqB,CACzF,aACD,CAAC;EAEF,MAAM,WAAW,MAAM,MAAM,IAAI,UAAU,oBAA2B;AAGtE,WAAS,aAAa;AAEtB,qBACE,SACQ,OAAO,aACZ,eAAe;GACd,MAAM,kBAAkB,WAAwB;AAC9C,aAAS,OAAO,OAAO;;AAGzB,OAAI,eAAe,OAAO;IACxB,MAAM,SAAS,WAAW;AAC1B,WAAO,IAAI,eAAe;AAC1B,oBAAgB;AACd,YAAO,OAAO,eAAe;MAC7B;;IAGP,CACF;AAED,0BAAwB,UAAU,oBAAoB;AACtD,mBAAiB,UAAU,aAAa;AAExC,kBAAgB;AACd,YAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;IACpC;AAEF,SAAO;;;AAIX,IAAa,+BAIX,cACiG;AACjG,SACE,UAC+B;EAC/B,MAAM,CAAC,cAAc,uBAAuB,WAAW,OAAO,2BAA2B;EAEzF,MAAM,WAAW,MAAM,MAAM,IAAI,UAAU,oBAA2B;AAEtE,0BAAwB,UAAU,oBAAoB;AACtD,mBAAiB,UAAU,aAAa;AAExC,kBAAgB;AACd,YAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;IACpC;AAEF,SAAO"}
1
+ {"version":3,"file":"component-factories.js","names":[],"sources":["../../src/components/component-factories.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { createRenderEffect, on, splitProps, onCleanup } from \"solid-js\";\n\nimport { getTicker } from \"../pixi-application\";\n\nimport { bindInitialisationProps, bindRuntimeProps } from \"./bind-props\";\nimport type { PixiSolidEventHandlerMap } from \"./bind-props/event-names\";\nimport { PIXI_SOLID_EVENT_HANDLER_NAMES } from \"./bind-props/event-names\";\nimport type {\n CommonPointAxisPropName,\n AnchorPointAxisPropName,\n TilingPointAxisPropName,\n} from \"./bind-props/point-property-names\";\nimport {\n COMMON_POINT_PROP_AXIS_NAMES,\n ANCHOR_POINT_PROP_AXIS_NAMES,\n TILING_POINT_PROP_AXIS_NAMES,\n} from \"./bind-props/point-property-names\";\n\n/**\n * Common point axis properties available on all Container-based components\n */\nexport type CommonPointAxisProps = Partial<Record<CommonPointAxisPropName, number>>;\n\n/**\n * Anchor point axis properties available on Sprite-like components\n */\nexport type AnchorPointAxisProps = Partial<Record<AnchorPointAxisPropName, number>>;\n\n/**\n * Tiling point axis properties available on TilingSprite\n */\nexport type TilingPointAxisProps = Partial<Record<TilingPointAxisPropName, number>>;\n\n/**\n * This is a utility type useful for extending the props of custom components to allow props to be passed through to the underlying Pixi instance.\n *\n * If you don't require them all it's recommended to narrow the type by using Pick or Omit the props to only allow the ones you need.\n *\n * @example PixiComponentProps<Pixi.SpriteOptions>.\n */\nexport type PixiComponentProps<\n ComponentOptions extends Pixi.ContainerOptions = Pixi.ContainerOptions,\n> = PixiSolidEventHandlerMap & CommonPointAxisProps & Omit<ComponentOptions, \"children\">;\n\ntype RefAsProps<Component> = {\n ref?: Ref<Component>;\n as?: Component;\n};\n\ntype PixiComponent<Props, Instance> = (props: Props) => Instance & JSX.Element;\n\n/**\n * Prop definition for basic Container components (position, scale, pivot, skew only)\n */\nexport type ContainerProps<Component> = PixiSolidEventHandlerMap &\n CommonPointAxisProps &\n RefAsProps<Component> & {\n children?: JSX.Element;\n };\n\n/**\n * Prop definition for components that cannot have children\n */\nexport type LeafProps<Component> = PixiSolidEventHandlerMap &\n CommonPointAxisProps &\n RefAsProps<Component>;\n\n/**\n * Prop definition for Sprite-like components (includes anchor properties)\n */\nexport type SpriteProps<Component> = PixiSolidEventHandlerMap &\n CommonPointAxisProps &\n AnchorPointAxisProps &\n RefAsProps<Component>;\n\nexport type AnimatedSpriteProps<Component> = SpriteProps<Component> &\n Pick<Pixi.AnimatedSpriteOptions, \"autoUpdate\">;\n\ntype AnimatedSpriteLike = Pixi.Container & {\n autoUpdate: boolean;\n update: (ticker: Pixi.Ticker) => void;\n};\n\n/**\n * Prop definition for TilingSprite (includes anchor and tiling properties)\n */\nexport type TilingSpriteProps<Component> = PixiSolidEventHandlerMap &\n CommonPointAxisProps &\n AnchorPointAxisProps &\n TilingPointAxisProps &\n RefAsProps<Component>;\n\n/**\n * Prop definition for filter components\n */\nexport type FilterProps<Component> = RefAsProps<Component>;\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// Combined keys for splitting props\nconst CONTAINER_RUNTIME_KEYS = [\n ...SOLID_PROP_KEYS,\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ...COMMON_POINT_PROP_AXIS_NAMES,\n] as const;\n\n// Sprite components don't accept \"children\" since they can't have children\nconst SPRITE_RUNTIME_KEYS = [\n \"ref\",\n \"as\",\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ...COMMON_POINT_PROP_AXIS_NAMES,\n ...ANCHOR_POINT_PROP_AXIS_NAMES,\n] as const;\n\nconst TILING_SPRITE_RUNTIME_KEYS = [\n \"ref\",\n \"as\",\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ...COMMON_POINT_PROP_AXIS_NAMES,\n ...ANCHOR_POINT_PROP_AXIS_NAMES,\n ...TILING_POINT_PROP_AXIS_NAMES,\n] as const;\n\nexport const createContainerComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<Omit<OptionsType, \"children\"> & ContainerProps<InstanceType>, InstanceType> => {\n return (props): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, CONTAINER_RUNTIME_KEYS);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n bindInitialisationProps(instance, initialisationProps);\n bindRuntimeProps(instance, runtimeProps);\n\n onCleanup(() => {\n if (\"attach\" in instance) {\n // Means it's a render layer so we don't want to destroy children as they are managed elsewhere in the tree.\n instance.destroy({ children: false });\n } else {\n instance.destroy({ children: true });\n }\n });\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): PixiComponent<Omit<OptionsType, \"children\"> & LeafProps<InstanceType>, InstanceType> => {\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 createSpriteComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<Omit<OptionsType, \"children\"> & SpriteProps<InstanceType>, InstanceType> => {\n return (\n props: Omit<OptionsType, \"children\"> & SpriteProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, SPRITE_RUNTIME_KEYS);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n bindInitialisationProps(instance, initialisationProps);\n bindRuntimeProps(instance, runtimeProps);\n\n onCleanup(() => {\n instance.destroy({ children: true });\n });\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createAnimatedSpriteComponent = <\n InstanceType extends AnimatedSpriteLike,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<\n Omit<OptionsType, \"children\"> & AnimatedSpriteProps<InstanceType>,\n InstanceType\n> => {\n return (\n props: Omit<OptionsType, \"children\"> & AnimatedSpriteProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n // Specifically separate `autoUpdate` as we handle it manually below.\n const [runtimeProps, update, initialisationProps] = splitProps(props, SPRITE_RUNTIME_KEYS, [\n \"autoUpdate\",\n ]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n // Set this to false to override Pixi's default shared ticker behaviour.\n instance.autoUpdate = false;\n\n createRenderEffect(\n on(\n () => update.autoUpdate,\n (autoUpdate) => {\n const updateInstance = (ticker: Pixi.Ticker) => {\n instance.update(ticker);\n };\n\n if (autoUpdate !== false) {\n const ticker = getTicker();\n ticker.add(updateInstance);\n onCleanup(() => {\n ticker.remove(updateInstance);\n });\n }\n },\n ),\n );\n\n bindInitialisationProps(instance, initialisationProps);\n bindRuntimeProps(instance, runtimeProps);\n\n onCleanup(() => {\n instance.destroy({ children: true });\n });\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createTilingSpriteComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<Omit<OptionsType, \"children\"> & TilingSpriteProps<InstanceType>, InstanceType> => {\n return (\n props: Omit<OptionsType, \"children\"> & TilingSpriteProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, TILING_SPRITE_RUNTIME_KEYS);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n bindInitialisationProps(instance, initialisationProps);\n bindRuntimeProps(instance, runtimeProps);\n\n onCleanup(() => {\n instance.destroy({ children: true });\n });\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createFilterComponent = <InstanceType extends Pixi.Filter, OptionsType extends object>(\n PixiClass: new (props: OptionsType) => InstanceType,\n): PixiComponent<OptionsType & FilterProps<InstanceType>, InstanceType> => {\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 onCleanup(() => {\n instance.destroy();\n });\n\n return instance as InstanceType & JSX.Element;\n };\n};\n"],"mappings":";;;;;AAuGA,IAAM,yBAAyB;CAC7B,GAAG;EAJ2B;EAAO;EAAM;EAIxC;CACH,GAAG;CACH,GAAG;CACJ;AAGD,IAAM,sBAAsB;CAC1B;CACA;CACA,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,IAAM,6BAA6B;CACjC;CACA;CACA,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACJ;AAED,IAAa,4BAIX,cAC8F;CAC9F,QAAQ,UAAsC;EAC5C,MAAM,CAAC,cAAc,uBAAuB,WAAW,OAAO,uBAAuB;EAErF,MAAM,WAAW,MAAM,MAAM,IAAI,UAAU,oBAA2B;EAEtE,wBAAwB,UAAU,oBAAoB;EACtD,iBAAiB,UAAU,aAAa;EAExC,gBAAgB;GACd,IAAI,YAAY,UAEd,SAAS,QAAQ,EAAE,UAAU,OAAO,CAAC;QAErC,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;IAEtC;EAEF,OAAO;;;AAIX,IAAa,uBAIX,cACyF;CACzF,QACE,UAC+B;EAC/B,OAAO,yBAAoD,UAAU,CAAC,MAAM;;;AAIhF,IAAa,yBAIX,cAC2F;CAC3F,QACE,UAC+B;EAC/B,MAAM,CAAC,cAAc,uBAAuB,WAAW,OAAO,oBAAoB;EAElF,MAAM,WAAW,MAAM,MAAM,IAAI,UAAU,oBAA2B;EAEtE,wBAAwB,UAAU,oBAAoB;EACtD,iBAAiB,UAAU,aAAa;EAExC,gBAAgB;GACd,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;IACpC;EAEF,OAAO;;;AAIX,IAAa,iCAIX,cAIG;CACH,QACE,UAC+B;EAE/B,MAAM,CAAC,cAAc,QAAQ,uBAAuB,WAAW,OAAO,qBAAqB,CACzF,aACD,CAAC;EAEF,MAAM,WAAW,MAAM,MAAM,IAAI,UAAU,oBAA2B;EAGtE,SAAS,aAAa;EAEtB,mBACE,SACQ,OAAO,aACZ,eAAe;GACd,MAAM,kBAAkB,WAAwB;IAC9C,SAAS,OAAO,OAAO;;GAGzB,IAAI,eAAe,OAAO;IACxB,MAAM,SAAS,WAAW;IAC1B,OAAO,IAAI,eAAe;IAC1B,gBAAgB;KACd,OAAO,OAAO,eAAe;MAC7B;;IAGP,CACF;EAED,wBAAwB,UAAU,oBAAoB;EACtD,iBAAiB,UAAU,aAAa;EAExC,gBAAgB;GACd,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;IACpC;EAEF,OAAO;;;AAIX,IAAa,+BAIX,cACiG;CACjG,QACE,UAC+B;EAC/B,MAAM,CAAC,cAAc,uBAAuB,WAAW,OAAO,2BAA2B;EAEzF,MAAM,WAAW,MAAM,MAAM,IAAI,UAAU,oBAA2B;EAEtE,wBAAwB,UAAU,oBAAoB;EACtD,iBAAiB,UAAU,aAAa;EAExC,gBAAgB;GACd,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC;IACpC;EAEF,OAAO"}
@@ -2,8 +2,7 @@ export type { AnimatedSpriteProps, ContainerProps, LeafProps, SpriteProps, Tilin
2
2
  export { onResize } from "./on-resize";
3
3
  export { onTick } from "./on-tick";
4
4
  export type { PixiApplicationProps } from "./pixi-application";
5
- export { getPixiApp, getTicker, PixiApplicationProvider, TickerProvider } from "./pixi-application";
6
- export { createAsyncDelay, delay } from "./delay";
5
+ export { getPixiApp, getTicker, getRenderer, PixiApplicationProvider, TickerProvider, } from "./pixi-application";
7
6
  export type { PixiCanvasProps } from "./pixi-canvas";
8
7
  export { PixiCanvas } from "./pixi-canvas";
9
8
  export { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, NineSliceSprite, ParticleContainer, PerspectiveMesh, RenderContainer, RenderLayer, Sprite, Text, TilingSprite, } from "./components";
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { getPixiApp } from "./pixi-application/get-pixi-app.js";
2
2
  import { getTicker } from "./pixi-application/get-ticker.js";
3
3
  import { PixiApplicationProvider, TickerProvider } from "./pixi-application/pixi-application-provider.js";
4
+ import { getRenderer } from "./pixi-application/get-renderer.js";
4
5
  import { onResize } from "./on-resize.js";
5
6
  import { onTick } from "./on-tick.js";
6
- import { createAsyncDelay, delay } from "./delay.js";
7
7
  import { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, NineSliceSprite, ParticleContainer, PerspectiveMesh, RenderContainer, RenderLayer, Sprite, Text, TilingSprite } from "./components/components.js";
8
8
  import { PixiCanvas } from "./pixi-canvas.js";
9
9
  import { usePixiScreen } from "./use-pixi-screen/use-pixi-screen.js";
10
- export { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, NineSliceSprite, ParticleContainer, PerspectiveMesh, PixiApplicationProvider, PixiCanvas, RenderContainer, RenderLayer, Sprite, Text, TickerProvider, TilingSprite, createAsyncDelay, delay, getPixiApp, getTicker, onResize, onTick, usePixiScreen };
10
+ export { AnimatedSprite, BitmapText, Container, Graphics, HTMLText, MeshPlane, MeshRope, NineSliceSprite, ParticleContainer, PerspectiveMesh, PixiApplicationProvider, PixiCanvas, RenderContainer, RenderLayer, Sprite, Text, TickerProvider, TilingSprite, getPixiApp, getRenderer, getTicker, onResize, onTick, usePixiScreen };
@@ -1 +1 @@
1
- {"version":3,"file":"on-resize.js","names":[],"sources":["../src/on-resize.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { onCleanup } from \"solid-js\";\n\nimport { getPixiApp } from \"./pixi-application\";\n\n/**\n *\n * A SolidJS hook that runs a callback function whenever the PixiJS renderer is resized.\n * The callback is automatically removed when the component or hook's owning computation is cleaned up.\n *\n * This hook must be called from a component that is a descendant of `PixiCanvas` or `PixiApplicationProvider`.\n *\n * @param resizeCallback - A callback function that receives the updated screen dimensions as a `Pixi.Rectangle` object. This function will be called immediately upon hook initialization and then on every subsequent resize event.\n *\n * We listen for the renderer's \"resize\" event so this hook will work correctly whether the window is resized or just the DOM element the PixiCanvas is inside of changes size.\n */\nexport const onResize = (resizeCallback: (screen: Pixi.Rectangle) => void): void => {\n let pixiApp: Pixi.Application;\n\n try {\n pixiApp = getPixiApp();\n } catch {\n throw new Error(\"onResize must be used within a PixiApplicationProvider or a PixiCanvas\");\n }\n\n // Ensure initial callback happens during setup.\n resizeCallback(pixiApp.renderer.screen);\n\n const handleResize = () => {\n // Keep onResize event-driven (fires for every renderer resize event), but schedule the\n // callback after the current emit cycle so usePixiScreen listeners have already synchronized\n // their reactive values. This avoids stale reads when both hooks are used together.\n queueMicrotask(() => {\n resizeCallback(pixiApp.renderer.screen);\n });\n };\n\n pixiApp.renderer.addListener(\"resize\", handleResize);\n\n onCleanup(() => {\n pixiApp.renderer.removeListener(\"resize\", handleResize);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAa,YAAY,mBAA2D;CAClF,IAAI;AAEJ,KAAI;AACF,YAAU,YAAY;SAChB;AACN,QAAM,IAAI,MAAM,yEAAyE;;AAI3F,gBAAe,QAAQ,SAAS,OAAO;CAEvC,MAAM,qBAAqB;AAIzB,uBAAqB;AACnB,kBAAe,QAAQ,SAAS,OAAO;IACvC;;AAGJ,SAAQ,SAAS,YAAY,UAAU,aAAa;AAEpD,iBAAgB;AACd,UAAQ,SAAS,eAAe,UAAU,aAAa;GACvD"}
1
+ {"version":3,"file":"on-resize.js","names":[],"sources":["../src/on-resize.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { onCleanup } from \"solid-js\";\n\nimport { getPixiApp } from \"./pixi-application\";\n\n/**\n *\n * A SolidJS hook that runs a callback function whenever the PixiJS renderer is resized.\n * The callback is automatically removed when the component or hook's owning computation is cleaned up.\n *\n * This hook must be called from a component that is a descendant of `PixiCanvas` or `PixiApplicationProvider`.\n *\n * @param resizeCallback - A callback function that receives the updated screen dimensions as a `Pixi.Rectangle` object. This function will be called immediately upon hook initialization and then on every subsequent resize event.\n *\n * We listen for the renderer's \"resize\" event so this hook will work correctly whether the window is resized or just the DOM element the PixiCanvas is inside of changes size.\n */\nexport const onResize = (resizeCallback: (screen: Pixi.Rectangle) => void): void => {\n let pixiApp: Pixi.Application;\n\n try {\n pixiApp = getPixiApp();\n } catch {\n throw new Error(\"onResize must be used within a PixiApplicationProvider or a PixiCanvas\");\n }\n\n // Ensure initial callback happens during setup.\n resizeCallback(pixiApp.renderer.screen);\n\n const handleResize = () => {\n // Keep onResize event-driven (fires for every renderer resize event), but schedule the\n // callback after the current emit cycle so usePixiScreen listeners have already synchronized\n // their reactive values. This avoids stale reads when both hooks are used together.\n queueMicrotask(() => {\n resizeCallback(pixiApp.renderer.screen);\n });\n };\n\n pixiApp.renderer.addListener(\"resize\", handleResize);\n\n onCleanup(() => {\n pixiApp.renderer.removeListener(\"resize\", handleResize);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAa,YAAY,mBAA2D;CAClF,IAAI;CAEJ,IAAI;EACF,UAAU,YAAY;SAChB;EACN,MAAM,IAAI,MAAM,yEAAyE;;CAI3F,eAAe,QAAQ,SAAS,OAAO;CAEvC,MAAM,qBAAqB;EAIzB,qBAAqB;GACnB,eAAe,QAAQ,SAAS,OAAO;IACvC;;CAGJ,QAAQ,SAAS,YAAY,UAAU,aAAa;CAEpD,gBAAgB;EACd,QAAQ,SAAS,eAAe,UAAU,aAAa;GACvD"}
@@ -1 +1 @@
1
- {"version":3,"file":"on-tick.js","names":[],"sources":["../src/on-tick.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { UPDATE_PRIORITY } from \"pixi.js\";\nimport { onCleanup, useContext } from \"solid-js\";\n\nimport { TickerContext } from \"./pixi-application\";\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 `PixiCanvas`,\n * `PixiApplicationProvider`, or `TickerProvider`.\n *\n * @param tickerCallback - The function to call on each ticker update. It receives\n * the `Pixi.Ticker` instance as its argument.\n * @param priority - An optional priority level for the ticker callback.\n *\n */\nexport const onTick = (\n tickerCallback: Pixi.TickerCallback<Pixi.Ticker>,\n priority: Pixi.UPDATE_PRIORITY = UPDATE_PRIORITY.NORMAL,\n): void => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\n \"onTick must be used within a PixiApplicationProvider, PixiCanvas or a TickerProvider\",\n );\n }\n\n ticker.add(tickerCallback, ticker, priority);\n\n onCleanup(() => {\n ticker.remove(tickerCallback, ticker);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,IAAa,UACX,gBACA,WAAiC,gBAAgB,WACxC;CACT,MAAM,SAAS,WAAW,cAAc;AAExC,KAAI,CAAC,OACH,OAAM,IAAI,MACR,uFACD;AAGH,QAAO,IAAI,gBAAgB,QAAQ,SAAS;AAE5C,iBAAgB;AACd,SAAO,OAAO,gBAAgB,OAAO;GACrC"}
1
+ {"version":3,"file":"on-tick.js","names":[],"sources":["../src/on-tick.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { UPDATE_PRIORITY } from \"pixi.js\";\nimport { onCleanup, useContext } from \"solid-js\";\n\nimport { TickerContext } from \"./pixi-application\";\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 `PixiCanvas`,\n * `PixiApplicationProvider`, or `TickerProvider`.\n *\n * @param tickerCallback - The function to call on each ticker update. It receives\n * the `Pixi.Ticker` instance as its argument.\n * @param priority - An optional priority level for the ticker callback.\n *\n */\nexport const onTick = (\n tickerCallback: Pixi.TickerCallback<Pixi.Ticker>,\n priority: Pixi.UPDATE_PRIORITY = UPDATE_PRIORITY.NORMAL,\n): void => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\n \"onTick must be used within a PixiApplicationProvider, PixiCanvas or a TickerProvider\",\n );\n }\n\n ticker.add(tickerCallback, ticker, priority);\n\n onCleanup(() => {\n ticker.remove(tickerCallback, ticker);\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,IAAa,UACX,gBACA,WAAiC,gBAAgB,WACxC;CACT,MAAM,SAAS,WAAW,cAAc;CAExC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,uFACD;CAGH,OAAO,IAAI,gBAAgB,QAAQ,SAAS;CAE5C,gBAAgB;EACd,OAAO,OAAO,gBAAgB,OAAO;GACrC"}
@@ -1,7 +1,5 @@
1
1
  import type * as Pixi from "pixi.js";
2
2
  import type { PixiScreenDimensions } from "../use-pixi-screen/pixi-screen-store";
3
- export declare const PixiAppContext: import("solid-js").Context<{
4
- app: Pixi.Application;
5
- pixiScreenStore: Readonly<PixiScreenDimensions>;
6
- } | undefined>;
3
+ export declare const PixiAppContext: import("solid-js").Context<Pixi.Application<Pixi.Renderer> | undefined>;
7
4
  export declare const TickerContext: import("solid-js").Context<Pixi.Ticker | undefined>;
5
+ export declare const ScreenStoreContext: import("solid-js").Context<Readonly<PixiScreenDimensions> | undefined>;
@@ -2,7 +2,8 @@ import { createContext } from "solid-js";
2
2
  //#region src/pixi-application/context.ts
3
3
  var PixiAppContext = createContext();
4
4
  var TickerContext = createContext();
5
+ var ScreenStoreContext = createContext();
5
6
  //#endregion
6
- export { PixiAppContext, TickerContext };
7
+ export { PixiAppContext, ScreenStoreContext, TickerContext };
7
8
 
8
9
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../../src/pixi-application/context.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { createContext } from \"solid-js\";\n\nimport type { PixiScreenDimensions } from \"../use-pixi-screen/pixi-screen-store\";\n\nexport const PixiAppContext = createContext<{\n app: Pixi.Application;\n pixiScreenStore: Readonly<PixiScreenDimensions>;\n}>();\n\nexport const TickerContext = createContext<Pixi.Ticker>();\n"],"mappings":";;AAKA,IAAa,iBAAiB,eAG1B;AAEJ,IAAa,gBAAgB,eAA4B"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../src/pixi-application/context.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { createContext } from \"solid-js\";\n\nimport type { PixiScreenDimensions } from \"../use-pixi-screen/pixi-screen-store\";\n\nexport const PixiAppContext = createContext<Pixi.Application>();\n\nexport const TickerContext = createContext<Pixi.Ticker>();\n\nexport const ScreenStoreContext = createContext<Readonly<PixiScreenDimensions>>();\n"],"mappings":";;AAKA,IAAa,iBAAiB,eAAiC;AAE/D,IAAa,gBAAgB,eAA4B;AAEzD,IAAa,qBAAqB,eAA+C"}
@@ -10,7 +10,7 @@ import { useContext } from "solid-js";
10
10
  var getPixiApp = () => {
11
11
  const appContext = useContext(PixiAppContext);
12
12
  if (!appContext) throw new Error("getPixiApp must be used within a PixiApplicationProvider or a PixiCanvas");
13
- return appContext.app;
13
+ return appContext;
14
14
  };
15
15
  //#endregion
16
16
  export { getPixiApp };
@@ -1 +1 @@
1
- {"version":3,"file":"get-pixi-app.js","names":[],"sources":["../../src/pixi-application/get-pixi-app.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { useContext } from \"solid-js\";\n\nimport { PixiAppContext } from \"./context\";\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 `PixiApplicationProvider` or `PixiCanvas`.\n *\n * @returns The Pixi.Application instance provided by the `PixiApplication` component.\n */\nexport const getPixiApp = (): Pixi.Application => {\n const appContext = useContext(PixiAppContext);\n\n if (!appContext) {\n throw new Error(\"getPixiApp must be used within a PixiApplicationProvider or a PixiCanvas\");\n }\n\n return appContext.app;\n};\n"],"mappings":";;;;;;;;;AAWA,IAAa,mBAAqC;CAChD,MAAM,aAAa,WAAW,eAAe;AAE7C,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,2EAA2E;AAG7F,QAAO,WAAW"}
1
+ {"version":3,"file":"get-pixi-app.js","names":[],"sources":["../../src/pixi-application/get-pixi-app.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { useContext } from \"solid-js\";\n\nimport { PixiAppContext } from \"./context\";\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 `PixiApplicationProvider` or `PixiCanvas`.\n *\n * @returns The Pixi.Application instance provided by the `PixiApplication` component.\n */\nexport const getPixiApp = (): Pixi.Application => {\n const appContext = useContext(PixiAppContext);\n\n if (!appContext) {\n throw new Error(\"getPixiApp must be used within a PixiApplicationProvider or a PixiCanvas\");\n }\n\n return appContext;\n};\n"],"mappings":";;;;;;;;;AAWA,IAAa,mBAAqC;CAChD,MAAM,aAAa,WAAW,eAAe;CAE7C,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,2EAA2E;CAG7F,OAAO"}
@@ -0,0 +1,8 @@
1
+ import type * as Pixi from "pixi.js";
2
+ /**
3
+ * A custom SolidJS hook to access the root Pixi Renderer instance.
4
+ * This hook must be called from a component that is a descendant of `PixiApplicationProvider` or `PixiCanvas`.
5
+ *
6
+ * @returns The Pixi.Renderer instance.
7
+ */
8
+ export declare const getRenderer: () => Pixi.Renderer;
@@ -0,0 +1,18 @@
1
+ import { PixiAppContext } from "./context.js";
2
+ import { useContext } from "solid-js";
3
+ //#region src/pixi-application/get-renderer.ts
4
+ /**
5
+ * A custom SolidJS hook to access the root Pixi Renderer instance.
6
+ * This hook must be called from a component that is a descendant of `PixiApplicationProvider` or `PixiCanvas`.
7
+ *
8
+ * @returns The Pixi.Renderer instance.
9
+ */
10
+ var getRenderer = () => {
11
+ const appContext = useContext(PixiAppContext);
12
+ if (!appContext) throw new Error("getRenderer must be used within a PixiApplicationProvider or a PixiCanvas");
13
+ return appContext.renderer;
14
+ };
15
+ //#endregion
16
+ export { getRenderer };
17
+
18
+ //# sourceMappingURL=get-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-renderer.js","names":[],"sources":["../../src/pixi-application/get-renderer.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { useContext } from \"solid-js\";\n\nimport { PixiAppContext } from \"./context\";\n\n/**\n * A custom SolidJS hook to access the root Pixi Renderer instance.\n * This hook must be called from a component that is a descendant of `PixiApplicationProvider` or `PixiCanvas`.\n *\n * @returns The Pixi.Renderer instance.\n */\nexport const getRenderer = (): Pixi.Renderer => {\n const appContext = useContext(PixiAppContext);\n\n if (!appContext) {\n throw new Error(\"getRenderer must be used within a PixiApplicationProvider or a PixiCanvas\");\n }\n\n return appContext.renderer;\n};\n"],"mappings":";;;;;;;;;AAWA,IAAa,oBAAmC;CAC9C,MAAM,aAAa,WAAW,eAAe;CAE7C,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,4EAA4E;CAG9F,OAAO,WAAW"}
@@ -0,0 +1,8 @@
1
+ import type * as Pixi from "pixi.js";
2
+ /**
3
+ * A custom SolidJS hook that provides access to the Pixi Ticker instance.
4
+ * This hook must be called from a component that is a descendant of `PixiApplicationProvider`, `PixiCanvas` or `TickerProvider`.
5
+ *
6
+ * @returns The Pixi.Ticker instance from the nearest context provider.
7
+ */
8
+ export declare const getTicker: () => Pixi.Ticker;
@@ -2,18 +2,14 @@ import { TickerContext } from "./context.js";
2
2
  import { useContext } from "solid-js";
3
3
  //#region src/pixi-application/get-ticker.ts
4
4
  /**
5
- * getTicker
5
+ * A custom SolidJS hook that provides access to the Pixi Ticker instance.
6
+ * This hook must be called from a component that is a descendant of `PixiApplicationProvider`, `PixiCanvas` or `TickerProvider`.
6
7
  *
7
- * A custom SolidJS hook that provides access to the PIXI.Application's shared Ticker instance.
8
- * This hook must be called from a component that is a descendant of `PixiApplication`.
9
- * Or a descendant of `TickerProvider` if being used for testing without an application.
10
- *
11
- * @returns The PIXI.Ticker instance from the application context.
12
- * @throws Will throw an error if used outside of a `PixiApplication` or `TickerProvider` context.
8
+ * @returns The Pixi.Ticker instance from the nearest context provider.
13
9
  */
14
10
  var getTicker = () => {
15
11
  const ticker = useContext(TickerContext);
16
- if (!ticker) throw new Error("getTicker must be used within a PixiApplication or a TickerProvider");
12
+ if (!ticker) throw new Error("getTicker must be used within a PixiApplicationProvider, PixiCanvas, or TickerProvider");
17
13
  return ticker;
18
14
  };
19
15
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"get-ticker.js","names":[],"sources":["../../src/pixi-application/get-ticker.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { useContext } from \"solid-js\";\n\nimport { TickerContext } from \"./context\";\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 = (): Pixi.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"],"mappings":";;;;;;;;;;;;;AAeA,IAAa,kBAA+B;CAC1C,MAAM,SAAS,WAAW,cAAc;AACxC,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,sEAAsE;AAExF,QAAO"}
1
+ {"version":3,"file":"get-ticker.js","names":[],"sources":["../../src/pixi-application/get-ticker.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { useContext } from \"solid-js\";\n\nimport { TickerContext } from \"./context\";\n\n/**\n * A custom SolidJS hook that provides access to the Pixi Ticker instance.\n * This hook must be called from a component that is a descendant of `PixiApplicationProvider`, `PixiCanvas` or `TickerProvider`.\n *\n * @returns The Pixi.Ticker instance from the nearest context provider.\n */\nexport const getTicker = (): Pixi.Ticker => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\n \"getTicker must be used within a PixiApplicationProvider, PixiCanvas, or TickerProvider\",\n );\n }\n return ticker;\n};\n"],"mappings":";;;;;;;;;AAWA,IAAa,kBAA+B;CAC1C,MAAM,SAAS,WAAW,cAAc;CACxC,IAAI,CAAC,QACH,MAAM,IAAI,MACR,yFACD;CAEH,OAAO"}