@lwrjs/view-registry 0.9.0-alpha.1 → 0.9.0-alpha.11
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/index.cjs +8 -3
- package/build/cjs/linkers/view_bootstrap.cjs +2 -2
- package/build/cjs/view-handler.cjs +6 -3
- package/build/es/index.js +8 -2
- package/build/es/linkers/view_bootstrap.js +4 -2
- package/build/es/view-handler.d.ts +2 -2
- package/build/es/view-handler.js +4 -1
- package/package.json +6 -6
package/build/cjs/index.cjs
CHANGED
|
@@ -278,8 +278,11 @@ var LwrViewRegistry = class {
|
|
|
278
278
|
importer: importer || renderedView.compiledView.filePath
|
|
279
279
|
};
|
|
280
280
|
const stringBuilder = (0, import_shared_utils.createStringBuilder)(renderedViewContent);
|
|
281
|
+
let pageTtl;
|
|
281
282
|
for (const viewTransformer of this.viewTransformers) {
|
|
282
|
-
await viewTransformer.link?.(stringBuilder, mergedViewContext, linkedMetadata);
|
|
283
|
+
const linkResults = await viewTransformer.link?.(stringBuilder, mergedViewContext, linkedMetadata);
|
|
284
|
+
const ttl = linkResults && linkResults.cache?.ttl;
|
|
285
|
+
pageTtl = (0, import_shared_utils.shortestTtl)(ttl || void 0, pageTtl);
|
|
283
286
|
}
|
|
284
287
|
const linkedAssetContent = stringBuilder.toString();
|
|
285
288
|
if (linkedAssetContent.includes(lwrResourcesId)) {
|
|
@@ -298,7 +301,8 @@ var LwrViewRegistry = class {
|
|
|
298
301
|
viewRecord: {
|
|
299
302
|
assetReferences: (0, import_utils.reduceSourceAssetReferences)(linkedMetadata.assetReferences),
|
|
300
303
|
...viewRecord
|
|
301
|
-
}
|
|
304
|
+
},
|
|
305
|
+
cache: {ttl: pageTtl}
|
|
302
306
|
};
|
|
303
307
|
}
|
|
304
308
|
return {
|
|
@@ -306,7 +310,8 @@ var LwrViewRegistry = class {
|
|
|
306
310
|
immutable,
|
|
307
311
|
viewRecord: {
|
|
308
312
|
assetReferences: (0, import_utils.reduceSourceAssetReferences)(linkedMetadata.assetReferences)
|
|
309
|
-
}
|
|
313
|
+
},
|
|
314
|
+
cache: {ttl: pageTtl}
|
|
310
315
|
};
|
|
311
316
|
}
|
|
312
317
|
};
|
|
@@ -111,7 +111,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
111
111
|
let importMetadata = await (0, import_shared_utils.toImportMetadata)(bootstrapModuleGraph, {imports: {}, index: {}}, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
112
112
|
const customElementsRecords = [];
|
|
113
113
|
const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements, isSSR);
|
|
114
|
-
|
|
114
|
+
for (const {tagName: element} of flattenedElements) {
|
|
115
115
|
const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabCaseToModuleSpecifer)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
|
|
116
116
|
customElementsRecords.push({elementName: element, flatGraph: graph});
|
|
117
117
|
const specifier = graph.graphs[0].specifier;
|
|
@@ -131,7 +131,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
importMetadata = await (0, import_shared_utils.toImportMetadata)(graph, importMetadata, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
134
|
-
}
|
|
134
|
+
}
|
|
135
135
|
configResources.unshift(await (0, import_utils2.getViewBootstrapConfigurationResource)({
|
|
136
136
|
id: view.id,
|
|
137
137
|
url: viewParams?.page?.url,
|
|
@@ -55,7 +55,8 @@ var LwrViewHandler = class {
|
|
|
55
55
|
body: viewDefinition2.renderedView,
|
|
56
56
|
metadata: {
|
|
57
57
|
viewDefinition: viewDefinition2
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
|
+
cache: {ttl: (0, import_shared_utils.shortestTtl)(response.cache?.ttl, viewDefinition2.cache?.ttl)}
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
const viewDefinition = await this.getDefaultRouteViewDefinition(viewRequest, route, runtimeEnvironment, runtimeParams);
|
|
@@ -63,7 +64,8 @@ var LwrViewHandler = class {
|
|
|
63
64
|
body: viewDefinition.renderedView,
|
|
64
65
|
metadata: {
|
|
65
66
|
viewDefinition
|
|
66
|
-
}
|
|
67
|
+
},
|
|
68
|
+
cache: viewDefinition.cache
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
71
|
async getViewJson(viewRequest, route, runtimeEnvironment, runtimeParams = {}) {
|
|
@@ -169,7 +171,8 @@ var LwrViewHandler = class {
|
|
|
169
171
|
body: viewDefinition.renderedView,
|
|
170
172
|
metadata: {
|
|
171
173
|
viewDefinition
|
|
172
|
-
}
|
|
174
|
+
},
|
|
175
|
+
cache: viewDefinition.cache
|
|
173
176
|
};
|
|
174
177
|
}
|
|
175
178
|
};
|
package/build/es/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractMetadataFromHtml, getCacheKeyFromJson, getSpecifier, normalizeResourcePath, createStringBuilder, InflightTasks, } from '@lwrjs/shared-utils';
|
|
1
|
+
import { extractMetadataFromHtml, getCacheKeyFromJson, getSpecifier, normalizeResourcePath, createStringBuilder, shortestTtl, InflightTasks, } from '@lwrjs/shared-utils';
|
|
2
2
|
import { normalizeRenderOptions, normalizeRenderedResult, reduceSourceAssetReferences } from './utils.js';
|
|
3
3
|
import { linkLwrResources } from './linkers/link-lwr-resources.js';
|
|
4
4
|
export { LwrViewHandler } from './view-handler.js';
|
|
@@ -295,9 +295,13 @@ export class LwrViewRegistry {
|
|
|
295
295
|
importer: importer || renderedView.compiledView.filePath,
|
|
296
296
|
};
|
|
297
297
|
const stringBuilder = createStringBuilder(renderedViewContent);
|
|
298
|
+
let pageTtl;
|
|
298
299
|
for (const viewTransformer of this.viewTransformers) {
|
|
299
300
|
// eslint-disable-next-line no-await-in-loop
|
|
300
|
-
await viewTransformer.link?.(stringBuilder, mergedViewContext, linkedMetadata);
|
|
301
|
+
const linkResults = await viewTransformer.link?.(stringBuilder, mergedViewContext, linkedMetadata);
|
|
302
|
+
// Keep track of the shortest TTL from each view transformer (e.g. lwcSsrViewTranformer)
|
|
303
|
+
const ttl = linkResults && linkResults.cache?.ttl;
|
|
304
|
+
pageTtl = shortestTtl(ttl || undefined, pageTtl);
|
|
301
305
|
}
|
|
302
306
|
const linkedAssetContent = stringBuilder.toString();
|
|
303
307
|
// Link LWR related resources
|
|
@@ -321,6 +325,7 @@ export class LwrViewRegistry {
|
|
|
321
325
|
assetReferences: reduceSourceAssetReferences(linkedMetadata.assetReferences),
|
|
322
326
|
...viewRecord,
|
|
323
327
|
},
|
|
328
|
+
cache: { ttl: pageTtl },
|
|
324
329
|
};
|
|
325
330
|
}
|
|
326
331
|
return {
|
|
@@ -329,6 +334,7 @@ export class LwrViewRegistry {
|
|
|
329
334
|
viewRecord: {
|
|
330
335
|
assetReferences: reduceSourceAssetReferences(linkedMetadata.assetReferences),
|
|
331
336
|
},
|
|
337
|
+
cache: { ttl: pageTtl },
|
|
332
338
|
};
|
|
333
339
|
}
|
|
334
340
|
}
|
|
@@ -118,7 +118,8 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
118
118
|
// ------- View related custom element moduleResources
|
|
119
119
|
const customElementsRecords = [];
|
|
120
120
|
const flattenedElements = flattenCustomElements(customElements, isSSR);
|
|
121
|
-
|
|
121
|
+
for (const { tagName: element } of flattenedElements) {
|
|
122
|
+
// eslint-disable-next-line no-await-in-loop
|
|
122
123
|
const graph = await getModuleGraphs(kebabCaseToModuleSpecifer(element), { includeUris: true, includeLinkedDefinitions: true, depth }, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
|
|
123
124
|
// add to the viewRecord
|
|
124
125
|
customElementsRecords.push({ elementName: element, flatGraph: graph });
|
|
@@ -142,8 +143,9 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
142
143
|
imports[dynamicDep] = uri;
|
|
143
144
|
}
|
|
144
145
|
}
|
|
146
|
+
// eslint-disable-next-line no-await-in-loop
|
|
145
147
|
importMetadata = await toImportMetadata(graph, importMetadata, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
146
|
-
}
|
|
148
|
+
}
|
|
147
149
|
// ADD configuration of the bootstrapModule
|
|
148
150
|
configResources.unshift(await getViewBootstrapConfigurationResource({
|
|
149
151
|
id: view.id,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ViewRegistry, RuntimeEnvironment, NormalizedLwrGlobalConfig, ViewRequest, RuntimeParams, ViewResponse, LwrErrorRoute, LwrRoute, ModuleRegistry, RouteHandlerFunction } from '@lwrjs/types';
|
|
1
|
+
import { ViewRegistry, RuntimeEnvironment, NormalizedLwrGlobalConfig, ViewRequest, RuntimeParams, ViewResponse, LwrErrorRoute, LwrRoute, ModuleRegistry, RouteHandlerFunction, ViewHandler } from '@lwrjs/types';
|
|
2
2
|
export interface ViewHandlerContext {
|
|
3
3
|
viewRegistry: ViewRegistry;
|
|
4
4
|
moduleRegistry: ModuleRegistry;
|
|
5
5
|
}
|
|
6
|
-
export declare class LwrViewHandler {
|
|
6
|
+
export declare class LwrViewHandler implements ViewHandler {
|
|
7
7
|
viewRegistry: ViewRegistry;
|
|
8
8
|
moduleRegistry: ModuleRegistry;
|
|
9
9
|
globalConfig: NormalizedLwrGlobalConfig;
|
package/build/es/view-handler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeResourcePath } from '@lwrjs/shared-utils';
|
|
1
|
+
import { normalizeResourcePath, shortestTtl } from '@lwrjs/shared-utils';
|
|
2
2
|
import { generateHtmlTag, generatePageContext, getRouteHandler, isViewResponse, toJsonFormat, } from './utils.js';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
export class LwrViewHandler {
|
|
@@ -38,6 +38,7 @@ export class LwrViewHandler {
|
|
|
38
38
|
metadata: {
|
|
39
39
|
viewDefinition,
|
|
40
40
|
},
|
|
41
|
+
cache: { ttl: shortestTtl(response.cache?.ttl, viewDefinition.cache?.ttl) },
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
// default static view
|
|
@@ -47,6 +48,7 @@ export class LwrViewHandler {
|
|
|
47
48
|
metadata: {
|
|
48
49
|
viewDefinition,
|
|
49
50
|
},
|
|
51
|
+
cache: viewDefinition.cache,
|
|
50
52
|
};
|
|
51
53
|
}
|
|
52
54
|
// Get the View's JSON Manifest Response
|
|
@@ -202,6 +204,7 @@ export class LwrViewHandler {
|
|
|
202
204
|
metadata: {
|
|
203
205
|
viewDefinition,
|
|
204
206
|
},
|
|
207
|
+
cache: viewDefinition.cache,
|
|
205
208
|
};
|
|
206
209
|
}
|
|
207
210
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.9.0-alpha.
|
|
7
|
+
"version": "0.9.0-alpha.11",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"build/**/*.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lwrjs/app-service": "0.9.0-alpha.
|
|
34
|
-
"@lwrjs/diagnostics": "0.9.0-alpha.
|
|
35
|
-
"@lwrjs/shared-utils": "0.9.0-alpha.
|
|
33
|
+
"@lwrjs/app-service": "0.9.0-alpha.11",
|
|
34
|
+
"@lwrjs/diagnostics": "0.9.0-alpha.11",
|
|
35
|
+
"@lwrjs/shared-utils": "0.9.0-alpha.11"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@lwrjs/types": "0.9.0-alpha.
|
|
38
|
+
"@lwrjs/types": "0.9.0-alpha.11"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=14.15.4 <19"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "3cb1275b364ae7373c1868c79e6082a122dbef9c"
|
|
44
44
|
}
|