@lwrjs/everywhere 0.10.0-alpha.2 → 0.10.0-alpha.20
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/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/981eca8f72a57fecd21a35a5dfee2751/config.js +10 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_20/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +18 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{2_38_1/s/8cf6b94d9c0b398c70c97fdca2759caa → 2_50_0/s/b40440e2e29d782101f05d6085a324e9}/lwc.js +560 -584
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_10_0-alpha_2/s/c538071acf5bde58e816967a14c465c3 → 0_10_0-alpha_20/s/cb931ebef2b89dcf8ab51456e3a68864}/lwr_everywhereAmd.js +4 -4
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/0_10_0-alpha_20/s/5e6db37af51f0d23be4893abe5eeb913/lwr_init.js +163 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_10_0-alpha_2/s/b9b0d37c87017e0845caa60b6f4b88f9 → 0_10_0-alpha_20/s/e768d044ed1b7b7babca2f39e1cbca58}/lwr_loader.js +105 -14
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_10_0-alpha_2/s/3426e42c3e22ce07ab2adc62c4c523a0 → 0_10_0-alpha_20/s/7a802ee7a2430244c1f66bce2c2eafef}/lwr_metrics.js +14 -2
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/0_10_0-alpha_20/s/a152b8d35f12ca1b5147c5cd1ee155fb/lwr_profiler.js +102 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_10_0-alpha_2 → 0_10_0-alpha_20}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +2 -2
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_10_0-alpha_2 → 0_10_0-alpha_20}/lwr-error-shim.js +2 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_10_0-alpha_2 → 0_10_0-alpha_20}/lwr-loader-shim.bundle.js +583 -259
- package/build/assets/amd/lwr-everywhere-debug.js +536 -278
- package/build/assets/amd/lwr-everywhere-min.js +6 -1
- package/build/assets/amd/lwr-everywhere.js +536 -278
- package/build/assets/core/lwr-everywhere-debug.js +534 -276
- package/build/assets/core/lwr-everywhere-min.js +6 -1
- package/build/assets/core/lwr-everywhere.js +534 -276
- package/build/assets/esm/lwr-everywhere-debug.js +10 -3
- package/build/assets/esm/lwr-everywhere-min.js +1 -1
- package/build/assets/esm/lwr-everywhere.js +10 -3
- package/build/generate.js +5 -10
- package/build/index.js +1 -1
- package/build/modules/lwr/everywhereAmd/everywhereAmd.d.ts +1 -1
- package/build/modules/lwr/host/host.html +1 -1
- package/build/modules/lwr/host/host.js +2 -2
- package/build/modules/lwr/setupLDS/setupLDS.js +8 -5
- package/build/modules/lwr/vault/vault.d.ts +1 -1
- package/build/utils.d.ts +1 -1
- package/package.json +15 -13
- package/src/generate.ts +7 -11
- package/src/index.ts +4 -1
- package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/e8b5228f499eea69a8f669aada1f8042/config.js +0 -10
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_10_0-alpha_2/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -18
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/0_10_0-alpha_2/s/206e6e0af6f019fdfd86d87d56331bc2/lwr_init.js +0 -97
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/0_10_0-alpha_2/s/e25f3b0b8b5c096acebf847d0a83ea62/lwr_profiler.js +0 -68
- package/build/modules/@salesforce/lds-default-luvio/lds-default-luvio.d.ts +0 -24
- package/build/modules/@salesforce/lds-default-luvio/lds-default-luvio.js +0 -60
- package/build/modules/lwr/setupNodeLDS/network.d.ts +0 -3
- package/build/modules/lwr/setupNodeLDS/network.js +0 -88
- package/build/modules/lwr/setupNodeLDS/setupNodeLDS.d.ts +0 -2
- package/build/modules/lwr/setupNodeLDS/setupNodeLDS.js +0 -14
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
LWR.define('lwr/everywhereAmd/v/0_10_0-
|
|
1
|
+
LWR.define('lwr/everywhereAmd/v/0_10_0-alpha_20', ['exports', 'lwr/vault/v/0_10_0-alpha_20'], (function (exports, _0_10_0Alpha_20) { 'use strict';
|
|
2
2
|
|
|
3
3
|
// IMPORTANT: Do not add any static imports to this file that are not bundled with the amd-client
|
|
4
4
|
|
|
5
5
|
// Do an OAuthed fetch
|
|
6
6
|
async function authFetch(url, accept = 'javascript') {
|
|
7
|
-
const authInfo =
|
|
7
|
+
const authInfo = _0_10_0Alpha_20.getAuthInfo();
|
|
8
8
|
if (authInfo) {
|
|
9
9
|
return fetch(url, {
|
|
10
10
|
headers: {
|
|
@@ -54,7 +54,7 @@ LWR.define('lwr/everywhereAmd/v/0_10_0-alpha_2', ['exports', 'lwr/vault/v/0_10_0
|
|
|
54
54
|
function authenticate(authInfo) {
|
|
55
55
|
// Put OAuth info into the vault
|
|
56
56
|
if (authInfo) {
|
|
57
|
-
|
|
57
|
+
_0_10_0Alpha_20.setAuthInfo(authInfo);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -63,4 +63,4 @@ LWR.define('lwr/everywhereAmd/v/0_10_0-alpha_2', ['exports', 'lwr/vault/v/0_10_0
|
|
|
63
63
|
|
|
64
64
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
65
65
|
|
|
66
|
-
});
|
|
66
|
+
}));
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
LWR.define('lwr/init/v/0_10_0-alpha_20', ['exports', 'lwr/metrics/v/0_10_0-alpha_20', 'lwr/profiler/v/0_10_0-alpha_20', 'lwc/v/2_50_0'], (function (exports, _0_10_0Alpha_20$1, _0_10_0Alpha_20, _2_50_0) { 'use strict';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
|
|
5
|
+
// <hydrateComponentProxy> - This code is removed in core
|
|
6
|
+
|
|
7
|
+
function hydrateComponentProxy(customElement, Ctor, props) {
|
|
8
|
+
_2_50_0.hydrateComponent(customElement, Ctor, props);
|
|
9
|
+
}
|
|
10
|
+
// </hydrateComponentProxy>
|
|
11
|
+
|
|
12
|
+
function initializeWebComponent(elementName, Ctor) {
|
|
13
|
+
return _2_50_0.createElement(elementName, {
|
|
14
|
+
is: Ctor
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Convert a module specifier into a valid CustomElement registry name:
|
|
20
|
+
* - remove any version linking
|
|
21
|
+
* - change / to -
|
|
22
|
+
* - convert uppercase letters into "-${lowercase}"
|
|
23
|
+
* eg: "c/app" => "c-app"
|
|
24
|
+
* eg: "my/helloWorld" => "my-hello-world"
|
|
25
|
+
* eg: "lwr/example/v/1.0.0" => "lwr-example"
|
|
26
|
+
* @param specifier The bare specifier to convert
|
|
27
|
+
*/
|
|
28
|
+
function toKebabCase(specifier) {
|
|
29
|
+
return specifier.replace(/\/v\/[a-zA-Z0-9-_.]+$/, '').replace('/', '-').replace(/([A-Z])/g, c => `-${c.toLowerCase()}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This method maps between attribute names
|
|
34
|
+
* and the corresponding props name.
|
|
35
|
+
*/
|
|
36
|
+
const CAMEL_REGEX = /-([a-z])/g;
|
|
37
|
+
function getPropFromAttrName(propName) {
|
|
38
|
+
return propName.replace(CAMEL_REGEX, g => g[1].toUpperCase());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Import any requested static application dependencies, define the root
|
|
43
|
+
* application component(s) into the CustomElement registry, and inject them.
|
|
44
|
+
* @param rootModules - An array of arrays, each one holding a pair of
|
|
45
|
+
* bare specifier and corresponding LightningElement constructor
|
|
46
|
+
* @example - [['x/appRoot', appCtor], ['x/nav', navCtor]]
|
|
47
|
+
*/
|
|
48
|
+
function init(rootModules, ssrProps = {}) {
|
|
49
|
+
if (typeof customElements === 'undefined' || typeof document === 'undefined') {
|
|
50
|
+
_0_10_0Alpha_20.logOperationStart({
|
|
51
|
+
id: _0_10_0Alpha_20$1.BOOTSTRAP_END
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
_0_10_0Alpha_20.logOperationStart({
|
|
56
|
+
id: _0_10_0Alpha_20$1.INIT
|
|
57
|
+
});
|
|
58
|
+
let index = 0;
|
|
59
|
+
for (const [specifier, ctor] of rootModules) {
|
|
60
|
+
const elementName = toKebabCase(specifier);
|
|
61
|
+
|
|
62
|
+
// initialize and inject the root module into the LWR Root or DOM if it is missing
|
|
63
|
+
if (!document.body.querySelector(elementName)) {
|
|
64
|
+
_0_10_0Alpha_20.logOperationStart({
|
|
65
|
+
id: _0_10_0Alpha_20$1.INIT_MODULE,
|
|
66
|
+
specifier,
|
|
67
|
+
specifierIndex: ++index
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// this is for SPA like routes (one component at the root level) utilizing the lwr-root directive
|
|
71
|
+
const component = initializeWebComponent(elementName, ctor);
|
|
72
|
+
const container = document.querySelector('[lwr-root]');
|
|
73
|
+
container ? container.appendChild(component) : document.body.appendChild(component);
|
|
74
|
+
_0_10_0Alpha_20.logOperationEnd({
|
|
75
|
+
id: _0_10_0Alpha_20$1.INIT_MODULE,
|
|
76
|
+
specifier,
|
|
77
|
+
specifierIndex: index,
|
|
78
|
+
metadata: {
|
|
79
|
+
renderMode: 'spa'
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// the page has been rendered or SSR'd, and each component needs to initialized(or hydrated)
|
|
86
|
+
const elements = document.querySelectorAll(elementName);
|
|
87
|
+
for (const element of elements) {
|
|
88
|
+
_0_10_0Alpha_20.logOperationStart({
|
|
89
|
+
id: _0_10_0Alpha_20$1.INIT_MODULE,
|
|
90
|
+
specifier,
|
|
91
|
+
specifierIndex: ++index
|
|
92
|
+
});
|
|
93
|
+
const propsId = element.dataset.lwrPropsId;
|
|
94
|
+
|
|
95
|
+
// hydrate SSR'd components
|
|
96
|
+
if (propsId) {
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
hydrateComponentProxy(element, ctor, ssrProps[propsId] || {});
|
|
100
|
+
_0_10_0Alpha_20.logOperationEnd({
|
|
101
|
+
id: _0_10_0Alpha_20$1.INIT_MODULE,
|
|
102
|
+
specifier,
|
|
103
|
+
specifierIndex: index,
|
|
104
|
+
metadata: {
|
|
105
|
+
renderMode: 'ssr'
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Note: due to the bug described at the top of this file, each CSR'd custom element
|
|
112
|
+
// must be replaced with the new synthetic constructor. Attributes and children are
|
|
113
|
+
// copied over to the new component.
|
|
114
|
+
const component = initializeWebComponent(elementName, ctor);
|
|
115
|
+
|
|
116
|
+
// copy the attributes
|
|
117
|
+
for (const {
|
|
118
|
+
name,
|
|
119
|
+
value
|
|
120
|
+
} of element.attributes) {
|
|
121
|
+
component.setAttribute(name, value);
|
|
122
|
+
const prop = getPropFromAttrName(name);
|
|
123
|
+
if (prop in component) {
|
|
124
|
+
// set attributes as properties for reactivity
|
|
125
|
+
component[prop] = value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// save the children
|
|
130
|
+
while (element.childNodes.length > 0) {
|
|
131
|
+
component.appendChild(element.childNodes[0]);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// swap the element out with the initialized component
|
|
135
|
+
const parent = element.parentElement;
|
|
136
|
+
if (parent) {
|
|
137
|
+
parent.replaceChild(component, element);
|
|
138
|
+
}
|
|
139
|
+
_0_10_0Alpha_20.logOperationEnd({
|
|
140
|
+
id: _0_10_0Alpha_20$1.INIT_MODULE,
|
|
141
|
+
specifier,
|
|
142
|
+
specifierIndex: index,
|
|
143
|
+
metadata: {
|
|
144
|
+
renderMode: 'csr'
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
_0_10_0Alpha_20.logOperationEnd({
|
|
150
|
+
id: _0_10_0Alpha_20$1.INIT
|
|
151
|
+
});
|
|
152
|
+
_0_10_0Alpha_20.logOperationStart({
|
|
153
|
+
id: _0_10_0Alpha_20$1.BOOTSTRAP_END
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
exports.getPropFromAttrName = getPropFromAttrName;
|
|
158
|
+
exports.init = init;
|
|
159
|
+
exports.toKebabCase = toKebabCase;
|
|
160
|
+
|
|
161
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
162
|
+
|
|
163
|
+
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
LWR.define('lwr/loader/v/0_10_0-
|
|
1
|
+
LWR.define('lwr/loader/v/0_10_0-alpha_20', ['exports'], (function (exports) { 'use strict';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Copyright (c) 2021, salesforce.com, inc.
|
|
@@ -6,7 +6,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
6
6
|
* SPDX-License-Identifier: MIT
|
|
7
7
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8
8
|
*/
|
|
9
|
-
/* LWR Module Loader v0.10.0-alpha.
|
|
9
|
+
/* LWR Module Loader v0.10.0-alpha.20 */
|
|
10
10
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
12
|
function templateString(template, args) {
|
|
@@ -25,7 +25,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
25
25
|
super();
|
|
26
26
|
this.message = generateErrorMessage(errorInfo, errorArgs);
|
|
27
27
|
}
|
|
28
|
-
/*LWC compiler v2.
|
|
28
|
+
/*LWC compiler v2.50.0*/
|
|
29
29
|
}
|
|
30
30
|
function invariant(condition, errorInfo) {
|
|
31
31
|
if (!condition) {
|
|
@@ -122,6 +122,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
122
122
|
level: 0,
|
|
123
123
|
message: 'Invalid import metadata: {0} {1}'
|
|
124
124
|
});
|
|
125
|
+
|
|
125
126
|
/* importMap errors */
|
|
126
127
|
Object.freeze({
|
|
127
128
|
code: 3011,
|
|
@@ -153,6 +154,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
153
154
|
}
|
|
154
155
|
return baseUrl;
|
|
155
156
|
}
|
|
157
|
+
|
|
156
158
|
/**
|
|
157
159
|
* Check if a string is a URL based on Common Internet Scheme Syntax
|
|
158
160
|
* https://www.ietf.org/rfc/rfc1738.txt
|
|
@@ -179,6 +181,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
179
181
|
function isUrl(url) {
|
|
180
182
|
return url.indexOf('://') !== -1;
|
|
181
183
|
}
|
|
184
|
+
|
|
182
185
|
// Borrowed and adapted from https://github.com/systemjs/systemjs/blob/master/src/common.js
|
|
183
186
|
// Resolves the first path segment relative to the second/parent URL
|
|
184
187
|
// eg: resolveIfNotPlainOrUrl('../test', 'http://www.site.com/one/two') => 'http://www.site.com/test'
|
|
@@ -207,6 +210,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
207
210
|
pathname = parentUrl.slice(parentProtocol.length + (parentUrl[parentProtocol.length] === '/' ? 1 : 0));
|
|
208
211
|
}
|
|
209
212
|
if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
213
|
+
|
|
210
214
|
// join together and split for removal of .. and . segments
|
|
211
215
|
// looping the string instead of anything fancy for perf reasons
|
|
212
216
|
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
@@ -221,6 +225,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
221
225
|
segmentIndex = -1;
|
|
222
226
|
}
|
|
223
227
|
}
|
|
228
|
+
|
|
224
229
|
// new segment - check if it is relative
|
|
225
230
|
else if (segmented[i] === '.') {
|
|
226
231
|
// ../ segment
|
|
@@ -304,11 +309,20 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
304
309
|
|
|
305
310
|
/* spec based import map resolver */
|
|
306
311
|
class ImportMetadataResolver {
|
|
307
|
-
|
|
308
|
-
|
|
312
|
+
// Default to empty mappings
|
|
313
|
+
__init() {
|
|
309
314
|
this.importURICache = new Map();
|
|
315
|
+
}
|
|
316
|
+
__init2() {
|
|
310
317
|
this.pendingURICache = new Map();
|
|
318
|
+
}
|
|
319
|
+
__init3() {
|
|
311
320
|
this.loadMappingHooks = [];
|
|
321
|
+
}
|
|
322
|
+
constructor(config, invalidationCallback) {
|
|
323
|
+
ImportMetadataResolver.prototype.__init.call(this);
|
|
324
|
+
ImportMetadataResolver.prototype.__init2.call(this);
|
|
325
|
+
ImportMetadataResolver.prototype.__init3.call(this);
|
|
312
326
|
this.config = config;
|
|
313
327
|
this.invalidationCallback = invalidationCallback;
|
|
314
328
|
}
|
|
@@ -369,6 +383,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
369
383
|
});
|
|
370
384
|
}
|
|
371
385
|
}
|
|
386
|
+
|
|
372
387
|
// Get URL from the local cache or return undefiend
|
|
373
388
|
getURI(specifier) {
|
|
374
389
|
return this.importURICache.has(specifier) ? resolveUrl(this.importURICache.get(specifier).uri, this.getBaseUrl()) : undefined;
|
|
@@ -382,6 +397,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
382
397
|
}
|
|
383
398
|
return undefined;
|
|
384
399
|
}
|
|
400
|
+
|
|
385
401
|
/**
|
|
386
402
|
* Resolves a the URI for a specified module. It will return the value in this order:
|
|
387
403
|
*
|
|
@@ -432,6 +448,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
432
448
|
hasMappingHooks() {
|
|
433
449
|
return this.loadMappingHooks.length > 0;
|
|
434
450
|
}
|
|
451
|
+
|
|
435
452
|
/**
|
|
436
453
|
* Evaluates mapping hooks. Returns first match. If all hooks return null call the mapping service.
|
|
437
454
|
* @param specifier Request module identifier
|
|
@@ -454,6 +471,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
454
471
|
}
|
|
455
472
|
}
|
|
456
473
|
}
|
|
474
|
+
|
|
457
475
|
// If we still do not have a match call the mapping service
|
|
458
476
|
return this.fetchNewMappings(specifier);
|
|
459
477
|
}
|
|
@@ -461,6 +479,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
461
479
|
if (typeof globalThis.fetch !== 'function') {
|
|
462
480
|
throw new LoaderError(UNRESOLVED, [specifier]);
|
|
463
481
|
}
|
|
482
|
+
|
|
464
483
|
// TODO For module invalidation with bundles it is recommended we have to send back all loaded root specified
|
|
465
484
|
// to ensure we detect all conflicts.
|
|
466
485
|
const uri = resolveUrl(this.buildMappingUrl(specifier), this.getBaseUrl());
|
|
@@ -522,9 +541,38 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
522
541
|
}
|
|
523
542
|
}
|
|
524
543
|
}
|
|
525
|
-
const MODULE_LOAD_TIMEOUT_TIMER =
|
|
544
|
+
const MODULE_LOAD_TIMEOUT_TIMER = 60 * 1000; // 1m
|
|
545
|
+
|
|
546
|
+
/*!
|
|
547
|
+
* Copyright (C) 2023 salesforce.com, inc.
|
|
548
|
+
*/
|
|
549
|
+
// @ts-ignore: Prevent cannot find name 'trustedTypes' error.
|
|
550
|
+
const SUPPORTS_TRUSTED_TYPES = typeof trustedTypes !== 'undefined';
|
|
551
|
+
function createTrustedTypesPolicy(name, options) {
|
|
552
|
+
// @ts-ignore: Prevent cannot find name 'trustedTypes' error.
|
|
553
|
+
return trustedTypes.createPolicy(name, options);
|
|
554
|
+
}
|
|
555
|
+
function createFallbackPolicy(_name, options) {
|
|
556
|
+
return options;
|
|
557
|
+
}
|
|
558
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
559
|
+
const createPolicy = SUPPORTS_TRUSTED_TYPES ? createTrustedTypesPolicy : createFallbackPolicy;
|
|
560
|
+
const policyOptions = {
|
|
561
|
+
createHTML(value) {
|
|
562
|
+
return value;
|
|
563
|
+
},
|
|
564
|
+
createScript(value) {
|
|
565
|
+
return value;
|
|
566
|
+
},
|
|
567
|
+
createScriptURL(value) {
|
|
568
|
+
return value;
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
const trusted = createPolicy('trusted', policyOptions);
|
|
572
|
+
/*! version: 0.19.4 */
|
|
526
573
|
|
|
527
574
|
/* global console,process */
|
|
575
|
+
|
|
528
576
|
let lastWindowError;
|
|
529
577
|
if (hasDocument) {
|
|
530
578
|
globalThis.addEventListener('error', evt => {
|
|
@@ -571,7 +619,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
571
619
|
code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
|
|
572
620
|
try {
|
|
573
621
|
// TODO eval source maps for debugging
|
|
574
|
-
eval(code);
|
|
622
|
+
eval(trusted.createScript(code));
|
|
575
623
|
} catch (e) {
|
|
576
624
|
throw new LoaderError(FAIL_LOAD, [id]);
|
|
577
625
|
}
|
|
@@ -603,14 +651,12 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
603
651
|
}
|
|
604
652
|
|
|
605
653
|
/* global console,process */
|
|
654
|
+
|
|
606
655
|
class ModuleRegistry {
|
|
607
656
|
constructor(config) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
this.moduleRegistry = new Map();
|
|
612
|
-
// Aliases of modules in the registry
|
|
613
|
-
this.aliases = new Map();
|
|
657
|
+
ModuleRegistry.prototype.__init.call(this);
|
|
658
|
+
ModuleRegistry.prototype.__init2.call(this);
|
|
659
|
+
ModuleRegistry.prototype.__init3.call(this);
|
|
614
660
|
this.profiler = config.profiler;
|
|
615
661
|
this.resolver = new ImportMetadataResolver(config, this.importMetadataInvalidationCallback.bind(this));
|
|
616
662
|
}
|
|
@@ -628,6 +674,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
628
674
|
}
|
|
629
675
|
async resolve(id, importer) {
|
|
630
676
|
const parentUrl = this.resolver.getBaseUrl(); // only support baseUrl for now
|
|
677
|
+
|
|
631
678
|
let resolved;
|
|
632
679
|
let aliasedId = id;
|
|
633
680
|
const resolveHooks = this.resolveHook;
|
|
@@ -642,6 +689,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
642
689
|
// eslint-disable-next-line no-await-in-loop
|
|
643
690
|
result = isResponseAPromise(response) ? await response : response;
|
|
644
691
|
}
|
|
692
|
+
|
|
645
693
|
// if result is not null, attempt resolution
|
|
646
694
|
if (result !== null) {
|
|
647
695
|
if (typeof result === 'string') {
|
|
@@ -671,6 +719,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
671
719
|
}
|
|
672
720
|
if (!resolved) {
|
|
673
721
|
const resolvedOrPlain = resolveIfNotPlainOrUrl(id, parentUrl) || id;
|
|
722
|
+
|
|
674
723
|
// if module registry already has named module the resolved id is the plain id
|
|
675
724
|
if (this.moduleRegistry.has(resolvedOrPlain)) {
|
|
676
725
|
return resolvedOrPlain;
|
|
@@ -737,6 +786,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
737
786
|
this.namedDefineRegistry.set(name, moduleDef);
|
|
738
787
|
this.lastDefine = moduleDef;
|
|
739
788
|
}
|
|
789
|
+
|
|
740
790
|
/**
|
|
741
791
|
* Marks modules as "externally" loaded/provided, so that the loader does not attempt to fetch them.
|
|
742
792
|
*
|
|
@@ -749,6 +799,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
749
799
|
let timer;
|
|
750
800
|
const moduleDefPromise = new Promise((resolve, reject) => {
|
|
751
801
|
resolveExternal = resolve;
|
|
802
|
+
|
|
752
803
|
// watch the external for timeout
|
|
753
804
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
754
805
|
timer = setTimeout(() => {
|
|
@@ -773,9 +824,25 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
773
824
|
}
|
|
774
825
|
});
|
|
775
826
|
}
|
|
827
|
+
|
|
828
|
+
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
829
|
+
__init() {
|
|
830
|
+
this.namedDefineRegistry = new Map();
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
834
|
+
__init2() {
|
|
835
|
+
this.moduleRegistry = new Map();
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// Aliases of modules in the registry
|
|
839
|
+
__init3() {
|
|
840
|
+
this.aliases = new Map();
|
|
841
|
+
}
|
|
776
842
|
getImportMetadataResolver() {
|
|
777
843
|
return this.resolver;
|
|
778
844
|
}
|
|
845
|
+
|
|
779
846
|
// Returns an existing module record by the resolvedId or aliased id
|
|
780
847
|
getExistingModuleRecord(resolvedId, aliasId) {
|
|
781
848
|
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
@@ -783,6 +850,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
783
850
|
this.storeModuleAlias(aliasId, resolvedId);
|
|
784
851
|
return moduleRecord;
|
|
785
852
|
}
|
|
853
|
+
|
|
786
854
|
// Check if this is a known alias
|
|
787
855
|
if (resolvedId !== aliasId) {
|
|
788
856
|
const alias = this.aliases.get(aliasId);
|
|
@@ -802,6 +870,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
802
870
|
// return existing
|
|
803
871
|
return existingRecord;
|
|
804
872
|
}
|
|
873
|
+
|
|
805
874
|
// Create a new Module Record
|
|
806
875
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
807
876
|
const dependencyRecords = instantiation.then(moduleDef => {
|
|
@@ -846,11 +915,13 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
846
915
|
const resolvedDepId = await this.resolve(dependency);
|
|
847
916
|
return this.getModuleRecord(resolvedDepId, dependency);
|
|
848
917
|
}
|
|
918
|
+
|
|
849
919
|
// execute the "top-level code" (the code outside of functions) of a module
|
|
850
920
|
async topLevelEvaluation(moduleRecord) {
|
|
851
921
|
await this.instantiateAll(moduleRecord, {});
|
|
852
922
|
return this.evaluateModule(moduleRecord, {});
|
|
853
923
|
}
|
|
924
|
+
|
|
854
925
|
// Returns a promise when a module and all of it's dependencies have finished instantiation
|
|
855
926
|
async instantiateAll(moduleRecord, instantiatedMap) {
|
|
856
927
|
if (!instantiatedMap[moduleRecord.id]) {
|
|
@@ -888,6 +959,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
888
959
|
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
889
960
|
}
|
|
890
961
|
const module = moduleRecord.module;
|
|
962
|
+
|
|
891
963
|
/**
|
|
892
964
|
* Circular dependencies are handled properly when named exports are used,
|
|
893
965
|
* however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
|
|
@@ -902,12 +974,15 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
902
974
|
}
|
|
903
975
|
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
904
976
|
}));
|
|
977
|
+
|
|
905
978
|
// W-10029836 - In the case where we could be instantiating multiple graphs at the same time lets make sure the module have not already been evaluated
|
|
906
979
|
if (moduleRecord.evaluated) {
|
|
907
980
|
return moduleRecord.module;
|
|
908
981
|
}
|
|
982
|
+
|
|
909
983
|
// evaluates the module function
|
|
910
984
|
let moduleDefault = exporter(...depsMapped);
|
|
985
|
+
|
|
911
986
|
// value is returned from exporter, then we are not using named exports
|
|
912
987
|
if (moduleDefault !== undefined) {
|
|
913
988
|
moduleDefault = {
|
|
@@ -930,6 +1005,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
930
1005
|
}
|
|
931
1006
|
}
|
|
932
1007
|
const moduleExports = moduleDefault || exports;
|
|
1008
|
+
|
|
933
1009
|
// update the module record
|
|
934
1010
|
// copy over enumerable public methods to module
|
|
935
1011
|
for (const key in moduleExports) {
|
|
@@ -943,6 +1019,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
943
1019
|
}
|
|
944
1020
|
});
|
|
945
1021
|
}
|
|
1022
|
+
|
|
946
1023
|
// copy non-enumerable to module
|
|
947
1024
|
if (moduleExports.__useDefault) {
|
|
948
1025
|
Object.defineProperty(moduleRecord.module, '__useDefault', {
|
|
@@ -963,10 +1040,12 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
963
1040
|
Object.freeze(moduleRecord.module);
|
|
964
1041
|
return moduleRecord.module;
|
|
965
1042
|
}
|
|
1043
|
+
|
|
966
1044
|
// Determines if named exports module has only default export
|
|
967
1045
|
isNamedExportDefaultOnly(exports) {
|
|
968
1046
|
return exports !== undefined && Object.getOwnPropertyNames(exports).length === 2 && Object.prototype.hasOwnProperty.call(exports, 'default') && Object.prototype.hasOwnProperty.call(exports, '__esModule');
|
|
969
1047
|
}
|
|
1048
|
+
|
|
970
1049
|
// Wrap the dependency in a function that can be called and detected by __circular__ property.
|
|
971
1050
|
// The LWC engine checks for __circular__ to detect circular dependencies.
|
|
972
1051
|
getCircularDependencyWrapper(module) {
|
|
@@ -989,6 +1068,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
989
1068
|
async getModuleDef(resolvedId, originalId) {
|
|
990
1069
|
// reset lastDefine
|
|
991
1070
|
this.lastDefine = undefined;
|
|
1071
|
+
|
|
992
1072
|
// the module name can be the resolved ID or the original ID if neither are URL's.
|
|
993
1073
|
const moduleName = !isUrl(resolvedId) ? resolvedId : originalId !== resolvedId ? originalId : undefined;
|
|
994
1074
|
let moduleDef = moduleName && this.namedDefineRegistry.get(moduleName);
|
|
@@ -1029,10 +1109,12 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1029
1109
|
}).then(() => {
|
|
1030
1110
|
// Attempt to retrieve the module definition by name first
|
|
1031
1111
|
moduleDef = moduleName && this.namedDefineRegistry.get(moduleName);
|
|
1112
|
+
|
|
1032
1113
|
// Fallback to the last loader.define call
|
|
1033
1114
|
if (!moduleDef) {
|
|
1034
1115
|
moduleDef = this.lastDefine;
|
|
1035
1116
|
}
|
|
1117
|
+
|
|
1036
1118
|
// This should not happen
|
|
1037
1119
|
if (!moduleDef) {
|
|
1038
1120
|
throw new LoaderError(FAIL_INSTANTIATE, [resolvedId]);
|
|
@@ -1116,6 +1198,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1116
1198
|
if (!mappingEndpoint) {
|
|
1117
1199
|
throw new LoaderError(NO_MAPPING_URL);
|
|
1118
1200
|
}
|
|
1201
|
+
|
|
1119
1202
|
// add a trailing slash, if it does not exist
|
|
1120
1203
|
config.endpoints.uris.mapping = mappingEndpoint.replace(/\/?$/, '/');
|
|
1121
1204
|
if (baseUrl) {
|
|
@@ -1144,6 +1227,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1144
1227
|
baseUrl,
|
|
1145
1228
|
profiler
|
|
1146
1229
|
}));
|
|
1230
|
+
|
|
1147
1231
|
// TODO: W-10539691 - temp workaround for LWR-Java -- remove once appId is implemented there
|
|
1148
1232
|
if (config.appMetadata && !config.appMetadata.appId) {
|
|
1149
1233
|
// Parse the appId from the bootstrapModule
|
|
@@ -1152,6 +1236,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1152
1236
|
const appId = match && match[1];
|
|
1153
1237
|
config.appMetadata.appId = appId;
|
|
1154
1238
|
}
|
|
1239
|
+
|
|
1155
1240
|
// TODO: https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
1156
1241
|
this.services = Object.freeze({
|
|
1157
1242
|
addLoaderPlugin: this.registry.addLoaderPlugin.bind(this.registry),
|
|
@@ -1159,6 +1244,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1159
1244
|
appMetadata: config.appMetadata
|
|
1160
1245
|
});
|
|
1161
1246
|
}
|
|
1247
|
+
|
|
1162
1248
|
/**
|
|
1163
1249
|
* Defines/registers a single named AMD module definition.
|
|
1164
1250
|
*
|
|
@@ -1171,6 +1257,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1171
1257
|
invariant(typeof name === 'string', MISSING_NAME);
|
|
1172
1258
|
let ctor = execute;
|
|
1173
1259
|
let deps = dependencies;
|
|
1260
|
+
|
|
1174
1261
|
// Convert no dependencies form `define('name', function(){}, {});` to: `define('name', [], function(){}, {})`
|
|
1175
1262
|
if (typeof deps === 'function') {
|
|
1176
1263
|
ctor = dependencies;
|
|
@@ -1179,6 +1266,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1179
1266
|
invariant(Array.isArray(deps), INVALID_DEPS);
|
|
1180
1267
|
this.registry.define(name, deps, ctor);
|
|
1181
1268
|
}
|
|
1269
|
+
|
|
1182
1270
|
/**
|
|
1183
1271
|
* Retrieves/loads a module, returning it from the registry if it exists and fetching it if it doesn't.
|
|
1184
1272
|
*
|
|
@@ -1190,6 +1278,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1190
1278
|
async load(id, importer) {
|
|
1191
1279
|
return this.registry.load(id, importer);
|
|
1192
1280
|
}
|
|
1281
|
+
|
|
1193
1282
|
/**
|
|
1194
1283
|
* Checks if a Module exists in the registry. Note, returns false even if the ModuleDefinition exists but the Module has not been instantiated yet (executed).
|
|
1195
1284
|
*
|
|
@@ -1199,6 +1288,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1199
1288
|
has(id) {
|
|
1200
1289
|
return this.registry.has(id);
|
|
1201
1290
|
}
|
|
1291
|
+
|
|
1202
1292
|
/**
|
|
1203
1293
|
* Resolves the module identifier or URL. Returns the module identifier if the moduleDefinition exists, or the full resolved URL if a URL is given.
|
|
1204
1294
|
*
|
|
@@ -1213,6 +1303,7 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1213
1303
|
async registerImportMappings(mappings, rootSpecifiers) {
|
|
1214
1304
|
this.registry.getImportMetadataResolver().registerImportMappings(mappings, rootSpecifiers);
|
|
1215
1305
|
}
|
|
1306
|
+
|
|
1216
1307
|
/**
|
|
1217
1308
|
* Marks modules as "externally" loaded/provided (e.g. preloaded), so that the loader does not attempt to load them.
|
|
1218
1309
|
*
|
|
@@ -1227,4 +1318,4 @@ LWR.define('lwr/loader/v/0_10_0-alpha_2', ['exports'], function (exports) { 'use
|
|
|
1227
1318
|
|
|
1228
1319
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1229
1320
|
|
|
1230
|
-
});
|
|
1321
|
+
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
LWR.define('lwr/metrics/v/0_10_0-
|
|
1
|
+
LWR.define('lwr/metrics/v/0_10_0-alpha_20', ['exports'], (function (exports) { 'use strict';
|
|
2
2
|
|
|
3
3
|
// Bootstrap / shim
|
|
4
4
|
const BOOTSTRAP_PREFIX = 'lwr.bootstrap.';
|
|
@@ -7,6 +7,13 @@ LWR.define('lwr/metrics/v/0_10_0-alpha_2', ['exports'], function (exports) { 'us
|
|
|
7
7
|
const BOOTSTRAP_ERROR_COUNT = `${BOOTSTRAP_ERROR}.count`;
|
|
8
8
|
const BOOTSTRAP_DURATION = `${BOOTSTRAP_PREFIX}duration`;
|
|
9
9
|
|
|
10
|
+
// Initialization
|
|
11
|
+
const INIT = 'lwr.bootstrap.init';
|
|
12
|
+
const INIT_DURATION = `${INIT}.duration`;
|
|
13
|
+
const INIT_MODULE = `lwr.bootstrap.init.module`;
|
|
14
|
+
const INIT_MODULE_DURATION = `${INIT_MODULE}.duration`;
|
|
15
|
+
const INIT_MODULE_COUNT = `${INIT_MODULE}.count`;
|
|
16
|
+
|
|
10
17
|
// Loader: modules
|
|
11
18
|
const LOADER_PREFIX = 'lwr.loader.';
|
|
12
19
|
const MODULE_DEFINE = `${LOADER_PREFIX}module.define`;
|
|
@@ -39,6 +46,11 @@ LWR.define('lwr/metrics/v/0_10_0-alpha_2', ['exports'], function (exports) { 'us
|
|
|
39
46
|
exports.BOOTSTRAP_ERROR = BOOTSTRAP_ERROR;
|
|
40
47
|
exports.BOOTSTRAP_ERROR_COUNT = BOOTSTRAP_ERROR_COUNT;
|
|
41
48
|
exports.BOOTSTRAP_PREFIX = BOOTSTRAP_PREFIX;
|
|
49
|
+
exports.INIT = INIT;
|
|
50
|
+
exports.INIT_DURATION = INIT_DURATION;
|
|
51
|
+
exports.INIT_MODULE = INIT_MODULE;
|
|
52
|
+
exports.INIT_MODULE_COUNT = INIT_MODULE_COUNT;
|
|
53
|
+
exports.INIT_MODULE_DURATION = INIT_MODULE_DURATION;
|
|
42
54
|
exports.LOADER_PREFIX = LOADER_PREFIX;
|
|
43
55
|
exports.MAPPINGS_ERROR = MAPPINGS_ERROR;
|
|
44
56
|
exports.MAPPINGS_ERROR_COUNT = MAPPINGS_ERROR_COUNT;
|
|
@@ -63,4 +75,4 @@ LWR.define('lwr/metrics/v/0_10_0-alpha_2', ['exports'], function (exports) { 'us
|
|
|
63
75
|
|
|
64
76
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
65
77
|
|
|
66
|
-
});
|
|
78
|
+
}));
|