@knapsack/renderer-react 4.69.12--canary.4821.8709676.0 → 4.69.12--canary.4739.7e3b906.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,48 +24,59 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
 
25
25
  // src/client/init.tsx
26
26
  var import_react = __toESM(require("react"));
27
- var import_client = __toESM(require("react-dom/client"));
28
- var import_client2 = require("@knapsack/renderer-webpack-base/client");
27
+ var import_client2 = __toESM(require("react-dom/client"));
28
+
29
+ // src/client/ks-utils.ts
30
+ var import_client = require("@knapsack/renderer-webpack-base/client");
29
31
 
30
32
  // src/types.ts
31
33
  var rendererMetaScriptTagId = "ks-react-meta";
32
34
 
35
+ // src/client/ks-utils.ts
36
+ var {
37
+ allAvailableImports,
38
+ getAllImports,
39
+ getExtraImport,
40
+ getImport,
41
+ getImports,
42
+ getPatternImport,
43
+ importedModules,
44
+ meta,
45
+ rendererMeta,
46
+ rendererMethods
47
+ } = (0, import_client.getKsRendererClientGlobal)({
48
+ rendererMetaScriptTagId
49
+ });
50
+
33
51
  // src/client/init.tsx
34
52
  var import_jsx_runtime = require("react/jsx-runtime");
