@swiftuijs/twill 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -7
- package/bin/run.mjs +2 -2
- package/dist/cli.js +6 -6
- package/dist/{compilation-cache-CuCGz02_.js → compilation-cache-7SugqJ4n.js} +2 -2
- package/dist/{compilation-cache-CuCGz02_.js.map → compilation-cache-7SugqJ4n.js.map} +1 -1
- package/dist/{compiler-DY1N07np.js → compiler-BdkU4Ruh.js} +85 -26
- package/dist/compiler-BdkU4Ruh.js.map +1 -0
- package/dist/config-la_KkjCS.js +1 -0
- package/dist/config.js +2 -1
- package/dist/{configuration-CTJjSu_h.js → configuration-BVMf6Q_j.js} +17 -7
- package/dist/configuration-BVMf6Q_j.js.map +1 -0
- package/dist/declarations-BTAS8Mb_.js +132 -0
- package/dist/declarations-BTAS8Mb_.js.map +1 -0
- package/dist/declarations.js +1 -131
- package/dist/defer.d.ts +1 -1
- package/dist/doctor-Co_pdZtt.js +202 -0
- package/dist/doctor-Co_pdZtt.js.map +1 -0
- package/dist/doctor.js +1 -201
- package/dist/editor.js +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{loader-compiler-DIw9aw5n.js → loader-compiler.js} +3 -3
- package/dist/loader-compiler.js.map +1 -0
- package/dist/loader-registration-B1ST9h1e.js +15 -0
- package/dist/loader-registration-B1ST9h1e.js.map +1 -0
- package/dist/loader-registration.d.ts +4 -0
- package/dist/loader-registration.js +2 -0
- package/dist/loader-state-DE2ArGYl.js +61 -0
- package/dist/loader-state-DE2ArGYl.js.map +1 -0
- package/dist/loader-state.d.ts +34 -0
- package/dist/loader-sync.d.ts +3 -0
- package/dist/loader-sync.js +28 -0
- package/dist/loader-sync.js.map +1 -0
- package/dist/loader.d.ts +2 -4
- package/dist/loader.js +9 -46
- package/dist/loader.js.map +1 -1
- package/dist/{plugin-Bks2hxCJ.js → plugin-DdTVagIU.js} +3 -3
- package/dist/{plugin-Bks2hxCJ.js.map → plugin-DdTVagIU.js.map} +1 -1
- package/dist/project-ZmlpFooa.js +444 -0
- package/dist/project-ZmlpFooa.js.map +1 -0
- package/dist/project.js +1 -438
- package/dist/recovery.d.ts +2 -2
- package/dist/register.js +2 -2
- package/dist/register.js.map +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.js +1 -1
- package/dist/syntax.js +1 -1
- package/dist/{transpile-DG81yfVs.js → transpile-CLNavDUr.js} +2 -2
- package/dist/{transpile-DG81yfVs.js.map → transpile-CLNavDUr.js.map} +1 -1
- package/dist/typescript-plugin.cjs +96 -33
- package/dist/typescript-plugin.cjs.map +1 -1
- package/dist/vite-BI-5KRgr.js +7 -0
- package/dist/vite-BI-5KRgr.js.map +1 -0
- package/dist/vite-react.js +1 -1
- package/dist/vite.js +1 -6
- package/dist/webpack.js +1 -1
- package/package.json +2 -2
- package/dist/compiler-DY1N07np.js.map +0 -1
- package/dist/configuration-CTJjSu_h.js.map +0 -1
- package/dist/declarations.js.map +0 -1
- package/dist/doctor.js.map +0 -1
- package/dist/loader-compiler-DIw9aw5n.js.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/vite.js.map +0 -1
package/dist/declarations.js
CHANGED
|
@@ -1,132 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import MagicString from "magic-string";
|
|
3
|
-
import { mkdirSync, renameSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { basename, dirname, relative, resolve } from "node:path";
|
|
5
|
-
import ts from "typescript";
|
|
6
|
-
import remapping from "@ampproject/remapping";
|
|
7
|
-
//#region src/declarations.ts
|
|
8
|
-
var moduleName = (value) => value.replace(/\.twillx?(?:\.tsx?)?$/, ".js").replace(/\.(?:tsx?|jsx)$/, ".js").replace(/\.(m|c)ts$/, ".$1js");
|
|
9
|
-
var outputName = (filename) => filename.replace(/\.twillx?\.d\.ts(?=\.map$|$)/, ".d.ts");
|
|
10
|
-
function moduleEdits(text, filename, source, redirects) {
|
|
11
|
-
const file = ts.createSourceFile(filename, text, ts.ScriptTarget.Latest, true);
|
|
12
|
-
const edits = new MagicString(text);
|
|
13
|
-
const visit = (node) => {
|
|
14
|
-
if (ts.isStringLiteral(node)) {
|
|
15
|
-
const parent = node.parent;
|
|
16
|
-
if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier === node || ts.isExternalModuleReference(parent) || ts.isLiteralTypeNode(parent) && ts.isImportTypeNode(parent.parent)) {
|
|
17
|
-
let value = moduleName(node.text);
|
|
18
|
-
if (source && node.text.startsWith(".")) {
|
|
19
|
-
const base = sourceFilename(resolve(dirname(source), node.text));
|
|
20
|
-
const target = [base, ...[
|
|
21
|
-
".twill",
|
|
22
|
-
".twillx",
|
|
23
|
-
".ts",
|
|
24
|
-
".tsx",
|
|
25
|
-
".mts",
|
|
26
|
-
".cts",
|
|
27
|
-
".js"
|
|
28
|
-
].map((ext) => base + ext)].map((candidate) => redirects.get(candidate)).find(Boolean);
|
|
29
|
-
if (target) {
|
|
30
|
-
value = relative(dirname(filename), target).replaceAll("\\", "/").replace(/\.d\.(ts|mts|cts)$/, (_, extension) => extension === "ts" ? ".js" : extension === "mts" ? ".mjs" : ".cjs");
|
|
31
|
-
if (!value.startsWith(".")) value = "./" + value;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (value !== node.text) edits.overwrite(node.getStart() + 1, node.end - 1, value);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
ts.forEachChild(node, visit);
|
|
38
|
-
};
|
|
39
|
-
visit(file);
|
|
40
|
-
return edits;
|
|
41
|
-
}
|
|
42
|
-
/** Emits ordinary declaration files; a reference build visits dependencies first.
|
|
43
|
-
* No output is written for a project with syntax, type or emit errors. */
|
|
44
|
-
function emitDeclarations(tsconfig, options = {}) {
|
|
45
|
-
const result = {
|
|
46
|
-
projects: [],
|
|
47
|
-
files: [],
|
|
48
|
-
diagnostics: []
|
|
49
|
-
};
|
|
50
|
-
const visited = /* @__PURE__ */ new Set();
|
|
51
|
-
const active = /* @__PURE__ */ new Set();
|
|
52
|
-
const redirects = /* @__PURE__ */ new Map();
|
|
53
|
-
const build = (config, root) => {
|
|
54
|
-
config = sourceFilename(resolve(config));
|
|
55
|
-
if (active.has(config)) throw new Error(`Circular project reference: ${config}`);
|
|
56
|
-
if (visited.has(config)) return;
|
|
57
|
-
active.add(config);
|
|
58
|
-
const parsed = ts.getParsedCommandLineOfConfigFile(config, {}, {
|
|
59
|
-
...ts.sys,
|
|
60
|
-
getCurrentDirectory: () => dirname(config),
|
|
61
|
-
onUnRecoverableConfigFileDiagnostic() {}
|
|
62
|
-
});
|
|
63
|
-
if (options.build) for (const reference of parsed?.projectReferences ?? []) build(ts.resolveProjectReferencePath(reference), false);
|
|
64
|
-
active.delete(config);
|
|
65
|
-
visited.add(config);
|
|
66
|
-
if (result.diagnostics.some((item) => item.category === "error")) return;
|
|
67
|
-
const project = new TwillProject(config, {}, { declarationRedirects: redirects });
|
|
68
|
-
try {
|
|
69
|
-
const outDir = resolve(root && options.outDir || parsed?.options.declarationDir || parsed?.options.outDir || resolve(project.root, "dist"));
|
|
70
|
-
const emitted = project.declarationOutput(outDir, options.declarationMap ?? true);
|
|
71
|
-
result.diagnostics.push(...emitted.diagnostics);
|
|
72
|
-
if (emitted.diagnostics.some((item) => item.category === "error")) return;
|
|
73
|
-
const inputs = new Set(project.sourceFiles().map((file) => ts.sys.useCaseSensitiveFileNames ? file : file.toLowerCase()));
|
|
74
|
-
const files = /* @__PURE__ */ new Map();
|
|
75
|
-
const edits = /* @__PURE__ */ new Map();
|
|
76
|
-
const projectRedirects = new Map(redirects);
|
|
77
|
-
const outputKeys = /* @__PURE__ */ new Set();
|
|
78
|
-
for (const file of emitted.files) if (!file.filename.endsWith(".map")) for (const source of file.sources) projectRedirects.set(source, outputName(file.filename));
|
|
79
|
-
for (const file of emitted.files) {
|
|
80
|
-
const filename = outputName(file.filename);
|
|
81
|
-
const key = ts.sys.useCaseSensitiveFileNames ? filename : filename.toLowerCase();
|
|
82
|
-
if (inputs.has(key)) throw new Error(`Declaration output would overwrite source: ${filename}`);
|
|
83
|
-
if (outputKeys.has(key)) throw new Error(`Declaration output collision: ${filename}`);
|
|
84
|
-
outputKeys.add(key);
|
|
85
|
-
if (!filename.endsWith(".map")) {
|
|
86
|
-
const changed = moduleEdits(file.text, filename, file.sources[0], projectRedirects);
|
|
87
|
-
edits.set(filename, changed);
|
|
88
|
-
files.set(filename, {
|
|
89
|
-
text: changed.toString().replace(/(sourceMappingURL=.*)\.twillx?\.d\.ts\.map/g, "$1.d.ts.map"),
|
|
90
|
-
sources: file.sources
|
|
91
|
-
});
|
|
92
|
-
} else files.set(filename, {
|
|
93
|
-
text: file.text,
|
|
94
|
-
sources: file.sources
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
for (const [filename, file] of files) if (filename.endsWith(".map")) {
|
|
98
|
-
const declaration = filename.slice(0, -4);
|
|
99
|
-
const originalMap = JSON.parse(file.text);
|
|
100
|
-
const source = sourceFilename(resolve(dirname(filename), originalMap.sourceRoot ?? "", decodeURIComponent(originalMap.sources[0] ?? "")));
|
|
101
|
-
const transformed = project.transformed(source);
|
|
102
|
-
const maps = [edits.get(declaration).generateMap({
|
|
103
|
-
source: declaration,
|
|
104
|
-
hires: true,
|
|
105
|
-
includeContent: true
|
|
106
|
-
}), originalMap];
|
|
107
|
-
if (transformed) maps.push(transformed.map);
|
|
108
|
-
const combined = remapping(maps, () => null);
|
|
109
|
-
combined.file = basename(declaration);
|
|
110
|
-
combined.sources = combined.sources.map(() => relative(dirname(filename), source).replaceAll("\\", "/"));
|
|
111
|
-
file.text = JSON.stringify(combined);
|
|
112
|
-
}
|
|
113
|
-
for (const [filename, file] of files) {
|
|
114
|
-
mkdirSync(dirname(filename), { recursive: true });
|
|
115
|
-
const staging = filename + ".twill-tmp";
|
|
116
|
-
writeFileSync(staging, file.text);
|
|
117
|
-
renameSync(staging, filename);
|
|
118
|
-
result.files.push(filename);
|
|
119
|
-
if (!filename.endsWith(".map")) for (const source of file.sources) redirects.set(source, filename);
|
|
120
|
-
}
|
|
121
|
-
result.projects.push(config);
|
|
122
|
-
} finally {
|
|
123
|
-
project.dispose();
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
build(tsconfig, true);
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
|
-
//#endregion
|
|
1
|
+
import { t as emitDeclarations } from "./declarations-BTAS8Mb_.js";
|
|
130
2
|
export { emitDeclarations };
|
|
131
|
-
|
|
132
|
-
//# sourceMappingURL=declarations.js.map
|
package/dist/defer.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ type Comment = {
|
|
|
12
12
|
value: string;
|
|
13
13
|
type: string;
|
|
14
14
|
};
|
|
15
|
-
/**
|
|
15
|
+
/** Native finally where scope permits; callbacks retain dynamic registration semantics. */
|
|
16
16
|
export declare function lowerDefers(source: string, ast: Node, code: MagicString, language: Language, usedNames: Set<string>, contentStarts: Map<Node, number>, comments: Comment[], runtime: 'inline' | 'external', sourceType: 'module' | 'script', fail: (node: Node, message: string) => never): void;
|
|
17
17
|
export {};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { n as isTwillFile } from "./extensions-B1xTkoYP.js";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
var package_default = {
|
|
4
|
+
name: "@swiftuijs/twill",
|
|
5
|
+
version: "0.3.1",
|
|
6
|
+
description: "Twill extends TypeScript with Swift-inspired syntax: trailing closures, guards, defer and checked switch expressions. Compiles to ordinary JavaScript.",
|
|
7
|
+
main: "./dist/typescript-plugin.cjs",
|
|
8
|
+
repository: {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/swiftuijs/twill.git",
|
|
11
|
+
"directory": "packages/twill"
|
|
12
|
+
},
|
|
13
|
+
keywords: [
|
|
14
|
+
"javascript",
|
|
15
|
+
"typescript",
|
|
16
|
+
"trailing-closures",
|
|
17
|
+
"swift",
|
|
18
|
+
"vite",
|
|
19
|
+
"unplugin",
|
|
20
|
+
"react",
|
|
21
|
+
"vue",
|
|
22
|
+
"twill",
|
|
23
|
+
"guard",
|
|
24
|
+
"defer"
|
|
25
|
+
],
|
|
26
|
+
author: {
|
|
27
|
+
"name": "forth.ink",
|
|
28
|
+
"url": "https://forth.ink"
|
|
29
|
+
},
|
|
30
|
+
license: "MIT",
|
|
31
|
+
type: "module",
|
|
32
|
+
bugs: { "url": "https://github.com/swiftuijs/twill/issues" },
|
|
33
|
+
homepage: "https://twill.evecalm.com/",
|
|
34
|
+
dependencies: {
|
|
35
|
+
"@ampproject/remapping": "^2.3.0",
|
|
36
|
+
"@jridgewell/trace-mapping": "^0.3.31",
|
|
37
|
+
"acorn": "8.18.0",
|
|
38
|
+
"acorn-jsx": "^5.3.2",
|
|
39
|
+
"acorn-typescript": "1.4.13",
|
|
40
|
+
"magic-string": "^1.4.2",
|
|
41
|
+
"typescript": "catalog:",
|
|
42
|
+
"unplugin": "^3.4.0"
|
|
43
|
+
},
|
|
44
|
+
sideEffects: false,
|
|
45
|
+
engines: { "node": "^20.19.0 || >=22.12.0" },
|
|
46
|
+
files: [
|
|
47
|
+
"bin",
|
|
48
|
+
"dist/**/*.js",
|
|
49
|
+
"dist/**/*.js.map",
|
|
50
|
+
"dist/**/*.d.ts",
|
|
51
|
+
"schemas",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE",
|
|
54
|
+
"dist/**/*.cjs",
|
|
55
|
+
"dist/**/*.cjs.map",
|
|
56
|
+
"dist/*.LICENSE.txt"
|
|
57
|
+
],
|
|
58
|
+
bin: { "twill": "./bin/twill.mjs" },
|
|
59
|
+
exports: {
|
|
60
|
+
".": {
|
|
61
|
+
"types": "./dist/index.d.ts",
|
|
62
|
+
"import": "./dist/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./vite": {
|
|
65
|
+
"types": "./dist/vite.d.ts",
|
|
66
|
+
"import": "./dist/vite.js"
|
|
67
|
+
},
|
|
68
|
+
"./rollup": {
|
|
69
|
+
"types": "./dist/rollup.d.ts",
|
|
70
|
+
"import": "./dist/rollup.js"
|
|
71
|
+
},
|
|
72
|
+
"./esbuild": {
|
|
73
|
+
"types": "./dist/esbuild.d.ts",
|
|
74
|
+
"import": "./dist/esbuild.js"
|
|
75
|
+
},
|
|
76
|
+
"./webpack": {
|
|
77
|
+
"types": "./dist/webpack.d.ts",
|
|
78
|
+
"import": "./dist/webpack.js"
|
|
79
|
+
},
|
|
80
|
+
"./rspack": {
|
|
81
|
+
"types": "./dist/rspack.d.ts",
|
|
82
|
+
"import": "./dist/rspack.js"
|
|
83
|
+
},
|
|
84
|
+
"./project": {
|
|
85
|
+
"types": "./dist/project.d.ts",
|
|
86
|
+
"import": "./dist/project.js"
|
|
87
|
+
},
|
|
88
|
+
"./editor": {
|
|
89
|
+
"types": "./dist/editor.d.ts",
|
|
90
|
+
"import": "./dist/editor.js"
|
|
91
|
+
},
|
|
92
|
+
"./register": {
|
|
93
|
+
"types": "./dist/register.d.ts",
|
|
94
|
+
"import": "./dist/register.js"
|
|
95
|
+
},
|
|
96
|
+
"./schema": "./schemas/twill.schema.json",
|
|
97
|
+
"./typescript-plugin": {
|
|
98
|
+
"types": "./dist/typescript-plugin.d.ts",
|
|
99
|
+
"require": "./dist/typescript-plugin.cjs",
|
|
100
|
+
"default": "./dist/typescript-plugin.cjs"
|
|
101
|
+
},
|
|
102
|
+
"./doctor": {
|
|
103
|
+
"types": "./dist/doctor.d.ts",
|
|
104
|
+
"import": "./dist/doctor.js"
|
|
105
|
+
},
|
|
106
|
+
"./syntax": {
|
|
107
|
+
"types": "./dist/syntax.d.ts",
|
|
108
|
+
"import": "./dist/syntax.js"
|
|
109
|
+
},
|
|
110
|
+
"./config": {
|
|
111
|
+
"types": "./dist/config.d.ts",
|
|
112
|
+
"import": "./dist/config.js"
|
|
113
|
+
},
|
|
114
|
+
"./declarations": {
|
|
115
|
+
"types": "./dist/declarations.d.ts",
|
|
116
|
+
"import": "./dist/declarations.js"
|
|
117
|
+
},
|
|
118
|
+
"./vite-react": {
|
|
119
|
+
"types": "./dist/vite-react.d.ts",
|
|
120
|
+
"import": "./dist/vite-react.js"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
peerDependencies: {
|
|
124
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
125
|
+
"vue": "^3.3.0",
|
|
126
|
+
"@vitejs/plugin-react": "^6.1.1"
|
|
127
|
+
},
|
|
128
|
+
peerDependenciesMeta: {
|
|
129
|
+
"react": { "optional": true },
|
|
130
|
+
"vue": { "optional": true },
|
|
131
|
+
"@vitejs/plugin-react": { "optional": true }
|
|
132
|
+
},
|
|
133
|
+
types: "./dist/index.d.ts",
|
|
134
|
+
publishConfig: { "access": "public" },
|
|
135
|
+
module: "./dist/index.js",
|
|
136
|
+
scripts: {
|
|
137
|
+
"build": "node ../../scripts/generate-runtime-helper.mjs && vite build && vite build --config vite.plugin.config.ts && node scripts/prepare-core.mjs",
|
|
138
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
139
|
+
"prepack": "pnpm run build",
|
|
140
|
+
"test:unit": "vitest run",
|
|
141
|
+
"test:watch": "vitest",
|
|
142
|
+
"test:coverage": "vitest run --coverage",
|
|
143
|
+
"test:package": "node tests/consumer.mjs",
|
|
144
|
+
"test:size": "node tests/bundle-size.mjs",
|
|
145
|
+
"test:browser": "playwright test",
|
|
146
|
+
"benchmark": "node benchmarks/compiler.mjs",
|
|
147
|
+
"test": "pnpm run test:unit",
|
|
148
|
+
"benchmark:branching": "node benchmarks/branching.mjs",
|
|
149
|
+
"benchmark:enum-patterns": "node benchmarks/enum-patterns.mjs",
|
|
150
|
+
"benchmark:runtime": "node benchmarks/runtime-helpers.mjs",
|
|
151
|
+
"benchmark:if-bindings": "node benchmarks/if-bindings.mjs"
|
|
152
|
+
},
|
|
153
|
+
devDependencies: {
|
|
154
|
+
"vite": "catalog:",
|
|
155
|
+
"vite-plugin-dts": "^5.1.2",
|
|
156
|
+
"@types/node": "catalog:",
|
|
157
|
+
"@vitejs/plugin-react": "catalog:",
|
|
158
|
+
"vitest": "catalog:",
|
|
159
|
+
"@vitest/coverage-v8": "catalog:",
|
|
160
|
+
"@rspack/core": "catalog:",
|
|
161
|
+
"@types/react": "catalog:",
|
|
162
|
+
"@types/react-dom": "catalog:",
|
|
163
|
+
"@vue/server-renderer": "catalog:",
|
|
164
|
+
"esbuild": "catalog:",
|
|
165
|
+
"react": "catalog:",
|
|
166
|
+
"react-dom": "catalog:",
|
|
167
|
+
"rollup": "catalog:",
|
|
168
|
+
"vue": "catalog:",
|
|
169
|
+
"webpack": "catalog:",
|
|
170
|
+
"@playwright/test": "catalog:",
|
|
171
|
+
"@swiftuijs/twill-runtime": "workspace:*"
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/doctor.ts
|
|
176
|
+
/** Shareable diagnostics without source contents or environment-variable values. */
|
|
177
|
+
function inspectProject(project, filename) {
|
|
178
|
+
const started = performance.now();
|
|
179
|
+
const diagnostics = project.diagnostics(filename);
|
|
180
|
+
const files = project.sourceFiles();
|
|
181
|
+
return {
|
|
182
|
+
twillVersion: package_default.version,
|
|
183
|
+
typescriptVersion: ts.version,
|
|
184
|
+
nodeVersion: process.version,
|
|
185
|
+
root: project.root,
|
|
186
|
+
configFiles: project.configFiles,
|
|
187
|
+
compilerOptions: project.compilerOptions,
|
|
188
|
+
files: {
|
|
189
|
+
total: files.length,
|
|
190
|
+
twill: files.filter(isTwillFile).length,
|
|
191
|
+
native: files.filter((file) => !isTwillFile(file)).length
|
|
192
|
+
},
|
|
193
|
+
sourceFiles: files,
|
|
194
|
+
diagnostics,
|
|
195
|
+
diagnosticTimeMs: performance.now() - started,
|
|
196
|
+
ok: !diagnostics.some((diagnostic) => diagnostic.category === "error")
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
export { inspectProject as t };
|
|
201
|
+
|
|
202
|
+
//# sourceMappingURL=doctor-Co_pdZtt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor-Co_pdZtt.js","names":["metadata"],"sources":["../package.json","../src/doctor.ts"],"sourcesContent":["{\n \"name\": \"@swiftuijs/twill\",\n \"version\": \"0.3.1\",\n \"description\": \"Twill extends TypeScript with Swift-inspired syntax: trailing closures, guards, defer and checked switch expressions. Compiles to ordinary JavaScript.\",\n \"main\": \"./dist/typescript-plugin.cjs\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/swiftuijs/twill.git\",\n \"directory\": \"packages/twill\"\n },\n \"keywords\": [\n \"javascript\",\n \"typescript\",\n \"trailing-closures\",\n \"swift\",\n \"vite\",\n \"unplugin\",\n \"react\",\n \"vue\",\n \"twill\",\n \"guard\",\n \"defer\"\n ],\n \"author\": {\n \"name\": \"forth.ink\",\n \"url\": \"https://forth.ink\"\n },\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"bugs\": {\n \"url\": \"https://github.com/swiftuijs/twill/issues\"\n },\n \"homepage\": \"https://twill.evecalm.com/\",\n \"dependencies\": {\n \"@ampproject/remapping\": \"^2.3.0\",\n \"@jridgewell/trace-mapping\": \"^0.3.31\",\n \"acorn\": \"8.18.0\",\n \"acorn-jsx\": \"^5.3.2\",\n \"acorn-typescript\": \"1.4.13\",\n \"magic-string\": \"^1.4.2\",\n \"typescript\": \"catalog:\",\n \"unplugin\": \"^3.4.0\"\n },\n \"sideEffects\": false,\n \"engines\": {\n \"node\": \"^20.19.0 || >=22.12.0\"\n },\n \"files\": [\n \"bin\",\n \"dist/**/*.js\",\n \"dist/**/*.js.map\",\n \"dist/**/*.d.ts\",\n \"schemas\",\n \"README.md\",\n \"LICENSE\",\n \"dist/**/*.cjs\",\n \"dist/**/*.cjs.map\",\n \"dist/*.LICENSE.txt\"\n ],\n \"bin\": {\n \"twill\": \"./bin/twill.mjs\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\"\n },\n \"./vite\": {\n \"types\": \"./dist/vite.d.ts\",\n \"import\": \"./dist/vite.js\"\n },\n \"./rollup\": {\n \"types\": \"./dist/rollup.d.ts\",\n \"import\": \"./dist/rollup.js\"\n },\n \"./esbuild\": {\n \"types\": \"./dist/esbuild.d.ts\",\n \"import\": \"./dist/esbuild.js\"\n },\n \"./webpack\": {\n \"types\": \"./dist/webpack.d.ts\",\n \"import\": \"./dist/webpack.js\"\n },\n \"./rspack\": {\n \"types\": \"./dist/rspack.d.ts\",\n \"import\": \"./dist/rspack.js\"\n },\n \"./project\": {\n \"types\": \"./dist/project.d.ts\",\n \"import\": \"./dist/project.js\"\n },\n \"./editor\": {\n \"types\": \"./dist/editor.d.ts\",\n \"import\": \"./dist/editor.js\"\n },\n \"./register\": {\n \"types\": \"./dist/register.d.ts\",\n \"import\": \"./dist/register.js\"\n },\n \"./schema\": \"./schemas/twill.schema.json\",\n \"./typescript-plugin\": {\n \"types\": \"./dist/typescript-plugin.d.ts\",\n \"require\": \"./dist/typescript-plugin.cjs\",\n \"default\": \"./dist/typescript-plugin.cjs\"\n },\n \"./doctor\": {\n \"types\": \"./dist/doctor.d.ts\",\n \"import\": \"./dist/doctor.js\"\n },\n \"./syntax\": {\n \"types\": \"./dist/syntax.d.ts\",\n \"import\": \"./dist/syntax.js\"\n },\n \"./config\": {\n \"types\": \"./dist/config.d.ts\",\n \"import\": \"./dist/config.js\"\n },\n \"./declarations\": {\n \"types\": \"./dist/declarations.d.ts\",\n \"import\": \"./dist/declarations.js\"\n },\n \"./vite-react\": {\n \"types\": \"./dist/vite-react.d.ts\",\n \"import\": \"./dist/vite-react.js\"\n }\n },\n \"peerDependencies\": {\n \"react\": \"^18.2.0 || ^19.0.0\",\n \"vue\": \"^3.3.0\",\n \"@vitejs/plugin-react\": \"^6.1.1\"\n },\n \"peerDependenciesMeta\": {\n \"react\": {\n \"optional\": true\n },\n \"vue\": {\n \"optional\": true\n },\n \"@vitejs/plugin-react\": {\n \"optional\": true\n }\n },\n \"types\": \"./dist/index.d.ts\",\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"module\": \"./dist/index.js\",\n \"scripts\": {\n \"build\": \"node ../../scripts/generate-runtime-helper.mjs && vite build && vite build --config vite.plugin.config.ts && node scripts/prepare-core.mjs\",\n \"typecheck\": \"tsc --noEmit -p tsconfig.json\",\n \"prepack\": \"pnpm run build\",\n \"test:unit\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"test:package\": \"node tests/consumer.mjs\",\n \"test:size\": \"node tests/bundle-size.mjs\",\n \"test:browser\": \"playwright test\",\n \"benchmark\": \"node benchmarks/compiler.mjs\",\n \"test\": \"pnpm run test:unit\",\n \"benchmark:branching\": \"node benchmarks/branching.mjs\",\n \"benchmark:enum-patterns\": \"node benchmarks/enum-patterns.mjs\",\n \"benchmark:runtime\": \"node benchmarks/runtime-helpers.mjs\",\n \"benchmark:if-bindings\": \"node benchmarks/if-bindings.mjs\"\n },\n \"devDependencies\": {\n \"vite\": \"catalog:\",\n \"vite-plugin-dts\": \"^5.1.2\",\n \"@types/node\": \"catalog:\",\n \"@vitejs/plugin-react\": \"catalog:\",\n \"vitest\": \"catalog:\",\n \"@vitest/coverage-v8\": \"catalog:\",\n \"@rspack/core\": \"catalog:\",\n \"@types/react\": \"catalog:\",\n \"@types/react-dom\": \"catalog:\",\n \"@vue/server-renderer\": \"catalog:\",\n \"esbuild\": \"catalog:\",\n \"react\": \"catalog:\",\n \"react-dom\": \"catalog:\",\n \"rollup\": \"catalog:\",\n \"vue\": \"catalog:\",\n \"webpack\": \"catalog:\",\n \"@playwright/test\": \"catalog:\",\n \"@swiftuijs/twill-runtime\": \"workspace:*\"\n }\n}\n","import ts from 'typescript';\nimport metadata from '../package.json';\nimport { TwillProject } from './project.js';\nimport { isTwillFile } from './compiler.js';\n\n/** Shareable diagnostics without source contents or environment-variable values. */\nexport function inspectProject(project: TwillProject, filename?: string) {\n const started = performance.now();\n const diagnostics = project.diagnostics(filename);\n const files = project.sourceFiles();\n return {\n twillVersion: metadata.version,\n typescriptVersion: ts.version,\n nodeVersion: process.version,\n root: project.root,\n configFiles: project.configFiles,\n compilerOptions: project.compilerOptions,\n files: {\n total: files.length,\n twill: files.filter(isTwillFile).length,\n native: files.filter((file) => !isTwillFile(file)).length,\n },\n sourceFiles: files,\n diagnostics,\n diagnosticTimeMs: performance.now() - started,\n ok: !diagnostics.some((diagnostic) => diagnostic.category === 'error'),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACMA,SAAgB,eAAe,SAAuB,UAAmB;CACvE,MAAM,UAAU,YAAY,IAAI;CAChC,MAAM,cAAc,QAAQ,YAAY,QAAQ;CAChD,MAAM,QAAQ,QAAQ,YAAY;CAClC,OAAO;EACL,cAAcA,gBAAS;EACvB,mBAAmB,GAAG;EACtB,aAAa,QAAQ;EACrB,MAAM,QAAQ;EACd,aAAa,QAAQ;EACrB,iBAAiB,QAAQ;EACzB,OAAO;GACL,OAAO,MAAM;GACb,OAAO,MAAM,OAAO,WAAW,CAAC,CAAC;GACjC,QAAQ,MAAM,QAAQ,SAAS,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC;EACrD;EACA,aAAa;EACb;EACA,kBAAkB,YAAY,IAAI,IAAI;EACtC,IAAI,CAAC,YAAY,MAAM,eAAe,WAAW,aAAa,OAAO;CACvE;AACF"}
|
package/dist/doctor.js
CHANGED
|
@@ -1,202 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
var package_default = {
|
|
4
|
-
name: "@swiftuijs/twill",
|
|
5
|
-
version: "0.2.0",
|
|
6
|
-
description: "Twill extends TypeScript with Swift-inspired syntax: trailing closures, guards, defer and checked switch expressions. Compiles to ordinary JavaScript.",
|
|
7
|
-
main: "./dist/typescript-plugin.cjs",
|
|
8
|
-
repository: {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/swiftuijs/twill.git",
|
|
11
|
-
"directory": "packages/twill"
|
|
12
|
-
},
|
|
13
|
-
keywords: [
|
|
14
|
-
"javascript",
|
|
15
|
-
"typescript",
|
|
16
|
-
"trailing-closures",
|
|
17
|
-
"swift",
|
|
18
|
-
"vite",
|
|
19
|
-
"unplugin",
|
|
20
|
-
"react",
|
|
21
|
-
"vue",
|
|
22
|
-
"twill",
|
|
23
|
-
"guard",
|
|
24
|
-
"defer"
|
|
25
|
-
],
|
|
26
|
-
author: {
|
|
27
|
-
"name": "forth.ink",
|
|
28
|
-
"url": "https://forth.ink"
|
|
29
|
-
},
|
|
30
|
-
license: "MIT",
|
|
31
|
-
type: "module",
|
|
32
|
-
bugs: { "url": "https://github.com/swiftuijs/twill/issues" },
|
|
33
|
-
homepage: "https://twill.evecalm.com/",
|
|
34
|
-
dependencies: {
|
|
35
|
-
"@ampproject/remapping": "^2.3.0",
|
|
36
|
-
"@jridgewell/trace-mapping": "^0.3.31",
|
|
37
|
-
"acorn": "8.18.0",
|
|
38
|
-
"acorn-jsx": "^5.3.2",
|
|
39
|
-
"acorn-typescript": "1.4.13",
|
|
40
|
-
"magic-string": "^1.4.2",
|
|
41
|
-
"typescript": "catalog:",
|
|
42
|
-
"unplugin": "^3.4.0"
|
|
43
|
-
},
|
|
44
|
-
sideEffects: false,
|
|
45
|
-
engines: { "node": "^20.19.0 || >=22.12.0" },
|
|
46
|
-
files: [
|
|
47
|
-
"bin",
|
|
48
|
-
"dist/**/*.js",
|
|
49
|
-
"dist/**/*.js.map",
|
|
50
|
-
"dist/**/*.d.ts",
|
|
51
|
-
"schemas",
|
|
52
|
-
"README.md",
|
|
53
|
-
"LICENSE",
|
|
54
|
-
"dist/**/*.cjs",
|
|
55
|
-
"dist/**/*.cjs.map",
|
|
56
|
-
"dist/*.LICENSE.txt"
|
|
57
|
-
],
|
|
58
|
-
bin: { "twill": "./bin/twill.mjs" },
|
|
59
|
-
exports: {
|
|
60
|
-
".": {
|
|
61
|
-
"types": "./dist/index.d.ts",
|
|
62
|
-
"import": "./dist/index.js"
|
|
63
|
-
},
|
|
64
|
-
"./vite": {
|
|
65
|
-
"types": "./dist/vite.d.ts",
|
|
66
|
-
"import": "./dist/vite.js"
|
|
67
|
-
},
|
|
68
|
-
"./rollup": {
|
|
69
|
-
"types": "./dist/rollup.d.ts",
|
|
70
|
-
"import": "./dist/rollup.js"
|
|
71
|
-
},
|
|
72
|
-
"./esbuild": {
|
|
73
|
-
"types": "./dist/esbuild.d.ts",
|
|
74
|
-
"import": "./dist/esbuild.js"
|
|
75
|
-
},
|
|
76
|
-
"./webpack": {
|
|
77
|
-
"types": "./dist/webpack.d.ts",
|
|
78
|
-
"import": "./dist/webpack.js"
|
|
79
|
-
},
|
|
80
|
-
"./rspack": {
|
|
81
|
-
"types": "./dist/rspack.d.ts",
|
|
82
|
-
"import": "./dist/rspack.js"
|
|
83
|
-
},
|
|
84
|
-
"./project": {
|
|
85
|
-
"types": "./dist/project.d.ts",
|
|
86
|
-
"import": "./dist/project.js"
|
|
87
|
-
},
|
|
88
|
-
"./editor": {
|
|
89
|
-
"types": "./dist/editor.d.ts",
|
|
90
|
-
"import": "./dist/editor.js"
|
|
91
|
-
},
|
|
92
|
-
"./register": {
|
|
93
|
-
"types": "./dist/register.d.ts",
|
|
94
|
-
"import": "./dist/register.js"
|
|
95
|
-
},
|
|
96
|
-
"./schema": "./schemas/twill.schema.json",
|
|
97
|
-
"./typescript-plugin": {
|
|
98
|
-
"types": "./dist/typescript-plugin.d.ts",
|
|
99
|
-
"require": "./dist/typescript-plugin.cjs",
|
|
100
|
-
"default": "./dist/typescript-plugin.cjs"
|
|
101
|
-
},
|
|
102
|
-
"./doctor": {
|
|
103
|
-
"types": "./dist/doctor.d.ts",
|
|
104
|
-
"import": "./dist/doctor.js"
|
|
105
|
-
},
|
|
106
|
-
"./syntax": {
|
|
107
|
-
"types": "./dist/syntax.d.ts",
|
|
108
|
-
"import": "./dist/syntax.js"
|
|
109
|
-
},
|
|
110
|
-
"./config": {
|
|
111
|
-
"types": "./dist/config.d.ts",
|
|
112
|
-
"import": "./dist/config.js"
|
|
113
|
-
},
|
|
114
|
-
"./declarations": {
|
|
115
|
-
"types": "./dist/declarations.d.ts",
|
|
116
|
-
"import": "./dist/declarations.js"
|
|
117
|
-
},
|
|
118
|
-
"./vite-react": {
|
|
119
|
-
"types": "./dist/vite-react.d.ts",
|
|
120
|
-
"import": "./dist/vite-react.js"
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
peerDependencies: {
|
|
124
|
-
"react": "^18.2.0 || ^19.0.0",
|
|
125
|
-
"vue": "^3.3.0",
|
|
126
|
-
"@vitejs/plugin-react": "^6.1.1"
|
|
127
|
-
},
|
|
128
|
-
peerDependenciesMeta: {
|
|
129
|
-
"react": { "optional": true },
|
|
130
|
-
"vue": { "optional": true },
|
|
131
|
-
"@vitejs/plugin-react": { "optional": true }
|
|
132
|
-
},
|
|
133
|
-
types: "./dist/index.d.ts",
|
|
134
|
-
publishConfig: { "access": "public" },
|
|
135
|
-
module: "./dist/index.js",
|
|
136
|
-
scripts: {
|
|
137
|
-
"build": "node ../../scripts/generate-runtime-helper.mjs && vite build && vite build --config vite.plugin.config.ts && node scripts/prepare-core.mjs",
|
|
138
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
139
|
-
"prepack": "pnpm run build",
|
|
140
|
-
"test:unit": "vitest run",
|
|
141
|
-
"test:watch": "vitest",
|
|
142
|
-
"test:coverage": "vitest run --coverage",
|
|
143
|
-
"test:package": "node tests/consumer.mjs",
|
|
144
|
-
"test:size": "node tests/bundle-size.mjs",
|
|
145
|
-
"test:browser": "playwright test",
|
|
146
|
-
"benchmark": "node benchmarks/compiler.mjs",
|
|
147
|
-
"test": "pnpm run test:unit",
|
|
148
|
-
"benchmark:branching": "node benchmarks/branching.mjs",
|
|
149
|
-
"benchmark:enum-patterns": "node benchmarks/enum-patterns.mjs",
|
|
150
|
-
"benchmark:runtime": "node benchmarks/runtime-helpers.mjs",
|
|
151
|
-
"benchmark:if-bindings": "node benchmarks/if-bindings.mjs"
|
|
152
|
-
},
|
|
153
|
-
devDependencies: {
|
|
154
|
-
"vite": "catalog:",
|
|
155
|
-
"vite-plugin-dts": "^5.1.2",
|
|
156
|
-
"@types/node": "catalog:",
|
|
157
|
-
"@vitejs/plugin-react": "catalog:",
|
|
158
|
-
"vitest": "catalog:",
|
|
159
|
-
"@vitest/coverage-v8": "catalog:",
|
|
160
|
-
"@rspack/core": "catalog:",
|
|
161
|
-
"@types/react": "catalog:",
|
|
162
|
-
"@types/react-dom": "catalog:",
|
|
163
|
-
"@vue/server-renderer": "catalog:",
|
|
164
|
-
"esbuild": "catalog:",
|
|
165
|
-
"react": "catalog:",
|
|
166
|
-
"react-dom": "catalog:",
|
|
167
|
-
"rollup": "catalog:",
|
|
168
|
-
"vue": "catalog:",
|
|
169
|
-
"webpack": "catalog:",
|
|
170
|
-
"@playwright/test": "catalog:",
|
|
171
|
-
"@swiftuijs/twill-runtime": "workspace:*"
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/doctor.ts
|
|
176
|
-
/** Shareable diagnostics without source contents or environment-variable values. */
|
|
177
|
-
function inspectProject(project, filename) {
|
|
178
|
-
const started = performance.now();
|
|
179
|
-
const diagnostics = project.diagnostics(filename);
|
|
180
|
-
const files = project.sourceFiles();
|
|
181
|
-
return {
|
|
182
|
-
twillVersion: package_default.version,
|
|
183
|
-
typescriptVersion: ts.version,
|
|
184
|
-
nodeVersion: process.version,
|
|
185
|
-
root: project.root,
|
|
186
|
-
configFiles: project.configFiles,
|
|
187
|
-
compilerOptions: project.compilerOptions,
|
|
188
|
-
files: {
|
|
189
|
-
total: files.length,
|
|
190
|
-
twill: files.filter(isTwillFile).length,
|
|
191
|
-
native: files.filter((file) => !isTwillFile(file)).length
|
|
192
|
-
},
|
|
193
|
-
sourceFiles: files,
|
|
194
|
-
diagnostics,
|
|
195
|
-
diagnosticTimeMs: performance.now() - started,
|
|
196
|
-
ok: !diagnostics.some((diagnostic) => diagnostic.category === "error")
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
//#endregion
|
|
1
|
+
import { t as inspectProject } from "./doctor-Co_pdZtt.js";
|
|
200
2
|
export { inspectProject };
|
|
201
|
-
|
|
202
|
-
//# sourceMappingURL=doctor.js.map
|
package/dist/editor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as isTwillFile } from "./extensions-B1xTkoYP.js";
|
|
2
|
-
import { sourceFilename, virtualFilename } from "./project.js";
|
|
2
|
+
import { n as sourceFilename, r as virtualFilename } from "./project-ZmlpFooa.js";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
//#region src/editor.ts
|
|
5
5
|
/** Shared semantic requests and conservative source edits for both editor hosts. */
|
package/dist/esbuild.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as transform, i as originalPosition, n as generatedPosition, r as inferLanguage, t as TwillSyntaxError } from "./compiler-
|
|
1
|
+
import { a as transform, i as originalPosition, n as generatedPosition, r as inferLanguage, t as TwillSyntaxError } from "./compiler-BdkU4Ruh.js";
|
|
2
2
|
import { n as isTwillFile, t as extensions } from "./extensions-B1xTkoYP.js";
|
|
3
3
|
export { TwillSyntaxError, extensions, generatedPosition, inferLanguage, isTwillFile, originalPosition, transform };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as loaderConfiguration } from "./configuration-
|
|
2
|
-
import { n as transpileNative, t as transpile } from "./transpile-
|
|
1
|
+
import { r as loaderConfiguration } from "./configuration-BVMf6Q_j.js";
|
|
2
|
+
import { n as transpileNative, t as transpile } from "./transpile-CLNavDUr.js";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
//#region src/loader-compiler.ts
|
|
5
5
|
function compileModule(source, filename, dialect) {
|
|
@@ -16,4 +16,4 @@ function compileModule(source, filename, dialect) {
|
|
|
16
16
|
//#endregion
|
|
17
17
|
export { compileModule };
|
|
18
18
|
|
|
19
|
-
//# sourceMappingURL=loader-compiler
|
|
19
|
+
//# sourceMappingURL=loader-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-compiler.js","names":[],"sources":["../src/loader-compiler.ts"],"sourcesContent":["import ts from 'typescript';\nimport { transpile, transpileNative } from './transpile.js';\nimport { loaderConfiguration } from './configuration.js';\n\nexport function compileModule(source: string, filename: string, dialect: boolean) {\n const { config, observations } = loaderConfiguration(filename);\n const result = dialect\n ? transpile(source, { ...config, filename }, ts.ScriptTarget.ES2022)\n : transpileNative(\n source,\n filename,\n undefined,\n undefined,\n config.jsxImportSource,\n ts.ScriptTarget.ES2022,\n );\n return {\n source:\n result.code +\n '\\n//# sourceMappingURL=data:application/json;base64,' +\n Buffer.from(result.map).toString('base64'),\n observations,\n };\n}\n"],"mappings":";;;;AAIA,SAAgB,cAAc,QAAgB,UAAkB,SAAkB;CAChF,MAAM,EAAE,QAAQ,iBAAiB,oBAAoB,QAAQ;CAC7D,MAAM,SAAS,UACX,UAAU,QAAQ;EAAE,GAAG;EAAQ;CAAS,GAAG,GAAG,aAAa,MAAM,IACjE,gBACE,QACA,UACA,KAAA,GACA,KAAA,GACA,OAAO,iBACP,GAAG,aAAa,MAClB;CACJ,OAAO;EACL,QACE,OAAO,OACP,yDACA,OAAO,KAAK,OAAO,GAAG,CAAC,CAAC,SAAS,QAAQ;EAC3C;CACF;AACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as nodeModule from "node:module";
|
|
2
|
+
//#region src/loader-registration.ts
|
|
3
|
+
/** Internal registrar shared by the CLI and the public --import entry. */
|
|
4
|
+
async function registerLoader(data = {}) {
|
|
5
|
+
if (typeof nodeModule.registerHooks !== "function") {
|
|
6
|
+
nodeModule.register("./loader.js", import.meta.url, { data });
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const { createHooks } = await import("./loader-sync.js");
|
|
10
|
+
return nodeModule.registerHooks(createHooks(data));
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { registerLoader as t };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=loader-registration-B1ST9h1e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-registration-B1ST9h1e.js","names":[],"sources":["../src/loader-registration.ts"],"sourcesContent":["import * as nodeModule from 'node:module';\nimport type { LoaderOptions } from './loader-state.js';\n\n/** Internal registrar shared by the CLI and the public --import entry. */\nexport async function registerLoader(data: LoaderOptions = {}) {\n if (typeof nodeModule.registerHooks !== 'function') {\n nodeModule.register('./loader.js', import.meta.url, { data });\n return;\n }\n const { createHooks } = await import('./loader-sync.js');\n return nodeModule.registerHooks(createHooks(data));\n}\n"],"mappings":";;;AAIA,eAAsB,eAAe,OAAsB,CAAC,GAAG;CAC7D,IAAI,OAAO,WAAW,kBAAkB,YAAY;EAClD,WAAW,SAAS,eAAe,YAAY,KAAK,EAAE,KAAK,CAAC;EAC5D;CACF;CACA,MAAM,EAAE,gBAAgB,MAAM,OAAO;CACrC,OAAO,WAAW,cAAc,YAAY,IAAI,CAAC;AACnD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LoaderOptions } from './loader-state.js';
|
|
2
|
+
import * as nodeModule from 'node:module';
|
|
3
|
+
/** Internal registrar shared by the CLI and the public --import entry. */
|
|
4
|
+
export declare function registerLoader(data?: LoaderOptions): Promise<nodeModule.ModuleHooks | undefined>;
|