@knapsack/renderer-react 4.69.9--canary.32dcae2.0 → 4.69.10--canary.4739.305bd52.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +18 -0
- package/dist/client/init.d.mts +2 -0
- package/dist/client/init.d.ts +2 -0
- package/dist/client/init.js +82 -0
- package/dist/client/init.js.map +1 -0
- package/dist/client/init.mjs +90 -0
- package/dist/client/init.mjs.map +1 -0
- package/dist/demo-wrapper.d.mts +1 -4
- package/dist/demo-wrapper.d.ts +1 -4
- package/dist/demo-wrapper.js.map +1 -1
- package/dist/demo-wrapper.mjs.map +1 -1
- package/dist/index.d.mts +4 -12
- package/dist/index.d.ts +4 -12
- package/dist/index.js +61 -135
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -137
- package/dist/index.mjs.map +1 -1
- package/dist/types-D2eCZXsg.d.mts +13 -0
- package/dist/types-D2eCZXsg.d.ts +13 -0
- package/package.json +19 -14
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# v4.69.9 (Sat Sep 14 2024)
|
2
|
+
|
3
|
+
#### 🐛 Bug Fix
|
4
|
+
|
5
|
+
- refactor Renderer clients [#4768](https://github.com/knapsack-labs/app-monorepo/pull/4768) ([@EvanLovely](https://github.com/EvanLovely))
|
6
|
+
|
7
|
+
#### 🏠 Internal
|
8
|
+
|
9
|
+
- update template stage ui [#4763](https://github.com/knapsack-labs/app-monorepo/pull/4763) ([@GormanDesign](https://github.com/GormanDesign))
|
10
|
+
- add spacing under form feedback banner [#4747](https://github.com/knapsack-labs/app-monorepo/pull/4747) ([@GormanDesign](https://github.com/GormanDesign))
|
11
|
+
|
12
|
+
#### Authors: 2
|
13
|
+
|
14
|
+
- Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
|
15
|
+
- Matt Gorman ([@GormanDesign](https://github.com/GormanDesign))
|
16
|
+
|
17
|
+
---
|
18
|
+
|
1
19
|
# v4.69.8 (Thu Sep 12 2024)
|
2
20
|
|
3
21
|
#### 🐛 Bug Fix
|
@@ -0,0 +1,82 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
}
|
14
|
+
return to;
|
15
|
+
};
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
+
mod
|
23
|
+
));
|
24
|
+
|
25
|
+
// src/client/init.tsx
|
26
|
+
var import_react = __toESM(require("react"));
|
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");
|
31
|
+
|
32
|
+
// src/types.ts
|
33
|
+
var rendererMetaScriptTagId = "ks-react-meta";
|
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
|
+
|
51
|
+
// src/client/init.tsx
|
52
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
53
|
+
async function init() {
|
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 = `
|
77
|
+
<h1>Error</h1>
|
78
|
+
<p>${e.message}</p>
|
79
|
+
`;
|
80
|
+
document.body.appendChild(errorElement);
|
81
|
+
}
|
82
|
+
//# sourceMappingURL=init.js.map
|
@@ -0,0 +1 @@
|
|
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"]}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
4
|
+
var __esm = (fn, res) => function __init() {
|
5
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
6
|
+
};
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
9
|
+
};
|
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_qewjfurrjspcqzwdqcz2r3oykm/node_modules/tsup/assets/esm_shims.js
|
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_qewjfurrjspcqzwdqcz2r3oykm/node_modules/tsup/assets/esm_shims.js"() {
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
// src/types.ts
|
18
|
+
var rendererMetaScriptTagId;
|
19
|
+
var init_types = __esm({
|
20
|
+
"src/types.ts"() {
|
21
|
+
init_esm_shims();
|
22
|
+
rendererMetaScriptTagId = "ks-react-meta";
|
23
|
+
}
|
24
|
+
});
|
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
|
+
|
50
|
+
// src/client/init.tsx
|
51
|
+
import React from "react";
|
52
|
+
import ReactDOM from "react-dom/client";
|
53
|
+
import { jsx } from "react/jsx-runtime";
|
54
|
+
var require_init = __commonJS({
|
55
|
+
"src/client/init.tsx"() {
|
56
|
+
init_esm_shims();
|
57
|
+
init_ks_utils();
|
58
|
+
async function init() {
|
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 = `
|
82
|
+
<h1>Error</h1>
|
83
|
+
<p>${e.message}</p>
|
84
|
+
`;
|
85
|
+
document.body.appendChild(errorElement);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
});
|
89
|
+
export default require_init();
|
90
|
+
//# sourceMappingURL=init.mjs.map
|
@@ -0,0 +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_qewjfurrjspcqzwdqcz2r3oykm/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":[]}
|
package/dist/demo-wrapper.d.mts
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
-
import { DemoWrapperProps } from './
|
3
|
-
import '@knapsack/renderer-webpack-base';
|
4
|
-
import '@knapsack/utils';
|
5
|
-
import '@knapsack/app/renderers';
|
2
|
+
import { D as DemoWrapperProps } from './types-D2eCZXsg.mjs';
|
6
3
|
import '@knapsack/types';
|
7
4
|
import '@knapsack/app/types';
|
8
5
|
|
package/dist/demo-wrapper.d.ts
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
|
-
import { DemoWrapperProps } from './
|
3
|
-
import '@knapsack/renderer-webpack-base';
|
4
|
-
import '@knapsack/utils';
|
5
|
-
import '@knapsack/app/renderers';
|
2
|
+
import { D as DemoWrapperProps } from './types-D2eCZXsg.js';
|
6
3
|
import '@knapsack/types';
|
7
4
|
import '@knapsack/app/types';
|
8
5
|
|
package/dist/demo-wrapper.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/demo-wrapper.tsx"],"sourcesContent":["import type { DemoWrapperProps } from './
|
1
|
+
{"version":3,"sources":["../src/demo-wrapper.tsx"],"sourcesContent":["import type { DemoWrapperProps } from './types';\n\nconst DemoWrapper = ({ children }: DemoWrapperProps) => (\n <div className=\"demo-wrapper\">{children}</div>\n);\n\nexport default DemoWrapper;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGE;AADF,IAAM,cAAc,wBAAC,EAAE,SAAS,MAC9B,4CAAC,SAAI,WAAU,gBAAgB,UAAS,GADtB;AAIpB,IAAO,uBAAQ;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/demo-wrapper.tsx"],"sourcesContent":["import type { DemoWrapperProps } from './
|
1
|
+
{"version":3,"sources":["../src/demo-wrapper.tsx"],"sourcesContent":["import type { DemoWrapperProps } from './types';\n\nconst DemoWrapper = ({ children }: DemoWrapperProps) => (\n <div className=\"demo-wrapper\">{children}</div>\n);\n\nexport default DemoWrapper;\n"],"mappings":";;;;AAGE;AADF,IAAM,cAAc,wBAAC,EAAE,SAAS,MAC9B,oBAAC,SAAI,WAAU,gBAAgB,UAAS,GADtB;AAIpB,IAAO,uBAAQ;","names":[]}
|
package/dist/index.d.mts
CHANGED
@@ -1,17 +1,9 @@
|
|
1
|
-
import { RendererWebpackBase, Renderer } from '@knapsack/renderer-webpack-base';
|
2
|
-
import { Except } from '@knapsack/utils';
|
1
|
+
import { RendererWebpackBase, Renderer, KsJsImport } from '@knapsack/renderer-webpack-base';
|
3
2
|
import { Renderable } from '@knapsack/app/renderers';
|
4
|
-
import { RendererId
|
3
|
+
import { RendererId } from '@knapsack/types';
|
5
4
|
import { KnapsackRenderParams } from '@knapsack/app/types';
|
5
|
+
export { D as DemoWrapperProps } from './types-D2eCZXsg.mjs';
|
6
6
|
|
7
|
-
type DemoWrapperProps = {
|
8
|
-
children: React.ReactNode;
|
9
|
-
patternsUsed: {
|
10
|
-
patternId: string;
|
11
|
-
templateId: string;
|
12
|
-
demoId?: string;
|
13
|
-
}[];
|
14
|
-
} & Except<KnapsackRenderParams, 'patternManifest'>;
|
15
7
|
declare class KnapsackReactRenderer extends RendererWebpackBase implements Renderable {
|
16
8
|
/**
|
17
9
|
* `react.js` & `react-dom.js` root relative paths
|
@@ -51,4 +43,4 @@ declare class KnapsackReactRenderer extends RendererWebpackBase implements Rende
|
|
51
43
|
getTemplateSuggestions: Renderer['getTemplateSuggestions'];
|
52
44
|
}
|
53
45
|
|
54
|
-
export {
|
46
|
+
export { KnapsackReactRenderer };
|
package/dist/index.d.ts
CHANGED
@@ -1,17 +1,9 @@
|
|
1
|
-
import { RendererWebpackBase, Renderer } from '@knapsack/renderer-webpack-base';
|
2
|
-
import { Except } from '@knapsack/utils';
|
1
|
+
import { RendererWebpackBase, Renderer, KsJsImport } from '@knapsack/renderer-webpack-base';
|
3
2
|
import { Renderable } from '@knapsack/app/renderers';
|
4
|
-
import { RendererId
|
3
|
+
import { RendererId } from '@knapsack/types';
|
5
4
|
import { KnapsackRenderParams } from '@knapsack/app/types';
|
5
|
+
export { D as DemoWrapperProps } from './types-D2eCZXsg.js';
|
6
6
|
|
7
|
-
type DemoWrapperProps = {
|
8
|
-
children: React.ReactNode;
|
9
|
-
patternsUsed: {
|
10
|
-
patternId: string;
|
11
|
-
templateId: string;
|
12
|
-
demoId?: string;
|
13
|
-
}[];
|
14
|
-
} & Except<KnapsackRenderParams, 'patternManifest'>;
|
15
7
|
declare class KnapsackReactRenderer extends RendererWebpackBase implements Renderable {
|
16
8
|
/**
|
17
9
|
* `react.js` & `react-dom.js` root relative paths
|
@@ -51,4 +43,4 @@ declare class KnapsackReactRenderer extends RendererWebpackBase implements Rende
|
|
51
43
|
getTemplateSuggestions: Renderer['getTemplateSuggestions'];
|
52
44
|
}
|
53
45
|
|
54
|
-
export {
|
46
|
+
export { KnapsackReactRenderer };
|
package/dist/index.js
CHANGED
@@ -64,13 +64,14 @@ function renderUsageTemplate({
|
|
64
64
|
`;
|
65
65
|
}
|
66
66
|
__name(renderUsageTemplate, "renderUsageTemplate");
|
67
|
+
var demoAppName = "DemoApp";
|
67
68
|
function renderDemoAppTemplate({
|
68
|
-
imports,
|
69
|
+
imports = "",
|
69
70
|
children
|
70
71
|
}) {
|
71
72
|
return `${imports}
|
72
73
|
|
73
|
-
function
|
74
|
+
function ${demoAppName}() {
|
74
75
|
return (
|
75
76
|
${children}
|
76
77
|
)
|
@@ -129,12 +130,14 @@ async function getUsage(data) {
|
|
129
130
|
__name(getUsage, "getUsage");
|
130
131
|
async function getDemoAppUsage({
|
131
132
|
children,
|
132
|
-
imports
|
133
|
+
imports,
|
134
|
+
format
|
133
135
|
}) {
|
134
136
|
const code = renderDemoAppTemplate({
|
135
137
|
children,
|
136
138
|
imports
|
137
139
|
});
|
140
|
+
if (!format) return code;
|
138
141
|
return (0, import_file_utils.formatCode)({
|
139
142
|
contents: code,
|
140
143
|
path: "x.tsx"
|
@@ -718,6 +721,9 @@ var createReactPattern = (0, import_creator_utils.createCreator)({
|
|
718
721
|
}, "getTasks")
|
719
722
|
});
|
720
723
|
|
724
|
+
// src/types.ts
|
725
|
+
var rendererMetaScriptTagId = "ks-react-meta";
|
726
|
+
|
721
727
|
// src/renderer-react.ts
|
722
728
|
var { pkg } = (0, import_file_utils3.findUpPkgJson)(__dirname);
|
723
729
|
import_app2.log.setupUpdateNotifier({ ...pkg, name: pkg.name, version: pkg.version });
|
@@ -742,7 +748,11 @@ var KnapsackReactRenderer = class _KnapsackReactRenderer extends import_renderer
|
|
742
748
|
id,
|
743
749
|
extension: ".jsx",
|
744
750
|
language: "jsx",
|
745
|
-
webpackConfig
|
751
|
+
webpackConfig,
|
752
|
+
extraScripts: [
|
753
|
+
// this is the code in `./client/init.mts`
|
754
|
+
"@knapsack/renderer-react/client"
|
755
|
+
]
|
746
756
|
});
|
747
757
|
this.language = "jsx";
|
748
758
|
this.assets = [];
|
@@ -825,167 +835,82 @@ var KnapsackReactRenderer = class _KnapsackReactRenderer extends import_renderer
|
|
825
835
|
imports: xImports,
|
826
836
|
renderOptions: { pattern, template, demo }
|
827
837
|
}) {
|
828
|
-
const
|
829
|
-
(imp) => imp.type === "extra"
|
838
|
+
const extraImports = this.getJsImports().filter(
|
839
|
+
(imp) => imp.type === "extra"
|
830
840
|
);
|
831
|
-
const { imports, isDeclaredVarsUnique, nameCollisions } = this.makeKsJsImportsUnique({ imports: xImports });
|
841
|
+
const { imports, isDeclaredVarsUnique, nameCollisions } = this.makeKsJsImportsUnique({ imports: [...xImports, ...extraImports] });
|
832
842
|
if (!isDeclaredVarsUnique) {
|
833
843
|
import_app2.log.error(`${nameCollisions.join(", ")} are declared multiple times`, {
|
834
844
|
imports
|
835
845
|
});
|
836
846
|
}
|
837
|
-
const
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
+
const importInfos = imports.map(({ importInfo }) => importInfo);
|
848
|
+
const meta = {
|
849
|
+
demo,
|
850
|
+
moduleImports: (0, import_utils3.groupBy)(importInfos, (importInfo) => importInfo.path),
|
851
|
+
patternId: pattern.id,
|
852
|
+
templateId: template.id,
|
853
|
+
imports,
|
854
|
+
disableReactStrictMode: this.disableReactStrictMode,
|
855
|
+
demoWrapperProps: {
|
856
|
+
pattern,
|
857
|
+
template,
|
858
|
+
demo,
|
859
|
+
patternsUsed: imports.flatMap((imp) => {
|
860
|
+
if (imp.type === "pattern-template") {
|
861
|
+
return [
|
862
|
+
{
|
863
|
+
patternId: imp.patternId,
|
864
|
+
templateId: imp.templateId
|
865
|
+
}
|
866
|
+
];
|
847
867
|
}
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
868
|
+
if (imp.type === "pattern-template-demo") {
|
869
|
+
return [
|
870
|
+
{
|
871
|
+
patternId: imp.patternId,
|
872
|
+
templateId: imp.templateId,
|
873
|
+
demoId: imp.demoId
|
874
|
+
}
|
875
|
+
];
|
856
876
|
}
|
857
|
-
|
877
|
+
return [];
|
878
|
+
})
|
858
879
|
}
|
859
|
-
return [];
|
860
|
-
});
|
861
|
-
const demoWrapperProps = {
|
862
|
-
patternsUsed,
|
863
|
-
pattern,
|
864
|
-
template,
|
865
|
-
demo
|
866
880
|
};
|
867
|
-
const demoWrapperCode = await getUsage({
|
868
|
-
templateName: "DemoWrapper",
|
869
|
-
props: demoWrapperProps,
|
870
|
-
children: `<DemoApp />`
|
871
|
-
// extraProps,
|
872
|
-
});
|
873
|
-
async function renderReact({
|
874
|
-
patterns,
|
875
|
-
theExtraImportNames,
|
876
|
-
ksGlobal
|
877
|
-
}) {
|
878
|
-
if (!ksGlobal) {
|
879
|
-
throw new Error('"window.knapsack" is null');
|
880
|
-
}
|
881
|
-
const components = await ksGlobal.getAllImports({
|
882
|
-
patterns,
|
883
|
-
extras: theExtraImportNames.map((name) => ({ name }))
|
884
|
-
});
|
885
|
-
return components;
|
886
|
-
}
|
887
|
-
__name(renderReact, "renderReact");
|
888
881
|
let code = `
|
889
|
-
|
890
|
-
${
|
891
|
-
${
|
892
|
-
|
893
|
-
patterns: ${JSON.stringify(patternsUsed)},
|
894
|
-
theExtraImportNames: ${JSON.stringify(extraImportNames)},
|
895
|
-
}).then((components) => {
|
896
|
-
const { ${importNames.join(", ")} } = components;
|
897
|
-
const root = document.getElementById('render-root');
|
898
|
-
|
899
|
-
${demoApp}
|
900
|
-
|
901
|
-
const reactDomVersion = parseInt(ReactDOM.version.split('.')[0], 10);
|
902
|
-
|
903
|
-
const ReactRendererResult = () => {
|
904
|
-
if (reactDomVersion < 17 || ${this.disableReactStrictMode}){
|
905
|
-
return (
|
906
|
-
<ErrorCatcher>
|
907
|
-
${demoWrapperCode}
|
908
|
-
</ErrorCatcher>
|
909
|
-
)
|
882
|
+
window.knapsack = window.knapsack || {};
|
883
|
+
window.knapsack.getDemoApp = ({ ${imports.map((i) => i.importInfo.name).join(", ")} }) => {
|
884
|
+
${demoApp}
|
885
|
+
return ${demoAppName}
|
910
886
|
}
|
911
|
-
|
912
|
-
return (
|
913
|
-
<React.StrictMode>
|
914
|
-
<ErrorCatcher>
|
915
|
-
${demoWrapperCode}
|
916
|
-
</ErrorCatcher>
|
917
|
-
</React.StrictMode>
|
918
|
-
)
|
919
|
-
};
|
920
|
-
|
921
|
-
|
922
|
-
if (reactDomVersion > 17){
|
923
|
-
ReactDOM.createRoot(root).render(
|
924
|
-
<ReactRendererResult />
|
925
|
-
)
|
926
|
-
} else {
|
927
|
-
ReactDOM.render(
|
928
|
-
<ReactRendererResult />,
|
929
|
-
root
|
930
|
-
);
|
931
|
-
}
|
932
|
-
}).catch((err) => {
|
933
|
-
console.error(err);
|
934
|
-
const root = document.getElementById('render-root');
|
935
|
-
// Create a new <div> element to contain the error message
|
936
|
-
const errorMsgDiv = document.createElement('div');
|
937
|
-
// Insert the new <div> element before the existing element
|
938
|
-
root.parentNode.insertBefore(errorMsgDiv, root);
|
939
|
-
// add error message so users can see it
|
940
|
-
errorMsgDiv.innerHTML = '<h1>Component Error</h1><p>' + err.message + '</p>';
|
941
|
-
});
|
942
887
|
`;
|
943
|
-
let codeHadError = false;
|
944
888
|
let errorHtmlMsg = "";
|
945
889
|
try {
|
946
|
-
code = await (0, import_renderers.babelCodeForBrowser)({
|
947
|
-
code
|
948
|
-
});
|
890
|
+
code = await (0, import_renderers.babelCodeForBrowser)({ code });
|
949
891
|
} catch (e) {
|
950
|
-
codeHadError = true;
|
951
892
|
console.log(code);
|
952
893
|
console.log("---original code before babel error ^---");
|
953
894
|
console.trace(e.message);
|
954
895
|
code = `console.error(${JSON.stringify(e.message)});`;
|
955
896
|
errorHtmlMsg = `<pre><code>${e.message}</code></pre>`;
|
956
897
|
}
|
957
|
-
if (!codeHadError) {
|
958
|
-
try {
|
959
|
-
code = await (0, import_file_utils3.formatCode)({
|
960
|
-
contents: code,
|
961
|
-
path: "x.tsx"
|
962
|
-
// doing this to set format language
|
963
|
-
});
|
964
|
-
} catch (e) {
|
965
|
-
codeHadError = true;
|
966
|
-
console.log(code);
|
967
|
-
console.log("---original code before prettier error ^---");
|
968
|
-
console.trace(e.message);
|
969
|
-
code = `console.error(${JSON.stringify(e.message)});`;
|
970
|
-
errorHtmlMsg = `<pre><code>${e.message}</code></pre>`;
|
971
|
-
}
|
972
|
-
}
|
973
898
|
const html = `
|
899
|
+
<script type="application/json" id="${rendererMetaScriptTagId}">${JSON.stringify(
|
900
|
+
meta
|
901
|
+
)}</script>
|
902
|
+
<script type="application/javascript">${code}</script>
|
903
|
+
<div id="render-root" class="knapsack-pattern-direct-parent" data-dev-note="Knapsack React Template Wrapper"></div>
|
974
904
|
${this.assets.map((asset) => `<script src="${asset}"></script>`).join("\n")}
|
975
|
-
|
976
905
|
${this.createHtmlTagsForAssetPaths({
|
977
906
|
assets: this.getWebpackAssetPaths(),
|
978
907
|
// we need the scripts to finish adding methods to the global knapsack object synchronously before the client-side code runs that is in the <script> tag below
|
979
908
|
scriptTagsAreAsync: false
|
980
909
|
})}
|
981
|
-
|
982
|
-
<div id="render-root" class="knapsack-pattern-direct-parent" data-dev-note="Knapsack React Template Wrapper"></div>
|
983
|
-
<script type="application/javascript">${code}</script>
|
984
|
-
${errorHtmlMsg}
|
985
|
-
|
910
|
+
${errorHtmlMsg}
|
986
911
|
`;
|
987
912
|
return {
|
988
|
-
ok: !
|
913
|
+
ok: !errorHtmlMsg,
|
989
914
|
html: await (0, import_file_utils3.formatCode)({
|
990
915
|
contents: html,
|
991
916
|
path: "x.html"
|
@@ -1046,7 +971,8 @@ ${errorHtmlMsg}
|
|
1046
971
|
const [demoAppUsage, demoApp] = await Promise.all([
|
1047
972
|
getDemoAppUsage({
|
1048
973
|
children: usage,
|
1049
|
-
imports: importCode
|
974
|
+
imports: importCode,
|
975
|
+
format: true
|
1050
976
|
}),
|
1051
977
|
getDemoAppUsage({
|
1052
978
|
children: usage
|