@lwrjs/lwc-ssr 0.13.0 → 0.13.2
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.
- package/README.md +2 -0
- package/build/cjs/utils.cjs +9 -2
- package/build/es/utils.js +12 -2
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -158,6 +158,7 @@ interface SsrDataResponse {
|
|
|
158
158
|
fetchpriority?: 'high' | 'low' | 'auto';
|
|
159
159
|
}[];
|
|
160
160
|
scripts?: { body: string }[]; // for security, all scripts are inlined with `type="application/ld+json"`
|
|
161
|
+
styles?: { body: string; id?: string }[]; // <style> tags
|
|
161
162
|
};
|
|
162
163
|
cache?: {
|
|
163
164
|
ttl?: string | number; // time-to-live: time string or number of seconds
|
|
@@ -220,6 +221,7 @@ export async function getServerData(context: SsrRequestContext): Promise<SsrData
|
|
|
220
221
|
},
|
|
221
222
|
],
|
|
222
223
|
scripts: [{ body: `{ "tags": "${category}" }` }], // SEO data
|
|
224
|
+
styles: [{ body: 'body { margin: 0 }' }],
|
|
223
225
|
},
|
|
224
226
|
cache: { ttl: '60s' },
|
|
225
227
|
};
|
package/build/cjs/utils.cjs
CHANGED
|
@@ -226,15 +226,22 @@ function createLinkTags(links) {
|
|
|
226
226
|
`;
|
|
227
227
|
}, "");
|
|
228
228
|
}
|
|
229
|
+
function createStyleTags(styles) {
|
|
230
|
+
return styles.reduce((styleStr, {body, id}) => {
|
|
231
|
+
const idStr = id ? ` id="${id}"` : "";
|
|
232
|
+
return styleStr + `<style type="text/css"${idStr}>${body}</style>
|
|
233
|
+
`;
|
|
234
|
+
}, "");
|
|
235
|
+
}
|
|
229
236
|
function createHeadMarkup(results) {
|
|
230
237
|
let hasTitle = false;
|
|
231
|
-
return results.reduce((str, {markup: {title, scripts = [], meta = [], links = []} = {}}) => {
|
|
238
|
+
return results.reduce((str, {markup: {title, scripts = [], meta = [], links = [], styles = []} = {}}) => {
|
|
232
239
|
if (title && !hasTitle) {
|
|
233
240
|
hasTitle = true;
|
|
234
241
|
str += `<title>${title}</title>
|
|
235
242
|
`;
|
|
236
243
|
}
|
|
237
|
-
return str + createMetaTags(meta) + createScriptTags(scripts) + createLinkTags(links);
|
|
244
|
+
return str + createMetaTags(meta) + createScriptTags(scripts) + createLinkTags(links) + createStyleTags(styles);
|
|
238
245
|
}, "");
|
|
239
246
|
}
|
|
240
247
|
function addHeadMarkup(results, stringBuilder) {
|
package/build/es/utils.js
CHANGED
|
@@ -243,6 +243,12 @@ function createLinkTags(links) {
|
|
|
243
243
|
return linkStr + `<link href="${href}"${relStr}${asStr}${fetchStr}>\n`;
|
|
244
244
|
}, '');
|
|
245
245
|
}
|
|
246
|
+
function createStyleTags(styles) {
|
|
247
|
+
return styles.reduce((styleStr, { body, id }) => {
|
|
248
|
+
const idStr = id ? ` id="${id}"` : '';
|
|
249
|
+
return styleStr + `<style type="text/css"${idStr}>${body}</style>\n`;
|
|
250
|
+
}, '');
|
|
251
|
+
}
|
|
246
252
|
/**
|
|
247
253
|
* Serialize SsrDataResponse.markup into an HTML string
|
|
248
254
|
* @param results An array of responses from getServerData hooks
|
|
@@ -252,13 +258,17 @@ export function createHeadMarkup(results) {
|
|
|
252
258
|
// Loop through the <title>, <script>, <meta>, and <link> tag information
|
|
253
259
|
// Create an HTML string for each tag
|
|
254
260
|
let hasTitle = false;
|
|
255
|
-
return results.reduce((str, { markup: { title, scripts = [], meta = [], links = [] } = {} }) => {
|
|
261
|
+
return results.reduce((str, { markup: { title, scripts = [], meta = [], links = [], styles = [] } = {} }) => {
|
|
256
262
|
if (title && !hasTitle) {
|
|
257
263
|
// first <title> wins
|
|
258
264
|
hasTitle = true;
|
|
259
265
|
str += `<title>${title}</title>\n`;
|
|
260
266
|
}
|
|
261
|
-
return str +
|
|
267
|
+
return (str +
|
|
268
|
+
createMetaTags(meta) +
|
|
269
|
+
createScriptTags(scripts) +
|
|
270
|
+
createLinkTags(links) +
|
|
271
|
+
createStyleTags(styles));
|
|
262
272
|
}, '');
|
|
263
273
|
}
|
|
264
274
|
/**
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.13.
|
|
7
|
+
"version": "0.13.2",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"build/**/*.d.ts"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@lwrjs/config": "0.13.
|
|
46
|
-
"@lwrjs/diagnostics": "0.13.
|
|
47
|
-
"@lwrjs/instrumentation": "0.13.
|
|
48
|
-
"@lwrjs/loader": "0.13.
|
|
49
|
-
"@lwrjs/shared-utils": "0.13.
|
|
45
|
+
"@lwrjs/config": "0.13.2",
|
|
46
|
+
"@lwrjs/diagnostics": "0.13.2",
|
|
47
|
+
"@lwrjs/instrumentation": "0.13.2",
|
|
48
|
+
"@lwrjs/loader": "0.13.2",
|
|
49
|
+
"@lwrjs/shared-utils": "0.13.2",
|
|
50
50
|
"fs-extra": "^11.2.0",
|
|
51
51
|
"lru-cache": "^10.4.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@lwrjs/types": "0.13.
|
|
54
|
+
"@lwrjs/types": "0.13.2",
|
|
55
55
|
"jest": "^26.6.3",
|
|
56
56
|
"mock-fs": "^5.2.0",
|
|
57
57
|
"ts-jest": "^26.5.6"
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"volta": {
|
|
63
63
|
"extends": "../../../package.json"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "607ec6610069ef1214b4c20f146ab97225554405"
|
|
66
66
|
}
|