@lwrjs/app-service 0.13.0-alpha.3 → 0.13.0-alpha.30

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.
@@ -38,7 +38,7 @@ function createServicesSource(services) {
38
38
  });
39
39
  const body = services.map(({name}) => {
40
40
  const defaultImportName = getDefaultImportName(name);
41
- return `${defaultImportName}(services)`;
41
+ return `${defaultImportName}({...services, addServerDataCallback: registerServerDataCallbacks })`;
42
42
  });
43
43
  return [...imports, ...body].join(";\n") + ";";
44
44
  }
@@ -77,6 +77,7 @@ function createAppRouteViewBootstrapModule(route, options, lockerConfig) {
77
77
  syntheticShadow && `import '@lwc/synthetic-shadow';`,
78
78
  ssr && `import { polyfillDeclarativeShadowDom } from 'lwr/declarativeShadow';`,
79
79
  services && services.length && `import { services } from '${serviceApiModule}';`,
80
+ services && services.length && `import { registerServerDataCallbacks, evaluateServerDataCallbacks } from 'lwr/serverDataCallback';`,
80
81
  servicesSource,
81
82
  isESM && options.hmrEnabled && `import { initHMR } from 'lwr/hmr';`,
82
83
  isESM && `import { init as esmLoaderInit } from 'lwr/esmLoader';`,
@@ -85,14 +86,15 @@ function createAppRouteViewBootstrapModule(route, options, lockerConfig) {
85
86
  import { registerLockerDefine } from 'lwr/lockerDefine';
86
87
  registerLockerDefine(${JSON.stringify(lockerConfig.trustedComponents)});
87
88
  `,
88
- `const clientBootstrapConfig = getClientBootstrapConfig()`,
89
+ `const clientBootstrapConfig = getClientBootstrapConfig();`,
90
+ `const { serverData, rootComponents } = clientBootstrapConfig;`,
89
91
  isESM && `
90
92
  const { imports, index, importMappings, endpoints } = clientBootstrapConfig;
91
93
  esmLoaderInit({ imports, index, importMappings, endpoints });`,
92
94
  ssr && `polyfillDeclarativeShadowDom();`,
95
+ services && services.length && `evaluateServerDataCallbacks(serverData)`,
93
96
  `
94
97
  // initialize additional non-configured root components
95
- const { rootComponents, serverData } = clientBootstrapConfig;
96
98
  Promise.all(rootComponents.map(async (rootSpecifier) => {
97
99
  const element = toKebabCase(rootSpecifier);
98
100
  return import(rootSpecifier).then(({default: Ctor}) => {
@@ -9,7 +9,7 @@ function createServicesSource(services) {
9
9
  });
10
10
  const body = services.map(({ name }) => {
11
11
  const defaultImportName = getDefaultImportName(name);
12
- return `${defaultImportName}(services)`;
12
+ return `${defaultImportName}({...services, addServerDataCallback: registerServerDataCallbacks })`;
13
13
  });
14
14
  return [...imports, ...body].join(';\n') + ';';
15
15
  }
@@ -68,7 +68,11 @@ export function createAppRouteViewBootstrapModule(route, options, lockerConfig)
68
68
  // Declarative ShadowDOM polyfill
69
69
  ssr && `import { polyfillDeclarativeShadowDom } from 'lwr/declarativeShadow';`,
70
70
  // Import bootstrap services
71
+ // Note: in AMD, only part of the ServiceAPI contract is implemented by the AMD loader
71
72
  services && services.length && `import { services } from '${serviceApiModule}';`,
73
+ services &&
74
+ services.length &&
75
+ `import { registerServerDataCallbacks, evaluateServerDataCallbacks } from 'lwr/serverDataCallback';`,
72
76
  // import and register the configured services
73
77
  servicesSource,
74
78
  // HMR (ESM format only)
@@ -86,7 +90,8 @@ import { registerLockerDefine } from 'lwr/lockerDefine';
86
90
  registerLockerDefine(${JSON.stringify(lockerConfig.trustedComponents)});
87
91
  `,
88
92
  // grab client bootstrap config
89
- `const clientBootstrapConfig = getClientBootstrapConfig()`,
93
+ `const clientBootstrapConfig = getClientBootstrapConfig();`,
94
+ `const { serverData, rootComponents } = clientBootstrapConfig;`,
90
95
  // Initialize the ESM loader with the Client Bootstrap Config
91
96
  isESM &&
92
97
  `
@@ -94,9 +99,10 @@ const { imports, index, importMappings, endpoints } = clientBootstrapConfig;
94
99
  esmLoaderInit({ imports, index, importMappings, endpoints });`,
95
100
  // Invoke the Declarative ShadowDOM polyfill
96
101
  ssr && `polyfillDeclarativeShadowDom();`,
102
+ // Invoke `serverDataCallback` bootstrap services
103
+ services && services.length && `evaluateServerDataCallbacks(serverData)`,
97
104
  `
98
105
  // initialize additional non-configured root components
99
- const { rootComponents, serverData } = clientBootstrapConfig;
100
106
  Promise.all(rootComponents.map(async (rootSpecifier) => {
101
107
  const element = toKebabCase(rootSpecifier);
102
108
  return import(rootSpecifier).then(({default: Ctor}) => {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.13.0-alpha.3",
7
+ "version": "0.13.0-alpha.30",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -32,15 +32,18 @@
32
32
  "build/**/*.cjs",
33
33
  "build/**/*.d.ts"
34
34
  ],
35
+ "scripts": {
36
+ "build": "tsc -b"
37
+ },
35
38
  "dependencies": {
36
- "@lwrjs/diagnostics": "0.13.0-alpha.3",
37
- "@lwrjs/shared-utils": "0.13.0-alpha.3"
39
+ "@lwrjs/diagnostics": "0.13.0-alpha.30",
40
+ "@lwrjs/shared-utils": "0.13.0-alpha.30"
38
41
  },
39
42
  "devDependencies": {
40
- "@lwrjs/types": "0.13.0-alpha.3"
43
+ "@lwrjs/types": "0.13.0-alpha.30"
41
44
  },
42
45
  "engines": {
43
46
  "node": ">=18.0.0"
44
47
  },
45
- "gitHead": "f2435da0eb0cf643add2a7cf896b3372df75733e"
48
+ "gitHead": "8bf14ed00a95675fdb506e2cbdb6033324bf95bf"
46
49
  }