@lwrjs/core 0.5.11-alpha.1 → 0.6.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/env-config.cjs +31 -3
- package/build/cjs/index.cjs +41 -10
- package/build/cjs/middlewares/api-middleware.cjs +8 -7
- package/build/cjs/middlewares/ui-middleware.cjs +26 -21
- package/build/cjs/middlewares/utils.cjs +1 -1
- package/build/cjs/tools/static-generation.cjs +259 -114
- package/build/cjs/tools/utils/network-dispatcher.cjs +22 -2
- package/build/cjs/tools/utils/stream.cjs +9 -1
- package/build/cjs/validation/app-config-context.cjs +5 -2
- package/build/cjs/validation/app-config.cjs +1 -0
- package/build/es/env-config.js +32 -3
- package/build/es/index.js +48 -11
- package/build/es/middlewares/api-middleware.js +10 -7
- package/build/es/middlewares/ui-middleware.js +29 -22
- package/build/es/middlewares/utils.d.ts +2 -5
- package/build/es/middlewares/utils.js +3 -3
- package/build/es/tools/static-generation.d.ts +95 -6
- package/build/es/tools/static-generation.js +399 -166
- package/build/es/tools/types.d.ts +22 -2
- package/build/es/tools/utils/network-dispatcher.d.ts +3 -0
- package/build/es/tools/utils/network-dispatcher.js +26 -2
- package/build/es/tools/utils/stream.d.ts +5 -0
- package/build/es/tools/utils/stream.js +13 -1
- package/build/es/validation/app-config-context.d.ts +2 -2
- package/build/es/validation/app-config-context.js +3 -0
- package/build/es/validation/app-config.js +1 -0
- package/package.json +29 -25
package/build/es/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { deepFreeze, getExperimentalFeatures } from '@lwrjs/shared-utils';
|
|
1
|
+
import { deepFreeze, getExperimentalFeatures, DEFAULT_LWR_BOOTSTRAP_CONFIG } from '@lwrjs/shared-utils';
|
|
2
2
|
import { LwrCompiler } from '@lwrjs/compiler';
|
|
3
3
|
import { LwrModuleBundler } from '@lwrjs/module-bundler';
|
|
4
4
|
import { LwrModuleRegistry } from '@lwrjs/module-registry';
|
|
5
5
|
import { LwrResourceRegistry } from '@lwrjs/resource-registry';
|
|
6
6
|
import { LwrAssetRegistry } from '@lwrjs/asset-registry';
|
|
7
7
|
import { LwrViewRegistry } from '@lwrjs/view-registry';
|
|
8
|
+
import { LwrServerError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
|
|
8
9
|
import { normalizeConfig, explodeMode } from './env-config.js';
|
|
9
10
|
import { LwrApplicationObserver } from './lwr-app-observer.js';
|
|
10
11
|
import localeMiddleware from './middlewares/locale-middleware.js';
|
|
@@ -52,10 +53,12 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
52
53
|
};
|
|
53
54
|
const hookProviders = await getServices(rawLwrConfig.hooks, undefined, rawLwrConfig);
|
|
54
55
|
const { lwrConfig, dataConfig, runtimeConfig } = await runConfigurationsHook(hookProviders, rawLwrConfig, rawDataConfig, rawRuntimeEnvConfig);
|
|
56
|
+
const assetTransformers = await getServices(rawLwrConfig.assetTransformers, undefined, rawLwrConfig);
|
|
55
57
|
const appObserver = new LwrApplicationObserver();
|
|
56
58
|
const appEmitter = appObserver.createLwrEmitter();
|
|
57
59
|
const compiler = new LwrCompiler();
|
|
58
60
|
const assetRegistry = new LwrAssetRegistry({
|
|
61
|
+
assetTransformers,
|
|
59
62
|
appObserver,
|
|
60
63
|
appEmitter,
|
|
61
64
|
runtimeEnvironment: runtimeConfig,
|
|
@@ -96,9 +99,9 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
96
99
|
const { cacheDir, lwc: { modules = [] }, routes, errorRoutes, rootDir, contentDir, layoutsDir, locker, amdLoader, esmLoader, environment, } = lwrConfig;
|
|
97
100
|
const { onModuleDefinitionChange, onModuleSourceChange } = appObserver;
|
|
98
101
|
const { notifyModuleDefinitionChanged, notifyModuleSourceChanged, notifyViewSourceChanged, notifyAssetSourceChanged, } = appEmitter;
|
|
99
|
-
const providerContext =
|
|
102
|
+
const providerContext = {
|
|
100
103
|
compiler,
|
|
101
|
-
appObserver: { onModuleDefinitionChange, onModuleSourceChange },
|
|
104
|
+
appObserver: deepFreeze({ onModuleDefinitionChange, onModuleSourceChange }),
|
|
102
105
|
appEmitter: {
|
|
103
106
|
notifyModuleDefinitionChanged: (payload) => notifyModuleDefinitionChanged.call(appEmitter, payload),
|
|
104
107
|
notifyModuleSourceChanged: (payload) => notifyModuleSourceChanged.call(appEmitter, payload),
|
|
@@ -106,10 +109,11 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
106
109
|
notifyAssetSourceChanged: (payload) => notifyAssetSourceChanged.call(appEmitter, payload),
|
|
107
110
|
},
|
|
108
111
|
moduleRegistry: moduleRegistry.getPublicApi(),
|
|
112
|
+
moduleBundler: moduleBundler,
|
|
109
113
|
resourceRegistry: resourceRegistry.getPublicApi(),
|
|
110
114
|
viewRegistry: viewRegistry.getPublicApi(),
|
|
111
115
|
assetRegistry: assetRegistry.getPublicApi(),
|
|
112
|
-
config: {
|
|
116
|
+
config: deepFreeze({
|
|
113
117
|
cacheDir,
|
|
114
118
|
modules,
|
|
115
119
|
routes,
|
|
@@ -121,9 +125,9 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
121
125
|
amdLoader,
|
|
122
126
|
esmLoader,
|
|
123
127
|
environment,
|
|
124
|
-
},
|
|
125
|
-
runtimeEnvironment: runtimeConfig,
|
|
126
|
-
}
|
|
128
|
+
}),
|
|
129
|
+
runtimeEnvironment: deepFreeze(runtimeConfig),
|
|
130
|
+
};
|
|
127
131
|
// Module Providers
|
|
128
132
|
const moduleProviders = await getServices(lwrConfig.moduleProviders, providerContext, lwrConfig);
|
|
129
133
|
moduleRegistry.addModuleProviders(moduleProviders);
|
|
@@ -132,7 +136,10 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
132
136
|
resourceRegistry.addResourceProviders(resourceProviders);
|
|
133
137
|
// View Providers
|
|
134
138
|
const viewProviders = await getServices(lwrConfig.viewProviders, providerContext, lwrConfig);
|
|
139
|
+
// View Transformers
|
|
140
|
+
const viewTransformers = await getServices(rawLwrConfig.viewTransformers, providerContext, rawLwrConfig);
|
|
135
141
|
viewRegistry.addViewProviders(viewProviders);
|
|
142
|
+
viewRegistry.addViewTransformers(viewTransformers);
|
|
136
143
|
await viewRegistry.initializeViewProviders();
|
|
137
144
|
// Asset Providers
|
|
138
145
|
const assetProviders = await getServices(lwrConfig.assetProviders, providerContext, lwrConfig);
|
|
@@ -154,9 +161,15 @@ export class LwrApp {
|
|
|
154
161
|
}
|
|
155
162
|
async init() {
|
|
156
163
|
if (!this.initialized) {
|
|
157
|
-
const context = await initContext(this.app, this.server, this.config);
|
|
158
|
-
initMiddlewares(this.app, this.server, context);
|
|
159
164
|
this.initialized = true;
|
|
165
|
+
try {
|
|
166
|
+
const context = await initContext(this.app, this.server, this.config);
|
|
167
|
+
initMiddlewares(this.app, this.server, context);
|
|
168
|
+
}
|
|
169
|
+
catch (e) {
|
|
170
|
+
this.initialized = false;
|
|
171
|
+
throw e;
|
|
172
|
+
}
|
|
160
173
|
}
|
|
161
174
|
}
|
|
162
175
|
async listen(callback) {
|
|
@@ -165,13 +178,20 @@ export class LwrApp {
|
|
|
165
178
|
const { serverMode, port } = config;
|
|
166
179
|
server.listen(port || config.port, async () => {
|
|
167
180
|
if (process.env.WARMUP?.toLowerCase() === 'true') {
|
|
168
|
-
|
|
181
|
+
try {
|
|
182
|
+
await warmupServer(config, app.getInternalRequestKey());
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
throw createSingleDiagnosticError({
|
|
186
|
+
description: descriptions.SERVER.WARMUP_ERROR(err.message),
|
|
187
|
+
}, LwrServerError);
|
|
188
|
+
}
|
|
169
189
|
}
|
|
170
190
|
callback?.({ serverMode, port });
|
|
171
191
|
});
|
|
172
192
|
}
|
|
173
193
|
async close() {
|
|
174
|
-
await this.server.close();
|
|
194
|
+
this.server?.close && (await this.server.close());
|
|
175
195
|
}
|
|
176
196
|
getInternalServer() {
|
|
177
197
|
return this.app.getImpl();
|
|
@@ -184,8 +204,25 @@ export async function generateStaticSite(config) {
|
|
|
184
204
|
config = config || {};
|
|
185
205
|
config.serverType = 'fs'; // override serverType
|
|
186
206
|
const lwrApp = createServer(config);
|
|
207
|
+
overrideConfigAsSrc(lwrApp);
|
|
187
208
|
await lwrApp.init();
|
|
188
209
|
const dispatcher = lwrApp.getInternalServer();
|
|
189
210
|
await new SiteGenerator().buildStaticApplication(lwrApp.getConfig(), dispatcher);
|
|
190
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Create normalized config for static generation forcing the app config to come as src
|
|
214
|
+
*/
|
|
215
|
+
function overrideConfigAsSrc(lwrApp) {
|
|
216
|
+
if (getExperimentalFeatures().ENABLE_FINGERPRINTS) {
|
|
217
|
+
const normalizedConfig = lwrApp.getConfig();
|
|
218
|
+
const routes = normalizedConfig.routes || [];
|
|
219
|
+
for (const route of routes) {
|
|
220
|
+
route.bootstrap = {
|
|
221
|
+
...DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
222
|
+
...route.bootstrap,
|
|
223
|
+
configAsSrc: true,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
191
228
|
//# sourceMappingURL=index.js.map
|
|
@@ -61,20 +61,20 @@ export default function apiMiddleware(app, context) {
|
|
|
61
61
|
// TODO might be able to remove this in the future but not sure how to properly send
|
|
62
62
|
// back bundleRecord imports with absolute uris (lwc is the main one)
|
|
63
63
|
if (bundleDef.bundleRecord.imports) {
|
|
64
|
-
for (
|
|
65
|
-
const
|
|
64
|
+
for (const theImport of bundleDef.bundleRecord.imports) {
|
|
65
|
+
const childSpecifier = theImport.specifier;
|
|
66
66
|
// eslint-disable-next-line no-await-in-loop
|
|
67
|
-
const id = await getVersionedModuleId(
|
|
67
|
+
const id = await getVersionedModuleId(childSpecifier, moduleRegistry);
|
|
68
68
|
// eslint-disable-next-line no-await-in-loop
|
|
69
69
|
const uri = await moduleRegistry.resolveModuleUri(id, runtimeEnvironment, runtimeParams);
|
|
70
70
|
resolvedUris.push(uri);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
if (bundleDef.bundleRecord.dynamicImports) {
|
|
74
|
-
for (
|
|
75
|
-
const
|
|
74
|
+
for (const theImport of bundleDef.bundleRecord.dynamicImports) {
|
|
75
|
+
const childSpecifier = theImport.specifier;
|
|
76
76
|
// eslint-disable-next-line no-await-in-loop
|
|
77
|
-
const id = await getVersionedModuleId(
|
|
77
|
+
const id = await getVersionedModuleId(childSpecifier, moduleRegistry);
|
|
78
78
|
// eslint-disable-next-line no-await-in-loop
|
|
79
79
|
const uri = await moduleRegistry.resolveModuleUri(id, runtimeEnvironment, runtimeParams);
|
|
80
80
|
resolvedUris.push(uri);
|
|
@@ -307,7 +307,10 @@ export default function apiMiddleware(app, context) {
|
|
|
307
307
|
({ moduleIds } = getMappingIdentity(req));
|
|
308
308
|
const { runtimeEnvironment, runtimeParams } = requestContext;
|
|
309
309
|
const importMetadata = await getImportMetadataMappings(moduleIds, runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler);
|
|
310
|
-
|
|
310
|
+
// Include import metadata as an object for use with the static site generator
|
|
311
|
+
res.setMetadata({ importMetadata });
|
|
312
|
+
// Respond to request
|
|
313
|
+
res.status(200).type('application/json').send(importMetadata);
|
|
311
314
|
}
|
|
312
315
|
catch (e) {
|
|
313
316
|
console.log(e);
|
|
@@ -2,13 +2,14 @@ import ms from 'ms';
|
|
|
2
2
|
import { DiagnosticsError } from '@lwrjs/diagnostics';
|
|
3
3
|
import { LwrViewHandler } from '@lwrjs/view-registry';
|
|
4
4
|
import { isSupportedEnvironment } from './utils.js';
|
|
5
|
+
import { getClientBootstrapConfigurationRoutes, extractRequestParams } from '@lwrjs/shared-utils';
|
|
5
6
|
export default function uiMiddleware(app, context) {
|
|
6
7
|
const { viewRegistry, moduleRegistry, runtimeEnvironment: defaultRuntimeEnvironment } = context;
|
|
7
8
|
const { environment: environmentConfig, routes, errorRoutes } = context.appConfig;
|
|
8
9
|
const route404 = errorRoutes.find((r) => r.status === 404);
|
|
9
10
|
const route500 = errorRoutes.find((r) => r.status === 500);
|
|
10
11
|
const viewHandler = new LwrViewHandler({ viewRegistry, moduleRegistry }, context.appConfig);
|
|
11
|
-
async function
|
|
12
|
+
async function sendViewResponse(req, res, route, defaultStatus = 200) {
|
|
12
13
|
if (!req.validateJsonRequest()) {
|
|
13
14
|
res.status(400).send({ error: 'Accept header and json query parameter are incompatible' });
|
|
14
15
|
return;
|
|
@@ -28,7 +29,7 @@ export default function uiMiddleware(app, context) {
|
|
|
28
29
|
url: req.originalUrl,
|
|
29
30
|
params: req.params,
|
|
30
31
|
query: req.query,
|
|
31
|
-
requestPath: req.path,
|
|
32
|
+
requestPath: req.path, // Runtime resolved version vs. the original route path
|
|
32
33
|
};
|
|
33
34
|
const response = req.isJsonRequest()
|
|
34
35
|
? await viewHandler.getViewJson(viewRequest, route, runtimeEnvironment, runtimeParams)
|
|
@@ -58,27 +59,33 @@ export default function uiMiddleware(app, context) {
|
|
|
58
59
|
console.error(error);
|
|
59
60
|
}
|
|
60
61
|
if (route500 && defaultStatus !== 500) {
|
|
61
|
-
await
|
|
62
|
+
await sendViewResponse(req, res, route500, 500);
|
|
62
63
|
}
|
|
63
64
|
else {
|
|
64
65
|
res.status(500).send(`500 - Error retrieving view for route "${route.id}"`);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
async function sendConfigurationResponse(req, res,
|
|
69
|
+
async function sendConfigurationResponse(req, res, defaultStatus = 200) {
|
|
69
70
|
const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
70
|
-
const {
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
const { appId, encodedViewPath } = req.params;
|
|
72
|
+
// Match the route id
|
|
73
|
+
const route = routes.find((route) => route.id === appId);
|
|
74
|
+
if (!route) {
|
|
75
|
+
res.status(404).send({ error: `LWR configuration for "${appId} is not available"` });
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
75
78
|
try {
|
|
79
|
+
// decode the resolved view path and extract any params.
|
|
80
|
+
const url = decodeURIComponent(encodedViewPath);
|
|
81
|
+
const requestPath = route.path;
|
|
82
|
+
const params = extractRequestParams(requestPath, url, req.params);
|
|
76
83
|
// HTML document
|
|
77
84
|
const viewRequest = {
|
|
78
85
|
url,
|
|
79
|
-
params
|
|
86
|
+
params,
|
|
80
87
|
query: req.query,
|
|
81
|
-
requestPath,
|
|
88
|
+
requestPath, // Runtime resolved version vs. the original route path
|
|
82
89
|
};
|
|
83
90
|
const response = await viewHandler.getViewConfiguration(viewRequest, route, runtimeEnvironment, runtimeParams);
|
|
84
91
|
if (!response) {
|
|
@@ -108,7 +115,7 @@ export default function uiMiddleware(app, context) {
|
|
|
108
115
|
console.error(error);
|
|
109
116
|
}
|
|
110
117
|
if (route500 && defaultStatus !== 500) {
|
|
111
|
-
await
|
|
118
|
+
await sendViewResponse(req, res, route500, 500);
|
|
112
119
|
}
|
|
113
120
|
else {
|
|
114
121
|
res.status(500).send(`500 - Error retrieving route "${route.id}"`);
|
|
@@ -120,29 +127,29 @@ export default function uiMiddleware(app, context) {
|
|
|
120
127
|
// Seems like we only support get or post
|
|
121
128
|
if (route.method === 'post') {
|
|
122
129
|
app.post(route.path, async (req, res) => {
|
|
123
|
-
await
|
|
130
|
+
await sendViewResponse(req, res, route);
|
|
124
131
|
});
|
|
125
132
|
}
|
|
126
133
|
else {
|
|
127
134
|
// vanity urls
|
|
128
135
|
app.get(route.path, async (req, res) => {
|
|
129
|
-
await
|
|
136
|
+
await sendViewResponse(req, res, route);
|
|
130
137
|
});
|
|
131
138
|
// canonical URL
|
|
132
139
|
app.get([
|
|
133
140
|
`/:apiVersion/application/:format/l/:locale/ai/:appId${route.path}`,
|
|
134
141
|
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId${route.path}`,
|
|
142
|
+
`/:apiVersion/application/:format/ai/:appId${route.path}`,
|
|
143
|
+
`/:apiVersion/application/:format/e/:environment/ai/:appId${route.path}`,
|
|
135
144
|
], async (req, res) => {
|
|
136
|
-
await
|
|
137
|
-
});
|
|
138
|
-
app.get([
|
|
139
|
-
`/:apiVersion/application/:format/l/:locale/ai/:appId/configuration/ci${route.path}`,
|
|
140
|
-
`/:apiVersion/application/:format/l/:locale/e/:environment/ai/:appId/configuration/ci${route.path}`,
|
|
141
|
-
], async (req, res) => {
|
|
142
|
-
await sendConfigurationResponse(req, res, route);
|
|
145
|
+
await sendViewResponse(req, res, route);
|
|
143
146
|
});
|
|
144
147
|
}
|
|
145
148
|
});
|
|
149
|
+
const clientBootstrapConfigurationRoutes = getClientBootstrapConfigurationRoutes();
|
|
150
|
+
app.get(clientBootstrapConfigurationRoutes, async (req, res) => {
|
|
151
|
+
await sendConfigurationResponse(req, res);
|
|
152
|
+
});
|
|
146
153
|
// TODO nrkruk - This needs to be more generalized and visible at the top level of our middleware code.
|
|
147
154
|
// This is the only time we call initRoutes() - which adds all the routing middleware that has been declared previously
|
|
148
155
|
// to the app (get()/post()/all()). Any routing middleware declared after this point will not be initialized
|
|
@@ -152,7 +159,7 @@ export default function uiMiddleware(app, context) {
|
|
|
152
159
|
// -- Default 404 route -------------------------------------------------------------
|
|
153
160
|
app.use(async (req, res) => {
|
|
154
161
|
if (route404) {
|
|
155
|
-
await
|
|
162
|
+
await sendViewResponse(req, res, route404, 404);
|
|
156
163
|
}
|
|
157
164
|
else {
|
|
158
165
|
res.status(404).send('404 - This page does not exist');
|
|
@@ -2,16 +2,13 @@
|
|
|
2
2
|
import http from 'http';
|
|
3
3
|
import { EnvironmentConfig } from '@lwrjs/types';
|
|
4
4
|
import qs from 'qs';
|
|
5
|
-
interface E extends Error {
|
|
6
|
-
code: string;
|
|
7
|
-
}
|
|
8
5
|
/**
|
|
9
6
|
* Create a status object Express can return when there is an error
|
|
10
7
|
*
|
|
11
8
|
* @param name - string name of the problem module/resource
|
|
12
|
-
* @param error
|
|
9
|
+
* @param error - an Error/Diagnostic object; thrown from try/catch
|
|
13
10
|
*/
|
|
14
|
-
export declare function createReturnStatus(name: string, error:
|
|
11
|
+
export declare function createReturnStatus(name: string, error: unknown): {
|
|
15
12
|
status: number;
|
|
16
13
|
message: string;
|
|
17
14
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LwrUnresolvableError, descriptions } from '@lwrjs/diagnostics';
|
|
1
|
+
import { LwrUnresolvableError, descriptions, isNodeError } from '@lwrjs/diagnostics';
|
|
2
2
|
import { pathToRegexp } from 'path-to-regexp';
|
|
3
3
|
import qs from 'qs';
|
|
4
4
|
import createDOMPurify from 'dompurify';
|
|
@@ -9,11 +9,11 @@ const DOMPurify = createDOMPurify(window);
|
|
|
9
9
|
* Create a status object Express can return when there is an error
|
|
10
10
|
*
|
|
11
11
|
* @param name - string name of the problem module/resource
|
|
12
|
-
* @param error
|
|
12
|
+
* @param error - an Error/Diagnostic object; thrown from try/catch
|
|
13
13
|
*/
|
|
14
14
|
export function createReturnStatus(name, error) {
|
|
15
15
|
let returnStatus = { status: 501, message: '' };
|
|
16
|
-
if (error.code === 'NO_LWC_MODULE_FOUND') {
|
|
16
|
+
if (isNodeError(error) && error.code === 'NO_LWC_MODULE_FOUND') {
|
|
17
17
|
returnStatus = { status: 404, message: descriptions.UNRESOLVABLE.LWC_MODULE(name).message };
|
|
18
18
|
}
|
|
19
19
|
else if (error instanceof LwrUnresolvableError &&
|
|
@@ -1,16 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ResourceContextOpts, SiteConfig } from './types.js';
|
|
1
|
+
import { ImportMetadata, LwrDispatcher, StaticSiteGenerator, LwrRoute, NormalizedLwrGlobalConfig } from '@lwrjs/types';
|
|
2
|
+
import { ResourceContextOpts, SiteConfig, ViewImportMetadata } from './types.js';
|
|
3
3
|
export default class SiteGenerator {
|
|
4
|
-
dispatchResourceRecursive(url: string, dispatcher: LwrDispatcher, resourceOpts: ResourceContextOpts, siteConfig: SiteConfig): Promise<void>;
|
|
5
4
|
/**
|
|
6
5
|
* Build a static site in the configured directory
|
|
7
6
|
* - Generate all routes / modules
|
|
8
7
|
* - copy assets / resources
|
|
9
8
|
*
|
|
10
|
-
* @param
|
|
9
|
+
* @param config - LWR config for the site
|
|
10
|
+
* @param dispatcher - Facilitate server requests
|
|
11
11
|
*/
|
|
12
12
|
buildStaticApplication(config: NormalizedLwrGlobalConfig, dispatcher: LwrDispatcher): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Crawl all view routes for a site
|
|
15
|
+
*/
|
|
13
16
|
generateRoutes(staticSiteGenerator: StaticSiteGenerator, routes: LwrRoute[], dispatcher: LwrDispatcher, outputDir: string, urlRewriteMap?: Map<string, string>): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a function to dispatch the root requests for a given view url
|
|
19
|
+
*/
|
|
20
|
+
private createGenerateURLFunction;
|
|
21
|
+
/**
|
|
22
|
+
* Primary recursive dispatch function. Executes a URL and crawls its dependents.
|
|
23
|
+
*
|
|
24
|
+
* @param url - URL to execute
|
|
25
|
+
* @param dispatcher - Facilitates GET requests
|
|
26
|
+
* @param resourceOpts - Data about the URL to execute
|
|
27
|
+
* @param siteConfig - Running config for the current view
|
|
28
|
+
*/
|
|
29
|
+
dispatchResourceRecursive(url: string, dispatcher: LwrDispatcher, resourceOpts: ResourceContextOpts, siteConfig: SiteConfig): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Handle processing a returned javascript module or bundle and follow all returned references
|
|
32
|
+
* @param url - URL of the request javascript resource
|
|
33
|
+
* @param context - Response Context
|
|
34
|
+
* @param siteConfig - Global metadata about the site
|
|
35
|
+
* @param dispatcher - Network dispatcher
|
|
36
|
+
*/
|
|
37
|
+
private handleJavascriptResource;
|
|
38
|
+
/**
|
|
39
|
+
* Handle processing a returned module URI mapping resource and follow all returned references
|
|
40
|
+
* @param url - URL of the request mapping resource
|
|
41
|
+
* @param context - Response Context
|
|
42
|
+
* @param siteConfig - Global metadata about the site
|
|
43
|
+
* @param dispatcher - Network dispatcher
|
|
44
|
+
*/
|
|
45
|
+
private handleMappingResource;
|
|
46
|
+
/**
|
|
47
|
+
* Handle processing a returned HTML resource and process any provided view metadata
|
|
48
|
+
*
|
|
49
|
+
* @param url - URL of the requested HTML resource
|
|
50
|
+
* @param context - Response Context
|
|
51
|
+
* @param siteConfig - Global metadata about the site
|
|
52
|
+
* @param dispatcher - Network Dispatcher
|
|
53
|
+
*/
|
|
54
|
+
private handleHtmlResource;
|
|
55
|
+
/**
|
|
56
|
+
* Handle processing a returned view definition by following all returned references
|
|
57
|
+
* @param viewDefinition - Metadata about everything directly referenced form the view
|
|
58
|
+
* @param siteConfig - Global metadata about the site
|
|
59
|
+
* @param dispatcher - Network dispatcher
|
|
60
|
+
*/
|
|
61
|
+
private handleViewDefinition;
|
|
62
|
+
private dispatchJSResourceRecursive;
|
|
63
|
+
/**
|
|
64
|
+
* Handle processing a returned asset or resource
|
|
65
|
+
* @param url - URL of the requested asset or resource
|
|
66
|
+
* @param context - Response Context
|
|
67
|
+
* @param siteConfig - Global metadata about the site
|
|
68
|
+
*/
|
|
69
|
+
private handleAssetOrResource;
|
|
70
|
+
private getResourcePathFromUrl;
|
|
14
71
|
/**
|
|
15
72
|
* Write out redirect mapping files for static hosting services like netlify. Examples for why this is needed:
|
|
16
73
|
* -- Redirect /1/bundle/amd/l/en-US/bi/0/module/mi/lwr/navigation/v/0_1_6 -> /1/bundle/amd/l/en-US/bi/0/module/mi/lwr/navigation/v/0_1_6/s/{signature}
|
|
@@ -19,7 +76,7 @@ export default class SiteGenerator {
|
|
|
19
76
|
* @param outputDir
|
|
20
77
|
* @param urlRewriteMap
|
|
21
78
|
*/
|
|
22
|
-
|
|
79
|
+
private writeNetlifyRedirectConfig;
|
|
23
80
|
/**
|
|
24
81
|
* Copy over assets
|
|
25
82
|
* TODO this results in duplicate assets at the moment since assets can be referenced multiple ways:
|
|
@@ -29,6 +86,38 @@ export default class SiteGenerator {
|
|
|
29
86
|
* @param assets AssetConfig
|
|
30
87
|
*
|
|
31
88
|
*/
|
|
32
|
-
copyAssets
|
|
89
|
+
private copyAssets;
|
|
90
|
+
/**
|
|
91
|
+
* Create a new site config for the current view
|
|
92
|
+
*/
|
|
93
|
+
private createSiteConfig;
|
|
94
|
+
private filterExperimentalFeatures;
|
|
95
|
+
/**
|
|
96
|
+
* Add any additional import metadata collected during static site generation to the Client Bootstrap Config for this view.
|
|
97
|
+
*/
|
|
98
|
+
private addAdditionalImportMetadataToViewConfig;
|
|
99
|
+
}
|
|
100
|
+
export declare class ViewImportMetadataImpl implements ViewImportMetadata {
|
|
101
|
+
private existing;
|
|
102
|
+
private additional;
|
|
103
|
+
constructor(existingImportMetadata: ImportMetadata, additionalImportMetadata?: ImportMetadata);
|
|
104
|
+
/**
|
|
105
|
+
* Get the additional import metadata collected while generating this view
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
getAdditionalImportMetadata(): ImportMetadata;
|
|
109
|
+
/**
|
|
110
|
+
* Adds any new imports found to the additional metadata map. Returns a filtered
|
|
111
|
+
* map of imports not in the initial view
|
|
112
|
+
*/
|
|
113
|
+
addAdditionalMetadata(newMetadata: ImportMetadata): ImportMetadata;
|
|
114
|
+
/**
|
|
115
|
+
* Filter out any existing import metadata the would have already been sent back with the view from set of additional metadata detected
|
|
116
|
+
*/
|
|
117
|
+
private filterMetadata;
|
|
118
|
+
/**
|
|
119
|
+
* Merge new import metadata into target import metadata
|
|
120
|
+
*/
|
|
121
|
+
private mergeImportMetadata;
|
|
33
122
|
}
|
|
34
123
|
//# sourceMappingURL=static-generation.d.ts.map
|