targetj 1.1.3 → 1.1.5

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.
@@ -548,27 +548,11 @@ var TModelUtil = /*#__PURE__*/function () {
548
548
  transformUpdate = true;
549
549
  }
550
550
  } else if (key === 'dim') {
551
- var dim = Math.floor(tmodel.val('dim'));
552
- if (tmodel.styleMap['height'] !== dim || tmodel.$dom.getStyleValue('height') !== dim) {
553
- tmodel.styleMap['height'] = dim;
554
- tmodel.$dom.height(dim);
555
- }
556
- if (tmodel.styleMap['width'] !== dim || tmodel.$dom.getStyleValue('width') !== dim) {
557
- tmodel.styleMap['width'] = dim;
558
- tmodel.$dom.width(dim);
559
- }
560
- } else if (key === 'width') {
561
- var width = Math.floor(tmodel.getWidth());
562
- if (tmodel.styleMap['width'] !== width || tmodel.$dom.getStyleValue('width') !== width) {
563
- tmodel.styleMap['width'] = width;
564
- tmodel.$dom.width(width);
565
- }
566
- } else if (key === 'height') {
567
- var height = Math.floor(tmodel.getHeight());
568
- if (tmodel.styleMap['height'] !== height || tmodel.$dom.getStyleValue('height') !== height) {
569
- tmodel.styleMap['height'] = height;
570
- tmodel.$dom.height(height);
571
- }
551
+ var dim = tmodel.val('dim');
552
+ TModelUtil.applyDimensionStyle(tmodel, 'width', dim);
553
+ TModelUtil.applyDimensionStyle(tmodel, 'height', dim);
554
+ } else if (key === 'width' || key === 'height') {
555
+ TModelUtil.applyDimensionStyle(tmodel, key, tmodel.val(key));
572
556
  } else if (TargetData.styleWithUnitMap[key]) {
573
557
  if (TUtil.isDefined(tmodel.val(key)) && tmodel.styleMap[key] !== tmodel.val(key)) {
574
558
  tmodel.$dom.style(key, TUtil.isNumber(tmodel.val(key)) ? "".concat(tmodel.val(key), "px") : tmodel.val(key));
@@ -586,6 +570,58 @@ var TModelUtil = /*#__PURE__*/function () {
586
570
  }
587
571
  tmodel.styleTargetMap.clear();
588
572
  }
573
+ }, {
574
+ key: "applyDimensionStyle",
575
+ value: function applyDimensionStyle(tmodel, key, value) {
576
+ if (!TUtil.isDefined(value)) {
577
+ return;
578
+ }
579
+ var cssValue = typeof value === 'number' ? "".concat(Math.floor(value), "px") : value;
580
+ if (tmodel.styleMap[key] !== value || tmodel.$dom.style(key) !== cssValue) {
581
+ tmodel.styleMap[key] = value;
582
+ tmodel.$dom.style(key, cssValue);
583
+ if (tmodel.isDomIsland()) {
584
+ tmodel.originWindowEpoch = -1;
585
+ getRunScheduler().schedule(1, 'domIslandDimensionStyle');
586
+ }
587
+ }
588
+ }
589
+ }, {
590
+ key: "resolveDimension",
591
+ value: function resolveDimension(value, parentSize) {
592
+ if (typeof value !== 'string') {
593
+ return value;
594
+ }
595
+ var str = value.trim();
596
+ var single = /^([+-]?(?:\d+\.?\d*|\.\d+))(px|%)$/i.exec(str);
597
+ var convert = function convert(term) {
598
+ var number = parseFloat(term);
599
+ if (term.endsWith('%')) {
600
+ if (!Number.isFinite(parentSize)) {
601
+ throw new Error("Percentage dimension requires a definite parent size: ".concat(value));
602
+ }
603
+ return number * parentSize / 100;
604
+ }
605
+ return number;
606
+ };
607
+ if (single) {
608
+ return convert(str);
609
+ }
610
+ var calc = /^calc\((.*)\)$/i.exec(str);
611
+ if (!calc) {
612
+ throw new Error("Unsupported dimension: ".concat(value));
613
+ }
614
+ var expression = calc[1].replace(/\s+/g, '');
615
+ var terms = expression.match(/[+-]?(?:\d+\.?\d*|\.\d+)(?:%|px)/gi);
616
+ if (!terms || terms.join('') !== expression || terms.slice(1).some(function (term) {
617
+ return !/^[+-]/.test(term);
618
+ })) {
619
+ throw new Error("Unsupported calc expression: ".concat(value));
620
+ }
621
+ return terms.reduce(function (total, term) {
622
+ return total + convert(term);
623
+ }, 0);
624
+ }
589
625
  }, {
590
626
  key: "commitAnimatedStyles",
591
627
  value: function commitAnimatedStyles(tmodel, originalKeys) {
@@ -611,24 +647,13 @@ var TModelUtil = /*#__PURE__*/function () {
611
647
  }
612
648
  continue;
613
649
  }
614
- if (key === "dim") {
615
- var dim = Math.floor(value);
616
- tmodel.styleMap.width = dim;
617
- tmodel.styleMap.height = dim;
618
- tmodel.$dom.width(dim);
619
- tmodel.$dom.height(dim);
620
- continue;
621
- }
622
- if (key === "width") {
623
- var width = Math.floor(value);
624
- tmodel.styleMap.width = width;
625
- tmodel.$dom.width(width);
650
+ if (key === 'dim') {
651
+ TModelUtil.applyDimensionStyle(tmodel, 'width', value);
652
+ TModelUtil.applyDimensionStyle(tmodel, 'height', value);
626
653
  continue;
627
654
  }
628
- if (key === "height") {
629
- var height = Math.floor(value);
630
- tmodel.styleMap.height = height;
631
- tmodel.$dom.height(height);
655
+ if (key === 'width' || key === 'height') {
656
+ TModelUtil.applyDimensionStyle(tmodel, key, value);
632
657
  continue;
633
658
  }
634
659
  var styleValue = typeof value === "number" && TargetData.styleWithUnitMap[key] ? "".concat(value, "px") : "".concat(value);
@@ -736,10 +761,10 @@ var TModelUtil = /*#__PURE__*/function () {
736
761
  if (TUtil.isDefined(style) && tmodel.styleMap.style !== style) {
737
762
  tmodel.$dom.setStyleByMap(style);
738
763
  if (style.height) {
739
- tmodel.val('height', parseInt(style.height, 10));
764
+ tmodel.val('height', style.height);
740
765
  }
741
766
  if (style.width) {
742
- tmodel.val('width', parseInt(style.width, 10));
767
+ tmodel.val('width', style.width);
743
768
  }
744
769
  tmodel.styleMap.style = style;
745
770
  }
@@ -1095,6 +1120,17 @@ var TModelUtil = /*#__PURE__*/function () {
1095
1120
  tmodel.absY = rect.top;
1096
1121
  tmodel.markLayoutDirty('islandAbsXY');
1097
1122
  }
1123
+ var size = tmodel.domIslandSize;
1124
+ if (!size || size.width !== rect.width || size.height !== rect.height) {
1125
+ tmodel.domIslandSize = {
1126
+ width: rect.width,
1127
+ height: rect.height
1128
+ };
1129
+ var now = TUtil.now();
1130
+ tmodel.domWidthTimestamp = now;
1131
+ tmodel.domHeightTimestamp = now;
1132
+ tmodel.markLayoutDirty('islandDimensions');
1133
+ }
1098
1134
  }
1099
1135
  }]);
