@webspatial/core-sdk 1.7.0 → 2.0.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.
Files changed (296) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +10 -0
  3. package/dist/JSBCommand.d.ts +398 -0
  4. package/dist/JSBCommand.js +668 -0
  5. package/dist/JSBCommand.js.map +1 -0
  6. package/dist/Spatial.d.ts +63 -0
  7. package/dist/Spatial.js +60 -0
  8. package/dist/Spatial.js.map +1 -0
  9. package/dist/SpatialObject.d.ts +19 -0
  10. package/dist/SpatialObject.js +44 -0
  11. package/dist/SpatialObject.js.map +1 -0
  12. package/dist/SpatialScene.d.ts +51 -0
  13. package/dist/SpatialScene.js +74 -0
  14. package/dist/SpatialScene.js.map +1 -0
  15. package/dist/SpatialSession.d.ts +143 -0
  16. package/dist/SpatialSession.js +173 -0
  17. package/dist/SpatialSession.js.map +1 -0
  18. package/dist/SpatialWebEvent.d.ts +8 -0
  19. package/dist/SpatialWebEvent.js +18 -0
  20. package/dist/SpatialWebEvent.js.map +1 -0
  21. package/dist/SpatialWebEventCreator.d.ts +11 -0
  22. package/dist/SpatialWebEventCreator.js +11 -0
  23. package/dist/SpatialWebEventCreator.js.map +1 -0
  24. package/dist/Spatialized2DElement.d.ts +42 -0
  25. package/dist/Spatialized2DElement.js +47 -0
  26. package/dist/Spatialized2DElement.js.map +1 -0
  27. package/dist/SpatializedDynamic3DElement.d.ts +7 -0
  28. package/dist/SpatializedDynamic3DElement.js +43 -0
  29. package/dist/SpatializedDynamic3DElement.js.map +1 -0
  30. package/dist/SpatializedElement.d.ts +7 -0
  31. package/dist/SpatializedElement.js +206 -0
  32. package/dist/SpatializedElement.js.map +1 -0
  33. package/dist/SpatializedElementCreator.d.ts +15 -0
  34. package/dist/SpatializedElementCreator.js +47 -0
  35. package/dist/SpatializedElementCreator.js.map +1 -0
  36. package/dist/SpatializedStatic3DElement.d.ts +195 -0
  37. package/dist/SpatializedStatic3DElement.js +327 -0
  38. package/dist/SpatializedStatic3DElement.js.map +1 -0
  39. package/dist/WebMsgCommand.d.ts +7 -0
  40. package/dist/WebMsgCommand.js +23 -0
  41. package/dist/WebMsgCommand.js.map +1 -0
  42. package/dist/index.d.ts +35 -1251
  43. package/dist/index.js +21 -3650
  44. package/dist/index.js.map +1 -1
  45. package/dist/install-polyfills.d.ts +2 -0
  46. package/dist/install-polyfills.js +13 -0
  47. package/dist/install-polyfills.js.map +1 -0
  48. package/dist/isSSREnv.d.ts +3 -0
  49. package/dist/isSSREnv.js +6 -0
  50. package/dist/isSSREnv.js.map +1 -0
  51. package/dist/motion/AnimationObject.d.ts +7 -0
  52. package/dist/motion/AnimationObject.js +140 -0
  53. package/dist/motion/AnimationObject.js.map +1 -0
  54. package/dist/motion/compute/index.d.ts +10 -0
  55. package/dist/motion/compute/index.js +19 -0
  56. package/dist/motion/compute/index.js.map +1 -0
  57. package/dist/motion/compute/motionPropertyValues.d.ts +19 -0
  58. package/dist/motion/compute/motionPropertyValues.js +50 -0
  59. package/dist/motion/compute/motionPropertyValues.js.map +1 -0
  60. package/dist/motion/compute/normalize.d.ts +31 -0
  61. package/dist/motion/compute/normalize.js +201 -0
  62. package/dist/motion/compute/normalize.js.map +1 -0
  63. package/dist/motion/compute/validate.d.ts +22 -0
  64. package/dist/motion/compute/validate.js +103 -0
  65. package/dist/motion/compute/validate.js.map +1 -0
  66. package/dist/motion/index.d.ts +8 -0
  67. package/dist/motion/index.js +6 -0
  68. package/dist/motion/index.js.map +1 -0
  69. package/dist/motion/native/serializeMotionTimeline.d.ts +12 -0
  70. package/dist/motion/native/serializeMotionTimeline.js +21 -0
  71. package/dist/motion/native/serializeMotionTimeline.js.map +1 -0
  72. package/dist/physicalMetrics-W5uZ5xKb.d.ts +48 -0
  73. package/dist/physicalMetrics.d.ts +1 -0
  74. package/dist/physicalMetrics.js +58 -0
  75. package/dist/physicalMetrics.js.map +1 -0
  76. package/dist/platform-adapter/CommandResultUtils.d.ts +12 -0
  77. package/dist/platform-adapter/CommandResultUtils.js +21 -0
  78. package/dist/platform-adapter/CommandResultUtils.js.map +1 -0
  79. package/dist/platform-adapter/createPlatformSync.d.ts +16 -0
  80. package/dist/platform-adapter/createPlatformSync.js +30 -0
  81. package/dist/platform-adapter/createPlatformSync.js.map +1 -0
  82. package/dist/platform-adapter/index.d.ts +12 -0
  83. package/dist/platform-adapter/index.js +10 -0
  84. package/dist/platform-adapter/index.js.map +1 -0
  85. package/dist/platform-adapter/interface.d.ts +7 -0
  86. package/dist/platform-adapter/interface.js +1 -0
  87. package/dist/platform-adapter/interface.js.map +1 -0
  88. package/dist/platform-adapter/pico-os/PicoOSPlatform.d.ts +25 -0
  89. package/dist/platform-adapter/pico-os/PicoOSPlatform.js +168 -0
  90. package/dist/platform-adapter/pico-os/PicoOSPlatform.js.map +1 -0
  91. package/dist/platform-adapter/puppeteer/PuppeteerPlatform.d.ts +66 -0
  92. package/dist/platform-adapter/puppeteer/PuppeteerPlatform.js +372 -0
  93. package/dist/platform-adapter/puppeteer/PuppeteerPlatform.js.map +1 -0
  94. package/dist/platform-adapter/spatialRequestMetadata.d.ts +6 -0
  95. package/dist/platform-adapter/spatialRequestMetadata.js +39 -0
  96. package/dist/platform-adapter/spatialRequestMetadata.js.map +1 -0
  97. package/dist/platform-adapter/spatialSceneQuery.d.ts +12 -0
  98. package/dist/platform-adapter/spatialSceneQuery.js +12 -0
  99. package/dist/platform-adapter/spatialSceneQuery.js.map +1 -0
  100. package/dist/platform-adapter/vision-os/VisionOSPlatform.d.ts +19 -0
  101. package/dist/platform-adapter/vision-os/VisionOSPlatform.js +77 -0
  102. package/dist/platform-adapter/vision-os/VisionOSPlatform.js.map +1 -0
  103. package/dist/platform-runtime.d.ts +12 -0
  104. package/dist/platform-runtime.js +14 -0
  105. package/dist/platform-runtime.js.map +1 -0
  106. package/dist/reality/Attachment.d.ts +19 -0
  107. package/dist/reality/Attachment.js +39 -0
  108. package/dist/reality/Attachment.js.map +1 -0
  109. package/dist/reality/component/ModelComponent.d.ts +14 -0
  110. package/dist/reality/component/ModelComponent.js +11 -0
  111. package/dist/reality/component/ModelComponent.js.map +1 -0
  112. package/dist/reality/component/SpatialComponent.d.ts +8 -0
  113. package/dist/reality/component/SpatialComponent.js +19 -0
  114. package/dist/reality/component/SpatialComponent.js.map +1 -0
  115. package/dist/reality/component/index.d.ts +8 -0
  116. package/dist/reality/component/index.js +3 -0
  117. package/dist/reality/component/index.js.map +1 -0
  118. package/dist/reality/entity/SpatialEntity.d.ts +7 -0
  119. package/dist/reality/entity/SpatialEntity.js +291 -0
  120. package/dist/reality/entity/SpatialEntity.js.map +1 -0
  121. package/dist/reality/entity/SpatialModelEntity.d.ts +17 -0
  122. package/dist/reality/entity/SpatialModelEntity.js +17 -0
  123. package/dist/reality/entity/SpatialModelEntity.js.map +1 -0
  124. package/dist/reality/entity/index.d.ts +8 -0
  125. package/dist/reality/entity/index.js +3 -0
  126. package/dist/reality/entity/index.js.map +1 -0
  127. package/dist/reality/geometry/SpatialBoxGeometry.d.ts +16 -0
  128. package/dist/reality/geometry/SpatialBoxGeometry.js +13 -0
  129. package/dist/reality/geometry/SpatialBoxGeometry.js.map +1 -0
  130. package/dist/reality/geometry/SpatialConeGeometry.d.ts +16 -0
  131. package/dist/reality/geometry/SpatialConeGeometry.js +13 -0
  132. package/dist/reality/geometry/SpatialConeGeometry.js.map +1 -0
  133. package/dist/reality/geometry/SpatialCylinderGeometry.d.ts +16 -0
  134. package/dist/reality/geometry/SpatialCylinderGeometry.js +13 -0
  135. package/dist/reality/geometry/SpatialCylinderGeometry.js.map +1 -0
  136. package/dist/reality/geometry/SpatialGeometry.d.ts +7 -0
  137. package/dist/reality/geometry/SpatialGeometry.js +13 -0
  138. package/dist/reality/geometry/SpatialGeometry.js.map +1 -0
  139. package/dist/reality/geometry/SpatialPlaneGeometry.d.ts +16 -0
  140. package/dist/reality/geometry/SpatialPlaneGeometry.js +13 -0
  141. package/dist/reality/geometry/SpatialPlaneGeometry.js.map +1 -0
  142. package/dist/reality/geometry/SpatialSphereGeometry.d.ts +16 -0
  143. package/dist/reality/geometry/SpatialSphereGeometry.js +13 -0
  144. package/dist/reality/geometry/SpatialSphereGeometry.js.map +1 -0
  145. package/dist/reality/geometry/index.d.ts +12 -0
  146. package/dist/reality/geometry/index.js +7 -0
  147. package/dist/reality/geometry/index.js.map +1 -0
  148. package/dist/reality/index.d.ts +18 -0
  149. package/dist/reality/index.js +7 -0
  150. package/dist/reality/index.js.map +1 -0
  151. package/dist/reality/material/SpatialMaterial.d.ts +7 -0
  152. package/dist/reality/material/SpatialMaterial.js +13 -0
  153. package/dist/reality/material/SpatialMaterial.js.map +1 -0
  154. package/dist/reality/material/SpatialUnlitMaterial.d.ts +16 -0
  155. package/dist/reality/material/SpatialUnlitMaterial.js +16 -0
  156. package/dist/reality/material/SpatialUnlitMaterial.js.map +1 -0
  157. package/dist/reality/material/index.d.ts +8 -0
  158. package/dist/reality/material/index.js +3 -0
  159. package/dist/reality/material/index.js.map +1 -0
  160. package/dist/reality/realityCreator.d.ts +22 -0
  161. package/dist/reality/realityCreator.js +89 -0
  162. package/dist/reality/realityCreator.js.map +1 -0
  163. package/dist/reality/resource/SpatialModelAsset.d.ts +15 -0
  164. package/dist/reality/resource/SpatialModelAsset.js +12 -0
  165. package/dist/reality/resource/SpatialModelAsset.js.map +1 -0
  166. package/dist/reality/resource/SpatialTextureResource.d.ts +16 -0
  167. package/dist/reality/resource/SpatialTextureResource.js +16 -0
  168. package/dist/reality/resource/SpatialTextureResource.js.map +1 -0
  169. package/dist/reality/resource/index.d.ts +9 -0
  170. package/dist/reality/resource/index.js +3 -0
  171. package/dist/reality/resource/index.js.map +1 -0
  172. package/dist/runtime/WebSpatialRuntimeError.d.ts +10 -0
  173. package/dist/runtime/WebSpatialRuntimeError.js +14 -0
  174. package/dist/runtime/WebSpatialRuntimeError.js.map +1 -0
  175. package/dist/runtime/capability-data.d.ts +12 -0
  176. package/dist/runtime/capability-data.js +134 -0
  177. package/dist/runtime/capability-data.js.map +1 -0
  178. package/dist/runtime/index.d.ts +8 -0
  179. package/dist/runtime/index.js +27 -0
  180. package/dist/runtime/index.js.map +1 -0
  181. package/dist/runtime/jsbAdapterPlatform.d.ts +9 -0
  182. package/dist/runtime/jsbAdapterPlatform.js +38 -0
  183. package/dist/runtime/jsbAdapterPlatform.js.map +1 -0
  184. package/dist/runtime/keys.d.ts +34 -0
  185. package/dist/runtime/keys.js +122 -0
  186. package/dist/runtime/keys.js.map +1 -0
  187. package/dist/runtime/semver.d.ts +8 -0
  188. package/dist/runtime/semver.js +32 -0
  189. package/dist/runtime/semver.js.map +1 -0
  190. package/dist/runtime/supports.d.ts +22 -0
  191. package/dist/runtime/supports.js +78 -0
  192. package/dist/runtime/supports.js.map +1 -0
  193. package/dist/runtime/types.d.ts +12 -0
  194. package/dist/runtime/types.js +1 -0
  195. package/dist/runtime/types.js.map +1 -0
  196. package/dist/runtime/userAgent.d.ts +20 -0
  197. package/dist/runtime/userAgent.js +41 -0
  198. package/dist/runtime/userAgent.js.map +1 -0
  199. package/dist/scene-polyfill.d.ts +18 -0
  200. package/dist/scene-polyfill.js +480 -0
  201. package/dist/scene-polyfill.js.map +1 -0
  202. package/dist/spatial-host.d.ts +13 -0
  203. package/dist/spatial-host.js +18 -0
  204. package/dist/spatial-host.js.map +1 -0
  205. package/dist/spatial-window-polyfill.d.ts +3 -0
  206. package/dist/spatial-window-polyfill.js +155 -0
  207. package/dist/spatial-window-polyfill.js.map +1 -0
  208. package/dist/spatializedElementMotion-_0XWPQCE.d.ts +1009 -0
  209. package/dist/types/animation.d.ts +7 -0
  210. package/dist/types/animation.js +1 -0
  211. package/dist/types/animation.js.map +1 -0
  212. package/dist/types/global.d.ts +38 -0
  213. package/dist/types/global.js +1 -0
  214. package/dist/types/global.js.map +1 -0
  215. package/dist/types/internal.d.ts +7 -0
  216. package/dist/types/internal.js +12 -0
  217. package/dist/types/internal.js.map +1 -0
  218. package/dist/types/motion/index.d.ts +7 -0
  219. package/dist/types/motion/index.js +3 -0
  220. package/dist/types/motion/index.js.map +1 -0
  221. package/dist/types/motion/spatializedElementMotion.d.ts +7 -0
  222. package/dist/types/motion/spatializedElementMotion.js +1 -0
  223. package/dist/types/motion/spatializedElementMotion.js.map +1 -0
  224. package/dist/types/motion/spatializedMotion.d.ts +7 -0
  225. package/dist/types/motion/spatializedMotion.js +16 -0
  226. package/dist/types/motion/spatializedMotion.js.map +1 -0
  227. package/dist/types/motion/spatializedPlayback.d.ts +11 -0
  228. package/dist/types/motion/spatializedPlayback.js +1 -0
  229. package/dist/types/motion/spatializedPlayback.js.map +1 -0
  230. package/dist/types/motion/spatializedVisual.d.ts +35 -0
  231. package/dist/types/motion/spatializedVisual.js +1 -0
  232. package/dist/types/motion/spatializedVisual.js.map +1 -0
  233. package/dist/types/types.d.ts +7 -0
  234. package/dist/types/types.js +117 -0
  235. package/dist/types/types.js.map +1 -0
  236. package/dist/utils.d.ts +44 -0
  237. package/dist/utils.js +86 -0
  238. package/dist/utils.js.map +1 -0
  239. package/package.json +20 -4
  240. package/src/JSBCommand.ts +132 -5
  241. package/src/SpatialObject.ts +10 -0
  242. package/src/Spatialized2DElement.ts +5 -0
  243. package/src/SpatializedDynamic3DElement.ts +5 -0
  244. package/src/SpatializedElement.ts +29 -0
  245. package/src/SpatializedStatic3DElement.ts +42 -3
  246. package/src/WebMsgCommand.ts +40 -0
  247. package/src/coverage-boost.test.ts +239 -216
  248. package/src/index.ts +25 -11
  249. package/src/install-polyfills.ts +38 -0
  250. package/src/jsbcommand.coverage.test.ts +23 -0
  251. package/src/motion/AnimationObject.test.ts +421 -0
  252. package/src/motion/AnimationObject.ts +208 -0
  253. package/src/motion/compute/index.ts +10 -0
  254. package/src/motion/compute/motionPropertyValues.test.ts +55 -0
  255. package/src/motion/compute/motionPropertyValues.ts +70 -0
  256. package/src/motion/compute/normalize.test.ts +99 -0
  257. package/src/motion/compute/normalize.ts +289 -0
  258. package/src/motion/compute/validate.test.ts +229 -0
  259. package/src/motion/compute/validate.ts +156 -0
  260. package/src/motion/index.ts +2 -0
  261. package/src/motion/native/serializeMotionTimeline.test.ts +61 -0
  262. package/src/motion/native/serializeMotionTimeline.ts +27 -0
  263. package/src/platform-adapter/createPlatformSync.ts +5 -3
  264. package/src/platform-adapter/pico-os/PicoOSPlatform.ts +76 -11
  265. package/src/platform-adapter/spatialRequestMetadata.test.ts +175 -0
  266. package/src/platform-adapter/spatialRequestMetadata.ts +48 -0
  267. package/src/platform-adapter/vision-os/VisionOSPlatform.ts +6 -1
  268. package/src/reality/entity/SpatialEntity.ts +127 -0
  269. package/src/runtime/capability-data.ts +104 -4
  270. package/src/runtime/index.ts +0 -11
  271. package/src/runtime/keys.ts +12 -1
  272. package/src/runtime/supports.test.ts +143 -4
  273. package/src/runtime/supports.ts +3 -1
  274. package/src/runtime/useAnimation.capability.test.ts +275 -0
  275. package/src/scene-polyfill.manifest.test.ts +306 -5
  276. package/src/scene-polyfill.request-metadata.test.ts +39 -0
  277. package/src/scene-polyfill.test.ts +33 -94
  278. package/src/scene-polyfill.ts +117 -87
  279. package/src/spatial-window-polyfill.ts +18 -2
  280. package/src/transform-roundtrip.test.ts +90 -0
  281. package/src/types/animation.ts +224 -0
  282. package/src/types/global.ts +1 -8
  283. package/src/types/motion/index.ts +10 -0
  284. package/src/types/motion/spatializedElementMotion.ts +49 -0
  285. package/src/types/motion/spatializedMotion.ts +147 -0
  286. package/src/types/motion/spatializedPlayback.ts +17 -0
  287. package/src/types/motion/spatializedVisual.ts +24 -0
  288. package/src/types/types.ts +3 -0
  289. package/src/utils.ts +54 -0
  290. package/tsup.config.ts +61 -36
  291. package/vitest.config.ts +5 -1
  292. package/dist/iife/index.d.ts +0 -1251
  293. package/dist/iife/index.global.js +0 -75
  294. package/dist/iife/index.global.js.map +0 -1
  295. package/src/platform-adapter/ssr/SSRPlatform.ts +0 -52
  296. /package/src/{ssr-polyfill.ts → isSSREnv.ts} +0 -0
