oriverse-engine 0.1.2 → 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.
@@ -1,21 +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
- try {
10
- device.addEventListener('uncapturederror', function(event) {
11
- const e = event.error;
12
- const name = (e && e.constructor && e.constructor.name) || 'GPUError';
13
- const msg = (e && e.message) || '';
14
- try { sink(name + ': ' + msg); } catch (_) {}
15
- try { console.error('[raw_webgpu_uncaptured]', name, msg); } catch (_) {}
16
- });
17
- } catch (_) {}
18
- return device;
19
- };
20
- } 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
+ };
21
60
  }
@@ -1,60 +1,22 @@
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
+ 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
  }
@@ -11,9 +11,9 @@ loader scripts or engine URLs.
11
11
 
12
12
  ## Before writing Weave, read the guide
13
13
 
14
- - https://unpkg.com/oriverse-engine@0.1.2/dist/GAME_AUTHORING.md — authoring patterns + 3 complete tested
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://unpkg.com/oriverse-engine@0.1.2/dist/weave_documentation.txt — full language + API reference.
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
@@ -11,9 +11,9 @@ loader scripts or engine URLs.
11
11
 
12
12
  ## Before writing Weave, read the guide
13
13
 
14
- - https://unpkg.com/oriverse-engine@0.1.2/dist/GAME_AUTHORING.md — authoring patterns + 3 complete tested
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://unpkg.com/oriverse-engine@0.1.2/dist/weave_documentation.txt — full language + API reference.
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
@@ -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 unpkg, your game is
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://unpkg.com/oriverse-engine@0.1.2/dist urls below (injected from
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://unpkg.com/oriverse-engine@0.1.2/dist/ktx_lib.js"></script>
47
- <script src="https://unpkg.com/oriverse-engine@0.1.2/dist/ktx_bridge.js"></script>
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://unpkg.com/oriverse-engine@0.1.2/dist/oriverse_wgpu.js";
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://unpkg.com/oriverse-engine@0.1.2/dist/oriverse_wgpu_bg.wasm" });
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);
@@ -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 unpkg, your game is
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://unpkg.com/oriverse-engine@0.1.2/dist urls below (injected from
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://unpkg.com/oriverse-engine@0.1.2/dist/ktx_lib.js"></script>
47
- <script src="https://unpkg.com/oriverse-engine@0.1.2/dist/ktx_bridge.js"></script>
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://unpkg.com/oriverse-engine@0.1.2/dist/oriverse_wgpu.js";
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://unpkg.com/oriverse-engine@0.1.2/dist/oriverse_wgpu_bg.wasm" });
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);
@@ -1,7 +1,7 @@
1
1
 
2
2
  >>>>>>>>>>>>
3
3
  Weave World Description Language Documentation
4
- Version:29Jul26-18:08-41702
4
+ Version:29Jul26-23:56-13158
5
5
  >>>>>>>>>>>>
6
6
 
7
7
  <weave_language>
