oriverse-engine 0.1.3 → 0.1.4
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/CODEX_PROMPT.md +7 -7
- package/dist/oriverse_wgpu.d.ts +15 -15
- package/dist/oriverse_wgpu.js +78 -78
- package/dist/oriverse_wgpu_bg.wasm +0 -0
- package/dist/oriverse_wgpu_bg.wasm.d.ts +15 -15
- package/dist/prewarm.js +61 -0
- package/dist/shader_prewarm_manifest.json +1 -0
- package/dist/snippets/oriverse_wgpu-255445ce6d9a0851/inline0.js +58 -20
- package/dist/snippets/oriverse_wgpu-255445ce6d9a0851/inline1.js +20 -58
- package/dist/starter/AGENTS.md +2 -2
- package/dist/starter/CLAUDE.md +2 -2
- package/dist/starter/game.html +9 -6
- package/dist/templates/game.html +3 -0
- package/dist/templates/game_cdn.html +9 -6
- package/package.json +1 -1
|
@@ -1,22 +1,60 @@
|
|
|
1
1
|
|
|
2
|
-
export function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
export function observeDevicePixels(canvas, onSize) {
|
|
3
|
+
const hasDPCB = (() => {
|
|
4
|
+
try { return 'devicePixelContentBoxSize' in ResizeObserverEntry.prototype; } catch { return false; }
|
|
5
|
+
})();
|
|
6
|
+
|
|
7
|
+
// Compute current CSS and device-pixel sizes and call onSize(dpW, dpH, effectiveDpr)
|
|
8
|
+
function fireNow() {
|
|
9
|
+
let cssW, cssH, dpW, dpH;
|
|
10
|
+
if (hasDPCB && canvas.__lastROEntry) {
|
|
11
|
+
const e = canvas.__lastROEntry;
|
|
12
|
+
dpW = e.devicePixelContentBoxSize[0].inlineSize;
|
|
13
|
+
dpH = e.devicePixelContentBoxSize[0].blockSize;
|
|
14
|
+
cssW = e.contentBoxSize[0].inlineSize;
|
|
15
|
+
cssH = e.contentBoxSize[0].blockSize;
|
|
16
|
+
} else {
|
|
17
|
+
const rect = canvas.getBoundingClientRect();
|
|
18
|
+
const dpr = window.devicePixelRatio || 1;
|
|
19
|
+
cssW = rect.width; cssH = rect.height;
|
|
20
|
+
dpW = Math.max(1, Math.round(cssW * dpr));
|
|
21
|
+
dpH = Math.max(1, Math.round(cssH * dpr));
|
|
22
|
+
}
|
|
23
|
+
const dprEff = cssW > 0 ? (dpW / cssW) : (window.devicePixelRatio || 1);
|
|
24
|
+
onSize(dpW >>> 0, dpH >>> 0, dprEff);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ro = new ResizeObserver(entries => {
|
|
28
|
+
// Save the last entry for precise device-pixel info.
|
|
29
|
+
canvas.__lastROEntry = entries[0];
|
|
30
|
+
fireNow();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
try { ro.observe(canvas, { box: 'device-pixel-content-box' }); }
|
|
34
|
+
catch { ro.observe(canvas); }
|
|
35
|
+
|
|
36
|
+
// DPR changes (zoom / moving across monitors) don't always reflow. Listen explicitly.
|
|
37
|
+
let mq = matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
38
|
+
const onMQ = () => {
|
|
39
|
+
// Force a non-layout-janking "poke" to trigger RO in some browsers.
|
|
40
|
+
const t = canvas.style.transform;
|
|
41
|
+
canvas.style.transform = 'translateZ(0)'; canvas.style.transform = t;
|
|
42
|
+
fireNow();
|
|
43
|
+
// Re-arm listener for the new DPR.
|
|
44
|
+
mq.removeEventListener?.('change', onMQ);
|
|
45
|
+
mq = matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
46
|
+
mq.addEventListener?.('change', onMQ);
|
|
47
|
+
};
|
|
48
|
+
mq.addEventListener?.('change', onMQ);
|
|
49
|
+
window.addEventListener('pageshow', onMQ);
|
|
50
|
+
|
|
51
|
+
// Fire once now so we start sized correctly.
|
|
52
|
+
Promise.resolve().then(fireNow);
|
|
53
|
+
|
|
54
|
+
// Return disposer
|
|
55
|
+
return () => {
|
|
56
|
+
try { ro.disconnect(); } catch {}
|
|
57
|
+
try { mq.removeEventListener?.('change', onMQ); } catch {}
|
|
58
|
+
try { window.removeEventListener('pageshow', onMQ); } catch {}
|
|
59
|
+
};
|
|
22
60
|
}
|
|
@@ -1,60 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
export function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
const dprEff = cssW > 0 ? (dpW / cssW) : (window.devicePixelRatio || 1);
|
|
24
|
-
onSize(dpW >>> 0, dpH >>> 0, dprEff);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const ro = new ResizeObserver(entries => {
|
|
28
|
-
// Save the last entry for precise device-pixel info.
|
|
29
|
-
canvas.__lastROEntry = entries[0];
|
|
30
|
-
fireNow();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
try { ro.observe(canvas, { box: 'device-pixel-content-box' }); }
|
|
34
|
-
catch { ro.observe(canvas); }
|
|
35
|
-
|
|
36
|
-
// DPR changes (zoom / moving across monitors) don't always reflow. Listen explicitly.
|
|
37
|
-
let mq = matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
38
|
-
const onMQ = () => {
|
|
39
|
-
// Force a non-layout-janking "poke" to trigger RO in some browsers.
|
|
40
|
-
const t = canvas.style.transform;
|
|
41
|
-
canvas.style.transform = 'translateZ(0)'; canvas.style.transform = t;
|
|
42
|
-
fireNow();
|
|
43
|
-
// Re-arm listener for the new DPR.
|
|
44
|
-
mq.removeEventListener?.('change', onMQ);
|
|
45
|
-
mq = matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
46
|
-
mq.addEventListener?.('change', onMQ);
|
|
47
|
-
};
|
|
48
|
-
mq.addEventListener?.('change', onMQ);
|
|
49
|
-
window.addEventListener('pageshow', onMQ);
|
|
50
|
-
|
|
51
|
-
// Fire once now so we start sized correctly.
|
|
52
|
-
Promise.resolve().then(fireNow);
|
|
53
|
-
|
|
54
|
-
// Return disposer
|
|
55
|
-
return () => {
|
|
56
|
-
try { ro.disconnect(); } catch {}
|
|
57
|
-
try { mq.removeEventListener?.('change', onMQ); } catch {}
|
|
58
|
-
try { window.removeEventListener('pageshow', onMQ); } catch {}
|
|
59
|
-
};
|
|
2
|
+
export function __ori_install_webgpu_error_tap(sink) {
|
|
3
|
+
try {
|
|
4
|
+
if (typeof GPUAdapter === 'undefined' || GPUAdapter.prototype.__ori_err_tap) return;
|
|
5
|
+
GPUAdapter.prototype.__ori_err_tap = true;
|
|
6
|
+
const orig = GPUAdapter.prototype.requestDevice;
|
|
7
|
+
GPUAdapter.prototype.requestDevice = async function(desc) {
|
|
8
|
+
const device = await orig.call(this, desc);
|
|
9
|
+
try { window.__ori_gpu_device = device; } catch (_) {}
|
|
10
|
+
try {
|
|
11
|
+
device.addEventListener('uncapturederror', function(event) {
|
|
12
|
+
const e = event.error;
|
|
13
|
+
const name = (e && e.constructor && e.constructor.name) || 'GPUError';
|
|
14
|
+
const msg = (e && e.message) || '';
|
|
15
|
+
try { sink(name, msg); } catch (_) {}
|
|
16
|
+
try { console.error('[raw_webgpu_uncaptured]', name, msg); } catch (_) {}
|
|
17
|
+
});
|
|
18
|
+
} catch (_) {}
|
|
19
|
+
return device;
|
|
20
|
+
};
|
|
21
|
+
} catch (_) {}
|
|
60
22
|
}
|
package/dist/starter/AGENTS.md
CHANGED
|
@@ -11,9 +11,9 @@ loader scripts or engine URLs.
|
|
|
11
11
|
|
|
12
12
|
## Before writing Weave, read the guide
|
|
13
13
|
|
|
14
|
-
- https://
|
|
14
|
+
- https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/GAME_AUTHORING.md — authoring patterns + 3 complete tested
|
|
15
15
|
example games (coin collector, dodge blocks, target range) to pattern-match from.
|
|
16
|
-
- https://
|
|
16
|
+
- https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/weave_documentation.txt — full language + API reference.
|
|
17
17
|
|
|
18
18
|
Key constraints: content must be fully procedural (primitive models `"cube"`,
|
|
19
19
|
`"sphere"`, ..., `#mesh`, `#texture` — no market/network assets); units are cm with Z
|
package/dist/starter/CLAUDE.md
CHANGED
|
@@ -11,9 +11,9 @@ loader scripts or engine URLs.
|
|
|
11
11
|
|
|
12
12
|
## Before writing Weave, read the guide
|
|
13
13
|
|
|
14
|
-
- https://
|
|
14
|
+
- https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/GAME_AUTHORING.md — authoring patterns + 3 complete tested
|
|
15
15
|
example games (coin collector, dodge blocks, target range) to pattern-match from.
|
|
16
|
-
- https://
|
|
16
|
+
- https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/weave_documentation.txt — full language + API reference.
|
|
17
17
|
|
|
18
18
|
Key constraints: content must be fully procedural (primitive models `"cube"`,
|
|
19
19
|
`"sphere"`, ..., `#mesh`, `#texture` — no market/network assets); units are cm with Z
|
package/dist/starter/game.html
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!-- game_cdn.html — Oriverse artifact game loading the engine from a CDN (three.js-style).
|
|
2
|
-
This single small file IS the whole game: engine js/wasm come from
|
|
2
|
+
This single small file IS the whole game: engine js/wasm come from the npm CDN, your game is
|
|
3
3
|
the inline Weave source below. Serve from any static host (no COOP/COEP headers) or a
|
|
4
4
|
plain `python -m http.server`; open in a WebGPU browser (Chrome/Edge).
|
|
5
|
-
The engine version is pinned in the https://
|
|
5
|
+
The engine version is pinned in the https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist urls below (injected from
|
|
6
6
|
npm_package/package.json at packaging time) — bump the @version with engine releases.
|
|
7
7
|
Content must be fully procedural: primitives ("cube", "sphere", ...), #mesh, #texture,
|
|
8
8
|
#particles. Market/network assets are unavailable and will hard-error. -->
|
|
@@ -42,17 +42,20 @@ object BlueCube {
|
|
|
42
42
|
}
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
|
+
<!-- Shader prewarm: replays the build's pipeline manifest on a throwaway device during
|
|
46
|
+
engine download dead-time (kills the first-view compile freeze). Fail-open. -->
|
|
47
|
+
<script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/prewarm.js"></script>
|
|
45
48
|
<!-- KTX2 texture transcoder sidecar (classic scripts; ktx_lib.wasm resolves relative to the script url). -->
|
|
46
|
-
<script src="https://
|
|
47
|
-
<script src="https://
|
|
49
|
+
<script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/ktx_lib.js"></script>
|
|
50
|
+
<script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/ktx_bridge.js"></script>
|
|
48
51
|
<script type="module">
|
|
49
|
-
import initOriverse from "https://
|
|
52
|
+
import initOriverse from "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/oriverse_wgpu.js";
|
|
50
53
|
const setBoot = (t) => { const b = document.getElementById('oriverse-status-banner'); if (b) b.textContent = t; };
|
|
51
54
|
(async () => {
|
|
52
55
|
try {
|
|
53
56
|
setBoot('instantiating wasm...');
|
|
54
57
|
// Artifact build: wasm-bindgen owns a private (non-shared) memory; no COOP/COEP needed.
|
|
55
|
-
await initOriverse({ module_or_path: "https://
|
|
58
|
+
await initOriverse({ module_or_path: "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/oriverse_wgpu_bg.wasm" });
|
|
56
59
|
} catch (e) {
|
|
57
60
|
const msg = (e && e.stack) ? e.stack : String(e);
|
|
58
61
|
setBoot('WASM init failed:\n' + msg);
|
package/dist/templates/game.html
CHANGED
|
@@ -42,6 +42,9 @@ object BlueCube {
|
|
|
42
42
|
}
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
|
+
<!-- Shader prewarm: replays the build's pipeline manifest on a throwaway device during
|
|
46
|
+
boot (kills the first-view compile freeze). Fail-open when the manifest is absent. -->
|
|
47
|
+
<script src="prewarm.js"></script>
|
|
45
48
|
<script src="ktx_lib.js"></script>
|
|
46
49
|
<script src="ktx_bridge.js"></script>
|
|
47
50
|
<script type="module">
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!-- game_cdn.html — Oriverse artifact game loading the engine from a CDN (three.js-style).
|
|
2
|
-
This single small file IS the whole game: engine js/wasm come from
|
|
2
|
+
This single small file IS the whole game: engine js/wasm come from the npm CDN, your game is
|
|
3
3
|
the inline Weave source below. Serve from any static host (no COOP/COEP headers) or a
|
|
4
4
|
plain `python -m http.server`; open in a WebGPU browser (Chrome/Edge).
|
|
5
|
-
The engine version is pinned in the https://
|
|
5
|
+
The engine version is pinned in the https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist urls below (injected from
|
|
6
6
|
npm_package/package.json at packaging time) — bump the @version with engine releases.
|
|
7
7
|
Content must be fully procedural: primitives ("cube", "sphere", ...), #mesh, #texture,
|
|
8
8
|
#particles. Market/network assets are unavailable and will hard-error. -->
|
|
@@ -42,17 +42,20 @@ object BlueCube {
|
|
|
42
42
|
}
|
|
43
43
|
</script>
|
|
44
44
|
|
|
45
|
+
<!-- Shader prewarm: replays the build's pipeline manifest on a throwaway device during
|
|
46
|
+
engine download dead-time (kills the first-view compile freeze). Fail-open. -->
|
|
47
|
+
<script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/prewarm.js"></script>
|
|
45
48
|
<!-- KTX2 texture transcoder sidecar (classic scripts; ktx_lib.wasm resolves relative to the script url). -->
|
|
46
|
-
<script src="https://
|
|
47
|
-
<script src="https://
|
|
49
|
+
<script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/ktx_lib.js"></script>
|
|
50
|
+
<script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/ktx_bridge.js"></script>
|
|
48
51
|
<script type="module">
|
|
49
|
-
import initOriverse from "https://
|
|
52
|
+
import initOriverse from "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/oriverse_wgpu.js";
|
|
50
53
|
const setBoot = (t) => { const b = document.getElementById('oriverse-status-banner'); if (b) b.textContent = t; };
|
|
51
54
|
(async () => {
|
|
52
55
|
try {
|
|
53
56
|
setBoot('instantiating wasm...');
|
|
54
57
|
// Artifact build: wasm-bindgen owns a private (non-shared) memory; no COOP/COEP needed.
|
|
55
|
-
await initOriverse({ module_or_path: "https://
|
|
58
|
+
await initOriverse({ module_or_path: "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.4/dist/oriverse_wgpu_bg.wasm" });
|
|
56
59
|
} catch (e) {
|
|
57
60
|
const msg = (e && e.stack) ? e.stack : String(e);
|
|
58
61
|
setBoot('WASM init failed:\n' + msg);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oriverse-engine",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Prebuilt Oriverse engine bundle (WebGPU wasm + js glue) for serverless single-player games authored as one game.html with inline Weave source. Compiled engine only - contains no source code.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"files": [
|