@knapsack/types 4.69.9--canary.4768.997c53b.0 → 4.69.9--canary.4739.c87ad2d.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -1648,13 +1648,81 @@ var rendererIds = {
1648
1648
  angular: "angular",
1649
1649
  html: "html"
1650
1650
  };
1651
+ function isKsJsImports(imports) {
1652
+ if (!Array.isArray(imports)) return false;
1653
+ if (imports.length === 0) return true;
1654
+ const [anImport] = imports;
1655
+ if (anImport.type === "pattern-template" && typeof anImport.patternId !== "string")
1656
+ return false;
1657
+ if (anImport.type === "pattern-template-demo" && typeof anImport.patternId !== "string")
1658
+ return false;
1659
+ if (anImport.type === "pattern-template-demo" && typeof anImport.templateId !== "string")
1660
+ return false;
1661
+ if (anImport.type === "pattern-template-demo" && typeof anImport.demoId !== "string")
1662
+ return false;
1663
+ if (anImport.type === "extra" && typeof anImport.importInfo !== "object")
1664
+ return false;
1665
+ if (anImport.type === "extra" && typeof anImport.importInfo.type !== "string")
1666
+ return false;
1667
+ if (anImport.type === "extra" && typeof anImport.importInfo.name !== "string")
1668
+ return false;
1669
+ if (anImport.type === "extra" && typeof anImport.importInfo.path !== "string")
1670
+ return false;
1671
+ if (anImport.type === "extra" && typeof anImport.importInfo.names !== "undefined") {
1672
+ if (!Array.isArray(anImport.importInfo.names)) return false;
1673
+ if (anImport.importInfo.names.some((name) => typeof name !== "string"))
1674
+ return false;
1675
+ }
1676
+ return true;
1677
+ }
1678
+ __name(isKsJsImports, "isKsJsImports");
1679
+ function isKsRendererClientGlobalImportedModules(mods) {
1680
+ if (!isObject(mods)) return false;
1681
+ for (const key in mods) {
1682
+ if (typeof mods[key] !== "function") return false;
1683
+ }
1684
+ return true;
1685
+ }
1686
+ __name(isKsRendererClientGlobalImportedModules, "isKsRendererClientGlobalImportedModules");
1687
+ function isKsRendererClientGlobal(knapsack) {
1688
+ if (!isObject(knapsack)) return false;
1689
+ if (knapsack.typeName !== "KsRendererClientGlobal") return false;
1690
+ if (typeof knapsack.getImport !== "function") return false;
1691
+ if (!Array.isArray(knapsack.allAvailableImports)) return false;
1692
+ if (!isKsRendererClientGlobalImportedModules(knapsack.importedModules)) {
1693
+ return false;
1694
+ }
1695
+ return isKsJsImports(knapsack.allAvailableImports);
1696
+ }
1697
+ __name(isKsRendererClientGlobal, "isKsRendererClientGlobal");
1698
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
1699
+ function getKsRendererClientGlobal() {
1700
+ if (!isBrowser) {
1701
+ throw new Error(
1702
+ "Cannot get KsRendererClientGlobal in a non-browser environment"
1703
+ );
1704
+ }
1705
+ const { knapsack } = window;
1706
+ if (!knapsack) {
1707
+ throw new Error(
1708
+ 'Cannot get KsRendererClientGlobal: "knapsack" is not defined on the window'
1709
+ );
1710
+ }
1711
+ if (!isKsRendererClientGlobal(knapsack)) {
1712
+ console.log(`Object found at "window.knapsack":`, knapsack);
1713
+ throw new Error(
1714
+ `Cannot get KsRendererClientGlobal: knapsack is not the correct type`
1715
+ );
1716
+ }
1717
+ return knapsack;
1718
+ }
1719
+ __name(getKsRendererClientGlobal, "getKsRendererClientGlobal");
1651
1720
 
1652
1721
  // src/renderer-client-types.ts
1653
1722
  var KsRendererClientEvents = /* @__PURE__ */ ((KsRendererClientEvents2) => {
1654
1723
  KsRendererClientEvents2["ready"] = "ready";
1655
1724
  return KsRendererClientEvents2;
1656
1725
  })(KsRendererClientEvents || {});
1657
- var ksRendererClientMetaId = "ks-meta";
1658
1726
 
1659
1727
  // src/web-sockets.ts
1660
1728
  var WS_EVENTS = {
@@ -1786,6 +1854,7 @@ export {
1786
1854
  WS_EVENTS,
1787
1855
  assertTokenData,
1788
1856
  customizableNavElements,
1857
+ getKsRendererClientGlobal,
1789
1858
  getPrimitiveValue,
1790
1859
  hasTokenReferences,
1791
1860
  isArrayOfObjectsProp,
@@ -1799,10 +1868,13 @@ export {
1799
1868
  isKsAppClientDataAndMetaV3,
1800
1869
  isKsAppClientDataNoMeta,
1801
1870
  isKsAppClientDataNoMetaV3,
1871
+ isKsJsImports,
1802
1872
  isKsMetaState,
1803
1873
  isKsMetaStateV3,
1804
1874
  isKsRemoteChange,
1805
1875
  isKsRemoteChanges,
1876
+ isKsRendererClientGlobal,
1877
+ isKsRendererClientGlobalImportedModules,
1806
1878
  isNotTokenReference,
1807
1879
  isNumberProp,
1808
1880
  isObjKey,
@@ -1833,7 +1905,6 @@ export {
1833
1905
  isTokenValueFontWeight,
1834
1906
  isTokenValueShadow,
1835
1907
  isTokenValueTransition,
1836
- ksRendererClientMetaId,
1837
1908
  migrations,
1838
1909
  pageElements,
1839
1910
  pageElementsV2,