@@ -264,7 +264,7 @@ event OnTuneChanged {
264
264
  - RandomNumber/RandomPosition* are deterministic (seeded per tick + calling object + call index, so repeated or cross-object same-tick calls draw fresh values); inside player input events (key/mouse/action) all Random* calls are seeded by that input edge instead, so the predicted result matches the final one. RandomChancePercent outside input events returns false during client prediction, so there use it only for delay-tolerant side effects (e.g. drops), not moment-to-moment combat.
265
265
  - Don't rely on cross-object event ordering (OnSpawned order across objects is unspecified).
266
266
  - Lobby/session APIs:
267
- - AdvertiseLobbySession/ListLobbySessionsForProject/JoinLobbySession are relay lobby discovery helpers for menus; sessions match only worlds with identical content (both sides run the same saved version).
267
+ - AdvertiseLobbySession()/ListLobbySessions()/JoinLobbySession are relay lobby discovery for menus; identity is automatic - sessions match only peers running this project with identical content (same saved version). LobbySessionStage(i) says which stage each session is on.
268
268
  - They do NOT create gameplay replication endpoints or change sim authority; once joined, the same shared deterministic simulation model applies.
269
269
  - Lobby UI lists real joined players via GetAllPlayers(); never simulate joins with a local counter/button.
270
270
  - AI players (bots): var bot = SpawnAIPlayer("Rival") spawns a real PlayerObject: '#class player' code + OnSpawned run for it, it appears in GetAllPlayers(), has physics/animations, but no user/camera/UI. The Name arg becomes the bot's object name and its GetPlayerName().
@@ -1350,14 +1350,10 @@ SetSunColor(Color: Vector) // Default: (1, 1, 1) white
1350
1350
  SetSunColor(R: Number, G: Number, B: Number)
1351
1351
  SetFogColor(Color: Vector)
1352
1352
  SetFogColor(R: Number, G: Number, B: Number)
1353
- LoadWorldFile(File: Text) // First File arg must be a direct string literal so packaging/oripak dependency scan and project game_id detection can see it.
1354
- LoadWorldFileWithInputs(File: Text, Input1: Number, Input2: Number) // First File arg must be a direct string literal so packaging/oripak dependency scan and project game_id detection can see it.
1355
1353
  LoadWorldTransferClear()
1356
1354
  LoadWorldTransferPush(Value: Number)
1357
1355
  LoadWorldTransferCount() -> Number
1358
1356
  LoadWorldTransferGet(Index: Number) -> Number
1359
- GetWorldInput1() -> Number
1360
- GetWorldInput2() -> Number
1361
1357
  GetVignetteStrength() -> Number
1362
1358
  GetVignetteRadius() -> Number
1363
1359
  GetVignetteSoftness() -> Number
@@ -1368,15 +1364,17 @@ PersistSetNumber(Player: Object, Key: Text, Value: Number)
1368
1364
  PersistAddNumber(Player: Object, Key: Text, Delta: Number)
1369
1365
  RefreshStaticBaseline() // Call once at the end of heavy static-scene init; non-moving objects then skip per-frame display CPU (a later manipulation opts that object out).
1370
1366
  RestartGame()
1371
- AdvertiseLobbySession(Project: Text) // Advertise this relay as a joinable lobby session for Project (this project/world's file name); not a gameplay replication/server-authority API.
1367
+ AdvertiseLobbySession() // Advertise this relay as a joinable lobby session for the running project; not a gameplay replication/server-authority API.
1372
1368
  StopAdvertisingLobbySession() // Stop advertising this relay lobby session.
1373
- ListLobbySessionsForProject(Project: Text) // Request discoverable relay lobby sessions for Project (this project/world's file name). Sessions match by a game id hashed from world content, so only content-identical worlds are found. Results update LobbySession* getters and fire OnLobbySessionListUpdated.
1369
+ ListLobbySessions() // Request discoverable lobby sessions of the running project (identity automatic, exact content version). Results update LobbySession* getters and fire OnLobbySessionListUpdated; state 2 with 0 sessions = nobody hosts this exact version.
1374
1370
  JoinLobbySession(RelayPubkey: Text) // Join a discovered relay lobby session by LobbySessionRelayPubkey; deterministic shared sim still applies after joining.
1375
- LobbySessionCount() -> Number // Number of discovered relay lobby sessions from the latest ListLobbySessionsForProject result.
1371
+ LobbySessionCount() -> Number // Number of discovered relay lobby sessions from the latest ListLobbySessions result.
1376
1372
  LobbySessionRelayPubkey(Index: Number) -> Text // Relay pubkey for a discovered lobby session; pass to JoinLobbySession.
1377
1373
  LobbySessionConnectId(Index: Number) -> Text // Debug/connect id for a discovered relay lobby session; usually not needed for gameplay code.
1378
1374
  LobbySessionDisplayName(Index: Number) -> Text // Human display name for a discovered relay lobby session.
1379
- LobbySessionRefreshState() -> Number // Latest lobby-session list state: 0 idle, 1 pending, 2 ok, 3 error (reason in the desktop client log, e.g. unresolvable LoadWorldFile deps).
1375
+ LobbySessionRefreshState() -> Number // Latest list state: 0 idle, 1 pending, 2 ok, 3 error (read LobbySessionErrorText).
1376
+ LobbySessionStage(Index: Number) -> Text // #stage name a discovered session is currently on (empty for stageless projects); show or filter it in the session browser.
1377
+ LobbySessionErrorText() -> Text // Reason for state 3 (empty otherwise), e.g. relay unreachable or no loaded world.
1380
1378
  AnyBasicType.NearestPlayerNonSpectator() -> Object
1381
1379
  SetSsrRoughnessFade(StartRoughness: Number, EndRoughness: Number) // Default: 0.68, 0.7
1382
1380
  SetSsrRayFade(NearFadePower: Number, FarFadePower: Number) // Default: 0.08, 0.8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oriverse-engine",
3
- "version": "0.1.2",
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": [