@knapsack/renderer-react 4.69.13--canary.4821.022ca72.0 → 4.69.13

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # v4.69.13 (Thu Sep 26 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - update design src user flow to be async [#4739](https://github.com/knapsack-labs/app-monorepo/pull/4739) ([@mabry1985](https://github.com/mabry1985))
6
+ - Merge branch 'latest' into feature/ksp-5512-create-add-design-src-file-async-mutation ([@mabry1985](https://github.com/mabry1985))
7
+
8
+ #### 🏠 Internal
9
+
10
+ - improve Renderer clients [#4770](https://github.com/knapsack-labs/app-monorepo/pull/4770) ([@EvanLovely](https://github.com/EvanLovely))
11
+ - refactors user flow for updating design src files [#4769](https://github.com/knapsack-labs/app-monorepo/pull/4769) ([@mabry1985](https://github.com/mabry1985))
12
+
13
+ #### Authors: 2
14
+
15
+ - Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
16
+ - Josh Mabry ([@mabry1985](https://github.com/mabry1985))
17
+
18
+ ---
19
+
1
20
  # v4.69.12 (Thu Sep 26 2024)
2
21
 
3
22
  #### 🐛 Bug Fix
@@ -24,48 +24,58 @@ 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
+ getAllImports,
38
+ getExtraImport,
39
+ getImport,
40
+ getImports,
41
+ getPatternImport,
42
+ importedModules,
43
+ meta,
44
+ rendererMeta,
45
+ rendererMethods
46
+ } = (0, import_client.getKsRendererClientGlobal)({
47
+ rendererMetaScriptTagId
48
+ });
49
+
33
50
  // src/client/init.tsx
34
51
  var import_jsx_runtime = require("react/jsx-runtime");
35
52
  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 = `
53
+ const { neededImports, disableReactStrictMode, demoWrapperProps } = rendererMeta;
54
+ const all = await getAllImports({
55
+ patterns: neededImports.filter((i) => i.type !== "extra"),
56
+ extras: neededImports.filter((i) => i.type === "extra").map(({ importInfo }) => ({ name: importInfo.name }))
57
+ });
58
+ const root = document.getElementById("render-root");
59
+ if (!root) {
60
+ throw new Error("No root element found");
61
+ }
62
+ const { DemoWrapper, ErrorCatcher, ...demoComponents } = all;
63
+ const DemoApp = rendererMethods.getDemoApp(demoComponents);
64
+ 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, {}) }) });
65
+ import_client2.default.createRoot(root).render(
66
+ disableReactStrictMode ? app : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.StrictMode, { children: app })
67
+ );
68
+ }
69
+ __name(init, "init");
70
+ try {
71
+ init();
72
+ } catch (e) {
73
+ console.error(e);
74
+ const errorElement = document.createElement("div");
75
+ errorElement.innerHTML = `
63
76
  <h1>Error</h1>
64
77
  <p>${e.message}</p>
65
78
  `;
66
- document.body.appendChild(errorElement);
67
- }
79
+ document.body.appendChild(errorElement);
68
80
  }
69
- __name(init, "init");
70
- init();
71
81
  //# 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 { neededImports, disableReactStrictMode, demoWrapperProps } =\n rendererMeta;\n const all = await getAllImports({\n patterns: neededImports.filter((i) => i.type !== 'extra'),\n extras: neededImports\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 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 { RendererMetaBase } 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 disableReactStrictMode: boolean;\n demo: Demo;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n} & RendererMetaBase;\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;;;ACyBnC,IAAM,0BAA0B;;;ADjBhC,IAAM;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,QAAI,yCAAmE;AAAA,EACrE;AACF,CAAC;;;ADIO;AAnBR,eAAe,OAAO;AACpB,QAAM,EAAE,eAAe,wBAAwB,iBAAiB,IAC9D;AACF,QAAM,MAAM,MAAM,cAAc;AAAA,IAC9B,UAAU,cAAc,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO;AAAA,IACxD,QAAQ,cACL,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;AA3Be;AA6Bf,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"]}
@@ -23,51 +23,66 @@ 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 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
+ getAllImports,
35
+ getExtraImport,
36
+ getImport,
37
+ getImports,
38
+ getPatternImport,
39
+ importedModules,
40
+ meta,
41
+ rendererMeta,
42
+ rendererMethods
43
+ } = getKsRendererClientGlobal({
44
+ rendererMetaScriptTagId
45
+ }));
46
+ }
47
+ });
48
+
26
49
  // src/client/init.tsx
27
50
  import React from "react";
28
51
  import ReactDOM from "react-dom/client";
29
- import { getKsRendererClientUtils } from "@knapsack/renderer-webpack-base/client";
30
52
  import { jsx } from "react/jsx-runtime";
31
53
  var require_init = __commonJS({
32
54
  "src/client/init.tsx"() {
33
55
  init_esm_shims();
34
- init_types();
56
+ init_ks_utils();
35
57
  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 = `
58
+ const { neededImports, disableReactStrictMode, demoWrapperProps } = rendererMeta;
59
+ const all = await getAllImports({
60
+ patterns: neededImports.filter((i) => i.type !== "extra"),
61
+ extras: neededImports.filter((i) => i.type === "extra").map(({ importInfo }) => ({ name: importInfo.name }))
62
+ });
63
+ const root = document.getElementById("render-root");
64
+ if (!root) {
65
+ throw new Error("No root element found");
66
+ }
67
+ const { DemoWrapper, ErrorCatcher, ...demoComponents } = all;
68
+ const DemoApp = rendererMethods.getDemoApp(demoComponents);
69
+ const app = /* @__PURE__ */ jsx(ErrorCatcher, { children: /* @__PURE__ */ jsx(DemoWrapper, { ...demoWrapperProps, children: /* @__PURE__ */ jsx(DemoApp, {}) }) });
70
+ ReactDOM.createRoot(root).render(
71
+ disableReactStrictMode ? app : /* @__PURE__ */ jsx(React.StrictMode, { children: app })
72
+ );
73
+ }
74
+ __name(init, "init");
75
+ try {
76
+ init();
77
+ } catch (e) {
78
+ console.error(e);
79
+ const errorElement = document.createElement("div");
80
+ errorElement.innerHTML = `
63
81
  <h1>Error</h1>
64
82
  <p>${e.message}</p>
65
83
  `;
66
- document.body.appendChild(errorElement);
67
- }
84
+ document.body.appendChild(errorElement);
68
85
  }
69
- __name(init, "init");
70
- init();
71
86
  }
72
87
  });
