@powerlines/plugin-rspack 0.5.231 → 0.5.233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +0 -2
  2. package/dist/helpers/unplugin.cjs +2 -2
  3. package/dist/helpers/unplugin.mjs +1 -1
  4. package/dist/index.d.cts +3 -2
  5. package/dist/index.d.mts +1 -1
  6. package/dist/types/plugin.d.cts +3 -3
  7. package/dist/types/plugin.d.mts +3 -3
  8. package/package.json +3 -3
  9. package/dist/_virtual/rolldown_runtime.mjs +0 -32
  10. package/dist/node_modules/.pnpm/@jridgewell_gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.cjs +0 -2
  11. package/dist/node_modules/.pnpm/@jridgewell_gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs +0 -4
  12. package/dist/node_modules/.pnpm/@jridgewell_remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.cjs +0 -2
  13. package/dist/node_modules/.pnpm/@jridgewell_remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.mjs +0 -4
  14. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +0 -15
  15. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -15
  16. package/dist/node_modules/.pnpm/@jridgewell_trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.cjs +0 -1
  17. package/dist/node_modules/.pnpm/@jridgewell_trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs +0 -3
  18. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.cjs +0 -28
  19. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.mjs +0 -23
  20. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.cjs +0 -175
  21. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.mjs +0 -170
  22. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.cjs +0 -871
  23. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.mjs +0 -866
  24. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.cjs +0 -307
  25. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.mjs +0 -302
  26. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.cjs +0 -300
  27. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.mjs +0 -295
  28. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.cjs +0 -60
  29. package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.mjs +0 -55
  30. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.cjs +0 -46
  31. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.mjs +0 -44
  32. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.cjs +0 -142
  33. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.mjs +0 -140
  34. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.cjs +0 -114
  35. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.mjs +0 -112
  36. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.cjs +0 -59
  37. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.mjs +0 -54
  38. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.cjs +0 -35
  39. package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.mjs +0 -33
  40. package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.cjs +0 -236
  41. package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.mjs +0 -231
  42. package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.cjs +0 -54
  43. package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.mjs +0 -49
  44. package/dist/packages/powerlines/src/internal/helpers/hooks.d.mts +0 -49
  45. package/dist/packages/powerlines/src/types/api.d.mts +0 -104
  46. package/dist/packages/powerlines/src/types/build.d.mts +0 -185
  47. package/dist/packages/powerlines/src/types/commands.d.mts +0 -9
  48. package/dist/packages/powerlines/src/types/config.d.mts +0 -424
  49. package/dist/packages/powerlines/src/types/context.d.mts +0 -514
  50. package/dist/packages/powerlines/src/types/fs.d.mts +0 -486
  51. package/dist/packages/powerlines/src/types/hooks.d.mts +0 -32
  52. package/dist/packages/powerlines/src/types/plugin.d.mts +0 -205
  53. package/dist/packages/powerlines/src/types/resolved.d.mts +0 -93
  54. package/dist/packages/powerlines/src/types/tsconfig.d.mts +0 -69
  55. package/dist/packages/powerlines/src/types/unplugin.d.mts +0 -23
  56. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -47
  57. package/dist/powerlines/src/types/api.d.cts +0 -104
  58. package/dist/powerlines/src/types/build.d.cts +0 -185
  59. package/dist/powerlines/src/types/commands.d.cts +0 -8
  60. package/dist/powerlines/src/types/config.d.cts +0 -424
  61. package/dist/powerlines/src/types/context.d.cts +0 -514
  62. package/dist/powerlines/src/types/fs.d.cts +0 -486
  63. package/dist/powerlines/src/types/hooks.d.cts +0 -32
  64. package/dist/powerlines/src/types/plugin.d.cts +0 -205
  65. package/dist/powerlines/src/types/resolved.d.cts +0 -93
  66. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  67. package/dist/powerlines/src/types/unplugin.d.cts +0 -22
