pixi-solid 0.0.25 → 0.0.27
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/node_modules/.pnpm/solid-js@1.9.10/node_modules/solid-js/store/dist/store.js +168 -0
- package/dist/node_modules/.pnpm/solid-js@1.9.10/node_modules/solid-js/store/dist/store.js.map +1 -0
- package/dist/packages/pixi-solid/src/component-creation.js.map +1 -0
- package/dist/packages/pixi-solid/src/on-resize.js.map +1 -0
- package/dist/{pixi-application.js → packages/pixi-solid/src/pixi-application.js} +37 -2
- package/dist/packages/pixi-solid/src/pixi-application.js.map +1 -0
- package/dist/packages/pixi-solid/src/pixi-canvas.js.map +1 -0
- package/dist/packages/pixi-solid/src/pixi-components.js.map +1 -0
- package/dist/packages/pixi-solid/src/pixi-events.js.map +1 -0
- package/dist/packages/pixi-solid/src/pixi-stage.js.map +1 -0
- package/dist/{renderer.js → packages/pixi-solid/src/renderer.js} +3 -0
- package/dist/packages/pixi-solid/src/renderer.js.map +1 -0
- package/dist/packages/pixi-solid/src/utils/object-fit.js.map +1 -0
- package/dist/types/pixi-application.d.ts +18 -0
- package/package.json +1 -1
- package/dist/component-creation.js.map +0 -1
- package/dist/on-resize.js.map +0 -1
- package/dist/pixi-application.js.map +0 -1
- package/dist/pixi-canvas.js.map +0 -1
- package/dist/pixi-components.js.map +0 -1
- package/dist/pixi-events.js.map +0 -1
- package/dist/pixi-stage.js.map +0 -1
- package/dist/renderer.js.map +0 -1
- package/dist/utils/object-fit.js.map +0 -1
- /package/dist/{component-creation.js → packages/pixi-solid/src/component-creation.js} +0 -0
- /package/dist/{index.js → packages/pixi-solid/src/index.js} +0 -0
- /package/dist/{index.js.map → packages/pixi-solid/src/index.js.map} +0 -0
- /package/dist/{on-resize.js → packages/pixi-solid/src/on-resize.js} +0 -0
- /package/dist/{pixi-canvas.js → packages/pixi-solid/src/pixi-canvas.js} +0 -0
- /package/dist/{pixi-components.js → packages/pixi-solid/src/pixi-components.js} +0 -0
- /package/dist/{pixi-events.js → packages/pixi-solid/src/pixi-events.js} +0 -0
- /package/dist/{pixi-stage.js → packages/pixi-solid/src/pixi-stage.js} +0 -0
- /package/dist/{utils → packages/pixi-solid/src/utils}/index.js +0 -0
- /package/dist/{utils → packages/pixi-solid/src/utils}/index.js.map +0 -0
- /package/dist/{utils → packages/pixi-solid/src/utils}/object-fit.js +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { $PROXY, batch, $TRACK, getListener, createSignal } from "solid-js";
|
|
2
|
+
const $RAW = Symbol("store-raw"), $NODE = Symbol("store-node"), $HAS = Symbol("store-has"), $SELF = Symbol("store-self");
|
|
3
|
+
function isWrappable(obj) {
|
|
4
|
+
let proto;
|
|
5
|
+
return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
|
|
6
|
+
}
|
|
7
|
+
function unwrap(item, set = /* @__PURE__ */ new Set()) {
|
|
8
|
+
let result, unwrapped, v, prop;
|
|
9
|
+
if (result = item != null && item[$RAW]) return result;
|
|
10
|
+
if (!isWrappable(item) || set.has(item)) return item;
|
|
11
|
+
if (Array.isArray(item)) {
|
|
12
|
+
if (Object.isFrozen(item)) item = item.slice(0);
|
|
13
|
+
else set.add(item);
|
|
14
|
+
for (let i = 0, l = item.length; i < l; i++) {
|
|
15
|
+
v = item[i];
|
|
16
|
+
if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
if (Object.isFrozen(item)) item = Object.assign({}, item);
|
|
20
|
+
else set.add(item);
|
|
21
|
+
const keys = Object.keys(item), desc = Object.getOwnPropertyDescriptors(item);
|
|
22
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
23
|
+
prop = keys[i];
|
|
24
|
+
if (desc[prop].get) continue;
|
|
25
|
+
v = item[prop];
|
|
26
|
+
if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return item;
|
|
30
|
+
}
|
|
31
|
+
function getNodes(target, symbol) {
|
|
32
|
+
let nodes = target[symbol];
|
|
33
|
+
if (!nodes) Object.defineProperty(target, symbol, {
|
|
34
|
+
value: nodes = /* @__PURE__ */ Object.create(null)
|
|
35
|
+
});
|
|
36
|
+
return nodes;
|
|
37
|
+
}
|
|
38
|
+
function getNode(nodes, property, value) {
|
|
39
|
+
if (nodes[property]) return nodes[property];
|
|
40
|
+
const [s, set] = createSignal(value, {
|
|
41
|
+
equals: false,
|
|
42
|
+
internal: true
|
|
43
|
+
});
|
|
44
|
+
s.$ = set;
|
|
45
|
+
return nodes[property] = s;
|
|
46
|
+
}
|
|
47
|
+
function trackSelf(target) {
|
|
48
|
+
getListener() && getNode(getNodes(target, $NODE), $SELF)();
|
|
49
|
+
}
|
|
50
|
+
function ownKeys(target) {
|
|
51
|
+
trackSelf(target);
|
|
52
|
+
return Reflect.ownKeys(target);
|
|
53
|
+
}
|
|
54
|
+
function setProperty(state, property, value, deleting = false) {
|
|
55
|
+
if (!deleting && state[property] === value) return;
|
|
56
|
+
const prev = state[property], len = state.length;
|
|
57
|
+
if (value === void 0) {
|
|
58
|
+
delete state[property];
|
|
59
|
+
if (state[$HAS] && state[$HAS][property] && prev !== void 0) state[$HAS][property].$();
|
|
60
|
+
} else {
|
|
61
|
+
state[property] = value;
|
|
62
|
+
if (state[$HAS] && state[$HAS][property] && prev === void 0) state[$HAS][property].$();
|
|
63
|
+
}
|
|
64
|
+
let nodes = getNodes(state, $NODE), node;
|
|
65
|
+
if (node = getNode(nodes, property, prev)) node.$(() => value);
|
|
66
|
+
if (Array.isArray(state) && state.length !== len) {
|
|
67
|
+
for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
|
|
68
|
+
(node = getNode(nodes, "length", len)) && node.$(state.length);
|
|
69
|
+
}
|
|
70
|
+
(node = nodes[$SELF]) && node.$();
|
|
71
|
+
}
|
|
72
|
+
function proxyDescriptor(target, property) {
|
|
73
|
+
const desc = Reflect.getOwnPropertyDescriptor(target, property);
|
|
74
|
+
if (!desc || desc.get || desc.set || !desc.configurable || property === $PROXY || property === $NODE) return desc;
|
|
75
|
+
delete desc.value;
|
|
76
|
+
delete desc.writable;
|
|
77
|
+
desc.get = () => target[$PROXY][property];
|
|
78
|
+
desc.set = (v) => target[$PROXY][property] = v;
|
|
79
|
+
return desc;
|
|
80
|
+
}
|
|
81
|
+
const proxyTraps = {
|
|
82
|
+
get(target, property, receiver) {
|
|
83
|
+
if (property === $RAW) return target;
|
|
84
|
+
if (property === $PROXY) return receiver;
|
|
85
|
+
if (property === $TRACK) {
|
|
86
|
+
trackSelf(target);
|
|
87
|
+
return receiver;
|
|
88
|
+
}
|
|
89
|
+
const nodes = getNodes(target, $NODE);
|
|
90
|
+
const tracked = nodes[property];
|
|
91
|
+
let value = tracked ? tracked() : target[property];
|
|
92
|
+
if (property === $NODE || property === $HAS || property === "__proto__") return value;
|
|
93
|
+
if (!tracked) {
|
|
94
|
+
const desc = Object.getOwnPropertyDescriptor(target, property);
|
|
95
|
+
const isFunction = typeof value === "function";
|
|
96
|
+
if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getNode(nodes, property, value)();
|
|
97
|
+
else if (value != null && isFunction && value === Array.prototype[property]) {
|
|
98
|
+
return (...args) => batch(() => Array.prototype[property].apply(receiver, args));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return isWrappable(value) ? wrap(value) : value;
|
|
102
|
+
},
|
|
103
|
+
has(target, property) {
|
|
104
|
+
if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__") return true;
|
|
105
|
+
getListener() && getNode(getNodes(target, $HAS), property)();
|
|
106
|
+
return property in target;
|
|
107
|
+
},
|
|
108
|
+
set(target, property, value) {
|
|
109
|
+
batch(() => setProperty(target, property, unwrap(value)));
|
|
110
|
+
return true;
|
|
111
|
+
},
|
|
112
|
+
deleteProperty(target, property) {
|
|
113
|
+
batch(() => setProperty(target, property, void 0, true));
|
|
114
|
+
return true;
|
|
115
|
+
},
|
|
116
|
+
ownKeys,
|
|
117
|
+
getOwnPropertyDescriptor: proxyDescriptor
|
|
118
|
+
};
|
|
119
|
+
function wrap(value) {
|
|
120
|
+
let p = value[$PROXY];
|
|
121
|
+
if (!p) {
|
|
122
|
+
Object.defineProperty(value, $PROXY, {
|
|
123
|
+
value: p = new Proxy(value, proxyTraps)
|
|
124
|
+
});
|
|
125
|
+
const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
|
|
126
|
+
const proto = Object.getPrototypeOf(value);
|
|
127
|
+
const isClass = proto !== null && value !== null && typeof value === "object" && !Array.isArray(value) && proto !== Object.prototype;
|
|
128
|
+
if (isClass) {
|
|
129
|
+
let curProto = proto;
|
|
130
|
+
while (curProto != null) {
|
|
131
|
+
const descriptors = Object.getOwnPropertyDescriptors(curProto);
|
|
132
|
+
keys.push(...Object.keys(descriptors));
|
|
133
|
+
Object.assign(desc, descriptors);
|
|
134
|
+
curProto = Object.getPrototypeOf(curProto);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
138
|
+
const prop = keys[i];
|
|
139
|
+
if (isClass && prop === "constructor") continue;
|
|
140
|
+
if (desc[prop].get) {
|
|
141
|
+
const get = desc[prop].get.bind(p);
|
|
142
|
+
Object.defineProperty(value, prop, {
|
|
143
|
+
get,
|
|
144
|
+
configurable: true
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (desc[prop].set) {
|
|
148
|
+
const og = desc[prop].set, set = (v) => batch(() => og.call(p, v));
|
|
149
|
+
Object.defineProperty(value, prop, {
|
|
150
|
+
set,
|
|
151
|
+
configurable: true
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return p;
|
|
157
|
+
}
|
|
158
|
+
function createMutable(state, options) {
|
|
159
|
+
const unwrappedStore = unwrap(state || {});
|
|
160
|
+
const wrappedStore = wrap(unwrappedStore);
|
|
161
|
+
return wrappedStore;
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
$RAW,
|
|
165
|
+
createMutable,
|
|
166
|
+
unwrap
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sources":["../../../../../../../../../../node_modules/.pnpm/solid-js@1.9.10/node_modules/solid-js/store/dist/store.js"],"sourcesContent":["import { $PROXY, $TRACK, getListener, batch, createSignal } from 'solid-js';\n\nconst $RAW = Symbol(\"store-raw\"),\n $NODE = Symbol(\"store-node\"),\n $HAS = Symbol(\"store-has\"),\n $SELF = Symbol(\"store-self\");\nfunction wrap$1(value) {\n let p = value[$PROXY];\n if (!p) {\n Object.defineProperty(value, $PROXY, {\n value: p = new Proxy(value, proxyTraps$1)\n });\n if (!Array.isArray(value)) {\n const keys = Object.keys(value),\n desc = Object.getOwnPropertyDescriptors(value);\n for (let i = 0, l = keys.length; i < l; i++) {\n const prop = keys[i];\n if (desc[prop].get) {\n Object.defineProperty(value, prop, {\n enumerable: desc[prop].enumerable,\n get: desc[prop].get.bind(p)\n });\n }\n }\n }\n }\n return p;\n}\nfunction isWrappable(obj) {\n let proto;\n return obj != null && typeof obj === \"object\" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));\n}\nfunction unwrap(item, set = new Set()) {\n let result, unwrapped, v, prop;\n if (result = item != null && item[$RAW]) return result;\n if (!isWrappable(item) || set.has(item)) return item;\n if (Array.isArray(item)) {\n if (Object.isFrozen(item)) item = item.slice(0);else set.add(item);\n for (let i = 0, l = item.length; i < l; i++) {\n v = item[i];\n if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;\n }\n } else {\n if (Object.isFrozen(item)) item = Object.assign({}, item);else set.add(item);\n const keys = Object.keys(item),\n desc = Object.getOwnPropertyDescriptors(item);\n for (let i = 0, l = keys.length; i < l; i++) {\n prop = keys[i];\n if (desc[prop].get) continue;\n v = item[prop];\n if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;\n }\n }\n return item;\n}\nfunction getNodes(target, symbol) {\n let nodes = target[symbol];\n if (!nodes) Object.defineProperty(target, symbol, {\n value: nodes = Object.create(null)\n });\n return nodes;\n}\nfunction getNode(nodes, property, value) {\n if (nodes[property]) return nodes[property];\n const [s, set] = createSignal(value, {\n equals: false,\n internal: true\n });\n s.$ = set;\n return nodes[property] = s;\n}\nfunction proxyDescriptor$1(target, property) {\n const desc = Reflect.getOwnPropertyDescriptor(target, property);\n if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE) return desc;\n delete desc.value;\n delete desc.writable;\n desc.get = () => target[$PROXY][property];\n return desc;\n}\nfunction trackSelf(target) {\n getListener() && getNode(getNodes(target, $NODE), $SELF)();\n}\nfunction ownKeys(target) {\n trackSelf(target);\n return Reflect.ownKeys(target);\n}\nconst proxyTraps$1 = {\n get(target, property, receiver) {\n if (property === $RAW) return target;\n if (property === $PROXY) return receiver;\n if (property === $TRACK) {\n trackSelf(target);\n return receiver;\n }\n const nodes = getNodes(target, $NODE);\n const tracked = nodes[property];\n let value = tracked ? tracked() : target[property];\n if (property === $NODE || property === $HAS || property === \"__proto__\") return value;\n if (!tracked) {\n const desc = Object.getOwnPropertyDescriptor(target, property);\n if (getListener() && (typeof value !== \"function\" || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getNode(nodes, property, value)();\n }\n return isWrappable(value) ? wrap$1(value) : value;\n },\n has(target, property) {\n if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === \"__proto__\") return true;\n getListener() && getNode(getNodes(target, $HAS), property)();\n return property in target;\n },\n set() {\n return true;\n },\n deleteProperty() {\n return true;\n },\n ownKeys: ownKeys,\n getOwnPropertyDescriptor: proxyDescriptor$1\n};\nfunction setProperty(state, property, value, deleting = false) {\n if (!deleting && state[property] === value) return;\n const prev = state[property],\n len = state.length;\n if (value === undefined) {\n delete state[property];\n if (state[$HAS] && state[$HAS][property] && prev !== undefined) state[$HAS][property].$();\n } else {\n state[property] = value;\n if (state[$HAS] && state[$HAS][property] && prev === undefined) state[$HAS][property].$();\n }\n let nodes = getNodes(state, $NODE),\n node;\n if (node = getNode(nodes, property, prev)) node.$(() => value);\n if (Array.isArray(state) && state.length !== len) {\n for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();\n (node = getNode(nodes, \"length\", len)) && node.$(state.length);\n }\n (node = nodes[$SELF]) && node.$();\n}\nfunction mergeStoreNode(state, value) {\n const keys = Object.keys(value);\n for (let i = 0; i < keys.length; i += 1) {\n const key = keys[i];\n setProperty(state, key, value[key]);\n }\n}\nfunction updateArray(current, next) {\n if (typeof next === \"function\") next = next(current);\n next = unwrap(next);\n if (Array.isArray(next)) {\n if (current === next) return;\n let i = 0,\n len = next.length;\n for (; i < len; i++) {\n const value = next[i];\n if (current[i] !== value) setProperty(current, i, value);\n }\n setProperty(current, \"length\", len);\n } else mergeStoreNode(current, next);\n}\nfunction updatePath(current, path, traversed = []) {\n let part,\n prev = current;\n if (path.length > 1) {\n part = path.shift();\n const partType = typeof part,\n isArray = Array.isArray(current);\n if (Array.isArray(part)) {\n for (let i = 0; i < part.length; i++) {\n updatePath(current, [part[i]].concat(path), traversed);\n }\n return;\n } else if (isArray && partType === \"function\") {\n for (let i = 0; i < current.length; i++) {\n if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);\n }\n return;\n } else if (isArray && partType === \"object\") {\n const {\n from = 0,\n to = current.length - 1,\n by = 1\n } = part;\n for (let i = from; i <= to; i += by) {\n updatePath(current, [i].concat(path), traversed);\n }\n return;\n } else if (path.length > 1) {\n updatePath(current[part], path, [part].concat(traversed));\n return;\n }\n prev = current[part];\n traversed = [part].concat(traversed);\n }\n let value = path[0];\n if (typeof value === \"function\") {\n value = value(prev, traversed);\n if (value === prev) return;\n }\n if (part === undefined && value == undefined) return;\n value = unwrap(value);\n if (part === undefined || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {\n mergeStoreNode(prev, value);\n } else setProperty(current, part, value);\n}\nfunction createStore(...[store, options]) {\n const unwrappedStore = unwrap(store || {});\n const isArray = Array.isArray(unwrappedStore);\n const wrappedStore = wrap$1(unwrappedStore);\n function setStore(...args) {\n batch(() => {\n isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);\n });\n }\n return [wrappedStore, setStore];\n}\n\nfunction proxyDescriptor(target, property) {\n const desc = Reflect.getOwnPropertyDescriptor(target, property);\n if (!desc || desc.get || desc.set || !desc.configurable || property === $PROXY || property === $NODE) return desc;\n delete desc.value;\n delete desc.writable;\n desc.get = () => target[$PROXY][property];\n desc.set = v => target[$PROXY][property] = v;\n return desc;\n}\nconst proxyTraps = {\n get(target, property, receiver) {\n if (property === $RAW) return target;\n if (property === $PROXY) return receiver;\n if (property === $TRACK) {\n trackSelf(target);\n return receiver;\n }\n const nodes = getNodes(target, $NODE);\n const tracked = nodes[property];\n let value = tracked ? tracked() : target[property];\n if (property === $NODE || property === $HAS || property === \"__proto__\") return value;\n if (!tracked) {\n const desc = Object.getOwnPropertyDescriptor(target, property);\n const isFunction = typeof value === \"function\";\n if (getListener() && (!isFunction || target.hasOwnProperty(property)) && !(desc && desc.get)) value = getNode(nodes, property, value)();else if (value != null && isFunction && value === Array.prototype[property]) {\n return (...args) => batch(() => Array.prototype[property].apply(receiver, args));\n }\n }\n return isWrappable(value) ? wrap(value) : value;\n },\n has(target, property) {\n if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === \"__proto__\") return true;\n getListener() && getNode(getNodes(target, $HAS), property)();\n return property in target;\n },\n set(target, property, value) {\n batch(() => setProperty(target, property, unwrap(value)));\n return true;\n },\n deleteProperty(target, property) {\n batch(() => setProperty(target, property, undefined, true));\n return true;\n },\n ownKeys: ownKeys,\n getOwnPropertyDescriptor: proxyDescriptor\n};\nfunction wrap(value) {\n let p = value[$PROXY];\n if (!p) {\n Object.defineProperty(value, $PROXY, {\n value: p = new Proxy(value, proxyTraps)\n });\n const keys = Object.keys(value),\n desc = Object.getOwnPropertyDescriptors(value);\n const proto = Object.getPrototypeOf(value);\n const isClass = proto !== null && value !== null && typeof value === \"object\" && !Array.isArray(value) && proto !== Object.prototype;\n if (isClass) {\n let curProto = proto;\n while (curProto != null) {\n const descriptors = Object.getOwnPropertyDescriptors(curProto);\n keys.push(...Object.keys(descriptors));\n Object.assign(desc, descriptors);\n curProto = Object.getPrototypeOf(curProto);\n }\n }\n for (let i = 0, l = keys.length; i < l; i++) {\n const prop = keys[i];\n if (isClass && prop === \"constructor\") continue;\n if (desc[prop].get) {\n const get = desc[prop].get.bind(p);\n Object.defineProperty(value, prop, {\n get,\n configurable: true\n });\n }\n if (desc[prop].set) {\n const og = desc[prop].set,\n set = v => batch(() => og.call(p, v));\n Object.defineProperty(value, prop, {\n set,\n configurable: true\n });\n }\n }\n }\n return p;\n}\nfunction createMutable(state, options) {\n const unwrappedStore = unwrap(state || {});\n const wrappedStore = wrap(unwrappedStore);\n return wrappedStore;\n}\nfunction modifyMutable(state, modifier) {\n batch(() => modifier(unwrap(state)));\n}\n\nconst $ROOT = Symbol(\"store-root\");\nfunction applyState(target, parent, property, merge, key) {\n const previous = parent[property];\n if (target === previous) return;\n const isArray = Array.isArray(target);\n if (property !== $ROOT && (!isWrappable(target) || !isWrappable(previous) || isArray !== Array.isArray(previous) || key && target[key] !== previous[key])) {\n setProperty(parent, property, target);\n return;\n }\n if (isArray) {\n if (target.length && previous.length && (!merge || key && target[0] && target[0][key] != null)) {\n let i, j, start, end, newEnd, item, newIndicesNext, keyVal;\n for (start = 0, end = Math.min(previous.length, target.length); start < end && (previous[start] === target[start] || key && previous[start] && target[start] && previous[start][key] && previous[start][key] === target[start][key]); start++) {\n applyState(target[start], previous, start, merge, key);\n }\n const temp = new Array(target.length),\n newIndices = new Map();\n for (end = previous.length - 1, newEnd = target.length - 1; end >= start && newEnd >= start && (previous[end] === target[newEnd] || key && previous[end] && target[newEnd] && previous[end][key] && previous[end][key] === target[newEnd][key]); end--, newEnd--) {\n temp[newEnd] = previous[end];\n }\n if (start > newEnd || start > end) {\n for (j = start; j <= newEnd; j++) setProperty(previous, j, target[j]);\n for (; j < target.length; j++) {\n setProperty(previous, j, temp[j]);\n applyState(target[j], previous, j, merge, key);\n }\n if (previous.length > target.length) setProperty(previous, \"length\", target.length);\n return;\n }\n newIndicesNext = new Array(newEnd + 1);\n for (j = newEnd; j >= start; j--) {\n item = target[j];\n keyVal = key && item ? item[key] : item;\n i = newIndices.get(keyVal);\n newIndicesNext[j] = i === undefined ? -1 : i;\n newIndices.set(keyVal, j);\n }\n for (i = start; i <= end; i++) {\n item = previous[i];\n keyVal = key && item ? item[key] : item;\n j = newIndices.get(keyVal);\n if (j !== undefined && j !== -1) {\n temp[j] = previous[i];\n j = newIndicesNext[j];\n newIndices.set(keyVal, j);\n }\n }\n for (j = start; j < target.length; j++) {\n if (j in temp) {\n setProperty(previous, j, temp[j]);\n applyState(target[j], previous, j, merge, key);\n } else setProperty(previous, j, target[j]);\n }\n } else {\n for (let i = 0, len = target.length; i < len; i++) {\n applyState(target[i], previous, i, merge, key);\n }\n }\n if (previous.length > target.length) setProperty(previous, \"length\", target.length);\n return;\n }\n const targetKeys = Object.keys(target);\n for (let i = 0, len = targetKeys.length; i < len; i++) {\n applyState(target[targetKeys[i]], previous, targetKeys[i], merge, key);\n }\n const previousKeys = Object.keys(previous);\n for (let i = 0, len = previousKeys.length; i < len; i++) {\n if (target[previousKeys[i]] === undefined) setProperty(previous, previousKeys[i], undefined);\n }\n}\nfunction reconcile(value, options = {}) {\n const {\n merge,\n key = \"id\"\n } = options,\n v = unwrap(value);\n return state => {\n if (!isWrappable(state) || !isWrappable(v)) return v;\n const res = applyState(v, {\n [$ROOT]: state\n }, $ROOT, merge, key);\n return res === undefined ? state : res;\n };\n}\nconst producers = new WeakMap();\nconst setterTraps = {\n get(target, property) {\n if (property === $RAW) return target;\n const value = target[property];\n let proxy;\n return isWrappable(value) ? producers.get(value) || (producers.set(value, proxy = new Proxy(value, setterTraps)), proxy) : value;\n },\n set(target, property, value) {\n setProperty(target, property, unwrap(value));\n return true;\n },\n deleteProperty(target, property) {\n setProperty(target, property, undefined, true);\n return true;\n }\n};\nfunction produce(fn) {\n return state => {\n if (isWrappable(state)) {\n let proxy;\n if (!(proxy = producers.get(state))) {\n producers.set(state, proxy = new Proxy(state, setterTraps));\n }\n fn(proxy);\n }\n return state;\n };\n}\n\nconst DEV = undefined;\n\nexport { $RAW, DEV, createMutable, createStore, modifyMutable, produce, reconcile, unwrap };\n"],"names":[],"mappings":";AAEK,MAAC,OAAO,OAAO,WAAW,GAC7B,QAAQ,OAAO,YAAY,GAC3B,OAAO,OAAO,WAAW,GACzB,QAAQ,OAAO,YAAY;AAuB7B,SAAS,YAAY,KAAK;AACxB,MAAI;AACJ,SAAO,OAAO,QAAQ,OAAO,QAAQ,aAAa,IAAI,MAAM,KAAK,EAAE,QAAQ,OAAO,eAAe,GAAG,MAAM,UAAU,OAAO,aAAa,MAAM,QAAQ,GAAG;AAC3J;AACA,SAAS,OAAO,MAAM,MAAM,oBAAI,IAAG,GAAI;AACrC,MAAI,QAAQ,WAAW,GAAG;AAC1B,MAAI,SAAS,QAAQ,QAAQ,KAAK,IAAI,EAAG,QAAO;AAChD,MAAI,CAAC,YAAY,IAAI,KAAK,IAAI,IAAI,IAAI,EAAG,QAAO;AAChD,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,QAAI,OAAO,SAAS,IAAI,EAAG,QAAO,KAAK,MAAM,CAAC;AAAA,QAAO,KAAI,IAAI,IAAI;AACjE,aAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,IAAI,GAAG,KAAK;AAC3C,UAAI,KAAK,CAAC;AACV,WAAK,YAAY,OA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ACT;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-creation.js","sources":["../../../../src/component-creation.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { createRenderEffect, on, splitProps } from \"solid-js\";\nimport type { PixiEventHandlerMap } from \"./pixi-events\";\nimport { PIXI_SOLID_EVENT_HANDLER_NAMES } from \"./pixi-events\";\nimport { insert, setProp } from \"./renderer\";\n\n/**\n * Prop definition for components that CAN have children\n */\nexport type ContainerProps<Component> = PixiEventHandlerMap & {\n ref?: Ref<Component>;\n as?: Component;\n children?: JSX.Element;\n};\n\n/**\n * Prop definition for components that CANNOT have children\n */\nexport type LeafProps<Component> = Omit<ContainerProps<Component>, \"children\">;\n\n/**\n * Prop definition for filter components\n */\nexport type FilterProps<Component> = {\n ref?: Ref<Component>;\n as?: Component;\n};\n\n// Keys that are specific to Solid components and not Pixi props\nexport const SOLID_PROP_KEYS = [\"ref\", \"as\", \"children\"] as const;\n\n/**\n * Apply's the props to a Pixi instance with subsriptions to maintain reactivity.\n *\n * @param instance The Pixi instance we want to apply props to.\n * @param props The props object.\n * @param defer Defers the createRenderEffect so the props aren't set on the first run.\n * This is useful because setting initialisation props can have unintended side effects.\n * Notibly in AnimatedSprite, if we set the textures roperty after instantiation it will stop the instance from playing.\n */\nexport const applyProps = <\n InstanceType extends Pixi.Container,\n OptionsType extends ContainerProps<InstanceType>,\n>(\n instance: InstanceType,\n props: OptionsType,\n defer?: boolean,\n) => {\n for (const key in props) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n } else if (key === \"children\") {\n if (!(\"addChild\" in instance)) {\n throw new Error(`Cannot set children on non-container instance.`);\n }\n createRenderEffect(() => {\n insert(instance, () => props.children);\n });\n } else if (defer) {\n createRenderEffect(\n on(\n () => props[key as keyof typeof props],\n () => {\n setProp(instance, key, props[key as keyof typeof props]);\n },\n { defer },\n ),\n );\n } else {\n createRenderEffect(() => {\n setProp(instance, key, props[key as keyof typeof props]);\n });\n }\n }\n};\n\nexport const createContainerComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (\n props: Omit<OptionsType, \"children\"> & ContainerProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, [\n ...SOLID_PROP_KEYS,\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n applyProps(instance, initialisationProps, true);\n applyProps(instance, runtimeProps);\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createLeafComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (\n props: Omit<OptionsType, \"children\"> & LeafProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n return createContainerComponent<InstanceType, OptionsType>(PixiClass)(props);\n };\n};\n\nexport const createFilterComponent = <InstanceType extends Pixi.Filter, OptionsType extends object>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (props: OptionsType & FilterProps<InstanceType>): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, [\"ref\", \"as\"]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n for (const key in initialisationProps) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n } else if (key === \"children\") {\n throw new Error(`Cannot set children on non-container instance.`);\n } else {\n createRenderEffect(\n on(\n () => props[key as keyof typeof initialisationProps],\n () => {\n (instance as any)[key] = initialisationProps[key];\n },\n { defer: true },\n ),\n );\n }\n }\n\n for (const key in runtimeProps) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n }\n }\n\n return instance as InstanceType & JSX.Element;\n };\n};\n"],"names":[],"mappings":";;;AA8BO,MAAM,kBAAkB,CAAC,OAAO,MAAM,UAAU;AAWhD,MAAM,aAAa,CAIxB,UACA,OACA,UACG;AACH,aAAW,OAAO,OAAO;AACvB,QAAI,QAAQ,KAAM;AAElB,QAAI,QAAQ,OAAO;AACjB,yBAAmB,MAAM;AAEtB,cAAM,GAAG,EAAoC,QAAQ;AAAA,MACxD,CAAC;AAAA,IACH,WAAW,QAAQ,YAAY;AAC7B,UAAI,EAAE,cAAc,WAAW;AAC7B,cAAM,IAAI,MAAM,gDAAgD;AAAA,MAClE;AACA,yBAAmB,MAAM;AACvB,eAAO,UAAU,MAAM,MAAM,QAAQ;AAAA,MACvC,CAAC;AAAA,IACH,WAAW,OAAO;AAChB;AAAA,QACE;AAAA,UACE,MAAM,MAAM,GAAyB;AAAA,UACrC,MAAM;AACJ,oBAAQ,UAAU,KAAK,MAAM,GAAyB,CAAC;AAAA,UACzD;AAAA,UACA,EAAE,MAAA;AAAA,QAAM;AAAA,MACV;AAAA,IAEJ,OAAO;AACL,yBAAmB,MAAM;AACvB,gBAAQ,UAAU,KAAK,MAAM,GAAyB,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,2BAA2B,CAItC,cACG;AACH,SAAO,CACL,UAC+B;AAC/B,UAAM,CAAC,cAAc,mBAAmB,IAAI,WAAW,OAAO;AAAA,MAC5D,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAED,UAAM,WAAW,MAAM,MAAM,IAAI,UAAU,mBAA0B;AAErE,eAAW,UAAU,qBAAqB,IAAI;AAC9C,eAAW,UAAU,YAAY;AAEjC,WAAO;AAAA,EACT;AACF;AAEO,MAAM,sBAAsB,CAIjC,cACG;AACH,SAAO,CACL,UAC+B;AAC/B,WAAO,yBAAoD,SAAS,EAAE,KAAK;AAAA,EAC7E;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"on-resize.js","sources":["../../../../src/on-resize.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { onCleanup } from \"solid-js\";\nimport { getPixiApp } from \"./pixi-application\";\n\n/**\n * A SolidJS hook that runs a callback function whenever the PixiJS renderer is resized.\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 * Because we listen for the renderer's \"resize\" event, this hook will work correctly whether the window is resized or just the DOM element the PixiCanvas is inside changes size.\n */\nexport const onResize = (resizeCallback: (screen: Pixi.Rectangle) => void): void => {\n const app = getPixiApp();\n\n const handleResize = () => {\n resizeCallback(app.renderer.screen);\n };\n\n handleResize();\n\n app.renderer.addListener(\"resize\", handleResize);\n\n onCleanup(() => {\n app.renderer.removeListener(\"resize\", handleResize);\n });\n};\n"],"names":[],"mappings":";;AAWO,MAAM,WAAW,CAAC,mBAA2D;AAClF,QAAM,MAAM,WAAA;AAEZ,QAAM,eAAe,MAAM;AACzB,mBAAe,IAAI,SAAS,MAAM;AAAA,EACpC;AAEA,eAAA;AAEA,MAAI,SAAS,YAAY,UAAU,YAAY;AAE/C,YAAU,MAAM;AACd,QAAI,SAAS,eAAe,UAAU,YAAY;AAAA,EACpD,CAAC;AACH;"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createComponent } from "solid-js/web";
|
|
2
2
|
import { Application } from "pixi.js";
|
|
3
|
-
import { createContext, useContext, splitProps, createResource, createEffect, onCleanup, Show } from "solid-js";
|
|
3
|
+
import { createContext, useContext, splitProps, createResource, createEffect, onCleanup, Show, batch } from "solid-js";
|
|
4
|
+
import { createMutable } from "../../../node_modules/.pnpm/solid-js@1.9.10/node_modules/solid-js/store/dist/store.js";
|
|
4
5
|
const PixiAppContext = createContext();
|
|
5
6
|
const TickerContext = createContext();
|
|
7
|
+
const PixiScreenContext = createContext();
|
|
6
8
|
const getPixiApp = () => {
|
|
7
9
|
const app = useContext(PixiAppContext);
|
|
8
10
|
if (!app) {
|
|
@@ -12,6 +14,16 @@ const getPixiApp = () => {
|
|
|
12
14
|
};
|
|
13
15
|
const PixiApplication = (props) => {
|
|
14
16
|
const [, initialisationProps] = splitProps(props, ["ref", "children"]);
|
|
17
|
+
const pixiScreenDimensions = createMutable({
|
|
18
|
+
width: 800,
|
|
19
|
+
height: 600,
|
|
20
|
+
left: 0,
|
|
21
|
+
right: 800,
|
|
22
|
+
top: 0,
|
|
23
|
+
bottom: 600,
|
|
24
|
+
x: 0,
|
|
25
|
+
y: 0
|
|
26
|
+
});
|
|
15
27
|
const [appResource] = createResource(async () => {
|
|
16
28
|
const app = new Application();
|
|
17
29
|
await app.init({
|
|
@@ -22,6 +34,18 @@ const PixiApplication = (props) => {
|
|
|
22
34
|
});
|
|
23
35
|
return app;
|
|
24
36
|
});
|
|
37
|
+
const updatePixiScreenStore = (screen) => {
|
|
38
|
+
batch(() => {
|
|
39
|
+
pixiScreenDimensions.width = screen.width;
|
|
40
|
+
pixiScreenDimensions.height = screen.height;
|
|
41
|
+
pixiScreenDimensions.left = screen.x;
|
|
42
|
+
pixiScreenDimensions.top = screen.y;
|
|
43
|
+
pixiScreenDimensions.right = screen.x + screen.width;
|
|
44
|
+
pixiScreenDimensions.bottom = screen.y + screen.height;
|
|
45
|
+
pixiScreenDimensions.x = screen.x;
|
|
46
|
+
pixiScreenDimensions.y = screen.y;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
25
49
|
createEffect(() => {
|
|
26
50
|
const app = appResource();
|
|
27
51
|
if (app) {
|
|
@@ -30,7 +54,13 @@ const PixiApplication = (props) => {
|
|
|
30
54
|
}
|
|
31
55
|
app.ticker.autoStart = false;
|
|
32
56
|
app.ticker.start();
|
|
57
|
+
updatePixiScreenStore(app.renderer.screen);
|
|
58
|
+
const handleResize = () => {
|
|
59
|
+
updatePixiScreenStore(app.renderer.screen);
|
|
60
|
+
};
|
|
61
|
+
app.renderer.addListener("resize", handleResize);
|
|
33
62
|
onCleanup(() => {
|
|
63
|
+
app.renderer.removeListener("resize", handleResize);
|
|
34
64
|
app.destroy(true, {
|
|
35
65
|
children: true
|
|
36
66
|
});
|
|
@@ -51,7 +81,12 @@ const PixiApplication = (props) => {
|
|
|
51
81
|
return app().ticker;
|
|
52
82
|
},
|
|
53
83
|
get children() {
|
|
54
|
-
return
|
|
84
|
+
return createComponent(PixiScreenContext.Provider, {
|
|
85
|
+
value: pixiScreenDimensions,
|
|
86
|
+
get children() {
|
|
87
|
+
return props.children;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
55
90
|
}
|
|
56
91
|
});
|
|
57
92
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixi-application.js","sources":["../../../../src/pixi-application.tsx"],"sourcesContent":["import type { ApplicationOptions, Rectangle, Ticker, TickerCallback } from \"pixi.js\";\nimport { Application } from \"pixi.js\";\nimport type { JSX, ParentProps, Ref } from \"solid-js\";\nimport { batch, createContext, createEffect, createResource, onCleanup, Show, splitProps, useContext } from \"solid-js\";\nimport { createMutable } from \"solid-js/store\";\n\nexport type PixiScreenDimensions = {\n width: number;\n height: number;\n left: number;\n right: number;\n bottom: number;\n top: number;\n x: number;\n y: number;\n};\n\nconst PixiAppContext = createContext<Application>();\nconst TickerContext = createContext<Ticker>();\nconst PixiScreenContext = createContext<Readonly<PixiScreenDimensions>>();\n\n/**\n * A custom SolidJS hook to access the root PIXI.Application instance.\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n *\n * @returns The PIXI.Application instance provided by the `PixiApplication` component.\n * @throws Will throw an error if used outside of a `PixiApplication` context provider.\n */\nexport const getPixiApp = () => {\n const app = useContext(PixiAppContext);\n if (!app) {\n throw new Error(\"getPixiApp must be used within a PixiApplication\");\n }\n return app;\n};\n\n/**\n * Props for the `PixiApplication` component. It extends the PIXI.ApplicationOptions\n * to allow passing configuration directly to the Pixi.js Application constructor,\n * but omits properties that are handled by the component itself.\n */\nexport type PixiApplicationProps = Partial<Omit<ApplicationOptions, \"children\" | \"resizeTo\">> & {\n ref?: Ref<Application>;\n children?: JSX.Element;\n};\n\n/**\n * A SolidJS component that creates and manages a PIXI.Application instance.\n * It provides the application instance through context to be used by child components\n * and custom hooks like `getPixiApp`, `onTick`, and `getTicker`.\n *\n * This component should only be used once in your application.\n *\n * @param props The properties to configure the Pixi.js Application.\n *\n */\nexport const PixiApplication = (props: PixiApplicationProps) => {\n const [, initialisationProps] = splitProps(props, [\"ref\", \"children\"]);\n const pixiScreenDimensions = createMutable<PixiScreenDimensions>({\n width: 800,\n height: 600,\n left: 0,\n right: 800,\n top: 0,\n bottom: 600,\n x: 0,\n y: 0,\n });\n\n // TODO: Split props into initialisation props and runtime props\n\n const [appResource] = createResource(async () => {\n const app = new Application();\n await app.init({\n autoDensity: true,\n resolution: Math.min(window.devicePixelRatio, 2),\n sharedTicker: true,\n ...initialisationProps,\n });\n\n return app;\n });\n\n const updatePixiScreenStore = (screen: Rectangle) => {\n batch(() => {\n pixiScreenDimensions.width = screen.width;\n pixiScreenDimensions.height = screen.height;\n pixiScreenDimensions.left = screen.x;\n pixiScreenDimensions.top = screen.y;\n pixiScreenDimensions.right = screen.x + screen.width;\n pixiScreenDimensions.bottom = screen.y + screen.height;\n pixiScreenDimensions.x = screen.x;\n pixiScreenDimensions.y = screen.y;\n });\n };\n\n createEffect(() => {\n const app = appResource();\n if (app) {\n if (props.ref) {\n // Solid converts the ref prop to a callback function\n (props.ref as unknown as (arg: any) => void)(app);\n }\n\n // TODO: Go through the other props that can be set at runtime and apply them here\n // e.g. backgroundColor => app.renderer.backgroundColor, etc.\n\n app.ticker.autoStart = false;\n app.ticker.start();\n\n updatePixiScreenStore(app.renderer.screen);\n\n const handleResize = () => {\n updatePixiScreenStore(app.renderer.screen);\n };\n\n app.renderer.addListener(\"resize\", handleResize);\n\n onCleanup(() => {\n app.renderer.removeListener(\"resize\", handleResize);\n app.destroy(true, { children: true });\n });\n }\n });\n\n return (\n <Show when={appResource()}>\n {(app) => (\n <PixiAppContext.Provider value={app()}>\n <TickerContext.Provider value={app().ticker}>\n <PixiScreenContext.Provider value={pixiScreenDimensions}>{props.children}</PixiScreenContext.Provider>\n </TickerContext.Provider>\n </PixiAppContext.Provider>\n )}\n </Show>\n );\n};\n\nexport type TickerProviderProps = ParentProps<{ ticker: Ticker }>;\n\n/**\n * This is only required if you want a ticker without the Application.\n * It provides context for the `onTick` and `getTicker` hooks so we can run tests that use them without having to instantate a Pixi Application.\n *\n * You need to pass in the ticker instance you want to use so it can be manually controled form the outside for testing.\n */\nexport const TickerProvider = (props: TickerProviderProps) => {\n return <TickerContext.Provider value={props.ticker}>{props.children}</TickerContext.Provider>;\n};\n\n/**\n * getTicker\n *\n * A custom SolidJS hook that provides access to the PIXI.Application's shared Ticker instance.\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n * Or a descendant of `TickerProvider` if being used for testing without an application.\n *\n * @returns The PIXI.Ticker instance from the application context.\n * @throws Will throw an error if used outside of a `PixiApplication` or `TickerProvider` context.\n */\nexport const getTicker = (): Ticker => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\"getTicker must be used within a PixiApplication or a TickerProvider\");\n }\n return ticker;\n};\n\n/**\n * onTick\n *\n * A custom SolidJS hook that registers a callback function to be executed on every frame\n * of the PIXI.Application's ticker. The callback is automatically removed when the\n * component or hook's owning computation is cleaned up.\n *\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n * Or a descendant of `TickerProvider` if being used for testing without an application.\n *\n * @param tickerCallback - The function to call on each ticker update. It receives\n * the `PIXI.Ticker` instance as its argument.\n *\n */\nexport const onTick = (tickerCallback: TickerCallback<Ticker>): void => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\"onTick must be used within a PixiApplication or a TickerProvider\");\n }\n\n ticker.add(tickerCallback);\n onCleanup(() => {\n ticker.remove(tickerCallback);\n });\n};\n\nconst asyncDelay = async (ticker: Ticker, delayMs: number) => {\n let timeDelayed = 0;\n\n let resolvePromise: (value: void | PromiseLike<void>) => void;\n\n const promise = new Promise<void>((resolve) => {\n resolvePromise = resolve;\n });\n\n const internalCallback = () => {\n timeDelayed += ticker.deltaMS;\n if (timeDelayed < delayMs) return;\n resolvePromise();\n };\n\n ticker.add(internalCallback);\n\n await promise;\n\n ticker.remove(internalCallback);\n};\n\n/**\n * Create a delay function that waits until a given number of milliseconds has passed on the current Ticker context before resolving.\n *\n * This function must be called inside a `PixiApplication` or `TickerProvider` context.\n *\n * @returns An async function we can await to delay events in sync with time passed on the Ticker.\n *\n * Simply await for it to resolve in an async context.\n *\n * @note It will not resolve if the ticker is paused or stopped.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n */\nexport const createAsyncDelay = (): ((delayMs: number) => Promise<void>) => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\n \"`createDelay` must be used within a PixiApplication or a TickerProvider. The returned `delay` function can be called in an async context but `createDelay` must be called in a synchronous scope within a PixiApplication or a TickerProvider\"\n );\n }\n const delayWithTicker = (delayMs: number) => asyncDelay(ticker, delayMs);\n\n return delayWithTicker;\n};\n\n/**\n * Runs a callback when a given number of milliseconds has passed on the ticker.\n *\n * It is guaranteed to be in sync with the shared ticker and uses accumulated deltaMs not an external time measurement.\n *\n * @param delayMs - Number of milliseconds to wait (measured in the ticker's time units).\n *\n * @param callback - A callback function that will fire when the delayMs time has passed.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n *\n * @note It will not run the callback if the ticker is paused or stopped.\n *\n */\nexport const delay = (delayMs: number, callback?: () => void): void => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\n \"`createDelay` must be used within a PixiApplication or a TickerProvider. The returned `delay` function can be called in an async context but `createDelay` must be called in a synchronous scope within a PixiApplication or a TickerProvider\"\n );\n }\n\n let timeDelayed = 0;\n\n const internalCallback = () => {\n timeDelayed += ticker.deltaMS;\n if (timeDelayed < delayMs) return;\n callback?.();\n ticker.remove(internalCallback);\n };\n\n ticker.add(internalCallback);\n};\n\n/**\n * A hook that provides the current dimensions of the Pixi application's screen as a reactive object.\n * The properties of the returned object will update automatically when the screen size changes and can be subscribed to reactively.\n *\n * @returns An object containing the width and height of the Pixi screen.\n * @throws Will throw an error if not used within a `<PixiApplication>` component.\n */\nexport const usePixiScreen = (): Readonly<PixiScreenDimensions> => {\n const pixiScreen = useContext(PixiScreenContext);\n if (!pixiScreen) {\n throw new Error(\"usePixiScreen must be used within a PixiApplication\");\n }\n return pixiScreen;\n};\n"],"names":["PixiAppContext","createContext","TickerContext","PixiScreenContext","getPixiApp","app","useContext","Error","PixiApplication","props","initialisationProps","splitProps","pixiScreenDimensions","createMutable","width","height","left","right","top","bottom","x","y","appResource","createResource","Application","init","autoDensity","resolution","Math","min","window","devicePixelRatio","sharedTicker","updatePixiScreenStore","screen","batch","createEffect","ref","ticker","autoStart","start","renderer","handleResize","addListener","onCleanup","removeListener","destroy","children","_$createComponent","Show","when","Provider","value","TickerProvider","getTicker","onTick","tickerCallback","add","remove","asyncDelay","delayMs","timeDelayed","resolvePromise","promise","Promise","resolve","internalCallback","deltaMS","createAsyncDelay","delayWithTicker","delay","callback"],"mappings":";;;;AAiBA,MAAMA,iBAAiBC,cAAAA;AACvB,MAAMC,gBAAgBD,cAAAA;AACtB,MAAME,oBAAoBF,cAAAA;AASnB,MAAMG,aAAaA,MAAM;AAC9B,QAAMC,MAAMC,WAAWN,cAAc;AACrC,MAAI,CAACK,KAAK;AACR,UAAM,IAAIE,MAAM,kDAAkD;AAAA,EACpE;AACA,SAAOF;AACT;AAsBO,MAAMG,kBAAkBA,CAACC,UAAgC;AAC9D,QAAM,CAAA,EAAGC,mBAAmB,IAAIC,WAAWF,OAAO,CAAC,OAAO,UAAU,CAAC;AACrE,QAAMG,uBA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AAAA,EACpF;AAEA+B,SAAOmB,IAAID,cAAc;AACzBZ,YAAU,MAAM;AACdN,WAAOoB,OAAOF,cAAc;AAAA,EAC9B,CAAC;AACH;AAEA,MAAMG,aAAa,OAAOrB,QAAgBsB,YAAoB;AAC5D,MAAIC,cAAc;AAElB,MAAIC;AAEJ,QAAMC,UAAU,IAAIC,QAAeC,CAAAA,YAAY;AAC7CH,qBAAiBG;AAAAA,EACnB,CAAC;AAED,QAAMC,mBAAmBA,MAAM;AAC7BL,mBAAevB,OAAO6B;AACtB,QAAIN,cAAcD,QAAS;AAC3BE,mBAAAA;AAAAA,EACF;AAEAxB,SAAOmB,IAAIS,gBAAgB;AAE3B,QAAMH;AAENzB,SAAOoB,OAAOQ,gBAAgB;AAChC;AAeO,MAAME,mBAAmBA,MAA4C;AAC1E,QAAM9B,SAAShC,WAAWJ,aAAa;AAEvC,MAAI,CAACoC,QAAQ;AACX,UAAM,IAAI/B,MACR,+OACF;AAAA,EACF;AACA,QAAM8D,kBAAkBA,CAACT,YAAoBD,WAAWrB,QAAQsB,OAAO;AAEvE,SAAOS;AACT;AAgBO,MAAMC,QAAQA,CAACV,SAAiBW,aAAgC;AACrE,QAAMjC,SAAShC,WAAWJ,aAAa;AACvC,MAAI,CAACoC,QAAQ;AACX,UAAM,IAAI/B,MACR,+OACF;AAAA,EACF;AAEA,MAAIsD,cAAc;AAElB,QAAMK,mBAAmBA,MAAM;AAC7BL,mBAAevB,OAAO6B;AACtB,QAAIN,cAAcD,QAAS;AAC3BW,eAAAA;AACAjC,WAAOoB,OAAOQ,gBAAgB;AAAA,EAChC;AAEA5B,SAAOmB,IAAIS,gBAAgB;AAC7B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixi-canvas.js","sources":["../../../../src/pixi-canvas.tsx"],"sourcesContent":["import type { JSX } from \"solid-js\";\nimport { createRenderEffect, onCleanup, onMount } from \"solid-js\";\nimport { getPixiApp } from \"./pixi-application\";\n\n/**\n * PixiCanvas\n *\n * A small wrapper that mounts the PIXI application's canvas element into the DOM\n * and automatically resizes it.\n *\n * - Requires a surrounding `PixiApplication` component.\n * - Requires a `PixiStage` component as a child.\n *\n * Props:\n * @param props.children - JSX content to render inside the canvas wrapper. Use `PixiStage` as the only child.\n */\n\nexport const PixiCanvas = (props: {\n children: JSX.Element;\n style?: JSX.CSSProperties | undefined;\n className?: string;\n}): JSX.Element => {\n let canvasWrapElement: HTMLDivElement | undefined;\n\n const pixiApp = getPixiApp();\n pixiApp.canvas.style.display = \"block\";\n pixiApp.canvas.style.position = \"absolute\";\n pixiApp.canvas.style.top = \"0\";\n pixiApp.canvas.style.left = \"0\";\n pixiApp.canvas.style.width = \"100%\";\n pixiApp.canvas.style.height = \"100%\";\n\n createRenderEffect(() => {\n if (props.children === undefined) {\n throw new Error(\"PixiCanvas requires the `PixiStage` component to render.\");\n }\n });\n\n let previousResizeTo: typeof pixiApp.resizeTo;\n let resizeObserver: ResizeObserver | undefined;\n\n onMount(() => {\n if (!canvasWrapElement) return;\n previousResizeTo = pixiApp.resizeTo;\n pixiApp.resizeTo = canvasWrapElement;\n pixiApp.queueResize();\n resizeObserver = new ResizeObserver(() => {\n pixiApp.queueResize();\n });\n resizeObserver.observe(canvasWrapElement);\n });\n\n onCleanup(() => {\n if (!canvasWrapElement) return;\n pixiApp.resizeTo = previousResizeTo;\n resizeObserver?.disconnect();\n resizeObserver = undefined;\n });\n\n return (\n <div\n ref={canvasWrapElement}\n style={{\n position: \"relative\",\n ...(typeof props.style === \"object\" ? props.style : {}),\n }}\n class={props.className}\n >\n {pixiApp.canvas}\n </div>\n );\n};\n"],"names":["PixiCanvas","props","canvasWrapElement","pixiApp","getPixiApp","canvas","style","display","position","top","left","width","height","createRenderEffect","children","undefined","Error","previousResizeTo","resizeObserver","onMount","resizeTo","queueResize","ResizeObserver","observe","onCleanup","disconnect","_el$","_tmpl$","_ref$","_$use","_$insert","_$effect","_p$","_v$","_v$2","className","e","_$style","t","_$className"],"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KAAAC,UAAAb,MAAAM,IAAAM,IAAAJ,IAAA;AAAA,aAAAF;AAAAA,IAAA,GAAA;AAAA,MAAAI,GAAArB;AAAAA,MAAAuB,GAAAvB;AAAAA,IAAAA,CAAA;AAAA,WAAAW;AAAAA,EAAA,GAAA;AAK5B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixi-components.js","sources":["../../../../src/pixi-components.tsx"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport {\n AnimatedSprite as PixiAnimatedSprite,\n BitmapText as PixiBitmapText,\n Container as PixiContainer,\n Graphics as PixiGraphics,\n HTMLText as PixiHTMLText,\n MeshPlane as PixiMeshPlane,\n MeshRope as PixiMeshRope,\n NineSliceSprite as PixiNineSliceSprite,\n ParticleContainer as PixiParticleContainer,\n PerspectiveMesh as PixiPerspectiveMesh,\n RenderContainer as PixiRenderContainer,\n RenderLayer as PixiRenderLayer,\n Sprite as PixiSprite,\n Text as PixiText,\n TilingSprite as PixiTilingSprite,\n} from \"pixi.js\";\nimport { createContainerComponent, createLeafComponent } from \"./component-creation\";\n\n/**\n * A SolidJS component that renders a `PIXI.AnimatedSprite`.\n */\nexport const AnimatedSprite = createLeafComponent<PixiAnimatedSprite, Pixi.AnimatedSpriteOptions>(PixiAnimatedSprite);\n/**\n * A SolidJS component that renders a `PIXI.BitmapText`.\n */\nexport const BitmapText = createLeafComponent<PixiBitmapText, Pixi.TextOptions>(PixiBitmapText);\n/**\n * A SolidJS component that renders a `PIXI.Container`.\n */\nexport const Container = createContainerComponent<PixiContainer, Pixi.ContainerOptions>(PixiContainer);\n/**\n * A SolidJS component that renders a `PIXI.Graphics`.\n * Use a ref to access the underlying graphics instance and draw with it.\n */\nexport const Graphics = createLeafComponent<PixiGraphics, Pixi.GraphicsOptions>(PixiGraphics);\n/**\n * A SolidJS component that renders a `PIXI.HTMLText`.\n */\nexport const HTMLText = createLeafComponent<PixiHTMLText, Pixi.HTMLTextOptions>(PixiHTMLText);\n\n/**\n * A SolidJS component that renders a `PIXI.MeshPlane`.\n */\nexport const MeshPlane = createLeafComponent<PixiMeshPlane, Pixi.MeshPlaneOptions>(PixiMeshPlane);\n\n/**\n * A SolidJS component that renders a `PIXI.MeshRope`.\n */\nexport const MeshRope = createLeafComponent<PixiMeshRope, Pixi.MeshRopeOptions>(PixiMeshRope);\n\n/**\n * A SolidJS component that renders a `PIXI.NineSliceSprite`.\n */\nexport const NineSliceSprite = createLeafComponent<PixiNineSliceSprite, Pixi.NineSliceSpriteOptions>(\n PixiNineSliceSprite\n);\n\n/**\n * A SolidJS component that renders a `PIXI.ParticleContainer`.\n *\n * Particles should be added and removed from this component imperatively. Please see the docs for a reference example.\n */\nexport const ParticleContainer = createLeafComponent<PixiParticleContainer, Pixi.ParticleContainerOptions>(\n PixiParticleContainer\n);\n\n/**\n * A SolidJS component that renders a `PIXI.PerspectiveMesh`.\n */\nexport const PerspectiveMesh = createLeafComponent<PixiPerspectiveMesh, Pixi.PerspectivePlaneOptions>(\n PixiPerspectiveMesh\n);\n\n/**\n * A SolidJS component that renders a `PIXI.RenderContainer`.\n */\nexport const RenderContainer = createContainerComponent<PixiRenderContainer, Pixi.RenderContainerOptions>(\n PixiRenderContainer\n);\n\n/**\n * A SolidJS component that renders a `PIXI.RenderLayer`.\n */\nexport const RenderLayer = createContainerComponent<PixiRenderLayer, Pixi.RenderLayerOptions>(PixiRenderLayer);\n\n/**\n * A SolidJS component that renders a `PIXI.Sprite`.\n */\nexport const Sprite = createLeafComponent<PixiSprite, Pixi.SpriteOptions>(PixiSprite);\n/**\n * A SolidJS component that renders a `PIXI.Text`.\n */\nexport const Text = createLeafComponent<PixiText, Pixi.CanvasTextOptions>(PixiText);\n\n/**\n * A SolidJS component that renders a `PIXI.TilingSprite`.\n */\nexport const TilingSprite = createLeafComponent<PixiTilingSprite, Pixi.TilingSpriteOptions>(PixiTilingSprite);\n\n// export const MeshGeometry = createLeafComponent<PixiMeshGeometry, Pixi.MeshGeometryOptions>(PixiMeshGeometry);\n\n// export const NineSliceGeometry = createLeafComponent<PixiNineSliceGeometry, Pixi.NineSliceGeometryOptions>(\n// PixiNineSliceGeometry\n// );\n\n// export const Particle = createLeafComponent<PixiParticle, Pixi.ParticleOptions>(PixiParticle);\n\n// export const PerspectivePlaneGeometry = createLeafComponent<\n// PixiPerspectivePlaneGeometry,\n// Pixi.PerspectivePlaneGeometryOptions\n// >(PixiPerspectivePlaneGeometry);\n\n// export const PlaneGeometry = createLeafComponent<PixiPlaneGeometry, Pixi.PlaneGeometryOptions>(PixiPlaneGeometry);\n\n// export const RopeGeometry = createLeafComponent<PixiRopeGeometry, Pixi.RopeGeometryOptions>(PixiRopeGeometry);\n\n// TODO: Do we need a component for the Culler. It needs to interact with the stage directly.\n// export const Culler = createLeafComponent<PixiCuller, Pixi.Culler>(PixiCuller);\n"],"names":["AnimatedSprite","createLeafComponent","PixiAnimatedSprite","BitmapText","PixiBitmapText","Container","createContainerComponent","PixiContainer","Graphics","PixiGraphics","HTMLText","PixiHTMLText","MeshPlane","PixiMeshPlane","MeshRope","PixiMeshRope","NineSliceSprite","PixiNineSliceSprite","ParticleContainer","PixiParticleContainer","PerspectiveMesh","PixiPerspectiveMesh","RenderContainer","PixiRenderContainer","RenderLayer","PixiRenderLayer","Sprite","PixiSprite","Text","PixiText","TilingSprite","PixiTilingSprite"],"mappings":";;AAuBO,MAAMA,iBAAiBC,oBAAoEC,gBAAkB;AAI7G,MAAMC,aAAaF,oBAAsDG,YAAc;AAIvF,MAAMC,YAAYC,yBAA+DC,WAAa;AAK9F,MAAMC,WAAWP,oBAAwDQ,UAAY;AAIrF,MAAMC,WAAWT,oBAAwDU,UAAY;AAKrF,MAAMC,YAAYX,oBAA0DY,WAAa;AAKzF,MAAMC,WAAWb,oBAAwDc,UAAY;AAKrF,MAAMC,kBAAkBf,oBAC7BgB,iBACF;AAOO,MAAMC,oBAAoBjB,oBAC/BkB,mBACF;AAKO,MAAMC,kBAAkBnB,oBAC7BoB,iBACF;AAKO,MAAMC,kBAAkBhB,yBAC7BiB,iBACF;AAKO,MAAMC,cAAclB,yBAAmEmB,aAAe;AAKtG,MAAMC,SAASzB,oBAAoD0B,QAAU;AAI7E,MAAMC,OAAO3B,oBAAsD4B,MAAQ;AAK3E,MAAMC,eAAe7B,oBAAgE8B,cAAgB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixi-events.js","sources":["../../../../src/pixi-events.ts"],"sourcesContent":["import type { FederatedEventEmitterTypes } from \"pixi.js\";\n\nexport const PIXI_EVENT_NAMES: (keyof FederatedEventEmitterTypes)[] = [\n \"click\",\n \"mousedown\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseout\",\n \"mouseover\",\n \"mouseup\",\n \"mouseupoutside\",\n \"pointercancel\",\n \"pointerdown\",\n \"pointerenter\",\n \"pointerleave\",\n \"pointermove\",\n \"pointerout\",\n \"pointerover\",\n \"pointertap\",\n \"pointerup\",\n \"pointerupoutside\",\n \"rightclick\",\n \"rightdown\",\n \"rightup\",\n \"rightupoutside\",\n \"tap\",\n \"touchcancel\",\n \"touchend\",\n \"touchendoutside\",\n \"touchmove\",\n \"touchstart\",\n \"wheel\",\n \"globalmousemove\",\n \"globalpointermove\",\n \"globaltouchmove\",\n \"clickcapture\",\n \"mousedowncapture\",\n \"mouseentercapture\",\n \"mouseleavecapture\",\n \"mousemovecapture\",\n \"mouseoutcapture\",\n \"mouseovercapture\",\n \"mouseupcapture\",\n \"mouseupoutsidecapture\",\n \"pointercancelcapture\",\n \"pointerdowncapture\",\n \"pointerentercapture\",\n \"pointerleavecapture\",\n \"pointermovecapture\",\n \"pointeroutcapture\",\n \"pointerovercapture\",\n \"pointertapcapture\",\n \"pointerupcapture\",\n \"pointerupoutsidecapture\",\n \"rightclickcapture\",\n \"rightdowncapture\",\n \"rightupcapture\",\n \"rightupoutsidecapture\",\n \"tapcapture\",\n \"touchcancelcapture\",\n \"touchendcapture\",\n \"touchendoutsidecapture\",\n \"touchmovecapture\",\n \"touchstartcapture\",\n \"wheelcapture\",\n] as const;\n\nexport const PIXI_SOLID_EVENT_HANDLER_NAMES = PIXI_EVENT_NAMES.map(\n (eventName) => `on${eventName}` as const,\n);\n\nexport type PixiEventHandlerMap = {\n [K in (typeof PIXI_EVENT_NAMES)[number] as `on${K}`]?:\n | null\n | ((...args: FederatedEventEmitterTypes[K]) => void);\n};\n\nexport const PIXI_EVENT_HANDLER_NAME_SET: Readonly<\n Set<(typeof PIXI_SOLID_EVENT_HANDLER_NAMES)[number]>\n> = new Set(PIXI_SOLID_EVENT_HANDLER_NAMES);\n\n/**\n * This is a type-safe check that ensures `PIXI_EVENT_NAMES` includes every key from Pixi's `AllFederatedEventMap` type.\n * It will cause a build error if any event names are missing.\n */\ntype MissingKeys = Exclude<keyof FederatedEventEmitterTypes, (typeof PIXI_EVENT_NAMES)[number]>;\ntype AllEventsAreHandled = MissingKeys extends never\n ? true\n : `Error: Missing event keys: ${MissingKeys}`;\nconst allEventsAreHandled: AllEventsAreHandled = true;\nvoid allEventsAreHandled;\n"],"names":[],"mappings":"AAEO,MAAM,mBAAyD;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,iCAAiC,iBAAiB;AAAA,EAC7D,CAAC,cAAc,KAAK,SAAS;AAC/B;AAQO,MAAM,8BAET,IAAI,IAAI,8BAA8B;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pixi-stage.js","sources":["../../../../src/pixi-stage.tsx"],"sourcesContent":["import type { Container, ContainerOptions } from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { applyProps } from \"./component-creation\";\nimport { getPixiApp } from \"./pixi-application\";\nimport type { PixiEventHandlerMap } from \"./pixi-events\";\n\nexport type PixiStageProps = PixiEventHandlerMap &\n Omit<ContainerOptions, \"children\"> & {\n ref?: Ref<Container>;\n children?: JSX.Element;\n };\n\n/**\n * PixiStage\n *\n * The root container for rendering Pixi display objects. This component\n * uses the application stage (`pixiApp.stage`) as the mount point and\n * applies props and event handlers to it.\n *\n * Props:\n * - `ref` (optional): receives the stage container reference.\n * - Event handler props (e.g. `onpointerdown`) are forwarded to the stage.\n * - Any other container options supported by Pixi may be passed.\n *\n * Children passed to `PixiStage` are inserted into the application stage.\n */\nexport const PixiStage = (props: PixiStageProps): JSX.Element => {\n const pixiApp = getPixiApp();\n\n applyProps(pixiApp.stage, props);\n\n return <>{pixiApp.stage}</>;\n};\n"],"names":["PixiStage","props","pixiApp","getPixiApp","applyProps","stage","_$memo"],"mappings":";;;AA0BO,MAAMA,YAAYA,CAACC,UAAuC;AAC/D,QAAMC,UAAUC,WAAAA;AAEhBC,aAAWF,QAAQG,OAAOJ,KAAK;AAE/B,SAAAK,KAAA,MAAUJ,QAAQG,KAAK;AACzB;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sources":["../../../../src/renderer.tsx"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { Text as PixiText } from \"pixi.js\";\nimport { createRenderer } from \"solid-js/universal\";\nimport type { PIXI_EVENT_NAMES, PixiEventHandlerMap } from \"./pixi-events\";\nimport { PIXI_EVENT_HANDLER_NAME_SET } from \"./pixi-events\";\n\nexport const {\n effect,\n memo,\n createComponent,\n createElement,\n createTextNode,\n insertNode,\n insert,\n setProp,\n mergeProps,\n use,\n render,\n spread,\n} = createRenderer<Pixi.Container>({\n createElement(name: string) {\n // This function is for lowercase string tags like `<container />`.\n // To support tree-shaking, we require users to import components\n // directly and use them with an uppercase name like `<Container />`,\n // which does not call this function.\n throw new Error(\n `Cannot create element \"${name}\". Please import components directly from 'pixi-solid' and use them with a capital letter.`\n );\n },\n createTextNode(value) {\n return new PixiText({ text: value });\n },\n replaceText(textNode: PixiText, value) {\n textNode.text = value;\n },\n setProperty(node, name, value, prev) {\n if (name in node) {\n (node as any)[name] = value;\n return;\n }\n\n // Check for event listeners and handle them appropriately.\n if (PIXI_EVENT_HANDLER_NAME_SET.has(name as keyof PixiEventHandlerMap)) {\n // Remove the 'on' prefix to get the actual event name.\n const eventName = name.slice(2) as (typeof PIXI_EVENT_NAMES)[number];\n\n if (prev) {\n node.removeEventListener(eventName, prev as any);\n }\n node.addEventListener(eventName, value as any);\n return;\n }\n },\n insertNode(parent, node, anchor) {\n // RenderLayer uses `attach` instead of `addChild`.\n if (\"attach\" in parent && typeof parent.attach === \"function\") {\n parent.attach(node);\n // Note: `attach` does not support anchoring, so we ignore the anchor.\n return;\n }\n\n if (!(\"addChildAt\" in parent) || !(\"addChild\" in parent) || typeof parent.addChild !== \"function\") {\n throw new Error(\"Parent does not support children.\");\n }\n\n if (anchor) {\n parent.addChildAt(node, parent.children.indexOf(anchor));\n } else {\n parent.addChild(node);\n }\n },\n isTextNode(node) {\n return node instanceof PixiText;\n },\n removeNode(_, node) {\n // RenderLayer uses `detach` instead of `removeChild`.\n if (\"detach\" in parent && typeof parent.detach === \"function\") {\n parent.detach(node);\n return;\n }\n\n node.removeFromParent();\n node.destroy({ children: true });\n },\n getParentNode(node) {\n return node?.parent ?? undefined;\n },\n getFirstChild(node) {\n return node.children?.[0];\n },\n getNextSibling(node) {\n if (!node.parent) return undefined;\n const index = node.parent.children.indexOf(node);\n // Return the next child if it exists, otherwise undefined.\n return index > -1 ? node.parent.children[index + 1] : undefined;\n },\n});\n"],"names":["effect","memo","createComponent","createElement","createTextNode","insertNode","insert","setProp","mergeProps","use","render","spread","createRenderer","name","Error","value","PixiText","text","replaceText","textNode","setProperty","node","prev","PIXI_EVENT_HANDLER_NAME_SET","has","eventName","slice","removeEventListener","addEventListener","parent","anchor","attach","addChild","addChildAt","children","indexOf","isTextNode","removeNode","_","detach","removeFromParent","destroy","getParentNode","undefined","getFirstChild","getNextSibling","index"],"mappings":";;;AAMO,MAAM;AAAA,EACXA;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACF,IAAIC,eAA+B;AAAA,EACjCT,cAAcU,MAAc;AAK1B,UAAM,IAAIC,MACR,0BAA0BD,IAAI,4FAChC;AAAA,EACF;AAAA,EACAT,eAAeW,OAAO;AACpB,WAAO,IAAIC,KAAS;AAAA,MAAEC,MAAMF;AAAAA,IAAAA,CAAO;AAAA,EACrC;AAAA,EACAG,YAAYC,UAAoBJ,OAAO;AACrCI,aAASF,OAAOF;AAAAA,EAClB;AAAA,EACAK,YAAYC,MAAMR,MAAME,OAAOO,MAAM;AACnC,QAAIT,QAAQQ,MAAM;AACfA,WAAaR,IAAI,IAAIE;AACtB;AAAA,IACF;AAGA,QAAIQ,4BAA4BC,IAAIX,IAAiC,GAAG;AAEtE,YAAMY,YAAYZ,KAAKa,MAAM,CAAC;AAE9B,UAAIJ,MAAM;AACRD,aAAKM,oBAAo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../../../../src/utils/object-fit.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\n\nexport type ObjectFitMode = \"cover\" | \"contain\" | \"fill\" | \"scale-down\";\n\n/**\n * Scale an object to fit within the given bounds according to the specified fit mode.\n * @param object The object to be scaled.\n * @param bounds The bounds it should fit within.\n * @param fitMode The object fit mode to apply.\n */\nexport const objectFit = (\n object: Pixi.Container,\n bounds: { width: number; height: number },\n fitMode: ObjectFitMode,\n): void => {\n const originalWidth = object.width / object.scale.x;\n const originalHeight = object.height / object.scale.y;\n\n if (originalWidth === 0 || originalHeight === 0 || bounds.width === 0 || bounds.height === 0)\n return;\n\n const widthRatio = bounds.width / originalWidth;\n const heightRatio = bounds.height / originalHeight;\n\n let scaleX = 1;\n let scaleY = 1;\n\n switch (fitMode) {\n case \"cover\": {\n const coverScale = Math.max(widthRatio, heightRatio);\n scaleX = coverScale;\n scaleY = coverScale;\n break;\n }\n case \"contain\": {\n const containScale = Math.min(widthRatio, heightRatio);\n scaleX = containScale;\n scaleY = containScale;\n break;\n }\n case \"fill\": {\n scaleX = widthRatio;\n scaleY = heightRatio;\n break;\n }\n case \"scale-down\": {\n // If the object is smaller than the container, it's 'none' (no scaling up).\n // Otherwise, it's 'contain'.\n if (originalWidth <= bounds.width && originalHeight <= bounds.height) {\n scaleX = 1;\n scaleY = 1;\n } else {\n const scaleDown = Math.min(widthRatio, heightRatio);\n scaleX = scaleDown;\n scaleY = scaleDown;\n }\n break;\n }\n default:\n // Default to no scaling if an unknown fitMode is provided\n break;\n }\n\n object.scale.set(scaleX, scaleY);\n\n // Center the object\n object.x = (bounds.width - object.width) / 2;\n object.y = (bounds.height - object.height) / 2;\n};\n"],"names":[],"mappings":"AAUO,MAAM,YAAY,CACvB,QACA,QACA,YACS;AACT,QAAM,gBAAgB,OAAO,QAAQ,OAAO,MAAM;AAClD,QAAM,iBAAiB,OAAO,SAAS,OAAO,MAAM;AAEpD,MAAI,kBAAkB,KAAK,mBAAmB,KAAK,OAAO,UAAU,KAAK,OAAO,WAAW;AACzF;AAEF,QAAM,aAAa,OAAO,QAAQ;AAClC,QAAM,cAAc,OAAO,SAAS;AAEpC,MAAI,SAAS;AACb,MAAI,SAAS;AAEb,UAAQ,SAAA;AAAA,IACN,KAAK,SAAS;AACZ,YAAM,aAAa,KAAK,IAAI,YAAY,WAAW;AACnD,eAAS;AACT,eAAS;AACT;AAAA,IACF;AAAA,IACA,KAAK,WAAW;AACd,YAAM,eAAe,KAAK,IAAI,YAAY,WAAW;AACrD,eAAS;AACT,eAAS;AACT;AAAA,IACF;AAAA,IACA,KAAK,QAAQ;AACX,eAAS;AACT,eAAS;AACT;AAAA,IACF;AAAA,IACA,KAAK,cAAc;AAGjB,UAAI,iBAAiB,OAAO,SAAS,kBAAkB,OAAO,QAAQ;AACpE,iBAAS;AACT,iBAAS;AAAA,MACX,OAAO;AACL,cAAM,YAAY,KAAK,IAAI,YAAY,WAAW;AAClD,iBAAS;AACT,iBAAS;AAAA,MACX;AACA;AAAA,IACF;AAAA,EAGE;AAGJ,SAAO,MAAM,IAAI,QAAQ,MAAM;AAG/B,SAAO,KAAK,OAAO,QAAQ,OAAO,SAAS;AAC3C,SAAO,KAAK,OAAO,SAAS,OAAO,UAAU;AAC/C;"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { ApplicationOptions, Ticker, TickerCallback } from "pixi.js";
|
|
2
2
|
import { Application } from "pixi.js";
|
|
3
3
|
import type { JSX, ParentProps, Ref } from "solid-js";
|
|
4
|
+
export type PixiScreenDimensions = {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
left: number;
|
|
8
|
+
right: number;
|
|
9
|
+
bottom: number;
|
|
10
|
+
top: number;
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
4
14
|
/**
|
|
5
15
|
* A custom SolidJS hook to access the root PIXI.Application instance.
|
|
6
16
|
* This hook must be called from a component that is a descendant of `PixiApplication`.
|
|
@@ -94,3 +104,11 @@ export declare const createAsyncDelay: () => ((delayMs: number) => Promise<void>
|
|
|
94
104
|
*
|
|
95
105
|
*/
|
|
96
106
|
export declare const delay: (delayMs: number, callback?: () => void) => void;
|
|
107
|
+
/**
|
|
108
|
+
* A hook that provides the current dimensions of the Pixi application's screen as a reactive object.
|
|
109
|
+
* The properties of the returned object will update automatically when the screen size changes and can be subscribed to reactively.
|
|
110
|
+
*
|
|
111
|
+
* @returns An object containing the width and height of the Pixi screen.
|
|
112
|
+
* @throws Will throw an error if not used within a `<PixiApplication>` component.
|
|
113
|
+
*/
|
|
114
|
+
export declare const usePixiScreen: () => Readonly<PixiScreenDimensions>;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component-creation.js","sources":["../src/component-creation.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { createRenderEffect, on, splitProps } from \"solid-js\";\nimport type { PixiEventHandlerMap } from \"./pixi-events\";\nimport { PIXI_SOLID_EVENT_HANDLER_NAMES } from \"./pixi-events\";\nimport { insert, setProp } from \"./renderer\";\n\n/**\n * Prop definition for components that CAN have children\n */\nexport type ContainerProps<Component> = PixiEventHandlerMap & {\n ref?: Ref<Component>;\n as?: Component;\n children?: JSX.Element;\n};\n\n/**\n * Prop definition for components that CANNOT have children\n */\nexport type LeafProps<Component> = Omit<ContainerProps<Component>, \"children\">;\n\n/**\n * Prop definition for filter components\n */\nexport type FilterProps<Component> = {\n ref?: Ref<Component>;\n as?: Component;\n};\n\n// Keys that are specific to Solid components and not Pixi props\nexport const SOLID_PROP_KEYS = [\"ref\", \"as\", \"children\"] as const;\n\n/**\n * Apply's the props to a Pixi instance with subsriptions to maintain reactivity.\n *\n * @param instance The Pixi instance we want to apply props to.\n * @param props The props object.\n * @param defer Defers the createRenderEffect so the props aren't set on the first run.\n * This is useful because setting initialisation props can have unintended side effects.\n * Notibly in AnimatedSprite, if we set the textures roperty after instantiation it will stop the instance from playing.\n */\nexport const applyProps = <\n InstanceType extends Pixi.Container,\n OptionsType extends ContainerProps<InstanceType>,\n>(\n instance: InstanceType,\n props: OptionsType,\n defer?: boolean,\n) => {\n for (const key in props) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n } else if (key === \"children\") {\n if (!(\"addChild\" in instance)) {\n throw new Error(`Cannot set children on non-container instance.`);\n }\n createRenderEffect(() => {\n insert(instance, () => props.children);\n });\n } else if (defer) {\n createRenderEffect(\n on(\n () => props[key as keyof typeof props],\n () => {\n setProp(instance, key, props[key as keyof typeof props]);\n },\n { defer },\n ),\n );\n } else {\n createRenderEffect(() => {\n setProp(instance, key, props[key as keyof typeof props]);\n });\n }\n }\n};\n\nexport const createContainerComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (\n props: Omit<OptionsType, \"children\"> & ContainerProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, [\n ...SOLID_PROP_KEYS,\n ...PIXI_SOLID_EVENT_HANDLER_NAMES,\n ]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n applyProps(instance, initialisationProps, true);\n applyProps(instance, runtimeProps);\n\n return instance as InstanceType & JSX.Element;\n };\n};\n\nexport const createLeafComponent = <\n InstanceType extends Pixi.Container,\n OptionsType extends object,\n>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (\n props: Omit<OptionsType, \"children\"> & LeafProps<InstanceType>,\n ): InstanceType & JSX.Element => {\n return createContainerComponent<InstanceType, OptionsType>(PixiClass)(props);\n };\n};\n\nexport const createFilterComponent = <InstanceType extends Pixi.Filter, OptionsType extends object>(\n PixiClass: new (props: OptionsType) => InstanceType,\n) => {\n return (props: OptionsType & FilterProps<InstanceType>): InstanceType & JSX.Element => {\n const [runtimeProps, initialisationProps] = splitProps(props, [\"ref\", \"as\"]);\n\n const instance = props.as || new PixiClass(initialisationProps as any);\n\n for (const key in initialisationProps) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n } else if (key === \"children\") {\n throw new Error(`Cannot set children on non-container instance.`);\n } else {\n createRenderEffect(\n on(\n () => props[key as keyof typeof initialisationProps],\n () => {\n (instance as any)[key] = initialisationProps[key];\n },\n { defer: true },\n ),\n );\n }\n }\n\n for (const key in runtimeProps) {\n if (key === \"as\") continue;\n\n if (key === \"ref\") {\n createRenderEffect(() => {\n // Solid converts the ref prop to a callback function\n (props[key] as unknown as (arg: any) => void)(instance);\n });\n }\n }\n\n return instance as InstanceType & JSX.Element;\n };\n};\n"],"names":[],"mappings":";;;AA8BO,MAAM,kBAAkB,CAAC,OAAO,MAAM,UAAU;AAWhD,MAAM,aAAa,CAIxB,UACA,OACA,UACG;AACH,aAAW,OAAO,OAAO;AACvB,QAAI,QAAQ,KAAM;AAElB,QAAI,QAAQ,OAAO;AACjB,yBAAmB,MAAM;AAEtB,cAAM,GAAG,EAAoC,QAAQ;AAAA,MACxD,CAAC;AAAA,IACH,WAAW,QAAQ,YAAY;AAC7B,UAAI,EAAE,cAAc,WAAW;AAC7B,cAAM,IAAI,MAAM,gDAAgD;AAAA,MAClE;AACA,yBAAmB,MAAM;AACvB,eAAO,UAAU,MAAM,MAAM,QAAQ;AAAA,MACvC,CAAC;AAAA,IACH,WAAW,OAAO;AAChB;AAAA,QACE;AAAA,UACE,MAAM,MAAM,GAAyB;AAAA,UACrC,MAAM;AACJ,oBAAQ,UAAU,KAAK,MAAM,GAAyB,CAAC;AAAA,UACzD;AAAA,UACA,EAAE,MAAA;AAAA,QAAM;AAAA,MACV;AAAA,IAEJ,OAAO;AACL,yBAAmB,MAAM;AACvB,gBAAQ,UAAU,KAAK,MAAM,GAAyB,CAAC;AAAA,MACzD,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,MAAM,2BAA2B,CAItC,cACG;AACH,SAAO,CACL,UAC+B;AAC/B,UAAM,CAAC,cAAc,mBAAmB,IAAI,WAAW,OAAO;AAAA,MAC5D,GAAG;AAAA,MACH,GAAG;AAAA,IAAA,CACJ;AAED,UAAM,WAAW,MAAM,MAAM,IAAI,UAAU,mBAA0B;AAErE,eAAW,UAAU,qBAAqB,IAAI;AAC9C,eAAW,UAAU,YAAY;AAEjC,WAAO;AAAA,EACT;AACF;AAEO,MAAM,sBAAsB,CAIjC,cACG;AACH,SAAO,CACL,UAC+B;AAC/B,WAAO,yBAAoD,SAAS,EAAE,KAAK;AAAA,EAC7E;AACF;"}
|
package/dist/on-resize.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"on-resize.js","sources":["../src/on-resize.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { onCleanup } from \"solid-js\";\nimport { getPixiApp } from \"./pixi-application\";\n\n/**\n * A SolidJS hook that runs a callback function whenever the PixiJS renderer is resized.\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 * Because we listen for the renderer's \"resize\" event, this hook will work correctly whether the window is resized or just the DOM element the PixiCanvas is inside changes size.\n */\nexport const onResize = (resizeCallback: (screen: Pixi.Rectangle) => void): void => {\n const app = getPixiApp();\n\n const handleResize = () => {\n resizeCallback(app.renderer.screen);\n };\n\n handleResize();\n\n app.renderer.addListener(\"resize\", handleResize);\n\n onCleanup(() => {\n app.renderer.removeListener(\"resize\", handleResize);\n });\n};\n"],"names":[],"mappings":";;AAWO,MAAM,WAAW,CAAC,mBAA2D;AAClF,QAAM,MAAM,WAAA;AAEZ,QAAM,eAAe,MAAM;AACzB,mBAAe,IAAI,SAAS,MAAM;AAAA,EACpC;AAEA,eAAA;AAEA,MAAI,SAAS,YAAY,UAAU,YAAY;AAE/C,YAAU,MAAM;AACd,QAAI,SAAS,eAAe,UAAU,YAAY;AAAA,EACpD,CAAC;AACH;"}
|
|
@@ -1 +0,0 @@
|
|
|
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 getPixiApp = () => {\n const app = useContext(PixiAppContext);\n if (!app) {\n throw new Error(\"getPixiApp must be used within a PixiApplication\");\n }\n return app;\n};\n\n/**\n * Props for the `PixiApplication` component. It extends the PIXI.ApplicationOptions\n * to allow passing configuration directly to the Pixi.js Application constructor,\n * but omits properties that are handled by the component itself.\n */\nexport type PixiApplicationProps = Partial<Omit<ApplicationOptions, \"children\" | \"resizeTo\">> & {\n ref?: Ref<Application>;\n children?: JSX.Element;\n};\n\n/**\n * A SolidJS component that creates and manages a PIXI.Application instance.\n * It provides the application instance through context to be used by child components\n * and custom hooks like `getPixiApp`, `onTick`, and `getTicker`.\n *\n * This component should only be used once in your application.\n *\n * @param props The properties to configure the Pixi.js Application.\n *\n */\nexport const PixiApplication = (props: PixiApplicationProps) => {\n const [, initialisationProps] = splitProps(props, [\"ref\", \"children\"]);\n\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 `onTick` and `getTicker` hooks so we can run tests that use them without having to instantate a Pixi Application.\n *\n * You need to pass in the ticker instance you want to use so it can be manually controled form the outside for testing.\n */\nexport const TickerProvider = (props: TickerProviderProps) => {\n return <TickerContext.Provider value={props.ticker}>{props.children}</TickerContext.Provider>;\n};\n\n/**\n * getTicker\n *\n * A custom SolidJS hook that provides access to the PIXI.Application's shared Ticker instance.\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n * Or a descendant of `TickerProvider` if being used for testing without an application.\n *\n * @returns The PIXI.Ticker instance from the application context.\n * @throws Will throw an error if used outside of a `PixiApplication` or `TickerProvider` context.\n */\nexport const getTicker = (): Ticker => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\"getTicker must be used within a PixiApplication or a TickerProvider\");\n }\n return ticker;\n};\n\n/**\n * onTick\n *\n * A custom SolidJS hook that registers a callback function to be executed on every frame\n * of the PIXI.Application's ticker. The callback is automatically removed when the\n * component or hook's owning computation is cleaned up.\n *\n * This hook must be called from a component that is a descendant of `PixiApplication`.\n * Or a descendant of `TickerProvider` if being used for testing without an application.\n *\n * @param tickerCallback - The function to call on each ticker update. It receives\n * the `PIXI.Ticker` instance as its argument.\n *\n */\nexport const onTick = (tickerCallback: TickerCallback<Ticker>): void => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\"onTick must be used within a PixiApplication or a TickerProvider\");\n }\n\n ticker.add(tickerCallback);\n onCleanup(() => {\n ticker.remove(tickerCallback);\n });\n};\n\nconst asyncDelay = async (ticker: Ticker, delayMs: number) => {\n let timeDelayed = 0;\n\n let resolvePromise: (value: void | PromiseLike<void>) => void;\n\n const promise = new Promise<void>((resolve) => {\n resolvePromise = resolve;\n });\n\n const internalCallback = () => {\n timeDelayed += ticker.deltaMS;\n if (timeDelayed < delayMs) return;\n resolvePromise();\n };\n\n ticker.add(internalCallback);\n\n await promise;\n\n ticker.remove(internalCallback);\n};\n\n/**\n * Create a delay function that waits until a given number of milliseconds has passed on the current Ticker context before resolving.\n *\n * This function must be called inside a `PixiApplication` or `TickerProvider` context.\n *\n * @returns An async function we can await to delay events in sync with time passed on the Ticker.\n *\n * Simply await for it to resolve in an async context.\n *\n * @note It will not resolve if the ticker is paused or stopped.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n */\nexport const createAsyncDelay = (): ((delayMs: number) => Promise<void>) => {\n const ticker = useContext(TickerContext);\n\n if (!ticker) {\n throw new Error(\n \"`createDelay` must be used within a PixiApplication or a TickerProvider. The returned `delay` function can be called in an async context but `createDelay` must be called in a synchronous scope within a PixiApplication or a TickerProvider\"\n );\n }\n const delayWithTicker = (delayMs: number) => asyncDelay(ticker, delayMs);\n\n return delayWithTicker;\n};\n\n/**\n * Runs a callback when a given number of milliseconds has passed on the ticker.\n *\n * It is guaranteed to be in sync with the shared ticker and uses accumulated deltaMs not an external time measurement.\n *\n * @param delayMs - Number of milliseconds to wait (measured in the ticker's time units).\n *\n * @param callback - A callback function that will fire when the delayMs time has passed.\n *\n * @throws {Error} If called outside of a `PixiApplication` or `TickerProvider` context.\n *\n * @note It will not run the callback if the ticker is paused or stopped.\n *\n */\nexport const delay = (delayMs: number, callback?: () => void): void => {\n const ticker = useContext(TickerContext);\n if (!ticker) {\n throw new Error(\n \"`createDelay` must be used within a PixiApplication or a TickerProvider. The returned `delay` function can be called in an async context but `createDelay` must be called in a synchronous scope within a PixiApplication or a TickerProvider\"\n );\n }\n\n let timeDelayed = 0;\n\n const internalCallback = () => {\n timeDelayed += ticker.deltaMS;\n if (timeDelayed < delayMs) return;\n callback?.();\n ticker.remove(internalCallback);\n };\n\n ticker.add(internalCallback);\n};\n"],"names":["PixiAppContext","createContext","TickerContext","getPixiApp","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","getTicker","onTick","tickerCallback","add","remove","asyncDelay","delayMs","timeDelayed","resolvePromise","promise","Promise","resolve","internalCallback","deltaMS","createAsyncDelay","delayWithTicker","delay","callback"],"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;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kE;AAAA,EACpF;AAEAkB,SAAOe,IAAID,cAAc;AACzBX,YAAU,MAAM;AACdH,WAAOgB,OAAOF,cAAc;AAAA,EAC9B,CAAC;AACH;AAEA,MAAMG,aAAa,OAAOjB,QAAgBkB,YAAoB;AAC5D,MAAIC,cAAc;AAElB,MAAIC;AAEJ,QAAMC,UAAU,IAAIC,QAAeC,CAAAA,YAAY;AAC7CH,qBAAiBG;AAAAA,EACnB,CAAC;AAED,QAAMC,mBAAmBA,MAAM;AAC7BL,mBAAenB,OAAOyB;AACtB,QAAIN,cAAcD,QAAS;AAC3BE,mBAAAA;AAAAA,EACF;AAEApB,SAAOe,IAAIS,gBAAgB;AAE3B,QAAMH;AAENrB,SAAOgB,OAAOQ,gBAAgB;AAChC;AAeO,MAAME,mBAAmBA,MAA4C;AAC1E,QAAM1B,SAASnB,WAAWH,aAAa;AAEvC,MAAI,CAACsB,QAAQ;AACX,UAAM,IAAIlB,MACR,+OACF;AAAA,EACF;AACA,QAAM6C,kBAAkBA,CAACT,YAAoBD,WAAWjB,QAAQkB,OAAO;AAEvE,SAAOS;AACT;AAgBO,MAAMC,QAAQA,CAACV,SAAiBW,aAAgC;AACrE,QAAM7B,SAASnB,WAAWH,aAAa;AACvC,MAAI,CAACsB,QAAQ;AACX,UAAM,IAAIlB,MACR,+OACF;AAAA,EACF;AAEA,MAAIqC,cAAc;AAElB,QAAMK,mBAAmBA,MAAM;AAC7BL,mBAAenB,OAAOyB;AACtB,QAAIN,cAAcD,QAAS;AAC3BW,eAAAA;AACA7B,WAAOgB,OAAOQ,gBAAgB;AAAA,EAChC;AAEAxB,SAAOe,IAAIS,gBAAgB;AAC7B;"}
|
package/dist/pixi-canvas.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pixi-canvas.js","sources":["../src/pixi-canvas.tsx"],"sourcesContent":["import type { JSX } from \"solid-js\";\nimport { createRenderEffect, onCleanup, onMount } from \"solid-js\";\nimport { getPixiApp } from \"./pixi-application\";\n\n/**\n * PixiCanvas\n *\n * A small wrapper that mounts the PIXI application's canvas element into the DOM\n * and automatically resizes it.\n *\n * - Requires a surrounding `PixiApplication` component.\n * - Requires a `PixiStage` component as a child.\n *\n * Props:\n * @param props.children - JSX content to render inside the canvas wrapper. Use `PixiStage` as the only child.\n */\n\nexport const PixiCanvas = (props: {\n children: JSX.Element;\n style?: JSX.CSSProperties | undefined;\n className?: string;\n}): JSX.Element => {\n let canvasWrapElement: HTMLDivElement | undefined;\n\n const pixiApp = getPixiApp();\n pixiApp.canvas.style.display = \"block\";\n pixiApp.canvas.style.position = \"absolute\";\n pixiApp.canvas.style.top = \"0\";\n pixiApp.canvas.style.left = \"0\";\n pixiApp.canvas.style.width = \"100%\";\n pixiApp.canvas.style.height = \"100%\";\n\n createRenderEffect(() => {\n if (props.children === undefined) {\n throw new Error(\"PixiCanvas requires the `PixiStage` component to render.\");\n }\n });\n\n let previousResizeTo: typeof pixiApp.resizeTo;\n let resizeObserver: ResizeObserver | undefined;\n\n onMount(() => {\n if (!canvasWrapElement) return;\n previousResizeTo = pixiApp.resizeTo;\n pixiApp.resizeTo = canvasWrapElement;\n pixiApp.queueResize();\n resizeObserver = new ResizeObserver(() => {\n pixiApp.queueResize();\n });\n resizeObserver.observe(canvasWrapElement);\n });\n\n onCleanup(() => {\n if (!canvasWrapElement) return;\n pixiApp.resizeTo = previousResizeTo;\n resizeObserver?.disconnect();\n resizeObserver = undefined;\n });\n\n return (\n <div\n ref={canvasWrapElement}\n style={{\n position: \"relative\",\n ...(typeof props.style === \"object\" ? props.style : {}),\n }}\n class={props.className}\n >\n {pixiApp.canvas}\n </div>\n );\n};\n"],"names":["PixiCanvas","props","canvasWrapElement","pixiApp","getPixiApp","canvas","style","display","position","top","left","width","height","createRenderEffect","children","undefined","Error","previousResizeTo","resizeObserver","onMount","resizeTo","queueResize","ResizeObserver","observe","onCleanup","disconnect","_el$","_tmpl$","_ref$","_$use","_$insert","_$effect","_p$","_v$","_v$2","className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AF,eAAAF,IAAAM,KAAAC,UAAAb,MAAAM,IAAAM,IAAAJ,IAAA;AAAA,aAAAF;AAAAA,IAAA,GAAA;AAAA,MAAAI,GAAArB;AAAAA,MAAAuB,GAAAvB;AAAAA,IAAAA,CAAA;AAAA,WAAAW;AAAAA,EAAA,GAAA;AAK5B;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pixi-components.js","sources":["../src/pixi-components.tsx"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport {\n AnimatedSprite as PixiAnimatedSprite,\n BitmapText as PixiBitmapText,\n Container as PixiContainer,\n Graphics as PixiGraphics,\n HTMLText as PixiHTMLText,\n MeshPlane as PixiMeshPlane,\n MeshRope as PixiMeshRope,\n NineSliceSprite as PixiNineSliceSprite,\n ParticleContainer as PixiParticleContainer,\n PerspectiveMesh as PixiPerspectiveMesh,\n RenderContainer as PixiRenderContainer,\n RenderLayer as PixiRenderLayer,\n Sprite as PixiSprite,\n Text as PixiText,\n TilingSprite as PixiTilingSprite,\n} from \"pixi.js\";\nimport { createContainerComponent, createLeafComponent } from \"./component-creation\";\n\n/**\n * A SolidJS component that renders a `PIXI.AnimatedSprite`.\n */\nexport const AnimatedSprite = createLeafComponent<PixiAnimatedSprite, Pixi.AnimatedSpriteOptions>(PixiAnimatedSprite);\n/**\n * A SolidJS component that renders a `PIXI.BitmapText`.\n */\nexport const BitmapText = createLeafComponent<PixiBitmapText, Pixi.TextOptions>(PixiBitmapText);\n/**\n * A SolidJS component that renders a `PIXI.Container`.\n */\nexport const Container = createContainerComponent<PixiContainer, Pixi.ContainerOptions>(PixiContainer);\n/**\n * A SolidJS component that renders a `PIXI.Graphics`.\n * Use a ref to access the underlying graphics instance and draw with it.\n */\nexport const Graphics = createLeafComponent<PixiGraphics, Pixi.GraphicsOptions>(PixiGraphics);\n/**\n * A SolidJS component that renders a `PIXI.HTMLText`.\n */\nexport const HTMLText = createLeafComponent<PixiHTMLText, Pixi.HTMLTextOptions>(PixiHTMLText);\n\n/**\n * A SolidJS component that renders a `PIXI.MeshPlane`.\n */\nexport const MeshPlane = createLeafComponent<PixiMeshPlane, Pixi.MeshPlaneOptions>(PixiMeshPlane);\n\n/**\n * A SolidJS component that renders a `PIXI.MeshRope`.\n */\nexport const MeshRope = createLeafComponent<PixiMeshRope, Pixi.MeshRopeOptions>(PixiMeshRope);\n\n/**\n * A SolidJS component that renders a `PIXI.NineSliceSprite`.\n */\nexport const NineSliceSprite = createLeafComponent<PixiNineSliceSprite, Pixi.NineSliceSpriteOptions>(\n PixiNineSliceSprite\n);\n\n/**\n * A SolidJS component that renders a `PIXI.ParticleContainer`.\n *\n * Particles should be added and removed from this component imperatively. Please see the docs for a reference example.\n */\nexport const ParticleContainer = createLeafComponent<PixiParticleContainer, Pixi.ParticleContainerOptions>(\n PixiParticleContainer\n);\n\n/**\n * A SolidJS component that renders a `PIXI.PerspectiveMesh`.\n */\nexport const PerspectiveMesh = createLeafComponent<PixiPerspectiveMesh, Pixi.PerspectivePlaneOptions>(\n PixiPerspectiveMesh\n);\n\n/**\n * A SolidJS component that renders a `PIXI.RenderContainer`.\n */\nexport const RenderContainer = createContainerComponent<PixiRenderContainer, Pixi.RenderContainerOptions>(\n PixiRenderContainer\n);\n\n/**\n * A SolidJS component that renders a `PIXI.RenderLayer`.\n */\nexport const RenderLayer = createContainerComponent<PixiRenderLayer, Pixi.RenderLayerOptions>(PixiRenderLayer);\n\n/**\n * A SolidJS component that renders a `PIXI.Sprite`.\n */\nexport const Sprite = createLeafComponent<PixiSprite, Pixi.SpriteOptions>(PixiSprite);\n/**\n * A SolidJS component that renders a `PIXI.Text`.\n */\nexport const Text = createLeafComponent<PixiText, Pixi.CanvasTextOptions>(PixiText);\n\n/**\n * A SolidJS component that renders a `PIXI.TilingSprite`.\n */\nexport const TilingSprite = createLeafComponent<PixiTilingSprite, Pixi.TilingSpriteOptions>(PixiTilingSprite);\n\n// export const MeshGeometry = createLeafComponent<PixiMeshGeometry, Pixi.MeshGeometryOptions>(PixiMeshGeometry);\n\n// export const NineSliceGeometry = createLeafComponent<PixiNineSliceGeometry, Pixi.NineSliceGeometryOptions>(\n// PixiNineSliceGeometry\n// );\n\n// export const Particle = createLeafComponent<PixiParticle, Pixi.ParticleOptions>(PixiParticle);\n\n// export const PerspectivePlaneGeometry = createLeafComponent<\n// PixiPerspectivePlaneGeometry,\n// Pixi.PerspectivePlaneGeometryOptions\n// >(PixiPerspectivePlaneGeometry);\n\n// export const PlaneGeometry = createLeafComponent<PixiPlaneGeometry, Pixi.PlaneGeometryOptions>(PixiPlaneGeometry);\n\n// export const RopeGeometry = createLeafComponent<PixiRopeGeometry, Pixi.RopeGeometryOptions>(PixiRopeGeometry);\n\n// TODO: Do we need a component for the Culler. It needs to interact with the stage directly.\n// export const Culler = createLeafComponent<PixiCuller, Pixi.Culler>(PixiCuller);\n"],"names":["AnimatedSprite","createLeafComponent","PixiAnimatedSprite","BitmapText","PixiBitmapText","Container","createContainerComponent","PixiContainer","Graphics","PixiGraphics","HTMLText","PixiHTMLText","MeshPlane","PixiMeshPlane","MeshRope","PixiMeshRope","NineSliceSprite","PixiNineSliceSprite","ParticleContainer","PixiParticleContainer","PerspectiveMesh","PixiPerspectiveMesh","RenderContainer","PixiRenderContainer","RenderLayer","PixiRenderLayer","Sprite","PixiSprite","Text","PixiText","TilingSprite","PixiTilingSprite"],"mappings":";;AAuBO,MAAMA,iBAAiBC,oBAAoEC,gBAAkB;AAI7G,MAAMC,aAAaF,oBAAsDG,YAAc;AAIvF,MAAMC,YAAYC,yBAA+DC,WAAa;AAK9F,MAAMC,WAAWP,oBAAwDQ,UAAY;AAIrF,MAAMC,WAAWT,oBAAwDU,UAAY;AAKrF,MAAMC,YAAYX,oBAA0DY,WAAa;AAKzF,MAAMC,WAAWb,oBAAwDc,UAAY;AAKrF,MAAMC,kBAAkBf,oBAC7BgB,iBACF;AAOO,MAAMC,oBAAoBjB,oBAC/BkB,mBACF;AAKO,MAAMC,kBAAkBnB,oBAC7BoB,iBACF;AAKO,MAAMC,kBAAkBhB,yBAC7BiB,iBACF;AAKO,MAAMC,cAAclB,yBAAmEmB,aAAe;AAKtG,MAAMC,SAASzB,oBAAoD0B,QAAU;AAI7E,MAAMC,OAAO3B,oBAAsD4B,MAAQ;AAK3E,MAAMC,eAAe7B,oBAAgE8B,cAAgB;"}
|
package/dist/pixi-events.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pixi-events.js","sources":["../src/pixi-events.ts"],"sourcesContent":["import type { FederatedEventEmitterTypes } from \"pixi.js\";\n\nexport const PIXI_EVENT_NAMES: (keyof FederatedEventEmitterTypes)[] = [\n \"click\",\n \"mousedown\",\n \"mouseenter\",\n \"mouseleave\",\n \"mousemove\",\n \"mouseout\",\n \"mouseover\",\n \"mouseup\",\n \"mouseupoutside\",\n \"pointercancel\",\n \"pointerdown\",\n \"pointerenter\",\n \"pointerleave\",\n \"pointermove\",\n \"pointerout\",\n \"pointerover\",\n \"pointertap\",\n \"pointerup\",\n \"pointerupoutside\",\n \"rightclick\",\n \"rightdown\",\n \"rightup\",\n \"rightupoutside\",\n \"tap\",\n \"touchcancel\",\n \"touchend\",\n \"touchendoutside\",\n \"touchmove\",\n \"touchstart\",\n \"wheel\",\n \"globalmousemove\",\n \"globalpointermove\",\n \"globaltouchmove\",\n \"clickcapture\",\n \"mousedowncapture\",\n \"mouseentercapture\",\n \"mouseleavecapture\",\n \"mousemovecapture\",\n \"mouseoutcapture\",\n \"mouseovercapture\",\n \"mouseupcapture\",\n \"mouseupoutsidecapture\",\n \"pointercancelcapture\",\n \"pointerdowncapture\",\n \"pointerentercapture\",\n \"pointerleavecapture\",\n \"pointermovecapture\",\n \"pointeroutcapture\",\n \"pointerovercapture\",\n \"pointertapcapture\",\n \"pointerupcapture\",\n \"pointerupoutsidecapture\",\n \"rightclickcapture\",\n \"rightdowncapture\",\n \"rightupcapture\",\n \"rightupoutsidecapture\",\n \"tapcapture\",\n \"touchcancelcapture\",\n \"touchendcapture\",\n \"touchendoutsidecapture\",\n \"touchmovecapture\",\n \"touchstartcapture\",\n \"wheelcapture\",\n] as const;\n\nexport const PIXI_SOLID_EVENT_HANDLER_NAMES = PIXI_EVENT_NAMES.map(\n (eventName) => `on${eventName}` as const,\n);\n\nexport type PixiEventHandlerMap = {\n [K in (typeof PIXI_EVENT_NAMES)[number] as `on${K}`]?:\n | null\n | ((...args: FederatedEventEmitterTypes[K]) => void);\n};\n\nexport const PIXI_EVENT_HANDLER_NAME_SET: Readonly<\n Set<(typeof PIXI_SOLID_EVENT_HANDLER_NAMES)[number]>\n> = new Set(PIXI_SOLID_EVENT_HANDLER_NAMES);\n\n/**\n * This is a type-safe check that ensures `PIXI_EVENT_NAMES` includes every key from Pixi's `AllFederatedEventMap` type.\n * It will cause a build error if any event names are missing.\n */\ntype MissingKeys = Exclude<keyof FederatedEventEmitterTypes, (typeof PIXI_EVENT_NAMES)[number]>;\ntype AllEventsAreHandled = MissingKeys extends never\n ? true\n : `Error: Missing event keys: ${MissingKeys}`;\nconst allEventsAreHandled: AllEventsAreHandled = true;\nvoid allEventsAreHandled;\n"],"names":[],"mappings":"AAEO,MAAM,mBAAyD;AAAA,EACpE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,iCAAiC,iBAAiB;AAAA,EAC7D,CAAC,cAAc,KAAK,SAAS;AAC/B;AAQO,MAAM,8BAET,IAAI,IAAI,8BAA8B;"}
|
package/dist/pixi-stage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pixi-stage.js","sources":["../src/pixi-stage.tsx"],"sourcesContent":["import type { Container, ContainerOptions } from \"pixi.js\";\nimport type { JSX, Ref } from \"solid-js\";\nimport { applyProps } from \"./component-creation\";\nimport { getPixiApp } from \"./pixi-application\";\nimport type { PixiEventHandlerMap } from \"./pixi-events\";\n\nexport type PixiStageProps = PixiEventHandlerMap &\n Omit<ContainerOptions, \"children\"> & {\n ref?: Ref<Container>;\n children?: JSX.Element;\n };\n\n/**\n * PixiStage\n *\n * The root container for rendering Pixi display objects. This component\n * uses the application stage (`pixiApp.stage`) as the mount point and\n * applies props and event handlers to it.\n *\n * Props:\n * - `ref` (optional): receives the stage container reference.\n * - Event handler props (e.g. `onpointerdown`) are forwarded to the stage.\n * - Any other container options supported by Pixi may be passed.\n *\n * Children passed to `PixiStage` are inserted into the application stage.\n */\nexport const PixiStage = (props: PixiStageProps): JSX.Element => {\n const pixiApp = getPixiApp();\n\n applyProps(pixiApp.stage, props);\n\n return <>{pixiApp.stage}</>;\n};\n"],"names":["PixiStage","props","pixiApp","getPixiApp","applyProps","stage","_$memo"],"mappings":";;;AA0BO,MAAMA,YAAYA,CAACC,UAAuC;AAC/D,QAAMC,UAAUC,WAAAA;AAEhBC,aAAWF,QAAQG,OAAOJ,KAAK;AAE/B,SAAAK,KAAA,MAAUJ,QAAQG,KAAK;AACzB;"}
|
package/dist/renderer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sources":["../src/renderer.tsx"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { Text as PixiText } from \"pixi.js\";\nimport { createRenderer } from \"solid-js/universal\";\nimport type { PIXI_EVENT_NAMES, PixiEventHandlerMap } from \"./pixi-events\";\nimport { PIXI_EVENT_HANDLER_NAME_SET } from \"./pixi-events\";\n\nexport const {\n effect,\n memo,\n createComponent,\n createElement,\n createTextNode,\n insertNode,\n insert,\n setProp,\n mergeProps,\n use,\n render,\n spread,\n} = createRenderer<Pixi.Container>({\n createElement(name: string) {\n // This function is for lowercase string tags like `<container />`.\n // To support tree-shaking, we require users to import components\n // directly and use them with an uppercase name like `<Container />`,\n // which does not call this function.\n throw new Error(\n `Cannot create element \"${name}\". Please import components directly from 'pixi-solid' and use them with a capital letter.`\n );\n },\n createTextNode(value) {\n return new PixiText({ text: value });\n },\n replaceText(textNode: PixiText, value) {\n textNode.text = value;\n },\n setProperty(node, name, value, prev) {\n if (name in node) {\n (node as any)[name] = value;\n return;\n }\n\n // Check for event listeners and handle them appropriately.\n if (PIXI_EVENT_HANDLER_NAME_SET.has(name as keyof PixiEventHandlerMap)) {\n // Remove the 'on' prefix to get the actual event name.\n const eventName = name.slice(2) as (typeof PIXI_EVENT_NAMES)[number];\n\n if (prev) {\n node.removeEventListener(eventName, prev as any);\n }\n node.addEventListener(eventName, value as any);\n return;\n }\n },\n insertNode(parent, node, anchor) {\n // RenderLayer uses `attach` instead of `addChild`.\n if (\"attach\" in parent && typeof parent.attach === \"function\") {\n parent.attach(node);\n // Note: `attach` does not support anchoring, so we ignore the anchor.\n return;\n }\n\n if (!(\"addChildAt\" in parent) || !(\"addChild\" in parent) || typeof parent.addChild !== \"function\") {\n throw new Error(\"Parent does not support children.\");\n }\n\n if (anchor) {\n parent.addChildAt(node, parent.children.indexOf(anchor));\n } else {\n parent.addChild(node);\n }\n },\n isTextNode(node) {\n return node instanceof PixiText;\n },\n removeNode(_, node) {\n // RenderLayer uses `detach` instead of `removeChild`.\n if (\"detach\" in parent && typeof parent.detach === \"function\") {\n parent.detach(node);\n return;\n }\n\n node.removeFromParent();\n // TODO: Do we need to destroy nodes? When can we do it?\n // node.destroy({ children: true });\n },\n getParentNode(node) {\n return node?.parent ?? undefined;\n },\n getFirstChild(node) {\n return node.children?.[0];\n },\n getNextSibling(node) {\n if (!node.parent) return undefined;\n const index = node.parent.children.indexOf(node);\n // Return the next child if it exists, otherwise undefined.\n return index > -1 ? node.parent.children[index + 1] : undefined;\n },\n});\n"],"names":["effect","memo","createComponent","createElement","createTextNode","insertNode","insert","setProp","mergeProps","use","render","spread","createRenderer","name","Error","value","PixiText","text","replaceText","textNode","setProperty","node","prev","PIXI_EVENT_HANDLER_NAME_SET","has","eventName","slice","removeEventListener","addEventListener","parent","anchor","attach","addChild","addChildAt","children","indexOf","isTextNode","removeNode","_","detach","removeFromParent","getParentNode","undefined","getFirstChild","getNextSibling","index"],"mappings":";;;AAMO,MAAM;AAAA,EACXA;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACF,IAAIC,eAA+B;AAAA,EACjCT,cAAcU,MAAc;AAK1B,UAAM,IAAIC,MACR,0BAA0BD,IAAI,4FAChC;AAAA,EACF;AAAA,EACAT,eAAeW,OAAO;AACpB,WAAO,IAAIC,KAAS;AAAA,MAAEC,MAAMF;AAAAA,IAAAA,CAAO;AAAA,EACrC;AAAA,EACAG,YAAYC,UAAoBJ,OAAO;AACrCI,aAASF,OAAOF;AAAAA,EAClB;AAAA,EACAK,YAAYC,MAAMR,MAAME,OAAOO,MAAM;AACnC,QAAIT,QAAQQ,MAAM;AACfA,WAAaR,IAAI,IAAIE;AACtB;AAAA,IACF;AAGA,QAAIQ,4BAA4BC,IA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|
|
1
|
-
{"version":3,"file":"object-fit.js","sources":["../../src/utils/object-fit.ts"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\n\nexport type ObjectFitMode = \"cover\" | \"contain\" | \"fill\" | \"scale-down\";\n\n/**\n * Scale an object to fit within the given bounds according to the specified fit mode.\n * @param object The object to be scaled.\n * @param bounds The bounds it should fit within.\n * @param fitMode The object fit mode to apply.\n */\nexport const objectFit = (\n object: Pixi.Container,\n bounds: { width: number; height: number },\n fitMode: ObjectFitMode,\n): void => {\n const originalWidth = object.width / object.scale.x;\n const originalHeight = object.height / object.scale.y;\n\n if (originalWidth === 0 || originalHeight === 0 || bounds.width === 0 || bounds.height === 0)\n return;\n\n const widthRatio = bounds.width / originalWidth;\n const heightRatio = bounds.height / originalHeight;\n\n let scaleX = 1;\n let scaleY = 1;\n\n switch (fitMode) {\n case \"cover\": {\n const coverScale = Math.max(widthRatio, heightRatio);\n scaleX = coverScale;\n scaleY = coverScale;\n break;\n }\n case \"contain\": {\n const containScale = Math.min(widthRatio, heightRatio);\n scaleX = containScale;\n scaleY = containScale;\n break;\n }\n case \"fill\": {\n scaleX = widthRatio;\n scaleY = heightRatio;\n break;\n }\n case \"scale-down\": {\n // If the object is smaller than the container, it's 'none' (no scaling up).\n // Otherwise, it's 'contain'.\n if (originalWidth <= bounds.width && originalHeight <= bounds.height) {\n scaleX = 1;\n scaleY = 1;\n } else {\n const scaleDown = Math.min(widthRatio, heightRatio);\n scaleX = scaleDown;\n scaleY = scaleDown;\n }\n break;\n }\n default:\n // Default to no scaling if an unknown fitMode is provided\n break;\n }\n\n object.scale.set(scaleX, scaleY);\n\n // Center the object\n object.x = (bounds.width - object.width) / 2;\n object.y = (bounds.height - object.height) / 2;\n};\n"],"names":[],"mappings":"AAUO,MAAM,YAAY,CACvB,QACA,QACA,YACS;AACT,QAAM,gBAAgB,OAAO,QAAQ,OAAO,MAAM;AAClD,QAAM,iBAAiB,OAAO,SAAS,OAAO,MAAM;AAEpD,MAAI,kBAAkB,KAAK,mBAAmB,KAAK,OAAO,UAAU,KAAK,OAAO,WAAW;AACzF;AAEF,QAAM,aAAa,OAAO,QAAQ;AAClC,QAAM,cAAc,OAAO,SAAS;AAEpC,MAAI,SAAS;AACb,MAAI,SAAS;AAEb,UAAQ,SAAA;AAAA,IACN,KAAK,SAAS;AACZ,YAAM,aAAa,KAAK,IAAI,YAAY,WAAW;AACnD,eAAS;AACT,eAAS;AACT;AAAA,IACF;AAAA,IACA,KAAK,WAAW;AACd,YAAM,eAAe,KAAK,IAAI,YAAY,WAAW;AACrD,eAAS;AACT,eAAS;AACT;AAAA,IACF;AAAA,IACA,KAAK,QAAQ;AACX,eAAS;AACT,eAAS;AACT;AAAA,IACF;AAAA,IACA,KAAK,cAAc;AAGjB,UAAI,iBAAiB,OAAO,SAAS,kBAAkB,OAAO,QAAQ;AACpE,iBAAS;AACT,iBAAS;AAAA,MACX,OAAO;AACL,cAAM,YAAY,KAAK,IAAI,YAAY,WAAW;AAClD,iBAAS;AACT,iBAAS;AAAA,MACX;AACA;AAAA,IACF;AAAA,EAGE;AAGJ,SAAO,MAAM,IAAI,QAAQ,MAAM;AAG/B,SAAO,KAAK,OAAO,QAAQ,OAAO,SAAS;AAC3C,SAAO,KAAK,OAAO,SAAS,OAAO,UAAU;AAC/C;"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|