@lwrjs/loader 0.24.2 → 0.24.4

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 (47) hide show
  1. package/build/assets/prod/lwr-error-shim.js +1 -1
  2. package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +23 -10
  3. package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +3 -3
  4. package/build/assets/prod/lwr-loader-shim-legacy.js +5 -5
  5. package/build/assets/prod/lwr-loader-shim.bundle.js +23 -10
  6. package/build/assets/prod/lwr-loader-shim.bundle.min.js +3 -3
  7. package/build/assets/prod/lwr-loader-shim.js +5 -5
  8. package/build/cjs/index.cjs +51 -36
  9. package/build/cjs/modules/lwr/esmLoader/esmLoader.cjs +31 -22
  10. package/build/cjs/modules/lwr/esmLoader/importResolver.cjs +24 -9
  11. package/build/cjs/modules/lwr/esmLoader/importResolverLegacy.cjs +24 -7
  12. package/build/cjs/modules/lwr/loader/constants/constants.cjs +19 -7
  13. package/build/cjs/modules/lwr/loader/errors/messages.cjs +14 -18
  14. package/build/cjs/modules/lwr/loader/errors/reportError.cjs +15 -20
  15. package/build/cjs/modules/lwr/loader/errors/utils.cjs +16 -4
  16. package/build/cjs/modules/lwr/loader/hooks/moduleInvalidation.cjs +17 -21
  17. package/build/cjs/modules/lwr/loader/hooks/resolveAndLoadHook.cjs +37 -37
  18. package/build/cjs/modules/lwr/loader/moduleRegistry/importMetadataResolver.cjs +48 -27
  19. package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +131 -77
  20. package/build/cjs/modules/lwr/loader/moduleRegistry/scriptLoad.cjs +15 -19
  21. package/build/cjs/modules/lwr/loader/utils/dom.cjs +16 -4
  22. package/build/cjs/modules/lwr/loader/utils/url.cjs +20 -25
  23. package/build/cjs/modules/lwr/loader/utils/validation.cjs +21 -7
  24. package/build/cjs/modules/lwr/loader/validateLoadSpecifier.cjs +17 -5
  25. package/build/cjs/modules/lwr/loaderLegacy/constants/constants.cjs +19 -7
  26. package/build/cjs/modules/lwr/loaderLegacy/errors/messages.cjs +14 -18
  27. package/build/cjs/modules/lwr/loaderLegacy/errors/reportError.cjs +15 -20
  28. package/build/cjs/modules/lwr/loaderLegacy/errors/utils.cjs +16 -4
  29. package/build/cjs/modules/lwr/loaderLegacy/hooks/moduleInvalidation.cjs +17 -21
  30. package/build/cjs/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.cjs +37 -37
  31. package/build/cjs/modules/lwr/loaderLegacy/importMap/dom.cjs +24 -25
  32. package/build/cjs/modules/lwr/loaderLegacy/importMap/importMap.cjs +31 -25
  33. package/build/cjs/modules/lwr/loaderLegacy/importMap/importMapResolver.cjs +16 -19
  34. package/build/cjs/modules/lwr/loaderLegacy/importMap/utils.cjs +14 -18
  35. package/build/cjs/modules/lwr/loaderLegacy/importResolver/importResolver.cjs +14 -2
  36. package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +113 -77
  37. package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/scriptLoad.cjs +15 -19
  38. package/build/cjs/modules/lwr/loaderLegacy/utils/dom.cjs +16 -4
  39. package/build/cjs/modules/lwr/loaderLegacy/utils/url.cjs +20 -25
  40. package/build/cjs/modules/lwr/loaderLegacy/utils/validation.cjs +17 -19
  41. package/build/cjs/types.cjs +14 -2
  42. package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
  43. package/build/modules/lwr/loader/hooks/resolveAndLoadHook.js +15 -3
  44. package/build/modules/lwr/loader/loader.js +18 -5
  45. package/build/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.js +15 -3
  46. package/build/modules/lwr/loaderLegacy/loaderLegacy.js +18 -5
  47. package/package.json +7 -7
@@ -1,34 +1,30 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
5
  var __export = (target, all) => {
9
6
  for (var name in all)
10
- __defProp(target, name, {get: all[name], enumerable: true});
7
+ __defProp(target, name, { get: all[name], enumerable: true });
11
8
  };
