@absolutejs/absolute 0.20.0-beta.172 → 0.20.0-beta.174
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/CHANGELOG.md +39 -0
- package/README.md +3 -2
- package/changelog.json +68 -0
- package/dist/angular/browser.js +12 -12
- package/dist/angular/browser.js.map +6 -7
- package/dist/angular/components/core/streamingSlotRegistrar.js +2 -6
- package/dist/angular/components/core/streamingSlotRegistry.js +3 -7
- package/dist/angular/components/defer-slot.component.js +12 -7
- package/dist/angular/components/stream-slot.component.js +3 -1
- package/dist/angular/index.js +86 -39
- package/dist/angular/index.js.map +11 -10
- package/dist/angular/server.js +85 -38
- package/dist/angular/server.js.map +10 -9
- package/dist/build/buildWorker.js +135 -57
- package/dist/build.js +1817 -1623
- package/dist/build.js.map +38 -36
- package/dist/cli/{add-ae6mg79m.js → add-ntg96znk.js} +32 -31
- package/dist/cli/{compile-ndc36zna.js → compile-n6fs2vmx.js} +16 -14
- package/dist/cli/config/server.js +128 -77
- package/dist/cli/{dev-x49583aj.js → dev-6h1f0mzq.js} +1 -1
- package/dist/cli/{doctor-repprx92.js → doctor-m36tmx4d.js} +70 -15
- package/dist/cli/{expoProject-h404n2r8.js → expoProject-1qtw97js.js} +2 -1
- package/dist/cli/{generate-brvjesd6.js → generate-5vyz1s44.js} +7 -6
- package/dist/cli/{htmx-5twhjz7p.js → htmx-26hs6jdm.js} +2 -1
- package/dist/cli/{index-gyjxrnnz.js → index-23hvdyxf.js} +18 -16
- package/dist/cli/index-4j1twret.js +22 -0
- package/dist/cli/{index-25e7k849.js → index-bhyd3ejc.js} +4 -4
- package/dist/cli/{index-s0r5q839.js → index-cksezef8.js} +10 -8
- package/dist/cli/{index-q3snnhyd.js → index-enbw9484.js} +34 -33
- package/dist/cli/{index-b1wht4q5.js → index-kes8he5s.js} +6 -4
- package/dist/cli/{index-z794p5qg.js → index-mqevg32w.js} +22 -19
- package/dist/cli/{index-vh68jb0e.js → index-pkw3jktb.js} +17 -16
- package/dist/cli/{index-rervww4p.js → index-zyd80s3h.js} +119 -119
- package/dist/cli/index.js +12 -12
- package/dist/cli/{islands-p4vgx7a2.js → islands-vk05sj6v.js} +5 -4
- package/dist/cli/{mobile-nqdkk3gd.js → mobile-62b6j3j7.js} +5 -4
- package/dist/cli/{remove-abaf0w6k.js → remove-4jh862qa.js} +6 -5
- package/dist/cli/{start-t3cq57wn.js → start-jh6kyp92.js} +5 -4
- package/dist/cli/{typecheck-fag7djt5.js → typecheck-7fvww3b7.js} +28 -26
- package/dist/core/streamingSlotRegistrar.js +2 -5
- package/dist/core/streamingSlotRegistrar.js.map +4 -5
- package/dist/core/streamingSlotRegistry.js +2 -5
- package/dist/core/streamingSlotRegistry.js.map +4 -5
- package/dist/dev/importCostReport.js +45 -26
- package/dist/dev/serverBootstrap.js +2 -1
- package/dist/index.js +1748 -1550
- package/dist/index.js.map +40 -38
- package/dist/islands/index.js +2 -2
- package/dist/islands/index.js.map +3 -3
- package/dist/mobile/browser.js +2 -2
- package/dist/mobile/browser.js.map +3 -3
- package/dist/mobile/index.js +116 -96
- package/dist/mobile/index.js.map +7 -6
- package/dist/mobile/remoteMacAgentEntry.js +205 -651
- package/dist/react/components/index.js +2 -5
- package/dist/react/components/index.js.map +5 -6
- package/dist/react/index.js +45 -16
- package/dist/react/index.js.map +8 -8
- package/dist/react/router/browser.js.map +2 -2
- package/dist/react/router/index.js.map +2 -2
- package/dist/react/server.js +45 -16
- package/dist/react/server.js.map +8 -8
- package/dist/src/angular/components/defer-slot.component.d.ts +1 -0
- package/dist/src/build/missingReactRouter.d.ts +8 -0
- package/dist/src/build/vueModuleOutputPath.d.ts +10 -6
- package/dist/src/cli/config/absolute/resolveAbsoluteConfig.d.ts +3 -3
- package/dist/src/cli/config/auth/resolveAuthSettings.d.ts +3 -3
- package/dist/src/cli/scripts/doctor.d.ts +10 -0
- package/dist/src/core/streamingSlotWarningScope.d.ts +3 -0
- package/dist/src/dev/angular/fastHmrCompiler.d.ts +2 -2
- package/dist/src/dev/angular/hmrImportGenerator.d.ts +2 -2
- package/dist/src/dev/angular/vendor/translator/ts_util.d.ts +2 -2
- package/dist/src/dev/angular/vendor/translator/typescript_ast_factory.d.ts +40 -40
- package/dist/src/dev/angular/vendor/translator/typescript_translator.d.ts +3 -3
- package/dist/src/dev/hot/reload.d.ts +5 -0
- package/dist/src/dev/hot/runtime.d.ts +2 -0
- package/dist/src/dev/srcPath.d.ts +2 -1
- package/dist/src/react/pageHandler.d.ts +5 -0
- package/dist/src/react/router/Link.d.ts +6 -1
- package/dist/src/react/serverComponents/pageHandler.d.ts +2 -0
- package/dist/src/utils/lazyTypescript.d.ts +3 -0
- package/dist/src/utils/portInUse.d.ts +16 -0
- package/dist/svelte/index.js +39 -12
- package/dist/svelte/index.js.map +6 -6
- package/dist/svelte/server.js +39 -12
- package/dist/svelte/server.js.map +6 -6
- package/dist/vue/components/index.js +2 -5
- package/dist/vue/components/index.js.map +4 -5
- package/dist/vue/index.js +39 -12
- package/dist/vue/index.js.map +6 -6
- package/dist/vue/server.js +39 -12
- package/dist/vue/server.js.map +6 -6
- package/package.json +1 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import {
|
|
3
|
+
lazyTypescript
|
|
4
|
+
} from "./index-4j1twret.js";
|
|
2
5
|
import {
|
|
3
6
|
normalizeAbsoluteMobileConfig2
|
|
4
7
|
} from "./index-t7yf3vxs.js";
|
|
@@ -7,40 +10,39 @@ import {
|
|
|
7
10
|
resolveAbsoluteMobileUpdateRuntime,
|
|
8
11
|
writeAbsoluteExpoProject2,
|
|
9
12
|
syncAbsoluteExpoWebAssets2
|
|
10
|
-
} from "./index-
|
|
13
|
+
} from "./index-cksezef8.js";
|
|
11
14
|
import {
|
|
12
15
|
toPascal
|
|
13
16
|
} from "./index-92g14j47.js";
|
|
14
17
|
|
|
15
18
|
// src/build/islandRegistryTransform.ts
|
|
16
19
|
import { basename } from "path";
|
|
17
|
-
import ts from "typescript";
|
|
18
20
|
var VALID_FRAMEWORKS = [
|
|
19
21
|
"react",
|
|
20
22
|
"svelte",
|
|
21
23
|
"vue",
|
|
22
24
|
"angular"
|
|
23
25
|
];
|
|
24
|
-
var getObjectPropertyName = (name) =>
|
|
26
|
+
var getObjectPropertyName = (name) => lazyTypescript.isIdentifier(name) || lazyTypescript.isStringLiteral(name) ? name.text : null;
|
|
25
27
|
var isIslandRegistryHelperImport = (source) => source === "@absolutejs/absolute/islands" || source.endsWith("/islands") || source.endsWith("/core/islands");
|
|
26
28
|
var collectRegistryFactory = (sourceFile) => {
|
|
27
29
|
const factoryNames = new Set;
|
|
28
30
|
const namespaceNames = new Set;
|
|
29
31
|
for (const statement of sourceFile.statements) {
|
|
30
|
-
if (!
|
|
32
|
+
if (!lazyTypescript.isImportDeclaration(statement))
|
|
31
33
|
continue;
|
|
32
|
-
if (!
|
|
34
|
+
if (!lazyTypescript.isStringLiteral(statement.moduleSpecifier))
|
|
33
35
|
continue;
|
|
34
36
|
if (!isIslandRegistryHelperImport(statement.moduleSpecifier.text))
|
|
35
37
|
continue;
|
|
36
38
|
const bindings = statement.importClause?.namedBindings;
|
|
37
39
|
if (!bindings)
|
|
38
40
|
continue;
|
|
39
|
-
if (
|
|
41
|
+
if (lazyTypescript.isNamespaceImport(bindings)) {
|
|
40
42
|
namespaceNames.add(bindings.name.text);
|
|
41
43
|
continue;
|
|
42
44
|
}
|
|
43
|
-
if (!
|
|
45
|
+
if (!lazyTypescript.isNamedImports(bindings))
|
|
44
46
|
continue;
|
|
45
47
|
for (const element of bindings.elements) {
|
|
46
48
|
const imported = element.propertyName?.text ?? element.name.text;
|
|
@@ -52,21 +54,21 @@ var collectRegistryFactory = (sourceFile) => {
|
|
|
52
54
|
return { factoryNames, namespaceNames };
|
|
53
55
|
};
|
|
54
56
|
var isDefineIslandRegistryCall = (expression, factoryNames, namespaceNames) => {
|
|
55
|
-
if (
|
|
57
|
+
if (lazyTypescript.isIdentifier(expression))
|
|
56
58
|
return factoryNames.has(expression.text);
|
|
57
|
-
return
|
|
59
|
+
return lazyTypescript.isPropertyAccessExpression(expression) && expression.name.text === "defineIslandRegistry" && lazyTypescript.isIdentifier(expression.expression) && namespaceNames.has(expression.expression.text);
|
|
58
60
|
};
|
|
59
61
|
var findDefineIslandRegistryCall = (sourceFile, factoryNames, namespaceNames) => {
|
|
60
62
|
let found = null;
|
|
61
63
|
const visit = (node) => {
|
|
62
64
|
if (found)
|
|
63
65
|
return;
|
|
64
|
-
const [firstArg] =
|
|
65
|
-
if (
|
|
66
|
+
const [firstArg] = lazyTypescript.isCallExpression(node) ? node.arguments : [];
|
|
67
|
+
if (lazyTypescript.isCallExpression(node) && isDefineIslandRegistryCall(node.expression, factoryNames, namespaceNames) && firstArg && lazyTypescript.isObjectLiteralExpression(firstArg)) {
|
|
66
68
|
found = node;
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
lazyTypescript.forEachChild(node, visit);
|
|
70
72
|
};
|
|
71
73
|
visit(sourceFile);
|
|
72
74
|
return found;
|
|
@@ -79,8 +81,8 @@ var definitionLiteral = (reference) => {
|
|
|
79
81
|
var transformIslandRegistrySource = (source, filePath, info) => {
|
|
80
82
|
if (!source.includes("defineIslandRegistry"))
|
|
81
83
|
return null;
|
|
82
|
-
const scriptKind = filePath.endsWith(".tsx") || filePath.endsWith(".jsx") ?
|
|
83
|
-
const sourceFile =
|
|
84
|
+
const scriptKind = filePath.endsWith(".tsx") || filePath.endsWith(".jsx") ? lazyTypescript.ScriptKind.TSX : lazyTypescript.ScriptKind.TS;
|
|
85
|
+
const sourceFile = lazyTypescript.createSourceFile(filePath, source, lazyTypescript.ScriptTarget.Latest, true, scriptKind);
|
|
84
86
|
const { factoryNames, namespaceNames } = collectRegistryFactory(sourceFile);
|
|
85
87
|
if (factoryNames.size === 0 && namespaceNames.size === 0)
|
|
86
88
|
return null;
|
|
@@ -88,7 +90,7 @@ var transformIslandRegistrySource = (source, filePath, info) => {
|
|
|
88
90
|
if (!call)
|
|
89
91
|
return null;
|
|
90
92
|
const [objectLiteral] = call.arguments;
|
|
91
|
-
if (!objectLiteral || !
|
|
93
|
+
if (!objectLiteral || !lazyTypescript.isObjectLiteralExpression(objectLiteral)) {
|
|
92
94
|
return null;
|
|
93
95
|
}
|
|
94
96
|
const definitionLookup = new Map;
|
|
@@ -103,20 +105,20 @@ var transformIslandRegistrySource = (source, filePath, info) => {
|
|
|
103
105
|
const edits = [];
|
|
104
106
|
const replacedLocals = new Set;
|
|
105
107
|
for (const frameworkProperty of objectLiteral.properties) {
|
|
106
|
-
if (!
|
|
108
|
+
if (!lazyTypescript.isPropertyAssignment(frameworkProperty))
|
|
107
109
|
continue;
|
|
108
110
|
const frameworkName = getObjectPropertyName(frameworkProperty.name);
|
|
109
111
|
const framework = VALID_FRAMEWORKS.find((f) => f === frameworkName);
|
|
110
112
|
if (!framework)
|
|
111
113
|
continue;
|
|
112
|
-
if (!
|
|
114
|
+
if (!lazyTypescript.isObjectLiteralExpression(frameworkProperty.initializer))
|
|
113
115
|
continue;
|
|
114
116
|
for (const componentProperty of frameworkProperty.initializer.properties) {
|
|
115
117
|
let componentKey = null;
|
|
116
118
|
let localName = null;
|
|
117
119
|
let replaceNode = null;
|
|
118
120
|
let replacementText = "";
|
|
119
|
-
if (
|
|
121
|
+
if (lazyTypescript.isShorthandPropertyAssignment(componentProperty)) {
|
|
120
122
|
componentKey = componentProperty.name.text;
|
|
121
123
|
localName = componentProperty.name.text;
|
|
122
124
|
const reference = definitionLookup.get(`${framework}:${componentKey}`);
|
|
@@ -124,7 +126,7 @@ var transformIslandRegistrySource = (source, filePath, info) => {
|
|
|
124
126
|
continue;
|
|
125
127
|
replaceNode = componentProperty;
|
|
126
128
|
replacementText = `${quoteKey(componentKey)}: ${definitionLiteral(reference)}`;
|
|
127
|
-
} else if (
|
|
129
|
+
} else if (lazyTypescript.isPropertyAssignment(componentProperty) && lazyTypescript.isIdentifier(componentProperty.initializer)) {
|
|
128
130
|
componentKey = getObjectPropertyName(componentProperty.name);
|
|
129
131
|
localName = componentProperty.initializer.text;
|
|
130
132
|
if (!componentKey)
|
|
@@ -148,7 +150,7 @@ var transformIslandRegistrySource = (source, filePath, info) => {
|
|
|
148
150
|
if (edits.length === 0)
|
|
149
151
|
return null;
|
|
150
152
|
for (const statement of sourceFile.statements) {
|
|
151
|
-
if (!
|
|
153
|
+
if (!lazyTypescript.isImportDeclaration(statement))
|
|
152
154
|
continue;
|
|
153
155
|
const clause = statement.importClause;
|
|
154
156
|
if (!clause)
|
|
@@ -157,11 +159,11 @@ var transformIslandRegistrySource = (source, filePath, info) => {
|
|
|
157
159
|
if (clause.name)
|
|
158
160
|
localNames.push(clause.name.text);
|
|
159
161
|
const bindings = clause.namedBindings;
|
|
160
|
-
if (bindings &&
|
|
162
|
+
if (bindings && lazyTypescript.isNamedImports(bindings)) {
|
|
161
163
|
for (const element of bindings.elements) {
|
|
162
164
|
localNames.push(element.name.text);
|
|
163
165
|
}
|
|
164
|
-
} else if (bindings &&
|
|
166
|
+
} else if (bindings && lazyTypescript.isNamespaceImport(bindings)) {
|
|
165
167
|
localNames.push(bindings.name.text);
|
|
166
168
|
}
|
|
167
169
|
if (localNames.length === 0)
|
|
@@ -214,16 +216,15 @@ var createIslandRegistryDefinitionPlugin = (info) => {
|
|
|
214
216
|
|
|
215
217
|
// src/build/bunStringRawUnicodePlugin.ts
|
|
216
218
|
import { extname } from "path";
|
|
217
|
-
import ts2 from "typescript";
|
|
218
219
|
var NON_ASCII = /[^\x00-\x7f]/;
|
|
219
220
|
var getScriptKind = (filePath) => {
|
|
220
221
|
if (/\.[cm]?tsx$/.test(filePath))
|
|
221
|
-
return
|
|
222
|
+
return lazyTypescript.ScriptKind.TSX;
|
|
222
223
|
if (/\.[cm]?jsx$/.test(filePath))
|
|
223
|
-
return
|
|
224
|
+
return lazyTypescript.ScriptKind.JSX;
|
|
224
225
|
if (/\.[cm]?ts$/.test(filePath))
|
|
225
|
-
return
|
|
226
|
-
return
|
|
226
|
+
return lazyTypescript.ScriptKind.TS;
|
|
227
|
+
return lazyTypescript.ScriptKind.JS;
|
|
227
228
|
};
|
|
228
229
|
var getLoader = (filePath) => {
|
|
229
230
|
const extension = extname(filePath);
|
|
@@ -236,21 +237,21 @@ var getLoader = (filePath) => {
|
|
|
236
237
|
}
|
|
237
238
|
return "js";
|
|
238
239
|
};
|
|
239
|
-
var isStringRawTag = (node) =>
|
|
240
|
+
var isStringRawTag = (node) => lazyTypescript.isPropertyAccessExpression(node.tag) && lazyTypescript.isIdentifier(node.tag.expression) && node.tag.expression.text === "String" && node.tag.name.text === "raw";
|
|
240
241
|
var getRawText = (node) => node.rawText ?? node.text;
|
|
241
242
|
var rewriteBunStringRawUnicode = (source, filePath = "input.ts") => {
|
|
242
243
|
if (!source.includes("String.raw") || !NON_ASCII.test(source))
|
|
243
244
|
return source;
|
|
244
|
-
const sourceFile =
|
|
245
|
+
const sourceFile = lazyTypescript.createSourceFile(filePath, source, lazyTypescript.ScriptTarget.Latest, true, getScriptKind(filePath));
|
|
245
246
|
const replacements = [];
|
|
246
247
|
const visit = (node) => {
|
|
247
|
-
if (
|
|
248
|
-
const rawSegments =
|
|
248
|
+
if (lazyTypescript.isTaggedTemplateExpression(node) && isStringRawTag(node)) {
|
|
249
|
+
const rawSegments = lazyTypescript.isNoSubstitutionTemplateLiteral(node.template) ? [getRawText(node.template)] : [
|
|
249
250
|
getRawText(node.template.head),
|
|
250
251
|
...node.template.templateSpans.map((span) => getRawText(span.literal))
|
|
251
252
|
];
|
|
252
253
|
if (rawSegments.some((segment) => NON_ASCII.test(segment))) {
|
|
253
|
-
const expressions =
|
|
254
|
+
const expressions = lazyTypescript.isTemplateExpression(node.template) ? node.template.templateSpans.map((span) => {
|
|
254
255
|
const expression = source.slice(span.expression.getStart(sourceFile), span.expression.end);
|
|
255
256
|
return rewriteBunStringRawUnicode(expression, filePath);
|
|
256
257
|
}) : [];
|
|
@@ -266,7 +267,7 @@ var rewriteBunStringRawUnicode = (source, filePath = "input.ts") => {
|
|
|
266
267
|
return;
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
|
-
|
|
270
|
+
lazyTypescript.forEachChild(node, visit);
|
|
270
271
|
};
|
|
271
272
|
visit(sourceFile);
|
|
272
273
|
let result = source;
|
|
@@ -1567,7 +1568,6 @@ var finalizeAbsoluteMobileCompatibilityBuild = async (options) => {
|
|
|
1567
1568
|
// src/mobile/routeMetadataTransform.ts
|
|
1568
1569
|
import { existsSync as existsSync2, readFileSync } from "fs";
|
|
1569
1570
|
import { dirname as dirname4, extname as extname4, relative as relative3, resolve as resolve4 } from "path";
|
|
1570
|
-
import ts3 from "typescript";
|
|
1571
1571
|
var ROUTE_METHODS = new Set(["get", "head"]);
|
|
1572
1572
|
var SOURCE_FILTER = /\.[cm]?[jt]sx?$/;
|
|
1573
1573
|
var PAGE_HANDLERS = new Map([
|
|
@@ -1617,60 +1617,60 @@ var PAGE_HANDLERS = new Map([
|
|
|
1617
1617
|
]
|
|
1618
1618
|
]);
|
|
1619
1619
|
var posixPath = (value) => value.replace(/\\/g, "/");
|
|
1620
|
-
var findTsconfig = (entry, projectRoot) =>
|
|
1620
|
+
var findTsconfig = (entry, projectRoot) => lazyTypescript.findConfigFile(dirname4(entry), existsSync2, "tsconfig.json") ?? lazyTypescript.findConfigFile(projectRoot, existsSync2, "tsconfig.json");
|
|
1621
1621
|
var createProgram = (entry, projectRoot) => {
|
|
1622
1622
|
const configPath = findTsconfig(entry, projectRoot);
|
|
1623
1623
|
if (!configPath) {
|
|
1624
|
-
return
|
|
1624
|
+
return lazyTypescript.createProgram([entry], {
|
|
1625
1625
|
allowJs: true,
|
|
1626
|
-
jsx:
|
|
1627
|
-
module:
|
|
1628
|
-
moduleResolution:
|
|
1629
|
-
target:
|
|
1626
|
+
jsx: lazyTypescript.JsxEmit.ReactJSX,
|
|
1627
|
+
module: lazyTypescript.ModuleKind.ESNext,
|
|
1628
|
+
moduleResolution: lazyTypescript.ModuleResolutionKind.Bundler,
|
|
1629
|
+
target: lazyTypescript.ScriptTarget.ESNext
|
|
1630
1630
|
});
|
|
1631
1631
|
}
|
|
1632
|
-
const parsed =
|
|
1632
|
+
const parsed = lazyTypescript.parseJsonConfigFileContent(lazyTypescript.readConfigFile(configPath, (path) => readFileSync(path, "utf8")).config, lazyTypescript.sys, dirname4(configPath));
|
|
1633
1633
|
if (!parsed.fileNames.includes(entry))
|
|
1634
1634
|
parsed.fileNames.push(entry);
|
|
1635
|
-
return
|
|
1635
|
+
return lazyTypescript.createProgram(parsed.fileNames, parsed.options);
|
|
1636
1636
|
};
|
|
1637
1637
|
var propertyName = (property) => {
|
|
1638
1638
|
if (!("name" in property) || !property.name)
|
|
1639
1639
|
return;
|
|
1640
|
-
if (
|
|
1640
|
+
if (lazyTypescript.isIdentifier(property.name))
|
|
1641
1641
|
return property.name.text;
|
|
1642
|
-
if (
|
|
1642
|
+
if (lazyTypescript.isStringLiteralLike(property.name))
|
|
1643
1643
|
return property.name.text;
|
|
1644
1644
|
return;
|
|
1645
1645
|
};
|
|
1646
1646
|
var objectPropertyExpression = (object, name) => {
|
|
1647
1647
|
const property = object.properties.find((candidate) => propertyName(candidate) === name);
|
|
1648
|
-
if (property &&
|
|
1648
|
+
if (property && lazyTypescript.isPropertyAssignment(property)) {
|
|
1649
1649
|
return property.initializer;
|
|
1650
1650
|
}
|
|
1651
|
-
if (property &&
|
|
1651
|
+
if (property && lazyTypescript.isShorthandPropertyAssignment(property)) {
|
|
1652
1652
|
return property.name;
|
|
1653
1653
|
}
|
|
1654
1654
|
return;
|
|
1655
1655
|
};
|
|
1656
1656
|
var serializeType = (type, checker, ancestors = new Set) => {
|
|
1657
|
-
if (type.flags &
|
|
1657
|
+
if (type.flags & lazyTypescript.TypeFlags.Any)
|
|
1658
1658
|
return { type: "any" };
|
|
1659
|
-
if (type.flags &
|
|
1659
|
+
if (type.flags & lazyTypescript.TypeFlags.Unknown)
|
|
1660
1660
|
return { type: "unknown" };
|
|
1661
|
-
if (type.flags &
|
|
1661
|
+
if (type.flags & lazyTypescript.TypeFlags.Never)
|
|
1662
1662
|
return { type: "never" };
|
|
1663
|
-
if (type.flags &
|
|
1663
|
+
if (type.flags & lazyTypescript.TypeFlags.StringLike)
|
|
1664
1664
|
return { type: "string" };
|
|
1665
|
-
if (type.flags &
|
|
1665
|
+
if (type.flags & lazyTypescript.TypeFlags.NumberLike)
|
|
1666
1666
|
return { type: "number" };
|
|
1667
|
-
if (type.flags &
|
|
1667
|
+
if (type.flags & lazyTypescript.TypeFlags.BooleanLike)
|
|
1668
1668
|
return { type: "boolean" };
|
|
1669
|
-
if (type.flags &
|
|
1669
|
+
if (type.flags & lazyTypescript.TypeFlags.BigIntLike)
|
|
1670
1670
|
return { type: "bigint" };
|
|
1671
|
-
if (type.flags &
|
|
1671
|
+
if (type.flags & lazyTypescript.TypeFlags.Null)
|
|
1672
1672
|
return { type: "null" };
|
|
1673
|
-
if (type.flags &
|
|
1673
|
+
if (type.flags & lazyTypescript.TypeFlags.Undefined)
|
|
1674
1674
|
return { type: "undefined" };
|
|
1675
1675
|
if (type.isUnion()) {
|
|
1676
1676
|
return {
|
|
@@ -1684,11 +1684,11 @@ var serializeType = (type, checker, ancestors = new Set) => {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
if (ancestors.has(type)) {
|
|
1686
1686
|
return {
|
|
1687
|
-
ref: checker.typeToString(type, undefined,
|
|
1687
|
+
ref: checker.typeToString(type, undefined, lazyTypescript.TypeFormatFlags.NoTruncation)
|
|
1688
1688
|
};
|
|
1689
1689
|
}
|
|
1690
1690
|
ancestors.add(type);
|
|
1691
|
-
const arrayElement = checker.getIndexTypeOfType(type,
|
|
1691
|
+
const arrayElement = checker.getIndexTypeOfType(type, lazyTypescript.IndexKind.Number);
|
|
1692
1692
|
const properties = checker.getPropertiesOfType(type);
|
|
1693
1693
|
let schema;
|
|
1694
1694
|
if (arrayElement && properties.some(({ name }) => name === "length")) {
|
|
@@ -1703,7 +1703,7 @@ var serializeType = (type, checker, ancestors = new Set) => {
|
|
|
1703
1703
|
return [
|
|
1704
1704
|
property.name,
|
|
1705
1705
|
{
|
|
1706
|
-
optional: Boolean(property.flags &
|
|
1706
|
+
optional: Boolean(property.flags & lazyTypescript.SymbolFlags.Optional),
|
|
1707
1707
|
schema: serializeType(propertyType, checker, ancestors)
|
|
1708
1708
|
}
|
|
1709
1709
|
];
|
|
@@ -1711,7 +1711,7 @@ var serializeType = (type, checker, ancestors = new Set) => {
|
|
|
1711
1711
|
schema = { properties: Object.fromEntries(entries), type: "object" };
|
|
1712
1712
|
} else {
|
|
1713
1713
|
schema = {
|
|
1714
|
-
type: checker.typeToString(type, undefined,
|
|
1714
|
+
type: checker.typeToString(type, undefined, lazyTypescript.TypeFormatFlags.NoTruncation)
|
|
1715
1715
|
};
|
|
1716
1716
|
}
|
|
1717
1717
|
ancestors.delete(type);
|
|
@@ -1729,7 +1729,7 @@ var pagePropsType = (pageExpression, propsExpression, checker) => {
|
|
|
1729
1729
|
};
|
|
1730
1730
|
var resolvePageIdentity = (expression, sourceFile, checker, projectRoot) => {
|
|
1731
1731
|
let symbol = checker.getSymbolAtLocation(expression);
|
|
1732
|
-
if (symbol?.flags && symbol.flags &
|
|
1732
|
+
if (symbol?.flags && symbol.flags & lazyTypescript.SymbolFlags.Alias) {
|
|
1733
1733
|
symbol = checker.getAliasedSymbol(symbol);
|
|
1734
1734
|
}
|
|
1735
1735
|
const declaration = symbol?.declarations?.[0];
|
|
@@ -1739,15 +1739,15 @@ var resolvePageIdentity = (expression, sourceFile, checker, projectRoot) => {
|
|
|
1739
1739
|
return `${source}#${exportedName}`;
|
|
1740
1740
|
};
|
|
1741
1741
|
var resolveAlias = (symbol, checker) => {
|
|
1742
|
-
if (!(symbol.flags &
|
|
1742
|
+
if (!(symbol.flags & lazyTypescript.SymbolFlags.Alias))
|
|
1743
1743
|
return symbol;
|
|
1744
1744
|
return checker.getAliasedSymbol(symbol);
|
|
1745
1745
|
};
|
|
1746
1746
|
var assetKey = (expression, checker, seen = new Set) => {
|
|
1747
1747
|
if (!expression)
|
|
1748
1748
|
return;
|
|
1749
|
-
if (
|
|
1750
|
-
const unresolved =
|
|
1749
|
+
if (lazyTypescript.isIdentifier(expression)) {
|
|
1750
|
+
const unresolved = lazyTypescript.isShorthandPropertyAssignment(expression.parent) ? checker.getShorthandAssignmentValueSymbol(expression.parent) : checker.getSymbolAtLocation(expression);
|
|
1751
1751
|
if (!unresolved)
|
|
1752
1752
|
return;
|
|
1753
1753
|
const symbol = resolveAlias(unresolved, checker);
|
|
@@ -1755,26 +1755,26 @@ var assetKey = (expression, checker, seen = new Set) => {
|
|
|
1755
1755
|
return;
|
|
1756
1756
|
seen.add(symbol);
|
|
1757
1757
|
const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
1758
|
-
if (!declaration || !
|
|
1758
|
+
if (!declaration || !lazyTypescript.isVariableDeclaration(declaration))
|
|
1759
1759
|
return;
|
|
1760
1760
|
return assetKey(declaration.initializer, checker, seen);
|
|
1761
1761
|
}
|
|
1762
|
-
if (!
|
|
1762
|
+
if (!lazyTypescript.isCallExpression(expression))
|
|
1763
1763
|
return;
|
|
1764
|
-
if (!
|
|
1764
|
+
if (!lazyTypescript.isIdentifier(expression.expression) || expression.expression.text !== "asset") {
|
|
1765
1765
|
return;
|
|
1766
1766
|
}
|
|
1767
1767
|
const [, key] = expression.arguments;
|
|
1768
|
-
return key &&
|
|
1768
|
+
return key && lazyTypescript.isStringLiteralLike(key) ? key.text : undefined;
|
|
1769
1769
|
};
|
|
1770
1770
|
var staticString = (expression, bindings) => {
|
|
1771
|
-
if (
|
|
1771
|
+
if (lazyTypescript.isStringLiteralLike(expression))
|
|
1772
1772
|
return expression.text;
|
|
1773
|
-
if (
|
|
1773
|
+
if (lazyTypescript.isIdentifier(expression))
|
|
1774
1774
|
return bindings.get(expression.text);
|
|
1775
|
-
if (
|
|
1775
|
+
if (lazyTypescript.isNoSubstitutionTemplateLiteral(expression))
|
|
1776
1776
|
return expression.text;
|
|
1777
|
-
if (!
|
|
1777
|
+
if (!lazyTypescript.isTemplateExpression(expression))
|
|
1778
1778
|
return;
|
|
1779
1779
|
let value = expression.head.text;
|
|
1780
1780
|
for (const span of expression.templateSpans) {
|
|
@@ -1788,7 +1788,7 @@ var staticString = (expression, bindings) => {
|
|
|
1788
1788
|
var assetKeyWithBindings = (expression, checker, bindings = new Map) => {
|
|
1789
1789
|
if (!expression)
|
|
1790
1790
|
return;
|
|
1791
|
-
if (
|
|
1791
|
+
if (lazyTypescript.isCallExpression(expression) && lazyTypescript.isIdentifier(expression.expression) && expression.expression.text === "asset") {
|
|
1792
1792
|
const [, key] = expression.arguments;
|
|
1793
1793
|
return key ? staticString(key, bindings) : undefined;
|
|
1794
1794
|
}
|
|
@@ -1799,16 +1799,16 @@ var callableObject = (call, checker) => {
|
|
|
1799
1799
|
const resolved = symbol ? resolveAlias(symbol, checker) : undefined;
|
|
1800
1800
|
const declaration = resolved?.valueDeclaration ?? resolved?.declarations?.[0];
|
|
1801
1801
|
let callable;
|
|
1802
|
-
if (declaration &&
|
|
1802
|
+
if (declaration && lazyTypescript.isFunctionDeclaration(declaration)) {
|
|
1803
1803
|
callable = declaration;
|
|
1804
|
-
} else if (declaration &&
|
|
1804
|
+
} else if (declaration && lazyTypescript.isVariableDeclaration(declaration) && declaration.initializer && (lazyTypescript.isArrowFunction(declaration.initializer) || lazyTypescript.isFunctionExpression(declaration.initializer))) {
|
|
1805
1805
|
callable = declaration.initializer;
|
|
1806
1806
|
}
|
|
1807
1807
|
if (!callable)
|
|
1808
1808
|
return;
|
|
1809
1809
|
const bindings = new Map;
|
|
1810
1810
|
callable.parameters.forEach((parameter, index) => {
|
|
1811
|
-
if (!
|
|
1811
|
+
if (!lazyTypescript.isIdentifier(parameter.name))
|
|
1812
1812
|
return;
|
|
1813
1813
|
const argument = call.arguments[index];
|
|
1814
1814
|
if (!argument)
|
|
@@ -1820,35 +1820,35 @@ var callableObject = (call, checker) => {
|
|
|
1820
1820
|
const { body } = callable;
|
|
1821
1821
|
if (!body)
|
|
1822
1822
|
return;
|
|
1823
|
-
const expressionBody =
|
|
1824
|
-
if (
|
|
1823
|
+
const expressionBody = lazyTypescript.isParenthesizedExpression(body) ? body.expression : body;
|
|
1824
|
+
if (lazyTypescript.isObjectLiteralExpression(expressionBody)) {
|
|
1825
1825
|
return { bindings, object: expressionBody };
|
|
1826
1826
|
}
|
|
1827
|
-
if (
|
|
1828
|
-
const returned = body.statements.find(
|
|
1829
|
-
if (returned &&
|
|
1827
|
+
if (lazyTypescript.isBlock(body)) {
|
|
1828
|
+
const returned = body.statements.find(lazyTypescript.isReturnStatement)?.expression;
|
|
1829
|
+
if (returned && lazyTypescript.isObjectLiteralExpression(returned)) {
|
|
1830
1830
|
return { bindings, object: returned };
|
|
1831
1831
|
}
|
|
1832
1832
|
}
|
|
1833
1833
|
return;
|
|
1834
1834
|
};
|
|
1835
1835
|
var spreadObject = (expression, checker, bindings) => {
|
|
1836
|
-
if (
|
|
1836
|
+
if (lazyTypescript.isObjectLiteralExpression(expression)) {
|
|
1837
1837
|
return { bindings, object: expression };
|
|
1838
1838
|
}
|
|
1839
|
-
if (!
|
|
1839
|
+
if (!lazyTypescript.isCallExpression(expression))
|
|
1840
1840
|
return;
|
|
1841
1841
|
return callableObject(expression, checker);
|
|
1842
1842
|
};
|
|
1843
1843
|
var objectAssetKey = (object, name, checker, bindings = new Map) => {
|
|
1844
1844
|
for (const property of [...object.properties].reverse()) {
|
|
1845
|
-
if (propertyName(property) === name &&
|
|
1845
|
+
if (propertyName(property) === name && lazyTypescript.isShorthandPropertyAssignment(property)) {
|
|
1846
1846
|
return assetKeyWithBindings(property.name, checker, bindings);
|
|
1847
1847
|
}
|
|
1848
|
-
if (propertyName(property) === name &&
|
|
1848
|
+
if (propertyName(property) === name && lazyTypescript.isPropertyAssignment(property)) {
|
|
1849
1849
|
return assetKeyWithBindings(property.initializer, checker, bindings);
|
|
1850
1850
|
}
|
|
1851
|
-
if (!
|
|
1851
|
+
if (!lazyTypescript.isSpreadAssignment(property))
|
|
1852
1852
|
continue;
|
|
1853
1853
|
const nestedObject = spreadObject(property.expression, checker, bindings);
|
|
1854
1854
|
if (!nestedObject)
|
|
@@ -1864,14 +1864,14 @@ var findPageCall = (nodes) => {
|
|
|
1864
1864
|
const visit = (candidate) => {
|
|
1865
1865
|
if (found)
|
|
1866
1866
|
return;
|
|
1867
|
-
if (
|
|
1867
|
+
if (lazyTypescript.isCallExpression(candidate) && lazyTypescript.isIdentifier(candidate.expression) && PAGE_HANDLERS.has(candidate.expression.text)) {
|
|
1868
1868
|
const definition = PAGE_HANDLERS.get(candidate.expression.text);
|
|
1869
1869
|
if (!definition)
|
|
1870
1870
|
return;
|
|
1871
1871
|
found = { definition, node: candidate };
|
|
1872
1872
|
return;
|
|
1873
1873
|
}
|
|
1874
|
-
|
|
1874
|
+
lazyTypescript.forEachChild(candidate, visit);
|
|
1875
1875
|
};
|
|
1876
1876
|
for (const node of nodes)
|
|
1877
1877
|
visit(node);
|
|
@@ -1880,12 +1880,12 @@ var findPageCall = (nodes) => {
|
|
|
1880
1880
|
var isProjectSource = (sourceFile, resolvedFile, projectRoot) => !sourceFile.isDeclarationFile && !resolvedFile.includes("/node_modules/") && resolvedFile.startsWith(`${projectRoot}/`);
|
|
1881
1881
|
var analyzeRouteCall = (node, sourceFile, checker, projectRoot) => {
|
|
1882
1882
|
const callee = node.expression;
|
|
1883
|
-
if (!
|
|
1883
|
+
if (!lazyTypescript.isPropertyAccessExpression(callee))
|
|
1884
1884
|
return;
|
|
1885
1885
|
if (!ROUTE_METHODS.has(callee.name.text))
|
|
1886
1886
|
return;
|
|
1887
1887
|
const [routePath] = node.arguments;
|
|
1888
|
-
if (!routePath || !
|
|
1888
|
+
if (!routePath || !lazyTypescript.isStringLiteralLike(routePath))
|
|
1889
1889
|
return;
|
|
1890
1890
|
const foundPageCall = findPageCall(node.arguments.slice(1));
|
|
1891
1891
|
const pageCall = foundPageCall?.node;
|
|
@@ -1918,7 +1918,7 @@ var analyzeRouteCall = (node, sourceFile, checker, projectRoot) => {
|
|
|
1918
1918
|
routeCallSpan: `${node.getStart(sourceFile)}:${node.end}`
|
|
1919
1919
|
};
|
|
1920
1920
|
}
|
|
1921
|
-
if (!
|
|
1921
|
+
if (!lazyTypescript.isObjectLiteralExpression(input) || !definition.bundleProperty) {
|
|
1922
1922
|
return;
|
|
1923
1923
|
}
|
|
1924
1924
|
const page = definition.pageProperty ? objectPropertyExpression(input, definition.pageProperty) : undefined;
|
|
@@ -1960,14 +1960,14 @@ var analyzeSourceFile = (sourceFile, checker, projectRoot) => {
|
|
|
1960
1960
|
byRouteCall: new Map
|
|
1961
1961
|
};
|
|
1962
1962
|
const visit = (node) => {
|
|
1963
|
-
const result =
|
|
1963
|
+
const result = lazyTypescript.isCallExpression(node) ? analyzeRouteCall(node, sourceFile, checker, projectRoot) : undefined;
|
|
1964
1964
|
if (result) {
|
|
1965
1965
|
analysis.byPageCall.set(result.pageCallStart, result);
|
|
1966
1966
|
analysis.byRouteCall.set(result.routeCallSpan, result);
|
|
1967
1967
|
}
|
|
1968
|
-
|
|
1968
|
+
lazyTypescript.forEachChild(node, visit);
|
|
1969
1969
|
};
|
|
1970
|
-
|
|
1970
|
+
lazyTypescript.forEachChild(sourceFile, visit);
|
|
1971
1971
|
return analysis;
|
|
1972
1972
|
};
|
|
1973
1973
|
var analyzeProgram = (program, projectRoot) => {
|
|
@@ -1983,21 +1983,21 @@ var analyzeProgram = (program, projectRoot) => {
|
|
|
1983
1983
|
}
|
|
1984
1984
|
return analyzed;
|
|
1985
1985
|
};
|
|
1986
|
-
var metadataExpression = (metadata) =>
|
|
1986
|
+
var metadataExpression = (metadata) => lazyTypescript.factory.createObjectLiteralExpression(Object.entries(metadata).map(([key, item]) => lazyTypescript.factory.createPropertyAssignment(lazyTypescript.factory.createStringLiteral(key), lazyTypescript.factory.createStringLiteral(item))), false);
|
|
1987
1987
|
var routeOptions = (existing, metadata) => {
|
|
1988
|
-
const detail =
|
|
1989
|
-
|
|
1988
|
+
const detail = lazyTypescript.factory.createObjectLiteralExpression([
|
|
1989
|
+
lazyTypescript.factory.createPropertyAssignment(lazyTypescript.factory.createStringLiteral(ABSOLUTE_MOBILE_ROUTE_DETAIL), metadataExpression(metadata))
|
|
1990
1990
|
]);
|
|
1991
1991
|
if (!existing) {
|
|
1992
|
-
return
|
|
1993
|
-
|
|
1992
|
+
return lazyTypescript.factory.createObjectLiteralExpression([
|
|
1993
|
+
lazyTypescript.factory.createPropertyAssignment("detail", detail)
|
|
1994
1994
|
]);
|
|
1995
1995
|
}
|
|
1996
|
-
return
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
1996
|
+
return lazyTypescript.factory.createObjectLiteralExpression([
|
|
1997
|
+
lazyTypescript.factory.createSpreadAssignment(existing),
|
|
1998
|
+
lazyTypescript.factory.createPropertyAssignment("detail", lazyTypescript.factory.createObjectLiteralExpression([
|
|
1999
|
+
lazyTypescript.factory.createSpreadAssignment(lazyTypescript.factory.createPropertyAccessExpression(existing, "detail")),
|
|
2000
|
+
lazyTypescript.factory.createPropertyAssignment(lazyTypescript.factory.createStringLiteral(ABSOLUTE_MOBILE_ROUTE_DETAIL), metadataExpression(metadata))
|
|
2001
2001
|
]))
|
|
2002
2002
|
]);
|
|
2003
2003
|
};
|
|
@@ -2008,19 +2008,19 @@ var transformPageCall = (node, page) => {
|
|
|
2008
2008
|
const [pagePath, existingOptions, ...rest] = node.arguments;
|
|
2009
2009
|
if (!pagePath)
|
|
2010
2010
|
return;
|
|
2011
|
-
const options =
|
|
2012
|
-
...existingOptions ? [
|
|
2013
|
-
|
|
2011
|
+
const options = lazyTypescript.factory.createObjectLiteralExpression([
|
|
2012
|
+
...existingOptions ? [lazyTypescript.factory.createSpreadAssignment(existingOptions)] : [],
|
|
2013
|
+
lazyTypescript.factory.createPropertyAssignment("__absoluteMobile", metadataExpression(page.metadata))
|
|
2014
2014
|
]);
|
|
2015
|
-
return
|
|
2015
|
+
return lazyTypescript.factory.updateCallExpression(node, node.expression, node.typeArguments, [pagePath, options, ...rest]);
|
|
2016
2016
|
}
|
|
2017
2017
|
const [input] = node.arguments;
|
|
2018
|
-
if (!input || !
|
|
2018
|
+
if (!input || !lazyTypescript.isObjectLiteralExpression(input))
|
|
2019
2019
|
return;
|
|
2020
|
-
return
|
|
2021
|
-
|
|
2020
|
+
return lazyTypescript.factory.updateCallExpression(node, node.expression, node.typeArguments, [
|
|
2021
|
+
lazyTypescript.factory.updateObjectLiteralExpression(input, [
|
|
2022
2022
|
...input.properties,
|
|
2023
|
-
|
|
2023
|
+
lazyTypescript.factory.createPropertyAssignment("__absoluteMobile", metadataExpression(page.metadata))
|
|
2024
2024
|
]),
|
|
2025
2025
|
...node.arguments.slice(1)
|
|
2026
2026
|
]);
|
|
@@ -2033,16 +2033,16 @@ var transformRouteCall = (node, route) => {
|
|
|
2033
2033
|
return;
|
|
2034
2034
|
const options = maybeHandler ? maybeOptions : undefined;
|
|
2035
2035
|
const handler = maybeHandler ?? maybeOptions;
|
|
2036
|
-
return
|
|
2036
|
+
return lazyTypescript.factory.updateCallExpression(node, node.expression, node.typeArguments, [path, routeOptions(options, route.metadata), handler, ...rest]);
|
|
2037
2037
|
};
|
|
2038
2038
|
var transformFile = (source, fileName, analysis) => {
|
|
2039
|
-
const sourceFile =
|
|
2039
|
+
const sourceFile = lazyTypescript.createSourceFile(fileName, source, lazyTypescript.ScriptTarget.Latest, true, fileName.endsWith("x") ? lazyTypescript.ScriptKind.TSX : lazyTypescript.ScriptKind.TS);
|
|
2040
2040
|
const transformer = (context) => {
|
|
2041
2041
|
const visit = (node) => {
|
|
2042
|
-
if (!
|
|
2043
|
-
return
|
|
2042
|
+
if (!lazyTypescript.isCallExpression(node)) {
|
|
2043
|
+
return lazyTypescript.visitEachChild(node, visit, context);
|
|
2044
2044
|
}
|
|
2045
|
-
const transformedChildren =
|
|
2045
|
+
const transformedChildren = lazyTypescript.visitEachChild(node, visit, context);
|
|
2046
2046
|
const page = analysis.byPageCall.get(node.getStart(sourceFile));
|
|
2047
2047
|
const transformedPage = transformPageCall(transformedChildren, page);
|
|
2048
2048
|
if (transformedPage)
|
|
@@ -2053,14 +2053,14 @@ var transformFile = (source, fileName, analysis) => {
|
|
|
2053
2053
|
return transformedRoute;
|
|
2054
2054
|
return transformedChildren;
|
|
2055
2055
|
};
|
|
2056
|
-
return (node) =>
|
|
2056
|
+
return (node) => lazyTypescript.visitNode(node, visit, lazyTypescript.isSourceFile) ?? node;
|
|
2057
2057
|
};
|
|
2058
|
-
const result =
|
|
2058
|
+
const result = lazyTypescript.transform(sourceFile, [transformer]);
|
|
2059
2059
|
try {
|
|
2060
2060
|
const [transformed] = result.transformed;
|
|
2061
2061
|
if (!transformed)
|
|
2062
2062
|
throw new TypeError("Mobile route transform failed.");
|
|
2063
|
-
return
|
|
2063
|
+
return lazyTypescript.createPrinter().printFile(transformed);
|
|
2064
2064
|
} finally {
|
|
2065
2065
|
result.dispose();
|
|
2066
2066
|
}
|