@lwrjs/client-modules 0.9.0-alpha.2 → 0.9.0-alpha.21

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.
@@ -3,8 +3,9 @@ export const BOOTSTRAP_PREFIX = 'lwr.bootstrap.';
3
3
  export const BOOTSTRAP_END = `${BOOTSTRAP_PREFIX}end`;
4
4
  export const BOOTSTRAP_ERROR = `${BOOTSTRAP_PREFIX}error`;
5
5
  export const BOOTSTRAP_ERROR_COUNT = `${BOOTSTRAP_ERROR}.count`;
6
- export const BOOTSTRAP_DURATION = `${BOOTSTRAP_PREFIX}duration`; // Loader: modules
6
+ export const BOOTSTRAP_DURATION = `${BOOTSTRAP_PREFIX}duration`;
7
7
 
8
+ // Loader: modules
8
9
  export const LOADER_PREFIX = 'lwr.loader.';
9
10
  export const MODULE_DEFINE = `${LOADER_PREFIX}module.define`;
10
11
  export const MODULE_DEFINE_COUNT = `${MODULE_DEFINE}.count`;
@@ -12,14 +13,16 @@ export const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
12
13
  export const MODULE_FETCH_COUNT = `${MODULE_FETCH}.count`;
13
14
  export const MODULE_FETCH_DURATION = `${MODULE_FETCH}.duration`;
14
15
  export const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
15
- export const MODULE_ERROR_COUNT = `${MODULE_ERROR}.count`; // Loader: mappings
16
+ export const MODULE_ERROR_COUNT = `${MODULE_ERROR}.count`;
16
17
 
18
+ // Loader: mappings
17
19
  export const MAPPINGS_FETCH = `${LOADER_PREFIX}mappings.fetch`;
18
20
  export const MAPPINGS_FETCH_COUNT = `${MAPPINGS_FETCH}.count`;
19
21
  export const MAPPINGS_FETCH_DURATION = `${MAPPINGS_FETCH}.duration`;
20
22
  export const MAPPINGS_ERROR = `${LOADER_PREFIX}mappings.error`;
21
- export const MAPPINGS_ERROR_COUNT = `${MAPPINGS_ERROR}.count`; // Router
23
+ export const MAPPINGS_ERROR_COUNT = `${MAPPINGS_ERROR}.count`;
22
24
 
25
+ // Router
23
26
  export const ROUTER_PREFIX = 'lwr.router.';
24
27
  export const ROUTER_NAV = `${ROUTER_PREFIX}navigate`;
25
28
  export const ROUTER_NAV_COUNT = `${ROUTER_NAV}.count`;
@@ -2,8 +2,8 @@
2
2
  * This module is called in the ABS module (app bootstrap module) to perform neccesary pre initialization steps for an LWR app.
3
3
  * Note: this module should be imported before other dependencies in the ABS
4
4
  */
5
- const lwrGlobals = globalThis.LWR;
6
5
 
