@lwrjs/everywhere 0.9.9-alpha.8 → 0.10.0-alpha.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.
Files changed (43) hide show
  1. package/README.md +1 -6
  2. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/9fa50240fcef7e2e2f0a984c64618266/config.js +10 -0
  3. 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_0/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +18 -0
  4. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/2_38_1/s/8cf6b94d9c0b398c70c97fdca2759caa/lwc.js +8934 -0
  5. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/0_10_0-alpha_0/s/c538071acf5bde58e816967a14c465c3/lwr_everywhereAmd.js +66 -0
  6. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/0_10_0-alpha_0/s/206e6e0af6f019fdfd86d87d56331bc2/lwr_init.js +97 -0
  7. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_9_9-alpha_8/s/b234adc35388b40b104bed6bf73710c1 → 0_10_0-alpha_0/s/93913c303e4da43e040d25afbea8865a}/lwr_loader.js +362 -137
  8. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/0_10_0-alpha_0/s/3426e42c3e22ce07ab2adc62c4c523a0/lwr_metrics.js +66 -0
  9. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/0_10_0-alpha_0/s/e25f3b0b8b5c096acebf847d0a83ea62/lwr_profiler.js +68 -0
  10. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/0_10_0-alpha_0/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +21 -0
  11. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_9_9-alpha_8 → 0_10_0-alpha_0/lwr-error-shim.js} +1 -1
  12. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/0_10_0-alpha_0/lwr-loader-shim.bundle.js +1547 -0
  13. package/build/assets/amd/lwr-everywhere-debug.js +39 -27
  14. package/build/assets/amd/lwr-everywhere-min.js +1 -1
  15. package/build/assets/amd/lwr-everywhere.js +39 -27
  16. package/build/assets/core/lwr-everywhere-debug.js +36 -24
  17. package/build/assets/core/lwr-everywhere-min.js +1 -1
  18. package/build/assets/core/lwr-everywhere.js +36 -24
  19. package/build/assets/esm/lwr-everywhere-debug.js +1 -1
  20. package/build/assets/esm/lwr-everywhere-min.js +1 -1
  21. package/build/assets/esm/lwr-everywhere.js +1 -1
  22. package/build/modules/@salesforce/lds-default-luvio/lds-default-luvio.js +11 -7
  23. package/build/modules/lwr/everywhere/everywhere.js +6 -7
  24. package/build/modules/lwr/everywhereAmd/everywhereAmd.js +9 -11
  25. package/build/modules/lwr/everywhereEsm/everywhereEsm.js +1 -2
  26. package/build/modules/lwr/host/host.js +23 -27
  27. package/build/modules/lwr/setupLDS/network.js +9 -17
  28. package/build/modules/lwr/setupLDS/setupLDS.js +6 -4
  29. package/build/modules/lwr/setupNodeLDS/network.js +9 -17
  30. package/build/modules/lwr/setupNodeLDS/setupNodeLDS.js +3 -1
  31. package/build/modules/lwr/vault/vault.js +3 -1
  32. package/package.json +11 -8
  33. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/5a9af800813ae5f06687a5ebe9c0396e/config.js +0 -10
  34. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_9_9-alpha_8/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -14
  35. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/2_17_0/s/60dae7a83431c35c02c87ca8aaaa6044/lwc.js +0 -6244
  36. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/0_9_9-alpha_8/s/c538071acf5bde58e816967a14c465c3/lwr_everywhereAmd.js +0 -48
  37. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/0_9_9-alpha_8/s/6258bcb20cc2d5d6a9f3c5a6f9d0acaf/lwr_init.js +0 -58
  38. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/0_9_9-alpha_8/s/dfbc827104d50ff7d16b59c9d0e06aca/lwr_metrics.js +0 -56
  39. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/0_9_9-alpha_8/s/5a10236d8c52bc9f6dee22875cd7016d/lwr_profiler.js +0 -51
  40. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/0_9_9-alpha_8/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +0 -13
  41. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.js/v/0_9_9-alpha_8 +0 -311
  42. package/build/__generated_site_amd_modules__/en-US/index.html +0 -26
  43. package/build/__generated_site_amd_modules__/index.html +0 -26
