@nuasite/cli 0.39.2 → 0.41.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 +8 -30
- package/dist/index.js +963 -569
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -6
- package/src/index.ts +1 -53
- package/src/tsconfig.json +1 -1
- package/dist/types/build.d.ts +0 -3
- package/dist/types/build.d.ts.map +0 -1
- package/src/build.ts +0 -30
package/dist/index.js
CHANGED
|
@@ -707,17 +707,17 @@ var require_visit = __commonJS((exports) => {
|
|
|
707
707
|
visit.BREAK = BREAK;
|
|
708
708
|
visit.SKIP = SKIP;
|
|
709
709
|
visit.REMOVE = REMOVE;
|
|
710
|
-
function visit_(key, node, visitor,
|
|
711
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
710
|
+
function visit_(key, node, visitor, path) {
|
|
711
|
+
const ctrl = callVisitor(key, node, visitor, path);
|
|
712
712
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
713
|
-
replaceNode(key,
|
|
714
|
-
return visit_(key, ctrl, visitor,
|
|
713
|
+
replaceNode(key, path, ctrl);
|
|
714
|
+
return visit_(key, ctrl, visitor, path);
|
|
715
715
|
}
|
|
716
716
|
if (typeof ctrl !== "symbol") {
|
|
717
717
|
if (identity.isCollection(node)) {
|
|
718
|
-
|
|
718
|
+
path = Object.freeze(path.concat(node));
|
|
719
719
|
for (let i = 0;i < node.items.length; ++i) {
|
|
720
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
720
|
+
const ci = visit_(i, node.items[i], visitor, path);
|
|
721
721
|
if (typeof ci === "number")
|
|
722
722
|
i = ci - 1;
|
|
723
723
|
else if (ci === BREAK)
|
|
@@ -728,13 +728,13 @@ var require_visit = __commonJS((exports) => {
|
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
730
|
} else if (identity.isPair(node)) {
|
|
731
|
-
|
|
732
|
-
const ck = visit_("key", node.key, visitor,
|
|
731
|
+
path = Object.freeze(path.concat(node));
|
|
732
|
+
const ck = visit_("key", node.key, visitor, path);
|
|
733
733
|
if (ck === BREAK)
|
|
734
734
|
return BREAK;
|
|
735
735
|
else if (ck === REMOVE)
|
|
736
736
|
node.key = null;
|
|
737
|
-
const cv = visit_("value", node.value, visitor,
|
|
737
|
+
const cv = visit_("value", node.value, visitor, path);
|
|
738
738
|
if (cv === BREAK)
|
|
739
739
|
return BREAK;
|
|
740
740
|
else if (cv === REMOVE)
|
|
@@ -755,17 +755,17 @@ var require_visit = __commonJS((exports) => {
|
|
|
755
755
|
visitAsync.BREAK = BREAK;
|
|
756
756
|
visitAsync.SKIP = SKIP;
|
|
757
757
|
visitAsync.REMOVE = REMOVE;
|
|
758
|
-
async function visitAsync_(key, node, visitor,
|
|
759
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
758
|
+
async function visitAsync_(key, node, visitor, path) {
|
|
759
|
+
const ctrl = await callVisitor(key, node, visitor, path);
|
|
760
760
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
761
|
-
replaceNode(key,
|
|
762
|
-
return visitAsync_(key, ctrl, visitor,
|
|
761
|
+
replaceNode(key, path, ctrl);
|
|
762
|
+
return visitAsync_(key, ctrl, visitor, path);
|
|
763
763
|
}
|
|
764
764
|
if (typeof ctrl !== "symbol") {
|
|
765
765
|
if (identity.isCollection(node)) {
|
|
766
|
-
|
|
766
|
+
path = Object.freeze(path.concat(node));
|
|
767
767
|
for (let i = 0;i < node.items.length; ++i) {
|
|
768
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
768
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path);
|
|
769
769
|
if (typeof ci === "number")
|
|
770
770
|
i = ci - 1;
|
|
771
771
|
else if (ci === BREAK)
|
|
@@ -776,13 +776,13 @@ var require_visit = __commonJS((exports) => {
|
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
} else if (identity.isPair(node)) {
|
|
779
|
-
|
|
780
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
779
|
+
path = Object.freeze(path.concat(node));
|
|
780
|
+
const ck = await visitAsync_("key", node.key, visitor, path);
|
|
781
781
|
if (ck === BREAK)
|
|
782
782
|
return BREAK;
|
|
783
783
|
else if (ck === REMOVE)
|
|
784
784
|
node.key = null;
|
|
785
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
785
|
+
const cv = await visitAsync_("value", node.value, visitor, path);
|
|
786
786
|
if (cv === BREAK)
|
|
787
787
|
return BREAK;
|
|
788
788
|
else if (cv === REMOVE)
|
|
@@ -809,23 +809,23 @@ var require_visit = __commonJS((exports) => {
|
|
|
809
809
|
}
|
|
810
810
|
return visitor;
|
|
811
811
|
}
|
|
812
|
-
function callVisitor(key, node, visitor,
|
|
812
|
+
function callVisitor(key, node, visitor, path) {
|
|
813
813
|
if (typeof visitor === "function")
|
|
814
|
-
return visitor(key, node,
|
|
814
|
+
return visitor(key, node, path);
|
|
815
815
|
if (identity.isMap(node))
|
|
816
|
-
return visitor.Map?.(key, node,
|
|
816
|
+
return visitor.Map?.(key, node, path);
|
|
817
817
|
if (identity.isSeq(node))
|
|
818
|
-
return visitor.Seq?.(key, node,
|
|
818
|
+
return visitor.Seq?.(key, node, path);
|
|
819
819
|
if (identity.isPair(node))
|
|
820
|
-
return visitor.Pair?.(key, node,
|
|
820
|
+
return visitor.Pair?.(key, node, path);
|
|
821
821
|
if (identity.isScalar(node))
|
|
822
|
-
return visitor.Scalar?.(key, node,
|
|
822
|
+
return visitor.Scalar?.(key, node, path);
|
|
823
823
|
if (identity.isAlias(node))
|
|
824
|
-
return visitor.Alias?.(key, node,
|
|
824
|
+
return visitor.Alias?.(key, node, path);
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
function replaceNode(key,
|
|
828
|
-
const parent =
|
|
827
|
+
function replaceNode(key, path, node) {
|
|
828
|
+
const parent = path[path.length - 1];
|
|
829
829
|
if (identity.isCollection(parent)) {
|
|
830
830
|
parent.items[key] = node;
|
|
831
831
|
} else if (identity.isPair(parent)) {
|
|
@@ -1382,10 +1382,10 @@ var require_Collection = __commonJS((exports) => {
|
|
|
1382
1382
|
var createNode = require_createNode();
|
|
1383
1383
|
var identity = require_identity();
|
|
1384
1384
|
var Node = require_Node();
|
|
1385
|
-
function collectionFromPath(schema,
|
|
1385
|
+
function collectionFromPath(schema, path, value) {
|
|
1386
1386
|
let v = value;
|
|
1387
|
-
for (let i =
|
|
1388
|
-
const k =
|
|
1387
|
+
for (let i = path.length - 1;i >= 0; --i) {
|
|
1388
|
+
const k = path[i];
|
|
1389
1389
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
1390
1390
|
const a = [];
|
|
1391
1391
|
a[k] = v;
|
|
@@ -1404,7 +1404,7 @@ var require_Collection = __commonJS((exports) => {
|
|
|
1404
1404
|
sourceObjects: new Map
|
|
1405
1405
|
});
|
|
1406
1406
|
}
|
|
1407
|
-
var isEmptyPath = (
|
|
1407
|
+
var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
|
|
1408
1408
|
|
|
1409
1409
|
class Collection extends Node.NodeBase {
|
|
1410
1410
|
constructor(type, schema) {
|
|
@@ -1425,11 +1425,11 @@ var require_Collection = __commonJS((exports) => {
|
|
|
1425
1425
|
copy.range = this.range.slice();
|
|
1426
1426
|
return copy;
|
|
1427
1427
|
}
|
|
1428
|
-
addIn(
|
|
1429
|
-
if (isEmptyPath(
|
|
1428
|
+
addIn(path, value) {
|
|
1429
|
+
if (isEmptyPath(path))
|
|
1430
1430
|
this.add(value);
|
|
1431
1431
|
else {
|
|
1432
|
-
const [key, ...rest] =
|
|
1432
|
+
const [key, ...rest] = path;
|
|
1433
1433
|
const node = this.get(key, true);
|
|
1434
1434
|
if (identity.isCollection(node))
|
|
1435
1435
|
node.addIn(rest, value);
|
|
@@ -1439,8 +1439,8 @@ var require_Collection = __commonJS((exports) => {
|
|
|
1439
1439
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
1440
1440
|
}
|
|
1441
1441
|
}
|
|
1442
|
-
deleteIn(
|
|
1443
|
-
const [key, ...rest] =
|
|
1442
|
+
deleteIn(path) {
|
|
1443
|
+
const [key, ...rest] = path;
|
|
1444
1444
|
if (rest.length === 0)
|
|
1445
1445
|
return this.delete(key);
|
|
1446
1446
|
const node = this.get(key, true);
|
|
@@ -1449,8 +1449,8 @@ var require_Collection = __commonJS((exports) => {
|
|
|
1449
1449
|
else
|
|
1450
1450
|
throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
|
|
1451
1451
|
}
|
|
1452
|
-
getIn(
|
|
1453
|
-
const [key, ...rest] =
|
|
1452
|
+
getIn(path, keepScalar) {
|
|
1453
|
+
const [key, ...rest] = path;
|
|
1454
1454
|
const node = this.get(key, true);
|
|
1455
1455
|
if (rest.length === 0)
|
|
1456
1456
|
return !keepScalar && identity.isScalar(node) ? node.value : node;
|
|
@@ -1465,15 +1465,15 @@ var require_Collection = __commonJS((exports) => {
|
|
|
1465
1465
|
return n == null || allowScalar && identity.isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
|
|
1466
1466
|
});
|
|
1467
1467
|
}
|
|
1468
|
-
hasIn(
|
|
1469
|
-
const [key, ...rest] =
|
|
1468
|
+
hasIn(path) {
|
|
1469
|
+
const [key, ...rest] = path;
|
|
1470
1470
|
if (rest.length === 0)
|
|
1471
1471
|
return this.has(key);
|
|
1472
1472
|
const node = this.get(key, true);
|
|
1473
1473
|
return identity.isCollection(node) ? node.hasIn(rest) : false;
|
|
1474
1474
|
}
|
|
1475
|
-
setIn(
|
|
1476
|
-
const [key, ...rest] =
|
|
1475
|
+
setIn(path, value) {
|
|
1476
|
+
const [key, ...rest] = path;
|
|
1477
1477
|
if (rest.length === 0) {
|
|
1478
1478
|
this.set(key, value);
|
|
1479
1479
|
} else {
|
|
@@ -3863,9 +3863,9 @@ var require_Document = __commonJS((exports) => {
|
|
|
3863
3863
|
if (assertCollection(this.contents))
|
|
3864
3864
|
this.contents.add(value);
|
|
3865
3865
|
}
|
|
3866
|
-
addIn(
|
|
3866
|
+
addIn(path, value) {
|
|
3867
3867
|
if (assertCollection(this.contents))
|
|
3868
|
-
this.contents.addIn(
|
|
3868
|
+
this.contents.addIn(path, value);
|
|
3869
3869
|
}
|
|
3870
3870
|
createAlias(node, name) {
|
|
3871
3871
|
if (!node.anchor) {
|
|
@@ -3914,30 +3914,30 @@ var require_Document = __commonJS((exports) => {
|
|
|
3914
3914
|
delete(key) {
|
|
3915
3915
|
return assertCollection(this.contents) ? this.contents.delete(key) : false;
|
|
3916
3916
|
}
|
|
3917
|
-
deleteIn(
|
|
3918
|
-
if (Collection.isEmptyPath(
|
|
3917
|
+
deleteIn(path) {
|
|
3918
|
+
if (Collection.isEmptyPath(path)) {
|
|
3919
3919
|
if (this.contents == null)
|
|
3920
3920
|
return false;
|
|
3921
3921
|
this.contents = null;
|
|
3922
3922
|
return true;
|
|
3923
3923
|
}
|
|
3924
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
3924
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path) : false;
|
|
3925
3925
|
}
|
|
3926
3926
|
get(key, keepScalar) {
|
|
3927
3927
|
return identity.isCollection(this.contents) ? this.contents.get(key, keepScalar) : undefined;
|
|
3928
3928
|
}
|
|
3929
|
-
getIn(
|
|
3930
|
-
if (Collection.isEmptyPath(
|
|
3929
|
+
getIn(path, keepScalar) {
|
|
3930
|
+
if (Collection.isEmptyPath(path))
|
|
3931
3931
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
3932
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
3932
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path, keepScalar) : undefined;
|
|
3933
3933
|
}
|
|
3934
3934
|
has(key) {
|
|
3935
3935
|
return identity.isCollection(this.contents) ? this.contents.has(key) : false;
|
|
3936
3936
|
}
|
|
3937
|
-
hasIn(
|
|
3938
|
-
if (Collection.isEmptyPath(
|
|
3937
|
+
hasIn(path) {
|
|
3938
|
+
if (Collection.isEmptyPath(path))
|
|
3939
3939
|
return this.contents !== undefined;
|
|
3940
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
3940
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path) : false;
|
|
3941
3941
|
}
|
|
3942
3942
|
set(key, value) {
|
|
3943
3943
|
if (this.contents == null) {
|
|
@@ -3946,13 +3946,13 @@ var require_Document = __commonJS((exports) => {
|
|
|
3946
3946
|
this.contents.set(key, value);
|
|
3947
3947
|
}
|
|
3948
3948
|
}
|
|
3949
|
-
setIn(
|
|
3950
|
-
if (Collection.isEmptyPath(
|
|
3949
|
+
setIn(path, value) {
|
|
3950
|
+
if (Collection.isEmptyPath(path)) {
|
|
3951
3951
|
this.contents = value;
|
|
3952
3952
|
} else if (this.contents == null) {
|
|
3953
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
3953
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
|
|
3954
3954
|
} else if (assertCollection(this.contents)) {
|
|
3955
|
-
this.contents.setIn(
|
|
3955
|
+
this.contents.setIn(path, value);
|
|
3956
3956
|
}
|
|
3957
3957
|
}
|
|
3958
3958
|
setSchema(version, options = {}) {
|
|
@@ -5846,9 +5846,9 @@ var require_cst_visit = __commonJS((exports) => {
|
|
|
5846
5846
|
visit.BREAK = BREAK;
|
|
5847
5847
|
visit.SKIP = SKIP;
|
|
5848
5848
|
visit.REMOVE = REMOVE;
|
|
5849
|
-
visit.itemAtPath = (cst,
|
|
5849
|
+
visit.itemAtPath = (cst, path) => {
|
|
5850
5850
|
let item = cst;
|
|
5851
|
-
for (const [field, index] of
|
|
5851
|
+
for (const [field, index] of path) {
|
|
5852
5852
|
const tok = item?.[field];
|
|
5853
5853
|
if (tok && "items" in tok) {
|
|
5854
5854
|
item = tok.items[index];
|
|
@@ -5857,23 +5857,23 @@ var require_cst_visit = __commonJS((exports) => {
|
|
|
5857
5857
|
}
|
|
5858
5858
|
return item;
|
|
5859
5859
|
};
|
|
5860
|
-
visit.parentCollection = (cst,
|
|
5861
|
-
const parent = visit.itemAtPath(cst,
|
|
5862
|
-
const field =
|
|
5860
|
+
visit.parentCollection = (cst, path) => {
|
|
5861
|
+
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
5862
|
+
const field = path[path.length - 1][0];
|
|
5863
5863
|
const coll = parent?.[field];
|
|
5864
5864
|
if (coll && "items" in coll)
|
|
5865
5865
|
return coll;
|
|
5866
5866
|
throw new Error("Parent collection not found");
|
|
5867
5867
|
};
|
|
5868
|
-
function _visit(
|
|
5869
|
-
let ctrl = visitor(item,
|
|
5868
|
+
function _visit(path, item, visitor) {
|
|
5869
|
+
let ctrl = visitor(item, path);
|
|
5870
5870
|
if (typeof ctrl === "symbol")
|
|
5871
5871
|
return ctrl;
|
|
5872
5872
|
for (const field of ["key", "value"]) {
|
|
5873
5873
|
const token = item[field];
|
|
5874
5874
|
if (token && "items" in token) {
|
|
5875
5875
|
for (let i = 0;i < token.items.length; ++i) {
|
|
5876
|
-
const ci = _visit(Object.freeze(
|
|
5876
|
+
const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
|
|
5877
5877
|
if (typeof ci === "number")
|
|
5878
5878
|
i = ci - 1;
|
|
5879
5879
|
else if (ci === BREAK)
|
|
@@ -5884,10 +5884,10 @@ var require_cst_visit = __commonJS((exports) => {
|
|
|
5884
5884
|
}
|
|
5885
5885
|
}
|
|
5886
5886
|
if (typeof ctrl === "function" && field === "key")
|
|
5887
|
-
ctrl = ctrl(item,
|
|
5887
|
+
ctrl = ctrl(item, path);
|
|
5888
5888
|
}
|
|
5889
5889
|
}
|
|
5890
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
5890
|
+
return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
|
|
5891
5891
|
}
|
|
5892
5892
|
exports.visit = visit;
|
|
5893
5893
|
});
|
|
@@ -7156,14 +7156,14 @@ var require_parser = __commonJS((exports) => {
|
|
|
7156
7156
|
case "scalar":
|
|
7157
7157
|
case "single-quoted-scalar":
|
|
7158
7158
|
case "double-quoted-scalar": {
|
|
7159
|
-
const
|
|
7159
|
+
const fs = this.flowScalar(this.type);
|
|
7160
7160
|
if (atNextItem || it.value) {
|
|
7161
|
-
map.items.push({ start, key:
|
|
7161
|
+
map.items.push({ start, key: fs, sep: [] });
|
|
7162
7162
|
this.onKeyLine = true;
|
|
7163
7163
|
} else if (it.sep) {
|
|
7164
|
-
this.stack.push(
|
|
7164
|
+
this.stack.push(fs);
|
|
7165
7165
|
} else {
|
|
7166
|
-
Object.assign(it, { key:
|
|
7166
|
+
Object.assign(it, { key: fs, sep: [] });
|
|
7167
7167
|
this.onKeyLine = true;
|
|
7168
7168
|
}
|
|
7169
7169
|
return;
|
|
@@ -7291,13 +7291,13 @@ var require_parser = __commonJS((exports) => {
|
|
|
7291
7291
|
case "scalar":
|
|
7292
7292
|
case "single-quoted-scalar":
|
|
7293
7293
|
case "double-quoted-scalar": {
|
|
7294
|
-
const
|
|
7294
|
+
const fs = this.flowScalar(this.type);
|
|
7295
7295
|
if (!it || it.value)
|
|
7296
|
-
fc.items.push({ start: [], key:
|
|
7296
|
+
fc.items.push({ start: [], key: fs, sep: [] });
|
|
7297
7297
|
else if (it.sep)
|
|
7298
|
-
this.stack.push(
|
|
7298
|
+
this.stack.push(fs);
|
|
7299
7299
|
else
|
|
7300
|
-
Object.assign(it, { key:
|
|
7300
|
+
Object.assign(it, { key: fs, sep: [] });
|
|
7301
7301
|
return;
|
|
7302
7302
|
}
|
|
7303
7303
|
case "flow-map-end":
|
|
@@ -8524,13 +8524,13 @@ var require_lib = __commonJS((exports) => {
|
|
|
8524
8524
|
this.preserveSpace = !!preserveSpace;
|
|
8525
8525
|
}
|
|
8526
8526
|
}
|
|
8527
|
-
var
|
|
8527
|
+
var types = {
|
|
8528
8528
|
brace: new TokContext("{"),
|
|
8529
8529
|
j_oTag: new TokContext("<tag"),
|
|
8530
8530
|
j_cTag: new TokContext("</tag"),
|
|
8531
8531
|
j_expr: new TokContext("<tag>...</tag>", true)
|
|
8532
8532
|
};
|
|
8533
|
-
|
|
8533
|
+
types.template = new TokContext("`", true);
|
|
8534
8534
|
var beforeExpr = true;
|
|
8535
8535
|
var startsExpr = true;
|
|
8536
8536
|
var isLoop = true;
|
|
@@ -9065,17 +9065,17 @@ var require_lib = __commonJS((exports) => {
|
|
|
9065
9065
|
context.pop();
|
|
9066
9066
|
};
|
|
9067
9067
|
tokenTypes[5].updateContext = tokenTypes[7].updateContext = tokenTypes[23].updateContext = (context) => {
|
|
9068
|
-
context.push(
|
|
9068
|
+
context.push(types.brace);
|
|
9069
9069
|
};
|
|
9070
9070
|
tokenTypes[22].updateContext = (context) => {
|
|
9071
|
-
if (context[context.length - 1] ===
|
|
9071
|
+
if (context[context.length - 1] === types.template) {
|
|
9072
9072
|
context.pop();
|
|
9073
9073
|
} else {
|
|
9074
|
-
context.push(
|
|
9074
|
+
context.push(types.template);
|
|
9075
9075
|
}
|
|
9076
9076
|
};
|
|
9077
9077
|
tokenTypes[143].updateContext = (context) => {
|
|
9078
|
-
context.push(
|
|
9078
|
+
context.push(types.j_expr, types.j_oTag);
|
|
9079
9079
|
};
|
|
9080
9080
|
var nonASCIIidentifierStartChars = "\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC";
|
|
9081
9081
|
var nonASCIIidentifierChars = "\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65";
|
|
@@ -9863,7 +9863,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
9863
9863
|
return this.finishNode(node, "TypeParameterDeclaration");
|
|
9864
9864
|
}
|
|
9865
9865
|
flowInTopLevelContext(cb) {
|
|
9866
|
-
if (this.curContext() !==
|
|
9866
|
+
if (this.curContext() !== types.brace) {
|
|
9867
9867
|
const oldContext = this.state.context;
|
|
9868
9868
|
this.state.context = [oldContext[0]];
|
|
9869
9869
|
try {
|
|
@@ -9898,7 +9898,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
9898
9898
|
this.state.noAnonFunctionType = oldNoAnonFunctionType;
|
|
9899
9899
|
});
|
|
9900
9900
|
this.state.inType = oldInType;
|
|
9901
|
-
if (!this.state.inType && this.curContext() ===
|
|
9901
|
+
if (!this.state.inType && this.curContext() === types.brace) {
|
|
9902
9902
|
this.reScan_lt_gt();
|
|
9903
9903
|
}
|
|
9904
9904
|
this.expect(48);
|
|
@@ -11173,7 +11173,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
11173
11173
|
context
|
|
11174
11174
|
} = this.state;
|
|
11175
11175
|
const currentContext = context[context.length - 1];
|
|
11176
|
-
if (currentContext ===
|
|
11176
|
+
if (currentContext === types.j_oTag || currentContext === types.j_expr) {
|
|
11177
11177
|
context.pop();
|
|
11178
11178
|
}
|
|
11179
11179
|
}
|
|
@@ -12279,9 +12279,9 @@ var require_lib = __commonJS((exports) => {
|
|
|
12279
12279
|
switch (this.state.type) {
|
|
12280
12280
|
case 5:
|
|
12281
12281
|
node = this.startNode();
|
|
12282
|
-
this.setContext(
|
|
12282
|
+
this.setContext(types.brace);
|
|
12283
12283
|
this.next();
|
|
12284
|
-
node = this.jsxParseExpressionContainer(node,
|
|
12284
|
+
node = this.jsxParseExpressionContainer(node, types.j_oTag);
|
|
12285
12285
|
if (node.expression.type === "JSXEmptyExpression") {
|
|
12286
12286
|
this.raise(JsxErrors.AttributeIsEmpty, node);
|
|
12287
12287
|
}
|
|
@@ -12300,7 +12300,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
12300
12300
|
jsxParseSpreadChild(node) {
|
|
12301
12301
|
this.next();
|
|
12302
12302
|
node.expression = this.parseExpression();
|
|
12303
|
-
this.setContext(
|
|
12303
|
+
this.setContext(types.j_expr);
|
|
12304
12304
|
this.state.canStartJSXElement = true;
|
|
12305
12305
|
this.expect(8);
|
|
12306
12306
|
return this.finishNode(node, "JSXSpreadChild");
|
|
@@ -12320,11 +12320,11 @@ var require_lib = __commonJS((exports) => {
|
|
|
12320
12320
|
jsxParseAttribute() {
|
|
12321
12321
|
const node = this.startNode();
|
|
12322
12322
|
if (this.match(5)) {
|
|
12323
|
-
this.setContext(
|
|
12323
|
+
this.setContext(types.brace);
|
|
12324
12324
|
this.next();
|
|
12325
12325
|
this.expect(21);
|
|
12326
12326
|
node.argument = this.parseMaybeAssignAllowIn();
|
|
12327
|
-
this.setContext(
|
|
12327
|
+
this.setContext(types.j_oTag);
|
|
12328
12328
|
this.state.canStartJSXElement = true;
|
|
12329
12329
|
this.expect(8);
|
|
12330
12330
|
return this.finishNode(node, "JSXSpreadAttribute");
|
|
@@ -12383,12 +12383,12 @@ var require_lib = __commonJS((exports) => {
|
|
|
12383
12383
|
break;
|
|
12384
12384
|
case 5: {
|
|
12385
12385
|
const node2 = this.startNode();
|
|
12386
|
-
this.setContext(
|
|
12386
|
+
this.setContext(types.brace);
|
|
12387
12387
|
this.next();
|
|
12388
12388
|
if (this.match(21)) {
|
|
12389
12389
|
children.push(this.jsxParseSpreadChild(node2));
|
|
12390
12390
|
} else {
|
|
12391
|
-
children.push(this.jsxParseExpressionContainer(node2,
|
|
12391
|
+
children.push(this.jsxParseExpressionContainer(node2, types.j_expr));
|
|
12392
12392
|
}
|
|
12393
12393
|
break;
|
|
12394
12394
|
}
|
|
@@ -12451,11 +12451,11 @@ var require_lib = __commonJS((exports) => {
|
|
|
12451
12451
|
}
|
|
12452
12452
|
getTokenFromCode(code2) {
|
|
12453
12453
|
const context = this.curContext();
|
|
12454
|
-
if (context ===
|
|
12454
|
+
if (context === types.j_expr) {
|
|
12455
12455
|
this.jsxReadToken();
|
|
12456
12456
|
return;
|
|
12457
12457
|
}
|
|
12458
|
-
if (context ===
|
|
12458
|
+
if (context === types.j_oTag || context === types.j_cTag) {
|
|
12459
12459
|
if (isIdentifierStart(code2)) {
|
|
12460
12460
|
this.jsxReadWord();
|
|
12461
12461
|
return;
|
|
@@ -12465,7 +12465,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
12465
12465
|
this.finishToken(144);
|
|
12466
12466
|
return;
|
|
12467
12467
|
}
|
|
12468
|
-
if ((code2 === 34 || code2 === 39) && context ===
|
|
12468
|
+
if ((code2 === 34 || code2 === 39) && context === types.j_oTag) {
|
|
12469
12469
|
this.jsxReadString(code2);
|
|
12470
12470
|
return;
|
|
12471
12471
|
}
|
|
@@ -12483,17 +12483,17 @@ var require_lib = __commonJS((exports) => {
|
|
|
12483
12483
|
type
|
|
12484
12484
|
} = this.state;
|
|
12485
12485
|
if (type === 56 && prevType === 143) {
|
|
12486
|
-
context.splice(-2, 2,
|
|
12486
|
+
context.splice(-2, 2, types.j_cTag);
|
|
12487
12487
|
this.state.canStartJSXElement = false;
|
|
12488
12488
|
} else if (type === 143) {
|
|
12489
|
-
context.push(
|
|
12489
|
+
context.push(types.j_oTag);
|
|
12490
12490
|
} else if (type === 144) {
|
|
12491
12491
|
const out = context[context.length - 1];
|
|
12492
|
-
if (out ===
|
|
12492
|
+
if (out === types.j_oTag && prevType === 56 || out === types.j_cTag) {
|
|
12493
12493
|
context.pop();
|
|
12494
|
-
this.state.canStartJSXElement = context[context.length - 1] ===
|
|
12494
|
+
this.state.canStartJSXElement = context[context.length - 1] === types.j_expr;
|
|
12495
12495
|
} else {
|
|
12496
|
-
this.setContext(
|
|
12496
|
+
this.setContext(types.j_expr);
|
|
12497
12497
|
this.state.canStartJSXElement = true;
|
|
12498
12498
|
}
|
|
12499
12499
|
} else {
|
|
@@ -12901,7 +12901,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
12901
12901
|
this.end = 0;
|
|
12902
12902
|
this.lastTokEndLoc = null;
|
|
12903
12903
|
this.lastTokStartLoc = null;
|
|
12904
|
-
this.context = [
|
|
12904
|
+
this.context = [types.brace];
|
|
12905
12905
|
this.firstInvalidTemplateEscapePos = null;
|
|
12906
12906
|
this.strictErrors = new Map;
|
|
12907
12907
|
this.tokensLength = 0;
|
|
@@ -16304,14 +16304,14 @@ var require_lib = __commonJS((exports) => {
|
|
|
16304
16304
|
tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
|
|
16305
16305
|
const node = this.startNode();
|
|
16306
16306
|
const hasLeadingOperator = this.eat(operator);
|
|
16307
|
-
const
|
|
16307
|
+
const types2 = [];
|
|
16308
16308
|
do {
|
|
16309
|
-
|
|
16309
|
+
types2.push(parseConstituentType());
|
|
16310
16310
|
} while (this.eat(operator));
|
|
16311
|
-
if (
|
|
16312
|
-
return
|
|
16311
|
+
if (types2.length === 1 && !hasLeadingOperator) {
|
|
16312
|
+
return types2[0];
|
|
16313
16313
|
}
|
|
16314
|
-
node.types =
|
|
16314
|
+
node.types = types2;
|
|
16315
16315
|
return this.finishNode(node, kind);
|
|
16316
16316
|
}
|
|
16317
16317
|
tsParseIntersectionTypeOrHigher() {
|
|
@@ -16557,7 +16557,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
16557
16557
|
return this.finishNode(node, "TSTypeAliasDeclaration");
|
|
16558
16558
|
}
|
|
16559
16559
|
tsInTopLevelContext(cb) {
|
|
16560
|
-
if (this.curContext() !==
|
|
16560
|
+
if (this.curContext() !== types.brace) {
|
|
16561
16561
|
const oldContext = this.state.context;
|
|
16562
16562
|
this.state.context = [oldContext[0]];
|
|
16563
16563
|
try {
|
|
@@ -16878,7 +16878,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
16878
16878
|
}));
|
|
16879
16879
|
if (node.params.length === 0) {
|
|
16880
16880
|
this.raise(TSErrors.EmptyTypeArguments, node);
|
|
16881
|
-
} else if (!this.state.inType && this.curContext() ===
|
|
16881
|
+
} else if (!this.state.inType && this.curContext() === types.brace) {
|
|
16882
16882
|
this.reScan_lt_gt();
|
|
16883
16883
|
}
|
|
16884
16884
|
this.expect(48);
|
|
@@ -17580,7 +17580,7 @@ var require_lib = __commonJS((exports) => {
|
|
|
17580
17580
|
context
|
|
17581
17581
|
} = this.state;
|
|
17582
17582
|
const currentContext = context[context.length - 1];
|
|
17583
|
-
if (currentContext ===
|
|
17583
|
+
if (currentContext === types.j_oTag || currentContext === types.j_expr) {
|
|
17584
17584
|
context.pop();
|
|
17585
17585
|
}
|
|
17586
17586
|
}
|
|
@@ -22504,15 +22504,28 @@ var init_ast_parser = __esm(() => {
|
|
|
22504
22504
|
});
|
|
22505
22505
|
|
|
22506
22506
|
// ../cms/src/content-config-ast.ts
|
|
22507
|
-
import
|
|
22508
|
-
import
|
|
22507
|
+
import fs from "fs/promises";
|
|
22508
|
+
import path from "path";
|
|
22509
|
+
function resolveExpression(node, bindings, visited = new Set) {
|
|
22510
|
+
let current = node;
|
|
22511
|
+
while (current.type === "Identifier") {
|
|
22512
|
+
if (visited.has(current.name))
|
|
22513
|
+
return current;
|
|
22514
|
+
visited.add(current.name);
|
|
22515
|
+
const next = bindings.get(current.name);
|
|
22516
|
+
if (!next)
|
|
22517
|
+
return current;
|
|
22518
|
+
current = next;
|
|
22519
|
+
}
|
|
22520
|
+
return current;
|
|
22521
|
+
}
|
|
22509
22522
|
async function parseContentConfig() {
|
|
22510
22523
|
const projectRoot = getProjectRoot();
|
|
22511
22524
|
for (const configPath of ["src/content/config.ts", "src/content.config.ts"]) {
|
|
22512
|
-
const fullPath =
|
|
22525
|
+
const fullPath = path.join(projectRoot, configPath);
|
|
22513
22526
|
let stat;
|
|
22514
22527
|
try {
|
|
22515
|
-
stat = await
|
|
22528
|
+
stat = await fs.stat(fullPath);
|
|
22516
22529
|
} catch {
|
|
22517
22530
|
continue;
|
|
22518
22531
|
}
|
|
@@ -22522,7 +22535,7 @@ async function parseContentConfig() {
|
|
|
22522
22535
|
return cached.parsed;
|
|
22523
22536
|
continue;
|
|
22524
22537
|
}
|
|
22525
|
-
const content = await
|
|
22538
|
+
const content = await fs.readFile(fullPath, "utf-8");
|
|
22526
22539
|
const parsed = parseConfigSource(content, configPath);
|
|
22527
22540
|
parseCache.set(fullPath, { mtimeMs: stat.mtimeMs, parsed });
|
|
22528
22541
|
if (parsed.size > 0)
|
|
@@ -22535,6 +22548,7 @@ function parseConfigSource(source, sourcePath) {
|
|
|
22535
22548
|
const ast = parseFrontmatter(source, sourcePath);
|
|
22536
22549
|
if (!ast)
|
|
22537
22550
|
return result;
|
|
22551
|
+
const bindings = new Map;
|
|
22538
22552
|
const collectionDecls = new Map;
|
|
22539
22553
|
const exportMap = new Map;
|
|
22540
22554
|
for (const stmt of ast.program.body) {
|
|
@@ -22546,6 +22560,7 @@ function parseConfigSource(source, sourcePath) {
|
|
|
22546
22560
|
continue;
|
|
22547
22561
|
if (!decl.init)
|
|
22548
22562
|
continue;
|
|
22563
|
+
bindings.set(decl.id.name, decl.init);
|
|
22549
22564
|
if (decl.id.name === "collections" && decl.init.type === "ObjectExpression") {
|
|
22550
22565
|
for (const prop of decl.init.properties) {
|
|
22551
22566
|
if (prop.type !== "ObjectProperty")
|
|
@@ -22574,12 +22589,12 @@ function parseConfigSource(source, sourcePath) {
|
|
|
22574
22589
|
const schemaProperty = decl.properties.find((p) => p.type === "ObjectProperty" && propertyKeyName(p.key) === "schema");
|
|
22575
22590
|
if (!schemaProperty)
|
|
22576
22591
|
continue;
|
|
22577
|
-
const schemaObject = unwrapSchemaToObject(schemaProperty.value);
|
|
22592
|
+
const schemaObject = unwrapSchemaToObject(schemaProperty.value, bindings);
|
|
22578
22593
|
if (!schemaObject)
|
|
22579
22594
|
continue;
|
|
22580
22595
|
result.set(collectionName, {
|
|
22581
22596
|
name: collectionName,
|
|
22582
|
-
fields: parseSchemaFields(schemaObject)
|
|
22597
|
+
fields: parseSchemaFields(schemaObject, bindings)
|
|
22583
22598
|
});
|
|
22584
22599
|
}
|
|
22585
22600
|
return result;
|
|
@@ -22594,30 +22609,34 @@ function propertyKeyName(key) {
|
|
|
22594
22609
|
return key.value;
|
|
22595
22610
|
return null;
|
|
22596
22611
|
}
|
|
22597
|
-
function unwrapSchemaToObject(node) {
|
|
22598
|
-
|
|
22599
|
-
|
|
22612
|
+
function unwrapSchemaToObject(node, bindings) {
|
|
22613
|
+
const resolved = resolveExpression(node, bindings);
|
|
22614
|
+
if (resolved.type === "ArrowFunctionExpression" || resolved.type === "FunctionExpression") {
|
|
22615
|
+
const body = resolved.body;
|
|
22600
22616
|
if (body.type === "BlockStatement") {
|
|
22601
22617
|
for (const stmt of body.body) {
|
|
22602
22618
|
if (stmt.type === "ReturnStatement" && stmt.argument) {
|
|
22603
|
-
return unwrapSchemaToObject(stmt.argument);
|
|
22619
|
+
return unwrapSchemaToObject(stmt.argument, bindings);
|
|
22604
22620
|
}
|
|
22605
22621
|
}
|
|
22606
22622
|
return null;
|
|
22607
22623
|
}
|
|
22608
|
-
return unwrapSchemaToObject(body);
|
|
22624
|
+
return unwrapSchemaToObject(body, bindings);
|
|
22609
22625
|
}
|
|
22610
|
-
if (
|
|
22611
|
-
const callee =
|
|
22626
|
+
if (resolved.type === "CallExpression") {
|
|
22627
|
+
const callee = resolved.callee;
|
|
22612
22628
|
if (callee.type === "MemberExpression" && callee.object.type === "Identifier" && (callee.object.name === "z" || callee.object.name === "n") && callee.property.type === "Identifier" && callee.property.name === "object") {
|
|
22613
|
-
const arg =
|
|
22614
|
-
if (arg
|
|
22615
|
-
return
|
|
22629
|
+
const arg = resolved.arguments[0];
|
|
22630
|
+
if (!arg)
|
|
22631
|
+
return null;
|
|
22632
|
+
const resolvedArg = resolveExpression(arg, bindings);
|
|
22633
|
+
if (resolvedArg.type === "ObjectExpression")
|
|
22634
|
+
return resolvedArg;
|
|
22616
22635
|
}
|
|
22617
22636
|
}
|
|
22618
22637
|
return null;
|
|
22619
22638
|
}
|
|
22620
|
-
function parseSchemaFields(schemaObject) {
|
|
22639
|
+
function parseSchemaFields(schemaObject, bindings) {
|
|
22621
22640
|
const fields = [];
|
|
22622
22641
|
for (const prop of schemaObject.properties) {
|
|
22623
22642
|
if (prop.type !== "ObjectProperty")
|
|
@@ -22626,18 +22645,18 @@ function parseSchemaFields(schemaObject) {
|
|
|
22626
22645
|
if (!name)
|
|
22627
22646
|
continue;
|
|
22628
22647
|
const field = { name, required: true };
|
|
22629
|
-
analyzeFieldExpression(prop.value, field);
|
|
22648
|
+
analyzeFieldExpression(prop.value, field, bindings);
|
|
22630
22649
|
fields.push(field);
|
|
22631
22650
|
}
|
|
22632
22651
|
return fields;
|
|
22633
22652
|
}
|
|
22634
|
-
function analyzeFieldExpression(node, field) {
|
|
22635
|
-
let current = node;
|
|
22653
|
+
function analyzeFieldExpression(node, field, bindings) {
|
|
22654
|
+
let current = resolveExpression(node, bindings);
|
|
22636
22655
|
while (current) {
|
|
22637
22656
|
if (current.type !== "CallExpression")
|
|
22638
22657
|
return;
|
|
22639
22658
|
if (isBaseCall(current)) {
|
|
22640
|
-
analyzeBaseCall(current, field);
|
|
22659
|
+
analyzeBaseCall(current, field, bindings);
|
|
22641
22660
|
return;
|
|
22642
22661
|
}
|
|
22643
22662
|
if (current.callee.type !== "MemberExpression")
|
|
@@ -22651,7 +22670,7 @@ function analyzeFieldExpression(node, field) {
|
|
|
22651
22670
|
const direction = arg?.type === "StringLiteral" && arg.value === "desc" ? "desc" : "asc";
|
|
22652
22671
|
field.orderBy = { direction };
|
|
22653
22672
|
}
|
|
22654
|
-
current = current.callee.object;
|
|
22673
|
+
current = resolveExpression(current.callee.object, bindings);
|
|
22655
22674
|
}
|
|
22656
22675
|
}
|
|
22657
22676
|
function isBaseCall(node) {
|
|
@@ -22664,7 +22683,7 @@ function isBaseCall(node) {
|
|
|
22664
22683
|
}
|
|
22665
22684
|
return false;
|
|
22666
22685
|
}
|
|
22667
|
-
function analyzeBaseCall(node, field) {
|
|
22686
|
+
function analyzeBaseCall(node, field, bindings) {
|
|
22668
22687
|
const callee = node.callee;
|
|
22669
22688
|
if (callee.type === "Identifier") {
|
|
22670
22689
|
if (callee.name === "image") {
|
|
@@ -22712,14 +22731,36 @@ function analyzeBaseCall(node, field) {
|
|
|
22712
22731
|
}
|
|
22713
22732
|
return;
|
|
22714
22733
|
}
|
|
22734
|
+
if ((ns === "z" || ns === "n") && fn === "object") {
|
|
22735
|
+
const arg = node.arguments[0];
|
|
22736
|
+
if (!arg)
|
|
22737
|
+
return;
|
|
22738
|
+
const resolved = resolveExpression(arg, bindings);
|
|
22739
|
+
if (resolved.type === "ObjectExpression") {
|
|
22740
|
+
field.type = "object";
|
|
22741
|
+
field.fields = parseSchemaFields(resolved, bindings);
|
|
22742
|
+
}
|
|
22743
|
+
return;
|
|
22744
|
+
}
|
|
22715
22745
|
if ((ns === "z" || ns === "n") && fn === "array") {
|
|
22716
|
-
const
|
|
22717
|
-
if (
|
|
22746
|
+
const innerRaw = node.arguments[0];
|
|
22747
|
+
if (!innerRaw)
|
|
22748
|
+
return;
|
|
22749
|
+
const inner = resolveExpression(innerRaw, bindings);
|
|
22750
|
+
if (inner.type === "CallExpression" && inner.callee.type === "Identifier" && inner.callee.name === "reference") {
|
|
22718
22751
|
const target = inner.arguments[0];
|
|
22719
22752
|
if (target?.type === "StringLiteral") {
|
|
22720
22753
|
field.reference = { target: target.value, isArray: true };
|
|
22721
22754
|
}
|
|
22755
|
+
return;
|
|
22722
22756
|
}
|
|
22757
|
+
const innerField = { name: "__item__", required: true };
|
|
22758
|
+
analyzeFieldExpression(inner, innerField, bindings);
|
|
22759
|
+
field.type = "array";
|
|
22760
|
+
if (innerField.type)
|
|
22761
|
+
field.itemType = innerField.type;
|
|
22762
|
+
if (innerField.fields)
|
|
22763
|
+
field.fields = innerField.fields;
|
|
22723
22764
|
return;
|
|
22724
22765
|
}
|
|
22725
22766
|
}
|
|
@@ -22752,6 +22793,7 @@ var init_content_config_ast = __esm(() => {
|
|
|
22752
22793
|
"text",
|
|
22753
22794
|
"number",
|
|
22754
22795
|
"image",
|
|
22796
|
+
"file",
|
|
22755
22797
|
"url",
|
|
22756
22798
|
"email",
|
|
22757
22799
|
"tel",
|
|
@@ -22759,6 +22801,8 @@ var init_content_config_ast = __esm(() => {
|
|
|
22759
22801
|
"date",
|
|
22760
22802
|
"datetime",
|
|
22761
22803
|
"time",
|
|
22804
|
+
"year",
|
|
22805
|
+
"month",
|
|
22762
22806
|
"textarea"
|
|
22763
22807
|
]);
|
|
22764
22808
|
VALID_HINT_KEYS = new Set([
|
|
@@ -22784,8 +22828,11 @@ function slugifyHref(text) {
|
|
|
22784
22828
|
}
|
|
22785
22829
|
|
|
22786
22830
|
// ../cms/src/collection-scanner.ts
|
|
22787
|
-
import
|
|
22788
|
-
import
|
|
22831
|
+
import fs2 from "fs/promises";
|
|
22832
|
+
import path2 from "path";
|
|
22833
|
+
function normalizeFieldName(name) {
|
|
22834
|
+
return name.toLowerCase().replace(/[_-]/g, "");
|
|
22835
|
+
}
|
|
22789
22836
|
function extractFrontmatterBlock(content) {
|
|
22790
22837
|
const match = content.match(FRONTMATTER_PATTERN);
|
|
22791
22838
|
return match?.[1] ?? null;
|
|
@@ -22831,7 +22878,7 @@ function parseFieldDirectives(content) {
|
|
|
22831
22878
|
}
|
|
22832
22879
|
function assignFieldMetadata(fields, directives) {
|
|
22833
22880
|
for (const field of fields) {
|
|
22834
|
-
if (SIDEBAR_FIELD_NAMES.has(field.name
|
|
22881
|
+
if (SIDEBAR_FIELD_NAMES.has(normalizeFieldName(field.name)) || field.type === "image" || field.type === "boolean") {
|
|
22835
22882
|
field.position = "sidebar";
|
|
22836
22883
|
} else {
|
|
22837
22884
|
field.position = "header";
|
|
@@ -22883,7 +22930,9 @@ function inferFieldType(value, key) {
|
|
|
22883
22930
|
}
|
|
22884
22931
|
return "text";
|
|
22885
22932
|
}
|
|
22886
|
-
function mergeFieldObservations(observations) {
|
|
22933
|
+
function mergeFieldObservations(observations, depth = 0) {
|
|
22934
|
+
if (depth >= MAX_NESTED_FIELD_DEPTH)
|
|
22935
|
+
return [];
|
|
22887
22936
|
const fields = [];
|
|
22888
22937
|
for (const obs of observations) {
|
|
22889
22938
|
const nonNullValues = obs.values.filter((v2) => v2 !== null && v2 !== undefined);
|
|
@@ -22908,7 +22957,7 @@ function mergeFieldObservations(observations) {
|
|
|
22908
22957
|
required: obs.presentCount === obs.totalEntries,
|
|
22909
22958
|
examples: nonNullValues.slice(0, 3)
|
|
22910
22959
|
};
|
|
22911
|
-
if (fieldType === "text" && !FREE_TEXT_FIELD_NAMES.has(obs.name
|
|
22960
|
+
if (fieldType === "text" && !FREE_TEXT_FIELD_NAMES.has(normalizeFieldName(obs.name))) {
|
|
22912
22961
|
const uniqueValues = [...new Set(nonNullValues.map((v2) => String(v2)))];
|
|
22913
22962
|
const uniqueRatio = uniqueValues.length / nonNullValues.length;
|
|
22914
22963
|
if (uniqueValues.length > 0 && uniqueValues.length <= MAX_SELECT_OPTIONS && nonNullValues.length >= 2 && uniqueRatio <= 0.8) {
|
|
@@ -22934,11 +22983,21 @@ function mergeFieldObservations(observations) {
|
|
|
22934
22983
|
for (const item of objectItems) {
|
|
22935
22984
|
collectFieldObservations(subFieldMap, item, objectItems.length);
|
|
22936
22985
|
}
|
|
22937
|
-
field.fields = mergeFieldObservations(Array.from(subFieldMap.values()));
|
|
22986
|
+
field.fields = mergeFieldObservations(Array.from(subFieldMap.values()), depth + 1);
|
|
22938
22987
|
}
|
|
22939
22988
|
}
|
|
22940
22989
|
}
|
|
22941
22990
|
}
|
|
22991
|
+
if (fieldType === "object") {
|
|
22992
|
+
const objectValues = nonNullValues.filter((v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2));
|
|
22993
|
+
if (objectValues.length > 0) {
|
|
22994
|
+
const subFieldMap = new Map;
|
|
22995
|
+
for (const item of objectValues) {
|
|
22996
|
+
collectFieldObservations(subFieldMap, item, objectValues.length);
|
|
22997
|
+
}
|
|
22998
|
+
field.fields = mergeFieldObservations(Array.from(subFieldMap.values()), depth + 1);
|
|
22999
|
+
}
|
|
23000
|
+
}
|
|
22942
23001
|
fields.push(field);
|
|
22943
23002
|
}
|
|
22944
23003
|
return fields;
|
|
@@ -22964,7 +23023,7 @@ function buildCollectionDefinition(collectionName, contentDir, fieldMap, entryIn
|
|
|
22964
23023
|
return {
|
|
22965
23024
|
name: collectionName,
|
|
22966
23025
|
label,
|
|
22967
|
-
path:
|
|
23026
|
+
path: path2.join(contentDir, collectionName),
|
|
22968
23027
|
entryCount,
|
|
22969
23028
|
fields,
|
|
22970
23029
|
fileExtension: "md",
|
|
@@ -22974,7 +23033,7 @@ function buildCollectionDefinition(collectionName, contentDir, fieldMap, entryIn
|
|
|
22974
23033
|
}
|
|
22975
23034
|
async function scanCollection(collectionPath, collectionName, contentDir) {
|
|
22976
23035
|
try {
|
|
22977
|
-
const dirEntries = await
|
|
23036
|
+
const dirEntries = await fs2.readdir(collectionPath, { withFileTypes: true });
|
|
22978
23037
|
const sources = [];
|
|
22979
23038
|
const takenSlugs = new Set;
|
|
22980
23039
|
for (const entry of dirEntries) {
|
|
@@ -22991,9 +23050,9 @@ async function scanCollection(collectionPath, collectionName, contentDir) {
|
|
|
22991
23050
|
if (takenSlugs.has(dir.name))
|
|
22992
23051
|
return null;
|
|
22993
23052
|
for (const ext of ["md", "mdx"]) {
|
|
22994
|
-
const relPath =
|
|
23053
|
+
const relPath = path2.join(dir.name, `index.${ext}`);
|
|
22995
23054
|
try {
|
|
22996
|
-
await
|
|
23055
|
+
await fs2.access(path2.join(collectionPath, relPath));
|
|
22997
23056
|
return { slug: dir.name, relPath };
|
|
22998
23057
|
} catch {}
|
|
22999
23058
|
}
|
|
@@ -23011,7 +23070,7 @@ async function scanCollection(collectionPath, collectionName, contentDir) {
|
|
|
23011
23070
|
const allDirectives = {};
|
|
23012
23071
|
const entryInfos = [];
|
|
23013
23072
|
let hasDraft = false;
|
|
23014
|
-
const fileContents = await Promise.all(sources.map((s) =>
|
|
23073
|
+
const fileContents = await Promise.all(sources.map((s) => fs2.readFile(path2.join(collectionPath, s.relPath), "utf-8")));
|
|
23015
23074
|
for (let i = 0;i < sources.length; i++) {
|
|
23016
23075
|
const source = sources[i];
|
|
23017
23076
|
const content = fileContents[i];
|
|
@@ -23024,7 +23083,7 @@ async function scanCollection(collectionPath, collectionName, contentDir) {
|
|
|
23024
23083
|
}
|
|
23025
23084
|
const entryInfo = {
|
|
23026
23085
|
slug: source.slug,
|
|
23027
|
-
sourcePath:
|
|
23086
|
+
sourcePath: path2.join(contentDir, collectionName, source.relPath)
|
|
23028
23087
|
};
|
|
23029
23088
|
if (frontmatter) {
|
|
23030
23089
|
if (typeof frontmatter.title === "string") {
|
|
@@ -23066,19 +23125,53 @@ function applyParsedConfig(collections, parsed) {
|
|
|
23066
23125
|
const field = fieldsByName.get(pf.name);
|
|
23067
23126
|
if (!field)
|
|
23068
23127
|
continue;
|
|
23069
|
-
|
|
23070
|
-
field.type = pf.type;
|
|
23071
|
-
if (pf.options)
|
|
23072
|
-
field.options = pf.options;
|
|
23073
|
-
}
|
|
23074
|
-
if (pf.hints)
|
|
23075
|
-
field.hints = pf.hints;
|
|
23076
|
-
if (pf.astroImage)
|
|
23077
|
-
field.astroImage = true;
|
|
23078
|
-
field.required = pf.required;
|
|
23128
|
+
applyParsedFieldOverrides(field, pf);
|
|
23079
23129
|
}
|
|
23080
23130
|
}
|
|
23081
23131
|
}
|
|
23132
|
+
function applyParsedFieldOverrides(field, pf) {
|
|
23133
|
+
if (pf.type) {
|
|
23134
|
+
field.type = pf.type;
|
|
23135
|
+
if (pf.options)
|
|
23136
|
+
field.options = pf.options;
|
|
23137
|
+
}
|
|
23138
|
+
if (pf.itemType)
|
|
23139
|
+
field.itemType = pf.itemType;
|
|
23140
|
+
if (pf.hints)
|
|
23141
|
+
field.hints = pf.hints;
|
|
23142
|
+
if (pf.astroImage)
|
|
23143
|
+
field.astroImage = true;
|
|
23144
|
+
field.required = pf.required;
|
|
23145
|
+
if (pf.fields) {
|
|
23146
|
+
const existingByName = new Map((field.fields ?? []).map((f) => [f.name, f]));
|
|
23147
|
+
field.fields = pf.fields.map((subPf) => {
|
|
23148
|
+
const existing = existingByName.get(subPf.name);
|
|
23149
|
+
if (existing) {
|
|
23150
|
+
applyParsedFieldOverrides(existing, subPf);
|
|
23151
|
+
return existing;
|
|
23152
|
+
}
|
|
23153
|
+
return parsedFieldToFieldDefinition(subPf);
|
|
23154
|
+
});
|
|
23155
|
+
}
|
|
23156
|
+
}
|
|
23157
|
+
function parsedFieldToFieldDefinition(pf) {
|
|
23158
|
+
const fd = {
|
|
23159
|
+
name: pf.name,
|
|
23160
|
+
type: pf.type ?? (pf.fields ? "object" : "text"),
|
|
23161
|
+
required: pf.required
|
|
23162
|
+
};
|
|
23163
|
+
if (pf.options)
|
|
23164
|
+
fd.options = pf.options;
|
|
23165
|
+
if (pf.itemType)
|
|
23166
|
+
fd.itemType = pf.itemType;
|
|
23167
|
+
if (pf.hints)
|
|
23168
|
+
fd.hints = pf.hints;
|
|
23169
|
+
if (pf.astroImage)
|
|
23170
|
+
fd.astroImage = true;
|
|
23171
|
+
if (pf.fields)
|
|
23172
|
+
fd.fields = pf.fields.map(parsedFieldToFieldDefinition);
|
|
23173
|
+
return fd;
|
|
23174
|
+
}
|
|
23082
23175
|
function applyCollectionOrderBy(collections, parsed) {
|
|
23083
23176
|
for (const [collectionName, parsedColl] of parsed) {
|
|
23084
23177
|
const orderField = parsedColl.fields.find((f) => f.orderBy);
|
|
@@ -23206,6 +23299,30 @@ function detectReferenceFieldsBySlugMatch(collections) {
|
|
|
23206
23299
|
}
|
|
23207
23300
|
}
|
|
23208
23301
|
}
|
|
23302
|
+
function assignSemanticRoles(collections) {
|
|
23303
|
+
for (const def of Object.values(collections)) {
|
|
23304
|
+
let toggle;
|
|
23305
|
+
let dateByName;
|
|
23306
|
+
let dateByType;
|
|
23307
|
+
for (const field of def.fields) {
|
|
23308
|
+
if (field.hidden || field.role)
|
|
23309
|
+
continue;
|
|
23310
|
+
const normalized = normalizeFieldName(field.name);
|
|
23311
|
+
if (!toggle && field.type === "boolean" && PUBLISH_TOGGLE_NAMES.has(normalized)) {
|
|
23312
|
+
toggle = field;
|
|
23313
|
+
} else if (!dateByName && PUBLISH_DATE_NAMES.has(normalized)) {
|
|
23314
|
+
dateByName = field;
|
|
23315
|
+
} else if (!dateByType && (field.type === "date" || field.type === "datetime")) {
|
|
23316
|
+
dateByType = field;
|
|
23317
|
+
}
|
|
23318
|
+
}
|
|
23319
|
+
if (toggle)
|
|
23320
|
+
toggle.role = "publish-toggle";
|
|
23321
|
+
const date = dateByName ?? dateByType;
|
|
23322
|
+
if (date)
|
|
23323
|
+
date.role = "publish-date";
|
|
23324
|
+
}
|
|
23325
|
+
}
|
|
23209
23326
|
function detectDerivedHrefFields(collections) {
|
|
23210
23327
|
for (const def of Object.values(collections)) {
|
|
23211
23328
|
const fieldsByName = new Map(def.fields.map((f) => [f.name, f]));
|
|
@@ -23248,7 +23365,7 @@ function detectDerivedHrefFields(collections) {
|
|
|
23248
23365
|
}
|
|
23249
23366
|
async function scanDataCollection(collectionPath, collectionName, contentDir) {
|
|
23250
23367
|
try {
|
|
23251
|
-
const dirEntries = await
|
|
23368
|
+
const dirEntries = await fs2.readdir(collectionPath, { withFileTypes: true });
|
|
23252
23369
|
const sources = [];
|
|
23253
23370
|
const takenSlugs = new Set;
|
|
23254
23371
|
for (const entry of dirEntries) {
|
|
@@ -23265,9 +23382,9 @@ async function scanDataCollection(collectionPath, collectionName, contentDir) {
|
|
|
23265
23382
|
if (takenSlugs.has(dir.name))
|
|
23266
23383
|
return null;
|
|
23267
23384
|
for (const indexExt of ["json", "yaml", "yml"]) {
|
|
23268
|
-
const relPath =
|
|
23385
|
+
const relPath = path2.join(dir.name, `index.${indexExt}`);
|
|
23269
23386
|
try {
|
|
23270
|
-
await
|
|
23387
|
+
await fs2.access(path2.join(collectionPath, relPath));
|
|
23271
23388
|
return { slug: dir.name, relPath };
|
|
23272
23389
|
} catch {}
|
|
23273
23390
|
}
|
|
@@ -23282,7 +23399,7 @@ async function scanDataCollection(collectionPath, collectionName, contentDir) {
|
|
|
23282
23399
|
const fieldMap = new Map;
|
|
23283
23400
|
const entryInfos = [];
|
|
23284
23401
|
const ext = sources.some((s) => s.relPath.endsWith(".json")) ? "json" : sources.some((s) => s.relPath.endsWith(".yaml")) ? "yaml" : "yml";
|
|
23285
|
-
const fileContents = await Promise.all(sources.map((s) =>
|
|
23402
|
+
const fileContents = await Promise.all(sources.map((s) => fs2.readFile(path2.join(collectionPath, s.relPath), "utf-8").catch(() => null)));
|
|
23286
23403
|
for (let i = 0;i < sources.length; i++) {
|
|
23287
23404
|
const source = sources[i];
|
|
23288
23405
|
const raw = fileContents[i];
|
|
@@ -23300,7 +23417,7 @@ async function scanDataCollection(collectionPath, collectionName, contentDir) {
|
|
|
23300
23417
|
entryInfos.push({
|
|
23301
23418
|
slug: source.slug,
|
|
23302
23419
|
title,
|
|
23303
|
-
sourcePath:
|
|
23420
|
+
sourcePath: path2.join(contentDir, collectionName, source.relPath),
|
|
23304
23421
|
data
|
|
23305
23422
|
});
|
|
23306
23423
|
collectFieldObservations(fieldMap, data, sources.length);
|
|
@@ -23315,12 +23432,12 @@ async function scanDataCollection(collectionPath, collectionName, contentDir) {
|
|
|
23315
23432
|
}
|
|
23316
23433
|
async function scanCollections(contentDir = "src/content") {
|
|
23317
23434
|
const projectRoot = getProjectRoot();
|
|
23318
|
-
const fullContentDir =
|
|
23435
|
+
const fullContentDir = path2.isAbsolute(contentDir) ? contentDir : path2.join(projectRoot, contentDir);
|
|
23319
23436
|
const collections = {};
|
|
23320
23437
|
try {
|
|
23321
|
-
const entries = await
|
|
23438
|
+
const entries = await fs2.readdir(fullContentDir, { withFileTypes: true });
|
|
23322
23439
|
const scanPromises = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith("_") && !entry.name.startsWith(".")).map(async (entry) => {
|
|
23323
|
-
const collectionPath =
|
|
23440
|
+
const collectionPath = path2.join(fullContentDir, entry.name);
|
|
23324
23441
|
const definition = await scanCollection(collectionPath, entry.name, contentDir) ?? await scanDataCollection(collectionPath, entry.name, contentDir);
|
|
23325
23442
|
if (definition) {
|
|
23326
23443
|
collections[entry.name] = definition;
|
|
@@ -23332,10 +23449,11 @@ async function scanCollections(contentDir = "src/content") {
|
|
|
23332
23449
|
applyParsedConfig(collections, parsed);
|
|
23333
23450
|
detectReferenceFields(collections, parsed);
|
|
23334
23451
|
detectDerivedHrefFields(collections);
|
|
23452
|
+
assignSemanticRoles(collections);
|
|
23335
23453
|
applyCollectionOrderBy(collections, parsed);
|
|
23336
23454
|
return collections;
|
|
23337
23455
|
}
|
|
23338
|
-
var import_yaml, DATE_PATTERN, URL_PATTERN, IMAGE_EXTENSIONS, MAX_SELECT_OPTIONS = 10, TEXTAREA_MIN_LENGTH = 200, SIDEBAR_FIELD_NAMES, DIRECTIVE_PATTERN, FREE_TEXT_FIELD_NAMES, FRONTMATTER_PATTERN, HREF_SUFFIXES;
|
|
23456
|
+
var import_yaml, 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, FRONTMATTER_PATTERN, MAX_NESTED_FIELD_DEPTH = 16, HREF_SUFFIXES;
|
|
23339
23457
|
var init_collection_scanner = __esm(() => {
|
|
23340
23458
|
init_config();
|
|
23341
23459
|
init_content_config_ast();
|
|
@@ -23370,13 +23488,23 @@ var init_collection_scanner = __esm(() => {
|
|
|
23370
23488
|
"alt",
|
|
23371
23489
|
"caption"
|
|
23372
23490
|
]);
|
|
23491
|
+
PUBLISH_TOGGLE_NAMES = new Set(["draft", "isdraft", "published", "ispublished", "unpublished"]);
|
|
23492
|
+
PUBLISH_DATE_NAMES = new Set([
|
|
23493
|
+
"date",
|
|
23494
|
+
"pubdate",
|
|
23495
|
+
"publishdate",
|
|
23496
|
+
"publisheddate",
|
|
23497
|
+
"publishedate",
|
|
23498
|
+
"publishedat",
|
|
23499
|
+
"datepublished"
|
|
23500
|
+
]);
|
|
23373
23501
|
FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
23374
23502
|
HREF_SUFFIXES = ["href", "url", "link", "slug", "path"];
|
|
23375
23503
|
});
|
|
23376
23504
|
|
|
23377
23505
|
// ../cms/src/component-registry.ts
|
|
23378
|
-
import
|
|
23379
|
-
import
|
|
23506
|
+
import fs3 from "fs/promises";
|
|
23507
|
+
import path3 from "path";
|
|
23380
23508
|
|
|
23381
23509
|
class ComponentRegistry {
|
|
23382
23510
|
components = new Map;
|
|
@@ -23386,7 +23514,7 @@ class ComponentRegistry {
|
|
|
23386
23514
|
}
|
|
23387
23515
|
async scan() {
|
|
23388
23516
|
for (const dir of this.componentDirs) {
|
|
23389
|
-
const fullPath =
|
|
23517
|
+
const fullPath = path3.join(getProjectRoot(), dir);
|
|
23390
23518
|
try {
|
|
23391
23519
|
await this.scanDirectory(fullPath, dir);
|
|
23392
23520
|
} catch {}
|
|
@@ -23399,10 +23527,10 @@ class ComponentRegistry {
|
|
|
23399
23527
|
return this.components.get(name);
|
|
23400
23528
|
}
|
|
23401
23529
|
async scanDirectory(dir, relativePath) {
|
|
23402
|
-
const entries = await
|
|
23530
|
+
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
23403
23531
|
for (const entry of entries) {
|
|
23404
|
-
const fullPath =
|
|
23405
|
-
const relPath =
|
|
23532
|
+
const fullPath = path3.join(dir, entry.name);
|
|
23533
|
+
const relPath = path3.join(relativePath, entry.name);
|
|
23406
23534
|
if (entry.isDirectory()) {
|
|
23407
23535
|
await this.scanDirectory(fullPath, relPath);
|
|
23408
23536
|
} else if (entry.isFile() && entry.name.endsWith(".astro")) {
|
|
@@ -23412,8 +23540,8 @@ class ComponentRegistry {
|
|
|
23412
23540
|
}
|
|
23413
23541
|
async parseComponent(filePath, relativePath) {
|
|
23414
23542
|
try {
|
|
23415
|
-
const content = await
|
|
23416
|
-
const componentName =
|
|
23543
|
+
const content = await fs3.readFile(filePath, "utf-8");
|
|
23544
|
+
const componentName = path3.basename(filePath, ".astro");
|
|
23417
23545
|
const props = await this.extractProps(content);
|
|
23418
23546
|
const slots = this.extractSlots(content);
|
|
23419
23547
|
const description = this.extractDescription(content);
|
|
@@ -23672,14 +23800,14 @@ var init_local = __esm(() => {
|
|
|
23672
23800
|
});
|
|
23673
23801
|
|
|
23674
23802
|
// ../cms/src/media/project-images.ts
|
|
23675
|
-
import
|
|
23676
|
-
import
|
|
23803
|
+
import fs4 from "fs/promises";
|
|
23804
|
+
import path4 from "path";
|
|
23677
23805
|
async function listProjectImages(options) {
|
|
23678
23806
|
const root = getProjectRoot();
|
|
23679
|
-
const excludeDir = options?.excludeDir ?
|
|
23807
|
+
const excludeDir = options?.excludeDir ? path4.resolve(options.excludeDir) : null;
|
|
23680
23808
|
const scanDirs = [
|
|
23681
|
-
{ dir:
|
|
23682
|
-
{ dir:
|
|
23809
|
+
{ dir: path4.join(root, "public"), urlPrefix: "" },
|
|
23810
|
+
{ dir: path4.join(root, "src"), urlPrefix: null }
|
|
23683
23811
|
];
|
|
23684
23812
|
const results = await Promise.all(scanDirs.map(({ dir, urlPrefix }) => {
|
|
23685
23813
|
const items2 = [];
|
|
@@ -23690,11 +23818,11 @@ async function listProjectImages(options) {
|
|
|
23690
23818
|
return items;
|
|
23691
23819
|
}
|
|
23692
23820
|
async function scanDirectory(currentDir, baseDir, urlPrefix, excludeDir, items) {
|
|
23693
|
-
if (excludeDir &&
|
|
23821
|
+
if (excludeDir && path4.resolve(currentDir) === excludeDir)
|
|
23694
23822
|
return;
|
|
23695
23823
|
let entries;
|
|
23696
23824
|
try {
|
|
23697
|
-
entries = await
|
|
23825
|
+
entries = await fs4.readdir(currentDir, { withFileTypes: true });
|
|
23698
23826
|
} catch {
|
|
23699
23827
|
return;
|
|
23700
23828
|
}
|
|
@@ -23703,15 +23831,15 @@ async function scanDirectory(currentDir, baseDir, urlPrefix, excludeDir, items)
|
|
|
23703
23831
|
const name = String(entry.name);
|
|
23704
23832
|
if (name.startsWith(".") || name === "node_modules")
|
|
23705
23833
|
continue;
|
|
23706
|
-
const fullPath =
|
|
23834
|
+
const fullPath = path4.join(currentDir, name);
|
|
23707
23835
|
if (entry.isDirectory()) {
|
|
23708
23836
|
subdirs.push(scanDirectory(fullPath, baseDir, urlPrefix, excludeDir, items));
|
|
23709
23837
|
} else if (entry.isFile()) {
|
|
23710
|
-
const ext =
|
|
23838
|
+
const ext = path4.extname(name).toLowerCase();
|
|
23711
23839
|
if (!IMAGE_EXTENSIONS2.has(ext))
|
|
23712
23840
|
continue;
|
|
23713
|
-
const relativePath =
|
|
23714
|
-
const url = urlPrefix !== null ? `/${relativePath}` : `/${
|
|
23841
|
+
const relativePath = path4.relative(baseDir, fullPath).split(path4.sep).join("/");
|
|
23842
|
+
const url = urlPrefix !== null ? `/${relativePath}` : `/${path4.relative(getProjectRoot(), fullPath).split(path4.sep).join("/")}`;
|
|
23715
23843
|
items.push({
|
|
23716
23844
|
id: `project:${url}`,
|
|
23717
23845
|
url,
|
|
@@ -23731,7 +23859,7 @@ var init_project_images = __esm(() => {
|
|
|
23731
23859
|
|
|
23732
23860
|
// ../cms/src/utils.ts
|
|
23733
23861
|
import { createHash } from "crypto";
|
|
23734
|
-
import
|
|
23862
|
+
import path5 from "path";
|
|
23735
23863
|
function normalizePagePath(url) {
|
|
23736
23864
|
let pathname;
|
|
23737
23865
|
try {
|
|
@@ -23784,21 +23912,21 @@ function escapeReplacement(str) {
|
|
|
23784
23912
|
return str.replace(/\$/g, "$$$$");
|
|
23785
23913
|
}
|
|
23786
23914
|
function resolveSourcePath(sourcePath) {
|
|
23787
|
-
return
|
|
23915
|
+
return path5.isAbsolute(sourcePath) ? sourcePath : path5.join(getProjectRoot(), sourcePath);
|
|
23788
23916
|
}
|
|
23789
23917
|
function resolveAndValidatePath(filePath) {
|
|
23790
23918
|
const projectRoot = getProjectRoot();
|
|
23791
|
-
const resolvedRoot =
|
|
23919
|
+
const resolvedRoot = path5.resolve(projectRoot);
|
|
23792
23920
|
const isAbsoluteFs = filePath.startsWith(resolvedRoot);
|
|
23793
23921
|
const normalizedPath = !isAbsoluteFs && filePath.startsWith("/") ? filePath.slice(1) : filePath;
|
|
23794
|
-
const fullPath =
|
|
23795
|
-
if (!fullPath.startsWith(resolvedRoot +
|
|
23922
|
+
const fullPath = path5.isAbsolute(normalizedPath) ? path5.resolve(normalizedPath) : path5.resolve(projectRoot, normalizedPath);
|
|
23923
|
+
if (!fullPath.startsWith(resolvedRoot + path5.sep) && fullPath !== resolvedRoot) {
|
|
23796
23924
|
throw new Error(`Path traversal detected: ${filePath}`);
|
|
23797
23925
|
}
|
|
23798
23926
|
return fullPath;
|
|
23799
23927
|
}
|
|
23800
23928
|
async function acquireFileLock(filePath) {
|
|
23801
|
-
const key =
|
|
23929
|
+
const key = path5.resolve(filePath);
|
|
23802
23930
|
while (fileLocks.has(key)) {
|
|
23803
23931
|
await fileLocks.get(key);
|
|
23804
23932
|
}
|
|
@@ -23819,8 +23947,8 @@ function escapeHtml(text) {
|
|
|
23819
23947
|
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
23820
23948
|
}
|
|
23821
23949
|
function relativeImportPath(fromFile, toFile) {
|
|
23822
|
-
const fromDir =
|
|
23823
|
-
let rel =
|
|
23950
|
+
const fromDir = path5.dirname(fromFile);
|
|
23951
|
+
let rel = path5.relative(fromDir, toFile).split(path5.sep).join("/");
|
|
23824
23952
|
if (!rel.startsWith("."))
|
|
23825
23953
|
rel = `./${rel}`;
|
|
23826
23954
|
return rel;
|
|
@@ -23832,8 +23960,8 @@ var init_utils2 = __esm(() => {
|
|
|
23832
23960
|
});
|
|
23833
23961
|
|
|
23834
23962
|
// ../cms/src/handlers/component-ops.ts
|
|
23835
|
-
import
|
|
23836
|
-
import
|
|
23963
|
+
import fs5 from "fs/promises";
|
|
23964
|
+
import path6 from "path";
|
|
23837
23965
|
async function handleInsertComponent(request, manifestWriter) {
|
|
23838
23966
|
const { position, referenceComponentId, componentName, props, meta } = request;
|
|
23839
23967
|
if (!meta?.url) {
|
|
@@ -23866,7 +23994,7 @@ async function handleInsertComponent(request, manifestWriter) {
|
|
|
23866
23994
|
try {
|
|
23867
23995
|
let currentContent;
|
|
23868
23996
|
try {
|
|
23869
|
-
currentContent = await
|
|
23997
|
+
currentContent = await fs5.readFile(fullPath, "utf-8");
|
|
23870
23998
|
} catch {
|
|
23871
23999
|
return { success: false, error: `Source file not found: ${filePath}` };
|
|
23872
24000
|
}
|
|
@@ -23891,7 +24019,7 @@ async function handleInsertComponent(request, manifestWriter) {
|
|
|
23891
24019
|
`);
|
|
23892
24020
|
lines.splice(insertIndex, 0, indentedJsx);
|
|
23893
24021
|
ensureComponentImport(lines, componentName, componentDef.file, filePath);
|
|
23894
|
-
await
|
|
24022
|
+
await fs5.writeFile(fullPath, lines.join(`
|
|
23895
24023
|
`), "utf-8");
|
|
23896
24024
|
return {
|
|
23897
24025
|
success: true,
|
|
@@ -23934,7 +24062,7 @@ async function handleRemoveComponent(request, manifestWriter) {
|
|
|
23934
24062
|
try {
|
|
23935
24063
|
let currentContent;
|
|
23936
24064
|
try {
|
|
23937
|
-
currentContent = await
|
|
24065
|
+
currentContent = await fs5.readFile(fullPath, "utf-8");
|
|
23938
24066
|
} catch {
|
|
23939
24067
|
return { success: false, error: `Source file not found: ${filePath}` };
|
|
23940
24068
|
}
|
|
@@ -23956,7 +24084,7 @@ async function handleRemoveComponent(request, manifestWriter) {
|
|
|
23956
24084
|
removeCount++;
|
|
23957
24085
|
}
|
|
23958
24086
|
lines.splice(startLine, removeCount);
|
|
23959
|
-
await
|
|
24087
|
+
await fs5.writeFile(fullPath, lines.join(`
|
|
23960
24088
|
`), "utf-8");
|
|
23961
24089
|
return {
|
|
23962
24090
|
success: true,
|
|
@@ -24051,9 +24179,9 @@ function getComponentOccurrenceIndex(manifest, referenceComponent) {
|
|
|
24051
24179
|
async function findComponentInvocationFile(projectRoot, pageUrl, manifest, referenceComponent) {
|
|
24052
24180
|
if (referenceComponent.invocationSourcePath) {
|
|
24053
24181
|
const filePath = normalizeFilePath(referenceComponent.invocationSourcePath);
|
|
24054
|
-
const fullPath =
|
|
24182
|
+
const fullPath = path6.resolve(projectRoot, filePath);
|
|
24055
24183
|
try {
|
|
24056
|
-
const content = await
|
|
24184
|
+
const content = await fs5.readFile(fullPath, "utf-8");
|
|
24057
24185
|
const lines = content.split(`
|
|
24058
24186
|
`);
|
|
24059
24187
|
const lineIndex = findComponentInvocationLine(lines, referenceComponent.componentName, referenceComponent.invocationIndex ?? 0);
|
|
@@ -24065,9 +24193,9 @@ async function findComponentInvocationFile(projectRoot, pageUrl, manifest, refer
|
|
|
24065
24193
|
const candidates = getPageFileCandidates(pageUrl);
|
|
24066
24194
|
const occurrenceIndex = getComponentOccurrenceIndex(manifest, referenceComponent);
|
|
24067
24195
|
for (const candidate of candidates) {
|
|
24068
|
-
const fullPath =
|
|
24196
|
+
const fullPath = path6.resolve(projectRoot, candidate);
|
|
24069
24197
|
try {
|
|
24070
|
-
const content = await
|
|
24198
|
+
const content = await fs5.readFile(fullPath, "utf-8");
|
|
24071
24199
|
const lines = content.split(`
|
|
24072
24200
|
`);
|
|
24073
24201
|
const lineIndex = findComponentInvocationLine(lines, referenceComponent.componentName, occurrenceIndex);
|
|
@@ -24125,7 +24253,7 @@ function getIndentation(line) {
|
|
|
24125
24253
|
function normalizeFilePath(p) {
|
|
24126
24254
|
if (!p.startsWith("/"))
|
|
24127
24255
|
return p;
|
|
24128
|
-
const projectRoot =
|
|
24256
|
+
const projectRoot = path6.resolve(getProjectRoot());
|
|
24129
24257
|
if (p.startsWith(projectRoot))
|
|
24130
24258
|
return p;
|
|
24131
24259
|
return p.slice(1);
|
|
@@ -24157,7 +24285,7 @@ var init_component_ops = __esm(() => {
|
|
|
24157
24285
|
});
|
|
24158
24286
|
|
|
24159
24287
|
// ../cms/src/handlers/array-ops.ts
|
|
24160
|
-
import
|
|
24288
|
+
import fs6 from "fs/promises";
|
|
24161
24289
|
function parseInlineArrayName(componentName) {
|
|
24162
24290
|
if (!componentName.startsWith("__array:"))
|
|
24163
24291
|
return null;
|
|
@@ -24237,7 +24365,7 @@ async function resolveArrayContext(component, manifest, pageUrl) {
|
|
|
24237
24365
|
const { arrayVarName, mapOccurrence } = parsed;
|
|
24238
24366
|
const filePath2 = normalizeFilePath(component.invocationSourcePath ?? component.sourcePath);
|
|
24239
24367
|
const fullPath2 = resolveAndValidatePath(filePath2);
|
|
24240
|
-
const content2 = await
|
|
24368
|
+
const content2 = await fs6.readFile(fullPath2, "utf-8");
|
|
24241
24369
|
const lines2 = content2.split(`
|
|
24242
24370
|
`);
|
|
24243
24371
|
const fmEnd2 = findFrontmatterEnd(lines2);
|
|
@@ -24282,7 +24410,7 @@ async function resolveArrayContext(component, manifest, pageUrl) {
|
|
|
24282
24410
|
const invocation = await findComponentInvocationFile(projectRoot, pageUrl, manifest, component);
|
|
24283
24411
|
const filePath = invocation?.filePath ?? normalizeFilePath(component.invocationSourcePath ?? component.sourcePath);
|
|
24284
24412
|
const fullPath = resolveAndValidatePath(filePath);
|
|
24285
|
-
const content = await
|
|
24413
|
+
const content = await fs6.readFile(fullPath, "utf-8");
|
|
24286
24414
|
const lines = content.split(`
|
|
24287
24415
|
`);
|
|
24288
24416
|
let refLineIndex;
|
|
@@ -24354,7 +24482,7 @@ async function handleRemoveArrayItem(request, manifestWriter) {
|
|
|
24354
24482
|
const { fullPath, arrayIndex } = ctx;
|
|
24355
24483
|
const release = await acquireFileLock(fullPath);
|
|
24356
24484
|
try {
|
|
24357
|
-
const freshContent = await
|
|
24485
|
+
const freshContent = await fs6.readFile(fullPath, "utf-8");
|
|
24358
24486
|
const freshLines = freshContent.split(`
|
|
24359
24487
|
`);
|
|
24360
24488
|
const freshFmEnd = findFrontmatterEnd(freshLines);
|
|
@@ -24383,7 +24511,7 @@ async function handleRemoveArrayItem(request, manifestWriter) {
|
|
|
24383
24511
|
freshLines[removeStart - 1] = prevLine.replace(/,\s*$/, "");
|
|
24384
24512
|
}
|
|
24385
24513
|
}
|
|
24386
|
-
await
|
|
24514
|
+
await fs6.writeFile(fullPath, freshLines.join(`
|
|
24387
24515
|
`), "utf-8");
|
|
24388
24516
|
return {
|
|
24389
24517
|
success: true,
|
|
@@ -24425,7 +24553,7 @@ async function handleAddArrayItem(request, manifestWriter) {
|
|
|
24425
24553
|
const { fullPath, arrayIndex } = ctx;
|
|
24426
24554
|
const release = await acquireFileLock(fullPath);
|
|
24427
24555
|
try {
|
|
24428
|
-
const freshContent = await
|
|
24556
|
+
const freshContent = await fs6.readFile(fullPath, "utf-8");
|
|
24429
24557
|
const freshLines = freshContent.split(`
|
|
24430
24558
|
`);
|
|
24431
24559
|
const freshFmEnd = findFrontmatterEnd(freshLines);
|
|
@@ -24476,7 +24604,7 @@ async function handleAddArrayItem(request, manifestWriter) {
|
|
|
24476
24604
|
break;
|
|
24477
24605
|
}
|
|
24478
24606
|
}
|
|
24479
|
-
await
|
|
24607
|
+
await fs6.writeFile(fullPath, freshLines.join(`
|
|
24480
24608
|
`), "utf-8");
|
|
24481
24609
|
return {
|
|
24482
24610
|
success: true,
|
|
@@ -24532,46 +24660,46 @@ var init_array_ops = __esm(() => {
|
|
|
24532
24660
|
|
|
24533
24661
|
// ../cms/src/astro-image-paths.ts
|
|
24534
24662
|
import { createHash as createHash2 } from "crypto";
|
|
24535
|
-
import
|
|
24536
|
-
import
|
|
24663
|
+
import fs7 from "fs/promises";
|
|
24664
|
+
import path7 from "path";
|
|
24537
24665
|
function isHugoStyleEntry(entryAbsPath) {
|
|
24538
|
-
return HUGO_INDEX_RE.test(
|
|
24666
|
+
return HUGO_INDEX_RE.test(path7.basename(entryAbsPath));
|
|
24539
24667
|
}
|
|
24540
24668
|
function shortContentHash(buf) {
|
|
24541
24669
|
return createHash2("sha256").update(buf).digest("hex").slice(0, 8);
|
|
24542
24670
|
}
|
|
24543
24671
|
async function pickAstroImageTarget(args) {
|
|
24544
|
-
const entryDir =
|
|
24672
|
+
const entryDir = path7.dirname(args.entryAbsPath);
|
|
24545
24673
|
const isHugoStyle = isHugoStyleEntry(args.entryAbsPath);
|
|
24546
|
-
const safeFilename =
|
|
24674
|
+
const safeFilename = path7.basename(args.originalFilename);
|
|
24547
24675
|
if (!safeFilename || safeFilename === "." || safeFilename === "..") {
|
|
24548
24676
|
throw new Error(`Invalid filename: ${args.originalFilename}`);
|
|
24549
24677
|
}
|
|
24550
24678
|
const baseName = isHugoStyle ? safeFilename : `${args.slug}-${safeFilename}`;
|
|
24551
|
-
const baseAbs =
|
|
24679
|
+
const baseAbs = path7.join(entryDir, baseName);
|
|
24552
24680
|
if (await isFreeOrMatching(baseAbs, args.compareBuffer)) {
|
|
24553
24681
|
return { absPath: baseAbs, relPath: `./${baseName}` };
|
|
24554
24682
|
}
|
|
24555
24683
|
const candidateAbs = await pickHashedSibling(entryDir, baseName, args.compareBuffer);
|
|
24556
|
-
return { absPath: candidateAbs, relPath: `./${
|
|
24684
|
+
return { absPath: candidateAbs, relPath: `./${path7.basename(candidateAbs)}` };
|
|
24557
24685
|
}
|
|
24558
24686
|
async function pickSiblingTarget(dir, filename, buf) {
|
|
24559
|
-
const safe =
|
|
24687
|
+
const safe = path7.basename(filename);
|
|
24560
24688
|
if (!safe || safe === "." || safe === "..") {
|
|
24561
24689
|
throw new Error(`Invalid filename: ${filename}`);
|
|
24562
24690
|
}
|
|
24563
|
-
const baseAbs =
|
|
24691
|
+
const baseAbs = path7.join(dir, safe);
|
|
24564
24692
|
if (await isFreeOrMatching(baseAbs, buf))
|
|
24565
24693
|
return baseAbs;
|
|
24566
24694
|
return pickHashedSibling(dir, safe, buf);
|
|
24567
24695
|
}
|
|
24568
24696
|
async function pickHashedSibling(dir, baseName, buf) {
|
|
24569
24697
|
const hash = shortContentHash(buf);
|
|
24570
|
-
const ext =
|
|
24571
|
-
const stem =
|
|
24698
|
+
const ext = path7.extname(baseName);
|
|
24699
|
+
const stem = path7.basename(baseName, ext);
|
|
24572
24700
|
for (let attempt = 0;attempt < 5; attempt++) {
|
|
24573
24701
|
const suffix = attempt === 0 ? hash : `${hash}-${attempt}`;
|
|
24574
|
-
const candidateAbs =
|
|
24702
|
+
const candidateAbs = path7.join(dir, `${stem}-${suffix}${ext}`);
|
|
24575
24703
|
if (await isFreeOrMatching(candidateAbs, buf))
|
|
24576
24704
|
return candidateAbs;
|
|
24577
24705
|
}
|
|
@@ -24579,10 +24707,10 @@ async function pickHashedSibling(dir, baseName, buf) {
|
|
|
24579
24707
|
}
|
|
24580
24708
|
async function isFreeOrMatching(absPath, compareBuffer) {
|
|
24581
24709
|
try {
|
|
24582
|
-
const stat = await
|
|
24710
|
+
const stat = await fs7.stat(absPath);
|
|
24583
24711
|
if (stat.size !== compareBuffer.length)
|
|
24584
24712
|
return false;
|
|
24585
|
-
const existing = await
|
|
24713
|
+
const existing = await fs7.readFile(absPath);
|
|
24586
24714
|
return compareBuffer.equals(existing);
|
|
24587
24715
|
} catch {
|
|
24588
24716
|
return true;
|
|
@@ -24594,8 +24722,8 @@ var init_astro_image_paths = __esm(() => {
|
|
|
24594
24722
|
});
|
|
24595
24723
|
|
|
24596
24724
|
// ../cms/src/handlers/astro-image-upload.ts
|
|
24597
|
-
import
|
|
24598
|
-
import
|
|
24725
|
+
import fs8 from "fs/promises";
|
|
24726
|
+
import path8 from "path";
|
|
24599
24727
|
async function tryAstroImageUpload(args) {
|
|
24600
24728
|
const { collection, entry, field } = args.context;
|
|
24601
24729
|
if (!collection || !entry || !field)
|
|
@@ -24617,12 +24745,12 @@ async function tryAstroImageUpload(args) {
|
|
|
24617
24745
|
originalFilename: args.originalFilename,
|
|
24618
24746
|
compareBuffer: args.fileBuffer
|
|
24619
24747
|
});
|
|
24620
|
-
await
|
|
24621
|
-
await
|
|
24748
|
+
await fs8.mkdir(path8.dirname(target.absPath), { recursive: true });
|
|
24749
|
+
await fs8.writeFile(target.absPath, args.fileBuffer);
|
|
24622
24750
|
return {
|
|
24623
24751
|
success: true,
|
|
24624
24752
|
url: target.relPath,
|
|
24625
|
-
filename:
|
|
24753
|
+
filename: path8.basename(target.absPath)
|
|
24626
24754
|
};
|
|
24627
24755
|
}
|
|
24628
24756
|
var init_astro_image_upload = __esm(() => {
|
|
@@ -24631,12 +24759,12 @@ var init_astro_image_upload = __esm(() => {
|
|
|
24631
24759
|
});
|
|
24632
24760
|
|
|
24633
24761
|
// ../cms/src/handlers/markdown-ops.ts
|
|
24634
|
-
import
|
|
24635
|
-
import
|
|
24762
|
+
import fs9 from "fs/promises";
|
|
24763
|
+
import path9 from "path";
|
|
24636
24764
|
async function handleGetMarkdownContent(filePath) {
|
|
24637
24765
|
try {
|
|
24638
24766
|
const fullPath = resolveAndValidatePath(filePath);
|
|
24639
|
-
const raw = await
|
|
24767
|
+
const raw = await fs9.readFile(fullPath, "utf-8");
|
|
24640
24768
|
if (isDataFile(filePath)) {
|
|
24641
24769
|
const data = filePath.endsWith(".json") ? JSON.parse(raw) : import_yaml2.default.parse(raw);
|
|
24642
24770
|
return {
|
|
@@ -24661,14 +24789,14 @@ async function handleUpdateMarkdown(request, componentDefinitions) {
|
|
|
24661
24789
|
const release = await acquireFileLock(fullPath);
|
|
24662
24790
|
try {
|
|
24663
24791
|
if (isDataFile(request.filePath)) {
|
|
24664
|
-
const raw = await
|
|
24792
|
+
const raw = await fs9.readFile(fullPath, "utf-8");
|
|
24665
24793
|
const existing = request.filePath.endsWith(".json") ? JSON.parse(raw) : import_yaml2.default.parse(raw);
|
|
24666
24794
|
const merged = { ...existing ?? {}, ...request.frontmatter };
|
|
24667
24795
|
const output = request.filePath.endsWith(".json") ? JSON.stringify(merged, null, 2) + `
|
|
24668
24796
|
` : import_yaml2.default.stringify(merged);
|
|
24669
|
-
await
|
|
24797
|
+
await fs9.writeFile(fullPath, output, "utf-8");
|
|
24670
24798
|
} else {
|
|
24671
|
-
const raw = await
|
|
24799
|
+
const raw = await fs9.readFile(fullPath, "utf-8");
|
|
24672
24800
|
const existing = parseFrontmatter3(raw);
|
|
24673
24801
|
const mergedFrontmatter = {
|
|
24674
24802
|
...existing.frontmatter,
|
|
@@ -24679,7 +24807,7 @@ async function handleUpdateMarkdown(request, componentDefinitions) {
|
|
|
24679
24807
|
finalContent = ensureMdxImports(finalContent, request.filePath, componentDefinitions);
|
|
24680
24808
|
}
|
|
24681
24809
|
const markdownContent = serializeFrontmatter(mergedFrontmatter, finalContent);
|
|
24682
|
-
await
|
|
24810
|
+
await fs9.writeFile(fullPath, markdownContent, "utf-8");
|
|
24683
24811
|
}
|
|
24684
24812
|
return { success: true };
|
|
24685
24813
|
} finally {
|
|
@@ -24718,8 +24846,8 @@ async function handleCreateMarkdown(request) {
|
|
|
24718
24846
|
fileContent = serializeFrontmatter(fullFrontmatter, content);
|
|
24719
24847
|
}
|
|
24720
24848
|
try {
|
|
24721
|
-
await
|
|
24722
|
-
await
|
|
24849
|
+
await fs9.mkdir(path9.dirname(fullPath), { recursive: true });
|
|
24850
|
+
await fs9.writeFile(fullPath, fileContent, { encoding: "utf-8", flag: "wx" });
|
|
24723
24851
|
return {
|
|
24724
24852
|
success: true,
|
|
24725
24853
|
filePath,
|
|
@@ -24736,8 +24864,8 @@ async function handleCreateMarkdown(request) {
|
|
|
24736
24864
|
async function handleDeleteMarkdown(request) {
|
|
24737
24865
|
try {
|
|
24738
24866
|
const fullPath = resolveAndValidatePath(request.filePath);
|
|
24739
|
-
await
|
|
24740
|
-
await
|
|
24867
|
+
await fs9.access(fullPath);
|
|
24868
|
+
await fs9.unlink(fullPath);
|
|
24741
24869
|
return { success: true };
|
|
24742
24870
|
} catch (error) {
|
|
24743
24871
|
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
@@ -24754,16 +24882,16 @@ async function handleRenameMarkdown(request) {
|
|
|
24754
24882
|
if (!normalizedSlug) {
|
|
24755
24883
|
return { success: false, error: "Invalid slug" };
|
|
24756
24884
|
}
|
|
24757
|
-
const dir =
|
|
24758
|
-
const ext =
|
|
24759
|
-
const newFullPath =
|
|
24885
|
+
const dir = path9.dirname(fullPath);
|
|
24886
|
+
const ext = path9.extname(fullPath);
|
|
24887
|
+
const newFullPath = path9.join(dir, `${normalizedSlug}${ext}`);
|
|
24760
24888
|
if (fullPath === newFullPath) {
|
|
24761
24889
|
return { success: true, newFilePath: request.filePath, newSlug: normalizedSlug };
|
|
24762
24890
|
}
|
|
24763
24891
|
const release = await acquireFileLock(fullPath);
|
|
24764
24892
|
try {
|
|
24765
24893
|
try {
|
|
24766
|
-
await
|
|
24894
|
+
await fs9.link(fullPath, newFullPath);
|
|
24767
24895
|
} catch (err) {
|
|
24768
24896
|
if (isNodeError(err, "EEXIST")) {
|
|
24769
24897
|
return { success: false, error: `File already exists: ${normalizedSlug}${ext}` };
|
|
@@ -24771,16 +24899,16 @@ async function handleRenameMarkdown(request) {
|
|
|
24771
24899
|
throw err;
|
|
24772
24900
|
}
|
|
24773
24901
|
try {
|
|
24774
|
-
await
|
|
24902
|
+
await fs9.unlink(fullPath);
|
|
24775
24903
|
} catch (err) {
|
|
24776
|
-
await
|
|
24904
|
+
await fs9.unlink(newFullPath).catch(() => {});
|
|
24777
24905
|
throw err;
|
|
24778
24906
|
}
|
|
24779
24907
|
} finally {
|
|
24780
24908
|
release();
|
|
24781
24909
|
}
|
|
24782
24910
|
const projectRoot = getProjectRoot();
|
|
24783
|
-
const newFilePath =
|
|
24911
|
+
const newFilePath = path9.relative(projectRoot, newFullPath).split(path9.sep).join("/");
|
|
24784
24912
|
return { success: true, newFilePath, newSlug: normalizedSlug };
|
|
24785
24913
|
} catch (error) {
|
|
24786
24914
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -24872,7 +25000,7 @@ function ensureMdxImports(content, filePath, componentDefinitions) {
|
|
|
24872
25000
|
}
|
|
24873
25001
|
}
|
|
24874
25002
|
const root = getProjectRoot();
|
|
24875
|
-
const mdxFullPath =
|
|
25003
|
+
const mdxFullPath = path9.join(root, filePath);
|
|
24876
25004
|
const missingImports = [];
|
|
24877
25005
|
for (const name of usedComponents) {
|
|
24878
25006
|
if (importedNames.has(name))
|
|
@@ -24880,7 +25008,7 @@ function ensureMdxImports(content, filePath, componentDefinitions) {
|
|
|
24880
25008
|
const def = componentDefinitions[name];
|
|
24881
25009
|
if (!def)
|
|
24882
25010
|
continue;
|
|
24883
|
-
const componentAbsPath =
|
|
25011
|
+
const componentAbsPath = path9.join(root, def.file);
|
|
24884
25012
|
const rel = relativeImportPath(mdxFullPath, componentAbsPath);
|
|
24885
25013
|
missingImports.push(`import ${name} from '${rel}'`);
|
|
24886
25014
|
}
|
|
@@ -24905,8 +25033,8 @@ var init_markdown_ops = __esm(() => {
|
|
|
24905
25033
|
});
|
|
24906
25034
|
|
|
24907
25035
|
// ../cms/src/handlers/page-ops.ts
|
|
24908
|
-
import
|
|
24909
|
-
import
|
|
25036
|
+
import fs10 from "fs/promises";
|
|
25037
|
+
import path10 from "path";
|
|
24910
25038
|
async function handleCreatePage(request) {
|
|
24911
25039
|
const { title, slug } = request;
|
|
24912
25040
|
const normalizedSlug = slugify(slug || title);
|
|
@@ -24918,8 +25046,8 @@ async function handleCreatePage(request) {
|
|
|
24918
25046
|
const layoutImport = await resolveLayoutImport(request.layoutPath);
|
|
24919
25047
|
const content = generatePageContent(title, layoutImport);
|
|
24920
25048
|
try {
|
|
24921
|
-
await
|
|
24922
|
-
await
|
|
25049
|
+
await fs10.mkdir(path10.dirname(fullPath), { recursive: true });
|
|
25050
|
+
await fs10.writeFile(fullPath, content, { encoding: "utf-8", flag: "wx" });
|
|
24923
25051
|
const url = normalizedSlug === "index" ? "/" : `/${normalizedSlug}`;
|
|
24924
25052
|
return { success: true, filePath, slug: normalizedSlug, url };
|
|
24925
25053
|
} catch (error) {
|
|
@@ -24941,7 +25069,7 @@ async function handleDuplicatePage(request) {
|
|
|
24941
25069
|
}
|
|
24942
25070
|
let content;
|
|
24943
25071
|
try {
|
|
24944
|
-
content = await
|
|
25072
|
+
content = await fs10.readFile(resolveAndValidatePath(sourceFile), "utf-8");
|
|
24945
25073
|
} catch {
|
|
24946
25074
|
return { success: false, error: `Could not read source file: ${sourceFile}` };
|
|
24947
25075
|
}
|
|
@@ -24951,8 +25079,8 @@ async function handleDuplicatePage(request) {
|
|
|
24951
25079
|
const newFilePath = `src/pages/${normalizedSlug}.astro`;
|
|
24952
25080
|
const newFullPath = resolveAndValidatePath(newFilePath);
|
|
24953
25081
|
try {
|
|
24954
|
-
await
|
|
24955
|
-
await
|
|
25082
|
+
await fs10.mkdir(path10.dirname(newFullPath), { recursive: true });
|
|
25083
|
+
await fs10.writeFile(newFullPath, content, { encoding: "utf-8", flag: "wx" });
|
|
24956
25084
|
const url = normalizedSlug === "index" ? "/" : `/${normalizedSlug}`;
|
|
24957
25085
|
return { success: true, filePath: newFilePath, slug: normalizedSlug, url };
|
|
24958
25086
|
} catch (error) {
|
|
@@ -24969,7 +25097,7 @@ async function handleDeletePage(request) {
|
|
|
24969
25097
|
return { success: false, error: `Page not found: ${pagePath}` };
|
|
24970
25098
|
}
|
|
24971
25099
|
try {
|
|
24972
|
-
await
|
|
25100
|
+
await fs10.unlink(resolveAndValidatePath(pageFile));
|
|
24973
25101
|
return { success: true, filePath: pageFile, url: pagePath };
|
|
24974
25102
|
} catch (error) {
|
|
24975
25103
|
if (isNodeError(error, "ENOENT")) {
|
|
@@ -24986,10 +25114,10 @@ async function handleCheckSlugExists(slug) {
|
|
|
24986
25114
|
return found ? { exists: true, filePath: found } : { exists: false };
|
|
24987
25115
|
}
|
|
24988
25116
|
async function handleGetLayouts() {
|
|
24989
|
-
const layoutsDir =
|
|
25117
|
+
const layoutsDir = path10.join(getProjectRoot(), "src", "layouts");
|
|
24990
25118
|
let entries;
|
|
24991
25119
|
try {
|
|
24992
|
-
entries = await
|
|
25120
|
+
entries = await fs10.readdir(layoutsDir, { withFileTypes: true });
|
|
24993
25121
|
} catch {
|
|
24994
25122
|
return [];
|
|
24995
25123
|
}
|
|
@@ -24997,7 +25125,7 @@ async function handleGetLayouts() {
|
|
|
24997
25125
|
for (const entry of entries) {
|
|
24998
25126
|
if (entry.isFile() && entry.name.endsWith(".astro")) {
|
|
24999
25127
|
layouts.push({
|
|
25000
|
-
name:
|
|
25128
|
+
name: path10.basename(entry.name, ".astro"),
|
|
25001
25129
|
path: `src/layouts/${entry.name}`
|
|
25002
25130
|
});
|
|
25003
25131
|
}
|
|
@@ -25009,7 +25137,7 @@ function errorMessage(error) {
|
|
|
25009
25137
|
}
|
|
25010
25138
|
async function fileExists(fullPath) {
|
|
25011
25139
|
try {
|
|
25012
|
-
await
|
|
25140
|
+
await fs10.access(fullPath);
|
|
25013
25141
|
return true;
|
|
25014
25142
|
} catch {
|
|
25015
25143
|
return false;
|
|
@@ -25031,7 +25159,7 @@ async function findPageFile(pagePath) {
|
|
|
25031
25159
|
}
|
|
25032
25160
|
async function resolveLayoutImport(layoutPath) {
|
|
25033
25161
|
if (layoutPath) {
|
|
25034
|
-
const name =
|
|
25162
|
+
const name = path10.basename(layoutPath, ".astro");
|
|
25035
25163
|
const importPath2 = `../${layoutPath.replace(/^src\//, "")}`;
|
|
25036
25164
|
return { importPath: importPath2, componentName: pascalCase(name) };
|
|
25037
25165
|
}
|
|
@@ -25094,10 +25222,10 @@ var init_page_ops = __esm(() => {
|
|
|
25094
25222
|
});
|
|
25095
25223
|
|
|
25096
25224
|
// ../cms/src/handlers/redirect-ops.ts
|
|
25097
|
-
import
|
|
25098
|
-
import
|
|
25225
|
+
import fs11 from "fs/promises";
|
|
25226
|
+
import path11 from "path";
|
|
25099
25227
|
function getRedirectsFilePath() {
|
|
25100
|
-
return
|
|
25228
|
+
return path11.join(getProjectRoot(), REDIRECTS_FILE);
|
|
25101
25229
|
}
|
|
25102
25230
|
async function handleGetRedirects() {
|
|
25103
25231
|
const lines = await readRedirectsFile(getRedirectsFilePath());
|
|
@@ -25174,7 +25302,7 @@ function formatRedirectLine(source, destination, statusCode) {
|
|
|
25174
25302
|
}
|
|
25175
25303
|
async function readRedirectsFile(filePath) {
|
|
25176
25304
|
try {
|
|
25177
|
-
const content = await
|
|
25305
|
+
const content = await fs11.readFile(filePath, "utf-8");
|
|
25178
25306
|
return content.split(`
|
|
25179
25307
|
`);
|
|
25180
25308
|
} catch (error) {
|
|
@@ -25184,16 +25312,16 @@ async function readRedirectsFile(filePath) {
|
|
|
25184
25312
|
}
|
|
25185
25313
|
}
|
|
25186
25314
|
async function writeRedirectsFile(filePath, lines) {
|
|
25187
|
-
await
|
|
25315
|
+
await fs11.mkdir(path11.dirname(filePath), { recursive: true });
|
|
25188
25316
|
const trimmed = lines.slice();
|
|
25189
25317
|
while (trimmed.length > 0 && trimmed[trimmed.length - 1].trim() === "") {
|
|
25190
25318
|
trimmed.pop();
|
|
25191
25319
|
}
|
|
25192
25320
|
if (trimmed.length === 0) {
|
|
25193
|
-
await
|
|
25321
|
+
await fs11.writeFile(filePath, "", "utf-8");
|
|
25194
25322
|
return;
|
|
25195
25323
|
}
|
|
25196
|
-
await
|
|
25324
|
+
await fs11.writeFile(filePath, trimmed.join(`
|
|
25197
25325
|
`) + `
|
|
25198
25326
|
`, "utf-8");
|
|
25199
25327
|
}
|
|
@@ -30981,8 +31109,8 @@ var init_snippet_utils = __esm(() => {
|
|
|
30981
31109
|
});
|
|
30982
31110
|
|
|
30983
31111
|
// ../cms/src/handlers/source-writer.ts
|
|
30984
|
-
import
|
|
30985
|
-
import
|
|
31112
|
+
import fs12 from "fs/promises";
|
|
31113
|
+
import path12 from "path";
|
|
30986
31114
|
async function handleUpdate(request, manifestWriter) {
|
|
30987
31115
|
const { changes, meta } = request;
|
|
30988
31116
|
const errors = [];
|
|
@@ -31012,17 +31140,17 @@ async function handleUpdate(request, manifestWriter) {
|
|
|
31012
31140
|
const fullPath = resolveAndValidatePath(filePath);
|
|
31013
31141
|
const release = await acquireFileLock(fullPath);
|
|
31014
31142
|
try {
|
|
31015
|
-
const currentContent = await
|
|
31143
|
+
const currentContent = await fs12.readFile(fullPath, "utf-8");
|
|
31016
31144
|
const { newContent, appliedCount, failedChanges, fileOps } = await applyChanges(currentContent, fileChanges, manifest, fullPath, meta.url);
|
|
31017
31145
|
if (failedChanges.length > 0) {
|
|
31018
31146
|
errors.push(...failedChanges);
|
|
31019
31147
|
}
|
|
31020
31148
|
if (appliedCount > 0 && newContent !== currentContent) {
|
|
31021
31149
|
for (const op of fileOps) {
|
|
31022
|
-
await
|
|
31023
|
-
await
|
|
31150
|
+
await fs12.mkdir(path12.dirname(op.target), { recursive: true });
|
|
31151
|
+
await fs12.writeFile(op.target, op.bytes);
|
|
31024
31152
|
}
|
|
31025
|
-
await
|
|
31153
|
+
await fs12.writeFile(fullPath, newContent, "utf-8");
|
|
31026
31154
|
updated += appliedCount;
|
|
31027
31155
|
}
|
|
31028
31156
|
} finally {
|
|
@@ -31285,8 +31413,8 @@ async function tryRewriteAssetImport(content, importInfo, newSrc, absFilePath, o
|
|
|
31285
31413
|
const resolved = await resolveNewSrcBytes(newSrc, originUrl);
|
|
31286
31414
|
if (!resolved)
|
|
31287
31415
|
return null;
|
|
31288
|
-
const originalAssetAbs =
|
|
31289
|
-
const targetAbs = await pickSiblingTarget(
|
|
31416
|
+
const originalAssetAbs = path12.resolve(path12.dirname(absFilePath), importInfo.source);
|
|
31417
|
+
const targetAbs = await pickSiblingTarget(path12.dirname(originalAssetAbs), resolved.filename, resolved.bytes);
|
|
31290
31418
|
const newRelImport = relativeImportPath(absFilePath, targetAbs);
|
|
31291
31419
|
const newContent = content.slice(0, importInfo.sourceStart) + newRelImport + content.slice(importInfo.sourceEnd);
|
|
31292
31420
|
return {
|
|
@@ -31296,11 +31424,11 @@ async function tryRewriteAssetImport(content, importInfo, newSrc, absFilePath, o
|
|
|
31296
31424
|
};
|
|
31297
31425
|
}
|
|
31298
31426
|
async function resolveNewSrcBytes(newSrc, originUrl) {
|
|
31299
|
-
const filenameFromPath = (p) =>
|
|
31300
|
-
const diskPath = newSrc.startsWith("/src/") ?
|
|
31427
|
+
const filenameFromPath = (p) => path12.basename(p.split("?")[0] ?? p);
|
|
31428
|
+
const diskPath = newSrc.startsWith("/src/") ? path12.join(getProjectRoot(), newSrc.slice(1)) : newSrc.startsWith("/") && !newSrc.startsWith("//") ? path12.join(getProjectRoot(), "public", newSrc.replace(/^\/+/, "")) : null;
|
|
31301
31429
|
if (diskPath) {
|
|
31302
31430
|
try {
|
|
31303
|
-
return { bytes: await
|
|
31431
|
+
return { bytes: await fs12.readFile(diskPath), filename: filenameFromPath(newSrc) };
|
|
31304
31432
|
} catch {}
|
|
31305
31433
|
}
|
|
31306
31434
|
try {
|
|
@@ -31845,7 +31973,7 @@ var init_source_writer = __esm(() => {
|
|
|
31845
31973
|
});
|
|
31846
31974
|
|
|
31847
31975
|
// ../cms/src/handlers/api-routes.ts
|
|
31848
|
-
import
|
|
31976
|
+
import path13 from "path";
|
|
31849
31977
|
function requireMedia(ctx) {
|
|
31850
31978
|
if (!ctx.mediaAdapter) {
|
|
31851
31979
|
sendError(ctx.res, "Media storage not configured", 501);
|
|
@@ -31935,7 +32063,7 @@ var init_api_routes = __esm(() => {
|
|
|
31935
32063
|
}),
|
|
31936
32064
|
custom("POST", "markdown/delete", async ({ req, res, manifestWriter, contentDir }) => {
|
|
31937
32065
|
const body = await parseJsonBody(req);
|
|
31938
|
-
const fullPath =
|
|
32066
|
+
const fullPath = path13.resolve(getProjectRoot(), body.filePath?.replace(/^\//, "") ?? "");
|
|
31939
32067
|
expectedDeletions.add(fullPath);
|
|
31940
32068
|
const result = await handleDeleteMarkdown(body);
|
|
31941
32069
|
if (result.success) {
|
|
@@ -32043,7 +32171,7 @@ var init_api_routes = __esm(() => {
|
|
|
32043
32171
|
const body = await parseJsonBody(req);
|
|
32044
32172
|
const result = await handleDeletePage(body);
|
|
32045
32173
|
if (result.success && result.filePath) {
|
|
32046
|
-
expectedDeletions.add(
|
|
32174
|
+
expectedDeletions.add(path13.resolve(getProjectRoot(), result.filePath));
|
|
32047
32175
|
}
|
|
32048
32176
|
if (result.success && body.createRedirect && body.redirectTo) {
|
|
32049
32177
|
await handleAddRedirect({ source: body.pagePath, destination: body.redirectTo, statusCode: 307 });
|
|
@@ -32147,8 +32275,8 @@ var init_color_patterns = __esm(() => {
|
|
|
32147
32275
|
});
|
|
32148
32276
|
|
|
32149
32277
|
// ../cms/src/tailwind-colors.ts
|
|
32150
|
-
import
|
|
32151
|
-
import
|
|
32278
|
+
import fs13 from "fs/promises";
|
|
32279
|
+
import path14 from "path";
|
|
32152
32280
|
async function parseTailwindConfig(projectRoot = getProjectRoot()) {
|
|
32153
32281
|
const cssFiles = [
|
|
32154
32282
|
"src/styles/global.css",
|
|
@@ -32162,9 +32290,9 @@ async function parseTailwindConfig(projectRoot = getProjectRoot()) {
|
|
|
32162
32290
|
];
|
|
32163
32291
|
let customColors = [];
|
|
32164
32292
|
for (const cssFile of cssFiles) {
|
|
32165
|
-
const fullPath =
|
|
32293
|
+
const fullPath = path14.join(projectRoot, cssFile);
|
|
32166
32294
|
try {
|
|
32167
|
-
const content = await
|
|
32295
|
+
const content = await fs13.readFile(fullPath, "utf-8");
|
|
32168
32296
|
customColors = extractColorsFromCss(content);
|
|
32169
32297
|
if (customColors.length > 0) {
|
|
32170
32298
|
break;
|
|
@@ -32235,9 +32363,9 @@ async function parseTextStyles(projectRoot = getProjectRoot()) {
|
|
|
32235
32363
|
];
|
|
32236
32364
|
let customTextStyles = {};
|
|
32237
32365
|
for (const cssFile of cssFiles) {
|
|
32238
|
-
const fullPath =
|
|
32366
|
+
const fullPath = path14.join(projectRoot, cssFile);
|
|
32239
32367
|
try {
|
|
32240
|
-
const content = await
|
|
32368
|
+
const content = await fs13.readFile(fullPath, "utf-8");
|
|
32241
32369
|
customTextStyles = extractTextStylesFromCss(content);
|
|
32242
32370
|
if (Object.values(customTextStyles).some((arr) => arr && arr.length > 0)) {
|
|
32243
32371
|
break;
|
|
@@ -32691,8 +32819,8 @@ var init_dev_middleware = __esm(() => {
|
|
|
32691
32819
|
});
|
|
32692
32820
|
|
|
32693
32821
|
// ../cms/src/manifest-writer.ts
|
|
32694
|
-
import
|
|
32695
|
-
import
|
|
32822
|
+
import fs14 from "fs/promises";
|
|
32823
|
+
import path15 from "path";
|
|
32696
32824
|
|
|
32697
32825
|
class ManifestWriter {
|
|
32698
32826
|
globalManifest;
|
|
@@ -32763,10 +32891,10 @@ class ManifestWriter {
|
|
|
32763
32891
|
}
|
|
32764
32892
|
getPageManifestPath(pagePath) {
|
|
32765
32893
|
if (pagePath === "/" || pagePath === "") {
|
|
32766
|
-
return
|
|
32894
|
+
return path15.join(this.outDir, "index.json");
|
|
32767
32895
|
}
|
|
32768
32896
|
const cleanPath = pagePath.replace(/^\//, "");
|
|
32769
|
-
return
|
|
32897
|
+
return path15.join(this.outDir, `${cleanPath}.json`);
|
|
32770
32898
|
}
|
|
32771
32899
|
addPage(pagePath, entries, components, collection, seo) {
|
|
32772
32900
|
this.pageManifests.set(pagePath, { entries, components, collection, seo });
|
|
@@ -32792,8 +32920,8 @@ class ManifestWriter {
|
|
|
32792
32920
|
}
|
|
32793
32921
|
async writePageManifest(pagePath, entries, components, collection, seo) {
|
|
32794
32922
|
const manifestPath = this.getPageManifestPath(pagePath);
|
|
32795
|
-
const manifestDir =
|
|
32796
|
-
await
|
|
32923
|
+
const manifestDir = path15.dirname(manifestPath);
|
|
32924
|
+
await fs14.mkdir(manifestDir, { recursive: true });
|
|
32797
32925
|
const metadata = {
|
|
32798
32926
|
version: MANIFEST_VERSION,
|
|
32799
32927
|
generatedAt: new Date().toISOString(),
|
|
@@ -32814,7 +32942,7 @@ class ManifestWriter {
|
|
|
32814
32942
|
if (seo) {
|
|
32815
32943
|
pageManifest.seo = seo;
|
|
32816
32944
|
}
|
|
32817
|
-
await
|
|
32945
|
+
await fs14.writeFile(manifestPath, JSON.stringify(pageManifest, null, 2), "utf-8");
|
|
32818
32946
|
}
|
|
32819
32947
|
async finalize() {
|
|
32820
32948
|
await this.writeQueue;
|
|
@@ -32843,7 +32971,7 @@ class ManifestWriter {
|
|
|
32843
32971
|
}
|
|
32844
32972
|
}
|
|
32845
32973
|
if (this.outDir) {
|
|
32846
|
-
const globalManifestPath =
|
|
32974
|
+
const globalManifestPath = path15.join(this.outDir, this.manifestFile);
|
|
32847
32975
|
const globalSettings = {
|
|
32848
32976
|
componentDefinitions: this.componentDefinitions,
|
|
32849
32977
|
pages
|
|
@@ -32857,7 +32985,7 @@ class ManifestWriter {
|
|
|
32857
32985
|
if (this.availableTextStyles) {
|
|
32858
32986
|
globalSettings.availableTextStyles = this.availableTextStyles;
|
|
32859
32987
|
}
|
|
32860
|
-
await
|
|
32988
|
+
await fs14.writeFile(globalManifestPath, JSON.stringify(globalSettings, null, 2), "utf-8");
|
|
32861
32989
|
}
|
|
32862
32990
|
return {
|
|
32863
32991
|
totalEntries: Object.keys(this.globalManifest.entries).length,
|
|
@@ -32923,17 +33051,533 @@ var init_vite_plugin = __esm(() => {
|
|
|
32923
33051
|
init_vite_plugin_array_transform();
|
|
32924
33052
|
});
|
|
32925
33053
|
|
|
33054
|
+
// ../../node_modules/zod/v4/core/core.js
|
|
33055
|
+
function $constructor(name, initializer, params) {
|
|
33056
|
+
function init2(inst, def) {
|
|
33057
|
+
if (!inst._zod) {
|
|
33058
|
+
Object.defineProperty(inst, "_zod", {
|
|
33059
|
+
value: {
|
|
33060
|
+
def,
|
|
33061
|
+
constr: _2,
|
|
33062
|
+
traits: new Set
|
|
33063
|
+
},
|
|
33064
|
+
enumerable: false
|
|
33065
|
+
});
|
|
33066
|
+
}
|
|
33067
|
+
if (inst._zod.traits.has(name)) {
|
|
33068
|
+
return;
|
|
33069
|
+
}
|
|
33070
|
+
inst._zod.traits.add(name);
|
|
33071
|
+
initializer(inst, def);
|
|
33072
|
+
const proto = _2.prototype;
|
|
33073
|
+
const keys = Object.keys(proto);
|
|
33074
|
+
for (let i = 0;i < keys.length; i++) {
|
|
33075
|
+
const k = keys[i];
|
|
33076
|
+
if (!(k in inst)) {
|
|
33077
|
+
inst[k] = proto[k].bind(inst);
|
|
33078
|
+
}
|
|
33079
|
+
}
|
|
33080
|
+
}
|
|
33081
|
+
const Parent = params?.Parent ?? Object;
|
|
33082
|
+
|
|
33083
|
+
class Definition extends Parent {
|
|
33084
|
+
}
|
|
33085
|
+
Object.defineProperty(Definition, "name", { value: name });
|
|
33086
|
+
function _2(def) {
|
|
33087
|
+
var _a;
|
|
33088
|
+
const inst = params?.Parent ? new Definition : this;
|
|
33089
|
+
init2(inst, def);
|
|
33090
|
+
(_a = inst._zod).deferred ?? (_a.deferred = []);
|
|
33091
|
+
for (const fn of inst._zod.deferred) {
|
|
33092
|
+
fn();
|
|
33093
|
+
}
|
|
33094
|
+
return inst;
|
|
33095
|
+
}
|
|
33096
|
+
Object.defineProperty(_2, "init", { value: init2 });
|
|
33097
|
+
Object.defineProperty(_2, Symbol.hasInstance, {
|
|
33098
|
+
value: (inst) => {
|
|
33099
|
+
if (params?.Parent && inst instanceof params.Parent)
|
|
33100
|
+
return true;
|
|
33101
|
+
return inst?._zod?.traits?.has(name);
|
|
33102
|
+
}
|
|
33103
|
+
});
|
|
33104
|
+
Object.defineProperty(_2, "name", { value: name });
|
|
33105
|
+
return _2;
|
|
33106
|
+
}
|
|
33107
|
+
function config(newConfig) {
|
|
33108
|
+
if (newConfig)
|
|
33109
|
+
Object.assign(globalConfig, newConfig);
|
|
33110
|
+
return globalConfig;
|
|
33111
|
+
}
|
|
33112
|
+
var NEVER, $brand, globalConfig;
|
|
33113
|
+
var init_core = __esm(() => {
|
|
33114
|
+
NEVER = Object.freeze({
|
|
33115
|
+
status: "aborted"
|
|
33116
|
+
});
|
|
33117
|
+
$brand = Symbol("zod_brand");
|
|
33118
|
+
globalConfig = {};
|
|
33119
|
+
});
|
|
33120
|
+
|
|
33121
|
+
// ../../node_modules/zod/v4/core/util.js
|
|
33122
|
+
function joinValues(array, separator = "|") {
|
|
33123
|
+
return array.map((val) => stringifyPrimitive(val)).join(separator);
|
|
33124
|
+
}
|
|
33125
|
+
function jsonStringifyReplacer(_2, value) {
|
|
33126
|
+
if (typeof value === "bigint")
|
|
33127
|
+
return value.toString();
|
|
33128
|
+
return value;
|
|
33129
|
+
}
|
|
33130
|
+
function cached(getter) {
|
|
33131
|
+
const set = false;
|
|
33132
|
+
return {
|
|
33133
|
+
get value() {
|
|
33134
|
+
if (!set) {
|
|
33135
|
+
const value = getter();
|
|
33136
|
+
Object.defineProperty(this, "value", { value });
|
|
33137
|
+
return value;
|
|
33138
|
+
}
|
|
33139
|
+
throw new Error("cached value already set");
|
|
33140
|
+
}
|
|
33141
|
+
};
|
|
33142
|
+
}
|
|
33143
|
+
function stringifyPrimitive(value) {
|
|
33144
|
+
if (typeof value === "bigint")
|
|
33145
|
+
return value.toString() + "n";
|
|
33146
|
+
if (typeof value === "string")
|
|
33147
|
+
return `"${value}"`;
|
|
33148
|
+
return `${value}`;
|
|
33149
|
+
}
|
|
33150
|
+
function parsedType(data) {
|
|
33151
|
+
const t = typeof data;
|
|
33152
|
+
switch (t) {
|
|
33153
|
+
case "number": {
|
|
33154
|
+
return Number.isNaN(data) ? "nan" : "number";
|
|
33155
|
+
}
|
|
33156
|
+
case "object": {
|
|
33157
|
+
if (data === null) {
|
|
33158
|
+
return "null";
|
|
33159
|
+
}
|
|
33160
|
+
if (Array.isArray(data)) {
|
|
33161
|
+
return "array";
|
|
33162
|
+
}
|
|
33163
|
+
const obj = data;
|
|
33164
|
+
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
33165
|
+
return obj.constructor.name;
|
|
33166
|
+
}
|
|
33167
|
+
}
|
|
33168
|
+
}
|
|
33169
|
+
return t;
|
|
33170
|
+
}
|
|
33171
|
+
var EVALUATING, captureStackTrace, allowsEval, propertyKeyTypes, primitiveTypes, NUMBER_FORMAT_RANGES;
|
|
33172
|
+
var init_util = __esm(() => {
|
|
33173
|
+
EVALUATING = Symbol("evaluating");
|
|
33174
|
+
captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
33175
|
+
allowsEval = cached(() => {
|
|
33176
|
+
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
|
|
33177
|
+
return false;
|
|
33178
|
+
}
|
|
33179
|
+
try {
|
|
33180
|
+
const F = Function;
|
|
33181
|
+
new F("");
|
|
33182
|
+
return true;
|
|
33183
|
+
} catch (_2) {
|
|
33184
|
+
return false;
|
|
33185
|
+
}
|
|
33186
|
+
});
|
|
33187
|
+
propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
|
33188
|
+
primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
|
|
33189
|
+
NUMBER_FORMAT_RANGES = {
|
|
33190
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
33191
|
+
int32: [-2147483648, 2147483647],
|
|
33192
|
+
uint32: [0, 4294967295],
|
|
33193
|
+
float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000],
|
|
33194
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
33195
|
+
};
|
|
33196
|
+
});
|
|
33197
|
+
|
|
33198
|
+
// ../../node_modules/zod/v4/core/errors.js
|
|
33199
|
+
function flattenError(error, mapper = (issue) => issue.message) {
|
|
33200
|
+
const fieldErrors = {};
|
|
33201
|
+
const formErrors = [];
|
|
33202
|
+
for (const sub of error.issues) {
|
|
33203
|
+
if (sub.path.length > 0) {
|
|
33204
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
33205
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
33206
|
+
} else {
|
|
33207
|
+
formErrors.push(mapper(sub));
|
|
33208
|
+
}
|
|
33209
|
+
}
|
|
33210
|
+
return { formErrors, fieldErrors };
|
|
33211
|
+
}
|
|
33212
|
+
function formatError(error, mapper = (issue) => issue.message) {
|
|
33213
|
+
const fieldErrors = { _errors: [] };
|
|
33214
|
+
const processError = (error2) => {
|
|
33215
|
+
for (const issue of error2.issues) {
|
|
33216
|
+
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
33217
|
+
issue.errors.map((issues) => processError({ issues }));
|
|
33218
|
+
} else if (issue.code === "invalid_key") {
|
|
33219
|
+
processError({ issues: issue.issues });
|
|
33220
|
+
} else if (issue.code === "invalid_element") {
|
|
33221
|
+
processError({ issues: issue.issues });
|
|
33222
|
+
} else if (issue.path.length === 0) {
|
|
33223
|
+
fieldErrors._errors.push(mapper(issue));
|
|
33224
|
+
} else {
|
|
33225
|
+
let curr = fieldErrors;
|
|
33226
|
+
let i = 0;
|
|
33227
|
+
while (i < issue.path.length) {
|
|
33228
|
+
const el = issue.path[i];
|
|
33229
|
+
const terminal = i === issue.path.length - 1;
|
|
33230
|
+
if (!terminal) {
|
|
33231
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
33232
|
+
} else {
|
|
33233
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
33234
|
+
curr[el]._errors.push(mapper(issue));
|
|
33235
|
+
}
|
|
33236
|
+
curr = curr[el];
|
|
33237
|
+
i++;
|
|
33238
|
+
}
|
|
33239
|
+
}
|
|
33240
|
+
}
|
|
33241
|
+
};
|
|
33242
|
+
processError(error);
|
|
33243
|
+
return fieldErrors;
|
|
33244
|
+
}
|
|
33245
|
+
var initializer = (inst, def) => {
|
|
33246
|
+
inst.name = "$ZodError";
|
|
33247
|
+
Object.defineProperty(inst, "_zod", {
|
|
33248
|
+
value: inst._zod,
|
|
33249
|
+
enumerable: false
|
|
33250
|
+
});
|
|
33251
|
+
Object.defineProperty(inst, "issues", {
|
|
33252
|
+
value: def,
|
|
33253
|
+
enumerable: false
|
|
33254
|
+
});
|
|
33255
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
33256
|
+
Object.defineProperty(inst, "toString", {
|
|
33257
|
+
value: () => inst.message,
|
|
33258
|
+
enumerable: false
|
|
33259
|
+
});
|
|
33260
|
+
}, $ZodError, $ZodRealError;
|
|
33261
|
+
var init_errors = __esm(() => {
|
|
33262
|
+
init_core();
|
|
33263
|
+
init_util();
|
|
33264
|
+
$ZodError = $constructor("$ZodError", initializer);
|
|
33265
|
+
$ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
|
|
33266
|
+
});
|
|
33267
|
+
|
|
33268
|
+
// ../../node_modules/zod/v4/core/parse.js
|
|
33269
|
+
var init_parse = () => {};
|
|
33270
|
+
|
|
33271
|
+
// ../../node_modules/zod/v4/core/regexes.js
|
|
33272
|
+
var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`, date;
|
|
33273
|
+
var init_regexes = __esm(() => {
|
|
33274
|
+
date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
33275
|
+
});
|
|
33276
|
+
|
|
33277
|
+
// ../../node_modules/zod/v4/core/checks.js
|
|
33278
|
+
var init_checks = () => {};
|
|
33279
|
+
|
|
33280
|
+
// ../../node_modules/zod/v4/core/versions.js
|
|
33281
|
+
var init_versions = () => {};
|
|
33282
|
+
|
|
33283
|
+
// ../../node_modules/zod/v4/core/schemas.js
|
|
33284
|
+
var init_schemas = () => {};
|
|
33285
|
+
|
|
33286
|
+
// ../../node_modules/zod/v4/locales/en.js
|
|
33287
|
+
function en_default() {
|
|
33288
|
+
return {
|
|
33289
|
+
localeError: error()
|
|
33290
|
+
};
|
|
33291
|
+
}
|
|
33292
|
+
var error = () => {
|
|
33293
|
+
const Sizable = {
|
|
33294
|
+
string: { unit: "characters", verb: "to have" },
|
|
33295
|
+
file: { unit: "bytes", verb: "to have" },
|
|
33296
|
+
array: { unit: "items", verb: "to have" },
|
|
33297
|
+
set: { unit: "items", verb: "to have" },
|
|
33298
|
+
map: { unit: "entries", verb: "to have" }
|
|
33299
|
+
};
|
|
33300
|
+
function getSizing(origin) {
|
|
33301
|
+
return Sizable[origin] ?? null;
|
|
33302
|
+
}
|
|
33303
|
+
const FormatDictionary = {
|
|
33304
|
+
regex: "input",
|
|
33305
|
+
email: "email address",
|
|
33306
|
+
url: "URL",
|
|
33307
|
+
emoji: "emoji",
|
|
33308
|
+
uuid: "UUID",
|
|
33309
|
+
uuidv4: "UUIDv4",
|
|
33310
|
+
uuidv6: "UUIDv6",
|
|
33311
|
+
nanoid: "nanoid",
|
|
33312
|
+
guid: "GUID",
|
|
33313
|
+
cuid: "cuid",
|
|
33314
|
+
cuid2: "cuid2",
|
|
33315
|
+
ulid: "ULID",
|
|
33316
|
+
xid: "XID",
|
|
33317
|
+
ksuid: "KSUID",
|
|
33318
|
+
datetime: "ISO datetime",
|
|
33319
|
+
date: "ISO date",
|
|
33320
|
+
time: "ISO time",
|
|
33321
|
+
duration: "ISO duration",
|
|
33322
|
+
ipv4: "IPv4 address",
|
|
33323
|
+
ipv6: "IPv6 address",
|
|
33324
|
+
mac: "MAC address",
|
|
33325
|
+
cidrv4: "IPv4 range",
|
|
33326
|
+
cidrv6: "IPv6 range",
|
|
33327
|
+
base64: "base64-encoded string",
|
|
33328
|
+
base64url: "base64url-encoded string",
|
|
33329
|
+
json_string: "JSON string",
|
|
33330
|
+
e164: "E.164 number",
|
|
33331
|
+
jwt: "JWT",
|
|
33332
|
+
template_literal: "input"
|
|
33333
|
+
};
|
|
33334
|
+
const TypeDictionary = {
|
|
33335
|
+
nan: "NaN"
|
|
33336
|
+
};
|
|
33337
|
+
return (issue) => {
|
|
33338
|
+
switch (issue.code) {
|
|
33339
|
+
case "invalid_type": {
|
|
33340
|
+
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
|
33341
|
+
const receivedType = parsedType(issue.input);
|
|
33342
|
+
const received = TypeDictionary[receivedType] ?? receivedType;
|
|
33343
|
+
return `Invalid input: expected ${expected}, received ${received}`;
|
|
33344
|
+
}
|
|
33345
|
+
case "invalid_value":
|
|
33346
|
+
if (issue.values.length === 1)
|
|
33347
|
+
return `Invalid input: expected ${stringifyPrimitive(issue.values[0])}`;
|
|
33348
|
+
return `Invalid option: expected one of ${joinValues(issue.values, "|")}`;
|
|
33349
|
+
case "too_big": {
|
|
33350
|
+
const adj = issue.inclusive ? "<=" : "<";
|
|
33351
|
+
const sizing = getSizing(issue.origin);
|
|
33352
|
+
if (sizing)
|
|
33353
|
+
return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
|
|
33354
|
+
return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
|
|
33355
|
+
}
|
|
33356
|
+
case "too_small": {
|
|
33357
|
+
const adj = issue.inclusive ? ">=" : ">";
|
|
33358
|
+
const sizing = getSizing(issue.origin);
|
|
33359
|
+
if (sizing) {
|
|
33360
|
+
return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
|
|
33361
|
+
}
|
|
33362
|
+
return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
|
|
33363
|
+
}
|
|
33364
|
+
case "invalid_format": {
|
|
33365
|
+
const _issue = issue;
|
|
33366
|
+
if (_issue.format === "starts_with") {
|
|
33367
|
+
return `Invalid string: must start with "${_issue.prefix}"`;
|
|
33368
|
+
}
|
|
33369
|
+
if (_issue.format === "ends_with")
|
|
33370
|
+
return `Invalid string: must end with "${_issue.suffix}"`;
|
|
33371
|
+
if (_issue.format === "includes")
|
|
33372
|
+
return `Invalid string: must include "${_issue.includes}"`;
|
|
33373
|
+
if (_issue.format === "regex")
|
|
33374
|
+
return `Invalid string: must match pattern ${_issue.pattern}`;
|
|
33375
|
+
return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
|
|
33376
|
+
}
|
|
33377
|
+
case "not_multiple_of":
|
|
33378
|
+
return `Invalid number: must be a multiple of ${issue.divisor}`;
|
|
33379
|
+
case "unrecognized_keys":
|
|
33380
|
+
return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${joinValues(issue.keys, ", ")}`;
|
|
33381
|
+
case "invalid_key":
|
|
33382
|
+
return `Invalid key in ${issue.origin}`;
|
|
33383
|
+
case "invalid_union":
|
|
33384
|
+
return "Invalid input";
|
|
33385
|
+
case "invalid_element":
|
|
33386
|
+
return `Invalid value in ${issue.origin}`;
|
|
33387
|
+
default:
|
|
33388
|
+
return `Invalid input`;
|
|
33389
|
+
}
|
|
33390
|
+
};
|
|
33391
|
+
};
|
|
33392
|
+
var init_en = __esm(() => {
|
|
33393
|
+
init_util();
|
|
33394
|
+
});
|
|
33395
|
+
|
|
33396
|
+
// ../../node_modules/zod/v4/locales/index.js
|
|
33397
|
+
var init_locales = () => {};
|
|
33398
|
+
|
|
33399
|
+
// ../../node_modules/zod/v4/core/registries.js
|
|
33400
|
+
class $ZodRegistry {
|
|
33401
|
+
constructor() {
|
|
33402
|
+
this._map = new WeakMap;
|
|
33403
|
+
this._idmap = new Map;
|
|
33404
|
+
}
|
|
33405
|
+
add(schema, ..._meta) {
|
|
33406
|
+
const meta = _meta[0];
|
|
33407
|
+
this._map.set(schema, meta);
|
|
33408
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
33409
|
+
this._idmap.set(meta.id, schema);
|
|
33410
|
+
}
|
|
33411
|
+
return this;
|
|
33412
|
+
}
|
|
33413
|
+
clear() {
|
|
33414
|
+
this._map = new WeakMap;
|
|
33415
|
+
this._idmap = new Map;
|
|
33416
|
+
return this;
|
|
33417
|
+
}
|
|
33418
|
+
remove(schema) {
|
|
33419
|
+
const meta = this._map.get(schema);
|
|
33420
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
33421
|
+
this._idmap.delete(meta.id);
|
|
33422
|
+
}
|
|
33423
|
+
this._map.delete(schema);
|
|
33424
|
+
return this;
|
|
33425
|
+
}
|
|
33426
|
+
get(schema) {
|
|
33427
|
+
const p = schema._zod.parent;
|
|
33428
|
+
if (p) {
|
|
33429
|
+
const pm = { ...this.get(p) ?? {} };
|
|
33430
|
+
delete pm.id;
|
|
33431
|
+
const f = { ...pm, ...this._map.get(schema) };
|
|
33432
|
+
return Object.keys(f).length ? f : undefined;
|
|
33433
|
+
}
|
|
33434
|
+
return this._map.get(schema);
|
|
33435
|
+
}
|
|
33436
|
+
has(schema) {
|
|
33437
|
+
return this._map.has(schema);
|
|
33438
|
+
}
|
|
33439
|
+
}
|
|
33440
|
+
function registry() {
|
|
33441
|
+
return new $ZodRegistry;
|
|
33442
|
+
}
|
|
33443
|
+
var _a, $output, $input, globalRegistry;
|
|
33444
|
+
var init_registries = __esm(() => {
|
|
33445
|
+
$output = Symbol("ZodOutput");
|
|
33446
|
+
$input = Symbol("ZodInput");
|
|
33447
|
+
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
33448
|
+
globalRegistry = globalThis.__zod_globalRegistry;
|
|
33449
|
+
});
|
|
33450
|
+
|
|
33451
|
+
// ../../node_modules/zod/v4/core/api.js
|
|
33452
|
+
var init_api = () => {};
|
|
33453
|
+
|
|
33454
|
+
// ../../node_modules/zod/v4/core/to-json-schema.js
|
|
33455
|
+
var init_to_json_schema = () => {};
|
|
33456
|
+
|
|
33457
|
+
// ../../node_modules/zod/v4/core/json-schema.js
|
|
33458
|
+
var init_json_schema = () => {};
|
|
33459
|
+
|
|
33460
|
+
// ../../node_modules/zod/v4/core/index.js
|
|
33461
|
+
var init_core2 = __esm(() => {
|
|
33462
|
+
init_util();
|
|
33463
|
+
init_regexes();
|
|
33464
|
+
init_locales();
|
|
33465
|
+
init_json_schema();
|
|
33466
|
+
init_core();
|
|
33467
|
+
init_parse();
|
|
33468
|
+
init_errors();
|
|
33469
|
+
init_schemas();
|
|
33470
|
+
init_checks();
|
|
33471
|
+
init_versions();
|
|
33472
|
+
init_registries();
|
|
33473
|
+
init_api();
|
|
33474
|
+
init_to_json_schema();
|
|
33475
|
+
});
|
|
33476
|
+
|
|
33477
|
+
// ../../node_modules/zod/v4/classic/checks.js
|
|
33478
|
+
var init_checks2 = () => {};
|
|
33479
|
+
|
|
33480
|
+
// ../../node_modules/zod/v4/classic/iso.js
|
|
33481
|
+
var init_iso = () => {};
|
|
33482
|
+
|
|
33483
|
+
// ../../node_modules/zod/v4/classic/errors.js
|
|
33484
|
+
var initializer2 = (inst, issues) => {
|
|
33485
|
+
$ZodError.init(inst, issues);
|
|
33486
|
+
inst.name = "ZodError";
|
|
33487
|
+
Object.defineProperties(inst, {
|
|
33488
|
+
format: {
|
|
33489
|
+
value: (mapper) => formatError(inst, mapper)
|
|
33490
|
+
},
|
|
33491
|
+
flatten: {
|
|
33492
|
+
value: (mapper) => flattenError(inst, mapper)
|
|
33493
|
+
},
|
|
33494
|
+
addIssue: {
|
|
33495
|
+
value: (issue) => {
|
|
33496
|
+
inst.issues.push(issue);
|
|
33497
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
33498
|
+
}
|
|
33499
|
+
},
|
|
33500
|
+
addIssues: {
|
|
33501
|
+
value: (issues2) => {
|
|
33502
|
+
inst.issues.push(...issues2);
|
|
33503
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
33504
|
+
}
|
|
33505
|
+
},
|
|
33506
|
+
isEmpty: {
|
|
33507
|
+
get() {
|
|
33508
|
+
return inst.issues.length === 0;
|
|
33509
|
+
}
|
|
33510
|
+
}
|
|
33511
|
+
});
|
|
33512
|
+
}, ZodError, ZodRealError;
|
|
33513
|
+
var init_errors2 = __esm(() => {
|
|
33514
|
+
init_core2();
|
|
33515
|
+
init_core2();
|
|
33516
|
+
init_util();
|
|
33517
|
+
ZodError = $constructor("ZodError", initializer2);
|
|
33518
|
+
ZodRealError = $constructor("ZodError", initializer2, {
|
|
33519
|
+
Parent: Error
|
|
33520
|
+
});
|
|
33521
|
+
});
|
|
33522
|
+
|
|
33523
|
+
// ../../node_modules/zod/v4/classic/parse.js
|
|
33524
|
+
var init_parse2 = () => {};
|
|
33525
|
+
|
|
33526
|
+
// ../../node_modules/zod/v4/classic/schemas.js
|
|
33527
|
+
var init_schemas2 = () => {};
|
|
33528
|
+
|
|
33529
|
+
// ../../node_modules/zod/v4/classic/compat.js
|
|
33530
|
+
var ZodFirstPartyTypeKind;
|
|
33531
|
+
var init_compat = __esm(() => {
|
|
33532
|
+
(function(ZodFirstPartyTypeKind2) {})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
33533
|
+
});
|
|
33534
|
+
|
|
33535
|
+
// ../../node_modules/zod/v4/classic/coerce.js
|
|
33536
|
+
var init_coerce = () => {};
|
|
33537
|
+
|
|
33538
|
+
// ../../node_modules/zod/v4/classic/external.js
|
|
33539
|
+
var init_external = __esm(() => {
|
|
33540
|
+
init_core2();
|
|
33541
|
+
init_core2();
|
|
33542
|
+
init_en();
|
|
33543
|
+
init_locales();
|
|
33544
|
+
init_iso();
|
|
33545
|
+
init_coerce();
|
|
33546
|
+
init_schemas2();
|
|
33547
|
+
init_checks2();
|
|
33548
|
+
init_errors2();
|
|
33549
|
+
init_parse2();
|
|
33550
|
+
init_compat();
|
|
33551
|
+
config(en_default());
|
|
33552
|
+
});
|
|
33553
|
+
|
|
33554
|
+
// ../../node_modules/zod/v4/classic/index.js
|
|
33555
|
+
var init_classic = __esm(() => {
|
|
33556
|
+
init_external();
|
|
33557
|
+
});
|
|
33558
|
+
|
|
33559
|
+
// ../../node_modules/zod/v4/index.js
|
|
33560
|
+
var init_v4 = __esm(() => {
|
|
33561
|
+
init_classic();
|
|
33562
|
+
});
|
|
33563
|
+
|
|
33564
|
+
// ../../node_modules/astro/dist/zod.js
|
|
33565
|
+
var init_zod = __esm(() => {
|
|
33566
|
+
init_v4();
|
|
33567
|
+
});
|
|
33568
|
+
|
|
32926
33569
|
// ../cms/src/field-types.ts
|
|
32927
|
-
|
|
32928
|
-
|
|
33570
|
+
var init_field_types = __esm(() => {
|
|
33571
|
+
init_zod();
|
|
33572
|
+
});
|
|
32929
33573
|
// ../cms/src/media/s3.ts
|
|
32930
33574
|
var init_s3 = __esm(() => {
|
|
32931
33575
|
init_local();
|
|
32932
33576
|
});
|
|
32933
33577
|
|
|
32934
33578
|
// ../cms/src/migrate-astro-image.ts
|
|
32935
|
-
import
|
|
32936
|
-
import
|
|
33579
|
+
import fs15 from "fs/promises";
|
|
33580
|
+
import path16 from "path";
|
|
32937
33581
|
async function migrateAstroImages(options = {}) {
|
|
32938
33582
|
const projectRoot = options.projectRoot ?? getProjectRoot();
|
|
32939
33583
|
const dryRun = options.dryRun ?? false;
|
|
@@ -32945,10 +33589,10 @@ async function migrateAstroImages(options = {}) {
|
|
|
32945
33589
|
if (astroFields.length === 0 || !def.entries)
|
|
32946
33590
|
continue;
|
|
32947
33591
|
for (const entry of def.entries) {
|
|
32948
|
-
const entryAbs =
|
|
33592
|
+
const entryAbs = path16.isAbsolute(entry.sourcePath) ? entry.sourcePath : path16.join(projectRoot, entry.sourcePath);
|
|
32949
33593
|
let raw;
|
|
32950
33594
|
try {
|
|
32951
|
-
raw = await
|
|
33595
|
+
raw = await fs15.readFile(entryAbs, "utf-8");
|
|
32952
33596
|
} catch {
|
|
32953
33597
|
skipped.push({ entrySourcePath: entry.sourcePath, fieldName: "*", reason: "read failed" });
|
|
32954
33598
|
continue;
|
|
@@ -32959,10 +33603,10 @@ async function migrateAstroImages(options = {}) {
|
|
|
32959
33603
|
continue;
|
|
32960
33604
|
}
|
|
32961
33605
|
const [fullFm, fmStart, yamlBody, fmEnd] = fmMatch;
|
|
32962
|
-
const
|
|
33606
|
+
const doc2 = import_yaml6.parseDocument(yamlBody);
|
|
32963
33607
|
let mutated = false;
|
|
32964
33608
|
for (const field of astroFields) {
|
|
32965
|
-
const current =
|
|
33609
|
+
const current = doc2.get(field.name);
|
|
32966
33610
|
if (typeof current !== "string") {
|
|
32967
33611
|
if (current != null)
|
|
32968
33612
|
skipped.push({ entrySourcePath: entry.sourcePath, fieldName: field.name, reason: "non-string value" });
|
|
@@ -32970,10 +33614,10 @@ async function migrateAstroImages(options = {}) {
|
|
|
32970
33614
|
}
|
|
32971
33615
|
if (!current.startsWith("/") || current.startsWith("//"))
|
|
32972
33616
|
continue;
|
|
32973
|
-
const sourceAbs =
|
|
33617
|
+
const sourceAbs = path16.join(projectRoot, "public", current.replace(/^\/+/, ""));
|
|
32974
33618
|
let sourceBuf;
|
|
32975
33619
|
try {
|
|
32976
|
-
sourceBuf = await
|
|
33620
|
+
sourceBuf = await fs15.readFile(sourceAbs);
|
|
32977
33621
|
} catch {
|
|
32978
33622
|
skipped.push({ entrySourcePath: entry.sourcePath, fieldName: field.name, reason: `source missing: ${sourceAbs}` });
|
|
32979
33623
|
continue;
|
|
@@ -32981,14 +33625,14 @@ async function migrateAstroImages(options = {}) {
|
|
|
32981
33625
|
const target = await pickAstroImageTarget({
|
|
32982
33626
|
entryAbsPath: entryAbs,
|
|
32983
33627
|
slug: entry.slug,
|
|
32984
|
-
originalFilename:
|
|
33628
|
+
originalFilename: path16.basename(current),
|
|
32985
33629
|
compareBuffer: sourceBuf
|
|
32986
33630
|
});
|
|
32987
33631
|
if (!dryRun) {
|
|
32988
|
-
await
|
|
32989
|
-
await
|
|
33632
|
+
await fs15.mkdir(path16.dirname(target.absPath), { recursive: true });
|
|
33633
|
+
await fs15.writeFile(target.absPath, sourceBuf);
|
|
32990
33634
|
}
|
|
32991
|
-
|
|
33635
|
+
doc2.set(field.name, target.relPath);
|
|
32992
33636
|
mutated = true;
|
|
32993
33637
|
migrations.push({
|
|
32994
33638
|
entrySourcePath: entry.sourcePath,
|
|
@@ -33000,9 +33644,9 @@ async function migrateAstroImages(options = {}) {
|
|
|
33000
33644
|
});
|
|
33001
33645
|
}
|
|
33002
33646
|
if (mutated && !dryRun) {
|
|
33003
|
-
const newYaml =
|
|
33647
|
+
const newYaml = doc2.toString().replace(/\n$/, "");
|
|
33004
33648
|
const newRaw = raw.replace(fullFm, `${fmStart}${newYaml}${fmEnd}`);
|
|
33005
|
-
await
|
|
33649
|
+
await fs15.writeFile(entryAbs, newRaw, "utf-8");
|
|
33006
33650
|
}
|
|
33007
33651
|
}
|
|
33008
33652
|
}
|
|
@@ -33044,7 +33688,7 @@ var exports_migrate = {};
|
|
|
33044
33688
|
__export(exports_migrate, {
|
|
33045
33689
|
migrate: () => migrate
|
|
33046
33690
|
});
|
|
33047
|
-
import
|
|
33691
|
+
import path17 from "path";
|
|
33048
33692
|
async function migrate(args) {
|
|
33049
33693
|
if (args.target !== "astro-image") {
|
|
33050
33694
|
console.error(`Unknown migrate target: ${args.target}`);
|
|
@@ -33063,7 +33707,7 @@ async function migrate(args) {
|
|
|
33063
33707
|
for (const m of result.migrations) {
|
|
33064
33708
|
console.log(` ${m.entrySourcePath}`);
|
|
33065
33709
|
console.log(` ${m.fieldName}: ${m.originalValue} \u2192 ${m.newValue}`);
|
|
33066
|
-
console.log(` copy: ${
|
|
33710
|
+
console.log(` copy: ${path17.relative(process.cwd(), m.copiedFrom)} \u2192 ${path17.relative(process.cwd(), m.copiedTo)}`);
|
|
33067
33711
|
}
|
|
33068
33712
|
}
|
|
33069
33713
|
if (result.skipped.length > 0) {
|
|
@@ -33082,224 +33726,9 @@ var init_migrate = __esm(() => {
|
|
|
33082
33726
|
init_src();
|
|
33083
33727
|
});
|
|
33084
33728
|
|
|
33085
|
-
// ../agent-summary/src/agent-summary-integration.ts
|
|
33086
|
-
import fs2 from "fs/promises";
|
|
33087
|
-
import { fileURLToPath } from "url";
|
|
33088
|
-
|
|
33089
|
-
// ../agent-summary/src/utils.ts
|
|
33090
|
-
import { promises as fs } from "fs";
|
|
33091
|
-
import path from "path";
|
|
33092
|
-
var AGENTS_PATH = path.resolve("AGENTS.md");
|
|
33093
|
-
var SUMMARY_START = "<page_summary>";
|
|
33094
|
-
var SUMMARY_END = "</page_summary>";
|
|
33095
|
-
var decodeEntities = (value) => {
|
|
33096
|
-
return value.replace(/&/gi, "&").replace(/</gi, "<").replace(/>/gi, ">").replace(/"/gi, '"').replace(/'/gi, "'").replace(/ /gi, " ");
|
|
33097
|
-
};
|
|
33098
|
-
var sanitize = (value) => {
|
|
33099
|
-
if (!value) {
|
|
33100
|
-
return "";
|
|
33101
|
-
}
|
|
33102
|
-
const decoded = decodeEntities(value);
|
|
33103
|
-
return decoded.replace(/\s+/g, " ").replace(/[\u2012-\u2015]/g, "-").replace(/\u2026/g, "...").trim();
|
|
33104
|
-
};
|
|
33105
|
-
var truncate = (value, maxLength) => {
|
|
33106
|
-
if (value.length <= maxLength) {
|
|
33107
|
-
return value;
|
|
33108
|
-
}
|
|
33109
|
-
return `${value.slice(0, maxLength - 3).trimEnd()}...`;
|
|
33110
|
-
};
|
|
33111
|
-
var normalizeRoute = (pathname) => {
|
|
33112
|
-
const trimmed = pathname.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
33113
|
-
if (trimmed.length === 0) {
|
|
33114
|
-
return "/";
|
|
33115
|
-
}
|
|
33116
|
-
return `/${trimmed}`;
|
|
33117
|
-
};
|
|
33118
|
-
var formatDestination = (value) => {
|
|
33119
|
-
if (!value) {
|
|
33120
|
-
return "/";
|
|
33121
|
-
}
|
|
33122
|
-
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("#")) {
|
|
33123
|
-
return value;
|
|
33124
|
-
}
|
|
33125
|
-
return normalizeRoute(value);
|
|
33126
|
-
};
|
|
33127
|
-
var resolveHtmlPath = async (distDir, pathname) => {
|
|
33128
|
-
const normalizedRoute = normalizeRoute(pathname);
|
|
33129
|
-
const routeSegment = normalizedRoute === "/" ? "" : normalizedRoute.slice(1);
|
|
33130
|
-
const candidates = routeSegment === "" ? [path.join(distDir, "index.html")] : [
|
|
33131
|
-
path.join(distDir, routeSegment, "index.html"),
|
|
33132
|
-
path.join(distDir, `${routeSegment}.html`)
|
|
33133
|
-
];
|
|
33134
|
-
for (const candidate of candidates) {
|
|
33135
|
-
try {
|
|
33136
|
-
const stats = await fs.stat(candidate);
|
|
33137
|
-
if (stats.isFile()) {
|
|
33138
|
-
return candidate;
|
|
33139
|
-
}
|
|
33140
|
-
} catch {}
|
|
33141
|
-
}
|
|
33142
|
-
return null;
|
|
33143
|
-
};
|
|
33144
|
-
var extractMetaFromHtml = (route, html) => {
|
|
33145
|
-
const titleMatch = html.match(/<title[^>]*>([^<]*)<\/title>/i);
|
|
33146
|
-
const metaMatch = html.match(/<meta[^>]+name=["']description["'][^>]*?>/i);
|
|
33147
|
-
const contentMatch = metaMatch?.[0]?.match(/content=["']([^"']*)["']/i);
|
|
33148
|
-
const headingMatches = [...html.matchAll(/<h([1-6])[^>]*>([\s\S]*?)<\/h\1>/gi)];
|
|
33149
|
-
const headingEntries = headingMatches.map((match) => ({
|
|
33150
|
-
level: `h${match[1]}`,
|
|
33151
|
-
text: sanitize(match[2]?.replace(/<[^>]+>/g, ""))
|
|
33152
|
-
})).filter((entry) => entry.text.length > 0);
|
|
33153
|
-
const primaryHeading = headingEntries.find((entry) => entry.level === "h1" && entry.text.length >= 8) || headingEntries.find((entry) => entry.text.length >= 16) || headingEntries[0];
|
|
33154
|
-
const primaryHeadingText = primaryHeading?.text ?? "";
|
|
33155
|
-
const paragraphMatches = [...html.matchAll(/<p[^>]*>([\s\S]*?)<\/p>/gi)];
|
|
33156
|
-
const paragraphCandidates = paragraphMatches.map((match) => sanitize(match[1]?.replace(/<[^>]+>/g, "")));
|
|
33157
|
-
const fallbackParagraph = paragraphCandidates.find((text) => text.length >= 40) ?? paragraphCandidates[0] ?? "";
|
|
33158
|
-
const title = sanitize(titleMatch?.[1] ?? (primaryHeadingText || "Untitled page"));
|
|
33159
|
-
const descriptionSource = contentMatch?.[1];
|
|
33160
|
-
const paragraphDescription = descriptionSource ? "" : fallbackParagraph;
|
|
33161
|
-
const description = truncate((descriptionSource ? sanitize(descriptionSource) : paragraphDescription) || "Description unavailable", 220);
|
|
33162
|
-
return {
|
|
33163
|
-
route: normalizeRoute(route),
|
|
33164
|
-
title,
|
|
33165
|
-
description,
|
|
33166
|
-
headlines: headingEntries
|
|
33167
|
-
};
|
|
33168
|
-
};
|
|
33169
|
-
var createJsonlRecords = (pages, redirects) => {
|
|
33170
|
-
const records = [];
|
|
33171
|
-
for (const page of pages.sort((a, b) => a.route.localeCompare(b.route))) {
|
|
33172
|
-
records.push(JSON.stringify({
|
|
33173
|
-
kind: "page",
|
|
33174
|
-
route: page.route,
|
|
33175
|
-
title: page.title,
|
|
33176
|
-
description: page.description,
|
|
33177
|
-
headlines: page.headlines
|
|
33178
|
-
}));
|
|
33179
|
-
}
|
|
33180
|
-
for (const redirect of redirects.sort((a, b) => a.from.localeCompare(b.from))) {
|
|
33181
|
-
records.push(JSON.stringify({
|
|
33182
|
-
kind: "redirect",
|
|
33183
|
-
route: redirect.from,
|
|
33184
|
-
to: redirect.to,
|
|
33185
|
-
status: redirect.status
|
|
33186
|
-
}));
|
|
33187
|
-
}
|
|
33188
|
-
return records;
|
|
33189
|
-
};
|
|
33190
|
-
var updateAgentsSummary = async (pages, redirects) => {
|
|
33191
|
-
const jsonlRecords = createJsonlRecords(pages, redirects);
|
|
33192
|
-
const summaryBody = jsonlRecords.join(`
|
|
33193
|
-
`);
|
|
33194
|
-
const summaryBlock = summaryBody ? `${SUMMARY_START}
|
|
33195
|
-
${summaryBody}
|
|
33196
|
-
${SUMMARY_END}
|
|
33197
|
-
` : `${SUMMARY_START}
|
|
33198
|
-
${SUMMARY_END}
|
|
33199
|
-
`;
|
|
33200
|
-
const agentsContent = await fs.readFile(AGENTS_PATH, "utf8").catch(() => "");
|
|
33201
|
-
if (agentsContent.includes(SUMMARY_START) && agentsContent.includes(SUMMARY_END)) {
|
|
33202
|
-
const startIndex = agentsContent.indexOf(SUMMARY_START);
|
|
33203
|
-
const summaryEndIndex = agentsContent.indexOf(SUMMARY_END, startIndex);
|
|
33204
|
-
if (summaryEndIndex === -1) {
|
|
33205
|
-
const recovered = `${agentsContent.slice(0, startIndex)}${summaryBlock}`;
|
|
33206
|
-
await fs.writeFile(AGENTS_PATH, recovered, "utf8");
|
|
33207
|
-
return;
|
|
33208
|
-
}
|
|
33209
|
-
let endIndex = summaryEndIndex + SUMMARY_END.length;
|
|
33210
|
-
while (endIndex < agentsContent.length && (agentsContent[endIndex] === `
|
|
33211
|
-
` || agentsContent[endIndex] === "\r")) {
|
|
33212
|
-
endIndex += 1;
|
|
33213
|
-
}
|
|
33214
|
-
const updated = `${agentsContent.slice(0, startIndex)}${summaryBlock}${agentsContent.slice(endIndex)}`;
|
|
33215
|
-
await fs.writeFile(AGENTS_PATH, updated, "utf8");
|
|
33216
|
-
return;
|
|
33217
|
-
}
|
|
33218
|
-
const prefix = agentsContent.trimEnd();
|
|
33219
|
-
const separator = prefix.length === 0 ? "" : `
|
|
33220
|
-
`;
|
|
33221
|
-
await fs.writeFile(AGENTS_PATH, `${prefix}${separator}${summaryBlock}`, "utf8");
|
|
33222
|
-
};
|
|
33223
|
-
|
|
33224
|
-
// ../agent-summary/src/agent-summary-integration.ts
|
|
33225
|
-
var agentsSummary = () => {
|
|
33226
|
-
const redirectPathnames = new Set;
|
|
33227
|
-
const redirects = [];
|
|
33228
|
-
return {
|
|
33229
|
-
name: "agents-summary",
|
|
33230
|
-
hooks: {
|
|
33231
|
-
"astro:routes:resolved": ({ routes }) => {
|
|
33232
|
-
redirectPathnames.clear();
|
|
33233
|
-
redirects.length = 0;
|
|
33234
|
-
for (const route of routes) {
|
|
33235
|
-
if (route.type === "redirect" && route.pathname) {
|
|
33236
|
-
const from = normalizeRoute(route.pathname);
|
|
33237
|
-
redirectPathnames.add(from);
|
|
33238
|
-
let destination = "";
|
|
33239
|
-
let status = "";
|
|
33240
|
-
const redirectConfig = route.redirect;
|
|
33241
|
-
if (typeof redirectConfig === "string") {
|
|
33242
|
-
destination = redirectConfig;
|
|
33243
|
-
status = "302";
|
|
33244
|
-
} else if (redirectConfig) {
|
|
33245
|
-
destination = redirectConfig.destination;
|
|
33246
|
-
status = redirectConfig.status?.toString() ?? "";
|
|
33247
|
-
} else if (route.redirectRoute?.pathname) {
|
|
33248
|
-
destination = route.redirectRoute.pathname;
|
|
33249
|
-
}
|
|
33250
|
-
let resolvedDestination = destination;
|
|
33251
|
-
if (!resolvedDestination && route.redirectRoute?.pattern) {
|
|
33252
|
-
resolvedDestination = route.redirectRoute.pattern.toString();
|
|
33253
|
-
}
|
|
33254
|
-
const to = resolvedDestination?.startsWith("^") ? resolvedDestination : formatDestination(resolvedDestination);
|
|
33255
|
-
redirects.push({
|
|
33256
|
-
from,
|
|
33257
|
-
to,
|
|
33258
|
-
status: status || "302"
|
|
33259
|
-
});
|
|
33260
|
-
}
|
|
33261
|
-
}
|
|
33262
|
-
},
|
|
33263
|
-
"astro:build:done": async ({ dir, pages, logger }) => {
|
|
33264
|
-
const distDir = fileURLToPath(dir);
|
|
33265
|
-
const summaries = [];
|
|
33266
|
-
for (const page of pages) {
|
|
33267
|
-
const route = normalizeRoute(page.pathname);
|
|
33268
|
-
if (redirectPathnames.has(route)) {
|
|
33269
|
-
continue;
|
|
33270
|
-
}
|
|
33271
|
-
const htmlPath = await resolveHtmlPath(distDir, page.pathname);
|
|
33272
|
-
if (!htmlPath) {
|
|
33273
|
-
logger.warn(`Skipping ${page.pathname}; no HTML output found.`);
|
|
33274
|
-
continue;
|
|
33275
|
-
}
|
|
33276
|
-
const html = await fs2.readFile(htmlPath, "utf8");
|
|
33277
|
-
summaries.push(extractMetaFromHtml(page.pathname, html));
|
|
33278
|
-
}
|
|
33279
|
-
if (summaries.length === 0) {
|
|
33280
|
-
logger.warn("No pages detected; AGENTS.md was not updated.");
|
|
33281
|
-
return;
|
|
33282
|
-
}
|
|
33283
|
-
await updateAgentsSummary(summaries, redirects);
|
|
33284
|
-
logger.info(`Updated AGENTS.md with ${summaries.length} page entries${redirects.length > 0 ? ` and ${redirects.length} redirects` : ""}.`);
|
|
33285
|
-
}
|
|
33286
|
-
}
|
|
33287
|
-
};
|
|
33288
|
-
};
|
|
33289
33729
|
// src/index.ts
|
|
33290
|
-
init_utils();
|
|
33291
|
-
import { build as astroBuild, dev, preview } from "astro";
|
|
33292
33730
|
import { spawn } from "child_process";
|
|
33293
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
33294
33731
|
var [, , command, ...args] = process.argv;
|
|
33295
|
-
function hasNuaIntegration(configPath) {
|
|
33296
|
-
try {
|
|
33297
|
-
const content = readFileSync3(configPath, "utf-8");
|
|
33298
|
-
return content.includes("@nuasite/agent-summary") || content.includes("agentsSummary");
|
|
33299
|
-
} catch {
|
|
33300
|
-
return false;
|
|
33301
|
-
}
|
|
33302
|
-
}
|
|
33303
33732
|
function proxyToAstroCLI(command2, args2) {
|
|
33304
33733
|
const astro = spawn("npx", ["astro", command2, ...args2], {
|
|
33305
33734
|
stdio: "inherit",
|
|
@@ -33308,8 +33737,8 @@ function proxyToAstroCLI(command2, args2) {
|
|
|
33308
33737
|
astro.on("close", (code) => {
|
|
33309
33738
|
process.exit(code || 0);
|
|
33310
33739
|
});
|
|
33311
|
-
astro.on("error", (
|
|
33312
|
-
console.error("Error running astro command:",
|
|
33740
|
+
astro.on("error", (error2) => {
|
|
33741
|
+
console.error("Error running astro command:", error2);
|
|
33313
33742
|
process.exit(1);
|
|
33314
33743
|
});
|
|
33315
33744
|
}
|
|
@@ -33328,45 +33757,10 @@ Commands:`);
|
|
|
33328
33757
|
All Astro CLI options are supported.
|
|
33329
33758
|
`);
|
|
33330
33759
|
}
|
|
33331
|
-
|
|
33332
|
-
var canProxyDirectly = configPath && hasNuaIntegration(configPath);
|
|
33333
|
-
if (canProxyDirectly && command && ["build", "dev", "preview"].includes(command)) {
|
|
33760
|
+
if (command && ["build", "dev", "preview"].includes(command)) {
|
|
33334
33761
|
proxyToAstroCLI(command, args);
|
|
33335
33762
|
} else {
|
|
33336
33763
|
switch (command) {
|
|
33337
|
-
case "build":
|
|
33338
|
-
astroBuild({
|
|
33339
|
-
root: process.cwd(),
|
|
33340
|
-
integrations: [agentsSummary()]
|
|
33341
|
-
}).catch((error) => {
|
|
33342
|
-
console.error("Error:", error);
|
|
33343
|
-
process.exit(1);
|
|
33344
|
-
});
|
|
33345
|
-
break;
|
|
33346
|
-
case "dev":
|
|
33347
|
-
case "preview": {
|
|
33348
|
-
const server = {};
|
|
33349
|
-
for (let i = 0;i < args.length; i++) {
|
|
33350
|
-
if (args[i] === "--port" && args[i + 1]) {
|
|
33351
|
-
server.port = parseInt(args[i + 1], 10);
|
|
33352
|
-
i++;
|
|
33353
|
-
} else if (args[i] === "--host" && args[i + 1]) {
|
|
33354
|
-
server.host = args[i + 1];
|
|
33355
|
-
i++;
|
|
33356
|
-
}
|
|
33357
|
-
}
|
|
33358
|
-
const options = {
|
|
33359
|
-
root: process.cwd(),
|
|
33360
|
-
integrations: [agentsSummary()],
|
|
33361
|
-
server
|
|
33362
|
-
};
|
|
33363
|
-
const runner = command === "dev" ? dev : preview;
|
|
33364
|
-
runner(options).catch((error) => {
|
|
33365
|
-
console.error("Error:", error);
|
|
33366
|
-
process.exit(1);
|
|
33367
|
-
});
|
|
33368
|
-
break;
|
|
33369
|
-
}
|
|
33370
33764
|
case "init": {
|
|
33371
33765
|
const { init: init2 } = await Promise.resolve().then(() => (init_init(), exports_init));
|
|
33372
33766
|
await init2({
|