@antv/g-webgpu 1.7.67 → 1.7.68

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/dist/index.umd.js CHANGED
@@ -348,783 +348,6 @@
348
348
  return _setPrototypeOf(o, p);
349
349
  }
350
350
 
351
- function createCommonjsModule(fn, basedir, module) {
352
- return module = {
353
- path: basedir,
354
- exports: {},
355
- require: function (path, base) {
356
- return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
357
- }
358
- }, fn(module, module.exports), module.exports;
359
- }
360
-
361
- function commonjsRequire () {
362
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
363
- }
364
-
365
- var runtime_1 = createCommonjsModule(function (module) {
366
- /**
367
- * Copyright (c) 2014-present, Facebook, Inc.
368
- *
369
- * This source code is licensed under the MIT license found in the
370
- * LICENSE file in the root directory of this source tree.
371
- */
372
-
373
- var runtime = (function (exports) {
374
-
375
- var Op = Object.prototype;
376
- var hasOwn = Op.hasOwnProperty;
377
- var defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; };
378
- var undefined$1; // More compressible than void 0.
379
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
380
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
381
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
382
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
383
-
384
- function define(obj, key, value) {
385
- Object.defineProperty(obj, key, {
386
- value: value,
387
- enumerable: true,
388
- configurable: true,
389
- writable: true
390
- });
391
- return obj[key];
392
- }
393
- try {
394
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
395
- define({}, "");
396
- } catch (err) {
397
- define = function(obj, key, value) {
398
- return obj[key] = value;
399
- };
400
- }
401
-
402
- function wrap(innerFn, outerFn, self, tryLocsList) {
403
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
404
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
405
- var generator = Object.create(protoGenerator.prototype);
406
- var context = new Context(tryLocsList || []);
407
-
408
- // The ._invoke method unifies the implementations of the .next,
409
- // .throw, and .return methods.
410
- defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) });
411
-
412
- return generator;
413
- }
414
- exports.wrap = wrap;
415
-
416
- // Try/catch helper to minimize deoptimizations. Returns a completion
417
- // record like context.tryEntries[i].completion. This interface could
418
- // have been (and was previously) designed to take a closure to be
419
- // invoked without arguments, but in all the cases we care about we
420
- // already have an existing method we want to call, so there's no need
421
- // to create a new function object. We can even get away with assuming
422
- // the method takes exactly one argument, since that happens to be true
423
- // in every case, so we don't have to touch the arguments object. The
424
- // only additional allocation required is the completion record, which
425
- // has a stable shape and so hopefully should be cheap to allocate.
426
- function tryCatch(fn, obj, arg) {
427
- try {
428
- return { type: "normal", arg: fn.call(obj, arg) };
429
- } catch (err) {
430
- return { type: "throw", arg: err };
431
- }
432
- }
433
-
434
- var GenStateSuspendedStart = "suspendedStart";
435
- var GenStateSuspendedYield = "suspendedYield";
436
- var GenStateExecuting = "executing";
437
- var GenStateCompleted = "completed";
438
-
439
- // Returning this object from the innerFn has the same effect as
440
- // breaking out of the dispatch switch statement.
441
- var ContinueSentinel = {};
442
-
443
- // Dummy constructor functions that we use as the .constructor and
444
- // .constructor.prototype properties for functions that return Generator
445
- // objects. For full spec compliance, you may wish to configure your
446
- // minifier not to mangle the names of these two functions.
447
- function Generator() {}
448
- function GeneratorFunction() {}
449
- function GeneratorFunctionPrototype() {}
450
-
451
- // This is a polyfill for %IteratorPrototype% for environments that
452
- // don't natively support it.
453
- var IteratorPrototype = {};
454
- define(IteratorPrototype, iteratorSymbol, function () {
455
- return this;
456
- });
457
-
458
- var getProto = Object.getPrototypeOf;
459
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
460
- if (NativeIteratorPrototype &&
461
- NativeIteratorPrototype !== Op &&
462
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
463
- // This environment has a native %IteratorPrototype%; use it instead
464
- // of the polyfill.
465
- IteratorPrototype = NativeIteratorPrototype;
466
- }
467
-
468
- var Gp = GeneratorFunctionPrototype.prototype =
469
- Generator.prototype = Object.create(IteratorPrototype);
470
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
471
- defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: true });
472
- defineProperty(
473
- GeneratorFunctionPrototype,
474
- "constructor",
475
- { value: GeneratorFunction, configurable: true }
476
- );
477
- GeneratorFunction.displayName = define(
478
- GeneratorFunctionPrototype,
479
- toStringTagSymbol,
480
- "GeneratorFunction"
481
- );
482
-
483
- // Helper for defining the .next, .throw, and .return methods of the
484
- // Iterator interface in terms of a single ._invoke method.
485
- function defineIteratorMethods(prototype) {
486
- ["next", "throw", "return"].forEach(function(method) {
487
- define(prototype, method, function(arg) {
488
- return this._invoke(method, arg);
489
- });
490
- });
491
- }
492
-
493
- exports.isGeneratorFunction = function(genFun) {
494
- var ctor = typeof genFun === "function" && genFun.constructor;
495
- return ctor
496
- ? ctor === GeneratorFunction ||
497
- // For the native GeneratorFunction constructor, the best we can
498
- // do is to check its .name property.
499
- (ctor.displayName || ctor.name) === "GeneratorFunction"
500
- : false;
501
- };
502
-
503
- exports.mark = function(genFun) {
504
- if (Object.setPrototypeOf) {
505
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
506
- } else {
507
- genFun.__proto__ = GeneratorFunctionPrototype;
508
- define(genFun, toStringTagSymbol, "GeneratorFunction");
509
- }
510
- genFun.prototype = Object.create(Gp);
511
- return genFun;
512
- };
513
-
514
- // Within the body of any async function, `await x` is transformed to
515
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
516
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
517
- // meant to be awaited.
518
- exports.awrap = function(arg) {
519
- return { __await: arg };
520
- };
521
-
522
- function AsyncIterator(generator, PromiseImpl) {
523
- function invoke(method, arg, resolve, reject) {
524
- var record = tryCatch(generator[method], generator, arg);
525
- if (record.type === "throw") {
526
- reject(record.arg);
527
- } else {
528
- var result = record.arg;
529
- var value = result.value;
530
- if (value &&
531
- typeof value === "object" &&
532
- hasOwn.call(value, "__await")) {
533
- return PromiseImpl.resolve(value.__await).then(function(value) {
534
- invoke("next", value, resolve, reject);
535
- }, function(err) {
536
- invoke("throw", err, resolve, reject);
537
- });
538
- }
539
-
540
- return PromiseImpl.resolve(value).then(function(unwrapped) {
541
- // When a yielded Promise is resolved, its final value becomes
542
- // the .value of the Promise<{value,done}> result for the
543
- // current iteration.
544
- result.value = unwrapped;
545
- resolve(result);
546
- }, function(error) {
547
- // If a rejected Promise was yielded, throw the rejection back
548
- // into the async generator function so it can be handled there.
549
- return invoke("throw", error, resolve, reject);
550
- });
551
- }
552
- }
553
-
554
- var previousPromise;
555
-
556
- function enqueue(method, arg) {
557
- function callInvokeWithMethodAndArg() {
558
- return new PromiseImpl(function(resolve, reject) {
559
- invoke(method, arg, resolve, reject);
560
- });
561
- }
562
-
563
- return previousPromise =
564
- // If enqueue has been called before, then we want to wait until
565
- // all previous Promises have been resolved before calling invoke,
566
- // so that results are always delivered in the correct order. If
567
- // enqueue has not been called before, then it is important to
568
- // call invoke immediately, without waiting on a callback to fire,
569
- // so that the async generator function has the opportunity to do
570
- // any necessary setup in a predictable way. This predictability
571
- // is why the Promise constructor synchronously invokes its
572
- // executor callback, and why async functions synchronously
573
- // execute code before the first await. Since we implement simple
574
- // async functions in terms of async generators, it is especially
575
- // important to get this right, even though it requires care.
576
- previousPromise ? previousPromise.then(
577
- callInvokeWithMethodAndArg,
578
- // Avoid propagating failures to Promises returned by later
579
- // invocations of the iterator.
580
- callInvokeWithMethodAndArg
581
- ) : callInvokeWithMethodAndArg();
582
- }
583
-
584
- // Define the unified helper method that is used to implement .next,
585
- // .throw, and .return (see defineIteratorMethods).
586
- defineProperty(this, "_invoke", { value: enqueue });
587
- }
588
-
589
- defineIteratorMethods(AsyncIterator.prototype);
590
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
591
- return this;
592
- });
593
- exports.AsyncIterator = AsyncIterator;
594
-
595
- // Note that simple async functions are implemented on top of
596
- // AsyncIterator objects; they just return a Promise for the value of
597
- // the final result produced by the iterator.
598
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
599
- if (PromiseImpl === void 0) PromiseImpl = Promise;
600
-
601
- var iter = new AsyncIterator(
602
- wrap(innerFn, outerFn, self, tryLocsList),
603
- PromiseImpl
604
- );
605
-
606
- return exports.isGeneratorFunction(outerFn)
607
- ? iter // If outerFn is a generator, return the full iterator.
608
- : iter.next().then(function(result) {
609
- return result.done ? result.value : iter.next();
610
- });
611
- };
612
-
613
- function makeInvokeMethod(innerFn, self, context) {
614
- var state = GenStateSuspendedStart;
615
-
616
- return function invoke(method, arg) {
617
- if (state === GenStateExecuting) {
618
- throw new Error("Generator is already running");
619
- }
620
-
621
- if (state === GenStateCompleted) {
622
- if (method === "throw") {
623
- throw arg;
624
- }
625
-
626
- // Be forgiving, per 25.3.3.3.3 of the spec:
627
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
628
- return doneResult();
629
- }
630
-
631
- context.method = method;
632
- context.arg = arg;
633
-
634
- while (true) {
635
- var delegate = context.delegate;
636
- if (delegate) {
637
- var delegateResult = maybeInvokeDelegate(delegate, context);
638
- if (delegateResult) {
639
- if (delegateResult === ContinueSentinel) continue;
640
- return delegateResult;
641
- }
642
- }
643
-
644
- if (context.method === "next") {
645
- // Setting context._sent for legacy support of Babel's
646
- // function.sent implementation.
647
- context.sent = context._sent = context.arg;
648
-
649
- } else if (context.method === "throw") {
650
- if (state === GenStateSuspendedStart) {
651
- state = GenStateCompleted;
652
- throw context.arg;
653
- }
654
-
655
- context.dispatchException(context.arg);
656
-
657
- } else if (context.method === "return") {
658
- context.abrupt("return", context.arg);
659
- }
660
-
661
- state = GenStateExecuting;
662
-
663
- var record = tryCatch(innerFn, self, context);
664
- if (record.type === "normal") {
665
- // If an exception is thrown from innerFn, we leave state ===
666
- // GenStateExecuting and loop back for another invocation.
667
- state = context.done
668
- ? GenStateCompleted
669
- : GenStateSuspendedYield;
670
-
671
- if (record.arg === ContinueSentinel) {
672
- continue;
673
- }
674
-
675
- return {
676
- value: record.arg,
677
- done: context.done
678
- };
679
-
680
- } else if (record.type === "throw") {
681
- state = GenStateCompleted;
682
- // Dispatch the exception by looping back around to the
683
- // context.dispatchException(context.arg) call above.
684
- context.method = "throw";
685
- context.arg = record.arg;
686
- }
687
- }
688
- };
689
- }
690
-
691
- // Call delegate.iterator[context.method](context.arg) and handle the
692
- // result, either by returning a { value, done } result from the
693
- // delegate iterator, or by modifying context.method and context.arg,
694
- // setting context.delegate to null, and returning the ContinueSentinel.
695
- function maybeInvokeDelegate(delegate, context) {
696
- var methodName = context.method;
697
- var method = delegate.iterator[methodName];
698
- if (method === undefined$1) {
699
- // A .throw or .return when the delegate iterator has no .throw
700
- // method, or a missing .next mehtod, always terminate the
701
- // yield* loop.
702
- context.delegate = null;
703
-
704
- // Note: ["return"] must be used for ES3 parsing compatibility.
705
- if (methodName === "throw" && delegate.iterator["return"]) {
706
- // If the delegate iterator has a return method, give it a
707
- // chance to clean up.
708
- context.method = "return";
709
- context.arg = undefined$1;
710
- maybeInvokeDelegate(delegate, context);
711
-
712
- if (context.method === "throw") {
713
- // If maybeInvokeDelegate(context) changed context.method from
714
- // "return" to "throw", let that override the TypeError below.
715
- return ContinueSentinel;
716
- }
717
- }
718
- if (methodName !== "return") {
719
- context.method = "throw";
720
- context.arg = new TypeError(
721
- "The iterator does not provide a '" + methodName + "' method");
722
- }
723
-
724
- return ContinueSentinel;
725
- }
726
-
727
- var record = tryCatch(method, delegate.iterator, context.arg);
728
-
729
- if (record.type === "throw") {
730
- context.method = "throw";
731
- context.arg = record.arg;
732
- context.delegate = null;
733
- return ContinueSentinel;
734
- }
735
-
736
- var info = record.arg;
737
-
738
- if (! info) {
739
- context.method = "throw";
740
- context.arg = new TypeError("iterator result is not an object");
741
- context.delegate = null;
742
- return ContinueSentinel;
743
- }
744
-
745
- if (info.done) {
746
- // Assign the result of the finished delegate to the temporary
747
- // variable specified by delegate.resultName (see delegateYield).
748
- context[delegate.resultName] = info.value;
749
-
750
- // Resume execution at the desired location (see delegateYield).
751
- context.next = delegate.nextLoc;
752
-
753
- // If context.method was "throw" but the delegate handled the
754
- // exception, let the outer generator proceed normally. If
755
- // context.method was "next", forget context.arg since it has been
756
- // "consumed" by the delegate iterator. If context.method was
757
- // "return", allow the original .return call to continue in the
758
- // outer generator.
759
- if (context.method !== "return") {
760
- context.method = "next";
761
- context.arg = undefined$1;
762
- }
763
-
764
- } else {
765
- // Re-yield the result returned by the delegate method.
766
- return info;
767
- }
768
-
769
- // The delegate iterator is finished, so forget it and continue with
770
- // the outer generator.
771
- context.delegate = null;
772
- return ContinueSentinel;
773
- }
774
-
775
- // Define Generator.prototype.{next,throw,return} in terms of the
776
- // unified ._invoke helper method.
777
- defineIteratorMethods(Gp);
778
-
779
- define(Gp, toStringTagSymbol, "Generator");
780
-
781
- // A Generator should always return itself as the iterator object when the
782
- // @@iterator function is called on it. Some browsers' implementations of the
783
- // iterator prototype chain incorrectly implement this, causing the Generator
784
- // object to not be returned from this call. This ensures that doesn't happen.
785
- // See https://github.com/facebook/regenerator/issues/274 for more details.
786
- define(Gp, iteratorSymbol, function() {
787
- return this;
788
- });
789
-
790
- define(Gp, "toString", function() {
791
- return "[object Generator]";
792
- });
793
-
794
- function pushTryEntry(locs) {
795
- var entry = { tryLoc: locs[0] };
796
-
797
- if (1 in locs) {
798
- entry.catchLoc = locs[1];
799
- }
800
-
801
- if (2 in locs) {
802
- entry.finallyLoc = locs[2];
803
- entry.afterLoc = locs[3];
804
- }
805
-
806
- this.tryEntries.push(entry);
807
- }
808
-
809
- function resetTryEntry(entry) {
810
- var record = entry.completion || {};
811
- record.type = "normal";
812
- delete record.arg;
813
- entry.completion = record;
814
- }
815
-
816
- function Context(tryLocsList) {
817
- // The root entry object (effectively a try statement without a catch
818
- // or a finally block) gives us a place to store values thrown from
819
- // locations where there is no enclosing try statement.
820
- this.tryEntries = [{ tryLoc: "root" }];
821
- tryLocsList.forEach(pushTryEntry, this);
822
- this.reset(true);
823
- }
824
-
825
- exports.keys = function(val) {
826
- var object = Object(val);
827
- var keys = [];
828
- for (var key in object) {
829
- keys.push(key);
830
- }
831
- keys.reverse();
832
-
833
- // Rather than returning an object with a next method, we keep
834
- // things simple and return the next function itself.
835
- return function next() {
836
- while (keys.length) {
837
- var key = keys.pop();
838
- if (key in object) {
839
- next.value = key;
840
- next.done = false;
841
- return next;
842
- }
843
- }
844
-
845
- // To avoid creating an additional object, we just hang the .value
846
- // and .done properties off the next function object itself. This
847
- // also ensures that the minifier will not anonymize the function.
848
- next.done = true;
849
- return next;
850
- };
851
- };
852
-
853
- function values(iterable) {
854
- if (iterable) {
855
- var iteratorMethod = iterable[iteratorSymbol];
856
- if (iteratorMethod) {
857
- return iteratorMethod.call(iterable);
858
- }
859
-
860
- if (typeof iterable.next === "function") {
861
- return iterable;
862
- }
863
-
864
- if (!isNaN(iterable.length)) {
865
- var i = -1, next = function next() {
866
- while (++i < iterable.length) {
867
- if (hasOwn.call(iterable, i)) {
868
- next.value = iterable[i];
869
- next.done = false;
870
- return next;
871
- }
872
- }
873
-
874
- next.value = undefined$1;
875
- next.done = true;
876
-
877
- return next;
878
- };
879
-
880
- return next.next = next;
881
- }
882
- }
883
-
884
- // Return an iterator with no values.
885
- return { next: doneResult };
886
- }
887
- exports.values = values;
888
-
889
- function doneResult() {
890
- return { value: undefined$1, done: true };
891
- }
892
-
893
- Context.prototype = {
894
- constructor: Context,
895
-
896
- reset: function(skipTempReset) {
897
- this.prev = 0;
898
- this.next = 0;
899
- // Resetting context._sent for legacy support of Babel's
900
- // function.sent implementation.
901
- this.sent = this._sent = undefined$1;
902
- this.done = false;
903
- this.delegate = null;
904
-
905
- this.method = "next";
906
- this.arg = undefined$1;
907
-
908
- this.tryEntries.forEach(resetTryEntry);
909
-
910
- if (!skipTempReset) {
911
- for (var name in this) {
912
- // Not sure about the optimal order of these conditions:
913
- if (name.charAt(0) === "t" &&
914
- hasOwn.call(this, name) &&
915
- !isNaN(+name.slice(1))) {
916
- this[name] = undefined$1;
917
- }
918
- }
919
- }
920
- },
921
-
922
- stop: function() {
923
- this.done = true;
924
-
925
- var rootEntry = this.tryEntries[0];
926
- var rootRecord = rootEntry.completion;
927
- if (rootRecord.type === "throw") {
928
- throw rootRecord.arg;
929
- }
930
-
931
- return this.rval;
932
- },
933
-
934
- dispatchException: function(exception) {
935
- if (this.done) {
936
- throw exception;
937
- }
938
-
939
- var context = this;
940
- function handle(loc, caught) {
941
- record.type = "throw";
942
- record.arg = exception;
943
- context.next = loc;
944
-
945
- if (caught) {
946
- // If the dispatched exception was caught by a catch block,
947
- // then let that catch block handle the exception normally.
948
- context.method = "next";
949
- context.arg = undefined$1;
950
- }
951
-
952
- return !! caught;
953
- }
954
-
955
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
956
- var entry = this.tryEntries[i];
957
- var record = entry.completion;
958
-
959
- if (entry.tryLoc === "root") {
960
- // Exception thrown outside of any try block that could handle
961
- // it, so set the completion value of the entire function to
962
- // throw the exception.
963
- return handle("end");
964
- }
965
-
966
- if (entry.tryLoc <= this.prev) {
967
- var hasCatch = hasOwn.call(entry, "catchLoc");
968
- var hasFinally = hasOwn.call(entry, "finallyLoc");
969
-
970
- if (hasCatch && hasFinally) {
971
- if (this.prev < entry.catchLoc) {
972
- return handle(entry.catchLoc, true);
973
- } else if (this.prev < entry.finallyLoc) {
974
- return handle(entry.finallyLoc);
975
- }
976
-
977
- } else if (hasCatch) {
978
- if (this.prev < entry.catchLoc) {
979
- return handle(entry.catchLoc, true);
980
- }
981
-
982
- } else if (hasFinally) {
983
- if (this.prev < entry.finallyLoc) {
984
- return handle(entry.finallyLoc);
985
- }
986
-
987
- } else {
988
- throw new Error("try statement without catch or finally");
989
- }
990
- }
991
- }
992
- },
993
-
994
- abrupt: function(type, arg) {
995
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
996
- var entry = this.tryEntries[i];
997
- if (entry.tryLoc <= this.prev &&
998
- hasOwn.call(entry, "finallyLoc") &&
999
- this.prev < entry.finallyLoc) {
1000
- var finallyEntry = entry;
1001
- break;
1002
- }
1003
- }
1004
-
1005
- if (finallyEntry &&
1006
- (type === "break" ||
1007
- type === "continue") &&
1008
- finallyEntry.tryLoc <= arg &&
1009
- arg <= finallyEntry.finallyLoc) {
1010
- // Ignore the finally entry if control is not jumping to a
1011
- // location outside the try/catch block.
1012
- finallyEntry = null;
1013
- }
1014
-
1015
- var record = finallyEntry ? finallyEntry.completion : {};
1016
- record.type = type;
1017
- record.arg = arg;
1018
-
1019
- if (finallyEntry) {
1020
- this.method = "next";
1021
- this.next = finallyEntry.finallyLoc;
1022
- return ContinueSentinel;
1023
- }
1024
-
1025
- return this.complete(record);
1026
- },
1027
-
1028
- complete: function(record, afterLoc) {
1029
- if (record.type === "throw") {
1030
- throw record.arg;
1031
- }
1032
-
1033
- if (record.type === "break" ||
1034
- record.type === "continue") {
1035
- this.next = record.arg;
1036
- } else if (record.type === "return") {
1037
- this.rval = this.arg = record.arg;
1038
- this.method = "return";
1039
- this.next = "end";
1040
- } else if (record.type === "normal" && afterLoc) {
1041
- this.next = afterLoc;
1042
- }
1043
-
1044
- return ContinueSentinel;
1045
- },
1046
-
1047
- finish: function(finallyLoc) {
1048
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1049
- var entry = this.tryEntries[i];
1050
- if (entry.finallyLoc === finallyLoc) {
1051
- this.complete(entry.completion, entry.afterLoc);
1052
- resetTryEntry(entry);
1053
- return ContinueSentinel;
1054
- }
1055
- }
1056
- },
1057
-
1058
- "catch": function(tryLoc) {
1059
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1060
- var entry = this.tryEntries[i];
1061
- if (entry.tryLoc === tryLoc) {
1062
- var record = entry.completion;
1063
- if (record.type === "throw") {
1064
- var thrown = record.arg;
1065
- resetTryEntry(entry);
1066
- }
1067
- return thrown;
1068
- }
1069
- }
1070
-
1071
- // The context.catch method must only be called with a location
1072
- // argument that corresponds to a known catch block.
1073
- throw new Error("illegal catch attempt");
1074
- },
1075
-
1076
- delegateYield: function(iterable, resultName, nextLoc) {
1077
- this.delegate = {
1078
- iterator: values(iterable),
1079
- resultName: resultName,
1080
- nextLoc: nextLoc
1081
- };
1082
-
1083
- if (this.method === "next") {
1084
- // Deliberately forget the last sent value so that we don't
1085
- // accidentally pass it on to the delegate.
1086
- this.arg = undefined$1;
1087
- }
1088
-
1089
- return ContinueSentinel;
1090
- }
1091
- };
1092
-
1093
- // Regardless of whether this script is executing as a CommonJS module
1094
- // or not, return the runtime object so that we can declare the variable
1095
- // regeneratorRuntime in the outer scope, which allows this module to be
1096
- // injected easily by `bin/regenerator --include-runtime script.js`.
1097
- return exports;
1098
-
1099
- }(
1100
- // If this script is executing as a CommonJS module, use module.exports
1101
- // as the regeneratorRuntime namespace. Otherwise create a new empty
1102
- // object. Either way, the resulting object will be used to initialize
1103
- // the regeneratorRuntime variable at the top of this file.
1104
- module.exports
1105
- ));
1106
-
1107
- try {
1108
- regeneratorRuntime = runtime;
1109
- } catch (accidentalStrictMode) {
1110
- // This module should not be running in strict mode, so the above
1111
- // assignment should always work unless something is misconfigured. Just
1112
- // in case runtime.js accidentally runs in strict mode, in modern engines
1113
- // we can explicitly access globalThis. In older engines we can escape
1114
- // strict mode using a global Function call. This could conceivably fail
1115
- // if a Content Security Policy forbids using Function, but in that case
1116
- // the proper solution is to fix the accidental strict mode problem. If
1117
- // you've misconfigured your bundler to force strict mode and applied a
1118
- // CSP to forbid Function, and you're not willing to fix either of those
1119
- // problems, please detail your unique predicament in a GitHub issue.
1120
- if (typeof globalThis === "object") {
1121
- globalThis.regeneratorRuntime = runtime;
1122
- } else {
1123
- Function("r", "regeneratorRuntime = r")(runtime);
1124
- }
1125
- }
1126
- });
1127
-
1128
351
  /**
1129
352
  * Common utilities
1130
353
  * @module glMatrix
@@ -1887,6 +1110,20 @@
1887
1110
  return isType(value, 'Number');
1888
1111
  };
1889
1112
 
1113
+ function createCommonjsModule(fn, basedir, module) {
1114
+ return module = {
1115
+ path: basedir,
1116
+ exports: {},
1117
+ require: function (path, base) {
1118
+ return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
1119
+ }
1120
+ }, fn(module, module.exports), module.exports;
1121
+ }
1122
+
1123
+ function commonjsRequire () {
1124
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
1125
+ }
1126
+
1890
1127
  var eventemitter3 = createCommonjsModule(function (module) {
1891
1128
 
1892
1129
  var has = Object.prototype.hasOwnProperty
@@ -5898,6 +5135,15 @@
5898
5135
  };
5899
5136
  return RenderCache;
5900
5137
  }();
5138
+ var ToneMapping;
5139
+ (function (ToneMapping) {
5140
+ ToneMapping["NONE"] = "none";
5141
+ ToneMapping["LINEAR"] = "LinearToneMapping";
5142
+ ToneMapping["REINHARD"] = "ReinhardToneMapping";
5143
+ ToneMapping["CINEON"] = "OptimizedCineonToneMapping";
5144
+ ToneMapping["ACES_FILMIC"] = "ACESFilmicToneMapping";
5145
+ ToneMapping["CUSTOM"] = "CustomToneMapping";
5146
+ })(ToneMapping || (ToneMapping = {}));
5901
5147
  var RGAttachmentSlot;
5902
5148
  (function (RGAttachmentSlot) {
5903
5149
  RGAttachmentSlot[RGAttachmentSlot["Color0"] = 0] = "Color0";
@@ -7357,13 +6603,15 @@
7357
6603
  return RenderInstManager;
7358
6604
  }();
7359
6605
  var RenderHelper = /*#__PURE__*/function () {
7360
- function RenderHelper() {
6606
+ function RenderHelper(parameters) {
6607
+ this.parameters = void 0;
7361
6608
  this.renderCache = void 0;
7362
6609
  this.renderGraph = void 0;
7363
6610
  this.renderInstManager = void 0;
7364
6611
  this.uniformBuffer = void 0;
7365
6612
  // debugThumbnails: DebugThumbnailDrawer;
7366
6613
  this.device = void 0;
6614
+ this.parameters = parameters;
7367
6615
  }
7368
6616
  var _proto = RenderHelper.prototype;
7369
6617
  _proto.getDevice = function getDevice() {
@@ -7404,6 +6652,13 @@
7404
6652
  _proto.getCache = function getCache() {
7405
6653
  return this.renderCache;
7406
6654
  };
6655
+ _proto.getDefines = function getDefines() {
6656
+ var _this$parameters, _this$parameters2, _this$parameters3;
6657
+ return {
6658
+ USE_TONEMAPPING: ((_this$parameters = this.parameters) === null || _this$parameters === void 0 ? void 0 : _this$parameters.toneMapping) && ((_this$parameters2 = this.parameters) === null || _this$parameters2 === void 0 ? void 0 : _this$parameters2.toneMapping) !== ToneMapping.NONE,
6659
+ toneMapping: (_this$parameters3 = this.parameters) === null || _this$parameters3 === void 0 ? void 0 : _this$parameters3.toneMapping
6660
+ };
6661
+ };
7407
6662
  return RenderHelper;
7408
6663
  }();
7409
6664
  var RGRenderTargetDescription = /*#__PURE__*/function () {
@@ -7708,24 +6963,17 @@
7708
6963
  var object = e.target;
7709
6964
  var attrName = e.attrName,
7710
6965
  newValue = e.newValue;
7711
- _this.batchManager.updateAttribute(object, attrName, newValue);
6966
+ if (attrName === 'zIndex') {
6967
+ object.parentNode.forEach(function (child) {
6968
+ _this.batchManager.changeRenderOrder(child, child.sortable.renderOrder);
6969
+ });
6970
+ } else {
6971
+ _this.batchManager.updateAttribute(object, attrName, newValue);
6972
+ }
7712
6973
  };
7713
6974
  var handleBoundsChanged = function handleBoundsChanged(e) {
7714
6975
  var object = e.target;
7715
- // const { affectChildren } = e.detail;
7716
- // if (affectChildren) {
7717
- // object.forEach(() => {
7718
- // this.batchManager.updateAttribute(object, 'modelMatrix', null);
7719
- // });
7720
- // } else {
7721
6976
  _this.batchManager.updateAttribute(object, 'modelMatrix', null);
7722
- // }
7723
- };
7724
-
7725
- var handleRenderOrderChanged = function handleRenderOrderChanged(e) {
7726
- var object = e.target;
7727
- var renderOrder = e.detail.renderOrder;
7728
- _this.batchManager.changeRenderOrder(object, renderOrder);
7729
6977
  };
7730
6978
  renderingService.hooks.init.tapPromise(RenderGraphPlugin.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
7731
6979
  var $canvas, _this$context$config, width, height;
@@ -7736,16 +6984,15 @@
7736
6984
  canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
7737
6985
  canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
7738
6986
  canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
7739
- canvas.addEventListener(gLite.ElementEvent.RENDER_ORDER_CHANGED, handleRenderOrderChanged);
7740
6987
  _this.context.config.renderer.getConfig().enableDirtyRectangleRendering = false;
7741
6988
  $canvas = _this.context.contextService.getDomElement();
7742
6989
  _this$context$config = _this.context.config, width = _this$context$config.width, height = _this$context$config.height;
7743
6990
  _this.context.contextService.resize(width, height);
7744
6991
  // create swap chain and get device
7745
6992
  // @ts-ignore
7746
- _context.next = 11;
6993
+ _context.next = 10;
7747
6994
  return _this.context.deviceContribution.createSwapChain($canvas);
7748
- case 11:
6995
+ case 10:
7749
6996
  _this.swapChain = _context.sent;
7750
6997
  _this.device = _this.swapChain.getDevice();
7751
6998
  _this.renderHelper.setDevice(_this.device);
@@ -7757,7 +7004,7 @@
7757
7004
  _this.batchManager.attach(_extends({
7758
7005
  device: _this.device
7759
7006
  }, context));
7760
- case 18:
7007
+ case 17:
7761
7008
  case "end":
7762
7009
  return _context.stop();
7763
7010
  }
@@ -7769,7 +7016,6 @@
7769
7016
  canvas.removeEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
7770
7017
  canvas.removeEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
7771
7018
  canvas.removeEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
7772
- canvas.removeEventListener(gLite.ElementEvent.RENDER_ORDER_CHANGED, handleRenderOrderChanged);
7773
7019
  });
