@lwrjs/client-modules 0.17.2-alpha.1 → 0.17.2-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/bundle/prod/lwr/init/init.js +1 -1
- package/build/bundle/prod/lwr/lockerDefine/lockerDefine.js +1 -1
- package/build/bundle/prod/lwr/servicesESM/servicesESM.js +1 -1
- package/build/es/modules/lwr/init/init.js +80 -39
- package/build/es/modules/lwr/profiler/profiler.js +1 -0
- package/build/modules/lwr/hmr/hmr.js +1 -1
- package/build/modules/lwr/init/init.js +98 -51
- package/build/modules/lwr/lockerDefine/lockerDefine.js +6 -4
- package/build/modules/lwr/preInit/preInit.js +4 -3
- package/build/modules/lwr/profiler/profiler.js +1 -0
- package/build/modules/lwr/servicesESM/handleStaleModuleESM.js +2 -3
- package/build/modules/lwr/servicesESM/servicesESM.js +4 -0
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=[];let o;const n=globalThis.LWR;
|
|
1
|
+
const e=[];let o;const n=globalThis,t=n.LWR;t.define||t.env?n.LWR=Object.freeze({define:t.define,env:t.env}):delete n.LWR;const a={addLoaderPlugin:()=>{console.warn("API is not supported in ESM format")},handleStaleModule:function(n){e.push(n),o||(o=new WebSocket(`ws://${location.host}`),o.addEventListener("message",(async o=>{const n=o.data,t=JSON.parse(n);if("moduleUpdate"===t.eventType){const{oldHash:o,newHash:n,module:{specifier:a}}=t.payload;for(let t=0;t<e.length;t++){if(null!==(0,e[t])({name:a,oldHash:o,newHash:n}))break}}})))},appMetadata:function(){const{appId:e,bootstrapModule:o,rootComponent:n,rootComponents:a}=t;return{appId:e,bootstrapModule:o,rootComponent:n,rootComponents:a}}(),addServerDataCallback:function(e){}};export{a as services};
|
|
2
2
|
//# sourceMappingURL=servicesESM.js.map
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
import { BOOTSTRAP_END, INIT, INIT_MODULE } from 'lwr/metrics';
|
|
2
2
|
import { logOperationStart, logOperationEnd } from 'lwr/profiler';
|
|
3
3
|
// TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted - tmp
|
|
4
|
+
// eslint-disable-next-line lwr/only-allowed-imports
|
|
4
5
|
import { createElement } from 'lwc';
|
|
5
6
|
// <hydrateComponentProxy> - This code is removed in core
|
|
7
|
+
// Note: a build step uses these comments to strip the code for core.
|
|
8
|
+
// eslint-disable-next-line lwr/only-allowed-imports
|
|
6
9
|
import { hydrateComponent } from 'lwc';
|
|
7
10
|
function hydrateComponentProxy(customElement, Ctor, props) {
|
|
8
11
|
hydrateComponent(customElement, Ctor, props);
|
|
9
12
|
}
|
|
10
13
|
// </hydrateComponentProxy>
|
|
14
|
+
const shouldYield = (() => {
|
|
15
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
16
|
+
if (!globalThis.performance) {
|
|
17
|
+
return () => false;
|
|
18
|
+
}
|
|
19
|
+
// Break up hydration tasks into timed batches.
|
|
20
|
+
// Borrowed from https://tinyurl.com/5b4fw7eb
|
|
21
|
+
const HYDRATION_TASK_BATCH_DURATION = 50;
|
|
22
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
23
|
+
let timeOfLastYield = globalThis.performance.now();
|
|
24
|
+
return () => {
|
|
25
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
26
|
+
const now = globalThis.performance.now();
|
|
27
|
+
if (now - timeOfLastYield > HYDRATION_TASK_BATCH_DURATION) {
|
|
28
|
+
timeOfLastYield = now;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
11
34
|
function initializeWebComponent(elementName, Ctor) {
|
|
12
35
|
return createElement(elementName, { is: Ctor });
|
|
13
36
|
}
|
|
@@ -43,20 +66,26 @@ export function getPropFromAttrName(propName) {
|
|
|
43
66
|
* @example - [['x/appRoot', appCtor], ['x/nav', navCtor]]
|
|
44
67
|
*/
|
|
45
68
|
export function init(rootModules, serverData = {}) {
|
|
46
|
-
|
|
69
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
70
|
+
if (typeof globalThis.customElements === 'undefined' || typeof globalThis.document === 'undefined') {
|
|
47
71
|
logOperationStart({ id: BOOTSTRAP_END });
|
|
48
72
|
return;
|
|
49
73
|
}
|
|
50
74
|
logOperationStart({ id: INIT });
|
|
51
75
|
let index = 0;
|
|
76
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
77
|
+
const document = globalThis.document;
|
|
52
78
|
for (const [specifier, ctor] of rootModules) {
|
|
53
79
|
const elementName = toKebabCase(specifier);
|
|
54
80
|
// initialize and inject the root module into the LWR Root or DOM if it is missing
|
|
81
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
55
82
|
if (!document.body.querySelector(elementName)) {
|
|
56
83
|
logOperationStart({ id: INIT_MODULE, specifier, specifierIndex: ++index });
|
|
57
84
|
// this is for SPA like routes (one component at the root level) utilizing the lwr-root directive
|
|
58
85
|
const component = initializeWebComponent(elementName, ctor);
|
|
86
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
59
87
|
const container = document.querySelector('[lwr-root]');
|
|
88
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
60
89
|
container ? container.appendChild(component) : document.body.appendChild(component);
|
|
61
90
|
logOperationEnd({
|
|
62
91
|
id: INIT_MODULE,
|
|
@@ -67,52 +96,64 @@ export function init(rootModules, serverData = {}) {
|
|
|
67
96
|
continue;
|
|
68
97
|
}
|
|
69
98
|
// the page has been rendered or SSR'd, and each component needs to initialized(or hydrated)
|
|
99
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
70
100
|
const elements = document.querySelectorAll(elementName);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
101
|
+
(async () => {
|
|
102
|
+
const specifierIndex = ++index;
|
|
103
|
+
for (const element of elements) {
|
|
104
|
+
logOperationStart({ id: INIT_MODULE, specifier, specifierIndex });
|
|
105
|
+
const propsId = element.dataset.lwrPropsId;
|
|
106
|
+
// hydrate SSR'd components
|
|
107
|
+
if (propsId) {
|
|
108
|
+
if (shouldYield()) {
|
|
109
|
+
// Yield to the main thread during long hydration tasks
|
|
110
|
+
// eslint-disable-next-line no-await-in-loop
|
|
111
|
+
await yieldToMainThread();
|
|
112
|
+
}
|
|
113
|
+
hydrateComponentProxy(element, ctor, serverData[propsId] || {});
|
|
114
|
+
logOperationEnd({
|
|
115
|
+
id: INIT_MODULE,
|
|
116
|
+
specifier,
|
|
117
|
+
specifierIndex: index,
|
|
118
|
+
metadata: { renderMode: 'ssr' },
|
|
119
|
+
});
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
// Note: due to the bug described at the top of this file, each CSR'd custom element
|
|
123
|
+
// must be replaced with the new synthetic constructor. Attributes and children are
|
|
124
|
+
// copied over to the new component.
|
|
125
|
+
const component = initializeWebComponent(elementName, ctor);
|
|
126
|
+
// copy the attributes
|
|
127
|
+
for (const { name, value } of element.attributes) {
|
|
128
|
+
component.setAttribute(name, value);
|
|
129
|
+
const prop = getPropFromAttrName(name);
|
|
130
|
+
if (prop in component) {
|
|
131
|
+
// set attributes as properties for reactivity
|
|
132
|
+
component[prop] = value;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// save the children
|
|
136
|
+
while (element.firstChild) {
|
|
137
|
+
component.appendChild(element.firstChild);
|
|
138
|
+
}
|
|
139
|
+
// swap the element out with the initialized component
|
|
140
|
+
element.replaceWith(component);
|
|
77
141
|
logOperationEnd({
|
|
78
142
|
id: INIT_MODULE,
|
|
79
143
|
specifier,
|
|
80
|
-
specifierIndex
|
|
81
|
-
metadata: { renderMode: '
|
|
144
|
+
specifierIndex,
|
|
145
|
+
metadata: { renderMode: 'csr' },
|
|
82
146
|
});
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
// Note: due to the bug described at the top of this file, each CSR'd custom element
|
|
86
|
-
// must be replaced with the new synthetic constructor. Attributes and children are
|
|
87
|
-
// copied over to the new component.
|
|
88
|
-
const component = initializeWebComponent(elementName, ctor);
|
|
89
|
-
// copy the attributes
|
|
90
|
-
for (const { name, value } of element.attributes) {
|
|
91
|
-
component.setAttribute(name, value);
|
|
92
|
-
const prop = getPropFromAttrName(name);
|
|
93
|
-
if (prop in component) {
|
|
94
|
-
// set attributes as properties for reactivity
|
|
95
|
-
component[prop] = value;
|
|
96
|
-
}
|
|
97
147
|
}
|
|
98
|
-
|
|
99
|
-
while (element.childNodes.length > 0) {
|
|
100
|
-
component.appendChild(element.childNodes[0]);
|
|
101
|
-
}
|
|
102
|
-
// swap the element out with the initialized component
|
|
103
|
-
const parent = element.parentElement;
|
|
104
|
-
if (parent) {
|
|
105
|
-
parent.replaceChild(component, element);
|
|
106
|
-
}
|
|
107
|
-
logOperationEnd({
|
|
108
|
-
id: INIT_MODULE,
|
|
109
|
-
specifier,
|
|
110
|
-
specifierIndex: index,
|
|
111
|
-
metadata: { renderMode: 'csr' },
|
|
112
|
-
});
|
|
113
|
-
}
|
|
148
|
+
})();
|
|
114
149
|
}
|
|
115
150
|
logOperationEnd({ id: INIT });
|
|
116
151
|
logOperationStart({ id: BOOTSTRAP_END });
|
|
117
152
|
}
|
|
153
|
+
// Allows the browser to yield to the main thread during long-running tasks, improving responsiveness.
|
|
154
|
+
async function yieldToMainThread() {
|
|
155
|
+
const scheduler = globalThis.scheduler;
|
|
156
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
157
|
+
return scheduler?.yield ? scheduler.yield() : new Promise((resolve) => setTimeout(resolve, 0));
|
|
158
|
+
}
|
|
118
159
|
//# sourceMappingURL=init.js.map
|
|
@@ -10,6 +10,7 @@ export function attachDispatcher(dispatcher) {
|
|
|
10
10
|
}
|
|
11
11
|
// Check if the Performance API is available
|
|
12
12
|
// e.g. JSDom (used in Jest) doesn't implement these
|
|
13
|
+
// eslint-disable-next-line
|
|
13
14
|
const perf = globalThis.performance;
|
|
14
15
|
const isPerfSupported = typeof perf !== 'undefined' &&
|
|
15
16
|
typeof perf.mark === 'function' &&
|
|
@@ -27,7 +27,7 @@ function updateStaleModule({ oldModule, newModule, specifier }) {
|
|
|
27
27
|
if (specifier.endsWith('html') && newModule.default) {
|
|
28
28
|
console.log(`Swapping HTML template for module "${specifier}"`);
|
|
29
29
|
swapTemplate(oldModule.default, newModule.default);
|
|
30
|
-
} else if (specifier.endsWith('css') && newModule.default) {
|
|
30
|
+
} else if ((specifier.endsWith('css') || specifier.endsWith('.css?scoped=true')) && newModule.default) {
|
|
31
31
|
console.log(`Swapping CSS for module "${specifier}"`);
|
|
32
32
|
swapStyle(oldModule.default[0], newModule.default[0]);
|
|
33
33
|
} else {
|
|
@@ -1,16 +1,44 @@
|
|
|
1
|
+
// eslint-disable-next-line lwr/only-allowed-type-imports
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line lwr/only-allowed-type-imports
|
|
4
|
+
|
|
1
5
|
import { BOOTSTRAP_END, INIT, INIT_MODULE } from 'lwr/metrics';
|
|
2
6
|
import { logOperationStart, logOperationEnd } from 'lwr/profiler';
|
|
3
7
|
|
|
4
8
|
// TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted - tmp
|
|
9
|
+
// eslint-disable-next-line lwr/only-allowed-imports
|
|
5
10
|
import { createElement } from 'lwc';
|
|
6
11
|
|
|
7
12
|
// <hydrateComponentProxy> - This code is removed in core
|
|
13
|
+
// Note: a build step uses these comments to strip the code for core.
|
|
14
|
+
// eslint-disable-next-line lwr/only-allowed-imports
|
|
8
15
|
import { hydrateComponent } from 'lwc';
|
|
9
16
|
function hydrateComponentProxy(customElement, Ctor, props) {
|
|
10
17
|
hydrateComponent(customElement, Ctor, props);
|
|
11
18
|
}
|
|
12
19
|
// </hydrateComponentProxy>
|
|
13
20
|
|
|
21
|
+
const shouldYield = (() => {
|
|
22
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
23
|
+
if (!globalThis.performance) {
|
|
24
|
+
return () => false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Break up hydration tasks into timed batches.
|
|
28
|
+
// Borrowed from https://tinyurl.com/5b4fw7eb
|
|
29
|
+
const HYDRATION_TASK_BATCH_DURATION = 50;
|
|
30
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
31
|
+
let timeOfLastYield = globalThis.performance.now();
|
|
32
|
+
return () => {
|
|
33
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
34
|
+
const now = globalThis.performance.now();
|
|
35
|
+
if (now - timeOfLastYield > HYDRATION_TASK_BATCH_DURATION) {
|
|
36
|
+
timeOfLastYield = now;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
14
42
|
function initializeWebComponent(elementName, Ctor) {
|
|
15
43
|
return createElement(elementName, {
|
|
16
44
|
is: Ctor
|
|
@@ -48,7 +76,8 @@ export function getPropFromAttrName(propName) {
|
|
|
48
76
|
* @example - [['x/appRoot', appCtor], ['x/nav', navCtor]]
|
|
49
77
|
*/
|
|
50
78
|
export function init(rootModules, serverData = {}) {
|
|
51
|
-
|
|
79
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
80
|
+
if (typeof globalThis.customElements === 'undefined' || typeof globalThis.document === 'undefined') {
|
|
52
81
|
logOperationStart({
|
|
53
82
|
id: BOOTSTRAP_END
|
|
54
83
|
});
|
|
@@ -58,10 +87,13 @@ export function init(rootModules, serverData = {}) {
|
|
|
58
87
|
id: INIT
|
|
59
88
|
});
|
|
60
89
|
let index = 0;
|
|
90
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
91
|
+
const document = globalThis.document;
|
|
61
92
|
for (const [specifier, ctor] of rootModules) {
|
|
62
93
|
const elementName = toKebabCase(specifier);
|
|
63
94
|
|
|
64
95
|
// initialize and inject the root module into the LWR Root or DOM if it is missing
|
|
96
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
65
97
|
if (!document.body.querySelector(elementName)) {
|
|
66
98
|
logOperationStart({
|
|
67
99
|
id: INIT_MODULE,
|
|
@@ -71,7 +103,9 @@ export function init(rootModules, serverData = {}) {
|
|
|
71
103
|
|
|
72
104
|
// this is for SPA like routes (one component at the root level) utilizing the lwr-root directive
|
|
73
105
|
const component = initializeWebComponent(elementName, ctor);
|
|
106
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
74
107
|
const container = document.querySelector('[lwr-root]');
|
|
108
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
75
109
|
container ? container.appendChild(component) : document.body.appendChild(component);
|
|
76
110
|
logOperationEnd({
|
|
77
111
|
id: INIT_MODULE,
|
|
@@ -85,66 +119,72 @@ export function init(rootModules, serverData = {}) {
|
|
|
85
119
|
}
|
|
86
120
|
|
|
87
121
|
// the page has been rendered or SSR'd, and each component needs to initialized(or hydrated)
|
|
122
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
88
123
|
const elements = document.querySelectorAll(elementName);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
specifierIndex: ++index
|
|
94
|
-
});
|
|
95
|
-
const propsId = element.dataset.lwrPropsId;
|
|
96
|
-
|
|
97
|
-
// hydrate SSR'd components
|
|
98
|
-
if (propsId) {
|
|
99
|
-
hydrateComponentProxy(element, ctor, serverData[propsId] || {});
|
|
100
|
-
logOperationEnd({
|
|
124
|
+
(async () => {
|
|
125
|
+
const specifierIndex = ++index;
|
|
126
|
+
for (const element of elements) {
|
|
127
|
+
logOperationStart({
|
|
101
128
|
id: INIT_MODULE,
|
|
102
129
|
specifier,
|
|
103
|
-
specifierIndex
|
|
104
|
-
metadata: {
|
|
105
|
-
renderMode: 'ssr'
|
|
106
|
-
}
|
|
130
|
+
specifierIndex
|
|
107
131
|
});
|
|
108
|
-
|
|
109
|
-
}
|
|
132
|
+
const propsId = element.dataset.lwrPropsId;
|
|
110
133
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
134
|
+
// hydrate SSR'd components
|
|
135
|
+
if (propsId) {
|
|
136
|
+
if (shouldYield()) {
|
|
137
|
+
// Yield to the main thread during long hydration tasks
|
|
138
|
+
// eslint-disable-next-line no-await-in-loop
|
|
139
|
+
await yieldToMainThread();
|
|
140
|
+
}
|
|
141
|
+
hydrateComponentProxy(element, ctor, serverData[propsId] || {});
|
|
142
|
+
logOperationEnd({
|
|
143
|
+
id: INIT_MODULE,
|
|
144
|
+
specifier,
|
|
145
|
+
specifierIndex: index,
|
|
146
|
+
metadata: {
|
|
147
|
+
renderMode: 'ssr'
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
115
152
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
153
|
+
// Note: due to the bug described at the top of this file, each CSR'd custom element
|
|
154
|
+
// must be replaced with the new synthetic constructor. Attributes and children are
|
|
155
|
+
// copied over to the new component.
|
|
156
|
+
const component = initializeWebComponent(elementName, ctor);
|
|
157
|
+
|
|
158
|
+
// copy the attributes
|
|
159
|
+
for (const {
|
|
160
|
+
name,
|
|
161
|
+
value
|
|
162
|
+
} of element.attributes) {
|
|
163
|
+
component.setAttribute(name, value);
|
|
164
|
+
const prop = getPropFromAttrName(name);
|
|
165
|
+
if (prop in component) {
|
|
166
|
+
// set attributes as properties for reactivity
|
|
167
|
+
component[prop] = value;
|
|
168
|
+
}
|
|
126
169
|
}
|
|
127
|
-
}
|
|
128
170
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
171
|
+
// save the children
|
|
172
|
+
while (element.firstChild) {
|
|
173
|
+
component.appendChild(element.firstChild);
|
|
174
|
+
}
|
|
133
175
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
176
|
+
// swap the element out with the initialized component
|
|
177
|
+
element.replaceWith(component);
|
|
178
|
+
logOperationEnd({
|
|
179
|
+
id: INIT_MODULE,
|
|
180
|
+
specifier,
|
|
181
|
+
specifierIndex,
|
|
182
|
+
metadata: {
|
|
183
|
+
renderMode: 'csr'
|
|
184
|
+
}
|
|
185
|
+
});
|
|
138
186
|
}
|
|
139
|
-
|
|
140
|
-
id: INIT_MODULE,
|
|
141
|
-
specifier,
|
|
142
|
-
specifierIndex: index,
|
|
143
|
-
metadata: {
|
|
144
|
-
renderMode: 'csr'
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
187
|
+
})();
|
|
148
188
|
}
|
|
149
189
|
logOperationEnd({
|
|
150
190
|
id: INIT
|
|
@@ -152,4 +192,11 @@ export function init(rootModules, serverData = {}) {
|
|
|
152
192
|
logOperationStart({
|
|
153
193
|
id: BOOTSTRAP_END
|
|
154
194
|
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Allows the browser to yield to the main thread during long-running tasks, improving responsiveness.
|
|
198
|
+
async function yieldToMainThread() {
|
|
199
|
+
const scheduler = globalThis.scheduler;
|
|
200
|
+
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
201
|
+
return scheduler?.yield ? scheduler.yield() : new Promise(resolve => setTimeout(resolve, 0));
|
|
155
202
|
}
|
|
@@ -16392,7 +16392,7 @@ function wrapPlatformResourceLoader$LWS(dep$LWS, key$LWS) {
|
|
|
16392
16392
|
}
|
|
16393
16393
|
/*! version: 0.23.6 */
|
|
16394
16394
|
|
|
16395
|
-
const loaderDefine = globalThis.LWR.define;
|
|
16395
|
+
const loaderDefine = (globalThis ).LWR.define;
|
|
16396
16396
|
|
|
16397
16397
|
/**
|
|
16398
16398
|
* Mark an exports object as "live", see https://github.com/caridy/secure-javascript-environment/pull/87.
|
|
@@ -16461,7 +16461,7 @@ function secureExporter(
|
|
|
16461
16461
|
}
|
|
16462
16462
|
}
|
|
16463
16463
|
if (exportsIndex !== -1 || lwcIndex !== -1 || platformResourceLoaderIndex !== -1) {
|
|
16464
|
-
return
|
|
16464
|
+
return (...args) => {
|
|
16465
16465
|
if (exportsIndex !== -1) {
|
|
16466
16466
|
const arg = args[exportsIndex];
|
|
16467
16467
|
args[exportsIndex] = markLiveObject(arg) || arg;
|
|
@@ -16483,6 +16483,8 @@ function secureExporter(
|
|
|
16483
16483
|
namespace,
|
|
16484
16484
|
);
|
|
16485
16485
|
}
|
|
16486
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16487
|
+
// @ts-ignore
|
|
16486
16488
|
return out.apply(this, args);
|
|
16487
16489
|
};
|
|
16488
16490
|
}
|
|
@@ -16492,8 +16494,8 @@ function secureExporter(
|
|
|
16492
16494
|
|
|
16493
16495
|
function registerLockerDefine(trustedNamespaces) {
|
|
16494
16496
|
// override the global LWR.define() for Locker
|
|
16495
|
-
globalThis.LWR = Object.freeze(
|
|
16496
|
-
Object.assign(Object.assign({}, globalThis.LWR), {
|
|
16497
|
+
(globalThis ).LWR = Object.freeze(
|
|
16498
|
+
Object.assign(Object.assign({}, (globalThis ).LWR), {
|
|
16497
16499
|
define: function (specifier, dependencies, exporter, signature) {
|
|
16498
16500
|
if (typeof dependencies === 'function') {
|
|
16499
16501
|
// when the module has no dependency, the bundler only passes 3 parameters, the specifier, exporter and signature
|
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
* Note: this module should be imported before other dependencies in the ABS
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const GLOBAL = globalThis;
|
|
7
|
+
const lwrGlobals = GLOBAL.LWR;
|
|
7
8
|
if (lwrGlobals.define || lwrGlobals.env) {
|
|
8
9
|
// AMD only
|
|
9
|
-
|
|
10
|
+
GLOBAL.LWR = Object.freeze({
|
|
10
11
|
define: lwrGlobals.define,
|
|
11
12
|
env: lwrGlobals.env
|
|
12
13
|
});
|
|
13
14
|
} else {
|
|
14
|
-
delete
|
|
15
|
+
delete GLOBAL.LWR;
|
|
15
16
|
}
|
|
16
17
|
export function getClientBootstrapConfig() {
|
|
17
18
|
return lwrGlobals;
|
|
@@ -11,6 +11,7 @@ export function attachDispatcher(dispatcher) {
|
|
|
11
11
|
|
|
12
12
|
// Check if the Performance API is available
|
|
13
13
|
// e.g. JSDom (used in Jest) doesn't implement these
|
|
14
|
+
// eslint-disable-next-line
|
|
14
15
|
const perf = globalThis.performance;
|
|
15
16
|
const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
|
|
16
17
|
function getMeasureName(id, specifier) {
|
|
@@ -4,9 +4,8 @@ export function registerHandleStaleModuleHook(callback) {
|
|
|
4
4
|
handleStaleModuleHooks.push(callback);
|
|
5
5
|
if (!socket) {
|
|
6
6
|
socket = new WebSocket(`ws://${location.host}`);
|
|
7
|
-
socket.addEventListener('message', async
|
|
8
|
-
data
|
|
9
|
-
}) => {
|
|
7
|
+
socket.addEventListener('message', async payload => {
|
|
8
|
+
const data = payload.data;
|
|
10
9
|
const event = JSON.parse(data);
|
|
11
10
|
if (event.eventType === 'moduleUpdate') {
|
|
12
11
|
const {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { registerHandleStaleModuleHook } from './handleStaleModuleESM';
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
+
// @ts-ignore
|
|
2
4
|
import { getClientBootstrapConfig } from 'lwr/preInit';
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// @ts-ignore
|
|
3
7
|
import { registerServerDataCallbacks } from 'lwr/serverDataCallback';
|
|
4
8
|
const noop = () => {
|
|
5
9
|
console.warn('API is not supported in ESM format');
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.17.2-alpha.
|
|
7
|
+
"version": "0.17.2-alpha.11",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@locker/sandbox": "0.23.6",
|
|
37
|
-
"@lwrjs/shared-utils": "0.17.2-alpha.
|
|
37
|
+
"@lwrjs/shared-utils": "0.17.2-alpha.11"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@lwrjs/types": "0.17.2-alpha.
|
|
40
|
+
"@lwrjs/types": "0.17.2-alpha.11",
|
|
41
41
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
42
42
|
"@rollup/plugin-sucrase": "^5.0.2",
|
|
43
43
|
"@rollup/plugin-terser": "^0.4.4",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"volta": {
|
|
71
71
|
"extends": "../../../package.json"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "72217912e6c17e617413044743892582be5599a0"
|
|
74
74
|
}
|