6
+ const lwrGlobals = globalThis.LWR;
7
7
  if (globalThis.LWR.define) {
8
8
  // AMD only
9
9
  globalThis.LWR = Object.freeze({
@@ -12,7 +12,6 @@ if (globalThis.LWR.define) {
12
12
  } else {
13
13
  delete globalThis.LWR;
14
14
  }
15
-
16
15
  export function getClientBootstrapConfig() {
17
16
  return lwrGlobals;
18
17
  }
@@ -1,21 +1,21 @@
1
1
  var Phase;
2
-
3
2
  (function (Phase) {
4
3
  Phase[Phase["Start"] = 0] = "Start";
5
4
  Phase[Phase["End"] = 1] = "End";
6
5
  })(Phase || (Phase = {}));
7
-
8
6
  // Attach a custom dispatcher
9
7
  let customDispatcher;
10
8
  export function attachDispatcher(dispatcher) {
11
9
  customDispatcher = dispatcher;
12
- } // Check if the Performance API is available
13
- // e.g. JSDom (used in Jest) doesn't implement these
10
+ }
14
11
 
12
+ // Check if the Performance API is available
13
+ // e.g. JSDom (used in Jest) doesn't implement these
15
14
  const perf = globalThis.performance;
16
- 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
17
- // Fallback to the Performance API if there is no custom dispatcher
15
+ const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
18
16
 
17
+ // For marking request metrics
18
+ // Fallback to the Performance API if there is no custom dispatcher
19
19
  export function logOperationStart({
20
20
  id,
21
21
  specifier
@@ -29,11 +29,11 @@ export function logOperationStart({
29
29
  } else if (isPerfSupported) {
30
30
  perf.mark(id + (specifier ? `.${specifier}` : ''));
31
31
  }
32
- } // For measuring duration metrics
33
- // Fallback to the Performance API if there is no custom dispatcher
32
+ }
34
33
 
34
+ // For measuring duration metrics
35
+ // Fallback to the Performance API if there is no custom dispatcher
35
36
  /* istanbul ignore next */
36
-
37
37
  export function logOperationEnd({
38
38
  id,
39
39
  specifier
@@ -48,9 +48,10 @@ export function logOperationEnd({
48
48
  const suffix = specifier ? `.${specifier}` : '';
49
49
  const markName = id + suffix;
50
50
  const measureName = `${id}.duration${suffix}`;
51
- perf.measure(measureName, markName); // Clear the created mark and measure to avoid filling the performance entry buffer
52
- // Even if they get deleted, existing PerformanceObservers preserve copies of the entries
51
+ perf.measure(measureName, markName);
53
52
 
53
+ // Clear the created mark and measure to avoid filling the performance entry buffer
54
+ // Even if they get deleted, existing PerformanceObservers preserve copies of the entries
54
55
  perf.clearMarks(markName);
55
56
  perf.clearMeasures(measureName);
56
57
  }
@@ -2,14 +2,12 @@ const handleStaleModuleHooks = [];
2
2
  let socket;
3
3
  export function registerHandleStaleModuleHook(callback) {
4
4
  handleStaleModuleHooks.push(callback);
5
-
6
5
  if (!socket) {
7
6
  socket = new WebSocket(`ws://${location.host}`);
8
7
  socket.addEventListener('message', async ({
9
8
  data
10
9
  }) => {
11
10
  const event = JSON.parse(data);
12
-
13
11
  if (event.eventType === 'moduleUpdate') {
14
12
  const {
15
13
  oldHash,
@@ -17,8 +15,9 @@ export function registerHandleStaleModuleHook(callback) {
17
15
  module: {
18
16
  specifier
19
17
  }
20
- } = event.payload; // keep evaluating hooks unless return value is null
18
+ } = event.payload;
21
19
 
20
+ // keep evaluating hooks unless return value is null
22
21
  for (let i = 0; i < handleStaleModuleHooks.length; i++) {
23
22
  const hook = handleStaleModuleHooks[i];
24
23
  const result = hook({
@@ -26,7 +25,6 @@ export function registerHandleStaleModuleHook(callback) {
26
25
  oldHash,
27
26
  newHash
28
27
  });
29
-
30
28
  if (result !== null) {
31
29
  break;
32
30
  }
@@ -1,10 +1,8 @@
1
1
  import { registerHandleStaleModuleHook } from './handleStaleModuleESM';
2
2
  import { getClientBootstrapConfig } from 'lwr/preInit';
3
-
4
3
  const noop = () => {
5
4
  console.warn('API is not supported in ESM format');
6
5
  };
7
-
8
6
  function getAppMetadata() {
9
7
  const {
10
8
  appId,
@@ -19,7 +17,6 @@ function getAppMetadata() {
19
17
  rootComponents
20
18
  };
21
19
  }
22
-
23
20
  export const services = {
24
21
  // addLoaderPlugin is only supported in AMD
25
22
  addLoaderPlugin: noop,
package/package.json CHANGED
@@ -4,15 +4,15 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.9.0-alpha.2",
7
+ "version": "0.9.0-alpha.21",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/salesforce/lwr.git",
11
+ "url": "https://github.com/salesforce-experience-platform-emu/lwr/lwr.git",
12
12
  "directory": "packages/@lwrjs/client-modules"
13
13
  },
14
14
  "bugs": {
15
- "url": "https://github.com/salesforce/lwr/issues"
15
+ "url": "https://github.com/salesforce-experience-platform-emu/lwr/lwr/issues"
16
16
  },
17
17
  "type": "module",
18
18
  "types": "build/es/index.d.ts",
@@ -31,8 +31,8 @@
31
31
  "build:bundle": "rollup --config scripts/rollup.moduleBundle.config.cjs"
32
32
  },
33
33
  "dependencies": {
34
- "@locker/sandbox": "0.17.9",
35
- "@lwrjs/shared-utils": "0.9.0-alpha.2"
34
+ "@locker/sandbox": "0.18.9",
35
+ "@lwrjs/shared-utils": "0.9.0-alpha.21"
36
36
  },
37
37
  "devDependencies": {
38
38
  "rollup-plugin-terser": "^7.0.2"
@@ -58,5 +58,5 @@
58
58
  "engines": {
59
59
  "node": ">=14.15.4 <19"
60
60
  },
61
- "gitHead": "bcf63de23d1a2a53fb0e961dba4396e8753710dd"
61
+ "gitHead": "a89adcac80601f657becd6fd734c765e6b2a2745"
62
62
  }