7774
7020
  /**
7775
7021
  * build frame graph at the beginning of each frame
@@ -8179,28 +7425,12 @@
8179
7425
  * render order start from 0, our default camera's Z is 500
8180
7426
  */
8181
7427
  var RENDER_ORDER_SCALE = 1 / 200;
8182
- var counter = 1;
8183
7428
  /**
8184
7429
  * A container for multiple display objects with the same `style`,
8185
7430
  * eg. 1000 Circles with the same stroke color, but their position, radius can be different
8186
7431
  */
8187
7432
  var Batch = /*#__PURE__*/function () {
8188
7433
  function Batch() {
8189
- // @inject(RenderHelper)
8190
- // protected renderHelper: RenderHelper;
8191
- // @inject(TexturePool)
8192
- // protected texturePool: TexturePool;
8193
- // @inject(DefaultCamera)
8194
- // protected camera: ICamera;
8195
- // @inject(LightPool)
8196
- // protected lightPool: LightPool;
8197
- // @inject(BatchManager)
8198
- // protected batchManager: BatchManager;
8199
- // @inject(MeshFactory)
8200
- // protected meshFactory: (shape: string) => Instanced;
8201
- // device: Device;
8202
- // renderingService: RenderingService;
8203
- this.id = counter++;
8204
7434
  /**
8205
7435
  * describe render insts used in this draw call
8206
7436
  * eg. a Polygon with stroke will use 2 renderInsts
@@ -8774,7 +8004,7 @@
8774
8004
  return v !== undefined;
8775
8005
  }));
8776
8006
  };
8777
- var counter$1 = 1;
8007
+ var counter = 1;
8778
8008
  var FILL_TEXTURE_MAPPING = 'FillTextureMapping';
8779
8009
  /**
8780
8010
  * WebGPU has max vertex attribute num(8)
@@ -8824,8 +8054,13 @@
8824
8054
  /**
8825
8055
  * unique ID
8826
8056
  */
8827
- this.id = counter$1++;
8057
+ this.id = counter++;
8828
8058
  this.renderer = void 0;
8059
+ /**
8060
+ * assigned by user which help BatchManager deciding whether to merge,
8061
+ * e.g. `will-change` property in CSS
8062
+ */
8063
+ this.key = void 0;
8829
8064
  /**
8830
8065
  * index in renderer.meshes
8831
8066
  */
@@ -9131,7 +8366,7 @@
9131
8366
  var oldDefines = _extends({}, this.material.defines);
9132
8367
  this.material.defines.USE_FOG = useFog;
9133
8368
  this.material.defines.USE_LIGHT = useLight;
9134
- this.material.defines = _extends({}, this.material.defines, this.lightPool.getDefines());
8369
+ this.material.defines = _extends({}, this.material.defines, this.lightPool.getDefines(), this.renderHelper.getDefines());
9135
8370
  // re-upload textures
9136
8371
  if (this.material.textureDirty) {
9137
8372
  this.textureMappings = [];
@@ -9174,10 +8409,10 @@
9174
8409
  this.material.defines = _extends({}, this.material.defines, enumToObject(VertexAttributeLocation));
9175
8410
  Object.keys(this.material.defines).forEach(function (key) {
9176
8411
  var value = _this4.material.defines[key];
9177
- if (typeof value === 'number') {
9178
- _this4.program.setDefineString(key, "" + value);
9179
- } else {
8412
+ if (typeof value === 'boolean') {
9180
8413
  _this4.program.setDefineBool(key, value);
8414
+ } else {
8415
+ _this4.program.setDefineString(key, "" + value);
9181
8416
  }
9182
8417
  });
9183
8418
  // build shaders
@@ -12042,6 +11277,7 @@
12042
11277
  }
12043
11278
  _this = _Instanced.call.apply(_Instanced, [this].concat(args)) || this;
12044
11279
  _this.glyphManager = new GlyphManager();
11280
+ _this.packedBufferObjectMap = new WeakMap();
12045
11281
  return _this;
12046
11282
  }
12047
11283
  var _proto = TextMesh.prototype;
@@ -12122,7 +11358,10 @@
12122
11358
  charUVOffsetBuffer = _this2$buildTextBuffe.charUVOffsetBuffer,
12123
11359
  charPackedBuffer = _this2$buildTextBuffe.charPackedBuffer;
12124
11360
  indicesOff = indicesOffset;
11361
+ var start = packed.length;
12125
11362
  packed.push.apply(packed, charPackedBuffer);
11363
+ var end = packed.length;
11364
+ _this2.packedBufferObjectMap.set(object, [start, end]);
12126
11365
  uvOffsets.push.apply(uvOffsets, charUVOffsetBuffer);
12127
11366
  indices.push.apply(indices, indexBuffer);
12128
11367
  });
