@absolutejs/absolute 0.20.0-beta.16 → 0.20.0-beta.18
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 +25 -0
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/build.js +35 -3
- package/dist/build.js.map +4 -4
- package/dist/cli/index.js +976 -722
- package/dist/dev/client/hmrClient.ts +9 -3
- package/dist/dev/client/syncDevtools.ts +237 -0
- package/dist/index.js +35 -3
- package/dist/index.js.map +4 -4
- package/dist/mobile/browser.js +110 -1
- package/dist/mobile/browser.js.map +6 -4
- package/dist/mobile/index.js +470 -125
- package/dist/mobile/index.js.map +12 -9
- package/dist/mobile/shellAuth.js +0 -8
- package/dist/mobile/shellSync.js +42 -0
- package/dist/src/mobile/browser.d.ts +1 -0
- package/dist/src/mobile/capacitorBundle.d.ts +4 -0
- package/dist/src/mobile/deviceCapabilities.d.ts +20 -0
- package/dist/src/mobile/index.d.ts +2 -0
- package/dist/src/mobile/syncRemediation.d.ts +10 -0
- package/dist/src/mobile/transport.d.ts +1 -0
- package/package.json +16 -13
package/dist/cli/index.js
CHANGED
|
@@ -5965,16 +5965,49 @@ var MANIFEST_FILE = "absolute-mobile-manifest.json", BOOTSTRAP_FILE = "absolute-
|
|
|
5965
5965
|
throw new TypeError("Mobile page bundle escaped the build directory.");
|
|
5966
5966
|
}
|
|
5967
5967
|
return asset;
|
|
5968
|
-
},
|
|
5968
|
+
}, importEntryTarget = (entry) => {
|
|
5969
|
+
if (typeof entry === "string")
|
|
5970
|
+
return entry;
|
|
5971
|
+
if (typeof entry === "object" && entry !== null)
|
|
5972
|
+
return Reflect.get(entry, "import");
|
|
5973
|
+
return;
|
|
5974
|
+
}, resolveProjectImport = async (projectRoot, specifier) => {
|
|
5975
|
+
const segments = specifier.split("/");
|
|
5976
|
+
const packageName = specifier.startsWith("@") ? segments.slice(0, 2).join("/") : segments[0] ?? "";
|
|
5977
|
+
const subpath = specifier.slice(packageName.length);
|
|
5978
|
+
const packageDirectory = join17(resolve14(projectRoot), "node_modules", packageName);
|
|
5979
|
+
const manifest = JSON.parse(await readFile8(join17(packageDirectory, "package.json"), "utf8"));
|
|
5980
|
+
const exports = typeof manifest === "object" && manifest !== null ? Reflect.get(manifest, "exports") : undefined;
|
|
5981
|
+
const entry = typeof exports === "object" && exports !== null ? Reflect.get(exports, subpath ? `.${subpath}` : ".") : undefined;
|
|
5982
|
+
const target = importEntryTarget(entry);
|
|
5983
|
+
if (typeof target !== "string" || !target.startsWith("./"))
|
|
5984
|
+
throw new TypeError(`${specifier} does not publish an import entry.`);
|
|
5985
|
+
const resolved = resolve14(packageDirectory, target);
|
|
5986
|
+
if (!resolved.startsWith(`${resolve14(packageDirectory)}/`))
|
|
5987
|
+
throw new TypeError(`${specifier} has an unsafe import entry.`);
|
|
5988
|
+
return resolved;
|
|
5989
|
+
}, buildShellBootstrap = async (staging, auth, sync, storagePrefix, deviceCapabilities, projectRoot) => {
|
|
5969
5990
|
const modulePath = shellBootstrapModule();
|
|
5970
5991
|
const authImport = auth ? `import { createAbsoluteMobileShellAuth } from ${JSON.stringify(shellAuthModule())};
|
|
5971
5992
|
` : "";
|
|
5972
5993
|
const options = auth ? `{ createAuth: createAbsoluteMobileShellAuth${sync ? ", installSync: installAbsoluteMobileShellSync" : ""} }` : "";
|
|
5973
5994
|
const syncImport = sync ? `import { installAbsoluteMobileShellSync } from ${JSON.stringify(shellSyncModule())};
|
|
5974
5995
|
` : "";
|
|
5996
|
+
const capabilityImports = (await Promise.all(deviceCapabilities.capabilities.map(async (name, index) => {
|
|
5997
|
+
const provider = deviceCapabilities.providers[name];
|
|
5998
|
+
if (!provider)
|
|
5999
|
+
throw new TypeError(`Missing device capability provider ${name}.`);
|
|
6000
|
+
return `import { ${provider.factory} as absoluteDeviceCapability${index} } from ${JSON.stringify(await resolveProjectImport(projectRoot, provider.module))};`;
|
|
6001
|
+
}))).join(`
|
|
6002
|
+
`);
|
|
6003
|
+
const capabilityOptions = deviceCapabilities.capabilities.map((name, index) => `${JSON.stringify(name)}: absoluteDeviceCapability${index}()`).join(", ");
|
|
5975
6004
|
const entryPath = join17(staging, ".absolute-mobile-entry.ts");
|
|
6005
|
+
const baseAdapterModule = await resolveProjectImport(projectRoot, "@absolutejs/devices-capacitor");
|
|
5976
6006
|
await writeFile7(entryPath, `import { startAbsoluteMobileShell } from ${JSON.stringify(modulePath)};
|
|
5977
|
-
|
|
6007
|
+
import { installCapacitorDeviceAdapterIfNative } from ${JSON.stringify(baseAdapterModule)};
|
|
6008
|
+
${authImport}${syncImport}${capabilityImports}
|
|
6009
|
+
installCapacitorDeviceAdapterIfNative({ storagePrefix: ${JSON.stringify(storagePrefix)}${capabilityOptions ? `, ${capabilityOptions}` : ""} });
|
|
6010
|
+
void startAbsoluteMobileShell(${options});
|
|
5978
6011
|
`);
|
|
5979
6012
|
const build = await Bun.build({
|
|
5980
6013
|
entrypoints: [entryPath],
|
|
@@ -6104,6 +6137,7 @@ ${authImport}${syncImport}void startAbsoluteMobileShell(${options});
|
|
|
6104
6137
|
appName: options.config.appName,
|
|
6105
6138
|
deepLinkHosts: options.config.deepLinkHosts,
|
|
6106
6139
|
deepLinkScheme: options.config.deepLinkScheme,
|
|
6140
|
+
deviceCapabilities: options.deviceCapabilities.capabilities,
|
|
6107
6141
|
entry: options.config.entry,
|
|
6108
6142
|
format: ABSOLUTE_MOBILE_CLIENT_MANIFEST_FORMAT,
|
|
6109
6143
|
pages,
|
|
@@ -6129,7 +6163,7 @@ ${authImport}${syncImport}void startAbsoluteMobileShell(${options});
|
|
|
6129
6163
|
writeFile7(join17(staging, MANIFEST_FILE), `${JSON.stringify(manifest, null, "\t")}
|
|
6130
6164
|
`),
|
|
6131
6165
|
writeFile7(join17(staging, INDEX_FILE), indexHtml(options.config.appName)),
|
|
6132
|
-
buildShellBootstrap(staging, options.auth !== undefined, options.auth !== undefined && options.sync === true)
|
|
6166
|
+
buildShellBootstrap(staging, options.auth !== undefined, options.auth !== undefined && options.sync === true, `absolutejs.${options.auth?.clientId ?? options.config.appId}.`, options.deviceCapabilities, options.projectRoot)
|
|
6133
6167
|
]);
|
|
6134
6168
|
await installBundle(staging, destination);
|
|
6135
6169
|
return manifest;
|
|
@@ -6304,7 +6338,7 @@ var init_materializedBundle = __esm(() => {
|
|
|
6304
6338
|
});
|
|
6305
6339
|
|
|
6306
6340
|
// node_modules/@absolutejs/sync/dist/client/index.js
|
|
6307
|
-
var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations")), registry, SyncLocalDataPolicyError, SyncLocalStoreSchemaError, positiveVersion = (value, label) => {
|
|
6341
|
+
var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations")) && Array.isArray(Reflect.get(value, "clients")), registry, SyncLocalDataPolicyError, SyncLocalStoreSchemaError, positiveVersion = (value, label) => {
|
|
6308
6342
|
if (!Number.isSafeInteger(value) || value < 1)
|
|
6309
6343
|
throw new SyncLocalStoreSchemaError("INVALID_PLAN", `${label} must be a positive safe integer`);
|
|
6310
6344
|
return value;
|
|
@@ -6325,6 +6359,12 @@ var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" &
|
|
|
6325
6359
|
}
|
|
6326
6360
|
for (const [index, rule] of (policy.mutations ?? []).entries()) {
|
|
6327
6361
|
validatePolicyMatch(rule.match, `${label}.mutations[${index}]`);
|
|
6362
|
+
if (rule.conflict !== undefined && rule.conflict.strategy !== "client-wins" && rule.conflict.strategy !== "manual" && rule.conflict.strategy !== "server-wins")
|
|
6363
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}].conflict.strategy is invalid.`);
|
|
6364
|
+
if (rule.conflict?.maxAttempts !== undefined && (!Number.isSafeInteger(rule.conflict.maxAttempts) || rule.conflict.maxAttempts < 1))
|
|
6365
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}].conflict.maxAttempts must be a positive safe integer.`);
|
|
6366
|
+
if (rule.conflict?.maxAttempts !== undefined && rule.conflict.strategy !== "client-wins")
|
|
6367
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}].conflict.maxAttempts is only valid for client-wins.`);
|
|
6328
6368
|
if (rule.persistence === "memory-only" && rule.protection === "required")
|
|
6329
6369
|
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}] cannot require at-rest protection when it is memory-only.`);
|
|
6330
6370
|
if (rule.sensitivity !== undefined && rule.sensitivity !== "public" && rule.protection !== "required" && rule.persistence !== "memory-only")
|
|
@@ -6390,7 +6430,11 @@ var init_client2 = __esm(() => {
|
|
|
6390
6430
|
const existing = host[RUNTIME_TRANSPORT];
|
|
6391
6431
|
if (isRegistry(existing))
|
|
6392
6432
|
return existing;
|
|
6393
|
-
|
|
6433
|
+
if (typeof existing === "object" && existing !== null && Array.isArray(Reflect.get(existing, "installations"))) {
|
|
6434
|
+
Reflect.set(existing, "clients", []);
|
|
6435
|
+
return existing;
|
|
6436
|
+
}
|
|
6437
|
+
const created = { clients: [], installations: [] };
|
|
6394
6438
|
Object.defineProperty(host, RUNTIME_TRANSPORT, {
|
|
6395
6439
|
configurable: false,
|
|
6396
6440
|
enumerable: false,
|
|
@@ -6578,6 +6622,7 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
|
|
|
6578
6622
|
const mutations = Array.isArray(mutationRules) ? mutationRules.map((entry, index) => {
|
|
6579
6623
|
const rule = requireObject(entry, id, `localData.mutations[${index}] must be an object.`);
|
|
6580
6624
|
const allowedRuleKeys = new Set([
|
|
6625
|
+
"conflict",
|
|
6581
6626
|
"match",
|
|
6582
6627
|
"onProtectionUnavailable",
|
|
6583
6628
|
"persistence",
|
|
@@ -6591,6 +6636,26 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
|
|
|
6591
6636
|
const sensitivity = unknownField(rule, "sensitivity");
|
|
6592
6637
|
const persistence = unknownField(rule, "persistence");
|
|
6593
6638
|
const onProtectionUnavailable = unknownField(rule, "onProtectionUnavailable");
|
|
6639
|
+
const declaredConflict = unknownField(rule, "conflict");
|
|
6640
|
+
let conflict;
|
|
6641
|
+
if (declaredConflict !== undefined) {
|
|
6642
|
+
const conflictRecord = requireObject(declaredConflict, id, `localData.mutations[${index}].conflict must be an object.`);
|
|
6643
|
+
const unsupportedConflictKey = Object.keys(conflictRecord).find((key) => key !== "maxAttempts" && key !== "strategy");
|
|
6644
|
+
if (unsupportedConflictKey)
|
|
6645
|
+
throw metadataError(id, `localData.mutations[${index}].conflict.${unsupportedConflictKey} is not supported.`);
|
|
6646
|
+
const strategy = unknownField(conflictRecord, "strategy");
|
|
6647
|
+
if (strategy !== "client-wins" && strategy !== "manual" && strategy !== "server-wins")
|
|
6648
|
+
throw metadataError(id, `localData.mutations[${index}].conflict.strategy is invalid.`);
|
|
6649
|
+
const maxAttempts = unknownField(conflictRecord, "maxAttempts");
|
|
6650
|
+
if (maxAttempts !== undefined && strategy !== "client-wins")
|
|
6651
|
+
throw metadataError(id, `localData.mutations[${index}].conflict.maxAttempts requires client-wins.`);
|
|
6652
|
+
conflict = {
|
|
6653
|
+
strategy,
|
|
6654
|
+
...maxAttempts === undefined ? {} : {
|
|
6655
|
+
maxAttempts: positiveVersion2(maxAttempts, id, `localData.mutations[${index}].conflict.maxAttempts`)
|
|
6656
|
+
}
|
|
6657
|
+
};
|
|
6658
|
+
}
|
|
6594
6659
|
if (protection !== undefined && protection !== "none" && protection !== "required")
|
|
6595
6660
|
throw metadataError(id, `localData.mutations[${index}].protection is invalid.`);
|
|
6596
6661
|
if (sensitivity !== undefined && sensitivity !== "public" && sensitivity !== "private" && sensitivity !== "secret")
|
|
@@ -6601,6 +6666,7 @@ var object = (value) => typeof value === "object" && value !== null && !Array.is
|
|
|
6601
6666
|
throw metadataError(id, `localData.mutations[${index}].persistence is invalid.`);
|
|
6602
6667
|
return {
|
|
6603
6668
|
match: nonEmpty(Reflect.get(rule, "match"), id, `localData.mutations[${index}].match`),
|
|
6669
|
+
...conflict ? { conflict } : {},
|
|
6604
6670
|
...sensitivity ? { sensitivity } : {},
|
|
6605
6671
|
...onProtectionUnavailable ? { onProtectionUnavailable } : {},
|
|
6606
6672
|
...persistence ? {
|
|
@@ -6693,9 +6759,154 @@ var init_syncSchema = __esm(() => {
|
|
|
6693
6759
|
init_client2();
|
|
6694
6760
|
});
|
|
6695
6761
|
|
|
6762
|
+
// src/mobile/deviceCapabilities.ts
|
|
6763
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
6764
|
+
import { extname as extname5, join as join20, relative as relative11, resolve as resolve16 } from "path";
|
|
6765
|
+
import ts4 from "typescript";
|
|
6766
|
+
var DEVICES_PACKAGE = "@absolutejs/devices", CAPACITOR_ADAPTER = "@absolutejs/devices-capacitor", SOURCE_GLOB, IGNORED_DIRECTORIES, IDENTIFIER_PATTERN, CAPACITOR_MODULE_PATTERN, CAPACITOR_PACKAGE_PATTERN, object2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), readJson = (path) => {
|
|
6767
|
+
const value = JSON.parse(readFileSync12(path, "utf8"));
|
|
6768
|
+
if (!object2(value))
|
|
6769
|
+
throw new TypeError(`${path} must contain an object.`);
|
|
6770
|
+
return value;
|
|
6771
|
+
}, text = (value, field) => {
|
|
6772
|
+
if (typeof value !== "string" || value.length === 0)
|
|
6773
|
+
throw new TypeError(`${field} must be a non-empty string.`);
|
|
6774
|
+
return value;
|
|
6775
|
+
}, parseProvider = (name, value) => {
|
|
6776
|
+
if (!IDENTIFIER_PATTERN.test(name))
|
|
6777
|
+
throw new TypeError("Device capability names must be identifiers.");
|
|
6778
|
+
if (!object2(value))
|
|
6779
|
+
throw new TypeError(`Device capability ${name} must be an object.`);
|
|
6780
|
+
const factory = text(value.factory, `${name}.factory`);
|
|
6781
|
+
const module = text(value.module, `${name}.module`);
|
|
6782
|
+
if (!IDENTIFIER_PATTERN.test(factory))
|
|
6783
|
+
throw new TypeError(`${name}.factory must be a JavaScript identifier.`);
|
|
6784
|
+
if (!CAPACITOR_MODULE_PATTERN.test(module))
|
|
6785
|
+
throw new TypeError(`${name}.module must be an official devices-capacitor subpath.`);
|
|
6786
|
+
if (!Array.isArray(value.packages) || !value.packages.every((spec) => typeof spec === "string" && CAPACITOR_PACKAGE_PATTERN.test(spec)))
|
|
6787
|
+
throw new TypeError(`${name}.packages must contain exact official Capacitor package versions.`);
|
|
6788
|
+
return { factory, module, packages: [...value.packages] };
|
|
6789
|
+
}, loadAbsoluteDeviceCapabilityProviders = (projectRoot) => {
|
|
6790
|
+
const path = join20(resolve16(projectRoot), "node_modules", CAPACITOR_ADAPTER, "package.json");
|
|
6791
|
+
const manifest = readJson(path);
|
|
6792
|
+
const { absolutejs } = manifest;
|
|
6793
|
+
const devices = object2(absolutejs) ? absolutejs.devices : undefined;
|
|
6794
|
+
if (!object2(devices) || devices.format !== 1 || devices.provider !== "capacitor" || !object2(devices.capabilities))
|
|
6795
|
+
throw new TypeError(`${CAPACITOR_ADAPTER} does not publish supported capability metadata.`);
|
|
6796
|
+
const entries = Object.entries(devices.capabilities).map(([name, provider]) => ({
|
|
6797
|
+
name,
|
|
6798
|
+
provider: parseProvider(name, provider)
|
|
6799
|
+
}));
|
|
6800
|
+
return Object.fromEntries(entries.sort((left, right) => left.name.localeCompare(right.name)).map(({ name, provider }) => [name, provider]));
|
|
6801
|
+
}, isIgnored2 = (path) => path.split("/").some((segment) => IGNORED_DIRECTORIES.has(segment)), importedCapabilities = (source, file) => {
|
|
6802
|
+
const names = new Set;
|
|
6803
|
+
const namespaces = new Set;
|
|
6804
|
+
const visit = (node) => {
|
|
6805
|
+
if (ts4.isImportDeclaration(node) && ts4.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text === DEVICES_PACKAGE && !node.importClause?.isTypeOnly) {
|
|
6806
|
+
const bindings = node.importClause?.namedBindings;
|
|
6807
|
+
if (bindings && ts4.isNamedImports(bindings)) {
|
|
6808
|
+
for (const element of bindings.elements)
|
|
6809
|
+
if (!element.isTypeOnly)
|
|
6810
|
+
names.add((element.propertyName ?? element.name).text);
|
|
6811
|
+
}
|
|
6812
|
+
if (bindings && ts4.isNamespaceImport(bindings))
|
|
6813
|
+
namespaces.add(bindings.name.text);
|
|
6814
|
+
}
|
|
6815
|
+
if (ts4.isExportDeclaration(node) && !node.isTypeOnly && node.moduleSpecifier !== undefined && ts4.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text === DEVICES_PACKAGE && node.exportClause && ts4.isNamedExports(node.exportClause)) {
|
|
6816
|
+
for (const element of node.exportClause.elements)
|
|
6817
|
+
if (!element.isTypeOnly)
|
|
6818
|
+
names.add((element.propertyName ?? element.name).text);
|
|
6819
|
+
}
|
|
6820
|
+
if (ts4.isPropertyAccessExpression(node) && ts4.isIdentifier(node.expression) && namespaces.has(node.expression.text))
|
|
6821
|
+
names.add(node.name.text);
|
|
6822
|
+
ts4.forEachChild(node, visit);
|
|
6823
|
+
};
|
|
6824
|
+
const extension = extname5(file).toLowerCase();
|
|
6825
|
+
const sources = extension === ".svelte" || extension === ".vue" ? [...source.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script\s*>/giu)].map((match) => match[1]).filter((value) => value !== undefined) : [source];
|
|
6826
|
+
for (const [index, script] of sources.entries())
|
|
6827
|
+
visit(ts4.createSourceFile(`${file}#script-${index}`, script, ts4.ScriptTarget.Latest, true, ts4.ScriptKind.TSX));
|
|
6828
|
+
return names;
|
|
6829
|
+
}, assertAbsoluteDeviceCapabilityPackages = (projectRoot, plan) => {
|
|
6830
|
+
const missing = missingAbsoluteDeviceCapabilityPackages(plan, directAbsoluteProjectPackages(projectRoot));
|
|
6831
|
+
const mismatched = plan.requiredPackages.filter((spec) => {
|
|
6832
|
+
const separator = spec.lastIndexOf("@");
|
|
6833
|
+
const packageName = spec.slice(0, separator);
|
|
6834
|
+
if (missing.includes(spec))
|
|
6835
|
+
return false;
|
|
6836
|
+
try {
|
|
6837
|
+
return readJson(join20(resolve16(projectRoot), "node_modules", packageName, "package.json")).version !== spec.slice(separator + 1);
|
|
6838
|
+
} catch {
|
|
6839
|
+
return true;
|
|
6840
|
+
}
|
|
6841
|
+
});
|
|
6842
|
+
const unmet = [...missing, ...mismatched];
|
|
6843
|
+
if (unmet.length > 0)
|
|
6844
|
+
throw new TypeError(`Device capabilities ${plan.capabilities.join(", ")} require ${unmet.join(", ")}. Run absolute mobile sync and approve the detected capability plugins.`);
|
|
6845
|
+
}, directAbsoluteProjectPackages = (projectRoot) => {
|
|
6846
|
+
const manifest = readJson(join20(resolve16(projectRoot), "package.json"));
|
|
6847
|
+
const packages = new Set;
|
|
6848
|
+
for (const field of ["dependencies", "devDependencies"]) {
|
|
6849
|
+
const dependencies = manifest[field];
|
|
6850
|
+
if (object2(dependencies))
|
|
6851
|
+
for (const name of Object.keys(dependencies))
|
|
6852
|
+
packages.add(name);
|
|
6853
|
+
}
|
|
6854
|
+
return packages;
|
|
6855
|
+
}, discoverAbsoluteDeviceCapabilities = (projectRoot, providers = loadAbsoluteDeviceCapabilityProviders(projectRoot)) => {
|
|
6856
|
+
const root = resolve16(projectRoot);
|
|
6857
|
+
const known = new Set(Object.keys(providers));
|
|
6858
|
+
const capabilities = new Set;
|
|
6859
|
+
for (const path of SOURCE_GLOB.scanSync({ cwd: root })) {
|
|
6860
|
+
const portable = relative11(root, resolve16(root, path)).replaceAll("\\", "/");
|
|
6861
|
+
if (isIgnored2(portable))
|
|
6862
|
+
continue;
|
|
6863
|
+
const source = readFileSync12(resolve16(root, portable), "utf8");
|
|
6864
|
+
for (const name of importedCapabilities(source, portable))
|
|
6865
|
+
if (known.has(name))
|
|
6866
|
+
capabilities.add(name);
|
|
6867
|
+
}
|
|
6868
|
+
return [...capabilities].sort();
|
|
6869
|
+
}, missingAbsoluteDeviceCapabilityPackages = (plan, directPackages) => plan.requiredPackages.filter((spec) => {
|
|
6870
|
+
const packageName = spec.slice(0, spec.lastIndexOf("@"));
|
|
6871
|
+
return !directPackages.has(packageName);
|
|
6872
|
+
}), resolveAbsoluteDeviceCapabilityPlan = (projectRoot) => {
|
|
6873
|
+
const allProviders = loadAbsoluteDeviceCapabilityProviders(projectRoot);
|
|
6874
|
+
const capabilities = discoverAbsoluteDeviceCapabilities(projectRoot, allProviders);
|
|
6875
|
+
const providers = {};
|
|
6876
|
+
for (const name of capabilities) {
|
|
6877
|
+
const provider = allProviders[name];
|
|
6878
|
+
if (provider)
|
|
6879
|
+
providers[name] = provider;
|
|
6880
|
+
}
|
|
6881
|
+
return {
|
|
6882
|
+
capabilities,
|
|
6883
|
+
providers,
|
|
6884
|
+
requiredPackages: [
|
|
6885
|
+
...new Set(capabilities.flatMap((name) => providers[name]?.packages ?? []))
|
|
6886
|
+
].sort()
|
|
6887
|
+
};
|
|
6888
|
+
};
|
|
6889
|
+
var init_deviceCapabilities = __esm(() => {
|
|
6890
|
+
SOURCE_GLOB = new Bun.Glob("**/*.{js,jsx,ts,tsx,svelte,vue}");
|
|
6891
|
+
IGNORED_DIRECTORIES = new Set([
|
|
6892
|
+
".absolutejs",
|
|
6893
|
+
".git",
|
|
6894
|
+
".test-builds",
|
|
6895
|
+
".test-shards",
|
|
6896
|
+
"build",
|
|
6897
|
+
"dist",
|
|
6898
|
+
"node_modules",
|
|
6899
|
+
"test",
|
|
6900
|
+
"tests"
|
|
6901
|
+
]);
|
|
6902
|
+
IDENTIFIER_PATTERN = /^[A-Za-z_$][\w$]*$/u;
|
|
6903
|
+
CAPACITOR_MODULE_PATTERN = /^@absolutejs\/devices-capacitor\/[a-z][a-z0-9-]*$/u;
|
|
6904
|
+
CAPACITOR_PACKAGE_PATTERN = /^@capacitor\/[a-z][a-z0-9-]*@\d+\.\d+\.\d+$/u;
|
|
6905
|
+
});
|
|
6906
|
+
|
|
6696
6907
|
// src/mobile/buildPipeline.ts
|
|
6697
6908
|
import { readFile as readFile10 } from "fs/promises";
|
|
6698
|
-
import { join as
|
|
6909
|
+
import { join as join21, resolve as resolve17 } from "path";
|
|
6699
6910
|
import { pathToFileURL } from "url";
|
|
6700
6911
|
var isElysiaApp = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "compile") === "function" && Array.isArray(Reflect.get(value, "routes")), isStringRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((entry) => typeof entry === "string"), serverExportName = (loaded, app) => {
|
|
6701
6912
|
if (loaded.server === app)
|
|
@@ -6724,11 +6935,11 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6724
6935
|
const exportName = serverExportName(loaded, app);
|
|
6725
6936
|
return { app, exportName };
|
|
6726
6937
|
}, finalizeAbsoluteMobileCompatibilityBuild = async (options) => {
|
|
6727
|
-
const buildDirectory =
|
|
6938
|
+
const buildDirectory = resolve17(options.buildDirectory);
|
|
6728
6939
|
const mobile = normalizeAbsoluteMobileConfig(options.mobile, options.projectRoot);
|
|
6729
|
-
const root =
|
|
6940
|
+
const root = join21(buildDirectory, ".absolutejs", "mobile-compatibility");
|
|
6730
6941
|
const [manifestSource, previous] = await Promise.all([
|
|
6731
|
-
readFile10(
|
|
6942
|
+
readFile10(join21(buildDirectory, "manifest.json"), "utf8"),
|
|
6732
6943
|
readAbsoluteMobileMaterializedReleases(root)
|
|
6733
6944
|
]);
|
|
6734
6945
|
const manifest = JSON.parse(manifestSource);
|
|
@@ -6741,11 +6952,11 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6741
6952
|
process.env.ABSOLUTE_BUILD_DIR = buildDirectory;
|
|
6742
6953
|
process.env.ABSOLUTE_COMPILED_RUNTIME = "1";
|
|
6743
6954
|
if (options.configPath) {
|
|
6744
|
-
process.env.ABSOLUTE_CONFIG =
|
|
6955
|
+
process.env.ABSOLUTE_CONFIG = resolve17(options.projectRoot, options.configPath);
|
|
6745
6956
|
}
|
|
6746
6957
|
let loaded;
|
|
6747
6958
|
try {
|
|
6748
|
-
loaded = await loadServerApp(
|
|
6959
|
+
loaded = await loadServerApp(resolve17(options.producerPath));
|
|
6749
6960
|
} finally {
|
|
6750
6961
|
restoreEnvironmentVariable("ABSOLUTE_BUILD_DIR", previousBuildDirectory);
|
|
6751
6962
|
restoreEnvironmentVariable("ABSOLUTE_COMPILED_RUNTIME", previousCompiledRuntime);
|
|
@@ -6758,12 +6969,14 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6758
6969
|
manifest,
|
|
6759
6970
|
previousArtifacts: previous.map(({ artifact }) => artifact),
|
|
6760
6971
|
producerExport: loaded.exportName,
|
|
6761
|
-
producerPath:
|
|
6972
|
+
producerPath: resolve17(options.producerPath),
|
|
6762
6973
|
runtime: String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)
|
|
6763
6974
|
});
|
|
6764
6975
|
const auth = resolveAbsoluteMobileAuthManifest(options.projectRoot, mobile);
|
|
6765
6976
|
const sync = auth !== undefined && projectUsesAbsoluteSync(options.projectRoot);
|
|
6766
6977
|
const syncSchema = sync ? discoverAbsoluteSyncSchema(options.projectRoot) : undefined;
|
|
6978
|
+
const deviceCapabilities = resolveAbsoluteDeviceCapabilityPlan(options.projectRoot);
|
|
6979
|
+
assertAbsoluteDeviceCapabilityPackages(options.projectRoot, deviceCapabilities);
|
|
6767
6980
|
if (auth && !loaded.app.routes.some((route) => route.path === "/.well-known/openid-configuration")) {
|
|
6768
6981
|
throw new TypeError("@absolutejs/auth is installed, but its OIDC provider is not mounted. Native authentication requires the auth oidc configuration so AbsoluteJS can provision a public PKCE client.");
|
|
6769
6982
|
}
|
|
@@ -6782,6 +6995,8 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6782
6995
|
...auth ? { auth } : {},
|
|
6783
6996
|
buildDirectory,
|
|
6784
6997
|
config: mobile,
|
|
6998
|
+
deviceCapabilities,
|
|
6999
|
+
projectRoot: options.projectRoot,
|
|
6785
7000
|
...sync ? { sync: true } : {},
|
|
6786
7001
|
...syncSchema ? { syncSchema: { components: syncSchema.components } } : {}
|
|
6787
7002
|
});
|
|
@@ -6796,62 +7011,63 @@ var init_buildPipeline = __esm(() => {
|
|
|
6796
7011
|
init_releaseArtifact();
|
|
6797
7012
|
init_nativeAuth();
|
|
6798
7013
|
init_syncSchema();
|
|
7014
|
+
init_deviceCapabilities();
|
|
6799
7015
|
});
|
|
6800
7016
|
|
|
6801
7017
|
// src/mobile/routeMetadataTransform.ts
|
|
6802
|
-
import { existsSync as existsSync10, readFileSync as
|
|
6803
|
-
import { dirname as dirname13, extname as
|
|
6804
|
-
import
|
|
6805
|
-
var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.replace(/\\/g, "/"), findTsconfig = (entry, projectRoot) =>
|
|
7018
|
+
import { existsSync as existsSync10, readFileSync as readFileSync13 } from "fs";
|
|
7019
|
+
import { dirname as dirname13, extname as extname6, relative as relative12, resolve as resolve18 } from "path";
|
|
7020
|
+
import ts5 from "typescript";
|
|
7021
|
+
var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.replace(/\\/g, "/"), findTsconfig = (entry, projectRoot) => ts5.findConfigFile(dirname13(entry), existsSync10, "tsconfig.json") ?? ts5.findConfigFile(projectRoot, existsSync10, "tsconfig.json"), createProgram = (entry, projectRoot) => {
|
|
6806
7022
|
const configPath2 = findTsconfig(entry, projectRoot);
|
|
6807
7023
|
if (!configPath2) {
|
|
6808
|
-
return
|
|
7024
|
+
return ts5.createProgram([entry], {
|
|
6809
7025
|
allowJs: true,
|
|
6810
|
-
jsx:
|
|
6811
|
-
module:
|
|
6812
|
-
moduleResolution:
|
|
6813
|
-
target:
|
|
7026
|
+
jsx: ts5.JsxEmit.ReactJSX,
|
|
7027
|
+
module: ts5.ModuleKind.ESNext,
|
|
7028
|
+
moduleResolution: ts5.ModuleResolutionKind.Bundler,
|
|
7029
|
+
target: ts5.ScriptTarget.ESNext
|
|
6814
7030
|
});
|
|
6815
7031
|
}
|
|
6816
|
-
const parsed =
|
|
7032
|
+
const parsed = ts5.parseJsonConfigFileContent(ts5.readConfigFile(configPath2, (path) => readFileSync13(path, "utf8")).config, ts5.sys, dirname13(configPath2));
|
|
6817
7033
|
if (!parsed.fileNames.includes(entry))
|
|
6818
7034
|
parsed.fileNames.push(entry);
|
|
6819
|
-
return
|
|
7035
|
+
return ts5.createProgram(parsed.fileNames, parsed.options);
|
|
6820
7036
|
}, propertyName = (property) => {
|
|
6821
7037
|
if (!("name" in property) || !property.name)
|
|
6822
7038
|
return;
|
|
6823
|
-
if (
|
|
7039
|
+
if (ts5.isIdentifier(property.name))
|
|
6824
7040
|
return property.name.text;
|
|
6825
|
-
if (
|
|
7041
|
+
if (ts5.isStringLiteralLike(property.name))
|
|
6826
7042
|
return property.name.text;
|
|
6827
7043
|
return;
|
|
6828
|
-
}, objectPropertyExpression = (
|
|
6829
|
-
const property =
|
|
6830
|
-
if (property &&
|
|
7044
|
+
}, objectPropertyExpression = (object3, name) => {
|
|
7045
|
+
const property = object3.properties.find((candidate) => propertyName(candidate) === name);
|
|
7046
|
+
if (property && ts5.isPropertyAssignment(property)) {
|
|
6831
7047
|
return property.initializer;
|
|
6832
7048
|
}
|
|
6833
|
-
if (property &&
|
|
7049
|
+
if (property && ts5.isShorthandPropertyAssignment(property)) {
|
|
6834
7050
|
return property.name;
|
|
6835
7051
|
}
|
|
6836
7052
|
return;
|
|
6837
7053
|
}, serializeType = (type, checker, ancestors = new Set) => {
|
|
6838
|
-
if (type.flags &
|
|
7054
|
+
if (type.flags & ts5.TypeFlags.Any)
|
|
6839
7055
|
return { type: "any" };
|
|
6840
|
-
if (type.flags &
|
|
7056
|
+
if (type.flags & ts5.TypeFlags.Unknown)
|
|
6841
7057
|
return { type: "unknown" };
|
|
6842
|
-
if (type.flags &
|
|
7058
|
+
if (type.flags & ts5.TypeFlags.Never)
|
|
6843
7059
|
return { type: "never" };
|
|
6844
|
-
if (type.flags &
|
|
7060
|
+
if (type.flags & ts5.TypeFlags.StringLike)
|
|
6845
7061
|
return { type: "string" };
|
|
6846
|
-
if (type.flags &
|
|
7062
|
+
if (type.flags & ts5.TypeFlags.NumberLike)
|
|
6847
7063
|
return { type: "number" };
|
|
6848
|
-
if (type.flags &
|
|
7064
|
+
if (type.flags & ts5.TypeFlags.BooleanLike)
|
|
6849
7065
|
return { type: "boolean" };
|
|
6850
|
-
if (type.flags &
|
|
7066
|
+
if (type.flags & ts5.TypeFlags.BigIntLike)
|
|
6851
7067
|
return { type: "bigint" };
|
|
6852
|
-
if (type.flags &
|
|
7068
|
+
if (type.flags & ts5.TypeFlags.Null)
|
|
6853
7069
|
return { type: "null" };
|
|
6854
|
-
if (type.flags &
|
|
7070
|
+
if (type.flags & ts5.TypeFlags.Undefined)
|
|
6855
7071
|
return { type: "undefined" };
|
|
6856
7072
|
if (type.isUnion()) {
|
|
6857
7073
|
return {
|
|
@@ -6865,11 +7081,11 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6865
7081
|
}
|
|
6866
7082
|
if (ancestors.has(type)) {
|
|
6867
7083
|
return {
|
|
6868
|
-
ref: checker.typeToString(type, undefined,
|
|
7084
|
+
ref: checker.typeToString(type, undefined, ts5.TypeFormatFlags.NoTruncation)
|
|
6869
7085
|
};
|
|
6870
7086
|
}
|
|
6871
7087
|
ancestors.add(type);
|
|
6872
|
-
const arrayElement = checker.getIndexTypeOfType(type,
|
|
7088
|
+
const arrayElement = checker.getIndexTypeOfType(type, ts5.IndexKind.Number);
|
|
6873
7089
|
const properties = checker.getPropertiesOfType(type);
|
|
6874
7090
|
let schema;
|
|
6875
7091
|
if (arrayElement && properties.some(({ name }) => name === "length")) {
|
|
@@ -6884,7 +7100,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6884
7100
|
return [
|
|
6885
7101
|
property.name,
|
|
6886
7102
|
{
|
|
6887
|
-
optional: Boolean(property.flags &
|
|
7103
|
+
optional: Boolean(property.flags & ts5.SymbolFlags.Optional),
|
|
6888
7104
|
schema: serializeType(propertyType, checker, ancestors)
|
|
6889
7105
|
}
|
|
6890
7106
|
];
|
|
@@ -6892,7 +7108,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6892
7108
|
schema = { properties: Object.fromEntries(entries), type: "object" };
|
|
6893
7109
|
} else {
|
|
6894
7110
|
schema = {
|
|
6895
|
-
type: checker.typeToString(type, undefined,
|
|
7111
|
+
type: checker.typeToString(type, undefined, ts5.TypeFormatFlags.NoTruncation)
|
|
6896
7112
|
};
|
|
6897
7113
|
}
|
|
6898
7114
|
ancestors.delete(type);
|
|
@@ -6908,23 +7124,23 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6908
7124
|
return propsExpression ? checker.getTypeAtLocation(propsExpression) : checker.getTypeAtLocation(pageExpression);
|
|
6909
7125
|
}, resolvePageIdentity = (expression, sourceFile, checker, projectRoot) => {
|
|
6910
7126
|
let symbol = checker.getSymbolAtLocation(expression);
|
|
6911
|
-
if (symbol?.flags && symbol.flags &
|
|
7127
|
+
if (symbol?.flags && symbol.flags & ts5.SymbolFlags.Alias) {
|
|
6912
7128
|
symbol = checker.getAliasedSymbol(symbol);
|
|
6913
7129
|
}
|
|
6914
7130
|
const declaration = symbol?.declarations?.[0];
|
|
6915
7131
|
const file = declaration?.getSourceFile().fileName ?? sourceFile.fileName;
|
|
6916
7132
|
const exportedName = symbol?.name ?? expression.getText(sourceFile);
|
|
6917
|
-
const source = posixPath(
|
|
7133
|
+
const source = posixPath(relative12(projectRoot, file));
|
|
6918
7134
|
return `${source}#${exportedName}`;
|
|
6919
7135
|
}, resolveAlias = (symbol, checker) => {
|
|
6920
|
-
if (!(symbol.flags &
|
|
7136
|
+
if (!(symbol.flags & ts5.SymbolFlags.Alias))
|
|
6921
7137
|
return symbol;
|
|
6922
7138
|
return checker.getAliasedSymbol(symbol);
|
|
6923
7139
|
}, assetKey = (expression, checker, seen = new Set) => {
|
|
6924
7140
|
if (!expression)
|
|
6925
7141
|
return;
|
|
6926
|
-
if (
|
|
6927
|
-
const unresolved =
|
|
7142
|
+
if (ts5.isIdentifier(expression)) {
|
|
7143
|
+
const unresolved = ts5.isShorthandPropertyAssignment(expression.parent) ? checker.getShorthandAssignmentValueSymbol(expression.parent) : checker.getSymbolAtLocation(expression);
|
|
6928
7144
|
if (!unresolved)
|
|
6929
7145
|
return;
|
|
6930
7146
|
const symbol = resolveAlias(unresolved, checker);
|
|
@@ -6932,25 +7148,25 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6932
7148
|
return;
|
|
6933
7149
|
seen.add(symbol);
|
|
6934
7150
|
const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
6935
|
-
if (!declaration || !
|
|
7151
|
+
if (!declaration || !ts5.isVariableDeclaration(declaration))
|
|
6936
7152
|
return;
|
|
6937
7153
|
return assetKey(declaration.initializer, checker, seen);
|
|
6938
7154
|
}
|
|
6939
|
-
if (!
|
|
7155
|
+
if (!ts5.isCallExpression(expression))
|
|
6940
7156
|
return;
|
|
6941
|
-
if (!
|
|
7157
|
+
if (!ts5.isIdentifier(expression.expression) || expression.expression.text !== "asset") {
|
|
6942
7158
|
return;
|
|
6943
7159
|
}
|
|
6944
7160
|
const [, key] = expression.arguments;
|
|
6945
|
-
return key &&
|
|
7161
|
+
return key && ts5.isStringLiteralLike(key) ? key.text : undefined;
|
|
6946
7162
|
}, staticString = (expression, bindings) => {
|
|
6947
|
-
if (
|
|
7163
|
+
if (ts5.isStringLiteralLike(expression))
|
|
6948
7164
|
return expression.text;
|
|
6949
|
-
if (
|
|
7165
|
+
if (ts5.isIdentifier(expression))
|
|
6950
7166
|
return bindings.get(expression.text);
|
|
6951
|
-
if (
|
|
7167
|
+
if (ts5.isNoSubstitutionTemplateLiteral(expression))
|
|
6952
7168
|
return expression.text;
|
|
6953
|
-
if (!
|
|
7169
|
+
if (!ts5.isTemplateExpression(expression))
|
|
6954
7170
|
return;
|
|
6955
7171
|
let value = expression.head.text;
|
|
6956
7172
|
for (const span of expression.templateSpans) {
|
|
@@ -6963,7 +7179,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6963
7179
|
}, assetKeyWithBindings = (expression, checker, bindings = new Map) => {
|
|
6964
7180
|
if (!expression)
|
|
6965
7181
|
return;
|
|
6966
|
-
if (
|
|
7182
|
+
if (ts5.isCallExpression(expression) && ts5.isIdentifier(expression.expression) && expression.expression.text === "asset") {
|
|
6967
7183
|
const [, key] = expression.arguments;
|
|
6968
7184
|
return key ? staticString(key, bindings) : undefined;
|
|
6969
7185
|
}
|
|
@@ -6973,16 +7189,16 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6973
7189
|
const resolved = symbol ? resolveAlias(symbol, checker) : undefined;
|
|
6974
7190
|
const declaration = resolved?.valueDeclaration ?? resolved?.declarations?.[0];
|
|
6975
7191
|
let callable;
|
|
6976
|
-
if (declaration &&
|
|
7192
|
+
if (declaration && ts5.isFunctionDeclaration(declaration)) {
|
|
6977
7193
|
callable = declaration;
|
|
6978
|
-
} else if (declaration &&
|
|
7194
|
+
} else if (declaration && ts5.isVariableDeclaration(declaration) && declaration.initializer && (ts5.isArrowFunction(declaration.initializer) || ts5.isFunctionExpression(declaration.initializer))) {
|
|
6979
7195
|
callable = declaration.initializer;
|
|
6980
7196
|
}
|
|
6981
7197
|
if (!callable)
|
|
6982
7198
|
return;
|
|
6983
7199
|
const bindings = new Map;
|
|
6984
7200
|
callable.parameters.forEach((parameter, index) => {
|
|
6985
|
-
if (!
|
|
7201
|
+
if (!ts5.isIdentifier(parameter.name))
|
|
6986
7202
|
return;
|
|
6987
7203
|
const argument = call.arguments[index];
|
|
6988
7204
|
if (!argument)
|
|
@@ -6994,33 +7210,33 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6994
7210
|
const { body } = callable;
|
|
6995
7211
|
if (!body)
|
|
6996
7212
|
return;
|
|
6997
|
-
const expressionBody =
|
|
6998
|
-
if (
|
|
7213
|
+
const expressionBody = ts5.isParenthesizedExpression(body) ? body.expression : body;
|
|
7214
|
+
if (ts5.isObjectLiteralExpression(expressionBody)) {
|
|
6999
7215
|
return { bindings, object: expressionBody };
|
|
7000
7216
|
}
|
|
7001
|
-
if (
|
|
7002
|
-
const returned = body.statements.find(
|
|
7003
|
-
if (returned &&
|
|
7217
|
+
if (ts5.isBlock(body)) {
|
|
7218
|
+
const returned = body.statements.find(ts5.isReturnStatement)?.expression;
|
|
7219
|
+
if (returned && ts5.isObjectLiteralExpression(returned)) {
|
|
7004
7220
|
return { bindings, object: returned };
|
|
7005
7221
|
}
|
|
7006
7222
|
}
|
|
7007
7223
|
return;
|
|
7008
7224
|
}, spreadObject = (expression, checker, bindings) => {
|
|
7009
|
-
if (
|
|
7225
|
+
if (ts5.isObjectLiteralExpression(expression)) {
|
|
7010
7226
|
return { bindings, object: expression };
|
|
7011
7227
|
}
|
|
7012
|
-
if (!
|
|
7228
|
+
if (!ts5.isCallExpression(expression))
|
|
7013
7229
|
return;
|
|
7014
7230
|
return callableObject(expression, checker);
|
|
7015
|
-
}, objectAssetKey = (
|
|
7016
|
-
for (const property of [...
|
|
7017
|
-
if (propertyName(property) === name &&
|
|
7231
|
+
}, objectAssetKey = (object3, name, checker, bindings = new Map) => {
|
|
7232
|
+
for (const property of [...object3.properties].reverse()) {
|
|
7233
|
+
if (propertyName(property) === name && ts5.isShorthandPropertyAssignment(property)) {
|
|
7018
7234
|
return assetKeyWithBindings(property.name, checker, bindings);
|
|
7019
7235
|
}
|
|
7020
|
-
if (propertyName(property) === name &&
|
|
7236
|
+
if (propertyName(property) === name && ts5.isPropertyAssignment(property)) {
|
|
7021
7237
|
return assetKeyWithBindings(property.initializer, checker, bindings);
|
|
7022
7238
|
}
|
|
7023
|
-
if (!
|
|
7239
|
+
if (!ts5.isSpreadAssignment(property))
|
|
7024
7240
|
continue;
|
|
7025
7241
|
const nestedObject = spreadObject(property.expression, checker, bindings);
|
|
7026
7242
|
if (!nestedObject)
|
|
@@ -7035,26 +7251,26 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7035
7251
|
const visit = (candidate) => {
|
|
7036
7252
|
if (found)
|
|
7037
7253
|
return;
|
|
7038
|
-
if (
|
|
7254
|
+
if (ts5.isCallExpression(candidate) && ts5.isIdentifier(candidate.expression) && PAGE_HANDLERS.has(candidate.expression.text)) {
|
|
7039
7255
|
const definition = PAGE_HANDLERS.get(candidate.expression.text);
|
|
7040
7256
|
if (!definition)
|
|
7041
7257
|
return;
|
|
7042
7258
|
found = { definition, node: candidate };
|
|
7043
7259
|
return;
|
|
7044
7260
|
}
|
|
7045
|
-
|
|
7261
|
+
ts5.forEachChild(candidate, visit);
|
|
7046
7262
|
};
|
|
7047
7263
|
for (const node of nodes)
|
|
7048
7264
|
visit(node);
|
|
7049
7265
|
return found;
|
|
7050
7266
|
}, isProjectSource = (sourceFile, resolvedFile, projectRoot) => !sourceFile.isDeclarationFile && !resolvedFile.includes("/node_modules/") && resolvedFile.startsWith(`${projectRoot}/`), analyzeRouteCall = (node, sourceFile, checker, projectRoot) => {
|
|
7051
7267
|
const callee = node.expression;
|
|
7052
|
-
if (!
|
|
7268
|
+
if (!ts5.isPropertyAccessExpression(callee))
|
|
7053
7269
|
return;
|
|
7054
7270
|
if (!ROUTE_METHODS.has(callee.name.text))
|
|
7055
7271
|
return;
|
|
7056
7272
|
const [routePath] = node.arguments;
|
|
7057
|
-
if (!routePath || !
|
|
7273
|
+
if (!routePath || !ts5.isStringLiteralLike(routePath))
|
|
7058
7274
|
return;
|
|
7059
7275
|
const foundPageCall = findPageCall(node.arguments.slice(1));
|
|
7060
7276
|
const pageCall = foundPageCall?.node;
|
|
@@ -7087,7 +7303,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7087
7303
|
routeCallSpan: `${node.getStart(sourceFile)}:${node.end}`
|
|
7088
7304
|
};
|
|
7089
7305
|
}
|
|
7090
|
-
if (!
|
|
7306
|
+
if (!ts5.isObjectLiteralExpression(input) || !definition.bundleProperty) {
|
|
7091
7307
|
return;
|
|
7092
7308
|
}
|
|
7093
7309
|
const page = definition.pageProperty ? objectPropertyExpression(input, definition.pageProperty) : undefined;
|
|
@@ -7128,20 +7344,20 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7128
7344
|
byRouteCall: new Map
|
|
7129
7345
|
};
|
|
7130
7346
|
const visit = (node) => {
|
|
7131
|
-
const result =
|
|
7347
|
+
const result = ts5.isCallExpression(node) ? analyzeRouteCall(node, sourceFile, checker, projectRoot) : undefined;
|
|
7132
7348
|
if (result) {
|
|
7133
7349
|
analysis.byPageCall.set(result.pageCallStart, result);
|
|
7134
7350
|
analysis.byRouteCall.set(result.routeCallSpan, result);
|
|
7135
7351
|
}
|
|
7136
|
-
|
|
7352
|
+
ts5.forEachChild(node, visit);
|
|
7137
7353
|
};
|
|
7138
|
-
|
|
7354
|
+
ts5.forEachChild(sourceFile, visit);
|
|
7139
7355
|
return analysis;
|
|
7140
7356
|
}, analyzeProgram = (program, projectRoot) => {
|
|
7141
7357
|
const checker = program.getTypeChecker();
|
|
7142
7358
|
const analyzed = new Map;
|
|
7143
7359
|
for (const sourceFile of program.getSourceFiles()) {
|
|
7144
|
-
const resolvedFile =
|
|
7360
|
+
const resolvedFile = resolve18(sourceFile.fileName);
|
|
7145
7361
|
if (!isProjectSource(sourceFile, resolvedFile, projectRoot))
|
|
7146
7362
|
continue;
|
|
7147
7363
|
const analysis = analyzeSourceFile(sourceFile, checker, projectRoot);
|
|
@@ -7149,20 +7365,20 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7149
7365
|
analyzed.set(resolvedFile, analysis);
|
|
7150
7366
|
}
|
|
7151
7367
|
return analyzed;
|
|
7152
|
-
}, metadataExpression = (metadata) =>
|
|
7153
|
-
const detail =
|
|
7154
|
-
|
|
7368
|
+
}, metadataExpression = (metadata) => ts5.factory.createObjectLiteralExpression(Object.entries(metadata).map(([key, item]) => ts5.factory.createPropertyAssignment(ts5.factory.createStringLiteral(key), ts5.factory.createStringLiteral(item))), false), routeOptions = (existing, metadata) => {
|
|
7369
|
+
const detail = ts5.factory.createObjectLiteralExpression([
|
|
7370
|
+
ts5.factory.createPropertyAssignment(ts5.factory.createStringLiteral(ABSOLUTE_MOBILE_ROUTE_DETAIL), metadataExpression(metadata))
|
|
7155
7371
|
]);
|
|
7156
7372
|
if (!existing) {
|
|
7157
|
-
return
|
|
7158
|
-
|
|
7373
|
+
return ts5.factory.createObjectLiteralExpression([
|
|
7374
|
+
ts5.factory.createPropertyAssignment("detail", detail)
|
|
7159
7375
|
]);
|
|
7160
7376
|
}
|
|
7161
|
-
return
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7377
|
+
return ts5.factory.createObjectLiteralExpression([
|
|
7378
|
+
ts5.factory.createSpreadAssignment(existing),
|
|
7379
|
+
ts5.factory.createPropertyAssignment("detail", ts5.factory.createObjectLiteralExpression([
|
|
7380
|
+
ts5.factory.createSpreadAssignment(ts5.factory.createPropertyAccessExpression(existing, "detail")),
|
|
7381
|
+
ts5.factory.createPropertyAssignment(ts5.factory.createStringLiteral(ABSOLUTE_MOBILE_ROUTE_DETAIL), metadataExpression(metadata))
|
|
7166
7382
|
]))
|
|
7167
7383
|
]);
|
|
7168
7384
|
}, transformPageCall = (node, page) => {
|
|
@@ -7172,19 +7388,19 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7172
7388
|
const [pagePath, existingOptions, ...rest] = node.arguments;
|
|
7173
7389
|
if (!pagePath)
|
|
7174
7390
|
return;
|
|
7175
|
-
const options =
|
|
7176
|
-
...existingOptions ? [
|
|
7177
|
-
|
|
7391
|
+
const options = ts5.factory.createObjectLiteralExpression([
|
|
7392
|
+
...existingOptions ? [ts5.factory.createSpreadAssignment(existingOptions)] : [],
|
|
7393
|
+
ts5.factory.createPropertyAssignment("__absoluteMobile", metadataExpression(page.metadata))
|
|
7178
7394
|
]);
|
|
7179
|
-
return
|
|
7395
|
+
return ts5.factory.updateCallExpression(node, node.expression, node.typeArguments, [pagePath, options, ...rest]);
|
|
7180
7396
|
}
|
|
7181
7397
|
const [input] = node.arguments;
|
|
7182
|
-
if (!input || !
|
|
7398
|
+
if (!input || !ts5.isObjectLiteralExpression(input))
|
|
7183
7399
|
return;
|
|
7184
|
-
return
|
|
7185
|
-
|
|
7400
|
+
return ts5.factory.updateCallExpression(node, node.expression, node.typeArguments, [
|
|
7401
|
+
ts5.factory.updateObjectLiteralExpression(input, [
|
|
7186
7402
|
...input.properties,
|
|
7187
|
-
|
|
7403
|
+
ts5.factory.createPropertyAssignment("__absoluteMobile", metadataExpression(page.metadata))
|
|
7188
7404
|
]),
|
|
7189
7405
|
...node.arguments.slice(1)
|
|
7190
7406
|
]);
|
|
@@ -7196,15 +7412,15 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7196
7412
|
return;
|
|
7197
7413
|
const options = maybeHandler ? maybeOptions : undefined;
|
|
7198
7414
|
const handler = maybeHandler ?? maybeOptions;
|
|
7199
|
-
return
|
|
7415
|
+
return ts5.factory.updateCallExpression(node, node.expression, node.typeArguments, [path, routeOptions(options, route.metadata), handler, ...rest]);
|
|
7200
7416
|
}, transformFile = (source, fileName, analysis) => {
|
|
7201
|
-
const sourceFile =
|
|
7417
|
+
const sourceFile = ts5.createSourceFile(fileName, source, ts5.ScriptTarget.Latest, true, fileName.endsWith("x") ? ts5.ScriptKind.TSX : ts5.ScriptKind.TS);
|
|
7202
7418
|
const transformer = (context) => {
|
|
7203
7419
|
const visit = (node) => {
|
|
7204
|
-
if (!
|
|
7205
|
-
return
|
|
7420
|
+
if (!ts5.isCallExpression(node)) {
|
|
7421
|
+
return ts5.visitEachChild(node, visit, context);
|
|
7206
7422
|
}
|
|
7207
|
-
const transformedChildren =
|
|
7423
|
+
const transformedChildren = ts5.visitEachChild(node, visit, context);
|
|
7208
7424
|
const page = analysis.byPageCall.get(node.getStart(sourceFile));
|
|
7209
7425
|
const transformedPage = transformPageCall(transformedChildren, page);
|
|
7210
7426
|
if (transformedPage)
|
|
@@ -7215,32 +7431,32 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7215
7431
|
return transformedRoute;
|
|
7216
7432
|
return transformedChildren;
|
|
7217
7433
|
};
|
|
7218
|
-
return (node) =>
|
|
7434
|
+
return (node) => ts5.visitNode(node, visit, ts5.isSourceFile) ?? node;
|
|
7219
7435
|
};
|
|
7220
|
-
const result =
|
|
7436
|
+
const result = ts5.transform(sourceFile, [transformer]);
|
|
7221
7437
|
try {
|
|
7222
7438
|
const [transformed] = result.transformed;
|
|
7223
7439
|
if (!transformed)
|
|
7224
7440
|
throw new TypeError("Mobile route transform failed.");
|
|
7225
|
-
return
|
|
7441
|
+
return ts5.createPrinter().printFile(transformed);
|
|
7226
7442
|
} finally {
|
|
7227
7443
|
result.dispose();
|
|
7228
7444
|
}
|
|
7229
7445
|
}, createAbsoluteMobileRouteMetadataPlugin = (options) => {
|
|
7230
|
-
const projectRoot =
|
|
7231
|
-
const entry =
|
|
7446
|
+
const projectRoot = resolve18(options.projectRoot ?? process.cwd());
|
|
7447
|
+
const entry = resolve18(options.entry);
|
|
7232
7448
|
const analyzed = analyzeProgram(createProgram(entry, projectRoot), projectRoot);
|
|
7233
7449
|
return {
|
|
7234
7450
|
name: "absolute-mobile-route-metadata",
|
|
7235
7451
|
setup(build) {
|
|
7236
7452
|
build.onLoad({ filter: SOURCE_FILTER }, async ({ path }) => {
|
|
7237
|
-
const analysis = analyzed.get(
|
|
7453
|
+
const analysis = analyzed.get(resolve18(path));
|
|
7238
7454
|
if (!analysis)
|
|
7239
7455
|
return;
|
|
7240
7456
|
const source = await Bun.file(path).text();
|
|
7241
7457
|
return {
|
|
7242
7458
|
contents: transformFile(source, path, analysis),
|
|
7243
|
-
loader:
|
|
7459
|
+
loader: extname6(path).endsWith("x") ? "tsx" : "ts"
|
|
7244
7460
|
};
|
|
7245
7461
|
});
|
|
7246
7462
|
}
|
|
@@ -7301,7 +7517,7 @@ var init_routeMetadataTransform = __esm(() => {
|
|
|
7301
7517
|
});
|
|
7302
7518
|
|
|
7303
7519
|
// src/cli/elysiaOpenApiTypeboxPlugin.ts
|
|
7304
|
-
import { dirname as dirname14, resolve as
|
|
7520
|
+
import { dirname as dirname14, resolve as resolve19 } from "path";
|
|
7305
7521
|
var OPENAPI_TYPEBOX_PREFIX = "../node_modules/typebox/", OPENAPI_DISTRIBUTION_SEGMENT = "/@elysia/openapi/dist/", createElysiaOpenApiTypeboxPlugin = () => ({
|
|
7306
7522
|
name: "absolute-elysia-openapi-typebox",
|
|
7307
7523
|
setup(build) {
|
|
@@ -7313,7 +7529,7 @@ var OPENAPI_TYPEBOX_PREFIX = "../node_modules/typebox/", OPENAPI_DISTRIBUTION_SE
|
|
|
7313
7529
|
const relativePath = args.path.slice(OPENAPI_TYPEBOX_PREFIX.length);
|
|
7314
7530
|
const typeboxEntry = Bun.resolveSync("typebox", dirname14(args.importer));
|
|
7315
7531
|
return {
|
|
7316
|
-
path:
|
|
7532
|
+
path: resolve19(dirname14(typeboxEntry), "..", relativePath)
|
|
7317
7533
|
};
|
|
7318
7534
|
});
|
|
7319
7535
|
}
|
|
@@ -7373,15 +7589,15 @@ __export(exports_prerender, {
|
|
|
7373
7589
|
prerender: () => prerender,
|
|
7374
7590
|
PRERENDER_BYPASS_HEADER: () => PRERENDER_BYPASS_HEADER
|
|
7375
7591
|
});
|
|
7376
|
-
import { mkdirSync as mkdirSync6, readFileSync as
|
|
7377
|
-
import { join as
|
|
7592
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync14 } from "fs";
|
|
7593
|
+
import { join as join22 } from "path";
|
|
7378
7594
|
var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_TIMEOUT_MS = 30000, DEFAULT_FETCH_TIMEOUT_MS = 1e4, PRERENDER_BYPASS_HEADER = "X-Absolute-Prerender-Bypass", routeToFilename = (route) => route === "/" ? "index.html" : `${route.slice(1).replace(/\//g, "-")}.html`, writeTimestamp = async (htmlPath) => {
|
|
7379
7595
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
7380
7596
|
await Bun.write(metaPath, String(Date.now()));
|
|
7381
7597
|
}, readTimestamp = (htmlPath) => {
|
|
7382
7598
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
7383
7599
|
try {
|
|
7384
|
-
const content =
|
|
7600
|
+
const content = readFileSync14(metaPath, "utf-8");
|
|
7385
7601
|
return Number(content) || 0;
|
|
7386
7602
|
} catch {
|
|
7387
7603
|
return 0;
|
|
@@ -7444,7 +7660,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
7444
7660
|
if (!isCompleteHtml(html))
|
|
7445
7661
|
return false;
|
|
7446
7662
|
const fileName = routeToFilename(route);
|
|
7447
|
-
const filePath =
|
|
7663
|
+
const filePath = join22(prerenderDir, fileName);
|
|
7448
7664
|
await Bun.write(filePath, html);
|
|
7449
7665
|
await writeTimestamp(filePath);
|
|
7450
7666
|
return true;
|
|
@@ -7474,13 +7690,13 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
7474
7690
|
return;
|
|
7475
7691
|
}
|
|
7476
7692
|
const fileName = routeToFilename(route);
|
|
7477
|
-
const filePath =
|
|
7693
|
+
const filePath = join22(prerenderDir, fileName);
|
|
7478
7694
|
await Bun.write(filePath, html);
|
|
7479
7695
|
await writeTimestamp(filePath);
|
|
7480
7696
|
result.routes.set(route, filePath);
|
|
7481
7697
|
log?.(` Pre-rendered ${route} \u2192 ${fileName} (${html.length} bytes)`);
|
|
7482
7698
|
}, prerender = async (port, outDir, staticConfig, log) => {
|
|
7483
|
-
const prerenderDir =
|
|
7699
|
+
const prerenderDir = join22(outDir, "_prerendered");
|
|
7484
7700
|
mkdirSync6(prerenderDir, { recursive: true });
|
|
7485
7701
|
const baseUrl = `http://localhost:${port}`;
|
|
7486
7702
|
let routes;
|
|
@@ -7547,10 +7763,10 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
7547
7763
|
};
|
|
7548
7764
|
read();
|
|
7549
7765
|
}, formatServerOutput = (output) => {
|
|
7550
|
-
const
|
|
7551
|
-
if (!
|
|
7766
|
+
const text2 = output.join("").trim();
|
|
7767
|
+
if (!text2)
|
|
7552
7768
|
return "";
|
|
7553
|
-
return
|
|
7769
|
+
return text2.length > SERVER_OUTPUT_LIMIT ? text2.slice(-SERVER_OUTPUT_LIMIT) : text2;
|
|
7554
7770
|
}, createServerStartupError = (output) => {
|
|
7555
7771
|
const serverOutput = formatServerOutput(output);
|
|
7556
7772
|
const message = serverOutput ? `Server failed to start for pre-rendering.
|
|
@@ -7599,9 +7815,9 @@ var SENTINEL, RISKY_STRING_CONTENT, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c)
|
|
|
7599
7815
|
let prevChar = "";
|
|
7600
7816
|
let prevWord = "";
|
|
7601
7817
|
let prevWasSpace = false;
|
|
7602
|
-
const mask = (
|
|
7818
|
+
const mask = (text2) => {
|
|
7603
7819
|
out += SENTINEL + pieces.length + SENTINEL;
|
|
7604
|
-
pieces.push(
|
|
7820
|
+
pieces.push(text2);
|
|
7605
7821
|
prevChar = ")";
|
|
7606
7822
|
prevWord = "";
|
|
7607
7823
|
prevWasSpace = false;
|
|
@@ -7767,11 +7983,11 @@ var SENTINEL, RISKY_STRING_CONTENT, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c)
|
|
|
7767
7983
|
}
|
|
7768
7984
|
if (c === '"' || c === "'") {
|
|
7769
7985
|
const end = endOfString(i);
|
|
7770
|
-
const
|
|
7771
|
-
if (RISKY_STRING_CONTENT.test(
|
|
7772
|
-
mask(
|
|
7986
|
+
const text2 = src.slice(i, end);
|
|
7987
|
+
if (RISKY_STRING_CONTENT.test(text2)) {
|
|
7988
|
+
mask(text2);
|
|
7773
7989
|
} else {
|
|
7774
|
-
out +=
|
|
7990
|
+
out += text2;
|
|
7775
7991
|
prevChar = '"';
|
|
7776
7992
|
prevWord = "";
|
|
7777
7993
|
prevWasSpace = false;
|
|
@@ -7856,7 +8072,7 @@ var init_maskLiterals = __esm(() => {
|
|
|
7856
8072
|
// src/build/nativeRewrite.ts
|
|
7857
8073
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
7858
8074
|
import { platform as platform4, arch as arch3 } from "os";
|
|
7859
|
-
import { resolve as
|
|
8075
|
+
import { resolve as resolve20 } from "path";
|
|
7860
8076
|
var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
7861
8077
|
if (nativeLib !== null)
|
|
7862
8078
|
return nativeLib;
|
|
@@ -7874,7 +8090,7 @@ var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
|
7874
8090
|
if (!libPath)
|
|
7875
8091
|
return null;
|
|
7876
8092
|
try {
|
|
7877
|
-
const fullPath =
|
|
8093
|
+
const fullPath = resolve20(import.meta.dir, "../../native/packages", libPath);
|
|
7878
8094
|
const lib = dlopen(fullPath, ffiDefinition);
|
|
7879
8095
|
nativeLib = lib.symbols;
|
|
7880
8096
|
return nativeLib;
|
|
@@ -7916,7 +8132,7 @@ var init_nativeRewrite = __esm(() => {
|
|
|
7916
8132
|
|
|
7917
8133
|
// src/build/rewriteImportsPlugin.ts
|
|
7918
8134
|
import { readdir as readdir3 } from "fs/promises";
|
|
7919
|
-
import { join as
|
|
8135
|
+
import { join as join23 } from "path";
|
|
7920
8136
|
var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
|
|
7921
8137
|
let result = content;
|
|
7922
8138
|
for (const [specifier, webPath] of replacements) {
|
|
@@ -7995,7 +8211,7 @@ ${content}`;
|
|
|
7995
8211
|
const entries = await readdir3(dir);
|
|
7996
8212
|
for (const entry of entries) {
|
|
7997
8213
|
if (entry.endsWith(".js"))
|
|
7998
|
-
allFiles.push(
|
|
8214
|
+
allFiles.push(join23(dir, entry));
|
|
7999
8215
|
}
|
|
8000
8216
|
} catch {}
|
|
8001
8217
|
}
|
|
@@ -8070,8 +8286,8 @@ var init_rewriteImports = __esm(() => {
|
|
|
8070
8286
|
|
|
8071
8287
|
// src/cli/scripts/start.ts
|
|
8072
8288
|
var {env: env2 } = globalThis.Bun;
|
|
8073
|
-
import { existsSync as existsSync11, readFileSync as
|
|
8074
|
-
import { basename as basename8, join as
|
|
8289
|
+
import { existsSync as existsSync11, readFileSync as readFileSync15, rmSync as rmSync4 } from "fs";
|
|
8290
|
+
import { basename as basename8, join as join24, resolve as resolve21 } from "path";
|
|
8075
8291
|
var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, resolvePackageVersion = (candidates) => {
|
|
8076
8292
|
for (const candidate of candidates) {
|
|
8077
8293
|
const version2 = readPackageVersion2(candidate);
|
|
@@ -8082,7 +8298,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8082
8298
|
return "";
|
|
8083
8299
|
}, readPackageVersion2 = (candidate) => {
|
|
8084
8300
|
try {
|
|
8085
|
-
const pkg = JSON.parse(
|
|
8301
|
+
const pkg = JSON.parse(readFileSync15(candidate, "utf-8"));
|
|
8086
8302
|
if (pkg.name !== "@absolutejs/absolute")
|
|
8087
8303
|
return null;
|
|
8088
8304
|
const ver = pkg.version;
|
|
@@ -8120,18 +8336,18 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8120
8336
|
process.exit(1);
|
|
8121
8337
|
}, resolveJsxDevRuntimeCompatPath = () => {
|
|
8122
8338
|
const candidates = [
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8339
|
+
resolve21(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
8340
|
+
resolve21(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
8341
|
+
resolve21(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
|
|
8342
|
+
resolve21(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
8343
|
+
resolve21(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
8344
|
+
resolve21(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
|
|
8129
8345
|
];
|
|
8130
8346
|
for (const candidate of candidates) {
|
|
8131
8347
|
if (existsSync11(candidate))
|
|
8132
8348
|
return candidate;
|
|
8133
8349
|
}
|
|
8134
|
-
return
|
|
8350
|
+
return resolve21(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
|
|
8135
8351
|
}, jsxDevRuntimeCompatPath, prerenderStaticPages = async (outputPath, prerenderPort, resolvedOutdir, staticConfig, absoluteVersion, configPath2) => {
|
|
8136
8352
|
const prerenderStart = performance.now();
|
|
8137
8353
|
process.stdout.write(cliTag2("\x1B[36m", "Pre-rendering static pages"));
|
|
@@ -8165,7 +8381,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8165
8381
|
serverEntry,
|
|
8166
8382
|
totalDuration
|
|
8167
8383
|
}) => {
|
|
8168
|
-
const usesDocker = existsSync11(
|
|
8384
|
+
const usesDocker = existsSync11(resolve21(COMPOSE_PATH));
|
|
8169
8385
|
const scripts = usesDocker ? await readDbScripts() : null;
|
|
8170
8386
|
if (scripts)
|
|
8171
8387
|
await startDatabase(scripts);
|
|
@@ -8256,10 +8472,10 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8256
8472
|
const port = Number(env2.PORT) || DEFAULT_PORT;
|
|
8257
8473
|
killStaleProcesses(port);
|
|
8258
8474
|
const entryName = basename8(serverEntry).replace(/\.[^.]+$/, "");
|
|
8259
|
-
const resolvedOutdir =
|
|
8475
|
+
const resolvedOutdir = resolve21(outdir ?? "dist");
|
|
8260
8476
|
const absoluteVersion = resolvePackageVersion([
|
|
8261
|
-
|
|
8262
|
-
|
|
8477
|
+
resolve21(import.meta.dir, "..", "..", "..", "package.json"),
|
|
8478
|
+
resolve21(import.meta.dir, "..", "..", "package.json")
|
|
8263
8479
|
]);
|
|
8264
8480
|
const buildConfig = await loadConfig(configPath2);
|
|
8265
8481
|
buildConfig.buildDirectory = resolvedOutdir;
|
|
@@ -8274,7 +8490,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8274
8490
|
buildConfig.vueDirectory && "vue",
|
|
8275
8491
|
buildConfig.angularDirectory && "angular"
|
|
8276
8492
|
].filter((val) => Boolean(val));
|
|
8277
|
-
const outputPath =
|
|
8493
|
+
const outputPath = resolve21(resolvedOutdir, `${entryName}.js`);
|
|
8278
8494
|
if (options.prebuilt) {
|
|
8279
8495
|
if (!existsSync11(outputPath)) {
|
|
8280
8496
|
throw new Error(`Prepared production server not found: ${outputPath}`);
|
|
@@ -8297,13 +8513,13 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8297
8513
|
process.stdout.write(cliTag2("\x1B[36m", `Building assets`));
|
|
8298
8514
|
try {
|
|
8299
8515
|
const build = await resolveBuildModule([
|
|
8300
|
-
|
|
8301
|
-
|
|
8516
|
+
resolve21(import.meta.dir, "..", "..", "core", "build"),
|
|
8517
|
+
resolve21(import.meta.dir, "..", "build")
|
|
8302
8518
|
]);
|
|
8303
8519
|
if (!build)
|
|
8304
8520
|
throw new Error("Could not locate build module");
|
|
8305
8521
|
await build(buildConfig);
|
|
8306
|
-
rmSync4(
|
|
8522
|
+
rmSync4(join24(resolvedOutdir, "_prerendered"), {
|
|
8307
8523
|
force: true,
|
|
8308
8524
|
recursive: true
|
|
8309
8525
|
});
|
|
@@ -8368,8 +8584,8 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8368
8584
|
const normalizedPath = args.path.replace(/\\/g, "/");
|
|
8369
8585
|
if (normalizedPath.includes("/src/angular/"))
|
|
8370
8586
|
return;
|
|
8371
|
-
const
|
|
8372
|
-
if (
|
|
8587
|
+
const text2 = await Bun.file(args.path).text();
|
|
8588
|
+
if (text2.includes("@Component") && stripStringsAndComments(text2).includes("@Component")) {
|
|
8373
8589
|
return {
|
|
8374
8590
|
contents: "export default {}",
|
|
8375
8591
|
loader: "js"
|
|
@@ -8380,17 +8596,17 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8380
8596
|
}
|
|
8381
8597
|
};
|
|
8382
8598
|
const islandRegistrySpec = buildConfig.islands?.registry;
|
|
8383
|
-
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(
|
|
8599
|
+
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve21(islandRegistrySpec))) : undefined;
|
|
8384
8600
|
const serverBundle = await Bun.build({
|
|
8385
8601
|
define: { "process.env.NODE_ENV": '"production"' },
|
|
8386
|
-
entrypoints: [
|
|
8602
|
+
entrypoints: [resolve21(serverEntry)],
|
|
8387
8603
|
external: resolveServerBundleExternals(buildConfig),
|
|
8388
8604
|
outdir: resolvedOutdir,
|
|
8389
8605
|
plugins: [
|
|
8390
8606
|
...islandRegistryPlugin ? [islandRegistryPlugin] : [],
|
|
8391
8607
|
...buildConfig.mobile ? [
|
|
8392
8608
|
createAbsoluteMobileRouteMetadataPlugin({
|
|
8393
|
-
entry:
|
|
8609
|
+
entry: resolve21(serverEntry)
|
|
8394
8610
|
})
|
|
8395
8611
|
] : [],
|
|
8396
8612
|
createElysiaOpenApiTypeboxPlugin(),
|
|
@@ -8407,9 +8623,9 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8407
8623
|
console.error(cliTag2("\x1B[31m", `Expected output not found: ${outputPath}`));
|
|
8408
8624
|
process.exit(1);
|
|
8409
8625
|
}
|
|
8410
|
-
if (existsSync11(
|
|
8626
|
+
if (existsSync11(resolve21(resolvedOutdir, "angular", "vendor", "server"))) {
|
|
8411
8627
|
const { readdirSync: readdirSync2 } = await import("fs");
|
|
8412
|
-
const vendorDir =
|
|
8628
|
+
const vendorDir = resolve21(resolvedOutdir, "angular", "vendor", "server");
|
|
8413
8629
|
const vendorEntries = readdirSync2(vendorDir).filter((fileName) => fileName.endsWith(".js"));
|
|
8414
8630
|
const angularServerVendorPaths = {};
|
|
8415
8631
|
const { relative: pathRelative, dirname: pathDirname } = await import("path");
|
|
@@ -8419,7 +8635,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8419
8635
|
if (scope !== "angular" || rest.length === 0)
|
|
8420
8636
|
continue;
|
|
8421
8637
|
const specifier = `@angular/${rest.join("/")}`;
|
|
8422
|
-
const relPath = pathRelative(pathDirname(outputPath),
|
|
8638
|
+
const relPath = pathRelative(pathDirname(outputPath), resolve21(vendorDir, file));
|
|
8423
8639
|
angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
8424
8640
|
}
|
|
8425
8641
|
if (Object.keys(angularServerVendorPaths).length > 0) {
|
|
@@ -8606,17 +8822,17 @@ var exports_build = {};
|
|
|
8606
8822
|
__export(exports_build, {
|
|
8607
8823
|
build: () => build
|
|
8608
8824
|
});
|
|
8609
|
-
import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as
|
|
8610
|
-
import { join as
|
|
8825
|
+
import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as readFileSync17 } from "fs";
|
|
8826
|
+
import { join as join25, resolve as resolve23 } from "path";
|
|
8611
8827
|
var PROFILE_TOP = 15, PROFILE_COL = 8, FRAMEWORK_KEYS, cliTag3 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, printProfile = (buildDir) => {
|
|
8612
|
-
const traceDir =
|
|
8828
|
+
const traceDir = join25(buildDir, ".absolute-trace");
|
|
8613
8829
|
if (!existsSync13(traceDir))
|
|
8614
8830
|
return;
|
|
8615
8831
|
const files = readdirSync3(traceDir).filter((file) => file.endsWith(".json")).sort();
|
|
8616
8832
|
const latest = files[files.length - 1];
|
|
8617
8833
|
if (latest === undefined)
|
|
8618
8834
|
return;
|
|
8619
|
-
const trace = JSON.parse(
|
|
8835
|
+
const trace = JSON.parse(readFileSync17(join25(traceDir, latest), "utf-8"));
|
|
8620
8836
|
const events = Array.isArray(trace.events) ? trace.events : [];
|
|
8621
8837
|
if (events.length === 0)
|
|
8622
8838
|
return;
|
|
@@ -8653,7 +8869,7 @@ var PROFILE_TOP = 15, PROFILE_COL = 8, FRAMEWORK_KEYS, cliTag3 = (color, message
|
|
|
8653
8869
|
}
|
|
8654
8870
|
return resolveBuildModule2(remaining);
|
|
8655
8871
|
}, build = async (outdir, configPath2, profile = false) => {
|
|
8656
|
-
const resolvedOutdir =
|
|
8872
|
+
const resolvedOutdir = resolve23(outdir ?? "build");
|
|
8657
8873
|
const buildStart = performance.now();
|
|
8658
8874
|
if (profile)
|
|
8659
8875
|
process.env.ABSOLUTE_BUILD_TRACE = "1";
|
|
@@ -8663,8 +8879,8 @@ var PROFILE_TOP = 15, PROFILE_COL = 8, FRAMEWORK_KEYS, cliTag3 = (color, message
|
|
|
8663
8879
|
buildConfig.mode = "production";
|
|
8664
8880
|
try {
|
|
8665
8881
|
const buildApp = await resolveBuildModule2([
|
|
8666
|
-
|
|
8667
|
-
|
|
8882
|
+
resolve23(import.meta.dir, "..", "..", "core", "build"),
|
|
8883
|
+
resolve23(import.meta.dir, "..", "build")
|
|
8668
8884
|
]);
|
|
8669
8885
|
if (!buildApp)
|
|
8670
8886
|
throw new Error("Could not locate build module");
|
|
@@ -8713,14 +8929,14 @@ import {
|
|
|
8713
8929
|
lstatSync,
|
|
8714
8930
|
mkdirSync as mkdirSync8,
|
|
8715
8931
|
mkdtempSync,
|
|
8716
|
-
readFileSync as
|
|
8932
|
+
readFileSync as readFileSync18,
|
|
8717
8933
|
realpathSync,
|
|
8718
8934
|
renameSync as renameSync2,
|
|
8719
8935
|
rmSync as rmSync5,
|
|
8720
8936
|
writeFileSync as writeFileSync7
|
|
8721
8937
|
} from "fs";
|
|
8722
8938
|
import { tmpdir as tmpdir3 } from "os";
|
|
8723
|
-
import { delimiter, dirname as dirname15, relative as
|
|
8939
|
+
import { delimiter, dirname as dirname15, relative as relative13, resolve as resolve24 } from "path";
|
|
8724
8940
|
var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSION = 2, FLAG_NOT_FOUND = -1, CHUNKED_FLAG = "--chunked", TSCONFIG_PATTERN, ABSOLUTE_BINARY, runGit = (args, options) => {
|
|
8725
8941
|
const proc = Bun.spawnSync(["git", ...args], {
|
|
8726
8942
|
cwd: options.cwd,
|
|
@@ -8733,8 +8949,8 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8733
8949
|
throw new Error(detail || `git ${args.join(" ")} failed`);
|
|
8734
8950
|
}
|
|
8735
8951
|
return proc.stdout.toString().trim();
|
|
8736
|
-
}, gitRoot = (cwd) =>
|
|
8737
|
-
const path =
|
|
8952
|
+
}, gitRoot = (cwd) => resolve24(runGit(["rev-parse", "--show-toplevel"], { cwd })), isInside3 = (parent, candidate) => {
|
|
8953
|
+
const path = relative13(parent, candidate);
|
|
8738
8954
|
return path === "" || !path.startsWith("../") && path !== "..";
|
|
8739
8955
|
}, attestationPayload = (proof) => Buffer.from([
|
|
8740
8956
|
"absolute-lint-proof-attestation:1",
|
|
@@ -8746,17 +8962,17 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8746
8962
|
sourceTree: proof.sourceTree
|
|
8747
8963
|
})
|
|
8748
8964
|
].join("\x00")), publicKeyId = (key) => createHash11("sha256").update(key.export({ format: "der", type: "spki" })).digest("hex"), readEd25519PrivateKey = (cwd, location) => {
|
|
8749
|
-
const path =
|
|
8965
|
+
const path = resolve24(cwd, location);
|
|
8750
8966
|
if (isInside3(realpathSync(gitRoot(cwd)), realpathSync(path))) {
|
|
8751
8967
|
throw new Error("lint proof signing key must live outside the Git working tree");
|
|
8752
8968
|
}
|
|
8753
|
-
const key = createPrivateKey(
|
|
8969
|
+
const key = createPrivateKey(readFileSync18(path));
|
|
8754
8970
|
if (key.asymmetricKeyType !== "ed25519") {
|
|
8755
8971
|
throw new Error("lint proof signing key must be an Ed25519 private key");
|
|
8756
8972
|
}
|
|
8757
8973
|
return key;
|
|
8758
8974
|
}, readEd25519PublicKey = (cwd, location) => {
|
|
8759
|
-
const key = createPublicKey(
|
|
8975
|
+
const key = createPublicKey(readFileSync18(resolve24(cwd, location)));
|
|
8760
8976
|
if (key.asymmetricKeyType !== "ed25519") {
|
|
8761
8977
|
throw new Error("trusted lint proof key must be an Ed25519 public key");
|
|
8762
8978
|
}
|
|
@@ -8784,7 +9000,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8784
9000
|
return null;
|
|
8785
9001
|
const auxiliary = gitVisibleFiles(root).filter((file) => TSCONFIG_PATTERN.test(file));
|
|
8786
9002
|
const configPath2 = findEslintConfigPath(root);
|
|
8787
|
-
const configRelative = configPath2 === null ? null :
|
|
9003
|
+
const configRelative = configPath2 === null ? null : relative13(root, configPath2).replaceAll("\\", "/");
|
|
8788
9004
|
return [
|
|
8789
9005
|
...new Set([
|
|
8790
9006
|
...resolveLintTargets(args, root),
|
|
@@ -8794,17 +9010,17 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8794
9010
|
].sort();
|
|
8795
9011
|
}, createLintSourceTree = (cwd = process.cwd(), proofLocation = DEFAULT_PROOF_LOCATION, command = []) => {
|
|
8796
9012
|
const root = gitRoot(cwd);
|
|
8797
|
-
const proofPath =
|
|
8798
|
-
const proofRelative =
|
|
9013
|
+
const proofPath = resolve24(cwd, proofLocation);
|
|
9014
|
+
const proofRelative = relative13(root, proofPath).replaceAll("\\", "/");
|
|
8799
9015
|
if (proofRelative === ".." || proofRelative.startsWith("../") || proofRelative === "") {
|
|
8800
9016
|
throw new Error("lint proof must live inside the Git working tree");
|
|
8801
9017
|
}
|
|
8802
|
-
const temporaryDirectory = mkdtempSync(
|
|
8803
|
-
const temporaryIndex =
|
|
8804
|
-
const temporaryObjects =
|
|
9018
|
+
const temporaryDirectory = mkdtempSync(resolve24(tmpdir3(), "absolute-lint-proof-"));
|
|
9019
|
+
const temporaryIndex = resolve24(temporaryDirectory, "index");
|
|
9020
|
+
const temporaryObjects = resolve24(temporaryDirectory, "objects");
|
|
8805
9021
|
mkdirSync8(temporaryObjects, { recursive: true });
|
|
8806
9022
|
const repositoryObjectsPath = runGit(["rev-parse", "--git-path", "objects"], { cwd: root });
|
|
8807
|
-
const repositoryObjects =
|
|
9023
|
+
const repositoryObjects = resolve24(root, repositoryObjectsPath);
|
|
8808
9024
|
const existingAlternates = process.env.GIT_ALTERNATE_OBJECT_DIRECTORIES?.trim();
|
|
8809
9025
|
const env3 = {
|
|
8810
9026
|
GIT_ALTERNATE_OBJECT_DIRECTORIES: [
|
|
@@ -8828,7 +9044,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8828
9044
|
if (!path || path === proofRelative)
|
|
8829
9045
|
return false;
|
|
8830
9046
|
try {
|
|
8831
|
-
lstatSync(
|
|
9047
|
+
lstatSync(resolve24(root, path));
|
|
8832
9048
|
return true;
|
|
8833
9049
|
} catch {
|
|
8834
9050
|
return false;
|
|
@@ -8852,7 +9068,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8852
9068
|
}, writeLintProof = (command, options = {}) => {
|
|
8853
9069
|
const cwd = options.cwd ?? process.cwd();
|
|
8854
9070
|
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
8855
|
-
const path =
|
|
9071
|
+
const path = resolve24(cwd, proofLocation);
|
|
8856
9072
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
8857
9073
|
const proof = createLintProof(command, { cwd, proofLocation });
|
|
8858
9074
|
if (options.signingKeyLocation) {
|
|
@@ -8908,12 +9124,12 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8908
9124
|
}, verifyLintProof = (command, options = {}) => {
|
|
8909
9125
|
const cwd = options.cwd ?? process.cwd();
|
|
8910
9126
|
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
8911
|
-
const path =
|
|
9127
|
+
const path = resolve24(cwd, proofLocation);
|
|
8912
9128
|
if (!existsSync14(path))
|
|
8913
9129
|
return { reason: `missing lint proof: ${proofLocation}`, valid: false };
|
|
8914
9130
|
let proof;
|
|
8915
9131
|
try {
|
|
8916
|
-
proof = JSON.parse(
|
|
9132
|
+
proof = JSON.parse(readFileSync18(path, "utf-8"));
|
|
8917
9133
|
} catch {
|
|
8918
9134
|
return { reason: `invalid lint proof: ${proofLocation}`, valid: false };
|
|
8919
9135
|
}
|
|
@@ -9078,8 +9294,8 @@ var exports_ls = {};
|
|
|
9078
9294
|
__export(exports_ls, {
|
|
9079
9295
|
runLs: () => runLs
|
|
9080
9296
|
});
|
|
9081
|
-
import { existsSync as existsSync16, readFileSync as
|
|
9082
|
-
import { basename as basename10, extname as
|
|
9297
|
+
import { existsSync as existsSync16, readFileSync as readFileSync19, statSync } from "fs";
|
|
9298
|
+
import { basename as basename10, extname as extname7, join as join26, relative as relative14 } from "path";
|
|
9083
9299
|
var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELDS, readStringField = (source, key) => {
|
|
9084
9300
|
const value = Reflect.get(source, key);
|
|
9085
9301
|
return typeof value === "string" ? value : undefined;
|
|
@@ -9094,24 +9310,24 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
9094
9310
|
} catch {
|
|
9095
9311
|
return null;
|
|
9096
9312
|
}
|
|
9097
|
-
}, relativeOrSelf = (target) =>
|
|
9313
|
+
}, relativeOrSelf = (target) => relative14(process.cwd(), target) || target, configCandidates = (raw) => isWorkspaceConfig(raw) ? Object.values(raw).map((service) => ({
|
|
9098
9314
|
baseDir: readStringField(service, "cwd") ?? ".",
|
|
9099
9315
|
source: service
|
|
9100
9316
|
})) : [{ baseDir: ".", source: raw }], specsFor = (source, baseDir) => FRAMEWORK_FIELDS.flatMap((framework) => {
|
|
9101
9317
|
const dir = readStringField(source, framework.field);
|
|
9102
9318
|
return dir === undefined ? [] : [
|
|
9103
9319
|
{
|
|
9104
|
-
dir:
|
|
9320
|
+
dir: join26(baseDir, dir),
|
|
9105
9321
|
label: framework.label,
|
|
9106
9322
|
pattern: framework.pattern
|
|
9107
9323
|
}
|
|
9108
9324
|
];
|
|
9109
9325
|
}), scanFramework = async (spec) => {
|
|
9110
|
-
const { pageFiles } = await scanConventions(
|
|
9326
|
+
const { pageFiles } = await scanConventions(join26(spec.dir, "pages"), spec.pattern);
|
|
9111
9327
|
if (pageFiles.length === 0)
|
|
9112
9328
|
return null;
|
|
9113
9329
|
const pages = pageFiles.map((file) => ({
|
|
9114
|
-
name: basename10(file,
|
|
9330
|
+
name: basename10(file, extname7(file)),
|
|
9115
9331
|
sizeBytes: null,
|
|
9116
9332
|
sourcePath: relativeOrSelf(file)
|
|
9117
9333
|
}));
|
|
@@ -9131,10 +9347,10 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
9131
9347
|
}, resolveDiskPath = (buildDir, value) => {
|
|
9132
9348
|
if (existsSync16(value))
|
|
9133
9349
|
return value;
|
|
9134
|
-
const underBuild =
|
|
9350
|
+
const underBuild = join26(buildDir, value);
|
|
9135
9351
|
if (existsSync16(underBuild))
|
|
9136
9352
|
return underBuild;
|
|
9137
|
-
return
|
|
9353
|
+
return join26(process.cwd(), value);
|
|
9138
9354
|
}, fileSize = (diskPath) => {
|
|
9139
9355
|
try {
|
|
9140
9356
|
return statSync(diskPath).size;
|
|
@@ -9142,7 +9358,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
9142
9358
|
return 0;
|
|
9143
9359
|
}
|
|
9144
9360
|
}, readManifestSizes = (manifestDir) => {
|
|
9145
|
-
const manifest = JSON.parse(
|
|
9361
|
+
const manifest = JSON.parse(readFileSync19(join26(manifestDir, "manifest.json"), "utf-8"));
|
|
9146
9362
|
const sizes = new Map;
|
|
9147
9363
|
Object.entries(manifest).forEach(([key, value]) => {
|
|
9148
9364
|
sizes.set(key, fileSize(resolveDiskPath(manifestDir, value)));
|
|
@@ -9161,7 +9377,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
9161
9377
|
}))
|
|
9162
9378
|
})), manifestAge = (manifestPath) => getDurationString(Date.now() - statSync(manifestPath).mtimeMs), firstBuildDir = (candidates) => candidates.map((candidate) => {
|
|
9163
9379
|
const dir = readStringField(candidate.source, "buildDirectory");
|
|
9164
|
-
return dir === undefined ? undefined :
|
|
9380
|
+
return dir === undefined ? undefined : join26(candidate.baseDir, dir);
|
|
9165
9381
|
}).find((dir) => dir !== undefined), resolveSizesDir = (args, candidates) => parseFlagValue(args, "--outdir") ?? firstBuildDir(candidates) ?? DEFAULT_BUILD_DIR, formatSize = (bytes) => {
|
|
9166
9382
|
if (bytes === null || bytes === 0)
|
|
9167
9383
|
return "-";
|
|
@@ -9259,7 +9475,7 @@ ${colors.dim}${frameworkCount} ${frameworkCount === 1 ? "framework" : "framework
|
|
|
9259
9475
|
return;
|
|
9260
9476
|
}
|
|
9261
9477
|
const sizesDir = resolveSizesDir(args, candidates);
|
|
9262
|
-
const manifestPath =
|
|
9478
|
+
const manifestPath = join26(sizesDir, "manifest.json");
|
|
9263
9479
|
if (!existsSync16(manifestPath)) {
|
|
9264
9480
|
printDim(`No build at ${relativeOrSelf(manifestPath)}. Run \`absolute build\` first, or pass \`--outdir <dir>\`.`);
|
|
9265
9481
|
return;
|
|
@@ -9384,21 +9600,21 @@ var init_discoverInstances = __esm(() => {
|
|
|
9384
9600
|
import { createConnection as createConnection2 } from "net";
|
|
9385
9601
|
var {$: $4 } = globalThis.Bun;
|
|
9386
9602
|
var displayHost = (host2) => host2 === "0.0.0.0" || host2 === "::" ? "localhost" : host2, probePort = (host2, port) => {
|
|
9387
|
-
const { promise, resolve:
|
|
9603
|
+
const { promise, resolve: resolve25 } = Promise.withResolvers();
|
|
9388
9604
|
const socket = createConnection2({ host: displayHost(host2), port });
|
|
9389
9605
|
const timeout = setTimeout(() => {
|
|
9390
9606
|
socket.destroy();
|
|
9391
|
-
|
|
9607
|
+
resolve25(false);
|
|
9392
9608
|
}, INSTANCE_PROBE_TIMEOUT_MS);
|
|
9393
9609
|
socket.once("connect", () => {
|
|
9394
9610
|
clearTimeout(timeout);
|
|
9395
9611
|
socket.end();
|
|
9396
|
-
|
|
9612
|
+
resolve25(true);
|
|
9397
9613
|
});
|
|
9398
9614
|
socket.once("error", () => {
|
|
9399
9615
|
clearTimeout(timeout);
|
|
9400
9616
|
socket.destroy();
|
|
9401
|
-
|
|
9617
|
+
resolve25(false);
|
|
9402
9618
|
});
|
|
9403
9619
|
return promise;
|
|
9404
9620
|
}, probeStatus = async (record) => {
|
|
@@ -9530,8 +9746,8 @@ var TUI_HEADERS, STATUS_INDEX = 8, URL_INDEX = 9, MEM_HISTORY_MAX = 12, SPARK_CH
|
|
|
9530
9746
|
render();
|
|
9531
9747
|
}, LIST_TUI_RENDER_DEBOUNCE_MS);
|
|
9532
9748
|
};
|
|
9533
|
-
const setStatus = (
|
|
9534
|
-
statusMessage = { level, text };
|
|
9749
|
+
const setStatus = (text2, level) => {
|
|
9750
|
+
statusMessage = { level, text: text2 };
|
|
9535
9751
|
if (statusTimer)
|
|
9536
9752
|
clearTimeout(statusTimer);
|
|
9537
9753
|
statusTimer = setTimeout(() => {
|
|
@@ -10110,9 +10326,9 @@ var exports_heapDiff = {};
|
|
|
10110
10326
|
__export(exports_heapDiff, {
|
|
10111
10327
|
runHeapDiff: () => runHeapDiff
|
|
10112
10328
|
});
|
|
10113
|
-
import { existsSync as existsSync17, readFileSync as
|
|
10329
|
+
import { existsSync as existsSync17, readFileSync as readFileSync20 } from "fs";
|
|
10114
10330
|
var TOP = 15, STRING_TYPES, aggregate = (path) => {
|
|
10115
|
-
const data = JSON.parse(
|
|
10331
|
+
const data = JSON.parse(readFileSync20(path, "utf-8"));
|
|
10116
10332
|
const { nodes, strings } = data;
|
|
10117
10333
|
const { node_fields: fields, node_types: nodeTypes } = data.snapshot.meta;
|
|
10118
10334
|
const [typeNames] = nodeTypes;
|
|
@@ -10260,31 +10476,31 @@ var init_mem = __esm(() => {
|
|
|
10260
10476
|
var isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10261
10477
|
|
|
10262
10478
|
// src/cli/config/schema/fromType.ts
|
|
10263
|
-
import
|
|
10479
|
+
import ts6 from "typescript";
|
|
10264
10480
|
import {
|
|
10265
10481
|
existsSync as existsSync18,
|
|
10266
10482
|
mkdirSync as mkdirSync9,
|
|
10267
|
-
readFileSync as
|
|
10483
|
+
readFileSync as readFileSync21,
|
|
10268
10484
|
statSync as statSync2,
|
|
10269
10485
|
writeFileSync as writeFileSync8
|
|
10270
10486
|
} from "fs";
|
|
10271
|
-
import { resolve as
|
|
10487
|
+
import { resolve as resolve25 } from "path";
|
|
10272
10488
|
var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFrameworkRepo = (cwd) => {
|
|
10273
10489
|
try {
|
|
10274
|
-
const pkg = JSON.parse(
|
|
10490
|
+
const pkg = JSON.parse(readFileSync21(resolve25(cwd, "package.json"), "utf-8"));
|
|
10275
10491
|
return pkg?.name === "@absolutejs/absolute";
|
|
10276
10492
|
} catch {
|
|
10277
10493
|
return false;
|
|
10278
10494
|
}
|
|
10279
10495
|
}, compilerOptionsFor = (cwd) => {
|
|
10280
|
-
const tsconfigPath =
|
|
10496
|
+
const tsconfigPath = ts6.findConfigFile(cwd, ts6.sys.fileExists, "tsconfig.json");
|
|
10281
10497
|
const parseConfigHost = {
|
|
10282
|
-
...
|
|
10498
|
+
...ts6.sys,
|
|
10283
10499
|
onUnRecoverableConfigFileDiagnostic: () => {}
|
|
10284
10500
|
};
|
|
10285
|
-
const base = tsconfigPath &&
|
|
10501
|
+
const base = tsconfigPath && ts6.getParsedCommandLineOfConfigFile(tsconfigPath, {}, parseConfigHost)?.options;
|
|
10286
10502
|
return {
|
|
10287
|
-
...base ??
|
|
10503
|
+
...base ?? ts6.getDefaultCompilerOptions(),
|
|
10288
10504
|
noEmit: true,
|
|
10289
10505
|
skipDefaultLibCheck: true,
|
|
10290
10506
|
skipLibCheck: true,
|
|
@@ -10292,14 +10508,14 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10292
10508
|
};
|
|
10293
10509
|
}, SCHEMA_VERSION = 1, packageVersion = (cwd, specifier) => {
|
|
10294
10510
|
const candidates = specifier === "@absolutejs/absolute" ? [
|
|
10295
|
-
|
|
10296
|
-
|
|
10511
|
+
resolve25(cwd, "node_modules", "@absolutejs", "absolute", "package.json"),
|
|
10512
|
+
resolve25(cwd, "package.json")
|
|
10297
10513
|
] : [
|
|
10298
|
-
|
|
10514
|
+
resolve25(cwd, "node_modules", ...specifier.split("/"), "package.json")
|
|
10299
10515
|
];
|
|
10300
10516
|
for (const candidate of candidates) {
|
|
10301
10517
|
try {
|
|
10302
|
-
const { version: version2 } = JSON.parse(
|
|
10518
|
+
const { version: version2 } = JSON.parse(readFileSync21(candidate, "utf-8"));
|
|
10303
10519
|
if (typeof version2 === "string")
|
|
10304
10520
|
return version2;
|
|
10305
10521
|
} catch {}
|
|
@@ -10310,16 +10526,16 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10310
10526
|
if (local) {
|
|
10311
10527
|
const file = typeName === "PackageJson" ? "packageJson.ts" : "build.ts";
|
|
10312
10528
|
try {
|
|
10313
|
-
signature += `:${statSync2(
|
|
10529
|
+
signature += `:${statSync2(resolve25(cwd, "types", file)).mtimeMs}`;
|
|
10314
10530
|
} catch {}
|
|
10315
10531
|
}
|
|
10316
10532
|
return signature;
|
|
10317
10533
|
}, cacheSlug = (specifier) => specifier.replace("@", "").split("/").join("-"), cacheFile = (cwd, typeName, specifier) => {
|
|
10318
10534
|
const name = specifier === "@absolutejs/absolute" ? typeName : `${typeName}.${cacheSlug(specifier)}`;
|
|
10319
|
-
return
|
|
10535
|
+
return resolve25(cwd, ".absolutejs", "config-schema", `${name}.json`);
|
|
10320
10536
|
}, readDiskCache = (cwd, typeName, signature, specifier) => {
|
|
10321
10537
|
try {
|
|
10322
|
-
const cached = JSON.parse(
|
|
10538
|
+
const cached = JSON.parse(readFileSync21(cacheFile(cwd, typeName, specifier), "utf-8"));
|
|
10323
10539
|
if (isRecord9(cached) && cached.signature === signature && Array.isArray(cached.fields)) {
|
|
10324
10540
|
return cached.fields;
|
|
10325
10541
|
}
|
|
@@ -10327,12 +10543,12 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10327
10543
|
return null;
|
|
10328
10544
|
}, writeDiskCache = (cwd, typeName, signature, fields, specifier) => {
|
|
10329
10545
|
try {
|
|
10330
|
-
mkdirSync9(
|
|
10546
|
+
mkdirSync9(resolve25(cwd, ".absolutejs", "config-schema"), {
|
|
10331
10547
|
recursive: true
|
|
10332
10548
|
});
|
|
10333
10549
|
writeFileSync8(cacheFile(cwd, typeName, specifier), JSON.stringify({ fields, signature }));
|
|
10334
10550
|
} catch {}
|
|
10335
|
-
}, docOf = (symbol, checker) =>
|
|
10551
|
+
}, docOf = (symbol, checker) => ts6.displayPartsToString(symbol.getDocumentationComment(checker)).trim(), typeOfSymbol = (symbol, checker) => {
|
|
10336
10552
|
const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
10337
10553
|
return declaration ? checker.getTypeOfSymbolAtLocation(symbol, declaration) : checker.getDeclaredTypeOfSymbol(symbol);
|
|
10338
10554
|
}, hasFlag = (type, flag) => (type.flags & flag) !== 0, unionParts = (type) => type.isUnion() ? type.types : [type], literalChoice = (type) => {
|
|
@@ -10348,10 +10564,10 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10348
10564
|
});
|
|
10349
10565
|
if (depth > MAX_DEPTH)
|
|
10350
10566
|
return opaque();
|
|
10351
|
-
const parts = unionParts(type).filter((part) => !hasFlag(part,
|
|
10567
|
+
const parts = unionParts(type).filter((part) => !hasFlag(part, ts6.TypeFlags.Undefined) && !hasFlag(part, ts6.TypeFlags.Null));
|
|
10352
10568
|
if (parts.length === 0)
|
|
10353
10569
|
return opaque();
|
|
10354
|
-
if (parts.every((part) => hasFlag(part,
|
|
10570
|
+
if (parts.every((part) => hasFlag(part, ts6.TypeFlags.BooleanLike))) {
|
|
10355
10571
|
return { kind: "boolean" };
|
|
10356
10572
|
}
|
|
10357
10573
|
const choices = parts.map(literalChoice);
|
|
@@ -10371,13 +10587,13 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10371
10587
|
kind: "opaque",
|
|
10372
10588
|
typeText: checker.typeToString(type)
|
|
10373
10589
|
});
|
|
10374
|
-
if (hasFlag(type,
|
|
10590
|
+
if (hasFlag(type, ts6.TypeFlags.BooleanLike))
|
|
10375
10591
|
return { kind: "boolean" };
|
|
10376
|
-
if (hasFlag(type,
|
|
10592
|
+
if (hasFlag(type, ts6.TypeFlags.NumberLike))
|
|
10377
10593
|
return { kind: "number" };
|
|
10378
|
-
if (hasFlag(type,
|
|
10594
|
+
if (hasFlag(type, ts6.TypeFlags.StringLike))
|
|
10379
10595
|
return { kind: "string" };
|
|
10380
|
-
if (!hasFlag(type,
|
|
10596
|
+
if (!hasFlag(type, ts6.TypeFlags.Object))
|
|
10381
10597
|
return opaque();
|
|
10382
10598
|
if (type.getCallSignatures().length > 0)
|
|
10383
10599
|
return opaque();
|
|
@@ -10398,7 +10614,7 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10398
10614
|
const fields = props.map((symbol) => ({
|
|
10399
10615
|
description: docOf(symbol, checker),
|
|
10400
10616
|
name: symbol.getName(),
|
|
10401
|
-
optional: (symbol.flags &
|
|
10617
|
+
optional: (symbol.flags & ts6.SymbolFlags.Optional) !== 0,
|
|
10402
10618
|
schema: toSchema(typeOfSymbol(symbol, checker), checker, depth + 1, seen)
|
|
10403
10619
|
}));
|
|
10404
10620
|
return { fields, kind: "object" };
|
|
@@ -10414,26 +10630,26 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10414
10630
|
}
|
|
10415
10631
|
return opaque();
|
|
10416
10632
|
}, introspectFrom = (cwd, specifier, typeName, options, exclude) => {
|
|
10417
|
-
const virtualPath =
|
|
10633
|
+
const virtualPath = resolve25(cwd, VIRTUAL_NAME);
|
|
10418
10634
|
const source = `import type { ${typeName} } from '${specifier}';
|
|
10419
10635
|
declare const value: ${typeName};
|
|
10420
10636
|
export { value };
|
|
10421
10637
|
`;
|
|
10422
|
-
const host2 =
|
|
10638
|
+
const host2 = ts6.createCompilerHost(options, true);
|
|
10423
10639
|
const getSourceFile = host2.getSourceFile.bind(host2);
|
|
10424
|
-
host2.getSourceFile = (fileName, languageVersion, onError, shouldCreate) => fileName === virtualPath ?
|
|
10640
|
+
host2.getSourceFile = (fileName, languageVersion, onError, shouldCreate) => fileName === virtualPath ? ts6.createSourceFile(fileName, source, languageVersion, true) : getSourceFile(fileName, languageVersion, onError, shouldCreate);
|
|
10425
10641
|
const fileExists = host2.fileExists.bind(host2);
|
|
10426
10642
|
host2.fileExists = (fileName) => fileName === virtualPath ? true : fileExists(fileName);
|
|
10427
10643
|
const readFile11 = host2.readFile.bind(host2);
|
|
10428
10644
|
host2.readFile = (fileName) => fileName === virtualPath ? source : readFile11(fileName);
|
|
10429
|
-
const program =
|
|
10645
|
+
const program = ts6.createProgram([virtualPath], options, host2);
|
|
10430
10646
|
const checker = program.getTypeChecker();
|
|
10431
10647
|
const sourceFile = program.getSourceFile(virtualPath);
|
|
10432
10648
|
if (!sourceFile)
|
|
10433
10649
|
return [];
|
|
10434
10650
|
const nodes = [];
|
|
10435
10651
|
sourceFile.forEachChild((node) => {
|
|
10436
|
-
if (!
|
|
10652
|
+
if (!ts6.isVariableStatement(node))
|
|
10437
10653
|
return;
|
|
10438
10654
|
const [declaration] = node.declarationList.declarations;
|
|
10439
10655
|
if (!declaration)
|
|
@@ -10446,7 +10662,7 @@ export { value };
|
|
|
10446
10662
|
nodes.push({
|
|
10447
10663
|
description: docOf(symbol, checker),
|
|
10448
10664
|
name,
|
|
10449
|
-
optional: (symbol.flags &
|
|
10665
|
+
optional: (symbol.flags & ts6.SymbolFlags.Optional) !== 0,
|
|
10450
10666
|
schema: toSchema(typeOfSymbol(symbol, checker), checker, 1, new Set)
|
|
10451
10667
|
});
|
|
10452
10668
|
}
|
|
@@ -10457,7 +10673,7 @@ export { value };
|
|
|
10457
10673
|
const cached = cache.get(cacheKey);
|
|
10458
10674
|
if (cached)
|
|
10459
10675
|
return cached;
|
|
10460
|
-
const local = specifier === "@absolutejs/absolute" && isFrameworkRepo(cwd) && existsSync18(
|
|
10676
|
+
const local = specifier === "@absolutejs/absolute" && isFrameworkRepo(cwd) && existsSync18(resolve25(cwd, "types/index.ts"));
|
|
10461
10677
|
const signature = cacheSignature(cwd, typeName, local, specifier);
|
|
10462
10678
|
const fromDisk = readDiskCache(cwd, typeName, signature, specifier);
|
|
10463
10679
|
if (fromDisk) {
|
|
@@ -10484,59 +10700,59 @@ var init_fromType = __esm(() => {
|
|
|
10484
10700
|
});
|
|
10485
10701
|
|
|
10486
10702
|
// src/cli/config/absolute/resolveAbsoluteConfig.ts
|
|
10487
|
-
import
|
|
10488
|
-
import { existsSync as existsSync19, readFileSync as
|
|
10489
|
-
import { resolve as
|
|
10703
|
+
import ts7 from "typescript";
|
|
10704
|
+
import { existsSync as existsSync19, readFileSync as readFileSync22 } from "fs";
|
|
10705
|
+
import { resolve as resolve26 } from "path";
|
|
10490
10706
|
var CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath = (cwd, override) => {
|
|
10491
10707
|
if (override) {
|
|
10492
|
-
const resolved =
|
|
10708
|
+
const resolved = resolve26(cwd, override);
|
|
10493
10709
|
return existsSync19(resolved) ? resolved : null;
|
|
10494
10710
|
}
|
|
10495
10711
|
for (const name of CONFIG_CANDIDATES2) {
|
|
10496
|
-
const candidate =
|
|
10712
|
+
const candidate = resolve26(cwd, name);
|
|
10497
10713
|
if (existsSync19(candidate))
|
|
10498
10714
|
return candidate;
|
|
10499
10715
|
}
|
|
10500
10716
|
return null;
|
|
10501
|
-
}, parseSource = (configPath2,
|
|
10717
|
+
}, parseSource = (configPath2, text2) => ts7.createSourceFile(configPath2, text2, ts7.ScriptTarget.Latest, true), findConfigObject = (sourceFile) => {
|
|
10502
10718
|
const pending = [sourceFile];
|
|
10503
10719
|
while (pending.length > 0) {
|
|
10504
10720
|
const node = pending.pop();
|
|
10505
10721
|
if (!node)
|
|
10506
10722
|
continue;
|
|
10507
|
-
const [firstArgument] =
|
|
10508
|
-
if (
|
|
10723
|
+
const [firstArgument] = ts7.isCallExpression(node) ? node.arguments : [];
|
|
10724
|
+
if (ts7.isCallExpression(node) && ts7.isIdentifier(node.expression) && node.expression.text === "defineConfig" && firstArgument && ts7.isObjectLiteralExpression(firstArgument)) {
|
|
10509
10725
|
return firstArgument;
|
|
10510
10726
|
}
|
|
10511
|
-
if (
|
|
10727
|
+
if (ts7.isExportAssignment(node) && ts7.isObjectLiteralExpression(node.expression)) {
|
|
10512
10728
|
return node.expression;
|
|
10513
10729
|
}
|
|
10514
10730
|
node.forEachChild((child) => pending.push(child));
|
|
10515
10731
|
}
|
|
10516
10732
|
return null;
|
|
10517
10733
|
}, parseConfigObject = (configPath2) => {
|
|
10518
|
-
const
|
|
10519
|
-
return { object: findConfigObject(parseSource(configPath2,
|
|
10734
|
+
const text2 = readFileSync22(configPath2, "utf-8");
|
|
10735
|
+
return { object: findConfigObject(parseSource(configPath2, text2)), text: text2 };
|
|
10520
10736
|
}, evalLiteral = (node) => {
|
|
10521
|
-
if (
|
|
10737
|
+
if (ts7.isStringLiteralLike(node)) {
|
|
10522
10738
|
return { opaque: false, value: node.text };
|
|
10523
10739
|
}
|
|
10524
|
-
if (node.kind ===
|
|
10740
|
+
if (node.kind === ts7.SyntaxKind.TrueKeyword) {
|
|
10525
10741
|
return { opaque: false, value: true };
|
|
10526
10742
|
}
|
|
10527
|
-
if (node.kind ===
|
|
10743
|
+
if (node.kind === ts7.SyntaxKind.FalseKeyword) {
|
|
10528
10744
|
return { opaque: false, value: false };
|
|
10529
10745
|
}
|
|
10530
|
-
if (node.kind ===
|
|
10746
|
+
if (node.kind === ts7.SyntaxKind.NullKeyword) {
|
|
10531
10747
|
return { opaque: false, value: null };
|
|
10532
10748
|
}
|
|
10533
|
-
if (
|
|
10749
|
+
if (ts7.isNumericLiteral(node)) {
|
|
10534
10750
|
return { opaque: false, value: Number(node.text) };
|
|
10535
10751
|
}
|
|
10536
|
-
if (
|
|
10752
|
+
if (ts7.isPrefixUnaryExpression(node) && node.operator === ts7.SyntaxKind.MinusToken && ts7.isNumericLiteral(node.operand)) {
|
|
10537
10753
|
return { opaque: false, value: -Number(node.operand.text) };
|
|
10538
10754
|
}
|
|
10539
|
-
if (
|
|
10755
|
+
if (ts7.isArrayLiteralExpression(node)) {
|
|
10540
10756
|
const items = [];
|
|
10541
10757
|
for (const element of node.elements) {
|
|
10542
10758
|
const result = evalLiteral(element);
|
|
@@ -10546,28 +10762,28 @@ var CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath = (cwd, override) => {
|
|
|
10546
10762
|
}
|
|
10547
10763
|
return { opaque: false, value: items };
|
|
10548
10764
|
}
|
|
10549
|
-
if (
|
|
10550
|
-
const
|
|
10765
|
+
if (ts7.isObjectLiteralExpression(node)) {
|
|
10766
|
+
const object3 = {};
|
|
10551
10767
|
for (const property of node.properties) {
|
|
10552
|
-
if (!
|
|
10768
|
+
if (!ts7.isPropertyAssignment(property) || !(ts7.isIdentifier(property.name) || ts7.isStringLiteral(property.name))) {
|
|
10553
10769
|
return { opaque: true, value: undefined };
|
|
10554
10770
|
}
|
|
10555
10771
|
const result = evalLiteral(property.initializer);
|
|
10556
10772
|
if (result.opaque)
|
|
10557
10773
|
return { opaque: true, value: undefined };
|
|
10558
|
-
|
|
10774
|
+
object3[property.name.text] = result.value;
|
|
10559
10775
|
}
|
|
10560
|
-
return { opaque: false, value:
|
|
10776
|
+
return { opaque: false, value: object3 };
|
|
10561
10777
|
}
|
|
10562
10778
|
return { opaque: true, value: undefined };
|
|
10563
10779
|
}, readCurrent = (configPath2) => {
|
|
10564
10780
|
const current = {};
|
|
10565
10781
|
const opaqueKeys = [];
|
|
10566
|
-
const { object:
|
|
10567
|
-
if (!
|
|
10782
|
+
const { object: object3 } = parseConfigObject(configPath2);
|
|
10783
|
+
if (!object3)
|
|
10568
10784
|
return { current, opaqueKeys };
|
|
10569
|
-
for (const property of
|
|
10570
|
-
if (!
|
|
10785
|
+
for (const property of object3.properties) {
|
|
10786
|
+
if (!ts7.isPropertyAssignment(property) || !(ts7.isIdentifier(property.name) || ts7.isStringLiteral(property.name))) {
|
|
10571
10787
|
continue;
|
|
10572
10788
|
}
|
|
10573
10789
|
const name = property.name.text;
|
|
@@ -10726,8 +10942,8 @@ var init_frameworks = __esm(() => {
|
|
|
10726
10942
|
});
|
|
10727
10943
|
|
|
10728
10944
|
// src/cli/generate/context.ts
|
|
10729
|
-
import { dirname as dirname16, isAbsolute as isAbsolute5, join as
|
|
10730
|
-
var asString = (value) => typeof value === "string" ? value : undefined, isRecord10 = (value) => typeof value === "object" && value !== null, resolveDir = (cwd, value) => isAbsolute5(value) ? value :
|
|
10945
|
+
import { dirname as dirname16, isAbsolute as isAbsolute5, join as join27, relative as relative15, resolve as resolve27 } from "path";
|
|
10946
|
+
var asString = (value) => typeof value === "string" ? value : undefined, isRecord10 = (value) => typeof value === "object" && value !== null, resolveDir = (cwd, value) => isAbsolute5(value) ? value : resolve27(cwd, value), resolveStylesDir = (cwd, config) => {
|
|
10731
10947
|
const styles = config.stylesConfig;
|
|
10732
10948
|
if (typeof styles === "string")
|
|
10733
10949
|
return resolveDir(cwd, styles);
|
|
@@ -10736,10 +10952,10 @@ var asString = (value) => typeof value === "string" ? value : undefined, isRecor
|
|
|
10736
10952
|
if (indexes)
|
|
10737
10953
|
return resolveDir(cwd, indexes);
|
|
10738
10954
|
}
|
|
10739
|
-
return
|
|
10955
|
+
return resolve27(cwd, "src/frontend/styles/indexes");
|
|
10740
10956
|
}, configuredFrameworks = (project) => FRAMEWORK_KEYS2.filter((key) => project.frameworkDirs[key] !== undefined), frontendRootFor = (project, framework) => {
|
|
10741
10957
|
const dir = project.frameworkDirs[framework];
|
|
10742
|
-
return dir ? dirname16(dir) :
|
|
10958
|
+
return dir ? dirname16(dir) : resolve27(project.cwd, "src/frontend");
|
|
10743
10959
|
}, resolveProject = async (cwd, configOverride) => {
|
|
10744
10960
|
const loaded = await loadConfig(configOverride);
|
|
10745
10961
|
const config = isRecord10(loaded) ? loaded : {};
|
|
@@ -10789,8 +11005,8 @@ var asString = (value) => typeof value === "string" ? value : undefined, isRecor
|
|
|
10789
11005
|
message: `Multiple frameworks configured (${configured.join(", ")}). Pass --framework <name>.`,
|
|
10790
11006
|
ok: false
|
|
10791
11007
|
};
|
|
10792
|
-
}, sharedDirFor = (project, framework) =>
|
|
10793
|
-
const rel =
|
|
11008
|
+
}, sharedDirFor = (project, framework) => join27(frontendRootFor(project, framework), "shared"), toModuleSpecifier = (fromDir, toFileNoExt) => {
|
|
11009
|
+
const rel = relative15(fromDir, toFileNoExt).split("\\").join("/");
|
|
10794
11010
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
10795
11011
|
};
|
|
10796
11012
|
var init_context = __esm(() => {
|
|
@@ -10817,78 +11033,78 @@ var emptyOutcome = () => ({
|
|
|
10817
11033
|
});
|
|
10818
11034
|
|
|
10819
11035
|
// src/cli/generate/routeWiring.ts
|
|
10820
|
-
import
|
|
10821
|
-
import { existsSync as existsSync20, readFileSync as
|
|
10822
|
-
import { dirname as dirname17, join as
|
|
11036
|
+
import ts8 from "typescript";
|
|
11037
|
+
import { existsSync as existsSync20, readFileSync as readFileSync23, readdirSync as readdirSync4, writeFileSync as writeFileSync9 } from "fs";
|
|
11038
|
+
import { dirname as dirname17, join as join28 } from "path";
|
|
10823
11039
|
var DEFAULT_SEPARATOR = `
|
|
10824
|
-
`, BOUNDARY_USE, applyEdits = (
|
|
11040
|
+
`, BOUNDARY_USE, applyEdits = (text2, edits) => {
|
|
10825
11041
|
const ordered = [...edits].sort((first, second) => second.start - first.start);
|
|
10826
|
-
let output =
|
|
11042
|
+
let output = text2;
|
|
10827
11043
|
for (const edit of ordered) {
|
|
10828
11044
|
output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);
|
|
10829
11045
|
}
|
|
10830
11046
|
return output;
|
|
10831
|
-
}, stripExtension = (path) => path.replace(/\.[^./\\]+$/, ""), parse2 = (path,
|
|
11047
|
+
}, stripExtension = (path) => path.replace(/\.[^./\\]+$/, ""), parse2 = (path, text2) => ts8.createSourceFile(path, text2, ts8.ScriptTarget.Latest, true), findElysiaNew = (sourceFile) => {
|
|
10832
11048
|
let found = null;
|
|
10833
11049
|
const visit = (node) => {
|
|
10834
11050
|
if (found)
|
|
10835
11051
|
return;
|
|
10836
|
-
if (
|
|
11052
|
+
if (ts8.isNewExpression(node) && ts8.isIdentifier(node.expression) && node.expression.text === "Elysia") {
|
|
10837
11053
|
found = node;
|
|
10838
11054
|
return;
|
|
10839
11055
|
}
|
|
10840
|
-
|
|
11056
|
+
ts8.forEachChild(node, visit);
|
|
10841
11057
|
};
|
|
10842
11058
|
visit(sourceFile);
|
|
10843
11059
|
return found;
|
|
10844
11060
|
}, climbChain = (start2) => {
|
|
10845
11061
|
let top = start2;
|
|
10846
|
-
while (
|
|
11062
|
+
while (ts8.isPropertyAccessExpression(top.parent) && top.parent.expression === top && ts8.isCallExpression(top.parent.parent) && top.parent.parent.expression === top.parent) {
|
|
10847
11063
|
top = top.parent.parent;
|
|
10848
11064
|
}
|
|
10849
11065
|
return top;
|
|
10850
11066
|
}, collectCalls = (top) => {
|
|
10851
11067
|
const calls = [];
|
|
10852
11068
|
let node = top;
|
|
10853
|
-
while (
|
|
11069
|
+
while (ts8.isCallExpression(node) && ts8.isPropertyAccessExpression(node.expression)) {
|
|
10854
11070
|
calls.push(node);
|
|
10855
11071
|
node = node.expression.expression;
|
|
10856
11072
|
}
|
|
10857
11073
|
return calls.reverse();
|
|
10858
|
-
}, methodName = (call) =>
|
|
11074
|
+
}, methodName = (call) => ts8.isPropertyAccessExpression(call.expression) ? call.expression.name.text : null, isBoundary = (call) => {
|
|
10859
11075
|
const name = methodName(call);
|
|
10860
11076
|
const [arg] = call.arguments;
|
|
10861
|
-
if (name === "use" && arg &&
|
|
11077
|
+
if (name === "use" && arg && ts8.isIdentifier(arg)) {
|
|
10862
11078
|
return BOUNDARY_USE.has(arg.text);
|
|
10863
11079
|
}
|
|
10864
|
-
return name === "on" && arg !== undefined &&
|
|
10865
|
-
}, receiverEnd = (call) =>
|
|
10866
|
-
const match =
|
|
11080
|
+
return name === "on" && arg !== undefined && ts8.isStringLiteralLike(arg);
|
|
11081
|
+
}, receiverEnd = (call) => ts8.isPropertyAccessExpression(call.expression) ? call.expression.expression.getEnd() : call.getEnd(), separatorBefore = (text2, offset) => {
|
|
11082
|
+
const match = text2.slice(offset).match(/^(\s*\n[ \t]*)\./);
|
|
10867
11083
|
return match ? match[1] : DEFAULT_SEPARATOR;
|
|
10868
|
-
}, findRouteInsertion = (
|
|
11084
|
+
}, findRouteInsertion = (text2, top) => {
|
|
10869
11085
|
const calls = collectCalls(top);
|
|
10870
11086
|
const boundary = calls.find(isBoundary);
|
|
10871
11087
|
if (boundary) {
|
|
10872
11088
|
const offset2 = receiverEnd(boundary);
|
|
10873
|
-
return { offset: offset2, separator: separatorBefore(
|
|
11089
|
+
return { offset: offset2, separator: separatorBefore(text2, offset2) };
|
|
10874
11090
|
}
|
|
10875
11091
|
const last = calls[calls.length - 1];
|
|
10876
11092
|
const offset = last ? last.getEnd() : top.getEnd();
|
|
10877
11093
|
const sepProbe = last ? receiverEnd(last) : top.getEnd();
|
|
10878
|
-
return { offset, separator: separatorBefore(
|
|
10879
|
-
}, namedImportDecl = (sourceFile, module) => sourceFile.statements.find((statement) =>
|
|
11094
|
+
return { offset, separator: separatorBefore(text2, sepProbe) };
|
|
11095
|
+
}, namedImportDecl = (sourceFile, module) => sourceFile.statements.find((statement) => ts8.isImportDeclaration(statement) && ts8.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === module && statement.importClause !== undefined && !statement.importClause.isTypeOnly && statement.importClause.namedBindings !== undefined && ts8.isNamedImports(statement.importClause.namedBindings)), importedNames = (decl) => {
|
|
10880
11096
|
const bindings = decl.importClause?.namedBindings;
|
|
10881
|
-
if (!bindings || !
|
|
11097
|
+
if (!bindings || !ts8.isNamedImports(bindings))
|
|
10882
11098
|
return new Set;
|
|
10883
11099
|
return new Set(bindings.elements.map((element) => (element.propertyName ?? element.name).text));
|
|
10884
11100
|
}, lastImportEnd = (sourceFile) => {
|
|
10885
11101
|
let end = 0;
|
|
10886
11102
|
for (const statement of sourceFile.statements) {
|
|
10887
|
-
if (
|
|
11103
|
+
if (ts8.isImportDeclaration(statement))
|
|
10888
11104
|
end = statement.getEnd();
|
|
10889
11105
|
}
|
|
10890
11106
|
return end;
|
|
10891
|
-
}, hasTypeImport = (sourceFile, module, local) => sourceFile.statements.some((statement) =>
|
|
11107
|
+
}, hasTypeImport = (sourceFile, module, local) => sourceFile.statements.some((statement) => ts8.isImportDeclaration(statement) && ts8.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === module && statement.getText().includes(local)), renderTypeImport = (spec) => {
|
|
10892
11108
|
if (spec.kind === "typeDefault") {
|
|
10893
11109
|
return `import type ${spec.local} from '${spec.module}';`;
|
|
10894
11110
|
}
|
|
@@ -10908,7 +11124,7 @@ var DEFAULT_SEPARATOR = `
|
|
|
10908
11124
|
return byModule;
|
|
10909
11125
|
}, mergeNamedEdit = (decl, sourceFile, missing) => {
|
|
10910
11126
|
const bindings = decl.importClause?.namedBindings;
|
|
10911
|
-
if (!bindings || !
|
|
11127
|
+
if (!bindings || !ts8.isNamedImports(bindings))
|
|
10912
11128
|
return null;
|
|
10913
11129
|
const { elements } = bindings;
|
|
10914
11130
|
const additions = missing.join(", ");
|
|
@@ -10969,7 +11185,7 @@ ${newLines.join(`
|
|
|
10969
11185
|
}, hasChain = (path) => {
|
|
10970
11186
|
if (!existsSync20(path))
|
|
10971
11187
|
return false;
|
|
10972
|
-
const sourceFile = parse2(path,
|
|
11188
|
+
const sourceFile = parse2(path, readFileSync23(path, "utf-8"));
|
|
10973
11189
|
const found = findElysiaNew(sourceFile);
|
|
10974
11190
|
return found !== null;
|
|
10975
11191
|
}, firstChainFile = (pluginsDir) => {
|
|
@@ -10978,14 +11194,14 @@ ${newLines.join(`
|
|
|
10978
11194
|
for (const name of readdirSync4(pluginsDir)) {
|
|
10979
11195
|
if (!name.endsWith(".ts"))
|
|
10980
11196
|
continue;
|
|
10981
|
-
const candidate =
|
|
11197
|
+
const candidate = join28(pluginsDir, name);
|
|
10982
11198
|
if (hasChain(candidate))
|
|
10983
11199
|
return candidate;
|
|
10984
11200
|
}
|
|
10985
11201
|
return null;
|
|
10986
11202
|
}, findRoutingFile = (serverEntry) => {
|
|
10987
|
-
const pluginsDir =
|
|
10988
|
-
const preferred =
|
|
11203
|
+
const pluginsDir = join28(dirname17(serverEntry), "plugins");
|
|
11204
|
+
const preferred = join28(pluginsDir, "pagesPlugin.ts");
|
|
10989
11205
|
if (hasChain(preferred))
|
|
10990
11206
|
return preferred;
|
|
10991
11207
|
const scanned = firstChainFile(pluginsDir);
|
|
@@ -11018,20 +11234,20 @@ ${newLines.join(`
|
|
|
11018
11234
|
};
|
|
11019
11235
|
if (!hasChain(serverEntry))
|
|
11020
11236
|
return fallback;
|
|
11021
|
-
const
|
|
11022
|
-
const sourceFile = parse2(serverEntry,
|
|
11237
|
+
const text2 = readFileSync23(serverEntry, "utf-8");
|
|
11238
|
+
const sourceFile = parse2(serverEntry, text2);
|
|
11023
11239
|
const newExpr = findElysiaNew(sourceFile);
|
|
11024
11240
|
if (!newExpr)
|
|
11025
11241
|
return fallback;
|
|
11026
11242
|
const top = climbChain(newExpr);
|
|
11027
|
-
const { offset, separator } = findRouteInsertion(
|
|
11243
|
+
const { offset, separator } = findRouteInsertion(text2, top);
|
|
11028
11244
|
const edits = buildImportEdits(sourceFile, specs);
|
|
11029
11245
|
edits.push({
|
|
11030
11246
|
end: offset,
|
|
11031
11247
|
start: offset,
|
|
11032
11248
|
text: `${separator}.use(${pluginName})`
|
|
11033
11249
|
});
|
|
11034
|
-
writeFileSync9(serverEntry, applyEdits(
|
|
11250
|
+
writeFileSync9(serverEntry, applyEdits(text2, edits), "utf-8");
|
|
11035
11251
|
return { kind: "edited", routingFile: serverEntry };
|
|
11036
11252
|
}, wireRoute = (input) => {
|
|
11037
11253
|
const routingFile = findRoutingFile(input.serverEntry);
|
|
@@ -11047,8 +11263,8 @@ ${newLines.join(`
|
|
|
11047
11263
|
${routeExpr}`
|
|
11048
11264
|
};
|
|
11049
11265
|
}
|
|
11050
|
-
const
|
|
11051
|
-
const sourceFile = parse2(routingFile,
|
|
11266
|
+
const text2 = readFileSync23(routingFile, "utf-8");
|
|
11267
|
+
const sourceFile = parse2(routingFile, text2);
|
|
11052
11268
|
const newExpr = findElysiaNew(sourceFile);
|
|
11053
11269
|
if (!newExpr) {
|
|
11054
11270
|
return {
|
|
@@ -11060,14 +11276,14 @@ ${routeExpr}`
|
|
|
11060
11276
|
};
|
|
11061
11277
|
}
|
|
11062
11278
|
const top = climbChain(newExpr);
|
|
11063
|
-
const { offset, separator } = findRouteInsertion(
|
|
11279
|
+
const { offset, separator } = findRouteInsertion(text2, top);
|
|
11064
11280
|
const edits = buildImportEdits(sourceFile, specs);
|
|
11065
11281
|
edits.push({
|
|
11066
11282
|
end: offset,
|
|
11067
11283
|
start: offset,
|
|
11068
11284
|
text: `${separator}${routeExpr}`
|
|
11069
11285
|
});
|
|
11070
|
-
writeFileSync9(routingFile, applyEdits(
|
|
11286
|
+
writeFileSync9(routingFile, applyEdits(text2, edits), "utf-8");
|
|
11071
11287
|
return { kind: "edited", routingFile };
|
|
11072
11288
|
};
|
|
11073
11289
|
var init_routeWiring = __esm(() => {
|
|
@@ -11077,7 +11293,7 @@ var init_routeWiring = __esm(() => {
|
|
|
11077
11293
|
|
|
11078
11294
|
// src/cli/generate/generateApi.ts
|
|
11079
11295
|
import { existsSync as existsSync21, mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
11080
|
-
import { dirname as dirname18, join as
|
|
11296
|
+
import { dirname as dirname18, join as join29 } from "path";
|
|
11081
11297
|
var apiPluginTemplate = (pluginName, base) => `import { Elysia } from 'elysia';
|
|
11082
11298
|
|
|
11083
11299
|
export const ${pluginName} = new Elysia()
|
|
@@ -11089,8 +11305,8 @@ export const ${pluginName} = new Elysia()
|
|
|
11089
11305
|
const pluginName = `${camel}Plugin`;
|
|
11090
11306
|
const base = `/api/${kebab}`;
|
|
11091
11307
|
const outcome = { ...emptyOutcome(), route: base };
|
|
11092
|
-
const pluginsDir =
|
|
11093
|
-
const fileAbs =
|
|
11308
|
+
const pluginsDir = join29(dirname18(project.serverEntry), "plugins");
|
|
11309
|
+
const fileAbs = join29(pluginsDir, `${pluginName}.ts`);
|
|
11094
11310
|
if (existsSync21(fileAbs)) {
|
|
11095
11311
|
outcome.notes.push(`${pluginName} already exists at ${fileAbs} \u2014 skipped.`);
|
|
11096
11312
|
return outcome;
|
|
@@ -11165,7 +11381,7 @@ var init_componentTemplates = __esm(() => {
|
|
|
11165
11381
|
|
|
11166
11382
|
// src/cli/generate/generateComponent.ts
|
|
11167
11383
|
import { existsSync as existsSync22, mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "fs";
|
|
11168
|
-
import { dirname as dirname19, join as
|
|
11384
|
+
import { dirname as dirname19, join as join30 } from "path";
|
|
11169
11385
|
var generateComponent = (project, framework, rawName) => {
|
|
11170
11386
|
const def = frameworks6[framework];
|
|
11171
11387
|
const pascal = toPascalCase(rawName);
|
|
@@ -11176,7 +11392,7 @@ var generateComponent = (project, framework, rawName) => {
|
|
|
11176
11392
|
outcome.manual = { reason: "framework directory missing", snippet: "" };
|
|
11177
11393
|
return outcome;
|
|
11178
11394
|
}
|
|
11179
|
-
const fileAbs =
|
|
11395
|
+
const fileAbs = join30(frameworkDir, "components", def.componentFile({ kebab, pascal }));
|
|
11180
11396
|
if (existsSync22(fileAbs)) {
|
|
11181
11397
|
outcome.notes.push(`${pascal} already exists at ${fileAbs} \u2014 skipped.`);
|
|
11182
11398
|
return outcome;
|
|
@@ -11196,36 +11412,36 @@ var init_generateComponent = __esm(() => {
|
|
|
11196
11412
|
});
|
|
11197
11413
|
|
|
11198
11414
|
// src/cli/generate/cssStrategy.ts
|
|
11199
|
-
import
|
|
11415
|
+
import ts9 from "typescript";
|
|
11200
11416
|
import { existsSync as existsSync23 } from "fs";
|
|
11201
|
-
import { join as
|
|
11417
|
+
import { join as join31 } from "path";
|
|
11202
11418
|
var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
11203
11419
|
margin: 0 auto;
|
|
11204
11420
|
max-width: 64rem;
|
|
11205
11421
|
padding: 2rem;
|
|
11206
11422
|
}
|
|
11207
11423
|
`, cssAssetArg = (node) => {
|
|
11208
|
-
if (!
|
|
11424
|
+
if (!ts9.isCallExpression(node) || !ts9.isIdentifier(node.expression) || node.expression.text !== "asset") {
|
|
11209
11425
|
return null;
|
|
11210
11426
|
}
|
|
11211
11427
|
const [, arg] = node.arguments;
|
|
11212
|
-
if (arg &&
|
|
11428
|
+
if (arg && ts9.isStringLiteralLike(arg) && arg.text.endsWith(CSS_SUFFIX)) {
|
|
11213
11429
|
return arg.text;
|
|
11214
11430
|
}
|
|
11215
11431
|
return null;
|
|
11216
11432
|
}, detectSharedKey = (routingText) => {
|
|
11217
|
-
const sourceFile =
|
|
11433
|
+
const sourceFile = ts9.createSourceFile("routing.ts", routingText, ts9.ScriptTarget.Latest, true);
|
|
11218
11434
|
let hoisted = null;
|
|
11219
11435
|
const inlineCounts = new Map;
|
|
11220
11436
|
const visit = (node) => {
|
|
11221
11437
|
const key = cssAssetArg(node);
|
|
11222
11438
|
if (key) {
|
|
11223
|
-
if (
|
|
11439
|
+
if (ts9.isVariableDeclaration(node.parent))
|
|
11224
11440
|
hoisted ??= key;
|
|
11225
11441
|
else
|
|
11226
11442
|
inlineCounts.set(key, (inlineCounts.get(key) ?? 0) + 1);
|
|
11227
11443
|
}
|
|
11228
|
-
|
|
11444
|
+
ts9.forEachChild(node, visit);
|
|
11229
11445
|
};
|
|
11230
11446
|
visit(sourceFile);
|
|
11231
11447
|
if (hoisted)
|
|
@@ -11237,7 +11453,7 @@ var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
|
11237
11453
|
return null;
|
|
11238
11454
|
}, fileForKey = (stylesDir, assetKey2) => {
|
|
11239
11455
|
const base = assetKey2.endsWith(CSS_SUFFIX) ? assetKey2.slice(0, -CSS_SUFFIX.length) : assetKey2;
|
|
11240
|
-
return
|
|
11456
|
+
return join31(stylesDir, `${toKebabCase(base)}.css`);
|
|
11241
11457
|
}, planCss = (routingText, stylesDir, pascal, kebab) => {
|
|
11242
11458
|
const sharedKey = detectSharedKey(routingText);
|
|
11243
11459
|
if (sharedKey) {
|
|
@@ -11250,7 +11466,7 @@ var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
|
11250
11466
|
shared: true
|
|
11251
11467
|
};
|
|
11252
11468
|
}
|
|
11253
|
-
const cssFileAbs =
|
|
11469
|
+
const cssFileAbs = join31(stylesDir, `${kebab}.css`);
|
|
11254
11470
|
return {
|
|
11255
11471
|
assetKey: `${pascal}${CSS_SUFFIX}`,
|
|
11256
11472
|
contents: DEFAULT_CSS,
|
|
@@ -11262,8 +11478,8 @@ var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
|
11262
11478
|
var init_cssStrategy = () => {};
|
|
11263
11479
|
|
|
11264
11480
|
// src/cli/generate/navData.ts
|
|
11265
|
-
import
|
|
11266
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync12, readFileSync as
|
|
11481
|
+
import ts10 from "typescript";
|
|
11482
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync12, readFileSync as readFileSync24, writeFileSync as writeFileSync12 } from "fs";
|
|
11267
11483
|
import { dirname as dirname20 } from "path";
|
|
11268
11484
|
var NAV_DATA_TEMPLATE = `type NavItem = {
|
|
11269
11485
|
href: string;
|
|
@@ -11276,24 +11492,24 @@ export const navData: NavItem[] = [];
|
|
|
11276
11492
|
const visit = (node) => {
|
|
11277
11493
|
if (found)
|
|
11278
11494
|
return;
|
|
11279
|
-
if (
|
|
11495
|
+
if (ts10.isVariableDeclaration(node) && ts10.isIdentifier(node.name) && node.name.text === "navData" && node.initializer && ts10.isArrayLiteralExpression(node.initializer)) {
|
|
11280
11496
|
found = node.initializer;
|
|
11281
11497
|
return;
|
|
11282
11498
|
}
|
|
11283
|
-
|
|
11499
|
+
ts10.forEachChild(node, visit);
|
|
11284
11500
|
};
|
|
11285
11501
|
visit(sourceFile);
|
|
11286
11502
|
return found;
|
|
11287
|
-
}, readStringProperty = (
|
|
11288
|
-
const property =
|
|
11289
|
-
if (!property || !
|
|
11503
|
+
}, readStringProperty = (object3, name) => {
|
|
11504
|
+
const property = object3.properties.find((candidate) => ts10.isPropertyAssignment(candidate) && ts10.isIdentifier(candidate.name) && candidate.name.text === name);
|
|
11505
|
+
if (!property || !ts10.isStringLiteralLike(property.initializer)) {
|
|
11290
11506
|
return null;
|
|
11291
11507
|
}
|
|
11292
11508
|
return property.initializer.text;
|
|
11293
11509
|
}, parseNavItems = (array) => {
|
|
11294
11510
|
const items = [];
|
|
11295
11511
|
for (const element of array.elements) {
|
|
11296
|
-
if (!
|
|
11512
|
+
if (!ts10.isObjectLiteralExpression(element))
|
|
11297
11513
|
continue;
|
|
11298
11514
|
const href = readStringProperty(element, "href");
|
|
11299
11515
|
const label = readStringProperty(element, "label");
|
|
@@ -11304,40 +11520,40 @@ export const navData: NavItem[] = [];
|
|
|
11304
11520
|
}, readNavItems = (navDataPath) => {
|
|
11305
11521
|
if (!existsSync24(navDataPath))
|
|
11306
11522
|
return [];
|
|
11307
|
-
const
|
|
11308
|
-
const sourceFile =
|
|
11523
|
+
const text2 = readFileSync24(navDataPath, "utf-8");
|
|
11524
|
+
const sourceFile = ts10.createSourceFile(navDataPath, text2, ts10.ScriptTarget.Latest, true);
|
|
11309
11525
|
const array = findNavArray(sourceFile);
|
|
11310
11526
|
return array ? parseNavItems(array) : [];
|
|
11311
|
-
}, indentOf = (
|
|
11527
|
+
}, indentOf = (text2, position) => {
|
|
11312
11528
|
let index = position;
|
|
11313
|
-
while (index > 0 &&
|
|
11529
|
+
while (index > 0 && text2[index - 1] !== `
|
|
11314
11530
|
`)
|
|
11315
11531
|
index -= 1;
|
|
11316
11532
|
let end = index;
|
|
11317
|
-
while (
|
|
11533
|
+
while (text2[end] === " " || text2[end] === "\t")
|
|
11318
11534
|
end += 1;
|
|
11319
|
-
return
|
|
11320
|
-
}, insertElement = (
|
|
11535
|
+
return text2.slice(index, end);
|
|
11536
|
+
}, insertElement = (text2, array, sourceFile, entry) => {
|
|
11321
11537
|
const { elements } = array;
|
|
11322
11538
|
if (elements.length === 0) {
|
|
11323
11539
|
const insertAt2 = array.getStart(sourceFile) + 1;
|
|
11324
|
-
const indent2 = `${indentOf(
|
|
11540
|
+
const indent2 = `${indentOf(text2, array.getStart(sourceFile))} `;
|
|
11325
11541
|
const insertion2 = `
|
|
11326
11542
|
${indent2}${entry}
|
|
11327
|
-
${indentOf(
|
|
11328
|
-
return
|
|
11543
|
+
${indentOf(text2, array.getStart(sourceFile))}`;
|
|
11544
|
+
return text2.slice(0, insertAt2) + insertion2 + text2.slice(insertAt2);
|
|
11329
11545
|
}
|
|
11330
11546
|
const last = elements[elements.length - 1];
|
|
11331
11547
|
if (!last)
|
|
11332
|
-
return
|
|
11333
|
-
const indent = indentOf(
|
|
11548
|
+
return text2;
|
|
11549
|
+
const indent = indentOf(text2, last.getStart(sourceFile));
|
|
11334
11550
|
let insertAt = last.getEnd();
|
|
11335
|
-
const hasComma =
|
|
11551
|
+
const hasComma = text2[insertAt] === ",";
|
|
11336
11552
|
if (hasComma)
|
|
11337
11553
|
insertAt += 1;
|
|
11338
11554
|
const insertion = `${hasComma ? "" : ","}
|
|
11339
11555
|
${indent}${entry}`;
|
|
11340
|
-
return
|
|
11556
|
+
return text2.slice(0, insertAt) + insertion + text2.slice(insertAt);
|
|
11341
11557
|
}, upsertNavItem = (navDataPath, item) => {
|
|
11342
11558
|
const created = !existsSync24(navDataPath);
|
|
11343
11559
|
if (created) {
|
|
@@ -11348,24 +11564,24 @@ ${indent}${entry}`;
|
|
|
11348
11564
|
if (existing.some((candidate) => candidate.href === item.href)) {
|
|
11349
11565
|
return { changed: created, created, items: existing };
|
|
11350
11566
|
}
|
|
11351
|
-
const
|
|
11352
|
-
const sourceFile =
|
|
11567
|
+
const text2 = readFileSync24(navDataPath, "utf-8");
|
|
11568
|
+
const sourceFile = ts10.createSourceFile(navDataPath, text2, ts10.ScriptTarget.Latest, true);
|
|
11353
11569
|
const array = findNavArray(sourceFile);
|
|
11354
11570
|
if (!array)
|
|
11355
11571
|
return { changed: created, created, items: existing };
|
|
11356
11572
|
const entry = `{ href: '${item.href}', label: '${item.label}' }`;
|
|
11357
|
-
writeFileSync12(navDataPath, insertElement(
|
|
11573
|
+
writeFileSync12(navDataPath, insertElement(text2, array, sourceFile, entry), "utf-8");
|
|
11358
11574
|
return { changed: true, created, items: [...existing, item] };
|
|
11359
11575
|
};
|
|
11360
11576
|
var init_navData = () => {};
|
|
11361
11577
|
|
|
11362
11578
|
// src/cli/generate/staticNav.ts
|
|
11363
|
-
var NAV_MARKER_END = "<!-- /absolute:nav -->", NAV_MARKER_START = "<!-- absolute:nav -->", escapeHtml2 = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), indentBefore = (
|
|
11579
|
+
var NAV_MARKER_END = "<!-- /absolute:nav -->", NAV_MARKER_START = "<!-- absolute:nav -->", escapeHtml2 = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), indentBefore = (text2, position) => {
|
|
11364
11580
|
let index = position;
|
|
11365
|
-
while (index > 0 &&
|
|
11581
|
+
while (index > 0 && text2[index - 1] !== `
|
|
11366
11582
|
`)
|
|
11367
11583
|
index -= 1;
|
|
11368
|
-
return
|
|
11584
|
+
return text2.slice(index, position);
|
|
11369
11585
|
}, renderNavBlock = (items, indent) => {
|
|
11370
11586
|
const links = items.map((item) => `${indent} <a href="${escapeHtml2(item.href)}">${escapeHtml2(item.label)}</a>`).join(`
|
|
11371
11587
|
`);
|
|
@@ -11507,19 +11723,19 @@ var init_pageTemplates = __esm(() => {
|
|
|
11507
11723
|
import {
|
|
11508
11724
|
existsSync as existsSync25,
|
|
11509
11725
|
mkdirSync as mkdirSync13,
|
|
11510
|
-
readFileSync as
|
|
11726
|
+
readFileSync as readFileSync25,
|
|
11511
11727
|
readdirSync as readdirSync5,
|
|
11512
11728
|
writeFileSync as writeFileSync13
|
|
11513
11729
|
} from "fs";
|
|
11514
|
-
import { dirname as dirname21, join as
|
|
11730
|
+
import { dirname as dirname21, join as join32, relative as relative16 } from "path";
|
|
11515
11731
|
var writeNew = (path, contents) => {
|
|
11516
11732
|
mkdirSync13(dirname21(path), { recursive: true });
|
|
11517
11733
|
writeFileSync13(path, contents, "utf-8");
|
|
11518
11734
|
}, toHref = (fromDir, toFile) => {
|
|
11519
|
-
const rel =
|
|
11735
|
+
const rel = relative16(fromDir, toFile).split("\\").join("/");
|
|
11520
11736
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
11521
|
-
}, staticPageFiles = (project) => ["html", "htmx"].map((key) => project.frameworkDirs[key]).map((dir) => dir ?
|
|
11522
|
-
const html =
|
|
11737
|
+
}, staticPageFiles = (project) => ["html", "htmx"].map((key) => project.frameworkDirs[key]).map((dir) => dir ? join32(dir, "pages") : null).filter((pagesDir) => pagesDir !== null && existsSync25(pagesDir)).flatMap((pagesDir) => readdirSync5(pagesDir).filter((name) => name.endsWith(".html")).map((name) => join32(pagesDir, name))), resyncPage = (file, items) => {
|
|
11738
|
+
const html = readFileSync25(file, "utf-8");
|
|
11523
11739
|
const synced = syncStaticNav(html, items);
|
|
11524
11740
|
if (synced === null || synced === html)
|
|
11525
11741
|
return false;
|
|
@@ -11546,15 +11762,15 @@ var writeNew = (path, contents) => {
|
|
|
11546
11762
|
outcome.manual = { reason: "framework directory missing", snippet: "" };
|
|
11547
11763
|
return outcome;
|
|
11548
11764
|
}
|
|
11549
|
-
const pageFileAbs =
|
|
11765
|
+
const pageFileAbs = join32(frameworkDir, "pages", def.pageFile({ kebab, pascal }));
|
|
11550
11766
|
if (existsSync25(pageFileAbs)) {
|
|
11551
11767
|
outcome.notes.push(`${pascal} already exists at ${pageFileAbs} \u2014 skipped.`);
|
|
11552
11768
|
return outcome;
|
|
11553
11769
|
}
|
|
11554
11770
|
const routingFile = findRoutingFile(project.serverEntry);
|
|
11555
|
-
const routingText = routingFile ?
|
|
11771
|
+
const routingText = routingFile ? readFileSync25(routingFile, "utf-8") : "";
|
|
11556
11772
|
const css = planCss(routingText, project.stylesDir, pascal, kebab);
|
|
11557
|
-
const navDataPath =
|
|
11773
|
+
const navDataPath = join32(sharedDirFor(project, framework), "navData.ts");
|
|
11558
11774
|
const nav = upsertNavItem(navDataPath, { href: route, label: title });
|
|
11559
11775
|
const navImportPath = toModuleSpecifier(dirname21(pageFileAbs), navDataPath.replace(/\.ts$/, ""));
|
|
11560
11776
|
writeNew(pageFileAbs, pageTemplates[framework]({
|
|
@@ -11608,8 +11824,8 @@ var exports_generate = {};
|
|
|
11608
11824
|
__export(exports_generate, {
|
|
11609
11825
|
runGenerate: () => runGenerate
|
|
11610
11826
|
});
|
|
11611
|
-
import { relative as
|
|
11612
|
-
var SUBCOMMANDS, write = (
|
|
11827
|
+
import { relative as relative17 } from "path";
|
|
11828
|
+
var SUBCOMMANDS, write = (text2) => process.stdout.write(`${text2}
|
|
11613
11829
|
`), fail = (message) => {
|
|
11614
11830
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
11615
11831
|
`);
|
|
@@ -11640,7 +11856,7 @@ var SUBCOMMANDS, write = (text) => process.stdout.write(`${text}
|
|
|
11640
11856
|
return;
|
|
11641
11857
|
write(` ${colors.dim}${label}${colors.reset}`);
|
|
11642
11858
|
for (const path of paths)
|
|
11643
|
-
write(` ${
|
|
11859
|
+
write(` ${relative17(cwd, path)}`);
|
|
11644
11860
|
}, printSummary = (title, outcome, cwd) => {
|
|
11645
11861
|
for (const note of outcome.notes) {
|
|
11646
11862
|
write(`${colors.yellow}!${colors.reset} ${note}`);
|
|
@@ -11740,47 +11956,47 @@ ${indent.repeat(level)}}`;
|
|
|
11740
11956
|
var init_serialize = () => {};
|
|
11741
11957
|
|
|
11742
11958
|
// src/cli/config/absolute/editAbsoluteConfig.ts
|
|
11743
|
-
import
|
|
11744
|
-
import { readFileSync as
|
|
11745
|
-
var lineStartOffset = (
|
|
11959
|
+
import ts11 from "typescript";
|
|
11960
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync14 } from "fs";
|
|
11961
|
+
var lineStartOffset = (text2, position) => {
|
|
11746
11962
|
let index = position;
|
|
11747
|
-
while (index > 0 &&
|
|
11963
|
+
while (index > 0 && text2[index - 1] !== `
|
|
11748
11964
|
`)
|
|
11749
11965
|
index -= 1;
|
|
11750
11966
|
return index;
|
|
11751
|
-
}, indentBefore2 = (
|
|
11967
|
+
}, indentBefore2 = (text2, position) => text2.slice(lineStartOffset(text2, position), position), findProperty = (object3, name) => object3.properties.find((property) => ts11.isPropertyAssignment(property) && (ts11.isIdentifier(property.name) || ts11.isStringLiteral(property.name)) && property.name.text === name), applyAbsoluteConfigEdit = (configPath2, request) => {
|
|
11752
11968
|
try {
|
|
11753
|
-
const
|
|
11754
|
-
const sourceFile =
|
|
11755
|
-
const
|
|
11756
|
-
if (!
|
|
11969
|
+
const text2 = readFileSync26(configPath2, "utf-8");
|
|
11970
|
+
const sourceFile = ts11.createSourceFile(configPath2, text2, ts11.ScriptTarget.Latest, true);
|
|
11971
|
+
const object3 = findConfigObject(sourceFile);
|
|
11972
|
+
if (!object3) {
|
|
11757
11973
|
return {
|
|
11758
11974
|
message: "Could not find defineConfig({ ... }) in the config file.",
|
|
11759
11975
|
ok: false
|
|
11760
11976
|
};
|
|
11761
11977
|
}
|
|
11762
|
-
const existing = findProperty(
|
|
11978
|
+
const existing = findProperty(object3, request.name);
|
|
11763
11979
|
if (request.remove) {
|
|
11764
11980
|
if (!existing)
|
|
11765
11981
|
return { message: `${request.name} is not set`, ok: true };
|
|
11766
|
-
const start2 = lineStartOffset(
|
|
11982
|
+
const start2 = lineStartOffset(text2, existing.getStart(sourceFile));
|
|
11767
11983
|
let end = existing.getEnd();
|
|
11768
|
-
if (
|
|
11984
|
+
if (text2[end] === ",")
|
|
11769
11985
|
end += 1;
|
|
11770
|
-
if (
|
|
11986
|
+
if (text2[end] === `
|
|
11771
11987
|
`)
|
|
11772
11988
|
end += 1;
|
|
11773
|
-
writeFileSync14(configPath2,
|
|
11989
|
+
writeFileSync14(configPath2, text2.slice(0, start2) + text2.slice(end), "utf-8");
|
|
11774
11990
|
return { message: `Removed ${request.name}`, ok: true };
|
|
11775
11991
|
}
|
|
11776
11992
|
const valueText = serializeValue(request.value);
|
|
11777
11993
|
if (existing) {
|
|
11778
11994
|
const start2 = existing.initializer.getStart(sourceFile);
|
|
11779
11995
|
const end = existing.initializer.getEnd();
|
|
11780
|
-
writeFileSync14(configPath2,
|
|
11996
|
+
writeFileSync14(configPath2, text2.slice(0, start2) + valueText + text2.slice(end), "utf-8");
|
|
11781
11997
|
return { message: `Updated ${request.name}`, ok: true };
|
|
11782
11998
|
}
|
|
11783
|
-
const { properties } =
|
|
11999
|
+
const { properties } = object3;
|
|
11784
12000
|
const entry = `${request.name}: ${valueText}`;
|
|
11785
12001
|
if (properties.length > 0) {
|
|
11786
12002
|
const last = properties[properties.length - 1];
|
|
@@ -11790,21 +12006,21 @@ var lineStartOffset = (text, position) => {
|
|
|
11790
12006
|
ok: false
|
|
11791
12007
|
};
|
|
11792
12008
|
}
|
|
11793
|
-
const indent = indentBefore2(
|
|
12009
|
+
const indent = indentBefore2(text2, last.getStart(sourceFile));
|
|
11794
12010
|
let insertionIndex = last.getEnd();
|
|
11795
|
-
const hasComma =
|
|
12011
|
+
const hasComma = text2[insertionIndex] === ",";
|
|
11796
12012
|
if (hasComma)
|
|
11797
12013
|
insertionIndex += 1;
|
|
11798
12014
|
const insertion = `${hasComma ? "" : ","}
|
|
11799
12015
|
${indent}${entry}`;
|
|
11800
|
-
writeFileSync14(configPath2,
|
|
12016
|
+
writeFileSync14(configPath2, text2.slice(0, insertionIndex) + insertion + text2.slice(insertionIndex), "utf-8");
|
|
11801
12017
|
} else {
|
|
11802
|
-
const insertionIndex =
|
|
11803
|
-
const indent = `${indentBefore2(
|
|
12018
|
+
const insertionIndex = object3.getStart(sourceFile) + 1;
|
|
12019
|
+
const indent = `${indentBefore2(text2, object3.getStart(sourceFile))} `;
|
|
11804
12020
|
const insertion = `
|
|
11805
12021
|
${indent}${entry}
|
|
11806
|
-
${indentBefore2(
|
|
11807
|
-
writeFileSync14(configPath2,
|
|
12022
|
+
${indentBefore2(text2, object3.getStart(sourceFile))}`;
|
|
12023
|
+
writeFileSync14(configPath2, text2.slice(0, insertionIndex) + insertion + text2.slice(insertionIndex), "utf-8");
|
|
11808
12024
|
}
|
|
11809
12025
|
return { message: `Updated ${request.name}`, ok: true };
|
|
11810
12026
|
} catch (error) {
|
|
@@ -11933,14 +12149,14 @@ var init_catalog = __esm(() => {
|
|
|
11933
12149
|
});
|
|
11934
12150
|
|
|
11935
12151
|
// src/cli/integrations/addPlugin.ts
|
|
11936
|
-
import { existsSync as existsSync26, readFileSync as
|
|
11937
|
-
import { join as
|
|
12152
|
+
import { existsSync as existsSync26, readFileSync as readFileSync27 } from "fs";
|
|
12153
|
+
import { join as join33 } from "path";
|
|
11938
12154
|
var isRecord11 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), readPackageJson = (cwd) => {
|
|
11939
|
-
const path =
|
|
12155
|
+
const path = join33(cwd, "package.json");
|
|
11940
12156
|
if (!existsSync26(path))
|
|
11941
12157
|
return null;
|
|
11942
12158
|
try {
|
|
11943
|
-
const parsed = JSON.parse(
|
|
12159
|
+
const parsed = JSON.parse(readFileSync27(path, "utf-8"));
|
|
11944
12160
|
return isRecord11(parsed) ? parsed : null;
|
|
11945
12161
|
} catch {
|
|
11946
12162
|
return null;
|
|
@@ -12431,61 +12647,61 @@ var init_authCatalog = __esm(() => {
|
|
|
12431
12647
|
});
|
|
12432
12648
|
|
|
12433
12649
|
// src/cli/config/auth/resolveAuthSettings.ts
|
|
12434
|
-
import
|
|
12435
|
-
import { existsSync as existsSync27, readFileSync as
|
|
12436
|
-
import { resolve as
|
|
12650
|
+
import ts12 from "typescript";
|
|
12651
|
+
import { existsSync as existsSync27, readFileSync as readFileSync28 } from "fs";
|
|
12652
|
+
import { resolve as resolve28 } from "path";
|
|
12437
12653
|
var AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, findAuthSettingsPath = (cwd, override) => {
|
|
12438
12654
|
if (override) {
|
|
12439
|
-
const resolved =
|
|
12655
|
+
const resolved = resolve28(cwd, override);
|
|
12440
12656
|
return existsSync27(resolved) ? resolved : null;
|
|
12441
12657
|
}
|
|
12442
12658
|
for (const name of CONFIG_CANDIDATES3) {
|
|
12443
|
-
const candidate =
|
|
12659
|
+
const candidate = resolve28(cwd, name);
|
|
12444
12660
|
if (existsSync27(candidate))
|
|
12445
12661
|
return candidate;
|
|
12446
12662
|
}
|
|
12447
12663
|
return null;
|
|
12448
|
-
}, parseSource2 = (configPath2,
|
|
12664
|
+
}, parseSource2 = (configPath2, text2) => ts12.createSourceFile(configPath2, text2, ts12.ScriptTarget.Latest, true), findAuthSettingsObject = (sourceFile) => {
|
|
12449
12665
|
const pending = [sourceFile];
|
|
12450
12666
|
while (pending.length > 0) {
|
|
12451
12667
|
const node = pending.pop();
|
|
12452
12668
|
if (!node)
|
|
12453
12669
|
continue;
|
|
12454
|
-
const [firstArgument] =
|
|
12455
|
-
if (
|
|
12670
|
+
const [firstArgument] = ts12.isCallExpression(node) ? node.arguments : [];
|
|
12671
|
+
if (ts12.isCallExpression(node) && ts12.isIdentifier(node.expression) && node.expression.text === "defineAuthSettings" && firstArgument && ts12.isObjectLiteralExpression(firstArgument)) {
|
|
12456
12672
|
return firstArgument;
|
|
12457
12673
|
}
|
|
12458
|
-
if (
|
|
12674
|
+
if (ts12.isExportAssignment(node) && ts12.isObjectLiteralExpression(node.expression)) {
|
|
12459
12675
|
return node.expression;
|
|
12460
12676
|
}
|
|
12461
12677
|
node.forEachChild((child) => pending.push(child));
|
|
12462
12678
|
}
|
|
12463
12679
|
return null;
|
|
12464
12680
|
}, parseAuthSettingsObject = (configPath2) => {
|
|
12465
|
-
const
|
|
12681
|
+
const text2 = readFileSync28(configPath2, "utf-8");
|
|
12466
12682
|
return {
|
|
12467
|
-
object: findAuthSettingsObject(parseSource2(configPath2,
|
|
12468
|
-
text
|
|
12683
|
+
object: findAuthSettingsObject(parseSource2(configPath2, text2)),
|
|
12684
|
+
text: text2
|
|
12469
12685
|
};
|
|
12470
12686
|
}, evalLiteral2 = (node) => {
|
|
12471
|
-
if (
|
|
12687
|
+
if (ts12.isStringLiteralLike(node))
|
|
12472
12688
|
return { opaque: false, value: node.text };
|
|
12473
|
-
if (node.kind ===
|
|
12689
|
+
if (node.kind === ts12.SyntaxKind.TrueKeyword) {
|
|
12474
12690
|
return { opaque: false, value: true };
|
|
12475
12691
|
}
|
|
12476
|
-
if (node.kind ===
|
|
12692
|
+
if (node.kind === ts12.SyntaxKind.FalseKeyword) {
|
|
12477
12693
|
return { opaque: false, value: false };
|
|
12478
12694
|
}
|
|
12479
|
-
if (node.kind ===
|
|
12695
|
+
if (node.kind === ts12.SyntaxKind.NullKeyword) {
|
|
12480
12696
|
return { opaque: false, value: null };
|
|
12481
12697
|
}
|
|
12482
|
-
if (
|
|
12698
|
+
if (ts12.isNumericLiteral(node)) {
|
|
12483
12699
|
return { opaque: false, value: Number(node.text) };
|
|
12484
12700
|
}
|
|
12485
|
-
if (
|
|
12701
|
+
if (ts12.isPrefixUnaryExpression(node) && node.operator === ts12.SyntaxKind.MinusToken && ts12.isNumericLiteral(node.operand)) {
|
|
12486
12702
|
return { opaque: false, value: -Number(node.operand.text) };
|
|
12487
12703
|
}
|
|
12488
|
-
if (
|
|
12704
|
+
if (ts12.isArrayLiteralExpression(node)) {
|
|
12489
12705
|
const items = [];
|
|
12490
12706
|
for (const element of node.elements) {
|
|
12491
12707
|
const result = evalLiteral2(element);
|
|
@@ -12499,11 +12715,11 @@ var AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, findAuthSettingsPath
|
|
|
12499
12715
|
}, readCurrent2 = (configPath2) => {
|
|
12500
12716
|
const current = {};
|
|
12501
12717
|
const opaqueKeys = [];
|
|
12502
|
-
const { object:
|
|
12503
|
-
if (!
|
|
12718
|
+
const { object: object3 } = parseAuthSettingsObject(configPath2);
|
|
12719
|
+
if (!object3)
|
|
12504
12720
|
return { current, opaqueKeys };
|
|
12505
|
-
for (const property of
|
|
12506
|
-
if (!
|
|
12721
|
+
for (const property of object3.properties) {
|
|
12722
|
+
if (!ts12.isPropertyAssignment(property) || !(ts12.isIdentifier(property.name) || ts12.isStringLiteral(property.name))) {
|
|
12507
12723
|
continue;
|
|
12508
12724
|
}
|
|
12509
12725
|
const name = property.name.text;
|
|
@@ -12536,14 +12752,14 @@ var init_resolveAuthSettings = __esm(() => {
|
|
|
12536
12752
|
});
|
|
12537
12753
|
|
|
12538
12754
|
// src/cli/config/auth/resolveAuthState.ts
|
|
12539
|
-
import
|
|
12540
|
-
import { existsSync as existsSync28, readdirSync as readdirSync6, readFileSync as
|
|
12541
|
-
import { join as
|
|
12542
|
-
var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutejs/absolute-auth", NPM_URL = "https://www.npmjs.com/package/@absolutejs/auth", SKIP_DIRS, MAX_FILES = 4000, SETUP_EXPORTS, isRecord12 = (value) => typeof value === "object" && value !== null && !Array.isArray(value),
|
|
12755
|
+
import ts13 from "typescript";
|
|
12756
|
+
import { existsSync as existsSync28, readdirSync as readdirSync6, readFileSync as readFileSync29 } from "fs";
|
|
12757
|
+
import { join as join34, relative as relative18, resolve as resolve29 } from "path";
|
|
12758
|
+
var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutejs/absolute-auth", NPM_URL = "https://www.npmjs.com/package/@absolutejs/auth", SKIP_DIRS, MAX_FILES = 4000, SETUP_EXPORTS, isRecord12 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), readJson2 = (path) => {
|
|
12543
12759
|
if (!existsSync28(path))
|
|
12544
12760
|
return null;
|
|
12545
12761
|
try {
|
|
12546
|
-
const parsed = JSON.parse(
|
|
12762
|
+
const parsed = JSON.parse(readFileSync29(path, "utf-8"));
|
|
12547
12763
|
return isRecord12(parsed) ? parsed : null;
|
|
12548
12764
|
} catch {
|
|
12549
12765
|
return null;
|
|
@@ -12552,7 +12768,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12552
12768
|
const value = record?.[key];
|
|
12553
12769
|
return typeof value === "string" ? value : null;
|
|
12554
12770
|
}, declaredVersionFor = (cwd) => {
|
|
12555
|
-
const pkg =
|
|
12771
|
+
const pkg = readJson2(join34(cwd, "package.json"));
|
|
12556
12772
|
if (!pkg)
|
|
12557
12773
|
return null;
|
|
12558
12774
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
@@ -12564,14 +12780,14 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12564
12780
|
return version2;
|
|
12565
12781
|
}
|
|
12566
12782
|
return null;
|
|
12567
|
-
}, installedVersionFor = (cwd) => stringField(
|
|
12783
|
+
}, installedVersionFor = (cwd) => stringField(readJson2(join34(cwd, "node_modules", AUTH_PACKAGE2, "package.json")), "version"), SOURCE_FILE, safeReaddir = (dir) => {
|
|
12568
12784
|
try {
|
|
12569
12785
|
return readdirSync6(dir, { withFileTypes: true });
|
|
12570
12786
|
} catch {
|
|
12571
12787
|
return [];
|
|
12572
12788
|
}
|
|
12573
12789
|
}, sortEntry = (dir, entry, found, dirs) => {
|
|
12574
|
-
const full =
|
|
12790
|
+
const full = join34(dir, entry.name);
|
|
12575
12791
|
if (entry.isDirectory()) {
|
|
12576
12792
|
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith("."))
|
|
12577
12793
|
return;
|
|
@@ -12593,9 +12809,9 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12593
12809
|
collectFrom(dir, found, stack);
|
|
12594
12810
|
}
|
|
12595
12811
|
return found;
|
|
12596
|
-
}, isAuthPackageImport = (statement) =>
|
|
12812
|
+
}, isAuthPackageImport = (statement) => ts13.isImportDeclaration(statement) && ts13.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === AUTH_PACKAGE2, addAuthNames = (statement, names) => {
|
|
12597
12813
|
const bindings = statement.importClause?.namedBindings;
|
|
12598
|
-
if (!bindings || !
|
|
12814
|
+
if (!bindings || !ts13.isNamedImports(bindings))
|
|
12599
12815
|
return;
|
|
12600
12816
|
for (const element of bindings.elements) {
|
|
12601
12817
|
const imported = element.propertyName?.text ?? element.name.text;
|
|
@@ -12610,18 +12826,18 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12610
12826
|
addAuthNames(statement, names);
|
|
12611
12827
|
}
|
|
12612
12828
|
return names;
|
|
12613
|
-
}, isAuthCall = (node, bindings) =>
|
|
12614
|
-
if (!
|
|
12829
|
+
}, isAuthCall = (node, bindings) => ts13.isIdentifier(node.expression) && bindings.has(node.expression.text), providerCountOf = (property) => {
|
|
12830
|
+
if (!ts13.isPropertyAssignment(property) || !ts13.isObjectLiteralExpression(property.initializer)) {
|
|
12615
12831
|
return null;
|
|
12616
12832
|
}
|
|
12617
12833
|
return property.initializer.properties.length;
|
|
12618
|
-
}, readConfigKeys = (
|
|
12834
|
+
}, readConfigKeys = (object3) => {
|
|
12619
12835
|
const keys = new Set;
|
|
12620
12836
|
let providerCount = null;
|
|
12621
|
-
const usesSpread =
|
|
12622
|
-
for (const property of
|
|
12837
|
+
const usesSpread = object3.properties.some((property) => ts13.isSpreadAssignment(property));
|
|
12838
|
+
for (const property of object3.properties) {
|
|
12623
12839
|
const { name } = property;
|
|
12624
|
-
if (name === undefined || !
|
|
12840
|
+
if (name === undefined || !ts13.isIdentifier(name))
|
|
12625
12841
|
continue;
|
|
12626
12842
|
keys.add(name.text);
|
|
12627
12843
|
if (name.text !== "providersConfiguration")
|
|
@@ -12631,20 +12847,20 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12631
12847
|
return { keys, providerCount, usesSpread };
|
|
12632
12848
|
}, matchFromCall = (node) => {
|
|
12633
12849
|
const [arg] = node.arguments;
|
|
12634
|
-
if (arg &&
|
|
12850
|
+
if (arg && ts13.isObjectLiteralExpression(arg))
|
|
12635
12851
|
return readConfigKeys(arg);
|
|
12636
12852
|
return { keys: new Set, providerCount: null, usesSpread: true };
|
|
12637
12853
|
}, readFileOrNull = (path) => {
|
|
12638
12854
|
try {
|
|
12639
|
-
return
|
|
12855
|
+
return readFileSync29(path, "utf-8");
|
|
12640
12856
|
} catch {
|
|
12641
12857
|
return null;
|
|
12642
12858
|
}
|
|
12643
12859
|
}, findSetupInFile = (path) => {
|
|
12644
|
-
const
|
|
12645
|
-
if (
|
|
12860
|
+
const text2 = readFileOrNull(path);
|
|
12861
|
+
if (text2 === null || !text2.includes(AUTH_PACKAGE2))
|
|
12646
12862
|
return null;
|
|
12647
|
-
const sourceFile =
|
|
12863
|
+
const sourceFile = ts13.createSourceFile(path, text2, ts13.ScriptTarget.Latest, true);
|
|
12648
12864
|
const bindings = authBindings(sourceFile);
|
|
12649
12865
|
if (bindings.size === 0)
|
|
12650
12866
|
return null;
|
|
@@ -12653,7 +12869,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12653
12869
|
const node = pending.pop();
|
|
12654
12870
|
if (!node)
|
|
12655
12871
|
continue;
|
|
12656
|
-
if (
|
|
12872
|
+
if (ts13.isCallExpression(node) && isAuthCall(node, bindings)) {
|
|
12657
12873
|
return matchFromCall(node);
|
|
12658
12874
|
}
|
|
12659
12875
|
node.forEachChild((child) => pending.push(child));
|
|
@@ -12669,7 +12885,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12669
12885
|
scaffoldable: isScaffoldableFeature(feature.id)
|
|
12670
12886
|
})), resolveAuthState = (cwd) => {
|
|
12671
12887
|
const installedVersion = installedVersionFor(cwd);
|
|
12672
|
-
const root = existsSync28(
|
|
12888
|
+
const root = existsSync28(join34(cwd, "src")) ? join34(cwd, "src") : cwd;
|
|
12673
12889
|
let match = null;
|
|
12674
12890
|
let setupPath = null;
|
|
12675
12891
|
for (const file of candidateFiles(root)) {
|
|
@@ -12677,7 +12893,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12677
12893
|
if (found === null)
|
|
12678
12894
|
continue;
|
|
12679
12895
|
match = found;
|
|
12680
|
-
setupPath =
|
|
12896
|
+
setupPath = relative18(cwd, resolve29(file));
|
|
12681
12897
|
break;
|
|
12682
12898
|
}
|
|
12683
12899
|
const keys = match?.keys ?? new Set;
|
|
@@ -12715,7 +12931,7 @@ var init_resolveAuthState = __esm(() => {
|
|
|
12715
12931
|
|
|
12716
12932
|
// src/cli/config/auth/scaffoldAuthFeature.ts
|
|
12717
12933
|
import { existsSync as existsSync29, writeFileSync as writeFileSync15 } from "fs";
|
|
12718
|
-
import { dirname as dirname22, join as
|
|
12934
|
+
import { dirname as dirname22, join as join35, relative as relative19, resolve as resolve30 } from "path";
|
|
12719
12935
|
var renderScaffold = (scaffold) => {
|
|
12720
12936
|
const importNames = [...scaffold.imports, `type ${scaffold.typeName}`];
|
|
12721
12937
|
const importLine = `import { ${importNames.join(", ")} } from '@absolutejs/auth';`;
|
|
@@ -12740,8 +12956,8 @@ ${body}
|
|
|
12740
12956
|
}, targetDir = (cwd) => {
|
|
12741
12957
|
const { setupPath } = resolveAuthState(cwd);
|
|
12742
12958
|
if (setupPath)
|
|
12743
|
-
return dirname22(
|
|
12744
|
-
const src =
|
|
12959
|
+
return dirname22(resolve30(cwd, setupPath));
|
|
12960
|
+
const src = join35(cwd, "src");
|
|
12745
12961
|
return existsSync29(src) ? src : cwd;
|
|
12746
12962
|
}, spreadFor = (scaffold) => `import { ${scaffold.exportName} } from './${scaffold.exportName}';
|
|
12747
12963
|
// add to your auth() call:
|
|
@@ -12755,8 +12971,8 @@ ${scaffold.configKey}: ${scaffold.exportName}`, failure2 = (message) => ({
|
|
|
12755
12971
|
const scaffold = AUTH_SCAFFOLDS[id];
|
|
12756
12972
|
if (!scaffold)
|
|
12757
12973
|
return failure2(`Unknown auth feature "${id}".`);
|
|
12758
|
-
const filePath =
|
|
12759
|
-
const relPath =
|
|
12974
|
+
const filePath = join35(targetDir(cwd), `${scaffold.exportName}.ts`);
|
|
12975
|
+
const relPath = relative19(cwd, filePath);
|
|
12760
12976
|
if (existsSync29(filePath)) {
|
|
12761
12977
|
return {
|
|
12762
12978
|
created: null,
|
|
@@ -12784,12 +13000,12 @@ var init_scaffoldAuthFeature = __esm(() => {
|
|
|
12784
13000
|
});
|
|
12785
13001
|
|
|
12786
13002
|
// src/cli/htmx/install.ts
|
|
12787
|
-
import { existsSync as existsSync30, mkdirSync as mkdirSync14, readFileSync as
|
|
12788
|
-
import { join as
|
|
13003
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync14, readFileSync as readFileSync30, writeFileSync as writeFileSync16 } from "fs";
|
|
13004
|
+
import { join as join36 } from "path";
|
|
12789
13005
|
var VENDORED_HTMX_VERSION = "2.0.6", vendoredHtmxFile = () => [
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
13006
|
+
join36(import.meta.dir, "htmx.min.js"),
|
|
13007
|
+
join36(import.meta.dir, "htmx", "htmx.min.js"),
|
|
13008
|
+
join36(import.meta.dir, "..", "htmx", "htmx.min.js")
|
|
12793
13009
|
].find((path) => existsSync30(path)) ?? null, detectHtmxVersion = (content) => {
|
|
12794
13010
|
const match = content.match(/version:"([0-9.]+)"/);
|
|
12795
13011
|
return match ? match[1] : null;
|
|
@@ -12801,16 +13017,16 @@ var VENDORED_HTMX_VERSION = "2.0.6", vendoredHtmxFile = () => [
|
|
|
12801
13017
|
}
|
|
12802
13018
|
return response.text();
|
|
12803
13019
|
}, installedHtmxVersion = (htmxDir) => {
|
|
12804
|
-
const file =
|
|
13020
|
+
const file = join36(htmxDir, "htmx.min.js");
|
|
12805
13021
|
if (!existsSync30(file))
|
|
12806
13022
|
return null;
|
|
12807
|
-
return detectHtmxVersion(
|
|
13023
|
+
return detectHtmxVersion(readFileSync30(file, "utf-8"));
|
|
12808
13024
|
}, readVendoredHtmx = () => {
|
|
12809
13025
|
const file = vendoredHtmxFile();
|
|
12810
|
-
return file ?
|
|
13026
|
+
return file ? readFileSync30(file, "utf-8") : null;
|
|
12811
13027
|
}, writeHtmx = (htmxDir, content) => {
|
|
12812
13028
|
mkdirSync14(htmxDir, { recursive: true });
|
|
12813
|
-
const file =
|
|
13029
|
+
const file = join36(htmxDir, "htmx.min.js");
|
|
12814
13030
|
writeFileSync16(file, content, "utf-8");
|
|
12815
13031
|
return file;
|
|
12816
13032
|
};
|
|
@@ -12821,8 +13037,8 @@ var exports_add = {};
|
|
|
12821
13037
|
__export(exports_add, {
|
|
12822
13038
|
runAdd: () => runAdd
|
|
12823
13039
|
});
|
|
12824
|
-
import { dirname as dirname23, join as
|
|
12825
|
-
var write2 = (
|
|
13040
|
+
import { dirname as dirname23, join as join37, relative as relative20 } from "path";
|
|
13041
|
+
var write2 = (text2) => process.stdout.write(`${text2}
|
|
12826
13042
|
`), fail2 = (message) => {
|
|
12827
13043
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
12828
13044
|
`);
|
|
@@ -12832,11 +13048,11 @@ var write2 = (text) => process.stdout.write(`${text}
|
|
|
12832
13048
|
return;
|
|
12833
13049
|
write2(` ${colors.dim}${label}${colors.reset}`);
|
|
12834
13050
|
for (const path of paths)
|
|
12835
|
-
write2(` ${
|
|
13051
|
+
write2(` ${relative20(cwd, path)}`);
|
|
12836
13052
|
}, frontendRoot = (project, cwd) => {
|
|
12837
13053
|
const [firstKey] = configuredFrameworks(project);
|
|
12838
13054
|
const firstDir = firstKey ? project.frameworkDirs[firstKey] : undefined;
|
|
12839
|
-
return firstDir ? dirname23(firstDir) :
|
|
13055
|
+
return firstDir ? dirname23(firstDir) : join37(cwd, "src", "frontend");
|
|
12840
13056
|
}, addIntegrationCli = (id, install) => {
|
|
12841
13057
|
const result = addIntegration(process.cwd(), id, { install });
|
|
12842
13058
|
if (!result.ok) {
|
|
@@ -12900,8 +13116,8 @@ var write2 = (text) => process.stdout.write(`${text}
|
|
|
12900
13116
|
write2(`${colors.yellow}!${colors.reset} ${frameworks6[framework].label} is already configured \u2014 nothing to do.`);
|
|
12901
13117
|
return;
|
|
12902
13118
|
}
|
|
12903
|
-
const dirAbs =
|
|
12904
|
-
const dirRel = `./${
|
|
13119
|
+
const dirAbs = join37(frontendRoot(project, cwd), framework);
|
|
13120
|
+
const dirRel = `./${relative20(cwd, dirAbs).split("\\").join("/")}`;
|
|
12905
13121
|
let depNote = "Skipped dependency install (--no-install).";
|
|
12906
13122
|
if (!noInstall) {
|
|
12907
13123
|
write2(`${colors.dim}Installing ${frameworks6[framework].label} dependencies\u2026${colors.reset}`);
|
|
@@ -12970,8 +13186,8 @@ var exports_analyze = {};
|
|
|
12970
13186
|
__export(exports_analyze, {
|
|
12971
13187
|
runAnalyze: () => runAnalyze
|
|
12972
13188
|
});
|
|
12973
|
-
import { existsSync as existsSync31, readFileSync as
|
|
12974
|
-
import { join as
|
|
13189
|
+
import { existsSync as existsSync31, readFileSync as readFileSync31, statSync as statSync3, writeFileSync as writeFileSync17 } from "fs";
|
|
13190
|
+
import { join as join38, resolve as resolve31 } from "path";
|
|
12975
13191
|
var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_WIDTH = 16, SIZE_WIDTH = 12, CHANGE_WIDTH = 10, CATEGORY_ORDER, categoryOf = (key) => {
|
|
12976
13192
|
if (key.startsWith("Island"))
|
|
12977
13193
|
return "Islands";
|
|
@@ -12991,21 +13207,21 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
12991
13207
|
return 0;
|
|
12992
13208
|
}
|
|
12993
13209
|
}, readSizes = (manifestDir) => {
|
|
12994
|
-
const manifestPath =
|
|
13210
|
+
const manifestPath = join38(manifestDir, "manifest.json");
|
|
12995
13211
|
if (!existsSync31(manifestPath))
|
|
12996
13212
|
return null;
|
|
12997
|
-
const manifest = JSON.parse(
|
|
13213
|
+
const manifest = JSON.parse(readFileSync31(manifestPath, "utf-8"));
|
|
12998
13214
|
const sizes = {};
|
|
12999
13215
|
for (const [key, value] of Object.entries(manifest)) {
|
|
13000
|
-
sizes[key] = fileSize2(
|
|
13216
|
+
sizes[key] = fileSize2(join38(manifestDir, value.replace(/^\//, "")));
|
|
13001
13217
|
}
|
|
13002
13218
|
return sizes;
|
|
13003
13219
|
}, readBaseline = (cwd) => {
|
|
13004
|
-
const path =
|
|
13220
|
+
const path = join38(cwd, BASELINE_FILE);
|
|
13005
13221
|
if (!existsSync31(path))
|
|
13006
13222
|
return null;
|
|
13007
13223
|
try {
|
|
13008
|
-
const parsed = JSON.parse(
|
|
13224
|
+
const parsed = JSON.parse(readFileSync31(path, "utf-8"));
|
|
13009
13225
|
return parsed;
|
|
13010
13226
|
} catch {
|
|
13011
13227
|
return null;
|
|
@@ -13083,14 +13299,14 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
13083
13299
|
const config = await loadConfig(configIndex >= 0 ? args[configIndex + 1] : undefined);
|
|
13084
13300
|
const outdirIndex = args.indexOf("--outdir");
|
|
13085
13301
|
const outdir = outdirIndex >= 0 ? args[outdirIndex + 1] : config.buildDirectory;
|
|
13086
|
-
const sizes = readSizes(
|
|
13302
|
+
const sizes = readSizes(resolve31(cwd, outdir ?? "build"));
|
|
13087
13303
|
if (sizes === null) {
|
|
13088
13304
|
process.stdout.write(`${colors.dim}No build found. Run \`absolute build\` first.${colors.reset}
|
|
13089
13305
|
`);
|
|
13090
13306
|
return;
|
|
13091
13307
|
}
|
|
13092
13308
|
if (args.includes("--save")) {
|
|
13093
|
-
writeFileSync17(
|
|
13309
|
+
writeFileSync17(join38(cwd, BASELINE_FILE), `${JSON.stringify(sizes, null, 2)}
|
|
13094
13310
|
`);
|
|
13095
13311
|
process.stdout.write(`${colors.green}\u2713${colors.reset} Saved size baseline (${Object.keys(sizes).length} entries) to ${BASELINE_FILE}
|
|
13096
13312
|
`);
|
|
@@ -13135,7 +13351,7 @@ var SLOW_MS = 100, VERY_SLOW_MS = 500, HTTP_SERVER_ERROR = 500, HTTP_CLIENT_ERRO
|
|
|
13135
13351
|
}, isDim = (kind) => kind !== "api" && kind !== "page", pickServer = (instances) => {
|
|
13136
13352
|
const withUrl = instances.filter((instance) => instance.url !== null);
|
|
13137
13353
|
return withUrl.find((instance) => instance.source === "dev") ?? withUrl.find((instance) => instance.source !== "untracked") ?? withUrl[0] ?? null;
|
|
13138
|
-
}, clock = (epochMs) => new Date(epochMs).toLocaleTimeString([], { hour12: false }), tint = (
|
|
13354
|
+
}, clock = (epochMs) => new Date(epochMs).toLocaleTimeString([], { hour12: false }), tint = (text2, color, dim) => `${dim ? colors.dim : color}${text2}${colors.reset}`, aggregates = (records) => {
|
|
13139
13355
|
const durations = records.filter((record) => !isDim(record.kind)).map((record) => record.durationMs).sort((left, right) => left - right);
|
|
13140
13356
|
const total = durations.reduce((sum, value) => sum + value, 0);
|
|
13141
13357
|
const avgMs = durations.length ? Math.round(total / durations.length) : 0;
|
|
@@ -13336,9 +13552,9 @@ var exports_remove = {};
|
|
|
13336
13552
|
__export(exports_remove, {
|
|
13337
13553
|
runRemove: () => runRemove
|
|
13338
13554
|
});
|
|
13339
|
-
import { existsSync as existsSync32, readFileSync as
|
|
13340
|
-
import { relative as
|
|
13341
|
-
var write3 = (
|
|
13555
|
+
import { existsSync as existsSync32, readFileSync as readFileSync32 } from "fs";
|
|
13556
|
+
import { relative as relative21 } from "path";
|
|
13557
|
+
var write3 = (text2) => process.stdout.write(`${text2}
|
|
13342
13558
|
`), fail3 = (message) => {
|
|
13343
13559
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
13344
13560
|
`);
|
|
@@ -13350,7 +13566,7 @@ var write3 = (text) => process.stdout.write(`${text}
|
|
|
13350
13566
|
if (file === null || seen.has(file) || !existsSync32(file))
|
|
13351
13567
|
return false;
|
|
13352
13568
|
seen.add(file);
|
|
13353
|
-
return
|
|
13569
|
+
return readFileSync32(file, "utf-8").includes(handler);
|
|
13354
13570
|
});
|
|
13355
13571
|
}, runRemove = async (args) => {
|
|
13356
13572
|
const [framework] = args.filter((arg) => !arg.startsWith("--"));
|
|
@@ -13386,10 +13602,10 @@ var write3 = (text) => process.stdout.write(`${text}
|
|
|
13386
13602
|
}
|
|
13387
13603
|
write3(`${colors.green}\u2713${colors.reset} Removed ${framework}Directory from absolute.config.ts
|
|
13388
13604
|
`);
|
|
13389
|
-
write3(` ${colors.dim}Kept${colors.reset} ${
|
|
13605
|
+
write3(` ${colors.dim}Kept${colors.reset} ${relative21(cwd, frameworkDir)} \u2014 delete its source manually if no longer needed.`);
|
|
13390
13606
|
const refs = referencingFiles(project.serverEntry, HANDLER_NAME[framework]);
|
|
13391
13607
|
for (const file of refs) {
|
|
13392
|
-
write3(` ${colors.yellow}Still references${colors.reset} ${
|
|
13608
|
+
write3(` ${colors.yellow}Still references${colors.reset} ${relative21(cwd, file)} (calls ${HANDLER_NAME[framework]})`);
|
|
13393
13609
|
}
|
|
13394
13610
|
const deps = frameworkDependencyNames(framework);
|
|
13395
13611
|
if (prune && deps.length > 0) {
|
|
@@ -13427,7 +13643,7 @@ var exports_htmx = {};
|
|
|
13427
13643
|
__export(exports_htmx, {
|
|
13428
13644
|
runHtmx: () => runHtmx
|
|
13429
13645
|
});
|
|
13430
|
-
var write4 = (
|
|
13646
|
+
var write4 = (text2) => process.stdout.write(`${text2}
|
|
13431
13647
|
`), fail4 = (message) => {
|
|
13432
13648
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
13433
13649
|
`);
|
|
@@ -13477,15 +13693,15 @@ __export(exports_env, {
|
|
|
13477
13693
|
runEnv: () => runEnv,
|
|
13478
13694
|
collectEnvVars: () => collectEnvVars
|
|
13479
13695
|
});
|
|
13480
|
-
import { existsSync as existsSync33, readFileSync as
|
|
13481
|
-
import { join as
|
|
13696
|
+
import { existsSync as existsSync33, readFileSync as readFileSync33 } from "fs";
|
|
13697
|
+
import { join as join39 } from "path";
|
|
13482
13698
|
var {env: env3, Glob: Glob3 } = globalThis.Bun;
|
|
13483
|
-
var EXTENSIONS = "ts,tsx,js,jsx,mjs,cjs,svelte,vue", STATUS_WIDTH2, keysInFile = (
|
|
13699
|
+
var EXTENSIONS = "ts,tsx,js,jsx,mjs,cjs,svelte,vue", STATUS_WIDTH2, keysInFile = (text2) => [...text2.matchAll(/getEnv\(\s*['"]([^'"]+)['"]\s*\)/g)].map((match) => match[1]).filter((key) => key !== undefined), scanPatterns = () => existsSync33(join39(process.cwd(), "src")) ? [`src/**/*.{${EXTENSIONS}}`] : [`*.{${EXTENSIONS}}`], scanEnvUsage = async () => {
|
|
13484
13700
|
const scans = scanPatterns().map((pattern) => Array.fromAsync(new Glob3(pattern).scan({ cwd: process.cwd() })));
|
|
13485
13701
|
const files = (await Promise.all(scans)).flat();
|
|
13486
13702
|
const usage = new Map;
|
|
13487
13703
|
files.forEach((file) => {
|
|
13488
|
-
keysInFile(
|
|
13704
|
+
keysInFile(readFileSync33(file, "utf-8")).forEach((key) => {
|
|
13489
13705
|
usage.set(key, [...usage.get(key) ?? [], file]);
|
|
13490
13706
|
});
|
|
13491
13707
|
});
|
|
@@ -13546,10 +13762,10 @@ __export(exports_db, {
|
|
|
13546
13762
|
conflictClause: () => conflictClause,
|
|
13547
13763
|
chunkRows: () => chunkRows
|
|
13548
13764
|
});
|
|
13549
|
-
import { existsSync as existsSync34, mkdirSync as mkdirSync15, readFileSync as
|
|
13550
|
-
import { join as
|
|
13765
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync15, readFileSync as readFileSync34, writeFileSync as writeFileSync18 } from "fs";
|
|
13766
|
+
import { join as join40 } from "path";
|
|
13551
13767
|
var {env: env4, spawn: spawn2, SQL } = globalThis.Bun;
|
|
13552
|
-
var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA_TYPES, SEED_CANDIDATES, VALUE_FLAGS, paint = (
|
|
13768
|
+
var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA_TYPES, SEED_CANDIDATES, VALUE_FLAGS, paint = (text2, color) => `${color}${text2}${colors.reset}`, chunkRows = (items, size) => Array.from({ length: Math.ceil(items.length / size) }, (_, idx) => items.slice(idx * size, idx * size + size)), quoteIdent = (name) => `"${name.replace(/"/g, '""')}"`, resolveUrl = (explicit) => {
|
|
13553
13769
|
const found = explicit ?? URL_ENV_KEYS.map((key) => env4[key]).find((value) => typeof value === "string" && value !== "");
|
|
13554
13770
|
if (found === undefined || found === "")
|
|
13555
13771
|
throw new Error(`No database URL found. Set ${URL_ENV_KEYS.join(" or ")}, or pass --url <url>.`);
|
|
@@ -13657,19 +13873,19 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13657
13873
|
tables,
|
|
13658
13874
|
v: BACKUP_FORMAT_VERSION
|
|
13659
13875
|
};
|
|
13660
|
-
const dir = options.out ??
|
|
13876
|
+
const dir = options.out ?? join40(process.cwd(), "backups");
|
|
13661
13877
|
mkdirSync15(dir, { recursive: true });
|
|
13662
13878
|
const json = JSON.stringify(payload, (_, value) => typeof value === "bigint" ? value.toString() : value);
|
|
13663
|
-
const file =
|
|
13879
|
+
const file = join40(dir, `backup-${payload.at.replace(/[:.]/g, "-")}.json`);
|
|
13664
13880
|
writeFileSync18(file, json);
|
|
13665
|
-
writeFileSync18(
|
|
13881
|
+
writeFileSync18(join40(dir, "latest.json"), json);
|
|
13666
13882
|
const total = chosen.reduce((sum, name) => sum + (tables[name]?.length ?? 0), 0);
|
|
13667
13883
|
console.log(paint(`\u2713 backup \u2192 ${file}`, colors.green));
|
|
13668
13884
|
console.log(paint(` ${chosen.length} tables, ${total} rows`, colors.dim));
|
|
13669
13885
|
}, runRestore = async (file, options) => {
|
|
13670
13886
|
if (!existsSync34(file))
|
|
13671
13887
|
throw new Error(`Backup not found: ${file}`);
|
|
13672
|
-
const payload = JSON.parse(
|
|
13888
|
+
const payload = JSON.parse(readFileSync34(file, "utf-8"));
|
|
13673
13889
|
const names = Object.keys(payload.tables).filter((name) => keepTable(name, options));
|
|
13674
13890
|
const sql = new SQL(options.url);
|
|
13675
13891
|
const order = dependencyOrder(names, await foreignLinks(sql));
|
|
@@ -13691,7 +13907,7 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13691
13907
|
const total = order.reduce((sum, name) => sum + (payload.tables[name]?.length ?? 0), 0);
|
|
13692
13908
|
console.log(paint(`\u2713 restored ${order.length} tables, ${total} rows (idempotent upsert by primary key)`, colors.green));
|
|
13693
13909
|
}, runSeed = async (entry) => {
|
|
13694
|
-
const target = entry ?? SEED_CANDIDATES.find((candidate) => existsSync34(
|
|
13910
|
+
const target = entry ?? SEED_CANDIDATES.find((candidate) => existsSync34(join40(process.cwd(), candidate)));
|
|
13695
13911
|
if (target === undefined)
|
|
13696
13912
|
throw new Error(`No seed script found (looked for ${SEED_CANDIDATES.join(", ")}). Pass a path: absolute db seed <file>.`);
|
|
13697
13913
|
console.log(paint(`seeding via ${target}\u2026`, colors.cyan));
|
|
@@ -13726,7 +13942,7 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13726
13942
|
return;
|
|
13727
13943
|
}
|
|
13728
13944
|
if (sub === "restore") {
|
|
13729
|
-
const file = positionalArgs(rest)[0] ??
|
|
13945
|
+
const file = positionalArgs(rest)[0] ?? join40(process.cwd(), "backups", "latest.json");
|
|
13730
13946
|
await runRestore(file, parseOptions(rest));
|
|
13731
13947
|
return;
|
|
13732
13948
|
}
|
|
@@ -13840,16 +14056,16 @@ var init_logs = __esm(() => {
|
|
|
13840
14056
|
// src/cli/typeGraphCoherence.ts
|
|
13841
14057
|
import {
|
|
13842
14058
|
existsSync as existsSync36,
|
|
13843
|
-
readFileSync as
|
|
14059
|
+
readFileSync as readFileSync35,
|
|
13844
14060
|
realpathSync as realpathSync2,
|
|
13845
14061
|
rmSync as rmSync6,
|
|
13846
14062
|
writeFileSync as writeFileSync19
|
|
13847
14063
|
} from "fs";
|
|
13848
14064
|
import { createRequire } from "module";
|
|
13849
|
-
import { dirname as dirname24, join as
|
|
14065
|
+
import { dirname as dirname24, join as join41, resolve as resolve32, sep as sep5 } from "path";
|
|
13850
14066
|
var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
13851
14067
|
try {
|
|
13852
|
-
const parsed = JSON.parse(
|
|
14068
|
+
const parsed = JSON.parse(readFileSync35(path, "utf-8"));
|
|
13853
14069
|
return isRecord9(parsed) ? parsed : null;
|
|
13854
14070
|
} catch {
|
|
13855
14071
|
return null;
|
|
@@ -13868,7 +14084,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13868
14084
|
}, packageJsonFromEntry = (entry, expectedName) => {
|
|
13869
14085
|
let directory = dirname24(entry);
|
|
13870
14086
|
for (;; ) {
|
|
13871
|
-
const candidate =
|
|
14087
|
+
const candidate = join41(directory, "package.json");
|
|
13872
14088
|
const manifest = readManifest(candidate);
|
|
13873
14089
|
if (manifest && manifestName(manifest, "") === expectedName)
|
|
13874
14090
|
return candidate;
|
|
@@ -13888,27 +14104,27 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13888
14104
|
}
|
|
13889
14105
|
}
|
|
13890
14106
|
}, findInstallRoot = (cwd) => {
|
|
13891
|
-
let directory =
|
|
14107
|
+
let directory = resolve32(cwd);
|
|
13892
14108
|
for (;; ) {
|
|
13893
|
-
if (existsSync36(
|
|
14109
|
+
if (existsSync36(join41(directory, "bun.lock")) || existsSync36(join41(directory, "bun.lockb"))) {
|
|
13894
14110
|
return directory;
|
|
13895
14111
|
}
|
|
13896
14112
|
const parent = dirname24(directory);
|
|
13897
14113
|
if (parent === directory)
|
|
13898
|
-
return
|
|
14114
|
+
return resolve32(cwd);
|
|
13899
14115
|
directory = parent;
|
|
13900
14116
|
}
|
|
13901
14117
|
}, findProjectManifest = (cwd, installRoot) => {
|
|
13902
|
-
let directory =
|
|
14118
|
+
let directory = resolve32(cwd);
|
|
13903
14119
|
for (;; ) {
|
|
13904
|
-
const candidate =
|
|
14120
|
+
const candidate = join41(directory, "package.json");
|
|
13905
14121
|
if (existsSync36(candidate))
|
|
13906
14122
|
return candidate;
|
|
13907
14123
|
if (directory === installRoot)
|
|
13908
|
-
return
|
|
14124
|
+
return join41(installRoot, "package.json");
|
|
13909
14125
|
const parent = dirname24(directory);
|
|
13910
14126
|
if (parent === directory)
|
|
13911
|
-
return
|
|
14127
|
+
return join41(installRoot, "package.json");
|
|
13912
14128
|
directory = parent;
|
|
13913
14129
|
}
|
|
13914
14130
|
}, appendConsumer = (consumers, consumerPaths, path, manifest) => {
|
|
@@ -13946,7 +14162,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13946
14162
|
appendConsumer(consumers, consumerPaths, inspection.consumer.path, inspection.consumer.manifest);
|
|
13947
14163
|
}, inspectTypeGraph = (cwd) => {
|
|
13948
14164
|
const installRoot = findInstallRoot(cwd);
|
|
13949
|
-
const rootManifestPath =
|
|
14165
|
+
const rootManifestPath = join41(installRoot, "package.json");
|
|
13950
14166
|
const rootManifest = readManifest(rootManifestPath) ?? {};
|
|
13951
14167
|
const consumers = [
|
|
13952
14168
|
{ manifest: rootManifest, path: rootManifestPath }
|
|
@@ -13982,7 +14198,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13982
14198
|
const duplicates = duplicateTypeGraphPackages(report);
|
|
13983
14199
|
if (duplicates.length === 0)
|
|
13984
14200
|
return [];
|
|
13985
|
-
const manifestPath =
|
|
14201
|
+
const manifestPath = join41(report.installRoot, "package.json");
|
|
13986
14202
|
const manifest = readManifest(manifestPath);
|
|
13987
14203
|
if (!manifest)
|
|
13988
14204
|
return [];
|
|
@@ -14004,7 +14220,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
14004
14220
|
}
|
|
14005
14221
|
return changes;
|
|
14006
14222
|
}, removeDuplicateTypeGraphPackages = (report) => {
|
|
14007
|
-
const manifest = readManifest(
|
|
14223
|
+
const manifest = readManifest(join41(report.installRoot, "package.json")) ?? {};
|
|
14008
14224
|
const rootName = manifestName(manifest, "<workspace>");
|
|
14009
14225
|
const installPrefix = `${realpathSync2(report.installRoot)}${sep5}`;
|
|
14010
14226
|
const nodeModulesSegment = `${sep5}node_modules${sep5}`;
|
|
@@ -14043,10 +14259,10 @@ var exports_doctor = {};
|
|
|
14043
14259
|
__export(exports_doctor, {
|
|
14044
14260
|
runDoctor: () => runDoctor
|
|
14045
14261
|
});
|
|
14046
|
-
import { existsSync as existsSync37, mkdirSync as mkdirSync16, readFileSync as
|
|
14262
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync16, readFileSync as readFileSync36, writeFileSync as writeFileSync20 } from "fs";
|
|
14047
14263
|
import { createRequire as createRequire2 } from "module";
|
|
14048
14264
|
import { arch as arch4, platform as platform5 } from "os";
|
|
14049
|
-
import { join as
|
|
14265
|
+
import { join as join42 } from "path";
|
|
14050
14266
|
var FRAMEWORK_FIELDS2, projectRequire, check = (status2, label, detail) => ({
|
|
14051
14267
|
detail,
|
|
14052
14268
|
label,
|
|
@@ -14081,7 +14297,7 @@ var FRAMEWORK_FIELDS2, projectRequire, check = (status2, label, detail) => ({
|
|
|
14081
14297
|
return [];
|
|
14082
14298
|
const label = `${field.replace("Directory", "")} pages`;
|
|
14083
14299
|
return [
|
|
14084
|
-
existsSync37(
|
|
14300
|
+
existsSync37(join42(process.cwd(), dir)) ? check("ok", label, dir) : check("fail", label, `${dir} (missing)`)
|
|
14085
14301
|
];
|
|
14086
14302
|
}), envCheck = async () => {
|
|
14087
14303
|
const vars = await collectEnvVars();
|
|
@@ -14143,9 +14359,9 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
14143
14359
|
const fixes = [];
|
|
14144
14360
|
for (const field of FRAMEWORK_FIELDS2) {
|
|
14145
14361
|
const dir = readString2(config, field);
|
|
14146
|
-
if (dir === undefined || existsSync37(
|
|
14362
|
+
if (dir === undefined || existsSync37(join42(cwd, dir)))
|
|
14147
14363
|
continue;
|
|
14148
|
-
mkdirSync16(
|
|
14364
|
+
mkdirSync16(join42(cwd, dir, "pages"), { recursive: true });
|
|
14149
14365
|
fixes.push(`created ${dir}/pages`);
|
|
14150
14366
|
}
|
|
14151
14367
|
return fixes;
|
|
@@ -14153,8 +14369,8 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
14153
14369
|
const missing = (await collectEnvVars()).filter((entry) => !entry.set);
|
|
14154
14370
|
if (missing.length === 0)
|
|
14155
14371
|
return null;
|
|
14156
|
-
const envExample =
|
|
14157
|
-
const existing = existsSync37(envExample) ?
|
|
14372
|
+
const envExample = join42(cwd, ".env.example");
|
|
14373
|
+
const existing = existsSync37(envExample) ? readFileSync36(envExample, "utf-8") : "";
|
|
14158
14374
|
const existingKeys = new Set(existing.split(`
|
|
14159
14375
|
`).map((line) => line.split("=")[0]?.trim()));
|
|
14160
14376
|
const toAdd = missing.filter((entry) => !existingKeys.has(entry.key));
|
|
@@ -14224,7 +14440,7 @@ var init_doctor = __esm(() => {
|
|
|
14224
14440
|
"htmlDirectory",
|
|
14225
14441
|
"htmxDirectory"
|
|
14226
14442
|
];
|
|
14227
|
-
projectRequire = createRequire2(
|
|
14443
|
+
projectRequire = createRequire2(join42(process.cwd(), "package.json"));
|
|
14228
14444
|
STATUS_MARK = {
|
|
14229
14445
|
fail: `${colors.red}\u2717${colors.reset}`,
|
|
14230
14446
|
ok: `${colors.green}\u2713${colors.reset}`,
|
|
@@ -14613,8 +14829,8 @@ var init_sourceMetadata = __esm(() => {
|
|
|
14613
14829
|
});
|
|
14614
14830
|
|
|
14615
14831
|
// src/islands/pageMetadata.ts
|
|
14616
|
-
import { readFileSync as
|
|
14617
|
-
import { dirname as dirname25, resolve as
|
|
14832
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
14833
|
+
import { dirname as dirname25, resolve as resolve33 } from "path";
|
|
14618
14834
|
var pagePatterns, getPageDirs = (config) => [
|
|
14619
14835
|
{ dir: config.angularDirectory, framework: "angular" },
|
|
14620
14836
|
{ dir: config.emberDirectory, framework: "ember" },
|
|
@@ -14634,8 +14850,8 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
14634
14850
|
const source = definition.buildReference?.source;
|
|
14635
14851
|
if (!source)
|
|
14636
14852
|
continue;
|
|
14637
|
-
const resolvedSource = source.startsWith("file://") ? new URL(source).pathname :
|
|
14638
|
-
lookup.set(`${definition.framework}:${definition.component}`,
|
|
14853
|
+
const resolvedSource = source.startsWith("file://") ? new URL(source).pathname : resolve33(dirname25(buildInfo.resolvedRegistryPath), source);
|
|
14854
|
+
lookup.set(`${definition.framework}:${definition.component}`, resolve33(resolvedSource));
|
|
14639
14855
|
}
|
|
14640
14856
|
return lookup;
|
|
14641
14857
|
}, resolveIslandUsages = (islands, islandSourceLookup) => islands.map((usage2) => {
|
|
@@ -14648,13 +14864,13 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
14648
14864
|
const pattern = pagePatterns[entry.framework];
|
|
14649
14865
|
if (!pattern)
|
|
14650
14866
|
return;
|
|
14651
|
-
const files = await scanEntryPoints(
|
|
14867
|
+
const files = await scanEntryPoints(resolve33(entry.dir), pattern);
|
|
14652
14868
|
for (const filePath of files) {
|
|
14653
|
-
const source =
|
|
14869
|
+
const source = readFileSync37(filePath, "utf-8");
|
|
14654
14870
|
const islands = extractIslandUsagesFromSource(source);
|
|
14655
|
-
pageMetadata.set(
|
|
14871
|
+
pageMetadata.set(resolve33(filePath), {
|
|
14656
14872
|
islands: resolveIslandUsages(islands, islandSourceLookup),
|
|
14657
|
-
pagePath:
|
|
14873
|
+
pagePath: resolve33(filePath)
|
|
14658
14874
|
});
|
|
14659
14875
|
}
|
|
14660
14876
|
}, loadPageIslandMetadata = async (config) => {
|
|
@@ -14683,14 +14899,14 @@ var exports_islands = {};
|
|
|
14683
14899
|
__export(exports_islands, {
|
|
14684
14900
|
runIslands: () => runIslands
|
|
14685
14901
|
});
|
|
14686
|
-
import { existsSync as existsSync39, readFileSync as
|
|
14687
|
-
import { join as
|
|
14902
|
+
import { existsSync as existsSync39, readFileSync as readFileSync38, statSync as statSync5 } from "fs";
|
|
14903
|
+
import { join as join43, relative as relative22, resolve as resolve34 } from "path";
|
|
14688
14904
|
var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.write(`${colors.dim}${message}${colors.reset}
|
|
14689
14905
|
`), hostFrameworkOf = (pagePath, cwd, config) => {
|
|
14690
|
-
const resolved =
|
|
14906
|
+
const resolved = resolve34(cwd, pagePath);
|
|
14691
14907
|
for (const [framework, key] of Object.entries(FRAMEWORK_DIR_KEY)) {
|
|
14692
14908
|
const dir = config[key];
|
|
14693
|
-
if (typeof dir === "string" && resolved.startsWith(
|
|
14909
|
+
if (typeof dir === "string" && resolved.startsWith(resolve34(cwd, dir))) {
|
|
14694
14910
|
return framework;
|
|
14695
14911
|
}
|
|
14696
14912
|
}
|
|
@@ -14702,20 +14918,20 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14702
14918
|
return 0;
|
|
14703
14919
|
}
|
|
14704
14920
|
}, readManifestSizes2 = (manifestDir) => {
|
|
14705
|
-
const manifestPath =
|
|
14921
|
+
const manifestPath = join43(manifestDir, "manifest.json");
|
|
14706
14922
|
if (!existsSync39(manifestPath))
|
|
14707
14923
|
return null;
|
|
14708
|
-
const manifest = JSON.parse(
|
|
14924
|
+
const manifest = JSON.parse(readFileSync38(manifestPath, "utf-8"));
|
|
14709
14925
|
const sizes = new Map;
|
|
14710
14926
|
for (const [key, value] of Object.entries(manifest)) {
|
|
14711
|
-
sizes.set(key, fileSize3(
|
|
14927
|
+
sizes.set(key, fileSize3(join43(manifestDir, value.replace(/^\//, ""))));
|
|
14712
14928
|
}
|
|
14713
14929
|
return sizes;
|
|
14714
14930
|
}, collectIslands = async (cwd, config, sizes) => {
|
|
14715
14931
|
const registryPath = config.islands?.registry;
|
|
14716
14932
|
if (typeof registryPath !== "string")
|
|
14717
14933
|
return null;
|
|
14718
|
-
const buildInfo = await loadIslandRegistryBuildInfo(
|
|
14934
|
+
const buildInfo = await loadIslandRegistryBuildInfo(resolve34(cwd, registryPath));
|
|
14719
14935
|
const pageMetadata = await loadPageIslandMetadata(config);
|
|
14720
14936
|
const usages = [...pageMetadata.values()].flatMap((meta) => meta.islands.map((island) => ({ ...island, page: meta.pagePath })));
|
|
14721
14937
|
return buildInfo.definitions.map((definition) => {
|
|
@@ -14725,7 +14941,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14725
14941
|
crossFramework: hostFramework !== null && hostFramework !== definition.framework,
|
|
14726
14942
|
hostFramework,
|
|
14727
14943
|
hydrate: usage2.hydrate ?? "load",
|
|
14728
|
-
page:
|
|
14944
|
+
page: relative22(cwd, resolve34(cwd, usage2.page))
|
|
14729
14945
|
};
|
|
14730
14946
|
});
|
|
14731
14947
|
const key = getIslandManifestKey(definition.framework, definition.component);
|
|
@@ -14764,7 +14980,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14764
14980
|
` ${color}\u2B21${colors.reset} ${colors.bold}${island.component}${colors.reset} ${meta}${sizeText}`
|
|
14765
14981
|
];
|
|
14766
14982
|
if (island.source) {
|
|
14767
|
-
lines.push(` ${colors.dim}${
|
|
14983
|
+
lines.push(` ${colors.dim}${relative22(cwd, island.source)}${colors.reset}`);
|
|
14768
14984
|
}
|
|
14769
14985
|
if (pages.length === 0) {
|
|
14770
14986
|
lines.push(` ${colors.dim}(registered but not mounted on any page)${colors.reset}`);
|
|
@@ -14794,7 +15010,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14794
15010
|
}
|
|
14795
15011
|
const outdirIndex = args.indexOf("--outdir");
|
|
14796
15012
|
const outdir = outdirIndex >= 0 ? args[outdirIndex + 1] : config.buildDirectory;
|
|
14797
|
-
const sizes = args.includes("--sizes") ? readManifestSizes2(
|
|
15013
|
+
const sizes = args.includes("--sizes") ? readManifestSizes2(resolve34(cwd, outdir ?? "build")) : null;
|
|
14798
15014
|
const islands = await collectIslands(cwd, config, sizes);
|
|
14799
15015
|
if (islands === null) {
|
|
14800
15016
|
printDim6('No island registry configured. Set `islands: { registry: "..." }` in absolute.config.ts.');
|
|
@@ -14844,12 +15060,12 @@ var init_islands2 = __esm(() => {
|
|
|
14844
15060
|
|
|
14845
15061
|
// src/build/externalAssetPlugin.ts
|
|
14846
15062
|
import { copyFileSync as copyFileSync2, existsSync as existsSync40, mkdirSync as mkdirSync17, statSync as statSync6 } from "fs";
|
|
14847
|
-
import { basename as basename11, dirname as dirname26, join as
|
|
15063
|
+
import { basename as basename11, dirname as dirname26, join as join44, resolve as resolve35 } from "path";
|
|
14848
15064
|
var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
14849
15065
|
name: "absolute-external-asset",
|
|
14850
15066
|
setup(bld) {
|
|
14851
15067
|
const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
|
|
14852
|
-
const skipRoots = userSourceRoots.map((root) =>
|
|
15068
|
+
const skipRoots = userSourceRoots.map((root) => resolve35(root));
|
|
14853
15069
|
const isUserSource = (path) => skipRoots.some((root) => path.startsWith(`${root}/`));
|
|
14854
15070
|
bld.onLoad({ filter: /\.[mc]?[jt]sx?$/ }, async (args) => {
|
|
14855
15071
|
if (isUserSource(args.path))
|
|
@@ -14864,12 +15080,12 @@ var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
|
14864
15080
|
const relPath = match[1];
|
|
14865
15081
|
if (!relPath)
|
|
14866
15082
|
continue;
|
|
14867
|
-
const assetPath =
|
|
15083
|
+
const assetPath = resolve35(sourceDir, relPath);
|
|
14868
15084
|
if (!existsSync40(assetPath))
|
|
14869
15085
|
continue;
|
|
14870
15086
|
if (!statSync6(assetPath).isFile())
|
|
14871
15087
|
continue;
|
|
14872
|
-
const targetPath =
|
|
15088
|
+
const targetPath = join44(outDir, basename11(assetPath));
|
|
14873
15089
|
if (existsSync40(targetPath))
|
|
14874
15090
|
continue;
|
|
14875
15091
|
mkdirSync17(dirname26(targetPath), { recursive: true });
|
|
@@ -14893,7 +15109,7 @@ import {
|
|
|
14893
15109
|
existsSync as existsSync41,
|
|
14894
15110
|
mkdirSync as mkdirSync18,
|
|
14895
15111
|
readdirSync as readdirSync7,
|
|
14896
|
-
readFileSync as
|
|
15112
|
+
readFileSync as readFileSync39,
|
|
14897
15113
|
rmSync as rmSync7,
|
|
14898
15114
|
statSync as statSync7,
|
|
14899
15115
|
unlinkSync as unlinkSync4,
|
|
@@ -14904,9 +15120,9 @@ import {
|
|
|
14904
15120
|
basename as basename12,
|
|
14905
15121
|
dirname as dirname27,
|
|
14906
15122
|
isAbsolute as isAbsolute6,
|
|
14907
|
-
join as
|
|
14908
|
-
relative as
|
|
14909
|
-
resolve as
|
|
15123
|
+
join as join45,
|
|
15124
|
+
relative as relative23,
|
|
15125
|
+
resolve as resolve36
|
|
14910
15126
|
} from "path";
|
|
14911
15127
|
var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
|
|
14912
15128
|
const resolvedVersion = version2 || "unknown";
|
|
@@ -14920,7 +15136,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14920
15136
|
const entry = pending.pop();
|
|
14921
15137
|
if (!entry)
|
|
14922
15138
|
continue;
|
|
14923
|
-
const fullPath =
|
|
15139
|
+
const fullPath = join45(entry.parentPath, entry.name);
|
|
14924
15140
|
if (entry.isDirectory())
|
|
14925
15141
|
pending = pending.concat(readdirSync7(fullPath, { withFileTypes: true }));
|
|
14926
15142
|
else
|
|
@@ -14928,7 +15144,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14928
15144
|
}
|
|
14929
15145
|
return result;
|
|
14930
15146
|
}, INLINE_SOURCE_MAP_RE, rebaseInlineSourceMap = (filePath) => {
|
|
14931
|
-
const source =
|
|
15147
|
+
const source = readFileSync39(filePath, "utf-8");
|
|
14932
15148
|
const match = source.match(INLINE_SOURCE_MAP_RE);
|
|
14933
15149
|
const encoded = match?.[1];
|
|
14934
15150
|
if (!encoded)
|
|
@@ -14948,7 +15164,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14948
15164
|
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(sourceRoot)) {
|
|
14949
15165
|
return new URL(entry, sourceRoot).href;
|
|
14950
15166
|
}
|
|
14951
|
-
return
|
|
15167
|
+
return resolve36(bundleDirectory, sourceRoot, entry);
|
|
14952
15168
|
});
|
|
14953
15169
|
delete map.sourceRoot;
|
|
14954
15170
|
const rebased = Buffer.from(JSON.stringify(map)).toString("base64");
|
|
@@ -14966,7 +15182,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14966
15182
|
const entry = pending.pop();
|
|
14967
15183
|
if (!entry)
|
|
14968
15184
|
continue;
|
|
14969
|
-
const fullPath =
|
|
15185
|
+
const fullPath = join45(entry.parentPath, entry.name);
|
|
14970
15186
|
if (entry.isDirectory()) {
|
|
14971
15187
|
if (SERVER_RUNTIME_SCAN_SKIP_DIRS.has(entry.name))
|
|
14972
15188
|
continue;
|
|
@@ -14978,12 +15194,12 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14978
15194
|
return result;
|
|
14979
15195
|
}, copyServerRuntimeAssetReferences = (outdir) => {
|
|
14980
15196
|
const copied = new Set;
|
|
14981
|
-
const normalizedOutdir =
|
|
15197
|
+
const normalizedOutdir = resolve36(outdir);
|
|
14982
15198
|
const copyReference = (filePath, relPath) => {
|
|
14983
|
-
const assetSource =
|
|
15199
|
+
const assetSource = resolve36(dirname27(filePath), relPath);
|
|
14984
15200
|
if (!existsSync41(assetSource) || !statSync7(assetSource).isFile())
|
|
14985
15201
|
return;
|
|
14986
|
-
const assetTarget =
|
|
15202
|
+
const assetTarget = resolve36(normalizedOutdir, relPath.replace(/^\.\//, ""));
|
|
14987
15203
|
if (assetTarget !== normalizedOutdir && !assetTarget.startsWith(`${normalizedOutdir}/`))
|
|
14988
15204
|
return;
|
|
14989
15205
|
if (copied.has(assetTarget))
|
|
@@ -14993,7 +15209,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14993
15209
|
cpSync(assetSource, assetTarget, { force: true });
|
|
14994
15210
|
};
|
|
14995
15211
|
for (const filePath of collectProjectSourceFiles(process.cwd())) {
|
|
14996
|
-
const source =
|
|
15212
|
+
const source = readFileSync39(filePath, "utf-8");
|
|
14997
15213
|
SERVER_RUNTIME_ASSET_RE.lastIndex = 0;
|
|
14998
15214
|
let match;
|
|
14999
15215
|
while ((match = SERVER_RUNTIME_ASSET_RE.exec(source)) !== null) {
|
|
@@ -15022,7 +15238,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15022
15238
|
}
|
|
15023
15239
|
}, readPackageVersion4 = (candidate) => {
|
|
15024
15240
|
try {
|
|
15025
|
-
const pkg = JSON.parse(
|
|
15241
|
+
const pkg = JSON.parse(readFileSync39(candidate, "utf-8"));
|
|
15026
15242
|
if (pkg.name !== "@absolutejs/absolute")
|
|
15027
15243
|
return null;
|
|
15028
15244
|
const ver = pkg.version;
|
|
@@ -15057,18 +15273,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15057
15273
|
return resolveBuildModule3(remaining);
|
|
15058
15274
|
}, resolveJsxDevRuntimeCompatPath2 = () => {
|
|
15059
15275
|
const candidates = [
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
|
|
15064
|
-
|
|
15065
|
-
|
|
15276
|
+
resolve36(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
15277
|
+
resolve36(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
15278
|
+
resolve36(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
|
|
15279
|
+
resolve36(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
15280
|
+
resolve36(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
15281
|
+
resolve36(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
|
|
15066
15282
|
];
|
|
15067
15283
|
for (const candidate of candidates) {
|
|
15068
15284
|
if (existsSync41(candidate))
|
|
15069
15285
|
return candidate;
|
|
15070
15286
|
}
|
|
15071
|
-
return
|
|
15287
|
+
return resolve36(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
|
|
15072
15288
|
}, jsxDevRuntimeCompatPath2, shouldEmbedCompiledAsset = (relativePath, skip = new Set) => {
|
|
15073
15289
|
if (skip.has(relativePath))
|
|
15074
15290
|
return false;
|
|
@@ -15093,7 +15309,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15093
15309
|
return true;
|
|
15094
15310
|
}), requireForCompile, resolveNativeAssetForRuntime = (specifier) => {
|
|
15095
15311
|
if (specifier.startsWith("."))
|
|
15096
|
-
return
|
|
15312
|
+
return resolve36(process.cwd(), specifier);
|
|
15097
15313
|
if (specifier.startsWith("/"))
|
|
15098
15314
|
return specifier;
|
|
15099
15315
|
return requireForCompile.resolve(specifier, { paths: [process.cwd()] });
|
|
@@ -15105,11 +15321,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15105
15321
|
return nativeAssetEnv;
|
|
15106
15322
|
}, tryReadNodePackageJson = (packageDir) => {
|
|
15107
15323
|
try {
|
|
15108
|
-
return JSON.parse(
|
|
15324
|
+
return JSON.parse(readFileSync39(join45(packageDir, "package.json"), "utf-8"));
|
|
15109
15325
|
} catch {
|
|
15110
15326
|
return null;
|
|
15111
15327
|
}
|
|
15112
|
-
}, resolveProjectPackageDir = (specifier) =>
|
|
15328
|
+
}, resolveProjectPackageDir = (specifier) => resolve36(process.cwd(), "node_modules", ...specifier.split("/")), copyPackageToBuild = (specifier, outdir, seen) => {
|
|
15113
15329
|
if (seen.has(specifier))
|
|
15114
15330
|
return;
|
|
15115
15331
|
const srcDir = resolveProjectPackageDir(specifier);
|
|
@@ -15117,13 +15333,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15117
15333
|
if (!pkg)
|
|
15118
15334
|
return;
|
|
15119
15335
|
seen.add(specifier);
|
|
15120
|
-
const destDir =
|
|
15336
|
+
const destDir = join45(outdir, "node_modules", ...specifier.split("/"));
|
|
15121
15337
|
rmSync7(destDir, { force: true, recursive: true });
|
|
15122
15338
|
cpSync(srcDir, destDir, {
|
|
15123
15339
|
force: true,
|
|
15124
15340
|
recursive: true,
|
|
15125
15341
|
filter(source) {
|
|
15126
|
-
const rel =
|
|
15342
|
+
const rel = relative23(srcDir, source);
|
|
15127
15343
|
const [firstSegment] = rel.split(/[\\/]/);
|
|
15128
15344
|
return firstSegment !== "node_modules" && firstSegment !== ".git";
|
|
15129
15345
|
}
|
|
@@ -15139,7 +15355,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15139
15355
|
}, copyAngularRuntimePackages = (buildConfig, outdir) => {
|
|
15140
15356
|
if (!buildConfig.angularDirectory)
|
|
15141
15357
|
return;
|
|
15142
|
-
const angularScopeDir =
|
|
15358
|
+
const angularScopeDir = resolve36(process.cwd(), "node_modules", "@angular");
|
|
15143
15359
|
const angularPackages = existsSync41(angularScopeDir) ? readdirSync7(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
|
|
15144
15360
|
const roots = new Set([...angularPackages, "rxjs", "tslib", "typescript"]);
|
|
15145
15361
|
const seen = new Set;
|
|
@@ -15158,7 +15374,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15158
15374
|
copyAngularRuntimePackages(buildConfig, outdir);
|
|
15159
15375
|
copyChunkReferencedPackages(outdir, seen);
|
|
15160
15376
|
}, collectRuntimePackageSpecifiers = (distDir) => {
|
|
15161
|
-
const nodeModulesDir =
|
|
15377
|
+
const nodeModulesDir = join45(distDir, "node_modules");
|
|
15162
15378
|
if (!existsSync41(nodeModulesDir))
|
|
15163
15379
|
return [];
|
|
15164
15380
|
const specifiers = [];
|
|
@@ -15166,7 +15382,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15166
15382
|
if (!entry.isDirectory())
|
|
15167
15383
|
continue;
|
|
15168
15384
|
if (entry.name.startsWith("@")) {
|
|
15169
|
-
const scopeDir =
|
|
15385
|
+
const scopeDir = join45(nodeModulesDir, entry.name);
|
|
15170
15386
|
for (const scopedEntry of readdirSync7(scopeDir, {
|
|
15171
15387
|
withFileTypes: true
|
|
15172
15388
|
})) {
|
|
@@ -15180,7 +15396,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15180
15396
|
}
|
|
15181
15397
|
return specifiers.sort((firstSpecifier, secondSpecifier) => secondSpecifier.length - firstSpecifier.length);
|
|
15182
15398
|
}, ensureRelativeModuleSpecifier = (fromFile, toFile) => {
|
|
15183
|
-
const rel =
|
|
15399
|
+
const rel = relative23(dirname27(fromFile), toFile).replace(/\\/g, "/");
|
|
15184
15400
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
15185
15401
|
}, pickExportEntry = (value) => {
|
|
15186
15402
|
if (typeof value === "string")
|
|
@@ -15197,18 +15413,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15197
15413
|
const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
|
|
15198
15414
|
if (!packageSpecifier)
|
|
15199
15415
|
return null;
|
|
15200
|
-
const packageDir =
|
|
15416
|
+
const packageDir = join45(distDir, "node_modules", ...packageSpecifier.split("/"));
|
|
15201
15417
|
const subpath = specifier.slice(packageSpecifier.length);
|
|
15202
|
-
const subPackageDir = subpath ?
|
|
15203
|
-
const resolvedPackageDir = subPackageDir && existsSync41(
|
|
15204
|
-
const packageJsonPath =
|
|
15418
|
+
const subPackageDir = subpath ? join45(packageDir, ...subpath.slice(1).split("/")) : null;
|
|
15419
|
+
const resolvedPackageDir = subPackageDir && existsSync41(join45(subPackageDir, "package.json")) ? subPackageDir : packageDir;
|
|
15420
|
+
const packageJsonPath = join45(resolvedPackageDir, "package.json");
|
|
15205
15421
|
if (!existsSync41(packageJsonPath))
|
|
15206
15422
|
return null;
|
|
15207
|
-
const pkg = JSON.parse(
|
|
15423
|
+
const pkg = JSON.parse(readFileSync39(packageJsonPath, "utf-8"));
|
|
15208
15424
|
const exportKey = resolvedPackageDir !== subPackageDir && subpath ? `.${subpath}` : ".";
|
|
15209
15425
|
const rootExport = pkg.exports?.[exportKey];
|
|
15210
15426
|
const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
|
|
15211
|
-
return
|
|
15427
|
+
return join45(resolvedPackageDir, entry);
|
|
15212
15428
|
}, RUNTIME_JS_EXTENSIONS, MODULE_SPECIFIER_RE, isRuntimeJsFile = (filePath) => RUNTIME_JS_EXTENSIONS.some((extension) => filePath.endsWith(extension)), isNodeModulesPath = (filePath) => filePath.split(/[\\/]/).includes("node_modules"), isFile = (filePath) => {
|
|
15213
15429
|
try {
|
|
15214
15430
|
return statSync7(filePath).isFile();
|
|
@@ -15221,13 +15437,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15221
15437
|
const candidates = [
|
|
15222
15438
|
candidate,
|
|
15223
15439
|
...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
|
|
15224
|
-
...RUNTIME_JS_EXTENSIONS.map((extension) =>
|
|
15440
|
+
...RUNTIME_JS_EXTENSIONS.map((extension) => join45(candidate, `index${extension}`))
|
|
15225
15441
|
];
|
|
15226
15442
|
return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
|
|
15227
15443
|
}, findContainingRuntimePackageDir = (filePath) => {
|
|
15228
15444
|
let dir = dirname27(filePath);
|
|
15229
15445
|
while (dir !== dirname27(dir)) {
|
|
15230
|
-
if (isNodeModulesPath(dir) && existsSync41(
|
|
15446
|
+
if (isNodeModulesPath(dir) && existsSync41(join45(dir, "package.json"))) {
|
|
15231
15447
|
return dir;
|
|
15232
15448
|
}
|
|
15233
15449
|
dir = dirname27(dir);
|
|
@@ -15243,13 +15459,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15243
15459
|
const entry = pickExportEntry(pkg?.imports?.[specifier]);
|
|
15244
15460
|
if (!entry)
|
|
15245
15461
|
return null;
|
|
15246
|
-
return
|
|
15462
|
+
return join45(packageDir, entry);
|
|
15247
15463
|
}, collectRuntimeRewriteRoots = (distDir) => collectFiles2(distDir).filter((filePath) => isRuntimeJsFile(filePath) && !isNodeModulesPath(filePath)), toTopLevelPackage = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/"), FRAMEWORK_PACKAGE_NAME = "@absolutejs/absolute", copyChunkReferencedPackages = (distDir, seen) => {
|
|
15248
|
-
const distRoot =
|
|
15464
|
+
const distRoot = resolve36(distDir);
|
|
15249
15465
|
for (const filePath of collectRuntimeRewriteRoots(distDir)) {
|
|
15250
|
-
if (
|
|
15466
|
+
if (resolve36(dirname27(filePath)) === distRoot)
|
|
15251
15467
|
continue;
|
|
15252
|
-
const source =
|
|
15468
|
+
const source = readFileSync39(filePath, "utf-8");
|
|
15253
15469
|
for (const match of source.matchAll(MODULE_SPECIFIER_RE)) {
|
|
15254
15470
|
const [, , , specifier] = match;
|
|
15255
15471
|
if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.startsWith("node:") || specifier.startsWith("bun:")) {
|
|
@@ -15279,11 +15495,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15279
15495
|
if (!filePath || seen.has(filePath))
|
|
15280
15496
|
continue;
|
|
15281
15497
|
seen.add(filePath);
|
|
15282
|
-
const source =
|
|
15498
|
+
const source = readFileSync39(filePath, "utf-8");
|
|
15283
15499
|
const { masked, restore } = maskLiterals(source);
|
|
15284
15500
|
const rewrittenMasked = masked.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
|
|
15285
15501
|
if (typeof specifier === "string" && specifier.startsWith(".")) {
|
|
15286
|
-
enqueue(resolveRuntimeJsFile(
|
|
15502
|
+
enqueue(resolveRuntimeJsFile(resolve36(dirname27(filePath), specifier)));
|
|
15287
15503
|
return match;
|
|
15288
15504
|
}
|
|
15289
15505
|
const packageImportTarget = resolveRuntimeJsFile(resolvePackageImportEntryFile(filePath, specifier) ?? "");
|
|
@@ -15312,12 +15528,12 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15312
15528
|
"_compile_entrypoint.ts"
|
|
15313
15529
|
]);
|
|
15314
15530
|
const embeddedFiles = allFiles.filter((file) => {
|
|
15315
|
-
const rel =
|
|
15531
|
+
const rel = relative23(distDir, file);
|
|
15316
15532
|
if (embeddedSkip.has(rel))
|
|
15317
15533
|
return false;
|
|
15318
15534
|
return true;
|
|
15319
15535
|
});
|
|
15320
|
-
const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(
|
|
15536
|
+
const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(relative23(distDir, file), assetSkip));
|
|
15321
15537
|
const imports = [];
|
|
15322
15538
|
const nativeImports = [];
|
|
15323
15539
|
const nativeMappings = [];
|
|
@@ -15327,19 +15543,19 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15327
15543
|
const nativeAssets = resolveCompileNativeAssets(buildConfig);
|
|
15328
15544
|
nativeAssets.forEach((asset, idx) => {
|
|
15329
15545
|
const varName = `__native${idx}`;
|
|
15330
|
-
const importSpecifier = asset.import.startsWith(".") ?
|
|
15546
|
+
const importSpecifier = asset.import.startsWith(".") ? resolve36(process.cwd(), asset.import) : asset.import;
|
|
15331
15547
|
nativeImports.push(`import ${varName} from ${JSON.stringify(importSpecifier)} with { type: "file" };`);
|
|
15332
15548
|
nativeMappings.push(` [${JSON.stringify(asset.env)}, resolveNativeAssetPath(${varName})],`);
|
|
15333
15549
|
});
|
|
15334
15550
|
embeddedFiles.forEach((filePath, idx) => {
|
|
15335
|
-
const rel =
|
|
15551
|
+
const rel = relative23(distDir, filePath).replace(/\\/g, "/");
|
|
15336
15552
|
const varName = `__a${idx}`;
|
|
15337
15553
|
embeddedVarMap.set(rel, varName);
|
|
15338
15554
|
imports.push(`import ${varName} from "./${rel}" with { type: "file" };`);
|
|
15339
15555
|
embeddedMappings.push(` ["${rel}", ${varName}],`);
|
|
15340
15556
|
});
|
|
15341
15557
|
clientFiles.forEach((filePath) => {
|
|
15342
|
-
const rel =
|
|
15558
|
+
const rel = relative23(distDir, filePath).replace(/\\/g, "/");
|
|
15343
15559
|
const varName = embeddedVarMap.get(rel);
|
|
15344
15560
|
if (!varName)
|
|
15345
15561
|
return;
|
|
@@ -15353,7 +15569,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15353
15569
|
const pageVarMap = new Map;
|
|
15354
15570
|
const prerenderEntries = Array.from(prerenderMap.entries());
|
|
15355
15571
|
prerenderEntries.forEach(([route, filePath]) => {
|
|
15356
|
-
const rel =
|
|
15572
|
+
const rel = relative23(distDir, filePath).replace(/\\/g, "/");
|
|
15357
15573
|
const varName = embeddedVarMap.get(rel);
|
|
15358
15574
|
if (varName)
|
|
15359
15575
|
pageVarMap.set(route, varName);
|
|
@@ -15386,7 +15602,7 @@ import { buildGlobalWSHandler } from "elysia/ws";
|
|
|
15386
15602
|
const SERVER_MODULE = (runtimeDir: string) => import(pathToFileURL(join(runtimeDir, ${JSON.stringify(serverBundleName)})).href);
|
|
15387
15603
|
const RUNTIME_BUILD_ID = ${JSON.stringify(runtimeBuildId)};
|
|
15388
15604
|
const RUNTIME_CONFIG_SOURCE = ${JSON.stringify(runtimeConfigSource)};
|
|
15389
|
-
const ORIGINAL_BUILD_DIR = ${JSON.stringify(
|
|
15605
|
+
const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve36(distDir))};
|
|
15390
15606
|
const ORIGINAL_BUILD_DIR_NORMALIZED = ORIGINAL_BUILD_DIR.replace(/\\\\/g, "/");
|
|
15391
15607
|
const EMBEDDED_NATIVE_AUTH_CLIENTS = ${JSON.stringify(process.env[ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV])};
|
|
15392
15608
|
|
|
@@ -15799,25 +16015,25 @@ console.log(\`
|
|
|
15799
16015
|
const normalizedPath = args.path.replace(/\\/g, "/");
|
|
15800
16016
|
if (normalizedPath.includes("/src/angular/"))
|
|
15801
16017
|
return;
|
|
15802
|
-
const
|
|
15803
|
-
if (
|
|
16018
|
+
const text2 = await Bun.file(args.path).text();
|
|
16019
|
+
if (text2.includes("@Component") && stripStringsAndComments(text2).includes("@Component")) {
|
|
15804
16020
|
return { contents: "export default {}", loader: "js" };
|
|
15805
16021
|
}
|
|
15806
16022
|
return;
|
|
15807
16023
|
});
|
|
15808
16024
|
}
|
|
15809
16025
|
}), compile = async (serverEntry, outdir, outfile, configPath2) => {
|
|
15810
|
-
const resolvedOutdir =
|
|
16026
|
+
const resolvedOutdir = resolve36(outdir ?? "dist");
|
|
15811
16027
|
await withBuildDirectoryLock(resolvedOutdir, () => compileUnlocked(serverEntry, resolvedOutdir, outfile, configPath2));
|
|
15812
16028
|
}, compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath2) => {
|
|
15813
16029
|
const configuredPrerenderPort = env5.COMPILE_PORT === undefined ? Number(env5.PORT) : Number(env5.COMPILE_PORT);
|
|
15814
16030
|
const prerenderPort = configuredPrerenderPort > 0 ? configuredPrerenderPort : await findFreePort();
|
|
15815
16031
|
killStaleProcesses(prerenderPort);
|
|
15816
16032
|
const entryName = basename12(serverEntry).replace(/\.[^.]+$/, "");
|
|
15817
|
-
const resolvedOutfile =
|
|
16033
|
+
const resolvedOutfile = resolve36(outfile ?? "compiled-server");
|
|
15818
16034
|
const absoluteVersion = resolvePackageVersion3([
|
|
15819
|
-
|
|
15820
|
-
|
|
16035
|
+
resolve36(import.meta.dir, "..", "..", "..", "package.json"),
|
|
16036
|
+
resolve36(import.meta.dir, "..", "..", "package.json")
|
|
15821
16037
|
]);
|
|
15822
16038
|
compileBanner(absoluteVersion);
|
|
15823
16039
|
const totalStart = performance.now();
|
|
@@ -15830,8 +16046,8 @@ console.log(\`
|
|
|
15830
16046
|
installAbsoluteMobileAuthEnvironment(process.cwd(), normalizeAbsoluteMobileConfig(buildConfig.mobile, process.cwd()));
|
|
15831
16047
|
try {
|
|
15832
16048
|
const build2 = await resolveBuildModule3([
|
|
15833
|
-
|
|
15834
|
-
|
|
16049
|
+
resolve36(import.meta.dir, "..", "..", "core", "build"),
|
|
16050
|
+
resolve36(import.meta.dir, "..", "build")
|
|
15835
16051
|
]);
|
|
15836
16052
|
if (!build2)
|
|
15837
16053
|
throw new Error("Could not locate build module");
|
|
@@ -15853,11 +16069,11 @@ console.log(\`
|
|
|
15853
16069
|
buildConfig.htmxDirectory
|
|
15854
16070
|
].filter((dir) => Boolean(dir));
|
|
15855
16071
|
const islandRegistrySpec = buildConfig.islands?.registry;
|
|
15856
|
-
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(
|
|
15857
|
-
const serverBundleEntryDirectory =
|
|
16072
|
+
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve36(islandRegistrySpec))) : undefined;
|
|
16073
|
+
const serverBundleEntryDirectory = join45(resolvedOutdir, ".absolutejs-server-entry");
|
|
15858
16074
|
mkdirSync18(serverBundleEntryDirectory, { recursive: true });
|
|
15859
|
-
const typeboxSetupEntry =
|
|
15860
|
-
const serverBundleEntry =
|
|
16075
|
+
const typeboxSetupEntry = join45(serverBundleEntryDirectory, "_typebox_setup.ts");
|
|
16076
|
+
const serverBundleEntry = join45(serverBundleEntryDirectory, basename12(serverEntry));
|
|
15861
16077
|
writeFileSync21(typeboxSetupEntry, `import { setupTypebox } from 'elysia';
|
|
15862
16078
|
import * as compile from 'typebox/compile';
|
|
15863
16079
|
import * as schema from 'typebox/schema';
|
|
@@ -15868,7 +16084,7 @@ import * as value from 'typebox/value';
|
|
|
15868
16084
|
setupTypebox({ typebox: { compile, schema, system, type, value } });
|
|
15869
16085
|
`);
|
|
15870
16086
|
writeFileSync21(serverBundleEntry, `import './_typebox_setup';
|
|
15871
|
-
import * as serverModule from ${JSON.stringify(
|
|
16087
|
+
import * as serverModule from ${JSON.stringify(resolve36(serverEntry))};
|
|
15872
16088
|
|
|
15873
16089
|
export const server = serverModule.server ?? serverModule.app ?? serverModule.default;
|
|
15874
16090
|
export default server;
|
|
@@ -15882,7 +16098,7 @@ export default server;
|
|
|
15882
16098
|
...islandRegistryPlugin ? [islandRegistryPlugin] : [],
|
|
15883
16099
|
...buildConfig.mobile ? [
|
|
15884
16100
|
createAbsoluteMobileRouteMetadataPlugin({
|
|
15885
|
-
entry:
|
|
16101
|
+
entry: resolve36(serverEntry)
|
|
15886
16102
|
})
|
|
15887
16103
|
] : [],
|
|
15888
16104
|
createElysiaOpenApiTypeboxPlugin(),
|
|
@@ -15906,13 +16122,13 @@ export default server;
|
|
|
15906
16122
|
console.error(cliTag4("\x1B[31m", "Server bundle failed."));
|
|
15907
16123
|
process.exit(1);
|
|
15908
16124
|
}
|
|
15909
|
-
const outputPath =
|
|
16125
|
+
const outputPath = resolve36(resolvedOutdir, `${entryName}.js`);
|
|
15910
16126
|
if (!existsSync41(outputPath)) {
|
|
15911
16127
|
console.error(cliTag4("\x1B[31m", `Expected output not found: ${outputPath}`));
|
|
15912
16128
|
process.exit(1);
|
|
15913
16129
|
}
|
|
15914
|
-
if (existsSync41(
|
|
15915
|
-
const vendorDir =
|
|
16130
|
+
if (existsSync41(resolve36(resolvedOutdir, "angular", "vendor", "server"))) {
|
|
16131
|
+
const vendorDir = resolve36(resolvedOutdir, "angular", "vendor", "server");
|
|
15916
16132
|
const vendorEntries = readdirSync7(vendorDir).filter((fileName) => fileName.endsWith(".js"));
|
|
15917
16133
|
const angularServerVendorPaths = {};
|
|
15918
16134
|
for (const file of vendorEntries) {
|
|
@@ -15921,7 +16137,7 @@ export default server;
|
|
|
15921
16137
|
if (scope !== "angular" || rest.length === 0)
|
|
15922
16138
|
continue;
|
|
15923
16139
|
const specifier = `@angular/${rest.join("/")}`;
|
|
15924
|
-
const relPath =
|
|
16140
|
+
const relPath = relative23(dirname27(outputPath), resolve36(vendorDir, file));
|
|
15925
16141
|
angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
15926
16142
|
}
|
|
15927
16143
|
if (Object.keys(angularServerVendorPaths).length > 0) {
|
|
@@ -15933,7 +16149,7 @@ export default server;
|
|
|
15933
16149
|
copyServerRuntimeAssetReferences(resolvedOutdir);
|
|
15934
16150
|
const prerenderStart = performance.now();
|
|
15935
16151
|
process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
|
|
15936
|
-
rmSync7(
|
|
16152
|
+
rmSync7(join45(resolvedOutdir, "_prerendered"), {
|
|
15937
16153
|
force: true,
|
|
15938
16154
|
recursive: true
|
|
15939
16155
|
});
|
|
@@ -15963,7 +16179,7 @@ export default server;
|
|
|
15963
16179
|
const compileStart = performance.now();
|
|
15964
16180
|
process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
|
|
15965
16181
|
const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
|
|
15966
|
-
const entrypointPath =
|
|
16182
|
+
const entrypointPath = join45(resolvedOutdir, "_compile_entrypoint.ts");
|
|
15967
16183
|
await Bun.write(entrypointPath, entrypointCode);
|
|
15968
16184
|
mkdirSync18(dirname27(resolvedOutfile), { recursive: true });
|
|
15969
16185
|
const result = await Bun.build({
|
|
@@ -16049,7 +16265,7 @@ var init_compile = __esm(() => {
|
|
|
16049
16265
|
|
|
16050
16266
|
// src/mobile/nativeDeepLinks.ts
|
|
16051
16267
|
import { readFile as readFile11, rename as rename8, writeFile as writeFile9 } from "fs/promises";
|
|
16052
|
-
import { join as
|
|
16268
|
+
import { join as join46 } from "path";
|
|
16053
16269
|
var START_MARKER = "<!-- absolutejs:deep-links:start -->", END_MARKER = "<!-- absolutejs:deep-links:end -->", IOS_ENTITLEMENTS = "App/AbsoluteJS.entitlements", NOT_FOUND = -1, escapeXml = (value) => value.replaceAll("&", "&").replaceAll('"', """).replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">"), writeChangedFile = async (path, source) => {
|
|
16054
16270
|
const current = await readFile11(path, "utf8");
|
|
16055
16271
|
if (current === source)
|
|
@@ -16098,7 +16314,7 @@ ${hosts}
|
|
|
16098
16314
|
${END_MARKER}
|
|
16099
16315
|
`;
|
|
16100
16316
|
}, configureAndroid = async (config) => {
|
|
16101
|
-
const path =
|
|
16317
|
+
const path = join46(config.nativeProjectDirectory, "android/app/src/main/AndroidManifest.xml");
|
|
16102
16318
|
const source = await readFile11(path, "utf8");
|
|
16103
16319
|
const mainActivity = source.indexOf('android:name=".MainActivity"');
|
|
16104
16320
|
if (mainActivity === NOT_FOUND) {
|
|
@@ -16122,7 +16338,7 @@ ${hosts}
|
|
|
16122
16338
|
</array>
|
|
16123
16339
|
${END_MARKER}
|
|
16124
16340
|
`, configureIosInfo = async (config) => {
|
|
16125
|
-
const path =
|
|
16341
|
+
const path = join46(config.nativeProjectDirectory, "ios/App/App/Info.plist");
|
|
16126
16342
|
const source = await readFile11(path, "utf8");
|
|
16127
16343
|
const region = config.deepLinkScheme ? iosSchemeRegion(config.deepLinkScheme) : ` ${START_MARKER}
|
|
16128
16344
|
${END_MARKER}
|
|
@@ -16144,7 +16360,7 @@ ${domains}
|
|
|
16144
16360
|
</plist>
|
|
16145
16361
|
`;
|
|
16146
16362
|
}, configureIosEntitlements = async (config) => {
|
|
16147
|
-
const path =
|
|
16363
|
+
const path = join46(config.nativeProjectDirectory, "ios/App/AbsoluteJS.entitlements");
|
|
16148
16364
|
let current = "";
|
|
16149
16365
|
try {
|
|
16150
16366
|
current = await readFile11(path, "utf8");
|
|
@@ -16161,7 +16377,7 @@ ${domains}
|
|
|
16161
16377
|
await rename8(temporary, path);
|
|
16162
16378
|
return true;
|
|
16163
16379
|
}, configureIosProject = async (config) => {
|
|
16164
|
-
const path =
|
|
16380
|
+
const path = join46(config.nativeProjectDirectory, "ios/App/App.xcodeproj/project.pbxproj");
|
|
16165
16381
|
const source = await readFile11(path, "utf8");
|
|
16166
16382
|
const declarations = [
|
|
16167
16383
|
...source.matchAll(/CODE_SIGN_ENTITLEMENTS = ([^;]+);/g)
|
|
@@ -16201,7 +16417,7 @@ var init_nativeDeepLinks = () => {};
|
|
|
16201
16417
|
|
|
16202
16418
|
// src/mobile/nativeBackgroundSync.ts
|
|
16203
16419
|
import { readFile as readFile12, rename as rename9, writeFile as writeFile10 } from "fs/promises";
|
|
16204
|
-
import { join as
|
|
16420
|
+
import { join as join47 } from "path";
|
|
16205
16421
|
var writeChanged = async (path, source) => {
|
|
16206
16422
|
const current = await readFile12(path, "utf8");
|
|
16207
16423
|
if (current === source)
|
|
@@ -16284,10 +16500,10 @@ ${makeRegion(values)} </array>
|
|
|
16284
16500
|
if (!platforms.includes("ios") || !projectUsesAbsoluteAuth(projectRoot) || !projectUsesAbsoluteSync(projectRoot))
|
|
16285
16501
|
return { changed: false };
|
|
16286
16502
|
const identifier = `${config.appId}.absolutejs.background-sync`;
|
|
16287
|
-
const infoPath =
|
|
16503
|
+
const infoPath = join47(config.nativeProjectDirectory, "ios/App/App/Info.plist");
|
|
16288
16504
|
const info2 = await readFile12(infoPath, "utf8");
|
|
16289
16505
|
const nextInfo = ensurePlistArrayValues(ensurePlistArrayValues(info2, "BGTaskSchedulerPermittedIdentifiers", [identifier], "background-sync-identifiers"), "UIBackgroundModes", ["fetch", "processing"], "background-sync-modes");
|
|
16290
|
-
const delegatePath =
|
|
16506
|
+
const delegatePath = join47(config.nativeProjectDirectory, "ios/App/App/AppDelegate.swift");
|
|
16291
16507
|
let delegate = await readFile12(delegatePath, "utf8");
|
|
16292
16508
|
if (!delegate.includes("import AbsoluteSyncCapacitor")) {
|
|
16293
16509
|
const importIndex = delegate.lastIndexOf("import Capacitor");
|
|
@@ -16327,7 +16543,7 @@ import {
|
|
|
16327
16543
|
rm as rm7,
|
|
16328
16544
|
writeFile as writeFile11
|
|
16329
16545
|
} from "fs/promises";
|
|
16330
|
-
import { resolve as
|
|
16546
|
+
import { resolve as resolve37 } from "path";
|
|
16331
16547
|
import { Elysia } from "elysia";
|
|
16332
16548
|
var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERIFY_TIMEOUT_MS = 1e4, ANDROID_ASSOCIATION_PATH = "/.well-known/assetlinks.json", APPLE_ASSOCIATION_PATH = "/.well-known/apple-app-site-association", missingIdentity = (field, platform6) => new TypeError(`${field} is required to publish ${platform6} deep-link association files.`), createAppleDocument = (config, requireAll) => {
|
|
16333
16549
|
if (!config.platforms.includes("ios"))
|
|
@@ -16400,7 +16616,7 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16400
16616
|
return false;
|
|
16401
16617
|
}
|
|
16402
16618
|
}, assertOwnedOutput = async (root) => {
|
|
16403
|
-
const path =
|
|
16619
|
+
const path = resolve37(root, OWNERSHIP_FILE);
|
|
16404
16620
|
let ownership;
|
|
16405
16621
|
try {
|
|
16406
16622
|
ownership = JSON.parse(await readFile13(path, "utf8"));
|
|
@@ -16427,10 +16643,10 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16427
16643
|
if (hasCurrent)
|
|
16428
16644
|
await rm7(backup, { force: true, recursive: true });
|
|
16429
16645
|
}, materializeHost = async (root, host2, files) => {
|
|
16430
|
-
const directory =
|
|
16646
|
+
const directory = resolve37(root, host2, ".well-known");
|
|
16431
16647
|
await mkdir10(directory, { recursive: true });
|
|
16432
16648
|
return Promise.all(files.map(async ([name, document]) => {
|
|
16433
|
-
const path =
|
|
16649
|
+
const path = resolve37(directory, name);
|
|
16434
16650
|
await writeAtomic(path, `${JSON.stringify(document, null, 2)}
|
|
16435
16651
|
`);
|
|
16436
16652
|
return path;
|
|
@@ -16453,7 +16669,7 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16453
16669
|
});
|
|
16454
16670
|
return endpoints;
|
|
16455
16671
|
}), materializeAbsoluteMobileAssociationFiles = async (config, outputDirectory) => {
|
|
16456
|
-
const root =
|
|
16672
|
+
const root = resolve37(outputDirectory);
|
|
16457
16673
|
const temporary = `${root}.${crypto.randomUUID()}.tmp`;
|
|
16458
16674
|
const documents = createAbsoluteMobileAssociationDocuments(config, {
|
|
16459
16675
|
requireAll: true
|
|
@@ -16467,10 +16683,10 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16467
16683
|
await mkdir10(temporary, { recursive: true });
|
|
16468
16684
|
try {
|
|
16469
16685
|
const temporaryPaths = (await Promise.all(config.deepLinkHosts.map((host2) => materializeHost(temporary, host2, files)))).flat();
|
|
16470
|
-
await writeAtomic(
|
|
16686
|
+
await writeAtomic(resolve37(temporary, OWNERSHIP_FILE), `${JSON.stringify({ format: 1, hosts: config.deepLinkHosts }, null, 2)}
|
|
16471
16687
|
`);
|
|
16472
16688
|
await publishGeneratedDirectory(temporary, root);
|
|
16473
|
-
const written = temporaryPaths.map((path) =>
|
|
16689
|
+
const written = temporaryPaths.map((path) => resolve37(root, path.slice(temporary.length + 1)));
|
|
16474
16690
|
return { root, written };
|
|
16475
16691
|
} catch (error) {
|
|
16476
16692
|
await rm7(temporary, { force: true, recursive: true });
|
|
@@ -16512,7 +16728,7 @@ var init_associationFiles = __esm(() => {
|
|
|
16512
16728
|
|
|
16513
16729
|
// src/mobile/androidWebView.ts
|
|
16514
16730
|
import { mkdir as mkdir11, writeFile as writeFile12 } from "fs/promises";
|
|
16515
|
-
import { dirname as dirname28, resolve as
|
|
16731
|
+
import { dirname as dirname28, resolve as resolve38 } from "path";
|
|
16516
16732
|
|
|
16517
16733
|
class CdpConnection {
|
|
16518
16734
|
diagnostics = [];
|
|
@@ -16783,7 +16999,7 @@ var CDP_COMMAND_TIMEOUT_MS = 1e4, WEBVIEW_ATTACH_TIMEOUT_MS = 30000, WEBVIEW_POL
|
|
|
16783
16999
|
if (typeof data !== "string") {
|
|
16784
17000
|
throw new Error("Android WebView screenshot returned no image data.");
|
|
16785
17001
|
}
|
|
16786
|
-
const absolutePath =
|
|
17002
|
+
const absolutePath = resolve38(path);
|
|
16787
17003
|
await mkdir11(dirname28(absolutePath), { recursive: true });
|
|
16788
17004
|
await writeFile12(absolutePath, Buffer.from(data, "base64"));
|
|
16789
17005
|
return absolutePath;
|
|
@@ -16904,7 +17120,7 @@ var DEFAULT_ROUTE_TIMEOUT_MS = 30000, DEFAULT_HMR_TIMEOUT_MS = 30000, routeExpre
|
|
|
16904
17120
|
|
|
16905
17121
|
// src/mobile/releaseDoctor.ts
|
|
16906
17122
|
import { access as access8, readFile as readFile14, readdir as readdir4 } from "fs/promises";
|
|
16907
|
-
import { extname as
|
|
17123
|
+
import { extname as extname8, join as join48, relative as relative24 } from "path";
|
|
16908
17124
|
var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
16909
17125
|
try {
|
|
16910
17126
|
await access8(path);
|
|
@@ -16915,7 +17131,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16915
17131
|
}, inspectReleaseAsset = async (path, isDirectory, isFile2) => {
|
|
16916
17132
|
if (isDirectory)
|
|
16917
17133
|
return findHmrAsset(path);
|
|
16918
|
-
if (!isFile2 || !RELEASE_ASSET_EXTENSIONS.has(
|
|
17134
|
+
if (!isFile2 || !RELEASE_ASSET_EXTENSIONS.has(extname8(path)))
|
|
16919
17135
|
return;
|
|
16920
17136
|
const source = await readFile14(path, "utf8");
|
|
16921
17137
|
return HMR_ASSET_PATTERN.test(source) ? path : undefined;
|
|
@@ -16923,7 +17139,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16923
17139
|
if (!await pathExists5(root))
|
|
16924
17140
|
return;
|
|
16925
17141
|
const entries = await readdir4(root, { withFileTypes: true });
|
|
16926
|
-
const matches = await Promise.all(entries.map((entry) => inspectReleaseAsset(
|
|
17142
|
+
const matches = await Promise.all(entries.map((entry) => inspectReleaseAsset(join48(root, entry.name), entry.isDirectory(), entry.isFile())));
|
|
16927
17143
|
return matches.find((match) => match !== undefined);
|
|
16928
17144
|
}, pass = (id, detail, path) => ({ detail, id, path, status: "pass" }), fail5 = (id, detail, path, remediation) => ({
|
|
16929
17145
|
detail,
|
|
@@ -16970,7 +17186,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16970
17186
|
}, syncSchemaReleaseCheck = (projectRoot) => {
|
|
16971
17187
|
if (!projectUsesAbsoluteSync(projectRoot))
|
|
16972
17188
|
return;
|
|
16973
|
-
const manifestPath =
|
|
17189
|
+
const manifestPath = join48(projectRoot, "package.json");
|
|
16974
17190
|
try {
|
|
16975
17191
|
const schema = discoverAbsoluteSyncSchema(projectRoot);
|
|
16976
17192
|
const versions = schema.components.map((component2) => `${component2.id}@${component2.version}`).join(", ");
|
|
@@ -16978,18 +17194,32 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16978
17194
|
const mutationRules = schema.components.flatMap((component2) => component2.localData?.mutations ?? []);
|
|
16979
17195
|
const protectedCount = [...collectionRules, ...mutationRules].filter((rule) => rule.protection === "required").length;
|
|
16980
17196
|
const memoryOnlyCount = [...collectionRules, ...mutationRules].filter((rule) => rule.persistence === "memory-only" || rule.onProtectionUnavailable === "memory-only").length;
|
|
17197
|
+
const conflictCounts = {
|
|
17198
|
+
clientWins: mutationRules.filter((rule) => rule.conflict?.strategy === "client-wins").length,
|
|
17199
|
+
manual: mutationRules.filter((rule) => rule.conflict?.strategy === "manual").length,
|
|
17200
|
+
serverWins: mutationRules.filter((rule) => rule.conflict?.strategy === "server-wins").length
|
|
17201
|
+
};
|
|
16981
17202
|
const quotas = schema.components.map((component2) => component2.localData?.maxBytesPerNamespace).filter((value) => value !== undefined);
|
|
16982
|
-
const policy = `${collectionRules.length} collection rule(s), ${mutationRules.length} mutation rule(s), ${protectedCount} encryption-required, ${memoryOnlyCount} memory-only fallback(s)${quotas.length > 0 ? `, ${Math.min(...quotas)}-byte effective quota` : ", no logical quota"}`;
|
|
17203
|
+
const policy = `${collectionRules.length} collection rule(s), ${mutationRules.length} mutation rule(s), ${protectedCount} encryption-required, ${memoryOnlyCount} memory-only fallback(s), conflicts ${conflictCounts.clientWins} client-wins/${conflictCounts.serverWins} server-wins/${conflictCounts.manual} manual${quotas.length > 0 ? `, ${Math.min(...quotas)}-byte effective quota` : ", no logical quota"}`;
|
|
16983
17204
|
return pass("sync.storage-schema", `Generated offline schema is compatible: ${versions}; ${policy}.`, manifestPath);
|
|
16984
17205
|
} catch (error) {
|
|
16985
17206
|
return fail5("sync.storage-schema", error instanceof Error ? error.message : "Generated offline schema metadata is invalid.", manifestPath, "Fix absolutejs.sync.localSchema metadata in the named app or package before releasing.");
|
|
16986
17207
|
}
|
|
17208
|
+
}, deviceCapabilityReleaseCheck = (projectRoot) => {
|
|
17209
|
+
const manifestPath = join48(projectRoot, "package.json");
|
|
17210
|
+
try {
|
|
17211
|
+
const plan = resolveAbsoluteDeviceCapabilityPlan(projectRoot);
|
|
17212
|
+
assertAbsoluteDeviceCapabilityPackages(projectRoot, plan);
|
|
17213
|
+
return pass("mobile.device-capabilities", plan.capabilities.length > 0 ? `Native provider packages match detected capabilities: ${plan.capabilities.join(", ")}.` : "No optional native device capabilities are used.", manifestPath);
|
|
17214
|
+
} catch (error) {
|
|
17215
|
+
return fail5("mobile.device-capabilities", error instanceof Error ? error.message : "Native device capability provisioning is invalid.", manifestPath, "Run `absolute mobile sync` and approve the exact capability plugins before releasing.");
|
|
17216
|
+
}
|
|
16987
17217
|
}, inspectAndroidRelease = async (config, projectRoot) => {
|
|
16988
|
-
const androidRoot =
|
|
16989
|
-
const nativeConfigPath =
|
|
16990
|
-
const manifestPath =
|
|
16991
|
-
const publicRoot =
|
|
16992
|
-
const journalPath =
|
|
17218
|
+
const androidRoot = join48(config.nativeProjectDirectory, "android");
|
|
17219
|
+
const nativeConfigPath = join48(androidRoot, "app", "src", "main", "assets", "capacitor.config.json");
|
|
17220
|
+
const manifestPath = join48(androidRoot, "app", "src", "main", "AndroidManifest.xml");
|
|
17221
|
+
const publicRoot = join48(androidRoot, "app", "src", "main", "assets", "public");
|
|
17222
|
+
const journalPath = join48(projectRoot, ".absolutejs", "mobile", "dev-session", "journal.json");
|
|
16993
17223
|
const checks = await Promise.all([
|
|
16994
17224
|
journalReleaseCheck(journalPath, "android"),
|
|
16995
17225
|
capacitorConfigReleaseCheck(nativeConfigPath),
|
|
@@ -16998,14 +17228,14 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16998
17228
|
]);
|
|
16999
17229
|
return checks.map((check2) => ({
|
|
17000
17230
|
...check2,
|
|
17001
|
-
path: check2.path ?
|
|
17231
|
+
path: check2.path ? relative24(projectRoot, check2.path).replaceAll("\\", "/") || "." : undefined
|
|
17002
17232
|
}));
|
|
17003
17233
|
}, inspectIosRelease = async (config, projectRoot) => {
|
|
17004
|
-
const iosAppRoot =
|
|
17005
|
-
const nativeConfigPath =
|
|
17006
|
-
const infoPath =
|
|
17007
|
-
const publicRoot =
|
|
17008
|
-
const journalPath =
|
|
17234
|
+
const iosAppRoot = join48(config.nativeProjectDirectory, "ios", "App", "App");
|
|
17235
|
+
const nativeConfigPath = join48(iosAppRoot, "capacitor.config.json");
|
|
17236
|
+
const infoPath = join48(iosAppRoot, "Info.plist");
|
|
17237
|
+
const publicRoot = join48(iosAppRoot, "public");
|
|
17238
|
+
const journalPath = join48(projectRoot, ".absolutejs", "mobile", "ios-dev-session", "journal.json");
|
|
17009
17239
|
const checks = [
|
|
17010
17240
|
await journalReleaseCheck(journalPath, "ios")
|
|
17011
17241
|
];
|
|
@@ -17031,7 +17261,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17031
17261
|
checks.push(hmrAsset ? fail5("ios.hmr-assets", "A packaged iOS asset contains the development HMR client.", hmrAsset, "Rebuild the production mobile bundle and run Capacitor sync again.") : pass("ios.hmr-assets", "Packaged iOS assets contain no development HMR markers.", publicRoot));
|
|
17032
17262
|
return checks.map((check2) => ({
|
|
17033
17263
|
...check2,
|
|
17034
|
-
path: check2.path ?
|
|
17264
|
+
path: check2.path ? relative24(projectRoot, check2.path).replaceAll("\\", "/") || "." : undefined
|
|
17035
17265
|
}));
|
|
17036
17266
|
}, inspectAbsoluteMobileRelease = async (config, projectRoot) => {
|
|
17037
17267
|
const checks = config.platforms.includes("android") ? await inspectAndroidRelease(config, projectRoot) : [];
|
|
@@ -17042,9 +17272,14 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17042
17272
|
if (syncSchema) {
|
|
17043
17273
|
checks.push({
|
|
17044
17274
|
...syncSchema,
|
|
17045
|
-
path: syncSchema.path ?
|
|
17275
|
+
path: syncSchema.path ? relative24(projectRoot, syncSchema.path).replaceAll("\\", "/") || "." : undefined
|
|
17046
17276
|
});
|
|
17047
17277
|
}
|
|
17278
|
+
const deviceCapabilities = deviceCapabilityReleaseCheck(projectRoot);
|
|
17279
|
+
checks.push({
|
|
17280
|
+
...deviceCapabilities,
|
|
17281
|
+
path: deviceCapabilities.path ? relative24(projectRoot, deviceCapabilities.path).replaceAll("\\", "/") || "." : undefined
|
|
17282
|
+
});
|
|
17048
17283
|
return {
|
|
17049
17284
|
checks,
|
|
17050
17285
|
ready: checks.length > 0 && checks.every((check2) => check2.status === "pass")
|
|
@@ -17053,6 +17288,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17053
17288
|
var init_releaseDoctor = __esm(() => {
|
|
17054
17289
|
init_nativeAuth();
|
|
17055
17290
|
init_syncSchema();
|
|
17291
|
+
init_deviceCapabilities();
|
|
17056
17292
|
HMR_ASSET_PATTERN = /(?:__HMR_WS__|hmr-timing|__absolute_target|absolutejs-error-overlay)/u;
|
|
17057
17293
|
RELEASE_ASSET_EXTENSIONS = new Set([".html", ".js", ".mjs"]);
|
|
17058
17294
|
});
|
|
@@ -17070,7 +17306,7 @@ import {
|
|
|
17070
17306
|
stat as stat2,
|
|
17071
17307
|
writeFile as writeFile13
|
|
17072
17308
|
} from "fs/promises";
|
|
17073
|
-
import { dirname as dirname29, isAbsolute as isAbsolute7, join as
|
|
17309
|
+
import { dirname as dirname29, isAbsolute as isAbsolute7, join as join49, relative as relative25, resolve as resolve39, sep as sep6 } from "path";
|
|
17074
17310
|
var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), requireManifest2 = (value) => {
|
|
17075
17311
|
if (!isRecord13(value) || typeof value.appBuild !== "string" || typeof value.appId !== "string" || typeof value.runtime !== "string") {
|
|
17076
17312
|
throw new TypeError("Invalid embedded AbsoluteJS mobile manifest.");
|
|
@@ -17121,19 +17357,19 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
17121
17357
|
]);
|
|
17122
17358
|
return result.exitCode === 0 && /jar verified/iu.test(result.stdout);
|
|
17123
17359
|
}, sha256File2 = async (path) => createHash12("sha256").update(await readFile15(path)).digest("hex"), safeOutputDirectory2 = (projectRoot, requested) => {
|
|
17124
|
-
const root =
|
|
17125
|
-
const output =
|
|
17126
|
-
const projectRelative =
|
|
17360
|
+
const root = resolve39(projectRoot);
|
|
17361
|
+
const output = resolve39(root, requested ?? ".absolutejs/mobile/releases/android");
|
|
17362
|
+
const projectRelative = relative25(root, output);
|
|
17127
17363
|
if (projectRelative === ".." || projectRelative.startsWith(`..${sep6}`) || isAbsolute7(projectRelative)) {
|
|
17128
17364
|
throw new TypeError("mobile build --outdir must remain inside the project.");
|
|
17129
17365
|
}
|
|
17130
17366
|
return output;
|
|
17131
17367
|
}, installRelease2 = async (artifactPath, metadata, outputRoot) => {
|
|
17132
|
-
const releaseRoot =
|
|
17368
|
+
const releaseRoot = join49(outputRoot, metadata.releaseId);
|
|
17133
17369
|
const artifactName = "app-release.aab";
|
|
17134
|
-
const destination =
|
|
17370
|
+
const destination = join49(releaseRoot, artifactName);
|
|
17135
17371
|
if (await pathExists6(releaseRoot)) {
|
|
17136
|
-
const existing = requireManifestIdentity(JSON.parse(await readFile15(
|
|
17372
|
+
const existing = requireManifestIdentity(JSON.parse(await readFile15(join49(releaseRoot, "release.json"), "utf8")), metadata);
|
|
17137
17373
|
const [installedBytes, installedSha256] = await Promise.all([
|
|
17138
17374
|
stat2(destination).then(({ size }) => size),
|
|
17139
17375
|
sha256File2(destination)
|
|
@@ -17144,14 +17380,14 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
17144
17380
|
return { artifactPath: destination, metadata: existing, releaseRoot };
|
|
17145
17381
|
}
|
|
17146
17382
|
await mkdir12(dirname29(releaseRoot), { recursive: true });
|
|
17147
|
-
const staging = await mkdtemp5(
|
|
17383
|
+
const staging = await mkdtemp5(join49(dirname29(releaseRoot), ".android-stage-"));
|
|
17148
17384
|
try {
|
|
17149
|
-
await copyFile5(artifactPath,
|
|
17385
|
+
await copyFile5(artifactPath, join49(staging, artifactName));
|
|
17150
17386
|
const complete = {
|
|
17151
17387
|
...metadata,
|
|
17152
17388
|
artifact: artifactName
|
|
17153
17389
|
};
|
|
17154
|
-
await writeFile13(
|
|
17390
|
+
await writeFile13(join49(staging, "release.json"), `${JSON.stringify(complete, null, "\t")}
|
|
17155
17391
|
`, { flag: "wx" });
|
|
17156
17392
|
await rename11(staging, releaseRoot);
|
|
17157
17393
|
return { artifactPath: destination, metadata: complete, releaseRoot };
|
|
@@ -17176,11 +17412,11 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
17176
17412
|
if (options.versionCode !== undefined && (!Number.isSafeInteger(options.versionCode) || options.versionCode < 1 || options.versionCode > 2100000000)) {
|
|
17177
17413
|
throw new TypeError("Android versionCode must be an integer from 1 through 2100000000.");
|
|
17178
17414
|
}
|
|
17179
|
-
const projectRoot =
|
|
17415
|
+
const projectRoot = resolve39(options.projectRoot);
|
|
17180
17416
|
const host2 = options.host ?? detectAbsoluteMobileHost();
|
|
17181
17417
|
const androidRoot = options.androidRoot ?? process.env.ANDROID_HOME ?? process.env.ANDROID_SDK_ROOT ?? absoluteManagedAndroidSdkRoot(host2);
|
|
17182
|
-
const nativeDirectory =
|
|
17183
|
-
const manifest = requireManifest2(JSON.parse(await readFile15(
|
|
17418
|
+
const nativeDirectory = join49(options.config.nativeProjectDirectory, "android");
|
|
17419
|
+
const manifest = requireManifest2(JSON.parse(await readFile15(join49(options.config.bundleDirectory, "absolute-mobile-manifest.json"), "utf8")));
|
|
17184
17420
|
if (manifest.appId !== options.config.appId) {
|
|
17185
17421
|
throw new TypeError("Embedded mobile manifest appId does not match mobile.appId.");
|
|
17186
17422
|
}
|
|
@@ -17304,7 +17540,7 @@ var init_iosConformance = __esm(() => {
|
|
|
17304
17540
|
|
|
17305
17541
|
// src/mobile/releasePublisher.ts
|
|
17306
17542
|
import { access as access10 } from "fs/promises";
|
|
17307
|
-
import { isAbsolute as isAbsolute8, relative as
|
|
17543
|
+
import { isAbsolute as isAbsolute8, relative as relative26, resolve as resolve40, sep as sep7 } from "path";
|
|
17308
17544
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
17309
17545
|
var prepareAbsoluteIosRelease = async (publisher, options) => {
|
|
17310
17546
|
if (typeof publisher.prepareIosRelease !== "function") {
|
|
@@ -17326,9 +17562,9 @@ var prepareAbsoluteIosRelease = async (publisher, options) => {
|
|
|
17326
17562
|
}
|
|
17327
17563
|
return versionCode;
|
|
17328
17564
|
}, isRecord14 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), isPublisher = (value) => isRecord14(value) && typeof value.publish === "function", publisherModulePath = (projectRoot, requested) => {
|
|
17329
|
-
const root =
|
|
17330
|
-
const path =
|
|
17331
|
-
const projectRelative =
|
|
17565
|
+
const root = resolve40(projectRoot);
|
|
17566
|
+
const path = resolve40(root, requested);
|
|
17567
|
+
const projectRelative = relative26(root, path);
|
|
17332
17568
|
if (projectRelative === ".." || projectRelative.startsWith(`..${sep7}`) || isAbsolute8(projectRelative)) {
|
|
17333
17569
|
throw new TypeError("mobile publish --registry must remain inside the project.");
|
|
17334
17570
|
}
|
|
@@ -17401,10 +17637,10 @@ __export(exports_mobile, {
|
|
|
17401
17637
|
runMobile: () => runMobile
|
|
17402
17638
|
});
|
|
17403
17639
|
import { access as access11, mkdir as mkdir13, readFile as readFile17, writeFile as writeFile14 } from "fs/promises";
|
|
17404
|
-
import { join as
|
|
17640
|
+
import { join as join50, resolve as resolve41 } from "path";
|
|
17405
17641
|
import { createInterface } from "readline/promises";
|
|
17406
17642
|
var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), CAPACITOR_PACKAGES, CAPACITOR_PACKAGE_SPECS, CAPACITOR_SYNC_PACKAGE_SPECS, packageNameFromSpec = (spec) => spec.slice(0, spec.lastIndexOf("@")), directProjectPackages = async (projectRoot) => {
|
|
17407
|
-
const manifest = JSON.parse(await readFile17(
|
|
17643
|
+
const manifest = JSON.parse(await readFile17(join50(projectRoot, "package.json"), "utf8"));
|
|
17408
17644
|
if (!isRecord15(manifest))
|
|
17409
17645
|
throw new TypeError("Application package.json must contain an object.");
|
|
17410
17646
|
const names = new Set;
|
|
@@ -17415,20 +17651,37 @@ var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value
|
|
|
17415
17651
|
names.add(name);
|
|
17416
17652
|
}
|
|
17417
17653
|
return names;
|
|
17418
|
-
},
|
|
17654
|
+
}, resolvedPackageVersion = async (projectRoot, packageName) => {
|
|
17655
|
+
try {
|
|
17656
|
+
const manifest = JSON.parse(await readFile17(join50(projectRoot, "node_modules", packageName, "package.json"), "utf8"));
|
|
17657
|
+
return isRecord15(manifest) && typeof manifest.version === "string" ? manifest.version : undefined;
|
|
17658
|
+
} catch {
|
|
17659
|
+
return;
|
|
17660
|
+
}
|
|
17661
|
+
}, exactVersionFromSpec = (spec) => spec.slice(spec.lastIndexOf("@") + 1), installApprovedPackages = async (projectRoot, args, message, specs) => {
|
|
17662
|
+
if (specs.length === 0)
|
|
17663
|
+
return;
|
|
17664
|
+
const approved = args.includes("--yes") || await confirmInstall(message);
|
|
17665
|
+
if (!approved)
|
|
17666
|
+
throw new TypeError(`Mobile initialization requires: bun add ${specs.join(" ")}`);
|
|
17667
|
+
if (!installPackages(projectRoot, specs))
|
|
17668
|
+
throw new TypeError("Failed to install the AbsoluteJS mobile toolchain.");
|
|
17669
|
+
}, packagesNeedingExactInstall = async (projectRoot, specs, installed, exactPackages) => (await Promise.all(specs.map(async (spec) => {
|
|
17670
|
+
const name = packageNameFromSpec(spec);
|
|
17671
|
+
const needsInstall = !installed.has(name) || exactPackages.has(name) && await resolvedPackageVersion(projectRoot, name) !== exactVersionFromSpec(spec);
|
|
17672
|
+
return needsInstall ? spec : undefined;
|
|
17673
|
+
}))).filter((spec) => spec !== undefined), ensureCapacitorPackages = async (projectRoot, args) => {
|
|
17419
17674
|
const specs = [
|
|
17420
17675
|
...CAPACITOR_PACKAGE_SPECS,
|
|
17421
17676
|
...projectUsesAbsoluteSync(projectRoot) ? CAPACITOR_SYNC_PACKAGE_SPECS : []
|
|
17422
17677
|
];
|
|
17423
17678
|
const installed = await directProjectPackages(projectRoot);
|
|
17424
|
-
const missing =
|
|
17425
|
-
|
|
17426
|
-
|
|
17427
|
-
const
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
if (!installPackages(projectRoot, missing))
|
|
17431
|
-
throw new TypeError("Failed to install the AbsoluteJS mobile toolchain.");
|
|
17679
|
+
const missing = await packagesNeedingExactInstall(projectRoot, specs, installed, new Set(["@absolutejs/devices", "@absolutejs/devices-capacitor"]));
|
|
17680
|
+
await installApprovedPackages(projectRoot, args, "Capacitor and the AbsoluteJS native adapters are missing or outdated. Install the tested mobile toolchain now?", missing);
|
|
17681
|
+
const capabilityPlan = resolveAbsoluteDeviceCapabilityPlan(projectRoot);
|
|
17682
|
+
const directCapabilityPackages = await directProjectPackages(projectRoot);
|
|
17683
|
+
const capabilityPackages = await packagesNeedingExactInstall(projectRoot, capabilityPlan.requiredPackages, directCapabilityPackages, new Set(capabilityPlan.requiredPackages.map(packageNameFromSpec)));
|
|
17684
|
+
await installApprovedPackages(projectRoot, args, `AbsoluteJS detected native device capabilities (${capabilityPlan.capabilities.join(", ")}). Install only their required Capacitor plugins now?`, capabilityPackages);
|
|
17432
17685
|
}, valueAfter = (args, flag) => {
|
|
17433
17686
|
const index = args.indexOf(flag);
|
|
17434
17687
|
return index === NOT_FOUND2 ? undefined : args[index + 1];
|
|
@@ -17441,7 +17694,7 @@ var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value
|
|
|
17441
17694
|
}
|
|
17442
17695
|
return value;
|
|
17443
17696
|
}, capacitorExecutable = async (projectRoot) => {
|
|
17444
|
-
const executable =
|
|
17697
|
+
const executable = join50(projectRoot, "node_modules", ".bin", "cap");
|
|
17445
17698
|
try {
|
|
17446
17699
|
await access11(executable);
|
|
17447
17700
|
return executable;
|
|
@@ -17527,7 +17780,7 @@ var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value
|
|
|
17527
17780
|
await applyAbsoluteNativeBackgroundSync(projectRoot, mobile, platforms);
|
|
17528
17781
|
}, associations = async (args) => {
|
|
17529
17782
|
const { mobile, projectRoot } = await loadMobile(valueAfter(args, "--config"));
|
|
17530
|
-
const outputDirectory =
|
|
17783
|
+
const outputDirectory = resolve41(projectRoot, valueAfter(args, "--outdir") ?? ".absolutejs/mobile/associations");
|
|
17531
17784
|
if (args.includes("--verify")) {
|
|
17532
17785
|
const result2 = await verifyAbsoluteMobileAssociationFiles(mobile);
|
|
17533
17786
|
console.log(`Verified ${result2.results.length} hosted association files`);
|
|
@@ -17757,7 +18010,7 @@ Mobile release transport checks failed.`);
|
|
|
17757
18010
|
const durationMs = Math.round(performance.now() - startedAt);
|
|
17758
18011
|
console.log(`Built ${release.metadata.signed ? "signed" : "unsigned"} Android App Bundle in ${getDurationString(durationMs)}.`);
|
|
17759
18012
|
console.log(`Artifact: ${release.artifactPath}`);
|
|
17760
|
-
console.log(`Metadata: ${
|
|
18013
|
+
console.log(`Metadata: ${join50(release.releaseRoot, "release.json")}`);
|
|
17761
18014
|
return release;
|
|
17762
18015
|
} finally {
|
|
17763
18016
|
sendTelemetryEvent("mobile:android-release-build", {
|
|
@@ -17857,7 +18110,7 @@ Mobile release transport checks failed.`);
|
|
|
17857
18110
|
const durationMs = Math.round(performance.now() - startedAt);
|
|
17858
18111
|
console.log(`Built ${release.metadata.signed ? "signed" : "unsigned"} iOS IPA ${release.metadata.marketingVersion}${release.metadata.buildNumber ? ` (${release.metadata.buildNumber})` : ""} in ${getDurationString(durationMs)}.`);
|
|
17859
18112
|
console.log(`Artifact: ${release.artifactPath}`);
|
|
17860
|
-
console.log(`Metadata: ${
|
|
18113
|
+
console.log(`Metadata: ${join50(release.releaseRoot, "release.json")}`);
|
|
17861
18114
|
return release;
|
|
17862
18115
|
} finally {
|
|
17863
18116
|
sendTelemetryEvent("mobile:ios-release-build", {
|
|
@@ -17964,7 +18217,7 @@ Mobile release transport checks failed.`);
|
|
|
17964
18217
|
checks.push({
|
|
17965
18218
|
id: "sync.storage-schema",
|
|
17966
18219
|
label: `Offline schema ${schema.components.map((component2) => `${component2.id}@${component2.version}`).join(", ")}`,
|
|
17967
|
-
path:
|
|
18220
|
+
path: join50(projectRoot, "package.json"),
|
|
17968
18221
|
platform: "host",
|
|
17969
18222
|
status: "pass"
|
|
17970
18223
|
});
|
|
@@ -17972,7 +18225,7 @@ Mobile release transport checks failed.`);
|
|
|
17972
18225
|
checks.push({
|
|
17973
18226
|
id: "sync.storage-schema",
|
|
17974
18227
|
label: "Offline schema metadata is invalid",
|
|
17975
|
-
path:
|
|
18228
|
+
path: join50(projectRoot, "package.json"),
|
|
17976
18229
|
platform: "host",
|
|
17977
18230
|
remediation: error instanceof Error ? error.message : String(error),
|
|
17978
18231
|
status: "fail"
|
|
@@ -18057,7 +18310,7 @@ Emulator setup verification:`);
|
|
|
18057
18310
|
}
|
|
18058
18311
|
return { https: args.includes("--https"), port };
|
|
18059
18312
|
}
|
|
18060
|
-
const instances = listLiveInstances().filter((instance2) =>
|
|
18313
|
+
const instances = listLiveInstances().filter((instance2) => resolve41(instance2.cwd) === resolve41(projectRoot) && instance2.source === "dev" && instance2.port !== null);
|
|
18061
18314
|
if (instances.length !== 1) {
|
|
18062
18315
|
throw new TypeError(instances.length === 0 ? "No running AbsoluteJS dev server was found for this project. Start `bun dev`, wait for Android to report ready, then run `absolute mobile test android`." : "Multiple dev servers are running for this project. Select one with mobile test android --port <port>.");
|
|
18063
18316
|
}
|
|
@@ -18100,8 +18353,8 @@ Emulator setup verification:`);
|
|
|
18100
18353
|
}
|
|
18101
18354
|
return selected;
|
|
18102
18355
|
}, safeArtifactRoot = (projectRoot, value) => {
|
|
18103
|
-
const root =
|
|
18104
|
-
if (root !== projectRoot && !root.startsWith(`${
|
|
18356
|
+
const root = resolve41(projectRoot, value ?? ".absolutejs/mobile/test-artifacts");
|
|
18357
|
+
if (root !== projectRoot && !root.startsWith(`${resolve41(projectRoot)}/`)) {
|
|
18105
18358
|
throw new TypeError("mobile test --artifacts must remain inside the project.");
|
|
18106
18359
|
}
|
|
18107
18360
|
return root;
|
|
@@ -18126,10 +18379,10 @@ Emulator setup verification:`);
|
|
|
18126
18379
|
});
|
|
18127
18380
|
}, writeAndroidFailureArtifacts = async (options) => {
|
|
18128
18381
|
await mkdir13(options.artifactRoot, { recursive: true });
|
|
18129
|
-
const screenshot = options.session ? await options.session.screenshot(
|
|
18382
|
+
const screenshot = options.session ? await options.session.screenshot(join50(options.artifactRoot, "android-failure.png")).catch(() => {
|
|
18130
18383
|
return;
|
|
18131
18384
|
}) : undefined;
|
|
18132
|
-
const diagnosticPath =
|
|
18385
|
+
const diagnosticPath = join50(options.artifactRoot, "android-failure.json");
|
|
18133
18386
|
await writeFile14(diagnosticPath, `${JSON.stringify({
|
|
18134
18387
|
diagnostics: options.session?.diagnostics ?? [],
|
|
18135
18388
|
error: options.error instanceof Error ? options.error.message : String(options.error),
|
|
@@ -18220,14 +18473,14 @@ Emulator setup verification:`);
|
|
|
18220
18473
|
const port = Number(explicit);
|
|
18221
18474
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
18222
18475
|
throw new TypeError("mobile test --port must be a valid TCP port.");
|
|
18223
|
-
const instance2 = listLiveInstances().find((candidate) =>
|
|
18476
|
+
const instance2 = listLiveInstances().find((candidate) => resolve41(candidate.cwd) === resolve41(projectRoot) && candidate.source === "dev" && candidate.port === port);
|
|
18224
18477
|
return {
|
|
18225
18478
|
https: instance2?.https ?? args.includes("--https"),
|
|
18226
18479
|
instance: instance2,
|
|
18227
18480
|
port
|
|
18228
18481
|
};
|
|
18229
18482
|
}
|
|
18230
|
-
const instances = listLiveInstances().filter((instance2) =>
|
|
18483
|
+
const instances = listLiveInstances().filter((instance2) => resolve41(instance2.cwd) === resolve41(projectRoot) && instance2.source === "dev" && instance2.port !== null);
|
|
18231
18484
|
if (instances.length !== 1)
|
|
18232
18485
|
throw new TypeError(instances.length === 0 ? "No running AbsoluteJS dev server was found for this project. Start `bun dev`, wait for iOS to report ready, then run `absolute mobile test ios`." : "Multiple dev servers are running for this project. Select one with mobile test ios --port <port>.");
|
|
18233
18486
|
const [instance] = instances;
|
|
@@ -18307,7 +18560,7 @@ Emulator setup verification:`);
|
|
|
18307
18560
|
return result;
|
|
18308
18561
|
}, writeIosFailureArtifacts = async (options) => {
|
|
18309
18562
|
await mkdir13(options.artifactRoot, { recursive: true });
|
|
18310
|
-
const screenshot =
|
|
18563
|
+
const screenshot = join50(options.artifactRoot, "ios-failure.png");
|
|
18311
18564
|
const screenshotResult = captureCommand4([
|
|
18312
18565
|
options.xcrun,
|
|
18313
18566
|
"simctl",
|
|
@@ -18316,7 +18569,7 @@ Emulator setup verification:`);
|
|
|
18316
18569
|
"screenshot",
|
|
18317
18570
|
screenshot
|
|
18318
18571
|
]);
|
|
18319
|
-
const diagnosticPath =
|
|
18572
|
+
const diagnosticPath = join50(options.artifactRoot, "ios-failure.json");
|
|
18320
18573
|
await writeFile14(diagnosticPath, `${JSON.stringify({
|
|
18321
18574
|
appId: options.appId,
|
|
18322
18575
|
error: options.error instanceof Error ? options.error.message : String(options.error),
|
|
@@ -18362,7 +18615,7 @@ Emulator setup verification:`);
|
|
|
18362
18615
|
], "iOS app launch");
|
|
18363
18616
|
await waitForIosHmrClient({ https, port, timeoutMs });
|
|
18364
18617
|
await mkdir13(artifactRoot, { recursive: true });
|
|
18365
|
-
const screenshot =
|
|
18618
|
+
const screenshot = join50(artifactRoot, "ios-simulator.png");
|
|
18366
18619
|
requireCapturedIosCommand([xcrun, "simctl", "io", simulator.udid, "screenshot", screenshot], "iOS simulator screenshot");
|
|
18367
18620
|
const hmrApply = await waitForRequestedIosHmr(args, instance, timeoutMs);
|
|
18368
18621
|
const report = {
|
|
@@ -18487,6 +18740,7 @@ var init_mobile = __esm(() => {
|
|
|
18487
18740
|
init_remoteMacProtocol();
|
|
18488
18741
|
init_nativeAuth();
|
|
18489
18742
|
init_syncSchema();
|
|
18743
|
+
init_deviceCapabilities();
|
|
18490
18744
|
CAPACITOR_PACKAGES = [
|
|
18491
18745
|
"@capacitor/core",
|
|
18492
18746
|
"@capacitor/app",
|
|
@@ -18508,11 +18762,11 @@ var init_mobile = __esm(() => {
|
|
|
18508
18762
|
"@capacitor/cli@8.5.0",
|
|
18509
18763
|
"@capacitor/android@8.5.0",
|
|
18510
18764
|
"@capacitor/ios@8.5.0",
|
|
18511
|
-
"@absolutejs/devices@0.0
|
|
18512
|
-
"@absolutejs/devices-capacitor@0.
|
|
18765
|
+
"@absolutejs/devices@0.1.0",
|
|
18766
|
+
"@absolutejs/devices-capacitor@0.2.0"
|
|
18513
18767
|
];
|
|
18514
18768
|
CAPACITOR_SYNC_PACKAGE_SPECS = [
|
|
18515
|
-
"@absolutejs/sync-capacitor@0.
|
|
18769
|
+
"@absolutejs/sync-capacitor@0.8.0",
|
|
18516
18770
|
"@capacitor-community/sqlite@8.1.1"
|
|
18517
18771
|
];
|
|
18518
18772
|
});
|
|
@@ -18522,10 +18776,10 @@ var exports_typecheck = {};
|
|
|
18522
18776
|
__export(exports_typecheck, {
|
|
18523
18777
|
typecheck: () => typecheck
|
|
18524
18778
|
});
|
|
18525
|
-
import { resolve as
|
|
18526
|
-
import { existsSync as existsSync42, readFileSync as
|
|
18779
|
+
import { resolve as resolve42, join as join51 } from "path";
|
|
18780
|
+
import { existsSync as existsSync42, readFileSync as readFileSync40 } from "fs";
|
|
18527
18781
|
import { mkdir as mkdir14, writeFile as writeFile15 } from "fs/promises";
|
|
18528
|
-
var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), resolveConfigPath = (configPath2) =>
|
|
18782
|
+
var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), resolveConfigPath = (configPath2) => resolve42(configPath2 ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts"), getTypecheckTargets = async (configPath2) => {
|
|
18529
18783
|
if (!existsSync42(resolveConfigPath(configPath2))) {
|
|
18530
18784
|
const defaultService = {};
|
|
18531
18785
|
return [defaultService];
|
|
@@ -18547,7 +18801,7 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
|
|
|
18547
18801
|
const exitCode = await proc.exited;
|
|
18548
18802
|
return { exitCode, name, output: (stdout + stderr).trim() };
|
|
18549
18803
|
}, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
|
|
18550
|
-
const local =
|
|
18804
|
+
const local = resolve42("node_modules", ".bin", name);
|
|
18551
18805
|
return existsSync42(local) ? local : null;
|
|
18552
18806
|
}, ANSI_COLOR_REGEX, ANSI_PURPLE_REGEX, ANSI_CYAN_REGEX, ANSI_TOKEN_END_REGEX, stripAnsi4 = (str) => str.replace(ANSI_COLOR_REGEX, ""), formatSvelteOutput = (output) => {
|
|
18553
18807
|
const cwd = `${process.cwd()}/`;
|
|
@@ -18595,15 +18849,15 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18595
18849
|
return formatted;
|
|
18596
18850
|
}, ABSOLUTE_INTERNAL_EXCLUDES, resolveAbsoluteTypeFile = (fileName) => {
|
|
18597
18851
|
const candidates = [
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18852
|
+
resolve42("node_modules/@absolutejs/absolute/dist/types", fileName),
|
|
18853
|
+
resolve42(import.meta.dir, "../types", fileName),
|
|
18854
|
+
resolve42(import.meta.dir, "../../types", fileName),
|
|
18855
|
+
resolve42(import.meta.dir, "../../../types", fileName)
|
|
18602
18856
|
];
|
|
18603
18857
|
return candidates.find((candidate) => existsSync42(candidate)) ?? candidates[0];
|
|
18604
18858
|
}, ABSOLUTE_TYPECHECK_FILES, readProjectTsconfig = () => {
|
|
18605
18859
|
try {
|
|
18606
|
-
return JSON.parse(
|
|
18860
|
+
return JSON.parse(readFileSync40(resolve42("tsconfig.json"), "utf-8"));
|
|
18607
18861
|
} catch {
|
|
18608
18862
|
return {};
|
|
18609
18863
|
}
|
|
@@ -18631,27 +18885,27 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18631
18885
|
console.error("\x1B[31m\u2717\x1B[0m vue-tsc is required for Vue type checking. Install it: bun add -d vue-tsc");
|
|
18632
18886
|
process.exit(1);
|
|
18633
18887
|
}
|
|
18634
|
-
const vueTsconfigPath =
|
|
18888
|
+
const vueTsconfigPath = join51(cacheDir, "tsconfig.vue-check.json");
|
|
18635
18889
|
await writeFile15(vueTsconfigPath, JSON.stringify({
|
|
18636
18890
|
compilerOptions: {
|
|
18637
18891
|
rootDir: ".."
|
|
18638
18892
|
},
|
|
18639
18893
|
exclude: getProjectTypecheckExcludes(),
|
|
18640
|
-
extends:
|
|
18894
|
+
extends: resolve42("tsconfig.json"),
|
|
18641
18895
|
include: getProjectTypecheckIncludes()
|
|
18642
18896
|
}, null, "\t"));
|
|
18643
18897
|
const base = [
|
|
18644
18898
|
vueTscBin,
|
|
18645
18899
|
"--noEmit",
|
|
18646
18900
|
"--project",
|
|
18647
|
-
|
|
18901
|
+
resolve42(vueTsconfigPath),
|
|
18648
18902
|
"--pretty"
|
|
18649
18903
|
];
|
|
18650
18904
|
const cached = await run("vue-tsc", [
|
|
18651
18905
|
...base,
|
|
18652
18906
|
"--incremental",
|
|
18653
18907
|
"--tsBuildInfoFile",
|
|
18654
|
-
|
|
18908
|
+
join51(cacheDir, "vue-tsc.tsbuildinfo")
|
|
18655
18909
|
]);
|
|
18656
18910
|
if (cached.exitCode === 0 || cached.output.length > 0)
|
|
18657
18911
|
return cached;
|
|
@@ -18662,7 +18916,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18662
18916
|
console.error("\x1B[31m\u2717\x1B[0m @angular/compiler-cli is required for Angular type checking. Install it: bun add -d @angular/compiler-cli");
|
|
18663
18917
|
process.exit(1);
|
|
18664
18918
|
}
|
|
18665
|
-
const angularTsconfigPath =
|
|
18919
|
+
const angularTsconfigPath = join51(cacheDir, "tsconfig.angular-check.json");
|
|
18666
18920
|
await writeFile15(angularTsconfigPath, JSON.stringify({
|
|
18667
18921
|
angularCompilerOptions: {
|
|
18668
18922
|
strictTemplates: true
|
|
@@ -18672,32 +18926,32 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18672
18926
|
rootDir: ".."
|
|
18673
18927
|
},
|
|
18674
18928
|
exclude: ABSOLUTE_INTERNAL_EXCLUDES.map(toGeneratedConfigPath),
|
|
18675
|
-
extends:
|
|
18929
|
+
extends: resolve42("tsconfig.json"),
|
|
18676
18930
|
include: [`../${angularDir}/**/*`]
|
|
18677
18931
|
}, null, "\t"));
|
|
18678
|
-
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(
|
|
18932
|
+
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve42(angularTsconfigPath))}`);
|
|
18679
18933
|
}, buildTscCheck = (cacheDir) => {
|
|
18680
18934
|
const tscBin = findBin("tsc");
|
|
18681
18935
|
if (!tscBin) {
|
|
18682
18936
|
console.error("\x1B[31m\u2717\x1B[0m typescript is required for type checking. Install it: bun add -d typescript");
|
|
18683
18937
|
process.exit(1);
|
|
18684
18938
|
}
|
|
18685
|
-
const tscConfigPath =
|
|
18939
|
+
const tscConfigPath = join51(cacheDir, "tsconfig.typecheck.json");
|
|
18686
18940
|
return writeFile15(tscConfigPath, JSON.stringify({
|
|
18687
18941
|
compilerOptions: {
|
|
18688
18942
|
rootDir: ".."
|
|
18689
18943
|
},
|
|
18690
18944
|
exclude: getProjectTypecheckExcludes(),
|
|
18691
|
-
extends:
|
|
18945
|
+
extends: resolve42("tsconfig.json"),
|
|
18692
18946
|
include: getProjectTypecheckIncludes()
|
|
18693
18947
|
}, null, "\t")).then(() => run("tsc", [
|
|
18694
18948
|
tscBin,
|
|
18695
18949
|
"--noEmit",
|
|
18696
18950
|
"--project",
|
|
18697
|
-
|
|
18951
|
+
resolve42(tscConfigPath),
|
|
18698
18952
|
"--incremental",
|
|
18699
18953
|
"--tsBuildInfoFile",
|
|
18700
|
-
|
|
18954
|
+
join51(cacheDir, "tsc.tsbuildinfo"),
|
|
18701
18955
|
"--pretty"
|
|
18702
18956
|
]));
|
|
18703
18957
|
}, buildSvelteCheck = async (cacheDir, svelteDir) => {
|
|
@@ -18706,16 +18960,16 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18706
18960
|
console.error("\x1B[31m\u2717\x1B[0m svelte-check is required for Svelte type checking. Install it: bun add -d svelte-check");
|
|
18707
18961
|
process.exit(1);
|
|
18708
18962
|
}
|
|
18709
|
-
const svelteTsconfigPath =
|
|
18963
|
+
const svelteTsconfigPath = join51(cacheDir, "tsconfig.svelte-check.json");
|
|
18710
18964
|
await writeFile15(svelteTsconfigPath, JSON.stringify({
|
|
18711
|
-
extends:
|
|
18965
|
+
extends: resolve42("tsconfig.json"),
|
|
18712
18966
|
files: ABSOLUTE_TYPECHECK_FILES,
|
|
18713
18967
|
include: [`../${svelteDir}/**/*`]
|
|
18714
18968
|
}, null, "\t"));
|
|
18715
18969
|
return run("svelte-check", [
|
|
18716
18970
|
svelteBin,
|
|
18717
18971
|
"--tsconfig",
|
|
18718
|
-
|
|
18972
|
+
resolve42(svelteTsconfigPath),
|
|
18719
18973
|
"--threshold",
|
|
18720
18974
|
"error",
|
|
18721
18975
|
"--compiler-warnings",
|
|
@@ -18909,11 +19163,11 @@ var DEFAULT_RELAY_PORT = 8787, DEFAULT_REQUEST_TIMEOUT_MS = 30000, headersToObje
|
|
|
18909
19163
|
url: url.pathname + url.search,
|
|
18910
19164
|
...bodyBytes && bodyBytes.length > 0 ? { bodyBase64: Buffer.from(bodyBytes).toString("base64") } : {}
|
|
18911
19165
|
};
|
|
18912
|
-
const responsePromise = new Promise((
|
|
18913
|
-
pending.set(id,
|
|
19166
|
+
const responsePromise = new Promise((resolve43) => {
|
|
19167
|
+
pending.set(id, resolve43);
|
|
18914
19168
|
});
|
|
18915
19169
|
client.send(encodeTunnelMessage(message));
|
|
18916
|
-
const timeout = new Promise((
|
|
19170
|
+
const timeout = new Promise((resolve43) => setTimeout(() => resolve43({ id, message: "timeout", type: "error" }), requestTimeoutMs));
|
|
18917
19171
|
const result = await Promise.race([responsePromise, timeout]);
|
|
18918
19172
|
pending.delete(id);
|
|
18919
19173
|
if (result.type === "error") {
|
|
@@ -21165,12 +21419,12 @@ import {
|
|
|
21165
21419
|
existsSync as existsSync12,
|
|
21166
21420
|
mkdirSync as mkdirSync7,
|
|
21167
21421
|
readdirSync as readdirSync2,
|
|
21168
|
-
readFileSync as
|
|
21422
|
+
readFileSync as readFileSync16,
|
|
21169
21423
|
unlinkSync as unlinkSync3,
|
|
21170
21424
|
writeFileSync as writeFileSync6
|
|
21171
21425
|
} from "fs";
|
|
21172
21426
|
import { createConnection } from "net";
|
|
21173
|
-
import { resolve as
|
|
21427
|
+
import { resolve as resolve22 } from "path";
|
|
21174
21428
|
|
|
21175
21429
|
// src/cli/workspaceTui.ts
|
|
21176
21430
|
init_constants();
|
|
@@ -21732,18 +21986,18 @@ var createWorkspaceTui = ({
|
|
|
21732
21986
|
|
|
21733
21987
|
// src/cli/scripts/workspace.ts
|
|
21734
21988
|
init_utils();
|
|
21735
|
-
var sourceServerBootstrap2 =
|
|
21736
|
-
var serverBootstrap2 = existsSync12(sourceServerBootstrap2) ? sourceServerBootstrap2 :
|
|
21989
|
+
var sourceServerBootstrap2 = resolve22(import.meta.dir, "../../dev/serverBootstrap.ts");
|
|
21990
|
+
var serverBootstrap2 = existsSync12(sourceServerBootstrap2) ? sourceServerBootstrap2 : resolve22(import.meta.dir, "../dev/serverBootstrap.js");
|
|
21737
21991
|
var ANSI_REGEX2 = new RegExp(`${String.fromCharCode(ANSI_ESCAPE_CODE)}\\[[0-?]*[ -/]*[@-~]`, "g");
|
|
21738
21992
|
var sleep = (durationMs) => Bun.sleep(durationMs);
|
|
21739
21993
|
var stripAnsi3 = (value) => value.replace(ANSI_REGEX2, "");
|
|
21740
21994
|
var sanitizeLogFileName = (value) => value.replace(/[^a-zA-Z0-9._-]/g, "_") || "unknown";
|
|
21741
21995
|
var createWorkspaceLogSink = (appendLog) => {
|
|
21742
|
-
const logDirectory =
|
|
21996
|
+
const logDirectory = resolve22(".absolutejs", "workspace", "logs");
|
|
21743
21997
|
mkdirSync7(logDirectory, { recursive: true });
|
|
21744
|
-
readdirSync2(logDirectory).filter((file) => file.endsWith(".log")).forEach((file) => unlinkSync3(
|
|
21745
|
-
writeFileSync6(
|
|
21746
|
-
writeFileSync6(
|
|
21998
|
+
readdirSync2(logDirectory).filter((file) => file.endsWith(".log")).forEach((file) => unlinkSync3(resolve22(logDirectory, file)));
|
|
21999
|
+
writeFileSync6(resolve22(logDirectory, "all.log"), "");
|
|
22000
|
+
writeFileSync6(resolve22(logDirectory, "workspace.log"), "");
|
|
21747
22001
|
const initializedSources = new Set(["workspace"]);
|
|
21748
22002
|
const writeLog = (source, message, level) => {
|
|
21749
22003
|
const cleanMessage = stripAnsi3(message).trimEnd();
|
|
@@ -21753,13 +22007,13 @@ var createWorkspaceLogSink = (appendLog) => {
|
|
|
21753
22007
|
const timestamp = new Date().toISOString();
|
|
21754
22008
|
const line = `[${timestamp}] [${level}] [${source}] ${cleanMessage}
|
|
21755
22009
|
`;
|
|
21756
|
-
const sourceFile =
|
|
22010
|
+
const sourceFile = resolve22(logDirectory, `${sanitizeLogFileName(source)}.log`);
|
|
21757
22011
|
if (!initializedSources.has(source)) {
|
|
21758
22012
|
writeFileSync6(sourceFile, "");
|
|
21759
22013
|
initializedSources.add(source);
|
|
21760
22014
|
}
|
|
21761
22015
|
appendFileSync(sourceFile, line);
|
|
21762
|
-
appendFileSync(
|
|
22016
|
+
appendFileSync(resolve22(logDirectory, "all.log"), line);
|
|
21763
22017
|
};
|
|
21764
22018
|
return {
|
|
21765
22019
|
appendLog: (source, message, level = "info") => {
|
|
@@ -21771,7 +22025,7 @@ var createWorkspaceLogSink = (appendLog) => {
|
|
|
21771
22025
|
};
|
|
21772
22026
|
var readPackageVersion3 = (candidate) => {
|
|
21773
22027
|
try {
|
|
21774
|
-
const pkg = JSON.parse(
|
|
22028
|
+
const pkg = JSON.parse(readFileSync16(candidate, "utf-8"));
|
|
21775
22029
|
if (pkg.name !== "@absolutejs/absolute") {
|
|
21776
22030
|
return null;
|
|
21777
22031
|
}
|
|
@@ -21783,9 +22037,9 @@ var readPackageVersion3 = (candidate) => {
|
|
|
21783
22037
|
};
|
|
21784
22038
|
var resolvePackageVersion2 = () => {
|
|
21785
22039
|
const candidates = [
|
|
21786
|
-
|
|
21787
|
-
|
|
21788
|
-
|
|
22040
|
+
resolve22(import.meta.dir, "..", "..", "package.json"),
|
|
22041
|
+
resolve22(import.meta.dir, "..", "..", "..", "package.json"),
|
|
22042
|
+
resolve22(import.meta.dir, "..", "..", "..", "..", "package.json")
|
|
21789
22043
|
];
|
|
21790
22044
|
for (const candidate of candidates) {
|
|
21791
22045
|
const version2 = readPackageVersion3(candidate);
|
|
@@ -22139,15 +22393,15 @@ var createWorkspaceServiceEnv = (services) => {
|
|
|
22139
22393
|
var getDefinedProcessEnv = () => Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string"));
|
|
22140
22394
|
var resolveAbsoluteServiceConfigPath = (service, cwd, options) => {
|
|
22141
22395
|
if (service.config)
|
|
22142
|
-
return
|
|
22396
|
+
return resolve22(cwd, service.config);
|
|
22143
22397
|
if (options.configPath)
|
|
22144
|
-
return
|
|
22398
|
+
return resolve22(options.configPath);
|
|
22145
22399
|
if (process.env.ABSOLUTE_CONFIG)
|
|
22146
|
-
return
|
|
22400
|
+
return resolve22(process.env.ABSOLUTE_CONFIG);
|
|
22147
22401
|
return;
|
|
22148
22402
|
};
|
|
22149
22403
|
var resolveService = (name, service, workspaceEnv, options) => {
|
|
22150
|
-
const cwd =
|
|
22404
|
+
const cwd = resolve22(service.cwd ?? ".");
|
|
22151
22405
|
const envVars = Object.assign(getDefinedProcessEnv(), workspaceEnv, service.port ? { PORT: String(service.port) } : {}, service.env, {
|
|
22152
22406
|
ABSOLUTE_INSTANCE_MANAGED: "1",
|
|
22153
22407
|
ABSOLUTE_WORKSPACE_MANAGED: "1",
|
|
@@ -22159,7 +22413,7 @@ var resolveService = (name, service, workspaceEnv, options) => {
|
|
|
22159
22413
|
if (isAbsoluteService(service)) {
|
|
22160
22414
|
const configPath2 = resolveAbsoluteServiceConfigPath(service, cwd, options);
|
|
22161
22415
|
Object.assign(envVars, configPath2 ? { ABSOLUTE_CONFIG: configPath2 } : {}, {
|
|
22162
|
-
ABSOLUTE_SERVER_ENTRY:
|
|
22416
|
+
ABSOLUTE_SERVER_ENTRY: resolve22(cwd, service.entry ?? DEFAULT_SERVER_ENTRY)
|
|
22163
22417
|
});
|
|
22164
22418
|
const command = [
|
|
22165
22419
|
process.execPath,
|
|
@@ -22189,8 +22443,8 @@ var resolveService = (name, service, workspaceEnv, options) => {
|
|
|
22189
22443
|
var resolveServiceBuildDirectory = (service) => {
|
|
22190
22444
|
if (!isAbsoluteService(service))
|
|
22191
22445
|
return null;
|
|
22192
|
-
const cwd =
|
|
22193
|
-
return
|
|
22446
|
+
const cwd = resolve22(service.cwd ?? ".");
|
|
22447
|
+
return resolve22(cwd, service.buildDirectory ?? "build");
|
|
22194
22448
|
};
|
|
22195
22449
|
var findSharedWorkspaceBuildDirectories = (services) => {
|
|
22196
22450
|
const byBuildDirectory = new Map;
|
|
@@ -22408,7 +22662,7 @@ var workspace = async (subcommand, options) => {
|
|
|
22408
22662
|
frameworks: [],
|
|
22409
22663
|
host: getServicePublicHost(resolved.service),
|
|
22410
22664
|
https: getServiceProtocol(resolved.service) === "https",
|
|
22411
|
-
logFile:
|
|
22665
|
+
logFile: resolve22(workspaceLogs.logDirectory, `${sanitizeLogFileName(name)}.log`),
|
|
22412
22666
|
name,
|
|
22413
22667
|
pid: processHandle.pid,
|
|
22414
22668
|
port: resolved.service.port ?? null,
|