@swiftuijs/twill 0.3.0 → 0.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.
Files changed (72) hide show
  1. package/README.md +8 -3
  2. package/bin/run.mjs +2 -2
  3. package/dist/branches.d.ts +7 -1
  4. package/dist/cli.js +7 -8
  5. package/dist/{compilation-cache-7SugqJ4n.js → compilation-cache-BrV71YKt.js} +2 -3
  6. package/dist/{compilation-cache-7SugqJ4n.js.map → compilation-cache-BrV71YKt.js.map} +1 -1
  7. package/dist/{compiler-CbNSBUI2.js → compiler-DI0H4d1R.js} +178 -66
  8. package/dist/compiler-DI0H4d1R.js.map +1 -0
  9. package/dist/compiler.d.ts +2 -0
  10. package/dist/config-la_KkjCS.js +1 -0
  11. package/dist/config.js +2 -2
  12. package/dist/{configuration-BVMf6Q_j.js → configuration-ppqhmuy4.js} +7 -5
  13. package/dist/configuration-ppqhmuy4.js.map +1 -0
  14. package/dist/configuration.d.ts +1 -1
  15. package/dist/declarations-DXtb1AHP.js +131 -0
  16. package/dist/declarations-DXtb1AHP.js.map +1 -0
  17. package/dist/declarations.js +1 -132
  18. package/dist/doctor-BHwU_YBw.js +200 -0
  19. package/dist/doctor-BHwU_YBw.js.map +1 -0
  20. package/dist/doctor.js +1 -202
  21. package/dist/editor.d.ts +1 -0
  22. package/dist/editor.js +31 -5
  23. package/dist/editor.js.map +1 -1
  24. package/dist/esbuild.js +2 -3
  25. package/dist/{extensions-B1xTkoYP.js → extensions-7ixttcoK.js} +2 -3
  26. package/dist/{extensions-B1xTkoYP.js.map → extensions-7ixttcoK.js.map} +1 -1
  27. package/dist/{files-BW9geU0_.js → files-CgwJJ992.js} +3 -4
  28. package/dist/{files-BW9geU0_.js.map → files-CgwJJ992.js.map} +1 -1
  29. package/dist/index.js +2 -2
  30. package/dist/{loader-compiler-D1teTrXw.js → loader-compiler.js} +4 -5
  31. package/dist/loader-compiler.js.map +1 -0
  32. package/dist/loader-registration-BO43rvVU.js +14 -0
  33. package/dist/loader-registration-BO43rvVU.js.map +1 -0
  34. package/dist/loader-registration.d.ts +4 -0
  35. package/dist/loader-registration.js +1 -0
  36. package/dist/loader-state-DB7sONR_.js +60 -0
  37. package/dist/loader-state-DB7sONR_.js.map +1 -0
  38. package/dist/loader-state.d.ts +34 -0
  39. package/dist/loader-sync.d.ts +3 -0
  40. package/dist/loader-sync.js +27 -0
  41. package/dist/loader-sync.js.map +1 -0
  42. package/dist/loader.d.ts +2 -4
  43. package/dist/loader.js +10 -48
  44. package/dist/loader.js.map +1 -1
  45. package/dist/{plugin-BHfiQ2L-.js → plugin-DDOHhv7Z.js} +6 -7
  46. package/dist/{plugin-BHfiQ2L-.js.map → plugin-DDOHhv7Z.js.map} +1 -1
  47. package/dist/project-DYXf2Kgt.js +442 -0
  48. package/dist/project-DYXf2Kgt.js.map +1 -0
  49. package/dist/project.js +2 -443
  50. package/dist/register.js +3 -4
  51. package/dist/register.js.map +1 -1
  52. package/dist/rollup.js +2 -3
  53. package/dist/rspack.js +2 -3
  54. package/dist/syntax.js +2 -3
  55. package/dist/{transpile-D8P8Lsbx.js → transpile--6CFGUm0.js} +3 -4
  56. package/dist/{transpile-D8P8Lsbx.js.map → transpile--6CFGUm0.js.map} +1 -1
  57. package/dist/typescript-plugin.cjs +252 -128
  58. package/dist/typescript-plugin.cjs.map +1 -1
  59. package/dist/vite-D0Ct4uy4.js +6 -0
  60. package/dist/vite-D0Ct4uy4.js.map +1 -0
  61. package/dist/vite-react.js +2 -3
  62. package/dist/vite.js +1 -7
  63. package/dist/webpack.js +2 -3
  64. package/package.json +3 -3
  65. package/schemas/twill.schema.json +6 -0
  66. package/dist/compiler-CbNSBUI2.js.map +0 -1
  67. package/dist/configuration-BVMf6Q_j.js.map +0 -1
  68. package/dist/declarations.js.map +0 -1
  69. package/dist/doctor.js.map +0 -1
  70. package/dist/loader-compiler-D1teTrXw.js.map +0 -1
  71. package/dist/project.js.map +0 -1
  72. package/dist/vite.js.map +0 -1
