@needle-tools/engine 5.1.0 → 5.1.2

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 (80) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/{needle-engine.bundle-5oIL49YP.js → needle-engine.bundle-BAUfRyBA.js} +7692 -7506
  3. package/dist/{needle-engine.bundle-DvOrfXws.umd.cjs → needle-engine.bundle-BL2wG5Te.umd.cjs} +159 -159
  4. package/dist/{needle-engine.bundle-DAAfj8Cs.min.js → needle-engine.bundle-BpNRkY3s.min.js} +184 -184
  5. package/dist/needle-engine.d.ts +25 -7
  6. package/dist/needle-engine.js +533 -533
  7. package/dist/needle-engine.min.js +1 -1
  8. package/dist/needle-engine.umd.cjs +1 -1
  9. package/lib/engine/api.d.ts +1 -1
  10. package/lib/engine/api.js +1 -1
  11. package/lib/engine/api.js.map +1 -1
  12. package/lib/engine/engine_init.js +2 -2
  13. package/lib/engine/engine_init.js.map +1 -1
  14. package/lib/engine/engine_license.d.ts +45 -7
  15. package/lib/engine/engine_license.js +276 -77
  16. package/lib/engine/engine_license.js.map +1 -1
  17. package/lib/engine/engine_networking.js +6 -0
  18. package/lib/engine/engine_networking.js.map +1 -1
  19. package/lib/engine/engine_networking_blob.js +3 -3
  20. package/lib/engine/engine_networking_blob.js.map +1 -1
  21. package/lib/engine/engine_networking_peer.js +19 -13
  22. package/lib/engine/engine_networking_peer.js.map +1 -1
  23. package/lib/engine/engine_utils_qrcode.js +2 -2
  24. package/lib/engine/engine_utils_qrcode.js.map +1 -1
  25. package/lib/engine/webcomponents/WebXRButtons.js +5 -6
  26. package/lib/engine/webcomponents/WebXRButtons.js.map +1 -1
  27. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
  28. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
  29. package/lib/engine/webcomponents/needle menu/needle-menu.js +5 -5
  30. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  31. package/lib/engine/webcomponents/needle-engine.js +31 -2
  32. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  33. package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
  34. package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
  35. package/lib/engine/xr/NeedleXRSession.d.ts +7 -1
  36. package/lib/engine/xr/NeedleXRSession.js +70 -11
  37. package/lib/engine/xr/NeedleXRSession.js.map +1 -1
  38. package/lib/engine/xr/NeedleXRSync.js +23 -4
  39. package/lib/engine/xr/NeedleXRSync.js.map +1 -1
  40. package/lib/engine/xr/TempXRContext.js +2 -2
  41. package/lib/engine/xr/TempXRContext.js.map +1 -1
  42. package/lib/engine-components/SyncedTransform.d.ts +5 -1
  43. package/lib/engine-components/SyncedTransform.js +45 -8
  44. package/lib/engine-components/SyncedTransform.js.map +1 -1
  45. package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
  46. package/lib/engine-components/webxr/Avatar.d.ts +8 -0
  47. package/lib/engine-components/webxr/Avatar.js +60 -32
  48. package/lib/engine-components/webxr/Avatar.js.map +1 -1
  49. package/lib/engine-components/webxr/WebXR.js +25 -14
  50. package/lib/engine-components/webxr/WebXR.js.map +1 -1
  51. package/lib/engine-schemes/synced-transform-model.d.ts +2 -0
  52. package/lib/engine-schemes/synced-transform-model.js +8 -1
  53. package/lib/engine-schemes/synced-transform-model.js.map +1 -1
  54. package/package.json +2 -2
  55. package/plugins/common/license.js +4 -4
  56. package/plugins/types/userconfig.d.ts +4 -3
  57. package/plugins/vite/build-pipeline.d.ts +3 -1
  58. package/plugins/vite/build-pipeline.js +19 -9
  59. package/plugins/vite/license.js +4 -4
  60. package/src/engine/api.ts +1 -1
  61. package/src/engine/engine_init.ts +2 -2
  62. package/src/engine/engine_license.ts +263 -73
  63. package/src/engine/engine_networking.ts +5 -0
  64. package/src/engine/engine_networking_blob.ts +3 -3
  65. package/src/engine/engine_networking_peer.ts +12 -13
  66. package/src/engine/engine_utils_qrcode.ts +2 -2
  67. package/src/engine/webcomponents/WebXRButtons.ts +5 -6
  68. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
  69. package/src/engine/webcomponents/needle menu/needle-menu.ts +5 -5
  70. package/src/engine/webcomponents/needle-engine.loading.ts +6 -6
  71. package/src/engine/webcomponents/needle-engine.ts +31 -2
  72. package/src/engine/xr/NeedleXRSession.ts +72 -14
  73. package/src/engine/xr/NeedleXRSync.ts +24 -4
  74. package/src/engine/xr/TempXRContext.ts +2 -2
  75. package/src/engine-components/SyncedTransform.ts +49 -10
  76. package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
  77. package/src/engine-components/webxr/Avatar.ts +60 -33
  78. package/src/engine-components/webxr/WebXR.ts +23 -15
  79. package/src/engine-schemes/synced-transform-model.ts +10 -1
  80. package/src/engine-schemes/transforms.fbs +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.",
