@module-federation/node 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703

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 (128) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +31 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  3. package/dist/node_modules/.pnpm/webpack@5.104.1_@swc_core@1.7.26_@swc_helpers@0.5.13__esbuild@0.28.1_webpack-cli@5.1.4/node_modules/webpack/types.d.mts +1 -0
  4. package/dist/node_modules/.pnpm/webpack@5.104.1_@swc_core@1.7.26_@swc_helpers@0.5.13__esbuild@0.28.1_webpack-cli@5.1.4/node_modules/webpack/types.d.ts +1 -0
  5. package/dist/plugins/ChunkCorrelationPlugin.js +308 -0
  6. package/dist/plugins/ChunkCorrelationPlugin.js.map +1 -0
  7. package/dist/plugins/ChunkCorrelationPlugin.mjs +305 -0
  8. package/dist/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
  9. package/dist/plugins/createBundlerLogger.js +9 -0
  10. package/dist/plugins/createBundlerLogger.js.map +1 -0
  11. package/dist/plugins/createBundlerLogger.mjs +8 -0
  12. package/dist/plugins/createBundlerLogger.mjs.map +1 -0
  13. package/dist/src/filesystem/stratagies.d.mts +21 -0
  14. package/dist/src/filesystem/stratagies.d.ts +10 -7
  15. package/dist/src/filesystem/stratagies.js +97 -116
  16. package/dist/src/filesystem/stratagies.js.map +1 -1
  17. package/dist/src/filesystem/stratagies.mjs +103 -0
  18. package/dist/src/filesystem/stratagies.mjs.map +1 -0
  19. package/dist/src/index.d.mts +8 -0
  20. package/dist/src/index.d.ts +8 -7
  21. package/dist/src/index.js +16 -22
  22. package/dist/src/index.mjs +9 -0
  23. package/dist/src/plugins/AutomaticPublicPathPlugin.d.mts +12 -0
  24. package/dist/src/plugins/AutomaticPublicPathPlugin.d.ts +9 -7
  25. package/dist/src/plugins/AutomaticPublicPathPlugin.js +26 -35
  26. package/dist/src/plugins/AutomaticPublicPathPlugin.js.map +1 -1
  27. package/dist/src/plugins/AutomaticPublicPathPlugin.mjs +28 -0
  28. package/dist/src/plugins/AutomaticPublicPathPlugin.mjs.map +1 -0
  29. package/dist/src/plugins/ChunkCorrelationPlugin.d.mts +5 -0
  30. package/dist/src/plugins/ChunkCorrelationPlugin.d.ts +4 -61
  31. package/dist/src/plugins/ChunkCorrelationPlugin.js +8 -440
  32. package/dist/src/plugins/ChunkCorrelationPlugin.js.map +1 -1
  33. package/dist/src/plugins/ChunkCorrelationPlugin.mjs +8 -0
  34. package/dist/src/plugins/ChunkCorrelationPlugin.mjs.map +1 -0
  35. package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.mts +21 -0
  36. package/dist/src/plugins/CommonJsChunkLoadingPlugin.d.ts +16 -13
  37. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js +68 -118
  38. package/dist/src/plugins/CommonJsChunkLoadingPlugin.js.map +1 -1
  39. package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs +70 -0
  40. package/dist/src/plugins/CommonJsChunkLoadingPlugin.mjs.map +1 -0
  41. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.mts +44 -0
  42. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.d.ts +37 -34
  43. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js +109 -126
  44. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.js.map +1 -1
  45. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs +110 -0
  46. package/dist/src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.mjs.map +1 -0
  47. package/dist/src/plugins/EntryChunkTrackerPlugin.d.mts +17 -0
  48. package/dist/src/plugins/EntryChunkTrackerPlugin.d.ts +14 -10
  49. package/dist/src/plugins/EntryChunkTrackerPlugin.js +30 -32
  50. package/dist/src/plugins/EntryChunkTrackerPlugin.js.map +1 -1
  51. package/dist/src/plugins/EntryChunkTrackerPlugin.mjs +38 -0
  52. package/dist/src/plugins/EntryChunkTrackerPlugin.mjs.map +1 -0
  53. package/dist/src/plugins/NodeFederationPlugin.d.mts +54 -0
  54. package/dist/src/plugins/NodeFederationPlugin.d.ts +33 -26
  55. package/dist/src/plugins/NodeFederationPlugin.js +72 -84
  56. package/dist/src/plugins/NodeFederationPlugin.js.map +1 -1
  57. package/dist/src/plugins/NodeFederationPlugin.mjs +73 -0
  58. package/dist/src/plugins/NodeFederationPlugin.mjs.map +1 -0
  59. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.mts +13 -0
  60. package/dist/src/plugins/RemotePublicPathRuntimeModule.d.ts +10 -8
  61. package/dist/src/plugins/RemotePublicPathRuntimeModule.js +34 -35
  62. package/dist/src/plugins/RemotePublicPathRuntimeModule.js.map +1 -1
  63. package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs +132 -0
  64. package/dist/src/plugins/RemotePublicPathRuntimeModule.mjs.map +1 -0
  65. package/dist/src/plugins/StreamingTargetPlugin.d.mts +32 -0
  66. package/dist/src/plugins/StreamingTargetPlugin.d.ts +19 -16
  67. package/dist/src/plugins/StreamingTargetPlugin.js +43 -56
  68. package/dist/src/plugins/StreamingTargetPlugin.js.map +1 -1
  69. package/dist/src/plugins/StreamingTargetPlugin.mjs +46 -0
  70. package/dist/src/plugins/StreamingTargetPlugin.mjs.map +1 -0
  71. package/dist/src/plugins/UniversalFederationPlugin.d.mts +49 -0
  72. package/dist/src/plugins/UniversalFederationPlugin.d.ts +26 -23
  73. package/dist/src/plugins/UniversalFederationPlugin.js +62 -81
  74. package/dist/src/plugins/UniversalFederationPlugin.js.map +1 -1
  75. package/dist/src/plugins/UniversalFederationPlugin.mjs +65 -0
  76. package/dist/src/plugins/UniversalFederationPlugin.mjs.map +1 -0
  77. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.mts +9 -0
  78. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.d.ts +6 -3
  79. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js +14 -17
  80. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.js.map +1 -1
  81. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs +23 -0
  82. package/dist/src/plugins/UniverseEntryChunkTrackerPlugin.mjs.map +1 -0
  83. package/dist/src/plugins/webpackChunkUtilities.d.mts +55 -0
  84. package/dist/src/plugins/webpackChunkUtilities.d.ts +14 -9
  85. package/dist/src/plugins/webpackChunkUtilities.js +195 -257
  86. package/dist/src/plugins/webpackChunkUtilities.js.map +1 -1
  87. package/dist/src/plugins/webpackChunkUtilities.mjs +234 -0
  88. package/dist/src/plugins/webpackChunkUtilities.mjs.map +1 -0
  89. package/dist/src/recordDynamicRemoteEntryHashPlugin.d.mts +7 -0
  90. package/dist/src/recordDynamicRemoteEntryHashPlugin.d.ts +5 -2
  91. package/dist/src/recordDynamicRemoteEntryHashPlugin.js +24 -61
  92. package/dist/src/recordDynamicRemoteEntryHashPlugin.js.map +1 -1
  93. package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs +26 -0
  94. package/dist/src/recordDynamicRemoteEntryHashPlugin.mjs.map +1 -0
  95. package/dist/src/runtimePlugin.d.mts +27 -0
  96. package/dist/src/runtimePlugin.d.ts +24 -19
  97. package/dist/src/runtimePlugin.js +214 -252
  98. package/dist/src/runtimePlugin.js.map +1 -1
  99. package/dist/src/runtimePlugin.mjs +226 -0
  100. package/dist/src/runtimePlugin.mjs.map +1 -0
  101. package/dist/src/types/index.d.mts +8 -0
  102. package/dist/src/types/index.d.ts +8 -3
  103. package/dist/src/types/index.js +1 -3
  104. package/dist/src/types/index.mjs +1 -0
  105. package/dist/src/utils/flush-chunks.d.mts +17 -0
  106. package/dist/src/utils/flush-chunks.d.ts +9 -3
  107. package/dist/src/utils/flush-chunks.js +138 -167
  108. package/dist/src/utils/flush-chunks.js.map +1 -1
  109. package/dist/src/utils/flush-chunks.mjs +144 -0
  110. package/dist/src/utils/flush-chunks.mjs.map +1 -0
  111. package/dist/src/utils/hot-reload.d.mts +16 -0
  112. package/dist/src/utils/hot-reload.d.ts +14 -10
  113. package/dist/src/utils/hot-reload.js +178 -264
  114. package/dist/src/utils/hot-reload.js.map +1 -1
  115. package/dist/src/utils/hot-reload.mjs +195 -0
  116. package/dist/src/utils/hot-reload.mjs.map +1 -0
  117. package/dist/src/utils/index.d.mts +3 -0
  118. package/dist/src/utils/index.d.ts +3 -2
  119. package/dist/src/utils/index.js +15 -19
  120. package/dist/src/utils/index.mjs +4 -0
  121. package/package.json +71 -26
  122. package/dist/jest.config.d.ts +0 -11
  123. package/dist/jest.config.js +0 -19
  124. package/dist/jest.config.js.map +0 -1
  125. package/dist/package.json +0 -90
  126. package/dist/src/index.js.map +0 -1
  127. package/dist/src/types/index.js.map +0 -1
  128. package/dist/src/utils/index.js.map +0 -1
