kitchen-simulator 6.0.2-react.18 → 6.0.3-react.18
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/es/index.js +393 -78
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -6,12 +6,12 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
|
6
6
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
7
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
8
8
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
9
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
11
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
10
12
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
13
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
14
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
13
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
14
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
15
15
|
// kitchen-simulator/index.js (or wherever renderKitchenSimulator lives)
|
|
16
16
|
import React from 'react';
|
|
17
17
|
import { createRoot } from 'react-dom/client';
|
|
@@ -81,10 +81,325 @@ Three.TextureLoader.prototype.load = function (url, onLoad, onProgress, onError)
|
|
|
81
81
|
return originalTextureLoad.call(this, newUrl, onLoad, onProgress, onError);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Track 3D asset network activity (gltf/glb/bin/textures/hdr/etc)
|
|
86
|
+
* Ref-counted global install so multiple instances don't clobber each other.
|
|
87
|
+
*/
|
|
88
|
+
function installGltfTracker() {
|
|
89
|
+
if (typeof window === 'undefined') {
|
|
90
|
+
var _subscribe = function _subscribe() {
|
|
91
|
+
return function () {};
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
getInFlight: function getInFlight() {
|
|
95
|
+
return 0;
|
|
96
|
+
},
|
|
97
|
+
waitForIdle: function () {
|
|
98
|
+
var _waitForIdle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
99
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
100
|
+
while (1) switch (_context.prev = _context.next) {
|
|
101
|
+
case 0:
|
|
102
|
+
return _context.abrupt("return", true);
|
|
103
|
+
case 1:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context.stop();
|
|
106
|
+
}
|
|
107
|
+
}, _callee);
|
|
108
|
+
}));
|
|
109
|
+
function waitForIdle() {
|
|
110
|
+
return _waitForIdle.apply(this, arguments);
|
|
111
|
+
}
|
|
112
|
+
return waitForIdle;
|
|
113
|
+
}(),
|
|
114
|
+
uninstall: function uninstall() {},
|
|
115
|
+
subscribe: _subscribe
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
var GLOBAL_KEY = '__kitchenSimulatorGltfTracker__';
|
|
119
|
+
if (!window[GLOBAL_KEY]) {
|
|
120
|
+
window[GLOBAL_KEY] = {
|
|
121
|
+
refCount: 0,
|
|
122
|
+
inFlight: 0,
|
|
123
|
+
listeners: new Set(),
|
|
124
|
+
installed: false,
|
|
125
|
+
originalFetch: null,
|
|
126
|
+
originalOpen: null,
|
|
127
|
+
originalSend: null
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
var g = window[GLOBAL_KEY];
|
|
131
|
+
var is3dAssetUrl = function is3dAssetUrl(url) {
|
|
132
|
+
try {
|
|
133
|
+
var _url$toString, _url$toString2;
|
|
134
|
+
var s = typeof url === 'string' ? url : (_url$toString = url === null || url === void 0 || (_url$toString2 = url.toString) === null || _url$toString2 === void 0 ? void 0 : _url$toString2.call(url)) !== null && _url$toString !== void 0 ? _url$toString : '';
|
|
135
|
+
var u = s.toLowerCase().split('?')[0]; // ignore cache params
|
|
136
|
+
return u.endsWith('.gltf') || u.endsWith('.glb') || u.endsWith('.bin') || u.endsWith('.ktx2') || u.endsWith('.hdr') || u.endsWith('.exr') || u.endsWith('.png') || u.endsWith('.jpg') || u.endsWith('.jpeg') || u.endsWith('.webp');
|
|
137
|
+
} catch (_unused2) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var notify = function notify() {
|
|
142
|
+
var _iterator = _createForOfIteratorHelper(g.listeners),
|
|
143
|
+
_step;
|
|
144
|
+
try {
|
|
145
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
146
|
+
var fn = _step.value;
|
|
147
|
+
fn(g.inFlight);
|
|
148
|
+
}
|
|
149
|
+
} catch (err) {
|
|
150
|
+
_iterator.e(err);
|
|
151
|
+
} finally {
|
|
152
|
+
_iterator.f();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
var subscribe = function subscribe(fn) {
|
|
156
|
+
g.listeners.add(fn);
|
|
157
|
+
fn(g.inFlight); // sync emit on subscribe
|
|
158
|
+
return function () {
|
|
159
|
+
return g.listeners["delete"](fn);
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
var installIfNeeded = function installIfNeeded() {
|
|
163
|
+
var _XHR$prototype, _XHR$prototype2;
|
|
164
|
+
if (g.installed) return;
|
|
165
|
+
|
|
166
|
+
// ---- XHR hook ----
|
|
167
|
+
var XHR = window.XMLHttpRequest;
|
|
168
|
+
if (XHR !== null && XHR !== void 0 && (_XHR$prototype = XHR.prototype) !== null && _XHR$prototype !== void 0 && _XHR$prototype.open && XHR !== null && XHR !== void 0 && (_XHR$prototype2 = XHR.prototype) !== null && _XHR$prototype2 !== void 0 && _XHR$prototype2.send) {
|
|
169
|
+
g.originalOpen = XHR.prototype.open;
|
|
170
|
+
g.originalSend = XHR.prototype.send;
|
|
171
|
+
XHR.prototype.open = function (method, url) {
|
|
172
|
+
var _g$originalOpen;
|
|
173
|
+
this.__is3dAssetRequest = is3dAssetUrl(url);
|
|
174
|
+
for (var _len4 = arguments.length, rest = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
|
175
|
+
rest[_key4 - 2] = arguments[_key4];
|
|
176
|
+
}
|
|
177
|
+
return (_g$originalOpen = g.originalOpen).call.apply(_g$originalOpen, [this, method, url].concat(rest));
|
|
178
|
+
};
|
|
179
|
+
XHR.prototype.send = function () {
|
|
180
|
+
var _this = this;
|
|
181
|
+
if (this.__is3dAssetRequest) {
|
|
182
|
+
g.inFlight += 1;
|
|
183
|
+
notify();
|
|
184
|
+
var _done = function done() {
|
|
185
|
+
g.inFlight -= 1;
|
|
186
|
+
if (g.inFlight < 0) g.inFlight = 0;
|
|
187
|
+
notify();
|
|
188
|
+
_this.removeEventListener('loadend', _done);
|
|
189
|
+
_this.removeEventListener('error', _done);
|
|
190
|
+
_this.removeEventListener('abort', _done);
|
|
191
|
+
_this.removeEventListener('timeout', _done);
|
|
192
|
+
};
|
|
193
|
+
this.addEventListener('loadend', _done);
|
|
194
|
+
this.addEventListener('error', _done);
|
|
195
|
+
this.addEventListener('abort', _done);
|
|
196
|
+
this.addEventListener('timeout', _done);
|
|
197
|
+
}
|
|
198
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
199
|
+
args[_key5] = arguments[_key5];
|
|
200
|
+
}
|
|
201
|
+
return g.originalSend.apply(this, args);
|
|
202
|
+
};
|
|
203
|
+
}
|
|
87
204
|
|
|
205
|
+
// ---- fetch hook ----
|
|
206
|
+
g.originalFetch = window.fetch;
|
|
207
|
+
if (typeof g.originalFetch === 'function') {
|
|
208
|
+
window.fetch = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
209
|
+
var _len6,
|
|
210
|
+
args,
|
|
211
|
+
_key6,
|
|
212
|
+
input,
|
|
213
|
+
init,
|
|
214
|
+
newUrl,
|
|
215
|
+
track,
|
|
216
|
+
_args2 = arguments;
|
|
217
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
218
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
219
|
+
case 0:
|
|
220
|
+
for (_len6 = _args2.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
221
|
+
args[_key6] = _args2[_key6];
|
|
222
|
+
}
|
|
223
|
+
input = args[0], init = args[1]; // DIY-714 [Temp Fix] Rewrite API URLs
|
|
224
|
+
if (typeof input === 'string') {
|
|
225
|
+
input = rewriteApiUrl(input);
|
|
226
|
+
} else if (input instanceof Request) {
|
|
227
|
+
newUrl = rewriteApiUrl(input.url);
|
|
228
|
+
input = new Request(newUrl, input);
|
|
229
|
+
}
|
|
230
|
+
track = is3dAssetUrl(input);
|
|
231
|
+
if (track) {
|
|
232
|
+
_context2.next = 1;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
return _context2.abrupt("return", g.originalFetch.call(this, input, init));
|
|
236
|
+
case 1:
|
|
237
|
+
g.inFlight += 1;
|
|
238
|
+
notify();
|
|
239
|
+
_context2.prev = 2;
|
|
240
|
+
_context2.next = 3;
|
|
241
|
+
return g.originalFetch.call(this, input, init);
|
|
242
|
+
case 3:
|
|
243
|
+
return _context2.abrupt("return", _context2.sent);
|
|
244
|
+
case 4:
|
|
245
|
+
_context2.prev = 4;
|
|
246
|
+
g.inFlight -= 1;
|
|
247
|
+
if (g.inFlight < 0) g.inFlight = 0;
|
|
248
|
+
notify();
|
|
249
|
+
return _context2.finish(4);
|
|
250
|
+
case 5:
|
|
251
|
+
case "end":
|
|
252
|
+
return _context2.stop();
|
|
253
|
+
}
|
|
254
|
+
}, _callee2, this, [[2,, 4, 5]]);
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
g.installed = true;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// “No grace” but stable: idle must remain idle for 2 RAF frames
|
|
261
|
+
function waitStableIdle2Frames() {
|
|
262
|
+
return _waitStableIdle2Frames.apply(this, arguments);
|
|
263
|
+
}
|
|
264
|
+
function _waitStableIdle2Frames() {
|
|
265
|
+
_waitStableIdle2Frames = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
266
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
267
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
268
|
+
case 0:
|
|
269
|
+
_context5.next = 1;
|
|
270
|
+
return nextFrame();
|
|
271
|
+
case 1:
|
|
272
|
+
if (!(g.inFlight !== 0)) {
|
|
273
|
+
_context5.next = 2;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
return _context5.abrupt("return", false);
|
|
277
|
+
case 2:
|
|
278
|
+
_context5.next = 3;
|
|
279
|
+
return nextFrame();
|
|
280
|
+
case 3:
|
|
281
|
+
return _context5.abrupt("return", g.inFlight === 0);
|
|
282
|
+
case 4:
|
|
283
|
+
case "end":
|
|
284
|
+
return _context5.stop();
|
|
285
|
+
}
|
|
286
|
+
}, _callee5);
|
|
287
|
+
}));
|
|
288
|
+
return _waitStableIdle2Frames.apply(this, arguments);
|
|
289
|
+
}
|
|
290
|
+
var waitForIdle = /*#__PURE__*/function () {
|
|
291
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
292
|
+
var _ref3,
|
|
293
|
+
_ref3$timeoutMs,
|
|
294
|
+
timeoutMs,
|
|
295
|
+
_args4 = arguments;
|
|
296
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
297
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
_ref3 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref3$timeoutMs = _ref3.timeoutMs, timeoutMs = _ref3$timeoutMs === void 0 ? 30000 : _ref3$timeoutMs;
|
|
300
|
+
_context4.next = 1;
|
|
301
|
+
return waitStableIdle2Frames();
|
|
302
|
+
case 1:
|
|
303
|
+
if (!_context4.sent) {
|
|
304
|
+
_context4.next = 2;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
return _context4.abrupt("return", true);
|
|
308
|
+
case 2:
|
|
309
|
+
return _context4.abrupt("return", new Promise(function (resolve, reject) {
|
|
310
|
+
var unsub = null;
|
|
311
|
+
var finished = false;
|
|
312
|
+
var finishOk = function finishOk() {
|
|
313
|
+
if (finished) return;
|
|
314
|
+
finished = true;
|
|
315
|
+
if (unsub) unsub();
|
|
316
|
+
clearTimeout(timer);
|
|
317
|
+
resolve(true);
|
|
318
|
+
};
|
|
319
|
+
var finishErr = function finishErr(err) {
|
|
320
|
+
if (finished) return;
|
|
321
|
+
finished = true;
|
|
322
|
+
if (unsub) unsub();
|
|
323
|
+
clearTimeout(timer);
|
|
324
|
+
reject(err);
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// ✅ Real timeout no matter what happens with inFlight changes
|
|
328
|
+
var timer = setTimeout(function () {
|
|
329
|
+
finishErr(new Error('3D assets did not become idle within timeout'));
|
|
330
|
+
}, timeoutMs);
|
|
331
|
+
var onChange = /*#__PURE__*/function () {
|
|
332
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(count) {
|
|
333
|
+
var stable;
|
|
334
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
335
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
336
|
+
case 0:
|
|
337
|
+
if (!finished) {
|
|
338
|
+
_context3.next = 1;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
return _context3.abrupt("return");
|
|
342
|
+
case 1:
|
|
343
|
+
if (!(count !== 0)) {
|
|
344
|
+
_context3.next = 2;
|
|
345
|
+
break;
|
|
346
|
+
}
|
|
347
|
+
return _context3.abrupt("return");
|
|
348
|
+
case 2:
|
|
349
|
+
_context3.next = 3;
|
|
350
|
+
return waitStableIdle2Frames();
|
|
351
|
+
case 3:
|
|
352
|
+
stable = _context3.sent;
|
|
353
|
+
if (stable) finishOk();
|
|
354
|
+
// else keep waiting
|
|
355
|
+
case 4:
|
|
356
|
+
case "end":
|
|
357
|
+
return _context3.stop();
|
|
358
|
+
}
|
|
359
|
+
}, _callee3);
|
|
360
|
+
}));
|
|
361
|
+
return function onChange(_x) {
|
|
362
|
+
return _ref4.apply(this, arguments);
|
|
363
|
+
};
|
|
364
|
+
}();
|
|
365
|
+
unsub = subscribe(onChange);
|
|
366
|
+
}));
|
|
367
|
+
case 3:
|
|
368
|
+
case "end":
|
|
369
|
+
return _context4.stop();
|
|
370
|
+
}
|
|
371
|
+
}, _callee4);
|
|
372
|
+
}));
|
|
373
|
+
return function waitForIdle() {
|
|
374
|
+
return _ref2.apply(this, arguments);
|
|
375
|
+
};
|
|
376
|
+
}();
|
|
377
|
+
var uninstall = function uninstall() {
|
|
378
|
+
var _XHR$prototype3, _XHR$prototype4;
|
|
379
|
+
g.refCount -= 1;
|
|
380
|
+
if (g.refCount > 0) return;
|
|
381
|
+
var XHR = window.XMLHttpRequest;
|
|
382
|
+
if (XHR !== null && XHR !== void 0 && (_XHR$prototype3 = XHR.prototype) !== null && _XHR$prototype3 !== void 0 && _XHR$prototype3.open && g.originalOpen) XHR.prototype.open = g.originalOpen;
|
|
383
|
+
if (XHR !== null && XHR !== void 0 && (_XHR$prototype4 = XHR.prototype) !== null && _XHR$prototype4 !== void 0 && _XHR$prototype4.send && g.originalSend) XHR.prototype.send = g.originalSend;
|
|
384
|
+
if (typeof g.originalFetch === 'function') window.fetch = g.originalFetch;
|
|
385
|
+
g.listeners.clear();
|
|
386
|
+
g.inFlight = 0;
|
|
387
|
+
g.installed = false;
|
|
388
|
+
g.originalFetch = null;
|
|
389
|
+
g.originalOpen = null;
|
|
390
|
+
g.originalSend = null;
|
|
391
|
+
};
|
|
392
|
+
g.refCount += 1;
|
|
393
|
+
installIfNeeded();
|
|
394
|
+
return {
|
|
395
|
+
getInFlight: function getInFlight() {
|
|
396
|
+
return g.inFlight;
|
|
397
|
+
},
|
|
398
|
+
waitForIdle: waitForIdle,
|
|
399
|
+
uninstall: uninstall,
|
|
400
|
+
subscribe: subscribe
|
|
401
|
+
};
|
|
402
|
+
}
|
|
88
403
|
export function renderKitchenSimulator(container) {
|
|
89
404
|
var _props$framesPerEvent, _props$waitForGltfIdl, _props$gltfTimeoutMs;
|
|
90
405
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -145,15 +460,15 @@ export function renderKitchenSimulator(container) {
|
|
|
145
460
|
return requestAnimationFrame(resolve);
|
|
146
461
|
});
|
|
147
462
|
}
|
|
148
|
-
function settle(
|
|
463
|
+
function settle(_x2) {
|
|
149
464
|
return _settle.apply(this, arguments);
|
|
150
465
|
}
|
|
151
466
|
function _settle() {
|
|
152
|
-
_settle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
467
|
+
_settle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(ev) {
|
|
153
468
|
var _ev$framesPerEvent, _ev$waitForGltfIdleAf, _ev$gltfTimeoutMs;
|
|
154
469
|
var frames, shouldWait, timeoutMs, i;
|
|
155
|
-
return _regeneratorRuntime.wrap(function (
|
|
156
|
-
while (1) switch (
|
|
470
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
471
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
157
472
|
case 0:
|
|
158
473
|
frames = (_ev$framesPerEvent = ev === null || ev === void 0 ? void 0 : ev.framesPerEvent) !== null && _ev$framesPerEvent !== void 0 ? _ev$framesPerEvent : defaultFramesPerEvent;
|
|
159
474
|
shouldWait = (_ev$waitForGltfIdleAf = ev === null || ev === void 0 ? void 0 : ev.waitForGltfIdleAfterEachEvent) !== null && _ev$waitForGltfIdleAf !== void 0 ? _ev$waitForGltfIdleAf : waitForAssets;
|
|
@@ -161,32 +476,32 @@ export function renderKitchenSimulator(container) {
|
|
|
161
476
|
i = 0;
|
|
162
477
|
case 1:
|
|
163
478
|
if (!(i < frames)) {
|
|
164
|
-
|
|
479
|
+
_context8.next = 3;
|
|
165
480
|
break;
|
|
166
481
|
}
|
|
167
|
-
|
|
482
|
+
_context8.next = 2;
|
|
168
483
|
return nextFrame();
|
|
169
484
|
case 2:
|
|
170
485
|
i++;
|
|
171
|
-
|
|
486
|
+
_context8.next = 1;
|
|
172
487
|
break;
|
|
173
488
|
case 3:
|
|
174
489
|
if (!shouldWait) {
|
|
175
|
-
|
|
490
|
+
_context8.next = 4;
|
|
176
491
|
break;
|
|
177
492
|
}
|
|
178
|
-
|
|
493
|
+
_context8.next = 4;
|
|
179
494
|
return gltfTracker.waitForIdle({
|
|
180
495
|
timeoutMs: timeoutMs
|
|
181
496
|
});
|
|
182
497
|
case 4:
|
|
183
|
-
|
|
498
|
+
_context8.next = 5;
|
|
184
499
|
return nextFrame();
|
|
185
500
|
case 5:
|
|
186
501
|
case "end":
|
|
187
|
-
return
|
|
502
|
+
return _context8.stop();
|
|
188
503
|
}
|
|
189
|
-
},
|
|
504
|
+
}, _callee8);
|
|
190
505
|
}));
|
|
191
506
|
return _settle.apply(this, arguments);
|
|
192
507
|
}
|
|
@@ -194,93 +509,93 @@ export function renderKitchenSimulator(container) {
|
|
|
194
509
|
return _drain.apply(this, arguments);
|
|
195
510
|
}
|
|
196
511
|
function _drain() {
|
|
197
|
-
_drain = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
512
|
+
_drain = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
|
|
198
513
|
var item, _err$message, _t;
|
|
199
|
-
return _regeneratorRuntime.wrap(function (
|
|
200
|
-
while (1) switch (
|
|
514
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
515
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
201
516
|
case 0:
|
|
202
517
|
if (!(draining || destroyed)) {
|
|
203
|
-
|
|
518
|
+
_context9.next = 1;
|
|
204
519
|
break;
|
|
205
520
|
}
|
|
206
|
-
return
|
|
521
|
+
return _context9.abrupt("return");
|
|
207
522
|
case 1:
|
|
208
523
|
draining = true;
|
|
209
|
-
|
|
210
|
-
|
|
524
|
+
_context9.prev = 2;
|
|
525
|
+
_context9.next = 3;
|
|
211
526
|
return readyPromise;
|
|
212
527
|
case 3:
|
|
213
528
|
if (!(!destroyed && queue.length)) {
|
|
214
|
-
|
|
529
|
+
_context9.next = 10;
|
|
215
530
|
break;
|
|
216
531
|
}
|
|
217
532
|
if (setExternalEventFn) {
|
|
218
|
-
|
|
533
|
+
_context9.next = 5;
|
|
219
534
|
break;
|
|
220
535
|
}
|
|
221
|
-
|
|
536
|
+
_context9.next = 4;
|
|
222
537
|
return nextFrame();
|
|
223
538
|
case 4:
|
|
224
|
-
return
|
|
539
|
+
return _context9.abrupt("continue", 3);
|
|
225
540
|
case 5:
|
|
226
541
|
item = queue.shift();
|
|
227
542
|
if (!(item && item.__marker === MARKER)) {
|
|
228
|
-
|
|
543
|
+
_context9.next = 6;
|
|
229
544
|
break;
|
|
230
545
|
}
|
|
231
546
|
pendingMarkers["delete"](item.token);
|
|
232
|
-
return
|
|
547
|
+
return _context9.abrupt("continue", 3);
|
|
233
548
|
case 6:
|
|
234
|
-
|
|
549
|
+
_context9.prev = 6;
|
|
235
550
|
setExternalEventFn(item);
|
|
236
|
-
|
|
551
|
+
_context9.next = 7;
|
|
237
552
|
return settle(item);
|
|
238
553
|
case 7:
|
|
239
|
-
|
|
554
|
+
_context9.next = 9;
|
|
240
555
|
break;
|
|
241
556
|
case 8:
|
|
242
|
-
|
|
243
|
-
_t =
|
|
557
|
+
_context9.prev = 8;
|
|
558
|
+
_t = _context9["catch"](6);
|
|
244
559
|
error('drain:event failed', {
|
|
245
560
|
err: (_err$message = _t === null || _t === void 0 ? void 0 : _t.message) !== null && _err$message !== void 0 ? _err$message : _t,
|
|
246
561
|
type: item === null || item === void 0 ? void 0 : item.type
|
|
247
562
|
});
|
|
248
563
|
case 9:
|
|
249
|
-
|
|
564
|
+
_context9.next = 3;
|
|
250
565
|
break;
|
|
251
566
|
case 10:
|
|
252
|
-
|
|
567
|
+
_context9.prev = 10;
|
|
253
568
|
draining = false;
|
|
254
|
-
return
|
|
569
|
+
return _context9.finish(10);
|
|
255
570
|
case 11:
|
|
256
571
|
case "end":
|
|
257
|
-
return
|
|
572
|
+
return _context9.stop();
|
|
258
573
|
}
|
|
259
|
-
},
|
|
574
|
+
}, _callee9, null, [[2,, 10, 11], [6, 8]]);
|
|
260
575
|
}));
|
|
261
576
|
return _drain.apply(this, arguments);
|
|
262
577
|
}
|
|
263
578
|
var Wrapper = /*#__PURE__*/function (_React$Component) {
|
|
264
579
|
function Wrapper(p) {
|
|
265
|
-
var
|
|
580
|
+
var _this2;
|
|
266
581
|
_classCallCheck(this, Wrapper);
|
|
267
|
-
|
|
268
|
-
|
|
582
|
+
_this2 = _callSuper(this, Wrapper, [p]);
|
|
583
|
+
_this2.state = {
|
|
269
584
|
externalEvent: p.externalEvent || null
|
|
270
585
|
};
|
|
271
|
-
|
|
272
|
-
return
|
|
586
|
+
_this2._mounted = false;
|
|
587
|
+
return _this2;
|
|
273
588
|
}
|
|
274
589
|
_inherits(Wrapper, _React$Component);
|
|
275
590
|
return _createClass(Wrapper, [{
|
|
276
591
|
key: "componentDidMount",
|
|
277
592
|
value: function componentDidMount() {
|
|
278
|
-
var
|
|
593
|
+
var _this3 = this;
|
|
279
594
|
this._mounted = true;
|
|
280
595
|
log('Wrapper mounted -> ready');
|
|
281
596
|
setExternalEventFn = function setExternalEventFn(newEvent) {
|
|
282
|
-
if (!
|
|
283
|
-
|
|
597
|
+
if (!_this3._mounted) return;
|
|
598
|
+
_this3.setState({
|
|
284
599
|
externalEvent: newEvent
|
|
285
600
|
});
|
|
286
601
|
};
|
|
@@ -306,9 +621,9 @@ export function renderKitchenSimulator(container) {
|
|
|
306
621
|
|
|
307
622
|
// ✅ Wrap internal event to detect catalog readiness
|
|
308
623
|
var onInternalEventWrapped = /*#__PURE__*/function () {
|
|
309
|
-
var
|
|
310
|
-
return _regeneratorRuntime.wrap(function (
|
|
311
|
-
while (1) switch (
|
|
624
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(evt, callback) {
|
|
625
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
626
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
312
627
|
case 0:
|
|
313
628
|
// IMPORTANT: first time we see INTERNAL_EVENT_ITEMS_CATALOG,
|
|
314
629
|
// it means catalog init path ran and tool is requesting items.
|
|
@@ -320,15 +635,15 @@ export function renderKitchenSimulator(container) {
|
|
|
320
635
|
}
|
|
321
636
|
log('Catalog is ready (observed INTERNAL_EVENT_ITEMS_CATALOG)');
|
|
322
637
|
}
|
|
323
|
-
return
|
|
638
|
+
return _context6.abrupt("return", userOnInternalEvent === null || userOnInternalEvent === void 0 ? void 0 : userOnInternalEvent(evt, callback));
|
|
324
639
|
case 1:
|
|
325
640
|
case "end":
|
|
326
|
-
return
|
|
641
|
+
return _context6.stop();
|
|
327
642
|
}
|
|
328
|
-
},
|
|
643
|
+
}, _callee6);
|
|
329
644
|
}));
|
|
330
|
-
return function onInternalEventWrapped(
|
|
331
|
-
return
|
|
645
|
+
return function onInternalEventWrapped(_x3, _x4) {
|
|
646
|
+
return _ref5.apply(this, arguments);
|
|
332
647
|
};
|
|
333
648
|
}();
|
|
334
649
|
return /*#__PURE__*/React.createElement(LiteRenderer, _extends({}, this.props, {
|
|
@@ -357,22 +672,22 @@ export function renderKitchenSimulator(container) {
|
|
|
357
672
|
return gltfTracker.subscribe(cb);
|
|
358
673
|
},
|
|
359
674
|
sendExternalEvents: function sendExternalEvents(eventOrEvents) {
|
|
360
|
-
var
|
|
361
|
-
|
|
362
|
-
timeoutMs =
|
|
675
|
+
var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
676
|
+
_ref6$timeoutMs = _ref6.timeoutMs,
|
|
677
|
+
timeoutMs = _ref6$timeoutMs === void 0 ? 60000 : _ref6$timeoutMs;
|
|
363
678
|
var events = Array.isArray(eventOrEvents) ? eventOrEvents : [eventOrEvents];
|
|
364
679
|
var token = Symbol('batch');
|
|
365
|
-
var
|
|
366
|
-
|
|
680
|
+
var _iterator2 = _createForOfIteratorHelper(events),
|
|
681
|
+
_step2;
|
|
367
682
|
try {
|
|
368
|
-
for (
|
|
369
|
-
var e =
|
|
683
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
684
|
+
var e = _step2.value;
|
|
370
685
|
queue.push(e);
|
|
371
686
|
}
|
|
372
687
|
} catch (err) {
|
|
373
|
-
|
|
688
|
+
_iterator2.e(err);
|
|
374
689
|
} finally {
|
|
375
|
-
|
|
690
|
+
_iterator2.f();
|
|
376
691
|
}
|
|
377
692
|
pendingMarkers.add(token);
|
|
378
693
|
queue.push({
|
|
@@ -383,23 +698,23 @@ export function renderKitchenSimulator(container) {
|
|
|
383
698
|
return new Promise(function (resolve) {
|
|
384
699
|
var start = Date.now();
|
|
385
700
|
var check = /*#__PURE__*/function () {
|
|
386
|
-
var
|
|
387
|
-
return _regeneratorRuntime.wrap(function (
|
|
388
|
-
while (1) switch (
|
|
701
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
702
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
703
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
389
704
|
case 0:
|
|
390
705
|
if (destroyed) {
|
|
391
|
-
|
|
706
|
+
_context7.next = 4;
|
|
392
707
|
break;
|
|
393
708
|
}
|
|
394
709
|
if (pendingMarkers.has(token)) {
|
|
395
|
-
|
|
710
|
+
_context7.next = 1;
|
|
396
711
|
break;
|
|
397
712
|
}
|
|
398
713
|
resolve(true);
|
|
399
|
-
return
|
|
714
|
+
return _context7.abrupt("return");
|
|
400
715
|
case 1:
|
|
401
716
|
if (!(Date.now() - start > timeoutMs)) {
|
|
402
|
-
|
|
717
|
+
_context7.next = 2;
|
|
403
718
|
break;
|
|
404
719
|
}
|
|
405
720
|
error('sendExternalEvents timed out', {
|
|
@@ -407,23 +722,23 @@ export function renderKitchenSimulator(container) {
|
|
|
407
722
|
});
|
|
408
723
|
pendingMarkers["delete"](token); // fail-open
|
|
409
724
|
resolve(false);
|
|
410
|
-
return
|
|
725
|
+
return _context7.abrupt("return");
|
|
411
726
|
case 2:
|
|
412
|
-
|
|
727
|
+
_context7.next = 3;
|
|
413
728
|
return nextFrame();
|
|
414
729
|
case 3:
|
|
415
|
-
|
|
730
|
+
_context7.next = 0;
|
|
416
731
|
break;
|
|
417
732
|
case 4:
|
|
418
733
|
resolve(false);
|
|
419
734
|
case 5:
|
|
420
735
|
case "end":
|
|
421
|
-
return
|
|
736
|
+
return _context7.stop();
|
|
422
737
|
}
|
|
423
|
-
},
|
|
738
|
+
}, _callee7);
|
|
424
739
|
}));
|
|
425
740
|
return function check() {
|
|
426
|
-
return
|
|
741
|
+
return _ref7.apply(this, arguments);
|
|
427
742
|
};
|
|
428
743
|
}();
|
|
429
744
|
check();
|