@threenative/core 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -0
- package/capabilities.json +3542 -0
- package/dist/audio-Dp2mXpD3.d.ts +94 -0
- package/dist/canvas-layer-CtrZHgIh.d.ts +608 -0
- package/dist/game-CYIaKhgl.d.ts +980 -0
- package/dist/hot.d.ts +33 -5
- package/dist/hot.js +10 -2
- package/dist/index.d.ts +1480 -41
- package/dist/index.js +12604 -1104
- package/dist/playtest.d.ts +36 -5
- package/dist/playtest.js +160 -468
- package/dist/react.d.ts +175 -0
- package/dist/react.js +635 -0
- package/dist/ui-layer.d.ts +306 -0
- package/dist/ui-layer.js +425 -0
- package/dist/world.d.ts +55 -0
- package/dist/world.js +175 -0
- package/mcp/assets.mjs +5 -0
- package/mcp/engine-server.mjs +253 -0
- package/mcp/engine.mjs +23 -0
- package/mcp/install.mjs +77 -0
- package/mcp/launch.mjs +72 -0
- package/mcp/sculpt.mjs +5 -0
- package/mcp/servers.mjs +59 -0
- package/package.json +49 -6
- package/patches/three@0.185.1.patch +287 -0
- package/scripts/apply-three-patch.mjs +297 -0
- package/scripts/bundle-engine-mcp.mjs +15 -0
- package/scripts/ensure-mcp.mjs +36 -0
- package/scripts/generate-version.mjs +13 -0
- package/scripts/postinstall.mjs +6 -0
- package/dist/audio-3vkjtiuo.d.ts +0 -35
- package/dist/game-DRPs3M7r.d.ts +0 -269
package/dist/hot.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { a as audioRuntimeSnapshot } from './audio-
|
|
2
|
-
import {
|
|
1
|
+
import { a as audioRuntimeSnapshot } from './audio-Dp2mXpD3.js';
|
|
2
|
+
import { I as IGame } from './game-CYIaKhgl.js';
|
|
3
3
|
import 'three';
|
|
4
|
+
import './canvas-layer-CtrZHgIh.js';
|
|
5
|
+
import 'three/webgpu';
|
|
4
6
|
import 'zustand/vanilla';
|
|
5
7
|
|
|
6
|
-
interface
|
|
8
|
+
interface IHotDiagnostics {
|
|
7
9
|
readonly reloads: number;
|
|
8
10
|
readonly entities: number;
|
|
9
11
|
readonly sceneObjects: number;
|
|
@@ -11,7 +13,33 @@ interface HotDiagnostics {
|
|
|
11
13
|
readonly audio: ReturnType<typeof audioRuntimeSnapshot>;
|
|
12
14
|
readonly physics: number | null;
|
|
13
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Validate that hot-reload state can cross the Vite boundary.
|
|
18
|
+
* @situation preserve JSON-shaped state during hot reload
|
|
19
|
+
* @situation reject a non-portable game state before reload
|
|
20
|
+
* @constraint state must contain finite numbers and plain objects only
|
|
21
|
+
* @example assertPortableState(game.state.getState());
|
|
22
|
+
*/
|
|
14
23
|
declare function assertPortableState(state: unknown): void;
|
|
15
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Register hot-reload state preservation for a game.
|
|
26
|
+
* @situation keep game state while editing source in development
|
|
27
|
+
* @situation diagnose state shape changes during hot reload
|
|
28
|
+
* @constraint use only in the web development entry
|
|
29
|
+
* @example acceptHotUpdate(game, import.meta.hot);
|
|
30
|
+
*/
|
|
31
|
+
declare function acceptHotUpdate<TState extends Record<string, unknown>, TPhysics>(game: IGame<TState, TPhysics>, hot: IImportMeta["hot"]): void;
|
|
32
|
+
interface IImportMeta {
|
|
33
|
+
readonly env?: {
|
|
34
|
+
readonly DEV?: boolean;
|
|
35
|
+
};
|
|
36
|
+
readonly hot?: IViteHotContext;
|
|
37
|
+
}
|
|
38
|
+
interface IViteHotContext {
|
|
39
|
+
readonly data: Record<string, unknown>;
|
|
40
|
+
accept(): void;
|
|
41
|
+
dispose(callback: (data: Record<string, unknown>) => void): void;
|
|
42
|
+
invalidate(message?: string): void;
|
|
43
|
+
}
|
|
16
44
|
|
|
17
|
-
export { type
|
|
45
|
+
export { type IHotDiagnostics, acceptHotUpdate, assertPortableState };
|
package/dist/hot.js
CHANGED
|
@@ -5,11 +5,13 @@ var buses = /* @__PURE__ */ new Set();
|
|
|
5
5
|
function audioRuntimeSnapshot() {
|
|
6
6
|
let queued = 0;
|
|
7
7
|
let voices = 0;
|
|
8
|
+
let pooled = 0;
|
|
8
9
|
for (const bus of buses) {
|
|
9
10
|
queued += bus.queued;
|
|
10
11
|
voices += bus.voices;
|
|
12
|
+
pooled += bus.pooled;
|
|
11
13
|
}
|
|
12
|
-
return { queued, voices };
|
|
14
|
+
return { pooled, queued, voices };
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
// src/hot.ts
|
|
@@ -23,6 +25,12 @@ function acceptHotUpdate(game, hot) {
|
|
|
23
25
|
const carried = hot.data.threenative;
|
|
24
26
|
const reloads = carried?.reloads ?? 0;
|
|
25
27
|
if (carried !== void 0) restoreState(game, carried.state);
|
|
28
|
+
if (carried?.sceneName !== void 0) {
|
|
29
|
+
try {
|
|
30
|
+
game.resumeScene(carried.sceneName);
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
26
34
|
if (isDev && typeof window !== "undefined") {
|
|
27
35
|
const host = window;
|
|
28
36
|
host.__THREENATIVE__ = {
|
|
@@ -39,7 +47,7 @@ function acceptHotUpdate(game, hot) {
|
|
|
39
47
|
game.state.flush();
|
|
40
48
|
const state = game.state.getState();
|
|
41
49
|
assertPortableState(state);
|
|
42
|
-
data.threenative = { reloads: reloads + 1, state };
|
|
50
|
+
data.threenative = { reloads: reloads + 1, sceneName: game.sceneName, state };
|
|
43
51
|
} catch (error) {
|
|
44
52
|
data.threenative = void 0;
|
|
45
53
|
hot.invalidate(error instanceof Error ? error.message : String(error));
|