12
- var __exportStar = (target, module2, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && key !== "default")
16
- __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
14
  }
18
- return target;
19
- };
20
- var __toModule = (module2) => {
21
- return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
15
+ return to;
22
16
  };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
18
 
24
19
  // packages/@lwrjs/loader/src/modules/lwr/loaderLegacy/utils/validation.ts
25
- __markAsModule(exports);
26
- __export(exports, {
20
+ var validation_exports = {};
21
+ __export(validation_exports, {
27
22
  validateAndConvertImportMapUpdate: () => validateAndConvertImportMapUpdate,
28
23
  validateMappingUri: () => validateMappingUri,
29
24
  validateSpecifier: () => validateSpecifier
30
25
  });
31
- var import_dom = __toModule(require("../utils/dom.cjs"));
26
+ module.exports = __toCommonJS(validation_exports);
27
+ var import_dom = require("../utils/dom.cjs");
32
28
  function validateMappingUri(uri, specifier) {
33
29
  const lowerUri = uri.toLowerCase();
34
30
  if (lowerUri.startsWith("blob:")) {
@@ -67,7 +63,9 @@ function validateAndConvertImportMapUpdate(update) {
67
63
  validateSpecifier(moduleName);
68
64
  if (moduleName in convertedImports) {
69
65
  if (import_dom.hasConsole) {
70
- console.warn(`LWR.importMap(): duplicate module "${moduleName}" \u2014 already mapped to "${convertedImports[moduleName]}", ignoring mapping to "${moduleScriptURL}"`);
66
+ console.warn(
67
+ `LWR.importMap(): duplicate module "${moduleName}" \u2014 already mapped to "${convertedImports[moduleName]}", ignoring mapping to "${moduleScriptURL}"`
68
+ );
71
69
  }
72
70
  } else {
73
71
  convertedImports[moduleName] = moduleScriptURL;
@@ -1,5 +1,17 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
3
14
 
4
15
  // packages/@lwrjs/loader/src/types.ts
5
- __markAsModule(exports);
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR ESM Module Loader v0.24.2 */
7
+ /* LWR ESM Module Loader v0.24.4 */
8
8
  function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
9
9
 
10
10
 
@@ -10,6 +10,12 @@ if (hasDocument) {
10
10
  lastWindowError = evt.error;
11
11
  });
12
12
  }
13
+ // Clear via a function so `lastWindowError` stays in the "assigned in a closure" category (like the
14
+ // listener above): that keeps its declared `null | Error` type at the check below and lets us reset
15
+ // the latch around each eval without leaving flow analysis thinking it is always null.
16
+ function resetLastWindowError() {
17
+ lastWindowError = null;
18
+ }
13
19
  // eslint-disable-next-line lwr/no-unguarded-apis
14
20
  if (process.env.NODE_ENV !== 'production') {
15
21
  if (!hasSetTimeout && hasConsole) {
@@ -52,6 +58,12 @@ export async function evaluateLoadHookResponse(response, id) {
52
58
  throw new LoaderError(FAIL_LOAD, [`empty code for ${id}`]);
53
59
  }
54
60
  code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
61
+ // Reset before eval so we only attribute window errors raised synchronously by THIS
62
+ // module's evaluation, and so a stale error from an earlier point in the page's life
63
+ // cannot poison this (or any subsequent) load. There is no `await` between here and the
64
+ // check below, so on the single-threaded runtime only a synchronous eval-time error can
65
+ // be observed; any later async error is cleared by the next load's reset.
66
+ resetLastWindowError();
55
67
  try {
56
68
  // TODO eval source maps for debugging
57
69
  eval(trusted.createScript(code));
@@ -65,9 +77,9 @@ export async function evaluateLoadHookResponse(response, id) {
65
77
  throw new LoaderError(FAIL_LOAD, [`"${id}": ${e instanceof Error ? e.message : String(e)}`]);
66
78
  }
67
79
  if (lastWindowError) {
68
- throw new LoaderError(FAIL_LOAD, [
69
- `"${id}": window error ${lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError)}`,
70
- ]);
80
+ const message = lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError);
81
+ resetLastWindowError(); // clear on the failure path too, so it can't poison later loads
82
+ throw new LoaderError(FAIL_LOAD, [`"${id}": window error ${message}`]);
71
83
  }
72
84
  return true;
73
85
  });
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Module Loader v0.24.2 */
7
+ /* LWR Module Loader v0.24.4 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -721,7 +721,7 @@ try {
721
721
  // swallow
722
722
  }
723
723
  const trusted = createPolicy('trusted', policyOptions);
724
- /*! version: 0.29.2 */
724
+ /*! version: 0.29.3 */
725
725
 
726
726
  /* global console,process */
727
727
 
@@ -732,6 +732,12 @@ if (hasDocument) {
732
732
  lastWindowError = evt.error;
733
733
  });
734
734
  }
735
+ // Clear via a function so `lastWindowError` stays in the "assigned in a closure" category (like the
736
+ // listener above): that keeps its declared `null | Error` type at the check below and lets us reset
737
+ // the latch around each eval without leaving flow analysis thinking it is always null.
738
+ function resetLastWindowError() {
739
+ lastWindowError = null;
740
+ }
735
741
 
736
742
  // eslint-disable-next-line lwr/no-unguarded-apis
737
743
  if (process.env.NODE_ENV !== 'production') {
@@ -789,6 +795,12 @@ async function evaluateLoadHookResponse(response, id) {
789
795
  }
790
796
 
791
797
  code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
798
+ // Reset before eval so we only attribute window errors raised synchronously by THIS
799
+ // module's evaluation, and so a stale error from an earlier point in the page's life
800
+ // cannot poison this (or any subsequent) load. There is no `await` between here and the
801
+ // check below, so on the single-threaded runtime only a synchronous eval-time error can
802
+ // be observed; any later async error is cleared by the next load's reset.
803
+ resetLastWindowError();
792
804
  try {
793
805
  // TODO eval source maps for debugging
794
806
  eval(trusted.createScript(code) );
@@ -802,9 +814,10 @@ async function evaluateLoadHookResponse(response, id) {
802
814
  }
803
815
 
804
816
  if (lastWindowError) {
805
- throw new LoaderError(FAIL_LOAD, [
806
- `"${id}": window error ${lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError)}`,
807
- ]);
817
+ const message =
818
+ lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError);
819
+ resetLastWindowError(); // clear on the failure path too, so it can't poison later loads
820
+ throw new LoaderError(FAIL_LOAD, [`"${id}": window error ${message}`]);
808
821
  }
809
822
  return true;
810
823
  });
@@ -10,6 +10,12 @@ if (hasDocument) {
10
10
  lastWindowError = evt.error;
11
11
  });
