pixi-solid 0.0.23 → 0.0.24

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/renderer.js CHANGED
@@ -27,6 +27,10 @@ const {
27
27
  textNode.text = value;
28
28
  },
29
29
  setProperty(node, name, value, prev) {
30
+ if (name in node) {
31
+ node[name] = value;
32
+ return;
33
+ }
30
34
  if (PIXI_EVENT_HANDLER_NAME_SET.has(name)) {
31
35
  const eventName = name.slice(2);
32
36
  if (prev) {
@@ -35,29 +39,29 @@ const {
35
39
  node.addEventListener(eventName, value);
36
40
  return;
37
41
  }
38
- if (name in node) {
39
- node[name] = value;
40
- return;
41
- }
42
42
  },
43
- insertNode(parent, node, anchor) {
44
- if ("attach" in parent && typeof parent.attach === "function") {
45
- parent.attach(node);
43
+ insertNode(parent2, node, anchor) {
44
+ if ("attach" in parent2 && typeof parent2.attach === "function") {
45
+ parent2.attach(node);
46
46
  return;
47
47
  }
48
- if (!("addChildAt" in parent) || !("addChild" in parent) || typeof parent.addChild !== "function") {
48
+ if (!("addChildAt" in parent2) || !("addChild" in parent2) || typeof parent2.addChild !== "function") {
49
49
  throw new Error("Parent does not support children.");
50
50
  }
51
51
  if (anchor) {
52
- parent.addChildAt(node, parent.children.indexOf(anchor));
52
+ parent2.addChildAt(node, parent2.children.indexOf(anchor));
53
53
  } else {
54
- parent.addChild(node);
54
+ parent2.addChild(node);
55
55
  }
56
56
  },
57
57
  isTextNode(node) {
58
58
  return node instanceof Text;
59
59
  },
60
60
  removeNode(_, node) {
61
+ if ("detach" in parent && typeof parent.detach === "function") {
62
+ parent.detach(node);
63
+ return;
64
+ }
61
65
  node.removeFromParent();
62
66
  node.destroy({
63
67
  children: true
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.js","sources":["../src/renderer.tsx"],"sourcesContent":["import type * as Pixi from \"pixi.js\";\nimport { Text as PixiText } from \"pixi.js\";\nimport { createRenderer } from \"solid-js/universal\";\nimport type { PIXI_EVENT_NAMES, PixiEventHandlerMap } from \"./pixi-events\";\nimport { PIXI_EVENT_HANDLER_NAME_SET } from \"./pixi-events\";\n\nexport const {\n effect,\n memo,\n createComponent,\n createElement,\n createTextNode,\n insertNode,\n insert,\n setProp,\n mergeProps,\n use,\n render,\n spread,\n} = createRenderer<Pixi.Container>({\n createElement(name: string) {\n // This function is for lowercase string tags like `<container />`.\n // To support tree-shaking, we require users to import components\n // directly and use them with an uppercase name like `<Container />`,\n // which does not call this function.\n throw new Error(\n `Cannot create element \"${name}\". Please import components directly from 'pixi-solid' and use them with a capital letter.`\n );\n },\n createTextNode(value) {\n return new PixiText({ text: value });\n },\n replaceText(textNode: PixiText, value) {\n textNode.text = value;\n },\n setProperty(node, name, value, prev) {\n // Check for event listeners and handle them appropriately.\n if (PIXI_EVENT_HANDLER_NAME_SET.has(name as keyof PixiEventHandlerMap)) {\n // Remove the 'on' prefix to get the actual event name.\n const eventName = name.slice(2) as (typeof PIXI_EVENT_NAMES)[number];\n\n if (prev) {\n node.removeEventListener(eventName, prev as any);\n }\n node.addEventListener(eventName, value as any);\n return;\n }\n\n if (name in node) {\n (node as any)[name] = value;\n return;\n }\n },\n insertNode(parent, node, anchor) {\n // RenderLayer uses `attach` instead of `addChild`.\n if (\"attach\" in parent && typeof parent.attach === \"function\") {\n parent.attach(node);\n // Note: `attach` does not support anchoring, so we ignore the anchor.\n return;\n }\n\n if (!(\"addChildAt\" in parent) || !(\"addChild\" in parent) || typeof parent.addChild !== \"function\") {\n throw new Error(\"Parent does not support children.\");\n }\n\n if (anchor) {\n parent.addChildAt(node, parent.children.indexOf(anchor));\n } else {\n parent.addChild(node);\n }\n },\n isTextNode(node) {\n return node instanceof PixiText;\n },\n removeNode(_, node) {\n node.removeFromParent();\n node.destroy({ children: true });\n },\n getParentNode(node) {\n return node?.parent ?? undefined;\n },\n getFirstChild(node) {\n return node.children?.[0];\n },\n getNextSibling(node) {\n if (!node.parent) return undefined;\n const index = node.parent.children.indexOf(node);\n // Return the next child if it exists, otherwise undefined.\n return index > -1 ? node.parent.children[index + 1] : undefined;\n },\n});\n"],"names":["effect","memo","createComponent","createElement","createTextNode","insertNode","insert","setProp","mergeProps","use","render","spread","createRenderer","name","Error","value","PixiText","text","replaceText","textNode","setProperty","node","prev","PIXI_EVENT_HANDLER_NAME_SET","has","eventName","slice","removeEventListener","addEventListener","parent","anchor","attach","addChild","addChildAt","children","indexOf","isTextNode","removeNode","_","removeFromParent","destroy","getParentNode","undefined","getFirstChild","getNextSibling","index"],"mappings":";;;AAMO,MAAM;AAAA,EACXA;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AAAAA,EACAC;AACF,IAAIC,eAA+B;AAAA,EACjCT,cAAcU,MAAc;AAK1B,UAAM,IAAIC,MACR,0BAA0BD,IAAI,4FAChC;AAAA,EACF;AAAA,EACAT,eAAeW,OAAO;AACpB,WAAO,IAAIC,KAAS;AAAA,MAAEC,MAAMF;AAAAA,IAAAA,CAAO;AAAA,EACrC;AAAA,EACAG,YAAYC,UAAoBJ,OAAO;AACrCI,aAASF,OAAOF;AAAAA,EAClB;AAAA,EACAK,YAAYC,MAAMR,MAAME,OAAOO,MAAM;AAEnC,QAAIC,4BAA4BC,IAAIX,IAAiC,GAAG;AAEtE,YAAMY,YAAYZ,KAAKa,MAAM,CAAC;AAE9B,UAAIJ,MAAM;AACRD,aAAKM,oBAAoBF,WAAWH,IAAW;AAAA,MACjD;AACAD,WAAKO,iBAAiBH,WAAWV,KAAY;AAC7C;AAAA,IACF;AAEA,QAAIF,QAAQQ,MAAM;AACfA,WAAaR,IAAI,IAAIE;AACtB;AAAA,IACF;AAAA,EACF;AAAA,EACAV,WAAWwB,QAAQR,MAAMS,QAAQ;AAE/B,QAAI,YAAYD,UAAU,OAAOA,OAAOE,WAAW,YAAY;AAC7DF,aAAOE,OAAOV,IAAI;AAElB;AAAA,IACF;AAEA,QAAI,EAAE,gBAAgBQ,WAAW,EAAE,cAAcA,WAAW,OAAOA,OAAOG,aAAa,YAAY;AACjG,YAAM,IAAIlB,MAAM,mCAAmC;AAAA,IACrD;AAEA,QAAIgB,QAAQ;AACVD,aAAOI,WAAWZ,MAAMQ,OAAOK,SAASC,QAAQL,MAAM,CAAC;AAAA,IACzD,OAAO;AACLD,aAAOG,SAASX,IAAI;AAAA,IACtB;AAAA,EACF;AAAA,EACAe,WAAWf,MAAM;AACf,WAAOA,gBAAgBL;AAAAA,EACzB;AAAA,EACAqB,WAAWC,GAAGjB,MAAM;AAClBA,SAAKkB,iBAAAA;AACLlB,SAAKmB,QAAQ;AAAA,MAAEN,UAAU;AAAA,IAAA,CAAM;AAAA,EACjC;AAAA,EACAO,cAAcpB,MAAM;AAClB,WAAOA,MAAMQ,UAAUa;AAAAA,EACzB;AAAA,EACAC,cAActB,MAAM;AAClB,WAAOA,KAAKa,WAAW,CAAC;AAAA,EAC1B;AAAA,EACAU,eAAevB,MAAM;AACnB,QAAI,CAACA,KAAKQ,OAAQ,QAAOa;AACzB,UAAMG,QAAQxB,KAAKQ,OAAOK,SAASC,QAAQd,IAAI;AAE/C,WAAOwB,QAAQ,KAAKxB,KAAKQ,OAAOK,SAASW,QAAQ,CAAC,IAAIH;AAAAA,EACxD;AACF,CAAC;"}
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,oBAAoBF,WAAWH,IAAW;AAAA,MACjD;AACAD,WAAKO,iBAAiBH,WAAWV,KAAY;AAC7C;AAAA,IACF;AAAA,EACF;AAAA,EACAV,WAAWwB,SAAQR,MAAMS,QAAQ;AAE/B,QAAI,YAAYD,WAAU,OAAOA,QAAOE,WAAW,YAAY;AAC7DF,cAAOE,OAAOV,IAAI;AAElB;AAAA,IACF;AAEA,QAAI,EAAE,gBAAgBQ,YAAW,EAAE,cAAcA,YAAW,OAAOA,QAAOG,aAAa,YAAY;AACjG,YAAM,IAAIlB,MAAM,mCAAmC;AAAA,IACrD;AAEA,QAAIgB,QAAQ;AACVD,cAAOI,WAAWZ,MAAMQ,QAAOK,SAASC,QAAQL,MAAM,CAAC;AAAA,IACzD,OAAO;AACLD,cAAOG,SAASX,IAAI;AAAA,IACtB;AAAA,EACF;AAAA,EACAe,WAAWf,MAAM;AACf,WAAOA,gBAAgBL;AAAAA,EACzB;AAAA,EACAqB,WAAWC,GAAGjB,MAAM;AAElB,QAAI,YAAYQ,UAAU,OAAOA,OAAOU,WAAW,YAAY;AAC7DV,aAAOU,OAAOlB,IAAI;AAClB;AAAA,IACF;AAEAA,SAAKmB,iBAAAA;AACLnB,SAAKoB,QAAQ;AAAA,MAAEP,UAAU;AAAA,IAAA,CAAM;AAAA,EACjC;AAAA,EACAQ,cAAcrB,MAAM;AAClB,WAAOA,MAAMQ,UAAUc;AAAAA,EACzB;AAAA,EACAC,cAAcvB,MAAM;AAClB,WAAOA,KAAKa,WAAW,CAAC;AAAA,EAC1B;AAAA,EACAW,eAAexB,MAAM;AACnB,QAAI,CAACA,KAAKQ,OAAQ,QAAOc;AACzB,UAAMG,QAAQzB,KAAKQ,OAAOK,SAASC,QAAQd,IAAI;AAE/C,WAAOyB,QAAQ,KAAKzB,KAAKQ,OAAOK,SAASY,QAAQ,CAAC,IAAIH;AAAAA,EACxD;AACF,CAAC;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pixi-solid",
3
3
  "private": false,
4
- "version": "0.0.23",
4
+ "version": "0.0.24",
5
5
  "description": "A library to write PixiJS applications with SolidJS",
6
6
  "author": "Luke Thompson",
7
7
  "license": "MIT",