@nuasite/cli 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -3
- package/dist/index.js +2376 -625
- package/dist/types/check-code.d.ts +19 -0
- package/dist/types/check-code.d.ts.map +1 -0
- package/dist/types/check.d.ts +11 -0
- package/dist/types/check.d.ts.map +1 -1
- package/dist/types/live-schema.d.ts +20 -0
- package/dist/types/live-schema.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/src/check-code.ts +133 -0
- package/src/check.ts +65 -6
- package/src/index.ts +3 -9
- package/src/live-schema.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -47,6 +47,39 @@ var __export = (target, all) => {
|
|
|
47
47
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
48
48
|
var __require = import.meta.require;
|
|
49
49
|
|
|
50
|
+
// ../cms-core/src/asset-paths.ts
|
|
51
|
+
function assetBaseDir(file) {
|
|
52
|
+
const lastSlash = file.lastIndexOf("/");
|
|
53
|
+
return lastSlash >= 0 ? file.slice(0, lastSlash) : "";
|
|
54
|
+
}
|
|
55
|
+
function normalizeSegments(base, rel) {
|
|
56
|
+
const out = base.slice();
|
|
57
|
+
for (const seg of rel.replace(/^\/+/, "").split("/")) {
|
|
58
|
+
if (seg === "" || seg === ".")
|
|
59
|
+
continue;
|
|
60
|
+
if (seg === "..") {
|
|
61
|
+
if (out.length === 0)
|
|
62
|
+
return null;
|
|
63
|
+
out.pop();
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
out.push(seg);
|
|
67
|
+
}
|
|
68
|
+
return out.join("/");
|
|
69
|
+
}
|
|
70
|
+
function resolveAssetCandidates(baseDir, rel) {
|
|
71
|
+
if (rel.startsWith("/")) {
|
|
72
|
+
const fromRoot = normalizeSegments([], rel);
|
|
73
|
+
if (fromRoot === null || fromRoot === "")
|
|
74
|
+
return [];
|
|
75
|
+
return [`public/${fromRoot}`, fromRoot];
|
|
76
|
+
}
|
|
77
|
+
if (baseDir === undefined)
|
|
78
|
+
return [];
|
|
79
|
+
const joined = normalizeSegments(baseDir.split("/").filter(Boolean), rel);
|
|
80
|
+
return joined === null ? [] : [joined];
|
|
81
|
+
}
|
|
82
|
+
|
|
50
83
|
// ../../node_modules/yaml/dist/nodes/identity.js
|
|
51
84
|
var require_identity = __commonJS((exports) => {
|
|
52
85
|
var ALIAS = Symbol.for("yaml.alias");
|
|
@@ -7011,6 +7044,497 @@ var require_dist = __commonJS((exports) => {
|
|
|
7011
7044
|
exports.visitAsync = visit.visitAsync;
|
|
7012
7045
|
});
|
|
7013
7046
|
|
|
7047
|
+
// ../cms-core/src/check-entries.ts
|
|
7048
|
+
import path from "path";
|
|
7049
|
+
function isPlainObject(value) {
|
|
7050
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
|
|
7051
|
+
}
|
|
7052
|
+
async function collectEntryFiles(fs, collection, base) {
|
|
7053
|
+
const pattern = collection.loaderPattern ?? "**/*.{md,mdx,json,yaml,yml}";
|
|
7054
|
+
const files = await fs.glob(`${base}/${pattern}`);
|
|
7055
|
+
return files.filter((file) => !path.basename(file).startsWith("_")).sort();
|
|
7056
|
+
}
|
|
7057
|
+
function parseEntry(file, raw) {
|
|
7058
|
+
const extension = path.extname(file);
|
|
7059
|
+
if (DATA_EXTENSIONS.has(extension)) {
|
|
7060
|
+
try {
|
|
7061
|
+
const parsed = extension === ".json" ? JSON.parse(raw) : import_yaml.default.parse(raw);
|
|
7062
|
+
return { frontmatter: isPlainObject(parsed) ? parsed : {} };
|
|
7063
|
+
} catch (error) {
|
|
7064
|
+
return { error: error instanceof Error ? error.message.split(`
|
|
7065
|
+
`)[0] : String(error) };
|
|
7066
|
+
}
|
|
7067
|
+
}
|
|
7068
|
+
const trimmed = raw.trimStart();
|
|
7069
|
+
if (!trimmed.startsWith("---"))
|
|
7070
|
+
return { frontmatter: {} };
|
|
7071
|
+
const lines = trimmed.split(`
|
|
7072
|
+
`);
|
|
7073
|
+
const end = lines.findIndex((line, index) => index > 0 && line.trimEnd() === "---");
|
|
7074
|
+
if (end === -1)
|
|
7075
|
+
return { error: "frontmatter is never closed (missing the second `---`)" };
|
|
7076
|
+
try {
|
|
7077
|
+
const parsed = import_yaml.default.parse(lines.slice(1, end).join(`
|
|
7078
|
+
`).trim());
|
|
7079
|
+
return { frontmatter: isPlainObject(parsed) ? parsed : {} };
|
|
7080
|
+
} catch (error) {
|
|
7081
|
+
return { error: error instanceof Error ? error.message.split(`
|
|
7082
|
+
`)[0] : String(error) };
|
|
7083
|
+
}
|
|
7084
|
+
}
|
|
7085
|
+
function collectionKind(collection, loaderPattern) {
|
|
7086
|
+
const extensions = collection.entries.map((entry) => path.extname(entry.file));
|
|
7087
|
+
if (extensions.length > 0)
|
|
7088
|
+
return extensions.some((extension) => extension === ".md" || extension === ".mdx") ? "markdown" : "data";
|
|
7089
|
+
return loaderPattern === undefined || /\bmdx?\b/.test(loaderPattern) ? "markdown" : "data";
|
|
7090
|
+
}
|
|
7091
|
+
async function loadCollections(fs, config) {
|
|
7092
|
+
const loaded = new Map;
|
|
7093
|
+
for (const [name, collection] of config) {
|
|
7094
|
+
const base = normalizeBase(collection.loaderBase ?? `src/content/${name}`);
|
|
7095
|
+
if (!await fs.exists(base)) {
|
|
7096
|
+
loaded.set(name, { name, base, exists: false, entries: [] });
|
|
7097
|
+
continue;
|
|
7098
|
+
}
|
|
7099
|
+
const entries = [];
|
|
7100
|
+
for (const file of await collectEntryFiles(fs, collection, base)) {
|
|
7101
|
+
const parsed = parseEntry(file, await fs.readFile(file));
|
|
7102
|
+
entries.push({
|
|
7103
|
+
file,
|
|
7104
|
+
stem: entryStem(file),
|
|
7105
|
+
..."error" in parsed ? { parseError: parsed.error } : { frontmatter: parsed.frontmatter }
|
|
7106
|
+
});
|
|
7107
|
+
}
|
|
7108
|
+
loaded.set(name, { name, base, exists: true, entries });
|
|
7109
|
+
}
|
|
7110
|
+
return loaded;
|
|
7111
|
+
}
|
|
7112
|
+
var import_yaml, DATA_EXTENSIONS, normalizeBase = (base) => path.normalize(base).replace(/^\.\//, "").replace(/\/+$/, ""), entryStem = (file) => path.basename(file).replace(/\.(md|mdx|json|ya?ml)$/, "");
|
|
7113
|
+
var init_check_entries = __esm(() => {
|
|
7114
|
+
import_yaml = __toESM(require_dist(), 1);
|
|
7115
|
+
DATA_EXTENSIONS = new Set([".json", ".yaml", ".yml"]);
|
|
7116
|
+
});
|
|
7117
|
+
|
|
7118
|
+
// ../cms-core/src/schema-port.ts
|
|
7119
|
+
function describeIssue(issue) {
|
|
7120
|
+
if (issue.path.length === 0)
|
|
7121
|
+
return { message: issue.message };
|
|
7122
|
+
const field = issue.path.join(".");
|
|
7123
|
+
return { field, message: `${field}: ${issue.message}` };
|
|
7124
|
+
}
|
|
7125
|
+
function schemaFor(schemas, collection) {
|
|
7126
|
+
return Object.hasOwn(schemas, collection) ? schemas[collection] : undefined;
|
|
7127
|
+
}
|
|
7128
|
+
|
|
7129
|
+
// ../cms-core/src/check-live.ts
|
|
7130
|
+
async function checkAgainstSchemas(input) {
|
|
7131
|
+
const findings = [];
|
|
7132
|
+
for (const collection of input.collections.values()) {
|
|
7133
|
+
const schema = schemaFor(input.schemas, collection.name);
|
|
7134
|
+
if (!schema)
|
|
7135
|
+
continue;
|
|
7136
|
+
for (const entry of collection.entries) {
|
|
7137
|
+
if (entry.frontmatter === undefined)
|
|
7138
|
+
continue;
|
|
7139
|
+
let result;
|
|
7140
|
+
try {
|
|
7141
|
+
result = await schema.safeParse(entry.frontmatter);
|
|
7142
|
+
} catch (error) {
|
|
7143
|
+
findings.push({
|
|
7144
|
+
severity: "error",
|
|
7145
|
+
code: "entry/schema-rejected",
|
|
7146
|
+
file: entry.file,
|
|
7147
|
+
message: `The collection schema threw while validating this entry: ${error instanceof Error ? error.message : String(error)}`
|
|
7148
|
+
});
|
|
7149
|
+
continue;
|
|
7150
|
+
}
|
|
7151
|
+
if (result.success)
|
|
7152
|
+
continue;
|
|
7153
|
+
for (const issue of result.issues) {
|
|
7154
|
+
findings.push({ severity: "error", code: "entry/schema-rejected", file: entry.file, ...describeIssue(issue) });
|
|
7155
|
+
}
|
|
7156
|
+
}
|
|
7157
|
+
}
|
|
7158
|
+
return findings;
|
|
7159
|
+
}
|
|
7160
|
+
var init_check_live = () => {};
|
|
7161
|
+
|
|
7162
|
+
// ../cms-core/src/schema-probe.ts
|
|
7163
|
+
function mutated(point, mutation) {
|
|
7164
|
+
let copy;
|
|
7165
|
+
try {
|
|
7166
|
+
copy = structuredClone(point.record);
|
|
7167
|
+
} catch {
|
|
7168
|
+
return null;
|
|
7169
|
+
}
|
|
7170
|
+
let parent = copy;
|
|
7171
|
+
for (const segment of point.path.slice(0, -1)) {
|
|
7172
|
+
if (!isContainer(parent))
|
|
7173
|
+
return null;
|
|
7174
|
+
parent = parent[segment];
|
|
7175
|
+
}
|
|
7176
|
+
const last = point.path.at(-1);
|
|
7177
|
+
if (last === undefined || !isContainer(parent))
|
|
7178
|
+
return null;
|
|
7179
|
+
if ("remove" in mutation)
|
|
7180
|
+
delete parent[last];
|
|
7181
|
+
else
|
|
7182
|
+
parent[last] = mutation.set;
|
|
7183
|
+
return copy;
|
|
7184
|
+
}
|
|
7185
|
+
async function probe(schema, point, mutation) {
|
|
7186
|
+
const value = mutated(point, mutation);
|
|
7187
|
+
if (value === null)
|
|
7188
|
+
return "unknown";
|
|
7189
|
+
try {
|
|
7190
|
+
const result = await schema.safeParse(value);
|
|
7191
|
+
if (result.success)
|
|
7192
|
+
return "accepted";
|
|
7193
|
+
const here = result.issues.some((issue) => point.path.every((segment, index) => issue.path[index] === segment));
|
|
7194
|
+
return here ? "rejected-here" : "rejected-elsewhere";
|
|
7195
|
+
} catch {
|
|
7196
|
+
return "unknown";
|
|
7197
|
+
}
|
|
7198
|
+
}
|
|
7199
|
+
async function governsPath(schema, point) {
|
|
7200
|
+
for (const value of GOVERNANCE_PROBES) {
|
|
7201
|
+
if (await probe(schema, point, { set: value }) === "rejected-here")
|
|
7202
|
+
return true;
|
|
7203
|
+
}
|
|
7204
|
+
return false;
|
|
7205
|
+
}
|
|
7206
|
+
async function acceptsMissing(schema, point) {
|
|
7207
|
+
return await probe(schema, point, { remove: true }) === "accepted";
|
|
7208
|
+
}
|
|
7209
|
+
async function rejectsValueAt(schema, point, value) {
|
|
7210
|
+
return await probe(schema, point, { set: value }) === "rejected-here";
|
|
7211
|
+
}
|
|
7212
|
+
async function firstAcceptedEntry(schema, entries) {
|
|
7213
|
+
for (const entry of entries) {
|
|
7214
|
+
if (!entry.frontmatter)
|
|
7215
|
+
continue;
|
|
7216
|
+
try {
|
|
7217
|
+
const result = await schema.safeParse(entry.frontmatter);
|
|
7218
|
+
if (result.success)
|
|
7219
|
+
return entry.frontmatter;
|
|
7220
|
+
} catch {}
|
|
7221
|
+
}
|
|
7222
|
+
return;
|
|
7223
|
+
}
|
|
7224
|
+
var pointAt = (seed, field) => ({ record: seed, path: [field] }), GOVERNANCE_PROBES, isContainer = (value) => typeof value === "object" && value !== null;
|
|
7225
|
+
var init_schema_probe = __esm(() => {
|
|
7226
|
+
GOVERNANCE_PROBES = [{ __nuaProbe: true }, ["__nua_probe__"], 918273.456, null];
|
|
7227
|
+
});
|
|
7228
|
+
|
|
7229
|
+
// ../cms-core/src/check-shape.ts
|
|
7230
|
+
async function requiredDrift(name, field, seed, schemas) {
|
|
7231
|
+
const schema = schemaFor(schemas, name);
|
|
7232
|
+
if (!schema || !field.required || field.layout?.hidden)
|
|
7233
|
+
return null;
|
|
7234
|
+
const point = pointAt(seed, field.name);
|
|
7235
|
+
if (!await acceptsMissing(schema, point))
|
|
7236
|
+
return null;
|
|
7237
|
+
if (!await governsPath(schema, point))
|
|
7238
|
+
return null;
|
|
7239
|
+
return {
|
|
7240
|
+
severity: "warning",
|
|
7241
|
+
code: "cms/required-drift",
|
|
7242
|
+
file: CONFIG_FILE,
|
|
7243
|
+
field: `${name}.${field.name}`,
|
|
7244
|
+
message: `The editor treats "${name}.${field.name}" as required and refuses to save it blank, but the schema accepts an entry without it.`,
|
|
7245
|
+
hint: "Either the schema should require it, or the config should show the parser that it is optional. Wrapping a field schema in a helper call (`field.image(z.string().optional())`) or reaching it through an import hides the `.optional()` from the parser, which then reads the field as required \u2014 put the wrapper outside, as `field.image(z.string()).optional()`."
|
|
7246
|
+
};
|
|
7247
|
+
}
|
|
7248
|
+
async function degradedField(name, field, seed, input) {
|
|
7249
|
+
const schema = schemaFor(input.schemas, name);
|
|
7250
|
+
if (!schema || field.type !== undefined || field.layout?.hidden)
|
|
7251
|
+
return null;
|
|
7252
|
+
if (anyEntryHasValue(input.collections.get(name)?.entries ?? [], field.name))
|
|
7253
|
+
return null;
|
|
7254
|
+
const point = pointAt(seed, field.name);
|
|
7255
|
+
for (const text of TEXT_PROBES) {
|
|
7256
|
+
if (!await rejectsValueAt(schema, point, text))
|
|
7257
|
+
return null;
|
|
7258
|
+
}
|
|
7259
|
+
return {
|
|
7260
|
+
severity: "error",
|
|
7261
|
+
code: "cms/field-degraded",
|
|
7262
|
+
file: CONFIG_FILE,
|
|
7263
|
+
field: `${name}.${field.name}`,
|
|
7264
|
+
message: `The editor will render "${name}.${field.name}" as a plain text input \u2014 the parser pinned no type and no entry supplies one \u2014 and the schema rejects text there.`,
|
|
7265
|
+
hint: "Write the field's type chain inline in the content config (`n.number()`, `n.date()`, `n.enum([\u2026])`). A type reached through an import, a helper with arguments, or a modifier applied after the object is built is invisible to the parser, which then leaves the editor guessing."
|
|
7266
|
+
};
|
|
7267
|
+
}
|
|
7268
|
+
async function checkFieldShapes(input) {
|
|
7269
|
+
const findings = [];
|
|
7270
|
+
for (const [name, collection] of input.config) {
|
|
7271
|
+
const schema = schemaFor(input.schemas, name);
|
|
7272
|
+
if (!schema || collection.fields.length === 0)
|
|
7273
|
+
continue;
|
|
7274
|
+
const seed = await firstAcceptedEntry(schema, input.collections.get(name)?.entries ?? []);
|
|
7275
|
+
if (!seed)
|
|
7276
|
+
continue;
|
|
7277
|
+
for (const field of collection.fields) {
|
|
7278
|
+
const drift = await requiredDrift(name, field, seed, input.schemas);
|
|
7279
|
+
if (drift)
|
|
7280
|
+
findings.push(drift);
|
|
7281
|
+
const degraded = await degradedField(name, field, seed, input);
|
|
7282
|
+
if (degraded)
|
|
7283
|
+
findings.push(degraded);
|
|
7284
|
+
}
|
|
7285
|
+
}
|
|
7286
|
+
return findings;
|
|
7287
|
+
}
|
|
7288
|
+
var CONFIG_FILE = "src/content.config.ts", TEXT_PROBES, anyEntryHasValue = (entries, field) => entries.some((entry) => entry.frontmatter !== undefined && entry.frontmatter[field] !== undefined);
|
|
7289
|
+
var init_check_shape = __esm(() => {
|
|
7290
|
+
init_schema_probe();
|
|
7291
|
+
TEXT_PROBES = ["", "nua", "https://nua.test/probe", "2024-01-02", "123"];
|
|
7292
|
+
});
|
|
7293
|
+
|
|
7294
|
+
// ../cms-types/src/field-values.ts
|
|
7295
|
+
function isBlankFieldValue(value) {
|
|
7296
|
+
return value === undefined || value === null || value === "";
|
|
7297
|
+
}
|
|
7298
|
+
function defaultValueForNewEntry(field, today = () => new Date) {
|
|
7299
|
+
if (field.defaultValue !== undefined)
|
|
7300
|
+
return field.defaultValue;
|
|
7301
|
+
switch (field.type) {
|
|
7302
|
+
case "boolean":
|
|
7303
|
+
return false;
|
|
7304
|
+
case "number":
|
|
7305
|
+
return 0;
|
|
7306
|
+
case "array":
|
|
7307
|
+
return [];
|
|
7308
|
+
case "date":
|
|
7309
|
+
return today().toISOString().split("T")[0];
|
|
7310
|
+
default:
|
|
7311
|
+
return "";
|
|
7312
|
+
}
|
|
7313
|
+
}
|
|
7314
|
+
function newRepeaterItem(fields, today) {
|
|
7315
|
+
const item = {};
|
|
7316
|
+
for (const field of fields) {
|
|
7317
|
+
if (!field.required || field.hidden)
|
|
7318
|
+
continue;
|
|
7319
|
+
item[field.name] = defaultValueForNewEntry(field, today);
|
|
7320
|
+
}
|
|
7321
|
+
return item;
|
|
7322
|
+
}
|
|
7323
|
+
function blankRequiredFields(fields, frontmatter) {
|
|
7324
|
+
return fields.filter((field) => field.required && !(field.hidden ?? field.layout?.hidden) && isBlankFieldValue(frontmatter[field.name])).map((field) => field.name);
|
|
7325
|
+
}
|
|
7326
|
+
// ../cms-types/src/index.ts
|
|
7327
|
+
function isFieldType(value) {
|
|
7328
|
+
return FIELD_TYPES.includes(value);
|
|
7329
|
+
}
|
|
7330
|
+
var FIELD_TYPES;
|
|
7331
|
+
var init_src = __esm(() => {
|
|
7332
|
+
FIELD_TYPES = [
|
|
7333
|
+
"text",
|
|
7334
|
+
"textarea",
|
|
7335
|
+
"markdown",
|
|
7336
|
+
"date",
|
|
7337
|
+
"datetime",
|
|
7338
|
+
"time",
|
|
7339
|
+
"year",
|
|
7340
|
+
"month",
|
|
7341
|
+
"boolean",
|
|
7342
|
+
"number",
|
|
7343
|
+
"image",
|
|
7344
|
+
"file",
|
|
7345
|
+
"url",
|
|
7346
|
+
"email",
|
|
7347
|
+
"tel",
|
|
7348
|
+
"color",
|
|
7349
|
+
"select",
|
|
7350
|
+
"array",
|
|
7351
|
+
"object",
|
|
7352
|
+
"reference"
|
|
7353
|
+
];
|
|
7354
|
+
});
|
|
7355
|
+
|
|
7356
|
+
// ../cms-core/src/editor-write-model.ts
|
|
7357
|
+
function newEntryFrontmatter(fields, today) {
|
|
7358
|
+
const frontmatter = {};
|
|
7359
|
+
for (const field of fields) {
|
|
7360
|
+
if (field.name === "title" || field.hidden)
|
|
7361
|
+
continue;
|
|
7362
|
+
frontmatter[field.name] = defaultValueForNewEntry(field, today);
|
|
7363
|
+
}
|
|
7364
|
+
return frontmatter;
|
|
7365
|
+
}
|
|
7366
|
+
function applyCreateRouteFields(frontmatter, kind, today = () => new Date) {
|
|
7367
|
+
const title = "Untitled";
|
|
7368
|
+
if (kind === "data")
|
|
7369
|
+
return { title, ...frontmatter };
|
|
7370
|
+
return { title, date: today().toISOString().split("T")[0], ...frontmatter };
|
|
7371
|
+
}
|
|
7372
|
+
function omitEmptyOnCreate(frontmatter) {
|
|
7373
|
+
const out = {};
|
|
7374
|
+
for (const [key, value] of Object.entries(frontmatter)) {
|
|
7375
|
+
if (value !== undefined && value !== "")
|
|
7376
|
+
out[key] = value;
|
|
7377
|
+
}
|
|
7378
|
+
return out;
|
|
7379
|
+
}
|
|
7380
|
+
var init_editor_write_model = __esm(() => {
|
|
7381
|
+
init_src();
|
|
7382
|
+
init_src();
|
|
7383
|
+
});
|
|
7384
|
+
|
|
7385
|
+
// ../cms-core/src/check-write.ts
|
|
7386
|
+
async function parseWrite(schema, value) {
|
|
7387
|
+
try {
|
|
7388
|
+
const result = await schema.safeParse(value);
|
|
7389
|
+
return { issues: result.success ? [] : result.issues };
|
|
7390
|
+
} catch (error) {
|
|
7391
|
+
return { threw: errorText(error) };
|
|
7392
|
+
}
|
|
7393
|
+
}
|
|
7394
|
+
function valueAt(record, path2) {
|
|
7395
|
+
let current = record;
|
|
7396
|
+
for (const segment of path2) {
|
|
7397
|
+
if (Array.isArray(current)) {
|
|
7398
|
+
const index = typeof segment === "number" ? segment : Number(segment);
|
|
7399
|
+
if (!Number.isInteger(index) || index < 0 || index >= current.length)
|
|
7400
|
+
return { present: false };
|
|
7401
|
+
current = current[index];
|
|
7402
|
+
continue;
|
|
7403
|
+
}
|
|
7404
|
+
if (!isPlainObject(current) || !Object.hasOwn(current, String(segment)))
|
|
7405
|
+
return { present: false };
|
|
7406
|
+
current = current[String(segment)];
|
|
7407
|
+
}
|
|
7408
|
+
return current === undefined ? { present: false } : { present: true, value: current };
|
|
7409
|
+
}
|
|
7410
|
+
function hintFor(action, found) {
|
|
7411
|
+
if (action === "create") {
|
|
7412
|
+
if (!found.present) {
|
|
7413
|
+
return "The create form leaves an untouched field out of the write entirely. `.optional()` or `.default(\u2026)` accepts a missing key; `.nullable()` does not \u2014 it accepts `null`, not absence.";
|
|
7414
|
+
}
|
|
7415
|
+
return `The create form starts this field at ${JSON.stringify(found.value)} and nothing makes the editor change it before saving. Either the schema accepts that value, or mark the field \`hidden\` so the write omits it and let \`.default(\u2026)\` supply one.`;
|
|
7416
|
+
}
|
|
7417
|
+
if (!found.present) {
|
|
7418
|
+
return 'The appended item does not carry this key \u2014 "+ Add" seeds only the item fields the config declares required. Declaring it required there is what makes the editor seed it; if it is not required, `.optional()` or `.default(\u2026)` says so to the schema, and `.nullable()` does not \u2014 it accepts `null`, not absence.';
|
|
7419
|
+
}
|
|
7420
|
+
return `The appended item carries ${JSON.stringify(found.value)} for this key, and it is written the moment "+ Add" is clicked. \`.default(\u2026)\` on the inner field is the way out: the parser then reads the field as optional, so the item leaves the key out and the schema supplies the value itself.`;
|
|
7421
|
+
}
|
|
7422
|
+
function rejectionFinding(action, issue, kind, written) {
|
|
7423
|
+
const { field, message } = describeIssue(issue);
|
|
7424
|
+
const finding = {
|
|
7425
|
+
severity: "error",
|
|
7426
|
+
code: "cms/empty-write",
|
|
7427
|
+
file: CONFIG_FILE2,
|
|
7428
|
+
message: `${action} produces a write the schema rejects. ${message}`
|
|
7429
|
+
};
|
|
7430
|
+
if (field !== undefined)
|
|
7431
|
+
finding.field = field;
|
|
7432
|
+
finding.hint = hintFor(kind, valueAt(written, issue.path));
|
|
7433
|
+
return finding;
|
|
7434
|
+
}
|
|
7435
|
+
function blankItemsFor(field, current, today) {
|
|
7436
|
+
const itemFields = field.fields ?? [];
|
|
7437
|
+
if (itemFields.length > 0) {
|
|
7438
|
+
return [newRepeaterItem(itemFields.map((item) => ({ ...toWriteModelField(item), required: item.required })), today)];
|
|
7439
|
+
}
|
|
7440
|
+
if (current.length === 0)
|
|
7441
|
+
return [{}, { name: "" }];
|
|
7442
|
+
const first = current[0];
|
|
7443
|
+
const template = isPlainObject(first) ? Object.fromEntries(Object.keys(first).map((key) => [key, ""])) : {};
|
|
7444
|
+
return [{}, template];
|
|
7445
|
+
}
|
|
7446
|
+
async function checkEditorWrites(input) {
|
|
7447
|
+
const findings = [];
|
|
7448
|
+
const seen = new Set;
|
|
7449
|
+
const report = (key, finding) => {
|
|
7450
|
+
const identity = `${key} ${finding.field ?? ""}`;
|
|
7451
|
+
if (seen.has(identity))
|
|
7452
|
+
return;
|
|
7453
|
+
seen.add(identity);
|
|
7454
|
+
findings.push(finding);
|
|
7455
|
+
};
|
|
7456
|
+
for (const [name, collection] of input.config) {
|
|
7457
|
+
const schema = schemaFor(input.schemas, name);
|
|
7458
|
+
if (!schema)
|
|
7459
|
+
continue;
|
|
7460
|
+
const createKey = `${name} create`;
|
|
7461
|
+
if (collection.fields.length === 0) {
|
|
7462
|
+
report(createKey, {
|
|
7463
|
+
severity: "warning",
|
|
7464
|
+
code: "cms/empty-write-unchecked",
|
|
7465
|
+
file: CONFIG_FILE2,
|
|
7466
|
+
field: name,
|
|
7467
|
+
message: `Could not check what creating a new entry in "${name}" writes: its schema is not readable from the content config, so there are no fields to predict the write from.`,
|
|
7468
|
+
hint: "Write the field types inline in the content config rather than importing the shape from another module \u2014 the prediction reads the config source, and a schema assembled elsewhere leaves it nothing to read."
|
|
7469
|
+
});
|
|
7470
|
+
continue;
|
|
7471
|
+
}
|
|
7472
|
+
const loaded = input.collections.get(name);
|
|
7473
|
+
const entries = loaded?.entries ?? [];
|
|
7474
|
+
const kind = loaded ? collectionKind(loaded, collection.loaderPattern) : "markdown";
|
|
7475
|
+
const created = applyCreateRouteFields(omitEmptyOnCreate(newEntryFrontmatter(collection.fields.map(toWriteModelField), input.today)), kind, input.today);
|
|
7476
|
+
const guarded = new Set(blankRequiredFields(collection.fields, created));
|
|
7477
|
+
const createAction = `Creating a new entry in "${name}"`;
|
|
7478
|
+
const createVerdict = await parseWrite(schema, created);
|
|
7479
|
+
if ("threw" in createVerdict) {
|
|
7480
|
+
report(createKey, throwFinding(createAction, createVerdict.threw));
|
|
7481
|
+
} else {
|
|
7482
|
+
for (const issue of createVerdict.issues) {
|
|
7483
|
+
const top = issue.path[0];
|
|
7484
|
+
if (typeof top === "string" && guarded.has(top))
|
|
7485
|
+
continue;
|
|
7486
|
+
report(createKey, rejectionFinding(createAction, issue, "create", created));
|
|
7487
|
+
}
|
|
7488
|
+
}
|
|
7489
|
+
const repeaters = collection.fields.filter((field) => field.type === "array" && field.itemType === "object");
|
|
7490
|
+
if (repeaters.length === 0)
|
|
7491
|
+
continue;
|
|
7492
|
+
const seed = await firstAcceptedEntry(schema, entries);
|
|
7493
|
+
for (const field of repeaters) {
|
|
7494
|
+
const key = `${name} add:${field.name}`;
|
|
7495
|
+
if (!seed) {
|
|
7496
|
+
const hasEntries = entries.some((entry) => entry.frontmatter !== undefined);
|
|
7497
|
+
const reason = hasEntries ? "no existing entry passes the schema, so there is no valid record to add an item to" : "the collection has no entry to add an item to";
|
|
7498
|
+
report(key, {
|
|
7499
|
+
severity: "warning",
|
|
7500
|
+
code: "cms/empty-write-unchecked",
|
|
7501
|
+
file: CONFIG_FILE2,
|
|
7502
|
+
field: field.name,
|
|
7503
|
+
message: `Could not check what "+ Add" on "${name}.${field.name}" writes: ${reason}.`,
|
|
7504
|
+
hint: hasEntries ? `Fix the \`entry/schema-rejected\` findings in "${name}" and run this again \u2014 the prediction needs one entry the schema accepts.` : `Add one entry to "${name}" and run this again.`
|
|
7505
|
+
});
|
|
7506
|
+
continue;
|
|
7507
|
+
}
|
|
7508
|
+
const current = seed[field.name];
|
|
7509
|
+
const existing = Array.isArray(current) ? current : [];
|
|
7510
|
+
const action = `Clicking "+ Add" on "${name}.${field.name}"`;
|
|
7511
|
+
for (const item of blankItemsFor(field, existing, input.today)) {
|
|
7512
|
+
const written = { ...seed, [field.name]: [...existing, item] };
|
|
7513
|
+
const verdict = await parseWrite(schema, written);
|
|
7514
|
+
if ("threw" in verdict) {
|
|
7515
|
+
report(key, throwFinding(action, verdict.threw));
|
|
7516
|
+
continue;
|
|
7517
|
+
}
|
|
7518
|
+
for (const issue of verdict.issues)
|
|
7519
|
+
report(key, rejectionFinding(action, issue, "add", written));
|
|
7520
|
+
}
|
|
7521
|
+
}
|
|
7522
|
+
}
|
|
7523
|
+
return findings;
|
|
7524
|
+
}
|
|
7525
|
+
var CONFIG_FILE2 = "src/content.config.ts", toWriteModelField = (field) => ({ name: field.name, type: field.type, hidden: field.layout?.hidden }), errorText = (error) => error instanceof Error ? error.message : String(error), throwFinding = (action, threw) => ({
|
|
7526
|
+
severity: "error",
|
|
7527
|
+
code: "cms/empty-write",
|
|
7528
|
+
file: CONFIG_FILE2,
|
|
7529
|
+
message: `${action} produces a write the schema throws on: ${threw}`,
|
|
7530
|
+
hint: "A schema that throws instead of returning an issue is usually a refinement reading a field this write does not carry. Guard it against a missing value \u2014 `astro sync` runs the same schema over the same record."
|
|
7531
|
+
});
|
|
7532
|
+
var init_check_write = __esm(() => {
|
|
7533
|
+
init_check_entries();
|
|
7534
|
+
init_editor_write_model();
|
|
7535
|
+
init_schema_probe();
|
|
7536
|
+
});
|
|
7537
|
+
|
|
7014
7538
|
// ../../node_modules/@babel/parser/lib/index.js
|
|
7015
7539
|
var require_lib = __commonJS((exports) => {
|
|
7016
7540
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -21794,40 +22318,16 @@ var require_lib = __commonJS((exports) => {
|
|
|
21794
22318
|
exports.tokTypes = tokTypes;
|
|
21795
22319
|
});
|
|
21796
22320
|
|
|
21797
|
-
// ../cms-types/src/index.ts
|
|
21798
|
-
function isFieldType(value) {
|
|
21799
|
-
return FIELD_TYPES.includes(value);
|
|
21800
|
-
}
|
|
21801
|
-
var FIELD_TYPES;
|
|
21802
|
-
var init_src = __esm(() => {
|
|
21803
|
-
FIELD_TYPES = [
|
|
21804
|
-
"text",
|
|
21805
|
-
"textarea",
|
|
21806
|
-
"markdown",
|
|
21807
|
-
"date",
|
|
21808
|
-
"datetime",
|
|
21809
|
-
"time",
|
|
21810
|
-
"year",
|
|
21811
|
-
"month",
|
|
21812
|
-
"boolean",
|
|
21813
|
-
"number",
|
|
21814
|
-
"image",
|
|
21815
|
-
"file",
|
|
21816
|
-
"url",
|
|
21817
|
-
"email",
|
|
21818
|
-
"tel",
|
|
21819
|
-
"color",
|
|
21820
|
-
"select",
|
|
21821
|
-
"array",
|
|
21822
|
-
"object",
|
|
21823
|
-
"reference"
|
|
21824
|
-
];
|
|
21825
|
-
});
|
|
21826
|
-
|
|
21827
22321
|
// ../cms-core/src/content-config-ast.ts
|
|
21828
22322
|
function resolveExpression(node, bindings, visited = new Set) {
|
|
21829
22323
|
let current = node;
|
|
21830
|
-
|
|
22324
|
+
for (;; ) {
|
|
22325
|
+
if (current.type === "TSAsExpression" || current.type === "TSSatisfiesExpression" || current.type === "TSNonNullExpression" || current.type === "TSTypeAssertion") {
|
|
22326
|
+
current = current.expression;
|
|
22327
|
+
continue;
|
|
22328
|
+
}
|
|
22329
|
+
if (current.type !== "Identifier")
|
|
22330
|
+
return current;
|
|
21831
22331
|
if (visited.has(current.name))
|
|
21832
22332
|
return current;
|
|
21833
22333
|
visited.add(current.name);
|
|
@@ -21836,7 +22336,80 @@ function resolveExpression(node, bindings, visited = new Set) {
|
|
|
21836
22336
|
return current;
|
|
21837
22337
|
current = next;
|
|
21838
22338
|
}
|
|
21839
|
-
|
|
22339
|
+
}
|
|
22340
|
+
function isAstNode(value) {
|
|
22341
|
+
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
22342
|
+
}
|
|
22343
|
+
function walkNodes(node, visit) {
|
|
22344
|
+
visit(node);
|
|
22345
|
+
const children = Object.values(node);
|
|
22346
|
+
for (const child of children) {
|
|
22347
|
+
if (Array.isArray(child)) {
|
|
22348
|
+
for (const item of child) {
|
|
22349
|
+
if (isAstNode(item))
|
|
22350
|
+
walkNodes(item, visit);
|
|
22351
|
+
}
|
|
22352
|
+
} else if (isAstNode(child)) {
|
|
22353
|
+
walkNodes(child, visit);
|
|
22354
|
+
}
|
|
22355
|
+
}
|
|
22356
|
+
}
|
|
22357
|
+
function declaredPatternNames(node, record) {
|
|
22358
|
+
switch (node.type) {
|
|
22359
|
+
case "Identifier":
|
|
22360
|
+
record(node.name);
|
|
22361
|
+
return;
|
|
22362
|
+
case "ObjectPattern":
|
|
22363
|
+
for (const prop of node.properties)
|
|
22364
|
+
declaredPatternNames(prop.type === "RestElement" ? prop.argument : prop.value, record);
|
|
22365
|
+
return;
|
|
22366
|
+
case "ArrayPattern":
|
|
22367
|
+
for (const el of node.elements) {
|
|
22368
|
+
if (el)
|
|
22369
|
+
declaredPatternNames(el, record);
|
|
22370
|
+
}
|
|
22371
|
+
return;
|
|
22372
|
+
case "AssignmentPattern":
|
|
22373
|
+
declaredPatternNames(node.left, record);
|
|
22374
|
+
return;
|
|
22375
|
+
case "RestElement":
|
|
22376
|
+
declaredPatternNames(node.argument, record);
|
|
22377
|
+
return;
|
|
22378
|
+
}
|
|
22379
|
+
}
|
|
22380
|
+
function shadowedNames(ast) {
|
|
22381
|
+
const seen = new Set;
|
|
22382
|
+
const shadowed = new Set;
|
|
22383
|
+
const record = (name) => {
|
|
22384
|
+
if (seen.has(name))
|
|
22385
|
+
shadowed.add(name);
|
|
22386
|
+
seen.add(name);
|
|
22387
|
+
};
|
|
22388
|
+
walkNodes(ast, (node) => {
|
|
22389
|
+
switch (node.type) {
|
|
22390
|
+
case "VariableDeclarator":
|
|
22391
|
+
declaredPatternNames(node.id, record);
|
|
22392
|
+
return;
|
|
22393
|
+
case "FunctionDeclaration":
|
|
22394
|
+
case "FunctionExpression":
|
|
22395
|
+
case "ArrowFunctionExpression":
|
|
22396
|
+
for (const param of node.params)
|
|
22397
|
+
declaredPatternNames(param, record);
|
|
22398
|
+
if (node.type !== "ArrowFunctionExpression" && node.id)
|
|
22399
|
+
record(node.id.name);
|
|
22400
|
+
return;
|
|
22401
|
+
case "ClassDeclaration":
|
|
22402
|
+
if (node.id)
|
|
22403
|
+
record(node.id.name);
|
|
22404
|
+
return;
|
|
22405
|
+
case "ImportSpecifier":
|
|
22406
|
+
case "ImportDefaultSpecifier":
|
|
22407
|
+
case "ImportNamespaceSpecifier":
|
|
22408
|
+
record(node.local.name);
|
|
22409
|
+
return;
|
|
22410
|
+
}
|
|
22411
|
+
});
|
|
22412
|
+
return shadowed;
|
|
21840
22413
|
}
|
|
21841
22414
|
function parseSource(source) {
|
|
21842
22415
|
try {
|
|
@@ -21916,6 +22489,8 @@ function parseConfigSource(source, _sourcePath) {
|
|
|
21916
22489
|
}
|
|
21917
22490
|
}
|
|
21918
22491
|
}
|
|
22492
|
+
for (const name of shadowedNames(ast))
|
|
22493
|
+
bindings.delete(name);
|
|
21919
22494
|
const collectionObjects = new Map(inlineCollections);
|
|
21920
22495
|
for (const [varName, collectionName] of exportMap) {
|
|
21921
22496
|
const decl = collectionDecls.get(varName);
|
|
@@ -21974,6 +22549,7 @@ function parseConfigSource(source, _sourcePath) {
|
|
|
21974
22549
|
result.set(collectionName, {
|
|
21975
22550
|
name: collectionName,
|
|
21976
22551
|
fields: parseSchemaFields(schemaObject, bindings),
|
|
22552
|
+
...hasSkippedMembers(schemaObject) ? { partialFields: true } : {},
|
|
21977
22553
|
loaderPattern,
|
|
21978
22554
|
loaderBase,
|
|
21979
22555
|
layout,
|
|
@@ -22032,6 +22608,15 @@ function parseLayoutSection(node) {
|
|
|
22032
22608
|
return null;
|
|
22033
22609
|
return collapsed ? { title, fields, collapsed } : { title, fields };
|
|
22034
22610
|
}
|
|
22611
|
+
function readEnumOptions(node) {
|
|
22612
|
+
const options = [];
|
|
22613
|
+
for (const el of node.elements) {
|
|
22614
|
+
if (el?.type !== "StringLiteral")
|
|
22615
|
+
return null;
|
|
22616
|
+
options.push(el.value);
|
|
22617
|
+
}
|
|
22618
|
+
return options.length > 0 ? options : null;
|
|
22619
|
+
}
|
|
22035
22620
|
function stringArray(node) {
|
|
22036
22621
|
const out = [];
|
|
22037
22622
|
for (const el of node.elements) {
|
|
@@ -22218,7 +22803,10 @@ function parseSchemaFields(schemaObject, bindings) {
|
|
|
22218
22803
|
}
|
|
22219
22804
|
return fields;
|
|
22220
22805
|
}
|
|
22221
|
-
function
|
|
22806
|
+
function hasSkippedMembers(schemaObject) {
|
|
22807
|
+
return schemaObject.properties.some((prop) => prop.type !== "ObjectProperty" || !propertyKeyName(prop.key));
|
|
22808
|
+
}
|
|
22809
|
+
function analyzeFieldExpression(node, field, bindings, helpers = new Set) {
|
|
22222
22810
|
let current = resolveExpression(node, bindings);
|
|
22223
22811
|
while (current) {
|
|
22224
22812
|
if (current.type !== "CallExpression")
|
|
@@ -22227,10 +22815,30 @@ function analyzeFieldExpression(node, field, bindings) {
|
|
|
22227
22815
|
analyzeBaseCall(current, field, bindings);
|
|
22228
22816
|
return;
|
|
22229
22817
|
}
|
|
22818
|
+
if (current.callee.type === "Identifier") {
|
|
22819
|
+
const returned = sameFileHelperReturn(current, bindings, helpers);
|
|
22820
|
+
if (returned)
|
|
22821
|
+
analyzeFieldExpression(returned, field, bindings, helpers);
|
|
22822
|
+
return;
|
|
22823
|
+
}
|
|
22230
22824
|
if (current.callee.type !== "MemberExpression")
|
|
22231
22825
|
return;
|
|
22232
22826
|
const property = current.callee.property;
|
|
22233
22827
|
const methodName = property.type === "Identifier" ? property.name : "";
|
|
22828
|
+
if (methodName === "array") {
|
|
22829
|
+
const item = { name: "__item__", required: true };
|
|
22830
|
+
analyzeFieldExpression(current.callee.object, item, bindings, helpers);
|
|
22831
|
+
if (item.reference) {
|
|
22832
|
+
field.reference = { target: item.reference.target, isArray: true };
|
|
22833
|
+
return;
|
|
22834
|
+
}
|
|
22835
|
+
field.type = "array";
|
|
22836
|
+
if (item.type)
|
|
22837
|
+
field.itemType = item.type;
|
|
22838
|
+
if (item.fields)
|
|
22839
|
+
field.fields = item.fields;
|
|
22840
|
+
return;
|
|
22841
|
+
}
|
|
22234
22842
|
if (WRAPPER_METHODS.has(methodName)) {
|
|
22235
22843
|
field.required = false;
|
|
22236
22844
|
} else if (methodName === "orderBy") {
|
|
@@ -22241,6 +22849,25 @@ function analyzeFieldExpression(node, field, bindings) {
|
|
|
22241
22849
|
current = resolveExpression(current.callee.object, bindings);
|
|
22242
22850
|
}
|
|
22243
22851
|
}
|
|
22852
|
+
function sameFileHelperReturn(call, bindings, seen) {
|
|
22853
|
+
if (call.callee.type !== "Identifier" || call.arguments.length > 0)
|
|
22854
|
+
return null;
|
|
22855
|
+
if (seen.has(call.callee.name))
|
|
22856
|
+
return null;
|
|
22857
|
+
seen.add(call.callee.name);
|
|
22858
|
+
const fn = resolveExpression(call.callee, bindings);
|
|
22859
|
+
if (fn.type !== "ArrowFunctionExpression" && fn.type !== "FunctionExpression")
|
|
22860
|
+
return null;
|
|
22861
|
+
if (fn.params.length > 0)
|
|
22862
|
+
return null;
|
|
22863
|
+
if (fn.body.type !== "BlockStatement")
|
|
22864
|
+
return fn.body;
|
|
22865
|
+
for (const stmt of fn.body.body) {
|
|
22866
|
+
if (stmt.type === "ReturnStatement" && stmt.argument)
|
|
22867
|
+
return stmt.argument;
|
|
22868
|
+
}
|
|
22869
|
+
return null;
|
|
22870
|
+
}
|
|
22244
22871
|
function isBaseCall(node) {
|
|
22245
22872
|
const callee = node.callee;
|
|
22246
22873
|
if (callee.type === "Identifier") {
|
|
@@ -22287,18 +22914,16 @@ function analyzeBaseCall(node, field, bindings) {
|
|
|
22287
22914
|
}
|
|
22288
22915
|
return;
|
|
22289
22916
|
}
|
|
22917
|
+
if ((ns === "z" || ns === "n") && fn === "boolean") {
|
|
22918
|
+
field.type = "boolean";
|
|
22919
|
+
return;
|
|
22920
|
+
}
|
|
22290
22921
|
if ((ns === "z" || ns === "n") && fn === "enum") {
|
|
22291
|
-
const arg = node.arguments[0];
|
|
22292
|
-
|
|
22293
|
-
|
|
22294
|
-
|
|
22295
|
-
|
|
22296
|
-
options.push(el.value);
|
|
22297
|
-
}
|
|
22298
|
-
if (options.length > 0) {
|
|
22299
|
-
field.type = "select";
|
|
22300
|
-
field.options = options;
|
|
22301
|
-
}
|
|
22922
|
+
const arg = node.arguments[0] ? resolveExpression(node.arguments[0], bindings) : undefined;
|
|
22923
|
+
const options = arg?.type === "ArrayExpression" ? readEnumOptions(arg) : null;
|
|
22924
|
+
if (options) {
|
|
22925
|
+
field.type = "select";
|
|
22926
|
+
field.options = options;
|
|
22302
22927
|
}
|
|
22303
22928
|
const hintsArg = node.arguments[1];
|
|
22304
22929
|
if (hintsArg?.type === "ObjectExpression") {
|
|
@@ -22459,11 +23084,44 @@ var init_content_config_ast = __esm(() => {
|
|
|
22459
23084
|
WRAPPER_METHODS = new Set(["optional", "nullable", "nullish", "default"]);
|
|
22460
23085
|
});
|
|
22461
23086
|
|
|
22462
|
-
// ../cms-core/src/
|
|
22463
|
-
|
|
22464
|
-
|
|
22465
|
-
|
|
23087
|
+
// ../cms-core/src/shared.ts
|
|
23088
|
+
function pathSegmentValue(raw) {
|
|
23089
|
+
if (typeof raw === "string")
|
|
23090
|
+
return raw;
|
|
23091
|
+
if (typeof raw === "number" || typeof raw === "boolean")
|
|
23092
|
+
return String(raw);
|
|
23093
|
+
if (raw instanceof Date)
|
|
23094
|
+
return raw.toISOString().slice(0, 10);
|
|
23095
|
+
return;
|
|
22466
23096
|
}
|
|
23097
|
+
function computePathnameFromSpec(spec, data) {
|
|
23098
|
+
const segments = [];
|
|
23099
|
+
for (const seg of spec) {
|
|
23100
|
+
if ("literal" in seg) {
|
|
23101
|
+
segments.push(seg.literal);
|
|
23102
|
+
continue;
|
|
23103
|
+
}
|
|
23104
|
+
const value = pathSegmentValue(data[seg.field]);
|
|
23105
|
+
if (value === undefined)
|
|
23106
|
+
return;
|
|
23107
|
+
segments.push(seg.map && Object.hasOwn(seg.map, value) ? seg.map[value] : value);
|
|
23108
|
+
}
|
|
23109
|
+
const path2 = ("/" + segments.join("/")).replace(/\/{2,}/g, "/").replace(/\/+$/, "");
|
|
23110
|
+
return path2 === "" ? "/" : path2;
|
|
23111
|
+
}
|
|
23112
|
+
function resolvePathnameFromSpec(def, data) {
|
|
23113
|
+
if (!def.pathname)
|
|
23114
|
+
return;
|
|
23115
|
+
return computePathnameFromSpec(def.pathname, data ?? {});
|
|
23116
|
+
}
|
|
23117
|
+
function slugifyHref(text) {
|
|
23118
|
+
return "/" + text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
|
|
23119
|
+
}
|
|
23120
|
+
var init_shared = __esm(() => {
|
|
23121
|
+
init_src();
|
|
23122
|
+
});
|
|
23123
|
+
|
|
23124
|
+
// ../cms-core/src/check.ts
|
|
22467
23125
|
function typeMismatch(field, value) {
|
|
22468
23126
|
switch (field.type) {
|
|
22469
23127
|
case "number":
|
|
@@ -22505,40 +23163,86 @@ function typeMismatch(field, value) {
|
|
|
22505
23163
|
return null;
|
|
22506
23164
|
}
|
|
22507
23165
|
}
|
|
22508
|
-
|
|
22509
|
-
|
|
22510
|
-
|
|
22511
|
-
|
|
23166
|
+
function projectAssetPath(value) {
|
|
23167
|
+
if (value === "" || value.startsWith("//"))
|
|
23168
|
+
return null;
|
|
23169
|
+
if (/^[a-z][a-z\d+\-.]*:/i.test(value))
|
|
23170
|
+
return null;
|
|
23171
|
+
if (/^[~@#]/.test(value))
|
|
23172
|
+
return null;
|
|
23173
|
+
const withoutQuery = value.split(/[?#]/)[0] ?? "";
|
|
23174
|
+
return withoutQuery === "" ? null : withoutQuery;
|
|
22512
23175
|
}
|
|
22513
|
-
function
|
|
22514
|
-
const
|
|
22515
|
-
|
|
22516
|
-
|
|
22517
|
-
|
|
22518
|
-
|
|
22519
|
-
|
|
22520
|
-
|
|
22521
|
-
|
|
23176
|
+
async function checkAssets(fs, fields, data, file, prefix, findings) {
|
|
23177
|
+
for (const field of fields) {
|
|
23178
|
+
const value = data[field.name];
|
|
23179
|
+
if (value === undefined || value === null)
|
|
23180
|
+
continue;
|
|
23181
|
+
const label = prefix === "" ? field.name : `${prefix}.${field.name}`;
|
|
23182
|
+
if (field.type === "object" && field.fields && isPlainObject(value)) {
|
|
23183
|
+
await checkAssets(fs, field.fields, value, file, label, findings);
|
|
23184
|
+
continue;
|
|
23185
|
+
}
|
|
23186
|
+
if (field.type === "array" && field.itemType === "object" && field.fields && Array.isArray(value)) {
|
|
23187
|
+
for (const [index, item] of value.entries()) {
|
|
23188
|
+
if (isPlainObject(item))
|
|
23189
|
+
await checkAssets(fs, field.fields, item, file, `${label}[${index}]`, findings);
|
|
23190
|
+
}
|
|
23191
|
+
continue;
|
|
23192
|
+
}
|
|
23193
|
+
if (field.type !== "image" || typeof value !== "string")
|
|
23194
|
+
continue;
|
|
23195
|
+
const assetPath = projectAssetPath(value);
|
|
23196
|
+
if (assetPath === null)
|
|
23197
|
+
continue;
|
|
23198
|
+
const candidates = resolveAssetCandidates(assetBaseDir(file), assetPath);
|
|
23199
|
+
if (candidates.length === 0)
|
|
23200
|
+
continue;
|
|
23201
|
+
let found = false;
|
|
23202
|
+
for (const candidate of candidates) {
|
|
23203
|
+
if (await fs.exists(candidate)) {
|
|
23204
|
+
found = true;
|
|
23205
|
+
break;
|
|
23206
|
+
}
|
|
22522
23207
|
}
|
|
23208
|
+
if (found)
|
|
23209
|
+
continue;
|
|
23210
|
+
findings.push({
|
|
23211
|
+
severity: "warning",
|
|
23212
|
+
code: "entry/missing-asset",
|
|
23213
|
+
file,
|
|
23214
|
+
field: label,
|
|
23215
|
+
message: `${label}: "${value}" points at no file (tried ${candidates.join(", ")}).`
|
|
23216
|
+
});
|
|
22523
23217
|
}
|
|
22524
|
-
|
|
22525
|
-
|
|
22526
|
-
|
|
22527
|
-
|
|
22528
|
-
|
|
22529
|
-
const
|
|
22530
|
-
|
|
22531
|
-
|
|
22532
|
-
|
|
22533
|
-
const
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22537
|
-
|
|
22538
|
-
|
|
23218
|
+
}
|
|
23219
|
+
function pathnameCollisions(collection, entries) {
|
|
23220
|
+
if (!collection.pathname)
|
|
23221
|
+
return [];
|
|
23222
|
+
const findings = [];
|
|
23223
|
+
const firstAt = new Map;
|
|
23224
|
+
for (const entry of entries) {
|
|
23225
|
+
if (!entry.frontmatter)
|
|
23226
|
+
continue;
|
|
23227
|
+
const pathname = computePathnameFromSpec(collection.pathname, entry.frontmatter);
|
|
23228
|
+
if (pathname === undefined)
|
|
23229
|
+
continue;
|
|
23230
|
+
const first = firstAt.get(pathname);
|
|
23231
|
+
if (!first) {
|
|
23232
|
+
firstAt.set(pathname, entry);
|
|
23233
|
+
continue;
|
|
23234
|
+
}
|
|
23235
|
+
findings.push({
|
|
23236
|
+
severity: "warning",
|
|
23237
|
+
code: "entry/pathname-collision",
|
|
23238
|
+
file: entry.file,
|
|
23239
|
+
field: collection.name,
|
|
23240
|
+
message: `The pathname rule maps this entry and ${first.file} to ${pathname} \u2014 they collide on one page.`
|
|
23241
|
+
});
|
|
22539
23242
|
}
|
|
23243
|
+
return findings;
|
|
22540
23244
|
}
|
|
22541
|
-
async function checkContent(fs) {
|
|
23245
|
+
async function checkContent(fs, options = {}) {
|
|
22542
23246
|
const findings = [];
|
|
22543
23247
|
const config = await parseContentConfig(fs, new Map);
|
|
22544
23248
|
if (config.size === 0) {
|
|
@@ -22550,51 +23254,47 @@ async function checkContent(fs) {
|
|
|
22550
23254
|
});
|
|
22551
23255
|
return { findings, collections: 0, entries: 0 };
|
|
22552
23256
|
}
|
|
22553
|
-
const
|
|
22554
|
-
const files = new Map;
|
|
23257
|
+
const collections = await loadCollections(fs, config);
|
|
22555
23258
|
const stems = new Map;
|
|
22556
|
-
for (const [name,
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
if (!await fs.exists(base)) {
|
|
23259
|
+
for (const [name, loaded] of collections) {
|
|
23260
|
+
stems.set(name, new Set(loaded.entries.map((entry) => entry.stem)));
|
|
23261
|
+
if (!loaded.exists) {
|
|
22560
23262
|
findings.push({
|
|
22561
23263
|
severity: "error",
|
|
22562
23264
|
code: "config/missing-dir",
|
|
22563
23265
|
file: "src/content.config.ts",
|
|
22564
23266
|
field: name,
|
|
22565
|
-
message: `Collection "${name}" loads from ${base}/, which does not exist.`
|
|
23267
|
+
message: `Collection "${name}" loads from ${loaded.base}/, which does not exist.`
|
|
22566
23268
|
});
|
|
22567
|
-
files.set(name, []);
|
|
22568
|
-
stems.set(name, new Set);
|
|
22569
23269
|
continue;
|
|
22570
23270
|
}
|
|
22571
|
-
|
|
22572
|
-
files.set(name, collectionFiles);
|
|
22573
|
-
stems.set(name, new Set(collectionFiles.map(entryStem)));
|
|
22574
|
-
if (collectionFiles.length === 0) {
|
|
23271
|
+
if (loaded.entries.length === 0) {
|
|
22575
23272
|
findings.push({
|
|
22576
23273
|
severity: "warning",
|
|
22577
23274
|
code: "config/empty-collection",
|
|
22578
|
-
file: base,
|
|
23275
|
+
file: loaded.base,
|
|
22579
23276
|
field: name,
|
|
22580
|
-
message: `Collection "${name}" matched no entries under ${base}/.`
|
|
23277
|
+
message: `Collection "${name}" matched no entries under ${loaded.base}/.`
|
|
22581
23278
|
});
|
|
22582
23279
|
}
|
|
22583
23280
|
}
|
|
22584
23281
|
let entries = 0;
|
|
22585
23282
|
for (const [name, collection] of config) {
|
|
22586
23283
|
const typedFields = collection.fields.filter((field) => field.type !== undefined || field.required || field.reference);
|
|
22587
|
-
|
|
23284
|
+
const declared = new Set(collection.fields.map((field) => field.name));
|
|
23285
|
+
const loadedEntries = collections.get(name)?.entries ?? [];
|
|
23286
|
+
const schemaJudgesEntries = options.schemas !== undefined && schemaFor(options.schemas, name) !== undefined;
|
|
23287
|
+
for (const entry of loadedEntries) {
|
|
22588
23288
|
entries++;
|
|
22589
|
-
const
|
|
22590
|
-
if (
|
|
22591
|
-
findings.push({ severity: "error", code: "entry/syntax", file, message: `Frontmatter does not parse: ${
|
|
23289
|
+
const file = entry.file;
|
|
23290
|
+
if (entry.frontmatter === undefined) {
|
|
23291
|
+
findings.push({ severity: "error", code: "entry/syntax", file, message: `Frontmatter does not parse: ${entry.parseError}` });
|
|
22592
23292
|
continue;
|
|
22593
23293
|
}
|
|
22594
23294
|
for (const field of typedFields) {
|
|
22595
|
-
const value =
|
|
23295
|
+
const value = entry.frontmatter[field.name];
|
|
22596
23296
|
if (value === undefined || value === null) {
|
|
22597
|
-
if (field.required) {
|
|
23297
|
+
if (field.required && !schemaJudgesEntries) {
|
|
22598
23298
|
findings.push({
|
|
22599
23299
|
severity: "error",
|
|
22600
23300
|
code: "entry/missing-required",
|
|
@@ -22605,7 +23305,7 @@ async function checkContent(fs) {
|
|
|
22605
23305
|
}
|
|
22606
23306
|
continue;
|
|
22607
23307
|
}
|
|
22608
|
-
const mismatch = field.type === undefined ? null : typeMismatch(field, value);
|
|
23308
|
+
const mismatch = field.type === undefined || schemaJudgesEntries ? null : typeMismatch(field, value);
|
|
22609
23309
|
if (mismatch) {
|
|
22610
23310
|
findings.push({ severity: "error", code: "entry/field-type", file, field: field.name, message: `${field.name}: ${mismatch}` });
|
|
22611
23311
|
continue;
|
|
@@ -22629,7 +23329,26 @@ async function checkContent(fs) {
|
|
|
22629
23329
|
});
|
|
22630
23330
|
}
|
|
22631
23331
|
}
|
|
23332
|
+
await checkAssets(fs, collection.fields, entry.frontmatter, file, "", findings);
|
|
23333
|
+
if (declared.size > 0 && !collection.partialFields) {
|
|
23334
|
+
for (const key of Object.keys(entry.frontmatter)) {
|
|
23335
|
+
if (declared.has(key))
|
|
23336
|
+
continue;
|
|
23337
|
+
findings.push({
|
|
23338
|
+
severity: "warning",
|
|
23339
|
+
code: "entry/unknown-key",
|
|
23340
|
+
file,
|
|
23341
|
+
field: key,
|
|
23342
|
+
message: `"${key}" is not a field of "${name}" \u2014 nothing reads it.`
|
|
23343
|
+
});
|
|
23344
|
+
}
|
|
23345
|
+
}
|
|
22632
23346
|
}
|
|
23347
|
+
findings.push(...pathnameCollisions(collection, loadedEntries));
|
|
23348
|
+
}
|
|
23349
|
+
if (options.schemas) {
|
|
23350
|
+
const input = { config, collections, schemas: options.schemas };
|
|
23351
|
+
findings.push(...await checkAgainstSchemas(input), ...await checkEditorWrites(input), ...await checkFieldShapes(input));
|
|
22633
23352
|
}
|
|
22634
23353
|
return { findings, collections: config.size, entries };
|
|
22635
23354
|
}
|
|
@@ -22647,14 +23366,19 @@ function formatCheckReport(report) {
|
|
|
22647
23366
|
const lines = [];
|
|
22648
23367
|
for (const [file, findings] of byFile) {
|
|
22649
23368
|
lines.push(file);
|
|
23369
|
+
let lastHint;
|
|
22650
23370
|
for (const finding of findings) {
|
|
22651
|
-
|
|
23371
|
+
const at = finding.line === undefined ? "" : `${finding.line}:${finding.column ?? 0}`;
|
|
23372
|
+
lines.push(` ${at.padEnd(8)}${(finding.severity === "error" ? "error" : "warn").padEnd(6)} ${finding.message} [${finding.code}]`);
|
|
23373
|
+
if (finding.hint !== undefined && finding.hint !== lastHint)
|
|
23374
|
+
lines.push(` ${" ".repeat(14)}\u2192 ${finding.hint}`);
|
|
23375
|
+
lastHint = finding.hint;
|
|
22652
23376
|
}
|
|
22653
23377
|
}
|
|
22654
23378
|
return lines.join(`
|
|
22655
23379
|
`);
|
|
22656
23380
|
}
|
|
22657
|
-
var
|
|
23381
|
+
var typeName = (value) => {
|
|
22658
23382
|
if (value === null)
|
|
22659
23383
|
return "null";
|
|
22660
23384
|
if (Array.isArray(value))
|
|
@@ -22664,45 +23388,14 @@ var import_yaml, DATA_EXTENSIONS, normalizeBase = (base) => path.normalize(base)
|
|
|
22664
23388
|
return typeof value;
|
|
22665
23389
|
};
|
|
22666
23390
|
var init_check = __esm(() => {
|
|
23391
|
+
init_check_entries();
|
|
23392
|
+
init_check_live();
|
|
23393
|
+
init_check_shape();
|
|
23394
|
+
init_check_write();
|
|
22667
23395
|
init_content_config_ast();
|
|
22668
|
-
|
|
22669
|
-
DATA_EXTENSIONS = new Set([".json", ".yaml", ".yml"]);
|
|
23396
|
+
init_shared();
|
|
22670
23397
|
});
|
|
22671
23398
|
|
|
22672
|
-
// ../cms-core/src/shared.ts
|
|
22673
|
-
function pathSegmentValue(raw) {
|
|
22674
|
-
if (typeof raw === "string")
|
|
22675
|
-
return raw;
|
|
22676
|
-
if (typeof raw === "number" || typeof raw === "boolean")
|
|
22677
|
-
return String(raw);
|
|
22678
|
-
if (raw instanceof Date)
|
|
22679
|
-
return raw.toISOString().slice(0, 10);
|
|
22680
|
-
return;
|
|
22681
|
-
}
|
|
22682
|
-
function computePathnameFromSpec(spec, data) {
|
|
22683
|
-
const segments = [];
|
|
22684
|
-
for (const seg of spec) {
|
|
22685
|
-
if ("literal" in seg) {
|
|
22686
|
-
segments.push(seg.literal);
|
|
22687
|
-
continue;
|
|
22688
|
-
}
|
|
22689
|
-
const value = pathSegmentValue(data[seg.field]);
|
|
22690
|
-
if (value === undefined)
|
|
22691
|
-
return;
|
|
22692
|
-
segments.push(seg.map && Object.hasOwn(seg.map, value) ? seg.map[value] : value);
|
|
22693
|
-
}
|
|
22694
|
-
const path2 = ("/" + segments.join("/")).replace(/\/{2,}/g, "/").replace(/\/+$/, "");
|
|
22695
|
-
return path2 === "" ? "/" : path2;
|
|
22696
|
-
}
|
|
22697
|
-
function resolvePathnameFromSpec(def, data) {
|
|
22698
|
-
if (!def.pathname)
|
|
22699
|
-
return;
|
|
22700
|
-
return computePathnameFromSpec(def.pathname, data ?? {});
|
|
22701
|
-
}
|
|
22702
|
-
function slugifyHref(text) {
|
|
22703
|
-
return "/" + text.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_]+/g, "-").replace(/^-+|-+$/g, "");
|
|
22704
|
-
}
|
|
22705
|
-
|
|
22706
23399
|
// ../cms-core/src/collection-scanner.ts
|
|
22707
23400
|
import path2 from "path";
|
|
22708
23401
|
function normalizeFieldName(name) {
|
|
@@ -23495,6 +24188,7 @@ function warnOnPathnameCollisions(collections) {
|
|
|
23495
24188
|
var import_yaml2, DATE_PATTERN, URL_PATTERN, IMAGE_EXTENSIONS, MAX_SELECT_OPTIONS = 10, TEXTAREA_MIN_LENGTH = 200, SIDEBAR_FIELD_NAMES, DIRECTIVE_PATTERN, FREE_TEXT_FIELD_NAMES, PUBLISH_TOGGLE_NAMES, PUBLISH_DATE_NAMES, TITLE_FALLBACK_FIELDS, FRONTMATTER_PATTERN, MAX_NESTED_FIELD_DEPTH = 16, HREF_SUFFIXES, WHOLE_DIRECTORY_PATTERN;
|
|
23496
24189
|
var init_collection_scanner = __esm(() => {
|
|
23497
24190
|
init_content_config_ast();
|
|
24191
|
+
init_shared();
|
|
23498
24192
|
import_yaml2 = __toESM(require_dist(), 1);
|
|
23499
24193
|
DATE_PATTERN = /^\d{4}-\d{2}-\d{2}/;
|
|
23500
24194
|
URL_PATTERN = /^(https?:\/\/|\/)/;
|
|
@@ -23574,12 +24268,16 @@ var import_yaml3;
|
|
|
23574
24268
|
var init_entry_ops = __esm(() => {
|
|
23575
24269
|
init_collection_scanner();
|
|
23576
24270
|
init_content_config_ast();
|
|
24271
|
+
init_editor_write_model();
|
|
23577
24272
|
init_local();
|
|
24273
|
+
init_shared();
|
|
23578
24274
|
import_yaml3 = __toESM(require_dist(), 1);
|
|
23579
24275
|
});
|
|
23580
24276
|
|
|
23581
24277
|
// ../cms-core/src/handlers/page-ops.ts
|
|
23582
|
-
var init_page_ops = () => {
|
|
24278
|
+
var init_page_ops = __esm(() => {
|
|
24279
|
+
init_shared();
|
|
24280
|
+
});
|
|
23583
24281
|
// ../cms-core/src/core.ts
|
|
23584
24282
|
var init_core = __esm(() => {
|
|
23585
24283
|
init_collection_scanner();
|
|
@@ -23816,80 +24514,1160 @@ var init_project_config_ast = __esm(() => {
|
|
|
23816
24514
|
// ../cms-core/src/index.ts
|
|
23817
24515
|
var init_src2 = __esm(() => {
|
|
23818
24516
|
init_check();
|
|
24517
|
+
init_check_entries();
|
|
24518
|
+
init_check_live();
|
|
24519
|
+
init_check_shape();
|
|
24520
|
+
init_check_write();
|
|
23819
24521
|
init_collection_scanner();
|
|
23820
24522
|
init_component_registry();
|
|
23821
24523
|
init_content_config_ast();
|
|
23822
24524
|
init_core();
|
|
24525
|
+
init_editor_write_model();
|
|
23823
24526
|
init_node_fs();
|
|
23824
24527
|
init_entry_ops();
|
|
23825
24528
|
init_media();
|
|
23826
24529
|
init_project_config_ast();
|
|
24530
|
+
init_schema_probe();
|
|
24531
|
+
init_shared();
|
|
24532
|
+
});
|
|
24533
|
+
|
|
24534
|
+
// ../../node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
|
|
24535
|
+
import g from "crypto";
|
|
24536
|
+
import _ from "fs";
|
|
24537
|
+
import { TextDecoder as b, TextEncoder as v } from "util";
|
|
24538
|
+
var y, w, d = class {
|
|
24539
|
+
constructor() {
|
|
24540
|
+
this.argv = ["js"], this.env = {}, this.exit = (t) => {
|
|
24541
|
+
t !== 0 && console.warn("exit code:", t);
|
|
24542
|
+
}, this._exitPromise = new Promise((t) => {
|
|
24543
|
+
this._resolveExitPromise = t;
|
|
24544
|
+
}), this._pendingEvent = null, this._scheduledTimeouts = new Map, this._nextCallbackTimeoutID = 1;
|
|
24545
|
+
let o = (t, e) => {
|
|
24546
|
+
this.mem.setUint32(t + 0, e, true), this.mem.setUint32(t + 4, Math.floor(e / 4294967296), true);
|
|
24547
|
+
}, n = (t) => {
|
|
24548
|
+
let e = this.mem.getUint32(t + 0, true), s = this.mem.getInt32(t + 4, true);
|
|
24549
|
+
return e + s * 4294967296;
|
|
24550
|
+
}, r = (t) => {
|
|
24551
|
+
let e = this.mem.getFloat64(t, true);
|
|
24552
|
+
if (e === 0)
|
|
24553
|
+
return;
|
|
24554
|
+
if (!isNaN(e))
|
|
24555
|
+
return e;
|
|
24556
|
+
let s = this.mem.getUint32(t, true);
|
|
24557
|
+
return this._values[s];
|
|
24558
|
+
}, l = (t, e) => {
|
|
24559
|
+
if (typeof e == "number" && e !== 0) {
|
|
24560
|
+
if (isNaN(e)) {
|
|
24561
|
+
this.mem.setUint32(t + 4, 2146959360, true), this.mem.setUint32(t, 0, true);
|
|
24562
|
+
return;
|
|
24563
|
+
}
|
|
24564
|
+
this.mem.setFloat64(t, e, true);
|
|
24565
|
+
return;
|
|
24566
|
+
}
|
|
24567
|
+
if (e === undefined) {
|
|
24568
|
+
this.mem.setFloat64(t, 0, true);
|
|
24569
|
+
return;
|
|
24570
|
+
}
|
|
24571
|
+
let i = this._ids.get(e);
|
|
24572
|
+
i === undefined && (i = this._idPool.pop(), i === undefined && (i = this._values.length), this._values[i] = e, this._goRefCounts[i] = 0, this._ids.set(e, i)), this._goRefCounts[i]++;
|
|
24573
|
+
let a = 0;
|
|
24574
|
+
switch (typeof e) {
|
|
24575
|
+
case "object":
|
|
24576
|
+
e !== null && (a = 1);
|
|
24577
|
+
break;
|
|
24578
|
+
case "string":
|
|
24579
|
+
a = 2;
|
|
24580
|
+
break;
|
|
24581
|
+
case "symbol":
|
|
24582
|
+
a = 3;
|
|
24583
|
+
break;
|
|
24584
|
+
case "function":
|
|
24585
|
+
a = 4;
|
|
24586
|
+
break;
|
|
24587
|
+
}
|
|
24588
|
+
this.mem.setUint32(t + 4, 2146959360 | a, true), this.mem.setUint32(t, i, true);
|
|
24589
|
+
}, c = (t) => {
|
|
24590
|
+
let e = n(t + 0), s = n(t + 8);
|
|
24591
|
+
return new Uint8Array(this._inst.exports.mem.buffer, e, s);
|
|
24592
|
+
}, f = (t) => {
|
|
24593
|
+
let e = n(t + 0), s = n(t + 8), i = new Array(s);
|
|
24594
|
+
for (let a = 0;a < s; a++)
|
|
24595
|
+
i[a] = r(e + a * 8);
|
|
24596
|
+
return i;
|
|
24597
|
+
}, u = (t) => {
|
|
24598
|
+
let e = n(t + 0), s = n(t + 8);
|
|
24599
|
+
return w.decode(new DataView(this._inst.exports.mem.buffer, e, s));
|
|
24600
|
+
}, h = Date.now() - performance.now();
|
|
24601
|
+
this.importObject = { gojs: { "runtime.wasmExit": (t) => {
|
|
24602
|
+
t >>>= 0;
|
|
24603
|
+
let e = this.mem.getInt32(t + 8, true);
|
|
24604
|
+
this.exited = true, delete this._inst, delete this._values, delete this._goRefCounts, delete this._ids, delete this._idPool, this.exit(e);
|
|
24605
|
+
}, "runtime.wasmWrite": (t) => {
|
|
24606
|
+
t >>>= 0;
|
|
24607
|
+
let e = n(t + 8), s = n(t + 16), i = this.mem.getInt32(t + 24, true);
|
|
24608
|
+
_.writeSync(e, new Uint8Array(this._inst.exports.mem.buffer, s, i));
|
|
24609
|
+
}, "runtime.resetMemoryDataView": (t) => {
|
|
24610
|
+
t >>>= 0, this.mem = new DataView(this._inst.exports.mem.buffer);
|
|
24611
|
+
}, "runtime.nanotime1": (t) => {
|
|
24612
|
+
t >>>= 0, o(t + 8, (h + performance.now()) * 1e6);
|
|
24613
|
+
}, "runtime.walltime": (t) => {
|
|
24614
|
+
t >>>= 0;
|
|
24615
|
+
let e = new Date().getTime();
|
|
24616
|
+
o(t + 8, e / 1000), this.mem.setInt32(t + 16, e % 1000 * 1e6, true);
|
|
24617
|
+
}, "runtime.scheduleTimeoutEvent": (t) => {
|
|
24618
|
+
t >>>= 0;
|
|
24619
|
+
let e = this._nextCallbackTimeoutID;
|
|
24620
|
+
this._nextCallbackTimeoutID++, this._scheduledTimeouts.set(e, setTimeout(() => {
|
|
24621
|
+
for (this._resume();this._scheduledTimeouts.has(e); )
|
|
24622
|
+
console.warn("scheduleTimeoutEvent: missed timeout event"), this._resume();
|
|
24623
|
+
}, n(t + 8) + 1)), this.mem.setInt32(t + 16, e, true);
|
|
24624
|
+
}, "runtime.clearTimeoutEvent": (t) => {
|
|
24625
|
+
t >>>= 0;
|
|
24626
|
+
let e = this.mem.getInt32(t + 8, true);
|
|
24627
|
+
clearTimeout(this._scheduledTimeouts.get(e)), this._scheduledTimeouts.delete(e);
|
|
24628
|
+
}, "runtime.getRandomData": (t) => {
|
|
24629
|
+
t >>>= 0, globalThis.crypto.getRandomValues(c(t + 8));
|
|
24630
|
+
}, "syscall/js.finalizeRef": (t) => {
|
|
24631
|
+
t >>>= 0;
|
|
24632
|
+
let e = this.mem.getUint32(t + 8, true);
|
|
24633
|
+
if (this._goRefCounts[e]--, this._goRefCounts[e] === 0) {
|
|
24634
|
+
let s = this._values[e];
|
|
24635
|
+
this._values[e] = null, this._ids.delete(s), this._idPool.push(e);
|
|
24636
|
+
}
|
|
24637
|
+
}, "syscall/js.stringVal": (t) => {
|
|
24638
|
+
t >>>= 0, l(t + 24, u(t + 8));
|
|
24639
|
+
}, "syscall/js.valueGet": (t) => {
|
|
24640
|
+
t >>>= 0;
|
|
24641
|
+
let e = Reflect.get(r(t + 8), u(t + 16));
|
|
24642
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 32, e);
|
|
24643
|
+
}, "syscall/js.valueSet": (t) => {
|
|
24644
|
+
t >>>= 0, Reflect.set(r(t + 8), u(t + 16), r(t + 32));
|
|
24645
|
+
}, "syscall/js.valueDelete": (t) => {
|
|
24646
|
+
t >>>= 0, Reflect.deleteProperty(r(t + 8), u(t + 16));
|
|
24647
|
+
}, "syscall/js.valueIndex": (t) => {
|
|
24648
|
+
t >>>= 0, l(t + 24, Reflect.get(r(t + 8), n(t + 16)));
|
|
24649
|
+
}, "syscall/js.valueSetIndex": (t) => {
|
|
24650
|
+
t >>>= 0, Reflect.set(r(t + 8), n(t + 16), r(t + 24));
|
|
24651
|
+
}, "syscall/js.valueCall": (t) => {
|
|
24652
|
+
t >>>= 0;
|
|
24653
|
+
try {
|
|
24654
|
+
let e = r(t + 8), s = Reflect.get(e, u(t + 16)), i = f(t + 32), a = Reflect.apply(s, e, i);
|
|
24655
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 56, a), this.mem.setUint8(t + 64, 1);
|
|
24656
|
+
} catch (e) {
|
|
24657
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 56, e), this.mem.setUint8(t + 64, 0);
|
|
24658
|
+
}
|
|
24659
|
+
}, "syscall/js.valueInvoke": (t) => {
|
|
24660
|
+
t >>>= 0;
|
|
24661
|
+
try {
|
|
24662
|
+
let e = r(t + 8), s = f(t + 16), i = Reflect.apply(e, undefined, s);
|
|
24663
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 40, i), this.mem.setUint8(t + 48, 1);
|
|
24664
|
+
} catch (e) {
|
|
24665
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 40, e), this.mem.setUint8(t + 48, 0);
|
|
24666
|
+
}
|
|
24667
|
+
}, "syscall/js.valueNew": (t) => {
|
|
24668
|
+
t >>>= 0;
|
|
24669
|
+
try {
|
|
24670
|
+
let e = r(t + 8), s = f(t + 16), i = Reflect.construct(e, s);
|
|
24671
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 40, i), this.mem.setUint8(t + 48, 1);
|
|
24672
|
+
} catch (e) {
|
|
24673
|
+
t = this._inst.exports.getsp() >>> 0, l(t + 40, e), this.mem.setUint8(t + 48, 0);
|
|
24674
|
+
}
|
|
24675
|
+
}, "syscall/js.valueLength": (t) => {
|
|
24676
|
+
t >>>= 0, o(t + 16, Number.parseInt(r(t + 8).length));
|
|
24677
|
+
}, "syscall/js.valuePrepareString": (t) => {
|
|
24678
|
+
t >>>= 0;
|
|
24679
|
+
let e = y.encode(String(r(t + 8)));
|
|
24680
|
+
l(t + 16, e), o(t + 24, e.length);
|
|
24681
|
+
}, "syscall/js.valueLoadString": (t) => {
|
|
24682
|
+
t >>>= 0;
|
|
24683
|
+
let e = r(t + 8);
|
|
24684
|
+
c(t + 16).set(e);
|
|
24685
|
+
}, "syscall/js.valueInstanceOf": (t) => {
|
|
24686
|
+
t >>>= 0, this.mem.setUint8(t + 24, r(t + 8) instanceof r(t + 16) ? 1 : 0);
|
|
24687
|
+
}, "syscall/js.copyBytesToGo": (t) => {
|
|
24688
|
+
t >>>= 0;
|
|
24689
|
+
let e = c(t + 8), s = r(t + 32);
|
|
24690
|
+
if (!(s instanceof Uint8Array || s instanceof Uint8ClampedArray)) {
|
|
24691
|
+
this.mem.setUint8(t + 48, 0);
|
|
24692
|
+
return;
|
|
24693
|
+
}
|
|
24694
|
+
let i = s.subarray(0, e.length);
|
|
24695
|
+
e.set(i), o(t + 40, i.length), this.mem.setUint8(t + 48, 1);
|
|
24696
|
+
}, "syscall/js.copyBytesToJS": (t) => {
|
|
24697
|
+
t >>>= 0;
|
|
24698
|
+
let e = r(t + 8), s = c(t + 16);
|
|
24699
|
+
if (!(e instanceof Uint8Array || e instanceof Uint8ClampedArray)) {
|
|
24700
|
+
this.mem.setUint8(t + 48, 0);
|
|
24701
|
+
return;
|
|
24702
|
+
}
|
|
24703
|
+
let i = s.subarray(0, e.length);
|
|
24704
|
+
e.set(i), o(t + 40, i.length), this.mem.setUint8(t + 48, 1);
|
|
24705
|
+
}, debug: (t) => {
|
|
24706
|
+
console.log(t);
|
|
24707
|
+
} } };
|
|
24708
|
+
}
|
|
24709
|
+
async run(o) {
|
|
24710
|
+
if (!(o instanceof WebAssembly.Instance))
|
|
24711
|
+
throw new Error("Go.run: WebAssembly.Instance expected");
|
|
24712
|
+
this._inst = o, this.mem = new DataView(this._inst.exports.mem.buffer), this._values = [Number.NaN, 0, null, true, false, globalThis, this], this._goRefCounts = new Array(this._values.length).fill(Number.POSITIVE_INFINITY), this._ids = new Map([[0, 1], [null, 2], [true, 3], [false, 4], [globalThis, 5], [this, 6]]), this._idPool = [], this.exited = false;
|
|
24713
|
+
let n = 4096, r = (h) => {
|
|
24714
|
+
let t = n, e = y.encode(`${h}\x00`);
|
|
24715
|
+
return new Uint8Array(this.mem.buffer, n, e.length).set(e), n += e.length, n % 8 !== 0 && (n += 8 - n % 8), t;
|
|
24716
|
+
}, l = this.argv.length, c = [];
|
|
24717
|
+
this.argv.forEach((h) => {
|
|
24718
|
+
c.push(r(h));
|
|
24719
|
+
}), c.push(0), Object.keys(this.env).sort().forEach((h) => {
|
|
24720
|
+
c.push(r(`${h}=${this.env[h]}`));
|
|
24721
|
+
}), c.push(0);
|
|
24722
|
+
let u = n;
|
|
24723
|
+
c.forEach((h) => {
|
|
24724
|
+
this.mem.setUint32(n, h, true), this.mem.setUint32(n + 4, 0, true), n += 8;
|
|
24725
|
+
}), this._inst.exports.run(l, u), this.exited && this._resolveExitPromise(), await this._exitPromise;
|
|
24726
|
+
}
|
|
24727
|
+
_resume() {
|
|
24728
|
+
if (this.exited)
|
|
24729
|
+
throw new Error("Go program has already exited");
|
|
24730
|
+
this._inst.exports.resume(), this.exited && this._resolveExitPromise();
|
|
24731
|
+
}
|
|
24732
|
+
_makeFuncWrapper(o) {
|
|
24733
|
+
let n = this;
|
|
24734
|
+
return function() {
|
|
24735
|
+
let r = { id: o, this: this, args: arguments };
|
|
24736
|
+
return n._pendingEvent = r, n._resume(), r.result;
|
|
24737
|
+
};
|
|
24738
|
+
}
|
|
24739
|
+
};
|
|
24740
|
+
var init_chunk_W5DTLHV4 = __esm(() => {
|
|
24741
|
+
globalThis.fs || Object.defineProperty(globalThis, "fs", { value: _ });
|
|
24742
|
+
globalThis.process || Object.defineProperties(globalThis, "process", { value: process });
|
|
24743
|
+
globalThis.crypto || Object.defineProperty(globalThis, "crypto", { value: g.webcrypto ? g.webcrypto : { getRandomValues(m) {
|
|
24744
|
+
return g.randomFillSync(m);
|
|
24745
|
+
} } });
|
|
24746
|
+
globalThis.performance || Object.defineProperty(globalThis, "performance", { value: { now() {
|
|
24747
|
+
let [m, o] = process.hrtime();
|
|
24748
|
+
return m * 1000 + o / 1e6;
|
|
24749
|
+
} } });
|
|
24750
|
+
y = new v("utf-8");
|
|
24751
|
+
w = new b("utf-8");
|
|
24752
|
+
});
|
|
24753
|
+
|
|
24754
|
+
// ../../node_modules/@astrojs/compiler/dist/node/index.js
|
|
24755
|
+
import { promises as m } from "fs";
|
|
24756
|
+
import { fileURLToPath as f } from "url";
|
|
24757
|
+
var w2 = async (t, s) => i().then((r) => r.transform(t, s)), n, i = () => (n || (n = d2().catch((t) => {
|
|
24758
|
+
throw n = undefined, t;
|
|
24759
|
+
})), n), y2 = async (t, s) => {
|
|
24760
|
+
let r;
|
|
24761
|
+
return r = await (async () => {
|
|
24762
|
+
let o = await m.readFile(t).then((e) => e.buffer);
|
|
24763
|
+
return WebAssembly.instantiate(new Uint8Array(o), s);
|
|
24764
|
+
})(), r;
|
|
24765
|
+
}, d2 = async () => {
|
|
24766
|
+
let t = new d, s = await y2(f(new URL("../astro.wasm", import.meta.url)), t.importObject);
|
|
24767
|
+
t.run(s.instance);
|
|
24768
|
+
let r = globalThis["@astrojs/compiler"];
|
|
24769
|
+
return { transform: (a, o) => new Promise((e) => {
|
|
24770
|
+
try {
|
|
24771
|
+
e(r.transform(a, o || {}));
|
|
24772
|
+
} catch (p) {
|
|
24773
|
+
throw n = undefined, p;
|
|
24774
|
+
}
|
|
24775
|
+
}), parse: (a, o) => new Promise((e) => e(r.parse(a, o || {}))).catch((e) => {
|
|
24776
|
+
throw n = undefined, e;
|
|
24777
|
+
}).then((e) => ({ ...e, ast: JSON.parse(e.ast) })), convertToTSX: (a, o) => new Promise((e) => e(r.convertToTSX(a, o || {}))).catch((e) => {
|
|
24778
|
+
throw n = undefined, e;
|
|
24779
|
+
}).then((e) => ({ ...e, map: JSON.parse(e.map) })) };
|
|
24780
|
+
};
|
|
24781
|
+
var init_node = __esm(() => {
|
|
24782
|
+
init_chunk_W5DTLHV4();
|
|
24783
|
+
});
|
|
24784
|
+
|
|
24785
|
+
// ../../node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
24786
|
+
function decodeInteger(reader, relative) {
|
|
24787
|
+
let value = 0;
|
|
24788
|
+
let shift = 0;
|
|
24789
|
+
let integer = 0;
|
|
24790
|
+
do {
|
|
24791
|
+
const c = reader.next();
|
|
24792
|
+
integer = charToInt[c];
|
|
24793
|
+
value |= (integer & 31) << shift;
|
|
24794
|
+
shift += 5;
|
|
24795
|
+
} while (integer & 32);
|
|
24796
|
+
const shouldNegate = value & 1;
|
|
24797
|
+
value >>>= 1;
|
|
24798
|
+
if (shouldNegate) {
|
|
24799
|
+
value = -2147483648 | -value;
|
|
24800
|
+
}
|
|
24801
|
+
return relative + value;
|
|
24802
|
+
}
|
|
24803
|
+
function hasMoreVlq(reader, max) {
|
|
24804
|
+
if (reader.pos >= max)
|
|
24805
|
+
return false;
|
|
24806
|
+
return reader.peek() !== comma;
|
|
24807
|
+
}
|
|
24808
|
+
function decode(mappings) {
|
|
24809
|
+
const { length } = mappings;
|
|
24810
|
+
const reader = new StringReader(mappings);
|
|
24811
|
+
const decoded = [];
|
|
24812
|
+
let genColumn = 0;
|
|
24813
|
+
let sourcesIndex = 0;
|
|
24814
|
+
let sourceLine = 0;
|
|
24815
|
+
let sourceColumn = 0;
|
|
24816
|
+
let namesIndex = 0;
|
|
24817
|
+
do {
|
|
24818
|
+
const semi = reader.indexOf(";");
|
|
24819
|
+
const line = [];
|
|
24820
|
+
let sorted = true;
|
|
24821
|
+
let lastCol = 0;
|
|
24822
|
+
genColumn = 0;
|
|
24823
|
+
while (reader.pos < semi) {
|
|
24824
|
+
let seg;
|
|
24825
|
+
genColumn = decodeInteger(reader, genColumn);
|
|
24826
|
+
if (genColumn < lastCol)
|
|
24827
|
+
sorted = false;
|
|
24828
|
+
lastCol = genColumn;
|
|
24829
|
+
if (hasMoreVlq(reader, semi)) {
|
|
24830
|
+
sourcesIndex = decodeInteger(reader, sourcesIndex);
|
|
24831
|
+
sourceLine = decodeInteger(reader, sourceLine);
|
|
24832
|
+
sourceColumn = decodeInteger(reader, sourceColumn);
|
|
24833
|
+
if (hasMoreVlq(reader, semi)) {
|
|
24834
|
+
namesIndex = decodeInteger(reader, namesIndex);
|
|
24835
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
|
|
24836
|
+
} else {
|
|
24837
|
+
seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
|
|
24838
|
+
}
|
|
24839
|
+
} else {
|
|
24840
|
+
seg = [genColumn];
|
|
24841
|
+
}
|
|
24842
|
+
line.push(seg);
|
|
24843
|
+
reader.pos++;
|
|
24844
|
+
}
|
|
24845
|
+
if (!sorted)
|
|
24846
|
+
sort(line);
|
|
24847
|
+
decoded.push(line);
|
|
24848
|
+
reader.pos = semi + 1;
|
|
24849
|
+
} while (reader.pos <= length);
|
|
24850
|
+
return decoded;
|
|
24851
|
+
}
|
|
24852
|
+
function sort(line) {
|
|
24853
|
+
line.sort(sortComparator);
|
|
24854
|
+
}
|
|
24855
|
+
function sortComparator(a, b2) {
|
|
24856
|
+
return a[0] - b2[0];
|
|
24857
|
+
}
|
|
24858
|
+
var comma = 44, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar, charToInt, bufLength, StringReader = class {
|
|
24859
|
+
constructor(buffer) {
|
|
24860
|
+
this.pos = 0;
|
|
24861
|
+
this.buffer = buffer;
|
|
24862
|
+
}
|
|
24863
|
+
next() {
|
|
24864
|
+
return this.buffer.charCodeAt(this.pos++);
|
|
24865
|
+
}
|
|
24866
|
+
peek() {
|
|
24867
|
+
return this.buffer.charCodeAt(this.pos);
|
|
24868
|
+
}
|
|
24869
|
+
indexOf(char) {
|
|
24870
|
+
const { buffer, pos } = this;
|
|
24871
|
+
const idx = buffer.indexOf(char, pos);
|
|
24872
|
+
return idx === -1 ? buffer.length : idx;
|
|
24873
|
+
}
|
|
24874
|
+
};
|
|
24875
|
+
var init_sourcemap_codec = __esm(() => {
|
|
24876
|
+
intToChar = new Uint8Array(64);
|
|
24877
|
+
charToInt = new Uint8Array(128);
|
|
24878
|
+
for (let i2 = 0;i2 < chars.length; i2++) {
|
|
24879
|
+
const c = chars.charCodeAt(i2);
|
|
24880
|
+
intToChar[i2] = c;
|
|
24881
|
+
charToInt[c] = i2;
|
|
24882
|
+
}
|
|
24883
|
+
bufLength = 1024 * 16;
|
|
24884
|
+
});
|
|
24885
|
+
|
|
24886
|
+
// ../../node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
|
|
24887
|
+
function isAbsoluteUrl(input) {
|
|
24888
|
+
return schemeRegex.test(input);
|
|
24889
|
+
}
|
|
24890
|
+
function isSchemeRelativeUrl(input) {
|
|
24891
|
+
return input.startsWith("//");
|
|
24892
|
+
}
|
|
24893
|
+
function isAbsolutePath(input) {
|
|
24894
|
+
return input.startsWith("/");
|
|
24895
|
+
}
|
|
24896
|
+
function isFileUrl(input) {
|
|
24897
|
+
return input.startsWith("file:");
|
|
24898
|
+
}
|
|
24899
|
+
function isRelative(input) {
|
|
24900
|
+
return /^[.?#]/.test(input);
|
|
24901
|
+
}
|
|
24902
|
+
function parseAbsoluteUrl(input) {
|
|
24903
|
+
const match = urlRegex.exec(input);
|
|
24904
|
+
return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
|
|
24905
|
+
}
|
|
24906
|
+
function parseFileUrl(input) {
|
|
24907
|
+
const match = fileRegex.exec(input);
|
|
24908
|
+
const path4 = match[2];
|
|
24909
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path4) ? path4 : "/" + path4, match[3] || "", match[4] || "");
|
|
24910
|
+
}
|
|
24911
|
+
function makeUrl(scheme, user, host, port, path4, query, hash) {
|
|
24912
|
+
return {
|
|
24913
|
+
scheme,
|
|
24914
|
+
user,
|
|
24915
|
+
host,
|
|
24916
|
+
port,
|
|
24917
|
+
path: path4,
|
|
24918
|
+
query,
|
|
24919
|
+
hash,
|
|
24920
|
+
type: 7
|
|
24921
|
+
};
|
|
24922
|
+
}
|
|
24923
|
+
function parseUrl(input) {
|
|
24924
|
+
if (isSchemeRelativeUrl(input)) {
|
|
24925
|
+
const url2 = parseAbsoluteUrl("http:" + input);
|
|
24926
|
+
url2.scheme = "";
|
|
24927
|
+
url2.type = 6;
|
|
24928
|
+
return url2;
|
|
24929
|
+
}
|
|
24930
|
+
if (isAbsolutePath(input)) {
|
|
24931
|
+
const url2 = parseAbsoluteUrl("http://foo.com" + input);
|
|
24932
|
+
url2.scheme = "";
|
|
24933
|
+
url2.host = "";
|
|
24934
|
+
url2.type = 5;
|
|
24935
|
+
return url2;
|
|
24936
|
+
}
|
|
24937
|
+
if (isFileUrl(input))
|
|
24938
|
+
return parseFileUrl(input);
|
|
24939
|
+
if (isAbsoluteUrl(input))
|
|
24940
|
+
return parseAbsoluteUrl(input);
|
|
24941
|
+
const url = parseAbsoluteUrl("http://foo.com/" + input);
|
|
24942
|
+
url.scheme = "";
|
|
24943
|
+
url.host = "";
|
|
24944
|
+
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
24945
|
+
return url;
|
|
24946
|
+
}
|
|
24947
|
+
function stripPathFilename(path4) {
|
|
24948
|
+
if (path4.endsWith("/.."))
|
|
24949
|
+
return path4;
|
|
24950
|
+
const index = path4.lastIndexOf("/");
|
|
24951
|
+
return path4.slice(0, index + 1);
|
|
24952
|
+
}
|
|
24953
|
+
function mergePaths(url, base) {
|
|
24954
|
+
normalizePath(base, base.type);
|
|
24955
|
+
if (url.path === "/") {
|
|
24956
|
+
url.path = base.path;
|
|
24957
|
+
} else {
|
|
24958
|
+
url.path = stripPathFilename(base.path) + url.path;
|
|
24959
|
+
}
|
|
24960
|
+
}
|
|
24961
|
+
function normalizePath(url, type) {
|
|
24962
|
+
const rel = type <= 4;
|
|
24963
|
+
const pieces = url.path.split("/");
|
|
24964
|
+
let pointer = 1;
|
|
24965
|
+
let positive = 0;
|
|
24966
|
+
let addTrailingSlash = false;
|
|
24967
|
+
for (let i2 = 1;i2 < pieces.length; i2++) {
|
|
24968
|
+
const piece = pieces[i2];
|
|
24969
|
+
if (!piece) {
|
|
24970
|
+
addTrailingSlash = true;
|
|
24971
|
+
continue;
|
|
24972
|
+
}
|
|
24973
|
+
addTrailingSlash = false;
|
|
24974
|
+
if (piece === ".")
|
|
24975
|
+
continue;
|
|
24976
|
+
if (piece === "..") {
|
|
24977
|
+
if (positive) {
|
|
24978
|
+
addTrailingSlash = true;
|
|
24979
|
+
positive--;
|
|
24980
|
+
pointer--;
|
|
24981
|
+
} else if (rel) {
|
|
24982
|
+
pieces[pointer++] = piece;
|
|
24983
|
+
}
|
|
24984
|
+
continue;
|
|
24985
|
+
}
|
|
24986
|
+
pieces[pointer++] = piece;
|
|
24987
|
+
positive++;
|
|
24988
|
+
}
|
|
24989
|
+
let path4 = "";
|
|
24990
|
+
for (let i2 = 1;i2 < pointer; i2++) {
|
|
24991
|
+
path4 += "/" + pieces[i2];
|
|
24992
|
+
}
|
|
24993
|
+
if (!path4 || addTrailingSlash && !path4.endsWith("/..")) {
|
|
24994
|
+
path4 += "/";
|
|
24995
|
+
}
|
|
24996
|
+
url.path = path4;
|
|
24997
|
+
}
|
|
24998
|
+
function resolve(input, base) {
|
|
24999
|
+
if (!input && !base)
|
|
25000
|
+
return "";
|
|
25001
|
+
const url = parseUrl(input);
|
|
25002
|
+
let inputType = url.type;
|
|
25003
|
+
if (base && inputType !== 7) {
|
|
25004
|
+
const baseUrl = parseUrl(base);
|
|
25005
|
+
const baseType = baseUrl.type;
|
|
25006
|
+
switch (inputType) {
|
|
25007
|
+
case 1:
|
|
25008
|
+
url.hash = baseUrl.hash;
|
|
25009
|
+
case 2:
|
|
25010
|
+
url.query = baseUrl.query;
|
|
25011
|
+
case 3:
|
|
25012
|
+
case 4:
|
|
25013
|
+
mergePaths(url, baseUrl);
|
|
25014
|
+
case 5:
|
|
25015
|
+
url.user = baseUrl.user;
|
|
25016
|
+
url.host = baseUrl.host;
|
|
25017
|
+
url.port = baseUrl.port;
|
|
25018
|
+
case 6:
|
|
25019
|
+
url.scheme = baseUrl.scheme;
|
|
25020
|
+
}
|
|
25021
|
+
if (baseType > inputType)
|
|
25022
|
+
inputType = baseType;
|
|
25023
|
+
}
|
|
25024
|
+
normalizePath(url, inputType);
|
|
25025
|
+
const queryHash = url.query + url.hash;
|
|
25026
|
+
switch (inputType) {
|
|
25027
|
+
case 2:
|
|
25028
|
+
case 3:
|
|
25029
|
+
return queryHash;
|
|
25030
|
+
case 4: {
|
|
25031
|
+
const path4 = url.path.slice(1);
|
|
25032
|
+
if (!path4)
|
|
25033
|
+
return queryHash || ".";
|
|
25034
|
+
if (isRelative(base || input) && !isRelative(path4)) {
|
|
25035
|
+
return "./" + path4 + queryHash;
|
|
25036
|
+
}
|
|
25037
|
+
return path4 + queryHash;
|
|
25038
|
+
}
|
|
25039
|
+
case 5:
|
|
25040
|
+
return url.path + queryHash;
|
|
25041
|
+
default:
|
|
25042
|
+
return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
|
|
25043
|
+
}
|
|
25044
|
+
}
|
|
25045
|
+
var schemeRegex, urlRegex, fileRegex;
|
|
25046
|
+
var init_resolve_uri = __esm(() => {
|
|
25047
|
+
schemeRegex = /^[\w+.-]+:\/\//;
|
|
25048
|
+
urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
|
|
25049
|
+
fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
|
|
25050
|
+
});
|
|
25051
|
+
|
|
25052
|
+
// ../../node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
|
|
25053
|
+
function stripFilename(path4) {
|
|
25054
|
+
if (!path4)
|
|
25055
|
+
return "";
|
|
25056
|
+
const index = path4.lastIndexOf("/");
|
|
25057
|
+
return path4.slice(0, index + 1);
|
|
25058
|
+
}
|
|
25059
|
+
function resolver(mapUrl, sourceRoot) {
|
|
25060
|
+
const from = stripFilename(mapUrl);
|
|
25061
|
+
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
25062
|
+
return (source) => resolve(prefix + (source || ""), from);
|
|
25063
|
+
}
|
|
25064
|
+
function maybeSort(mappings, owned) {
|
|
25065
|
+
const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
|
|
25066
|
+
if (unsortedIndex === mappings.length)
|
|
25067
|
+
return mappings;
|
|
25068
|
+
if (!owned)
|
|
25069
|
+
mappings = mappings.slice();
|
|
25070
|
+
for (let i2 = unsortedIndex;i2 < mappings.length; i2 = nextUnsortedSegmentLine(mappings, i2 + 1)) {
|
|
25071
|
+
mappings[i2] = sortSegments(mappings[i2], owned);
|
|
25072
|
+
}
|
|
25073
|
+
return mappings;
|
|
25074
|
+
}
|
|
25075
|
+
function nextUnsortedSegmentLine(mappings, start) {
|
|
25076
|
+
for (let i2 = start;i2 < mappings.length; i2++) {
|
|
25077
|
+
if (!isSorted(mappings[i2]))
|
|
25078
|
+
return i2;
|
|
25079
|
+
}
|
|
25080
|
+
return mappings.length;
|
|
25081
|
+
}
|
|
25082
|
+
function isSorted(line) {
|
|
25083
|
+
for (let j = 1;j < line.length; j++) {
|
|
25084
|
+
if (line[j][COLUMN] < line[j - 1][COLUMN]) {
|
|
25085
|
+
return false;
|
|
25086
|
+
}
|
|
25087
|
+
}
|
|
25088
|
+
return true;
|
|
25089
|
+
}
|
|
25090
|
+
function sortSegments(line, owned) {
|
|
25091
|
+
if (!owned)
|
|
25092
|
+
line = line.slice();
|
|
25093
|
+
return line.sort(sortComparator2);
|
|
25094
|
+
}
|
|
25095
|
+
function sortComparator2(a, b2) {
|
|
25096
|
+
return a[COLUMN] - b2[COLUMN];
|
|
25097
|
+
}
|
|
25098
|
+
function binarySearch(haystack, needle, low, high) {
|
|
25099
|
+
while (low <= high) {
|
|
25100
|
+
const mid = low + (high - low >> 1);
|
|
25101
|
+
const cmp = haystack[mid][COLUMN] - needle;
|
|
25102
|
+
if (cmp === 0) {
|
|
25103
|
+
found = true;
|
|
25104
|
+
return mid;
|
|
25105
|
+
}
|
|
25106
|
+
if (cmp < 0) {
|
|
25107
|
+
low = mid + 1;
|
|
25108
|
+
} else {
|
|
25109
|
+
high = mid - 1;
|
|
25110
|
+
}
|
|
25111
|
+
}
|
|
25112
|
+
found = false;
|
|
25113
|
+
return low - 1;
|
|
25114
|
+
}
|
|
25115
|
+
function upperBound(haystack, needle, index) {
|
|
25116
|
+
for (let i2 = index + 1;i2 < haystack.length; index = i2++) {
|
|
25117
|
+
if (haystack[i2][COLUMN] !== needle)
|
|
25118
|
+
break;
|
|
25119
|
+
}
|
|
25120
|
+
return index;
|
|
25121
|
+
}
|
|
25122
|
+
function lowerBound(haystack, needle, index) {
|
|
25123
|
+
for (let i2 = index - 1;i2 >= 0; index = i2--) {
|
|
25124
|
+
if (haystack[i2][COLUMN] !== needle)
|
|
25125
|
+
break;
|
|
25126
|
+
}
|
|
25127
|
+
return index;
|
|
25128
|
+
}
|
|
25129
|
+
function memoizedState() {
|
|
25130
|
+
return {
|
|
25131
|
+
lastKey: -1,
|
|
25132
|
+
lastNeedle: -1,
|
|
25133
|
+
lastIndex: -1
|
|
25134
|
+
};
|
|
25135
|
+
}
|
|
25136
|
+
function memoizedBinarySearch(haystack, needle, state, key) {
|
|
25137
|
+
const { lastKey, lastNeedle, lastIndex } = state;
|
|
25138
|
+
let low = 0;
|
|
25139
|
+
let high = haystack.length - 1;
|
|
25140
|
+
if (key === lastKey) {
|
|
25141
|
+
if (needle === lastNeedle) {
|
|
25142
|
+
found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
|
|
25143
|
+
return lastIndex;
|
|
25144
|
+
}
|
|
25145
|
+
if (needle >= lastNeedle) {
|
|
25146
|
+
low = lastIndex === -1 ? 0 : lastIndex;
|
|
25147
|
+
} else {
|
|
25148
|
+
high = lastIndex;
|
|
25149
|
+
}
|
|
25150
|
+
}
|
|
25151
|
+
state.lastKey = key;
|
|
25152
|
+
state.lastNeedle = needle;
|
|
25153
|
+
return state.lastIndex = binarySearch(haystack, needle, low, high);
|
|
25154
|
+
}
|
|
25155
|
+
function parse2(map) {
|
|
25156
|
+
return typeof map === "string" ? JSON.parse(map) : map;
|
|
25157
|
+
}
|
|
25158
|
+
function cast(map) {
|
|
25159
|
+
return map;
|
|
25160
|
+
}
|
|
25161
|
+
function decodedMappings(map) {
|
|
25162
|
+
var _a;
|
|
25163
|
+
return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
|
|
25164
|
+
}
|
|
25165
|
+
function originalPositionFor(map, needle) {
|
|
25166
|
+
let { line, column, bias } = needle;
|
|
25167
|
+
line--;
|
|
25168
|
+
if (line < 0)
|
|
25169
|
+
throw new Error(LINE_GTR_ZERO);
|
|
25170
|
+
if (column < 0)
|
|
25171
|
+
throw new Error(COL_GTR_EQ_ZERO);
|
|
25172
|
+
const decoded = decodedMappings(map);
|
|
25173
|
+
if (line >= decoded.length)
|
|
25174
|
+
return OMapping(null, null, null, null);
|
|
25175
|
+
const segments = decoded[line];
|
|
25176
|
+
const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
|
25177
|
+
if (index === -1)
|
|
25178
|
+
return OMapping(null, null, null, null);
|
|
25179
|
+
const segment = segments[index];
|
|
25180
|
+
if (segment.length === 1)
|
|
25181
|
+
return OMapping(null, null, null, null);
|
|
25182
|
+
const { names, resolvedSources } = map;
|
|
25183
|
+
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
|
25184
|
+
}
|
|
25185
|
+
function OMapping(source, line, column, name) {
|
|
25186
|
+
return { source, line, column, name };
|
|
25187
|
+
}
|
|
25188
|
+
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
25189
|
+
let index = memoizedBinarySearch(segments, column, memo, line);
|
|
25190
|
+
if (found) {
|
|
25191
|
+
index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
|
|
25192
|
+
} else if (bias === LEAST_UPPER_BOUND)
|
|
25193
|
+
index++;
|
|
25194
|
+
if (index === -1 || index === segments.length)
|
|
25195
|
+
return -1;
|
|
25196
|
+
return index;
|
|
25197
|
+
}
|
|
25198
|
+
var COLUMN = 0, SOURCES_INDEX = 1, SOURCE_LINE = 2, SOURCE_COLUMN = 3, NAMES_INDEX = 4, found = false, LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)", COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)", LEAST_UPPER_BOUND = -1, GREATEST_LOWER_BOUND = 1, TraceMap = class {
|
|
25199
|
+
constructor(map, mapUrl) {
|
|
25200
|
+
const isString = typeof map === "string";
|
|
25201
|
+
if (!isString && map._decodedMemo)
|
|
25202
|
+
return map;
|
|
25203
|
+
const parsed = parse2(map);
|
|
25204
|
+
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
25205
|
+
this.version = version;
|
|
25206
|
+
this.file = file;
|
|
25207
|
+
this.names = names || [];
|
|
25208
|
+
this.sourceRoot = sourceRoot;
|
|
25209
|
+
this.sources = sources;
|
|
25210
|
+
this.sourcesContent = sourcesContent;
|
|
25211
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
|
|
25212
|
+
const resolve2 = resolver(mapUrl, sourceRoot);
|
|
25213
|
+
this.resolvedSources = sources.map(resolve2);
|
|
25214
|
+
const { mappings } = parsed;
|
|
25215
|
+
if (typeof mappings === "string") {
|
|
25216
|
+
this._encoded = mappings;
|
|
25217
|
+
this._decoded = undefined;
|
|
25218
|
+
} else if (Array.isArray(mappings)) {
|
|
25219
|
+
this._encoded = undefined;
|
|
25220
|
+
this._decoded = maybeSort(mappings, isString);
|
|
25221
|
+
} else if (parsed.sections) {
|
|
25222
|
+
throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
|
|
25223
|
+
} else {
|
|
25224
|
+
throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
|
|
25225
|
+
}
|
|
25226
|
+
this._decodedMemo = memoizedState();
|
|
25227
|
+
this._bySources = undefined;
|
|
25228
|
+
this._bySourceMemos = undefined;
|
|
25229
|
+
}
|
|
25230
|
+
};
|
|
25231
|
+
var init_trace_mapping = __esm(() => {
|
|
25232
|
+
init_sourcemap_codec();
|
|
25233
|
+
init_resolve_uri();
|
|
25234
|
+
});
|
|
25235
|
+
|
|
25236
|
+
// src/check-code.ts
|
|
25237
|
+
var {Glob } = globalThis.Bun;
|
|
25238
|
+
import path4 from "path";
|
|
25239
|
+
function buildPosition(error) {
|
|
25240
|
+
if (typeof error !== "object" || error === null || !("position" in error))
|
|
25241
|
+
return null;
|
|
25242
|
+
const position = error.position;
|
|
25243
|
+
return typeof position === "object" && position !== null ? position : null;
|
|
25244
|
+
}
|
|
25245
|
+
function messageOf(error) {
|
|
25246
|
+
const message = typeof error === "object" && error !== null && "message" in error ? error.message : undefined;
|
|
25247
|
+
return String(typeof message === "string" ? message : error).split(`
|
|
25248
|
+
`)[0];
|
|
25249
|
+
}
|
|
25250
|
+
function toSource(map, position) {
|
|
25251
|
+
if (!map || position?.line === undefined)
|
|
25252
|
+
return {};
|
|
25253
|
+
try {
|
|
25254
|
+
const traced = originalPositionFor(new TraceMap(JSON.parse(map)), {
|
|
25255
|
+
line: position.line,
|
|
25256
|
+
column: position.column ?? 0
|
|
25257
|
+
});
|
|
25258
|
+
if (traced.line === null)
|
|
25259
|
+
return {};
|
|
25260
|
+
return { line: traced.line, column: traced.column + 1 };
|
|
25261
|
+
} catch {
|
|
25262
|
+
return {};
|
|
25263
|
+
}
|
|
25264
|
+
}
|
|
25265
|
+
async function checkAstroFile(absolute, relative, source) {
|
|
25266
|
+
let emitted;
|
|
25267
|
+
try {
|
|
25268
|
+
emitted = await w2(source, { filename: absolute, sourcemap: "both" });
|
|
25269
|
+
} catch (error) {
|
|
25270
|
+
return { severity: "error", code: "code/astro-parse", file: relative, message: messageOf(error) };
|
|
25271
|
+
}
|
|
25272
|
+
try {
|
|
25273
|
+
new Bun.Transpiler({ loader: "ts" }).transformSync(emitted.code);
|
|
25274
|
+
return null;
|
|
25275
|
+
} catch (error) {
|
|
25276
|
+
const position = buildPosition(error);
|
|
25277
|
+
return {
|
|
25278
|
+
severity: "error",
|
|
25279
|
+
code: "code/syntax",
|
|
25280
|
+
file: relative,
|
|
25281
|
+
...toSource(emitted.map, position),
|
|
25282
|
+
message: messageOf(error)
|
|
25283
|
+
};
|
|
25284
|
+
}
|
|
25285
|
+
}
|
|
25286
|
+
function checkScriptFile(relative, source, loader) {
|
|
25287
|
+
try {
|
|
25288
|
+
new Bun.Transpiler({ loader }).transformSync(source);
|
|
25289
|
+
return null;
|
|
25290
|
+
} catch (error) {
|
|
25291
|
+
const position = buildPosition(error);
|
|
25292
|
+
return {
|
|
25293
|
+
severity: "error",
|
|
25294
|
+
code: "code/syntax",
|
|
25295
|
+
file: relative,
|
|
25296
|
+
line: position?.line,
|
|
25297
|
+
column: position?.column === undefined ? undefined : position.column + 1,
|
|
25298
|
+
message: messageOf(error)
|
|
25299
|
+
};
|
|
25300
|
+
}
|
|
25301
|
+
}
|
|
25302
|
+
async function checkCode(root) {
|
|
25303
|
+
const findings = [];
|
|
25304
|
+
let files = 0;
|
|
25305
|
+
const paths = [];
|
|
25306
|
+
for await (const relative of new Glob("**/*.{astro,ts,tsx,mts,cts}").scan({ cwd: root })) {
|
|
25307
|
+
if (!isIgnored(relative))
|
|
25308
|
+
paths.push(relative);
|
|
25309
|
+
}
|
|
25310
|
+
paths.sort();
|
|
25311
|
+
for (const relative of paths) {
|
|
25312
|
+
files++;
|
|
25313
|
+
const absolute = path4.join(root, relative);
|
|
25314
|
+
const source = await Bun.file(absolute).text();
|
|
25315
|
+
const finding = relative.endsWith(".astro") ? await checkAstroFile(absolute, relative, source) : checkScriptFile(relative, source, relative.endsWith(".tsx") ? "tsx" : "ts");
|
|
25316
|
+
if (finding)
|
|
25317
|
+
findings.push(finding);
|
|
25318
|
+
}
|
|
25319
|
+
return { findings, files };
|
|
25320
|
+
}
|
|
25321
|
+
var IGNORED, isIgnored = (relative) => /\.d\.[mc]?ts$/.test(relative) || relative.split(path4.sep).some((segment) => IGNORED.includes(segment));
|
|
25322
|
+
var init_check_code = __esm(() => {
|
|
25323
|
+
init_node();
|
|
25324
|
+
init_trace_mapping();
|
|
25325
|
+
IGNORED = ["node_modules", "dist", ".astro", ".git", ".output", ".vercel", ".netlify"];
|
|
25326
|
+
});
|
|
25327
|
+
|
|
25328
|
+
// src/live-schema.ts
|
|
25329
|
+
import { existsSync, realpathSync } from "fs";
|
|
25330
|
+
import path5 from "path";
|
|
25331
|
+
function reasonOf(error, fallback = "unknown error") {
|
|
25332
|
+
try {
|
|
25333
|
+
if (typeof error === "string" && error !== "")
|
|
25334
|
+
return error;
|
|
25335
|
+
if (error instanceof Error && error.message !== "")
|
|
25336
|
+
return error.message;
|
|
25337
|
+
if (isRecord(error) && typeof error.message === "string" && error.message !== "")
|
|
25338
|
+
return error.message;
|
|
25339
|
+
} catch {}
|
|
25340
|
+
return fallback;
|
|
25341
|
+
}
|
|
25342
|
+
function findConfig(projectRoot) {
|
|
25343
|
+
for (const name of CONFIG_NAMES) {
|
|
25344
|
+
const candidate = path5.join(projectRoot, name);
|
|
25345
|
+
if (existsSync(candidate))
|
|
25346
|
+
return candidate;
|
|
25347
|
+
}
|
|
25348
|
+
return null;
|
|
25349
|
+
}
|
|
25350
|
+
function projectAstroDir(projectRoot) {
|
|
25351
|
+
let dir = projectRoot;
|
|
25352
|
+
while (true) {
|
|
25353
|
+
const candidate = path5.join(dir, "node_modules", "astro");
|
|
25354
|
+
if (existsSync(path5.join(candidate, "package.json")))
|
|
25355
|
+
return candidate;
|
|
25356
|
+
const parent = path5.dirname(dir);
|
|
25357
|
+
if (parent === dir)
|
|
25358
|
+
return null;
|
|
25359
|
+
dir = parent;
|
|
25360
|
+
}
|
|
25361
|
+
}
|
|
25362
|
+
function zodEntryOf(module) {
|
|
25363
|
+
if (!isRecord(module))
|
|
25364
|
+
return null;
|
|
25365
|
+
const namespace = module.z;
|
|
25366
|
+
if (!isRecord(namespace))
|
|
25367
|
+
return null;
|
|
25368
|
+
const string = namespace.string;
|
|
25369
|
+
const object = namespace.object;
|
|
25370
|
+
const union = namespace.union;
|
|
25371
|
+
const any = namespace.any;
|
|
25372
|
+
if (typeof string !== "function" || typeof object !== "function" || typeof union !== "function" || typeof any !== "function")
|
|
25373
|
+
return null;
|
|
25374
|
+
return {
|
|
25375
|
+
namespace,
|
|
25376
|
+
any: () => Reflect.apply(any, namespace, []),
|
|
25377
|
+
reference: () => {
|
|
25378
|
+
const text = () => Reflect.apply(string, namespace, []);
|
|
25379
|
+
const lookup = (key) => Reflect.apply(object, namespace, [{ [key]: text(), collection: text() }]);
|
|
25380
|
+
return Reflect.apply(union, namespace, [[text(), lookup("id"), lookup("slug")]]);
|
|
25381
|
+
}
|
|
25382
|
+
};
|
|
25383
|
+
}
|
|
25384
|
+
function installContentStub(zodPath, zod) {
|
|
25385
|
+
Bun.plugin({
|
|
25386
|
+
name: "astro-content-stub",
|
|
25387
|
+
setup(build) {
|
|
25388
|
+
build.module("astro:content", () => ({
|
|
25389
|
+
loader: "object",
|
|
25390
|
+
exports: {
|
|
25391
|
+
defineCollection: (collection) => collection,
|
|
25392
|
+
reference: () => zod.reference(),
|
|
25393
|
+
z: zod.namespace
|
|
25394
|
+
}
|
|
25395
|
+
}));
|
|
25396
|
+
}
|
|
25397
|
+
});
|
|
25398
|
+
stubbedZod = zodPath;
|
|
25399
|
+
}
|
|
25400
|
+
function parseMethod(schema) {
|
|
25401
|
+
if (!isRecord(schema))
|
|
25402
|
+
return null;
|
|
25403
|
+
for (const name of ["safeParseAsync", "safeParse"]) {
|
|
25404
|
+
const method = schema[name];
|
|
25405
|
+
if (typeof method === "function")
|
|
25406
|
+
return (value) => Reflect.apply(method, schema, [value]);
|
|
25407
|
+
}
|
|
25408
|
+
return null;
|
|
25409
|
+
}
|
|
25410
|
+
function dedupe(issues) {
|
|
25411
|
+
const seen = new Set;
|
|
25412
|
+
const unique = [];
|
|
25413
|
+
for (const issue of issues) {
|
|
25414
|
+
const key = `${issue.path.join("\x00")}\x01${issue.message}`;
|
|
25415
|
+
if (seen.has(key))
|
|
25416
|
+
continue;
|
|
25417
|
+
seen.add(key);
|
|
25418
|
+
unique.push(issue);
|
|
25419
|
+
}
|
|
25420
|
+
return unique;
|
|
25421
|
+
}
|
|
25422
|
+
function unionIssues(raw) {
|
|
25423
|
+
return asArray(raw.errors ?? raw.unionErrors).flatMap((branch) => asArray(isRecord(branch) ? branch.issues ?? branch.errors : branch).flatMap(toIssues));
|
|
25424
|
+
}
|
|
25425
|
+
function toIssues(raw) {
|
|
25426
|
+
if (!isRecord(raw))
|
|
25427
|
+
return [{ path: [], message: reasonOf(raw, "invalid value") }];
|
|
25428
|
+
const base = asArray(raw.path).map((segment) => typeof segment === "number" ? segment : String(segment));
|
|
25429
|
+
const branches = raw.code === "invalid_union" ? unionIssues(raw) : [];
|
|
25430
|
+
if (branches.length > 0)
|
|
25431
|
+
return dedupe(branches.map((issue) => ({ path: [...base, ...issue.path], message: issue.message })));
|
|
25432
|
+
return [{ path: base, message: typeof raw.message === "string" ? raw.message : "invalid value" }];
|
|
25433
|
+
}
|
|
25434
|
+
function normalizeIssues(error) {
|
|
25435
|
+
const raw = isRecord(error) ? asArray(error.issues ?? error.errors) : [];
|
|
25436
|
+
if (raw.length > 0)
|
|
25437
|
+
return raw.flatMap(toIssues);
|
|
25438
|
+
return [{ path: [], message: reasonOf(error, "the schema rejected this value without saying why") }];
|
|
25439
|
+
}
|
|
25440
|
+
function liveSchema(parse3) {
|
|
25441
|
+
return {
|
|
25442
|
+
async safeParse(value) {
|
|
25443
|
+
try {
|
|
25444
|
+
const result = await parse3(value);
|
|
25445
|
+
if (!isRecord(result))
|
|
25446
|
+
return { success: false, issues: [{ path: [], message: "the schema returned no parse result" }] };
|
|
25447
|
+
if (result.success === true)
|
|
25448
|
+
return { success: true };
|
|
25449
|
+
return { success: false, issues: normalizeIssues(result.error) };
|
|
25450
|
+
} catch (error) {
|
|
25451
|
+
return { success: false, issues: [{ path: [], message: reasonOf(error, "the schema threw while parsing this entry") }] };
|
|
25452
|
+
}
|
|
25453
|
+
}
|
|
25454
|
+
};
|
|
25455
|
+
}
|
|
25456
|
+
async function collectSchemas(module, zod, configName) {
|
|
25457
|
+
const collections = isRecord(module) ? module.collections : undefined;
|
|
25458
|
+
if (!isRecord(collections))
|
|
25459
|
+
return { skipped: `${configName} does not export a \`collections\` object.` };
|
|
25460
|
+
const schemas = {};
|
|
25461
|
+
for (const [name, definition] of Object.entries(collections)) {
|
|
25462
|
+
if (!isRecord(definition))
|
|
25463
|
+
continue;
|
|
25464
|
+
const factory = definition.schema;
|
|
25465
|
+
if (factory === undefined)
|
|
25466
|
+
continue;
|
|
25467
|
+
let resolved;
|
|
25468
|
+
try {
|
|
25469
|
+
resolved = typeof factory === "function" ? await Reflect.apply(factory, definition, [{ image: () => zod.any() }]) : factory;
|
|
25470
|
+
} catch (error) {
|
|
25471
|
+
return { skipped: `The schema of collection "${name}" in ${configName} threw while being built: ${reasonOf(error)}` };
|
|
25472
|
+
}
|
|
25473
|
+
const parse3 = parseMethod(resolved);
|
|
25474
|
+
if (!parse3) {
|
|
25475
|
+
return { skipped: `The schema of collection "${name}" in ${configName} has no safeParse method \u2014 is it a zod schema?` };
|
|
25476
|
+
}
|
|
25477
|
+
schemas[name] = liveSchema(parse3);
|
|
25478
|
+
}
|
|
25479
|
+
return { schemas };
|
|
25480
|
+
}
|
|
25481
|
+
async function loadLiveSchemas(projectRoot) {
|
|
25482
|
+
const root = path5.resolve(projectRoot);
|
|
25483
|
+
const configPath = findConfig(root);
|
|
25484
|
+
if (!configPath) {
|
|
25485
|
+
return { skipped: `No content config in ${root} \u2014 expected src/content.config.ts or src/content/config.ts.` };
|
|
25486
|
+
}
|
|
25487
|
+
const configName = path5.relative(root, configPath);
|
|
25488
|
+
const astroDir = projectAstroDir(root);
|
|
25489
|
+
if (!astroDir) {
|
|
25490
|
+
return { skipped: `No node_modules/astro above ${root} \u2014 install the project's dependencies and run this again.` };
|
|
25491
|
+
}
|
|
25492
|
+
let zodPath;
|
|
25493
|
+
try {
|
|
25494
|
+
zodPath = realOf(Bun.resolveSync("astro/zod", root));
|
|
25495
|
+
} catch (error) {
|
|
25496
|
+
return { skipped: `Could not resolve astro/zod from ${root}: ${reasonOf(error)}` };
|
|
25497
|
+
}
|
|
25498
|
+
if (!contains(astroDir, zodPath)) {
|
|
25499
|
+
return {
|
|
25500
|
+
skipped: `astro/zod resolved to ${zodPath}, outside the project's own ${astroDir} \u2014 reinstall the project's dependencies and run this again.`
|
|
25501
|
+
};
|
|
25502
|
+
}
|
|
25503
|
+
let zodModule;
|
|
25504
|
+
try {
|
|
25505
|
+
zodModule = await import(zodPath);
|
|
25506
|
+
} catch (error) {
|
|
25507
|
+
return { skipped: `Loading astro/zod from ${root} failed: ${reasonOf(error)}` };
|
|
25508
|
+
}
|
|
25509
|
+
let zod;
|
|
25510
|
+
try {
|
|
25511
|
+
zod = zodEntryOf(zodModule);
|
|
25512
|
+
} catch {
|
|
25513
|
+
zod = null;
|
|
25514
|
+
}
|
|
25515
|
+
if (!zod) {
|
|
25516
|
+
return { skipped: `astro/zod in ${root} does not export a usable \`z\` \u2014 the installed Astro version may be unsupported.` };
|
|
25517
|
+
}
|
|
25518
|
+
if (stubbedZod === null) {
|
|
25519
|
+
try {
|
|
25520
|
+
installContentStub(zodPath, zod);
|
|
25521
|
+
} catch (error) {
|
|
25522
|
+
return { skipped: `Installing the astro:content stub failed: ${reasonOf(error)}` };
|
|
25523
|
+
}
|
|
25524
|
+
} else if (stubbedZod !== zodPath) {
|
|
25525
|
+
return {
|
|
25526
|
+
skipped: `Live schemas were already loaded against ${stubbedZod}; the astro:content stub is process-global, so ${root} needs a run of its own.`
|
|
25527
|
+
};
|
|
25528
|
+
}
|
|
25529
|
+
let module;
|
|
25530
|
+
try {
|
|
25531
|
+
module = await import(configPath);
|
|
25532
|
+
} catch (error) {
|
|
25533
|
+
return { skipped: `${configName} failed to load: ${reasonOf(error)}` };
|
|
25534
|
+
}
|
|
25535
|
+
try {
|
|
25536
|
+
return await collectSchemas(module, zod, configName);
|
|
25537
|
+
} catch (error) {
|
|
25538
|
+
return { skipped: `Reading the collections in ${configName} failed: ${reasonOf(error)}` };
|
|
25539
|
+
}
|
|
25540
|
+
}
|
|
25541
|
+
var CONFIG_NAMES, isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value), asArray = (value) => Array.isArray(value) ? value : [], realOf = (target) => {
|
|
25542
|
+
try {
|
|
25543
|
+
return realpathSync(target);
|
|
25544
|
+
} catch {
|
|
25545
|
+
return target;
|
|
25546
|
+
}
|
|
25547
|
+
}, contains = (dir, file) => {
|
|
25548
|
+
const relative = path5.relative(realOf(dir), realOf(file));
|
|
25549
|
+
return relative !== "" && !relative.startsWith("..") && !path5.isAbsolute(relative);
|
|
25550
|
+
}, stubbedZod = null;
|
|
25551
|
+
var init_live_schema = __esm(() => {
|
|
25552
|
+
CONFIG_NAMES = [
|
|
25553
|
+
"src/content.config.mjs",
|
|
25554
|
+
"src/content.config.js",
|
|
25555
|
+
"src/content.config.mts",
|
|
25556
|
+
"src/content.config.ts",
|
|
25557
|
+
"src/content/config.ts",
|
|
25558
|
+
"src/content/config.js",
|
|
25559
|
+
"src/content/config.mjs",
|
|
25560
|
+
"src/content/config.mts"
|
|
25561
|
+
];
|
|
23827
25562
|
});
|
|
23828
25563
|
|
|
23829
25564
|
// src/check.ts
|
|
23830
25565
|
var exports_check = {};
|
|
23831
25566
|
__export(exports_check, {
|
|
25567
|
+
parseCheckArgs: () => parseCheckArgs,
|
|
23832
25568
|
check: () => check,
|
|
23833
25569
|
astroRoots: () => astroRoots
|
|
23834
25570
|
});
|
|
23835
|
-
import { existsSync, readdirSync } from "fs";
|
|
23836
|
-
import
|
|
25571
|
+
import { existsSync as existsSync2, readdirSync } from "fs";
|
|
25572
|
+
import path6 from "path";
|
|
25573
|
+
function parseCheckArgs(args, cwd) {
|
|
25574
|
+
const contentOnly = args.includes("--content-only");
|
|
25575
|
+
return {
|
|
25576
|
+
cwd,
|
|
25577
|
+
json: args.includes("--json"),
|
|
25578
|
+
strict: args.includes("--strict"),
|
|
25579
|
+
contentOnly,
|
|
25580
|
+
live: !contentOnly && !args.includes("--no-live")
|
|
25581
|
+
};
|
|
25582
|
+
}
|
|
23837
25583
|
function astroRoots(cwd) {
|
|
23838
25584
|
if (hasAstroConfig(cwd))
|
|
23839
25585
|
return ["."];
|
|
23840
|
-
const packagesDir =
|
|
23841
|
-
if (!
|
|
25586
|
+
const packagesDir = path6.join(cwd, "packages");
|
|
25587
|
+
if (!existsSync2(packagesDir))
|
|
23842
25588
|
return [];
|
|
23843
|
-
return readdirSync(packagesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().filter((name) => hasAstroConfig(
|
|
25589
|
+
return readdirSync(packagesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().filter((name) => hasAstroConfig(path6.join(packagesDir, name))).map((name) => path6.join("packages", name));
|
|
23844
25590
|
}
|
|
23845
25591
|
function prefixed(report, root) {
|
|
23846
25592
|
if (root === ".")
|
|
23847
25593
|
return report;
|
|
23848
25594
|
return {
|
|
23849
25595
|
...report,
|
|
23850
|
-
findings: report.findings.map((finding) => ({ ...finding, file:
|
|
25596
|
+
findings: report.findings.map((finding) => ({ ...finding, file: path6.join(root, finding.file) }))
|
|
23851
25597
|
};
|
|
23852
25598
|
}
|
|
25599
|
+
async function liveSchemasFor(options, roots) {
|
|
25600
|
+
if (options.contentOnly) {
|
|
25601
|
+
return { skipped: "--content-only was passed, and reading the real schemas means executing the project's content config." };
|
|
25602
|
+
}
|
|
25603
|
+
if (!options.live)
|
|
25604
|
+
return { skipped: "--no-live was passed." };
|
|
25605
|
+
const first = roots[0];
|
|
25606
|
+
if (roots.length !== 1 || first === undefined) {
|
|
25607
|
+
const where = roots.join(", ");
|
|
25608
|
+
return { skipped: `They need exactly one Astro project; this run covers ${roots.length} (${where}). Check each one from its own directory.` };
|
|
25609
|
+
}
|
|
25610
|
+
return loadLiveSchemas(path6.join(options.cwd, first));
|
|
25611
|
+
}
|
|
23853
25612
|
async function check(options) {
|
|
23854
25613
|
const roots = astroRoots(options.cwd);
|
|
23855
25614
|
if (roots.length === 0) {
|
|
23856
25615
|
console.error(`No astro.config.* found in ${options.cwd} or its packages/*. Run this in an Astro project.`);
|
|
23857
25616
|
return 1;
|
|
23858
25617
|
}
|
|
23859
|
-
const
|
|
25618
|
+
const live = await liveSchemasFor(options, roots);
|
|
25619
|
+
const schemas = "schemas" in live ? live.schemas : undefined;
|
|
25620
|
+
const reports = await Promise.all(roots.map(async (root) => {
|
|
25621
|
+
const absolute = path6.join(options.cwd, root);
|
|
25622
|
+
const content = prefixed(await checkContent(createNodeFs(absolute), schemas ? { schemas } : {}), root);
|
|
25623
|
+
if (options.contentOnly)
|
|
25624
|
+
return { ...content, files: 0 };
|
|
25625
|
+
const code = await checkCode(absolute);
|
|
25626
|
+
return {
|
|
25627
|
+
...content,
|
|
25628
|
+
findings: [...content.findings, ...code.findings.map((finding) => ({ ...finding, file: path6.join(root, finding.file) }))],
|
|
25629
|
+
files: code.files
|
|
25630
|
+
};
|
|
25631
|
+
}));
|
|
23860
25632
|
const report = {
|
|
23861
25633
|
findings: reports.flatMap((one) => one.findings),
|
|
23862
25634
|
collections: reports.reduce((total, one) => total + one.collections, 0),
|
|
23863
25635
|
entries: reports.reduce((total, one) => total + one.entries, 0)
|
|
23864
25636
|
};
|
|
25637
|
+
const sourceFiles = reports.reduce((total, one) => total + one.files, 0);
|
|
23865
25638
|
const errors = report.findings.filter((finding) => finding.severity === "error").length;
|
|
23866
25639
|
const warnings = report.findings.length - errors;
|
|
23867
25640
|
if (options.json) {
|
|
23868
|
-
console.log(JSON.stringify({ ...report, roots }, null, 2));
|
|
25641
|
+
console.log(JSON.stringify({ ...report, roots, liveSchemas: "schemas" in live ? "ran" : live.skipped }, null, 2));
|
|
23869
25642
|
} else {
|
|
23870
25643
|
const formatted = formatCheckReport(report);
|
|
23871
25644
|
if (formatted)
|
|
23872
25645
|
console.log(formatted + `
|
|
23873
25646
|
`);
|
|
23874
25647
|
const where = roots.length === 1 && roots[0] === "." ? "" : ` in ${roots.join(", ")}`;
|
|
23875
|
-
const
|
|
25648
|
+
const code = options.contentOnly ? "" : `, ${sourceFiles} source file(s)`;
|
|
25649
|
+
const counts = `${report.collections} collection(s), ${report.entries} entries${code}${where}`;
|
|
23876
25650
|
console.log(errors === 0 && warnings === 0 ? `${counts} \u2014 no problems found` : `${counts} \u2014 ${errors} error(s), ${warnings} warning(s)`);
|
|
25651
|
+
if ("skipped" in live)
|
|
25652
|
+
console.log(`Live schema rules did not run: ${live.skipped}`);
|
|
23877
25653
|
}
|
|
23878
25654
|
return errors > 0 || options.strict && warnings > 0 ? 1 : 0;
|
|
23879
25655
|
}
|
|
23880
|
-
var ASTRO_CONFIG_NAMES, hasAstroConfig = (dir) => ASTRO_CONFIG_NAMES.some((name) =>
|
|
25656
|
+
var ASTRO_CONFIG_NAMES, hasAstroConfig = (dir) => ASTRO_CONFIG_NAMES.some((name) => existsSync2(path6.join(dir, name)));
|
|
23881
25657
|
var init_check2 = __esm(() => {
|
|
23882
25658
|
init_src2();
|
|
25659
|
+
init_check_code();
|
|
25660
|
+
init_live_schema();
|
|
23883
25661
|
ASTRO_CONFIG_NAMES = ["astro.config.ts", "astro.config.mts", "astro.config.mjs", "astro.config.js"];
|
|
23884
25662
|
});
|
|
23885
25663
|
|
|
23886
25664
|
// src/utils.ts
|
|
23887
|
-
import { existsSync as
|
|
25665
|
+
import { existsSync as existsSync3 } from "fs";
|
|
23888
25666
|
import { join } from "path";
|
|
23889
25667
|
function findAstroConfig(cwd = process.cwd()) {
|
|
23890
|
-
for (const name of
|
|
25668
|
+
for (const name of CONFIG_NAMES2) {
|
|
23891
25669
|
const p = join(cwd, name);
|
|
23892
|
-
if (
|
|
25670
|
+
if (existsSync3(p))
|
|
23893
25671
|
return p;
|
|
23894
25672
|
}
|
|
23895
25673
|
return null;
|
|
@@ -23899,11 +25677,11 @@ function findMatchingClose(text, start) {
|
|
|
23899
25677
|
const close = open === "{" ? "}" : open === "[" ? "]" : ")";
|
|
23900
25678
|
let depth = 0;
|
|
23901
25679
|
let inString = false;
|
|
23902
|
-
for (let
|
|
23903
|
-
const ch = text[
|
|
25680
|
+
for (let i2 = start;i2 < text.length; i2++) {
|
|
25681
|
+
const ch = text[i2];
|
|
23904
25682
|
if (inString) {
|
|
23905
25683
|
if (ch === "\\") {
|
|
23906
|
-
|
|
25684
|
+
i2++;
|
|
23907
25685
|
continue;
|
|
23908
25686
|
}
|
|
23909
25687
|
if (ch === inString)
|
|
@@ -23919,7 +25697,7 @@ function findMatchingClose(text, start) {
|
|
|
23919
25697
|
if (ch === close) {
|
|
23920
25698
|
depth--;
|
|
23921
25699
|
if (depth === 0)
|
|
23922
|
-
return
|
|
25700
|
+
return i2;
|
|
23923
25701
|
}
|
|
23924
25702
|
}
|
|
23925
25703
|
return -1;
|
|
@@ -23941,20 +25719,20 @@ function removeProperty(body, propName) {
|
|
|
23941
25719
|
return body;
|
|
23942
25720
|
const propLineStart = match.index + 1;
|
|
23943
25721
|
const afterMatch = match.index + match[0].length;
|
|
23944
|
-
let
|
|
23945
|
-
while (
|
|
23946
|
-
|
|
25722
|
+
let i2 = afterMatch;
|
|
25723
|
+
while (i2 < body.length && (body[i2] === " " || body[i2] === "\t"))
|
|
25724
|
+
i2++;
|
|
23947
25725
|
let valueEnd;
|
|
23948
|
-
if (body[
|
|
23949
|
-
valueEnd = findMatchingClose(body,
|
|
25726
|
+
if (body[i2] === "{" || body[i2] === "[") {
|
|
25727
|
+
valueEnd = findMatchingClose(body, i2);
|
|
23950
25728
|
if (valueEnd === -1)
|
|
23951
25729
|
return body;
|
|
23952
25730
|
valueEnd++;
|
|
23953
25731
|
} else {
|
|
23954
|
-
while (
|
|
25732
|
+
while (i2 < body.length && body[i2] !== "," && body[i2] !== `
|
|
23955
25733
|
`)
|
|
23956
|
-
|
|
23957
|
-
valueEnd =
|
|
25734
|
+
i2++;
|
|
25735
|
+
valueEnd = i2;
|
|
23958
25736
|
}
|
|
23959
25737
|
let end = valueEnd;
|
|
23960
25738
|
while (end < body.length && (body[end] === " " || body[end] === "\t"))
|
|
@@ -23986,9 +25764,9 @@ function assembleConfig(imports, body) {
|
|
|
23986
25764
|
`;
|
|
23987
25765
|
return result;
|
|
23988
25766
|
}
|
|
23989
|
-
var
|
|
25767
|
+
var CONFIG_NAMES2;
|
|
23990
25768
|
var init_utils = __esm(() => {
|
|
23991
|
-
|
|
25769
|
+
CONFIG_NAMES2 = [
|
|
23992
25770
|
"astro.config.ts",
|
|
23993
25771
|
"astro.config.mts",
|
|
23994
25772
|
"astro.config.mjs",
|
|
@@ -24006,7 +25784,7 @@ __export(exports_init, {
|
|
|
24006
25784
|
detectNuaManagedImports: () => detectNuaManagedImports,
|
|
24007
25785
|
cleanEmptyStructures: () => cleanEmptyStructures
|
|
24008
25786
|
});
|
|
24009
|
-
import { existsSync as
|
|
25787
|
+
import { existsSync as existsSync4, readFileSync, writeFileSync } from "fs";
|
|
24010
25788
|
import { basename, join as join2 } from "path";
|
|
24011
25789
|
function detectNuaManagedImports(content) {
|
|
24012
25790
|
const managed = new Map;
|
|
@@ -24131,7 +25909,7 @@ function transformPackageJson(pkg, nuaVersion) {
|
|
|
24131
25909
|
if (!result.dependencies["@nuasite/nua"]) {
|
|
24132
25910
|
result.dependencies["@nuasite/nua"] = nuaVersion;
|
|
24133
25911
|
}
|
|
24134
|
-
result.dependencies = Object.fromEntries(Object.entries(result.dependencies).sort(([a], [
|
|
25912
|
+
result.dependencies = Object.fromEntries(Object.entries(result.dependencies).sort(([a], [b2]) => a.localeCompare(b2)));
|
|
24135
25913
|
return result;
|
|
24136
25914
|
}
|
|
24137
25915
|
async function init({ cwd = process.cwd(), dryRun = false, yes = false } = {}) {
|
|
@@ -24150,7 +25928,7 @@ async function init({ cwd = process.cwd(), dryRun = false, yes = false } = {}) {
|
|
|
24150
25928
|
process.exit(1);
|
|
24151
25929
|
}
|
|
24152
25930
|
const pkgPath = join2(cwd, "package.json");
|
|
24153
|
-
if (!
|
|
25931
|
+
if (!existsSync4(pkgPath)) {
|
|
24154
25932
|
console.error("No package.json found.");
|
|
24155
25933
|
process.exit(1);
|
|
24156
25934
|
}
|
|
@@ -24228,7 +26006,7 @@ __export(exports_clean, {
|
|
|
24228
26006
|
detectDisabledFeatures: () => detectDisabledFeatures,
|
|
24229
26007
|
clean: () => clean
|
|
24230
26008
|
});
|
|
24231
|
-
import { existsSync as
|
|
26009
|
+
import { existsSync as existsSync5, readdirSync as readdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
24232
26010
|
import { basename as basename2, join as join3 } from "path";
|
|
24233
26011
|
function detectDisabledFeatures(content) {
|
|
24234
26012
|
const disabled = new Set;
|
|
@@ -24241,9 +26019,9 @@ function detectDisabledFeatures(content) {
|
|
|
24241
26019
|
}
|
|
24242
26020
|
function prependToArrayProperty(lines, property, items) {
|
|
24243
26021
|
const pattern = new RegExp(`\\b${property}\\s*:\\s*\\[`);
|
|
24244
|
-
for (let
|
|
24245
|
-
if (pattern.test(lines[
|
|
24246
|
-
lines[
|
|
26022
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
26023
|
+
if (pattern.test(lines[i2])) {
|
|
26024
|
+
lines[i2] = lines[i2].replace(new RegExp(`(\\b${property}\\s*:\\s*\\[)`), `$1${items}, `);
|
|
24247
26025
|
return true;
|
|
24248
26026
|
}
|
|
24249
26027
|
}
|
|
@@ -24332,12 +26110,12 @@ function transformPackageJson2(pkg, disabled, usedRuntimePackages = []) {
|
|
|
24332
26110
|
result.dependencies[name] = nuaVersion ?? "^0.16.0";
|
|
24333
26111
|
}
|
|
24334
26112
|
}
|
|
24335
|
-
result.dependencies = Object.fromEntries(Object.entries(result.dependencies).sort(([a], [
|
|
26113
|
+
result.dependencies = Object.fromEntries(Object.entries(result.dependencies).sort(([a], [b2]) => a.localeCompare(b2)));
|
|
24336
26114
|
return result;
|
|
24337
26115
|
}
|
|
24338
26116
|
function scanForNuasiteUsage(cwd) {
|
|
24339
26117
|
const srcDir = join3(cwd, "src");
|
|
24340
|
-
if (!
|
|
26118
|
+
if (!existsSync5(srcDir))
|
|
24341
26119
|
return [];
|
|
24342
26120
|
const results = [];
|
|
24343
26121
|
try {
|
|
@@ -24372,7 +26150,7 @@ async function clean({ cwd = process.cwd(), dryRun = false, yes = false } = {})
|
|
|
24372
26150
|
return;
|
|
24373
26151
|
}
|
|
24374
26152
|
const pkgPath = join3(cwd, "package.json");
|
|
24375
|
-
if (!
|
|
26153
|
+
if (!existsSync5(pkgPath)) {
|
|
24376
26154
|
console.error("No package.json found.");
|
|
24377
26155
|
process.exit(1);
|
|
24378
26156
|
}
|
|
@@ -24480,7 +26258,7 @@ var init_config = () => {};
|
|
|
24480
26258
|
|
|
24481
26259
|
// ../cms/src/component-registry.ts
|
|
24482
26260
|
import fs2 from "fs/promises";
|
|
24483
|
-
import
|
|
26261
|
+
import path7 from "path";
|
|
24484
26262
|
|
|
24485
26263
|
class ComponentRegistry {
|
|
24486
26264
|
components = new Map;
|
|
@@ -24490,7 +26268,7 @@ class ComponentRegistry {
|
|
|
24490
26268
|
}
|
|
24491
26269
|
async scan() {
|
|
24492
26270
|
for (const dir of this.componentDirs) {
|
|
24493
|
-
const fullPath =
|
|
26271
|
+
const fullPath = path7.join(getProjectRoot(), dir);
|
|
24494
26272
|
try {
|
|
24495
26273
|
await this.scanDirectory(fullPath, dir);
|
|
24496
26274
|
} catch {}
|
|
@@ -24505,8 +26283,8 @@ class ComponentRegistry {
|
|
|
24505
26283
|
async scanDirectory(dir, relativePath) {
|
|
24506
26284
|
const entries = await fs2.readdir(dir, { withFileTypes: true });
|
|
24507
26285
|
for (const entry of entries) {
|
|
24508
|
-
const fullPath =
|
|
24509
|
-
const relPath =
|
|
26286
|
+
const fullPath = path7.join(dir, entry.name);
|
|
26287
|
+
const relPath = path7.join(relativePath, entry.name);
|
|
24510
26288
|
if (entry.isDirectory()) {
|
|
24511
26289
|
await this.scanDirectory(fullPath, relPath);
|
|
24512
26290
|
} else if (entry.isFile() && entry.name.endsWith(".astro")) {
|
|
@@ -24517,7 +26295,7 @@ class ComponentRegistry {
|
|
|
24517
26295
|
async parseComponent(filePath, relativePath) {
|
|
24518
26296
|
try {
|
|
24519
26297
|
const content = await fs2.readFile(filePath, "utf-8");
|
|
24520
|
-
const componentName =
|
|
26298
|
+
const componentName = path7.basename(filePath, ".astro");
|
|
24521
26299
|
const props = await this.extractProps(content);
|
|
24522
26300
|
const slots = this.extractSlots(content);
|
|
24523
26301
|
const description = this.extractDescription(content);
|
|
@@ -24663,18 +26441,18 @@ ${propsContent}
|
|
|
24663
26441
|
return null;
|
|
24664
26442
|
const startIndex = match.index + match[0].length;
|
|
24665
26443
|
let depth = 1;
|
|
24666
|
-
let
|
|
24667
|
-
while (
|
|
24668
|
-
if (text[
|
|
26444
|
+
let i2 = startIndex;
|
|
26445
|
+
while (i2 < text.length && depth > 0) {
|
|
26446
|
+
if (text[i2] === "{") {
|
|
24669
26447
|
depth++;
|
|
24670
|
-
} else if (text[
|
|
26448
|
+
} else if (text[i2] === "}") {
|
|
24671
26449
|
depth--;
|
|
24672
26450
|
}
|
|
24673
|
-
|
|
26451
|
+
i2++;
|
|
24674
26452
|
}
|
|
24675
26453
|
if (depth !== 0)
|
|
24676
26454
|
return null;
|
|
24677
|
-
return text.substring(startIndex,
|
|
26455
|
+
return text.substring(startIndex, i2 - 1);
|
|
24678
26456
|
}
|
|
24679
26457
|
async extractProps(content) {
|
|
24680
26458
|
const props = [];
|
|
@@ -24772,7 +26550,7 @@ function slugify2(text) {
|
|
|
24772
26550
|
|
|
24773
26551
|
// ../cms/src/utils.ts
|
|
24774
26552
|
import { createHash } from "crypto";
|
|
24775
|
-
import
|
|
26553
|
+
import path8 from "path";
|
|
24776
26554
|
function normalizePagePath(url) {
|
|
24777
26555
|
let pathname;
|
|
24778
26556
|
try {
|
|
@@ -24811,7 +26589,7 @@ function generateSourceFileHashes(entries) {
|
|
|
24811
26589
|
}
|
|
24812
26590
|
const hashes = {};
|
|
24813
26591
|
for (const [filePath, fileEntries] of Object.entries(entriesByFile)) {
|
|
24814
|
-
const sorted = fileEntries.sort((a,
|
|
26592
|
+
const sorted = fileEntries.sort((a, b2) => (a.sourceLine || 0) - (b2.sourceLine || 0));
|
|
24815
26593
|
const content = sorted.map((e) => `${e.sourceLine || 0}|${e.text}|${e.sourceSnippet || ""}`).join(`
|
|
24816
26594
|
`);
|
|
24817
26595
|
hashes[filePath] = sha256(content);
|
|
@@ -24825,27 +26603,27 @@ function escapeReplacement(str) {
|
|
|
24825
26603
|
return str.replace(/\$/g, "$$$$");
|
|
24826
26604
|
}
|
|
24827
26605
|
function resolveSourcePath(sourcePath) {
|
|
24828
|
-
return
|
|
26606
|
+
return path8.isAbsolute(sourcePath) ? sourcePath : path8.join(getProjectRoot(), sourcePath);
|
|
24829
26607
|
}
|
|
24830
26608
|
function resolveAndValidatePath(filePath) {
|
|
24831
26609
|
const projectRoot = getProjectRoot();
|
|
24832
|
-
const resolvedRoot =
|
|
26610
|
+
const resolvedRoot = path8.resolve(projectRoot);
|
|
24833
26611
|
const isAbsoluteFs = filePath.startsWith(resolvedRoot);
|
|
24834
26612
|
const normalizedPath = !isAbsoluteFs && filePath.startsWith("/") ? filePath.slice(1) : filePath;
|
|
24835
|
-
const fullPath =
|
|
24836
|
-
if (!fullPath.startsWith(resolvedRoot +
|
|
26613
|
+
const fullPath = path8.isAbsolute(normalizedPath) ? path8.resolve(normalizedPath) : path8.resolve(projectRoot, normalizedPath);
|
|
26614
|
+
if (!fullPath.startsWith(resolvedRoot + path8.sep) && fullPath !== resolvedRoot) {
|
|
24837
26615
|
throw new Error(`Path traversal detected: ${filePath}`);
|
|
24838
26616
|
}
|
|
24839
26617
|
return fullPath;
|
|
24840
26618
|
}
|
|
24841
26619
|
async function acquireFileLock(filePath) {
|
|
24842
|
-
const key =
|
|
26620
|
+
const key = path8.resolve(filePath);
|
|
24843
26621
|
while (fileLocks.has(key)) {
|
|
24844
26622
|
await fileLocks.get(key);
|
|
24845
26623
|
}
|
|
24846
26624
|
let release;
|
|
24847
|
-
const lockPromise = new Promise((
|
|
24848
|
-
release =
|
|
26625
|
+
const lockPromise = new Promise((resolve2) => {
|
|
26626
|
+
release = resolve2;
|
|
24849
26627
|
});
|
|
24850
26628
|
fileLocks.set(key, lockPromise);
|
|
24851
26629
|
return () => {
|
|
@@ -24857,8 +26635,8 @@ function escapeHtml2(text) {
|
|
|
24857
26635
|
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
24858
26636
|
}
|
|
24859
26637
|
function relativeImportPath2(fromFile, toFile) {
|
|
24860
|
-
const fromDir =
|
|
24861
|
-
let rel =
|
|
26638
|
+
const fromDir = path8.dirname(fromFile);
|
|
26639
|
+
let rel = path8.relative(fromDir, toFile).split(path8.sep).join("/");
|
|
24862
26640
|
if (!rel.startsWith("."))
|
|
24863
26641
|
rel = `./${rel}`;
|
|
24864
26642
|
return rel;
|
|
@@ -24871,7 +26649,7 @@ var init_utils2 = __esm(() => {
|
|
|
24871
26649
|
|
|
24872
26650
|
// ../cms/src/handlers/component-ops.ts
|
|
24873
26651
|
import fs3 from "fs/promises";
|
|
24874
|
-
import
|
|
26652
|
+
import path9 from "path";
|
|
24875
26653
|
async function handleInsertComponent(request, manifestWriter) {
|
|
24876
26654
|
const { position, referenceComponentId, componentName, props, meta } = request;
|
|
24877
26655
|
if (!meta?.url) {
|
|
@@ -25012,12 +26790,12 @@ async function handleRemoveComponent(request, manifestWriter) {
|
|
|
25012
26790
|
function findComponentBounds(lines, startLineIndex, componentName) {
|
|
25013
26791
|
const startLine = startLineIndex;
|
|
25014
26792
|
let tagClosed = false;
|
|
25015
|
-
for (let
|
|
25016
|
-
const currentLine = lines[
|
|
26793
|
+
for (let i2 = startLineIndex;i2 < lines.length; i2++) {
|
|
26794
|
+
const currentLine = lines[i2];
|
|
25017
26795
|
const selfCloseIdx = currentLine.indexOf("/>");
|
|
25018
26796
|
const openEndIdx = currentLine.indexOf(">");
|
|
25019
26797
|
if (selfCloseIdx >= 0 && (openEndIdx < 0 || selfCloseIdx <= openEndIdx)) {
|
|
25020
|
-
return { startLine, endLine:
|
|
26798
|
+
return { startLine, endLine: i2 };
|
|
25021
26799
|
}
|
|
25022
26800
|
if (openEndIdx >= 0) {
|
|
25023
26801
|
tagClosed = true;
|
|
@@ -25031,8 +26809,8 @@ function findComponentBounds(lines, startLineIndex, componentName) {
|
|
|
25031
26809
|
const closingTag = `</${componentName}>`;
|
|
25032
26810
|
let depth = 1;
|
|
25033
26811
|
let endLine = startLineIndex;
|
|
25034
|
-
for (let
|
|
25035
|
-
const currentLine = lines[
|
|
26812
|
+
for (let i2 = startLineIndex + 1;i2 < lines.length; i2++) {
|
|
26813
|
+
const currentLine = lines[i2];
|
|
25036
26814
|
const openingMatches = currentLine.match(new RegExp(`<${escapedName}(?:\\s|>)`, "g"));
|
|
25037
26815
|
if (openingMatches) {
|
|
25038
26816
|
for (const match of openingMatches) {
|
|
@@ -25048,7 +26826,7 @@ function findComponentBounds(lines, startLineIndex, componentName) {
|
|
|
25048
26826
|
depth -= closingMatches.length;
|
|
25049
26827
|
}
|
|
25050
26828
|
if (depth <= 0) {
|
|
25051
|
-
endLine =
|
|
26829
|
+
endLine = i2;
|
|
25052
26830
|
break;
|
|
25053
26831
|
}
|
|
25054
26832
|
}
|
|
@@ -25089,7 +26867,7 @@ function getComponentOccurrenceIndex(manifest, referenceComponent) {
|
|
|
25089
26867
|
async function findComponentInvocationFile(projectRoot, pageUrl, manifest, referenceComponent) {
|
|
25090
26868
|
if (referenceComponent.invocationSourcePath) {
|
|
25091
26869
|
const filePath = normalizeFilePath(referenceComponent.invocationSourcePath);
|
|
25092
|
-
const fullPath =
|
|
26870
|
+
const fullPath = path9.resolve(projectRoot, filePath);
|
|
25093
26871
|
try {
|
|
25094
26872
|
const content = await fs3.readFile(fullPath, "utf-8");
|
|
25095
26873
|
const lines = content.split(`
|
|
@@ -25103,7 +26881,7 @@ async function findComponentInvocationFile(projectRoot, pageUrl, manifest, refer
|
|
|
25103
26881
|
const candidates = getPageFileCandidates(pageUrl);
|
|
25104
26882
|
const occurrenceIndex = getComponentOccurrenceIndex(manifest, referenceComponent);
|
|
25105
26883
|
for (const candidate of candidates) {
|
|
25106
|
-
const fullPath =
|
|
26884
|
+
const fullPath = path9.resolve(projectRoot, candidate);
|
|
25107
26885
|
try {
|
|
25108
26886
|
const content = await fs3.readFile(fullPath, "utf-8");
|
|
25109
26887
|
const lines = content.split(`
|
|
@@ -25119,22 +26897,22 @@ async function findComponentInvocationFile(projectRoot, pageUrl, manifest, refer
|
|
|
25119
26897
|
function findComponentInvocationLine(lines, componentName, occurrenceIndex) {
|
|
25120
26898
|
const pattern = new RegExp(`<${escapeRegex(componentName)}(?:\\s|>|/>|$)`);
|
|
25121
26899
|
const startLine = findFrontmatterEnd(lines);
|
|
25122
|
-
let
|
|
25123
|
-
for (let
|
|
25124
|
-
if (pattern.test(lines[
|
|
25125
|
-
if (
|
|
25126
|
-
return
|
|
25127
|
-
|
|
26900
|
+
let found2 = 0;
|
|
26901
|
+
for (let i2 = startLine;i2 < lines.length; i2++) {
|
|
26902
|
+
if (pattern.test(lines[i2])) {
|
|
26903
|
+
if (found2 === occurrenceIndex)
|
|
26904
|
+
return i2;
|
|
26905
|
+
found2++;
|
|
25128
26906
|
}
|
|
25129
26907
|
}
|
|
25130
|
-
return
|
|
26908
|
+
return found2 > 0 ? findComponentInvocationLine(lines, componentName, 0) : -1;
|
|
25131
26909
|
}
|
|
25132
26910
|
function findFrontmatterEnd(lines) {
|
|
25133
26911
|
if (lines.length === 0 || lines[0].trim() !== "---")
|
|
25134
26912
|
return 0;
|
|
25135
|
-
for (let
|
|
25136
|
-
if (lines[
|
|
25137
|
-
return
|
|
26913
|
+
for (let i2 = 1;i2 < lines.length; i2++) {
|
|
26914
|
+
if (lines[i2].trim() === "---")
|
|
26915
|
+
return i2 + 1;
|
|
25138
26916
|
}
|
|
25139
26917
|
return 0;
|
|
25140
26918
|
}
|
|
@@ -25163,7 +26941,7 @@ function getIndentation(line) {
|
|
|
25163
26941
|
function normalizeFilePath(p) {
|
|
25164
26942
|
if (!p.startsWith("/"))
|
|
25165
26943
|
return p;
|
|
25166
|
-
const projectRoot =
|
|
26944
|
+
const projectRoot = path9.resolve(getProjectRoot());
|
|
25167
26945
|
if (p.startsWith(projectRoot))
|
|
25168
26946
|
return p;
|
|
25169
26947
|
return p.slice(1);
|
|
@@ -25171,17 +26949,17 @@ function normalizeFilePath(p) {
|
|
|
25171
26949
|
function ensureComponentImport(lines, componentName, componentFile, targetFile) {
|
|
25172
26950
|
const importPattern = new RegExp(`import\\s+${escapeRegex(componentName)}\\s+from\\s+['"]`);
|
|
25173
26951
|
const frontmatterEnd = findFrontmatterEnd(lines);
|
|
25174
|
-
for (let
|
|
25175
|
-
if (importPattern.test(lines[
|
|
26952
|
+
for (let i2 = 0;i2 < frontmatterEnd; i2++) {
|
|
26953
|
+
if (importPattern.test(lines[i2])) {
|
|
25176
26954
|
return;
|
|
25177
26955
|
}
|
|
25178
26956
|
}
|
|
25179
26957
|
const importStatement = `import ${componentName} from '${relativeImportPath2(targetFile, componentFile)}'`;
|
|
25180
26958
|
if (frontmatterEnd > 0) {
|
|
25181
26959
|
let insertAt = 1;
|
|
25182
|
-
for (let
|
|
25183
|
-
if (/^\s*import\s/.test(lines[
|
|
25184
|
-
insertAt =
|
|
26960
|
+
for (let i2 = 1;i2 < frontmatterEnd - 1; i2++) {
|
|
26961
|
+
if (/^\s*import\s/.test(lines[i2])) {
|
|
26962
|
+
insertAt = i2 + 1;
|
|
25185
26963
|
}
|
|
25186
26964
|
}
|
|
25187
26965
|
lines.splice(insertAt, 0, importStatement);
|
|
@@ -25218,11 +26996,11 @@ function buildMapPattern(varName) {
|
|
|
25218
26996
|
}
|
|
25219
26997
|
function detectArrayPattern(lines, invocationLineIndex) {
|
|
25220
26998
|
const searchStart = Math.max(0, invocationLineIndex - 5);
|
|
25221
|
-
for (let
|
|
25222
|
-
const line = lines[
|
|
26999
|
+
for (let i2 = invocationLineIndex;i2 >= searchStart; i2--) {
|
|
27000
|
+
const line = lines[i2];
|
|
25223
27001
|
const match = line.match(new RegExp(buildMapPattern()));
|
|
25224
27002
|
if (match) {
|
|
25225
|
-
return { arrayVarName: match[1], mapLineIndex:
|
|
27003
|
+
return { arrayVarName: match[1], mapLineIndex: i2 };
|
|
25226
27004
|
}
|
|
25227
27005
|
}
|
|
25228
27006
|
return null;
|
|
@@ -25284,10 +27062,10 @@ async function resolveArrayContext(component, manifest, pageUrl) {
|
|
|
25284
27062
|
let mapLineIndex = -1;
|
|
25285
27063
|
let occurrencesSeen = 0;
|
|
25286
27064
|
const mapPattern = new RegExp(buildMapPattern(arrayVarName));
|
|
25287
|
-
for (let
|
|
25288
|
-
if (mapPattern.test(lines2[
|
|
27065
|
+
for (let i2 = fmEnd2;i2 < lines2.length; i2++) {
|
|
27066
|
+
if (mapPattern.test(lines2[i2])) {
|
|
25289
27067
|
if (occurrencesSeen === mapOccurrence) {
|
|
25290
|
-
mapLineIndex =
|
|
27068
|
+
mapLineIndex = i2;
|
|
25291
27069
|
break;
|
|
25292
27070
|
}
|
|
25293
27071
|
occurrencesSeen++;
|
|
@@ -25301,7 +27079,7 @@ async function resolveArrayContext(component, manifest, pageUrl) {
|
|
|
25301
27079
|
const elementBounds2 = findArrayDeclaration(frontmatterContent2, frontmatterStartLine2, arrayVarName);
|
|
25302
27080
|
if (!elementBounds2 || elementBounds2.length === 0)
|
|
25303
27081
|
return null;
|
|
25304
|
-
const sameSourceComponents2 = Object.values(manifest.components).filter((c) => c.componentName === component.componentName && c.invocationSourcePath === component.invocationSourcePath).sort((a,
|
|
27082
|
+
const sameSourceComponents2 = Object.values(manifest.components).filter((c) => c.componentName === component.componentName && c.invocationSourcePath === component.invocationSourcePath).sort((a, b2) => (a.invocationIndex ?? 0) - (b2.invocationIndex ?? 0));
|
|
25305
27083
|
const arrayIndex2 = sameSourceComponents2.findIndex((c) => c.id === component.id);
|
|
25306
27084
|
if (arrayIndex2 < 0 || arrayIndex2 >= elementBounds2.length)
|
|
25307
27085
|
return null;
|
|
@@ -25348,7 +27126,7 @@ async function resolveArrayContext(component, manifest, pageUrl) {
|
|
|
25348
27126
|
return null;
|
|
25349
27127
|
}
|
|
25350
27128
|
const occurrenceIndex = getComponentOccurrenceIndex(manifest, component);
|
|
25351
|
-
const sameSourceComponents = Object.values(manifest.components).filter((c) => c.componentName === component.componentName && c.invocationSourcePath === component.invocationSourcePath).sort((a,
|
|
27129
|
+
const sameSourceComponents = Object.values(manifest.components).filter((c) => c.componentName === component.componentName && c.invocationSourcePath === component.invocationSourcePath).sort((a, b2) => (a.invocationIndex ?? 0) - (b2.invocationIndex ?? 0));
|
|
25352
27130
|
const arrayIndex = sameSourceComponents.findIndex((c) => c.id === component.id);
|
|
25353
27131
|
if (arrayIndex < 0 || arrayIndex >= elementBounds.length) {
|
|
25354
27132
|
return null;
|
|
@@ -25480,8 +27258,8 @@ async function handleAddArrayItem(request, manifestWriter) {
|
|
|
25480
27258
|
const newElement = generateObjectLiteral(props);
|
|
25481
27259
|
const indentation = getIndentation(freshLines[refBounds.startLine]);
|
|
25482
27260
|
const indentedLines = newElement.split(`
|
|
25483
|
-
`).map((line,
|
|
25484
|
-
if (
|
|
27261
|
+
`).map((line, i2) => {
|
|
27262
|
+
if (i2 === 0)
|
|
25485
27263
|
return indentation + line;
|
|
25486
27264
|
if (line.trim())
|
|
25487
27265
|
return indentation + line;
|
|
@@ -25505,11 +27283,11 @@ async function handleAddArrayItem(request, manifestWriter) {
|
|
|
25505
27283
|
const addedLineCount = indentedLines.split(`
|
|
25506
27284
|
`).length;
|
|
25507
27285
|
const closingSearchStart = lastEl.endLine + addedLineCount + 1;
|
|
25508
|
-
for (let
|
|
25509
|
-
if (freshLines[
|
|
25510
|
-
const prev = freshLines[
|
|
27286
|
+
for (let i2 = closingSearchStart;i2 < closingSearchStart + 5 && i2 < freshLines.length; i2++) {
|
|
27287
|
+
if (freshLines[i2].trim().startsWith("]")) {
|
|
27288
|
+
const prev = freshLines[i2 - 1];
|
|
25511
27289
|
if (prev?.trimEnd().endsWith(",")) {
|
|
25512
|
-
freshLines[
|
|
27290
|
+
freshLines[i2 - 1] = prev.replace(/,(\s*)$/, "$1");
|
|
25513
27291
|
}
|
|
25514
27292
|
break;
|
|
25515
27293
|
}
|
|
@@ -25571,45 +27349,45 @@ var init_array_ops = __esm(() => {
|
|
|
25571
27349
|
// ../cms/src/astro-image-paths.ts
|
|
25572
27350
|
import { createHash as createHash2 } from "crypto";
|
|
25573
27351
|
import fs5 from "fs/promises";
|
|
25574
|
-
import
|
|
27352
|
+
import path10 from "path";
|
|
25575
27353
|
function isHugoStyleEntry(entryAbsPath) {
|
|
25576
|
-
return HUGO_INDEX_RE.test(
|
|
27354
|
+
return HUGO_INDEX_RE.test(path10.basename(entryAbsPath));
|
|
25577
27355
|
}
|
|
25578
27356
|
function shortContentHash(buf) {
|
|
25579
27357
|
return createHash2("sha256").update(buf).digest("hex").slice(0, 8);
|
|
25580
27358
|
}
|
|
25581
27359
|
async function pickAstroImageTarget(args) {
|
|
25582
|
-
const entryDir =
|
|
27360
|
+
const entryDir = path10.dirname(args.entryAbsPath);
|
|
25583
27361
|
const isHugoStyle = isHugoStyleEntry(args.entryAbsPath);
|
|
25584
|
-
const safeFilename =
|
|
27362
|
+
const safeFilename = path10.basename(args.originalFilename);
|
|
25585
27363
|
if (!safeFilename || safeFilename === "." || safeFilename === "..") {
|
|
25586
27364
|
throw new Error(`Invalid filename: ${args.originalFilename}`);
|
|
25587
27365
|
}
|
|
25588
27366
|
const baseName = isHugoStyle ? safeFilename : `${args.slug}-${safeFilename}`;
|
|
25589
|
-
const baseAbs =
|
|
27367
|
+
const baseAbs = path10.join(entryDir, baseName);
|
|
25590
27368
|
if (await isFreeOrMatching(baseAbs, args.compareBuffer)) {
|
|
25591
27369
|
return { absPath: baseAbs, relPath: `./${baseName}` };
|
|
25592
27370
|
}
|
|
25593
27371
|
const candidateAbs = await pickHashedSibling(entryDir, baseName, args.compareBuffer);
|
|
25594
|
-
return { absPath: candidateAbs, relPath: `./${
|
|
27372
|
+
return { absPath: candidateAbs, relPath: `./${path10.basename(candidateAbs)}` };
|
|
25595
27373
|
}
|
|
25596
27374
|
async function pickSiblingTarget(dir, filename, buf) {
|
|
25597
|
-
const safe =
|
|
27375
|
+
const safe = path10.basename(filename);
|
|
25598
27376
|
if (!safe || safe === "." || safe === "..") {
|
|
25599
27377
|
throw new Error(`Invalid filename: ${filename}`);
|
|
25600
27378
|
}
|
|
25601
|
-
const baseAbs =
|
|
27379
|
+
const baseAbs = path10.join(dir, safe);
|
|
25602
27380
|
if (await isFreeOrMatching(baseAbs, buf))
|
|
25603
27381
|
return baseAbs;
|
|
25604
27382
|
return pickHashedSibling(dir, safe, buf);
|
|
25605
27383
|
}
|
|
25606
27384
|
async function pickHashedSibling(dir, baseName, buf) {
|
|
25607
27385
|
const hash = shortContentHash(buf);
|
|
25608
|
-
const ext =
|
|
25609
|
-
const stem =
|
|
27386
|
+
const ext = path10.extname(baseName);
|
|
27387
|
+
const stem = path10.basename(baseName, ext);
|
|
25610
27388
|
for (let attempt = 0;attempt < 5; attempt++) {
|
|
25611
27389
|
const suffix = attempt === 0 ? hash : `${hash}-${attempt}`;
|
|
25612
|
-
const candidateAbs =
|
|
27390
|
+
const candidateAbs = path10.join(dir, `${stem}-${suffix}${ext}`);
|
|
25613
27391
|
if (await isFreeOrMatching(candidateAbs, buf))
|
|
25614
27392
|
return candidateAbs;
|
|
25615
27393
|
}
|
|
@@ -25633,7 +27411,7 @@ var init_astro_image_paths = __esm(() => {
|
|
|
25633
27411
|
|
|
25634
27412
|
// ../cms/src/handlers/astro-image-upload.ts
|
|
25635
27413
|
import fs6 from "fs/promises";
|
|
25636
|
-
import
|
|
27414
|
+
import path11 from "path";
|
|
25637
27415
|
async function tryAstroImageUpload(args) {
|
|
25638
27416
|
const { collection, entry, field } = args.context;
|
|
25639
27417
|
if (!collection || !entry || !field)
|
|
@@ -25642,7 +27420,7 @@ async function tryAstroImageUpload(args) {
|
|
|
25642
27420
|
const def = definitions[collection];
|
|
25643
27421
|
if (!def)
|
|
25644
27422
|
return null;
|
|
25645
|
-
const fieldDef = def.fields.find((
|
|
27423
|
+
const fieldDef = def.fields.find((f2) => f2.name === field);
|
|
25646
27424
|
if (!fieldDef?.astroImage)
|
|
25647
27425
|
return null;
|
|
25648
27426
|
const entryInfo = def.entries?.find((e) => e.slug === entry);
|
|
@@ -25655,12 +27433,12 @@ async function tryAstroImageUpload(args) {
|
|
|
25655
27433
|
originalFilename: args.originalFilename,
|
|
25656
27434
|
compareBuffer: args.fileBuffer
|
|
25657
27435
|
});
|
|
25658
|
-
await fs6.mkdir(
|
|
27436
|
+
await fs6.mkdir(path11.dirname(target.absPath), { recursive: true });
|
|
25659
27437
|
await fs6.writeFile(target.absPath, args.fileBuffer);
|
|
25660
27438
|
return {
|
|
25661
27439
|
success: true,
|
|
25662
27440
|
url: target.relPath,
|
|
25663
|
-
filename:
|
|
27441
|
+
filename: path11.basename(target.absPath)
|
|
25664
27442
|
};
|
|
25665
27443
|
}
|
|
25666
27444
|
var init_astro_image_upload = __esm(() => {
|
|
@@ -25674,8 +27452,8 @@ async function handleCheckSlugExists(slug) {
|
|
|
25674
27452
|
const normalizedSlug = slugify2(slug);
|
|
25675
27453
|
if (!normalizedSlug)
|
|
25676
27454
|
return { exists: false };
|
|
25677
|
-
const
|
|
25678
|
-
return
|
|
27455
|
+
const found2 = await findPageFile(`/${normalizedSlug}`);
|
|
27456
|
+
return found2 ? { exists: true, filePath: found2 } : { exists: false };
|
|
25679
27457
|
}
|
|
25680
27458
|
async function fileExists(fullPath) {
|
|
25681
27459
|
try {
|
|
@@ -25707,7 +27485,7 @@ var init_page_ops2 = __esm(() => {
|
|
|
25707
27485
|
|
|
25708
27486
|
// ../cms/src/handlers/request-utils.ts
|
|
25709
27487
|
function readBody(req, maxSize = MAX_BODY_SIZE) {
|
|
25710
|
-
return new Promise((
|
|
27488
|
+
return new Promise((resolve2, reject) => {
|
|
25711
27489
|
const chunks = [];
|
|
25712
27490
|
let totalSize = 0;
|
|
25713
27491
|
req.on("data", (chunk) => {
|
|
@@ -25719,7 +27497,7 @@ function readBody(req, maxSize = MAX_BODY_SIZE) {
|
|
|
25719
27497
|
}
|
|
25720
27498
|
chunks.push(chunk);
|
|
25721
27499
|
});
|
|
25722
|
-
req.on("end", () =>
|
|
27500
|
+
req.on("end", () => resolve2(Buffer.concat(chunks)));
|
|
25723
27501
|
req.on("error", reject);
|
|
25724
27502
|
});
|
|
25725
27503
|
}
|
|
@@ -25852,7 +27630,7 @@ var require_he = __commonJS((exports, module) => {
|
|
|
25852
27630
|
var has = function(object2, propertyName) {
|
|
25853
27631
|
return hasOwnProperty2.call(object2, propertyName);
|
|
25854
27632
|
};
|
|
25855
|
-
var
|
|
27633
|
+
var contains2 = function(array, value) {
|
|
25856
27634
|
var index = -1;
|
|
25857
27635
|
var length = array.length;
|
|
25858
27636
|
while (++index < length) {
|
|
@@ -25887,7 +27665,7 @@ var require_he = __commonJS((exports, module) => {
|
|
|
25887
27665
|
}
|
|
25888
27666
|
return decodeMapNumeric[codePoint];
|
|
25889
27667
|
}
|
|
25890
|
-
if (strict &&
|
|
27668
|
+
if (strict && contains2(invalidReferenceCodePoints, codePoint)) {
|
|
25891
27669
|
parseError("disallowed character reference");
|
|
25892
27670
|
}
|
|
25893
27671
|
if (codePoint > 65535) {
|
|
@@ -25907,8 +27685,8 @@ var require_he = __commonJS((exports, module) => {
|
|
|
25907
27685
|
var parseError = function(message) {
|
|
25908
27686
|
throw Error("Parse error: " + message);
|
|
25909
27687
|
};
|
|
25910
|
-
var
|
|
25911
|
-
options = merge(options,
|
|
27688
|
+
var encode2 = function(string, options) {
|
|
27689
|
+
options = merge(options, encode2.options);
|
|
25912
27690
|
var strict = options.strict;
|
|
25913
27691
|
if (strict && regexInvalidRawCodePoint.test(string)) {
|
|
25914
27692
|
parseError("forbidden code point");
|
|
@@ -25955,15 +27733,15 @@ var require_he = __commonJS((exports, module) => {
|
|
|
25955
27733
|
return escapeCodePoint(codePoint);
|
|
25956
27734
|
}).replace(regexBmpWhitelist, escapeBmpSymbol);
|
|
25957
27735
|
};
|
|
25958
|
-
|
|
27736
|
+
encode2.options = {
|
|
25959
27737
|
allowUnsafeSymbols: false,
|
|
25960
27738
|
encodeEverything: false,
|
|
25961
27739
|
strict: false,
|
|
25962
27740
|
useNamedReferences: false,
|
|
25963
27741
|
decimal: false
|
|
25964
27742
|
};
|
|
25965
|
-
var
|
|
25966
|
-
options = merge(options,
|
|
27743
|
+
var decode2 = function(html, options) {
|
|
27744
|
+
options = merge(options, decode2.options);
|
|
25967
27745
|
var strict = options.strict;
|
|
25968
27746
|
if (strict && regexInvalidEntity.test(html)) {
|
|
25969
27747
|
parseError("malformed character reference");
|
|
@@ -26018,7 +27796,7 @@ var require_he = __commonJS((exports, module) => {
|
|
|
26018
27796
|
return $0;
|
|
26019
27797
|
});
|
|
26020
27798
|
};
|
|
26021
|
-
|
|
27799
|
+
decode2.options = {
|
|
26022
27800
|
isAttributeValue: false,
|
|
26023
27801
|
strict: false
|
|
26024
27802
|
};
|
|
@@ -26029,10 +27807,10 @@ var require_he = __commonJS((exports, module) => {
|
|
|
26029
27807
|
};
|
|
26030
27808
|
var he = {
|
|
26031
27809
|
version: "1.2.0",
|
|
26032
|
-
encode,
|
|
26033
|
-
decode,
|
|
27810
|
+
encode: encode2,
|
|
27811
|
+
decode: decode2,
|
|
26034
27812
|
escape,
|
|
26035
|
-
unescape:
|
|
27813
|
+
unescape: decode2
|
|
26036
27814
|
};
|
|
26037
27815
|
if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
|
|
26038
27816
|
define(function() {
|
|
@@ -26166,30 +27944,30 @@ var require_lib2 = __commonJS((exports) => {
|
|
|
26166
27944
|
// ../../node_modules/domhandler/lib/node.js
|
|
26167
27945
|
var require_node2 = __commonJS((exports) => {
|
|
26168
27946
|
var __extends = exports && exports.__extends || function() {
|
|
26169
|
-
var extendStatics = function(
|
|
26170
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(
|
|
26171
|
-
|
|
26172
|
-
} || function(
|
|
26173
|
-
for (var p in
|
|
26174
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
26175
|
-
|
|
27947
|
+
var extendStatics = function(d3, b2) {
|
|
27948
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d4, b3) {
|
|
27949
|
+
d4.__proto__ = b3;
|
|
27950
|
+
} || function(d4, b3) {
|
|
27951
|
+
for (var p in b3)
|
|
27952
|
+
if (Object.prototype.hasOwnProperty.call(b3, p))
|
|
27953
|
+
d4[p] = b3[p];
|
|
26176
27954
|
};
|
|
26177
|
-
return extendStatics(
|
|
27955
|
+
return extendStatics(d3, b2);
|
|
26178
27956
|
};
|
|
26179
|
-
return function(
|
|
26180
|
-
if (typeof
|
|
26181
|
-
throw new TypeError("Class extends value " + String(
|
|
26182
|
-
extendStatics(
|
|
27957
|
+
return function(d3, b2) {
|
|
27958
|
+
if (typeof b2 !== "function" && b2 !== null)
|
|
27959
|
+
throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
|
|
27960
|
+
extendStatics(d3, b2);
|
|
26183
27961
|
function __() {
|
|
26184
|
-
this.constructor =
|
|
27962
|
+
this.constructor = d3;
|
|
26185
27963
|
}
|
|
26186
|
-
|
|
27964
|
+
d3.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __);
|
|
26187
27965
|
};
|
|
26188
27966
|
}();
|
|
26189
27967
|
var __assign = exports && exports.__assign || function() {
|
|
26190
27968
|
__assign = Object.assign || function(t) {
|
|
26191
|
-
for (var s,
|
|
26192
|
-
s = arguments[
|
|
27969
|
+
for (var s, i2 = 1, n2 = arguments.length;i2 < n2; i2++) {
|
|
27970
|
+
s = arguments[i2];
|
|
26193
27971
|
for (var p in s)
|
|
26194
27972
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
26195
27973
|
t[p] = s[p];
|
|
@@ -26533,9 +28311,9 @@ var require_node2 = __commonJS((exports) => {
|
|
|
26533
28311
|
var children = childs.map(function(child) {
|
|
26534
28312
|
return cloneNode(child, true);
|
|
26535
28313
|
});
|
|
26536
|
-
for (var
|
|
26537
|
-
children[
|
|
26538
|
-
children[
|
|
28314
|
+
for (var i2 = 1;i2 < children.length; i2++) {
|
|
28315
|
+
children[i2].prev = children[i2 - 1];
|
|
28316
|
+
children[i2 - 1].next = children[i2];
|
|
26539
28317
|
}
|
|
26540
28318
|
return children;
|
|
26541
28319
|
}
|
|
@@ -26543,25 +28321,25 @@ var require_node2 = __commonJS((exports) => {
|
|
|
26543
28321
|
|
|
26544
28322
|
// ../../node_modules/domhandler/lib/index.js
|
|
26545
28323
|
var require_lib3 = __commonJS((exports) => {
|
|
26546
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o,
|
|
28324
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
26547
28325
|
if (k2 === undefined)
|
|
26548
28326
|
k2 = k;
|
|
26549
|
-
var desc = Object.getOwnPropertyDescriptor(
|
|
26550
|
-
if (!desc || ("get" in desc ? !
|
|
28327
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k);
|
|
28328
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
26551
28329
|
desc = { enumerable: true, get: function() {
|
|
26552
|
-
return
|
|
28330
|
+
return m2[k];
|
|
26553
28331
|
} };
|
|
26554
28332
|
}
|
|
26555
28333
|
Object.defineProperty(o, k2, desc);
|
|
26556
|
-
} : function(o,
|
|
28334
|
+
} : function(o, m2, k, k2) {
|
|
26557
28335
|
if (k2 === undefined)
|
|
26558
28336
|
k2 = k;
|
|
26559
|
-
o[k2] =
|
|
28337
|
+
o[k2] = m2[k];
|
|
26560
28338
|
});
|
|
26561
|
-
var __exportStar = exports && exports.__exportStar || function(
|
|
26562
|
-
for (var p in
|
|
28339
|
+
var __exportStar = exports && exports.__exportStar || function(m2, exports2) {
|
|
28340
|
+
for (var p in m2)
|
|
26563
28341
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
26564
|
-
__createBinding(exports2,
|
|
28342
|
+
__createBinding(exports2, m2, p);
|
|
26565
28343
|
};
|
|
26566
28344
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26567
28345
|
exports.DomHandler = undefined;
|
|
@@ -26775,25 +28553,25 @@ var require_decode_codepoint = __commonJS((exports) => {
|
|
|
26775
28553
|
|
|
26776
28554
|
// ../../node_modules/dom-serializer/node_modules/entities/lib/decode.js
|
|
26777
28555
|
var require_decode = __commonJS((exports) => {
|
|
26778
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o,
|
|
28556
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
26779
28557
|
if (k2 === undefined)
|
|
26780
28558
|
k2 = k;
|
|
26781
|
-
var desc = Object.getOwnPropertyDescriptor(
|
|
26782
|
-
if (!desc || ("get" in desc ? !
|
|
28559
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k);
|
|
28560
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
26783
28561
|
desc = { enumerable: true, get: function() {
|
|
26784
|
-
return
|
|
28562
|
+
return m2[k];
|
|
26785
28563
|
} };
|
|
26786
28564
|
}
|
|
26787
28565
|
Object.defineProperty(o, k2, desc);
|
|
26788
|
-
} : function(o,
|
|
28566
|
+
} : function(o, m2, k, k2) {
|
|
26789
28567
|
if (k2 === undefined)
|
|
26790
28568
|
k2 = k;
|
|
26791
|
-
o[k2] =
|
|
28569
|
+
o[k2] = m2[k];
|
|
26792
28570
|
});
|
|
26793
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o,
|
|
26794
|
-
Object.defineProperty(o, "default", { enumerable: true, value:
|
|
26795
|
-
} : function(o,
|
|
26796
|
-
o["default"] =
|
|
28571
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v2) {
|
|
28572
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v2 });
|
|
28573
|
+
} : function(o, v2) {
|
|
28574
|
+
o["default"] = v2;
|
|
26797
28575
|
});
|
|
26798
28576
|
var __importStar = exports && exports.__importStar || function(mod) {
|
|
26799
28577
|
if (mod && mod.__esModule)
|
|
@@ -27127,8 +28905,8 @@ var require_decode = __commonJS((exports) => {
|
|
|
27127
28905
|
var require_encode_html = __commonJS((exports) => {
|
|
27128
28906
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27129
28907
|
function restoreDiff(arr) {
|
|
27130
|
-
for (var
|
|
27131
|
-
arr[
|
|
28908
|
+
for (var i2 = 1;i2 < arr.length; i2++) {
|
|
28909
|
+
arr[i2][0] += arr[i2 - 1][0] + 1;
|
|
27132
28910
|
}
|
|
27133
28911
|
return arr;
|
|
27134
28912
|
}
|
|
@@ -27157,14 +28935,14 @@ var require_escape = __commonJS((exports) => {
|
|
|
27157
28935
|
var lastIdx = 0;
|
|
27158
28936
|
var match;
|
|
27159
28937
|
while ((match = exports.xmlReplacer.exec(str)) !== null) {
|
|
27160
|
-
var
|
|
27161
|
-
var char = str.charCodeAt(
|
|
28938
|
+
var i2 = match.index;
|
|
28939
|
+
var char = str.charCodeAt(i2);
|
|
27162
28940
|
var next = xmlCodeMap.get(char);
|
|
27163
28941
|
if (next !== undefined) {
|
|
27164
|
-
ret += str.substring(lastIdx,
|
|
27165
|
-
lastIdx =
|
|
28942
|
+
ret += str.substring(lastIdx, i2) + next;
|
|
28943
|
+
lastIdx = i2 + 1;
|
|
27166
28944
|
} else {
|
|
27167
|
-
ret += "".concat(str.substring(lastIdx,
|
|
28945
|
+
ret += "".concat(str.substring(lastIdx, i2), "&#x").concat((0, exports.getCodePoint)(str, i2).toString(16), ";");
|
|
27168
28946
|
lastIdx = exports.xmlReplacer.lastIndex += Number((char & 64512) === 55296);
|
|
27169
28947
|
}
|
|
27170
28948
|
}
|
|
@@ -27224,13 +29002,13 @@ var require_encode = __commonJS((exports) => {
|
|
|
27224
29002
|
var lastIdx = 0;
|
|
27225
29003
|
var match;
|
|
27226
29004
|
while ((match = regExp.exec(str)) !== null) {
|
|
27227
|
-
var
|
|
27228
|
-
ret += str.substring(lastIdx,
|
|
27229
|
-
var char = str.charCodeAt(
|
|
29005
|
+
var i2 = match.index;
|
|
29006
|
+
ret += str.substring(lastIdx, i2);
|
|
29007
|
+
var char = str.charCodeAt(i2);
|
|
27230
29008
|
var next = encode_html_js_1.default.get(char);
|
|
27231
29009
|
if (typeof next === "object") {
|
|
27232
|
-
if (
|
|
27233
|
-
var nextChar = str.charCodeAt(
|
|
29010
|
+
if (i2 + 1 < str.length) {
|
|
29011
|
+
var nextChar = str.charCodeAt(i2 + 1);
|
|
27234
29012
|
var value = typeof next.n === "number" ? next.n === nextChar ? next.o : undefined : next.n.get(nextChar);
|
|
27235
29013
|
if (value !== undefined) {
|
|
27236
29014
|
ret += value;
|
|
@@ -27242,9 +29020,9 @@ var require_encode = __commonJS((exports) => {
|
|
|
27242
29020
|
}
|
|
27243
29021
|
if (next !== undefined) {
|
|
27244
29022
|
ret += next;
|
|
27245
|
-
lastIdx =
|
|
29023
|
+
lastIdx = i2 + 1;
|
|
27246
29024
|
} else {
|
|
27247
|
-
var cp = (0, escape_js_1.getCodePoint)(str,
|
|
29025
|
+
var cp = (0, escape_js_1.getCodePoint)(str, i2);
|
|
27248
29026
|
ret += "&#x".concat(cp.toString(16), ";");
|
|
27249
29027
|
lastIdx = regExp.lastIndex += Number(cp !== char);
|
|
27250
29028
|
}
|
|
@@ -27273,7 +29051,7 @@ var require_lib4 = __commonJS((exports) => {
|
|
|
27273
29051
|
EncodingMode2[EncodingMode2["Attribute"] = 3] = "Attribute";
|
|
27274
29052
|
EncodingMode2[EncodingMode2["Text"] = 4] = "Text";
|
|
27275
29053
|
})(EncodingMode = exports.EncodingMode || (exports.EncodingMode = {}));
|
|
27276
|
-
function
|
|
29054
|
+
function decode2(data, options) {
|
|
27277
29055
|
if (options === undefined) {
|
|
27278
29056
|
options = EntityLevel.XML;
|
|
27279
29057
|
}
|
|
@@ -27284,7 +29062,7 @@ var require_lib4 = __commonJS((exports) => {
|
|
|
27284
29062
|
}
|
|
27285
29063
|
return (0, decode_js_1.decodeXML)(data);
|
|
27286
29064
|
}
|
|
27287
|
-
exports.decode =
|
|
29065
|
+
exports.decode = decode2;
|
|
27288
29066
|
function decodeStrict(data, options) {
|
|
27289
29067
|
var _a;
|
|
27290
29068
|
if (options === undefined) {
|
|
@@ -27292,10 +29070,10 @@ var require_lib4 = __commonJS((exports) => {
|
|
|
27292
29070
|
}
|
|
27293
29071
|
var opts = typeof options === "number" ? { level: options } : options;
|
|
27294
29072
|
(_a = opts.mode) !== null && _a !== undefined || (opts.mode = decode_js_1.DecodingMode.Strict);
|
|
27295
|
-
return
|
|
29073
|
+
return decode2(data, opts);
|
|
27296
29074
|
}
|
|
27297
29075
|
exports.decodeStrict = decodeStrict;
|
|
27298
|
-
function
|
|
29076
|
+
function encode2(data, options) {
|
|
27299
29077
|
if (options === undefined) {
|
|
27300
29078
|
options = EntityLevel.XML;
|
|
27301
29079
|
}
|
|
@@ -27314,7 +29092,7 @@ var require_lib4 = __commonJS((exports) => {
|
|
|
27314
29092
|
}
|
|
27315
29093
|
return (0, escape_js_1.encodeXML)(data);
|
|
27316
29094
|
}
|
|
27317
|
-
exports.encode =
|
|
29095
|
+
exports.encode = encode2;
|
|
27318
29096
|
var escape_js_2 = require_escape();
|
|
27319
29097
|
Object.defineProperty(exports, "encodeXML", { enumerable: true, get: function() {
|
|
27320
29098
|
return escape_js_2.encodeXML;
|
|
@@ -27494,8 +29272,8 @@ var require_foreignNames = __commonJS((exports) => {
|
|
|
27494
29272
|
var require_lib5 = __commonJS((exports) => {
|
|
27495
29273
|
var __assign = exports && exports.__assign || function() {
|
|
27496
29274
|
__assign = Object.assign || function(t) {
|
|
27497
|
-
for (var s,
|
|
27498
|
-
s = arguments[
|
|
29275
|
+
for (var s, i2 = 1, n2 = arguments.length;i2 < n2; i2++) {
|
|
29276
|
+
s = arguments[i2];
|
|
27499
29277
|
for (var p in s)
|
|
27500
29278
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
27501
29279
|
t[p] = s[p];
|
|
@@ -27504,25 +29282,25 @@ var require_lib5 = __commonJS((exports) => {
|
|
|
27504
29282
|
};
|
|
27505
29283
|
return __assign.apply(this, arguments);
|
|
27506
29284
|
};
|
|
27507
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o,
|
|
29285
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
27508
29286
|
if (k2 === undefined)
|
|
27509
29287
|
k2 = k;
|
|
27510
|
-
var desc = Object.getOwnPropertyDescriptor(
|
|
27511
|
-
if (!desc || ("get" in desc ? !
|
|
29288
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k);
|
|
29289
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
27512
29290
|
desc = { enumerable: true, get: function() {
|
|
27513
|
-
return
|
|
29291
|
+
return m2[k];
|
|
27514
29292
|
} };
|
|
27515
29293
|
}
|
|
27516
29294
|
Object.defineProperty(o, k2, desc);
|
|
27517
|
-
} : function(o,
|
|
29295
|
+
} : function(o, m2, k, k2) {
|
|
27518
29296
|
if (k2 === undefined)
|
|
27519
29297
|
k2 = k;
|
|
27520
|
-
o[k2] =
|
|
29298
|
+
o[k2] = m2[k];
|
|
27521
29299
|
});
|
|
27522
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o,
|
|
27523
|
-
Object.defineProperty(o, "default", { enumerable: true, value:
|
|
27524
|
-
} : function(o,
|
|
27525
|
-
o["default"] =
|
|
29300
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v2) {
|
|
29301
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v2 });
|
|
29302
|
+
} : function(o, v2) {
|
|
29303
|
+
o["default"] = v2;
|
|
27526
29304
|
});
|
|
27527
29305
|
var __importStar = exports && exports.__importStar || function(mod) {
|
|
27528
29306
|
if (mod && mod.__esModule)
|
|
@@ -27558,7 +29336,7 @@ var require_lib5 = __commonJS((exports) => {
|
|
|
27558
29336
|
var _a;
|
|
27559
29337
|
if (!attributes)
|
|
27560
29338
|
return;
|
|
27561
|
-
var
|
|
29339
|
+
var encode2 = ((_a = opts.encodeEntities) !== null && _a !== undefined ? _a : opts.decodeEntities) === false ? replaceQuotes : opts.xmlMode || opts.encodeEntities !== "utf8" ? entities_1.encodeXML : entities_1.escapeAttribute;
|
|
27562
29340
|
return Object.keys(attributes).map(function(key) {
|
|
27563
29341
|
var _a2, _b;
|
|
27564
29342
|
var value = (_a2 = attributes[key]) !== null && _a2 !== undefined ? _a2 : "";
|
|
@@ -27568,7 +29346,7 @@ var require_lib5 = __commonJS((exports) => {
|
|
|
27568
29346
|
if (!opts.emptyAttrs && !opts.xmlMode && value === "") {
|
|
27569
29347
|
return key;
|
|
27570
29348
|
}
|
|
27571
|
-
return "".concat(key, '="').concat(
|
|
29349
|
+
return "".concat(key, '="').concat(encode2(value), '"');
|
|
27572
29350
|
}).join(" ");
|
|
27573
29351
|
}
|
|
27574
29352
|
var singleTag = new Set([
|
|
@@ -27598,8 +29376,8 @@ var require_lib5 = __commonJS((exports) => {
|
|
|
27598
29376
|
}
|
|
27599
29377
|
var nodes = "length" in node ? node : [node];
|
|
27600
29378
|
var output = "";
|
|
27601
|
-
for (var
|
|
27602
|
-
output += renderNode(nodes[
|
|
29379
|
+
for (var i2 = 0;i2 < nodes.length; i2++) {
|
|
29380
|
+
output += renderNode(nodes[i2], options);
|
|
27603
29381
|
}
|
|
27604
29382
|
return output;
|
|
27605
29383
|
}
|
|
@@ -27955,15 +29733,15 @@ var require_querying = __commonJS((exports) => {
|
|
|
27955
29733
|
recurse = true;
|
|
27956
29734
|
}
|
|
27957
29735
|
var searchedNodes = Array.isArray(nodes) ? nodes : [nodes];
|
|
27958
|
-
for (var
|
|
27959
|
-
var node = searchedNodes[
|
|
29736
|
+
for (var i2 = 0;i2 < searchedNodes.length; i2++) {
|
|
29737
|
+
var node = searchedNodes[i2];
|
|
27960
29738
|
if ((0, domhandler_1.isTag)(node) && test(node)) {
|
|
27961
29739
|
return node;
|
|
27962
29740
|
}
|
|
27963
29741
|
if (recurse && (0, domhandler_1.hasChildren)(node) && node.children.length > 0) {
|
|
27964
|
-
var
|
|
27965
|
-
if (
|
|
27966
|
-
return
|
|
29742
|
+
var found2 = findOne(test, node.children, true);
|
|
29743
|
+
if (found2)
|
|
29744
|
+
return found2;
|
|
27967
29745
|
}
|
|
27968
29746
|
}
|
|
27969
29747
|
return null;
|
|
@@ -28052,9 +29830,9 @@ var require_legacy = __commonJS((exports) => {
|
|
|
28052
29830
|
return (0, domhandler_1.isTag)(elem) && elem.attribs[attrib] === value;
|
|
28053
29831
|
};
|
|
28054
29832
|
}
|
|
28055
|
-
function combineFuncs(a,
|
|
29833
|
+
function combineFuncs(a, b2) {
|
|
28056
29834
|
return function(elem) {
|
|
28057
|
-
return a(elem) ||
|
|
29835
|
+
return a(elem) || b2(elem);
|
|
28058
29836
|
};
|
|
28059
29837
|
}
|
|
28060
29838
|
function compileTest(options) {
|
|
@@ -28185,11 +29963,11 @@ var require_helpers = __commonJS((exports) => {
|
|
|
28185
29963
|
return DocumentPosition.PRECEDING;
|
|
28186
29964
|
}
|
|
28187
29965
|
function uniqueSort(nodes) {
|
|
28188
|
-
nodes = nodes.filter(function(node,
|
|
28189
|
-
return !arr.includes(node,
|
|
29966
|
+
nodes = nodes.filter(function(node, i2, arr) {
|
|
29967
|
+
return !arr.includes(node, i2 + 1);
|
|
28190
29968
|
});
|
|
28191
|
-
nodes.sort(function(a,
|
|
28192
|
-
var relative = compareDocumentPosition(a,
|
|
29969
|
+
nodes.sort(function(a, b2) {
|
|
29970
|
+
var relative = compareDocumentPosition(a, b2);
|
|
28193
29971
|
if (relative & DocumentPosition.PRECEDING) {
|
|
28194
29972
|
return -1;
|
|
28195
29973
|
} else if (relative & DocumentPosition.FOLLOWING) {
|
|
@@ -28340,25 +30118,25 @@ var require_feeds = __commonJS((exports) => {
|
|
|
28340
30118
|
|
|
28341
30119
|
// ../../node_modules/domutils/lib/index.js
|
|
28342
30120
|
var require_lib6 = __commonJS((exports) => {
|
|
28343
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o,
|
|
30121
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
28344
30122
|
if (k2 === undefined)
|
|
28345
30123
|
k2 = k;
|
|
28346
|
-
var desc = Object.getOwnPropertyDescriptor(
|
|
28347
|
-
if (!desc || ("get" in desc ? !
|
|
30124
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k);
|
|
30125
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
28348
30126
|
desc = { enumerable: true, get: function() {
|
|
28349
|
-
return
|
|
30127
|
+
return m2[k];
|
|
28350
30128
|
} };
|
|
28351
30129
|
}
|
|
28352
30130
|
Object.defineProperty(o, k2, desc);
|
|
28353
|
-
} : function(o,
|
|
30131
|
+
} : function(o, m2, k, k2) {
|
|
28354
30132
|
if (k2 === undefined)
|
|
28355
30133
|
k2 = k;
|
|
28356
|
-
o[k2] =
|
|
30134
|
+
o[k2] = m2[k];
|
|
28357
30135
|
});
|
|
28358
|
-
var __exportStar = exports && exports.__exportStar || function(
|
|
28359
|
-
for (var p in
|
|
30136
|
+
var __exportStar = exports && exports.__exportStar || function(m2, exports2) {
|
|
30137
|
+
for (var p in m2)
|
|
28360
30138
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
28361
|
-
__createBinding(exports2,
|
|
30139
|
+
__createBinding(exports2, m2, p);
|
|
28362
30140
|
};
|
|
28363
30141
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28364
30142
|
exports.hasChildren = exports.isDocument = exports.isComment = exports.isText = exports.isCDATA = exports.isTag = undefined;
|
|
@@ -28478,7 +30256,7 @@ var require_parse = __commonJS((exports) => {
|
|
|
28478
30256
|
}
|
|
28479
30257
|
exports.isTraversal = isTraversal;
|
|
28480
30258
|
var stripQuotesFromPseudos = new Set(["contains", "icontains"]);
|
|
28481
|
-
function funescape(
|
|
30259
|
+
function funescape(_2, escaped, escapedWhitespace) {
|
|
28482
30260
|
var high = parseInt(escaped, 16) - 65536;
|
|
28483
30261
|
return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320);
|
|
28484
30262
|
}
|
|
@@ -28491,7 +30269,7 @@ var require_parse = __commonJS((exports) => {
|
|
|
28491
30269
|
function isWhitespace(c) {
|
|
28492
30270
|
return c === 32 || c === 9 || c === 10 || c === 12 || c === 13;
|
|
28493
30271
|
}
|
|
28494
|
-
function
|
|
30272
|
+
function parse3(selector) {
|
|
28495
30273
|
var subselects = [];
|
|
28496
30274
|
var endIndex = parseSelector(subselects, "".concat(selector), 0);
|
|
28497
30275
|
if (endIndex < selector.length) {
|
|
@@ -28499,7 +30277,7 @@ var require_parse = __commonJS((exports) => {
|
|
|
28499
30277
|
}
|
|
28500
30278
|
return subselects;
|
|
28501
30279
|
}
|
|
28502
|
-
exports.parse =
|
|
30280
|
+
exports.parse = parse3;
|
|
28503
30281
|
function parseSelector(subselects, selector, selectorIndex) {
|
|
28504
30282
|
var tokens = [];
|
|
28505
30283
|
function getName(offset) {
|
|
@@ -28787,11 +30565,11 @@ var require_parse = __commonJS((exports) => {
|
|
|
28787
30565
|
var require_stringify3 = __commonJS((exports) => {
|
|
28788
30566
|
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|
28789
30567
|
if (pack || arguments.length === 2)
|
|
28790
|
-
for (var
|
|
28791
|
-
if (ar || !(
|
|
30568
|
+
for (var i2 = 0, l = from.length, ar;i2 < l; i2++) {
|
|
30569
|
+
if (ar || !(i2 in from)) {
|
|
28792
30570
|
if (!ar)
|
|
28793
|
-
ar = Array.prototype.slice.call(from, 0,
|
|
28794
|
-
ar[
|
|
30571
|
+
ar = Array.prototype.slice.call(from, 0, i2);
|
|
30572
|
+
ar[i2] = from[i2];
|
|
28795
30573
|
}
|
|
28796
30574
|
}
|
|
28797
30575
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
@@ -28895,10 +30673,10 @@ var require_stringify3 = __commonJS((exports) => {
|
|
|
28895
30673
|
function escapeName(str, charsToEscape) {
|
|
28896
30674
|
var lastIdx = 0;
|
|
28897
30675
|
var ret = "";
|
|
28898
|
-
for (var
|
|
28899
|
-
if (charsToEscape.has(str.charCodeAt(
|
|
28900
|
-
ret += "".concat(str.slice(lastIdx,
|
|
28901
|
-
lastIdx =
|
|
30676
|
+
for (var i2 = 0;i2 < str.length; i2++) {
|
|
30677
|
+
if (charsToEscape.has(str.charCodeAt(i2))) {
|
|
30678
|
+
ret += "".concat(str.slice(lastIdx, i2), "\\").concat(str.charAt(i2));
|
|
30679
|
+
lastIdx = i2 + 1;
|
|
28902
30680
|
}
|
|
28903
30681
|
}
|
|
28904
30682
|
return ret.length > 0 ? ret + str.slice(lastIdx) : str;
|
|
@@ -28907,25 +30685,25 @@ var require_stringify3 = __commonJS((exports) => {
|
|
|
28907
30685
|
|
|
28908
30686
|
// ../../node_modules/css-what/lib/commonjs/index.js
|
|
28909
30687
|
var require_commonjs = __commonJS((exports) => {
|
|
28910
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o,
|
|
30688
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
28911
30689
|
if (k2 === undefined)
|
|
28912
30690
|
k2 = k;
|
|
28913
|
-
var desc = Object.getOwnPropertyDescriptor(
|
|
28914
|
-
if (!desc || ("get" in desc ? !
|
|
30691
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k);
|
|
30692
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
28915
30693
|
desc = { enumerable: true, get: function() {
|
|
28916
|
-
return
|
|
30694
|
+
return m2[k];
|
|
28917
30695
|
} };
|
|
28918
30696
|
}
|
|
28919
30697
|
Object.defineProperty(o, k2, desc);
|
|
28920
|
-
} : function(o,
|
|
30698
|
+
} : function(o, m2, k, k2) {
|
|
28921
30699
|
if (k2 === undefined)
|
|
28922
30700
|
k2 = k;
|
|
28923
|
-
o[k2] =
|
|
30701
|
+
o[k2] = m2[k];
|
|
28924
30702
|
});
|
|
28925
|
-
var __exportStar = exports && exports.__exportStar || function(
|
|
28926
|
-
for (var p in
|
|
30703
|
+
var __exportStar = exports && exports.__exportStar || function(m2, exports2) {
|
|
30704
|
+
for (var p in m2)
|
|
28927
30705
|
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
28928
|
-
__createBinding(exports2,
|
|
30706
|
+
__createBinding(exports2, m2, p);
|
|
28929
30707
|
};
|
|
28930
30708
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28931
30709
|
exports.stringify = exports.parse = exports.isTraversal = undefined;
|
|
@@ -28968,11 +30746,11 @@ var require_sort = __commonJS((exports) => {
|
|
|
28968
30746
|
]);
|
|
28969
30747
|
function sortByProcedure(arr) {
|
|
28970
30748
|
var procs = arr.map(getProcedure);
|
|
28971
|
-
for (var
|
|
28972
|
-
var procNew = procs[
|
|
30749
|
+
for (var i2 = 1;i2 < arr.length; i2++) {
|
|
30750
|
+
var procNew = procs[i2];
|
|
28973
30751
|
if (procNew < 0)
|
|
28974
30752
|
continue;
|
|
28975
|
-
for (var j =
|
|
30753
|
+
for (var j = i2 - 1;j >= 0 && procNew < procs[j]; j--) {
|
|
28976
30754
|
var token = arr[j + 1];
|
|
28977
30755
|
arr[j + 1] = arr[j];
|
|
28978
30756
|
arr[j] = token;
|
|
@@ -28999,8 +30777,8 @@ var require_sort = __commonJS((exports) => {
|
|
|
28999
30777
|
} else if (token.name === "has" || token.name === "contains") {
|
|
29000
30778
|
proc = 0;
|
|
29001
30779
|
} else if (Array.isArray(token.data)) {
|
|
29002
|
-
proc = Math.min.apply(Math, token.data.map(function(
|
|
29003
|
-
return Math.min.apply(Math,
|
|
30780
|
+
proc = Math.min.apply(Math, token.data.map(function(d3) {
|
|
30781
|
+
return Math.min.apply(Math, d3.map(getProcedure));
|
|
29004
30782
|
}));
|
|
29005
30783
|
if (proc < 0) {
|
|
29006
30784
|
proc = 0;
|
|
@@ -29215,7 +30993,7 @@ var require_parse2 = __commonJS((exports) => {
|
|
|
29215
30993
|
var whitespace = new Set([9, 10, 12, 13, 32]);
|
|
29216
30994
|
var ZERO = 48;
|
|
29217
30995
|
var NINE = 57;
|
|
29218
|
-
function
|
|
30996
|
+
function parse3(formula) {
|
|
29219
30997
|
formula = formula.trim().toLowerCase();
|
|
29220
30998
|
if (formula === "even") {
|
|
29221
30999
|
return [2, 0];
|
|
@@ -29267,7 +31045,7 @@ var require_parse2 = __commonJS((exports) => {
|
|
|
29267
31045
|
}
|
|
29268
31046
|
}
|
|
29269
31047
|
}
|
|
29270
|
-
exports.parse =
|
|
31048
|
+
exports.parse = parse3;
|
|
29271
31049
|
});
|
|
29272
31050
|
|
|
29273
31051
|
// ../../node_modules/nth-check/lib/compile.js
|
|
@@ -29280,53 +31058,53 @@ var require_compile = __commonJS((exports) => {
|
|
|
29280
31058
|
var boolbase_1 = __importDefault(require_boolbase());
|
|
29281
31059
|
function compile(parsed) {
|
|
29282
31060
|
var a = parsed[0];
|
|
29283
|
-
var
|
|
29284
|
-
if (
|
|
31061
|
+
var b2 = parsed[1] - 1;
|
|
31062
|
+
if (b2 < 0 && a <= 0)
|
|
29285
31063
|
return boolbase_1.default.falseFunc;
|
|
29286
31064
|
if (a === -1)
|
|
29287
31065
|
return function(index) {
|
|
29288
|
-
return index <=
|
|
31066
|
+
return index <= b2;
|
|
29289
31067
|
};
|
|
29290
31068
|
if (a === 0)
|
|
29291
31069
|
return function(index) {
|
|
29292
|
-
return index ===
|
|
31070
|
+
return index === b2;
|
|
29293
31071
|
};
|
|
29294
31072
|
if (a === 1)
|
|
29295
|
-
return
|
|
29296
|
-
return index >=
|
|
31073
|
+
return b2 < 0 ? boolbase_1.default.trueFunc : function(index) {
|
|
31074
|
+
return index >= b2;
|
|
29297
31075
|
};
|
|
29298
31076
|
var absA = Math.abs(a);
|
|
29299
|
-
var bMod = (
|
|
31077
|
+
var bMod = (b2 % absA + absA) % absA;
|
|
29300
31078
|
return a > 1 ? function(index) {
|
|
29301
|
-
return index >=
|
|
31079
|
+
return index >= b2 && index % absA === bMod;
|
|
29302
31080
|
} : function(index) {
|
|
29303
|
-
return index <=
|
|
31081
|
+
return index <= b2 && index % absA === bMod;
|
|
29304
31082
|
};
|
|
29305
31083
|
}
|
|
29306
31084
|
exports.compile = compile;
|
|
29307
31085
|
function generate(parsed) {
|
|
29308
31086
|
var a = parsed[0];
|
|
29309
|
-
var
|
|
29310
|
-
var
|
|
31087
|
+
var b2 = parsed[1] - 1;
|
|
31088
|
+
var n2 = 0;
|
|
29311
31089
|
if (a < 0) {
|
|
29312
31090
|
var aPos_1 = -a;
|
|
29313
|
-
var minValue_1 = (
|
|
31091
|
+
var minValue_1 = (b2 % aPos_1 + aPos_1) % aPos_1;
|
|
29314
31092
|
return function() {
|
|
29315
|
-
var val = minValue_1 + aPos_1 *
|
|
29316
|
-
return val >
|
|
31093
|
+
var val = minValue_1 + aPos_1 * n2++;
|
|
31094
|
+
return val > b2 ? null : val;
|
|
29317
31095
|
};
|
|
29318
31096
|
}
|
|
29319
31097
|
if (a === 0)
|
|
29320
|
-
return
|
|
31098
|
+
return b2 < 0 ? function() {
|
|
29321
31099
|
return null;
|
|
29322
31100
|
} : function() {
|
|
29323
|
-
return
|
|
31101
|
+
return n2++ === 0 ? b2 : null;
|
|
29324
31102
|
};
|
|
29325
|
-
if (
|
|
29326
|
-
|
|
31103
|
+
if (b2 < 0) {
|
|
31104
|
+
b2 += a * Math.ceil(-b2 / a);
|
|
29327
31105
|
}
|
|
29328
31106
|
return function() {
|
|
29329
|
-
return a *
|
|
31107
|
+
return a * n2++ + b2;
|
|
29330
31108
|
};
|
|
29331
31109
|
}
|
|
29332
31110
|
exports.generate = generate;
|
|
@@ -29375,7 +31153,7 @@ var require_filters = __commonJS((exports) => {
|
|
|
29375
31153
|
exports.filters = {
|
|
29376
31154
|
contains: function(next, text, _a) {
|
|
29377
31155
|
var adapter = _a.adapter;
|
|
29378
|
-
return function
|
|
31156
|
+
return function contains2(elem) {
|
|
29379
31157
|
return next(elem) && adapter.getText(elem).includes(text);
|
|
29380
31158
|
};
|
|
29381
31159
|
},
|
|
@@ -29396,10 +31174,10 @@ var require_filters = __commonJS((exports) => {
|
|
|
29396
31174
|
return function nthChild(elem) {
|
|
29397
31175
|
var siblings = adapter.getSiblings(elem);
|
|
29398
31176
|
var pos = 0;
|
|
29399
|
-
for (var
|
|
29400
|
-
if (equals(elem, siblings[
|
|
31177
|
+
for (var i2 = 0;i2 < siblings.length; i2++) {
|
|
31178
|
+
if (equals(elem, siblings[i2]))
|
|
29401
31179
|
break;
|
|
29402
|
-
if (adapter.isTag(siblings[
|
|
31180
|
+
if (adapter.isTag(siblings[i2])) {
|
|
29403
31181
|
pos++;
|
|
29404
31182
|
}
|
|
29405
31183
|
}
|
|
@@ -29416,10 +31194,10 @@ var require_filters = __commonJS((exports) => {
|
|
|
29416
31194
|
return function nthLastChild(elem) {
|
|
29417
31195
|
var siblings = adapter.getSiblings(elem);
|
|
29418
31196
|
var pos = 0;
|
|
29419
|
-
for (var
|
|
29420
|
-
if (equals(elem, siblings[
|
|
31197
|
+
for (var i2 = siblings.length - 1;i2 >= 0; i2--) {
|
|
31198
|
+
if (equals(elem, siblings[i2]))
|
|
29421
31199
|
break;
|
|
29422
|
-
if (adapter.isTag(siblings[
|
|
31200
|
+
if (adapter.isTag(siblings[i2])) {
|
|
29423
31201
|
pos++;
|
|
29424
31202
|
}
|
|
29425
31203
|
}
|
|
@@ -29436,8 +31214,8 @@ var require_filters = __commonJS((exports) => {
|
|
|
29436
31214
|
return function nthOfType(elem) {
|
|
29437
31215
|
var siblings = adapter.getSiblings(elem);
|
|
29438
31216
|
var pos = 0;
|
|
29439
|
-
for (var
|
|
29440
|
-
var currentSibling = siblings[
|
|
31217
|
+
for (var i2 = 0;i2 < siblings.length; i2++) {
|
|
31218
|
+
var currentSibling = siblings[i2];
|
|
29441
31219
|
if (equals(elem, currentSibling))
|
|
29442
31220
|
break;
|
|
29443
31221
|
if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === adapter.getName(elem)) {
|
|
@@ -29457,8 +31235,8 @@ var require_filters = __commonJS((exports) => {
|
|
|
29457
31235
|
return function nthLastOfType(elem) {
|
|
29458
31236
|
var siblings = adapter.getSiblings(elem);
|
|
29459
31237
|
var pos = 0;
|
|
29460
|
-
for (var
|
|
29461
|
-
var currentSibling = siblings[
|
|
31238
|
+
for (var i2 = siblings.length - 1;i2 >= 0; i2--) {
|
|
31239
|
+
var currentSibling = siblings[i2];
|
|
29462
31240
|
if (equals(elem, currentSibling))
|
|
29463
31241
|
break;
|
|
29464
31242
|
if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === adapter.getName(elem)) {
|
|
@@ -29531,10 +31309,10 @@ var require_pseudos = __commonJS((exports) => {
|
|
|
29531
31309
|
"last-child": function(elem, _a) {
|
|
29532
31310
|
var { adapter, equals } = _a;
|
|
29533
31311
|
var siblings = adapter.getSiblings(elem);
|
|
29534
|
-
for (var
|
|
29535
|
-
if (equals(elem, siblings[
|
|
31312
|
+
for (var i2 = siblings.length - 1;i2 >= 0; i2--) {
|
|
31313
|
+
if (equals(elem, siblings[i2]))
|
|
29536
31314
|
return true;
|
|
29537
|
-
if (adapter.isTag(siblings[
|
|
31315
|
+
if (adapter.isTag(siblings[i2]))
|
|
29538
31316
|
break;
|
|
29539
31317
|
}
|
|
29540
31318
|
return false;
|
|
@@ -29543,8 +31321,8 @@ var require_pseudos = __commonJS((exports) => {
|
|
|
29543
31321
|
var { adapter, equals } = _a;
|
|
29544
31322
|
var siblings = adapter.getSiblings(elem);
|
|
29545
31323
|
var elemName = adapter.getName(elem);
|
|
29546
|
-
for (var
|
|
29547
|
-
var currentSibling = siblings[
|
|
31324
|
+
for (var i2 = 0;i2 < siblings.length; i2++) {
|
|
31325
|
+
var currentSibling = siblings[i2];
|
|
29548
31326
|
if (equals(elem, currentSibling))
|
|
29549
31327
|
return true;
|
|
29550
31328
|
if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === elemName) {
|
|
@@ -29557,8 +31335,8 @@ var require_pseudos = __commonJS((exports) => {
|
|
|
29557
31335
|
var { adapter, equals } = _a;
|
|
29558
31336
|
var siblings = adapter.getSiblings(elem);
|
|
29559
31337
|
var elemName = adapter.getName(elem);
|
|
29560
|
-
for (var
|
|
29561
|
-
var currentSibling = siblings[
|
|
31338
|
+
for (var i2 = siblings.length - 1;i2 >= 0; i2--) {
|
|
31339
|
+
var currentSibling = siblings[i2];
|
|
29562
31340
|
if (equals(elem, currentSibling))
|
|
29563
31341
|
return true;
|
|
29564
31342
|
if (adapter.isTag(currentSibling) && adapter.getName(currentSibling) === elemName) {
|
|
@@ -29629,11 +31407,11 @@ var require_aliases = __commonJS((exports) => {
|
|
|
29629
31407
|
var require_subselects = __commonJS((exports) => {
|
|
29630
31408
|
var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
|
|
29631
31409
|
if (pack || arguments.length === 2)
|
|
29632
|
-
for (var
|
|
29633
|
-
if (ar || !(
|
|
31410
|
+
for (var i2 = 0, l = from.length, ar;i2 < l; i2++) {
|
|
31411
|
+
if (ar || !(i2 in from)) {
|
|
29634
31412
|
if (!ar)
|
|
29635
|
-
ar = Array.prototype.slice.call(from, 0,
|
|
29636
|
-
ar[
|
|
31413
|
+
ar = Array.prototype.slice.call(from, 0, i2);
|
|
31414
|
+
ar[i2] = from[i2];
|
|
29637
31415
|
}
|
|
29638
31416
|
}
|
|
29639
31417
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
@@ -29877,8 +31655,8 @@ var require_general = __commonJS((exports) => {
|
|
|
29877
31655
|
case css_what_1.SelectorType.Sibling: {
|
|
29878
31656
|
return function sibling(elem) {
|
|
29879
31657
|
var siblings = adapter.getSiblings(elem);
|
|
29880
|
-
for (var
|
|
29881
|
-
var currentSibling = siblings[
|
|
31658
|
+
for (var i2 = 0;i2 < siblings.length; i2++) {
|
|
31659
|
+
var currentSibling = siblings[i2];
|
|
29882
31660
|
if (equals(elem, currentSibling))
|
|
29883
31661
|
break;
|
|
29884
31662
|
if (adapter.isTag(currentSibling) && next(currentSibling)) {
|
|
@@ -29898,8 +31676,8 @@ var require_general = __commonJS((exports) => {
|
|
|
29898
31676
|
return function adjacent(elem) {
|
|
29899
31677
|
var siblings = adapter.getSiblings(elem);
|
|
29900
31678
|
var lastElement;
|
|
29901
|
-
for (var
|
|
29902
|
-
var currentSibling = siblings[
|
|
31679
|
+
for (var i2 = 0;i2 < siblings.length; i2++) {
|
|
31680
|
+
var currentSibling = siblings[i2];
|
|
29903
31681
|
if (equals(elem, currentSibling))
|
|
29904
31682
|
break;
|
|
29905
31683
|
if (adapter.isTag(currentSibling)) {
|
|
@@ -29922,25 +31700,25 @@ var require_general = __commonJS((exports) => {
|
|
|
29922
31700
|
|
|
29923
31701
|
// ../../node_modules/css-select/lib/compile.js
|
|
29924
31702
|
var require_compile2 = __commonJS((exports) => {
|
|
29925
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o,
|
|
31703
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
29926
31704
|
if (k2 === undefined)
|
|
29927
31705
|
k2 = k;
|
|
29928
|
-
var desc = Object.getOwnPropertyDescriptor(
|
|
29929
|
-
if (!desc || ("get" in desc ? !
|
|
31706
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k);
|
|
31707
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
29930
31708
|
desc = { enumerable: true, get: function() {
|
|
29931
|
-
return
|
|
31709
|
+
return m2[k];
|
|
29932
31710
|
} };
|
|
29933
31711
|
}
|
|
29934
31712
|
Object.defineProperty(o, k2, desc);
|
|
29935
|
-
} : function(o,
|
|
31713
|
+
} : function(o, m2, k, k2) {
|
|
29936
31714
|
if (k2 === undefined)
|
|
29937
31715
|
k2 = k;
|
|
29938
|
-
o[k2] =
|
|
31716
|
+
o[k2] = m2[k];
|
|
29939
31717
|
});
|
|
29940
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o,
|
|
29941
|
-
Object.defineProperty(o, "default", { enumerable: true, value:
|
|
29942
|
-
} : function(o,
|
|
29943
|
-
o["default"] =
|
|
31718
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v2) {
|
|
31719
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v2 });
|
|
31720
|
+
} : function(o, v2) {
|
|
31721
|
+
o["default"] = v2;
|
|
29944
31722
|
});
|
|
29945
31723
|
var __importStar = exports && exports.__importStar || function(mod) {
|
|
29946
31724
|
if (mod && mod.__esModule)
|
|
@@ -30039,40 +31817,40 @@ var require_compile2 = __commonJS((exports) => {
|
|
|
30039
31817
|
return previous === boolbase_1.default.falseFunc ? boolbase_1.default.falseFunc : (0, general_js_1.compileGeneralSelector)(previous, rule, options, context, compileToken);
|
|
30040
31818
|
}, (_a = options.rootFunc) !== null && _a !== undefined ? _a : boolbase_1.default.trueFunc);
|
|
30041
31819
|
}
|
|
30042
|
-
function reduceRules(a,
|
|
30043
|
-
if (
|
|
31820
|
+
function reduceRules(a, b2) {
|
|
31821
|
+
if (b2 === boolbase_1.default.falseFunc || a === boolbase_1.default.trueFunc) {
|
|
30044
31822
|
return a;
|
|
30045
31823
|
}
|
|
30046
|
-
if (a === boolbase_1.default.falseFunc ||
|
|
30047
|
-
return
|
|
31824
|
+
if (a === boolbase_1.default.falseFunc || b2 === boolbase_1.default.trueFunc) {
|
|
31825
|
+
return b2;
|
|
30048
31826
|
}
|
|
30049
31827
|
return function combine(elem) {
|
|
30050
|
-
return a(elem) ||
|
|
31828
|
+
return a(elem) || b2(elem);
|
|
30051
31829
|
};
|
|
30052
31830
|
}
|
|
30053
31831
|
});
|
|
30054
31832
|
|
|
30055
31833
|
// ../../node_modules/css-select/lib/index.js
|
|
30056
31834
|
var require_lib8 = __commonJS((exports) => {
|
|
30057
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o,
|
|
31835
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m2, k, k2) {
|
|
30058
31836
|
if (k2 === undefined)
|
|
30059
31837
|
k2 = k;
|
|
30060
|
-
var desc = Object.getOwnPropertyDescriptor(
|
|
30061
|
-
if (!desc || ("get" in desc ? !
|
|
31838
|
+
var desc = Object.getOwnPropertyDescriptor(m2, k);
|
|
31839
|
+
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
30062
31840
|
desc = { enumerable: true, get: function() {
|
|
30063
|
-
return
|
|
31841
|
+
return m2[k];
|
|
30064
31842
|
} };
|
|
30065
31843
|
}
|
|
30066
31844
|
Object.defineProperty(o, k2, desc);
|
|
30067
|
-
} : function(o,
|
|
31845
|
+
} : function(o, m2, k, k2) {
|
|
30068
31846
|
if (k2 === undefined)
|
|
30069
31847
|
k2 = k;
|
|
30070
|
-
o[k2] =
|
|
31848
|
+
o[k2] = m2[k];
|
|
30071
31849
|
});
|
|
30072
|
-
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o,
|
|
30073
|
-
Object.defineProperty(o, "default", { enumerable: true, value:
|
|
30074
|
-
} : function(o,
|
|
30075
|
-
o["default"] =
|
|
31850
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v2) {
|
|
31851
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v2 });
|
|
31852
|
+
} : function(o, v2) {
|
|
31853
|
+
o["default"] = v2;
|
|
30076
31854
|
});
|
|
30077
31855
|
var __importStar = exports && exports.__importStar || function(mod) {
|
|
30078
31856
|
if (mod && mod.__esModule)
|
|
@@ -30095,8 +31873,8 @@ var require_lib8 = __commonJS((exports) => {
|
|
|
30095
31873
|
var boolbase_1 = __importDefault(require_boolbase());
|
|
30096
31874
|
var compile_js_1 = require_compile2();
|
|
30097
31875
|
var subselects_js_1 = require_subselects();
|
|
30098
|
-
var defaultEquals = function(a,
|
|
30099
|
-
return a ===
|
|
31876
|
+
var defaultEquals = function(a, b2) {
|
|
31877
|
+
return a === b2;
|
|
30100
31878
|
};
|
|
30101
31879
|
var defaultOptions = {
|
|
30102
31880
|
adapter: DomUtils,
|
|
@@ -30141,8 +31919,8 @@ var require_lib8 = __commonJS((exports) => {
|
|
|
30141
31919
|
function appendNextSiblings(elem, adapter) {
|
|
30142
31920
|
var elems = Array.isArray(elem) ? elem.slice(0) : [elem];
|
|
30143
31921
|
var elemsLength = elems.length;
|
|
30144
|
-
for (var
|
|
30145
|
-
var nextSiblings = (0, subselects_js_1.getNextSiblings)(elems[
|
|
31922
|
+
for (var i2 = 0;i2 < elemsLength; i2++) {
|
|
31923
|
+
var nextSiblings = (0, subselects_js_1.getNextSiblings)(elems[i2], adapter);
|
|
30146
31924
|
elems.push.apply(elems, nextSiblings);
|
|
30147
31925
|
}
|
|
30148
31926
|
return elems;
|
|
@@ -30242,8 +32020,8 @@ var require_matcher = __commonJS((exports) => {
|
|
|
30242
32020
|
}
|
|
30243
32021
|
function findOne(test, elems) {
|
|
30244
32022
|
let elem = null;
|
|
30245
|
-
for (let
|
|
30246
|
-
const el = elems[
|
|
32023
|
+
for (let i2 = 0, l = elems === null || elems === undefined ? undefined : elems.length;i2 < l && !elem; i2++) {
|
|
32024
|
+
const el = elems[i2];
|
|
30247
32025
|
if (test(el)) {
|
|
30248
32026
|
elem = el;
|
|
30249
32027
|
} else {
|
|
@@ -30257,12 +32035,12 @@ var require_matcher = __commonJS((exports) => {
|
|
|
30257
32035
|
}
|
|
30258
32036
|
function findAll(test, nodes) {
|
|
30259
32037
|
let result = [];
|
|
30260
|
-
for (let
|
|
30261
|
-
if (!isTag(nodes[
|
|
32038
|
+
for (let i2 = 0, j = nodes.length;i2 < j; i2++) {
|
|
32039
|
+
if (!isTag(nodes[i2]))
|
|
30262
32040
|
continue;
|
|
30263
|
-
if (test(nodes[
|
|
30264
|
-
result.push(nodes[
|
|
30265
|
-
const childs = getChildren(nodes[
|
|
32041
|
+
if (test(nodes[i2]))
|
|
32042
|
+
result.push(nodes[i2]);
|
|
32043
|
+
const childs = getChildren(nodes[i2]);
|
|
30266
32044
|
if (childs)
|
|
30267
32045
|
result = result.concat(findAll(test, childs));
|
|
30268
32046
|
}
|
|
@@ -30366,23 +32144,23 @@ var require_text = __commonJS((exports) => {
|
|
|
30366
32144
|
}
|
|
30367
32145
|
exports.default = TextNode;
|
|
30368
32146
|
function trimText(text) {
|
|
30369
|
-
let
|
|
32147
|
+
let i2 = 0;
|
|
30370
32148
|
let startPos;
|
|
30371
32149
|
let endPos;
|
|
30372
|
-
while (
|
|
30373
|
-
if (/\S/.test(text[
|
|
32150
|
+
while (i2 >= 0 && i2 < text.length) {
|
|
32151
|
+
if (/\S/.test(text[i2])) {
|
|
30374
32152
|
if (startPos === undefined) {
|
|
30375
|
-
startPos =
|
|
30376
|
-
|
|
32153
|
+
startPos = i2;
|
|
32154
|
+
i2 = text.length;
|
|
30377
32155
|
} else {
|
|
30378
|
-
endPos =
|
|
30379
|
-
|
|
32156
|
+
endPos = i2;
|
|
32157
|
+
i2 = undefined;
|
|
30380
32158
|
}
|
|
30381
32159
|
}
|
|
30382
32160
|
if (startPos === undefined)
|
|
30383
|
-
|
|
32161
|
+
i2++;
|
|
30384
32162
|
else
|
|
30385
|
-
|
|
32163
|
+
i2--;
|
|
30386
32164
|
}
|
|
30387
32165
|
if (startPos === undefined)
|
|
30388
32166
|
startPos = 0;
|
|
@@ -30410,7 +32188,7 @@ var require_html = __commonJS((exports) => {
|
|
|
30410
32188
|
var node_1 = __importDefault(require_node());
|
|
30411
32189
|
var text_1 = __importDefault(require_text());
|
|
30412
32190
|
var type_1 = __importDefault(require_type());
|
|
30413
|
-
function
|
|
32191
|
+
function decode2(val) {
|
|
30414
32192
|
return JSON.parse(JSON.stringify(he_1.default.decode(val)));
|
|
30415
32193
|
}
|
|
30416
32194
|
var Htags = ["h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup"];
|
|
@@ -30560,14 +32338,14 @@ var require_html = __commonJS((exports) => {
|
|
|
30560
32338
|
}, "");
|
|
30561
32339
|
}
|
|
30562
32340
|
get textContent() {
|
|
30563
|
-
return
|
|
32341
|
+
return decode2(this.rawText);
|
|
30564
32342
|
}
|
|
30565
32343
|
set textContent(val) {
|
|
30566
32344
|
const content = [new text_1.default(val, this)];
|
|
30567
32345
|
this.childNodes = content;
|
|
30568
32346
|
}
|
|
30569
32347
|
get text() {
|
|
30570
|
-
return
|
|
32348
|
+
return decode2(this.rawText);
|
|
30571
32349
|
}
|
|
30572
32350
|
get structuredText() {
|
|
30573
32351
|
let currentBlock = [];
|
|
@@ -30618,7 +32396,7 @@ var require_html = __commonJS((exports) => {
|
|
|
30618
32396
|
}).join("");
|
|
30619
32397
|
}
|
|
30620
32398
|
set innerHTML(content) {
|
|
30621
|
-
const r =
|
|
32399
|
+
const r = parse3(content, this._parseOptions);
|
|
30622
32400
|
const nodes = r.childNodes.length ? r.childNodes : [new text_1.default(content, this)];
|
|
30623
32401
|
resetParent(nodes, this);
|
|
30624
32402
|
resetParent(this.childNodes, null);
|
|
@@ -30629,7 +32407,7 @@ var require_html = __commonJS((exports) => {
|
|
|
30629
32407
|
content = [content];
|
|
30630
32408
|
} else if (typeof content == "string") {
|
|
30631
32409
|
options = Object.assign(Object.assign({}, this._parseOptions), options);
|
|
30632
|
-
const r =
|
|
32410
|
+
const r = parse3(content, options);
|
|
30633
32411
|
content = r.childNodes.length ? r.childNodes : [new text_1.default(r.innerHTML, this)];
|
|
30634
32412
|
}
|
|
30635
32413
|
resetParent(this.childNodes, null);
|
|
@@ -30643,7 +32421,7 @@ var require_html = __commonJS((exports) => {
|
|
|
30643
32421
|
if (node instanceof node_1.default) {
|
|
30644
32422
|
return [node];
|
|
30645
32423
|
} else if (typeof node == "string") {
|
|
30646
|
-
const r =
|
|
32424
|
+
const r = parse3(node, this._parseOptions);
|
|
30647
32425
|
return r.childNodes.length ? r.childNodes : [new text_1.default(node, this)];
|
|
30648
32426
|
}
|
|
30649
32427
|
return [];
|
|
@@ -30659,15 +32437,15 @@ var require_html = __commonJS((exports) => {
|
|
|
30659
32437
|
return this.toString();
|
|
30660
32438
|
}
|
|
30661
32439
|
trimRight(pattern) {
|
|
30662
|
-
for (let
|
|
30663
|
-
const childNode = this.childNodes[
|
|
32440
|
+
for (let i2 = 0;i2 < this.childNodes.length; i2++) {
|
|
32441
|
+
const childNode = this.childNodes[i2];
|
|
30664
32442
|
if (childNode.nodeType === type_1.default.ELEMENT_NODE) {
|
|
30665
32443
|
childNode.trimRight(pattern);
|
|
30666
32444
|
} else {
|
|
30667
32445
|
const index = childNode.rawText.search(pattern);
|
|
30668
32446
|
if (index > -1) {
|
|
30669
32447
|
childNode.rawText = childNode.rawText.substr(0, index);
|
|
30670
|
-
this.childNodes.length =
|
|
32448
|
+
this.childNodes.length = i2 + 1;
|
|
30671
32449
|
}
|
|
30672
32450
|
}
|
|
30673
32451
|
}
|
|
@@ -30800,8 +32578,8 @@ var require_html = __commonJS((exports) => {
|
|
|
30800
32578
|
let old = null;
|
|
30801
32579
|
function findOne(test, elems) {
|
|
30802
32580
|
let elem = null;
|
|
30803
|
-
for (let
|
|
30804
|
-
const el2 = elems[
|
|
32581
|
+
for (let i2 = 0, l = elems.length;i2 < l && !elem; i2++) {
|
|
32582
|
+
const el2 = elems[i2];
|
|
30805
32583
|
if (test(el2)) {
|
|
30806
32584
|
elem = el2;
|
|
30807
32585
|
} else {
|
|
@@ -30855,7 +32633,7 @@ var require_html = __commonJS((exports) => {
|
|
|
30855
32633
|
const attrs = this.rawAttributes;
|
|
30856
32634
|
for (const key in attrs) {
|
|
30857
32635
|
const val = attrs[key] || "";
|
|
30858
|
-
this._attrs[key.toLowerCase()] =
|
|
32636
|
+
this._attrs[key.toLowerCase()] = decode2(val);
|
|
30859
32637
|
}
|
|
30860
32638
|
return this._attrs;
|
|
30861
32639
|
}
|
|
@@ -30864,7 +32642,7 @@ var require_html = __commonJS((exports) => {
|
|
|
30864
32642
|
const attrs = this.rawAttributes;
|
|
30865
32643
|
for (const key in attrs) {
|
|
30866
32644
|
const val = attrs[key] || "";
|
|
30867
|
-
ret_attrs[key] =
|
|
32645
|
+
ret_attrs[key] = decode2(val);
|
|
30868
32646
|
}
|
|
30869
32647
|
return ret_attrs;
|
|
30870
32648
|
}
|
|
@@ -30924,7 +32702,7 @@ var require_html = __commonJS((exports) => {
|
|
|
30924
32702
|
}
|
|
30925
32703
|
attrs[key] = String(value);
|
|
30926
32704
|
if (this._attrs) {
|
|
30927
|
-
this._attrs[k2] =
|
|
32705
|
+
this._attrs[k2] = decode2(attrs[key]);
|
|
30928
32706
|
}
|
|
30929
32707
|
this.rawAttrs = Object.keys(attrs).map((name) => {
|
|
30930
32708
|
const val = this.quoteAttribute(attrs[name]);
|
|
@@ -30959,7 +32737,7 @@ var require_html = __commonJS((exports) => {
|
|
|
30959
32737
|
if (arguments.length < 2) {
|
|
30960
32738
|
throw new Error("2 arguments required");
|
|
30961
32739
|
}
|
|
30962
|
-
const p =
|
|
32740
|
+
const p = parse3(html, this._parseOptions);
|
|
30963
32741
|
if (where === "afterend") {
|
|
30964
32742
|
this.after(...p.childNodes);
|
|
30965
32743
|
} else if (where === "afterbegin") {
|
|
@@ -30998,11 +32776,11 @@ var require_html = __commonJS((exports) => {
|
|
|
30998
32776
|
get nextSibling() {
|
|
30999
32777
|
if (this.parentNode) {
|
|
31000
32778
|
const children = this.parentNode.childNodes;
|
|
31001
|
-
let
|
|
31002
|
-
while (
|
|
31003
|
-
const child = children[
|
|
32779
|
+
let i2 = 0;
|
|
32780
|
+
while (i2 < children.length) {
|
|
32781
|
+
const child = children[i2++];
|
|
31004
32782
|
if (this === child)
|
|
31005
|
-
return children[
|
|
32783
|
+
return children[i2] || null;
|
|
31006
32784
|
}
|
|
31007
32785
|
return null;
|
|
31008
32786
|
}
|
|
@@ -31010,10 +32788,10 @@ var require_html = __commonJS((exports) => {
|
|
|
31010
32788
|
get nextElementSibling() {
|
|
31011
32789
|
if (this.parentNode) {
|
|
31012
32790
|
const children = this.parentNode.childNodes;
|
|
31013
|
-
let
|
|
32791
|
+
let i2 = 0;
|
|
31014
32792
|
let find = false;
|
|
31015
|
-
while (
|
|
31016
|
-
const child = children[
|
|
32793
|
+
while (i2 < children.length) {
|
|
32794
|
+
const child = children[i2++];
|
|
31017
32795
|
if (find) {
|
|
31018
32796
|
if (child instanceof HTMLElement) {
|
|
31019
32797
|
return child || null;
|
|
@@ -31028,11 +32806,11 @@ var require_html = __commonJS((exports) => {
|
|
|
31028
32806
|
get previousSibling() {
|
|
31029
32807
|
if (this.parentNode) {
|
|
31030
32808
|
const children = this.parentNode.childNodes;
|
|
31031
|
-
let
|
|
31032
|
-
while (
|
|
31033
|
-
const child = children[--
|
|
32809
|
+
let i2 = children.length;
|
|
32810
|
+
while (i2 > 0) {
|
|
32811
|
+
const child = children[--i2];
|
|
31034
32812
|
if (this === child)
|
|
31035
|
-
return children[
|
|
32813
|
+
return children[i2 - 1] || null;
|
|
31036
32814
|
}
|
|
31037
32815
|
return null;
|
|
31038
32816
|
}
|
|
@@ -31040,10 +32818,10 @@ var require_html = __commonJS((exports) => {
|
|
|
31040
32818
|
get previousElementSibling() {
|
|
31041
32819
|
if (this.parentNode) {
|
|
31042
32820
|
const children = this.parentNode.childNodes;
|
|
31043
|
-
let
|
|
32821
|
+
let i2 = children.length;
|
|
31044
32822
|
let find = false;
|
|
31045
|
-
while (
|
|
31046
|
-
const child = children[--
|
|
32823
|
+
while (i2 > 0) {
|
|
32824
|
+
const child = children[--i2];
|
|
31047
32825
|
if (find) {
|
|
31048
32826
|
if (child instanceof HTMLElement) {
|
|
31049
32827
|
return child || null;
|
|
@@ -31083,7 +32861,7 @@ var require_html = __commonJS((exports) => {
|
|
|
31083
32861
|
return this.classList.toString();
|
|
31084
32862
|
}
|
|
31085
32863
|
clone() {
|
|
31086
|
-
return
|
|
32864
|
+
return parse3(this.toString(), this._parseOptions).firstChild;
|
|
31087
32865
|
}
|
|
31088
32866
|
}
|
|
31089
32867
|
exports.default = HTMLElement;
|
|
@@ -31260,13 +33038,13 @@ var require_html = __commonJS((exports) => {
|
|
|
31260
33038
|
}
|
|
31261
33039
|
}
|
|
31262
33040
|
if (options.closeAllByClosing === true) {
|
|
31263
|
-
let
|
|
31264
|
-
for (
|
|
31265
|
-
if (stack[
|
|
33041
|
+
let i2;
|
|
33042
|
+
for (i2 = stack.length - 2;i2 >= 0; i2--) {
|
|
33043
|
+
if (stack[i2].rawTagName === tagName)
|
|
31266
33044
|
break;
|
|
31267
33045
|
}
|
|
31268
|
-
if (
|
|
31269
|
-
while (stack.length >
|
|
33046
|
+
if (i2 >= 0) {
|
|
33047
|
+
while (stack.length > i2) {
|
|
31270
33048
|
currentParent.range[1] = createRange(-1, Math.max(lastTextPos, tagEndPos))[1];
|
|
31271
33049
|
stack.pop();
|
|
31272
33050
|
currentParent = (0, back_1.default)(stack);
|
|
@@ -31282,7 +33060,7 @@ var require_html = __commonJS((exports) => {
|
|
|
31282
33060
|
return stack;
|
|
31283
33061
|
}
|
|
31284
33062
|
exports.base_parse = base_parse;
|
|
31285
|
-
function
|
|
33063
|
+
function parse3(data, options = {}) {
|
|
31286
33064
|
const stack = base_parse(data, options);
|
|
31287
33065
|
const [root] = stack;
|
|
31288
33066
|
while (stack.length > 1) {
|
|
@@ -31309,7 +33087,7 @@ var require_html = __commonJS((exports) => {
|
|
|
31309
33087
|
}
|
|
31310
33088
|
return root;
|
|
31311
33089
|
}
|
|
31312
|
-
exports.parse =
|
|
33090
|
+
exports.parse = parse3;
|
|
31313
33091
|
function resolveInsertable(insertable) {
|
|
31314
33092
|
return insertable.map((val) => {
|
|
31315
33093
|
if (typeof val === "string") {
|
|
@@ -31368,41 +33146,18 @@ var require_dist2 = __commonJS((exports) => {
|
|
|
31368
33146
|
var parse_1 = __importDefault(require_parse3());
|
|
31369
33147
|
var valid_1 = __importDefault(require_valid());
|
|
31370
33148
|
exports.valid = valid_1.default;
|
|
31371
|
-
function
|
|
33149
|
+
function parse3(data, options = {}) {
|
|
31372
33150
|
return (0, parse_1.default)(data, options);
|
|
31373
33151
|
}
|
|
31374
|
-
exports.default =
|
|
31375
|
-
exports.parse =
|
|
31376
|
-
|
|
31377
|
-
|
|
31378
|
-
|
|
31379
|
-
|
|
31380
|
-
|
|
31381
|
-
|
|
31382
|
-
|
|
31383
|
-
});
|
|
31384
|
-
// ../../node_modules/@astrojs/compiler/dist/chunk-W5DTLHV4.js
|
|
31385
|
-
import g from "crypto";
|
|
31386
|
-
import _ from "fs";
|
|
31387
|
-
import { TextDecoder as b, TextEncoder as v } from "util";
|
|
31388
|
-
var y, w;
|
|
31389
|
-
var init_chunk_W5DTLHV4 = __esm(() => {
|
|
31390
|
-
globalThis.fs || Object.defineProperty(globalThis, "fs", { value: _ });
|
|
31391
|
-
globalThis.process || Object.defineProperties(globalThis, "process", { value: process });
|
|
31392
|
-
globalThis.crypto || Object.defineProperty(globalThis, "crypto", { value: g.webcrypto ? g.webcrypto : { getRandomValues(m) {
|
|
31393
|
-
return g.randomFillSync(m);
|
|
31394
|
-
} } });
|
|
31395
|
-
globalThis.performance || Object.defineProperty(globalThis, "performance", { value: { now() {
|
|
31396
|
-
let [m, o] = process.hrtime();
|
|
31397
|
-
return m * 1000 + o / 1e6;
|
|
31398
|
-
} } });
|
|
31399
|
-
y = new v("utf-8");
|
|
31400
|
-
w = new b("utf-8");
|
|
31401
|
-
});
|
|
31402
|
-
|
|
31403
|
-
// ../../node_modules/@astrojs/compiler/dist/node/index.js
|
|
31404
|
-
var init_node = __esm(() => {
|
|
31405
|
-
init_chunk_W5DTLHV4();
|
|
33152
|
+
exports.default = parse3;
|
|
33153
|
+
exports.parse = parse3;
|
|
33154
|
+
parse3.parse = parse_1.default;
|
|
33155
|
+
parse3.HTMLElement = html_1.default;
|
|
33156
|
+
parse3.CommentNode = comment_1.default;
|
|
33157
|
+
parse3.valid = valid_1.default;
|
|
33158
|
+
parse3.Node = node_1.default;
|
|
33159
|
+
parse3.TextNode = text_1.default;
|
|
33160
|
+
parse3.NodeType = type_1.default;
|
|
31406
33161
|
});
|
|
31407
33162
|
// ../cms/src/source-finder/cache.ts
|
|
31408
33163
|
var parsedFileCache, directoryCache, markdownFileCache, declaredUrlIndexCache, dirtyFiles;
|
|
@@ -31489,9 +33244,9 @@ function extractAstroImageOriginalUrl(src) {
|
|
|
31489
33244
|
return href;
|
|
31490
33245
|
}
|
|
31491
33246
|
if (url.pathname.startsWith("/@image/")) {
|
|
31492
|
-
const
|
|
31493
|
-
if (
|
|
31494
|
-
return
|
|
33247
|
+
const f2 = url.searchParams.get("f");
|
|
33248
|
+
if (f2)
|
|
33249
|
+
return f2;
|
|
31495
33250
|
}
|
|
31496
33251
|
} catch {}
|
|
31497
33252
|
return;
|
|
@@ -31511,7 +33266,7 @@ var init_snippet_utils = __esm(() => {
|
|
|
31511
33266
|
|
|
31512
33267
|
// ../cms/src/handlers/source-writer.ts
|
|
31513
33268
|
import fs8 from "fs/promises";
|
|
31514
|
-
import
|
|
33269
|
+
import path12 from "path";
|
|
31515
33270
|
async function handleUpdate(request, manifestWriter) {
|
|
31516
33271
|
const { changes, meta } = request;
|
|
31517
33272
|
const errors = [];
|
|
@@ -31548,7 +33303,7 @@ async function handleUpdate(request, manifestWriter) {
|
|
|
31548
33303
|
}
|
|
31549
33304
|
if (appliedCount > 0 && newContent !== currentContent) {
|
|
31550
33305
|
for (const op of fileOps) {
|
|
31551
|
-
await fs8.mkdir(
|
|
33306
|
+
await fs8.mkdir(path12.dirname(op.target), { recursive: true });
|
|
31552
33307
|
await fs8.writeFile(op.target, op.bytes);
|
|
31553
33308
|
}
|
|
31554
33309
|
await fs8.writeFile(fullPath, newContent, "utf-8");
|
|
@@ -31782,28 +33537,28 @@ function findFrontmatterAssetImport(content, varName) {
|
|
|
31782
33537
|
return null;
|
|
31783
33538
|
const fmStart = fmMatch[0].indexOf(fmMatch[1]);
|
|
31784
33539
|
const importRe = /^\s*import\s+(?!type\b)([\s\S]+?)\s+from\s+(['"])([^'"]+)\2/gm;
|
|
31785
|
-
let
|
|
31786
|
-
while ((
|
|
31787
|
-
const source =
|
|
33540
|
+
let m2;
|
|
33541
|
+
while ((m2 = importRe.exec(fmMatch[1])) !== null) {
|
|
33542
|
+
const source = m2[3];
|
|
31788
33543
|
if (!source.startsWith(".") || !ASSET_IMPORT_EXT_RE.test(source))
|
|
31789
33544
|
continue;
|
|
31790
|
-
const tokens =
|
|
33545
|
+
const tokens = m2[1].replace(/[{}]/g, ",").split(",").map((s) => s.trim()).filter((t) => t && !t.startsWith("type "));
|
|
31791
33546
|
const matches = tokens.some((tok) => {
|
|
31792
33547
|
const aliasMatch = tok.match(/^\S+\s+as\s+(\S+)$/);
|
|
31793
33548
|
return (aliasMatch ? aliasMatch[1] : tok) === varName;
|
|
31794
33549
|
});
|
|
31795
33550
|
if (!matches)
|
|
31796
33551
|
continue;
|
|
31797
|
-
const matchStart = fmStart +
|
|
31798
|
-
const sourceStart = matchStart +
|
|
33552
|
+
const matchStart = fmStart + m2.index;
|
|
33553
|
+
const sourceStart = matchStart + m2[0].indexOf(m2[2]) + 1;
|
|
31799
33554
|
return { localName: varName, source, sourceStart, sourceEnd: sourceStart + source.length };
|
|
31800
33555
|
}
|
|
31801
33556
|
return null;
|
|
31802
33557
|
}
|
|
31803
33558
|
function inlineJsxLiteralReplace(content, lines, regionStart, exprMatch, newSrc) {
|
|
31804
33559
|
let regionStartOffset = 0;
|
|
31805
|
-
for (let
|
|
31806
|
-
regionStartOffset += lines[
|
|
33560
|
+
for (let i2 = 0;i2 < regionStart; i2++)
|
|
33561
|
+
regionStartOffset += lines[i2].length + 1;
|
|
31807
33562
|
const absIndex = regionStartOffset + exprMatch.index;
|
|
31808
33563
|
return {
|
|
31809
33564
|
content: content.slice(0, absIndex) + `src="${escapeReplacement(newSrc)}"` + content.slice(absIndex + exprMatch.length),
|
|
@@ -31814,8 +33569,8 @@ async function tryRewriteAssetImport(content, importInfo, newSrc, absFilePath, o
|
|
|
31814
33569
|
const resolved = await resolveNewSrcBytes(newSrc, originUrl);
|
|
31815
33570
|
if (!resolved)
|
|
31816
33571
|
return null;
|
|
31817
|
-
const originalAssetAbs =
|
|
31818
|
-
const targetAbs = await pickSiblingTarget(
|
|
33572
|
+
const originalAssetAbs = path12.resolve(path12.dirname(absFilePath), importInfo.source);
|
|
33573
|
+
const targetAbs = await pickSiblingTarget(path12.dirname(originalAssetAbs), resolved.filename, resolved.bytes);
|
|
31819
33574
|
const newRelImport = relativeImportPath2(absFilePath, targetAbs);
|
|
31820
33575
|
const newContent = content.slice(0, importInfo.sourceStart) + newRelImport + content.slice(importInfo.sourceEnd);
|
|
31821
33576
|
return {
|
|
@@ -31825,8 +33580,8 @@ async function tryRewriteAssetImport(content, importInfo, newSrc, absFilePath, o
|
|
|
31825
33580
|
};
|
|
31826
33581
|
}
|
|
31827
33582
|
async function resolveNewSrcBytes(newSrc, originUrl) {
|
|
31828
|
-
const filenameFromPath = (p) =>
|
|
31829
|
-
const diskPath = newSrc.startsWith("/src/") ?
|
|
33583
|
+
const filenameFromPath = (p) => path12.basename(p.split("?")[0] ?? p);
|
|
33584
|
+
const diskPath = newSrc.startsWith("/src/") ? path12.join(getProjectRoot(), newSrc.slice(1)) : newSrc.startsWith("/") && !newSrc.startsWith("//") ? path12.join(getProjectRoot(), "public", newSrc.replace(/^\/+/, "")) : null;
|
|
31830
33585
|
if (diskPath) {
|
|
31831
33586
|
try {
|
|
31832
33587
|
return { bytes: await fs8.readFile(diskPath), filename: filenameFromPath(newSrc) };
|
|
@@ -31916,10 +33671,10 @@ function replaceClassInAttribute(content, oldClass, newClass, sourceLine) {
|
|
|
31916
33671
|
}
|
|
31917
33672
|
const lines = content.split(`
|
|
31918
33673
|
`);
|
|
31919
|
-
for (let
|
|
31920
|
-
const result = replaceOnLine(lines[
|
|
33674
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
33675
|
+
const result = replaceOnLine(lines[i2]);
|
|
31921
33676
|
if (result !== null) {
|
|
31922
|
-
lines[
|
|
33677
|
+
lines[i2] = result;
|
|
31923
33678
|
return { success: true, content: lines.join(`
|
|
31924
33679
|
`) };
|
|
31925
33680
|
}
|
|
@@ -31959,10 +33714,10 @@ function appendClassToAttribute(content, newClass, sourceLine) {
|
|
|
31959
33714
|
}
|
|
31960
33715
|
const lines = content.split(`
|
|
31961
33716
|
`);
|
|
31962
|
-
for (let
|
|
31963
|
-
const result = doAppendOnLine(lines[
|
|
33717
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
33718
|
+
const result = doAppendOnLine(lines[i2]);
|
|
31964
33719
|
if (result !== null) {
|
|
31965
|
-
lines[
|
|
33720
|
+
lines[i2] = result;
|
|
31966
33721
|
return { success: true, content: lines.join(`
|
|
31967
33722
|
`) };
|
|
31968
33723
|
}
|
|
@@ -32121,9 +33876,9 @@ function applyTextChangeWithPlaceholders(content, sourceSnippet, originalValue,
|
|
|
32121
33876
|
}
|
|
32122
33877
|
let updatedSnippet = sourceSnippet;
|
|
32123
33878
|
let anyChange = false;
|
|
32124
|
-
for (let
|
|
32125
|
-
const oldPart = originalParts[
|
|
32126
|
-
let newPart = newParts[
|
|
33879
|
+
for (let i2 = 0;i2 < originalParts.length; i2++) {
|
|
33880
|
+
const oldPart = originalParts[i2];
|
|
33881
|
+
let newPart = newParts[i2];
|
|
32127
33882
|
if (oldPart === newPart || oldPart.length === 0) {
|
|
32128
33883
|
continue;
|
|
32129
33884
|
}
|
|
@@ -32170,8 +33925,8 @@ function findTextInSnippet(snippet, decodedText) {
|
|
|
32170
33925
|
const match = snippet.match(regex);
|
|
32171
33926
|
if (match)
|
|
32172
33927
|
return match[0];
|
|
32173
|
-
const
|
|
32174
|
-
const brAwarePattern =
|
|
33928
|
+
const chars2 = [...decodedText].map((ch) => escapeRegex(ch));
|
|
33929
|
+
const brAwarePattern = chars2.join("(?:<br\\b[^>]*\\/?>)*");
|
|
32175
33930
|
const brRegex = new RegExp(brAwarePattern);
|
|
32176
33931
|
const brMatch = snippet.match(brRegex);
|
|
32177
33932
|
return brMatch && brMatch[0] !== decodedText ? brMatch[0] : null;
|
|
@@ -32215,19 +33970,19 @@ function findExpressionAttribute(text, attr) {
|
|
|
32215
33970
|
return null;
|
|
32216
33971
|
const braceStart = match.index + match[0].length - 1;
|
|
32217
33972
|
let depth = 1;
|
|
32218
|
-
let
|
|
32219
|
-
while (
|
|
32220
|
-
if (text[
|
|
33973
|
+
let i2 = braceStart + 1;
|
|
33974
|
+
while (i2 < text.length && depth > 0) {
|
|
33975
|
+
if (text[i2] === "{")
|
|
32221
33976
|
depth++;
|
|
32222
|
-
else if (text[
|
|
33977
|
+
else if (text[i2] === "}")
|
|
32223
33978
|
depth--;
|
|
32224
|
-
|
|
33979
|
+
i2++;
|
|
32225
33980
|
}
|
|
32226
33981
|
if (depth !== 0)
|
|
32227
33982
|
return null;
|
|
32228
33983
|
return {
|
|
32229
33984
|
index: match.index,
|
|
32230
|
-
length:
|
|
33985
|
+
length: i2 - match.index
|
|
32231
33986
|
};
|
|
32232
33987
|
}
|
|
32233
33988
|
function findExpressionSrcAttribute(text) {
|
|
@@ -32323,16 +34078,16 @@ function tryBrNormalizedChange(sourceSnippet, resolvedOriginal, resolvedNewText)
|
|
|
32323
34078
|
if (originalSegments.length !== newSegments.length)
|
|
32324
34079
|
return null;
|
|
32325
34080
|
const root = import_node_html_parser.parse(sourceSnippet, { blockTextElements: {} });
|
|
32326
|
-
const outerElement = root.childNodes.find((
|
|
34081
|
+
const outerElement = root.childNodes.find((n2) => n2.nodeType === import_node_html_parser.NodeType.ELEMENT_NODE);
|
|
32327
34082
|
if (!outerElement)
|
|
32328
34083
|
return null;
|
|
32329
34084
|
const groups = [[]];
|
|
32330
|
-
for (let
|
|
32331
|
-
const child = outerElement.childNodes[
|
|
34085
|
+
for (let i2 = 0;i2 < outerElement.childNodes.length; i2++) {
|
|
34086
|
+
const child = outerElement.childNodes[i2];
|
|
32332
34087
|
if (child.nodeType === import_node_html_parser.NodeType.ELEMENT_NODE && child.rawTagName === "br") {
|
|
32333
34088
|
groups.push([]);
|
|
32334
34089
|
} else if (child.nodeType === import_node_html_parser.NodeType.TEXT_NODE) {
|
|
32335
|
-
groups[groups.length - 1].push({ node: child, index:
|
|
34090
|
+
groups[groups.length - 1].push({ node: child, index: i2 });
|
|
32336
34091
|
}
|
|
32337
34092
|
}
|
|
32338
34093
|
if (groups.length !== originalSegments.length)
|
|
@@ -32374,7 +34129,7 @@ var init_source_writer = __esm(() => {
|
|
|
32374
34129
|
});
|
|
32375
34130
|
|
|
32376
34131
|
// ../cms/src/handlers/api-routes.ts
|
|
32377
|
-
import
|
|
34132
|
+
import path13 from "path";
|
|
32378
34133
|
function requireMedia(ctx) {
|
|
32379
34134
|
if (!ctx.mediaAdapter) {
|
|
32380
34135
|
sendError(ctx.res, "Media storage not configured", 501);
|
|
@@ -32537,7 +34292,7 @@ var init_api_routes = __esm(() => {
|
|
|
32537
34292
|
sendJson(res, { success: false, error: `Invalid content path: ${body.filePath}` }, 400);
|
|
32538
34293
|
return;
|
|
32539
34294
|
}
|
|
32540
|
-
const fullPath =
|
|
34295
|
+
const fullPath = path13.resolve(getProjectRoot(), body.filePath.replace(/^\//, ""));
|
|
32541
34296
|
expectedDeletions.add(fullPath);
|
|
32542
34297
|
const result = await core.deleteEntry(entry.collection, entry.slug);
|
|
32543
34298
|
if (result.success) {
|
|
@@ -32644,7 +34399,7 @@ var init_api_routes = __esm(() => {
|
|
|
32644
34399
|
const body = await parseJsonBody(req);
|
|
32645
34400
|
const result = await core.deletePage(body);
|
|
32646
34401
|
if (result.success && result.filePath) {
|
|
32647
|
-
expectedDeletions.add(
|
|
34402
|
+
expectedDeletions.add(path13.resolve(getProjectRoot(), result.filePath));
|
|
32648
34403
|
}
|
|
32649
34404
|
if (result.success && body.createRedirect && body.redirectTo) {
|
|
32650
34405
|
await core.addRedirect({ source: body.pagePath, destination: body.redirectTo, statusCode: 307 });
|
|
@@ -32749,7 +34504,7 @@ var init_color_patterns = __esm(() => {
|
|
|
32749
34504
|
|
|
32750
34505
|
// ../cms/src/tailwind-colors.ts
|
|
32751
34506
|
import fs9 from "fs/promises";
|
|
32752
|
-
import
|
|
34507
|
+
import path14 from "path";
|
|
32753
34508
|
async function parseTailwindConfig(projectRoot = getProjectRoot()) {
|
|
32754
34509
|
const cssFiles = [
|
|
32755
34510
|
"src/styles/global.css",
|
|
@@ -32763,7 +34518,7 @@ async function parseTailwindConfig(projectRoot = getProjectRoot()) {
|
|
|
32763
34518
|
];
|
|
32764
34519
|
let customColors = [];
|
|
32765
34520
|
for (const cssFile of cssFiles) {
|
|
32766
|
-
const fullPath =
|
|
34521
|
+
const fullPath = path14.join(projectRoot, cssFile);
|
|
32767
34522
|
try {
|
|
32768
34523
|
const content = await fs9.readFile(fullPath, "utf-8");
|
|
32769
34524
|
customColors = extractColorsFromCss(content);
|
|
@@ -32836,7 +34591,7 @@ async function parseTextStyles(projectRoot = getProjectRoot()) {
|
|
|
32836
34591
|
];
|
|
32837
34592
|
let customTextStyles = {};
|
|
32838
34593
|
for (const cssFile of cssFiles) {
|
|
32839
|
-
const fullPath =
|
|
34594
|
+
const fullPath = path14.join(projectRoot, cssFile);
|
|
32840
34595
|
try {
|
|
32841
34596
|
const content = await fs9.readFile(fullPath, "utf-8");
|
|
32842
34597
|
customTextStyles = extractTextStylesFromCss(content);
|
|
@@ -33304,7 +35059,7 @@ var init_local_admin = __esm(() => {
|
|
|
33304
35059
|
|
|
33305
35060
|
// ../cms/src/manifest-writer.ts
|
|
33306
35061
|
import fs10 from "fs/promises";
|
|
33307
|
-
import
|
|
35062
|
+
import path15 from "path";
|
|
33308
35063
|
|
|
33309
35064
|
class ManifestWriter {
|
|
33310
35065
|
globalManifest;
|
|
@@ -33375,10 +35130,10 @@ class ManifestWriter {
|
|
|
33375
35130
|
}
|
|
33376
35131
|
getPageManifestPath(pagePath) {
|
|
33377
35132
|
if (pagePath === "/" || pagePath === "") {
|
|
33378
|
-
return
|
|
35133
|
+
return path15.join(this.outDir, "index.json");
|
|
33379
35134
|
}
|
|
33380
35135
|
const cleanPath = pagePath.replace(/^\//, "");
|
|
33381
|
-
return
|
|
35136
|
+
return path15.join(this.outDir, `${cleanPath}.json`);
|
|
33382
35137
|
}
|
|
33383
35138
|
addPage(pagePath, entries, components, collection, seo) {
|
|
33384
35139
|
this.pageManifests.set(pagePath, { entries, components, collection, seo });
|
|
@@ -33404,7 +35159,7 @@ class ManifestWriter {
|
|
|
33404
35159
|
}
|
|
33405
35160
|
async writePageManifest(pagePath, entries, components, collection, seo) {
|
|
33406
35161
|
const manifestPath = this.getPageManifestPath(pagePath);
|
|
33407
|
-
const manifestDir =
|
|
35162
|
+
const manifestDir = path15.dirname(manifestPath);
|
|
33408
35163
|
await fs10.mkdir(manifestDir, { recursive: true });
|
|
33409
35164
|
const metadata = {
|
|
33410
35165
|
version: MANIFEST_VERSION,
|
|
@@ -33460,7 +35215,7 @@ class ManifestWriter {
|
|
|
33460
35215
|
}
|
|
33461
35216
|
}
|
|
33462
35217
|
if (this.outDir) {
|
|
33463
|
-
const globalManifestPath =
|
|
35218
|
+
const globalManifestPath = path15.join(this.outDir, this.manifestFile);
|
|
33464
35219
|
const globalSettings = {
|
|
33465
35220
|
componentDefinitions: this.componentDefinitions,
|
|
33466
35221
|
pages
|
|
@@ -33570,8 +35325,8 @@ function $constructor(name, initializer, params) {
|
|
|
33570
35325
|
initializer(inst, def);
|
|
33571
35326
|
const proto = _2.prototype;
|
|
33572
35327
|
const keys = Object.keys(proto);
|
|
33573
|
-
for (let
|
|
33574
|
-
const k = keys[
|
|
35328
|
+
for (let i2 = 0;i2 < keys.length; i2++) {
|
|
35329
|
+
const k = keys[i2];
|
|
33575
35330
|
if (!(k in inst)) {
|
|
33576
35331
|
inst[k] = proto[k].bind(inst);
|
|
33577
35332
|
}
|
|
@@ -33722,10 +35477,10 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
33722
35477
|
fieldErrors._errors.push(mapper(issue));
|
|
33723
35478
|
} else {
|
|
33724
35479
|
let curr = fieldErrors;
|
|
33725
|
-
let
|
|
33726
|
-
while (
|
|
33727
|
-
const el = issue.path[
|
|
33728
|
-
const terminal =
|
|
35480
|
+
let i2 = 0;
|
|
35481
|
+
while (i2 < issue.path.length) {
|
|
35482
|
+
const el = issue.path[i2];
|
|
35483
|
+
const terminal = i2 === issue.path.length - 1;
|
|
33729
35484
|
if (!terminal) {
|
|
33730
35485
|
curr[el] = curr[el] || { _errors: [] };
|
|
33731
35486
|
} else {
|
|
@@ -33733,7 +35488,7 @@ function formatError(error, mapper = (issue) => issue.message) {
|
|
|
33733
35488
|
curr[el]._errors.push(mapper(issue));
|
|
33734
35489
|
}
|
|
33735
35490
|
curr = curr[el];
|
|
33736
|
-
|
|
35491
|
+
i2++;
|
|
33737
35492
|
}
|
|
33738
35493
|
}
|
|
33739
35494
|
}
|
|
@@ -33927,8 +35682,8 @@ class $ZodRegistry {
|
|
|
33927
35682
|
if (p) {
|
|
33928
35683
|
const pm = { ...this.get(p) ?? {} };
|
|
33929
35684
|
delete pm.id;
|
|
33930
|
-
const
|
|
33931
|
-
return Object.keys(
|
|
35685
|
+
const f2 = { ...pm, ...this._map.get(schema) };
|
|
35686
|
+
return Object.keys(f2).length ? f2 : undefined;
|
|
33932
35687
|
}
|
|
33933
35688
|
return this._map.get(schema);
|
|
33934
35689
|
}
|
|
@@ -34072,7 +35827,7 @@ var init_field_types = __esm(() => {
|
|
|
34072
35827
|
|
|
34073
35828
|
// ../cms/src/migrate-astro-image.ts
|
|
34074
35829
|
import fs11 from "fs/promises";
|
|
34075
|
-
import
|
|
35830
|
+
import path16 from "path";
|
|
34076
35831
|
async function migrateAstroImages(options = {}) {
|
|
34077
35832
|
const projectRoot = options.projectRoot ?? getProjectRoot();
|
|
34078
35833
|
const dryRun = options.dryRun ?? false;
|
|
@@ -34080,11 +35835,11 @@ async function migrateAstroImages(options = {}) {
|
|
|
34080
35835
|
const migrations = [];
|
|
34081
35836
|
const skipped = [];
|
|
34082
35837
|
for (const def of Object.values(collections)) {
|
|
34083
|
-
const astroFields = def.fields.filter((
|
|
35838
|
+
const astroFields = def.fields.filter((f2) => f2.astroImage);
|
|
34084
35839
|
if (astroFields.length === 0 || !def.entries)
|
|
34085
35840
|
continue;
|
|
34086
35841
|
for (const entry of def.entries) {
|
|
34087
|
-
const entryAbs =
|
|
35842
|
+
const entryAbs = path16.isAbsolute(entry.sourcePath) ? entry.sourcePath : path16.join(projectRoot, entry.sourcePath);
|
|
34088
35843
|
let raw;
|
|
34089
35844
|
try {
|
|
34090
35845
|
raw = await fs11.readFile(entryAbs, "utf-8");
|
|
@@ -34099,7 +35854,7 @@ async function migrateAstroImages(options = {}) {
|
|
|
34099
35854
|
}
|
|
34100
35855
|
const [fullFm, fmStart, yamlBody, fmEnd] = fmMatch;
|
|
34101
35856
|
const doc2 = import_yaml7.parseDocument(yamlBody);
|
|
34102
|
-
let
|
|
35857
|
+
let mutated2 = false;
|
|
34103
35858
|
for (const field of astroFields) {
|
|
34104
35859
|
const current = doc2.get(field.name);
|
|
34105
35860
|
if (typeof current !== "string") {
|
|
@@ -34109,7 +35864,7 @@ async function migrateAstroImages(options = {}) {
|
|
|
34109
35864
|
}
|
|
34110
35865
|
if (!current.startsWith("/") || current.startsWith("//"))
|
|
34111
35866
|
continue;
|
|
34112
|
-
const sourceAbs =
|
|
35867
|
+
const sourceAbs = path16.join(projectRoot, "public", current.replace(/^\/+/, ""));
|
|
34113
35868
|
let sourceBuf;
|
|
34114
35869
|
try {
|
|
34115
35870
|
sourceBuf = await fs11.readFile(sourceAbs);
|
|
@@ -34120,15 +35875,15 @@ async function migrateAstroImages(options = {}) {
|
|
|
34120
35875
|
const target = await pickAstroImageTarget({
|
|
34121
35876
|
entryAbsPath: entryAbs,
|
|
34122
35877
|
slug: entry.slug,
|
|
34123
|
-
originalFilename:
|
|
35878
|
+
originalFilename: path16.basename(current),
|
|
34124
35879
|
compareBuffer: sourceBuf
|
|
34125
35880
|
});
|
|
34126
35881
|
if (!dryRun) {
|
|
34127
|
-
await fs11.mkdir(
|
|
35882
|
+
await fs11.mkdir(path16.dirname(target.absPath), { recursive: true });
|
|
34128
35883
|
await fs11.writeFile(target.absPath, sourceBuf);
|
|
34129
35884
|
}
|
|
34130
35885
|
doc2.set(field.name, target.relPath);
|
|
34131
|
-
|
|
35886
|
+
mutated2 = true;
|
|
34132
35887
|
migrations.push({
|
|
34133
35888
|
entrySourcePath: entry.sourcePath,
|
|
34134
35889
|
fieldName: field.name,
|
|
@@ -34138,7 +35893,7 @@ async function migrateAstroImages(options = {}) {
|
|
|
34138
35893
|
copiedTo: target.absPath
|
|
34139
35894
|
});
|
|
34140
35895
|
}
|
|
34141
|
-
if (
|
|
35896
|
+
if (mutated2 && !dryRun) {
|
|
34142
35897
|
const newYaml = doc2.toString().replace(/\n$/, "");
|
|
34143
35898
|
const newRaw = raw.replace(fullFm, `${fmStart}${newYaml}${fmEnd}`);
|
|
34144
35899
|
await fs11.writeFile(entryAbs, newRaw, "utf-8");
|
|
@@ -34187,7 +35942,7 @@ var exports_migrate = {};
|
|
|
34187
35942
|
__export(exports_migrate, {
|
|
34188
35943
|
migrate: () => migrate
|
|
34189
35944
|
});
|
|
34190
|
-
import
|
|
35945
|
+
import path17 from "path";
|
|
34191
35946
|
async function migrate(args) {
|
|
34192
35947
|
if (args.target !== "astro-image") {
|
|
34193
35948
|
console.error(`Unknown migrate target: ${args.target}`);
|
|
@@ -34203,10 +35958,10 @@ async function migrate(args) {
|
|
|
34203
35958
|
} else {
|
|
34204
35959
|
console.log(`${result.migrations.length} field(s) to migrate:
|
|
34205
35960
|
`);
|
|
34206
|
-
for (const
|
|
34207
|
-
console.log(` ${
|
|
34208
|
-
console.log(` ${
|
|
34209
|
-
console.log(` copy: ${
|
|
35961
|
+
for (const m2 of result.migrations) {
|
|
35962
|
+
console.log(` ${m2.entrySourcePath}`);
|
|
35963
|
+
console.log(` ${m2.fieldName}: ${m2.originalValue} \u2192 ${m2.newValue}`);
|
|
35964
|
+
console.log(` copy: ${path17.relative(process.cwd(), m2.copiedFrom)} \u2192 ${path17.relative(process.cwd(), m2.copiedTo)}`);
|
|
34210
35965
|
}
|
|
34211
35966
|
}
|
|
34212
35967
|
if (result.skipped.length > 0) {
|
|
@@ -34248,7 +36003,7 @@ Commands:`);
|
|
|
34248
36003
|
console.log(" build Run astro build with the Nua defaults");
|
|
34249
36004
|
console.log(" dev Run astro dev with the Nua defaults");
|
|
34250
36005
|
console.log(" preview Run astro preview with the Nua defaults");
|
|
34251
|
-
console.log(" check Validate the
|
|
36006
|
+
console.log(" check Validate collections and parse the source (no build). --json, --strict, --content-only, --no-live");
|
|
34252
36007
|
console.log(" init Convert a standard Astro project to use Nua");
|
|
34253
36008
|
console.log(" clean Eject to a standard Astro project (remove @nuasite/* deps)");
|
|
34254
36009
|
console.log(" migrate <target> Run a content migration. Targets: astro-image");
|
|
@@ -34262,12 +36017,8 @@ if (command && ["build", "dev", "preview"].includes(command)) {
|
|
|
34262
36017
|
} else {
|
|
34263
36018
|
switch (command) {
|
|
34264
36019
|
case "check": {
|
|
34265
|
-
const { check: check2 } = await Promise.resolve().then(() => (init_check2(), exports_check));
|
|
34266
|
-
process.exit(await check2(
|
|
34267
|
-
cwd: process.cwd(),
|
|
34268
|
-
json: args.includes("--json"),
|
|
34269
|
-
strict: args.includes("--strict")
|
|
34270
|
-
}));
|
|
36020
|
+
const { check: check2, parseCheckArgs: parseCheckArgs2 } = await Promise.resolve().then(() => (init_check2(), exports_check));
|
|
36021
|
+
process.exit(await check2(parseCheckArgs2(args, process.cwd())));
|
|
34271
36022
|
break;
|
|
34272
36023
|
}
|
|
34273
36024
|
case "init": {
|