@unpackjs/core 1.5.4 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/bin/openChrome.applescript +94 -0
  2. package/compiled/chokidar/index.d.ts +327 -0
  3. package/compiled/chokidar/index.js +1773 -0
  4. package/compiled/chokidar/license +21 -0
  5. package/compiled/chokidar/package.json +1 -0
  6. package/compiled/commander/index.d.ts +971 -0
  7. package/compiled/commander/index.js +2190 -0
  8. package/compiled/commander/license +22 -0
  9. package/compiled/commander/package.json +1 -0
  10. package/compiled/css-loader/api.js +85 -0
  11. package/compiled/css-loader/getUrl.js +26 -0
  12. package/compiled/css-loader/index.d.ts +1 -0
  13. package/compiled/css-loader/index.js +8004 -0
  14. package/compiled/css-loader/license +20 -0
  15. package/compiled/css-loader/noSourceMaps.js +5 -0
  16. package/compiled/css-loader/package.json +1 -0
  17. package/compiled/css-loader/sourceMaps.js +16 -0
  18. package/compiled/fast-glob/index.d.ts +237 -0
  19. package/compiled/fast-glob/index.js +5726 -0
  20. package/compiled/fast-glob/license +21 -0
  21. package/compiled/fast-glob/package.json +1 -0
  22. package/compiled/less-loader/index.d.ts +1 -0
  23. package/compiled/less-loader/index.js +340 -0
  24. package/compiled/less-loader/license +20 -0
  25. package/compiled/less-loader/package.json +1 -0
  26. package/compiled/line-diff/index.d.ts +1 -0
  27. package/compiled/line-diff/index.js +160 -0
  28. package/compiled/line-diff/license +21 -0
  29. package/compiled/line-diff/package.json +1 -0
  30. package/compiled/log-update/index.d.ts +1 -0
  31. package/compiled/log-update/index.js +1970 -0
  32. package/compiled/log-update/package.json +1 -0
  33. package/compiled/portfinder/index.d.ts +64 -0
  34. package/compiled/portfinder/index.js +3401 -0
  35. package/compiled/portfinder/license +22 -0
  36. package/compiled/portfinder/package.json +1 -0
  37. package/compiled/postcss-loader/index.d.ts +1 -0
  38. package/compiled/postcss-loader/index.js +94945 -0
  39. package/compiled/postcss-loader/license +20 -0
  40. package/compiled/postcss-loader/package.json +1 -0
  41. package/compiled/sass-loader/index.d.ts +961 -0
  42. package/compiled/sass-loader/index.js +5610 -0
  43. package/compiled/sass-loader/index1.js +65 -0
  44. package/compiled/sass-loader/license +20 -0
  45. package/compiled/sass-loader/package.json +1 -0
  46. package/compiled/sass-loader/sass.node.js +12 -0
  47. package/compiled/semver/index.d.ts +1 -0
  48. package/compiled/semver/index.js +1940 -0
  49. package/compiled/semver/license +15 -0
  50. package/compiled/semver/package.json +1 -0
  51. package/compiled/style-loader/index.d.ts +1 -0
  52. package/compiled/style-loader/index.js +370 -0
  53. package/compiled/style-loader/license +20 -0
  54. package/compiled/style-loader/package.json +1 -0
  55. package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
  56. package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
  57. package/compiled/style-loader/runtime/insertBySelector.js +34 -0
  58. package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
  59. package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
  60. package/compiled/style-loader/runtime/isOldIE.js +17 -0
  61. package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
  62. package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
  63. package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
  64. package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
  65. package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
  66. package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
  67. package/compiled/webpack-bundle-analyzer/index.d.ts +1 -0
  68. package/compiled/webpack-bundle-analyzer/index.js +13276 -0
  69. package/compiled/webpack-bundle-analyzer/license +20 -0
  70. package/compiled/webpack-bundle-analyzer/package.json +1 -0
  71. package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
  72. package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
  73. package/compiled/webpack-merge/index.d.ts +31 -0
  74. package/compiled/webpack-merge/index.js +1200 -0
  75. package/compiled/webpack-merge/license +20 -0
  76. package/compiled/webpack-merge/package.json +1 -0
  77. package/dist/bundleRequire.cjs +200 -0
  78. package/dist/bundleRequire.d.ts +5 -0
  79. package/dist/bundleRequire.d.ts.map +1 -0
  80. package/dist/bundleRequire.js +173 -0
  81. package/dist/bundler-config/chunkSplit.cjs +151 -0
  82. package/dist/bundler-config/chunkSplit.d.ts +6 -0
  83. package/dist/bundler-config/chunkSplit.d.ts.map +1 -0
  84. package/dist/bundler-config/chunkSplit.js +127 -0
  85. package/dist/bundler-config/css.cjs +167 -0
  86. package/dist/bundler-config/css.d.ts +6 -0
  87. package/dist/bundler-config/css.d.ts.map +1 -0
  88. package/dist/bundler-config/css.js +158 -0
  89. package/dist/bundler-config/experimentCss.cjs +166 -0
  90. package/dist/bundler-config/experimentCss.d.ts +6 -0
  91. package/dist/bundler-config/experimentCss.d.ts.map +1 -0
  92. package/dist/bundler-config/experimentCss.js +157 -0
  93. package/dist/bundler-config/helper.cjs +83 -0
  94. package/dist/bundler-config/helper.d.ts +8 -0
  95. package/dist/bundler-config/helper.d.ts.map +1 -0
  96. package/dist/bundler-config/helper.js +58 -0
  97. package/dist/bundler-config/index.cjs +204 -0
  98. package/dist/bundler-config/index.d.ts +3 -0
  99. package/dist/bundler-config/index.d.ts.map +1 -0
  100. package/dist/bundler-config/index.js +180 -0
  101. package/dist/colors.cjs +60 -0
  102. package/dist/colors.d.ts +6 -0
  103. package/dist/colors.d.ts.map +1 -0
  104. package/dist/colors.js +40 -0
  105. package/dist/{config/index.cjs → config.cjs} +21 -47
  106. package/dist/{config/index.d.ts → config.d.ts} +4 -3
  107. package/dist/config.d.ts.map +1 -0
  108. package/dist/{config/index.js → config.js} +18 -52
  109. package/dist/constants.cjs +86 -0
  110. package/dist/constants.d.ts +25 -0
  111. package/dist/constants.d.ts.map +1 -0
  112. package/dist/constants.js +61 -0
  113. package/dist/createUnpack.cjs +102 -0
  114. package/dist/createUnpack.d.ts +7 -0
  115. package/dist/createUnpack.d.ts.map +1 -0
  116. package/dist/createUnpack.js +78 -0
  117. package/dist/index.cjs +26 -48
  118. package/dist/index.d.ts +7 -7
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +8 -52
  121. package/dist/lightningcss/cache.cjs +36 -0
  122. package/dist/lightningcss/cache.d.ts +2 -0
  123. package/dist/lightningcss/cache.d.ts.map +1 -0
  124. package/dist/lightningcss/cache.js +22 -0
  125. package/dist/lightningcss/index.cjs +21 -0
  126. package/dist/lightningcss/index.d.ts +2 -0
  127. package/dist/lightningcss/index.d.ts.map +1 -0
  128. package/dist/lightningcss/index.js +10 -0
  129. package/dist/lightningcss/loader.cjs +56 -0
  130. package/dist/lightningcss/loader.d.ts +5 -0
  131. package/dist/lightningcss/loader.d.ts.map +1 -0
  132. package/dist/lightningcss/loader.js +36 -0
  133. package/dist/lightningcss/minimizer.cjs +114 -0
  134. package/dist/lightningcss/minimizer.d.ts +11 -0
  135. package/dist/lightningcss/minimizer.d.ts.map +1 -0
  136. package/dist/lightningcss/minimizer.js +90 -0
  137. package/dist/logger.cjs +103 -0
  138. package/dist/logger.d.ts +3 -0
  139. package/dist/logger.d.ts.map +1 -0
  140. package/dist/logger.js +79 -0
  141. package/dist/openBrowser.cjs +85 -0
  142. package/dist/openBrowser.d.ts +2 -0
  143. package/dist/openBrowser.d.ts.map +1 -0
  144. package/dist/openBrowser.js +61 -0
  145. package/dist/plugin-progress/rspack.cjs +74 -0
  146. package/dist/plugin-progress/rspack.d.ts +9 -0
  147. package/dist/plugin-progress/rspack.d.ts.map +1 -0
  148. package/dist/plugin-progress/rspack.js +50 -0
  149. package/dist/plugin-progress/webpack.cjs +84 -0
  150. package/dist/plugin-progress/webpack.d.ts +9 -0
  151. package/dist/plugin-progress/webpack.d.ts.map +1 -0
  152. package/dist/plugin-progress/webpack.js +60 -0
  153. package/dist/plugin.cjs +33 -0
  154. package/dist/plugin.d.ts +3 -0
  155. package/dist/plugin.d.ts.map +1 -0
  156. package/dist/plugin.js +19 -0
  157. package/dist/progressBar.cjs +70 -0
  158. package/dist/progressBar.d.ts +14 -0
  159. package/dist/progressBar.d.ts.map +1 -0
  160. package/dist/progressBar.js +46 -0
  161. package/dist/reporter.cjs +133 -0
  162. package/dist/reporter.d.ts +9 -0
  163. package/dist/reporter.d.ts.map +1 -0
  164. package/dist/reporter.js +109 -0
  165. package/dist/run/build.cjs +77 -0
  166. package/dist/run/build.d.ts +3 -0
  167. package/dist/run/build.d.ts.map +1 -0
  168. package/dist/run/build.js +53 -0
  169. package/dist/run/dev.cjs +107 -0
  170. package/dist/run/dev.d.ts +3 -0
  171. package/dist/run/dev.d.ts.map +1 -0
  172. package/dist/run/dev.js +83 -0
  173. package/dist/run/index.cjs +23 -0
  174. package/dist/run/index.d.ts +3 -0
  175. package/dist/run/index.d.ts.map +1 -0
  176. package/dist/run/index.js +11 -0
  177. package/dist/thread-loader/WorkerError.cjs +41 -0
  178. package/dist/thread-loader/WorkerError.js +31 -0
  179. package/dist/thread-loader/WorkerPool.cjs +407 -0
  180. package/dist/thread-loader/WorkerPool.js +387 -0
  181. package/dist/thread-loader/index.cjs +100 -0
  182. package/dist/thread-loader/index.js +85 -0
  183. package/dist/thread-loader/readBuffer.cjs +55 -0
  184. package/dist/thread-loader/readBuffer.js +45 -0
  185. package/dist/thread-loader/serializer.cjs +46 -0
  186. package/dist/thread-loader/serializer.js +31 -0
  187. package/dist/thread-loader/utils.cjs +84 -0
  188. package/dist/thread-loader/utils.js +60 -0
  189. package/dist/thread-loader/worker.cjs +377 -0
  190. package/dist/thread-loader/worker.js +382 -0
  191. package/dist/thread-loader/workerPools.cjs +57 -0
  192. package/dist/thread-loader/workerPools.js +33 -0
  193. package/dist/typed-css-modules/index.cjs +21 -0
  194. package/dist/typed-css-modules/index.d.ts +2 -0
  195. package/dist/typed-css-modules/index.d.ts.map +1 -0
  196. package/dist/typed-css-modules/index.js +10 -0
  197. package/dist/typed-css-modules/loader.cjs +195 -0
  198. package/dist/typed-css-modules/loader.d.ts +10 -0
  199. package/dist/typed-css-modules/loader.d.ts.map +1 -0
  200. package/dist/typed-css-modules/loader.js +170 -0
  201. package/dist/typed-css-modules/plugin.cjs +96 -0
  202. package/dist/typed-css-modules/plugin.d.ts +16 -0
  203. package/dist/typed-css-modules/plugin.d.ts.map +1 -0
  204. package/dist/typed-css-modules/plugin.js +72 -0
  205. package/dist/typed-css-modules/utils.cjs +45 -0
  206. package/dist/typed-css-modules/utils.d.ts +6 -0
  207. package/dist/typed-css-modules/utils.d.ts.map +1 -0
  208. package/dist/typed-css-modules/utils.js +31 -0
  209. package/dist/types/chunkSplit.cjs +15 -0
  210. package/dist/types/chunkSplit.d.ts +35 -0
  211. package/dist/types/chunkSplit.d.ts.map +1 -0
  212. package/dist/types/chunkSplit.js +9 -0
  213. package/dist/types/config.cjs +15 -0
  214. package/dist/types/config.d.ts +176 -0
  215. package/dist/types/config.d.ts.map +1 -0
  216. package/dist/types/config.js +9 -0
  217. package/dist/types/index.cjs +29 -0
  218. package/dist/types/index.d.ts +16 -0
  219. package/dist/types/index.d.ts.map +1 -0
  220. package/dist/types/index.js +14 -0
  221. package/dist/types/lightningcss.cjs +15 -0
  222. package/dist/types/lightningcss.d.ts +11 -0
  223. package/dist/types/lightningcss.d.ts.map +1 -0
  224. package/dist/types/lightningcss.js +9 -0
  225. package/dist/types/logger.cjs +35 -0
  226. package/dist/types/logger.d.ts +16 -0
  227. package/dist/types/logger.d.ts.map +1 -0
  228. package/dist/types/logger.js +21 -0
  229. package/dist/types/plugin.cjs +15 -0
  230. package/dist/types/plugin.d.ts +18 -0
  231. package/dist/types/plugin.d.ts.map +1 -0
  232. package/dist/types/plugin.js +9 -0
  233. package/dist/utils.cjs +286 -0
  234. package/dist/utils.d.ts +43 -0
  235. package/dist/utils.d.ts.map +1 -0
  236. package/dist/utils.js +235 -0
  237. package/package.json +95 -6
  238. package/dist/config/index.d.ts.map +0 -1
