@ohos-ports/rspack-core 2.2.9-beta.0 → 2.3.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +5 -6
  2. package/compiled/http-proxy-middleware/index.d.ts +10 -10
  3. package/compiled/http-proxy-middleware/package.json +1 -1
  4. package/compiled/watchpack/index.js +276 -49
  5. package/compiled/watchpack/package.json +1 -1
  6. package/compiled/watchpack/types/DirectoryWatcher.d.ts +24 -0
  7. package/compiled/watchpack/types/index.d.ts +1 -1
  8. package/compiled/watchpack/types/watchEventSource.d.ts +9 -0
  9. package/dist/BuildInfo.d.ts +7 -0
  10. package/dist/Compilation.d.ts +3 -1
  11. package/dist/Compiler.d.ts +5 -6
  12. package/dist/ConcatenatedModule.d.ts +5 -1
  13. package/dist/ContextModule.d.ts +3 -1
  14. package/dist/ExternalModule.d.ts +7 -6
  15. package/dist/FileSystemInfo.d.ts +1 -0
  16. package/dist/Module.d.ts +12 -8
  17. package/dist/ModuleGraphConnection.d.ts +9 -3
  18. package/dist/NativeWatchFileSystem.d.ts +19 -7
  19. package/dist/NormalModule.d.ts +14 -6
  20. package/dist/RuntimeTemplate.d.ts +1 -0
  21. package/dist/Stats.d.ts +1 -1
  22. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +3 -2
  23. package/dist/builtin-plugin/ImportedByDeferModulesPlugin.d.ts +9 -0
  24. package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +1 -0
  25. package/dist/builtin-plugin/index.d.ts +1 -0
  26. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +2 -2
  27. package/dist/config/normalization.d.ts +2 -2
  28. package/dist/config/target.d.ts +2 -0
  29. package/dist/config/types.d.ts +57 -35
  30. package/dist/cssExtractHmr.js +1 -1
  31. package/dist/exports.d.ts +3 -3
  32. package/dist/index.js +1140 -842
  33. package/dist/loader-runner/codeFilter.d.ts +9 -0
  34. package/dist/loader-runner/dependencies.d.ts +1 -1
  35. package/dist/loader-runner/index.d.ts +2 -1
  36. package/dist/loader-runner/service.d.ts +0 -4
  37. package/dist/loader-runner/worker.d.ts +4 -1
  38. package/dist/node/NodeWatchFileSystem.d.ts +7 -4
  39. package/dist/sources.d.ts +3 -0
  40. package/dist/stats/statsFactoryUtils.d.ts +7 -0
  41. package/dist/util/bindingHelpers.d.ts +2 -0
  42. package/dist/util/createModule.d.ts +3 -0
  43. package/dist/util/fs.d.ts +13 -7
  44. package/dist/util/resolveLayerExternals.d.ts +1 -0
  45. package/dist/util/source.d.ts +12 -3
  46. package/dist/util/symbols.d.ts +10 -0
  47. package/dist/util/watchTimeInfo.d.ts +5 -1
  48. package/dist/worker.js +323 -325
  49. package/hot/lazy-compilation-node.js +1 -1
  50. package/hot/lazy-compilation-web.js +1 -1
  51. package/package.json +3 -3
  52. package/dist/loader-runner/cache.d.ts +0 -27
package/dist/worker.js CHANGED
@@ -22,7 +22,7 @@ makeNamespaceObject(swc_namespaceObject), definePropertyGetters(swc_namespaceObj
22
22
  transform: ()=>transform,
23
23
  transformSync: ()=>transformSync
24
24
  });
25
- let binding_namespaceObject = __rspack_createRequire_require(process.env.RSPACK_BINDING || "@rspack/binding");
25
+ let binding_namespaceObject = __rspack_createRequire_require(process.env.RSPACK_BINDING || "@ohos-ports/rspack-binding");
26
26
  var binding_default = compatGetDefaultExport(binding_namespaceObject);