@@ -1,128 +1,111 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
4
- const { RuntimeGlobals, RuntimeModule } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack'));
5
- const { getUndoPath } = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/identifier'));
6
- const tapable_1 = require("tapable");
7
- const compileBooleanMatcher = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/compileBooleanMatcher'));
8
- const webpackChunkUtilities_1 = require("./webpackChunkUtilities");
9
- const sdk_1 = require("@module-federation/sdk");
10
- const stratagies_1 = require("../filesystem/stratagies");
11
- const createBundlerLogger = typeof sdk_1.createInfrastructureLogger === 'function'
12
- ? sdk_1.createInfrastructureLogger
13
- : sdk_1.createLogger;
14
- class DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {
15
- constructor(runtimeRequirements, options, chunkLoadingContext) {
16
- super('readFile chunk loading', RuntimeModule.STAGE_ATTACH + 1);
17
- this.hooks = {
18
- strategyCase: new tapable_1.SyncWaterfallHook(['source']),
19
- };
20
- this.logger = createBundlerLogger('[ DynamicFilesystemChunkLoadingRuntimeModule ]');
21
- this.runtimeRequirements = runtimeRequirements;
22
- this.options = options;
23
- this.chunkLoadingContext = chunkLoadingContext;
24
- }
25
- /**
26
- * @private
27
- * @param {Chunk} chunk chunk
28
- * @param {string} rootOutputDir root output directory
29
- * @returns {string} generated code
30
- */
31
- _generateBaseUri(chunk, rootOutputDir) {
32
- const options = chunk.getEntryOptions();
33
- if (options && options.baseUri) {
34
- return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
35
- }
36
- return `${RuntimeGlobals.baseURI} = require("url").pathToFileURL(${rootOutputDir
37
- ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`
38
- : '__filename'});`;
39
- }
40
- /**
41
- * @private
42
- * @param {unknown[]} items item to log
43
- */
44
- _getLogger(...items) {
45
- if (!this.options.debug) {
46
- return '';
47
- }
48
- return `console.log(${items.join(',')});`;
49
- }
50
- /**
51
- * @returns {string} runtime code
52
- */
53
- generate() {
54
- const { remotes = {}, name } = this.options;
55
- const { webpack } = this.chunkLoadingContext;
56
- const { chunkGraph, chunk, compilation } = this;
57
- const { Template } = webpack;
58
- if (!chunkGraph || !chunk || !compilation) {
59
- this.logger.warn('Missing required properties. Returning empty string.');
60
- return '';
61
- }
62
- const infrastructureLogger = compilation.getLogger?.('DynamicFilesystemChunkLoadingRuntimeModule');
63
- if (infrastructureLogger) {
64
- this.logger.setDelegate(infrastructureLogger);
65
- }
66
- const { runtimeTemplate } = compilation;
67
- const jsModulePlugin = webpack?.javascript?.JavascriptModulesPlugin ||
68
- require('webpack/lib/javascript/JavascriptModulesPlugin');
69
- const { chunkHasJs } = jsModulePlugin;
70
- const fn = RuntimeGlobals.ensureChunkHandlers;
71
- const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
72
- const hasJsMatcher = compileBooleanMatcher(conditionMap);
73
- const initialChunkIds = (0, webpackChunkUtilities_1.getInitialChunkIds)(chunk, chunkGraph, chunkHasJs);
74
- const outputName = compilation.getPath(jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions), { chunk, contentHashType: 'javascript' });
75
- const rootOutputDir = getUndoPath(outputName, compilation.outputOptions.path || '', false);
76
- const stateExpression = this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers)
77
- ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`
78
- : undefined;
79
- const dynamicFilesystemChunkLoadingPluginCode = Template.asString([
80
- stratagies_1.fileSystemRunInContextStrategy.toString(),
81
- stratagies_1.httpEvalStrategy.toString(),
82
- stratagies_1.httpVmStrategy.toString(),
83
- 'const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {',
84
- Template.indent([
85
- 'switch (strategyType) {',
86
- Template.indent([
87
- 'case "filesystem": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);',
88
- 'case "http-eval": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);',
89
- 'case "http-vm": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);',
90
- this.hooks.strategyCase.call('default: throw new Error("Invalid strategy type");'),
91
- ]),
92
- '}',
93
- ]),
94
- '};',
95
- ]);
96
- return Template.asString([
97
- dynamicFilesystemChunkLoadingPluginCode,
98
- this.runtimeRequirements.has(RuntimeGlobals.baseURI)
99
- ? this._generateBaseUri(chunk, rootOutputDir)
100
- : '// no baseURI',
101
- '',
102
- '// object to store loaded chunks',
103
- '// "0" means "already loaded", Promise means loading',
104
- `var installedChunks = ${stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''}{`,
105
- Template.indent(Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(',\n')),
106
- '};',
107
- '',
108
- (0, webpackChunkUtilities_1.handleOnChunkLoad)(this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded), runtimeTemplate),
109
- '',
110
- (0, webpackChunkUtilities_1.generateInstallChunk)(runtimeTemplate, this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)),
111
- '',
112
- this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)
113
- ? (0, webpackChunkUtilities_1.generateLoadScript)(runtimeTemplate)
114
- : '// no remote script loader needed',
115
- this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)
116
- ? (0, webpackChunkUtilities_1.generateLoadingCode)(this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers), fn, hasJsMatcher, rootOutputDir, remotes, name)
117
- : '// no chunk loading',
118
- '',
119
- (0, webpackChunkUtilities_1.generateExternalInstallChunkCode)(this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk), this.options.debug),
120
- '',
121
- (0, webpackChunkUtilities_1.generateHmrCode)(this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers), rootOutputDir),
122
- '',
123
- (0, webpackChunkUtilities_1.generateHmrManifestCode)(this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest), rootOutputDir),
124
- ]);
125
- }
126
- }
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_src_plugins_webpackChunkUtilities = require('./webpackChunkUtilities.js');
4
+ const require_createBundlerLogger = require('../../plugins/createBundlerLogger.js');
5
+ const require_src_filesystem_stratagies = require('../filesystem/stratagies.js');
6
+ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
7
+ let tapable = require("tapable");
8
+
9
+ //#region src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts
10
+ const { RuntimeGlobals, RuntimeModule } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
11
+ const { getUndoPath } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/identifier"));
12
+ const compileBooleanMatcher = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/compileBooleanMatcher"));
13
+ var DynamicFilesystemChunkLoadingRuntimeModule = class extends RuntimeModule {
14
+ constructor(runtimeRequirements, options, chunkLoadingContext) {
15
+ super("readFile chunk loading", RuntimeModule.STAGE_ATTACH + 1);
16
+ this.hooks = { strategyCase: new tapable.SyncWaterfallHook(["source"]) };
17
+ this.logger = require_createBundlerLogger.createBundlerLogger("[ DynamicFilesystemChunkLoadingRuntimeModule ]");
18
+ this.runtimeRequirements = runtimeRequirements;
19
+ this.options = options;
20
+ this.chunkLoadingContext = chunkLoadingContext;
21
+ }
22
+ /**
23
+ * @private
24
+ * @param {Chunk} chunk chunk
25
+ * @param {string} rootOutputDir root output directory
26
+ * @returns {string} generated code
27
+ */
28
+ _generateBaseUri(chunk, rootOutputDir) {
29
+ const options = chunk.getEntryOptions();
30
+ if (options && options.baseUri) return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
31
+ return `${RuntimeGlobals.baseURI} = require("url").pathToFileURL(${rootOutputDir ? `__dirname + ${JSON.stringify("/" + rootOutputDir)}` : "__filename"});`;
32
+ }
33
+ /**
34
+ * @private
35
+ * @param {unknown[]} items item to log
36
+ */
37
+ _getLogger(...items) {
38
+ if (!this.options.debug) return "";
39
+ return `console.log(${items.join(",")});`;
40
+ }
41
+ /**
42
+ * @returns {string} runtime code
43
+ */
44
+ generate() {
45
+ const { remotes = {}, name } = this.options;
46
+ const { webpack } = this.chunkLoadingContext;
47
+ const { chunkGraph, chunk, compilation } = this;
48
+ const { Template } = webpack;
49
+ if (!chunkGraph || !chunk || !compilation) {
50
+ this.logger.warn("Missing required properties. Returning empty string.");
51
+ return "";
52
+ }
53
+ const infrastructureLogger = compilation.getLogger?.("DynamicFilesystemChunkLoadingRuntimeModule");
54
+ if (infrastructureLogger) this.logger.setDelegate(infrastructureLogger);
55
+ const { runtimeTemplate } = compilation;
56
+ const jsModulePlugin = webpack?.javascript?.JavascriptModulesPlugin || require("webpack/lib/javascript/JavascriptModulesPlugin");
57
+ const { chunkHasJs } = jsModulePlugin;
58
+ const fn = RuntimeGlobals.ensureChunkHandlers;
59
+ const hasJsMatcher = compileBooleanMatcher(chunkGraph.getChunkConditionMap(chunk, chunkHasJs));
60
+ const initialChunkIds = require_src_plugins_webpackChunkUtilities.getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
61
+ const rootOutputDir = getUndoPath(compilation.getPath(jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions), {
62
+ chunk,
63
+ contentHashType: "javascript"
64
+ }), compilation.outputOptions.path || "", false);
65
+ const stateExpression = this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers) ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm` : void 0;
66
+ const dynamicFilesystemChunkLoadingPluginCode = Template.asString([
67
+ require_src_filesystem_stratagies.fileSystemRunInContextStrategy.toString(),
68
+ require_src_filesystem_stratagies.httpEvalStrategy.toString(),
69
+ require_src_filesystem_stratagies.httpVmStrategy.toString(),
70
+ "const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {",
71
+ Template.indent([
72
+ "switch (strategyType) {",
73
+ Template.indent([
74
+ "case \"filesystem\": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);",
75
+ "case \"http-eval\": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);",
76
+ "case \"http-vm\": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);",
77
+ this.hooks.strategyCase.call("default: throw new Error(\"Invalid strategy type\");")
78
+ ]),
79
+ "}"
80
+ ]),
81
+ "};"
82
+ ]);
83
+ return Template.asString([
84
+ dynamicFilesystemChunkLoadingPluginCode,
85
+ this.runtimeRequirements.has(RuntimeGlobals.baseURI) ? this._generateBaseUri(chunk, rootOutputDir) : "// no baseURI",
86
+ "",
87
+ "// object to store loaded chunks",
88
+ "// \"0\" means \"already loaded\", Promise means loading",
89
+ `var installedChunks = ${stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""}{`,
90
+ Template.indent(Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(",\n")),
91
+ "};",
92
+ "",
93
+ require_src_plugins_webpackChunkUtilities.handleOnChunkLoad(this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded), runtimeTemplate),
94
+ "",
95
+ require_src_plugins_webpackChunkUtilities.generateInstallChunk(runtimeTemplate, this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)),
96
+ "",
97
+ this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) ? require_src_plugins_webpackChunkUtilities.generateLoadScript(runtimeTemplate) : "// no remote script loader needed",
98
+ this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) ? require_src_plugins_webpackChunkUtilities.generateLoadingCode(this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers), fn, hasJsMatcher, rootOutputDir, remotes, name) : "// no chunk loading",
99
+ "",
100
+ require_src_plugins_webpackChunkUtilities.generateExternalInstallChunkCode(this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk), this.options.debug),
101
+ "",
102
+ require_src_plugins_webpackChunkUtilities.generateHmrCode(this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers), rootOutputDir),
103
+ "",
104
+ require_src_plugins_webpackChunkUtilities.generateHmrManifestCode(this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest), rootOutputDir)
105
+ ]);
106
+ }
107
+ };
108
+
109
+ //#endregion
127
110
  exports.default = DynamicFilesystemChunkLoadingRuntimeModule;
128
111
  //# sourceMappingURL=DynamicFilesystemChunkLoadingRuntimeModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DynamicFilesystemChunkLoadingRuntimeModule.js","sourceRoot":"","sources":["../../../src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts"],"names":[],"mappings":";;AAIA,0FAAqF;AACrF,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE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,EACb,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,cAAc,CAAC,yBAAyB,CAAC,EACtE,aAAa,CACd;YACD,EAAE;YACF,IAAA,+CAAuB,EACrB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,cAAc,CAAC,mBAAmB,CAAC,EAChE,aAAa,CACd;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAED,kBAAe,0CAA0C,CAAC"}
1
+ {"version":3,"file":"DynamicFilesystemChunkLoadingRuntimeModule.js","names":["SyncWaterfallHook","createBundlerLogger","getInitialChunkIds","fileSystemRunInContextStrategy","httpEvalStrategy","httpVmStrategy","handleOnChunkLoad","generateInstallChunk","generateLoadScript","generateLoadingCode","generateExternalInstallChunkCode","generateHmrCode","generateHmrManifestCode"],"sources":["../../../src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n*/\nimport type { Chunk, Compiler } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeGlobals, RuntimeModule } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { getUndoPath } = require(\n normalizeWebpackPath('webpack/lib/util/identifier'),\n) as typeof import('webpack/lib/util/identifier');\nimport { SyncWaterfallHook } from 'tapable';\nconst compileBooleanMatcher = require(\n normalizeWebpackPath('webpack/lib/util/compileBooleanMatcher'),\n) as typeof import('webpack/lib/util/compileBooleanMatcher');\nimport {\n generateHmrCode,\n getInitialChunkIds,\n generateLoadingCode,\n generateHmrManifestCode,\n handleOnChunkLoad,\n generateLoadScript,\n generateInstallChunk,\n generateExternalInstallChunkCode,\n} from './webpackChunkUtilities';\nimport { createBundlerLogger } from './createBundlerLogger';\nimport {\n fileSystemRunInContextStrategy,\n httpEvalStrategy,\n httpVmStrategy,\n} from '../filesystem/stratagies';\n\ninterface RemotesByType {\n functional: string[];\n normal: string[];\n}\n\ninterface DynamicFilesystemChunkLoadingRuntimeModuleOptions {\n baseURI: Compiler['options']['output']['publicPath'];\n promiseBaseURI?: string;\n remotes: Record<string, string>;\n name?: string;\n debug?: boolean;\n}\n\ninterface ChunkLoadingContext {\n webpack: Compiler['webpack'];\n}\n\nclass DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {\n private runtimeRequirements: Set<string>;\n private options: DynamicFilesystemChunkLoadingRuntimeModuleOptions;\n private chunkLoadingContext: ChunkLoadingContext;\n hooks = {\n strategyCase: new SyncWaterfallHook(['source']),\n };\n private logger = createBundlerLogger(\n '[ DynamicFilesystemChunkLoadingRuntimeModule ]',\n );\n\n constructor(\n runtimeRequirements: Set<string>,\n options: DynamicFilesystemChunkLoadingRuntimeModuleOptions,\n chunkLoadingContext: ChunkLoadingContext,\n ) {\n super('readFile chunk loading', RuntimeModule.STAGE_ATTACH + 1);\n this.runtimeRequirements = runtimeRequirements;\n\n this.options = options;\n this.chunkLoadingContext = chunkLoadingContext;\n }\n\n /**\n * @private\n * @param {Chunk} chunk chunk\n * @param {string} rootOutputDir root output directory\n * @returns {string} generated code\n */\n _generateBaseUri(chunk: Chunk, rootOutputDir: string) {\n const options = chunk.getEntryOptions();\n if (options && options.baseUri) {\n return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;\n }\n\n return `${RuntimeGlobals.baseURI} = require(\"url\").pathToFileURL(${\n rootOutputDir\n ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`\n : '__filename'\n });`;\n }\n\n /**\n * @private\n * @param {unknown[]} items item to log\n */\n _getLogger(...items: unknown[]) {\n if (!this.options.debug) {\n return '';\n }\n\n return `console.log(${items.join(',')});`;\n }\n\n /**\n * @returns {string} runtime code\n */\n override generate() {\n const { remotes = {}, name } = this.options;\n const { webpack } = this.chunkLoadingContext;\n const { chunkGraph, chunk, compilation } = this;\n const { Template } = webpack;\n if (!chunkGraph || !chunk || !compilation) {\n this.logger.warn('Missing required properties. Returning empty string.');\n return '';\n }\n\n const infrastructureLogger = compilation.getLogger?.(\n 'DynamicFilesystemChunkLoadingRuntimeModule',\n );\n if (infrastructureLogger) {\n this.logger.setDelegate(infrastructureLogger as any);\n }\n\n const { runtimeTemplate } = compilation;\n const jsModulePlugin =\n webpack?.javascript?.JavascriptModulesPlugin ||\n require('webpack/lib/javascript/JavascriptModulesPlugin');\n const { chunkHasJs } = jsModulePlugin;\n const fn = RuntimeGlobals.ensureChunkHandlers;\n\n const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);\n const hasJsMatcher = compileBooleanMatcher(conditionMap);\n const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);\n\n const outputName = compilation.getPath(\n jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions),\n { chunk, contentHashType: 'javascript' },\n );\n const rootOutputDir = getUndoPath(\n outputName,\n compilation.outputOptions.path || '',\n false,\n );\n const stateExpression = this.runtimeRequirements.has(\n RuntimeGlobals.hmrDownloadUpdateHandlers,\n )\n ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`\n : undefined;\n\n const dynamicFilesystemChunkLoadingPluginCode = Template.asString([\n fileSystemRunInContextStrategy.toString(),\n httpEvalStrategy.toString(),\n httpVmStrategy.toString(),\n 'const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {',\n Template.indent([\n 'switch (strategyType) {',\n Template.indent([\n 'case \"filesystem\": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-eval\": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-vm\": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);',\n this.hooks.strategyCase.call(\n 'default: throw new Error(\"Invalid strategy type\");',\n ) as string,\n ]),\n '}',\n ]),\n '};',\n ]);\n\n return Template.asString([\n dynamicFilesystemChunkLoadingPluginCode,\n this.runtimeRequirements.has(RuntimeGlobals.baseURI)\n ? this._generateBaseUri(chunk, rootOutputDir)\n : '// no baseURI',\n '',\n '// object to store loaded chunks',\n '// \"0\" means \"already loaded\", Promise means loading',\n `var installedChunks = ${\n stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''\n }{`,\n Template.indent(\n Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(\n ',\\n',\n ),\n ),\n '};',\n '',\n handleOnChunkLoad(\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n runtimeTemplate,\n ),\n '',\n generateInstallChunk(\n runtimeTemplate,\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n ),\n '',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadScript(runtimeTemplate)\n : '// no remote script loader needed',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadingCode(\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers),\n fn,\n hasJsMatcher,\n rootOutputDir,\n remotes,\n name,\n )\n : '// no chunk loading',\n '',\n generateExternalInstallChunkCode(\n this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk),\n this.options.debug,\n ),\n '',\n generateHmrCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers),\n rootOutputDir,\n ),\n '',\n generateHmrManifestCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest),\n rootOutputDir,\n ),\n ]);\n }\n}\n\nexport default DynamicFilesystemChunkLoadingRuntimeModule;\n"],"mappings":";;;;;;;;;AAKA,MAAM,EAAE,gBAAgB,kBAAkB,gFACnB,UAAU,CAChC;AACD,MAAM,EAAE,gBAAgB,gFACD,8BAA8B,CACpD;AAED,MAAM,wBAAwB,gFACP,yCAAyC,CAC/D;AAmCD,IAAM,6CAAN,cAAyD,cAAc;CAWrE,YACE,qBACA,SACA,qBACA;AACA,QAAM,0BAA0B,cAAc,eAAe,EAAE;eAZzD,EACN,cAAc,IAAIA,0BAAkB,CAAC,SAAS,CAAC,EAChD;gBAC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GAAG,eAAe,sBAAsB,eACxC;EAEJ,MAAM,0CAA0C,SAAS,SAAS;GAChEC,iEAA+B,UAAU;GACzCC,mDAAiB,UAAU;GAC3BC,iDAAe,UAAU;GACzB;GACA,SAAS,OAAO;IACd;IACA,SAAS,OAAO;KACd;KACA;KACA;KACA,KAAK,MAAM,aAAa,KACtB,uDACD;KACF,CAAC;IACF;IACD,CAAC;GACF;GACD,CAAC;AAEF,SAAO,SAAS,SAAS;GACvB;GACA,KAAK,oBAAoB,IAAI,eAAe,QAAQ,GAChD,KAAK,iBAAiB,OAAO,cAAc,GAC3C;GACJ;GACA;GACA;GACA,yBACE,kBAAkB,GAAG,gBAAgB,KAAK,gBAAgB,QAAQ,GACnE;GACD,SAAS,OACP,MAAM,KAAK,kBAAkB,OAAO,GAAG,KAAK,UAAU,GAAG,CAAC,KAAK,CAAC,KAC9D,MACD,CACF;GACD;GACA;GACAC,4DACE,KAAK,oBAAoB,IAAI,eAAe,eAAe,EAC3D,gBACD;GACD;GACAC,+DACE,iBACA,KAAK,oBAAoB,IAAI,eAAe,eAAe,CAC5D;GACD;GACA,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,GAC5DC,6DAAmB,gBAAgB,GACnC;GACJ,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,GAC5DC,8DACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,IACA,cACA,eACA,SACA,KACD,GACD;GACJ;GACAC,2EACE,KAAK,oBAAoB,IAAI,eAAe,qBAAqB,EACjE,KAAK,QAAQ,MACd;GACD;GACAC,0DACE,KAAK,oBAAoB,IAAI,eAAe,0BAA0B,EACtE,cACD;GACD;GACAC,kEACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,cACD;GACF,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { __require } from "../../_virtual/_rolldown/runtime.mjs";
2
+ import { generateExternalInstallChunkCode, generateHmrCode, generateHmrManifestCode, generateInstallChunk, generateLoadScript, generateLoadingCode, getInitialChunkIds, handleOnChunkLoad } from "./webpackChunkUtilities.mjs";
3
+ import { createBundlerLogger } from "../../plugins/createBundlerLogger.mjs";
4
+ import { fileSystemRunInContextStrategy, httpEvalStrategy, httpVmStrategy } from "../filesystem/stratagies.mjs";
5
+ import { normalizeWebpackPath } from "@module-federation/sdk/normalize-webpack-path";
6
+ import { SyncWaterfallHook } from "tapable";
7
+
8
+ //#region src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts
9
+ const { RuntimeGlobals, RuntimeModule } = __require(normalizeWebpackPath("webpack"));
10
+ const { getUndoPath } = __require(normalizeWebpackPath("webpack/lib/util/identifier"));
11
+ const compileBooleanMatcher = __require(normalizeWebpackPath("webpack/lib/util/compileBooleanMatcher"));
12
+ var DynamicFilesystemChunkLoadingRuntimeModule = class extends RuntimeModule {
13
+ constructor(runtimeRequirements, options, chunkLoadingContext) {
14
+ super("readFile chunk loading", RuntimeModule.STAGE_ATTACH + 1);
15
+ this.hooks = { strategyCase: new SyncWaterfallHook(["source"]) };
16
+ this.logger = createBundlerLogger("[ DynamicFilesystemChunkLoadingRuntimeModule ]");
17
+ this.runtimeRequirements = runtimeRequirements;
18
+ this.options = options;
19
+ this.chunkLoadingContext = chunkLoadingContext;
20
+ }
21
+ /**
22
+ * @private
23
+ * @param {Chunk} chunk chunk
24
+ * @param {string} rootOutputDir root output directory
25
+ * @returns {string} generated code
26
+ */
27
+ _generateBaseUri(chunk, rootOutputDir) {
28
+ const options = chunk.getEntryOptions();
29
+ if (options && options.baseUri) return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
30
+ return `${RuntimeGlobals.baseURI} = require("url").pathToFileURL(${rootOutputDir ? `__dirname + ${JSON.stringify("/" + rootOutputDir)}` : "__filename"});`;
31
+ }
32
+ /**
33
+ * @private
34
+ * @param {unknown[]} items item to log
35
+ */
36
+ _getLogger(...items) {
37
+ if (!this.options.debug) return "";
38
+ return `console.log(${items.join(",")});`;
39
+ }
40
+ /**
41
+ * @returns {string} runtime code
42
+ */
43
+ generate() {
44
+ const { remotes = {}, name } = this.options;
45
+ const { webpack } = this.chunkLoadingContext;
46
+ const { chunkGraph, chunk, compilation } = this;
47
+ const { Template } = webpack;
48
+ if (!chunkGraph || !chunk || !compilation) {
49
+ this.logger.warn("Missing required properties. Returning empty string.");
50
+ return "";
51
+ }
52
+ const infrastructureLogger = compilation.getLogger?.("DynamicFilesystemChunkLoadingRuntimeModule");
53
+ if (infrastructureLogger) this.logger.setDelegate(infrastructureLogger);
54
+ const { runtimeTemplate } = compilation;
55
+ const jsModulePlugin = webpack?.javascript?.JavascriptModulesPlugin || __require("webpack/lib/javascript/JavascriptModulesPlugin");
56
+ const { chunkHasJs } = jsModulePlugin;
57
+ const fn = RuntimeGlobals.ensureChunkHandlers;
58
+ const hasJsMatcher = compileBooleanMatcher(chunkGraph.getChunkConditionMap(chunk, chunkHasJs));
59
+ const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
60
+ const rootOutputDir = getUndoPath(compilation.getPath(jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions), {
61
+ chunk,
62
+ contentHashType: "javascript"
63
+ }), compilation.outputOptions.path || "", false);
64
+ const stateExpression = this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers) ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm` : void 0;
65
+ const dynamicFilesystemChunkLoadingPluginCode = Template.asString([
66
+ fileSystemRunInContextStrategy.toString(),
67
+ httpEvalStrategy.toString(),
68
+ httpVmStrategy.toString(),
69
+ "const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {",
70
+ Template.indent([
71
+ "switch (strategyType) {",
72
+ Template.indent([
73
+ "case \"filesystem\": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);",
74
+ "case \"http-eval\": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);",
75
+ "case \"http-vm\": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);",
76
+ this.hooks.strategyCase.call("default: throw new Error(\"Invalid strategy type\");")
77
+ ]),
78
+ "}"
79
+ ]),
80
+ "};"
81
+ ]);
82
+ return Template.asString([
83
+ dynamicFilesystemChunkLoadingPluginCode,
84
+ this.runtimeRequirements.has(RuntimeGlobals.baseURI) ? this._generateBaseUri(chunk, rootOutputDir) : "// no baseURI",
85
+ "",
86
+ "// object to store loaded chunks",
87
+ "// \"0\" means \"already loaded\", Promise means loading",
88
+ `var installedChunks = ${stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""}{`,
89
+ Template.indent(Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(",\n")),
90
+ "};",
91
+ "",
92
+ handleOnChunkLoad(this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded), runtimeTemplate),
93
+ "",
94
+ generateInstallChunk(runtimeTemplate, this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)),
95
+ "",
96
+ this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) ? generateLoadScript(runtimeTemplate) : "// no remote script loader needed",
97
+ this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) ? generateLoadingCode(this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers), fn, hasJsMatcher, rootOutputDir, remotes, name) : "// no chunk loading",
98
+ "",
99
+ generateExternalInstallChunkCode(this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk), this.options.debug),
100
+ "",
101
+ generateHmrCode(this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers), rootOutputDir),
102
+ "",
103
+ generateHmrManifestCode(this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest), rootOutputDir)
104
+ ]);
105
+ }
106
+ };
107
+
108
+ //#endregion
109
+ export { DynamicFilesystemChunkLoadingRuntimeModule as default };
110
+ //# sourceMappingURL=DynamicFilesystemChunkLoadingRuntimeModule.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicFilesystemChunkLoadingRuntimeModule.mjs","names":[],"sources":["../../../src/plugins/DynamicFilesystemChunkLoadingRuntimeModule.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n*/\nimport type { Chunk, Compiler } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nconst { RuntimeGlobals, RuntimeModule } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { getUndoPath } = require(\n normalizeWebpackPath('webpack/lib/util/identifier'),\n) as typeof import('webpack/lib/util/identifier');\nimport { SyncWaterfallHook } from 'tapable';\nconst compileBooleanMatcher = require(\n normalizeWebpackPath('webpack/lib/util/compileBooleanMatcher'),\n) as typeof import('webpack/lib/util/compileBooleanMatcher');\nimport {\n generateHmrCode,\n getInitialChunkIds,\n generateLoadingCode,\n generateHmrManifestCode,\n handleOnChunkLoad,\n generateLoadScript,\n generateInstallChunk,\n generateExternalInstallChunkCode,\n} from './webpackChunkUtilities';\nimport { createBundlerLogger } from './createBundlerLogger';\nimport {\n fileSystemRunInContextStrategy,\n httpEvalStrategy,\n httpVmStrategy,\n} from '../filesystem/stratagies';\n\ninterface RemotesByType {\n functional: string[];\n normal: string[];\n}\n\ninterface DynamicFilesystemChunkLoadingRuntimeModuleOptions {\n baseURI: Compiler['options']['output']['publicPath'];\n promiseBaseURI?: string;\n remotes: Record<string, string>;\n name?: string;\n debug?: boolean;\n}\n\ninterface ChunkLoadingContext {\n webpack: Compiler['webpack'];\n}\n\nclass DynamicFilesystemChunkLoadingRuntimeModule extends RuntimeModule {\n private runtimeRequirements: Set<string>;\n private options: DynamicFilesystemChunkLoadingRuntimeModuleOptions;\n private chunkLoadingContext: ChunkLoadingContext;\n hooks = {\n strategyCase: new SyncWaterfallHook(['source']),\n };\n private logger = createBundlerLogger(\n '[ DynamicFilesystemChunkLoadingRuntimeModule ]',\n );\n\n constructor(\n runtimeRequirements: Set<string>,\n options: DynamicFilesystemChunkLoadingRuntimeModuleOptions,\n chunkLoadingContext: ChunkLoadingContext,\n ) {\n super('readFile chunk loading', RuntimeModule.STAGE_ATTACH + 1);\n this.runtimeRequirements = runtimeRequirements;\n\n this.options = options;\n this.chunkLoadingContext = chunkLoadingContext;\n }\n\n /**\n * @private\n * @param {Chunk} chunk chunk\n * @param {string} rootOutputDir root output directory\n * @returns {string} generated code\n */\n _generateBaseUri(chunk: Chunk, rootOutputDir: string) {\n const options = chunk.getEntryOptions();\n if (options && options.baseUri) {\n return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;\n }\n\n return `${RuntimeGlobals.baseURI} = require(\"url\").pathToFileURL(${\n rootOutputDir\n ? `__dirname + ${JSON.stringify('/' + rootOutputDir)}`\n : '__filename'\n });`;\n }\n\n /**\n * @private\n * @param {unknown[]} items item to log\n */\n _getLogger(...items: unknown[]) {\n if (!this.options.debug) {\n return '';\n }\n\n return `console.log(${items.join(',')});`;\n }\n\n /**\n * @returns {string} runtime code\n */\n override generate() {\n const { remotes = {}, name } = this.options;\n const { webpack } = this.chunkLoadingContext;\n const { chunkGraph, chunk, compilation } = this;\n const { Template } = webpack;\n if (!chunkGraph || !chunk || !compilation) {\n this.logger.warn('Missing required properties. Returning empty string.');\n return '';\n }\n\n const infrastructureLogger = compilation.getLogger?.(\n 'DynamicFilesystemChunkLoadingRuntimeModule',\n );\n if (infrastructureLogger) {\n this.logger.setDelegate(infrastructureLogger as any);\n }\n\n const { runtimeTemplate } = compilation;\n const jsModulePlugin =\n webpack?.javascript?.JavascriptModulesPlugin ||\n require('webpack/lib/javascript/JavascriptModulesPlugin');\n const { chunkHasJs } = jsModulePlugin;\n const fn = RuntimeGlobals.ensureChunkHandlers;\n\n const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);\n const hasJsMatcher = compileBooleanMatcher(conditionMap);\n const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);\n\n const outputName = compilation.getPath(\n jsModulePlugin.getChunkFilenameTemplate(chunk, compilation.outputOptions),\n { chunk, contentHashType: 'javascript' },\n );\n const rootOutputDir = getUndoPath(\n outputName,\n compilation.outputOptions.path || '',\n false,\n );\n const stateExpression = this.runtimeRequirements.has(\n RuntimeGlobals.hmrDownloadUpdateHandlers,\n )\n ? `${RuntimeGlobals.hmrRuntimeStatePrefix}_readFileVm`\n : undefined;\n\n const dynamicFilesystemChunkLoadingPluginCode = Template.asString([\n fileSystemRunInContextStrategy.toString(),\n httpEvalStrategy.toString(),\n httpVmStrategy.toString(),\n 'const loadChunkStrategy = async (strategyType,chunkId,rootOutputDir, remotes, callback) => {',\n Template.indent([\n 'switch (strategyType) {',\n Template.indent([\n 'case \"filesystem\": return await fileSystemRunInContextStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-eval\": return await httpEvalStrategy(chunkId,rootOutputDir, remotes, callback);',\n 'case \"http-vm\": return await httpVmStrategy(chunkId,rootOutputDir, remotes, callback);',\n this.hooks.strategyCase.call(\n 'default: throw new Error(\"Invalid strategy type\");',\n ) as string,\n ]),\n '}',\n ]),\n '};',\n ]);\n\n return Template.asString([\n dynamicFilesystemChunkLoadingPluginCode,\n this.runtimeRequirements.has(RuntimeGlobals.baseURI)\n ? this._generateBaseUri(chunk, rootOutputDir)\n : '// no baseURI',\n '',\n '// object to store loaded chunks',\n '// \"0\" means \"already loaded\", Promise means loading',\n `var installedChunks = ${\n stateExpression ? `${stateExpression} = ${stateExpression} || ` : ''\n }{`,\n Template.indent(\n Array.from(initialChunkIds, (id) => `${JSON.stringify(id)}: 0`).join(\n ',\\n',\n ),\n ),\n '};',\n '',\n handleOnChunkLoad(\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n runtimeTemplate,\n ),\n '',\n generateInstallChunk(\n runtimeTemplate,\n this.runtimeRequirements.has(RuntimeGlobals.onChunksLoaded),\n ),\n '',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadScript(runtimeTemplate)\n : '// no remote script loader needed',\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)\n ? generateLoadingCode(\n this.runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers),\n fn,\n hasJsMatcher,\n rootOutputDir,\n remotes,\n name,\n )\n : '// no chunk loading',\n '',\n generateExternalInstallChunkCode(\n this.runtimeRequirements.has(RuntimeGlobals.externalInstallChunk),\n this.options.debug,\n ),\n '',\n generateHmrCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers),\n rootOutputDir,\n ),\n '',\n generateHmrManifestCode(\n this.runtimeRequirements.has(RuntimeGlobals.hmrDownloadManifest),\n rootOutputDir,\n ),\n ]);\n }\n}\n\nexport default DynamicFilesystemChunkLoadingRuntimeModule;\n"],"mappings":";;;;;;;;AAKA,MAAM,EAAE,gBAAgB,4BACtB,qBAAqB,UAAU,CAChC;AACD,MAAM,EAAE,0BACN,qBAAqB,8BAA8B,CACpD;AAED,MAAM,kCACJ,qBAAqB,yCAAyC,CAC/D;AAmCD,IAAM,6CAAN,cAAyD,cAAc;CAWrE,YACE,qBACA,SACA,qBACA;AACA,QAAM,0BAA0B,cAAc,eAAe,EAAE;eAZzD,EACN,cAAc,IAAI,kBAAkB,CAAC,SAAS,CAAC,EAChD;gBACgB,oBACf,iDACD;AAQC,OAAK,sBAAsB;AAE3B,OAAK,UAAU;AACf,OAAK,sBAAsB;;;;;;;;CAS7B,iBAAiB,OAAc,eAAuB;EACpD,MAAM,UAAU,MAAM,iBAAiB;AACvC,MAAI,WAAW,QAAQ,QACrB,QAAO,GAAG,eAAe,QAAQ,KAAK,KAAK,UAAU,QAAQ,QAAQ,CAAC;AAGxE,SAAO,GAAG,eAAe,QAAQ,kCAC/B,gBACI,eAAe,KAAK,UAAU,MAAM,cAAc,KAClD,aACL;;;;;;CAOH,WAAW,GAAG,OAAkB;AAC9B,MAAI,CAAC,KAAK,QAAQ,MAChB,QAAO;AAGT,SAAO,eAAe,MAAM,KAAK,IAAI,CAAC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P,MAAM,KAAK,kBAAkB,OAAO,GAAG,KAAK,UAAU,GAAG,CAAC,KAAK,CAAC,KAC9D,MACD,CACF;GACD;GACA;GACA,kBACE,KAAK,oBAAoB,IAAI,eAAe,eAAe,EAC3D,gBACD;GACD;GACA,qBACE,iBACA,KAAK,oBAAoB,IAAI,eAAe,eAAe,CAC5D;GACD;GACA,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,GAC5D,mBAAmB,gBAAgB,GACnC;GACJ,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,GAC5D,oBACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,IACA,cACA,eACA,SACA,KACD,GACD;GACJ;GACA,iCACE,KAAK,oBAAoB,IAAI,eAAe,qBAAqB,EACjE,KAAK,QAAQ,MACd;GACD;GACA,gBACE,KAAK,oBAAoB,IAAI,eAAe,0BAA0B,EACtE,cACD;GACD;GACA,wBACE,KAAK,oBAAoB,IAAI,eAAe,oBAAoB,EAChE,cACD;GACF,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Chunk, Compiler, Module } from "webpack";
2
+
3
+ //#region src/plugins/EntryChunkTrackerPlugin.d.ts
4
+ interface Options {
5
+ eager?: RegExp | ((module: Module) => boolean);
6
+ excludeChunk?: (chunk: Chunk) => boolean;
7
+ }
8
+ declare class EntryChunkTrackerPlugin {
9
+ private _options;
10
+ constructor(options?: Options);
11
+ apply(compiler: Compiler): void;
12
+ private _handleRenderStartup;
13
+ private _getTemplateString;
14
+ }
15
+ //#endregion
16
+ export { Options, EntryChunkTrackerPlugin as default };
17
+ //# sourceMappingURL=EntryChunkTrackerPlugin.d.mts.map
@@ -1,13 +1,17 @@
1
- import type { Compiler, Chunk, Module } from 'webpack';
2
- export interface Options {
3
- eager?: RegExp | ((module: Module) => boolean);
4
- excludeChunk?: (chunk: Chunk) => boolean;
1
+ import { Chunk, Compiler, Module } from "webpack";
2
+
3
+ //#region src/plugins/EntryChunkTrackerPlugin.d.ts
4
+ interface Options {
5
+ eager?: RegExp | ((module: Module) => boolean);
6
+ excludeChunk?: (chunk: Chunk) => boolean;
5
7
  }
6
8
  declare class EntryChunkTrackerPlugin {
7
- private _options;
8
- constructor(options?: Options);
9
- apply(compiler: Compiler): void;
10
- private _handleRenderStartup;
11
- private _getTemplateString;
9
+ private _options;
10
+ constructor(options?: Options);
11
+ apply(compiler: Compiler): void;
12
+ private _handleRenderStartup;
13
+ private _getTemplateString;
12
14
  }
13
- export default EntryChunkTrackerPlugin;
15
+ //#endregion
16
+ export { Options, EntryChunkTrackerPlugin as default };
17
+ //# sourceMappingURL=EntryChunkTrackerPlugin.d.ts.map
@@ -1,30 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
4
- const SortableSet = require((0, normalize_webpack_path_1.normalizeWebpackPath)('webpack/lib/util/SortableSet'));
5
- class EntryChunkTrackerPlugin {
6
- constructor(options) {
7
- this._options = options || {};
8
- }
9
- apply(compiler) {
10
- compiler.hooks.thisCompilation.tap('EntryChunkTrackerPlugin', (compilation) => {
11
- this._handleRenderStartup(compiler, compilation);
12
- });
13
- }
14
- _handleRenderStartup(compiler, compilation) {
15
- compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderStartup.tap('EntryChunkTrackerPlugin', (source, _renderContext, upperContext) => {
16
- if (this._options.excludeChunk &&
17
- this._options.excludeChunk(upperContext.chunk)) {
18
- return source;
19
- }
20
- const templateString = this._getTemplateString(compiler, source);
21
- return new compiler.webpack.sources.ConcatSource(templateString);
22
- });
23
- }
24
- _getTemplateString(compiler, source) {
25
- const { Template } = compiler.webpack;
26
- return Template.asString([
27
- `if(typeof module !== 'undefined') {
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
4
+
5
+ //#region src/plugins/EntryChunkTrackerPlugin.ts
6
+ require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/SortableSet"));
7
+ var EntryChunkTrackerPlugin = class {
8
+ constructor(options) {
9
+ this._options = options || {};
10
+ }
11
+ apply(compiler) {
12
+ compiler.hooks.thisCompilation.tap("EntryChunkTrackerPlugin", (compilation) => {
13
+ this._handleRenderStartup(compiler, compilation);
14
+ });
15
+ }
16
+ _handleRenderStartup(compiler, compilation) {
17
+ compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderStartup.tap("EntryChunkTrackerPlugin", (source, _renderContext, upperContext) => {
18
+ if (this._options.excludeChunk && this._options.excludeChunk(upperContext.chunk)) return source;
19
+ const templateString = this._getTemplateString(compiler, source);
20
+ return new compiler.webpack.sources.ConcatSource(templateString);
21
+ });
22
+ }
23
+ _getTemplateString(compiler, source) {
24
+ const { Template } = compiler.webpack;
25
+ return Template.asString([`if(typeof module !== 'undefined') {
28
26
  globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();
29
27
  module.filename && globalThis.entryChunkCache.add(module.filename);
30
28
  if(module.children) {
@@ -32,10 +30,10 @@ class EntryChunkTrackerPlugin {
32
30
  c.filename && globalThis.entryChunkCache.add(c.filename);
33
31
  })
34
32
  }
35
- }`,
36
- Template.indent(source.source().toString()),
37
- ]);
38
- }
39
- }
33
+ }`, Template.indent(source.source().toString())]);
34
+ }
35
+ };
36
+
37
+ //#endregion
40
38
  exports.default = EntryChunkTrackerPlugin;
41
39
  //# sourceMappingURL=EntryChunkTrackerPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EntryChunkTrackerPlugin.js","sourceRoot":"","sources":["../../../src/plugins/EntryChunkTrackerPlugin.ts"],"names":[],"mappings":";;AAAA,0FAAqF;AAYrF,MAAM,WAAW,GAAG,OAAO,CACzB,IAAA,6CAAoB,EAAC,8BAA8B,CAAC,CACJ,CAAC;AAqB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ryChunkTrackerPlugin.js","names":[],"sources":["../../../src/plugins/EntryChunkTrackerPlugin.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type {\n Compiler,\n Compilation,\n Chunk,\n sources,\n Module,\n RuntimeGlobals,\n javascript,\n} from 'webpack';\nimport type { SyncWaterfallHook } from 'tapable';\n\nconst SortableSet = require(\n normalizeWebpackPath('webpack/lib/util/SortableSet'),\n) as typeof import('webpack/lib/util/SortableSet');\n\ntype CompilationHooksJavascriptModulesPlugin = ReturnType<\n typeof javascript.JavascriptModulesPlugin.getCompilationHooks\n>;\ntype RenderStartup = CompilationHooksJavascriptModulesPlugin['renderStartup'];\n\ntype InferStartupRenderContext<T> =\n T extends SyncWaterfallHook<\n [infer Source, infer Module, infer StartupRenderContext]\n >\n ? StartupRenderContext\n : never;\n\ntype StartupRenderContext = InferStartupRenderContext<RenderStartup>;\n\nexport interface Options {\n eager?: RegExp | ((module: Module) => boolean);\n excludeChunk?: (chunk: Chunk) => boolean;\n}\n\nclass EntryChunkTrackerPlugin {\n private _options: Options;\n\n constructor(options?: Options) {\n this._options = options || {};\n }\n\n apply(compiler: Compiler) {\n compiler.hooks.thisCompilation.tap(\n 'EntryChunkTrackerPlugin',\n (compilation: Compilation) => {\n this._handleRenderStartup(compiler, compilation);\n },\n );\n }\n private _handleRenderStartup(compiler: Compiler, compilation: Compilation) {\n compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(\n compilation,\n ).renderStartup.tap(\n 'EntryChunkTrackerPlugin',\n (\n source: sources.Source,\n _renderContext: Module,\n upperContext: StartupRenderContext,\n ) => {\n if (\n this._options.excludeChunk &&\n this._options.excludeChunk(upperContext.chunk)\n ) {\n return source;\n }\n\n const templateString = this._getTemplateString(compiler, source);\n\n return new compiler.webpack.sources.ConcatSource(templateString);\n },\n );\n }\n\n private _getTemplateString(compiler: Compiler, source: sources.Source) {\n const { Template } = compiler.webpack;\n return Template.asString([\n `if(typeof module !== 'undefined') {\n globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();\n module.filename && globalThis.entryChunkCache.add(module.filename);\n if(module.children) {\n module.children.forEach(function(c) {\n c.filename && globalThis.entryChunkCache.add(c.filename);\n })\n}\n }`,\n Template.indent(source.source().toString()),\n ]);\n }\n}\n\nexport default EntryChunkTrackerPlugin;\n"],"mappings":";;;;;AAYoB,gFACG,+BAA+B,CACrD;AAqBD,IAAM,0BAAN,MAA8B;CAG5B,YAAY,SAAmB;AAC7B,OAAK,WAAW,WAAW,EAAE;;CAG/B,MAAM,UAAoB;AACxB,WAAS,MAAM,gBAAgB,IAC7B,4BACC,gBAA6B;AAC5B,QAAK,qBAAqB,UAAU,YAAY;IAEnD;;CAEH,AAAQ,qBAAqB,UAAoB,aAA0B;AACzE,WAAS,QAAQ,WAAW,wBAAwB,oBAClD,YACD,CAAC,cAAc,IACd,4BAEE,QACA,gBACA,iBACG;AACH,OACE,KAAK,SAAS,gBACd,KAAK,SAAS,aAAa,aAAa,MAAM,CAE9C,QAAO;GAGT,MAAM,iBAAiB,KAAK,mBAAmB,UAAU,OAAO;AAEhE,UAAO,IAAI,SAAS,QAAQ,QAAQ,aAAa,eAAe;IAEnE;;CAGH,AAAQ,mBAAmB,UAAoB,QAAwB;EACrE,MAAM,EAAE,aAAa,SAAS;AAC9B,SAAO,SAAS,SAAS,CACvB;;;;;;;;UASA,SAAS,OAAO,OAAO,QAAQ,CAAC,UAAU,CAAC,CAC5C,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { __require } from "../../_virtual/_rolldown/runtime.mjs";
2
+ import { normalizeWebpackPath } from "@module-federation/sdk/normalize-webpack-path";
3
+
4
+ //#region src/plugins/EntryChunkTrackerPlugin.ts
5
+ __require(normalizeWebpackPath("webpack/lib/util/SortableSet"));
6
+ var EntryChunkTrackerPlugin = class {
7
+ constructor(options) {
8
+ this._options = options || {};
9
+ }
10
+ apply(compiler) {
11
+ compiler.hooks.thisCompilation.tap("EntryChunkTrackerPlugin", (compilation) => {
12
+ this._handleRenderStartup(compiler, compilation);
13
+ });
14
+ }
15
+ _handleRenderStartup(compiler, compilation) {
16
+ compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(compilation).renderStartup.tap("EntryChunkTrackerPlugin", (source, _renderContext, upperContext) => {
17
+ if (this._options.excludeChunk && this._options.excludeChunk(upperContext.chunk)) return source;
18
+ const templateString = this._getTemplateString(compiler, source);
19
+ return new compiler.webpack.sources.ConcatSource(templateString);
20
+ });
21
+ }
22
+ _getTemplateString(compiler, source) {
23
+ const { Template } = compiler.webpack;
24
+ return Template.asString([`if(typeof module !== 'undefined') {
25
+ globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();
26
+ module.filename && globalThis.entryChunkCache.add(module.filename);
27
+ if(module.children) {
28
+ module.children.forEach(function(c) {
29
+ c.filename && globalThis.entryChunkCache.add(c.filename);
30
+ })
31
+ }
32
+ }`, Template.indent(source.source().toString())]);
33
+ }
34
+ };
35
+
36
+ //#endregion
37
+ export { EntryChunkTrackerPlugin as default };
38
+ //# sourceMappingURL=EntryChunkTrackerPlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntryChunkTrackerPlugin.mjs","names":[],"sources":["../../../src/plugins/EntryChunkTrackerPlugin.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type {\n Compiler,\n Compilation,\n Chunk,\n sources,\n Module,\n RuntimeGlobals,\n javascript,\n} from 'webpack';\nimport type { SyncWaterfallHook } from 'tapable';\n\nconst SortableSet = require(\n normalizeWebpackPath('webpack/lib/util/SortableSet'),\n) as typeof import('webpack/lib/util/SortableSet');\n\ntype CompilationHooksJavascriptModulesPlugin = ReturnType<\n typeof javascript.JavascriptModulesPlugin.getCompilationHooks\n>;\ntype RenderStartup = CompilationHooksJavascriptModulesPlugin['renderStartup'];\n\ntype InferStartupRenderContext<T> =\n T extends SyncWaterfallHook<\n [infer Source, infer Module, infer StartupRenderContext]\n >\n ? StartupRenderContext\n : never;\n\ntype StartupRenderContext = InferStartupRenderContext<RenderStartup>;\n\nexport interface Options {\n eager?: RegExp | ((module: Module) => boolean);\n excludeChunk?: (chunk: Chunk) => boolean;\n}\n\nclass EntryChunkTrackerPlugin {\n private _options: Options;\n\n constructor(options?: Options) {\n this._options = options || {};\n }\n\n apply(compiler: Compiler) {\n compiler.hooks.thisCompilation.tap(\n 'EntryChunkTrackerPlugin',\n (compilation: Compilation) => {\n this._handleRenderStartup(compiler, compilation);\n },\n );\n }\n private _handleRenderStartup(compiler: Compiler, compilation: Compilation) {\n compiler.webpack.javascript.JavascriptModulesPlugin.getCompilationHooks(\n compilation,\n ).renderStartup.tap(\n 'EntryChunkTrackerPlugin',\n (\n source: sources.Source,\n _renderContext: Module,\n upperContext: StartupRenderContext,\n ) => {\n if (\n this._options.excludeChunk &&\n this._options.excludeChunk(upperContext.chunk)\n ) {\n return source;\n }\n\n const templateString = this._getTemplateString(compiler, source);\n\n return new compiler.webpack.sources.ConcatSource(templateString);\n },\n );\n }\n\n private _getTemplateString(compiler: Compiler, source: sources.Source) {\n const { Template } = compiler.webpack;\n return Template.asString([\n `if(typeof module !== 'undefined') {\n globalThis.entryChunkCache = globalThis.entryChunkCache || new Set();\n module.filename && globalThis.entryChunkCache.add(module.filename);\n if(module.children) {\n module.children.forEach(function(c) {\n c.filename && globalThis.entryChunkCache.add(c.filename);\n })\n}\n }`,\n Template.indent(source.source().toString()),\n ]);\n }\n}\n\nexport default EntryChunkTrackerPlugin;\n"],"mappings":";;;;UAaE,qBAAqB,+BAA+B,CACrD;AAqBD,IAAM,0BAAN,MAA8B;CAG5B,YAAY,SAAmB;AAC7B,OAAK,WAAW,WAAW,EAAE;;CAG/B,MAAM,UAAoB;AACxB,WAAS,MAAM,gBAAgB,IAC7B,4BACC,gBAA6B;AAC5B,QAAK,qBAAqB,UAAU,YAAY;IAEnD;;CAEH,AAAQ,qBAAqB,UAAoB,aAA0B;AACzE,WAAS,QAAQ,WAAW,wBAAwB,oBAClD,YACD,CAAC,cAAc,IACd,4BAEE,QACA,gBACA,iBACG;AACH,OACE,KAAK,SAAS,gBACd,KAAK,SAAS,aAAa,aAAa,MAAM,CAE9C,QAAO;GAGT,MAAM,iBAAiB,KAAK,mBAAmB,UAAU,OAAO;AAEhE,UAAO,IAAI,SAAS,QAAQ,QAAQ,aAAa,eAAe;IAEnE;;CAGH,AAAQ,mBAAmB,UAAoB,QAAwB;EACrE,MAAM,EAAE,aAAa,SAAS;AAC9B,SAAO,SAAS,SAAS,CACvB;;;;;;;;UASA,SAAS,OAAO,OAAO,QAAQ,CAAC,UAAU,CAAC,CAC5C,CAAC"}