@absolutejs/absolute 0.20.0-beta.17 → 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/cli/index.js +935 -718
- package/dist/mobile/index.js +325 -121
- package/dist/mobile/index.js.map +8 -7
- package/dist/mobile/shellAuth.js +0 -8
- 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 +1 -0
- package/dist/src/mobile/transport.d.ts +1 -0
- package/package.json +12 -9
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;
|
|
@@ -6725,9 +6759,154 @@ var init_syncSchema = __esm(() => {
|
|
|
6725
6759
|
init_client2();
|
|
6726
6760
|
});
|
|
6727
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
|
+
|
|
6728
6907
|
// src/mobile/buildPipeline.ts
|
|
6729
6908
|
import { readFile as readFile10 } from "fs/promises";
|
|
6730
|
-
import { join as
|
|
6909
|
+
import { join as join21, resolve as resolve17 } from "path";
|
|
6731
6910
|
import { pathToFileURL } from "url";
|
|
6732
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) => {
|
|
6733
6912
|
if (loaded.server === app)
|
|
@@ -6756,11 +6935,11 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6756
6935
|
const exportName = serverExportName(loaded, app);
|
|
6757
6936
|
return { app, exportName };
|
|
6758
6937
|
}, finalizeAbsoluteMobileCompatibilityBuild = async (options) => {
|
|
6759
|
-
const buildDirectory =
|
|
6938
|
+
const buildDirectory = resolve17(options.buildDirectory);
|
|
6760
6939
|
const mobile = normalizeAbsoluteMobileConfig(options.mobile, options.projectRoot);
|
|
6761
|
-
const root =
|
|
6940
|
+
const root = join21(buildDirectory, ".absolutejs", "mobile-compatibility");
|
|
6762
6941
|
const [manifestSource, previous] = await Promise.all([
|
|
6763
|
-
readFile10(
|
|
6942
|
+
readFile10(join21(buildDirectory, "manifest.json"), "utf8"),
|
|
6764
6943
|
readAbsoluteMobileMaterializedReleases(root)
|
|
6765
6944
|
]);
|
|
6766
6945
|
const manifest = JSON.parse(manifestSource);
|
|
@@ -6773,11 +6952,11 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6773
6952
|
process.env.ABSOLUTE_BUILD_DIR = buildDirectory;
|
|
6774
6953
|
process.env.ABSOLUTE_COMPILED_RUNTIME = "1";
|
|
6775
6954
|
if (options.configPath) {
|
|
6776
|
-
process.env.ABSOLUTE_CONFIG =
|
|
6955
|
+
process.env.ABSOLUTE_CONFIG = resolve17(options.projectRoot, options.configPath);
|
|
6777
6956
|
}
|
|
6778
6957
|
let loaded;
|
|
6779
6958
|
try {
|
|
6780
|
-
loaded = await loadServerApp(
|
|
6959
|
+
loaded = await loadServerApp(resolve17(options.producerPath));
|
|
6781
6960
|
} finally {
|
|
6782
6961
|
restoreEnvironmentVariable("ABSOLUTE_BUILD_DIR", previousBuildDirectory);
|
|
6783
6962
|
restoreEnvironmentVariable("ABSOLUTE_COMPILED_RUNTIME", previousCompiledRuntime);
|
|
@@ -6790,12 +6969,14 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6790
6969
|
manifest,
|
|
6791
6970
|
previousArtifacts: previous.map(({ artifact }) => artifact),
|
|
6792
6971
|
producerExport: loaded.exportName,
|
|
6793
|
-
producerPath:
|
|
6972
|
+
producerPath: resolve17(options.producerPath),
|
|
6794
6973
|
runtime: String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)
|
|
6795
6974
|
});
|
|
6796
6975
|
const auth = resolveAbsoluteMobileAuthManifest(options.projectRoot, mobile);
|
|
6797
6976
|
const sync = auth !== undefined && projectUsesAbsoluteSync(options.projectRoot);
|
|
6798
6977
|
const syncSchema = sync ? discoverAbsoluteSyncSchema(options.projectRoot) : undefined;
|
|
6978
|
+
const deviceCapabilities = resolveAbsoluteDeviceCapabilityPlan(options.projectRoot);
|
|
6979
|
+
assertAbsoluteDeviceCapabilityPackages(options.projectRoot, deviceCapabilities);
|
|
6799
6980
|
if (auth && !loaded.app.routes.some((route) => route.path === "/.well-known/openid-configuration")) {
|
|
6800
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.");
|
|
6801
6982
|
}
|
|
@@ -6814,6 +6995,8 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6814
6995
|
...auth ? { auth } : {},
|
|
6815
6996
|
buildDirectory,
|
|
6816
6997
|
config: mobile,
|
|
6998
|
+
deviceCapabilities,
|
|
6999
|
+
projectRoot: options.projectRoot,
|
|
6817
7000
|
...sync ? { sync: true } : {},
|
|
6818
7001
|
...syncSchema ? { syncSchema: { components: syncSchema.components } } : {}
|
|
6819
7002
|
});
|
|
@@ -6828,62 +7011,63 @@ var init_buildPipeline = __esm(() => {
|
|
|
6828
7011
|
init_releaseArtifact();
|
|
6829
7012
|
init_nativeAuth();
|
|
6830
7013
|
init_syncSchema();
|
|
7014
|
+
init_deviceCapabilities();
|
|
6831
7015
|
});
|
|
6832
7016
|
|
|
6833
7017
|
// src/mobile/routeMetadataTransform.ts
|
|
6834
|
-
import { existsSync as existsSync10, readFileSync as
|
|
6835
|
-
import { dirname as dirname13, extname as
|
|
6836
|
-
import
|
|
6837
|
-
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) => {
|
|
6838
7022
|
const configPath2 = findTsconfig(entry, projectRoot);
|
|
6839
7023
|
if (!configPath2) {
|
|
6840
|
-
return
|
|
7024
|
+
return ts5.createProgram([entry], {
|
|
6841
7025
|
allowJs: true,
|
|
6842
|
-
jsx:
|
|
6843
|
-
module:
|
|
6844
|
-
moduleResolution:
|
|
6845
|
-
target:
|
|
7026
|
+
jsx: ts5.JsxEmit.ReactJSX,
|
|
7027
|
+
module: ts5.ModuleKind.ESNext,
|
|
7028
|
+
moduleResolution: ts5.ModuleResolutionKind.Bundler,
|
|
7029
|
+
target: ts5.ScriptTarget.ESNext
|
|
6846
7030
|
});
|
|
6847
7031
|
}
|
|
6848
|
-
const parsed =
|
|
7032
|
+
const parsed = ts5.parseJsonConfigFileContent(ts5.readConfigFile(configPath2, (path) => readFileSync13(path, "utf8")).config, ts5.sys, dirname13(configPath2));
|
|
6849
7033
|
if (!parsed.fileNames.includes(entry))
|
|
6850
7034
|
parsed.fileNames.push(entry);
|
|
6851
|
-
return
|
|
7035
|
+
return ts5.createProgram(parsed.fileNames, parsed.options);
|
|
6852
7036
|
}, propertyName = (property) => {
|
|
6853
7037
|
if (!("name" in property) || !property.name)
|
|
6854
7038
|
return;
|
|
6855
|
-
if (
|
|
7039
|
+
if (ts5.isIdentifier(property.name))
|
|
6856
7040
|
return property.name.text;
|
|
6857
|
-
if (
|
|
7041
|
+
if (ts5.isStringLiteralLike(property.name))
|
|
6858
7042
|
return property.name.text;
|
|
6859
7043
|
return;
|
|
6860
|
-
}, objectPropertyExpression = (
|
|
6861
|
-
const property =
|
|
6862
|
-
if (property &&
|
|
7044
|
+
}, objectPropertyExpression = (object3, name) => {
|
|
7045
|
+
const property = object3.properties.find((candidate) => propertyName(candidate) === name);
|
|
7046
|
+
if (property && ts5.isPropertyAssignment(property)) {
|
|
6863
7047
|
return property.initializer;
|
|
6864
7048
|
}
|
|
6865
|
-
if (property &&
|
|
7049
|
+
if (property && ts5.isShorthandPropertyAssignment(property)) {
|
|
6866
7050
|
return property.name;
|
|
6867
7051
|
}
|
|
6868
7052
|
return;
|
|
6869
7053
|
}, serializeType = (type, checker, ancestors = new Set) => {
|
|
6870
|
-
if (type.flags &
|
|
7054
|
+
if (type.flags & ts5.TypeFlags.Any)
|
|
6871
7055
|
return { type: "any" };
|
|
6872
|
-
if (type.flags &
|
|
7056
|
+
if (type.flags & ts5.TypeFlags.Unknown)
|
|
6873
7057
|
return { type: "unknown" };
|
|
6874
|
-
if (type.flags &
|
|
7058
|
+
if (type.flags & ts5.TypeFlags.Never)
|
|
6875
7059
|
return { type: "never" };
|
|
6876
|
-
if (type.flags &
|
|
7060
|
+
if (type.flags & ts5.TypeFlags.StringLike)
|
|
6877
7061
|
return { type: "string" };
|
|
6878
|
-
if (type.flags &
|
|
7062
|
+
if (type.flags & ts5.TypeFlags.NumberLike)
|
|
6879
7063
|
return { type: "number" };
|
|
6880
|
-
if (type.flags &
|
|
7064
|
+
if (type.flags & ts5.TypeFlags.BooleanLike)
|
|
6881
7065
|
return { type: "boolean" };
|
|
6882
|
-
if (type.flags &
|
|
7066
|
+
if (type.flags & ts5.TypeFlags.BigIntLike)
|
|
6883
7067
|
return { type: "bigint" };
|
|
6884
|
-
if (type.flags &
|
|
7068
|
+
if (type.flags & ts5.TypeFlags.Null)
|
|
6885
7069
|
return { type: "null" };
|
|
6886
|
-
if (type.flags &
|
|
7070
|
+
if (type.flags & ts5.TypeFlags.Undefined)
|
|
6887
7071
|
return { type: "undefined" };
|
|
6888
7072
|
if (type.isUnion()) {
|
|
6889
7073
|
return {
|
|
@@ -6897,11 +7081,11 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6897
7081
|
}
|
|
6898
7082
|
if (ancestors.has(type)) {
|
|
6899
7083
|
return {
|
|
6900
|
-
ref: checker.typeToString(type, undefined,
|
|
7084
|
+
ref: checker.typeToString(type, undefined, ts5.TypeFormatFlags.NoTruncation)
|
|
6901
7085
|
};
|
|
6902
7086
|
}
|
|
6903
7087
|
ancestors.add(type);
|
|
6904
|
-
const arrayElement = checker.getIndexTypeOfType(type,
|
|
7088
|
+
const arrayElement = checker.getIndexTypeOfType(type, ts5.IndexKind.Number);
|
|
6905
7089
|
const properties = checker.getPropertiesOfType(type);
|
|
6906
7090
|
let schema;
|
|
6907
7091
|
if (arrayElement && properties.some(({ name }) => name === "length")) {
|
|
@@ -6916,7 +7100,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6916
7100
|
return [
|
|
6917
7101
|
property.name,
|
|
6918
7102
|
{
|
|
6919
|
-
optional: Boolean(property.flags &
|
|
7103
|
+
optional: Boolean(property.flags & ts5.SymbolFlags.Optional),
|
|
6920
7104
|
schema: serializeType(propertyType, checker, ancestors)
|
|
6921
7105
|
}
|
|
6922
7106
|
];
|
|
@@ -6924,7 +7108,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6924
7108
|
schema = { properties: Object.fromEntries(entries), type: "object" };
|
|
6925
7109
|
} else {
|
|
6926
7110
|
schema = {
|
|
6927
|
-
type: checker.typeToString(type, undefined,
|
|
7111
|
+
type: checker.typeToString(type, undefined, ts5.TypeFormatFlags.NoTruncation)
|
|
6928
7112
|
};
|
|
6929
7113
|
}
|
|
6930
7114
|
ancestors.delete(type);
|
|
@@ -6940,23 +7124,23 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6940
7124
|
return propsExpression ? checker.getTypeAtLocation(propsExpression) : checker.getTypeAtLocation(pageExpression);
|
|
6941
7125
|
}, resolvePageIdentity = (expression, sourceFile, checker, projectRoot) => {
|
|
6942
7126
|
let symbol = checker.getSymbolAtLocation(expression);
|
|
6943
|
-
if (symbol?.flags && symbol.flags &
|
|
7127
|
+
if (symbol?.flags && symbol.flags & ts5.SymbolFlags.Alias) {
|
|
6944
7128
|
symbol = checker.getAliasedSymbol(symbol);
|
|
6945
7129
|
}
|
|
6946
7130
|
const declaration = symbol?.declarations?.[0];
|
|
6947
7131
|
const file = declaration?.getSourceFile().fileName ?? sourceFile.fileName;
|
|
6948
7132
|
const exportedName = symbol?.name ?? expression.getText(sourceFile);
|
|
6949
|
-
const source = posixPath(
|
|
7133
|
+
const source = posixPath(relative12(projectRoot, file));
|
|
6950
7134
|
return `${source}#${exportedName}`;
|
|
6951
7135
|
}, resolveAlias = (symbol, checker) => {
|
|
6952
|
-
if (!(symbol.flags &
|
|
7136
|
+
if (!(symbol.flags & ts5.SymbolFlags.Alias))
|
|
6953
7137
|
return symbol;
|
|
6954
7138
|
return checker.getAliasedSymbol(symbol);
|
|
6955
7139
|
}, assetKey = (expression, checker, seen = new Set) => {
|
|
6956
7140
|
if (!expression)
|
|
6957
7141
|
return;
|
|
6958
|
-
if (
|
|
6959
|
-
const unresolved =
|
|
7142
|
+
if (ts5.isIdentifier(expression)) {
|
|
7143
|
+
const unresolved = ts5.isShorthandPropertyAssignment(expression.parent) ? checker.getShorthandAssignmentValueSymbol(expression.parent) : checker.getSymbolAtLocation(expression);
|
|
6960
7144
|
if (!unresolved)
|
|
6961
7145
|
return;
|
|
6962
7146
|
const symbol = resolveAlias(unresolved, checker);
|
|
@@ -6964,25 +7148,25 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6964
7148
|
return;
|
|
6965
7149
|
seen.add(symbol);
|
|
6966
7150
|
const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
6967
|
-
if (!declaration || !
|
|
7151
|
+
if (!declaration || !ts5.isVariableDeclaration(declaration))
|
|
6968
7152
|
return;
|
|
6969
7153
|
return assetKey(declaration.initializer, checker, seen);
|
|
6970
7154
|
}
|
|
6971
|
-
if (!
|
|
7155
|
+
if (!ts5.isCallExpression(expression))
|
|
6972
7156
|
return;
|
|
6973
|
-
if (!
|
|
7157
|
+
if (!ts5.isIdentifier(expression.expression) || expression.expression.text !== "asset") {
|
|
6974
7158
|
return;
|
|
6975
7159
|
}
|
|
6976
7160
|
const [, key] = expression.arguments;
|
|
6977
|
-
return key &&
|
|
7161
|
+
return key && ts5.isStringLiteralLike(key) ? key.text : undefined;
|
|
6978
7162
|
}, staticString = (expression, bindings) => {
|
|
6979
|
-
if (
|
|
7163
|
+
if (ts5.isStringLiteralLike(expression))
|
|
6980
7164
|
return expression.text;
|
|
6981
|
-
if (
|
|
7165
|
+
if (ts5.isIdentifier(expression))
|
|
6982
7166
|
return bindings.get(expression.text);
|
|
6983
|
-
if (
|
|
7167
|
+
if (ts5.isNoSubstitutionTemplateLiteral(expression))
|
|
6984
7168
|
return expression.text;
|
|
6985
|
-
if (!
|
|
7169
|
+
if (!ts5.isTemplateExpression(expression))
|
|
6986
7170
|
return;
|
|
6987
7171
|
let value = expression.head.text;
|
|
6988
7172
|
for (const span of expression.templateSpans) {
|
|
@@ -6995,7 +7179,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6995
7179
|
}, assetKeyWithBindings = (expression, checker, bindings = new Map) => {
|
|
6996
7180
|
if (!expression)
|
|
6997
7181
|
return;
|
|
6998
|
-
if (
|
|
7182
|
+
if (ts5.isCallExpression(expression) && ts5.isIdentifier(expression.expression) && expression.expression.text === "asset") {
|
|
6999
7183
|
const [, key] = expression.arguments;
|
|
7000
7184
|
return key ? staticString(key, bindings) : undefined;
|
|
7001
7185
|
}
|
|
@@ -7005,16 +7189,16 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7005
7189
|
const resolved = symbol ? resolveAlias(symbol, checker) : undefined;
|
|
7006
7190
|
const declaration = resolved?.valueDeclaration ?? resolved?.declarations?.[0];
|
|
7007
7191
|
let callable;
|
|
7008
|
-
if (declaration &&
|
|
7192
|
+
if (declaration && ts5.isFunctionDeclaration(declaration)) {
|
|
7009
7193
|
callable = declaration;
|
|
7010
|
-
} else if (declaration &&
|
|
7194
|
+
} else if (declaration && ts5.isVariableDeclaration(declaration) && declaration.initializer && (ts5.isArrowFunction(declaration.initializer) || ts5.isFunctionExpression(declaration.initializer))) {
|
|
7011
7195
|
callable = declaration.initializer;
|
|
7012
7196
|
}
|
|
7013
7197
|
if (!callable)
|
|
7014
7198
|
return;
|
|
7015
7199
|
const bindings = new Map;
|
|
7016
7200
|
callable.parameters.forEach((parameter, index) => {
|
|
7017
|
-
if (!
|
|
7201
|
+
if (!ts5.isIdentifier(parameter.name))
|
|
7018
7202
|
return;
|
|
7019
7203
|
const argument = call.arguments[index];
|
|
7020
7204
|
if (!argument)
|
|
@@ -7026,33 +7210,33 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7026
7210
|
const { body } = callable;
|
|
7027
7211
|
if (!body)
|
|
7028
7212
|
return;
|
|
7029
|
-
const expressionBody =
|
|
7030
|
-
if (
|
|
7213
|
+
const expressionBody = ts5.isParenthesizedExpression(body) ? body.expression : body;
|
|
7214
|
+
if (ts5.isObjectLiteralExpression(expressionBody)) {
|
|
7031
7215
|
return { bindings, object: expressionBody };
|
|
7032
7216
|
}
|
|
7033
|
-
if (
|
|
7034
|
-
const returned = body.statements.find(
|
|
7035
|
-
if (returned &&
|
|
7217
|
+
if (ts5.isBlock(body)) {
|
|
7218
|
+
const returned = body.statements.find(ts5.isReturnStatement)?.expression;
|
|
7219
|
+
if (returned && ts5.isObjectLiteralExpression(returned)) {
|
|
7036
7220
|
return { bindings, object: returned };
|
|
7037
7221
|
}
|
|
7038
7222
|
}
|
|
7039
7223
|
return;
|
|
7040
7224
|
}, spreadObject = (expression, checker, bindings) => {
|
|
7041
|
-
if (
|
|
7225
|
+
if (ts5.isObjectLiteralExpression(expression)) {
|
|
7042
7226
|
return { bindings, object: expression };
|
|
7043
7227
|
}
|
|
7044
|
-
if (!
|
|
7228
|
+
if (!ts5.isCallExpression(expression))
|
|
7045
7229
|
return;
|
|
7046
7230
|
return callableObject(expression, checker);
|
|
7047
|
-
}, objectAssetKey = (
|
|
7048
|
-
for (const property of [...
|
|
7049
|
-
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)) {
|
|
7050
7234
|
return assetKeyWithBindings(property.name, checker, bindings);
|
|
7051
7235
|
}
|
|
7052
|
-
if (propertyName(property) === name &&
|
|
7236
|
+
if (propertyName(property) === name && ts5.isPropertyAssignment(property)) {
|
|
7053
7237
|
return assetKeyWithBindings(property.initializer, checker, bindings);
|
|
7054
7238
|
}
|
|
7055
|
-
if (!
|
|
7239
|
+
if (!ts5.isSpreadAssignment(property))
|
|
7056
7240
|
continue;
|
|
7057
7241
|
const nestedObject = spreadObject(property.expression, checker, bindings);
|
|
7058
7242
|
if (!nestedObject)
|
|
@@ -7067,26 +7251,26 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7067
7251
|
const visit = (candidate) => {
|
|
7068
7252
|
if (found)
|
|
7069
7253
|
return;
|
|
7070
|
-
if (
|
|
7254
|
+
if (ts5.isCallExpression(candidate) && ts5.isIdentifier(candidate.expression) && PAGE_HANDLERS.has(candidate.expression.text)) {
|
|
7071
7255
|
const definition = PAGE_HANDLERS.get(candidate.expression.text);
|
|
7072
7256
|
if (!definition)
|
|
7073
7257
|
return;
|
|
7074
7258
|
found = { definition, node: candidate };
|
|
7075
7259
|
return;
|
|
7076
7260
|
}
|
|
7077
|
-
|
|
7261
|
+
ts5.forEachChild(candidate, visit);
|
|
7078
7262
|
};
|
|
7079
7263
|
for (const node of nodes)
|
|
7080
7264
|
visit(node);
|
|
7081
7265
|
return found;
|
|
7082
7266
|
}, isProjectSource = (sourceFile, resolvedFile, projectRoot) => !sourceFile.isDeclarationFile && !resolvedFile.includes("/node_modules/") && resolvedFile.startsWith(`${projectRoot}/`), analyzeRouteCall = (node, sourceFile, checker, projectRoot) => {
|
|
7083
7267
|
const callee = node.expression;
|
|
7084
|
-
if (!
|
|
7268
|
+
if (!ts5.isPropertyAccessExpression(callee))
|
|
7085
7269
|
return;
|
|
7086
7270
|
if (!ROUTE_METHODS.has(callee.name.text))
|
|
7087
7271
|
return;
|
|
7088
7272
|
const [routePath] = node.arguments;
|
|
7089
|
-
if (!routePath || !
|
|
7273
|
+
if (!routePath || !ts5.isStringLiteralLike(routePath))
|
|
7090
7274
|
return;
|
|
7091
7275
|
const foundPageCall = findPageCall(node.arguments.slice(1));
|
|
7092
7276
|
const pageCall = foundPageCall?.node;
|
|
@@ -7119,7 +7303,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7119
7303
|
routeCallSpan: `${node.getStart(sourceFile)}:${node.end}`
|
|
7120
7304
|
};
|
|
7121
7305
|
}
|
|
7122
|
-
if (!
|
|
7306
|
+
if (!ts5.isObjectLiteralExpression(input) || !definition.bundleProperty) {
|
|
7123
7307
|
return;
|
|
7124
7308
|
}
|
|
7125
7309
|
const page = definition.pageProperty ? objectPropertyExpression(input, definition.pageProperty) : undefined;
|
|
@@ -7160,20 +7344,20 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7160
7344
|
byRouteCall: new Map
|
|
7161
7345
|
};
|
|
7162
7346
|
const visit = (node) => {
|
|
7163
|
-
const result =
|
|
7347
|
+
const result = ts5.isCallExpression(node) ? analyzeRouteCall(node, sourceFile, checker, projectRoot) : undefined;
|
|
7164
7348
|
if (result) {
|
|
7165
7349
|
analysis.byPageCall.set(result.pageCallStart, result);
|
|
7166
7350
|
analysis.byRouteCall.set(result.routeCallSpan, result);
|
|
7167
7351
|
}
|
|
7168
|
-
|
|
7352
|
+
ts5.forEachChild(node, visit);
|
|
7169
7353
|
};
|
|
7170
|
-
|
|
7354
|
+
ts5.forEachChild(sourceFile, visit);
|
|
7171
7355
|
return analysis;
|
|
7172
7356
|
}, analyzeProgram = (program, projectRoot) => {
|
|
7173
7357
|
const checker = program.getTypeChecker();
|
|
7174
7358
|
const analyzed = new Map;
|
|
7175
7359
|
for (const sourceFile of program.getSourceFiles()) {
|
|
7176
|
-
const resolvedFile =
|
|
7360
|
+
const resolvedFile = resolve18(sourceFile.fileName);
|
|
7177
7361
|
if (!isProjectSource(sourceFile, resolvedFile, projectRoot))
|
|
7178
7362
|
continue;
|
|
7179
7363
|
const analysis = analyzeSourceFile(sourceFile, checker, projectRoot);
|
|
@@ -7181,20 +7365,20 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7181
7365
|
analyzed.set(resolvedFile, analysis);
|
|
7182
7366
|
}
|
|
7183
7367
|
return analyzed;
|
|
7184
|
-
}, metadataExpression = (metadata) =>
|
|
7185
|
-
const detail =
|
|
7186
|
-
|
|
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))
|
|
7187
7371
|
]);
|
|
7188
7372
|
if (!existing) {
|
|
7189
|
-
return
|
|
7190
|
-
|
|
7373
|
+
return ts5.factory.createObjectLiteralExpression([
|
|
7374
|
+
ts5.factory.createPropertyAssignment("detail", detail)
|
|
7191
7375
|
]);
|
|
7192
7376
|
}
|
|
7193
|
-
return
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
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))
|
|
7198
7382
|
]))
|
|
7199
7383
|
]);
|
|
7200
7384
|
}, transformPageCall = (node, page) => {
|
|
@@ -7204,19 +7388,19 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7204
7388
|
const [pagePath, existingOptions, ...rest] = node.arguments;
|
|
7205
7389
|
if (!pagePath)
|
|
7206
7390
|
return;
|
|
7207
|
-
const options =
|
|
7208
|
-
...existingOptions ? [
|
|
7209
|
-
|
|
7391
|
+
const options = ts5.factory.createObjectLiteralExpression([
|
|
7392
|
+
...existingOptions ? [ts5.factory.createSpreadAssignment(existingOptions)] : [],
|
|
7393
|
+
ts5.factory.createPropertyAssignment("__absoluteMobile", metadataExpression(page.metadata))
|
|
7210
7394
|
]);
|
|
7211
|
-
return
|
|
7395
|
+
return ts5.factory.updateCallExpression(node, node.expression, node.typeArguments, [pagePath, options, ...rest]);
|
|
7212
7396
|
}
|
|
7213
7397
|
const [input] = node.arguments;
|
|
7214
|
-
if (!input || !
|
|
7398
|
+
if (!input || !ts5.isObjectLiteralExpression(input))
|
|
7215
7399
|
return;
|
|
7216
|
-
return
|
|
7217
|
-
|
|
7400
|
+
return ts5.factory.updateCallExpression(node, node.expression, node.typeArguments, [
|
|
7401
|
+
ts5.factory.updateObjectLiteralExpression(input, [
|
|
7218
7402
|
...input.properties,
|
|
7219
|
-
|
|
7403
|
+
ts5.factory.createPropertyAssignment("__absoluteMobile", metadataExpression(page.metadata))
|
|
7220
7404
|
]),
|
|
7221
7405
|
...node.arguments.slice(1)
|
|
7222
7406
|
]);
|
|
@@ -7228,15 +7412,15 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7228
7412
|
return;
|
|
7229
7413
|
const options = maybeHandler ? maybeOptions : undefined;
|
|
7230
7414
|
const handler = maybeHandler ?? maybeOptions;
|
|
7231
|
-
return
|
|
7415
|
+
return ts5.factory.updateCallExpression(node, node.expression, node.typeArguments, [path, routeOptions(options, route.metadata), handler, ...rest]);
|
|
7232
7416
|
}, transformFile = (source, fileName, analysis) => {
|
|
7233
|
-
const sourceFile =
|
|
7417
|
+
const sourceFile = ts5.createSourceFile(fileName, source, ts5.ScriptTarget.Latest, true, fileName.endsWith("x") ? ts5.ScriptKind.TSX : ts5.ScriptKind.TS);
|
|
7234
7418
|
const transformer = (context) => {
|
|
7235
7419
|
const visit = (node) => {
|
|
7236
|
-
if (!
|
|
7237
|
-
return
|
|
7420
|
+
if (!ts5.isCallExpression(node)) {
|
|
7421
|
+
return ts5.visitEachChild(node, visit, context);
|
|
7238
7422
|
}
|
|
7239
|
-
const transformedChildren =
|
|
7423
|
+
const transformedChildren = ts5.visitEachChild(node, visit, context);
|
|
7240
7424
|
const page = analysis.byPageCall.get(node.getStart(sourceFile));
|
|
7241
7425
|
const transformedPage = transformPageCall(transformedChildren, page);
|
|
7242
7426
|
if (transformedPage)
|
|
@@ -7247,32 +7431,32 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
7247
7431
|
return transformedRoute;
|
|
7248
7432
|
return transformedChildren;
|
|
7249
7433
|
};
|
|
7250
|
-
return (node) =>
|
|
7434
|
+
return (node) => ts5.visitNode(node, visit, ts5.isSourceFile) ?? node;
|
|
7251
7435
|
};
|
|
7252
|
-
const result =
|
|
7436
|
+
const result = ts5.transform(sourceFile, [transformer]);
|
|
7253
7437
|
try {
|
|
7254
7438
|
const [transformed] = result.transformed;
|
|
7255
7439
|
if (!transformed)
|
|
7256
7440
|
throw new TypeError("Mobile route transform failed.");
|
|
7257
|
-
return
|
|
7441
|
+
return ts5.createPrinter().printFile(transformed);
|
|
7258
7442
|
} finally {
|
|
7259
7443
|
result.dispose();
|
|
7260
7444
|
}
|
|
7261
7445
|
}, createAbsoluteMobileRouteMetadataPlugin = (options) => {
|
|
7262
|
-
const projectRoot =
|
|
7263
|
-
const entry =
|
|
7446
|
+
const projectRoot = resolve18(options.projectRoot ?? process.cwd());
|
|
7447
|
+
const entry = resolve18(options.entry);
|
|
7264
7448
|
const analyzed = analyzeProgram(createProgram(entry, projectRoot), projectRoot);
|
|
7265
7449
|
return {
|
|
7266
7450
|
name: "absolute-mobile-route-metadata",
|
|
7267
7451
|
setup(build) {
|
|
7268
7452
|
build.onLoad({ filter: SOURCE_FILTER }, async ({ path }) => {
|
|
7269
|
-
const analysis = analyzed.get(
|
|
7453
|
+
const analysis = analyzed.get(resolve18(path));
|
|
7270
7454
|
if (!analysis)
|
|
7271
7455
|
return;
|
|
7272
7456
|
const source = await Bun.file(path).text();
|
|
7273
7457
|
return {
|
|
7274
7458
|
contents: transformFile(source, path, analysis),
|
|
7275
|
-
loader:
|
|
7459
|
+
loader: extname6(path).endsWith("x") ? "tsx" : "ts"
|
|
7276
7460
|
};
|
|
7277
7461
|
});
|
|
7278
7462
|
}
|
|
@@ -7333,7 +7517,7 @@ var init_routeMetadataTransform = __esm(() => {
|
|
|
7333
7517
|
});
|
|
7334
7518
|
|
|
7335
7519
|
// src/cli/elysiaOpenApiTypeboxPlugin.ts
|
|
7336
|
-
import { dirname as dirname14, resolve as
|
|
7520
|
+
import { dirname as dirname14, resolve as resolve19 } from "path";
|
|
7337
7521
|
var OPENAPI_TYPEBOX_PREFIX = "../node_modules/typebox/", OPENAPI_DISTRIBUTION_SEGMENT = "/@elysia/openapi/dist/", createElysiaOpenApiTypeboxPlugin = () => ({
|
|
7338
7522
|
name: "absolute-elysia-openapi-typebox",
|
|
7339
7523
|
setup(build) {
|
|
@@ -7345,7 +7529,7 @@ var OPENAPI_TYPEBOX_PREFIX = "../node_modules/typebox/", OPENAPI_DISTRIBUTION_SE
|
|
|
7345
7529
|
const relativePath = args.path.slice(OPENAPI_TYPEBOX_PREFIX.length);
|
|
7346
7530
|
const typeboxEntry = Bun.resolveSync("typebox", dirname14(args.importer));
|
|
7347
7531
|
return {
|
|
7348
|
-
path:
|
|
7532
|
+
path: resolve19(dirname14(typeboxEntry), "..", relativePath)
|
|
7349
7533
|
};
|
|
7350
7534
|
});
|
|
7351
7535
|
}
|
|
@@ -7405,15 +7589,15 @@ __export(exports_prerender, {
|
|
|
7405
7589
|
prerender: () => prerender,
|
|
7406
7590
|
PRERENDER_BYPASS_HEADER: () => PRERENDER_BYPASS_HEADER
|
|
7407
7591
|
});
|
|
7408
|
-
import { mkdirSync as mkdirSync6, readFileSync as
|
|
7409
|
-
import { join as
|
|
7592
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync14 } from "fs";
|
|
7593
|
+
import { join as join22 } from "path";
|
|
7410
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) => {
|
|
7411
7595
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
7412
7596
|
await Bun.write(metaPath, String(Date.now()));
|
|
7413
7597
|
}, readTimestamp = (htmlPath) => {
|
|
7414
7598
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
7415
7599
|
try {
|
|
7416
|
-
const content =
|
|
7600
|
+
const content = readFileSync14(metaPath, "utf-8");
|
|
7417
7601
|
return Number(content) || 0;
|
|
7418
7602
|
} catch {
|
|
7419
7603
|
return 0;
|
|
@@ -7476,7 +7660,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
7476
7660
|
if (!isCompleteHtml(html))
|
|
7477
7661
|
return false;
|
|
7478
7662
|
const fileName = routeToFilename(route);
|
|
7479
|
-
const filePath =
|
|
7663
|
+
const filePath = join22(prerenderDir, fileName);
|
|
7480
7664
|
await Bun.write(filePath, html);
|
|
7481
7665
|
await writeTimestamp(filePath);
|
|
7482
7666
|
return true;
|
|
@@ -7506,13 +7690,13 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
7506
7690
|
return;
|
|
7507
7691
|
}
|
|
7508
7692
|
const fileName = routeToFilename(route);
|
|
7509
|
-
const filePath =
|
|
7693
|
+
const filePath = join22(prerenderDir, fileName);
|
|
7510
7694
|
await Bun.write(filePath, html);
|
|
7511
7695
|
await writeTimestamp(filePath);
|
|
7512
7696
|
result.routes.set(route, filePath);
|
|
7513
7697
|
log?.(` Pre-rendered ${route} \u2192 ${fileName} (${html.length} bytes)`);
|
|
7514
7698
|
}, prerender = async (port, outDir, staticConfig, log) => {
|
|
7515
|
-
const prerenderDir =
|
|
7699
|
+
const prerenderDir = join22(outDir, "_prerendered");
|
|
7516
7700
|
mkdirSync6(prerenderDir, { recursive: true });
|
|
7517
7701
|
const baseUrl = `http://localhost:${port}`;
|
|
7518
7702
|
let routes;
|
|
@@ -7579,10 +7763,10 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
7579
7763
|
};
|
|
7580
7764
|
read();
|
|
7581
7765
|
}, formatServerOutput = (output) => {
|
|
7582
|
-
const
|
|
7583
|
-
if (!
|
|
7766
|
+
const text2 = output.join("").trim();
|
|
7767
|
+
if (!text2)
|
|
7584
7768
|
return "";
|
|
7585
|
-
return
|
|
7769
|
+
return text2.length > SERVER_OUTPUT_LIMIT ? text2.slice(-SERVER_OUTPUT_LIMIT) : text2;
|
|
7586
7770
|
}, createServerStartupError = (output) => {
|
|
7587
7771
|
const serverOutput = formatServerOutput(output);
|
|
7588
7772
|
const message = serverOutput ? `Server failed to start for pre-rendering.
|
|
@@ -7631,9 +7815,9 @@ var SENTINEL, RISKY_STRING_CONTENT, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c)
|
|
|
7631
7815
|
let prevChar = "";
|
|
7632
7816
|
let prevWord = "";
|
|
7633
7817
|
let prevWasSpace = false;
|
|
7634
|
-
const mask = (
|
|
7818
|
+
const mask = (text2) => {
|
|
7635
7819
|
out += SENTINEL + pieces.length + SENTINEL;
|
|
7636
|
-
pieces.push(
|
|
7820
|
+
pieces.push(text2);
|
|
7637
7821
|
prevChar = ")";
|
|
7638
7822
|
prevWord = "";
|
|
7639
7823
|
prevWasSpace = false;
|
|
@@ -7799,11 +7983,11 @@ var SENTINEL, RISKY_STRING_CONTENT, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c)
|
|
|
7799
7983
|
}
|
|
7800
7984
|
if (c === '"' || c === "'") {
|
|
7801
7985
|
const end = endOfString(i);
|
|
7802
|
-
const
|
|
7803
|
-
if (RISKY_STRING_CONTENT.test(
|
|
7804
|
-
mask(
|
|
7986
|
+
const text2 = src.slice(i, end);
|
|
7987
|
+
if (RISKY_STRING_CONTENT.test(text2)) {
|
|
7988
|
+
mask(text2);
|
|
7805
7989
|
} else {
|
|
7806
|
-
out +=
|
|
7990
|
+
out += text2;
|
|
7807
7991
|
prevChar = '"';
|
|
7808
7992
|
prevWord = "";
|
|
7809
7993
|
prevWasSpace = false;
|
|
@@ -7888,7 +8072,7 @@ var init_maskLiterals = __esm(() => {
|
|
|
7888
8072
|
// src/build/nativeRewrite.ts
|
|
7889
8073
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
7890
8074
|
import { platform as platform4, arch as arch3 } from "os";
|
|
7891
|
-
import { resolve as
|
|
8075
|
+
import { resolve as resolve20 } from "path";
|
|
7892
8076
|
var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
7893
8077
|
if (nativeLib !== null)
|
|
7894
8078
|
return nativeLib;
|
|
@@ -7906,7 +8090,7 @@ var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
|
7906
8090
|
if (!libPath)
|
|
7907
8091
|
return null;
|
|
7908
8092
|
try {
|
|
7909
|
-
const fullPath =
|
|
8093
|
+
const fullPath = resolve20(import.meta.dir, "../../native/packages", libPath);
|
|
7910
8094
|
const lib = dlopen(fullPath, ffiDefinition);
|
|
7911
8095
|
nativeLib = lib.symbols;
|
|
7912
8096
|
return nativeLib;
|
|
@@ -7948,7 +8132,7 @@ var init_nativeRewrite = __esm(() => {
|
|
|
7948
8132
|
|
|
7949
8133
|
// src/build/rewriteImportsPlugin.ts
|
|
7950
8134
|
import { readdir as readdir3 } from "fs/promises";
|
|
7951
|
-
import { join as
|
|
8135
|
+
import { join as join23 } from "path";
|
|
7952
8136
|
var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
|
|
7953
8137
|
let result = content;
|
|
7954
8138
|
for (const [specifier, webPath] of replacements) {
|
|
@@ -8027,7 +8211,7 @@ ${content}`;
|
|
|
8027
8211
|
const entries = await readdir3(dir);
|
|
8028
8212
|
for (const entry of entries) {
|
|
8029
8213
|
if (entry.endsWith(".js"))
|
|
8030
|
-
allFiles.push(
|
|
8214
|
+
allFiles.push(join23(dir, entry));
|
|
8031
8215
|
}
|
|
8032
8216
|
} catch {}
|
|
8033
8217
|
}
|
|
@@ -8102,8 +8286,8 @@ var init_rewriteImports = __esm(() => {
|
|
|
8102
8286
|
|
|
8103
8287
|
// src/cli/scripts/start.ts
|
|
8104
8288
|
var {env: env2 } = globalThis.Bun;
|
|
8105
|
-
import { existsSync as existsSync11, readFileSync as
|
|
8106
|
-
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";
|
|
8107
8291
|
var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, resolvePackageVersion = (candidates) => {
|
|
8108
8292
|
for (const candidate of candidates) {
|
|
8109
8293
|
const version2 = readPackageVersion2(candidate);
|
|
@@ -8114,7 +8298,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8114
8298
|
return "";
|
|
8115
8299
|
}, readPackageVersion2 = (candidate) => {
|
|
8116
8300
|
try {
|
|
8117
|
-
const pkg = JSON.parse(
|
|
8301
|
+
const pkg = JSON.parse(readFileSync15(candidate, "utf-8"));
|
|
8118
8302
|
if (pkg.name !== "@absolutejs/absolute")
|
|
8119
8303
|
return null;
|
|
8120
8304
|
const ver = pkg.version;
|
|
@@ -8152,18 +8336,18 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8152
8336
|
process.exit(1);
|
|
8153
8337
|
}, resolveJsxDevRuntimeCompatPath = () => {
|
|
8154
8338
|
const candidates = [
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
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")
|
|
8161
8345
|
];
|
|
8162
8346
|
for (const candidate of candidates) {
|
|
8163
8347
|
if (existsSync11(candidate))
|
|
8164
8348
|
return candidate;
|
|
8165
8349
|
}
|
|
8166
|
-
return
|
|
8350
|
+
return resolve21(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
|
|
8167
8351
|
}, jsxDevRuntimeCompatPath, prerenderStaticPages = async (outputPath, prerenderPort, resolvedOutdir, staticConfig, absoluteVersion, configPath2) => {
|
|
8168
8352
|
const prerenderStart = performance.now();
|
|
8169
8353
|
process.stdout.write(cliTag2("\x1B[36m", "Pre-rendering static pages"));
|
|
@@ -8197,7 +8381,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8197
8381
|
serverEntry,
|
|
8198
8382
|
totalDuration
|
|
8199
8383
|
}) => {
|
|
8200
|
-
const usesDocker = existsSync11(
|
|
8384
|
+
const usesDocker = existsSync11(resolve21(COMPOSE_PATH));
|
|
8201
8385
|
const scripts = usesDocker ? await readDbScripts() : null;
|
|
8202
8386
|
if (scripts)
|
|
8203
8387
|
await startDatabase(scripts);
|
|
@@ -8288,10 +8472,10 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8288
8472
|
const port = Number(env2.PORT) || DEFAULT_PORT;
|
|
8289
8473
|
killStaleProcesses(port);
|
|
8290
8474
|
const entryName = basename8(serverEntry).replace(/\.[^.]+$/, "");
|
|
8291
|
-
const resolvedOutdir =
|
|
8475
|
+
const resolvedOutdir = resolve21(outdir ?? "dist");
|
|
8292
8476
|
const absoluteVersion = resolvePackageVersion([
|
|
8293
|
-
|
|
8294
|
-
|
|
8477
|
+
resolve21(import.meta.dir, "..", "..", "..", "package.json"),
|
|
8478
|
+
resolve21(import.meta.dir, "..", "..", "package.json")
|
|
8295
8479
|
]);
|
|
8296
8480
|
const buildConfig = await loadConfig(configPath2);
|
|
8297
8481
|
buildConfig.buildDirectory = resolvedOutdir;
|
|
@@ -8306,7 +8490,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8306
8490
|
buildConfig.vueDirectory && "vue",
|
|
8307
8491
|
buildConfig.angularDirectory && "angular"
|
|
8308
8492
|
].filter((val) => Boolean(val));
|
|
8309
|
-
const outputPath =
|
|
8493
|
+
const outputPath = resolve21(resolvedOutdir, `${entryName}.js`);
|
|
8310
8494
|
if (options.prebuilt) {
|
|
8311
8495
|
if (!existsSync11(outputPath)) {
|
|
8312
8496
|
throw new Error(`Prepared production server not found: ${outputPath}`);
|
|
@@ -8329,13 +8513,13 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8329
8513
|
process.stdout.write(cliTag2("\x1B[36m", `Building assets`));
|
|
8330
8514
|
try {
|
|
8331
8515
|
const build = await resolveBuildModule([
|
|
8332
|
-
|
|
8333
|
-
|
|
8516
|
+
resolve21(import.meta.dir, "..", "..", "core", "build"),
|
|
8517
|
+
resolve21(import.meta.dir, "..", "build")
|
|
8334
8518
|
]);
|
|
8335
8519
|
if (!build)
|
|
8336
8520
|
throw new Error("Could not locate build module");
|
|
8337
8521
|
await build(buildConfig);
|
|
8338
|
-
rmSync4(
|
|
8522
|
+
rmSync4(join24(resolvedOutdir, "_prerendered"), {
|
|
8339
8523
|
force: true,
|
|
8340
8524
|
recursive: true
|
|
8341
8525
|
});
|
|
@@ -8400,8 +8584,8 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8400
8584
|
const normalizedPath = args.path.replace(/\\/g, "/");
|
|
8401
8585
|
if (normalizedPath.includes("/src/angular/"))
|
|
8402
8586
|
return;
|
|
8403
|
-
const
|
|
8404
|
-
if (
|
|
8587
|
+
const text2 = await Bun.file(args.path).text();
|
|
8588
|
+
if (text2.includes("@Component") && stripStringsAndComments(text2).includes("@Component")) {
|
|
8405
8589
|
return {
|
|
8406
8590
|
contents: "export default {}",
|
|
8407
8591
|
loader: "js"
|
|
@@ -8412,17 +8596,17 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8412
8596
|
}
|
|
8413
8597
|
};
|
|
8414
8598
|
const islandRegistrySpec = buildConfig.islands?.registry;
|
|
8415
|
-
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(
|
|
8599
|
+
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve21(islandRegistrySpec))) : undefined;
|
|
8416
8600
|
const serverBundle = await Bun.build({
|
|
8417
8601
|
define: { "process.env.NODE_ENV": '"production"' },
|
|
8418
|
-
entrypoints: [
|
|
8602
|
+
entrypoints: [resolve21(serverEntry)],
|
|
8419
8603
|
external: resolveServerBundleExternals(buildConfig),
|
|
8420
8604
|
outdir: resolvedOutdir,
|
|
8421
8605
|
plugins: [
|
|
8422
8606
|
...islandRegistryPlugin ? [islandRegistryPlugin] : [],
|
|
8423
8607
|
...buildConfig.mobile ? [
|
|
8424
8608
|
createAbsoluteMobileRouteMetadataPlugin({
|
|
8425
|
-
entry:
|
|
8609
|
+
entry: resolve21(serverEntry)
|
|
8426
8610
|
})
|
|
8427
8611
|
] : [],
|
|
8428
8612
|
createElysiaOpenApiTypeboxPlugin(),
|
|
@@ -8439,9 +8623,9 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8439
8623
|
console.error(cliTag2("\x1B[31m", `Expected output not found: ${outputPath}`));
|
|
8440
8624
|
process.exit(1);
|
|
8441
8625
|
}
|
|
8442
|
-
if (existsSync11(
|
|
8626
|
+
if (existsSync11(resolve21(resolvedOutdir, "angular", "vendor", "server"))) {
|
|
8443
8627
|
const { readdirSync: readdirSync2 } = await import("fs");
|
|
8444
|
-
const vendorDir =
|
|
8628
|
+
const vendorDir = resolve21(resolvedOutdir, "angular", "vendor", "server");
|
|
8445
8629
|
const vendorEntries = readdirSync2(vendorDir).filter((fileName) => fileName.endsWith(".js"));
|
|
8446
8630
|
const angularServerVendorPaths = {};
|
|
8447
8631
|
const { relative: pathRelative, dirname: pathDirname } = await import("path");
|
|
@@ -8451,7 +8635,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8451
8635
|
if (scope !== "angular" || rest.length === 0)
|
|
8452
8636
|
continue;
|
|
8453
8637
|
const specifier = `@angular/${rest.join("/")}`;
|
|
8454
|
-
const relPath = pathRelative(pathDirname(outputPath),
|
|
8638
|
+
const relPath = pathRelative(pathDirname(outputPath), resolve21(vendorDir, file));
|
|
8455
8639
|
angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
8456
8640
|
}
|
|
8457
8641
|
if (Object.keys(angularServerVendorPaths).length > 0) {
|
|
@@ -8638,17 +8822,17 @@ var exports_build = {};
|
|
|
8638
8822
|
__export(exports_build, {
|
|
8639
8823
|
build: () => build
|
|
8640
8824
|
});
|
|
8641
|
-
import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as
|
|
8642
|
-
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";
|
|
8643
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) => {
|
|
8644
|
-
const traceDir =
|
|
8828
|
+
const traceDir = join25(buildDir, ".absolute-trace");
|
|
8645
8829
|
if (!existsSync13(traceDir))
|
|
8646
8830
|
return;
|
|
8647
8831
|
const files = readdirSync3(traceDir).filter((file) => file.endsWith(".json")).sort();
|
|
8648
8832
|
const latest = files[files.length - 1];
|
|
8649
8833
|
if (latest === undefined)
|
|
8650
8834
|
return;
|
|
8651
|
-
const trace = JSON.parse(
|
|
8835
|
+
const trace = JSON.parse(readFileSync17(join25(traceDir, latest), "utf-8"));
|
|
8652
8836
|
const events = Array.isArray(trace.events) ? trace.events : [];
|
|
8653
8837
|
if (events.length === 0)
|
|
8654
8838
|
return;
|
|
@@ -8685,7 +8869,7 @@ var PROFILE_TOP = 15, PROFILE_COL = 8, FRAMEWORK_KEYS, cliTag3 = (color, message
|
|
|
8685
8869
|
}
|
|
8686
8870
|
return resolveBuildModule2(remaining);
|
|
8687
8871
|
}, build = async (outdir, configPath2, profile = false) => {
|
|
8688
|
-
const resolvedOutdir =
|
|
8872
|
+
const resolvedOutdir = resolve23(outdir ?? "build");
|
|
8689
8873
|
const buildStart = performance.now();
|
|
8690
8874
|
if (profile)
|
|
8691
8875
|
process.env.ABSOLUTE_BUILD_TRACE = "1";
|
|
@@ -8695,8 +8879,8 @@ var PROFILE_TOP = 15, PROFILE_COL = 8, FRAMEWORK_KEYS, cliTag3 = (color, message
|
|
|
8695
8879
|
buildConfig.mode = "production";
|
|
8696
8880
|
try {
|
|
8697
8881
|
const buildApp = await resolveBuildModule2([
|
|
8698
|
-
|
|
8699
|
-
|
|
8882
|
+
resolve23(import.meta.dir, "..", "..", "core", "build"),
|
|
8883
|
+
resolve23(import.meta.dir, "..", "build")
|
|
8700
8884
|
]);
|
|
8701
8885
|
if (!buildApp)
|
|
8702
8886
|
throw new Error("Could not locate build module");
|
|
@@ -8745,14 +8929,14 @@ import {
|
|
|
8745
8929
|
lstatSync,
|
|
8746
8930
|
mkdirSync as mkdirSync8,
|
|
8747
8931
|
mkdtempSync,
|
|
8748
|
-
readFileSync as
|
|
8932
|
+
readFileSync as readFileSync18,
|
|
8749
8933
|
realpathSync,
|
|
8750
8934
|
renameSync as renameSync2,
|
|
8751
8935
|
rmSync as rmSync5,
|
|
8752
8936
|
writeFileSync as writeFileSync7
|
|
8753
8937
|
} from "fs";
|
|
8754
8938
|
import { tmpdir as tmpdir3 } from "os";
|
|
8755
|
-
import { delimiter, dirname as dirname15, relative as
|
|
8939
|
+
import { delimiter, dirname as dirname15, relative as relative13, resolve as resolve24 } from "path";
|
|
8756
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) => {
|
|
8757
8941
|
const proc = Bun.spawnSync(["git", ...args], {
|
|
8758
8942
|
cwd: options.cwd,
|
|
@@ -8765,8 +8949,8 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8765
8949
|
throw new Error(detail || `git ${args.join(" ")} failed`);
|
|
8766
8950
|
}
|
|
8767
8951
|
return proc.stdout.toString().trim();
|
|
8768
|
-
}, gitRoot = (cwd) =>
|
|
8769
|
-
const path =
|
|
8952
|
+
}, gitRoot = (cwd) => resolve24(runGit(["rev-parse", "--show-toplevel"], { cwd })), isInside3 = (parent, candidate) => {
|
|
8953
|
+
const path = relative13(parent, candidate);
|
|
8770
8954
|
return path === "" || !path.startsWith("../") && path !== "..";
|
|
8771
8955
|
}, attestationPayload = (proof) => Buffer.from([
|
|
8772
8956
|
"absolute-lint-proof-attestation:1",
|
|
@@ -8778,17 +8962,17 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8778
8962
|
sourceTree: proof.sourceTree
|
|
8779
8963
|
})
|
|
8780
8964
|
].join("\x00")), publicKeyId = (key) => createHash11("sha256").update(key.export({ format: "der", type: "spki" })).digest("hex"), readEd25519PrivateKey = (cwd, location) => {
|
|
8781
|
-
const path =
|
|
8965
|
+
const path = resolve24(cwd, location);
|
|
8782
8966
|
if (isInside3(realpathSync(gitRoot(cwd)), realpathSync(path))) {
|
|
8783
8967
|
throw new Error("lint proof signing key must live outside the Git working tree");
|
|
8784
8968
|
}
|
|
8785
|
-
const key = createPrivateKey(
|
|
8969
|
+
const key = createPrivateKey(readFileSync18(path));
|
|
8786
8970
|
if (key.asymmetricKeyType !== "ed25519") {
|
|
8787
8971
|
throw new Error("lint proof signing key must be an Ed25519 private key");
|
|
8788
8972
|
}
|
|
8789
8973
|
return key;
|
|
8790
8974
|
}, readEd25519PublicKey = (cwd, location) => {
|
|
8791
|
-
const key = createPublicKey(
|
|
8975
|
+
const key = createPublicKey(readFileSync18(resolve24(cwd, location)));
|
|
8792
8976
|
if (key.asymmetricKeyType !== "ed25519") {
|
|
8793
8977
|
throw new Error("trusted lint proof key must be an Ed25519 public key");
|
|
8794
8978
|
}
|
|
@@ -8816,7 +9000,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8816
9000
|
return null;
|
|
8817
9001
|
const auxiliary = gitVisibleFiles(root).filter((file) => TSCONFIG_PATTERN.test(file));
|
|
8818
9002
|
const configPath2 = findEslintConfigPath(root);
|
|
8819
|
-
const configRelative = configPath2 === null ? null :
|
|
9003
|
+
const configRelative = configPath2 === null ? null : relative13(root, configPath2).replaceAll("\\", "/");
|
|
8820
9004
|
return [
|
|
8821
9005
|
...new Set([
|
|
8822
9006
|
...resolveLintTargets(args, root),
|
|
@@ -8826,17 +9010,17 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8826
9010
|
].sort();
|
|
8827
9011
|
}, createLintSourceTree = (cwd = process.cwd(), proofLocation = DEFAULT_PROOF_LOCATION, command = []) => {
|
|
8828
9012
|
const root = gitRoot(cwd);
|
|
8829
|
-
const proofPath =
|
|
8830
|
-
const proofRelative =
|
|
9013
|
+
const proofPath = resolve24(cwd, proofLocation);
|
|
9014
|
+
const proofRelative = relative13(root, proofPath).replaceAll("\\", "/");
|
|
8831
9015
|
if (proofRelative === ".." || proofRelative.startsWith("../") || proofRelative === "") {
|
|
8832
9016
|
throw new Error("lint proof must live inside the Git working tree");
|
|
8833
9017
|
}
|
|
8834
|
-
const temporaryDirectory = mkdtempSync(
|
|
8835
|
-
const temporaryIndex =
|
|
8836
|
-
const temporaryObjects =
|
|
9018
|
+
const temporaryDirectory = mkdtempSync(resolve24(tmpdir3(), "absolute-lint-proof-"));
|
|
9019
|
+
const temporaryIndex = resolve24(temporaryDirectory, "index");
|
|
9020
|
+
const temporaryObjects = resolve24(temporaryDirectory, "objects");
|
|
8837
9021
|
mkdirSync8(temporaryObjects, { recursive: true });
|
|
8838
9022
|
const repositoryObjectsPath = runGit(["rev-parse", "--git-path", "objects"], { cwd: root });
|
|
8839
|
-
const repositoryObjects =
|
|
9023
|
+
const repositoryObjects = resolve24(root, repositoryObjectsPath);
|
|
8840
9024
|
const existingAlternates = process.env.GIT_ALTERNATE_OBJECT_DIRECTORIES?.trim();
|
|
8841
9025
|
const env3 = {
|
|
8842
9026
|
GIT_ALTERNATE_OBJECT_DIRECTORIES: [
|
|
@@ -8860,7 +9044,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8860
9044
|
if (!path || path === proofRelative)
|
|
8861
9045
|
return false;
|
|
8862
9046
|
try {
|
|
8863
|
-
lstatSync(
|
|
9047
|
+
lstatSync(resolve24(root, path));
|
|
8864
9048
|
return true;
|
|
8865
9049
|
} catch {
|
|
8866
9050
|
return false;
|
|
@@ -8884,7 +9068,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8884
9068
|
}, writeLintProof = (command, options = {}) => {
|
|
8885
9069
|
const cwd = options.cwd ?? process.cwd();
|
|
8886
9070
|
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
8887
|
-
const path =
|
|
9071
|
+
const path = resolve24(cwd, proofLocation);
|
|
8888
9072
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
8889
9073
|
const proof = createLintProof(command, { cwd, proofLocation });
|
|
8890
9074
|
if (options.signingKeyLocation) {
|
|
@@ -8940,12 +9124,12 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8940
9124
|
}, verifyLintProof = (command, options = {}) => {
|
|
8941
9125
|
const cwd = options.cwd ?? process.cwd();
|
|
8942
9126
|
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
8943
|
-
const path =
|
|
9127
|
+
const path = resolve24(cwd, proofLocation);
|
|
8944
9128
|
if (!existsSync14(path))
|
|
8945
9129
|
return { reason: `missing lint proof: ${proofLocation}`, valid: false };
|
|
8946
9130
|
let proof;
|
|
8947
9131
|
try {
|
|
8948
|
-
proof = JSON.parse(
|
|
9132
|
+
proof = JSON.parse(readFileSync18(path, "utf-8"));
|
|
8949
9133
|
} catch {
|
|
8950
9134
|
return { reason: `invalid lint proof: ${proofLocation}`, valid: false };
|
|
8951
9135
|
}
|
|
@@ -9110,8 +9294,8 @@ var exports_ls = {};
|
|
|
9110
9294
|
__export(exports_ls, {
|
|
9111
9295
|
runLs: () => runLs
|
|
9112
9296
|
});
|
|
9113
|
-
import { existsSync as existsSync16, readFileSync as
|
|
9114
|
-
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";
|
|
9115
9299
|
var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELDS, readStringField = (source, key) => {
|
|
9116
9300
|
const value = Reflect.get(source, key);
|
|
9117
9301
|
return typeof value === "string" ? value : undefined;
|
|
@@ -9126,24 +9310,24 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
9126
9310
|
} catch {
|
|
9127
9311
|
return null;
|
|
9128
9312
|
}
|
|
9129
|
-
}, relativeOrSelf = (target) =>
|
|
9313
|
+
}, relativeOrSelf = (target) => relative14(process.cwd(), target) || target, configCandidates = (raw) => isWorkspaceConfig(raw) ? Object.values(raw).map((service) => ({
|
|
9130
9314
|
baseDir: readStringField(service, "cwd") ?? ".",
|
|
9131
9315
|
source: service
|
|
9132
9316
|
})) : [{ baseDir: ".", source: raw }], specsFor = (source, baseDir) => FRAMEWORK_FIELDS.flatMap((framework) => {
|
|
9133
9317
|
const dir = readStringField(source, framework.field);
|
|
9134
9318
|
return dir === undefined ? [] : [
|
|
9135
9319
|
{
|
|
9136
|
-
dir:
|
|
9320
|
+
dir: join26(baseDir, dir),
|
|
9137
9321
|
label: framework.label,
|
|
9138
9322
|
pattern: framework.pattern
|
|
9139
9323
|
}
|
|
9140
9324
|
];
|
|
9141
9325
|
}), scanFramework = async (spec) => {
|
|
9142
|
-
const { pageFiles } = await scanConventions(
|
|
9326
|
+
const { pageFiles } = await scanConventions(join26(spec.dir, "pages"), spec.pattern);
|
|
9143
9327
|
if (pageFiles.length === 0)
|
|
9144
9328
|
return null;
|
|
9145
9329
|
const pages = pageFiles.map((file) => ({
|
|
9146
|
-
name: basename10(file,
|
|
9330
|
+
name: basename10(file, extname7(file)),
|
|
9147
9331
|
sizeBytes: null,
|
|
9148
9332
|
sourcePath: relativeOrSelf(file)
|
|
9149
9333
|
}));
|
|
@@ -9163,10 +9347,10 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
9163
9347
|
}, resolveDiskPath = (buildDir, value) => {
|
|
9164
9348
|
if (existsSync16(value))
|
|
9165
9349
|
return value;
|
|
9166
|
-
const underBuild =
|
|
9350
|
+
const underBuild = join26(buildDir, value);
|
|
9167
9351
|
if (existsSync16(underBuild))
|
|
9168
9352
|
return underBuild;
|
|
9169
|
-
return
|
|
9353
|
+
return join26(process.cwd(), value);
|
|
9170
9354
|
}, fileSize = (diskPath) => {
|
|
9171
9355
|
try {
|
|
9172
9356
|
return statSync(diskPath).size;
|
|
@@ -9174,7 +9358,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
9174
9358
|
return 0;
|
|
9175
9359
|
}
|
|
9176
9360
|
}, readManifestSizes = (manifestDir) => {
|
|
9177
|
-
const manifest = JSON.parse(
|
|
9361
|
+
const manifest = JSON.parse(readFileSync19(join26(manifestDir, "manifest.json"), "utf-8"));
|
|
9178
9362
|
const sizes = new Map;
|
|
9179
9363
|
Object.entries(manifest).forEach(([key, value]) => {
|
|
9180
9364
|
sizes.set(key, fileSize(resolveDiskPath(manifestDir, value)));
|
|
@@ -9193,7 +9377,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
9193
9377
|
}))
|
|
9194
9378
|
})), manifestAge = (manifestPath) => getDurationString(Date.now() - statSync(manifestPath).mtimeMs), firstBuildDir = (candidates) => candidates.map((candidate) => {
|
|
9195
9379
|
const dir = readStringField(candidate.source, "buildDirectory");
|
|
9196
|
-
return dir === undefined ? undefined :
|
|
9380
|
+
return dir === undefined ? undefined : join26(candidate.baseDir, dir);
|
|
9197
9381
|
}).find((dir) => dir !== undefined), resolveSizesDir = (args, candidates) => parseFlagValue(args, "--outdir") ?? firstBuildDir(candidates) ?? DEFAULT_BUILD_DIR, formatSize = (bytes) => {
|
|
9198
9382
|
if (bytes === null || bytes === 0)
|
|
9199
9383
|
return "-";
|
|
@@ -9291,7 +9475,7 @@ ${colors.dim}${frameworkCount} ${frameworkCount === 1 ? "framework" : "framework
|
|
|
9291
9475
|
return;
|
|
9292
9476
|
}
|
|
9293
9477
|
const sizesDir = resolveSizesDir(args, candidates);
|
|
9294
|
-
const manifestPath =
|
|
9478
|
+
const manifestPath = join26(sizesDir, "manifest.json");
|
|
9295
9479
|
if (!existsSync16(manifestPath)) {
|
|
9296
9480
|
printDim(`No build at ${relativeOrSelf(manifestPath)}. Run \`absolute build\` first, or pass \`--outdir <dir>\`.`);
|
|
9297
9481
|
return;
|
|
@@ -9416,21 +9600,21 @@ var init_discoverInstances = __esm(() => {
|
|
|
9416
9600
|
import { createConnection as createConnection2 } from "net";
|
|
9417
9601
|
var {$: $4 } = globalThis.Bun;
|
|
9418
9602
|
var displayHost = (host2) => host2 === "0.0.0.0" || host2 === "::" ? "localhost" : host2, probePort = (host2, port) => {
|
|
9419
|
-
const { promise, resolve:
|
|
9603
|
+
const { promise, resolve: resolve25 } = Promise.withResolvers();
|
|
9420
9604
|
const socket = createConnection2({ host: displayHost(host2), port });
|
|
9421
9605
|
const timeout = setTimeout(() => {
|
|
9422
9606
|
socket.destroy();
|
|
9423
|
-
|
|
9607
|
+
resolve25(false);
|
|
9424
9608
|
}, INSTANCE_PROBE_TIMEOUT_MS);
|
|
9425
9609
|
socket.once("connect", () => {
|
|
9426
9610
|
clearTimeout(timeout);
|
|
9427
9611
|
socket.end();
|
|
9428
|
-
|
|
9612
|
+
resolve25(true);
|
|
9429
9613
|
});
|
|
9430
9614
|
socket.once("error", () => {
|
|
9431
9615
|
clearTimeout(timeout);
|
|
9432
9616
|
socket.destroy();
|
|
9433
|
-
|
|
9617
|
+
resolve25(false);
|
|
9434
9618
|
});
|
|
9435
9619
|
return promise;
|
|
9436
9620
|
}, probeStatus = async (record) => {
|
|
@@ -9562,8 +9746,8 @@ var TUI_HEADERS, STATUS_INDEX = 8, URL_INDEX = 9, MEM_HISTORY_MAX = 12, SPARK_CH
|
|
|
9562
9746
|
render();
|
|
9563
9747
|
}, LIST_TUI_RENDER_DEBOUNCE_MS);
|
|
9564
9748
|
};
|
|
9565
|
-
const setStatus = (
|
|
9566
|
-
statusMessage = { level, text };
|
|
9749
|
+
const setStatus = (text2, level) => {
|
|
9750
|
+
statusMessage = { level, text: text2 };
|
|
9567
9751
|
if (statusTimer)
|
|
9568
9752
|
clearTimeout(statusTimer);
|
|
9569
9753
|
statusTimer = setTimeout(() => {
|
|
@@ -10142,9 +10326,9 @@ var exports_heapDiff = {};
|
|
|
10142
10326
|
__export(exports_heapDiff, {
|
|
10143
10327
|
runHeapDiff: () => runHeapDiff
|
|
10144
10328
|
});
|
|
10145
|
-
import { existsSync as existsSync17, readFileSync as
|
|
10329
|
+
import { existsSync as existsSync17, readFileSync as readFileSync20 } from "fs";
|
|
10146
10330
|
var TOP = 15, STRING_TYPES, aggregate = (path) => {
|
|
10147
|
-
const data = JSON.parse(
|
|
10331
|
+
const data = JSON.parse(readFileSync20(path, "utf-8"));
|
|
10148
10332
|
const { nodes, strings } = data;
|
|
10149
10333
|
const { node_fields: fields, node_types: nodeTypes } = data.snapshot.meta;
|
|
10150
10334
|
const [typeNames] = nodeTypes;
|
|
@@ -10292,31 +10476,31 @@ var init_mem = __esm(() => {
|
|
|
10292
10476
|
var isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10293
10477
|
|
|
10294
10478
|
// src/cli/config/schema/fromType.ts
|
|
10295
|
-
import
|
|
10479
|
+
import ts6 from "typescript";
|
|
10296
10480
|
import {
|
|
10297
10481
|
existsSync as existsSync18,
|
|
10298
10482
|
mkdirSync as mkdirSync9,
|
|
10299
|
-
readFileSync as
|
|
10483
|
+
readFileSync as readFileSync21,
|
|
10300
10484
|
statSync as statSync2,
|
|
10301
10485
|
writeFileSync as writeFileSync8
|
|
10302
10486
|
} from "fs";
|
|
10303
|
-
import { resolve as
|
|
10487
|
+
import { resolve as resolve25 } from "path";
|
|
10304
10488
|
var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFrameworkRepo = (cwd) => {
|
|
10305
10489
|
try {
|
|
10306
|
-
const pkg = JSON.parse(
|
|
10490
|
+
const pkg = JSON.parse(readFileSync21(resolve25(cwd, "package.json"), "utf-8"));
|
|
10307
10491
|
return pkg?.name === "@absolutejs/absolute";
|
|
10308
10492
|
} catch {
|
|
10309
10493
|
return false;
|
|
10310
10494
|
}
|
|
10311
10495
|
}, compilerOptionsFor = (cwd) => {
|
|
10312
|
-
const tsconfigPath =
|
|
10496
|
+
const tsconfigPath = ts6.findConfigFile(cwd, ts6.sys.fileExists, "tsconfig.json");
|
|
10313
10497
|
const parseConfigHost = {
|
|
10314
|
-
...
|
|
10498
|
+
...ts6.sys,
|
|
10315
10499
|
onUnRecoverableConfigFileDiagnostic: () => {}
|
|
10316
10500
|
};
|
|
10317
|
-
const base = tsconfigPath &&
|
|
10501
|
+
const base = tsconfigPath && ts6.getParsedCommandLineOfConfigFile(tsconfigPath, {}, parseConfigHost)?.options;
|
|
10318
10502
|
return {
|
|
10319
|
-
...base ??
|
|
10503
|
+
...base ?? ts6.getDefaultCompilerOptions(),
|
|
10320
10504
|
noEmit: true,
|
|
10321
10505
|
skipDefaultLibCheck: true,
|
|
10322
10506
|
skipLibCheck: true,
|
|
@@ -10324,14 +10508,14 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10324
10508
|
};
|
|
10325
10509
|
}, SCHEMA_VERSION = 1, packageVersion = (cwd, specifier) => {
|
|
10326
10510
|
const candidates = specifier === "@absolutejs/absolute" ? [
|
|
10327
|
-
|
|
10328
|
-
|
|
10511
|
+
resolve25(cwd, "node_modules", "@absolutejs", "absolute", "package.json"),
|
|
10512
|
+
resolve25(cwd, "package.json")
|
|
10329
10513
|
] : [
|
|
10330
|
-
|
|
10514
|
+
resolve25(cwd, "node_modules", ...specifier.split("/"), "package.json")
|
|
10331
10515
|
];
|
|
10332
10516
|
for (const candidate of candidates) {
|
|
10333
10517
|
try {
|
|
10334
|
-
const { version: version2 } = JSON.parse(
|
|
10518
|
+
const { version: version2 } = JSON.parse(readFileSync21(candidate, "utf-8"));
|
|
10335
10519
|
if (typeof version2 === "string")
|
|
10336
10520
|
return version2;
|
|
10337
10521
|
} catch {}
|
|
@@ -10342,16 +10526,16 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10342
10526
|
if (local) {
|
|
10343
10527
|
const file = typeName === "PackageJson" ? "packageJson.ts" : "build.ts";
|
|
10344
10528
|
try {
|
|
10345
|
-
signature += `:${statSync2(
|
|
10529
|
+
signature += `:${statSync2(resolve25(cwd, "types", file)).mtimeMs}`;
|
|
10346
10530
|
} catch {}
|
|
10347
10531
|
}
|
|
10348
10532
|
return signature;
|
|
10349
10533
|
}, cacheSlug = (specifier) => specifier.replace("@", "").split("/").join("-"), cacheFile = (cwd, typeName, specifier) => {
|
|
10350
10534
|
const name = specifier === "@absolutejs/absolute" ? typeName : `${typeName}.${cacheSlug(specifier)}`;
|
|
10351
|
-
return
|
|
10535
|
+
return resolve25(cwd, ".absolutejs", "config-schema", `${name}.json`);
|
|
10352
10536
|
}, readDiskCache = (cwd, typeName, signature, specifier) => {
|
|
10353
10537
|
try {
|
|
10354
|
-
const cached = JSON.parse(
|
|
10538
|
+
const cached = JSON.parse(readFileSync21(cacheFile(cwd, typeName, specifier), "utf-8"));
|
|
10355
10539
|
if (isRecord9(cached) && cached.signature === signature && Array.isArray(cached.fields)) {
|
|
10356
10540
|
return cached.fields;
|
|
10357
10541
|
}
|
|
@@ -10359,12 +10543,12 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10359
10543
|
return null;
|
|
10360
10544
|
}, writeDiskCache = (cwd, typeName, signature, fields, specifier) => {
|
|
10361
10545
|
try {
|
|
10362
|
-
mkdirSync9(
|
|
10546
|
+
mkdirSync9(resolve25(cwd, ".absolutejs", "config-schema"), {
|
|
10363
10547
|
recursive: true
|
|
10364
10548
|
});
|
|
10365
10549
|
writeFileSync8(cacheFile(cwd, typeName, specifier), JSON.stringify({ fields, signature }));
|
|
10366
10550
|
} catch {}
|
|
10367
|
-
}, docOf = (symbol, checker) =>
|
|
10551
|
+
}, docOf = (symbol, checker) => ts6.displayPartsToString(symbol.getDocumentationComment(checker)).trim(), typeOfSymbol = (symbol, checker) => {
|
|
10368
10552
|
const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
10369
10553
|
return declaration ? checker.getTypeOfSymbolAtLocation(symbol, declaration) : checker.getDeclaredTypeOfSymbol(symbol);
|
|
10370
10554
|
}, hasFlag = (type, flag) => (type.flags & flag) !== 0, unionParts = (type) => type.isUnion() ? type.types : [type], literalChoice = (type) => {
|
|
@@ -10380,10 +10564,10 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10380
10564
|
});
|
|
10381
10565
|
if (depth > MAX_DEPTH)
|
|
10382
10566
|
return opaque();
|
|
10383
|
-
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));
|
|
10384
10568
|
if (parts.length === 0)
|
|
10385
10569
|
return opaque();
|
|
10386
|
-
if (parts.every((part) => hasFlag(part,
|
|
10570
|
+
if (parts.every((part) => hasFlag(part, ts6.TypeFlags.BooleanLike))) {
|
|
10387
10571
|
return { kind: "boolean" };
|
|
10388
10572
|
}
|
|
10389
10573
|
const choices = parts.map(literalChoice);
|
|
@@ -10403,13 +10587,13 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10403
10587
|
kind: "opaque",
|
|
10404
10588
|
typeText: checker.typeToString(type)
|
|
10405
10589
|
});
|
|
10406
|
-
if (hasFlag(type,
|
|
10590
|
+
if (hasFlag(type, ts6.TypeFlags.BooleanLike))
|
|
10407
10591
|
return { kind: "boolean" };
|
|
10408
|
-
if (hasFlag(type,
|
|
10592
|
+
if (hasFlag(type, ts6.TypeFlags.NumberLike))
|
|
10409
10593
|
return { kind: "number" };
|
|
10410
|
-
if (hasFlag(type,
|
|
10594
|
+
if (hasFlag(type, ts6.TypeFlags.StringLike))
|
|
10411
10595
|
return { kind: "string" };
|
|
10412
|
-
if (!hasFlag(type,
|
|
10596
|
+
if (!hasFlag(type, ts6.TypeFlags.Object))
|
|
10413
10597
|
return opaque();
|
|
10414
10598
|
if (type.getCallSignatures().length > 0)
|
|
10415
10599
|
return opaque();
|
|
@@ -10430,7 +10614,7 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10430
10614
|
const fields = props.map((symbol) => ({
|
|
10431
10615
|
description: docOf(symbol, checker),
|
|
10432
10616
|
name: symbol.getName(),
|
|
10433
|
-
optional: (symbol.flags &
|
|
10617
|
+
optional: (symbol.flags & ts6.SymbolFlags.Optional) !== 0,
|
|
10434
10618
|
schema: toSchema(typeOfSymbol(symbol, checker), checker, depth + 1, seen)
|
|
10435
10619
|
}));
|
|
10436
10620
|
return { fields, kind: "object" };
|
|
@@ -10446,26 +10630,26 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10446
10630
|
}
|
|
10447
10631
|
return opaque();
|
|
10448
10632
|
}, introspectFrom = (cwd, specifier, typeName, options, exclude) => {
|
|
10449
|
-
const virtualPath =
|
|
10633
|
+
const virtualPath = resolve25(cwd, VIRTUAL_NAME);
|
|
10450
10634
|
const source = `import type { ${typeName} } from '${specifier}';
|
|
10451
10635
|
declare const value: ${typeName};
|
|
10452
10636
|
export { value };
|
|
10453
10637
|
`;
|
|
10454
|
-
const host2 =
|
|
10638
|
+
const host2 = ts6.createCompilerHost(options, true);
|
|
10455
10639
|
const getSourceFile = host2.getSourceFile.bind(host2);
|
|
10456
|
-
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);
|
|
10457
10641
|
const fileExists = host2.fileExists.bind(host2);
|
|
10458
10642
|
host2.fileExists = (fileName) => fileName === virtualPath ? true : fileExists(fileName);
|
|
10459
10643
|
const readFile11 = host2.readFile.bind(host2);
|
|
10460
10644
|
host2.readFile = (fileName) => fileName === virtualPath ? source : readFile11(fileName);
|
|
10461
|
-
const program =
|
|
10645
|
+
const program = ts6.createProgram([virtualPath], options, host2);
|
|
10462
10646
|
const checker = program.getTypeChecker();
|
|
10463
10647
|
const sourceFile = program.getSourceFile(virtualPath);
|
|
10464
10648
|
if (!sourceFile)
|
|
10465
10649
|
return [];
|
|
10466
10650
|
const nodes = [];
|
|
10467
10651
|
sourceFile.forEachChild((node) => {
|
|
10468
|
-
if (!
|
|
10652
|
+
if (!ts6.isVariableStatement(node))
|
|
10469
10653
|
return;
|
|
10470
10654
|
const [declaration] = node.declarationList.declarations;
|
|
10471
10655
|
if (!declaration)
|
|
@@ -10478,7 +10662,7 @@ export { value };
|
|
|
10478
10662
|
nodes.push({
|
|
10479
10663
|
description: docOf(symbol, checker),
|
|
10480
10664
|
name,
|
|
10481
|
-
optional: (symbol.flags &
|
|
10665
|
+
optional: (symbol.flags & ts6.SymbolFlags.Optional) !== 0,
|
|
10482
10666
|
schema: toSchema(typeOfSymbol(symbol, checker), checker, 1, new Set)
|
|
10483
10667
|
});
|
|
10484
10668
|
}
|
|
@@ -10489,7 +10673,7 @@ export { value };
|
|
|
10489
10673
|
const cached = cache.get(cacheKey);
|
|
10490
10674
|
if (cached)
|
|
10491
10675
|
return cached;
|
|
10492
|
-
const local = specifier === "@absolutejs/absolute" && isFrameworkRepo(cwd) && existsSync18(
|
|
10676
|
+
const local = specifier === "@absolutejs/absolute" && isFrameworkRepo(cwd) && existsSync18(resolve25(cwd, "types/index.ts"));
|
|
10493
10677
|
const signature = cacheSignature(cwd, typeName, local, specifier);
|
|
10494
10678
|
const fromDisk = readDiskCache(cwd, typeName, signature, specifier);
|
|
10495
10679
|
if (fromDisk) {
|
|
@@ -10516,59 +10700,59 @@ var init_fromType = __esm(() => {
|
|
|
10516
10700
|
});
|
|
10517
10701
|
|
|
10518
10702
|
// src/cli/config/absolute/resolveAbsoluteConfig.ts
|
|
10519
|
-
import
|
|
10520
|
-
import { existsSync as existsSync19, readFileSync as
|
|
10521
|
-
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";
|
|
10522
10706
|
var CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath = (cwd, override) => {
|
|
10523
10707
|
if (override) {
|
|
10524
|
-
const resolved =
|
|
10708
|
+
const resolved = resolve26(cwd, override);
|
|
10525
10709
|
return existsSync19(resolved) ? resolved : null;
|
|
10526
10710
|
}
|
|
10527
10711
|
for (const name of CONFIG_CANDIDATES2) {
|
|
10528
|
-
const candidate =
|
|
10712
|
+
const candidate = resolve26(cwd, name);
|
|
10529
10713
|
if (existsSync19(candidate))
|
|
10530
10714
|
return candidate;
|
|
10531
10715
|
}
|
|
10532
10716
|
return null;
|
|
10533
|
-
}, parseSource = (configPath2,
|
|
10717
|
+
}, parseSource = (configPath2, text2) => ts7.createSourceFile(configPath2, text2, ts7.ScriptTarget.Latest, true), findConfigObject = (sourceFile) => {
|
|
10534
10718
|
const pending = [sourceFile];
|
|
10535
10719
|
while (pending.length > 0) {
|
|
10536
10720
|
const node = pending.pop();
|
|
10537
10721
|
if (!node)
|
|
10538
10722
|
continue;
|
|
10539
|
-
const [firstArgument] =
|
|
10540
|
-
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)) {
|
|
10541
10725
|
return firstArgument;
|
|
10542
10726
|
}
|
|
10543
|
-
if (
|
|
10727
|
+
if (ts7.isExportAssignment(node) && ts7.isObjectLiteralExpression(node.expression)) {
|
|
10544
10728
|
return node.expression;
|
|
10545
10729
|
}
|
|
10546
10730
|
node.forEachChild((child) => pending.push(child));
|
|
10547
10731
|
}
|
|
10548
10732
|
return null;
|
|
10549
10733
|
}, parseConfigObject = (configPath2) => {
|
|
10550
|
-
const
|
|
10551
|
-
return { object: findConfigObject(parseSource(configPath2,
|
|
10734
|
+
const text2 = readFileSync22(configPath2, "utf-8");
|
|
10735
|
+
return { object: findConfigObject(parseSource(configPath2, text2)), text: text2 };
|
|
10552
10736
|
}, evalLiteral = (node) => {
|
|
10553
|
-
if (
|
|
10737
|
+
if (ts7.isStringLiteralLike(node)) {
|
|
10554
10738
|
return { opaque: false, value: node.text };
|
|
10555
10739
|
}
|
|
10556
|
-
if (node.kind ===
|
|
10740
|
+
if (node.kind === ts7.SyntaxKind.TrueKeyword) {
|
|
10557
10741
|
return { opaque: false, value: true };
|
|
10558
10742
|
}
|
|
10559
|
-
if (node.kind ===
|
|
10743
|
+
if (node.kind === ts7.SyntaxKind.FalseKeyword) {
|
|
10560
10744
|
return { opaque: false, value: false };
|
|
10561
10745
|
}
|
|
10562
|
-
if (node.kind ===
|
|
10746
|
+
if (node.kind === ts7.SyntaxKind.NullKeyword) {
|
|
10563
10747
|
return { opaque: false, value: null };
|
|
10564
10748
|
}
|
|
10565
|
-
if (
|
|
10749
|
+
if (ts7.isNumericLiteral(node)) {
|
|
10566
10750
|
return { opaque: false, value: Number(node.text) };
|
|
10567
10751
|
}
|
|
10568
|
-
if (
|
|
10752
|
+
if (ts7.isPrefixUnaryExpression(node) && node.operator === ts7.SyntaxKind.MinusToken && ts7.isNumericLiteral(node.operand)) {
|
|
10569
10753
|
return { opaque: false, value: -Number(node.operand.text) };
|
|
10570
10754
|
}
|
|
10571
|
-
if (
|
|
10755
|
+
if (ts7.isArrayLiteralExpression(node)) {
|
|
10572
10756
|
const items = [];
|
|
10573
10757
|
for (const element of node.elements) {
|
|
10574
10758
|
const result = evalLiteral(element);
|
|
@@ -10578,28 +10762,28 @@ var CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath = (cwd, override) => {
|
|
|
10578
10762
|
}
|
|
10579
10763
|
return { opaque: false, value: items };
|
|
10580
10764
|
}
|
|
10581
|
-
if (
|
|
10582
|
-
const
|
|
10765
|
+
if (ts7.isObjectLiteralExpression(node)) {
|
|
10766
|
+
const object3 = {};
|
|
10583
10767
|
for (const property of node.properties) {
|
|
10584
|
-
if (!
|
|
10768
|
+
if (!ts7.isPropertyAssignment(property) || !(ts7.isIdentifier(property.name) || ts7.isStringLiteral(property.name))) {
|
|
10585
10769
|
return { opaque: true, value: undefined };
|
|
10586
10770
|
}
|
|
10587
10771
|
const result = evalLiteral(property.initializer);
|
|
10588
10772
|
if (result.opaque)
|
|
10589
10773
|
return { opaque: true, value: undefined };
|
|
10590
|
-
|
|
10774
|
+
object3[property.name.text] = result.value;
|
|
10591
10775
|
}
|
|
10592
|
-
return { opaque: false, value:
|
|
10776
|
+
return { opaque: false, value: object3 };
|
|
10593
10777
|
}
|
|
10594
10778
|
return { opaque: true, value: undefined };
|
|
10595
10779
|
}, readCurrent = (configPath2) => {
|
|
10596
10780
|
const current = {};
|
|
10597
10781
|
const opaqueKeys = [];
|
|
10598
|
-
const { object:
|
|
10599
|
-
if (!
|
|
10782
|
+
const { object: object3 } = parseConfigObject(configPath2);
|
|
10783
|
+
if (!object3)
|
|
10600
10784
|
return { current, opaqueKeys };
|
|
10601
|
-
for (const property of
|
|
10602
|
-
if (!
|
|
10785
|
+
for (const property of object3.properties) {
|
|
10786
|
+
if (!ts7.isPropertyAssignment(property) || !(ts7.isIdentifier(property.name) || ts7.isStringLiteral(property.name))) {
|
|
10603
10787
|
continue;
|
|
10604
10788
|
}
|
|
10605
10789
|
const name = property.name.text;
|
|
@@ -10758,8 +10942,8 @@ var init_frameworks = __esm(() => {
|
|
|
10758
10942
|
});
|
|
10759
10943
|
|
|
10760
10944
|
// src/cli/generate/context.ts
|
|
10761
|
-
import { dirname as dirname16, isAbsolute as isAbsolute5, join as
|
|
10762
|
-
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) => {
|
|
10763
10947
|
const styles = config.stylesConfig;
|
|
10764
10948
|
if (typeof styles === "string")
|
|
10765
10949
|
return resolveDir(cwd, styles);
|
|
@@ -10768,10 +10952,10 @@ var asString = (value) => typeof value === "string" ? value : undefined, isRecor
|
|
|
10768
10952
|
if (indexes)
|
|
10769
10953
|
return resolveDir(cwd, indexes);
|
|
10770
10954
|
}
|
|
10771
|
-
return
|
|
10955
|
+
return resolve27(cwd, "src/frontend/styles/indexes");
|
|
10772
10956
|
}, configuredFrameworks = (project) => FRAMEWORK_KEYS2.filter((key) => project.frameworkDirs[key] !== undefined), frontendRootFor = (project, framework) => {
|
|
10773
10957
|
const dir = project.frameworkDirs[framework];
|
|
10774
|
-
return dir ? dirname16(dir) :
|
|
10958
|
+
return dir ? dirname16(dir) : resolve27(project.cwd, "src/frontend");
|
|
10775
10959
|
}, resolveProject = async (cwd, configOverride) => {
|
|
10776
10960
|
const loaded = await loadConfig(configOverride);
|
|
10777
10961
|
const config = isRecord10(loaded) ? loaded : {};
|
|
@@ -10821,8 +11005,8 @@ var asString = (value) => typeof value === "string" ? value : undefined, isRecor
|
|
|
10821
11005
|
message: `Multiple frameworks configured (${configured.join(", ")}). Pass --framework <name>.`,
|
|
10822
11006
|
ok: false
|
|
10823
11007
|
};
|
|
10824
|
-
}, sharedDirFor = (project, framework) =>
|
|
10825
|
-
const rel =
|
|
11008
|
+
}, sharedDirFor = (project, framework) => join27(frontendRootFor(project, framework), "shared"), toModuleSpecifier = (fromDir, toFileNoExt) => {
|
|
11009
|
+
const rel = relative15(fromDir, toFileNoExt).split("\\").join("/");
|
|
10826
11010
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
10827
11011
|
};
|
|
10828
11012
|
var init_context = __esm(() => {
|
|
@@ -10849,78 +11033,78 @@ var emptyOutcome = () => ({
|
|
|
10849
11033
|
});
|
|
10850
11034
|
|
|
10851
11035
|
// src/cli/generate/routeWiring.ts
|
|
10852
|
-
import
|
|
10853
|
-
import { existsSync as existsSync20, readFileSync as
|
|
10854
|
-
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";
|
|
10855
11039
|
var DEFAULT_SEPARATOR = `
|
|
10856
|
-
`, BOUNDARY_USE, applyEdits = (
|
|
11040
|
+
`, BOUNDARY_USE, applyEdits = (text2, edits) => {
|
|
10857
11041
|
const ordered = [...edits].sort((first, second) => second.start - first.start);
|
|
10858
|
-
let output =
|
|
11042
|
+
let output = text2;
|
|
10859
11043
|
for (const edit of ordered) {
|
|
10860
11044
|
output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);
|
|
10861
11045
|
}
|
|
10862
11046
|
return output;
|
|
10863
|
-
}, stripExtension = (path) => path.replace(/\.[^./\\]+$/, ""), parse2 = (path,
|
|
11047
|
+
}, stripExtension = (path) => path.replace(/\.[^./\\]+$/, ""), parse2 = (path, text2) => ts8.createSourceFile(path, text2, ts8.ScriptTarget.Latest, true), findElysiaNew = (sourceFile) => {
|
|
10864
11048
|
let found = null;
|
|
10865
11049
|
const visit = (node) => {
|
|
10866
11050
|
if (found)
|
|
10867
11051
|
return;
|
|
10868
|
-
if (
|
|
11052
|
+
if (ts8.isNewExpression(node) && ts8.isIdentifier(node.expression) && node.expression.text === "Elysia") {
|
|
10869
11053
|
found = node;
|
|
10870
11054
|
return;
|
|
10871
11055
|
}
|
|
10872
|
-
|
|
11056
|
+
ts8.forEachChild(node, visit);
|
|
10873
11057
|
};
|
|
10874
11058
|
visit(sourceFile);
|
|
10875
11059
|
return found;
|
|
10876
11060
|
}, climbChain = (start2) => {
|
|
10877
11061
|
let top = start2;
|
|
10878
|
-
while (
|
|
11062
|
+
while (ts8.isPropertyAccessExpression(top.parent) && top.parent.expression === top && ts8.isCallExpression(top.parent.parent) && top.parent.parent.expression === top.parent) {
|
|
10879
11063
|
top = top.parent.parent;
|
|
10880
11064
|
}
|
|
10881
11065
|
return top;
|
|
10882
11066
|
}, collectCalls = (top) => {
|
|
10883
11067
|
const calls = [];
|
|
10884
11068
|
let node = top;
|
|
10885
|
-
while (
|
|
11069
|
+
while (ts8.isCallExpression(node) && ts8.isPropertyAccessExpression(node.expression)) {
|
|
10886
11070
|
calls.push(node);
|
|
10887
11071
|
node = node.expression.expression;
|
|
10888
11072
|
}
|
|
10889
11073
|
return calls.reverse();
|
|
10890
|
-
}, methodName = (call) =>
|
|
11074
|
+
}, methodName = (call) => ts8.isPropertyAccessExpression(call.expression) ? call.expression.name.text : null, isBoundary = (call) => {
|
|
10891
11075
|
const name = methodName(call);
|
|
10892
11076
|
const [arg] = call.arguments;
|
|
10893
|
-
if (name === "use" && arg &&
|
|
11077
|
+
if (name === "use" && arg && ts8.isIdentifier(arg)) {
|
|
10894
11078
|
return BOUNDARY_USE.has(arg.text);
|
|
10895
11079
|
}
|
|
10896
|
-
return name === "on" && arg !== undefined &&
|
|
10897
|
-
}, receiverEnd = (call) =>
|
|
10898
|
-
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]*)\./);
|
|
10899
11083
|
return match ? match[1] : DEFAULT_SEPARATOR;
|
|
10900
|
-
}, findRouteInsertion = (
|
|
11084
|
+
}, findRouteInsertion = (text2, top) => {
|
|
10901
11085
|
const calls = collectCalls(top);
|
|
10902
11086
|
const boundary = calls.find(isBoundary);
|
|
10903
11087
|
if (boundary) {
|
|
10904
11088
|
const offset2 = receiverEnd(boundary);
|
|
10905
|
-
return { offset: offset2, separator: separatorBefore(
|
|
11089
|
+
return { offset: offset2, separator: separatorBefore(text2, offset2) };
|
|
10906
11090
|
}
|
|
10907
11091
|
const last = calls[calls.length - 1];
|
|
10908
11092
|
const offset = last ? last.getEnd() : top.getEnd();
|
|
10909
11093
|
const sepProbe = last ? receiverEnd(last) : top.getEnd();
|
|
10910
|
-
return { offset, separator: separatorBefore(
|
|
10911
|
-
}, 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) => {
|
|
10912
11096
|
const bindings = decl.importClause?.namedBindings;
|
|
10913
|
-
if (!bindings || !
|
|
11097
|
+
if (!bindings || !ts8.isNamedImports(bindings))
|
|
10914
11098
|
return new Set;
|
|
10915
11099
|
return new Set(bindings.elements.map((element) => (element.propertyName ?? element.name).text));
|
|
10916
11100
|
}, lastImportEnd = (sourceFile) => {
|
|
10917
11101
|
let end = 0;
|
|
10918
11102
|
for (const statement of sourceFile.statements) {
|
|
10919
|
-
if (
|
|
11103
|
+
if (ts8.isImportDeclaration(statement))
|
|
10920
11104
|
end = statement.getEnd();
|
|
10921
11105
|
}
|
|
10922
11106
|
return end;
|
|
10923
|
-
}, 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) => {
|
|
10924
11108
|
if (spec.kind === "typeDefault") {
|
|
10925
11109
|
return `import type ${spec.local} from '${spec.module}';`;
|
|
10926
11110
|
}
|
|
@@ -10940,7 +11124,7 @@ var DEFAULT_SEPARATOR = `
|
|
|
10940
11124
|
return byModule;
|
|
10941
11125
|
}, mergeNamedEdit = (decl, sourceFile, missing) => {
|
|
10942
11126
|
const bindings = decl.importClause?.namedBindings;
|
|
10943
|
-
if (!bindings || !
|
|
11127
|
+
if (!bindings || !ts8.isNamedImports(bindings))
|
|
10944
11128
|
return null;
|
|
10945
11129
|
const { elements } = bindings;
|
|
10946
11130
|
const additions = missing.join(", ");
|
|
@@ -11001,7 +11185,7 @@ ${newLines.join(`
|
|
|
11001
11185
|
}, hasChain = (path) => {
|
|
11002
11186
|
if (!existsSync20(path))
|
|
11003
11187
|
return false;
|
|
11004
|
-
const sourceFile = parse2(path,
|
|
11188
|
+
const sourceFile = parse2(path, readFileSync23(path, "utf-8"));
|
|
11005
11189
|
const found = findElysiaNew(sourceFile);
|
|
11006
11190
|
return found !== null;
|
|
11007
11191
|
}, firstChainFile = (pluginsDir) => {
|
|
@@ -11010,14 +11194,14 @@ ${newLines.join(`
|
|
|
11010
11194
|
for (const name of readdirSync4(pluginsDir)) {
|
|
11011
11195
|
if (!name.endsWith(".ts"))
|
|
11012
11196
|
continue;
|
|
11013
|
-
const candidate =
|
|
11197
|
+
const candidate = join28(pluginsDir, name);
|
|
11014
11198
|
if (hasChain(candidate))
|
|
11015
11199
|
return candidate;
|
|
11016
11200
|
}
|
|
11017
11201
|
return null;
|
|
11018
11202
|
}, findRoutingFile = (serverEntry) => {
|
|
11019
|
-
const pluginsDir =
|
|
11020
|
-
const preferred =
|
|
11203
|
+
const pluginsDir = join28(dirname17(serverEntry), "plugins");
|
|
11204
|
+
const preferred = join28(pluginsDir, "pagesPlugin.ts");
|
|
11021
11205
|
if (hasChain(preferred))
|
|
11022
11206
|
return preferred;
|
|
11023
11207
|
const scanned = firstChainFile(pluginsDir);
|
|
@@ -11050,20 +11234,20 @@ ${newLines.join(`
|
|
|
11050
11234
|
};
|
|
11051
11235
|
if (!hasChain(serverEntry))
|
|
11052
11236
|
return fallback;
|
|
11053
|
-
const
|
|
11054
|
-
const sourceFile = parse2(serverEntry,
|
|
11237
|
+
const text2 = readFileSync23(serverEntry, "utf-8");
|
|
11238
|
+
const sourceFile = parse2(serverEntry, text2);
|
|
11055
11239
|
const newExpr = findElysiaNew(sourceFile);
|
|
11056
11240
|
if (!newExpr)
|
|
11057
11241
|
return fallback;
|
|
11058
11242
|
const top = climbChain(newExpr);
|
|
11059
|
-
const { offset, separator } = findRouteInsertion(
|
|
11243
|
+
const { offset, separator } = findRouteInsertion(text2, top);
|
|
11060
11244
|
const edits = buildImportEdits(sourceFile, specs);
|
|
11061
11245
|
edits.push({
|
|
11062
11246
|
end: offset,
|
|
11063
11247
|
start: offset,
|
|
11064
11248
|
text: `${separator}.use(${pluginName})`
|
|
11065
11249
|
});
|
|
11066
|
-
writeFileSync9(serverEntry, applyEdits(
|
|
11250
|
+
writeFileSync9(serverEntry, applyEdits(text2, edits), "utf-8");
|
|
11067
11251
|
return { kind: "edited", routingFile: serverEntry };
|
|
11068
11252
|
}, wireRoute = (input) => {
|
|
11069
11253
|
const routingFile = findRoutingFile(input.serverEntry);
|
|
@@ -11079,8 +11263,8 @@ ${newLines.join(`
|
|
|
11079
11263
|
${routeExpr}`
|
|
11080
11264
|
};
|
|
11081
11265
|
}
|
|
11082
|
-
const
|
|
11083
|
-
const sourceFile = parse2(routingFile,
|
|
11266
|
+
const text2 = readFileSync23(routingFile, "utf-8");
|
|
11267
|
+
const sourceFile = parse2(routingFile, text2);
|
|
11084
11268
|
const newExpr = findElysiaNew(sourceFile);
|
|
11085
11269
|
if (!newExpr) {
|
|
11086
11270
|
return {
|
|
@@ -11092,14 +11276,14 @@ ${routeExpr}`
|
|
|
11092
11276
|
};
|
|
11093
11277
|
}
|
|
11094
11278
|
const top = climbChain(newExpr);
|
|
11095
|
-
const { offset, separator } = findRouteInsertion(
|
|
11279
|
+
const { offset, separator } = findRouteInsertion(text2, top);
|
|
11096
11280
|
const edits = buildImportEdits(sourceFile, specs);
|
|
11097
11281
|
edits.push({
|
|
11098
11282
|
end: offset,
|
|
11099
11283
|
start: offset,
|
|
11100
11284
|
text: `${separator}${routeExpr}`
|
|
11101
11285
|
});
|
|
11102
|
-
writeFileSync9(routingFile, applyEdits(
|
|
11286
|
+
writeFileSync9(routingFile, applyEdits(text2, edits), "utf-8");
|
|
11103
11287
|
return { kind: "edited", routingFile };
|
|
11104
11288
|
};
|
|
11105
11289
|
var init_routeWiring = __esm(() => {
|
|
@@ -11109,7 +11293,7 @@ var init_routeWiring = __esm(() => {
|
|
|
11109
11293
|
|
|
11110
11294
|
// src/cli/generate/generateApi.ts
|
|
11111
11295
|
import { existsSync as existsSync21, mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
11112
|
-
import { dirname as dirname18, join as
|
|
11296
|
+
import { dirname as dirname18, join as join29 } from "path";
|
|
11113
11297
|
var apiPluginTemplate = (pluginName, base) => `import { Elysia } from 'elysia';
|
|
11114
11298
|
|
|
11115
11299
|
export const ${pluginName} = new Elysia()
|
|
@@ -11121,8 +11305,8 @@ export const ${pluginName} = new Elysia()
|
|
|
11121
11305
|
const pluginName = `${camel}Plugin`;
|
|
11122
11306
|
const base = `/api/${kebab}`;
|
|
11123
11307
|
const outcome = { ...emptyOutcome(), route: base };
|
|
11124
|
-
const pluginsDir =
|
|
11125
|
-
const fileAbs =
|
|
11308
|
+
const pluginsDir = join29(dirname18(project.serverEntry), "plugins");
|
|
11309
|
+
const fileAbs = join29(pluginsDir, `${pluginName}.ts`);
|
|
11126
11310
|
if (existsSync21(fileAbs)) {
|
|
11127
11311
|
outcome.notes.push(`${pluginName} already exists at ${fileAbs} \u2014 skipped.`);
|
|
11128
11312
|
return outcome;
|
|
@@ -11197,7 +11381,7 @@ var init_componentTemplates = __esm(() => {
|
|
|
11197
11381
|
|
|
11198
11382
|
// src/cli/generate/generateComponent.ts
|
|
11199
11383
|
import { existsSync as existsSync22, mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "fs";
|
|
11200
|
-
import { dirname as dirname19, join as
|
|
11384
|
+
import { dirname as dirname19, join as join30 } from "path";
|
|
11201
11385
|
var generateComponent = (project, framework, rawName) => {
|
|
11202
11386
|
const def = frameworks6[framework];
|
|
11203
11387
|
const pascal = toPascalCase(rawName);
|
|
@@ -11208,7 +11392,7 @@ var generateComponent = (project, framework, rawName) => {
|
|
|
11208
11392
|
outcome.manual = { reason: "framework directory missing", snippet: "" };
|
|
11209
11393
|
return outcome;
|
|
11210
11394
|
}
|
|
11211
|
-
const fileAbs =
|
|
11395
|
+
const fileAbs = join30(frameworkDir, "components", def.componentFile({ kebab, pascal }));
|
|
11212
11396
|
if (existsSync22(fileAbs)) {
|
|
11213
11397
|
outcome.notes.push(`${pascal} already exists at ${fileAbs} \u2014 skipped.`);
|
|
11214
11398
|
return outcome;
|
|
@@ -11228,36 +11412,36 @@ var init_generateComponent = __esm(() => {
|
|
|
11228
11412
|
});
|
|
11229
11413
|
|
|
11230
11414
|
// src/cli/generate/cssStrategy.ts
|
|
11231
|
-
import
|
|
11415
|
+
import ts9 from "typescript";
|
|
11232
11416
|
import { existsSync as existsSync23 } from "fs";
|
|
11233
|
-
import { join as
|
|
11417
|
+
import { join as join31 } from "path";
|
|
11234
11418
|
var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
11235
11419
|
margin: 0 auto;
|
|
11236
11420
|
max-width: 64rem;
|
|
11237
11421
|
padding: 2rem;
|
|
11238
11422
|
}
|
|
11239
11423
|
`, cssAssetArg = (node) => {
|
|
11240
|
-
if (!
|
|
11424
|
+
if (!ts9.isCallExpression(node) || !ts9.isIdentifier(node.expression) || node.expression.text !== "asset") {
|
|
11241
11425
|
return null;
|
|
11242
11426
|
}
|
|
11243
11427
|
const [, arg] = node.arguments;
|
|
11244
|
-
if (arg &&
|
|
11428
|
+
if (arg && ts9.isStringLiteralLike(arg) && arg.text.endsWith(CSS_SUFFIX)) {
|
|
11245
11429
|
return arg.text;
|
|
11246
11430
|
}
|
|
11247
11431
|
return null;
|
|
11248
11432
|
}, detectSharedKey = (routingText) => {
|
|
11249
|
-
const sourceFile =
|
|
11433
|
+
const sourceFile = ts9.createSourceFile("routing.ts", routingText, ts9.ScriptTarget.Latest, true);
|
|
11250
11434
|
let hoisted = null;
|
|
11251
11435
|
const inlineCounts = new Map;
|
|
11252
11436
|
const visit = (node) => {
|
|
11253
11437
|
const key = cssAssetArg(node);
|
|
11254
11438
|
if (key) {
|
|
11255
|
-
if (
|
|
11439
|
+
if (ts9.isVariableDeclaration(node.parent))
|
|
11256
11440
|
hoisted ??= key;
|
|
11257
11441
|
else
|
|
11258
11442
|
inlineCounts.set(key, (inlineCounts.get(key) ?? 0) + 1);
|
|
11259
11443
|
}
|
|
11260
|
-
|
|
11444
|
+
ts9.forEachChild(node, visit);
|
|
11261
11445
|
};
|
|
11262
11446
|
visit(sourceFile);
|
|
11263
11447
|
if (hoisted)
|
|
@@ -11269,7 +11453,7 @@ var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
|
11269
11453
|
return null;
|
|
11270
11454
|
}, fileForKey = (stylesDir, assetKey2) => {
|
|
11271
11455
|
const base = assetKey2.endsWith(CSS_SUFFIX) ? assetKey2.slice(0, -CSS_SUFFIX.length) : assetKey2;
|
|
11272
|
-
return
|
|
11456
|
+
return join31(stylesDir, `${toKebabCase(base)}.css`);
|
|
11273
11457
|
}, planCss = (routingText, stylesDir, pascal, kebab) => {
|
|
11274
11458
|
const sharedKey = detectSharedKey(routingText);
|
|
11275
11459
|
if (sharedKey) {
|
|
@@ -11282,7 +11466,7 @@ var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
|
11282
11466
|
shared: true
|
|
11283
11467
|
};
|
|
11284
11468
|
}
|
|
11285
|
-
const cssFileAbs =
|
|
11469
|
+
const cssFileAbs = join31(stylesDir, `${kebab}.css`);
|
|
11286
11470
|
return {
|
|
11287
11471
|
assetKey: `${pascal}${CSS_SUFFIX}`,
|
|
11288
11472
|
contents: DEFAULT_CSS,
|
|
@@ -11294,8 +11478,8 @@ var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
|
11294
11478
|
var init_cssStrategy = () => {};
|
|
11295
11479
|
|
|
11296
11480
|
// src/cli/generate/navData.ts
|
|
11297
|
-
import
|
|
11298
|
-
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";
|
|
11299
11483
|
import { dirname as dirname20 } from "path";
|
|
11300
11484
|
var NAV_DATA_TEMPLATE = `type NavItem = {
|
|
11301
11485
|
href: string;
|
|
@@ -11308,24 +11492,24 @@ export const navData: NavItem[] = [];
|
|
|
11308
11492
|
const visit = (node) => {
|
|
11309
11493
|
if (found)
|
|
11310
11494
|
return;
|
|
11311
|
-
if (
|
|
11495
|
+
if (ts10.isVariableDeclaration(node) && ts10.isIdentifier(node.name) && node.name.text === "navData" && node.initializer && ts10.isArrayLiteralExpression(node.initializer)) {
|
|
11312
11496
|
found = node.initializer;
|
|
11313
11497
|
return;
|
|
11314
11498
|
}
|
|
11315
|
-
|
|
11499
|
+
ts10.forEachChild(node, visit);
|
|
11316
11500
|
};
|
|
11317
11501
|
visit(sourceFile);
|
|
11318
11502
|
return found;
|
|
11319
|
-
}, readStringProperty = (
|
|
11320
|
-
const property =
|
|
11321
|
-
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)) {
|
|
11322
11506
|
return null;
|
|
11323
11507
|
}
|
|
11324
11508
|
return property.initializer.text;
|
|
11325
11509
|
}, parseNavItems = (array) => {
|
|
11326
11510
|
const items = [];
|
|
11327
11511
|
for (const element of array.elements) {
|
|
11328
|
-
if (!
|
|
11512
|
+
if (!ts10.isObjectLiteralExpression(element))
|
|
11329
11513
|
continue;
|
|
11330
11514
|
const href = readStringProperty(element, "href");
|
|
11331
11515
|
const label = readStringProperty(element, "label");
|
|
@@ -11336,40 +11520,40 @@ export const navData: NavItem[] = [];
|
|
|
11336
11520
|
}, readNavItems = (navDataPath) => {
|
|
11337
11521
|
if (!existsSync24(navDataPath))
|
|
11338
11522
|
return [];
|
|
11339
|
-
const
|
|
11340
|
-
const sourceFile =
|
|
11523
|
+
const text2 = readFileSync24(navDataPath, "utf-8");
|
|
11524
|
+
const sourceFile = ts10.createSourceFile(navDataPath, text2, ts10.ScriptTarget.Latest, true);
|
|
11341
11525
|
const array = findNavArray(sourceFile);
|
|
11342
11526
|
return array ? parseNavItems(array) : [];
|
|
11343
|
-
}, indentOf = (
|
|
11527
|
+
}, indentOf = (text2, position) => {
|
|
11344
11528
|
let index = position;
|
|
11345
|
-
while (index > 0 &&
|
|
11529
|
+
while (index > 0 && text2[index - 1] !== `
|
|
11346
11530
|
`)
|
|
11347
11531
|
index -= 1;
|
|
11348
11532
|
let end = index;
|
|
11349
|
-
while (
|
|
11533
|
+
while (text2[end] === " " || text2[end] === "\t")
|
|
11350
11534
|
end += 1;
|
|
11351
|
-
return
|
|
11352
|
-
}, insertElement = (
|
|
11535
|
+
return text2.slice(index, end);
|
|
11536
|
+
}, insertElement = (text2, array, sourceFile, entry) => {
|
|
11353
11537
|
const { elements } = array;
|
|
11354
11538
|
if (elements.length === 0) {
|
|
11355
11539
|
const insertAt2 = array.getStart(sourceFile) + 1;
|
|
11356
|
-
const indent2 = `${indentOf(
|
|
11540
|
+
const indent2 = `${indentOf(text2, array.getStart(sourceFile))} `;
|
|
11357
11541
|
const insertion2 = `
|
|
11358
11542
|
${indent2}${entry}
|
|
11359
|
-
${indentOf(
|
|
11360
|
-
return
|
|
11543
|
+
${indentOf(text2, array.getStart(sourceFile))}`;
|
|
11544
|
+
return text2.slice(0, insertAt2) + insertion2 + text2.slice(insertAt2);
|
|
11361
11545
|
}
|
|
11362
11546
|
const last = elements[elements.length - 1];
|
|
11363
11547
|
if (!last)
|
|
11364
|
-
return
|
|
11365
|
-
const indent = indentOf(
|
|
11548
|
+
return text2;
|
|
11549
|
+
const indent = indentOf(text2, last.getStart(sourceFile));
|
|
11366
11550
|
let insertAt = last.getEnd();
|
|
11367
|
-
const hasComma =
|
|
11551
|
+
const hasComma = text2[insertAt] === ",";
|
|
11368
11552
|
if (hasComma)
|
|
11369
11553
|
insertAt += 1;
|
|
11370
11554
|
const insertion = `${hasComma ? "" : ","}
|
|
11371
11555
|
${indent}${entry}`;
|
|
11372
|
-
return
|
|
11556
|
+
return text2.slice(0, insertAt) + insertion + text2.slice(insertAt);
|
|
11373
11557
|
}, upsertNavItem = (navDataPath, item) => {
|
|
11374
11558
|
const created = !existsSync24(navDataPath);
|
|
11375
11559
|
if (created) {
|
|
@@ -11380,24 +11564,24 @@ ${indent}${entry}`;
|
|
|
11380
11564
|
if (existing.some((candidate) => candidate.href === item.href)) {
|
|
11381
11565
|
return { changed: created, created, items: existing };
|
|
11382
11566
|
}
|
|
11383
|
-
const
|
|
11384
|
-
const sourceFile =
|
|
11567
|
+
const text2 = readFileSync24(navDataPath, "utf-8");
|
|
11568
|
+
const sourceFile = ts10.createSourceFile(navDataPath, text2, ts10.ScriptTarget.Latest, true);
|
|
11385
11569
|
const array = findNavArray(sourceFile);
|
|
11386
11570
|
if (!array)
|
|
11387
11571
|
return { changed: created, created, items: existing };
|
|
11388
11572
|
const entry = `{ href: '${item.href}', label: '${item.label}' }`;
|
|
11389
|
-
writeFileSync12(navDataPath, insertElement(
|
|
11573
|
+
writeFileSync12(navDataPath, insertElement(text2, array, sourceFile, entry), "utf-8");
|
|
11390
11574
|
return { changed: true, created, items: [...existing, item] };
|
|
11391
11575
|
};
|
|
11392
11576
|
var init_navData = () => {};
|
|
11393
11577
|
|
|
11394
11578
|
// src/cli/generate/staticNav.ts
|
|
11395
|
-
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) => {
|
|
11396
11580
|
let index = position;
|
|
11397
|
-
while (index > 0 &&
|
|
11581
|
+
while (index > 0 && text2[index - 1] !== `
|
|
11398
11582
|
`)
|
|
11399
11583
|
index -= 1;
|
|
11400
|
-
return
|
|
11584
|
+
return text2.slice(index, position);
|
|
11401
11585
|
}, renderNavBlock = (items, indent) => {
|
|
11402
11586
|
const links = items.map((item) => `${indent} <a href="${escapeHtml2(item.href)}">${escapeHtml2(item.label)}</a>`).join(`
|
|
11403
11587
|
`);
|
|
@@ -11539,19 +11723,19 @@ var init_pageTemplates = __esm(() => {
|
|
|
11539
11723
|
import {
|
|
11540
11724
|
existsSync as existsSync25,
|
|
11541
11725
|
mkdirSync as mkdirSync13,
|
|
11542
|
-
readFileSync as
|
|
11726
|
+
readFileSync as readFileSync25,
|
|
11543
11727
|
readdirSync as readdirSync5,
|
|
11544
11728
|
writeFileSync as writeFileSync13
|
|
11545
11729
|
} from "fs";
|
|
11546
|
-
import { dirname as dirname21, join as
|
|
11730
|
+
import { dirname as dirname21, join as join32, relative as relative16 } from "path";
|
|
11547
11731
|
var writeNew = (path, contents) => {
|
|
11548
11732
|
mkdirSync13(dirname21(path), { recursive: true });
|
|
11549
11733
|
writeFileSync13(path, contents, "utf-8");
|
|
11550
11734
|
}, toHref = (fromDir, toFile) => {
|
|
11551
|
-
const rel =
|
|
11735
|
+
const rel = relative16(fromDir, toFile).split("\\").join("/");
|
|
11552
11736
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
11553
|
-
}, staticPageFiles = (project) => ["html", "htmx"].map((key) => project.frameworkDirs[key]).map((dir) => dir ?
|
|
11554
|
-
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");
|
|
11555
11739
|
const synced = syncStaticNav(html, items);
|
|
11556
11740
|
if (synced === null || synced === html)
|
|
11557
11741
|
return false;
|
|
@@ -11578,15 +11762,15 @@ var writeNew = (path, contents) => {
|
|
|
11578
11762
|
outcome.manual = { reason: "framework directory missing", snippet: "" };
|
|
11579
11763
|
return outcome;
|
|
11580
11764
|
}
|
|
11581
|
-
const pageFileAbs =
|
|
11765
|
+
const pageFileAbs = join32(frameworkDir, "pages", def.pageFile({ kebab, pascal }));
|
|
11582
11766
|
if (existsSync25(pageFileAbs)) {
|
|
11583
11767
|
outcome.notes.push(`${pascal} already exists at ${pageFileAbs} \u2014 skipped.`);
|
|
11584
11768
|
return outcome;
|
|
11585
11769
|
}
|
|
11586
11770
|
const routingFile = findRoutingFile(project.serverEntry);
|
|
11587
|
-
const routingText = routingFile ?
|
|
11771
|
+
const routingText = routingFile ? readFileSync25(routingFile, "utf-8") : "";
|
|
11588
11772
|
const css = planCss(routingText, project.stylesDir, pascal, kebab);
|
|
11589
|
-
const navDataPath =
|
|
11773
|
+
const navDataPath = join32(sharedDirFor(project, framework), "navData.ts");
|
|
11590
11774
|
const nav = upsertNavItem(navDataPath, { href: route, label: title });
|
|
11591
11775
|
const navImportPath = toModuleSpecifier(dirname21(pageFileAbs), navDataPath.replace(/\.ts$/, ""));
|
|
11592
11776
|
writeNew(pageFileAbs, pageTemplates[framework]({
|
|
@@ -11640,8 +11824,8 @@ var exports_generate = {};
|
|
|
11640
11824
|
__export(exports_generate, {
|
|
11641
11825
|
runGenerate: () => runGenerate
|
|
11642
11826
|
});
|
|
11643
|
-
import { relative as
|
|
11644
|
-
var SUBCOMMANDS, write = (
|
|
11827
|
+
import { relative as relative17 } from "path";
|
|
11828
|
+
var SUBCOMMANDS, write = (text2) => process.stdout.write(`${text2}
|
|
11645
11829
|
`), fail = (message) => {
|
|
11646
11830
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
11647
11831
|
`);
|
|
@@ -11672,7 +11856,7 @@ var SUBCOMMANDS, write = (text) => process.stdout.write(`${text}
|
|
|
11672
11856
|
return;
|
|
11673
11857
|
write(` ${colors.dim}${label}${colors.reset}`);
|
|
11674
11858
|
for (const path of paths)
|
|
11675
|
-
write(` ${
|
|
11859
|
+
write(` ${relative17(cwd, path)}`);
|
|
11676
11860
|
}, printSummary = (title, outcome, cwd) => {
|
|
11677
11861
|
for (const note of outcome.notes) {
|
|
11678
11862
|
write(`${colors.yellow}!${colors.reset} ${note}`);
|
|
@@ -11772,47 +11956,47 @@ ${indent.repeat(level)}}`;
|
|
|
11772
11956
|
var init_serialize = () => {};
|
|
11773
11957
|
|
|
11774
11958
|
// src/cli/config/absolute/editAbsoluteConfig.ts
|
|
11775
|
-
import
|
|
11776
|
-
import { readFileSync as
|
|
11777
|
-
var lineStartOffset = (
|
|
11959
|
+
import ts11 from "typescript";
|
|
11960
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync14 } from "fs";
|
|
11961
|
+
var lineStartOffset = (text2, position) => {
|
|
11778
11962
|
let index = position;
|
|
11779
|
-
while (index > 0 &&
|
|
11963
|
+
while (index > 0 && text2[index - 1] !== `
|
|
11780
11964
|
`)
|
|
11781
11965
|
index -= 1;
|
|
11782
11966
|
return index;
|
|
11783
|
-
}, 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) => {
|
|
11784
11968
|
try {
|
|
11785
|
-
const
|
|
11786
|
-
const sourceFile =
|
|
11787
|
-
const
|
|
11788
|
-
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) {
|
|
11789
11973
|
return {
|
|
11790
11974
|
message: "Could not find defineConfig({ ... }) in the config file.",
|
|
11791
11975
|
ok: false
|
|
11792
11976
|
};
|
|
11793
11977
|
}
|
|
11794
|
-
const existing = findProperty(
|
|
11978
|
+
const existing = findProperty(object3, request.name);
|
|
11795
11979
|
if (request.remove) {
|
|
11796
11980
|
if (!existing)
|
|
11797
11981
|
return { message: `${request.name} is not set`, ok: true };
|
|
11798
|
-
const start2 = lineStartOffset(
|
|
11982
|
+
const start2 = lineStartOffset(text2, existing.getStart(sourceFile));
|
|
11799
11983
|
let end = existing.getEnd();
|
|
11800
|
-
if (
|
|
11984
|
+
if (text2[end] === ",")
|
|
11801
11985
|
end += 1;
|
|
11802
|
-
if (
|
|
11986
|
+
if (text2[end] === `
|
|
11803
11987
|
`)
|
|
11804
11988
|
end += 1;
|
|
11805
|
-
writeFileSync14(configPath2,
|
|
11989
|
+
writeFileSync14(configPath2, text2.slice(0, start2) + text2.slice(end), "utf-8");
|
|
11806
11990
|
return { message: `Removed ${request.name}`, ok: true };
|
|
11807
11991
|
}
|
|
11808
11992
|
const valueText = serializeValue(request.value);
|
|
11809
11993
|
if (existing) {
|
|
11810
11994
|
const start2 = existing.initializer.getStart(sourceFile);
|
|
11811
11995
|
const end = existing.initializer.getEnd();
|
|
11812
|
-
writeFileSync14(configPath2,
|
|
11996
|
+
writeFileSync14(configPath2, text2.slice(0, start2) + valueText + text2.slice(end), "utf-8");
|
|
11813
11997
|
return { message: `Updated ${request.name}`, ok: true };
|
|
11814
11998
|
}
|
|
11815
|
-
const { properties } =
|
|
11999
|
+
const { properties } = object3;
|
|
11816
12000
|
const entry = `${request.name}: ${valueText}`;
|
|
11817
12001
|
if (properties.length > 0) {
|
|
11818
12002
|
const last = properties[properties.length - 1];
|
|
@@ -11822,21 +12006,21 @@ var lineStartOffset = (text, position) => {
|
|
|
11822
12006
|
ok: false
|
|
11823
12007
|
};
|
|
11824
12008
|
}
|
|
11825
|
-
const indent = indentBefore2(
|
|
12009
|
+
const indent = indentBefore2(text2, last.getStart(sourceFile));
|
|
11826
12010
|
let insertionIndex = last.getEnd();
|
|
11827
|
-
const hasComma =
|
|
12011
|
+
const hasComma = text2[insertionIndex] === ",";
|
|
11828
12012
|
if (hasComma)
|
|
11829
12013
|
insertionIndex += 1;
|
|
11830
12014
|
const insertion = `${hasComma ? "" : ","}
|
|
11831
12015
|
${indent}${entry}`;
|
|
11832
|
-
writeFileSync14(configPath2,
|
|
12016
|
+
writeFileSync14(configPath2, text2.slice(0, insertionIndex) + insertion + text2.slice(insertionIndex), "utf-8");
|
|
11833
12017
|
} else {
|
|
11834
|
-
const insertionIndex =
|
|
11835
|
-
const indent = `${indentBefore2(
|
|
12018
|
+
const insertionIndex = object3.getStart(sourceFile) + 1;
|
|
12019
|
+
const indent = `${indentBefore2(text2, object3.getStart(sourceFile))} `;
|
|
11836
12020
|
const insertion = `
|
|
11837
12021
|
${indent}${entry}
|
|
11838
|
-
${indentBefore2(
|
|
11839
|
-
writeFileSync14(configPath2,
|
|
12022
|
+
${indentBefore2(text2, object3.getStart(sourceFile))}`;
|
|
12023
|
+
writeFileSync14(configPath2, text2.slice(0, insertionIndex) + insertion + text2.slice(insertionIndex), "utf-8");
|
|
11840
12024
|
}
|
|
11841
12025
|
return { message: `Updated ${request.name}`, ok: true };
|
|
11842
12026
|
} catch (error) {
|
|
@@ -11965,14 +12149,14 @@ var init_catalog = __esm(() => {
|
|
|
11965
12149
|
});
|
|
11966
12150
|
|
|
11967
12151
|
// src/cli/integrations/addPlugin.ts
|
|
11968
|
-
import { existsSync as existsSync26, readFileSync as
|
|
11969
|
-
import { join as
|
|
12152
|
+
import { existsSync as existsSync26, readFileSync as readFileSync27 } from "fs";
|
|
12153
|
+
import { join as join33 } from "path";
|
|
11970
12154
|
var isRecord11 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), readPackageJson = (cwd) => {
|
|
11971
|
-
const path =
|
|
12155
|
+
const path = join33(cwd, "package.json");
|
|
11972
12156
|
if (!existsSync26(path))
|
|
11973
12157
|
return null;
|
|
11974
12158
|
try {
|
|
11975
|
-
const parsed = JSON.parse(
|
|
12159
|
+
const parsed = JSON.parse(readFileSync27(path, "utf-8"));
|
|
11976
12160
|
return isRecord11(parsed) ? parsed : null;
|
|
11977
12161
|
} catch {
|
|
11978
12162
|
return null;
|
|
@@ -12463,61 +12647,61 @@ var init_authCatalog = __esm(() => {
|
|
|
12463
12647
|
});
|
|
12464
12648
|
|
|
12465
12649
|
// src/cli/config/auth/resolveAuthSettings.ts
|
|
12466
|
-
import
|
|
12467
|
-
import { existsSync as existsSync27, readFileSync as
|
|
12468
|
-
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";
|
|
12469
12653
|
var AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, findAuthSettingsPath = (cwd, override) => {
|
|
12470
12654
|
if (override) {
|
|
12471
|
-
const resolved =
|
|
12655
|
+
const resolved = resolve28(cwd, override);
|
|
12472
12656
|
return existsSync27(resolved) ? resolved : null;
|
|
12473
12657
|
}
|
|
12474
12658
|
for (const name of CONFIG_CANDIDATES3) {
|
|
12475
|
-
const candidate =
|
|
12659
|
+
const candidate = resolve28(cwd, name);
|
|
12476
12660
|
if (existsSync27(candidate))
|
|
12477
12661
|
return candidate;
|
|
12478
12662
|
}
|
|
12479
12663
|
return null;
|
|
12480
|
-
}, parseSource2 = (configPath2,
|
|
12664
|
+
}, parseSource2 = (configPath2, text2) => ts12.createSourceFile(configPath2, text2, ts12.ScriptTarget.Latest, true), findAuthSettingsObject = (sourceFile) => {
|
|
12481
12665
|
const pending = [sourceFile];
|
|
12482
12666
|
while (pending.length > 0) {
|
|
12483
12667
|
const node = pending.pop();
|
|
12484
12668
|
if (!node)
|
|
12485
12669
|
continue;
|
|
12486
|
-
const [firstArgument] =
|
|
12487
|
-
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)) {
|
|
12488
12672
|
return firstArgument;
|
|
12489
12673
|
}
|
|
12490
|
-
if (
|
|
12674
|
+
if (ts12.isExportAssignment(node) && ts12.isObjectLiteralExpression(node.expression)) {
|
|
12491
12675
|
return node.expression;
|
|
12492
12676
|
}
|
|
12493
12677
|
node.forEachChild((child) => pending.push(child));
|
|
12494
12678
|
}
|
|
12495
12679
|
return null;
|
|
12496
12680
|
}, parseAuthSettingsObject = (configPath2) => {
|
|
12497
|
-
const
|
|
12681
|
+
const text2 = readFileSync28(configPath2, "utf-8");
|
|
12498
12682
|
return {
|
|
12499
|
-
object: findAuthSettingsObject(parseSource2(configPath2,
|
|
12500
|
-
text
|
|
12683
|
+
object: findAuthSettingsObject(parseSource2(configPath2, text2)),
|
|
12684
|
+
text: text2
|
|
12501
12685
|
};
|
|
12502
12686
|
}, evalLiteral2 = (node) => {
|
|
12503
|
-
if (
|
|
12687
|
+
if (ts12.isStringLiteralLike(node))
|
|
12504
12688
|
return { opaque: false, value: node.text };
|
|
12505
|
-
if (node.kind ===
|
|
12689
|
+
if (node.kind === ts12.SyntaxKind.TrueKeyword) {
|
|
12506
12690
|
return { opaque: false, value: true };
|
|
12507
12691
|
}
|
|
12508
|
-
if (node.kind ===
|
|
12692
|
+
if (node.kind === ts12.SyntaxKind.FalseKeyword) {
|
|
12509
12693
|
return { opaque: false, value: false };
|
|
12510
12694
|
}
|
|
12511
|
-
if (node.kind ===
|
|
12695
|
+
if (node.kind === ts12.SyntaxKind.NullKeyword) {
|
|
12512
12696
|
return { opaque: false, value: null };
|
|
12513
12697
|
}
|
|
12514
|
-
if (
|
|
12698
|
+
if (ts12.isNumericLiteral(node)) {
|
|
12515
12699
|
return { opaque: false, value: Number(node.text) };
|
|
12516
12700
|
}
|
|
12517
|
-
if (
|
|
12701
|
+
if (ts12.isPrefixUnaryExpression(node) && node.operator === ts12.SyntaxKind.MinusToken && ts12.isNumericLiteral(node.operand)) {
|
|
12518
12702
|
return { opaque: false, value: -Number(node.operand.text) };
|
|
12519
12703
|
}
|
|
12520
|
-
if (
|
|
12704
|
+
if (ts12.isArrayLiteralExpression(node)) {
|
|
12521
12705
|
const items = [];
|
|
12522
12706
|
for (const element of node.elements) {
|
|
12523
12707
|
const result = evalLiteral2(element);
|
|
@@ -12531,11 +12715,11 @@ var AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, findAuthSettingsPath
|
|
|
12531
12715
|
}, readCurrent2 = (configPath2) => {
|
|
12532
12716
|
const current = {};
|
|
12533
12717
|
const opaqueKeys = [];
|
|
12534
|
-
const { object:
|
|
12535
|
-
if (!
|
|
12718
|
+
const { object: object3 } = parseAuthSettingsObject(configPath2);
|
|
12719
|
+
if (!object3)
|
|
12536
12720
|
return { current, opaqueKeys };
|
|
12537
|
-
for (const property of
|
|
12538
|
-
if (!
|
|
12721
|
+
for (const property of object3.properties) {
|
|
12722
|
+
if (!ts12.isPropertyAssignment(property) || !(ts12.isIdentifier(property.name) || ts12.isStringLiteral(property.name))) {
|
|
12539
12723
|
continue;
|
|
12540
12724
|
}
|
|
12541
12725
|
const name = property.name.text;
|
|
@@ -12568,14 +12752,14 @@ var init_resolveAuthSettings = __esm(() => {
|
|
|
12568
12752
|
});
|
|
12569
12753
|
|
|
12570
12754
|
// src/cli/config/auth/resolveAuthState.ts
|
|
12571
|
-
import
|
|
12572
|
-
import { existsSync as existsSync28, readdirSync as readdirSync6, readFileSync as
|
|
12573
|
-
import { join as
|
|
12574
|
-
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) => {
|
|
12575
12759
|
if (!existsSync28(path))
|
|
12576
12760
|
return null;
|
|
12577
12761
|
try {
|
|
12578
|
-
const parsed = JSON.parse(
|
|
12762
|
+
const parsed = JSON.parse(readFileSync29(path, "utf-8"));
|
|
12579
12763
|
return isRecord12(parsed) ? parsed : null;
|
|
12580
12764
|
} catch {
|
|
12581
12765
|
return null;
|
|
@@ -12584,7 +12768,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12584
12768
|
const value = record?.[key];
|
|
12585
12769
|
return typeof value === "string" ? value : null;
|
|
12586
12770
|
}, declaredVersionFor = (cwd) => {
|
|
12587
|
-
const pkg =
|
|
12771
|
+
const pkg = readJson2(join34(cwd, "package.json"));
|
|
12588
12772
|
if (!pkg)
|
|
12589
12773
|
return null;
|
|
12590
12774
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
@@ -12596,14 +12780,14 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12596
12780
|
return version2;
|
|
12597
12781
|
}
|
|
12598
12782
|
return null;
|
|
12599
|
-
}, installedVersionFor = (cwd) => stringField(
|
|
12783
|
+
}, installedVersionFor = (cwd) => stringField(readJson2(join34(cwd, "node_modules", AUTH_PACKAGE2, "package.json")), "version"), SOURCE_FILE, safeReaddir = (dir) => {
|
|
12600
12784
|
try {
|
|
12601
12785
|
return readdirSync6(dir, { withFileTypes: true });
|
|
12602
12786
|
} catch {
|
|
12603
12787
|
return [];
|
|
12604
12788
|
}
|
|
12605
12789
|
}, sortEntry = (dir, entry, found, dirs) => {
|
|
12606
|
-
const full =
|
|
12790
|
+
const full = join34(dir, entry.name);
|
|
12607
12791
|
if (entry.isDirectory()) {
|
|
12608
12792
|
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith("."))
|
|
12609
12793
|
return;
|
|
@@ -12625,9 +12809,9 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12625
12809
|
collectFrom(dir, found, stack);
|
|
12626
12810
|
}
|
|
12627
12811
|
return found;
|
|
12628
|
-
}, isAuthPackageImport = (statement) =>
|
|
12812
|
+
}, isAuthPackageImport = (statement) => ts13.isImportDeclaration(statement) && ts13.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === AUTH_PACKAGE2, addAuthNames = (statement, names) => {
|
|
12629
12813
|
const bindings = statement.importClause?.namedBindings;
|
|
12630
|
-
if (!bindings || !
|
|
12814
|
+
if (!bindings || !ts13.isNamedImports(bindings))
|
|
12631
12815
|
return;
|
|
12632
12816
|
for (const element of bindings.elements) {
|
|
12633
12817
|
const imported = element.propertyName?.text ?? element.name.text;
|
|
@@ -12642,18 +12826,18 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12642
12826
|
addAuthNames(statement, names);
|
|
12643
12827
|
}
|
|
12644
12828
|
return names;
|
|
12645
|
-
}, isAuthCall = (node, bindings) =>
|
|
12646
|
-
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)) {
|
|
12647
12831
|
return null;
|
|
12648
12832
|
}
|
|
12649
12833
|
return property.initializer.properties.length;
|
|
12650
|
-
}, readConfigKeys = (
|
|
12834
|
+
}, readConfigKeys = (object3) => {
|
|
12651
12835
|
const keys = new Set;
|
|
12652
12836
|
let providerCount = null;
|
|
12653
|
-
const usesSpread =
|
|
12654
|
-
for (const property of
|
|
12837
|
+
const usesSpread = object3.properties.some((property) => ts13.isSpreadAssignment(property));
|
|
12838
|
+
for (const property of object3.properties) {
|
|
12655
12839
|
const { name } = property;
|
|
12656
|
-
if (name === undefined || !
|
|
12840
|
+
if (name === undefined || !ts13.isIdentifier(name))
|
|
12657
12841
|
continue;
|
|
12658
12842
|
keys.add(name.text);
|
|
12659
12843
|
if (name.text !== "providersConfiguration")
|
|
@@ -12663,20 +12847,20 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12663
12847
|
return { keys, providerCount, usesSpread };
|
|
12664
12848
|
}, matchFromCall = (node) => {
|
|
12665
12849
|
const [arg] = node.arguments;
|
|
12666
|
-
if (arg &&
|
|
12850
|
+
if (arg && ts13.isObjectLiteralExpression(arg))
|
|
12667
12851
|
return readConfigKeys(arg);
|
|
12668
12852
|
return { keys: new Set, providerCount: null, usesSpread: true };
|
|
12669
12853
|
}, readFileOrNull = (path) => {
|
|
12670
12854
|
try {
|
|
12671
|
-
return
|
|
12855
|
+
return readFileSync29(path, "utf-8");
|
|
12672
12856
|
} catch {
|
|
12673
12857
|
return null;
|
|
12674
12858
|
}
|
|
12675
12859
|
}, findSetupInFile = (path) => {
|
|
12676
|
-
const
|
|
12677
|
-
if (
|
|
12860
|
+
const text2 = readFileOrNull(path);
|
|
12861
|
+
if (text2 === null || !text2.includes(AUTH_PACKAGE2))
|
|
12678
12862
|
return null;
|
|
12679
|
-
const sourceFile =
|
|
12863
|
+
const sourceFile = ts13.createSourceFile(path, text2, ts13.ScriptTarget.Latest, true);
|
|
12680
12864
|
const bindings = authBindings(sourceFile);
|
|
12681
12865
|
if (bindings.size === 0)
|
|
12682
12866
|
return null;
|
|
@@ -12685,7 +12869,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12685
12869
|
const node = pending.pop();
|
|
12686
12870
|
if (!node)
|
|
12687
12871
|
continue;
|
|
12688
|
-
if (
|
|
12872
|
+
if (ts13.isCallExpression(node) && isAuthCall(node, bindings)) {
|
|
12689
12873
|
return matchFromCall(node);
|
|
12690
12874
|
}
|
|
12691
12875
|
node.forEachChild((child) => pending.push(child));
|
|
@@ -12701,7 +12885,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12701
12885
|
scaffoldable: isScaffoldableFeature(feature.id)
|
|
12702
12886
|
})), resolveAuthState = (cwd) => {
|
|
12703
12887
|
const installedVersion = installedVersionFor(cwd);
|
|
12704
|
-
const root = existsSync28(
|
|
12888
|
+
const root = existsSync28(join34(cwd, "src")) ? join34(cwd, "src") : cwd;
|
|
12705
12889
|
let match = null;
|
|
12706
12890
|
let setupPath = null;
|
|
12707
12891
|
for (const file of candidateFiles(root)) {
|
|
@@ -12709,7 +12893,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12709
12893
|
if (found === null)
|
|
12710
12894
|
continue;
|
|
12711
12895
|
match = found;
|
|
12712
|
-
setupPath =
|
|
12896
|
+
setupPath = relative18(cwd, resolve29(file));
|
|
12713
12897
|
break;
|
|
12714
12898
|
}
|
|
12715
12899
|
const keys = match?.keys ?? new Set;
|
|
@@ -12747,7 +12931,7 @@ var init_resolveAuthState = __esm(() => {
|
|
|
12747
12931
|
|
|
12748
12932
|
// src/cli/config/auth/scaffoldAuthFeature.ts
|
|
12749
12933
|
import { existsSync as existsSync29, writeFileSync as writeFileSync15 } from "fs";
|
|
12750
|
-
import { dirname as dirname22, join as
|
|
12934
|
+
import { dirname as dirname22, join as join35, relative as relative19, resolve as resolve30 } from "path";
|
|
12751
12935
|
var renderScaffold = (scaffold) => {
|
|
12752
12936
|
const importNames = [...scaffold.imports, `type ${scaffold.typeName}`];
|
|
12753
12937
|
const importLine = `import { ${importNames.join(", ")} } from '@absolutejs/auth';`;
|
|
@@ -12772,8 +12956,8 @@ ${body}
|
|
|
12772
12956
|
}, targetDir = (cwd) => {
|
|
12773
12957
|
const { setupPath } = resolveAuthState(cwd);
|
|
12774
12958
|
if (setupPath)
|
|
12775
|
-
return dirname22(
|
|
12776
|
-
const src =
|
|
12959
|
+
return dirname22(resolve30(cwd, setupPath));
|
|
12960
|
+
const src = join35(cwd, "src");
|
|
12777
12961
|
return existsSync29(src) ? src : cwd;
|
|
12778
12962
|
}, spreadFor = (scaffold) => `import { ${scaffold.exportName} } from './${scaffold.exportName}';
|
|
12779
12963
|
// add to your auth() call:
|
|
@@ -12787,8 +12971,8 @@ ${scaffold.configKey}: ${scaffold.exportName}`, failure2 = (message) => ({
|
|
|
12787
12971
|
const scaffold = AUTH_SCAFFOLDS[id];
|
|
12788
12972
|
if (!scaffold)
|
|
12789
12973
|
return failure2(`Unknown auth feature "${id}".`);
|
|
12790
|
-
const filePath =
|
|
12791
|
-
const relPath =
|
|
12974
|
+
const filePath = join35(targetDir(cwd), `${scaffold.exportName}.ts`);
|
|
12975
|
+
const relPath = relative19(cwd, filePath);
|
|
12792
12976
|
if (existsSync29(filePath)) {
|
|
12793
12977
|
return {
|
|
12794
12978
|
created: null,
|
|
@@ -12816,12 +13000,12 @@ var init_scaffoldAuthFeature = __esm(() => {
|
|
|
12816
13000
|
});
|
|
12817
13001
|
|
|
12818
13002
|
// src/cli/htmx/install.ts
|
|
12819
|
-
import { existsSync as existsSync30, mkdirSync as mkdirSync14, readFileSync as
|
|
12820
|
-
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";
|
|
12821
13005
|
var VENDORED_HTMX_VERSION = "2.0.6", vendoredHtmxFile = () => [
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
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")
|
|
12825
13009
|
].find((path) => existsSync30(path)) ?? null, detectHtmxVersion = (content) => {
|
|
12826
13010
|
const match = content.match(/version:"([0-9.]+)"/);
|
|
12827
13011
|
return match ? match[1] : null;
|
|
@@ -12833,16 +13017,16 @@ var VENDORED_HTMX_VERSION = "2.0.6", vendoredHtmxFile = () => [
|
|
|
12833
13017
|
}
|
|
12834
13018
|
return response.text();
|
|
12835
13019
|
}, installedHtmxVersion = (htmxDir) => {
|
|
12836
|
-
const file =
|
|
13020
|
+
const file = join36(htmxDir, "htmx.min.js");
|
|
12837
13021
|
if (!existsSync30(file))
|
|
12838
13022
|
return null;
|
|
12839
|
-
return detectHtmxVersion(
|
|
13023
|
+
return detectHtmxVersion(readFileSync30(file, "utf-8"));
|
|
12840
13024
|
}, readVendoredHtmx = () => {
|
|
12841
13025
|
const file = vendoredHtmxFile();
|
|
12842
|
-
return file ?
|
|
13026
|
+
return file ? readFileSync30(file, "utf-8") : null;
|
|
12843
13027
|
}, writeHtmx = (htmxDir, content) => {
|
|
12844
13028
|
mkdirSync14(htmxDir, { recursive: true });
|
|
12845
|
-
const file =
|
|
13029
|
+
const file = join36(htmxDir, "htmx.min.js");
|
|
12846
13030
|
writeFileSync16(file, content, "utf-8");
|
|
12847
13031
|
return file;
|
|
12848
13032
|
};
|
|
@@ -12853,8 +13037,8 @@ var exports_add = {};
|
|
|
12853
13037
|
__export(exports_add, {
|
|
12854
13038
|
runAdd: () => runAdd
|
|
12855
13039
|
});
|
|
12856
|
-
import { dirname as dirname23, join as
|
|
12857
|
-
var write2 = (
|
|
13040
|
+
import { dirname as dirname23, join as join37, relative as relative20 } from "path";
|
|
13041
|
+
var write2 = (text2) => process.stdout.write(`${text2}
|
|
12858
13042
|
`), fail2 = (message) => {
|
|
12859
13043
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
12860
13044
|
`);
|
|
@@ -12864,11 +13048,11 @@ var write2 = (text) => process.stdout.write(`${text}
|
|
|
12864
13048
|
return;
|
|
12865
13049
|
write2(` ${colors.dim}${label}${colors.reset}`);
|
|
12866
13050
|
for (const path of paths)
|
|
12867
|
-
write2(` ${
|
|
13051
|
+
write2(` ${relative20(cwd, path)}`);
|
|
12868
13052
|
}, frontendRoot = (project, cwd) => {
|
|
12869
13053
|
const [firstKey] = configuredFrameworks(project);
|
|
12870
13054
|
const firstDir = firstKey ? project.frameworkDirs[firstKey] : undefined;
|
|
12871
|
-
return firstDir ? dirname23(firstDir) :
|
|
13055
|
+
return firstDir ? dirname23(firstDir) : join37(cwd, "src", "frontend");
|
|
12872
13056
|
}, addIntegrationCli = (id, install) => {
|
|
12873
13057
|
const result = addIntegration(process.cwd(), id, { install });
|
|
12874
13058
|
if (!result.ok) {
|
|
@@ -12932,8 +13116,8 @@ var write2 = (text) => process.stdout.write(`${text}
|
|
|
12932
13116
|
write2(`${colors.yellow}!${colors.reset} ${frameworks6[framework].label} is already configured \u2014 nothing to do.`);
|
|
12933
13117
|
return;
|
|
12934
13118
|
}
|
|
12935
|
-
const dirAbs =
|
|
12936
|
-
const dirRel = `./${
|
|
13119
|
+
const dirAbs = join37(frontendRoot(project, cwd), framework);
|
|
13120
|
+
const dirRel = `./${relative20(cwd, dirAbs).split("\\").join("/")}`;
|
|
12937
13121
|
let depNote = "Skipped dependency install (--no-install).";
|
|
12938
13122
|
if (!noInstall) {
|
|
12939
13123
|
write2(`${colors.dim}Installing ${frameworks6[framework].label} dependencies\u2026${colors.reset}`);
|
|
@@ -13002,8 +13186,8 @@ var exports_analyze = {};
|
|
|
13002
13186
|
__export(exports_analyze, {
|
|
13003
13187
|
runAnalyze: () => runAnalyze
|
|
13004
13188
|
});
|
|
13005
|
-
import { existsSync as existsSync31, readFileSync as
|
|
13006
|
-
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";
|
|
13007
13191
|
var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_WIDTH = 16, SIZE_WIDTH = 12, CHANGE_WIDTH = 10, CATEGORY_ORDER, categoryOf = (key) => {
|
|
13008
13192
|
if (key.startsWith("Island"))
|
|
13009
13193
|
return "Islands";
|
|
@@ -13023,21 +13207,21 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
13023
13207
|
return 0;
|
|
13024
13208
|
}
|
|
13025
13209
|
}, readSizes = (manifestDir) => {
|
|
13026
|
-
const manifestPath =
|
|
13210
|
+
const manifestPath = join38(manifestDir, "manifest.json");
|
|
13027
13211
|
if (!existsSync31(manifestPath))
|
|
13028
13212
|
return null;
|
|
13029
|
-
const manifest = JSON.parse(
|
|
13213
|
+
const manifest = JSON.parse(readFileSync31(manifestPath, "utf-8"));
|
|
13030
13214
|
const sizes = {};
|
|
13031
13215
|
for (const [key, value] of Object.entries(manifest)) {
|
|
13032
|
-
sizes[key] = fileSize2(
|
|
13216
|
+
sizes[key] = fileSize2(join38(manifestDir, value.replace(/^\//, "")));
|
|
13033
13217
|
}
|
|
13034
13218
|
return sizes;
|
|
13035
13219
|
}, readBaseline = (cwd) => {
|
|
13036
|
-
const path =
|
|
13220
|
+
const path = join38(cwd, BASELINE_FILE);
|
|
13037
13221
|
if (!existsSync31(path))
|
|
13038
13222
|
return null;
|
|
13039
13223
|
try {
|
|
13040
|
-
const parsed = JSON.parse(
|
|
13224
|
+
const parsed = JSON.parse(readFileSync31(path, "utf-8"));
|
|
13041
13225
|
return parsed;
|
|
13042
13226
|
} catch {
|
|
13043
13227
|
return null;
|
|
@@ -13115,14 +13299,14 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
13115
13299
|
const config = await loadConfig(configIndex >= 0 ? args[configIndex + 1] : undefined);
|
|
13116
13300
|
const outdirIndex = args.indexOf("--outdir");
|
|
13117
13301
|
const outdir = outdirIndex >= 0 ? args[outdirIndex + 1] : config.buildDirectory;
|
|
13118
|
-
const sizes = readSizes(
|
|
13302
|
+
const sizes = readSizes(resolve31(cwd, outdir ?? "build"));
|
|
13119
13303
|
if (sizes === null) {
|
|
13120
13304
|
process.stdout.write(`${colors.dim}No build found. Run \`absolute build\` first.${colors.reset}
|
|
13121
13305
|
`);
|
|
13122
13306
|
return;
|
|
13123
13307
|
}
|
|
13124
13308
|
if (args.includes("--save")) {
|
|
13125
|
-
writeFileSync17(
|
|
13309
|
+
writeFileSync17(join38(cwd, BASELINE_FILE), `${JSON.stringify(sizes, null, 2)}
|
|
13126
13310
|
`);
|
|
13127
13311
|
process.stdout.write(`${colors.green}\u2713${colors.reset} Saved size baseline (${Object.keys(sizes).length} entries) to ${BASELINE_FILE}
|
|
13128
13312
|
`);
|
|
@@ -13167,7 +13351,7 @@ var SLOW_MS = 100, VERY_SLOW_MS = 500, HTTP_SERVER_ERROR = 500, HTTP_CLIENT_ERRO
|
|
|
13167
13351
|
}, isDim = (kind) => kind !== "api" && kind !== "page", pickServer = (instances) => {
|
|
13168
13352
|
const withUrl = instances.filter((instance) => instance.url !== null);
|
|
13169
13353
|
return withUrl.find((instance) => instance.source === "dev") ?? withUrl.find((instance) => instance.source !== "untracked") ?? withUrl[0] ?? null;
|
|
13170
|
-
}, 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) => {
|
|
13171
13355
|
const durations = records.filter((record) => !isDim(record.kind)).map((record) => record.durationMs).sort((left, right) => left - right);
|
|
13172
13356
|
const total = durations.reduce((sum, value) => sum + value, 0);
|
|
13173
13357
|
const avgMs = durations.length ? Math.round(total / durations.length) : 0;
|
|
@@ -13368,9 +13552,9 @@ var exports_remove = {};
|
|
|
13368
13552
|
__export(exports_remove, {
|
|
13369
13553
|
runRemove: () => runRemove
|
|
13370
13554
|
});
|
|
13371
|
-
import { existsSync as existsSync32, readFileSync as
|
|
13372
|
-
import { relative as
|
|
13373
|
-
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}
|
|
13374
13558
|
`), fail3 = (message) => {
|
|
13375
13559
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
13376
13560
|
`);
|
|
@@ -13382,7 +13566,7 @@ var write3 = (text) => process.stdout.write(`${text}
|
|
|
13382
13566
|
if (file === null || seen.has(file) || !existsSync32(file))
|
|
13383
13567
|
return false;
|
|
13384
13568
|
seen.add(file);
|
|
13385
|
-
return
|
|
13569
|
+
return readFileSync32(file, "utf-8").includes(handler);
|
|
13386
13570
|
});
|
|
13387
13571
|
}, runRemove = async (args) => {
|
|
13388
13572
|
const [framework] = args.filter((arg) => !arg.startsWith("--"));
|
|
@@ -13418,10 +13602,10 @@ var write3 = (text) => process.stdout.write(`${text}
|
|
|
13418
13602
|
}
|
|
13419
13603
|
write3(`${colors.green}\u2713${colors.reset} Removed ${framework}Directory from absolute.config.ts
|
|
13420
13604
|
`);
|
|
13421
|
-
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.`);
|
|
13422
13606
|
const refs = referencingFiles(project.serverEntry, HANDLER_NAME[framework]);
|
|
13423
13607
|
for (const file of refs) {
|
|
13424
|
-
write3(` ${colors.yellow}Still references${colors.reset} ${
|
|
13608
|
+
write3(` ${colors.yellow}Still references${colors.reset} ${relative21(cwd, file)} (calls ${HANDLER_NAME[framework]})`);
|
|
13425
13609
|
}
|
|
13426
13610
|
const deps = frameworkDependencyNames(framework);
|
|
13427
13611
|
if (prune && deps.length > 0) {
|
|
@@ -13459,7 +13643,7 @@ var exports_htmx = {};
|
|
|
13459
13643
|
__export(exports_htmx, {
|
|
13460
13644
|
runHtmx: () => runHtmx
|
|
13461
13645
|
});
|
|
13462
|
-
var write4 = (
|
|
13646
|
+
var write4 = (text2) => process.stdout.write(`${text2}
|
|
13463
13647
|
`), fail4 = (message) => {
|
|
13464
13648
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
13465
13649
|
`);
|
|
@@ -13509,15 +13693,15 @@ __export(exports_env, {
|
|
|
13509
13693
|
runEnv: () => runEnv,
|
|
13510
13694
|
collectEnvVars: () => collectEnvVars
|
|
13511
13695
|
});
|
|
13512
|
-
import { existsSync as existsSync33, readFileSync as
|
|
13513
|
-
import { join as
|
|
13696
|
+
import { existsSync as existsSync33, readFileSync as readFileSync33 } from "fs";
|
|
13697
|
+
import { join as join39 } from "path";
|
|
13514
13698
|
var {env: env3, Glob: Glob3 } = globalThis.Bun;
|
|
13515
|
-
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 () => {
|
|
13516
13700
|
const scans = scanPatterns().map((pattern) => Array.fromAsync(new Glob3(pattern).scan({ cwd: process.cwd() })));
|
|
13517
13701
|
const files = (await Promise.all(scans)).flat();
|
|
13518
13702
|
const usage = new Map;
|
|
13519
13703
|
files.forEach((file) => {
|
|
13520
|
-
keysInFile(
|
|
13704
|
+
keysInFile(readFileSync33(file, "utf-8")).forEach((key) => {
|
|
13521
13705
|
usage.set(key, [...usage.get(key) ?? [], file]);
|
|
13522
13706
|
});
|
|
13523
13707
|
});
|
|
@@ -13578,10 +13762,10 @@ __export(exports_db, {
|
|
|
13578
13762
|
conflictClause: () => conflictClause,
|
|
13579
13763
|
chunkRows: () => chunkRows
|
|
13580
13764
|
});
|
|
13581
|
-
import { existsSync as existsSync34, mkdirSync as mkdirSync15, readFileSync as
|
|
13582
|
-
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";
|
|
13583
13767
|
var {env: env4, spawn: spawn2, SQL } = globalThis.Bun;
|
|
13584
|
-
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) => {
|
|
13585
13769
|
const found = explicit ?? URL_ENV_KEYS.map((key) => env4[key]).find((value) => typeof value === "string" && value !== "");
|
|
13586
13770
|
if (found === undefined || found === "")
|
|
13587
13771
|
throw new Error(`No database URL found. Set ${URL_ENV_KEYS.join(" or ")}, or pass --url <url>.`);
|
|
@@ -13689,19 +13873,19 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13689
13873
|
tables,
|
|
13690
13874
|
v: BACKUP_FORMAT_VERSION
|
|
13691
13875
|
};
|
|
13692
|
-
const dir = options.out ??
|
|
13876
|
+
const dir = options.out ?? join40(process.cwd(), "backups");
|
|
13693
13877
|
mkdirSync15(dir, { recursive: true });
|
|
13694
13878
|
const json = JSON.stringify(payload, (_, value) => typeof value === "bigint" ? value.toString() : value);
|
|
13695
|
-
const file =
|
|
13879
|
+
const file = join40(dir, `backup-${payload.at.replace(/[:.]/g, "-")}.json`);
|
|
13696
13880
|
writeFileSync18(file, json);
|
|
13697
|
-
writeFileSync18(
|
|
13881
|
+
writeFileSync18(join40(dir, "latest.json"), json);
|
|
13698
13882
|
const total = chosen.reduce((sum, name) => sum + (tables[name]?.length ?? 0), 0);
|
|
13699
13883
|
console.log(paint(`\u2713 backup \u2192 ${file}`, colors.green));
|
|
13700
13884
|
console.log(paint(` ${chosen.length} tables, ${total} rows`, colors.dim));
|
|
13701
13885
|
}, runRestore = async (file, options) => {
|
|
13702
13886
|
if (!existsSync34(file))
|
|
13703
13887
|
throw new Error(`Backup not found: ${file}`);
|
|
13704
|
-
const payload = JSON.parse(
|
|
13888
|
+
const payload = JSON.parse(readFileSync34(file, "utf-8"));
|
|
13705
13889
|
const names = Object.keys(payload.tables).filter((name) => keepTable(name, options));
|
|
13706
13890
|
const sql = new SQL(options.url);
|
|
13707
13891
|
const order = dependencyOrder(names, await foreignLinks(sql));
|
|
@@ -13723,7 +13907,7 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13723
13907
|
const total = order.reduce((sum, name) => sum + (payload.tables[name]?.length ?? 0), 0);
|
|
13724
13908
|
console.log(paint(`\u2713 restored ${order.length} tables, ${total} rows (idempotent upsert by primary key)`, colors.green));
|
|
13725
13909
|
}, runSeed = async (entry) => {
|
|
13726
|
-
const target = entry ?? SEED_CANDIDATES.find((candidate) => existsSync34(
|
|
13910
|
+
const target = entry ?? SEED_CANDIDATES.find((candidate) => existsSync34(join40(process.cwd(), candidate)));
|
|
13727
13911
|
if (target === undefined)
|
|
13728
13912
|
throw new Error(`No seed script found (looked for ${SEED_CANDIDATES.join(", ")}). Pass a path: absolute db seed <file>.`);
|
|
13729
13913
|
console.log(paint(`seeding via ${target}\u2026`, colors.cyan));
|
|
@@ -13758,7 +13942,7 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13758
13942
|
return;
|
|
13759
13943
|
}
|
|
13760
13944
|
if (sub === "restore") {
|
|
13761
|
-
const file = positionalArgs(rest)[0] ??
|
|
13945
|
+
const file = positionalArgs(rest)[0] ?? join40(process.cwd(), "backups", "latest.json");
|
|
13762
13946
|
await runRestore(file, parseOptions(rest));
|
|
13763
13947
|
return;
|
|
13764
13948
|
}
|
|
@@ -13872,16 +14056,16 @@ var init_logs = __esm(() => {
|
|
|
13872
14056
|
// src/cli/typeGraphCoherence.ts
|
|
13873
14057
|
import {
|
|
13874
14058
|
existsSync as existsSync36,
|
|
13875
|
-
readFileSync as
|
|
14059
|
+
readFileSync as readFileSync35,
|
|
13876
14060
|
realpathSync as realpathSync2,
|
|
13877
14061
|
rmSync as rmSync6,
|
|
13878
14062
|
writeFileSync as writeFileSync19
|
|
13879
14063
|
} from "fs";
|
|
13880
14064
|
import { createRequire } from "module";
|
|
13881
|
-
import { dirname as dirname24, join as
|
|
14065
|
+
import { dirname as dirname24, join as join41, resolve as resolve32, sep as sep5 } from "path";
|
|
13882
14066
|
var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
13883
14067
|
try {
|
|
13884
|
-
const parsed = JSON.parse(
|
|
14068
|
+
const parsed = JSON.parse(readFileSync35(path, "utf-8"));
|
|
13885
14069
|
return isRecord9(parsed) ? parsed : null;
|
|
13886
14070
|
} catch {
|
|
13887
14071
|
return null;
|
|
@@ -13900,7 +14084,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13900
14084
|
}, packageJsonFromEntry = (entry, expectedName) => {
|
|
13901
14085
|
let directory = dirname24(entry);
|
|
13902
14086
|
for (;; ) {
|
|
13903
|
-
const candidate =
|
|
14087
|
+
const candidate = join41(directory, "package.json");
|
|
13904
14088
|
const manifest = readManifest(candidate);
|
|
13905
14089
|
if (manifest && manifestName(manifest, "") === expectedName)
|
|
13906
14090
|
return candidate;
|
|
@@ -13920,27 +14104,27 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13920
14104
|
}
|
|
13921
14105
|
}
|
|
13922
14106
|
}, findInstallRoot = (cwd) => {
|
|
13923
|
-
let directory =
|
|
14107
|
+
let directory = resolve32(cwd);
|
|
13924
14108
|
for (;; ) {
|
|
13925
|
-
if (existsSync36(
|
|
14109
|
+
if (existsSync36(join41(directory, "bun.lock")) || existsSync36(join41(directory, "bun.lockb"))) {
|
|
13926
14110
|
return directory;
|
|
13927
14111
|
}
|
|
13928
14112
|
const parent = dirname24(directory);
|
|
13929
14113
|
if (parent === directory)
|
|
13930
|
-
return
|
|
14114
|
+
return resolve32(cwd);
|
|
13931
14115
|
directory = parent;
|
|
13932
14116
|
}
|
|
13933
14117
|
}, findProjectManifest = (cwd, installRoot) => {
|
|
13934
|
-
let directory =
|
|
14118
|
+
let directory = resolve32(cwd);
|
|
13935
14119
|
for (;; ) {
|
|
13936
|
-
const candidate =
|
|
14120
|
+
const candidate = join41(directory, "package.json");
|
|
13937
14121
|
if (existsSync36(candidate))
|
|
13938
14122
|
return candidate;
|
|
13939
14123
|
if (directory === installRoot)
|
|
13940
|
-
return
|
|
14124
|
+
return join41(installRoot, "package.json");
|
|
13941
14125
|
const parent = dirname24(directory);
|
|
13942
14126
|
if (parent === directory)
|
|
13943
|
-
return
|
|
14127
|
+
return join41(installRoot, "package.json");
|
|
13944
14128
|
directory = parent;
|
|
13945
14129
|
}
|
|
13946
14130
|
}, appendConsumer = (consumers, consumerPaths, path, manifest) => {
|
|
@@ -13978,7 +14162,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13978
14162
|
appendConsumer(consumers, consumerPaths, inspection.consumer.path, inspection.consumer.manifest);
|
|
13979
14163
|
}, inspectTypeGraph = (cwd) => {
|
|
13980
14164
|
const installRoot = findInstallRoot(cwd);
|
|
13981
|
-
const rootManifestPath =
|
|
14165
|
+
const rootManifestPath = join41(installRoot, "package.json");
|
|
13982
14166
|
const rootManifest = readManifest(rootManifestPath) ?? {};
|
|
13983
14167
|
const consumers = [
|
|
13984
14168
|
{ manifest: rootManifest, path: rootManifestPath }
|
|
@@ -14014,7 +14198,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
14014
14198
|
const duplicates = duplicateTypeGraphPackages(report);
|
|
14015
14199
|
if (duplicates.length === 0)
|
|
14016
14200
|
return [];
|
|
14017
|
-
const manifestPath =
|
|
14201
|
+
const manifestPath = join41(report.installRoot, "package.json");
|
|
14018
14202
|
const manifest = readManifest(manifestPath);
|
|
14019
14203
|
if (!manifest)
|
|
14020
14204
|
return [];
|
|
@@ -14036,7 +14220,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
14036
14220
|
}
|
|
14037
14221
|
return changes;
|
|
14038
14222
|
}, removeDuplicateTypeGraphPackages = (report) => {
|
|
14039
|
-
const manifest = readManifest(
|
|
14223
|
+
const manifest = readManifest(join41(report.installRoot, "package.json")) ?? {};
|
|
14040
14224
|
const rootName = manifestName(manifest, "<workspace>");
|
|
14041
14225
|
const installPrefix = `${realpathSync2(report.installRoot)}${sep5}`;
|
|
14042
14226
|
const nodeModulesSegment = `${sep5}node_modules${sep5}`;
|
|
@@ -14075,10 +14259,10 @@ var exports_doctor = {};
|
|
|
14075
14259
|
__export(exports_doctor, {
|
|
14076
14260
|
runDoctor: () => runDoctor
|
|
14077
14261
|
});
|
|
14078
|
-
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";
|
|
14079
14263
|
import { createRequire as createRequire2 } from "module";
|
|
14080
14264
|
import { arch as arch4, platform as platform5 } from "os";
|
|
14081
|
-
import { join as
|
|
14265
|
+
import { join as join42 } from "path";
|
|
14082
14266
|
var FRAMEWORK_FIELDS2, projectRequire, check = (status2, label, detail) => ({
|
|
14083
14267
|
detail,
|
|
14084
14268
|
label,
|
|
@@ -14113,7 +14297,7 @@ var FRAMEWORK_FIELDS2, projectRequire, check = (status2, label, detail) => ({
|
|
|
14113
14297
|
return [];
|
|
14114
14298
|
const label = `${field.replace("Directory", "")} pages`;
|
|
14115
14299
|
return [
|
|
14116
|
-
existsSync37(
|
|
14300
|
+
existsSync37(join42(process.cwd(), dir)) ? check("ok", label, dir) : check("fail", label, `${dir} (missing)`)
|
|
14117
14301
|
];
|
|
14118
14302
|
}), envCheck = async () => {
|
|
14119
14303
|
const vars = await collectEnvVars();
|
|
@@ -14175,9 +14359,9 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
14175
14359
|
const fixes = [];
|
|
14176
14360
|
for (const field of FRAMEWORK_FIELDS2) {
|
|
14177
14361
|
const dir = readString2(config, field);
|
|
14178
|
-
if (dir === undefined || existsSync37(
|
|
14362
|
+
if (dir === undefined || existsSync37(join42(cwd, dir)))
|
|
14179
14363
|
continue;
|
|
14180
|
-
mkdirSync16(
|
|
14364
|
+
mkdirSync16(join42(cwd, dir, "pages"), { recursive: true });
|
|
14181
14365
|
fixes.push(`created ${dir}/pages`);
|
|
14182
14366
|
}
|
|
14183
14367
|
return fixes;
|
|
@@ -14185,8 +14369,8 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
14185
14369
|
const missing = (await collectEnvVars()).filter((entry) => !entry.set);
|
|
14186
14370
|
if (missing.length === 0)
|
|
14187
14371
|
return null;
|
|
14188
|
-
const envExample =
|
|
14189
|
-
const existing = existsSync37(envExample) ?
|
|
14372
|
+
const envExample = join42(cwd, ".env.example");
|
|
14373
|
+
const existing = existsSync37(envExample) ? readFileSync36(envExample, "utf-8") : "";
|
|
14190
14374
|
const existingKeys = new Set(existing.split(`
|
|
14191
14375
|
`).map((line) => line.split("=")[0]?.trim()));
|
|
14192
14376
|
const toAdd = missing.filter((entry) => !existingKeys.has(entry.key));
|
|
@@ -14256,7 +14440,7 @@ var init_doctor = __esm(() => {
|
|
|
14256
14440
|
"htmlDirectory",
|
|
14257
14441
|
"htmxDirectory"
|
|
14258
14442
|
];
|
|
14259
|
-
projectRequire = createRequire2(
|
|
14443
|
+
projectRequire = createRequire2(join42(process.cwd(), "package.json"));
|
|
14260
14444
|
STATUS_MARK = {
|
|
14261
14445
|
fail: `${colors.red}\u2717${colors.reset}`,
|
|
14262
14446
|
ok: `${colors.green}\u2713${colors.reset}`,
|
|
@@ -14645,8 +14829,8 @@ var init_sourceMetadata = __esm(() => {
|
|
|
14645
14829
|
});
|
|
14646
14830
|
|
|
14647
14831
|
// src/islands/pageMetadata.ts
|
|
14648
|
-
import { readFileSync as
|
|
14649
|
-
import { dirname as dirname25, resolve as
|
|
14832
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
14833
|
+
import { dirname as dirname25, resolve as resolve33 } from "path";
|
|
14650
14834
|
var pagePatterns, getPageDirs = (config) => [
|
|
14651
14835
|
{ dir: config.angularDirectory, framework: "angular" },
|
|
14652
14836
|
{ dir: config.emberDirectory, framework: "ember" },
|
|
@@ -14666,8 +14850,8 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
14666
14850
|
const source = definition.buildReference?.source;
|
|
14667
14851
|
if (!source)
|
|
14668
14852
|
continue;
|
|
14669
|
-
const resolvedSource = source.startsWith("file://") ? new URL(source).pathname :
|
|
14670
|
-
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));
|
|
14671
14855
|
}
|
|
14672
14856
|
return lookup;
|
|
14673
14857
|
}, resolveIslandUsages = (islands, islandSourceLookup) => islands.map((usage2) => {
|
|
@@ -14680,13 +14864,13 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
14680
14864
|
const pattern = pagePatterns[entry.framework];
|
|
14681
14865
|
if (!pattern)
|
|
14682
14866
|
return;
|
|
14683
|
-
const files = await scanEntryPoints(
|
|
14867
|
+
const files = await scanEntryPoints(resolve33(entry.dir), pattern);
|
|
14684
14868
|
for (const filePath of files) {
|
|
14685
|
-
const source =
|
|
14869
|
+
const source = readFileSync37(filePath, "utf-8");
|
|
14686
14870
|
const islands = extractIslandUsagesFromSource(source);
|
|
14687
|
-
pageMetadata.set(
|
|
14871
|
+
pageMetadata.set(resolve33(filePath), {
|
|
14688
14872
|
islands: resolveIslandUsages(islands, islandSourceLookup),
|
|
14689
|
-
pagePath:
|
|
14873
|
+
pagePath: resolve33(filePath)
|
|
14690
14874
|
});
|
|
14691
14875
|
}
|
|
14692
14876
|
}, loadPageIslandMetadata = async (config) => {
|
|
@@ -14715,14 +14899,14 @@ var exports_islands = {};
|
|
|
14715
14899
|
__export(exports_islands, {
|
|
14716
14900
|
runIslands: () => runIslands
|
|
14717
14901
|
});
|
|
14718
|
-
import { existsSync as existsSync39, readFileSync as
|
|
14719
|
-
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";
|
|
14720
14904
|
var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.write(`${colors.dim}${message}${colors.reset}
|
|
14721
14905
|
`), hostFrameworkOf = (pagePath, cwd, config) => {
|
|
14722
|
-
const resolved =
|
|
14906
|
+
const resolved = resolve34(cwd, pagePath);
|
|
14723
14907
|
for (const [framework, key] of Object.entries(FRAMEWORK_DIR_KEY)) {
|
|
14724
14908
|
const dir = config[key];
|
|
14725
|
-
if (typeof dir === "string" && resolved.startsWith(
|
|
14909
|
+
if (typeof dir === "string" && resolved.startsWith(resolve34(cwd, dir))) {
|
|
14726
14910
|
return framework;
|
|
14727
14911
|
}
|
|
14728
14912
|
}
|
|
@@ -14734,20 +14918,20 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14734
14918
|
return 0;
|
|
14735
14919
|
}
|
|
14736
14920
|
}, readManifestSizes2 = (manifestDir) => {
|
|
14737
|
-
const manifestPath =
|
|
14921
|
+
const manifestPath = join43(manifestDir, "manifest.json");
|
|
14738
14922
|
if (!existsSync39(manifestPath))
|
|
14739
14923
|
return null;
|
|
14740
|
-
const manifest = JSON.parse(
|
|
14924
|
+
const manifest = JSON.parse(readFileSync38(manifestPath, "utf-8"));
|
|
14741
14925
|
const sizes = new Map;
|
|
14742
14926
|
for (const [key, value] of Object.entries(manifest)) {
|
|
14743
|
-
sizes.set(key, fileSize3(
|
|
14927
|
+
sizes.set(key, fileSize3(join43(manifestDir, value.replace(/^\//, ""))));
|
|
14744
14928
|
}
|
|
14745
14929
|
return sizes;
|
|
14746
14930
|
}, collectIslands = async (cwd, config, sizes) => {
|
|
14747
14931
|
const registryPath = config.islands?.registry;
|
|
14748
14932
|
if (typeof registryPath !== "string")
|
|
14749
14933
|
return null;
|
|
14750
|
-
const buildInfo = await loadIslandRegistryBuildInfo(
|
|
14934
|
+
const buildInfo = await loadIslandRegistryBuildInfo(resolve34(cwd, registryPath));
|
|
14751
14935
|
const pageMetadata = await loadPageIslandMetadata(config);
|
|
14752
14936
|
const usages = [...pageMetadata.values()].flatMap((meta) => meta.islands.map((island) => ({ ...island, page: meta.pagePath })));
|
|
14753
14937
|
return buildInfo.definitions.map((definition) => {
|
|
@@ -14757,7 +14941,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14757
14941
|
crossFramework: hostFramework !== null && hostFramework !== definition.framework,
|
|
14758
14942
|
hostFramework,
|
|
14759
14943
|
hydrate: usage2.hydrate ?? "load",
|
|
14760
|
-
page:
|
|
14944
|
+
page: relative22(cwd, resolve34(cwd, usage2.page))
|
|
14761
14945
|
};
|
|
14762
14946
|
});
|
|
14763
14947
|
const key = getIslandManifestKey(definition.framework, definition.component);
|
|
@@ -14796,7 +14980,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14796
14980
|
` ${color}\u2B21${colors.reset} ${colors.bold}${island.component}${colors.reset} ${meta}${sizeText}`
|
|
14797
14981
|
];
|
|
14798
14982
|
if (island.source) {
|
|
14799
|
-
lines.push(` ${colors.dim}${
|
|
14983
|
+
lines.push(` ${colors.dim}${relative22(cwd, island.source)}${colors.reset}`);
|
|
14800
14984
|
}
|
|
14801
14985
|
if (pages.length === 0) {
|
|
14802
14986
|
lines.push(` ${colors.dim}(registered but not mounted on any page)${colors.reset}`);
|
|
@@ -14826,7 +15010,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14826
15010
|
}
|
|
14827
15011
|
const outdirIndex = args.indexOf("--outdir");
|
|
14828
15012
|
const outdir = outdirIndex >= 0 ? args[outdirIndex + 1] : config.buildDirectory;
|
|
14829
|
-
const sizes = args.includes("--sizes") ? readManifestSizes2(
|
|
15013
|
+
const sizes = args.includes("--sizes") ? readManifestSizes2(resolve34(cwd, outdir ?? "build")) : null;
|
|
14830
15014
|
const islands = await collectIslands(cwd, config, sizes);
|
|
14831
15015
|
if (islands === null) {
|
|
14832
15016
|
printDim6('No island registry configured. Set `islands: { registry: "..." }` in absolute.config.ts.');
|
|
@@ -14876,12 +15060,12 @@ var init_islands2 = __esm(() => {
|
|
|
14876
15060
|
|
|
14877
15061
|
// src/build/externalAssetPlugin.ts
|
|
14878
15062
|
import { copyFileSync as copyFileSync2, existsSync as existsSync40, mkdirSync as mkdirSync17, statSync as statSync6 } from "fs";
|
|
14879
|
-
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";
|
|
14880
15064
|
var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
14881
15065
|
name: "absolute-external-asset",
|
|
14882
15066
|
setup(bld) {
|
|
14883
15067
|
const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
|
|
14884
|
-
const skipRoots = userSourceRoots.map((root) =>
|
|
15068
|
+
const skipRoots = userSourceRoots.map((root) => resolve35(root));
|
|
14885
15069
|
const isUserSource = (path) => skipRoots.some((root) => path.startsWith(`${root}/`));
|
|
14886
15070
|
bld.onLoad({ filter: /\.[mc]?[jt]sx?$/ }, async (args) => {
|
|
14887
15071
|
if (isUserSource(args.path))
|
|
@@ -14896,12 +15080,12 @@ var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
|
14896
15080
|
const relPath = match[1];
|
|
14897
15081
|
if (!relPath)
|
|
14898
15082
|
continue;
|
|
14899
|
-
const assetPath =
|
|
15083
|
+
const assetPath = resolve35(sourceDir, relPath);
|
|
14900
15084
|
if (!existsSync40(assetPath))
|
|
14901
15085
|
continue;
|
|
14902
15086
|
if (!statSync6(assetPath).isFile())
|
|
14903
15087
|
continue;
|
|
14904
|
-
const targetPath =
|
|
15088
|
+
const targetPath = join44(outDir, basename11(assetPath));
|
|
14905
15089
|
if (existsSync40(targetPath))
|
|
14906
15090
|
continue;
|
|
14907
15091
|
mkdirSync17(dirname26(targetPath), { recursive: true });
|
|
@@ -14925,7 +15109,7 @@ import {
|
|
|
14925
15109
|
existsSync as existsSync41,
|
|
14926
15110
|
mkdirSync as mkdirSync18,
|
|
14927
15111
|
readdirSync as readdirSync7,
|
|
14928
|
-
readFileSync as
|
|
15112
|
+
readFileSync as readFileSync39,
|
|
14929
15113
|
rmSync as rmSync7,
|
|
14930
15114
|
statSync as statSync7,
|
|
14931
15115
|
unlinkSync as unlinkSync4,
|
|
@@ -14936,9 +15120,9 @@ import {
|
|
|
14936
15120
|
basename as basename12,
|
|
14937
15121
|
dirname as dirname27,
|
|
14938
15122
|
isAbsolute as isAbsolute6,
|
|
14939
|
-
join as
|
|
14940
|
-
relative as
|
|
14941
|
-
resolve as
|
|
15123
|
+
join as join45,
|
|
15124
|
+
relative as relative23,
|
|
15125
|
+
resolve as resolve36
|
|
14942
15126
|
} from "path";
|
|
14943
15127
|
var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
|
|
14944
15128
|
const resolvedVersion = version2 || "unknown";
|
|
@@ -14952,7 +15136,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14952
15136
|
const entry = pending.pop();
|
|
14953
15137
|
if (!entry)
|
|
14954
15138
|
continue;
|
|
14955
|
-
const fullPath =
|
|
15139
|
+
const fullPath = join45(entry.parentPath, entry.name);
|
|
14956
15140
|
if (entry.isDirectory())
|
|
14957
15141
|
pending = pending.concat(readdirSync7(fullPath, { withFileTypes: true }));
|
|
14958
15142
|
else
|
|
@@ -14960,7 +15144,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14960
15144
|
}
|
|
14961
15145
|
return result;
|
|
14962
15146
|
}, INLINE_SOURCE_MAP_RE, rebaseInlineSourceMap = (filePath) => {
|
|
14963
|
-
const source =
|
|
15147
|
+
const source = readFileSync39(filePath, "utf-8");
|
|
14964
15148
|
const match = source.match(INLINE_SOURCE_MAP_RE);
|
|
14965
15149
|
const encoded = match?.[1];
|
|
14966
15150
|
if (!encoded)
|
|
@@ -14980,7 +15164,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14980
15164
|
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(sourceRoot)) {
|
|
14981
15165
|
return new URL(entry, sourceRoot).href;
|
|
14982
15166
|
}
|
|
14983
|
-
return
|
|
15167
|
+
return resolve36(bundleDirectory, sourceRoot, entry);
|
|
14984
15168
|
});
|
|
14985
15169
|
delete map.sourceRoot;
|
|
14986
15170
|
const rebased = Buffer.from(JSON.stringify(map)).toString("base64");
|
|
@@ -14998,7 +15182,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14998
15182
|
const entry = pending.pop();
|
|
14999
15183
|
if (!entry)
|
|
15000
15184
|
continue;
|
|
15001
|
-
const fullPath =
|
|
15185
|
+
const fullPath = join45(entry.parentPath, entry.name);
|
|
15002
15186
|
if (entry.isDirectory()) {
|
|
15003
15187
|
if (SERVER_RUNTIME_SCAN_SKIP_DIRS.has(entry.name))
|
|
15004
15188
|
continue;
|
|
@@ -15010,12 +15194,12 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15010
15194
|
return result;
|
|
15011
15195
|
}, copyServerRuntimeAssetReferences = (outdir) => {
|
|
15012
15196
|
const copied = new Set;
|
|
15013
|
-
const normalizedOutdir =
|
|
15197
|
+
const normalizedOutdir = resolve36(outdir);
|
|
15014
15198
|
const copyReference = (filePath, relPath) => {
|
|
15015
|
-
const assetSource =
|
|
15199
|
+
const assetSource = resolve36(dirname27(filePath), relPath);
|
|
15016
15200
|
if (!existsSync41(assetSource) || !statSync7(assetSource).isFile())
|
|
15017
15201
|
return;
|
|
15018
|
-
const assetTarget =
|
|
15202
|
+
const assetTarget = resolve36(normalizedOutdir, relPath.replace(/^\.\//, ""));
|
|
15019
15203
|
if (assetTarget !== normalizedOutdir && !assetTarget.startsWith(`${normalizedOutdir}/`))
|
|
15020
15204
|
return;
|
|
15021
15205
|
if (copied.has(assetTarget))
|
|
@@ -15025,7 +15209,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15025
15209
|
cpSync(assetSource, assetTarget, { force: true });
|
|
15026
15210
|
};
|
|
15027
15211
|
for (const filePath of collectProjectSourceFiles(process.cwd())) {
|
|
15028
|
-
const source =
|
|
15212
|
+
const source = readFileSync39(filePath, "utf-8");
|
|
15029
15213
|
SERVER_RUNTIME_ASSET_RE.lastIndex = 0;
|
|
15030
15214
|
let match;
|
|
15031
15215
|
while ((match = SERVER_RUNTIME_ASSET_RE.exec(source)) !== null) {
|
|
@@ -15054,7 +15238,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15054
15238
|
}
|
|
15055
15239
|
}, readPackageVersion4 = (candidate) => {
|
|
15056
15240
|
try {
|
|
15057
|
-
const pkg = JSON.parse(
|
|
15241
|
+
const pkg = JSON.parse(readFileSync39(candidate, "utf-8"));
|
|
15058
15242
|
if (pkg.name !== "@absolutejs/absolute")
|
|
15059
15243
|
return null;
|
|
15060
15244
|
const ver = pkg.version;
|
|
@@ -15089,18 +15273,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15089
15273
|
return resolveBuildModule3(remaining);
|
|
15090
15274
|
}, resolveJsxDevRuntimeCompatPath2 = () => {
|
|
15091
15275
|
const candidates = [
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
|
|
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")
|
|
15098
15282
|
];
|
|
15099
15283
|
for (const candidate of candidates) {
|
|
15100
15284
|
if (existsSync41(candidate))
|
|
15101
15285
|
return candidate;
|
|
15102
15286
|
}
|
|
15103
|
-
return
|
|
15287
|
+
return resolve36(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
|
|
15104
15288
|
}, jsxDevRuntimeCompatPath2, shouldEmbedCompiledAsset = (relativePath, skip = new Set) => {
|
|
15105
15289
|
if (skip.has(relativePath))
|
|
15106
15290
|
return false;
|
|
@@ -15125,7 +15309,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15125
15309
|
return true;
|
|
15126
15310
|
}), requireForCompile, resolveNativeAssetForRuntime = (specifier) => {
|
|
15127
15311
|
if (specifier.startsWith("."))
|
|
15128
|
-
return
|
|
15312
|
+
return resolve36(process.cwd(), specifier);
|
|
15129
15313
|
if (specifier.startsWith("/"))
|
|
15130
15314
|
return specifier;
|
|
15131
15315
|
return requireForCompile.resolve(specifier, { paths: [process.cwd()] });
|
|
@@ -15137,11 +15321,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15137
15321
|
return nativeAssetEnv;
|
|
15138
15322
|
}, tryReadNodePackageJson = (packageDir) => {
|
|
15139
15323
|
try {
|
|
15140
|
-
return JSON.parse(
|
|
15324
|
+
return JSON.parse(readFileSync39(join45(packageDir, "package.json"), "utf-8"));
|
|
15141
15325
|
} catch {
|
|
15142
15326
|
return null;
|
|
15143
15327
|
}
|
|
15144
|
-
}, resolveProjectPackageDir = (specifier) =>
|
|
15328
|
+
}, resolveProjectPackageDir = (specifier) => resolve36(process.cwd(), "node_modules", ...specifier.split("/")), copyPackageToBuild = (specifier, outdir, seen) => {
|
|
15145
15329
|
if (seen.has(specifier))
|
|
15146
15330
|
return;
|
|
15147
15331
|
const srcDir = resolveProjectPackageDir(specifier);
|
|
@@ -15149,13 +15333,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15149
15333
|
if (!pkg)
|
|
15150
15334
|
return;
|
|
15151
15335
|
seen.add(specifier);
|
|
15152
|
-
const destDir =
|
|
15336
|
+
const destDir = join45(outdir, "node_modules", ...specifier.split("/"));
|
|
15153
15337
|
rmSync7(destDir, { force: true, recursive: true });
|
|
15154
15338
|
cpSync(srcDir, destDir, {
|
|
15155
15339
|
force: true,
|
|
15156
15340
|
recursive: true,
|
|
15157
15341
|
filter(source) {
|
|
15158
|
-
const rel =
|
|
15342
|
+
const rel = relative23(srcDir, source);
|
|
15159
15343
|
const [firstSegment] = rel.split(/[\\/]/);
|
|
15160
15344
|
return firstSegment !== "node_modules" && firstSegment !== ".git";
|
|
15161
15345
|
}
|
|
@@ -15171,7 +15355,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15171
15355
|
}, copyAngularRuntimePackages = (buildConfig, outdir) => {
|
|
15172
15356
|
if (!buildConfig.angularDirectory)
|
|
15173
15357
|
return;
|
|
15174
|
-
const angularScopeDir =
|
|
15358
|
+
const angularScopeDir = resolve36(process.cwd(), "node_modules", "@angular");
|
|
15175
15359
|
const angularPackages = existsSync41(angularScopeDir) ? readdirSync7(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
|
|
15176
15360
|
const roots = new Set([...angularPackages, "rxjs", "tslib", "typescript"]);
|
|
15177
15361
|
const seen = new Set;
|
|
@@ -15190,7 +15374,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15190
15374
|
copyAngularRuntimePackages(buildConfig, outdir);
|
|
15191
15375
|
copyChunkReferencedPackages(outdir, seen);
|
|
15192
15376
|
}, collectRuntimePackageSpecifiers = (distDir) => {
|
|
15193
|
-
const nodeModulesDir =
|
|
15377
|
+
const nodeModulesDir = join45(distDir, "node_modules");
|
|
15194
15378
|
if (!existsSync41(nodeModulesDir))
|
|
15195
15379
|
return [];
|
|
15196
15380
|
const specifiers = [];
|
|
@@ -15198,7 +15382,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15198
15382
|
if (!entry.isDirectory())
|
|
15199
15383
|
continue;
|
|
15200
15384
|
if (entry.name.startsWith("@")) {
|
|
15201
|
-
const scopeDir =
|
|
15385
|
+
const scopeDir = join45(nodeModulesDir, entry.name);
|
|
15202
15386
|
for (const scopedEntry of readdirSync7(scopeDir, {
|
|
15203
15387
|
withFileTypes: true
|
|
15204
15388
|
})) {
|
|
@@ -15212,7 +15396,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15212
15396
|
}
|
|
15213
15397
|
return specifiers.sort((firstSpecifier, secondSpecifier) => secondSpecifier.length - firstSpecifier.length);
|
|
15214
15398
|
}, ensureRelativeModuleSpecifier = (fromFile, toFile) => {
|
|
15215
|
-
const rel =
|
|
15399
|
+
const rel = relative23(dirname27(fromFile), toFile).replace(/\\/g, "/");
|
|
15216
15400
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
15217
15401
|
}, pickExportEntry = (value) => {
|
|
15218
15402
|
if (typeof value === "string")
|
|
@@ -15229,18 +15413,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15229
15413
|
const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
|
|
15230
15414
|
if (!packageSpecifier)
|
|
15231
15415
|
return null;
|
|
15232
|
-
const packageDir =
|
|
15416
|
+
const packageDir = join45(distDir, "node_modules", ...packageSpecifier.split("/"));
|
|
15233
15417
|
const subpath = specifier.slice(packageSpecifier.length);
|
|
15234
|
-
const subPackageDir = subpath ?
|
|
15235
|
-
const resolvedPackageDir = subPackageDir && existsSync41(
|
|
15236
|
-
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");
|
|
15237
15421
|
if (!existsSync41(packageJsonPath))
|
|
15238
15422
|
return null;
|
|
15239
|
-
const pkg = JSON.parse(
|
|
15423
|
+
const pkg = JSON.parse(readFileSync39(packageJsonPath, "utf-8"));
|
|
15240
15424
|
const exportKey = resolvedPackageDir !== subPackageDir && subpath ? `.${subpath}` : ".";
|
|
15241
15425
|
const rootExport = pkg.exports?.[exportKey];
|
|
15242
15426
|
const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
|
|
15243
|
-
return
|
|
15427
|
+
return join45(resolvedPackageDir, entry);
|
|
15244
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) => {
|
|
15245
15429
|
try {
|
|
15246
15430
|
return statSync7(filePath).isFile();
|
|
@@ -15253,13 +15437,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15253
15437
|
const candidates = [
|
|
15254
15438
|
candidate,
|
|
15255
15439
|
...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
|
|
15256
|
-
...RUNTIME_JS_EXTENSIONS.map((extension) =>
|
|
15440
|
+
...RUNTIME_JS_EXTENSIONS.map((extension) => join45(candidate, `index${extension}`))
|
|
15257
15441
|
];
|
|
15258
15442
|
return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
|
|
15259
15443
|
}, findContainingRuntimePackageDir = (filePath) => {
|
|
15260
15444
|
let dir = dirname27(filePath);
|
|
15261
15445
|
while (dir !== dirname27(dir)) {
|
|
15262
|
-
if (isNodeModulesPath(dir) && existsSync41(
|
|
15446
|
+
if (isNodeModulesPath(dir) && existsSync41(join45(dir, "package.json"))) {
|
|
15263
15447
|
return dir;
|
|
15264
15448
|
}
|
|
15265
15449
|
dir = dirname27(dir);
|
|
@@ -15275,13 +15459,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15275
15459
|
const entry = pickExportEntry(pkg?.imports?.[specifier]);
|
|
15276
15460
|
if (!entry)
|
|
15277
15461
|
return null;
|
|
15278
|
-
return
|
|
15462
|
+
return join45(packageDir, entry);
|
|
15279
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) => {
|
|
15280
|
-
const distRoot =
|
|
15464
|
+
const distRoot = resolve36(distDir);
|
|
15281
15465
|
for (const filePath of collectRuntimeRewriteRoots(distDir)) {
|
|
15282
|
-
if (
|
|
15466
|
+
if (resolve36(dirname27(filePath)) === distRoot)
|
|
15283
15467
|
continue;
|
|
15284
|
-
const source =
|
|
15468
|
+
const source = readFileSync39(filePath, "utf-8");
|
|
15285
15469
|
for (const match of source.matchAll(MODULE_SPECIFIER_RE)) {
|
|
15286
15470
|
const [, , , specifier] = match;
|
|
15287
15471
|
if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.startsWith("node:") || specifier.startsWith("bun:")) {
|
|
@@ -15311,11 +15495,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15311
15495
|
if (!filePath || seen.has(filePath))
|
|
15312
15496
|
continue;
|
|
15313
15497
|
seen.add(filePath);
|
|
15314
|
-
const source =
|
|
15498
|
+
const source = readFileSync39(filePath, "utf-8");
|
|
15315
15499
|
const { masked, restore } = maskLiterals(source);
|
|
15316
15500
|
const rewrittenMasked = masked.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
|
|
15317
15501
|
if (typeof specifier === "string" && specifier.startsWith(".")) {
|
|
15318
|
-
enqueue(resolveRuntimeJsFile(
|
|
15502
|
+
enqueue(resolveRuntimeJsFile(resolve36(dirname27(filePath), specifier)));
|
|
15319
15503
|
return match;
|
|
15320
15504
|
}
|
|
15321
15505
|
const packageImportTarget = resolveRuntimeJsFile(resolvePackageImportEntryFile(filePath, specifier) ?? "");
|
|
@@ -15344,12 +15528,12 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15344
15528
|
"_compile_entrypoint.ts"
|
|
15345
15529
|
]);
|
|
15346
15530
|
const embeddedFiles = allFiles.filter((file) => {
|
|
15347
|
-
const rel =
|
|
15531
|
+
const rel = relative23(distDir, file);
|
|
15348
15532
|
if (embeddedSkip.has(rel))
|
|
15349
15533
|
return false;
|
|
15350
15534
|
return true;
|
|
15351
15535
|
});
|
|
15352
|
-
const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(
|
|
15536
|
+
const clientFiles = embeddedFiles.filter((file) => shouldEmbedCompiledAsset(relative23(distDir, file), assetSkip));
|
|
15353
15537
|
const imports = [];
|
|
15354
15538
|
const nativeImports = [];
|
|
15355
15539
|
const nativeMappings = [];
|
|
@@ -15359,19 +15543,19 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15359
15543
|
const nativeAssets = resolveCompileNativeAssets(buildConfig);
|
|
15360
15544
|
nativeAssets.forEach((asset, idx) => {
|
|
15361
15545
|
const varName = `__native${idx}`;
|
|
15362
|
-
const importSpecifier = asset.import.startsWith(".") ?
|
|
15546
|
+
const importSpecifier = asset.import.startsWith(".") ? resolve36(process.cwd(), asset.import) : asset.import;
|
|
15363
15547
|
nativeImports.push(`import ${varName} from ${JSON.stringify(importSpecifier)} with { type: "file" };`);
|
|
15364
15548
|
nativeMappings.push(` [${JSON.stringify(asset.env)}, resolveNativeAssetPath(${varName})],`);
|
|
15365
15549
|
});
|
|
15366
15550
|
embeddedFiles.forEach((filePath, idx) => {
|
|
15367
|
-
const rel =
|
|
15551
|
+
const rel = relative23(distDir, filePath).replace(/\\/g, "/");
|
|
15368
15552
|
const varName = `__a${idx}`;
|
|
15369
15553
|
embeddedVarMap.set(rel, varName);
|
|
15370
15554
|
imports.push(`import ${varName} from "./${rel}" with { type: "file" };`);
|
|
15371
15555
|
embeddedMappings.push(` ["${rel}", ${varName}],`);
|
|
15372
15556
|
});
|
|
15373
15557
|
clientFiles.forEach((filePath) => {
|
|
15374
|
-
const rel =
|
|
15558
|
+
const rel = relative23(distDir, filePath).replace(/\\/g, "/");
|
|
15375
15559
|
const varName = embeddedVarMap.get(rel);
|
|
15376
15560
|
if (!varName)
|
|
15377
15561
|
return;
|
|
@@ -15385,7 +15569,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
15385
15569
|
const pageVarMap = new Map;
|
|
15386
15570
|
const prerenderEntries = Array.from(prerenderMap.entries());
|
|
15387
15571
|
prerenderEntries.forEach(([route, filePath]) => {
|
|
15388
|
-
const rel =
|
|
15572
|
+
const rel = relative23(distDir, filePath).replace(/\\/g, "/");
|
|
15389
15573
|
const varName = embeddedVarMap.get(rel);
|
|
15390
15574
|
if (varName)
|
|
15391
15575
|
pageVarMap.set(route, varName);
|
|
@@ -15418,7 +15602,7 @@ import { buildGlobalWSHandler } from "elysia/ws";
|
|
|
15418
15602
|
const SERVER_MODULE = (runtimeDir: string) => import(pathToFileURL(join(runtimeDir, ${JSON.stringify(serverBundleName)})).href);
|
|
15419
15603
|
const RUNTIME_BUILD_ID = ${JSON.stringify(runtimeBuildId)};
|
|
15420
15604
|
const RUNTIME_CONFIG_SOURCE = ${JSON.stringify(runtimeConfigSource)};
|
|
15421
|
-
const ORIGINAL_BUILD_DIR = ${JSON.stringify(
|
|
15605
|
+
const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve36(distDir))};
|
|
15422
15606
|
const ORIGINAL_BUILD_DIR_NORMALIZED = ORIGINAL_BUILD_DIR.replace(/\\\\/g, "/");
|
|
15423
15607
|
const EMBEDDED_NATIVE_AUTH_CLIENTS = ${JSON.stringify(process.env[ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV])};
|
|
15424
15608
|
|
|
@@ -15831,25 +16015,25 @@ console.log(\`
|
|
|
15831
16015
|
const normalizedPath = args.path.replace(/\\/g, "/");
|
|
15832
16016
|
if (normalizedPath.includes("/src/angular/"))
|
|
15833
16017
|
return;
|
|
15834
|
-
const
|
|
15835
|
-
if (
|
|
16018
|
+
const text2 = await Bun.file(args.path).text();
|
|
16019
|
+
if (text2.includes("@Component") && stripStringsAndComments(text2).includes("@Component")) {
|
|
15836
16020
|
return { contents: "export default {}", loader: "js" };
|
|
15837
16021
|
}
|
|
15838
16022
|
return;
|
|
15839
16023
|
});
|
|
15840
16024
|
}
|
|
15841
16025
|
}), compile = async (serverEntry, outdir, outfile, configPath2) => {
|
|
15842
|
-
const resolvedOutdir =
|
|
16026
|
+
const resolvedOutdir = resolve36(outdir ?? "dist");
|
|
15843
16027
|
await withBuildDirectoryLock(resolvedOutdir, () => compileUnlocked(serverEntry, resolvedOutdir, outfile, configPath2));
|
|
15844
16028
|
}, compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath2) => {
|
|
15845
16029
|
const configuredPrerenderPort = env5.COMPILE_PORT === undefined ? Number(env5.PORT) : Number(env5.COMPILE_PORT);
|
|
15846
16030
|
const prerenderPort = configuredPrerenderPort > 0 ? configuredPrerenderPort : await findFreePort();
|
|
15847
16031
|
killStaleProcesses(prerenderPort);
|
|
15848
16032
|
const entryName = basename12(serverEntry).replace(/\.[^.]+$/, "");
|
|
15849
|
-
const resolvedOutfile =
|
|
16033
|
+
const resolvedOutfile = resolve36(outfile ?? "compiled-server");
|
|
15850
16034
|
const absoluteVersion = resolvePackageVersion3([
|
|
15851
|
-
|
|
15852
|
-
|
|
16035
|
+
resolve36(import.meta.dir, "..", "..", "..", "package.json"),
|
|
16036
|
+
resolve36(import.meta.dir, "..", "..", "package.json")
|
|
15853
16037
|
]);
|
|
15854
16038
|
compileBanner(absoluteVersion);
|
|
15855
16039
|
const totalStart = performance.now();
|
|
@@ -15862,8 +16046,8 @@ console.log(\`
|
|
|
15862
16046
|
installAbsoluteMobileAuthEnvironment(process.cwd(), normalizeAbsoluteMobileConfig(buildConfig.mobile, process.cwd()));
|
|
15863
16047
|
try {
|
|
15864
16048
|
const build2 = await resolveBuildModule3([
|
|
15865
|
-
|
|
15866
|
-
|
|
16049
|
+
resolve36(import.meta.dir, "..", "..", "core", "build"),
|
|
16050
|
+
resolve36(import.meta.dir, "..", "build")
|
|
15867
16051
|
]);
|
|
15868
16052
|
if (!build2)
|
|
15869
16053
|
throw new Error("Could not locate build module");
|
|
@@ -15885,11 +16069,11 @@ console.log(\`
|
|
|
15885
16069
|
buildConfig.htmxDirectory
|
|
15886
16070
|
].filter((dir) => Boolean(dir));
|
|
15887
16071
|
const islandRegistrySpec = buildConfig.islands?.registry;
|
|
15888
|
-
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(
|
|
15889
|
-
const serverBundleEntryDirectory =
|
|
16072
|
+
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve36(islandRegistrySpec))) : undefined;
|
|
16073
|
+
const serverBundleEntryDirectory = join45(resolvedOutdir, ".absolutejs-server-entry");
|
|
15890
16074
|
mkdirSync18(serverBundleEntryDirectory, { recursive: true });
|
|
15891
|
-
const typeboxSetupEntry =
|
|
15892
|
-
const serverBundleEntry =
|
|
16075
|
+
const typeboxSetupEntry = join45(serverBundleEntryDirectory, "_typebox_setup.ts");
|
|
16076
|
+
const serverBundleEntry = join45(serverBundleEntryDirectory, basename12(serverEntry));
|
|
15893
16077
|
writeFileSync21(typeboxSetupEntry, `import { setupTypebox } from 'elysia';
|
|
15894
16078
|
import * as compile from 'typebox/compile';
|
|
15895
16079
|
import * as schema from 'typebox/schema';
|
|
@@ -15900,7 +16084,7 @@ import * as value from 'typebox/value';
|
|
|
15900
16084
|
setupTypebox({ typebox: { compile, schema, system, type, value } });
|
|
15901
16085
|
`);
|
|
15902
16086
|
writeFileSync21(serverBundleEntry, `import './_typebox_setup';
|
|
15903
|
-
import * as serverModule from ${JSON.stringify(
|
|
16087
|
+
import * as serverModule from ${JSON.stringify(resolve36(serverEntry))};
|
|
15904
16088
|
|
|
15905
16089
|
export const server = serverModule.server ?? serverModule.app ?? serverModule.default;
|
|
15906
16090
|
export default server;
|
|
@@ -15914,7 +16098,7 @@ export default server;
|
|
|
15914
16098
|
...islandRegistryPlugin ? [islandRegistryPlugin] : [],
|
|
15915
16099
|
...buildConfig.mobile ? [
|
|
15916
16100
|
createAbsoluteMobileRouteMetadataPlugin({
|
|
15917
|
-
entry:
|
|
16101
|
+
entry: resolve36(serverEntry)
|
|
15918
16102
|
})
|
|
15919
16103
|
] : [],
|
|
15920
16104
|
createElysiaOpenApiTypeboxPlugin(),
|
|
@@ -15938,13 +16122,13 @@ export default server;
|
|
|
15938
16122
|
console.error(cliTag4("\x1B[31m", "Server bundle failed."));
|
|
15939
16123
|
process.exit(1);
|
|
15940
16124
|
}
|
|
15941
|
-
const outputPath =
|
|
16125
|
+
const outputPath = resolve36(resolvedOutdir, `${entryName}.js`);
|
|
15942
16126
|
if (!existsSync41(outputPath)) {
|
|
15943
16127
|
console.error(cliTag4("\x1B[31m", `Expected output not found: ${outputPath}`));
|
|
15944
16128
|
process.exit(1);
|
|
15945
16129
|
}
|
|
15946
|
-
if (existsSync41(
|
|
15947
|
-
const vendorDir =
|
|
16130
|
+
if (existsSync41(resolve36(resolvedOutdir, "angular", "vendor", "server"))) {
|
|
16131
|
+
const vendorDir = resolve36(resolvedOutdir, "angular", "vendor", "server");
|
|
15948
16132
|
const vendorEntries = readdirSync7(vendorDir).filter((fileName) => fileName.endsWith(".js"));
|
|
15949
16133
|
const angularServerVendorPaths = {};
|
|
15950
16134
|
for (const file of vendorEntries) {
|
|
@@ -15953,7 +16137,7 @@ export default server;
|
|
|
15953
16137
|
if (scope !== "angular" || rest.length === 0)
|
|
15954
16138
|
continue;
|
|
15955
16139
|
const specifier = `@angular/${rest.join("/")}`;
|
|
15956
|
-
const relPath =
|
|
16140
|
+
const relPath = relative23(dirname27(outputPath), resolve36(vendorDir, file));
|
|
15957
16141
|
angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
15958
16142
|
}
|
|
15959
16143
|
if (Object.keys(angularServerVendorPaths).length > 0) {
|
|
@@ -15965,7 +16149,7 @@ export default server;
|
|
|
15965
16149
|
copyServerRuntimeAssetReferences(resolvedOutdir);
|
|
15966
16150
|
const prerenderStart = performance.now();
|
|
15967
16151
|
process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
|
|
15968
|
-
rmSync7(
|
|
16152
|
+
rmSync7(join45(resolvedOutdir, "_prerendered"), {
|
|
15969
16153
|
force: true,
|
|
15970
16154
|
recursive: true
|
|
15971
16155
|
});
|
|
@@ -15995,7 +16179,7 @@ export default server;
|
|
|
15995
16179
|
const compileStart = performance.now();
|
|
15996
16180
|
process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
|
|
15997
16181
|
const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
|
|
15998
|
-
const entrypointPath =
|
|
16182
|
+
const entrypointPath = join45(resolvedOutdir, "_compile_entrypoint.ts");
|
|
15999
16183
|
await Bun.write(entrypointPath, entrypointCode);
|
|
16000
16184
|
mkdirSync18(dirname27(resolvedOutfile), { recursive: true });
|
|
16001
16185
|
const result = await Bun.build({
|
|
@@ -16081,7 +16265,7 @@ var init_compile = __esm(() => {
|
|
|
16081
16265
|
|
|
16082
16266
|
// src/mobile/nativeDeepLinks.ts
|
|
16083
16267
|
import { readFile as readFile11, rename as rename8, writeFile as writeFile9 } from "fs/promises";
|
|
16084
|
-
import { join as
|
|
16268
|
+
import { join as join46 } from "path";
|
|
16085
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) => {
|
|
16086
16270
|
const current = await readFile11(path, "utf8");
|
|
16087
16271
|
if (current === source)
|
|
@@ -16130,7 +16314,7 @@ ${hosts}
|
|
|
16130
16314
|
${END_MARKER}
|
|
16131
16315
|
`;
|
|
16132
16316
|
}, configureAndroid = async (config) => {
|
|
16133
|
-
const path =
|
|
16317
|
+
const path = join46(config.nativeProjectDirectory, "android/app/src/main/AndroidManifest.xml");
|
|
16134
16318
|
const source = await readFile11(path, "utf8");
|
|
16135
16319
|
const mainActivity = source.indexOf('android:name=".MainActivity"');
|
|
16136
16320
|
if (mainActivity === NOT_FOUND) {
|
|
@@ -16154,7 +16338,7 @@ ${hosts}
|
|
|
16154
16338
|
</array>
|
|
16155
16339
|
${END_MARKER}
|
|
16156
16340
|
`, configureIosInfo = async (config) => {
|
|
16157
|
-
const path =
|
|
16341
|
+
const path = join46(config.nativeProjectDirectory, "ios/App/App/Info.plist");
|
|
16158
16342
|
const source = await readFile11(path, "utf8");
|
|
16159
16343
|
const region = config.deepLinkScheme ? iosSchemeRegion(config.deepLinkScheme) : ` ${START_MARKER}
|
|
16160
16344
|
${END_MARKER}
|
|
@@ -16176,7 +16360,7 @@ ${domains}
|
|
|
16176
16360
|
</plist>
|
|
16177
16361
|
`;
|
|
16178
16362
|
}, configureIosEntitlements = async (config) => {
|
|
16179
|
-
const path =
|
|
16363
|
+
const path = join46(config.nativeProjectDirectory, "ios/App/AbsoluteJS.entitlements");
|
|
16180
16364
|
let current = "";
|
|
16181
16365
|
try {
|
|
16182
16366
|
current = await readFile11(path, "utf8");
|
|
@@ -16193,7 +16377,7 @@ ${domains}
|
|
|
16193
16377
|
await rename8(temporary, path);
|
|
16194
16378
|
return true;
|
|
16195
16379
|
}, configureIosProject = async (config) => {
|
|
16196
|
-
const path =
|
|
16380
|
+
const path = join46(config.nativeProjectDirectory, "ios/App/App.xcodeproj/project.pbxproj");
|
|
16197
16381
|
const source = await readFile11(path, "utf8");
|
|
16198
16382
|
const declarations = [
|
|
16199
16383
|
...source.matchAll(/CODE_SIGN_ENTITLEMENTS = ([^;]+);/g)
|
|
@@ -16233,7 +16417,7 @@ var init_nativeDeepLinks = () => {};
|
|
|
16233
16417
|
|
|
16234
16418
|
// src/mobile/nativeBackgroundSync.ts
|
|
16235
16419
|
import { readFile as readFile12, rename as rename9, writeFile as writeFile10 } from "fs/promises";
|
|
16236
|
-
import { join as
|
|
16420
|
+
import { join as join47 } from "path";
|
|
16237
16421
|
var writeChanged = async (path, source) => {
|
|
16238
16422
|
const current = await readFile12(path, "utf8");
|
|
16239
16423
|
if (current === source)
|
|
@@ -16316,10 +16500,10 @@ ${makeRegion(values)} </array>
|
|
|
16316
16500
|
if (!platforms.includes("ios") || !projectUsesAbsoluteAuth(projectRoot) || !projectUsesAbsoluteSync(projectRoot))
|
|
16317
16501
|
return { changed: false };
|
|
16318
16502
|
const identifier = `${config.appId}.absolutejs.background-sync`;
|
|
16319
|
-
const infoPath =
|
|
16503
|
+
const infoPath = join47(config.nativeProjectDirectory, "ios/App/App/Info.plist");
|
|
16320
16504
|
const info2 = await readFile12(infoPath, "utf8");
|
|
16321
16505
|
const nextInfo = ensurePlistArrayValues(ensurePlistArrayValues(info2, "BGTaskSchedulerPermittedIdentifiers", [identifier], "background-sync-identifiers"), "UIBackgroundModes", ["fetch", "processing"], "background-sync-modes");
|
|
16322
|
-
const delegatePath =
|
|
16506
|
+
const delegatePath = join47(config.nativeProjectDirectory, "ios/App/App/AppDelegate.swift");
|
|
16323
16507
|
let delegate = await readFile12(delegatePath, "utf8");
|
|
16324
16508
|
if (!delegate.includes("import AbsoluteSyncCapacitor")) {
|
|
16325
16509
|
const importIndex = delegate.lastIndexOf("import Capacitor");
|
|
@@ -16359,7 +16543,7 @@ import {
|
|
|
16359
16543
|
rm as rm7,
|
|
16360
16544
|
writeFile as writeFile11
|
|
16361
16545
|
} from "fs/promises";
|
|
16362
|
-
import { resolve as
|
|
16546
|
+
import { resolve as resolve37 } from "path";
|
|
16363
16547
|
import { Elysia } from "elysia";
|
|
16364
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) => {
|
|
16365
16549
|
if (!config.platforms.includes("ios"))
|
|
@@ -16432,7 +16616,7 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16432
16616
|
return false;
|
|
16433
16617
|
}
|
|
16434
16618
|
}, assertOwnedOutput = async (root) => {
|
|
16435
|
-
const path =
|
|
16619
|
+
const path = resolve37(root, OWNERSHIP_FILE);
|
|
16436
16620
|
let ownership;
|
|
16437
16621
|
try {
|
|
16438
16622
|
ownership = JSON.parse(await readFile13(path, "utf8"));
|
|
@@ -16459,10 +16643,10 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16459
16643
|
if (hasCurrent)
|
|
16460
16644
|
await rm7(backup, { force: true, recursive: true });
|
|
16461
16645
|
}, materializeHost = async (root, host2, files) => {
|
|
16462
|
-
const directory =
|
|
16646
|
+
const directory = resolve37(root, host2, ".well-known");
|
|
16463
16647
|
await mkdir10(directory, { recursive: true });
|
|
16464
16648
|
return Promise.all(files.map(async ([name, document]) => {
|
|
16465
|
-
const path =
|
|
16649
|
+
const path = resolve37(directory, name);
|
|
16466
16650
|
await writeAtomic(path, `${JSON.stringify(document, null, 2)}
|
|
16467
16651
|
`);
|
|
16468
16652
|
return path;
|
|
@@ -16485,7 +16669,7 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16485
16669
|
});
|
|
16486
16670
|
return endpoints;
|
|
16487
16671
|
}), materializeAbsoluteMobileAssociationFiles = async (config, outputDirectory) => {
|
|
16488
|
-
const root =
|
|
16672
|
+
const root = resolve37(outputDirectory);
|
|
16489
16673
|
const temporary = `${root}.${crypto.randomUUID()}.tmp`;
|
|
16490
16674
|
const documents = createAbsoluteMobileAssociationDocuments(config, {
|
|
16491
16675
|
requireAll: true
|
|
@@ -16499,10 +16683,10 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16499
16683
|
await mkdir10(temporary, { recursive: true });
|
|
16500
16684
|
try {
|
|
16501
16685
|
const temporaryPaths = (await Promise.all(config.deepLinkHosts.map((host2) => materializeHost(temporary, host2, files)))).flat();
|
|
16502
|
-
await writeAtomic(
|
|
16686
|
+
await writeAtomic(resolve37(temporary, OWNERSHIP_FILE), `${JSON.stringify({ format: 1, hosts: config.deepLinkHosts }, null, 2)}
|
|
16503
16687
|
`);
|
|
16504
16688
|
await publishGeneratedDirectory(temporary, root);
|
|
16505
|
-
const written = temporaryPaths.map((path) =>
|
|
16689
|
+
const written = temporaryPaths.map((path) => resolve37(root, path.slice(temporary.length + 1)));
|
|
16506
16690
|
return { root, written };
|
|
16507
16691
|
} catch (error) {
|
|
16508
16692
|
await rm7(temporary, { force: true, recursive: true });
|
|
@@ -16544,7 +16728,7 @@ var init_associationFiles = __esm(() => {
|
|
|
16544
16728
|
|
|
16545
16729
|
// src/mobile/androidWebView.ts
|
|
16546
16730
|
import { mkdir as mkdir11, writeFile as writeFile12 } from "fs/promises";
|
|
16547
|
-
import { dirname as dirname28, resolve as
|
|
16731
|
+
import { dirname as dirname28, resolve as resolve38 } from "path";
|
|
16548
16732
|
|
|
16549
16733
|
class CdpConnection {
|
|
16550
16734
|
diagnostics = [];
|
|
@@ -16815,7 +16999,7 @@ var CDP_COMMAND_TIMEOUT_MS = 1e4, WEBVIEW_ATTACH_TIMEOUT_MS = 30000, WEBVIEW_POL
|
|
|
16815
16999
|
if (typeof data !== "string") {
|
|
16816
17000
|
throw new Error("Android WebView screenshot returned no image data.");
|
|
16817
17001
|
}
|
|
16818
|
-
const absolutePath =
|
|
17002
|
+
const absolutePath = resolve38(path);
|
|
16819
17003
|
await mkdir11(dirname28(absolutePath), { recursive: true });
|
|
16820
17004
|
await writeFile12(absolutePath, Buffer.from(data, "base64"));
|
|
16821
17005
|
return absolutePath;
|
|
@@ -16936,7 +17120,7 @@ var DEFAULT_ROUTE_TIMEOUT_MS = 30000, DEFAULT_HMR_TIMEOUT_MS = 30000, routeExpre
|
|
|
16936
17120
|
|
|
16937
17121
|
// src/mobile/releaseDoctor.ts
|
|
16938
17122
|
import { access as access8, readFile as readFile14, readdir as readdir4 } from "fs/promises";
|
|
16939
|
-
import { extname as
|
|
17123
|
+
import { extname as extname8, join as join48, relative as relative24 } from "path";
|
|
16940
17124
|
var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
16941
17125
|
try {
|
|
16942
17126
|
await access8(path);
|
|
@@ -16947,7 +17131,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16947
17131
|
}, inspectReleaseAsset = async (path, isDirectory, isFile2) => {
|
|
16948
17132
|
if (isDirectory)
|
|
16949
17133
|
return findHmrAsset(path);
|
|
16950
|
-
if (!isFile2 || !RELEASE_ASSET_EXTENSIONS.has(
|
|
17134
|
+
if (!isFile2 || !RELEASE_ASSET_EXTENSIONS.has(extname8(path)))
|
|
16951
17135
|
return;
|
|
16952
17136
|
const source = await readFile14(path, "utf8");
|
|
16953
17137
|
return HMR_ASSET_PATTERN.test(source) ? path : undefined;
|
|
@@ -16955,7 +17139,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16955
17139
|
if (!await pathExists5(root))
|
|
16956
17140
|
return;
|
|
16957
17141
|
const entries = await readdir4(root, { withFileTypes: true });
|
|
16958
|
-
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())));
|
|
16959
17143
|
return matches.find((match) => match !== undefined);
|
|
16960
17144
|
}, pass = (id, detail, path) => ({ detail, id, path, status: "pass" }), fail5 = (id, detail, path, remediation) => ({
|
|
16961
17145
|
detail,
|
|
@@ -17002,7 +17186,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17002
17186
|
}, syncSchemaReleaseCheck = (projectRoot) => {
|
|
17003
17187
|
if (!projectUsesAbsoluteSync(projectRoot))
|
|
17004
17188
|
return;
|
|
17005
|
-
const manifestPath =
|
|
17189
|
+
const manifestPath = join48(projectRoot, "package.json");
|
|
17006
17190
|
try {
|
|
17007
17191
|
const schema = discoverAbsoluteSyncSchema(projectRoot);
|
|
17008
17192
|
const versions = schema.components.map((component2) => `${component2.id}@${component2.version}`).join(", ");
|
|
@@ -17021,12 +17205,21 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17021
17205
|
} catch (error) {
|
|
17022
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.");
|
|
17023
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
|
+
}
|
|
17024
17217
|
}, inspectAndroidRelease = async (config, projectRoot) => {
|
|
17025
|
-
const androidRoot =
|
|
17026
|
-
const nativeConfigPath =
|
|
17027
|
-
const manifestPath =
|
|
17028
|
-
const publicRoot =
|
|
17029
|
-
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");
|
|
17030
17223
|
const checks = await Promise.all([
|
|
17031
17224
|
journalReleaseCheck(journalPath, "android"),
|
|
17032
17225
|
capacitorConfigReleaseCheck(nativeConfigPath),
|
|
@@ -17035,14 +17228,14 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17035
17228
|
]);
|
|
17036
17229
|
return checks.map((check2) => ({
|
|
17037
17230
|
...check2,
|
|
17038
|
-
path: check2.path ?
|
|
17231
|
+
path: check2.path ? relative24(projectRoot, check2.path).replaceAll("\\", "/") || "." : undefined
|
|
17039
17232
|
}));
|
|
17040
17233
|
}, inspectIosRelease = async (config, projectRoot) => {
|
|
17041
|
-
const iosAppRoot =
|
|
17042
|
-
const nativeConfigPath =
|
|
17043
|
-
const infoPath =
|
|
17044
|
-
const publicRoot =
|
|
17045
|
-
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");
|
|
17046
17239
|
const checks = [
|
|
17047
17240
|
await journalReleaseCheck(journalPath, "ios")
|
|
17048
17241
|
];
|
|
@@ -17068,7 +17261,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17068
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));
|
|
17069
17262
|
return checks.map((check2) => ({
|
|
17070
17263
|
...check2,
|
|
17071
|
-
path: check2.path ?
|
|
17264
|
+
path: check2.path ? relative24(projectRoot, check2.path).replaceAll("\\", "/") || "." : undefined
|
|
17072
17265
|
}));
|
|
17073
17266
|
}, inspectAbsoluteMobileRelease = async (config, projectRoot) => {
|
|
17074
17267
|
const checks = config.platforms.includes("android") ? await inspectAndroidRelease(config, projectRoot) : [];
|
|
@@ -17079,9 +17272,14 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17079
17272
|
if (syncSchema) {
|
|
17080
17273
|
checks.push({
|
|
17081
17274
|
...syncSchema,
|
|
17082
|
-
path: syncSchema.path ?
|
|
17275
|
+
path: syncSchema.path ? relative24(projectRoot, syncSchema.path).replaceAll("\\", "/") || "." : undefined
|
|
17083
17276
|
});
|
|
17084
17277
|
}
|
|
17278
|
+
const deviceCapabilities = deviceCapabilityReleaseCheck(projectRoot);
|
|
17279
|
+
checks.push({
|
|
17280
|
+
...deviceCapabilities,
|
|
17281
|
+
path: deviceCapabilities.path ? relative24(projectRoot, deviceCapabilities.path).replaceAll("\\", "/") || "." : undefined
|
|
17282
|
+
});
|
|
17085
17283
|
return {
|
|
17086
17284
|
checks,
|
|
17087
17285
|
ready: checks.length > 0 && checks.every((check2) => check2.status === "pass")
|
|
@@ -17090,6 +17288,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
17090
17288
|
var init_releaseDoctor = __esm(() => {
|
|
17091
17289
|
init_nativeAuth();
|
|
17092
17290
|
init_syncSchema();
|
|
17291
|
+
init_deviceCapabilities();
|
|
17093
17292
|
HMR_ASSET_PATTERN = /(?:__HMR_WS__|hmr-timing|__absolute_target|absolutejs-error-overlay)/u;
|
|
17094
17293
|
RELEASE_ASSET_EXTENSIONS = new Set([".html", ".js", ".mjs"]);
|
|
17095
17294
|
});
|
|
@@ -17107,7 +17306,7 @@ import {
|
|
|
17107
17306
|
stat as stat2,
|
|
17108
17307
|
writeFile as writeFile13
|
|
17109
17308
|
} from "fs/promises";
|
|
17110
|
-
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";
|
|
17111
17310
|
var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), requireManifest2 = (value) => {
|
|
17112
17311
|
if (!isRecord13(value) || typeof value.appBuild !== "string" || typeof value.appId !== "string" || typeof value.runtime !== "string") {
|
|
17113
17312
|
throw new TypeError("Invalid embedded AbsoluteJS mobile manifest.");
|
|
@@ -17158,19 +17357,19 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
17158
17357
|
]);
|
|
17159
17358
|
return result.exitCode === 0 && /jar verified/iu.test(result.stdout);
|
|
17160
17359
|
}, sha256File2 = async (path) => createHash12("sha256").update(await readFile15(path)).digest("hex"), safeOutputDirectory2 = (projectRoot, requested) => {
|
|
17161
|
-
const root =
|
|
17162
|
-
const output =
|
|
17163
|
-
const projectRelative =
|
|
17360
|
+
const root = resolve39(projectRoot);
|
|
17361
|
+
const output = resolve39(root, requested ?? ".absolutejs/mobile/releases/android");
|
|
17362
|
+
const projectRelative = relative25(root, output);
|
|
17164
17363
|
if (projectRelative === ".." || projectRelative.startsWith(`..${sep6}`) || isAbsolute7(projectRelative)) {
|
|
17165
17364
|
throw new TypeError("mobile build --outdir must remain inside the project.");
|
|
17166
17365
|
}
|
|
17167
17366
|
return output;
|
|
17168
17367
|
}, installRelease2 = async (artifactPath, metadata, outputRoot) => {
|
|
17169
|
-
const releaseRoot =
|
|
17368
|
+
const releaseRoot = join49(outputRoot, metadata.releaseId);
|
|
17170
17369
|
const artifactName = "app-release.aab";
|
|
17171
|
-
const destination =
|
|
17370
|
+
const destination = join49(releaseRoot, artifactName);
|
|
17172
17371
|
if (await pathExists6(releaseRoot)) {
|
|
17173
|
-
const existing = requireManifestIdentity(JSON.parse(await readFile15(
|
|
17372
|
+
const existing = requireManifestIdentity(JSON.parse(await readFile15(join49(releaseRoot, "release.json"), "utf8")), metadata);
|
|
17174
17373
|
const [installedBytes, installedSha256] = await Promise.all([
|
|
17175
17374
|
stat2(destination).then(({ size }) => size),
|
|
17176
17375
|
sha256File2(destination)
|
|
@@ -17181,14 +17380,14 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
17181
17380
|
return { artifactPath: destination, metadata: existing, releaseRoot };
|
|
17182
17381
|
}
|
|
17183
17382
|
await mkdir12(dirname29(releaseRoot), { recursive: true });
|
|
17184
|
-
const staging = await mkdtemp5(
|
|
17383
|
+
const staging = await mkdtemp5(join49(dirname29(releaseRoot), ".android-stage-"));
|
|
17185
17384
|
try {
|
|
17186
|
-
await copyFile5(artifactPath,
|
|
17385
|
+
await copyFile5(artifactPath, join49(staging, artifactName));
|
|
17187
17386
|
const complete = {
|
|
17188
17387
|
...metadata,
|
|
17189
17388
|
artifact: artifactName
|
|
17190
17389
|
};
|
|
17191
|
-
await writeFile13(
|
|
17390
|
+
await writeFile13(join49(staging, "release.json"), `${JSON.stringify(complete, null, "\t")}
|
|
17192
17391
|
`, { flag: "wx" });
|
|
17193
17392
|
await rename11(staging, releaseRoot);
|
|
17194
17393
|
return { artifactPath: destination, metadata: complete, releaseRoot };
|
|
@@ -17213,11 +17412,11 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
17213
17412
|
if (options.versionCode !== undefined && (!Number.isSafeInteger(options.versionCode) || options.versionCode < 1 || options.versionCode > 2100000000)) {
|
|
17214
17413
|
throw new TypeError("Android versionCode must be an integer from 1 through 2100000000.");
|
|
17215
17414
|
}
|
|
17216
|
-
const projectRoot =
|
|
17415
|
+
const projectRoot = resolve39(options.projectRoot);
|
|
17217
17416
|
const host2 = options.host ?? detectAbsoluteMobileHost();
|
|
17218
17417
|
const androidRoot = options.androidRoot ?? process.env.ANDROID_HOME ?? process.env.ANDROID_SDK_ROOT ?? absoluteManagedAndroidSdkRoot(host2);
|
|
17219
|
-
const nativeDirectory =
|
|
17220
|
-
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")));
|
|
17221
17420
|
if (manifest.appId !== options.config.appId) {
|
|
17222
17421
|
throw new TypeError("Embedded mobile manifest appId does not match mobile.appId.");
|
|
17223
17422
|
}
|
|
@@ -17341,7 +17540,7 @@ var init_iosConformance = __esm(() => {
|
|
|
17341
17540
|
|
|
17342
17541
|
// src/mobile/releasePublisher.ts
|
|
17343
17542
|
import { access as access10 } from "fs/promises";
|
|
17344
|
-
import { isAbsolute as isAbsolute8, relative as
|
|
17543
|
+
import { isAbsolute as isAbsolute8, relative as relative26, resolve as resolve40, sep as sep7 } from "path";
|
|
17345
17544
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
17346
17545
|
var prepareAbsoluteIosRelease = async (publisher, options) => {
|
|
17347
17546
|
if (typeof publisher.prepareIosRelease !== "function") {
|
|
@@ -17363,9 +17562,9 @@ var prepareAbsoluteIosRelease = async (publisher, options) => {
|
|
|
17363
17562
|
}
|
|
17364
17563
|
return versionCode;
|
|
17365
17564
|
}, isRecord14 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), isPublisher = (value) => isRecord14(value) && typeof value.publish === "function", publisherModulePath = (projectRoot, requested) => {
|
|
17366
|
-
const root =
|
|
17367
|
-
const path =
|
|
17368
|
-
const projectRelative =
|
|
17565
|
+
const root = resolve40(projectRoot);
|
|
17566
|
+
const path = resolve40(root, requested);
|
|
17567
|
+
const projectRelative = relative26(root, path);
|
|
17369
17568
|
if (projectRelative === ".." || projectRelative.startsWith(`..${sep7}`) || isAbsolute8(projectRelative)) {
|
|
17370
17569
|
throw new TypeError("mobile publish --registry must remain inside the project.");
|
|
17371
17570
|
}
|
|
@@ -17438,10 +17637,10 @@ __export(exports_mobile, {
|
|
|
17438
17637
|
runMobile: () => runMobile
|
|
17439
17638
|
});
|
|
17440
17639
|
import { access as access11, mkdir as mkdir13, readFile as readFile17, writeFile as writeFile14 } from "fs/promises";
|
|
17441
|
-
import { join as
|
|
17640
|
+
import { join as join50, resolve as resolve41 } from "path";
|
|
17442
17641
|
import { createInterface } from "readline/promises";
|
|
17443
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) => {
|
|
17444
|
-
const manifest = JSON.parse(await readFile17(
|
|
17643
|
+
const manifest = JSON.parse(await readFile17(join50(projectRoot, "package.json"), "utf8"));
|
|
17445
17644
|
if (!isRecord15(manifest))
|
|
17446
17645
|
throw new TypeError("Application package.json must contain an object.");
|
|
17447
17646
|
const names = new Set;
|
|
@@ -17452,20 +17651,37 @@ var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value
|
|
|
17452
17651
|
names.add(name);
|
|
17453
17652
|
}
|
|
17454
17653
|
return names;
|
|
17455
|
-
},
|
|
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) => {
|
|
17456
17674
|
const specs = [
|
|
17457
17675
|
...CAPACITOR_PACKAGE_SPECS,
|
|
17458
17676
|
...projectUsesAbsoluteSync(projectRoot) ? CAPACITOR_SYNC_PACKAGE_SPECS : []
|
|
17459
17677
|
];
|
|
17460
17678
|
const installed = await directProjectPackages(projectRoot);
|
|
17461
|
-
const missing =
|
|
17462
|
-
|
|
17463
|
-
|
|
17464
|
-
const
|
|
17465
|
-
|
|
17466
|
-
|
|
17467
|
-
if (!installPackages(projectRoot, missing))
|
|
17468
|
-
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);
|
|
17469
17685
|
}, valueAfter = (args, flag) => {
|
|
17470
17686
|
const index = args.indexOf(flag);
|
|
17471
17687
|
return index === NOT_FOUND2 ? undefined : args[index + 1];
|
|
@@ -17478,7 +17694,7 @@ var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value
|
|
|
17478
17694
|
}
|
|
17479
17695
|
return value;
|
|
17480
17696
|
}, capacitorExecutable = async (projectRoot) => {
|
|
17481
|
-
const executable =
|
|
17697
|
+
const executable = join50(projectRoot, "node_modules", ".bin", "cap");
|
|
17482
17698
|
try {
|
|
17483
17699
|
await access11(executable);
|
|
17484
17700
|
return executable;
|
|
@@ -17564,7 +17780,7 @@ var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value
|
|
|
17564
17780
|
await applyAbsoluteNativeBackgroundSync(projectRoot, mobile, platforms);
|
|
17565
17781
|
}, associations = async (args) => {
|
|
17566
17782
|
const { mobile, projectRoot } = await loadMobile(valueAfter(args, "--config"));
|
|
17567
|
-
const outputDirectory =
|
|
17783
|
+
const outputDirectory = resolve41(projectRoot, valueAfter(args, "--outdir") ?? ".absolutejs/mobile/associations");
|
|
17568
17784
|
if (args.includes("--verify")) {
|
|
17569
17785
|
const result2 = await verifyAbsoluteMobileAssociationFiles(mobile);
|
|
17570
17786
|
console.log(`Verified ${result2.results.length} hosted association files`);
|
|
@@ -17794,7 +18010,7 @@ Mobile release transport checks failed.`);
|
|
|
17794
18010
|
const durationMs = Math.round(performance.now() - startedAt);
|
|
17795
18011
|
console.log(`Built ${release.metadata.signed ? "signed" : "unsigned"} Android App Bundle in ${getDurationString(durationMs)}.`);
|
|
17796
18012
|
console.log(`Artifact: ${release.artifactPath}`);
|
|
17797
|
-
console.log(`Metadata: ${
|
|
18013
|
+
console.log(`Metadata: ${join50(release.releaseRoot, "release.json")}`);
|
|
17798
18014
|
return release;
|
|
17799
18015
|
} finally {
|
|
17800
18016
|
sendTelemetryEvent("mobile:android-release-build", {
|
|
@@ -17894,7 +18110,7 @@ Mobile release transport checks failed.`);
|
|
|
17894
18110
|
const durationMs = Math.round(performance.now() - startedAt);
|
|
17895
18111
|
console.log(`Built ${release.metadata.signed ? "signed" : "unsigned"} iOS IPA ${release.metadata.marketingVersion}${release.metadata.buildNumber ? ` (${release.metadata.buildNumber})` : ""} in ${getDurationString(durationMs)}.`);
|
|
17896
18112
|
console.log(`Artifact: ${release.artifactPath}`);
|
|
17897
|
-
console.log(`Metadata: ${
|
|
18113
|
+
console.log(`Metadata: ${join50(release.releaseRoot, "release.json")}`);
|
|
17898
18114
|
return release;
|
|
17899
18115
|
} finally {
|
|
17900
18116
|
sendTelemetryEvent("mobile:ios-release-build", {
|
|
@@ -18001,7 +18217,7 @@ Mobile release transport checks failed.`);
|
|
|
18001
18217
|
checks.push({
|
|
18002
18218
|
id: "sync.storage-schema",
|
|
18003
18219
|
label: `Offline schema ${schema.components.map((component2) => `${component2.id}@${component2.version}`).join(", ")}`,
|
|
18004
|
-
path:
|
|
18220
|
+
path: join50(projectRoot, "package.json"),
|
|
18005
18221
|
platform: "host",
|
|
18006
18222
|
status: "pass"
|
|
18007
18223
|
});
|
|
@@ -18009,7 +18225,7 @@ Mobile release transport checks failed.`);
|
|
|
18009
18225
|
checks.push({
|
|
18010
18226
|
id: "sync.storage-schema",
|
|
18011
18227
|
label: "Offline schema metadata is invalid",
|
|
18012
|
-
path:
|
|
18228
|
+
path: join50(projectRoot, "package.json"),
|
|
18013
18229
|
platform: "host",
|
|
18014
18230
|
remediation: error instanceof Error ? error.message : String(error),
|
|
18015
18231
|
status: "fail"
|
|
@@ -18094,7 +18310,7 @@ Emulator setup verification:`);
|
|
|
18094
18310
|
}
|
|
18095
18311
|
return { https: args.includes("--https"), port };
|
|
18096
18312
|
}
|
|
18097
|
-
const instances = listLiveInstances().filter((instance2) =>
|
|
18313
|
+
const instances = listLiveInstances().filter((instance2) => resolve41(instance2.cwd) === resolve41(projectRoot) && instance2.source === "dev" && instance2.port !== null);
|
|
18098
18314
|
if (instances.length !== 1) {
|
|
18099
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>.");
|
|
18100
18316
|
}
|
|
@@ -18137,8 +18353,8 @@ Emulator setup verification:`);
|
|
|
18137
18353
|
}
|
|
18138
18354
|
return selected;
|
|
18139
18355
|
}, safeArtifactRoot = (projectRoot, value) => {
|
|
18140
|
-
const root =
|
|
18141
|
-
if (root !== projectRoot && !root.startsWith(`${
|
|
18356
|
+
const root = resolve41(projectRoot, value ?? ".absolutejs/mobile/test-artifacts");
|
|
18357
|
+
if (root !== projectRoot && !root.startsWith(`${resolve41(projectRoot)}/`)) {
|
|
18142
18358
|
throw new TypeError("mobile test --artifacts must remain inside the project.");
|
|
18143
18359
|
}
|
|
18144
18360
|
return root;
|
|
@@ -18163,10 +18379,10 @@ Emulator setup verification:`);
|
|
|
18163
18379
|
});
|
|
18164
18380
|
}, writeAndroidFailureArtifacts = async (options) => {
|
|
18165
18381
|
await mkdir13(options.artifactRoot, { recursive: true });
|
|
18166
|
-
const screenshot = options.session ? await options.session.screenshot(
|
|
18382
|
+
const screenshot = options.session ? await options.session.screenshot(join50(options.artifactRoot, "android-failure.png")).catch(() => {
|
|
18167
18383
|
return;
|
|
18168
18384
|
}) : undefined;
|
|
18169
|
-
const diagnosticPath =
|
|
18385
|
+
const diagnosticPath = join50(options.artifactRoot, "android-failure.json");
|
|
18170
18386
|
await writeFile14(diagnosticPath, `${JSON.stringify({
|
|
18171
18387
|
diagnostics: options.session?.diagnostics ?? [],
|
|
18172
18388
|
error: options.error instanceof Error ? options.error.message : String(options.error),
|
|
@@ -18257,14 +18473,14 @@ Emulator setup verification:`);
|
|
|
18257
18473
|
const port = Number(explicit);
|
|
18258
18474
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
18259
18475
|
throw new TypeError("mobile test --port must be a valid TCP port.");
|
|
18260
|
-
const instance2 = listLiveInstances().find((candidate) =>
|
|
18476
|
+
const instance2 = listLiveInstances().find((candidate) => resolve41(candidate.cwd) === resolve41(projectRoot) && candidate.source === "dev" && candidate.port === port);
|
|
18261
18477
|
return {
|
|
18262
18478
|
https: instance2?.https ?? args.includes("--https"),
|
|
18263
18479
|
instance: instance2,
|
|
18264
18480
|
port
|
|
18265
18481
|
};
|
|
18266
18482
|
}
|
|
18267
|
-
const instances = listLiveInstances().filter((instance2) =>
|
|
18483
|
+
const instances = listLiveInstances().filter((instance2) => resolve41(instance2.cwd) === resolve41(projectRoot) && instance2.source === "dev" && instance2.port !== null);
|
|
18268
18484
|
if (instances.length !== 1)
|
|
18269
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>.");
|
|
18270
18486
|
const [instance] = instances;
|
|
@@ -18344,7 +18560,7 @@ Emulator setup verification:`);
|
|
|
18344
18560
|
return result;
|
|
18345
18561
|
}, writeIosFailureArtifacts = async (options) => {
|
|
18346
18562
|
await mkdir13(options.artifactRoot, { recursive: true });
|
|
18347
|
-
const screenshot =
|
|
18563
|
+
const screenshot = join50(options.artifactRoot, "ios-failure.png");
|
|
18348
18564
|
const screenshotResult = captureCommand4([
|
|
18349
18565
|
options.xcrun,
|
|
18350
18566
|
"simctl",
|
|
@@ -18353,7 +18569,7 @@ Emulator setup verification:`);
|
|
|
18353
18569
|
"screenshot",
|
|
18354
18570
|
screenshot
|
|
18355
18571
|
]);
|
|
18356
|
-
const diagnosticPath =
|
|
18572
|
+
const diagnosticPath = join50(options.artifactRoot, "ios-failure.json");
|
|
18357
18573
|
await writeFile14(diagnosticPath, `${JSON.stringify({
|
|
18358
18574
|
appId: options.appId,
|
|
18359
18575
|
error: options.error instanceof Error ? options.error.message : String(options.error),
|
|
@@ -18399,7 +18615,7 @@ Emulator setup verification:`);
|
|
|
18399
18615
|
], "iOS app launch");
|
|
18400
18616
|
await waitForIosHmrClient({ https, port, timeoutMs });
|
|
18401
18617
|
await mkdir13(artifactRoot, { recursive: true });
|
|
18402
|
-
const screenshot =
|
|
18618
|
+
const screenshot = join50(artifactRoot, "ios-simulator.png");
|
|
18403
18619
|
requireCapturedIosCommand([xcrun, "simctl", "io", simulator.udid, "screenshot", screenshot], "iOS simulator screenshot");
|
|
18404
18620
|
const hmrApply = await waitForRequestedIosHmr(args, instance, timeoutMs);
|
|
18405
18621
|
const report = {
|
|
@@ -18524,6 +18740,7 @@ var init_mobile = __esm(() => {
|
|
|
18524
18740
|
init_remoteMacProtocol();
|
|
18525
18741
|
init_nativeAuth();
|
|
18526
18742
|
init_syncSchema();
|
|
18743
|
+
init_deviceCapabilities();
|
|
18527
18744
|
CAPACITOR_PACKAGES = [
|
|
18528
18745
|
"@capacitor/core",
|
|
18529
18746
|
"@capacitor/app",
|
|
@@ -18545,8 +18762,8 @@ var init_mobile = __esm(() => {
|
|
|
18545
18762
|
"@capacitor/cli@8.5.0",
|
|
18546
18763
|
"@capacitor/android@8.5.0",
|
|
18547
18764
|
"@capacitor/ios@8.5.0",
|
|
18548
|
-
"@absolutejs/devices@0.0
|
|
18549
|
-
"@absolutejs/devices-capacitor@0.
|
|
18765
|
+
"@absolutejs/devices@0.1.0",
|
|
18766
|
+
"@absolutejs/devices-capacitor@0.2.0"
|
|
18550
18767
|
];
|
|
18551
18768
|
CAPACITOR_SYNC_PACKAGE_SPECS = [
|
|
18552
18769
|
"@absolutejs/sync-capacitor@0.8.0",
|
|
@@ -18559,10 +18776,10 @@ var exports_typecheck = {};
|
|
|
18559
18776
|
__export(exports_typecheck, {
|
|
18560
18777
|
typecheck: () => typecheck
|
|
18561
18778
|
});
|
|
18562
|
-
import { resolve as
|
|
18563
|
-
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";
|
|
18564
18781
|
import { mkdir as mkdir14, writeFile as writeFile15 } from "fs/promises";
|
|
18565
|
-
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) => {
|
|
18566
18783
|
if (!existsSync42(resolveConfigPath(configPath2))) {
|
|
18567
18784
|
const defaultService = {};
|
|
18568
18785
|
return [defaultService];
|
|
@@ -18584,7 +18801,7 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
|
|
|
18584
18801
|
const exitCode = await proc.exited;
|
|
18585
18802
|
return { exitCode, name, output: (stdout + stderr).trim() };
|
|
18586
18803
|
}, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
|
|
18587
|
-
const local =
|
|
18804
|
+
const local = resolve42("node_modules", ".bin", name);
|
|
18588
18805
|
return existsSync42(local) ? local : null;
|
|
18589
18806
|
}, ANSI_COLOR_REGEX, ANSI_PURPLE_REGEX, ANSI_CYAN_REGEX, ANSI_TOKEN_END_REGEX, stripAnsi4 = (str) => str.replace(ANSI_COLOR_REGEX, ""), formatSvelteOutput = (output) => {
|
|
18590
18807
|
const cwd = `${process.cwd()}/`;
|
|
@@ -18632,15 +18849,15 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18632
18849
|
return formatted;
|
|
18633
18850
|
}, ABSOLUTE_INTERNAL_EXCLUDES, resolveAbsoluteTypeFile = (fileName) => {
|
|
18634
18851
|
const candidates = [
|
|
18635
|
-
|
|
18636
|
-
|
|
18637
|
-
|
|
18638
|
-
|
|
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)
|
|
18639
18856
|
];
|
|
18640
18857
|
return candidates.find((candidate) => existsSync42(candidate)) ?? candidates[0];
|
|
18641
18858
|
}, ABSOLUTE_TYPECHECK_FILES, readProjectTsconfig = () => {
|
|
18642
18859
|
try {
|
|
18643
|
-
return JSON.parse(
|
|
18860
|
+
return JSON.parse(readFileSync40(resolve42("tsconfig.json"), "utf-8"));
|
|
18644
18861
|
} catch {
|
|
18645
18862
|
return {};
|
|
18646
18863
|
}
|
|
@@ -18668,27 +18885,27 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18668
18885
|
console.error("\x1B[31m\u2717\x1B[0m vue-tsc is required for Vue type checking. Install it: bun add -d vue-tsc");
|
|
18669
18886
|
process.exit(1);
|
|
18670
18887
|
}
|
|
18671
|
-
const vueTsconfigPath =
|
|
18888
|
+
const vueTsconfigPath = join51(cacheDir, "tsconfig.vue-check.json");
|
|
18672
18889
|
await writeFile15(vueTsconfigPath, JSON.stringify({
|
|
18673
18890
|
compilerOptions: {
|
|
18674
18891
|
rootDir: ".."
|
|
18675
18892
|
},
|
|
18676
18893
|
exclude: getProjectTypecheckExcludes(),
|
|
18677
|
-
extends:
|
|
18894
|
+
extends: resolve42("tsconfig.json"),
|
|
18678
18895
|
include: getProjectTypecheckIncludes()
|
|
18679
18896
|
}, null, "\t"));
|
|
18680
18897
|
const base = [
|
|
18681
18898
|
vueTscBin,
|
|
18682
18899
|
"--noEmit",
|
|
18683
18900
|
"--project",
|
|
18684
|
-
|
|
18901
|
+
resolve42(vueTsconfigPath),
|
|
18685
18902
|
"--pretty"
|
|
18686
18903
|
];
|
|
18687
18904
|
const cached = await run("vue-tsc", [
|
|
18688
18905
|
...base,
|
|
18689
18906
|
"--incremental",
|
|
18690
18907
|
"--tsBuildInfoFile",
|
|
18691
|
-
|
|
18908
|
+
join51(cacheDir, "vue-tsc.tsbuildinfo")
|
|
18692
18909
|
]);
|
|
18693
18910
|
if (cached.exitCode === 0 || cached.output.length > 0)
|
|
18694
18911
|
return cached;
|
|
@@ -18699,7 +18916,7 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18699
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");
|
|
18700
18917
|
process.exit(1);
|
|
18701
18918
|
}
|
|
18702
|
-
const angularTsconfigPath =
|
|
18919
|
+
const angularTsconfigPath = join51(cacheDir, "tsconfig.angular-check.json");
|
|
18703
18920
|
await writeFile15(angularTsconfigPath, JSON.stringify({
|
|
18704
18921
|
angularCompilerOptions: {
|
|
18705
18922
|
strictTemplates: true
|
|
@@ -18709,32 +18926,32 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18709
18926
|
rootDir: ".."
|
|
18710
18927
|
},
|
|
18711
18928
|
exclude: ABSOLUTE_INTERNAL_EXCLUDES.map(toGeneratedConfigPath),
|
|
18712
|
-
extends:
|
|
18929
|
+
extends: resolve42("tsconfig.json"),
|
|
18713
18930
|
include: [`../${angularDir}/**/*`]
|
|
18714
18931
|
}, null, "\t"));
|
|
18715
|
-
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(
|
|
18932
|
+
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve42(angularTsconfigPath))}`);
|
|
18716
18933
|
}, buildTscCheck = (cacheDir) => {
|
|
18717
18934
|
const tscBin = findBin("tsc");
|
|
18718
18935
|
if (!tscBin) {
|
|
18719
18936
|
console.error("\x1B[31m\u2717\x1B[0m typescript is required for type checking. Install it: bun add -d typescript");
|
|
18720
18937
|
process.exit(1);
|
|
18721
18938
|
}
|
|
18722
|
-
const tscConfigPath =
|
|
18939
|
+
const tscConfigPath = join51(cacheDir, "tsconfig.typecheck.json");
|
|
18723
18940
|
return writeFile15(tscConfigPath, JSON.stringify({
|
|
18724
18941
|
compilerOptions: {
|
|
18725
18942
|
rootDir: ".."
|
|
18726
18943
|
},
|
|
18727
18944
|
exclude: getProjectTypecheckExcludes(),
|
|
18728
|
-
extends:
|
|
18945
|
+
extends: resolve42("tsconfig.json"),
|
|
18729
18946
|
include: getProjectTypecheckIncludes()
|
|
18730
18947
|
}, null, "\t")).then(() => run("tsc", [
|
|
18731
18948
|
tscBin,
|
|
18732
18949
|
"--noEmit",
|
|
18733
18950
|
"--project",
|
|
18734
|
-
|
|
18951
|
+
resolve42(tscConfigPath),
|
|
18735
18952
|
"--incremental",
|
|
18736
18953
|
"--tsBuildInfoFile",
|
|
18737
|
-
|
|
18954
|
+
join51(cacheDir, "tsc.tsbuildinfo"),
|
|
18738
18955
|
"--pretty"
|
|
18739
18956
|
]));
|
|
18740
18957
|
}, buildSvelteCheck = async (cacheDir, svelteDir) => {
|
|
@@ -18743,16 +18960,16 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18743
18960
|
console.error("\x1B[31m\u2717\x1B[0m svelte-check is required for Svelte type checking. Install it: bun add -d svelte-check");
|
|
18744
18961
|
process.exit(1);
|
|
18745
18962
|
}
|
|
18746
|
-
const svelteTsconfigPath =
|
|
18963
|
+
const svelteTsconfigPath = join51(cacheDir, "tsconfig.svelte-check.json");
|
|
18747
18964
|
await writeFile15(svelteTsconfigPath, JSON.stringify({
|
|
18748
|
-
extends:
|
|
18965
|
+
extends: resolve42("tsconfig.json"),
|
|
18749
18966
|
files: ABSOLUTE_TYPECHECK_FILES,
|
|
18750
18967
|
include: [`../${svelteDir}/**/*`]
|
|
18751
18968
|
}, null, "\t"));
|
|
18752
18969
|
return run("svelte-check", [
|
|
18753
18970
|
svelteBin,
|
|
18754
18971
|
"--tsconfig",
|
|
18755
|
-
|
|
18972
|
+
resolve42(svelteTsconfigPath),
|
|
18756
18973
|
"--threshold",
|
|
18757
18974
|
"error",
|
|
18758
18975
|
"--compiler-warnings",
|
|
@@ -18946,11 +19163,11 @@ var DEFAULT_RELAY_PORT = 8787, DEFAULT_REQUEST_TIMEOUT_MS = 30000, headersToObje
|
|
|
18946
19163
|
url: url.pathname + url.search,
|
|
18947
19164
|
...bodyBytes && bodyBytes.length > 0 ? { bodyBase64: Buffer.from(bodyBytes).toString("base64") } : {}
|
|
18948
19165
|
};
|
|
18949
|
-
const responsePromise = new Promise((
|
|
18950
|
-
pending.set(id,
|
|
19166
|
+
const responsePromise = new Promise((resolve43) => {
|
|
19167
|
+
pending.set(id, resolve43);
|
|
18951
19168
|
});
|
|
18952
19169
|
client.send(encodeTunnelMessage(message));
|
|
18953
|
-
const timeout = new Promise((
|
|
19170
|
+
const timeout = new Promise((resolve43) => setTimeout(() => resolve43({ id, message: "timeout", type: "error" }), requestTimeoutMs));
|
|
18954
19171
|
const result = await Promise.race([responsePromise, timeout]);
|
|
18955
19172
|
pending.delete(id);
|
|
18956
19173
|
if (result.type === "error") {
|
|
@@ -21202,12 +21419,12 @@ import {
|
|
|
21202
21419
|
existsSync as existsSync12,
|
|
21203
21420
|
mkdirSync as mkdirSync7,
|
|
21204
21421
|
readdirSync as readdirSync2,
|
|
21205
|
-
readFileSync as
|
|
21422
|
+
readFileSync as readFileSync16,
|
|
21206
21423
|
unlinkSync as unlinkSync3,
|
|
21207
21424
|
writeFileSync as writeFileSync6
|
|
21208
21425
|
} from "fs";
|
|
21209
21426
|
import { createConnection } from "net";
|
|
21210
|
-
import { resolve as
|
|
21427
|
+
import { resolve as resolve22 } from "path";
|
|
21211
21428
|
|
|
21212
21429
|
// src/cli/workspaceTui.ts
|
|
21213
21430
|
init_constants();
|
|
@@ -21769,18 +21986,18 @@ var createWorkspaceTui = ({
|
|
|
21769
21986
|
|
|
21770
21987
|
// src/cli/scripts/workspace.ts
|
|
21771
21988
|
init_utils();
|
|
21772
|
-
var sourceServerBootstrap2 =
|
|
21773
|
-
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");
|
|
21774
21991
|
var ANSI_REGEX2 = new RegExp(`${String.fromCharCode(ANSI_ESCAPE_CODE)}\\[[0-?]*[ -/]*[@-~]`, "g");
|
|
21775
21992
|
var sleep = (durationMs) => Bun.sleep(durationMs);
|
|
21776
21993
|
var stripAnsi3 = (value) => value.replace(ANSI_REGEX2, "");
|
|
21777
21994
|
var sanitizeLogFileName = (value) => value.replace(/[^a-zA-Z0-9._-]/g, "_") || "unknown";
|
|
21778
21995
|
var createWorkspaceLogSink = (appendLog) => {
|
|
21779
|
-
const logDirectory =
|
|
21996
|
+
const logDirectory = resolve22(".absolutejs", "workspace", "logs");
|
|
21780
21997
|
mkdirSync7(logDirectory, { recursive: true });
|
|
21781
|
-
readdirSync2(logDirectory).filter((file) => file.endsWith(".log")).forEach((file) => unlinkSync3(
|
|
21782
|
-
writeFileSync6(
|
|
21783
|
-
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"), "");
|
|
21784
22001
|
const initializedSources = new Set(["workspace"]);
|
|
21785
22002
|
const writeLog = (source, message, level) => {
|
|
21786
22003
|
const cleanMessage = stripAnsi3(message).trimEnd();
|
|
@@ -21790,13 +22007,13 @@ var createWorkspaceLogSink = (appendLog) => {
|
|
|
21790
22007
|
const timestamp = new Date().toISOString();
|
|
21791
22008
|
const line = `[${timestamp}] [${level}] [${source}] ${cleanMessage}
|
|
21792
22009
|
`;
|
|
21793
|
-
const sourceFile =
|
|
22010
|
+
const sourceFile = resolve22(logDirectory, `${sanitizeLogFileName(source)}.log`);
|
|
21794
22011
|
if (!initializedSources.has(source)) {
|
|
21795
22012
|
writeFileSync6(sourceFile, "");
|
|
21796
22013
|
initializedSources.add(source);
|
|
21797
22014
|
}
|
|
21798
22015
|
appendFileSync(sourceFile, line);
|
|
21799
|
-
appendFileSync(
|
|
22016
|
+
appendFileSync(resolve22(logDirectory, "all.log"), line);
|
|
21800
22017
|
};
|
|
21801
22018
|
return {
|
|
21802
22019
|
appendLog: (source, message, level = "info") => {
|
|
@@ -21808,7 +22025,7 @@ var createWorkspaceLogSink = (appendLog) => {
|
|
|
21808
22025
|
};
|
|
21809
22026
|
var readPackageVersion3 = (candidate) => {
|
|
21810
22027
|
try {
|
|
21811
|
-
const pkg = JSON.parse(
|
|
22028
|
+
const pkg = JSON.parse(readFileSync16(candidate, "utf-8"));
|
|
21812
22029
|
if (pkg.name !== "@absolutejs/absolute") {
|
|
21813
22030
|
return null;
|
|
21814
22031
|
}
|
|
@@ -21820,9 +22037,9 @@ var readPackageVersion3 = (candidate) => {
|
|
|
21820
22037
|
};
|
|
21821
22038
|
var resolvePackageVersion2 = () => {
|
|
21822
22039
|
const candidates = [
|
|
21823
|
-
|
|
21824
|
-
|
|
21825
|
-
|
|
22040
|
+
resolve22(import.meta.dir, "..", "..", "package.json"),
|
|
22041
|
+
resolve22(import.meta.dir, "..", "..", "..", "package.json"),
|
|
22042
|
+
resolve22(import.meta.dir, "..", "..", "..", "..", "package.json")
|
|
21826
22043
|
];
|
|
21827
22044
|
for (const candidate of candidates) {
|
|
21828
22045
|
const version2 = readPackageVersion3(candidate);
|
|
@@ -22176,15 +22393,15 @@ var createWorkspaceServiceEnv = (services) => {
|
|
|
22176
22393
|
var getDefinedProcessEnv = () => Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string"));
|
|
22177
22394
|
var resolveAbsoluteServiceConfigPath = (service, cwd, options) => {
|
|
22178
22395
|
if (service.config)
|
|
22179
|
-
return
|
|
22396
|
+
return resolve22(cwd, service.config);
|
|
22180
22397
|
if (options.configPath)
|
|
22181
|
-
return
|
|
22398
|
+
return resolve22(options.configPath);
|
|
22182
22399
|
if (process.env.ABSOLUTE_CONFIG)
|
|
22183
|
-
return
|
|
22400
|
+
return resolve22(process.env.ABSOLUTE_CONFIG);
|
|
22184
22401
|
return;
|
|
22185
22402
|
};
|
|
22186
22403
|
var resolveService = (name, service, workspaceEnv, options) => {
|
|
22187
|
-
const cwd =
|
|
22404
|
+
const cwd = resolve22(service.cwd ?? ".");
|
|
22188
22405
|
const envVars = Object.assign(getDefinedProcessEnv(), workspaceEnv, service.port ? { PORT: String(service.port) } : {}, service.env, {
|
|
22189
22406
|
ABSOLUTE_INSTANCE_MANAGED: "1",
|
|
22190
22407
|
ABSOLUTE_WORKSPACE_MANAGED: "1",
|
|
@@ -22196,7 +22413,7 @@ var resolveService = (name, service, workspaceEnv, options) => {
|
|
|
22196
22413
|
if (isAbsoluteService(service)) {
|
|
22197
22414
|
const configPath2 = resolveAbsoluteServiceConfigPath(service, cwd, options);
|
|
22198
22415
|
Object.assign(envVars, configPath2 ? { ABSOLUTE_CONFIG: configPath2 } : {}, {
|
|
22199
|
-
ABSOLUTE_SERVER_ENTRY:
|
|
22416
|
+
ABSOLUTE_SERVER_ENTRY: resolve22(cwd, service.entry ?? DEFAULT_SERVER_ENTRY)
|
|
22200
22417
|
});
|
|
22201
22418
|
const command = [
|
|
22202
22419
|
process.execPath,
|
|
@@ -22226,8 +22443,8 @@ var resolveService = (name, service, workspaceEnv, options) => {
|
|
|
22226
22443
|
var resolveServiceBuildDirectory = (service) => {
|
|
22227
22444
|
if (!isAbsoluteService(service))
|
|
22228
22445
|
return null;
|
|
22229
|
-
const cwd =
|
|
22230
|
-
return
|
|
22446
|
+
const cwd = resolve22(service.cwd ?? ".");
|
|
22447
|
+
return resolve22(cwd, service.buildDirectory ?? "build");
|
|
22231
22448
|
};
|
|
22232
22449
|
var findSharedWorkspaceBuildDirectories = (services) => {
|
|
22233
22450
|
const byBuildDirectory = new Map;
|
|
@@ -22445,7 +22662,7 @@ var workspace = async (subcommand, options) => {
|
|
|
22445
22662
|
frameworks: [],
|
|
22446
22663
|
host: getServicePublicHost(resolved.service),
|
|
22447
22664
|
https: getServiceProtocol(resolved.service) === "https",
|
|
22448
|
-
logFile:
|
|
22665
|
+
logFile: resolve22(workspaceLogs.logDirectory, `${sanitizeLogFileName(name)}.log`),
|
|
22449
22666
|
name,
|
|
22450
22667
|
pid: processHandle.pid,
|
|
22451
22668
|
port: resolved.service.port ?? null,
|