@ttsc/unplugin 0.28.5 → 0.29.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 +15 -11
- package/lib/api.js +10 -0
- package/lib/api.js.map +1 -1
- package/lib/api.mjs +3 -2
- package/lib/api.mjs.map +1 -1
- package/lib/bun-register.d.cts +10 -7
- package/lib/bun-register.d.mts +10 -7
- package/lib/bun-register.d.ts +10 -7
- package/lib/bun-register.js +90 -24
- package/lib/bun-register.js.map +1 -1
- package/lib/bun-register.mjs +90 -24
- package/lib/bun-register.mjs.map +1 -1
- package/lib/bun.d.cts +10 -8
- package/lib/bun.d.mts +10 -8
- package/lib/bun.d.ts +10 -8
- package/lib/bun.js +19 -17
- package/lib/bun.js.map +1 -1
- package/lib/bun.mjs +20 -18
- package/lib/bun.mjs.map +1 -1
- package/lib/core/index.d.cts +10 -8
- package/lib/core/index.d.mts +10 -8
- package/lib/core/index.d.ts +10 -8
- package/lib/core/index.js +88 -16
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +81 -18
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/projectDiscovery.d.cts +55 -0
- package/lib/core/projectDiscovery.d.mts +55 -0
- package/lib/core/projectDiscovery.d.ts +55 -0
- package/lib/core/projectDiscovery.js +187 -0
- package/lib/core/projectDiscovery.js.map +1 -0
- package/lib/core/projectDiscovery.mjs +182 -0
- package/lib/core/projectDiscovery.mjs.map +1 -0
- package/lib/core/sourceExtensions.d.cts +10 -0
- package/lib/core/sourceExtensions.d.mts +10 -0
- package/lib/core/sourceExtensions.d.ts +10 -0
- package/lib/core/sourceExtensions.js +38 -0
- package/lib/core/sourceExtensions.js.map +1 -0
- package/lib/core/sourceExtensions.mjs +32 -0
- package/lib/core/sourceExtensions.mjs.map +1 -0
- package/lib/core/transform.d.cts +96 -16
- package/lib/core/transform.d.mts +96 -16
- package/lib/core/transform.d.ts +96 -16
- package/lib/core/transform.js +1295 -309
- package/lib/core/transform.js.map +1 -1
- package/lib/core/transform.mjs +1290 -310
- package/lib/core/transform.mjs.map +1 -1
- package/lib/core/tsconfigPaths.d.cts +55 -3
- package/lib/core/tsconfigPaths.d.mts +55 -3
- package/lib/core/tsconfigPaths.d.ts +55 -3
- package/lib/core/tsconfigPaths.js +260 -46
- package/lib/core/tsconfigPaths.js.map +1 -1
- package/lib/core/tsconfigPaths.mjs +255 -47
- package/lib/core/tsconfigPaths.mjs.map +1 -1
- package/lib/core/viteServe.d.cts +18 -21
- package/lib/core/viteServe.d.mts +18 -21
- package/lib/core/viteServe.d.ts +18 -21
- package/lib/core/viteServe.js +88 -47
- package/lib/core/viteServe.js.map +1 -1
- package/lib/core/viteServe.mjs +89 -49
- package/lib/core/viteServe.mjs.map +1 -1
- package/lib/next.d.cts +7 -0
- package/lib/next.d.mts +7 -0
- package/lib/next.d.ts +7 -0
- package/lib/next.js +186 -54
- package/lib/next.js.map +1 -1
- package/lib/next.mjs +186 -55
- package/lib/next.mjs.map +1 -1
- package/lib/turbopack.d.cts +6 -4
- package/lib/turbopack.d.mts +6 -4
- package/lib/turbopack.d.ts +6 -4
- package/lib/turbopack.js +11 -10
- package/lib/turbopack.js.map +1 -1
- package/lib/turbopack.mjs +11 -10
- package/lib/turbopack.mjs.map +1 -1
- package/package.json +7 -4
- package/src/bun-register.ts +112 -25
- package/src/bun.ts +60 -50
- package/src/core/index.ts +114 -19
- package/src/core/projectDiscovery.ts +256 -0
- package/src/core/sourceExtensions.ts +47 -0
- package/src/core/transform.ts +1671 -361
- package/src/core/tsconfigPaths.ts +406 -46
- package/src/core/viteServe.ts +125 -74
- package/src/next.ts +230 -54
- package/src/turbopack.ts +11 -10
package/lib/bun.d.mts
CHANGED
|
@@ -20,19 +20,19 @@ export type BunLoader = "ts" | "tsx";
|
|
|
20
20
|
*
|
|
21
21
|
* The provider form exists for the runtime registration path (`bun-register`),
|
|
22
22
|
* where a single Bun plugin is registered on import but its effective options
|
|
23
|
-
* may be overridden by
|
|
24
|
-
*
|
|
25
|
-
* at registration, lets
|
|
26
|
-
* shadowing loader.
|
|
23
|
+
* may be overridden by explicit `register(options)` calls made before the first
|
|
24
|
+
* transformable TypeScript load. Resolving through the provider on that first
|
|
25
|
+
* load, rather than at registration, lets the last pending call win without Bun
|
|
26
|
+
* ever seeing a second shadowing loader.
|
|
27
27
|
*/
|
|
28
28
|
export type TtscBunOptions = TtscUnpluginOptions | (() => TtscUnpluginOptions | undefined);
|
|
29
29
|
/**
|
|
30
30
|
* Minimal subset of the Bun `BuildConfig` plugin build object.
|
|
31
31
|
*
|
|
32
|
-
* `onLoad` drives the source transform. Bun's bundler also exposes `onStart
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* `onLoad` drives the source transform. Bun's bundler also exposes `onStart`
|
|
33
|
+
* and `onEnd`, which bracket the shared plugin's build lifecycle. The runtime
|
|
34
|
+
* plugin API omits those hooks, so plugin setup itself starts its one
|
|
35
|
+
* process-scoped module-loading session.
|
|
36
36
|
*/
|
|
37
37
|
export interface BunLikeBuild {
|
|
38
38
|
/**
|
|
@@ -51,6 +51,8 @@ export interface BunLikeBuild {
|
|
|
51
51
|
* Optional because `Bun.plugin()` runtime builders do not expose this hook.
|
|
52
52
|
*/
|
|
53
53
|
onStart?(callback: () => void | Promise<void>): void;
|
|
54
|
+
/** Register a callback for deterministic bundler-session teardown. */
|
|
55
|
+
onEnd?(callback: () => void | Promise<void>): void;
|
|
54
56
|
/**
|
|
55
57
|
* Register a loader callback for files matching `filter`.
|
|
56
58
|
*
|
package/lib/bun.d.ts
CHANGED
|
@@ -20,19 +20,19 @@ export type BunLoader = "ts" | "tsx";
|
|
|
20
20
|
*
|
|
21
21
|
* The provider form exists for the runtime registration path (`bun-register`),
|
|
22
22
|
* where a single Bun plugin is registered on import but its effective options
|
|
23
|
-
* may be overridden by
|
|
24
|
-
*
|
|
25
|
-
* at registration, lets
|
|
26
|
-
* shadowing loader.
|
|
23
|
+
* may be overridden by explicit `register(options)` calls made before the first
|
|
24
|
+
* transformable TypeScript load. Resolving through the provider on that first
|
|
25
|
+
* load, rather than at registration, lets the last pending call win without Bun
|
|
26
|
+
* ever seeing a second shadowing loader.
|
|
27
27
|
*/
|
|
28
28
|
export type TtscBunOptions = TtscUnpluginOptions | (() => TtscUnpluginOptions | undefined);
|
|
29
29
|
/**
|
|
30
30
|
* Minimal subset of the Bun `BuildConfig` plugin build object.
|
|
31
31
|
*
|
|
32
|
-
* `onLoad` drives the source transform. Bun's bundler also exposes `onStart
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* `onLoad` drives the source transform. Bun's bundler also exposes `onStart`
|
|
33
|
+
* and `onEnd`, which bracket the shared plugin's build lifecycle. The runtime
|
|
34
|
+
* plugin API omits those hooks, so plugin setup itself starts its one
|
|
35
|
+
* process-scoped module-loading session.
|
|
36
36
|
*/
|
|
37
37
|
export interface BunLikeBuild {
|
|
38
38
|
/**
|
|
@@ -51,6 +51,8 @@ export interface BunLikeBuild {
|
|
|
51
51
|
* Optional because `Bun.plugin()` runtime builders do not expose this hook.
|
|
52
52
|
*/
|
|
53
53
|
onStart?(callback: () => void | Promise<void>): void;
|
|
54
|
+
/** Register a callback for deterministic bundler-session teardown. */
|
|
55
|
+
onEnd?(callback: () => void | Promise<void>): void;
|
|
54
56
|
/**
|
|
55
57
|
* Register a loader callback for files matching `filter`.
|
|
56
58
|
*
|
package/lib/bun.js
CHANGED
|
@@ -4,16 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var fs = require('node:fs/promises');
|
|
6
6
|
var index = require('./core/index.js');
|
|
7
|
+
var sourceExtensions = require('./core/sourceExtensions.js');
|
|
7
8
|
var transform = require('./core/transform.js');
|
|
8
9
|
var options = require('./core/options.js');
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
-
* Bun normally reports filesystem source paths, while plugin-created virtual
|
|
12
|
-
* ids may contain a NUL sentinel. A virtual id must stay with the plugin that
|
|
13
|
-
* created it: claiming it here and trying to read it from disk prevents that
|
|
14
|
-
* plugin's later loader from running.
|
|
15
|
-
*/
|
|
16
|
-
const bunSourceFilePattern = /^[^\x00]*\.[cm]?tsx?$/;
|
|
17
11
|
/**
|
|
18
12
|
* Transform hooks handed to the shared transform under Bun.
|
|
19
13
|
*
|
|
@@ -59,10 +53,10 @@ function bun(options$1) {
|
|
|
59
53
|
return {
|
|
60
54
|
name: "ttsc-unplugin",
|
|
61
55
|
setup(build) {
|
|
62
|
-
// Resolve options lazily on first load.
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
56
|
+
// Resolve options lazily on the first transformable TypeScript load.
|
|
57
|
+
// Runtime registration may replace its pending configuration at any time
|
|
58
|
+
// before then; the provider form must observe that last update without
|
|
59
|
+
// installing a second shadowing loader.
|
|
66
60
|
let resolved;
|
|
67
61
|
const getOptions = () => (resolved ??= options.resolveOptions(resolveBunOptions(options$1)));
|
|
68
62
|
const cache = transform.createTtscTransformCache();
|
|
@@ -76,7 +70,10 @@ function bun(options$1) {
|
|
|
76
70
|
// repeats it for subsequent builds.
|
|
77
71
|
transform.beginTtscTransformBuild(cache);
|
|
78
72
|
build.onStart?.(() => transform.beginTtscTransformBuild(cache));
|
|
79
|
-
|
|
73
|
+
if (!runtime) {
|
|
74
|
+
build.onEnd?.(() => transform.resetTtscTransformCache(cache));
|
|
75
|
+
}
|
|
76
|
+
build.onLoad({ filter: sourceExtensions.bunTypeScriptTransformSourcePattern }, async (args) => {
|
|
80
77
|
if (!runtime && ownsInMemoryFile(args.path)) {
|
|
81
78
|
return undefined;
|
|
82
79
|
}
|
|
@@ -89,8 +86,9 @@ function bun(options$1) {
|
|
|
89
86
|
};
|
|
90
87
|
}
|
|
91
88
|
const loader = bunLoaderFor(args.path);
|
|
89
|
+
const transformOptions = getOptions();
|
|
92
90
|
const source = await fs.readFile(args.path, "utf8");
|
|
93
|
-
const result = await transform.transformTtsc(args.path, source,
|
|
91
|
+
const result = await transform.transformTtsc(args.path, source, transformOptions, undefined, cache, bunTransformHooks);
|
|
94
92
|
if (result !== undefined) {
|
|
95
93
|
return { contents: result.code, loader };
|
|
96
94
|
}
|
|
@@ -100,12 +98,16 @@ function bun(options$1) {
|
|
|
100
98
|
};
|
|
101
99
|
}
|
|
102
100
|
/**
|
|
103
|
-
* Pick the Bun loader
|
|
104
|
-
*
|
|
105
|
-
*
|
|
101
|
+
* Pick the Bun loader recorded beside the matched extension in the shared
|
|
102
|
+
* source table. Reaching this function without a table entry would mean Bun
|
|
103
|
+
* invoked a callback whose registration filter did not match.
|
|
106
104
|
*/
|
|
107
105
|
function bunLoaderFor(filePath) {
|
|
108
|
-
|
|
106
|
+
const loader = sourceExtensions.typescriptTransformBunLoader(filePath);
|
|
107
|
+
if (loader === undefined) {
|
|
108
|
+
throw new Error(`Bun delivered an unsupported source path: ${filePath}`);
|
|
109
|
+
}
|
|
110
|
+
return loader;
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
111
113
|
* Create a stable ownership matcher for Bun's `BuildConfig.files` map.
|
package/lib/bun.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun.js","sources":["../src/bun.ts"],"sourcesContent":[null],"names":["options","resolveOptions","createTtscTransformCache","beginTtscTransformBuild","isTransformTarget","transformTtsc"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bun.js","sources":["../src/bun.ts"],"sourcesContent":[null],"names":["options","resolveOptions","createTtscTransformCache","beginTtscTransformBuild","resetTtscTransformCache","bunTypeScriptTransformSourcePattern","isTransformTarget","transformTtsc","typescriptTransformBunLoader"],"mappings":";;;;;;;;;;AAgDA;;;;;;;;;;;AAWG;AACH,MAAM,iBAAiB,GAAG;AACxB,IAAA,YAAY,KAAU,CAAC;CACxB;AAED;AACA,SAAS,iBAAiB,CACxB,OAAwB,EAAA;AAExB,IAAA,OAAO,OAAO,OAAO,KAAK,UAAU,GAAG,OAAO,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;;;;AAMG;AACH,SAAS,kBAAkB,CAAC,IAAY,EAAA;AACtC,IAAA,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;AAAE,QAAA,OAAO,IAAI;AAC7C,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,KAAK,EAAE,GAAG;AAClB,SAAA,OAAO,CACN,YAAY,EACZ,CAAC,MAAM,EAAE,KAAa,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA,CAAA,CAAG,CACrD;AACL;;;;"}
|
package/lib/bun.mjs
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
2
|
import { isTransformTarget } from './core/index.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { bunTypeScriptTransformSourcePattern, typescriptTransformBunLoader } from './core/sourceExtensions.mjs';
|
|
4
|
+
import { createTtscTransformCache, beginTtscTransformBuild, resetTtscTransformCache, transformTtsc } from './core/transform.mjs';
|
|
4
5
|
import { resolveOptions } from './core/options.mjs';
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* Bun normally reports filesystem source paths, while plugin-created virtual
|
|
8
|
-
* ids may contain a NUL sentinel. A virtual id must stay with the plugin that
|
|
9
|
-
* created it: claiming it here and trying to read it from disk prevents that
|
|
10
|
-
* plugin's later loader from running.
|
|
11
|
-
*/
|
|
12
|
-
const bunSourceFilePattern = /^[^\x00]*\.[cm]?tsx?$/;
|
|
13
7
|
/**
|
|
14
8
|
* Transform hooks handed to the shared transform under Bun.
|
|
15
9
|
*
|
|
@@ -55,10 +49,10 @@ function bun(options) {
|
|
|
55
49
|
return {
|
|
56
50
|
name: "ttsc-unplugin",
|
|
57
51
|
setup(build) {
|
|
58
|
-
// Resolve options lazily on first load.
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
52
|
+
// Resolve options lazily on the first transformable TypeScript load.
|
|
53
|
+
// Runtime registration may replace its pending configuration at any time
|
|
54
|
+
// before then; the provider form must observe that last update without
|
|
55
|
+
// installing a second shadowing loader.
|
|
62
56
|
let resolved;
|
|
63
57
|
const getOptions = () => (resolved ??= resolveOptions(resolveBunOptions(options)));
|
|
64
58
|
const cache = createTtscTransformCache();
|
|
@@ -72,7 +66,10 @@ function bun(options) {
|
|
|
72
66
|
// repeats it for subsequent builds.
|
|
73
67
|
beginTtscTransformBuild(cache);
|
|
74
68
|
build.onStart?.(() => beginTtscTransformBuild(cache));
|
|
75
|
-
|
|
69
|
+
if (!runtime) {
|
|
70
|
+
build.onEnd?.(() => resetTtscTransformCache(cache));
|
|
71
|
+
}
|
|
72
|
+
build.onLoad({ filter: bunTypeScriptTransformSourcePattern }, async (args) => {
|
|
76
73
|
if (!runtime && ownsInMemoryFile(args.path)) {
|
|
77
74
|
return undefined;
|
|
78
75
|
}
|
|
@@ -85,8 +82,9 @@ function bun(options) {
|
|
|
85
82
|
};
|
|
86
83
|
}
|
|
87
84
|
const loader = bunLoaderFor(args.path);
|
|
85
|
+
const transformOptions = getOptions();
|
|
88
86
|
const source = await fs.readFile(args.path, "utf8");
|
|
89
|
-
const result = await transformTtsc(args.path, source,
|
|
87
|
+
const result = await transformTtsc(args.path, source, transformOptions, undefined, cache, bunTransformHooks);
|
|
90
88
|
if (result !== undefined) {
|
|
91
89
|
return { contents: result.code, loader };
|
|
92
90
|
}
|
|
@@ -96,12 +94,16 @@ function bun(options) {
|
|
|
96
94
|
};
|
|
97
95
|
}
|
|
98
96
|
/**
|
|
99
|
-
* Pick the Bun loader
|
|
100
|
-
*
|
|
101
|
-
*
|
|
97
|
+
* Pick the Bun loader recorded beside the matched extension in the shared
|
|
98
|
+
* source table. Reaching this function without a table entry would mean Bun
|
|
99
|
+
* invoked a callback whose registration filter did not match.
|
|
102
100
|
*/
|
|
103
101
|
function bunLoaderFor(filePath) {
|
|
104
|
-
|
|
102
|
+
const loader = typescriptTransformBunLoader(filePath);
|
|
103
|
+
if (loader === undefined) {
|
|
104
|
+
throw new Error(`Bun delivered an unsupported source path: ${filePath}`);
|
|
105
|
+
}
|
|
106
|
+
return loader;
|
|
105
107
|
}
|
|
106
108
|
/**
|
|
107
109
|
* Create a stable ownership matcher for Bun's `BuildConfig.files` map.
|
package/lib/bun.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun.mjs","sources":["../src/bun.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bun.mjs","sources":["../src/bun.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAgDA;;;;;;;;;;;AAWG;AACH,MAAM,iBAAiB,GAAG;AACxB,IAAA,YAAY,KAAU,CAAC;CACxB;AAED;AACA,SAAS,iBAAiB,CACxB,OAAwB,EAAA;AAExB,IAAA,OAAO,OAAO,OAAO,KAAK,UAAU,GAAG,OAAO,EAAE,GAAG,OAAO;AAC5D;AA+CA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACW,SAAU,GAAG,CAAC,OAAwB,EAAA;IAClD,OAAO;AACL,QAAA,IAAI,EAAE,eAAe;AACrB,QAAA,KAAK,CAAC,KAAK,EAAA;;;;;AAKT,YAAA,IAAI,QAAuD;AAC3D,YAAA,MAAM,UAAU,GAAG,OAChB,QAAQ,KAAK,cAAc,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC3D,YAAA,MAAM,KAAK,GAAG,wBAAwB,EAAE;AACxC,YAAA,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,KAAK,SAAS;AAC3C,YAAA,MAAM,gBAAgB,GAAG,4BAA4B,CAAC,KAAK,CAAC;;;;;;;YAO5D,uBAAuB,CAAC,KAAK,CAAC;AAC9B,YAAA,KAAK,CAAC,OAAO,GAAG,MAAM,uBAAuB,CAAC,KAAK,CAAC,CAAC;YACrD,IAAI,CAAC,OAAO,EAAE;AACZ,gBAAA,KAAK,CAAC,KAAK,GAAG,MAAM,uBAAuB,CAAC,KAAK,CAAC,CAAC;YACrD;AACA,YAAA,KAAK,CA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,IAAI,KAAK,CAAC,6CAA6C,QAAQ,CAAA,CAAE,CAAC;IAC1E;AACA,IAAA,OAAO,MAAM;AACf;AAEA;;;;;;;AAOG;AACH,SAAS,4BAA4B,CACnC,KAAmB,EAAA;AAEnB,IAAA,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK;IACjC,IAAI,KAAK,KAAK,SAAS;AAAE,QAAA,OAAO,MAAM,KAAK;AAC3C,IAAA,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AACtE,IAAA,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAC3D;AAEA;;;;;;AAMG;AACH,SAAS,kBAAkB,CAAC,IAAY,EAAA;AACtC,IAAA,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;AAAE,QAAA,OAAO,IAAI;AAC7C,IAAA,OAAO;AACJ,SAAA,OAAO,CAAC,KAAK,EAAE,GAAG;AAClB,SAAA,OAAO,CACN,YAAY,EACZ,CAAC,MAAM,EAAE,KAAa,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAA,CAAA,CAAG,CACrD;AACL;;;;"}
|
package/lib/core/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { UnpluginInstance } from "unplugin";
|
|
2
2
|
import type { TtscUnpluginOptions } from "./options.cjs";
|
|
3
3
|
import { resolveOptions } from "./options.cjs";
|
|
4
|
-
import { beginTtscTransformBuild, collectExternalInputHashes, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, resetTtscTransformCache, transformTtsc } from "./transform.cjs";
|
|
4
|
+
import { beginTtscTransformBuild, captureWatchInputBaseline, captureWatchInputFileBaseline, collectExternalInputHashes, collectProjectInputHashSnapshot, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, isWatchInputKeyBaseline, resetTtscTransformCache, transformTtsc, watchInputEvidenceMatchesBaseline } from "./transform.cjs";
|
|
5
5
|
/**
|
|
6
|
-
* Matches the TypeScript source extensions the ttsc transform handles:
|
|
7
|
-
* `.tsx`, `.mts`, `.cts
|
|
8
|
-
*
|
|
6
|
+
* Matches the exact TypeScript source extensions the ttsc transform handles:
|
|
7
|
+
* `.ts`, `.tsx`, `.mts`, and `.cts`. JavaScript and invented extension forms
|
|
8
|
+
* such as `.mtsx` are deliberately excluded.
|
|
9
9
|
*
|
|
10
10
|
* Shared with the Bun adapter (`bun.ts`) and the standalone Turbopack loader
|
|
11
11
|
* (`turbopack.ts`) through {@link isTransformTarget}, so the filter is defined
|
|
@@ -14,10 +14,12 @@ import { beginTtscTransformBuild, collectExternalInputHashes, collectProjectInpu
|
|
|
14
14
|
export declare const sourceFilePattern: RegExp;
|
|
15
15
|
declare const unplugin: UnpluginInstance<TtscUnpluginOptions | undefined, false>;
|
|
16
16
|
export type { TtscUnpluginCompilerOptionsJson, TtscUnpluginOptions, } from "./options.cjs";
|
|
17
|
-
export type {
|
|
18
|
-
export type {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
17
|
+
export type { TtscProjectDiscoveryFilesystem, TtscProjectTreeDiscoveryFilesystem, TtscProjectTsconfigCandidate, TtscProjectTsconfigDiscovery, } from "./projectDiscovery.cjs";
|
|
18
|
+
export type { TtscProjectInputHashSnapshot, TtscTransformFilesystemOperations, TtscTransformHooks, TtscWatchInput, TtscWatchInputBaseline, TtscWatchInputEvidence, TtscWatchInputFileBaseline, TtscWatchInputKeyBaseline, TtscWatchInputState, } from "./transform.cjs";
|
|
19
|
+
export type { ITsconfigSourceSnapshotEntry, ITtscProjectMembershipPolicy, } from "./tsconfigPaths.cjs";
|
|
20
|
+
export { mergeMembershipPolicyOverlay, readProjectMembershipPolicy, readTsconfigSourceSnapshot, } from "./tsconfigPaths.cjs";
|
|
21
|
+
export { beginTtscTransformBuild, captureWatchInputBaseline, captureWatchInputFileBaseline, collectExternalInputHashes, collectProjectInputHashSnapshot, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, isWatchInputKeyBaseline, resetTtscTransformCache, resolveOptions, transformTtsc, unplugin, watchInputEvidenceMatchesBaseline, };
|
|
22
|
+
export { discoverNearestProjectTsconfig, findNearestProjectTsconfig, findProjectTsconfigs, } from "./projectDiscovery.cjs";
|
|
21
23
|
export default unplugin;
|
|
22
24
|
/**
|
|
23
25
|
* Returns `true` when the module id refers to a real TypeScript source file
|
package/lib/core/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { UnpluginInstance } from "unplugin";
|
|
2
2
|
import type { TtscUnpluginOptions } from "./options.mjs";
|
|
3
3
|
import { resolveOptions } from "./options.mjs";
|
|
4
|
-
import { beginTtscTransformBuild, collectExternalInputHashes, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, resetTtscTransformCache, transformTtsc } from "./transform.mjs";
|
|
4
|
+
import { beginTtscTransformBuild, captureWatchInputBaseline, captureWatchInputFileBaseline, collectExternalInputHashes, collectProjectInputHashSnapshot, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, isWatchInputKeyBaseline, resetTtscTransformCache, transformTtsc, watchInputEvidenceMatchesBaseline } from "./transform.mjs";
|
|
5
5
|
/**
|
|
6
|
-
* Matches the TypeScript source extensions the ttsc transform handles:
|
|
7
|
-
* `.tsx`, `.mts`, `.cts
|
|
8
|
-
*
|
|
6
|
+
* Matches the exact TypeScript source extensions the ttsc transform handles:
|
|
7
|
+
* `.ts`, `.tsx`, `.mts`, and `.cts`. JavaScript and invented extension forms
|
|
8
|
+
* such as `.mtsx` are deliberately excluded.
|
|
9
9
|
*
|
|
10
10
|
* Shared with the Bun adapter (`bun.ts`) and the standalone Turbopack loader
|
|
11
11
|
* (`turbopack.ts`) through {@link isTransformTarget}, so the filter is defined
|
|
@@ -14,10 +14,12 @@ import { beginTtscTransformBuild, collectExternalInputHashes, collectProjectInpu
|
|
|
14
14
|
export declare const sourceFilePattern: RegExp;
|
|
15
15
|
declare const unplugin: UnpluginInstance<TtscUnpluginOptions | undefined, false>;
|
|
16
16
|
export type { TtscUnpluginCompilerOptionsJson, TtscUnpluginOptions, } from "./options.mjs";
|
|
17
|
-
export type {
|
|
18
|
-
export type {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
17
|
+
export type { TtscProjectDiscoveryFilesystem, TtscProjectTreeDiscoveryFilesystem, TtscProjectTsconfigCandidate, TtscProjectTsconfigDiscovery, } from "./projectDiscovery.mjs";
|
|
18
|
+
export type { TtscProjectInputHashSnapshot, TtscTransformFilesystemOperations, TtscTransformHooks, TtscWatchInput, TtscWatchInputBaseline, TtscWatchInputEvidence, TtscWatchInputFileBaseline, TtscWatchInputKeyBaseline, TtscWatchInputState, } from "./transform.mjs";
|
|
19
|
+
export type { ITsconfigSourceSnapshotEntry, ITtscProjectMembershipPolicy, } from "./tsconfigPaths.mjs";
|
|
20
|
+
export { mergeMembershipPolicyOverlay, readProjectMembershipPolicy, readTsconfigSourceSnapshot, } from "./tsconfigPaths.mjs";
|
|
21
|
+
export { beginTtscTransformBuild, captureWatchInputBaseline, captureWatchInputFileBaseline, collectExternalInputHashes, collectProjectInputHashSnapshot, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, isWatchInputKeyBaseline, resetTtscTransformCache, resolveOptions, transformTtsc, unplugin, watchInputEvidenceMatchesBaseline, };
|
|
22
|
+
export { discoverNearestProjectTsconfig, findNearestProjectTsconfig, findProjectTsconfigs, } from "./projectDiscovery.mjs";
|
|
21
23
|
export default unplugin;
|
|
22
24
|
/**
|
|
23
25
|
* Returns `true` when the module id refers to a real TypeScript source file
|
package/lib/core/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { UnpluginInstance } from "unplugin";
|
|
2
2
|
import type { TtscUnpluginOptions } from "./options";
|
|
3
3
|
import { resolveOptions } from "./options";
|
|
4
|
-
import { beginTtscTransformBuild, collectExternalInputHashes, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, resetTtscTransformCache, transformTtsc } from "./transform";
|
|
4
|
+
import { beginTtscTransformBuild, captureWatchInputBaseline, captureWatchInputFileBaseline, collectExternalInputHashes, collectProjectInputHashSnapshot, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, isWatchInputKeyBaseline, resetTtscTransformCache, transformTtsc, watchInputEvidenceMatchesBaseline } from "./transform";
|
|
5
5
|
/**
|
|
6
|
-
* Matches the TypeScript source extensions the ttsc transform handles:
|
|
7
|
-
* `.tsx`, `.mts`, `.cts
|
|
8
|
-
*
|
|
6
|
+
* Matches the exact TypeScript source extensions the ttsc transform handles:
|
|
7
|
+
* `.ts`, `.tsx`, `.mts`, and `.cts`. JavaScript and invented extension forms
|
|
8
|
+
* such as `.mtsx` are deliberately excluded.
|
|
9
9
|
*
|
|
10
10
|
* Shared with the Bun adapter (`bun.ts`) and the standalone Turbopack loader
|
|
11
11
|
* (`turbopack.ts`) through {@link isTransformTarget}, so the filter is defined
|
|
@@ -14,10 +14,12 @@ import { beginTtscTransformBuild, collectExternalInputHashes, collectProjectInpu
|
|
|
14
14
|
export declare const sourceFilePattern: RegExp;
|
|
15
15
|
declare const unplugin: UnpluginInstance<TtscUnpluginOptions | undefined, false>;
|
|
16
16
|
export type { TtscUnpluginCompilerOptionsJson, TtscUnpluginOptions, } from "./options";
|
|
17
|
-
export type {
|
|
18
|
-
export type {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
17
|
+
export type { TtscProjectDiscoveryFilesystem, TtscProjectTreeDiscoveryFilesystem, TtscProjectTsconfigCandidate, TtscProjectTsconfigDiscovery, } from "./projectDiscovery";
|
|
18
|
+
export type { TtscProjectInputHashSnapshot, TtscTransformFilesystemOperations, TtscTransformHooks, TtscWatchInput, TtscWatchInputBaseline, TtscWatchInputEvidence, TtscWatchInputFileBaseline, TtscWatchInputKeyBaseline, TtscWatchInputState, } from "./transform";
|
|
19
|
+
export type { ITsconfigSourceSnapshotEntry, ITtscProjectMembershipPolicy, } from "./tsconfigPaths";
|
|
20
|
+
export { mergeMembershipPolicyOverlay, readProjectMembershipPolicy, readTsconfigSourceSnapshot, } from "./tsconfigPaths";
|
|
21
|
+
export { beginTtscTransformBuild, captureWatchInputBaseline, captureWatchInputFileBaseline, collectExternalInputHashes, collectProjectInputHashSnapshot, collectProjectInputHashes, createTtscTransformCache, isProjectWalkPath, isWatchInputKeyBaseline, resetTtscTransformCache, resolveOptions, transformTtsc, unplugin, watchInputEvidenceMatchesBaseline, };
|
|
22
|
+
export { discoverNearestProjectTsconfig, findNearestProjectTsconfig, findProjectTsconfigs, } from "./projectDiscovery";
|
|
21
23
|
export default unplugin;
|
|
22
24
|
/**
|
|
23
25
|
* Returns `true` when the module id refers to a real TypeScript source file
|
package/lib/core/index.js
CHANGED
|
@@ -6,21 +6,23 @@ var fs = require('node:fs');
|
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
var unplugin$1 = require('unplugin');
|
|
8
8
|
var options = require('./options.js');
|
|
9
|
+
var sourceExtensions = require('./sourceExtensions.js');
|
|
9
10
|
var transform = require('./transform.js');
|
|
10
11
|
var viteServe = require('./viteServe.js');
|
|
11
12
|
var tsconfigPaths = require('./tsconfigPaths.js');
|
|
13
|
+
var projectDiscovery = require('./projectDiscovery.js');
|
|
12
14
|
|
|
13
15
|
const name = "ttsc-unplugin";
|
|
14
16
|
/**
|
|
15
|
-
* Matches the TypeScript source extensions the ttsc transform handles:
|
|
16
|
-
* `.tsx`, `.mts`, `.cts
|
|
17
|
-
*
|
|
17
|
+
* Matches the exact TypeScript source extensions the ttsc transform handles:
|
|
18
|
+
* `.ts`, `.tsx`, `.mts`, and `.cts`. JavaScript and invented extension forms
|
|
19
|
+
* such as `.mtsx` are deliberately excluded.
|
|
18
20
|
*
|
|
19
21
|
* Shared with the Bun adapter (`bun.ts`) and the standalone Turbopack loader
|
|
20
22
|
* (`turbopack.ts`) through {@link isTransformTarget}, so the filter is defined
|
|
21
23
|
* once and every adapter answers the same way.
|
|
22
24
|
*/
|
|
23
|
-
const sourceFilePattern =
|
|
25
|
+
const sourceFilePattern = sourceExtensions.typescriptTransformSourcePattern;
|
|
24
26
|
/** Matches any path segment that is a `node_modules` directory (cross-platform). */
|
|
25
27
|
const nodeModulesPattern = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
|
|
26
28
|
/**
|
|
@@ -60,6 +62,13 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
60
62
|
// old containers cannot dispose a replacement's freshly initialized cache.
|
|
61
63
|
let viteBuildOwners = new WeakSet();
|
|
62
64
|
let viteBuildLifecycles = 0;
|
|
65
|
+
// esbuild schedules one-shot onDispose callbacks after it settles the build
|
|
66
|
+
// Promise. Acquire ownership only at onStart: plugin setup runs before build
|
|
67
|
+
// option validation, and a validation failure has no onDispose callback with
|
|
68
|
+
// which to release a setup-time owner. Once a build has actually started, the
|
|
69
|
+
// count keeps an older delayed callback from disposing its active generation.
|
|
70
|
+
const esbuildOwners = new WeakSet();
|
|
71
|
+
let esbuildLifecycles = 0;
|
|
63
72
|
return {
|
|
64
73
|
name,
|
|
65
74
|
enforce: "pre",
|
|
@@ -114,13 +123,14 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
114
123
|
// project per edit (samchon/ttsc#1301). The watching build hands its
|
|
115
124
|
// teardown to `closeWatcher` below instead.
|
|
116
125
|
buildEnd() {
|
|
117
|
-
missingInputs.dispose();
|
|
118
126
|
if (viteBuildOwners.delete(this)) {
|
|
119
127
|
viteBuildLifecycles -= 1;
|
|
120
128
|
}
|
|
121
|
-
if (viteBuildLifecycles === 0
|
|
122
|
-
(
|
|
123
|
-
|
|
129
|
+
if (viteBuildLifecycles === 0) {
|
|
130
|
+
missingInputs.dispose();
|
|
131
|
+
if (viteCommand === "serve" || !viteBuildWatching) {
|
|
132
|
+
transform.resetTtscTransformCache(transformCache);
|
|
133
|
+
}
|
|
124
134
|
}
|
|
125
135
|
},
|
|
126
136
|
// The watching build's real teardown, and the only hook in a
|
|
@@ -140,6 +150,7 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
140
150
|
closeWatcher() {
|
|
141
151
|
viteBuildOwners = new WeakSet();
|
|
142
152
|
viteBuildLifecycles = 0;
|
|
153
|
+
missingInputs.dispose();
|
|
143
154
|
transform.resetTtscTransformCache(transformCache);
|
|
144
155
|
},
|
|
145
156
|
},
|
|
@@ -177,6 +188,38 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
177
188
|
transform.resetTtscTransformCache(transformCache);
|
|
178
189
|
},
|
|
179
190
|
},
|
|
191
|
+
// These hosts map a top-level buildEnd to a per-compilation hook, so use
|
|
192
|
+
// their true compiler or context teardown instead. The custom callbacks
|
|
193
|
+
// are installed by unplugin alongside its ordinary transform wiring.
|
|
194
|
+
webpack(compiler) {
|
|
195
|
+
compiler.hooks.shutdown.tap(name, () => {
|
|
196
|
+
transform.resetTtscTransformCache(transformCache);
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
rspack(compiler) {
|
|
200
|
+
compiler.hooks.shutdown.tap(name, () => {
|
|
201
|
+
transform.resetTtscTransformCache(transformCache);
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
esbuild: {
|
|
205
|
+
setup(build) {
|
|
206
|
+
build.onStart(() => {
|
|
207
|
+
if (!esbuildOwners.has(build)) {
|
|
208
|
+
esbuildOwners.add(build);
|
|
209
|
+
esbuildLifecycles += 1;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
build.onDispose(() => {
|
|
213
|
+
if (!esbuildOwners.delete(build)) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
esbuildLifecycles -= 1;
|
|
217
|
+
if (esbuildLifecycles === 0) {
|
|
218
|
+
transform.resetTtscTransformCache(transformCache);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
},
|
|
180
223
|
buildStart() {
|
|
181
224
|
if (viteCommand !== undefined && !viteBuildOwners.has(this)) {
|
|
182
225
|
viteBuildOwners.add(this);
|
|
@@ -223,19 +266,39 @@ const unpluginFactory = (rawOptions = {}) => {
|
|
|
223
266
|
// invalidate this module in watch mode and persistent caches;
|
|
224
267
|
// bundlers erase type-only imports from their own module graph and
|
|
225
268
|
// would otherwise serve stale generated code. Under Vite serve a
|
|
226
|
-
//
|
|
227
|
-
// resolves added imports and 500s on
|
|
228
|
-
//
|
|
229
|
-
//
|
|
230
|
-
//
|
|
269
|
+
// resolver input that is not proven to be a file must not enter
|
|
270
|
+
// `addWatchFile`: import-analysis resolves added imports and 500s on
|
|
271
|
+
// missing paths and directories, so those are watched against their
|
|
272
|
+
// compiler predicates instead and invalidate this module when the
|
|
273
|
+
// observation changes.
|
|
231
274
|
addWatchFile: (watched, evidence) => {
|
|
232
275
|
if (viteCommand === "serve" && missingInputs.serving()) {
|
|
276
|
+
const observation = evidence?.state?.codec === "predicates"
|
|
277
|
+
? evidence.state.observation
|
|
278
|
+
: undefined;
|
|
279
|
+
const unsafePredicate = observation !== undefined &&
|
|
280
|
+
observation.fileExists !== true &&
|
|
281
|
+
observation.stat !== "file" &&
|
|
282
|
+
observation.readFile?.ok !== true
|
|
283
|
+
? observation
|
|
284
|
+
: undefined;
|
|
285
|
+
if (unsafePredicate !== undefined) {
|
|
286
|
+
missingInputs.watch(watched, path.resolve(file), unsafePredicate);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
233
289
|
// Trust the generation's recorded existence when it supplied one:
|
|
234
290
|
// every cache hit revalidates it, and probing each input again
|
|
235
291
|
// costs one `existsSync` per input per delivered module.
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
292
|
+
const unavailable = evidence?.unavailable ??
|
|
293
|
+
(evidence === undefined
|
|
294
|
+
? !fs.existsSync(watched)
|
|
295
|
+
? "missing"
|
|
296
|
+
: undefined
|
|
297
|
+
: evidence.missing
|
|
298
|
+
? "missing"
|
|
299
|
+
: undefined);
|
|
300
|
+
if (unavailable !== undefined) {
|
|
301
|
+
missingInputs.watch(watched, path.resolve(file), unavailable === "not-file" ? "file" : "exists");
|
|
239
302
|
return;
|
|
240
303
|
}
|
|
241
304
|
}
|
|
@@ -286,14 +349,23 @@ function isTransformTarget(id) {
|
|
|
286
349
|
|
|
287
350
|
exports.resolveOptions = options.resolveOptions;
|
|
288
351
|
exports.beginTtscTransformBuild = transform.beginTtscTransformBuild;
|
|
352
|
+
exports.captureWatchInputBaseline = transform.captureWatchInputBaseline;
|
|
353
|
+
exports.captureWatchInputFileBaseline = transform.captureWatchInputFileBaseline;
|
|
289
354
|
exports.collectExternalInputHashes = transform.collectExternalInputHashes;
|
|
355
|
+
exports.collectProjectInputHashSnapshot = transform.collectProjectInputHashSnapshot;
|
|
290
356
|
exports.collectProjectInputHashes = transform.collectProjectInputHashes;
|
|
291
357
|
exports.createTtscTransformCache = transform.createTtscTransformCache;
|
|
292
358
|
exports.isProjectWalkPath = transform.isProjectWalkPath;
|
|
359
|
+
exports.isWatchInputKeyBaseline = transform.isWatchInputKeyBaseline;
|
|
293
360
|
exports.resetTtscTransformCache = transform.resetTtscTransformCache;
|
|
294
361
|
exports.transformTtsc = transform.transformTtsc;
|
|
362
|
+
exports.watchInputEvidenceMatchesBaseline = transform.watchInputEvidenceMatchesBaseline;
|
|
295
363
|
exports.mergeMembershipPolicyOverlay = tsconfigPaths.mergeMembershipPolicyOverlay;
|
|
296
364
|
exports.readProjectMembershipPolicy = tsconfigPaths.readProjectMembershipPolicy;
|
|
365
|
+
exports.readTsconfigSourceSnapshot = tsconfigPaths.readTsconfigSourceSnapshot;
|
|
366
|
+
exports.discoverNearestProjectTsconfig = projectDiscovery.discoverNearestProjectTsconfig;
|
|
367
|
+
exports.findNearestProjectTsconfig = projectDiscovery.findNearestProjectTsconfig;
|
|
368
|
+
exports.findProjectTsconfigs = projectDiscovery.findProjectTsconfigs;
|
|
297
369
|
exports.default = unplugin;
|
|
298
370
|
exports.isTransformTarget = isTransformTarget;
|
|
299
371
|
exports.sourceFilePattern = sourceFilePattern;
|
package/lib/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/core/index.ts"],"sourcesContent":[null],"names":["options","resolveOptions","createTtscTransformCache","createViteServeMissingInputWatch","resetTtscTransformCache","beginTtscTransformBuild","stripQuery","transformTtsc","createUnplugin","isDeclarationFile"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/core/index.ts"],"sourcesContent":[null],"names":["typescriptTransformSourcePattern","options","resolveOptions","createTtscTransformCache","createViteServeMissingInputWatch","resetTtscTransformCache","beginTtscTransformBuild","stripQuery","transformTtsc","createUnplugin","isDeclarationFile"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAM,IAAI,GAAG,eAAe;AAC5B;;;;;;;;AAQG;AACI,MAAM,iBAAiB,GAAGA;AACjC;AACA,MAAM,kBAAkB,GAAG,oCAAoC;AAC/D;;;AAGG;AACH,MAAM,oBAAoB,GAAG,IAAI;AAEjC;;;;;;;;;;;;;AAaG;AACH,MAAM,eAAe,GAGjB,CAAC,UAAU,GAAG,EAAE,KAAI;AACtB,IAAA,MAAMC,SAAO,GAAGC,sBAAc,CAAC,UAAU,CAAC;AAC1C,IAAA,MAAM,cAAc,GAAGC,kCAAwB,EAAE;AACjD,IAAA,MAAM,aAAa,GAAGC,0CAAgC,EAAE;AACxD,IAAA,IAAI,OAAgB;AACpB,IAAA,IAAI,WAA+B;IACnC,IAAI,YAAY,GAAG,IAAI;;;;;IAKvB,IAAI,iBAAiB,GAAG,KAAK;;;;;AAK7B,IAAA,IAAI,eAAe,GAAG,IAAI,OAAO,EAAU;IAC3C,IAAI,mBAAmB,GAAG,CAAC;;;;;;AAM3B,IAAA,MAAM,aAAa,GAAG,IAAI,OAAO,EAAU;IAC3C,IAAI,iBAAiB,GAAG,CAAC;IAEzB,OAAO;QACL,IAAI;AACJ,QAAA,OAAO,EAAE,KAAK;AAEd,QAAA,IAAI,EAAE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