@@ -12236,6 +11475,17 @@
12236
11475
  this.material.setUniforms((_this$material$setUni = {}, _this$material$setUni[TextUniform.SDF_MAP] = glyphAtlasTexture, _this$material$setUni[TextUniform.SDF_MAP_SIZE] = [atlasWidth, atlasHeight], _this$material$setUni[TextUniform.FONT_SIZE] = fontSize, _this$material$setUni[TextUniform.GAMMA_SCALE] = 1, _this$material$setUni[TextUniform.STROKE_BLUR] = 0.2, _this$material$setUni[TextUniform.HAS_STROKE] = this.index, _this$material$setUni));
12237
11476
  };
12238
11477
  _proto.changeRenderOrder = function changeRenderOrder(object, renderOrder) {
11478
+ var vertice = this.geometry.vertices[TextVertexAttributeBufferIndex.INSTANCED];
11479
+ var byteStride = this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[TextVertexAttributeBufferIndex.INSTANCED].byteStride;
11480
+ var bytes = byteStride / 4;
11481
+ var _this$packedBufferObj = this.packedBufferObjectMap.get(object),
11482
+ start = _this$packedBufferObj[0],
11483
+ end = _this$packedBufferObj[1];
11484
+ var sliced = vertice.slice(start, end);
11485
+ for (var i = 0; i < end - start; i += bytes) {
11486
+ sliced[i + bytes - 1] = renderOrder * RENDER_ORDER_SCALE;
11487
+ }
11488
+ this.geometry.updateVertexBuffer(TextVertexAttributeBufferIndex.INSTANCED, VertexAttributeLocation.MODEL_MATRIX0, start / byteStride, new Uint8Array(sliced.buffer));
12239
11489
  if (this.material) {
12240
11490
  this.material.programDirty = true;
12241
11491
  this.material.geometryDirty = true;
@@ -12247,7 +11497,7 @@
12247
11497
  this.material.geometryDirty = true;
12248
11498
  // need re-upload SDF texture
12249
11499
  this.material.textureDirty = true;
12250
- } else if (name === 'fill' || name === 'fillOpacity' || name === 'stroke' || name === 'strokeOpacity' || name === 'opacity' || name === 'lineWidth' || name === 'visibility' || name === 'pointerEvents') {
11500
+ } else if (name === 'fill' || name === 'fillOpacity' || name === 'stroke' || name === 'strokeOpacity' || name === 'opacity' || name === 'lineWidth' || name === 'pointerEvents') {
12251
11501
  this.material.geometryDirty = true;
12252
11502
  }
12253
11503
  };
