@lwrjs/view-registry 0.4.4 → 0.5.0
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/LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/build/cjs/index.cjs
CHANGED
|
@@ -166,7 +166,8 @@ var LwrViewRegistry = class {
|
|
|
166
166
|
debug: runtimeEnvironment.debug
|
|
167
167
|
});
|
|
168
168
|
const viewParamKey = viewParamCacheKey ? (0, import_shared_utils.getCacheKeyFromJson)(viewParamCacheKey) : (0, import_shared_utils.getCacheKeyFromJson)(viewParams);
|
|
169
|
-
|
|
169
|
+
const cacheDisabled = process.env.NOCACHE === "true" || skipCaching;
|
|
170
|
+
if (cacheDisabled === false && this.viewDefinitions.has(viewDefCacheKey)) {
|
|
170
171
|
const viewDefinition2 = this.viewDefinitions.get(viewDefCacheKey);
|
|
171
172
|
if (viewDefinition2 && viewDefinition2.paramKey === viewParamKey && viewDefinition2.viewDefinition.immutable) {
|
|
172
173
|
return viewDefinition2.viewDefinition;
|
|
@@ -180,7 +181,7 @@ var LwrViewRegistry = class {
|
|
|
180
181
|
this.pendingViewDefinitions.set(pendingViewDefCacheKey, pendingViewDefinition);
|
|
181
182
|
const viewDefinition = await pendingViewDefinition;
|
|
182
183
|
this.pendingViewDefinitions.delete(pendingViewDefCacheKey);
|
|
183
|
-
if (
|
|
184
|
+
if (cacheDisabled === false) {
|
|
184
185
|
this.viewDefinitions.set(viewDefCacheKey, {
|
|
185
186
|
view: {id, bootstrap, rootComponent, contentTemplate, layoutTemplate},
|
|
186
187
|
viewDefinition,
|
|
@@ -97,7 +97,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
let importMetadata = (0, import_shared_utils.toImportMetadata)(bootstrapModuleGraph);
|
|
100
|
+
let importMetadata = await (0, import_shared_utils.toImportMetadata)(bootstrapModuleGraph, {imports: {}, index: {}}, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
101
101
|
const customElementsRecords = [];
|
|
102
102
|
await Promise.all(customElements.map(async (element) => {
|
|
103
103
|
const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabcaseToCamelcase)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, bundle ? moduleBundler : moduleRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
|
|
@@ -118,7 +118,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
118
118
|
imports[dynamicDep] = uri3;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
importMetadata = (0, import_shared_utils.toImportMetadata)(graph, importMetadata);
|
|
121
|
+
importMetadata = await (0, import_shared_utils.toImportMetadata)(graph, importMetadata, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
122
122
|
}));
|
|
123
123
|
configResources.unshift(await (0, import_utils2.getViewBootstrapConfigurationResource)({
|
|
124
124
|
id: view.id,
|
|
@@ -128,6 +128,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
128
128
|
bootstrapModule: versionedSpecifier,
|
|
129
129
|
autoBoot: view.bootstrap?.autoBoot === false ? false : true,
|
|
130
130
|
imports: importMetadata?.imports,
|
|
131
|
+
index: importMetadata?.index,
|
|
131
132
|
rootComponents,
|
|
132
133
|
...isAMD && {requiredModules: requiredAmdModules},
|
|
133
134
|
...isAMD && {preloadModules: preloadAmdModules}
|
package/build/es/index.js
CHANGED
|
@@ -101,6 +101,7 @@ export class LwrViewRegistry {
|
|
|
101
101
|
}
|
|
102
102
|
async delegateGetView(viewId) {
|
|
103
103
|
for (const vp of this.viewProviders) {
|
|
104
|
+
// eslint-disable-next-line no-await-in-loop
|
|
104
105
|
const result = await vp.getView(viewId);
|
|
105
106
|
if (result) {
|
|
106
107
|
return result;
|
|
@@ -169,8 +170,9 @@ export class LwrViewRegistry {
|
|
|
169
170
|
const viewParamKey = viewParamCacheKey
|
|
170
171
|
? getCacheKeyFromJson(viewParamCacheKey)
|
|
171
172
|
: getCacheKeyFromJson(viewParams);
|
|
173
|
+
const cacheDisabled = process.env.NOCACHE === 'true' || skipCaching;
|
|
172
174
|
// important: cache key does not include the unbounded viewParams
|
|
173
|
-
if (
|
|
175
|
+
if (cacheDisabled === false && this.viewDefinitions.has(viewDefCacheKey)) {
|
|
174
176
|
const viewDefinition = this.viewDefinitions.get(viewDefCacheKey);
|
|
175
177
|
if (viewDefinition &&
|
|
176
178
|
viewDefinition.paramKey === viewParamKey &&
|
|
@@ -186,7 +188,7 @@ export class LwrViewRegistry {
|
|
|
186
188
|
this.pendingViewDefinitions.set(pendingViewDefCacheKey, pendingViewDefinition);
|
|
187
189
|
const viewDefinition = await pendingViewDefinition;
|
|
188
190
|
this.pendingViewDefinitions.delete(pendingViewDefCacheKey);
|
|
189
|
-
if (
|
|
191
|
+
if (cacheDisabled === false) {
|
|
190
192
|
this.viewDefinitions.set(viewDefCacheKey, {
|
|
191
193
|
view: { id, bootstrap, rootComponent, contentTemplate, layoutTemplate },
|
|
192
194
|
viewDefinition,
|
|
@@ -62,7 +62,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
62
62
|
}
|
|
63
63
|
// ------- Application Bootstrap module
|
|
64
64
|
// Traversal of the Bootstrap Module Graph is done to get all the URLS for discoverable static dependencies.
|
|
65
|
-
// Reasoning: This is to avoid
|
|
65
|
+
// Reasoning: This is to avoid unnecessary HTTP 302's during initial application module fetching.
|
|
66
66
|
// Scope: ESM currently only exposes immutable URI references, optimize for AMD formats
|
|
67
67
|
const depth = isAMD
|
|
68
68
|
? { static: GraphDepth.ALL, dynamic: 1 }
|
|
@@ -100,7 +100,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
let importMetadata = toImportMetadata(bootstrapModuleGraph);
|
|
103
|
+
let importMetadata = await toImportMetadata(bootstrapModuleGraph, { imports: {}, index: {} }, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
104
104
|
// ------- View related custom element moduleResources
|
|
105
105
|
const customElementsRecords = [];
|
|
106
106
|
await Promise.all(customElements.map(async (element) => {
|
|
@@ -127,7 +127,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
127
127
|
imports[dynamicDep] = uri;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
importMetadata = toImportMetadata(graph, importMetadata);
|
|
130
|
+
importMetadata = await toImportMetadata(graph, importMetadata, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
131
131
|
}));
|
|
132
132
|
// ADD configuration of the bootstrapModule
|
|
133
133
|
configResources.unshift(await getViewBootstrapConfigurationResource({
|
|
@@ -138,6 +138,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
138
138
|
bootstrapModule: versionedSpecifier,
|
|
139
139
|
autoBoot: view.bootstrap?.autoBoot === false ? false : true,
|
|
140
140
|
imports: importMetadata?.imports,
|
|
141
|
+
index: importMetadata?.index,
|
|
141
142
|
rootComponents,
|
|
142
143
|
...(isAMD && { requiredModules: requiredAmdModules }),
|
|
143
144
|
...(isAMD && { preloadModules: preloadAmdModules }),
|
package/build/es/utils.js
CHANGED
|
@@ -146,6 +146,7 @@ export async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEn
|
|
|
146
146
|
},
|
|
147
147
|
};
|
|
148
148
|
const workerBootstrapSpecifier = getAppSpecifier(appIdentity);
|
|
149
|
+
// eslint-disable-next-line no-await-in-loop
|
|
149
150
|
workers[id] = await createJsonModule(workerBootstrapSpecifier, moduleRegistry, runtimeEnvironment, runtimeParams);
|
|
150
151
|
}
|
|
151
152
|
// ADD bootstrap module and dependencies to modules property
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.5.0",
|
|
8
8
|
"homepage": "https://lwr.dev/",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -30,15 +30,16 @@
|
|
|
30
30
|
"build/**/*.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lwrjs/app-service": "0.
|
|
34
|
-
"@lwrjs/diagnostics": "0.
|
|
35
|
-
"@lwrjs/shared-utils": "0.
|
|
33
|
+
"@lwrjs/app-service": "0.5.0",
|
|
34
|
+
"@lwrjs/diagnostics": "0.5.0",
|
|
35
|
+
"@lwrjs/shared-utils": "0.5.0",
|
|
36
36
|
"magic-string": "^0.25.7"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lwrjs/types": "0.
|
|
39
|
+
"@lwrjs/types": "0.5.0"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=14.15.4 <15"
|
|
43
|
-
}
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "8b46ed1d391c744926ad65b442e5a9f9969d832e"
|
|
44
45
|
}
|