@holoscript/engine 6.0.3 → 6.0.4

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 (192) hide show
  1. package/dist/AutoMesher-CK47F6AV.js +17 -0
  2. package/dist/GPUBuffers-2LHBCD7X.js +9 -0
  3. package/dist/WebGPUContext-TNEUYU2Y.js +11 -0
  4. package/dist/animation/index.cjs +38 -38
  5. package/dist/animation/index.d.cts +1 -1
  6. package/dist/animation/index.d.ts +1 -1
  7. package/dist/animation/index.js +1 -1
  8. package/dist/audio/index.cjs +16 -6
  9. package/dist/audio/index.d.cts +1 -1
  10. package/dist/audio/index.d.ts +1 -1
  11. package/dist/audio/index.js +1 -1
  12. package/dist/camera/index.cjs +23 -23
  13. package/dist/camera/index.d.cts +1 -1
  14. package/dist/camera/index.d.ts +1 -1
  15. package/dist/camera/index.js +1 -1
  16. package/dist/character/index.cjs +6 -4
  17. package/dist/character/index.js +1 -1
  18. package/dist/choreography/index.cjs +1194 -0
  19. package/dist/choreography/index.d.cts +687 -0
  20. package/dist/choreography/index.d.ts +687 -0
  21. package/dist/choreography/index.js +1156 -0
  22. package/dist/chunk-2CSNRI2N.js +217 -0
  23. package/dist/chunk-33T2WINR.js +266 -0
  24. package/dist/chunk-35R73OFM.js +1257 -0
  25. package/dist/chunk-4MMDSUNP.js +1256 -0
  26. package/dist/chunk-5V6HOU72.js +319 -0
  27. package/dist/chunk-6QOP6PYF.js +1038 -0
  28. package/dist/chunk-7KMJVHIL.js +8944 -0
  29. package/dist/chunk-7VPUC62U.js +1106 -0
  30. package/dist/chunk-A2Y6RCAT.js +1878 -0
  31. package/dist/chunk-AHM42MK6.js +8944 -0
  32. package/dist/chunk-BL7IDTHE.js +218 -0
  33. package/dist/chunk-CITOMSWL.js +10462 -0
  34. package/dist/chunk-CXDPKW2K.js +8944 -0
  35. package/dist/chunk-CXZPLD4S.js +223 -0
  36. package/dist/chunk-CZYJE7IH.js +5169 -0
  37. package/dist/chunk-D2OP7YC7.js +6325 -0
  38. package/dist/chunk-EDRVQHUU.js +1544 -0
  39. package/dist/chunk-EJSLOOW2.js +3589 -0
  40. package/dist/chunk-F53SFGW5.js +1878 -0
  41. package/dist/chunk-HCFPELPY.js +919 -0
  42. package/dist/chunk-HNEE36PY.js +93 -0
  43. package/dist/chunk-HYXNV36F.js +1256 -0
  44. package/dist/chunk-IB7KHVFY.js +821 -0
  45. package/dist/chunk-IBBO7YYG.js +690 -0
  46. package/dist/chunk-ILIBGINU.js +5470 -0
  47. package/dist/chunk-IS4MHLKN.js +5479 -0
  48. package/dist/chunk-JT2PFKWD.js +5479 -0
  49. package/dist/chunk-K4CUB4NY.js +1038 -0
  50. package/dist/chunk-KATDQXRJ.js +10462 -0
  51. package/dist/chunk-KBQE6ZFJ.js +8944 -0
  52. package/dist/chunk-KBVD5K7E.js +560 -0
  53. package/dist/chunk-KCDPVQRY.js +4088 -0
  54. package/dist/chunk-KN4QJPKN.js +8944 -0
  55. package/dist/chunk-KWJ3ROSI.js +8944 -0
  56. package/dist/chunk-L45VF6DD.js +919 -0
  57. package/dist/chunk-LY4T37YK.js +307 -0
  58. package/dist/chunk-MDN5WZXA.js +1544 -0
  59. package/dist/chunk-MGCDP6VU.js +928 -0
  60. package/dist/chunk-NCX7X6G2.js +8681 -0
  61. package/dist/chunk-OF54BPVD.js +913 -0
  62. package/dist/chunk-OWSN2Q3Q.js +690 -0
  63. package/dist/chunk-PRRB5TTA.js +406 -0
  64. package/dist/chunk-PXWVQF76.js +4086 -0
  65. package/dist/chunk-PYCOIDT2.js +812 -0
  66. package/dist/chunk-PZCSADOV.js +928 -0
  67. package/dist/chunk-Q2XBVS2K.js +1038 -0
  68. package/dist/chunk-QDZRXWN5.js +1776 -0
  69. package/dist/chunk-RNWOZ6WQ.js +913 -0
  70. package/dist/chunk-ROLFT4CJ.js +1693 -0
  71. package/dist/chunk-SLTJRZ2N.js +266 -0
  72. package/dist/chunk-SRUS5XSU.js +4088 -0
  73. package/dist/chunk-TKCA3WZ5.js +5409 -0
  74. package/dist/chunk-TNRMXYI2.js +1650 -0
  75. package/dist/chunk-TQB3GJGM.js +9763 -0
  76. package/dist/chunk-TUFGXG6K.js +510 -0
  77. package/dist/chunk-U6KMTGQJ.js +632 -0
  78. package/dist/chunk-VMGJQST6.js +8681 -0
  79. package/dist/chunk-X4F4TCG4.js +5470 -0
  80. package/dist/chunk-ZIFROE75.js +1544 -0
  81. package/dist/chunk-ZIJQYHSQ.js +1204 -0
  82. package/dist/combat/index.cjs +4 -4
  83. package/dist/combat/index.d.cts +1 -1
  84. package/dist/combat/index.d.ts +1 -1
  85. package/dist/combat/index.js +1 -1
  86. package/dist/ecs/index.cjs +1 -1
  87. package/dist/ecs/index.js +1 -1
  88. package/dist/environment/index.cjs +14 -14
  89. package/dist/environment/index.d.cts +1 -1
  90. package/dist/environment/index.d.ts +1 -1
  91. package/dist/environment/index.js +1 -1
  92. package/dist/gpu/index.cjs +4810 -0
  93. package/dist/gpu/index.js +3714 -0
  94. package/dist/hologram/index.cjs +27 -1
  95. package/dist/hologram/index.js +1 -1
  96. package/dist/index-B2PIsAmR.d.cts +2180 -0
  97. package/dist/index-B2PIsAmR.d.ts +2180 -0
  98. package/dist/index-BHySEPX7.d.cts +2921 -0
  99. package/dist/index-BJV21zuy.d.cts +341 -0
  100. package/dist/index-BJV21zuy.d.ts +341 -0
  101. package/dist/index-BQutTphC.d.cts +790 -0
  102. package/dist/index-ByIq2XrS.d.cts +3910 -0
  103. package/dist/index-BysHjDSO.d.cts +224 -0
  104. package/dist/index-BysHjDSO.d.ts +224 -0
  105. package/dist/index-CKwAJGck.d.ts +455 -0
  106. package/dist/index-CUl3QstQ.d.cts +3006 -0
  107. package/dist/index-CUl3QstQ.d.ts +3006 -0
  108. package/dist/index-CmYtNiI-.d.cts +953 -0
  109. package/dist/index-CmYtNiI-.d.ts +953 -0
  110. package/dist/index-CnRzWxi_.d.cts +522 -0
  111. package/dist/index-CnRzWxi_.d.ts +522 -0
  112. package/dist/index-CwRWbSC7.d.ts +2921 -0
  113. package/dist/index-CxKIBstO.d.ts +790 -0
  114. package/dist/index-DJ6-R8vh.d.cts +455 -0
  115. package/dist/index-DQKisbcI.d.cts +4968 -0
  116. package/dist/index-DQKisbcI.d.ts +4968 -0
  117. package/dist/index-DRT2zJez.d.ts +3910 -0
  118. package/dist/index-DfNLiAka.d.cts +192 -0
  119. package/dist/index-DfNLiAka.d.ts +192 -0
  120. package/dist/index-nMvkoRm8.d.cts +405 -0
  121. package/dist/index-nMvkoRm8.d.ts +405 -0
  122. package/dist/index-s9yOFU37.d.cts +604 -0
  123. package/dist/index-s9yOFU37.d.ts +604 -0
  124. package/dist/index.cjs +22966 -6960
  125. package/dist/index.d.cts +864 -20
  126. package/dist/index.d.ts +864 -20
  127. package/dist/index.js +3062 -48
  128. package/dist/input/index.cjs +1 -1
  129. package/dist/input/index.js +1 -1
  130. package/dist/orbital/index.cjs +3 -3
  131. package/dist/orbital/index.d.cts +1 -1
  132. package/dist/orbital/index.d.ts +1 -1
  133. package/dist/orbital/index.js +1 -1
  134. package/dist/particles/index.cjs +16 -16
  135. package/dist/particles/index.d.cts +1 -1
  136. package/dist/particles/index.d.ts +1 -1
  137. package/dist/particles/index.js +1 -1
  138. package/dist/physics/index.cjs +2377 -21
  139. package/dist/physics/index.d.cts +1 -1
  140. package/dist/physics/index.d.ts +1 -1
  141. package/dist/physics/index.js +35 -1
  142. package/dist/postfx/index.cjs +3491 -0
  143. package/dist/postfx/index.js +93 -0
  144. package/dist/procedural/index.cjs +1 -1
  145. package/dist/procedural/index.js +1 -1
  146. package/dist/puppeteer-5VF6KDVO.js +52197 -0
  147. package/dist/puppeteer-IZVZ3SG4.js +52197 -0
  148. package/dist/rendering/index.cjs +33 -32
  149. package/dist/rendering/index.d.cts +1 -1
  150. package/dist/rendering/index.d.ts +1 -1
  151. package/dist/rendering/index.js +8 -6
  152. package/dist/runtime/index.cjs +23 -13
  153. package/dist/runtime/index.d.cts +1 -1
  154. package/dist/runtime/index.d.ts +1 -1
  155. package/dist/runtime/index.js +8 -6
  156. package/dist/runtime/protocols/index.cjs +349 -0
  157. package/dist/runtime/protocols/index.js +15 -0
  158. package/dist/scene/index.cjs +8 -8
  159. package/dist/scene/index.d.cts +1 -1
  160. package/dist/scene/index.d.ts +1 -1
  161. package/dist/scene/index.js +1 -1
  162. package/dist/shader/index.cjs +3087 -0
  163. package/dist/shader/index.js +3044 -0
  164. package/dist/simulation/index.cjs +10680 -0
  165. package/dist/simulation/index.d.cts +3 -0
  166. package/dist/simulation/index.d.ts +3 -0
  167. package/dist/simulation/index.js +307 -0
  168. package/dist/spatial/index.cjs +2443 -0
  169. package/dist/spatial/index.d.cts +1545 -0
  170. package/dist/spatial/index.d.ts +1545 -0
  171. package/dist/spatial/index.js +2400 -0
  172. package/dist/terrain/index.cjs +1 -1
  173. package/dist/terrain/index.d.cts +1 -1
  174. package/dist/terrain/index.d.ts +1 -1
  175. package/dist/terrain/index.js +1 -1
  176. package/dist/transformers.node-4NKAPD5U.js +45620 -0
  177. package/dist/vm/index.cjs +7 -8
  178. package/dist/vm/index.d.cts +1 -1
  179. package/dist/vm/index.d.ts +1 -1
  180. package/dist/vm/index.js +1 -1
  181. package/dist/vm-bridge/index.cjs +2 -2
  182. package/dist/vm-bridge/index.d.cts +2 -2
  183. package/dist/vm-bridge/index.d.ts +2 -2
  184. package/dist/vm-bridge/index.js +1 -1
  185. package/dist/vr/index.cjs +6 -6
  186. package/dist/vr/index.js +1 -1
  187. package/dist/world/index.cjs +3 -3
  188. package/dist/world/index.d.cts +1 -1
  189. package/dist/world/index.d.ts +1 -1
  190. package/dist/world/index.js +1 -1
  191. package/package.json +53 -21
  192. package/LICENSE +0 -21
