@lwrjs/view-registry 0.10.0-alpha.11 → 0.10.0-alpha.13
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.
|
@@ -54,7 +54,7 @@ function getViewBootstrapConfigurationResource(viewInfo, config, runtimeEnvironm
|
|
|
54
54
|
...config,
|
|
55
55
|
endpoints
|
|
56
56
|
})});`,
|
|
57
|
-
`globalThis.process = { env: { NODE_ENV: "${runtimeEnvironment.serverMode}" } };`
|
|
57
|
+
`globalThis.process = { env: { NODE_ENV: "${runtimeEnvironment.serverMode}", SSR: false } };`
|
|
58
58
|
].filter(Boolean).join("\n");
|
|
59
59
|
if (viewInfo.configAsSrc) {
|
|
60
60
|
const viewUrl = viewInfo.url || "/";
|
package/build/cjs/utils.cjs
CHANGED
|
@@ -38,14 +38,6 @@ __export(exports, {
|
|
|
38
38
|
var import_path = __toModule(require("path"));
|
|
39
39
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
40
40
|
var import_identity = __toModule(require("@lwrjs/app-service/identity"));
|
|
41
|
-
function streamToString(stream) {
|
|
42
|
-
const chunks = [];
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
stream.on("data", (c) => chunks.push(c));
|
|
45
|
-
stream.on("error", reject);
|
|
46
|
-
stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
41
|
function generateExternalStyle(src) {
|
|
50
42
|
return `<link rel="stylesheet" href="${src}">`;
|
|
51
43
|
}
|
|
@@ -81,7 +73,7 @@ async function generateInlineTag({specifier, type, content, stream, nonce}) {
|
|
|
81
73
|
if (!content && !stream) {
|
|
82
74
|
throw new Error(`Invalid inline Resource Definition: must have either "content" or "stream": "${specifier}"`);
|
|
83
75
|
}
|
|
84
|
-
const code = stream ? await streamToString(stream()) : content;
|
|
76
|
+
const code = stream ? await (0, import_shared_utils.streamToString)(stream()) : content;
|
|
85
77
|
return `<${tag}${typeStr}${nonceStr}>${code}</${tag}>`;
|
|
86
78
|
}
|
|
87
79
|
async function generateHtmlTag(definition) {
|
|
@@ -212,9 +204,9 @@ async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEnvironme
|
|
|
212
204
|
}
|
|
213
205
|
};
|
|
214
206
|
}
|
|
215
|
-
async function getModuleResource(moduleId, runtimeEnvironment,
|
|
207
|
+
async function getModuleResource(moduleId, runtimeEnvironment, moduleResourceMeta, defRegistry, runtimeParams) {
|
|
216
208
|
const {format} = runtimeEnvironment;
|
|
217
|
-
const {isSSR = false, isPreload = false} =
|
|
209
|
+
const {isSSR = false, isPreload = false} = moduleResourceMeta;
|
|
218
210
|
const moduleUri = await defRegistry.resolveModuleUri(moduleId, runtimeEnvironment, runtimeParams);
|
|
219
211
|
return {
|
|
220
212
|
src: moduleUri,
|
|
@@ -224,8 +216,8 @@ async function getModuleResource(moduleId, runtimeEnvironment, moduleResouceMeta
|
|
|
224
216
|
isPreload: format !== "amd" && isPreload
|
|
225
217
|
};
|
|
226
218
|
}
|
|
227
|
-
function getModuleResourceByUri(uri, runtimeEnvironment,
|
|
228
|
-
const {isSSR = false, isPreload = false} =
|
|
219
|
+
function getModuleResourceByUri(uri, runtimeEnvironment, moduleResourceMeta) {
|
|
220
|
+
const {isSSR = false, isPreload = false} = moduleResourceMeta;
|
|
229
221
|
const {format} = runtimeEnvironment;
|
|
230
222
|
return {
|
|
231
223
|
src: uri,
|
package/build/es/index.js
CHANGED
|
@@ -299,7 +299,7 @@ export class LwrViewRegistry {
|
|
|
299
299
|
for (const viewTransformer of this.viewTransformers) {
|
|
300
300
|
// eslint-disable-next-line no-await-in-loop
|
|
301
301
|
const linkResults = await viewTransformer.link?.(stringBuilder, mergedViewContext, linkedMetadata);
|
|
302
|
-
// Keep track of the shortest TTL from each view transformer (e.g.
|
|
302
|
+
// Keep track of the shortest TTL from each view transformer (e.g. lwcSsrViewTransformer)
|
|
303
303
|
const ttl = linkResults && linkResults.cache?.ttl;
|
|
304
304
|
pageTtl = shortestTtl(ttl || undefined, pageTtl);
|
|
305
305
|
}
|
|
@@ -11,7 +11,7 @@ interface ResourceContext {
|
|
|
11
11
|
resourceRegistry: ResourceRegistry;
|
|
12
12
|
bundleConfig: BundleConfig;
|
|
13
13
|
}
|
|
14
|
-
type LinkedResourcesViewDefinition = Pick<LinkedViewDefinition, 'renderedView' | 'viewRecord'>;
|
|
14
|
+
declare type LinkedResourcesViewDefinition = Pick<LinkedViewDefinition, 'renderedView' | 'viewRecord'>;
|
|
15
15
|
export declare function linkLwrResources(source: string, view: View, viewParams: ViewParams, cxt: LwrResourcesLinkedContext): Promise<LinkedResourcesViewDefinition>;
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=link-lwr-resources.d.ts.map
|
|
@@ -25,8 +25,9 @@ export function getViewBootstrapConfigurationResource(viewInfo, config, runtimeE
|
|
|
25
25
|
...config,
|
|
26
26
|
endpoints,
|
|
27
27
|
})});`,
|
|
28
|
-
// TODO: W-12639529 change after addressing downstream customers
|
|
29
|
-
|
|
28
|
+
// TODO: W-12639529 change NODE_ENV after addressing downstream customers
|
|
29
|
+
// Note: SSR is always false because this script is executed on the client
|
|
30
|
+
`globalThis.process = { env: { NODE_ENV: "${runtimeEnvironment.serverMode}", SSR: false } };`,
|
|
30
31
|
]
|
|
31
32
|
.filter(Boolean)
|
|
32
33
|
.join('\n');
|
package/build/es/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AssetReference, JsonCompatible, LinkedViewDefinition, LwrErrorRoute, LwrRoute, ModuleBundler, ModuleId, ModuleJson, ModuleRegistry, NormalizedRenderingResult, PublicModuleRegistry, RenderOptions, RenderedAssetReference, RenderingResult, ResourceDefinition, RouteHandlerViewResponse, RuntimeEnvironment, RuntimeParams, ViewModuleResourceContext, ViewPageContext, ViewRequest, ViewResponse } from '@lwrjs/types';
|
|
2
|
-
export type HTMLResource = Partial<ResourceDefinition>;
|
|
2
|
+
export declare type HTMLResource = Partial<ResourceDefinition>;
|
|
3
3
|
export declare function generateHtmlTag(definition: HTMLResource): Promise<string>;
|
|
4
4
|
export declare function normalizeRenderedResult({ renderedView, metadata, options, }: RenderingResult): NormalizedRenderingResult;
|
|
5
5
|
export declare function reduceSourceAssetReferences(assets: AssetReference[]): RenderedAssetReference[];
|
|
@@ -7,7 +7,7 @@ export declare function normalizeRenderOptions(runtimeEnvironment: RuntimeEnviro
|
|
|
7
7
|
export declare function generatePageContext({ requestPath: url }: ViewRequest, { id, contentTemplate, properties }: LwrRoute | LwrErrorRoute): JsonCompatible<ViewPageContext>;
|
|
8
8
|
export declare function isViewResponse(response: RouteHandlerViewResponse): response is ViewResponse;
|
|
9
9
|
export declare function toJsonFormat(viewRequest: ViewRequest, viewDefinition: LinkedViewDefinition, route: LwrRoute | LwrErrorRoute, runtimeEnvironment: RuntimeEnvironment, runtimeParams: RuntimeParams, moduleRegistry: ModuleRegistry): Promise<ViewResponse>;
|
|
10
|
-
export declare function getModuleResource(moduleId: Pick<ModuleId, 'specifier' | 'version'>, runtimeEnvironment: RuntimeEnvironment,
|
|
11
|
-
export declare function getModuleResourceByUri(uri: string, runtimeEnvironment: RuntimeEnvironment,
|
|
10
|
+
export declare function getModuleResource(moduleId: Pick<ModuleId, 'specifier' | 'version'>, runtimeEnvironment: RuntimeEnvironment, moduleResourceMeta: ViewModuleResourceContext, defRegistry: ModuleRegistry | ModuleBundler, runtimeParams?: RuntimeParams): Promise<ResourceDefinition>;
|
|
11
|
+
export declare function getModuleResourceByUri(uri: string, runtimeEnvironment: RuntimeEnvironment, moduleResourceMeta: ViewModuleResourceContext): ResourceDefinition;
|
|
12
12
|
export declare function createJsonModule(specifier: string, moduleRegistry: PublicModuleRegistry, environment: RuntimeEnvironment, params?: RuntimeParams): Promise<ModuleJson>;
|
|
13
13
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/es/utils.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { basename, extname } from 'path';
|
|
2
|
-
import { explodeSpecifier, getMappingUriPrefix, getSpecifier, getClientBootstrapConfigurationUri, mimeLookup, DEFAULT_TITLE, } from '@lwrjs/shared-utils';
|
|
2
|
+
import { explodeSpecifier, getMappingUriPrefix, getSpecifier, getClientBootstrapConfigurationUri, mimeLookup, DEFAULT_TITLE, streamToString, } from '@lwrjs/shared-utils';
|
|
3
3
|
import { AppResourceEnum, getAppSpecifier, ResourceIdentityTypes, } from '@lwrjs/app-service/identity';
|
|
4
|
-
function streamToString(stream) {
|
|
5
|
-
const chunks = [];
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
stream.on('data', (c) => chunks.push(c));
|
|
8
|
-
stream.on('error', reject);
|
|
9
|
-
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
4
|
function generateExternalStyle(src) {
|
|
13
5
|
return `<link rel="stylesheet" href="${src}">`;
|
|
14
6
|
}
|
|
@@ -191,9 +183,9 @@ export async function toJsonFormat(viewRequest, viewDefinition, route, runtimeEn
|
|
|
191
183
|
},
|
|
192
184
|
};
|
|
193
185
|
}
|
|
194
|
-
export async function getModuleResource(moduleId, runtimeEnvironment,
|
|
186
|
+
export async function getModuleResource(moduleId, runtimeEnvironment, moduleResourceMeta, defRegistry, runtimeParams) {
|
|
195
187
|
const { format } = runtimeEnvironment;
|
|
196
|
-
const { isSSR = false, isPreload = false } =
|
|
188
|
+
const { isSSR = false, isPreload = false } = moduleResourceMeta;
|
|
197
189
|
const moduleUri = await defRegistry.resolveModuleUri(moduleId, runtimeEnvironment, runtimeParams);
|
|
198
190
|
return {
|
|
199
191
|
src: moduleUri,
|
|
@@ -205,8 +197,8 @@ export async function getModuleResource(moduleId, runtimeEnvironment, moduleReso
|
|
|
205
197
|
isPreload: format !== 'amd' && isPreload,
|
|
206
198
|
};
|
|
207
199
|
}
|
|
208
|
-
export function getModuleResourceByUri(uri, runtimeEnvironment,
|
|
209
|
-
const { isSSR = false, isPreload = false } =
|
|
200
|
+
export function getModuleResourceByUri(uri, runtimeEnvironment, moduleResourceMeta) {
|
|
201
|
+
const { isSSR = false, isPreload = false } = moduleResourceMeta;
|
|
210
202
|
const { format } = runtimeEnvironment;
|
|
211
203
|
return {
|
|
212
204
|
src: uri,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.10.0-alpha.
|
|
7
|
+
"version": "0.10.0-alpha.13",
|
|
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.10.0-alpha.
|
|
34
|
-
"@lwrjs/diagnostics": "0.10.0-alpha.
|
|
35
|
-
"@lwrjs/shared-utils": "0.10.0-alpha.
|
|
33
|
+
"@lwrjs/app-service": "0.10.0-alpha.13",
|
|
34
|
+
"@lwrjs/diagnostics": "0.10.0-alpha.13",
|
|
35
|
+
"@lwrjs/shared-utils": "0.10.0-alpha.13"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@lwrjs/types": "0.10.0-alpha.
|
|
38
|
+
"@lwrjs/types": "0.10.0-alpha.13"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=16.0.0 <20"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "f6d142d5a027554cb1685389e0b173734149683d"
|
|
44
44
|
}
|