oriverse-engine 0.1.7 → 0.1.9

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.
@@ -1,36 +1,4 @@
1
1
 
2
- export function marketClientInitMessageBridge(worker) {
3
- if (!worker || typeof window === 'undefined') throw new Error('Worker and window required');
4
- if (window.marketClientMessageBridgeInitialized) return;
5
- window.marketClientMessageBridgeInitialized = true;
6
-
7
- window.top.marketClientWorker = worker;
8
- worker.addEventListener('message', (e) => {
9
- const data = e.data;
10
- if (data?.type === 'market-client-open-url' && data.value) window.open(data.value, '_blank');
11
- else if (data?.type === 'market-client-open-url-popup' && data.value) {
12
- const w = Math.min(560, Math.floor(screen.availWidth * 0.4));
13
- const h = Math.min(860, Math.floor(screen.availHeight * 0.9));
14
- const left = (screen.availLeft ?? 0) + screen.availWidth - w - 8;
15
- window.open(data.value, 'oriverse_connect_ai', `popup,width=${w},height=${h},left=${left},top=40`);
16
- }
17
- else if (data?.type?.startsWith('market-client-')) {
18
- window.top.postMessage(data, '*');
19
- }
20
- });
21
- }
22
- export function marketClientInitMessageListener(callback) {
23
- const target = typeof window !== 'undefined' ? window.top : (typeof self !== 'undefined' ? self : globalThis);
24
- target.addEventListener('message', (e) => {
25
- if (e.data?.type) callback(e.data.type);
26
- });
27
- }
28
- export function marketClientPostMessage(messageType, value) {
29
- const message = { type: messageType, ...(value != null && { value }) };
30
- if (typeof window !== 'undefined') {
31
- window.top.postMessage(message, '*');
32
- } else {
33
- const g = typeof self !== 'undefined' ? self : globalThis;
34
- g.postMessage(message);
35
- }
2
+ export function marketClientPageHostname() {
3
+ try { return (location && location.hostname) || ''; } catch (e) { return ''; }
36
4
  }
@@ -0,0 +1,36 @@
1
+
2
+ export function marketClientInitMessageBridge(worker) {
3
+ if (!worker || typeof window === 'undefined') throw new Error('Worker and window required');
4
+ if (window.marketClientMessageBridgeInitialized) return;
5
+ window.marketClientMessageBridgeInitialized = true;
6
+
7
+ window.top.marketClientWorker = worker;
8
+ worker.addEventListener('message', (e) => {
9
+ const data = e.data;
10
+ if (data?.type === 'market-client-open-url' && data.value) window.open(data.value, '_blank');
11
+ else if (data?.type === 'market-client-open-url-popup' && data.value) {
12
+ const w = Math.min(560, Math.floor(screen.availWidth * 0.4));
13
+ const h = Math.min(860, Math.floor(screen.availHeight * 0.9));
14
+ const left = (screen.availLeft ?? 0) + screen.availWidth - w - 8;
15
+ window.open(data.value, 'oriverse_connect_ai', `popup,width=${w},height=${h},left=${left},top=40`);
16
+ }
17
+ else if (data?.type?.startsWith('market-client-')) {
18
+ window.top.postMessage(data, '*');
19
+ }
20
+ });
21
+ }
22
+ export function marketClientInitMessageListener(callback) {
23
+ const target = typeof window !== 'undefined' ? window.top : (typeof self !== 'undefined' ? self : globalThis);
24
+ target.addEventListener('message', (e) => {
25
+ if (e.data?.type) callback(e.data.type);
26
+ });
27
+ }
28
+ export function marketClientPostMessage(messageType, value) {
29
+ const message = { type: messageType, ...(value != null && { value }) };
30
+ if (typeof window !== 'undefined') {
31
+ window.top.postMessage(message, '*');
32
+ } else {
33
+ const g = typeof self !== 'undefined' ? self : globalThis;
34
+ g.postMessage(message);
35
+ }
36
+ }
@@ -16,6 +16,7 @@ export function get_selected_candidate_info(stats) {
16
16
  remoteProtocol: remote.protocol || '',
17
17
  rttMs: pair.currentRoundTripTime != null ? pair.currentRoundTripTime * 1000 : -1,
18
18
  txBytes: pair.bytesSent || 0,
19
- rxBytes: pair.bytesReceived || 0
19
+ rxBytes: pair.bytesReceived || 0,
20
+ availOutBps: pair.availableOutgoingBitrate != null ? pair.availableOutgoingBitrate : -1
20
21
  };
21
22
  }
@@ -1,60 +1,28 @@
1
1
 
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
- };
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
+ // Only the engine's own device (wgpu_base::APP_DEVICE_LABEL) may escalate to the
10
+ // fatal path. Foreign devices — the index.html [pre_shader] throwaway runs at
11
+ // DEFAULT limits and its replay errors are fail-open by contract — still log
12
+ // through the sink for ring/field visibility (07Aug26 first-contact crash: a
13
+ // throwaway-device validation error killed a healthy boot).
14
+ const isApp = !!(desc && desc.label === 'oriverse-app-device');
15
+ if (isApp) { try { window.__ori_gpu_device = device; } catch (_) {} }
16
+ try {
17
+ device.addEventListener('uncapturederror', function(event) {
18
+ const e = event.error;
19
+ const name = (e && e.constructor && e.constructor.name) || 'GPUError';
20
+ const msg = (e && e.message) || '';
21
+ try { sink(name, msg, isApp); } catch (_) {}
22
+ try { console.error(isApp ? '[raw_webgpu_uncaptured]' : '[raw_webgpu_uncaptured_foreign]', name, msg); } catch (_) {}
23
+ });
24
+ } catch (_) {}
25
+ return device;
26
+ };
27
+ } catch (_) {}
60
28
  }
