@axion-engine/core 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { AxionContext } from "./axion-platform";
2
- export { AxionCanvas } from "./axion-platform";
3
- export { AxionEngine } from "./axion-platform";
1
+ export { AxionContext } from "./axion-platform/src/context/AxionContext";
2
+ export { AxionCanvas } from "./axion-platform/src/components/AxionCanvas";
3
+ export { AxionEngine } from "./axion-platform/src/context/AxionContext";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../packages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,2CAA2C,CAAA;AACtE,OAAO,EAAC,WAAW,EAAC,MAAM,6CAA6C,CAAA;AACvE,OAAO,EAAC,WAAW,EAAC,MAAM,2CAA2C,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{createContext as d}from"react";import{jsx as f}from"react/jsx-runtime";var o=d(null),s=({worker:i,children:n})=>f(o.Provider,{value:i,children:n});import{useContext as p,useEffect as m,useRef as u}from"react";import{jsx as h}from"react/jsx-runtime";var e=null,l=!1,c=({shadows:i})=>{let n=p(o),a=u(null);return m(()=>{if(!a.current||!n)return;let t=a.current,x=setTimeout(()=>{if(l&&e){e.parentNode!==t&&t.appendChild(e);return}l=!0,e=document.createElement("canvas"),e.style.width="100%",e.style.height="100%";try{console.log("Transferring canvas to worker...");let r=e.transferControlToOffscreen();n.postMessage({type:"INIT",canvas:r,width:window.innerWidth,height:window.innerHeight,dpr:window.devicePixelRatio,props:{shadows:i}},[r]),t.appendChild(e),console.log("\u{1F680} Axion ENGINE: Delayed Handshake Success.")}catch(r){console.warn("Axion Bridge: Handshake race condition caught.",r)}},50);return()=>{clearTimeout(x),e&&e.parentNode===t&&t.removeChild(e)}},[n]),h("div",{ref:a,style:{width:"100%",height:"100%"}})};export{c as AxionCanvas,o as AxionContext,s as AxionEngine};
1
+ import{createContext as f}from"react";import{jsx as x}from"react/jsx-runtime";var i=f(null),u=({worker:a,children:t})=>x(i.Provider,{value:a,children:t});import{useContext as C,useEffect as h,useRef as m}from"react";import{jsx as N}from"react/jsx-runtime";var e=null,l=!1,p=0,w=4,A=8,I=12,v=({shadows:a})=>{let t=C(i),c=m(null);return h(()=>{if(!c.current||!t)return;let n=c.current,d=setTimeout(()=>{if(l&&e){e.parentNode!==n&&n.appendChild(e);return}l=!0,e=document.createElement("canvas"),e.style.width="100%",e.style.height="100%";try{let o=e.transferControlToOffscreen(),s=new ArrayBuffer(16),r=new DataView(s);r.setUint32(p,window.innerWidth),r.setUint32(w,window.innerHeight),r.setFloat32(A,window.devicePixelRatio),r.setUint8(I,a?1:0),t.postMessage({type:"INIT",canvas:o,config:s},[o,s]),n.appendChild(e),console.log("\u{1F680} Axion ENGINE: Binary Handshake Success.")}catch(o){console.warn("Axion Bridge: Handshake race condition caught.",o)}},50);return()=>{clearTimeout(d),e&&e.parentNode===n&&n.removeChild(e)}},[t]),N("div",{ref:c,style:{width:"100%",height:"100%"}})};export{v as AxionCanvas,i as AxionContext,u as AxionEngine};
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../packages/axion-platform/src/context/AxionContext.tsx", "../packages/axion-platform/src/components/AxionCanvas.tsx"],
4
- "sourcesContent": ["// src/context/AxionContext.tsx\r\nimport React, { Context, createContext, ReactNode } from \"react\";\r\nexport const AxionContext: Context<Worker | null> = createContext<Worker | null>(null);\r\n\r\n// 2. The Engine Provider (Manages the Worker)\r\nexport const AxionEngine = ({ worker, children }: { worker: Worker, children: ReactNode }): React.JSX.Element => {\r\n return (\r\n <AxionContext.Provider value={worker}>\r\n {children}\r\n </AxionContext.Provider>\r\n );\r\n};", "\r\nimport React, { useContext, useEffect, useRef } from \"react\";\r\nimport { AxionContext } from \"../context/AxionContext\";\r\n\r\n// Global reference that persists across re-renders/HMR\r\nlet GLOBAL_CANVAS: HTMLCanvasElement | null = null;\r\nlet INITIALIZED = false;\r\n\r\nexport const AxionCanvas = ({ shadows }: { shadows?: boolean }): React.JSX.Element => {\r\n const worker = useContext(AxionContext);\r\n const containerRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n if (!containerRef.current || !worker) return;\r\n\r\n const container = containerRef.current;\r\n\r\n // Use a timeout to wait for React's StrictMode double-fire to finish\r\n const timeoutId = setTimeout(() => {\r\n if (INITIALIZED && GLOBAL_CANVAS) {\r\n // If already initialized, just re-append the existing canvas\r\n if (GLOBAL_CANVAS.parentNode !== container) {\r\n container.appendChild(GLOBAL_CANVAS);\r\n }\r\n return;\r\n }\r\n\r\n // If we get here, this is the \"surviving\" mount attempt\r\n INITIALIZED = true;\r\n GLOBAL_CANVAS = document.createElement('canvas');\r\n GLOBAL_CANVAS.style.width = '100%';\r\n GLOBAL_CANVAS.style.height = '100%';\r\n\r\n try {\r\n console.log(\"Transferring canvas to worker...\")\r\n const offscreen = GLOBAL_CANVAS.transferControlToOffscreen();\r\n\r\n worker.postMessage({\r\n type: 'INIT',\r\n canvas: offscreen,\r\n width: window.innerWidth,\r\n height: window.innerHeight,\r\n dpr: window.devicePixelRatio,\r\n props: { shadows }\r\n }, [offscreen]);\r\n\r\n container.appendChild(GLOBAL_CANVAS);\r\n console.log(\"\uD83D\uDE80 Axion ENGINE: Delayed Handshake Success.\");\r\n } catch (e) {\r\n console.warn(\"Axion Bridge: Handshake race condition caught.\", e);\r\n }\r\n }, 50); // 50ms is plenty to clear React's mount/unmount cycle\r\n\r\n return () => {\r\n clearTimeout(timeoutId);\r\n // We detach the canvas so it can be re-appended elsewhere\r\n if (GLOBAL_CANVAS && GLOBAL_CANVAS.parentNode === container) {\r\n container.removeChild(GLOBAL_CANVAS);\r\n }\r\n };\r\n }, [worker]);\r\n\r\n return <div ref={containerRef} style={{ width: '100%', height: '100%' }} />;\r\n};"],
5
- "mappings": "AACA,OAAyB,iBAAAA,MAAgC,QAMjD,cAAAC,MAAA,oBALD,IAAMC,EAAuCF,EAA6B,IAAI,EAGxEG,EAAc,CAAC,CAAE,OAAAC,EAAQ,SAAAC,CAAS,IAEvCJ,EAACC,EAAa,SAAb,CAAsB,MAAOE,EACzB,SAAAC,EACL,ECRR,OAAgB,cAAAC,EAAY,aAAAC,EAAW,UAAAC,MAAc,QA6D1C,cAAAC,MAAA,oBAzDX,IAAIC,EAA0C,KAC1CC,EAAc,GAELC,EAAc,CAAC,CAAE,QAAAC,CAAQ,IAAgD,CAClF,IAAMC,EAASC,EAAWC,CAAY,EAChCC,EAAeC,EAAuB,IAAI,EAEhD,OAAAC,EAAU,IAAM,CACZ,GAAI,CAACF,EAAa,SAAW,CAACH,EAAQ,OAEtC,IAAMM,EAAYH,EAAa,QAGzBI,EAAY,WAAW,IAAM,CAC/B,GAAIV,GAAeD,EAAe,CAE1BA,EAAc,aAAeU,GAC7BA,EAAU,YAAYV,CAAa,EAEvC,MACJ,CAGAC,EAAc,GACdD,EAAgB,SAAS,cAAc,QAAQ,EAC/CA,EAAc,MAAM,MAAQ,OAC5BA,EAAc,MAAM,OAAS,OAE7B,GAAI,CACA,QAAQ,IAAI,kCAAkC,EAC9C,IAAMY,EAAYZ,EAAc,2BAA2B,EAE3DI,EAAO,YAAY,CACf,KAAM,OACN,OAAQQ,EACR,MAAO,OAAO,WACd,OAAQ,OAAO,YACf,IAAK,OAAO,iBACZ,MAAO,CAAE,QAAAT,CAAQ,CACrB,EAAG,CAACS,CAAS,CAAC,EAEdF,EAAU,YAAYV,CAAa,EACnC,QAAQ,IAAI,oDAA6C,CAC7D,OAASa,EAAG,CACR,QAAQ,KAAK,iDAAkDA,CAAC,CACpE,CACJ,EAAG,EAAE,EAEL,MAAO,IAAM,CACT,aAAaF,CAAS,EAElBX,GAAiBA,EAAc,aAAeU,GAC9CA,EAAU,YAAYV,CAAa,CAE3C,CACJ,EAAG,CAACI,CAAM,CAAC,EAEJL,EAAC,OAAI,IAAKQ,EAAc,MAAO,CAAE,MAAO,OAAQ,OAAQ,MAAO,EAAG,CAC7E",
6
- "names": ["createContext", "jsx", "AxionContext", "AxionEngine", "worker", "children", "useContext", "useEffect", "useRef", "jsx", "GLOBAL_CANVAS", "INITIALIZED", "AxionCanvas", "shadows", "worker", "useContext", "AxionContext", "containerRef", "useRef", "useEffect", "container", "timeoutId", "offscreen", "e"]
4
+ "sourcesContent": ["// src/context/AxionContext.tsx\r\nimport React, { Context, createContext, ReactNode } from \"react\";\r\nexport const AxionContext: Context<Worker | null> = createContext<Worker | null>(null);\r\n\r\n// 2. The Engine Provider (Manages the Worker)\r\nexport const AxionEngine = ({ worker, children }: { worker: Worker, children: ReactNode }): React.JSX.Element => {\r\n return (\r\n <AxionContext.Provider value={worker}>\r\n {children}\r\n </AxionContext.Provider>\r\n );\r\n};", "\r\nimport React, { useContext, useEffect, useRef } from \"react\";\r\nimport { AxionContext } from \"../context/AxionContext\";\r\n\r\nlet GLOBAL_CANVAS: HTMLCanvasElement | null = null;\r\nlet INITIALIZED = false;\r\nconst CONFIG_WIDTH = 0;\r\nconst CONFIG_HEIGHT = 4;\r\nconst CONFIG_DPR = 8;\r\nconst CONFIG_SHADOWS = 12;\r\n\r\nexport const AxionCanvas = ({ shadows }: { shadows?: boolean }): React.JSX.Element => {\r\n const worker = useContext(AxionContext);\r\n const containerRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n if (!containerRef.current || !worker) return;\r\n\r\n const container = containerRef.current;\r\n\r\n const timeoutId = setTimeout(() => {\r\n if (INITIALIZED && GLOBAL_CANVAS) {\r\n if (GLOBAL_CANVAS.parentNode !== container) {\r\n container.appendChild(GLOBAL_CANVAS);\r\n }\r\n return;\r\n }\r\n\r\n INITIALIZED = true;\r\n GLOBAL_CANVAS = document.createElement('canvas');\r\n GLOBAL_CANVAS.style.width = '100%';\r\n GLOBAL_CANVAS.style.height = '100%';\r\n\r\n try {\r\n const offscreen = GLOBAL_CANVAS.transferControlToOffscreen();\r\n\r\n // --- NEW: CREATE INITIALIZATION BUFFER ---\r\n const initBuffer = new ArrayBuffer(16); // 16 bytes is enough for 4 values\r\n const view = new DataView(initBuffer);\r\n\r\n view.setUint32(CONFIG_WIDTH, window.innerWidth);\r\n view.setUint32(CONFIG_HEIGHT, window.innerHeight);\r\n view.setFloat32(CONFIG_DPR, window.devicePixelRatio);\r\n view.setUint8(CONFIG_SHADOWS, shadows ? 1 : 0);\r\n\r\n worker.postMessage({\r\n type: 'INIT',\r\n canvas: offscreen,\r\n config: initBuffer // Send the buffer here\r\n }, [offscreen, initBuffer]); // Transfer BOTH to the worker\r\n // -----------------------------------------\r\n\r\n container.appendChild(GLOBAL_CANVAS);\r\n console.log(\"\uD83D\uDE80 Axion ENGINE: Binary Handshake Success.\");\r\n } catch (e) {\r\n console.warn(\"Axion Bridge: Handshake race condition caught.\", e);\r\n }\r\n }, 50);\r\n\r\n return () => {\r\n clearTimeout(timeoutId);\r\n if (GLOBAL_CANVAS && GLOBAL_CANVAS.parentNode === container) {\r\n container.removeChild(GLOBAL_CANVAS);\r\n }\r\n };\r\n }, [worker]);\r\n\r\n return <div ref={containerRef} style={{ width: '100%', height: '100%' }} />;\r\n};"],
5
+ "mappings": "AACA,OAAyB,iBAAAA,MAAgC,QAMjD,cAAAC,MAAA,oBALD,IAAMC,EAAuCF,EAA6B,IAAI,EAGxEG,EAAc,CAAC,CAAE,OAAAC,EAAQ,SAAAC,CAAS,IAEvCJ,EAACC,EAAa,SA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J,EAAG,CAACQ,CAAM,CAAC,EAEJT,EAAC,OAAI,IAAKY,EAAc,MAAO,CAAE,MAAO,OAAQ,OAAQ,MAAO,EAAG,CAC7E",
6
+ "names": ["createContext", "jsx", "AxionContext", "AxionEngine", "worker", "children", "useContext", "useEffect", "useRef", "jsx", "GLOBAL_CANVAS", "INITIALIZED", "CONFIG_WIDTH", "CONFIG_HEIGHT", "CONFIG_DPR", "CONFIG_SHADOWS", "AxionCanvas", "shadows", "worker", "useContext", "AxionContext", "containerRef", "useRef", "useEffect", "container", "timeoutId", "offscreen", "initBuffer", "view", "e"]
7
7
  }
@@ -1,7 +1,6 @@
1
1
  /**
2
- * AxionWorker.ts
2
+ * AxionWorker.tsx
3
3
  * This utility resolves the worker path based on whether the engine
4
4
  * is running in development (via yalc/linked) or production.
5
5
  */
6
- export declare const createOrionWorker: (customPath?: string) => Worker;
7
6
  //# sourceMappingURL=AxionWorker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AxionWorker.d.ts","sourceRoot":"","sources":["../../../packages/worker/hooks/AxionWorker.tsx"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axion-engine/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Origin-rebasing, multi-threaded game engine for Orion Realms",
5
5
  "type": "module",
6
6
  "author": "Vikas",
@@ -1 +0,0 @@
1
- {"version":3,"file":"AxionWorker.d.ts","sourceRoot":"","sources":["../../packages/worker/AxionWorker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,KAAG,MASvD,CAAC"}