package/dist/project.js CHANGED
@@ -1,444 +1,3 @@
1
- import { a as transform, i as originalPosition, n as generatedPosition, r as inferLanguage, t as TwillSyntaxError } from "./compiler-CbNSBUI2.js";
2
- import { n as isTwillFile, t as extensions } from "./extensions-B1xTkoYP.js";
3
- import { n as loadConfig } from "./configuration-BVMf6Q_j.js";
4
- import { t as isDependency } from "./files-BW9geU0_.js";
5
- import MagicString from "magic-string";
6
- import { dirname, resolve } from "node:path";
7
- import ts from "typescript";
8
- import remapping from "@ampproject/remapping";
9
- //#region src/recovery.ts
10
- /** Editor-only recovery; build and CLI compilation always use strict parsing. */
11
- function recoverTransform(source, options, onSyntaxError) {
12
- const repaired = new MagicString(source);
13
- let text = source;
14
- for (let attempt = 0; attempt < 8; attempt++) try {
15
- const result = transform(text, options);
16
- if (text === source) return result;
17
- const repairMap = repaired.generateMap({
18
- source: options.filename,
19
- includeContent: true,
20
- hires: true
21
- });
22
- const repairedResult = {
23
- ...result,
24
- map: repairMap
25
- };
26
- const starts = [0];
27
- for (const match of source.matchAll(/\n/g)) starts.push(match.index + 1);
28
- const sourceOffset = (offset) => {
29
- const prefix = text.slice(0, offset).split("\n");
30
- const point = originalPosition(repairedResult, prefix.length, prefix.at(-1).length);
31
- return starts[point.line - 1] + point.column;
32
- };
33
- const enumPatterns = result.enumPatterns.map((pattern) => ({
34
- ...pattern,
35
- reference: {
36
- ...pattern.reference,
37
- property: {
38
- ...pattern.reference.property,
39
- start: sourceOffset(pattern.reference.property.start),
40
- end: sourceOffset(pattern.reference.property.end)
41
- }
42
- }
43
- }));
44
- const map = remapping([JSON.parse(result.map.toString()), JSON.parse(repairMap.toString())], () => null);
45
- return {
46
- ...result,
47
- enumPatterns,
48
- map
49
- };
50
- } catch (error) {
51
- if (!(error instanceof TwillSyntaxError)) throw error;
52
- if (attempt === 0) onSyntaxError?.(error);
53
- const before = text.slice(0, error.offset);
54
- let insertion;
55
- let offset = error.offset;
56
- if (/\.\s*$/.test(before)) insertion = "__twillIncomplete";
57
- else if (offset >= text.length) {
58
- const stack = [];
59
- for (const token of text.matchAll(/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|\/\*[\s\S]*?\*\/|\/\/[^\n]*|[()[\]{}])/g)) if ("([{".includes(token[0])) stack.push(token[0]);
60
- else if (")]}".includes(token[0])) stack.pop();
61
- const opening = stack.at(-1);
62
- if (!opening) throw error;
63
- insertion = {
64
- "(": ")",
65
- "[": "]",
66
- "{": "}"
67
- }[opening];
68
- } else throw error;
69
- if (offset >= text.length) offset = source.length;
70
- else if (text !== source) {
71
- const prefix = text.slice(0, offset).split("\n");
72
- const point = originalPosition({
73
- code: text,
74
- map: repaired.generateMap({
75
- source: options.filename,
76
- hires: true
77
- })
78
- }, prefix.length, prefix.at(-1).length);
79
- const starts = [0];
80
- for (const match of source.matchAll(/\n/g)) starts.push(match.index + 1);
81
- offset = point.line == null || point.column == null ? source.length : starts[point.line - 1] + point.column;
82
- }
83
- repaired.appendLeft(offset, insertion);
84
- text = repaired.toString();
85
- }
86
- return transform(source, options);
87
- }
88
- //#endregion
89
- //#region src/project.ts
90
- function lineStarts(text) {
91
- const starts = [0];
92
- const breaks = /\n/g;
93
- while (breaks.exec(text)) starts.push(breaks.lastIndex);
94
- return starts;
95
- }
96
- function positionAt(starts, offset) {
97
- let low = 0;
98
- let high = starts.length;
99
- while (low + 1 < high) {
100
- const mid = low + high >>> 1;
101
- if (starts[mid] <= offset) low = mid;
102
- else high = mid;
103
- }
104
- return {
105
- line: low + 1,
106
- column: offset - starts[low]
107
- };
108
- }
109
- var extraExtensions = extensions.map((extension) => ({
110
- extension,
111
- isMixedContent: false,
112
- scriptKind: ts.ScriptKind.Deferred
113
- }));
114
- function virtualFilename(filename) {
115
- filename = filename.replaceAll("\\", "/");
116
- return isTwillFile(filename) ? filename + {
117
- ts: ".ts",
118
- tsx: ".tsx",
119
- js: ".js",
120
- jsx: ".jsx"
121
- }[inferLanguage(filename)] : filename;
122
- }
123
- function sourceFilename(filename) {
124
- filename = filename.replaceAll("\\", "/");
125
- if (isTwillFile(filename)) return filename;
126
- return filename.replace(/(\.twill)\.ts$/, "$1").replace(/(\.twillx)\.tsx$/, "$1");
127
- }
128
- /** A virtual-source TypeScript project shared by the CLI and VS Code extension. */
129
- var TwillProject = class {
130
- root;
131
- service;
132
- compilerOptions;
133
- configFiles;
134
- files;
135
- overlays = /* @__PURE__ */ new Map();
136
- results = /* @__PURE__ */ new Map();
137
- lineMaps = /* @__PURE__ */ new WeakMap();
138
- version = 0;
139
- invalidation = 0;
140
- fileVersions = /* @__PURE__ */ new Map();
141
- configurationErrors;
142
- options;
143
- host;
144
- recover;
145
- discoverFiles;
146
- constructor(tsconfig, options = {}, projectOptions = {}) {
147
- const configFile = sourceFilename(resolve(tsconfig));
148
- this.root = dirname(configFile);
149
- this.recover = projectOptions.recover ?? false;
150
- this.options = {
151
- ...loadConfig(this.root, configFile),
152
- ...options
153
- };
154
- const configReads = /* @__PURE__ */ new Set([configFile, sourceFilename(resolve(this.root, "twill.config.json"))]);
155
- const configHost = {
156
- ...ts.sys,
157
- readFile: (filename) => {
158
- configReads.add(sourceFilename(filename));
159
- return ts.sys.readFile(filename);
160
- }
161
- };
162
- const raw = projectOptions.inferred && !ts.sys.fileExists(configFile) ? { config: { compilerOptions: {
163
- strict: true,
164
- target: "ES2022",
165
- module: "ESNext",
166
- moduleResolution: "Bundler",
167
- jsx: "react-jsx"
168
- } } } : ts.readConfigFile(configFile, configHost.readFile);
169
- const parsed = ts.parseJsonConfigFileContent(raw.config ?? {}, configHost, this.root, {
170
- allowJs: true,
171
- allowImportingTsExtensions: true,
172
- noEmit: true
173
- }, configFile, void 0, extraExtensions);
174
- this.configurationErrors = [...raw.error ? [raw.error] : [], ...parsed.errors];
175
- if (parsed.projectReferences?.length && !projectOptions.declarationRedirects) this.configurationErrors = [...this.configurationErrors, {
176
- category: ts.DiagnosticCategory.Error,
177
- code: 90002,
178
- file: void 0,
179
- start: void 0,
180
- length: void 0,
181
- messageText: "TypeScript project references are not supported by twill check. Check each referenced project separately."
182
- }];
183
- this.compilerOptions = parsed.options;
184
- this.configFiles = [...configReads];
185
- this.options.jsxImportSource ??= parsed.options.jsxImportSource;
186
- this.files = parsed.fileNames.map(virtualFilename);
187
- this.discoverFiles = () => ts.parseJsonConfigFileContent(raw.config ?? {}, configHost, this.root, {
188
- allowJs: true,
189
- allowImportingTsExtensions: true,
190
- noEmit: true
191
- }, configFile, void 0, extraExtensions).fileNames.map(virtualFilename);
192
- const readFile = (name) => {
193
- const original = sourceFilename(name);
194
- const source = this.overlays.get(original) ?? ts.sys.readFile(original);
195
- if (source === void 0) return void 0;
196
- if (!isTwillFile(original)) return source;
197
- try {
198
- return this.result(original, source).code;
199
- } catch {
200
- return "";
201
- }
202
- };
203
- const fileExists = (name) => this.overlays.has(sourceFilename(name)) || ts.sys.fileExists(sourceFilename(name));
204
- const resolutionHost = {
205
- ...ts.sys,
206
- readFile,
207
- fileExists
208
- };
209
- this.host = {
210
- ...ts.sys,
211
- getScriptFileNames: () => this.files,
212
- useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
213
- getScriptVersion: (name) => `${this.invalidation}:${this.fileVersions.get(sourceFilename(name)) ?? 0}`,
214
- getProjectVersion: () => String(this.version),
215
- getScriptSnapshot: (name) => {
216
- const text = readFile(name);
217
- return text === void 0 ? void 0 : ts.ScriptSnapshot.fromString(text);
218
- },
219
- getCurrentDirectory: () => this.root,
220
- getCompilationSettings: () => this.compilerOptions,
221
- getDefaultLibFileName: projectOptions.defaultLibFileName ?? ((opts) => ts.getDefaultLibFilePath(opts)),
222
- readFile,
223
- fileExists,
224
- resolveModuleNames: (names, importer) => names.map((name) => {
225
- const resolved = ts.resolveModuleName(name, importer, this.compilerOptions, resolutionHost).resolvedModule;
226
- if (resolved) {
227
- const redirect = projectOptions.declarationRedirects?.get(sourceFilename(resolved.resolvedFileName));
228
- return redirect ? {
229
- ...resolved,
230
- resolvedFileName: redirect,
231
- extension: ts.Extension.Dts
232
- } : {
233
- ...resolved,
234
- resolvedFileName: virtualFilename(resolved.resolvedFileName)
235
- };
236
- }
237
- if (name.startsWith(".") || name.startsWith("/")) {
238
- const base = resolve(dirname(sourceFilename(importer)), name);
239
- const candidates = isTwillFile(base) ? [base] : extensions.flatMap((extension) => [base + extension, resolve(base, "index" + extension)]);
240
- for (const candidate of candidates) if (fileExists(candidate)) {
241
- const redirect = projectOptions.declarationRedirects?.get(sourceFilename(candidate));
242
- if (redirect) return {
243
- resolvedFileName: redirect,
244
- extension: ts.Extension.Dts,
245
- isExternalLibraryImport: false
246
- };
247
- const file = virtualFilename(candidate);
248
- return {
249
- resolvedFileName: file,
250
- extension: file.endsWith(".tsx") ? ts.Extension.Tsx : ts.Extension.Ts,
251
- isExternalLibraryImport: false
252
- };
253
- }
254
- }
255
- })
256
- };
257
- this.service = ts.createLanguageService(this.host);
258
- }
259
- /** Declaration-only native TypeScript emit from the checked virtual program. */
260
- declarationOutput(outDir, declarationMap = true) {
261
- const diagnostics = this.diagnostics();
262
- if (diagnostics.some((item) => item.category === "error")) return {
263
- diagnostics,
264
- files: []
265
- };
266
- const previous = this.service.getProgram();
267
- if (!previous) return {
268
- diagnostics,
269
- files: []
270
- };
271
- const options = {
272
- ...this.compilerOptions,
273
- noEmit: false,
274
- declaration: true,
275
- emitDeclarationOnly: true,
276
- declarationMap,
277
- noEmitOnError: true,
278
- incremental: false,
279
- composite: false,
280
- rootDir: this.compilerOptions.rootDir ?? this.root,
281
- outDir,
282
- declarationDir: outDir,
283
- allowImportingTsExtensions: true
284
- };
285
- const host = ts.createCompilerHost(options);
286
- host.readFile = this.host.readFile;
287
- host.fileExists = this.host.fileExists;
288
- host.getCurrentDirectory = () => this.root;
289
- host.resolveModuleNames = this.host.resolveModuleNames;
290
- host.getSourceFile = (filename, languageVersion) => previous.getSourceFile(filename) ?? (host.readFile(filename) === void 0 ? void 0 : ts.createSourceFile(filename, host.readFile(filename), languageVersion, true));
291
- const program = ts.createProgram(previous.getRootFileNames(), options, host);
292
- const errors = ts.getPreEmitDiagnostics(program).map((item) => this.diagnostic(item));
293
- if (errors.some((item) => item.category === "error")) return {
294
- diagnostics: errors,
295
- files: []
296
- };
297
- const files = [];
298
- const emitted = program.emit(void 0, (filename, text, _bom, _error, sources) => {
299
- files.push({
300
- filename: sourceFilename(filename),
301
- text,
302
- sources: sources?.map((source) => sourceFilename(source.fileName)) ?? []
303
- });
304
- }, void 0, true);
305
- return {
306
- diagnostics: [...diagnostics, ...emitted.diagnostics.map((item) => this.diagnostic(item))],
307
- files: emitted.emitSkipped ? [] : files
308
- };
309
- }
310
- result(filename, source) {
311
- const cached = this.results.get(filename);
312
- if (cached?.source === source) return cached.result;
313
- const options = {
314
- ...this.options,
315
- filename
316
- };
317
- let syntaxError;
318
- const result = this.recover ? recoverTransform(source, options, (error) => {
319
- syntaxError = error;
320
- }) : transform(source, options);
321
- this.results.set(filename, {
322
- source,
323
- result,
324
- syntaxError
325
- });
326
- return result;
327
- }
328
- update(filename, text) {
329
- filename = sourceFilename(resolve(filename));
330
- if (text !== void 0 && text === this.overlays.get(filename) && this.files.includes(virtualFilename(filename))) return;
331
- if (text === void 0) this.overlays.delete(filename);
332
- else this.overlays.set(filename, text);
333
- this.fileVersions.set(filename, (this.fileVersions.get(filename) ?? 0) + 1);
334
- if (!this.files.includes(virtualFilename(filename))) this.files.push(virtualFilename(filename));
335
- this.results.delete(filename);
336
- this.version++;
337
- }
338
- invalidate() {
339
- this.invalidation++;
340
- this.version++;
341
- this.results.clear();
342
- }
343
- /** Refresh a disk version without discarding unsaved overlays or other transforms. */
344
- refresh(filename, discover = false) {
345
- filename = sourceFilename(resolve(filename));
346
- if (discover) this.files = [.../* @__PURE__ */ new Set([...this.discoverFiles(), ...[...this.overlays.keys()].map(virtualFilename)])];
347
- if (!this.overlays.has(filename)) {
348
- this.results.delete(filename);
349
- this.fileVersions.set(filename, (this.fileVersions.get(filename) ?? 0) + 1);
350
- }
351
- this.version++;
352
- }
353
- text(filename) {
354
- filename = sourceFilename(resolve(filename));
355
- return this.overlays.get(filename) ?? ts.sys.readFile(filename);
356
- }
357
- transformed(filename) {
358
- filename = sourceFilename(resolve(filename));
359
- const source = this.text(filename);
360
- return source !== void 0 && isTwillFile(filename) ? this.result(filename, source) : void 0;
361
- }
362
- sourceFiles() {
363
- const dependencies = this.service.getProgram()?.getSourceFiles().filter((file) => !file.isDeclarationFile && !isDependency(file.fileName)).map((file) => file.fileName) ?? [];
364
- return [...new Set([...this.files, ...dependencies].map(sourceFilename))];
365
- }
366
- lines(filename, result) {
367
- let lines = this.lineMaps.get(result);
368
- if (!lines) {
369
- lines = {
370
- original: lineStarts(this.text(filename)),
371
- generated: lineStarts(result.code)
372
- };
373
- this.lineMaps.set(result, lines);
374
- }
375
- return lines;
376
- }
377
- toGeneratedOffset(filename, offset) {
378
- const result = this.transformed(filename);
379
- if (!result) return offset;
380
- const lines = this.lines(filename, result);
381
- const sourcePosition = positionAt(lines.original, offset);
382
- const position = generatedPosition(result, sourcePosition.line, sourcePosition.column);
383
- if (position.line === null || position.column === null) return offset;
384
- return (lines.generated[position.line - 1] ?? 0) + position.column;
385
- }
386
- toOriginalOffset(filename, offset) {
387
- const result = this.transformed(filename);
388
- if (!result) return offset;
389
- const lines = this.lines(filename, result);
390
- const sourcePosition = positionAt(lines.generated, offset);
391
- const position = originalPosition(result, sourcePosition.line, sourcePosition.column);
392
- if (position.line === null || position.column === null) return 0;
393
- return (lines.original[position.line - 1] ?? 0) + position.column;
394
- }
395
- diagnostic(diagnostic) {
396
- const filename = diagnostic.file ? sourceFilename(diagnostic.file.fileName) : void 0;
397
- const source = filename ? this.text(filename) ?? "" : "";
398
- const start = filename ? this.toOriginalOffset(filename, diagnostic.start ?? 0) : 0;
399
- const end = filename ? this.toOriginalOffset(filename, (diagnostic.start ?? 0) + (diagnostic.length ?? 1)) : start + 1;
400
- const before = source.slice(0, start).split(/\r\n|[\r\n\u2028\u2029]/);
401
- return {
402
- filename,
403
- line: before.length,
404
- column: before.at(-1).length,
405
- length: Math.max(1, end - start),
406
- code: diagnostic.code,
407
- category: diagnostic.category === ts.DiagnosticCategory.Error ? "error" : diagnostic.category === ts.DiagnosticCategory.Warning ? "warning" : "message",
408
- message: ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
409
- };
410
- }
411
- diagnostics(filename) {
412
- const result = this.configurationErrors.map((error) => this.diagnostic(error));
413
- if (!filename) result.push(...this.service.getCompilerOptionsDiagnostics().map((error) => this.diagnostic(error)));
414
- const files = filename ? [virtualFilename(resolve(filename))] : this.sourceFiles().map(virtualFilename);
415
- for (const file of files) {
416
- if (/\.d\.[cm]?ts$/.test(file)) continue;
417
- try {
418
- this.transformed(file);
419
- const syntaxError = this.results.get(sourceFilename(file))?.syntaxError;
420
- if (syntaxError) throw syntaxError;
421
- result.push(...[...this.service.getSyntacticDiagnostics(file), ...this.service.getSemanticDiagnostics(file)].map((error) => this.diagnostic(error)));
422
- } catch (error) {
423
- const syntax = error;
424
- result.push({
425
- filename: sourceFilename(file),
426
- line: syntax.line ?? 1,
427
- column: syntax.column ?? 0,
428
- length: 1,
429
- code: 90001,
430
- category: "error",
431
- message: syntax.message
432
- });
433
- }
434
- }
435
- return result;
436
- }
437
- dispose() {
438
- this.service.dispose();
439
- }
440
- };
441
- //#endregion
1
+ import { n as sourceFilename, r as virtualFilename, t as TwillProject } from "./project-DYXf2Kgt.js";
2
+ import { t as isDependency } from "./files-CgwJJ992.js";
442
3
  export { TwillProject, isDependency, sourceFilename, virtualFilename };
