kitchen-simulator 3.12.0-test.3 → 3.12.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.
- package/es/index.js +5 -102
- package/lib/index.js +5 -102
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
@@ -6,8 +5,6 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
6
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
6
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
7
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
8
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
9
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
10
|
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; } } }; }
|
|
@@ -249,10 +246,10 @@ export function renderKitchenSimulator(container) {
|
|
|
249
246
|
|
|
250
247
|
// ✅ Reuse existing API for same container
|
|
251
248
|
if (container[API_KEY]) {
|
|
252
|
-
var
|
|
253
|
-
|
|
254
|
-
(
|
|
255
|
-
return
|
|
249
|
+
var _container$API_KEY$__, _container$API_KEY;
|
|
250
|
+
// update render with latest props (safe)
|
|
251
|
+
(_container$API_KEY$__ = (_container$API_KEY = container[API_KEY]).__render) === null || _container$API_KEY$__ === void 0 || _container$API_KEY$__.call(_container$API_KEY, props);
|
|
252
|
+
return container[API_KEY];
|
|
256
253
|
}
|
|
257
254
|
|
|
258
255
|
// ✅ Reuse root for same container
|
|
@@ -447,79 +444,10 @@ export function renderKitchenSimulator(container) {
|
|
|
447
444
|
}
|
|
448
445
|
}]);
|
|
449
446
|
}(React.Component);
|
|
450
|
-
var ro = null;
|
|
451
|
-
var roEl = null;
|
|
452
|
-
var roRaf = 0;
|
|
453
|
-
function installContentBoxObserver() {
|
|
454
|
-
var _lastProps$width2, _lastProps$height2;
|
|
455
|
-
if (typeof window === 'undefined') return;
|
|
456
|
-
if (typeof ResizeObserver === 'undefined') return;
|
|
457
|
-
var el = document.getElementById('content-box');
|
|
458
|
-
if (!el) return; // tool won't crash if element isn't there yet
|
|
459
|
-
|
|
460
|
-
roEl = el;
|
|
461
|
-
var syncFromEl = function syncFromEl(entry) {
|
|
462
|
-
var _lastProps$width, _lastProps$height;
|
|
463
|
-
// Prefer contentBoxSize when available; fallback to getBoundingClientRect.
|
|
464
|
-
var w = 0,
|
|
465
|
-
h = 0;
|
|
466
|
-
var cbs = entry === null || entry === void 0 ? void 0 : entry.contentBoxSize;
|
|
467
|
-
if (cbs) {
|
|
468
|
-
var _box$inlineSize, _box$blockSize;
|
|
469
|
-
// contentBoxSize can be array (Chrome) or single object (Firefox)
|
|
470
|
-
var box = Array.isArray(cbs) ? cbs[0] : cbs;
|
|
471
|
-
w = (_box$inlineSize = box === null || box === void 0 ? void 0 : box.inlineSize) !== null && _box$inlineSize !== void 0 ? _box$inlineSize : 0;
|
|
472
|
-
h = (_box$blockSize = box === null || box === void 0 ? void 0 : box.blockSize) !== null && _box$blockSize !== void 0 ? _box$blockSize : 0;
|
|
473
|
-
}
|
|
474
|
-
if (!w || !h) {
|
|
475
|
-
var _rect = roEl.getBoundingClientRect();
|
|
476
|
-
w = _rect.width;
|
|
477
|
-
h = _rect.height;
|
|
478
|
-
}
|
|
479
|
-
w = normalizeSize(w, (_lastProps$width = lastProps.width) !== null && _lastProps$width !== void 0 ? _lastProps$width : 1);
|
|
480
|
-
h = normalizeSize(h, (_lastProps$height = lastProps.height) !== null && _lastProps$height !== void 0 ? _lastProps$height : 1);
|
|
481
|
-
|
|
482
|
-
// avoid thrash: coalesce multiple observer callbacks into 1 RAF
|
|
483
|
-
if (roRaf) cancelAnimationFrame(roRaf);
|
|
484
|
-
roRaf = requestAnimationFrame(function () {
|
|
485
|
-
roRaf = 0;
|
|
486
|
-
if (destroyed) return;
|
|
487
|
-
// only update if changed (prevents infinite loops)
|
|
488
|
-
if (lastProps.width === w && lastProps.height === h) return;
|
|
489
|
-
// update props via existing render path
|
|
490
|
-
api.__render({
|
|
491
|
-
width: w,
|
|
492
|
-
height: h
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
};
|
|
496
|
-
ro = new ResizeObserver(function (entries) {
|
|
497
|
-
var entry = entries && entries[0];
|
|
498
|
-
if (!entry) return;
|
|
499
|
-
syncFromEl(entry);
|
|
500
|
-
});
|
|
501
|
-
ro.observe(el, {
|
|
502
|
-
box: 'content-box'
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
// initial sync (in case observer doesn't fire immediately)
|
|
506
|
-
var rect = el.getBoundingClientRect();
|
|
507
|
-
api.__render({
|
|
508
|
-
width: normalizeSize(rect.width, (_lastProps$width2 = lastProps.width) !== null && _lastProps$width2 !== void 0 ? _lastProps$width2 : 1),
|
|
509
|
-
height: normalizeSize(rect.height, (_lastProps$height2 = lastProps.height) !== null && _lastProps$height2 !== void 0 ? _lastProps$height2 : 1)
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
var lastProps = _objectSpread({}, props);
|
|
513
|
-
function normalizeSize(n) {
|
|
514
|
-
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
515
|
-
var v = typeof n === 'string' ? parseFloat(n) : n;
|
|
516
|
-
return Number.isFinite(v) && v > 0 ? v : fallback;
|
|
517
|
-
}
|
|
518
447
|
var api = {
|
|
519
448
|
// internal: rerender wrapper with latest props if host calls renderKitchenSimulator again
|
|
520
449
|
__render: function __render(nextProps) {
|
|
521
|
-
|
|
522
|
-
root.render(/*#__PURE__*/React.createElement(Wrapper, lastProps));
|
|
450
|
+
root.render(/*#__PURE__*/React.createElement(Wrapper, nextProps));
|
|
523
451
|
},
|
|
524
452
|
/**
|
|
525
453
|
* Send one or many events (in order).
|
|
@@ -603,17 +531,6 @@ export function renderKitchenSimulator(container) {
|
|
|
603
531
|
container[API_KEY] = null;
|
|
604
532
|
}
|
|
605
533
|
};
|
|
606
|
-
if (ro) {
|
|
607
|
-
try {
|
|
608
|
-
ro.disconnect();
|
|
609
|
-
} catch (_unused2) {}
|
|
610
|
-
ro = null;
|
|
611
|
-
}
|
|
612
|
-
roEl = null;
|
|
613
|
-
if (roRaf) {
|
|
614
|
-
cancelAnimationFrame(roRaf);
|
|
615
|
-
roRaf = 0;
|
|
616
|
-
}
|
|
617
534
|
|
|
618
535
|
// Prefer microtask when available, otherwise macrotask
|
|
619
536
|
if (typeof queueMicrotask === 'function') queueMicrotask(doUnmount);else setTimeout(doUnmount, 0);
|
|
@@ -623,20 +540,6 @@ export function renderKitchenSimulator(container) {
|
|
|
623
540
|
// first render
|
|
624
541
|
api.__render(props);
|
|
625
542
|
|
|
626
|
-
// Install observer after initial mount.
|
|
627
|
-
// If #content-box is created later, retry a few frames.
|
|
628
|
-
(function tryInstall() {
|
|
629
|
-
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
630
|
-
if (destroyed) return;
|
|
631
|
-
installContentBoxObserver();
|
|
632
|
-
if (!ro && attempt < 30) {
|
|
633
|
-
// element not found yet; retry next frame for up to ~30 frames
|
|
634
|
-
requestAnimationFrame(function () {
|
|
635
|
-
return tryInstall(attempt + 1);
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
})();
|
|
639
|
-
|
|
640
543
|
// store api on container so repeated calls reuse it
|
|
641
544
|
container[API_KEY] = api;
|
|
642
545
|
return api;
|
package/lib/index.js
CHANGED
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
exports.renderKitchenSimulator = renderKitchenSimulator;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -18,8 +17,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
18
17
|
var _react = _interopRequireDefault(require("react"));
|
|
19
18
|
var _LiteRenderer = _interopRequireDefault(require("./LiteRenderer"));
|
|
20
19
|
var _client = require("react-dom/client");
|
|
21
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
20
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
24
21
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
25
22
|
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; } } }; }
|
|
@@ -257,10 +254,10 @@ function renderKitchenSimulator(container) {
|
|
|
257
254
|
|
|
258
255
|
// ✅ Reuse existing API for same container
|
|
259
256
|
if (container[API_KEY]) {
|
|
260
|
-
var
|
|
261
|
-
|
|
262
|
-
(
|
|
263
|
-
return
|
|
257
|
+
var _container$API_KEY$__, _container$API_KEY;
|
|
258
|
+
// update render with latest props (safe)
|
|
259
|
+
(_container$API_KEY$__ = (_container$API_KEY = container[API_KEY]).__render) === null || _container$API_KEY$__ === void 0 || _container$API_KEY$__.call(_container$API_KEY, props);
|
|
260
|
+
return container[API_KEY];
|
|
264
261
|
}
|
|
265
262
|
|
|
266
263
|
// ✅ Reuse root for same container
|
|
@@ -455,79 +452,10 @@ function renderKitchenSimulator(container) {
|
|
|
455
452
|
}
|
|
456
453
|
}]);
|
|
457
454
|
}(_react["default"].Component);
|
|
458
|
-
var ro = null;
|
|
459
|
-
var roEl = null;
|
|
460
|
-
var roRaf = 0;
|
|
461
|
-
function installContentBoxObserver() {
|
|
462
|
-
var _lastProps$width2, _lastProps$height2;
|
|
463
|
-
if (typeof window === 'undefined') return;
|
|
464
|
-
if (typeof ResizeObserver === 'undefined') return;
|
|
465
|
-
var el = document.getElementById('content-box');
|
|
466
|
-
if (!el) return; // tool won't crash if element isn't there yet
|
|
467
|
-
|
|
468
|
-
roEl = el;
|
|
469
|
-
var syncFromEl = function syncFromEl(entry) {
|
|
470
|
-
var _lastProps$width, _lastProps$height;
|
|
471
|
-
// Prefer contentBoxSize when available; fallback to getBoundingClientRect.
|
|
472
|
-
var w = 0,
|
|
473
|
-
h = 0;
|
|
474
|
-
var cbs = entry === null || entry === void 0 ? void 0 : entry.contentBoxSize;
|
|
475
|
-
if (cbs) {
|
|
476
|
-
var _box$inlineSize, _box$blockSize;
|
|
477
|
-
// contentBoxSize can be array (Chrome) or single object (Firefox)
|
|
478
|
-
var box = Array.isArray(cbs) ? cbs[0] : cbs;
|
|
479
|
-
w = (_box$inlineSize = box === null || box === void 0 ? void 0 : box.inlineSize) !== null && _box$inlineSize !== void 0 ? _box$inlineSize : 0;
|
|
480
|
-
h = (_box$blockSize = box === null || box === void 0 ? void 0 : box.blockSize) !== null && _box$blockSize !== void 0 ? _box$blockSize : 0;
|
|
481
|
-
}
|
|
482
|
-
if (!w || !h) {
|
|
483
|
-
var _rect = roEl.getBoundingClientRect();
|
|
484
|
-
w = _rect.width;
|
|
485
|
-
h = _rect.height;
|
|
486
|
-
}
|
|
487
|
-
w = normalizeSize(w, (_lastProps$width = lastProps.width) !== null && _lastProps$width !== void 0 ? _lastProps$width : 1);
|
|
488
|
-
h = normalizeSize(h, (_lastProps$height = lastProps.height) !== null && _lastProps$height !== void 0 ? _lastProps$height : 1);
|
|
489
|
-
|
|
490
|
-
// avoid thrash: coalesce multiple observer callbacks into 1 RAF
|
|
491
|
-
if (roRaf) cancelAnimationFrame(roRaf);
|
|
492
|
-
roRaf = requestAnimationFrame(function () {
|
|
493
|
-
roRaf = 0;
|
|
494
|
-
if (destroyed) return;
|
|
495
|
-
// only update if changed (prevents infinite loops)
|
|
496
|
-
if (lastProps.width === w && lastProps.height === h) return;
|
|
497
|
-
// update props via existing render path
|
|
498
|
-
api.__render({
|
|
499
|
-
width: w,
|
|
500
|
-
height: h
|
|
501
|
-
});
|
|
502
|
-
});
|
|
503
|
-
};
|
|
504
|
-
ro = new ResizeObserver(function (entries) {
|
|
505
|
-
var entry = entries && entries[0];
|
|
506
|
-
if (!entry) return;
|
|
507
|
-
syncFromEl(entry);
|
|
508
|
-
});
|
|
509
|
-
ro.observe(el, {
|
|
510
|
-
box: 'content-box'
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
// initial sync (in case observer doesn't fire immediately)
|
|
514
|
-
var rect = el.getBoundingClientRect();
|
|
515
|
-
api.__render({
|
|
516
|
-
width: normalizeSize(rect.width, (_lastProps$width2 = lastProps.width) !== null && _lastProps$width2 !== void 0 ? _lastProps$width2 : 1),
|
|
517
|
-
height: normalizeSize(rect.height, (_lastProps$height2 = lastProps.height) !== null && _lastProps$height2 !== void 0 ? _lastProps$height2 : 1)
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
var lastProps = _objectSpread({}, props);
|
|
521
|
-
function normalizeSize(n) {
|
|
522
|
-
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
523
|
-
var v = typeof n === 'string' ? parseFloat(n) : n;
|
|
524
|
-
return Number.isFinite(v) && v > 0 ? v : fallback;
|
|
525
|
-
}
|
|
526
455
|
var api = {
|
|
527
456
|
// internal: rerender wrapper with latest props if host calls renderKitchenSimulator again
|
|
528
457
|
__render: function __render(nextProps) {
|
|
529
|
-
|
|
530
|
-
root.render(/*#__PURE__*/_react["default"].createElement(Wrapper, lastProps));
|
|
458
|
+
root.render(/*#__PURE__*/_react["default"].createElement(Wrapper, nextProps));
|
|
531
459
|
},
|
|
532
460
|
/**
|
|
533
461
|
* Send one or many events (in order).
|
|
@@ -611,17 +539,6 @@ function renderKitchenSimulator(container) {
|
|
|
611
539
|
container[API_KEY] = null;
|
|
612
540
|
}
|
|
613
541
|
};
|
|
614
|
-
if (ro) {
|
|
615
|
-
try {
|
|
616
|
-
ro.disconnect();
|
|
617
|
-
} catch (_unused2) {}
|
|
618
|
-
ro = null;
|
|
619
|
-
}
|
|
620
|
-
roEl = null;
|
|
621
|
-
if (roRaf) {
|
|
622
|
-
cancelAnimationFrame(roRaf);
|
|
623
|
-
roRaf = 0;
|
|
624
|
-
}
|
|
625
542
|
|
|
626
543
|
// Prefer microtask when available, otherwise macrotask
|
|
627
544
|
if (typeof queueMicrotask === 'function') queueMicrotask(doUnmount);else setTimeout(doUnmount, 0);
|
|
@@ -631,20 +548,6 @@ function renderKitchenSimulator(container) {
|
|
|
631
548
|
// first render
|
|
632
549
|
api.__render(props);
|
|
633
550
|
|
|
634
|
-
// Install observer after initial mount.
|
|
635
|
-
// If #content-box is created later, retry a few frames.
|
|
636
|
-
(function tryInstall() {
|
|
637
|
-
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
638
|
-
if (destroyed) return;
|
|
639
|
-
installContentBoxObserver();
|
|
640
|
-
if (!ro && attempt < 30) {
|
|
641
|
-
// element not found yet; retry next frame for up to ~30 frames
|
|
642
|
-
requestAnimationFrame(function () {
|
|
643
|
-
return tryInstall(attempt + 1);
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
})();
|
|
647
|
-
|
|
648
551
|
// store api on container so repeated calls reuse it
|
|
649
552
|
container[API_KEY] = api;
|
|
650
553
|
return api;
|