@absolutejs/absolute 0.20.0-beta.13 → 0.20.0-beta.15
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 +40 -0
- package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
- package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
- package/dist/build.js +954 -561
- package/dist/build.js.map +7 -5
- package/dist/cli/index.js +972 -515
- package/dist/index.js +1036 -643
- package/dist/index.js.map +7 -5
- package/dist/mobile/index.js +442 -36
- package/dist/mobile/index.js.map +10 -7
- package/dist/mobile/shellSync.js +8 -1
- package/dist/src/build/pwa.d.ts +2 -1
- package/dist/src/mobile/capacitorBundle.d.ts +3 -0
- package/dist/src/mobile/index.d.ts +1 -0
- package/dist/src/mobile/shellSync.d.ts +2 -2
- package/dist/src/mobile/syncSchema.d.ts +9 -0
- package/dist/src/mobile/transport.d.ts +2 -0
- package/dist/types/build.d.ts +1 -1
- package/package.json +11 -11
package/dist/cli/index.js
CHANGED
|
@@ -3458,7 +3458,7 @@ import {
|
|
|
3458
3458
|
resolve as resolvePath,
|
|
3459
3459
|
sep as sep4
|
|
3460
3460
|
} from "path";
|
|
3461
|
-
var PROFILE_FORMAT = 1, PROFILE_NAME, SSH_DESTINATION, defaultProfilePath = () => join11(homedir4(), ".absolutejs", "mobile", "remote-macs.json"), emptyStore = () => ({
|
|
3461
|
+
var PROFILE_FORMAT = 1, REMOTE_STDIN_FLUSH_ATTEMPTS = 3, PROFILE_NAME, SSH_DESTINATION, defaultProfilePath = () => join11(homedir4(), ".absolutejs", "mobile", "remote-macs.json"), emptyStore = () => ({
|
|
3462
3462
|
format: PROFILE_FORMAT,
|
|
3463
3463
|
profiles: {}
|
|
3464
3464
|
}), loadStore = async (path = defaultProfilePath()) => {
|
|
@@ -3913,8 +3913,17 @@ var PROFILE_FORMAT = 1, PROFILE_NAME, SSH_DESTINATION, defaultProfilePath = () =
|
|
|
3913
3913
|
const response = new Promise((resolve8, reject) => pending.set(id, { reject, resolve: resolve8 }));
|
|
3914
3914
|
process2.stdin.write(`${JSON.stringify({ command: commandName, id, v: 1 })}
|
|
3915
3915
|
`);
|
|
3916
|
-
|
|
3917
|
-
|
|
3916
|
+
const flush = async () => {
|
|
3917
|
+
for (let attempt = 0;attempt < REMOTE_STDIN_FLUSH_ATTEMPTS; attempt++) {
|
|
3918
|
+
try {
|
|
3919
|
+
await process2.stdin.flush();
|
|
3920
|
+
return;
|
|
3921
|
+
} catch {
|
|
3922
|
+
await Promise.resolve();
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
};
|
|
3926
|
+
return flush().then(() => response);
|
|
3918
3927
|
};
|
|
3919
3928
|
let closed = false;
|
|
3920
3929
|
const close = async () => {
|
|
@@ -6107,7 +6116,12 @@ ${authImport}${syncImport}void startAbsoluteMobileShell(${options});
|
|
|
6107
6116
|
endpoint: new URL("/__absolute/sync/background", options.config.productionOrigin).href,
|
|
6108
6117
|
intervalMinutes: 15
|
|
6109
6118
|
},
|
|
6110
|
-
socketTickets: true
|
|
6119
|
+
socketTickets: true,
|
|
6120
|
+
storageSchema: options.syncSchema ?? {
|
|
6121
|
+
components: [
|
|
6122
|
+
{ id: "@absolutejs/app", version: 1 }
|
|
6123
|
+
]
|
|
6124
|
+
}
|
|
6111
6125
|
}
|
|
6112
6126
|
} : {}
|
|
6113
6127
|
};
|
|
@@ -6289,9 +6303,392 @@ var init_materializedBundle = __esm(() => {
|
|
|
6289
6303
|
BUNDLE_ID_PATTERN = /^amb_[a-f0-9]{64}$/;
|
|
6290
6304
|
});
|
|
6291
6305
|
|
|
6306
|
+
// node_modules/@absolutejs/sync/dist/client/index.js
|
|
6307
|
+
var RUNTIME_TRANSPORT, host, isRegistry = (value) => typeof value === "object" && value !== null && Array.isArray(Reflect.get(value, "installations")), registry, SyncLocalDataPolicyError, SyncLocalStoreSchemaError, positiveVersion = (value, label) => {
|
|
6308
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
6309
|
+
throw new SyncLocalStoreSchemaError("INVALID_PLAN", `${label} must be a positive safe integer`);
|
|
6310
|
+
return value;
|
|
6311
|
+
}, isSchemaBundle = (schema) => ("components" in schema), validatePolicyMatch = (match, label) => {
|
|
6312
|
+
if (match.length === 0 || match.trim() !== match || /^\*+$/.test(match) || match.includes("**"))
|
|
6313
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.match must be an exact name or a non-empty glob without adjacent wildcards.`);
|
|
6314
|
+
}, validateSyncLocalDataPolicy = (policy, label = "localData") => {
|
|
6315
|
+
if (policy.maxBytesPerNamespace !== undefined && (!Number.isSafeInteger(policy.maxBytesPerNamespace) || policy.maxBytesPerNamespace < 1))
|
|
6316
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.maxBytesPerNamespace must be a positive safe integer.`);
|
|
6317
|
+
for (const [index, rule] of (policy.collections ?? []).entries()) {
|
|
6318
|
+
validatePolicyMatch(rule.match, `${label}.collections[${index}]`);
|
|
6319
|
+
if (rule.maxAgeMs !== undefined && (!Number.isSafeInteger(rule.maxAgeMs) || rule.maxAgeMs < 1))
|
|
6320
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}].maxAgeMs must be a positive safe integer.`);
|
|
6321
|
+
if (rule.persistence === "memory-only" && rule.protection === "required")
|
|
6322
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}] cannot require at-rest protection when it is memory-only.`);
|
|
6323
|
+
if (rule.sensitivity !== undefined && rule.sensitivity !== "public" && rule.protection !== "required" && rule.persistence !== "memory-only")
|
|
6324
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.collections[${index}] declares ${rule.sensitivity} data without required protection or memory-only persistence.`);
|
|
6325
|
+
}
|
|
6326
|
+
for (const [index, rule] of (policy.mutations ?? []).entries()) {
|
|
6327
|
+
validatePolicyMatch(rule.match, `${label}.mutations[${index}]`);
|
|
6328
|
+
if (rule.sensitivity !== undefined && rule.sensitivity !== "public" && rule.protection !== "required" && rule.persistence !== "memory-only")
|
|
6329
|
+
throw new SyncLocalDataPolicyError("INVALID_POLICY", `${label}.mutations[${index}] declares ${rule.sensitivity} arguments without required protection.`);
|
|
6330
|
+
}
|
|
6331
|
+
return policy;
|
|
6332
|
+
}, normalizeSyncLocalSchemaComponents = (schema = { version: 1 }) => {
|
|
6333
|
+
const components = isSchemaBundle(schema) ? [...schema.components] : [{ ...schema, id: "@absolutejs/app" }];
|
|
6334
|
+
const ids = new Set;
|
|
6335
|
+
for (const component of components) {
|
|
6336
|
+
if (typeof component.id !== "string" || component.id.trim() !== component.id || component.id.length === 0)
|
|
6337
|
+
throw new SyncLocalStoreSchemaError("INVALID_PLAN", "Sync schema component id must be non-empty and trimmed");
|
|
6338
|
+
if (ids.has(component.id))
|
|
6339
|
+
throw new SyncLocalStoreSchemaError("INVALID_PLAN", `Sync schema component "${component.id}" is declared more than once`);
|
|
6340
|
+
ids.add(component.id);
|
|
6341
|
+
if (component.localData)
|
|
6342
|
+
validateSyncLocalDataPolicy(component.localData, `${component.id}.localData`);
|
|
6343
|
+
}
|
|
6344
|
+
return components.sort((a, b) => a.id.localeCompare(b.id));
|
|
6345
|
+
}, resolveSyncLocalSchemaComponents = (storedVersions, schema = { version: 1 }) => {
|
|
6346
|
+
const components = normalizeSyncLocalSchemaComponents(schema).map((component) => {
|
|
6347
|
+
const current = resolveSyncLocalMigrations(component.version, component);
|
|
6348
|
+
return {
|
|
6349
|
+
id: component.id,
|
|
6350
|
+
...resolveSyncLocalMigrations(storedVersions[component.id] ?? current.minimumCompatibleVersion, component)
|
|
6351
|
+
};
|
|
6352
|
+
});
|
|
6353
|
+
const active = new Set(components.map((component) => component.id));
|
|
6354
|
+
const orphanedComponents = Object.keys(storedVersions).filter((id) => !active.has(id)).sort();
|
|
6355
|
+
return { components, orphanedComponents };
|
|
6356
|
+
}, resolveSyncLocalMigrations = (storedVersion, schema = { version: 1 }) => {
|
|
6357
|
+
positiveVersion(storedVersion, "Stored Sync schema version");
|
|
6358
|
+
const targetVersion = positiveVersion(schema.version, "Target Sync schema version");
|
|
6359
|
+
const migrations = [...schema.migrations ?? []].sort((a, b) => a.toVersion - b.toVersion);
|
|
6360
|
+
const versions = new Set;
|
|
6361
|
+
for (const migration of migrations) {
|
|
6362
|
+
positiveVersion(migration.toVersion, "Sync migration toVersion");
|
|
6363
|
+
if (versions.has(migration.toVersion))
|
|
6364
|
+
throw new SyncLocalStoreSchemaError("INVALID_PLAN", `Sync migration ${migration.toVersion} is declared more than once`);
|
|
6365
|
+
versions.add(migration.toVersion);
|
|
6366
|
+
}
|
|
6367
|
+
const inferredMinimum = migrations[0] ? migrations[0].toVersion - 1 : targetVersion;
|
|
6368
|
+
const minimumCompatibleVersion = positiveVersion(schema.minimumCompatibleVersion ?? inferredMinimum, "Minimum compatible Sync schema version");
|
|
6369
|
+
if (minimumCompatibleVersion > targetVersion)
|
|
6370
|
+
throw new SyncLocalStoreSchemaError("INVALID_PLAN", "Minimum compatible Sync schema version cannot exceed its target");
|
|
6371
|
+
if (storedVersion > targetVersion)
|
|
6372
|
+
throw new SyncLocalStoreSchemaError("SCHEMA_TOO_NEW", `Stored Sync schema ${storedVersion} is newer than this runtime's schema ${targetVersion}`, { storedVersion, targetVersion });
|
|
6373
|
+
if (storedVersion < minimumCompatibleVersion)
|
|
6374
|
+
throw new SyncLocalStoreSchemaError("SCHEMA_TOO_OLD", `Stored Sync schema ${storedVersion} is older than the minimum compatible schema ${minimumCompatibleVersion}`, { storedVersion, targetVersion });
|
|
6375
|
+
const steps = [];
|
|
6376
|
+
for (let version2 = storedVersion + 1;version2 <= targetVersion; version2++) {
|
|
6377
|
+
const migration = migrations.find((candidate) => candidate.toVersion === version2);
|
|
6378
|
+
if (migration === undefined)
|
|
6379
|
+
throw new SyncLocalStoreSchemaError("MIGRATION_MISSING", `Sync migration ${version2 - 1} -> ${version2} is missing`, { storedVersion, targetVersion });
|
|
6380
|
+
steps.push(migration);
|
|
6381
|
+
}
|
|
6382
|
+
return { minimumCompatibleVersion, steps, targetVersion };
|
|
6383
|
+
};
|
|
6384
|
+
var init_client2 = __esm(() => {
|
|
6385
|
+
RUNTIME_TRANSPORT = Symbol.for("@absolutejs/sync/client-runtime-transport");
|
|
6386
|
+
host = globalThis;
|
|
6387
|
+
registry = (() => {
|
|
6388
|
+
const existing = host[RUNTIME_TRANSPORT];
|
|
6389
|
+
if (isRegistry(existing))
|
|
6390
|
+
return existing;
|
|
6391
|
+
const created = { installations: [] };
|
|
6392
|
+
Object.defineProperty(host, RUNTIME_TRANSPORT, {
|
|
6393
|
+
configurable: false,
|
|
6394
|
+
enumerable: false,
|
|
6395
|
+
value: created,
|
|
6396
|
+
writable: false
|
|
6397
|
+
});
|
|
6398
|
+
return created;
|
|
6399
|
+
})();
|
|
6400
|
+
SyncLocalDataPolicyError = class SyncLocalDataPolicyError extends Error {
|
|
6401
|
+
code;
|
|
6402
|
+
constructor(code, message) {
|
|
6403
|
+
super(message);
|
|
6404
|
+
this.name = "SyncLocalDataPolicyError";
|
|
6405
|
+
this.code = code;
|
|
6406
|
+
}
|
|
6407
|
+
};
|
|
6408
|
+
SyncLocalStoreSchemaError = class SyncLocalStoreSchemaError extends Error {
|
|
6409
|
+
code;
|
|
6410
|
+
storedVersion;
|
|
6411
|
+
targetVersion;
|
|
6412
|
+
constructor(code, message, versions = {}) {
|
|
6413
|
+
super(message);
|
|
6414
|
+
this.name = "SyncLocalStoreSchemaError";
|
|
6415
|
+
this.code = code;
|
|
6416
|
+
this.storedVersion = versions.storedVersion;
|
|
6417
|
+
this.targetVersion = versions.targetVersion;
|
|
6418
|
+
}
|
|
6419
|
+
};
|
|
6420
|
+
});
|
|
6421
|
+
|
|
6422
|
+
// src/mobile/syncSchema.ts
|
|
6423
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
6424
|
+
import { dirname as dirname12, join as join19, resolve as resolve15 } from "path";
|
|
6425
|
+
var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value), manifestAt = (path) => {
|
|
6426
|
+
try {
|
|
6427
|
+
const value = JSON.parse(readFileSync11(path, "utf8"));
|
|
6428
|
+
return object(value) ? value : undefined;
|
|
6429
|
+
} catch {
|
|
6430
|
+
return;
|
|
6431
|
+
}
|
|
6432
|
+
}, localSchemaMetadata = (manifest) => {
|
|
6433
|
+
const absolutejs = Reflect.get(manifest, "absolutejs");
|
|
6434
|
+
if (!object(absolutejs))
|
|
6435
|
+
return;
|
|
6436
|
+
const sync = Reflect.get(absolutejs, "sync");
|
|
6437
|
+
if (!object(sync))
|
|
6438
|
+
return;
|
|
6439
|
+
return Reflect.get(sync, "localSchema");
|
|
6440
|
+
}, packageManifestPath = (projectRoot, packageName) => {
|
|
6441
|
+
let directory = resolve15(projectRoot);
|
|
6442
|
+
while (true) {
|
|
6443
|
+
const candidate = join19(directory, "node_modules", packageName, "package.json");
|
|
6444
|
+
const manifest = manifestAt(candidate);
|
|
6445
|
+
if (manifest && Reflect.get(manifest, "name") === packageName)
|
|
6446
|
+
return candidate;
|
|
6447
|
+
const parent = dirname12(directory);
|
|
6448
|
+
if (parent === directory)
|
|
6449
|
+
return;
|
|
6450
|
+
directory = parent;
|
|
6451
|
+
}
|
|
6452
|
+
}, metadataError = (id, detail) => new TypeError(`Invalid AbsoluteJS Sync schema metadata for ${id}: ${detail}`), positiveVersion2 = (value, id, field) => {
|
|
6453
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1)
|
|
6454
|
+
throw metadataError(id, `${field} must be a positive safe integer.`);
|
|
6455
|
+
return value;
|
|
6456
|
+
}, nonEmpty = (value, id, field) => {
|
|
6457
|
+
if (typeof value !== "string" || value.trim() !== value || value.length === 0)
|
|
6458
|
+
throw metadataError(id, `${field} must be a non-empty trimmed string.`);
|
|
6459
|
+
return value;
|
|
6460
|
+
}, requireObject = (value, id, detail) => {
|
|
6461
|
+
if (!object(value))
|
|
6462
|
+
throw metadataError(id, detail);
|
|
6463
|
+
return value;
|
|
6464
|
+
}, unknownField = (record, key) => record[key], normalizeJsonValue = (value, id, field) => {
|
|
6465
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
6466
|
+
return value;
|
|
6467
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
6468
|
+
return value;
|
|
6469
|
+
if (Array.isArray(value))
|
|
6470
|
+
return value.map((entry) => normalizeJsonValue(entry, id, field));
|
|
6471
|
+
if (object(value))
|
|
6472
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [
|
|
6473
|
+
key,
|
|
6474
|
+
normalizeJsonValue(entry, id, field)
|
|
6475
|
+
]));
|
|
6476
|
+
throw metadataError(id, `${field} must be JSON-safe.`);
|
|
6477
|
+
}, operation = (value, id, index) => {
|
|
6478
|
+
const record = requireObject(value, id, `migration operation ${index} must be an object.`);
|
|
6479
|
+
const type = Reflect.get(record, "type");
|
|
6480
|
+
const collection = nonEmpty(Reflect.get(record, "collection"), id, `operation ${index}.collection`);
|
|
6481
|
+
if (type === "delete-collection")
|
|
6482
|
+
return { collection, type };
|
|
6483
|
+
if (type === "rename-field")
|
|
6484
|
+
return {
|
|
6485
|
+
collection,
|
|
6486
|
+
from: nonEmpty(Reflect.get(record, "from"), id, `operation ${index}.from`),
|
|
6487
|
+
to: nonEmpty(Reflect.get(record, "to"), id, `operation ${index}.to`),
|
|
6488
|
+
type
|
|
6489
|
+
};
|
|
6490
|
+
const field = nonEmpty(Reflect.get(record, "field"), id, `operation ${index}.field`);
|
|
6491
|
+
if (type === "remove-field")
|
|
6492
|
+
return { collection, field, type };
|
|
6493
|
+
if (type === "set-default")
|
|
6494
|
+
return {
|
|
6495
|
+
collection,
|
|
6496
|
+
field,
|
|
6497
|
+
type,
|
|
6498
|
+
value: normalizeJsonValue(Reflect.get(record, "value"), id, `operation ${index}.value`)
|
|
6499
|
+
};
|
|
6500
|
+
throw metadataError(id, `operation ${index}.type is not supported.`);
|
|
6501
|
+
}, migration = (value, id, index) => {
|
|
6502
|
+
const record = requireObject(value, id, `migration ${index} must be an object.`);
|
|
6503
|
+
const allowed = new Set(["operations", "toVersion"]);
|
|
6504
|
+
const unsupported = Object.keys(record).find((key) => !allowed.has(key));
|
|
6505
|
+
if (unsupported)
|
|
6506
|
+
throw metadataError(id, `migration ${index}.${unsupported} is not declarative metadata.`);
|
|
6507
|
+
const declaredOperations = Reflect.get(record, "operations");
|
|
6508
|
+
if (declaredOperations !== undefined && !Array.isArray(declaredOperations))
|
|
6509
|
+
throw metadataError(id, `migration ${index}.operations must be an array.`);
|
|
6510
|
+
const operations = Array.isArray(declaredOperations) ? declaredOperations : [];
|
|
6511
|
+
return {
|
|
6512
|
+
operations: operations.map((entry, operationIndex) => operation(entry, id, operationIndex)),
|
|
6513
|
+
toVersion: positiveVersion2(Reflect.get(record, "toVersion"), id, `migration ${index}.toVersion`)
|
|
6514
|
+
};
|
|
6515
|
+
}, localDataPolicy = (value, id) => {
|
|
6516
|
+
const record = requireObject(value, id, "localData must be an object.");
|
|
6517
|
+
const allowed = new Set([
|
|
6518
|
+
"collections",
|
|
6519
|
+
"maxBytesPerNamespace",
|
|
6520
|
+
"mutations"
|
|
6521
|
+
]);
|
|
6522
|
+
const unsupported = Object.keys(record).find((key) => !allowed.has(key));
|
|
6523
|
+
if (unsupported)
|
|
6524
|
+
throw metadataError(id, `localData.${unsupported} is not supported.`);
|
|
6525
|
+
const collectionRules = Reflect.get(record, "collections");
|
|
6526
|
+
const mutationRules = Reflect.get(record, "mutations");
|
|
6527
|
+
if (collectionRules !== undefined && !Array.isArray(collectionRules))
|
|
6528
|
+
throw metadataError(id, "localData.collections must be an array.");
|
|
6529
|
+
if (mutationRules !== undefined && !Array.isArray(mutationRules))
|
|
6530
|
+
throw metadataError(id, "localData.mutations must be an array.");
|
|
6531
|
+
const collections = Array.isArray(collectionRules) ? collectionRules.map((entry, index) => {
|
|
6532
|
+
const rule = requireObject(entry, id, `localData.collections[${index}] must be an object.`);
|
|
6533
|
+
const allowedRuleKeys = new Set([
|
|
6534
|
+
"evictionPriority",
|
|
6535
|
+
"match",
|
|
6536
|
+
"maxAgeMs",
|
|
6537
|
+
"onProtectionUnavailable",
|
|
6538
|
+
"persistence",
|
|
6539
|
+
"protection",
|
|
6540
|
+
"sensitivity"
|
|
6541
|
+
]);
|
|
6542
|
+
const unsupportedRuleKey = Object.keys(rule).find((key) => !allowedRuleKeys.has(key));
|
|
6543
|
+
if (unsupportedRuleKey)
|
|
6544
|
+
throw metadataError(id, `localData.collections[${index}].${unsupportedRuleKey} is not supported.`);
|
|
6545
|
+
const match = nonEmpty(Reflect.get(rule, "match"), id, `localData.collections[${index}].match`);
|
|
6546
|
+
const persistence = unknownField(rule, "persistence");
|
|
6547
|
+
const sensitivity = unknownField(rule, "sensitivity");
|
|
6548
|
+
const protection = unknownField(rule, "protection");
|
|
6549
|
+
const onProtectionUnavailable = unknownField(rule, "onProtectionUnavailable");
|
|
6550
|
+
const evictionPriority = unknownField(rule, "evictionPriority");
|
|
6551
|
+
const maxAge = unknownField(rule, "maxAgeMs");
|
|
6552
|
+
if (persistence !== undefined && persistence !== "durable" && persistence !== "memory-only")
|
|
6553
|
+
throw metadataError(id, `localData.collections[${index}].persistence is invalid.`);
|
|
6554
|
+
if (sensitivity !== undefined && sensitivity !== "public" && sensitivity !== "private" && sensitivity !== "secret")
|
|
6555
|
+
throw metadataError(id, `localData.collections[${index}].sensitivity is invalid.`);
|
|
6556
|
+
if (protection !== undefined && protection !== "none" && protection !== "required")
|
|
6557
|
+
throw metadataError(id, `localData.collections[${index}].protection is invalid.`);
|
|
6558
|
+
if (onProtectionUnavailable !== undefined && onProtectionUnavailable !== "error" && onProtectionUnavailable !== "memory-only")
|
|
6559
|
+
throw metadataError(id, `localData.collections[${index}].onProtectionUnavailable is invalid.`);
|
|
6560
|
+
if (evictionPriority !== undefined && evictionPriority !== "critical" && evictionPriority !== "normal" && evictionPriority !== "disposable")
|
|
6561
|
+
throw metadataError(id, `localData.collections[${index}].evictionPriority is invalid.`);
|
|
6562
|
+
return {
|
|
6563
|
+
match,
|
|
6564
|
+
...sensitivity ? { sensitivity } : {},
|
|
6565
|
+
...persistence ? { persistence } : {},
|
|
6566
|
+
...protection ? { protection } : {},
|
|
6567
|
+
...onProtectionUnavailable ? {
|
|
6568
|
+
onProtectionUnavailable
|
|
6569
|
+
} : {},
|
|
6570
|
+
...evictionPriority ? { evictionPriority } : {},
|
|
6571
|
+
...maxAge === undefined ? {} : {
|
|
6572
|
+
maxAgeMs: positiveVersion2(maxAge, id, `localData.collections[${index}].maxAgeMs`)
|
|
6573
|
+
}
|
|
6574
|
+
};
|
|
6575
|
+
}) : undefined;
|
|
6576
|
+
const mutations = Array.isArray(mutationRules) ? mutationRules.map((entry, index) => {
|
|
6577
|
+
const rule = requireObject(entry, id, `localData.mutations[${index}] must be an object.`);
|
|
6578
|
+
const allowedRuleKeys = new Set([
|
|
6579
|
+
"match",
|
|
6580
|
+
"persistence",
|
|
6581
|
+
"protection",
|
|
6582
|
+
"sensitivity"
|
|
6583
|
+
]);
|
|
6584
|
+
const unsupportedRuleKey = Object.keys(rule).find((key) => !allowedRuleKeys.has(key));
|
|
6585
|
+
if (unsupportedRuleKey)
|
|
6586
|
+
throw metadataError(id, `localData.mutations[${index}].${unsupportedRuleKey} is not supported.`);
|
|
6587
|
+
const protection = unknownField(rule, "protection");
|
|
6588
|
+
const sensitivity = unknownField(rule, "sensitivity");
|
|
6589
|
+
const persistence = unknownField(rule, "persistence");
|
|
6590
|
+
if (protection !== undefined && protection !== "none" && protection !== "required")
|
|
6591
|
+
throw metadataError(id, `localData.mutations[${index}].protection is invalid.`);
|
|
6592
|
+
if (sensitivity !== undefined && sensitivity !== "public" && sensitivity !== "private" && sensitivity !== "secret")
|
|
6593
|
+
throw metadataError(id, `localData.mutations[${index}].sensitivity is invalid.`);
|
|
6594
|
+
if (persistence !== undefined && persistence !== "durable" && persistence !== "memory-only")
|
|
6595
|
+
throw metadataError(id, `localData.mutations[${index}].persistence is invalid.`);
|
|
6596
|
+
return {
|
|
6597
|
+
match: nonEmpty(Reflect.get(rule, "match"), id, `localData.mutations[${index}].match`),
|
|
6598
|
+
...sensitivity ? { sensitivity } : {},
|
|
6599
|
+
...persistence ? {
|
|
6600
|
+
persistence
|
|
6601
|
+
} : {},
|
|
6602
|
+
...protection ? { protection } : {}
|
|
6603
|
+
};
|
|
6604
|
+
}) : undefined;
|
|
6605
|
+
const quota = Reflect.get(record, "maxBytesPerNamespace");
|
|
6606
|
+
return {
|
|
6607
|
+
...collections ? { collections } : {},
|
|
6608
|
+
...mutations ? { mutations } : {},
|
|
6609
|
+
...quota === undefined ? {} : {
|
|
6610
|
+
maxBytesPerNamespace: positiveVersion2(quota, id, "localData.maxBytesPerNamespace")
|
|
6611
|
+
}
|
|
6612
|
+
};
|
|
6613
|
+
}, component = (id, value) => {
|
|
6614
|
+
const record = requireObject(value, id, "localSchema must be an object.");
|
|
6615
|
+
const allowed = new Set([
|
|
6616
|
+
"localData",
|
|
6617
|
+
"migrations",
|
|
6618
|
+
"minimumCompatibleVersion",
|
|
6619
|
+
"version"
|
|
6620
|
+
]);
|
|
6621
|
+
const unsupported = Object.keys(record).find((key) => !allowed.has(key));
|
|
6622
|
+
if (unsupported)
|
|
6623
|
+
throw metadataError(id, `${unsupported} is not supported.`);
|
|
6624
|
+
const version2 = positiveVersion2(Reflect.get(record, "version"), id, "version");
|
|
6625
|
+
const declaredMinimum = Reflect.get(record, "minimumCompatibleVersion");
|
|
6626
|
+
const minimumCompatibleVersion = declaredMinimum === undefined ? Math.max(1, version2 - 2) : positiveVersion2(declaredMinimum, id, "minimumCompatibleVersion");
|
|
6627
|
+
const declaredMigrations = Reflect.get(record, "migrations");
|
|
6628
|
+
const declaredLocalData = Reflect.get(record, "localData");
|
|
6629
|
+
if (declaredMigrations !== undefined && !Array.isArray(declaredMigrations))
|
|
6630
|
+
throw metadataError(id, "migrations must be an array.");
|
|
6631
|
+
const migrations = Array.isArray(declaredMigrations) ? declaredMigrations : undefined;
|
|
6632
|
+
return {
|
|
6633
|
+
id,
|
|
6634
|
+
...declaredLocalData === undefined ? {} : { localData: localDataPolicy(declaredLocalData, id) },
|
|
6635
|
+
minimumCompatibleVersion,
|
|
6636
|
+
...Array.isArray(migrations) ? {
|
|
6637
|
+
migrations: migrations.map((entry, index) => migration(entry, id, index))
|
|
6638
|
+
} : {},
|
|
6639
|
+
version: version2
|
|
6640
|
+
};
|
|
6641
|
+
}, dependencyNames = (manifest) => [
|
|
6642
|
+
Reflect.get(manifest, "dependencies"),
|
|
6643
|
+
Reflect.get(manifest, "optionalDependencies"),
|
|
6644
|
+
Reflect.get(manifest, "devDependencies"),
|
|
6645
|
+
Reflect.get(manifest, "peerDependencies")
|
|
6646
|
+
].flatMap((dependencies) => object(dependencies) ? Object.keys(dependencies) : []).filter((name, index, names) => names.indexOf(name) === index).sort(), discoverAbsoluteSyncSchema = (projectRoot) => {
|
|
6647
|
+
const appManifestPath = join19(resolve15(projectRoot), "package.json");
|
|
6648
|
+
const appManifest = manifestAt(appManifestPath);
|
|
6649
|
+
if (!appManifest)
|
|
6650
|
+
return {
|
|
6651
|
+
components: [
|
|
6652
|
+
{
|
|
6653
|
+
id: "@absolutejs/app",
|
|
6654
|
+
minimumCompatibleVersion: 1,
|
|
6655
|
+
version: 1
|
|
6656
|
+
}
|
|
6657
|
+
],
|
|
6658
|
+
sources: []
|
|
6659
|
+
};
|
|
6660
|
+
const appMetadata = localSchemaMetadata(appManifest);
|
|
6661
|
+
const components = [
|
|
6662
|
+
appMetadata === undefined ? { id: "@absolutejs/app", minimumCompatibleVersion: 1, version: 1 } : component("@absolutejs/app", appMetadata)
|
|
6663
|
+
];
|
|
6664
|
+
const sources = [
|
|
6665
|
+
{ id: "@absolutejs/app", manifestPath: appManifestPath }
|
|
6666
|
+
];
|
|
6667
|
+
for (const name of dependencyNames(appManifest)) {
|
|
6668
|
+
const manifestPath = packageManifestPath(projectRoot, name);
|
|
6669
|
+
if (!manifestPath)
|
|
6670
|
+
continue;
|
|
6671
|
+
const manifest = manifestAt(manifestPath);
|
|
6672
|
+
if (!manifest)
|
|
6673
|
+
continue;
|
|
6674
|
+
const metadata = localSchemaMetadata(manifest);
|
|
6675
|
+
if (metadata === undefined)
|
|
6676
|
+
continue;
|
|
6677
|
+
components.push(component(name, metadata));
|
|
6678
|
+
sources.push({ id: name, manifestPath });
|
|
6679
|
+
}
|
|
6680
|
+
components.sort((left, right) => left.id.localeCompare(right.id));
|
|
6681
|
+
sources.sort((left, right) => left.id.localeCompare(right.id));
|
|
6682
|
+
resolveSyncLocalSchemaComponents({}, { components });
|
|
6683
|
+
return { components, sources };
|
|
6684
|
+
};
|
|
6685
|
+
var init_syncSchema = __esm(() => {
|
|
6686
|
+
init_client2();
|
|
6687
|
+
});
|
|
6688
|
+
|
|
6292
6689
|
// src/mobile/buildPipeline.ts
|
|
6293
6690
|
import { readFile as readFile10 } from "fs/promises";
|
|
6294
|
-
import { join as
|
|
6691
|
+
import { join as join20, resolve as resolve16 } from "path";
|
|
6295
6692
|
import { pathToFileURL } from "url";
|
|
6296
6693
|
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) => {
|
|
6297
6694
|
if (loaded.server === app)
|
|
@@ -6320,11 +6717,11 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6320
6717
|
const exportName = serverExportName(loaded, app);
|
|
6321
6718
|
return { app, exportName };
|
|
6322
6719
|
}, finalizeAbsoluteMobileCompatibilityBuild = async (options) => {
|
|
6323
|
-
const buildDirectory =
|
|
6720
|
+
const buildDirectory = resolve16(options.buildDirectory);
|
|
6324
6721
|
const mobile = normalizeAbsoluteMobileConfig(options.mobile, options.projectRoot);
|
|
6325
|
-
const root =
|
|
6722
|
+
const root = join20(buildDirectory, ".absolutejs", "mobile-compatibility");
|
|
6326
6723
|
const [manifestSource, previous] = await Promise.all([
|
|
6327
|
-
readFile10(
|
|
6724
|
+
readFile10(join20(buildDirectory, "manifest.json"), "utf8"),
|
|
6328
6725
|
readAbsoluteMobileMaterializedReleases(root)
|
|
6329
6726
|
]);
|
|
6330
6727
|
const manifest = JSON.parse(manifestSource);
|
|
@@ -6337,11 +6734,11 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6337
6734
|
process.env.ABSOLUTE_BUILD_DIR = buildDirectory;
|
|
6338
6735
|
process.env.ABSOLUTE_COMPILED_RUNTIME = "1";
|
|
6339
6736
|
if (options.configPath) {
|
|
6340
|
-
process.env.ABSOLUTE_CONFIG =
|
|
6737
|
+
process.env.ABSOLUTE_CONFIG = resolve16(options.projectRoot, options.configPath);
|
|
6341
6738
|
}
|
|
6342
6739
|
let loaded;
|
|
6343
6740
|
try {
|
|
6344
|
-
loaded = await loadServerApp(
|
|
6741
|
+
loaded = await loadServerApp(resolve16(options.producerPath));
|
|
6345
6742
|
} finally {
|
|
6346
6743
|
restoreEnvironmentVariable("ABSOLUTE_BUILD_DIR", previousBuildDirectory);
|
|
6347
6744
|
restoreEnvironmentVariable("ABSOLUTE_COMPILED_RUNTIME", previousCompiledRuntime);
|
|
@@ -6354,11 +6751,12 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6354
6751
|
manifest,
|
|
6355
6752
|
previousArtifacts: previous.map(({ artifact }) => artifact),
|
|
6356
6753
|
producerExport: loaded.exportName,
|
|
6357
|
-
producerPath:
|
|
6754
|
+
producerPath: resolve16(options.producerPath),
|
|
6358
6755
|
runtime: String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)
|
|
6359
6756
|
});
|
|
6360
6757
|
const auth = resolveAbsoluteMobileAuthManifest(options.projectRoot, mobile);
|
|
6361
6758
|
const sync = auth !== undefined && projectUsesAbsoluteSync(options.projectRoot);
|
|
6759
|
+
const syncSchema = sync ? discoverAbsoluteSyncSchema(options.projectRoot) : undefined;
|
|
6362
6760
|
if (auth && !loaded.app.routes.some((route) => route.path === "/.well-known/openid-configuration")) {
|
|
6363
6761
|
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.");
|
|
6364
6762
|
}
|
|
@@ -6377,7 +6775,8 @@ var isElysiaApp = (value) => typeof value === "object" && value !== null && type
|
|
|
6377
6775
|
...auth ? { auth } : {},
|
|
6378
6776
|
buildDirectory,
|
|
6379
6777
|
config: mobile,
|
|
6380
|
-
...sync ? { sync: true } : {}
|
|
6778
|
+
...sync ? { sync: true } : {},
|
|
6779
|
+
...syncSchema ? { syncSchema: { components: syncSchema.components } } : {}
|
|
6381
6780
|
});
|
|
6382
6781
|
return current.artifact;
|
|
6383
6782
|
};
|
|
@@ -6389,13 +6788,14 @@ var init_buildPipeline = __esm(() => {
|
|
|
6389
6788
|
init_pageProtocol();
|
|
6390
6789
|
init_releaseArtifact();
|
|
6391
6790
|
init_nativeAuth();
|
|
6791
|
+
init_syncSchema();
|
|
6392
6792
|
});
|
|
6393
6793
|
|
|
6394
6794
|
// src/mobile/routeMetadataTransform.ts
|
|
6395
|
-
import { existsSync as existsSync10, readFileSync as
|
|
6396
|
-
import { dirname as
|
|
6795
|
+
import { existsSync as existsSync10, readFileSync as readFileSync12 } from "fs";
|
|
6796
|
+
import { dirname as dirname13, extname as extname5, relative as relative11, resolve as resolve17 } from "path";
|
|
6397
6797
|
import ts4 from "typescript";
|
|
6398
|
-
var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.replace(/\\/g, "/"), findTsconfig = (entry, projectRoot) => ts4.findConfigFile(
|
|
6798
|
+
var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.replace(/\\/g, "/"), findTsconfig = (entry, projectRoot) => ts4.findConfigFile(dirname13(entry), existsSync10, "tsconfig.json") ?? ts4.findConfigFile(projectRoot, existsSync10, "tsconfig.json"), createProgram = (entry, projectRoot) => {
|
|
6399
6799
|
const configPath2 = findTsconfig(entry, projectRoot);
|
|
6400
6800
|
if (!configPath2) {
|
|
6401
6801
|
return ts4.createProgram([entry], {
|
|
@@ -6406,7 +6806,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6406
6806
|
target: ts4.ScriptTarget.ESNext
|
|
6407
6807
|
});
|
|
6408
6808
|
}
|
|
6409
|
-
const parsed = ts4.parseJsonConfigFileContent(ts4.readConfigFile(configPath2, (path) =>
|
|
6809
|
+
const parsed = ts4.parseJsonConfigFileContent(ts4.readConfigFile(configPath2, (path) => readFileSync12(path, "utf8")).config, ts4.sys, dirname13(configPath2));
|
|
6410
6810
|
if (!parsed.fileNames.includes(entry))
|
|
6411
6811
|
parsed.fileNames.push(entry);
|
|
6412
6812
|
return ts4.createProgram(parsed.fileNames, parsed.options);
|
|
@@ -6418,8 +6818,8 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6418
6818
|
if (ts4.isStringLiteralLike(property.name))
|
|
6419
6819
|
return property.name.text;
|
|
6420
6820
|
return;
|
|
6421
|
-
}, objectPropertyExpression = (
|
|
6422
|
-
const property =
|
|
6821
|
+
}, objectPropertyExpression = (object2, name) => {
|
|
6822
|
+
const property = object2.properties.find((candidate) => propertyName(candidate) === name);
|
|
6423
6823
|
if (property && ts4.isPropertyAssignment(property)) {
|
|
6424
6824
|
return property.initializer;
|
|
6425
6825
|
}
|
|
@@ -6605,8 +7005,8 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6605
7005
|
if (!ts4.isCallExpression(expression))
|
|
6606
7006
|
return;
|
|
6607
7007
|
return callableObject(expression, checker);
|
|
6608
|
-
}, objectAssetKey = (
|
|
6609
|
-
for (const property of [...
|
|
7008
|
+
}, objectAssetKey = (object2, name, checker, bindings = new Map) => {
|
|
7009
|
+
for (const property of [...object2.properties].reverse()) {
|
|
6610
7010
|
if (propertyName(property) === name && ts4.isShorthandPropertyAssignment(property)) {
|
|
6611
7011
|
return assetKeyWithBindings(property.name, checker, bindings);
|
|
6612
7012
|
}
|
|
@@ -6734,7 +7134,7 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6734
7134
|
const checker = program.getTypeChecker();
|
|
6735
7135
|
const analyzed = new Map;
|
|
6736
7136
|
for (const sourceFile of program.getSourceFiles()) {
|
|
6737
|
-
const resolvedFile =
|
|
7137
|
+
const resolvedFile = resolve17(sourceFile.fileName);
|
|
6738
7138
|
if (!isProjectSource(sourceFile, resolvedFile, projectRoot))
|
|
6739
7139
|
continue;
|
|
6740
7140
|
const analysis = analyzeSourceFile(sourceFile, checker, projectRoot);
|
|
@@ -6820,14 +7220,14 @@ var ROUTE_METHODS, SOURCE_FILTER, PAGE_HANDLERS, posixPath = (value) => value.re
|
|
|
6820
7220
|
result.dispose();
|
|
6821
7221
|
}
|
|
6822
7222
|
}, createAbsoluteMobileRouteMetadataPlugin = (options) => {
|
|
6823
|
-
const projectRoot =
|
|
6824
|
-
const entry =
|
|
7223
|
+
const projectRoot = resolve17(options.projectRoot ?? process.cwd());
|
|
7224
|
+
const entry = resolve17(options.entry);
|
|
6825
7225
|
const analyzed = analyzeProgram(createProgram(entry, projectRoot), projectRoot);
|
|
6826
7226
|
return {
|
|
6827
7227
|
name: "absolute-mobile-route-metadata",
|
|
6828
7228
|
setup(build) {
|
|
6829
7229
|
build.onLoad({ filter: SOURCE_FILTER }, async ({ path }) => {
|
|
6830
|
-
const analysis = analyzed.get(
|
|
7230
|
+
const analysis = analyzed.get(resolve17(path));
|
|
6831
7231
|
if (!analysis)
|
|
6832
7232
|
return;
|
|
6833
7233
|
const source = await Bun.file(path).text();
|
|
@@ -6894,7 +7294,7 @@ var init_routeMetadataTransform = __esm(() => {
|
|
|
6894
7294
|
});
|
|
6895
7295
|
|
|
6896
7296
|
// src/cli/elysiaOpenApiTypeboxPlugin.ts
|
|
6897
|
-
import { dirname as
|
|
7297
|
+
import { dirname as dirname14, resolve as resolve18 } from "path";
|
|
6898
7298
|
var OPENAPI_TYPEBOX_PREFIX = "../node_modules/typebox/", OPENAPI_DISTRIBUTION_SEGMENT = "/@elysia/openapi/dist/", createElysiaOpenApiTypeboxPlugin = () => ({
|
|
6899
7299
|
name: "absolute-elysia-openapi-typebox",
|
|
6900
7300
|
setup(build) {
|
|
@@ -6904,9 +7304,9 @@ var OPENAPI_TYPEBOX_PREFIX = "../node_modules/typebox/", OPENAPI_DISTRIBUTION_SE
|
|
|
6904
7304
|
return;
|
|
6905
7305
|
}
|
|
6906
7306
|
const relativePath = args.path.slice(OPENAPI_TYPEBOX_PREFIX.length);
|
|
6907
|
-
const typeboxEntry = Bun.resolveSync("typebox",
|
|
7307
|
+
const typeboxEntry = Bun.resolveSync("typebox", dirname14(args.importer));
|
|
6908
7308
|
return {
|
|
6909
|
-
path:
|
|
7309
|
+
path: resolve18(dirname14(typeboxEntry), "..", relativePath)
|
|
6910
7310
|
};
|
|
6911
7311
|
});
|
|
6912
7312
|
}
|
|
@@ -6966,15 +7366,15 @@ __export(exports_prerender, {
|
|
|
6966
7366
|
prerender: () => prerender,
|
|
6967
7367
|
PRERENDER_BYPASS_HEADER: () => PRERENDER_BYPASS_HEADER
|
|
6968
7368
|
});
|
|
6969
|
-
import { mkdirSync as mkdirSync6, readFileSync as
|
|
6970
|
-
import { join as
|
|
7369
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync13 } from "fs";
|
|
7370
|
+
import { join as join21 } from "path";
|
|
6971
7371
|
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) => {
|
|
6972
7372
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
6973
7373
|
await Bun.write(metaPath, String(Date.now()));
|
|
6974
7374
|
}, readTimestamp = (htmlPath) => {
|
|
6975
7375
|
const metaPath = htmlPath.replace(/\.html$/, ".meta");
|
|
6976
7376
|
try {
|
|
6977
|
-
const content =
|
|
7377
|
+
const content = readFileSync13(metaPath, "utf-8");
|
|
6978
7378
|
return Number(content) || 0;
|
|
6979
7379
|
} catch {
|
|
6980
7380
|
return 0;
|
|
@@ -7037,7 +7437,7 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
7037
7437
|
if (!isCompleteHtml(html))
|
|
7038
7438
|
return false;
|
|
7039
7439
|
const fileName = routeToFilename(route);
|
|
7040
|
-
const filePath =
|
|
7440
|
+
const filePath = join21(prerenderDir, fileName);
|
|
7041
7441
|
await Bun.write(filePath, html);
|
|
7042
7442
|
await writeTimestamp(filePath);
|
|
7043
7443
|
return true;
|
|
@@ -7067,13 +7467,13 @@ var SERVER_OUTPUT_LIMIT = 4000, STARTUP_POLL_INTERVAL_MS = 100, DEFAULT_STARTUP_
|
|
|
7067
7467
|
return;
|
|
7068
7468
|
}
|
|
7069
7469
|
const fileName = routeToFilename(route);
|
|
7070
|
-
const filePath =
|
|
7470
|
+
const filePath = join21(prerenderDir, fileName);
|
|
7071
7471
|
await Bun.write(filePath, html);
|
|
7072
7472
|
await writeTimestamp(filePath);
|
|
7073
7473
|
result.routes.set(route, filePath);
|
|
7074
7474
|
log?.(` Pre-rendered ${route} \u2192 ${fileName} (${html.length} bytes)`);
|
|
7075
7475
|
}, prerender = async (port, outDir, staticConfig, log) => {
|
|
7076
|
-
const prerenderDir =
|
|
7476
|
+
const prerenderDir = join21(outDir, "_prerendered");
|
|
7077
7477
|
mkdirSync6(prerenderDir, { recursive: true });
|
|
7078
7478
|
const baseUrl = `http://localhost:${port}`;
|
|
7079
7479
|
let routes;
|
|
@@ -7449,7 +7849,7 @@ var init_maskLiterals = __esm(() => {
|
|
|
7449
7849
|
// src/build/nativeRewrite.ts
|
|
7450
7850
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
7451
7851
|
import { platform as platform4, arch as arch3 } from "os";
|
|
7452
|
-
import { resolve as
|
|
7852
|
+
import { resolve as resolve19 } from "path";
|
|
7453
7853
|
var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
7454
7854
|
if (nativeLib !== null)
|
|
7455
7855
|
return nativeLib;
|
|
@@ -7467,7 +7867,7 @@ var ffiDefinition, nativeLib = null, loadNative = () => {
|
|
|
7467
7867
|
if (!libPath)
|
|
7468
7868
|
return null;
|
|
7469
7869
|
try {
|
|
7470
|
-
const fullPath =
|
|
7870
|
+
const fullPath = resolve19(import.meta.dir, "../../native/packages", libPath);
|
|
7471
7871
|
const lib = dlopen(fullPath, ffiDefinition);
|
|
7472
7872
|
nativeLib = lib.symbols;
|
|
7473
7873
|
return nativeLib;
|
|
@@ -7509,7 +7909,7 @@ var init_nativeRewrite = __esm(() => {
|
|
|
7509
7909
|
|
|
7510
7910
|
// src/build/rewriteImportsPlugin.ts
|
|
7511
7911
|
import { readdir as readdir3 } from "fs/promises";
|
|
7512
|
-
import { join as
|
|
7912
|
+
import { join as join22 } from "path";
|
|
7513
7913
|
var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
|
|
7514
7914
|
let result = content;
|
|
7515
7915
|
for (const [specifier, webPath] of replacements) {
|
|
@@ -7588,7 +7988,7 @@ ${content}`;
|
|
|
7588
7988
|
const entries = await readdir3(dir);
|
|
7589
7989
|
for (const entry of entries) {
|
|
7590
7990
|
if (entry.endsWith(".js"))
|
|
7591
|
-
allFiles.push(
|
|
7991
|
+
allFiles.push(join22(dir, entry));
|
|
7592
7992
|
}
|
|
7593
7993
|
} catch {}
|
|
7594
7994
|
}
|
|
@@ -7663,8 +8063,8 @@ var init_rewriteImports = __esm(() => {
|
|
|
7663
8063
|
|
|
7664
8064
|
// src/cli/scripts/start.ts
|
|
7665
8065
|
var {env: env2 } = globalThis.Bun;
|
|
7666
|
-
import { existsSync as existsSync11, readFileSync as
|
|
7667
|
-
import { basename as basename8, join as
|
|
8066
|
+
import { existsSync as existsSync11, readFileSync as readFileSync14, rmSync as rmSync4 } from "fs";
|
|
8067
|
+
import { basename as basename8, join as join23, resolve as resolve20 } from "path";
|
|
7668
8068
|
var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, resolvePackageVersion = (candidates) => {
|
|
7669
8069
|
for (const candidate of candidates) {
|
|
7670
8070
|
const version2 = readPackageVersion2(candidate);
|
|
@@ -7675,7 +8075,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
7675
8075
|
return "";
|
|
7676
8076
|
}, readPackageVersion2 = (candidate) => {
|
|
7677
8077
|
try {
|
|
7678
|
-
const pkg = JSON.parse(
|
|
8078
|
+
const pkg = JSON.parse(readFileSync14(candidate, "utf-8"));
|
|
7679
8079
|
if (pkg.name !== "@absolutejs/absolute")
|
|
7680
8080
|
return null;
|
|
7681
8081
|
const ver = pkg.version;
|
|
@@ -7713,18 +8113,18 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
7713
8113
|
process.exit(1);
|
|
7714
8114
|
}, resolveJsxDevRuntimeCompatPath = () => {
|
|
7715
8115
|
const candidates = [
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
8116
|
+
resolve20(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
8117
|
+
resolve20(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
8118
|
+
resolve20(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
|
|
8119
|
+
resolve20(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
8120
|
+
resolve20(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
8121
|
+
resolve20(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
|
|
7722
8122
|
];
|
|
7723
8123
|
for (const candidate of candidates) {
|
|
7724
8124
|
if (existsSync11(candidate))
|
|
7725
8125
|
return candidate;
|
|
7726
8126
|
}
|
|
7727
|
-
return
|
|
8127
|
+
return resolve20(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
|
|
7728
8128
|
}, jsxDevRuntimeCompatPath, prerenderStaticPages = async (outputPath, prerenderPort, resolvedOutdir, staticConfig, absoluteVersion, configPath2) => {
|
|
7729
8129
|
const prerenderStart = performance.now();
|
|
7730
8130
|
process.stdout.write(cliTag2("\x1B[36m", "Pre-rendering static pages"));
|
|
@@ -7758,7 +8158,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
7758
8158
|
serverEntry,
|
|
7759
8159
|
totalDuration
|
|
7760
8160
|
}) => {
|
|
7761
|
-
const usesDocker = existsSync11(
|
|
8161
|
+
const usesDocker = existsSync11(resolve20(COMPOSE_PATH));
|
|
7762
8162
|
const scripts = usesDocker ? await readDbScripts() : null;
|
|
7763
8163
|
if (scripts)
|
|
7764
8164
|
await startDatabase(scripts);
|
|
@@ -7849,10 +8249,10 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
7849
8249
|
const port = Number(env2.PORT) || DEFAULT_PORT;
|
|
7850
8250
|
killStaleProcesses(port);
|
|
7851
8251
|
const entryName = basename8(serverEntry).replace(/\.[^.]+$/, "");
|
|
7852
|
-
const resolvedOutdir =
|
|
8252
|
+
const resolvedOutdir = resolve20(outdir ?? "dist");
|
|
7853
8253
|
const absoluteVersion = resolvePackageVersion([
|
|
7854
|
-
|
|
7855
|
-
|
|
8254
|
+
resolve20(import.meta.dir, "..", "..", "..", "package.json"),
|
|
8255
|
+
resolve20(import.meta.dir, "..", "..", "package.json")
|
|
7856
8256
|
]);
|
|
7857
8257
|
const buildConfig = await loadConfig(configPath2);
|
|
7858
8258
|
buildConfig.buildDirectory = resolvedOutdir;
|
|
@@ -7867,7 +8267,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
7867
8267
|
buildConfig.vueDirectory && "vue",
|
|
7868
8268
|
buildConfig.angularDirectory && "angular"
|
|
7869
8269
|
].filter((val) => Boolean(val));
|
|
7870
|
-
const outputPath =
|
|
8270
|
+
const outputPath = resolve20(resolvedOutdir, `${entryName}.js`);
|
|
7871
8271
|
if (options.prebuilt) {
|
|
7872
8272
|
if (!existsSync11(outputPath)) {
|
|
7873
8273
|
throw new Error(`Prepared production server not found: ${outputPath}`);
|
|
@@ -7890,13 +8290,13 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
7890
8290
|
process.stdout.write(cliTag2("\x1B[36m", `Building assets`));
|
|
7891
8291
|
try {
|
|
7892
8292
|
const build = await resolveBuildModule([
|
|
7893
|
-
|
|
7894
|
-
|
|
8293
|
+
resolve20(import.meta.dir, "..", "..", "core", "build"),
|
|
8294
|
+
resolve20(import.meta.dir, "..", "build")
|
|
7895
8295
|
]);
|
|
7896
8296
|
if (!build)
|
|
7897
8297
|
throw new Error("Could not locate build module");
|
|
7898
8298
|
await build(buildConfig);
|
|
7899
|
-
rmSync4(
|
|
8299
|
+
rmSync4(join23(resolvedOutdir, "_prerendered"), {
|
|
7900
8300
|
force: true,
|
|
7901
8301
|
recursive: true
|
|
7902
8302
|
});
|
|
@@ -7973,17 +8373,17 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
7973
8373
|
}
|
|
7974
8374
|
};
|
|
7975
8375
|
const islandRegistrySpec = buildConfig.islands?.registry;
|
|
7976
|
-
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(
|
|
8376
|
+
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve20(islandRegistrySpec))) : undefined;
|
|
7977
8377
|
const serverBundle = await Bun.build({
|
|
7978
8378
|
define: { "process.env.NODE_ENV": '"production"' },
|
|
7979
|
-
entrypoints: [
|
|
8379
|
+
entrypoints: [resolve20(serverEntry)],
|
|
7980
8380
|
external: resolveServerBundleExternals(buildConfig),
|
|
7981
8381
|
outdir: resolvedOutdir,
|
|
7982
8382
|
plugins: [
|
|
7983
8383
|
...islandRegistryPlugin ? [islandRegistryPlugin] : [],
|
|
7984
8384
|
...buildConfig.mobile ? [
|
|
7985
8385
|
createAbsoluteMobileRouteMetadataPlugin({
|
|
7986
|
-
entry:
|
|
8386
|
+
entry: resolve20(serverEntry)
|
|
7987
8387
|
})
|
|
7988
8388
|
] : [],
|
|
7989
8389
|
createElysiaOpenApiTypeboxPlugin(),
|
|
@@ -8000,9 +8400,9 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8000
8400
|
console.error(cliTag2("\x1B[31m", `Expected output not found: ${outputPath}`));
|
|
8001
8401
|
process.exit(1);
|
|
8002
8402
|
}
|
|
8003
|
-
if (existsSync11(
|
|
8403
|
+
if (existsSync11(resolve20(resolvedOutdir, "angular", "vendor", "server"))) {
|
|
8004
8404
|
const { readdirSync: readdirSync2 } = await import("fs");
|
|
8005
|
-
const vendorDir =
|
|
8405
|
+
const vendorDir = resolve20(resolvedOutdir, "angular", "vendor", "server");
|
|
8006
8406
|
const vendorEntries = readdirSync2(vendorDir).filter((fileName) => fileName.endsWith(".js"));
|
|
8007
8407
|
const angularServerVendorPaths = {};
|
|
8008
8408
|
const { relative: pathRelative, dirname: pathDirname } = await import("path");
|
|
@@ -8012,7 +8412,7 @@ var cliTag2 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
8012
8412
|
if (scope !== "angular" || rest.length === 0)
|
|
8013
8413
|
continue;
|
|
8014
8414
|
const specifier = `@angular/${rest.join("/")}`;
|
|
8015
|
-
const relPath = pathRelative(pathDirname(outputPath),
|
|
8415
|
+
const relPath = pathRelative(pathDirname(outputPath), resolve20(vendorDir, file));
|
|
8016
8416
|
angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
8017
8417
|
}
|
|
8018
8418
|
if (Object.keys(angularServerVendorPaths).length > 0) {
|
|
@@ -8199,17 +8599,17 @@ var exports_build = {};
|
|
|
8199
8599
|
__export(exports_build, {
|
|
8200
8600
|
build: () => build
|
|
8201
8601
|
});
|
|
8202
|
-
import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as
|
|
8203
|
-
import { join as
|
|
8602
|
+
import { existsSync as existsSync13, readdirSync as readdirSync3, readFileSync as readFileSync16 } from "fs";
|
|
8603
|
+
import { join as join24, resolve as resolve22 } from "path";
|
|
8204
8604
|
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) => {
|
|
8205
|
-
const traceDir =
|
|
8605
|
+
const traceDir = join24(buildDir, ".absolute-trace");
|
|
8206
8606
|
if (!existsSync13(traceDir))
|
|
8207
8607
|
return;
|
|
8208
8608
|
const files = readdirSync3(traceDir).filter((file) => file.endsWith(".json")).sort();
|
|
8209
8609
|
const latest = files[files.length - 1];
|
|
8210
8610
|
if (latest === undefined)
|
|
8211
8611
|
return;
|
|
8212
|
-
const trace = JSON.parse(
|
|
8612
|
+
const trace = JSON.parse(readFileSync16(join24(traceDir, latest), "utf-8"));
|
|
8213
8613
|
const events = Array.isArray(trace.events) ? trace.events : [];
|
|
8214
8614
|
if (events.length === 0)
|
|
8215
8615
|
return;
|
|
@@ -8246,7 +8646,7 @@ var PROFILE_TOP = 15, PROFILE_COL = 8, FRAMEWORK_KEYS, cliTag3 = (color, message
|
|
|
8246
8646
|
}
|
|
8247
8647
|
return resolveBuildModule2(remaining);
|
|
8248
8648
|
}, build = async (outdir, configPath2, profile = false) => {
|
|
8249
|
-
const resolvedOutdir =
|
|
8649
|
+
const resolvedOutdir = resolve22(outdir ?? "build");
|
|
8250
8650
|
const buildStart = performance.now();
|
|
8251
8651
|
if (profile)
|
|
8252
8652
|
process.env.ABSOLUTE_BUILD_TRACE = "1";
|
|
@@ -8256,8 +8656,8 @@ var PROFILE_TOP = 15, PROFILE_COL = 8, FRAMEWORK_KEYS, cliTag3 = (color, message
|
|
|
8256
8656
|
buildConfig.mode = "production";
|
|
8257
8657
|
try {
|
|
8258
8658
|
const buildApp = await resolveBuildModule2([
|
|
8259
|
-
|
|
8260
|
-
|
|
8659
|
+
resolve22(import.meta.dir, "..", "..", "core", "build"),
|
|
8660
|
+
resolve22(import.meta.dir, "..", "build")
|
|
8261
8661
|
]);
|
|
8262
8662
|
if (!buildApp)
|
|
8263
8663
|
throw new Error("Could not locate build module");
|
|
@@ -8306,14 +8706,14 @@ import {
|
|
|
8306
8706
|
lstatSync,
|
|
8307
8707
|
mkdirSync as mkdirSync8,
|
|
8308
8708
|
mkdtempSync,
|
|
8309
|
-
readFileSync as
|
|
8709
|
+
readFileSync as readFileSync17,
|
|
8310
8710
|
realpathSync,
|
|
8311
8711
|
renameSync as renameSync2,
|
|
8312
8712
|
rmSync as rmSync5,
|
|
8313
8713
|
writeFileSync as writeFileSync7
|
|
8314
8714
|
} from "fs";
|
|
8315
8715
|
import { tmpdir as tmpdir3 } from "os";
|
|
8316
|
-
import { delimiter, dirname as
|
|
8716
|
+
import { delimiter, dirname as dirname15, relative as relative12, resolve as resolve23 } from "path";
|
|
8317
8717
|
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) => {
|
|
8318
8718
|
const proc = Bun.spawnSync(["git", ...args], {
|
|
8319
8719
|
cwd: options.cwd,
|
|
@@ -8326,7 +8726,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8326
8726
|
throw new Error(detail || `git ${args.join(" ")} failed`);
|
|
8327
8727
|
}
|
|
8328
8728
|
return proc.stdout.toString().trim();
|
|
8329
|
-
}, gitRoot = (cwd) =>
|
|
8729
|
+
}, gitRoot = (cwd) => resolve23(runGit(["rev-parse", "--show-toplevel"], { cwd })), isInside3 = (parent, candidate) => {
|
|
8330
8730
|
const path = relative12(parent, candidate);
|
|
8331
8731
|
return path === "" || !path.startsWith("../") && path !== "..";
|
|
8332
8732
|
}, attestationPayload = (proof) => Buffer.from([
|
|
@@ -8339,17 +8739,17 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8339
8739
|
sourceTree: proof.sourceTree
|
|
8340
8740
|
})
|
|
8341
8741
|
].join("\x00")), publicKeyId = (key) => createHash11("sha256").update(key.export({ format: "der", type: "spki" })).digest("hex"), readEd25519PrivateKey = (cwd, location) => {
|
|
8342
|
-
const path =
|
|
8742
|
+
const path = resolve23(cwd, location);
|
|
8343
8743
|
if (isInside3(realpathSync(gitRoot(cwd)), realpathSync(path))) {
|
|
8344
8744
|
throw new Error("lint proof signing key must live outside the Git working tree");
|
|
8345
8745
|
}
|
|
8346
|
-
const key = createPrivateKey(
|
|
8746
|
+
const key = createPrivateKey(readFileSync17(path));
|
|
8347
8747
|
if (key.asymmetricKeyType !== "ed25519") {
|
|
8348
8748
|
throw new Error("lint proof signing key must be an Ed25519 private key");
|
|
8349
8749
|
}
|
|
8350
8750
|
return key;
|
|
8351
8751
|
}, readEd25519PublicKey = (cwd, location) => {
|
|
8352
|
-
const key = createPublicKey(
|
|
8752
|
+
const key = createPublicKey(readFileSync17(resolve23(cwd, location)));
|
|
8353
8753
|
if (key.asymmetricKeyType !== "ed25519") {
|
|
8354
8754
|
throw new Error("trusted lint proof key must be an Ed25519 public key");
|
|
8355
8755
|
}
|
|
@@ -8387,17 +8787,17 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8387
8787
|
].sort();
|
|
8388
8788
|
}, createLintSourceTree = (cwd = process.cwd(), proofLocation = DEFAULT_PROOF_LOCATION, command = []) => {
|
|
8389
8789
|
const root = gitRoot(cwd);
|
|
8390
|
-
const proofPath =
|
|
8790
|
+
const proofPath = resolve23(cwd, proofLocation);
|
|
8391
8791
|
const proofRelative = relative12(root, proofPath).replaceAll("\\", "/");
|
|
8392
8792
|
if (proofRelative === ".." || proofRelative.startsWith("../") || proofRelative === "") {
|
|
8393
8793
|
throw new Error("lint proof must live inside the Git working tree");
|
|
8394
8794
|
}
|
|
8395
|
-
const temporaryDirectory = mkdtempSync(
|
|
8396
|
-
const temporaryIndex =
|
|
8397
|
-
const temporaryObjects =
|
|
8795
|
+
const temporaryDirectory = mkdtempSync(resolve23(tmpdir3(), "absolute-lint-proof-"));
|
|
8796
|
+
const temporaryIndex = resolve23(temporaryDirectory, "index");
|
|
8797
|
+
const temporaryObjects = resolve23(temporaryDirectory, "objects");
|
|
8398
8798
|
mkdirSync8(temporaryObjects, { recursive: true });
|
|
8399
8799
|
const repositoryObjectsPath = runGit(["rev-parse", "--git-path", "objects"], { cwd: root });
|
|
8400
|
-
const repositoryObjects =
|
|
8800
|
+
const repositoryObjects = resolve23(root, repositoryObjectsPath);
|
|
8401
8801
|
const existingAlternates = process.env.GIT_ALTERNATE_OBJECT_DIRECTORIES?.trim();
|
|
8402
8802
|
const env3 = {
|
|
8403
8803
|
GIT_ALTERNATE_OBJECT_DIRECTORIES: [
|
|
@@ -8421,7 +8821,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8421
8821
|
if (!path || path === proofRelative)
|
|
8422
8822
|
return false;
|
|
8423
8823
|
try {
|
|
8424
|
-
lstatSync(
|
|
8824
|
+
lstatSync(resolve23(root, path));
|
|
8425
8825
|
return true;
|
|
8426
8826
|
} catch {
|
|
8427
8827
|
return false;
|
|
@@ -8445,7 +8845,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8445
8845
|
}, writeLintProof = (command, options = {}) => {
|
|
8446
8846
|
const cwd = options.cwd ?? process.cwd();
|
|
8447
8847
|
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
8448
|
-
const path =
|
|
8848
|
+
const path = resolve23(cwd, proofLocation);
|
|
8449
8849
|
const temporary = `${path}.${process.pid}.tmp`;
|
|
8450
8850
|
const proof = createLintProof(command, { cwd, proofLocation });
|
|
8451
8851
|
if (options.signingKeyLocation) {
|
|
@@ -8457,7 +8857,7 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8457
8857
|
signature: sign(null, attestationPayload(proof), privateKey).toString("base64")
|
|
8458
8858
|
};
|
|
8459
8859
|
}
|
|
8460
|
-
mkdirSync8(
|
|
8860
|
+
mkdirSync8(dirname15(path), { recursive: true });
|
|
8461
8861
|
writeFileSync7(temporary, `${JSON.stringify(proof, null, 2)}
|
|
8462
8862
|
`);
|
|
8463
8863
|
renameSync2(temporary, path);
|
|
@@ -8501,12 +8901,12 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8501
8901
|
}, verifyLintProof = (command, options = {}) => {
|
|
8502
8902
|
const cwd = options.cwd ?? process.cwd();
|
|
8503
8903
|
const proofLocation = options.proofLocation ?? DEFAULT_PROOF_LOCATION;
|
|
8504
|
-
const path =
|
|
8904
|
+
const path = resolve23(cwd, proofLocation);
|
|
8505
8905
|
if (!existsSync14(path))
|
|
8506
8906
|
return { reason: `missing lint proof: ${proofLocation}`, valid: false };
|
|
8507
8907
|
let proof;
|
|
8508
8908
|
try {
|
|
8509
|
-
proof = JSON.parse(
|
|
8909
|
+
proof = JSON.parse(readFileSync17(path, "utf-8"));
|
|
8510
8910
|
} catch {
|
|
8511
8911
|
return { reason: `invalid lint proof: ${proofLocation}`, valid: false };
|
|
8512
8912
|
}
|
|
@@ -8567,8 +8967,8 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8567
8967
|
console.log(`\x1B[32m\u2713\x1B[0m Lint proof matches the source tree, command, and lint toolchain${parsed.trustedKeyLocation ? ", with a trusted signature" : ""}`);
|
|
8568
8968
|
return 0;
|
|
8569
8969
|
}, runLintProof = async (args) => {
|
|
8570
|
-
const [
|
|
8571
|
-
if (
|
|
8970
|
+
const [operation2] = args;
|
|
8971
|
+
if (operation2 !== "run" && operation2 !== "verify") {
|
|
8572
8972
|
console.error("Usage: absolute lint-proof <run|verify> [--proof path] [--signing-key path | --trusted-key path] -- <lint command>");
|
|
8573
8973
|
return 2;
|
|
8574
8974
|
}
|
|
@@ -8583,15 +8983,15 @@ var DEFAULT_PROOF_LOCATION = ".absolutejs/lint-proof.json", PROOF_CONTRACT_VERSI
|
|
|
8583
8983
|
console.error("A lint command is required after --");
|
|
8584
8984
|
return 2;
|
|
8585
8985
|
}
|
|
8586
|
-
if (
|
|
8986
|
+
if (operation2 === "run" && parsed.trustedKeyLocation) {
|
|
8587
8987
|
console.error("--trusted-key is only valid with lint-proof verify");
|
|
8588
8988
|
return 2;
|
|
8589
8989
|
}
|
|
8590
|
-
if (
|
|
8990
|
+
if (operation2 === "verify" && parsed.signingKeyLocation) {
|
|
8591
8991
|
console.error("--signing-key is only valid with lint-proof run");
|
|
8592
8992
|
return 2;
|
|
8593
8993
|
}
|
|
8594
|
-
if (
|
|
8994
|
+
if (operation2 === "verify")
|
|
8595
8995
|
return runVerification(parsed);
|
|
8596
8996
|
const proc = Bun.spawn(parsed.command, {
|
|
8597
8997
|
stderr: "inherit",
|
|
@@ -8671,8 +9071,8 @@ var exports_ls = {};
|
|
|
8671
9071
|
__export(exports_ls, {
|
|
8672
9072
|
runLs: () => runLs
|
|
8673
9073
|
});
|
|
8674
|
-
import { existsSync as existsSync16, readFileSync as
|
|
8675
|
-
import { basename as basename10, extname as extname6, join as
|
|
9074
|
+
import { existsSync as existsSync16, readFileSync as readFileSync18, statSync } from "fs";
|
|
9075
|
+
import { basename as basename10, extname as extname6, join as join25, relative as relative13 } from "path";
|
|
8676
9076
|
var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELDS, readStringField = (source, key) => {
|
|
8677
9077
|
const value = Reflect.get(source, key);
|
|
8678
9078
|
return typeof value === "string" ? value : undefined;
|
|
@@ -8694,13 +9094,13 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
8694
9094
|
const dir = readStringField(source, framework.field);
|
|
8695
9095
|
return dir === undefined ? [] : [
|
|
8696
9096
|
{
|
|
8697
|
-
dir:
|
|
9097
|
+
dir: join25(baseDir, dir),
|
|
8698
9098
|
label: framework.label,
|
|
8699
9099
|
pattern: framework.pattern
|
|
8700
9100
|
}
|
|
8701
9101
|
];
|
|
8702
9102
|
}), scanFramework = async (spec) => {
|
|
8703
|
-
const { pageFiles } = await scanConventions(
|
|
9103
|
+
const { pageFiles } = await scanConventions(join25(spec.dir, "pages"), spec.pattern);
|
|
8704
9104
|
if (pageFiles.length === 0)
|
|
8705
9105
|
return null;
|
|
8706
9106
|
const pages = pageFiles.map((file) => ({
|
|
@@ -8724,10 +9124,10 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
8724
9124
|
}, resolveDiskPath = (buildDir, value) => {
|
|
8725
9125
|
if (existsSync16(value))
|
|
8726
9126
|
return value;
|
|
8727
|
-
const underBuild =
|
|
9127
|
+
const underBuild = join25(buildDir, value);
|
|
8728
9128
|
if (existsSync16(underBuild))
|
|
8729
9129
|
return underBuild;
|
|
8730
|
-
return
|
|
9130
|
+
return join25(process.cwd(), value);
|
|
8731
9131
|
}, fileSize = (diskPath) => {
|
|
8732
9132
|
try {
|
|
8733
9133
|
return statSync(diskPath).size;
|
|
@@ -8735,7 +9135,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
8735
9135
|
return 0;
|
|
8736
9136
|
}
|
|
8737
9137
|
}, readManifestSizes = (manifestDir) => {
|
|
8738
|
-
const manifest = JSON.parse(
|
|
9138
|
+
const manifest = JSON.parse(readFileSync18(join25(manifestDir, "manifest.json"), "utf-8"));
|
|
8739
9139
|
const sizes = new Map;
|
|
8740
9140
|
Object.entries(manifest).forEach(([key, value]) => {
|
|
8741
9141
|
sizes.set(key, fileSize(resolveDiskPath(manifestDir, value)));
|
|
@@ -8754,7 +9154,7 @@ var DEFAULT_BUILD_DIR = "build", LABEL_ORDER, ARTIFACT_SUFFIXES, FRAMEWORK_FIELD
|
|
|
8754
9154
|
}))
|
|
8755
9155
|
})), manifestAge = (manifestPath) => getDurationString(Date.now() - statSync(manifestPath).mtimeMs), firstBuildDir = (candidates) => candidates.map((candidate) => {
|
|
8756
9156
|
const dir = readStringField(candidate.source, "buildDirectory");
|
|
8757
|
-
return dir === undefined ? undefined :
|
|
9157
|
+
return dir === undefined ? undefined : join25(candidate.baseDir, dir);
|
|
8758
9158
|
}).find((dir) => dir !== undefined), resolveSizesDir = (args, candidates) => parseFlagValue(args, "--outdir") ?? firstBuildDir(candidates) ?? DEFAULT_BUILD_DIR, formatSize = (bytes) => {
|
|
8759
9159
|
if (bytes === null || bytes === 0)
|
|
8760
9160
|
return "-";
|
|
@@ -8852,7 +9252,7 @@ ${colors.dim}${frameworkCount} ${frameworkCount === 1 ? "framework" : "framework
|
|
|
8852
9252
|
return;
|
|
8853
9253
|
}
|
|
8854
9254
|
const sizesDir = resolveSizesDir(args, candidates);
|
|
8855
|
-
const manifestPath =
|
|
9255
|
+
const manifestPath = join25(sizesDir, "manifest.json");
|
|
8856
9256
|
if (!existsSync16(manifestPath)) {
|
|
8857
9257
|
printDim(`No build at ${relativeOrSelf(manifestPath)}. Run \`absolute build\` first, or pass \`--outdir <dir>\`.`);
|
|
8858
9258
|
return;
|
|
@@ -8976,22 +9376,22 @@ var init_discoverInstances = __esm(() => {
|
|
|
8976
9376
|
// src/cli/instanceStatus.ts
|
|
8977
9377
|
import { createConnection as createConnection2 } from "net";
|
|
8978
9378
|
var {$: $4 } = globalThis.Bun;
|
|
8979
|
-
var displayHost = (
|
|
8980
|
-
const { promise, resolve:
|
|
8981
|
-
const socket = createConnection2({ host: displayHost(
|
|
9379
|
+
var displayHost = (host2) => host2 === "0.0.0.0" || host2 === "::" ? "localhost" : host2, probePort = (host2, port) => {
|
|
9380
|
+
const { promise, resolve: resolve24 } = Promise.withResolvers();
|
|
9381
|
+
const socket = createConnection2({ host: displayHost(host2), port });
|
|
8982
9382
|
const timeout = setTimeout(() => {
|
|
8983
9383
|
socket.destroy();
|
|
8984
|
-
|
|
9384
|
+
resolve24(false);
|
|
8985
9385
|
}, INSTANCE_PROBE_TIMEOUT_MS);
|
|
8986
9386
|
socket.once("connect", () => {
|
|
8987
9387
|
clearTimeout(timeout);
|
|
8988
9388
|
socket.end();
|
|
8989
|
-
|
|
9389
|
+
resolve24(true);
|
|
8990
9390
|
});
|
|
8991
9391
|
socket.once("error", () => {
|
|
8992
9392
|
clearTimeout(timeout);
|
|
8993
9393
|
socket.destroy();
|
|
8994
|
-
|
|
9394
|
+
resolve24(false);
|
|
8995
9395
|
});
|
|
8996
9396
|
return promise;
|
|
8997
9397
|
}, probeStatus = async (record) => {
|
|
@@ -9703,9 +10103,9 @@ var exports_heapDiff = {};
|
|
|
9703
10103
|
__export(exports_heapDiff, {
|
|
9704
10104
|
runHeapDiff: () => runHeapDiff
|
|
9705
10105
|
});
|
|
9706
|
-
import { existsSync as existsSync17, readFileSync as
|
|
10106
|
+
import { existsSync as existsSync17, readFileSync as readFileSync19 } from "fs";
|
|
9707
10107
|
var TOP = 15, STRING_TYPES, aggregate = (path) => {
|
|
9708
|
-
const data = JSON.parse(
|
|
10108
|
+
const data = JSON.parse(readFileSync19(path, "utf-8"));
|
|
9709
10109
|
const { nodes, strings } = data;
|
|
9710
10110
|
const { node_fields: fields, node_types: nodeTypes } = data.snapshot.meta;
|
|
9711
10111
|
const [typeNames] = nodeTypes;
|
|
@@ -9857,14 +10257,14 @@ import ts5 from "typescript";
|
|
|
9857
10257
|
import {
|
|
9858
10258
|
existsSync as existsSync18,
|
|
9859
10259
|
mkdirSync as mkdirSync9,
|
|
9860
|
-
readFileSync as
|
|
10260
|
+
readFileSync as readFileSync20,
|
|
9861
10261
|
statSync as statSync2,
|
|
9862
10262
|
writeFileSync as writeFileSync8
|
|
9863
10263
|
} from "fs";
|
|
9864
|
-
import { resolve as
|
|
10264
|
+
import { resolve as resolve24 } from "path";
|
|
9865
10265
|
var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFrameworkRepo = (cwd) => {
|
|
9866
10266
|
try {
|
|
9867
|
-
const pkg = JSON.parse(
|
|
10267
|
+
const pkg = JSON.parse(readFileSync20(resolve24(cwd, "package.json"), "utf-8"));
|
|
9868
10268
|
return pkg?.name === "@absolutejs/absolute";
|
|
9869
10269
|
} catch {
|
|
9870
10270
|
return false;
|
|
@@ -9885,14 +10285,14 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
9885
10285
|
};
|
|
9886
10286
|
}, SCHEMA_VERSION = 1, packageVersion = (cwd, specifier) => {
|
|
9887
10287
|
const candidates = specifier === "@absolutejs/absolute" ? [
|
|
9888
|
-
|
|
9889
|
-
|
|
10288
|
+
resolve24(cwd, "node_modules", "@absolutejs", "absolute", "package.json"),
|
|
10289
|
+
resolve24(cwd, "package.json")
|
|
9890
10290
|
] : [
|
|
9891
|
-
|
|
10291
|
+
resolve24(cwd, "node_modules", ...specifier.split("/"), "package.json")
|
|
9892
10292
|
];
|
|
9893
10293
|
for (const candidate of candidates) {
|
|
9894
10294
|
try {
|
|
9895
|
-
const { version: version2 } = JSON.parse(
|
|
10295
|
+
const { version: version2 } = JSON.parse(readFileSync20(candidate, "utf-8"));
|
|
9896
10296
|
if (typeof version2 === "string")
|
|
9897
10297
|
return version2;
|
|
9898
10298
|
} catch {}
|
|
@@ -9903,16 +10303,16 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
9903
10303
|
if (local) {
|
|
9904
10304
|
const file = typeName === "PackageJson" ? "packageJson.ts" : "build.ts";
|
|
9905
10305
|
try {
|
|
9906
|
-
signature += `:${statSync2(
|
|
10306
|
+
signature += `:${statSync2(resolve24(cwd, "types", file)).mtimeMs}`;
|
|
9907
10307
|
} catch {}
|
|
9908
10308
|
}
|
|
9909
10309
|
return signature;
|
|
9910
10310
|
}, cacheSlug = (specifier) => specifier.replace("@", "").split("/").join("-"), cacheFile = (cwd, typeName, specifier) => {
|
|
9911
10311
|
const name = specifier === "@absolutejs/absolute" ? typeName : `${typeName}.${cacheSlug(specifier)}`;
|
|
9912
|
-
return
|
|
10312
|
+
return resolve24(cwd, ".absolutejs", "config-schema", `${name}.json`);
|
|
9913
10313
|
}, readDiskCache = (cwd, typeName, signature, specifier) => {
|
|
9914
10314
|
try {
|
|
9915
|
-
const cached = JSON.parse(
|
|
10315
|
+
const cached = JSON.parse(readFileSync20(cacheFile(cwd, typeName, specifier), "utf-8"));
|
|
9916
10316
|
if (isRecord9(cached) && cached.signature === signature && Array.isArray(cached.fields)) {
|
|
9917
10317
|
return cached.fields;
|
|
9918
10318
|
}
|
|
@@ -9920,7 +10320,7 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
9920
10320
|
return null;
|
|
9921
10321
|
}, writeDiskCache = (cwd, typeName, signature, fields, specifier) => {
|
|
9922
10322
|
try {
|
|
9923
|
-
mkdirSync9(
|
|
10323
|
+
mkdirSync9(resolve24(cwd, ".absolutejs", "config-schema"), {
|
|
9924
10324
|
recursive: true
|
|
9925
10325
|
});
|
|
9926
10326
|
writeFileSync8(cacheFile(cwd, typeName, specifier), JSON.stringify({ fields, signature }));
|
|
@@ -10007,19 +10407,19 @@ var VIRTUAL_NAME = "__absolute_type_introspect__.ts", MAX_DEPTH = 6, isFramework
|
|
|
10007
10407
|
}
|
|
10008
10408
|
return opaque();
|
|
10009
10409
|
}, introspectFrom = (cwd, specifier, typeName, options, exclude) => {
|
|
10010
|
-
const virtualPath =
|
|
10410
|
+
const virtualPath = resolve24(cwd, VIRTUAL_NAME);
|
|
10011
10411
|
const source = `import type { ${typeName} } from '${specifier}';
|
|
10012
10412
|
declare const value: ${typeName};
|
|
10013
10413
|
export { value };
|
|
10014
10414
|
`;
|
|
10015
|
-
const
|
|
10016
|
-
const getSourceFile =
|
|
10017
|
-
|
|
10018
|
-
const fileExists =
|
|
10019
|
-
|
|
10020
|
-
const readFile11 =
|
|
10021
|
-
|
|
10022
|
-
const program = ts5.createProgram([virtualPath], options,
|
|
10415
|
+
const host2 = ts5.createCompilerHost(options, true);
|
|
10416
|
+
const getSourceFile = host2.getSourceFile.bind(host2);
|
|
10417
|
+
host2.getSourceFile = (fileName, languageVersion, onError, shouldCreate) => fileName === virtualPath ? ts5.createSourceFile(fileName, source, languageVersion, true) : getSourceFile(fileName, languageVersion, onError, shouldCreate);
|
|
10418
|
+
const fileExists = host2.fileExists.bind(host2);
|
|
10419
|
+
host2.fileExists = (fileName) => fileName === virtualPath ? true : fileExists(fileName);
|
|
10420
|
+
const readFile11 = host2.readFile.bind(host2);
|
|
10421
|
+
host2.readFile = (fileName) => fileName === virtualPath ? source : readFile11(fileName);
|
|
10422
|
+
const program = ts5.createProgram([virtualPath], options, host2);
|
|
10023
10423
|
const checker = program.getTypeChecker();
|
|
10024
10424
|
const sourceFile = program.getSourceFile(virtualPath);
|
|
10025
10425
|
if (!sourceFile)
|
|
@@ -10050,7 +10450,7 @@ export { value };
|
|
|
10050
10450
|
const cached = cache.get(cacheKey);
|
|
10051
10451
|
if (cached)
|
|
10052
10452
|
return cached;
|
|
10053
|
-
const local = specifier === "@absolutejs/absolute" && isFrameworkRepo(cwd) && existsSync18(
|
|
10453
|
+
const local = specifier === "@absolutejs/absolute" && isFrameworkRepo(cwd) && existsSync18(resolve24(cwd, "types/index.ts"));
|
|
10054
10454
|
const signature = cacheSignature(cwd, typeName, local, specifier);
|
|
10055
10455
|
const fromDisk = readDiskCache(cwd, typeName, signature, specifier);
|
|
10056
10456
|
if (fromDisk) {
|
|
@@ -10078,15 +10478,15 @@ var init_fromType = __esm(() => {
|
|
|
10078
10478
|
|
|
10079
10479
|
// src/cli/config/absolute/resolveAbsoluteConfig.ts
|
|
10080
10480
|
import ts6 from "typescript";
|
|
10081
|
-
import { existsSync as existsSync19, readFileSync as
|
|
10082
|
-
import { resolve as
|
|
10481
|
+
import { existsSync as existsSync19, readFileSync as readFileSync21 } from "fs";
|
|
10482
|
+
import { resolve as resolve25 } from "path";
|
|
10083
10483
|
var CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath = (cwd, override) => {
|
|
10084
10484
|
if (override) {
|
|
10085
|
-
const resolved =
|
|
10485
|
+
const resolved = resolve25(cwd, override);
|
|
10086
10486
|
return existsSync19(resolved) ? resolved : null;
|
|
10087
10487
|
}
|
|
10088
10488
|
for (const name of CONFIG_CANDIDATES2) {
|
|
10089
|
-
const candidate =
|
|
10489
|
+
const candidate = resolve25(cwd, name);
|
|
10090
10490
|
if (existsSync19(candidate))
|
|
10091
10491
|
return candidate;
|
|
10092
10492
|
}
|
|
@@ -10108,7 +10508,7 @@ var CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath = (cwd, override) => {
|
|
|
10108
10508
|
}
|
|
10109
10509
|
return null;
|
|
10110
10510
|
}, parseConfigObject = (configPath2) => {
|
|
10111
|
-
const text =
|
|
10511
|
+
const text = readFileSync21(configPath2, "utf-8");
|
|
10112
10512
|
return { object: findConfigObject(parseSource(configPath2, text)), text };
|
|
10113
10513
|
}, evalLiteral = (node) => {
|
|
10114
10514
|
if (ts6.isStringLiteralLike(node)) {
|
|
@@ -10140,7 +10540,7 @@ var CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath = (cwd, override) => {
|
|
|
10140
10540
|
return { opaque: false, value: items };
|
|
10141
10541
|
}
|
|
10142
10542
|
if (ts6.isObjectLiteralExpression(node)) {
|
|
10143
|
-
const
|
|
10543
|
+
const object2 = {};
|
|
10144
10544
|
for (const property of node.properties) {
|
|
10145
10545
|
if (!ts6.isPropertyAssignment(property) || !(ts6.isIdentifier(property.name) || ts6.isStringLiteral(property.name))) {
|
|
10146
10546
|
return { opaque: true, value: undefined };
|
|
@@ -10148,18 +10548,18 @@ var CONFIG_CANDIDATES2, RUNTIME_FIELDS, findConfigPath = (cwd, override) => {
|
|
|
10148
10548
|
const result = evalLiteral(property.initializer);
|
|
10149
10549
|
if (result.opaque)
|
|
10150
10550
|
return { opaque: true, value: undefined };
|
|
10151
|
-
|
|
10551
|
+
object2[property.name.text] = result.value;
|
|
10152
10552
|
}
|
|
10153
|
-
return { opaque: false, value:
|
|
10553
|
+
return { opaque: false, value: object2 };
|
|
10154
10554
|
}
|
|
10155
10555
|
return { opaque: true, value: undefined };
|
|
10156
10556
|
}, readCurrent = (configPath2) => {
|
|
10157
10557
|
const current = {};
|
|
10158
10558
|
const opaqueKeys = [];
|
|
10159
|
-
const { object } = parseConfigObject(configPath2);
|
|
10160
|
-
if (!
|
|
10559
|
+
const { object: object2 } = parseConfigObject(configPath2);
|
|
10560
|
+
if (!object2)
|
|
10161
10561
|
return { current, opaqueKeys };
|
|
10162
|
-
for (const property of
|
|
10562
|
+
for (const property of object2.properties) {
|
|
10163
10563
|
if (!ts6.isPropertyAssignment(property) || !(ts6.isIdentifier(property.name) || ts6.isStringLiteral(property.name))) {
|
|
10164
10564
|
continue;
|
|
10165
10565
|
}
|
|
@@ -10319,8 +10719,8 @@ var init_frameworks = __esm(() => {
|
|
|
10319
10719
|
});
|
|
10320
10720
|
|
|
10321
10721
|
// src/cli/generate/context.ts
|
|
10322
|
-
import { dirname as
|
|
10323
|
-
var asString = (value) => typeof value === "string" ? value : undefined, isRecord10 = (value) => typeof value === "object" && value !== null, resolveDir = (cwd, value) => isAbsolute5(value) ? value :
|
|
10722
|
+
import { dirname as dirname16, isAbsolute as isAbsolute5, join as join26, relative as relative14, resolve as resolve26 } from "path";
|
|
10723
|
+
var asString = (value) => typeof value === "string" ? value : undefined, isRecord10 = (value) => typeof value === "object" && value !== null, resolveDir = (cwd, value) => isAbsolute5(value) ? value : resolve26(cwd, value), resolveStylesDir = (cwd, config) => {
|
|
10324
10724
|
const styles = config.stylesConfig;
|
|
10325
10725
|
if (typeof styles === "string")
|
|
10326
10726
|
return resolveDir(cwd, styles);
|
|
@@ -10329,10 +10729,10 @@ var asString = (value) => typeof value === "string" ? value : undefined, isRecor
|
|
|
10329
10729
|
if (indexes)
|
|
10330
10730
|
return resolveDir(cwd, indexes);
|
|
10331
10731
|
}
|
|
10332
|
-
return
|
|
10732
|
+
return resolve26(cwd, "src/frontend/styles/indexes");
|
|
10333
10733
|
}, configuredFrameworks = (project) => FRAMEWORK_KEYS2.filter((key) => project.frameworkDirs[key] !== undefined), frontendRootFor = (project, framework) => {
|
|
10334
10734
|
const dir = project.frameworkDirs[framework];
|
|
10335
|
-
return dir ?
|
|
10735
|
+
return dir ? dirname16(dir) : resolve26(project.cwd, "src/frontend");
|
|
10336
10736
|
}, resolveProject = async (cwd, configOverride) => {
|
|
10337
10737
|
const loaded = await loadConfig(configOverride);
|
|
10338
10738
|
const config = isRecord10(loaded) ? loaded : {};
|
|
@@ -10382,7 +10782,7 @@ var asString = (value) => typeof value === "string" ? value : undefined, isRecor
|
|
|
10382
10782
|
message: `Multiple frameworks configured (${configured.join(", ")}). Pass --framework <name>.`,
|
|
10383
10783
|
ok: false
|
|
10384
10784
|
};
|
|
10385
|
-
}, sharedDirFor = (project, framework) =>
|
|
10785
|
+
}, sharedDirFor = (project, framework) => join26(frontendRootFor(project, framework), "shared"), toModuleSpecifier = (fromDir, toFileNoExt) => {
|
|
10386
10786
|
const rel = relative14(fromDir, toFileNoExt).split("\\").join("/");
|
|
10387
10787
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
10388
10788
|
};
|
|
@@ -10411,8 +10811,8 @@ var emptyOutcome = () => ({
|
|
|
10411
10811
|
|
|
10412
10812
|
// src/cli/generate/routeWiring.ts
|
|
10413
10813
|
import ts7 from "typescript";
|
|
10414
|
-
import { existsSync as existsSync20, readFileSync as
|
|
10415
|
-
import { dirname as
|
|
10814
|
+
import { existsSync as existsSync20, readFileSync as readFileSync22, readdirSync as readdirSync4, writeFileSync as writeFileSync9 } from "fs";
|
|
10815
|
+
import { dirname as dirname17, join as join27 } from "path";
|
|
10416
10816
|
var DEFAULT_SEPARATOR = `
|
|
10417
10817
|
`, BOUNDARY_USE, applyEdits = (text, edits) => {
|
|
10418
10818
|
const ordered = [...edits].sort((first, second) => second.start - first.start);
|
|
@@ -10562,7 +10962,7 @@ ${newLines.join(`
|
|
|
10562
10962
|
}, hasChain = (path) => {
|
|
10563
10963
|
if (!existsSync20(path))
|
|
10564
10964
|
return false;
|
|
10565
|
-
const sourceFile = parse2(path,
|
|
10965
|
+
const sourceFile = parse2(path, readFileSync22(path, "utf-8"));
|
|
10566
10966
|
const found = findElysiaNew(sourceFile);
|
|
10567
10967
|
return found !== null;
|
|
10568
10968
|
}, firstChainFile = (pluginsDir) => {
|
|
@@ -10571,14 +10971,14 @@ ${newLines.join(`
|
|
|
10571
10971
|
for (const name of readdirSync4(pluginsDir)) {
|
|
10572
10972
|
if (!name.endsWith(".ts"))
|
|
10573
10973
|
continue;
|
|
10574
|
-
const candidate =
|
|
10974
|
+
const candidate = join27(pluginsDir, name);
|
|
10575
10975
|
if (hasChain(candidate))
|
|
10576
10976
|
return candidate;
|
|
10577
10977
|
}
|
|
10578
10978
|
return null;
|
|
10579
10979
|
}, findRoutingFile = (serverEntry) => {
|
|
10580
|
-
const pluginsDir =
|
|
10581
|
-
const preferred =
|
|
10980
|
+
const pluginsDir = join27(dirname17(serverEntry), "plugins");
|
|
10981
|
+
const preferred = join27(pluginsDir, "pagesPlugin.ts");
|
|
10582
10982
|
if (hasChain(preferred))
|
|
10583
10983
|
return preferred;
|
|
10584
10984
|
const scanned = firstChainFile(pluginsDir);
|
|
@@ -10588,7 +10988,7 @@ ${newLines.join(`
|
|
|
10588
10988
|
return serverEntry;
|
|
10589
10989
|
return null;
|
|
10590
10990
|
}, buildRouteContext = (input, routingFile) => {
|
|
10591
|
-
const specifier = `${toModuleSpecifier(
|
|
10991
|
+
const specifier = `${toModuleSpecifier(dirname17(routingFile), stripExtension(input.pageFileAbs))}${input.def.pageImportExtension ?? ""}`;
|
|
10592
10992
|
return {
|
|
10593
10993
|
cssAssetKey: input.cssAssetKey,
|
|
10594
10994
|
indexKey: input.indexKey,
|
|
@@ -10611,7 +11011,7 @@ ${newLines.join(`
|
|
|
10611
11011
|
};
|
|
10612
11012
|
if (!hasChain(serverEntry))
|
|
10613
11013
|
return fallback;
|
|
10614
|
-
const text =
|
|
11014
|
+
const text = readFileSync22(serverEntry, "utf-8");
|
|
10615
11015
|
const sourceFile = parse2(serverEntry, text);
|
|
10616
11016
|
const newExpr = findElysiaNew(sourceFile);
|
|
10617
11017
|
if (!newExpr)
|
|
@@ -10640,7 +11040,7 @@ ${newLines.join(`
|
|
|
10640
11040
|
${routeExpr}`
|
|
10641
11041
|
};
|
|
10642
11042
|
}
|
|
10643
|
-
const text =
|
|
11043
|
+
const text = readFileSync22(routingFile, "utf-8");
|
|
10644
11044
|
const sourceFile = parse2(routingFile, text);
|
|
10645
11045
|
const newExpr = findElysiaNew(sourceFile);
|
|
10646
11046
|
if (!newExpr) {
|
|
@@ -10670,7 +11070,7 @@ var init_routeWiring = __esm(() => {
|
|
|
10670
11070
|
|
|
10671
11071
|
// src/cli/generate/generateApi.ts
|
|
10672
11072
|
import { existsSync as existsSync21, mkdirSync as mkdirSync10, writeFileSync as writeFileSync10 } from "fs";
|
|
10673
|
-
import { dirname as
|
|
11073
|
+
import { dirname as dirname18, join as join28 } from "path";
|
|
10674
11074
|
var apiPluginTemplate = (pluginName, base) => `import { Elysia } from 'elysia';
|
|
10675
11075
|
|
|
10676
11076
|
export const ${pluginName} = new Elysia()
|
|
@@ -10682,8 +11082,8 @@ export const ${pluginName} = new Elysia()
|
|
|
10682
11082
|
const pluginName = `${camel}Plugin`;
|
|
10683
11083
|
const base = `/api/${kebab}`;
|
|
10684
11084
|
const outcome = { ...emptyOutcome(), route: base };
|
|
10685
|
-
const pluginsDir =
|
|
10686
|
-
const fileAbs =
|
|
11085
|
+
const pluginsDir = join28(dirname18(project.serverEntry), "plugins");
|
|
11086
|
+
const fileAbs = join28(pluginsDir, `${pluginName}.ts`);
|
|
10687
11087
|
if (existsSync21(fileAbs)) {
|
|
10688
11088
|
outcome.notes.push(`${pluginName} already exists at ${fileAbs} \u2014 skipped.`);
|
|
10689
11089
|
return outcome;
|
|
@@ -10691,7 +11091,7 @@ export const ${pluginName} = new Elysia()
|
|
|
10691
11091
|
mkdirSync10(pluginsDir, { recursive: true });
|
|
10692
11092
|
writeFileSync10(fileAbs, apiPluginTemplate(pluginName, base), "utf-8");
|
|
10693
11093
|
outcome.created.push(fileAbs);
|
|
10694
|
-
const specifier = toModuleSpecifier(
|
|
11094
|
+
const specifier = toModuleSpecifier(dirname18(project.serverEntry), fileAbs.replace(/\.ts$/, ""));
|
|
10695
11095
|
const wired = wirePluginUse(project.serverEntry, pluginName, specifier);
|
|
10696
11096
|
if (wired.kind === "edited")
|
|
10697
11097
|
outcome.updated.push(wired.routingFile);
|
|
@@ -10758,7 +11158,7 @@ var init_componentTemplates = __esm(() => {
|
|
|
10758
11158
|
|
|
10759
11159
|
// src/cli/generate/generateComponent.ts
|
|
10760
11160
|
import { existsSync as existsSync22, mkdirSync as mkdirSync11, writeFileSync as writeFileSync11 } from "fs";
|
|
10761
|
-
import { dirname as
|
|
11161
|
+
import { dirname as dirname19, join as join29 } from "path";
|
|
10762
11162
|
var generateComponent = (project, framework, rawName) => {
|
|
10763
11163
|
const def = frameworks6[framework];
|
|
10764
11164
|
const pascal = toPascalCase(rawName);
|
|
@@ -10769,12 +11169,12 @@ var generateComponent = (project, framework, rawName) => {
|
|
|
10769
11169
|
outcome.manual = { reason: "framework directory missing", snippet: "" };
|
|
10770
11170
|
return outcome;
|
|
10771
11171
|
}
|
|
10772
|
-
const fileAbs =
|
|
11172
|
+
const fileAbs = join29(frameworkDir, "components", def.componentFile({ kebab, pascal }));
|
|
10773
11173
|
if (existsSync22(fileAbs)) {
|
|
10774
11174
|
outcome.notes.push(`${pascal} already exists at ${fileAbs} \u2014 skipped.`);
|
|
10775
11175
|
return outcome;
|
|
10776
11176
|
}
|
|
10777
|
-
mkdirSync11(
|
|
11177
|
+
mkdirSync11(dirname19(fileAbs), { recursive: true });
|
|
10778
11178
|
writeFileSync11(fileAbs, componentTemplates[framework]({
|
|
10779
11179
|
kebab,
|
|
10780
11180
|
pascal,
|
|
@@ -10791,7 +11191,7 @@ var init_generateComponent = __esm(() => {
|
|
|
10791
11191
|
// src/cli/generate/cssStrategy.ts
|
|
10792
11192
|
import ts8 from "typescript";
|
|
10793
11193
|
import { existsSync as existsSync23 } from "fs";
|
|
10794
|
-
import { join as
|
|
11194
|
+
import { join as join30 } from "path";
|
|
10795
11195
|
var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
10796
11196
|
margin: 0 auto;
|
|
10797
11197
|
max-width: 64rem;
|
|
@@ -10830,7 +11230,7 @@ var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
|
10830
11230
|
return null;
|
|
10831
11231
|
}, fileForKey = (stylesDir, assetKey2) => {
|
|
10832
11232
|
const base = assetKey2.endsWith(CSS_SUFFIX) ? assetKey2.slice(0, -CSS_SUFFIX.length) : assetKey2;
|
|
10833
|
-
return
|
|
11233
|
+
return join30(stylesDir, `${toKebabCase(base)}.css`);
|
|
10834
11234
|
}, planCss = (routingText, stylesDir, pascal, kebab) => {
|
|
10835
11235
|
const sharedKey = detectSharedKey(routingText);
|
|
10836
11236
|
if (sharedKey) {
|
|
@@ -10843,7 +11243,7 @@ var CSS_SUFFIX = "CSS", SHARED_MIN_USES = 2, DEFAULT_CSS = `main {
|
|
|
10843
11243
|
shared: true
|
|
10844
11244
|
};
|
|
10845
11245
|
}
|
|
10846
|
-
const cssFileAbs =
|
|
11246
|
+
const cssFileAbs = join30(stylesDir, `${kebab}.css`);
|
|
10847
11247
|
return {
|
|
10848
11248
|
assetKey: `${pascal}${CSS_SUFFIX}`,
|
|
10849
11249
|
contents: DEFAULT_CSS,
|
|
@@ -10856,8 +11256,8 @@ var init_cssStrategy = () => {};
|
|
|
10856
11256
|
|
|
10857
11257
|
// src/cli/generate/navData.ts
|
|
10858
11258
|
import ts9 from "typescript";
|
|
10859
|
-
import { existsSync as existsSync24, mkdirSync as mkdirSync12, readFileSync as
|
|
10860
|
-
import { dirname as
|
|
11259
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync12, readFileSync as readFileSync23, writeFileSync as writeFileSync12 } from "fs";
|
|
11260
|
+
import { dirname as dirname20 } from "path";
|
|
10861
11261
|
var NAV_DATA_TEMPLATE = `type NavItem = {
|
|
10862
11262
|
href: string;
|
|
10863
11263
|
label: string;
|
|
@@ -10877,8 +11277,8 @@ export const navData: NavItem[] = [];
|
|
|
10877
11277
|
};
|
|
10878
11278
|
visit(sourceFile);
|
|
10879
11279
|
return found;
|
|
10880
|
-
}, readStringProperty = (
|
|
10881
|
-
const property =
|
|
11280
|
+
}, readStringProperty = (object2, name) => {
|
|
11281
|
+
const property = object2.properties.find((candidate) => ts9.isPropertyAssignment(candidate) && ts9.isIdentifier(candidate.name) && candidate.name.text === name);
|
|
10882
11282
|
if (!property || !ts9.isStringLiteralLike(property.initializer)) {
|
|
10883
11283
|
return null;
|
|
10884
11284
|
}
|
|
@@ -10897,7 +11297,7 @@ export const navData: NavItem[] = [];
|
|
|
10897
11297
|
}, readNavItems = (navDataPath) => {
|
|
10898
11298
|
if (!existsSync24(navDataPath))
|
|
10899
11299
|
return [];
|
|
10900
|
-
const text =
|
|
11300
|
+
const text = readFileSync23(navDataPath, "utf-8");
|
|
10901
11301
|
const sourceFile = ts9.createSourceFile(navDataPath, text, ts9.ScriptTarget.Latest, true);
|
|
10902
11302
|
const array = findNavArray(sourceFile);
|
|
10903
11303
|
return array ? parseNavItems(array) : [];
|
|
@@ -10934,14 +11334,14 @@ ${indent}${entry}`;
|
|
|
10934
11334
|
}, upsertNavItem = (navDataPath, item) => {
|
|
10935
11335
|
const created = !existsSync24(navDataPath);
|
|
10936
11336
|
if (created) {
|
|
10937
|
-
mkdirSync12(
|
|
11337
|
+
mkdirSync12(dirname20(navDataPath), { recursive: true });
|
|
10938
11338
|
writeFileSync12(navDataPath, NAV_DATA_TEMPLATE, "utf-8");
|
|
10939
11339
|
}
|
|
10940
11340
|
const existing = readNavItems(navDataPath);
|
|
10941
11341
|
if (existing.some((candidate) => candidate.href === item.href)) {
|
|
10942
11342
|
return { changed: created, created, items: existing };
|
|
10943
11343
|
}
|
|
10944
|
-
const text =
|
|
11344
|
+
const text = readFileSync23(navDataPath, "utf-8");
|
|
10945
11345
|
const sourceFile = ts9.createSourceFile(navDataPath, text, ts9.ScriptTarget.Latest, true);
|
|
10946
11346
|
const array = findNavArray(sourceFile);
|
|
10947
11347
|
if (!array)
|
|
@@ -11100,19 +11500,19 @@ var init_pageTemplates = __esm(() => {
|
|
|
11100
11500
|
import {
|
|
11101
11501
|
existsSync as existsSync25,
|
|
11102
11502
|
mkdirSync as mkdirSync13,
|
|
11103
|
-
readFileSync as
|
|
11503
|
+
readFileSync as readFileSync24,
|
|
11104
11504
|
readdirSync as readdirSync5,
|
|
11105
11505
|
writeFileSync as writeFileSync13
|
|
11106
11506
|
} from "fs";
|
|
11107
|
-
import { dirname as
|
|
11507
|
+
import { dirname as dirname21, join as join31, relative as relative15 } from "path";
|
|
11108
11508
|
var writeNew = (path, contents) => {
|
|
11109
|
-
mkdirSync13(
|
|
11509
|
+
mkdirSync13(dirname21(path), { recursive: true });
|
|
11110
11510
|
writeFileSync13(path, contents, "utf-8");
|
|
11111
11511
|
}, toHref = (fromDir, toFile) => {
|
|
11112
11512
|
const rel = relative15(fromDir, toFile).split("\\").join("/");
|
|
11113
11513
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
11114
|
-
}, staticPageFiles = (project) => ["html", "htmx"].map((key) => project.frameworkDirs[key]).map((dir) => dir ?
|
|
11115
|
-
const html =
|
|
11514
|
+
}, staticPageFiles = (project) => ["html", "htmx"].map((key) => project.frameworkDirs[key]).map((dir) => dir ? join31(dir, "pages") : null).filter((pagesDir) => pagesDir !== null && existsSync25(pagesDir)).flatMap((pagesDir) => readdirSync5(pagesDir).filter((name) => name.endsWith(".html")).map((name) => join31(pagesDir, name))), resyncPage = (file, items) => {
|
|
11515
|
+
const html = readFileSync24(file, "utf-8");
|
|
11116
11516
|
const synced = syncStaticNav(html, items);
|
|
11117
11517
|
if (synced === null || synced === html)
|
|
11118
11518
|
return false;
|
|
@@ -11139,19 +11539,19 @@ var writeNew = (path, contents) => {
|
|
|
11139
11539
|
outcome.manual = { reason: "framework directory missing", snippet: "" };
|
|
11140
11540
|
return outcome;
|
|
11141
11541
|
}
|
|
11142
|
-
const pageFileAbs =
|
|
11542
|
+
const pageFileAbs = join31(frameworkDir, "pages", def.pageFile({ kebab, pascal }));
|
|
11143
11543
|
if (existsSync25(pageFileAbs)) {
|
|
11144
11544
|
outcome.notes.push(`${pascal} already exists at ${pageFileAbs} \u2014 skipped.`);
|
|
11145
11545
|
return outcome;
|
|
11146
11546
|
}
|
|
11147
11547
|
const routingFile = findRoutingFile(project.serverEntry);
|
|
11148
|
-
const routingText = routingFile ?
|
|
11548
|
+
const routingText = routingFile ? readFileSync24(routingFile, "utf-8") : "";
|
|
11149
11549
|
const css = planCss(routingText, project.stylesDir, pascal, kebab);
|
|
11150
|
-
const navDataPath =
|
|
11550
|
+
const navDataPath = join31(sharedDirFor(project, framework), "navData.ts");
|
|
11151
11551
|
const nav = upsertNavItem(navDataPath, { href: route, label: title });
|
|
11152
|
-
const navImportPath = toModuleSpecifier(
|
|
11552
|
+
const navImportPath = toModuleSpecifier(dirname21(pageFileAbs), navDataPath.replace(/\.ts$/, ""));
|
|
11153
11553
|
writeNew(pageFileAbs, pageTemplates[framework]({
|
|
11154
|
-
cssHref: toHref(
|
|
11554
|
+
cssHref: toHref(dirname21(pageFileAbs), css.cssFileAbs),
|
|
11155
11555
|
kebab,
|
|
11156
11556
|
navImportPath,
|
|
11157
11557
|
navItems: nav.items,
|
|
@@ -11334,25 +11734,25 @@ var init_serialize = () => {};
|
|
|
11334
11734
|
|
|
11335
11735
|
// src/cli/config/absolute/editAbsoluteConfig.ts
|
|
11336
11736
|
import ts10 from "typescript";
|
|
11337
|
-
import { readFileSync as
|
|
11737
|
+
import { readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "fs";
|
|
11338
11738
|
var lineStartOffset = (text, position) => {
|
|
11339
11739
|
let index = position;
|
|
11340
11740
|
while (index > 0 && text[index - 1] !== `
|
|
11341
11741
|
`)
|
|
11342
11742
|
index -= 1;
|
|
11343
11743
|
return index;
|
|
11344
|
-
}, indentBefore2 = (text, position) => text.slice(lineStartOffset(text, position), position), findProperty = (
|
|
11744
|
+
}, indentBefore2 = (text, position) => text.slice(lineStartOffset(text, position), position), findProperty = (object2, name) => object2.properties.find((property) => ts10.isPropertyAssignment(property) && (ts10.isIdentifier(property.name) || ts10.isStringLiteral(property.name)) && property.name.text === name), applyAbsoluteConfigEdit = (configPath2, request) => {
|
|
11345
11745
|
try {
|
|
11346
|
-
const text =
|
|
11746
|
+
const text = readFileSync25(configPath2, "utf-8");
|
|
11347
11747
|
const sourceFile = ts10.createSourceFile(configPath2, text, ts10.ScriptTarget.Latest, true);
|
|
11348
|
-
const
|
|
11349
|
-
if (!
|
|
11748
|
+
const object2 = findConfigObject(sourceFile);
|
|
11749
|
+
if (!object2) {
|
|
11350
11750
|
return {
|
|
11351
11751
|
message: "Could not find defineConfig({ ... }) in the config file.",
|
|
11352
11752
|
ok: false
|
|
11353
11753
|
};
|
|
11354
11754
|
}
|
|
11355
|
-
const existing = findProperty(
|
|
11755
|
+
const existing = findProperty(object2, request.name);
|
|
11356
11756
|
if (request.remove) {
|
|
11357
11757
|
if (!existing)
|
|
11358
11758
|
return { message: `${request.name} is not set`, ok: true };
|
|
@@ -11373,7 +11773,7 @@ var lineStartOffset = (text, position) => {
|
|
|
11373
11773
|
writeFileSync14(configPath2, text.slice(0, start2) + valueText + text.slice(end), "utf-8");
|
|
11374
11774
|
return { message: `Updated ${request.name}`, ok: true };
|
|
11375
11775
|
}
|
|
11376
|
-
const { properties } =
|
|
11776
|
+
const { properties } = object2;
|
|
11377
11777
|
const entry = `${request.name}: ${valueText}`;
|
|
11378
11778
|
if (properties.length > 0) {
|
|
11379
11779
|
const last = properties[properties.length - 1];
|
|
@@ -11392,11 +11792,11 @@ var lineStartOffset = (text, position) => {
|
|
|
11392
11792
|
${indent}${entry}`;
|
|
11393
11793
|
writeFileSync14(configPath2, text.slice(0, insertionIndex) + insertion + text.slice(insertionIndex), "utf-8");
|
|
11394
11794
|
} else {
|
|
11395
|
-
const insertionIndex =
|
|
11396
|
-
const indent = `${indentBefore2(text,
|
|
11795
|
+
const insertionIndex = object2.getStart(sourceFile) + 1;
|
|
11796
|
+
const indent = `${indentBefore2(text, object2.getStart(sourceFile))} `;
|
|
11397
11797
|
const insertion = `
|
|
11398
11798
|
${indent}${entry}
|
|
11399
|
-
${indentBefore2(text,
|
|
11799
|
+
${indentBefore2(text, object2.getStart(sourceFile))}`;
|
|
11400
11800
|
writeFileSync14(configPath2, text.slice(0, insertionIndex) + insertion + text.slice(insertionIndex), "utf-8");
|
|
11401
11801
|
}
|
|
11402
11802
|
return { message: `Updated ${request.name}`, ok: true };
|
|
@@ -11526,14 +11926,14 @@ var init_catalog = __esm(() => {
|
|
|
11526
11926
|
});
|
|
11527
11927
|
|
|
11528
11928
|
// src/cli/integrations/addPlugin.ts
|
|
11529
|
-
import { existsSync as existsSync26, readFileSync as
|
|
11530
|
-
import { join as
|
|
11929
|
+
import { existsSync as existsSync26, readFileSync as readFileSync26 } from "fs";
|
|
11930
|
+
import { join as join32 } from "path";
|
|
11531
11931
|
var isRecord11 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), readPackageJson = (cwd) => {
|
|
11532
|
-
const path =
|
|
11932
|
+
const path = join32(cwd, "package.json");
|
|
11533
11933
|
if (!existsSync26(path))
|
|
11534
11934
|
return null;
|
|
11535
11935
|
try {
|
|
11536
|
-
const parsed = JSON.parse(
|
|
11936
|
+
const parsed = JSON.parse(readFileSync26(path, "utf-8"));
|
|
11537
11937
|
return isRecord11(parsed) ? parsed : null;
|
|
11538
11938
|
} catch {
|
|
11539
11939
|
return null;
|
|
@@ -12025,15 +12425,15 @@ var init_authCatalog = __esm(() => {
|
|
|
12025
12425
|
|
|
12026
12426
|
// src/cli/config/auth/resolveAuthSettings.ts
|
|
12027
12427
|
import ts11 from "typescript";
|
|
12028
|
-
import { existsSync as existsSync27, readFileSync as
|
|
12029
|
-
import { resolve as
|
|
12428
|
+
import { existsSync as existsSync27, readFileSync as readFileSync27 } from "fs";
|
|
12429
|
+
import { resolve as resolve27 } from "path";
|
|
12030
12430
|
var AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, findAuthSettingsPath = (cwd, override) => {
|
|
12031
12431
|
if (override) {
|
|
12032
|
-
const resolved =
|
|
12432
|
+
const resolved = resolve27(cwd, override);
|
|
12033
12433
|
return existsSync27(resolved) ? resolved : null;
|
|
12034
12434
|
}
|
|
12035
12435
|
for (const name of CONFIG_CANDIDATES3) {
|
|
12036
|
-
const candidate =
|
|
12436
|
+
const candidate = resolve27(cwd, name);
|
|
12037
12437
|
if (existsSync27(candidate))
|
|
12038
12438
|
return candidate;
|
|
12039
12439
|
}
|
|
@@ -12055,7 +12455,7 @@ var AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, findAuthSettingsPath
|
|
|
12055
12455
|
}
|
|
12056
12456
|
return null;
|
|
12057
12457
|
}, parseAuthSettingsObject = (configPath2) => {
|
|
12058
|
-
const text =
|
|
12458
|
+
const text = readFileSync27(configPath2, "utf-8");
|
|
12059
12459
|
return {
|
|
12060
12460
|
object: findAuthSettingsObject(parseSource2(configPath2, text)),
|
|
12061
12461
|
text
|
|
@@ -12092,10 +12492,10 @@ var AUTH_PACKAGE = "@absolutejs/auth", CONFIG_CANDIDATES3, findAuthSettingsPath
|
|
|
12092
12492
|
}, readCurrent2 = (configPath2) => {
|
|
12093
12493
|
const current = {};
|
|
12094
12494
|
const opaqueKeys = [];
|
|
12095
|
-
const { object } = parseAuthSettingsObject(configPath2);
|
|
12096
|
-
if (!
|
|
12495
|
+
const { object: object2 } = parseAuthSettingsObject(configPath2);
|
|
12496
|
+
if (!object2)
|
|
12097
12497
|
return { current, opaqueKeys };
|
|
12098
|
-
for (const property of
|
|
12498
|
+
for (const property of object2.properties) {
|
|
12099
12499
|
if (!ts11.isPropertyAssignment(property) || !(ts11.isIdentifier(property.name) || ts11.isStringLiteral(property.name))) {
|
|
12100
12500
|
continue;
|
|
12101
12501
|
}
|
|
@@ -12130,13 +12530,13 @@ var init_resolveAuthSettings = __esm(() => {
|
|
|
12130
12530
|
|
|
12131
12531
|
// src/cli/config/auth/resolveAuthState.ts
|
|
12132
12532
|
import ts12 from "typescript";
|
|
12133
|
-
import { existsSync as existsSync28, readdirSync as readdirSync6, readFileSync as
|
|
12134
|
-
import { join as
|
|
12533
|
+
import { existsSync as existsSync28, readdirSync as readdirSync6, readFileSync as readFileSync28 } from "fs";
|
|
12534
|
+
import { join as join33, relative as relative17, resolve as resolve28 } from "path";
|
|
12135
12535
|
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), readJson = (path) => {
|
|
12136
12536
|
if (!existsSync28(path))
|
|
12137
12537
|
return null;
|
|
12138
12538
|
try {
|
|
12139
|
-
const parsed = JSON.parse(
|
|
12539
|
+
const parsed = JSON.parse(readFileSync28(path, "utf-8"));
|
|
12140
12540
|
return isRecord12(parsed) ? parsed : null;
|
|
12141
12541
|
} catch {
|
|
12142
12542
|
return null;
|
|
@@ -12145,7 +12545,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12145
12545
|
const value = record?.[key];
|
|
12146
12546
|
return typeof value === "string" ? value : null;
|
|
12147
12547
|
}, declaredVersionFor = (cwd) => {
|
|
12148
|
-
const pkg = readJson(
|
|
12548
|
+
const pkg = readJson(join33(cwd, "package.json"));
|
|
12149
12549
|
if (!pkg)
|
|
12150
12550
|
return null;
|
|
12151
12551
|
for (const field of ["dependencies", "devDependencies"]) {
|
|
@@ -12157,14 +12557,14 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12157
12557
|
return version2;
|
|
12158
12558
|
}
|
|
12159
12559
|
return null;
|
|
12160
|
-
}, installedVersionFor = (cwd) => stringField(readJson(
|
|
12560
|
+
}, installedVersionFor = (cwd) => stringField(readJson(join33(cwd, "node_modules", AUTH_PACKAGE2, "package.json")), "version"), SOURCE_FILE, safeReaddir = (dir) => {
|
|
12161
12561
|
try {
|
|
12162
12562
|
return readdirSync6(dir, { withFileTypes: true });
|
|
12163
12563
|
} catch {
|
|
12164
12564
|
return [];
|
|
12165
12565
|
}
|
|
12166
12566
|
}, sortEntry = (dir, entry, found, dirs) => {
|
|
12167
|
-
const full =
|
|
12567
|
+
const full = join33(dir, entry.name);
|
|
12168
12568
|
if (entry.isDirectory()) {
|
|
12169
12569
|
if (SKIP_DIRS.has(entry.name) || entry.name.startsWith("."))
|
|
12170
12570
|
return;
|
|
@@ -12208,11 +12608,11 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12208
12608
|
return null;
|
|
12209
12609
|
}
|
|
12210
12610
|
return property.initializer.properties.length;
|
|
12211
|
-
}, readConfigKeys = (
|
|
12611
|
+
}, readConfigKeys = (object2) => {
|
|
12212
12612
|
const keys = new Set;
|
|
12213
12613
|
let providerCount = null;
|
|
12214
|
-
const usesSpread =
|
|
12215
|
-
for (const property of
|
|
12614
|
+
const usesSpread = object2.properties.some((property) => ts12.isSpreadAssignment(property));
|
|
12615
|
+
for (const property of object2.properties) {
|
|
12216
12616
|
const { name } = property;
|
|
12217
12617
|
if (name === undefined || !ts12.isIdentifier(name))
|
|
12218
12618
|
continue;
|
|
@@ -12229,7 +12629,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12229
12629
|
return { keys: new Set, providerCount: null, usesSpread: true };
|
|
12230
12630
|
}, readFileOrNull = (path) => {
|
|
12231
12631
|
try {
|
|
12232
|
-
return
|
|
12632
|
+
return readFileSync28(path, "utf-8");
|
|
12233
12633
|
} catch {
|
|
12234
12634
|
return null;
|
|
12235
12635
|
}
|
|
@@ -12262,7 +12662,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12262
12662
|
scaffoldable: isScaffoldableFeature(feature.id)
|
|
12263
12663
|
})), resolveAuthState = (cwd) => {
|
|
12264
12664
|
const installedVersion = installedVersionFor(cwd);
|
|
12265
|
-
const root = existsSync28(
|
|
12665
|
+
const root = existsSync28(join33(cwd, "src")) ? join33(cwd, "src") : cwd;
|
|
12266
12666
|
let match = null;
|
|
12267
12667
|
let setupPath = null;
|
|
12268
12668
|
for (const file of candidateFiles(root)) {
|
|
@@ -12270,7 +12670,7 @@ var AUTH_PACKAGE2 = "@absolutejs/auth", REPO_URL = "https://github.com/absolutej
|
|
|
12270
12670
|
if (found === null)
|
|
12271
12671
|
continue;
|
|
12272
12672
|
match = found;
|
|
12273
|
-
setupPath = relative17(cwd,
|
|
12673
|
+
setupPath = relative17(cwd, resolve28(file));
|
|
12274
12674
|
break;
|
|
12275
12675
|
}
|
|
12276
12676
|
const keys = match?.keys ?? new Set;
|
|
@@ -12308,7 +12708,7 @@ var init_resolveAuthState = __esm(() => {
|
|
|
12308
12708
|
|
|
12309
12709
|
// src/cli/config/auth/scaffoldAuthFeature.ts
|
|
12310
12710
|
import { existsSync as existsSync29, writeFileSync as writeFileSync15 } from "fs";
|
|
12311
|
-
import { dirname as
|
|
12711
|
+
import { dirname as dirname22, join as join34, relative as relative18, resolve as resolve29 } from "path";
|
|
12312
12712
|
var renderScaffold = (scaffold) => {
|
|
12313
12713
|
const importNames = [...scaffold.imports, `type ${scaffold.typeName}`];
|
|
12314
12714
|
const importLine = `import { ${importNames.join(", ")} } from '@absolutejs/auth';`;
|
|
@@ -12333,8 +12733,8 @@ ${body}
|
|
|
12333
12733
|
}, targetDir = (cwd) => {
|
|
12334
12734
|
const { setupPath } = resolveAuthState(cwd);
|
|
12335
12735
|
if (setupPath)
|
|
12336
|
-
return
|
|
12337
|
-
const src =
|
|
12736
|
+
return dirname22(resolve29(cwd, setupPath));
|
|
12737
|
+
const src = join34(cwd, "src");
|
|
12338
12738
|
return existsSync29(src) ? src : cwd;
|
|
12339
12739
|
}, spreadFor = (scaffold) => `import { ${scaffold.exportName} } from './${scaffold.exportName}';
|
|
12340
12740
|
// add to your auth() call:
|
|
@@ -12348,7 +12748,7 @@ ${scaffold.configKey}: ${scaffold.exportName}`, failure2 = (message) => ({
|
|
|
12348
12748
|
const scaffold = AUTH_SCAFFOLDS[id];
|
|
12349
12749
|
if (!scaffold)
|
|
12350
12750
|
return failure2(`Unknown auth feature "${id}".`);
|
|
12351
|
-
const filePath =
|
|
12751
|
+
const filePath = join34(targetDir(cwd), `${scaffold.exportName}.ts`);
|
|
12352
12752
|
const relPath = relative18(cwd, filePath);
|
|
12353
12753
|
if (existsSync29(filePath)) {
|
|
12354
12754
|
return {
|
|
@@ -12377,12 +12777,12 @@ var init_scaffoldAuthFeature = __esm(() => {
|
|
|
12377
12777
|
});
|
|
12378
12778
|
|
|
12379
12779
|
// src/cli/htmx/install.ts
|
|
12380
|
-
import { existsSync as existsSync30, mkdirSync as mkdirSync14, readFileSync as
|
|
12381
|
-
import { join as
|
|
12780
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync14, readFileSync as readFileSync29, writeFileSync as writeFileSync16 } from "fs";
|
|
12781
|
+
import { join as join35 } from "path";
|
|
12382
12782
|
var VENDORED_HTMX_VERSION = "2.0.6", vendoredHtmxFile = () => [
|
|
12383
|
-
|
|
12384
|
-
|
|
12385
|
-
|
|
12783
|
+
join35(import.meta.dir, "htmx.min.js"),
|
|
12784
|
+
join35(import.meta.dir, "htmx", "htmx.min.js"),
|
|
12785
|
+
join35(import.meta.dir, "..", "htmx", "htmx.min.js")
|
|
12386
12786
|
].find((path) => existsSync30(path)) ?? null, detectHtmxVersion = (content) => {
|
|
12387
12787
|
const match = content.match(/version:"([0-9.]+)"/);
|
|
12388
12788
|
return match ? match[1] : null;
|
|
@@ -12394,16 +12794,16 @@ var VENDORED_HTMX_VERSION = "2.0.6", vendoredHtmxFile = () => [
|
|
|
12394
12794
|
}
|
|
12395
12795
|
return response.text();
|
|
12396
12796
|
}, installedHtmxVersion = (htmxDir) => {
|
|
12397
|
-
const file =
|
|
12797
|
+
const file = join35(htmxDir, "htmx.min.js");
|
|
12398
12798
|
if (!existsSync30(file))
|
|
12399
12799
|
return null;
|
|
12400
|
-
return detectHtmxVersion(
|
|
12800
|
+
return detectHtmxVersion(readFileSync29(file, "utf-8"));
|
|
12401
12801
|
}, readVendoredHtmx = () => {
|
|
12402
12802
|
const file = vendoredHtmxFile();
|
|
12403
|
-
return file ?
|
|
12803
|
+
return file ? readFileSync29(file, "utf-8") : null;
|
|
12404
12804
|
}, writeHtmx = (htmxDir, content) => {
|
|
12405
12805
|
mkdirSync14(htmxDir, { recursive: true });
|
|
12406
|
-
const file =
|
|
12806
|
+
const file = join35(htmxDir, "htmx.min.js");
|
|
12407
12807
|
writeFileSync16(file, content, "utf-8");
|
|
12408
12808
|
return file;
|
|
12409
12809
|
};
|
|
@@ -12414,7 +12814,7 @@ var exports_add = {};
|
|
|
12414
12814
|
__export(exports_add, {
|
|
12415
12815
|
runAdd: () => runAdd
|
|
12416
12816
|
});
|
|
12417
|
-
import { dirname as
|
|
12817
|
+
import { dirname as dirname23, join as join36, relative as relative19 } from "path";
|
|
12418
12818
|
var write2 = (text) => process.stdout.write(`${text}
|
|
12419
12819
|
`), fail2 = (message) => {
|
|
12420
12820
|
process.stdout.write(`${colors.red}${message}${colors.reset}
|
|
@@ -12429,7 +12829,7 @@ var write2 = (text) => process.stdout.write(`${text}
|
|
|
12429
12829
|
}, frontendRoot = (project, cwd) => {
|
|
12430
12830
|
const [firstKey] = configuredFrameworks(project);
|
|
12431
12831
|
const firstDir = firstKey ? project.frameworkDirs[firstKey] : undefined;
|
|
12432
|
-
return firstDir ?
|
|
12832
|
+
return firstDir ? dirname23(firstDir) : join36(cwd, "src", "frontend");
|
|
12433
12833
|
}, addIntegrationCli = (id, install) => {
|
|
12434
12834
|
const result = addIntegration(process.cwd(), id, { install });
|
|
12435
12835
|
if (!result.ok) {
|
|
@@ -12493,7 +12893,7 @@ var write2 = (text) => process.stdout.write(`${text}
|
|
|
12493
12893
|
write2(`${colors.yellow}!${colors.reset} ${frameworks6[framework].label} is already configured \u2014 nothing to do.`);
|
|
12494
12894
|
return;
|
|
12495
12895
|
}
|
|
12496
|
-
const dirAbs =
|
|
12896
|
+
const dirAbs = join36(frontendRoot(project, cwd), framework);
|
|
12497
12897
|
const dirRel = `./${relative19(cwd, dirAbs).split("\\").join("/")}`;
|
|
12498
12898
|
let depNote = "Skipped dependency install (--no-install).";
|
|
12499
12899
|
if (!noInstall) {
|
|
@@ -12563,8 +12963,8 @@ var exports_analyze = {};
|
|
|
12563
12963
|
__export(exports_analyze, {
|
|
12564
12964
|
runAnalyze: () => runAnalyze
|
|
12565
12965
|
});
|
|
12566
|
-
import { existsSync as existsSync31, readFileSync as
|
|
12567
|
-
import { join as
|
|
12966
|
+
import { existsSync as existsSync31, readFileSync as readFileSync30, statSync as statSync3, writeFileSync as writeFileSync17 } from "fs";
|
|
12967
|
+
import { join as join37, resolve as resolve30 } from "path";
|
|
12568
12968
|
var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_WIDTH = 16, SIZE_WIDTH = 12, CHANGE_WIDTH = 10, CATEGORY_ORDER, categoryOf = (key) => {
|
|
12569
12969
|
if (key.startsWith("Island"))
|
|
12570
12970
|
return "Islands";
|
|
@@ -12584,21 +12984,21 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
12584
12984
|
return 0;
|
|
12585
12985
|
}
|
|
12586
12986
|
}, readSizes = (manifestDir) => {
|
|
12587
|
-
const manifestPath =
|
|
12987
|
+
const manifestPath = join37(manifestDir, "manifest.json");
|
|
12588
12988
|
if (!existsSync31(manifestPath))
|
|
12589
12989
|
return null;
|
|
12590
|
-
const manifest = JSON.parse(
|
|
12990
|
+
const manifest = JSON.parse(readFileSync30(manifestPath, "utf-8"));
|
|
12591
12991
|
const sizes = {};
|
|
12592
12992
|
for (const [key, value] of Object.entries(manifest)) {
|
|
12593
|
-
sizes[key] = fileSize2(
|
|
12993
|
+
sizes[key] = fileSize2(join37(manifestDir, value.replace(/^\//, "")));
|
|
12594
12994
|
}
|
|
12595
12995
|
return sizes;
|
|
12596
12996
|
}, readBaseline = (cwd) => {
|
|
12597
|
-
const path =
|
|
12997
|
+
const path = join37(cwd, BASELINE_FILE);
|
|
12598
12998
|
if (!existsSync31(path))
|
|
12599
12999
|
return null;
|
|
12600
13000
|
try {
|
|
12601
|
-
const parsed = JSON.parse(
|
|
13001
|
+
const parsed = JSON.parse(readFileSync30(path, "utf-8"));
|
|
12602
13002
|
return parsed;
|
|
12603
13003
|
} catch {
|
|
12604
13004
|
return null;
|
|
@@ -12676,14 +13076,14 @@ var BASELINE_FILE = ".absolute-size-baseline.json", TOP_CHANGES = 12, CATEGORY_W
|
|
|
12676
13076
|
const config = await loadConfig(configIndex >= 0 ? args[configIndex + 1] : undefined);
|
|
12677
13077
|
const outdirIndex = args.indexOf("--outdir");
|
|
12678
13078
|
const outdir = outdirIndex >= 0 ? args[outdirIndex + 1] : config.buildDirectory;
|
|
12679
|
-
const sizes = readSizes(
|
|
13079
|
+
const sizes = readSizes(resolve30(cwd, outdir ?? "build"));
|
|
12680
13080
|
if (sizes === null) {
|
|
12681
13081
|
process.stdout.write(`${colors.dim}No build found. Run \`absolute build\` first.${colors.reset}
|
|
12682
13082
|
`);
|
|
12683
13083
|
return;
|
|
12684
13084
|
}
|
|
12685
13085
|
if (args.includes("--save")) {
|
|
12686
|
-
writeFileSync17(
|
|
13086
|
+
writeFileSync17(join37(cwd, BASELINE_FILE), `${JSON.stringify(sizes, null, 2)}
|
|
12687
13087
|
`);
|
|
12688
13088
|
process.stdout.write(`${colors.green}\u2713${colors.reset} Saved size baseline (${Object.keys(sizes).length} entries) to ${BASELINE_FILE}
|
|
12689
13089
|
`);
|
|
@@ -12845,10 +13245,10 @@ var METHOD_COLOR2, HTTP_METHODS, printDim2 = (message) => process.stdout.write(`
|
|
|
12845
13245
|
}, getProp = (value, key) => typeof value === "object" && value !== null ? Reflect.get(value, key) : undefined, propertyNames = (schema) => {
|
|
12846
13246
|
const properties = getProp(schema, "properties");
|
|
12847
13247
|
return typeof properties === "object" && properties !== null ? Object.keys(properties) : [];
|
|
12848
|
-
}, summarize = (
|
|
12849
|
-
const parameters = getProp(
|
|
13248
|
+
}, summarize = (operation2) => {
|
|
13249
|
+
const parameters = getProp(operation2, "parameters");
|
|
12850
13250
|
const names = Array.isArray(parameters) ? parameters.map((param) => getProp(param, "name")).filter((name) => typeof name === "string") : [];
|
|
12851
|
-
const json = getProp(getProp(
|
|
13251
|
+
const json = getProp(getProp(operation2, "requestBody"), "content");
|
|
12852
13252
|
const body = propertyNames(getProp(getProp(json, "application/json"), "schema"));
|
|
12853
13253
|
const parts = [];
|
|
12854
13254
|
if (names.length > 0)
|
|
@@ -12860,10 +13260,10 @@ var METHOD_COLOR2, HTTP_METHODS, printDim2 = (message) => process.stdout.write(`
|
|
|
12860
13260
|
const paths = Reflect.get(spec ?? {}, "paths");
|
|
12861
13261
|
if (typeof paths !== "object" || paths === null)
|
|
12862
13262
|
return [];
|
|
12863
|
-
return Object.entries(paths).filter(([path]) => !isInternal(path)).flatMap(([path, methods]) => Object.entries(methods ?? {}).filter(([method]) => HTTP_METHODS.has(method)).map(([method,
|
|
13263
|
+
return Object.entries(paths).filter(([path]) => !isInternal(path)).flatMap(([path, methods]) => Object.entries(methods ?? {}).filter(([method]) => HTTP_METHODS.has(method)).map(([method, operation2]) => ({
|
|
12864
13264
|
method: method.toUpperCase(),
|
|
12865
13265
|
path,
|
|
12866
|
-
summary: summarize(
|
|
13266
|
+
summary: summarize(operation2)
|
|
12867
13267
|
})));
|
|
12868
13268
|
}, runApi = async (args) => {
|
|
12869
13269
|
const server = await findServer();
|
|
@@ -12929,7 +13329,7 @@ var exports_remove = {};
|
|
|
12929
13329
|
__export(exports_remove, {
|
|
12930
13330
|
runRemove: () => runRemove
|
|
12931
13331
|
});
|
|
12932
|
-
import { existsSync as existsSync32, readFileSync as
|
|
13332
|
+
import { existsSync as existsSync32, readFileSync as readFileSync31 } from "fs";
|
|
12933
13333
|
import { relative as relative20 } from "path";
|
|
12934
13334
|
var write3 = (text) => process.stdout.write(`${text}
|
|
12935
13335
|
`), fail3 = (message) => {
|
|
@@ -12943,7 +13343,7 @@ var write3 = (text) => process.stdout.write(`${text}
|
|
|
12943
13343
|
if (file === null || seen.has(file) || !existsSync32(file))
|
|
12944
13344
|
return false;
|
|
12945
13345
|
seen.add(file);
|
|
12946
|
-
return
|
|
13346
|
+
return readFileSync31(file, "utf-8").includes(handler);
|
|
12947
13347
|
});
|
|
12948
13348
|
}, runRemove = async (args) => {
|
|
12949
13349
|
const [framework] = args.filter((arg) => !arg.startsWith("--"));
|
|
@@ -13070,15 +13470,15 @@ __export(exports_env, {
|
|
|
13070
13470
|
runEnv: () => runEnv,
|
|
13071
13471
|
collectEnvVars: () => collectEnvVars
|
|
13072
13472
|
});
|
|
13073
|
-
import { existsSync as existsSync33, readFileSync as
|
|
13074
|
-
import { join as
|
|
13473
|
+
import { existsSync as existsSync33, readFileSync as readFileSync32 } from "fs";
|
|
13474
|
+
import { join as join38 } from "path";
|
|
13075
13475
|
var {env: env3, Glob: Glob3 } = globalThis.Bun;
|
|
13076
|
-
var EXTENSIONS = "ts,tsx,js,jsx,mjs,cjs,svelte,vue", STATUS_WIDTH2, keysInFile = (text) => [...text.matchAll(/getEnv\(\s*['"]([^'"]+)['"]\s*\)/g)].map((match) => match[1]).filter((key) => key !== undefined), scanPatterns = () => existsSync33(
|
|
13476
|
+
var EXTENSIONS = "ts,tsx,js,jsx,mjs,cjs,svelte,vue", STATUS_WIDTH2, keysInFile = (text) => [...text.matchAll(/getEnv\(\s*['"]([^'"]+)['"]\s*\)/g)].map((match) => match[1]).filter((key) => key !== undefined), scanPatterns = () => existsSync33(join38(process.cwd(), "src")) ? [`src/**/*.{${EXTENSIONS}}`] : [`*.{${EXTENSIONS}}`], scanEnvUsage = async () => {
|
|
13077
13477
|
const scans = scanPatterns().map((pattern) => Array.fromAsync(new Glob3(pattern).scan({ cwd: process.cwd() })));
|
|
13078
13478
|
const files = (await Promise.all(scans)).flat();
|
|
13079
13479
|
const usage = new Map;
|
|
13080
13480
|
files.forEach((file) => {
|
|
13081
|
-
keysInFile(
|
|
13481
|
+
keysInFile(readFileSync32(file, "utf-8")).forEach((key) => {
|
|
13082
13482
|
usage.set(key, [...usage.get(key) ?? [], file]);
|
|
13083
13483
|
});
|
|
13084
13484
|
});
|
|
@@ -13139,8 +13539,8 @@ __export(exports_db, {
|
|
|
13139
13539
|
conflictClause: () => conflictClause,
|
|
13140
13540
|
chunkRows: () => chunkRows
|
|
13141
13541
|
});
|
|
13142
|
-
import { existsSync as existsSync34, mkdirSync as mkdirSync15, readFileSync as
|
|
13143
|
-
import { join as
|
|
13542
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync15, readFileSync as readFileSync33, writeFileSync as writeFileSync18 } from "fs";
|
|
13543
|
+
import { join as join39 } from "path";
|
|
13144
13544
|
var {env: env4, spawn: spawn2, SQL } = globalThis.Bun;
|
|
13145
13545
|
var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA_TYPES, SEED_CANDIDATES, VALUE_FLAGS, paint = (text, color) => `${color}${text}${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) => {
|
|
13146
13546
|
const found = explicit ?? URL_ENV_KEYS.map((key) => env4[key]).find((value) => typeof value === "string" && value !== "");
|
|
@@ -13250,19 +13650,19 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13250
13650
|
tables,
|
|
13251
13651
|
v: BACKUP_FORMAT_VERSION
|
|
13252
13652
|
};
|
|
13253
|
-
const dir = options.out ??
|
|
13653
|
+
const dir = options.out ?? join39(process.cwd(), "backups");
|
|
13254
13654
|
mkdirSync15(dir, { recursive: true });
|
|
13255
13655
|
const json = JSON.stringify(payload, (_, value) => typeof value === "bigint" ? value.toString() : value);
|
|
13256
|
-
const file =
|
|
13656
|
+
const file = join39(dir, `backup-${payload.at.replace(/[:.]/g, "-")}.json`);
|
|
13257
13657
|
writeFileSync18(file, json);
|
|
13258
|
-
writeFileSync18(
|
|
13658
|
+
writeFileSync18(join39(dir, "latest.json"), json);
|
|
13259
13659
|
const total = chosen.reduce((sum, name) => sum + (tables[name]?.length ?? 0), 0);
|
|
13260
13660
|
console.log(paint(`\u2713 backup \u2192 ${file}`, colors.green));
|
|
13261
13661
|
console.log(paint(` ${chosen.length} tables, ${total} rows`, colors.dim));
|
|
13262
13662
|
}, runRestore = async (file, options) => {
|
|
13263
13663
|
if (!existsSync34(file))
|
|
13264
13664
|
throw new Error(`Backup not found: ${file}`);
|
|
13265
|
-
const payload = JSON.parse(
|
|
13665
|
+
const payload = JSON.parse(readFileSync33(file, "utf-8"));
|
|
13266
13666
|
const names = Object.keys(payload.tables).filter((name) => keepTable(name, options));
|
|
13267
13667
|
const sql = new SQL(options.url);
|
|
13268
13668
|
const order = dependencyOrder(names, await foreignLinks(sql));
|
|
@@ -13284,7 +13684,7 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13284
13684
|
const total = order.reduce((sum, name) => sum + (payload.tables[name]?.length ?? 0), 0);
|
|
13285
13685
|
console.log(paint(`\u2713 restored ${order.length} tables, ${total} rows (idempotent upsert by primary key)`, colors.green));
|
|
13286
13686
|
}, runSeed = async (entry) => {
|
|
13287
|
-
const target = entry ?? SEED_CANDIDATES.find((candidate) => existsSync34(
|
|
13687
|
+
const target = entry ?? SEED_CANDIDATES.find((candidate) => existsSync34(join39(process.cwd(), candidate)));
|
|
13288
13688
|
if (target === undefined)
|
|
13289
13689
|
throw new Error(`No seed script found (looked for ${SEED_CANDIDATES.join(", ")}). Pass a path: absolute db seed <file>.`);
|
|
13290
13690
|
console.log(paint(`seeding via ${target}\u2026`, colors.cyan));
|
|
@@ -13319,7 +13719,7 @@ var BACKUP_FORMAT_VERSION = 1, RESTORE_CHUNK_ROWS = 500, URL_ENV_KEYS, JSON_DATA
|
|
|
13319
13719
|
return;
|
|
13320
13720
|
}
|
|
13321
13721
|
if (sub === "restore") {
|
|
13322
|
-
const file = positionalArgs(rest)[0] ??
|
|
13722
|
+
const file = positionalArgs(rest)[0] ?? join39(process.cwd(), "backups", "latest.json");
|
|
13323
13723
|
await runRestore(file, parseOptions(rest));
|
|
13324
13724
|
return;
|
|
13325
13725
|
}
|
|
@@ -13433,16 +13833,16 @@ var init_logs = __esm(() => {
|
|
|
13433
13833
|
// src/cli/typeGraphCoherence.ts
|
|
13434
13834
|
import {
|
|
13435
13835
|
existsSync as existsSync36,
|
|
13436
|
-
readFileSync as
|
|
13836
|
+
readFileSync as readFileSync34,
|
|
13437
13837
|
realpathSync as realpathSync2,
|
|
13438
13838
|
rmSync as rmSync6,
|
|
13439
13839
|
writeFileSync as writeFileSync19
|
|
13440
13840
|
} from "fs";
|
|
13441
13841
|
import { createRequire } from "module";
|
|
13442
|
-
import { dirname as
|
|
13842
|
+
import { dirname as dirname24, join as join40, resolve as resolve31, sep as sep5 } from "path";
|
|
13443
13843
|
var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
13444
13844
|
try {
|
|
13445
|
-
const parsed = JSON.parse(
|
|
13845
|
+
const parsed = JSON.parse(readFileSync34(path, "utf-8"));
|
|
13446
13846
|
return isRecord9(parsed) ? parsed : null;
|
|
13447
13847
|
} catch {
|
|
13448
13848
|
return null;
|
|
@@ -13450,7 +13850,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13450
13850
|
}, dependencyRecord = (manifest, field) => {
|
|
13451
13851
|
const value = Reflect.get(manifest, field);
|
|
13452
13852
|
return isRecord9(value) ? value : {};
|
|
13453
|
-
},
|
|
13853
|
+
}, dependencyNames2 = (manifest) => [
|
|
13454
13854
|
...new Set(DEPENDENCY_FIELDS.flatMap((field) => Object.keys(dependencyRecord(manifest, field))))
|
|
13455
13855
|
], declaresPackage = (manifest, name) => DEPENDENCY_FIELDS.some((field) => Object.hasOwn(dependencyRecord(manifest, field), name)), manifestName = (manifest, fallback) => {
|
|
13456
13856
|
const name = Reflect.get(manifest, "name");
|
|
@@ -13459,13 +13859,13 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13459
13859
|
const version2 = Reflect.get(manifest, "version");
|
|
13460
13860
|
return typeof version2 === "string" ? version2 : "unknown";
|
|
13461
13861
|
}, packageJsonFromEntry = (entry, expectedName) => {
|
|
13462
|
-
let directory =
|
|
13862
|
+
let directory = dirname24(entry);
|
|
13463
13863
|
for (;; ) {
|
|
13464
|
-
const candidate =
|
|
13864
|
+
const candidate = join40(directory, "package.json");
|
|
13465
13865
|
const manifest = readManifest(candidate);
|
|
13466
13866
|
if (manifest && manifestName(manifest, "") === expectedName)
|
|
13467
13867
|
return candidate;
|
|
13468
|
-
const parent =
|
|
13868
|
+
const parent = dirname24(directory);
|
|
13469
13869
|
if (parent === directory)
|
|
13470
13870
|
return null;
|
|
13471
13871
|
directory = parent;
|
|
@@ -13481,27 +13881,27 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13481
13881
|
}
|
|
13482
13882
|
}
|
|
13483
13883
|
}, findInstallRoot = (cwd) => {
|
|
13484
|
-
let directory =
|
|
13884
|
+
let directory = resolve31(cwd);
|
|
13485
13885
|
for (;; ) {
|
|
13486
|
-
if (existsSync36(
|
|
13886
|
+
if (existsSync36(join40(directory, "bun.lock")) || existsSync36(join40(directory, "bun.lockb"))) {
|
|
13487
13887
|
return directory;
|
|
13488
13888
|
}
|
|
13489
|
-
const parent =
|
|
13889
|
+
const parent = dirname24(directory);
|
|
13490
13890
|
if (parent === directory)
|
|
13491
|
-
return
|
|
13891
|
+
return resolve31(cwd);
|
|
13492
13892
|
directory = parent;
|
|
13493
13893
|
}
|
|
13494
13894
|
}, findProjectManifest = (cwd, installRoot) => {
|
|
13495
|
-
let directory =
|
|
13895
|
+
let directory = resolve31(cwd);
|
|
13496
13896
|
for (;; ) {
|
|
13497
|
-
const candidate =
|
|
13897
|
+
const candidate = join40(directory, "package.json");
|
|
13498
13898
|
if (existsSync36(candidate))
|
|
13499
13899
|
return candidate;
|
|
13500
13900
|
if (directory === installRoot)
|
|
13501
|
-
return
|
|
13502
|
-
const parent =
|
|
13901
|
+
return join40(installRoot, "package.json");
|
|
13902
|
+
const parent = dirname24(directory);
|
|
13503
13903
|
if (parent === directory)
|
|
13504
|
-
return
|
|
13904
|
+
return join40(installRoot, "package.json");
|
|
13505
13905
|
directory = parent;
|
|
13506
13906
|
}
|
|
13507
13907
|
}, appendConsumer = (consumers, consumerPaths, path, manifest) => {
|
|
@@ -13539,7 +13939,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13539
13939
|
appendConsumer(consumers, consumerPaths, inspection.consumer.path, inspection.consumer.manifest);
|
|
13540
13940
|
}, inspectTypeGraph = (cwd) => {
|
|
13541
13941
|
const installRoot = findInstallRoot(cwd);
|
|
13542
|
-
const rootManifestPath =
|
|
13942
|
+
const rootManifestPath = join40(installRoot, "package.json");
|
|
13543
13943
|
const rootManifest = readManifest(rootManifestPath) ?? {};
|
|
13544
13944
|
const consumers = [
|
|
13545
13945
|
{ manifest: rootManifest, path: rootManifestPath }
|
|
@@ -13550,7 +13950,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13550
13950
|
const projectConsumers = [...consumers];
|
|
13551
13951
|
projectConsumers.forEach((consumer) => {
|
|
13552
13952
|
const projectRequire = createRequire(consumer.path);
|
|
13553
|
-
|
|
13953
|
+
dependencyNames2(consumer.manifest).forEach((dependency) => {
|
|
13554
13954
|
const path = resolvePackageJson(projectRequire, dependency);
|
|
13555
13955
|
if (!path)
|
|
13556
13956
|
return;
|
|
@@ -13575,7 +13975,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13575
13975
|
const duplicates = duplicateTypeGraphPackages(report);
|
|
13576
13976
|
if (duplicates.length === 0)
|
|
13577
13977
|
return [];
|
|
13578
|
-
const manifestPath =
|
|
13978
|
+
const manifestPath = join40(report.installRoot, "package.json");
|
|
13579
13979
|
const manifest = readManifest(manifestPath);
|
|
13580
13980
|
if (!manifest)
|
|
13581
13981
|
return [];
|
|
@@ -13597,7 +13997,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13597
13997
|
}
|
|
13598
13998
|
return changes;
|
|
13599
13999
|
}, removeDuplicateTypeGraphPackages = (report) => {
|
|
13600
|
-
const manifest = readManifest(
|
|
14000
|
+
const manifest = readManifest(join40(report.installRoot, "package.json")) ?? {};
|
|
13601
14001
|
const rootName = manifestName(manifest, "<workspace>");
|
|
13602
14002
|
const installPrefix = `${realpathSync2(report.installRoot)}${sep5}`;
|
|
13603
14003
|
const nodeModulesSegment = `${sep5}node_modules${sep5}`;
|
|
@@ -13609,7 +14009,7 @@ var DEPENDENCY_FIELDS, TYPE_GRAPH_PACKAGES, readManifest = (path) => {
|
|
|
13609
14009
|
for (const stalePath of stalePaths) {
|
|
13610
14010
|
if (!stalePath.startsWith(installPrefix) || !stalePath.includes(nodeModulesSegment))
|
|
13611
14011
|
continue;
|
|
13612
|
-
rmSync6(
|
|
14012
|
+
rmSync6(dirname24(stalePath), { force: true, recursive: true });
|
|
13613
14013
|
removed.push(stalePath);
|
|
13614
14014
|
}
|
|
13615
14015
|
return removed;
|
|
@@ -13636,10 +14036,10 @@ var exports_doctor = {};
|
|
|
13636
14036
|
__export(exports_doctor, {
|
|
13637
14037
|
runDoctor: () => runDoctor
|
|
13638
14038
|
});
|
|
13639
|
-
import { existsSync as existsSync37, mkdirSync as mkdirSync16, readFileSync as
|
|
14039
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync16, readFileSync as readFileSync35, writeFileSync as writeFileSync20 } from "fs";
|
|
13640
14040
|
import { createRequire as createRequire2 } from "module";
|
|
13641
14041
|
import { arch as arch4, platform as platform5 } from "os";
|
|
13642
|
-
import { join as
|
|
14042
|
+
import { join as join41 } from "path";
|
|
13643
14043
|
var FRAMEWORK_FIELDS2, projectRequire, check = (status2, label, detail) => ({
|
|
13644
14044
|
detail,
|
|
13645
14045
|
label,
|
|
@@ -13674,7 +14074,7 @@ var FRAMEWORK_FIELDS2, projectRequire, check = (status2, label, detail) => ({
|
|
|
13674
14074
|
return [];
|
|
13675
14075
|
const label = `${field.replace("Directory", "")} pages`;
|
|
13676
14076
|
return [
|
|
13677
|
-
existsSync37(
|
|
14077
|
+
existsSync37(join41(process.cwd(), dir)) ? check("ok", label, dir) : check("fail", label, `${dir} (missing)`)
|
|
13678
14078
|
];
|
|
13679
14079
|
}), envCheck = async () => {
|
|
13680
14080
|
const vars = await collectEnvVars();
|
|
@@ -13736,9 +14136,9 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
13736
14136
|
const fixes = [];
|
|
13737
14137
|
for (const field of FRAMEWORK_FIELDS2) {
|
|
13738
14138
|
const dir = readString2(config, field);
|
|
13739
|
-
if (dir === undefined || existsSync37(
|
|
14139
|
+
if (dir === undefined || existsSync37(join41(cwd, dir)))
|
|
13740
14140
|
continue;
|
|
13741
|
-
mkdirSync16(
|
|
14141
|
+
mkdirSync16(join41(cwd, dir, "pages"), { recursive: true });
|
|
13742
14142
|
fixes.push(`created ${dir}/pages`);
|
|
13743
14143
|
}
|
|
13744
14144
|
return fixes;
|
|
@@ -13746,8 +14146,8 @@ ${colors.dim}${checks.length} checks \xB7 ${colors.reset}${summary}${colors.dim}
|
|
|
13746
14146
|
const missing = (await collectEnvVars()).filter((entry) => !entry.set);
|
|
13747
14147
|
if (missing.length === 0)
|
|
13748
14148
|
return null;
|
|
13749
|
-
const envExample =
|
|
13750
|
-
const existing = existsSync37(envExample) ?
|
|
14149
|
+
const envExample = join41(cwd, ".env.example");
|
|
14150
|
+
const existing = existsSync37(envExample) ? readFileSync35(envExample, "utf-8") : "";
|
|
13751
14151
|
const existingKeys = new Set(existing.split(`
|
|
13752
14152
|
`).map((line) => line.split("=")[0]?.trim()));
|
|
13753
14153
|
const toAdd = missing.filter((entry) => !existingKeys.has(entry.key));
|
|
@@ -13817,7 +14217,7 @@ var init_doctor = __esm(() => {
|
|
|
13817
14217
|
"htmlDirectory",
|
|
13818
14218
|
"htmxDirectory"
|
|
13819
14219
|
];
|
|
13820
|
-
projectRequire = createRequire2(
|
|
14220
|
+
projectRequire = createRequire2(join41(process.cwd(), "package.json"));
|
|
13821
14221
|
STATUS_MARK = {
|
|
13822
14222
|
fail: `${colors.red}\u2717${colors.reset}`,
|
|
13823
14223
|
ok: `${colors.green}\u2713${colors.reset}`,
|
|
@@ -14141,8 +14541,8 @@ var islandFrameworks, islandHydrationModes, isIslandFramework = (value) => islan
|
|
|
14141
14541
|
const componentMatch = attributeString.match(/\bcomponent\s*=\s*["']([^"']+)["']/);
|
|
14142
14542
|
const hydrateMatch = attributeString.match(/\bhydrate\s*=\s*["']([^"']+)["']/);
|
|
14143
14543
|
const framework = frameworkMatch?.[1];
|
|
14144
|
-
const
|
|
14145
|
-
if (!framework || !
|
|
14544
|
+
const component2 = componentMatch?.[1];
|
|
14545
|
+
if (!framework || !component2) {
|
|
14146
14546
|
return null;
|
|
14147
14547
|
}
|
|
14148
14548
|
if (!isIslandFramework(framework)) {
|
|
@@ -14150,7 +14550,7 @@ var islandFrameworks, islandHydrationModes, isIslandFramework = (value) => islan
|
|
|
14150
14550
|
}
|
|
14151
14551
|
const hydrateCandidate = hydrateMatch?.[1];
|
|
14152
14552
|
return {
|
|
14153
|
-
component,
|
|
14553
|
+
component: component2,
|
|
14154
14554
|
framework,
|
|
14155
14555
|
hydrate: hydrateCandidate && isIslandHydrate(hydrateCandidate) ? hydrateCandidate : undefined
|
|
14156
14556
|
};
|
|
@@ -14159,12 +14559,12 @@ var islandFrameworks, islandHydrationModes, isIslandFramework = (value) => islan
|
|
|
14159
14559
|
return;
|
|
14160
14560
|
usageMap.set(normalizeUsage(usage2), usage2);
|
|
14161
14561
|
}, addRenderCallUsage = (usageMap, match) => {
|
|
14162
|
-
const [, framework,
|
|
14163
|
-
if (!framework || !
|
|
14562
|
+
const [, framework, component2, hydrate] = match;
|
|
14563
|
+
if (!framework || !component2 || !isIslandFramework(framework)) {
|
|
14164
14564
|
return;
|
|
14165
14565
|
}
|
|
14166
14566
|
addUsage(usageMap, {
|
|
14167
|
-
component,
|
|
14567
|
+
component: component2,
|
|
14168
14568
|
framework,
|
|
14169
14569
|
hydrate: hydrate && isIslandHydrate(hydrate) ? hydrate : undefined
|
|
14170
14570
|
});
|
|
@@ -14206,8 +14606,8 @@ var init_sourceMetadata = __esm(() => {
|
|
|
14206
14606
|
});
|
|
14207
14607
|
|
|
14208
14608
|
// src/islands/pageMetadata.ts
|
|
14209
|
-
import { readFileSync as
|
|
14210
|
-
import { dirname as
|
|
14609
|
+
import { readFileSync as readFileSync36 } from "fs";
|
|
14610
|
+
import { dirname as dirname25, resolve as resolve32 } from "path";
|
|
14211
14611
|
var pagePatterns, getPageDirs = (config) => [
|
|
14212
14612
|
{ dir: config.angularDirectory, framework: "angular" },
|
|
14213
14613
|
{ dir: config.emberDirectory, framework: "ember" },
|
|
@@ -14227,8 +14627,8 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
14227
14627
|
const source = definition.buildReference?.source;
|
|
14228
14628
|
if (!source)
|
|
14229
14629
|
continue;
|
|
14230
|
-
const resolvedSource = source.startsWith("file://") ? new URL(source).pathname :
|
|
14231
|
-
lookup.set(`${definition.framework}:${definition.component}`,
|
|
14630
|
+
const resolvedSource = source.startsWith("file://") ? new URL(source).pathname : resolve32(dirname25(buildInfo.resolvedRegistryPath), source);
|
|
14631
|
+
lookup.set(`${definition.framework}:${definition.component}`, resolve32(resolvedSource));
|
|
14232
14632
|
}
|
|
14233
14633
|
return lookup;
|
|
14234
14634
|
}, resolveIslandUsages = (islands, islandSourceLookup) => islands.map((usage2) => {
|
|
@@ -14241,13 +14641,13 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
14241
14641
|
const pattern = pagePatterns[entry.framework];
|
|
14242
14642
|
if (!pattern)
|
|
14243
14643
|
return;
|
|
14244
|
-
const files = await scanEntryPoints(
|
|
14644
|
+
const files = await scanEntryPoints(resolve32(entry.dir), pattern);
|
|
14245
14645
|
for (const filePath of files) {
|
|
14246
|
-
const source =
|
|
14646
|
+
const source = readFileSync36(filePath, "utf-8");
|
|
14247
14647
|
const islands = extractIslandUsagesFromSource(source);
|
|
14248
|
-
pageMetadata.set(
|
|
14648
|
+
pageMetadata.set(resolve32(filePath), {
|
|
14249
14649
|
islands: resolveIslandUsages(islands, islandSourceLookup),
|
|
14250
|
-
pagePath:
|
|
14650
|
+
pagePath: resolve32(filePath)
|
|
14251
14651
|
});
|
|
14252
14652
|
}
|
|
14253
14653
|
}, loadPageIslandMetadata = async (config) => {
|
|
@@ -14276,14 +14676,14 @@ var exports_islands = {};
|
|
|
14276
14676
|
__export(exports_islands, {
|
|
14277
14677
|
runIslands: () => runIslands
|
|
14278
14678
|
});
|
|
14279
|
-
import { existsSync as existsSync39, readFileSync as
|
|
14280
|
-
import { join as
|
|
14679
|
+
import { existsSync as existsSync39, readFileSync as readFileSync37, statSync as statSync5 } from "fs";
|
|
14680
|
+
import { join as join42, relative as relative21, resolve as resolve33 } from "path";
|
|
14281
14681
|
var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.write(`${colors.dim}${message}${colors.reset}
|
|
14282
14682
|
`), hostFrameworkOf = (pagePath, cwd, config) => {
|
|
14283
|
-
const resolved =
|
|
14683
|
+
const resolved = resolve33(cwd, pagePath);
|
|
14284
14684
|
for (const [framework, key] of Object.entries(FRAMEWORK_DIR_KEY)) {
|
|
14285
14685
|
const dir = config[key];
|
|
14286
|
-
if (typeof dir === "string" && resolved.startsWith(
|
|
14686
|
+
if (typeof dir === "string" && resolved.startsWith(resolve33(cwd, dir))) {
|
|
14287
14687
|
return framework;
|
|
14288
14688
|
}
|
|
14289
14689
|
}
|
|
@@ -14295,20 +14695,20 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14295
14695
|
return 0;
|
|
14296
14696
|
}
|
|
14297
14697
|
}, readManifestSizes2 = (manifestDir) => {
|
|
14298
|
-
const manifestPath =
|
|
14698
|
+
const manifestPath = join42(manifestDir, "manifest.json");
|
|
14299
14699
|
if (!existsSync39(manifestPath))
|
|
14300
14700
|
return null;
|
|
14301
|
-
const manifest = JSON.parse(
|
|
14701
|
+
const manifest = JSON.parse(readFileSync37(manifestPath, "utf-8"));
|
|
14302
14702
|
const sizes = new Map;
|
|
14303
14703
|
for (const [key, value] of Object.entries(manifest)) {
|
|
14304
|
-
sizes.set(key, fileSize3(
|
|
14704
|
+
sizes.set(key, fileSize3(join42(manifestDir, value.replace(/^\//, ""))));
|
|
14305
14705
|
}
|
|
14306
14706
|
return sizes;
|
|
14307
14707
|
}, collectIslands = async (cwd, config, sizes) => {
|
|
14308
14708
|
const registryPath = config.islands?.registry;
|
|
14309
14709
|
if (typeof registryPath !== "string")
|
|
14310
14710
|
return null;
|
|
14311
|
-
const buildInfo = await loadIslandRegistryBuildInfo(
|
|
14711
|
+
const buildInfo = await loadIslandRegistryBuildInfo(resolve33(cwd, registryPath));
|
|
14312
14712
|
const pageMetadata = await loadPageIslandMetadata(config);
|
|
14313
14713
|
const usages = [...pageMetadata.values()].flatMap((meta) => meta.islands.map((island) => ({ ...island, page: meta.pagePath })));
|
|
14314
14714
|
return buildInfo.definitions.map((definition) => {
|
|
@@ -14318,7 +14718,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14318
14718
|
crossFramework: hostFramework !== null && hostFramework !== definition.framework,
|
|
14319
14719
|
hostFramework,
|
|
14320
14720
|
hydrate: usage2.hydrate ?? "load",
|
|
14321
|
-
page: relative21(cwd,
|
|
14721
|
+
page: relative21(cwd, resolve33(cwd, usage2.page))
|
|
14322
14722
|
};
|
|
14323
14723
|
});
|
|
14324
14724
|
const key = getIslandManifestKey(definition.framework, definition.component);
|
|
@@ -14387,7 +14787,7 @@ var FRAMEWORK_DIR_KEY, FRAMEWORK_COLOR, printDim6 = (message) => process.stdout.
|
|
|
14387
14787
|
}
|
|
14388
14788
|
const outdirIndex = args.indexOf("--outdir");
|
|
14389
14789
|
const outdir = outdirIndex >= 0 ? args[outdirIndex + 1] : config.buildDirectory;
|
|
14390
|
-
const sizes = args.includes("--sizes") ? readManifestSizes2(
|
|
14790
|
+
const sizes = args.includes("--sizes") ? readManifestSizes2(resolve33(cwd, outdir ?? "build")) : null;
|
|
14391
14791
|
const islands = await collectIslands(cwd, config, sizes);
|
|
14392
14792
|
if (islands === null) {
|
|
14393
14793
|
printDim6('No island registry configured. Set `islands: { registry: "..." }` in absolute.config.ts.');
|
|
@@ -14437,12 +14837,12 @@ var init_islands2 = __esm(() => {
|
|
|
14437
14837
|
|
|
14438
14838
|
// src/build/externalAssetPlugin.ts
|
|
14439
14839
|
import { copyFileSync as copyFileSync2, existsSync as existsSync40, mkdirSync as mkdirSync17, statSync as statSync6 } from "fs";
|
|
14440
|
-
import { basename as basename11, dirname as
|
|
14840
|
+
import { basename as basename11, dirname as dirname26, join as join43, resolve as resolve34 } from "path";
|
|
14441
14841
|
var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
14442
14842
|
name: "absolute-external-asset",
|
|
14443
14843
|
setup(bld) {
|
|
14444
14844
|
const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
|
|
14445
|
-
const skipRoots = userSourceRoots.map((root) =>
|
|
14845
|
+
const skipRoots = userSourceRoots.map((root) => resolve34(root));
|
|
14446
14846
|
const isUserSource = (path) => skipRoots.some((root) => path.startsWith(`${root}/`));
|
|
14447
14847
|
bld.onLoad({ filter: /\.[mc]?[jt]sx?$/ }, async (args) => {
|
|
14448
14848
|
if (isUserSource(args.path))
|
|
@@ -14452,20 +14852,20 @@ var createExternalAssetPlugin = (outDir, userSourceRoots = []) => ({
|
|
|
14452
14852
|
return;
|
|
14453
14853
|
urlPattern.lastIndex = 0;
|
|
14454
14854
|
let match;
|
|
14455
|
-
const sourceDir =
|
|
14855
|
+
const sourceDir = dirname26(args.path);
|
|
14456
14856
|
while ((match = urlPattern.exec(source)) !== null) {
|
|
14457
14857
|
const relPath = match[1];
|
|
14458
14858
|
if (!relPath)
|
|
14459
14859
|
continue;
|
|
14460
|
-
const assetPath =
|
|
14860
|
+
const assetPath = resolve34(sourceDir, relPath);
|
|
14461
14861
|
if (!existsSync40(assetPath))
|
|
14462
14862
|
continue;
|
|
14463
14863
|
if (!statSync6(assetPath).isFile())
|
|
14464
14864
|
continue;
|
|
14465
|
-
const targetPath =
|
|
14865
|
+
const targetPath = join43(outDir, basename11(assetPath));
|
|
14466
14866
|
if (existsSync40(targetPath))
|
|
14467
14867
|
continue;
|
|
14468
|
-
mkdirSync17(
|
|
14868
|
+
mkdirSync17(dirname26(targetPath), { recursive: true });
|
|
14469
14869
|
copyFileSync2(assetPath, targetPath);
|
|
14470
14870
|
}
|
|
14471
14871
|
return;
|
|
@@ -14486,7 +14886,7 @@ import {
|
|
|
14486
14886
|
existsSync as existsSync41,
|
|
14487
14887
|
mkdirSync as mkdirSync18,
|
|
14488
14888
|
readdirSync as readdirSync7,
|
|
14489
|
-
readFileSync as
|
|
14889
|
+
readFileSync as readFileSync38,
|
|
14490
14890
|
rmSync as rmSync7,
|
|
14491
14891
|
statSync as statSync7,
|
|
14492
14892
|
unlinkSync as unlinkSync4,
|
|
@@ -14495,11 +14895,11 @@ import {
|
|
|
14495
14895
|
import { createRequire as createRequire3 } from "module";
|
|
14496
14896
|
import {
|
|
14497
14897
|
basename as basename12,
|
|
14498
|
-
dirname as
|
|
14898
|
+
dirname as dirname27,
|
|
14499
14899
|
isAbsolute as isAbsolute6,
|
|
14500
|
-
join as
|
|
14900
|
+
join as join44,
|
|
14501
14901
|
relative as relative22,
|
|
14502
|
-
resolve as
|
|
14902
|
+
resolve as resolve35
|
|
14503
14903
|
} from "path";
|
|
14504
14904
|
var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[cli]\x1B[0m ${color}${message}\x1B[0m`, compileBanner = (version2) => {
|
|
14505
14905
|
const resolvedVersion = version2 || "unknown";
|
|
@@ -14513,7 +14913,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14513
14913
|
const entry = pending.pop();
|
|
14514
14914
|
if (!entry)
|
|
14515
14915
|
continue;
|
|
14516
|
-
const fullPath =
|
|
14916
|
+
const fullPath = join44(entry.parentPath, entry.name);
|
|
14517
14917
|
if (entry.isDirectory())
|
|
14518
14918
|
pending = pending.concat(readdirSync7(fullPath, { withFileTypes: true }));
|
|
14519
14919
|
else
|
|
@@ -14521,7 +14921,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14521
14921
|
}
|
|
14522
14922
|
return result;
|
|
14523
14923
|
}, INLINE_SOURCE_MAP_RE, rebaseInlineSourceMap = (filePath) => {
|
|
14524
|
-
const source =
|
|
14924
|
+
const source = readFileSync38(filePath, "utf-8");
|
|
14525
14925
|
const match = source.match(INLINE_SOURCE_MAP_RE);
|
|
14526
14926
|
const encoded = match?.[1];
|
|
14527
14927
|
if (!encoded)
|
|
@@ -14532,7 +14932,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14532
14932
|
if (!Array.isArray(map.sources))
|
|
14533
14933
|
return;
|
|
14534
14934
|
const sourceRoot = typeof map.sourceRoot === "string" ? map.sourceRoot : "";
|
|
14535
|
-
const bundleDirectory =
|
|
14935
|
+
const bundleDirectory = dirname27(filePath);
|
|
14536
14936
|
map.sources = map.sources.map((entry) => {
|
|
14537
14937
|
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(entry))
|
|
14538
14938
|
return entry;
|
|
@@ -14541,7 +14941,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14541
14941
|
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(sourceRoot)) {
|
|
14542
14942
|
return new URL(entry, sourceRoot).href;
|
|
14543
14943
|
}
|
|
14544
|
-
return
|
|
14944
|
+
return resolve35(bundleDirectory, sourceRoot, entry);
|
|
14545
14945
|
});
|
|
14546
14946
|
delete map.sourceRoot;
|
|
14547
14947
|
const rebased = Buffer.from(JSON.stringify(map)).toString("base64");
|
|
@@ -14559,7 +14959,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14559
14959
|
const entry = pending.pop();
|
|
14560
14960
|
if (!entry)
|
|
14561
14961
|
continue;
|
|
14562
|
-
const fullPath =
|
|
14962
|
+
const fullPath = join44(entry.parentPath, entry.name);
|
|
14563
14963
|
if (entry.isDirectory()) {
|
|
14564
14964
|
if (SERVER_RUNTIME_SCAN_SKIP_DIRS.has(entry.name))
|
|
14565
14965
|
continue;
|
|
@@ -14571,22 +14971,22 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14571
14971
|
return result;
|
|
14572
14972
|
}, copyServerRuntimeAssetReferences = (outdir) => {
|
|
14573
14973
|
const copied = new Set;
|
|
14574
|
-
const normalizedOutdir =
|
|
14974
|
+
const normalizedOutdir = resolve35(outdir);
|
|
14575
14975
|
const copyReference = (filePath, relPath) => {
|
|
14576
|
-
const assetSource =
|
|
14976
|
+
const assetSource = resolve35(dirname27(filePath), relPath);
|
|
14577
14977
|
if (!existsSync41(assetSource) || !statSync7(assetSource).isFile())
|
|
14578
14978
|
return;
|
|
14579
|
-
const assetTarget =
|
|
14979
|
+
const assetTarget = resolve35(normalizedOutdir, relPath.replace(/^\.\//, ""));
|
|
14580
14980
|
if (assetTarget !== normalizedOutdir && !assetTarget.startsWith(`${normalizedOutdir}/`))
|
|
14581
14981
|
return;
|
|
14582
14982
|
if (copied.has(assetTarget))
|
|
14583
14983
|
return;
|
|
14584
14984
|
copied.add(assetTarget);
|
|
14585
|
-
mkdirSync18(
|
|
14985
|
+
mkdirSync18(dirname27(assetTarget), { recursive: true });
|
|
14586
14986
|
cpSync(assetSource, assetTarget, { force: true });
|
|
14587
14987
|
};
|
|
14588
14988
|
for (const filePath of collectProjectSourceFiles(process.cwd())) {
|
|
14589
|
-
const source =
|
|
14989
|
+
const source = readFileSync38(filePath, "utf-8");
|
|
14590
14990
|
SERVER_RUNTIME_ASSET_RE.lastIndex = 0;
|
|
14591
14991
|
let match;
|
|
14592
14992
|
while ((match = SERVER_RUNTIME_ASSET_RE.exec(source)) !== null) {
|
|
@@ -14615,7 +15015,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14615
15015
|
}
|
|
14616
15016
|
}, readPackageVersion4 = (candidate) => {
|
|
14617
15017
|
try {
|
|
14618
|
-
const pkg = JSON.parse(
|
|
15018
|
+
const pkg = JSON.parse(readFileSync38(candidate, "utf-8"));
|
|
14619
15019
|
if (pkg.name !== "@absolutejs/absolute")
|
|
14620
15020
|
return null;
|
|
14621
15021
|
const ver = pkg.version;
|
|
@@ -14650,18 +15050,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14650
15050
|
return resolveBuildModule3(remaining);
|
|
14651
15051
|
}, resolveJsxDevRuntimeCompatPath2 = () => {
|
|
14652
15052
|
const candidates = [
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
15053
|
+
resolve35(import.meta.dir, "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
15054
|
+
resolve35(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
15055
|
+
resolve35(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.ts"),
|
|
15056
|
+
resolve35(import.meta.dir, "..", "..", "..", "dist", "react", "jsxDevRuntimeCompat.js"),
|
|
15057
|
+
resolve35(import.meta.dir, "..", "..", "..", "react", "jsxDevRuntimeCompat.js"),
|
|
15058
|
+
resolve35(import.meta.dir, "..", "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
|
|
14659
15059
|
];
|
|
14660
15060
|
for (const candidate of candidates) {
|
|
14661
15061
|
if (existsSync41(candidate))
|
|
14662
15062
|
return candidate;
|
|
14663
15063
|
}
|
|
14664
|
-
return
|
|
15064
|
+
return resolve35(import.meta.dir, "..", "..", "react", "jsxDevRuntimeCompat.js");
|
|
14665
15065
|
}, jsxDevRuntimeCompatPath2, shouldEmbedCompiledAsset = (relativePath, skip = new Set) => {
|
|
14666
15066
|
if (skip.has(relativePath))
|
|
14667
15067
|
return false;
|
|
@@ -14686,7 +15086,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14686
15086
|
return true;
|
|
14687
15087
|
}), requireForCompile, resolveNativeAssetForRuntime = (specifier) => {
|
|
14688
15088
|
if (specifier.startsWith("."))
|
|
14689
|
-
return
|
|
15089
|
+
return resolve35(process.cwd(), specifier);
|
|
14690
15090
|
if (specifier.startsWith("/"))
|
|
14691
15091
|
return specifier;
|
|
14692
15092
|
return requireForCompile.resolve(specifier, { paths: [process.cwd()] });
|
|
@@ -14698,11 +15098,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14698
15098
|
return nativeAssetEnv;
|
|
14699
15099
|
}, tryReadNodePackageJson = (packageDir) => {
|
|
14700
15100
|
try {
|
|
14701
|
-
return JSON.parse(
|
|
15101
|
+
return JSON.parse(readFileSync38(join44(packageDir, "package.json"), "utf-8"));
|
|
14702
15102
|
} catch {
|
|
14703
15103
|
return null;
|
|
14704
15104
|
}
|
|
14705
|
-
}, resolveProjectPackageDir = (specifier) =>
|
|
15105
|
+
}, resolveProjectPackageDir = (specifier) => resolve35(process.cwd(), "node_modules", ...specifier.split("/")), copyPackageToBuild = (specifier, outdir, seen) => {
|
|
14706
15106
|
if (seen.has(specifier))
|
|
14707
15107
|
return;
|
|
14708
15108
|
const srcDir = resolveProjectPackageDir(specifier);
|
|
@@ -14710,7 +15110,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14710
15110
|
if (!pkg)
|
|
14711
15111
|
return;
|
|
14712
15112
|
seen.add(specifier);
|
|
14713
|
-
const destDir =
|
|
15113
|
+
const destDir = join44(outdir, "node_modules", ...specifier.split("/"));
|
|
14714
15114
|
rmSync7(destDir, { force: true, recursive: true });
|
|
14715
15115
|
cpSync(srcDir, destDir, {
|
|
14716
15116
|
force: true,
|
|
@@ -14732,7 +15132,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14732
15132
|
}, copyAngularRuntimePackages = (buildConfig, outdir) => {
|
|
14733
15133
|
if (!buildConfig.angularDirectory)
|
|
14734
15134
|
return;
|
|
14735
|
-
const angularScopeDir =
|
|
15135
|
+
const angularScopeDir = resolve35(process.cwd(), "node_modules", "@angular");
|
|
14736
15136
|
const angularPackages = existsSync41(angularScopeDir) ? readdirSync7(angularScopeDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).filter((entry) => entry.name !== "compiler-cli").map((entry) => `@angular/${entry.name}`) : [];
|
|
14737
15137
|
const roots = new Set([...angularPackages, "rxjs", "tslib", "typescript"]);
|
|
14738
15138
|
const seen = new Set;
|
|
@@ -14751,7 +15151,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14751
15151
|
copyAngularRuntimePackages(buildConfig, outdir);
|
|
14752
15152
|
copyChunkReferencedPackages(outdir, seen);
|
|
14753
15153
|
}, collectRuntimePackageSpecifiers = (distDir) => {
|
|
14754
|
-
const nodeModulesDir =
|
|
15154
|
+
const nodeModulesDir = join44(distDir, "node_modules");
|
|
14755
15155
|
if (!existsSync41(nodeModulesDir))
|
|
14756
15156
|
return [];
|
|
14757
15157
|
const specifiers = [];
|
|
@@ -14759,7 +15159,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14759
15159
|
if (!entry.isDirectory())
|
|
14760
15160
|
continue;
|
|
14761
15161
|
if (entry.name.startsWith("@")) {
|
|
14762
|
-
const scopeDir =
|
|
15162
|
+
const scopeDir = join44(nodeModulesDir, entry.name);
|
|
14763
15163
|
for (const scopedEntry of readdirSync7(scopeDir, {
|
|
14764
15164
|
withFileTypes: true
|
|
14765
15165
|
})) {
|
|
@@ -14773,7 +15173,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14773
15173
|
}
|
|
14774
15174
|
return specifiers.sort((firstSpecifier, secondSpecifier) => secondSpecifier.length - firstSpecifier.length);
|
|
14775
15175
|
}, ensureRelativeModuleSpecifier = (fromFile, toFile) => {
|
|
14776
|
-
const rel = relative22(
|
|
15176
|
+
const rel = relative22(dirname27(fromFile), toFile).replace(/\\/g, "/");
|
|
14777
15177
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
14778
15178
|
}, pickExportEntry = (value) => {
|
|
14779
15179
|
if (typeof value === "string")
|
|
@@ -14790,18 +15190,18 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14790
15190
|
const packageSpecifier = packageSpecifiers.find((root) => specifier === root || specifier.startsWith(`${root}/`));
|
|
14791
15191
|
if (!packageSpecifier)
|
|
14792
15192
|
return null;
|
|
14793
|
-
const packageDir =
|
|
15193
|
+
const packageDir = join44(distDir, "node_modules", ...packageSpecifier.split("/"));
|
|
14794
15194
|
const subpath = specifier.slice(packageSpecifier.length);
|
|
14795
|
-
const subPackageDir = subpath ?
|
|
14796
|
-
const resolvedPackageDir = subPackageDir && existsSync41(
|
|
14797
|
-
const packageJsonPath =
|
|
15195
|
+
const subPackageDir = subpath ? join44(packageDir, ...subpath.slice(1).split("/")) : null;
|
|
15196
|
+
const resolvedPackageDir = subPackageDir && existsSync41(join44(subPackageDir, "package.json")) ? subPackageDir : packageDir;
|
|
15197
|
+
const packageJsonPath = join44(resolvedPackageDir, "package.json");
|
|
14798
15198
|
if (!existsSync41(packageJsonPath))
|
|
14799
15199
|
return null;
|
|
14800
|
-
const pkg = JSON.parse(
|
|
15200
|
+
const pkg = JSON.parse(readFileSync38(packageJsonPath, "utf-8"));
|
|
14801
15201
|
const exportKey = resolvedPackageDir !== subPackageDir && subpath ? `.${subpath}` : ".";
|
|
14802
15202
|
const rootExport = pkg.exports?.[exportKey];
|
|
14803
15203
|
const entry = pickExportEntry(rootExport) ?? (resolvedPackageDir === subPackageDir || !subpath ? pkg.module ?? pkg.main ?? "index.js" : `.${subpath}`);
|
|
14804
|
-
return
|
|
15204
|
+
return join44(resolvedPackageDir, entry);
|
|
14805
15205
|
}, 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) => {
|
|
14806
15206
|
try {
|
|
14807
15207
|
return statSync7(filePath).isFile();
|
|
@@ -14814,16 +15214,16 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14814
15214
|
const candidates = [
|
|
14815
15215
|
candidate,
|
|
14816
15216
|
...RUNTIME_JS_EXTENSIONS.map((extension) => `${candidate}${extension}`),
|
|
14817
|
-
...RUNTIME_JS_EXTENSIONS.map((extension) =>
|
|
15217
|
+
...RUNTIME_JS_EXTENSIONS.map((extension) => join44(candidate, `index${extension}`))
|
|
14818
15218
|
];
|
|
14819
15219
|
return candidates.find((filePath) => isRuntimeJsFile(filePath) && isFile(filePath)) ?? null;
|
|
14820
15220
|
}, findContainingRuntimePackageDir = (filePath) => {
|
|
14821
|
-
let dir =
|
|
14822
|
-
while (dir !==
|
|
14823
|
-
if (isNodeModulesPath(dir) && existsSync41(
|
|
15221
|
+
let dir = dirname27(filePath);
|
|
15222
|
+
while (dir !== dirname27(dir)) {
|
|
15223
|
+
if (isNodeModulesPath(dir) && existsSync41(join44(dir, "package.json"))) {
|
|
14824
15224
|
return dir;
|
|
14825
15225
|
}
|
|
14826
|
-
dir =
|
|
15226
|
+
dir = dirname27(dir);
|
|
14827
15227
|
}
|
|
14828
15228
|
return null;
|
|
14829
15229
|
}, resolvePackageImportEntryFile = (fromFile, specifier) => {
|
|
@@ -14836,13 +15236,13 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14836
15236
|
const entry = pickExportEntry(pkg?.imports?.[specifier]);
|
|
14837
15237
|
if (!entry)
|
|
14838
15238
|
return null;
|
|
14839
|
-
return
|
|
15239
|
+
return join44(packageDir, entry);
|
|
14840
15240
|
}, 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) => {
|
|
14841
|
-
const distRoot =
|
|
15241
|
+
const distRoot = resolve35(distDir);
|
|
14842
15242
|
for (const filePath of collectRuntimeRewriteRoots(distDir)) {
|
|
14843
|
-
if (
|
|
15243
|
+
if (resolve35(dirname27(filePath)) === distRoot)
|
|
14844
15244
|
continue;
|
|
14845
|
-
const source =
|
|
15245
|
+
const source = readFileSync38(filePath, "utf-8");
|
|
14846
15246
|
for (const match of source.matchAll(MODULE_SPECIFIER_RE)) {
|
|
14847
15247
|
const [, , , specifier] = match;
|
|
14848
15248
|
if (!specifier || specifier.startsWith(".") || specifier.startsWith("/") || specifier.startsWith("#") || specifier.startsWith("node:") || specifier.startsWith("bun:")) {
|
|
@@ -14872,11 +15272,11 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14872
15272
|
if (!filePath || seen.has(filePath))
|
|
14873
15273
|
continue;
|
|
14874
15274
|
seen.add(filePath);
|
|
14875
|
-
const source =
|
|
15275
|
+
const source = readFileSync38(filePath, "utf-8");
|
|
14876
15276
|
const { masked, restore } = maskLiterals(source);
|
|
14877
15277
|
const rewrittenMasked = masked.replace(MODULE_SPECIFIER_RE, (match, prefix, quote, specifier) => {
|
|
14878
15278
|
if (typeof specifier === "string" && specifier.startsWith(".")) {
|
|
14879
|
-
enqueue(resolveRuntimeJsFile(
|
|
15279
|
+
enqueue(resolveRuntimeJsFile(resolve35(dirname27(filePath), specifier)));
|
|
14880
15280
|
return match;
|
|
14881
15281
|
}
|
|
14882
15282
|
const packageImportTarget = resolveRuntimeJsFile(resolvePackageImportEntryFile(filePath, specifier) ?? "");
|
|
@@ -14920,7 +15320,7 @@ var cliTag4 = (color, message) => `\x1B[2m${formatTimestamp()}\x1B[0m ${color}[c
|
|
|
14920
15320
|
const nativeAssets = resolveCompileNativeAssets(buildConfig);
|
|
14921
15321
|
nativeAssets.forEach((asset, idx) => {
|
|
14922
15322
|
const varName = `__native${idx}`;
|
|
14923
|
-
const importSpecifier = asset.import.startsWith(".") ?
|
|
15323
|
+
const importSpecifier = asset.import.startsWith(".") ? resolve35(process.cwd(), asset.import) : asset.import;
|
|
14924
15324
|
nativeImports.push(`import ${varName} from ${JSON.stringify(importSpecifier)} with { type: "file" };`);
|
|
14925
15325
|
nativeMappings.push(` [${JSON.stringify(asset.env)}, resolveNativeAssetPath(${varName})],`);
|
|
14926
15326
|
});
|
|
@@ -14979,7 +15379,7 @@ import { buildGlobalWSHandler } from "elysia/ws";
|
|
|
14979
15379
|
const SERVER_MODULE = (runtimeDir: string) => import(pathToFileURL(join(runtimeDir, ${JSON.stringify(serverBundleName)})).href);
|
|
14980
15380
|
const RUNTIME_BUILD_ID = ${JSON.stringify(runtimeBuildId)};
|
|
14981
15381
|
const RUNTIME_CONFIG_SOURCE = ${JSON.stringify(runtimeConfigSource)};
|
|
14982
|
-
const ORIGINAL_BUILD_DIR = ${JSON.stringify(
|
|
15382
|
+
const ORIGINAL_BUILD_DIR = ${JSON.stringify(resolve35(distDir))};
|
|
14983
15383
|
const ORIGINAL_BUILD_DIR_NORMALIZED = ORIGINAL_BUILD_DIR.replace(/\\\\/g, "/");
|
|
14984
15384
|
const EMBEDDED_NATIVE_AUTH_CLIENTS = ${JSON.stringify(process.env[ABSOLUTE_NATIVE_AUTH_CLIENTS_ENV])};
|
|
14985
15385
|
|
|
@@ -15400,17 +15800,17 @@ console.log(\`
|
|
|
15400
15800
|
});
|
|
15401
15801
|
}
|
|
15402
15802
|
}), compile = async (serverEntry, outdir, outfile, configPath2) => {
|
|
15403
|
-
const resolvedOutdir =
|
|
15803
|
+
const resolvedOutdir = resolve35(outdir ?? "dist");
|
|
15404
15804
|
await withBuildDirectoryLock(resolvedOutdir, () => compileUnlocked(serverEntry, resolvedOutdir, outfile, configPath2));
|
|
15405
15805
|
}, compileUnlocked = async (serverEntry, resolvedOutdir, outfile, configPath2) => {
|
|
15406
15806
|
const configuredPrerenderPort = env5.COMPILE_PORT === undefined ? Number(env5.PORT) : Number(env5.COMPILE_PORT);
|
|
15407
15807
|
const prerenderPort = configuredPrerenderPort > 0 ? configuredPrerenderPort : await findFreePort();
|
|
15408
15808
|
killStaleProcesses(prerenderPort);
|
|
15409
15809
|
const entryName = basename12(serverEntry).replace(/\.[^.]+$/, "");
|
|
15410
|
-
const resolvedOutfile =
|
|
15810
|
+
const resolvedOutfile = resolve35(outfile ?? "compiled-server");
|
|
15411
15811
|
const absoluteVersion = resolvePackageVersion3([
|
|
15412
|
-
|
|
15413
|
-
|
|
15812
|
+
resolve35(import.meta.dir, "..", "..", "..", "package.json"),
|
|
15813
|
+
resolve35(import.meta.dir, "..", "..", "package.json")
|
|
15414
15814
|
]);
|
|
15415
15815
|
compileBanner(absoluteVersion);
|
|
15416
15816
|
const totalStart = performance.now();
|
|
@@ -15423,8 +15823,8 @@ console.log(\`
|
|
|
15423
15823
|
installAbsoluteMobileAuthEnvironment(process.cwd(), normalizeAbsoluteMobileConfig(buildConfig.mobile, process.cwd()));
|
|
15424
15824
|
try {
|
|
15425
15825
|
const build2 = await resolveBuildModule3([
|
|
15426
|
-
|
|
15427
|
-
|
|
15826
|
+
resolve35(import.meta.dir, "..", "..", "core", "build"),
|
|
15827
|
+
resolve35(import.meta.dir, "..", "build")
|
|
15428
15828
|
]);
|
|
15429
15829
|
if (!build2)
|
|
15430
15830
|
throw new Error("Could not locate build module");
|
|
@@ -15446,11 +15846,11 @@ console.log(\`
|
|
|
15446
15846
|
buildConfig.htmxDirectory
|
|
15447
15847
|
].filter((dir) => Boolean(dir));
|
|
15448
15848
|
const islandRegistrySpec = buildConfig.islands?.registry;
|
|
15449
|
-
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(
|
|
15450
|
-
const serverBundleEntryDirectory =
|
|
15849
|
+
const islandRegistryPlugin = islandRegistrySpec ? createIslandRegistryDefinitionPlugin(await loadIslandRegistryBuildInfo(resolve35(islandRegistrySpec))) : undefined;
|
|
15850
|
+
const serverBundleEntryDirectory = join44(resolvedOutdir, ".absolutejs-server-entry");
|
|
15451
15851
|
mkdirSync18(serverBundleEntryDirectory, { recursive: true });
|
|
15452
|
-
const typeboxSetupEntry =
|
|
15453
|
-
const serverBundleEntry =
|
|
15852
|
+
const typeboxSetupEntry = join44(serverBundleEntryDirectory, "_typebox_setup.ts");
|
|
15853
|
+
const serverBundleEntry = join44(serverBundleEntryDirectory, basename12(serverEntry));
|
|
15454
15854
|
writeFileSync21(typeboxSetupEntry, `import { setupTypebox } from 'elysia';
|
|
15455
15855
|
import * as compile from 'typebox/compile';
|
|
15456
15856
|
import * as schema from 'typebox/schema';
|
|
@@ -15461,7 +15861,7 @@ import * as value from 'typebox/value';
|
|
|
15461
15861
|
setupTypebox({ typebox: { compile, schema, system, type, value } });
|
|
15462
15862
|
`);
|
|
15463
15863
|
writeFileSync21(serverBundleEntry, `import './_typebox_setup';
|
|
15464
|
-
import * as serverModule from ${JSON.stringify(
|
|
15864
|
+
import * as serverModule from ${JSON.stringify(resolve35(serverEntry))};
|
|
15465
15865
|
|
|
15466
15866
|
export const server = serverModule.server ?? serverModule.app ?? serverModule.default;
|
|
15467
15867
|
export default server;
|
|
@@ -15475,7 +15875,7 @@ export default server;
|
|
|
15475
15875
|
...islandRegistryPlugin ? [islandRegistryPlugin] : [],
|
|
15476
15876
|
...buildConfig.mobile ? [
|
|
15477
15877
|
createAbsoluteMobileRouteMetadataPlugin({
|
|
15478
|
-
entry:
|
|
15878
|
+
entry: resolve35(serverEntry)
|
|
15479
15879
|
})
|
|
15480
15880
|
] : [],
|
|
15481
15881
|
createElysiaOpenApiTypeboxPlugin(),
|
|
@@ -15499,13 +15899,13 @@ export default server;
|
|
|
15499
15899
|
console.error(cliTag4("\x1B[31m", "Server bundle failed."));
|
|
15500
15900
|
process.exit(1);
|
|
15501
15901
|
}
|
|
15502
|
-
const outputPath =
|
|
15902
|
+
const outputPath = resolve35(resolvedOutdir, `${entryName}.js`);
|
|
15503
15903
|
if (!existsSync41(outputPath)) {
|
|
15504
15904
|
console.error(cliTag4("\x1B[31m", `Expected output not found: ${outputPath}`));
|
|
15505
15905
|
process.exit(1);
|
|
15506
15906
|
}
|
|
15507
|
-
if (existsSync41(
|
|
15508
|
-
const vendorDir =
|
|
15907
|
+
if (existsSync41(resolve35(resolvedOutdir, "angular", "vendor", "server"))) {
|
|
15908
|
+
const vendorDir = resolve35(resolvedOutdir, "angular", "vendor", "server");
|
|
15509
15909
|
const vendorEntries = readdirSync7(vendorDir).filter((fileName) => fileName.endsWith(".js"));
|
|
15510
15910
|
const angularServerVendorPaths = {};
|
|
15511
15911
|
for (const file of vendorEntries) {
|
|
@@ -15514,7 +15914,7 @@ export default server;
|
|
|
15514
15914
|
if (scope !== "angular" || rest.length === 0)
|
|
15515
15915
|
continue;
|
|
15516
15916
|
const specifier = `@angular/${rest.join("/")}`;
|
|
15517
|
-
const relPath = relative22(
|
|
15917
|
+
const relPath = relative22(dirname27(outputPath), resolve35(vendorDir, file));
|
|
15518
15918
|
angularServerVendorPaths[specifier] = relPath.startsWith(".") ? relPath : `./${relPath}`;
|
|
15519
15919
|
}
|
|
15520
15920
|
if (Object.keys(angularServerVendorPaths).length > 0) {
|
|
@@ -15526,7 +15926,7 @@ export default server;
|
|
|
15526
15926
|
copyServerRuntimeAssetReferences(resolvedOutdir);
|
|
15527
15927
|
const prerenderStart = performance.now();
|
|
15528
15928
|
process.stdout.write(cliTag4("\x1B[36m", "Pre-rendering pages"));
|
|
15529
|
-
rmSync7(
|
|
15929
|
+
rmSync7(join44(resolvedOutdir, "_prerendered"), {
|
|
15530
15930
|
force: true,
|
|
15531
15931
|
recursive: true
|
|
15532
15932
|
});
|
|
@@ -15556,9 +15956,9 @@ export default server;
|
|
|
15556
15956
|
const compileStart = performance.now();
|
|
15557
15957
|
process.stdout.write(cliTag4("\x1B[36m", "Compiling standalone executable"));
|
|
15558
15958
|
const entrypointCode = generateEntrypoint(resolvedOutdir, serverEntry, prerenderMap, absoluteVersion, buildConfig);
|
|
15559
|
-
const entrypointPath =
|
|
15959
|
+
const entrypointPath = join44(resolvedOutdir, "_compile_entrypoint.ts");
|
|
15560
15960
|
await Bun.write(entrypointPath, entrypointCode);
|
|
15561
|
-
mkdirSync18(
|
|
15961
|
+
mkdirSync18(dirname27(resolvedOutfile), { recursive: true });
|
|
15562
15962
|
const result = await Bun.build({
|
|
15563
15963
|
compile: { outfile: resolvedOutfile },
|
|
15564
15964
|
define: { "process.env.NODE_ENV": '"production"' },
|
|
@@ -15642,7 +16042,7 @@ var init_compile = __esm(() => {
|
|
|
15642
16042
|
|
|
15643
16043
|
// src/mobile/nativeDeepLinks.ts
|
|
15644
16044
|
import { readFile as readFile11, rename as rename8, writeFile as writeFile9 } from "fs/promises";
|
|
15645
|
-
import { join as
|
|
16045
|
+
import { join as join45 } from "path";
|
|
15646
16046
|
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) => {
|
|
15647
16047
|
const current = await readFile11(path, "utf8");
|
|
15648
16048
|
if (current === source)
|
|
@@ -15671,7 +16071,7 @@ var START_MARKER = "<!-- absolutejs:deep-links:start -->", END_MARKER = "<!-- ab
|
|
|
15671
16071
|
}
|
|
15672
16072
|
return `${source.slice(0, index)}${region}${source.slice(index)}`;
|
|
15673
16073
|
}, androidRegion = (config) => {
|
|
15674
|
-
const hosts = config.deepLinkHosts.map((
|
|
16074
|
+
const hosts = config.deepLinkHosts.map((host2) => ` <data android:scheme="https" android:host="${escapeXml(host2)}" />`).join(`
|
|
15675
16075
|
`);
|
|
15676
16076
|
const customScheme = config.deepLinkScheme ? `
|
|
15677
16077
|
|
|
@@ -15691,7 +16091,7 @@ ${hosts}
|
|
|
15691
16091
|
${END_MARKER}
|
|
15692
16092
|
`;
|
|
15693
16093
|
}, configureAndroid = async (config) => {
|
|
15694
|
-
const path =
|
|
16094
|
+
const path = join45(config.nativeProjectDirectory, "android/app/src/main/AndroidManifest.xml");
|
|
15695
16095
|
const source = await readFile11(path, "utf8");
|
|
15696
16096
|
const mainActivity = source.indexOf('android:name=".MainActivity"');
|
|
15697
16097
|
if (mainActivity === NOT_FOUND) {
|
|
@@ -15715,7 +16115,7 @@ ${hosts}
|
|
|
15715
16115
|
</array>
|
|
15716
16116
|
${END_MARKER}
|
|
15717
16117
|
`, configureIosInfo = async (config) => {
|
|
15718
|
-
const path =
|
|
16118
|
+
const path = join45(config.nativeProjectDirectory, "ios/App/App/Info.plist");
|
|
15719
16119
|
const source = await readFile11(path, "utf8");
|
|
15720
16120
|
const region = config.deepLinkScheme ? iosSchemeRegion(config.deepLinkScheme) : ` ${START_MARKER}
|
|
15721
16121
|
${END_MARKER}
|
|
@@ -15723,7 +16123,7 @@ ${hosts}
|
|
|
15723
16123
|
const updated = replaceManagedRegion(source, region, () => source.lastIndexOf("</dict>"));
|
|
15724
16124
|
return writeChangedFile(path, updated);
|
|
15725
16125
|
}, iosEntitlementsSource = (config) => {
|
|
15726
|
-
const domains = config.deepLinkHosts.map((
|
|
16126
|
+
const domains = config.deepLinkHosts.map((host2) => ` <string>applinks:${escapeXml(host2)}</string>`).join(`
|
|
15727
16127
|
`);
|
|
15728
16128
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
15729
16129
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -15737,7 +16137,7 @@ ${domains}
|
|
|
15737
16137
|
</plist>
|
|
15738
16138
|
`;
|
|
15739
16139
|
}, configureIosEntitlements = async (config) => {
|
|
15740
|
-
const path =
|
|
16140
|
+
const path = join45(config.nativeProjectDirectory, "ios/App/AbsoluteJS.entitlements");
|
|
15741
16141
|
let current = "";
|
|
15742
16142
|
try {
|
|
15743
16143
|
current = await readFile11(path, "utf8");
|
|
@@ -15754,7 +16154,7 @@ ${domains}
|
|
|
15754
16154
|
await rename8(temporary, path);
|
|
15755
16155
|
return true;
|
|
15756
16156
|
}, configureIosProject = async (config) => {
|
|
15757
|
-
const path =
|
|
16157
|
+
const path = join45(config.nativeProjectDirectory, "ios/App/App.xcodeproj/project.pbxproj");
|
|
15758
16158
|
const source = await readFile11(path, "utf8");
|
|
15759
16159
|
const declarations = [
|
|
15760
16160
|
...source.matchAll(/CODE_SIGN_ENTITLEMENTS = ([^;]+);/g)
|
|
@@ -15794,7 +16194,7 @@ var init_nativeDeepLinks = () => {};
|
|
|
15794
16194
|
|
|
15795
16195
|
// src/mobile/nativeBackgroundSync.ts
|
|
15796
16196
|
import { readFile as readFile12, rename as rename9, writeFile as writeFile10 } from "fs/promises";
|
|
15797
|
-
import { join as
|
|
16197
|
+
import { join as join46 } from "path";
|
|
15798
16198
|
var writeChanged = async (path, source) => {
|
|
15799
16199
|
const current = await readFile12(path, "utf8");
|
|
15800
16200
|
if (current === source)
|
|
@@ -15877,10 +16277,10 @@ ${makeRegion(values)} </array>
|
|
|
15877
16277
|
if (!platforms.includes("ios") || !projectUsesAbsoluteAuth(projectRoot) || !projectUsesAbsoluteSync(projectRoot))
|
|
15878
16278
|
return { changed: false };
|
|
15879
16279
|
const identifier = `${config.appId}.absolutejs.background-sync`;
|
|
15880
|
-
const infoPath =
|
|
16280
|
+
const infoPath = join46(config.nativeProjectDirectory, "ios/App/App/Info.plist");
|
|
15881
16281
|
const info2 = await readFile12(infoPath, "utf8");
|
|
15882
16282
|
const nextInfo = ensurePlistArrayValues(ensurePlistArrayValues(info2, "BGTaskSchedulerPermittedIdentifiers", [identifier], "background-sync-identifiers"), "UIBackgroundModes", ["fetch", "processing"], "background-sync-modes");
|
|
15883
|
-
const delegatePath =
|
|
16283
|
+
const delegatePath = join46(config.nativeProjectDirectory, "ios/App/App/AppDelegate.swift");
|
|
15884
16284
|
let delegate = await readFile12(delegatePath, "utf8");
|
|
15885
16285
|
if (!delegate.includes("import AbsoluteSyncCapacitor")) {
|
|
15886
16286
|
const importIndex = delegate.lastIndexOf("import Capacitor");
|
|
@@ -15920,7 +16320,7 @@ import {
|
|
|
15920
16320
|
rm as rm7,
|
|
15921
16321
|
writeFile as writeFile11
|
|
15922
16322
|
} from "fs/promises";
|
|
15923
|
-
import { resolve as
|
|
16323
|
+
import { resolve as resolve36 } from "path";
|
|
15924
16324
|
import { Elysia } from "elysia";
|
|
15925
16325
|
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) => {
|
|
15926
16326
|
if (!config.platforms.includes("ios"))
|
|
@@ -15993,7 +16393,7 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
15993
16393
|
return false;
|
|
15994
16394
|
}
|
|
15995
16395
|
}, assertOwnedOutput = async (root) => {
|
|
15996
|
-
const path =
|
|
16396
|
+
const path = resolve36(root, OWNERSHIP_FILE);
|
|
15997
16397
|
let ownership;
|
|
15998
16398
|
try {
|
|
15999
16399
|
ownership = JSON.parse(await readFile13(path, "utf8"));
|
|
@@ -16019,34 +16419,34 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16019
16419
|
}
|
|
16020
16420
|
if (hasCurrent)
|
|
16021
16421
|
await rm7(backup, { force: true, recursive: true });
|
|
16022
|
-
}, materializeHost = async (root,
|
|
16023
|
-
const directory =
|
|
16422
|
+
}, materializeHost = async (root, host2, files) => {
|
|
16423
|
+
const directory = resolve36(root, host2, ".well-known");
|
|
16024
16424
|
await mkdir10(directory, { recursive: true });
|
|
16025
16425
|
return Promise.all(files.map(async ([name, document]) => {
|
|
16026
|
-
const path =
|
|
16426
|
+
const path = resolve36(directory, name);
|
|
16027
16427
|
await writeAtomic(path, `${JSON.stringify(document, null, 2)}
|
|
16028
16428
|
`);
|
|
16029
16429
|
return path;
|
|
16030
16430
|
}));
|
|
16031
|
-
}, associationEndpoints = (config, documents) => config.deepLinkHosts.flatMap((
|
|
16431
|
+
}, associationEndpoints = (config, documents) => config.deepLinkHosts.flatMap((host2) => {
|
|
16032
16432
|
const endpoints = [];
|
|
16033
16433
|
if (documents.android)
|
|
16034
16434
|
endpoints.push({
|
|
16035
16435
|
document: documents.android,
|
|
16036
|
-
host,
|
|
16436
|
+
host: host2,
|
|
16037
16437
|
path: ANDROID_ASSOCIATION_PATH,
|
|
16038
16438
|
platform: "Android"
|
|
16039
16439
|
});
|
|
16040
16440
|
if (documents.apple)
|
|
16041
16441
|
endpoints.push({
|
|
16042
16442
|
document: documents.apple,
|
|
16043
|
-
host,
|
|
16443
|
+
host: host2,
|
|
16044
16444
|
path: APPLE_ASSOCIATION_PATH,
|
|
16045
16445
|
platform: "Apple"
|
|
16046
16446
|
});
|
|
16047
16447
|
return endpoints;
|
|
16048
16448
|
}), materializeAbsoluteMobileAssociationFiles = async (config, outputDirectory) => {
|
|
16049
|
-
const root =
|
|
16449
|
+
const root = resolve36(outputDirectory);
|
|
16050
16450
|
const temporary = `${root}.${crypto.randomUUID()}.tmp`;
|
|
16051
16451
|
const documents = createAbsoluteMobileAssociationDocuments(config, {
|
|
16052
16452
|
requireAll: true
|
|
@@ -16059,11 +16459,11 @@ var OWNERSHIP_FILE = ".absolutejs-mobile-associations.json", HTTP_OK = 200, VERI
|
|
|
16059
16459
|
}
|
|
16060
16460
|
await mkdir10(temporary, { recursive: true });
|
|
16061
16461
|
try {
|
|
16062
|
-
const temporaryPaths = (await Promise.all(config.deepLinkHosts.map((
|
|
16063
|
-
await writeAtomic(
|
|
16462
|
+
const temporaryPaths = (await Promise.all(config.deepLinkHosts.map((host2) => materializeHost(temporary, host2, files)))).flat();
|
|
16463
|
+
await writeAtomic(resolve36(temporary, OWNERSHIP_FILE), `${JSON.stringify({ format: 1, hosts: config.deepLinkHosts }, null, 2)}
|
|
16064
16464
|
`);
|
|
16065
16465
|
await publishGeneratedDirectory(temporary, root);
|
|
16066
|
-
const written = temporaryPaths.map((path) =>
|
|
16466
|
+
const written = temporaryPaths.map((path) => resolve36(root, path.slice(temporary.length + 1)));
|
|
16067
16467
|
return { root, written };
|
|
16068
16468
|
} catch (error) {
|
|
16069
16469
|
await rm7(temporary, { force: true, recursive: true });
|
|
@@ -16105,7 +16505,7 @@ var init_associationFiles = __esm(() => {
|
|
|
16105
16505
|
|
|
16106
16506
|
// src/mobile/androidWebView.ts
|
|
16107
16507
|
import { mkdir as mkdir11, writeFile as writeFile12 } from "fs/promises";
|
|
16108
|
-
import { dirname as
|
|
16508
|
+
import { dirname as dirname28, resolve as resolve37 } from "path";
|
|
16109
16509
|
|
|
16110
16510
|
class CdpConnection {
|
|
16111
16511
|
diagnostics = [];
|
|
@@ -16376,8 +16776,8 @@ var CDP_COMMAND_TIMEOUT_MS = 1e4, WEBVIEW_ATTACH_TIMEOUT_MS = 30000, WEBVIEW_POL
|
|
|
16376
16776
|
if (typeof data !== "string") {
|
|
16377
16777
|
throw new Error("Android WebView screenshot returned no image data.");
|
|
16378
16778
|
}
|
|
16379
|
-
const absolutePath =
|
|
16380
|
-
await mkdir11(
|
|
16779
|
+
const absolutePath = resolve37(path);
|
|
16780
|
+
await mkdir11(dirname28(absolutePath), { recursive: true });
|
|
16381
16781
|
await writeFile12(absolutePath, Buffer.from(data, "base64"));
|
|
16382
16782
|
return absolutePath;
|
|
16383
16783
|
}
|
|
@@ -16497,7 +16897,7 @@ var DEFAULT_ROUTE_TIMEOUT_MS = 30000, DEFAULT_HMR_TIMEOUT_MS = 30000, routeExpre
|
|
|
16497
16897
|
|
|
16498
16898
|
// src/mobile/releaseDoctor.ts
|
|
16499
16899
|
import { access as access8, readFile as readFile14, readdir as readdir4 } from "fs/promises";
|
|
16500
|
-
import { extname as extname7, join as
|
|
16900
|
+
import { extname as extname7, join as join47, relative as relative23 } from "path";
|
|
16501
16901
|
var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
16502
16902
|
try {
|
|
16503
16903
|
await access8(path);
|
|
@@ -16516,7 +16916,7 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16516
16916
|
if (!await pathExists5(root))
|
|
16517
16917
|
return;
|
|
16518
16918
|
const entries = await readdir4(root, { withFileTypes: true });
|
|
16519
|
-
const matches = await Promise.all(entries.map((entry) => inspectReleaseAsset(
|
|
16919
|
+
const matches = await Promise.all(entries.map((entry) => inspectReleaseAsset(join47(root, entry.name), entry.isDirectory(), entry.isFile())));
|
|
16520
16920
|
return matches.find((match) => match !== undefined);
|
|
16521
16921
|
}, pass = (id, detail, path) => ({ detail, id, path, status: "pass" }), fail5 = (id, detail, path, remediation) => ({
|
|
16522
16922
|
detail,
|
|
@@ -16560,12 +16960,29 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16560
16960
|
}, hmrAssetsReleaseCheck = async (publicRoot) => {
|
|
16561
16961
|
const hmrAsset = await findHmrAsset(publicRoot);
|
|
16562
16962
|
return hmrAsset ? fail5("android.hmr-assets", "A packaged Android asset contains the development HMR client.", hmrAsset, "Rebuild the production mobile bundle and run Capacitor sync again.") : pass("android.hmr-assets", "Packaged Android assets contain no development HMR markers.", publicRoot);
|
|
16963
|
+
}, syncSchemaReleaseCheck = (projectRoot) => {
|
|
16964
|
+
if (!projectUsesAbsoluteSync(projectRoot))
|
|
16965
|
+
return;
|
|
16966
|
+
const manifestPath = join47(projectRoot, "package.json");
|
|
16967
|
+
try {
|
|
16968
|
+
const schema = discoverAbsoluteSyncSchema(projectRoot);
|
|
16969
|
+
const versions = schema.components.map((component2) => `${component2.id}@${component2.version}`).join(", ");
|
|
16970
|
+
const collectionRules = schema.components.flatMap((component2) => component2.localData?.collections ?? []);
|
|
16971
|
+
const mutationRules = schema.components.flatMap((component2) => component2.localData?.mutations ?? []);
|
|
16972
|
+
const protectedCount = [...collectionRules, ...mutationRules].filter((rule) => rule.protection === "required").length;
|
|
16973
|
+
const memoryOnlyCount = collectionRules.filter((rule) => rule.persistence === "memory-only" || rule.onProtectionUnavailable === "memory-only").length;
|
|
16974
|
+
const quotas = schema.components.map((component2) => component2.localData?.maxBytesPerNamespace).filter((value) => value !== undefined);
|
|
16975
|
+
const policy = `${collectionRules.length} collection rule(s), ${mutationRules.length} mutation rule(s), ${protectedCount} encryption-required, ${memoryOnlyCount} memory-only fallback(s)${quotas.length > 0 ? `, ${Math.min(...quotas)}-byte effective quota` : ", no logical quota"}`;
|
|
16976
|
+
return pass("sync.storage-schema", `Generated offline schema is compatible: ${versions}; ${policy}.`, manifestPath);
|
|
16977
|
+
} catch (error) {
|
|
16978
|
+
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.");
|
|
16979
|
+
}
|
|
16563
16980
|
}, inspectAndroidRelease = async (config, projectRoot) => {
|
|
16564
|
-
const androidRoot =
|
|
16565
|
-
const nativeConfigPath =
|
|
16566
|
-
const manifestPath =
|
|
16567
|
-
const publicRoot =
|
|
16568
|
-
const journalPath =
|
|
16981
|
+
const androidRoot = join47(config.nativeProjectDirectory, "android");
|
|
16982
|
+
const nativeConfigPath = join47(androidRoot, "app", "src", "main", "assets", "capacitor.config.json");
|
|
16983
|
+
const manifestPath = join47(androidRoot, "app", "src", "main", "AndroidManifest.xml");
|
|
16984
|
+
const publicRoot = join47(androidRoot, "app", "src", "main", "assets", "public");
|
|
16985
|
+
const journalPath = join47(projectRoot, ".absolutejs", "mobile", "dev-session", "journal.json");
|
|
16569
16986
|
const checks = await Promise.all([
|
|
16570
16987
|
journalReleaseCheck(journalPath, "android"),
|
|
16571
16988
|
capacitorConfigReleaseCheck(nativeConfigPath),
|
|
@@ -16577,11 +16994,11 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16577
16994
|
path: check2.path ? relative23(projectRoot, check2.path).replaceAll("\\", "/") || "." : undefined
|
|
16578
16995
|
}));
|
|
16579
16996
|
}, inspectIosRelease = async (config, projectRoot) => {
|
|
16580
|
-
const iosAppRoot =
|
|
16581
|
-
const nativeConfigPath =
|
|
16582
|
-
const infoPath =
|
|
16583
|
-
const publicRoot =
|
|
16584
|
-
const journalPath =
|
|
16997
|
+
const iosAppRoot = join47(config.nativeProjectDirectory, "ios", "App", "App");
|
|
16998
|
+
const nativeConfigPath = join47(iosAppRoot, "capacitor.config.json");
|
|
16999
|
+
const infoPath = join47(iosAppRoot, "Info.plist");
|
|
17000
|
+
const publicRoot = join47(iosAppRoot, "public");
|
|
17001
|
+
const journalPath = join47(projectRoot, ".absolutejs", "mobile", "ios-dev-session", "journal.json");
|
|
16585
17002
|
const checks = [
|
|
16586
17003
|
await journalReleaseCheck(journalPath, "ios")
|
|
16587
17004
|
];
|
|
@@ -16614,12 +17031,21 @@ var HMR_ASSET_PATTERN, RELEASE_ASSET_EXTENSIONS, pathExists5 = async (path) => {
|
|
|
16614
17031
|
if (config.platforms.includes("ios")) {
|
|
16615
17032
|
checks.push(...await inspectIosRelease(config, projectRoot));
|
|
16616
17033
|
}
|
|
17034
|
+
const syncSchema = syncSchemaReleaseCheck(projectRoot);
|
|
17035
|
+
if (syncSchema) {
|
|
17036
|
+
checks.push({
|
|
17037
|
+
...syncSchema,
|
|
17038
|
+
path: syncSchema.path ? relative23(projectRoot, syncSchema.path).replaceAll("\\", "/") || "." : undefined
|
|
17039
|
+
});
|
|
17040
|
+
}
|
|
16617
17041
|
return {
|
|
16618
17042
|
checks,
|
|
16619
17043
|
ready: checks.length > 0 && checks.every((check2) => check2.status === "pass")
|
|
16620
17044
|
};
|
|
16621
17045
|
};
|
|
16622
17046
|
var init_releaseDoctor = __esm(() => {
|
|
17047
|
+
init_nativeAuth();
|
|
17048
|
+
init_syncSchema();
|
|
16623
17049
|
HMR_ASSET_PATTERN = /(?:__HMR_WS__|hmr-timing|__absolute_target|absolutejs-error-overlay)/u;
|
|
16624
17050
|
RELEASE_ASSET_EXTENSIONS = new Set([".html", ".js", ".mjs"]);
|
|
16625
17051
|
});
|
|
@@ -16637,7 +17063,7 @@ import {
|
|
|
16637
17063
|
stat as stat2,
|
|
16638
17064
|
writeFile as writeFile13
|
|
16639
17065
|
} from "fs/promises";
|
|
16640
|
-
import { dirname as
|
|
17066
|
+
import { dirname as dirname29, isAbsolute as isAbsolute7, join as join48, relative as relative24, resolve as resolve38, sep as sep6 } from "path";
|
|
16641
17067
|
var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), requireManifest2 = (value) => {
|
|
16642
17068
|
if (!isRecord13(value) || typeof value.appBuild !== "string" || typeof value.appId !== "string" || typeof value.runtime !== "string") {
|
|
16643
17069
|
throw new TypeError("Invalid embedded AbsoluteJS mobile manifest.");
|
|
@@ -16688,19 +17114,19 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
16688
17114
|
]);
|
|
16689
17115
|
return result.exitCode === 0 && /jar verified/iu.test(result.stdout);
|
|
16690
17116
|
}, sha256File2 = async (path) => createHash12("sha256").update(await readFile15(path)).digest("hex"), safeOutputDirectory2 = (projectRoot, requested) => {
|
|
16691
|
-
const root =
|
|
16692
|
-
const output =
|
|
17117
|
+
const root = resolve38(projectRoot);
|
|
17118
|
+
const output = resolve38(root, requested ?? ".absolutejs/mobile/releases/android");
|
|
16693
17119
|
const projectRelative = relative24(root, output);
|
|
16694
17120
|
if (projectRelative === ".." || projectRelative.startsWith(`..${sep6}`) || isAbsolute7(projectRelative)) {
|
|
16695
17121
|
throw new TypeError("mobile build --outdir must remain inside the project.");
|
|
16696
17122
|
}
|
|
16697
17123
|
return output;
|
|
16698
17124
|
}, installRelease2 = async (artifactPath, metadata, outputRoot) => {
|
|
16699
|
-
const releaseRoot =
|
|
17125
|
+
const releaseRoot = join48(outputRoot, metadata.releaseId);
|
|
16700
17126
|
const artifactName = "app-release.aab";
|
|
16701
|
-
const destination =
|
|
17127
|
+
const destination = join48(releaseRoot, artifactName);
|
|
16702
17128
|
if (await pathExists6(releaseRoot)) {
|
|
16703
|
-
const existing = requireManifestIdentity(JSON.parse(await readFile15(
|
|
17129
|
+
const existing = requireManifestIdentity(JSON.parse(await readFile15(join48(releaseRoot, "release.json"), "utf8")), metadata);
|
|
16704
17130
|
const [installedBytes, installedSha256] = await Promise.all([
|
|
16705
17131
|
stat2(destination).then(({ size }) => size),
|
|
16706
17132
|
sha256File2(destination)
|
|
@@ -16710,15 +17136,15 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
16710
17136
|
}
|
|
16711
17137
|
return { artifactPath: destination, metadata: existing, releaseRoot };
|
|
16712
17138
|
}
|
|
16713
|
-
await mkdir12(
|
|
16714
|
-
const staging = await mkdtemp5(
|
|
17139
|
+
await mkdir12(dirname29(releaseRoot), { recursive: true });
|
|
17140
|
+
const staging = await mkdtemp5(join48(dirname29(releaseRoot), ".android-stage-"));
|
|
16715
17141
|
try {
|
|
16716
|
-
await copyFile5(artifactPath,
|
|
17142
|
+
await copyFile5(artifactPath, join48(staging, artifactName));
|
|
16717
17143
|
const complete = {
|
|
16718
17144
|
...metadata,
|
|
16719
17145
|
artifact: artifactName
|
|
16720
17146
|
};
|
|
16721
|
-
await writeFile13(
|
|
17147
|
+
await writeFile13(join48(staging, "release.json"), `${JSON.stringify(complete, null, "\t")}
|
|
16722
17148
|
`, { flag: "wx" });
|
|
16723
17149
|
await rename11(staging, releaseRoot);
|
|
16724
17150
|
return { artifactPath: destination, metadata: complete, releaseRoot };
|
|
@@ -16743,11 +17169,11 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
16743
17169
|
if (options.versionCode !== undefined && (!Number.isSafeInteger(options.versionCode) || options.versionCode < 1 || options.versionCode > 2100000000)) {
|
|
16744
17170
|
throw new TypeError("Android versionCode must be an integer from 1 through 2100000000.");
|
|
16745
17171
|
}
|
|
16746
|
-
const projectRoot =
|
|
16747
|
-
const
|
|
16748
|
-
const androidRoot = options.androidRoot ?? process.env.ANDROID_HOME ?? process.env.ANDROID_SDK_ROOT ?? absoluteManagedAndroidSdkRoot(
|
|
16749
|
-
const nativeDirectory =
|
|
16750
|
-
const manifest = requireManifest2(JSON.parse(await readFile15(
|
|
17172
|
+
const projectRoot = resolve38(options.projectRoot);
|
|
17173
|
+
const host2 = options.host ?? detectAbsoluteMobileHost();
|
|
17174
|
+
const androidRoot = options.androidRoot ?? process.env.ANDROID_HOME ?? process.env.ANDROID_SDK_ROOT ?? absoluteManagedAndroidSdkRoot(host2);
|
|
17175
|
+
const nativeDirectory = join48(options.config.nativeProjectDirectory, "android");
|
|
17176
|
+
const manifest = requireManifest2(JSON.parse(await readFile15(join48(options.config.bundleDirectory, "absolute-mobile-manifest.json"), "utf8")));
|
|
16751
17177
|
if (manifest.appId !== options.config.appId) {
|
|
16752
17178
|
throw new TypeError("Embedded mobile manifest appId does not match mobile.appId.");
|
|
16753
17179
|
}
|
|
@@ -16766,7 +17192,7 @@ var ABSOLUTE_ANDROID_RELEASE_FORMAT = 1, isRecord13 = (value) => typeof value ==
|
|
|
16766
17192
|
project: {
|
|
16767
17193
|
androidRoot,
|
|
16768
17194
|
config: options.config,
|
|
16769
|
-
host,
|
|
17195
|
+
host: host2,
|
|
16770
17196
|
nativeDirectory,
|
|
16771
17197
|
projectRoot
|
|
16772
17198
|
},
|
|
@@ -16871,7 +17297,7 @@ var init_iosConformance = __esm(() => {
|
|
|
16871
17297
|
|
|
16872
17298
|
// src/mobile/releasePublisher.ts
|
|
16873
17299
|
import { access as access10 } from "fs/promises";
|
|
16874
|
-
import { isAbsolute as isAbsolute8, relative as relative25, resolve as
|
|
17300
|
+
import { isAbsolute as isAbsolute8, relative as relative25, resolve as resolve39, sep as sep7 } from "path";
|
|
16875
17301
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
16876
17302
|
var prepareAbsoluteIosRelease = async (publisher, options) => {
|
|
16877
17303
|
if (typeof publisher.prepareIosRelease !== "function") {
|
|
@@ -16893,8 +17319,8 @@ var prepareAbsoluteIosRelease = async (publisher, options) => {
|
|
|
16893
17319
|
}
|
|
16894
17320
|
return versionCode;
|
|
16895
17321
|
}, isRecord14 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), isPublisher = (value) => isRecord14(value) && typeof value.publish === "function", publisherModulePath = (projectRoot, requested) => {
|
|
16896
|
-
const root =
|
|
16897
|
-
const path =
|
|
17322
|
+
const root = resolve39(projectRoot);
|
|
17323
|
+
const path = resolve39(root, requested);
|
|
16898
17324
|
const projectRelative = relative25(root, path);
|
|
16899
17325
|
if (projectRelative === ".." || projectRelative.startsWith(`..${sep7}`) || isAbsolute8(projectRelative)) {
|
|
16900
17326
|
throw new TypeError("mobile publish --registry must remain inside the project.");
|
|
@@ -16968,10 +17394,10 @@ __export(exports_mobile, {
|
|
|
16968
17394
|
runMobile: () => runMobile
|
|
16969
17395
|
});
|
|
16970
17396
|
import { access as access11, mkdir as mkdir13, readFile as readFile17, writeFile as writeFile14 } from "fs/promises";
|
|
16971
|
-
import { join as
|
|
17397
|
+
import { join as join49, resolve as resolve40 } from "path";
|
|
16972
17398
|
import { createInterface } from "readline/promises";
|
|
16973
17399
|
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) => {
|
|
16974
|
-
const manifest = JSON.parse(await readFile17(
|
|
17400
|
+
const manifest = JSON.parse(await readFile17(join49(projectRoot, "package.json"), "utf8"));
|
|
16975
17401
|
if (!isRecord15(manifest))
|
|
16976
17402
|
throw new TypeError("Application package.json must contain an object.");
|
|
16977
17403
|
const names = new Set;
|
|
@@ -17008,7 +17434,7 @@ var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value
|
|
|
17008
17434
|
}
|
|
17009
17435
|
return value;
|
|
17010
17436
|
}, capacitorExecutable = async (projectRoot) => {
|
|
17011
|
-
const executable =
|
|
17437
|
+
const executable = join49(projectRoot, "node_modules", ".bin", "cap");
|
|
17012
17438
|
try {
|
|
17013
17439
|
await access11(executable);
|
|
17014
17440
|
return executable;
|
|
@@ -17094,7 +17520,7 @@ var NOT_FOUND2 = -1, isRecord15 = (value) => typeof value === "object" && value
|
|
|
17094
17520
|
await applyAbsoluteNativeBackgroundSync(projectRoot, mobile, platforms);
|
|
17095
17521
|
}, associations = async (args) => {
|
|
17096
17522
|
const { mobile, projectRoot } = await loadMobile(valueAfter(args, "--config"));
|
|
17097
|
-
const outputDirectory =
|
|
17523
|
+
const outputDirectory = resolve40(projectRoot, valueAfter(args, "--outdir") ?? ".absolutejs/mobile/associations");
|
|
17098
17524
|
if (args.includes("--verify")) {
|
|
17099
17525
|
const result2 = await verifyAbsoluteMobileAssociationFiles(mobile);
|
|
17100
17526
|
console.log(`Verified ${result2.results.length} hosted association files`);
|
|
@@ -17324,7 +17750,7 @@ Mobile release transport checks failed.`);
|
|
|
17324
17750
|
const durationMs = Math.round(performance.now() - startedAt);
|
|
17325
17751
|
console.log(`Built ${release.metadata.signed ? "signed" : "unsigned"} Android App Bundle in ${getDurationString(durationMs)}.`);
|
|
17326
17752
|
console.log(`Artifact: ${release.artifactPath}`);
|
|
17327
|
-
console.log(`Metadata: ${
|
|
17753
|
+
console.log(`Metadata: ${join49(release.releaseRoot, "release.json")}`);
|
|
17328
17754
|
return release;
|
|
17329
17755
|
} finally {
|
|
17330
17756
|
sendTelemetryEvent("mobile:android-release-build", {
|
|
@@ -17424,7 +17850,7 @@ Mobile release transport checks failed.`);
|
|
|
17424
17850
|
const durationMs = Math.round(performance.now() - startedAt);
|
|
17425
17851
|
console.log(`Built ${release.metadata.signed ? "signed" : "unsigned"} iOS IPA ${release.metadata.marketingVersion}${release.metadata.buildNumber ? ` (${release.metadata.buildNumber})` : ""} in ${getDurationString(durationMs)}.`);
|
|
17426
17852
|
console.log(`Artifact: ${release.artifactPath}`);
|
|
17427
|
-
console.log(`Metadata: ${
|
|
17853
|
+
console.log(`Metadata: ${join49(release.releaseRoot, "release.json")}`);
|
|
17428
17854
|
return release;
|
|
17429
17855
|
} finally {
|
|
17430
17856
|
sendTelemetryEvent("mobile:ios-release-build", {
|
|
@@ -17523,6 +17949,28 @@ Mobile release transport checks failed.`);
|
|
|
17523
17949
|
}
|
|
17524
17950
|
];
|
|
17525
17951
|
}
|
|
17952
|
+
}, appendSyncSchemaDoctorCheck = (checks, projectRoot) => {
|
|
17953
|
+
if (!projectUsesAbsoluteSync(projectRoot))
|
|
17954
|
+
return;
|
|
17955
|
+
try {
|
|
17956
|
+
const schema = discoverAbsoluteSyncSchema(projectRoot);
|
|
17957
|
+
checks.push({
|
|
17958
|
+
id: "sync.storage-schema",
|
|
17959
|
+
label: `Offline schema ${schema.components.map((component2) => `${component2.id}@${component2.version}`).join(", ")}`,
|
|
17960
|
+
path: join49(projectRoot, "package.json"),
|
|
17961
|
+
platform: "host",
|
|
17962
|
+
status: "pass"
|
|
17963
|
+
});
|
|
17964
|
+
} catch (error) {
|
|
17965
|
+
checks.push({
|
|
17966
|
+
id: "sync.storage-schema",
|
|
17967
|
+
label: "Offline schema metadata is invalid",
|
|
17968
|
+
path: join49(projectRoot, "package.json"),
|
|
17969
|
+
platform: "host",
|
|
17970
|
+
remediation: error instanceof Error ? error.message : String(error),
|
|
17971
|
+
status: "fail"
|
|
17972
|
+
});
|
|
17973
|
+
}
|
|
17526
17974
|
}, doctor = async (args) => {
|
|
17527
17975
|
if (args.includes("release")) {
|
|
17528
17976
|
await runReleaseDoctor(args);
|
|
@@ -17542,6 +17990,7 @@ Mobile release transport checks failed.`);
|
|
|
17542
17990
|
return;
|
|
17543
17991
|
}
|
|
17544
17992
|
const checks = await inspectAbsoluteMobileToolchain();
|
|
17993
|
+
appendSyncSchemaDoctorCheck(checks, process.cwd());
|
|
17545
17994
|
const selected = platform6 ? checks.filter((check2) => check2.platform === "host" || check2.platform === platform6) : checks;
|
|
17546
17995
|
if (args.includes("--json")) {
|
|
17547
17996
|
if (args.includes("--fix")) {
|
|
@@ -17601,7 +18050,7 @@ Emulator setup verification:`);
|
|
|
17601
18050
|
}
|
|
17602
18051
|
return { https: args.includes("--https"), port };
|
|
17603
18052
|
}
|
|
17604
|
-
const instances = listLiveInstances().filter((instance2) =>
|
|
18053
|
+
const instances = listLiveInstances().filter((instance2) => resolve40(instance2.cwd) === resolve40(projectRoot) && instance2.source === "dev" && instance2.port !== null);
|
|
17605
18054
|
if (instances.length !== 1) {
|
|
17606
18055
|
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>.");
|
|
17607
18056
|
}
|
|
@@ -17644,8 +18093,8 @@ Emulator setup verification:`);
|
|
|
17644
18093
|
}
|
|
17645
18094
|
return selected;
|
|
17646
18095
|
}, safeArtifactRoot = (projectRoot, value) => {
|
|
17647
|
-
const root =
|
|
17648
|
-
if (root !== projectRoot && !root.startsWith(`${
|
|
18096
|
+
const root = resolve40(projectRoot, value ?? ".absolutejs/mobile/test-artifacts");
|
|
18097
|
+
if (root !== projectRoot && !root.startsWith(`${resolve40(projectRoot)}/`)) {
|
|
17649
18098
|
throw new TypeError("mobile test --artifacts must remain inside the project.");
|
|
17650
18099
|
}
|
|
17651
18100
|
return root;
|
|
@@ -17670,10 +18119,10 @@ Emulator setup verification:`);
|
|
|
17670
18119
|
});
|
|
17671
18120
|
}, writeAndroidFailureArtifacts = async (options) => {
|
|
17672
18121
|
await mkdir13(options.artifactRoot, { recursive: true });
|
|
17673
|
-
const screenshot = options.session ? await options.session.screenshot(
|
|
18122
|
+
const screenshot = options.session ? await options.session.screenshot(join49(options.artifactRoot, "android-failure.png")).catch(() => {
|
|
17674
18123
|
return;
|
|
17675
18124
|
}) : undefined;
|
|
17676
|
-
const diagnosticPath =
|
|
18125
|
+
const diagnosticPath = join49(options.artifactRoot, "android-failure.json");
|
|
17677
18126
|
await writeFile14(diagnosticPath, `${JSON.stringify({
|
|
17678
18127
|
diagnostics: options.session?.diagnostics ?? [],
|
|
17679
18128
|
error: options.error instanceof Error ? options.error.message : String(options.error),
|
|
@@ -17764,14 +18213,14 @@ Emulator setup verification:`);
|
|
|
17764
18213
|
const port = Number(explicit);
|
|
17765
18214
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
17766
18215
|
throw new TypeError("mobile test --port must be a valid TCP port.");
|
|
17767
|
-
const instance2 = listLiveInstances().find((candidate) =>
|
|
18216
|
+
const instance2 = listLiveInstances().find((candidate) => resolve40(candidate.cwd) === resolve40(projectRoot) && candidate.source === "dev" && candidate.port === port);
|
|
17768
18217
|
return {
|
|
17769
18218
|
https: instance2?.https ?? args.includes("--https"),
|
|
17770
18219
|
instance: instance2,
|
|
17771
18220
|
port
|
|
17772
18221
|
};
|
|
17773
18222
|
}
|
|
17774
|
-
const instances = listLiveInstances().filter((instance2) =>
|
|
18223
|
+
const instances = listLiveInstances().filter((instance2) => resolve40(instance2.cwd) === resolve40(projectRoot) && instance2.source === "dev" && instance2.port !== null);
|
|
17775
18224
|
if (instances.length !== 1)
|
|
17776
18225
|
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>.");
|
|
17777
18226
|
const [instance] = instances;
|
|
@@ -17851,7 +18300,7 @@ Emulator setup verification:`);
|
|
|
17851
18300
|
return result;
|
|
17852
18301
|
}, writeIosFailureArtifacts = async (options) => {
|
|
17853
18302
|
await mkdir13(options.artifactRoot, { recursive: true });
|
|
17854
|
-
const screenshot =
|
|
18303
|
+
const screenshot = join49(options.artifactRoot, "ios-failure.png");
|
|
17855
18304
|
const screenshotResult = captureCommand4([
|
|
17856
18305
|
options.xcrun,
|
|
17857
18306
|
"simctl",
|
|
@@ -17860,7 +18309,7 @@ Emulator setup verification:`);
|
|
|
17860
18309
|
"screenshot",
|
|
17861
18310
|
screenshot
|
|
17862
18311
|
]);
|
|
17863
|
-
const diagnosticPath =
|
|
18312
|
+
const diagnosticPath = join49(options.artifactRoot, "ios-failure.json");
|
|
17864
18313
|
await writeFile14(diagnosticPath, `${JSON.stringify({
|
|
17865
18314
|
appId: options.appId,
|
|
17866
18315
|
error: options.error instanceof Error ? options.error.message : String(options.error),
|
|
@@ -17906,7 +18355,7 @@ Emulator setup verification:`);
|
|
|
17906
18355
|
], "iOS app launch");
|
|
17907
18356
|
await waitForIosHmrClient({ https, port, timeoutMs });
|
|
17908
18357
|
await mkdir13(artifactRoot, { recursive: true });
|
|
17909
|
-
const screenshot =
|
|
18358
|
+
const screenshot = join49(artifactRoot, "ios-simulator.png");
|
|
17910
18359
|
requireCapturedIosCommand([xcrun, "simctl", "io", simulator.udid, "screenshot", screenshot], "iOS simulator screenshot");
|
|
17911
18360
|
const hmrApply = await waitForRequestedIosHmr(args, instance, timeoutMs);
|
|
17912
18361
|
const report = {
|
|
@@ -18030,6 +18479,7 @@ var init_mobile = __esm(() => {
|
|
|
18030
18479
|
init_getDurationString();
|
|
18031
18480
|
init_remoteMacProtocol();
|
|
18032
18481
|
init_nativeAuth();
|
|
18482
|
+
init_syncSchema();
|
|
18033
18483
|
CAPACITOR_PACKAGES = [
|
|
18034
18484
|
"@capacitor/core",
|
|
18035
18485
|
"@capacitor/app",
|
|
@@ -18055,7 +18505,7 @@ var init_mobile = __esm(() => {
|
|
|
18055
18505
|
"@absolutejs/devices-capacitor@0.1.3"
|
|
18056
18506
|
];
|
|
18057
18507
|
CAPACITOR_SYNC_PACKAGE_SPECS = [
|
|
18058
|
-
"@absolutejs/sync-capacitor@0.
|
|
18508
|
+
"@absolutejs/sync-capacitor@0.7.0",
|
|
18059
18509
|
"@capacitor-community/sqlite@8.1.1"
|
|
18060
18510
|
];
|
|
18061
18511
|
});
|
|
@@ -18065,10 +18515,10 @@ var exports_typecheck = {};
|
|
|
18065
18515
|
__export(exports_typecheck, {
|
|
18066
18516
|
typecheck: () => typecheck
|
|
18067
18517
|
});
|
|
18068
|
-
import { resolve as
|
|
18069
|
-
import { existsSync as existsSync42, readFileSync as
|
|
18518
|
+
import { resolve as resolve41, join as join50 } from "path";
|
|
18519
|
+
import { existsSync as existsSync42, readFileSync as readFileSync39 } from "fs";
|
|
18070
18520
|
import { mkdir as mkdir14, writeFile as writeFile15 } from "fs/promises";
|
|
18071
|
-
var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), resolveConfigPath = (configPath2) =>
|
|
18521
|
+
var isCommandService3 = (service) => service.kind === "command" || Array.isArray(service.command), resolveConfigPath = (configPath2) => resolve41(configPath2 ?? process.env.ABSOLUTE_CONFIG ?? "absolute.config.ts"), getTypecheckTargets = async (configPath2) => {
|
|
18072
18522
|
if (!existsSync42(resolveConfigPath(configPath2))) {
|
|
18073
18523
|
const defaultService = {};
|
|
18074
18524
|
return [defaultService];
|
|
@@ -18090,7 +18540,7 @@ var isCommandService3 = (service) => service.kind === "command" || Array.isArray
|
|
|
18090
18540
|
const exitCode = await proc.exited;
|
|
18091
18541
|
return { exitCode, name, output: (stdout + stderr).trim() };
|
|
18092
18542
|
}, shellEscape = (value) => `'${value.replaceAll("'", "'\\''")}'`, runShell = async (name, command) => run(name, ["/bin/bash", "-lc", command]), findBin = (name) => {
|
|
18093
|
-
const local =
|
|
18543
|
+
const local = resolve41("node_modules", ".bin", name);
|
|
18094
18544
|
return existsSync42(local) ? local : null;
|
|
18095
18545
|
}, ANSI_COLOR_REGEX, ANSI_PURPLE_REGEX, ANSI_CYAN_REGEX, ANSI_TOKEN_END_REGEX, stripAnsi4 = (str) => str.replace(ANSI_COLOR_REGEX, ""), formatSvelteOutput = (output) => {
|
|
18096
18546
|
const cwd = `${process.cwd()}/`;
|
|
@@ -18138,15 +18588,15 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18138
18588
|
return formatted;
|
|
18139
18589
|
}, ABSOLUTE_INTERNAL_EXCLUDES, resolveAbsoluteTypeFile = (fileName) => {
|
|
18140
18590
|
const candidates = [
|
|
18141
|
-
|
|
18142
|
-
|
|
18143
|
-
|
|
18144
|
-
|
|
18591
|
+
resolve41("node_modules/@absolutejs/absolute/dist/types", fileName),
|
|
18592
|
+
resolve41(import.meta.dir, "../types", fileName),
|
|
18593
|
+
resolve41(import.meta.dir, "../../types", fileName),
|
|
18594
|
+
resolve41(import.meta.dir, "../../../types", fileName)
|
|
18145
18595
|
];
|
|
18146
18596
|
return candidates.find((candidate) => existsSync42(candidate)) ?? candidates[0];
|
|
18147
18597
|
}, ABSOLUTE_TYPECHECK_FILES, readProjectTsconfig = () => {
|
|
18148
18598
|
try {
|
|
18149
|
-
return JSON.parse(
|
|
18599
|
+
return JSON.parse(readFileSync39(resolve41("tsconfig.json"), "utf-8"));
|
|
18150
18600
|
} catch {
|
|
18151
18601
|
return {};
|
|
18152
18602
|
}
|
|
@@ -18168,37 +18618,44 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18168
18618
|
...excludes.map(toGeneratedConfigPath)
|
|
18169
18619
|
])
|
|
18170
18620
|
];
|
|
18171
|
-
}, buildVueTscCheck = (cacheDir) => {
|
|
18621
|
+
}, buildVueTscCheck = async (cacheDir) => {
|
|
18172
18622
|
const vueTscBin = findBin("vue-tsc");
|
|
18173
18623
|
if (!vueTscBin) {
|
|
18174
18624
|
console.error("\x1B[31m\u2717\x1B[0m vue-tsc is required for Vue type checking. Install it: bun add -d vue-tsc");
|
|
18175
18625
|
process.exit(1);
|
|
18176
18626
|
}
|
|
18177
|
-
const vueTsconfigPath =
|
|
18178
|
-
|
|
18627
|
+
const vueTsconfigPath = join50(cacheDir, "tsconfig.vue-check.json");
|
|
18628
|
+
await writeFile15(vueTsconfigPath, JSON.stringify({
|
|
18179
18629
|
compilerOptions: {
|
|
18180
18630
|
rootDir: ".."
|
|
18181
18631
|
},
|
|
18182
18632
|
exclude: getProjectTypecheckExcludes(),
|
|
18183
|
-
extends:
|
|
18633
|
+
extends: resolve41("tsconfig.json"),
|
|
18184
18634
|
include: getProjectTypecheckIncludes()
|
|
18185
|
-
}, null, "\t"))
|
|
18635
|
+
}, null, "\t"));
|
|
18636
|
+
const base = [
|
|
18186
18637
|
vueTscBin,
|
|
18187
18638
|
"--noEmit",
|
|
18188
18639
|
"--project",
|
|
18189
|
-
|
|
18640
|
+
resolve41(vueTsconfigPath),
|
|
18641
|
+
"--pretty"
|
|
18642
|
+
];
|
|
18643
|
+
const cached = await run("vue-tsc", [
|
|
18644
|
+
...base,
|
|
18190
18645
|
"--incremental",
|
|
18191
18646
|
"--tsBuildInfoFile",
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18647
|
+
join50(cacheDir, "vue-tsc.tsbuildinfo")
|
|
18648
|
+
]);
|
|
18649
|
+
if (cached.exitCode === 0 || cached.output.length > 0)
|
|
18650
|
+
return cached;
|
|
18651
|
+
return run("vue-tsc", base);
|
|
18195
18652
|
}, buildAngularCheck = async (cacheDir, angularDir) => {
|
|
18196
18653
|
const ngcBin = findBin("ngc");
|
|
18197
18654
|
if (!ngcBin) {
|
|
18198
18655
|
console.error("\x1B[31m\u2717\x1B[0m @angular/compiler-cli is required for Angular type checking. Install it: bun add -d @angular/compiler-cli");
|
|
18199
18656
|
process.exit(1);
|
|
18200
18657
|
}
|
|
18201
|
-
const angularTsconfigPath =
|
|
18658
|
+
const angularTsconfigPath = join50(cacheDir, "tsconfig.angular-check.json");
|
|
18202
18659
|
await writeFile15(angularTsconfigPath, JSON.stringify({
|
|
18203
18660
|
angularCompilerOptions: {
|
|
18204
18661
|
strictTemplates: true
|
|
@@ -18208,32 +18665,32 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18208
18665
|
rootDir: ".."
|
|
18209
18666
|
},
|
|
18210
18667
|
exclude: ABSOLUTE_INTERNAL_EXCLUDES.map(toGeneratedConfigPath),
|
|
18211
|
-
extends:
|
|
18668
|
+
extends: resolve41("tsconfig.json"),
|
|
18212
18669
|
include: [`../${angularDir}/**/*`]
|
|
18213
18670
|
}, null, "\t"));
|
|
18214
|
-
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(
|
|
18671
|
+
return runShell("ngc", `${shellEscape(ngcBin)} -p ${shellEscape(resolve41(angularTsconfigPath))}`);
|
|
18215
18672
|
}, buildTscCheck = (cacheDir) => {
|
|
18216
18673
|
const tscBin = findBin("tsc");
|
|
18217
18674
|
if (!tscBin) {
|
|
18218
18675
|
console.error("\x1B[31m\u2717\x1B[0m typescript is required for type checking. Install it: bun add -d typescript");
|
|
18219
18676
|
process.exit(1);
|
|
18220
18677
|
}
|
|
18221
|
-
const tscConfigPath =
|
|
18678
|
+
const tscConfigPath = join50(cacheDir, "tsconfig.typecheck.json");
|
|
18222
18679
|
return writeFile15(tscConfigPath, JSON.stringify({
|
|
18223
18680
|
compilerOptions: {
|
|
18224
18681
|
rootDir: ".."
|
|
18225
18682
|
},
|
|
18226
18683
|
exclude: getProjectTypecheckExcludes(),
|
|
18227
|
-
extends:
|
|
18684
|
+
extends: resolve41("tsconfig.json"),
|
|
18228
18685
|
include: getProjectTypecheckIncludes()
|
|
18229
18686
|
}, null, "\t")).then(() => run("tsc", [
|
|
18230
18687
|
tscBin,
|
|
18231
18688
|
"--noEmit",
|
|
18232
18689
|
"--project",
|
|
18233
|
-
|
|
18690
|
+
resolve41(tscConfigPath),
|
|
18234
18691
|
"--incremental",
|
|
18235
18692
|
"--tsBuildInfoFile",
|
|
18236
|
-
|
|
18693
|
+
join50(cacheDir, "tsc.tsbuildinfo"),
|
|
18237
18694
|
"--pretty"
|
|
18238
18695
|
]));
|
|
18239
18696
|
}, buildSvelteCheck = async (cacheDir, svelteDir) => {
|
|
@@ -18242,16 +18699,16 @@ Found ${errorCount} error${suffix}.`;
|
|
|
18242
18699
|
console.error("\x1B[31m\u2717\x1B[0m svelte-check is required for Svelte type checking. Install it: bun add -d svelte-check");
|
|
18243
18700
|
process.exit(1);
|
|
18244
18701
|
}
|
|
18245
|
-
const svelteTsconfigPath =
|
|
18702
|
+
const svelteTsconfigPath = join50(cacheDir, "tsconfig.svelte-check.json");
|
|
18246
18703
|
await writeFile15(svelteTsconfigPath, JSON.stringify({
|
|
18247
|
-
extends:
|
|
18704
|
+
extends: resolve41("tsconfig.json"),
|
|
18248
18705
|
files: ABSOLUTE_TYPECHECK_FILES,
|
|
18249
18706
|
include: [`../${svelteDir}/**/*`]
|
|
18250
18707
|
}, null, "\t"));
|
|
18251
18708
|
return run("svelte-check", [
|
|
18252
18709
|
svelteBin,
|
|
18253
18710
|
"--tsconfig",
|
|
18254
|
-
|
|
18711
|
+
resolve41(svelteTsconfigPath),
|
|
18255
18712
|
"--threshold",
|
|
18256
18713
|
"error",
|
|
18257
18714
|
"--compiler-warnings",
|
|
@@ -18331,9 +18788,9 @@ var DEFAULT_RELAY_PORT = 8787, DEFAULT_REQUEST_TIMEOUT_MS = 30000, headersToObje
|
|
|
18331
18788
|
if (options.publicUrl)
|
|
18332
18789
|
return options.publicUrl.replace(/\/$/, "");
|
|
18333
18790
|
const url = new URL(request.url);
|
|
18334
|
-
const
|
|
18791
|
+
const host2 = request.headers.get("x-forwarded-host") ?? url.host;
|
|
18335
18792
|
const proto = request.headers.get("x-forwarded-proto") ?? url.protocol.replace(":", "");
|
|
18336
|
-
return `${proto}://${
|
|
18793
|
+
return `${proto}://${host2}`;
|
|
18337
18794
|
};
|
|
18338
18795
|
const isWebSocketUpgrade = (request) => request.headers.get("upgrade")?.toLowerCase() === "websocket";
|
|
18339
18796
|
const server = Bun.serve({
|
|
@@ -18445,11 +18902,11 @@ var DEFAULT_RELAY_PORT = 8787, DEFAULT_REQUEST_TIMEOUT_MS = 30000, headersToObje
|
|
|
18445
18902
|
url: url.pathname + url.search,
|
|
18446
18903
|
...bodyBytes && bodyBytes.length > 0 ? { bodyBase64: Buffer.from(bodyBytes).toString("base64") } : {}
|
|
18447
18904
|
};
|
|
18448
|
-
const responsePromise = new Promise((
|
|
18449
|
-
pending.set(id,
|
|
18905
|
+
const responsePromise = new Promise((resolve42) => {
|
|
18906
|
+
pending.set(id, resolve42);
|
|
18450
18907
|
});
|
|
18451
18908
|
client.send(encodeTunnelMessage(message));
|
|
18452
|
-
const timeout = new Promise((
|
|
18909
|
+
const timeout = new Promise((resolve42) => setTimeout(() => resolve42({ id, message: "timeout", type: "error" }), requestTimeoutMs));
|
|
18453
18910
|
const result = await Promise.race([responsePromise, timeout]);
|
|
18454
18911
|
pending.delete(id);
|
|
18455
18912
|
if (result.type === "error") {
|
|
@@ -20701,12 +21158,12 @@ import {
|
|
|
20701
21158
|
existsSync as existsSync12,
|
|
20702
21159
|
mkdirSync as mkdirSync7,
|
|
20703
21160
|
readdirSync as readdirSync2,
|
|
20704
|
-
readFileSync as
|
|
21161
|
+
readFileSync as readFileSync15,
|
|
20705
21162
|
unlinkSync as unlinkSync3,
|
|
20706
21163
|
writeFileSync as writeFileSync6
|
|
20707
21164
|
} from "fs";
|
|
20708
21165
|
import { createConnection } from "net";
|
|
20709
|
-
import { resolve as
|
|
21166
|
+
import { resolve as resolve21 } from "path";
|
|
20710
21167
|
|
|
20711
21168
|
// src/cli/workspaceTui.ts
|
|
20712
21169
|
init_constants();
|
|
@@ -21268,18 +21725,18 @@ var createWorkspaceTui = ({
|
|
|
21268
21725
|
|
|
21269
21726
|
// src/cli/scripts/workspace.ts
|
|
21270
21727
|
init_utils();
|
|
21271
|
-
var sourceServerBootstrap2 =
|
|
21272
|
-
var serverBootstrap2 = existsSync12(sourceServerBootstrap2) ? sourceServerBootstrap2 :
|
|
21728
|
+
var sourceServerBootstrap2 = resolve21(import.meta.dir, "../../dev/serverBootstrap.ts");
|
|
21729
|
+
var serverBootstrap2 = existsSync12(sourceServerBootstrap2) ? sourceServerBootstrap2 : resolve21(import.meta.dir, "../dev/serverBootstrap.js");
|
|
21273
21730
|
var ANSI_REGEX2 = new RegExp(`${String.fromCharCode(ANSI_ESCAPE_CODE)}\\[[0-?]*[ -/]*[@-~]`, "g");
|
|
21274
21731
|
var sleep = (durationMs) => Bun.sleep(durationMs);
|
|
21275
21732
|
var stripAnsi3 = (value) => value.replace(ANSI_REGEX2, "");
|
|
21276
21733
|
var sanitizeLogFileName = (value) => value.replace(/[^a-zA-Z0-9._-]/g, "_") || "unknown";
|
|
21277
21734
|
var createWorkspaceLogSink = (appendLog) => {
|
|
21278
|
-
const logDirectory =
|
|
21735
|
+
const logDirectory = resolve21(".absolutejs", "workspace", "logs");
|
|
21279
21736
|
mkdirSync7(logDirectory, { recursive: true });
|
|
21280
|
-
readdirSync2(logDirectory).filter((file) => file.endsWith(".log")).forEach((file) => unlinkSync3(
|
|
21281
|
-
writeFileSync6(
|
|
21282
|
-
writeFileSync6(
|
|
21737
|
+
readdirSync2(logDirectory).filter((file) => file.endsWith(".log")).forEach((file) => unlinkSync3(resolve21(logDirectory, file)));
|
|
21738
|
+
writeFileSync6(resolve21(logDirectory, "all.log"), "");
|
|
21739
|
+
writeFileSync6(resolve21(logDirectory, "workspace.log"), "");
|
|
21283
21740
|
const initializedSources = new Set(["workspace"]);
|
|
21284
21741
|
const writeLog = (source, message, level) => {
|
|
21285
21742
|
const cleanMessage = stripAnsi3(message).trimEnd();
|
|
@@ -21289,13 +21746,13 @@ var createWorkspaceLogSink = (appendLog) => {
|
|
|
21289
21746
|
const timestamp = new Date().toISOString();
|
|
21290
21747
|
const line = `[${timestamp}] [${level}] [${source}] ${cleanMessage}
|
|
21291
21748
|
`;
|
|
21292
|
-
const sourceFile =
|
|
21749
|
+
const sourceFile = resolve21(logDirectory, `${sanitizeLogFileName(source)}.log`);
|
|
21293
21750
|
if (!initializedSources.has(source)) {
|
|
21294
21751
|
writeFileSync6(sourceFile, "");
|
|
21295
21752
|
initializedSources.add(source);
|
|
21296
21753
|
}
|
|
21297
21754
|
appendFileSync(sourceFile, line);
|
|
21298
|
-
appendFileSync(
|
|
21755
|
+
appendFileSync(resolve21(logDirectory, "all.log"), line);
|
|
21299
21756
|
};
|
|
21300
21757
|
return {
|
|
21301
21758
|
appendLog: (source, message, level = "info") => {
|
|
@@ -21307,7 +21764,7 @@ var createWorkspaceLogSink = (appendLog) => {
|
|
|
21307
21764
|
};
|
|
21308
21765
|
var readPackageVersion3 = (candidate) => {
|
|
21309
21766
|
try {
|
|
21310
|
-
const pkg = JSON.parse(
|
|
21767
|
+
const pkg = JSON.parse(readFileSync15(candidate, "utf-8"));
|
|
21311
21768
|
if (pkg.name !== "@absolutejs/absolute") {
|
|
21312
21769
|
return null;
|
|
21313
21770
|
}
|
|
@@ -21319,9 +21776,9 @@ var readPackageVersion3 = (candidate) => {
|
|
|
21319
21776
|
};
|
|
21320
21777
|
var resolvePackageVersion2 = () => {
|
|
21321
21778
|
const candidates = [
|
|
21322
|
-
|
|
21323
|
-
|
|
21324
|
-
|
|
21779
|
+
resolve21(import.meta.dir, "..", "..", "package.json"),
|
|
21780
|
+
resolve21(import.meta.dir, "..", "..", "..", "package.json"),
|
|
21781
|
+
resolve21(import.meta.dir, "..", "..", "..", "..", "package.json")
|
|
21325
21782
|
];
|
|
21326
21783
|
for (const candidate of candidates) {
|
|
21327
21784
|
const version2 = readPackageVersion3(candidate);
|
|
@@ -21657,11 +22114,11 @@ var appendRemainingLogBuffer = (buffer, name, level, appendLog) => {
|
|
|
21657
22114
|
appendLog(name, buffer, level);
|
|
21658
22115
|
};
|
|
21659
22116
|
var getServicePublicHost = (service) => {
|
|
21660
|
-
const
|
|
21661
|
-
if (
|
|
22117
|
+
const host2 = service.env?.HOST ?? process.env.HOST ?? "localhost";
|
|
22118
|
+
if (host2 === "0.0.0.0" || host2 === "::") {
|
|
21662
22119
|
return "localhost";
|
|
21663
22120
|
}
|
|
21664
|
-
return
|
|
22121
|
+
return host2;
|
|
21665
22122
|
};
|
|
21666
22123
|
var getServiceProtocol = (service) => service.env?.ABSOLUTE_HTTPS === "true" || process.env.ABSOLUTE_HTTPS === "true" ? "https" : "http";
|
|
21667
22124
|
var createWorkspaceServiceEnv = (services) => {
|
|
@@ -21675,15 +22132,15 @@ var createWorkspaceServiceEnv = (services) => {
|
|
|
21675
22132
|
var getDefinedProcessEnv = () => Object.fromEntries(Object.entries(process.env).filter((entry) => typeof entry[1] === "string"));
|
|
21676
22133
|
var resolveAbsoluteServiceConfigPath = (service, cwd, options) => {
|
|
21677
22134
|
if (service.config)
|
|
21678
|
-
return
|
|
22135
|
+
return resolve21(cwd, service.config);
|
|
21679
22136
|
if (options.configPath)
|
|
21680
|
-
return
|
|
22137
|
+
return resolve21(options.configPath);
|
|
21681
22138
|
if (process.env.ABSOLUTE_CONFIG)
|
|
21682
|
-
return
|
|
22139
|
+
return resolve21(process.env.ABSOLUTE_CONFIG);
|
|
21683
22140
|
return;
|
|
21684
22141
|
};
|
|
21685
22142
|
var resolveService = (name, service, workspaceEnv, options) => {
|
|
21686
|
-
const cwd =
|
|
22143
|
+
const cwd = resolve21(service.cwd ?? ".");
|
|
21687
22144
|
const envVars = Object.assign(getDefinedProcessEnv(), workspaceEnv, service.port ? { PORT: String(service.port) } : {}, service.env, {
|
|
21688
22145
|
ABSOLUTE_INSTANCE_MANAGED: "1",
|
|
21689
22146
|
ABSOLUTE_WORKSPACE_MANAGED: "1",
|
|
@@ -21695,7 +22152,7 @@ var resolveService = (name, service, workspaceEnv, options) => {
|
|
|
21695
22152
|
if (isAbsoluteService(service)) {
|
|
21696
22153
|
const configPath2 = resolveAbsoluteServiceConfigPath(service, cwd, options);
|
|
21697
22154
|
Object.assign(envVars, configPath2 ? { ABSOLUTE_CONFIG: configPath2 } : {}, {
|
|
21698
|
-
ABSOLUTE_SERVER_ENTRY:
|
|
22155
|
+
ABSOLUTE_SERVER_ENTRY: resolve21(cwd, service.entry ?? DEFAULT_SERVER_ENTRY)
|
|
21699
22156
|
});
|
|
21700
22157
|
const command = [
|
|
21701
22158
|
process.execPath,
|
|
@@ -21725,8 +22182,8 @@ var resolveService = (name, service, workspaceEnv, options) => {
|
|
|
21725
22182
|
var resolveServiceBuildDirectory = (service) => {
|
|
21726
22183
|
if (!isAbsoluteService(service))
|
|
21727
22184
|
return null;
|
|
21728
|
-
const cwd =
|
|
21729
|
-
return
|
|
22185
|
+
const cwd = resolve21(service.cwd ?? ".");
|
|
22186
|
+
return resolve21(cwd, service.buildDirectory ?? "build");
|
|
21730
22187
|
};
|
|
21731
22188
|
var findSharedWorkspaceBuildDirectories = (services) => {
|
|
21732
22189
|
const byBuildDirectory = new Map;
|
|
@@ -21944,7 +22401,7 @@ var workspace = async (subcommand, options) => {
|
|
|
21944
22401
|
frameworks: [],
|
|
21945
22402
|
host: getServicePublicHost(resolved.service),
|
|
21946
22403
|
https: getServiceProtocol(resolved.service) === "https",
|
|
21947
|
-
logFile:
|
|
22404
|
+
logFile: resolve21(workspaceLogs.logDirectory, `${sanitizeLogFileName(name)}.log`),
|
|
21948
22405
|
name,
|
|
21949
22406
|
pid: processHandle.pid,
|
|
21950
22407
|
port: resolved.service.port ?? null,
|