443
-
444
- //# sourceMappingURL=project.js.map
package/dist/register.js CHANGED
@@ -1,7 +1,6 @@
1
- import { register } from "node:module";
2
- //#region src/register.ts
3
- register("./loader.js", import.meta.url);
4
- //#endregion
1
+ import { t as registerLoader } from "./loader-registration-BO43rvVU.js";
2
+ // src/register.ts
3
+ await registerLoader();
5
4
  export {};
6
5
 
7
6
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","names":[],"sources":["../src/register.ts"],"sourcesContent":["import { register } from 'node:module';\nregister('./loader.js', import.meta.url);\n"],"mappings":";;AACA,SAAS,eAAe,YAAY,GAAG"}
1
+ {"version":3,"file":"register.js","names":[],"sources":["../src/register.ts"],"sourcesContent":["import { registerLoader } from './loader-registration.js';\nawait registerLoader();\n"],"mappings":";;AACA,MAAM,eAAe"}
package/dist/rollup.js CHANGED
@@ -1,7 +1,6 @@
1
- import { t as twillPlugin } from "./plugin-BHfiQ2L-.js";
2
- //#region src/rollup.ts
1
+ import { t as twillPlugin } from "./plugin-DDOHhv7Z.js";
2
+ // src/rollup.ts
3
3
  var rollup_default = twillPlugin.rollup;