@@ -0,0 +1,382 @@
1
+ import { createRequire } from 'node:module';
2
+ var require = createRequire(import.meta['url']);
3
+
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __esm = (fn, res) => function __init() {
6
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
7
+ };
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ import path from "path";
12
+ import { fileURLToPath } from "url";
13
+ var getFilename, getDirname, __dirname, __filename;
14
+ var init_esm = __esm({
15
+ "../../node_modules/.pnpm/@modern-js+module-tools@2.60.5_typescript@5.5.4/node_modules/@modern-js/module-tools/shims/esm.js"() {
16
+ getFilename = () => fileURLToPath(import.meta.url);
17
+ getDirname = () => path.dirname(getFilename());
18
+ __dirname = /* @__PURE__ */ getDirname();
19
+ __filename = /* @__PURE__ */ getFilename();
20
+ }
21
+ });
22
+ import fs from "node:fs";
23
+ import NativeModule from "node:module";
24
+ import querystring from "node:querystring";
25
+ import loaderRunner from "loader-runner";
26
+ import readBuffer from "./readBuffer.js";
27
+ import { replacer, reviver } from "./serializer.js";
28
+ import { utils } from "./utils.js";
29
+ var require_worker = __commonJS({
30
+ "src/thread-loader/worker.js"(exports) {
31
+ init_esm();
32
+ const asyncQueue = require("neo-async/queue.js");
33
+ const writePipe = fs.createWriteStream(null, { fd: 3 });
34
+ const readPipe = fs.createReadStream(null, { fd: 4 });
35
+ writePipe.on("finish", onTerminateWrite);
36
+ readPipe.on("end", onTerminateRead);
37
+ writePipe.on("close", onTerminateWrite);
38
+ readPipe.on("close", onTerminateRead);
39
+ readPipe.on("error", onError);
40
+ writePipe.on("error", onError);
41
+ const PARALLEL_JOBS = +process.argv[2] || 20;
42
+ let terminated = false;
43
+ let nextQuestionId = 0;
44
+ const callbackMap = /* @__PURE__ */ Object.create(null);
45
+ function onError(error) {
46
+ console.error(error);
47
+ }
48
+ function onTerminateRead() {
49
+ terminateRead();
50
+ }
51
+ function onTerminateWrite() {
52
+ terminateWrite();
53
+ }
54
+ function writePipeWrite(...args) {
55
+ if (!terminated) {
56
+ writePipe.write(...args);
57
+ }
58
+ }
59
+ function writePipeCork() {
60
+ if (!terminated) {
61
+ writePipe.cork();
62
+ }
63
+ }
64
+ function writePipeUncork() {
65
+ if (!terminated) {
66
+ writePipe.uncork();
67
+ }
68
+ }
69
+ function terminateRead() {
70
+ terminated = true;
71
+ readPipe.removeAllListeners();
72
+ }
73
+ function terminateWrite() {
74
+ terminated = true;
75
+ writePipe.removeAllListeners();
76
+ }
77
+ function terminate() {
78
+ terminateRead();
79
+ terminateWrite();
80
+ }
81
+ function toErrorObj(err) {
82
+ return {
83
+ message: err.message,
84
+ details: err.details,
85
+ stack: err.stack,
86
+ hideStack: err.hideStack
87
+ };
88
+ }
89
+ function toNativeError(obj) {
90
+ if (!obj)
91
+ return null;
92
+ const err = new Error(obj.message);
93
+ err.details = obj.details;
94
+ err.missing = obj.missing;
95
+ return err;
96
+ }
97
+ function writeJson(data) {
98
+ writePipeCork();
99
+ process.nextTick(() => {
100
+ writePipeUncork();
101
+ });
102
+ const lengthBuffer = Buffer.alloc(4);
103
+ const messageBuffer = Buffer.from(JSON.stringify(data, replacer), "utf-8");
104
+ lengthBuffer.writeInt32BE(messageBuffer.length, 0);
105
+ writePipeWrite(lengthBuffer);
106
+ writePipeWrite(messageBuffer);
107
+ }
108
+ const queue = asyncQueue(({ id, data }, taskCallback) => {
109
+ try {
110
+ const resolveWithOptions = (context, request, callback, options) => {
111
+ callbackMap[nextQuestionId] = callback;
112
+ writeJson({
113
+ type: "resolve",
114
+ id,
115
+ questionId: nextQuestionId,
116
+ context,
117
+ request,
118
+ options
119
+ });
120
+ nextQuestionId += 1;
121
+ };
122
+ const buildDependencies = [];
123
+ loaderRunner.runLoaders(
124
+ {
125
+ loaders: data.loaders,
126
+ resource: data.resource,
127
+ readResource: fs.readFile.bind(fs),
128
+ context: {
129
+ version: 2,
130
+ fs,
131
+ loadModule: (request, callback) => {
132
+ callbackMap[nextQuestionId] = (error, result) => callback(error, ...result);
133
+ writeJson({
134
+ type: "loadModule",
135
+ id,
136
+ questionId: nextQuestionId,
137
+ request
138
+ });
139
+ nextQuestionId += 1;
140
+ },
141
+ resolve: (context, request, callback) => {
142
+ resolveWithOptions(context, request, callback);
143
+ },
144
+ getResolve: (options) => (context, request, callback) => {
145
+ if (callback) {
146
+ resolveWithOptions(context, request, callback, options);
147
+ } else {
148
+ return new Promise((resolve, reject) => {
149
+ resolveWithOptions(
150
+ context,
151
+ request,
152
+ (err, result) => {
153
+ if (err) {
154
+ reject(err);
155
+ } else {
156
+ resolve(result);
157
+ }
158
+ },
159
+ options
160
+ );
161
+ });
162
+ }
163
+ },
164
+ // Not an arrow function because it uses this
165
+ getOptions() {
166
+ const loader = this.loaders[this.loaderIndex];
167
+ let { options } = loader;
168
+ if (typeof options === "string") {
169
+ if (options.substr(0, 1) === "{" && options.substr(-1) === "}") {
170
+ try {
171
+ options = JSON.parse(options);
172
+ } catch (e) {
173
+ throw new Error(`Cannot parse string options: ${e.message}`);
174
+ }
175
+ } else {
176
+ options = querystring.parse(options, "&", "=", {
177
+ maxKeys: 0
178
+ });
179
+ }
180
+ }
181
+ if (options === null || options === void 0) {
182
+ options = {};
183
+ }
184
+ return options;
185
+ },
186
+ emitWarning: (warning) => {
187
+ writeJson({
188
+ type: "emitWarning",
189
+ id,
190
+ data: toErrorObj(warning)
191
+ });
192
+ },
193
+ emitError: (error) => {
194
+ writeJson({
195
+ type: "emitError",
196
+ id,
197
+ data: toErrorObj(error)
198
+ });
199
+ },
200
+ exec: (code, filename) => {
201
+ const module2 = new NativeModule(filename, exports);
202
+ module2.paths = NativeModule._nodeModulePaths(exports.context);
203
+ module2.filename = filename;
204
+ module2._compile(code, filename);
205
+ return module2.exports;
206
+ },
207
+ addBuildDependency: (filename) => {
208
+ buildDependencies.push(filename);
209
+ },
210
+ getLogger: (name) => {
211
+ function writeLoggerJson(severity, message) {
212
+ writeJson({
213
+ type: "logger",
214
+ id,
215
+ data: { severity, name, message }
216
+ });
217
+ }
218
+ writeJson({
219
+ type: "getLogger",
220
+ id,
221
+ data: { name }
222
+ });
223
+ const loggers = [
224
+ "error",
225
+ "warn",
226
+ "info",
227
+ "log",
228
+ "debug",
229
+ "trace",
230
+ "group",
231
+ "groupEnd",
232
+ "groupCollapsed",
233
+ "status",
234
+ "clear",
235
+ "profile",
236
+ "profileEnd"
237
+ ];
238
+ const fnMap = {};
239
+ for (const logger of loggers) {
240
+ fnMap[logger] = (...args) => {
241
+ writeLoggerJson(logger, args);
242
+ };
243
+ }
244
+ return fnMap;
245
+ },
246
+ options: {
247
+ context: data.optionsContext
248
+ },
249
+ webpack: true,
250
+ "thread-loader": true,
251
+ sourceMap: data.sourceMap,
252
+ target: data.target,
253
+ minimize: data.minimize,
254
+ resourceQuery: data.resourceQuery,
255
+ rootContext: data.rootContext,
256
+ _compilation: data._compilation,
257
+ _compiler: data._compiler,
258
+ resourcePath: data.resourcePath,
259
+ utils
260
+ }
261
+ },
262
+ (err, lrResult) => {
263
+ const { result, cacheable, fileDependencies, contextDependencies, missingDependencies } = lrResult;
264
+ const buffersToSend = [];
265
+ const convertedResult = Array.isArray(result) && result.map((item) => {
266
+ const isBuffer = Buffer.isBuffer(item);
267
+ if (isBuffer) {
268
+ buffersToSend.push(item);
269
+ return {
270
+ buffer: true
271
+ };
272
+ }
273
+ if (typeof item === "string") {
274
+ const stringBuffer = Buffer.from(item, "utf-8");
275
+ buffersToSend.push(stringBuffer);
276
+ return {
277
+ buffer: true,
278
+ string: true
279
+ };
280
+ }
281
+ return {
282
+ data: item
283
+ };
284
+ });
285
+ writeJson({
286
+ type: "job",
287
+ id,
288
+ error: err && toErrorObj(err),
289
+ result: {
290
+ result: convertedResult,
291
+ cacheable,
292
+ fileDependencies,
293
+ contextDependencies,
294
+ missingDependencies,
295
+ buildDependencies
296
+ },
297
+ data: buffersToSend.map((buffer) => buffer.length)
298
+ });
299
+ buffersToSend.forEach((buffer) => {
300
+ writePipeWrite(buffer);
301
+ });
302
+ setImmediate(taskCallback);
303
+ }
304
+ );
305
+ } catch (e) {
306
+ writeJson({
307
+ type: "job",
308
+ id,
309
+ error: toErrorObj(e)
310
+ });
311
+ taskCallback();
312
+ }
313
+ }, PARALLEL_JOBS);
314
+ function dispose() {
315
+ terminate();
316
+ queue.kill();
317
+ process.exit(0);
318
+ }
319
+ function onMessage(message) {
320
+ try {
321
+ const { type, id } = message;
322
+ switch (type) {
323
+ case "job": {
324
+ queue.push(message);
325
+ break;
326
+ }
327
+ case "result": {
328
+ const { error, result } = message;
329
+ const callback = callbackMap[id];
330
+ if (callback) {
331
+ const nativeError = toNativeError(error);
332
+ callback(nativeError, result);
333
+ } else {
334
+ console.error(`Worker got unexpected result id ${id}`);
335
+ }
336
+ delete callbackMap[id];
337
+ break;
338
+ }
339
+ case "warmup": {
340
+ const { requires } = message;
341
+ requires.forEach((r) => require(r));
342
+ break;
343
+ }
344
+ default: {
345
+ console.error(`Worker got unexpected job type ${type}`);
346
+ break;
347
+ }
348
+ }
349
+ } catch (e) {
350
+ console.error(`Error in worker ${e}`);
351
+ }
352
+ }
353
+ function readNextMessage() {
354
+ readBuffer(readPipe, 4, (lengthReadError, lengthBuffer) => {
355
+ if (lengthReadError) {
356
+ console.error(`Failed to communicate with main process (read length) ${lengthReadError}`);
357
+ return;
358
+ }
359
+ const length = lengthBuffer.length && lengthBuffer.readInt32BE(0);
360
+ if (length === 0) {
361
+ dispose();
362
+ return;
363
+ }
364
+ readBuffer(readPipe, length, (messageError, messageBuffer) => {
365
+ if (terminated) {
366
+ return;
367
+ }
368
+ if (messageError) {
369
+ console.error(`Failed to communicate with main process (read message) ${messageError}`);
370
+ return;
371
+ }
372
+ const messageString = messageBuffer.toString("utf-8");
373
+ const message = JSON.parse(messageString, reviver);
374
+ onMessage(message);
375
+ setImmediate(() => readNextMessage());
376
+ });
377
+ });
378
+ }
379
+ readNextMessage();
380
+ }
381
+ });
382
+ export default require_worker();
@@ -0,0 +1,57 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var workerPools_exports = {};
29
+ __export(workerPools_exports, {
30
+ getPool: () => getPool
31
+ });
32
+ module.exports = __toCommonJS(workerPools_exports);
33
+ var import_node_os = __toESM(require("node:os"));
34
+ var import_WorkerPool = __toESM(require("./WorkerPool.cjs"));
35
+ const workerPools = /* @__PURE__ */ Object.create(null);
36
+ function calculateNumberOfWorkers() {
37
+ const cpus = import_node_os.default.cpus() || { length: 1 };
38
+ return Math.max(1, cpus.length - 1);
39
+ }
40
+ function getPool(options) {
41
+ const workerPoolOptions = {
42
+ name: options.name || "",
43
+ numberOfWorkers: options.workers || calculateNumberOfWorkers(),
44
+ workerNodeArgs: options.workerNodeArgs,
45
+ workerParallelJobs: options.workerParallelJobs || 20,
46
+ poolTimeout: options.poolTimeout || 500,
47
+ poolParallelJobs: options.poolParallelJobs || 200,
48
+ poolRespawn: options.poolRespawn || false
49
+ };
50
+ const tpKey = JSON.stringify(workerPoolOptions);
51
+ workerPools[tpKey] = workerPools[tpKey] || new import_WorkerPool.default(workerPoolOptions);
52
+ return workerPools[tpKey];
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ getPool
57
+ });
@@ -0,0 +1,33 @@
1
+ import { createRequire } from 'node:module';
2
+ var require = createRequire(import.meta['url']);
3
+
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+ var getFilename = () => fileURLToPath(import.meta.url);
7
+ var getDirname = () => path.dirname(getFilename());
8
+ var __dirname = /* @__PURE__ */ getDirname();
9
+ var __filename = /* @__PURE__ */ getFilename();
10
+ import os from "node:os";
11
+ import WorkerPool from "./WorkerPool.js";
12
+ const workerPools = /* @__PURE__ */ Object.create(null);
13
+ function calculateNumberOfWorkers() {
14
+ const cpus = os.cpus() || { length: 1 };
15
+ return Math.max(1, cpus.length - 1);
16
+ }
17
+ function getPool(options) {
18
+ const workerPoolOptions = {
19
+ name: options.name || "",
20
+ numberOfWorkers: options.workers || calculateNumberOfWorkers(),
21
+ workerNodeArgs: options.workerNodeArgs,
22
+ workerParallelJobs: options.workerParallelJobs || 20,
23
+ poolTimeout: options.poolTimeout || 500,
24
+ poolParallelJobs: options.poolParallelJobs || 200,
25
+ poolRespawn: options.poolRespawn || false
26
+ };
27
+ const tpKey = JSON.stringify(workerPoolOptions);
28
+ workerPools[tpKey] = workerPools[tpKey] || new WorkerPool(workerPoolOptions);
29
+ return workerPools[tpKey];
30
+ }
31
+ export {
32
+ getPool
33
+ };
@@ -0,0 +1,21 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var typed_css_modules_exports = {};
16
+ module.exports = __toCommonJS(typed_css_modules_exports);
17
+ __reExport(typed_css_modules_exports, require("./plugin.cjs"), module.exports);
18
+ // Annotate the CommonJS export names for ESM import in node:
19
+ 0 && (module.exports = {
20
+ ...require("./plugin.cjs")
21
+ });
@@ -0,0 +1,2 @@
1
+ export * from './plugin';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/typed-css-modules/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { createRequire } from 'node:module';
2
+ var require = createRequire(import.meta['url']);
3
+
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+ var getFilename = () => fileURLToPath(import.meta.url);
7
+ var getDirname = () => path.dirname(getFilename());
8
+ var __dirname = /* @__PURE__ */ getDirname();
9
+ var __filename = /* @__PURE__ */ getFilename();
10
+ export * from "./plugin.js";