1100
1136
  }();
package/build/TUtil.js CHANGED
@@ -1,3 +1,6 @@
1
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
3
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
1
4
  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; } } }; }
2
5
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
6
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
@@ -9,6 +12,7 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
9
12
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10
13
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
14
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
15
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
12
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
17
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
18
  import { getLocationManager, tRoot } from "./App.js";
@@ -310,165 +314,77 @@ var TUtil = /*#__PURE__*/function () {
310
314
  return cloned;
311
315
  }
312
316
  }, {
313
- key: "advanceTargetByElapsed",
314
- value: function advanceTargetByElapsed(tmodel, key) {
315
- var _targetValue$valueLis2;
316
- var targetValue = tmodel.targetValues[key];
317
- if (!targetValue) {
318
- return {
319
- step: 0,
320
- cycle: 0,
321
- valuePointer: 1,
322
- done: false
323
- };
324
- }
325
- if (!TUtil.isDefined(targetValue.catchupAt)) {
326
- var _targetValue$valueLis;
327
- var step = tmodel.getTargetStep(key);
328
- var valuePointer = (_targetValue$valueLis = targetValue.valueList) !== null && _targetValue$valueLis !== void 0 && _targetValue$valueLis.length ? tmodel.getValueListPointer(key) : 0;
329
- return {
330
- step: step,
331
- cycle: tmodel.getTargetCycle(key),
332
- valuePointer: valuePointer,
333
- done: !TargetUtil.isTargetUpdating(tmodel, key)
334
- };
335
- }
336
- var now = TUtil.now();
337
- var elapsedMs = now - targetValue.catchupAt;
338
- var progress = (_targetValue$valueLis2 = targetValue.valueList) !== null && _targetValue$valueLis2 !== void 0 && _targetValue$valueLis2.length ? TUtil.advanceValueListTargetByElapsed(tmodel, key, elapsedMs) : TUtil.advanceSimpleTargetByElapsed(tmodel, key, elapsedMs);
339
- if (!progress.done) {
340
- targetValue.catchupAt = now - progress.remainingMs;
341
- }
342
- return progress;
343
- }
344
- }, {
345
- key: "advanceSimpleTargetByElapsed",
346
- value: function advanceSimpleTargetByElapsed(tmodel, key, elapsedMs) {
347
- var steps = tmodel.getTargetSteps(key);
348
- var interval = tmodel.getTargetInterval(key) || 8;
349
- var cycles = tmodel.getTargetCycles(key);
350
- var step = tmodel.getTargetStep(key);
351
- var cycle = tmodel.getTargetCycle(key);
352
- var remainingMs = elapsedMs;
353
- if (steps <= 0) {
354
- return {
355
- step: steps,
356
- valuePointer: 0,
357
- cycle: cycles,
358
- done: true,
359
- remainingMs: 0
360
- };
361
- }
362
- while (remainingMs > 0 && cycle < cycles) {
363
- var remainingSteps = Math.max(steps - step, 0);
364
- var remainingSegmentMs = remainingSteps * interval;
365
- if (remainingMs >= remainingSegmentMs) {
366
- remainingMs -= remainingSegmentMs;
367
- cycle++;
368
- if (cycle >= cycles) {
369
- return {
370
- step: steps,
371
- valuePointer: 0,
372
- cycle: cycles,
373
- done: true,
374
- remainingMs: remainingMs
375
- };
317
+ key: "initWebGpu",
318
+ value: function initWebGpu() {
319
+ var _this$webGpuInitPromi,
320
+ _this = this;
321
+ return (_this$webGpuInitPromi = this.webGpuInitPromise) !== null && _this$webGpuInitPromi !== void 0 ? _this$webGpuInitPromi : this.webGpuInitPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
322
+ var device, adapter, canvas, context, _device;
323
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
324
+ while (1) switch (_context.prev = _context.next) {
325
+ case 0:
326
+ _this.webGpuAvailable = false;
327
+ if (_this.hasWebGpu()) {
328
+ _context.next = 3;
329
+ break;
330
+ }
331
+ return _context.abrupt("return", false);
332
+ case 3:
333
+ _context.prev = 3;
334
+ _context.next = 6;
335
+ return navigator.gpu.requestAdapter();
336
+ case 6:
337
+ adapter = _context.sent;
338
+ if (adapter) {
339
+ _context.next = 9;
340
+ break;
341
+ }
342
+ return _context.abrupt("return", false);
343
+ case 9:
344
+ _context.next = 11;
345
+ return adapter.requestDevice();
346
+ case 11:
347
+ device = _context.sent;
348
+ canvas = document.createElement("canvas");
349
+ context = canvas.getContext("webgpu");
350
+ if (context) {
351
+ _context.next = 16;
352
+ break;
353
+ }
354
+ return _context.abrupt("return", false);
355
+ case 16:
356
+ context.configure({
357
+ device: device,
358
+ format: navigator.gpu.getPreferredCanvasFormat(),
359
+ alphaMode: "premultiplied",
360
+ usage: globalThis.GPUTextureUsage.RENDER_ATTACHMENT | globalThis.GPUTextureUsage.COPY_SRC
361
+ });
362
+ context.unconfigure();
363
+ _this.webGpuAvailable = true;
364
+ return _context.abrupt("return", true);
365
+ case 22:
366
+ _context.prev = 22;
367
+ _context.t0 = _context["catch"](3);
368
+ console.warn("TargetJS: WebGPU unavailable. Using DOM.", _context.t0);
369
+ return _context.abrupt("return", false);
370
+ case 26:
371
+ _context.prev = 26;
372
+ (_device = device) === null || _device === void 0 || _device.destroy();
373
+ return _context.finish(26);
374
+ case 29:
375
+ case "end":
376
+ return _context.stop();
376
377
  }
377
- step = 0;
378
- continue;
379
- }
380
- var advancedSteps = TUtil.limit(Math.floor(remainingMs / interval), 0, remainingSteps);
381
- step += advancedSteps;
382
- remainingMs -= advancedSteps * interval;
383
- return {
384
- step: step,
385
- steps: steps,
386
- valuePointer: 0,
387
- cycle: cycle,
388
- done: false,
389
- remainingMs: remainingMs
390
- };
391
- }
392
- return {
393
- step: step,
394
- steps: steps,
395
- valuePointer: 0,
396
- cycle: cycle,
397
- done: cycle >= cycles,
398
- remainingMs: remainingMs
399
- };
378
+ }, _callee, null, [[3, 22, 26, 29]]);
379
+ }))();
400
380
  }