35
53
  async function init() {
36
- try {
37
- const {
38
- getNeededImports,
39
- getExtraImports,
40
- rendererMeta: { disableReactStrictMode, demoWrapperProps },
41
- rendererMethods: { getDemoApp }
42
- } = (0, import_client2.getKsRendererClientUtils)({
43
- rendererMetaScriptTagId
44
- });
45
- const [neededImports, { DemoWrapper, ErrorCatcher }] = await Promise.all([
46
- getNeededImports(),
47
- getExtraImports()
48
- ]);
49
- const root = document.getElementById("render-root");
50
- if (!root) {
51
- throw new Error("No root element found");
52
- }
53
- const demoComponents = neededImports;
54
- const DemoApp = getDemoApp(demoComponents);
55
- const app = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorCatcher, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DemoWrapper, { ...demoWrapperProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DemoApp, {}) }) });
56
- import_client.default.createRoot(root).render(
57
- disableReactStrictMode ? app : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.StrictMode, { children: app })
58
- );
59
- } catch (e) {
60
- console.error(e);
61
- const errorElement = document.createElement("div");
62
- errorElement.innerHTML = `
54
+ const { imports, disableReactStrictMode, demoWrapperProps } = rendererMeta;
55
+ const all = await getAllImports({
56
+ patterns: imports.filter((i) => i.type !== "extra"),
57
+ extras: imports.filter((i) => i.type === "extra").map(({ importInfo }) => ({ name: importInfo.name }))
58
+ });
59
+ const root = document.getElementById("render-root");
60
+ if (!root) {
61
+ throw new Error("No root element found");
62
+ }
63
+ const { DemoWrapper, ErrorCatcher, ...demoComponents } = all;
64
+ const DemoApp = rendererMethods.getDemoApp(demoComponents);
65
+ const app = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorCatcher, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DemoWrapper, { ...demoWrapperProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DemoApp, {}) }) });
66
+ import_client2.default.createRoot(root).render(
67
+ disableReactStrictMode ? app : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.StrictMode, { children: app })
68
+ );
69
+ }
70
+ __name(init, "init");
71
+ try {
72
+ init();
73
+ } catch (e) {
74
+ console.error(e);
75
+ const errorElement = document.createElement("div");
76
+ errorElement.innerHTML = `
63
77
  <h1>Error</h1>
64
78
  <p>${e.message}</p>
65
79
  `;
66
- document.body.appendChild(errorElement);
67
- }
80
+ document.body.appendChild(errorElement);
68
81
  }
69
- __name(init, "init");
70
- init();
71
82
  //# sourceMappingURL=init.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/init.tsx","../../src/types.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport { getKsRendererClientUtils } from '@knapsack/renderer-webpack-base/client';\nimport {\n rendererMetaScriptTagId,\n type KsReactMeta,\n type Component,\n type RendererMethods,\n} from '../types';\n\nasync function init() {\n try {\n const {\n getNeededImports,\n getExtraImports,\n rendererMeta: { disableReactStrictMode, demoWrapperProps },\n rendererMethods: { getDemoApp },\n } = getKsRendererClientUtils<Component, KsReactMeta, RendererMethods>({\n rendererMetaScriptTagId,\n });\n const [neededImports, { DemoWrapper, ErrorCatcher }] = await Promise.all([\n getNeededImports(),\n getExtraImports(),\n ]);\n const root = document.getElementById('render-root');\n if (!root) {\n throw new Error('No root element found');\n }\n const demoComponents = neededImports;\n const DemoApp = getDemoApp(demoComponents);\n const app = (\n <ErrorCatcher>\n <DemoWrapper {...demoWrapperProps}>\n <DemoApp />\n </DemoWrapper>\n </ErrorCatcher>\n );\n\n ReactDOM.createRoot(root).render(\n disableReactStrictMode ? app : <React.StrictMode>{app}</React.StrictMode>,\n );\n } catch (e) {\n console.error(e);\n // create html element with error message\n const errorElement = document.createElement('div');\n errorElement.innerHTML = `\n <h1>Error</h1>\n <p>${e.message}</p>\n `;\n document.body.appendChild(errorElement);\n }\n}\n\ninit();\n","import type { Demo, Except } from '@knapsack/types';\nimport type { ComponentType } from 'react';\nimport type { RendererMetaBase } from '@knapsack/renderer-webpack-base/client';\n\nexport type Component = ComponentType<Record<string, unknown>>;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n // patternsUsed: {\n // patternId: string;\n // templateId: string;\n // demoId?: string;\n // }[];\n demo: Demo;\n patternId: string;\n templateId: string;\n};\n\n/**\n * Found as JSON in HTML `#ks-react-meta`\n */\nexport type KsReactMeta = {\n disableReactStrictMode: boolean;\n demo: Demo;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n} & RendererMetaBase<'DemoWrapper' | 'ErrorCatcher'>;\n\nexport const rendererMetaScriptTagId = 'ks-react-meta';\n\nexport type RendererMethods = {\n getDemoApp: (components: Record<string, Component>) => Component;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,mBAAkB;AAClB,oBAAqB;AACrB,IAAAA,iBAAyC;;;ACwBlC,IAAM,0BAA0B;;;ADO7B;AAvBV,eAAe,OAAO;AACpB,MAAI;AACF,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,cAAc,EAAE,wBAAwB,iBAAiB;AAAA,MACzD,iBAAiB,EAAE,WAAW;AAAA,IAChC,QAAI,yCAAkE;AAAA,MACpE;AAAA,IACF,CAAC;AACD,UAAM,CAAC,eAAe,EAAE,aAAa,aAAa,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,MACvE,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,IAClB,CAAC;AACD,UAAM,OAAO,SAAS,eAAe,aAAa;AAClD,QAAI,CAAC,MAAM;AACT,YAAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AACA,UAAM,iBAAiB;AACvB,UAAM,UAAU,WAAW,cAAc;AACzC,UAAM,MACJ,4CAAC,gBACC,sDAAC,eAAa,GAAG,kBACf,sDAAC,WAAQ,GACX,GACF;AAGF,kBAAAC,QAAS,WAAW,IAAI,EAAE;AAAA,MACxB,yBAAyB,MAAM,4CAAC,aAAAC,QAAM,YAAN,EAAkB,eAAI;AAAA,IACxD;AAAA,EACF,SAAS,GAAG;AACV,YAAQ,MAAM,CAAC;AAEf,UAAM,eAAe,SAAS,cAAc,KAAK;AACjD,iBAAa,YAAY;AAAA;AAAA,SAEpB,EAAE,OAAO;AAAA;AAEd,aAAS,KAAK,YAAY,YAAY;AAAA,EACxC;AACF;AAzCe;AA2Cf,KAAK;","names":["import_client","ReactDOM","React"]}
1
+ {"version":3,"sources":["../../src/client/init.tsx","../../src/client/ks-utils.ts","../../src/types.ts"],"sourcesContent":["/// <reference lib=\"dom\" />\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport { rendererMeta, rendererMethods, getAllImports } from './ks-utils';\n\nasync function init() {\n const { imports, disableReactStrictMode, demoWrapperProps } = rendererMeta;\n const all = await getAllImports({\n patterns: imports.filter((i) => i.type !== 'extra'),\n extras: imports\n .filter((i) => i.type === 'extra')\n .map(({ importInfo }) => ({ name: importInfo.name })),\n });\n\n const root = document.getElementById('render-root');\n if (!root) {\n throw new Error('No root element found');\n }\n const { DemoWrapper, ErrorCatcher, ...demoComponents } = all;\n const DemoApp = rendererMethods.getDemoApp(demoComponents);\n const app = (\n <ErrorCatcher>\n <DemoWrapper {...demoWrapperProps}>\n <DemoApp />\n </DemoWrapper>\n </ErrorCatcher>\n );\n\n ReactDOM.createRoot(root).render(\n disableReactStrictMode ? app : <React.StrictMode>{app}</React.StrictMode>,\n );\n}\n\ntry {\n init();\n} catch (e) {\n console.error(e);\n // create html element with error message\n const errorElement = document.createElement('div');\n errorElement.innerHTML = `\n <h1>Error</h1>\n <p>${e.message}</p>\n `;\n document.body.appendChild(errorElement);\n}\n","import { getKsRendererClientGlobal } from '@knapsack/renderer-webpack-base/client';\nimport {\n rendererMetaScriptTagId,\n type KsReactMeta,\n type Component,\n type RendererMethods,\n} from '../types';\n\nexport const {\n allAvailableImports,\n getAllImports,\n getExtraImport,\n getImport,\n getImports,\n getPatternImport,\n importedModules,\n meta,\n rendererMeta,\n rendererMethods,\n} = getKsRendererClientGlobal<Component, KsReactMeta, RendererMethods>({\n rendererMetaScriptTagId,\n});\n","import type { Demo, Except } from '@knapsack/types';\nimport type { ComponentType } from 'react';\nimport type {\n KsJsImport,\n KsJsImportInfo,\n} from '@knapsack/renderer-webpack-base/client';\nimport type { KnapsackRenderParams } from '@knapsack/app/types';\n\nexport type Component = ComponentType<Record<string, unknown>>;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[];\n} & Except<KnapsackRenderParams, 'patternManifest'>;\n\n/**\n * Found as JSON in HTML `#ks-react-meta`\n */\nexport type KsReactMeta = {\n imports: KsJsImport[];\n moduleImports: {\n [path: string]: KsJsImportInfo[];\n };\n disableReactStrictMode: boolean;\n demo: Demo;\n patternId: string;\n templateId: string;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n};\n\nexport const rendererMetaScriptTagId = 'ks-react-meta';\n\nexport type RendererMethods = {\n getDemoApp: (components: Record<string, Component>) => Component;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,mBAAkB;AAClB,IAAAA,iBAAqB;;;ACFrB,oBAA0C;;;ACkCnC,IAAM,0BAA0B;;;AD1BhC,IAAM;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,QAAI,yCAAmE;AAAA,EACrE;AACF,CAAC;;;ADEO;AAlBR,eAAe,OAAO;AACpB,QAAM,EAAE,SAAS,wBAAwB,iBAAiB,IAAI;AAC9D,QAAM,MAAM,MAAM,cAAc;AAAA,IAC9B,UAAU,QAAQ,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO;AAAA,IAClD,QAAQ,QACL,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO,EAChC,IAAI,CAAC,EAAE,WAAW,OAAO,EAAE,MAAM,WAAW,KAAK,EAAE;AAAA,EACxD,CAAC;AAED,QAAM,OAAO,SAAS,eAAe,aAAa;AAClD,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,uBAAuB;AAAA,EACzC;AACA,QAAM,EAAE,aAAa,cAAc,GAAG,eAAe,IAAI;AACzD,QAAM,UAAU,gBAAgB,WAAW,cAAc;AACzD,QAAM,MACJ,4CAAC,gBACC,sDAAC,eAAa,GAAG,kBACf,sDAAC,WAAQ,GACX,GACF;AAGF,iBAAAC,QAAS,WAAW,IAAI,EAAE;AAAA,IACxB,yBAAyB,MAAM,4CAAC,aAAAC,QAAM,YAAN,EAAkB,eAAI;AAAA,EACxD;AACF;AA1Be;AA4Bf,IAAI;AACF,OAAK;AACP,SAAS,GAAG;AACV,UAAQ,MAAM,CAAC;AAEf,QAAM,eAAe,SAAS,cAAc,KAAK;AACjD,eAAa,YAAY;AAAA;AAAA,SAElB,EAAE,OAAO;AAAA;AAEhB,WAAS,KAAK,YAAY,YAAY;AACxC;","names":["import_client","ReactDOM","React"]}
@@ -8,9 +8,9 @@ var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
10
 
11
- // ../../../../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_ltnhnypbjniokjoiamajspm464/node_modules/tsup/assets/esm_shims.js
11
+ // ../../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.6__@swc+core@1.3.57_@swc+helpers_iqa4vqpgdlzwuubzthdmdz7nfe/node_modules/tsup/assets/esm_shims.js
12
12
  var init_esm_shims = __esm({
13
- "../../../../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_ltnhnypbjniokjoiamajspm464/node_modules/tsup/assets/esm_shims.js"() {
13
+ "../../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.6__@swc+core@1.3.57_@swc+helpers_iqa4vqpgdlzwuubzthdmdz7nfe/node_modules/tsup/assets/esm_shims.js"() {
14
14
  }
15
15
  });
16
16
 
@@ -23,51 +23,67 @@ var init_types = __esm({
23
23
  }
24
24
  });
25
25
 
26
+ // src/client/ks-utils.ts
27
+ import { getKsRendererClientGlobal } from "@knapsack/renderer-webpack-base/client";
28
+ var allAvailableImports, getAllImports, getExtraImport, getImport, getImports, getPatternImport, importedModules, meta, rendererMeta, rendererMethods;
29
+ var init_ks_utils = __esm({
30
+ "src/client/ks-utils.ts"() {
31
+ init_esm_shims();
32
+ init_types();
33
+ ({
34
+ allAvailableImports,
35
+ getAllImports,
36
+ getExtraImport,
37
+ getImport,
38
+ getImports,
39
+ getPatternImport,
40
+ importedModules,
41
+ meta,
42
+ rendererMeta,
43
+ rendererMethods
44
+ } = getKsRendererClientGlobal({
45
+ rendererMetaScriptTagId
46
+ }));
47
+ }
48
+ });
49
+
26
50
  // src/client/init.tsx
27
51
  import React from "react";
28
52
  import ReactDOM from "react-dom/client";
29
- import { getKsRendererClientUtils } from "@knapsack/renderer-webpack-base/client";
30
53
  import { jsx } from "react/jsx-runtime";
31
54
  var require_init = __commonJS({
32
55
  "src/client/init.tsx"() {
33
56
  init_esm_shims();
34
- init_types();
57
+ init_ks_utils();
35
58
  async function init() {
36
- try {
37
- const {
38
- getNeededImports,
39
- getExtraImports,
40
- rendererMeta: { disableReactStrictMode, demoWrapperProps },
41
- rendererMethods: { getDemoApp }
42
- } = getKsRendererClientUtils({
43
- rendererMetaScriptTagId
44
- });
45
- const [neededImports, { DemoWrapper, ErrorCatcher }] = await Promise.all([
46
- getNeededImports(),
47
- getExtraImports()
48
- ]);
49
- const root = document.getElementById("render-root");
50
- if (!root) {
51
- throw new Error("No root element found");
52
- }
53
- const demoComponents = neededImports;
54
- const DemoApp = getDemoApp(demoComponents);
55
- const app = /* @__PURE__ */ jsx(ErrorCatcher, { children: /* @__PURE__ */ jsx(DemoWrapper, { ...demoWrapperProps, children: /* @__PURE__ */ jsx(DemoApp, {}) }) });
56
- ReactDOM.createRoot(root).render(
57
- disableReactStrictMode ? app : /* @__PURE__ */ jsx(React.StrictMode, { children: app })
58
- );
59
- } catch (e) {
60
- console.error(e);
61
- const errorElement = document.createElement("div");
62
- errorElement.innerHTML = `
59
+ const { imports, disableReactStrictMode, demoWrapperProps } = rendererMeta;
60
+ const all = await getAllImports({
61
+ patterns: imports.filter((i) => i.type !== "extra"),
62
+ extras: imports.filter((i) => i.type === "extra").map(({ importInfo }) => ({ name: importInfo.name }))
63
+ });
64
+ const root = document.getElementById("render-root");
65
+ if (!root) {
66
+ throw new Error("No root element found");
67
+ }
68
+ const { DemoWrapper, ErrorCatcher, ...demoComponents } = all;
69
+ const DemoApp = rendererMethods.getDemoApp(demoComponents);
70
+ const app = /* @__PURE__ */ jsx(ErrorCatcher, { children: /* @__PURE__ */ jsx(DemoWrapper, { ...demoWrapperProps, children: /* @__PURE__ */ jsx(DemoApp, {}) }) });
71
+ ReactDOM.createRoot(root).render(
72
+ disableReactStrictMode ? app : /* @__PURE__ */ jsx(React.StrictMode, { children: app })
73
+ );
74
+ }
75
+ __name(init, "init");
76
+ try {
77
+ init();
78
+ } catch (e) {
79
+ console.error(e);
80
+ const errorElement = document.createElement("div");
81
+ errorElement.innerHTML = `
63
82
  <h1>Error</h1>
64
83
  <p>${e.message}</p>
65
84
  `;
66
- document.body.appendChild(errorElement);
67
- }
85
+ document.body.appendChild(errorElement);
68
86
  }
69
- __name(init, "init");
70
- init();
71
87
  }
72
88
  });
73
89
  export default require_init();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../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_ltnhnypbjniokjoiamajspm464/node_modules/tsup/assets/esm_shims.js","../../src/types.ts","../../src/client/init.tsx"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import type { Demo, Except } from '@knapsack/types';\nimport type { ComponentType } from 'react';\nimport type { RendererMetaBase } from '@knapsack/renderer-webpack-base/client';\n\nexport type Component = ComponentType<Record<string, unknown>>;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n // patternsUsed: {\n // patternId: string;\n // templateId: string;\n // demoId?: string;\n // }[];\n demo: Demo;\n patternId: string;\n templateId: string;\n};\n\n/**\n * Found as JSON in HTML `#ks-react-meta`\n */\nexport type KsReactMeta = {\n disableReactStrictMode: boolean;\n demo: Demo;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n} & RendererMetaBase<'DemoWrapper' | 'ErrorCatcher'>;\n\nexport const rendererMetaScriptTagId = 'ks-react-meta';\n\nexport type RendererMethods = {\n getDemoApp: (components: Record<string, Component>) => Component;\n};\n","/// <reference lib=\"dom\" />\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport { getKsRendererClientUtils } from '@knapsack/renderer-webpack-base/client';\nimport {\n rendererMetaScriptTagId,\n type KsReactMeta,\n type Component,\n type RendererMethods,\n} from '../types';\n\nasync function init() {\n try {\n const {\n getNeededImports,\n getExtraImports,\n rendererMeta: { disableReactStrictMode, demoWrapperProps },\n rendererMethods: { getDemoApp },\n } = getKsRendererClientUtils<Component, KsReactMeta, RendererMethods>({\n rendererMetaScriptTagId,\n });\n const [neededImports, { DemoWrapper, ErrorCatcher }] = await Promise.all([\n getNeededImports(),\n getExtraImports(),\n ]);\n const root = document.getElementById('render-root');\n if (!root) {\n throw new Error('No root element found');\n }\n const demoComponents = neededImports;\n const DemoApp = getDemoApp(demoComponents);\n const app = (\n <ErrorCatcher>\n <DemoWrapper {...demoWrapperProps}>\n <DemoApp />\n </DemoWrapper>\n </ErrorCatcher>\n );\n\n ReactDOM.createRoot(root).render(\n disableReactStrictMode ? app : <React.StrictMode>{app}</React.StrictMode>,\n );\n } catch (e) {\n console.error(e);\n // create html element with error message\n const errorElement = document.createElement('div');\n errorElement.innerHTML = `\n <h1>Error</h1>\n <p>${e.message}</p>\n `;\n document.body.appendChild(errorElement);\n }\n}\n\ninit();\n"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;;;ACAA,IA2Ba;AA3Bb;AAAA;AAAA;AA2BO,IAAM,0BAA0B;AAAA;AAAA;;;AC1BvC,OAAO,WAAW;AAClB,OAAO,cAAc;AACrB,SAAS,gCAAgC;AA+B/B;AAlCV;AAAA;AAAA;AAIA;AAOA,mBAAe,OAAO;AACpB,UAAI;AACF,cAAM;AAAA,UACJ;AAAA,UACA;AAAA,UACA,cAAc,EAAE,wBAAwB,iBAAiB;AAAA,UACzD,iBAAiB,EAAE,WAAW;AAAA,QAChC,IAAI,yBAAkE;AAAA,UACpE;AAAA,QACF,CAAC;AACD,cAAM,CAAC,eAAe,EAAE,aAAa,aAAa,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,UACvE,iBAAiB;AAAA,UACjB,gBAAgB;AAAA,QAClB,CAAC;AACD,cAAM,OAAO,SAAS,eAAe,aAAa;AAClD,YAAI,CAAC,MAAM;AACT,gBAAM,IAAI,MAAM,uBAAuB;AAAA,QACzC;AACA,cAAM,iBAAiB;AACvB,cAAM,UAAU,WAAW,cAAc;AACzC,cAAM,MACJ,oBAAC,gBACC,8BAAC,eAAa,GAAG,kBACf,8BAAC,WAAQ,GACX,GACF;AAGF,iBAAS,WAAW,IAAI,EAAE;AAAA,UACxB,yBAAyB,MAAM,oBAAC,MAAM,YAAN,EAAkB,eAAI;AAAA,QACxD;AAAA,MACF,SAAS,GAAG;AACV,gBAAQ,MAAM,CAAC;AAEf,cAAM,eAAe,SAAS,cAAc,KAAK;AACjD,qBAAa,YAAY;AAAA;AAAA,SAEpB,EAAE,OAAO;AAAA;AAEd,iBAAS,KAAK,YAAY,YAAY;AAAA,MACxC;AAAA,IACF;AAzCe;AA2Cf,SAAK;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.43.8_@types+node@20.16.6__@swc+core@1.3.57_@swc+helpers_iqa4vqpgdlzwuubzthdmdz7nfe/node_modules/tsup/assets/esm_shims.js","../../src/types.ts","../../src/client/ks-utils.ts","../../src/client/init.tsx"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import type { Demo, Except } from '@knapsack/types';\nimport type { ComponentType } from 'react';\nimport type {\n KsJsImport,\n KsJsImportInfo,\n} from '@knapsack/renderer-webpack-base/client';\nimport type { KnapsackRenderParams } from '@knapsack/app/types';\n\nexport type Component = ComponentType<Record<string, unknown>>;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[];\n} & Except<KnapsackRenderParams, 'patternManifest'>;\n\n/**\n * Found as JSON in HTML `#ks-react-meta`\n */\nexport type KsReactMeta = {\n imports: KsJsImport[];\n moduleImports: {\n [path: string]: KsJsImportInfo[];\n };\n disableReactStrictMode: boolean;\n demo: Demo;\n patternId: string;\n templateId: string;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n};\n\nexport const rendererMetaScriptTagId = 'ks-react-meta';\n\nexport type RendererMethods = {\n getDemoApp: (components: Record<string, Component>) => Component;\n};\n","import { getKsRendererClientGlobal } from '@knapsack/renderer-webpack-base/client';\nimport {\n rendererMetaScriptTagId,\n type KsReactMeta,\n type Component,\n type RendererMethods,\n} from '../types';\n\nexport const {\n allAvailableImports,\n getAllImports,\n getExtraImport,\n getImport,\n getImports,\n getPatternImport,\n importedModules,\n meta,\n rendererMeta,\n rendererMethods,\n} = getKsRendererClientGlobal<Component, KsReactMeta, RendererMethods>({\n rendererMetaScriptTagId,\n});\n","/// <reference lib=\"dom\" />\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport { rendererMeta, rendererMethods, getAllImports } from './ks-utils';\n\nasync function init() {\n const { imports, disableReactStrictMode, demoWrapperProps } = rendererMeta;\n const all = await getAllImports({\n patterns: imports.filter((i) => i.type !== 'extra'),\n extras: imports\n .filter((i) => i.type === 'extra')\n .map(({ importInfo }) => ({ name: importInfo.name })),\n });\n\n const root = document.getElementById('render-root');\n if (!root) {\n throw new Error('No root element found');\n }\n const { DemoWrapper, ErrorCatcher, ...demoComponents } = all;\n const DemoApp = rendererMethods.getDemoApp(demoComponents);\n const app = (\n <ErrorCatcher>\n <DemoWrapper {...demoWrapperProps}>\n <DemoApp />\n </DemoWrapper>\n </ErrorCatcher>\n );\n\n ReactDOM.createRoot(root).render(\n disableReactStrictMode ? app : <React.StrictMode>{app}</React.StrictMode>,\n );\n}\n\ntry {\n init();\n} catch (e) {\n console.error(e);\n // create html element with error message\n const errorElement = document.createElement('div');\n errorElement.innerHTML = `\n <h1>Error</h1>\n <p>${e.message}</p>\n `;\n document.body.appendChild(errorElement);\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAkCa;AAlCb;AAAA;AAAA;AAkCO,IAAM,0BAA0B;AAAA;AAAA;;;AClCvC,SAAS,iCAAiC;AAA1C,IASE,qBACA,eACA,gBACA,WACA,YACA,kBACA,iBACA,MACA,cACA;AAlBF;AAAA;AAAA;AACA;AAOO,KAAM;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE,0BAAmE;AAAA,MACrE;AAAA,IACF,CAAC;AAAA;AAAA;;;ACpBD,OAAO,WAAW;AAClB,OAAO,cAAc;AAqBb;AAvBR;AAAA;AAAA;AAGA;AAEA,mBAAe,OAAO;AACpB,YAAM,EAAE,SAAS,wBAAwB,iBAAiB,IAAI;AAC9D,YAAM,MAAM,MAAM,cAAc;AAAA,QAC9B,UAAU,QAAQ,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO;AAAA,QAClD,QAAQ,QACL,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO,EAChC,IAAI,CAAC,EAAE,WAAW,OAAO,EAAE,MAAM,WAAW,KAAK,EAAE;AAAA,MACxD,CAAC;AAED,YAAM,OAAO,SAAS,eAAe,aAAa;AAClD,UAAI,CAAC,MAAM;AACT,cAAM,IAAI,MAAM,uBAAuB;AAAA,MACzC;AACA,YAAM,EAAE,aAAa,cAAc,GAAG,eAAe,IAAI;AACzD,YAAM,UAAU,gBAAgB,WAAW,cAAc;AACzD,YAAM,MACJ,oBAAC,gBACC,8BAAC,eAAa,GAAG,kBACf,8BAAC,WAAQ,GACX,GACF;AAGF,eAAS,WAAW,IAAI,EAAE;AAAA,QACxB,yBAAyB,MAAM,oBAAC,MAAM,YAAN,EAAkB,eAAI;AAAA,MACxD;AAAA,IACF;AA1Be;AA4Bf,QAAI;AACF,WAAK;AAAA,IACP,SAAS,GAAG;AACV,cAAQ,MAAM,CAAC;AAEf,YAAM,eAAe,SAAS,cAAc,KAAK;AACjD,mBAAa,YAAY;AAAA;AAAA,SAElB,EAAE,OAAO;AAAA;AAEhB,eAAS,KAAK,YAAY,YAAY;AAAA,IACxC;AAAA;AAAA;","names":[]}
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { D as DemoWrapperProps } from './types-CivTHEEo.mjs';
2
+ import { D as DemoWrapperProps } from './types-D2eCZXsg.mjs';
3
3
  import '@knapsack/types';
4
+ import '@knapsack/app/types';
4
5
 
5
6
  declare const DemoWrapper: ({ children }: DemoWrapperProps) => react_jsx_runtime.JSX.Element;
6
7
 
@@ -1,6 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { D as DemoWrapperProps } from './types-CivTHEEo.js';
2
+ import { D as DemoWrapperProps } from './types-D2eCZXsg.js';
3
3
  import '@knapsack/types';
4
+ import '@knapsack/app/types';
4
5
 
5
6
  declare const DemoWrapper: ({ children }: DemoWrapperProps) => react_jsx_runtime.JSX.Element;
6
7
 
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
- import { RendererWebpackBase, Renderer, KsJsImportMap } from '@knapsack/renderer-webpack-base';
1
+ import { RendererWebpackBase, Renderer, KsJsImport } from '@knapsack/renderer-webpack-base';
2
2
  import { Renderable } from '@knapsack/app/renderers';
3
3
  import { RendererId } from '@knapsack/types';
4
- export { D as DemoWrapperProps } from './types-CivTHEEo.mjs';
4
+ import { KnapsackRenderParams } from '@knapsack/app/types';
5
+ export { D as DemoWrapperProps } from './types-D2eCZXsg.mjs';
5
6
 
6
7
  declare class KnapsackReactRenderer extends RendererWebpackBase implements Renderable {
7
8
  /**
@@ -26,11 +27,12 @@ declare class KnapsackReactRenderer extends RendererWebpackBase implements Rende
26
27
  getMeta: Renderer['getMeta'];
27
28
  changeCase: Renderer['changeCase'];
28
29
  createWebpackConfig: RendererWebpackBase['createWebpackConfig'];
29
- prepClientRenderResults({ usage, demoApp, importMap, renderOptions: { demo, state, patternId, templateId }, }: {
30
+ getJsImports: RendererWebpackBase['getJsImports'];
31
+ prepClientRenderResults({ usage, demoApp, imports: xImports, renderOptions: { pattern, template, demo }, }: {
30
32
  usage: string;
31
33
  demoApp: string;
32
- importMap: KsJsImportMap;
33
- renderOptions: Parameters<Renderer['render']>[0];
34
+ imports: KsJsImport[];
35
+ renderOptions: KnapsackRenderParams;
34
36
  }): ReturnType<Renderer['render']>;
35
37
  render: Renderer['render'];
36
38
  getUsageAndImports: RendererWebpackBase['getUsageAndImports'];
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { RendererWebpackBase, Renderer, KsJsImportMap } from '@knapsack/renderer-webpack-base';
1
+ import { RendererWebpackBase, Renderer, KsJsImport } from '@knapsack/renderer-webpack-base';
2
2
  import { Renderable } from '@knapsack/app/renderers';
3
3
  import { RendererId } from '@knapsack/types';
4
- export { D as DemoWrapperProps } from './types-CivTHEEo.js';
4
+ import { KnapsackRenderParams } from '@knapsack/app/types';
5
+ export { D as DemoWrapperProps } from './types-D2eCZXsg.js';
5
6
 
6
7
  declare class KnapsackReactRenderer extends RendererWebpackBase implements Renderable {
7
8
  /**
@@ -26,11 +27,12 @@ declare class KnapsackReactRenderer extends RendererWebpackBase implements Rende
26
27
  getMeta: Renderer['getMeta'];
27
28
  changeCase: Renderer['changeCase'];
28
29
  createWebpackConfig: RendererWebpackBase['createWebpackConfig'];
29
- prepClientRenderResults({ usage, demoApp, importMap, renderOptions: { demo, state, patternId, templateId }, }: {
30
+ getJsImports: RendererWebpackBase['getJsImports'];
31
+ prepClientRenderResults({ usage, demoApp, imports: xImports, renderOptions: { pattern, template, demo }, }: {
30
32
  usage: string;
31
33
  demoApp: string;
32
- importMap: KsJsImportMap;
33
- renderOptions: Parameters<Renderer['render']>[0];
34
+ imports: KsJsImport[];
35
+ renderOptions: KnapsackRenderParams;
34
36
  }): ReturnType<Renderer['render']>;
35
37
  render: Renderer['render'];
36
38
  getUsageAndImports: RendererWebpackBase['getUsageAndImports'];