@swiftuijs/twill 0.3.1 → 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.
- package/README.md +8 -3
- package/dist/branches.d.ts +7 -1
- package/dist/cli.js +7 -8
- package/dist/{compilation-cache-7SugqJ4n.js → compilation-cache-BrV71YKt.js} +2 -3
- package/dist/{compilation-cache-7SugqJ4n.js.map → compilation-cache-BrV71YKt.js.map} +1 -1
- package/dist/{compiler-BdkU4Ruh.js → compiler-DI0H4d1R.js} +147 -55
- package/dist/compiler-DI0H4d1R.js.map +1 -0
- package/dist/compiler.d.ts +2 -0
- package/dist/config.js +1 -2
- package/dist/{configuration-BVMf6Q_j.js → configuration-ppqhmuy4.js} +7 -5
- package/dist/configuration-ppqhmuy4.js.map +1 -0
- package/dist/configuration.d.ts +1 -1
- package/dist/{declarations-BTAS8Mb_.js → declarations-DXtb1AHP.js} +3 -4
- package/dist/{declarations-BTAS8Mb_.js.map → declarations-DXtb1AHP.js.map} +1 -1
- package/dist/declarations.js +1 -2
- package/dist/{doctor-Co_pdZtt.js → doctor-BHwU_YBw.js} +4 -6
- package/dist/{doctor-Co_pdZtt.js.map → doctor-BHwU_YBw.js.map} +1 -1
- package/dist/doctor.js +1 -2
- package/dist/editor.d.ts +1 -0
- package/dist/editor.js +31 -5
- package/dist/editor.js.map +1 -1
- package/dist/esbuild.js +2 -3
- package/dist/{extensions-B1xTkoYP.js → extensions-7ixttcoK.js} +2 -3
- package/dist/{extensions-B1xTkoYP.js.map → extensions-7ixttcoK.js.map} +1 -1
- package/dist/{files-BW9geU0_.js → files-CgwJJ992.js} +3 -4
- package/dist/{files-BW9geU0_.js.map → files-CgwJJ992.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/loader-compiler.js +3 -4
- package/dist/{loader-registration-B1ST9h1e.js → loader-registration-BO43rvVU.js} +2 -3
- package/dist/{loader-registration-B1ST9h1e.js.map → loader-registration-BO43rvVU.js.map} +1 -1
- package/dist/loader-registration.js +1 -2
- package/dist/{loader-state-DE2ArGYl.js → loader-state-DB7sONR_.js} +5 -6
- package/dist/{loader-state-DE2ArGYl.js.map → loader-state-DB7sONR_.js.map} +1 -1
- package/dist/loader-sync.js +2 -3
- package/dist/loader.js +2 -3
- package/dist/{plugin-DdTVagIU.js → plugin-DDOHhv7Z.js} +6 -7
- package/dist/{plugin-DdTVagIU.js.map → plugin-DDOHhv7Z.js.map} +1 -1
- package/dist/{project-ZmlpFooa.js → project-DYXf2Kgt.js} +7 -9
- package/dist/{project-ZmlpFooa.js.map → project-DYXf2Kgt.js.map} +1 -1
- package/dist/project.js +2 -2
- package/dist/register.js +2 -3
- package/dist/rollup.js +2 -3
- package/dist/rspack.js +2 -3
- package/dist/syntax.js +2 -3
- package/dist/{transpile-CLNavDUr.js → transpile--6CFGUm0.js} +3 -4
- package/dist/{transpile-CLNavDUr.js.map → transpile--6CFGUm0.js.map} +1 -1
- package/dist/typescript-plugin.cjs +221 -117
- package/dist/typescript-plugin.cjs.map +1 -1
- package/dist/vite-D0Ct4uy4.js +6 -0
- package/dist/{vite-BI-5KRgr.js.map → vite-D0Ct4uy4.js.map} +1 -1
- package/dist/vite-react.js +2 -3
- package/dist/vite.js +1 -2
- package/dist/webpack.js +2 -3
- package/package.json +3 -3
- package/schemas/twill.schema.json +6 -0
- package/dist/compiler-BdkU4Ruh.js.map +0 -1
- package/dist/configuration-BVMf6Q_j.js.map +0 -1
- package/dist/vite-BI-5KRgr.js +0 -7
|
@@ -2,14 +2,14 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
|
|
5
|
+
// \0rolldown/runtime.js
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
8
8
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
9
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
10
|
var __getProtoOf = Object.getPrototypeOf;
|
|
11
11
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
12
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
|
|
13
13
|
var __exportAll = (all, no_symbols) => {
|
|
14
14
|
let target = {};
|
|
15
15
|
for (var name in all) __defProp(target, name, {
|
|
@@ -33,13 +33,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
33
|
value: mod,
|
|
34
34
|
enumerable: true
|
|
35
35
|
}) : target, mod));
|
|
36
|
-
//#endregion
|
|
37
36
|
let node_fs = require("node:fs");
|
|
38
37
|
let node_path = require("node:path");
|
|
39
38
|
let typescript = require("typescript");
|
|
40
39
|
typescript = __toESM(typescript, 1);
|
|
41
40
|
let node_crypto = require("node:crypto");
|
|
42
|
-
|
|
41
|
+
// ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.6.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
43
42
|
var comma = ",".charCodeAt(0);
|
|
44
43
|
var semicolon = ";".charCodeAt(0);
|
|
45
44
|
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -223,8 +222,7 @@ function encode(decoded) {
|
|
|
223
222
|
}
|
|
224
223
|
return writer.flush();
|
|
225
224
|
}
|
|
226
|
-
|
|
227
|
-
//#region ../../node_modules/.pnpm/magic-string@1.4.2/node_modules/magic-string/dist/index.mjs
|
|
225
|
+
// ../../node_modules/.pnpm/magic-string@1.4.2/node_modules/magic-string/dist/index.mjs
|
|
228
226
|
var BitSet = class BitSet {
|
|
229
227
|
constructor(arg) {
|
|
230
228
|
this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
|
|
@@ -1658,8 +1656,7 @@ var MagicString = class MagicString {
|
|
|
1658
1656
|
return this._replaceRegexp(searchValue, replacement);
|
|
1659
1657
|
}
|
|
1660
1658
|
};
|
|
1661
|
-
|
|
1662
|
-
//#region ../../node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.mjs
|
|
1659
|
+
// ../../node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.mjs
|
|
1663
1660
|
var acorn_exports = /* @__PURE__ */ __exportAll({
|
|
1664
1661
|
Node: () => Node,
|
|
1665
1662
|
Parser: () => Parser,
|
|
@@ -6836,8 +6833,7 @@ function parseExpressionAt(input, pos, options) {
|
|
|
6836
6833
|
function tokenizer(input, options) {
|
|
6837
6834
|
return Parser.tokenizer(input, options);
|
|
6838
6835
|
}
|
|
6839
|
-
|
|
6840
|
-
//#region ../../node_modules/.pnpm/acorn-typescript@1.4.13_acorn@8.18.0/node_modules/acorn-typescript/lib/index.mjs
|
|
6836
|
+
// ../../node_modules/.pnpm/acorn-typescript@1.4.13_acorn@8.18.0/node_modules/acorn-typescript/lib/index.mjs
|
|
6841
6837
|
function a(t, e) {
|
|
6842
6838
|
for (var s = 0; s < e.length; s++) {
|
|
6843
6839
|
var i = e[s];
|
|
@@ -9204,8 +9200,7 @@ function D(e) {
|
|
|
9204
9200
|
}(s);
|
|
9205
9201
|
};
|
|
9206
9202
|
}
|
|
9207
|
-
|
|
9208
|
-
//#region ../../node_modules/.pnpm/acorn-jsx@5.3.2_acorn@8.18.0/node_modules/acorn-jsx/xhtml.js
|
|
9203
|
+
// ../../node_modules/.pnpm/acorn-jsx@5.3.2_acorn@8.18.0/node_modules/acorn-jsx/xhtml.js
|
|
9209
9204
|
var require_xhtml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9210
9205
|
module.exports = {
|
|
9211
9206
|
quot: "\"",
|
|
@@ -9463,12 +9458,11 @@ var require_xhtml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
9463
9458
|
diams: "♦"
|
|
9464
9459
|
};
|
|
9465
9460
|
}));
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
var require_acorn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
9461
|
+
// ../../node_modules/.pnpm/acorn@8.18.0/node_modules/acorn/dist/acorn.js
|
|
9462
|
+
var require_acorn = /* @__PURE__ */ __commonJSMin(((exports, module, this$1) => {
|
|
9469
9463
|
(function(global, factory) {
|
|
9470
9464
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.acorn = {}));
|
|
9471
|
-
})(
|
|
9465
|
+
})(this$1, (function(exports) {
|
|
9472
9466
|
"use strict";
|
|
9473
9467
|
var astralIdentifierCodes = [
|
|
9474
9468
|
509,
|
|
@@ -14602,32 +14596,31 @@ var require_acorn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14602
14596
|
function tokenizer(input, options) {
|
|
14603
14597
|
return Parser.tokenizer(input, options);
|
|
14604
14598
|
}
|
|
14605
|
-
exports
|
|
14606
|
-
exports
|
|
14607
|
-
exports
|
|
14608
|
-
exports
|
|
14609
|
-
exports
|
|
14610
|
-
exports
|
|
14611
|
-
exports
|
|
14612
|
-
exports
|
|
14613
|
-
exports
|
|
14614
|
-
exports
|
|
14615
|
-
exports
|
|
14616
|
-
exports
|
|
14617
|
-
exports
|
|
14618
|
-
exports
|
|
14619
|
-
exports
|
|
14620
|
-
exports
|
|
14621
|
-
exports
|
|
14622
|
-
exports
|
|
14623
|
-
exports
|
|
14624
|
-
exports
|
|
14625
|
-
exports
|
|
14626
|
-
exports
|
|
14599
|
+
exports.Node = Node;
|
|
14600
|
+
exports.Parser = Parser;
|
|
14601
|
+
exports.Position = Position;
|
|
14602
|
+
exports.SourceLocation = SourceLocation;
|
|
14603
|
+
exports.TokContext = TokContext;
|
|
14604
|
+
exports.Token = Token;
|
|
14605
|
+
exports.TokenType = TokenType;
|
|
14606
|
+
exports.defaultOptions = defaultOptions;
|
|
14607
|
+
exports.getLineInfo = getLineInfo;
|
|
14608
|
+
exports.isIdentifierChar = isIdentifierChar;
|
|
14609
|
+
exports.isIdentifierStart = isIdentifierStart;
|
|
14610
|
+
exports.isNewLine = isNewLine;
|
|
14611
|
+
exports.keywordTypes = keywords;
|
|
14612
|
+
exports.lineBreak = lineBreak;
|
|
14613
|
+
exports.lineBreakG = lineBreakG;
|
|
14614
|
+
exports.nonASCIIwhitespace = nonASCIIwhitespace;
|
|
14615
|
+
exports.parse = parse;
|
|
14616
|
+
exports.parseExpressionAt = parseExpressionAt;
|
|
14617
|
+
exports.tokContexts = types;
|
|
14618
|
+
exports.tokTypes = types$1;
|
|
14619
|
+
exports.tokenizer = tokenizer;
|
|
14620
|
+
exports.version = version;
|
|
14627
14621
|
}));
|
|
14628
14622
|
}));
|
|
14629
|
-
|
|
14630
|
-
//#region src/parser.js
|
|
14623
|
+
// src/parser.js
|
|
14631
14624
|
var import_acorn_jsx = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
14632
14625
|
var XHTMLEntities = require_xhtml();
|
|
14633
14626
|
var hexNumber = /^[\da-fA-F]+$/;
|
|
@@ -15684,13 +15677,11 @@ function parse$1(source, language = "ts", sourceType = "module") {
|
|
|
15684
15677
|
}))
|
|
15685
15678
|
};
|
|
15686
15679
|
}
|
|
15687
|
-
|
|
15688
|
-
//#region src/defer-helper.ts
|
|
15680
|
+
// src/defer-helper.ts
|
|
15689
15681
|
function syncDeferBody(names) {
|
|
15690
15682
|
return "\n let " + names.failed + " = false,\n " + names.failure + ";\n while (" + names.stack + "?.length) {\n const " + names.cleanup + " = " + names.stack + ".pop();\n if (" + names.cleanup + ") {\n try {\n " + names.cleanup + "();\n } catch (" + names.error + ") {\n " + names.failed + " = true;\n " + names.failure + " = " + names.error + ";\n }\n }\n }\n if (" + names.failed + ") throw " + names.failure + ";\n";
|
|
15691
15683
|
}
|
|
15692
|
-
|
|
15693
|
-
//#region src/defer.ts
|
|
15684
|
+
// src/defer.ts
|
|
15694
15685
|
var functions = /* @__PURE__ */ new Set([
|
|
15695
15686
|
"FunctionDeclaration",
|
|
15696
15687
|
"FunctionExpression",
|
|
@@ -15866,8 +15857,7 @@ function lowerDefers(source, ast, code, language, usedNames, contentStarts, comm
|
|
|
15866
15857
|
code.prependLeft(start, `\nimport { runDefers as ${sharedHelper} } from '@swiftuijs/twill-runtime/helpers/v1';\n`);
|
|
15867
15858
|
}
|
|
15868
15859
|
}
|
|
15869
|
-
|
|
15870
|
-
//#region src/branches.ts
|
|
15860
|
+
// src/branches.ts
|
|
15871
15861
|
function suspension(node) {
|
|
15872
15862
|
if (["AwaitExpression", "YieldExpression"].includes(node.type)) return node;
|
|
15873
15863
|
if ([
|
|
@@ -15887,10 +15877,53 @@ function suspension(node) {
|
|
|
15887
15877
|
}
|
|
15888
15878
|
}
|
|
15889
15879
|
}
|
|
15880
|
+
function directEval(node) {
|
|
15881
|
+
if ([
|
|
15882
|
+
"FunctionDeclaration",
|
|
15883
|
+
"FunctionExpression",
|
|
15884
|
+
"ArrowFunctionExpression"
|
|
15885
|
+
].includes(node.type)) return false;
|
|
15886
|
+
if (node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "eval" && !node.optional) return true;
|
|
15887
|
+
return Object.entries(node).some(([key, value]) => ![
|
|
15888
|
+
"loc",
|
|
15889
|
+
"trailing",
|
|
15890
|
+
"tag"
|
|
15891
|
+
].includes(key) && (Array.isArray(value) ? value : [value]).some((child) => child?.type && directEval(child)));
|
|
15892
|
+
}
|
|
15893
|
+
/** Preserve the existing expression boundary for direct eval and suspension. */
|
|
15894
|
+
function canInlineSwitchExpression(node) {
|
|
15895
|
+
return !directEval(node) && !suspension(node);
|
|
15896
|
+
}
|
|
15897
|
+
/** Reuse authored blocks only when no direct eval (including a captured one)
|
|
15898
|
+
* can observe the added temporary's broader lifetime/temporal dead zone.
|
|
15899
|
+
* Memoize shared parser nodes so this analysis stays linear in the AST size. */
|
|
15900
|
+
function reusableStatements(ast, usedNames) {
|
|
15901
|
+
const reusable = /* @__PURE__ */ new Set();
|
|
15902
|
+
const observed = /* @__PURE__ */ new Map();
|
|
15903
|
+
const visit = (node) => {
|
|
15904
|
+
const known = observed.get(node);
|
|
15905
|
+
if (known !== void 0) return known;
|
|
15906
|
+
if (node.type === "Identifier" || node.type === "JSXIdentifier") usedNames.add(node.name);
|
|
15907
|
+
let observable = node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "eval";
|
|
15908
|
+
for (const [key, value] of Object.entries(node)) {
|
|
15909
|
+
if (["loc", "trailing"].includes(key)) continue;
|
|
15910
|
+
for (const child of Array.isArray(value) ? value : [value]) if (child?.type && visit(child)) observable = true;
|
|
15911
|
+
}
|
|
15912
|
+
if (!observable && node.type === "BlockStatement") {
|
|
15913
|
+
for (const statement of node.body) if (statement.type === "TwillIfBinding" || (statement.argument ?? statement.expression)?.type === "TwillSwitchExpression") reusable.add(statement);
|
|
15914
|
+
}
|
|
15915
|
+
observed.set(node, observable);
|
|
15916
|
+
return observable;
|
|
15917
|
+
};
|
|
15918
|
+
visit(ast);
|
|
15919
|
+
return reusable;
|
|
15920
|
+
}
|
|
15890
15921
|
/** Native switches with per-arm scopes. Direct returns and standalone variable
|
|
15891
15922
|
* initializers need no extra function; other expressions keep a lexical IIFE. */
|
|
15892
|
-
function lowerSwitchExpressions(source, ast, switches, code, language, usedNames, comments, fail) {
|
|
15923
|
+
function lowerSwitchExpressions(source, ast, switches, code, language, usedNames, comments, fail, implicitReturns = [], reusable = /* @__PURE__ */ new Set()) {
|
|
15893
15924
|
const returns = /* @__PURE__ */ new Set();
|
|
15925
|
+
const implicit = new Set(implicitReturns);
|
|
15926
|
+
const sharedScopes = /* @__PURE__ */ new Set();
|
|
15894
15927
|
const initializers = /* @__PURE__ */ new Map();
|
|
15895
15928
|
const leadingDoc = (start) => {
|
|
15896
15929
|
let low = 0, high = comments.length;
|
|
@@ -15902,19 +15935,6 @@ function lowerSwitchExpressions(source, ast, switches, code, language, usedNames
|
|
|
15902
15935
|
const comment = comments[low - 1];
|
|
15903
15936
|
return comment && /^\s*$/.test(source.slice(comment.end, start)) ? comment : void 0;
|
|
15904
15937
|
};
|
|
15905
|
-
const directEval = (node) => {
|
|
15906
|
-
if ([
|
|
15907
|
-
"FunctionDeclaration",
|
|
15908
|
-
"FunctionExpression",
|
|
15909
|
-
"ArrowFunctionExpression"
|
|
15910
|
-
].includes(node.type)) return false;
|
|
15911
|
-
if (node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "eval" && !node.optional) return true;
|
|
15912
|
-
return Object.entries(node).some(([key, value]) => ![
|
|
15913
|
-
"loc",
|
|
15914
|
-
"trailing",
|
|
15915
|
-
"tag"
|
|
15916
|
-
].includes(key) && (Array.isArray(value) ? value : [value]).some((child) => child?.type && directEval(child)));
|
|
15917
|
-
};
|
|
15918
15938
|
const grouping = (start, end, initializer = false) => {
|
|
15919
15939
|
const parentheses = [];
|
|
15920
15940
|
const tokens = Parser.tokenizer(source.slice(start, end), { ecmaVersion: "latest" });
|
|
@@ -15927,6 +15947,15 @@ function lowerSwitchExpressions(source, ast, switches, code, language, usedNames
|
|
|
15927
15947
|
for (const token of parentheses) code.remove(start + token.start, start + token.end);
|
|
15928
15948
|
};
|
|
15929
15949
|
const visit = (node, parent) => {
|
|
15950
|
+
if (node.type === "BlockStatement") for (const statement of node.body) {
|
|
15951
|
+
const value = statement.type === "ReturnStatement" ? statement.argument : statement.expression;
|
|
15952
|
+
if (value?.type === "TwillSwitchExpression" && (node.body.length === 1 || reusable.has(statement)) && (statement.type === "ReturnStatement" || implicit.has(value))) sharedScopes.add(value);
|
|
15953
|
+
}
|
|
15954
|
+
if (node.type === "ExpressionStatement" && implicit.has(node.expression)) {
|
|
15955
|
+
grouping(node.start, node.expression.start);
|
|
15956
|
+
grouping(node.expression.end, node.end);
|
|
15957
|
+
if (source[node.end - 1] === ";") code.remove(node.end - 1, node.end);
|
|
15958
|
+
}
|
|
15930
15959
|
if (node.type === "VariableDeclaration" && node.declarations.length === 1) {
|
|
15931
15960
|
const declaration = node.declarations[0];
|
|
15932
15961
|
if (declaration.id.type === "Identifier" && declaration.init?.type === "TwillSwitchExpression" && [
|
|
@@ -15948,6 +15977,7 @@ function lowerSwitchExpressions(source, ast, switches, code, language, usedNames
|
|
|
15948
15977
|
if (node.type === "ReturnStatement" && node.argument?.type === "TwillSwitchExpression") {
|
|
15949
15978
|
returns.add(node.argument);
|
|
15950
15979
|
code.remove(node.start, node.start + 6);
|
|
15980
|
+
if (source[node.end - 1] === ";") code.remove(node.end - 1, node.end);
|
|
15951
15981
|
for (const [start, end] of [[node.start + 6, node.argument.start], [node.argument.end, node.end]]) grouping(start, end);
|
|
15952
15982
|
}
|
|
15953
15983
|
for (const [key, value] of Object.entries(node)) {
|
|
@@ -15970,8 +16000,8 @@ function lowerSwitchExpressions(source, ast, switches, code, language, usedNames
|
|
|
15970
16000
|
return name;
|
|
15971
16001
|
};
|
|
15972
16002
|
for (const node of switches) {
|
|
15973
|
-
const direct = returns.has(node);
|
|
15974
|
-
const suspended = !
|
|
16003
|
+
const direct = returns.has(node) || implicit.has(node);
|
|
16004
|
+
const suspended = !returns.has(node) && suspension(node);
|
|
15975
16005
|
if (suspended) fail(suspended, `await/yield inside a ${node.keyword} expression requires a direct return. Bind the subject first, or await the whole result explicitly.`);
|
|
15976
16006
|
const initializer = initializers.get(node);
|
|
15977
16007
|
const result = initializer ? fresh("Result") : void 0;
|
|
@@ -15990,7 +16020,10 @@ function lowerSwitchExpressions(source, ast, switches, code, language, usedNames
|
|
|
15990
16020
|
const valuePrefix = result ? `${result} = (` : "return ";
|
|
15991
16021
|
const valueSuffix = result ? `); break ${exit};` : ";";
|
|
15992
16022
|
const kind = node.cases.some((branch) => branch.enumPattern) ? fresh("Kind") : void 0;
|
|
15993
|
-
if (!initializer)
|
|
16023
|
+
if (!initializer) {
|
|
16024
|
+
const opening = direct ? sharedScopes.has(node) ? "" : "{" : "(() => {";
|
|
16025
|
+
code.appendLeft(node.start, `${opening}const ${subject} = `);
|
|
16026
|
+
}
|
|
15994
16027
|
code.remove(node.parenStart, node.parenStart + 1);
|
|
15995
16028
|
if (node.keyword === "match") {
|
|
15996
16029
|
const tokens = Parser.tokenizer(source.slice(node.discriminant.end, node.parenEnd), { ecmaVersion: "latest" });
|
|
@@ -16047,13 +16080,13 @@ function lowerSwitchExpressions(source, ast, switches, code, language, usedNames
|
|
|
16047
16080
|
}
|
|
16048
16081
|
}
|
|
16049
16082
|
const hasDefault = node.cases.some((branch) => !branch.pattern && !branch.enumPattern && branch.test === null);
|
|
16050
|
-
const check = !hasDefault && language.startsWith("ts") ?
|
|
16051
|
-
const failure = hasDefault ? "" : `${check} throw new TypeError('Non-exhaustive switch expression');`;
|
|
16052
|
-
|
|
16083
|
+
const check = !hasDefault && language.startsWith("ts") ? fresh("Check") : void 0;
|
|
16084
|
+
const failure = hasDefault ? "" : `${check ? ` type ${check}<T extends never = typeof ${kind ?? subject}> = T & never;` : ""} throw new TypeError('Non-exhaustive switch expression'${check ? ` as ${check}` : ""});`;
|
|
16085
|
+
const closing = initializer || direct && !sharedScopes.has(node) ? "}" : direct ? "" : "})()";
|
|
16086
|
+
code.overwrite(node.end - 1, node.end, `}${failure}${closing}`, { contentOnly: true });
|
|
16053
16087
|
}
|
|
16054
16088
|
}
|
|
16055
|
-
|
|
16056
|
-
//#region ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
|
|
16089
|
+
// ../../node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
|
|
16057
16090
|
var schemeRegex = /^[\w+.-]+:\/\//;
|
|
16058
16091
|
/**
|
|
16059
16092
|
* Matches the parts of a URL:
|
|
@@ -16216,8 +16249,7 @@ function resolve$4(input, base) {
|
|
|
16216
16249
|
default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
|
|
16217
16250
|
}
|
|
16218
16251
|
}
|
|
16219
|
-
|
|
16220
|
-
//#region ../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
|
|
16252
|
+
// ../../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
|
|
16221
16253
|
function stripFilename(path) {
|
|
16222
16254
|
if (!path) return "";
|
|
16223
16255
|
const index = path.lastIndexOf("/");
|
|
@@ -16455,8 +16487,7 @@ function generatedPosition$1(map, source, line, column, bias, all) {
|
|
|
16455
16487
|
const segment = segments[index];
|
|
16456
16488
|
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
|
|
16457
16489
|
}
|
|
16458
|
-
|
|
16459
|
-
//#region src/enums.ts
|
|
16490
|
+
// src/enums.ts
|
|
16460
16491
|
/** Find free type references, respecting generic function/mapped/infer binders. */
|
|
16461
16492
|
function references(node, names, found = /* @__PURE__ */ new Set(), bound = /* @__PURE__ */ new Set()) {
|
|
16462
16493
|
const local = new Set(bound);
|
|
@@ -16635,14 +16666,12 @@ function mapEnumCopies(source, generated, map, insertions) {
|
|
|
16635
16666
|
}));
|
|
16636
16667
|
return copies;
|
|
16637
16668
|
}
|
|
16638
|
-
|
|
16639
|
-
//#region src/extensions.ts
|
|
16669
|
+
// src/extensions.ts
|
|
16640
16670
|
var extensions = [".twill", ".twillx"];
|
|
16641
16671
|
function isTwillFile(id) {
|
|
16642
16672
|
return extensions.some((extension) => id.split(/[?#]/, 1)[0].endsWith(extension));
|
|
16643
16673
|
}
|
|
16644
|
-
|
|
16645
|
-
//#region src/compiler.ts
|
|
16674
|
+
// src/compiler.ts
|
|
16646
16675
|
function inferLanguage(filename) {
|
|
16647
16676
|
if (/\.(?:twillx|tsx)$/.test(filename)) return "tsx";
|
|
16648
16677
|
if (/\.jsx$/.test(filename)) return "jsx";
|
|
@@ -16667,6 +16696,25 @@ var TwillSyntaxError = class extends SyntaxError {
|
|
|
16667
16696
|
this.frame = `${source.split(/\r\n|[\r\n\u2028\u2029]/)[line - 1] ?? ""}\n${" ".repeat(column)}^`;
|
|
16668
16697
|
}
|
|
16669
16698
|
};
|
|
16699
|
+
function closureExpression(body) {
|
|
16700
|
+
if (body.length !== 1) return;
|
|
16701
|
+
return body[0].type === "ReturnStatement" ? body[0].argument : body[0].expression;
|
|
16702
|
+
}
|
|
16703
|
+
function conciseExpression(body) {
|
|
16704
|
+
const expression = closureExpression(body);
|
|
16705
|
+
return !!expression && (expression.type !== "TwillSwitchExpression" || !canInlineSwitchExpression(expression));
|
|
16706
|
+
}
|
|
16707
|
+
function expressionGrouping(expression, source, start) {
|
|
16708
|
+
while ([
|
|
16709
|
+
"TSAsExpression",
|
|
16710
|
+
"TSSatisfiesExpression",
|
|
16711
|
+
"TSNonNullExpression"
|
|
16712
|
+
].includes(expression.type)) expression = expression.expression;
|
|
16713
|
+
if (!["ObjectExpression", "SequenceExpression"].includes(expression.type)) return "";
|
|
16714
|
+
const tokens = Parser.tokenizer(source.slice(start, expression.start), { ecmaVersion: "latest" });
|
|
16715
|
+
for (let token = tokens.getToken(); token.type !== types$1.eof; token = tokens.getToken()) if (token.type === types$1.parenL) return "";
|
|
16716
|
+
return "(";
|
|
16717
|
+
}
|
|
16670
16718
|
function walk(node, visit) {
|
|
16671
16719
|
visit(node);
|
|
16672
16720
|
for (const key of Object.keys(node)) {
|
|
@@ -16696,7 +16744,9 @@ function transform(source, options = {}) {
|
|
|
16696
16744
|
const code = new MagicString(source);
|
|
16697
16745
|
const enumInsertions = parsed.enums.length ? lowerEnums(source, parsed.ast, parsed.enums, code) : [];
|
|
16698
16746
|
const usedNames = /* @__PURE__ */ new Set();
|
|
16699
|
-
|
|
16747
|
+
const reusable = parsed.ifBindings.length || parsed.switches.length ? reusableStatements(parsed.ast, usedNames) : /* @__PURE__ */ new Set();
|
|
16748
|
+
const patternGuards = parsed.guards.filter((guard) => guard.binding && guard.binding.declarations[0].id.type !== "Identifier");
|
|
16749
|
+
if (!parsed.ifBindings.length && !parsed.switches.length && (patternGuards.length || parsed.defers.length || parsed.closures.some((closure) => closure.implicitMembers.length) || /\.twillx$/.test(filename.split(/[?#]/, 1)[0]))) walk(parsed.ast, (node) => {
|
|
16700
16750
|
if (node.type === "Identifier" || node.type === "JSXIdentifier") usedNames.add(node.name);
|
|
16701
16751
|
});
|
|
16702
16752
|
let guardCounter = 0;
|
|
@@ -16709,12 +16759,13 @@ function transform(source, options = {}) {
|
|
|
16709
16759
|
while (usedNames.has(temporary));
|
|
16710
16760
|
usedNames.add(temporary);
|
|
16711
16761
|
const patternEnd = binding.typeAnnotation?.start ?? binding.end;
|
|
16712
|
-
|
|
16762
|
+
const reuseScope = reusable.has(statement);
|
|
16763
|
+
code.overwrite(statement.start, binding.start, `${reuseScope ? "" : "{"}const ${temporary}`);
|
|
16713
16764
|
code.move(binding.start, patternEnd, statement.consequent.start + 1);
|
|
16714
16765
|
code.prependRight(binding.start, "const ");
|
|
16715
16766
|
code.appendLeft(patternEnd, ` = ${temporary};`);
|
|
16716
16767
|
code.prependLeft(statement.consequent.start, `; if (${temporary} !== null && ${temporary} !== void 0) `);
|
|
16717
|
-
code.appendLeft(statement.end, "}");
|
|
16768
|
+
if (!reuseScope) code.appendLeft(statement.end, "}");
|
|
16718
16769
|
}
|
|
16719
16770
|
for (const guard of parsed.guards) {
|
|
16720
16771
|
if (guard.singleStatement) {
|
|
@@ -16723,22 +16774,24 @@ function transform(source, options = {}) {
|
|
|
16723
16774
|
}
|
|
16724
16775
|
if (guard.binding) {
|
|
16725
16776
|
const binding = guard.binding.declarations[0].id;
|
|
16726
|
-
|
|
16727
|
-
|
|
16777
|
+
let name;
|
|
16778
|
+
if (binding.type === "Identifier") {
|
|
16779
|
+
name = binding.name;
|
|
16780
|
+
code.remove(guard.start, guard.start + 5);
|
|
16781
|
+
} else {
|
|
16728
16782
|
let temporary;
|
|
16729
16783
|
do
|
|
16730
16784
|
temporary = `__twillGuard${guardCounter++}`;
|
|
16731
16785
|
while (usedNames.has(temporary));
|
|
16732
16786
|
usedNames.add(temporary);
|
|
16787
|
+
name = temporary;
|
|
16733
16788
|
const patternEnd = binding.typeAnnotation?.start ?? binding.end;
|
|
16734
16789
|
code.overwrite(guard.start, binding.start, `const ${temporary}`);
|
|
16735
16790
|
code.move(binding.start, patternEnd, guard.end);
|
|
16736
16791
|
code.prependRight(binding.start, "; const ");
|
|
16737
16792
|
code.appendLeft(patternEnd, ` = ${temporary};`);
|
|
16738
|
-
code.overwrite(guard.elseStart, guard.elseStart + 4, `; if (${temporary} == null)`);
|
|
16739
|
-
continue;
|
|
16740
16793
|
}
|
|
16741
|
-
code.overwrite(guard.elseStart, guard.elseStart + 4, `; if (${
|
|
16794
|
+
code.overwrite(guard.elseStart, guard.elseStart + 4, `; if (${name} === null || ${name} === void 0)`);
|
|
16742
16795
|
} else {
|
|
16743
16796
|
code.overwrite(guard.start, guard.start + 5, "if (!(");
|
|
16744
16797
|
code.overwrite(guard.elseStart, guard.elseStart + 4, "))");
|
|
@@ -16769,7 +16822,9 @@ function transform(source, options = {}) {
|
|
|
16769
16822
|
name = `__twillArg${implicitCounter++}`;
|
|
16770
16823
|
while (usedNames.has(name));
|
|
16771
16824
|
usedNames.add(name);
|
|
16772
|
-
|
|
16825
|
+
const body = metadata.node.body.body;
|
|
16826
|
+
const opening = (options.implicitReturn !== false || body[0]?.type === "ReturnStatement") && conciseExpression(body) ? expressionGrouping(closureExpression(body), source, metadata.header?.end ?? metadata.node.start + 1) : "{";
|
|
16827
|
+
code.overwrite(metadata.node.start, metadata.node.start + 1, `(${name}) => ${opening}`);
|
|
16773
16828
|
for (const offset of metadata.implicitMembers) code.appendLeft(offset, name);
|
|
16774
16829
|
}
|
|
16775
16830
|
const pragma = [...parsed.comments.filter((comment) => comment.start < (parsed.ast.body[0]?.start ?? source.length)).map((comment) => comment.value).join("\n").matchAll(/@jsxImportSource\s+(\S+)/g)].at(-1)?.[1];
|
|
@@ -16797,9 +16852,13 @@ function transform(source, options = {}) {
|
|
|
16797
16852
|
return edits.toString();
|
|
16798
16853
|
};
|
|
16799
16854
|
let counter = 0;
|
|
16855
|
+
const directReturns = [];
|
|
16800
16856
|
for (const node of parsed.calls) {
|
|
16801
16857
|
const { callEnd, hadParens, originalArgs, closures } = node.trailing;
|
|
16802
16858
|
const component = componentCalls.has(node);
|
|
16859
|
+
const slotObject = vue && (options.vueDefaultSlot !== "function" || closures.length > 1);
|
|
16860
|
+
let nativeChild = false;
|
|
16861
|
+
let bareChild = false;
|
|
16803
16862
|
if (component) {
|
|
16804
16863
|
if (originalArgs.length > 1 || originalArgs[0]?.type === "SpreadElement" || node.optional || node.callee.optional) throw new TwillSyntaxError(source, filename, {
|
|
16805
16864
|
message: "Component syntax accepts one props object and children; optional calls use ordinary callbacks.",
|
|
@@ -16824,8 +16883,13 @@ function transform(source, options = {}) {
|
|
|
16824
16883
|
labels.add(name);
|
|
16825
16884
|
}
|
|
16826
16885
|
}
|
|
16827
|
-
const opening = vue ? ">{({default: " : ">{(";
|
|
16828
16886
|
const tagEnd = node.typeParameters?.end ?? node.callee.end;
|
|
16887
|
+
const child = closures[0];
|
|
16888
|
+
const expression = child.body.body[0]?.expression;
|
|
16889
|
+
nativeChild = !vue && !metadataByNode.get(child).header && child.body.body.length === 1 && (expression?.type === "JSXElement" || expression?.type === "JSXFragment") && source.slice(child.start + 1, expression.start).trim() === "" && /^\s*;?\s*$/.test(source.slice(expression.end, child.end - 1)) && source.slice(callEnd, child.start).trim() === "" && (!hadParens || originalArgs.length > 0 || /^\s*\(\s*\)$/.test(source.slice(tagEnd, callEnd)));
|
|
16890
|
+
bareChild = !vue && (!!metadataByNode.get(child).header || child.body.body.length === 1 && expression !== void 0 && expression.type !== "SequenceExpression");
|
|
16891
|
+
let opening = nativeChild ? ">" : bareChild ? ">{" : ">{(";
|
|
16892
|
+
if (vue) opening = slotObject ? ">{{default: " : ">{";
|
|
16829
16893
|
code.appendLeft(node.callee.start, "(<");
|
|
16830
16894
|
const props = originalArgs[0];
|
|
16831
16895
|
if (!vue && props?.type === "ObjectExpression" && props.properties.every((property) => property.type === "SpreadElement" || property.kind === "init" && !property.method && !property.computed && (property.key.name ?? property.key.value) !== "__proto__" && /^[A-Za-z_$][\w$.:-]*$/.test(String(property.key.name ?? property.key.value)))) {
|
|
@@ -16872,7 +16936,7 @@ function transform(source, options = {}) {
|
|
|
16872
16936
|
const tokens = Parser.tokenizer(gap, { ecmaVersion: "latest" });
|
|
16873
16937
|
const first = tokens.getToken();
|
|
16874
16938
|
const last = tokens.getToken();
|
|
16875
|
-
code.overwrite(tagEnd, callEnd, opening + gap.slice(first.end, last.start));
|
|
16939
|
+
code.overwrite(tagEnd, callEnd, opening + (nativeChild ? "" : gap.slice(first.end, last.start)));
|
|
16876
16940
|
} else code.appendLeft(callEnd, opening);
|
|
16877
16941
|
} else if (hadParens) {
|
|
16878
16942
|
const tailStart = originalArgs.at(-1)?.end ?? callEnd - 1;
|
|
@@ -16895,24 +16959,40 @@ function transform(source, options = {}) {
|
|
|
16895
16959
|
"DeferStatement",
|
|
16896
16960
|
"EmptyStatement"
|
|
16897
16961
|
].includes(statement.type)) && body.filter((statement) => statement.type !== "EmptyStatement").at(-1) === expressions[0];
|
|
16962
|
+
const explicitReturn = !content && body.length === 1 && body[0].type === "ReturnStatement" && body[0].argument;
|
|
16963
|
+
const returnsValue = explicitReturn || singleContent || options.implicitReturn !== false && body.length === 1 && body[0].type === "ExpressionStatement";
|
|
16964
|
+
const conciseBody = returnsValue && conciseExpression(body);
|
|
16965
|
+
const grouping = conciseBody ? expressionGrouping(closureExpression(body), source, metadata.header?.end ?? closure.start + 1) : "{";
|
|
16898
16966
|
if (singleContent && body.length === 1 && !vue) {
|
|
16899
16967
|
directChild = true;
|
|
16900
|
-
code.remove(closure.start, closure.start + 1);
|
|
16901
|
-
code.remove(closure.end - 1, closure.end);
|
|
16902
16968
|
const statement = expressions[0];
|
|
16903
|
-
if (
|
|
16969
|
+
if (nativeChild) {
|
|
16970
|
+
code.remove(callEnd, statement.expression.start);
|
|
16971
|
+
code.overwrite(statement.expression.end, closure.end, "", { contentOnly: true });
|
|
16972
|
+
} else {
|
|
16973
|
+
code.remove(closure.start, closure.start + 1);
|
|
16974
|
+
code.overwrite(closure.end - 1, closure.end, "", { contentOnly: true });
|
|
16975
|
+
if (source[statement.end - 1] === ";") code.remove(statement.end - 1, statement.end);
|
|
16976
|
+
}
|
|
16904
16977
|
continue;
|
|
16905
16978
|
}
|
|
16906
16979
|
if (metadata.label) {
|
|
16907
16980
|
const label = source.slice(metadata.label.start, metadata.label.end).replace(/\s*:\s*$/, "");
|
|
16908
|
-
code.overwrite(metadata.label.start, closure.start, component && vue ? `, [${JSON.stringify(label)}]: ` : ", ");
|
|
16981
|
+
code.overwrite(metadata.label.start, closure.start, component && vue ? `, ${label === "__proto__" ? `[${JSON.stringify(label)}]` : JSON.stringify(label)}: ` : ", ");
|
|
16909
16982
|
}
|
|
16910
16983
|
if (metadata.header) {
|
|
16911
16984
|
const header = metadata.header;
|
|
16912
16985
|
code.overwrite(closure.start, closure.start + 1, header.parenthesized || metadata.async ? "" : "(");
|
|
16913
16986
|
if (metadata.async && !header.parenthesized) code.appendLeft(header.asyncEnd, " (");
|
|
16914
|
-
code.overwrite(header.inStart, header.end, `${header.parenthesized ? "" : ") "}=> {`);
|
|
16915
|
-
} else if (!metadata.implicitMembers.length) code.overwrite(closure.start, closure.start + 1,
|
|
16987
|
+
code.overwrite(header.inStart, header.end, `${header.parenthesized ? "" : ") "}=> ${grouping}`);
|
|
16988
|
+
} else if (!metadata.implicitMembers.length) code.overwrite(closure.start, closure.start + 1, `() => ${grouping}`);
|
|
16989
|
+
if (conciseBody) {
|
|
16990
|
+
const statement = body[0];
|
|
16991
|
+
if (explicitReturn) code.remove(statement.start, statement.start + 6);
|
|
16992
|
+
if (source[statement.end - 1] === ";") code.remove(statement.end - 1, statement.end);
|
|
16993
|
+
code.overwrite(closure.end - 1, closure.end, grouping ? ")" : "", { contentOnly: true });
|
|
16994
|
+
continue;
|
|
16995
|
+
}
|
|
16916
16996
|
if (content && !singleContent) {
|
|
16917
16997
|
let collector;
|
|
16918
16998
|
do
|
|
@@ -16965,13 +17045,16 @@ function transform(source, options = {}) {
|
|
|
16965
17045
|
body.forEach(collect);
|
|
16966
17046
|
code.prependLeft(bodyStart, `const ${collector} = [];`);
|
|
16967
17047
|
code.prependLeft(closure.end - 1, vue ? `;return ${collector};` : `;return ${collector}.length === 1 ? ${collector}[0] : ${collector};`);
|
|
16968
|
-
} else if (
|
|
17048
|
+
} else if (returnsValue && !explicitReturn) {
|
|
16969
17049
|
const statement = singleContent ? expressions[0] : body[0];
|
|
16970
|
-
|
|
16971
|
-
|
|
17050
|
+
if (statement.expression.type === "TwillSwitchExpression" && canInlineSwitchExpression(statement.expression)) directReturns.push(statement.expression);
|
|
17051
|
+
else {
|
|
17052
|
+
code.prependLeft(statement.start, "return (");
|
|
17053
|
+
code.appendLeft(source[statement.end - 1] === ";" ? statement.end - 1 : statement.end, ")");
|
|
17054
|
+
}
|
|
16972
17055
|
}
|
|
16973
17056
|
}
|
|
16974
|
-
if (component) code.prependLeft(closures.at(-1).end, (vue ? "}
|
|
17057
|
+
if (component) code.prependLeft(closures.at(-1).end, (vue ? slotObject ? "}}" : "}" : nativeChild ? "" : bareChild ? "}" : directChild ? ")}" : ")()}") + `</${calleeName(node.callee)}>)`);
|
|
16975
17058
|
else code.appendLeft(closures.at(-1).end, ")");
|
|
16976
17059
|
}
|
|
16977
17060
|
if (parsed.switches.length) lowerSwitchExpressions(source, parsed.ast, parsed.switches, code, options.language ?? inferLanguage(filename), usedNames, parsed.comments, (node, message) => {
|
|
@@ -16980,7 +17063,7 @@ function transform(source, options = {}) {
|
|
|
16980
17063
|
pos: node.start,
|
|
16981
17064
|
loc: node.loc.start
|
|
16982
17065
|
});
|
|
16983
|
-
});
|
|
17066
|
+
}, directReturns, reusable);
|
|
16984
17067
|
for (const end of attributeClosings) code.appendLeft(end, "}");
|
|
16985
17068
|
if (parsed.defers.length) {
|
|
16986
17069
|
const starts = /* @__PURE__ */ new Map();
|
|
@@ -17039,8 +17122,7 @@ function generatedPosition(result, line, column) {
|
|
|
17039
17122
|
bias: 1
|
|
17040
17123
|
});
|
|
17041
17124
|
}
|
|
17042
|
-
|
|
17043
|
-
//#region src/compilation-cache.ts
|
|
17125
|
+
// src/compilation-cache.ts
|
|
17044
17126
|
var digest = (source) => (0, node_crypto.createHash)("sha256").update(source).digest("hex");
|
|
17045
17127
|
function observe(path, kind) {
|
|
17046
17128
|
try {
|
|
@@ -17050,8 +17132,7 @@ function observe(path, kind) {
|
|
|
17050
17132
|
return ["ENOENT", "ENOTDIR"].includes(error.code ?? "") ? "absent" : "unavailable";
|
|
17051
17133
|
}
|
|
17052
17134
|
}
|
|
17053
|
-
|
|
17054
|
-
//#region src/configuration.ts
|
|
17135
|
+
// src/configuration.ts
|
|
17055
17136
|
var jsxConfigs = /* @__PURE__ */ new Map();
|
|
17056
17137
|
function record(observations, path, kind) {
|
|
17057
17138
|
path = (0, node_path.resolve)(path);
|
|
@@ -17137,22 +17218,24 @@ function readConfig(root, configFile, observations) {
|
|
|
17137
17218
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${filename}: expected an object`);
|
|
17138
17219
|
if (value.implicitReturn !== void 0 && typeof value.implicitReturn !== "boolean") throw new Error(`${filename}: implicitReturn must be a boolean`);
|
|
17139
17220
|
if (value.runtime !== void 0 && !["inline", "external"].includes(value.runtime)) throw new Error(`${filename}: runtime must be inline or external`);
|
|
17221
|
+
if (value.vueDefaultSlot !== void 0 && !["object", "function"].includes(value.vueDefaultSlot)) throw new Error(`${filename}: vueDefaultSlot must be object or function`);
|
|
17140
17222
|
for (const key of Object.keys(value)) if (![
|
|
17141
17223
|
"implicitReturn",
|
|
17142
17224
|
"runtime",
|
|
17225
|
+
"vueDefaultSlot",
|
|
17143
17226
|
"$schema"
|
|
17144
17227
|
].includes(key)) throw new Error(`${filename}: unknown option ${key}`);
|
|
17145
17228
|
return {
|
|
17146
17229
|
implicitReturn: value.implicitReturn,
|
|
17147
17230
|
jsxImportSource,
|
|
17148
|
-
...value.runtime === void 0 ? {} : { runtime: value.runtime }
|
|
17231
|
+
...value.runtime === void 0 ? {} : { runtime: value.runtime },
|
|
17232
|
+
...value.vueDefaultSlot === void 0 ? {} : { vueDefaultSlot: value.vueDefaultSlot }
|
|
17149
17233
|
};
|
|
17150
17234
|
}
|
|
17151
17235
|
function loadConfig(root = process.cwd(), configFile) {
|
|
17152
17236
|
return readConfig(root, configFile);
|
|
17153
17237
|
}
|
|
17154
|
-
|
|
17155
|
-
//#region ../../node_modules/.pnpm/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
|
|
17238
|
+
// ../../node_modules/.pnpm/@jridgewell+gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs
|
|
17156
17239
|
var SetArray = class {
|
|
17157
17240
|
constructor() {
|
|
17158
17241
|
this._indexes = { __proto__: null };
|
|
@@ -17290,8 +17373,7 @@ function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIn
|
|
|
17290
17373
|
if (prev.length === 1) return false;
|
|
17291
17374
|
return sourcesIndex === prev[SOURCES_INDEX] && sourceLine === prev[SOURCE_LINE] && sourceColumn === prev[SOURCE_COLUMN] && namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME);
|
|
17292
17375
|
}
|
|
17293
|
-
|
|
17294
|
-
//#region ../../node_modules/.pnpm/@ampproject+remapping@2.3.0/node_modules/@ampproject/remapping/dist/remapping.mjs
|
|
17376
|
+
// ../../node_modules/.pnpm/@ampproject+remapping@2.3.0/node_modules/@ampproject/remapping/dist/remapping.mjs
|
|
17295
17377
|
var SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject("", -1, -1, "", null, false);
|
|
17296
17378
|
var EMPTY_SOURCES = [];
|
|
17297
17379
|
function SegmentObject(source, line, column, name, content, ignore) {
|
|
@@ -17448,8 +17530,7 @@ function remapping(input, loader, options) {
|
|
|
17448
17530
|
};
|
|
17449
17531
|
return new SourceMap(traceMappings(buildSourceMapTree(input, loader)), opts);
|
|
17450
17532
|
}
|
|
17451
|
-
|
|
17452
|
-
//#region src/recovery.ts
|
|
17533
|
+
// src/recovery.ts
|
|
17453
17534
|
/** Editor-only recovery; build and CLI compilation always use strict parsing. */
|
|
17454
17535
|
function recoverTransform(source, options, onSyntaxError) {
|
|
17455
17536
|
const repaired = new MagicString(source);
|
|
@@ -17532,8 +17613,7 @@ function recoverTransform(source, options, onSyntaxError) {
|
|
|
17532
17613
|
function isDependency(filename) {
|
|
17533
17614
|
return /(?:^|[\\/])node_modules[\\/]/.test(filename);
|
|
17534
17615
|
}
|
|
17535
|
-
|
|
17536
|
-
//#region src/project.ts
|
|
17616
|
+
// src/project.ts
|
|
17537
17617
|
function lineStarts(text) {
|
|
17538
17618
|
const starts = [0];
|
|
17539
17619
|
const breaks = /\n/g;
|
|
@@ -17885,13 +17965,13 @@ var TwillProject = class {
|
|
|
17885
17965
|
this.service.dispose();
|
|
17886
17966
|
}
|
|
17887
17967
|
};
|
|
17888
|
-
|
|
17889
|
-
//#region src/editor.ts
|
|
17968
|
+
// src/editor.ts
|
|
17890
17969
|
/** Shared semantic requests and conservative source edits for both editor hosts. */
|
|
17891
17970
|
var TwillEditor = class {
|
|
17892
17971
|
project;
|
|
17893
17972
|
attributeCache = /* @__PURE__ */ new WeakMap();
|
|
17894
17973
|
descriptorCache = /* @__PURE__ */ new WeakMap();
|
|
17974
|
+
internalBindingCache = /* @__PURE__ */ new WeakMap();
|
|
17895
17975
|
constructor(project) {
|
|
17896
17976
|
this.project = project;
|
|
17897
17977
|
}
|
|
@@ -17942,11 +18022,37 @@ var TwillEditor = class {
|
|
|
17942
18022
|
}
|
|
17943
18023
|
completions(filename, position, preferences = {}) {
|
|
17944
18024
|
let { offset, props } = this.completionLocation(filename, position);
|
|
17945
|
-
|
|
18025
|
+
let info = this.project.service.getCompletionsAtPosition(virtualFilename(filename), offset, {
|
|
17946
18026
|
includeCompletionsForModuleExports: true,
|
|
17947
18027
|
includeCompletionsWithInsertText: true,
|
|
17948
18028
|
...preferences
|
|
17949
18029
|
});
|
|
18030
|
+
if (info && !info.isMemberCompletion && isTwillFile(sourceFilename(filename)) && this.project.transformed(filename)?.changed) {
|
|
18031
|
+
const file = this.sourceFile(filename);
|
|
18032
|
+
if (file) {
|
|
18033
|
+
let internal = this.internalBindingCache.get(file);
|
|
18034
|
+
if (!internal) {
|
|
18035
|
+
internal = /* @__PURE__ */ new Set();
|
|
18036
|
+
const visit = (node) => {
|
|
18037
|
+
if (typescript.default.isIdentifier(node) && node.text.startsWith("__twill")) {
|
|
18038
|
+
const parent = node.parent;
|
|
18039
|
+
if ((typescript.default.isVariableDeclaration(parent) || typescript.default.isBindingElement(parent) || typescript.default.isParameter(parent) || typescript.default.isTypeAliasDeclaration(parent) || typescript.default.isFunctionDeclaration(parent)) && parent.name === node && !this.mapSpan(filename, {
|
|
18040
|
+
start: node.getStart(),
|
|
18041
|
+
length: node.getWidth()
|
|
18042
|
+
})) internal.add(node.text);
|
|
18043
|
+
}
|
|
18044
|
+
typescript.default.forEachChild(node, visit);
|
|
18045
|
+
};
|
|
18046
|
+
visit(file);
|
|
18047
|
+
this.internalBindingCache.set(file, internal);
|
|
18048
|
+
}
|
|
18049
|
+
const hidden = internal;
|
|
18050
|
+
if (hidden.size) info = {
|
|
18051
|
+
...info,
|
|
18052
|
+
entries: info.entries.filter((entry) => !hidden.has(entry.name))
|
|
18053
|
+
};
|
|
18054
|
+
}
|
|
18055
|
+
}
|
|
17950
18056
|
if (props && !info?.isMemberCompletion) props = void 0;
|
|
17951
18057
|
return {
|
|
17952
18058
|
offset,
|
|
@@ -18211,8 +18317,7 @@ var TwillEditor = class {
|
|
|
18211
18317
|
});
|
|
18212
18318
|
}
|
|
18213
18319
|
};
|
|
18214
|
-
|
|
18215
|
-
//#region src/typescript-plugin.ts
|
|
18320
|
+
// src/typescript-plugin.ts
|
|
18216
18321
|
/** Semantic bridge for native TS/JS documents in configured mixed projects. */
|
|
18217
18322
|
function init(_modules) {
|
|
18218
18323
|
const contexts = /* @__PURE__ */ new Map();
|
|
@@ -18455,7 +18560,6 @@ function init(_modules) {
|
|
|
18455
18560
|
}
|
|
18456
18561
|
};
|
|
18457
18562
|
}
|
|
18458
|
-
//#endregion
|
|
18459
18563
|
exports.default = init;
|
|
18460
18564
|
module.exports = module.exports.default;
|
|
18461
18565
|
|