401
381
  }, {
402
- key: "advanceValueListTargetByElapsed",
403
- value: function advanceValueListTargetByElapsed(tmodel, key, elapsedMs) {
404
- var targetValue = tmodel.targetValues[key];
405
- var valueList = targetValue.valueList;
406
- var stepList = targetValue.stepList || [1];
407
- var intervalList = targetValue.intervalList || [targetValue.interval || 8];
408
- var cycles = tmodel.getTargetCycles(key);
409
- var cycle = tmodel.getTargetCycle(key);
410
- var valuePointer = tmodel.getValueListPointer(key);
411
- var step = tmodel.getTargetStep(key);
412
- var remainingMs = elapsedMs;
413
- while (cycle < cycles) {
414
- while (remainingMs > 0 && valuePointer < valueList.length) {
415
- var segmentSteps = stepList[(valuePointer - 1) % stepList.length];
416
- var interval = intervalList[(valuePointer - 1) % intervalList.length] || 8;
417
- step = TUtil.limit(step, 0, segmentSteps);
418
- var remainingSteps = Math.max(segmentSteps - step, 0);
419
- var remainingSegmentMs = remainingSteps * interval;
420
- if (remainingMs >= remainingSegmentMs) {
421
- remainingMs -= remainingSegmentMs;
422
- valuePointer++;
423
- step = 0;
424
- continue;
425
- }
426
- var advancedSteps = TUtil.limit(Math.floor(remainingMs / interval), 0, remainingSteps);
427
- step += advancedSteps;
428
- remainingMs -= advancedSteps * interval;
429
- return {
430
- step: step,
431
- steps: segmentSteps,
432
- valuePointer: valuePointer,
433
- cycle: cycle,
434
- done: false,
435
- remainingMs: remainingMs
436
- };
437
- }
438
- if (valuePointer >= valueList.length) {
439
- cycle++;
440
- if (cycle >= cycles) {
441
- var finalPointer = valueList.length;
442
- var finalStepIndex = Math.max(0, valueList.length - 2);
443
- var finalSteps = stepList[finalStepIndex % stepList.length];
444
- return {
445
- step: finalSteps,
446
- steps: finalSteps,
447
- valuePointer: finalPointer,
448
- cycle: cycles,
449
- done: true,
450
- remainingMs: remainingMs
451
- };
452
- }
453
- valuePointer = 1;
454
- step = 0;
455
- if (remainingMs <= 0) {
456
- break;
457
- }
458
- continue;
459
- }
460
- break;
461
- }
462
- var currentSteps = stepList[(valuePointer - 1) % stepList.length];
463
- return {
464
- step: step,
465
- steps: currentSteps,
466
- valuePointer: valuePointer,
467
- cycle: cycle,
468
- remainingMs: remainingMs,
469
- done: cycle >= cycles
470
- };
382
+ key: "hasWebGpu",
383
+ value: function hasWebGpu() {
384
+ return typeof navigator !== "undefined" && !!navigator.gpu && !!globalThis.GPUBufferUsage && !!globalThis.GPUTextureUsage && globalThis.isSecureContext === true;
471
385
  }
472
386
  }]);
