@kvyverse/world-runtime 0.4.2 → 0.5.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.
@@ -26,6 +26,7 @@ export declare class WorldRuntime implements RuntimeApi {
26
26
  /** Reverse index for `getUrl(resource)` — play mode resolves objects too. */
27
27
  private readonly _pathByResource;
28
28
  private _ctx;
29
+ private _starter;
29
30
  private _bloom;
30
31
  private _scriptContext;
31
32
  constructor(definition: RuntimeDefinitionSlice, options: LoadWorldOptions);
@@ -35,6 +36,8 @@ export declare class WorldRuntime implements RuntimeApi {
35
36
  get ctx(): ThreeContext;
36
37
  /** @internal Set by bootstrap. */
37
38
  setContext(ctx: ThreeContext): void;
39
+ /** @internal Set by bootstrap — backs `world.addModules` (register before start). */
40
+ setStarter(starter: ThreeStart): void;
38
41
  /** @internal World bloom, if enabled in the renderer config. */
39
42
  setBloom(bloom: SceneBloom): void;
40
43
  /** @internal Libs (config + required by modules/behaviours) and externals. */
package/dist/index.js CHANGED
@@ -1332,6 +1332,7 @@ var WorldRuntime = class {
1332
1332
  /** Reverse index for `getUrl(resource)` — play mode resolves objects too. */
1333
1333
  _pathByResource = /* @__PURE__ */ new Map();
1334
1334
  _ctx = null;
1335
+ _starter = null;
1335
1336
  _bloom = null;
1336
1337
  _scriptContext = null;
1337
1338
  constructor(definition, options) {
@@ -1352,6 +1353,10 @@ var WorldRuntime = class {
1352
1353
  setContext(ctx) {
1353
1354
  this._ctx = ctx;
1354
1355
  }
1356
+ /** @internal Set by bootstrap — backs `world.addModules` (register before start). */
1357
+ setStarter(starter) {
1358
+ this._starter = starter;
1359
+ }
1355
1360
  /** @internal World bloom, if enabled in the renderer config. */
1356
1361
  setBloom(bloom) {
1357
1362
  this._bloom = bloom;
@@ -1538,7 +1543,11 @@ var WorldRuntime = class {
1538
1543
  stores: this.stores,
1539
1544
  rendering: { get bloom() {
1540
1545
  return runtime.bloomApi;
1541
- } }
1546
+ } },
1547
+ addModules: (modules) => {
1548
+ if (!runtime._starter) throw new Error("world.addModules is only available in the entry script (main.ts), before the world starts.");
1549
+ runtime._starter.addModules(modules);
1550
+ }
1542
1551
  },
1543
1552
  modules: lazyProxy(() => runtime.ctx.modules),
1544
1553
  require: this.require,
@@ -1566,7 +1575,7 @@ function isAbsoluteUrl(url) {
1566
1575
  }
1567
1576
  //#endregion
1568
1577
  //#region packages/world-runtime/src/version.gen.ts
1569
- var RUNTIME_VERSION = "0.4.2";
1578
+ var RUNTIME_VERSION = "0.5.0";
1570
1579
  //#endregion
1571
1580
  //#region packages/world-runtime/src/version.ts
1572
1581
  /**
@@ -1604,6 +1613,7 @@ async function bootstrapWorld(definition, options) {
1604
1613
  runtime.reportProgress("Initializing 3D context");
1605
1614
  const world = await createWorld(definition, runtime);
1606
1615
  runtime.setContext(world.ctx);
1616
+ runtime.setStarter(world);
1607
1617
  await runtime.applyRequiredPatches(world);
1608
1618
  runtime.reportProgress("Applying scene settings");
1609
1619
  definition.applySceneSettings?.(runtime, world.ctx.scene);
@@ -1 +1 @@
1
- export declare const RUNTIME_VERSION = "0.4.2";
1
+ export declare const RUNTIME_VERSION = "0.5.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kvyverse/world-runtime",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Runtime for worlds exported from the Kvyverse platform for self-hosting",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Vladislav Kruteniuk",