@@ -0,0 +1,77 @@
1
+ import {
2
+ CommandResultFailure,
3
+ CommandResultSuccess
4
+ } from "../CommandResultUtils";
5
+ import { buildSpatialSceneQuery } from "../spatialSceneQuery";
6
+ import {
7
+ buildSpatialRequestQuery,
8
+ createSpatialRequestId
9
+ } from "../spatialRequestMetadata";
10
+ const UUID_RE = /\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\b/gi;
11
+ class VisionOSPlatform {
12
+ async callJSB(cmd, msg) {
13
+ try {
14
+ const result = await window.webkit.messageHandlers.bridge.postMessage(
15
+ `${cmd}::${msg}`
16
+ );
17
+ return CommandResultSuccess(result);
18
+ } catch (error) {
19
+ const { code, message } = this.parseJSBError(error);
20
+ return CommandResultFailure(code, message);
21
+ }
22
+ }
23
+ openSpatialSceneSync(url, config, target, features) {
24
+ const query = buildSpatialSceneQuery(url, config);
25
+ const { spatialId: id = "", windowProxy } = this.openWindow(
26
+ "createSpatialScene",
27
+ query,
28
+ target,
29
+ features
30
+ );
31
+ return CommandResultSuccess({ windowProxy, id });
32
+ }
33
+ createNativeSpatialDiv() {
34
+ return this.openProtocolAsync("createSpatialized2DElement");
35
+ }
36
+ createNativeAttachment(_options) {
37
+ return this.openProtocolAsync("createAttachment");
38
+ }
39
+ async openProtocolAsync(command) {
40
+ const requestId = createSpatialRequestId();
41
+ const { spatialId: id = "", windowProxy } = this.openWindow(
42
+ command,
43
+ buildSpatialRequestQuery(requestId),
44
+ void 0,
45
+ void 0
46
+ );
47
+ return CommandResultSuccess({ windowProxy, id });
48
+ }
49
+ openWindow(command, query, target, features) {
50
+ const windowProxy = window.open(
51
+ `webspatial://${command}?${query || ""}`,
52
+ target,
53
+ features
54
+ );
55
+ const ua = windowProxy?.navigator.userAgent;
56
+ const spatialId = ua?.match(UUID_RE)?.[0];
57
+ return { spatialId, windowProxy };
58
+ }
59
+ parseJSBError(error) {
60
+ try {
61
+ const parsed = JSON.parse(error.message ?? "");
62
+ return {
63
+ code: parsed.code ?? "E_VISIONOS_JSB",
64
+ message: parsed.message ?? "VisionOS JSB execution failed"
65
+ };
66
+ } catch {
67
+ return {
68
+ code: "E_VISIONOS_JSB",
69
+ message: error?.message ?? "VisionOS JSB execution failed"
70
+ };
71
+ }
72
+ }
73
+ }
74
+ export {
75
+ VisionOSPlatform
76
+ };
77
+ //# sourceMappingURL=VisionOSPlatform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/platform-adapter/vision-os/VisionOSPlatform.ts"],"sourcesContent":["import {\n PlatformAbility,\n CommandResult,\n WebSpatialProtocolResult,\n} from '../interface'\nimport {\n CommandResultFailure,\n CommandResultSuccess,\n} from '../CommandResultUtils'\nimport { buildSpatialSceneQuery } from '../spatialSceneQuery'\nimport type { SpatialSceneCreationOptionsInternal } from '../../types/internal'\nimport type { AttachmentEntityOptions } from '../../types/types'\nimport {\n buildSpatialRequestQuery,\n createSpatialRequestId,\n} from '../spatialRequestMetadata'\n\ntype JSBError = {\n code?: string\n message: string\n}\n\nconst UUID_RE =\n /\\b([0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})\\b/gi\n\nexport class VisionOSPlatform implements PlatformAbility {\n async callJSB(cmd: string, msg: string): Promise<CommandResult> {\n try {\n const result = await window.webkit.messageHandlers.bridge.postMessage(\n `${cmd}::${msg}`,\n )\n return CommandResultSuccess(result)\n } catch (error: unknown) {\n // console.error(`VisionOSPlatform cmd: ${cmd}, msg: ${msg} error: ${error}`)\n const { code, message } = this.parseJSBError(error)\n return CommandResultFailure(code, message)\n }\n }\n\n openSpatialSceneSync(\n url: string,\n config: SpatialSceneCreationOptionsInternal | undefined,\n target?: string,\n features?: string,\n ): WebSpatialProtocolResult {\n const query = buildSpatialSceneQuery(url, config)\n const { spatialId: id = '', windowProxy } = this.openWindow(\n 'createSpatialScene',\n query,\n target,\n features,\n )\n\n return CommandResultSuccess({ windowProxy, id })\n }\n\n createNativeSpatialDiv(): Promise<WebSpatialProtocolResult> {\n return this.openProtocolAsync('createSpatialized2DElement')\n }\n\n createNativeAttachment(\n _options?: AttachmentEntityOptions,\n ): Promise<WebSpatialProtocolResult> {\n return this.openProtocolAsync('createAttachment')\n }\n\n private async openProtocolAsync(\n command: string,\n ): Promise<WebSpatialProtocolResult> {\n const requestId = createSpatialRequestId()\n const { spatialId: id = '', windowProxy } = this.openWindow(\n command,\n buildSpatialRequestQuery(requestId),\n undefined,\n undefined,\n )\n return CommandResultSuccess({ windowProxy, id })\n }\n\n private openWindow(\n command: string,\n query?: string,\n target?: string,\n features?: string,\n ): { spatialId?: string; windowProxy: WindowProxy | null } {\n const windowProxy = window.open(\n `webspatial://${command}?${query || ''}`,\n target,\n features,\n )\n const ua = windowProxy?.navigator.userAgent\n const spatialId = ua?.match(UUID_RE)?.[0]\n\n return { spatialId, windowProxy }\n }\n\n private parseJSBError(error: unknown): { code: string; message: string } {\n try {\n const parsed = JSON.parse((error as JSBError).message ?? '')\n return {\n code: parsed.code ?? 'E_VISIONOS_JSB',\n message: parsed.message ?? 'VisionOS JSB execution failed',\n }\n } catch {\n return {\n code: 'E_VISIONOS_JSB',\n message:\n (error as JSBError)?.message ?? 'VisionOS JSB execution failed',\n }\n }\n }\n}\n"],"mappings":"AAKA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AAGvC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAOP,MAAM,UACJ;AAEK,MAAM,iBAA4C;AAAA,EACvD,MAAM,QAAQ,KAAa,KAAqC;AAC9D,QAAI;AACF,YAAM,SAAS,MAAM,OAAO,OAAO,gBAAgB,OAAO;AAAA,QACxD,GAAG,GAAG,KAAK,GAAG;AAAA,MAChB;AACA,aAAO,qBAAqB,MAAM;AAAA,IACpC,SAAS,OAAgB;AAEvB,YAAM,EAAE,MAAM,QAAQ,IAAI,KAAK,cAAc,KAAK;AAClD,aAAO,qBAAqB,MAAM,O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
+ import { aY as PlatformAbility } from './spatializedElementMotion-_0XWPQCE.js';
2
+ import './types/motion/spatializedVisual.js';
3
+ import './types/motion/spatializedPlayback.js';
4
+ import './types/global.js';
5
+ import './physicalMetrics-W5uZ5xKb.js';
6
+ import './SpatialObject.js';
7
+ import './reality/component/SpatialComponent.js';
8
+
9
+ declare function getPlatformSync(): PlatformAbility;
10
+ declare function getPlatform(): Promise<PlatformAbility>;
11
+
12
+ export { getPlatform, getPlatformSync };
@@ -0,0 +1,14 @@
1
+ import { createPlatformSync } from "./platform-adapter";
2
+ let platformResolved;
3
+ function getPlatformSync() {
4
+ platformResolved ??= createPlatformSync();
5
+ return platformResolved;
6
+ }
7
+ async function getPlatform() {
8
+ return getPlatformSync();
9
+ }
10
+ export {
11
+ getPlatform,
12
+ getPlatformSync
13
+ };
14
+ //# sourceMappingURL=platform-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/platform-runtime.ts"],"sourcesContent":["import { createPlatformSync } from './platform-adapter'\nimport type { PlatformAbility } from './platform-adapter/interface'\n\nlet platformResolved: PlatformAbility | undefined\n\nexport function getPlatformSync(): PlatformAbility {\n platformResolved ??= createPlatformSync()\n return platformResolved\n}\n\nexport async function getPlatform(): Promise<PlatformAbility> {\n return getPlatformSync()\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AAGnC,IAAI;AAEG,SAAS,kBAAmC;AACjD,uBAAqB,mBAAmB;AACxC,SAAO;AACT;AAEA,eAAsB,cAAwC;AAC5D,SAAO,gBAAgB;AACzB;","names":[]}
@@ -0,0 +1,19 @@
1
+ import { h as AttachmentEntityOptions, i as AttachmentEntityUpdateOptions, aK as CommandResult } from '../spatializedElementMotion-_0XWPQCE.js';
2
+ import { SpatialObject } from '../SpatialObject.js';
3
+ import '../types/motion/spatializedVisual.js';
4
+ import '../types/motion/spatializedPlayback.js';
5
+ import '../types/global.js';
6
+ import '../physicalMetrics-W5uZ5xKb.js';
7
+ import './component/SpatialComponent.js';
8
+
9
+ declare class Attachment extends SpatialObject {
10
+ private readonly windowProxy;
11
+ private options;
12
+ constructor(id: string, windowProxy: WindowProxy, options: AttachmentEntityOptions);
13
+ getContainer(): HTMLElement;
14
+ getWindowProxy(): WindowProxy;
15
+ update(options: AttachmentEntityUpdateOptions): Promise<CommandResult<any> | undefined>;
16
+ }
17
+ declare function createAttachmentEntity(options: AttachmentEntityOptions): Promise<Attachment>;
18
+
19
+ export { Attachment, createAttachmentEntity };
@@ -0,0 +1,39 @@
1
+ import { SpatialObject } from "../SpatialObject";
2
+ import {
3
+ UpdateAttachmentEntityCommand,
4
+ InitializeAttachmentCommand
5
+ } from "../JSBCommand";
6
+ import { createNativeAttachment } from "../spatial-host";
7
+ class Attachment extends SpatialObject {
8
+ constructor(id, windowProxy, options) {
9
+ super(id);
10
+ this.windowProxy = windowProxy;
11
+ this.options = options;
12
+ }
13
+ getContainer() {
14
+ return this.windowProxy.document.body;
15
+ }
16
+ getWindowProxy() {
17
+ return this.windowProxy;
18
+ }
19
+ async update(options) {
20
+ if (this.isDestroyed) return;
21
+ if (options.position) this.options.position = options.position;
22
+ if (options.size) this.options.size = options.size;
23
+ return new UpdateAttachmentEntityCommand(this.id, options).execute();
24
+ }
25
+ }
26
+ async function createAttachmentEntity(options) {
27
+ const result = await createNativeAttachment(options);
28
+ if (!result.success) {
29
+ throw new Error("createAttachmentEntity failed: " + result?.errorMessage);
30
+ }
31
+ const { id, windowProxy } = result.data;
32
+ await new InitializeAttachmentCommand(id, options).execute();
33
+ return new Attachment(id, windowProxy, options);
34
+ }
35
+ export {
36
+ Attachment,
37
+ createAttachmentEntity
38
+ };
39
+ //# sourceMappingURL=Attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/reality/Attachment.ts"],"sourcesContent":["import { SpatialObject } from '../SpatialObject'\nimport {\n UpdateAttachmentEntityCommand,\n InitializeAttachmentCommand,\n} from '../JSBCommand'\nimport { createNativeAttachment } from '../spatial-host'\nimport {\n AttachmentEntityOptions,\n AttachmentEntityUpdateOptions,\n} from '../types/types'\n\nexport class Attachment extends SpatialObject {\n constructor(\n id: string,\n private readonly windowProxy: WindowProxy,\n private options: AttachmentEntityOptions,\n ) {\n super(id)\n }\n\n getContainer(): HTMLElement {\n return (this.windowProxy as Window).document.body\n }\n\n getWindowProxy(): WindowProxy {\n return this.windowProxy\n }\n\n async update(options: AttachmentEntityUpdateOptions) {\n if (this.isDestroyed) return\n if (options.position) this.options.position = options.position\n if (options.size) this.options.size = options.size\n return new UpdateAttachmentEntityCommand(this.id, options).execute()\n }\n}\n\nexport async function createAttachmentEntity(\n options: AttachmentEntityOptions,\n): Promise<Attachment> {\n const result = await createNativeAttachment(options)\n if (!result.success) {\n throw new Error('createAttachmentEntity failed: ' + result?.errorMessage)\n }\n const { id, windowProxy } = result.data!\n await new InitializeAttachmentCommand(id, options).execute()\n return new Attachment(id, windowProxy, options)\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AAMhC,MAAM,mBAAmB,cAAc;AAAA,EAC5C,YACE,IACiB,aACT,SACR;AACA,UAAM,EAAE;AAHS;AACT;AAAA,EAGV;AAAA,EAEA,eAA4B;AAC1B,WAAQ,KAAK,YAAuB,SAAS;AAAA,EAC/C;AAAA,EAEA,iBAA8B;AAC5B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,OAAO,SAAwC;AACnD,QAAI,KAAK,YAAa;AACtB,QAAI,QAAQ,SAAU,MAAK,QAAQ,WAAW,QAAQ;AACtD,QAAI,QAAQ,KAAM,MAAK,QAAQ,OAAO,QAAQ;AAC9C,WAAO,IAAI,8BAA8B,KAAK,IAAI,OAAO,EAAE,QAAQ;AAAA,EACrE;AACF;AAEA,eAAsB,uBACpB,SACqB;AACrB,QAAM,SAAS,MAAM,uBAAuB,OAAO;AACnD,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,IAAI,MAAM,oCAAoC,QAAQ,YAAY;AAAA,EAC1E;AACA,QAAM,EAAE,IAAI,YAAY,IAAI,OAAO;AACnC,QAAM,IAAI,4BAA4B,IAAI,OAAO,EAAE,QAAQ;AAC3D,SAAO,IAAI,WAAW,IAAI,aAAa,OAAO;AAChD;","names":[]}
@@ -0,0 +1,14 @@
1
+ import { SpatialComponent } from './SpatialComponent.js';
2
+ import { m as ModelComponentOptions } from '../../spatializedElementMotion-_0XWPQCE.js';
3
+ import '../../SpatialObject.js';
4
+ import '../../types/motion/spatializedVisual.js';
5
+ import '../../types/motion/spatializedPlayback.js';
6
+ import '../../types/global.js';
7
+ import '../../physicalMetrics-W5uZ5xKb.js';
8
+
9
+ declare class ModelComponent extends SpatialComponent {
10
+ options: ModelComponentOptions;
11
+ constructor(id: string, options: ModelComponentOptions);
12
+ }
13
+
14
+ export { ModelComponent };
@@ -0,0 +1,11 @@
1
+ import { SpatialComponent } from "./SpatialComponent";
2
+ class ModelComponent extends SpatialComponent {
3
+ constructor(id, options) {
4
+ super(id);
5
+ this.options = options;
6
+ }
7
+ }
8
+ export {
9
+ ModelComponent
10
+ };
11
+ //# sourceMappingURL=ModelComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/reality/component/ModelComponent.ts"],"sourcesContent":["import { ModelComponentOptions } from '../../types/types'\nimport { SpatialComponent } from './SpatialComponent'\n\nexport class ModelComponent extends SpatialComponent {\n constructor(\n id: string,\n public options: ModelComponentOptions,\n ) {\n super(id)\n }\n}\n"],"mappings":"AACA,SAAS,wBAAwB;AAE1B,MAAM,uBAAuB,iBAAiB;AAAA,EACnD,YACE,IACO,SACP;AACA,UAAM,EAAE;AAFD;AAAA,EAGT;AACF;","names":[]}
@@ -0,0 +1,8 @@
1
+ import { SpatialObject } from '../../SpatialObject.js';
2
+
3
+ declare class SpatialComponent extends SpatialObject {
4
+ constructor(id: string);
5
+ private onReceiveEvent;
6
+ }
7
+
8
+ export { SpatialComponent };
@@ -0,0 +1,19 @@
1
+ import { SpatialObject } from "../../SpatialObject";
2
+ import { SpatialWebEvent } from "../../SpatialWebEvent";
3
+ import { SpatialWebMsgType } from "../../WebMsgCommand";
4
+ class SpatialComponent extends SpatialObject {
5
+ constructor(id) {
6
+ super(id);
7
+ SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent);
8
+ }
9
+ onReceiveEvent = (data) => {
10
+ const { type } = data;
11
+ if (type === SpatialWebMsgType.objectdestroy) {
12
+ this.isDestroyed = true;
13
+ }
14
+ };
15
+ }
16
+ export {
17
+ SpatialComponent
18
+ };
19
+ //# sourceMappingURL=SpatialComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/reality/component/SpatialComponent.ts"],"sourcesContent":["import { SpatialObject } from '../../SpatialObject'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { ObjectDestroyMsg, SpatialWebMsgType } from '../../WebMsgCommand'\n\nexport class SpatialComponent extends SpatialObject {\n constructor(id: string) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n private onReceiveEvent = (data: ObjectDestroyMsg) => {\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n }\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,SAA2B,yBAAyB;AAE7C,MAAM,yBAAyB,cAAc;AAAA,EAClD,YAAY,IAAY;AACtB,UAAM,EAAE;AACR,oBAAgB,iBAAiB,IAAI,KAAK,cAAc;AAAA,EAC1D;AAAA,EAEQ,iBAAiB,CAAC,SAA2B;AACnD,UAAM,EAAE,KAAK,IAAI;AACjB,QAAI,SAAS,kBAAkB,eAAe;AAC5C,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,8 @@
1
+ export { SpatialComponent } from './SpatialComponent.js';
2
+ export { ModelComponent } from './ModelComponent.js';
3
+ import '../../SpatialObject.js';
4
+ import '../../spatializedElementMotion-_0XWPQCE.js';
5
+ import '../../types/motion/spatializedVisual.js';
6
+ import '../../types/motion/spatializedPlayback.js';
7
+ import '../../types/global.js';
8
+ import '../../physicalMetrics-W5uZ5xKb.js';
@@ -0,0 +1,3 @@
1
+ export * from "./SpatialComponent";
2
+ export * from "./ModelComponent";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/reality/component/index.ts"],"sourcesContent":["export * from './SpatialComponent'\nexport * from './ModelComponent'\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,7 @@
1
+ export { H as SpatialEntity } from '../../spatializedElementMotion-_0XWPQCE.js';
2
+ import '../../SpatialObject.js';
3
+ import '../component/SpatialComponent.js';
4
+ import '../../types/motion/spatializedVisual.js';
5
+ import '../../types/motion/spatializedPlayback.js';
6
+ import '../../types/global.js';
7
+ import '../../physicalMetrics-W5uZ5xKb.js';
@@ -0,0 +1,291 @@
1
+ import {
2
+ ConvertFromEntityToEntityCommand,
3
+ ConvertFromEntityToSceneCommand,
4
+ ConvertFromSceneToEntityCommand,
5
+ SetParentForEntityCommand,
6
+ AnimateTransformJSBCommand
7
+ } from "./../../JSBCommand";
8
+ import {
9
+ AddComponentToEntityCommand,
10
+ RemoveComponentFromEntityCommand,
11
+ UpdateEntityEventCommand,
12
+ UpdateEntityPropertiesCommand
13
+ } from "../../JSBCommand";
14
+ import { SpatialObject } from "../../SpatialObject";
15
+ import { SpatialWebEvent } from "../../SpatialWebEvent";
16
+ import { createSpatialEvent } from "../../SpatialWebEventCreator";
17
+ import { decomposeSRT } from "../../utils";
18
+ import {
19
+ SpatialWebMsgType
20
+ } from "../../WebMsgCommand";
21
+ class SpatialEntity extends SpatialObject {
22
+ constructor(id, userData) {
23
+ super(id);
24
+ this.userData = userData;
25
+ SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent);
26
+ }
27
+ position = { x: 0, y: 0, z: 0 };
28
+ rotation = { x: 0, y: 0, z: 0 };
29
+ scale = { x: 1, y: 1, z: 1 };
30
+ events = {};
31
+ children = [];
32
+ parent = null;
33
+ _enableInput = false;
34
+ get enableInput() {
35
+ return this._enableInput;
36
+ }
37
+ set enableInput(value) {
38
+ if (this._enableInput === value) return;
39
+ this._enableInput = value;
40
+ void this.updateEntityEvent("spatialtap", value).catch((err) => {
41
+ console.error("enableInput updateEntityEvent failed", "spatialtap", err);
42
+ if (this._enableInput === value) {
43
+ this._enableInput = !value;
44
+ }
45
+ });
46
+ }
47
+ async addComponent(component) {
48
+ return new AddComponentToEntityCommand(this, component).execute();
49
+ }
50
+ async removeComponent(component) {
51
+ return new RemoveComponentFromEntityCommand(this, component).execute();
52
+ }
53
+ async setPosition(position) {
54
+ return this.updateTransform({ position });
55
+ }
56
+ async setRotation(rotation) {
57
+ return this.updateTransform({ rotation });
58
+ }
59
+ async setScale(scale) {
60
+ return this.updateTransform({ scale });
61
+ }
62
+ async addEntity(ent) {
63
+ const ans = await new SetParentForEntityCommand(ent.id, this.id).execute();
64
+ this.children.push(ent);
65
+ ent.parent = this;
66
+ return ans;
67
+ }
68
+ async removeFromParent() {
69
+ const ans = await new SetParentForEntityCommand(
70
+ this.id,
71
+ void 0
72
+ ).execute();
73
+ if (this.parent) {
74
+ this.parent.children = this.parent.children.filter(
75
+ (child) => child.id !== this.id
76
+ );
77
+ this.parent = null;
78
+ }
79
+ return ans;
80
+ }
81
+ async updateTransform(properties) {
82
+ this.position = properties.position ?? this.position;
83
+ this.rotation = properties.rotation ?? this.rotation;
84
+ this.scale = properties.scale ?? this.scale;
85
+ return new UpdateEntityPropertiesCommand(this, properties).execute();
86
+ }
87
+ async animateTransform(command) {
88
+ const { animationId, type } = command;
89
+ if (type === "play") {
90
+ let resolveFinished;
91
+ let resolveCancel;
92
+ let resolveFailed;
93
+ const finished = new Promise((r) => {
94
+ resolveFinished = r;
95
+ });
96
+ const canceled = new Promise((r) => {
97
+ resolveCancel = r;
98
+ });
99
+ const failed = new Promise((r) => {
100
+ resolveFailed = r;
101
+ });
102
+ const cleanup = () => {
103
+ SpatialWebEvent.removeEventReceiver(`${animationId}_completed`);
104
+ SpatialWebEvent.removeEventReceiver(`${animationId}_canceled`);
105
+ SpatialWebEvent.removeEventReceiver(`${animationId}_failed`);
106
+ };
107
+ SpatialWebEvent.addEventReceiver(
108
+ `${animationId}_completed`,
109
+ (data) => {
110
+ cleanup();
111
+ const values = decomposeSRT(data.transform);
112
+ if (values.position) this.position = values.position;
113
+ if (values.rotation) this.rotation = values.rotation;
114
+ if (values.scale) this.scale = values.scale;
115
+ resolveFinished(values);
116
+ }
117
+ );
118
+ SpatialWebEvent.addEventReceiver(
119
+ `${animationId}_canceled`,
120
+ (data) => {
121
+ cleanup();
122
+ const values = decomposeSRT(data.transform);
123
+ if (values.position) this.position = values.position;
124
+ if (values.rotation) this.rotation = values.rotation;
125
+ if (values.scale) this.scale = values.scale;
126
+ resolveCancel(values);
127
+ }
128
+ );
129
+ SpatialWebEvent.addEventReceiver(
130
+ `${animationId}_failed`,
131
+ (data) => {
132
+ cleanup();
133
+ resolveFailed({
134
+ animationId: data.animationId,
135
+ command: data.command,
136
+ code: data.code,
137
+ reason: data.reason
138
+ });
139
+ }
140
+ );
141
+ const result = await new AnimateTransformJSBCommand(command).execute();
142
+ if (!result.success) {
143
+ cleanup();
144
+ throw new Error(
145
+ result.errorMessage ?? "AnimateTransform play command failed"
146
+ );
147
+ }
148
+ return {
149
+ animationId,
150
+ finished,
151
+ canceled,
152
+ failed
153
+ };
154
+ } else {
155
+ const result = await new AnimateTransformJSBCommand(command).execute();
156
+ if (!result.success) {
157
+ throw new Error(
158
+ result.errorMessage ?? `AnimateTransform ${type} command failed`
159
+ );
160
+ }
161
+ }
162
+ }
163
+ /**
164
+ * Remove all animation event receivers for a given animationId.
165
+ * Called on entity unmount to prevent leaked listeners.
166
+ */
167
+ cleanupAnimationListeners(animationId) {
168
+ SpatialWebEvent.removeEventReceiver(`${animationId}_completed`);
169
+ SpatialWebEvent.removeEventReceiver(`${animationId}_canceled`);
170
+ SpatialWebEvent.removeEventReceiver(`${animationId}_failed`);
171
+ }
172
+ async addEvent(type, callback) {
173
+ if (this.events[type]) {
174
+ this.events[type] = callback;
175
+ } else {
176
+ try {
177
+ await this.updateEntityEvent(type, true);
178
+ this.events[type] = callback;
179
+ } catch (error) {
180
+ console.error("addEvent failed", type);
181
+ }
182
+ }
183
+ }
184
+ async removeEvent(eventName) {
185
+ if (this.events[eventName]) {
186
+ delete this.events[eventName];
187
+ try {
188
+ await this.updateEntityEvent(eventName, false);
189
+ } catch (error) {
190
+ console.error("removeEvent failed", eventName);
191
+ }
192
+ }
193
+ }
194
+ async updateEntityEvent(eventName, isEnable) {
195
+ return new UpdateEntityEventCommand(this, eventName, isEnable).execute();
196
+ }
197
+ onReceiveEvent = (data) => {
198
+ const { type } = data;
199
+ if (type === SpatialWebMsgType.objectdestroy) {
200
+ this.isDestroyed = true;
201
+ } else if (type === SpatialWebMsgType.spatialtap) {
202
+ const evt = createSpatialEvent(SpatialWebMsgType.spatialtap, data.detail);
203
+ this.dispatchEvent(evt);
204
+ } else if (type === SpatialWebMsgType.spatialdragstart) {
205
+ const evt = createSpatialEvent(
206
+ SpatialWebMsgType.spatialdragstart,
207
+ data.detail
208
+ );
209
+ this.dispatchEvent(evt);
210
+ } else if (type === SpatialWebMsgType.spatialdrag) {
211
+ const evt = createSpatialEvent(SpatialWebMsgType.spatialdrag, data.detail);
212
+ this.dispatchEvent(evt);
213
+ } else if (type === SpatialWebMsgType.spatialdragend) {
214
+ const evt = createSpatialEvent(
215
+ SpatialWebMsgType.spatialdragend,
216
+ data.detail
217
+ );
218
+ this.dispatchEvent(evt);
219
+ } else if (type === SpatialWebMsgType.spatialrotate) {
220
+ const evt = createSpatialEvent(
221
+ SpatialWebMsgType.spatialrotate,
222
+ data.detail
223
+ );
224
+ this.dispatchEvent(evt);
225
+ } else if (type === SpatialWebMsgType.spatialrotateend) {
226
+ const evt = createSpatialEvent(
227
+ SpatialWebMsgType.spatialrotateend,
228
+ data.detail
229
+ );
230
+ this.dispatchEvent(evt);
231
+ } else if (type === SpatialWebMsgType.spatialmagnify) {
232
+ const evt = createSpatialEvent(
233
+ SpatialWebMsgType.spatialmagnify,
234
+ data.detail
235
+ );
236
+ this.dispatchEvent(evt);
237
+ } else if (type === SpatialWebMsgType.spatialmagnifyend) {
238
+ const evt = createSpatialEvent(
239
+ SpatialWebMsgType.spatialmagnifyend,
240
+ data.detail
241
+ );
242
+ this.dispatchEvent(evt);
243
+ }
244
+ };
245
+ dispatchEvent(evt) {
246
+ if (!evt.__origin) {
247
+ Object.defineProperty(evt, "__origin", { value: this, enumerable: false });
248
+ }
249
+ this.events[evt.type]?.(evt);
250
+ if (evt.bubbles && !evt.cancelBubble) {
251
+ if (this.parent) {
252
+ this.parent.dispatchEvent(evt);
253
+ }
254
+ }
255
+ }
256
+ onDestroy() {
257
+ SpatialWebEvent.removeEventReceiver(this.id);
258
+ this.children.forEach((child) => {
259
+ child.parent = null;
260
+ });
261
+ this.children = [];
262
+ if (this.parent) {
263
+ this.parent.children = this.parent.children.filter(
264
+ (child) => child.id !== this.id
265
+ );
266
+ this.parent = null;
267
+ }
268
+ }
269
+ // onUpdate(properties: SpatialEntityProperties) {
270
+ // this.position = properties.position
271
+ // this.rotation = properties.rotation
272
+ // this.scale = properties.scale
273
+ // }
274
+ async convertFromEntityToEntity(fromEntityId, toEntityId, position) {
275
+ return new ConvertFromEntityToEntityCommand(
276
+ fromEntityId,
277
+ toEntityId,
278
+ position
279
+ ).execute();
280
+ }
281
+ async convertFromEntityToScene(fromEntityId, position) {
282
+ return new ConvertFromEntityToSceneCommand(fromEntityId, position).execute();
283
+ }
284
+ async convertFromSceneToEntity(entityId, position) {
285
+ return new ConvertFromSceneToEntityCommand(entityId, position).execute();
286
+ }
287
+ }
288
+ export {
289
+ SpatialEntity
290
+ };
291
+ //# sourceMappingURL=SpatialEntity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/reality/entity/SpatialEntity.ts"],"sourcesContent":["import {\n ConvertFromEntityToEntityCommand,\n ConvertFromEntityToSceneCommand,\n ConvertFromSceneToEntityCommand,\n SetParentForEntityCommand,\n AnimateTransformJSBCommand,\n} from './../../JSBCommand'\nimport {\n SpatialEntityEventType,\n SpatialEntityOrReality,\n SpatialEntityUserData,\n Vec3,\n} from '../../types/types'\nimport type {\n AnimateTransformCommand,\n AnimateTransformResult,\n TransformValues,\n AnimationError,\n} from '../../types/animation'\nimport {\n AddComponentToEntityCommand,\n RemoveComponentFromEntityCommand,\n UpdateEntityEventCommand,\n UpdateEntityPropertiesCommand,\n} from '../../JSBCommand'\nimport { SpatialObject } from '../../SpatialObject'\nimport { SpatialEntityProperties } from '../../types/types'\nimport { SpatialComponent } from '../component/SpatialComponent'\nimport { SpatialWebEvent } from '../../SpatialWebEvent'\nimport { createSpatialEvent } from '../../SpatialWebEventCreator'\nimport { decomposeSRT } from '../../utils'\nimport {\n ObjectDestroyMsg,\n SpatialDragEndMsg,\n SpatialDragMsg,\n SpatialDragStartMsg,\n SpatialMagnifyEndMsg,\n SpatialMagnifyMsg,\n SpatialRotateEndMsg,\n SpatialRotateMsg,\n SpatialTapMsg,\n SpatialWebMsgType,\n AnimationCompletedEventPayload,\n AnimationCanceledEventPayload,\n AnimationFailedEventPayload,\n} from '../../WebMsgCommand'\n\nexport class SpatialEntity extends SpatialObject {\n position: Vec3 = { x: 0, y: 0, z: 0 }\n rotation: Vec3 = { x: 0, y: 0, z: 0 }\n scale: Vec3 = { x: 1, y: 1, z: 1 }\n\n events: Record<string, (data: any) => void> = {}\n children: SpatialEntity[] = []\n parent: SpatialEntityOrReality | null = null\n private _enableInput: boolean = false\n\n get enableInput(): boolean {\n return this._enableInput\n }\n\n set enableInput(value: boolean) {\n // Why enabling only 'spatialtap' makes the entity interactive:\n // - On the native (Swift/RealityKit) side, SpatialEntity.updateGesture(type, isEnable)\n // toggles per-gesture flags. Then enableInteractive = enableTap || enableRotate || enableDrag || enableMagnify.\n // - As soon as any gesture (e.g., 'spatialtap') is enabled, enableInteractive becomes true and\n // InputTargetComponent is attached, making the entity targetable by targetedToAnyEntity().\n // - The view layer forwards hit gestures to the web, so enabling 'spatialtap' is sufficient to\n // make the entity targetable; enable additional gestures only when needed.\n if (this._enableInput === value) return\n this._enableInput = value\n void this.updateEntityEvent('spatialtap', value).catch(err => {\n console.error('enableInput updateEntityEvent failed', 'spatialtap', err)\n // Roll back local flag if the native toggle fails to keep web/native states consistent.\n // Otherwise, the web side would think the entity is interactive while RealityKit is not.\n if (this._enableInput === value) {\n this._enableInput = !value\n }\n })\n }\n constructor(\n id: string,\n public userData?: SpatialEntityUserData,\n ) {\n super(id)\n SpatialWebEvent.addEventReceiver(id, this.onReceiveEvent)\n }\n\n async addComponent(component: SpatialComponent) {\n return new AddComponentToEntityCommand(this, component).execute()\n }\n async removeComponent(component: SpatialComponent) {\n return new RemoveComponentFromEntityCommand(this, component).execute()\n }\n async setPosition(position: Vec3) {\n return this.updateTransform({ position })\n }\n async setRotation(rotation: Vec3) {\n return this.updateTransform({ rotation })\n }\n async setScale(scale: Vec3) {\n return this.updateTransform({ scale })\n }\n\n async addEntity(ent: SpatialEntity) {\n const ans = await new SetParentForEntityCommand(ent.id, this.id).execute()\n this.children.push(ent)\n ent.parent = this\n return ans\n }\n async removeFromParent() {\n const ans = await new SetParentForEntityCommand(\n this.id,\n undefined,\n ).execute()\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n return ans\n }\n\n async updateTransform(properties: Partial<SpatialEntityProperties>) {\n this.position = properties.position ?? this.position\n this.rotation = properties.rotation ?? this.rotation\n this.scale = properties.scale ?? this.scale\n return new UpdateEntityPropertiesCommand(this, properties).execute()\n }\n\n /**\n * Send an animation command to the native layer.\n *\n * For `play`: registers event listeners for completion / stop / failure,\n * sends the JSB command, and returns an `AnimateTransformResult` with\n * `finished` and `stopped` promises.\n *\n * For `pause`, `resume`, `cancel``: sends the command and resolves when\n * the bridge acknowledges it.\n */\n animateTransform(\n command: AnimateTransformCommand & { type: 'play' },\n ): Promise<AnimateTransformResult>\n animateTransform(command: AnimateTransformCommand): Promise<void>\n async animateTransform(\n command: AnimateTransformCommand,\n ): Promise<AnimateTransformResult | void> {\n const { animationId, type } = command\n\n if (type === 'play') {\n // Register event listeners BEFORE sending the play command\n // to avoid race conditions where native fires before we listen.\n let resolveFinished!: (val: TransformValues) => void\n let resolveCancel!: (val: TransformValues) => void\n let resolveFailed!: (err: AnimationError) => void\n\n const finished = new Promise<TransformValues>(r => {\n resolveFinished = r\n })\n const canceled = new Promise<TransformValues>(r => {\n resolveCancel = r\n })\n const failed = new Promise<AnimationError>(r => {\n resolveFailed = r\n })\n\n const cleanup = () => {\n SpatialWebEvent.removeEventReceiver(`${animationId}_completed`)\n SpatialWebEvent.removeEventReceiver(`${animationId}_canceled`)\n SpatialWebEvent.removeEventReceiver(`${animationId}_failed`)\n }\n\n SpatialWebEvent.addEventReceiver(\n `${animationId}_completed`,\n (data: AnimationCompletedEventPayload) => {\n cleanup()\n const values = decomposeSRT(data.transform)\n // Update local entity state to match the native final transform\n if (values.position) this.position = values.position\n if (values.rotation) this.rotation = values.rotation\n if (values.scale) this.scale = values.scale\n resolveFinished(values)\n },\n )\n\n SpatialWebEvent.addEventReceiver(\n `${animationId}_canceled`,\n (data: AnimationCanceledEventPayload) => {\n cleanup()\n const values = decomposeSRT(data.transform)\n if (values.position) this.position = values.position\n if (values.rotation) this.rotation = values.rotation\n if (values.scale) this.scale = values.scale\n resolveCancel(values)\n },\n )\n\n SpatialWebEvent.addEventReceiver(\n `${animationId}_failed`,\n (data: AnimationFailedEventPayload) => {\n cleanup()\n resolveFailed({\n animationId: data.animationId,\n command: data.command,\n code: data.code,\n reason: data.reason,\n })\n },\n )\n\n // Send the play command\n const result = await new AnimateTransformJSBCommand(command).execute()\n if (!result.success) {\n cleanup()\n throw new Error(\n result.errorMessage ?? 'AnimateTransform play command failed',\n )\n }\n\n return {\n animationId,\n finished,\n canceled,\n failed,\n } as AnimateTransformResult\n } else {\n // pause / resume / cancel — fire and wait for bridge ack\n const result = await new AnimateTransformJSBCommand(command).execute()\n if (!result.success) {\n throw new Error(\n result.errorMessage ?? `AnimateTransform ${type} command failed`,\n )\n }\n }\n }\n\n /**\n * Remove all animation event receivers for a given animationId.\n * Called on entity unmount to prevent leaked listeners.\n */\n cleanupAnimationListeners(animationId: string) {\n SpatialWebEvent.removeEventReceiver(`${animationId}_completed`)\n SpatialWebEvent.removeEventReceiver(`${animationId}_canceled`)\n SpatialWebEvent.removeEventReceiver(`${animationId}_failed`)\n }\n\n async addEvent(type: SpatialEntityEventType, callback: (data: any) => void) {\n if (this.events[type]) {\n // replace if exist\n this.events[type] = callback\n } else {\n try {\n await this.updateEntityEvent(type, true)\n this.events[type] = callback\n } catch (error) {\n console.error('addEvent failed', type)\n }\n }\n }\n\n async removeEvent(eventName: SpatialEntityEventType) {\n if (this.events[eventName]) {\n delete this.events[eventName]\n try {\n await this.updateEntityEvent(eventName, false)\n } catch (error) {\n console.error('removeEvent failed', eventName)\n }\n }\n }\n\n async updateEntityEvent(\n eventName: SpatialEntityEventType,\n isEnable: boolean,\n ) {\n return new UpdateEntityEventCommand(this, eventName, isEnable).execute()\n }\n private onReceiveEvent = (\n data:\n | SpatialTapMsg\n | SpatialDragStartMsg\n | SpatialDragMsg\n | SpatialDragEndMsg\n | SpatialMagnifyMsg\n | SpatialMagnifyEndMsg\n | SpatialRotateMsg\n | SpatialRotateEndMsg\n | ObjectDestroyMsg,\n ) => {\n // console.log('SpatialEntityEvent', data)\n const { type } = data\n if (type === SpatialWebMsgType.objectdestroy) {\n this.isDestroyed = true\n }\n // tap\n else if (type === SpatialWebMsgType.spatialtap) {\n const evt = createSpatialEvent(SpatialWebMsgType.spatialtap, data.detail)\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragstart) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragstart,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdrag) {\n const evt = createSpatialEvent(SpatialWebMsgType.spatialdrag, data.detail)\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialdragend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialdragend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n // rotate\n else if (type === SpatialWebMsgType.spatialrotate) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotate,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialrotateend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialrotateend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n // magnify\n else if (type === SpatialWebMsgType.spatialmagnify) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnify,\n data.detail,\n )\n this.dispatchEvent(evt)\n } else if (type === SpatialWebMsgType.spatialmagnifyend) {\n const evt = createSpatialEvent(\n SpatialWebMsgType.spatialmagnifyend,\n data.detail,\n )\n this.dispatchEvent(evt)\n }\n }\n\n dispatchEvent(evt: CustomEvent) {\n // Set origin once at the first dispatch in the bubbling chain\n if (!(evt as any).__origin) {\n Object.defineProperty(evt, '__origin', { value: this, enumerable: false })\n }\n this.events[evt.type]?.(evt)\n if (evt.bubbles && !evt.cancelBubble) {\n if (this.parent) {\n this.parent.dispatchEvent(evt)\n }\n }\n }\n\n protected onDestroy(): void {\n SpatialWebEvent.removeEventReceiver(this.id)\n // handle children\n this.children.forEach(child => {\n child.parent = null\n })\n this.children = []\n // handle parent\n if (this.parent) {\n this.parent.children = this.parent.children.filter(\n child => child.id !== this.id,\n )\n this.parent = null\n }\n }\n // onUpdate(properties: SpatialEntityProperties) {\n // this.position = properties.position\n // this.rotation = properties.rotation\n // this.scale = properties.scale\n // }\n async convertFromEntityToEntity(\n fromEntityId: string,\n toEntityId: string,\n position: Vec3,\n ) {\n return new ConvertFromEntityToEntityCommand(\n fromEntityId,\n toEntityId,\n position,\n ).execute()\n }\n\n async convertFromEntityToScene(fromEntityId: string, position: Vec3) {\n return new ConvertFromEntityToSceneCommand(fromEntityId, position).execute()\n }\n async convertFromSceneToEntity(entityId: string, position: Vec3) {\n return new ConvertFromSceneToEntityCommand(entityId, position).execute()\n }\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAaP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAG9B,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAC7B;AAAA,EAUE;AAAA,OAIK;AAEA,MAAM,sBAAsB,cAAc;AAAA,EAiC/C,YACE,IACO,UACP;AACA,UAAM,EAAE;AAFD;AAGP,oBAAgB,iBAAiB,IAAI,KAAK,cAAc;AAAA,EAC1D;AAAA,EAtCA,WAAiB,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAAA,EACpC,WAAiB,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAAA,EACpC,QAAc,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EAAE;AAAA,EAEjC,SAA8C,CAAC;AAAA,EAC/C,WAA4B,CAAC;AAAA,EAC7B,SAAwC;AAAA,EAChC,eAAwB;AAAA,EAEhC,IAAI,cAAuB;AACzB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,YAAY,OAAgB;AAQ9B,QAAI,KAAK,iBAAiB,MAAO;AACjC,SAAK,eAAe;AACpB,SAAK,KAAK,kBAAkB,cAAc,KAAK,EAAE,MAAM,SAAO;AAC5D,cAAQ,MAAM,wCAAwC,cAAc,GAAG;AAGvE,UAAI,KAAK,iBAAiB,OAAO;AAC/B,aAAK,eAAe,CAAC;AAAA,MACvB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EASA,MAAM,aA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C;AAAA,IAC3E;AACA,SAAK,OAAO,IAAI,IAAI,IAAI,GAAG;AAC3B,QAAI,IAAI,WAAW,CAAC,IAAI,cAAc;AACpC,UAAI,KAAK,QAAQ;AACf,aAAK,OAAO,cAAc,GAAG;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AAAA,EAEU,YAAkB;AAC1B,oBAAgB,oBAAoB,KAAK,EAAE;AAE3C,SAAK,SAAS,QAAQ,WAAS;AAC7B,YAAM,SAAS;AAAA,IACjB,CAAC;AACD,SAAK,WAAW,CAAC;AAEjB,QAAI,KAAK,QAAQ;AACf,WAAK,OAAO,WAAW,KAAK,OAAO,SAAS;AAAA,QAC1C,WAAS,MAAM,OAAO,KAAK;AAAA,MAC7B;AACA,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,0BACJ,cACA,YACA,UACA;AACA,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,QAAQ;AAAA,EACZ;AAAA,EAEA,MAAM,yBAAyB,cAAsB,UAAgB;AACnE,WAAO,IAAI,gCAAgC,cAAc,QAAQ,EAAE,QAAQ;AAAA,EAC7E;AAAA,EACA,MAAM,yBAAyB,UAAkB,UAAgB;AAC/D,WAAO,IAAI,gCAAgC,UAAU,QAAQ,EAAE,QAAQ;AAAA,EACzE;AACF;","names":[]}
@@ -0,0 +1,17 @@
1
+ import { H as SpatialEntity, _ as SpatialModelEntityCreationOptions, L as SpatialEntityUserData, X as SpatialMaterial, aK as CommandResult } from '../../spatializedElementMotion-_0XWPQCE.js';
2
+ import '../../types/motion/spatializedVisual.js';
3
+ import '../../types/motion/spatializedPlayback.js';
4
+ import '../../types/global.js';
5
+ import '../../physicalMetrics-W5uZ5xKb.js';
6
+ import '../../SpatialObject.js';
7
+ import '../component/SpatialComponent.js';
8
+
9
+ declare class SpatialModelEntity extends SpatialEntity {
10
+ id: string;
11
+ options?: SpatialModelEntityCreationOptions | undefined;
12
+ userData?: SpatialEntityUserData | undefined;
13
+ constructor(id: string, options?: SpatialModelEntityCreationOptions | undefined, userData?: SpatialEntityUserData | undefined);
14
+ setMaterials(materials: SpatialMaterial[]): Promise<CommandResult<any>>;
15
+ }
16
+
17
+ export { SpatialModelEntity };
@@ -0,0 +1,17 @@
1
+ import { SetMaterialsOnEntityCommand } from "../../JSBCommand";
2
+ import { SpatialEntity } from "./SpatialEntity";
3
+ class SpatialModelEntity extends SpatialEntity {
4
+ constructor(id, options, userData) {
5
+ super(id, userData);
6
+ this.id = id;
7
+ this.options = options;
8
+ this.userData = userData;
9
+ }
10
+ async setMaterials(materials) {
11
+ return new SetMaterialsOnEntityCommand(this.id, materials).execute();
12
+ }
13
+ }
14
+ export {
15
+ SpatialModelEntity
16
+ };
17
+ //# sourceMappingURL=SpatialModelEntity.js.map