@knapsack/types 4.68.4 → 4.68.6--canary.4475.83293df.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/index.js +29 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -160,8 +160,7 @@ var import_superstruct4 = require("superstruct");
|
|
|
160
160
|
var import_color_string = __toESM(require("color-string"));
|
|
161
161
|
var import_superstruct = require("superstruct");
|
|
162
162
|
function isColor(color) {
|
|
163
|
-
if (typeof color !== "string")
|
|
164
|
-
return false;
|
|
163
|
+
if (typeof color !== "string") return false;
|
|
165
164
|
try {
|
|
166
165
|
return !!import_color_string.default.get(color);
|
|
167
166
|
} catch (e) {
|
|
@@ -530,8 +529,7 @@ var strokeStyleValues = [
|
|
|
530
529
|
"inset"
|
|
531
530
|
];
|
|
532
531
|
function isTokenReference(val) {
|
|
533
|
-
if (typeof val !== "string")
|
|
534
|
-
return false;
|
|
532
|
+
if (typeof val !== "string") return false;
|
|
535
533
|
const totalOpenBrackets = val.split("{").length - 1;
|
|
536
534
|
return totalOpenBrackets === 1 && val.startsWith("{") && val.endsWith("}");
|
|
537
535
|
}
|
|
@@ -547,8 +545,7 @@ __name(isNotTokenReference, "isNotTokenReference");
|
|
|
547
545
|
var TokenReferenceStruct = s.define(
|
|
548
546
|
"Token Reference",
|
|
549
547
|
(value) => {
|
|
550
|
-
if (typeof value !== "string")
|
|
551
|
-
return false;
|
|
548
|
+
if (typeof value !== "string") return false;
|
|
552
549
|
if (isNotTokenReference(value)) {
|
|
553
550
|
return "Must start and end with curly braces";
|
|
554
551
|
}
|
|
@@ -961,8 +958,7 @@ __name(isTokenValueShadow, "isTokenValueShadow");
|
|
|
961
958
|
var TokenValueShadowStruct = s2.define(
|
|
962
959
|
"Shadow Value",
|
|
963
960
|
(value) => {
|
|
964
|
-
if (isTokenValueShadow(value))
|
|
965
|
-
return true;
|
|
961
|
+
if (isTokenValueShadow(value)) return true;
|
|
966
962
|
return `Expected a shadow value, got ${JSON.stringify(value)}`;
|
|
967
963
|
}
|
|
968
964
|
);
|
|
@@ -1261,8 +1257,7 @@ var assertTokenData = /* @__PURE__ */ __name((data) => {
|
|
|
1261
1257
|
}
|
|
1262
1258
|
}
|
|
1263
1259
|
} catch (error) {
|
|
1264
|
-
if (!(error instanceof s2.StructError))
|
|
1265
|
-
throw error;
|
|
1260
|
+
if (!(error instanceof s2.StructError)) throw error;
|
|
1266
1261
|
throw new Error(
|
|
1267
1262
|
`Invalid token data for type "${type9}": ${error.message}. Received this data: "${JSON.stringify(data)}"`
|
|
1268
1263
|
);
|
|
@@ -1429,8 +1424,7 @@ __name(isTokenSrcExtensions, "isTokenSrcExtensions");
|
|
|
1429
1424
|
}
|
|
1430
1425
|
]);
|
|
1431
1426
|
function isTokenSrc(tokenObject) {
|
|
1432
|
-
if ((0, import_utils4.isObject)(tokenObject) && (0, import_utils4.isObjKey)("$value", tokenObject))
|
|
1433
|
-
return true;
|
|
1427
|
+
if ((0, import_utils4.isObject)(tokenObject) && (0, import_utils4.isObjKey)("$value", tokenObject)) return true;
|
|
1434
1428
|
return false;
|
|
1435
1429
|
}
|
|
1436
1430
|
__name(isTokenSrc, "isTokenSrc");
|
|
@@ -1513,8 +1507,7 @@ var PageHeaderSizes = /* @__PURE__ */ ((PageHeaderSizes2) => {
|
|
|
1513
1507
|
|
|
1514
1508
|
// src/app-client-data/index.ts
|
|
1515
1509
|
function isKsAppClientDataNoMeta(data) {
|
|
1516
|
-
if (!(0, import_utils.isObject)(data))
|
|
1517
|
-
return false;
|
|
1510
|
+
if (!(0, import_utils.isObject)(data)) return false;
|
|
1518
1511
|
const requiredKeys = [
|
|
1519
1512
|
"assetSetsState",
|
|
1520
1513
|
"customPagesState",
|
|
@@ -1523,10 +1516,8 @@ function isKsAppClientDataNoMeta(data) {
|
|
|
1523
1516
|
"tokensSrc",
|
|
1524
1517
|
"db"
|
|
1525
1518
|
];
|
|
1526
|
-
if (!requiredKeys.every((key) => (0, import_utils.isObjKey)(key, data)))
|
|
1527
|
-
|
|
1528
|
-
if (!(0, import_utils.isObjKey)("metaState", data))
|
|
1529
|
-
return true;
|
|
1519
|
+
if (!requiredKeys.every((key) => (0, import_utils.isObjKey)(key, data))) return false;
|
|
1520
|
+
if (!(0, import_utils.isObjKey)("metaState", data)) return true;
|
|
1530
1521
|
return false;
|
|
1531
1522
|
}
|
|
1532
1523
|
__name(isKsAppClientDataNoMeta, "isKsAppClientDataNoMeta");
|
|
@@ -1535,8 +1526,7 @@ var KsAppClientDataNoMetaStruct = (0, import_superstruct5.define)(
|
|
|
1535
1526
|
isKsAppClientDataNoMeta
|
|
1536
1527
|
);
|
|
1537
1528
|
function isKsAppClientDataAndMeta(data) {
|
|
1538
|
-
if (!(0, import_utils.isObject)(data))
|
|
1539
|
-
return false;
|
|
1529
|
+
if (!(0, import_utils.isObject)(data)) return false;
|
|
1540
1530
|
const requiredKeys = [
|
|
1541
1531
|
"assetSetsState",
|
|
1542
1532
|
"customPagesState",
|
|
@@ -1583,8 +1573,7 @@ var isKsMetaState = KsMetaStateStruct.is;
|
|
|
1583
1573
|
// src/app-client-data-v3/index.ts
|
|
1584
1574
|
var import_superstruct6 = require("superstruct");
|
|
1585
1575
|
function isKsAppClientDataNoMetaV3(data) {
|
|
1586
|
-
if (!(0, import_utils.isObject)(data))
|
|
1587
|
-
return false;
|
|
1576
|
+
if (!(0, import_utils.isObject)(data)) return false;
|
|
1588
1577
|
const requiredKeys = [
|
|
1589
1578
|
"assetSetsState",
|
|
1590
1579
|
"customPagesState",
|
|
@@ -1593,10 +1582,8 @@ function isKsAppClientDataNoMetaV3(data) {
|
|
|
1593
1582
|
"settingsState",
|
|
1594
1583
|
"tokensState"
|
|
1595
1584
|
];
|
|
1596
|
-
if (!requiredKeys.every((key) => (0, import_utils.isObjKey)(key, data)))
|
|
1597
|
-
|
|
1598
|
-
if (!(0, import_utils.isObjKey)("metaState", data))
|
|
1599
|
-
return true;
|
|
1585
|
+
if (!requiredKeys.every((key) => (0, import_utils.isObjKey)(key, data))) return false;
|
|
1586
|
+
if (!(0, import_utils.isObjKey)("metaState", data)) return true;
|
|
1600
1587
|
return false;
|
|
1601
1588
|
}
|
|
1602
1589
|
__name(isKsAppClientDataNoMetaV3, "isKsAppClientDataNoMetaV3");
|
|
@@ -1605,8 +1592,7 @@ var KsAppClientDataNoMetaStructV3 = (0, import_superstruct6.define)(
|
|
|
1605
1592
|
isKsAppClientDataNoMetaV3
|
|
1606
1593
|
);
|
|
1607
1594
|
function isKsAppClientDataAndMetaV3(data) {
|
|
1608
|
-
if (!(0, import_utils.isObject)(data))
|
|
1609
|
-
return false;
|
|
1595
|
+
if (!(0, import_utils.isObject)(data)) return false;
|
|
1610
1596
|
const requiredKeys = [
|
|
1611
1597
|
"assetSetsState",
|
|
1612
1598
|
"customPagesState",
|
|
@@ -1654,11 +1640,11 @@ var isKsMetaStateV3 = KsMetaStateStructV3.is;
|
|
|
1654
1640
|
var import_immer = require("immer");
|
|
1655
1641
|
var migration417Demos = {
|
|
1656
1642
|
version: "4.1.7",
|
|
1657
|
-
checkIfNeeded: (appClientData) => {
|
|
1643
|
+
checkIfNeeded: /* @__PURE__ */ __name((appClientData) => {
|
|
1658
1644
|
return true;
|
|
1659
|
-
},
|
|
1645
|
+
}, "checkIfNeeded"),
|
|
1660
1646
|
// note that `appClientData` is mutable since we're already in Immer
|
|
1661
|
-
migrate: (appClientData) => {
|
|
1647
|
+
migrate: /* @__PURE__ */ __name((appClientData) => {
|
|
1662
1648
|
if (!(0, import_immer.isDraft)(appClientData)) {
|
|
1663
1649
|
throw new Error(
|
|
1664
1650
|
`Tried to run migrations on appClientData but it is not an Immer Draft`
|
|
@@ -1670,8 +1656,7 @@ var migration417Demos = {
|
|
|
1670
1656
|
}
|
|
1671
1657
|
);
|
|
1672
1658
|
Object.values(appClientData.db.demos.byId).forEach((demo) => {
|
|
1673
|
-
if (demo.type !== "data")
|
|
1674
|
-
return;
|
|
1659
|
+
if (demo.type !== "data") return;
|
|
1675
1660
|
Object.entries(demo.data.slots ?? {}).forEach(([slotName, slotData]) => {
|
|
1676
1661
|
demo.data.slots[slotName] = slotData.map(
|
|
1677
1662
|
(slottedData) => {
|
|
@@ -1693,8 +1678,7 @@ var migration417Demos = {
|
|
|
1693
1678
|
}
|
|
1694
1679
|
);
|
|
1695
1680
|
});
|
|
1696
|
-
if (demo.patternId && demo.templateId)
|
|
1697
|
-
return;
|
|
1681
|
+
if (demo.patternId && demo.templateId) return;
|
|
1698
1682
|
(() => {
|
|
1699
1683
|
for (const { id: pId, templates = [] } of Object.values(
|
|
1700
1684
|
appClientData.patternsState.patterns
|
|
@@ -1709,7 +1693,7 @@ var migration417Demos = {
|
|
|
1709
1693
|
}
|
|
1710
1694
|
})();
|
|
1711
1695
|
});
|
|
1712
|
-
}
|
|
1696
|
+
}, "migrate")
|
|
1713
1697
|
};
|
|
1714
1698
|
|
|
1715
1699
|
// src/app-client-data-migrations/index.ts
|
|
@@ -1777,10 +1761,8 @@ var rendererIds = {
|
|
|
1777
1761
|
html: "html"
|
|
1778
1762
|
};
|
|
1779
1763
|
function isKsJsImports(imports) {
|
|
1780
|
-
if (!Array.isArray(imports))
|
|
1781
|
-
|
|
1782
|
-
if (imports.length === 0)
|
|
1783
|
-
return true;
|
|
1764
|
+
if (!Array.isArray(imports)) return false;
|
|
1765
|
+
if (imports.length === 0) return true;
|
|
1784
1766
|
const [anImport] = imports;
|
|
1785
1767
|
if (anImport.type === "pattern-template" && typeof anImport.patternId !== "string")
|
|
1786
1768
|
return false;
|
|
@@ -1799,8 +1781,7 @@ function isKsJsImports(imports) {
|
|
|
1799
1781
|
if (anImport.type === "extra" && typeof anImport.importInfo.path !== "string")
|
|
1800
1782
|
return false;
|
|
1801
1783
|
if (anImport.type === "extra" && typeof anImport.importInfo.names !== "undefined") {
|
|
1802
|
-
if (!Array.isArray(anImport.importInfo.names))
|
|
1803
|
-
return false;
|
|
1784
|
+
if (!Array.isArray(anImport.importInfo.names)) return false;
|
|
1804
1785
|
if (anImport.importInfo.names.some((name) => typeof name !== "string"))
|
|
1805
1786
|
return false;
|
|
1806
1787
|
}
|
|
@@ -1808,24 +1789,18 @@ function isKsJsImports(imports) {
|
|
|
1808
1789
|
}
|
|
1809
1790
|
__name(isKsJsImports, "isKsJsImports");
|
|
1810
1791
|
function isKsRendererClientGlobalImportedModules(mods) {
|
|
1811
|
-
if (!(0, import_utils.isObject)(mods))
|
|
1812
|
-
return false;
|
|
1792
|
+
if (!(0, import_utils.isObject)(mods)) return false;
|
|
1813
1793
|
for (const key in mods) {
|
|
1814
|
-
if (typeof mods[key] !== "function")
|
|
1815
|
-
return false;
|
|
1794
|
+
if (typeof mods[key] !== "function") return false;
|
|
1816
1795
|
}
|
|
1817
1796
|
return true;
|
|
1818
1797
|
}
|
|
1819
1798
|
__name(isKsRendererClientGlobalImportedModules, "isKsRendererClientGlobalImportedModules");
|
|
1820
1799
|
function isKsRendererClientGlobal(knapsack) {
|
|
1821
|
-
if (!(0, import_utils.isObject)(knapsack))
|
|
1822
|
-
|
|
1823
|
-
if (knapsack.
|
|
1824
|
-
|
|
1825
|
-
if (typeof knapsack.getImport !== "function")
|
|
1826
|
-
return false;
|
|
1827
|
-
if (!Array.isArray(knapsack.allAvailableImports))
|
|
1828
|
-
return false;
|
|
1800
|
+
if (!(0, import_utils.isObject)(knapsack)) return false;
|
|
1801
|
+
if (knapsack.typeName !== "KsRendererClientGlobal") return false;
|
|
1802
|
+
if (typeof knapsack.getImport !== "function") return false;
|
|
1803
|
+
if (!Array.isArray(knapsack.allAvailableImports)) return false;
|
|
1829
1804
|
if (!isKsRendererClientGlobalImportedModules(knapsack.importedModules)) {
|
|
1830
1805
|
return false;
|
|
1831
1806
|
}
|