brandrail 0.7.0 → 0.8.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/dist/brandrail.mjs +1221 -385
- package/package.json +1 -1
package/dist/brandrail.mjs
CHANGED
|
@@ -1299,7 +1299,7 @@ var require_errors = __commonJS({
|
|
|
1299
1299
|
gen.if((0, codegen_1._)`${names_1.default.vErrors} !== null`, () => gen.if(errsCount, () => gen.assign((0, codegen_1._)`${names_1.default.vErrors}.length`, errsCount), () => gen.assign(names_1.default.vErrors, null)));
|
|
1300
1300
|
}
|
|
1301
1301
|
exports.resetErrorsCount = resetErrorsCount;
|
|
1302
|
-
function extendErrors({ gen, keyword, schemaValue, data, errsCount, it }) {
|
|
1302
|
+
function extendErrors({ gen, keyword, schemaValue, data: data2, errsCount, it }) {
|
|
1303
1303
|
if (errsCount === void 0)
|
|
1304
1304
|
throw new Error("ajv implementation error");
|
|
1305
1305
|
const err2 = gen.name("err");
|
|
@@ -1309,7 +1309,7 @@ var require_errors = __commonJS({
|
|
|
1309
1309
|
gen.assign((0, codegen_1._)`${err2}.schemaPath`, (0, codegen_1.str)`${it.errSchemaPath}/${keyword}`);
|
|
1310
1310
|
if (it.opts.verbose) {
|
|
1311
1311
|
gen.assign((0, codegen_1._)`${err2}.schema`, schemaValue);
|
|
1312
|
-
gen.assign((0, codegen_1._)`${err2}.data`,
|
|
1312
|
+
gen.assign((0, codegen_1._)`${err2}.data`, data2);
|
|
1313
1313
|
}
|
|
1314
1314
|
});
|
|
1315
1315
|
}
|
|
@@ -1365,14 +1365,14 @@ var require_errors = __commonJS({
|
|
|
1365
1365
|
return [E.schemaPath, schPath];
|
|
1366
1366
|
}
|
|
1367
1367
|
function extraErrorProps(cxt, { params, message }, keyValues) {
|
|
1368
|
-
const { keyword, data, schemaValue, it } = cxt;
|
|
1368
|
+
const { keyword, data: data2, schemaValue, it } = cxt;
|
|
1369
1369
|
const { opts, propertyName, topSchemaRef, schemaPath } = it;
|
|
1370
1370
|
keyValues.push([E.keyword, keyword], [E.params, typeof params == "function" ? params(cxt) : params || (0, codegen_1._)`{}`]);
|
|
1371
1371
|
if (opts.messages) {
|
|
1372
1372
|
keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]);
|
|
1373
1373
|
}
|
|
1374
1374
|
if (opts.verbose) {
|
|
1375
|
-
keyValues.push([E.schema, schemaValue], [E.parentSchema, (0, codegen_1._)`${topSchemaRef}${schemaPath}`], [names_1.default.data,
|
|
1375
|
+
keyValues.push([E.schema, schemaValue], [E.parentSchema, (0, codegen_1._)`${topSchemaRef}${schemaPath}`], [names_1.default.data, data2]);
|
|
1376
1376
|
}
|
|
1377
1377
|
if (propertyName)
|
|
1378
1378
|
keyValues.push([E.propertyName, propertyName]);
|
|
@@ -1415,11 +1415,11 @@ var require_boolSchema = __commonJS({
|
|
|
1415
1415
|
}
|
|
1416
1416
|
exports.boolOrEmptySchema = boolOrEmptySchema;
|
|
1417
1417
|
function falseSchemaError(it, overrideAllErrors) {
|
|
1418
|
-
const { gen, data } = it;
|
|
1418
|
+
const { gen, data: data2 } = it;
|
|
1419
1419
|
const cxt = {
|
|
1420
1420
|
gen,
|
|
1421
1421
|
keyword: "false schema",
|
|
1422
|
-
data,
|
|
1422
|
+
data: data2,
|
|
1423
1423
|
schema: false,
|
|
1424
1424
|
schemaCode: false,
|
|
1425
1425
|
schemaValue: false,
|
|
@@ -1525,11 +1525,11 @@ var require_dataType = __commonJS({
|
|
|
1525
1525
|
}
|
|
1526
1526
|
exports.getJSONTypes = getJSONTypes;
|
|
1527
1527
|
function coerceAndCheckDataType(it, types) {
|
|
1528
|
-
const { gen, data, opts } = it;
|
|
1528
|
+
const { gen, data: data2, opts } = it;
|
|
1529
1529
|
const coerceTo = coerceToTypes(types, opts.coerceTypes);
|
|
1530
1530
|
const checkTypes = types.length > 0 && !(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0]));
|
|
1531
1531
|
if (checkTypes) {
|
|
1532
|
-
const wrongType = checkDataTypes(types,
|
|
1532
|
+
const wrongType = checkDataTypes(types, data2, opts.strictNumbers, DataType.Wrong);
|
|
1533
1533
|
gen.if(wrongType, () => {
|
|
1534
1534
|
if (coerceTo.length)
|
|
1535
1535
|
coerceData(it, types, coerceTo);
|
|
@@ -1545,11 +1545,11 @@ var require_dataType = __commonJS({
|
|
|
1545
1545
|
return coerceTypes ? types.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
|
|
1546
1546
|
}
|
|
1547
1547
|
function coerceData(it, types, coerceTo) {
|
|
1548
|
-
const { gen, data, opts } = it;
|
|
1549
|
-
const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${
|
|
1548
|
+
const { gen, data: data2, opts } = it;
|
|
1549
|
+
const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data2}`);
|
|
1550
1550
|
const coerced = gen.let("coerced", (0, codegen_1._)`undefined`);
|
|
1551
1551
|
if (opts.coerceTypes === "array") {
|
|
1552
|
-
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${
|
|
1552
|
+
gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data2}) && ${data2}.length == 1`, () => gen.assign(data2, (0, codegen_1._)`${data2}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data2}`).if(checkDataTypes(types, data2, opts.strictNumbers), () => gen.assign(coerced, data2)));
|
|
1553
1553
|
}
|
|
1554
1554
|
gen.if((0, codegen_1._)`${coerced} !== undefined`);
|
|
1555
1555
|
for (const t of coerceTo) {
|
|
@@ -1561,74 +1561,74 @@ var require_dataType = __commonJS({
|
|
|
1561
1561
|
reportTypeError(it);
|
|
1562
1562
|
gen.endIf();
|
|
1563
1563
|
gen.if((0, codegen_1._)`${coerced} !== undefined`, () => {
|
|
1564
|
-
gen.assign(
|
|
1564
|
+
gen.assign(data2, coerced);
|
|
1565
1565
|
assignParentData(it, coerced);
|
|
1566
1566
|
});
|
|
1567
1567
|
function coerceSpecificType(t) {
|
|
1568
1568
|
switch (t) {
|
|
1569
1569
|
case "string":
|
|
1570
|
-
gen.elseIf((0, codegen_1._)`${dataType} == "number" || ${dataType} == "boolean"`).assign(coerced, (0, codegen_1._)`"" + ${
|
|
1570
|
+
gen.elseIf((0, codegen_1._)`${dataType} == "number" || ${dataType} == "boolean"`).assign(coerced, (0, codegen_1._)`"" + ${data2}`).elseIf((0, codegen_1._)`${data2} === null`).assign(coerced, (0, codegen_1._)`""`);
|
|
1571
1571
|
return;
|
|
1572
1572
|
case "number":
|
|
1573
|
-
gen.elseIf((0, codegen_1._)`${dataType} == "boolean" || ${
|
|
1574
|
-
|| (${dataType} == "string" && ${
|
|
1573
|
+
gen.elseIf((0, codegen_1._)`${dataType} == "boolean" || ${data2} === null
|
|
1574
|
+
|| (${dataType} == "string" && ${data2} && ${data2} == +${data2})`).assign(coerced, (0, codegen_1._)`+${data2}`);
|
|
1575
1575
|
return;
|
|
1576
1576
|
case "integer":
|
|
1577
|
-
gen.elseIf((0, codegen_1._)`${dataType} === "boolean" || ${
|
|
1578
|
-
|| (${dataType} === "string" && ${
|
|
1577
|
+
gen.elseIf((0, codegen_1._)`${dataType} === "boolean" || ${data2} === null
|
|
1578
|
+
|| (${dataType} === "string" && ${data2} && ${data2} == +${data2} && !(${data2} % 1))`).assign(coerced, (0, codegen_1._)`+${data2}`);
|
|
1579
1579
|
return;
|
|
1580
1580
|
case "boolean":
|
|
1581
|
-
gen.elseIf((0, codegen_1._)`${
|
|
1581
|
+
gen.elseIf((0, codegen_1._)`${data2} === "false" || ${data2} === 0 || ${data2} === null`).assign(coerced, false).elseIf((0, codegen_1._)`${data2} === "true" || ${data2} === 1`).assign(coerced, true);
|
|
1582
1582
|
return;
|
|
1583
1583
|
case "null":
|
|
1584
|
-
gen.elseIf((0, codegen_1._)`${
|
|
1584
|
+
gen.elseIf((0, codegen_1._)`${data2} === "" || ${data2} === 0 || ${data2} === false`);
|
|
1585
1585
|
gen.assign(coerced, null);
|
|
1586
1586
|
return;
|
|
1587
1587
|
case "array":
|
|
1588
1588
|
gen.elseIf((0, codegen_1._)`${dataType} === "string" || ${dataType} === "number"
|
|
1589
|
-
|| ${dataType} === "boolean" || ${
|
|
1589
|
+
|| ${dataType} === "boolean" || ${data2} === null`).assign(coerced, (0, codegen_1._)`[${data2}]`);
|
|
1590
1590
|
}
|
|
1591
1591
|
}
|
|
1592
1592
|
}
|
|
1593
1593
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
1594
1594
|
gen.if((0, codegen_1._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1._)`${parentData}[${parentDataProperty}]`, expr));
|
|
1595
1595
|
}
|
|
1596
|
-
function checkDataType(dataType,
|
|
1596
|
+
function checkDataType(dataType, data2, strictNums, correct = DataType.Correct) {
|
|
1597
1597
|
const EQ = correct === DataType.Correct ? codegen_1.operators.EQ : codegen_1.operators.NEQ;
|
|
1598
1598
|
let cond;
|
|
1599
1599
|
switch (dataType) {
|
|
1600
1600
|
case "null":
|
|
1601
|
-
return (0, codegen_1._)`${
|
|
1601
|
+
return (0, codegen_1._)`${data2} ${EQ} null`;
|
|
1602
1602
|
case "array":
|
|
1603
|
-
cond = (0, codegen_1._)`Array.isArray(${
|
|
1603
|
+
cond = (0, codegen_1._)`Array.isArray(${data2})`;
|
|
1604
1604
|
break;
|
|
1605
1605
|
case "object":
|
|
1606
|
-
cond = (0, codegen_1._)`${
|
|
1606
|
+
cond = (0, codegen_1._)`${data2} && typeof ${data2} == "object" && !Array.isArray(${data2})`;
|
|
1607
1607
|
break;
|
|
1608
1608
|
case "integer":
|
|
1609
|
-
cond = numCond((0, codegen_1._)`!(${
|
|
1609
|
+
cond = numCond((0, codegen_1._)`!(${data2} % 1) && !isNaN(${data2})`);
|
|
1610
1610
|
break;
|
|
1611
1611
|
case "number":
|
|
1612
1612
|
cond = numCond();
|
|
1613
1613
|
break;
|
|
1614
1614
|
default:
|
|
1615
|
-
return (0, codegen_1._)`typeof ${
|
|
1615
|
+
return (0, codegen_1._)`typeof ${data2} ${EQ} ${dataType}`;
|
|
1616
1616
|
}
|
|
1617
1617
|
return correct === DataType.Correct ? cond : (0, codegen_1.not)(cond);
|
|
1618
1618
|
function numCond(_cond = codegen_1.nil) {
|
|
1619
|
-
return (0, codegen_1.and)((0, codegen_1._)`typeof ${
|
|
1619
|
+
return (0, codegen_1.and)((0, codegen_1._)`typeof ${data2} == "number"`, _cond, strictNums ? (0, codegen_1._)`isFinite(${data2})` : codegen_1.nil);
|
|
1620
1620
|
}
|
|
1621
1621
|
}
|
|
1622
1622
|
exports.checkDataType = checkDataType;
|
|
1623
|
-
function checkDataTypes(dataTypes,
|
|
1623
|
+
function checkDataTypes(dataTypes, data2, strictNums, correct) {
|
|
1624
1624
|
if (dataTypes.length === 1) {
|
|
1625
|
-
return checkDataType(dataTypes[0],
|
|
1625
|
+
return checkDataType(dataTypes[0], data2, strictNums, correct);
|
|
1626
1626
|
}
|
|
1627
1627
|
let cond;
|
|
1628
1628
|
const types = (0, util_1.toHash)(dataTypes);
|
|
1629
1629
|
if (types.array && types.object) {
|
|
1630
|
-
const notObj = (0, codegen_1._)`typeof ${
|
|
1631
|
-
cond = types.null ? notObj : (0, codegen_1._)`!${
|
|
1630
|
+
const notObj = (0, codegen_1._)`typeof ${data2} != "object"`;
|
|
1631
|
+
cond = types.null ? notObj : (0, codegen_1._)`!${data2} || ${notObj}`;
|
|
1632
1632
|
delete types.null;
|
|
1633
1633
|
delete types.array;
|
|
1634
1634
|
delete types.object;
|
|
@@ -1638,7 +1638,7 @@ var require_dataType = __commonJS({
|
|
|
1638
1638
|
if (types.number)
|
|
1639
1639
|
delete types.integer;
|
|
1640
1640
|
for (const t in types)
|
|
1641
|
-
cond = (0, codegen_1.and)(cond, checkDataType(t,
|
|
1641
|
+
cond = (0, codegen_1.and)(cond, checkDataType(t, data2, strictNums, correct));
|
|
1642
1642
|
return cond;
|
|
1643
1643
|
}
|
|
1644
1644
|
exports.checkDataTypes = checkDataTypes;
|
|
@@ -1652,12 +1652,12 @@ var require_dataType = __commonJS({
|
|
|
1652
1652
|
}
|
|
1653
1653
|
exports.reportTypeError = reportTypeError;
|
|
1654
1654
|
function getTypeErrorContext(it) {
|
|
1655
|
-
const { gen, data, schema } = it;
|
|
1655
|
+
const { gen, data: data2, schema } = it;
|
|
1656
1656
|
const schemaCode = (0, util_1.schemaRefOrVal)(it, schema, "type");
|
|
1657
1657
|
return {
|
|
1658
1658
|
gen,
|
|
1659
1659
|
keyword: "type",
|
|
1660
|
-
data,
|
|
1660
|
+
data: data2,
|
|
1661
1661
|
schema: schema.type,
|
|
1662
1662
|
schemaCode,
|
|
1663
1663
|
schemaValue: schemaCode,
|
|
@@ -1689,10 +1689,10 @@ var require_defaults = __commonJS({
|
|
|
1689
1689
|
}
|
|
1690
1690
|
exports.assignDefaults = assignDefaults;
|
|
1691
1691
|
function assignDefault(it, prop, defaultValue) {
|
|
1692
|
-
const { gen, compositeRule, data, opts } = it;
|
|
1692
|
+
const { gen, compositeRule, data: data2, opts } = it;
|
|
1693
1693
|
if (defaultValue === void 0)
|
|
1694
1694
|
return;
|
|
1695
|
-
const childData = (0, codegen_1._)`${
|
|
1695
|
+
const childData = (0, codegen_1._)`${data2}${(0, codegen_1.getProperty)(prop)}`;
|
|
1696
1696
|
if (compositeRule) {
|
|
1697
1697
|
(0, util_1.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
1698
1698
|
return;
|
|
@@ -1717,19 +1717,19 @@ var require_code2 = __commonJS({
|
|
|
1717
1717
|
var names_1 = require_names();
|
|
1718
1718
|
var util_2 = require_util();
|
|
1719
1719
|
function checkReportMissingProp(cxt, prop) {
|
|
1720
|
-
const { gen, data, it } = cxt;
|
|
1721
|
-
gen.if(noPropertyInData(gen,
|
|
1720
|
+
const { gen, data: data2, it } = cxt;
|
|
1721
|
+
gen.if(noPropertyInData(gen, data2, prop, it.opts.ownProperties), () => {
|
|
1722
1722
|
cxt.setParams({ missingProperty: (0, codegen_1._)`${prop}` }, true);
|
|
1723
1723
|
cxt.error();
|
|
1724
1724
|
});
|
|
1725
1725
|
}
|
|
1726
1726
|
exports.checkReportMissingProp = checkReportMissingProp;
|
|
1727
|
-
function checkMissingProp({ gen, data, it: { opts } }, properties,
|
|
1728
|
-
return (0, codegen_1.or)(...properties.map((prop) => (0, codegen_1.and)(noPropertyInData(gen,
|
|
1727
|
+
function checkMissingProp({ gen, data: data2, it: { opts } }, properties, missing2) {
|
|
1728
|
+
return (0, codegen_1.or)(...properties.map((prop) => (0, codegen_1.and)(noPropertyInData(gen, data2, prop, opts.ownProperties), (0, codegen_1._)`${missing2} = ${prop}`)));
|
|
1729
1729
|
}
|
|
1730
1730
|
exports.checkMissingProp = checkMissingProp;
|
|
1731
|
-
function reportMissingProp(cxt,
|
|
1732
|
-
cxt.setParams({ missingProperty:
|
|
1731
|
+
function reportMissingProp(cxt, missing2) {
|
|
1732
|
+
cxt.setParams({ missingProperty: missing2 }, true);
|
|
1733
1733
|
cxt.error();
|
|
1734
1734
|
}
|
|
1735
1735
|
exports.reportMissingProp = reportMissingProp;
|
|
@@ -1741,18 +1741,18 @@ var require_code2 = __commonJS({
|
|
|
1741
1741
|
});
|
|
1742
1742
|
}
|
|
1743
1743
|
exports.hasPropFunc = hasPropFunc;
|
|
1744
|
-
function isOwnProperty(gen,
|
|
1745
|
-
return (0, codegen_1._)`${hasPropFunc(gen)}.call(${
|
|
1744
|
+
function isOwnProperty(gen, data2, property) {
|
|
1745
|
+
return (0, codegen_1._)`${hasPropFunc(gen)}.call(${data2}, ${property})`;
|
|
1746
1746
|
}
|
|
1747
1747
|
exports.isOwnProperty = isOwnProperty;
|
|
1748
|
-
function propertyInData(gen,
|
|
1749
|
-
const cond = (0, codegen_1._)`${
|
|
1750
|
-
return ownProperties ? (0, codegen_1._)`${cond} && ${isOwnProperty(gen,
|
|
1748
|
+
function propertyInData(gen, data2, property, ownProperties) {
|
|
1749
|
+
const cond = (0, codegen_1._)`${data2}${(0, codegen_1.getProperty)(property)} !== undefined`;
|
|
1750
|
+
return ownProperties ? (0, codegen_1._)`${cond} && ${isOwnProperty(gen, data2, property)}` : cond;
|
|
1751
1751
|
}
|
|
1752
1752
|
exports.propertyInData = propertyInData;
|
|
1753
|
-
function noPropertyInData(gen,
|
|
1754
|
-
const cond = (0, codegen_1._)`${
|
|
1755
|
-
return ownProperties ? (0, codegen_1.or)(cond, (0, codegen_1.not)(isOwnProperty(gen,
|
|
1753
|
+
function noPropertyInData(gen, data2, property, ownProperties) {
|
|
1754
|
+
const cond = (0, codegen_1._)`${data2}${(0, codegen_1.getProperty)(property)} === undefined`;
|
|
1755
|
+
return ownProperties ? (0, codegen_1.or)(cond, (0, codegen_1.not)(isOwnProperty(gen, data2, property))) : cond;
|
|
1756
1756
|
}
|
|
1757
1757
|
exports.noPropertyInData = noPropertyInData;
|
|
1758
1758
|
function allSchemaProperties(schemaMap) {
|
|
@@ -1763,8 +1763,8 @@ var require_code2 = __commonJS({
|
|
|
1763
1763
|
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p]));
|
|
1764
1764
|
}
|
|
1765
1765
|
exports.schemaProperties = schemaProperties;
|
|
1766
|
-
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
1767
|
-
const dataAndSchema = passSchema ? (0, codegen_1._)`${schemaCode}, ${
|
|
1766
|
+
function callValidateCode({ schemaCode, data: data2, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
1767
|
+
const dataAndSchema = passSchema ? (0, codegen_1._)`${schemaCode}, ${data2}, ${topSchemaRef}${schemaPath}` : data2;
|
|
1768
1768
|
const valCxt = [
|
|
1769
1769
|
[names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, errorPath)],
|
|
1770
1770
|
[names_1.default.parentData, it.parentData],
|
|
@@ -1790,7 +1790,7 @@ var require_code2 = __commonJS({
|
|
|
1790
1790
|
}
|
|
1791
1791
|
exports.usePattern = usePattern;
|
|
1792
1792
|
function validateArray(cxt) {
|
|
1793
|
-
const { gen, data, keyword, it } = cxt;
|
|
1793
|
+
const { gen, data: data2, keyword, it } = cxt;
|
|
1794
1794
|
const valid = gen.name("valid");
|
|
1795
1795
|
if (it.allErrors) {
|
|
1796
1796
|
const validArr = gen.let("valid", true);
|
|
@@ -1801,7 +1801,7 @@ var require_code2 = __commonJS({
|
|
|
1801
1801
|
validateItems(() => gen.break());
|
|
1802
1802
|
return valid;
|
|
1803
1803
|
function validateItems(notValid) {
|
|
1804
|
-
const len = gen.const("len", (0, codegen_1._)`${
|
|
1804
|
+
const len = gen.const("len", (0, codegen_1._)`${data2}.length`);
|
|
1805
1805
|
gen.forRange("i", 0, len, (i2) => {
|
|
1806
1806
|
cxt.subschema({
|
|
1807
1807
|
keyword,
|
|
@@ -1911,8 +1911,8 @@ var require_keyword = __commonJS({
|
|
|
1911
1911
|
}
|
|
1912
1912
|
exports.funcKeywordCode = funcKeywordCode;
|
|
1913
1913
|
function modifyData(cxt) {
|
|
1914
|
-
const { gen, data, it } = cxt;
|
|
1915
|
-
gen.if(it.parentData, () => gen.assign(
|
|
1914
|
+
const { gen, data: data2, it } = cxt;
|
|
1915
|
+
gen.if(it.parentData, () => gen.assign(data2, (0, codegen_1._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
1916
1916
|
}
|
|
1917
1917
|
function addErrs(cxt, errs) {
|
|
1918
1918
|
const { gen } = cxt;
|
|
@@ -1995,8 +1995,8 @@ var require_subschema = __commonJS({
|
|
|
1995
1995
|
throw new Error('either "keyword" or "schema" must be passed');
|
|
1996
1996
|
}
|
|
1997
1997
|
exports.getSubschema = getSubschema;
|
|
1998
|
-
function extendSubschemaData(subschema, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
|
|
1999
|
-
if (
|
|
1998
|
+
function extendSubschemaData(subschema, it, { dataProp, dataPropType: dpType, data: data2, dataTypes, propertyName }) {
|
|
1999
|
+
if (data2 !== void 0 && dataProp !== void 0) {
|
|
2000
2000
|
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
2001
2001
|
}
|
|
2002
2002
|
const { gen } = it;
|
|
@@ -2008,8 +2008,8 @@ var require_subschema = __commonJS({
|
|
|
2008
2008
|
subschema.parentDataProperty = (0, codegen_1._)`${dataProp}`;
|
|
2009
2009
|
subschema.dataPathArr = [...dataPathArr, subschema.parentDataProperty];
|
|
2010
2010
|
}
|
|
2011
|
-
if (
|
|
2012
|
-
const nextData =
|
|
2011
|
+
if (data2 !== void 0) {
|
|
2012
|
+
const nextData = data2 instanceof codegen_1.Name ? data2 : gen.let("data", data2, true);
|
|
2013
2013
|
dataContextProps(nextData);
|
|
2014
2014
|
if (propertyName !== void 0)
|
|
2015
2015
|
subschema.propertyName = propertyName;
|
|
@@ -2495,7 +2495,7 @@ var require_validate = __commonJS({
|
|
|
2495
2495
|
gen.assign((0, codegen_1._)`${evaluated}.items`, items);
|
|
2496
2496
|
}
|
|
2497
2497
|
function schemaKeywords(it, types, typeErrors, errsCount) {
|
|
2498
|
-
const { gen, schema, data, allErrors, opts, self } = it;
|
|
2498
|
+
const { gen, schema, data: data2, allErrors, opts, self } = it;
|
|
2499
2499
|
const { RULES: RULES2 } = self;
|
|
2500
2500
|
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES2))) {
|
|
2501
2501
|
gen.block(() => keywordCode(it, "$ref", RULES2.all.$ref.definition));
|
|
@@ -2512,7 +2512,7 @@ var require_validate = __commonJS({
|
|
|
2512
2512
|
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
2513
2513
|
return;
|
|
2514
2514
|
if (group.type) {
|
|
2515
|
-
gen.if((0, dataType_2.checkDataType)(group.type,
|
|
2515
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data2, opts.strictNumbers));
|
|
2516
2516
|
iterateKeywords(it, group);
|
|
2517
2517
|
if (types.length === 1 && types[0] === group.type && typeErrors) {
|
|
2518
2518
|
gen.else();
|
|
@@ -2785,14 +2785,14 @@ var require_validate = __commonJS({
|
|
|
2785
2785
|
var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
2786
2786
|
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
2787
2787
|
let jsonPointer;
|
|
2788
|
-
let
|
|
2788
|
+
let data2;
|
|
2789
2789
|
if ($data === "")
|
|
2790
2790
|
return names_1.default.rootData;
|
|
2791
2791
|
if ($data[0] === "/") {
|
|
2792
2792
|
if (!JSON_POINTER.test($data))
|
|
2793
2793
|
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
2794
2794
|
jsonPointer = $data;
|
|
2795
|
-
|
|
2795
|
+
data2 = names_1.default.rootData;
|
|
2796
2796
|
} else {
|
|
2797
2797
|
const matches2 = RELATIVE_JSON_POINTER.exec($data);
|
|
2798
2798
|
if (!matches2)
|
|
@@ -2806,16 +2806,16 @@ var require_validate = __commonJS({
|
|
|
2806
2806
|
}
|
|
2807
2807
|
if (up > dataLevel)
|
|
2808
2808
|
throw new Error(errorMsg("data", up));
|
|
2809
|
-
|
|
2809
|
+
data2 = dataNames[dataLevel - up];
|
|
2810
2810
|
if (!jsonPointer)
|
|
2811
|
-
return
|
|
2811
|
+
return data2;
|
|
2812
2812
|
}
|
|
2813
|
-
let expr =
|
|
2813
|
+
let expr = data2;
|
|
2814
2814
|
const segments = jsonPointer.split("/");
|
|
2815
2815
|
for (const segment of segments) {
|
|
2816
2816
|
if (segment) {
|
|
2817
|
-
|
|
2818
|
-
expr = (0, codegen_1._)`${expr} && ${
|
|
2817
|
+
data2 = (0, codegen_1._)`${data2}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`;
|
|
2818
|
+
expr = (0, codegen_1._)`${expr} && ${data2}`;
|
|
2819
2819
|
}
|
|
2820
2820
|
}
|
|
2821
2821
|
return expr;
|
|
@@ -3256,11 +3256,11 @@ var require_utils = __commonJS({
|
|
|
3256
3256
|
};
|
|
3257
3257
|
}
|
|
3258
3258
|
function findToken(str, token) {
|
|
3259
|
-
let
|
|
3259
|
+
let ind2 = 0;
|
|
3260
3260
|
for (let i2 = 0; i2 < str.length; i2++) {
|
|
3261
|
-
if (str[i2] === token)
|
|
3261
|
+
if (str[i2] === token) ind2++;
|
|
3262
3262
|
}
|
|
3263
|
-
return
|
|
3263
|
+
return ind2;
|
|
3264
3264
|
}
|
|
3265
3265
|
function removeDotSegments(path) {
|
|
3266
3266
|
let input2 = path;
|
|
@@ -4444,7 +4444,7 @@ var require_core = __commonJS({
|
|
|
4444
4444
|
const { meta: meta3, schemaId } = this.opts;
|
|
4445
4445
|
return this.opts.defaultMeta = typeof meta3 == "object" ? meta3[schemaId] || meta3 : void 0;
|
|
4446
4446
|
}
|
|
4447
|
-
validate(schemaKeyRef,
|
|
4447
|
+
validate(schemaKeyRef, data2) {
|
|
4448
4448
|
let v;
|
|
4449
4449
|
if (typeof schemaKeyRef == "string") {
|
|
4450
4450
|
v = this.getSchema(schemaKeyRef);
|
|
@@ -4453,7 +4453,7 @@ var require_core = __commonJS({
|
|
|
4453
4453
|
} else {
|
|
4454
4454
|
v = this.compile(schemaKeyRef);
|
|
4455
4455
|
}
|
|
4456
|
-
const valid = v(
|
|
4456
|
+
const valid = v(data2);
|
|
4457
4457
|
if (!("$async" in v))
|
|
4458
4458
|
this.errors = v.errors;
|
|
4459
4459
|
return valid;
|
|
@@ -5082,8 +5082,8 @@ var require_limitNumber = __commonJS({
|
|
|
5082
5082
|
$data: true,
|
|
5083
5083
|
error: error62,
|
|
5084
5084
|
code(cxt) {
|
|
5085
|
-
const { keyword, data, schemaCode } = cxt;
|
|
5086
|
-
cxt.fail$data((0, codegen_1._)`${
|
|
5085
|
+
const { keyword, data: data2, schemaCode } = cxt;
|
|
5086
|
+
cxt.fail$data((0, codegen_1._)`${data2} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data2})`);
|
|
5087
5087
|
}
|
|
5088
5088
|
};
|
|
5089
5089
|
exports.default = def;
|
|
@@ -5107,11 +5107,11 @@ var require_multipleOf = __commonJS({
|
|
|
5107
5107
|
$data: true,
|
|
5108
5108
|
error: error62,
|
|
5109
5109
|
code(cxt) {
|
|
5110
|
-
const { gen, data, schemaCode, it } = cxt;
|
|
5110
|
+
const { gen, data: data2, schemaCode, it } = cxt;
|
|
5111
5111
|
const prec = it.opts.multipleOfPrecision;
|
|
5112
5112
|
const res = gen.let("res");
|
|
5113
5113
|
const invalid = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
|
|
5114
|
-
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${
|
|
5114
|
+
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data2}/${schemaCode}, ${invalid}))`);
|
|
5115
5115
|
}
|
|
5116
5116
|
};
|
|
5117
5117
|
exports.default = def;
|
|
@@ -5166,9 +5166,9 @@ var require_limitLength = __commonJS({
|
|
|
5166
5166
|
$data: true,
|
|
5167
5167
|
error: error62,
|
|
5168
5168
|
code(cxt) {
|
|
5169
|
-
const { keyword, data, schemaCode, it } = cxt;
|
|
5169
|
+
const { keyword, data: data2, schemaCode, it } = cxt;
|
|
5170
5170
|
const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
5171
|
-
const len = it.opts.unicode === false ? (0, codegen_1._)`${
|
|
5171
|
+
const len = it.opts.unicode === false ? (0, codegen_1._)`${data2}.length` : (0, codegen_1._)`${(0, util_1.useFunc)(cxt.gen, ucs2length_1.default)}(${data2})`;
|
|
5172
5172
|
cxt.fail$data((0, codegen_1._)`${len} ${op} ${schemaCode}`);
|
|
5173
5173
|
}
|
|
5174
5174
|
};
|
|
@@ -5195,17 +5195,17 @@ var require_pattern = __commonJS({
|
|
|
5195
5195
|
$data: true,
|
|
5196
5196
|
error: error62,
|
|
5197
5197
|
code(cxt) {
|
|
5198
|
-
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
5198
|
+
const { gen, data: data2, $data, schema, schemaCode, it } = cxt;
|
|
5199
5199
|
const u = it.opts.unicodeRegExp ? "u" : "";
|
|
5200
5200
|
if ($data) {
|
|
5201
5201
|
const { regExp } = it.opts.code;
|
|
5202
5202
|
const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
|
|
5203
5203
|
const valid = gen.let("valid");
|
|
5204
|
-
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${
|
|
5204
|
+
gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data2})`), () => gen.assign(valid, false));
|
|
5205
5205
|
cxt.fail$data((0, codegen_1._)`!${valid}`);
|
|
5206
5206
|
} else {
|
|
5207
5207
|
const regExp = (0, code_1.usePattern)(cxt, schema);
|
|
5208
|
-
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${
|
|
5208
|
+
cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data2})`);
|
|
5209
5209
|
}
|
|
5210
5210
|
}
|
|
5211
5211
|
};
|
|
@@ -5233,9 +5233,9 @@ var require_limitProperties = __commonJS({
|
|
|
5233
5233
|
$data: true,
|
|
5234
5234
|
error: error62,
|
|
5235
5235
|
code(cxt) {
|
|
5236
|
-
const { keyword, data, schemaCode } = cxt;
|
|
5236
|
+
const { keyword, data: data2, schemaCode } = cxt;
|
|
5237
5237
|
const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
5238
|
-
cxt.fail$data((0, codegen_1._)`Object.keys(${
|
|
5238
|
+
cxt.fail$data((0, codegen_1._)`Object.keys(${data2}).length ${op} ${schemaCode}`);
|
|
5239
5239
|
}
|
|
5240
5240
|
};
|
|
5241
5241
|
exports.default = def;
|
|
@@ -5261,7 +5261,7 @@ var require_required = __commonJS({
|
|
|
5261
5261
|
$data: true,
|
|
5262
5262
|
error: error62,
|
|
5263
5263
|
code(cxt) {
|
|
5264
|
-
const { gen, schema, schemaCode, data, $data, it } = cxt;
|
|
5264
|
+
const { gen, schema, schemaCode, data: data2, $data, it } = cxt;
|
|
5265
5265
|
const { opts } = it;
|
|
5266
5266
|
if (!$data && schema.length === 0)
|
|
5267
5267
|
return;
|
|
@@ -5291,27 +5291,27 @@ var require_required = __commonJS({
|
|
|
5291
5291
|
}
|
|
5292
5292
|
}
|
|
5293
5293
|
function exitOnErrorMode() {
|
|
5294
|
-
const
|
|
5294
|
+
const missing2 = gen.let("missing");
|
|
5295
5295
|
if (useLoop || $data) {
|
|
5296
5296
|
const valid = gen.let("valid", true);
|
|
5297
|
-
cxt.block$data(valid, () => loopUntilMissing(
|
|
5297
|
+
cxt.block$data(valid, () => loopUntilMissing(missing2, valid));
|
|
5298
5298
|
cxt.ok(valid);
|
|
5299
5299
|
} else {
|
|
5300
|
-
gen.if((0, code_1.checkMissingProp)(cxt, schema,
|
|
5301
|
-
(0, code_1.reportMissingProp)(cxt,
|
|
5300
|
+
gen.if((0, code_1.checkMissingProp)(cxt, schema, missing2));
|
|
5301
|
+
(0, code_1.reportMissingProp)(cxt, missing2);
|
|
5302
5302
|
gen.else();
|
|
5303
5303
|
}
|
|
5304
5304
|
}
|
|
5305
5305
|
function loopAllRequired() {
|
|
5306
5306
|
gen.forOf("prop", schemaCode, (prop) => {
|
|
5307
5307
|
cxt.setParams({ missingProperty: prop });
|
|
5308
|
-
gen.if((0, code_1.noPropertyInData)(gen,
|
|
5308
|
+
gen.if((0, code_1.noPropertyInData)(gen, data2, prop, opts.ownProperties), () => cxt.error());
|
|
5309
5309
|
});
|
|
5310
5310
|
}
|
|
5311
|
-
function loopUntilMissing(
|
|
5312
|
-
cxt.setParams({ missingProperty:
|
|
5313
|
-
gen.forOf(
|
|
5314
|
-
gen.assign(valid, (0, code_1.propertyInData)(gen,
|
|
5311
|
+
function loopUntilMissing(missing2, valid) {
|
|
5312
|
+
cxt.setParams({ missingProperty: missing2 });
|
|
5313
|
+
gen.forOf(missing2, schemaCode, () => {
|
|
5314
|
+
gen.assign(valid, (0, code_1.propertyInData)(gen, data2, missing2, opts.ownProperties));
|
|
5315
5315
|
gen.if((0, codegen_1.not)(valid), () => {
|
|
5316
5316
|
cxt.error();
|
|
5317
5317
|
gen.break();
|
|
@@ -5344,9 +5344,9 @@ var require_limitItems = __commonJS({
|
|
|
5344
5344
|
$data: true,
|
|
5345
5345
|
error: error62,
|
|
5346
5346
|
code(cxt) {
|
|
5347
|
-
const { keyword, data, schemaCode } = cxt;
|
|
5347
|
+
const { keyword, data: data2, schemaCode } = cxt;
|
|
5348
5348
|
const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
|
|
5349
|
-
cxt.fail$data((0, codegen_1._)`${
|
|
5349
|
+
cxt.fail$data((0, codegen_1._)`${data2}.length ${op} ${schemaCode}`);
|
|
5350
5350
|
}
|
|
5351
5351
|
};
|
|
5352
5352
|
exports.default = def;
|
|
@@ -5384,7 +5384,7 @@ var require_uniqueItems = __commonJS({
|
|
|
5384
5384
|
$data: true,
|
|
5385
5385
|
error: error62,
|
|
5386
5386
|
code(cxt) {
|
|
5387
|
-
const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt;
|
|
5387
|
+
const { gen, data: data2, $data, schema, parentSchema, schemaCode, it } = cxt;
|
|
5388
5388
|
if (!$data && !schema)
|
|
5389
5389
|
return;
|
|
5390
5390
|
const valid = gen.let("valid");
|
|
@@ -5392,7 +5392,7 @@ var require_uniqueItems = __commonJS({
|
|
|
5392
5392
|
cxt.block$data(valid, validateUniqueItems, (0, codegen_1._)`${schemaCode} === false`);
|
|
5393
5393
|
cxt.ok(valid);
|
|
5394
5394
|
function validateUniqueItems() {
|
|
5395
|
-
const i2 = gen.let("i", (0, codegen_1._)`${
|
|
5395
|
+
const i2 = gen.let("i", (0, codegen_1._)`${data2}.length`);
|
|
5396
5396
|
const j = gen.let("j");
|
|
5397
5397
|
cxt.setParams({ i: i2, j });
|
|
5398
5398
|
gen.assign(valid, true);
|
|
@@ -5406,7 +5406,7 @@ var require_uniqueItems = __commonJS({
|
|
|
5406
5406
|
const wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong);
|
|
5407
5407
|
const indices = gen.const("indices", (0, codegen_1._)`{}`);
|
|
5408
5408
|
gen.for((0, codegen_1._)`;${i2}--;`, () => {
|
|
5409
|
-
gen.let(item, (0, codegen_1._)`${
|
|
5409
|
+
gen.let(item, (0, codegen_1._)`${data2}[${i2}]`);
|
|
5410
5410
|
gen.if(wrongType, (0, codegen_1._)`continue`);
|
|
5411
5411
|
if (itemTypes.length > 1)
|
|
5412
5412
|
gen.if((0, codegen_1._)`typeof ${item} == "string"`, (0, codegen_1._)`${item} += "_"`);
|
|
@@ -5420,7 +5420,7 @@ var require_uniqueItems = __commonJS({
|
|
|
5420
5420
|
function loopN2(i2, j) {
|
|
5421
5421
|
const eql = (0, util_1.useFunc)(gen, equal_1.default);
|
|
5422
5422
|
const outer = gen.name("outer");
|
|
5423
|
-
gen.label(outer).for((0, codegen_1._)`;${i2}--;`, () => gen.for((0, codegen_1._)`${j} = ${i2}; ${j}--;`, () => gen.if((0, codegen_1._)`${eql}(${
|
|
5423
|
+
gen.label(outer).for((0, codegen_1._)`;${i2}--;`, () => gen.for((0, codegen_1._)`${j} = ${i2}; ${j}--;`, () => gen.if((0, codegen_1._)`${eql}(${data2}[${i2}], ${data2}[${j}])`, () => {
|
|
5424
5424
|
cxt.error();
|
|
5425
5425
|
gen.assign(valid, false).break(outer);
|
|
5426
5426
|
})));
|
|
@@ -5448,11 +5448,11 @@ var require_const = __commonJS({
|
|
|
5448
5448
|
$data: true,
|
|
5449
5449
|
error: error62,
|
|
5450
5450
|
code(cxt) {
|
|
5451
|
-
const { gen, data, $data, schemaCode, schema } = cxt;
|
|
5451
|
+
const { gen, data: data2, $data, schemaCode, schema } = cxt;
|
|
5452
5452
|
if ($data || schema && typeof schema == "object") {
|
|
5453
|
-
cxt.fail$data((0, codegen_1._)`!${(0, util_1.useFunc)(gen, equal_1.default)}(${
|
|
5453
|
+
cxt.fail$data((0, codegen_1._)`!${(0, util_1.useFunc)(gen, equal_1.default)}(${data2}, ${schemaCode})`);
|
|
5454
5454
|
} else {
|
|
5455
|
-
cxt.fail((0, codegen_1._)`${schema} !== ${
|
|
5455
|
+
cxt.fail((0, codegen_1._)`${schema} !== ${data2}`);
|
|
5456
5456
|
}
|
|
5457
5457
|
}
|
|
5458
5458
|
};
|
|
@@ -5478,7 +5478,7 @@ var require_enum = __commonJS({
|
|
|
5478
5478
|
$data: true,
|
|
5479
5479
|
error: error62,
|
|
5480
5480
|
code(cxt) {
|
|
5481
|
-
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
5481
|
+
const { gen, data: data2, $data, schema, schemaCode, it } = cxt;
|
|
5482
5482
|
if (!$data && schema.length === 0)
|
|
5483
5483
|
throw new Error("enum must have non-empty array");
|
|
5484
5484
|
const useLoop = schema.length >= it.opts.loopEnum;
|
|
@@ -5497,11 +5497,11 @@ var require_enum = __commonJS({
|
|
|
5497
5497
|
cxt.pass(valid);
|
|
5498
5498
|
function loopEnum() {
|
|
5499
5499
|
gen.assign(valid, false);
|
|
5500
|
-
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${
|
|
5500
|
+
gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${data2}, ${v})`, () => gen.assign(valid, true).break()));
|
|
5501
5501
|
}
|
|
5502
5502
|
function equalCode(vSchema, i2) {
|
|
5503
5503
|
const sch = schema[i2];
|
|
5504
|
-
return typeof sch === "object" && sch !== null ? (0, codegen_1._)`${getEql()}(${
|
|
5504
|
+
return typeof sch === "object" && sch !== null ? (0, codegen_1._)`${getEql()}(${data2}, ${vSchema}[${i2}])` : (0, codegen_1._)`${data2} === ${sch}`;
|
|
5505
5505
|
}
|
|
5506
5506
|
}
|
|
5507
5507
|
};
|
|
@@ -5576,9 +5576,9 @@ var require_additionalItems = __commonJS({
|
|
|
5576
5576
|
}
|
|
5577
5577
|
};
|
|
5578
5578
|
function validateAdditionalItems(cxt, items) {
|
|
5579
|
-
const { gen, schema, data, keyword, it } = cxt;
|
|
5579
|
+
const { gen, schema, data: data2, keyword, it } = cxt;
|
|
5580
5580
|
it.items = true;
|
|
5581
|
-
const len = gen.const("len", (0, codegen_1._)`${
|
|
5581
|
+
const len = gen.const("len", (0, codegen_1._)`${data2}.length`);
|
|
5582
5582
|
if (schema === false) {
|
|
5583
5583
|
cxt.setParams({ len: items.length });
|
|
5584
5584
|
cxt.pass((0, codegen_1._)`${len} <= ${items.length}`);
|
|
@@ -5625,13 +5625,13 @@ var require_items = __commonJS({
|
|
|
5625
5625
|
}
|
|
5626
5626
|
};
|
|
5627
5627
|
function validateTuple(cxt, extraItems, schArr = cxt.schema) {
|
|
5628
|
-
const { gen, parentSchema, data, keyword, it } = cxt;
|
|
5628
|
+
const { gen, parentSchema, data: data2, keyword, it } = cxt;
|
|
5629
5629
|
checkStrictTuple(parentSchema);
|
|
5630
5630
|
if (it.opts.unevaluated && schArr.length && it.items !== true) {
|
|
5631
5631
|
it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items);
|
|
5632
5632
|
}
|
|
5633
5633
|
const valid = gen.name("valid");
|
|
5634
|
-
const len = gen.const("len", (0, codegen_1._)`${
|
|
5634
|
+
const len = gen.const("len", (0, codegen_1._)`${data2}.length`);
|
|
5635
5635
|
schArr.forEach((sch, i2) => {
|
|
5636
5636
|
if ((0, util_1.alwaysValidSchema)(it, sch))
|
|
5637
5637
|
return;
|
|
@@ -5728,7 +5728,7 @@ var require_contains = __commonJS({
|
|
|
5728
5728
|
trackErrors: true,
|
|
5729
5729
|
error: error62,
|
|
5730
5730
|
code(cxt) {
|
|
5731
|
-
const { gen, schema, parentSchema, data, it } = cxt;
|
|
5731
|
+
const { gen, schema, parentSchema, data: data2, it } = cxt;
|
|
5732
5732
|
let min;
|
|
5733
5733
|
let max2;
|
|
5734
5734
|
const { minContains, maxContains } = parentSchema;
|
|
@@ -5738,7 +5738,7 @@ var require_contains = __commonJS({
|
|
|
5738
5738
|
} else {
|
|
5739
5739
|
min = 1;
|
|
5740
5740
|
}
|
|
5741
|
-
const len = gen.const("len", (0, codegen_1._)`${
|
|
5741
|
+
const len = gen.const("len", (0, codegen_1._)`${data2}.length`);
|
|
5742
5742
|
cxt.setParams({ min, max: max2 });
|
|
5743
5743
|
if (max2 === void 0 && min === 0) {
|
|
5744
5744
|
(0, util_1.checkStrictMode)(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`);
|
|
@@ -5763,7 +5763,7 @@ var require_contains = __commonJS({
|
|
|
5763
5763
|
} else if (min === 0) {
|
|
5764
5764
|
gen.let(valid, true);
|
|
5765
5765
|
if (max2 !== void 0)
|
|
5766
|
-
gen.if((0, codegen_1._)`${
|
|
5766
|
+
gen.if((0, codegen_1._)`${data2}.length > 0`, validateItemsWithCount);
|
|
5767
5767
|
} else {
|
|
5768
5768
|
gen.let(valid, false);
|
|
5769
5769
|
validateItemsWithCount();
|
|
@@ -5846,15 +5846,15 @@ var require_dependencies = __commonJS({
|
|
|
5846
5846
|
return [propertyDeps, schemaDeps];
|
|
5847
5847
|
}
|
|
5848
5848
|
function validatePropertyDeps(cxt, propertyDeps = cxt.schema) {
|
|
5849
|
-
const { gen, data, it } = cxt;
|
|
5849
|
+
const { gen, data: data2, it } = cxt;
|
|
5850
5850
|
if (Object.keys(propertyDeps).length === 0)
|
|
5851
5851
|
return;
|
|
5852
|
-
const
|
|
5852
|
+
const missing2 = gen.let("missing");
|
|
5853
5853
|
for (const prop in propertyDeps) {
|
|
5854
5854
|
const deps = propertyDeps[prop];
|
|
5855
5855
|
if (deps.length === 0)
|
|
5856
5856
|
continue;
|
|
5857
|
-
const hasProperty = (0, code_1.propertyInData)(gen,
|
|
5857
|
+
const hasProperty = (0, code_1.propertyInData)(gen, data2, prop, it.opts.ownProperties);
|
|
5858
5858
|
cxt.setParams({
|
|
5859
5859
|
property: prop,
|
|
5860
5860
|
depsCount: deps.length,
|
|
@@ -5867,21 +5867,21 @@ var require_dependencies = __commonJS({
|
|
|
5867
5867
|
}
|
|
5868
5868
|
});
|
|
5869
5869
|
} else {
|
|
5870
|
-
gen.if((0, codegen_1._)`${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps,
|
|
5871
|
-
(0, code_1.reportMissingProp)(cxt,
|
|
5870
|
+
gen.if((0, codegen_1._)`${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing2)})`);
|
|
5871
|
+
(0, code_1.reportMissingProp)(cxt, missing2);
|
|
5872
5872
|
gen.else();
|
|
5873
5873
|
}
|
|
5874
5874
|
}
|
|
5875
5875
|
}
|
|
5876
5876
|
exports.validatePropertyDeps = validatePropertyDeps;
|
|
5877
5877
|
function validateSchemaDeps(cxt, schemaDeps = cxt.schema) {
|
|
5878
|
-
const { gen, data, keyword, it } = cxt;
|
|
5878
|
+
const { gen, data: data2, keyword, it } = cxt;
|
|
5879
5879
|
const valid = gen.name("valid");
|
|
5880
5880
|
for (const prop in schemaDeps) {
|
|
5881
5881
|
if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop]))
|
|
5882
5882
|
continue;
|
|
5883
5883
|
gen.if(
|
|
5884
|
-
(0, code_1.propertyInData)(gen,
|
|
5884
|
+
(0, code_1.propertyInData)(gen, data2, prop, it.opts.ownProperties),
|
|
5885
5885
|
() => {
|
|
5886
5886
|
const schCxt = cxt.subschema({ keyword, schemaProp: prop }, valid);
|
|
5887
5887
|
cxt.mergeValidEvaluated(schCxt, valid);
|
|
@@ -5914,11 +5914,11 @@ var require_propertyNames = __commonJS({
|
|
|
5914
5914
|
schemaType: ["object", "boolean"],
|
|
5915
5915
|
error: error62,
|
|
5916
5916
|
code(cxt) {
|
|
5917
|
-
const { gen, schema, data, it } = cxt;
|
|
5917
|
+
const { gen, schema, data: data2, it } = cxt;
|
|
5918
5918
|
if ((0, util_1.alwaysValidSchema)(it, schema))
|
|
5919
5919
|
return;
|
|
5920
5920
|
const valid = gen.name("valid");
|
|
5921
|
-
gen.forIn("key",
|
|
5921
|
+
gen.forIn("key", data2, (key) => {
|
|
5922
5922
|
cxt.setParams({ propertyName: key });
|
|
5923
5923
|
cxt.subschema({
|
|
5924
5924
|
keyword: "propertyNames",
|
|
@@ -5961,7 +5961,7 @@ var require_additionalProperties = __commonJS({
|
|
|
5961
5961
|
trackErrors: true,
|
|
5962
5962
|
error: error62,
|
|
5963
5963
|
code(cxt) {
|
|
5964
|
-
const { gen, schema, parentSchema, data, errsCount, it } = cxt;
|
|
5964
|
+
const { gen, schema, parentSchema, data: data2, errsCount, it } = cxt;
|
|
5965
5965
|
if (!errsCount)
|
|
5966
5966
|
throw new Error("ajv implementation error");
|
|
5967
5967
|
const { allErrors, opts } = it;
|
|
@@ -5973,7 +5973,7 @@ var require_additionalProperties = __commonJS({
|
|
|
5973
5973
|
checkAdditionalProperties();
|
|
5974
5974
|
cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
|
|
5975
5975
|
function checkAdditionalProperties() {
|
|
5976
|
-
gen.forIn("key",
|
|
5976
|
+
gen.forIn("key", data2, (key) => {
|
|
5977
5977
|
if (!props.length && !patProps.length)
|
|
5978
5978
|
additionalPropertyCode(key);
|
|
5979
5979
|
else
|
|
@@ -5996,7 +5996,7 @@ var require_additionalProperties = __commonJS({
|
|
|
5996
5996
|
return (0, codegen_1.not)(definedProp);
|
|
5997
5997
|
}
|
|
5998
5998
|
function deleteAdditional(key) {
|
|
5999
|
-
gen.code((0, codegen_1._)`delete ${
|
|
5999
|
+
gen.code((0, codegen_1._)`delete ${data2}[${key}]`);
|
|
6000
6000
|
}
|
|
6001
6001
|
function additionalPropertyCode(key) {
|
|
6002
6002
|
if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
|
|
@@ -6060,7 +6060,7 @@ var require_properties = __commonJS({
|
|
|
6060
6060
|
type: "object",
|
|
6061
6061
|
schemaType: "object",
|
|
6062
6062
|
code(cxt) {
|
|
6063
|
-
const { gen, schema, parentSchema, data, it } = cxt;
|
|
6063
|
+
const { gen, schema, parentSchema, data: data2, it } = cxt;
|
|
6064
6064
|
if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === void 0) {
|
|
6065
6065
|
additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties"));
|
|
6066
6066
|
}
|
|
@@ -6079,7 +6079,7 @@ var require_properties = __commonJS({
|
|
|
6079
6079
|
if (hasDefault(prop)) {
|
|
6080
6080
|
applyPropertySchema(prop);
|
|
6081
6081
|
} else {
|
|
6082
|
-
gen.if((0, code_1.propertyInData)(gen,
|
|
6082
|
+
gen.if((0, code_1.propertyInData)(gen, data2, prop, it.opts.ownProperties));
|
|
6083
6083
|
applyPropertySchema(prop);
|
|
6084
6084
|
if (!it.allErrors)
|
|
6085
6085
|
gen.else().var(valid, true);
|
|
@@ -6118,7 +6118,7 @@ var require_patternProperties = __commonJS({
|
|
|
6118
6118
|
type: "object",
|
|
6119
6119
|
schemaType: "object",
|
|
6120
6120
|
code(cxt) {
|
|
6121
|
-
const { gen, schema, data, parentSchema, it } = cxt;
|
|
6121
|
+
const { gen, schema, data: data2, parentSchema, it } = cxt;
|
|
6122
6122
|
const { opts } = it;
|
|
6123
6123
|
const patterns = (0, code_1.allSchemaProperties)(schema);
|
|
6124
6124
|
const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p]));
|
|
@@ -6153,7 +6153,7 @@ var require_patternProperties = __commonJS({
|
|
|
6153
6153
|
}
|
|
6154
6154
|
}
|
|
6155
6155
|
function validateProperties(pat) {
|
|
6156
|
-
gen.forIn("key",
|
|
6156
|
+
gen.forIn("key", data2, (key) => {
|
|
6157
6157
|
gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key})`, () => {
|
|
6158
6158
|
const alwaysValid = alwaysValidPatterns.includes(pat);
|
|
6159
6159
|
if (!alwaysValid) {
|
|
@@ -6463,7 +6463,7 @@ var require_format = __commonJS({
|
|
|
6463
6463
|
$data: true,
|
|
6464
6464
|
error: error62,
|
|
6465
6465
|
code(cxt, ruleType) {
|
|
6466
|
-
const { gen, data, $data, schema, schemaCode, it } = cxt;
|
|
6466
|
+
const { gen, data: data2, $data, schema, schemaCode, it } = cxt;
|
|
6467
6467
|
const { opts, errSchemaPath, schemaEnv, self } = it;
|
|
6468
6468
|
if (!opts.validateFormats)
|
|
6469
6469
|
return;
|
|
@@ -6487,8 +6487,8 @@ var require_format = __commonJS({
|
|
|
6487
6487
|
return (0, codegen_1._)`${schemaCode} && !${format}`;
|
|
6488
6488
|
}
|
|
6489
6489
|
function invalidFmt() {
|
|
6490
|
-
const callFormat = schemaEnv.$async ? (0, codegen_1._)`(${fDef}.async ? await ${format}(${
|
|
6491
|
-
const validData = (0, codegen_1._)`(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${
|
|
6490
|
+
const callFormat = schemaEnv.$async ? (0, codegen_1._)`(${fDef}.async ? await ${format}(${data2}) : ${format}(${data2}))` : (0, codegen_1._)`${format}(${data2})`;
|
|
6491
|
+
const validData = (0, codegen_1._)`(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data2}))`;
|
|
6492
6492
|
return (0, codegen_1._)`${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`;
|
|
6493
6493
|
}
|
|
6494
6494
|
}
|
|
@@ -6525,9 +6525,9 @@ var require_format = __commonJS({
|
|
|
6525
6525
|
if (typeof formatDef == "object" && !(formatDef instanceof RegExp) && formatDef.async) {
|
|
6526
6526
|
if (!schemaEnv.$async)
|
|
6527
6527
|
throw new Error("async format in sync schema");
|
|
6528
|
-
return (0, codegen_1._)`await ${fmtRef}(${
|
|
6528
|
+
return (0, codegen_1._)`await ${fmtRef}(${data2})`;
|
|
6529
6529
|
}
|
|
6530
|
-
return typeof format == "function" ? (0, codegen_1._)`${fmtRef}(${
|
|
6530
|
+
return typeof format == "function" ? (0, codegen_1._)`${fmtRef}(${data2})` : (0, codegen_1._)`${fmtRef}.test(${data2})`;
|
|
6531
6531
|
}
|
|
6532
6532
|
}
|
|
6533
6533
|
}
|
|
@@ -6626,7 +6626,7 @@ var require_discriminator = __commonJS({
|
|
|
6626
6626
|
schemaType: "object",
|
|
6627
6627
|
error: error62,
|
|
6628
6628
|
code(cxt) {
|
|
6629
|
-
const { gen, data, schema, parentSchema, it } = cxt;
|
|
6629
|
+
const { gen, data: data2, schema, parentSchema, it } = cxt;
|
|
6630
6630
|
const { oneOf } = parentSchema;
|
|
6631
6631
|
if (!it.opts.discriminator) {
|
|
6632
6632
|
throw new Error("discriminator: requires discriminator option");
|
|
@@ -6639,7 +6639,7 @@ var require_discriminator = __commonJS({
|
|
|
6639
6639
|
if (!oneOf)
|
|
6640
6640
|
throw new Error("discriminator: requires oneOf keyword");
|
|
6641
6641
|
const valid = gen.let("valid", false);
|
|
6642
|
-
const tag = gen.const("tag", (0, codegen_1._)`${
|
|
6642
|
+
const tag = gen.const("tag", (0, codegen_1._)`${data2}${(0, codegen_1.getProperty)(tagName)}`);
|
|
6643
6643
|
gen.if((0, codegen_1._)`typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, { discrError: types_1.DiscrError.Tag, tag, tagName }));
|
|
6644
6644
|
cxt.ok(valid);
|
|
6645
6645
|
function validateMapping() {
|
|
@@ -7167,7 +7167,7 @@ var require_limit = __commonJS({
|
|
|
7167
7167
|
$data: true,
|
|
7168
7168
|
error: error62,
|
|
7169
7169
|
code(cxt) {
|
|
7170
|
-
const { gen, data, schemaCode, keyword, it } = cxt;
|
|
7170
|
+
const { gen, data: data2, schemaCode, keyword, it } = cxt;
|
|
7171
7171
|
const { opts, self } = it;
|
|
7172
7172
|
if (!opts.validateFormats)
|
|
7173
7173
|
return;
|
|
@@ -7200,7 +7200,7 @@ var require_limit = __commonJS({
|
|
|
7200
7200
|
cxt.fail$data(compareCode(fmt2));
|
|
7201
7201
|
}
|
|
7202
7202
|
function compareCode(fmt2) {
|
|
7203
|
-
return (0, codegen_1._)`${fmt2}.compare(${
|
|
7203
|
+
return (0, codegen_1._)`${fmt2}.compare(${data2}, ${schemaCode}) ${KWDs[keyword].fail} 0`;
|
|
7204
7204
|
}
|
|
7205
7205
|
},
|
|
7206
7206
|
dependencies: ["format"]
|
|
@@ -7472,9 +7472,9 @@ var ec = [
|
|
|
7472
7472
|
"invalid zip data"
|
|
7473
7473
|
// determined by unknown compression method
|
|
7474
7474
|
];
|
|
7475
|
-
var err = function(
|
|
7476
|
-
var e = new Error(msg || ec[
|
|
7477
|
-
e.code =
|
|
7475
|
+
var err = function(ind2, msg, nt) {
|
|
7476
|
+
var e = new Error(msg || ec[ind2]);
|
|
7477
|
+
e.code = ind2;
|
|
7478
7478
|
if (Error.captureStackTrace)
|
|
7479
7479
|
Error.captureStackTrace(e, err);
|
|
7480
7480
|
if (!nt)
|
|
@@ -7632,8 +7632,8 @@ var b4 = function(d, b) {
|
|
|
7632
7632
|
var b8 = function(d, b) {
|
|
7633
7633
|
return b4(d, b) + b4(d, b + 4) * 4294967296;
|
|
7634
7634
|
};
|
|
7635
|
-
function inflateSync(
|
|
7636
|
-
return inflt(
|
|
7635
|
+
function inflateSync(data2, opts) {
|
|
7636
|
+
return inflt(data2, { i: 2 }, opts && opts.out, opts && opts.dictionary);
|
|
7637
7637
|
}
|
|
7638
7638
|
var td = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
|
|
7639
7639
|
var tds = 0;
|
|
@@ -7700,30 +7700,30 @@ var z64hs = function(d, b, l, z2, sc, su, off) {
|
|
|
7700
7700
|
}
|
|
7701
7701
|
return [sc, su, off, 0];
|
|
7702
7702
|
};
|
|
7703
|
-
function unzipSync(
|
|
7703
|
+
function unzipSync(data2, opts) {
|
|
7704
7704
|
var files = {};
|
|
7705
|
-
var e =
|
|
7706
|
-
for (; b4(
|
|
7707
|
-
if (!e ||
|
|
7705
|
+
var e = data2.length - 22;
|
|
7706
|
+
for (; b4(data2, e) != 101010256; --e) {
|
|
7707
|
+
if (!e || data2.length - e > 65558)
|
|
7708
7708
|
err(13);
|
|
7709
7709
|
}
|
|
7710
7710
|
;
|
|
7711
|
-
var c = b2(
|
|
7711
|
+
var c = b2(data2, e + 8);
|
|
7712
7712
|
if (!c)
|
|
7713
7713
|
return {};
|
|
7714
|
-
var o = b4(
|
|
7715
|
-
var z2 = b4(
|
|
7714
|
+
var o = b4(data2, e + 16);
|
|
7715
|
+
var z2 = b4(data2, e - 20) == 117853008;
|
|
7716
7716
|
if (z2) {
|
|
7717
|
-
var ze = b4(
|
|
7718
|
-
z2 = b4(
|
|
7717
|
+
var ze = b4(data2, e - 12);
|
|
7718
|
+
z2 = b4(data2, ze) == 101075792;
|
|
7719
7719
|
if (z2) {
|
|
7720
|
-
c = b4(
|
|
7721
|
-
o = b4(
|
|
7720
|
+
c = b4(data2, ze + 32);
|
|
7721
|
+
o = b4(data2, ze + 48);
|
|
7722
7722
|
}
|
|
7723
7723
|
}
|
|
7724
7724
|
var fltr = opts && opts.filter;
|
|
7725
7725
|
for (var i2 = 0; i2 < c; ++i2) {
|
|
7726
|
-
var _a4 = zh(
|
|
7726
|
+
var _a4 = zh(data2, o, z2), c_2 = _a4[0], sc = _a4[1], su = _a4[2], fn = _a4[3], no = _a4[4], off = _a4[5], b = slzh(data2, off);
|
|
7727
7727
|
o = no;
|
|
7728
7728
|
if (!fltr || fltr({
|
|
7729
7729
|
name: fn,
|
|
@@ -7732,9 +7732,9 @@ function unzipSync(data, opts) {
|
|
|
7732
7732
|
compression: c_2
|
|
7733
7733
|
})) {
|
|
7734
7734
|
if (!c_2)
|
|
7735
|
-
files[fn] = slc(
|
|
7735
|
+
files[fn] = slc(data2, b, b + sc);
|
|
7736
7736
|
else if (c_2 == 8)
|
|
7737
|
-
files[fn] = inflateSync(
|
|
7737
|
+
files[fn] = inflateSync(data2.subarray(b, b + sc), { out: new u8(su) });
|
|
7738
7738
|
else
|
|
7739
7739
|
err(14, "unknown compression type " + c_2);
|
|
7740
7740
|
}
|
|
@@ -8049,11 +8049,11 @@ var VALUE_PROPS = ["value", "checked", "selected", "selected-date", "selectedDat
|
|
|
8049
8049
|
function bindingHowTo(u) {
|
|
8050
8050
|
const ev = u.events?.[0];
|
|
8051
8051
|
if (!ev) return [];
|
|
8052
|
-
const
|
|
8052
|
+
const camel2 = (n) => n.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
8053
8053
|
const vp = u.props?.find((p) => VALUE_PROPS.includes(p.name))?.name;
|
|
8054
|
-
const valueProp = vp ?
|
|
8054
|
+
const valueProp = vp ? camel2(vp) : void 0;
|
|
8055
8055
|
const dashed = (u.props ?? []).find((p) => p.name.includes("-"))?.name;
|
|
8056
|
-
const caseNote = dashed ? ` Static attributes are kebab-case (\`${dashed}="\u2026"\`); bindings use the camelCase property (\`${u.framework === "vue" ? ":" : "["}${
|
|
8056
|
+
const caseNote = dashed ? ` Static attributes are kebab-case (\`${dashed}="\u2026"\`); bindings use the camelCase property (\`${u.framework === "vue" ? ":" : "["}${camel2(dashed)}${u.framework === "vue" ? "" : "]"}="expr"\`), never \`${u.framework === "vue" ? ":" : "["}${dashed}${u.framework === "vue" ? "" : "]"}\`.` : "";
|
|
8057
8057
|
const attrs = (u.props ?? []).filter((p) => p.required).map((p) => `${p.name}="\u2026"`).join(" ");
|
|
8058
8058
|
const open2 = (extra) => `<${u.tag}${attrs ? ` ${attrs}` : ""}${extra}></${u.tag}>`;
|
|
8059
8059
|
const ce = u.customElement || u.via === "web-components";
|
|
@@ -8950,11 +8950,11 @@ function templateProps({ code, config: config2, framework }) {
|
|
|
8950
8950
|
if (!n || !t.props?.length) continue;
|
|
8951
8951
|
passed.push(n);
|
|
8952
8952
|
if (t.ce && n.includes("-") && /^(?:\[(?!attr\.)|:|v-bind:|bind-)/.test(raw)) {
|
|
8953
|
-
const
|
|
8953
|
+
const camel2 = n.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
8954
8954
|
out.push({
|
|
8955
8955
|
offset: a.offset,
|
|
8956
8956
|
message: `${raw} binds a property that doesn't exist on <${t.tag}>`,
|
|
8957
|
-
suggestion: `Bind the camelCase property: ${framework === "vue" ? `:${
|
|
8957
|
+
suggestion: `Bind the camelCase property: ${framework === "vue" ? `:${camel2}` : `[${camel2}]`}="\u2026" (kebab-case is only for static attributes: ${n}="\u2026")`
|
|
8958
8958
|
});
|
|
8959
8959
|
continue;
|
|
8960
8960
|
}
|
|
@@ -9185,7 +9185,7 @@ function makeIgnore(globs) {
|
|
|
9185
9185
|
}
|
|
9186
9186
|
|
|
9187
9187
|
// ../engine/src/check.ts
|
|
9188
|
-
var ENGINE_VERSION = "0.
|
|
9188
|
+
var ENGINE_VERSION = "0.8.0";
|
|
9189
9189
|
var WEIGHT = { error: 4, warning: 1.5, info: 0.25 };
|
|
9190
9190
|
function computeScore(counts, lines) {
|
|
9191
9191
|
const penalty = counts.error * WEIGHT.error + counts.warning * WEIGHT.warning + counts.info * WEIGHT.info;
|
|
@@ -9999,7 +9999,7 @@ function generateInstructions(config2, opts = {}) {
|
|
|
9999
9999
|
if (r.components.length) {
|
|
10000
10000
|
const usable = r.components.map((c) => ({ c, u: resolveUsage(c, fw) }));
|
|
10001
10001
|
const here = usable.filter((x2) => x2.u);
|
|
10002
|
-
const
|
|
10002
|
+
const missing2 = usable.filter((x2) => !x2.u).map((x2) => x2.c.name);
|
|
10003
10003
|
lines.push("## Components");
|
|
10004
10004
|
if (fw !== "react") lines.push(`This is a${fw === "angular" ? "n" : ""} ${FRAMEWORK_LABEL[fw]} project: use the ${FRAMEWORK_LABEL[fw]} form of each component shown here.`);
|
|
10005
10005
|
if (here.length) lines.push("Always use these components. Never re-create them with raw HTML elements:");
|
|
@@ -10021,9 +10021,9 @@ function generateInstructions(config2, opts = {}) {
|
|
|
10021
10021
|
lines.push("");
|
|
10022
10022
|
lines.push("Pass only the props listed for each component (* = required). Any other prop is a type error and fails the check: if you need something a component doesn't take, look for a related component (often one with a longer name, like AvatarLabel next to Avatar) or compose it with design tokens.");
|
|
10023
10023
|
}
|
|
10024
|
-
if (
|
|
10024
|
+
if (missing2.length) {
|
|
10025
10025
|
lines.push("");
|
|
10026
|
-
lines.push(`No ${FRAMEWORK_LABEL[fw]} version yet: ${
|
|
10026
|
+
lines.push(`No ${FRAMEWORK_LABEL[fw]} version yet: ${missing2.join(", ")}. Build these with semantic HTML and the design tokens below; don't install another UI library.`);
|
|
10027
10027
|
}
|
|
10028
10028
|
lines.push("");
|
|
10029
10029
|
}
|
|
@@ -10047,6 +10047,9 @@ function generateInstructions(config2, opts = {}) {
|
|
|
10047
10047
|
if (sizeVars.length) lines.push(`- Font sizes come from the type scale: ${sizeVars.join(", ")}. Matching line heights are \`--font-line-height-*\`.`);
|
|
10048
10048
|
if (r.fonts.length) lines.push(`- Fonts: use ${r.fontVars.map((v) => `\`var(${v})\``).join(" or ")}; never set another font-family.`);
|
|
10049
10049
|
lines.push("");
|
|
10050
|
+
lines.push("## New pages");
|
|
10051
|
+
lines.push("- Building a new page or screen? Start from a page template: MCP `get_template` (list, detail, form, settings, dashboard, sign-in) or `npx brandrail template <name>`. It's built from these components and the spacing scale, and lists the page's rules (states, layout, accessibility). Rename its sample data; keep its structure.");
|
|
10052
|
+
lines.push("");
|
|
10050
10053
|
lines.push("## Migrating existing UI");
|
|
10051
10054
|
lines.push("- Code that still uses Material, MUI, Bootstrap, Ant Design, Chakra, PrimeNG or raw HTML controls is migration work (`legacy-library` findings). `npx brandrail migrate` lists what's left per file. In Claude Code, use the `brandrail-migrate` skill (or the `brandrail-migrator` agent) and work in small batches; keep behaviour identical.");
|
|
10052
10055
|
lines.push("");
|
|
@@ -10942,6 +10945,779 @@ ${trend}
|
|
|
10942
10945
|
`;
|
|
10943
10946
|
}
|
|
10944
10947
|
|
|
10948
|
+
// ../engine/src/templates.ts
|
|
10949
|
+
var data = (name) => ({ $data: name });
|
|
10950
|
+
var isData = (v) => !!v && typeof v === "object" && "$data" in v;
|
|
10951
|
+
var L = (as, ...children) => ({ kind: "layout", as, children });
|
|
10952
|
+
var T = (as, text2) => ({ kind: "text", as, text: text2 });
|
|
10953
|
+
var C = (component, part, purpose, props = {}, extra = {}) => ({
|
|
10954
|
+
kind: "c",
|
|
10955
|
+
component,
|
|
10956
|
+
part,
|
|
10957
|
+
purpose,
|
|
10958
|
+
// Cards sit under the page's h1, so their titles are h2.
|
|
10959
|
+
props: component === "Card" && props.title && props.headingLevel === void 0 ? { ...props, headingLevel: 2 } : props,
|
|
10960
|
+
...extra
|
|
10961
|
+
});
|
|
10962
|
+
var OWNERS = [
|
|
10963
|
+
{ label: "Alex Chen", value: "alex" },
|
|
10964
|
+
{ label: "Priya Nair", value: "priya" },
|
|
10965
|
+
{ label: "Sam Taylor", value: "sam" }
|
|
10966
|
+
];
|
|
10967
|
+
var confirmDelete = (what, lost) => C("Modal", "confirm-delete", "Confirms the destructive action", { title: `Delete ${what}?`, description: lost, primaryLabel: "Delete", danger: true, size: "small" }, {
|
|
10968
|
+
bind: { open: "confirmOpen" },
|
|
10969
|
+
on: { onClose: { set: "confirmOpen", to: false }, onPrimary: { set: "confirmOpen", to: false } }
|
|
10970
|
+
});
|
|
10971
|
+
var COMMON_RULES = [
|
|
10972
|
+
"Use only the components and CSS variables shown; no other UI library and no hard-coded colours, spacing or fonts.",
|
|
10973
|
+
"One primary (cta) button per view. Secondary actions are ghost buttons; destructive ones are danger and confirmed in a Modal.",
|
|
10974
|
+
"Every field has a visible label. Every table has a caption (captionHidden keeps it for screen readers).",
|
|
10975
|
+
"Show three states for data that loads: loading (Loader), empty (the component's empty message) and error (Notification with type error and what to do next).",
|
|
10976
|
+
"Keep the page within the layout classes below: they use the Brand Kit's spacing scale and collapse to one column on phones."
|
|
10977
|
+
];
|
|
10978
|
+
var PAGE_TEMPLATES = [
|
|
10979
|
+
{
|
|
10980
|
+
id: "list",
|
|
10981
|
+
name: "List page",
|
|
10982
|
+
description: "A table of records with a create button, filters and search. The index page of any section (projects, orders, users).",
|
|
10983
|
+
aliases: ["index", "table page", "records", "collection", "admin list", "crud", "overview list", "search results"],
|
|
10984
|
+
rules: [
|
|
10985
|
+
'The page title says what the records are; the create button names the thing ("New project", not "Add").',
|
|
10986
|
+
"Filters sit above the table and apply immediately; don't add an Apply button.",
|
|
10987
|
+
"Clicking a row opens its detail page. Long tables paginate on the server (manualSort and onSort).",
|
|
10988
|
+
"Confirm deletes with a Modal and report the result with a Toast offering Undo."
|
|
10989
|
+
],
|
|
10990
|
+
data: {
|
|
10991
|
+
owners: OWNERS,
|
|
10992
|
+
statusTabs: [
|
|
10993
|
+
{ label: "All", value: "all" },
|
|
10994
|
+
{ label: "Active", value: "active" },
|
|
10995
|
+
{ label: "Archived", value: "archived" }
|
|
10996
|
+
],
|
|
10997
|
+
columns: [
|
|
10998
|
+
{ key: "name", label: "Project", sortable: true },
|
|
10999
|
+
{ key: "owner", label: "Owner", sortable: true },
|
|
11000
|
+
{ key: "status", label: "Status" },
|
|
11001
|
+
{ key: "tasks", label: "Open tasks", align: "right", sortable: true }
|
|
11002
|
+
],
|
|
11003
|
+
rows: [
|
|
11004
|
+
{ id: "p1", name: "Website redesign", owner: "Alex Chen", status: "Active", tasks: 12 },
|
|
11005
|
+
{ id: "p2", name: "Mobile app", owner: "Priya Nair", status: "Active", tasks: 7 },
|
|
11006
|
+
{ id: "p3", name: "Q3 report", owner: "Sam Taylor", status: "Archived", tasks: 0 }
|
|
11007
|
+
]
|
|
11008
|
+
},
|
|
11009
|
+
state: { status: "all" },
|
|
11010
|
+
tree: L(
|
|
11011
|
+
"page",
|
|
11012
|
+
L("header", L("stack", T("h1", "Projects"), T("muted", "Every project in your workspace.")), C("Button", "create", "The page's one primary action", { label: "New project", type: "cta" })),
|
|
11013
|
+
L(
|
|
11014
|
+
"row",
|
|
11015
|
+
C("Tabs", "status-filter", "Filters the table by status", { label: "Status", tabs: data("statusTabs"), variant: "pills", size: "small" }, { bind: { selected: "status" }, on: { onChange: { store: "status" } } }),
|
|
11016
|
+
C("Combobox", "owner-filter", "Filters by owner; searchable for long lists", { label: "Owner", placeholder: "Anyone", options: data("owners"), size: "small" })
|
|
11017
|
+
),
|
|
11018
|
+
C("Table", "results", "The records; sortable, with an empty state", { caption: "Projects", captionHidden: true, rowKey: "id", columns: data("columns"), rows: data("rows"), emptyMessage: "No projects match these filters." })
|
|
11019
|
+
)
|
|
11020
|
+
},
|
|
11021
|
+
{
|
|
11022
|
+
id: "detail",
|
|
11023
|
+
name: "Detail page",
|
|
11024
|
+
description: "One record: breadcrumb, title with status, actions, tabs for its sections and a delete confirmation.",
|
|
11025
|
+
aliases: ["show page", "view page", "record page", "profile", "item page", "single"],
|
|
11026
|
+
rules: [
|
|
11027
|
+
"The breadcrumb leads back to the list page; the last item is the current record.",
|
|
11028
|
+
"Status is a Badge next to the title, using tone for meaning.",
|
|
11029
|
+
"Edit is a ghost button; rarer actions go in the More menu, destructive ones last with danger.",
|
|
11030
|
+
"Each tab is one section; keep the most used first."
|
|
11031
|
+
],
|
|
11032
|
+
data: {
|
|
11033
|
+
trail: [
|
|
11034
|
+
{ label: "Projects", href: "/projects" },
|
|
11035
|
+
{ label: "Website redesign", isCurrent: true }
|
|
11036
|
+
],
|
|
11037
|
+
tabs: [
|
|
11038
|
+
{ label: "Overview", value: "overview" },
|
|
11039
|
+
{ label: "Tasks", value: "tasks", count: 12 },
|
|
11040
|
+
{ label: "Files", value: "files" }
|
|
11041
|
+
],
|
|
11042
|
+
moreActions: [
|
|
11043
|
+
{ label: "Duplicate", value: "duplicate" },
|
|
11044
|
+
{ label: "Archive", value: "archive" },
|
|
11045
|
+
{ label: "Delete", value: "delete", danger: true, divider: true }
|
|
11046
|
+
]
|
|
11047
|
+
},
|
|
11048
|
+
state: { tab: "overview", confirmOpen: false },
|
|
11049
|
+
tree: L(
|
|
11050
|
+
"page",
|
|
11051
|
+
C("Breadcrumb", "trail", "Where this record sits", { items: data("trail"), size: "small" }),
|
|
11052
|
+
L(
|
|
11053
|
+
"header",
|
|
11054
|
+
L("stack", L("row", T("h1", "Website redesign"), C("Badge", "status", "The record's status", { label: "Active", tone: "success", dot: true })), T("muted", "Owned by Alex Chen \xB7 due 30 Nov")),
|
|
11055
|
+
L(
|
|
11056
|
+
"row",
|
|
11057
|
+
C("Button", "edit", "Opens the edit form", { label: "Edit", type: "ghost" }),
|
|
11058
|
+
C("Menu", "more", "Less frequent actions", { label: "More", items: data("moreActions"), align: "end" }, { on: { onSelect: { set: "confirmOpen", to: true, when: "delete" } } })
|
|
11059
|
+
)
|
|
11060
|
+
),
|
|
11061
|
+
C(
|
|
11062
|
+
"Tabs",
|
|
11063
|
+
"sections",
|
|
11064
|
+
"The record's sections",
|
|
11065
|
+
{ label: "Project sections", tabs: data("tabs") },
|
|
11066
|
+
{
|
|
11067
|
+
bind: { selected: "tab" },
|
|
11068
|
+
on: { onChange: { store: "tab" } },
|
|
11069
|
+
children: [
|
|
11070
|
+
L(
|
|
11071
|
+
"grid",
|
|
11072
|
+
C("Card", "summary", "A group of facts", { title: "Summary", description: "Rebuild the marketing site on the new design system." }),
|
|
11073
|
+
C("Card", "budget", "A group of facts", { title: "Budget", description: "$48,000 \xB7 62% used" }),
|
|
11074
|
+
C("Card", "team", "A group of facts", { title: "Team", description: "Alex Chen, Priya Nair and 3 others" })
|
|
11075
|
+
)
|
|
11076
|
+
]
|
|
11077
|
+
}
|
|
11078
|
+
),
|
|
11079
|
+
confirmDelete("this project", "Its tasks and files are deleted too. This can't be undone.")
|
|
11080
|
+
)
|
|
11081
|
+
},
|
|
11082
|
+
{
|
|
11083
|
+
id: "form",
|
|
11084
|
+
name: "Form page",
|
|
11085
|
+
description: "Create or edit a record: grouped fields, validation messages, Cancel and Save, and a confirmation Toast.",
|
|
11086
|
+
aliases: ["create page", "edit page", "new record", "input form", "wizard step", "submission"],
|
|
11087
|
+
rules: [
|
|
11088
|
+
"Group related fields in Cards with a title; one column of fields reads fastest.",
|
|
11089
|
+
"Validate on submit and on blur, never while typing. Show the error under the field (state error and caption) and say how to fix it.",
|
|
11090
|
+
'The primary button names the result ("Create project"); Cancel is a ghost button to its left.',
|
|
11091
|
+
"After saving, show a success Toast and go back to the list or detail page."
|
|
11092
|
+
],
|
|
11093
|
+
data: {
|
|
11094
|
+
trail: [
|
|
11095
|
+
{ label: "Projects", href: "/projects" },
|
|
11096
|
+
{ label: "New project", isCurrent: true }
|
|
11097
|
+
],
|
|
11098
|
+
owners: OWNERS
|
|
11099
|
+
},
|
|
11100
|
+
state: { saved: false },
|
|
11101
|
+
tree: L(
|
|
11102
|
+
"page",
|
|
11103
|
+
C("Breadcrumb", "trail", "Where this form sits", { items: data("trail"), size: "small" }),
|
|
11104
|
+
L("header", L("stack", T("h1", "New project"), T("muted", "Projects group tasks, files and people."))),
|
|
11105
|
+
L(
|
|
11106
|
+
"narrow",
|
|
11107
|
+
C("Card", "details", "Groups the main fields", { title: "Details" }, {
|
|
11108
|
+
children: [
|
|
11109
|
+
L(
|
|
11110
|
+
"stack",
|
|
11111
|
+
C("InputText", "name", "Required text field", { label: "Project name", placeholder: "Website redesign" }),
|
|
11112
|
+
C("InputTextArea", "description", "Optional longer text", { label: "Description", placeholder: "What is it for?" }),
|
|
11113
|
+
C("Combobox", "owner", "Pick one from a long list", { label: "Owner", options: data("owners") }),
|
|
11114
|
+
C("DatePicker", "due", "A date", { placeholder: "Due date" })
|
|
11115
|
+
)
|
|
11116
|
+
]
|
|
11117
|
+
}),
|
|
11118
|
+
C("Card", "notifications", "Groups the settings", { title: "Notifications" }, {
|
|
11119
|
+
children: [
|
|
11120
|
+
L(
|
|
11121
|
+
"stack",
|
|
11122
|
+
C("Toggle", "notify", "An instant on/off setting", { label: "Email me when tasks change" }),
|
|
11123
|
+
C("Checkbox", "public", "A yes/no choice saved with the form", { label: "Visible to everyone in the workspace" })
|
|
11124
|
+
)
|
|
11125
|
+
]
|
|
11126
|
+
}),
|
|
11127
|
+
L(
|
|
11128
|
+
"actions",
|
|
11129
|
+
C("Button", "cancel", "Leaves without saving", { label: "Cancel", type: "ghost" }),
|
|
11130
|
+
C("Button", "save", "Saves the form", { label: "Create project", type: "cta" }, { on: { onClick: { set: "saved", to: true } } })
|
|
11131
|
+
)
|
|
11132
|
+
),
|
|
11133
|
+
C("Toast", "saved", "Confirms the save", { title: "Project created", type: "success" }, { bind: { open: "saved" }, on: { onClose: { set: "saved", to: false } } })
|
|
11134
|
+
)
|
|
11135
|
+
},
|
|
11136
|
+
{
|
|
11137
|
+
id: "settings",
|
|
11138
|
+
name: "Settings page",
|
|
11139
|
+
description: "Settings in tabbed sections, each a Card, with a danger zone that confirms before deleting.",
|
|
11140
|
+
aliases: ["preferences", "account settings", "configuration", "admin settings", "profile settings"],
|
|
11141
|
+
rules: [
|
|
11142
|
+
"Toggles apply immediately; text fields save with a button in their Card.",
|
|
11143
|
+
"Put destructive settings last, in their own Card, with a danger button and a confirmation Modal.",
|
|
11144
|
+
"Tabs hold sections of five or fewer Cards; more sections means another tab."
|
|
11145
|
+
],
|
|
11146
|
+
data: {
|
|
11147
|
+
sections: [
|
|
11148
|
+
{ label: "General", value: "general" },
|
|
11149
|
+
{ label: "Notifications", value: "notifications" },
|
|
11150
|
+
{ label: "Billing", value: "billing" }
|
|
11151
|
+
],
|
|
11152
|
+
timezones: [
|
|
11153
|
+
{ label: "Perth (AWST)", value: "Australia/Perth" },
|
|
11154
|
+
{ label: "Sydney (AEDT)", value: "Australia/Sydney" },
|
|
11155
|
+
{ label: "London (GMT)", value: "Europe/London" }
|
|
11156
|
+
]
|
|
11157
|
+
},
|
|
11158
|
+
state: { section: "general", confirmOpen: false },
|
|
11159
|
+
tree: L(
|
|
11160
|
+
"page",
|
|
11161
|
+
L("header", L("stack", T("h1", "Settings"), T("muted", "Workspace settings apply to everyone."))),
|
|
11162
|
+
C(
|
|
11163
|
+
"Tabs",
|
|
11164
|
+
"sections",
|
|
11165
|
+
"Settings sections",
|
|
11166
|
+
{ label: "Settings sections", tabs: data("sections") },
|
|
11167
|
+
{
|
|
11168
|
+
bind: { selected: "section" },
|
|
11169
|
+
on: { onChange: { store: "section" } },
|
|
11170
|
+
children: [
|
|
11171
|
+
L(
|
|
11172
|
+
"stack",
|
|
11173
|
+
C("Card", "workspace", "A group of related settings", { title: "Workspace", description: "Shown to members and in emails." }, {
|
|
11174
|
+
children: [
|
|
11175
|
+
L(
|
|
11176
|
+
"stack",
|
|
11177
|
+
C("InputText", "workspace-name", "A text setting", { label: "Workspace name", placeholder: "Acme" }),
|
|
11178
|
+
C("Combobox", "timezone", "Pick one from a long list", { label: "Time zone", options: data("timezones") }),
|
|
11179
|
+
L("actions", C("Button", "save", "Saves this Card", { label: "Save changes", type: "cta" }))
|
|
11180
|
+
)
|
|
11181
|
+
]
|
|
11182
|
+
}),
|
|
11183
|
+
C("Card", "alerts", "Instant settings", { title: "Alerts" }, {
|
|
11184
|
+
children: [
|
|
11185
|
+
L(
|
|
11186
|
+
"stack",
|
|
11187
|
+
C("Toggle", "weekly", "An instant on/off setting", { label: "Weekly summary email", checked: true }),
|
|
11188
|
+
C("Toggle", "mentions", "An instant on/off setting", { label: "Email me when I'm mentioned" })
|
|
11189
|
+
)
|
|
11190
|
+
]
|
|
11191
|
+
}),
|
|
11192
|
+
C("Card", "danger-zone", "Destructive settings, last", { title: "Danger zone", description: "Deleting the workspace removes every project for everyone." }, {
|
|
11193
|
+
children: [L("actions", C("Button", "delete", "Starts the destructive action", { label: "Delete workspace", type: "danger" }, { on: { onClick: { set: "confirmOpen", to: true } } }))]
|
|
11194
|
+
})
|
|
11195
|
+
)
|
|
11196
|
+
]
|
|
11197
|
+
}
|
|
11198
|
+
),
|
|
11199
|
+
confirmDelete("the workspace", "Every project, task and file is deleted for all members. This can't be undone.")
|
|
11200
|
+
)
|
|
11201
|
+
},
|
|
11202
|
+
{
|
|
11203
|
+
id: "dashboard",
|
|
11204
|
+
name: "Dashboard",
|
|
11205
|
+
description: "Key numbers in Cards, a time range, and a table of recent activity.",
|
|
11206
|
+
aliases: ["home", "overview", "analytics", "metrics", "kpi", "stats", "report"],
|
|
11207
|
+
rules: [
|
|
11208
|
+
"Four key numbers at most, each with what it measures and how it changed.",
|
|
11209
|
+
'Use Badge tone for trends (success up, danger down) and say the period ("this week").',
|
|
11210
|
+
"The table shows the latest items only and links to the full list page."
|
|
11211
|
+
],
|
|
11212
|
+
data: {
|
|
11213
|
+
ranges: [
|
|
11214
|
+
{ label: "7 days", value: "7d" },
|
|
11215
|
+
{ label: "30 days", value: "30d" },
|
|
11216
|
+
{ label: "90 days", value: "90d" }
|
|
11217
|
+
],
|
|
11218
|
+
columns: [
|
|
11219
|
+
{ key: "item", label: "Project" },
|
|
11220
|
+
{ key: "event", label: "What happened" },
|
|
11221
|
+
{ key: "when", label: "When", align: "right" }
|
|
11222
|
+
],
|
|
11223
|
+
rows: [
|
|
11224
|
+
{ id: "a1", item: "Website redesign", event: "12 tasks completed", when: "Today" },
|
|
11225
|
+
{ id: "a2", item: "Mobile app", event: "New release 2.4", when: "Yesterday" },
|
|
11226
|
+
{ id: "a3", item: "Q3 report", event: "Archived", when: "3 Nov" }
|
|
11227
|
+
]
|
|
11228
|
+
},
|
|
11229
|
+
state: { range: "7d" },
|
|
11230
|
+
tree: L(
|
|
11231
|
+
"page",
|
|
11232
|
+
L(
|
|
11233
|
+
"header",
|
|
11234
|
+
L("stack", T("h1", "Overview"), T("muted", "How your workspace is doing.")),
|
|
11235
|
+
C("Tabs", "range", "The period every number uses", { label: "Period", tabs: data("ranges"), variant: "pills", size: "small" }, { bind: { selected: "range" }, on: { onChange: { store: "range" } } })
|
|
11236
|
+
),
|
|
11237
|
+
L(
|
|
11238
|
+
"grid",
|
|
11239
|
+
C("Card", "active", "A key number", { title: "Active projects" }, { children: [T("stat", "24"), C("Badge", "active-trend", "How it changed", { label: "+3 this week", tone: "success" })] }),
|
|
11240
|
+
C("Card", "done", "A key number", { title: "Tasks completed" }, { children: [T("stat", "186"), C("Badge", "done-trend", "How it changed", { label: "+12%", tone: "success" })] }),
|
|
11241
|
+
C("Card", "overdue", "A key number", { title: "Overdue tasks" }, { children: [T("stat", "9"), C("Badge", "overdue-trend", "How it changed", { label: "+4 this week", tone: "danger" })] })
|
|
11242
|
+
),
|
|
11243
|
+
C("Table", "recent", "The latest activity", { caption: "Recent activity", rowKey: "id", columns: data("columns"), rows: data("rows"), emptyMessage: "Nothing has happened yet." })
|
|
11244
|
+
)
|
|
11245
|
+
},
|
|
11246
|
+
{
|
|
11247
|
+
id: "sign-in",
|
|
11248
|
+
name: "Sign-in page",
|
|
11249
|
+
description: "A centred sign-in form with email, password and an error message.",
|
|
11250
|
+
aliases: ["login", "log in", "auth", "authentication", "sign up", "register", "password"],
|
|
11251
|
+
rules: [
|
|
11252
|
+
`Only ask for what's needed. Label fields "Email" and "Password"; no placeholders as labels.`,
|
|
11253
|
+
"Show sign-in errors in a Notification above the form, without saying which field was wrong.",
|
|
11254
|
+
"The submit button stays enabled; disable it only while the request runs."
|
|
11255
|
+
],
|
|
11256
|
+
data: {},
|
|
11257
|
+
state: {},
|
|
11258
|
+
tree: L(
|
|
11259
|
+
"center",
|
|
11260
|
+
L(
|
|
11261
|
+
"narrow",
|
|
11262
|
+
T("h1", "Sign in to Acme"),
|
|
11263
|
+
C("Card", "form", "Holds the form", {}, {
|
|
11264
|
+
children: [
|
|
11265
|
+
L(
|
|
11266
|
+
"stack",
|
|
11267
|
+
C("InputText", "email", "The account's email", { label: "Email", placeholder: "you@company.com" }),
|
|
11268
|
+
C("InputText", "password", "The account's password", { label: "Password", type: "password" }),
|
|
11269
|
+
C("Button", "submit", "Signs in", { label: "Sign in", type: "cta" })
|
|
11270
|
+
)
|
|
11271
|
+
]
|
|
11272
|
+
}),
|
|
11273
|
+
T("muted", "No account? Ask your workspace owner for an invite.")
|
|
11274
|
+
)
|
|
11275
|
+
)
|
|
11276
|
+
}
|
|
11277
|
+
];
|
|
11278
|
+
var squash2 = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
11279
|
+
function findTemplate(query) {
|
|
11280
|
+
const q = squash2(query);
|
|
11281
|
+
if (!q) return void 0;
|
|
11282
|
+
const exact = PAGE_TEMPLATES.find((t) => squash2(t.id) === q || squash2(t.name) === q || t.aliases.some((a) => squash2(a) === q));
|
|
11283
|
+
if (exact) return exact;
|
|
11284
|
+
const words = query.toLowerCase().split(/[^a-z0-9]+/).filter((w) => w.length > 2 && !["page", "the", "for", "with", "screen"].includes(w));
|
|
11285
|
+
let best;
|
|
11286
|
+
for (const t of PAGE_TEMPLATES) {
|
|
11287
|
+
const hay = [t.id, t.name, ...t.aliases, t.description].join(" ").toLowerCase();
|
|
11288
|
+
const score = words.reduce((s, w) => s + (hay.includes(w) ? 1 : 0), 0);
|
|
11289
|
+
if (score && (!best || score > best.score)) best = { t, score };
|
|
11290
|
+
}
|
|
11291
|
+
return best?.t;
|
|
11292
|
+
}
|
|
11293
|
+
var PART_LOOKUP = {
|
|
11294
|
+
Button: { concept: "button", names: ["Btn"] },
|
|
11295
|
+
InputText: { concept: "input", names: ["TextInput", "TextField", "Input"] },
|
|
11296
|
+
InputTextArea: { concept: "textarea", names: ["Textarea", "TextArea"] },
|
|
11297
|
+
Combobox: { names: ["Autocomplete", "Typeahead", "SearchSelect"] },
|
|
11298
|
+
DatePicker: { concept: "datepicker", names: ["DateInput", "Calendar"] },
|
|
11299
|
+
Toggle: { concept: "toggle", names: ["Switch"] },
|
|
11300
|
+
Checkbox: { concept: "checkbox", names: [] },
|
|
11301
|
+
Modal: { concept: "dialog", names: ["Dialog"] },
|
|
11302
|
+
Tabs: { concept: "tabs", names: ["TabBar", "TabList"] },
|
|
11303
|
+
Card: { concept: "card", names: ["Panel", "Tile"] },
|
|
11304
|
+
Table: { concept: "table", names: ["DataTable", "DataGrid"] },
|
|
11305
|
+
Badge: { names: ["Tag", "Chip", "Pill", "Lozenge", "StatusLabel"] },
|
|
11306
|
+
Toast: { names: ["Snackbar"] },
|
|
11307
|
+
Menu: { names: ["ActionMenu", "DropdownMenu"] },
|
|
11308
|
+
Breadcrumb: { concept: "breadcrumb", names: ["Breadcrumbs"] }
|
|
11309
|
+
};
|
|
11310
|
+
function resolvePart(config2, kitName) {
|
|
11311
|
+
const look = PART_LOOKUP[kitName] ?? { names: [] };
|
|
11312
|
+
for (const n of [kitName, ...look.names]) {
|
|
11313
|
+
const c = findComponentByName(config2, n);
|
|
11314
|
+
if (c && c.status !== "deprecated") return c;
|
|
11315
|
+
}
|
|
11316
|
+
if (look.concept) {
|
|
11317
|
+
const c = componentForConcept(config2, look.concept);
|
|
11318
|
+
if (c && c.status !== "deprecated") return c;
|
|
11319
|
+
}
|
|
11320
|
+
return void 0;
|
|
11321
|
+
}
|
|
11322
|
+
var kebab3 = (s) => s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
11323
|
+
var camel = (s) => s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
11324
|
+
var pascal2 = (s) => s.replace(/(^|[-_ ])(\w)/g, (_, __, c) => c.toUpperCase());
|
|
11325
|
+
var setter = (v) => `set${v[0].toUpperCase()}${v.slice(1)}`;
|
|
11326
|
+
var KIT2 = "@brandrail/kit";
|
|
11327
|
+
var KIT_TYPES = /* @__PURE__ */ new Set(["TableColumn", "TableRow", "TabItem", "MenuItem", "ComboboxOption"]);
|
|
11328
|
+
function enumOf(type, value) {
|
|
11329
|
+
const m = type ? /^(\w+) \(([^)]*)\)$/.exec(type) : null;
|
|
11330
|
+
if (!m) return void 0;
|
|
11331
|
+
const member = m[2].split("|").map((x2) => x2.trim()).find((x2) => x2.split(".")[1]?.toLowerCase().replace(/_/g, "-") === value.toLowerCase());
|
|
11332
|
+
return member ? { name: m[1], ref: member } : void 0;
|
|
11333
|
+
}
|
|
11334
|
+
function acceptedProps(part, fw) {
|
|
11335
|
+
const props = part.node.props ?? {};
|
|
11336
|
+
const list = part.usage?.props;
|
|
11337
|
+
const out = [];
|
|
11338
|
+
for (const [name, value] of Object.entries(props)) {
|
|
11339
|
+
if (!list?.length) {
|
|
11340
|
+
out.push([name, fw === "react" ? name : kebab3(name), value, void 0]);
|
|
11341
|
+
continue;
|
|
11342
|
+
}
|
|
11343
|
+
const candidates = fw === "react" ? [name] : [kebab3(name), name, ...name === "title" ? ["heading"] : []];
|
|
11344
|
+
const spec = list.find((p) => candidates.includes(p.name));
|
|
11345
|
+
if (spec) out.push([name, spec.name, value, spec]);
|
|
11346
|
+
}
|
|
11347
|
+
return out;
|
|
11348
|
+
}
|
|
11349
|
+
function eventFor(part, prop) {
|
|
11350
|
+
const u = part.usage;
|
|
11351
|
+
const bare = kebab3(prop.replace(/^on/, ""));
|
|
11352
|
+
const custom2 = u?.customElement || u?.via === "web-components";
|
|
11353
|
+
const events = u?.events ?? [];
|
|
11354
|
+
const hit = events.find((e) => e.name === `br-${bare}` || e.name === bare || e.name.endsWith(`-${bare}`) || camel(e.name) === camel(bare));
|
|
11355
|
+
if (hit) return hit.name;
|
|
11356
|
+
return custom2 ? `br-${bare}` : bare;
|
|
11357
|
+
}
|
|
11358
|
+
function literal(v, pad = "") {
|
|
11359
|
+
const one = (x2) => x2 && typeof x2 === "object" && !Array.isArray(x2) ? `{ ${Object.entries(x2).map(([k, y]) => `${/^\w+$/.test(k) ? k : JSON.stringify(k)}: ${one(y)}`).join(", ")} }` : Array.isArray(x2) ? `[${x2.map(one).join(", ")}]` : JSON.stringify(x2);
|
|
11360
|
+
if (Array.isArray(v) && v.length && v.every((x2) => x2 && typeof x2 === "object")) return `[
|
|
11361
|
+
${v.map((x2) => `${pad} ${one(x2)},`).join("\n")}
|
|
11362
|
+
${pad}]`;
|
|
11363
|
+
return one(v);
|
|
11364
|
+
}
|
|
11365
|
+
var tokenVar = (path) => `var(--${path.replace(/\./g, "-")})`;
|
|
11366
|
+
function nearest3(scale, want) {
|
|
11367
|
+
const s = scale.filter((v) => v > 0 && v < 999);
|
|
11368
|
+
return s.length ? s.reduce((a, b) => Math.abs(b - want) < Math.abs(a - want) ? b : a) : want;
|
|
11369
|
+
}
|
|
11370
|
+
function templateCss(config2) {
|
|
11371
|
+
const r = resolveConfig(config2);
|
|
11372
|
+
const sp = (v) => `${nearest3(r.spacing, v)}px`;
|
|
11373
|
+
const flat = flattenTokens(config2.tokens ?? {});
|
|
11374
|
+
const roles = pickColorRoles(flat.filter((t) => t.type === "color").map((t) => ({ path: t.path, value: String(t.value), dark: t.dark ? String(t.dark) : void 0 })));
|
|
11375
|
+
const color = (role) => roles[role].path ? tokenVar(roles[role].path) : void 0;
|
|
11376
|
+
const font = flat.find((t) => t.type === "fontFamily" || /^font\.family\./.test(t.path));
|
|
11377
|
+
const decl = (prop, v) => v ? ` ${prop}: ${v};` : "";
|
|
11378
|
+
return [
|
|
11379
|
+
`/* Page layout on the Brand Kit's spacing scale. Components style themselves. */`,
|
|
11380
|
+
`.pg {${decl("color", color("fg"))}${decl("background", color("canvas"))}${decl("font-family", font ? tokenVar(font.path) : void 0)} display: grid; grid-template-columns: minmax(0, 1fr); gap: ${sp(24)}; max-width: 1200px; margin: 0 auto; padding: ${sp(32)} ${sp(24)}; }`,
|
|
11381
|
+
`.pg-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: ${sp(16)}; }`,
|
|
11382
|
+
`.pg h1 { margin: 0; font-size: 24px; line-height: 1.25; }`,
|
|
11383
|
+
`.pg-muted { margin: 0;${decl("color", color("muted"))} }`,
|
|
11384
|
+
`.pg-stat { margin: 0 0 ${sp(8)}; font-size: 30px; font-weight: 600; line-height: 1.2; }`,
|
|
11385
|
+
`.pg-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: ${sp(16)}; align-content: start; }`,
|
|
11386
|
+
`.pg-row { display: flex; flex-wrap: wrap; align-items: center; gap: ${sp(12)}; }`,
|
|
11387
|
+
`.pg-grid { display: grid; gap: ${sp(16)}; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }`,
|
|
11388
|
+
`.pg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: ${sp(8)}; }`,
|
|
11389
|
+
`.pg-narrow { display: grid; grid-template-columns: minmax(0, 1fr); gap: ${sp(16)}; width: 100%; max-width: 640px; }`,
|
|
11390
|
+
`.pg-center { min-height: 100dvh; display: grid; place-items: center; padding: ${sp(24)}; }`,
|
|
11391
|
+
`.pg-center .pg-narrow { max-width: 400px; }`,
|
|
11392
|
+
`@media (max-width: 640px) { .pg { padding: ${sp(24)} ${sp(16)}; } .pg-header { flex-direction: column; } }`
|
|
11393
|
+
].join("\n");
|
|
11394
|
+
}
|
|
11395
|
+
var LAYOUT_TAG = { page: "main", header: "header", stack: "div", row: "div", grid: "div", actions: "div", center: "main", narrow: "div" };
|
|
11396
|
+
var LAYOUT_CLASS = { page: "pg", header: "pg-header", stack: "pg-stack", row: "pg-row", grid: "pg-grid", actions: "pg-actions", center: "pg pg-center", narrow: "pg-narrow" };
|
|
11397
|
+
var TEXT_TAG = { h1: "h1", h2: "h2", p: "p", muted: "p", stat: "p" };
|
|
11398
|
+
var TEXT_CLASS = { h1: "", h2: "", p: "", muted: "pg-muted", stat: "pg-stat" };
|
|
11399
|
+
function walk(n, visit2) {
|
|
11400
|
+
if (n.kind === "c") {
|
|
11401
|
+
visit2(n);
|
|
11402
|
+
n.children?.forEach((c) => walk(c, visit2));
|
|
11403
|
+
} else if (n.kind === "layout") n.children.forEach((c) => walk(c, visit2));
|
|
11404
|
+
}
|
|
11405
|
+
var esc3 = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
11406
|
+
var attrEsc = (s) => s.replace(/&/g, "&").replace(/"/g, """);
|
|
11407
|
+
var jsonAttr = (v) => JSON.stringify(v).replace(/'/g, "'");
|
|
11408
|
+
var ind = (d) => " ".repeat(d);
|
|
11409
|
+
function missing(part, d, ctx) {
|
|
11410
|
+
const msg = `${pascal2(part.node.part)}: no ${part.node.component} in your registry for ${FRAMEWORK_LABEL[ctx.fw]}. Ask find_component for "${part.node.purpose.toLowerCase()}", or build it with semantic HTML and the design tokens.`;
|
|
11411
|
+
return ctx.fw === "react" ? `${ind(d)}{/* ${msg} */}` : `${ind(d)}<!-- ${msg} -->`;
|
|
11412
|
+
}
|
|
11413
|
+
function actStatement(a, ctx, value) {
|
|
11414
|
+
if ("store" in a) return ctx.fw === "react" ? `${setter(a.store)}(${value})` : `${ctx.fw === "angular" ? "this." : ""}${a.store} = ${value}`;
|
|
11415
|
+
const assign = ctx.fw === "react" ? `${setter(a.set)}(${a.to})` : ctx.fw === "vue" ? `${a.set}.value = ${a.to}` : `this.${a.set} = ${a.to}`;
|
|
11416
|
+
return a.when ? `if (${value} === ${JSON.stringify(a.when)}) ${assign};` : `${assign};`;
|
|
11417
|
+
}
|
|
11418
|
+
function renderNode(n, d, ctx) {
|
|
11419
|
+
if (n.kind === "text") {
|
|
11420
|
+
const tag = TEXT_TAG[n.as];
|
|
11421
|
+
const cls = TEXT_CLASS[n.as];
|
|
11422
|
+
const attr = cls ? ` ${ctx.fw === "react" ? "className" : "class"}="${cls}"` : "";
|
|
11423
|
+
return `${ind(d)}<${tag}${attr}>${esc3(n.text)}</${tag}>`;
|
|
11424
|
+
}
|
|
11425
|
+
if (n.kind === "layout") {
|
|
11426
|
+
const tag = LAYOUT_TAG[n.as];
|
|
11427
|
+
const attr = `${ctx.fw === "react" ? "className" : "class"}="${LAYOUT_CLASS[n.as]}"`;
|
|
11428
|
+
return [`${ind(d)}<${tag} ${attr}>`, ...n.children.map((c) => renderNode(c, d + 1, ctx)), `${ind(d)}</${tag}>`].join("\n");
|
|
11429
|
+
}
|
|
11430
|
+
const part = ctx.parts.get(n);
|
|
11431
|
+
if (!part.usage) {
|
|
11432
|
+
const kids = (n.children ?? []).map((c) => renderNode(c, d, ctx));
|
|
11433
|
+
return [missing(part, d, ctx), ...kids].join("\n");
|
|
11434
|
+
}
|
|
11435
|
+
return ctx.fw === "react" ? renderReact(part, d, ctx) : renderMarkup(part, d, ctx);
|
|
11436
|
+
}
|
|
11437
|
+
function renderReact(part, d, ctx) {
|
|
11438
|
+
const { node: node2, usage, component } = part;
|
|
11439
|
+
const attrs = [];
|
|
11440
|
+
const isKit = component?.importPath === KIT2;
|
|
11441
|
+
if (isKit) attrs.push(`theme="brandrail"`);
|
|
11442
|
+
for (const [, name, value, spec] of acceptedProps(part, "react")) {
|
|
11443
|
+
if (node2.bind?.[name]) continue;
|
|
11444
|
+
if (isData(value)) attrs.push(`${name}={${value.$data}}`);
|
|
11445
|
+
else if (value === true) attrs.push(name);
|
|
11446
|
+
else if (typeof value === "string") {
|
|
11447
|
+
const e = isKit ? enumOf(spec?.type, value) : void 0;
|
|
11448
|
+
if (e) {
|
|
11449
|
+
attrs.push(`${name}={${e.ref}}`);
|
|
11450
|
+
const set2 = ctx.imports.get(component.importPath) ?? /* @__PURE__ */ new Set();
|
|
11451
|
+
set2.add(e.name);
|
|
11452
|
+
ctx.imports.set(component.importPath, set2);
|
|
11453
|
+
} else attrs.push(`${name}="${attrEsc(value)}"`);
|
|
11454
|
+
} else attrs.push(`${name}={${JSON.stringify(value)}}`);
|
|
11455
|
+
}
|
|
11456
|
+
for (const [prop, v] of Object.entries(node2.bind ?? {})) attrs.push(`${prop}={${v}}`);
|
|
11457
|
+
for (const [prop, a] of Object.entries(node2.on ?? {})) {
|
|
11458
|
+
if ("store" in a) attrs.push(`${prop}={${setter(a.store)}}`);
|
|
11459
|
+
else if (a.when) attrs.push(`${prop}={(value) => { ${actStatement(a, ctx, "value")} }}`);
|
|
11460
|
+
else attrs.push(`${prop}={() => ${setter(a.set)}(${a.to})}`);
|
|
11461
|
+
}
|
|
11462
|
+
const open2 = `${ind(d)}<${usage.tag}${attrs.length ? ` ${attrs.join(" ")}` : ""}`;
|
|
11463
|
+
if (!node2.children?.length) return `${open2} />`;
|
|
11464
|
+
return [`${open2}>`, ...node2.children.map((c) => renderNode(c, d + 1, ctx)), `${ind(d)}</${usage.tag}>`].join("\n");
|
|
11465
|
+
}
|
|
11466
|
+
function renderMarkup(part, d, ctx) {
|
|
11467
|
+
const { node: node2, usage } = part;
|
|
11468
|
+
const fw = ctx.fw;
|
|
11469
|
+
const attrs = [];
|
|
11470
|
+
const id = node2.part;
|
|
11471
|
+
const needsId = fw === "html" || fw === "web-components";
|
|
11472
|
+
const hasEvents = Object.keys(node2.on ?? {}).length > 0;
|
|
11473
|
+
if (needsId && (hasEvents || isBoundTarget(node2, ctx))) attrs.push(`id="${id}"`);
|
|
11474
|
+
for (const [prop, name, value] of acceptedProps(part, fw)) {
|
|
11475
|
+
if (node2.bind?.[prop]) continue;
|
|
11476
|
+
if (isData(value)) {
|
|
11477
|
+
if (fw === "angular") attrs.push(`[${camel(prop)}]="${value.$data}"`);
|
|
11478
|
+
else if (fw === "vue") attrs.push(`:${camel(prop)}="${value.$data}"`);
|
|
11479
|
+
else attrs.push(`${name}='${jsonAttr(ctx.tpl.data[value.$data])}'`);
|
|
11480
|
+
} else if (value === true) attrs.push(name);
|
|
11481
|
+
else if (typeof value === "string") attrs.push(`${name}="${attrEsc(value)}"`);
|
|
11482
|
+
else attrs.push(`${name}='${jsonAttr(value)}'`);
|
|
11483
|
+
}
|
|
11484
|
+
for (const [prop, v] of Object.entries(node2.bind ?? {})) {
|
|
11485
|
+
const start = ctx.tpl.state[v];
|
|
11486
|
+
const name = acceptedProps({ ...part, node: { ...node2, props: { [prop]: true } } }, fw)[0]?.[1] ?? kebab3(prop);
|
|
11487
|
+
if (fw === "angular") attrs.push(`[${camel(prop)}]="${v}"`);
|
|
11488
|
+
else if (fw === "vue") attrs.push(`:${camel(prop)}="${v}"`);
|
|
11489
|
+
else if (typeof start === "boolean") attrs.push(start ? name : `${name}="false"`);
|
|
11490
|
+
else if (typeof start === "string") attrs.push(`${name}="${attrEsc(start)}"`);
|
|
11491
|
+
}
|
|
11492
|
+
for (const [prop, a] of Object.entries(node2.on ?? {})) {
|
|
11493
|
+
const ev = eventFor(part, prop);
|
|
11494
|
+
const custom2 = usage.customElement || usage.via === "web-components";
|
|
11495
|
+
const detail = fw === "angular" ? custom2 ? "$any($event).detail" : "$event" : custom2 ? "$event.detail" : "$event";
|
|
11496
|
+
if (fw === "angular" || fw === "vue") {
|
|
11497
|
+
if ("store" in a) attrs.push(`${fw === "angular" ? `(${ev})` : `@${ev}`}="${a.store} = ${detail}"`);
|
|
11498
|
+
else if (a.when) {
|
|
11499
|
+
const name = `on${pascal2(node2.part)}${pascal2(prop.replace(/^on/, ""))}`;
|
|
11500
|
+
ctx.handlers.push({ name, param: true, body: [actStatement(a, ctx, "value")] });
|
|
11501
|
+
attrs.push(`${fw === "angular" ? `(${ev})` : `@${ev}`}="${name}(${detail})"`);
|
|
11502
|
+
} else attrs.push(`${fw === "angular" ? `(${ev})` : `@${ev}`}="${a.set} = ${a.to}"`);
|
|
11503
|
+
} else if (!("store" in a)) {
|
|
11504
|
+
for (const target of boundTargets(a.set, ctx)) {
|
|
11505
|
+
const tPart = ctx.parts.get(target);
|
|
11506
|
+
const [prop2] = Object.entries(target.bind).find(([, v]) => v === a.set);
|
|
11507
|
+
const attrName = acceptedProps({ ...tPart, node: { ...target, props: { [prop2]: true } } }, fw)[0]?.[1] ?? kebab3(prop2);
|
|
11508
|
+
const set2 = a.to ? `setAttribute("${attrName}", "")` : `setAttribute("${attrName}", "false")`;
|
|
11509
|
+
const body = `document.getElementById("${target.part}").${set2}`;
|
|
11510
|
+
ctx.listeners.push(`document.getElementById("${id}").addEventListener("${ev}", (e) => ${a.when ? `{ if (e.detail === ${JSON.stringify(a.when)}) ${body}; }` : body});`);
|
|
11511
|
+
}
|
|
11512
|
+
}
|
|
11513
|
+
}
|
|
11514
|
+
const open2 = `${ind(d)}<${usage.tag}${attrs.length ? ` ${attrs.join(" ")}` : ""}>`;
|
|
11515
|
+
if (!node2.children?.length) return `${open2}</${usage.tag}>`;
|
|
11516
|
+
return [open2, ...node2.children.map((c) => renderNode(c, d + 1, ctx)), `${ind(d)}</${usage.tag}>`].join("\n");
|
|
11517
|
+
}
|
|
11518
|
+
function boundTargets(stateVar, ctx) {
|
|
11519
|
+
const out = [];
|
|
11520
|
+
walk(ctx.tpl.tree, (n) => {
|
|
11521
|
+
if (Object.values(n.bind ?? {}).includes(stateVar)) out.push(n);
|
|
11522
|
+
});
|
|
11523
|
+
return out;
|
|
11524
|
+
}
|
|
11525
|
+
function isBoundTarget(n, ctx) {
|
|
11526
|
+
if (!n.bind) return false;
|
|
11527
|
+
let hit = false;
|
|
11528
|
+
walk(ctx.tpl.tree, (m) => {
|
|
11529
|
+
for (const a of Object.values(m.on ?? {})) if (!("store" in a) && Object.values(n.bind).includes(a.set)) hit = true;
|
|
11530
|
+
});
|
|
11531
|
+
return hit;
|
|
11532
|
+
}
|
|
11533
|
+
function renderTemplate(config2, template, framework) {
|
|
11534
|
+
const resolved = resolveConfig(config2);
|
|
11535
|
+
const fw = framework === "web-components" ? "html" : framework;
|
|
11536
|
+
const parts = /* @__PURE__ */ new Map();
|
|
11537
|
+
walk(template.tree, (node2) => {
|
|
11538
|
+
const component = resolvePart(resolved, node2.component);
|
|
11539
|
+
parts.set(node2, { node: node2, component, usage: component ? resolveUsage(component, framework) : null });
|
|
11540
|
+
});
|
|
11541
|
+
const ctx = { fw, parts, tpl: template, imports: /* @__PURE__ */ new Map(), handlers: [], listeners: [] };
|
|
11542
|
+
const base = template.id;
|
|
11543
|
+
const Name = `${pascal2(base)}Page`;
|
|
11544
|
+
const css = templateCss(config2);
|
|
11545
|
+
const importLines = /* @__PURE__ */ new Set();
|
|
11546
|
+
const setup = /* @__PURE__ */ new Set();
|
|
11547
|
+
for (const p of parts.values()) {
|
|
11548
|
+
if (!p.usage) continue;
|
|
11549
|
+
if (p.usage.setup) setup.add(p.usage.setup);
|
|
11550
|
+
if (fw !== "react" && p.usage.importLine) importLines.add(p.usage.importLine);
|
|
11551
|
+
}
|
|
11552
|
+
if (fw === "react" && [...parts.values()].some((p) => p.usage && p.component?.importPath === KIT2)) {
|
|
11553
|
+
setup.add(`Import \`${KIT2}/styles.css\` and \`brandrail.tokens.css\` once at the app entry.`);
|
|
11554
|
+
} else setup.add("Import `brandrail.tokens.css` (from `npx brandrail init`) once at the app entry, so the layout and components get the Brand Kit's variables.");
|
|
11555
|
+
const body = renderNode(template.tree, fw === "react" ? 2 : fw === "vue" ? 1 : 0, ctx);
|
|
11556
|
+
const usedData = Object.keys(template.data).filter((k) => JSON.stringify(template.tree).includes(`"$data":"${k}"`));
|
|
11557
|
+
const dataDecl = (decl, kw, pad = "", key = decl) => `${kw} ${decl} = ${literal(template.data[key], pad)};`;
|
|
11558
|
+
const files = [];
|
|
11559
|
+
if (fw === "react") {
|
|
11560
|
+
const dataType = /* @__PURE__ */ new Map();
|
|
11561
|
+
for (const p of parts.values()) {
|
|
11562
|
+
if (p.component?.importPath !== KIT2 || !p.usage) continue;
|
|
11563
|
+
for (const [, , value, spec] of acceptedProps(p, "react")) {
|
|
11564
|
+
const m = isData(value) && spec?.type ? /^(\w+)\[\]$/.exec(spec.type) : null;
|
|
11565
|
+
if (m && KIT_TYPES.has(m[1])) {
|
|
11566
|
+
dataType.set(value.$data, `${m[1]}[]`);
|
|
11567
|
+
const set2 = ctx.imports.get(KIT2) ?? /* @__PURE__ */ new Set();
|
|
11568
|
+
set2.add(`type ${m[1]}`);
|
|
11569
|
+
ctx.imports.set(KIT2, set2);
|
|
11570
|
+
}
|
|
11571
|
+
}
|
|
11572
|
+
}
|
|
11573
|
+
const byPkg = /* @__PURE__ */ new Map();
|
|
11574
|
+
for (const p of parts.values()) {
|
|
11575
|
+
if (!p.usage || !p.component) continue;
|
|
11576
|
+
const set2 = byPkg.get(p.component.importPath) ?? /* @__PURE__ */ new Set();
|
|
11577
|
+
set2.add(p.component.name);
|
|
11578
|
+
byPkg.set(p.component.importPath, set2);
|
|
11579
|
+
}
|
|
11580
|
+
for (const [pkg, names] of ctx.imports) for (const n of names) byPkg.get(pkg)?.add(n);
|
|
11581
|
+
const state = Object.entries(template.state);
|
|
11582
|
+
const code = [
|
|
11583
|
+
...state.length ? [`import { useState } from "react";`] : [],
|
|
11584
|
+
...[...byPkg].map(([pkg, names]) => `import { ${[...names].sort((a, b) => a.replace(/^type /, "").localeCompare(b.replace(/^type /, ""))).join(", ")} } from "${pkg}";`),
|
|
11585
|
+
`import "./${base}-page.css";`,
|
|
11586
|
+
"",
|
|
11587
|
+
...usedData.flatMap((k) => [dataDecl(dataType.has(k) ? `${k}: ${dataType.get(k)}` : k, "const", "", k), ""]),
|
|
11588
|
+
`export default function ${Name}() {`,
|
|
11589
|
+
...state.map(([k, v]) => ` const [${k}, ${setter(k)}] = useState(${JSON.stringify(v)});`),
|
|
11590
|
+
...state.length ? [""] : [],
|
|
11591
|
+
" return (",
|
|
11592
|
+
body,
|
|
11593
|
+
" );",
|
|
11594
|
+
"}",
|
|
11595
|
+
""
|
|
11596
|
+
].join("\n");
|
|
11597
|
+
files.push({ path: `${pascal2(base)}Page.tsx`, lang: "tsx", content: code }, { path: `${base}-page.css`, lang: "css", content: css + "\n" });
|
|
11598
|
+
} else if (fw === "angular") {
|
|
11599
|
+
const wc = [...parts.values()].some((p) => p.usage && (p.usage.via === "web-components" || p.usage.customElement));
|
|
11600
|
+
const ngImports = [...parts.values()].filter((p) => p.usage?.importLine && !(p.usage.via === "web-components" || p.usage.customElement)).map((p) => /import \{ (\w+) \}/.exec(p.usage.importLine)?.[1]).filter(Boolean);
|
|
11601
|
+
const ts = [
|
|
11602
|
+
`import { Component${wc ? ", CUSTOM_ELEMENTS_SCHEMA" : ""} } from "@angular/core";`,
|
|
11603
|
+
...[...importLines],
|
|
11604
|
+
"",
|
|
11605
|
+
"@Component({",
|
|
11606
|
+
` selector: "app-${base}-page",`,
|
|
11607
|
+
" standalone: true,",
|
|
11608
|
+
...ngImports.length ? [` imports: [${[...new Set(ngImports)].join(", ")}],`] : [],
|
|
11609
|
+
...wc ? [" schemas: [CUSTOM_ELEMENTS_SCHEMA],"] : [],
|
|
11610
|
+
` templateUrl: "./${base}-page.component.html",`,
|
|
11611
|
+
` styleUrl: "./${base}-page.component.css",`,
|
|
11612
|
+
"})",
|
|
11613
|
+
`export class ${Name}Component {`,
|
|
11614
|
+
...Object.entries(template.state).map(([k, v]) => ` ${k} = ${JSON.stringify(v)};`),
|
|
11615
|
+
...usedData.map((k) => ` ${dataDecl(k, "readonly", " ")}`),
|
|
11616
|
+
...ctx.handlers.map((h) => `
|
|
11617
|
+
${h.name}(value: string) {
|
|
11618
|
+
${h.body.join("\n ")}
|
|
11619
|
+
}`),
|
|
11620
|
+
"}",
|
|
11621
|
+
""
|
|
11622
|
+
].join("\n");
|
|
11623
|
+
files.push(
|
|
11624
|
+
{ path: `${base}-page.component.ts`, lang: "ts", content: ts },
|
|
11625
|
+
{ path: `${base}-page.component.html`, lang: "html", content: body + "\n" },
|
|
11626
|
+
{ path: `${base}-page.component.css`, lang: "css", content: css + "\n" }
|
|
11627
|
+
);
|
|
11628
|
+
} else if (fw === "vue") {
|
|
11629
|
+
const state = Object.entries(template.state);
|
|
11630
|
+
const script = [
|
|
11631
|
+
`<script setup lang="ts">`,
|
|
11632
|
+
...state.length ? [`import { ref } from "vue";`] : [],
|
|
11633
|
+
...[...importLines],
|
|
11634
|
+
...state.length || usedData.length ? [""] : [],
|
|
11635
|
+
...state.map(([k, v]) => `const ${k} = ref(${JSON.stringify(v)});`),
|
|
11636
|
+
...usedData.map((k) => dataDecl(k, "const")),
|
|
11637
|
+
...ctx.handlers.map((h) => `
|
|
11638
|
+
function ${h.name}(value: string) {
|
|
11639
|
+
${h.body.join("\n ")}
|
|
11640
|
+
}`),
|
|
11641
|
+
`</script>`
|
|
11642
|
+
].join("\n");
|
|
11643
|
+
files.push({ path: `${pascal2(base)}Page.vue`, lang: "vue", content: `${script}
|
|
11644
|
+
|
|
11645
|
+
<template>
|
|
11646
|
+
${body}
|
|
11647
|
+
</template>
|
|
11648
|
+
|
|
11649
|
+
<style scoped>
|
|
11650
|
+
${css}
|
|
11651
|
+
</style>
|
|
11652
|
+
` });
|
|
11653
|
+
} else {
|
|
11654
|
+
const loads = [
|
|
11655
|
+
...new Set(
|
|
11656
|
+
[...parts.values()].filter((p) => p.usage && (p.usage.via === "web-components" || p.usage.customElement)).map((p) => p.component?.frameworks?.["web-components"]?.importPath ?? p.component?.frameworks?.html?.importPath).filter((x2) => !!x2 && !/\.css(\?|$)/.test(x2))
|
|
11657
|
+
)
|
|
11658
|
+
];
|
|
11659
|
+
const html = [
|
|
11660
|
+
"<!doctype html>",
|
|
11661
|
+
`<html lang="en">`,
|
|
11662
|
+
"<head>",
|
|
11663
|
+
` <meta charset="utf-8" />`,
|
|
11664
|
+
` <meta name="viewport" content="width=device-width, initial-scale=1" />`,
|
|
11665
|
+
` <title>${esc3(template.name)}</title>`,
|
|
11666
|
+
` <link rel="stylesheet" href="brandrail.tokens.css" />`,
|
|
11667
|
+
` <link rel="stylesheet" href="${base}-page.css" />`,
|
|
11668
|
+
...loads.map(
|
|
11669
|
+
(u) => u === `${KIT2}/elements` ? ` <script type="module" src="https://cdn.jsdelivr.net/npm/${KIT2}@0.3/dist/elements.js"></script>` : ` <!-- Bundle this import, or map "${u}" to a URL with an import map. -->
|
|
11670
|
+
<script type="module">import "${u}";</script>`
|
|
11671
|
+
),
|
|
11672
|
+
"</head>",
|
|
11673
|
+
"<body>",
|
|
11674
|
+
body.split("\n").map((l) => ` ${l}`).join("\n"),
|
|
11675
|
+
...ctx.listeners.length ? [' <script type="module">', ...ctx.listeners.map((l) => ` ${l}`), " </script>"] : [],
|
|
11676
|
+
"</body>",
|
|
11677
|
+
"</html>",
|
|
11678
|
+
""
|
|
11679
|
+
].join("\n");
|
|
11680
|
+
files.push({ path: `${base}-page.html`, lang: "html", content: html }, { path: `${base}-page.css`, lang: "css", content: css + "\n" });
|
|
11681
|
+
}
|
|
11682
|
+
const list = [];
|
|
11683
|
+
for (const p of parts.values()) {
|
|
11684
|
+
list.push({
|
|
11685
|
+
part: p.node.part,
|
|
11686
|
+
purpose: p.node.purpose,
|
|
11687
|
+
component: p.usage ? p.component.name : void 0,
|
|
11688
|
+
tag: p.usage?.tag,
|
|
11689
|
+
importLine: p.usage?.importLine,
|
|
11690
|
+
setup: p.usage?.setup
|
|
11691
|
+
});
|
|
11692
|
+
}
|
|
11693
|
+
return { template, framework, files, parts: list, setup: [...setup] };
|
|
11694
|
+
}
|
|
11695
|
+
function templateMarkdown(config2, template, framework, org) {
|
|
11696
|
+
const r = renderTemplate(config2, template, framework);
|
|
11697
|
+
const missingParts = r.parts.filter((p) => !p.component);
|
|
11698
|
+
const lines = [
|
|
11699
|
+
`# ${template.name} template${org ? ` (${org})` : ""} \xB7 ${FRAMEWORK_LABEL[framework]}`,
|
|
11700
|
+
"",
|
|
11701
|
+
template.description,
|
|
11702
|
+
"",
|
|
11703
|
+
"Start from these files: rename the sample data and labels to the real ones, keep the structure, components and layout classes. Then call validate_snippet with the files you wrote.",
|
|
11704
|
+
""
|
|
11705
|
+
];
|
|
11706
|
+
if (r.setup.length) lines.push("## Setup (once per app)", "", ...r.setup.map((s) => `- ${s}`), "");
|
|
11707
|
+
lines.push("## Files", "");
|
|
11708
|
+
for (const f of r.files) lines.push(`### ${f.path}`, "", "```" + f.lang, f.content.trimEnd(), "```", "");
|
|
11709
|
+
lines.push("## Parts", "", "| Part | Purpose | Component |", "| --- | --- | --- |");
|
|
11710
|
+
for (const p of r.parts) lines.push(`| ${p.part} | ${p.purpose} | ${p.component ? `${p.component} (\`<${p.tag}>\`)` : "_none in the registry_"} |`);
|
|
11711
|
+
if (missingParts.length) {
|
|
11712
|
+
lines.push("", `${missingParts.length} part${missingParts.length === 1 ? " has" : "s have"} no component in the registry for ${FRAMEWORK_LABEL[framework]}. Use find_component for each; if nothing fits, build it with semantic HTML and the design tokens, never another UI library.`);
|
|
11713
|
+
}
|
|
11714
|
+
lines.push("", "## Rules", "", ...[...template.rules, ...COMMON_RULES].map((x2) => `- ${x2}`), "");
|
|
11715
|
+
return lines.join("\n");
|
|
11716
|
+
}
|
|
11717
|
+
function templateList() {
|
|
11718
|
+
return PAGE_TEMPLATES.map((t) => `- \`${t.id}\` \u2014 ${t.name}: ${t.description}`).join("\n");
|
|
11719
|
+
}
|
|
11720
|
+
|
|
10945
11721
|
// src/api.ts
|
|
10946
11722
|
var DEFAULT_API = "https://www.brandrail.com.au";
|
|
10947
11723
|
function apiBase() {
|
|
@@ -11284,7 +12060,7 @@ __export(external_exports, {
|
|
|
11284
12060
|
ksuid: () => ksuid2,
|
|
11285
12061
|
lazy: () => lazy,
|
|
11286
12062
|
length: () => _length,
|
|
11287
|
-
literal: () =>
|
|
12063
|
+
literal: () => literal2,
|
|
11288
12064
|
locales: () => locales_exports,
|
|
11289
12065
|
looseObject: () => looseObject,
|
|
11290
12066
|
looseRecord: () => looseRecord,
|
|
@@ -11730,7 +12506,7 @@ __export(util_exports, {
|
|
|
11730
12506
|
defineLazy: () => defineLazy,
|
|
11731
12507
|
defineLazyInternal: () => defineLazyInternal,
|
|
11732
12508
|
derived: () => derived,
|
|
11733
|
-
esc: () =>
|
|
12509
|
+
esc: () => esc4,
|
|
11734
12510
|
escapeRegex: () => escapeRegex,
|
|
11735
12511
|
explicitlyAborted: () => explicitlyAborted,
|
|
11736
12512
|
extend: () => extend,
|
|
@@ -11961,7 +12737,7 @@ function randomString(length = 10) {
|
|
|
11961
12737
|
}
|
|
11962
12738
|
return str;
|
|
11963
12739
|
}
|
|
11964
|
-
function
|
|
12740
|
+
function esc4(str) {
|
|
11965
12741
|
return JSON.stringify(str);
|
|
11966
12742
|
}
|
|
11967
12743
|
function slugify(input2) {
|
|
@@ -11969,8 +12745,8 @@ function slugify(input2) {
|
|
|
11969
12745
|
}
|
|
11970
12746
|
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
|
|
11971
12747
|
};
|
|
11972
|
-
function isObject(
|
|
11973
|
-
return typeof
|
|
12748
|
+
function isObject(data2) {
|
|
12749
|
+
return typeof data2 === "object" && data2 !== null && !Array.isArray(data2);
|
|
11974
12750
|
}
|
|
11975
12751
|
var allowsEval = /* @__PURE__ */ cached(() => {
|
|
11976
12752
|
if (globalConfig.jitless) {
|
|
@@ -12014,24 +12790,24 @@ function shallowClone(o) {
|
|
|
12014
12790
|
return new Set(o);
|
|
12015
12791
|
return o;
|
|
12016
12792
|
}
|
|
12017
|
-
function numKeys(
|
|
12793
|
+
function numKeys(data2) {
|
|
12018
12794
|
let keyCount = 0;
|
|
12019
|
-
for (const key in
|
|
12020
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
12795
|
+
for (const key in data2) {
|
|
12796
|
+
if (Object.prototype.hasOwnProperty.call(data2, key)) {
|
|
12021
12797
|
keyCount++;
|
|
12022
12798
|
}
|
|
12023
12799
|
}
|
|
12024
12800
|
return keyCount;
|
|
12025
12801
|
}
|
|
12026
|
-
var getParsedType = (
|
|
12027
|
-
const t = typeof
|
|
12802
|
+
var getParsedType = (data2) => {
|
|
12803
|
+
const t = typeof data2;
|
|
12028
12804
|
switch (t) {
|
|
12029
12805
|
case "undefined":
|
|
12030
12806
|
return "undefined";
|
|
12031
12807
|
case "string":
|
|
12032
12808
|
return "string";
|
|
12033
12809
|
case "number":
|
|
12034
|
-
return Number.isNaN(
|
|
12810
|
+
return Number.isNaN(data2) ? "nan" : "number";
|
|
12035
12811
|
case "boolean":
|
|
12036
12812
|
return "boolean";
|
|
12037
12813
|
case "function":
|
|
@@ -12041,25 +12817,25 @@ var getParsedType = (data) => {
|
|
|
12041
12817
|
case "symbol":
|
|
12042
12818
|
return "symbol";
|
|
12043
12819
|
case "object":
|
|
12044
|
-
if (Array.isArray(
|
|
12820
|
+
if (Array.isArray(data2)) {
|
|
12045
12821
|
return "array";
|
|
12046
12822
|
}
|
|
12047
|
-
if (
|
|
12823
|
+
if (data2 === null) {
|
|
12048
12824
|
return "null";
|
|
12049
12825
|
}
|
|
12050
|
-
if (
|
|
12826
|
+
if (data2.then && typeof data2.then === "function" && data2.catch && typeof data2.catch === "function") {
|
|
12051
12827
|
return "promise";
|
|
12052
12828
|
}
|
|
12053
|
-
if (typeof Map !== "undefined" &&
|
|
12829
|
+
if (typeof Map !== "undefined" && data2 instanceof Map) {
|
|
12054
12830
|
return "map";
|
|
12055
12831
|
}
|
|
12056
|
-
if (typeof Set !== "undefined" &&
|
|
12832
|
+
if (typeof Set !== "undefined" && data2 instanceof Set) {
|
|
12057
12833
|
return "set";
|
|
12058
12834
|
}
|
|
12059
|
-
if (typeof Date !== "undefined" &&
|
|
12835
|
+
if (typeof Date !== "undefined" && data2 instanceof Date) {
|
|
12060
12836
|
return "date";
|
|
12061
12837
|
}
|
|
12062
|
-
if (typeof File !== "undefined" &&
|
|
12838
|
+
if (typeof File !== "undefined" && data2 instanceof File) {
|
|
12063
12839
|
return "file";
|
|
12064
12840
|
}
|
|
12065
12841
|
return "object";
|
|
@@ -12363,20 +13139,20 @@ function getLengthableOrigin(input2) {
|
|
|
12363
13139
|
return "string";
|
|
12364
13140
|
return "unknown";
|
|
12365
13141
|
}
|
|
12366
|
-
function parsedType(
|
|
12367
|
-
const t = typeof
|
|
13142
|
+
function parsedType(data2) {
|
|
13143
|
+
const t = typeof data2;
|
|
12368
13144
|
switch (t) {
|
|
12369
13145
|
case "number": {
|
|
12370
|
-
return Number.isNaN(
|
|
13146
|
+
return Number.isNaN(data2) ? "nan" : "number";
|
|
12371
13147
|
}
|
|
12372
13148
|
case "object": {
|
|
12373
|
-
if (
|
|
13149
|
+
if (data2 === null) {
|
|
12374
13150
|
return "null";
|
|
12375
13151
|
}
|
|
12376
|
-
if (Array.isArray(
|
|
13152
|
+
if (Array.isArray(data2)) {
|
|
12377
13153
|
return "array";
|
|
12378
13154
|
}
|
|
12379
|
-
const obj =
|
|
13155
|
+
const obj = data2;
|
|
12380
13156
|
if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
|
|
12381
13157
|
return obj.constructor.name;
|
|
12382
13158
|
}
|
|
@@ -14128,15 +14904,15 @@ var $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
14128
14904
|
}
|
|
14129
14905
|
};
|
|
14130
14906
|
});
|
|
14131
|
-
function isValidBase64(
|
|
14132
|
-
if (
|
|
14907
|
+
function isValidBase64(data2) {
|
|
14908
|
+
if (data2 === "")
|
|
14133
14909
|
return true;
|
|
14134
|
-
if (/\s/.test(
|
|
14910
|
+
if (/\s/.test(data2))
|
|
14135
14911
|
return false;
|
|
14136
|
-
if (
|
|
14912
|
+
if (data2.length % 4 !== 0)
|
|
14137
14913
|
return false;
|
|
14138
14914
|
try {
|
|
14139
|
-
atob(
|
|
14915
|
+
atob(data2);
|
|
14140
14916
|
return true;
|
|
14141
14917
|
} catch {
|
|
14142
14918
|
return false;
|
|
@@ -14159,10 +14935,10 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
|
14159
14935
|
};
|
|
14160
14936
|
});
|
|
14161
14937
|
var base64urlCharset = /^[A-Za-z0-9_-]*$/;
|
|
14162
|
-
function isValidBase64URL(
|
|
14163
|
-
if (!base64urlCharset.test(
|
|
14938
|
+
function isValidBase64URL(data2) {
|
|
14939
|
+
if (!base64urlCharset.test(data2))
|
|
14164
14940
|
return false;
|
|
14165
|
-
const base643 =
|
|
14941
|
+
const base643 = data2.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
|
|
14166
14942
|
const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
|
|
14167
14943
|
return isValidBase64(padded);
|
|
14168
14944
|
}
|
|
@@ -14761,7 +15537,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
14761
15537
|
if (key === "__proto__")
|
|
14762
15538
|
continue;
|
|
14763
15539
|
const id = ids[key];
|
|
14764
|
-
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` :
|
|
15540
|
+
const k = typeof key === "symbol" ? `syms[${syms.indexOf(key)}]` : esc4(key);
|
|
14765
15541
|
const isPresent = `${k} in input`;
|
|
14766
15542
|
const schema = shape[key];
|
|
14767
15543
|
const optin = schema?._zod?.optin;
|
|
@@ -24133,22 +24909,22 @@ function installCompiledUserMethods(target, source, parser) {
|
|
|
24133
24909
|
const sourceAny = source;
|
|
24134
24910
|
if (typeof sourceAny.safeParse === "function") {
|
|
24135
24911
|
const originalSafeParse = sourceAny.safeParse;
|
|
24136
|
-
targetAny.safeParse = (
|
|
24137
|
-
const out = parser(
|
|
24912
|
+
targetAny.safeParse = (data2, params) => {
|
|
24913
|
+
const out = parser(data2);
|
|
24138
24914
|
if (out !== INVALID) {
|
|
24139
24915
|
return { success: true, data: out };
|
|
24140
24916
|
}
|
|
24141
|
-
return originalSafeParse(
|
|
24917
|
+
return originalSafeParse(data2, params);
|
|
24142
24918
|
};
|
|
24143
24919
|
}
|
|
24144
24920
|
if (typeof sourceAny.parse === "function") {
|
|
24145
24921
|
const originalParse = sourceAny.parse;
|
|
24146
|
-
targetAny.parse = (
|
|
24147
|
-
const out = parser(
|
|
24922
|
+
targetAny.parse = (data2, params) => {
|
|
24923
|
+
const out = parser(data2);
|
|
24148
24924
|
if (out !== INVALID) {
|
|
24149
24925
|
return out;
|
|
24150
24926
|
}
|
|
24151
|
-
return originalParse(
|
|
24927
|
+
return originalParse(data2, params);
|
|
24152
24928
|
};
|
|
24153
24929
|
}
|
|
24154
24930
|
}
|
|
@@ -24436,7 +25212,7 @@ function generatePropertiesChecks(doc, ctx, def, accessor) {
|
|
|
24436
25212
|
doc.write(`if (${accessor} == null) return INVALID;`);
|
|
24437
25213
|
const shape = def.shape;
|
|
24438
25214
|
for (const key of Reflect.ownKeys(shape)) {
|
|
24439
|
-
const keyExpr = typeof key === "symbol" ? addConstant(ctx, key) :
|
|
25215
|
+
const keyExpr = typeof key === "symbol" ? addConstant(ctx, key) : esc4(key);
|
|
24440
25216
|
const inputVar = newVar(ctx);
|
|
24441
25217
|
doc.write(`const ${inputVar} = ${accessor}[${keyExpr}];`);
|
|
24442
25218
|
compileChild(doc, ctx, shape[key], inputVar, false);
|
|
@@ -24610,16 +25386,16 @@ function generateStringFormatCheck(doc, ctx, def, accessor, needsValue = true) {
|
|
|
24610
25386
|
doc.write(`if (${accessor} !== ${accessor}.toUpperCase()) return INVALID;`);
|
|
24611
25387
|
break;
|
|
24612
25388
|
case "includes":
|
|
24613
|
-
doc.write(`if (!${accessor}.includes(${
|
|
25389
|
+
doc.write(`if (!${accessor}.includes(${esc4(def.includes)})) return INVALID;`);
|
|
24614
25390
|
break;
|
|
24615
25391
|
case "starts_with": {
|
|
24616
25392
|
const prefix = def.prefix;
|
|
24617
|
-
doc.write(`if (${accessor}.slice(0, ${prefix.length}) !== ${
|
|
25393
|
+
doc.write(`if (${accessor}.slice(0, ${prefix.length}) !== ${esc4(prefix)}) return INVALID;`);
|
|
24618
25394
|
break;
|
|
24619
25395
|
}
|
|
24620
25396
|
case "ends_with": {
|
|
24621
25397
|
const suffix = def.suffix;
|
|
24622
|
-
doc.write(`if (${accessor}.slice(-${suffix.length}) !== ${
|
|
25398
|
+
doc.write(`if (${accessor}.slice(-${suffix.length}) !== ${esc4(suffix)}) return INVALID;`);
|
|
24623
25399
|
break;
|
|
24624
25400
|
}
|
|
24625
25401
|
default: {
|
|
@@ -24825,8 +25601,8 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
24825
25601
|
const keys = Object.keys(shape);
|
|
24826
25602
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
24827
25603
|
const allKeys = symbolKeys.length ? [...keys, ...symbolKeys] : keys;
|
|
24828
|
-
const keyExpr = (k) => typeof k === "symbol" ? addConstant(ctx, k) :
|
|
24829
|
-
const propKey = (k) => typeof k === "symbol" ? `[${keyExpr(k)}]` :
|
|
25604
|
+
const keyExpr = (k) => typeof k === "symbol" ? addConstant(ctx, k) : esc4(k);
|
|
25605
|
+
const propKey = (k) => typeof k === "symbol" ? `[${keyExpr(k)}]` : esc4(k);
|
|
24830
25606
|
const propShape = shape;
|
|
24831
25607
|
if (keys.includes("__proto__")) {
|
|
24832
25608
|
throw new ZodCompileUnsupportedError('object shape key "__proto__"');
|
|
@@ -24870,7 +25646,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
24870
25646
|
if (catchall) {
|
|
24871
25647
|
const catchallType = catchall._zod.def.type;
|
|
24872
25648
|
if (catchallType === "never") {
|
|
24873
|
-
const condition = keys.map((k) => `k !== ${
|
|
25649
|
+
const condition = keys.map((k) => `k !== ${esc4(k)}`).join(" && ") || "true";
|
|
24874
25650
|
doc.write(`for (const k in ${accessor}) {`);
|
|
24875
25651
|
doc.indented((d) => {
|
|
24876
25652
|
d.write(`if (${condition}) return INVALID;`);
|
|
@@ -25141,7 +25917,7 @@ function generateLiteralCheck(doc, ctx, schema, accessor) {
|
|
|
25141
25917
|
return accessor;
|
|
25142
25918
|
}
|
|
25143
25919
|
if (typeof value === "string") {
|
|
25144
|
-
doc.write(`if (${accessor} !== ${
|
|
25920
|
+
doc.write(`if (${accessor} !== ${esc4(value)}) return INVALID;`);
|
|
25145
25921
|
} else if (typeof value === "number" || typeof value === "boolean") {
|
|
25146
25922
|
doc.write(`if (${accessor} !== ${value}) return INVALID;`);
|
|
25147
25923
|
} else if (value === null) {
|
|
@@ -25342,7 +26118,7 @@ function generateDiscriminatedUnionCheck(doc, ctx, def, accessor) {
|
|
|
25342
26118
|
}
|
|
25343
26119
|
const discVar = newVar(ctx);
|
|
25344
26120
|
const outputVar = newVar(ctx);
|
|
25345
|
-
doc.write(`const ${discVar} = ${accessor}?.[${
|
|
26121
|
+
doc.write(`const ${discVar} = ${accessor}?.[${esc4(def.discriminator)}];`);
|
|
25346
26122
|
doc.write(`let ${outputVar};`);
|
|
25347
26123
|
let firstBranch = true;
|
|
25348
26124
|
const claimed = /* @__PURE__ */ new Set();
|
|
@@ -25372,7 +26148,7 @@ function generateDiscriminatedUnionCheck(doc, ctx, def, accessor) {
|
|
|
25372
26148
|
}
|
|
25373
26149
|
function literalEquality(ctx, accessor, value) {
|
|
25374
26150
|
if (typeof value === "string")
|
|
25375
|
-
return `${accessor} === ${
|
|
26151
|
+
return `${accessor} === ${esc4(value)}`;
|
|
25376
26152
|
if (typeof value === "number") {
|
|
25377
26153
|
if (Number.isNaN(value))
|
|
25378
26154
|
return `Number.isNaN(${accessor})`;
|
|
@@ -25504,7 +26280,7 @@ function emitOwnKeys(doc, ctx, accessor, kVar, body, onSymbol) {
|
|
|
25504
26280
|
}
|
|
25505
26281
|
function literalPropertyKey(ctx, key) {
|
|
25506
26282
|
if (typeof key === "string")
|
|
25507
|
-
return
|
|
26283
|
+
return esc4(key);
|
|
25508
26284
|
return addConstant(ctx, key);
|
|
25509
26285
|
}
|
|
25510
26286
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
@@ -26681,12 +27457,12 @@ function _stringbool(Classes, _params) {
|
|
|
26681
27457
|
in: stringSchema,
|
|
26682
27458
|
out: booleanSchema,
|
|
26683
27459
|
transform: ((input2, payload) => {
|
|
26684
|
-
let
|
|
27460
|
+
let data2 = input2;
|
|
26685
27461
|
if (params.case !== "sensitive")
|
|
26686
|
-
|
|
26687
|
-
if (truthySet.has(
|
|
27462
|
+
data2 = data2.toLowerCase();
|
|
27463
|
+
if (truthySet.has(data2)) {
|
|
26688
27464
|
return true;
|
|
26689
|
-
} else if (falsySet.has(
|
|
27465
|
+
} else if (falsySet.has(data2)) {
|
|
26690
27466
|
return false;
|
|
26691
27467
|
} else {
|
|
26692
27468
|
payload.issues.push({
|
|
@@ -28219,7 +28995,7 @@ __export(schemas_exports2, {
|
|
|
28219
28995
|
keyof: () => keyof,
|
|
28220
28996
|
ksuid: () => ksuid2,
|
|
28221
28997
|
lazy: () => lazy,
|
|
28222
|
-
literal: () =>
|
|
28998
|
+
literal: () => literal2,
|
|
28223
28999
|
looseObject: () => looseObject,
|
|
28224
29000
|
looseRecord: () => looseRecord,
|
|
28225
29001
|
mac: () => mac2,
|
|
@@ -28489,17 +29265,17 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
28489
29265
|
set "~standard"(value) {
|
|
28490
29266
|
util_exports.own(this, "~standard", value);
|
|
28491
29267
|
},
|
|
28492
|
-
parse: function _parse2(
|
|
28493
|
-
return parse2(this,
|
|
29268
|
+
parse: function _parse2(data2, params) {
|
|
29269
|
+
return parse2(this, data2, params, { callee: _parse2 });
|
|
28494
29270
|
},
|
|
28495
|
-
parseAsync: async function _parseAsync2(
|
|
28496
|
-
return await parseAsync2(this,
|
|
29271
|
+
parseAsync: async function _parseAsync2(data2, params) {
|
|
29272
|
+
return await parseAsync2(this, data2, params, { callee: _parseAsync2 });
|
|
28497
29273
|
},
|
|
28498
|
-
safeParse(
|
|
28499
|
-
return safeParse2(this,
|
|
29274
|
+
safeParse(data2, params) {
|
|
29275
|
+
return safeParse2(this, data2, params);
|
|
28500
29276
|
},
|
|
28501
|
-
async safeParseAsync(
|
|
28502
|
-
return safeParseAsync2(this,
|
|
29277
|
+
async safeParseAsync(data2, params) {
|
|
29278
|
+
return safeParseAsync2(this, data2, params);
|
|
28503
29279
|
},
|
|
28504
29280
|
// `spa` is an alias: same function object as `safeParseAsync`, as before.
|
|
28505
29281
|
get spa() {
|
|
@@ -28508,35 +29284,35 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
28508
29284
|
set spa(value) {
|
|
28509
29285
|
util_exports.own(this, "spa", value);
|
|
28510
29286
|
},
|
|
28511
|
-
validate(
|
|
28512
|
-
return validate(this,
|
|
29287
|
+
validate(data2, params) {
|
|
29288
|
+
return validate(this, data2, params);
|
|
28513
29289
|
},
|
|
28514
|
-
validateAsync(
|
|
28515
|
-
return validateAsync(this,
|
|
29290
|
+
validateAsync(data2, params) {
|
|
29291
|
+
return validateAsync(this, data2, params);
|
|
28516
29292
|
},
|
|
28517
|
-
encode: function _encode2(
|
|
28518
|
-
return encode2(this,
|
|
29293
|
+
encode: function _encode2(data2, params) {
|
|
29294
|
+
return encode2(this, data2, params, { callee: _encode2 });
|
|
28519
29295
|
},
|
|
28520
|
-
decode: function _decode2(
|
|
28521
|
-
return decode2(this,
|
|
29296
|
+
decode: function _decode2(data2, params) {
|
|
29297
|
+
return decode2(this, data2, params, { callee: _decode2 });
|
|
28522
29298
|
},
|
|
28523
|
-
encodeAsync: async function _encodeAsync2(
|
|
28524
|
-
return await encodeAsync2(this,
|
|
29299
|
+
encodeAsync: async function _encodeAsync2(data2, params) {
|
|
29300
|
+
return await encodeAsync2(this, data2, params, { callee: _encodeAsync2 });
|
|
28525
29301
|
},
|
|
28526
|
-
decodeAsync: async function _decodeAsync2(
|
|
28527
|
-
return await decodeAsync2(this,
|
|
29302
|
+
decodeAsync: async function _decodeAsync2(data2, params) {
|
|
29303
|
+
return await decodeAsync2(this, data2, params, { callee: _decodeAsync2 });
|
|
28528
29304
|
},
|
|
28529
|
-
safeEncode(
|
|
28530
|
-
return safeEncode2(this,
|
|
29305
|
+
safeEncode(data2, params) {
|
|
29306
|
+
return safeEncode2(this, data2, params);
|
|
28531
29307
|
},
|
|
28532
|
-
safeDecode(
|
|
28533
|
-
return safeDecode2(this,
|
|
29308
|
+
safeDecode(data2, params) {
|
|
29309
|
+
return safeDecode2(this, data2, params);
|
|
28534
29310
|
},
|
|
28535
|
-
async safeEncodeAsync(
|
|
28536
|
-
return safeEncodeAsync2(this,
|
|
29311
|
+
async safeEncodeAsync(data2, params) {
|
|
29312
|
+
return safeEncodeAsync2(this, data2, params);
|
|
28537
29313
|
},
|
|
28538
|
-
async safeDecodeAsync(
|
|
28539
|
-
return safeDecodeAsync2(this,
|
|
29314
|
+
async safeDecodeAsync(data2, params) {
|
|
29315
|
+
return safeDecodeAsync2(this, data2, params);
|
|
28540
29316
|
},
|
|
28541
29317
|
toJSONSchema(params) {
|
|
28542
29318
|
return createToJSONSchemaMethod(this, {})(params);
|
|
@@ -29482,7 +30258,7 @@ var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
|
29482
30258
|
}
|
|
29483
30259
|
});
|
|
29484
30260
|
});
|
|
29485
|
-
function
|
|
30261
|
+
function literal2(value, params) {
|
|
29486
30262
|
return new ZodLiteral({
|
|
29487
30263
|
type: "literal",
|
|
29488
30264
|
values: Array.isArray(value) ? value : [value],
|
|
@@ -29794,7 +30570,7 @@ function _instanceof(cls, params = {}) {
|
|
|
29794
30570
|
const inst = new ZodInstanceOf({
|
|
29795
30571
|
type: "custom",
|
|
29796
30572
|
check: "custom",
|
|
29797
|
-
fn: (
|
|
30573
|
+
fn: (data2) => data2 instanceof cls,
|
|
29798
30574
|
abort: true,
|
|
29799
30575
|
...util_exports.normalizeParams(params)
|
|
29800
30576
|
});
|
|
@@ -30913,18 +31689,18 @@ var ResultSchema = looseObject({
|
|
|
30913
31689
|
});
|
|
30914
31690
|
var RequestIdSchema = union([string2(), number2().int()]);
|
|
30915
31691
|
var JSONRPCRequestSchema = object({
|
|
30916
|
-
jsonrpc:
|
|
31692
|
+
jsonrpc: literal2(JSONRPC_VERSION),
|
|
30917
31693
|
id: RequestIdSchema,
|
|
30918
31694
|
...RequestSchema.shape
|
|
30919
31695
|
}).strict();
|
|
30920
31696
|
var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
|
|
30921
31697
|
var JSONRPCNotificationSchema = object({
|
|
30922
|
-
jsonrpc:
|
|
31698
|
+
jsonrpc: literal2(JSONRPC_VERSION),
|
|
30923
31699
|
...NotificationSchema.shape
|
|
30924
31700
|
}).strict();
|
|
30925
31701
|
var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
|
|
30926
31702
|
var JSONRPCResultResponseSchema = object({
|
|
30927
|
-
jsonrpc:
|
|
31703
|
+
jsonrpc: literal2(JSONRPC_VERSION),
|
|
30928
31704
|
id: RequestIdSchema,
|
|
30929
31705
|
result: ResultSchema
|
|
30930
31706
|
}).strict();
|
|
@@ -30941,7 +31717,7 @@ var ErrorCode;
|
|
|
30941
31717
|
ErrorCode2[ErrorCode2["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
|
|
30942
31718
|
})(ErrorCode || (ErrorCode = {}));
|
|
30943
31719
|
var JSONRPCErrorResponseSchema = object({
|
|
30944
|
-
jsonrpc:
|
|
31720
|
+
jsonrpc: literal2(JSONRPC_VERSION),
|
|
30945
31721
|
id: RequestIdSchema.optional(),
|
|
30946
31722
|
error: object({
|
|
30947
31723
|
/**
|
|
@@ -30980,7 +31756,7 @@ var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
|
30980
31756
|
reason: string2().optional()
|
|
30981
31757
|
});
|
|
30982
31758
|
var CancelledNotificationSchema = NotificationSchema.extend({
|
|
30983
|
-
method:
|
|
31759
|
+
method: literal2("notifications/cancelled"),
|
|
30984
31760
|
params: CancelledNotificationParamsSchema
|
|
30985
31761
|
});
|
|
30986
31762
|
var IconSchema = object({
|
|
@@ -31164,7 +31940,7 @@ var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
31164
31940
|
clientInfo: ImplementationSchema
|
|
31165
31941
|
});
|
|
31166
31942
|
var InitializeRequestSchema = RequestSchema.extend({
|
|
31167
|
-
method:
|
|
31943
|
+
method: literal2("initialize"),
|
|
31168
31944
|
params: InitializeRequestParamsSchema
|
|
31169
31945
|
});
|
|
31170
31946
|
var ServerCapabilitiesSchema = object({
|
|
@@ -31235,11 +32011,11 @@ var InitializeResultSchema = ResultSchema.extend({
|
|
|
31235
32011
|
instructions: string2().optional()
|
|
31236
32012
|
});
|
|
31237
32013
|
var InitializedNotificationSchema = NotificationSchema.extend({
|
|
31238
|
-
method:
|
|
32014
|
+
method: literal2("notifications/initialized"),
|
|
31239
32015
|
params: NotificationsParamsSchema.optional()
|
|
31240
32016
|
});
|
|
31241
32017
|
var PingRequestSchema = RequestSchema.extend({
|
|
31242
|
-
method:
|
|
32018
|
+
method: literal2("ping"),
|
|
31243
32019
|
params: BaseRequestParamsSchema.optional()
|
|
31244
32020
|
});
|
|
31245
32021
|
var ProgressSchema = object({
|
|
@@ -31265,7 +32041,7 @@ var ProgressNotificationParamsSchema = object({
|
|
|
31265
32041
|
progressToken: ProgressTokenSchema
|
|
31266
32042
|
});
|
|
31267
32043
|
var ProgressNotificationSchema = NotificationSchema.extend({
|
|
31268
|
-
method:
|
|
32044
|
+
method: literal2("notifications/progress"),
|
|
31269
32045
|
params: ProgressNotificationParamsSchema
|
|
31270
32046
|
});
|
|
31271
32047
|
var PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
@@ -31313,31 +32089,31 @@ var CreateTaskResultSchema = ResultSchema.extend({
|
|
|
31313
32089
|
});
|
|
31314
32090
|
var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
|
|
31315
32091
|
var TaskStatusNotificationSchema = NotificationSchema.extend({
|
|
31316
|
-
method:
|
|
32092
|
+
method: literal2("notifications/tasks/status"),
|
|
31317
32093
|
params: TaskStatusNotificationParamsSchema
|
|
31318
32094
|
});
|
|
31319
32095
|
var GetTaskRequestSchema = RequestSchema.extend({
|
|
31320
|
-
method:
|
|
32096
|
+
method: literal2("tasks/get"),
|
|
31321
32097
|
params: BaseRequestParamsSchema.extend({
|
|
31322
32098
|
taskId: string2()
|
|
31323
32099
|
})
|
|
31324
32100
|
});
|
|
31325
32101
|
var GetTaskResultSchema = ResultSchema.merge(TaskSchema);
|
|
31326
32102
|
var GetTaskPayloadRequestSchema = RequestSchema.extend({
|
|
31327
|
-
method:
|
|
32103
|
+
method: literal2("tasks/result"),
|
|
31328
32104
|
params: BaseRequestParamsSchema.extend({
|
|
31329
32105
|
taskId: string2()
|
|
31330
32106
|
})
|
|
31331
32107
|
});
|
|
31332
32108
|
var GetTaskPayloadResultSchema = ResultSchema.loose();
|
|
31333
32109
|
var ListTasksRequestSchema = PaginatedRequestSchema.extend({
|
|
31334
|
-
method:
|
|
32110
|
+
method: literal2("tasks/list")
|
|
31335
32111
|
});
|
|
31336
32112
|
var ListTasksResultSchema = PaginatedResultSchema.extend({
|
|
31337
32113
|
tasks: array(TaskSchema)
|
|
31338
32114
|
});
|
|
31339
32115
|
var CancelTaskRequestSchema = RequestSchema.extend({
|
|
31340
|
-
method:
|
|
32116
|
+
method: literal2("tasks/cancel"),
|
|
31341
32117
|
params: BaseRequestParamsSchema.extend({
|
|
31342
32118
|
taskId: string2()
|
|
31343
32119
|
})
|
|
@@ -31454,13 +32230,13 @@ var ResourceTemplateSchema = object({
|
|
|
31454
32230
|
_meta: optional(looseObject({}))
|
|
31455
32231
|
});
|
|
31456
32232
|
var ListResourcesRequestSchema = PaginatedRequestSchema.extend({
|
|
31457
|
-
method:
|
|
32233
|
+
method: literal2("resources/list")
|
|
31458
32234
|
});
|
|
31459
32235
|
var ListResourcesResultSchema = PaginatedResultSchema.extend({
|
|
31460
32236
|
resources: array(ResourceSchema)
|
|
31461
32237
|
});
|
|
31462
32238
|
var ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({
|
|
31463
|
-
method:
|
|
32239
|
+
method: literal2("resources/templates/list")
|
|
31464
32240
|
});
|
|
31465
32241
|
var ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({
|
|
31466
32242
|
resourceTemplates: array(ResourceTemplateSchema)
|
|
@@ -31475,24 +32251,24 @@ var ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
31475
32251
|
});
|
|
31476
32252
|
var ReadResourceRequestParamsSchema = ResourceRequestParamsSchema;
|
|
31477
32253
|
var ReadResourceRequestSchema = RequestSchema.extend({
|
|
31478
|
-
method:
|
|
32254
|
+
method: literal2("resources/read"),
|
|
31479
32255
|
params: ReadResourceRequestParamsSchema
|
|
31480
32256
|
});
|
|
31481
32257
|
var ReadResourceResultSchema = ResultSchema.extend({
|
|
31482
32258
|
contents: array(union([TextResourceContentsSchema, BlobResourceContentsSchema]))
|
|
31483
32259
|
});
|
|
31484
32260
|
var ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
31485
|
-
method:
|
|
32261
|
+
method: literal2("notifications/resources/list_changed"),
|
|
31486
32262
|
params: NotificationsParamsSchema.optional()
|
|
31487
32263
|
});
|
|
31488
32264
|
var SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
31489
32265
|
var SubscribeRequestSchema = RequestSchema.extend({
|
|
31490
|
-
method:
|
|
32266
|
+
method: literal2("resources/subscribe"),
|
|
31491
32267
|
params: SubscribeRequestParamsSchema
|
|
31492
32268
|
});
|
|
31493
32269
|
var UnsubscribeRequestParamsSchema = ResourceRequestParamsSchema;
|
|
31494
32270
|
var UnsubscribeRequestSchema = RequestSchema.extend({
|
|
31495
|
-
method:
|
|
32271
|
+
method: literal2("resources/unsubscribe"),
|
|
31496
32272
|
params: UnsubscribeRequestParamsSchema
|
|
31497
32273
|
});
|
|
31498
32274
|
var ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
@@ -31502,7 +32278,7 @@ var ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
|
31502
32278
|
uri: string2()
|
|
31503
32279
|
});
|
|
31504
32280
|
var ResourceUpdatedNotificationSchema = NotificationSchema.extend({
|
|
31505
|
-
method:
|
|
32281
|
+
method: literal2("notifications/resources/updated"),
|
|
31506
32282
|
params: ResourceUpdatedNotificationParamsSchema
|
|
31507
32283
|
});
|
|
31508
32284
|
var PromptArgumentSchema = object({
|
|
@@ -31537,7 +32313,7 @@ var PromptSchema = object({
|
|
|
31537
32313
|
_meta: optional(looseObject({}))
|
|
31538
32314
|
});
|
|
31539
32315
|
var ListPromptsRequestSchema = PaginatedRequestSchema.extend({
|
|
31540
|
-
method:
|
|
32316
|
+
method: literal2("prompts/list")
|
|
31541
32317
|
});
|
|
31542
32318
|
var ListPromptsResultSchema = PaginatedResultSchema.extend({
|
|
31543
32319
|
prompts: array(PromptSchema)
|
|
@@ -31553,11 +32329,11 @@ var GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
31553
32329
|
arguments: record(string2(), string2()).optional()
|
|
31554
32330
|
});
|
|
31555
32331
|
var GetPromptRequestSchema = RequestSchema.extend({
|
|
31556
|
-
method:
|
|
32332
|
+
method: literal2("prompts/get"),
|
|
31557
32333
|
params: GetPromptRequestParamsSchema
|
|
31558
32334
|
});
|
|
31559
32335
|
var TextContentSchema = object({
|
|
31560
|
-
type:
|
|
32336
|
+
type: literal2("text"),
|
|
31561
32337
|
/**
|
|
31562
32338
|
* The text content of the message.
|
|
31563
32339
|
*/
|
|
@@ -31573,7 +32349,7 @@ var TextContentSchema = object({
|
|
|
31573
32349
|
_meta: record(string2(), unknown()).optional()
|
|
31574
32350
|
});
|
|
31575
32351
|
var ImageContentSchema = object({
|
|
31576
|
-
type:
|
|
32352
|
+
type: literal2("image"),
|
|
31577
32353
|
/**
|
|
31578
32354
|
* The base64-encoded image data.
|
|
31579
32355
|
*/
|
|
@@ -31593,7 +32369,7 @@ var ImageContentSchema = object({
|
|
|
31593
32369
|
_meta: record(string2(), unknown()).optional()
|
|
31594
32370
|
});
|
|
31595
32371
|
var AudioContentSchema = object({
|
|
31596
|
-
type:
|
|
32372
|
+
type: literal2("audio"),
|
|
31597
32373
|
/**
|
|
31598
32374
|
* The base64-encoded audio data.
|
|
31599
32375
|
*/
|
|
@@ -31613,7 +32389,7 @@ var AudioContentSchema = object({
|
|
|
31613
32389
|
_meta: record(string2(), unknown()).optional()
|
|
31614
32390
|
});
|
|
31615
32391
|
var ToolUseContentSchema = object({
|
|
31616
|
-
type:
|
|
32392
|
+
type: literal2("tool_use"),
|
|
31617
32393
|
/**
|
|
31618
32394
|
* The name of the tool to invoke.
|
|
31619
32395
|
* Must match a tool name from the request's tools array.
|
|
@@ -31636,7 +32412,7 @@ var ToolUseContentSchema = object({
|
|
|
31636
32412
|
_meta: record(string2(), unknown()).optional()
|
|
31637
32413
|
});
|
|
31638
32414
|
var EmbeddedResourceSchema = object({
|
|
31639
|
-
type:
|
|
32415
|
+
type: literal2("resource"),
|
|
31640
32416
|
resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
31641
32417
|
/**
|
|
31642
32418
|
* Optional annotations for the client.
|
|
@@ -31649,7 +32425,7 @@ var EmbeddedResourceSchema = object({
|
|
|
31649
32425
|
_meta: record(string2(), unknown()).optional()
|
|
31650
32426
|
});
|
|
31651
32427
|
var ResourceLinkSchema = ResourceSchema.extend({
|
|
31652
|
-
type:
|
|
32428
|
+
type: literal2("resource_link")
|
|
31653
32429
|
});
|
|
31654
32430
|
var ContentBlockSchema = union([
|
|
31655
32431
|
TextContentSchema,
|
|
@@ -31670,7 +32446,7 @@ var GetPromptResultSchema = ResultSchema.extend({
|
|
|
31670
32446
|
messages: array(PromptMessageSchema)
|
|
31671
32447
|
});
|
|
31672
32448
|
var PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
31673
|
-
method:
|
|
32449
|
+
method: literal2("notifications/prompts/list_changed"),
|
|
31674
32450
|
params: NotificationsParamsSchema.optional()
|
|
31675
32451
|
});
|
|
31676
32452
|
var ToolAnnotationsSchema = object({
|
|
@@ -31735,7 +32511,7 @@ var ToolSchema = object({
|
|
|
31735
32511
|
* Must have type: 'object' at the root level per MCP spec.
|
|
31736
32512
|
*/
|
|
31737
32513
|
inputSchema: object({
|
|
31738
|
-
type:
|
|
32514
|
+
type: literal2("object"),
|
|
31739
32515
|
properties: record(string2(), AssertObjectSchema).optional(),
|
|
31740
32516
|
required: array(string2()).optional()
|
|
31741
32517
|
}).catchall(unknown()),
|
|
@@ -31745,7 +32521,7 @@ var ToolSchema = object({
|
|
|
31745
32521
|
* Must have type: 'object' at the root level per MCP spec.
|
|
31746
32522
|
*/
|
|
31747
32523
|
outputSchema: object({
|
|
31748
|
-
type:
|
|
32524
|
+
type: literal2("object"),
|
|
31749
32525
|
properties: record(string2(), AssertObjectSchema).optional(),
|
|
31750
32526
|
required: array(string2()).optional()
|
|
31751
32527
|
}).catchall(unknown()).optional(),
|
|
@@ -31764,7 +32540,7 @@ var ToolSchema = object({
|
|
|
31764
32540
|
_meta: record(string2(), unknown()).optional()
|
|
31765
32541
|
});
|
|
31766
32542
|
var ListToolsRequestSchema = PaginatedRequestSchema.extend({
|
|
31767
|
-
method:
|
|
32543
|
+
method: literal2("tools/list")
|
|
31768
32544
|
});
|
|
31769
32545
|
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
|
31770
32546
|
tools: array(ToolSchema)
|
|
@@ -31813,11 +32589,11 @@ var CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
31813
32589
|
arguments: record(string2(), unknown()).optional()
|
|
31814
32590
|
});
|
|
31815
32591
|
var CallToolRequestSchema = RequestSchema.extend({
|
|
31816
|
-
method:
|
|
32592
|
+
method: literal2("tools/call"),
|
|
31817
32593
|
params: CallToolRequestParamsSchema
|
|
31818
32594
|
});
|
|
31819
32595
|
var ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
31820
|
-
method:
|
|
32596
|
+
method: literal2("notifications/tools/list_changed"),
|
|
31821
32597
|
params: NotificationsParamsSchema.optional()
|
|
31822
32598
|
});
|
|
31823
32599
|
var ListChangedOptionsBaseSchema = object({
|
|
@@ -31848,7 +32624,7 @@ var SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
31848
32624
|
level: LoggingLevelSchema
|
|
31849
32625
|
});
|
|
31850
32626
|
var SetLevelRequestSchema = RequestSchema.extend({
|
|
31851
|
-
method:
|
|
32627
|
+
method: literal2("logging/setLevel"),
|
|
31852
32628
|
params: SetLevelRequestParamsSchema
|
|
31853
32629
|
});
|
|
31854
32630
|
var LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
@@ -31866,7 +32642,7 @@ var LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
|
31866
32642
|
data: unknown()
|
|
31867
32643
|
});
|
|
31868
32644
|
var LoggingMessageNotificationSchema = NotificationSchema.extend({
|
|
31869
|
-
method:
|
|
32645
|
+
method: literal2("notifications/message"),
|
|
31870
32646
|
params: LoggingMessageNotificationParamsSchema
|
|
31871
32647
|
});
|
|
31872
32648
|
var ModelHintSchema = object({
|
|
@@ -31903,7 +32679,7 @@ var ToolChoiceSchema = object({
|
|
|
31903
32679
|
mode: _enum2(["auto", "required", "none"]).optional()
|
|
31904
32680
|
});
|
|
31905
32681
|
var ToolResultContentSchema = object({
|
|
31906
|
-
type:
|
|
32682
|
+
type: literal2("tool_result"),
|
|
31907
32683
|
toolUseId: string2().describe("The unique identifier for the corresponding tool call."),
|
|
31908
32684
|
content: array(ContentBlockSchema).default([]),
|
|
31909
32685
|
structuredContent: object({}).loose().optional(),
|
|
@@ -31974,7 +32750,7 @@ var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
31974
32750
|
toolChoice: ToolChoiceSchema.optional()
|
|
31975
32751
|
});
|
|
31976
32752
|
var CreateMessageRequestSchema = RequestSchema.extend({
|
|
31977
|
-
method:
|
|
32753
|
+
method: literal2("sampling/createMessage"),
|
|
31978
32754
|
params: CreateMessageRequestParamsSchema
|
|
31979
32755
|
});
|
|
31980
32756
|
var CreateMessageResultSchema = ResultSchema.extend({
|
|
@@ -32023,13 +32799,13 @@ var CreateMessageResultWithToolsSchema = ResultSchema.extend({
|
|
|
32023
32799
|
content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
|
|
32024
32800
|
});
|
|
32025
32801
|
var BooleanSchemaSchema = object({
|
|
32026
|
-
type:
|
|
32802
|
+
type: literal2("boolean"),
|
|
32027
32803
|
title: string2().optional(),
|
|
32028
32804
|
description: string2().optional(),
|
|
32029
32805
|
default: boolean2().optional()
|
|
32030
32806
|
});
|
|
32031
32807
|
var StringSchemaSchema = object({
|
|
32032
|
-
type:
|
|
32808
|
+
type: literal2("string"),
|
|
32033
32809
|
title: string2().optional(),
|
|
32034
32810
|
description: string2().optional(),
|
|
32035
32811
|
minLength: number2().optional(),
|
|
@@ -32046,14 +32822,14 @@ var NumberSchemaSchema = object({
|
|
|
32046
32822
|
default: number2().optional()
|
|
32047
32823
|
});
|
|
32048
32824
|
var UntitledSingleSelectEnumSchemaSchema = object({
|
|
32049
|
-
type:
|
|
32825
|
+
type: literal2("string"),
|
|
32050
32826
|
title: string2().optional(),
|
|
32051
32827
|
description: string2().optional(),
|
|
32052
32828
|
enum: array(string2()),
|
|
32053
32829
|
default: string2().optional()
|
|
32054
32830
|
});
|
|
32055
32831
|
var TitledSingleSelectEnumSchemaSchema = object({
|
|
32056
|
-
type:
|
|
32832
|
+
type: literal2("string"),
|
|
32057
32833
|
title: string2().optional(),
|
|
32058
32834
|
description: string2().optional(),
|
|
32059
32835
|
oneOf: array(object({
|
|
@@ -32063,7 +32839,7 @@ var TitledSingleSelectEnumSchemaSchema = object({
|
|
|
32063
32839
|
default: string2().optional()
|
|
32064
32840
|
});
|
|
32065
32841
|
var LegacyTitledEnumSchemaSchema = object({
|
|
32066
|
-
type:
|
|
32842
|
+
type: literal2("string"),
|
|
32067
32843
|
title: string2().optional(),
|
|
32068
32844
|
description: string2().optional(),
|
|
32069
32845
|
enum: array(string2()),
|
|
@@ -32072,19 +32848,19 @@ var LegacyTitledEnumSchemaSchema = object({
|
|
|
32072
32848
|
});
|
|
32073
32849
|
var SingleSelectEnumSchemaSchema = union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]);
|
|
32074
32850
|
var UntitledMultiSelectEnumSchemaSchema = object({
|
|
32075
|
-
type:
|
|
32851
|
+
type: literal2("array"),
|
|
32076
32852
|
title: string2().optional(),
|
|
32077
32853
|
description: string2().optional(),
|
|
32078
32854
|
minItems: number2().optional(),
|
|
32079
32855
|
maxItems: number2().optional(),
|
|
32080
32856
|
items: object({
|
|
32081
|
-
type:
|
|
32857
|
+
type: literal2("string"),
|
|
32082
32858
|
enum: array(string2())
|
|
32083
32859
|
}),
|
|
32084
32860
|
default: array(string2()).optional()
|
|
32085
32861
|
});
|
|
32086
32862
|
var TitledMultiSelectEnumSchemaSchema = object({
|
|
32087
|
-
type:
|
|
32863
|
+
type: literal2("array"),
|
|
32088
32864
|
title: string2().optional(),
|
|
32089
32865
|
description: string2().optional(),
|
|
32090
32866
|
minItems: number2().optional(),
|
|
@@ -32106,7 +32882,7 @@ var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
32106
32882
|
*
|
|
32107
32883
|
* Optional for backward compatibility. Clients MUST treat missing mode as "form".
|
|
32108
32884
|
*/
|
|
32109
|
-
mode:
|
|
32885
|
+
mode: literal2("form").optional(),
|
|
32110
32886
|
/**
|
|
32111
32887
|
* The message to present to the user describing what information is being requested.
|
|
32112
32888
|
*/
|
|
@@ -32116,7 +32892,7 @@ var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
32116
32892
|
* Only top-level properties are allowed, without nesting.
|
|
32117
32893
|
*/
|
|
32118
32894
|
requestedSchema: object({
|
|
32119
|
-
type:
|
|
32895
|
+
type: literal2("object"),
|
|
32120
32896
|
properties: record(string2(), PrimitiveSchemaDefinitionSchema),
|
|
32121
32897
|
required: array(string2()).optional()
|
|
32122
32898
|
})
|
|
@@ -32125,7 +32901,7 @@ var ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
32125
32901
|
/**
|
|
32126
32902
|
* The elicitation mode.
|
|
32127
32903
|
*/
|
|
32128
|
-
mode:
|
|
32904
|
+
mode: literal2("url"),
|
|
32129
32905
|
/**
|
|
32130
32906
|
* The message to present to the user explaining why the interaction is needed.
|
|
32131
32907
|
*/
|
|
@@ -32142,7 +32918,7 @@ var ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
|
|
|
32142
32918
|
});
|
|
32143
32919
|
var ElicitRequestParamsSchema = union([ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema]);
|
|
32144
32920
|
var ElicitRequestSchema = RequestSchema.extend({
|
|
32145
|
-
method:
|
|
32921
|
+
method: literal2("elicitation/create"),
|
|
32146
32922
|
params: ElicitRequestParamsSchema
|
|
32147
32923
|
});
|
|
32148
32924
|
var ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
|
|
@@ -32152,7 +32928,7 @@ var ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.exte
|
|
|
32152
32928
|
elicitationId: string2()
|
|
32153
32929
|
});
|
|
32154
32930
|
var ElicitationCompleteNotificationSchema = NotificationSchema.extend({
|
|
32155
|
-
method:
|
|
32931
|
+
method: literal2("notifications/elicitation/complete"),
|
|
32156
32932
|
params: ElicitationCompleteNotificationParamsSchema
|
|
32157
32933
|
});
|
|
32158
32934
|
var ElicitResultSchema = ResultSchema.extend({
|
|
@@ -32172,14 +32948,14 @@ var ElicitResultSchema = ResultSchema.extend({
|
|
|
32172
32948
|
content: preprocess((val) => val === null ? void 0 : val, record(string2(), union([string2(), number2(), boolean2(), array(string2())])).optional())
|
|
32173
32949
|
});
|
|
32174
32950
|
var ResourceTemplateReferenceSchema = object({
|
|
32175
|
-
type:
|
|
32951
|
+
type: literal2("ref/resource"),
|
|
32176
32952
|
/**
|
|
32177
32953
|
* The URI or URI template of the resource.
|
|
32178
32954
|
*/
|
|
32179
32955
|
uri: string2()
|
|
32180
32956
|
});
|
|
32181
32957
|
var PromptReferenceSchema = object({
|
|
32182
|
-
type:
|
|
32958
|
+
type: literal2("ref/prompt"),
|
|
32183
32959
|
/**
|
|
32184
32960
|
* The name of the prompt or prompt template
|
|
32185
32961
|
*/
|
|
@@ -32208,7 +32984,7 @@ var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
|
32208
32984
|
}).optional()
|
|
32209
32985
|
});
|
|
32210
32986
|
var CompleteRequestSchema = RequestSchema.extend({
|
|
32211
|
-
method:
|
|
32987
|
+
method: literal2("completion/complete"),
|
|
32212
32988
|
params: CompleteRequestParamsSchema
|
|
32213
32989
|
});
|
|
32214
32990
|
function assertCompleteRequestPrompt(request) {
|
|
@@ -32255,14 +33031,14 @@ var RootSchema = object({
|
|
|
32255
33031
|
_meta: record(string2(), unknown()).optional()
|
|
32256
33032
|
});
|
|
32257
33033
|
var ListRootsRequestSchema = RequestSchema.extend({
|
|
32258
|
-
method:
|
|
33034
|
+
method: literal2("roots/list"),
|
|
32259
33035
|
params: BaseRequestParamsSchema.optional()
|
|
32260
33036
|
});
|
|
32261
33037
|
var ListRootsResultSchema = ResultSchema.extend({
|
|
32262
33038
|
roots: array(RootSchema)
|
|
32263
33039
|
});
|
|
32264
33040
|
var RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
32265
|
-
method:
|
|
33041
|
+
method: literal2("notifications/roots/list_changed"),
|
|
32266
33042
|
params: NotificationsParamsSchema.optional()
|
|
32267
33043
|
});
|
|
32268
33044
|
var ClientRequestSchema = union([
|
|
@@ -32338,23 +33114,23 @@ var ServerResultSchema = union([
|
|
|
32338
33114
|
CreateTaskResultSchema
|
|
32339
33115
|
]);
|
|
32340
33116
|
var McpError = class _McpError extends Error {
|
|
32341
|
-
constructor(code, message,
|
|
33117
|
+
constructor(code, message, data2) {
|
|
32342
33118
|
super(`MCP error ${code}: ${message}`);
|
|
32343
33119
|
this.code = code;
|
|
32344
|
-
this.data =
|
|
33120
|
+
this.data = data2;
|
|
32345
33121
|
this.name = "McpError";
|
|
32346
33122
|
}
|
|
32347
33123
|
/**
|
|
32348
33124
|
* Factory method to create the appropriate error type based on the error code and data
|
|
32349
33125
|
*/
|
|
32350
|
-
static fromError(code, message,
|
|
32351
|
-
if (code === ErrorCode.UrlElicitationRequired &&
|
|
32352
|
-
const errorData =
|
|
33126
|
+
static fromError(code, message, data2) {
|
|
33127
|
+
if (code === ErrorCode.UrlElicitationRequired && data2) {
|
|
33128
|
+
const errorData = data2;
|
|
32353
33129
|
if (errorData.elicitations) {
|
|
32354
33130
|
return new UrlElicitationRequiredError(errorData.elicitations, message);
|
|
32355
33131
|
}
|
|
32356
33132
|
}
|
|
32357
|
-
return new _McpError(code, message,
|
|
33133
|
+
return new _McpError(code, message, data2);
|
|
32358
33134
|
}
|
|
32359
33135
|
};
|
|
32360
33136
|
var UrlElicitationRequiredError = class extends McpError {
|
|
@@ -32564,15 +33340,15 @@ var ZodParsedType = util.arrayToEnum([
|
|
|
32564
33340
|
"map",
|
|
32565
33341
|
"set"
|
|
32566
33342
|
]);
|
|
32567
|
-
var getParsedType2 = (
|
|
32568
|
-
const t = typeof
|
|
33343
|
+
var getParsedType2 = (data2) => {
|
|
33344
|
+
const t = typeof data2;
|
|
32569
33345
|
switch (t) {
|
|
32570
33346
|
case "undefined":
|
|
32571
33347
|
return ZodParsedType.undefined;
|
|
32572
33348
|
case "string":
|
|
32573
33349
|
return ZodParsedType.string;
|
|
32574
33350
|
case "number":
|
|
32575
|
-
return Number.isNaN(
|
|
33351
|
+
return Number.isNaN(data2) ? ZodParsedType.nan : ZodParsedType.number;
|
|
32576
33352
|
case "boolean":
|
|
32577
33353
|
return ZodParsedType.boolean;
|
|
32578
33354
|
case "function":
|
|
@@ -32582,22 +33358,22 @@ var getParsedType2 = (data) => {
|
|
|
32582
33358
|
case "symbol":
|
|
32583
33359
|
return ZodParsedType.symbol;
|
|
32584
33360
|
case "object":
|
|
32585
|
-
if (Array.isArray(
|
|
33361
|
+
if (Array.isArray(data2)) {
|
|
32586
33362
|
return ZodParsedType.array;
|
|
32587
33363
|
}
|
|
32588
|
-
if (
|
|
33364
|
+
if (data2 === null) {
|
|
32589
33365
|
return ZodParsedType.null;
|
|
32590
33366
|
}
|
|
32591
|
-
if (
|
|
33367
|
+
if (data2.then && typeof data2.then === "function" && data2.catch && typeof data2.catch === "function") {
|
|
32592
33368
|
return ZodParsedType.promise;
|
|
32593
33369
|
}
|
|
32594
|
-
if (typeof Map !== "undefined" &&
|
|
33370
|
+
if (typeof Map !== "undefined" && data2 instanceof Map) {
|
|
32595
33371
|
return ZodParsedType.map;
|
|
32596
33372
|
}
|
|
32597
|
-
if (typeof Set !== "undefined" &&
|
|
33373
|
+
if (typeof Set !== "undefined" && data2 instanceof Set) {
|
|
32598
33374
|
return ZodParsedType.set;
|
|
32599
33375
|
}
|
|
32600
|
-
if (typeof Date !== "undefined" &&
|
|
33376
|
+
if (typeof Date !== "undefined" && data2 instanceof Date) {
|
|
32601
33377
|
return ZodParsedType.date;
|
|
32602
33378
|
}
|
|
32603
33379
|
return ZodParsedType.object;
|
|
@@ -32846,7 +33622,7 @@ function getErrorMap2() {
|
|
|
32846
33622
|
|
|
32847
33623
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v3/helpers/parseUtil.js
|
|
32848
33624
|
var makeIssue = (params) => {
|
|
32849
|
-
const { data, path, errorMaps, issueData } = params;
|
|
33625
|
+
const { data: data2, path, errorMaps, issueData } = params;
|
|
32850
33626
|
const fullPath = [...path, ...issueData.path || []];
|
|
32851
33627
|
const fullIssue = {
|
|
32852
33628
|
...issueData,
|
|
@@ -32862,7 +33638,7 @@ var makeIssue = (params) => {
|
|
|
32862
33638
|
let errorMessage = "";
|
|
32863
33639
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
32864
33640
|
for (const map2 of maps) {
|
|
32865
|
-
errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
|
|
33641
|
+
errorMessage = map2(fullIssue, { data: data2, defaultError: errorMessage }).message;
|
|
32866
33642
|
}
|
|
32867
33643
|
return {
|
|
32868
33644
|
...issueData,
|
|
@@ -33063,13 +33839,13 @@ var ZodType2 = class {
|
|
|
33063
33839
|
const result = this._parse(input2);
|
|
33064
33840
|
return Promise.resolve(result);
|
|
33065
33841
|
}
|
|
33066
|
-
parse(
|
|
33067
|
-
const result = this.safeParse(
|
|
33842
|
+
parse(data2, params) {
|
|
33843
|
+
const result = this.safeParse(data2, params);
|
|
33068
33844
|
if (result.success)
|
|
33069
33845
|
return result.data;
|
|
33070
33846
|
throw result.error;
|
|
33071
33847
|
}
|
|
33072
|
-
safeParse(
|
|
33848
|
+
safeParse(data2, params) {
|
|
33073
33849
|
const ctx = {
|
|
33074
33850
|
common: {
|
|
33075
33851
|
issues: [],
|
|
@@ -33079,13 +33855,13 @@ var ZodType2 = class {
|
|
|
33079
33855
|
path: params?.path || [],
|
|
33080
33856
|
schemaErrorMap: this._def.errorMap,
|
|
33081
33857
|
parent: null,
|
|
33082
|
-
data,
|
|
33083
|
-
parsedType: getParsedType2(
|
|
33858
|
+
data: data2,
|
|
33859
|
+
parsedType: getParsedType2(data2)
|
|
33084
33860
|
};
|
|
33085
|
-
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
33861
|
+
const result = this._parseSync({ data: data2, path: ctx.path, parent: ctx });
|
|
33086
33862
|
return handleResult(ctx, result);
|
|
33087
33863
|
}
|
|
33088
|
-
"~validate"(
|
|
33864
|
+
"~validate"(data2) {
|
|
33089
33865
|
const ctx = {
|
|
33090
33866
|
common: {
|
|
33091
33867
|
issues: [],
|
|
@@ -33094,12 +33870,12 @@ var ZodType2 = class {
|
|
|
33094
33870
|
path: [],
|
|
33095
33871
|
schemaErrorMap: this._def.errorMap,
|
|
33096
33872
|
parent: null,
|
|
33097
|
-
data,
|
|
33098
|
-
parsedType: getParsedType2(
|
|
33873
|
+
data: data2,
|
|
33874
|
+
parsedType: getParsedType2(data2)
|
|
33099
33875
|
};
|
|
33100
33876
|
if (!this["~standard"].async) {
|
|
33101
33877
|
try {
|
|
33102
|
-
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
33878
|
+
const result = this._parseSync({ data: data2, path: [], parent: ctx });
|
|
33103
33879
|
return isValid(result) ? {
|
|
33104
33880
|
value: result.value
|
|
33105
33881
|
} : {
|
|
@@ -33115,19 +33891,19 @@ var ZodType2 = class {
|
|
|
33115
33891
|
};
|
|
33116
33892
|
}
|
|
33117
33893
|
}
|
|
33118
|
-
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
33894
|
+
return this._parseAsync({ data: data2, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
33119
33895
|
value: result.value
|
|
33120
33896
|
} : {
|
|
33121
33897
|
issues: ctx.common.issues
|
|
33122
33898
|
});
|
|
33123
33899
|
}
|
|
33124
|
-
async parseAsync(
|
|
33125
|
-
const result = await this.safeParseAsync(
|
|
33900
|
+
async parseAsync(data2, params) {
|
|
33901
|
+
const result = await this.safeParseAsync(data2, params);
|
|
33126
33902
|
if (result.success)
|
|
33127
33903
|
return result.data;
|
|
33128
33904
|
throw result.error;
|
|
33129
33905
|
}
|
|
33130
|
-
async safeParseAsync(
|
|
33906
|
+
async safeParseAsync(data2, params) {
|
|
33131
33907
|
const ctx = {
|
|
33132
33908
|
common: {
|
|
33133
33909
|
issues: [],
|
|
@@ -33137,10 +33913,10 @@ var ZodType2 = class {
|
|
|
33137
33913
|
path: params?.path || [],
|
|
33138
33914
|
schemaErrorMap: this._def.errorMap,
|
|
33139
33915
|
parent: null,
|
|
33140
|
-
data,
|
|
33141
|
-
parsedType: getParsedType2(
|
|
33916
|
+
data: data2,
|
|
33917
|
+
parsedType: getParsedType2(data2)
|
|
33142
33918
|
};
|
|
33143
|
-
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
|
|
33919
|
+
const maybeAsyncResult = this._parse({ data: data2, path: ctx.path, parent: ctx });
|
|
33144
33920
|
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
33145
33921
|
return handleResult(ctx, result);
|
|
33146
33922
|
}
|
|
@@ -33161,8 +33937,8 @@ var ZodType2 = class {
|
|
|
33161
33937
|
...getIssueProperties(val)
|
|
33162
33938
|
});
|
|
33163
33939
|
if (typeof Promise !== "undefined" && result instanceof Promise) {
|
|
33164
|
-
return result.then((
|
|
33165
|
-
if (!
|
|
33940
|
+
return result.then((data2) => {
|
|
33941
|
+
if (!data2) {
|
|
33166
33942
|
setError();
|
|
33167
33943
|
return false;
|
|
33168
33944
|
} else {
|
|
@@ -33228,7 +34004,7 @@ var ZodType2 = class {
|
|
|
33228
34004
|
this["~standard"] = {
|
|
33229
34005
|
version: 1,
|
|
33230
34006
|
vendor: "zod",
|
|
33231
|
-
validate: (
|
|
34007
|
+
validate: (data2) => this["~validate"](data2)
|
|
33232
34008
|
};
|
|
33233
34009
|
}
|
|
33234
34010
|
optional() {
|
|
@@ -33688,7 +34464,7 @@ var ZodString2 = class _ZodString2 extends ZodType2 {
|
|
|
33688
34464
|
return { status: status.value, value: input2.data };
|
|
33689
34465
|
}
|
|
33690
34466
|
_regex(regex, validation, message) {
|
|
33691
|
-
return this.refinement((
|
|
34467
|
+
return this.refinement((data2) => regex.test(data2), {
|
|
33692
34468
|
validation,
|
|
33693
34469
|
code: ZodIssueCode2.invalid_string,
|
|
33694
34470
|
...errorUtil.errToObj(message)
|
|
@@ -35908,8 +36684,8 @@ var ZodPromise2 = class extends ZodType2 {
|
|
|
35908
36684
|
return INVALID2;
|
|
35909
36685
|
}
|
|
35910
36686
|
const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
|
|
35911
|
-
return OK(promisified.then((
|
|
35912
|
-
return this._def.type.parseAsync(
|
|
36687
|
+
return OK(promisified.then((data2) => {
|
|
36688
|
+
return this._def.type.parseAsync(data2, {
|
|
35913
36689
|
path: ctx.path,
|
|
35914
36690
|
errorMap: ctx.common.contextualErrorMap
|
|
35915
36691
|
});
|
|
@@ -36103,12 +36879,12 @@ ZodNullable2.create = (type, params) => {
|
|
|
36103
36879
|
var ZodDefault2 = class extends ZodType2 {
|
|
36104
36880
|
_parse(input2) {
|
|
36105
36881
|
const { ctx } = this._processInputParams(input2);
|
|
36106
|
-
let
|
|
36882
|
+
let data2 = ctx.data;
|
|
36107
36883
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
36108
|
-
|
|
36884
|
+
data2 = this._def.defaultValue();
|
|
36109
36885
|
}
|
|
36110
36886
|
return this._def.innerType._parse({
|
|
36111
|
-
data,
|
|
36887
|
+
data: data2,
|
|
36112
36888
|
path: ctx.path,
|
|
36113
36889
|
parent: ctx
|
|
36114
36890
|
});
|
|
@@ -36202,9 +36978,9 @@ ZodNaN2.create = (params) => {
|
|
|
36202
36978
|
var ZodBranded = class extends ZodType2 {
|
|
36203
36979
|
_parse(input2) {
|
|
36204
36980
|
const { ctx } = this._processInputParams(input2);
|
|
36205
|
-
const
|
|
36981
|
+
const data2 = ctx.data;
|
|
36206
36982
|
return this._def.type._parse({
|
|
36207
|
-
data,
|
|
36983
|
+
data: data2,
|
|
36208
36984
|
path: ctx.path,
|
|
36209
36985
|
parent: ctx
|
|
36210
36986
|
});
|
|
@@ -36271,13 +37047,13 @@ var ZodPipeline = class _ZodPipeline extends ZodType2 {
|
|
|
36271
37047
|
var ZodReadonly2 = class extends ZodType2 {
|
|
36272
37048
|
_parse(input2) {
|
|
36273
37049
|
const result = this._def.innerType._parse(input2);
|
|
36274
|
-
const freeze = (
|
|
36275
|
-
if (isValid(
|
|
36276
|
-
|
|
37050
|
+
const freeze = (data2) => {
|
|
37051
|
+
if (isValid(data2)) {
|
|
37052
|
+
data2.value = Object.freeze(data2.value);
|
|
36277
37053
|
}
|
|
36278
|
-
return
|
|
37054
|
+
return data2;
|
|
36279
37055
|
};
|
|
36280
|
-
return isAsync(result) ? result.then((
|
|
37056
|
+
return isAsync(result) ? result.then((data2) => freeze(data2)) : freeze(result);
|
|
36281
37057
|
}
|
|
36282
37058
|
unwrap() {
|
|
36283
37059
|
return this._def.innerType;
|
|
@@ -36382,17 +37158,17 @@ var ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
|
36382
37158
|
set with(value) {
|
|
36383
37159
|
own(this, "with", value);
|
|
36384
37160
|
},
|
|
36385
|
-
parse(
|
|
36386
|
-
return parse(this,
|
|
37161
|
+
parse(data2, params) {
|
|
37162
|
+
return parse(this, data2, params, { callee: this.parse });
|
|
36387
37163
|
},
|
|
36388
|
-
parseAsync(
|
|
36389
|
-
return parseAsync(this,
|
|
37164
|
+
parseAsync(data2, params) {
|
|
37165
|
+
return parseAsync(this, data2, params, { callee: this.parseAsync });
|
|
36390
37166
|
},
|
|
36391
|
-
safeParse(
|
|
36392
|
-
return safeParse(this,
|
|
37167
|
+
safeParse(data2, params) {
|
|
37168
|
+
return safeParse(this, data2, params);
|
|
36393
37169
|
},
|
|
36394
|
-
safeParseAsync(
|
|
36395
|
-
return safeParseAsync(this,
|
|
37170
|
+
safeParseAsync(data2, params) {
|
|
37171
|
+
return safeParseAsync(this, data2, params);
|
|
36396
37172
|
},
|
|
36397
37173
|
check(...checks) {
|
|
36398
37174
|
const def = this.def;
|
|
@@ -36450,22 +37226,22 @@ function objectFromShape(shape) {
|
|
|
36450
37226
|
return objectType(shape);
|
|
36451
37227
|
throw new Error("Mixed Zod versions detected in object shape.");
|
|
36452
37228
|
}
|
|
36453
|
-
function safeParse3(schema,
|
|
37229
|
+
function safeParse3(schema, data2) {
|
|
36454
37230
|
if (isZ4Schema(schema)) {
|
|
36455
|
-
const result2 = safeParse(schema,
|
|
37231
|
+
const result2 = safeParse(schema, data2);
|
|
36456
37232
|
return result2;
|
|
36457
37233
|
}
|
|
36458
37234
|
const v3Schema = schema;
|
|
36459
|
-
const result = v3Schema.safeParse(
|
|
37235
|
+
const result = v3Schema.safeParse(data2);
|
|
36460
37236
|
return result;
|
|
36461
37237
|
}
|
|
36462
|
-
async function safeParseAsync3(schema,
|
|
37238
|
+
async function safeParseAsync3(schema, data2) {
|
|
36463
37239
|
if (isZ4Schema(schema)) {
|
|
36464
|
-
const result2 = await safeParseAsync(schema,
|
|
37240
|
+
const result2 = await safeParseAsync(schema, data2);
|
|
36465
37241
|
return result2;
|
|
36466
37242
|
}
|
|
36467
37243
|
const v3Schema = schema;
|
|
36468
|
-
const result = await v3Schema.safeParseAsync(
|
|
37244
|
+
const result = await v3Schema.safeParseAsync(data2);
|
|
36469
37245
|
return result;
|
|
36470
37246
|
}
|
|
36471
37247
|
function getObjectShape(schema) {
|
|
@@ -37103,8 +37879,8 @@ function parseStringDef(def, refs) {
|
|
|
37103
37879
|
}
|
|
37104
37880
|
return res;
|
|
37105
37881
|
}
|
|
37106
|
-
function escapeLiteralCheckValue(
|
|
37107
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(
|
|
37882
|
+
function escapeLiteralCheckValue(literal3, refs) {
|
|
37883
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal3) : literal3;
|
|
37108
37884
|
}
|
|
37109
37885
|
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
37110
37886
|
function escapeNonAlphaNumeric(source) {
|
|
@@ -37916,8 +38692,8 @@ function getMethodLiteral(schema) {
|
|
|
37916
38692
|
}
|
|
37917
38693
|
return value;
|
|
37918
38694
|
}
|
|
37919
|
-
function parseWithCompat(schema,
|
|
37920
|
-
const result = safeParse3(schema,
|
|
38695
|
+
function parseWithCompat(schema, data2) {
|
|
38696
|
+
const result = safeParse3(schema, data2);
|
|
37921
38697
|
if (!result.success) {
|
|
37922
38698
|
throw result.error;
|
|
37923
38699
|
}
|
|
@@ -40577,7 +41353,7 @@ function createBrandrailMcp(ctx) {
|
|
|
40577
41353
|
const server = new McpServer(
|
|
40578
41354
|
{ name: "brandrail", title: `Brandrail \u2014 ${ctx.org} design system`, version: ENGINE_VERSION },
|
|
40579
41355
|
{
|
|
40580
|
-
instructions: `Design system for ${ctx.org}. Before writing UI: call get_guidelines once,
|
|
41356
|
+
instructions: `Design system for ${ctx.org}. Before writing UI: call get_guidelines once. For a new page or screen, start from get_template. Use find_component for every UI element (pass \`framework\` \u2014 angular, vue, react, web-components or html \u2014 when the project isn't ${ctx.framework ? FRAMEWORK_LABEL[ctx.framework] : "React"}) (use only the props it lists) and get_design_tokens for colours/spacing. After writing UI: call validate_snippet once with all changed files and fix every violation before finishing.`
|
|
40581
41357
|
}
|
|
40582
41358
|
);
|
|
40583
41359
|
const resolved = resolveConfig(ctx.config);
|
|
@@ -40655,6 +41431,31 @@ function createBrandrailMcp(ctx) {
|
|
|
40655
41431
|
return text(componentDoc(c, fwOf(framework)));
|
|
40656
41432
|
}
|
|
40657
41433
|
);
|
|
41434
|
+
server.registerTool(
|
|
41435
|
+
"get_template",
|
|
41436
|
+
{
|
|
41437
|
+
title: "Start a page from a template",
|
|
41438
|
+
description: "A whole page (list, detail, form, settings, dashboard, sign-in) built from this organisation's components and spacing scale, in the project's framework: the files to create, which component fills each part, and the page's rules (states, layout, accessibility). Call before building a new page or screen; rename the sample data and keep the structure. Without a name, lists the templates.",
|
|
41439
|
+
inputSchema: {
|
|
41440
|
+
name: external_exports.string().max(80).optional().describe(`Template name or what the page is, e.g. "list", "login", "admin index". One of: ${PAGE_TEMPLATES.map((t) => t.id).join(", ")}`),
|
|
41441
|
+
framework: frameworkInput
|
|
41442
|
+
},
|
|
41443
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
41444
|
+
},
|
|
41445
|
+
async ({ name, framework }) => {
|
|
41446
|
+
if (!name?.trim()) return text(`# Page templates
|
|
41447
|
+
|
|
41448
|
+
${templateList()}
|
|
41449
|
+
|
|
41450
|
+
Call get_template with a name to get the files.`);
|
|
41451
|
+
const t = findTemplate(name);
|
|
41452
|
+
if (!t) return { ...text(`No template matches "${name}". Templates:
|
|
41453
|
+
${templateList()}
|
|
41454
|
+
|
|
41455
|
+
If none fits, start from the closest one, or compose the page from find_component results and the layout rules in get_guidelines.`), isError: true };
|
|
41456
|
+
return text(templateMarkdown(ctx.config, t, fwOf(framework), ctx.org) + kitNote);
|
|
41457
|
+
}
|
|
41458
|
+
);
|
|
40658
41459
|
server.registerTool(
|
|
40659
41460
|
"get_migration_map",
|
|
40660
41461
|
{
|
|
@@ -41002,10 +41803,10 @@ async function scanPages(cwd, url2, config2, opts, log3) {
|
|
|
41002
41803
|
await page.waitForLoadState("networkidle", { timeout: 8e3 }).catch(() => {
|
|
41003
41804
|
});
|
|
41004
41805
|
if (opts.waitMs) await page.waitForTimeout(opts.waitMs);
|
|
41005
|
-
const
|
|
41006
|
-
pages.push({ url: page.url(), title:
|
|
41007
|
-
log3(` \u2714 ${page.url()} (${
|
|
41008
|
-
if (pages.length === 1) queue.push(...
|
|
41806
|
+
const data2 = await page.evaluate(collectRenderedNodes, 4e3);
|
|
41807
|
+
pages.push({ url: page.url(), title: data2.title, nodes: data2.nodes });
|
|
41808
|
+
log3(` \u2714 ${page.url()} (${data2.nodes.length} elements)`);
|
|
41809
|
+
if (pages.length === 1) queue.push(...data2.links.filter((l) => l.startsWith(new URL(page.url()).origin)).sort((a, b) => a.length - b.length));
|
|
41009
41810
|
} finally {
|
|
41010
41811
|
await page.close().catch(() => {
|
|
41011
41812
|
});
|
|
@@ -41033,6 +41834,7 @@ Usage
|
|
|
41033
41834
|
brandrail scan <url> Check a running page (localhost, staging, behind a login) in a real browser
|
|
41034
41835
|
brandrail import <files\u2026> Load tokens into the config: DTCG, Tokens Studio, Figma variables JSON, or Figma's Export modes ZIP
|
|
41035
41836
|
brandrail rules List the rules
|
|
41837
|
+
brandrail template [name] Start a page (list, detail, form, settings, dashboard, sign-in) from your components
|
|
41036
41838
|
|
|
41037
41839
|
Options for check
|
|
41038
41840
|
--config <file> Config file (default: nearest brandrail.config.json)
|
|
@@ -41083,6 +41885,11 @@ Options for import
|
|
|
41083
41885
|
--replace Replace the config's tokens instead of merging
|
|
41084
41886
|
--primitives Keep raw palette ramps (gray.100\u2026900) that semantic tokens point at
|
|
41085
41887
|
|
|
41888
|
+
Options for template
|
|
41889
|
+
--framework <name> Override the detected framework
|
|
41890
|
+
--out <folder> Where to write the files (default: here)
|
|
41891
|
+
--force Overwrite files that already exist
|
|
41892
|
+
|
|
41086
41893
|
Environment
|
|
41087
41894
|
BRANDRAIL_KEY API key from Dashboard \u2192 Connect (CI). Otherwise the key saved by \`brandrail connect\`
|
|
41088
41895
|
BRANDRAIL_API_URL Brandrail URL (default ${apiBase()})
|
|
@@ -41512,9 +42319,9 @@ Brand score ${report.score} is below ${threshold}.`);
|
|
|
41512
42319
|
function readTokenInputs(cwd, inputs) {
|
|
41513
42320
|
const files = [];
|
|
41514
42321
|
const add = (name, text2) => files.push({ name, data: JSON.parse(text2) });
|
|
41515
|
-
const
|
|
42322
|
+
const walk2 = (abs, rel) => {
|
|
41516
42323
|
if (statSync2(abs).isDirectory()) {
|
|
41517
|
-
for (const e of readdirSync2(abs)) if (!e.startsWith("."))
|
|
42324
|
+
for (const e of readdirSync2(abs)) if (!e.startsWith(".")) walk2(join7(abs, e), rel ? `${rel}/${e}` : e);
|
|
41518
42325
|
} else if (/\.zip$/i.test(abs)) {
|
|
41519
42326
|
const entries = unzipSync(new Uint8Array(readFileSync6(abs)), { filter: (e) => /\.json$/i.test(e.name) && !/(^|\/)(__MACOSX|\.)/.test(e.name) });
|
|
41520
42327
|
for (const [name, bytes] of Object.entries(entries)) add(name, strFromU8(bytes));
|
|
@@ -41524,7 +42331,7 @@ function readTokenInputs(cwd, inputs) {
|
|
|
41524
42331
|
};
|
|
41525
42332
|
for (const input2 of inputs) {
|
|
41526
42333
|
const abs = resolve3(cwd, input2);
|
|
41527
|
-
|
|
42334
|
+
walk2(abs, statSync2(abs).isDirectory() ? "" : basename2(abs));
|
|
41528
42335
|
}
|
|
41529
42336
|
return files;
|
|
41530
42337
|
}
|
|
@@ -41547,6 +42354,33 @@ function cmdImport(cwd, positional, flags) {
|
|
|
41547
42354
|
log2("\nNext: npx brandrail init (to refresh AI rule files), then npx brandrail check");
|
|
41548
42355
|
return 0;
|
|
41549
42356
|
}
|
|
42357
|
+
async function cmdTemplate(cwd, positional, flags) {
|
|
42358
|
+
if (!positional.length) {
|
|
42359
|
+
process.stdout.write(`Page templates, built from your registry's components:
|
|
42360
|
+
${templateList()}
|
|
42361
|
+
|
|
42362
|
+
Usage: brandrail template <name> [--framework react|angular|vue|html] [--out <folder>] [--force]
|
|
42363
|
+
`);
|
|
42364
|
+
return 0;
|
|
42365
|
+
}
|
|
42366
|
+
const template = findTemplate(positional.join(" "));
|
|
42367
|
+
if (!template) throw new Error(`No template matches "${positional.join(" ")}". Run \`brandrail template\` for the list.`);
|
|
42368
|
+
const { config: config2 } = await loadConfig(cwd, flags);
|
|
42369
|
+
const framework = projectFramework(cwd, config2, flags);
|
|
42370
|
+
const r = renderTemplate(config2, template, framework);
|
|
42371
|
+
const dir = resolve3(cwd, typeof flags.out === "string" ? flags.out : ".");
|
|
42372
|
+
const clash = r.files.map((f) => join7(dir, f.path)).filter((p) => existsSync7(p));
|
|
42373
|
+
if (clash.length && !flags.force) throw new Error(`Already exists: ${clash.map((p) => relative3(cwd, p)).join(", ")}. Use --out <folder> or --force.`);
|
|
42374
|
+
mkdirSync4(dir, { recursive: true });
|
|
42375
|
+
for (const f of r.files) writeFileSync4(join7(dir, f.path), f.content);
|
|
42376
|
+
log2(`\u2714 ${template.name} (${FRAMEWORK_LABEL[framework]}): ${r.files.map((f) => relative3(cwd, join7(dir, f.path))).join(", ")}`);
|
|
42377
|
+
for (const s of r.setup) log2(` \xB7 ${s.replace(/\`/g, "")}`);
|
|
42378
|
+
const missing2 = r.parts.filter((p) => !p.component);
|
|
42379
|
+
if (missing2.length) log2(` ! No component in your registry for: ${missing2.map((p) => p.part).join(", ")}. Those spots have a comment saying what goes there.`);
|
|
42380
|
+
log2(`
|
|
42381
|
+
Next: rename the sample data and labels, then npx brandrail check ${relative3(cwd, dir) || "."}`);
|
|
42382
|
+
return 0;
|
|
42383
|
+
}
|
|
41550
42384
|
function cmdRules() {
|
|
41551
42385
|
for (const r of RULES) process.stdout.write(`${r.id.padEnd(28)} ${r.defaultSeverity.padEnd(8)} ${r.description}
|
|
41552
42386
|
`);
|
|
@@ -41571,6 +42405,8 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
41571
42405
|
return cmdImport(cwd, positional, flags);
|
|
41572
42406
|
case "rules":
|
|
41573
42407
|
return cmdRules();
|
|
42408
|
+
case "template":
|
|
42409
|
+
return cmdTemplate(cwd, positional, flags);
|
|
41574
42410
|
case "connect":
|
|
41575
42411
|
return cmdConnect(cwd, flags);
|
|
41576
42412
|
case "mcp":
|