screw-up 1.3.0 → 1.4.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 +8 -8
- package/dist/analyzer.d.ts +2 -2
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/cli-internal.d.ts +2 -2
- package/dist/cli-internal.d.ts.map +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/generated/packageMetadata.d.ts +4 -4
- package/dist/index.cjs +75 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +75 -20
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/main.cjs +62 -21
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.js +62 -21
- package/dist/main.js.map +1 -1
- package/dist/{packageMetadata-C9hcegXk.cjs → packageMetadata-BR1AdagI.cjs} +96 -28
- package/dist/packageMetadata-BR1AdagI.cjs.map +1 -0
- package/dist/{packageMetadata-CFcZlT3V.js → packageMetadata-CPcWAWcQ.js} +96 -28
- package/dist/packageMetadata-CPcWAWcQ.js.map +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/vite-plugin.d.ts +2 -2
- package/dist/vite-plugin.d.ts.map +1 -1
- package/package.json +9 -8
- package/dist/packageMetadata-C9hcegXk.cjs.map +0 -1
- package/dist/packageMetadata-CFcZlT3V.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Simply package metadata inserter for NPM.
|
|
|
7
7
|
[](https://www.repostatus.org/#active)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
---
|
|
11
11
|
|
|
12
12
|
## What is this?
|
|
13
13
|
|
|
@@ -59,14 +59,14 @@ my-awesome-library-2.1.0.tgz
|
|
|
59
59
|
|
|
60
60
|
## Key Features
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
- Automatic metadata extraction: Reads metadata from `package.json` automatically.
|
|
63
|
+
- Workspace support: Works with monorepos and automatically inherits metadata from parent packages.
|
|
64
|
+
- Flexible output: Specify exactly which metadata to include and in what order.
|
|
65
|
+
- TypeScript metadata generation: Can automatically generates TypeScript files with metadata constants for use in your source code.
|
|
66
|
+
- Git metadata extraction: Automatically extracts Git commit hash, tags, branches, and version information from local Git repository.
|
|
67
|
+
- Supported pack/publish CLI interface: When publishing using this feature, the package is generated after applying the above processing to `package.json`.
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
---
|
|
70
70
|
|
|
71
71
|
## Documentation
|
|
72
72
|
|
package/dist/analyzer.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: screw-up
|
|
3
|
-
* version: 1.
|
|
3
|
+
* version: 1.4.0
|
|
4
4
|
* description: Simply package metadata inserter on Vite plugin
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/screw-up.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 48850bae9ed83a921ef5239628983b3e797a0ce7
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { Logger } from './internal.js';
|
package/dist/analyzer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAuoBvC;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,EACjB,6BAA6B,OAAO,EACpC,QAAQ,MAAM,uBAaf,CAAC"}
|
package/dist/cli-internal.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: screw-up
|
|
3
|
-
* version: 1.
|
|
3
|
+
* version: 1.4.0
|
|
4
4
|
* description: Simply package metadata inserter on Vite plugin
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/screw-up.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 48850bae9ed83a921ef5239628983b3e797a0ce7
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { Logger } from './internal';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-internal.d.ts","sourceRoot":"","sources":["../src/cli-internal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli-internal.d.ts","sourceRoot":"","sources":["../src/cli-internal.ts"],"names":[],"mappings":"AAiBA,OAAO,EAKL,MAAM,EACP,MAAM,YAAY,CAAC;AAyEpB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GACrB,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,6BAA6B,OAAO,EACpC,8BAA8B,OAAO,EACrC,mBAAmB,GAAG,CAAC,MAAM,CAAC,EAC9B,uBAAuB,MAAM,GAAG,SAAS,EACzC,0BAA0B,OAAO,EACjC,uBAAuB,MAAM,EAC7B,QAAQ,MAAM,KACb,OAAO,CAAC,YAAY,GAAG,SAAS,CAmIlC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,WAAW,MAAM,EACjB,kBAAkB,MAAM,OAAO,CAAC,GAAG,CAAC,EACpC,8BAA8B,OAAO,EACrC,mBAAmB,GAAG,CAAC,MAAM,CAAC,EAC9B,QAAQ,MAAM,KACb,OAAO,CAAC,GAAG,CAeb,CAAC;AAIF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;CACpD;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GACpB,MAAM,MAAM,EAAE,EACd,cAAc,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,KACrC,UAyCF,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: screw-up
|
|
3
|
-
* version: 1.
|
|
3
|
+
* version: 1.4.0
|
|
4
4
|
* description: Simply package metadata inserter on Vite plugin
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/screw-up.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 48850bae9ed83a921ef5239628983b3e797a0ce7
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { Logger } from './internal';
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAycpC,eAAO,MAAM,OAAO,GAClB,MAAM,MAAM,EAAE,EACd,QAAQ,MAAM,KACb,OAAO,CAAC,MAAM,CA4BhB,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: screw-up
|
|
3
|
-
* version: 1.
|
|
3
|
+
* version: 1.4.0
|
|
4
4
|
* description: Simply package metadata inserter on Vite plugin
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/screw-up.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 48850bae9ed83a921ef5239628983b3e797a0ce7
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export declare const name = "screw-up";
|
|
12
|
-
export declare const version = "1.
|
|
12
|
+
export declare const version = "1.4.0";
|
|
13
13
|
export declare const description = "Simply package metadata inserter on Vite plugin";
|
|
14
14
|
export declare const author = "Kouji Matsui (@kekyo@mi.kekyo.net)";
|
|
15
15
|
export declare const license = "MIT";
|
|
16
16
|
export declare const repository_url = "https://github.com/kekyo/screw-up.git";
|
|
17
|
-
export declare const git_commit_hash = "
|
|
17
|
+
export declare const git_commit_hash = "48850bae9ed83a921ef5239628983b3e797a0ce7";
|
|
18
18
|
//# sourceMappingURL=packageMetadata.d.ts.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: screw-up
|
|
3
|
-
* version: 1.
|
|
3
|
+
* version: 1.4.0
|
|
4
4
|
* description: Simply package metadata inserter on Vite plugin
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/screw-up.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 48850bae9ed83a921ef5239628983b3e797a0ce7
|
|
9
9
|
*/
|
|
10
10
|
"use strict";
|
|
11
11
|
const fs = require("fs/promises");
|
|
12
12
|
const fs$1 = require("fs");
|
|
13
13
|
const path = require("path");
|
|
14
|
-
const packageMetadata = require("./packageMetadata-
|
|
14
|
+
const packageMetadata = require("./packageMetadata-BR1AdagI.cjs");
|
|
15
15
|
const __NOOP_HANDLER = () => {
|
|
16
16
|
};
|
|
17
17
|
const __NOOP_RELEASABLE = {
|
|
@@ -220,12 +220,28 @@ const generateMetadataTypeFile = (outputKeys) => {
|
|
|
220
220
|
};
|
|
221
221
|
const screwUp = (options = {}) => {
|
|
222
222
|
const {
|
|
223
|
-
outputKeys = [
|
|
223
|
+
outputKeys = [
|
|
224
|
+
"name",
|
|
225
|
+
"version",
|
|
226
|
+
"description",
|
|
227
|
+
"author",
|
|
228
|
+
"license",
|
|
229
|
+
"repository.url",
|
|
230
|
+
"git.commit.hash"
|
|
231
|
+
],
|
|
224
232
|
assetFilters = ["\\.d\\.ts$"],
|
|
225
233
|
outputMetadataFile = false,
|
|
226
234
|
outputMetadataFilePath = "src/generated/packageMetadata.ts",
|
|
227
235
|
outputMetadataFileTypePath,
|
|
228
|
-
outputMetadataKeys = [
|
|
236
|
+
outputMetadataKeys = [
|
|
237
|
+
"name",
|
|
238
|
+
"version",
|
|
239
|
+
"description",
|
|
240
|
+
"author",
|
|
241
|
+
"license",
|
|
242
|
+
"repository.url",
|
|
243
|
+
"git.commit.hash"
|
|
244
|
+
],
|
|
229
245
|
checkWorkingDirectoryStatus = true,
|
|
230
246
|
alwaysOverrideVersionFromGit = true,
|
|
231
247
|
insertMetadataBanner = true
|
|
@@ -272,17 +288,31 @@ const screwUp = (options = {}) => {
|
|
|
272
288
|
metadata = result.metadata;
|
|
273
289
|
banner = generateBanner(metadata, outputKeys);
|
|
274
290
|
if (outputMetadataFile) {
|
|
275
|
-
const metadataSourceContent = generateMetadataFile(
|
|
291
|
+
const metadataSourceContent = generateMetadataFile(
|
|
292
|
+
metadata,
|
|
293
|
+
outputMetadataKeys
|
|
294
|
+
);
|
|
276
295
|
const metadataSourcePath = path.join(projectRoot, outputMetadataFilePath);
|
|
277
|
-
return await writeFileIfChanged(
|
|
296
|
+
return await writeFileIfChanged(
|
|
297
|
+
metadataSourcePath,
|
|
298
|
+
metadataSourceContent,
|
|
299
|
+
"metadata source file"
|
|
300
|
+
);
|
|
278
301
|
}
|
|
279
302
|
return false;
|
|
280
303
|
};
|
|
281
304
|
const generateMetadataTypeDefinitionFile = async () => {
|
|
282
305
|
if (outputMetadataFile) {
|
|
283
306
|
const metadataTypeContent = generateMetadataTypeFile(outputMetadataKeys);
|
|
284
|
-
const metadataTypePath = path.join(
|
|
285
|
-
|
|
307
|
+
const metadataTypePath = path.join(
|
|
308
|
+
projectRoot,
|
|
309
|
+
resolvedOutputMetadataFileTypePath
|
|
310
|
+
);
|
|
311
|
+
return await writeFileIfChanged(
|
|
312
|
+
metadataTypePath,
|
|
313
|
+
metadataTypeContent,
|
|
314
|
+
"metadata type definition file"
|
|
315
|
+
);
|
|
286
316
|
}
|
|
287
317
|
return false;
|
|
288
318
|
};
|
|
@@ -294,8 +324,15 @@ const screwUp = (options = {}) => {
|
|
|
294
324
|
outputMetadataKeys.forEach((key) => {
|
|
295
325
|
dummyMetadata[key] = "[Require first build]";
|
|
296
326
|
});
|
|
297
|
-
const dummyContent = generateMetadataFile(
|
|
298
|
-
|
|
327
|
+
const dummyContent = generateMetadataFile(
|
|
328
|
+
dummyMetadata,
|
|
329
|
+
outputMetadataKeys
|
|
330
|
+
);
|
|
331
|
+
return await writeFileIfChanged(
|
|
332
|
+
metadataSourcePath,
|
|
333
|
+
dummyContent,
|
|
334
|
+
"dummy metadata source file"
|
|
335
|
+
);
|
|
299
336
|
}
|
|
300
337
|
}
|
|
301
338
|
return false;
|
|
@@ -306,13 +343,18 @@ const screwUp = (options = {}) => {
|
|
|
306
343
|
// (especially vite-plugin-dts, avoid packageMetadata.ts is not found)
|
|
307
344
|
enforce: "pre",
|
|
308
345
|
// Plugin starting
|
|
309
|
-
applyToEnvironment: async () => {
|
|
346
|
+
applyToEnvironment: async (penv) => {
|
|
310
347
|
logger.info(`${packageMetadata.version}-${packageMetadata.git_commit_hash}: Started.`);
|
|
348
|
+
projectRoot = penv.config.root;
|
|
311
349
|
if (projectRoot && await generateMetadataTypeDefinitionFile()) {
|
|
312
|
-
logger.info(
|
|
350
|
+
logger.info(
|
|
351
|
+
`applyToEnvironment: Metadata type definition file is generated: ${resolvedOutputMetadataFileTypePath}`
|
|
352
|
+
);
|
|
313
353
|
}
|
|
314
354
|
if (projectRoot && await generateDummyMetadataFile()) {
|
|
315
|
-
logger.info(
|
|
355
|
+
logger.info(
|
|
356
|
+
`applyToEnvironment: Dummy metadata source file is generated: ${outputMetadataFilePath}`
|
|
357
|
+
);
|
|
316
358
|
}
|
|
317
359
|
return true;
|
|
318
360
|
},
|
|
@@ -333,7 +375,9 @@ const screwUp = (options = {}) => {
|
|
|
333
375
|
logger
|
|
334
376
|
);
|
|
335
377
|
if (await generateMetadataSourceFile()) {
|
|
336
|
-
logger.info(
|
|
378
|
+
logger.info(
|
|
379
|
+
`configResolved: Metadata source file is generated: ${outputMetadataFilePath}`
|
|
380
|
+
);
|
|
337
381
|
}
|
|
338
382
|
} finally {
|
|
339
383
|
logger.debug(`configResolved: Exited.`);
|
|
@@ -348,10 +392,14 @@ const screwUp = (options = {}) => {
|
|
|
348
392
|
if (outputMetadataFile && server.watcher) {
|
|
349
393
|
const metadataSourcePath = path.join(projectRoot, outputMetadataFilePath);
|
|
350
394
|
server.watcher.unwatch(metadataSourcePath);
|
|
351
|
-
logger.debug(
|
|
395
|
+
logger.debug(
|
|
396
|
+
`configureServer: Excluded from watcher: ${outputMetadataFilePath}`
|
|
397
|
+
);
|
|
352
398
|
}
|
|
353
399
|
if (await generateMetadataSourceFile()) {
|
|
354
|
-
logger.info(
|
|
400
|
+
logger.info(
|
|
401
|
+
`configureServer: Metadata source file is generated: ${outputMetadataFilePath}`
|
|
402
|
+
);
|
|
355
403
|
}
|
|
356
404
|
} finally {
|
|
357
405
|
logger.debug(`configureServer: Exited.`);
|
|
@@ -364,7 +412,9 @@ const screwUp = (options = {}) => {
|
|
|
364
412
|
try {
|
|
365
413
|
logger.debug(`buildStart: Started.`);
|
|
366
414
|
if (await generateMetadataSourceFile()) {
|
|
367
|
-
logger.info(
|
|
415
|
+
logger.info(
|
|
416
|
+
`buildStart: Metadata source file is generated: ${outputMetadataFilePath}`
|
|
417
|
+
);
|
|
368
418
|
}
|
|
369
419
|
} finally {
|
|
370
420
|
logger.debug(`buildStart: Exited.`);
|
|
@@ -388,7 +438,9 @@ const screwUp = (options = {}) => {
|
|
|
388
438
|
}
|
|
389
439
|
}
|
|
390
440
|
if (count >= 1) {
|
|
391
|
-
logger.debug(
|
|
441
|
+
logger.debug(
|
|
442
|
+
`generateBundle: Banner header inserted: ${count} file(s)`
|
|
443
|
+
);
|
|
392
444
|
}
|
|
393
445
|
}
|
|
394
446
|
},
|
|
@@ -404,7 +456,10 @@ const screwUp = (options = {}) => {
|
|
|
404
456
|
try {
|
|
405
457
|
const content = await fs.readFile(filePath, "utf-8");
|
|
406
458
|
if (!content.includes(banner)) {
|
|
407
|
-
await fs.writeFile(
|
|
459
|
+
await fs.writeFile(
|
|
460
|
+
filePath,
|
|
461
|
+
insertBannerHeader(content, banner + "\n")
|
|
462
|
+
);
|
|
408
463
|
count++;
|
|
409
464
|
}
|
|
410
465
|
} catch (error) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../node_modules/async-primitives/dist/async-primitives.js","../src/vite-plugin.ts"],"sourcesContent":["const __NOOP_HANDLER = () => {\n};\nconst __NOOP_RELEASABLE = {\n release: __NOOP_HANDLER,\n [Symbol.dispose]: __NOOP_HANDLER\n};\nconst onAbort = (signal, callback) => {\n if (!signal) {\n return __NOOP_RELEASABLE;\n }\n if (signal.aborted) {\n try {\n callback();\n } catch (error) {\n console.warn(\"AbortHook callback error: \", error);\n }\n return __NOOP_RELEASABLE;\n }\n let abortHandler;\n abortHandler = () => {\n if (abortHandler) {\n signal.removeEventListener(\"abort\", abortHandler);\n abortHandler = void 0;\n try {\n callback();\n } catch (error) {\n console.warn(\"AbortHook callback error: \", error);\n }\n }\n };\n const release = () => {\n if (abortHandler) {\n signal.removeEventListener(\"abort\", abortHandler);\n abortHandler = void 0;\n }\n };\n signal.addEventListener(\"abort\", abortHandler, { once: true });\n const handle = {\n release,\n [Symbol.dispose]: release\n };\n return handle;\n};\nconst delay = (msec, signal) => {\n if (signal) {\n if (signal.aborted) {\n throw new Error(\"Delay was aborted\");\n }\n return new Promise((resolve, reject) => {\n const abortHandle = onAbort(signal, () => {\n clearTimeout(timeoutId);\n reject(new Error(\"Delay was aborted\"));\n });\n const timeoutId = setTimeout(() => {\n abortHandle.release();\n resolve();\n }, msec);\n });\n } else {\n return new Promise((resolve) => {\n setTimeout(resolve, msec);\n });\n }\n};\nconst defer = (fn) => {\n if (typeof setImmediate === \"function\") {\n setImmediate(fn);\n } else {\n setTimeout(fn, 0);\n }\n};\nconst ABORTED_ERROR = () => new Error(\"Lock acquisition was aborted\");\nconst createLockHandle = (releaseCallback) => {\n let isActive = true;\n const release = () => {\n if (!isActive) {\n return;\n }\n isActive = false;\n releaseCallback();\n };\n return {\n get isActive() {\n return isActive;\n },\n release,\n [Symbol.dispose]: release\n };\n};\nconst createAsyncLock = (maxConsecutiveCalls = 20) => {\n let isLocked = false;\n const queue = [];\n let count = 0;\n const processQueue = () => {\n var _a;\n if (isLocked || queue.length === 0) {\n return;\n }\n const item = queue.shift();\n if ((_a = item.signal) == null ? void 0 : _a.aborted) {\n item.reject(ABORTED_ERROR());\n scheduleNextProcess();\n return;\n }\n isLocked = true;\n const lockHandle = createLockHandle(releaseLock);\n item.resolve(lockHandle);\n };\n const scheduleNextProcess = () => {\n count++;\n if (count >= maxConsecutiveCalls) {\n count = 0;\n defer(processQueue);\n } else {\n processQueue();\n }\n };\n const releaseLock = () => {\n if (!isLocked) {\n return;\n }\n isLocked = false;\n scheduleNextProcess();\n };\n const removeFromQueue = (item) => {\n const index = queue.indexOf(item);\n if (index !== -1) {\n queue.splice(index, 1);\n }\n };\n const lock = async (signal) => {\n if (signal) {\n if (signal.aborted) {\n throw ABORTED_ERROR();\n }\n return new Promise((resolve, reject) => {\n const queueItem = {\n resolve: void 0,\n reject: void 0,\n signal\n };\n const abortHandle = onAbort(signal, () => {\n removeFromQueue(queueItem);\n reject(ABORTED_ERROR());\n });\n queueItem.resolve = (handle) => {\n abortHandle.release();\n resolve(handle);\n };\n queueItem.reject = (error) => {\n abortHandle.release();\n reject(error);\n };\n queue.push(queueItem);\n processQueue();\n });\n } else {\n return new Promise((resolve, reject) => {\n queue.push({\n resolve,\n reject\n });\n processQueue();\n });\n }\n };\n return {\n lock,\n get isLocked() {\n return isLocked;\n },\n get pendingCount() {\n return queue.length;\n }\n };\n};\nconst createDeferred = (signal) => {\n let resolve;\n let reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n const disposer = onAbort(signal, () => {\n const _reject = reject;\n if (_reject) {\n resolve = void 0;\n reject = void 0;\n _reject(new Error(\"Deferred aborted\"));\n }\n });\n return {\n // The promise that resolves to the result\n promise,\n // Resolve the promise with a result\n resolve: (value) => {\n const _resolve = resolve;\n if (_resolve) {\n resolve = void 0;\n reject = void 0;\n disposer.release();\n _resolve(value);\n }\n },\n // Reject the promise with an error\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n reject: (error) => {\n const _reject = reject;\n if (_reject) {\n resolve = void 0;\n reject = void 0;\n disposer.release();\n _reject(error);\n }\n }\n };\n};\nconst createSignal = () => {\n const waiters = [];\n return {\n trigger: () => {\n if (waiters.length >= 1) {\n waiters.shift().resolve();\n }\n },\n wait: async (signal) => {\n if (signal == null ? void 0 : signal.aborted) {\n throw new Error(\"Signal aborted\");\n }\n const waiter = createDeferred();\n waiters.push(waiter);\n const disposer = onAbort(signal, () => {\n waiters.splice(waiters.indexOf(waiter), 1);\n waiter.reject(new Error(\"Signal aborted\"));\n });\n try {\n await waiter.promise;\n } finally {\n disposer.release();\n }\n }\n };\n};\nconst createManuallySignal = (initialState) => {\n const waiters = [];\n let raised = initialState != null ? initialState : false;\n return {\n trigger: () => {\n raised = false;\n const waiter = waiters.shift();\n if (waiter) {\n waiter.resolve();\n raised = false;\n }\n },\n raise: () => {\n while (waiters.length >= 1) {\n raised = true;\n waiters.shift().resolve();\n }\n raised = true;\n },\n drop: () => {\n raised = false;\n },\n wait: async (signal) => {\n if (raised) {\n return;\n }\n if (signal == null ? void 0 : signal.aborted) {\n throw new Error(\"Signal aborted\");\n }\n const waiter = createDeferred();\n waiters.push(waiter);\n const disposer = onAbort(signal, () => {\n waiters.splice(waiters.indexOf(waiter), 1);\n waiter.reject(new Error(\"Signal aborted\"));\n });\n try {\n await waiter.promise;\n } finally {\n disposer.release();\n }\n }\n };\n};\nconst createDeferredGenerator = (options) => {\n const maxItemReserved = options == null ? void 0 : options.maxItemReserved;\n const signal = options == null ? void 0 : options.signal;\n const queue = [];\n const arrived = createManuallySignal();\n const canReserve = maxItemReserved ? createManuallySignal(true) : void 0;\n const generator = async function* () {\n while (true) {\n while (true) {\n const item = queue.shift();\n if (maxItemReserved && queue.length === maxItemReserved - 1) {\n canReserve.raise();\n }\n if (!item) {\n break;\n }\n switch (item.kind) {\n case \"value\":\n yield item.value;\n break;\n case \"completed\":\n return;\n case \"error\":\n throw item.error;\n }\n if (signal == null ? void 0 : signal.aborted) {\n throw new Error(\"Deferred generator aborted\");\n }\n }\n arrived.drop();\n try {\n await arrived.wait(signal);\n } catch (error) {\n if (error instanceof Error && error.message === \"Signal aborted\") {\n error.message = \"Deferred generator aborted\";\n }\n throw error;\n }\n }\n }();\n const enqueue = async (item, signal2) => {\n while (true) {\n if (!maxItemReserved || queue.length < maxItemReserved) {\n const remains = queue.push(item);\n if (remains === 1) {\n arrived.raise();\n }\n if (remains === maxItemReserved) {\n canReserve.drop();\n }\n break;\n }\n try {\n await canReserve.wait(signal2);\n } catch (error) {\n if (error instanceof Error && error.message === \"Signal aborted\") {\n error.message = \"Deferred generator aborted\";\n }\n throw error;\n }\n }\n };\n return {\n // The async generator that yields values\n generator,\n // Yield a value to the generator\n yield: (value, signal2) => enqueue({ kind: \"value\", value }, signal2),\n // Complete the generator (equivalent to return)\n return: (signal2) => enqueue({ kind: \"completed\" }, signal2),\n // Throw an error to the generator\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n throw: (error, signal2) => enqueue({ kind: \"error\", error }, signal2)\n };\n};\nconst createLogicalContext = (id) => {\n return { id, data: /* @__PURE__ */ new Map() };\n};\nlet currentLogicalContext = createLogicalContext(Symbol(\"[root]\"));\nconst setCurrentLogicalContext = (context) => {\n currentLogicalContext = context;\n};\nconst trampoline = (adjustment, callback, thisArg, ...args) => {\n const previousLogicalContext = currentLogicalContext;\n currentLogicalContext = adjustment.contextToUse;\n try {\n return callback.call(thisArg, ...args);\n } finally {\n adjustment.contextAfter = currentLogicalContext;\n currentLogicalContext = previousLogicalContext;\n }\n};\nlet isPrepared = false;\nconst prepare = () => {\n if (isPrepared) {\n return;\n }\n isPrepared = true;\n if (typeof globalThis.setTimeout !== \"undefined\") {\n const __setTimeout = globalThis.setTimeout;\n globalThis.setTimeout = (handler, timeout, ...args) => {\n const capturedLogicalContext = currentLogicalContext;\n return __setTimeout(\n (...args2) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, handler, void 0, ...args2);\n },\n timeout,\n ...args\n );\n };\n }\n if (typeof globalThis.setInterval !== \"undefined\") {\n const __setInterval = globalThis.setInterval;\n globalThis.setInterval = (handler, timeout, ...args) => {\n const capturedLogicalContext = currentLogicalContext;\n return __setInterval(\n (...args2) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, handler, void 0, ...args2);\n },\n timeout,\n ...args\n );\n };\n }\n if (typeof globalThis.queueMicrotask !== \"undefined\") {\n const __queueMicrotask = globalThis.queueMicrotask;\n globalThis.queueMicrotask = (callback) => {\n const capturedLogicalContext = currentLogicalContext;\n return __queueMicrotask(() => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, callback, void 0);\n });\n };\n }\n if (typeof globalThis.setImmediate !== \"undefined\") {\n const __setImmediate = globalThis.setImmediate;\n globalThis.setImmediate = (callback, ...args) => {\n const capturedLogicalContext = currentLogicalContext;\n return __setImmediate((...callbackArgs) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, callback, void 0, ...callbackArgs);\n }, ...args);\n };\n }\n if (typeof process !== \"undefined\" && process.nextTick) {\n const __nextTick = process.nextTick;\n process.nextTick = (callback, ...args) => {\n const capturedLogicalContext = currentLogicalContext;\n return __nextTick(() => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, callback, void 0, ...args);\n });\n };\n }\n if (typeof Promise !== \"undefined\") {\n const __then = Promise.prototype.then;\n const __catch = Promise.prototype.catch;\n const __finally = Promise.prototype.finally;\n Promise.prototype.then = function(onFulfilled, onRejected) {\n const capturedLogicalContext = currentLogicalContext;\n const resultPromise = __then.call(\n this,\n onFulfilled ? (value) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, onFulfilled, void 0, value);\n } : void 0,\n onRejected ? (reason) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, onRejected, void 0, reason);\n } : void 0\n );\n return resultPromise;\n };\n Promise.prototype.catch = function(onRejected) {\n const capturedLogicalContext = currentLogicalContext;\n const resultPromise = __catch.call(\n this,\n onRejected ? (reason) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, onRejected, void 0, reason);\n } : void 0\n );\n return resultPromise;\n };\n Promise.prototype.finally = function(onFinally) {\n const capturedLogicalContext = currentLogicalContext;\n const resultPromise = __finally.call(\n this,\n onFinally ? () => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, onFinally, void 0);\n } : void 0\n );\n return resultPromise;\n };\n }\n if (typeof EventTarget !== \"undefined\" && EventTarget.prototype && EventTarget.prototype.addEventListener) {\n const __eventTargetAddEventListener = EventTarget.prototype.addEventListener;\n EventTarget.prototype.addEventListener = function(type, listener, options) {\n if (listener === null || listener === void 0) {\n return __eventTargetAddEventListener.call(this, type, listener, options);\n }\n if (typeof listener === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return __eventTargetAddEventListener.call(this, type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return __eventTargetAddEventListener.call(this, type, wrappedListener, options);\n }\n return __eventTargetAddEventListener.call(this, type, listener, options);\n };\n }\n if (typeof Element !== \"undefined\" && Element.prototype && Element.prototype.addEventListener) {\n const __elementAddEventListener = Element.prototype.addEventListener;\n Element.prototype.addEventListener = function(type, listener, options) {\n if (listener === null || listener === void 0) {\n return __elementAddEventListener.call(this, type, listener, options);\n }\n if (typeof listener === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return __elementAddEventListener.call(this, type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return __elementAddEventListener.call(this, type, wrappedListener, options);\n }\n return __elementAddEventListener.call(this, type, listener, options);\n };\n }\n if (typeof globalThis.requestAnimationFrame !== \"undefined\") {\n const __requestAnimationFrame = globalThis.requestAnimationFrame;\n globalThis.requestAnimationFrame = (callback) => {\n const capturedLogicalContext = currentLogicalContext;\n return __requestAnimationFrame((time) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, callback, void 0, time);\n });\n };\n }\n if (typeof globalThis.XMLHttpRequest !== \"undefined\") {\n const __XMLHttpRequest = globalThis.XMLHttpRequest;\n globalThis.XMLHttpRequest = class extends __XMLHttpRequest {\n constructor() {\n super();\n this._userHandlers = /* @__PURE__ */ new Map();\n const eventHandlerProperties = [\n \"onreadystatechange\",\n \"onloadstart\",\n \"onprogress\",\n \"onabort\",\n \"onerror\",\n \"onload\",\n \"ontimeout\",\n \"onloadend\"\n ];\n eventHandlerProperties.forEach((prop) => {\n Object.defineProperty(this, prop, {\n get: () => this._userHandlers.get(prop) || null,\n set: (newHandler) => {\n this._userHandlers.set(prop, newHandler);\n if (newHandler && typeof newHandler === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedHandler = function(event) {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, newHandler, this, event);\n };\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, wrappedHandler);\n } else {\n this[`_${prop}`] = wrappedHandler;\n }\n } else {\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, null);\n } else {\n this[`_${prop}`] = null;\n }\n }\n },\n configurable: true,\n enumerable: true\n });\n });\n }\n addEventListener(type, listener, options) {\n const capturedLogicalContext = currentLogicalContext;\n if (!listener) {\n return super.addEventListener(type, listener, options);\n }\n if (typeof listener === \"function\") {\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return super.addEventListener(type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return super.addEventListener(type, wrappedListener, options);\n }\n return super.addEventListener(type, listener, options);\n }\n };\n }\n if (typeof globalThis.WebSocket !== \"undefined\") {\n const __WebSocket = globalThis.WebSocket;\n globalThis.WebSocket = class extends __WebSocket {\n constructor(url, protocols) {\n super(url, protocols);\n this._userHandlers = /* @__PURE__ */ new Map();\n const eventHandlerProperties = [\n \"onopen\",\n \"onmessage\",\n \"onerror\",\n \"onclose\"\n ];\n eventHandlerProperties.forEach((prop) => {\n Object.defineProperty(this, prop, {\n get: () => this._userHandlers.get(prop) || null,\n set: (newHandler) => {\n this._userHandlers.set(prop, newHandler);\n if (newHandler && typeof newHandler === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedHandler = function(event) {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, newHandler, this, event);\n };\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, wrappedHandler);\n } else {\n this[`_${prop}`] = wrappedHandler;\n }\n } else {\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, null);\n } else {\n this[`_${prop}`] = null;\n }\n }\n },\n configurable: true,\n enumerable: true\n });\n });\n }\n addEventListener(type, listener, options) {\n const capturedLogicalContext = currentLogicalContext;\n if (!listener) {\n return super.addEventListener(type, listener, options);\n }\n if (typeof listener === \"function\") {\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return super.addEventListener(type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return super.addEventListener(type, wrappedListener, options);\n }\n return super.addEventListener(type, listener, options);\n }\n };\n }\n if (typeof globalThis.MutationObserver !== \"undefined\") {\n const __MutationObserver = globalThis.MutationObserver;\n globalThis.MutationObserver = class extends __MutationObserver {\n constructor(callback) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedCallback = (mutations, observer) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, callback, void 0, mutations, observer);\n };\n super(wrappedCallback);\n }\n };\n }\n if (typeof globalThis.ResizeObserver !== \"undefined\") {\n const __ResizeObserver = globalThis.ResizeObserver;\n globalThis.ResizeObserver = class extends __ResizeObserver {\n constructor(callback) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedCallback = (entries, observer) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, callback, void 0, entries, observer);\n };\n super(wrappedCallback);\n }\n };\n }\n if (typeof globalThis.IntersectionObserver !== \"undefined\") {\n const __IntersectionObserver = globalThis.IntersectionObserver;\n globalThis.IntersectionObserver = class extends __IntersectionObserver {\n constructor(callback, options) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedCallback = (entries, observer) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, callback, void 0, entries, observer);\n };\n super(wrappedCallback, options);\n }\n };\n }\n if (typeof globalThis.Worker !== \"undefined\") {\n const __Worker = globalThis.Worker;\n globalThis.Worker = class extends __Worker {\n constructor(scriptURL, options) {\n super(scriptURL, options);\n this._userHandlers = /* @__PURE__ */ new Map();\n const eventHandlerProperties = [\n \"onmessage\",\n \"onmessageerror\",\n \"onerror\"\n ];\n eventHandlerProperties.forEach((prop) => {\n Object.defineProperty(this, prop, {\n get: () => this._userHandlers.get(prop) || null,\n set: (newHandler) => {\n this._userHandlers.set(prop, newHandler);\n if (newHandler && typeof newHandler === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedHandler = function(event) {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, newHandler, this, event);\n };\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, wrappedHandler);\n } else {\n this[`_${prop}`] = wrappedHandler;\n }\n } else {\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, null);\n } else {\n this[`_${prop}`] = null;\n }\n }\n },\n configurable: true,\n enumerable: true\n });\n });\n }\n addEventListener(type, listener, options) {\n const capturedLogicalContext = currentLogicalContext;\n if (!listener) {\n return super.addEventListener(type, listener, options);\n }\n if (typeof listener === \"function\") {\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return super.addEventListener(type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return super.addEventListener(type, wrappedListener, options);\n }\n return super.addEventListener(type, listener, options);\n }\n };\n }\n if (typeof globalThis.MessagePort !== \"undefined\") {\n const __MessagePort = globalThis.MessagePort;\n const createMessagePortWrapper = (originalPort) => {\n const _userHandlers = /* @__PURE__ */ new Map();\n const eventHandlerProperties = [\"onmessage\", \"onmessageerror\"];\n eventHandlerProperties.forEach((prop) => {\n Object.defineProperty(originalPort, prop, {\n get: () => _userHandlers.get(prop) || null,\n set: (newHandler) => {\n _userHandlers.set(prop, newHandler);\n if (newHandler && typeof newHandler === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedHandler = function(event) {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, newHandler, this, event);\n };\n const descriptor = Object.getOwnPropertyDescriptor(__MessagePort.prototype, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(originalPort, wrappedHandler);\n }\n } else {\n const descriptor = Object.getOwnPropertyDescriptor(__MessagePort.prototype, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(originalPort, null);\n }\n }\n },\n configurable: true,\n enumerable: true\n });\n });\n const originalAddEventListener = originalPort.addEventListener;\n originalPort.addEventListener = function(type, listener, options) {\n const capturedLogicalContext = currentLogicalContext;\n if (!listener) {\n return originalAddEventListener.call(this, type, listener, options);\n }\n if (typeof listener === \"function\") {\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return originalAddEventListener.call(this, type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return originalAddEventListener.call(this, type, wrappedListener, options);\n }\n return originalAddEventListener.call(this, type, listener, options);\n };\n return originalPort;\n };\n if (typeof globalThis.MessageChannel !== \"undefined\") {\n const __MessageChannel = globalThis.MessageChannel;\n globalThis.MessageChannel = class extends __MessageChannel {\n constructor() {\n super();\n createMessagePortWrapper(this.port1);\n createMessagePortWrapper(this.port2);\n }\n };\n }\n }\n};\nconst setLogicalContextValue = (key, value) => {\n prepare();\n if (value !== void 0) {\n currentLogicalContext.data.set(key, value);\n } else {\n currentLogicalContext.data.delete(key);\n }\n};\nconst getLogicalContextValue = (key) => {\n prepare();\n return currentLogicalContext.data.get(key);\n};\nconst runOnNewLogicalContext = (prefix, handler) => {\n const previousLogicalContext = currentLogicalContext;\n setCurrentLogicalContext(createLogicalContext(Symbol(`${prefix}-${crypto.randomUUID()}`)));\n try {\n return handler();\n } finally {\n setCurrentLogicalContext(previousLogicalContext);\n }\n};\nconst getCurrentLogicalContextId = () => {\n prepare();\n return currentLogicalContext.id;\n};\nconst createAsyncLocal = () => {\n const key = Symbol(`async-local-${crypto.randomUUID()}`);\n return {\n setValue: (value) => {\n setLogicalContextValue(key, value);\n },\n getValue: () => {\n return getLogicalContextValue(key);\n }\n };\n};\nexport {\n createAsyncLocal,\n createAsyncLock,\n createDeferred,\n createDeferredGenerator,\n createManuallySignal,\n createSignal,\n defer,\n delay,\n getCurrentLogicalContextId,\n getLogicalContextValue,\n onAbort,\n runOnNewLogicalContext,\n setLogicalContextValue\n};\n","// screw-up - Easy package metadata inserter on Vite plugin\n// Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/screw-up/\n\nimport type { Plugin } from 'vite';\nimport { readFile, writeFile, readdir, mkdir } from 'fs/promises';\nimport { existsSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { createAsyncLock } from 'async-primitives';\nimport { resolvePackageMetadata, createConsoleLogger } from './internal';\nimport { ScrewUpOptions, PackageMetadata } from './types';\nimport { getFetchGitMetadata } from './analyzer';\nimport { git_commit_hash, name, version } from './generated/packageMetadata';\n\n/**\n * Generate banner string from package.json metadata\n * @param metadata - Package metadata\n * @param outputKeys - Array of keys to output in specified order\n * @returns Banner string\n */\nexport const generateBanner = (metadata: PackageMetadata, outputKeys: string[]): string => {\n const parts: string[] = [];\n \n for (const key of outputKeys) {\n const value = metadata[key];\n if (value) {\n parts.push(`${key}: ${value}`);\n }\n }\n \n return parts.length > 0 ? `/*!\\n * ${parts.join('\\n * ')}\\n */` : '';\n};\n\n/**\n * Insert banner header at appropriate position considering shebang\n * @param content - The content to insert banner into\n * @param banner - The banner header to insert\n * @returns Content with banner header inserted\n */\nconst insertBannerHeader = (content: string, banner: string): string => {\n const lines = content.split('\\n');\n \n // Check if first line is shebang\n if (lines.length > 0 && lines[0].startsWith('#!')) {\n // Insert banner after shebang line\n return lines[0] + '\\n' + banner + '\\n' + lines.slice(1).join('\\n');\n } else {\n // Insert banner at the beginning\n return banner + '\\n' + content;\n }\n};\n\n/**\n * Convert string key to valid TypeScript identifier\n * @param key - The key to convert\n * @returns Valid TypeScript identifier\n */\nconst sanitizeKey = (key: string): string => {\n // Replace dots and other invalid characters with underscores\n return key.replace(/[^a-zA-Z0-9_]/g, '_').replace(/^(\\d)/, '_$1');\n};\n\n/**\n * Generate TypeScript metadata file content from package metadata\n * @param metadata - Package metadata\n * @param outputKeys - Array of keys to output\n * @returns TypeScript file content\n */\nconst generateMetadataFile = (metadata: PackageMetadata, outputKeys: string[]): string => {\n const lines: string[] = [];\n \n lines.push('// This file is auto-generated by screw-up plugin');\n lines.push('// Do not edit manually');\n lines.push('');\n \n for (const key of outputKeys) {\n const value = metadata[key];\n if (value) {\n const sanitizedKey = sanitizeKey(key);\n const escapedValue = JSON.stringify(value);\n lines.push(`export const ${sanitizedKey} = ${escapedValue};`);\n }\n }\n \n lines.push('');\n \n return lines.join('\\n');\n};\n\n/**\n * Generate TypeScript type definition file content from output keys\n * @param outputKeys - Array of keys to output\n * @returns TypeScript type definition file content\n */\nconst generateMetadataTypeFile = (outputKeys: string[]): string => {\n const lines: string[] = [];\n \n lines.push('// This file is auto-generated by screw-up plugin');\n lines.push('// Do not edit manually');\n lines.push('');\n \n for (const key of outputKeys) {\n const sanitizedKey = sanitizeKey(key);\n lines.push(`export declare const ${sanitizedKey}: string;`);\n }\n \n lines.push('');\n \n return lines.join('\\n');\n};\n\n/////////////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Vite plugin that adds banner to the bundled code\n * @param options - Plugin options\n * @returns Vite plugin\n */\nexport const screwUp = (options: ScrewUpOptions = {}): Plugin => {\n const {\n outputKeys = ['name', 'version', 'description', 'author', 'license', 'repository.url', 'git.commit.hash'],\n assetFilters = ['\\\\.d\\\\.ts$'],\n outputMetadataFile = false,\n outputMetadataFilePath = 'src/generated/packageMetadata.ts',\n outputMetadataFileTypePath,\n outputMetadataKeys = ['name', 'version', 'description', 'author', 'license', 'repository.url', 'git.commit.hash'],\n checkWorkingDirectoryStatus = true,\n alwaysOverrideVersionFromGit = true,\n insertMetadataBanner = true} = options;\n\n const assetFiltersRegex = assetFilters.map(filter => new RegExp(filter));\n\n // Generate default type definition file path if not provided\n const resolvedOutputMetadataFileTypePath = outputMetadataFileTypePath || \n outputMetadataFilePath.replace(/\\.ts$/, '.d.ts');\n const generateMetadataSourceLocker = createAsyncLock();\n\n const loggerPrefix = `${name}-vite`;\n let logger = createConsoleLogger(loggerPrefix);\n let banner: string;\n let metadata: any;\n let projectRoot: string;\n let fetchGitMetadata = () => Promise.resolve<any>({});\n\n // Helper function to write file if content has changed\n const writeFileIfChanged = async (filePath: string, content: string, description: string): Promise<boolean> => {\n try {\n // Check if file exists and compare content\n let shouldWrite = !existsSync(filePath);\n if (!shouldWrite) {\n try {\n const existingContent = await readFile(filePath, 'utf-8');\n shouldWrite = existingContent !== content;\n } catch {\n // File doesn't exist or couldn't read, we should write it\n shouldWrite = true;\n }\n }\n\n if (shouldWrite) {\n // Ensure directory exists\n await mkdir(dirname(filePath), { recursive: true });\n // Write file only if content has changed\n await writeFile(filePath, content);\n return true;\n } else {\n // File content is the same, no need to write\n return false;\n }\n } catch (error) {\n logger.warn(`Failed to write ${description}: ${filePath}: ${error}`);\n return false;\n }\n };\n\n // Generate and write metadata TypeScript file\n const generateMetadataSourceFile = async () => {\n // Resolve package metadata\n const result = await resolvePackageMetadata(\n projectRoot, fetchGitMetadata, alwaysOverrideVersionFromGit, logger);\n metadata = result.metadata;\n // Regenerate banner with updated metadata\n banner = generateBanner(metadata, outputKeys);\n if (outputMetadataFile) {\n const metadataSourceContent = generateMetadataFile(metadata, outputMetadataKeys);\n const metadataSourcePath = join(projectRoot, outputMetadataFilePath);\n return await writeFileIfChanged(metadataSourcePath, metadataSourceContent, 'metadata source file');\n }\n return false;\n };\n\n // Generate and write metadata TypeScript type definition file\n const generateMetadataTypeDefinitionFile = async () => {\n if (outputMetadataFile) {\n const metadataTypeContent = generateMetadataTypeFile(outputMetadataKeys);\n const metadataTypePath = join(projectRoot, resolvedOutputMetadataFileTypePath);\n return await writeFileIfChanged(metadataTypePath, metadataTypeContent, 'metadata type definition file');\n }\n return false;\n };\n\n // Generate dummy metadata TypeScript file with empty string values\n const generateDummyMetadataFile = async () => {\n if (outputMetadataFile) {\n const metadataSourcePath = join(projectRoot, outputMetadataFilePath);\n // Only generate if file doesn't exist (don't overwrite existing files)\n if (!existsSync(metadataSourcePath)) {\n // Create dummy metadata with empty strings for all keys\n const dummyMetadata: any = {};\n outputMetadataKeys.forEach(key => {\n dummyMetadata[key] = '[Require first build]';\n });\n const dummyContent = generateMetadataFile(dummyMetadata, outputMetadataKeys);\n return await writeFileIfChanged(metadataSourcePath, dummyContent, 'dummy metadata source file');\n }\n }\n return false;\n };\n\n return {\n name: 'screw-up',\n // Ensure screw-up runs before other plugins\n // (especially vite-plugin-dts, avoid packageMetadata.ts is not found)\n enforce: 'pre',\n // Plugin starting\n applyToEnvironment: async () => {\n logger.info(`${version}-${git_commit_hash}: Started.`);\n \n // Generate type definition file early since it doesn't require actual metadata values\n if (projectRoot && await generateMetadataTypeDefinitionFile()) {\n logger.info(`applyToEnvironment: Metadata type definition file is generated: ${resolvedOutputMetadataFileTypePath}`);\n }\n \n // Generate dummy metadata source file to prevent import errors on initial build\n if (projectRoot && await generateDummyMetadataFile()) {\n logger.info(`applyToEnvironment: Dummy metadata source file is generated: ${outputMetadataFilePath}`);\n }\n \n return true;\n },\n // Configuration resolved phase\n configResolved: async config => {\n // Avoid race conditions.\n const l = await generateMetadataSourceLocker.lock();\n try {\n logger.debug(`configResolved: Started.`);\n\n // Save project root\n projectRoot = config.root;\n if (config?.logger) {\n logger = createConsoleLogger(loggerPrefix, config.logger);\n } else if (config?.customLogger) {\n logger = createConsoleLogger(loggerPrefix, config.customLogger);\n }\n // Get Git metadata fetcher function\n fetchGitMetadata = getFetchGitMetadata(\n projectRoot, checkWorkingDirectoryStatus, logger);\n // Generate metadata TypeScript file early to ensure it's available during TypeScript compilation\n if (await generateMetadataSourceFile()) {\n logger.info(`configResolved: Metadata source file is generated: ${outputMetadataFilePath}`);\n }\n } finally {\n logger.debug(`configResolved: Exited.`);\n l.release();\n }\n },\n // Server hook\n configureServer: async (server) => {\n // Avoid race conditions.\n const l = await generateMetadataSourceLocker.lock();\n try {\n logger.debug(`configureServer: Started.`);\n\n // Exclude generated metadata file from watcher to prevent infinite loop\n if (outputMetadataFile && server.watcher) {\n const metadataSourcePath = join(projectRoot, outputMetadataFilePath);\n // Use unwatch to exclude the file from being watched\n server.watcher.unwatch(metadataSourcePath);\n logger.debug(`configureServer: Excluded from watcher: ${outputMetadataFilePath}`);\n }\n\n if (await generateMetadataSourceFile()) {\n logger.info(`configureServer: Metadata source file is generated: ${outputMetadataFilePath}`);\n }\n } finally {\n logger.debug(`configureServer: Exited.`);\n l.release();\n }\n },\n // Build start phase\n buildStart: async () => {\n // Avoid race conditions.\n const l = await generateMetadataSourceLocker.lock();\n try {\n logger.debug(`buildStart: Started.`);\n // Re-resolve package metadata to capture any changes since configResolved\n // Update metadata TypeScript file with latest data\n if (await generateMetadataSourceFile()) {\n logger.info(`buildStart: Metadata source file is generated: ${outputMetadataFilePath}`);\n }\n } finally {\n logger.debug(`buildStart: Exited.`);\n l.release();\n }\n },\n // Generate bundle phase\n generateBundle: (_options, bundle) => {\n // Add banner to each output file if enabled\n if (insertMetadataBanner) {\n let count = 0;\n for (const fileName in bundle) {\n const chunk = bundle[fileName];\n if (chunk.type === 'chunk') {\n chunk.code = insertBannerHeader(chunk.code, banner);\n count++;\n } else if (chunk.type === 'asset' && assetFiltersRegex.some(filter => filter.test(fileName))) {\n if (typeof chunk.source === 'string') {\n chunk.source = insertBannerHeader(chunk.source, banner + '\\n'); // insert more blank line\n count++;\n }\n }\n }\n if (count >= 1) {\n logger.debug(`generateBundle: Banner header inserted: ${count} file(s)`);\n }\n }\n },\n // Write bundle phase\n writeBundle: async options => {\n // Handle files written by other plugins (like vite-plugin-dts) if banner insertion is enabled\n if (!insertMetadataBanner || !options.dir) return;\n\n try {\n // Read all files in the output directory\n const files = await readdir(options.dir, { recursive: true });\n\n // Iterate over all files\n let count = 0;\n for (const file of files) {\n const filePath = join(options.dir, file);\n\n // Check if the file is target asset file\n if (assetFiltersRegex.some(filter => filter.test(file))) {\n try {\n // Read the asset file\n const content = await readFile(filePath, 'utf-8');\n // Append banner to the asset file if it doesn't already contain it\n if (!content.includes(banner)) {\n await writeFile(filePath, insertBannerHeader(content, banner + '\\n'));\n count++;\n }\n } catch (error) {\n // Skip files that can't be read/written\n }\n }\n }\n if (count >= 1) {\n logger.debug(`writeBundle: Banner header inserted: ${count} file(s)`);\n }\n } catch (error) {\n // Skip files that can't be read/written\n }\n }\n };\n};\n"],"names":["name","createConsoleLogger","existsSync","readFile","mkdir","dirname","writeFile","resolvePackageMetadata","join","version","git_commit_hash","getFetchGitMetadata","options","readdir"],"mappings":";;;;;AAAA,MAAM,iBAAiB,MAAM;AAC7B;AACA,MAAM,oBAAoB;AAAA,EACxB,SAAS;AAAA,EACT,CAAC,OAAO,OAAO,GAAG;AACpB;AACA,MAAM,UAAU,CAAC,QAAQ,aAAa;AACpC,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AACA,MAAI,OAAO,SAAS;AAClB,QAAI;AACF,eAAQ;AAAA,IACV,SAAS,OAAO;AACd,cAAQ,KAAK,8BAA8B,KAAK;AAAA,IAClD;AACA,WAAO;AAAA,EACT;AACA,MAAI;AACJ,iBAAe,MAAM;AACnB,QAAI,cAAc;AAChB,aAAO,oBAAoB,SAAS,YAAY;AAChD,qBAAe;AACf,UAAI;AACF,iBAAQ;AAAA,MACV,SAAS,OAAO;AACd,gBAAQ,KAAK,8BAA8B,KAAK;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AACA,QAAM,UAAU,MAAM;AACpB,QAAI,cA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AS,IAAI,CAAC;AACpE;AAAA,cACF;AAAA,YACF,SAAS,OAAO;AAAA,YAEhB;AAAA,UACF;AAAA,QACF;AACA,YAAI,SAAS,GAAG;AACd,iBAAO,MAAM,wCAAwC,KAAK,UAAU;AAAA,QACtE;AAAA,MACF,SAAS,OAAO;AAAA,MAEhB;AAAA,IACF;AAAA,EAAA;AAEJ;;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../node_modules/async-primitives/dist/async-primitives.js","../src/vite-plugin.ts"],"sourcesContent":["const __NOOP_HANDLER = () => {\n};\nconst __NOOP_RELEASABLE = {\n release: __NOOP_HANDLER,\n [Symbol.dispose]: __NOOP_HANDLER\n};\nconst onAbort = (signal, callback) => {\n if (!signal) {\n return __NOOP_RELEASABLE;\n }\n if (signal.aborted) {\n try {\n callback();\n } catch (error) {\n console.warn(\"AbortHook callback error: \", error);\n }\n return __NOOP_RELEASABLE;\n }\n let abortHandler;\n abortHandler = () => {\n if (abortHandler) {\n signal.removeEventListener(\"abort\", abortHandler);\n abortHandler = void 0;\n try {\n callback();\n } catch (error) {\n console.warn(\"AbortHook callback error: \", error);\n }\n }\n };\n const release = () => {\n if (abortHandler) {\n signal.removeEventListener(\"abort\", abortHandler);\n abortHandler = void 0;\n }\n };\n signal.addEventListener(\"abort\", abortHandler, { once: true });\n const handle = {\n release,\n [Symbol.dispose]: release\n };\n return handle;\n};\nconst delay = (msec, signal) => {\n if (signal) {\n if (signal.aborted) {\n throw new Error(\"Delay was aborted\");\n }\n return new Promise((resolve, reject) => {\n const abortHandle = onAbort(signal, () => {\n clearTimeout(timeoutId);\n reject(new Error(\"Delay was aborted\"));\n });\n const timeoutId = setTimeout(() => {\n abortHandle.release();\n resolve();\n }, msec);\n });\n } else {\n return new Promise((resolve) => {\n setTimeout(resolve, msec);\n });\n }\n};\nconst defer = (fn) => {\n if (typeof setImmediate === \"function\") {\n setImmediate(fn);\n } else {\n setTimeout(fn, 0);\n }\n};\nconst ABORTED_ERROR = () => new Error(\"Lock acquisition was aborted\");\nconst createLockHandle = (releaseCallback) => {\n let isActive = true;\n const release = () => {\n if (!isActive) {\n return;\n }\n isActive = false;\n releaseCallback();\n };\n return {\n get isActive() {\n return isActive;\n },\n release,\n [Symbol.dispose]: release\n };\n};\nconst createAsyncLock = (maxConsecutiveCalls = 20) => {\n let isLocked = false;\n const queue = [];\n let count = 0;\n const processQueue = () => {\n var _a;\n if (isLocked || queue.length === 0) {\n return;\n }\n const item = queue.shift();\n if ((_a = item.signal) == null ? void 0 : _a.aborted) {\n item.reject(ABORTED_ERROR());\n scheduleNextProcess();\n return;\n }\n isLocked = true;\n const lockHandle = createLockHandle(releaseLock);\n item.resolve(lockHandle);\n };\n const scheduleNextProcess = () => {\n count++;\n if (count >= maxConsecutiveCalls) {\n count = 0;\n defer(processQueue);\n } else {\n processQueue();\n }\n };\n const releaseLock = () => {\n if (!isLocked) {\n return;\n }\n isLocked = false;\n scheduleNextProcess();\n };\n const removeFromQueue = (item) => {\n const index = queue.indexOf(item);\n if (index !== -1) {\n queue.splice(index, 1);\n }\n };\n const lock = async (signal) => {\n if (signal) {\n if (signal.aborted) {\n throw ABORTED_ERROR();\n }\n return new Promise((resolve, reject) => {\n const queueItem = {\n resolve: void 0,\n reject: void 0,\n signal\n };\n const abortHandle = onAbort(signal, () => {\n removeFromQueue(queueItem);\n reject(ABORTED_ERROR());\n });\n queueItem.resolve = (handle) => {\n abortHandle.release();\n resolve(handle);\n };\n queueItem.reject = (error) => {\n abortHandle.release();\n reject(error);\n };\n queue.push(queueItem);\n processQueue();\n });\n } else {\n return new Promise((resolve, reject) => {\n queue.push({\n resolve,\n reject\n });\n processQueue();\n });\n }\n };\n return {\n lock,\n get isLocked() {\n return isLocked;\n },\n get pendingCount() {\n return queue.length;\n }\n };\n};\nconst createDeferred = (signal) => {\n let resolve;\n let reject;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n const disposer = onAbort(signal, () => {\n const _reject = reject;\n if (_reject) {\n resolve = void 0;\n reject = void 0;\n _reject(new Error(\"Deferred aborted\"));\n }\n });\n return {\n // The promise that resolves to the result\n promise,\n // Resolve the promise with a result\n resolve: (value) => {\n const _resolve = resolve;\n if (_resolve) {\n resolve = void 0;\n reject = void 0;\n disposer.release();\n _resolve(value);\n }\n },\n // Reject the promise with an error\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n reject: (error) => {\n const _reject = reject;\n if (_reject) {\n resolve = void 0;\n reject = void 0;\n disposer.release();\n _reject(error);\n }\n }\n };\n};\nconst createSignal = () => {\n const waiters = [];\n return {\n trigger: () => {\n if (waiters.length >= 1) {\n waiters.shift().resolve();\n }\n },\n wait: async (signal) => {\n if (signal == null ? void 0 : signal.aborted) {\n throw new Error(\"Signal aborted\");\n }\n const waiter = createDeferred();\n waiters.push(waiter);\n const disposer = onAbort(signal, () => {\n waiters.splice(waiters.indexOf(waiter), 1);\n waiter.reject(new Error(\"Signal aborted\"));\n });\n try {\n await waiter.promise;\n } finally {\n disposer.release();\n }\n }\n };\n};\nconst createManuallySignal = (initialState) => {\n const waiters = [];\n let raised = initialState != null ? initialState : false;\n return {\n trigger: () => {\n raised = false;\n const waiter = waiters.shift();\n if (waiter) {\n waiter.resolve();\n raised = false;\n }\n },\n raise: () => {\n while (waiters.length >= 1) {\n raised = true;\n waiters.shift().resolve();\n }\n raised = true;\n },\n drop: () => {\n raised = false;\n },\n wait: async (signal) => {\n if (raised) {\n return;\n }\n if (signal == null ? void 0 : signal.aborted) {\n throw new Error(\"Signal aborted\");\n }\n const waiter = createDeferred();\n waiters.push(waiter);\n const disposer = onAbort(signal, () => {\n waiters.splice(waiters.indexOf(waiter), 1);\n waiter.reject(new Error(\"Signal aborted\"));\n });\n try {\n await waiter.promise;\n } finally {\n disposer.release();\n }\n }\n };\n};\nconst createDeferredGenerator = (options) => {\n const maxItemReserved = options == null ? void 0 : options.maxItemReserved;\n const signal = options == null ? void 0 : options.signal;\n const queue = [];\n const arrived = createManuallySignal();\n const canReserve = maxItemReserved ? createManuallySignal(true) : void 0;\n const generator = async function* () {\n while (true) {\n while (true) {\n const item = queue.shift();\n if (maxItemReserved && queue.length === maxItemReserved - 1) {\n canReserve.raise();\n }\n if (!item) {\n break;\n }\n switch (item.kind) {\n case \"value\":\n yield item.value;\n break;\n case \"completed\":\n return;\n case \"error\":\n throw item.error;\n }\n if (signal == null ? void 0 : signal.aborted) {\n throw new Error(\"Deferred generator aborted\");\n }\n }\n arrived.drop();\n try {\n await arrived.wait(signal);\n } catch (error) {\n if (error instanceof Error && error.message === \"Signal aborted\") {\n error.message = \"Deferred generator aborted\";\n }\n throw error;\n }\n }\n }();\n const enqueue = async (item, signal2) => {\n while (true) {\n if (!maxItemReserved || queue.length < maxItemReserved) {\n const remains = queue.push(item);\n if (remains === 1) {\n arrived.raise();\n }\n if (remains === maxItemReserved) {\n canReserve.drop();\n }\n break;\n }\n try {\n await canReserve.wait(signal2);\n } catch (error) {\n if (error instanceof Error && error.message === \"Signal aborted\") {\n error.message = \"Deferred generator aborted\";\n }\n throw error;\n }\n }\n };\n return {\n // The async generator that yields values\n generator,\n // Yield a value to the generator\n yield: (value, signal2) => enqueue({ kind: \"value\", value }, signal2),\n // Complete the generator (equivalent to return)\n return: (signal2) => enqueue({ kind: \"completed\" }, signal2),\n // Throw an error to the generator\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n throw: (error, signal2) => enqueue({ kind: \"error\", error }, signal2)\n };\n};\nconst createLogicalContext = (id) => {\n return { id, data: /* @__PURE__ */ new Map() };\n};\nlet currentLogicalContext = createLogicalContext(Symbol(\"[root]\"));\nconst setCurrentLogicalContext = (context) => {\n currentLogicalContext = context;\n};\nconst trampoline = (adjustment, callback, thisArg, ...args) => {\n const previousLogicalContext = currentLogicalContext;\n currentLogicalContext = adjustment.contextToUse;\n try {\n return callback.call(thisArg, ...args);\n } finally {\n adjustment.contextAfter = currentLogicalContext;\n currentLogicalContext = previousLogicalContext;\n }\n};\nlet isPrepared = false;\nconst prepare = () => {\n if (isPrepared) {\n return;\n }\n isPrepared = true;\n if (typeof globalThis.setTimeout !== \"undefined\") {\n const __setTimeout = globalThis.setTimeout;\n globalThis.setTimeout = (handler, timeout, ...args) => {\n const capturedLogicalContext = currentLogicalContext;\n return __setTimeout(\n (...args2) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, handler, void 0, ...args2);\n },\n timeout,\n ...args\n );\n };\n }\n if (typeof globalThis.setInterval !== \"undefined\") {\n const __setInterval = globalThis.setInterval;\n globalThis.setInterval = (handler, timeout, ...args) => {\n const capturedLogicalContext = currentLogicalContext;\n return __setInterval(\n (...args2) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, handler, void 0, ...args2);\n },\n timeout,\n ...args\n );\n };\n }\n if (typeof globalThis.queueMicrotask !== \"undefined\") {\n const __queueMicrotask = globalThis.queueMicrotask;\n globalThis.queueMicrotask = (callback) => {\n const capturedLogicalContext = currentLogicalContext;\n return __queueMicrotask(() => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, callback, void 0);\n });\n };\n }\n if (typeof globalThis.setImmediate !== \"undefined\") {\n const __setImmediate = globalThis.setImmediate;\n globalThis.setImmediate = (callback, ...args) => {\n const capturedLogicalContext = currentLogicalContext;\n return __setImmediate((...callbackArgs) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, callback, void 0, ...callbackArgs);\n }, ...args);\n };\n }\n if (typeof process !== \"undefined\" && process.nextTick) {\n const __nextTick = process.nextTick;\n process.nextTick = (callback, ...args) => {\n const capturedLogicalContext = currentLogicalContext;\n return __nextTick(() => {\n const adjustment = { contextToUse: capturedLogicalContext };\n trampoline(adjustment, callback, void 0, ...args);\n });\n };\n }\n if (typeof Promise !== \"undefined\") {\n const __then = Promise.prototype.then;\n const __catch = Promise.prototype.catch;\n const __finally = Promise.prototype.finally;\n Promise.prototype.then = function(onFulfilled, onRejected) {\n const capturedLogicalContext = currentLogicalContext;\n const resultPromise = __then.call(\n this,\n onFulfilled ? (value) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, onFulfilled, void 0, value);\n } : void 0,\n onRejected ? (reason) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, onRejected, void 0, reason);\n } : void 0\n );\n return resultPromise;\n };\n Promise.prototype.catch = function(onRejected) {\n const capturedLogicalContext = currentLogicalContext;\n const resultPromise = __catch.call(\n this,\n onRejected ? (reason) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, onRejected, void 0, reason);\n } : void 0\n );\n return resultPromise;\n };\n Promise.prototype.finally = function(onFinally) {\n const capturedLogicalContext = currentLogicalContext;\n const resultPromise = __finally.call(\n this,\n onFinally ? () => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, onFinally, void 0);\n } : void 0\n );\n return resultPromise;\n };\n }\n if (typeof EventTarget !== \"undefined\" && EventTarget.prototype && EventTarget.prototype.addEventListener) {\n const __eventTargetAddEventListener = EventTarget.prototype.addEventListener;\n EventTarget.prototype.addEventListener = function(type, listener, options) {\n if (listener === null || listener === void 0) {\n return __eventTargetAddEventListener.call(this, type, listener, options);\n }\n if (typeof listener === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return __eventTargetAddEventListener.call(this, type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return __eventTargetAddEventListener.call(this, type, wrappedListener, options);\n }\n return __eventTargetAddEventListener.call(this, type, listener, options);\n };\n }\n if (typeof Element !== \"undefined\" && Element.prototype && Element.prototype.addEventListener) {\n const __elementAddEventListener = Element.prototype.addEventListener;\n Element.prototype.addEventListener = function(type, listener, options) {\n if (listener === null || listener === void 0) {\n return __elementAddEventListener.call(this, type, listener, options);\n }\n if (typeof listener === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return __elementAddEventListener.call(this, type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return __elementAddEventListener.call(this, type, wrappedListener, options);\n }\n return __elementAddEventListener.call(this, type, listener, options);\n };\n }\n if (typeof globalThis.requestAnimationFrame !== \"undefined\") {\n const __requestAnimationFrame = globalThis.requestAnimationFrame;\n globalThis.requestAnimationFrame = (callback) => {\n const capturedLogicalContext = currentLogicalContext;\n return __requestAnimationFrame((time) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, callback, void 0, time);\n });\n };\n }\n if (typeof globalThis.XMLHttpRequest !== \"undefined\") {\n const __XMLHttpRequest = globalThis.XMLHttpRequest;\n globalThis.XMLHttpRequest = class extends __XMLHttpRequest {\n constructor() {\n super();\n this._userHandlers = /* @__PURE__ */ new Map();\n const eventHandlerProperties = [\n \"onreadystatechange\",\n \"onloadstart\",\n \"onprogress\",\n \"onabort\",\n \"onerror\",\n \"onload\",\n \"ontimeout\",\n \"onloadend\"\n ];\n eventHandlerProperties.forEach((prop) => {\n Object.defineProperty(this, prop, {\n get: () => this._userHandlers.get(prop) || null,\n set: (newHandler) => {\n this._userHandlers.set(prop, newHandler);\n if (newHandler && typeof newHandler === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedHandler = function(event) {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, newHandler, this, event);\n };\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, wrappedHandler);\n } else {\n this[`_${prop}`] = wrappedHandler;\n }\n } else {\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, null);\n } else {\n this[`_${prop}`] = null;\n }\n }\n },\n configurable: true,\n enumerable: true\n });\n });\n }\n addEventListener(type, listener, options) {\n const capturedLogicalContext = currentLogicalContext;\n if (!listener) {\n return super.addEventListener(type, listener, options);\n }\n if (typeof listener === \"function\") {\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return super.addEventListener(type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return super.addEventListener(type, wrappedListener, options);\n }\n return super.addEventListener(type, listener, options);\n }\n };\n }\n if (typeof globalThis.WebSocket !== \"undefined\") {\n const __WebSocket = globalThis.WebSocket;\n globalThis.WebSocket = class extends __WebSocket {\n constructor(url, protocols) {\n super(url, protocols);\n this._userHandlers = /* @__PURE__ */ new Map();\n const eventHandlerProperties = [\n \"onopen\",\n \"onmessage\",\n \"onerror\",\n \"onclose\"\n ];\n eventHandlerProperties.forEach((prop) => {\n Object.defineProperty(this, prop, {\n get: () => this._userHandlers.get(prop) || null,\n set: (newHandler) => {\n this._userHandlers.set(prop, newHandler);\n if (newHandler && typeof newHandler === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedHandler = function(event) {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, newHandler, this, event);\n };\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, wrappedHandler);\n } else {\n this[`_${prop}`] = wrappedHandler;\n }\n } else {\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, null);\n } else {\n this[`_${prop}`] = null;\n }\n }\n },\n configurable: true,\n enumerable: true\n });\n });\n }\n addEventListener(type, listener, options) {\n const capturedLogicalContext = currentLogicalContext;\n if (!listener) {\n return super.addEventListener(type, listener, options);\n }\n if (typeof listener === \"function\") {\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return super.addEventListener(type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return super.addEventListener(type, wrappedListener, options);\n }\n return super.addEventListener(type, listener, options);\n }\n };\n }\n if (typeof globalThis.MutationObserver !== \"undefined\") {\n const __MutationObserver = globalThis.MutationObserver;\n globalThis.MutationObserver = class extends __MutationObserver {\n constructor(callback) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedCallback = (mutations, observer) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, callback, void 0, mutations, observer);\n };\n super(wrappedCallback);\n }\n };\n }\n if (typeof globalThis.ResizeObserver !== \"undefined\") {\n const __ResizeObserver = globalThis.ResizeObserver;\n globalThis.ResizeObserver = class extends __ResizeObserver {\n constructor(callback) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedCallback = (entries, observer) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, callback, void 0, entries, observer);\n };\n super(wrappedCallback);\n }\n };\n }\n if (typeof globalThis.IntersectionObserver !== \"undefined\") {\n const __IntersectionObserver = globalThis.IntersectionObserver;\n globalThis.IntersectionObserver = class extends __IntersectionObserver {\n constructor(callback, options) {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedCallback = (entries, observer) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, callback, void 0, entries, observer);\n };\n super(wrappedCallback, options);\n }\n };\n }\n if (typeof globalThis.Worker !== \"undefined\") {\n const __Worker = globalThis.Worker;\n globalThis.Worker = class extends __Worker {\n constructor(scriptURL, options) {\n super(scriptURL, options);\n this._userHandlers = /* @__PURE__ */ new Map();\n const eventHandlerProperties = [\n \"onmessage\",\n \"onmessageerror\",\n \"onerror\"\n ];\n eventHandlerProperties.forEach((prop) => {\n Object.defineProperty(this, prop, {\n get: () => this._userHandlers.get(prop) || null,\n set: (newHandler) => {\n this._userHandlers.set(prop, newHandler);\n if (newHandler && typeof newHandler === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedHandler = function(event) {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, newHandler, this, event);\n };\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, wrappedHandler);\n } else {\n this[`_${prop}`] = wrappedHandler;\n }\n } else {\n const parentProto = Object.getPrototypeOf(Object.getPrototypeOf(this));\n const descriptor = Object.getOwnPropertyDescriptor(parentProto, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(this, null);\n } else {\n this[`_${prop}`] = null;\n }\n }\n },\n configurable: true,\n enumerable: true\n });\n });\n }\n addEventListener(type, listener, options) {\n const capturedLogicalContext = currentLogicalContext;\n if (!listener) {\n return super.addEventListener(type, listener, options);\n }\n if (typeof listener === \"function\") {\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return super.addEventListener(type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return super.addEventListener(type, wrappedListener, options);\n }\n return super.addEventListener(type, listener, options);\n }\n };\n }\n if (typeof globalThis.MessagePort !== \"undefined\") {\n const __MessagePort = globalThis.MessagePort;\n const createMessagePortWrapper = (originalPort) => {\n const _userHandlers = /* @__PURE__ */ new Map();\n const eventHandlerProperties = [\"onmessage\", \"onmessageerror\"];\n eventHandlerProperties.forEach((prop) => {\n Object.defineProperty(originalPort, prop, {\n get: () => _userHandlers.get(prop) || null,\n set: (newHandler) => {\n _userHandlers.set(prop, newHandler);\n if (newHandler && typeof newHandler === \"function\") {\n const capturedLogicalContext = currentLogicalContext;\n const wrappedHandler = function(event) {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, newHandler, this, event);\n };\n const descriptor = Object.getOwnPropertyDescriptor(__MessagePort.prototype, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(originalPort, wrappedHandler);\n }\n } else {\n const descriptor = Object.getOwnPropertyDescriptor(__MessagePort.prototype, prop);\n if (descriptor && descriptor.set) {\n descriptor.set.call(originalPort, null);\n }\n }\n },\n configurable: true,\n enumerable: true\n });\n });\n const originalAddEventListener = originalPort.addEventListener;\n originalPort.addEventListener = function(type, listener, options) {\n const capturedLogicalContext = currentLogicalContext;\n if (!listener) {\n return originalAddEventListener.call(this, type, listener, options);\n }\n if (typeof listener === \"function\") {\n const wrappedListener = (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, listener, event.currentTarget, event);\n };\n return originalAddEventListener.call(this, type, wrappedListener, options);\n } else if (typeof listener === \"object\" && \"handleEvent\" in listener) {\n const wrappedListener = {\n handleEvent: (event) => {\n const adjustment = { contextToUse: capturedLogicalContext };\n return trampoline(adjustment, () => listener.handleEvent(event));\n }\n };\n return originalAddEventListener.call(this, type, wrappedListener, options);\n }\n return originalAddEventListener.call(this, type, listener, options);\n };\n return originalPort;\n };\n if (typeof globalThis.MessageChannel !== \"undefined\") {\n const __MessageChannel = globalThis.MessageChannel;\n globalThis.MessageChannel = class extends __MessageChannel {\n constructor() {\n super();\n createMessagePortWrapper(this.port1);\n createMessagePortWrapper(this.port2);\n }\n };\n }\n }\n};\nconst setLogicalContextValue = (key, value) => {\n prepare();\n if (value !== void 0) {\n currentLogicalContext.data.set(key, value);\n } else {\n currentLogicalContext.data.delete(key);\n }\n};\nconst getLogicalContextValue = (key) => {\n prepare();\n return currentLogicalContext.data.get(key);\n};\nconst runOnNewLogicalContext = (prefix, handler) => {\n const previousLogicalContext = currentLogicalContext;\n setCurrentLogicalContext(createLogicalContext(Symbol(`${prefix}-${crypto.randomUUID()}`)));\n try {\n return handler();\n } finally {\n setCurrentLogicalContext(previousLogicalContext);\n }\n};\nconst getCurrentLogicalContextId = () => {\n prepare();\n return currentLogicalContext.id;\n};\nconst createAsyncLocal = () => {\n const key = Symbol(`async-local-${crypto.randomUUID()}`);\n return {\n setValue: (value) => {\n setLogicalContextValue(key, value);\n },\n getValue: () => {\n return getLogicalContextValue(key);\n }\n };\n};\nexport {\n createAsyncLocal,\n createAsyncLock,\n createDeferred,\n createDeferredGenerator,\n createManuallySignal,\n createSignal,\n defer,\n delay,\n getCurrentLogicalContextId,\n getLogicalContextValue,\n onAbort,\n runOnNewLogicalContext,\n setLogicalContextValue\n};\n","// screw-up - Easy package metadata inserter on Vite plugin\n// Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/screw-up/\n\nimport type { Plugin } from \"vite\";\nimport { readFile, writeFile, readdir, mkdir } from \"fs/promises\";\nimport { existsSync } from \"fs\";\nimport { join, dirname } from \"path\";\nimport { createAsyncLock } from \"async-primitives\";\nimport { resolvePackageMetadata, createConsoleLogger } from \"./internal\";\nimport { ScrewUpOptions, PackageMetadata } from \"./types\";\nimport { getFetchGitMetadata } from \"./analyzer\";\nimport { git_commit_hash, name, version } from \"./generated/packageMetadata\";\n\n/**\n * Generate banner string from package.json metadata\n * @param metadata - Package metadata\n * @param outputKeys - Array of keys to output in specified order\n * @returns Banner string\n */\nexport const generateBanner = (\n metadata: PackageMetadata,\n outputKeys: string[],\n): string => {\n const parts: string[] = [];\n\n for (const key of outputKeys) {\n const value = metadata[key];\n if (value) {\n parts.push(`${key}: ${value}`);\n }\n }\n\n return parts.length > 0 ? `/*!\\n * ${parts.join(\"\\n * \")}\\n */` : \"\";\n};\n\n/**\n * Insert banner header at appropriate position considering shebang\n * @param content - The content to insert banner into\n * @param banner - The banner header to insert\n * @returns Content with banner header inserted\n */\nconst insertBannerHeader = (content: string, banner: string): string => {\n const lines = content.split(\"\\n\");\n\n // Check if first line is shebang\n if (lines.length > 0 && lines[0].startsWith(\"#!\")) {\n // Insert banner after shebang line\n return lines[0] + \"\\n\" + banner + \"\\n\" + lines.slice(1).join(\"\\n\");\n } else {\n // Insert banner at the beginning\n return banner + \"\\n\" + content;\n }\n};\n\n/**\n * Convert string key to valid TypeScript identifier\n * @param key - The key to convert\n * @returns Valid TypeScript identifier\n */\nconst sanitizeKey = (key: string): string => {\n // Replace dots and other invalid characters with underscores\n return key.replace(/[^a-zA-Z0-9_]/g, \"_\").replace(/^(\\d)/, \"_$1\");\n};\n\n/**\n * Generate TypeScript metadata file content from package metadata\n * @param metadata - Package metadata\n * @param outputKeys - Array of keys to output\n * @returns TypeScript file content\n */\nconst generateMetadataFile = (\n metadata: PackageMetadata,\n outputKeys: string[],\n): string => {\n const lines: string[] = [];\n\n lines.push(\"// This file is auto-generated by screw-up plugin\");\n lines.push(\"// Do not edit manually\");\n lines.push(\"\");\n\n for (const key of outputKeys) {\n const value = metadata[key];\n if (value) {\n const sanitizedKey = sanitizeKey(key);\n const escapedValue = JSON.stringify(value);\n lines.push(`export const ${sanitizedKey} = ${escapedValue};`);\n }\n }\n\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n};\n\n/**\n * Generate TypeScript type definition file content from output keys\n * @param outputKeys - Array of keys to output\n * @returns TypeScript type definition file content\n */\nconst generateMetadataTypeFile = (outputKeys: string[]): string => {\n const lines: string[] = [];\n\n lines.push(\"// This file is auto-generated by screw-up plugin\");\n lines.push(\"// Do not edit manually\");\n lines.push(\"\");\n\n for (const key of outputKeys) {\n const sanitizedKey = sanitizeKey(key);\n lines.push(`export declare const ${sanitizedKey}: string;`);\n }\n\n lines.push(\"\");\n\n return lines.join(\"\\n\");\n};\n\n/////////////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Vite plugin that adds banner to the bundled code\n * @param options - Plugin options\n * @returns Vite plugin\n */\nexport const screwUp = (options: ScrewUpOptions = {}): Plugin => {\n const {\n outputKeys = [\n \"name\",\n \"version\",\n \"description\",\n \"author\",\n \"license\",\n \"repository.url\",\n \"git.commit.hash\",\n ],\n assetFilters = [\"\\\\.d\\\\.ts$\"],\n outputMetadataFile = false,\n outputMetadataFilePath = \"src/generated/packageMetadata.ts\",\n outputMetadataFileTypePath,\n outputMetadataKeys = [\n \"name\",\n \"version\",\n \"description\",\n \"author\",\n \"license\",\n \"repository.url\",\n \"git.commit.hash\",\n ],\n checkWorkingDirectoryStatus = true,\n alwaysOverrideVersionFromGit = true,\n insertMetadataBanner = true,\n } = options;\n\n const assetFiltersRegex = assetFilters.map((filter) => new RegExp(filter));\n\n // Generate default type definition file path if not provided\n const resolvedOutputMetadataFileTypePath =\n outputMetadataFileTypePath ||\n outputMetadataFilePath.replace(/\\.ts$/, \".d.ts\");\n const generateMetadataSourceLocker = createAsyncLock();\n\n const loggerPrefix = `${name}-vite`;\n let logger = createConsoleLogger(loggerPrefix);\n let banner: string;\n let metadata: any;\n let projectRoot: string;\n let fetchGitMetadata = () => Promise.resolve<any>({});\n\n // Helper function to write file if content has changed\n const writeFileIfChanged = async (\n filePath: string,\n content: string,\n description: string,\n ): Promise<boolean> => {\n try {\n // Check if file exists and compare content\n let shouldWrite = !existsSync(filePath);\n if (!shouldWrite) {\n try {\n const existingContent = await readFile(filePath, \"utf-8\");\n shouldWrite = existingContent !== content;\n } catch {\n // File doesn't exist or couldn't read, we should write it\n shouldWrite = true;\n }\n }\n\n if (shouldWrite) {\n // Ensure directory exists\n await mkdir(dirname(filePath), { recursive: true });\n // Write file only if content has changed\n await writeFile(filePath, content);\n return true;\n } else {\n // File content is the same, no need to write\n return false;\n }\n } catch (error) {\n logger.warn(`Failed to write ${description}: ${filePath}: ${error}`);\n return false;\n }\n };\n\n // Generate and write metadata TypeScript file\n const generateMetadataSourceFile = async () => {\n // Resolve package metadata\n const result = await resolvePackageMetadata(\n projectRoot,\n fetchGitMetadata,\n alwaysOverrideVersionFromGit,\n logger,\n );\n metadata = result.metadata;\n // Regenerate banner with updated metadata\n banner = generateBanner(metadata, outputKeys);\n if (outputMetadataFile) {\n const metadataSourceContent = generateMetadataFile(\n metadata,\n outputMetadataKeys,\n );\n const metadataSourcePath = join(projectRoot, outputMetadataFilePath);\n return await writeFileIfChanged(\n metadataSourcePath,\n metadataSourceContent,\n \"metadata source file\",\n );\n }\n return false;\n };\n\n // Generate and write metadata TypeScript type definition file\n const generateMetadataTypeDefinitionFile = async () => {\n if (outputMetadataFile) {\n const metadataTypeContent = generateMetadataTypeFile(outputMetadataKeys);\n const metadataTypePath = join(\n projectRoot,\n resolvedOutputMetadataFileTypePath,\n );\n return await writeFileIfChanged(\n metadataTypePath,\n metadataTypeContent,\n \"metadata type definition file\",\n );\n }\n return false;\n };\n\n // Generate dummy metadata TypeScript file with empty string values\n const generateDummyMetadataFile = async () => {\n if (outputMetadataFile) {\n const metadataSourcePath = join(projectRoot, outputMetadataFilePath);\n // Only generate if file doesn't exist (don't overwrite existing files)\n if (!existsSync(metadataSourcePath)) {\n // Create dummy metadata with empty strings for all keys\n const dummyMetadata: any = {};\n outputMetadataKeys.forEach((key) => {\n dummyMetadata[key] = \"[Require first build]\";\n });\n const dummyContent = generateMetadataFile(\n dummyMetadata,\n outputMetadataKeys,\n );\n return await writeFileIfChanged(\n metadataSourcePath,\n dummyContent,\n \"dummy metadata source file\",\n );\n }\n }\n return false;\n };\n\n return {\n name: \"screw-up\",\n // Ensure screw-up runs before other plugins\n // (especially vite-plugin-dts, avoid packageMetadata.ts is not found)\n enforce: \"pre\",\n // Plugin starting\n applyToEnvironment: async (penv) => {\n logger.info(`${version}-${git_commit_hash}: Started.`);\n\n // Partial (but maybe exact) project root\n projectRoot = penv.config.root;\n\n // Generate type definition file early since it doesn't require actual metadata values\n if (projectRoot && (await generateMetadataTypeDefinitionFile())) {\n logger.info(\n `applyToEnvironment: Metadata type definition file is generated: ${resolvedOutputMetadataFileTypePath}`,\n );\n }\n\n // Generate dummy metadata source file to prevent import errors on initial build\n if (projectRoot && (await generateDummyMetadataFile())) {\n logger.info(\n `applyToEnvironment: Dummy metadata source file is generated: ${outputMetadataFilePath}`,\n );\n }\n\n return true;\n },\n // Configuration resolved phase\n configResolved: async (config) => {\n // Avoid race conditions.\n const l = await generateMetadataSourceLocker.lock();\n try {\n logger.debug(`configResolved: Started.`);\n\n // Save project root\n projectRoot = config.root;\n if (config?.logger) {\n logger = createConsoleLogger(loggerPrefix, config.logger);\n } else if (config?.customLogger) {\n logger = createConsoleLogger(loggerPrefix, config.customLogger);\n }\n // Get Git metadata fetcher function\n fetchGitMetadata = getFetchGitMetadata(\n projectRoot,\n checkWorkingDirectoryStatus,\n logger,\n );\n // Generate metadata TypeScript file early to ensure it's available during TypeScript compilation\n if (await generateMetadataSourceFile()) {\n logger.info(\n `configResolved: Metadata source file is generated: ${outputMetadataFilePath}`,\n );\n }\n } finally {\n logger.debug(`configResolved: Exited.`);\n l.release();\n }\n },\n // Server hook\n configureServer: async (server) => {\n // Avoid race conditions.\n const l = await generateMetadataSourceLocker.lock();\n try {\n logger.debug(`configureServer: Started.`);\n\n // Exclude generated metadata file from watcher to prevent infinite loop\n if (outputMetadataFile && server.watcher) {\n const metadataSourcePath = join(projectRoot, outputMetadataFilePath);\n // Use unwatch to exclude the file from being watched\n server.watcher.unwatch(metadataSourcePath);\n logger.debug(\n `configureServer: Excluded from watcher: ${outputMetadataFilePath}`,\n );\n }\n\n if (await generateMetadataSourceFile()) {\n logger.info(\n `configureServer: Metadata source file is generated: ${outputMetadataFilePath}`,\n );\n }\n } finally {\n logger.debug(`configureServer: Exited.`);\n l.release();\n }\n },\n // Build start phase\n buildStart: async () => {\n // Avoid race conditions.\n const l = await generateMetadataSourceLocker.lock();\n try {\n logger.debug(`buildStart: Started.`);\n // Re-resolve package metadata to capture any changes since configResolved\n // Update metadata TypeScript file with latest data\n if (await generateMetadataSourceFile()) {\n logger.info(\n `buildStart: Metadata source file is generated: ${outputMetadataFilePath}`,\n );\n }\n } finally {\n logger.debug(`buildStart: Exited.`);\n l.release();\n }\n },\n // Generate bundle phase\n generateBundle: (_options, bundle) => {\n // Add banner to each output file if enabled\n if (insertMetadataBanner) {\n let count = 0;\n for (const fileName in bundle) {\n const chunk = bundle[fileName];\n if (chunk.type === \"chunk\") {\n chunk.code = insertBannerHeader(chunk.code, banner);\n count++;\n } else if (\n chunk.type === \"asset\" &&\n assetFiltersRegex.some((filter) => filter.test(fileName))\n ) {\n if (typeof chunk.source === \"string\") {\n chunk.source = insertBannerHeader(chunk.source, banner + \"\\n\"); // insert more blank line\n count++;\n }\n }\n }\n if (count >= 1) {\n logger.debug(\n `generateBundle: Banner header inserted: ${count} file(s)`,\n );\n }\n }\n },\n // Write bundle phase\n writeBundle: async (options) => {\n // Handle files written by other plugins (like vite-plugin-dts) if banner insertion is enabled\n if (!insertMetadataBanner || !options.dir) return;\n\n try {\n // Read all files in the output directory\n const files = await readdir(options.dir, { recursive: true });\n\n // Iterate over all files\n let count = 0;\n for (const file of files) {\n const filePath = join(options.dir, file);\n\n // Check if the file is target asset file\n if (assetFiltersRegex.some((filter) => filter.test(file))) {\n try {\n // Read the asset file\n const content = await readFile(filePath, \"utf-8\");\n // Append banner to the asset file if it doesn't already contain it\n if (!content.includes(banner)) {\n await writeFile(\n filePath,\n insertBannerHeader(content, banner + \"\\n\"),\n );\n count++;\n }\n } catch (error) {\n // Skip files that can't be read/written\n }\n }\n }\n if (count >= 1) {\n logger.debug(`writeBundle: Banner header inserted: ${count} file(s)`);\n }\n } catch (error) {\n // Skip files that can't be read/written\n }\n },\n };\n};\n"],"names":["name","createConsoleLogger","existsSync","readFile","mkdir","dirname","writeFile","resolvePackageMetadata","join","version","git_commit_hash","getFetchGitMetadata","options","readdir"],"mappings":";;;;;AAAA,MAAM,iBAAiB,MAAM;AAC7B;AACA,MAAM,oBAAoB;AAAA,EACxB,SAAS;AAAA,EACT,CAAC,OAAO,OAAO,GAAG;AACpB;AACA,MAAM,UAAU,CAAC,QAAQ,aAAa;AACpC,MAAI,CAAC,QAAQ;AACX,WAAO;AAAA,EACT;AACA,MAAI,OAAO,SAAS;AAClB,QAAI;AACF,eAAQ;AAAA,IACV,SAAS,OAAO;AACd,cAAQ,KAAK,8BAA8B,KAAK;AAAA,IAClD;AACA,WAAO;AAAA,EACT;AACA,MAAI;AACJ,iBAAe,MAAM;AACnB,QAAI,cAAc;AAChB,aAAO,oBAAoB,SAAS,YAAY;AAChD,qBAAe;AACf,UAAI;AACF,iBAAQ;AAAA,MACV,SAAS,OAAO;AACd,gBAAQ,KAAK,8BAA8B,KAAK;AAAA,MAClD;AAAA,IACF;AAAA,EACF;AACA,QAAM,UAAU,MAAM;AACpB,QAAI,cAAc;AAChB,aAAO,oBAAoB,SAAS,YAAY;AAChD,qBAAe;AAAA,IACjB;AAAA,EACF;AACA,SAAO,iBAAiB,SAAS,cAAc,EAAE,MAAM,MAAM;AAC7D,QAAM,SAAS;AAAA,IACb;AAAA,IACA,CAAC,OAAO,OAAO,GAAG;AAAA,EACtB;AACE,SAAO;AACT;AAsBA,MAAM,QAAQ,CAAC,OAAO;AACpB,MAAI,OAAO,iBAAiB,YAAY;AACtC,iBA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,YACF,SAAS,OAAO;AAAA,YAEhB;AAAA,UACF;AAAA,QACF;AACA,YAAI,SAAS,GAAG;AACd,iBAAO,MAAM,wCAAwC,KAAK,UAAU;AAAA,QACtE;AAAA,MACF,SAAS,OAAO;AAAA,MAEhB;AAAA,IACF;AAAA,EAAA;AAEJ;;","x_google_ignoreList":[0]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: screw-up
|
|
3
|
-
* version: 1.
|
|
3
|
+
* version: 1.4.0
|
|
4
4
|
* description: Simply package metadata inserter on Vite plugin
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/screw-up.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 48850bae9ed83a921ef5239628983b3e797a0ce7
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { screwUp } from './vite-plugin';
|