73
88
  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.6__@swc+core@1.3.57_@swc+helpers_iqa4vqpgdlzwuubzthdmdz7nfe/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 { RendererMetaBase } 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 disableReactStrictMode: boolean;\n demo: Demo;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n} & RendererMetaBase;\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 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 { neededImports, disableReactStrictMode, demoWrapperProps } =\n rendererMeta;\n const all = await getAllImports({\n patterns: neededImports.filter((i) => i.type !== 'extra'),\n extras: neededImports\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,IAyBa;AAzBb;AAAA;AAAA;AAyBO,IAAM,0BAA0B;AAAA;AAAA;;;ACzBvC,SAAS,iCAAiC;AAA1C,IASE,eACA,gBACA,WACA,YACA,kBACA,iBACA,MACA,cACA;AAjBF;AAAA;AAAA;AACA;AAOO,KAAM;AAAA,MACX;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;;;ACnBD,OAAO,WAAW;AAClB,OAAO,cAAc;AAsBb;AAxBR;AAAA;AAAA;AAGA;AAEA,mBAAe,OAAO;AACpB,YAAM,EAAE,eAAe,wBAAwB,iBAAiB,IAC9D;AACF,YAAM,MAAM,MAAM,cAAc;AAAA,QAC9B,UAAU,cAAc,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO;AAAA,QACxD,QAAQ,cACL,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;AA3Be;AA6Bf,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'];