@kvyverse/world-runtime 0.6.2 → 0.6.8

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.
Files changed (39) hide show
  1. package/LICENSE.md +2 -2
  2. package/README.md +2 -2
  3. package/dist/{BallCollider-DdxrnexK.js → BallCollider-3L5vOrcL.js} +3 -3
  4. package/dist/{CapsuleCollider-XlGZqg_O.js → CapsuleCollider-CBTsR-Ys.js} +3 -3
  5. package/dist/{ChatModule-DzNY_v-3.js → ChatModule-BFNVVLA8.js} +65 -40
  6. package/dist/{Collider-ElnvKET2.js → Collider-CPUCG3RA.js} +2 -2
  7. package/dist/{ConeCollider-CQfGphDa.js → ConeCollider-C3XU3Y9X.js} +3 -3
  8. package/dist/{ConvexMeshCollider-0Q2u7QAL.js → ConvexMeshCollider-DzNV4HTO.js} +2 -2
  9. package/dist/{CuboidCollider-Cm7kKRMA.js → CuboidCollider-Dp1DZoFM.js} +2 -2
  10. package/dist/{CylinderCollider-P2oZeEyb.js → CylinderCollider-C0h_nhB5.js} +3 -3
  11. package/dist/{FpsCameraController-CuYDbMHJ.js → FpsCameraController-2GNWJM5D.js} +1 -1
  12. package/dist/{MeshInstansing-CSd1gjpu.js → MeshInstansing-Bxij0Yc9.js} +1 -1
  13. package/dist/{PointerLockCameraControls-Cq0m2NLS.js → PointerLockCameraControls-DIK3cVmo.js} +1 -1
  14. package/dist/{RapierDebugRenderer-BSsFENi2.js → RapierDebugRenderer-BQy_m-3C.js} +1 -1
  15. package/dist/{RapierFpsPlayerController-By_mnB5m.js → RapierFpsPlayerController-DthD8dw9.js} +1 -1
  16. package/dist/{RapierPhysics-C22OXUaE.js → RapierPhysics-yrsRPFS3.js} +3 -3
  17. package/dist/{Rigidbody-BHRxJKXd.js → Rigidbody-DLhN8ddv.js} +1 -1
  18. package/dist/{ScalingToFro-CmXQHfR5.js → ScalingToFro-BD-E5-uR.js} +1 -1
  19. package/dist/{SightInteractableArea-C7xBqoQo.js → SightInteractableArea-BK8IXNIl.js} +7 -7
  20. package/dist/{SimpleWASDMovement-BYu0AFeG.js → SimpleWASDMovement-C2m53YYH.js} +1 -1
  21. package/dist/{Spinning-DDhlLF3g.js → Spinning-sgUhHld8.js} +1 -1
  22. package/dist/{StartAnimation-BbY1HgSj.js → StartAnimation-B9eomOS2.js} +1 -1
  23. package/dist/{TrimeshCollider-CGirnNOf.js → TrimeshCollider-7dIs_xtZ.js} +1 -1
  24. package/dist/addons/AddonsRuntime.d.ts +3 -4
  25. package/dist/addons/lib-registry.d.ts +2 -1
  26. package/dist/behaviours/player/SightInteractableArea.d.ts +2 -2
  27. package/dist/{chat.module-descriptor-BMy5jpOU.js → chat.module-descriptor-CGeOaq16.js} +3 -3
  28. package/dist/{get-scale-from-obj-bFMquHMV.js → get-scale-from-obj-B7JlVPni.js} +1 -1
  29. package/dist/index.d.ts +2 -1
  30. package/dist/index.js +100 -69
  31. package/dist/{lib-registry-B-NnzKUx.js → lib-registry-CPwXvdYs.js} +8 -1
  32. package/dist/modules/chat/ChatDom.d.ts +16 -10
  33. package/dist/modules/contracts/platform.module-api.d.ts +60 -0
  34. package/dist/modules/index.d.ts +6 -0
  35. package/dist/modules/optional-module-descriptor.d.ts +7 -0
  36. package/dist/modules/platform/NullPlatformModule.d.ts +16 -0
  37. package/dist/modules/registry.d.ts +4 -0
  38. package/dist/version.gen.d.ts +1 -1
  39. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as OPTIONAL_MODULE_IDS, i as normalizeChat, n as CHAT_INPUT_MODES, o as OptionalModuleId, r as chatModuleDescriptor } from "./chat.module-descriptor-BMy5jpOU.js";
2
- import { a as LibId, c as libByRequireKey, i as LIB_IDS, n as LIBS, o as OPTIONAL_LIB_DESCRIPTORS, r as LIB_DESCRIPTORS, s as OPTIONAL_LIB_IDS, t as BUILTIN_LIB_DESCRIPTORS } from "./lib-registry-B-NnzKUx.js";
3
- import { n as getRadiusScale, t as getHalfheightRadiusScale } from "./get-scale-from-obj-bFMquHMV.js";
1
+ import { a as OPTIONAL_MODULE_IDS, i as normalizeChat, n as CHAT_INPUT_MODES, o as OptionalModuleId, r as chatModuleDescriptor } from "./chat.module-descriptor-CGeOaq16.js";
2
+ import { a as LibId, c as libByRequireKey, i as LIB_IDS, n as LIBS, o as OPTIONAL_LIB_DESCRIPTORS, r as LIB_DESCRIPTORS, s as OPTIONAL_LIB_IDS, t as BUILTIN_LIB_DESCRIPTORS } from "./lib-registry-CPwXvdYs.js";
3
+ import { n as getRadiusScale, t as getHalfheightRadiusScale } from "./get-scale-from-obj-B7JlVPni.js";
4
4
  import * as THREE from "three/webgpu";
