@lwrjs/view-registry 0.7.0-alpha.0 → 0.7.0-alpha.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.
@@ -65,6 +65,11 @@ async function getHtmlResources(view, viewParams, resourceContext) {
65
65
  throw Error("Failed to find definition of resource: " + shimBundle);
66
66
  }
67
67
  requiredResources.push(def);
68
+ const errorShimDef = await resourceRegistry.getResource({specifier: "lwr-error-shim.js", version}, runtimeEnvironment, runtimeParams);
69
+ if (!errorShimDef) {
70
+ throw Error("Failed to find definition of resource: lwr-error-shim.js");
71
+ }
72
+ requiredResources.push(errorShimDef);
68
73
  if (!bundle) {
69
74
  requiredResources.push(await (0, import_utils.getModuleResource)({
70
75
  specifier: "lwr/loaderLegacy",
@@ -31,9 +31,9 @@ var import_legacy_view_bootstrap = __toModule(require("./legacy_view_bootstrap.c
31
31
  async function linkLwrResources(source, view, viewParams, cxt) {
32
32
  const {lwrResourcesId, ...resourceContext} = cxt;
33
33
  const {
34
- experimental_features: {ENABLE_FINGERPRINTS}
34
+ featureFlags: {LEGACY_LOADER}
35
35
  } = resourceContext.runtimeEnvironment;
36
- const {partial, viewRecord} = ENABLE_FINGERPRINTS ? await (0, import_view_bootstrap.getHtmlResources)(view, viewParams, resourceContext) : await (0, import_legacy_view_bootstrap.getHtmlResources)(view, viewParams, resourceContext);
36
+ const {partial, viewRecord} = LEGACY_LOADER ? await (0, import_legacy_view_bootstrap.getHtmlResources)(view, viewParams, resourceContext) : await (0, import_view_bootstrap.getHtmlResources)(view, viewParams, resourceContext);
37
37
  return {
38
38
  renderedView: source.replace(lwrResourcesId, partial),
39
39
  viewRecord
@@ -65,6 +65,11 @@ async function getHtmlResources(view, viewParams, resourceContext) {
65
65
  throw Error("Failed to find definition of resource: " + shimBundle);
66
66
  }
67
67
  requiredResources.push(def);
68
+ const errorShimDef = await resourceRegistry.getResource({specifier: "lwr-error-shim.js", version}, runtimeEnvironment, runtimeParams);
69
+ if (!errorShimDef) {
70
+ throw Error("Failed to find definition of resource: lwr-error-shim.js");
71
+ }
72
+ requiredResources.push(errorShimDef);
68
73
  if (!bundle) {
69
74
  requiredResources.push(await (0, import_utils.getModuleResource)({
70
75
  specifier: "lwr/loader",
@@ -205,10 +205,12 @@ async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEnvironme
205
205
  resources.push({type, src: asset.override?.uri});
206
206
  }
207
207
  });
208
+ const importMetadata = !runtimeEnvironment.featureFlags?.LEGACY_LOADER && viewRecord.importMetadata;
208
209
  viewRecord.resources?.forEach((resource) => {
209
210
  resources.push({type: resource.type, src: resource.src});
210
211
  });
211
212
  const body = {
213
+ ...importMetadata,
212
214
  modules,
213
215
  preloadModules,
214
216
  endpoints,
@@ -41,7 +41,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
41
41
  const preloadAmdModules = [];
42
42
  // ------ AMD Required module resources
43
43
  if (isAMD) {
44
- // Keep changes in sync with view_bootstrap.ts
44
+ // Keep shim format in sync with view_bootstrap.ts
45
45
  const shimBundle = !bundle
46
46
  ? 'lwr-loader-shim-legacy.js'
47
47
  : debug || minify === false
@@ -52,6 +52,13 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
52
52
  throw Error('Failed to find definition of resource: ' + shimBundle);
53
53
  }
54
54
  requiredResources.push(def);
55
+ // Always inline the error shim script after the shim
56
+ const errorShimDef = (await resourceRegistry.getResource({ specifier: 'lwr-error-shim.js', version }, runtimeEnvironment, runtimeParams));
57
+ if (!errorShimDef) {
58
+ throw Error('Failed to find definition of resource: lwr-error-shim.js');
59
+ }
60
+ requiredResources.push(errorShimDef);
61
+ // Add loader, if not already bundled with the shim
55
62
  if (!bundle) {
56
63
  // needed because we're resolving against fully-linked modules
57
64
  requiredResources.push(await getModuleResource({
@@ -2,10 +2,10 @@ import { getHtmlResources } from './view_bootstrap.js';
2
2
  import { getHtmlResources as getLegacyHtmlResource } from './legacy_view_bootstrap.js';
3
3
  export async function linkLwrResources(source, view, viewParams, cxt) {
4
4
  const { lwrResourcesId, ...resourceContext } = cxt;
5
- const { experimental_features: { ENABLE_FINGERPRINTS }, } = resourceContext.runtimeEnvironment;
6
- const { partial, viewRecord } = ENABLE_FINGERPRINTS
7
- ? await getHtmlResources(view, viewParams, resourceContext)
8
- : await getLegacyHtmlResource(view, viewParams, resourceContext);
5
+ const { featureFlags: { LEGACY_LOADER }, } = resourceContext.runtimeEnvironment;
6
+ const { partial, viewRecord } = LEGACY_LOADER
7
+ ? await getLegacyHtmlResource(view, viewParams, resourceContext)
8
+ : await getHtmlResources(view, viewParams, resourceContext);
9
9
  // Finally replace the token with the real resources
10
10
  return {
11
11
  renderedView: source.replace(lwrResourcesId, partial),
@@ -41,7 +41,7 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
41
41
  const preloadAmdModules = [];
42
42
  // ------ AMD Required module resources
43
43
  if (isAMD) {
44
- // Keep changes in sync with legacy_view_bootstrap.ts
44
+ // Keep shim format in sync with legacy_view_bootstrap.ts
45
45
  const shimBundle = !bundle
46
46
  ? 'lwr-loader-shim.js'
47
47
  : debug || minify === false
@@ -52,6 +52,13 @@ export async function getHtmlResources(view, viewParams, resourceContext) {
52
52
  throw Error('Failed to find definition of resource: ' + shimBundle);
53
53
  }
54
54
  requiredResources.push(def);
55
+ // Always inline the error shim script after the shim
56
+ const errorShimDef = (await resourceRegistry.getResource({ specifier: 'lwr-error-shim.js', version }, runtimeEnvironment, runtimeParams));
57
+ if (!errorShimDef) {
58
+ throw Error('Failed to find definition of resource: lwr-error-shim.js');
59
+ }
60
+ requiredResources.push(errorShimDef);
61
+ // Add loader, if not already bundled with the shim
55
62
  if (!bundle) {
56
63
  // needed because we're resolving against fully-linked modules
57
64
  requiredResources.push(await getModuleResource({
package/build/es/utils.js CHANGED
@@ -187,10 +187,13 @@ export async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEn
187
187
  resources.push({ type, src: asset.override?.uri });
188
188
  }
189
189
  });
190
+ // Import Metadata
191
+ const importMetadata = !runtimeEnvironment.featureFlags?.LEGACY_LOADER && viewRecord.importMetadata;
190
192
  viewRecord.resources?.forEach((resource) => {
191
193
  resources.push({ type: resource.type, src: resource.src });
192
194
  });
193
195
  const body = {
196
+ ...importMetadata,
194
197
  modules,
195
198
  preloadModules,
196
199
  endpoints,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.7.0-alpha.0",
7
+ "version": "0.7.0-alpha.3",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -30,15 +30,15 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "@lwrjs/app-service": "0.7.0-alpha.0",
34
- "@lwrjs/diagnostics": "0.7.0-alpha.0",
35
- "@lwrjs/shared-utils": "0.7.0-alpha.0"
33
+ "@lwrjs/app-service": "0.7.0-alpha.3",
34
+ "@lwrjs/diagnostics": "0.7.0-alpha.3",
35
+ "@lwrjs/shared-utils": "0.7.0-alpha.3"
36
36
  },
37
37
  "devDependencies": {
38
- "@lwrjs/types": "0.7.0-alpha.0"
38
+ "@lwrjs/types": "0.7.0-alpha.3"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=14.15.4 <17"
42
42
  },
43
- "gitHead": "4ed70d0bb9fd53feb629468b558b882adade0967"
43
+ "gitHead": "5331416846f2de30b42a6c17f9ef723de2f30271"
44
44
  }