@@ -12700,11 +11950,14 @@
12700
11950
  var existedMesh = _this2.meshes.find(function (mesh) {
12701
11951
  return meshTag === mesh.constructor && mesh.index === i && mesh.shouldMerge(object, i);
12702
11952
  });
12703
- if (!existedMesh) {
11953
+ if (!existedMesh || existedMesh.key !== object.parsedStyle.batchKey) {
12704
11954
  existedMesh = new meshTag(_this2.renderHelper, _this2.texturePool, _this2.lightPool);
12705
11955
  existedMesh.renderer = renderer;
12706
11956
  existedMesh.index = i;
12707
11957
  _this2.meshes.push(existedMesh);
11958
+ if (object.parsedStyle.batchKey) {
11959
+ existedMesh.key = object.parsedStyle.batchKey;
11960
+ }
12708
11961
  }
12709
11962
  if (existedMesh) {
12710
11963
  existedMesh.objects.push(object);
@@ -13158,13 +12411,21 @@
13158
12411
  }
13159
12412
  _this = _AbstractRendererPlug.call.apply(_AbstractRendererPlug, [this].concat(args)) || this;
13160
12413
  _this.name = 'device-renderer';
12414
+ _this.parameters = {
12415
+ /**
12416
+ * ToneMapping is a renderer-level parameter, it will affect all materials.
12417
+ * @see https://threejs.org/docs/#api/en/renderers/WebGLRenderer.toneMapping
12418
+ */
12419
+ toneMapping: ToneMapping.NONE,
12420
+ toneMappingExposure: 1
12421
+ };
13161
12422
  return _this;
13162
12423
  }
