@needle-tools/engine 5.1.0-canary.fbdfce3 → 5.1.0-experimental.03e8105
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.
- package/CHANGELOG.md +86 -0
- package/SKILL.md +4 -1
- package/components.needle.json +1 -1
- package/dist/{needle-engine.bundle-BFSj2Fz8.js → needle-engine.bundle-BNqUjnSQ.js} +19180 -18386
- package/dist/needle-engine.bundle-Bt8ULD7E.umd.cjs +1733 -0
- package/dist/needle-engine.bundle-DF6ovbwD.min.js +1733 -0
- package/dist/needle-engine.d.ts +1487 -356
- package/dist/needle-engine.js +544 -542
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/three.js +1 -0
- package/dist/three.min.js +21 -21
- package/dist/three.umd.cjs +16 -16
- package/lib/engine/api.d.ts +8 -1
- package/lib/engine/api.js +7 -1
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/codegen/register_types.js +10 -18
- package/lib/engine/codegen/register_types.js.map +1 -1
- package/lib/engine/engine_audio.d.ts +68 -0
- package/lib/engine/engine_audio.js +172 -0
- package/lib/engine/engine_audio.js.map +1 -1
- package/lib/engine/engine_camera.fit.js +16 -4
- package/lib/engine/engine_camera.fit.js.map +1 -1
- package/lib/engine/engine_components.js +1 -1
- package/lib/engine/engine_components.js.map +1 -1
- package/lib/engine/engine_context.d.ts +21 -8
- package/lib/engine/engine_context.js +32 -16
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_context_eventbus.d.ts +47 -0
- package/lib/engine/engine_context_eventbus.js +47 -0
- package/lib/engine/engine_context_eventbus.js.map +1 -0
- package/lib/engine/engine_disposable.d.ts +172 -0
- package/lib/engine/engine_disposable.js +136 -0
- package/lib/engine/engine_disposable.js.map +1 -0
- package/lib/engine/engine_gameobject.d.ts +1 -10
- package/lib/engine/engine_gameobject.js +22 -120
- package/lib/engine/engine_gameobject.js.map +1 -1
- package/lib/engine/engine_gltf_builtin_components.js +7 -69
- package/lib/engine/engine_gltf_builtin_components.js.map +1 -1
- package/lib/engine/engine_init.js +7 -7
- package/lib/engine/engine_init.js.map +1 -1
- package/lib/engine/engine_input.d.ts +24 -5
- package/lib/engine/engine_input.js +3 -2
- package/lib/engine/engine_input.js.map +1 -1
- package/lib/engine/engine_instantiate_resolve.d.ts +42 -0
- package/lib/engine/engine_instantiate_resolve.js +372 -0
- package/lib/engine/engine_instantiate_resolve.js.map +1 -0
- package/lib/engine/engine_license.d.ts +7 -7
- package/lib/engine/engine_license.js +183 -57
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_mainloop_utils.js +7 -4
- package/lib/engine/engine_mainloop_utils.js.map +1 -1
- package/lib/engine/engine_networking.d.ts +51 -37
- package/lib/engine/engine_networking.js +132 -82
- package/lib/engine/engine_networking.js.map +1 -1
- package/lib/engine/engine_networking.transport.websocket.d.ts +15 -0
- package/lib/engine/engine_networking.transport.websocket.js +38 -0
- package/lib/engine/engine_networking.transport.websocket.js.map +1 -0
- package/lib/engine/engine_networking_blob.js +4 -4
- package/lib/engine/engine_networking_blob.js.map +1 -1
- package/lib/engine/engine_networking_instantiate.js +2 -2
- package/lib/engine/engine_networking_instantiate.js.map +1 -1
- package/lib/engine/engine_networking_types.d.ts +39 -1
- package/lib/engine/engine_networking_types.js +7 -0
- package/lib/engine/engine_networking_types.js.map +1 -1
- package/lib/engine/engine_physics_rapier.d.ts +21 -3
- package/lib/engine/engine_physics_rapier.js +94 -25
- package/lib/engine/engine_physics_rapier.js.map +1 -1
- package/lib/engine/engine_scenedata.js +2 -2
- package/lib/engine/engine_scenedata.js.map +1 -1
- package/lib/engine/engine_serialization_builtin_serializer.js +28 -5
- package/lib/engine/engine_serialization_builtin_serializer.js.map +1 -1
- package/lib/engine/engine_serialization_core.d.ts +1 -0
- package/lib/engine/engine_serialization_core.js +7 -0
- package/lib/engine/engine_serialization_core.js.map +1 -1
- package/lib/engine/engine_types.d.ts +29 -11
- package/lib/engine/engine_types.js +1 -1
- package/lib/engine/engine_types.js.map +1 -1
- package/lib/engine/engine_util_decorator.js +7 -2
- package/lib/engine/engine_util_decorator.js.map +1 -1
- package/lib/engine/engine_utils.d.ts +1 -1
- package/lib/engine/engine_utils.js +19 -5
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/engine_utils_qrcode.js +2 -2
- package/lib/engine/engine_utils_qrcode.js.map +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
- package/lib/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.js +6 -6
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +10 -4
- package/lib/engine/webcomponents/needle-engine.js +3 -3
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.loading.js +2 -2
- package/lib/engine/webcomponents/needle-engine.loading.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.d.ts +3 -2
- package/lib/engine/xr/NeedleXRSession.js +50 -14
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine/xr/TempXRContext.js +2 -2
- package/lib/engine/xr/TempXRContext.js.map +1 -1
- package/lib/engine/xr/events.d.ts +1 -1
- package/lib/engine/xr/events.js.map +1 -1
- package/lib/engine-components/Animation.js +17 -16
- package/lib/engine-components/Animation.js.map +1 -1
- package/lib/engine-components/AnimationBuilder.d.ts +158 -0
- package/lib/engine-components/AnimationBuilder.js +305 -0
- package/lib/engine-components/AnimationBuilder.js.map +1 -0
- package/lib/engine-components/Animator.d.ts +6 -0
- package/lib/engine-components/Animator.js +23 -13
- package/lib/engine-components/Animator.js.map +1 -1
- package/lib/engine-components/AnimatorController.builder.d.ts +191 -0
- package/lib/engine-components/AnimatorController.builder.js +263 -0
- package/lib/engine-components/AnimatorController.builder.js.map +1 -0
- package/lib/engine-components/AnimatorController.d.ts +2 -119
- package/lib/engine-components/AnimatorController.js +33 -232
- package/lib/engine-components/AnimatorController.js.map +1 -1
- package/lib/engine-components/AudioSource.d.ts +19 -3
- package/lib/engine-components/AudioSource.js +121 -68
- package/lib/engine-components/AudioSource.js.map +1 -1
- package/lib/engine-components/Collider.d.ts +18 -9
- package/lib/engine-components/Collider.js +61 -14
- package/lib/engine-components/Collider.js.map +1 -1
- package/lib/engine-components/Component.d.ts +72 -9
- package/lib/engine-components/Component.js +114 -10
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/ContactShadows.d.ts +1 -0
- package/lib/engine-components/ContactShadows.js +14 -1
- package/lib/engine-components/ContactShadows.js.map +1 -1
- package/lib/engine-components/DragControls.d.ts +7 -0
- package/lib/engine-components/DragControls.js +19 -7
- package/lib/engine-components/DragControls.js.map +1 -1
- package/lib/engine-components/DropListener.js +3 -0
- package/lib/engine-components/DropListener.js.map +1 -1
- package/lib/engine-components/EventList.d.ts +31 -9
- package/lib/engine-components/EventList.js +37 -76
- package/lib/engine-components/EventList.js.map +1 -1
- package/lib/engine-components/Joints.d.ts +4 -2
- package/lib/engine-components/Joints.js +19 -3
- package/lib/engine-components/Joints.js.map +1 -1
- package/lib/engine-components/Light.js +9 -1
- package/lib/engine-components/Light.js.map +1 -1
- package/lib/engine-components/Networking.d.ts +1 -1
- package/lib/engine-components/Networking.js +1 -1
- package/lib/engine-components/OrbitControls.d.ts +0 -2
- package/lib/engine-components/OrbitControls.js +30 -12
- package/lib/engine-components/OrbitControls.js.map +1 -1
- package/lib/engine-components/RigidBody.d.ts +12 -4
- package/lib/engine-components/RigidBody.js +18 -4
- package/lib/engine-components/RigidBody.js.map +1 -1
- package/lib/engine-components/SceneSwitcher.js +3 -0
- package/lib/engine-components/SceneSwitcher.js.map +1 -1
- package/lib/engine-components/SeeThrough.js +2 -2
- package/lib/engine-components/SeeThrough.js.map +1 -1
- package/lib/engine-components/api.d.ts +2 -1
- package/lib/engine-components/api.js +2 -1
- package/lib/engine-components/api.js.map +1 -1
- package/lib/engine-components/codegen/components.d.ts +7 -13
- package/lib/engine-components/codegen/components.js +7 -13
- package/lib/engine-components/codegen/components.js.map +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js +4 -4
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
- package/lib/engine-components/timeline/PlayableDirector.d.ts +21 -11
- package/lib/engine-components/timeline/PlayableDirector.js +75 -67
- package/lib/engine-components/timeline/PlayableDirector.js.map +1 -1
- package/lib/engine-components/timeline/SignalAsset.d.ts +3 -1
- package/lib/engine-components/timeline/SignalAsset.js +1 -0
- package/lib/engine-components/timeline/SignalAsset.js.map +1 -1
- package/lib/engine-components/timeline/TimelineBuilder.d.ts +413 -0
- package/lib/engine-components/timeline/TimelineBuilder.js +506 -0
- package/lib/engine-components/timeline/TimelineBuilder.js.map +1 -0
- package/lib/engine-components/timeline/TimelineModels.d.ts +2 -1
- package/lib/engine-components/timeline/TimelineModels.js +3 -0
- package/lib/engine-components/timeline/TimelineModels.js.map +1 -1
- package/lib/engine-components/timeline/TimelineTracks.d.ts +37 -6
- package/lib/engine-components/timeline/TimelineTracks.js +92 -26
- package/lib/engine-components/timeline/TimelineTracks.js.map +1 -1
- package/lib/engine-components/timeline/index.d.ts +2 -1
- package/lib/engine-components/timeline/index.js +2 -0
- package/lib/engine-components/timeline/index.js.map +1 -1
- package/lib/engine-components/ui/Canvas.d.ts +1 -1
- package/lib/engine-components/ui/Canvas.js +2 -8
- package/lib/engine-components/ui/Canvas.js.map +1 -1
- package/lib/engine-components/ui/Text.d.ts +1 -0
- package/lib/engine-components/ui/Text.js +10 -7
- package/lib/engine-components/ui/Text.js.map +1 -1
- package/lib/engine-components/web/CursorFollow.d.ts +0 -1
- package/lib/engine-components/web/CursorFollow.js +21 -13
- package/lib/engine-components/web/CursorFollow.js.map +1 -1
- package/lib/engine-components/webxr/WebXRImageTracking.js +4 -0
- package/lib/engine-components/webxr/WebXRImageTracking.js.map +1 -1
- package/package.json +2 -83
- package/plugins/common/cloud.js +6 -1
- package/plugins/common/license.js +31 -10
- package/plugins/common/worker.js +9 -4
- package/plugins/vite/asap.js +17 -8
- package/plugins/vite/dependencies.js +29 -10
- package/plugins/vite/dependency-watcher.js +2 -2
- package/plugins/vite/editor-connection.js +3 -3
- package/plugins/vite/license.js +46 -7
- package/plugins/vite/local-files-core.js +3 -3
- package/plugins/vite/local-files-utils.d.ts +3 -1
- package/plugins/vite/local-files-utils.js +29 -5
- package/plugins/vite/reload.js +1 -1
- package/plugins/vite/server.js +2 -1
- package/src/engine/api.ts +11 -1
- package/src/engine/codegen/register_types.ts +10 -18
- package/src/engine/engine_audio.ts +184 -0
- package/src/engine/engine_camera.fit.ts +15 -4
- package/src/engine/engine_components.ts +1 -1
- package/src/engine/engine_context.ts +34 -18
- package/src/engine/engine_context_eventbus.ts +73 -0
- package/src/engine/engine_disposable.ts +214 -0
- package/src/engine/engine_gameobject.ts +54 -159
- package/src/engine/engine_gltf_builtin_components.ts +7 -76
- package/src/engine/engine_init.ts +7 -7
- package/src/engine/engine_input.ts +28 -7
- package/src/engine/engine_instantiate_resolve.ts +407 -0
- package/src/engine/engine_license.ts +197 -55
- package/src/engine/engine_mainloop_utils.ts +7 -4
- package/src/engine/engine_networking.transport.websocket.ts +45 -0
- package/src/engine/engine_networking.ts +161 -137
- package/src/engine/engine_networking_blob.ts +4 -4
- package/src/engine/engine_networking_instantiate.ts +2 -2
- package/src/engine/engine_networking_types.ts +41 -1
- package/src/engine/engine_physics_rapier.ts +102 -33
- package/src/engine/engine_scenedata.ts +3 -3
- package/src/engine/engine_serialization_builtin_serializer.ts +32 -9
- package/src/engine/engine_serialization_core.ts +9 -0
- package/src/engine/engine_types.ts +46 -27
- package/src/engine/engine_util_decorator.ts +7 -2
- package/src/engine/engine_utils.ts +16 -5
- package/src/engine/engine_utils_qrcode.ts +2 -2
- package/src/engine/physics/workers/mesh-bvh/GenerateMeshBVHWorker.js +1 -1
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -2
- package/src/engine/webcomponents/needle menu/needle-menu.ts +6 -6
- package/src/engine/webcomponents/needle-engine.loading.ts +6 -6
- package/src/engine/webcomponents/needle-engine.ts +12 -6
- package/src/engine/xr/NeedleXRSession.ts +48 -13
- package/src/engine/xr/TempXRContext.ts +2 -2
- package/src/engine/xr/events.ts +1 -1
- package/src/engine-components/Animation.ts +19 -16
- package/src/engine-components/AnimationBuilder.ts +472 -0
- package/src/engine-components/Animator.ts +24 -12
- package/src/engine-components/AnimatorController.builder.ts +387 -0
- package/src/engine-components/AnimatorController.ts +20 -291
- package/src/engine-components/AudioSource.ts +130 -79
- package/src/engine-components/Collider.ts +66 -18
- package/src/engine-components/Component.ts +118 -20
- package/src/engine-components/ContactShadows.ts +15 -1
- package/src/engine-components/DragControls.ts +18 -11
- package/src/engine-components/DropListener.ts +3 -0
- package/src/engine-components/EventList.ts +45 -83
- package/src/engine-components/Joints.ts +20 -4
- package/src/engine-components/Light.ts +10 -2
- package/src/engine-components/Networking.ts +1 -1
- package/src/engine-components/OrbitControls.ts +34 -14
- package/src/engine-components/RigidBody.ts +18 -4
- package/src/engine-components/SceneSwitcher.ts +3 -0
- package/src/engine-components/SeeThrough.ts +2 -2
- package/src/engine-components/api.ts +2 -1
- package/src/engine-components/codegen/components.ts +7 -13
- package/src/engine-components/export/usdz/USDZExporter.ts +4 -4
- package/src/engine-components/timeline/PlayableDirector.ts +83 -81
- package/src/engine-components/timeline/SignalAsset.ts +4 -1
- package/src/engine-components/timeline/TimelineBuilder.ts +824 -0
- package/src/engine-components/timeline/TimelineModels.ts +5 -1
- package/src/engine-components/timeline/TimelineTracks.ts +96 -27
- package/src/engine-components/timeline/index.ts +2 -1
- package/src/engine-components/ui/Canvas.ts +2 -8
- package/src/engine-components/ui/Text.ts +12 -8
- package/src/engine-components/web/CursorFollow.ts +21 -14
- package/src/engine-components/webxr/WebXRImageTracking.ts +2 -0
- package/dist/needle-engine.bundle-CmxIO5uH.min.js +0 -1732
- package/dist/needle-engine.bundle-tJIZukCz.umd.cjs +0 -1732
- package/lib/engine-components/AvatarLoader.d.ts +0 -80
- package/lib/engine-components/AvatarLoader.js +0 -232
- package/lib/engine-components/AvatarLoader.js.map +0 -1
- package/lib/engine-components/avatar/AvatarBlink_Simple.d.ts +0 -11
- package/lib/engine-components/avatar/AvatarBlink_Simple.js +0 -77
- package/lib/engine-components/avatar/AvatarBlink_Simple.js.map +0 -1
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.d.ts +0 -14
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js +0 -69
- package/lib/engine-components/avatar/AvatarEyeLook_Rotation.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.d.ts +0 -29
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js +0 -122
- package/lib/engine-components/avatar/Avatar_Brain_LookAt.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_MouthShapes.d.ts +0 -15
- package/lib/engine-components/avatar/Avatar_MouthShapes.js +0 -80
- package/lib/engine-components/avatar/Avatar_MouthShapes.js.map +0 -1
- package/lib/engine-components/avatar/Avatar_MustacheShake.d.ts +0 -9
- package/lib/engine-components/avatar/Avatar_MustacheShake.js +0 -30
- package/lib/engine-components/avatar/Avatar_MustacheShake.js.map +0 -1
- package/plugins/dts-generator/dts.codegen.js +0 -334
- package/plugins/dts-generator/dts.scan.js +0 -99
- package/plugins/dts-generator/dts.writer.js +0 -59
- package/plugins/dts-generator/glb.discovery.js +0 -279
- package/plugins/dts-generator/glb.extractor.js +0 -215
- package/plugins/dts-generator/glb.reader.js +0 -167
- package/plugins/dts-generator/index.js +0 -36
- package/plugins/dts-generator/manifest.types.js +0 -174
- package/plugins/gltf-packer.mjs +0 -1
- package/src/engine-components/AvatarLoader.ts +0 -264
- package/src/engine-components/avatar/AvatarBlink_Simple.ts +0 -70
- package/src/engine-components/avatar/AvatarEyeLook_Rotation.ts +0 -64
- package/src/engine-components/avatar/Avatar_Brain_LookAt.ts +0 -140
- package/src/engine-components/avatar/Avatar_MouthShapes.ts +0 -84
- package/src/engine-components/avatar/Avatar_MustacheShake.ts +0 -32
- package/src/vite-env.d.ts +0 -16
|
@@ -3,23 +3,37 @@ import { ContextEvent, ContextRegistry } from "./engine_context_registry.js";
|
|
|
3
3
|
import { onInitialized } from "./engine_lifecycle_api.js";
|
|
4
4
|
import { isLocalNetwork } from "./engine_networking_utils.js";
|
|
5
5
|
import { Context } from "./engine_setup.js";
|
|
6
|
+
import { SSR } from "./engine_ssr.js";
|
|
6
7
|
import type { IContext } from "./engine_types.js";
|
|
7
8
|
import { getParam } from "./engine_utils.js";
|
|
8
|
-
import { SSR } from "./engine_ssr.js";
|
|
9
9
|
|
|
10
|
-
const debug = getParam("
|
|
10
|
+
const debug = getParam("__debuglic__");
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const dXgxU: ((result: boolean) => void)[] = [];
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// These are modified by a bundler (e.g. vite)
|
|
15
15
|
// Do not edit manually
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
let _PQYikbj: string = "basic";
|
|
17
|
+
// eslint-disable-next-line prefer-const -- value is replaced by the bundler at build time
|
|
18
|
+
let _$QHon: string = "";
|
|
19
|
+
if (debug) {
|
|
20
|
+
console.log("License Type: " + _PQYikbj);
|
|
21
|
+
if (_$QHon) {
|
|
22
|
+
console.log("License JWT: " + _$QHon);
|
|
23
|
+
try {
|
|
24
|
+
const payload = JSON.parse(atob(_$QHon.split(".")[1].replace(/-/g, '+').replace(/_/g, '/')));
|
|
25
|
+
console.log("License JWT payload:", payload);
|
|
26
|
+
}
|
|
27
|
+
catch { console.log("License JWT payload: (failed to decode)"); }
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.log("License JWT: (none)");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
19
33
|
|
|
20
34
|
/** @internal */
|
|
21
|
-
export function
|
|
22
|
-
switch (
|
|
35
|
+
export function UFadk() {
|
|
36
|
+
switch (_PQYikbj) {
|
|
23
37
|
case "pro":
|
|
24
38
|
case "enterprise":
|
|
25
39
|
return true;
|
|
@@ -28,8 +42,8 @@ export function hasProLicense() {
|
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
/** @internal */
|
|
31
|
-
export function
|
|
32
|
-
switch (
|
|
45
|
+
export function __tFkl() {
|
|
46
|
+
switch (_PQYikbj) {
|
|
33
47
|
case "indie":
|
|
34
48
|
return true;
|
|
35
49
|
}
|
|
@@ -37,8 +51,8 @@ export function hasIndieLicense() {
|
|
|
37
51
|
}
|
|
38
52
|
|
|
39
53
|
/** @internal */
|
|
40
|
-
export function
|
|
41
|
-
switch (
|
|
54
|
+
export function rxRjHuj() {
|
|
55
|
+
switch (_PQYikbj) {
|
|
42
56
|
case "edu":
|
|
43
57
|
return true;
|
|
44
58
|
}
|
|
@@ -46,20 +60,20 @@ export function hasEduLicense() {
|
|
|
46
60
|
}
|
|
47
61
|
|
|
48
62
|
/** @internal */
|
|
49
|
-
export function
|
|
50
|
-
return
|
|
63
|
+
export function _BGpnKD() {
|
|
64
|
+
return UFadk() || __tFkl() || rxRjHuj();
|
|
51
65
|
}
|
|
52
66
|
|
|
53
67
|
|
|
54
68
|
/** @internal */
|
|
55
|
-
export function
|
|
56
|
-
if (
|
|
69
|
+
export function __pLOnb(cb: (result: boolean) => void) {
|
|
70
|
+
if (UFadk() || __tFkl() || rxRjHuj())
|
|
57
71
|
return cb(true);
|
|
58
|
-
|
|
72
|
+
dXgxU.push(cb);
|
|
59
73
|
}
|
|
60
74
|
|
|
61
|
-
function
|
|
62
|
-
for (const cb of
|
|
75
|
+
function _csklVr(result: boolean) {
|
|
76
|
+
for (const cb of dXgxU) {
|
|
63
77
|
try {
|
|
64
78
|
cb(result);
|
|
65
79
|
}
|
|
@@ -70,6 +84,127 @@ function invokeLicenseCheckResultChanged(result: boolean) {
|
|
|
70
84
|
}
|
|
71
85
|
|
|
72
86
|
|
|
87
|
+
// #region JWT License Verification
|
|
88
|
+
|
|
89
|
+
// ECDSA P-256 public key for verifying license JWTs (verification-only, safe to ship)
|
|
90
|
+
/* eslint-disable no-secrets/no-secrets -- public key, not a secret */
|
|
91
|
+
const _$OYBbo = {
|
|
92
|
+
kty: "EC",
|
|
93
|
+
crv: "P-256",
|
|
94
|
+
x: "A34nyKMjhQYVgzeE4tyLUYdx34TAKogDa7v7PRaO9Lg",
|
|
95
|
+
y: "JZI9IQavGCpGjEG_-pa0J-MHQYWJYINUM-MnvSu0TmE",
|
|
96
|
+
} as const;
|
|
97
|
+
/* eslint-enable no-secrets/no-secrets */
|
|
98
|
+
|
|
99
|
+
/** Base64url decode (RFC 7515) */
|
|
100
|
+
function base64urlDecode(str: string): Uint8Array {
|
|
101
|
+
const base64 = str.replace(/-/g, '+').replace(/_/g, '/');
|
|
102
|
+
const padded = base64 + '='.repeat((4 - base64.length % 4) % 4);
|
|
103
|
+
const binary = atob(padded);
|
|
104
|
+
const bytes = new Uint8Array(binary.length);
|
|
105
|
+
for (let i = 0; i < binary.length; i++) {
|
|
106
|
+
bytes[i] = binary.charCodeAt(i);
|
|
107
|
+
}
|
|
108
|
+
return bytes;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Verify a JWT license token and return the `type` claim if valid.
|
|
113
|
+
* Returns null if the JWT is missing, malformed, or has an invalid signature.
|
|
114
|
+
*/
|
|
115
|
+
async function GTeeZaHi(jwt: string): Promise<string | null> {
|
|
116
|
+
if (!jwt) return null;
|
|
117
|
+
try {
|
|
118
|
+
const parts = jwt.split(".");
|
|
119
|
+
if (parts.length !== 3) return null;
|
|
120
|
+
|
|
121
|
+
const [headerB64, payloadB64, signatureB64] = parts;
|
|
122
|
+
|
|
123
|
+
const key = await crypto.subtle.importKey(
|
|
124
|
+
"jwk",
|
|
125
|
+
_$OYBbo,
|
|
126
|
+
{ name: "ECDSA", namedCurve: "P-256" },
|
|
127
|
+
false,
|
|
128
|
+
["verify"]
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const signingInput = new TextEncoder().encode(`${headerB64}.${payloadB64}`);
|
|
132
|
+
const signature = base64urlDecode(signatureB64);
|
|
133
|
+
|
|
134
|
+
const valid = await crypto.subtle.verify(
|
|
135
|
+
{ name: "ECDSA", hash: "SHA-256" },
|
|
136
|
+
key,
|
|
137
|
+
signature.buffer as ArrayBuffer,
|
|
138
|
+
signingInput
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
if (!valid) {
|
|
142
|
+
if (debug) console.warn("JWT: signature verification failed");
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const payloadStr = new TextDecoder().decode(base64urlDecode(payloadB64));
|
|
147
|
+
const payload = JSON.parse(payloadStr);
|
|
148
|
+
|
|
149
|
+
if (typeof payload.type !== "string" || payload.type.length === 0) {
|
|
150
|
+
if (debug) console.warn("JWT: missing or invalid 'type' claim");
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Optional: check expiration if present (future-proof — server doesn't set this yet)
|
|
155
|
+
if (typeof payload.exp === "number") {
|
|
156
|
+
const nowSeconds = Math.floor(Date.now() / 1000);
|
|
157
|
+
if (nowSeconds > payload.exp) {
|
|
158
|
+
if (debug) console.warn("JWT: token has expired (exp=" + payload.exp + ", now=" + nowSeconds + ")");
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Optional: check audience/domain if present (future-proof — server doesn't set this yet)
|
|
164
|
+
if (payload.aud) {
|
|
165
|
+
const currentHost = typeof window !== "undefined" ? window.location.hostname : undefined;
|
|
166
|
+
if (currentHost) {
|
|
167
|
+
const allowed = Array.isArray(payload.aud) ? payload.aud : [payload.aud];
|
|
168
|
+
if (!allowed.some((a: string) => currentHost === a || currentHost.endsWith("." + a))) {
|
|
169
|
+
if (debug) console.warn("JWT: domain '" + currentHost + "' not in allowed audience: " + allowed.join(", "));
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (debug) console.log("JWT: verified license type: " + payload.type);
|
|
176
|
+
return payload.type;
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
if (debug) console.error("JWT: verification error", err);
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Verify the injected JWT and update the license type if valid.
|
|
185
|
+
* The engine ONLY trusts the JWT — the plain _PQYikbj string is ignored. */
|
|
186
|
+
let _jwtVerificationPromise: Promise<void> | undefined = undefined;
|
|
187
|
+
async function $sATIKYrT(): Promise<void> {
|
|
188
|
+
if (!_$QHon) {
|
|
189
|
+
// No JWT present: license stays "basic" regardless of what _PQYikbj says
|
|
190
|
+
_PQYikbj = "basic";
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const verifiedType = await GTeeZaHi(_$QHon);
|
|
194
|
+
if (verifiedType) {
|
|
195
|
+
_PQYikbj = verifiedType;
|
|
196
|
+
if (debug) console.log("License type set from verified JWT: " + verifiedType);
|
|
197
|
+
_csklVr(_BGpnKD());
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
// JWT present but invalid: reset to basic
|
|
201
|
+
_PQYikbj = "basic";
|
|
202
|
+
if (debug) console.warn("JWT verification failed — license reset to basic");
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// #endregion JWT License Verification
|
|
207
|
+
|
|
73
208
|
|
|
74
209
|
// #region Telemetry
|
|
75
210
|
export namespace Telemetry {
|
|
@@ -135,7 +270,7 @@ export namespace Telemetry {
|
|
|
135
270
|
|
|
136
271
|
const attribute = domElement?.getAttribute("no-telemetry");
|
|
137
272
|
if (attribute === "" || attribute === "true" || attribute === "1") {
|
|
138
|
-
if (
|
|
273
|
+
if (_PQYikbj === "pro" || _PQYikbj === "enterprise") {
|
|
139
274
|
if (debug) console.debug("Telemetry is disabled via no-telemetry attribute");
|
|
140
275
|
return false;
|
|
141
276
|
}
|
|
@@ -242,22 +377,29 @@ export namespace Telemetry {
|
|
|
242
377
|
}
|
|
243
378
|
|
|
244
379
|
|
|
245
|
-
export function
|
|
380
|
+
export function rFPJwMWf() {
|
|
381
|
+
// Start JWT verification — must be here (not top-level) to avoid tree-shaking
|
|
382
|
+
_jwtVerificationPromise = $sATIKYrT();
|
|
383
|
+
|
|
246
384
|
Telemetry.init();
|
|
247
385
|
ContextRegistry.registerCallback(ContextEvent.ContextRegistered, evt => {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
setTimeout(() =>
|
|
386
|
+
__loEAQjNJ(evt.context);
|
|
387
|
+
__msk(evt.context);
|
|
388
|
+
setTimeout(() => $tlH(evt.context), 2000);
|
|
251
389
|
});
|
|
252
390
|
}
|
|
253
391
|
|
|
254
|
-
export let
|
|
392
|
+
export let _$YsQVksF: Promise<void> | undefined = undefined;
|
|
255
393
|
let applicationIsForbidden = false;
|
|
256
394
|
let applicationForbiddenText = "";
|
|
257
|
-
async function
|
|
395
|
+
async function _fYB() {
|
|
258
396
|
// Only perform the runtime license check once
|
|
259
|
-
if (
|
|
260
|
-
|
|
397
|
+
if (_$YsQVksF) return _$YsQVksF;
|
|
398
|
+
// Wait for JWT verification to complete first (if running)
|
|
399
|
+
if (_jwtVerificationPromise) {
|
|
400
|
+
await _jwtVerificationPromise;
|
|
401
|
+
}
|
|
402
|
+
if (_PQYikbj === "basic") {
|
|
261
403
|
try {
|
|
262
404
|
const licenseUrl = "https://needle.tools/api/v1/needle-engine/check?location=" + encodeURIComponent(window.location.href) + "&version=" + VERSION + "&generator=" + encodeURIComponent(GENERATOR);
|
|
263
405
|
const res = await fetch(licenseUrl, {
|
|
@@ -269,29 +411,29 @@ async function checkLicense() {
|
|
|
269
411
|
if (res?.status === 200) {
|
|
270
412
|
applicationIsForbidden = false;
|
|
271
413
|
if (debug) console.log("License check succeeded");
|
|
272
|
-
|
|
273
|
-
|
|
414
|
+
_PQYikbj = "pro";
|
|
415
|
+
_csklVr(true);
|
|
274
416
|
}
|
|
275
417
|
else if (res?.status === 403) {
|
|
276
|
-
|
|
418
|
+
_csklVr(false);
|
|
277
419
|
applicationIsForbidden = true;
|
|
278
420
|
applicationForbiddenText = await res.text();
|
|
279
421
|
}
|
|
280
422
|
else {
|
|
281
|
-
|
|
423
|
+
_csklVr(false);
|
|
282
424
|
if (debug) console.log("License check failed with status " + res?.status);
|
|
283
425
|
}
|
|
284
426
|
}
|
|
285
427
|
catch (err) {
|
|
286
|
-
|
|
428
|
+
_csklVr(false);
|
|
287
429
|
if (debug) console.error("License check failed", err);
|
|
288
430
|
}
|
|
289
431
|
}
|
|
290
|
-
else if (debug) console.log("Runtime license check is skipped because license is already applied as \"" +
|
|
432
|
+
else if (debug) console.log("Runtime license check is skipped because license is already applied as \"" + _PQYikbj + "\"");
|
|
291
433
|
}
|
|
292
|
-
|
|
434
|
+
_$YsQVksF = _fYB();
|
|
293
435
|
|
|
294
|
-
async function
|
|
436
|
+
async function __msk(ctx: IContext) {
|
|
295
437
|
function createForbiddenElement() {
|
|
296
438
|
const div = document.createElement("div");
|
|
297
439
|
div.className = "needle-forbidden";
|
|
@@ -356,40 +498,40 @@ async function handleForbidden(ctx: IContext) {
|
|
|
356
498
|
}, 500)
|
|
357
499
|
}
|
|
358
500
|
|
|
359
|
-
async function
|
|
501
|
+
async function __loEAQjNJ(ctx: IContext) {
|
|
360
502
|
try {
|
|
361
|
-
if (!
|
|
362
|
-
return
|
|
503
|
+
if (!UFadk() && !__tFkl()) {
|
|
504
|
+
return __pJSUSLs(ctx);
|
|
363
505
|
}
|
|
364
506
|
}
|
|
365
507
|
catch (err) {
|
|
366
508
|
if (debug) console.log("License check failed", err)
|
|
367
|
-
return
|
|
509
|
+
return __pJSUSLs(ctx)
|
|
368
510
|
}
|
|
369
|
-
if (debug)
|
|
511
|
+
if (debug) __pJSUSLs(ctx)
|
|
370
512
|
}
|
|
371
513
|
|
|
372
514
|
|
|
373
515
|
|
|
374
|
-
async function
|
|
516
|
+
async function __pJSUSLs(ctx: IContext) {
|
|
375
517
|
|
|
376
518
|
// if the engine loads faster than the license check, we need to capture the ready event here
|
|
377
519
|
let isReady = false;
|
|
378
520
|
ctx.domElement.addEventListener("ready", () => isReady = true);
|
|
379
521
|
|
|
380
|
-
await
|
|
522
|
+
await _$YsQVksF?.catch(() => { });
|
|
381
523
|
|
|
382
524
|
|
|
383
|
-
if (
|
|
384
|
-
if (
|
|
525
|
+
if (UFadk() || __tFkl()) return;
|
|
526
|
+
if (_BGpnKD() === false) _ArTbiTUU();
|
|
385
527
|
|
|
386
528
|
// check if the engine is already ready (meaning has finished loading)
|
|
387
529
|
if (isReady) {
|
|
388
|
-
|
|
530
|
+
_$gRXdD(ctx);
|
|
389
531
|
}
|
|
390
532
|
else {
|
|
391
533
|
ctx.domElement.addEventListener("ready", () => {
|
|
392
|
-
|
|
534
|
+
_$gRXdD(ctx);
|
|
393
535
|
});
|
|
394
536
|
}
|
|
395
537
|
}
|
|
@@ -397,7 +539,7 @@ async function onNonCommercialVersionDetected(ctx: IContext) {
|
|
|
397
539
|
// const licenseElementIdentifier = "needle-license-element";
|
|
398
540
|
// const licenseDuration = 10000;
|
|
399
541
|
// const licenseDelay = 1200;
|
|
400
|
-
function
|
|
542
|
+
function _$gRXdD(ctx: IContext) {
|
|
401
543
|
|
|
402
544
|
const style = `
|
|
403
545
|
position: relative;
|
|
@@ -410,7 +552,7 @@ function insertNonCommercialUseHint(ctx: IContext) {
|
|
|
410
552
|
padding: 10px;
|
|
411
553
|
padding-left: 30px;
|
|
412
554
|
`;
|
|
413
|
-
if (
|
|
555
|
+
if (_PQYikbj === "edu") {
|
|
414
556
|
if (navigator.webdriver) {
|
|
415
557
|
console.log("This project is supported by Needle for Education – https://needle.tools");
|
|
416
558
|
}
|
|
@@ -467,7 +609,7 @@ function insertNonCommercialUseHint(ctx: IContext) {
|
|
|
467
609
|
}
|
|
468
610
|
}, 1000);
|
|
469
611
|
|
|
470
|
-
if (
|
|
612
|
+
if (rxRjHuj()) {
|
|
471
613
|
const removeDelay = 20_000;
|
|
472
614
|
setTimeout(() => {
|
|
473
615
|
clearInterval(interval);
|
|
@@ -476,7 +618,7 @@ function insertNonCommercialUseHint(ctx: IContext) {
|
|
|
476
618
|
const intervalInMinutes = 5;
|
|
477
619
|
setTimeout(() => {
|
|
478
620
|
if (ctx.domElement.parentNode)
|
|
479
|
-
|
|
621
|
+
_$gRXdD(ctx);
|
|
480
622
|
}, 1000 * 60 * intervalInMinutes)
|
|
481
623
|
}, removeDelay);
|
|
482
624
|
}
|
|
@@ -487,7 +629,7 @@ function insertNonCommercialUseHint(ctx: IContext) {
|
|
|
487
629
|
const base64Logo = "data:image/webp;base64,UklGRrABAABXRUJQVlA4WAoAAAAQAAAAHwAAHwAAQUxQSKEAAAARN6CmbSM4WR7vdARON11EBDq3fLiNbVtVzpMCPlKAEzsx0Y/x+Ovuv4dn0EFE/ydAvz6YggXzgh5sVgXM/zOC/4sii7qgGvB5N7hmuQYwkvazWAu1JPW41FXSHq6pnaQWvqYH18Fc0j1hO/BFTtIeSBlJi5w6qIIO7IOrwhFsB2Yxukif0FTRLpXswHR8MxbslKe9VZsn/Ub5C7YFOpqSTABWUDgg6AAAAFAGAJ0BKiAAIAA+7VyoTqmkpCI3+qgBMB2JbACdMt69DwMIQBLhkTO6XwY00UEDK6cNIDnuNibPf0EgAP7Y1myuiQHLDsF/0h5unrGh6WAbv7aegg2ZMd3uRKfT/3SJztcaujYfTvMXspfCTmYcoO6a+vhC3ss4M8uM58t4siiu59I4aOl59e9Sr6xoxYlHf2v+NnBNpJYeJf8jABQAId/PXuBkLEFkiCucgSGEcfhvajql/j3reCGl0M5/9gQWy7ayNPs+wlvIxFnNfSlfuND4CZOCyxOHhRqOmHN4ULHo3tCSrUNvgAA=";
|
|
488
630
|
|
|
489
631
|
let lastLogTime = 0;
|
|
490
|
-
async function
|
|
632
|
+
async function _ArTbiTUU(_logo?: string) {
|
|
491
633
|
const now = Date.now();
|
|
492
634
|
if (now - lastLogTime < 2000) return;
|
|
493
635
|
lastLogTime = now;
|
|
@@ -520,7 +662,7 @@ async function logNonCommercialUse(_logo?: string) {
|
|
|
520
662
|
}
|
|
521
663
|
|
|
522
664
|
|
|
523
|
-
async function
|
|
665
|
+
async function $tlH(context: IContext) {
|
|
524
666
|
// We can't send beacons from cross-origin isolated pages
|
|
525
667
|
if (window.crossOriginIsolated) return;
|
|
526
668
|
|
|
@@ -535,7 +677,7 @@ async function sendUsageMessageToAnalyticsBackend(context: IContext) {
|
|
|
535
677
|
|
|
536
678
|
// current url without query parameters
|
|
537
679
|
const currentUrl = window.location.href.split("?")[0];
|
|
538
|
-
const license =
|
|
680
|
+
const license = _PQYikbj;
|
|
539
681
|
|
|
540
682
|
const beaconData = {
|
|
541
683
|
license,
|
|
@@ -344,8 +344,11 @@ function updateIsActiveInHierarchyRecursiveRuntime(go: Object3D, activeInHierarc
|
|
|
344
344
|
if (allowEventCall) {
|
|
345
345
|
const components = go.userData?.components;
|
|
346
346
|
if (components) {
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
// We need to iterate on components in the original order right now to work-around UI related initialization bugs where RectTransform must be initialized before e.g. Graphic components. https://linear.app/needle/issue/NE-6986
|
|
348
|
+
// In the future we can reverse iterate this once the UI system has been replaced (that being said it's probably expected that component enable in the order in which they're added to an object)
|
|
349
|
+
const componentsCopy = [...components];
|
|
350
|
+
for (let ci = 0; ci < componentsCopy.length; ci++) {
|
|
351
|
+
const comp = componentsCopy[ci];
|
|
349
352
|
if (activeInHierarchy) {
|
|
350
353
|
if (comp?.enabled) {
|
|
351
354
|
try { comp.__internalAwake(); }
|
|
@@ -357,8 +360,8 @@ function updateIsActiveInHierarchyRecursiveRuntime(go: Object3D, activeInHierarc
|
|
|
357
360
|
}
|
|
358
361
|
else if(comp) {
|
|
359
362
|
if (comp["__didAwake"] && comp.enabled) {
|
|
360
|
-
|
|
361
|
-
comp.
|
|
363
|
+
// autoCleanup uses __internalDisable; isRemovingFromScene=true preserves __isEnabled
|
|
364
|
+
comp.__internalDisable(true);
|
|
362
365
|
}
|
|
363
366
|
}
|
|
364
367
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { INetworkTransport } from './engine_networking_types.js';
|
|
2
|
+
|
|
3
|
+
/** Default transport that wraps the `websocket-ts` library */
|
|
4
|
+
export class WebsocketTransport implements INetworkTransport {
|
|
5
|
+
private _url: string;
|
|
6
|
+
private _ws: import('websocket-ts').Websocket | undefined;
|
|
7
|
+
|
|
8
|
+
onOpen: (() => void) | null = null;
|
|
9
|
+
onClose: (() => void) | null = null;
|
|
10
|
+
onError: ((err: any) => void) | null = null;
|
|
11
|
+
onMessage: ((data: string | Blob) => void) | null = null;
|
|
12
|
+
|
|
13
|
+
get url() { return this._ws?.url ?? this._url; }
|
|
14
|
+
|
|
15
|
+
constructor(url: string) {
|
|
16
|
+
this._url = url;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async start() {
|
|
20
|
+
const pkg = await import('websocket-ts');
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
const WebsocketBuilder = pkg.default?.WebsocketBuilder ?? pkg.WebsocketBuilder;
|
|
23
|
+
const ExponentialBackoff = pkg.default?.ExponentialBackoff ?? pkg.ExponentialBackoff;
|
|
24
|
+
const ws = new WebsocketBuilder(this._url)
|
|
25
|
+
.withMaxRetries(10)
|
|
26
|
+
.withBackoff(new ExponentialBackoff(2000, 4))
|
|
27
|
+
.onOpen(() => { this._ws = ws; this.onOpen?.(); })
|
|
28
|
+
.onClose(() => { this.onClose?.(); })
|
|
29
|
+
.onError(() => { this.onError?.(new Error("Websocket connection failed")); })
|
|
30
|
+
.onRetry(() => { console.log("Retry connecting to networking websocket"); })
|
|
31
|
+
.build();
|
|
32
|
+
ws.addEventListener(pkg.WebsocketEvent.message, (_, msg) => {
|
|
33
|
+
this.onMessage?.(msg.data);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
send(data: string | Uint8Array) {
|
|
38
|
+
this._ws?.send(data);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
close() {
|
|
42
|
+
this._ws?.close();
|
|
43
|
+
this._ws = undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|