5
5
  import { BufferGeometryLoader, LoadingManager, TextureLoader } from "three/webgpu";
6
6
  import * as ThreeStartNS from "three-start";
@@ -15,7 +15,7 @@ import { clone } from "three/examples/jsm/utils/SkeletonUtils.js";
15
15
  import EventEmitter from "eventemitter3";
16
16
  import * as nanostores from "nanostores";
17
17
  import { atom } from "nanostores";
18
- //#region src/world-events.ts
18
+ //#region packages/world-runtime/src/world-events.ts
19
19
  /**
20
20
  * World lifecycle events, emitted on `game.emitter` (`world.events` in scripts)
21
21
  * during classic-load. The entry script runs BEFORE them (step 9) — subscriptions
@@ -31,7 +31,7 @@ var WorldEvent = /* @__PURE__ */ function(WorldEvent) {
31
31
  return WorldEvent;
32
32
  }({});
33
33
  //#endregion
34
- //#region src/World.ts
34
+ //#region packages/world-runtime/src/World.ts
35
35
  /**
36
36
  * A loaded world is a three-start app with the scene already assembled.
37
37
  * Mounting and starting are manual: `mount(container)` attaches the canvas and
@@ -66,7 +66,7 @@ var World = class extends ThreeStart {
66
66
  }
67
67
  };
68
68
  //#endregion
69
- //#region src/utils/lazy.ts
69
+ //#region packages/world-runtime/src/utils/lazy.ts
70
70
  /**
71
71
  * Object that forwards every access to `resolve()`. For script globals that are
72
72
  * shortcuts into something created later (`modules` → `ctx.modules`): the script
@@ -100,7 +100,7 @@ function lazy(factory) {
100
100
  } };
101
101
  }
102
102
  //#endregion
103
- //#region src/resources/loaders.ts
103
+ //#region packages/world-runtime/src/resources/loaders.ts
104
104
  var LOADING_MANAGER = new LoadingManager();
105
105
  LOADING_MANAGER.onError = (url) => {
106
106
  console.error(`Loading asset failed: ${url}`);
@@ -174,7 +174,7 @@ var AssetLoaders = {
174
174
  })
175
175
  };
176
176
  //#endregion
177
- //#region src/rendering/renderer-apply.ts
177
+ //#region packages/world-runtime/src/rendering/renderer-apply.ts
178
178
  var SHADOW_MAP_TYPES$1 = {
179
179
  Basic: THREE.BasicShadowMap,
180
180
  PCF: THREE.PCFShadowMap,
@@ -210,7 +210,7 @@ function applyRendererConfig(renderer, cfg) {
210
210
  renderer.setPixelRatio(window.devicePixelRatio * pixelResolution);
211
211
  }
212
212
  //#endregion
213
- //#region src/rendering/SceneBloom.ts
213
+ //#region packages/world-runtime/src/rendering/SceneBloom.ts
214
214
  /** BloomNode loads as a chunk only when bloom is enabled. */
215
215
  var lazyBloomModule = lazy(() => import("three/addons/tsl/display/BloomNode.js"));
216
216
  /**
@@ -296,7 +296,7 @@ function finiteOr(value, fallback) {
296
296
  return typeof value === "number" && Number.isFinite(value) ? value : fallback;
297
297
  }
298
298
  //#endregion
299
- //#region src/modules/controls/KeyboardControlsDriver.ts
299
+ //#region packages/world-runtime/src/modules/controls/KeyboardControlsDriver.ts
300
300
  /** A diagonal must not be faster than a straight line. */
301
301
  var DIAGONAL = Math.SQRT1_2;
302
302
  /**
@@ -328,7 +328,7 @@ var KeyboardControlsDriver = class {
328
328
  }
329
329
  };
330
330
  //#endregion
331
- //#region src/modules/controls/ControlsModule.ts
331
+ //#region packages/world-runtime/src/modules/controls/ControlsModule.ts
332
332
  /**
333
333
  * The player's movement intent — what they want to do, whatever the hardware is.
334
334
  * Input sources register as drivers (`addDriver`); the module polls them once a
@@ -441,8 +441,8 @@ var ControlsModule = class extends ContextModule {
441
441
  }
442
442
  };
443
443
  //#endregion
444
- //#region src/behaviours/physics/_required-patch.ts
445
- var lazyRapierPhysicsModule = lazy(async () => (await import("./RapierPhysics-C22OXUaE.js")).default);
444
+ //#region packages/world-runtime/src/behaviours/physics/_required-patch.ts
445
+ var lazyRapierPhysicsModule = lazy(async () => (await import("./RapierPhysics-yrsRPFS3.js")).default);
446
446
  /** The only place the physics module is created — called by the registry
447
447
  * descriptor. The module itself takes rapier from `ctx.modules.addons` on awake. */
