@lwrjs/loader 0.24.2 → 0.24.3

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 (48) hide show
  1. package/build/assets/prod/lwr-error-shim.js +1 -1
  2. package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +22 -9
  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 +22 -9
  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 +35 -25
  9. package/build/cjs/modules/lwr/esmLoader/esmLoader.cjs +32 -22
  10. package/build/cjs/modules/lwr/esmLoader/importResolver.cjs +23 -8
  11. package/build/cjs/modules/lwr/esmLoader/importResolverLegacy.cjs +24 -7
  12. package/build/cjs/modules/lwr/loader/constants/constants.cjs +20 -7
  13. package/build/cjs/modules/lwr/loader/errors/messages.cjs +15 -18
  14. package/build/cjs/modules/lwr/loader/errors/reportError.cjs +16 -20
  15. package/build/cjs/modules/lwr/loader/errors/utils.cjs +17 -4
  16. package/build/cjs/modules/lwr/loader/hooks/moduleInvalidation.cjs +18 -21
  17. package/build/cjs/modules/lwr/loader/hooks/resolveAndLoadHook.cjs +38 -37
  18. package/build/cjs/modules/lwr/loader/moduleRegistry/importMetadataResolver.cjs +46 -26
  19. package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +124 -76
  20. package/build/cjs/modules/lwr/loader/moduleRegistry/scriptLoad.cjs +16 -19
  21. package/build/cjs/modules/lwr/loader/utils/dom.cjs +17 -4
  22. package/build/cjs/modules/lwr/loader/utils/url.cjs +21 -25
  23. package/build/cjs/modules/lwr/loader/utils/validation.cjs +22 -7
  24. package/build/cjs/modules/lwr/loader/validateLoadSpecifier.cjs +18 -5
  25. package/build/cjs/modules/lwr/loaderLegacy/constants/constants.cjs +20 -7
  26. package/build/cjs/modules/lwr/loaderLegacy/errors/messages.cjs +15 -18
  27. package/build/cjs/modules/lwr/loaderLegacy/errors/reportError.cjs +16 -20
  28. package/build/cjs/modules/lwr/loaderLegacy/errors/utils.cjs +17 -4
  29. package/build/cjs/modules/lwr/loaderLegacy/hooks/moduleInvalidation.cjs +18 -21
  30. package/build/cjs/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.cjs +38 -37
  31. package/build/cjs/modules/lwr/loaderLegacy/importMap/dom.cjs +25 -25
  32. package/build/cjs/modules/lwr/loaderLegacy/importMap/importMap.cjs +32 -25
  33. package/build/cjs/modules/lwr/loaderLegacy/importMap/importMapResolver.cjs +16 -19
  34. package/build/cjs/modules/lwr/loaderLegacy/importMap/utils.cjs +15 -18
  35. package/build/cjs/modules/lwr/loaderLegacy/importResolver/importResolver.cjs +15 -2
  36. package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +105 -76
  37. package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/scriptLoad.cjs +16 -19
  38. package/build/cjs/modules/lwr/loaderLegacy/utils/dom.cjs +17 -4
  39. package/build/cjs/modules/lwr/loaderLegacy/utils/url.cjs +21 -25
  40. package/build/cjs/modules/lwr/loaderLegacy/utils/validation.cjs +18 -19
  41. package/build/cjs/package.d.cjs +1 -0
  42. package/build/cjs/types.cjs +15 -2
  43. package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
  44. package/build/modules/lwr/loader/hooks/resolveAndLoadHook.js +15 -3
  45. package/build/modules/lwr/loader/loader.js +17 -4
  46. package/build/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.js +15 -3
  47. package/build/modules/lwr/loaderLegacy/loaderLegacy.js +17 -4
  48. package/package.json +6 -6
@@ -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.3 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -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.3 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -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.3",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -61,16 +61,16 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@locker/trusted-types": "0.29.2",
64
- "@lwrjs/diagnostics": "0.24.2",
65
- "@lwrjs/types": "0.24.2",
64
+ "@lwrjs/diagnostics": "0.24.3",
65
+ "@lwrjs/types": "0.24.3",
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.3",
73
+ "@lwrjs/shared-utils": "0.24.3"
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": "ed415a8f04d5558cac756fbc2a0e454a373e31c1"
94
94
  }