4
- //#endregion
5
4
  export { rollup_default as default };
6
5
 
7
6
  //# sourceMappingURL=rollup.js.map
package/dist/rspack.js CHANGED
@@ -1,7 +1,6 @@
1
- import { t as twillPlugin } from "./plugin-BHfiQ2L-.js";
2
- //#region src/rspack.ts
1
+ import { t as twillPlugin } from "./plugin-DDOHhv7Z.js";
2
+ // src/rspack.ts
3
3
  var rspack_default = twillPlugin.rspack;
4
- //#endregion
5
4
  export { rspack_default as default };
6
5
 
7
6
  //# sourceMappingURL=rspack.js.map
package/dist/syntax.js CHANGED
@@ -1,10 +1,9 @@
1
- import { o as parse, r as inferLanguage } from "./compiler-CbNSBUI2.js";
2
- //#region src/syntax.ts
1
+ import { o as parse, r as inferLanguage } from "./compiler-DI0H4d1R.js";
2
+ // src/syntax.ts
3
3
  /** Original ESTree and dialect metadata for source-aware tooling. */
4
4
  function parseSyntax(source, options = {}) {
5
5
  return parse(source, options.language ?? inferLanguage(options.filename ?? "input.twill"), options.sourceType ?? "module");
6
6
  }