@@ -1,28 +1,60 @@
1
1
 
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
- // Only the engine's own device (wgpu_base::APP_DEVICE_LABEL) may escalate to the
10
- // fatal path. Foreign devices — the index.html [pre_shader] throwaway runs at
11
- // DEFAULT limits and its replay errors are fail-open by contract — still log
12
- // through the sink for ring/field visibility (07Aug26 first-contact crash: a
13
- // throwaway-device validation error killed a healthy boot).
14
- const isApp = !!(desc && desc.label === 'oriverse-app-device');
15
- if (isApp) { try { window.__ori_gpu_device = device; } catch (_) {} }
16
- try {
17
- device.addEventListener('uncapturederror', function(event) {
18
- const e = event.error;
19
- const name = (e && e.constructor && e.constructor.name) || 'GPUError';
20
- const msg = (e && e.message) || '';
21
- try { sink(name, msg, isApp); } catch (_) {}
22
- try { console.error(isApp ? '[raw_webgpu_uncaptured]' : '[raw_webgpu_uncaptured_foreign]', name, msg); } catch (_) {}
23
- });
24
- } catch (_) {}
25
- return device;
26
- };
27
- } catch (_) {}
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
+ };
28
60
  }
@@ -11,9 +11,9 @@ loader scripts or engine URLs.
11
11
 
12
12
  ## Before writing Weave, read the guide
13
13
 
14
- - https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/GAME_AUTHORING.md — authoring patterns + 3 complete tested
14
+ - https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/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://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/weave_documentation.txt — full language + API reference.
16
+ - https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/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
@@ -11,9 +11,9 @@ loader scripts or engine URLs.
11
11
 
12
12
  ## Before writing Weave, read the guide
13
13
 
14
- - https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/GAME_AUTHORING.md — authoring patterns + 3 complete tested
14
+ - https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/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://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/weave_documentation.txt — full language + API reference.
16
+ - https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/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
@@ -2,7 +2,7 @@
2
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://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist urls below (injected from
5
+ The engine version is pinned in the https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/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. Google Fonts
@@ -46,18 +46,18 @@ object BlueCube {
46
46
 
47
47
  <!-- Shader prewarm: replays the build's pipeline manifest on a throwaway device during
48
48
  engine download dead-time (kills the first-view compile freeze). Fail-open. -->
49
- <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/prewarm.js"></script>
49
+ <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/prewarm.js"></script>
50
50
  <!-- KTX2 texture transcoder sidecar (classic scripts; ktx_lib.wasm resolves relative to the script url). -->
51
- <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/ktx_lib.js"></script>
52
- <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/ktx_bridge.js"></script>
51
+ <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/ktx_lib.js"></script>
52
+ <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/ktx_bridge.js"></script>
53
53
  <script type="module">
54
- import initOriverse from "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/oriverse_wgpu.js";
54
+ import initOriverse from "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/oriverse_wgpu.js";
55
55
  const setBoot = (t) => { const b = document.getElementById('oriverse-status-banner'); if (b) b.textContent = t; };
56
56
  (async () => {
57
57
  try {
58
58
  setBoot('starting engine…');
59
59
  // Artifact build: wasm-bindgen owns a private (non-shared) memory; no COOP/COEP needed.
60
- await initOriverse({ module_or_path: "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/oriverse_wgpu_bg.wasm" });
60
+ await initOriverse({ module_or_path: "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/oriverse_wgpu_bg.wasm" });
61
61
  } catch (e) {
62
62
  const msg = (e && e.stack) ? e.stack : String(e);
63
63
  setBoot('WASM init failed:\n' + msg);
@@ -2,7 +2,7 @@
2
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://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist urls below (injected from
5
+ The engine version is pinned in the https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/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. Google Fonts
@@ -46,18 +46,18 @@ object BlueCube {
46
46
 
47
47
  <!-- Shader prewarm: replays the build's pipeline manifest on a throwaway device during
48
48
  engine download dead-time (kills the first-view compile freeze). Fail-open. -->
49
- <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/prewarm.js"></script>
49
+ <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/prewarm.js"></script>
50
50
  <!-- KTX2 texture transcoder sidecar (classic scripts; ktx_lib.wasm resolves relative to the script url). -->
51
- <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/ktx_lib.js"></script>
52
- <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/ktx_bridge.js"></script>
51
+ <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/ktx_lib.js"></script>
52
+ <script src="https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/ktx_bridge.js"></script>
53
53
  <script type="module">
54
- import initOriverse from "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/oriverse_wgpu.js";
54
+ import initOriverse from "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/oriverse_wgpu.js";
55
55
  const setBoot = (t) => { const b = document.getElementById('oriverse-status-banner'); if (b) b.textContent = t; };
56
56
  (async () => {
57
57
  try {
58
58
  setBoot('starting engine…');
59
59
  // Artifact build: wasm-bindgen owns a private (non-shared) memory; no COOP/COEP needed.
60
- await initOriverse({ module_or_path: "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.7/dist/oriverse_wgpu_bg.wasm" });
60
+ await initOriverse({ module_or_path: "https://cdn.jsdelivr.net/npm/oriverse-engine@0.1.9/dist/oriverse_wgpu_bg.wasm" });
61
61
  } catch (e) {
62
62
  const msg = (e && e.stack) ? e.stack : String(e);
63
63
  setBoot('WASM init failed:\n' + msg);