@knapsack/renderer-webpack-base 4.69.13--canary.4860.ba46b2a.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/dist/client/index.d.mts +1 -1
- package/dist/client/index.d.mts.map +1 -1
- package/dist/client/renderer-webpack-client.d.mts +12 -72
- package/dist/client/renderer-webpack-client.d.mts.map +1 -1
- package/dist/client/renderer-webpack-client.mjs +92 -118
- package/dist/client/renderer-webpack-client.mjs.map +1 -1
- package/dist/create-js-import-entry.d.ts +1 -2
- package/dist/create-js-import-entry.d.ts.map +1 -1
- package/dist/create-js-import-entry.js +2 -8
- package/dist/create-js-import-entry.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/renderer-webpack-base.d.ts +23 -58
- package/dist/renderer-webpack-base.d.ts.map +1 -1
- package/dist/renderer-webpack-base.js +159 -226
- package/dist/renderer-webpack-base.js.map +1 -1
- package/dist/types.d.ts +45 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +8 -0
- package/dist/utils.js.map +1 -0
- package/package.json +11 -11
package/dist/client/index.d.mts
CHANGED
@@ -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,
|
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 {
|
2
|
-
|
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
|
-
|
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":"
|
1
|
+
{"version":3,"file":"renderer-webpack-client.d.mts","sourceRoot":"","sources":["../../src/client/renderer-webpack-client.mts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EAGtB,MAAM,aAAa,CAAC;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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
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 {
|
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
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
42
|
-
|
75
|
+
const mod = await getModule();
|
76
|
+
if (!mod) {
|
77
|
+
throw new Error(`No module contents found for "${path}"`);
|
43
78
|
}
|
44
|
-
|
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
|
48
|
-
const
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
89
|
-
|
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
|
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
|
-
|
119
|
-
|
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;
|
1
|
+
{"version":3,"file":"renderer-webpack-client.mjs","sourceRoot":"","sources":["../../src/client/renderer-webpack-client.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAA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H,YAAY,EAAE,MAAM;KACS,EAC/B,GAAG,CACJ,CAAC;AACJ,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"create-js-import-entry.d.ts","sourceRoot":"","sources":["../src/create-js-import-entry.ts"],"names":[],"mappings":"AAAA,
|
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(
|
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
|
-
${
|
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":";;
|
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
package/dist/index.d.ts.map
CHANGED
@@ -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 {
|
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,
|
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
|
-
|
20
|
-
hydrate
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
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(
|
44
|
+
watch(): Promise<void>;
|
67
45
|
onChange(): void;
|
68
|
-
abstract getUsageAndImports(_opt: Parameters<Renderable['render']>[0]
|
46
|
+
abstract getUsageAndImports(_opt: Parameters<Renderable['render']>[0] & {
|
47
|
+
importMap: KsJsImportMap;
|
48
|
+
}): Promise<{
|
69
49
|
usage: string;
|
70
|
-
|
50
|
+
importMap: KsJsImportMap;
|
71
51
|
}>;
|
72
52
|
getUsage: Renderable['getUsage'];
|
73
|
-
|
74
|
-
|
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,
|
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,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAUjC,OAAgB,EAEd,aAAa,IAAI,aAAa,EAG/B,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AA8BxD,8BAAsB,mBACpB,SAAQ,YACR,YAAW,YAAY;;IAEvB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,eAAe,CAAkB;IAGzC,OAAO,CAAC,YAAY,CAAW;IAC/B,OAAO,CAAC,aAAa,CAAS;gBAIlB,EACV,EAAE,EACF,QAAQ,EACR,aAAkB,EAClB,YAAiB,EACjB,QAAQ,GACT,EAAE;QACD,EAAE,EAAE,UAAU,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,aAAa,CAAC;QAC9B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB;IAoBQ,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,CAW3C;IAEF,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAY9B;IAEI,yBAAyB,CAAC,E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