7
- //#endregion
8
7
  export { parseSyntax };
9
8
 
10
9
  //# sourceMappingURL=syntax.js.map
@@ -1,8 +1,8 @@
1
- import { a as transform, r as inferLanguage } from "./compiler-CbNSBUI2.js";
1
+ import { a as transform, r as inferLanguage } from "./compiler-DI0H4d1R.js";
2
2
  import MagicString from "magic-string";
3
3
  import ts from "typescript";
4
4
  import remapping from "@ampproject/remapping";
5
- //#region src/transpile.ts
5
+ // src/transpile.ts
6
6
  function transpile(source, options = {}, target = ts.ScriptTarget.ESNext) {
7
7
  const filename = options.filename ?? "input.twill";
8
8
  const result = transform(source, options);
@@ -45,7 +45,6 @@ function transpileNative(source, filename, language = inferLanguage(filename), s
45
45
  map
46
46
  };
47
47
  }
48
- //#endregion
49
48
  export { transpileNative as n, transpile as t };
50
49
 
51
- //# sourceMappingURL=transpile-D8P8Lsbx.js.map
50
+ //# sourceMappingURL=transpile--6CFGUm0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transpile-D8P8Lsbx.js","names":[],"sources":["../src/transpile.ts"],"sourcesContent":["import ts from 'typescript';\nimport remapping from '@ampproject/remapping';\nimport MagicString from 'magic-string';\nimport { transform, inferLanguage, type TransformOptions } from './compiler.js';\n\nexport function transpile(\n source: string,\n options: TransformOptions = {},\n target = ts.ScriptTarget.ESNext,\n) {\n const filename = options.filename ?? 'input.twill';\n const result = transform(source, options);\n const language = options.language ?? inferLanguage(filename);\n return transpileNative(\n result.code,\n filename,\n language,\n result.map.toString(),\n options.jsxImportSource,\n target,\n );\n}\n\n/** Native source never goes through Twill's parser or implicit-return rules. */\nexport function transpileNative(\n source: string,\n filename: string,\n language = inferLanguage(filename),\n syntaxMap?: string,\n jsxImportSource?: string,\n target = ts.ScriptTarget.ESNext,\n) {\n // Plain JavaScript needs no type erasure or JSX transform. Leave modern JS\n // (including comments and import attributes) to the host's target pipeline.\n if (language === 'js')\n return {\n code: source,\n map:\n syntaxMap ??\n new MagicString(source)\n .generateMap({ source: filename, includeContent: true, hires: true })\n .toString(),\n };\n const output = ts.transpileModule(source, {\n fileName: syntaxMap ? filename + (language.endsWith('x') ? '.tsx' : '.ts') : filename,\n compilerOptions: {\n target,\n module: ts.ModuleKind.ESNext,\n jsx: ts.JsxEmit.ReactJSX,\n jsxImportSource,\n sourceMap: true,\n inlineSources: true,\n isolatedModules: true,\n verbatimModuleSyntax: true,\n },\n reportDiagnostics: true,\n });\n const errors = output.diagnostics?.filter(\n (diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error,\n );\n if (errors?.length)\n throw new Error(\n ts.formatDiagnostics(errors, {\n getCanonicalFileName: (name) => name,\n getCurrentDirectory: () => '',\n getNewLine: () => '\\n',\n }),\n );\n const map = syntaxMap\n ? remapping([JSON.parse(output.sourceMapText!), JSON.parse(syntaxMap)], () => null).toString()\n : output.sourceMapText!;\n return {\n code: output.outputText.replace(/^\\/\\/# sourceMappingURL=.*$/m, ''),\n map,\n };\n}\n"],"mappings":";;;;;AAKA,SAAgB,UACd,QACA,UAA4B,CAAC,GAC7B,SAAS,GAAG,aAAa,QACzB;CACA,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,SAAS,UAAU,QAAQ,OAAO;CACxC,MAAM,WAAW,QAAQ,YAAY,cAAc,QAAQ;CAC3D,OAAO,gBACL,OAAO,MACP,UACA,UACA,OAAO,IAAI,SAAS,GACpB,QAAQ,iBACR,MACF;AACF;;AAGA,SAAgB,gBACd,QACA,UACA,WAAW,cAAc,QAAQ,GACjC,WACA,iBACA,SAAS,GAAG,aAAa,QACzB;CAGA,IAAI,aAAa,MACf,OAAO;EACL,MAAM;EACN,KACE,aACA,IAAI,YAAY,MAAM,CAAC,CACpB,YAAY;GAAE,QAAQ;GAAU,gBAAgB;GAAM,OAAO;EAAK,CAAC,CAAC,CACpE,SAAS;CAChB;CACF,MAAM,SAAS,GAAG,gBAAgB,QAAQ;EACxC,UAAU,YAAY,YAAY,SAAS,SAAS,GAAG,IAAI,SAAS,SAAS;EAC7E,iBAAiB;GACf;GACA,QAAQ,GAAG,WAAW;GACtB,KAAK,GAAG,QAAQ;GAChB;GACA,WAAW;GACX,eAAe;GACf,iBAAiB;GACjB,sBAAsB;EACxB;EACA,mBAAmB;CACrB,CAAC;CACD,MAAM,SAAS,OAAO,aAAa,QAChC,eAAe,WAAW,aAAa,GAAG,mBAAmB,KAChE;CACA,IAAI,QAAQ,QACV,MAAM,IAAI,MACR,GAAG,kBAAkB,QAAQ;EAC3B,uBAAuB,SAAS;EAChC,2BAA2B;EAC3B,kBAAkB;CACpB,CAAC,CACH;CACF,MAAM,MAAM,YACR,UAAU,CAAC,KAAK,MAAM,OAAO,aAAc,GAAG,KAAK,MAAM,SAAS,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,IAC3F,OAAO;CACX,OAAO;EACL,MAAM,OAAO,WAAW,QAAQ,gCAAgC,EAAE;EAClE;CACF;AACF"}
1
+ {"version":3,"file":"transpile--6CFGUm0.js","names":[],"sources":["../src/transpile.ts"],"sourcesContent":["import ts from 'typescript';\nimport remapping from '@ampproject/remapping';\nimport MagicString from 'magic-string';\nimport { transform, inferLanguage, type TransformOptions } from './compiler.js';\n\nexport function transpile(\n source: string,\n options: TransformOptions = {},\n target = ts.ScriptTarget.ESNext,\n) {\n const filename = options.filename ?? 'input.twill';\n const result = transform(source, options);\n const language = options.language ?? inferLanguage(filename);\n return transpileNative(\n result.code,\n filename,\n language,\n result.map.toString(),\n options.jsxImportSource,\n target,\n );\n}\n\n/** Native source never goes through Twill's parser or implicit-return rules. */\nexport function transpileNative(\n source: string,\n filename: string,\n language = inferLanguage(filename),\n syntaxMap?: string,\n jsxImportSource?: string,\n target = ts.ScriptTarget.ESNext,\n) {\n // Plain JavaScript needs no type erasure or JSX transform. Leave modern JS\n // (including comments and import attributes) to the host's target pipeline.\n if (language === 'js')\n return {\n code: source,\n map:\n syntaxMap ??\n new MagicString(source)\n .generateMap({ source: filename, includeContent: true, hires: true })\n .toString(),\n };\n const output = ts.transpileModule(source, {\n fileName: syntaxMap ? filename + (language.endsWith('x') ? '.tsx' : '.ts') : filename,\n compilerOptions: {\n target,\n module: ts.ModuleKind.ESNext,\n jsx: ts.JsxEmit.ReactJSX,\n jsxImportSource,\n sourceMap: true,\n inlineSources: true,\n isolatedModules: true,\n verbatimModuleSyntax: true,\n },\n reportDiagnostics: true,\n });\n const errors = output.diagnostics?.filter(\n (diagnostic) => diagnostic.category === ts.DiagnosticCategory.Error,\n );\n if (errors?.length)\n throw new Error(\n ts.formatDiagnostics(errors, {\n getCanonicalFileName: (name) => name,\n getCurrentDirectory: () => '',\n getNewLine: () => '\\n',\n }),\n );\n const map = syntaxMap\n ? remapping([JSON.parse(output.sourceMapText!), JSON.parse(syntaxMap)], () => null).toString()\n : output.sourceMapText!;\n return {\n code: output.outputText.replace(/^\\/\\/# sourceMappingURL=.*$/m, ''),\n map,\n };\n}\n"],"mappings":";;;;;AAKA,SAAgB,UACd,QACA,UAA4B,CAAC,GAC7B,SAAS,GAAG,aAAa,QACzB;CACA,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,SAAS,UAAU,QAAQ,OAAO;CACxC,MAAM,WAAW,QAAQ,YAAY,cAAc,QAAQ;CAC3D,OAAO,gBACL,OAAO,MACP,UACA,UACA,OAAO,IAAI,SAAS,GACpB,QAAQ,iBACR,MACF;AACF;;AAGA,SAAgB,gBACd,QACA,UACA,WAAW,cAAc,QAAQ,GACjC,WACA,iBACA,SAAS,GAAG,aAAa,QACzB;CAGA,IAAI,aAAa,MACf,OAAO;EACL,MAAM;EACN,KACE,aACA,IAAI,YAAY,MAAM,CAAC,CACpB,YAAY;GAAE,QAAQ;GAAU,gBAAgB;GAAM,OAAO;EAAK,CAAC,CAAC,CACpE,SAAS;CAChB;CACF,MAAM,SAAS,GAAG,gBAAgB,QAAQ;EACxC,UAAU,YAAY,YAAY,SAAS,SAAS,GAAG,IAAI,SAAS,SAAS;EAC7E,iBAAiB;GACf;GACA,QAAQ,GAAG,WAAW;GACtB,KAAK,GAAG,QAAQ;GAChB;GACA,WAAW;GACX,eAAe;GACf,iBAAiB;GACjB,sBAAsB;EACxB;EACA,mBAAmB;CACrB,CAAC;CACD,MAAM,SAAS,OAAO,aAAa,QAChC,eAAe,WAAW,aAAa,GAAG,mBAAmB,KAChE;CACA,IAAI,QAAQ,QACV,MAAM,IAAI,MACR,GAAG,kBAAkB,QAAQ;EAC3B,uBAAuB,SAAS;EAChC,2BAA2B;EAC3B,kBAAkB;CACpB,CAAC,CACH;CACF,MAAM,MAAM,YACR,UAAU,CAAC,KAAK,MAAM,OAAO,aAAc,GAAG,KAAK,MAAM,SAAS,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,IAC3F,OAAO;CACX,OAAO;EACL,MAAM,OAAO,WAAW,QAAQ,gCAAgC,EAAE;EAClE;CACF;AACF"}