12
12
  }
13
+ // Clear via a function so `lastWindowError` stays in the "assigned in a closure" category (like the
14
+ // listener above): that keeps its declared `null | Error` type at the check below and lets us reset
15
+ // the latch around each eval without leaving flow analysis thinking it is always null.
16
+ function resetLastWindowError() {
17
+ lastWindowError = null;
18
+ }
13
19
  // eslint-disable-next-line lwr/no-unguarded-apis
14
20
  if (process.env.NODE_ENV !== 'production') {
15
21
  if (!hasSetTimeout && hasConsole) {
@@ -52,6 +58,12 @@ export async function evaluateLoadHookResponse(response, id) {
52
58
  throw new LoaderError(FAIL_LOAD, [`empty code for ${id}`]);
53
59
  }
54
60
  code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
61
+ // Reset before eval so we only attribute window errors raised synchronously by THIS
62
+ // module's evaluation, and so a stale error from an earlier point in the page's life
63
+ // cannot poison this (or any subsequent) load. There is no `await` between here and the
64
+ // check below, so on the single-threaded runtime only a synchronous eval-time error can
65
+ // be observed; any later async error is cleared by the next load's reset.
66
+ resetLastWindowError();
55
67
  try {
56
68
  // TODO eval source maps for debugging
57
69
  eval(trusted.createScript(code));
@@ -65,9 +77,9 @@ export async function evaluateLoadHookResponse(response, id) {
65
77
  throw new LoaderError(FAIL_LOAD, [`"${id}": ${e instanceof Error ? e.message : String(e)}`]);
66
78
  }
67
79
  if (lastWindowError) {
68
- throw new LoaderError(FAIL_LOAD, [
69
- `"${id}": window error ${lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError)}`,
70
- ]);
80
+ const message = lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError);
81
+ resetLastWindowError(); // clear on the failure path too, so it can't poison later loads
82
+ throw new LoaderError(FAIL_LOAD, [`"${id}": window error ${message}`]);
71
83
  }
72
84
  return true;
73
85
  });
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: MIT
5
5
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
6
  */