448
448
  async function createRapierPhysicsModule(config) {
@@ -468,7 +468,7 @@ async function applyRapierPhysicsPatch(starter) {
468
468
  starter.addModules({ rapier: module });
469
469
  }
470
470
  //#endregion
471
- //#region src/modules/physics/physics.module-descriptor.ts
471
+ //#region packages/world-runtime/src/modules/physics/physics.module-descriptor.ts
472
472
  var PHYSICS_ENGINES = ["rapier"];
473
473
  /** Physics defaults: the rapier engine, debug off. */
474
474
  function normalizePhysics(value) {
@@ -484,6 +484,7 @@ function normalizePhysics(value) {
484
484
  }
485
485
  var physicsModuleDescriptor = {
486
486
  id: OptionalModuleId.Physics,
487
+ ctxKey: "rapier",
487
488
  normalize: (raw) => normalizePhysics(raw),
488
489
  defaultConfig: () => ({
489
490
  engine: "rapier",
@@ -521,7 +522,7 @@ var physicsModuleDescriptor = {
521
522
  }
522
523
  };
523
524
  //#endregion
524
- //#region src/modules/optional-modules.ts
525
+ //#region packages/world-runtime/src/modules/optional-modules.ts
525
526
  /**
526
527
  * Table of contents for the world's pluggable modules: what can be enabled from
527
528
  * `settings.addons.json → modules`. The descriptors themselves live next to
@@ -538,7 +539,7 @@ function getOptionalModuleDescriptor(id) {
538
539
  return descriptor;
539
540
  }
540
541
  //#endregion
541
- //#region src/modules/is-mobile-device.ts
542
+ //#region packages/world-runtime/src/modules/is-mobile-device.ts
542
543
  function isMobileDevice() {
543
544
  if (typeof navigator === "undefined" || typeof window === "undefined") return false;
544
545
  const ua = navigator.userAgent || navigator.vendor || window.opera;
@@ -549,7 +550,7 @@ function isMobileDevice() {
549
550
  return "ontouchstart" in window || navigator.maxTouchPoints && navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
550
551
  }
551
552
  //#endregion
552
- //#region src/modules/EnvModule.ts
553
+ //#region packages/world-runtime/src/modules/EnvModule.ts
553
554
  var EnvModule = class extends ContextModule {
554
555
  mode;
555
556
  dev;
@@ -566,7 +567,7 @@ var EnvModule = class extends ContextModule {
566
567
  }
567
568
  };
568
569
  //#endregion
569
- //#region src/modules/HtmlHudModule.ts
570
+ //#region packages/world-runtime/src/modules/HtmlHudModule.ts
570
571
  var { div } = van.tags;
571
572
  var LAYER_STYLE = "position:fixed;inset:0;pointer-events:none;";
572
573
  var HtmlHudModule = class extends ContextModule {
@@ -622,7 +623,7 @@ var HtmlHudModule = class extends ContextModule {
622
623
  };
623
624
  };
624
625
  //#endregion
625
- //#region src/modules/InputSystemModule.ts
626
+ //#region packages/world-runtime/src/modules/InputSystemModule.ts
626
627
  var InputSystemModule = class extends ContextModule {
627
628
  _dom;
628
629
  _keys = /* @__PURE__ */ new Set();
@@ -874,7 +875,37 @@ function isUiKeyboardTarget(target) {
874
875
  }
875
876
  }
876
877
  //#endregion
877
- //#region src/modules/SoundsModule.ts
878
+ //#region packages/world-runtime/src/modules/platform/NullPlatformModule.ts
879
+ var NO_PARAMS = Object.freeze({});
880
+ var NULL_PLAYER = {
881
+ username: null,
882
+ storage: {
883
+ get: () => Promise.resolve(null),
884
+ save: () => Promise.resolve()
885
+ }
886
+ };
887
+ /**
888
+ * `world.platform` без платформы: self-hosted экспорт, мир без моста. Все вызовы
889
+ * безопасны — чтения пустые, записи ничего не делают. Мир на платформе получает
890
+ * вместо него реализацию хоста, переданную в `createWorldModules({ platform })`.
891
+ */
892
+ var NullPlatformModule = class extends ContextModule {
893
+ available = false;
894
+ player = NULL_PLAYER;
895
+ openedWith = NO_PARAMS;
896
+ referrer = null;
897
+ openWorld() {
898
+ return Promise.resolve(false);
899
+ }
900
+ resolveWorld() {
901
+ return Promise.resolve(null);
902
+ }
903
+ openLink() {
904
+ return Promise.resolve(false);
905
+ }
906
+ };
907
+ //#endregion
908
+ //#region packages/world-runtime/src/modules/SoundsModule.ts
878
909
  var SoundsModule = class extends ContextModule {
879
910
  global = Howler;
880
911
  /** three-start ContextModule has no onDestroy; teardown is explicit. */
@@ -883,7 +914,7 @@ var SoundsModule = class extends ContextModule {
883
914
  }
884
915
  };
885
916
  //#endregion
886
- //#region src/modules/UtilsModule.ts
917
+ //#region packages/world-runtime/src/modules/UtilsModule.ts
887
918
  var UtilsModule = class extends ContextModule {
888
919
  cloneObject3D;
889
920
  mergeGeometries;
@@ -894,7 +925,7 @@ var UtilsModule = class extends ContextModule {
894
925
  }
895
926
  };
896
927
  //#endregion
897
- //#region src/modules/index.ts
928
+ //#region packages/world-runtime/src/modules/index.ts
898
929
  /**
899
930
  * Assembles the world's ctx modules: core ones always, pluggable ones per config.
900
931
  * Pluggable classes are pulled dynamically, so a disabled module never reaches
@@ -912,6 +943,7 @@ async function createWorldModules(mode = "prod", options) {
912
943
  env: new EnvModule(mode),
913
944
  html: new HtmlHudModule(),
914
945
  input: new InputSystemModule(),
946
+ platform: options.platform ?? new NullPlatformModule(),
915
947
  sounds: new SoundsModule(),
916
948
  utils: new UtilsModule()
917
949
  };
@@ -919,7 +951,7 @@ async function createWorldModules(mode = "prod", options) {
919
951
  const config = descriptor.normalize(options.modules?.[descriptor.id]);
920
952
  if (!config) continue;
921
953
  try {
922
- modules[descriptor.id] = await descriptor.create(config);
954
+ modules[descriptor.ctxKey ?? descriptor.id] = await descriptor.create(config);
923
955
  } catch (error) {
924
956
  console.error(`[modules] failed to create "${descriptor.id}"`, error);
925
957
  }
@@ -927,100 +959,100 @@ async function createWorldModules(mode = "prod", options) {
927
959
  return modules;
928
960
  }
929
961
  //#endregion
930
- //#region src/behaviours/registry.ts
962
+ //#region packages/world-runtime/src/behaviours/registry.ts
931
963
  var entries = [
932
964
  {
933
965
  uuid: "spinning",
934
966
  name: "Spinning",
935
- load: () => loadDefault(import("./Spinning-DDhlLF3g.js"))
967
+ load: () => loadDefault(import("./Spinning-sgUhHld8.js"))
936
968
  },
937
969
  {
938
970
  uuid: "scalingtofro",
939
971
  name: "ScalingToFro",
940
- load: () => loadDefault(import("./ScalingToFro-CmXQHfR5.js"))
972
+ load: () => loadDefault(import("./ScalingToFro-BD-E5-uR.js"))
941
973
  },
942
974
  {
943
975
  uuid: "startanim",
944
976
  name: "StartAnimation",
945
- load: () => loadDefault(import("./StartAnimation-BbY1HgSj.js"))
977
+ load: () => loadDefault(import("./StartAnimation-B9eomOS2.js"))
946
978
  },
947
979
  {
948
980
  uuid: "pointerlockcameracontrols",
949
981
  name: "PointerLockCameraController",
950
- load: () => loadDefault(import("./PointerLockCameraControls-Cq0m2NLS.js"))
982
+ load: () => loadDefault(import("./PointerLockCameraControls-DIK3cVmo.js"))
951
983
  },
952
984
  {
953
985
  uuid: "simplewasdmovement",
954
986
  name: "SimpleWASDMovement",
955
- load: () => loadDefault(import("./SimpleWASDMovement-BYu0AFeG.js"))
987
+ load: () => loadDefault(import("./SimpleWASDMovement-C2m53YYH.js"))
956
988
  },
957
989
  {
958
990
  uuid: "fpscameracontroller",
959
991
  name: "FpsCameraController",
960
- load: () => loadDefault(import("./FpsCameraController-CuYDbMHJ.js"))
992
+ load: () => loadDefault(import("./FpsCameraController-2GNWJM5D.js"))
961
993
  },
962
994
  {
963
995
  uuid: "sightinteractablearea",
964
996
  name: "SightInteractableArea",
965
- load: () => loadDefault(import("./SightInteractableArea-C7xBqoQo.js"))
997
+ load: () => loadDefault(import("./SightInteractableArea-BK8IXNIl.js"))
966
998
  },
967
999
  {
968
1000
  uuid: "meshinstansing",
969
1001
  name: "MeshInstansing",
970
- load: () => loadDefault(import("./MeshInstansing-CSd1gjpu.js"))
1002
+ load: () => loadDefault(import("./MeshInstansing-Bxij0Yc9.js"))
971
1003
  },
972
1004
  {
973
1005
  uuid: "rrb",
974
1006
  name: "Rigidbody",
975
- load: () => loadDefault(import("./Rigidbody-BHRxJKXd.js").then((n) => n.n)),
1007
+ load: () => loadDefault(import("./Rigidbody-DLhN8ddv.js").then((n) => n.n)),
976
1008
  requiredPatch: rapierPhysicsPatch
977
1009
  },
978
1010
  {
979
1011
  uuid: "rapierballcol",
980
1012
  name: "BallCollider",
981
- load: () => loadDefault(import("./BallCollider-DdxrnexK.js")),
1013
+ load: () => loadDefault(import("./BallCollider-3L5vOrcL.js")),
982
1014
  requiredPatch: rapierPhysicsPatch
983
1015
  },
984
1016
  {
985
1017
  uuid: "rapiercapscol",
986
1018
  name: "CapsuleCollider",
987
- load: () => loadDefault(import("./CapsuleCollider-XlGZqg_O.js")),
1019
+ load: () => loadDefault(import("./CapsuleCollider-CBTsR-Ys.js")),
988
1020
  requiredPatch: rapierPhysicsPatch
989
1021
  },
990
1022
  {
991
1023
  uuid: "rapierconecol",
992
1024
  name: "ConeCollider",
993
- load: () => loadDefault(import("./ConeCollider-CQfGphDa.js")),
1025
+ load: () => loadDefault(import("./ConeCollider-C3XU3Y9X.js")),
994
1026
  requiredPatch: rapierPhysicsPatch
995
1027
  },
996
1028
  {
997
1029
  uuid: "rapierconvxcol",
998
1030
  name: "ConvexMeshCollider",
999
- load: () => loadDefault(import("./ConvexMeshCollider-0Q2u7QAL.js")),
1031
+ load: () => loadDefault(import("./ConvexMeshCollider-DzNV4HTO.js")),
1000
1032
  requiredPatch: rapierPhysicsPatch
1001
1033
  },
1002
1034
  {
1003
1035
  uuid: "rapiercubcol",
1004
1036
  name: "CuboidCollider",
1005
- load: () => loadDefault(import("./CuboidCollider-Cm7kKRMA.js")),
1037
+ load: () => loadDefault(import("./CuboidCollider-Dp1DZoFM.js")),
1006
1038
  requiredPatch: rapierPhysicsPatch
1007
1039
  },
1008
1040
  {
1009
1041
  uuid: "rapiercylcol",
1010
1042
  name: "CylinderCollider",
1011
- load: () => loadDefault(import("./CylinderCollider-P2oZeEyb.js")),
1043
+ load: () => loadDefault(import("./CylinderCollider-C0h_nhB5.js")),
1012
1044
  requiredPatch: rapierPhysicsPatch
1013
1045
  },
1014
1046
  {
1015
1047
  uuid: "rapiertricol",
1016
1048
  name: "TrimeshCollider",
1017
- load: () => loadDefault(import("./TrimeshCollider-CGirnNOf.js")),
1049
+ load: () => loadDefault(import("./TrimeshCollider-7dIs_xtZ.js")),
1018
1050
  requiredPatch: rapierPhysicsPatch
1019
1051
  },
1020
1052
  {
1021
1053
  uuid: "rapierfpsplayercontroller",
1022
1054
  name: "RapierFpsPlayerController",
1023
- load: () => loadDefault(import("./RapierFpsPlayerController-By_mnB5m.js")),
1055
+ load: () => loadDefault(import("./RapierFpsPlayerController-DthD8dw9.js")),
1024
1056
  requiredPatch: rapierPhysicsPatch
1025
1057
  }
1026
1058
  ];
@@ -1034,7 +1066,7 @@ async function loadDefault(module) {
1034
1066
  return (await module).default;
1035
1067
  }
1036
1068
  //#endregion
1037
- //#region src/resources/font.ts
1069
+ //#region packages/world-runtime/src/resources/font.ts
1038
1070
  var FORMAT_BY_MIME = {
1039
1071
  "font/ttf": "truetype",
1040
1072
  "font/otf": "opentype",
@@ -1096,7 +1128,7 @@ function createFont(url, family, mime, name) {
1096
1128
  return source;
1097
1129
  }
1098
1130
  //#endregion
1099
- //#region src/addons/builtin-libs.ts
1131
+ //#region packages/world-runtime/src/addons/builtin-libs.ts
1100
1132
  /**
1101
1133
  * Libraries the runtime bundles itself: `require("<key>")` hands these back in
1102
1134
  * every world, no config and no importer involved. Metadata (keys, labels) is
@@ -1123,7 +1155,7 @@ var BUILTIN_GLOBALS = {
1123
1155
  van
1124
1156
  };
1125
1157
  //#endregion
1126
- //#region src/addons/required-libs.ts
1158
+ //#region packages/world-runtime/src/addons/required-libs.ts
1127
1159
  /**
1128
1160
  * Libs the world needs beyond what `libs` lists: an enabled module or a built-in
1129
1161
  * behaviour on the scene declares them itself (`requiredLibs`), so physics keeps
@@ -1146,7 +1178,7 @@ function collectRequiredLibs(addons, usedBuiltinUuids = []) {
1146
1178
  return [...required];
1147
1179
  }
1148
1180
  //#endregion
1149
- //#region src/addons/AddonsRuntime.ts
1181
+ //#region packages/world-runtime/src/addons/AddonsRuntime.ts
1150
1182
  /**
1151
1183
  * External dependencies of the world: libs and external scripts. Built-in libs
1152
1184
  * are registered right away (the runtime bundles them), optional ones are loaded
@@ -1154,10 +1186,9 @@ function collectRequiredLibs(addons, usedBuiltinUuids = []) {
1154
1186
  * by a module/behaviour through `requiredLibs`. Scripts reach all of them by
1155
1187
  * `require("<key>")`.
1156
1188
  *
1157
- * This is the `addons` ctx module, but it also works without a ctx: launcher
1158
- * worlds have no 3d context while `require` still has to work, so there the
1159
- * instance is used directly. How to import optional packages is up to the
1160
- * runtime owner (see `WorldImports`).
1189
+ * This is the `addons` ctx module, but it is loaded before the ctx exists: a
1190
+ * module may need its lib (physics needs rapier) the moment the ctx is built.
1191
+ * How to import optional packages is up to the runtime owner (see `WorldImports`).
1161
1192
  */
1162
1193
  var AddonsRuntime = class extends ContextModule {
1163
1194
  _imports;
@@ -1253,7 +1284,7 @@ function unwrapLib(id, module) {
1253
1284
  return module.default ?? module;
1254
1285
  }
1255
1286
  //#endregion
1256
- //#region src/world-stores.ts
1287
+ //#region packages/world-runtime/src/world-stores.ts
1257
1288
  /**
1258
1289
  * Shared reactive key-value state of a world (`world.stores` in scripts) — the
1259
1290
  * state counterpart of the `world.events` bus. Stores are created lazily on
@@ -1314,7 +1345,7 @@ var WorldStores = class {
1314
1345
  }
1315
1346
  };
1316
1347
  //#endregion
1317
- //#region src/WorldRuntime.ts
1348
+ //#region packages/world-runtime/src/WorldRuntime.ts
1318
1349
  /**
1319
1350
  * Owner of the world's runtime state: assets, script execution, ctx access.
1320
1351
  * The only object the generated code receives.
@@ -1576,10 +1607,10 @@ function isAbsoluteUrl(url) {
1576
1607
  return /^(?:[a-z]+:)?\/\//i.test(url) || url.startsWith("data:");
1577
1608
  }
1578
1609
  //#endregion
1579
- //#region src/version.gen.ts
1580
- var RUNTIME_VERSION = "0.6.2";
1610
+ //#region packages/world-runtime/src/version.gen.ts
1611
+ var RUNTIME_VERSION = "0.6.8";
1581
1612
  //#endregion
1582
- //#region src/version.ts
1613
+ //#region packages/world-runtime/src/version.ts
1583
1614
  /**
1584
1615
  * Format version of the generated world. The codegen stamps it into the artifact,
1585
1616
  * the runtime checks it on load. A breaking format change = package major bump.
@@ -1593,7 +1624,7 @@ function assertFormatVersion(version) {
1593
1624
  throw new Error(`@kvyverse/world-runtime: world format v${version} is not supported by runtime (expected v1). Re-export the world or pin a matching runtime version.`);
1594
1625
  }
1595
1626
  //#endregion
1596
- //#region src/bootstrap.ts
1627
+ //#region packages/world-runtime/src/bootstrap.ts
1597
1628
  /**
1598
1629
  * World assembly order. The only place where it is fixed: the artifact supplies
1599
1630
  * the data and steps, the runtime owns the sequence. Mirrors the game's
@@ -1662,7 +1693,7 @@ async function createWorld(definition, runtime) {
1662
1693
  return world;
1663
1694
  }
1664
1695
  //#endregion
1665
- //#region src/define-world.ts
1696
+ //#region packages/world-runtime/src/define-world.ts
1666
1697
  /**
1667
1698
  * Entry point of the generated artifact: world definition → public `loadWorld`.
1668
1699
  * The codegen prints `export const { loadWorld } = defineWorld({ ... })`.
@@ -1671,7 +1702,7 @@ function defineWorld(definition) {
1671
1702
  return { loadWorld: (options = {}) => bootstrapWorld(definition, options) };
1672
1703
  }
1673
1704
  //#endregion
1674
- //#region src/values.ts
1705
+ //#region packages/world-runtime/src/values.ts
1675
1706
  /**
1676
1707
  * Writes a color into an object field, creating a `Color` if the slot is empty.
1677
1708
  * Mirrors the `$C` branch of `applyValues` — needed by generated code for fields
@@ -1688,7 +1719,7 @@ function setColor(target, key, hex) {
1688
1719
  holder[key] = new THREE.Color(hex);
1689
1720
  }
1690
1721
  //#endregion
1691
- //#region src/resources/default-resources.ts
1722
+ //#region packages/world-runtime/src/resources/default-resources.ts
1692
1723
  /**
1693
1724
  * Built-in engine resources with fixed uuids: world values reference them via
1694
1725
  * a regular ref (`{$A:"6"}`), so the identifiers must never change.
@@ -1759,7 +1790,7 @@ function isDefaultResourceId(uuid) {
1759
1790
  return DEFAULT_RESOURCE_IDS.includes(uuid);
1760
1791
  }
1761
1792
  //#endregion
1762
- //#region src/resources/texture.ts
1793
+ //#region packages/world-runtime/src/resources/texture.ts
1763
1794
  /**
1764
1795
  * World texture defaults: clamp wrapping switches to repeat, color space
1765
1796
  * is sRGB. Identical in the editor, the game and the exported world.
@@ -1777,7 +1808,7 @@ async function loadTexture(url, name) {
1777
1808
  return texture;
1778
1809
  }
1779
1810
  //#endregion
1780
- //#region src/resources/model.ts
1811
+ //#region packages/world-runtime/src/resources/model.ts
1781
1812
  /** Parses model bytes into a hierarchy. `data`: ArrayBuffer, for obj — text. */
1782
1813
  async function parseModel(data, format, name) {
1783
1814
  let root;
@@ -1846,7 +1877,7 @@ function collectModelSubResources(root) {
1846
1877
  };
1847
1878
  }
1848
1879
  //#endregion
1849
- //#region src/resources/hdr.ts
1880
+ //#region packages/world-runtime/src/resources/hdr.ts
1850
1881
  /** Parses hdr/exr into a `DataTexture` with environment defaults (equirect, no mipmaps). */
1851
1882
  async function parseHdr(data, format, name) {
1852
1883
  let texture;
@@ -1874,7 +1905,7 @@ async function loadHdr(url, format, name) {
1874
1905
  return parseHdr(await response.arrayBuffer(), format, name);
1875
1906
  }
1876
1907
  //#endregion
1877
- //#region src/resources/geometry.ts
1908
+ //#region packages/world-runtime/src/resources/geometry.ts
1878
1909
  /** Geometry from our json format (`BufferGeometry.toJSON`). */
1879
1910
  function parseGeometryJson(json, name) {
1880
1911
  const geometry = AssetLoaders.bufferGeometry.get().parse(json);
@@ -1888,7 +1919,7 @@ async function loadGeometry(url, name) {
1888
1919
  return parseGeometryJson(await response.json(), name);
1889
1920
  }
1890
1921
  //#endregion
1891
- //#region src/resources/audio.ts
1922
+ //#region packages/world-runtime/src/resources/audio.ts
1892
1923
  /**
1893
1924
  * Audio asset source: a `Howl` with identity — this is what scripts get
1894
1925
  * from `require("/Sounds/...")`.
@@ -1921,7 +1952,7 @@ function createAudio(url, format, name) {
1921
1952
  });
1922
1953
  }
1923
1954
  //#endregion
1924
- //#region src/resources/video.ts
1955
+ //#region packages/world-runtime/src/resources/video.ts
1925
1956
  /**
1926
1957
  * Video asset source: a `<video>` with identity — this is what scripts get
1927
1958
  * from `require("/Videos/...")` (and `THREE.VideoTexture` from `element`).
@@ -1978,7 +2009,7 @@ async function createVideo(url, name) {
1978
2009
  return source;
1979
2010
  }
1980
2011
  //#endregion
1981
- //#region src/rendering/tsl-node.ts
2012
+ //#region packages/world-runtime/src/rendering/tsl-node.ts
1982
2013
  /**
1983
2014
  * World TSL node: the built graph node + its uniform nodes. This is what
1984
2015
  * `require("/Shaders/....tsl")` returns, so the method set matches the editor's
@@ -2021,7 +2052,7 @@ function createTslNode(uniforms, build, name) {
2021
2052
  return new TslNode(uniforms, build, name);
2022
2053
  }
2023
2054
  //#endregion
2024
- //#region src/rendering/tsl-uniforms.ts
2055
+ //#region packages/world-runtime/src/rendering/tsl-uniforms.ts
2025
2056
  var UNIFORM_TYPES = [
2026
2057
  "float",
2027
2058
  "int",
@@ -2082,10 +2113,10 @@ var UNIFORM_DEFAULTS = {
2082
2113
  texture: () => getDefaultResource(DefaultResourceId.Texture)
2083
2114
  };
2084
2115
  //#endregion
2085
- //#region src/addons/externals.ts
2116
+ //#region packages/world-runtime/src/addons/externals.ts
2086
2117
  var EXTERNAL_TYPES = ["umd", "module"];
2087
2118
  //#endregion
2088
- //#region src/rendering/renderer-options.ts
2119
+ //#region packages/world-runtime/src/rendering/renderer-options.ts
2089
2120
  /**
2090
2121
  * String names for renderer options set as words in the config and mapped to
2091
2122
  * THREE constants at runtime (game). Single source for the JSON schema
@@ -2108,4 +2139,4 @@ var TONE_MAPPING_NAMES = [
2108
2139
  "Neutral"
2109
2140
  ];
2110
2141
  //#endregion
2111
- export { AddonsRuntime, AssetLoaders, AudioSource, BLOOM_MODES, BUILTIN_BEHAVIOURS, BUILTIN_BEHAVIOUR_LIST, BUILTIN_LIB_DESCRIPTORS, CHAT_INPUT_MODES, DEFAULT_RESOURCE_IDS, DefaultResourceId, EXTERNAL_TYPES, EnvModule, FontSource, HtmlHudModule, InputSystemModule, LIBS, LIB_DESCRIPTORS, LIB_IDS, LOADING_MANAGER, LibId, OPTIONAL_LIB_DESCRIPTORS, OPTIONAL_LIB_IDS, OPTIONAL_MODULES, OPTIONAL_MODULE_IDS, OptionalModuleId, PHYSICS_ENGINES, RUNTIME_VERSION, SHADOW_MAP_TYPES, SceneBloom, SoundsModule, TONE_MAPPING_NAMES, TslNode, UNIFORM_DEFAULTS, UNIFORM_TYPES, UtilsModule, VideoSource, WORLD_FORMAT_VERSION, World, WorldEvent, WorldStores, applyRendererConfig, applyTextureDefaults, collectModelSubResources, collectRequiredLibs, configureAssetLoaders, createAudio, createFont, createTslNode, createUniformNode, createVideo, createWorldModules, defineWorld, enableSceneEmissiveMrt, fontFormatFromMime, getBuiltinBehaviour, getDefaultResource, getHalfheightRadiusScale, getOptionalModuleDescriptor, getRadiusScale, isDefaultResourceId, isMobileDevice, isUniformType, lazyProxy, libByRequireKey, loadGeometry, loadHdr, loadModel, loadTexture, normalizeChat, normalizePhysics, parseGeometryJson, parseHdr, parseModel, rapierPhysicsPatch, setColor, uniformType };
2142
+ export { AddonsRuntime, AssetLoaders, AudioSource, BLOOM_MODES, BUILTIN_BEHAVIOURS, BUILTIN_BEHAVIOUR_LIST, BUILTIN_LIB_DESCRIPTORS, CHAT_INPUT_MODES, DEFAULT_RESOURCE_IDS, DefaultResourceId, EXTERNAL_TYPES, EnvModule, FontSource, HtmlHudModule, InputSystemModule, LIBS, LIB_DESCRIPTORS, LIB_IDS, LOADING_MANAGER, LibId, NullPlatformModule, OPTIONAL_LIB_DESCRIPTORS, OPTIONAL_LIB_IDS, OPTIONAL_MODULES, OPTIONAL_MODULE_IDS, OptionalModuleId, PHYSICS_ENGINES, RUNTIME_VERSION, SHADOW_MAP_TYPES, SceneBloom, SoundsModule, TONE_MAPPING_NAMES, TslNode, UNIFORM_DEFAULTS, UNIFORM_TYPES, UtilsModule, VideoSource, WORLD_FORMAT_VERSION, World, WorldEvent, WorldStores, applyRendererConfig, applyTextureDefaults, collectModelSubResources, collectRequiredLibs, configureAssetLoaders, createAudio, createFont, createTslNode, createUniformNode, createVideo, createWorldModules, defineWorld, enableSceneEmissiveMrt, fontFormatFromMime, getBuiltinBehaviour, getDefaultResource, getHalfheightRadiusScale, getOptionalModuleDescriptor, getRadiusScale, isDefaultResourceId, isMobileDevice, isUniformType, lazyProxy, libByRequireKey, loadGeometry, loadHdr, loadModel, loadTexture, normalizeChat, normalizePhysics, parseGeometryJson, parseHdr, parseModel, rapierPhysicsPatch, setColor, uniformType };
@@ -1,4 +1,4 @@
1
- //#region src/addons/lib-registry.ts
1
+ //#region packages/world-runtime/src/addons/lib-registry.ts
2
2
  /**
3
3
  * Registry of the libraries scripts can `require`. One entry describes one
4
4
  * library; the flags say how it gets into the world:
@@ -32,6 +32,7 @@ var LibId = /* @__PURE__ */ function(LibId) {
32
32
  LibId["Rapier"] = "rapier";
33
33
  LibId["Css2d"] = "css2d";
34
34
  LibId["Css3d"] = "css3d";
35
+ LibId["OrbitControls"] = "orbitControls";
35
36
  return LibId;
36
37
  }({});
37
38
  var LIBS = {
@@ -126,6 +127,12 @@ var LIBS = {
126
127
  requireKey: "three/addons/renderers/CSS3DRenderer.js",
127
128
  packageName: "three",
128
129
  label: "CSS3DRenderer (DOM elements in 3d)"
130
+ },
131
+ ["orbitControls"]: {
132
+ id: "orbitControls",
133
+ requireKey: "three/addons/controls/OrbitControls.js",
134
+ packageName: "three",
135
+ label: "OrbitControls (camera orbiting a target)"
129
136
  }
130
137
  };
131
138
  var LIB_IDS = Object.values(LibId);
@@ -28,19 +28,18 @@ export interface ChatDomOptions {
28
28
  /**
29
29
  * Chat DOM: the message feed plus the input field.
30
30
  *
31
- * Built to survive real devices: submit through a `<form>` (Enter/Go/Send on any
32
- * mobile keyboard), an IME composition guard, and lifting above the on-screen
33
- * keyboard via `visualViewport`. Details —
34
- * `./README.md`.
31
+ * Built to survive real devices: sending on the Enter keydown (no `<form>`: a
32
+ * sandboxed host may block form submission), an IME composition guard, and
33
+ * lifting above the on-screen keyboard via `visualViewport`. Details — `./README.md`.
35
34
  */
36
35
  export declare class ChatDom {
37
36
  readonly root: HTMLDivElement;
38
37
  readonly feed: HTMLDivElement;
39
- readonly form: HTMLFormElement;
40
38
  readonly input: HTMLInputElement;
41
39
  private readonly _options;
42
40
  private _lines;
43
- private _isComposing;
41
+ /** Timer of a send waiting for the keyboard to commit its composition. */
42
+ private _pendingSubmit;
44
43
  private _viewportRaf;
45
44
  private _mounted;
46
45
  constructor(options?: ChatDomOptions);
@@ -77,12 +76,19 @@ export declare class ChatDom {
77
76
  private _setFaded;
78
77
  private _bind;
79
78
  private _unbind;
80
- private readonly _onSubmit;
81
- private readonly _onCompositionStart;
79
+ private _submit;
80
+ /**
81
+ * Sends now or, while the keyboard still holds the typed word as a composition
82
+ * (Android), once it commits the word: clearing the field under a live
83
+ * composition can bring the word back into it.
84
+ */
85
+ private _requestSubmit;
86
+ private _cancelPendingSubmit;
87
+ private readonly _flushSubmit;
82
88
  private readonly _onCompositionEnd;
83
- /** Some Android keyboards send no Enter keydown, only `insertLineBreak`. */
84
- private readonly _onBeforeInput;
85
89
  private readonly _onKeyDown;
90
+ /** Fallback for keyboards that insert a line break instead of sending Enter. */
91
+ private readonly _onBeforeInput;
86
92
  private readonly _stopPropagation;
87
93
  private readonly _onFocus;
88
94
  private readonly _onBlur;