@lwrjs/lwc-ssr 0.7.1 → 0.8.0-alpha.0
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.
|
@@ -36,18 +36,21 @@ import Ctor, * as rootComponent from '${rootSpecifier}';
|
|
|
36
36
|
|
|
37
37
|
(async () => {
|
|
38
38
|
try {
|
|
39
|
-
|
|
39
|
+
// 1. setup props
|
|
40
|
+
const context = globalThis.getContext();
|
|
41
|
+
let props = context.props;
|
|
40
42
|
if (rootComponent.getProps) {
|
|
41
43
|
const data = await rootComponent.getProps({
|
|
42
|
-
|
|
43
|
-
params: globalThis.context.params,
|
|
44
|
-
query: globalThis.context.query,
|
|
45
|
-
locale: globalThis.context.locale,
|
|
44
|
+
...context,
|
|
46
45
|
fetch: globalThis.fetch,
|
|
47
46
|
});
|
|
48
47
|
props = data.props; // overwrite public props
|
|
49
48
|
}
|
|
49
|
+
|
|
50
|
+
// 2. render component
|
|
50
51
|
const result = renderComponent('${(0, import_shared_utils.moduleSpecifierToKebabCase)(rootSpecifier)}', Ctor, props || {});
|
|
52
|
+
|
|
53
|
+
// 3. relay results
|
|
51
54
|
globalThis.postMessage({ result, props });
|
|
52
55
|
} catch(e) {
|
|
53
56
|
globalThis.postMessage({ error: e });
|
|
@@ -30,7 +30,7 @@ var import_worker_threads = __toModule(require("worker_threads"));
|
|
|
30
30
|
var HEADER = "/* This module is generated and meant to be used in a Server context */";
|
|
31
31
|
var WORKER_CODE_SANDBOX_APIS = [
|
|
32
32
|
`const { parentPort, workerData } = require('worker_threads');`,
|
|
33
|
-
`globalThis.
|
|
33
|
+
`globalThis.getContext = () => workerData;`,
|
|
34
34
|
`globalThis.fetch = require('node-fetch');`,
|
|
35
35
|
`globalThis.postMessage = (...args) => parentPort.postMessage(...args);`
|
|
36
36
|
];
|
|
@@ -20,18 +20,21 @@ import Ctor, * as rootComponent from '${rootSpecifier}';
|
|
|
20
20
|
|
|
21
21
|
(async () => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
// 1. setup props
|
|
24
|
+
const context = globalThis.getContext();
|
|
25
|
+
let props = context.props;
|
|
24
26
|
if (rootComponent.getProps) {
|
|
25
27
|
const data = await rootComponent.getProps({
|
|
26
|
-
|
|
27
|
-
params: globalThis.context.params,
|
|
28
|
-
query: globalThis.context.query,
|
|
29
|
-
locale: globalThis.context.locale,
|
|
28
|
+
...context,
|
|
30
29
|
fetch: globalThis.fetch,
|
|
31
30
|
});
|
|
32
31
|
props = data.props; // overwrite public props
|
|
33
32
|
}
|
|
33
|
+
|
|
34
|
+
// 2. render component
|
|
34
35
|
const result = renderComponent('${moduleSpecifierToKebabCase(rootSpecifier)}', Ctor, props || {});
|
|
36
|
+
|
|
37
|
+
// 3. relay results
|
|
35
38
|
globalThis.postMessage({ result, props });
|
|
36
39
|
} catch(e) {
|
|
37
40
|
globalThis.postMessage({ error: e });
|
|
@@ -2,8 +2,8 @@ import { Worker } from 'worker_threads';
|
|
|
2
2
|
const HEADER = '/* This module is generated and meant to be used in a Server context */';
|
|
3
3
|
/**
|
|
4
4
|
* Sandbox APIs
|
|
5
|
-
* @param globalThis.
|
|
6
|
-
* context such as props, params, and locale
|
|
5
|
+
* @param globalThis.getContext
|
|
6
|
+
* function to provide prop request context object with properties such as props, params, and locale
|
|
7
7
|
*
|
|
8
8
|
* @param globalThis.fetch
|
|
9
9
|
* fetch function for external data fetching
|
|
@@ -13,7 +13,7 @@ const HEADER = '/* This module is generated and meant to be used in a Server con
|
|
|
13
13
|
*/
|
|
14
14
|
const WORKER_CODE_SANDBOX_APIS = [
|
|
15
15
|
`const { parentPort, workerData } = require('worker_threads');`,
|
|
16
|
-
`globalThis.
|
|
16
|
+
`globalThis.getContext = () => workerData;`,
|
|
17
17
|
`globalThis.fetch = require('node-fetch');`,
|
|
18
18
|
`globalThis.postMessage = (...args) => parentPort.postMessage(...args);`,
|
|
19
19
|
];
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.8.0-alpha.0",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"build/**/*.d.ts"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@lwrjs/diagnostics": "0.
|
|
37
|
-
"@lwrjs/shared-utils": "0.
|
|
36
|
+
"@lwrjs/diagnostics": "0.8.0-alpha.0",
|
|
37
|
+
"@lwrjs/shared-utils": "0.8.0-alpha.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@lwrjs/types": "0.
|
|
40
|
+
"@lwrjs/types": "0.8.0-alpha.0"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=14.15.4 <19"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "2e1f60ed13f9f8079f1333af9b614cd24715f3ad"
|
|
46
46
|
}
|