5
5
  "main": "dist/needle-engine.min.js",
6
6
  "exports": {
@@ -99,7 +99,7 @@
99
99
  ],
100
100
  "dependencies": {
101
101
  "@dimforge/rapier3d-compat": "0.19.3",
102
- "@needle-tools/gltf-progressive": "3.6.0-beta.1",
102
+ "@needle-tools/gltf-progressive": "3.6.0-beta.2",
103
103
  "@needle-tools/materialx": "1.7.0-next.0d06218",
104
104
  "@needle-tools/three-animation-pointer": "1.1.2",
105
105
  "@webxr-input-profiles/motion-controllers": "1.0.0",
@@ -111,7 +111,7 @@ async function requestNeedleCloud(path, options) {
111
111
  * @param {DefaultOptions & {accessToken?:string, team:string|undefined}} opts
112
112
  */
113
113
  export async function replaceLicense(code, opts) {
114
- const index = code?.indexOf("_LquBhwVh");
114
+ const index = code?.indexOf("__UoF");
115
115
  if (index >= 0) {
116
116
  const licenseResult = await resolveLicense(opts);
117
117
  if (!licenseResult) {
@@ -120,18 +120,18 @@ export async function replaceLicense(code, opts) {
120
120
  const end = code.indexOf(";", index);
121
121
  if (end >= 0) {
122
122
  const line = code.substring(index, end);
123
- const replaced = "_LquBhwVh = \"" + licenseResult.type + "\"";
123
+ const replaced = "__UoF = \"" + licenseResult.type + "\"";
124
124
  code = code.replace(line, replaced);
125
125
  }
126
126
 
127
127
  // Also inject JWT if available
128
128
  if (licenseResult.jwt) {
129
- const jwtIndex = code.indexOf("BEvs");
129
+ const jwtIndex = code.indexOf("_nMW");
130
130
  if (jwtIndex >= 0) {
131
131
  const jwtEnd = code.indexOf(";", jwtIndex);
132
132
  if (jwtEnd >= 0) {
133
133
  const jwtLine = code.substring(jwtIndex, jwtEnd);
134
- const jwtReplaced = "BEvs = \"" + licenseResult.jwt + "\"";
134
+ const jwtReplaced = "_nMW = \"" + licenseResult.jwt + "\"";
135
135
  code = code.replace(jwtLine, jwtReplaced);
136
136
  }
137
137
  }
@@ -76,9 +76,10 @@ export type userSettings = {
76
76
  /** Enable for verbose log output */
77
77
  verbose?: boolean,
78
78
 
79
- /** Set to a specific version of the Needle Build Pipeline.
80
- * @default "latest"
81
- * @example "2.2.0-alpha"
79
+ /** Set to a specific version of the Needle Build Pipeline used for local compression.
80
+ * Must be 3.x or newer (earlier versions don't support the required license auth).
81
+ * @default "3"
82
+ * @example "3.0.0"
82
83
  */
83
84
  version?: string;
84
85
 
@@ -11,11 +11,13 @@
11
11
  * (cloud was the implied intent and can't run without a token).
12
12
  *
13
13
  * @param {import('../types').userSettings | undefined | null} opts
14
- * @param {{ isCI?: boolean }} [env]
14
+ * @param {{ isCI?: boolean, cloudToken?: string }} [env] `cloudToken` is the NEEDLE_CLOUD_TOKEN
15
+ * env var fallback, used when `buildPipeline.accessToken` isn't set in the vite config.
15
16
  * @returns {"cloud" | "local" | "skip-no-token"}
16
17
  */
17
18
  export function resolveCompressionTarget(opts: import("../types").userSettings | undefined | null, env?: {
18
19
  isCI?: boolean;
20
+ cloudToken?: string;
19
21
  }): "cloud" | "local" | "skip-no-token";
20
22
  /**
21
23
  * This function can be used by other plugins to wait for the build pipeline to finish before doing some work in the closeBundle hook.
@@ -53,12 +53,19 @@ env:
53
53
  * (cloud was the implied intent and can't run without a token).
54
54
  *
55
55
  * @param {import('../types').userSettings | undefined | null} opts
56
- * @param {{ isCI?: boolean }} [env]
56
+ * @param {{ isCI?: boolean, cloudToken?: string }} [env] `cloudToken` is the NEEDLE_CLOUD_TOKEN
57
+ * env var fallback, used when `buildPipeline.accessToken` isn't set in the vite config.
57
58
  * @returns {"cloud" | "local" | "skip-no-token"}
58
59
  */
59
60
  export function resolveCompressionTarget(opts, env = {}) {
60
61
  const isCI = env.isCI ?? false;
61
- const token = opts?.buildPipeline?.accessToken;
62
+ // A Needle Cloud access token can be configured two ways: buildPipeline.accessToken in the
63
+ // vite config, or the NEEDLE_CLOUD_TOKEN env var (the same var the license plugin reads —
64
+ // see common/license.js). buildPipeline.accessToken is not populated from the env var
65
+ // anywhere, so without this fallback an env-only token is invisible to the decision below:
66
+ // outside CI the build then selects local compression (no warning explaining why), and in
67
+ // CI it returns "skip-no-token".
68
+ const token = opts?.buildPipeline?.accessToken || env.cloudToken;
62
69
  const hasToken = typeof token === "string" && token.length > 0;
63
70
  const wantsLocal = opts?.buildPipeline?.compression === "local";
64
71
 
@@ -394,10 +401,11 @@ async function invokeBuildPipeline(opts, options = {}) {
394
401
 
395
402
  // Cloud token used by `${NEEDLE_CLOUD_CLI_NAME} optimize --token <token>`.
396
403
  // This is a Needle Cloud access token (created in the Needle Cloud UI), NOT a JWT.
397
- const cloudAccessToken = opts.buildPipeline?.accessToken;
404
+ // Falls back to NEEDLE_CLOUD_TOKEN (same source the license plugin uses) when not set in the config.
405
+ const cloudAccessToken = opts.buildPipeline?.accessToken || process.env.NEEDLE_CLOUD_TOKEN;
398
406
 
399
407
  // Decide cloud vs local (see resolveCompressionTarget for the rules).
400
- const compressionTarget = resolveCompressionTarget(opts, { isCI: !!process.env.CI });
408
+ const compressionTarget = resolveCompressionTarget(opts, { isCI: !!process.env.CI, cloudToken: process.env.NEEDLE_CLOUD_TOKEN });
401
409
  if (compressionTarget === "skip-no-token") {
402
410
  warn(`No cloud access token found. Set process.env.NEEDLE_CLOUD_TOKEN, or set buildPipeline.compression: "local" to compress on the build machine.`);
403
411
  return false;
@@ -475,8 +483,9 @@ async function invokeBuildPipeline(opts, options = {}) {
475
483
  }
476
484
  }
477
485
  }
478
- // Otherwise we default to the stable version on npm
479
- if (!version) version = "stable";
486
+ // Otherwise default to the latest 3.x release on npm. 3.x is required for the
487
+ // `--auth-token` JWT auth used below; the older `stable` dist-tag predates that option.
488
+ if (!version) version = "3";
480
489
 
481
490
  resolvedPipelineVersion = version;
482
491
  const versionInfo = versionSource ? `'${version}' (${versionSource})` : `'${version}'`;
@@ -652,9 +661,10 @@ async function invokeBuildPipeline(opts, options = {}) {
652
661
  const pinned = resolvedPipelineVersion ? `@${resolvedPipelineVersion}` : "";
653
662
  needleLog("needle-buildpipeline",
654
663
  `The compression tool reported an unknown option, which means an older/incompatible ` +
655
- `@needle-tools/gltf-build-pipeline ran instead of the pinned version ${pinned}. ` +
656
- `This is usually a stale local install shadowing it check "npm ls @needle-tools/gltf-build-pipeline" ` +
657
- `in your web project and remove the old copy, or ensure the pinned version is reachable from your npm registry.`,
664
+ `@needle-tools/gltf-build-pipeline${pinned ? ` (${pinned})` : ""} ran. Likely causes: the pinned ` +
665
+ `version/tag itself predates this option (it must be 3.x or newer set buildPipeline.version, ` +
666
+ `e.g. "3.0.0"), or a stale local install is shadowing it (check "npm ls @needle-tools/gltf-build-pipeline" ` +
667
+ `in your web project and remove the old copy, or ensure the pinned version is reachable from your npm registry).`,
658
668
  "warn", { dimBody: false, showHeader: true, leadingNewline: true });
659
669
  }
660
670
  }
@@ -49,12 +49,12 @@ export function needleLicense(command, config, userSettings) {
49
49
  let modified = false;
50
50
 
51
51
  // Replace license type
52
- const index = src.indexOf("_LquBhwVh");
52
+ const index = src.indexOf("__UoF");
53
53
  if (index >= 0) {
54
54
  const end = src.indexOf(";", index);
55
55
  if (end >= 0) {
56
56
  const line = src.substring(index, end);
57
- const replaced = "_LquBhwVh = \"" + licenseResult.type + "\"";
57
+ const replaced = "__UoF = \"" + licenseResult.type + "\"";
58
58
  src = src.replace(line, replaced);
59
59
  modified = true;
60
60
  }
@@ -62,12 +62,12 @@ export function needleLicense(command, config, userSettings) {
62
62
 
63
63
  // Replace license JWT (same pattern)
64
64
  if (licenseResult.jwt) {
65
- const jwtIndex = src.indexOf("BEvs");
65
+ const jwtIndex = src.indexOf("_nMW");
66
66
  if (jwtIndex >= 0) {
67
67
  const jwtEnd = src.indexOf(";", jwtIndex);
68
68
  if (jwtEnd >= 0) {
69
69
  const jwtLine = src.substring(jwtIndex, jwtEnd);
70
- const jwtReplaced = "BEvs = \"" + licenseResult.jwt + "\"";
70
+ const jwtReplaced = "_nMW = \"" + licenseResult.jwt + "\"";
71
71
  src = src.replace(jwtLine, jwtReplaced);
72
72
  modified = true;
73
73
  }
package/src/engine/api.ts CHANGED
@@ -230,7 +230,7 @@ export * from "./engine_input.js";
230
230
  export { InstancingUtil } from "./engine_instancing.js";
231
231
 
232
232
  /** License checking utilities */
233
- export { $iujBhf, $RHhhju, rXELCf } from "./engine_license.js";
233
+ export { Jkdun, _$apSvAt, _hyjgv } from "./engine_license.js";
234
234
 
235
235
 
236
236
  // ============================================================================
@@ -8,7 +8,7 @@ import { initBuiltinTypes } from "./codegen/register_types.js";
8
8
  import { initSpatialConsole } from "./debug/debug_spatial_console.js";
9
9
  import { initAddressableSerializers } from "./engine_addressables.js";
10
10
  import { ensureAudioContextIsResumed } from "./engine_audio.js";
11
- import { __tBFssqnm } from "./engine_license.js";
11
+ import { __NjkWq } from "./engine_license.js";
12
12
  import { initNeedleLoader } from "./engine_loaders.js";
13
13
  import { initPhysics } from "./engine_physics_rapier.js";
14
14
  import { initBuiltinSerializers } from "./engine_serialization_builtin_serializer.js";
@@ -59,7 +59,7 @@ export function initEngine() {
59
59
  initPhysics();
60
60
  initXR();
61
61
  initSpatialConsole();
62
- __tBFssqnm();
62
+ __NjkWq();
63
63
 
64
64
  // Must be last. customElements.define() upgrades existing <needle-engine>
65
65
  // elements synchronously, which can trigger context.create() and dispatch