@@ -1,54 +0,0 @@
1
- import { basename, dirname, resolve } from "node:path";
2
- import fs from "node:fs";
3
-
4
- //#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.mjs
5
- function encodeVirtualModuleId(id, plugin) {
6
- return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
7
- }
8
- function decodeVirtualModuleId(encoded, _plugin) {
9
- return decodeURIComponent(basename(encoded));
10
- }
11
- function isVirtualModuleId(encoded, plugin) {
12
- return dirname(encoded) === plugin.__virtualModulePrefix;
13
- }
14
- var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin$1 {
15
- name = "FakeVirtualModulesPlugin";
16
- static counters = /* @__PURE__ */ new Map();
17
- static initCleanup = false;
18
- constructor(plugin) {
19
- this.plugin = plugin;
20
- if (!FakeVirtualModulesPlugin$1.initCleanup) {
21
- FakeVirtualModulesPlugin$1.initCleanup = true;
22
- process.once("exit", () => {
23
- FakeVirtualModulesPlugin$1.counters.forEach((_, dir) => {
24
- fs.rmSync(dir, {
25
- recursive: true,
26
- force: true
27
- });
28
- });
29
- });
30
- }
31
- }
32
- apply(compiler) {
33
- const dir = this.plugin.__virtualModulePrefix;
34
- if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
35
- const counter = FakeVirtualModulesPlugin$1.counters.get(dir) ?? 0;
36
- FakeVirtualModulesPlugin$1.counters.set(dir, counter + 1);
37
- compiler.hooks.shutdown.tap(this.name, () => {
38
- const counter$1 = (FakeVirtualModulesPlugin$1.counters.get(dir) ?? 1) - 1;
39
- if (counter$1 === 0) {
40
- FakeVirtualModulesPlugin$1.counters.delete(dir);
41
- fs.rmSync(dir, {
42
- recursive: true,
43
- force: true
44
- });
45
- } else FakeVirtualModulesPlugin$1.counters.set(dir, counter$1);
46
- });
47
- }
48
- async writeModule(file) {
49
- return fs.promises.writeFile(file, "");
50
- }
51
- };
52
-
53
- //#endregion
54
- export { FakeVirtualModulesPlugin, decodeVirtualModuleId, encodeVirtualModuleId, isVirtualModuleId };
@@ -1,35 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
2
- const require_parse_CRORloGP = require('./parse-CRORloGP.cjs');
3
- let node_path = require("node:path");
4
-
5
- //#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.mjs
6
- function transformUse(data, plugin, transformLoader) {
7
- if (data.resource == null) return [];
8
- const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
9
- if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
10
- const { filter } = require_parse_CRORloGP.normalizeObjectHook("load", plugin.transform);
11
- if (!filter(id)) return [];
12
- return [{
13
- loader: transformLoader,
14
- options: { plugin },
15
- ident: plugin.name
16
- }];
17
- }
18
- /**
19
- * Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
20
- * the input path to the native os format. This is useful in cases where we want to normalize
21
- * the `id` argument of a hook. Any absolute ids should be in the default format
22
- * of the operating system. Any relative imports or node_module imports should remain
23
- * untouched.
24
- *
25
- * @param path - Path to normalize.
26
- * @returns a new normalized path.
27
- */
28
- function normalizeAbsolutePath(path$1) {
29
- if ((0, node_path.isAbsolute)(path$1)) return (0, node_path.normalize)(path$1);
30
- else return path$1;
31
- }
32
-
33
- //#endregion
34
- exports.normalizeAbsolutePath = normalizeAbsolutePath;
35
- exports.transformUse = transformUse;
@@ -1,33 +0,0 @@
1
- import { normalizeObjectHook } from "./parse-CRORloGP.mjs";
2
- import { isAbsolute, normalize } from "node:path";
3
-
4
- //#region ../../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.mjs
5
- function transformUse(data, plugin, transformLoader) {
6
- if (data.resource == null) return [];
7
- const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
8
- if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
9
- const { filter } = normalizeObjectHook("load", plugin.transform);
10
- if (!filter(id)) return [];
11
- return [{
12
- loader: transformLoader,
13
- options: { plugin },
14
- ident: plugin.name
15
- }];
16
- }
17
- /**
18
- * Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
19
- * the input path to the native os format. This is useful in cases where we want to normalize
20
- * the `id` argument of a hook. Any absolute ids should be in the default format
21
- * of the operating system. Any relative imports or node_module imports should remain
22
- * untouched.
23
- *
24
- * @param path - Path to normalize.
25
- * @returns a new normalized path.
26
- */
27
- function normalizeAbsolutePath(path$1) {
28
- if (isAbsolute(path$1)) return normalize(path$1);
29
- else return path$1;
30
- }
31
-
32
- //#endregion
33
- export { normalizeAbsolutePath, transformUse };
@@ -1,236 +0,0 @@
1
- "use strict";
2
-
3
- const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
4
- const require_virtual_stats$1 = require('./virtual-stats.cjs');
5
-
6
- //#region ../../node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js
7
- var require_lib = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((exports, module) => {
8
- const path_1 = (exports && exports.__importDefault || function(mod) {
9
- return mod && mod.__esModule ? mod : { "default": mod };
10
- })(require("node:path"));
11
- const virtual_stats_1 = require_virtual_stats$1.default;
12
- let inode = 45e6;
13
- const ALL = "all";
14
- const STATIC = "static";
15
- const DYNAMIC = "dynamic";
16
- function checkActivation(instance) {
17
- if (!instance._compiler) throw new Error("You must use this plugin only after creating webpack instance!");
18
- }
19
- function getModulePath(filePath, compiler) {
20
- return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(compiler.context, filePath);
21
- }
22
- function createWebpackData(result) {
23
- return (backendOrStorage) => {
24
- if (backendOrStorage._data) {
25
- const curLevelIdx = backendOrStorage._currentLevel;
26
- return {
27
- result,
28
- level: backendOrStorage._levels[curLevelIdx]
29
- };
30
- }
31
- return [null, result];
32
- };
33
- }
34
- function getData(storage, key) {
35
- if (storage._data instanceof Map) return storage._data.get(key);
36
- else if (storage._data) return storage.data[key];
37
- else if (storage.data instanceof Map) return storage.data.get(key);
38
- else return storage.data[key];
39
- }
40
- function setData(backendOrStorage, key, valueFactory) {
41
- const value = valueFactory(backendOrStorage);
42
- if (backendOrStorage._data instanceof Map) backendOrStorage._data.set(key, value);
43
- else if (backendOrStorage._data) backendOrStorage.data[key] = value;
44
- else if (backendOrStorage.data instanceof Map) backendOrStorage.data.set(key, value);
45
- else backendOrStorage.data[key] = value;
46
- }
47
- function getStatStorage(fileSystem) {
48
- if (fileSystem._statStorage) return fileSystem._statStorage;
49
- else if (fileSystem._statBackend) return fileSystem._statBackend;
50
- else throw new Error("Couldn't find a stat storage");
51
- }
52
- function getFileStorage(fileSystem) {
53
- if (fileSystem._readFileStorage) return fileSystem._readFileStorage;
54
- else if (fileSystem._readFileBackend) return fileSystem._readFileBackend;
55
- else throw new Error("Couldn't find a readFileStorage");
56
- }
57
- function getReadDirBackend(fileSystem) {
58
- if (fileSystem._readdirBackend) return fileSystem._readdirBackend;
59
- else if (fileSystem._readdirStorage) return fileSystem._readdirStorage;
60
- else throw new Error("Couldn't find a readDirStorage from Webpack Internals");
61
- }
62
- function getRealpathBackend(fileSystem) {
63
- if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
64
- }
65
- var VirtualModulesPlugin = class {
66
- constructor(modules) {
67
- this._compiler = null;
68
- this._watcher = null;
69
- this._staticModules = modules || null;
70
- }
71
- getModuleList(filter = ALL) {
72
- var _a, _b;
73
- let modules = {};
74
- const shouldGetStaticModules = filter === ALL || filter === STATIC;
75
- const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
76
- if (shouldGetStaticModules) modules = Object.assign(Object.assign({}, modules), this._staticModules);
77
- if (shouldGetDynamicModules) {
78
- const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
79
- const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
80
- const dynamicModules = {};
81
- Object.keys(virtualFiles).forEach((key) => {
82
- dynamicModules[key] = virtualFiles[key].contents;
83
- });
84
- modules = Object.assign(Object.assign({}, modules), dynamicModules);
85
- }
86
- return modules;
87
- }
88
- writeModule(filePath, contents) {
89
- if (!this._compiler) throw new Error(`Plugin has not been initialized`);
90
- checkActivation(this);
91
- const len = contents ? contents.length : 0;
92
- const time = Date.now();
93
- const date = new Date(time);
94
- const stats = new virtual_stats_1.VirtualStats({
95
- dev: 8675309,
96
- nlink: 0,
97
- uid: 1e3,
98
- gid: 1e3,
99
- rdev: 0,
100
- blksize: 4096,
101
- ino: inode++,
102
- mode: 33188,
103
- size: len,
104
- blocks: Math.floor(len / 4096),
105
- atime: date,
106
- mtime: date,
107
- ctime: date,
108
- birthtime: date
109
- });
110
- const modulePath = getModulePath(filePath, this._compiler);
111
- if (process.env.WVM_DEBUG) console.log(this._compiler.name, "Write virtual module:", modulePath, contents);
112
- let finalWatchFileSystem = this._watcher && this._watcher.watchFileSystem;
113
- while (finalWatchFileSystem && finalWatchFileSystem.wfs) finalWatchFileSystem = finalWatchFileSystem.wfs;
114
- let finalInputFileSystem = this._compiler.inputFileSystem;
115
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
116
- finalInputFileSystem._writeVirtualFile(modulePath, stats, contents);
117
- if (finalWatchFileSystem && finalWatchFileSystem.watcher && (finalWatchFileSystem.watcher.fileWatchers.size || finalWatchFileSystem.watcher.fileWatchers.length)) {
118
- const fileWatchers = finalWatchFileSystem.watcher.fileWatchers instanceof Map ? Array.from(finalWatchFileSystem.watcher.fileWatchers.values()) : finalWatchFileSystem.watcher.fileWatchers;
119
- for (let fileWatcher of fileWatchers) {
120
- if ("watcher" in fileWatcher) fileWatcher = fileWatcher.watcher;
121
- if (fileWatcher.path === modulePath) {
122
- if (process.env.DEBUG) console.log(this._compiler.name, "Emit file change:", modulePath, time);
123
- delete fileWatcher.directoryWatcher._cachedTimeInfoEntries;
124
- fileWatcher.emit("change", time, null);
125
- }
126
- }
127
- }
128
- }
129
- apply(compiler) {
130
- this._compiler = compiler;
131
- const afterEnvironmentHook = () => {
132
- let finalInputFileSystem = compiler.inputFileSystem;
133
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
134
- if (!finalInputFileSystem._writeVirtualFile) {
135
- const originalPurge = finalInputFileSystem.purge;
136
- finalInputFileSystem.purge = () => {
137
- originalPurge.apply(finalInputFileSystem, []);
138
- if (finalInputFileSystem._virtualFiles) Object.keys(finalInputFileSystem._virtualFiles).forEach((file) => {
139
- const data = finalInputFileSystem._virtualFiles[file];
140
- finalInputFileSystem._writeVirtualFile(file, data.stats, data.contents);
141
- });
142
- };
143
- finalInputFileSystem._writeVirtualFile = (file, stats, contents) => {
144
- const statStorage = getStatStorage(finalInputFileSystem);
145
- const fileStorage = getFileStorage(finalInputFileSystem);
146
- const readDirStorage = getReadDirBackend(finalInputFileSystem);
147
- const realPathStorage = getRealpathBackend(finalInputFileSystem);
148
- finalInputFileSystem._virtualFiles = finalInputFileSystem._virtualFiles || {};
149
- finalInputFileSystem._virtualFiles[file] = {
150
- stats,
151
- contents
152
- };
153
- setData(statStorage, file, createWebpackData(stats));
154
- setData(fileStorage, file, createWebpackData(contents));
155
- const segments = file.split(/[\\/]/);
156
- let count = segments.length - 1;
157
- const minCount = segments[0] ? 1 : 0;
158
- while (count > minCount) {
159
- const dir = segments.slice(0, count).join(path_1.default.sep) || path_1.default.sep;
160
- try {
161
- finalInputFileSystem.readdirSync(dir);
162
- } catch (e) {
163
- const time = Date.now();
164
- const dirStats = new virtual_stats_1.VirtualStats({
165
- dev: 8675309,
166
- nlink: 0,
167
- uid: 1e3,
168
- gid: 1e3,
169
- rdev: 0,
170
- blksize: 4096,
171
- ino: inode++,
172
- mode: 16877,
173
- size: stats.size,
174
- blocks: Math.floor(stats.size / 4096),
175
- atime: time,
176
- mtime: time,
177
- ctime: time,
178
- birthtime: time
179
- });
180
- setData(readDirStorage, dir, createWebpackData([]));
181
- if (realPathStorage) setData(realPathStorage, dir, createWebpackData(dir));
182
- setData(statStorage, dir, createWebpackData(dirStats));
183
- }
184
- let dirData = getData(getReadDirBackend(finalInputFileSystem), dir);
185
- dirData = dirData[1] || dirData.result;
186
- const filename = segments[count];
187
- if (dirData.indexOf(filename) < 0) {
188
- const files = dirData.concat([filename]).sort();
189
- setData(getReadDirBackend(finalInputFileSystem), dir, createWebpackData(files));
190
- } else break;
191
- count--;
192
- }
193
- };
194
- }
195
- };
196
- const afterResolversHook = () => {
197
- if (this._staticModules) {
198
- for (const [filePath, contents] of Object.entries(this._staticModules)) this.writeModule(filePath, contents);
199
- this._staticModules = null;
200
- }
201
- };
202
- const version = typeof compiler.webpack === "undefined" ? 4 : 5;
203
- const watchRunHook = (watcher, callback) => {
204
- this._watcher = watcher.compiler || watcher;
205
- const virtualFiles = compiler.inputFileSystem._virtualFiles;
206
- const fts = compiler.fileTimestamps;
207
- if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
208
- const mtime = +virtualFiles[file].stats.mtime;
209
- fts.set(file, version === 4 ? mtime : {
210
- safeTime: mtime,
211
- timestamp: mtime
212
- });
213
- });
214
- callback();
215
- };
216
- if (compiler.hooks) {
217
- compiler.hooks.afterEnvironment.tap("VirtualModulesPlugin", afterEnvironmentHook);
218
- compiler.hooks.afterResolvers.tap("VirtualModulesPlugin", afterResolversHook);
219
- compiler.hooks.watchRun.tapAsync("VirtualModulesPlugin", watchRunHook);
220
- } else {
221
- compiler.plugin("after-environment", afterEnvironmentHook);
222
- compiler.plugin("after-resolvers", afterResolversHook);
223
- compiler.plugin("watch-run", watchRunHook);
224
- }
225
- }
226
- };
227
- module.exports = VirtualModulesPlugin;
228
- }));
229
-
230
- //#endregion
231
- Object.defineProperty(exports, 'default', {
232
- enumerable: true,
233
- get: function () {
234
- return require_lib();
235
- }
236
- });
@@ -1,231 +0,0 @@
1
- import { __commonJSMin, __require } from "../../../../../../_virtual/rolldown_runtime.mjs";
2
- import { require_virtual_stats } from "./virtual-stats.mjs";
3
-
4
- //#region ../../node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.js
5
- var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6
- const path_1 = (exports && exports.__importDefault || function(mod) {
7
- return mod && mod.__esModule ? mod : { "default": mod };
8
- })(__require("node:path"));
9
- const virtual_stats_1 = require_virtual_stats();
10
- let inode = 45e6;
11
- const ALL = "all";
12
- const STATIC = "static";
13
- const DYNAMIC = "dynamic";
14
- function checkActivation(instance) {
15
- if (!instance._compiler) throw new Error("You must use this plugin only after creating webpack instance!");
16
- }
17
- function getModulePath(filePath, compiler) {
18
- return path_1.default.isAbsolute(filePath) ? filePath : path_1.default.join(compiler.context, filePath);
19
- }
20
- function createWebpackData(result) {
21
- return (backendOrStorage) => {
22
- if (backendOrStorage._data) {
23
- const curLevelIdx = backendOrStorage._currentLevel;
24
- return {
25
- result,
26
- level: backendOrStorage._levels[curLevelIdx]
27
- };
28
- }
29
- return [null, result];
30
- };
31
- }
32
- function getData(storage, key) {
33
- if (storage._data instanceof Map) return storage._data.get(key);
34
- else if (storage._data) return storage.data[key];
35
- else if (storage.data instanceof Map) return storage.data.get(key);
36
- else return storage.data[key];
37
- }
38
- function setData(backendOrStorage, key, valueFactory) {
39
- const value = valueFactory(backendOrStorage);
40
- if (backendOrStorage._data instanceof Map) backendOrStorage._data.set(key, value);
41
- else if (backendOrStorage._data) backendOrStorage.data[key] = value;
42
- else if (backendOrStorage.data instanceof Map) backendOrStorage.data.set(key, value);
43
- else backendOrStorage.data[key] = value;
44
- }
45
- function getStatStorage(fileSystem) {
46
- if (fileSystem._statStorage) return fileSystem._statStorage;
47
- else if (fileSystem._statBackend) return fileSystem._statBackend;
48
- else throw new Error("Couldn't find a stat storage");
49
- }
50
- function getFileStorage(fileSystem) {
51
- if (fileSystem._readFileStorage) return fileSystem._readFileStorage;
52
- else if (fileSystem._readFileBackend) return fileSystem._readFileBackend;
53
- else throw new Error("Couldn't find a readFileStorage");
54
- }
55
- function getReadDirBackend(fileSystem) {
56
- if (fileSystem._readdirBackend) return fileSystem._readdirBackend;
57
- else if (fileSystem._readdirStorage) return fileSystem._readdirStorage;
58
- else throw new Error("Couldn't find a readDirStorage from Webpack Internals");
59
- }
60
- function getRealpathBackend(fileSystem) {
61
- if (fileSystem._realpathBackend) return fileSystem._realpathBackend;
62
- }
63
- var VirtualModulesPlugin = class {
64
- constructor(modules) {
65
- this._compiler = null;
66
- this._watcher = null;
67
- this._staticModules = modules || null;
68
- }
69
- getModuleList(filter = ALL) {
70
- var _a, _b;
71
- let modules = {};
72
- const shouldGetStaticModules = filter === ALL || filter === STATIC;
73
- const shouldGetDynamicModules = filter === ALL || filter === DYNAMIC;
74
- if (shouldGetStaticModules) modules = Object.assign(Object.assign({}, modules), this._staticModules);
75
- if (shouldGetDynamicModules) {
76
- const finalInputFileSystem = (_a = this._compiler) === null || _a === void 0 ? void 0 : _a.inputFileSystem;
77
- const virtualFiles = (_b = finalInputFileSystem === null || finalInputFileSystem === void 0 ? void 0 : finalInputFileSystem._virtualFiles) !== null && _b !== void 0 ? _b : {};
78
- const dynamicModules = {};
79
- Object.keys(virtualFiles).forEach((key) => {
80
- dynamicModules[key] = virtualFiles[key].contents;
81
- });
82
- modules = Object.assign(Object.assign({}, modules), dynamicModules);
83
- }
84
- return modules;
85
- }
86
- writeModule(filePath, contents) {
87
- if (!this._compiler) throw new Error(`Plugin has not been initialized`);
88
- checkActivation(this);
89
- const len = contents ? contents.length : 0;
90
- const time = Date.now();
91
- const date = new Date(time);
92
- const stats = new virtual_stats_1.VirtualStats({
93
- dev: 8675309,
94
- nlink: 0,
95
- uid: 1e3,
96
- gid: 1e3,
97
- rdev: 0,
98
- blksize: 4096,
99
- ino: inode++,
100
- mode: 33188,
101
- size: len,
102
- blocks: Math.floor(len / 4096),
103
- atime: date,
104
- mtime: date,
105
- ctime: date,
106
- birthtime: date
107
- });
108
- const modulePath = getModulePath(filePath, this._compiler);
109
- if (process.env.WVM_DEBUG) console.log(this._compiler.name, "Write virtual module:", modulePath, contents);
110
- let finalWatchFileSystem = this._watcher && this._watcher.watchFileSystem;
111
- while (finalWatchFileSystem && finalWatchFileSystem.wfs) finalWatchFileSystem = finalWatchFileSystem.wfs;
112
- let finalInputFileSystem = this._compiler.inputFileSystem;
113
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
114
- finalInputFileSystem._writeVirtualFile(modulePath, stats, contents);
115
- if (finalWatchFileSystem && finalWatchFileSystem.watcher && (finalWatchFileSystem.watcher.fileWatchers.size || finalWatchFileSystem.watcher.fileWatchers.length)) {
116
- const fileWatchers = finalWatchFileSystem.watcher.fileWatchers instanceof Map ? Array.from(finalWatchFileSystem.watcher.fileWatchers.values()) : finalWatchFileSystem.watcher.fileWatchers;
117
- for (let fileWatcher of fileWatchers) {
118
- if ("watcher" in fileWatcher) fileWatcher = fileWatcher.watcher;
119
- if (fileWatcher.path === modulePath) {
120
- if (process.env.DEBUG) console.log(this._compiler.name, "Emit file change:", modulePath, time);
121
- delete fileWatcher.directoryWatcher._cachedTimeInfoEntries;
122
- fileWatcher.emit("change", time, null);
123
- }
124
- }
125
- }
126
- }
127
- apply(compiler) {
128
- this._compiler = compiler;
129
- const afterEnvironmentHook = () => {
130
- let finalInputFileSystem = compiler.inputFileSystem;
131
- while (finalInputFileSystem && finalInputFileSystem._inputFileSystem) finalInputFileSystem = finalInputFileSystem._inputFileSystem;
132
- if (!finalInputFileSystem._writeVirtualFile) {
133
- const originalPurge = finalInputFileSystem.purge;
134
- finalInputFileSystem.purge = () => {
135
- originalPurge.apply(finalInputFileSystem, []);
136
- if (finalInputFileSystem._virtualFiles) Object.keys(finalInputFileSystem._virtualFiles).forEach((file) => {
137
- const data = finalInputFileSystem._virtualFiles[file];
138
- finalInputFileSystem._writeVirtualFile(file, data.stats, data.contents);
139
- });
140
- };
141
- finalInputFileSystem._writeVirtualFile = (file, stats, contents) => {
142
- const statStorage = getStatStorage(finalInputFileSystem);
143
- const fileStorage = getFileStorage(finalInputFileSystem);
144
- const readDirStorage = getReadDirBackend(finalInputFileSystem);
145
- const realPathStorage = getRealpathBackend(finalInputFileSystem);
146
- finalInputFileSystem._virtualFiles = finalInputFileSystem._virtualFiles || {};
147
- finalInputFileSystem._virtualFiles[file] = {
148
- stats,
149
- contents
150
- };
151
- setData(statStorage, file, createWebpackData(stats));
152
- setData(fileStorage, file, createWebpackData(contents));
153
- const segments = file.split(/[\\/]/);
154
- let count = segments.length - 1;
155
- const minCount = segments[0] ? 1 : 0;
156
- while (count > minCount) {
157
- const dir = segments.slice(0, count).join(path_1.default.sep) || path_1.default.sep;
158
- try {
159
- finalInputFileSystem.readdirSync(dir);
160
- } catch (e) {
161
- const time = Date.now();
162
- const dirStats = new virtual_stats_1.VirtualStats({
163
- dev: 8675309,
164
- nlink: 0,
165
- uid: 1e3,
166
- gid: 1e3,
167
- rdev: 0,
168
- blksize: 4096,
169
- ino: inode++,
170
- mode: 16877,
171
- size: stats.size,
172
- blocks: Math.floor(stats.size / 4096),
173
- atime: time,
174
- mtime: time,
175
- ctime: time,
176
- birthtime: time
177
- });
178
- setData(readDirStorage, dir, createWebpackData([]));
179
- if (realPathStorage) setData(realPathStorage, dir, createWebpackData(dir));
180
- setData(statStorage, dir, createWebpackData(dirStats));
181
- }
182
- let dirData = getData(getReadDirBackend(finalInputFileSystem), dir);
183
- dirData = dirData[1] || dirData.result;
184
- const filename = segments[count];
185
- if (dirData.indexOf(filename) < 0) {
186
- const files = dirData.concat([filename]).sort();
187
- setData(getReadDirBackend(finalInputFileSystem), dir, createWebpackData(files));
188
- } else break;
189
- count--;
190
- }
191
- };
192
- }
193
- };
194
- const afterResolversHook = () => {
195
- if (this._staticModules) {
196
- for (const [filePath, contents] of Object.entries(this._staticModules)) this.writeModule(filePath, contents);
197
- this._staticModules = null;
198
- }
199
- };
200
- const version = typeof compiler.webpack === "undefined" ? 4 : 5;
201
- const watchRunHook = (watcher, callback) => {
202
- this._watcher = watcher.compiler || watcher;
203
- const virtualFiles = compiler.inputFileSystem._virtualFiles;
204
- const fts = compiler.fileTimestamps;
205
- if (virtualFiles && fts && typeof fts.set === "function") Object.keys(virtualFiles).forEach((file) => {
206
- const mtime = +virtualFiles[file].stats.mtime;
207
- fts.set(file, version === 4 ? mtime : {
208
- safeTime: mtime,
209
- timestamp: mtime
210
- });
211
- });
212
- callback();
213
- };
214
- if (compiler.hooks) {
215
- compiler.hooks.afterEnvironment.tap("VirtualModulesPlugin", afterEnvironmentHook);
216
- compiler.hooks.afterResolvers.tap("VirtualModulesPlugin", afterResolversHook);
217
- compiler.hooks.watchRun.tapAsync("VirtualModulesPlugin", watchRunHook);
218
- } else {
219
- compiler.plugin("after-environment", afterEnvironmentHook);
220
- compiler.plugin("after-resolvers", afterResolversHook);
221
- compiler.plugin("watch-run", watchRunHook);
222
- }
223
- }
224
- };
225
- module.exports = VirtualModulesPlugin;
226
- }));
227
-
228
- //#endregion
229
- export default require_lib();
230
-
231
- export { require_lib };
@@ -1,54 +0,0 @@
1
- "use strict";
2
-
3
- const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
4
-
5
- //#region ../../node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.js
6
- var require_virtual_stats = /* @__PURE__ */ require_rolldown_runtime.__commonJSMin(((exports) => {
7
- var __importDefault = exports && exports.__importDefault || function(mod) {
8
- return mod && mod.__esModule ? mod : { "default": mod };
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.VirtualStats = void 0;
12
- const constants_1 = __importDefault(require("node:constants"));
13
- var VirtualStats = class {
14
- constructor(config) {
15
- for (const key in config) {
16
- if (!Object.prototype.hasOwnProperty.call(config, key)) continue;
17
- this[key] = config[key];
18
- }
19
- }
20
- _checkModeProperty(property) {
21
- return (this.mode & constants_1.default.S_IFMT) === property;
22
- }
23
- isDirectory() {
24
- return this._checkModeProperty(constants_1.default.S_IFDIR);
25
- }
26
- isFile() {
27
- return this._checkModeProperty(constants_1.default.S_IFREG);
28
- }
29
- isBlockDevice() {
30
- return this._checkModeProperty(constants_1.default.S_IFBLK);
31
- }
32
- isCharacterDevice() {
33
- return this._checkModeProperty(constants_1.default.S_IFCHR);
34
- }
35
- isSymbolicLink() {
36
- return this._checkModeProperty(constants_1.default.S_IFLNK);
37
- }
38
- isFIFO() {
39
- return this._checkModeProperty(constants_1.default.S_IFIFO);
40
- }
41
- isSocket() {
42
- return this._checkModeProperty(constants_1.default.S_IFSOCK);
43
- }
44
- };
45
- exports.VirtualStats = VirtualStats;
46
- }));
47
-
48
- //#endregion
49
- Object.defineProperty(exports, 'default', {
50
- enumerable: true,
51
- get: function () {
52
- return require_virtual_stats();
53
- }
54
- });