@knapsack/renderer-webpack-base 4.69.13--canary.4739.37477c8.0 → 4.69.13--canary.4821.ae550c0.0

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.12 (Thu Sep 26 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Merge branch 'latest' into feature/ksp-5560-replace-schema-forms-in-content-blocks ([@GormanDesign](https://github.com/GormanDesign))
6
+
7
+ #### 🏠 Internal
8
+
9
+ - Remove unused types [#4819](https://github.com/knapsack-labs/app-monorepo/pull/4819) ([@greylabel](https://github.com/greylabel))
10
+ - chore(deps): update dependency @types/node to ^20.16.6 [#4846](https://github.com/knapsack-labs/app-monorepo/pull/4846) ([@renovate[bot]](https://github.com/renovate[bot]))
11
+
12
+ #### Authors: 3
13
+
14
+ - [@renovate[bot]](https://github.com/renovate[bot])
15
+ - Grant Gaudet ([@greylabel](https://github.com/greylabel))
16
+ - Matt Gorman ([@GormanDesign](https://github.com/GormanDesign))
17
+
18
+ ---
19
+
1
20
  # v4.69.11 (Fri Sep 20 2024)
2
21
 
3
22
  #### 🏠 Internal
@@ -1,3 +1,3 @@
1
1
  export * from './renderer-webpack-client.mjs';
2
- export type { KsJsImport, KsJsImportInfo } from '../types.js';
2
+ export type { KsJsImportInfo, RendererMetaBase } from '../types.js';
3
3
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/client/index.mts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/client/index.mts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
@@ -1,80 +1,20 @@
1
- import { KsRendererClientMeta } from '@knapsack/types';
2
- import { KsJsImport } from '../types.js';
3
- type ImportedModules<ExportedComponentType> = {
4
- [id: string]: () => Promise<EsModuleObject<ExportedComponentType>>;
5
- };
6
- type AllAvailableImports = KsJsImport[];
7
- /** The result of `import`-ing a module */
8
- type EsModuleObject<ExportedType = unknown> = {
9
- default?: ExportedType;
10
- [key: string]: ExportedType;
11
- };
12
- type GetKsJsImportParam = {
13
- type: 'pattern-template';
14
- patternId: string;
15
- templateId: string;
16
- } | {
17
- type: 'pattern-template-demo';
18
- patternId: string;
19
- templateId: string;
20
- demoId: string;
21
- } | {
22
- type: 'extra';
23
- name: string;
24
- };
25
- type GetKsJsImportPatternParam = {
26
- patternId: string;
27
- templateId: string;
28
- demoId?: string;
29
- };
30
- /**
31
- * This is `window.knapsack` inside the renderer client: the iframe container for renderer components
32
- */
33
- export interface KsRendererClientGlobal<ExportedComponentType = unknown, RendererMetaType extends Record<string, unknown> = Record<string, unknown>, RendererMethods extends Record<string, unknown> = Record<string, unknown>> {
34
- typeName: 'KsRendererClientGlobal';
35
- importedModules: ImportedModules<ExportedComponentType>;
36
- rendererMeta: RendererMetaType;
37
- rendererMethods: RendererMethods;
38
- meta: KsRendererClientMeta;
39
- allAvailableImports: AllAvailableImports;
40
- getImport: (opt: GetKsJsImportParam) => Promise<{
41
- name: string;
42
- /** Most likely a component */
43
- value: ExportedComponentType;
44
- }>;
45
- getImports: (imports: GetKsJsImportParam[]) => Promise<{
46
- [importName: string]: ExportedComponentType;
47
- }>;
48
- getPatternImport: (opt: GetKsJsImportPatternParam) => Promise<{
49
- name: string;
50
- /** Most likely a component */
51
- value: ExportedComponentType;
52
- }>;
53
- getExtraImport: (opt: {
54
- name: string;
55
- }) => Promise<{
56
- name: string;
57
- /** Most likely a component */
58
- value: ExportedComponentType;
59
- }>;
60
- getAllImports: (opt: {
61
- patterns: GetKsJsImportPatternParam[];
62
- extras?: {
63
- name: string;
64
- }[];
65
- }) => Promise<{
66
- [importName: string]: ExportedComponentType;
67
- }>;
68
- }
69
- export declare function getKsRendererClientGlobal<ExportedComponentType, RendererMetaType extends Record<string, unknown>,
1
+ import type { KsJsImportInfo, RendererMetaBase, KsRendererClientUtils } from '../types.js';
2
+ export declare function getKsRendererClientUtils<ExportedComponentType, RendererMetaType extends RendererMetaBase,
70
3
  /**
71
4
  * Any extra properties or methods placed on the window.knapsack object by the renderer in a `<script>` tag
72
5
  */
73
- RendererMethods extends Record<string, unknown>>({ rendererMetaScriptTagId }: {
6
+ RendererMethods extends Record<string, unknown>>({ rendererMetaScriptTagId, assertImport, assertExtraImport, }: {
74
7
  rendererMetaScriptTagId: string;
75
- }): KsRendererClientGlobal<ExportedComponentType, RendererMetaType, RendererMethods>;
8
+ assertImport?: (opt: {
9
+ imp: unknown;
10
+ importInfo: KsJsImportInfo;
11
+ }) => void;
12
+ assertExtraImport?: (opt: {
13
+ imp: unknown;
14
+ importInfo: KsJsImportInfo;
15
+ }) => void;
16
+ }): KsRendererClientUtils<ExportedComponentType, RendererMetaType, RendererMethods>;
76
17
  export declare function showUiToastMsg({ msg }: {
77
18
  msg: string;
78
19
  }): void;
79
- export {};
80
20
  //# sourceMappingURL=renderer-webpack-client.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-webpack-client.d.mts","sourceRoot":"","sources":["../../src/client/renderer-webpack-client.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,oBAAoB,EAGrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAWzC,KAAK,eAAe,CAAC,qBAAqB,IAAI;IAC5C,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAC;CACpE,CAAC;AACF,KAAK,mBAAmB,GAAG,UAAU,EAAE,CAAC;AAExC,0CAA0C;AAC1C,KAAK,cAAc,CAAC,YAAY,GAAG,OAAO,IAAI;IAC5C,OAAO,CAAC,EAAE,YAAY,CA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AAC;AAmFrB,wBAAgB,wBAAwB,CACtC,qBAAqB,EACrB,gBAAgB,SAAS,gBAAgB;AACzC;;GAEG;AACH,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/C,EACA,uBAAuB,EACvB,YAAY,EACZ,iBAAiB,GAClB,EAAE;IACD,uBAAuB,EAAE,MAAM,CAAC;IAChC,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,GAAG,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,cAAc,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3E,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE;QACxB,GAAG,EAAE,OAAO,CAAC;QACb,UAAU,EAAE,cAAc,CAAC;KAC5B,KAAK,IAAI,CAAC;CACZ,GAsFoB,qBAAqB,CACtC,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,CAChB,CACF;AAED,wBAAgB,cAAc,CAAC,EAAE,GAAG,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,QAYtD"}
@@ -4,144 +4,118 @@ const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'u
4
4
  if (!isBrowser) {
5
5
  throw new Error('Cannot get KsRendererClientGlobal in a non-browser environment');
6
6
  }
7
- const createErrorName = (opt) => {
8
- switch (opt.type) {
9
- case 'extra':
10
- return `Extra "${opt.name}"`;
11
- case 'pattern-template':
12
- return `pattern "${opt.patternId}", template "${opt.templateId}"`;
13
- case 'pattern-template-demo':
14
- return `pattern "${opt.patternId}", template "${opt.templateId}", demo "${opt.demoId}"`;
15
- default:
16
- return JSON.stringify(opt);
7
+ function addImportToAllImports({ importInfo, mod, allImports, assertImport, }) {
8
+ const addImport = ({ component, name, }) => {
9
+ if (allImports[name]) {
10
+ throw new Error(`Duplicate import name: "${name}"`);
11
+ }
12
+ if (typeof component !== 'function') {
13
+ throw new Error(`Import "${name}" is not a component, its "typeof" should be "function" but is "${typeof component}"`);
14
+ }
15
+ assertImport?.({ imp: component, importInfo });
16
+ // should this get checked for correct type?
17
+ allImports[name] = component;
18
+ };
19
+ switch (importInfo.type) {
20
+ case 'named': {
21
+ const { name } = importInfo;
22
+ const component = mod[name];
23
+ if (!component) {
24
+ throw new Error(`No named export, ${name}, found for "${importInfo.path}"`);
25
+ }
26
+ addImport({ component, name });
27
+ break;
28
+ }
29
+ case 'default': {
30
+ const { name } = importInfo;
31
+ if (mod.default) {
32
+ addImport({ component: mod.default, name });
33
+ }
34
+ else if (typeof mod === 'function') {
35
+ addImport({ component: mod, name });
36
+ }
37
+ else {
38
+ throw new Error(`No default export found for "${importInfo.path}"`);
39
+ }
40
+ break;
41
+ }
42
+ case 'renamed': {
43
+ const { name, originalName } = importInfo;
44
+ const item = mod[originalName];
45
+ if (!item) {
46
+ throw new Error(`No renamed export, ${originalName}, found for "${importInfo.path}"`);
47
+ }
48
+ addImport({ component: item, name });
49
+ break;
50
+ }
51
+ default: {
52
+ const _exhaustiveCheck = importInfo;
53
+ throw new Error(`Unknown import type: "${JSON.stringify(importInfo)}"`);
54
+ }
17
55
  }
18
- };
19
- export function getKsRendererClientGlobal({ rendererMetaScriptTagId }) {
56
+ }
57
+ export function getKsRendererClientUtils({ rendererMetaScriptTagId, assertImport, assertExtraImport, }) {
20
58
  if (!isObject(window?.knapsack)) {
21
59
  throw new Error(`Could not find "window.knapsack"`);
22
60
  }
23
- const { allAvailableImports, importedModules, ...rendererMethods } = window.knapsack;
24
- if (!Array.isArray(allAvailableImports)) {
25
- throw new Error(`The object "window.knapsack.allAvailableImports" is not a valid "KsJsImports"`);
26
- }
61
+ const { importedModules, ...rendererMethods } = window.knapsack;
27
62
  if (!isObject(importedModules)) {
28
63
  throw new Error(`The object "window.knapsack.importedModules" is not a valid "KsRendererClientGlobalImportedModules"`);
29
64
  }
30
- const findImport = (opt) => {
31
- return allAvailableImports.find((imp) => {
32
- if (imp.type === 'pattern-template' && opt.type === 'pattern-template') {
33
- return (opt.patternId === imp.patternId && opt.templateId === imp.templateId);
34
- }
35
- if (imp.type === 'pattern-template-demo' &&
36
- opt.type === 'pattern-template-demo') {
37
- return (opt.patternId === imp.patternId &&
38
- opt.templateId === imp.templateId &&
39
- opt.demoId === imp.demoId);
65
+ const meta = getJsonFromScriptTag(ksRendererClientMetaId);
66
+ const rendererMeta = getJsonFromScriptTag(rendererMetaScriptTagId);
67
+ const { neededImportsByPath, extraImports } = rendererMeta;
68
+ const getNeededImports = async () => {
69
+ const neededImports = {};
70
+ await Promise.all(Object.entries(neededImportsByPath).map(async ([path, importInfos]) => {
71
+ const getModule = importedModules[path];
72
+ if (!getModule) {
73
+ throw new Error(`No "${path}" module found for "${path}"`);
40
74
  }
41
- if (imp.type === 'extra' && opt.type === 'extra') {
42
- return opt.name === imp.importInfo.name;
75
+ const mod = await getModule();
76
+ if (!mod) {
77
+ throw new Error(`No module contents found for "${path}"`);
43
78
  }
44
- return false;
45
- });
79
+ importInfos.forEach((importInfo) => {
80
+ addImportToAllImports({
81
+ importInfo,
82
+ mod,
83
+ allImports: neededImports,
84
+ assertImport,
85
+ });
86
+ });
87
+ }));
88
+ return neededImports;
46
89
  };
47
- const getImport = async (opt) => {
48
- const theImport = findImport(opt);
49
- if (!theImport) {
50
- throw new Error(`No import found for ${createErrorName(opt)}`);
51
- }
52
- const { importInfo } = theImport;
53
- const getModule = importedModules[importInfo.path];
54
- if (!getModule) {
55
- throw new Error(`No "${importInfo.path}" module found for ${JSON.stringify(opt)}`);
56
- }
57
- const mod = await getModule();
58
- if (!mod) {
59
- throw new Error(`No module found for ${JSON.stringify(opt)}`);
60
- }
61
- switch (importInfo.type) {
62
- case 'all':
63
- return {
64
- value: mod,
65
- name: importInfo.name,
66
- };
67
- case 'default': {
68
- const item = mod.default;
69
- if (!item) {
70
- throw new Error(`No default export found for ${JSON.stringify(opt)}`);
71
- }
72
- return {
73
- value: item,
74
- name: importInfo.name,
75
- };
90
+ const getExtraImports = async () => {
91
+ const theExtraImports = {};
92
+ await Promise.all(Object.entries(extraImports).map(async ([name, importInfo]) => {
93
+ const getModule = importedModules[importInfo.path];
94
+ if (!getModule) {
95
+ throw new Error(`No "${importInfo.path}" module found for "${name}"`);
76
96
  }
77
- case 'named': {
78
- const { name } = importInfo;
79
- const item = mod[name];
80
- if (!item) {
81
- throw new Error(`No named export, ${name}, found for ${JSON.stringify(opt)}`);
82
- }
83
- return {
84
- value: item,
85
- name,
86
- };
97
+ const mod = await getModule();
98
+ if (!mod) {
99
+ throw new Error(`No module found for "${importInfo.path}"`);
87
100
  }
88
- default: {
89
- throw new Error(`Unknown import type`);
90
- }
91
- }
92
- };
93
- const getPatternImport = async ({ patternId, templateId, demoId, }) => {
94
- if (demoId) {
95
- return getImport({
96
- type: 'pattern-template-demo',
97
- patternId,
98
- templateId,
99
- demoId,
101
+ addImportToAllImports({
102
+ importInfo,
103
+ mod,
104
+ allImports: theExtraImports,
105
+ assertImport: assertExtraImport,
100
106
  });
101
- }
102
- return getImport({
103
- type: 'pattern-template',
104
- patternId,
105
- templateId,
106
- });
107
+ }));
108
+ return theExtraImports;
107
109
  };
108
- const getExtraImport = async ({ name, }) => getImport({ type: 'extra', name });
109
- const meta = getJsonFromScriptTag(ksRendererClientMetaId);
110
- const rendererMeta = getJsonFromScriptTag(rendererMetaScriptTagId);
111
110
  const knapsack = {
112
- typeName: 'KsRendererClientGlobal',
113
- allAvailableImports,
114
111
  importedModules,
115
112
  meta,
116
113
  rendererMeta,
117
114
  rendererMethods,
118
- getImport,
119
- getPatternImport,
120
- getExtraImport,
121
- getAllImports: async ({ patterns, extras = [] }) => {
122
- const imported = await Promise.all([
123
- ...patterns.map(getPatternImport),
124
- ...extras.map(getExtraImport),
125
- ]);
126
- return imported.reduce((cur, { name, value }) => {
127
- if (cur[name]) {
128
- throw new Error(`Duplicate import name: ${name}`);
129
- }
130
- cur[name] = value;
131
- return cur;
132
- }, {});
133
- },
134
- getImports: async (importsToGet) => {
135
- const imported = await Promise.all(importsToGet.map(getImport));
136
- return imported.reduce((cur, { name, value }) => {
137
- if (cur[name]) {
138
- throw new Error(`Duplicate import name: ${name}`);
139
- }
140
- cur[name] = value;
141
- return cur;
142
- }, {});
143
- },
115
+ getNeededImports,
116
+ getExtraImports,
144
117
  };
118
+ window.knapsack = knapsack;
145
119
  return knapsack;
146
120
  }
147
121
  export function showUiToastMsg({ msg }) {
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-webpack-client.mjs","sourceRoot":"","sources":["../../src/client/renderer-webpack-client.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,sBAAsB,GAEvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,SAAS,GACb,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAE1E,IAAI,CAAC,SAAS,EAAE,CAAC;IACf,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;AACJ,CAAC;AA4ED,MAAM,eAAe,GAAG,CAAC,GAAuB,EAAU,EAAE;IAC1D,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,UAAU,GAAG,CAAC,IAAI,GAAG,CAAC;QAC/B,KAAK,kBAAkB;YACrB,OAAO,YAAY,GAAG,CAAC,SAAS,gBAAgB,GAAG,CAAC,UAAU,GAAG,CAAC;QACpE,KAAK,uBAAuB;YAC1B,OAAO,YAAY,GAAG,CAAC,SAAS,gBAAgB,GAAG,CAAC,UAAU,YAAY,GAAG,CAAC,MAAM,GAAG,CAAC;QAC1F;YACE,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,yBAAyB,CAOvC,EAAE,uBAAuB,EAAuC;IAChE,IAAI,CAAC,QAAQ,CAAE,MAAc,EAAE,QAAQ,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,K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O;IAC7B,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB;QACE,gGAAgG;QAChG,IAAI,EAAE,4BAA4B;QAClC,GAAG;QACH,YAAY,EAAE,MAAM;KACS,EAC/B,GAAG,CACJ,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"renderer-webpack-client.mjs","sourceRoot":"","sources":["../../src/client/renderer-webpack-client.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,sBAAsB,GAEvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AASnD,MAAM,SAAS,GACb,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAE1E,IAAI,CAAC,SAAS,EAAE,CAAC;IACf,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAwB,EACpD,UAAU,EACV,GAAG,EACH,UAAU,EACV,YAAY,GAMb;IACC,MAAM,SAAS,GAAG,CAAC,EACjB,SAAS,EACT,IAAI,GAIL,EAAE,EAAE;QACH,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,GAAG,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,WAAW,IAAI,mEAAmE,OAAO,SAAS,GAAG,CACtG,CAAC;QACJ,CAAC;QACD,YAAY,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;QAC/C,4CAA4C;QAC5C,UAAU,CAAC,IAAI,CAAC,GAAG,SAAkC,CAAC;IACxD,CAAC,CAAC;IAEF,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACxB,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,EAAE,IAAI,E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OAAO,QAIN,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAE,GAAG,EAAmB;IACrD,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;IACjD,IAAI,CAAC,eAAe;QAAE,OAAO;IAC7B,MAAM,CAAC,MAAM,CAAC,WAAW,CACvB;QACE,gGAAgG;QAChG,IAAI,EAAE,4BAA4B;QAClC,GAAG;QACH,YAAY,EAAE,MAAM;KACS,EAC/B,GAAG,CACJ,CAAC;AACJ,CAAC"}
@@ -1,3 +1,2 @@
1
- import type { KsJsImport } from './types';
2
- export declare function getEntryString(imports: KsJsImport[]): string;
1
+ export declare function getEntryString(importPaths: Set<string>): string;
3
2
  //# sourceMappingURL=create-js-import-entry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-js-import-entry.d.ts","sourceRoot":"","sources":["../src/create-js-import-entry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,MAAM,CAkB5D"}
1
+ {"version":3,"file":"create-js-import-entry.d.ts","sourceRoot":"","sources":["../src/create-js-import-entry.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,CAW/D"}
@@ -1,21 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEntryString = getEntryString;
4
- function getEntryString(imports) {
5
- const importedModulePaths = [
6
- ...new Set(imports.map((i) => i.importInfo.path)),
7
- ];
4
+ function getEntryString(importPaths) {
8
5
  return `
9
- const allAvailableImports = ${JSON.stringify(imports, null, ' ')};
10
-
11
6
  const importedModules = {
12
- ${importedModulePaths
7
+ ${[...importPaths]
13
8
  .map((path) => `'${path}': () => import('${path}'),`)
14
9
  .join('\n')}
15
10
  };
16
11
 
17
12
  window.knapsack = window.knapsack || {};
18
- window.knapsack.allAvailableImports = allAvailableImports;
19
13
  window.knapsack.importedModules = importedModules;
20
14
  `;
21
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-js-import-entry.js","sourceRoot":"","sources":["../src/create-js-import-entry.ts"],"names":[],"mappings":";;AAEA,wCAkBC;AAlBD,SAAgB,cAAc,CAAC,OAAqB;IAClD,MAAM,mBAAmB,GAAG;QAC1B,GAAG,IAAI,GAAG,CAAS,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;KAC1D,CAAC;IAEF,OAAO;8BACqB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;;;IAG7D,mBAAmB;SAClB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,oBAAoB,IAAI,KAAK,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC;;;;;;CAMd,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"create-js-import-entry.js","sourceRoot":"","sources":["../src/create-js-import-entry.ts"],"names":[],"mappings":";;AAAA,wCAWC;AAXD,SAAgB,cAAc,CAAC,WAAwB;IACrD,OAAO;;IAEL,CAAC,GAAG,WAAW,CAAC;SACf,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,oBAAoB,IAAI,KAAK,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC;;;;;CAKd,CAAC;AACF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './renderer-webpack-base';
2
2
  export * from './types';
3
+ export * from './utils';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./renderer-webpack-base"), exports);
18
18
  __exportStar(require("./types"), exports);
19
+ __exportStar(require("./utils"), exports);
19
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,0CAAwB;AACxB,0CAAwB"}
@@ -1,49 +1,28 @@
1
1
  import { RendererId } from '@knapsack/types';
2
- import { RendererBase, type Renderable } from '@knapsack/app/renderers';
2
+ import { CliLifecycle, RendererBase, type Renderable } from '@knapsack/app/renderers';
3
3
  import { Configuration as WebpackConfig } from 'webpack';
4
- import { KsJsImport } from './types';
5
- export declare abstract class RendererWebpackBase extends RendererBase {
4
+ import { KsJsImportInfo, KsJsImportMap } from './types';
5
+ export declare abstract class RendererWebpackBase extends RendererBase implements CliLifecycle {
6
6
  #private;
7
7
  private webpack;
8
8
  private webpackConfig;
9
9
  private webpackCompiler;
10
10
  private extraScripts;
11
11
  private entryFilePath;
12
- constructor({ id, extension, language, webpackConfig, extraScripts, }: {
12
+ constructor({ id, language, webpackConfig, extraScripts, codeSrcs, }: {
13
13
  id: RendererId;
14
- extension: string;
15
14
  language: string;
16
15
  webpackConfig?: WebpackConfig;
17
16
  extraScripts?: string[];
17
+ codeSrcs: string[];
18
18
  });
19
- init(opt: Parameters<RendererBase['init']>[0]): Promise<void>;
20
- hydrate(opt: Parameters<RendererBase['hydrate']>[0]): Promise<void>;
21
- /**
22
- * @see {getJsImport} for types "pattern-template" and "pattern-template-demo"
23
- * @see {getJsImportExtra} for type "extra"
24
- */
25
- getJsImports(): KsJsImport[];
26
- /**
27
- * @see {getJsImports} for all
28
- * @see {getJsImportExtra} for type "extra"
29
- */
30
- getJsImport({ patternId, templateId, demoId, }: {
31
- patternId: string;
32
- templateId: string;
33
- demoId?: string;
34
- }): Exclude<KsJsImport, {
35
- type: 'extra';
36
- }>;
37
- /**
38
- * @see {getJsImports} for all
39
- * @see {getJsImport} for types "pattern-template" and "pattern-template-demo"
40
- */
41
- getJsImportExtra({ name, }: {
42
- name: string;
43
- }): Extract<KsJsImport, {
44
- type: 'extra';
45
- }>;
46
- private writeKsEntryFile;
19
+ setConfig: RendererBase['setConfig'];
20
+ hydrate: CliLifecycle['hydrate'];
21
+ addUniqueValueToImportMap({ importMap, path: originalPath, alias, }: {
22
+ importMap: KsJsImportMap;
23
+ path: string;
24
+ alias: string;
25
+ }): Promise<KsJsImportInfo>;
47
26
  get webpackVersion(): {
48
27
  majorVersion: number;
49
28
  isWebpack4: boolean;
@@ -51,43 +30,29 @@ export declare abstract class RendererWebpackBase extends RendererBase {
51
30
  version: string;
52
31
  };
53
32
  createWebpackConfig(): WebpackConfig;
54
- private prepWebpack;
55
33
  /**
56
34
  * Every asset file path needed in `<script>` tags
57
35
  */
58
36
  getWebpackAssetPaths(): string[];
59
- createHtmlTagsForAssetPaths({ assets, scriptTagsAreAsync, }: {
37
+ static createHtmlTagsForAssetPaths({ assets, scriptTagsAreAsync, }: {
60
38
  assets: string[];
61
39
  scriptTagsAreAsync: boolean;
62
40
  }): string;
63
- build(): Promise<void>;
41
+ build: CliLifecycle['build'];
64
42
  /** Starts a webpack watch, returns an object with a `.close()` method for shutting down */
65
43
  private startWebpackWatch;
66
- watch(_opt: Parameters<RendererBase['watch']>[0]): Promise<void>;
44
+ watch(): Promise<void>;
67
45
  onChange(): void;
68
- abstract getUsageAndImports(_opt: Parameters<Renderable['render']>[0]): Promise<{
46
+ abstract getUsageAndImports(_opt: Parameters<Renderable['render']>[0] & {
47
+ importMap: KsJsImportMap;
48
+ }): Promise<{
69
49
  usage: string;
70
- imports: KsJsImport[];
50
+ importMap: KsJsImportMap;
71
51
  }>;
72
52
  getUsage: Renderable['getUsage'];
73
- makeKsJsImportsUnique({ imports }: {
74
- imports: KsJsImport[];
75
- }): {
76
- imports: KsJsImport[];
77
- nameCollisions: string[];
78
- /** all declared vars */
79
- declaredVars: string[];
80
- isDeclaredVarsUnique: boolean;
81
- };
82
- createJsImportCodeBlock({ imports: nonUniqueImports, }: {
83
- imports: KsJsImport[];
84
- }): {
85
- code: string;
86
- /** all declared vars */
87
- declaredVars: string[];
88
- isDeclaredVarsUnique: boolean;
89
- nameCollisions: string[];
90
- };
53
+ static createJsImportCodeBlock({ importMap, }: {
54
+ importMap: KsJsImportMap;
55
+ }): string;
91
56
  }
92
- export type Renderer = Renderable & RendererWebpackBase;
57
+ export type Renderer = Renderable & RendererWebpackBase & CliLifecycle;
93
58
  //# sourceMappingURL=renderer-webpack-base.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer-webpack-base.d.ts","sourceRoot":"","sources":["../src/renderer-webpack-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAgBxE,OAAgB,EAEd,aAAa,IAAI,aAAa,EAG/B,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AA8BrC,8BAAsB,mBAAoB,SAAQ,YAAY;;IAC5D,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,eAAe,CAAkB;IAGzC,OAAO,CAAC,YAAY,CAAW;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