@axion-engine/core 0.0.1
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/README.md +81 -0
- package/dist/axion-platform/index.d.ts +4 -0
- package/dist/axion-platform/index.d.ts.map +1 -0
- package/dist/axion-platform/src/components/AxionCanvas.d.ts +5 -0
- package/dist/axion-platform/src/components/AxionCanvas.d.ts.map +1 -0
- package/dist/axion-platform/src/context/AxionContext.d.ts +7 -0
- package/dist/axion-platform/src/context/AxionContext.d.ts.map +1 -0
- package/dist/axion-platform/src/index.d.ts +4 -0
- package/dist/axion-platform/src/index.d.ts.map +1 -0
- package/dist/axion-worker.js +4110 -0
- package/dist/axion-worker.js.map +7 -0
- package/dist/core/src/SceneRegistry/types.d.ts +17 -0
- package/dist/core/src/SceneRegistry/types.d.ts.map +1 -0
- package/dist/core/src/index.d.ts +1 -0
- package/dist/core/src/index.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/worker/AxionWorker.d.ts +7 -0
- package/dist/worker/AxionWorker.d.ts.map +1 -0
- package/dist/worker/src/defaultScene.d.ts +3 -0
- package/dist/worker/src/defaultScene.d.ts.map +1 -0
- package/dist/worker/src/index.d.ts +2 -0
- package/dist/worker/src/index.d.ts.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type SceneSource = {
|
|
2
|
+
type: 'URL' | 'RAW';
|
|
3
|
+
payload: string | any;
|
|
4
|
+
};
|
|
5
|
+
export interface SceneSupplyMessage {
|
|
6
|
+
type: 'SUPPLY_SCENE';
|
|
7
|
+
sceneId: string;
|
|
8
|
+
source: SceneSource;
|
|
9
|
+
}
|
|
10
|
+
export type EngineMessage = {
|
|
11
|
+
type: 'INIT';
|
|
12
|
+
canvas: OffscreenCanvas;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
dpr: number;
|
|
16
|
+
} | SceneSupplyMessage;
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/core/src/SceneRegistry/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,WAAW,GAAG;IACtB,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC;CACzB,CAAC;AAEF,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,MAAM,aAAa,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GACrF,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/core/src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +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};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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,SAA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", "worker", "children", "useContext", "useEffect", "useRef", "jsx", "GLOBAL_CANVAS", "INITIALIZED", "AxionCanvas", "shadows", "worker", "useContext", "AxionContext", "containerRef", "useRef", "useEffect", "container", "timeoutId", "offscreen", "e"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AxionWorker.ts
|
|
3
|
+
* This utility resolves the worker path based on whether the engine
|
|
4
|
+
* is running in development (via yalc/linked) or production.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createOrionWorker: (customPath?: string) => Worker;
|
|
7
|
+
//# sourceMappingURL=AxionWorker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultScene.d.ts","sourceRoot":"","sources":["../../../packages/worker/src/defaultScene.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,wBAAgB,YAAY,IAAI,GAAG,CAAC,OAAO,CAsB1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/worker/src/index.tsx"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@axion-engine/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Origin-rebasing, multi-threaded game engine for Orion Realms",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "Vikas",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"package.json"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./worker": "./dist/axion-worker.js"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build:lib": "node build-library.js && tsc",
|
|
26
|
+
"yalc-push": "npm run build:lib && yalc publish --push",
|
|
27
|
+
"yalc-push:prod":"npm run build:lib:prod && yalc publish --push",
|
|
28
|
+
"build:worker": "node build-worker.js",
|
|
29
|
+
"watch:worker": "node build-worker.js --watch",
|
|
30
|
+
"test:serve": "npx serve .",
|
|
31
|
+
"prepublishOnly": "npm run build:lib:prod",
|
|
32
|
+
"test": "concurrently \"npm run watch:worker\" \"npm run test:serve\"",
|
|
33
|
+
"check-types": "tsc --noEmit",
|
|
34
|
+
"clean": "rm -rf dist test/axion-worker.js test/axion-worker.js.map",
|
|
35
|
+
"build:lib:prod": "node build-library.js --production && tsc"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": ">=18.0.0",
|
|
39
|
+
"react-dom": ">=18.0.0",
|
|
40
|
+
"three": ">=0.150.0",
|
|
41
|
+
"@react-three/fiber": ">=8.0.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^25.0.3",
|
|
45
|
+
"@types/react": "^19.2.7",
|
|
46
|
+
"@types/react-dom": "^19.2.3",
|
|
47
|
+
"@types/three": "^0.182.0",
|
|
48
|
+
"concurrently": "^9.2.1",
|
|
49
|
+
"esbuild": "^0.27.2",
|
|
50
|
+
"three": "^0.182.0",
|
|
51
|
+
"typescript": "^5.9.3"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@react-three/fiber": "^9.4.2",
|
|
55
|
+
"react": "^19.2.3",
|
|
56
|
+
"react-dom": "^19.2.3"
|
|
57
|
+
}
|
|
58
|
+
}
|