@@ -0,0 +1,319 @@
1
+ // src/runtime/protocols/MQTTClient.ts
2
+ var MQTTClient = class _MQTTClient {
3
+ config;
4
+ state = "disconnected";
5
+ subscriptions = /* @__PURE__ */ new Map();
6
+ messageQueue = [];
7
+ reconnectAttempts = 0;
8
+ reconnectTimeout = null;
9
+ eventHandlers = /* @__PURE__ */ new Map();
10
+ // Simulated connection for environments without real MQTT
11
+ simulatedMode = false;
12
+ constructor(config) {
13
+ this.config = {
14
+ version: "5.0",
15
+ keepAlive: 60,
16
+ cleanSession: true,
17
+ reconnect: {
18
+ enabled: true,
19
+ maxAttempts: 10,
20
+ baseDelay: 1e3,
21
+ maxDelay: 3e4
22
+ },
23
+ ...config,
24
+ clientId: config.clientId || this.generateClientId()
25
+ };
26
+ }
27
+ // ===========================================================================
28
+ // CONNECTION MANAGEMENT
29
+ // ===========================================================================
30
+ /**
31
+ * Connect to the MQTT broker
32
+ */
33
+ async connect() {
34
+ if (this.state === "connected" || this.state === "connecting") {
35
+ return;
36
+ }
37
+ this.state = "connecting";
38
+ this.emit("connect");
39
+ try {
40
+ await this.simulateConnect();
41
+ this.state = "connected";
42
+ this.reconnectAttempts = 0;
43
+ this.flushMessageQueue();
44
+ } catch (error) {
45
+ this.state = "disconnected";
46
+ this.emit("error", error);
47
+ if (this.config.reconnect?.enabled) {
48
+ this.scheduleReconnect();
49
+ }
50
+ throw error;
51
+ }
52
+ }
53
+ /**
54
+ * Disconnect from the MQTT broker
55
+ */
56
+ async disconnect() {
57
+ if (this.state === "disconnected" || this.state === "closed") {
58
+ return;
59
+ }
60
+ if (this.reconnectTimeout) {
61
+ clearTimeout(this.reconnectTimeout);
62
+ this.reconnectTimeout = null;
63
+ }
64
+ this.state = "closed";
65
+ this.emit("disconnect", "client_disconnect");
66
+ this.subscriptions.clear();
67
+ }
68
+ /**
69
+ * Get current connection state
70
+ */
71
+ getState() {
72
+ return this.state;
73
+ }
74
+ /**
75
+ * Check if connected
76
+ */
77
+ isConnected() {
78
+ return this.state === "connected";
79
+ }
80
+ // ===========================================================================
81
+ // PUBLISH / SUBSCRIBE
82
+ // ===========================================================================
83
+ /**
84
+ * Publish a message to a topic
85
+ */
86
+ async publish(topic, payload, options = {}) {
87
+ const { qos = 0, retain = false, properties } = options;
88
+ const serializedPayload = typeof payload === "object" && !(payload instanceof Buffer) ? JSON.stringify(payload) : payload;
89
+ if (this.state !== "connected") {
90
+ this.messageQueue.push({ topic, payload: serializedPayload, options });
91
+ return;
92
+ }
93
+ await this.simulatePublish(topic, serializedPayload, { qos, retain, properties });
94
+ }
95
+ /**
96
+ * Subscribe to a topic pattern
97
+ */
98
+ async subscribe(topicOrSubscription, handler) {
99
+ const subscription = typeof topicOrSubscription === "string" ? { topic: topicOrSubscription, qos: 0 } : topicOrSubscription;
100
+ const { topic } = subscription;
101
+ if (!this.subscriptions.has(topic)) {
102
+ this.subscriptions.set(topic, /* @__PURE__ */ new Set());
103
+ }
104
+ this.subscriptions.get(topic).add(handler);
105
+ if (this.state === "connected") {
106
+ await this.simulateSubscribe(subscription);
107
+ }
108
+ }
109
+ /**
110
+ * Unsubscribe from a topic
111
+ */
112
+ async unsubscribe(topic, handler) {
113
+ const handlers = this.subscriptions.get(topic);
114
+ if (!handlers) return;
115
+ if (handler) {
116
+ handlers.delete(handler);
117
+ if (handlers.size === 0) {
118
+ this.subscriptions.delete(topic);
119
+ }
120
+ } else {
121
+ this.subscriptions.delete(topic);
122
+ }
123
+ if (this.state === "connected" && !this.subscriptions.has(topic)) {
124
+ await this.simulateUnsubscribe(topic);
125
+ }
126
+ }
127
+ /**
128
+ * Get active subscriptions
129
+ */
130
+ getSubscriptions() {
131
+ return Array.from(this.subscriptions.keys());
132
+ }
133
+ // ===========================================================================
134
+ // EVENT HANDLING
135
+ // ===========================================================================
136
+ /**
137
+ * Register an event handler
138
+ */
139
+ on(event, handler) {
140
+ if (!this.eventHandlers.has(event)) {
141
+ this.eventHandlers.set(event, /* @__PURE__ */ new Set());
142
+ }
143
+ this.eventHandlers.get(event).add(handler);
144
+ }
145
+ /**
146
+ * Remove an event handler
147
+ */
148
+ off(event, handler) {
149
+ this.eventHandlers.get(event)?.delete(handler);
150
+ }
151
+ /**
152
+ * Emit an event
153
+ */
154
+ emit(event, ...args) {
155
+ const handlers = this.eventHandlers.get(event);
156
+ if (handlers) {
157
+ for (const handler of handlers) {
158
+ try {
159
+ handler(...args);
160
+ } catch (error) {
161
+ console.error(`Error in MQTT event handler for ${event}:`, error);
162
+ }
163
+ }
164
+ }
165
+ }
166
+ // ===========================================================================
167
+ // TOPIC MATCHING
168
+ // ===========================================================================
169
+ /**
170
+ * Check if a topic matches a subscription pattern
171
+ * Supports + (single-level) and # (multi-level) wildcards
172
+ */
173
+ static matchTopic(pattern, topic) {
174
+ const patternParts = pattern.split("/");
175
+ const topicParts = topic.split("/");
176
+ for (let i = 0; i < patternParts.length; i++) {
177
+ const patternPart = patternParts[i];
178
+ if (patternPart === "#") {
179
+ return true;
180
+ }
181
+ if (i >= topicParts.length) {
182
+ return false;
183
+ }
184
+ if (patternPart !== "+" && patternPart !== topicParts[i]) {
185
+ return false;
186
+ }
187
+ }
188
+ return patternParts.length === topicParts.length;
189
+ }
190
+ // ===========================================================================
191
+ // MESSAGE PARSING
192
+ // ===========================================================================
193
+ /**
194
+ * Parse message payload based on content type
195
+ */
196
+ static parsePayload(message) {
197
+ const contentType = message.properties?.contentType || "";
198
+ const payloadStr = message.payload instanceof Buffer ? message.payload.toString("utf-8") : String(message.payload);
199
+ if (contentType.includes("json") || payloadStr.startsWith("{") || payloadStr.startsWith("[")) {
200
+ try {
201
+ return JSON.parse(payloadStr);
202
+ } catch {
203
+ return payloadStr;
204
+ }
205
+ }
206
+ const num = Number(payloadStr);
207
+ if (!isNaN(num)) {
208
+ return num;
209
+ }
210
+ return payloadStr;
211
+ }
212
+ // ===========================================================================
213
+ // PRIVATE METHODS
214
+ // ===========================================================================
215
+ generateClientId() {
216
+ const timestamp = Date.now().toString(36);
217
+ const random = Math.random().toString(36).substring(2, 8);
218
+ return `holoscript_${timestamp}_${random}`;
219
+ }
220
+ async simulateConnect() {
221
+ this.simulatedMode = true;
222
+ await new Promise((resolve) => setTimeout(resolve, 100));
223
+ }
224
+ async simulatePublish(topic, payload, options) {
225
+ const message = {
226
+ topic,
227
+ payload,
228
+ qos: options.qos || 0,
229
+ retain: options.retain || false,
230
+ properties: options.properties
231
+ };
232
+ this.deliverMessage(topic, message);
233
+ }
234
+ async simulateSubscribe(_subscription) {
235
+ }
236
+ async simulateUnsubscribe(_topic) {
237
+ }
238
+ deliverMessage(topic, message) {
239
+ for (const [pattern, handlers] of this.subscriptions) {
240
+ if (_MQTTClient.matchTopic(pattern, topic)) {
241
+ for (const handler of handlers) {
242
+ try {
243
+ handler(message);
244
+ } catch (error) {
245
+ console.error("Error in MQTT message handler:", error);
246
+ }
247
+ }
248
+ }
249
+ }
250
+ this.emit("message", topic, message);
251
+ }
252
+ scheduleReconnect() {
253
+ const config = this.config.reconnect;
254
+ if (this.reconnectAttempts >= (config.maxAttempts || 10)) {
255
+ this.state = "disconnected";
256
+ this.emit("error", new Error("Max reconnect attempts reached"));
257
+ return;
258
+ }
259
+ this.state = "reconnecting";
260
+ this.reconnectAttempts++;
261
+ const delay = Math.min(
262
+ (config.baseDelay || 1e3) * Math.pow(2, this.reconnectAttempts - 1),
263
+ config.maxDelay || 3e4
264
+ );
265
+ this.emit("reconnect", this.reconnectAttempts);
266
+ this.reconnectTimeout = setTimeout(async () => {
267
+ try {
268
+ await this.connect();
269
+ } catch {
270
+ }
271
+ }, delay);
272
+ }
273
+ flushMessageQueue() {
274
+ while (this.messageQueue.length > 0) {
275
+ const { topic, payload, options } = this.messageQueue.shift();
276
+ this.publish(topic, payload, options).catch((error) => {
277
+ console.error("Error publishing queued message:", error);
278
+ });
279
+ }
280
+ }
281
+ /**
282
+ * Inject a message for testing purposes
283
+ */
284
+ _injectMessage(topic, payload) {
285
+ const serializedPayload = typeof payload === "object" && !(payload instanceof Buffer) ? JSON.stringify(payload) : payload;
286
+ const message = {
287
+ topic,
288
+ payload: serializedPayload,
289
+ qos: 0,
290
+ retain: false
291
+ };
292
+ this.deliverMessage(topic, message);
293
+ }
294
+ };
295
+ function createMQTTClient(config) {
296
+ return new MQTTClient(config);
297
+ }
298
+ var clientRegistry = /* @__PURE__ */ new Map();
299
+ function registerMQTTClient(name, client) {
300
+ clientRegistry.set(name, client);
301
+ }
302
+ function getMQTTClient(name) {
303
+ return clientRegistry.get(name);
304
+ }
305
+ function unregisterMQTTClient(name) {
306
+ const client = clientRegistry.get(name);
307
+ if (client) {
308
+ client.disconnect();
309
+ clientRegistry.delete(name);
310
+ }
311
+ }
312
+
313
+ export {
314
+ MQTTClient,
315
+ createMQTTClient,
316
+ registerMQTTClient,
317
+ getMQTTClient,
318
+ unregisterMQTTClient
319
+ };