@knapsack/core 4.69.10--canary.4739.305bd52.0 → 4.69.10--canary.4745.042d9e2.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
 
31
- // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.5__@swc+core@1.3.57_@swc+helpers_qewjfurrjspcqzwdqcz2r3oykm/node_modules/tsup/assets/esm_shims.js
31
+ // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.5__@swc+core@1.3.57_@swc+helpers_qww7lehrx3uuw4jfw345astxp4/node_modules/tsup/assets/esm_shims.js
32
32
  var init_esm_shims = __esm({
33
- "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.5__@swc+core@1.3.57_@swc+helpers_qewjfurrjspcqzwdqcz2r3oykm/node_modules/tsup/assets/esm_shims.js"() {
33
+ "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.5__@swc+core@1.3.57_@swc+helpers_qww7lehrx3uuw4jfw345astxp4/node_modules/tsup/assets/esm_shims.js"() {
34
34
  }
35
35
  });
36
36
 
@@ -1763,6 +1763,79 @@ var KsRemoteChangeRuntime = s3.type({
1763
1763
  userId: s3.optional(s3.string())
1764
1764
  });
1765
1765
  var KsRemoteChangesStructRuntime = s3.array(KsRemoteChangeRuntime);
1766
+ function isKsJsImports(imports) {
1767
+ if (!Array.isArray(imports)) return false;
1768
+ if (imports.length === 0) return true;
1769
+ const [anImport] = imports;
1770
+ if (anImport.type === "pattern-template" && typeof anImport.patternId !== "string")
1771
+ return false;
1772
+ if (anImport.type === "pattern-template-demo" && typeof anImport.patternId !== "string")
1773
+ return false;
1774
+ if (anImport.type === "pattern-template-demo" && typeof anImport.templateId !== "string")
1775
+ return false;
1776
+ if (anImport.type === "pattern-template-demo" && typeof anImport.demoId !== "string")
1777
+ return false;
1778
+ if (anImport.type === "extra" && typeof anImport.importInfo !== "object")
1779
+ return false;
1780
+ if (anImport.type === "extra" && typeof anImport.importInfo.type !== "string")
1781
+ return false;
1782
+ if (anImport.type === "extra" && typeof anImport.importInfo.name !== "string")
1783
+ return false;
1784
+ if (anImport.type === "extra" && typeof anImport.importInfo.path !== "string")
1785
+ return false;
1786
+ if (anImport.type === "extra" && typeof anImport.importInfo.names !== "undefined") {
1787
+ if (!Array.isArray(anImport.importInfo.names)) return false;
1788
+ if (anImport.importInfo.names.some((name) => typeof name !== "string"))
1789
+ return false;
1790
+ }
1791
+ return true;
1792
+ }
1793
+ __name(isKsJsImports, "isKsJsImports");
1794
+ __name2(isKsJsImports, "isKsJsImports");
1795
+ function isKsRendererClientGlobalImportedModules(mods) {
1796
+ if (!isObject(mods)) return false;
1797
+ for (const key in mods) {
1798
+ if (typeof mods[key] !== "function") return false;
1799
+ }
1800
+ return true;
1801
+ }
1802
+ __name(isKsRendererClientGlobalImportedModules, "isKsRendererClientGlobalImportedModules");
1803
+ __name2(isKsRendererClientGlobalImportedModules, "isKsRendererClientGlobalImportedModules");
1804
+ function isKsRendererClientGlobal(knapsack) {
1805
+ if (!isObject(knapsack)) return false;
1806
+ if (knapsack.typeName !== "KsRendererClientGlobal") return false;
1807
+ if (typeof knapsack.getImport !== "function") return false;
1808
+ if (!Array.isArray(knapsack.allAvailableImports)) return false;
1809
+ if (!isKsRendererClientGlobalImportedModules(knapsack.importedModules)) {
1810
+ return false;
1811
+ }
1812
+ return isKsJsImports(knapsack.allAvailableImports);
1813
+ }
1814
+ __name(isKsRendererClientGlobal, "isKsRendererClientGlobal");
1815
+ __name2(isKsRendererClientGlobal, "isKsRendererClientGlobal");
1816
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
1817
+ function getKsRendererClientGlobal() {
1818
+ if (!isBrowser) {
1819
+ throw new Error(
1820
+ "Cannot get KsRendererClientGlobal in a non-browser environment"
1821
+ );
1822
+ }
1823
+ const { knapsack } = window;
1824
+ if (!knapsack) {
1825
+ throw new Error(
1826
+ 'Cannot get KsRendererClientGlobal: "knapsack" is not defined on the window'
1827
+ );
1828
+ }
1829
+ if (!isKsRendererClientGlobal(knapsack)) {
1830
+ console.log(`Object found at "window.knapsack":`, knapsack);
1831
+ throw new Error(
1832
+ `Cannot get KsRendererClientGlobal: knapsack is not the correct type`
1833
+ );
1834
+ }
1835
+ return knapsack;
1836
+ }
1837
+ __name(getKsRendererClientGlobal, "getKsRendererClientGlobal");
1838
+ __name2(getKsRendererClientGlobal, "getKsRendererClientGlobal");
1766
1839
  var plugins_exports = {};
1767
1840
  __export(plugins_exports, {
1768
1841
  ACTIONS: /* @__PURE__ */ __name(() => ACTIONS, "ACTIONS"),