13163
12424
  var _proto = Plugin.prototype;
13164
12425
  _proto.init = function init(runtime) {
13165
12426
  var _rendererFactory;
13166
12427
  runtime.geometryUpdaterFactory[gLite.Shape.MESH] = new MeshUpdater();
13167
- var renderHelper = new RenderHelper();
12428
+ var renderHelper = new RenderHelper(this.parameters);
13168
12429
  var lightPool = new LightPool();
13169
12430
  var texturePool = new TexturePool(this.context);
13170
12431
  var pickingIdGenerator = new PickingIdGenerator();
@@ -13191,6 +12452,9 @@
13191
12452
  _proto.toDataURL = function toDataURL(options) {
13192
12453
  return this.getRenderGraphPlugin().toDataURL(options);
13193
12454
  };
12455
+ _proto.setParameters = function setParameters(parameters) {
12456
+ this.parameters = _extends({}, this.parameters, parameters);
12457
+ };
13194
12458
  return Plugin;
13195
12459
  }(gLite.AbstractRendererPlugin);
13196
12460
 
@@ -13268,6 +12532,7 @@
13268
12532
  TexturePool: TexturePool,
13269
12533
  get TextureUsage () { return TextureUsage; },
13270
12534
  TinySDF: TinySDF,
12535
+ get ToneMapping () { return ToneMapping; },
13271
12536
  TransparentBlack: TransparentBlack,
13272
12537
  TransparentWhite: TransparentWhite,
13273
12538
  UNIFORM_SETTERS: UNIFORM_SETTERS,