@ohos-ports/rspack-core 1.7.11-beta.1 → 2.2.9-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.
- package/README.md +11 -1
- package/compiled/@rspack/lite-tapable/dist/index.d.ts +190 -0
- package/compiled/@rspack/lite-tapable/license +22 -0
- package/compiled/@rspack/lite-tapable/package.json +1 -0
- package/compiled/@swc/types/index.d.ts +161 -11
- package/compiled/@swc/types/package.json +1 -1
- package/compiled/connect-next/index.d.ts +57 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +455 -0
- package/compiled/{browserslist-load-config → http-proxy-middleware}/license +3 -2
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/open/index.d.ts +161 -0
- package/compiled/open/package.json +1 -0
- package/compiled/tinypool/README.md +196 -2
- package/compiled/tinypool/dist/{common-Qw-RoVFD.js → common-Bo3KCGim.js} +4 -1
- package/compiled/tinypool/dist/entry/worker.js +1 -1
- package/compiled/tinypool/dist/index.d.ts +9 -4
- package/compiled/tinypool/dist/index.js +17 -53
- package/compiled/tinypool/package.json +22 -6
- package/compiled/watchpack/index.d.ts +3 -217
- package/compiled/watchpack/index.js +1778 -1091
- package/compiled/watchpack/package.json +8 -1
- package/compiled/watchpack/types/DirectoryWatcher.d.ts +335 -0
- package/compiled/watchpack/types/LinkResolver.d.ts +10 -0
- package/compiled/watchpack/types/getWatcherManager.d.ts +62 -0
- package/compiled/watchpack/types/index.d.ts +269 -0
- package/compiled/watchpack/types/reducePlan.d.ts +34 -0
- package/compiled/watchpack/types/util/globToRegExp.d.ts +2 -0
- package/compiled/watchpack/types/watchEventSource.d.ts +53 -0
- package/compiled/watchpack/types/watchpack.d.ts +2 -0
- package/compiled/webpack-sources/index.d.ts +61 -0
- package/compiled/webpack-sources/index.js +2370 -576
- package/compiled/webpack-sources/package.json +8 -1
- package/compiled/webpack-sources/types/CachedSource.d.ts +192 -0
- package/compiled/webpack-sources/types/CompatSource.d.ts +87 -0
- package/compiled/webpack-sources/types/ConcatSource.d.ts +75 -0
- package/compiled/webpack-sources/types/OriginalSource.d.ts +87 -0
- package/compiled/webpack-sources/types/PrefixSource.d.ts +59 -0
- package/compiled/webpack-sources/types/RawSource.d.ts +75 -0
- package/compiled/webpack-sources/types/ReplaceSource.d.ts +107 -0
- package/compiled/webpack-sources/types/SizeOnlySource.d.ts +24 -0
- package/compiled/webpack-sources/types/Source.d.ts +189 -0
- package/compiled/webpack-sources/types/SourceMapSource.d.ts +136 -0
- package/compiled/webpack-sources/types/helpers/createMappingsSerializer.d.ts +60 -0
- package/compiled/webpack-sources/types/helpers/getFromStreamChunks.d.ts +16 -0
- package/compiled/webpack-sources/types/helpers/getGeneratedSourceInfo.d.ts +31 -0
- package/compiled/webpack-sources/types/helpers/getName.d.ts +15 -0
- package/compiled/webpack-sources/types/helpers/getSource.d.ts +15 -0
- package/compiled/webpack-sources/types/helpers/readMappings.d.ts +19 -0
- package/compiled/webpack-sources/types/helpers/scopes.d.ts +119 -0
- package/compiled/webpack-sources/types/helpers/splitIntoLines.d.ts +6 -0
- package/compiled/webpack-sources/types/helpers/splitIntoPotentialTokens.d.ts +37 -0
- package/compiled/webpack-sources/types/helpers/streamAndGetSourceAndMap.d.ts +39 -0
- package/compiled/webpack-sources/types/helpers/streamChunks.d.ts +56 -0
- package/compiled/webpack-sources/types/helpers/streamChunksOfCombinedSourceMap.d.ts +42 -0
- package/compiled/webpack-sources/types/helpers/streamChunksOfRawSource.d.ts +16 -0
- package/compiled/webpack-sources/types/helpers/streamChunksOfSourceMap.d.ts +19 -0
- package/compiled/webpack-sources/types/helpers/stringBufferUtils.d.ts +55 -0
- package/compiled/webpack-sources/types/index.d.ts +50 -0
- package/dist/BuildInfo.d.ts +3 -1
- package/dist/ChunkGraph.d.ts +1 -1
- package/dist/CodeGenerationResults.d.ts +6 -1
- package/dist/Compilation.d.ts +60 -89
- package/dist/Compiler.d.ts +25 -22
- package/dist/ContextModuleFactory.d.ts +2 -2
- package/dist/Diagnostics.d.ts +2 -6
- package/dist/ExecuteModulePlugin.d.ts +1 -1
- package/dist/ExportsInfo.d.ts +1 -1
- package/dist/ExternalModule.d.ts +15 -1
- package/dist/FileSystem.d.ts +4 -2
- package/dist/FileSystemDependencies.d.ts +15 -0
- package/dist/Module.d.ts +9 -6
- package/dist/ModuleGraph.d.ts +11 -8
- package/dist/ModuleGraphConnection.d.ts +10 -0
- package/dist/Modules.d.ts +3 -0
- package/dist/MultiCompiler.d.ts +9 -9
- package/dist/MultiStats.d.ts +3 -3
- package/dist/MultiWatching.d.ts +3 -3
- package/dist/NativeWatchFileSystem.d.ts +31 -2
- package/dist/NormalModule.d.ts +4 -5
- package/dist/NormalModuleFactory.d.ts +5 -4
- package/dist/Resolver.d.ts +10 -2
- package/dist/ResolverFactory.d.ts +2 -2
- package/dist/RuntimeGlobals.d.ts +61 -56
- package/dist/RuntimeModule.d.ts +3 -3
- package/dist/RuntimeTemplate.d.ts +151 -0
- package/dist/Stats.d.ts +4 -4
- package/dist/VirtualModulesPlugin.d.ts +1 -1
- package/dist/Watching.d.ts +5 -5
- package/dist/builtin-loader/lightningcss/index.d.ts +11 -14
- package/dist/builtin-loader/lightningcss/target.d.ts +4 -0
- package/dist/builtin-loader/swc/index.d.ts +3 -5
- package/dist/builtin-loader/swc/pluginImport.d.ts +1 -1
- package/dist/builtin-loader/swc/types.d.ts +36 -65
- package/dist/builtin-plugin/APIPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +3 -3
- package/dist/builtin-plugin/AssetModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/BannerPlugin.d.ts +3 -3
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +3 -3
- package/dist/builtin-plugin/CaseSensitivePlugin.d.ts +3 -3
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +3 -3
- package/dist/builtin-plugin/CircularCheckRspackPlugin.d.ts +33 -0
- package/dist/builtin-plugin/CircularDependencyRspackPlugin.d.ts +10 -4
- package/dist/builtin-plugin/CircularModulesInfoPlugin.d.ts +7 -0
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +3 -3
- package/dist/builtin-plugin/CompactHashedChunkIdsPlugin.d.ts +12 -0
- package/dist/builtin-plugin/CompactHashedModuleIdsPlugin.d.ts +12 -0
- package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +3 -3
- package/dist/builtin-plugin/CopyRspackPlugin.d.ts +3 -3
- package/dist/builtin-plugin/CssChunkingPlugin.d.ts +3 -3
- package/dist/builtin-plugin/CssHttpExternalsRspackPlugin.d.ts +9 -0
- package/dist/builtin-plugin/CssModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/DataUriPlugin.d.ts +3 -3
- package/dist/builtin-plugin/DefinePlugin.d.ts +3 -3
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +13 -2
- package/dist/builtin-plugin/DllEntryPlugin.d.ts +3 -3
- package/dist/builtin-plugin/DllReferenceAgencyPlugin.d.ts +3 -3
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +4 -4
- package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +3 -3
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/EntryPlugin.d.ts +4 -4
- package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +7 -2
- package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +9 -0
- package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +3 -3
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ExternalsPlugin.d.ts +4 -3
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FileUriPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FlagAllModulesAsUsedPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +2 -2
- package/dist/builtin-plugin/HashedModuleIdsPlugin.d.ts +10 -0
- package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +2 -2
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +5 -5
- package/dist/builtin-plugin/HttpUriPlugin.d.ts +7 -3
- package/dist/builtin-plugin/IgnorePlugin.d.ts +3 -3
- package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/InlineExportsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +21 -6
- package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +2 -2
- package/dist/builtin-plugin/JsonModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/LibManifestPlugin.d.ts +3 -3
- package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +7 -11
- package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +3 -3
- package/dist/builtin-plugin/MangleExportsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +2 -2
- package/dist/builtin-plugin/ModuleInfoHeaderPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +2 -2
- package/dist/builtin-plugin/NoEmitOnErrorsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NodeTargetPlugin.d.ts +3 -3
- package/dist/builtin-plugin/NormalModuleReplacementPlugin.d.ts +4 -4
- package/dist/builtin-plugin/OccurrenceChunkIdsPlugin.d.ts +3 -3
- package/dist/builtin-plugin/ProgressPlugin.d.ts +8 -7
- package/dist/builtin-plugin/ProvidePlugin.d.ts +3 -3
- package/dist/builtin-plugin/RealContentHashPlugin.d.ts +15 -4
- package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +3 -3
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +3 -3
- package/dist/builtin-plugin/RsdoctorPlugin.d.ts +8 -11
- package/dist/builtin-plugin/RslibPlugin.d.ts +5 -6
- package/dist/builtin-plugin/RstestPlugin.d.ts +3 -4
- package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +3 -3
- package/dist/builtin-plugin/RuntimePlugin.d.ts +7 -11
- package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +9 -9
- package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +5 -5
- package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +3 -3
- package/dist/builtin-plugin/SplitChunksPlugin.d.ts +6 -5
- package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +2 -2
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +7 -6
- package/dist/builtin-plugin/SyncModuleIdsPlugin.d.ts +16 -0
- package/dist/builtin-plugin/URLPlugin.d.ts +3 -3
- package/dist/builtin-plugin/WorkerPlugin.d.ts +4 -4
- package/dist/builtin-plugin/base.d.ts +3 -3
- package/dist/builtin-plugin/css-extract/index.d.ts +3 -3
- package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/utils.d.ts +8 -1
- package/dist/builtin-plugin/html-plugin/hooks.d.ts +3 -3
- package/dist/builtin-plugin/html-plugin/index.d.ts +2 -2
- package/dist/builtin-plugin/html-plugin/options.d.ts +2 -7
- package/dist/builtin-plugin/html-plugin/plugin.d.ts +5 -9
- package/dist/builtin-plugin/html-plugin/taps.d.ts +1 -1
- package/dist/builtin-plugin/index.d.ts +92 -84
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +6 -6
- package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +4 -4
- package/dist/builtin-plugin/rsc/Coordinator.d.ts +8 -0
- package/dist/builtin-plugin/rsc/RscClientPlugin.d.ts +13 -0
- package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +47 -0
- package/dist/builtin-plugin/rsc/index.d.ts +24 -0
- package/dist/checkNodeVersion.d.ts +1 -0
- package/dist/config/adapter.d.ts +4 -4
- package/dist/config/adapterRuleUse.d.ts +89 -55
- package/dist/config/browserslistTargetHandler.d.ts +1 -1
- package/dist/config/defaults.d.ts +5 -3
- package/dist/config/devServer.d.ts +103 -238
- package/dist/config/index.d.ts +5 -5
- package/dist/config/normalization.d.ts +26 -47
- package/dist/config/target.d.ts +19 -12
- package/dist/config/types.d.ts +615 -256
- package/dist/container/ContainerPlugin.d.ts +4 -4
- package/dist/container/ContainerReferencePlugin.d.ts +4 -4
- package/dist/container/ModuleFederationManifestPlugin.d.ts +12 -5
- package/dist/container/ModuleFederationPlugin.d.ts +22 -5
- package/dist/container/ModuleFederationPluginV1.d.ts +10 -6
- package/dist/container/ModuleFederationRuntimePlugin.d.ts +3 -3
- package/dist/cssExtractHmr.js +2 -27
- package/dist/cssExtractLoader.js +24 -65
- package/dist/exports.d.ts +98 -84
- package/dist/index.d.ts +4 -3
- package/dist/index.js +14201 -11810
- package/dist/lib/AbstractMethodError.d.ts +1 -1
- package/dist/lib/Cache.d.ts +5 -2
- package/dist/lib/CacheFacade.d.ts +4 -4
- package/dist/lib/DllPlugin.d.ts +2 -2
- package/dist/lib/DllReferencePlugin.d.ts +3 -3
- package/dist/lib/EntryOptionPlugin.d.ts +2 -2
- package/dist/lib/EnvironmentPlugin.d.ts +3 -3
- package/dist/lib/HookWebpackError.d.ts +2 -3
- package/dist/lib/IgnoreWarningsPlugin.d.ts +1 -1
- package/dist/lib/LoaderOptionsPlugin.d.ts +2 -2
- package/dist/lib/LoaderTargetPlugin.d.ts +2 -2
- package/dist/lib/WebpackError.d.ts +2 -2
- package/dist/lib/cache/MemoryCachePlugin.d.ts +1 -1
- package/dist/lib/cache/getLazyHashedEtag.d.ts +2 -2
- package/dist/lib/cache/mergeEtags.d.ts +1 -2
- package/dist/loader-runner/ModuleError.d.ts +1 -1
- package/dist/loader-runner/cache.d.ts +27 -0
- package/dist/loader-runner/dependencies.d.ts +23 -0
- package/dist/loader-runner/index.d.ts +10 -11
- package/dist/loader-runner/loadLoader.d.ts +2 -2
- package/dist/loader-runner/service.d.ts +10 -1
- package/dist/loader-runner/utils.d.ts +3 -3
- package/dist/loader-runner/worker.d.ts +1 -1
- package/dist/logging/createConsoleLogger.d.ts +2 -2
- package/dist/l~0.js +34 -0
- package/dist/l~3.js +34 -0
- package/dist/moduleFederationDefaultRuntime.js +1 -1
- package/dist/node/NodeEnvironmentPlugin.d.ts +2 -2
- package/dist/node/NodeTemplatePlugin.d.ts +1 -1
- package/dist/node/NodeWatchFileSystem.d.ts +15 -3
- package/dist/node/nodeConsole.d.ts +1 -1
- package/dist/rspack.d.ts +7 -8
- package/dist/rspackOptionsApply.d.ts +1 -1
- package/dist/runtime/cssExtractHmr.d.ts +2 -2
- package/dist/runtime/moduleFederationDefaultRuntime.d.ts +1 -2
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
- package/dist/sharing/ConsumeSharedPlugin.d.ts +18 -6
- package/dist/sharing/IndependentSharedPlugin.d.ts +37 -0
- package/dist/sharing/ProvideSharedPlugin.d.ts +22 -3
- package/dist/sharing/SharePlugin.d.ts +51 -3
- package/dist/sharing/ShareRuntimePlugin.d.ts +2 -2
- package/dist/sharing/SharedContainerPlugin.d.ts +23 -0
- package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +14 -0
- package/dist/sharing/TreeShakingSharedPlugin.d.ts +19 -0
- package/dist/sharing/utils.d.ts +1 -0
- package/dist/stats/DefaultStatsFactoryPlugin.d.ts +1 -1
- package/dist/stats/DefaultStatsPresetPlugin.d.ts +1 -1
- package/dist/stats/DefaultStatsPrinterPlugin.d.ts +1 -1
- package/dist/stats/StatsFactory.d.ts +7 -5
- package/dist/stats/StatsPrinter.d.ts +7 -7
- package/dist/stats/statsFactoryUtils.d.ts +15 -19
- package/dist/swc.d.ts +2 -2
- package/dist/taps/compilation.d.ts +1 -1
- package/dist/taps/compiler.d.ts +1 -1
- package/dist/taps/contextModuleFactory.d.ts +1 -1
- package/dist/taps/externalModule.d.ts +2 -0
- package/dist/taps/index.d.ts +7 -6
- package/dist/taps/javascriptModules.d.ts +1 -1
- package/dist/taps/normalModuleFactory.d.ts +1 -1
- package/dist/taps/types.d.ts +2 -2
- package/dist/trace/index.d.ts +1 -0
- package/dist/trace/traceHookPlugin.d.ts +1 -1
- package/dist/util/bindingHelpers.d.ts +7 -0
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/createHash.d.ts +2 -2
- package/dist/util/fs.d.ts +19 -18
- package/dist/util/hash/md4.d.ts +1 -1
- package/dist/util/hash/xxhash64.d.ts +1 -1
- package/dist/util/identifier.d.ts +35 -9
- package/dist/util/index.d.ts +2 -2
- package/dist/util/source.d.ts +3 -3
- package/dist/util/supportsColor.d.ts +6 -0
- package/dist/util/targetsVersion.d.ts +2 -0
- package/dist/util/validateConfig.d.ts +1 -1
- package/dist/util/watchTimeInfo.d.ts +7 -0
- package/dist/web/JsonpTemplatePlugin.d.ts +13 -0
- package/dist/webworker/WebWorkerTemplatePlugin.d.ts +13 -0
- package/dist/worker.js +935 -907
- package/hot/dev-server.js +12 -11
- package/hot/emitter.js +3 -1
- package/hot/lazy-compilation-node.js +4 -1
- package/hot/lazy-compilation-web.js +2 -3
- package/hot/log-apply-result.js +8 -5
- package/hot/log.js +18 -10
- package/hot/only-dev-server.js +13 -12
- package/hot/poll.js +10 -9
- package/hot/signal.js +12 -10
- package/module.d.ts +39 -2
- package/package.json +15 -39
- package/compiled/browserslist-load-config/index.d.ts +0 -21
- package/compiled/browserslist-load-config/index.js +0 -252
- package/compiled/browserslist-load-config/package.json +0 -1
- package/compiled/webpack-sources/types.d.ts +0 -458
- package/dist/builtin-loader/index.d.ts +0 -1
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +0 -7
- package/dist/container/index.d.ts +0 -4
- package/dist/util/MergeCaller.d.ts +0 -10
- package/dist/util/fake.d.ts +0 -14
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/******/ "use strict";
|
|
3
3
|
/******/ var __webpack_modules__ = ({
|
|
4
4
|
|
|
5
|
-
/***/
|
|
5
|
+
/***/ 384:
|
|
6
6
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
7
7
|
|
|
8
8
|
/*
|
|
@@ -12,14 +12,15 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
const Source = __nccwpck_require__(
|
|
16
|
-
const streamAndGetSourceAndMap = __nccwpck_require__(
|
|
17
|
-
const streamChunksOfRawSource = __nccwpck_require__(
|
|
18
|
-
const streamChunksOfSourceMap = __nccwpck_require__(
|
|
15
|
+
const Source = __nccwpck_require__(290);
|
|
16
|
+
const streamAndGetSourceAndMap = __nccwpck_require__(658);
|
|
17
|
+
const streamChunksOfRawSource = __nccwpck_require__(543);
|
|
18
|
+
const streamChunksOfSourceMap = __nccwpck_require__(637);
|
|
19
19
|
const {
|
|
20
20
|
isDualStringBufferCachingEnabled,
|
|
21
|
-
} = __nccwpck_require__(
|
|
21
|
+
} = __nccwpck_require__(345);
|
|
22
22
|
|
|
23
|
+
/** @typedef {import("./Source").ClearCacheOptions} ClearCacheOptions */
|
|
23
24
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
24
25
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
25
26
|
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
|
|
@@ -30,6 +31,7 @@ const {
|
|
|
30
31
|
/** @typedef {import("./helpers/streamChunks").OnName} OnName */
|
|
31
32
|
/** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
|
|
32
33
|
/** @typedef {import("./helpers/streamChunks").Options} Options */
|
|
34
|
+
/** @typedef {import("./helpers/streamChunks").ScopeBindings} ScopeBindings */
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* @typedef {object} BufferedMap
|
|
@@ -62,6 +64,25 @@ const mapToBufferedMap = (map) => {
|
|
|
62
64
|
return bufferedMap;
|
|
63
65
|
};
|
|
64
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Encodes every string a recorded hash update holds as a buffer, so cached data
|
|
69
|
+
* handed to a caller carries no big string: a string goes into the serialized
|
|
70
|
+
* payload, where it is copied in and rebuilt on every deserialization, while a
|
|
71
|
+
* buffer is carried alongside it. Hashing reads a string as utf8, so the
|
|
72
|
+
* encoded update hashes the same. It encodes in place, so a source handed out
|
|
73
|
+
* repeatedly is encoded once, and one that never is keeps its string uncopied.
|
|
74
|
+
* @param {(string | Buffer)[]=} update recorded hash update
|
|
75
|
+
* @returns {(string | Buffer)[]=} the update, holding no string
|
|
76
|
+
*/
|
|
77
|
+
const bufferHashUpdate = (update) => {
|
|
78
|
+
if (update === undefined) return undefined;
|
|
79
|
+
for (let index = 0; index < update.length; index++) {
|
|
80
|
+
const item = update[index];
|
|
81
|
+
if (typeof item === "string") update[index] = Buffer.from(item, "utf8");
|
|
82
|
+
}
|
|
83
|
+
return update;
|
|
84
|
+
};
|
|
85
|
+
|
|
65
86
|
/**
|
|
66
87
|
* @param {null | BufferedMap} bufferedMap buffered map
|
|
67
88
|
* @returns {null | RawSourceMap} map
|
|
@@ -82,9 +103,51 @@ const bufferedMapToMap = (bufferedMap) => {
|
|
|
82
103
|
return map;
|
|
83
104
|
};
|
|
84
105
|
|
|
85
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* What replaying an entry streamed for a `scopes` request needs besides its
|
|
108
|
+
* map. The map only keeps the encoded `scopes` field, so `bindings` holds, by
|
|
109
|
+
* source index, the bindings each source reported. The field also appended
|
|
110
|
+
* names to the map, and `names` counts the ones the stream itself reported,
|
|
111
|
+
* so a replay reports the same names a fresh stream would.
|
|
112
|
+
* @typedef {object} ScopesReplay
|
|
113
|
+
* @property {(ScopeBindings | undefined)[]} bindings bindings by source index
|
|
114
|
+
* @property {number} names number of names the stream reported
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @typedef {{ map?: null | RawSourceMap, bufferedMap?: null | BufferedMap, scopes?: ScopesReplay }} BufferEntry
|
|
119
|
+
*/
|
|
86
120
|
/** @typedef {Map<string, BufferEntry>} BufferedMaps */
|
|
87
121
|
|
|
122
|
+
const CACHE_KEY_EMPTY = "{}";
|
|
123
|
+
const CACHE_KEY_COLUMNS_FALSE = '{"columns":false}';
|
|
124
|
+
const CACHE_KEY_COLUMNS_TRUE = '{"columns":true}';
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Fast-path replacement for `JSON.stringify(options)` when used as a cache
|
|
128
|
+
* key. MapOptions / streamChunks Options are both small boolean-only shapes
|
|
129
|
+
* and the overwhelmingly common shapes (`undefined`, `{}`, `{columns}`) can
|
|
130
|
+
* be keyed without calling `JSON.stringify`, which dominates short-circuit
|
|
131
|
+
* cache lookups. Falls back to `JSON.stringify` for any other shape so keys
|
|
132
|
+
* remain compatible with previously cached `BufferedMaps` entries.
|
|
133
|
+
* @param {undefined | MapOptions | Options} options options
|
|
134
|
+
* @returns {string} cache key
|
|
135
|
+
*/
|
|
136
|
+
const getCacheKey = (options) => {
|
|
137
|
+
if (!options) return CACHE_KEY_EMPTY;
|
|
138
|
+
const { columns } = options;
|
|
139
|
+
if (
|
|
140
|
+
/** @type {Options} */ (options).source === undefined &&
|
|
141
|
+
/** @type {Options} */ (options).finalSource === undefined &&
|
|
142
|
+
/** @type {MapOptions} */ (options).module === undefined &&
|
|
143
|
+
/** @type {MapOptions} */ (options).scopes === undefined
|
|
144
|
+
) {
|
|
145
|
+
if (columns === undefined) return CACHE_KEY_EMPTY;
|
|
146
|
+
return columns ? CACHE_KEY_COLUMNS_TRUE : CACHE_KEY_COLUMNS_FALSE;
|
|
147
|
+
}
|
|
148
|
+
return JSON.stringify(options);
|
|
149
|
+
};
|
|
150
|
+
|
|
88
151
|
/**
|
|
89
152
|
* @typedef {object} CachedData
|
|
90
153
|
* @property {boolean=} source source
|
|
@@ -101,21 +164,57 @@ class CachedSource extends Source {
|
|
|
101
164
|
*/
|
|
102
165
|
constructor(source, cachedData) {
|
|
103
166
|
super();
|
|
167
|
+
/**
|
|
168
|
+
* @type {Source | (() => Source)}
|
|
169
|
+
*/
|
|
104
170
|
this._source = source;
|
|
105
|
-
this._cachedSourceType = cachedData ? cachedData.source : undefined;
|
|
106
171
|
/**
|
|
107
|
-
* @private
|
|
108
172
|
* @type {undefined | string}
|
|
109
173
|
*/
|
|
110
174
|
this._cachedSource = undefined;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
175
|
+
// Split on `cachedData` once instead of re-evaluating the ternary for
|
|
176
|
+
// every field. Under the interpreter (and CodSpeed's simulation) each
|
|
177
|
+
// ternary is a separate branch; consolidating cuts the per-instance
|
|
178
|
+
// branch count roughly in half.
|
|
179
|
+
if (cachedData) {
|
|
180
|
+
/**
|
|
181
|
+
* @type {boolean | undefined}
|
|
182
|
+
*/
|
|
183
|
+
this._cachedSourceType = cachedData.source;
|
|
184
|
+
/**
|
|
185
|
+
* @type {Buffer | undefined}
|
|
186
|
+
*/
|
|
187
|
+
this._cachedBuffer = cachedData.buffer;
|
|
188
|
+
/**
|
|
189
|
+
* @type {number | undefined}
|
|
190
|
+
*/
|
|
191
|
+
this._cachedSize = cachedData.size;
|
|
192
|
+
/**
|
|
193
|
+
* @type {BufferedMaps | undefined}
|
|
194
|
+
*/
|
|
195
|
+
this._cachedMaps = cachedData.maps;
|
|
196
|
+
/**
|
|
197
|
+
* @type {(string | Buffer)[] | undefined}
|
|
198
|
+
*/
|
|
199
|
+
this._cachedHashUpdate = cachedData.hash;
|
|
200
|
+
} else {
|
|
201
|
+
this._cachedSourceType = undefined;
|
|
202
|
+
this._cachedBuffer = undefined;
|
|
203
|
+
this._cachedSize = undefined;
|
|
204
|
+
this._cachedMaps = undefined;
|
|
205
|
+
this._cachedHashUpdate = undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The map cache, created on first use: a source nobody asks a map of holds
|
|
211
|
+
* none, since V8 allocates a Map's hash table whether or not it is filled.
|
|
212
|
+
* @returns {BufferedMaps} map cache
|
|
213
|
+
*/
|
|
214
|
+
_getOrCreateCachedMaps() {
|
|
215
|
+
const cachedMaps = this._cachedMaps;
|
|
216
|
+
if (cachedMaps !== undefined) return cachedMaps;
|
|
217
|
+
return (this._cachedMaps = new Map());
|
|
119
218
|
}
|
|
120
219
|
|
|
121
220
|
/**
|
|
@@ -124,26 +223,36 @@ class CachedSource extends Source {
|
|
|
124
223
|
getCachedData() {
|
|
125
224
|
/** @type {BufferedMaps} */
|
|
126
225
|
const bufferedMaps = new Map();
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
cacheEntry.bufferedMap
|
|
131
|
-
|
|
132
|
-
|
|
226
|
+
if (this._cachedMaps !== undefined) {
|
|
227
|
+
for (const pair of this._cachedMaps) {
|
|
228
|
+
const [, cacheEntry] = pair;
|
|
229
|
+
if (cacheEntry.bufferedMap === undefined) {
|
|
230
|
+
cacheEntry.bufferedMap = mapToBufferedMap(
|
|
231
|
+
this._getMapFromCacheEntry(cacheEntry),
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
/** @type {BufferEntry} */
|
|
235
|
+
const bufferEntry = {
|
|
236
|
+
map: undefined,
|
|
237
|
+
bufferedMap: cacheEntry.bufferedMap,
|
|
238
|
+
};
|
|
239
|
+
// Keep the bindings a `scopes` request recorded, so a source
|
|
240
|
+
// restored from this data replays them without its original.
|
|
241
|
+
if (cacheEntry.scopes !== undefined) {
|
|
242
|
+
bufferEntry.scopes = cacheEntry.scopes;
|
|
243
|
+
}
|
|
244
|
+
bufferedMaps.set(pair[0], bufferEntry);
|
|
133
245
|
}
|
|
134
|
-
bufferedMaps.set(pair[0], {
|
|
135
|
-
map: undefined,
|
|
136
|
-
bufferedMap: cacheEntry.bufferedMap,
|
|
137
|
-
});
|
|
138
246
|
}
|
|
139
247
|
return {
|
|
140
|
-
//
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
248
|
+
// `CachedData.buffer` is required (it is the on-disk
|
|
249
|
+
// serialization format consumed by the
|
|
250
|
+
// `new CachedSource(source, cachedData)` constructor).
|
|
251
|
+
// `_cachedBuffer` is populated by `buffer()` calls but a
|
|
252
|
+
// caller may invoke `getCachedData()` after `clearCache()`
|
|
253
|
+
// has dropped it; `this.buffer()` rehydrates via the
|
|
254
|
+
// wrapped source so the contract holds in every state.
|
|
255
|
+
buffer: this.buffer(),
|
|
147
256
|
source:
|
|
148
257
|
this._cachedSourceType !== undefined
|
|
149
258
|
? this._cachedSourceType
|
|
@@ -154,7 +263,7 @@ class CachedSource extends Source {
|
|
|
154
263
|
: undefined,
|
|
155
264
|
size: this._cachedSize,
|
|
156
265
|
maps: bufferedMaps,
|
|
157
|
-
hash: this._cachedHashUpdate,
|
|
266
|
+
hash: bufferHashUpdate(this._cachedHashUpdate),
|
|
158
267
|
};
|
|
159
268
|
}
|
|
160
269
|
|
|
@@ -171,15 +280,27 @@ class CachedSource extends Source {
|
|
|
171
280
|
* @returns {SourceValue} source
|
|
172
281
|
*/
|
|
173
282
|
source() {
|
|
174
|
-
|
|
175
|
-
|
|
283
|
+
// Fully inlined _getCachedSource: both warm- and cold-cache paths skip
|
|
284
|
+
// the prototype method lookup / stack frame the interpreter would
|
|
285
|
+
// otherwise pay on every call.
|
|
286
|
+
if (this._cachedSource !== undefined) return this._cachedSource;
|
|
287
|
+
const cachedBuffer = this._cachedBuffer;
|
|
288
|
+
const cachedSourceType = this._cachedSourceType;
|
|
289
|
+
if (cachedBuffer !== undefined && cachedSourceType !== undefined) {
|
|
290
|
+
const value = cachedSourceType
|
|
291
|
+
? cachedBuffer.toString("utf8")
|
|
292
|
+
: cachedBuffer;
|
|
293
|
+
if (isDualStringBufferCachingEnabled()) {
|
|
294
|
+
this._cachedSource = /** @type {string} */ (value);
|
|
295
|
+
}
|
|
296
|
+
return /** @type {string} */ (value);
|
|
297
|
+
}
|
|
176
298
|
return (this._cachedSource =
|
|
177
299
|
/** @type {string} */
|
|
178
300
|
(this.original().source()));
|
|
179
301
|
}
|
|
180
302
|
|
|
181
303
|
/**
|
|
182
|
-
* @private
|
|
183
304
|
* @param {BufferEntry} cacheEntry cache entry
|
|
184
305
|
* @returns {null | RawSourceMap} raw source map
|
|
185
306
|
*/
|
|
@@ -194,7 +315,6 @@ class CachedSource extends Source {
|
|
|
194
315
|
}
|
|
195
316
|
|
|
196
317
|
/**
|
|
197
|
-
* @private
|
|
198
318
|
* @returns {undefined | string} cached source
|
|
199
319
|
*/
|
|
200
320
|
_getCachedSource() {
|
|
@@ -215,6 +335,9 @@ class CachedSource extends Source {
|
|
|
215
335
|
*/
|
|
216
336
|
buffer() {
|
|
217
337
|
if (this._cachedBuffer !== undefined) return this._cachedBuffer;
|
|
338
|
+
if (this._cachedBuffers !== undefined) {
|
|
339
|
+
return (this._cachedBuffer = Buffer.concat(this._cachedBuffers));
|
|
340
|
+
}
|
|
218
341
|
if (this._cachedSource !== undefined) {
|
|
219
342
|
const value = Buffer.isBuffer(this._cachedSource)
|
|
220
343
|
? this._cachedSource
|
|
@@ -238,6 +361,21 @@ class CachedSource extends Source {
|
|
|
238
361
|
return value;
|
|
239
362
|
}
|
|
240
363
|
|
|
364
|
+
/**
|
|
365
|
+
* @returns {Buffer[]} buffers
|
|
366
|
+
*/
|
|
367
|
+
buffers() {
|
|
368
|
+
if (this._cachedBuffers !== undefined) return this._cachedBuffers;
|
|
369
|
+
if (this._cachedBuffer !== undefined) {
|
|
370
|
+
return (this._cachedBuffers = [this._cachedBuffer]);
|
|
371
|
+
}
|
|
372
|
+
const original = this.original();
|
|
373
|
+
if (typeof original.buffers === "function") {
|
|
374
|
+
return (this._cachedBuffers = original.buffers());
|
|
375
|
+
}
|
|
376
|
+
return (this._cachedBuffers = [this.buffer()]);
|
|
377
|
+
}
|
|
378
|
+
|
|
241
379
|
/**
|
|
242
380
|
* @returns {number} size
|
|
243
381
|
*/
|
|
@@ -258,8 +396,10 @@ class CachedSource extends Source {
|
|
|
258
396
|
* @returns {SourceAndMap} source and map
|
|
259
397
|
*/
|
|
260
398
|
sourceAndMap(options) {
|
|
261
|
-
const key =
|
|
262
|
-
const
|
|
399
|
+
const key = getCacheKey(options);
|
|
400
|
+
const cachedMaps = this._cachedMaps;
|
|
401
|
+
const cacheEntry =
|
|
402
|
+
cachedMaps === undefined ? undefined : cachedMaps.get(key);
|
|
263
403
|
// Look for a cached map
|
|
264
404
|
if (cacheEntry !== undefined) {
|
|
265
405
|
// We have a cached map in some representation
|
|
@@ -281,7 +421,7 @@ class CachedSource extends Source {
|
|
|
281
421
|
map = sourceAndMap.map;
|
|
282
422
|
this._cachedSource = source;
|
|
283
423
|
}
|
|
284
|
-
this.
|
|
424
|
+
this._getOrCreateCachedMaps().set(key, {
|
|
285
425
|
map,
|
|
286
426
|
bufferedMap: undefined,
|
|
287
427
|
});
|
|
@@ -296,19 +436,39 @@ class CachedSource extends Source {
|
|
|
296
436
|
* @returns {GeneratedSourceInfo} generated source info
|
|
297
437
|
*/
|
|
298
438
|
streamChunks(options, onChunk, onSource, onName) {
|
|
299
|
-
const key =
|
|
439
|
+
const key = getCacheKey(options);
|
|
440
|
+
const scopes = Boolean(
|
|
441
|
+
options && /** @type {MapOptions} */ (options).scopes,
|
|
442
|
+
);
|
|
443
|
+
const cachedMaps = this._cachedMaps;
|
|
444
|
+
const cacheEntry =
|
|
445
|
+
cachedMaps === undefined ? undefined : cachedMaps.get(key);
|
|
300
446
|
if (
|
|
301
|
-
|
|
447
|
+
cacheEntry !== undefined &&
|
|
448
|
+
// An entry filled without streaming never saw the bindings, so a
|
|
449
|
+
// scopes request streams the original once to record them.
|
|
450
|
+
(!scopes || cacheEntry.scopes !== undefined) &&
|
|
302
451
|
(this._cachedBuffer !== undefined || this._cachedSource !== undefined)
|
|
303
452
|
) {
|
|
304
453
|
const { source, map } = this.sourceAndMap(options);
|
|
305
454
|
if (map) {
|
|
455
|
+
const replay = scopes ? cacheEntry.scopes : undefined;
|
|
306
456
|
return streamChunksOfSourceMap(
|
|
307
457
|
/** @type {string} */
|
|
308
458
|
(source),
|
|
309
|
-
map
|
|
459
|
+
replay !== undefined && map.names.length > replay.names
|
|
460
|
+
? { ...map, names: map.names.slice(0, replay.names) }
|
|
461
|
+
: map,
|
|
310
462
|
onChunk,
|
|
311
|
-
|
|
463
|
+
replay !== undefined
|
|
464
|
+
? (sourceIndex, source, sourceContent) =>
|
|
465
|
+
onSource(
|
|
466
|
+
sourceIndex,
|
|
467
|
+
source,
|
|
468
|
+
sourceContent,
|
|
469
|
+
replay.bindings[sourceIndex],
|
|
470
|
+
)
|
|
471
|
+
: onSource,
|
|
312
472
|
onName,
|
|
313
473
|
Boolean(options && options.finalSource),
|
|
314
474
|
true,
|
|
@@ -323,17 +483,30 @@ class CachedSource extends Source {
|
|
|
323
483
|
Boolean(options && options.finalSource),
|
|
324
484
|
);
|
|
325
485
|
}
|
|
486
|
+
/** @type {ScopesReplay | undefined} */
|
|
487
|
+
const replay = scopes ? { bindings: [], names: 0 } : undefined;
|
|
326
488
|
const sourceAndMap = streamAndGetSourceAndMap(
|
|
327
489
|
this.original(),
|
|
328
490
|
options,
|
|
329
491
|
onChunk,
|
|
330
|
-
|
|
331
|
-
|
|
492
|
+
replay !== undefined
|
|
493
|
+
? (sourceIndex, source, sourceContent, bindings) => {
|
|
494
|
+
replay.bindings[sourceIndex] = bindings;
|
|
495
|
+
onSource(sourceIndex, source, sourceContent, bindings);
|
|
496
|
+
}
|
|
497
|
+
: onSource,
|
|
498
|
+
replay !== undefined
|
|
499
|
+
? (nameIndex, name) => {
|
|
500
|
+
if (nameIndex >= replay.names) replay.names = nameIndex + 1;
|
|
501
|
+
onName(nameIndex, name);
|
|
502
|
+
}
|
|
503
|
+
: onName,
|
|
332
504
|
);
|
|
333
505
|
this._cachedSource = sourceAndMap.source;
|
|
334
|
-
this.
|
|
506
|
+
this._getOrCreateCachedMaps().set(key, {
|
|
335
507
|
map: /** @type {RawSourceMap} */ (sourceAndMap.map),
|
|
336
508
|
bufferedMap: undefined,
|
|
509
|
+
scopes: replay,
|
|
337
510
|
});
|
|
338
511
|
return sourceAndMap.result;
|
|
339
512
|
}
|
|
@@ -343,19 +516,60 @@ class CachedSource extends Source {
|
|
|
343
516
|
* @returns {RawSourceMap | null} map
|
|
344
517
|
*/
|
|
345
518
|
map(options) {
|
|
346
|
-
const key =
|
|
347
|
-
const
|
|
519
|
+
const key = getCacheKey(options);
|
|
520
|
+
const cachedMaps = this._cachedMaps;
|
|
521
|
+
const cacheEntry =
|
|
522
|
+
cachedMaps === undefined ? undefined : cachedMaps.get(key);
|
|
348
523
|
if (cacheEntry !== undefined) {
|
|
349
524
|
return this._getMapFromCacheEntry(cacheEntry);
|
|
350
525
|
}
|
|
351
526
|
const map = this.original().map(options);
|
|
352
|
-
this.
|
|
527
|
+
this._getOrCreateCachedMaps().set(key, {
|
|
353
528
|
map,
|
|
354
529
|
bufferedMap: undefined,
|
|
355
530
|
});
|
|
356
531
|
return map;
|
|
357
532
|
}
|
|
358
533
|
|
|
534
|
+
/**
|
|
535
|
+
* Release cached data held by this source. clearCache is a memory
|
|
536
|
+
* hint: it never affects correctness or output, only how expensive
|
|
537
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
538
|
+
* every Source supports the call. Composite sources always recurse
|
|
539
|
+
* into wrapped sources. When the same child is reachable via several
|
|
540
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
541
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
542
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
543
|
+
* streamChunks/updateHash on the same instance.
|
|
544
|
+
* @param {ClearCacheOptions=} options selectors
|
|
545
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
546
|
+
* @returns {void}
|
|
547
|
+
*/
|
|
548
|
+
clearCache(options, visited) {
|
|
549
|
+
if (visited !== undefined && visited.has(this)) return;
|
|
550
|
+
const clearSource = !options || options.source !== false;
|
|
551
|
+
const clearMaps = !options || options.maps !== false;
|
|
552
|
+
if (clearSource) {
|
|
553
|
+
this._cachedSource = undefined;
|
|
554
|
+
this._cachedSourceType = undefined;
|
|
555
|
+
this._cachedBuffer = undefined;
|
|
556
|
+
this._cachedBuffers = undefined;
|
|
557
|
+
}
|
|
558
|
+
if (clearMaps && this._cachedMaps !== undefined) {
|
|
559
|
+
// Reusing the Map avoids per-call allocation churn when builds
|
|
560
|
+
// call clearCache thousands of times.
|
|
561
|
+
this._cachedMaps.clear();
|
|
562
|
+
}
|
|
563
|
+
if (typeof this._source !== "function") {
|
|
564
|
+
let v = visited;
|
|
565
|
+
if (v === undefined) v = new WeakSet();
|
|
566
|
+
v.add(this);
|
|
567
|
+
this._source.clearCache(options, v);
|
|
568
|
+
} else if (visited !== undefined) {
|
|
569
|
+
visited.add(this);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
359
573
|
/**
|
|
360
574
|
* @param {HashLike} hash hash
|
|
361
575
|
* @returns {void}
|
|
@@ -408,7 +622,7 @@ module.exports = CachedSource;
|
|
|
408
622
|
|
|
409
623
|
/***/ }),
|
|
410
624
|
|
|
411
|
-
/***/
|
|
625
|
+
/***/ 912:
|
|
412
626
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
413
627
|
|
|
414
628
|
/*
|
|
@@ -418,8 +632,9 @@ module.exports = CachedSource;
|
|
|
418
632
|
|
|
419
633
|
|
|
420
634
|
|
|
421
|
-
const Source = __nccwpck_require__(
|
|
635
|
+
const Source = __nccwpck_require__(290);
|
|
422
636
|
|
|
637
|
+
/** @typedef {import("./Source").ClearCacheOptions} ClearCacheOptions */
|
|
423
638
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
424
639
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
425
640
|
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
|
|
@@ -430,10 +645,12 @@ const Source = __nccwpck_require__(422);
|
|
|
430
645
|
* @typedef {object} SourceLike
|
|
431
646
|
* @property {() => SourceValue} source source
|
|
432
647
|
* @property {(() => Buffer)=} buffer buffer
|
|
648
|
+
* @property {(() => Buffer[])=} buffers buffers
|
|
433
649
|
* @property {(() => number)=} size size
|
|
434
650
|
* @property {((options?: MapOptions) => RawSourceMap | null)=} map map
|
|
435
651
|
* @property {((options?: MapOptions) => SourceAndMap)=} sourceAndMap source and map
|
|
436
652
|
* @property {((hash: HashLike) => void)=} updateHash hash updater
|
|
653
|
+
* @property {((options?: ClearCacheOptions, visited?: WeakSet<Source>) => void)=} clearCache clear cache
|
|
437
654
|
*/
|
|
438
655
|
|
|
439
656
|
class CompatSource extends Source {
|
|
@@ -452,6 +669,9 @@ class CompatSource extends Source {
|
|
|
452
669
|
*/
|
|
453
670
|
constructor(sourceLike) {
|
|
454
671
|
super();
|
|
672
|
+
/**
|
|
673
|
+
* @type {SourceLike}
|
|
674
|
+
*/
|
|
455
675
|
this._sourceLike = sourceLike;
|
|
456
676
|
}
|
|
457
677
|
|
|
@@ -462,6 +682,9 @@ class CompatSource extends Source {
|
|
|
462
682
|
return this._sourceLike.source();
|
|
463
683
|
}
|
|
464
684
|
|
|
685
|
+
/**
|
|
686
|
+
* @returns {Buffer} buffer
|
|
687
|
+
*/
|
|
465
688
|
buffer() {
|
|
466
689
|
if (typeof this._sourceLike.buffer === "function") {
|
|
467
690
|
return this._sourceLike.buffer();
|
|
@@ -469,6 +692,19 @@ class CompatSource extends Source {
|
|
|
469
692
|
return super.buffer();
|
|
470
693
|
}
|
|
471
694
|
|
|
695
|
+
/**
|
|
696
|
+
* @returns {Buffer[]} buffers
|
|
697
|
+
*/
|
|
698
|
+
buffers() {
|
|
699
|
+
if (typeof this._sourceLike.buffers === "function") {
|
|
700
|
+
return this._sourceLike.buffers();
|
|
701
|
+
}
|
|
702
|
+
return super.buffers();
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* @returns {number} size
|
|
707
|
+
*/
|
|
472
708
|
size() {
|
|
473
709
|
if (typeof this._sourceLike.size === "function") {
|
|
474
710
|
return this._sourceLike.size();
|
|
@@ -498,6 +734,29 @@ class CompatSource extends Source {
|
|
|
498
734
|
return super.sourceAndMap(options);
|
|
499
735
|
}
|
|
500
736
|
|
|
737
|
+
/**
|
|
738
|
+
* Release cached data held by this source. clearCache is a memory
|
|
739
|
+
* hint: it never affects correctness or output, only how expensive
|
|
740
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
741
|
+
* every Source supports the call. Composite sources always recurse
|
|
742
|
+
* into wrapped sources. When the same child is reachable via several
|
|
743
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
744
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
745
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
746
|
+
* streamChunks/updateHash on the same instance.
|
|
747
|
+
* @param {ClearCacheOptions=} options selectors
|
|
748
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
749
|
+
* @returns {void}
|
|
750
|
+
*/
|
|
751
|
+
clearCache(options, visited) {
|
|
752
|
+
if (visited !== undefined && visited.has(this)) return;
|
|
753
|
+
if (visited !== undefined) visited.add(this);
|
|
754
|
+
const sourceLike = this._sourceLike;
|
|
755
|
+
if (typeof sourceLike.clearCache === "function") {
|
|
756
|
+
sourceLike.clearCache(options, visited);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
501
760
|
/**
|
|
502
761
|
* @param {HashLike} hash hash
|
|
503
762
|
* @returns {void}
|
|
@@ -520,7 +779,7 @@ module.exports = CompatSource;
|
|
|
520
779
|
|
|
521
780
|
/***/ }),
|
|
522
781
|
|
|
523
|
-
/***/
|
|
782
|
+
/***/ 698:
|
|
524
783
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
525
784
|
|
|
526
785
|
/*
|
|
@@ -530,12 +789,13 @@ module.exports = CompatSource;
|
|
|
530
789
|
|
|
531
790
|
|
|
532
791
|
|
|
533
|
-
const RawSource = __nccwpck_require__(
|
|
534
|
-
const Source = __nccwpck_require__(
|
|
535
|
-
const { getMap, getSourceAndMap } = __nccwpck_require__(
|
|
536
|
-
const streamChunks = __nccwpck_require__(
|
|
792
|
+
const RawSource = __nccwpck_require__(132);
|
|
793
|
+
const Source = __nccwpck_require__(290);
|
|
794
|
+
const { getMap, getSourceAndMap } = __nccwpck_require__(847);
|
|
795
|
+
const streamChunks = __nccwpck_require__(487);
|
|
537
796
|
|
|
538
797
|
/** @typedef {import("./CompatSource").SourceLike} SourceLike */
|
|
798
|
+
/** @typedef {import("./Source").ClearCacheOptions} ClearCacheOptions */
|
|
539
799
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
540
800
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
541
801
|
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
|
|
@@ -558,21 +818,28 @@ class ConcatSource extends Source {
|
|
|
558
818
|
constructor(...args) {
|
|
559
819
|
super();
|
|
560
820
|
/**
|
|
561
|
-
* @private
|
|
562
821
|
* @type {Child[]}
|
|
563
822
|
*/
|
|
564
823
|
this._children = [];
|
|
565
824
|
|
|
566
|
-
|
|
825
|
+
// Indexed loops avoid the iterator-protocol overhead `for...of`
|
|
826
|
+
// pays per element. Hot during webpack's emit when many
|
|
827
|
+
// ConcatSources are constructed/flattened.
|
|
828
|
+
for (let i = 0, l = args.length; i < l; i++) {
|
|
829
|
+
const item = args[i];
|
|
567
830
|
if (item instanceof ConcatSource) {
|
|
568
|
-
|
|
569
|
-
|
|
831
|
+
const children = item._children;
|
|
832
|
+
for (let j = 0, jl = children.length; j < jl; j++) {
|
|
833
|
+
this._children.push(children[j]);
|
|
570
834
|
}
|
|
571
835
|
} else {
|
|
572
836
|
this._children.push(item);
|
|
573
837
|
}
|
|
574
838
|
}
|
|
575
839
|
|
|
840
|
+
/**
|
|
841
|
+
* @type {boolean}
|
|
842
|
+
*/
|
|
576
843
|
this._isOptimized = args.length === 0;
|
|
577
844
|
}
|
|
578
845
|
|
|
@@ -590,8 +857,9 @@ class ConcatSource extends Source {
|
|
|
590
857
|
*/
|
|
591
858
|
add(item) {
|
|
592
859
|
if (item instanceof ConcatSource) {
|
|
593
|
-
|
|
594
|
-
|
|
860
|
+
const children = item._children;
|
|
861
|
+
for (let i = 0, l = children.length; i < l; i++) {
|
|
862
|
+
this._children.push(children[i]);
|
|
595
863
|
}
|
|
596
864
|
} else {
|
|
597
865
|
this._children.push(item);
|
|
@@ -604,17 +872,38 @@ class ConcatSource extends Source {
|
|
|
604
872
|
* @returns {void}
|
|
605
873
|
*/
|
|
606
874
|
addAllSkipOptimizing(items) {
|
|
607
|
-
for (
|
|
608
|
-
this._children.push(
|
|
875
|
+
for (let i = 0, l = items.length; i < l; i++) {
|
|
876
|
+
this._children.push(items[i]);
|
|
609
877
|
}
|
|
610
878
|
}
|
|
611
879
|
|
|
880
|
+
/**
|
|
881
|
+
* @returns {Buffer} buffer
|
|
882
|
+
*/
|
|
612
883
|
buffer() {
|
|
884
|
+
return Buffer.concat(this.buffers());
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* @returns {Buffer[]} buffers
|
|
889
|
+
*/
|
|
890
|
+
buffers() {
|
|
613
891
|
if (!this._isOptimized) this._optimize();
|
|
892
|
+
const children = /** @type {SourceLike[]} */ (this._children);
|
|
893
|
+
const childCount = children.length;
|
|
614
894
|
/** @type {Buffer[]} */
|
|
615
895
|
const buffers = [];
|
|
616
|
-
|
|
617
|
-
|
|
896
|
+
// Indexed loop + manual splat avoids the iterator allocation per
|
|
897
|
+
// child and the inner for-of allocation per child.buffers() call.
|
|
898
|
+
// Hot path during webpack's emit on deeply-nested ConcatSources.
|
|
899
|
+
for (let ci = 0; ci < childCount; ci++) {
|
|
900
|
+
const child = children[ci];
|
|
901
|
+
if (typeof child.buffers === "function") {
|
|
902
|
+
const childBuffers = child.buffers();
|
|
903
|
+
for (let bi = 0, blen = childBuffers.length; bi < blen; bi++) {
|
|
904
|
+
buffers.push(childBuffers[bi]);
|
|
905
|
+
}
|
|
906
|
+
} else if (typeof child.buffer === "function") {
|
|
618
907
|
buffers.push(child.buffer());
|
|
619
908
|
} else {
|
|
620
909
|
const bufferOrString = child.source();
|
|
@@ -626,7 +915,7 @@ class ConcatSource extends Source {
|
|
|
626
915
|
}
|
|
627
916
|
}
|
|
628
917
|
}
|
|
629
|
-
return
|
|
918
|
+
return buffers;
|
|
630
919
|
}
|
|
631
920
|
|
|
632
921
|
/**
|
|
@@ -634,18 +923,25 @@ class ConcatSource extends Source {
|
|
|
634
923
|
*/
|
|
635
924
|
source() {
|
|
636
925
|
if (!this._isOptimized) this._optimize();
|
|
926
|
+
const children = /** @type {Source[]} */ (this._children);
|
|
927
|
+
const childCount = children.length;
|
|
637
928
|
let source = "";
|
|
638
|
-
for (
|
|
639
|
-
source +=
|
|
929
|
+
for (let ci = 0; ci < childCount; ci++) {
|
|
930
|
+
source += children[ci].source();
|
|
640
931
|
}
|
|
641
932
|
return source;
|
|
642
933
|
}
|
|
643
934
|
|
|
935
|
+
/**
|
|
936
|
+
* @returns {number} size
|
|
937
|
+
*/
|
|
644
938
|
size() {
|
|
645
939
|
if (!this._isOptimized) this._optimize();
|
|
940
|
+
const children = /** @type {Source[]} */ (this._children);
|
|
941
|
+
const childCount = children.length;
|
|
646
942
|
let size = 0;
|
|
647
|
-
for (
|
|
648
|
-
size +=
|
|
943
|
+
for (let ci = 0; ci < childCount; ci++) {
|
|
944
|
+
size += children[ci].size();
|
|
649
945
|
}
|
|
650
946
|
return size;
|
|
651
947
|
}
|
|
@@ -690,7 +986,10 @@ class ConcatSource extends Source {
|
|
|
690
986
|
const finalSource = Boolean(options && options.finalSource);
|
|
691
987
|
let code = "";
|
|
692
988
|
let needToCloseMapping = false;
|
|
693
|
-
|
|
989
|
+
const children = /** @type {Source[]} */ (this._children);
|
|
990
|
+
const childCount = children.length;
|
|
991
|
+
for (let ci = 0; ci < childCount; ci++) {
|
|
992
|
+
const item = children[ci];
|
|
694
993
|
/** @type {number[]} */
|
|
695
994
|
const sourceIndexMapping = [];
|
|
696
995
|
/** @type {number[]} */
|
|
@@ -732,11 +1031,6 @@ class ConcatSource extends Source {
|
|
|
732
1031
|
sourceIndex < 0 || sourceIndex >= sourceIndexMapping.length
|
|
733
1032
|
? -1
|
|
734
1033
|
: sourceIndexMapping[sourceIndex];
|
|
735
|
-
const resultNameIndex =
|
|
736
|
-
nameIndex < 0 || nameIndex >= nameIndexMapping.length
|
|
737
|
-
? -1
|
|
738
|
-
: nameIndexMapping[nameIndex];
|
|
739
|
-
lastMappingLine = resultSourceIndex < 0 ? 0 : generatedLine;
|
|
740
1034
|
let _chunk;
|
|
741
1035
|
// When using finalSource, we process the entire source code at once at the end, rather than chunk by chunk
|
|
742
1036
|
if (finalSource) {
|
|
@@ -745,8 +1039,17 @@ class ConcatSource extends Source {
|
|
|
745
1039
|
_chunk = chunk;
|
|
746
1040
|
}
|
|
747
1041
|
if (resultSourceIndex < 0) {
|
|
1042
|
+
lastMappingLine = 0;
|
|
748
1043
|
onChunk(_chunk, line, column, -1, -1, -1, -1);
|
|
749
1044
|
} else {
|
|
1045
|
+
// Only compute the remapped name index when the chunk
|
|
1046
|
+
// actually carries a source mapping; otherwise it is
|
|
1047
|
+
// unused.
|
|
1048
|
+
const resultNameIndex =
|
|
1049
|
+
nameIndex < 0 || nameIndex >= nameIndexMapping.length
|
|
1050
|
+
? -1
|
|
1051
|
+
: nameIndexMapping[nameIndex];
|
|
1052
|
+
lastMappingLine = generatedLine;
|
|
750
1053
|
onChunk(
|
|
751
1054
|
_chunk,
|
|
752
1055
|
line,
|
|
@@ -758,11 +1061,11 @@ class ConcatSource extends Source {
|
|
|
758
1061
|
);
|
|
759
1062
|
}
|
|
760
1063
|
},
|
|
761
|
-
(i, source, sourceContent) => {
|
|
1064
|
+
(i, source, sourceContent, scopeBindings) => {
|
|
762
1065
|
let globalIndex = sourceMapping.get(source);
|
|
763
1066
|
if (globalIndex === undefined) {
|
|
764
1067
|
sourceMapping.set(source, (globalIndex = sourceMapping.size));
|
|
765
|
-
onSource(globalIndex, source, sourceContent);
|
|
1068
|
+
onSource(globalIndex, source, sourceContent, scopeBindings);
|
|
766
1069
|
}
|
|
767
1070
|
sourceIndexMapping[i] = globalIndex;
|
|
768
1071
|
},
|
|
@@ -808,16 +1111,46 @@ class ConcatSource extends Source {
|
|
|
808
1111
|
};
|
|
809
1112
|
}
|
|
810
1113
|
|
|
1114
|
+
/**
|
|
1115
|
+
* Release cached data held by this source. clearCache is a memory
|
|
1116
|
+
* hint: it never affects correctness or output, only how expensive
|
|
1117
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
1118
|
+
* every Source supports the call. Composite sources always recurse
|
|
1119
|
+
* into wrapped sources. When the same child is reachable via several
|
|
1120
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
1121
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
1122
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
1123
|
+
* streamChunks/updateHash on the same instance.
|
|
1124
|
+
* @param {ClearCacheOptions=} options selectors
|
|
1125
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
1126
|
+
* @returns {void}
|
|
1127
|
+
*/
|
|
1128
|
+
clearCache(options, visited) {
|
|
1129
|
+
if (visited !== undefined && visited.has(this)) return;
|
|
1130
|
+
const children = this._children;
|
|
1131
|
+
const { length } = children;
|
|
1132
|
+
let v = visited;
|
|
1133
|
+
if (v === undefined && length > 0) v = new WeakSet();
|
|
1134
|
+
if (v !== undefined) v.add(this);
|
|
1135
|
+
for (let i = 0; i < length; i++) {
|
|
1136
|
+
const child = children[i];
|
|
1137
|
+
if (typeof child !== "string" && typeof child.clearCache === "function") {
|
|
1138
|
+
child.clearCache(options, v);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
|
|
811
1143
|
/**
|
|
812
1144
|
* @param {HashLike} hash hash
|
|
813
1145
|
* @returns {void}
|
|
814
1146
|
*/
|
|
815
1147
|
updateHash(hash) {
|
|
816
1148
|
if (!this._isOptimized) this._optimize();
|
|
1149
|
+
const children = /** @type {Source[]} */ (this._children);
|
|
1150
|
+
const childCount = children.length;
|
|
817
1151
|
hash.update("ConcatSource");
|
|
818
|
-
for (
|
|
819
|
-
|
|
820
|
-
(item).updateHash(hash);
|
|
1152
|
+
for (let ci = 0; ci < childCount; ci++) {
|
|
1153
|
+
children[ci].updateHash(hash);
|
|
821
1154
|
}
|
|
822
1155
|
}
|
|
823
1156
|
|
|
@@ -879,7 +1212,9 @@ class ConcatSource extends Source {
|
|
|
879
1212
|
newChildren.push(currentRawSources);
|
|
880
1213
|
}
|
|
881
1214
|
};
|
|
882
|
-
|
|
1215
|
+
const children = this._children;
|
|
1216
|
+
for (let ci = 0, cl = children.length; ci < cl; ci++) {
|
|
1217
|
+
const child = children[ci];
|
|
883
1218
|
if (typeof child === "string") {
|
|
884
1219
|
if (currentString === undefined) {
|
|
885
1220
|
currentString = child;
|
|
@@ -921,7 +1256,7 @@ module.exports = ConcatSource;
|
|
|
921
1256
|
|
|
922
1257
|
/***/ }),
|
|
923
1258
|
|
|
924
|
-
/***/
|
|
1259
|
+
/***/ 169:
|
|
925
1260
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
926
1261
|
|
|
927
1262
|
/*
|
|
@@ -931,15 +1266,15 @@ module.exports = ConcatSource;
|
|
|
931
1266
|
|
|
932
1267
|
|
|
933
1268
|
|
|
934
|
-
const Source = __nccwpck_require__(
|
|
935
|
-
const { getMap, getSourceAndMap } = __nccwpck_require__(
|
|
936
|
-
const getGeneratedSourceInfo = __nccwpck_require__(
|
|
937
|
-
const
|
|
938
|
-
const splitIntoPotentialTokens = __nccwpck_require__(403);
|
|
1269
|
+
const Source = __nccwpck_require__(290);
|
|
1270
|
+
const { getMap, getSourceAndMap } = __nccwpck_require__(847);
|
|
1271
|
+
const getGeneratedSourceInfo = __nccwpck_require__(769);
|
|
1272
|
+
const { eachPotentialToken } = __nccwpck_require__(919);
|
|
939
1273
|
const {
|
|
940
1274
|
isDualStringBufferCachingEnabled,
|
|
941
|
-
} = __nccwpck_require__(
|
|
1275
|
+
} = __nccwpck_require__(345);
|
|
942
1276
|
|
|
1277
|
+
/** @typedef {import("./Source").ClearCacheOptions} ClearCacheOptions */
|
|
943
1278
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
944
1279
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
945
1280
|
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
|
|
@@ -950,28 +1285,36 @@ const {
|
|
|
950
1285
|
/** @typedef {import("./helpers/streamChunks").OnName} OnName */
|
|
951
1286
|
/** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
|
|
952
1287
|
/** @typedef {import("./helpers/streamChunks").Options} Options */
|
|
1288
|
+
/** @typedef {import("./helpers/streamChunks").ScopeBindings} ScopeBindings */
|
|
953
1289
|
|
|
954
1290
|
class OriginalSource extends Source {
|
|
955
1291
|
/**
|
|
956
1292
|
* @param {string | Buffer} value value
|
|
957
1293
|
* @param {string} name name
|
|
1294
|
+
* @param {ScopeBindings=} scopeBindings what each name this source declares
|
|
1295
|
+
* evaluates to in the generated code, for the map's `scopes` field
|
|
958
1296
|
*/
|
|
959
|
-
constructor(value, name) {
|
|
1297
|
+
constructor(value, name, scopeBindings) {
|
|
960
1298
|
super();
|
|
961
1299
|
|
|
962
1300
|
const isBuffer = Buffer.isBuffer(value);
|
|
963
1301
|
|
|
964
1302
|
/**
|
|
965
|
-
* @private
|
|
966
1303
|
* @type {undefined | string}
|
|
967
1304
|
*/
|
|
968
1305
|
this._value = isBuffer ? undefined : value;
|
|
969
1306
|
/**
|
|
970
|
-
* @private
|
|
971
1307
|
* @type {undefined | Buffer}
|
|
972
1308
|
*/
|
|
973
1309
|
this._valueAsBuffer = isBuffer ? value : undefined;
|
|
1310
|
+
/**
|
|
1311
|
+
* @type {string}
|
|
1312
|
+
*/
|
|
974
1313
|
this._name = name;
|
|
1314
|
+
/**
|
|
1315
|
+
* @type {undefined | ScopeBindings}
|
|
1316
|
+
*/
|
|
1317
|
+
this._scopeBindings = scopeBindings;
|
|
975
1318
|
}
|
|
976
1319
|
|
|
977
1320
|
getName() {
|
|
@@ -994,6 +1337,9 @@ class OriginalSource extends Source {
|
|
|
994
1337
|
return this._value;
|
|
995
1338
|
}
|
|
996
1339
|
|
|
1340
|
+
/**
|
|
1341
|
+
* @returns {Buffer} buffer
|
|
1342
|
+
*/
|
|
997
1343
|
buffer() {
|
|
998
1344
|
if (this._valueAsBuffer === undefined) {
|
|
999
1345
|
const value = Buffer.from(/** @type {string} */ (this._value), "utf8");
|
|
@@ -1005,6 +1351,20 @@ class OriginalSource extends Source {
|
|
|
1005
1351
|
return this._valueAsBuffer;
|
|
1006
1352
|
}
|
|
1007
1353
|
|
|
1354
|
+
/**
|
|
1355
|
+
* @returns {number} size
|
|
1356
|
+
*/
|
|
1357
|
+
size() {
|
|
1358
|
+
if (this._cachedSize !== undefined) return this._cachedSize;
|
|
1359
|
+
if (this._valueAsBuffer !== undefined) {
|
|
1360
|
+
return (this._cachedSize = this._valueAsBuffer.length);
|
|
1361
|
+
}
|
|
1362
|
+
return (this._cachedSize = Buffer.byteLength(
|
|
1363
|
+
/** @type {string} */ (this._value),
|
|
1364
|
+
"utf8",
|
|
1365
|
+
));
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1008
1368
|
/**
|
|
1009
1369
|
* @param {MapOptions=} options map options
|
|
1010
1370
|
* @returns {RawSourceMap | null} map
|
|
@@ -1034,34 +1394,36 @@ class OriginalSource extends Source {
|
|
|
1034
1394
|
/** @type {Buffer} */
|
|
1035
1395
|
(this._valueAsBuffer).toString("utf8");
|
|
1036
1396
|
}
|
|
1037
|
-
onSource(0, this._name, this._value);
|
|
1397
|
+
onSource(0, this._name, this._value, this._scopeBindings);
|
|
1038
1398
|
const finalSource = Boolean(options && options.finalSource);
|
|
1039
1399
|
if (!options || options.columns !== false) {
|
|
1040
|
-
// With column info we need to
|
|
1041
|
-
|
|
1400
|
+
// With column info we need to walk every potential token. The
|
|
1401
|
+
// scan is streamed by offset (see `eachPotentialToken`) so we
|
|
1402
|
+
// only allocate a chunk substring when one is actually emitted —
|
|
1403
|
+
// and `map()` / `sourceAndMap()` set `finalSource`, in which case
|
|
1404
|
+
// the chunk is dropped and no substring is allocated at all.
|
|
1405
|
+
const value = this._value;
|
|
1042
1406
|
let line = 1;
|
|
1043
1407
|
let column = 0;
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
if (
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
onChunk(chunk, line, column, 0, line, column, -1);
|
|
1052
|
-
}
|
|
1053
|
-
if (isEndOfLine) {
|
|
1054
|
-
line++;
|
|
1055
|
-
column = 0;
|
|
1056
|
-
} else {
|
|
1057
|
-
column += match.length;
|
|
1058
|
-
}
|
|
1408
|
+
eachPotentialToken(value, (start, end, newline) => {
|
|
1409
|
+
const length = end - start;
|
|
1410
|
+
if (newline && length === 1) {
|
|
1411
|
+
if (!finalSource) onChunk("\n", line, column, -1, -1, -1, -1);
|
|
1412
|
+
} else {
|
|
1413
|
+
const chunk = finalSource ? undefined : value.slice(start, end);
|
|
1414
|
+
onChunk(chunk, line, column, 0, line, column, -1);
|
|
1059
1415
|
}
|
|
1060
|
-
|
|
1416
|
+
if (newline) {
|
|
1417
|
+
line++;
|
|
1418
|
+
column = 0;
|
|
1419
|
+
} else {
|
|
1420
|
+
column += length;
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1061
1423
|
return {
|
|
1062
1424
|
generatedLine: line,
|
|
1063
1425
|
generatedColumn: column,
|
|
1064
|
-
source: finalSource ?
|
|
1426
|
+
source: finalSource ? value : undefined,
|
|
1065
1427
|
};
|
|
1066
1428
|
} else if (finalSource) {
|
|
1067
1429
|
// Without column info and with final source we only
|
|
@@ -1087,27 +1449,64 @@ class OriginalSource extends Source {
|
|
|
1087
1449
|
}
|
|
1088
1450
|
return result;
|
|
1089
1451
|
}
|
|
1090
|
-
// Without column info, but also without final source
|
|
1091
|
-
//
|
|
1452
|
+
// Without column info, but also without final source.
|
|
1453
|
+
// We only get here when (options.columns === false && !finalSource),
|
|
1454
|
+
// so the source field is always undefined and the chunk arg is always
|
|
1455
|
+
// the line text. Single-pass scan over newlines avoids the
|
|
1456
|
+
// splitIntoLines array allocation.
|
|
1457
|
+
const value = this._value;
|
|
1458
|
+
const len = value.length;
|
|
1459
|
+
if (len === 0) {
|
|
1460
|
+
return { generatedLine: 1, generatedColumn: 0, source: undefined };
|
|
1461
|
+
}
|
|
1092
1462
|
let line = 1;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1463
|
+
let i = 0;
|
|
1464
|
+
while (i < len) {
|
|
1465
|
+
const n = value.indexOf("\n", i);
|
|
1466
|
+
if (n === -1) {
|
|
1467
|
+
const lastLine = i === 0 ? value : value.slice(i);
|
|
1468
|
+
onChunk(lastLine, line, 0, 0, line, 0, -1);
|
|
1469
|
+
return {
|
|
1470
|
+
generatedLine: line,
|
|
1471
|
+
generatedColumn: lastLine.length,
|
|
1472
|
+
source: undefined,
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
const chunk = n === i ? "\n" : value.slice(i, n + 1);
|
|
1476
|
+
onChunk(chunk, line, 0, 0, line, 0, -1);
|
|
1098
1477
|
line++;
|
|
1478
|
+
i = n + 1;
|
|
1479
|
+
}
|
|
1480
|
+
// Source ended with a newline.
|
|
1481
|
+
return { generatedLine: line, generatedColumn: 0, source: undefined };
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
/**
|
|
1485
|
+
* Release cached data held by this source. clearCache is a memory
|
|
1486
|
+
* hint: it never affects correctness or output, only how expensive
|
|
1487
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
1488
|
+
* every Source supports the call. Composite sources always recurse
|
|
1489
|
+
* into wrapped sources. When the same child is reachable via several
|
|
1490
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
1491
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
1492
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
1493
|
+
* streamChunks/updateHash on the same instance.
|
|
1494
|
+
* @param {ClearCacheOptions=} options selectors
|
|
1495
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
1496
|
+
* @returns {void}
|
|
1497
|
+
*/
|
|
1498
|
+
clearCache(options, visited) {
|
|
1499
|
+
if (visited !== undefined) {
|
|
1500
|
+
if (visited.has(this)) return;
|
|
1501
|
+
visited.add(this);
|
|
1502
|
+
}
|
|
1503
|
+
if (options !== undefined && options.source === false) return;
|
|
1504
|
+
if (this._value !== undefined && this._valueAsBuffer !== undefined) {
|
|
1505
|
+
// When both forms are cached, drop the string (UTF-16 in V8 is
|
|
1506
|
+
// ~2 bytes/char) and keep the more compact buffer. source() will
|
|
1507
|
+
// rehydrate the string on demand.
|
|
1508
|
+
this._value = undefined;
|
|
1099
1509
|
}
|
|
1100
|
-
return matches.length === 0 || /** @type {string} */ (match).endsWith("\n")
|
|
1101
|
-
? {
|
|
1102
|
-
generatedLine: matches.length + 1,
|
|
1103
|
-
generatedColumn: 0,
|
|
1104
|
-
source: finalSource ? this._value : undefined,
|
|
1105
|
-
}
|
|
1106
|
-
: {
|
|
1107
|
-
generatedLine: matches.length,
|
|
1108
|
-
generatedColumn: /** @type {string} */ (match).length,
|
|
1109
|
-
source: finalSource ? this._value : undefined,
|
|
1110
|
-
};
|
|
1111
1510
|
}
|
|
1112
1511
|
|
|
1113
1512
|
/**
|
|
@@ -1116,7 +1515,13 @@ class OriginalSource extends Source {
|
|
|
1116
1515
|
*/
|
|
1117
1516
|
updateHash(hash) {
|
|
1118
1517
|
hash.update("OriginalSource");
|
|
1119
|
-
|
|
1518
|
+
// Same as RawSource: utf8 is what `buffer()` would have encoded to,
|
|
1519
|
+
// and one of the two forms is always set.
|
|
1520
|
+
if (this._valueAsBuffer === undefined) {
|
|
1521
|
+
hash.update(/** @type {string} */ (this._value));
|
|
1522
|
+
} else {
|
|
1523
|
+
hash.update(this._valueAsBuffer);
|
|
1524
|
+
}
|
|
1120
1525
|
hash.update(this._name || "");
|
|
1121
1526
|
}
|
|
1122
1527
|
}
|
|
@@ -1126,7 +1531,7 @@ module.exports = OriginalSource;
|
|
|
1126
1531
|
|
|
1127
1532
|
/***/ }),
|
|
1128
1533
|
|
|
1129
|
-
/***/
|
|
1534
|
+
/***/ 814:
|
|
1130
1535
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1131
1536
|
|
|
1132
1537
|
/*
|
|
@@ -1136,11 +1541,12 @@ module.exports = OriginalSource;
|
|
|
1136
1541
|
|
|
1137
1542
|
|
|
1138
1543
|
|
|
1139
|
-
const RawSource = __nccwpck_require__(
|
|
1140
|
-
const Source = __nccwpck_require__(
|
|
1141
|
-
const { getMap, getSourceAndMap } = __nccwpck_require__(
|
|
1142
|
-
const streamChunks = __nccwpck_require__(
|
|
1544
|
+
const RawSource = __nccwpck_require__(132);
|
|
1545
|
+
const Source = __nccwpck_require__(290);
|
|
1546
|
+
const { getMap, getSourceAndMap } = __nccwpck_require__(847);
|
|
1547
|
+
const streamChunks = __nccwpck_require__(487);
|
|
1143
1548
|
|
|
1549
|
+
/** @typedef {import("./Source").ClearCacheOptions} ClearCacheOptions */
|
|
1144
1550
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
1145
1551
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
1146
1552
|
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
|
|
@@ -1152,7 +1558,31 @@ const streamChunks = __nccwpck_require__(779);
|
|
|
1152
1558
|
/** @typedef {import("./helpers/streamChunks").OnSource} OnSource */
|
|
1153
1559
|
/** @typedef {import("./helpers/streamChunks").Options} Options */
|
|
1154
1560
|
|
|
1155
|
-
|
|
1561
|
+
// `/\n/g` (no lookahead) lets V8's regex compiler take its
|
|
1562
|
+
// literal-character fast path; the previous `/\n(?=.|\s)/g` form
|
|
1563
|
+
// disabled it. Output stays identical because `buildPrefixed` strips
|
|
1564
|
+
// the spurious trailing prefix when the input ended with a newline.
|
|
1565
|
+
const NEWLINE_REGEX = /\n/g;
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* Prepend `prefix` and insert `prefix` after every newline that has
|
|
1569
|
+
* content following — the original `/\n(?=.|\s)/g` semantics, but
|
|
1570
|
+
* implemented as a fast-path regex + tail-strip.
|
|
1571
|
+
* @param {string} prefix prefix
|
|
1572
|
+
* @param {string} node underlying source string
|
|
1573
|
+
* @returns {string} prefixed string
|
|
1574
|
+
*/
|
|
1575
|
+
const buildPrefixed = (prefix, node) => {
|
|
1576
|
+
if (prefix.length === 0) return node;
|
|
1577
|
+
const replaced = node.replace(NEWLINE_REGEX, `\n${prefix}`);
|
|
1578
|
+
const len = node.length;
|
|
1579
|
+
// `/\n/g` matches the trailing newline too, so the replace appended
|
|
1580
|
+
// a spurious prefix at the end. Trim it.
|
|
1581
|
+
if (len > 0 && node.charCodeAt(len - 1) === 10) {
|
|
1582
|
+
return prefix + replaced.slice(0, replaced.length - prefix.length);
|
|
1583
|
+
}
|
|
1584
|
+
return prefix + replaced;
|
|
1585
|
+
};
|
|
1156
1586
|
|
|
1157
1587
|
class PrefixSource extends Source {
|
|
1158
1588
|
/**
|
|
@@ -1162,14 +1592,16 @@ class PrefixSource extends Source {
|
|
|
1162
1592
|
constructor(prefix, source) {
|
|
1163
1593
|
super();
|
|
1164
1594
|
/**
|
|
1165
|
-
* @
|
|
1595
|
+
* @type {string}
|
|
1596
|
+
*/
|
|
1597
|
+
this._prefix = prefix;
|
|
1598
|
+
/**
|
|
1166
1599
|
* @type {Source}
|
|
1167
1600
|
*/
|
|
1168
1601
|
this._source =
|
|
1169
1602
|
typeof source === "string" || Buffer.isBuffer(source)
|
|
1170
1603
|
? new RawSource(source, true)
|
|
1171
1604
|
: source;
|
|
1172
|
-
this._prefix = prefix;
|
|
1173
1605
|
}
|
|
1174
1606
|
|
|
1175
1607
|
getPrefix() {
|
|
@@ -1184,12 +1616,19 @@ class PrefixSource extends Source {
|
|
|
1184
1616
|
* @returns {SourceValue} source
|
|
1185
1617
|
*/
|
|
1186
1618
|
source() {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1619
|
+
return buildPrefixed(
|
|
1620
|
+
this._prefix,
|
|
1621
|
+
/** @type {string} */ (this._source.source()),
|
|
1622
|
+
);
|
|
1190
1623
|
}
|
|
1191
1624
|
|
|
1192
|
-
//
|
|
1625
|
+
// buffer() / buffers() / size() inherit from Source.prototype.
|
|
1626
|
+
// Source.buffer() does Buffer.from(this.source(), "utf8") — cheaper
|
|
1627
|
+
// in CodSpeed instruction count than any safe override we tried
|
|
1628
|
+
// (caching is unsafe with mutable child; a JS-side splice loop
|
|
1629
|
+
// regressed ~5x in instruction count). Speeding up source() via the
|
|
1630
|
+
// simpler regex above lifts buffer(), buffers(), size(), and any
|
|
1631
|
+
// other `this.source()`-using path with no override needed.
|
|
1193
1632
|
|
|
1194
1633
|
/**
|
|
1195
1634
|
* @param {MapOptions=} options map options
|
|
@@ -1268,10 +1707,7 @@ class PrefixSource extends Source {
|
|
|
1268
1707
|
generatedColumn === 0
|
|
1269
1708
|
? 0
|
|
1270
1709
|
: prefixOffset + /** @type {number} */ (generatedColumn),
|
|
1271
|
-
source:
|
|
1272
|
-
source !== undefined
|
|
1273
|
-
? prefix + source.replace(REPLACE_REGEX, `\n${prefix}`)
|
|
1274
|
-
: undefined,
|
|
1710
|
+
source: source !== undefined ? buildPrefixed(prefix, source) : undefined,
|
|
1275
1711
|
};
|
|
1276
1712
|
}
|
|
1277
1713
|
|
|
@@ -1284,6 +1720,28 @@ class PrefixSource extends Source {
|
|
|
1284
1720
|
this._source.updateHash(hash);
|
|
1285
1721
|
hash.update(this._prefix);
|
|
1286
1722
|
}
|
|
1723
|
+
|
|
1724
|
+
/**
|
|
1725
|
+
* Release cached data held by this source. clearCache is a memory
|
|
1726
|
+
* hint: it never affects correctness or output, only how expensive
|
|
1727
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
1728
|
+
* every Source supports the call. Composite sources always recurse
|
|
1729
|
+
* into wrapped sources. When the same child is reachable via several
|
|
1730
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
1731
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
1732
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
1733
|
+
* streamChunks/updateHash on the same instance.
|
|
1734
|
+
* @param {ClearCacheOptions=} options selectors
|
|
1735
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
1736
|
+
* @returns {void}
|
|
1737
|
+
*/
|
|
1738
|
+
clearCache(options, visited) {
|
|
1739
|
+
if (visited !== undefined && visited.has(this)) return;
|
|
1740
|
+
let v = visited;
|
|
1741
|
+
if (v === undefined) v = new WeakSet();
|
|
1742
|
+
v.add(this);
|
|
1743
|
+
this._source.clearCache(options, v);
|
|
1744
|
+
}
|
|
1287
1745
|
}
|
|
1288
1746
|
|
|
1289
1747
|
module.exports = PrefixSource;
|
|
@@ -1291,7 +1749,7 @@ module.exports = PrefixSource;
|
|
|
1291
1749
|
|
|
1292
1750
|
/***/ }),
|
|
1293
1751
|
|
|
1294
|
-
/***/
|
|
1752
|
+
/***/ 132:
|
|
1295
1753
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1296
1754
|
|
|
1297
1755
|
/*
|
|
@@ -1301,13 +1759,14 @@ module.exports = PrefixSource;
|
|
|
1301
1759
|
|
|
1302
1760
|
|
|
1303
1761
|
|
|
1304
|
-
const Source = __nccwpck_require__(
|
|
1305
|
-
const streamChunksOfRawSource = __nccwpck_require__(
|
|
1762
|
+
const Source = __nccwpck_require__(290);
|
|
1763
|
+
const streamChunksOfRawSource = __nccwpck_require__(543);
|
|
1306
1764
|
const {
|
|
1307
1765
|
internString,
|
|
1308
1766
|
isDualStringBufferCachingEnabled,
|
|
1309
|
-
} = __nccwpck_require__(
|
|
1767
|
+
} = __nccwpck_require__(345);
|
|
1310
1768
|
|
|
1769
|
+
/** @typedef {import("./Source").ClearCacheOptions} ClearCacheOptions */
|
|
1311
1770
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
1312
1771
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
1313
1772
|
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
|
|
@@ -1326,32 +1785,32 @@ class RawSource extends Source {
|
|
|
1326
1785
|
constructor(value, convertToString = false) {
|
|
1327
1786
|
super();
|
|
1328
1787
|
const isBuffer = Buffer.isBuffer(value);
|
|
1329
|
-
if (
|
|
1788
|
+
if (isBuffer) {
|
|
1789
|
+
/**
|
|
1790
|
+
* @type {boolean}
|
|
1791
|
+
*/
|
|
1792
|
+
this._valueIsBuffer = !convertToString;
|
|
1793
|
+
/**
|
|
1794
|
+
* @type {undefined | string | Buffer}
|
|
1795
|
+
*/
|
|
1796
|
+
this._value = convertToString ? undefined : value;
|
|
1797
|
+
/**
|
|
1798
|
+
* @type {undefined | Buffer}
|
|
1799
|
+
*/
|
|
1800
|
+
this._valueAsBuffer = value;
|
|
1801
|
+
/**
|
|
1802
|
+
* @type {undefined | string}
|
|
1803
|
+
*/
|
|
1804
|
+
this._valueAsString = undefined;
|
|
1805
|
+
} else if (typeof value === "string") {
|
|
1806
|
+
const interned = internString(value);
|
|
1807
|
+
this._valueIsBuffer = false;
|
|
1808
|
+
this._value = interned;
|
|
1809
|
+
this._valueAsBuffer = undefined;
|
|
1810
|
+
this._valueAsString = interned;
|
|
1811
|
+
} else {
|
|
1330
1812
|
throw new TypeError("argument 'value' must be either string or Buffer");
|
|
1331
1813
|
}
|
|
1332
|
-
this._valueIsBuffer = !convertToString && isBuffer;
|
|
1333
|
-
const internedString =
|
|
1334
|
-
typeof value === "string" ? internString(value) : undefined;
|
|
1335
|
-
/**
|
|
1336
|
-
* @private
|
|
1337
|
-
* @type {undefined | string | Buffer}
|
|
1338
|
-
*/
|
|
1339
|
-
this._value =
|
|
1340
|
-
convertToString && isBuffer
|
|
1341
|
-
? undefined
|
|
1342
|
-
: typeof value === "string"
|
|
1343
|
-
? internedString
|
|
1344
|
-
: value;
|
|
1345
|
-
/**
|
|
1346
|
-
* @private
|
|
1347
|
-
* @type {undefined | Buffer}
|
|
1348
|
-
*/
|
|
1349
|
-
this._valueAsBuffer = isBuffer ? value : undefined;
|
|
1350
|
-
/**
|
|
1351
|
-
* @private
|
|
1352
|
-
* @type {undefined | string}
|
|
1353
|
-
*/
|
|
1354
|
-
this._valueAsString = isBuffer ? undefined : internedString;
|
|
1355
1814
|
}
|
|
1356
1815
|
|
|
1357
1816
|
isBuffer() {
|
|
@@ -1374,6 +1833,9 @@ class RawSource extends Source {
|
|
|
1374
1833
|
return this._value;
|
|
1375
1834
|
}
|
|
1376
1835
|
|
|
1836
|
+
/**
|
|
1837
|
+
* @returns {Buffer} buffer
|
|
1838
|
+
*/
|
|
1377
1839
|
buffer() {
|
|
1378
1840
|
if (this._valueAsBuffer === undefined) {
|
|
1379
1841
|
const value = Buffer.from(/** @type {string} */ (this._value), "utf8");
|
|
@@ -1385,6 +1847,20 @@ class RawSource extends Source {
|
|
|
1385
1847
|
return this._valueAsBuffer;
|
|
1386
1848
|
}
|
|
1387
1849
|
|
|
1850
|
+
/**
|
|
1851
|
+
* @returns {number} size
|
|
1852
|
+
*/
|
|
1853
|
+
size() {
|
|
1854
|
+
if (this._cachedSize !== undefined) return this._cachedSize;
|
|
1855
|
+
if (this._valueAsBuffer !== undefined) {
|
|
1856
|
+
return (this._cachedSize = this._valueAsBuffer.length);
|
|
1857
|
+
}
|
|
1858
|
+
return (this._cachedSize = Buffer.byteLength(
|
|
1859
|
+
/** @type {string} */ (this._valueAsString),
|
|
1860
|
+
"utf8",
|
|
1861
|
+
));
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1388
1864
|
/**
|
|
1389
1865
|
* @param {MapOptions=} options map options
|
|
1390
1866
|
* @returns {RawSourceMap | null} map
|
|
@@ -1419,13 +1895,55 @@ class RawSource extends Source {
|
|
|
1419
1895
|
);
|
|
1420
1896
|
}
|
|
1421
1897
|
|
|
1898
|
+
/**
|
|
1899
|
+
* Release cached data held by this source. clearCache is a memory
|
|
1900
|
+
* hint: it never affects correctness or output, only how expensive
|
|
1901
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
1902
|
+
* every Source supports the call. Composite sources always recurse
|
|
1903
|
+
* into wrapped sources. When the same child is reachable via several
|
|
1904
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
1905
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
1906
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
1907
|
+
* streamChunks/updateHash on the same instance.
|
|
1908
|
+
* @param {ClearCacheOptions=} options selectors
|
|
1909
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
1910
|
+
* @returns {void}
|
|
1911
|
+
*/
|
|
1912
|
+
clearCache(options, visited) {
|
|
1913
|
+
if (visited !== undefined) {
|
|
1914
|
+
if (visited.has(this)) return;
|
|
1915
|
+
visited.add(this);
|
|
1916
|
+
}
|
|
1917
|
+
if (options !== undefined && options.source === false) return;
|
|
1918
|
+
if (this._valueIsBuffer) {
|
|
1919
|
+
// Buffer is the primary representation (and lives in `_value`);
|
|
1920
|
+
// only the string form, populated lazily by streamChunks, is
|
|
1921
|
+
// safe to drop.
|
|
1922
|
+
this._valueAsString = undefined;
|
|
1923
|
+
} else if (this._valueAsBuffer !== undefined && this._value !== undefined) {
|
|
1924
|
+
// The source was constructed from a string (so `_value` and
|
|
1925
|
+
// `_valueAsString` reference the same interned string) and the
|
|
1926
|
+
// buffer form was materialized later by `buffer()` /
|
|
1927
|
+
// `updateHash()`. The buffer is therefore safe to drop.
|
|
1928
|
+
this._valueAsBuffer = undefined;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1422
1932
|
/**
|
|
1423
1933
|
* @param {HashLike} hash hash
|
|
1424
1934
|
* @returns {void}
|
|
1425
1935
|
*/
|
|
1426
1936
|
updateHash(hash) {
|
|
1427
1937
|
hash.update("RawSource");
|
|
1428
|
-
|
|
1938
|
+
// A string is hashed as utf8, which is what `buffer()` would have
|
|
1939
|
+
// encoded it to, so hashing never has to materialize the buffer.
|
|
1940
|
+
// One of the two forms is always set: the constructor sets whichever
|
|
1941
|
+
// matches its input, and `clearCache` only drops the derived one.
|
|
1942
|
+
if (this._valueAsBuffer === undefined) {
|
|
1943
|
+
hash.update(/** @type {string} */ (this._valueAsString));
|
|
1944
|
+
} else {
|
|
1945
|
+
hash.update(this._valueAsBuffer);
|
|
1946
|
+
}
|
|
1429
1947
|
}
|
|
1430
1948
|
}
|
|
1431
1949
|
|
|
@@ -1434,7 +1952,7 @@ module.exports = RawSource;
|
|
|
1434
1952
|
|
|
1435
1953
|
/***/ }),
|
|
1436
1954
|
|
|
1437
|
-
/***/
|
|
1955
|
+
/***/ 522:
|
|
1438
1956
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1439
1957
|
|
|
1440
1958
|
/*
|
|
@@ -1444,11 +1962,12 @@ module.exports = RawSource;
|
|
|
1444
1962
|
|
|
1445
1963
|
|
|
1446
1964
|
|
|
1447
|
-
const Source = __nccwpck_require__(
|
|
1448
|
-
const { getMap, getSourceAndMap } = __nccwpck_require__(
|
|
1449
|
-
const splitIntoLines = __nccwpck_require__(
|
|
1450
|
-
const streamChunks = __nccwpck_require__(
|
|
1965
|
+
const Source = __nccwpck_require__(290);
|
|
1966
|
+
const { getMap, getSourceAndMap } = __nccwpck_require__(847);
|
|
1967
|
+
const splitIntoLines = __nccwpck_require__(416);
|
|
1968
|
+
const streamChunks = __nccwpck_require__(487);
|
|
1451
1969
|
|
|
1970
|
+
/** @typedef {import("./Source").ClearCacheOptions} ClearCacheOptions */
|
|
1452
1971
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
1453
1972
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
1454
1973
|
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
|
|
@@ -1470,6 +1989,38 @@ const hasStableSort =
|
|
|
1470
1989
|
// This is larger than max string length
|
|
1471
1990
|
const MAX_SOURCE_POSITION = 0x20000000;
|
|
1472
1991
|
|
|
1992
|
+
/**
|
|
1993
|
+
* Stable comparator hoisted to module scope so each `_sortReplacements()`
|
|
1994
|
+
* call doesn't allocate a fresh closure.
|
|
1995
|
+
* @param {Replacement} a a
|
|
1996
|
+
* @param {Replacement} b b
|
|
1997
|
+
* @returns {number} order
|
|
1998
|
+
*/
|
|
1999
|
+
const compareStable = (a, b) => {
|
|
2000
|
+
const diff1 = a.start - b.start;
|
|
2001
|
+
if (diff1 !== 0) return diff1;
|
|
2002
|
+
const diff2 = a.end - b.end;
|
|
2003
|
+
if (diff2 !== 0) return diff2;
|
|
2004
|
+
return 0;
|
|
2005
|
+
};
|
|
2006
|
+
|
|
2007
|
+
/**
|
|
2008
|
+
* Index-stabilising comparator for v8 < 7.0 (pre-stable Array.prototype.sort).
|
|
2009
|
+
* Unreachable on any supported Node — the `hasStableSort` guard always
|
|
2010
|
+
* wins so coverage tools never see this execute.
|
|
2011
|
+
* @param {Replacement} a a
|
|
2012
|
+
* @param {Replacement} b b
|
|
2013
|
+
* @returns {number} order
|
|
2014
|
+
*/
|
|
2015
|
+
/* istanbul ignore next */
|
|
2016
|
+
const compareUnstableFallback = (a, b) => {
|
|
2017
|
+
const diff1 = a.start - b.start;
|
|
2018
|
+
if (diff1 !== 0) return diff1;
|
|
2019
|
+
const diff2 = a.end - b.end;
|
|
2020
|
+
if (diff2 !== 0) return diff2;
|
|
2021
|
+
return /** @type {number} */ (a.index) - /** @type {number} */ (b.index);
|
|
2022
|
+
};
|
|
2023
|
+
|
|
1473
2024
|
class Replacement {
|
|
1474
2025
|
/**
|
|
1475
2026
|
* @param {number} start start
|
|
@@ -1482,6 +2033,8 @@ class Replacement {
|
|
|
1482
2033
|
this.end = end;
|
|
1483
2034
|
this.content = content;
|
|
1484
2035
|
this.name = name;
|
|
2036
|
+
// V8 < 7.0 only — unreachable on any supported Node.
|
|
2037
|
+
/* istanbul ignore if */
|
|
1485
2038
|
if (!hasStableSort) {
|
|
1486
2039
|
this.index = -1;
|
|
1487
2040
|
}
|
|
@@ -1495,10 +2048,19 @@ class ReplaceSource extends Source {
|
|
|
1495
2048
|
*/
|
|
1496
2049
|
constructor(source, name) {
|
|
1497
2050
|
super();
|
|
2051
|
+
/**
|
|
2052
|
+
* @type {Source}
|
|
2053
|
+
*/
|
|
1498
2054
|
this._source = source;
|
|
2055
|
+
/**
|
|
2056
|
+
* @type {string | undefined}
|
|
2057
|
+
*/
|
|
1499
2058
|
this._name = name;
|
|
1500
2059
|
/** @type {Replacement[]} */
|
|
1501
2060
|
this._replacements = [];
|
|
2061
|
+
/**
|
|
2062
|
+
* @type {boolean}
|
|
2063
|
+
*/
|
|
1502
2064
|
this._isSorted = true;
|
|
1503
2065
|
}
|
|
1504
2066
|
|
|
@@ -1551,7 +2113,7 @@ class ReplaceSource extends Source {
|
|
|
1551
2113
|
if (this._replacements.length === 0) {
|
|
1552
2114
|
return this._source.source();
|
|
1553
2115
|
}
|
|
1554
|
-
|
|
2116
|
+
const current = /** @type {string} */ (this._source.source());
|
|
1555
2117
|
let pos = 0;
|
|
1556
2118
|
const result = [];
|
|
1557
2119
|
|
|
@@ -1560,22 +2122,45 @@ class ReplaceSource extends Source {
|
|
|
1560
2122
|
const start = Math.floor(replacement.start);
|
|
1561
2123
|
const end = Math.floor(replacement.end + 1);
|
|
1562
2124
|
if (pos < start) {
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
current
|
|
2125
|
+
// slice directly from the original string rather than repeatedly
|
|
2126
|
+
// producing smaller intermediate strings, which avoids O(n) copies.
|
|
2127
|
+
result.push(current.slice(pos, start));
|
|
1566
2128
|
pos = start;
|
|
1567
2129
|
}
|
|
1568
2130
|
result.push(replacement.content);
|
|
1569
2131
|
if (pos < end) {
|
|
1570
|
-
const offset = end - pos;
|
|
1571
|
-
current = current.slice(offset);
|
|
1572
2132
|
pos = end;
|
|
1573
2133
|
}
|
|
1574
2134
|
}
|
|
1575
|
-
|
|
2135
|
+
if (pos < current.length) {
|
|
2136
|
+
result.push(pos === 0 ? current : current.slice(pos));
|
|
2137
|
+
}
|
|
1576
2138
|
return result.join("");
|
|
1577
2139
|
}
|
|
1578
2140
|
|
|
2141
|
+
/**
|
|
2142
|
+
* @returns {Buffer} buffer
|
|
2143
|
+
*/
|
|
2144
|
+
buffer() {
|
|
2145
|
+
if (this._replacements.length === 0) {
|
|
2146
|
+
return this._source.buffer();
|
|
2147
|
+
}
|
|
2148
|
+
return super.buffer();
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2151
|
+
/**
|
|
2152
|
+
* @returns {Buffer[]} buffers
|
|
2153
|
+
*/
|
|
2154
|
+
buffers() {
|
|
2155
|
+
if (this._replacements.length === 0) {
|
|
2156
|
+
// TODO remove in the next major release
|
|
2157
|
+
return typeof this._source.buffers === "function"
|
|
2158
|
+
? this._source.buffers()
|
|
2159
|
+
: [this._source.buffer()];
|
|
2160
|
+
}
|
|
2161
|
+
return [this.buffer()];
|
|
2162
|
+
}
|
|
2163
|
+
|
|
1579
2164
|
/**
|
|
1580
2165
|
* @param {MapOptions=} options map options
|
|
1581
2166
|
* @returns {RawSourceMap | null} map
|
|
@@ -1604,25 +2189,34 @@ class ReplaceSource extends Source {
|
|
|
1604
2189
|
|
|
1605
2190
|
_sortReplacements() {
|
|
1606
2191
|
if (this._isSorted) return;
|
|
2192
|
+
const replacements = this._replacements;
|
|
2193
|
+
// Replacements are usually appended in source order (ties keep
|
|
2194
|
+
// insertion order, matching a stable sort), so an O(n) pre-scan
|
|
2195
|
+
// often lets us skip the sort and its per-element comparator calls.
|
|
2196
|
+
let isPresorted = true;
|
|
2197
|
+
for (let i = 1; i < replacements.length; i++) {
|
|
2198
|
+
const prev = replacements[i - 1];
|
|
2199
|
+
const repl = replacements[i];
|
|
2200
|
+
if (
|
|
2201
|
+
repl.start < prev.start ||
|
|
2202
|
+
(repl.start === prev.start && repl.end < prev.end)
|
|
2203
|
+
) {
|
|
2204
|
+
isPresorted = false;
|
|
2205
|
+
break;
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
if (isPresorted) {
|
|
2209
|
+
this._isSorted = true;
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
1607
2212
|
if (hasStableSort) {
|
|
1608
|
-
this._replacements.sort(
|
|
1609
|
-
const diff1 = a.start - b.start;
|
|
1610
|
-
if (diff1 !== 0) return diff1;
|
|
1611
|
-
const diff2 = a.end - b.end;
|
|
1612
|
-
if (diff2 !== 0) return diff2;
|
|
1613
|
-
return 0;
|
|
1614
|
-
});
|
|
2213
|
+
this._replacements.sort(compareStable);
|
|
1615
2214
|
} else {
|
|
2215
|
+
// V8 < 7.0 only — unreachable on any supported Node.
|
|
2216
|
+
/* istanbul ignore next */
|
|
1616
2217
|
for (const [i, repl] of this._replacements.entries()) repl.index = i;
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
if (diff1 !== 0) return diff1;
|
|
1620
|
-
const diff2 = a.end - b.end;
|
|
1621
|
-
if (diff2 !== 0) return diff2;
|
|
1622
|
-
return (
|
|
1623
|
-
/** @type {number} */ (a.index) - /** @type {number} */ (b.index)
|
|
1624
|
-
);
|
|
1625
|
-
});
|
|
2218
|
+
/* istanbul ignore next */
|
|
2219
|
+
this._replacements.sort(compareUnstableFallback);
|
|
1626
2220
|
}
|
|
1627
2221
|
this._isSorted = true;
|
|
1628
2222
|
}
|
|
@@ -1636,6 +2230,18 @@ class ReplaceSource extends Source {
|
|
|
1636
2230
|
*/
|
|
1637
2231
|
streamChunks(options, onChunk, onSource, onName) {
|
|
1638
2232
|
this._sortReplacements();
|
|
2233
|
+
// When the consumer only wants the final source (map() /
|
|
2234
|
+
// sourceAndMap()), emit position-only chunks (chunk === undefined,
|
|
2235
|
+
// like OriginalSource and RawSource do) and hand back the whole
|
|
2236
|
+
// replaced source once at the end. This avoids allocating boundary
|
|
2237
|
+
// slices for emission and — more importantly — the per-chunk
|
|
2238
|
+
// `code += chunk` cons-string chain in every enclosing consumer.
|
|
2239
|
+
// With `source: false` the caller (getMap) additionally promises not
|
|
2240
|
+
// to read the returned source, so its assembly is skipped entirely;
|
|
2241
|
+
// streamAndGetSourceAndMap overrides that flag because it caches the
|
|
2242
|
+
// text.
|
|
2243
|
+
const finalSource = Boolean(options && options.finalSource);
|
|
2244
|
+
const needSource = !options || options.source !== false;
|
|
1639
2245
|
const replacements = this._replacements;
|
|
1640
2246
|
let pos = 0;
|
|
1641
2247
|
let i = 0;
|
|
@@ -1647,8 +2253,15 @@ class ReplaceSource extends Source {
|
|
|
1647
2253
|
let generatedLineOffset = 0;
|
|
1648
2254
|
let generatedColumnOffset = 0;
|
|
1649
2255
|
let generatedColumnOffsetLine = 0;
|
|
1650
|
-
/** @type {(string |
|
|
2256
|
+
/** @type {(string | undefined)[]} */
|
|
1651
2257
|
const sourceContents = [];
|
|
2258
|
+
/**
|
|
2259
|
+
* Lazily-built line-start offsets per source content. One number per
|
|
2260
|
+
* line instead of one substring per line (`splitIntoLines`), and the
|
|
2261
|
+
* chunk comparison below runs allocation-free via `startsWith`.
|
|
2262
|
+
* @type {(number[] | undefined)[]}
|
|
2263
|
+
*/
|
|
2264
|
+
const sourceContentLineStarts = [];
|
|
1652
2265
|
/** @type {Map<string, number>} */
|
|
1653
2266
|
const nameMapping = new Map();
|
|
1654
2267
|
/** @type {number[]} */
|
|
@@ -1661,22 +2274,34 @@ class ReplaceSource extends Source {
|
|
|
1661
2274
|
* @returns {boolean} result
|
|
1662
2275
|
*/
|
|
1663
2276
|
const checkOriginalContent = (sourceIndex, line, column, expectedChunk) => {
|
|
1664
|
-
|
|
1665
|
-
let content =
|
|
2277
|
+
const content =
|
|
1666
2278
|
sourceIndex < sourceContents.length
|
|
1667
2279
|
? sourceContents[sourceIndex]
|
|
1668
2280
|
: undefined;
|
|
1669
2281
|
if (content === undefined) return false;
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
2282
|
+
let lineStarts = sourceContentLineStarts[sourceIndex];
|
|
2283
|
+
if (lineStarts === undefined) {
|
|
2284
|
+
// Line boundaries mirror `splitIntoLines`: every line includes
|
|
2285
|
+
// its trailing "\n"; a final line without "\n" still counts.
|
|
2286
|
+
lineStarts = [];
|
|
2287
|
+
const { length } = content;
|
|
2288
|
+
let offset = 0;
|
|
2289
|
+
while (offset < length) {
|
|
2290
|
+
lineStarts.push(offset);
|
|
2291
|
+
const newline = content.indexOf("\n", offset);
|
|
2292
|
+
if (newline === -1) break;
|
|
2293
|
+
offset = newline + 1;
|
|
2294
|
+
}
|
|
2295
|
+
sourceContentLineStarts[sourceIndex] = lineStarts;
|
|
1673
2296
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
)
|
|
2297
|
+
if (line > lineStarts.length) return false;
|
|
2298
|
+
const lineStart = lineStarts[line - 1];
|
|
2299
|
+
const lineEnd =
|
|
2300
|
+
line < lineStarts.length ? lineStarts[line] : content.length;
|
|
2301
|
+
// The expected chunk never spans lines, so a match must fit into
|
|
2302
|
+
// the current line (mirrors the old per-line slice comparison).
|
|
2303
|
+
if (column + expectedChunk.length > lineEnd - lineStart) return false;
|
|
2304
|
+
return content.startsWith(expectedChunk, lineStart + column);
|
|
1680
2305
|
};
|
|
1681
2306
|
const { generatedLine, generatedColumn } = streamChunks(
|
|
1682
2307
|
this._source,
|
|
@@ -1708,7 +2333,9 @@ class ReplaceSource extends Source {
|
|
|
1708
2333
|
} else if (generatedColumnOffsetLine === line) {
|
|
1709
2334
|
generatedColumnOffset -= chunk.length;
|
|
1710
2335
|
} else {
|
|
2336
|
+
/* istanbul ignore next: pre-existing chunk-skipping cross-line case (also untested on main) */
|
|
1711
2337
|
generatedColumnOffset = -chunk.length;
|
|
2338
|
+
/* istanbul ignore next: pre-existing chunk-skipping cross-line case (also untested on main) */
|
|
1712
2339
|
generatedColumnOffsetLine = line;
|
|
1713
2340
|
}
|
|
1714
2341
|
pos = endPos;
|
|
@@ -1729,6 +2356,7 @@ class ReplaceSource extends Source {
|
|
|
1729
2356
|
}
|
|
1730
2357
|
pos += chunkPos;
|
|
1731
2358
|
const line = generatedLine + generatedLineOffset;
|
|
2359
|
+
/* istanbul ignore else: pre-existing chunk-skipping cross-line case (also untested on main) */
|
|
1732
2360
|
if (generatedColumnOffsetLine === line) {
|
|
1733
2361
|
generatedColumnOffset -= chunkPos;
|
|
1734
2362
|
} else {
|
|
@@ -1747,7 +2375,7 @@ class ReplaceSource extends Source {
|
|
|
1747
2375
|
const offset = nextReplacement - pos;
|
|
1748
2376
|
const chunkSlice = chunk.slice(chunkPos, chunkPos + offset);
|
|
1749
2377
|
onChunk(
|
|
1750
|
-
chunkSlice,
|
|
2378
|
+
finalSource ? undefined : chunkSlice,
|
|
1751
2379
|
line,
|
|
1752
2380
|
generatedColumn +
|
|
1753
2381
|
(line === generatedColumnOffsetLine
|
|
@@ -1777,7 +2405,6 @@ class ReplaceSource extends Source {
|
|
|
1777
2405
|
|
|
1778
2406
|
// Insert replacement content splitted into chunks by lines
|
|
1779
2407
|
const { content, name } = replacements[i];
|
|
1780
|
-
const matches = splitIntoLines(content);
|
|
1781
2408
|
let replacementNameIndex = nameIndex;
|
|
1782
2409
|
if (sourceIndex >= 0 && name) {
|
|
1783
2410
|
let globalIndex = nameMapping.get(name);
|
|
@@ -1788,10 +2415,16 @@ class ReplaceSource extends Source {
|
|
|
1788
2415
|
}
|
|
1789
2416
|
replacementNameIndex = globalIndex;
|
|
1790
2417
|
}
|
|
1791
|
-
|
|
1792
|
-
|
|
2418
|
+
// Fast path: most replacements (renamed identifiers,
|
|
2419
|
+
// short inserts) carry single-line content. Skip
|
|
2420
|
+
// `splitIntoLines` — and its array allocation — when
|
|
2421
|
+
// we can tell the content has no embedded newline.
|
|
2422
|
+
// `splitIntoLines("")` returns `[]`; emitting a zero-
|
|
2423
|
+
// length chunk would still walk the loop, so handle
|
|
2424
|
+
// it as a no-op explicitly.
|
|
2425
|
+
if (content.length > 0 && !content.includes("\n")) {
|
|
1793
2426
|
onChunk(
|
|
1794
|
-
|
|
2427
|
+
finalSource ? undefined : content,
|
|
1795
2428
|
line,
|
|
1796
2429
|
generatedColumn +
|
|
1797
2430
|
(line === generatedColumnOffsetLine
|
|
@@ -1802,22 +2435,51 @@ class ReplaceSource extends Source {
|
|
|
1802
2435
|
originalColumn,
|
|
1803
2436
|
replacementNameIndex,
|
|
1804
2437
|
);
|
|
2438
|
+
if (generatedColumnOffsetLine === line) {
|
|
2439
|
+
generatedColumnOffset += content.length;
|
|
2440
|
+
} else {
|
|
2441
|
+
generatedColumnOffset = content.length;
|
|
2442
|
+
generatedColumnOffsetLine = line;
|
|
2443
|
+
}
|
|
2444
|
+
} else if (content.length === 0) {
|
|
2445
|
+
// Empty replacement: no chunk to emit, no column
|
|
2446
|
+
// movement. `splitIntoLines("")` is `[]` so the
|
|
2447
|
+
// existing loop already does nothing — explicit
|
|
2448
|
+
// guard skips the per-call array allocation.
|
|
2449
|
+
} else {
|
|
2450
|
+
const matches = splitIntoLines(content);
|
|
2451
|
+
for (let m = 0; m < matches.length; m++) {
|
|
2452
|
+
const contentLine = matches[m];
|
|
2453
|
+
onChunk(
|
|
2454
|
+
finalSource ? undefined : contentLine,
|
|
2455
|
+
line,
|
|
2456
|
+
generatedColumn +
|
|
2457
|
+
(line === generatedColumnOffsetLine
|
|
2458
|
+
? generatedColumnOffset
|
|
2459
|
+
: 0),
|
|
2460
|
+
sourceIndex,
|
|
2461
|
+
originalLine,
|
|
2462
|
+
originalColumn,
|
|
2463
|
+
replacementNameIndex,
|
|
2464
|
+
);
|
|
1805
2465
|
|
|
1806
|
-
|
|
1807
|
-
|
|
2466
|
+
// Only the first chunk has name assigned
|
|
2467
|
+
replacementNameIndex = -1;
|
|
1808
2468
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
2469
|
+
if (m === matches.length - 1 && !contentLine.endsWith("\n")) {
|
|
2470
|
+
/* istanbul ignore else: pre-existing multi-line replacement cross-line case (also untested on main) */
|
|
2471
|
+
if (generatedColumnOffsetLine === line) {
|
|
2472
|
+
generatedColumnOffset += contentLine.length;
|
|
2473
|
+
} else {
|
|
2474
|
+
generatedColumnOffset = contentLine.length;
|
|
2475
|
+
generatedColumnOffsetLine = line;
|
|
2476
|
+
}
|
|
1812
2477
|
} else {
|
|
1813
|
-
|
|
2478
|
+
generatedLineOffset++;
|
|
2479
|
+
line++;
|
|
2480
|
+
generatedColumnOffset = -generatedColumn;
|
|
1814
2481
|
generatedColumnOffsetLine = line;
|
|
1815
2482
|
}
|
|
1816
|
-
} else {
|
|
1817
|
-
generatedLineOffset++;
|
|
1818
|
-
line++;
|
|
1819
|
-
generatedColumnOffset = -generatedColumn;
|
|
1820
|
-
generatedColumnOffsetLine = line;
|
|
1821
2483
|
}
|
|
1822
2484
|
}
|
|
1823
2485
|
|
|
@@ -1883,7 +2545,11 @@ class ReplaceSource extends Source {
|
|
|
1883
2545
|
|
|
1884
2546
|
// Emit remaining chunk
|
|
1885
2547
|
if (chunkPos < chunk.length) {
|
|
1886
|
-
const chunkSlice =
|
|
2548
|
+
const chunkSlice = finalSource
|
|
2549
|
+
? undefined
|
|
2550
|
+
: chunkPos === 0
|
|
2551
|
+
? chunk
|
|
2552
|
+
: chunk.slice(chunkPos);
|
|
1887
2553
|
const line = generatedLine + generatedLineOffset;
|
|
1888
2554
|
onChunk(
|
|
1889
2555
|
chunkSlice,
|
|
@@ -1898,12 +2564,13 @@ class ReplaceSource extends Source {
|
|
|
1898
2564
|
}
|
|
1899
2565
|
pos = endPos;
|
|
1900
2566
|
},
|
|
1901
|
-
(sourceIndex, source, sourceContent) => {
|
|
2567
|
+
(sourceIndex, source, sourceContent, scopeBindings) => {
|
|
2568
|
+
/* istanbul ignore next: non-sequential sourceIndex emission is not produced by any in-tree Source */
|
|
1902
2569
|
while (sourceContents.length < sourceIndex) {
|
|
1903
2570
|
sourceContents.push(undefined);
|
|
1904
2571
|
}
|
|
1905
2572
|
sourceContents[sourceIndex] = sourceContent;
|
|
1906
|
-
onSource(sourceIndex, source, sourceContent);
|
|
2573
|
+
onSource(sourceIndex, source, sourceContent, scopeBindings);
|
|
1907
2574
|
},
|
|
1908
2575
|
(nameIndex, name) => {
|
|
1909
2576
|
let globalIndex = nameMapping.get(name);
|
|
@@ -1924,11 +2591,13 @@ class ReplaceSource extends Source {
|
|
|
1924
2591
|
|
|
1925
2592
|
// Insert remaining replacements content splitted into chunks by lines
|
|
1926
2593
|
let line = /** @type {number} */ (generatedLine) + generatedLineOffset;
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
2594
|
+
// Fast path mirroring the in-chunk replacement loop above: skip
|
|
2595
|
+
// splitIntoLines + per-match loop when the trailing content has no
|
|
2596
|
+
// newlines (the common case when remaining replacements are single
|
|
2597
|
+
// inserts).
|
|
2598
|
+
if (remainer.length > 0 && !remainer.includes("\n")) {
|
|
1930
2599
|
onChunk(
|
|
1931
|
-
|
|
2600
|
+
finalSource ? undefined : remainer,
|
|
1932
2601
|
line,
|
|
1933
2602
|
/** @type {number} */
|
|
1934
2603
|
(generatedColumn) +
|
|
@@ -1938,19 +2607,43 @@ class ReplaceSource extends Source {
|
|
|
1938
2607
|
-1,
|
|
1939
2608
|
-1,
|
|
1940
2609
|
);
|
|
2610
|
+
/* istanbul ignore else: trailing-remainer cross-line case (also untested on main) */
|
|
2611
|
+
if (generatedColumnOffsetLine === line) {
|
|
2612
|
+
generatedColumnOffset += remainer.length;
|
|
2613
|
+
} else {
|
|
2614
|
+
generatedColumnOffset = remainer.length;
|
|
2615
|
+
generatedColumnOffsetLine = line;
|
|
2616
|
+
}
|
|
2617
|
+
} else {
|
|
2618
|
+
const matches = splitIntoLines(remainer);
|
|
2619
|
+
for (let m = 0; m < matches.length; m++) {
|
|
2620
|
+
const contentLine = matches[m];
|
|
2621
|
+
onChunk(
|
|
2622
|
+
finalSource ? undefined : contentLine,
|
|
2623
|
+
line,
|
|
2624
|
+
/** @type {number} */
|
|
2625
|
+
(generatedColumn) +
|
|
2626
|
+
(line === generatedColumnOffsetLine ? generatedColumnOffset : 0),
|
|
2627
|
+
-1,
|
|
2628
|
+
-1,
|
|
2629
|
+
-1,
|
|
2630
|
+
-1,
|
|
2631
|
+
);
|
|
1941
2632
|
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
2633
|
+
if (m === matches.length - 1 && !contentLine.endsWith("\n")) {
|
|
2634
|
+
/* istanbul ignore else: trailing-remainer multi-line cross-line case (also untested on main) */
|
|
2635
|
+
if (generatedColumnOffsetLine === line) {
|
|
2636
|
+
generatedColumnOffset += contentLine.length;
|
|
2637
|
+
} else {
|
|
2638
|
+
generatedColumnOffset = contentLine.length;
|
|
2639
|
+
generatedColumnOffsetLine = line;
|
|
2640
|
+
}
|
|
1945
2641
|
} else {
|
|
1946
|
-
|
|
2642
|
+
generatedLineOffset++;
|
|
2643
|
+
line++;
|
|
2644
|
+
generatedColumnOffset = -(/** @type {number} */ (generatedColumn));
|
|
1947
2645
|
generatedColumnOffsetLine = line;
|
|
1948
2646
|
}
|
|
1949
|
-
} else {
|
|
1950
|
-
generatedLineOffset++;
|
|
1951
|
-
line++;
|
|
1952
|
-
generatedColumnOffset = -(/** @type {number} */ (generatedColumn));
|
|
1953
|
-
generatedColumnOffsetLine = line;
|
|
1954
2647
|
}
|
|
1955
2648
|
}
|
|
1956
2649
|
|
|
@@ -1960,9 +2653,38 @@ class ReplaceSource extends Source {
|
|
|
1960
2653
|
/** @type {number} */
|
|
1961
2654
|
(generatedColumn) +
|
|
1962
2655
|
(line === generatedColumnOffsetLine ? generatedColumnOffset : 0),
|
|
2656
|
+
// The streamed chunks reproduce source() exactly, so the final
|
|
2657
|
+
// source can be assembled in O(replacements) string operations
|
|
2658
|
+
// instead of re-concatenating every emitted chunk downstream.
|
|
2659
|
+
source:
|
|
2660
|
+
finalSource && needSource
|
|
2661
|
+
? /** @type {string} */ (this.source())
|
|
2662
|
+
: undefined,
|
|
1963
2663
|
};
|
|
1964
2664
|
}
|
|
1965
2665
|
|
|
2666
|
+
/**
|
|
2667
|
+
* Release cached data held by this source. clearCache is a memory
|
|
2668
|
+
* hint: it never affects correctness or output, only how expensive
|
|
2669
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
2670
|
+
* every Source supports the call. Composite sources always recurse
|
|
2671
|
+
* into wrapped sources. When the same child is reachable via several
|
|
2672
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
2673
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
2674
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
2675
|
+
* streamChunks/updateHash on the same instance.
|
|
2676
|
+
* @param {ClearCacheOptions=} options selectors
|
|
2677
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
2678
|
+
* @returns {void}
|
|
2679
|
+
*/
|
|
2680
|
+
clearCache(options, visited) {
|
|
2681
|
+
if (visited !== undefined && visited.has(this)) return;
|
|
2682
|
+
let v = visited;
|
|
2683
|
+
if (v === undefined) v = new WeakSet();
|
|
2684
|
+
v.add(this);
|
|
2685
|
+
this._source.clearCache(options, v);
|
|
2686
|
+
}
|
|
2687
|
+
|
|
1966
2688
|
/**
|
|
1967
2689
|
* @param {HashLike} hash hash
|
|
1968
2690
|
* @returns {void}
|
|
@@ -1972,10 +2694,14 @@ class ReplaceSource extends Source {
|
|
|
1972
2694
|
hash.update("ReplaceSource");
|
|
1973
2695
|
this._source.updateHash(hash);
|
|
1974
2696
|
hash.update(this._name || "");
|
|
2697
|
+
// Feed each replacement as multiple updates instead of building one
|
|
2698
|
+
// combined template literal per replacement. The resulting digest is
|
|
2699
|
+
// identical (hash.update is additive over bytes), but we avoid
|
|
2700
|
+
// allocating a new string per replacement.
|
|
1975
2701
|
for (const repl of this._replacements) {
|
|
1976
|
-
hash.update(
|
|
1977
|
-
|
|
1978
|
-
);
|
|
2702
|
+
hash.update(`${repl.start}${repl.end}`);
|
|
2703
|
+
hash.update(repl.content);
|
|
2704
|
+
if (repl.name) hash.update(repl.name);
|
|
1979
2705
|
}
|
|
1980
2706
|
}
|
|
1981
2707
|
}
|
|
@@ -1986,7 +2712,7 @@ module.exports.Replacement = Replacement;
|
|
|
1986
2712
|
|
|
1987
2713
|
/***/ }),
|
|
1988
2714
|
|
|
1989
|
-
/***/
|
|
2715
|
+
/***/ 317:
|
|
1990
2716
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1991
2717
|
|
|
1992
2718
|
/*
|
|
@@ -1996,7 +2722,7 @@ module.exports.Replacement = Replacement;
|
|
|
1996
2722
|
|
|
1997
2723
|
|
|
1998
2724
|
|
|
1999
|
-
const Source = __nccwpck_require__(
|
|
2725
|
+
const Source = __nccwpck_require__(290);
|
|
2000
2726
|
|
|
2001
2727
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
2002
2728
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
@@ -2009,6 +2735,9 @@ class SizeOnlySource extends Source {
|
|
|
2009
2735
|
*/
|
|
2010
2736
|
constructor(size) {
|
|
2011
2737
|
super();
|
|
2738
|
+
/**
|
|
2739
|
+
* @type {number}
|
|
2740
|
+
*/
|
|
2012
2741
|
this._size = size;
|
|
2013
2742
|
}
|
|
2014
2743
|
|
|
@@ -2018,6 +2747,9 @@ class SizeOnlySource extends Source {
|
|
|
2018
2747
|
);
|
|
2019
2748
|
}
|
|
2020
2749
|
|
|
2750
|
+
/**
|
|
2751
|
+
* @returns {number} size
|
|
2752
|
+
*/
|
|
2021
2753
|
size() {
|
|
2022
2754
|
return this._size;
|
|
2023
2755
|
}
|
|
@@ -2036,6 +2768,13 @@ class SizeOnlySource extends Source {
|
|
|
2036
2768
|
throw this._error();
|
|
2037
2769
|
}
|
|
2038
2770
|
|
|
2771
|
+
/**
|
|
2772
|
+
* @returns {Buffer[]} buffers
|
|
2773
|
+
*/
|
|
2774
|
+
buffers() {
|
|
2775
|
+
throw this._error();
|
|
2776
|
+
}
|
|
2777
|
+
|
|
2039
2778
|
/**
|
|
2040
2779
|
* @param {MapOptions=} options map options
|
|
2041
2780
|
* @returns {RawSourceMap | null} map
|
|
@@ -2060,7 +2799,7 @@ module.exports = SizeOnlySource;
|
|
|
2060
2799
|
|
|
2061
2800
|
/***/ }),
|
|
2062
2801
|
|
|
2063
|
-
/***/
|
|
2802
|
+
/***/ 290:
|
|
2064
2803
|
/***/ ((module) => {
|
|
2065
2804
|
|
|
2066
2805
|
/*
|
|
@@ -2074,6 +2813,7 @@ module.exports = SizeOnlySource;
|
|
|
2074
2813
|
* @typedef {object} MapOptions
|
|
2075
2814
|
* @property {boolean=} columns need columns?
|
|
2076
2815
|
* @property {boolean=} module is module
|
|
2816
|
+
* @property {boolean=} scopes emit the `scopes` field from the bindings the sources declare
|
|
2077
2817
|
*/
|
|
2078
2818
|
|
|
2079
2819
|
/**
|
|
@@ -2087,6 +2827,7 @@ module.exports = SizeOnlySource;
|
|
|
2087
2827
|
* @property {string} file file
|
|
2088
2828
|
* @property {string=} debugId debug id
|
|
2089
2829
|
* @property {number[]=} ignoreList ignore list
|
|
2830
|
+
* @property {string=} scopes encoded `scopes` field of the "Scopes" proposal
|
|
2090
2831
|
*/
|
|
2091
2832
|
|
|
2092
2833
|
/** @typedef {string | Buffer} SourceValue */
|
|
@@ -2103,6 +2844,13 @@ module.exports = SizeOnlySource;
|
|
|
2103
2844
|
* @property {(encoding?: string) => string | Buffer} digest get hash digest
|
|
2104
2845
|
*/
|
|
2105
2846
|
|
|
2847
|
+
/**
|
|
2848
|
+
* @typedef {object} ClearCacheOptions
|
|
2849
|
+
* @property {boolean=} maps drop cached source maps (default `true`)
|
|
2850
|
+
* @property {boolean=} source drop cached source/buffer copies (default `true`)
|
|
2851
|
+
* @property {boolean=} parsedMap drop the parsed object form of cached source maps on `SourceMapSource` instances (default `false` — re-parsing JSON is significantly more expensive than `toString`). Only takes effect when a serialized form (buffer or string) is also retained, so the data remains recoverable.
|
|
2852
|
+
*/
|
|
2853
|
+
|
|
2106
2854
|
class Source {
|
|
2107
2855
|
/**
|
|
2108
2856
|
* @returns {SourceValue} source
|
|
@@ -2111,12 +2859,25 @@ class Source {
|
|
|
2111
2859
|
throw new Error("Abstract");
|
|
2112
2860
|
}
|
|
2113
2861
|
|
|
2862
|
+
/**
|
|
2863
|
+
* @returns {Buffer} buffer
|
|
2864
|
+
*/
|
|
2114
2865
|
buffer() {
|
|
2115
2866
|
const source = this.source();
|
|
2116
2867
|
if (Buffer.isBuffer(source)) return source;
|
|
2117
2868
|
return Buffer.from(source, "utf8");
|
|
2118
2869
|
}
|
|
2119
2870
|
|
|
2871
|
+
/**
|
|
2872
|
+
* @returns {Buffer[]} buffers
|
|
2873
|
+
*/
|
|
2874
|
+
buffers() {
|
|
2875
|
+
return [this.buffer()];
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
/**
|
|
2879
|
+
* @returns {number} size
|
|
2880
|
+
*/
|
|
2120
2881
|
size() {
|
|
2121
2882
|
return this.buffer().length;
|
|
2122
2883
|
}
|
|
@@ -2149,6 +2910,23 @@ class Source {
|
|
|
2149
2910
|
updateHash(hash) {
|
|
2150
2911
|
throw new Error("Abstract");
|
|
2151
2912
|
}
|
|
2913
|
+
|
|
2914
|
+
/**
|
|
2915
|
+
* Release cached data held by this source. clearCache is a memory
|
|
2916
|
+
* hint: it never affects correctness or output, only how expensive
|
|
2917
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
2918
|
+
* every Source supports the call. Composite sources always recurse
|
|
2919
|
+
* into wrapped sources. When the same child is reachable via several
|
|
2920
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
2921
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
2922
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
2923
|
+
* streamChunks/updateHash on the same instance.
|
|
2924
|
+
* @param {ClearCacheOptions=} options selectors
|
|
2925
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
2926
|
+
* @returns {void}
|
|
2927
|
+
*/
|
|
2928
|
+
// eslint-disable-next-line no-unused-vars
|
|
2929
|
+
clearCache(options, visited) {}
|
|
2152
2930
|
}
|
|
2153
2931
|
|
|
2154
2932
|
module.exports = Source;
|
|
@@ -2156,7 +2934,7 @@ module.exports = Source;
|
|
|
2156
2934
|
|
|
2157
2935
|
/***/ }),
|
|
2158
2936
|
|
|
2159
|
-
/***/
|
|
2937
|
+
/***/ 471:
|
|
2160
2938
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2161
2939
|
|
|
2162
2940
|
/*
|
|
@@ -2166,14 +2944,15 @@ module.exports = Source;
|
|
|
2166
2944
|
|
|
2167
2945
|
|
|
2168
2946
|
|
|
2169
|
-
const Source = __nccwpck_require__(
|
|
2170
|
-
const { getMap, getSourceAndMap } = __nccwpck_require__(
|
|
2171
|
-
const streamChunksOfCombinedSourceMap = __nccwpck_require__(
|
|
2172
|
-
const streamChunksOfSourceMap = __nccwpck_require__(
|
|
2947
|
+
const Source = __nccwpck_require__(290);
|
|
2948
|
+
const { getMap, getSourceAndMap } = __nccwpck_require__(847);
|
|
2949
|
+
const streamChunksOfCombinedSourceMap = __nccwpck_require__(808);
|
|
2950
|
+
const streamChunksOfSourceMap = __nccwpck_require__(637);
|
|
2173
2951
|
const {
|
|
2174
2952
|
isDualStringBufferCachingEnabled,
|
|
2175
|
-
} = __nccwpck_require__(
|
|
2953
|
+
} = __nccwpck_require__(345);
|
|
2176
2954
|
|
|
2955
|
+
/** @typedef {import("./Source").ClearCacheOptions} ClearCacheOptions */
|
|
2177
2956
|
/** @typedef {import("./Source").HashLike} HashLike */
|
|
2178
2957
|
/** @typedef {import("./Source").MapOptions} MapOptions */
|
|
2179
2958
|
/** @typedef {import("./Source").RawSourceMap} RawSourceMap */
|
|
@@ -2191,7 +2970,7 @@ class SourceMapSource extends Source {
|
|
|
2191
2970
|
* @param {string} name name
|
|
2192
2971
|
* @param {string | Buffer | RawSourceMap=} sourceMap source map
|
|
2193
2972
|
* @param {SourceValue=} originalSource original source
|
|
2194
|
-
* @param {(string | Buffer | RawSourceMap)=} innerSourceMap inner source map
|
|
2973
|
+
* @param {(null | string | Buffer | RawSourceMap)=} innerSourceMap inner source map
|
|
2195
2974
|
* @param {boolean=} removeOriginalSource do remove original source
|
|
2196
2975
|
*/
|
|
2197
2976
|
constructor(
|
|
@@ -2205,12 +2984,10 @@ class SourceMapSource extends Source {
|
|
|
2205
2984
|
super();
|
|
2206
2985
|
const valueIsBuffer = Buffer.isBuffer(value);
|
|
2207
2986
|
/**
|
|
2208
|
-
* @private
|
|
2209
2987
|
* @type {undefined | string}
|
|
2210
2988
|
*/
|
|
2211
2989
|
this._valueAsString = valueIsBuffer ? undefined : value;
|
|
2212
2990
|
/**
|
|
2213
|
-
* @private
|
|
2214
2991
|
* @type {undefined | Buffer}
|
|
2215
2992
|
*/
|
|
2216
2993
|
this._valueAsBuffer = valueIsBuffer ? value : undefined;
|
|
@@ -2221,18 +2998,15 @@ class SourceMapSource extends Source {
|
|
|
2221
2998
|
const sourceMapIsBuffer = Buffer.isBuffer(sourceMap);
|
|
2222
2999
|
const sourceMapIsString = typeof sourceMap === "string";
|
|
2223
3000
|
/**
|
|
2224
|
-
* @private
|
|
2225
3001
|
* @type {undefined | RawSourceMap}
|
|
2226
3002
|
*/
|
|
2227
3003
|
this._sourceMapAsObject =
|
|
2228
3004
|
sourceMapIsBuffer || sourceMapIsString ? undefined : sourceMap;
|
|
2229
3005
|
/**
|
|
2230
|
-
* @private
|
|
2231
3006
|
* @type {undefined | string}
|
|
2232
3007
|
*/
|
|
2233
3008
|
this._sourceMapAsString = sourceMapIsString ? sourceMap : undefined;
|
|
2234
3009
|
/**
|
|
2235
|
-
* @private
|
|
2236
3010
|
* @type {undefined | Buffer}
|
|
2237
3011
|
*/
|
|
2238
3012
|
this._sourceMapAsBuffer = sourceMapIsBuffer ? sourceMap : undefined;
|
|
@@ -2250,22 +3024,20 @@ class SourceMapSource extends Source {
|
|
|
2250
3024
|
const innerSourceMapIsBuffer = Buffer.isBuffer(innerSourceMap);
|
|
2251
3025
|
const innerSourceMapIsString = typeof innerSourceMap === "string";
|
|
2252
3026
|
/**
|
|
2253
|
-
* @private
|
|
2254
3027
|
* @type {undefined | RawSourceMap}
|
|
2255
3028
|
*/
|
|
3029
|
+
|
|
2256
3030
|
this._innerSourceMapAsObject =
|
|
2257
3031
|
innerSourceMapIsBuffer || innerSourceMapIsString
|
|
2258
3032
|
? undefined
|
|
2259
|
-
: innerSourceMap;
|
|
3033
|
+
: innerSourceMap || undefined;
|
|
2260
3034
|
/**
|
|
2261
|
-
* @private
|
|
2262
3035
|
* @type {undefined | string}
|
|
2263
3036
|
*/
|
|
2264
3037
|
this._innerSourceMapAsString = innerSourceMapIsString
|
|
2265
3038
|
? innerSourceMap
|
|
2266
3039
|
: undefined;
|
|
2267
3040
|
/**
|
|
2268
|
-
* @private
|
|
2269
3041
|
* @type {undefined | Buffer}
|
|
2270
3042
|
*/
|
|
2271
3043
|
this._innerSourceMapAsBuffer = innerSourceMapIsBuffer
|
|
@@ -2289,6 +3061,9 @@ class SourceMapSource extends Source {
|
|
|
2289
3061
|
];
|
|
2290
3062
|
}
|
|
2291
3063
|
|
|
3064
|
+
/**
|
|
3065
|
+
* @returns {Buffer} buffer
|
|
3066
|
+
*/
|
|
2292
3067
|
buffer() {
|
|
2293
3068
|
if (this._valueAsBuffer === undefined) {
|
|
2294
3069
|
const value = Buffer.from(
|
|
@@ -2303,6 +3078,20 @@ class SourceMapSource extends Source {
|
|
|
2303
3078
|
return this._valueAsBuffer;
|
|
2304
3079
|
}
|
|
2305
3080
|
|
|
3081
|
+
/**
|
|
3082
|
+
* @returns {number} size
|
|
3083
|
+
*/
|
|
3084
|
+
size() {
|
|
3085
|
+
if (this._cachedSize !== undefined) return this._cachedSize;
|
|
3086
|
+
if (this._valueAsBuffer !== undefined) {
|
|
3087
|
+
return (this._cachedSize = this._valueAsBuffer.length);
|
|
3088
|
+
}
|
|
3089
|
+
return (this._cachedSize = Buffer.byteLength(
|
|
3090
|
+
/** @type {string} */ (this._valueAsString),
|
|
3091
|
+
"utf8",
|
|
3092
|
+
));
|
|
3093
|
+
}
|
|
3094
|
+
|
|
2306
3095
|
/**
|
|
2307
3096
|
* @returns {SourceValue} source
|
|
2308
3097
|
*/
|
|
@@ -2320,7 +3109,6 @@ class SourceMapSource extends Source {
|
|
|
2320
3109
|
}
|
|
2321
3110
|
|
|
2322
3111
|
/**
|
|
2323
|
-
* @private
|
|
2324
3112
|
* @returns {undefined | Buffer} buffer
|
|
2325
3113
|
*/
|
|
2326
3114
|
_originalSourceBuffer() {
|
|
@@ -2374,7 +3162,6 @@ class SourceMapSource extends Source {
|
|
|
2374
3162
|
}
|
|
2375
3163
|
|
|
2376
3164
|
/**
|
|
2377
|
-
* @private
|
|
2378
3165
|
* @returns {string} result
|
|
2379
3166
|
*/
|
|
2380
3167
|
_innerSourceMapString() {
|
|
@@ -2497,6 +3284,80 @@ class SourceMapSource extends Source {
|
|
|
2497
3284
|
);
|
|
2498
3285
|
}
|
|
2499
3286
|
|
|
3287
|
+
/**
|
|
3288
|
+
* Release cached data held by this source. clearCache is a memory
|
|
3289
|
+
* hint: it never affects correctness or output, only how expensive
|
|
3290
|
+
* the next read is. Subclasses override; the base is a no-op so
|
|
3291
|
+
* every Source supports the call. Composite sources always recurse
|
|
3292
|
+
* into wrapped sources. When the same child is reachable via several
|
|
3293
|
+
* parents (e.g. modules shared across webpack chunks), pass a shared
|
|
3294
|
+
* `visited` WeakSet so each subtree is walked at most once.
|
|
3295
|
+
* Not safe to call concurrently with source/map/sourceAndMap/
|
|
3296
|
+
* streamChunks/updateHash on the same instance.
|
|
3297
|
+
* @param {ClearCacheOptions=} options selectors
|
|
3298
|
+
* @param {WeakSet<Source>=} visited de-duplication set shared across calls
|
|
3299
|
+
* @returns {void}
|
|
3300
|
+
*/
|
|
3301
|
+
clearCache(options, visited) {
|
|
3302
|
+
if (visited !== undefined) {
|
|
3303
|
+
if (visited.has(this)) return;
|
|
3304
|
+
visited.add(this);
|
|
3305
|
+
}
|
|
3306
|
+
const clearSource = !options || options.source !== false;
|
|
3307
|
+
const clearMaps = !options || options.maps !== false;
|
|
3308
|
+
const clearParsedMap = options !== undefined && options.parsedMap === true;
|
|
3309
|
+
// For every dual-cached pair, drop the string form when the
|
|
3310
|
+
// buffer is also held — buffer is more compact in V8 (1 byte/char
|
|
3311
|
+
// vs 2) and the string rehydrates cheaply. Parsed object forms
|
|
3312
|
+
// of source maps are heavier but only dropped when
|
|
3313
|
+
// `parsedMap: true` is set, because re-parsing JSON is much more
|
|
3314
|
+
// expensive than `toString` from a buffer.
|
|
3315
|
+
if (clearSource) {
|
|
3316
|
+
if (
|
|
3317
|
+
this._valueAsString !== undefined &&
|
|
3318
|
+
this._valueAsBuffer !== undefined
|
|
3319
|
+
) {
|
|
3320
|
+
this._valueAsString = undefined;
|
|
3321
|
+
}
|
|
3322
|
+
if (
|
|
3323
|
+
this._originalSourceAsString !== undefined &&
|
|
3324
|
+
this._originalSourceAsBuffer !== undefined
|
|
3325
|
+
) {
|
|
3326
|
+
this._originalSourceAsString = undefined;
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
if (clearMaps) {
|
|
3330
|
+
if (
|
|
3331
|
+
this._sourceMapAsString !== undefined &&
|
|
3332
|
+
this._sourceMapAsBuffer !== undefined
|
|
3333
|
+
) {
|
|
3334
|
+
this._sourceMapAsString = undefined;
|
|
3335
|
+
}
|
|
3336
|
+
if (
|
|
3337
|
+
clearParsedMap &&
|
|
3338
|
+
this._sourceMapAsObject !== undefined &&
|
|
3339
|
+
(this._sourceMapAsBuffer !== undefined ||
|
|
3340
|
+
this._sourceMapAsString !== undefined)
|
|
3341
|
+
) {
|
|
3342
|
+
this._sourceMapAsObject = undefined;
|
|
3343
|
+
}
|
|
3344
|
+
if (
|
|
3345
|
+
this._innerSourceMapAsString !== undefined &&
|
|
3346
|
+
this._innerSourceMapAsBuffer !== undefined
|
|
3347
|
+
) {
|
|
3348
|
+
this._innerSourceMapAsString = undefined;
|
|
3349
|
+
}
|
|
3350
|
+
if (
|
|
3351
|
+
clearParsedMap &&
|
|
3352
|
+
this._innerSourceMapAsObject !== undefined &&
|
|
3353
|
+
(this._innerSourceMapAsBuffer !== undefined ||
|
|
3354
|
+
this._innerSourceMapAsString !== undefined)
|
|
3355
|
+
) {
|
|
3356
|
+
this._innerSourceMapAsObject = undefined;
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
|
|
2500
3361
|
/**
|
|
2501
3362
|
* @param {HashLike} hash hash
|
|
2502
3363
|
* @returns {void}
|
|
@@ -2529,7 +3390,7 @@ module.exports = SourceMapSource;
|
|
|
2529
3390
|
|
|
2530
3391
|
/***/ }),
|
|
2531
3392
|
|
|
2532
|
-
/***/
|
|
3393
|
+
/***/ 818:
|
|
2533
3394
|
/***/ ((module) => {
|
|
2534
3395
|
|
|
2535
3396
|
/*
|
|
@@ -2550,12 +3411,209 @@ module.exports = SourceMapSource;
|
|
|
2550
3411
|
* @returns {string} result
|
|
2551
3412
|
*/
|
|
2552
3413
|
|
|
3414
|
+
/**
|
|
3415
|
+
* A push-based serializer: `add()` appends one mapping to an internal
|
|
3416
|
+
* byte buffer, `finish()` materialises the whole `mappings` string in a
|
|
3417
|
+
* single allocation. Compared to the string-returning
|
|
3418
|
+
* {@link MappingsSerializer} this avoids every per-mapping intermediate
|
|
3419
|
+
* string (each VLQ digit concatenation) plus the caller-side
|
|
3420
|
+
* `mappings += str` cons chain — together the dominant allocation site
|
|
3421
|
+
* of `map()` / `sourceAndMap()`.
|
|
3422
|
+
* @typedef {object} MappingsWriter
|
|
3423
|
+
* @property {(generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number, originalColumn: number, nameIndex: number) => void} add append one mapping
|
|
3424
|
+
* @property {() => string} finish materialise the mappings string
|
|
3425
|
+
*/
|
|
3426
|
+
|
|
2553
3427
|
const ALPHABET = [
|
|
2554
3428
|
..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
2555
3429
|
];
|
|
2556
3430
|
|
|
3431
|
+
// Char codes of ALPHABET for the buffer-writing path.
|
|
3432
|
+
const ALPHABET_CODES = new Uint8Array(64);
|
|
3433
|
+
for (let i = 0; i < 64; i++) ALPHABET_CODES[i] = ALPHABET[i].charCodeAt(0);
|
|
3434
|
+
|
|
3435
|
+
const CH_SEMICOLON = 59; // ;
|
|
3436
|
+
const CH_COMMA = 44; // ,
|
|
3437
|
+
const CH_A = 65; // A
|
|
3438
|
+
|
|
2557
3439
|
const CONTINUATION_BIT = 0x20;
|
|
2558
3440
|
|
|
3441
|
+
/**
|
|
3442
|
+
* Append a VLQ-encoded signed integer to `str`. Hoisted to module scope so
|
|
3443
|
+
* that both serializers share a single function object and avoid allocating
|
|
3444
|
+
* a new closure on every call.
|
|
3445
|
+
* @param {string} str current string buffer
|
|
3446
|
+
* @param {number} value signed integer to encode
|
|
3447
|
+
* @returns {string} updated string buffer
|
|
3448
|
+
*/
|
|
3449
|
+
const writeValue = (str, value) => {
|
|
3450
|
+
const sign = (value >>> 31) & 1;
|
|
3451
|
+
const mask = value >> 31;
|
|
3452
|
+
const absValue = (value + mask) ^ mask;
|
|
3453
|
+
let data = (absValue << 1) | sign;
|
|
3454
|
+
for (;;) {
|
|
3455
|
+
const sextet = data & 0x1f;
|
|
3456
|
+
data >>= 5;
|
|
3457
|
+
if (data === 0) {
|
|
3458
|
+
return str + ALPHABET[sextet];
|
|
3459
|
+
}
|
|
3460
|
+
str += ALPHABET[sextet | CONTINUATION_BIT];
|
|
3461
|
+
}
|
|
3462
|
+
};
|
|
3463
|
+
|
|
3464
|
+
/**
|
|
3465
|
+
* Byte-buffer state shared by the writer variants. A plain object (not a
|
|
3466
|
+
* class) so the hot `add` closures capture it directly.
|
|
3467
|
+
* @returns {{ buf: Uint8Array, pos: number }} state
|
|
3468
|
+
*/
|
|
3469
|
+
const createBufferState = () => ({ buf: new Uint8Array(1024), pos: 0 });
|
|
3470
|
+
|
|
3471
|
+
/**
|
|
3472
|
+
* Ensure space for `n` more bytes.
|
|
3473
|
+
* @param {{ buf: Uint8Array, pos: number }} state state
|
|
3474
|
+
* @param {number} n bytes needed
|
|
3475
|
+
* @returns {Uint8Array} the (possibly grown) buffer
|
|
3476
|
+
*/
|
|
3477
|
+
const ensure = (state, n) => {
|
|
3478
|
+
const { buf, pos } = state;
|
|
3479
|
+
if (pos + n <= buf.length) return buf;
|
|
3480
|
+
let nextLength = buf.length * 2;
|
|
3481
|
+
while (nextLength < pos + n) nextLength *= 2;
|
|
3482
|
+
const next = new Uint8Array(nextLength);
|
|
3483
|
+
next.set(buf);
|
|
3484
|
+
state.buf = next;
|
|
3485
|
+
return next;
|
|
3486
|
+
};
|
|
3487
|
+
|
|
3488
|
+
/**
|
|
3489
|
+
* Append a VLQ-encoded signed integer to the byte buffer. The caller must
|
|
3490
|
+
* have reserved space already (a 32-bit value needs at most 7 sextets).
|
|
3491
|
+
* @param {{ buf: Uint8Array, pos: number }} state state
|
|
3492
|
+
* @param {number} value signed integer to encode
|
|
3493
|
+
* @returns {void}
|
|
3494
|
+
*/
|
|
3495
|
+
const writeValueBytes = (state, value) => {
|
|
3496
|
+
const { buf } = state;
|
|
3497
|
+
let { pos } = state;
|
|
3498
|
+
const sign = (value >>> 31) & 1;
|
|
3499
|
+
const mask = value >> 31;
|
|
3500
|
+
const absValue = (value + mask) ^ mask;
|
|
3501
|
+
let data = (absValue << 1) | sign;
|
|
3502
|
+
for (;;) {
|
|
3503
|
+
const sextet = data & 0x1f;
|
|
3504
|
+
data >>= 5;
|
|
3505
|
+
if (data === 0) {
|
|
3506
|
+
buf[pos++] = ALPHABET_CODES[sextet];
|
|
3507
|
+
break;
|
|
3508
|
+
}
|
|
3509
|
+
buf[pos++] = ALPHABET_CODES[sextet | CONTINUATION_BIT];
|
|
3510
|
+
}
|
|
3511
|
+
state.pos = pos;
|
|
3512
|
+
};
|
|
3513
|
+
|
|
3514
|
+
/**
|
|
3515
|
+
* @param {{ buf: Uint8Array, pos: number }} state state
|
|
3516
|
+
* @returns {string} the mappings accumulated so far
|
|
3517
|
+
*/
|
|
3518
|
+
const bufferToString = (state) => {
|
|
3519
|
+
if (state.pos === 0) return "";
|
|
3520
|
+
// The mappings alphabet is pure ASCII, so a latin1 decode is exact and
|
|
3521
|
+
// needs no re-encoding pass.
|
|
3522
|
+
return Buffer.from(state.buf.buffer, 0, state.pos).toString("latin1");
|
|
3523
|
+
};
|
|
3524
|
+
|
|
3525
|
+
/**
|
|
3526
|
+
* @returns {MappingsWriter} writer
|
|
3527
|
+
*/
|
|
3528
|
+
const createFullMappingsWriter = () => {
|
|
3529
|
+
const state = createBufferState();
|
|
3530
|
+
let currentLine = 1;
|
|
3531
|
+
let currentColumn = 0;
|
|
3532
|
+
let currentSourceIndex = 0;
|
|
3533
|
+
let currentOriginalLine = 1;
|
|
3534
|
+
let currentOriginalColumn = 0;
|
|
3535
|
+
let currentNameIndex = 0;
|
|
3536
|
+
let activeMapping = false;
|
|
3537
|
+
let activeName = false;
|
|
3538
|
+
let initial = true;
|
|
3539
|
+
return {
|
|
3540
|
+
add(
|
|
3541
|
+
generatedLine,
|
|
3542
|
+
generatedColumn,
|
|
3543
|
+
sourceIndex,
|
|
3544
|
+
originalLine,
|
|
3545
|
+
originalColumn,
|
|
3546
|
+
nameIndex,
|
|
3547
|
+
) {
|
|
3548
|
+
if (activeMapping && currentLine === generatedLine) {
|
|
3549
|
+
// A mapping is still active
|
|
3550
|
+
if (
|
|
3551
|
+
sourceIndex === currentSourceIndex &&
|
|
3552
|
+
originalLine === currentOriginalLine &&
|
|
3553
|
+
originalColumn === currentOriginalColumn &&
|
|
3554
|
+
!activeName &&
|
|
3555
|
+
nameIndex < 0
|
|
3556
|
+
) {
|
|
3557
|
+
// avoid repeating the same original mapping
|
|
3558
|
+
return;
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
// No mapping is active
|
|
3562
|
+
else if (sourceIndex < 0) {
|
|
3563
|
+
// avoid writing unneccessary generated mappings
|
|
3564
|
+
return;
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
// Reserve the worst case for one mapping in a single check:
|
|
3568
|
+
// line separators + 5 VLQ values of up to 7 sextets each.
|
|
3569
|
+
const lineDiff = generatedLine - currentLine;
|
|
3570
|
+
const buf = ensure(state, (lineDiff > 0 ? lineDiff : 1) + 35);
|
|
3571
|
+
if (lineDiff > 0) {
|
|
3572
|
+
// Consecutive lines (diff === 1) are the dominant case.
|
|
3573
|
+
buf[state.pos++] = CH_SEMICOLON;
|
|
3574
|
+
for (let i = 1; i < lineDiff; i++) buf[state.pos++] = CH_SEMICOLON;
|
|
3575
|
+
currentLine = generatedLine;
|
|
3576
|
+
currentColumn = 0;
|
|
3577
|
+
initial = false;
|
|
3578
|
+
} else if (initial) {
|
|
3579
|
+
initial = false;
|
|
3580
|
+
} else {
|
|
3581
|
+
buf[state.pos++] = CH_COMMA;
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
writeValueBytes(state, generatedColumn - currentColumn);
|
|
3585
|
+
currentColumn = generatedColumn;
|
|
3586
|
+
if (sourceIndex >= 0) {
|
|
3587
|
+
activeMapping = true;
|
|
3588
|
+
if (sourceIndex === currentSourceIndex) {
|
|
3589
|
+
buf[state.pos++] = CH_A;
|
|
3590
|
+
} else {
|
|
3591
|
+
writeValueBytes(state, sourceIndex - currentSourceIndex);
|
|
3592
|
+
currentSourceIndex = sourceIndex;
|
|
3593
|
+
}
|
|
3594
|
+
writeValueBytes(state, originalLine - currentOriginalLine);
|
|
3595
|
+
currentOriginalLine = originalLine;
|
|
3596
|
+
if (originalColumn === currentOriginalColumn) {
|
|
3597
|
+
buf[state.pos++] = CH_A;
|
|
3598
|
+
} else {
|
|
3599
|
+
writeValueBytes(state, originalColumn - currentOriginalColumn);
|
|
3600
|
+
currentOriginalColumn = originalColumn;
|
|
3601
|
+
}
|
|
3602
|
+
if (nameIndex >= 0) {
|
|
3603
|
+
writeValueBytes(state, nameIndex - currentNameIndex);
|
|
3604
|
+
currentNameIndex = nameIndex;
|
|
3605
|
+
activeName = true;
|
|
3606
|
+
} else {
|
|
3607
|
+
activeName = false;
|
|
3608
|
+
}
|
|
3609
|
+
} else {
|
|
3610
|
+
activeMapping = false;
|
|
3611
|
+
}
|
|
3612
|
+
},
|
|
3613
|
+
finish: () => bufferToString(state),
|
|
3614
|
+
};
|
|
3615
|
+
};
|
|
3616
|
+
|
|
2559
3617
|
const createFullMappingsSerializer = () => {
|
|
2560
3618
|
let currentLine = 1;
|
|
2561
3619
|
let currentColumn = 0;
|
|
@@ -2594,10 +3652,14 @@ const createFullMappingsSerializer = () => {
|
|
|
2594
3652
|
return "";
|
|
2595
3653
|
}
|
|
2596
3654
|
|
|
2597
|
-
/** @type {undefined | string} */
|
|
2598
3655
|
let str;
|
|
2599
3656
|
if (currentLine < generatedLine) {
|
|
2600
|
-
|
|
3657
|
+
// Consecutive lines (diff === 1) are the dominant case; avoid the
|
|
3658
|
+
// `.repeat()` call entirely for them.
|
|
3659
|
+
str =
|
|
3660
|
+
generatedLine === currentLine + 1
|
|
3661
|
+
? ";"
|
|
3662
|
+
: ";".repeat(generatedLine - currentLine);
|
|
2601
3663
|
currentLine = generatedLine;
|
|
2602
3664
|
currentColumn = 0;
|
|
2603
3665
|
initial = false;
|
|
@@ -2608,46 +3670,26 @@ const createFullMappingsSerializer = () => {
|
|
|
2608
3670
|
str = ",";
|
|
2609
3671
|
}
|
|
2610
3672
|
|
|
2611
|
-
|
|
2612
|
-
* @param {number} value value
|
|
2613
|
-
* @returns {void}
|
|
2614
|
-
*/
|
|
2615
|
-
const writeValue = (value) => {
|
|
2616
|
-
const sign = (value >>> 31) & 1;
|
|
2617
|
-
const mask = value >> 31;
|
|
2618
|
-
const absValue = (value + mask) ^ mask;
|
|
2619
|
-
let data = (absValue << 1) | sign;
|
|
2620
|
-
for (;;) {
|
|
2621
|
-
const sextet = data & 0x1f;
|
|
2622
|
-
data >>= 5;
|
|
2623
|
-
if (data === 0) {
|
|
2624
|
-
str += ALPHABET[sextet];
|
|
2625
|
-
break;
|
|
2626
|
-
} else {
|
|
2627
|
-
str += ALPHABET[sextet | CONTINUATION_BIT];
|
|
2628
|
-
}
|
|
2629
|
-
}
|
|
2630
|
-
};
|
|
2631
|
-
writeValue(generatedColumn - currentColumn);
|
|
3673
|
+
str = writeValue(str, generatedColumn - currentColumn);
|
|
2632
3674
|
currentColumn = generatedColumn;
|
|
2633
3675
|
if (sourceIndex >= 0) {
|
|
2634
3676
|
activeMapping = true;
|
|
2635
3677
|
if (sourceIndex === currentSourceIndex) {
|
|
2636
3678
|
str += "A";
|
|
2637
3679
|
} else {
|
|
2638
|
-
writeValue(sourceIndex - currentSourceIndex);
|
|
3680
|
+
str = writeValue(str, sourceIndex - currentSourceIndex);
|
|
2639
3681
|
currentSourceIndex = sourceIndex;
|
|
2640
3682
|
}
|
|
2641
|
-
writeValue(originalLine - currentOriginalLine);
|
|
3683
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
2642
3684
|
currentOriginalLine = originalLine;
|
|
2643
3685
|
if (originalColumn === currentOriginalColumn) {
|
|
2644
3686
|
str += "A";
|
|
2645
3687
|
} else {
|
|
2646
|
-
writeValue(originalColumn - currentOriginalColumn);
|
|
3688
|
+
str = writeValue(str, originalColumn - currentOriginalColumn);
|
|
2647
3689
|
currentOriginalColumn = originalColumn;
|
|
2648
3690
|
}
|
|
2649
3691
|
if (nameIndex >= 0) {
|
|
2650
|
-
writeValue(nameIndex - currentNameIndex);
|
|
3692
|
+
str = writeValue(str, nameIndex - currentNameIndex);
|
|
2651
3693
|
currentNameIndex = nameIndex;
|
|
2652
3694
|
activeName = true;
|
|
2653
3695
|
} else {
|
|
@@ -2682,28 +3724,7 @@ const createLinesOnlyMappingsSerializer = () => {
|
|
|
2682
3724
|
// avoid writing multiple original mappings per line
|
|
2683
3725
|
return "";
|
|
2684
3726
|
}
|
|
2685
|
-
/** @type {undefined | string} */
|
|
2686
3727
|
let str;
|
|
2687
|
-
/**
|
|
2688
|
-
* @param {number} value value
|
|
2689
|
-
* @returns {void}
|
|
2690
|
-
*/
|
|
2691
|
-
const writeValue = (value) => {
|
|
2692
|
-
const sign = (value >>> 31) & 1;
|
|
2693
|
-
const mask = value >> 31;
|
|
2694
|
-
const absValue = (value + mask) ^ mask;
|
|
2695
|
-
let data = (absValue << 1) | sign;
|
|
2696
|
-
for (;;) {
|
|
2697
|
-
const sextet = data & 0x1f;
|
|
2698
|
-
data >>= 5;
|
|
2699
|
-
if (data === 0) {
|
|
2700
|
-
str += ALPHABET[sextet];
|
|
2701
|
-
break;
|
|
2702
|
-
} else {
|
|
2703
|
-
str += ALPHABET[sextet | CONTINUATION_BIT];
|
|
2704
|
-
}
|
|
2705
|
-
}
|
|
2706
|
-
};
|
|
2707
3728
|
lastWrittenLine = generatedLine;
|
|
2708
3729
|
if (generatedLine === currentLine + 1) {
|
|
2709
3730
|
currentLine = generatedLine;
|
|
@@ -2713,14 +3734,14 @@ const createLinesOnlyMappingsSerializer = () => {
|
|
|
2713
3734
|
return ";AACA";
|
|
2714
3735
|
}
|
|
2715
3736
|
str = ";AA";
|
|
2716
|
-
writeValue(originalLine - currentOriginalLine);
|
|
3737
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
2717
3738
|
currentOriginalLine = originalLine;
|
|
2718
3739
|
return `${str}A`;
|
|
2719
3740
|
}
|
|
2720
3741
|
str = ";A";
|
|
2721
|
-
writeValue(sourceIndex - currentSourceIndex);
|
|
3742
|
+
str = writeValue(str, sourceIndex - currentSourceIndex);
|
|
2722
3743
|
currentSourceIndex = sourceIndex;
|
|
2723
|
-
writeValue(originalLine - currentOriginalLine);
|
|
3744
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
2724
3745
|
currentOriginalLine = originalLine;
|
|
2725
3746
|
return `${str}A`;
|
|
2726
3747
|
}
|
|
@@ -2732,19 +3753,100 @@ const createLinesOnlyMappingsSerializer = () => {
|
|
|
2732
3753
|
return `${str}AACA`;
|
|
2733
3754
|
}
|
|
2734
3755
|
str += "AA";
|
|
2735
|
-
writeValue(originalLine - currentOriginalLine);
|
|
3756
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
2736
3757
|
currentOriginalLine = originalLine;
|
|
2737
3758
|
return `${str}A`;
|
|
2738
3759
|
}
|
|
2739
3760
|
str += "A";
|
|
2740
|
-
writeValue(sourceIndex - currentSourceIndex);
|
|
3761
|
+
str = writeValue(str, sourceIndex - currentSourceIndex);
|
|
2741
3762
|
currentSourceIndex = sourceIndex;
|
|
2742
|
-
writeValue(originalLine - currentOriginalLine);
|
|
3763
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
2743
3764
|
currentOriginalLine = originalLine;
|
|
2744
3765
|
return `${str}A`;
|
|
2745
3766
|
};
|
|
2746
3767
|
};
|
|
2747
3768
|
|
|
3769
|
+
/**
|
|
3770
|
+
* Lines-only mappings emit at most one short — usually constant — segment
|
|
3771
|
+
* per generated line, so the classic string encoding plus cons-string
|
|
3772
|
+
* append is already optimal there (measurably faster than byte-writing).
|
|
3773
|
+
* Only the full serializer, which emits per token, benefits from the byte
|
|
3774
|
+
* buffer. The encoding below mirrors `createLinesOnlyMappingsSerializer`,
|
|
3775
|
+
* inlined so `add` costs a single call.
|
|
3776
|
+
* @returns {MappingsWriter} writer
|
|
3777
|
+
*/
|
|
3778
|
+
const createLinesOnlyMappingsWriter = () => {
|
|
3779
|
+
let mappings = "";
|
|
3780
|
+
let lastWrittenLine = 0;
|
|
3781
|
+
let currentLine = 1;
|
|
3782
|
+
let currentSourceIndex = 0;
|
|
3783
|
+
let currentOriginalLine = 1;
|
|
3784
|
+
return {
|
|
3785
|
+
add(
|
|
3786
|
+
generatedLine,
|
|
3787
|
+
_generatedColumn,
|
|
3788
|
+
sourceIndex,
|
|
3789
|
+
originalLine,
|
|
3790
|
+
_originalColumn,
|
|
3791
|
+
_nameIndex,
|
|
3792
|
+
) {
|
|
3793
|
+
if (sourceIndex < 0) {
|
|
3794
|
+
// avoid writing generated mappings at all
|
|
3795
|
+
return;
|
|
3796
|
+
}
|
|
3797
|
+
if (lastWrittenLine === generatedLine) {
|
|
3798
|
+
// avoid writing multiple original mappings per line
|
|
3799
|
+
return;
|
|
3800
|
+
}
|
|
3801
|
+
let str;
|
|
3802
|
+
lastWrittenLine = generatedLine;
|
|
3803
|
+
if (generatedLine === currentLine + 1) {
|
|
3804
|
+
currentLine = generatedLine;
|
|
3805
|
+
if (sourceIndex === currentSourceIndex) {
|
|
3806
|
+
if (originalLine === currentOriginalLine + 1) {
|
|
3807
|
+
currentOriginalLine = originalLine;
|
|
3808
|
+
mappings += ";AACA";
|
|
3809
|
+
return;
|
|
3810
|
+
}
|
|
3811
|
+
str = ";AA";
|
|
3812
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
3813
|
+
currentOriginalLine = originalLine;
|
|
3814
|
+
mappings += `${str}A`;
|
|
3815
|
+
return;
|
|
3816
|
+
}
|
|
3817
|
+
str = ";A";
|
|
3818
|
+
str = writeValue(str, sourceIndex - currentSourceIndex);
|
|
3819
|
+
currentSourceIndex = sourceIndex;
|
|
3820
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
3821
|
+
currentOriginalLine = originalLine;
|
|
3822
|
+
mappings += `${str}A`;
|
|
3823
|
+
return;
|
|
3824
|
+
}
|
|
3825
|
+
str = ";".repeat(generatedLine - currentLine);
|
|
3826
|
+
currentLine = generatedLine;
|
|
3827
|
+
if (sourceIndex === currentSourceIndex) {
|
|
3828
|
+
if (originalLine === currentOriginalLine + 1) {
|
|
3829
|
+
currentOriginalLine = originalLine;
|
|
3830
|
+
mappings += `${str}AACA`;
|
|
3831
|
+
return;
|
|
3832
|
+
}
|
|
3833
|
+
str += "AA";
|
|
3834
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
3835
|
+
currentOriginalLine = originalLine;
|
|
3836
|
+
mappings += `${str}A`;
|
|
3837
|
+
return;
|
|
3838
|
+
}
|
|
3839
|
+
str += "A";
|
|
3840
|
+
str = writeValue(str, sourceIndex - currentSourceIndex);
|
|
3841
|
+
currentSourceIndex = sourceIndex;
|
|
3842
|
+
str = writeValue(str, originalLine - currentOriginalLine);
|
|
3843
|
+
currentOriginalLine = originalLine;
|
|
3844
|
+
mappings += `${str}A`;
|
|
3845
|
+
},
|
|
3846
|
+
finish: () => mappings,
|
|
3847
|
+
};
|
|
3848
|
+
};
|
|
3849
|
+
|
|
2748
3850
|
/**
|
|
2749
3851
|
* @param {{ columns?: boolean }=} options options
|
|
2750
3852
|
* @returns {MappingsSerializer} mappings serializer
|
|
@@ -2756,12 +3858,24 @@ const createMappingsSerializer = (options) => {
|
|
|
2756
3858
|
: createFullMappingsSerializer();
|
|
2757
3859
|
};
|
|
2758
3860
|
|
|
3861
|
+
/**
|
|
3862
|
+
* @param {{ columns?: boolean }=} options options
|
|
3863
|
+
* @returns {MappingsWriter} push-based mappings writer
|
|
3864
|
+
*/
|
|
3865
|
+
const createMappingsWriter = (options) => {
|
|
3866
|
+
const linesOnly = options && options.columns === false;
|
|
3867
|
+
return linesOnly
|
|
3868
|
+
? createLinesOnlyMappingsWriter()
|
|
3869
|
+
: createFullMappingsWriter();
|
|
3870
|
+
};
|
|
3871
|
+
|
|
2759
3872
|
module.exports = createMappingsSerializer;
|
|
3873
|
+
module.exports.createMappingsWriter = createMappingsWriter;
|
|
2760
3874
|
|
|
2761
3875
|
|
|
2762
3876
|
/***/ }),
|
|
2763
3877
|
|
|
2764
|
-
/***/
|
|
3878
|
+
/***/ 847:
|
|
2765
3879
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
2766
3880
|
|
|
2767
3881
|
/*
|
|
@@ -2771,7 +3885,7 @@ module.exports = createMappingsSerializer;
|
|
|
2771
3885
|
|
|
2772
3886
|
|
|
2773
3887
|
|
|
2774
|
-
const
|
|
3888
|
+
const { createMappingsWriter } = __nccwpck_require__(818);
|
|
2775
3889
|
|
|
2776
3890
|
/** @typedef {import("../Source").RawSourceMap} RawSourceMap */
|
|
2777
3891
|
/** @typedef {import("../Source").SourceAndMap} SourceAndMap */
|
|
@@ -2780,97 +3894,165 @@ const createMappingsSerializer = __nccwpck_require__(294);
|
|
|
2780
3894
|
|
|
2781
3895
|
/** @typedef {{ streamChunks: StreamChunksFunction }} SourceLikeWithStreamChunks */
|
|
2782
3896
|
|
|
3897
|
+
/** @type {typeof import("./scopes") | undefined} */
|
|
3898
|
+
let scopesHelpers;
|
|
3899
|
+
|
|
2783
3900
|
/**
|
|
2784
|
-
*
|
|
3901
|
+
* Loads the scopes helpers on first use. They are only reachable through the
|
|
3902
|
+
* `scopes` option, so requiring them eagerly would put the encoder in the
|
|
3903
|
+
* module graph of every caller that never asks for the field.
|
|
3904
|
+
* @returns {ReturnType<typeof import("./scopes").createScopesWriter>} writer
|
|
3905
|
+
*/
|
|
3906
|
+
const createScopesWriter = () => {
|
|
3907
|
+
if (scopesHelpers === undefined) scopesHelpers = __nccwpck_require__(928);
|
|
3908
|
+
return scopesHelpers.createScopesWriter();
|
|
3909
|
+
};
|
|
3910
|
+
|
|
3911
|
+
/**
|
|
3912
|
+
* Assign `value` at index `i` of `arr`, padding earlier slots with `null`.
|
|
3913
|
+
* Hoisted helper so `getMap` and `getSourceAndMap` share one
|
|
3914
|
+
* implementation. Uses `push` rather than `arr.length = i + 1` because the
|
|
3915
|
+
* latter forces V8's HOLEY_ELEMENTS kind permanently — push keeps the
|
|
3916
|
+
* backing store PACKED, which the downstream source-map serializer iterates
|
|
3917
|
+
* over far more efficiently.
|
|
3918
|
+
* @template T
|
|
3919
|
+
* @param {(T | null)[]} arr destination array
|
|
3920
|
+
* @param {number} i index to assign
|
|
3921
|
+
* @param {T} value value to assign
|
|
3922
|
+
* @returns {void}
|
|
3923
|
+
*/
|
|
3924
|
+
const setAtIndex = (arr, i, value) => {
|
|
3925
|
+
while (arr.length < i) arr.push(null);
|
|
3926
|
+
// `arr[i] = value` where `i === arr.length` extends the array exactly
|
|
3927
|
+
// like `push` (V8 keeps PACKED_ELEMENTS); after the while-loop
|
|
3928
|
+
// `i <= arr.length` always, so the hole case that would force HOLEY is
|
|
3929
|
+
// impossible here.
|
|
3930
|
+
arr[i] = value;
|
|
3931
|
+
};
|
|
3932
|
+
|
|
3933
|
+
/**
|
|
3934
|
+
* @param {SourceLikeWithStreamChunks} source source
|
|
2785
3935
|
* @param {Options=} options options
|
|
2786
|
-
* @returns {
|
|
3936
|
+
* @returns {RawSourceMap | null} map
|
|
2787
3937
|
*/
|
|
2788
|
-
module.exports.
|
|
2789
|
-
let code = "";
|
|
2790
|
-
let mappings = "";
|
|
3938
|
+
module.exports.getMap = (source, options) => {
|
|
2791
3939
|
/** @type {(string | null)[]} */
|
|
2792
3940
|
const potentialSources = [];
|
|
2793
3941
|
/** @type {(string | null)[]} */
|
|
2794
3942
|
const potentialSourcesContent = [];
|
|
2795
3943
|
/** @type {(string | null)[]} */
|
|
2796
3944
|
const potentialNames = [];
|
|
2797
|
-
const
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2800
|
-
(
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
potentialSources[sourceIndex] = source;
|
|
2824
|
-
if (sourceContent !== undefined) {
|
|
2825
|
-
while (potentialSourcesContent.length < sourceIndex) {
|
|
2826
|
-
potentialSourcesContent.push(null);
|
|
3945
|
+
const mappingsWriter = createMappingsWriter(options);
|
|
3946
|
+
const addMapping = mappingsWriter.add;
|
|
3947
|
+
const scopesWriter =
|
|
3948
|
+
options && options.scopes ? createScopesWriter() : undefined;
|
|
3949
|
+
// Chosen once rather than tested per segment: this callback is the whole of
|
|
3950
|
+
// the mapping loop, so a branch in it is measurable on every map built.
|
|
3951
|
+
const generated = source.streamChunks(
|
|
3952
|
+
{ ...options, source: false, finalSource: true },
|
|
3953
|
+
scopesWriter === undefined
|
|
3954
|
+
? (
|
|
3955
|
+
chunk,
|
|
3956
|
+
generatedLine,
|
|
3957
|
+
generatedColumn,
|
|
3958
|
+
sourceIndex,
|
|
3959
|
+
originalLine,
|
|
3960
|
+
originalColumn,
|
|
3961
|
+
nameIndex,
|
|
3962
|
+
) => {
|
|
3963
|
+
addMapping(
|
|
3964
|
+
generatedLine,
|
|
3965
|
+
generatedColumn,
|
|
3966
|
+
sourceIndex,
|
|
3967
|
+
originalLine,
|
|
3968
|
+
originalColumn,
|
|
3969
|
+
nameIndex,
|
|
3970
|
+
);
|
|
2827
3971
|
}
|
|
2828
|
-
|
|
3972
|
+
: (
|
|
3973
|
+
chunk,
|
|
3974
|
+
generatedLine,
|
|
3975
|
+
generatedColumn,
|
|
3976
|
+
sourceIndex,
|
|
3977
|
+
originalLine,
|
|
3978
|
+
originalColumn,
|
|
3979
|
+
nameIndex,
|
|
3980
|
+
) => {
|
|
3981
|
+
addMapping(
|
|
3982
|
+
generatedLine,
|
|
3983
|
+
generatedColumn,
|
|
3984
|
+
sourceIndex,
|
|
3985
|
+
originalLine,
|
|
3986
|
+
originalColumn,
|
|
3987
|
+
nameIndex,
|
|
3988
|
+
);
|
|
3989
|
+
scopesWriter.add(
|
|
3990
|
+
generatedLine,
|
|
3991
|
+
generatedColumn,
|
|
3992
|
+
sourceIndex,
|
|
3993
|
+
originalLine,
|
|
3994
|
+
);
|
|
3995
|
+
},
|
|
3996
|
+
(sourceIndex, source, sourceContent, scopeBindings) => {
|
|
3997
|
+
setAtIndex(potentialSources, sourceIndex, source);
|
|
3998
|
+
if (sourceContent !== undefined) {
|
|
3999
|
+
setAtIndex(potentialSourcesContent, sourceIndex, sourceContent);
|
|
4000
|
+
}
|
|
4001
|
+
if (scopesWriter !== undefined) {
|
|
4002
|
+
scopesWriter.addSource(sourceIndex, scopeBindings);
|
|
2829
4003
|
}
|
|
2830
4004
|
},
|
|
2831
4005
|
(nameIndex, name) => {
|
|
2832
|
-
|
|
2833
|
-
potentialNames.push(null);
|
|
2834
|
-
}
|
|
2835
|
-
potentialNames[nameIndex] = name;
|
|
4006
|
+
setAtIndex(potentialNames, nameIndex, name);
|
|
2836
4007
|
},
|
|
2837
4008
|
);
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
names: /** @type {string[]} */ (potentialNames),
|
|
2853
|
-
}
|
|
2854
|
-
: null,
|
|
4009
|
+
const mappings = mappingsWriter.finish();
|
|
4010
|
+
if (mappings.length === 0) return null;
|
|
4011
|
+
/** @type {RawSourceMap} */
|
|
4012
|
+
const map = {
|
|
4013
|
+
version: 3,
|
|
4014
|
+
file: "x",
|
|
4015
|
+
mappings,
|
|
4016
|
+
// We handle broken sources as `null`, in spec this field should be string, but no information what we should do in such cases if we change type it will be breaking change
|
|
4017
|
+
sources: /** @type {string[]} */ (potentialSources),
|
|
4018
|
+
sourcesContent:
|
|
4019
|
+
potentialSourcesContent.length > 0
|
|
4020
|
+
? /** @type {string[]} */ (potentialSourcesContent)
|
|
4021
|
+
: undefined,
|
|
4022
|
+
names: /** @type {string[]} */ (potentialNames),
|
|
2855
4023
|
};
|
|
4024
|
+
if (scopesWriter !== undefined) {
|
|
4025
|
+
scopesWriter.finish(
|
|
4026
|
+
map,
|
|
4027
|
+
generated.generatedLine,
|
|
4028
|
+
generated.generatedColumn,
|
|
4029
|
+
);
|
|
4030
|
+
}
|
|
4031
|
+
return map;
|
|
2856
4032
|
};
|
|
2857
4033
|
|
|
2858
4034
|
/**
|
|
2859
|
-
* @param {SourceLikeWithStreamChunks}
|
|
4035
|
+
* @param {SourceLikeWithStreamChunks} inputSource input source
|
|
2860
4036
|
* @param {Options=} options options
|
|
2861
|
-
* @returns {
|
|
2862
|
-
*/
|
|
2863
|
-
module.exports.
|
|
2864
|
-
let
|
|
4037
|
+
* @returns {SourceAndMap} map
|
|
4038
|
+
*/
|
|
4039
|
+
module.exports.getSourceAndMap = (inputSource, options) => {
|
|
4040
|
+
let code = "";
|
|
2865
4041
|
/** @type {(string | null)[]} */
|
|
2866
4042
|
const potentialSources = [];
|
|
2867
4043
|
/** @type {(string | null)[]} */
|
|
2868
4044
|
const potentialSourcesContent = [];
|
|
2869
4045
|
/** @type {(string | null)[]} */
|
|
2870
4046
|
const potentialNames = [];
|
|
2871
|
-
const
|
|
2872
|
-
|
|
2873
|
-
|
|
4047
|
+
const mappingsWriter = createMappingsWriter(options);
|
|
4048
|
+
const addMapping = mappingsWriter.add;
|
|
4049
|
+
const scopesWriter =
|
|
4050
|
+
options && options.scopes ? createScopesWriter() : undefined;
|
|
4051
|
+
const generated = inputSource.streamChunks(
|
|
4052
|
+
// `source: true` overrides any `source: false` a caller forwarded
|
|
4053
|
+
// (e.g. the streamChunks fallback passing getMap options through
|
|
4054
|
+
// sourceAndMap) — this helper always consumes the source.
|
|
4055
|
+
{ ...options, finalSource: true, source: true },
|
|
2874
4056
|
(
|
|
2875
4057
|
chunk,
|
|
2876
4058
|
generatedLine,
|
|
@@ -2880,7 +4062,8 @@ module.exports.getMap = (source, options) => {
|
|
|
2880
4062
|
originalColumn,
|
|
2881
4063
|
nameIndex,
|
|
2882
4064
|
) => {
|
|
2883
|
-
|
|
4065
|
+
if (chunk !== undefined) code += chunk;
|
|
4066
|
+
addMapping(
|
|
2884
4067
|
generatedLine,
|
|
2885
4068
|
generatedColumn,
|
|
2886
4069
|
sourceIndex,
|
|
@@ -2888,8 +4071,19 @@ module.exports.getMap = (source, options) => {
|
|
|
2888
4071
|
originalColumn,
|
|
2889
4072
|
nameIndex,
|
|
2890
4073
|
);
|
|
4074
|
+
if (scopesWriter !== undefined) {
|
|
4075
|
+
scopesWriter.add(
|
|
4076
|
+
generatedLine,
|
|
4077
|
+
generatedColumn,
|
|
4078
|
+
sourceIndex,
|
|
4079
|
+
originalLine,
|
|
4080
|
+
);
|
|
4081
|
+
}
|
|
2891
4082
|
},
|
|
2892
|
-
(sourceIndex, source, sourceContent) => {
|
|
4083
|
+
(sourceIndex, source, sourceContent, scopeBindings) => {
|
|
4084
|
+
if (scopesWriter !== undefined) {
|
|
4085
|
+
scopesWriter.addSource(sourceIndex, scopeBindings);
|
|
4086
|
+
}
|
|
2893
4087
|
while (potentialSources.length < sourceIndex) {
|
|
2894
4088
|
potentialSources.push(null);
|
|
2895
4089
|
}
|
|
@@ -2908,26 +4102,38 @@ module.exports.getMap = (source, options) => {
|
|
|
2908
4102
|
potentialNames[nameIndex] = name;
|
|
2909
4103
|
},
|
|
2910
4104
|
);
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
4105
|
+
const mappings = mappingsWriter.finish();
|
|
4106
|
+
const { source } = generated;
|
|
4107
|
+
/** @type {RawSourceMap | null} */
|
|
4108
|
+
let map = null;
|
|
4109
|
+
if (mappings.length > 0) {
|
|
4110
|
+
map = {
|
|
4111
|
+
version: 3,
|
|
4112
|
+
file: "x",
|
|
4113
|
+
mappings,
|
|
4114
|
+
// We handle broken sources as `null`, in spec this field should be string, but no information what we should do in such cases if we change type it will be breaking change
|
|
4115
|
+
sources: /** @type {string[]} */ (potentialSources),
|
|
4116
|
+
sourcesContent:
|
|
4117
|
+
potentialSourcesContent.length > 0
|
|
4118
|
+
? /** @type {string[]} */ (potentialSourcesContent)
|
|
4119
|
+
: undefined,
|
|
4120
|
+
names: /** @type {string[]} */ (potentialNames),
|
|
4121
|
+
};
|
|
4122
|
+
if (scopesWriter !== undefined) {
|
|
4123
|
+
scopesWriter.finish(
|
|
4124
|
+
map,
|
|
4125
|
+
generated.generatedLine,
|
|
4126
|
+
generated.generatedColumn,
|
|
4127
|
+
);
|
|
4128
|
+
}
|
|
4129
|
+
}
|
|
4130
|
+
return { source: source !== undefined ? source : code, map };
|
|
2925
4131
|
};
|
|
2926
4132
|
|
|
2927
4133
|
|
|
2928
4134
|
/***/ }),
|
|
2929
4135
|
|
|
2930
|
-
/***/
|
|
4136
|
+
/***/ 769:
|
|
2931
4137
|
/***/ ((module) => {
|
|
2932
4138
|
|
|
2933
4139
|
/*
|
|
@@ -2937,8 +4143,6 @@ module.exports.getMap = (source, options) => {
|
|
|
2937
4143
|
|
|
2938
4144
|
|
|
2939
4145
|
|
|
2940
|
-
const CHAR_CODE_NEW_LINE = "\n".charCodeAt(0);
|
|
2941
|
-
|
|
2942
4146
|
/**
|
|
2943
4147
|
* @typedef {object} GeneratedSourceInfo
|
|
2944
4148
|
* @property {number=} generatedLine generated line
|
|
@@ -2962,9 +4166,14 @@ const getGeneratedSourceInfo = (source) => {
|
|
|
2962
4166
|
source,
|
|
2963
4167
|
};
|
|
2964
4168
|
}
|
|
4169
|
+
// Use native indexOf to scan for newlines instead of charCodeAt loops.
|
|
4170
|
+
// This is significantly faster on large sources since indexOf uses
|
|
4171
|
+
// vectorized/native string scanning.
|
|
2965
4172
|
let generatedLine = 2;
|
|
2966
|
-
|
|
2967
|
-
|
|
4173
|
+
let idx = source.indexOf("\n");
|
|
4174
|
+
while (idx !== -1 && idx < lastLineStart) {
|
|
4175
|
+
generatedLine++;
|
|
4176
|
+
idx = source.indexOf("\n", idx + 1);
|
|
2968
4177
|
}
|
|
2969
4178
|
return {
|
|
2970
4179
|
generatedLine,
|
|
@@ -2978,7 +4187,7 @@ module.exports = getGeneratedSourceInfo;
|
|
|
2978
4187
|
|
|
2979
4188
|
/***/ }),
|
|
2980
4189
|
|
|
2981
|
-
/***/
|
|
4190
|
+
/***/ 292:
|
|
2982
4191
|
/***/ ((module) => {
|
|
2983
4192
|
|
|
2984
4193
|
/*
|
|
@@ -3009,7 +4218,7 @@ module.exports = getSource;
|
|
|
3009
4218
|
|
|
3010
4219
|
/***/ }),
|
|
3011
4220
|
|
|
3012
|
-
/***/
|
|
4221
|
+
/***/ 674:
|
|
3013
4222
|
/***/ ((module) => {
|
|
3014
4223
|
|
|
3015
4224
|
/*
|
|
@@ -3049,8 +4258,8 @@ const ccMax = ccToValue.length - 1;
|
|
|
3049
4258
|
* @returns {void}
|
|
3050
4259
|
*/
|
|
3051
4260
|
const readMappings = (mappings, onMapping) => {
|
|
3052
|
-
// generatedColumn, [sourceIndex, originalLine,
|
|
3053
|
-
const currentData = new
|
|
4261
|
+
// generatedColumn, [sourceIndex, originalLine, originalColumn, [nameIndex]]
|
|
4262
|
+
const currentData = new Int32Array([0, 0, 1, 0, 0]);
|
|
3054
4263
|
let currentDataPos = 0;
|
|
3055
4264
|
// currentValue will include a sign bit at bit 0
|
|
3056
4265
|
let currentValue = 0;
|
|
@@ -3085,7 +4294,10 @@ const readMappings = (mappings, onMapping) => {
|
|
|
3085
4294
|
currentData[4],
|
|
3086
4295
|
);
|
|
3087
4296
|
}
|
|
3088
|
-
|
|
4297
|
+
// Direct typed-array index is faster here than destructuring,
|
|
4298
|
+
// which would invoke the Int32Array iterator protocol.
|
|
4299
|
+
// eslint-disable-next-line prefer-destructuring
|
|
4300
|
+
generatedColumn = currentData[0];
|
|
3089
4301
|
}
|
|
3090
4302
|
currentDataPos = 0;
|
|
3091
4303
|
if (value === NEXT_LINE) {
|
|
@@ -3136,7 +4348,452 @@ module.exports = readMappings;
|
|
|
3136
4348
|
|
|
3137
4349
|
/***/ }),
|
|
3138
4350
|
|
|
3139
|
-
/***/
|
|
4351
|
+
/***/ 928:
|
|
4352
|
+
/***/ ((module) => {
|
|
4353
|
+
|
|
4354
|
+
/*
|
|
4355
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
4356
|
+
Author Alexander Akait @alexander-akait
|
|
4357
|
+
*/
|
|
4358
|
+
|
|
4359
|
+
|
|
4360
|
+
|
|
4361
|
+
/** @typedef {import("../Source").RawSourceMap} RawSourceMap */
|
|
4362
|
+
/** @typedef {import("./streamChunks").ScopeBindings} ScopeBindings */
|
|
4363
|
+
|
|
4364
|
+
/**
|
|
4365
|
+
* A generated or original position, both counted from zero.
|
|
4366
|
+
* @typedef {object} ScopePosition
|
|
4367
|
+
* @property {number} line line
|
|
4368
|
+
* @property {number} column column
|
|
4369
|
+
*/
|
|
4370
|
+
|
|
4371
|
+
/**
|
|
4372
|
+
* One source's scope, and the span of generated code it explains.
|
|
4373
|
+
* @typedef {object} SourceScope
|
|
4374
|
+
* @property {number} sourceIndex index into the map's `sources`
|
|
4375
|
+
* @property {string[]} variables the names the source declares
|
|
4376
|
+
* @property {string[]} values the generated expression each name evaluates to
|
|
4377
|
+
* @property {ScopePosition} originalEnd end of the original scope, exclusive
|
|
4378
|
+
* @property {ScopePosition[]} rangeStarts start of each generated range, inclusive
|
|
4379
|
+
* @property {ScopePosition[]} rangeEnds end of each generated range, exclusive
|
|
4380
|
+
*/
|
|
4381
|
+
|
|
4382
|
+
const BASE64_CHARS =
|
|
4383
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
4384
|
+
|
|
4385
|
+
const BASE64_VALUES = new Int8Array(128).fill(-1);
|
|
4386
|
+
for (let index = 0; index < BASE64_CHARS.length; index++) {
|
|
4387
|
+
BASE64_VALUES[BASE64_CHARS.charCodeAt(index)] = index;
|
|
4388
|
+
}
|
|
4389
|
+
|
|
4390
|
+
const VLQ_BASE_SHIFT = 5;
|
|
4391
|
+
const VLQ_BASE_MASK = (1 << VLQ_BASE_SHIFT) - 1;
|
|
4392
|
+
const VLQ_CONTINUATION_BIT = 1 << VLQ_BASE_SHIFT;
|
|
4393
|
+
|
|
4394
|
+
// Item tags of the "Scopes" proposal, base64 digits of their numeric values.
|
|
4395
|
+
const TAG_EMPTY = "A";
|
|
4396
|
+
const TAG_ORIGINAL_SCOPE_START = "B";
|
|
4397
|
+
const TAG_ORIGINAL_SCOPE_END = "C";
|
|
4398
|
+
const TAG_ORIGINAL_SCOPE_VARIABLES = "D";
|
|
4399
|
+
const TAG_GENERATED_RANGE_START = "E";
|
|
4400
|
+
const TAG_GENERATED_RANGE_END = "F";
|
|
4401
|
+
const TAG_GENERATED_RANGE_BINDINGS = "G";
|
|
4402
|
+
|
|
4403
|
+
const ORIGINAL_SCOPE_FLAG_HAS_KIND = 0x2;
|
|
4404
|
+
const GENERATED_RANGE_FLAG_HAS_LINE = 0x1;
|
|
4405
|
+
const GENERATED_RANGE_FLAG_HAS_DEFINITION = 0x2;
|
|
4406
|
+
|
|
4407
|
+
/**
|
|
4408
|
+
* Every scope webpack emits describes one module, which the proposal's
|
|
4409
|
+
* JavaScript vocabulary calls a module scope.
|
|
4410
|
+
*/
|
|
4411
|
+
const MODULE_SCOPE_KIND = "Module";
|
|
4412
|
+
|
|
4413
|
+
/**
|
|
4414
|
+
* @param {number} value non-negative value
|
|
4415
|
+
* @returns {string} base64 VLQ digits
|
|
4416
|
+
*/
|
|
4417
|
+
const encodeUnsigned = (value) => {
|
|
4418
|
+
let result = "";
|
|
4419
|
+
let rest = value;
|
|
4420
|
+
for (;;) {
|
|
4421
|
+
const digit = rest & VLQ_BASE_MASK;
|
|
4422
|
+
rest >>>= VLQ_BASE_SHIFT;
|
|
4423
|
+
if (rest === 0) return result + BASE64_CHARS[digit];
|
|
4424
|
+
result += BASE64_CHARS[VLQ_CONTINUATION_BIT + digit];
|
|
4425
|
+
}
|
|
4426
|
+
};
|
|
4427
|
+
|
|
4428
|
+
/**
|
|
4429
|
+
* @param {number} value value of either sign
|
|
4430
|
+
* @returns {string} base64 VLQ digits
|
|
4431
|
+
*/
|
|
4432
|
+
const encodeSigned = (value) =>
|
|
4433
|
+
encodeUnsigned(value >= 0 ? 2 * value : 1 - 2 * value);
|
|
4434
|
+
|
|
4435
|
+
/**
|
|
4436
|
+
* Walks the map's segments in generated order, reporting each one's source and
|
|
4437
|
+
* original line. A segment with no source position reports `sourceIndex` -1,
|
|
4438
|
+
* which ends whatever run precedes it.
|
|
4439
|
+
* @param {string} mappings the map's `mappings` field
|
|
4440
|
+
* @param {(generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number) => void} onSegment called per segment
|
|
4441
|
+
* @returns {number} the last generated line the mappings reach
|
|
4442
|
+
*/
|
|
4443
|
+
const forEachMapping = (mappings, onSegment) => {
|
|
4444
|
+
let generatedLine = 0;
|
|
4445
|
+
let generatedColumn = 0;
|
|
4446
|
+
let sourceIndex = 0;
|
|
4447
|
+
let originalLine = 0;
|
|
4448
|
+
let position = 0;
|
|
4449
|
+
const { length } = mappings;
|
|
4450
|
+
/** @type {number[]} */
|
|
4451
|
+
const fields = [];
|
|
4452
|
+
while (position < length) {
|
|
4453
|
+
const char = mappings.charCodeAt(position);
|
|
4454
|
+
if (char === 59 /* ; */) {
|
|
4455
|
+
generatedLine++;
|
|
4456
|
+
generatedColumn = 0;
|
|
4457
|
+
position++;
|
|
4458
|
+
continue;
|
|
4459
|
+
}
|
|
4460
|
+
if (char === 44 /* , */) {
|
|
4461
|
+
position++;
|
|
4462
|
+
continue;
|
|
4463
|
+
}
|
|
4464
|
+
fields.length = 0;
|
|
4465
|
+
while (position < length) {
|
|
4466
|
+
const next = mappings.charCodeAt(position);
|
|
4467
|
+
if (next === 59 || next === 44) break;
|
|
4468
|
+
let value = 0;
|
|
4469
|
+
let shift = 0;
|
|
4470
|
+
let digit;
|
|
4471
|
+
do {
|
|
4472
|
+
digit = BASE64_VALUES[mappings.charCodeAt(position++)];
|
|
4473
|
+
// A digit outside the alphabet cannot be recovered from, and
|
|
4474
|
+
// pretending otherwise would misplace every later segment.
|
|
4475
|
+
if (digit < 0) return generatedLine;
|
|
4476
|
+
value += (digit & VLQ_BASE_MASK) << shift;
|
|
4477
|
+
shift += VLQ_BASE_SHIFT;
|
|
4478
|
+
} while (digit & VLQ_CONTINUATION_BIT);
|
|
4479
|
+
fields.push(value & 1 ? -(value >>> 1) : value >>> 1);
|
|
4480
|
+
}
|
|
4481
|
+
if (fields.length === 0) continue;
|
|
4482
|
+
generatedColumn += fields[0];
|
|
4483
|
+
if (fields.length >= 4) {
|
|
4484
|
+
sourceIndex += fields[1];
|
|
4485
|
+
originalLine += fields[2];
|
|
4486
|
+
onSegment(generatedLine, generatedColumn, sourceIndex, originalLine);
|
|
4487
|
+
} else {
|
|
4488
|
+
onSegment(generatedLine, generatedColumn, -1, -1);
|
|
4489
|
+
}
|
|
4490
|
+
}
|
|
4491
|
+
return generatedLine;
|
|
4492
|
+
};
|
|
4493
|
+
|
|
4494
|
+
/**
|
|
4495
|
+
* Collects, segment by segment, the generated runs each source explains and how
|
|
4496
|
+
* far into it the map reaches. Both lines are counted from zero, so a caller
|
|
4497
|
+
* whose lines start at one subtracts before feeding a segment in.
|
|
4498
|
+
* @param {number=} sourceCount number of entries in the map's `sources`, when known
|
|
4499
|
+
* @returns {{ add: (generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number) => void, finish: (lastLine: number, lastColumn?: number) => SourceScope[] }} collector
|
|
4500
|
+
*/
|
|
4501
|
+
const createScopeCollector = (sourceCount) => {
|
|
4502
|
+
/** @type {Map<number, SourceScope>} */
|
|
4503
|
+
const scopes = new Map();
|
|
4504
|
+
let openSource = -1;
|
|
4505
|
+
/** @type {SourceScope | undefined} */
|
|
4506
|
+
let openScope;
|
|
4507
|
+
/**
|
|
4508
|
+
* @param {number} line generated line the run ends at
|
|
4509
|
+
* @param {number} column generated column the run ends at
|
|
4510
|
+
* @returns {void}
|
|
4511
|
+
*/
|
|
4512
|
+
const closeRun = (line, column) => {
|
|
4513
|
+
if (openScope === undefined) return;
|
|
4514
|
+
openScope.rangeEnds.push({ line, column });
|
|
4515
|
+
openScope = undefined;
|
|
4516
|
+
openSource = -1;
|
|
4517
|
+
};
|
|
4518
|
+
return {
|
|
4519
|
+
add(generatedLine, generatedColumn, sourceIndex, originalLine) {
|
|
4520
|
+
// A segment naming no source reports -1, which is also what no open
|
|
4521
|
+
// run reports, so the run has to be there before it is extended.
|
|
4522
|
+
if (openScope !== undefined && sourceIndex === openSource) {
|
|
4523
|
+
openScope.originalEnd.line = Math.max(
|
|
4524
|
+
openScope.originalEnd.line,
|
|
4525
|
+
originalLine + 1,
|
|
4526
|
+
);
|
|
4527
|
+
return;
|
|
4528
|
+
}
|
|
4529
|
+
closeRun(generatedLine, generatedColumn);
|
|
4530
|
+
if (
|
|
4531
|
+
sourceIndex < 0 ||
|
|
4532
|
+
(sourceCount !== undefined && sourceIndex >= sourceCount)
|
|
4533
|
+
) {
|
|
4534
|
+
return;
|
|
4535
|
+
}
|
|
4536
|
+
let scope = scopes.get(sourceIndex);
|
|
4537
|
+
if (scope === undefined) {
|
|
4538
|
+
scope = {
|
|
4539
|
+
sourceIndex,
|
|
4540
|
+
variables: [],
|
|
4541
|
+
values: [],
|
|
4542
|
+
originalEnd: { line: originalLine + 1, column: 0 },
|
|
4543
|
+
rangeStarts: [],
|
|
4544
|
+
rangeEnds: [],
|
|
4545
|
+
};
|
|
4546
|
+
scopes.set(sourceIndex, scope);
|
|
4547
|
+
} else {
|
|
4548
|
+
scope.originalEnd.line = Math.max(
|
|
4549
|
+
scope.originalEnd.line,
|
|
4550
|
+
originalLine + 1,
|
|
4551
|
+
);
|
|
4552
|
+
}
|
|
4553
|
+
scope.rangeStarts.push({ line: generatedLine, column: generatedColumn });
|
|
4554
|
+
openScope = scope;
|
|
4555
|
+
openSource = sourceIndex;
|
|
4556
|
+
},
|
|
4557
|
+
finish(lastLine, lastColumn = 0) {
|
|
4558
|
+
closeRun(lastLine, lastColumn);
|
|
4559
|
+
return [...scopes.values()].sort((a, b) => a.sourceIndex - b.sourceIndex);
|
|
4560
|
+
},
|
|
4561
|
+
};
|
|
4562
|
+
};
|
|
4563
|
+
|
|
4564
|
+
/**
|
|
4565
|
+
* Groups a finished map's segments into one entry per source. Prefer the
|
|
4566
|
+
* collector when the segments are still being written, which saves decoding
|
|
4567
|
+
* back what was just encoded.
|
|
4568
|
+
* @param {string} mappings the map's `mappings` field
|
|
4569
|
+
* @param {number} sourceCount number of entries in the map's `sources`
|
|
4570
|
+
* @returns {SourceScope[]} one entry per source that the mappings reach, in source order
|
|
4571
|
+
*/
|
|
4572
|
+
const collectSourceScopes = (mappings, sourceCount) => {
|
|
4573
|
+
const collector = createScopeCollector(sourceCount);
|
|
4574
|
+
const lastLine = forEachMapping(mappings, collector.add);
|
|
4575
|
+
return collector.finish(lastLine + 1);
|
|
4576
|
+
};
|
|
4577
|
+
|
|
4578
|
+
/**
|
|
4579
|
+
* Encodes the scope tree into the `scopes` field of the proposal, appending any
|
|
4580
|
+
* name it needs to the map's `names`.
|
|
4581
|
+
* @param {SourceScope[]} scopes the scopes to encode, in source order
|
|
4582
|
+
* @param {number} sourceCount number of entries in the map's `sources`
|
|
4583
|
+
* @param {string[]} names the map's `names`, extended in place
|
|
4584
|
+
* @returns {string} the encoded `scopes` field
|
|
4585
|
+
*/
|
|
4586
|
+
const encodeScopes = (scopes, sourceCount, names) => {
|
|
4587
|
+
/** @type {Map<string, number>} */
|
|
4588
|
+
const nameToIndex = new Map();
|
|
4589
|
+
for (let index = 0; index < names.length; index++) {
|
|
4590
|
+
if (!nameToIndex.has(names[index])) nameToIndex.set(names[index], index);
|
|
4591
|
+
}
|
|
4592
|
+
/**
|
|
4593
|
+
* @param {string} name the name to resolve
|
|
4594
|
+
* @returns {number} its index in `names`
|
|
4595
|
+
*/
|
|
4596
|
+
const nameIndex = (name) => {
|
|
4597
|
+
const existing = nameToIndex.get(name);
|
|
4598
|
+
if (existing !== undefined) return existing;
|
|
4599
|
+
const added = names.length;
|
|
4600
|
+
names.push(name);
|
|
4601
|
+
nameToIndex.set(name, added);
|
|
4602
|
+
return added;
|
|
4603
|
+
};
|
|
4604
|
+
|
|
4605
|
+
/** @type {Map<number, SourceScope>} */
|
|
4606
|
+
const scopeBySource = new Map();
|
|
4607
|
+
for (const scope of scopes) scopeBySource.set(scope.sourceIndex, scope);
|
|
4608
|
+
|
|
4609
|
+
/** @type {string[]} */
|
|
4610
|
+
const items = [];
|
|
4611
|
+
// The three running indices the proposal encodes names and definitions
|
|
4612
|
+
// against. Only the position pair restarts per source.
|
|
4613
|
+
let lastKind = 0;
|
|
4614
|
+
let lastVariable = 0;
|
|
4615
|
+
let lastDefinition = 0;
|
|
4616
|
+
let scopeCount = 0;
|
|
4617
|
+
/** @type {Map<number, number>} */
|
|
4618
|
+
const scopeIndexBySource = new Map();
|
|
4619
|
+
|
|
4620
|
+
for (let sourceIndex = 0; sourceIndex < sourceCount; sourceIndex++) {
|
|
4621
|
+
const scope = scopeBySource.get(sourceIndex);
|
|
4622
|
+
if (scope === undefined || scope.variables.length === 0) {
|
|
4623
|
+
items.push(TAG_EMPTY);
|
|
4624
|
+
continue;
|
|
4625
|
+
}
|
|
4626
|
+
const kind = nameIndex(MODULE_SCOPE_KIND);
|
|
4627
|
+
items.push(
|
|
4628
|
+
TAG_ORIGINAL_SCOPE_START +
|
|
4629
|
+
encodeUnsigned(ORIGINAL_SCOPE_FLAG_HAS_KIND) +
|
|
4630
|
+
encodeUnsigned(0) +
|
|
4631
|
+
encodeUnsigned(0) +
|
|
4632
|
+
encodeSigned(kind - lastKind),
|
|
4633
|
+
);
|
|
4634
|
+
lastKind = kind;
|
|
4635
|
+
let variables = TAG_ORIGINAL_SCOPE_VARIABLES;
|
|
4636
|
+
for (const variable of scope.variables) {
|
|
4637
|
+
const index = nameIndex(variable);
|
|
4638
|
+
variables += encodeSigned(index - lastVariable);
|
|
4639
|
+
lastVariable = index;
|
|
4640
|
+
}
|
|
4641
|
+
items.push(variables);
|
|
4642
|
+
items.push(
|
|
4643
|
+
TAG_ORIGINAL_SCOPE_END +
|
|
4644
|
+
encodeUnsigned(scope.originalEnd.line) +
|
|
4645
|
+
encodeUnsigned(scope.originalEnd.column),
|
|
4646
|
+
);
|
|
4647
|
+
scopeIndexBySource.set(sourceIndex, scopeCount++);
|
|
4648
|
+
}
|
|
4649
|
+
|
|
4650
|
+
/** @type {{ start: ScopePosition, end: ScopePosition, scope: SourceScope }[]} */
|
|
4651
|
+
const ranges = [];
|
|
4652
|
+
for (const scope of scopes) {
|
|
4653
|
+
if (!scopeIndexBySource.has(scope.sourceIndex)) continue;
|
|
4654
|
+
for (let index = 0; index < scope.rangeStarts.length; index++) {
|
|
4655
|
+
ranges.push({
|
|
4656
|
+
start: scope.rangeStarts[index],
|
|
4657
|
+
end: scope.rangeEnds[index],
|
|
4658
|
+
scope,
|
|
4659
|
+
});
|
|
4660
|
+
}
|
|
4661
|
+
}
|
|
4662
|
+
ranges.sort(
|
|
4663
|
+
(a, b) => a.start.line - b.start.line || a.start.column - b.start.column,
|
|
4664
|
+
);
|
|
4665
|
+
|
|
4666
|
+
let lastLine = 0;
|
|
4667
|
+
let lastColumn = 0;
|
|
4668
|
+
/**
|
|
4669
|
+
* Encodes a position against the running one, reporting whether it needed a
|
|
4670
|
+
* line of its own. A line is only carried when it moved forward, and then
|
|
4671
|
+
* the column is absolute rather than relative.
|
|
4672
|
+
* @param {ScopePosition} position the position to encode
|
|
4673
|
+
* @returns {[boolean, string]} whether a line is carried, and the digits
|
|
4674
|
+
*/
|
|
4675
|
+
const encodePosition = (position) => {
|
|
4676
|
+
const line = position.line - lastLine;
|
|
4677
|
+
const carriesLine = line > 0;
|
|
4678
|
+
const column = carriesLine ? position.column : position.column - lastColumn;
|
|
4679
|
+
lastLine = position.line;
|
|
4680
|
+
lastColumn = position.column;
|
|
4681
|
+
return [
|
|
4682
|
+
carriesLine,
|
|
4683
|
+
(carriesLine ? encodeUnsigned(line) : "") + encodeUnsigned(column),
|
|
4684
|
+
];
|
|
4685
|
+
};
|
|
4686
|
+
|
|
4687
|
+
for (const { start, end, scope } of ranges) {
|
|
4688
|
+
const definition =
|
|
4689
|
+
/** @type {number} */
|
|
4690
|
+
(scopeIndexBySource.get(scope.sourceIndex));
|
|
4691
|
+
const [startCarriesLine, startDigits] = encodePosition(start);
|
|
4692
|
+
items.push(
|
|
4693
|
+
TAG_GENERATED_RANGE_START +
|
|
4694
|
+
encodeUnsigned(
|
|
4695
|
+
GENERATED_RANGE_FLAG_HAS_DEFINITION |
|
|
4696
|
+
(startCarriesLine ? GENERATED_RANGE_FLAG_HAS_LINE : 0),
|
|
4697
|
+
) +
|
|
4698
|
+
startDigits +
|
|
4699
|
+
encodeSigned(definition - lastDefinition),
|
|
4700
|
+
);
|
|
4701
|
+
lastDefinition = definition;
|
|
4702
|
+
let bindings = TAG_GENERATED_RANGE_BINDINGS;
|
|
4703
|
+
for (const value of scope.values) {
|
|
4704
|
+
bindings += encodeUnsigned(value === "" ? 0 : nameIndex(value) + 1);
|
|
4705
|
+
}
|
|
4706
|
+
items.push(bindings);
|
|
4707
|
+
// An end item carries no flags: one digit is a column, two a line and a
|
|
4708
|
+
// column, which is what tells the reader whether the line moved.
|
|
4709
|
+
items.push(TAG_GENERATED_RANGE_END + encodePosition(end)[1]);
|
|
4710
|
+
}
|
|
4711
|
+
return items.join(",");
|
|
4712
|
+
};
|
|
4713
|
+
|
|
4714
|
+
/**
|
|
4715
|
+
* Adds the `scopes` field of the "Scopes" proposal to a source map, naming for
|
|
4716
|
+
* each source the bindings a debugger cannot resolve on its own and the
|
|
4717
|
+
* generated expression each one evaluates to. Does nothing when no source
|
|
4718
|
+
* contributes a binding.
|
|
4719
|
+
* @param {RawSourceMap} sourceMap the map to extend in place
|
|
4720
|
+
* @param {(sourceIndex: number) => Map<string, string> | undefined} getBindings binding expressions per source
|
|
4721
|
+
* @returns {void}
|
|
4722
|
+
*/
|
|
4723
|
+
const addScopesToSourceMap = (sourceMap, getBindings) => {
|
|
4724
|
+
if (!sourceMap.mappings || !sourceMap.sources) return;
|
|
4725
|
+
const sourceCount = sourceMap.sources.length;
|
|
4726
|
+
const scopes = collectSourceScopes(sourceMap.mappings, sourceCount);
|
|
4727
|
+
let any = false;
|
|
4728
|
+
for (const scope of scopes) {
|
|
4729
|
+
const bindings = getBindings(scope.sourceIndex);
|
|
4730
|
+
if (bindings === undefined || bindings.size === 0) continue;
|
|
4731
|
+
for (const [name, value] of bindings) {
|
|
4732
|
+
scope.variables.push(name);
|
|
4733
|
+
scope.values.push(value);
|
|
4734
|
+
}
|
|
4735
|
+
any = true;
|
|
4736
|
+
}
|
|
4737
|
+
if (!any) return;
|
|
4738
|
+
const names = sourceMap.names || (sourceMap.names = []);
|
|
4739
|
+
sourceMap.scopes = encodeScopes(scopes, sourceCount, names);
|
|
4740
|
+
};
|
|
4741
|
+
|
|
4742
|
+
/**
|
|
4743
|
+
* Builds the `scopes` field while a map is being written, so the segments are
|
|
4744
|
+
* read as they are produced rather than decoded back out of `mappings`. Lines
|
|
4745
|
+
* are the one-based ones the chunk stream reports; `finish` takes the position
|
|
4746
|
+
* the generated code ends at, where the last range closes.
|
|
4747
|
+
* @returns {{ add: (generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number) => void, addSource: (sourceIndex: number, scopeBindings?: ScopeBindings) => void, finish: (map: RawSourceMap, generatedLine: number, generatedColumn?: number) => void }} writer
|
|
4748
|
+
*/
|
|
4749
|
+
const createScopesWriter = () => {
|
|
4750
|
+
const collector = createScopeCollector();
|
|
4751
|
+
/** @type {Map<number, ScopeBindings>} */
|
|
4752
|
+
const bindingsBySource = new Map();
|
|
4753
|
+
return {
|
|
4754
|
+
add(generatedLine, generatedColumn, sourceIndex, originalLine) {
|
|
4755
|
+
collector.add(
|
|
4756
|
+
generatedLine - 1,
|
|
4757
|
+
generatedColumn,
|
|
4758
|
+
sourceIndex,
|
|
4759
|
+
originalLine - 1,
|
|
4760
|
+
);
|
|
4761
|
+
},
|
|
4762
|
+
addSource(sourceIndex, scopeBindings) {
|
|
4763
|
+
if (scopeBindings !== undefined && scopeBindings.size > 0) {
|
|
4764
|
+
bindingsBySource.set(sourceIndex, scopeBindings);
|
|
4765
|
+
}
|
|
4766
|
+
},
|
|
4767
|
+
finish(map, generatedLine, generatedColumn = 0) {
|
|
4768
|
+
if (bindingsBySource.size === 0) return;
|
|
4769
|
+
const scopes = collector.finish(generatedLine - 1, generatedColumn);
|
|
4770
|
+
let any = false;
|
|
4771
|
+
for (const scope of scopes) {
|
|
4772
|
+
const bindings = bindingsBySource.get(scope.sourceIndex);
|
|
4773
|
+
if (bindings === undefined) continue;
|
|
4774
|
+
for (const [name, value] of bindings) {
|
|
4775
|
+
scope.variables.push(name);
|
|
4776
|
+
scope.values.push(value);
|
|
4777
|
+
}
|
|
4778
|
+
any = true;
|
|
4779
|
+
}
|
|
4780
|
+
if (!any) return;
|
|
4781
|
+
const names = map.names || (map.names = []);
|
|
4782
|
+
map.scopes = encodeScopes(scopes, map.sources.length, names);
|
|
4783
|
+
},
|
|
4784
|
+
};
|
|
4785
|
+
};
|
|
4786
|
+
|
|
4787
|
+
module.exports.addScopesToSourceMap = addScopesToSourceMap;
|
|
4788
|
+
module.exports.collectSourceScopes = collectSourceScopes;
|
|
4789
|
+
module.exports.createScopeCollector = createScopeCollector;
|
|
4790
|
+
module.exports.createScopesWriter = createScopesWriter;
|
|
4791
|
+
module.exports.encodeScopes = encodeScopes;
|
|
4792
|
+
|
|
4793
|
+
|
|
4794
|
+
/***/ }),
|
|
4795
|
+
|
|
4796
|
+
/***/ 416:
|
|
3140
4797
|
/***/ ((module) => {
|
|
3141
4798
|
|
|
3142
4799
|
/*
|
|
@@ -3155,18 +4812,19 @@ const splitIntoLines = (str) => {
|
|
|
3155
4812
|
const len = str.length;
|
|
3156
4813
|
let i = 0;
|
|
3157
4814
|
while (i < len) {
|
|
3158
|
-
|
|
3159
|
-
//
|
|
3160
|
-
|
|
4815
|
+
// indexOf is implemented natively and is significantly faster than
|
|
4816
|
+
// scanning char-by-char with charCodeAt for long lines.
|
|
4817
|
+
const n = str.indexOf("\n", i);
|
|
4818
|
+
if (n === -1) {
|
|
4819
|
+
results.push(i === 0 ? str : str.slice(i));
|
|
4820
|
+
break;
|
|
4821
|
+
}
|
|
4822
|
+
if (n === i) {
|
|
3161
4823
|
results.push("\n");
|
|
3162
|
-
i++;
|
|
3163
4824
|
} else {
|
|
3164
|
-
|
|
3165
|
-
// 10 is "\n".charCodeAt(0)
|
|
3166
|
-
while (j < len && str.charCodeAt(j) !== 10) j++;
|
|
3167
|
-
results.push(str.slice(i, j + 1));
|
|
3168
|
-
i = j + 1;
|
|
4825
|
+
results.push(str.slice(i, n + 1));
|
|
3169
4826
|
}
|
|
4827
|
+
i = n + 1;
|
|
3170
4828
|
}
|
|
3171
4829
|
return results;
|
|
3172
4830
|
};
|
|
@@ -3176,7 +4834,7 @@ module.exports = splitIntoLines;
|
|
|
3176
4834
|
|
|
3177
4835
|
/***/ }),
|
|
3178
4836
|
|
|
3179
|
-
/***/
|
|
4837
|
+
/***/ 919:
|
|
3180
4838
|
/***/ ((module) => {
|
|
3181
4839
|
|
|
3182
4840
|
/*
|
|
@@ -3186,15 +4844,87 @@ module.exports = splitIntoLines;
|
|
|
3186
4844
|
|
|
3187
4845
|
|
|
3188
4846
|
|
|
3189
|
-
//
|
|
3190
|
-
//
|
|
3191
|
-
//
|
|
3192
|
-
//
|
|
3193
|
-
//
|
|
3194
|
-
// \r
|
|
3195
|
-
//
|
|
4847
|
+
// Character classification via a lookup table. A single bitmask test
|
|
4848
|
+
// replaces the multi-comparison chains in each inner loop phase.
|
|
4849
|
+
//
|
|
4850
|
+
// BIT layout per character:
|
|
4851
|
+
// bit 0 (STOP1 = 1): stops phase-1 scan (\n ; { })
|
|
4852
|
+
// bit 1 (CONT2 = 2): continues phase-2 scan (; { } space \r \t)
|
|
4853
|
+
//
|
|
4854
|
+
// Phase 1: scan regular source chars that are NOT a phase-1 stop.
|
|
4855
|
+
// Phase 2: consume runs of statement-boundary / whitespace chars.
|
|
4856
|
+
// Phase 3: consume a trailing \n if present.
|
|
4857
|
+
|
|
4858
|
+
const STOP1 = 1;
|
|
4859
|
+
const CONT2 = 2;
|
|
4860
|
+
|
|
4861
|
+
/** @type {Uint8Array} */
|
|
4862
|
+
const CF = new Uint8Array(128);
|
|
4863
|
+
CF[10] = STOP1; // \n – stops phase 1, NOT consumed in phase 2
|
|
4864
|
+
CF[59] = STOP1 | CONT2; // ;
|
|
4865
|
+
CF[123] = STOP1 | CONT2; // {
|
|
4866
|
+
CF[125] = STOP1 | CONT2; // }
|
|
4867
|
+
CF[32] = CONT2; // space
|
|
4868
|
+
CF[13] = CONT2; // \r
|
|
4869
|
+
CF[9] = CONT2; // \t
|
|
4870
|
+
|
|
4871
|
+
/**
|
|
4872
|
+
* @callback OnPotentialToken
|
|
4873
|
+
* @param {number} start start offset (inclusive)
|
|
4874
|
+
* @param {number} end end offset (exclusive)
|
|
4875
|
+
* @param {boolean} newline whether the token ends with a `\n`
|
|
4876
|
+
* @returns {void}
|
|
4877
|
+
*/
|
|
4878
|
+
|
|
4879
|
+
/**
|
|
4880
|
+
* Streaming core: report each potential token by its `[start, end)` bounds
|
|
4881
|
+
* instead of materialising substrings. The single real consumer
|
|
4882
|
+
* (`OriginalSource.streamChunks`) slices on demand — and skips slicing
|
|
4883
|
+
* entirely when emitting the final source (the `map()` / `sourceAndMap()`
|
|
4884
|
+
* paths, which discard the chunk text) — so this avoids both the
|
|
4885
|
+
* intermediate results array and every per-token `String.slice` allocation
|
|
4886
|
+
* in the dominant case.
|
|
4887
|
+
* @param {string} str string
|
|
4888
|
+
* @param {OnPotentialToken} onToken called for each token
|
|
4889
|
+
* @returns {void}
|
|
4890
|
+
*/
|
|
4891
|
+
const eachPotentialToken = (str, onToken) => {
|
|
4892
|
+
const len = str.length;
|
|
4893
|
+
let i = 0;
|
|
4894
|
+
outer: while (i < len) {
|
|
4895
|
+
const start = i;
|
|
4896
|
+
// Phase 1 – skip regular (non-stop) characters
|
|
4897
|
+
let cc = str.charCodeAt(i);
|
|
4898
|
+
while (cc > 127 || !(CF[cc] & STOP1)) {
|
|
4899
|
+
if (++i >= len) {
|
|
4900
|
+
onToken(start, i, false);
|
|
4901
|
+
break outer;
|
|
4902
|
+
}
|
|
4903
|
+
cc = str.charCodeAt(i);
|
|
4904
|
+
}
|
|
4905
|
+
// Phase 2 – consume delimiter / whitespace run (; { } space \r \t)
|
|
4906
|
+
while (cc < 128 && CF[cc] & CONT2) {
|
|
4907
|
+
if (++i >= len) {
|
|
4908
|
+
onToken(start, i, false);
|
|
4909
|
+
break outer;
|
|
4910
|
+
}
|
|
4911
|
+
cc = str.charCodeAt(i);
|
|
4912
|
+
}
|
|
4913
|
+
// Phase 3 – consume trailing newline
|
|
4914
|
+
if (cc === 10) {
|
|
4915
|
+
i++;
|
|
4916
|
+
onToken(start, i, true);
|
|
4917
|
+
} else {
|
|
4918
|
+
onToken(start, i, false);
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
};
|
|
3196
4922
|
|
|
3197
4923
|
/**
|
|
4924
|
+
* Array-returning variant. Kept as a standalone loop rather than wrapping
|
|
4925
|
+
* `eachPotentialToken` with a per-token callback: the callback indirection
|
|
4926
|
+
* measurably slows this hot scan (V8 can no longer inline the slice/push),
|
|
4927
|
+
* and the two only share the same small, well-tested classification table.
|
|
3198
4928
|
* @param {string} str string
|
|
3199
4929
|
* @returns {string[] | null} array of string separated by potential tokens
|
|
3200
4930
|
*/
|
|
@@ -3203,28 +4933,28 @@ const splitIntoPotentialTokens = (str) => {
|
|
|
3203
4933
|
if (len === 0) return null;
|
|
3204
4934
|
const results = [];
|
|
3205
4935
|
let i = 0;
|
|
3206
|
-
while (i < len) {
|
|
4936
|
+
outer: while (i < len) {
|
|
3207
4937
|
const start = i;
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
4938
|
+
// Phase 1 – skip regular (non-stop) characters
|
|
4939
|
+
let cc = str.charCodeAt(i);
|
|
4940
|
+
while (cc > 127 || !(CF[cc] & STOP1)) {
|
|
4941
|
+
if (++i >= len) {
|
|
4942
|
+
results.push(str.slice(start, i));
|
|
4943
|
+
break outer;
|
|
3213
4944
|
}
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
) {
|
|
3222
|
-
if (++i >= len) break block;
|
|
3223
|
-
cc = str.charCodeAt(i);
|
|
3224
|
-
}
|
|
3225
|
-
if (cc === 10) {
|
|
3226
|
-
i++;
|
|
4945
|
+
cc = str.charCodeAt(i);
|
|
4946
|
+
}
|
|
4947
|
+
// Phase 2 – consume delimiter / whitespace run (; { } space \r \t)
|
|
4948
|
+
while (cc < 128 && CF[cc] & CONT2) {
|
|
4949
|
+
if (++i >= len) {
|
|
4950
|
+
results.push(str.slice(start, i));
|
|
4951
|
+
break outer;
|
|
3227
4952
|
}
|
|
4953
|
+
cc = str.charCodeAt(i);
|
|
4954
|
+
}
|
|
4955
|
+
// Phase 3 – consume trailing newline
|
|
4956
|
+
if (cc === 10) {
|
|
4957
|
+
i++;
|
|
3228
4958
|
}
|
|
3229
4959
|
results.push(str.slice(start, i));
|
|
3230
4960
|
}
|
|
@@ -3232,11 +4962,12 @@ const splitIntoPotentialTokens = (str) => {
|
|
|
3232
4962
|
};
|
|
3233
4963
|
|
|
3234
4964
|
module.exports = splitIntoPotentialTokens;
|
|
4965
|
+
module.exports.eachPotentialToken = eachPotentialToken;
|
|
3235
4966
|
|
|
3236
4967
|
|
|
3237
4968
|
/***/ }),
|
|
3238
4969
|
|
|
3239
|
-
/***/
|
|
4970
|
+
/***/ 658:
|
|
3240
4971
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3241
4972
|
|
|
3242
4973
|
/*
|
|
@@ -3246,8 +4977,8 @@ module.exports = splitIntoPotentialTokens;
|
|
|
3246
4977
|
|
|
3247
4978
|
|
|
3248
4979
|
|
|
3249
|
-
const
|
|
3250
|
-
const streamChunks = __nccwpck_require__(
|
|
4980
|
+
const { createMappingsWriter } = __nccwpck_require__(818);
|
|
4981
|
+
const streamChunks = __nccwpck_require__(487);
|
|
3251
4982
|
|
|
3252
4983
|
/** @typedef {import("../Source").RawSourceMap} RawSourceMap */
|
|
3253
4984
|
/** @typedef {import("./streamChunks").GeneratedSourceInfo} GeneratedSourceInfo */
|
|
@@ -3257,6 +4988,20 @@ const streamChunks = __nccwpck_require__(779);
|
|
|
3257
4988
|
/** @typedef {import("./streamChunks").Options} Options */
|
|
3258
4989
|
/** @typedef {import("./streamChunks").SourceMaybeWithStreamChunksFunction} SourceMaybeWithStreamChunksFunction */
|
|
3259
4990
|
|
|
4991
|
+
/** @type {typeof import("./scopes") | undefined} */
|
|
4992
|
+
let scopesHelpers;
|
|
4993
|
+
|
|
4994
|
+
/**
|
|
4995
|
+
* Loads the scopes helpers on first use. They are only reachable through the
|
|
4996
|
+
* `scopes` option, so requiring them eagerly would put the encoder in the
|
|
4997
|
+
* module graph of every caller that never asks for the field.
|
|
4998
|
+
* @returns {ReturnType<typeof import("./scopes").createScopesWriter>} writer
|
|
4999
|
+
*/
|
|
5000
|
+
const createScopesWriter = () => {
|
|
5001
|
+
if (scopesHelpers === undefined) scopesHelpers = __nccwpck_require__(928);
|
|
5002
|
+
return scopesHelpers.createScopesWriter();
|
|
5003
|
+
};
|
|
5004
|
+
|
|
3260
5005
|
/**
|
|
3261
5006
|
* @param {SourceMaybeWithStreamChunksFunction} inputSource input source
|
|
3262
5007
|
* @param {Options} options options
|
|
@@ -3273,18 +5018,26 @@ const streamAndGetSourceAndMap = (
|
|
|
3273
5018
|
onName,
|
|
3274
5019
|
) => {
|
|
3275
5020
|
let code = "";
|
|
3276
|
-
let mappings = "";
|
|
3277
5021
|
/** @type {(string | null)[]} */
|
|
3278
5022
|
const potentialSources = [];
|
|
3279
5023
|
/** @type {(string | null)[]} */
|
|
3280
5024
|
const potentialSourcesContent = [];
|
|
3281
5025
|
/** @type {(string | null)[]} */
|
|
3282
5026
|
const potentialNames = [];
|
|
3283
|
-
const
|
|
5027
|
+
const mappingsWriter = createMappingsWriter({ ...options, columns: true });
|
|
5028
|
+
const addMapping = mappingsWriter.add;
|
|
5029
|
+
const scopesWriter =
|
|
5030
|
+
options && options.scopes ? createScopesWriter() : undefined;
|
|
3284
5031
|
const finalSource = Boolean(options && options.finalSource);
|
|
5032
|
+
// The caller may have passed `source: false` (getMap does), but this
|
|
5033
|
+
// helper caches the source text, so the inner stream must produce it.
|
|
5034
|
+
const innerOptions =
|
|
5035
|
+
options && options.source === false
|
|
5036
|
+
? { ...options, source: true }
|
|
5037
|
+
: options;
|
|
3285
5038
|
const { generatedLine, generatedColumn, source } = streamChunks(
|
|
3286
5039
|
inputSource,
|
|
3287
|
-
|
|
5040
|
+
innerOptions,
|
|
3288
5041
|
(
|
|
3289
5042
|
chunk,
|
|
3290
5043
|
generatedLine,
|
|
@@ -3295,7 +5048,7 @@ const streamAndGetSourceAndMap = (
|
|
|
3295
5048
|
nameIndex,
|
|
3296
5049
|
) => {
|
|
3297
5050
|
if (chunk !== undefined) code += chunk;
|
|
3298
|
-
|
|
5051
|
+
addMapping(
|
|
3299
5052
|
generatedLine,
|
|
3300
5053
|
generatedColumn,
|
|
3301
5054
|
sourceIndex,
|
|
@@ -3303,6 +5056,14 @@ const streamAndGetSourceAndMap = (
|
|
|
3303
5056
|
originalColumn,
|
|
3304
5057
|
nameIndex,
|
|
3305
5058
|
);
|
|
5059
|
+
if (scopesWriter !== undefined) {
|
|
5060
|
+
scopesWriter.add(
|
|
5061
|
+
generatedLine,
|
|
5062
|
+
generatedColumn,
|
|
5063
|
+
sourceIndex,
|
|
5064
|
+
originalLine,
|
|
5065
|
+
);
|
|
5066
|
+
}
|
|
3306
5067
|
return onChunk(
|
|
3307
5068
|
finalSource ? undefined : chunk,
|
|
3308
5069
|
generatedLine,
|
|
@@ -3313,7 +5074,7 @@ const streamAndGetSourceAndMap = (
|
|
|
3313
5074
|
nameIndex,
|
|
3314
5075
|
);
|
|
3315
5076
|
},
|
|
3316
|
-
(sourceIndex, source, sourceContent) => {
|
|
5077
|
+
(sourceIndex, source, sourceContent, scopeBindings) => {
|
|
3317
5078
|
while (potentialSources.length < sourceIndex) {
|
|
3318
5079
|
potentialSources.push(null);
|
|
3319
5080
|
}
|
|
@@ -3324,7 +5085,10 @@ const streamAndGetSourceAndMap = (
|
|
|
3324
5085
|
}
|
|
3325
5086
|
potentialSourcesContent[sourceIndex] = sourceContent;
|
|
3326
5087
|
}
|
|
3327
|
-
|
|
5088
|
+
if (scopesWriter !== undefined) {
|
|
5089
|
+
scopesWriter.addSource(sourceIndex, scopeBindings);
|
|
5090
|
+
}
|
|
5091
|
+
return onSource(sourceIndex, source, sourceContent, scopeBindings);
|
|
3328
5092
|
},
|
|
3329
5093
|
(nameIndex, name) => {
|
|
3330
5094
|
while (potentialNames.length < nameIndex) {
|
|
@@ -3335,6 +5099,26 @@ const streamAndGetSourceAndMap = (
|
|
|
3335
5099
|
},
|
|
3336
5100
|
);
|
|
3337
5101
|
const resultSource = source !== undefined ? source : code;
|
|
5102
|
+
const mappings = mappingsWriter.finish();
|
|
5103
|
+
/** @type {RawSourceMap | null} */
|
|
5104
|
+
let map = null;
|
|
5105
|
+
if (mappings.length > 0) {
|
|
5106
|
+
map = {
|
|
5107
|
+
version: 3,
|
|
5108
|
+
file: "x",
|
|
5109
|
+
mappings,
|
|
5110
|
+
// We handle broken sources as `null`, in spec this field should be string, but no information what we should do in such cases if we change type it will be breaking change
|
|
5111
|
+
sources: /** @type {string[]} */ (potentialSources),
|
|
5112
|
+
sourcesContent:
|
|
5113
|
+
potentialSourcesContent.length > 0
|
|
5114
|
+
? /** @type {string[]} */ (potentialSourcesContent)
|
|
5115
|
+
: undefined,
|
|
5116
|
+
names: /** @type {string[]} */ (potentialNames),
|
|
5117
|
+
};
|
|
5118
|
+
if (scopesWriter !== undefined) {
|
|
5119
|
+
scopesWriter.finish(map, generatedLine || 0, generatedColumn || 0);
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
3338
5122
|
|
|
3339
5123
|
return {
|
|
3340
5124
|
result: {
|
|
@@ -3343,21 +5127,7 @@ const streamAndGetSourceAndMap = (
|
|
|
3343
5127
|
source: finalSource ? resultSource : undefined,
|
|
3344
5128
|
},
|
|
3345
5129
|
source: resultSource,
|
|
3346
|
-
map
|
|
3347
|
-
mappings.length > 0
|
|
3348
|
-
? {
|
|
3349
|
-
version: 3,
|
|
3350
|
-
file: "x",
|
|
3351
|
-
mappings,
|
|
3352
|
-
// We handle broken sources as `null`, in spec this field should be string, but no information what we should do in such cases if we change type it will be breaking change
|
|
3353
|
-
sources: /** @type {string[]} */ (potentialSources),
|
|
3354
|
-
sourcesContent:
|
|
3355
|
-
potentialSourcesContent.length > 0
|
|
3356
|
-
? /** @type {string[]} */ (potentialSourcesContent)
|
|
3357
|
-
: undefined,
|
|
3358
|
-
names: /** @type {string[]} */ (potentialNames),
|
|
3359
|
-
}
|
|
3360
|
-
: null,
|
|
5130
|
+
map,
|
|
3361
5131
|
};
|
|
3362
5132
|
};
|
|
3363
5133
|
|
|
@@ -3366,7 +5136,7 @@ module.exports = streamAndGetSourceAndMap;
|
|
|
3366
5136
|
|
|
3367
5137
|
/***/ }),
|
|
3368
5138
|
|
|
3369
|
-
/***/
|
|
5139
|
+
/***/ 487:
|
|
3370
5140
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3371
5141
|
|
|
3372
5142
|
/*
|
|
@@ -3376,16 +5146,17 @@ module.exports = streamAndGetSourceAndMap;
|
|
|
3376
5146
|
|
|
3377
5147
|
|
|
3378
5148
|
|
|
3379
|
-
const streamChunksOfRawSource = __nccwpck_require__(
|
|
3380
|
-
const streamChunksOfSourceMap = __nccwpck_require__(
|
|
5149
|
+
const streamChunksOfRawSource = __nccwpck_require__(543);
|
|
5150
|
+
const streamChunksOfSourceMap = __nccwpck_require__(637);
|
|
3381
5151
|
|
|
3382
5152
|
/** @typedef {import("../Source")} Source */
|
|
3383
5153
|
/** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
|
|
3384
5154
|
/** @typedef {(chunk: string | undefined, generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number, originalColumn: number, nameIndex: number) => void} OnChunk */
|
|
3385
|
-
/** @typedef {
|
|
5155
|
+
/** @typedef {Map<string, string>} ScopeBindings */
|
|
5156
|
+
/** @typedef {(sourceIndex: number, source: string | null, sourceContent: string | undefined, scopeBindings?: ScopeBindings) => void} OnSource */
|
|
3386
5157
|
/** @typedef {(nameIndex: number, name: string) => void} OnName */
|
|
3387
5158
|
|
|
3388
|
-
/** @typedef {{ source?: boolean, finalSource?: boolean, columns?: boolean }} Options */
|
|
5159
|
+
/** @typedef {{ source?: boolean, finalSource?: boolean, columns?: boolean, scopes?: boolean }} Options */
|
|
3389
5160
|
|
|
3390
5161
|
/**
|
|
3391
5162
|
* @callback StreamChunksFunction
|
|
@@ -3435,7 +5206,7 @@ module.exports = (source, options, onChunk, onSource, onName) => {
|
|
|
3435
5206
|
|
|
3436
5207
|
/***/ }),
|
|
3437
5208
|
|
|
3438
|
-
/***/
|
|
5209
|
+
/***/ 808:
|
|
3439
5210
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3440
5211
|
|
|
3441
5212
|
/*
|
|
@@ -3445,8 +5216,8 @@ module.exports = (source, options, onChunk, onSource, onName) => {
|
|
|
3445
5216
|
|
|
3446
5217
|
|
|
3447
5218
|
|
|
3448
|
-
const splitIntoLines = __nccwpck_require__(
|
|
3449
|
-
const streamChunksOfSourceMap = __nccwpck_require__(
|
|
5219
|
+
const splitIntoLines = __nccwpck_require__(416);
|
|
5220
|
+
const streamChunksOfSourceMap = __nccwpck_require__(637);
|
|
3450
5221
|
|
|
3451
5222
|
/** @typedef {import("../Source").RawSourceMap} RawSourceMap */
|
|
3452
5223
|
/** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
|
|
@@ -3516,7 +5287,11 @@ const streamChunksOfCombinedSourceMap = (
|
|
|
3516
5287
|
if (line > innerSourceMapLineData.length) return -1;
|
|
3517
5288
|
const { mappingsData } = innerSourceMapLineData[line - 1];
|
|
3518
5289
|
let l = 0;
|
|
3519
|
-
|
|
5290
|
+
// `mappingsData.length` is always a multiple of 5 (five values pushed
|
|
5291
|
+
// per mapping), so dividing is exact. Coerce the bound to an int32 so
|
|
5292
|
+
// the binary-search loop stays on V8's fast small-int path instead of
|
|
5293
|
+
// comparing an int against a float.
|
|
5294
|
+
let r = (mappingsData.length / 5) | 0;
|
|
3520
5295
|
while (l < r) {
|
|
3521
5296
|
const m = (l + r) >> 1;
|
|
3522
5297
|
if (mappingsData[m * 5] <= column) {
|
|
@@ -3737,7 +5512,7 @@ const streamChunksOfCombinedSourceMap = (
|
|
|
3737
5512
|
);
|
|
3738
5513
|
}
|
|
3739
5514
|
},
|
|
3740
|
-
(i, source, sourceContent) => {
|
|
5515
|
+
(i, source, sourceContent, scopeBindings) => {
|
|
3741
5516
|
if (source === innerSourceName) {
|
|
3742
5517
|
outerSourceIndex = i;
|
|
3743
5518
|
if (innerSource !== undefined) sourceContent = innerSource;
|
|
@@ -3789,7 +5564,7 @@ const streamChunksOfCombinedSourceMap = (
|
|
|
3789
5564
|
let globalIndex = sourceMapping.get(source);
|
|
3790
5565
|
if (globalIndex === undefined) {
|
|
3791
5566
|
sourceMapping.set(source, (globalIndex = sourceMapping.size));
|
|
3792
|
-
onSource(globalIndex, source, sourceContent);
|
|
5567
|
+
onSource(globalIndex, source, sourceContent, scopeBindings);
|
|
3793
5568
|
}
|
|
3794
5569
|
sourceIndexMapping[i] = globalIndex;
|
|
3795
5570
|
}
|
|
@@ -3808,7 +5583,7 @@ module.exports = streamChunksOfCombinedSourceMap;
|
|
|
3808
5583
|
|
|
3809
5584
|
/***/ }),
|
|
3810
5585
|
|
|
3811
|
-
/***/
|
|
5586
|
+
/***/ 543:
|
|
3812
5587
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3813
5588
|
|
|
3814
5589
|
/*
|
|
@@ -3818,8 +5593,7 @@ module.exports = streamChunksOfCombinedSourceMap;
|
|
|
3818
5593
|
|
|
3819
5594
|
|
|
3820
5595
|
|
|
3821
|
-
const getGeneratedSourceInfo = __nccwpck_require__(
|
|
3822
|
-
const splitIntoLines = __nccwpck_require__(492);
|
|
5596
|
+
const getGeneratedSourceInfo = __nccwpck_require__(769);
|
|
3823
5597
|
|
|
3824
5598
|
/** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
|
|
3825
5599
|
/** @typedef {import("./streamChunks").OnChunk} OnChunk */
|
|
@@ -3832,25 +5606,34 @@ const splitIntoLines = __nccwpck_require__(492);
|
|
|
3832
5606
|
* @param {OnSource} _onSource on source
|
|
3833
5607
|
* @param {OnName} _onName on name
|
|
3834
5608
|
* @returns {GeneratedSourceInfo} source info
|
|
5609
|
+
*
|
|
5610
|
+
* Single-pass equivalent of `splitIntoLines(source).forEach(emit)` — emits
|
|
5611
|
+
* each line via onChunk while scanning for newlines, so we never allocate
|
|
5612
|
+
* the intermediate array of lines.
|
|
3835
5613
|
*/
|
|
3836
5614
|
const streamChunksOfRawSource = (source, onChunk, _onSource, _onName) => {
|
|
5615
|
+
const len = source.length;
|
|
5616
|
+
if (len === 0) {
|
|
5617
|
+
return { generatedLine: 1, generatedColumn: 0 };
|
|
5618
|
+
}
|
|
3837
5619
|
let line = 1;
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
5620
|
+
let i = 0;
|
|
5621
|
+
while (i < len) {
|
|
5622
|
+
const n = source.indexOf("\n", i);
|
|
5623
|
+
if (n === -1) {
|
|
5624
|
+
// Trailing partial line (no \n). Emit and return its length as the
|
|
5625
|
+
// final column.
|
|
5626
|
+
const lastLine = i === 0 ? source : source.slice(i);
|
|
5627
|
+
onChunk(lastLine, line, 0, -1, -1, -1, -1);
|
|
5628
|
+
return { generatedLine: line, generatedColumn: lastLine.length };
|
|
5629
|
+
}
|
|
5630
|
+
const chunk = n === i ? "\n" : source.slice(i, n + 1);
|
|
5631
|
+
onChunk(chunk, line, 0, -1, -1, -1, -1);
|
|
3843
5632
|
line++;
|
|
5633
|
+
i = n + 1;
|
|
3844
5634
|
}
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
generatedLine: matches.length + 1,
|
|
3848
|
-
generatedColumn: 0,
|
|
3849
|
-
}
|
|
3850
|
-
: {
|
|
3851
|
-
generatedLine: matches.length,
|
|
3852
|
-
generatedColumn: /** @type {string} */ (match).length,
|
|
3853
|
-
};
|
|
5635
|
+
// Source ended with a newline — the next "logical" line is empty.
|
|
5636
|
+
return { generatedLine: line, generatedColumn: 0 };
|
|
3854
5637
|
};
|
|
3855
5638
|
|
|
3856
5639
|
/**
|
|
@@ -3869,7 +5652,7 @@ module.exports = (source, onChunk, onSource, onName, finalSource) =>
|
|
|
3869
5652
|
|
|
3870
5653
|
/***/ }),
|
|
3871
5654
|
|
|
3872
|
-
/***/
|
|
5655
|
+
/***/ 637:
|
|
3873
5656
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
3874
5657
|
|
|
3875
5658
|
/*
|
|
@@ -3879,10 +5662,10 @@ module.exports = (source, onChunk, onSource, onName, finalSource) =>
|
|
|
3879
5662
|
|
|
3880
5663
|
|
|
3881
5664
|
|
|
3882
|
-
const getGeneratedSourceInfo = __nccwpck_require__(
|
|
3883
|
-
const getSource = __nccwpck_require__(
|
|
3884
|
-
const readMappings = __nccwpck_require__(
|
|
3885
|
-
const splitIntoLines = __nccwpck_require__(
|
|
5665
|
+
const getGeneratedSourceInfo = __nccwpck_require__(769);
|
|
5666
|
+
const getSource = __nccwpck_require__(292);
|
|
5667
|
+
const readMappings = __nccwpck_require__(674);
|
|
5668
|
+
const splitIntoLines = __nccwpck_require__(416);
|
|
3886
5669
|
|
|
3887
5670
|
/** @typedef {import("../Source").RawSourceMap} RawSourceMap */
|
|
3888
5671
|
/** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
|
|
@@ -3906,7 +5689,8 @@ const streamChunksOfSourceMapFull = (
|
|
|
3906
5689
|
onName,
|
|
3907
5690
|
) => {
|
|
3908
5691
|
const lines = splitIntoLines(source);
|
|
3909
|
-
|
|
5692
|
+
const linesLength = lines.length;
|
|
5693
|
+
if (linesLength === 0) {
|
|
3910
5694
|
return {
|
|
3911
5695
|
generatedLine: 1,
|
|
3912
5696
|
generatedColumn: 0,
|
|
@@ -3926,9 +5710,9 @@ const streamChunksOfSourceMapFull = (
|
|
|
3926
5710
|
}
|
|
3927
5711
|
}
|
|
3928
5712
|
|
|
3929
|
-
const lastLine = lines[
|
|
5713
|
+
const lastLine = lines[linesLength - 1];
|
|
3930
5714
|
const lastNewLine = lastLine.endsWith("\n");
|
|
3931
|
-
const finalLine = lastNewLine ?
|
|
5715
|
+
const finalLine = lastNewLine ? linesLength + 1 : linesLength;
|
|
3932
5716
|
const finalColumn = lastNewLine ? 0 : lastLine.length;
|
|
3933
5717
|
|
|
3934
5718
|
let currentGeneratedLine = 1;
|
|
@@ -3957,7 +5741,7 @@ const streamChunksOfSourceMapFull = (
|
|
|
3957
5741
|
originalColumn,
|
|
3958
5742
|
nameIndex,
|
|
3959
5743
|
) => {
|
|
3960
|
-
if (mappingActive && currentGeneratedLine <=
|
|
5744
|
+
if (mappingActive && currentGeneratedLine <= linesLength) {
|
|
3961
5745
|
let chunk;
|
|
3962
5746
|
const mappingLine = currentGeneratedLine;
|
|
3963
5747
|
const mappingColumn = currentGeneratedColumn;
|
|
@@ -3984,7 +5768,7 @@ const streamChunksOfSourceMapFull = (
|
|
|
3984
5768
|
mappingActive = false;
|
|
3985
5769
|
}
|
|
3986
5770
|
if (generatedLine > currentGeneratedLine && currentGeneratedColumn > 0) {
|
|
3987
|
-
if (currentGeneratedLine <=
|
|
5771
|
+
if (currentGeneratedLine <= linesLength) {
|
|
3988
5772
|
const chunk = lines[currentGeneratedLine - 1].slice(
|
|
3989
5773
|
currentGeneratedColumn,
|
|
3990
5774
|
);
|
|
@@ -4001,22 +5785,29 @@ const streamChunksOfSourceMapFull = (
|
|
|
4001
5785
|
currentGeneratedLine++;
|
|
4002
5786
|
currentGeneratedColumn = 0;
|
|
4003
5787
|
}
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
5788
|
+
// Emit each fully-passed generated line. Once we move past the last
|
|
5789
|
+
// available line we stop emitting, but still need to advance the
|
|
5790
|
+
// counter to `generatedLine` so subsequent state matches the caller.
|
|
5791
|
+
while (
|
|
5792
|
+
generatedLine > currentGeneratedLine &&
|
|
5793
|
+
currentGeneratedLine <= linesLength
|
|
5794
|
+
) {
|
|
5795
|
+
onChunk(
|
|
5796
|
+
lines[currentGeneratedLine - 1],
|
|
5797
|
+
currentGeneratedLine,
|
|
5798
|
+
0,
|
|
5799
|
+
-1,
|
|
5800
|
+
-1,
|
|
5801
|
+
-1,
|
|
5802
|
+
-1,
|
|
5803
|
+
);
|
|
4016
5804
|
currentGeneratedLine++;
|
|
4017
5805
|
}
|
|
5806
|
+
if (currentGeneratedLine < generatedLine) {
|
|
5807
|
+
currentGeneratedLine = generatedLine;
|
|
5808
|
+
}
|
|
4018
5809
|
if (generatedColumn > currentGeneratedColumn) {
|
|
4019
|
-
if (currentGeneratedLine <=
|
|
5810
|
+
if (currentGeneratedLine <= linesLength) {
|
|
4020
5811
|
const chunk = lines[currentGeneratedLine - 1].slice(
|
|
4021
5812
|
currentGeneratedColumn,
|
|
4022
5813
|
generatedColumn,
|
|
@@ -4069,7 +5860,8 @@ const streamChunksOfSourceMapLinesFull = (
|
|
|
4069
5860
|
_onName,
|
|
4070
5861
|
) => {
|
|
4071
5862
|
const lines = splitIntoLines(source);
|
|
4072
|
-
|
|
5863
|
+
const linesLength = lines.length;
|
|
5864
|
+
if (linesLength === 0) {
|
|
4073
5865
|
return {
|
|
4074
5866
|
generatedLine: 1,
|
|
4075
5867
|
generatedColumn: 0,
|
|
@@ -4106,39 +5898,38 @@ const streamChunksOfSourceMapLinesFull = (
|
|
|
4106
5898
|
if (
|
|
4107
5899
|
sourceIndex < 0 ||
|
|
4108
5900
|
generatedLine < currentGeneratedLine ||
|
|
4109
|
-
generatedLine >
|
|
5901
|
+
generatedLine > linesLength
|
|
4110
5902
|
) {
|
|
4111
5903
|
return;
|
|
4112
5904
|
}
|
|
5905
|
+
// `generatedLine <= linesLength` is guaranteed by the guard above, so
|
|
5906
|
+
// every line we iterate over is in bounds — no per-iteration length
|
|
5907
|
+
// check needed.
|
|
4113
5908
|
while (generatedLine > currentGeneratedLine) {
|
|
4114
|
-
if (currentGeneratedLine <= lines.length) {
|
|
4115
|
-
onChunk(
|
|
4116
|
-
lines[currentGeneratedLine - 1],
|
|
4117
|
-
currentGeneratedLine,
|
|
4118
|
-
0,
|
|
4119
|
-
-1,
|
|
4120
|
-
-1,
|
|
4121
|
-
-1,
|
|
4122
|
-
-1,
|
|
4123
|
-
);
|
|
4124
|
-
}
|
|
4125
|
-
currentGeneratedLine++;
|
|
4126
|
-
}
|
|
4127
|
-
if (generatedLine <= lines.length) {
|
|
4128
5909
|
onChunk(
|
|
4129
|
-
lines[
|
|
4130
|
-
|
|
5910
|
+
lines[currentGeneratedLine - 1],
|
|
5911
|
+
currentGeneratedLine,
|
|
4131
5912
|
0,
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
5913
|
+
-1,
|
|
5914
|
+
-1,
|
|
5915
|
+
-1,
|
|
4135
5916
|
-1,
|
|
4136
5917
|
);
|
|
4137
5918
|
currentGeneratedLine++;
|
|
4138
5919
|
}
|
|
5920
|
+
onChunk(
|
|
5921
|
+
lines[generatedLine - 1],
|
|
5922
|
+
generatedLine,
|
|
5923
|
+
0,
|
|
5924
|
+
sourceIndex,
|
|
5925
|
+
originalLine,
|
|
5926
|
+
originalColumn,
|
|
5927
|
+
-1,
|
|
5928
|
+
);
|
|
5929
|
+
currentGeneratedLine++;
|
|
4139
5930
|
};
|
|
4140
5931
|
readMappings(mappings, onMapping);
|
|
4141
|
-
for (; currentGeneratedLine <=
|
|
5932
|
+
for (; currentGeneratedLine <= linesLength; currentGeneratedLine++) {
|
|
4142
5933
|
onChunk(
|
|
4143
5934
|
lines[currentGeneratedLine - 1],
|
|
4144
5935
|
currentGeneratedLine,
|
|
@@ -4150,10 +5941,10 @@ const streamChunksOfSourceMapLinesFull = (
|
|
|
4150
5941
|
);
|
|
4151
5942
|
}
|
|
4152
5943
|
|
|
4153
|
-
const lastLine = lines[
|
|
5944
|
+
const lastLine = lines[linesLength - 1];
|
|
4154
5945
|
const lastNewLine = lastLine.endsWith("\n");
|
|
4155
5946
|
|
|
4156
|
-
const finalLine = lastNewLine ?
|
|
5947
|
+
const finalLine = lastNewLine ? linesLength + 1 : linesLength;
|
|
4157
5948
|
const finalColumn = lastNewLine ? 0 : lastLine.length;
|
|
4158
5949
|
|
|
4159
5950
|
return {
|
|
@@ -4375,7 +6166,7 @@ module.exports = (
|
|
|
4375
6166
|
|
|
4376
6167
|
/***/ }),
|
|
4377
6168
|
|
|
4378
|
-
/***/
|
|
6169
|
+
/***/ 345:
|
|
4379
6170
|
/***/ ((module) => {
|
|
4380
6171
|
|
|
4381
6172
|
/*
|
|
@@ -4490,16 +6281,16 @@ function internString(str) {
|
|
|
4490
6281
|
module.exports = {
|
|
4491
6282
|
disableDualStringBufferCaching,
|
|
4492
6283
|
enableDualStringBufferCaching,
|
|
4493
|
-
internString,
|
|
4494
|
-
isDualStringBufferCachingEnabled,
|
|
4495
6284
|
enterStringInterningRange,
|
|
4496
6285
|
exitStringInterningRange,
|
|
6286
|
+
internString,
|
|
6287
|
+
isDualStringBufferCachingEnabled,
|
|
4497
6288
|
};
|
|
4498
6289
|
|
|
4499
6290
|
|
|
4500
6291
|
/***/ }),
|
|
4501
6292
|
|
|
4502
|
-
/***/
|
|
6293
|
+
/***/ 751:
|
|
4503
6294
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
4504
6295
|
|
|
4505
6296
|
/*
|
|
@@ -4586,38 +6377,41 @@ module.exports = mergeExports(
|
|
|
4586
6377
|
{},
|
|
4587
6378
|
{
|
|
4588
6379
|
get Source() {
|
|
4589
|
-
return __nccwpck_require__(
|
|
6380
|
+
return __nccwpck_require__(290);
|
|
4590
6381
|
},
|
|
4591
6382
|
get RawSource() {
|
|
4592
|
-
return __nccwpck_require__(
|
|
6383
|
+
return __nccwpck_require__(132);
|
|
4593
6384
|
},
|
|
4594
6385
|
get OriginalSource() {
|
|
4595
|
-
return __nccwpck_require__(
|
|
6386
|
+
return __nccwpck_require__(169);
|
|
4596
6387
|
},
|
|
4597
6388
|
get SourceMapSource() {
|
|
4598
|
-
return __nccwpck_require__(
|
|
6389
|
+
return __nccwpck_require__(471);
|
|
4599
6390
|
},
|
|
4600
6391
|
get CachedSource() {
|
|
4601
|
-
return __nccwpck_require__(
|
|
6392
|
+
return __nccwpck_require__(384);
|
|
4602
6393
|
},
|
|
4603
6394
|
get ConcatSource() {
|
|
4604
|
-
return __nccwpck_require__(
|
|
6395
|
+
return __nccwpck_require__(698);
|
|
4605
6396
|
},
|
|
4606
6397
|
get ReplaceSource() {
|
|
4607
|
-
return __nccwpck_require__(
|
|
6398
|
+
return __nccwpck_require__(522);
|
|
4608
6399
|
},
|
|
4609
6400
|
get PrefixSource() {
|
|
4610
|
-
return __nccwpck_require__(
|
|
6401
|
+
return __nccwpck_require__(814);
|
|
4611
6402
|
},
|
|
4612
6403
|
get SizeOnlySource() {
|
|
4613
|
-
return __nccwpck_require__(
|
|
6404
|
+
return __nccwpck_require__(317);
|
|
4614
6405
|
},
|
|
4615
6406
|
get CompatSource() {
|
|
4616
|
-
return __nccwpck_require__(
|
|
6407
|
+
return __nccwpck_require__(912);
|
|
4617
6408
|
},
|
|
4618
6409
|
util: {
|
|
6410
|
+
get scopes() {
|
|
6411
|
+
return __nccwpck_require__(928);
|
|
6412
|
+
},
|
|
4619
6413
|
get stringBufferUtils() {
|
|
4620
|
-
return __nccwpck_require__(
|
|
6414
|
+
return __nccwpck_require__(345);
|
|
4621
6415
|
},
|
|
4622
6416
|
},
|
|
4623
6417
|
},
|
|
@@ -4668,7 +6462,7 @@ module.exports = mergeExports(
|
|
|
4668
6462
|
/******/ // startup
|
|
4669
6463
|
/******/ // Load entry module and return exports
|
|
4670
6464
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
4671
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(
|
|
6465
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(751);
|
|
4672
6466
|
/******/ module.exports = __webpack_exports__;
|
|
4673
6467
|
/******/
|
|
4674
6468
|
/******/ })()
|