7
- /* LWR Legacy Module Loader v0.24.2 */
7
+ /* LWR Legacy Module Loader v0.24.4 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -425,7 +425,7 @@ try {
425
425
  // swallow
426
426
  }
427
427
  const trusted = createPolicy('trusted', policyOptions);
428
- /*! version: 0.29.2 */
428
+ /*! version: 0.29.3 */
429
429
 
430
430
  /* global console,process */
431
431
 
@@ -436,6 +436,12 @@ if (hasDocument) {
436
436
  lastWindowError = evt.error;
437
437
  });
438
438
  }
439
+ // Clear via a function so `lastWindowError` stays in the "assigned in a closure" category (like the
440
+ // listener above): that keeps its declared `null | Error` type at the check below and lets us reset
441
+ // the latch around each eval without leaving flow analysis thinking it is always null.
442
+ function resetLastWindowError() {
443
+ lastWindowError = null;
444
+ }
439
445
 
440
446
  // eslint-disable-next-line lwr/no-unguarded-apis
441
447
  if (process.env.NODE_ENV !== 'production') {
@@ -493,6 +499,12 @@ async function evaluateLoadHookResponse(response, id) {
493
499
  }
494
500
 
495
501
  code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
502
+ // Reset before eval so we only attribute window errors raised synchronously by THIS
503
+ // module's evaluation, and so a stale error from an earlier point in the page's life
504
+ // cannot poison this (or any subsequent) load. There is no `await` between here and the
505
+ // check below, so on the single-threaded runtime only a synchronous eval-time error can
506
+ // be observed; any later async error is cleared by the next load's reset.
507
+ resetLastWindowError();
496
508
  try {
497
509
  // TODO eval source maps for debugging
498
510
  eval(trusted.createScript(code) );
@@ -506,9 +518,10 @@ async function evaluateLoadHookResponse(response, id) {
506
518
  }
507
519
 
508
520
  if (lastWindowError) {
509
- throw new LoaderError(FAIL_LOAD, [
510
- `"${id}": window error ${lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError)}`,
511
- ]);
521
+ const message =
522
+ lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError);
523
+ resetLastWindowError(); // clear on the failure path too, so it can't poison later loads
524
+ throw new LoaderError(FAIL_LOAD, [`"${id}": window error ${message}`]);
512
525
  }
513
526
  return true;
514
527
  });
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.24.2",
8
+ "version": "0.24.4",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -60,17 +60,17 @@
60
60
  "build": "yarn build:ts && yarn build:error-shim && yarn build:shim && yarn build:loader && yarn build:shim:bundle && yarn build:shim:bundle:minify"
61
61
  },
62
62
  "devDependencies": {
63
- "@locker/trusted-types": "0.29.2",
64
- "@lwrjs/diagnostics": "0.24.2",
65
- "@lwrjs/types": "0.24.2",
63
+ "@locker/trusted-types": "0.29.3",
64
+ "@lwrjs/diagnostics": "0.24.4",
65
+ "@lwrjs/types": "0.24.4",
66
66
  "@rollup/plugin-node-resolve": "^15.2.3",
67
67
  "@rollup/plugin-sucrase": "^5.1.0",
68
68
  "@rollup/plugin-terser": "^0.4.4",
69
69
  "rollup": "^2.80.0"
70
70
  },
71
71
  "dependencies": {
72
- "@lwrjs/client-modules": "0.24.2",
73
- "@lwrjs/shared-utils": "0.24.2"
72
+ "@lwrjs/client-modules": "0.24.4",
73
+ "@lwrjs/shared-utils": "0.24.4"
74
74
  },
75
75
  "lwc": {
76
76
  "modules": [
@@ -90,5 +90,5 @@
90
90
  "volta": {
91
91
  "extends": "../../../package.json"
92
92
  },
93
- "gitHead": "7492ce779f3b7e91617c4644a1aa567eff01db58"
93
+ "gitHead": "63feabb6eea1340e80a82146cc1c24bfc4f2d518"
94
94
  }