27
27
  async function minify(source, options) {
28
28
  let _options = JSON.stringify(options || {});
@@ -40,15 +40,7 @@ function transformSync(source, options) {
40
40
  let _options = JSON.stringify(options || {});
41
41
  return binding_default().transformSync(source, _options);
42
42
  }
43
- let decoder = new TextDecoder(), toObject = (input)=>{
44
- let s;
45
- if (Buffer.isBuffer(input)) s = input.toString('utf8');
46
- else if (input instanceof Uint8Array) s = decoder.decode(input);
47
- else if (input && 'object' == typeof input) return input;
48
- else if ('string' == typeof input) s = input;
49
- else throw Error('Buffer or string or object expected');
50
- return JSON.parse(s);
51
- }, DYNAMIC_INFO = Symbol('cleverMerge dynamic info'), mergeCache = new WeakMap(), DELETE = Symbol('DELETE'), cachedCleverMerge = (first, second)=>{
43
+ let DYNAMIC_INFO = Symbol('cleverMerge dynamic info'), mergeCache = new WeakMap(), DELETE = Symbol('DELETE'), cachedCleverMerge = (first, second)=>{
52
44
  if (void 0 === second) return first;
53
45
  if (void 0 === first || 'object' != typeof second || null === second) return second;
54
46
  if ('object' != typeof first || null === first) return first;
@@ -96,7 +88,7 @@ let decoder = new TextDecoder(), toObject = (input)=>{
96
88
  static: info,
97
89
  dynamic: dynamicInfo
98
90
  };
99
- }, cleverMerge_serializeObject = (info, dynamicInfo)=>{
91
+ }, serializeObject = (info, dynamicInfo)=>{
100
92
  let obj = {};
101
93
  for (let entry of info.values())if (void 0 !== entry.byProperty) {
102
94
  let byObj = obj[entry.byProperty] = obj[entry.byProperty] || {};
@@ -122,7 +114,7 @@ let decoder = new TextDecoder(), toObject = (input)=>{
122
114
  return newFn[DYNAMIC_INFO] = [
123
115
  fn,
124
116
  secondObj
125
- ], cleverMerge_serializeObject(firstObject.static, {
117
+ ], serializeObject(firstObject.static, {
126
118
  byProperty,
127
119
  fn: newFn
128
120
  });
@@ -133,7 +125,7 @@ let decoder = new TextDecoder(), toObject = (input)=>{
133
125
  resultInfo.set(key, entry);
134
126
  }
135
127
  for (let [key, secondEntry] of secondInfo)firstInfo.has(key) || resultInfo.set(key, secondEntry);
136
- return cleverMerge_serializeObject(resultInfo, secondDynamicInfo);
128
+ return serializeObject(resultInfo, secondDynamicInfo);
137
129
  }, mergeEntries = (firstEntry, secondEntry, internalCaching)=>{
138
130
  switch(getValueType(secondEntry.base)){
139
131
  case 1:
@@ -510,7 +502,9 @@ makeCacheable(function(str) {
510
502
  let memoize = (fn)=>{
511
503
  let result, cache = !1, callback = fn;
512
504
  return ()=>(cache || (result = callback(), cache = !0, callback = void 0), result);
513
- }, LoaderLoadingError = class extends Error {
505
+ }, decoder = new TextDecoder('utf-8', {
506
+ fatal: !0
507
+ }), LoaderLoadingError = class extends Error {
514
508
  constructor(message){
515
509
  super(message), this.name = 'LoaderRunnerError', Error.captureStackTrace(this, this.constructor);
516
510
  }
@@ -635,316 +629,7 @@ let utils_runSyncOrAsync = promisify(function(fn, context, args, callback) {
635
629
  if (isDone) return void (e instanceof Error ? console.error(e.stack) : console.error(e));
636
630
  isDone = !0, reportedError = !0, callback(e, []);
637
631
  }
638
- }), loadLoaderAsync = promisify(loadLoader);
639
- async function loaderImpl({ args, loaderContext, loaderState }, sendRequest, waitForPendingRequest) {
640
- let resourcePath = loaderContext.resourcePath, contextDirectory = resourcePath ? function(path) {
641
- if ('/' === path) return '/';
642
- let i = path.lastIndexOf('/'), j = path.lastIndexOf('\\'), i2 = path.indexOf('/'), j2 = path.indexOf('\\'), idx = i > j ? i : j, idx2 = i > j ? i2 : j2;
643
- return idx < 0 ? path : idx === idx2 ? path.slice(0, idx + 1) : path.slice(0, idx);
644
- }(resourcePath) : null, pendingDependencyRequest = [];
645
- loaderContext.parallel = !0, loaderContext.dependency = loaderContext.addDependency = function(file) {
646
- pendingDependencyRequest.push(sendRequest("AddDependency", file));
647
- }, loaderContext.addContextDependency = function(context) {
648
- pendingDependencyRequest.push(sendRequest("AddContextDependency", context));
649
- }, loaderContext.addMissingDependency = function(missing) {
650
- pendingDependencyRequest.push(sendRequest("AddMissingDependency", missing));
651
- }, loaderContext.addBuildDependency = function(file) {
652
- pendingDependencyRequest.push(sendRequest("AddBuildDependency", file));
653
- }, loaderContext.getDependencies = function() {
654
- return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetDependencies").wait();
655
- }, loaderContext.getContextDependencies = function() {
656
- return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetContextDependencies").wait();
657
- }, loaderContext.getMissingDependencies = function() {
658
- return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetMissingDependencies").wait();
659
- }, loaderContext.clearDependencies = function() {
660
- pendingDependencyRequest.push(sendRequest("ClearDependencies"));
661
- };
662
- let beginDependencyChanges = ()=>sendRequest("BeginDependencyChanges"), mergeDependencyChanges = async ()=>{
663
- pendingDependencyRequest.length > 0 && (waitForPendingRequest(pendingDependencyRequest), pendingDependencyRequest.length = 0), await sendRequest("MergeDependencyChanges");
664
- };
665
- loaderContext.resolve = function(context, request, callback) {
666
- sendRequest("Resolve", context, request).then(([result, resolveRequest])=>{
667
- callback(null, result, resolveRequest);
668
- }, (err)=>{
669
- callback(err);
670
- });
671
- }, loaderContext.getResolve = function(options) {
672
- return function(context, request, callback) {
673
- if (!callback) return new Promise((resolve, reject)=>{
674
- sendRequest("GetResolve", options, context, request).then(([result])=>{
675
- resolve(result);
676
- }, (err)=>{
677
- reject(err);
678
- });
679
- });
680
- sendRequest("GetResolve", options, context, request).then(([result, resolveRequest])=>{
681
- callback(null, result, resolveRequest);
682
- }, (err)=>{
683
- callback(err);
684
- });
685
- };
686
- }, loaderContext.getLogger = function(name) {
687
- return {
688
- error (...args) {
689
- sendRequest("GetLogger", 'error', name, args);
690
- },
691
- warn (...args) {
692
- sendRequest("GetLogger", 'warn', name, args);
693
- },
694
- info (...args) {
695
- sendRequest("GetLogger", 'info', name, args);
696
- },
697
- log (...args) {
698
- sendRequest("GetLogger", 'log', name, args);
699
- },
700
- debug (...args) {
701
- sendRequest("GetLogger", 'debug', name, args);
702
- },
703
- assert (assertion, ...args) {
704
- assertion || sendRequest("GetLogger", 'error', name, args);
705
- },
706
- trace () {
707
- sendRequest("GetLogger", 'trace', name, [
708
- 'Trace'
709
- ]);
710
- },
711
- clear () {
712
- sendRequest("GetLogger", 'clear', name, []);
713
- },
714
- status (...args) {
715
- sendRequest("GetLogger", 'status', name, args);
716
- },
717
- group (...args) {
718
- sendRequest("GetLogger", 'group', name, args);
719
- },
720
- groupCollapsed (...args) {
721
- sendRequest("GetLogger", 'groupCollapsed', name, args);
722
- },
723
- groupEnd (...args) {
724
- sendRequest("GetLogger", 'groupEnd', name, args);
725
- },
726
- profile (label) {
727
- sendRequest("GetLogger", 'profile', name, [
728
- label
729
- ]);
730
- },
731
- profileEnd (label) {
732
- sendRequest("GetLogger", 'profileEnd', name, [
733
- label
734
- ]);
735
- },
736
- time (label) {
737
- sendRequest("GetLogger", 'time', name, [
738
- label
739
- ]);
740
- },
741
- timeEnd (label) {
742
- sendRequest("GetLogger", 'timeEnd', name, [
743
- label
744
- ]);
745
- },
746
- timeLog (label, ...args) {
747
- sendRequest("GetLogger", 'timeLog', name, [
748
- label,
749
- ...args
750
- ]);
751
- },
752
- timeAggregate (label) {
753
- sendRequest("GetLogger", 'timeAggregate', name, [
754
- label
755
- ]);
756
- },
757
- timeAggregateEnd (label) {
758
- sendRequest("GetLogger", 'timeAggregateEnd', name, [
759
- label
760
- ]);
761
- }
762
- };
763
- }, loaderContext.emitError = function(err) {
764
- sendRequest("EmitError", serializeError(err));
765
- }, loaderContext.emitWarning = function(warning) {
766
- sendRequest("EmitWarning", serializeError(warning));
767
- }, loaderContext.emitFile = function(name, content, sourceMap, assetInfo) {
768
- sendRequest("EmitFile", name, content, sourceMap, assetInfo);
769
- }, loaderContext.experiments = {
770
- emitDiagnostic (diagnostic) {
771
- sendRequest("EmitDiagnostic", diagnostic);
772
- }
773
- };
774
- let getAbsolutify = memoize(()=>absolutify.bindCache({})), getAbsolutifyInContext = memoize(()=>absolutify.bindContextCache(contextDirectory, {})), getContextify = memoize(()=>contextify.bindCache({})), getContextifyInContext = memoize(()=>contextify.bindContextCache(contextDirectory, {}));
775
- loaderContext.utils = {
776
- absolutify: (context, request)=>context === contextDirectory ? getAbsolutifyInContext()(request) : getAbsolutify()(context, request),
777
- contextify: (context, request)=>context === contextDirectory ? getContextifyInContext()(request) : getContextify()(context, request),
778
- createHash: (type)=>createHash_createHash(type || loaderContext._compilation.outputOptions.hashFunction)
779
- }, loaderContext._compiler = {
780
- ...loaderContext._compiler,
781
- rspack: {
782
- experiments: {
783
- swc: swc_namespaceObject
784
- }
785
- },
786
- webpack: {
787
- util: {
788
- createHash: createHash_createHash,
789
- cleverMerge: cleverMerge
790
- }
791
- }
792
- }, loaderContext._compilation = {
793
- ...loaderContext._compilation,
794
- getPath: (filename, data = {})=>(data.hash || (data = {
795
- hash: loaderContext._compilation.hash ?? void 0,
796
- ...data
797
- }), sendRequest("CompilationGetPath", 'function' == typeof filename ? filename(data) : filename, data).wait()),
798
- getPathWithInfo (filename, data = {}) {
799
- data.hash || (data = {
800
- hash: loaderContext._compilation.hash ?? void 0,
801
- ...data
802
- });
803
- let info = {}, result = sendRequest("CompilationGetPathWithInfo", 'function' == typeof filename ? filename(data, info) : filename, data, info).wait();
804
- return Object.assign(info, result.info), {
805
- path: result.path,
806
- info
807
- };
808
- },
809
- getAssetPath: (filename, data = {})=>sendRequest("CompilationGetAssetPath", 'function' == typeof filename ? filename(data) : filename, data).wait(),
810
- getAssetPathWithInfo (filename, data = {}) {
811
- let info = {}, result = sendRequest("CompilationGetAssetPathWithInfo", 'function' == typeof filename ? filename(data, info) : filename, data, info).wait();
812
- return Object.assign(info, result.info), {
813
- path: result.path,
814
- info
815
- };
816
- }
817
- };
818
- let _module = loaderContext._module, buildInfo = {
819
- ..._module.buildInfo ?? {}
820
- };
821
- loaderContext._module = {
822
- type: _module.type,
823
- identifier: ()=>_module.identifier,
824
- matchResource: _module.matchResource,
825
- request: _module.request,
826
- userRequest: _module.userRequest,
827
- rawRequest: _module.rawRequest,
828
- buildInfo
829
- }, loaderContext.importModule = function(request, options, callback) {
830
- if (!callback) return new Promise((resolve, reject)=>{
831
- sendRequest("ImportModule", request, options).then((result)=>{
832
- resolve(result);
833
- }, (err)=>{
834
- reject(err);
835
- });
836
- });
837
- sendRequest("ImportModule", request, options).then((result)=>{
838
- callback(null, result);
839
- }, (err)=>{
840
- callback(err);
841
- });
842
- }, loaderContext.fs = node_fs, Object.defineProperty(loaderContext, 'request', {
843
- enumerable: !0,
844
- get: ()=>loaderContext.loaders.map((o)=>o.request).concat(loaderContext.resource || '').join('!')
845
- }), Object.defineProperty(loaderContext, 'remainingRequest', {
846
- enumerable: !0,
847
- get: ()=>loaderContext.loaderIndex >= loaderContext.loaders.length - 1 && !loaderContext.resource ? '' : loaderContext.loaders.slice(loaderContext.loaderIndex + 1).map((o)=>o.request).concat(loaderContext.resource || '').join('!')
848
- }), Object.defineProperty(loaderContext, 'currentRequest', {
849
- enumerable: !0,
850
- get: ()=>loaderContext.loaders.slice(loaderContext.loaderIndex).map((o)=>o.request).concat(loaderContext.resource || '').join('!')
851
- }), Object.defineProperty(loaderContext, 'previousRequest', {
852
- enumerable: !0,
853
- get: ()=>loaderContext.loaders.slice(0, loaderContext.loaderIndex).map((o)=>o.request).join('!')
854
- }), Object.defineProperty(loaderContext, 'query', {
855
- enumerable: !0,
856
- get: ()=>{
857
- let entry = loaderContext.loaders[loaderContext.loaderIndex];
858
- return entry.options && 'object' == typeof entry.options ? entry.options : entry.query;
859
- }
860
- }), loaderContext.getOptions = function() {
861
- let loader = function(loaderContext, index = loaderContext.loaderIndex) {
862
- return loaderContext.loaders?.length && index < loaderContext.loaders.length && index >= 0 && loaderContext.loaders[index] ? loaderContext.loaders[index] : null;
863
- }(loaderContext), options = loader?.options;
864
- if ('string' == typeof options) if (options.startsWith('{') && options.endsWith('}')) try {
865
- options = JSON.parse(options);
866
- } catch (e) {
867
- throw Error(`JSON parsing failed for loader's string options: ${e.message}`);
868
- }
869
- else options = node_querystring.parse(options);
870
- return null == options && (options = {}), options;
871
- }, loaderContext.cacheable = function(flag) {
872
- !1 === flag && sendRequest("SetCacheable", !1);
873
- }, Object.defineProperty(loaderContext, 'data', {
874
- enumerable: !0,
875
- get: ()=>loaderContext.loaders[loaderContext.loaderIndex].loaderItem.data,
876
- set: (value)=>{
877
- loaderContext.loaders[loaderContext.loaderIndex].loaderItem.data = value;
878
- }
879
- });
880
- let shouldYieldToMainThread = (currentLoaderObject)=>!!(!currentLoaderObject?.parallel || currentLoaderObject?.request.startsWith('builtin:'));
881
- switch(loaderState){
882
- case binding_namespaceObject.JsLoaderState.Pitching:
883
- for(; loaderContext.loaderIndex < loaderContext.loaders.length;){
884
- let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
885
- if (shouldYieldToMainThread(currentLoaderObject)) break;
886
- if (currentLoaderObject.pitchExecuted) {
887
- loaderContext.loaderIndex += 1;
888
- continue;
889
- }
890
- await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
891
- let fn = currentLoaderObject.pitch;
892
- if ((currentLoaderObject.pitchExecuted = !0, fn) && (args = await utils_runSyncOrAsync(fn, loaderContext, [
893
- loaderContext.remainingRequest,
894
- loaderContext.previousRequest,
895
- currentLoaderObject.loaderItem.data
896
- ]) || []).some((value)=>void 0 !== value)) break;
897
- }
898
- break;
899
- case binding_namespaceObject.JsLoaderState.Normal:
900
- for(; loaderContext.loaderIndex >= 0;){
901
- let cacheResult, currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
902
- if (shouldYieldToMainThread(currentLoaderObject)) break;
903
- if (currentLoaderObject.normalExecuted) {
904
- loaderContext.loaderIndex--;
905
- continue;
906
- }
907
- let trackDependencies = currentLoaderObject.loaderItem.cache;
908
- trackDependencies && await beginDependencyChanges();
909
- try {
910
- if (currentLoaderObject.loaderItem.cache) {
911
- waitForPendingRequest(pendingDependencyRequest);
912
- let result = await sendRequest("LoaderCacheGet", loaderContext.loaderIndex, args[0], args[2]);
913
- if (cacheResult = result, 'hit' === result.type) {
914
- let { entry } = result;
915
- currentLoaderObject.normalExecuted = !0, args = [
916
- 'string' == typeof entry.content ? entry.content : entry.content && Buffer.from(entry.content),
917
- entry.sourceMap ? toObject(Buffer.from(entry.sourceMap)) : void 0,
918
- void 0
919
- ];
920
- continue;
921
- }
922
- }
923
- await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
924
- let fn = currentLoaderObject.normal;
925
- if (currentLoaderObject.normalExecuted = !0, !fn) continue;
926
- !function(args, raw) {
927
- if (!raw && args[0] instanceof Uint8Array) {
928
- var buf;
929
- let isShared, str;
930
- args[0] = (isShared = (buf = args[0]).buffer instanceof SharedArrayBuffer || buf.buffer.constructor?.name === 'SharedArrayBuffer', str = utils_decoder.decode(isShared ? Buffer.from(buf) : buf), 0xfeff === str.charCodeAt(0) ? str.slice(1) : str);
931
- } else raw && 'string' == typeof args[0] && (args[0] = Buffer.from(args[0], 'utf-8'));
932
- raw && args[0] instanceof Uint8Array && !Buffer.isBuffer(args[0]) && (args[0] = Buffer.from(args[0].buffer, args[0].byteOffset, args[0].byteLength));
933
- }(args, !!currentLoaderObject.raw), args = await utils_runSyncOrAsync(fn, loaderContext, args) || [], cacheResult?.type === 'miss' && (waitForPendingRequest(pendingDependencyRequest), await sendRequest("LoaderCacheStore", loaderContext.loaderIndex, args[0], function(map) {
934
- if (null != map) return 'string' == typeof map ? map ? Buffer.from(map) : void 0 : Buffer.from(JSON.stringify(map));
935
- }(args[1]), args[2]));
936
- } finally{
937
- trackDependencies && await mergeDependencyChanges();
938
- }
939
- }
940
- }
941
- return sendRequest("UpdateLoaderObjects", loaderContext.loaders.map((item)=>({
942
- data: item.loaderItem.data,
943
- normalExecuted: item.normalExecuted,
944
- pitchExecuted: item.pitchExecuted
945
- }))), sendRequest("UpdateBuildInfo", buildInfo), args;
946
- }
947
- let nextId = 0, responseCallbacks = {};
632
+ }), loadLoaderAsync = promisify(loadLoader), nextId = 0, responseCallbacks = {};
948
633
  function handleIncomingResponses(workerMessage) {
949
634
  if (isWorkerResponseMessage(workerMessage)) {
950
635
  let { id, data } = workerMessage, callback = responseCallbacks[id];
@@ -992,7 +677,320 @@ export default function(workerOptions) {
992
677
  }), sendRequest), waitFor = (requests)=>sendRequest1.sync("WaitForPendingRequest", (Array.isArray(requests) ? requests : [
993
678
  requests
994
679
  ]).map((request)=>request.id));
995
- loaderImpl(workerOptions, sendRequest1, waitFor).then((data)=>{
680
+ (async function({ args, loaderContext, loaderState }, sendRequest, waitForPendingRequest) {
681
+ let resourcePath = loaderContext.resourcePath, contextDirectory = resourcePath ? function(path) {
682
+ if ('/' === path) return '/';
683
+ let i = path.lastIndexOf('/'), j = path.lastIndexOf('\\'), i2 = path.indexOf('/'), j2 = path.indexOf('\\'), idx = i > j ? i : j, idx2 = i > j ? i2 : j2;
684
+ return idx < 0 ? path : idx === idx2 ? path.slice(0, idx + 1) : path.slice(0, idx);
685
+ }(resourcePath) : null, pendingDependencyRequest = [];
686
+ loaderContext.parallel = !0, loaderContext.dependency = loaderContext.addDependency = function(file) {
687
+ pendingDependencyRequest.push(sendRequest("AddDependency", file));
688
+ }, loaderContext.addContextDependency = function(context) {
689
+ pendingDependencyRequest.push(sendRequest("AddContextDependency", context));
690
+ }, loaderContext.addMissingDependency = function(missing) {
691
+ pendingDependencyRequest.push(sendRequest("AddMissingDependency", missing));
692
+ }, loaderContext.addBuildDependency = function(file) {
693
+ pendingDependencyRequest.push(sendRequest("AddBuildDependency", file));
694
+ }, loaderContext.getDependencies = function() {
695
+ return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetDependencies").wait();
696
+ }, loaderContext.getContextDependencies = function() {
697
+ return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetContextDependencies").wait();
698
+ }, loaderContext.getMissingDependencies = function() {
699
+ return waitForPendingRequest(pendingDependencyRequest), sendRequest("GetMissingDependencies").wait();
700
+ }, loaderContext.clearDependencies = function() {
701
+ pendingDependencyRequest.push(sendRequest("ClearDependencies"));
702
+ }, loaderContext.resolve = function(context, request, callback) {
703
+ sendRequest("Resolve", context, request).then(([result, resolveRequest])=>{
704
+ callback(null, result, resolveRequest);
705
+ }, (err)=>{
706
+ callback(err);
707
+ });
708
+ }, loaderContext.getResolve = function(options) {
709
+ return function(context, request, callback) {
710
+ if (!callback) return new Promise((resolve, reject)=>{
711
+ sendRequest("GetResolve", options, context, request).then(([result])=>{
712
+ resolve(result);
713
+ }, (err)=>{
714
+ reject(err);
715
+ });
716
+ });
717
+ sendRequest("GetResolve", options, context, request).then(([result, resolveRequest])=>{
718
+ callback(null, result, resolveRequest);
719
+ }, (err)=>{
720
+ callback(err);
721
+ });
722
+ };
723
+ }, loaderContext.getLogger = function(name) {
724
+ return {
725
+ error (...args) {
726
+ sendRequest("GetLogger", 'error', name, args);
727
+ },
728
+ warn (...args) {
729
+ sendRequest("GetLogger", 'warn', name, args);
730
+ },
731
+ info (...args) {
732
+ sendRequest("GetLogger", 'info', name, args);
733
+ },
734
+ log (...args) {
735
+ sendRequest("GetLogger", 'log', name, args);
736
+ },
737
+ debug (...args) {
738
+ sendRequest("GetLogger", 'debug', name, args);
739
+ },
740
+ assert (assertion, ...args) {
741
+ assertion || sendRequest("GetLogger", 'error', name, args);
742
+ },
743
+ trace () {
744
+ sendRequest("GetLogger", 'trace', name, [
745
+ 'Trace'
746
+ ]);
747
+ },
748
+ clear () {
749
+ sendRequest("GetLogger", 'clear', name, []);
750
+ },
751
+ status (...args) {
752
+ sendRequest("GetLogger", 'status', name, args);
753
+ },
754
+ group (...args) {
755
+ sendRequest("GetLogger", 'group', name, args);
756
+ },
757
+ groupCollapsed (...args) {
758
+ sendRequest("GetLogger", 'groupCollapsed', name, args);
759
+ },
760
+ groupEnd (...args) {
761
+ sendRequest("GetLogger", 'groupEnd', name, args);
762
+ },
763
+ profile (label) {
764
+ sendRequest("GetLogger", 'profile', name, [
765
+ label
766
+ ]);
767
+ },
768
+ profileEnd (label) {
769
+ sendRequest("GetLogger", 'profileEnd', name, [
770
+ label
771
+ ]);
772
+ },
773
+ time (label) {
774
+ sendRequest("GetLogger", 'time', name, [
775
+ label
776
+ ]);
777
+ },
778
+ timeEnd (label) {
779
+ sendRequest("GetLogger", 'timeEnd', name, [
780
+ label
781
+ ]);
782
+ },
783
+ timeLog (label, ...args) {
784
+ sendRequest("GetLogger", 'timeLog', name, [
785
+ label,
786
+ ...args
787
+ ]);
788
+ },
789
+ timeAggregate (label) {
790
+ sendRequest("GetLogger", 'timeAggregate', name, [
791
+ label
792
+ ]);
793
+ },
794
+ timeAggregateEnd (label) {
795
+ sendRequest("GetLogger", 'timeAggregateEnd', name, [
796
+ label
797
+ ]);
798
+ }
799
+ };
800
+ }, loaderContext.emitError = function(err) {
801
+ sendRequest("EmitError", serializeError(err));
802
+ }, loaderContext.emitWarning = function(warning) {
803
+ sendRequest("EmitWarning", serializeError(warning));
804
+ }, loaderContext.emitFile = function(name, content, sourceMap, assetInfo) {
805
+ sendRequest("EmitFile", name, content, sourceMap, assetInfo);
806
+ }, loaderContext.experiments = {
807
+ emitDiagnostic (diagnostic) {
808
+ sendRequest("EmitDiagnostic", diagnostic);
809
+ }
810
+ };
811
+ let getAbsolutify = memoize(()=>absolutify.bindCache({})), getAbsolutifyInContext = memoize(()=>absolutify.bindContextCache(contextDirectory, {})), getContextify = memoize(()=>contextify.bindCache({})), getContextifyInContext = memoize(()=>contextify.bindContextCache(contextDirectory, {}));
812
+ loaderContext.utils = {
813
+ absolutify: (context, request)=>context === contextDirectory ? getAbsolutifyInContext()(request) : getAbsolutify()(context, request),
814
+ contextify: (context, request)=>context === contextDirectory ? getContextifyInContext()(request) : getContextify()(context, request),
815
+ createHash: (type)=>createHash_createHash(type || loaderContext._compilation.outputOptions.hashFunction)
816
+ }, loaderContext._compiler = {
817
+ ...loaderContext._compiler,
818
+ rspack: {
819
+ experiments: {
820
+ swc: swc_namespaceObject
821
+ }
822
+ },
823
+ webpack: {
824
+ util: {
825
+ createHash: createHash_createHash,
826
+ cleverMerge: cleverMerge
827
+ }
828
+ }
829
+ }, loaderContext._compilation = {
830
+ ...loaderContext._compilation,
831
+ getPath: (filename, data = {})=>(data.hash || (data = {
832
+ hash: loaderContext._compilation.hash ?? void 0,
833
+ ...data
834
+ }), sendRequest("CompilationGetPath", 'function' == typeof filename ? filename(data) : filename, data).wait()),
835
+ getPathWithInfo (filename, data = {}) {
836
+ data.hash || (data = {
837
+ hash: loaderContext._compilation.hash ?? void 0,
838
+ ...data
839
+ });
840
+ let info = {}, result = sendRequest("CompilationGetPathWithInfo", 'function' == typeof filename ? filename(data, info) : filename, data, info).wait();
841
+ return Object.assign(info, result.info), {
842
+ path: result.path,
843
+ info
844
+ };
845
+ },
846
+ getAssetPath: (filename, data = {})=>sendRequest("CompilationGetAssetPath", 'function' == typeof filename ? filename(data) : filename, data).wait(),
847
+ getAssetPathWithInfo (filename, data = {}) {
848
+ let info = {}, result = sendRequest("CompilationGetAssetPathWithInfo", 'function' == typeof filename ? filename(data, info) : filename, data, info).wait();
849
+ return Object.assign(info, result.info), {
850
+ path: result.path,
851
+ info
852
+ };
853
+ }
854
+ };
855
+ let _module = loaderContext._module, buildInfo = {
856
+ ..._module.buildInfo ?? {}
857
+ };
858
+ loaderContext._module = {
859
+ type: _module.type,
860
+ identifier: ()=>_module.identifier,
861
+ matchResource: _module.matchResource,
862
+ request: _module.request,
863
+ userRequest: _module.userRequest,
864
+ rawRequest: _module.rawRequest,
865
+ buildInfo
866
+ }, loaderContext.importModule = function(request, options, callback) {
867
+ if (!callback) return new Promise((resolve, reject)=>{
868
+ sendRequest("ImportModule", request, options).then((result)=>{
869
+ resolve(result);
870
+ }, (err)=>{
871
+ reject(err);
872
+ });
873
+ });
874
+ sendRequest("ImportModule", request, options).then((result)=>{
875
+ callback(null, result);
876
+ }, (err)=>{
877
+ callback(err);
878
+ });
879
+ }, loaderContext.fs = node_fs, Object.defineProperty(loaderContext, 'request', {
880
+ enumerable: !0,
881
+ get: ()=>loaderContext.loaders.map((o)=>o.request).concat(loaderContext.resource || '').join('!')
882
+ }), Object.defineProperty(loaderContext, 'remainingRequest', {
883
+ enumerable: !0,
884
+ get: ()=>loaderContext.loaderIndex >= loaderContext.loaders.length - 1 && !loaderContext.resource ? '' : loaderContext.loaders.slice(loaderContext.loaderIndex + 1).map((o)=>o.request).concat(loaderContext.resource || '').join('!')
885
+ }), Object.defineProperty(loaderContext, 'currentRequest', {
886
+ enumerable: !0,
887
+ get: ()=>loaderContext.loaders.slice(loaderContext.loaderIndex).map((o)=>o.request).concat(loaderContext.resource || '').join('!')
888
+ }), Object.defineProperty(loaderContext, 'previousRequest', {
889
+ enumerable: !0,
890
+ get: ()=>loaderContext.loaders.slice(0, loaderContext.loaderIndex).map((o)=>o.request).join('!')
891
+ }), Object.defineProperty(loaderContext, 'query', {
892
+ enumerable: !0,
893
+ get: ()=>{
894
+ let entry = loaderContext.loaders[loaderContext.loaderIndex];
895
+ return entry.options && 'object' == typeof entry.options ? entry.options : entry.query;
896
+ }
897
+ }), loaderContext.getOptions = function() {
898
+ let loader = function(loaderContext, index = loaderContext.loaderIndex) {
899
+ return loaderContext.loaders?.length && index < loaderContext.loaders.length && index >= 0 && loaderContext.loaders[index] ? loaderContext.loaders[index] : null;
900
+ }(loaderContext), options = loader?.options;
901
+ if ('string' == typeof options) if (options.startsWith('{') && options.endsWith('}')) try {
902
+ options = JSON.parse(options);
903
+ } catch (e) {
904
+ throw Error(`JSON parsing failed for loader's string options: ${e.message}`);
905
+ }
906
+ else options = node_querystring.parse(options);
907
+ return null == options && (options = {}), options;
908
+ }, loaderContext.cacheable = function(flag) {
909
+ !1 === flag && sendRequest("SetCacheable", !1);
910
+ }, Object.defineProperty(loaderContext, 'data', {
911
+ enumerable: !0,
912
+ get: ()=>loaderContext.loaders[loaderContext.loaderIndex].loaderItem.data,
913
+ set: (value)=>{
914
+ loaderContext.loaders[loaderContext.loaderIndex].loaderItem.data = value;
915
+ }
916
+ });
917
+ let shouldYieldToMainThread = (currentLoaderObject)=>!currentLoaderObject?.parallel;
918
+ switch(loaderState){
919
+ case binding_namespaceObject.JsLoaderState.Pitching:
920
+ for(; loaderContext.loaderIndex < loaderContext.loaderChainEnd;){
921
+ let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
922
+ if (shouldYieldToMainThread(currentLoaderObject)) break;
923
+ if (currentLoaderObject.pitchExecuted) {
924
+ loaderContext.loaderIndex += 1;
925
+ continue;
926
+ }
927
+ await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
928
+ let fn = currentLoaderObject.pitch;
929
+ if ((currentLoaderObject.pitchExecuted = !0, fn) && (args = await utils_runSyncOrAsync(fn, loaderContext, [
930
+ loaderContext.remainingRequest,
931
+ loaderContext.previousRequest,
932
+ currentLoaderObject.loaderItem.data
933
+ ]) || []).some((value)=>void 0 !== value)) break;
934
+ }
935
+ break;
936
+ case binding_namespaceObject.JsLoaderState.Normal:
937
+ {
938
+ let codeFilterTextCache = {
939
+ initialized: !1
940
+ };
941
+ for(; loaderContext.loaderIndex >= loaderContext.loaderChainStart;){
942
+ let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
943
+ if (currentLoaderObject.normalExecuted) {
944
+ loaderContext.loaderIndex--;
945
+ continue;
946
+ }
947
+ let { loaderItem } = currentLoaderObject, codeFilter = loaderItem.codeFilter;
948
+ if (codeFilter && !loaderItem.filterMatched) {
949
+ let matched = function(filter, content, cache) {
950
+ let code = function(content, cache) {
951
+ let text;
952
+ if (cache.initialized && cache.content === content) return cache.text ?? null;
953
+ if ('string' == typeof content) text = content;
954
+ else if (content instanceof Uint8Array) try {
955
+ text = decoder.decode(content);
956
+ } catch {
957
+ text = null;
958
+ }
959
+ else text = null;
960
+ return cache.initialized = !0, cache.content = content, cache.text = text, text;
961
+ }(content, cache);
962
+ if (null !== code) {
963
+ let matched;
964
+ return 'string' == typeof filter ? code.includes(filter) : (filter.lastIndex = 0, matched = filter.test(code), filter.lastIndex = 0, matched);
965
+ }
966
+ }(codeFilter, args[0], codeFilterTextCache);
967
+ if (!1 === matched) {
968
+ currentLoaderObject.normalExecuted = !0, loaderContext.loaderIndex--;
969
+ continue;
970
+ }
971
+ matched && (loaderItem.filterMatched = !0);
972
+ }
973
+ if (shouldYieldToMainThread(currentLoaderObject)) break;
974
+ await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
975
+ let fn = currentLoaderObject.normal;
976
+ currentLoaderObject.normalExecuted = !0, fn && (!function(args, raw) {
977
+ if (!raw && args[0] instanceof Uint8Array) {
978
+ var buf;
979
+ let isShared, str;
980
+ args[0] = (isShared = (buf = args[0]).buffer instanceof SharedArrayBuffer || buf.buffer.constructor?.name === 'SharedArrayBuffer', 0xfeff === (str = utils_decoder.decode(isShared ? Buffer.from(buf) : buf)).charCodeAt(0) ? str.slice(1) : str);
981
+ } else raw && 'string' == typeof args[0] && (args[0] = Buffer.from(args[0], 'utf-8'));
982
+ raw && args[0] instanceof Uint8Array && !Buffer.isBuffer(args[0]) && (args[0] = Buffer.from(args[0].buffer, args[0].byteOffset, args[0].byteLength));
983
+ }(args, !!currentLoaderObject.raw), args = await utils_runSyncOrAsync(fn, loaderContext, args) || [], codeFilterTextCache.initialized = !1, codeFilterTextCache.content = void 0, codeFilterTextCache.text = void 0);
984
+ }
985
+ }
986
+ }
987
+ return sendRequest("UpdateLoaderObjects", loaderContext.loaders.map((item)=>({
988
+ data: item.loaderItem.data,
989
+ normalExecuted: item.normalExecuted,
990
+ pitchExecuted: item.pitchExecuted,
991
+ filterMatched: item.loaderItem.filterMatched
992
+ }))), sendRequest("UpdateBuildInfo", buildInfo), args;
993
+ })(workerOptions, sendRequest1, waitFor).then((data)=>{
996
994
  workerData.workerPort.postMessage({
997
995
  type: 'done',
998
996
  data