webgal-parser 4.6.1 → 4.6.3-beta.1

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.
@@ -38,6 +38,7 @@ var webgalParser = (function (exports) {
38
38
  commandType[commandType["applyStyle"] = 32] = "applyStyle";
39
39
  commandType[commandType["wait"] = 33] = "wait";
40
40
  commandType[commandType["callSteam"] = 34] = "callSteam";
41
+ commandType[commandType["return"] = 35] = "return";
41
42
  })(commandType || (commandType = {}));
42
43
 
43
44
  const SCRIPT_CONFIG = [
@@ -79,6 +80,7 @@ var webgalParser = (function (exports) {
79
80
  { scriptString: 'applyStyle', scriptType: commandType.applyStyle },
80
81
  { scriptString: 'wait', scriptType: commandType.wait },
81
82
  { scriptString: 'callSteam', scriptType: commandType.callSteam },
83
+ { scriptString: 'return', scriptType: commandType.return },
82
84
  ];
83
85
  const ADD_NEXT_ARG_LIST = [
84
86
  commandType.bgm,
@@ -137,7 +139,7 @@ var webgalParser = (function (exports) {
137
139
  argValue = undefined;
138
140
  }
139
141
  // 判断是不是语音参数
140
- if (argName.toLowerCase().match(/.ogg|.mp3|.wav/)) {
142
+ if (argName.toLowerCase().match(/.ogg|.mp3|.wav|.opus/)) {
141
143
  returnArrayList.push({
142
144
  key: 'vocal',
143
145
  value: assetSetter(e, fileType.vocal),
@@ -452,7 +454,7 @@ var webgalParser = (function (exports) {
452
454
  const commentSplit = sentenceRaw.split(/(?<!\\);/);
453
455
  let newSentenceRaw = commentSplit[0];
454
456
  newSentenceRaw = newSentenceRaw.replaceAll('\\;', ';');
455
- const sentenceComment = commentSplit[1] ?? '';
457
+ const sentenceComment = commentSplit.slice(1).join(';');
456
458
  if (newSentenceRaw.trim() === '') {
457
459
  // 注释提前返回
458
460
  return {
@@ -462,7 +464,10 @@ var webgalParser = (function (exports) {
462
464
  args: [{ key: 'next', value: true }],
463
465
  sentenceAssets: [],
464
466
  subScene: [],
465
- inlineComment: '', // 行内注释
467
+ inlineComment: '',
468
+ startLine: lineNumber,
469
+ endLine: lineNumber,
470
+ isLineBreakHolder: false,
466
471
  };
467
472
  }
468
473
  // 截取命令
@@ -513,1326 +518,14 @@ var webgalParser = (function (exports) {
513
518
  args: args,
514
519
  sentenceAssets: sentenceAssets,
515
520
  subScene: subScene,
516
- inlineComment: sentenceComment.trim(), // 行内注释
521
+ inlineComment: sentenceComment.trim(),
522
+ // 单行语句的行范围就是自己,多行语句的 endLine 由 sceneParser 回填
523
+ startLine: lineNumber,
524
+ endLine: lineNumber,
525
+ isLineBreakHolder: false,
517
526
  };
518
527
  };
519
528
 
520
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
521
-
522
- /** Detect free variable `global` from Node.js. */
523
-
524
- var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
525
-
526
- var _freeGlobal = freeGlobal$1;
527
-
528
- var freeGlobal = _freeGlobal;
529
-
530
- /** Detect free variable `self`. */
531
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
532
-
533
- /** Used as a reference to the global object. */
534
- var root$4 = freeGlobal || freeSelf || Function('return this')();
535
-
536
- var _root = root$4;
537
-
538
- var root$3 = _root;
539
-
540
- /** Built-in value references. */
541
- var Symbol$2 = root$3.Symbol;
542
-
543
- var _Symbol = Symbol$2;
544
-
545
- var Symbol$1 = _Symbol;
546
-
547
- /** Used for built-in method references. */
548
- var objectProto$4 = Object.prototype;
549
-
550
- /** Used to check objects for own properties. */
551
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
552
-
553
- /**
554
- * Used to resolve the
555
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
556
- * of values.
557
- */
558
- var nativeObjectToString$1 = objectProto$4.toString;
559
-
560
- /** Built-in value references. */
561
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
562
-
563
- /**
564
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
565
- *
566
- * @private
567
- * @param {*} value The value to query.
568
- * @returns {string} Returns the raw `toStringTag`.
569
- */
570
- function getRawTag$1(value) {
571
- var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
572
- tag = value[symToStringTag$1];
573
-
574
- try {
575
- value[symToStringTag$1] = undefined;
576
- var unmasked = true;
577
- } catch (e) {}
578
-
579
- var result = nativeObjectToString$1.call(value);
580
- if (unmasked) {
581
- if (isOwn) {
582
- value[symToStringTag$1] = tag;
583
- } else {
584
- delete value[symToStringTag$1];
585
- }
586
- }
587
- return result;
588
- }
589
-
590
- var _getRawTag = getRawTag$1;
591
-
592
- /** Used for built-in method references. */
593
-
594
- var objectProto$3 = Object.prototype;
595
-
596
- /**
597
- * Used to resolve the
598
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
599
- * of values.
600
- */
601
- var nativeObjectToString = objectProto$3.toString;
602
-
603
- /**
604
- * Converts `value` to a string using `Object.prototype.toString`.
605
- *
606
- * @private
607
- * @param {*} value The value to convert.
608
- * @returns {string} Returns the converted string.
609
- */
610
- function objectToString$1(value) {
611
- return nativeObjectToString.call(value);
612
- }
613
-
614
- var _objectToString = objectToString$1;
615
-
616
- var Symbol = _Symbol,
617
- getRawTag = _getRawTag,
618
- objectToString = _objectToString;
619
-
620
- /** `Object#toString` result references. */
621
- var nullTag = '[object Null]',
622
- undefinedTag = '[object Undefined]';
623
-
624
- /** Built-in value references. */
625
- var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
626
-
627
- /**
628
- * The base implementation of `getTag` without fallbacks for buggy environments.
629
- *
630
- * @private
631
- * @param {*} value The value to query.
632
- * @returns {string} Returns the `toStringTag`.
633
- */
634
- function baseGetTag$1(value) {
635
- if (value == null) {
636
- return value === undefined ? undefinedTag : nullTag;
637
- }
638
- return (symToStringTag && symToStringTag in Object(value))
639
- ? getRawTag(value)
640
- : objectToString(value);
641
- }
642
-
643
- var _baseGetTag = baseGetTag$1;
644
-
645
- /**
646
- * Checks if `value` is the
647
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
648
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
649
- *
650
- * @static
651
- * @memberOf _
652
- * @since 0.1.0
653
- * @category Lang
654
- * @param {*} value The value to check.
655
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
656
- * @example
657
- *
658
- * _.isObject({});
659
- * // => true
660
- *
661
- * _.isObject([1, 2, 3]);
662
- * // => true
663
- *
664
- * _.isObject(_.noop);
665
- * // => true
666
- *
667
- * _.isObject(null);
668
- * // => false
669
- */
670
-
671
- function isObject$2(value) {
672
- var type = typeof value;
673
- return value != null && (type == 'object' || type == 'function');
674
- }
675
-
676
- var isObject_1 = isObject$2;
677
-
678
- var baseGetTag = _baseGetTag,
679
- isObject$1 = isObject_1;
680
-
681
- /** `Object#toString` result references. */
682
- var asyncTag = '[object AsyncFunction]',
683
- funcTag = '[object Function]',
684
- genTag = '[object GeneratorFunction]',
685
- proxyTag = '[object Proxy]';
686
-
687
- /**
688
- * Checks if `value` is classified as a `Function` object.
689
- *
690
- * @static
691
- * @memberOf _
692
- * @since 0.1.0
693
- * @category Lang
694
- * @param {*} value The value to check.
695
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
696
- * @example
697
- *
698
- * _.isFunction(_);
699
- * // => true
700
- *
701
- * _.isFunction(/abc/);
702
- * // => false
703
- */
704
- function isFunction$1(value) {
705
- if (!isObject$1(value)) {
706
- return false;
707
- }
708
- // The use of `Object#toString` avoids issues with the `typeof` operator
709
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
710
- var tag = baseGetTag(value);
711
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
712
- }
713
-
714
- var isFunction_1 = isFunction$1;
715
-
716
- var root$2 = _root;
717
-
718
- /** Used to detect overreaching core-js shims. */
719
- var coreJsData$1 = root$2['__core-js_shared__'];
720
-
721
- var _coreJsData = coreJsData$1;
722
-
723
- var coreJsData = _coreJsData;
724
-
725
- /** Used to detect methods masquerading as native. */
726
- var maskSrcKey = (function() {
727
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
728
- return uid ? ('Symbol(src)_1.' + uid) : '';
729
- }());
730
-
731
- /**
732
- * Checks if `func` has its source masked.
733
- *
734
- * @private
735
- * @param {Function} func The function to check.
736
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
737
- */
738
- function isMasked$1(func) {
739
- return !!maskSrcKey && (maskSrcKey in func);
740
- }
741
-
742
- var _isMasked = isMasked$1;
743
-
744
- /** Used for built-in method references. */
745
-
746
- var funcProto$1 = Function.prototype;
747
-
748
- /** Used to resolve the decompiled source of functions. */
749
- var funcToString$1 = funcProto$1.toString;
750
-
751
- /**
752
- * Converts `func` to its source code.
753
- *
754
- * @private
755
- * @param {Function} func The function to convert.
756
- * @returns {string} Returns the source code.
757
- */
758
- function toSource$1(func) {
759
- if (func != null) {
760
- try {
761
- return funcToString$1.call(func);
762
- } catch (e) {}
763
- try {
764
- return (func + '');
765
- } catch (e) {}
766
- }
767
- return '';
768
- }
769
-
770
- var _toSource = toSource$1;
771
-
772
- var isFunction = isFunction_1,
773
- isMasked = _isMasked,
774
- isObject = isObject_1,
775
- toSource = _toSource;
776
-
777
- /**
778
- * Used to match `RegExp`
779
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
780
- */
781
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
782
-
783
- /** Used to detect host constructors (Safari). */
784
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
785
-
786
- /** Used for built-in method references. */
787
- var funcProto = Function.prototype,
788
- objectProto$2 = Object.prototype;
789
-
790
- /** Used to resolve the decompiled source of functions. */
791
- var funcToString = funcProto.toString;
792
-
793
- /** Used to check objects for own properties. */
794
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
795
-
796
- /** Used to detect if a method is native. */
797
- var reIsNative = RegExp('^' +
798
- funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
799
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
800
- );
801
-
802
- /**
803
- * The base implementation of `_.isNative` without bad shim checks.
804
- *
805
- * @private
806
- * @param {*} value The value to check.
807
- * @returns {boolean} Returns `true` if `value` is a native function,
808
- * else `false`.
809
- */
810
- function baseIsNative$1(value) {
811
- if (!isObject(value) || isMasked(value)) {
812
- return false;
813
- }
814
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
815
- return pattern.test(toSource(value));
816
- }
817
-
818
- var _baseIsNative = baseIsNative$1;
819
-
820
- /**
821
- * Gets the value at `key` of `object`.
822
- *
823
- * @private
824
- * @param {Object} [object] The object to query.
825
- * @param {string} key The key of the property to get.
826
- * @returns {*} Returns the property value.
827
- */
828
-
829
- function getValue$1(object, key) {
830
- return object == null ? undefined : object[key];
831
- }
832
-
833
- var _getValue = getValue$1;
834
-
835
- var baseIsNative = _baseIsNative,
836
- getValue = _getValue;
837
-
838
- /**
839
- * Gets the native function at `key` of `object`.
840
- *
841
- * @private
842
- * @param {Object} object The object to query.
843
- * @param {string} key The key of the method to get.
844
- * @returns {*} Returns the function if it's native, else `undefined`.
845
- */
846
- function getNative$3(object, key) {
847
- var value = getValue(object, key);
848
- return baseIsNative(value) ? value : undefined;
849
- }
850
-
851
- var _getNative = getNative$3;
852
-
853
- var getNative$2 = _getNative;
854
-
855
- /* Built-in method references that are verified to be native. */
856
- var nativeCreate$4 = getNative$2(Object, 'create');
857
-
858
- var _nativeCreate = nativeCreate$4;
859
-
860
- var nativeCreate$3 = _nativeCreate;
861
-
862
- /**
863
- * Removes all key-value entries from the hash.
864
- *
865
- * @private
866
- * @name clear
867
- * @memberOf Hash
868
- */
869
- function hashClear$1() {
870
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
871
- this.size = 0;
872
- }
873
-
874
- var _hashClear = hashClear$1;
875
-
876
- /**
877
- * Removes `key` and its value from the hash.
878
- *
879
- * @private
880
- * @name delete
881
- * @memberOf Hash
882
- * @param {Object} hash The hash to modify.
883
- * @param {string} key The key of the value to remove.
884
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
885
- */
886
-
887
- function hashDelete$1(key) {
888
- var result = this.has(key) && delete this.__data__[key];
889
- this.size -= result ? 1 : 0;
890
- return result;
891
- }
892
-
893
- var _hashDelete = hashDelete$1;
894
-
895
- var nativeCreate$2 = _nativeCreate;
896
-
897
- /** Used to stand-in for `undefined` hash values. */
898
- var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
899
-
900
- /** Used for built-in method references. */
901
- var objectProto$1 = Object.prototype;
902
-
903
- /** Used to check objects for own properties. */
904
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
905
-
906
- /**
907
- * Gets the hash value for `key`.
908
- *
909
- * @private
910
- * @name get
911
- * @memberOf Hash
912
- * @param {string} key The key of the value to get.
913
- * @returns {*} Returns the entry value.
914
- */
915
- function hashGet$1(key) {
916
- var data = this.__data__;
917
- if (nativeCreate$2) {
918
- var result = data[key];
919
- return result === HASH_UNDEFINED$2 ? undefined : result;
920
- }
921
- return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
922
- }
923
-
924
- var _hashGet = hashGet$1;
925
-
926
- var nativeCreate$1 = _nativeCreate;
927
-
928
- /** Used for built-in method references. */
929
- var objectProto = Object.prototype;
930
-
931
- /** Used to check objects for own properties. */
932
- var hasOwnProperty = objectProto.hasOwnProperty;
933
-
934
- /**
935
- * Checks if a hash value for `key` exists.
936
- *
937
- * @private
938
- * @name has
939
- * @memberOf Hash
940
- * @param {string} key The key of the entry to check.
941
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
942
- */
943
- function hashHas$1(key) {
944
- var data = this.__data__;
945
- return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
946
- }
947
-
948
- var _hashHas = hashHas$1;
949
-
950
- var nativeCreate = _nativeCreate;
951
-
952
- /** Used to stand-in for `undefined` hash values. */
953
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
954
-
955
- /**
956
- * Sets the hash `key` to `value`.
957
- *
958
- * @private
959
- * @name set
960
- * @memberOf Hash
961
- * @param {string} key The key of the value to set.
962
- * @param {*} value The value to set.
963
- * @returns {Object} Returns the hash instance.
964
- */
965
- function hashSet$1(key, value) {
966
- var data = this.__data__;
967
- this.size += this.has(key) ? 0 : 1;
968
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
969
- return this;
970
- }
971
-
972
- var _hashSet = hashSet$1;
973
-
974
- var hashClear = _hashClear,
975
- hashDelete = _hashDelete,
976
- hashGet = _hashGet,
977
- hashHas = _hashHas,
978
- hashSet = _hashSet;
979
-
980
- /**
981
- * Creates a hash object.
982
- *
983
- * @private
984
- * @constructor
985
- * @param {Array} [entries] The key-value pairs to cache.
986
- */
987
- function Hash$1(entries) {
988
- var index = -1,
989
- length = entries == null ? 0 : entries.length;
990
-
991
- this.clear();
992
- while (++index < length) {
993
- var entry = entries[index];
994
- this.set(entry[0], entry[1]);
995
- }
996
- }
997
-
998
- // Add methods to `Hash`.
999
- Hash$1.prototype.clear = hashClear;
1000
- Hash$1.prototype['delete'] = hashDelete;
1001
- Hash$1.prototype.get = hashGet;
1002
- Hash$1.prototype.has = hashHas;
1003
- Hash$1.prototype.set = hashSet;
1004
-
1005
- var _Hash = Hash$1;
1006
-
1007
- /**
1008
- * Removes all key-value entries from the list cache.
1009
- *
1010
- * @private
1011
- * @name clear
1012
- * @memberOf ListCache
1013
- */
1014
-
1015
- function listCacheClear$1() {
1016
- this.__data__ = [];
1017
- this.size = 0;
1018
- }
1019
-
1020
- var _listCacheClear = listCacheClear$1;
1021
-
1022
- /**
1023
- * Performs a
1024
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1025
- * comparison between two values to determine if they are equivalent.
1026
- *
1027
- * @static
1028
- * @memberOf _
1029
- * @since 4.0.0
1030
- * @category Lang
1031
- * @param {*} value The value to compare.
1032
- * @param {*} other The other value to compare.
1033
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1034
- * @example
1035
- *
1036
- * var object = { 'a': 1 };
1037
- * var other = { 'a': 1 };
1038
- *
1039
- * _.eq(object, object);
1040
- * // => true
1041
- *
1042
- * _.eq(object, other);
1043
- * // => false
1044
- *
1045
- * _.eq('a', 'a');
1046
- * // => true
1047
- *
1048
- * _.eq('a', Object('a'));
1049
- * // => false
1050
- *
1051
- * _.eq(NaN, NaN);
1052
- * // => true
1053
- */
1054
-
1055
- function eq$1(value, other) {
1056
- return value === other || (value !== value && other !== other);
1057
- }
1058
-
1059
- var eq_1 = eq$1;
1060
-
1061
- var eq = eq_1;
1062
-
1063
- /**
1064
- * Gets the index at which the `key` is found in `array` of key-value pairs.
1065
- *
1066
- * @private
1067
- * @param {Array} array The array to inspect.
1068
- * @param {*} key The key to search for.
1069
- * @returns {number} Returns the index of the matched value, else `-1`.
1070
- */
1071
- function assocIndexOf$4(array, key) {
1072
- var length = array.length;
1073
- while (length--) {
1074
- if (eq(array[length][0], key)) {
1075
- return length;
1076
- }
1077
- }
1078
- return -1;
1079
- }
1080
-
1081
- var _assocIndexOf = assocIndexOf$4;
1082
-
1083
- var assocIndexOf$3 = _assocIndexOf;
1084
-
1085
- /** Used for built-in method references. */
1086
- var arrayProto = Array.prototype;
1087
-
1088
- /** Built-in value references. */
1089
- var splice = arrayProto.splice;
1090
-
1091
- /**
1092
- * Removes `key` and its value from the list cache.
1093
- *
1094
- * @private
1095
- * @name delete
1096
- * @memberOf ListCache
1097
- * @param {string} key The key of the value to remove.
1098
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1099
- */
1100
- function listCacheDelete$1(key) {
1101
- var data = this.__data__,
1102
- index = assocIndexOf$3(data, key);
1103
-
1104
- if (index < 0) {
1105
- return false;
1106
- }
1107
- var lastIndex = data.length - 1;
1108
- if (index == lastIndex) {
1109
- data.pop();
1110
- } else {
1111
- splice.call(data, index, 1);
1112
- }
1113
- --this.size;
1114
- return true;
1115
- }
1116
-
1117
- var _listCacheDelete = listCacheDelete$1;
1118
-
1119
- var assocIndexOf$2 = _assocIndexOf;
1120
-
1121
- /**
1122
- * Gets the list cache value for `key`.
1123
- *
1124
- * @private
1125
- * @name get
1126
- * @memberOf ListCache
1127
- * @param {string} key The key of the value to get.
1128
- * @returns {*} Returns the entry value.
1129
- */
1130
- function listCacheGet$1(key) {
1131
- var data = this.__data__,
1132
- index = assocIndexOf$2(data, key);
1133
-
1134
- return index < 0 ? undefined : data[index][1];
1135
- }
1136
-
1137
- var _listCacheGet = listCacheGet$1;
1138
-
1139
- var assocIndexOf$1 = _assocIndexOf;
1140
-
1141
- /**
1142
- * Checks if a list cache value for `key` exists.
1143
- *
1144
- * @private
1145
- * @name has
1146
- * @memberOf ListCache
1147
- * @param {string} key The key of the entry to check.
1148
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1149
- */
1150
- function listCacheHas$1(key) {
1151
- return assocIndexOf$1(this.__data__, key) > -1;
1152
- }
1153
-
1154
- var _listCacheHas = listCacheHas$1;
1155
-
1156
- var assocIndexOf = _assocIndexOf;
1157
-
1158
- /**
1159
- * Sets the list cache `key` to `value`.
1160
- *
1161
- * @private
1162
- * @name set
1163
- * @memberOf ListCache
1164
- * @param {string} key The key of the value to set.
1165
- * @param {*} value The value to set.
1166
- * @returns {Object} Returns the list cache instance.
1167
- */
1168
- function listCacheSet$1(key, value) {
1169
- var data = this.__data__,
1170
- index = assocIndexOf(data, key);
1171
-
1172
- if (index < 0) {
1173
- ++this.size;
1174
- data.push([key, value]);
1175
- } else {
1176
- data[index][1] = value;
1177
- }
1178
- return this;
1179
- }
1180
-
1181
- var _listCacheSet = listCacheSet$1;
1182
-
1183
- var listCacheClear = _listCacheClear,
1184
- listCacheDelete = _listCacheDelete,
1185
- listCacheGet = _listCacheGet,
1186
- listCacheHas = _listCacheHas,
1187
- listCacheSet = _listCacheSet;
1188
-
1189
- /**
1190
- * Creates an list cache object.
1191
- *
1192
- * @private
1193
- * @constructor
1194
- * @param {Array} [entries] The key-value pairs to cache.
1195
- */
1196
- function ListCache$1(entries) {
1197
- var index = -1,
1198
- length = entries == null ? 0 : entries.length;
1199
-
1200
- this.clear();
1201
- while (++index < length) {
1202
- var entry = entries[index];
1203
- this.set(entry[0], entry[1]);
1204
- }
1205
- }
1206
-
1207
- // Add methods to `ListCache`.
1208
- ListCache$1.prototype.clear = listCacheClear;
1209
- ListCache$1.prototype['delete'] = listCacheDelete;
1210
- ListCache$1.prototype.get = listCacheGet;
1211
- ListCache$1.prototype.has = listCacheHas;
1212
- ListCache$1.prototype.set = listCacheSet;
1213
-
1214
- var _ListCache = ListCache$1;
1215
-
1216
- var getNative$1 = _getNative,
1217
- root$1 = _root;
1218
-
1219
- /* Built-in method references that are verified to be native. */
1220
- var Map$2 = getNative$1(root$1, 'Map');
1221
-
1222
- var _Map = Map$2;
1223
-
1224
- var Hash = _Hash,
1225
- ListCache = _ListCache,
1226
- Map$1 = _Map;
1227
-
1228
- /**
1229
- * Removes all key-value entries from the map.
1230
- *
1231
- * @private
1232
- * @name clear
1233
- * @memberOf MapCache
1234
- */
1235
- function mapCacheClear$1() {
1236
- this.size = 0;
1237
- this.__data__ = {
1238
- 'hash': new Hash,
1239
- 'map': new (Map$1 || ListCache),
1240
- 'string': new Hash
1241
- };
1242
- }
1243
-
1244
- var _mapCacheClear = mapCacheClear$1;
1245
-
1246
- /**
1247
- * Checks if `value` is suitable for use as unique object key.
1248
- *
1249
- * @private
1250
- * @param {*} value The value to check.
1251
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1252
- */
1253
-
1254
- function isKeyable$1(value) {
1255
- var type = typeof value;
1256
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1257
- ? (value !== '__proto__')
1258
- : (value === null);
1259
- }
1260
-
1261
- var _isKeyable = isKeyable$1;
1262
-
1263
- var isKeyable = _isKeyable;
1264
-
1265
- /**
1266
- * Gets the data for `map`.
1267
- *
1268
- * @private
1269
- * @param {Object} map The map to query.
1270
- * @param {string} key The reference key.
1271
- * @returns {*} Returns the map data.
1272
- */
1273
- function getMapData$4(map, key) {
1274
- var data = map.__data__;
1275
- return isKeyable(key)
1276
- ? data[typeof key == 'string' ? 'string' : 'hash']
1277
- : data.map;
1278
- }
1279
-
1280
- var _getMapData = getMapData$4;
1281
-
1282
- var getMapData$3 = _getMapData;
1283
-
1284
- /**
1285
- * Removes `key` and its value from the map.
1286
- *
1287
- * @private
1288
- * @name delete
1289
- * @memberOf MapCache
1290
- * @param {string} key The key of the value to remove.
1291
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1292
- */
1293
- function mapCacheDelete$1(key) {
1294
- var result = getMapData$3(this, key)['delete'](key);
1295
- this.size -= result ? 1 : 0;
1296
- return result;
1297
- }
1298
-
1299
- var _mapCacheDelete = mapCacheDelete$1;
1300
-
1301
- var getMapData$2 = _getMapData;
1302
-
1303
- /**
1304
- * Gets the map value for `key`.
1305
- *
1306
- * @private
1307
- * @name get
1308
- * @memberOf MapCache
1309
- * @param {string} key The key of the value to get.
1310
- * @returns {*} Returns the entry value.
1311
- */
1312
- function mapCacheGet$1(key) {
1313
- return getMapData$2(this, key).get(key);
1314
- }
1315
-
1316
- var _mapCacheGet = mapCacheGet$1;
1317
-
1318
- var getMapData$1 = _getMapData;
1319
-
1320
- /**
1321
- * Checks if a map value for `key` exists.
1322
- *
1323
- * @private
1324
- * @name has
1325
- * @memberOf MapCache
1326
- * @param {string} key The key of the entry to check.
1327
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1328
- */
1329
- function mapCacheHas$1(key) {
1330
- return getMapData$1(this, key).has(key);
1331
- }
1332
-
1333
- var _mapCacheHas = mapCacheHas$1;
1334
-
1335
- var getMapData = _getMapData;
1336
-
1337
- /**
1338
- * Sets the map `key` to `value`.
1339
- *
1340
- * @private
1341
- * @name set
1342
- * @memberOf MapCache
1343
- * @param {string} key The key of the value to set.
1344
- * @param {*} value The value to set.
1345
- * @returns {Object} Returns the map cache instance.
1346
- */
1347
- function mapCacheSet$1(key, value) {
1348
- var data = getMapData(this, key),
1349
- size = data.size;
1350
-
1351
- data.set(key, value);
1352
- this.size += data.size == size ? 0 : 1;
1353
- return this;
1354
- }
1355
-
1356
- var _mapCacheSet = mapCacheSet$1;
1357
-
1358
- var mapCacheClear = _mapCacheClear,
1359
- mapCacheDelete = _mapCacheDelete,
1360
- mapCacheGet = _mapCacheGet,
1361
- mapCacheHas = _mapCacheHas,
1362
- mapCacheSet = _mapCacheSet;
1363
-
1364
- /**
1365
- * Creates a map cache object to store key-value pairs.
1366
- *
1367
- * @private
1368
- * @constructor
1369
- * @param {Array} [entries] The key-value pairs to cache.
1370
- */
1371
- function MapCache$1(entries) {
1372
- var index = -1,
1373
- length = entries == null ? 0 : entries.length;
1374
-
1375
- this.clear();
1376
- while (++index < length) {
1377
- var entry = entries[index];
1378
- this.set(entry[0], entry[1]);
1379
- }
1380
- }
1381
-
1382
- // Add methods to `MapCache`.
1383
- MapCache$1.prototype.clear = mapCacheClear;
1384
- MapCache$1.prototype['delete'] = mapCacheDelete;
1385
- MapCache$1.prototype.get = mapCacheGet;
1386
- MapCache$1.prototype.has = mapCacheHas;
1387
- MapCache$1.prototype.set = mapCacheSet;
1388
-
1389
- var _MapCache = MapCache$1;
1390
-
1391
- /** Used to stand-in for `undefined` hash values. */
1392
-
1393
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
1394
-
1395
- /**
1396
- * Adds `value` to the array cache.
1397
- *
1398
- * @private
1399
- * @name add
1400
- * @memberOf SetCache
1401
- * @alias push
1402
- * @param {*} value The value to cache.
1403
- * @returns {Object} Returns the cache instance.
1404
- */
1405
- function setCacheAdd$1(value) {
1406
- this.__data__.set(value, HASH_UNDEFINED);
1407
- return this;
1408
- }
1409
-
1410
- var _setCacheAdd = setCacheAdd$1;
1411
-
1412
- /**
1413
- * Checks if `value` is in the array cache.
1414
- *
1415
- * @private
1416
- * @name has
1417
- * @memberOf SetCache
1418
- * @param {*} value The value to search for.
1419
- * @returns {number} Returns `true` if `value` is found, else `false`.
1420
- */
1421
-
1422
- function setCacheHas$1(value) {
1423
- return this.__data__.has(value);
1424
- }
1425
-
1426
- var _setCacheHas = setCacheHas$1;
1427
-
1428
- var MapCache = _MapCache,
1429
- setCacheAdd = _setCacheAdd,
1430
- setCacheHas = _setCacheHas;
1431
-
1432
- /**
1433
- *
1434
- * Creates an array cache object to store unique values.
1435
- *
1436
- * @private
1437
- * @constructor
1438
- * @param {Array} [values] The values to cache.
1439
- */
1440
- function SetCache$1(values) {
1441
- var index = -1,
1442
- length = values == null ? 0 : values.length;
1443
-
1444
- this.__data__ = new MapCache;
1445
- while (++index < length) {
1446
- this.add(values[index]);
1447
- }
1448
- }
1449
-
1450
- // Add methods to `SetCache`.
1451
- SetCache$1.prototype.add = SetCache$1.prototype.push = setCacheAdd;
1452
- SetCache$1.prototype.has = setCacheHas;
1453
-
1454
- var _SetCache = SetCache$1;
1455
-
1456
- /**
1457
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
1458
- * support for iteratee shorthands.
1459
- *
1460
- * @private
1461
- * @param {Array} array The array to inspect.
1462
- * @param {Function} predicate The function invoked per iteration.
1463
- * @param {number} fromIndex The index to search from.
1464
- * @param {boolean} [fromRight] Specify iterating from right to left.
1465
- * @returns {number} Returns the index of the matched value, else `-1`.
1466
- */
1467
-
1468
- function baseFindIndex$1(array, predicate, fromIndex, fromRight) {
1469
- var length = array.length,
1470
- index = fromIndex + (fromRight ? 1 : -1);
1471
-
1472
- while ((fromRight ? index-- : ++index < length)) {
1473
- if (predicate(array[index], index, array)) {
1474
- return index;
1475
- }
1476
- }
1477
- return -1;
1478
- }
1479
-
1480
- var _baseFindIndex = baseFindIndex$1;
1481
-
1482
- /**
1483
- * The base implementation of `_.isNaN` without support for number objects.
1484
- *
1485
- * @private
1486
- * @param {*} value The value to check.
1487
- * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
1488
- */
1489
-
1490
- function baseIsNaN$1(value) {
1491
- return value !== value;
1492
- }
1493
-
1494
- var _baseIsNaN = baseIsNaN$1;
1495
-
1496
- /**
1497
- * A specialized version of `_.indexOf` which performs strict equality
1498
- * comparisons of values, i.e. `===`.
1499
- *
1500
- * @private
1501
- * @param {Array} array The array to inspect.
1502
- * @param {*} value The value to search for.
1503
- * @param {number} fromIndex The index to search from.
1504
- * @returns {number} Returns the index of the matched value, else `-1`.
1505
- */
1506
-
1507
- function strictIndexOf$1(array, value, fromIndex) {
1508
- var index = fromIndex - 1,
1509
- length = array.length;
1510
-
1511
- while (++index < length) {
1512
- if (array[index] === value) {
1513
- return index;
1514
- }
1515
- }
1516
- return -1;
1517
- }
1518
-
1519
- var _strictIndexOf = strictIndexOf$1;
1520
-
1521
- var baseFindIndex = _baseFindIndex,
1522
- baseIsNaN = _baseIsNaN,
1523
- strictIndexOf = _strictIndexOf;
1524
-
1525
- /**
1526
- * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
1527
- *
1528
- * @private
1529
- * @param {Array} array The array to inspect.
1530
- * @param {*} value The value to search for.
1531
- * @param {number} fromIndex The index to search from.
1532
- * @returns {number} Returns the index of the matched value, else `-1`.
1533
- */
1534
- function baseIndexOf$1(array, value, fromIndex) {
1535
- return value === value
1536
- ? strictIndexOf(array, value, fromIndex)
1537
- : baseFindIndex(array, baseIsNaN, fromIndex);
1538
- }
1539
-
1540
- var _baseIndexOf = baseIndexOf$1;
1541
-
1542
- var baseIndexOf = _baseIndexOf;
1543
-
1544
- /**
1545
- * A specialized version of `_.includes` for arrays without support for
1546
- * specifying an index to search from.
1547
- *
1548
- * @private
1549
- * @param {Array} [array] The array to inspect.
1550
- * @param {*} target The value to search for.
1551
- * @returns {boolean} Returns `true` if `target` is found, else `false`.
1552
- */
1553
- function arrayIncludes$1(array, value) {
1554
- var length = array == null ? 0 : array.length;
1555
- return !!length && baseIndexOf(array, value, 0) > -1;
1556
- }
1557
-
1558
- var _arrayIncludes = arrayIncludes$1;
1559
-
1560
- /**
1561
- * This function is like `arrayIncludes` except that it accepts a comparator.
1562
- *
1563
- * @private
1564
- * @param {Array} [array] The array to inspect.
1565
- * @param {*} target The value to search for.
1566
- * @param {Function} comparator The comparator invoked per element.
1567
- * @returns {boolean} Returns `true` if `target` is found, else `false`.
1568
- */
1569
-
1570
- function arrayIncludesWith$1(array, value, comparator) {
1571
- var index = -1,
1572
- length = array == null ? 0 : array.length;
1573
-
1574
- while (++index < length) {
1575
- if (comparator(value, array[index])) {
1576
- return true;
1577
- }
1578
- }
1579
- return false;
1580
- }
1581
-
1582
- var _arrayIncludesWith = arrayIncludesWith$1;
1583
-
1584
- /**
1585
- * Checks if a `cache` value for `key` exists.
1586
- *
1587
- * @private
1588
- * @param {Object} cache The cache to query.
1589
- * @param {string} key The key of the entry to check.
1590
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1591
- */
1592
-
1593
- function cacheHas$1(cache, key) {
1594
- return cache.has(key);
1595
- }
1596
-
1597
- var _cacheHas = cacheHas$1;
1598
-
1599
- var getNative = _getNative,
1600
- root = _root;
1601
-
1602
- /* Built-in method references that are verified to be native. */
1603
- var Set$1 = getNative(root, 'Set');
1604
-
1605
- var _Set = Set$1;
1606
-
1607
- /**
1608
- * This method returns `undefined`.
1609
- *
1610
- * @static
1611
- * @memberOf _
1612
- * @since 2.3.0
1613
- * @category Util
1614
- * @example
1615
- *
1616
- * _.times(2, _.noop);
1617
- * // => [undefined, undefined]
1618
- */
1619
-
1620
- function noop$1() {
1621
- // No operation performed.
1622
- }
1623
-
1624
- var noop_1 = noop$1;
1625
-
1626
- /**
1627
- * Converts `set` to an array of its values.
1628
- *
1629
- * @private
1630
- * @param {Object} set The set to convert.
1631
- * @returns {Array} Returns the values.
1632
- */
1633
-
1634
- function setToArray$2(set) {
1635
- var index = -1,
1636
- result = Array(set.size);
1637
-
1638
- set.forEach(function(value) {
1639
- result[++index] = value;
1640
- });
1641
- return result;
1642
- }
1643
-
1644
- var _setToArray = setToArray$2;
1645
-
1646
- var Set = _Set,
1647
- noop = noop_1,
1648
- setToArray$1 = _setToArray;
1649
-
1650
- /** Used as references for various `Number` constants. */
1651
- var INFINITY = 1 / 0;
1652
-
1653
- /**
1654
- * Creates a set object of `values`.
1655
- *
1656
- * @private
1657
- * @param {Array} values The values to add to the set.
1658
- * @returns {Object} Returns the new set.
1659
- */
1660
- var createSet$1 = !(Set && (1 / setToArray$1(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
1661
- return new Set(values);
1662
- };
1663
-
1664
- var _createSet = createSet$1;
1665
-
1666
- var SetCache = _SetCache,
1667
- arrayIncludes = _arrayIncludes,
1668
- arrayIncludesWith = _arrayIncludesWith,
1669
- cacheHas = _cacheHas,
1670
- createSet = _createSet,
1671
- setToArray = _setToArray;
1672
-
1673
- /** Used as the size to enable large array optimizations. */
1674
- var LARGE_ARRAY_SIZE = 200;
1675
-
1676
- /**
1677
- * The base implementation of `_.uniqBy` without support for iteratee shorthands.
1678
- *
1679
- * @private
1680
- * @param {Array} array The array to inspect.
1681
- * @param {Function} [iteratee] The iteratee invoked per element.
1682
- * @param {Function} [comparator] The comparator invoked per element.
1683
- * @returns {Array} Returns the new duplicate free array.
1684
- */
1685
- function baseUniq$1(array, iteratee, comparator) {
1686
- var index = -1,
1687
- includes = arrayIncludes,
1688
- length = array.length,
1689
- isCommon = true,
1690
- result = [],
1691
- seen = result;
1692
-
1693
- if (comparator) {
1694
- isCommon = false;
1695
- includes = arrayIncludesWith;
1696
- }
1697
- else if (length >= LARGE_ARRAY_SIZE) {
1698
- var set = iteratee ? null : createSet(array);
1699
- if (set) {
1700
- return setToArray(set);
1701
- }
1702
- isCommon = false;
1703
- includes = cacheHas;
1704
- seen = new SetCache;
1705
- }
1706
- else {
1707
- seen = iteratee ? [] : result;
1708
- }
1709
- outer:
1710
- while (++index < length) {
1711
- var value = array[index],
1712
- computed = iteratee ? iteratee(value) : value;
1713
-
1714
- value = (comparator || value !== 0) ? value : 0;
1715
- if (isCommon && computed === computed) {
1716
- var seenIndex = seen.length;
1717
- while (seenIndex--) {
1718
- if (seen[seenIndex] === computed) {
1719
- continue outer;
1720
- }
1721
- }
1722
- if (iteratee) {
1723
- seen.push(computed);
1724
- }
1725
- result.push(value);
1726
- }
1727
- else if (!includes(seen, computed, comparator)) {
1728
- if (seen !== result) {
1729
- seen.push(computed);
1730
- }
1731
- result.push(value);
1732
- }
1733
- }
1734
- return result;
1735
- }
1736
-
1737
- var _baseUniq = baseUniq$1;
1738
-
1739
- var baseUniq = _baseUniq;
1740
-
1741
- /**
1742
- * This method is like `_.uniq` except that it accepts `comparator` which
1743
- * is invoked to compare elements of `array`. The order of result values is
1744
- * determined by the order they occur in the array.The comparator is invoked
1745
- * with two arguments: (arrVal, othVal).
1746
- *
1747
- * @static
1748
- * @memberOf _
1749
- * @since 4.0.0
1750
- * @category Array
1751
- * @param {Array} array The array to inspect.
1752
- * @param {Function} [comparator] The comparator invoked per element.
1753
- * @returns {Array} Returns the new duplicate free array.
1754
- * @example
1755
- *
1756
- * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
1757
- *
1758
- * _.uniqWith(objects, _.isEqual);
1759
- * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
1760
- */
1761
- function uniqWith(array, comparator) {
1762
- comparator = typeof comparator == 'function' ? comparator : undefined;
1763
- return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
1764
- }
1765
-
1766
- var uniqWith_1 = uniqWith;
1767
-
1768
- /**
1769
- * 场景解析器
1770
- * @param rawScene 原始场景
1771
- * @param sceneName 场景名称
1772
- * @param sceneUrl 场景url
1773
- * @param assetsPrefetcher
1774
- * @param assetSetter
1775
- * @param ADD_NEXT_ARG_LIST
1776
- * @param SCRIPT_CONFIG_MAP
1777
- * @return {IScene} 解析后的场景
1778
- */
1779
- const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP) => {
1780
- const rawSentenceList = rawScene.replaceAll('\r', '').split('\n'); // 原始句子列表
1781
- // 去分号留到后面去做了,现在注释要单独处理
1782
- const rawSentenceListWithoutEmpty = rawSentenceList;
1783
- // .map((sentence) => sentence.split(";")[0])
1784
- // .filter((sentence) => sentence.trim() !== "");
1785
- let assetsList = []; // 场景资源列表
1786
- let subSceneList = []; // 子场景列表
1787
- const sentenceList = rawSentenceListWithoutEmpty.map((sentence, index) => {
1788
- const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP, index);
1789
- // 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
1790
- assetsList = [...assetsList, ...returnSentence.sentenceAssets];
1791
- subSceneList = [...subSceneList, ...returnSentence.subScene];
1792
- return returnSentence;
1793
- });
1794
- // 开始资源的预加载
1795
- assetsList = uniqWith_1(assetsList); // 去重
1796
- assetsPrefetcher(assetsList);
1797
- return {
1798
- sceneName: sceneName,
1799
- sceneUrl: sceneUrl,
1800
- sentenceList: sentenceList,
1801
- assetsList: assetsList,
1802
- subSceneList: subSceneList, // 子场景列表
1803
- };
1804
- };
1805
-
1806
- function scss2cssinjsParser(scssString) {
1807
- const [classNameStyles, others] = parseCSS(scssString);
1808
- return {
1809
- classNameStyles,
1810
- others,
1811
- };
1812
- }
1813
- /**
1814
- * GPT 4 写的,临时用,以后要重构!!!
1815
- * TODO:用人类智能重构,要是用着一直没问题,也不是不可以 trust AI
1816
- * @param css
1817
- */
1818
- function parseCSS(css) {
1819
- const result = {};
1820
- let specialRules = '';
1821
- let matches;
1822
- // 使用非贪婪匹配,尝试正确处理任意层次的嵌套
1823
- const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
1824
- const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
1825
- while ((matches = classRegex.exec(css)) !== null) {
1826
- const key = matches[1];
1827
- const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
1828
- result[key] = value;
1829
- }
1830
- while ((matches = specialRegex.exec(css)) !== null) {
1831
- specialRules += matches[1].trim() + '\n';
1832
- }
1833
- return [result, specialRules.trim()];
1834
- }
1835
-
1836
529
  /**
1837
530
  * Preprocessor for scene text.
1838
531
  *
@@ -1862,13 +555,11 @@ var webgalParser = (function (exports) {
1862
555
  let lastLineIsMultiline = false;
1863
556
  let thisLineIsMultiline = false;
1864
557
  for (const line of lines) {
1865
- thisLineIsMultiline = false;
1866
- if (canBeMultiline(line)) {
1867
- thisLineIsMultiline = true;
1868
- }
1869
- if (shouldNotBeMultiline(line, lastLineIsMultiline)) {
1870
- thisLineIsMultiline = false;
1871
- }
558
+ // 续行需要接到上一行,所以场景的第一行永远不会是续行。
559
+ thisLineIsMultiline =
560
+ processedLines.length > 0 &&
561
+ canBeMultiline(line) &&
562
+ !shouldNotBeMultiline(line, lastLineIsMultiline);
1872
563
  if (thisLineIsMultiline) {
1873
564
  processedLines[processedLines.length - 1] += '\\';
1874
565
  }
@@ -1926,7 +617,6 @@ var webgalParser = (function (exports) {
1926
617
  placeHolderLines.push(placeholderLine(line));
1927
618
  }
1928
619
  for (const line of lines) {
1929
- console.log(line);
1930
620
  if (line.endsWith('\\')) {
1931
621
  const trueLine = line.slice(0, -1);
1932
622
  if (currentMultilineContent === "") {
@@ -1950,8 +640,24 @@ var webgalParser = (function (exports) {
1950
640
  }
1951
641
  processedLines.push(line);
1952
642
  }
643
+ // 场景末行仍以 \ 结尾时循环里没有机会收尾,在这里把累积的内容补出去。
644
+ if (currentMultilineContent !== "") {
645
+ processedLines.push(currentMultilineContent, ...placeHolderLines);
646
+ }
1953
647
  return processedLines;
1954
648
  }
649
+ /**
650
+ * 占位行的前缀。占位行本身是一条注释,引擎会空跑掉;
651
+ * 它的作用是让预处理后的行数与原始场景一致,从而保持
652
+ * 「解析后语句 index == 文件行号」这一不变量。
653
+ */
654
+ const WEBGAL_LINE_BREAK_MARK = ';_WEBGAL_LINE_BREAK_';
655
+ /**
656
+ * 判断预处理后的某一行是否是占位行,即它是上一条多行语句折叠掉的续行。
657
+ */
658
+ function isLineBreakPlaceholder(processedLine) {
659
+ return processedLine.startsWith(WEBGAL_LINE_BREAK_MARK);
660
+ }
1955
661
  /**
1956
662
  * Placeholder Line. Adding this line preserves the original number of lines
1957
663
  * in the scene text, so that it can be compatible with the graphical editor.
@@ -1960,70 +666,116 @@ var webgalParser = (function (exports) {
1960
666
  * @returns The placeholder line
1961
667
  */
1962
668
  function placeholderLine(content = "") {
1963
- return ";_WEBGAL_LINE_BREAK_" + content;
669
+ return WEBGAL_LINE_BREAK_MARK + content;
670
+ }
671
+
672
+ /**
673
+ * 场景解析器
674
+ * @param rawScene 原始场景
675
+ * @param sceneName 场景名称
676
+ * @param sceneUrl 场景url
677
+ * @param assetsPrefetcher
678
+ * @param assetSetter
679
+ * @param ADD_NEXT_ARG_LIST
680
+ * @param SCRIPT_CONFIG_MAP
681
+ * @return {IScene} 解析后的场景
682
+ */
683
+ const sceneParser = (rawScene, sceneName, sceneUrl, assetsPrefetcher, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP) => {
684
+ // 预处理把多行语句折叠进它的首行,并用占位行补齐被折叠掉的行,
685
+ // 因此这里的行数与原始场景严格一致,「语句 index == 文件行号」始终成立。
686
+ const rawSentenceList = sceneTextPreProcess(rawScene).split('\n'); // 原始句子列表
687
+ // 去分号留到后面去做了,现在注释要单独处理
688
+ const rawSentenceListWithoutEmpty = rawSentenceList;
689
+ // .map((sentence) => sentence.split(";")[0])
690
+ // .filter((sentence) => sentence.trim() !== "");
691
+ let assetsList = []; // 场景资源列表
692
+ let subSceneList = []; // 子场景列表
693
+ const sentenceList = rawSentenceListWithoutEmpty.map((sentence, index) => {
694
+ const returnSentence = scriptParser(sentence, assetSetter, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP, index);
695
+ // 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
696
+ assetsList = [...assetsList, ...returnSentence.sentenceAssets];
697
+ subSceneList = [...subSceneList, ...returnSentence.subScene];
698
+ return returnSentence;
699
+ });
700
+ markMultilineRanges(sentenceList, rawSentenceList);
701
+ // 开始资源的预加载
702
+ assetsList = deduplicateAssets(assetsList);
703
+ assetsPrefetcher(assetsList);
704
+ return {
705
+ sceneName: sceneName,
706
+ sceneUrl: sceneUrl,
707
+ sentenceList: sentenceList,
708
+ assetsList: assetsList,
709
+ subSceneList: subSceneList, // 子场景列表
710
+ };
711
+ };
712
+ /**
713
+ * 回填多行语句的行范围。
714
+ *
715
+ * 预处理后,一条多行语句的完整内容都落在它的首行,紧跟其后的若干占位行
716
+ * 就是被折叠掉的续行。这里把占位行标记出来,并把首行语句的 endLine
717
+ * 推到最后一条续行,图形编辑器据此按整个行范围替换语句。
718
+ *
719
+ * @param sentenceList 解析后的语句列表
720
+ * @param processedLines 预处理后的行,与 sentenceList 一一对应
721
+ */
722
+ const markMultilineRanges = (sentenceList, processedLines) => {
723
+ let headIndex = -1; // 最近一条非占位语句的下标,即当前多行语句的首行
724
+ for (let index = 0; index < sentenceList.length; index++) {
725
+ if (!isLineBreakPlaceholder(processedLines[index])) {
726
+ headIndex = index;
727
+ continue;
728
+ }
729
+ sentenceList[index].isLineBreakHolder = true;
730
+ if (headIndex >= 0) {
731
+ sentenceList[headIndex].endLine = index;
732
+ }
733
+ }
734
+ };
735
+ const deduplicateAssets = (assetsList) => {
736
+ const seenAssets = new Set();
737
+ return assetsList.filter((asset) => {
738
+ if (!asset || typeof asset.url !== 'string' || asset.url === '') {
739
+ return false;
740
+ }
741
+ const assetKey = `${asset.type}:${asset.url}`;
742
+ if (seenAssets.has(assetKey)) {
743
+ return false;
744
+ }
745
+ seenAssets.add(assetKey);
746
+ return true;
747
+ });
748
+ };
749
+
750
+ function scss2cssinjsParser(scssString) {
751
+ const [classNameStyles, others] = parseCSS(scssString);
752
+ return {
753
+ classNameStyles,
754
+ others,
755
+ };
1964
756
  }
1965
- // export function sceneTextPreProcess(sceneText: string): string {
1966
- // const lines = sceneText.replaceAll('\r', '').split('\n');
1967
- // const processedLines: string[] = [];
1968
- // let lastNonMultilineIndex = -1;
1969
- // let isInMultilineSequence = false;
1970
- // function isMultiline(line: string): boolean {
1971
- // if (!line.startsWith(' ')) return false;
1972
- // const trimmedLine = line.trimStart();
1973
- // return trimmedLine.startsWith('|') || trimmedLine.startsWith('-');
1974
- // }
1975
- // for (let i = 0; i < lines.length; i++) {
1976
- // const line = lines[i];
1977
- // if (line.trim() === '') {
1978
- // // Empty line handling
1979
- // if (isInMultilineSequence) {
1980
- // // Check if the next line is a multiline line
1981
- // let isStillInMulti = false;
1982
- // for (let j = i + 1; j < lines.length; j++) {
1983
- // const lookForwardLine = lines[j] || '';
1984
- // // 遇到正常语句了,直接中断
1985
- // if (lookForwardLine.trim() !== '' && !isMultiline(lookForwardLine)) {
1986
- // isStillInMulti = false;
1987
- // break;
1988
- // }
1989
- // // 必须找到后面接的是参数,并且中间没有遇到任何正常语句才行
1990
- // if (lookForwardLine.trim() !== '' && isMultiline(lookForwardLine)) {
1991
- // isStillInMulti = true;
1992
- // break;
1993
- // }
1994
- // }
1995
- // if (isStillInMulti) {
1996
- // // Still within a multiline sequence
1997
- // processedLines.push(';_WEBGAL_LINE_BREAK_');
1998
- // } else {
1999
- // // End of multiline sequence
2000
- // isInMultilineSequence = false;
2001
- // processedLines.push(line);
2002
- // }
2003
- // } else {
2004
- // // Preserve empty lines outside of multiline sequences
2005
- // processedLines.push(line);
2006
- // }
2007
- // } else if (isMultiline(line)) {
2008
- // // Multiline statement handling
2009
- // if (lastNonMultilineIndex >= 0) {
2010
- // // Concatenate to the previous non-multiline statement
2011
- // const trimedLine = line.trimStart();
2012
- // const addBlank = trimedLine.startsWith('-') ? ' ' : '';
2013
- // processedLines[lastNonMultilineIndex] += addBlank + trimedLine;
2014
- // }
2015
- // // Add the special comment line
2016
- // processedLines.push(';_WEBGAL_LINE_BREAK_' + line);
2017
- // isInMultilineSequence = true;
2018
- // } else {
2019
- // // Non-multiline statement handling
2020
- // processedLines.push(line);
2021
- // lastNonMultilineIndex = processedLines.length - 1;
2022
- // isInMultilineSequence = false;
2023
- // }
2024
- // }
2025
- // return processedLines.join('\n');
2026
- // }
757
+ /**
758
+ * GPT 4 写的,临时用,以后要重构!!!
759
+ * TODO:用人类智能重构,要是用着一直没问题,也不是不可以 trust AI
760
+ * @param css
761
+ */
762
+ function parseCSS(css) {
763
+ const result = {};
764
+ let specialRules = '';
765
+ let matches;
766
+ // 使用非贪婪匹配,尝试正确处理任意层次的嵌套
767
+ const classRegex = /\.([^{\s]+)\s*{((?:[^{}]*|{[^}]*})*)}/g;
768
+ const specialRegex = /(@[^{]+{\s*(?:[^{}]*{[^}]*}[^{}]*)+\s*})/g;
769
+ while ((matches = classRegex.exec(css)) !== null) {
770
+ const key = matches[1];
771
+ const value = matches[2].trim().replace(/\s*;\s*/g, ';\n');
772
+ result[key] = value;
773
+ }
774
+ while ((matches = specialRegex.exec(css)) !== null) {
775
+ specialRules += matches[1].trim() + '\n';
776
+ }
777
+ return [result, specialRules.trim()];
778
+ }
2027
779
 
2028
780
  class SceneParser {
2029
781
  assetsPrefetcher;
@@ -2070,7 +822,9 @@ var webgalParser = (function (exports) {
2070
822
 
2071
823
  exports.ADD_NEXT_ARG_LIST = ADD_NEXT_ARG_LIST;
2072
824
  exports.SCRIPT_CONFIG = SCRIPT_CONFIG;
825
+ exports.WEBGAL_LINE_BREAK_MARK = WEBGAL_LINE_BREAK_MARK;
2073
826
  exports.default = SceneParser;
827
+ exports.isLineBreakPlaceholder = isLineBreakPlaceholder;
2074
828
  exports.sceneTextPreProcess = sceneTextPreProcess;
2075
829
 
2076
830
  Object.defineProperty(exports, '__esModule', { value: true });