473
387
  }();
388
+ _defineProperty(TUtil, "webGpuAvailable", false);
389
+ _defineProperty(TUtil, "webGpuInitPromise", void 0);
474
390
  export { TUtil };
@@ -248,7 +248,7 @@ var TargetManager = /*#__PURE__*/function () {
248
248
  done: false
249
249
  };
250
250
  }
251
- var progress = TUtil.advanceTargetByElapsed(tmodel, key);
251
+ var progress = ScheduleUtil.advanceTargetByElapsed(tmodel, key);
252
252
  var step = progress.step;
253
253
  var valuePointer = progress.valuePointer;
254
254
  var cycle = progress.cycle;
@@ -115,11 +115,20 @@ var TargetParser = /*#__PURE__*/function () {
115
115
  value: function getTargetInstances(tmodel, key) {
116
116
  var target = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : tmodel.targets[key];
117
117
  var cycle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : tmodel.getTargetCycle(key);
118
- if (!target || _typeof(target) !== 'object' || !TUtil.isDefined(target.instances)) {
118
+ if (!target || _typeof(target) !== "object" || !TUtil.isDefined(target.instances)) {
119
119
  return 1;
120
120
  }
121
- var instances = typeof target.instances === 'function' ? target.instances.call(tmodel, cycle) : target.instances;
122
- return Math.max(1, Math.floor(Number(instances) || 1));
121
+ var instances = typeof target.instances === "function" ? target.instances.call(tmodel, cycle) : target.instances;
122
+ var requested = Math.max(1, Math.floor(Number(instances) || 1));
123
+ if (!TUtil.webGpuAvailable && target.renderer !== "dom") {
124
+ var maxDomInstances = Math.max(1, Math.floor(Number(target.maxDomInstances) || 100));
125
+ var count = Math.min(requested, maxDomInstances);
126
+ if (count < requested) {
127
+ console.warn("TargetJS: ".concat(key, " reduced from ").concat(requested, " to ").concat(count, " children for DOM fallback."));
128
+ }
129
+ return count;
130
+ }
131
+ return requested;
123
132
  }
124
133
  }, {
125
134
  key: "getInstanceTargetValue",