@@ -1,48 +0,0 @@
1
- LWR.define("lwr/everywhereAmd/v/0_9_9-alpha_8", ["exports", "lwr/vault/v/0_9_9-alpha_8"], function(exports, _0_9_9Alpha_8) {
2
- "use strict";
3
- async function authFetch(url, accept = "javascript") {
4
- const authInfo = _0_9_9Alpha_8.getAuthInfo();
5
- if (authInfo) {
6
- return fetch(url, {
7
- headers: {
8
- Accept: `application/${accept}`,
9
- Authorization: `Bearer ${authInfo.access_token}`
10
- }
11
- });
12
- }
13
- return null;
14
- }
15
- function everywhereHooks(serviceAPI, mappingEndpoint, coreVersion) {
16
- serviceAPI.addLoaderPlugin({
17
- loadModule: async (url) => {
18
- return authFetch(url);
19
- },
20
- loadMapping: async (specifier) => {
21
- const res = await authFetch(`${mappingEndpoint}${encodeURIComponent(specifier)}`, "json");
22
- if (res && res.ok) {
23
- return res.json();
24
- }
25
- return null;
26
- },
27
- resolveModule: (specifier) => {
28
- if (specifier && !/\/v\/[^/]+?$/.test(specifier)) {
29
- return `${specifier}/v/${coreVersion}`;
30
- }
31
- return null;
32
- }
33
- });
34
- }
35
- function initAmd(services, mappingEndpoint, coreVersion) {
36
- if (mappingEndpoint.match(/\/v5\d\.0\//)) {
37
- everywhereHooks(services, mappingEndpoint, coreVersion);
38
- }
39
- }
40
- function authenticate(authInfo) {
41
- if (authInfo) {
42
- _0_9_9Alpha_8.setAuthInfo(authInfo);
43
- }
44
- }
45
- exports.authenticate = authenticate;
46
- exports.initAmd = initAmd;
47
- Object.defineProperty(exports, "__esModule", {value: true});
48
- });
@@ -1,58 +0,0 @@
1
- LWR.define("lwr/init/v/0_9_9-alpha_8", ["exports", "lwr/metrics/v/0_9_9-alpha_8", "lwr/profiler/v/0_9_9-alpha_8", "lwc/v/2_17_0"], function(exports, _0_9_9Alpha_8$1, _0_9_9Alpha_8, _2_17_0) {
2
- "use strict";
3
- function initializeWebComponent(elementName, Ctor) {
4
- return _2_17_0.createElement(elementName, {
5
- is: Ctor
6
- });
7
- }
8
- function toKebabCase(specifier) {
9
- return specifier.replace(/\/v\/[a-zA-Z0-9-_.]+$/, "").replace("/", "-").replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`);
10
- }
11
- const CAMEL_REGEX = /-([a-z])/g;
12
- function getPropFromAttrName(propName) {
13
- return propName.replace(CAMEL_REGEX, (g) => g[1].toUpperCase());
14
- }
15
- function init(rootModules) {
16
- if (typeof customElements !== "undefined" && typeof document !== "undefined") {
17
- const container = document.querySelector("[lwr-root]");
18
- rootModules.forEach(([moduleSpecifier, ctor]) => {
19
- const elementName = toKebabCase(moduleSpecifier);
20
- let el = document.body.querySelector(elementName);
21
- if (!el) {
22
- el = initializeWebComponent(elementName, ctor);
23
- if (container) {
24
- container.appendChild(el);
25
- } else {
26
- document.body.appendChild(el);
27
- }
28
- } else {
29
- const customElements2 = document.querySelectorAll(elementName);
30
- customElements2.forEach((customElement) => {
31
- const newElement = initializeWebComponent(elementName, ctor);
32
- for (const {
33
- name,
34
- value
35
- } of customElement.attributes) {
36
- newElement.setAttribute(name, value);
37
- const prop = getPropFromAttrName(name);
38
- if (prop in newElement) {
39
- newElement[prop] = value;
40
- }
41
- }
42
- while (customElement.childNodes.length > 0) {
43
- newElement.appendChild(customElement.childNodes[0]);
44
- }
45
- customElement.parentElement.replaceChild(newElement, customElement);
46
- });
47
- }
48
- });
49
- }
50
- _0_9_9Alpha_8.logOperationStart({
51
- id: _0_9_9Alpha_8$1.BOOTSTRAP_END
52
- });
53
- }
54
- exports.getPropFromAttrName = getPropFromAttrName;
55
- exports.init = init;
56
- exports.toKebabCase = toKebabCase;
57
- Object.defineProperty(exports, "__esModule", {value: true});
58
- });
@@ -1,56 +0,0 @@
1
- LWR.define("lwr/metrics/v/0_9_9-alpha_8", ["exports"], function(exports) {
2
- "use strict";
3
- const BOOTSTRAP_PREFIX = "lwr.bootstrap.";
4
- const BOOTSTRAP_END = `${BOOTSTRAP_PREFIX}end`;
5
- const BOOTSTRAP_ERROR = `${BOOTSTRAP_PREFIX}error`;
6
- const BOOTSTRAP_ERROR_COUNT = `${BOOTSTRAP_ERROR}.count`;
7
- const BOOTSTRAP_DURATION = `${BOOTSTRAP_PREFIX}duration`;
8
- const LOADER_PREFIX = "lwr.loader.";
9
- const MODULE_DEFINE = `${LOADER_PREFIX}module.define`;
10
- const MODULE_DEFINE_COUNT = `${MODULE_DEFINE}.count`;
11
- const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
12
- const MODULE_FETCH_COUNT = `${MODULE_FETCH}.count`;
13
- const MODULE_FETCH_DURATION = `${MODULE_FETCH}.duration`;
14
- const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
15
- const MODULE_ERROR_COUNT = `${MODULE_ERROR}.count`;
16
- const MAPPINGS_FETCH = `${LOADER_PREFIX}mappings.fetch`;
17
- const MAPPINGS_FETCH_COUNT = `${MAPPINGS_FETCH}.count`;
18
- const MAPPINGS_FETCH_DURATION = `${MAPPINGS_FETCH}.duration`;
19
- const MAPPINGS_ERROR = `${LOADER_PREFIX}mappings.error`;
20
- const MAPPINGS_ERROR_COUNT = `${MAPPINGS_ERROR}.count`;
21
- const ROUTER_PREFIX = "lwr.router.";
22
- const ROUTER_NAV = `${ROUTER_PREFIX}navigate`;
23
- const ROUTER_NAV_COUNT = `${ROUTER_NAV}.count`;
24
- const ROUTER_NAV_DURATION = `${ROUTER_NAV}.duration`;
25
- const ROUTER_VIEW = `${ROUTER_PREFIX}view`;
26
- const ROUTER_VIEW_DURATION = `${ROUTER_VIEW}.duration`;
27
- const ROUTER_ERROR = `${ROUTER_PREFIX}error`;
28
- const ROUTER_ERROR_COUNT = `${ROUTER_ERROR}.count`;
29
- exports.BOOTSTRAP_DURATION = BOOTSTRAP_DURATION;
30
- exports.BOOTSTRAP_END = BOOTSTRAP_END;
31
- exports.BOOTSTRAP_ERROR = BOOTSTRAP_ERROR;
32
- exports.BOOTSTRAP_ERROR_COUNT = BOOTSTRAP_ERROR_COUNT;
33
- exports.BOOTSTRAP_PREFIX = BOOTSTRAP_PREFIX;
34
- exports.LOADER_PREFIX = LOADER_PREFIX;
35
- exports.MAPPINGS_ERROR = MAPPINGS_ERROR;
36
- exports.MAPPINGS_ERROR_COUNT = MAPPINGS_ERROR_COUNT;
37
- exports.MAPPINGS_FETCH = MAPPINGS_FETCH;
38
- exports.MAPPINGS_FETCH_COUNT = MAPPINGS_FETCH_COUNT;
39
- exports.MAPPINGS_FETCH_DURATION = MAPPINGS_FETCH_DURATION;
40
- exports.MODULE_DEFINE = MODULE_DEFINE;
41
- exports.MODULE_DEFINE_COUNT = MODULE_DEFINE_COUNT;
42
- exports.MODULE_ERROR = MODULE_ERROR;
43
- exports.MODULE_ERROR_COUNT = MODULE_ERROR_COUNT;
44
- exports.MODULE_FETCH = MODULE_FETCH;
45
- exports.MODULE_FETCH_COUNT = MODULE_FETCH_COUNT;
46
- exports.MODULE_FETCH_DURATION = MODULE_FETCH_DURATION;
47
- exports.ROUTER_ERROR = ROUTER_ERROR;
48
- exports.ROUTER_ERROR_COUNT = ROUTER_ERROR_COUNT;
49
- exports.ROUTER_NAV = ROUTER_NAV;
50
- exports.ROUTER_NAV_COUNT = ROUTER_NAV_COUNT;
51
- exports.ROUTER_NAV_DURATION = ROUTER_NAV_DURATION;
52
- exports.ROUTER_PREFIX = ROUTER_PREFIX;
53
- exports.ROUTER_VIEW = ROUTER_VIEW;
54
- exports.ROUTER_VIEW_DURATION = ROUTER_VIEW_DURATION;
55
- Object.defineProperty(exports, "__esModule", {value: true});
56
- });
@@ -1,51 +0,0 @@
1
- LWR.define("lwr/profiler/v/0_9_9-alpha_8", ["exports"], function(exports) {
2
- "use strict";
3
- var Phase;
4
- (function(Phase2) {
5
- Phase2[Phase2["Start"] = 0] = "Start";
6
- Phase2[Phase2["End"] = 1] = "End";
7
- })(Phase || (Phase = {}));
8
- let customDispatcher;
9
- function attachDispatcher(dispatcher) {
10
- customDispatcher = dispatcher;
11
- }
12
- const perf = globalThis.performance;
13
- const isPerfSupported = typeof perf !== "undefined" && typeof perf.mark === "function" && typeof perf.clearMarks === "function" && typeof perf.measure === "function" && typeof perf.clearMeasures === "function";
14
- function logOperationStart({
15
- id,
16
- specifier
17
- }) {
18
- if (customDispatcher) {
19
- customDispatcher({
20
- id,
21
- phase: Phase.Start,
22
- specifier
23
- });
24
- } else if (isPerfSupported) {
25
- perf.mark(id + (specifier ? `.${specifier}` : ""));
26
- }
27
- }
28
- function logOperationEnd({
29
- id,
30
- specifier
31
- }) {
32
- if (customDispatcher) {
33
- customDispatcher({
34
- id,
35
- phase: Phase.End,
36
- specifier
37
- });
38
- } else if (isPerfSupported) {
39
- const suffix = specifier ? `.${specifier}` : "";
40
- const markName = id + suffix;
41
- const measureName = `${id}.duration${suffix}`;
42
- perf.measure(measureName, markName);
43
- perf.clearMarks(markName);
44
- perf.clearMeasures(measureName);
45
- }
46
- }
47
- exports.attachDispatcher = attachDispatcher;
48
- exports.logOperationEnd = logOperationEnd;
49
- exports.logOperationStart = logOperationStart;
50
- Object.defineProperty(exports, "__esModule", {value: true});
51
- });
@@ -1,13 +0,0 @@
1
- LWR.define("lwr/vault/v/0_9_9-alpha_8", ["exports"], function(exports) {
2
- "use strict";
3
- let authInfo;
4
- function getAuthInfo() {
5
- return authInfo;
6
- }
7
- function setAuthInfo(ai) {
8
- authInfo = ai;
9
- }
10
- exports.getAuthInfo = getAuthInfo;
11
- exports.setAuthInfo = setAuthInfo;
12
- Object.defineProperty(exports, "__esModule", {value: true});
13
- });
@@ -1,311 +0,0 @@
1
- /**
2
- * Copyright (c) 2021, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: MIT
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
- */
7
- /* LWR Module Loader Shim v0.9.9-alpha.8 */
8
- (function () {
9
- 'use strict';
10
-
11
- // Bootstrap / shim
12
- const BOOTSTRAP_PREFIX = 'lwr.bootstrap.';
13
- const BOOTSTRAP_ERROR = `${BOOTSTRAP_PREFIX}error`;
14
-
15
- var Phase;
16
-
17
- (function (Phase) {
18
- Phase[Phase["Start"] = 0] = "Start";
19
- Phase[Phase["End"] = 1] = "End";
20
- })(Phase || (Phase = {}));
21
-
22
- // Attach a custom dispatcher
23
- let customDispatcher;
24
- function attachDispatcher(dispatcher) {
25
- customDispatcher = dispatcher;
26
- } // Check if the Performance API is available
27
- // e.g. JSDom (used in Jest) doesn't implement these
28
-
29
- const perf = globalThis.performance;
30
- const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function'; // For marking request metrics
31
- // Fallback to the Performance API if there is no custom dispatcher
32
-
33
- function logOperationStart({
34
- id,
35
- specifier
36
- }) {
37
- if (customDispatcher) {
38
- customDispatcher({
39
- id,
40
- phase: Phase.Start,
41
- specifier
42
- });
43
- } else if (isPerfSupported) {
44
- perf.mark(id + (specifier ? `.${specifier}` : ''));
45
- }
46
- } // For measuring duration metrics
47
- // Fallback to the Performance API if there is no custom dispatcher
48
-
49
- /* istanbul ignore next */
50
-
51
- function logOperationEnd({
52
- id,
53
- specifier
54
- }) {
55
- if (customDispatcher) {
56
- customDispatcher({
57
- id,
58
- phase: Phase.End,
59
- specifier
60
- });
61
- } else if (isPerfSupported) {
62
- const suffix = specifier ? `.${specifier}` : '';
63
- const markName = id + suffix;
64
- const measureName = `${id}.duration${suffix}`;
65
- perf.measure(measureName, markName); // Clear the created mark and measure to avoid filling the performance entry buffer
66
- // Even if they get deleted, existing PerformanceObservers preserve copies of the entries
67
-
68
- perf.clearMarks(markName);
69
- perf.clearMeasures(measureName);
70
- }
71
- }
72
-
73
- function createLoader(name, definition, config, externalModules) {
74
- if (!definition || typeof definition[2] !== 'function') {
75
- throw new Error(`Expected loader with specifier "${name}" to be a module`);
76
- }
77
- // Create a Loader instance
78
- const exports = {};
79
- definition[2].call(null, exports);
80
- const { Loader } = exports;
81
- const loader = new Loader(config);
82
- if (externalModules && externalModules.length) {
83
- loader.registerExternalModules(externalModules);
84
- }
85
- // Define the loader module with public API: { define, load, services }
86
- const exporter = (exports) => {
87
- Object.assign(exports, {
88
- define: loader.define.bind(loader),
89
- load: loader.load.bind(loader),
90
- services: loader.services,
91
- });
92
- };
93
- loader.define(name, ['exports'], exporter);
94
- return loader;
95
- }
96
-
97
- const REQUIRED_MODULES_TIMEOUT = 300 * 1000;
98
-
99
- // Check for errors with autoBoot and customInit
100
- function validatePreInit(autoBoot, customInit) {
101
- // If autoBoot === false, there must be a customInit hook
102
- if (!autoBoot && !customInit) {
103
- throw new Error('The customInit hook is required when autoBoot is false');
104
- }
105
- // If autoBoot === true, there must NOT be a customInit hook
106
- if (autoBoot && customInit) {
107
- throw new Error('The customInit hook must not be defined when autoBoot is true');
108
- }
109
- }
110
- // Process the customInit hook
111
- function customInit(config, initializeApp, define, onBootstrapError) {
112
- // Validate config
113
- const { autoBoot, customInit } = config;
114
- validatePreInit(autoBoot, customInit);
115
- // Set up arguments and call the customInit hook, if available
116
- if (customInit) {
117
- const lwr = {
118
- initializeApp,
119
- define,
120
- onBootstrapError,
121
- attachDispatcher,
122
- };
123
- customInit(lwr, config);
124
- }
125
- }
126
-
127
- /* global document */
128
- /* eslint-disable lwr/no-unguarded-apis */
129
- const hasSetTimeout = typeof setTimeout === 'function';
130
- const hasConsole = typeof console !== 'undefined';
131
- /* eslint-enable lwr/no-unguarded-apis */
132
- class LoaderShim {
133
- constructor(global) {
134
- this.defineCache = {};
135
- this.orderedDefs = [];
136
- // Start watchdog timer
137
- if (hasSetTimeout) {
138
- this.watchdogTimerId = this.startWatchdogTimer();
139
- }
140
- // Parse configuration
141
- this.global = global;
142
- this.config = global.LWR;
143
- this.loaderSpecifier = 'lwr/loader/v/0_9_9-alpha_8';
144
- // Set up error handler
145
- this.errorHandler = this.config.onError;
146
- // Set up the temporary LWR.define function and customInit hook
147
- const tempDefine = this.tempDefine.bind(this);
148
- global.LWR.define = tempDefine;
149
- this.bootReady = this.config.autoBoot;
150
- try {
151
- customInit(Object.freeze(this.config), this.postCustomInit.bind(this), tempDefine, (e) => {
152
- // customInit handlers can overwrite
153
- // the error handler with onBootstrapError
154
- this.errorHandler = e;
155
- });
156
- }
157
- catch (e) {
158
- this.enterErrorState(e);
159
- }
160
- }
161
- // Return true if the app can be initialized
162
- canInit() {
163
- // Initialize the app if:
164
- // - bootReady: autoBoot is on OR customInit has finished
165
- // - all required modules are defined
166
- const allDefined = this.config.requiredModules.every((m) => this.orderedDefs.includes(m));
167
- return this.bootReady && allDefined;
168
- }
169
- /**
170
- * Create a temporary LWR.define() function which captures all
171
- * calls that occur BEFORE the full loader module is available
172
- *
173
- * Each call to LWR.define() is stored in 2 ways:
174
- * - in a map as [moduleName, arguments] pairs
175
- * - each moduleName is pushed onto an array, to preserve
176
- * the order in which the modules were defined
177
- */
178
- tempDefine(...args) {
179
- // Cache the incoming module
180
- const moduleName = args[0];
181
- this.defineCache[moduleName] = args;
182
- this.orderedDefs.push(moduleName);
183
- if (this.canInit()) {
184
- if (hasSetTimeout) {
185
- // requiredModules are defined, clear watchdog timer
186
- // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
187
- clearTimeout(this.watchdogTimerId);
188
- }
189
- this.initApp();
190
- }
191
- }
192
- // Called by the customInit hook via lwr.initializeApp()
193
- postCustomInit() {
194
- this.bootReady = true;
195
- if (this.canInit()) {
196
- this.initApp();
197
- }
198
- }
199
- // Create the loader and initialize the application
200
- initApp() {
201
- try {
202
- const loaderConfig = {
203
- endpoints: this.config.endpoints,
204
- baseUrl: this.config.baseUrl,
205
- profiler: { logOperationStart, logOperationEnd },
206
- // TODO: can be removed following https://github.com/salesforce/lwr/issues/1087
207
- appMetadata: {
208
- appId: this.config.appId,
209
- bootstrapModule: this.config.bootstrapModule,
210
- rootComponent: this.config.rootComponent,
211
- rootComponents: this.config.rootComponents,
212
- },
213
- };
214
- const loader = createLoader(this.loaderSpecifier, this.defineCache[this.loaderSpecifier], loaderConfig, this.config.preloadModules);
215
- this.createProfilerModule(loader);
216
- this.mountApp(loader);
217
- }
218
- catch (e) {
219
- this.enterErrorState(e);
220
- }
221
- }
222
- waitForDOMContentLoaded() {
223
- // eslint-disable-next-line lwr/no-unguarded-apis
224
- if (typeof document === undefined) {
225
- return Promise.resolve();
226
- }
227
- // Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
228
- // eslint-disable-next-line lwr/no-unguarded-apis
229
- if (document.readyState === 'interactive' || document.readyState === 'complete') {
230
- return Promise.resolve();
231
- }
232
- return new Promise((resolve) => {
233
- // eslint-disable-next-line lwr/no-unguarded-apis
234
- document.addEventListener('DOMContentLoaded', () => {
235
- resolve();
236
- });
237
- });
238
- }
239
- // Create a module out of the profiler
240
- // Note: The profiler is also available as a module through lwc module resolution (see package.json)
241
- createProfilerModule(loader) {
242
- const exporter = (exports) => {
243
- Object.assign(exports, { logOperationStart, logOperationEnd });
244
- };
245
- loader.define('lwr/profiler/v/0_9_9-alpha_8', ['exports'], exporter);
246
- }
247
- // Set up the application globals, import map, root custom element...
248
- mountApp(loader) {
249
- const { bootstrapModule, rootComponent, rootComponents, ssrProps, endpoints, imports, index } = this.config;
250
- // Set global LWR.define to loader.define
251
- this.global.LWR = Object.freeze({
252
- define: loader.define.bind(loader),
253
- rootComponent,
254
- rootComponents,
255
- ssrProps,
256
- endpoints,
257
- imports: imports || {},
258
- index: index || {},
259
- });
260
- // Redefine all modules in the temporary cache
261
- this.orderedDefs.forEach((specifier) => {
262
- if (specifier !== this.loaderSpecifier) {
263
- loader.define(...this.defineCache[specifier]);
264
- }
265
- });
266
- // by default, app initialization is gated on waiting for document to be parsed (via DOMContentLoaded)
267
- const { disableInitDefer } = this.config;
268
- // Load the import mappings and application bootstrap module
269
- loader
270
- .registerImportMappings({ imports, index }, [bootstrapModule, rootComponent])
271
- .then(() => {
272
- if (!disableInitDefer) {
273
- return this.waitForDOMContentLoaded();
274
- }
275
- })
276
- .then(() => loader.load(bootstrapModule))
277
- .catch((reason) => {
278
- this.enterErrorState(new Error(`Application ${rootComponent} could not be loaded: ${reason}`));
279
- });
280
- }
281
- // Trigger bootstrap error state, and call error handler if registered
282
- enterErrorState(error) {
283
- logOperationStart({ id: BOOTSTRAP_ERROR });
284
- if (this.errorHandler) {
285
- this.errorHandler(error);
286
- }
287
- else {
288
- if (hasConsole) {
289
- // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
290
- console.error(`An error occurred during LWR bootstrap. ${error.message}`, error.stack);
291
- }
292
- }
293
- }
294
- // eslint-disable-next-line no-undef, lwr/no-unguarded-apis
295
- startWatchdogTimer() {
296
- // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
297
- return setTimeout(() => {
298
- this.enterErrorState(new Error('Failed to load required modules - timed out'));
299
- }, REQUIRED_MODULES_TIMEOUT);
300
- }
301
- }
302
-
303
- // The loader module is ALWAYS required
304
- const GLOBAL = globalThis;
305
- GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
306
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_9_9-alpha_8') < 0) {
307
- GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_9_9-alpha_8');
308
- }
309
- new LoaderShim(GLOBAL);
310
-
311
- }());
@@ -1,26 +0,0 @@
1
-
2
- <!DOCTYPE html>
3
- <html lang="en">
4
- <head>
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
7
- <title>LWR App</title>
8
- </head>
9
- <body class="wrapper">
10
- <lwr-everywhere-amd></lwr-everywhere-amd>
11
- </body>
12
- <script type="application/javascript" src="/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-%2F-/s/5a9af800813ae5f06687a5ebe9c0396e/config.js"></script>
13
- <script type="application/javascript" src="/1/resource/amd/lwr-loader-shim.js%2Fv%2F0_9_9-alpha_8"></script>
14
- <script type="application/javascript">/**
15
- * Copyright (c) 2021, salesforce.com, inc.
16
- * All rights reserved.
17
- * SPDX-License-Identifier: MIT
18
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
19
- */
20
- /* LWR Error Shim v0.9.9-alpha.8 */
21
- !function(){"use strict";if(!(globalThis.LWR&&globalThis.LWR.define)){const o=new Error("The LWR application failed to bootstrap");if(!globalThis.LWR||!globalThis.LWR.onError)throw o;globalThis.LWR.onError(o)}}();
22
- </script>
23
- <script type="application/javascript" src="/1/module/amd/1/l/en-US/mi/lwr%2Floader%2Fv%2F0_9_9-alpha_8/s/b234adc35388b40b104bed6bf73710c1/lwr_loader.js"></script>
24
- <script type="application/javascript" src="/1/module/amd/1/l/en-US/mi/%40lwrjs%2Fapp-service%2Famd-bootstrap%2Fmodule%2Famd%2Fv%2F0_9_9-alpha_8/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js"></script>
25
- <script type="application/javascript" async src="/1/module/amd/1/l/en-US/mi/lwr%2FeverywhereAmd%2Fv%2F0_9_9-alpha_8/s/c538071acf5bde58e816967a14c465c3/lwr_everywhereAmd.js"></script>
26
- </html>
@@ -1,26 +0,0 @@
1
-
2
- <!DOCTYPE html>
3
- <html lang="en">
4
- <head>
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
7
- <title>LWR App</title>
8
- </head>
9
- <body class="wrapper">
10
- <lwr-everywhere-amd></lwr-everywhere-amd>
11
- </body>
12
- <script type="application/javascript" src="/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-%2F-/s/5a9af800813ae5f06687a5ebe9c0396e/config.js"></script>
13
- <script type="application/javascript" src="/1/resource/amd/lwr-loader-shim.js%2Fv%2F0_9_9-alpha_8"></script>
14
- <script type="application/javascript">/**
15
- * Copyright (c) 2021, salesforce.com, inc.
16
- * All rights reserved.
17
- * SPDX-License-Identifier: MIT
18
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
19
- */
20
- /* LWR Error Shim v0.9.9-alpha.8 */
21
- !function(){"use strict";if(!(globalThis.LWR&&globalThis.LWR.define)){const o=new Error("The LWR application failed to bootstrap");if(!globalThis.LWR||!globalThis.LWR.onError)throw o;globalThis.LWR.onError(o)}}();
22
- </script>
23
- <script type="application/javascript" src="/1/module/amd/1/l/en-US/mi/lwr%2Floader%2Fv%2F0_9_9-alpha_8/s/b234adc35388b40b104bed6bf73710c1/lwr_loader.js"></script>
24
- <script type="application/javascript" src="/1/module/amd/1/l/en-US/mi/%40lwrjs%2Fapp-service%2Famd-bootstrap%2Fmodule%2Famd%2Fv%2F0_9_9-alpha_8/s/c40e6caf07454ce13961de8ca76ab7f0/@lwrjs_app-service_amd-bootstrap_module_amd.js"></script>
25
- <script type="application/javascript" async src="/1/module/amd/1/l/en-US/mi/lwr%2FeverywhereAmd%2Fv%2F0_9_9-alpha_8/s/c538071acf5bde58e816967a14c465c3/lwr_everywhereAmd.js"></script>
26
- </html>