@lwrjs/client-modules 0.10.0-alpha.7 → 0.10.0-alpha.9
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BOOTSTRAP_END as e}from"lwr/metrics";import{logOperationStart as t}from"lwr/profiler";import
|
|
1
|
+
import{BOOTSTRAP_END as e}from"lwr/metrics";import{logOperationStart as t}from"lwr/profiler";import{hydrateComponent as o,createElement as r}from"lwc";function n(e,t){return r(e,{is:t})}function c(e){return e.replace(/\/v\/[a-zA-Z0-9-_.]+$/,"").replace("/","-").replace(/([A-Z])/g,(e=>`-${e.toLowerCase()}`))}const l=/-([a-z])/g;function i(e){return e.replace(l,(e=>e[1].toUpperCase()))}function d(r,l={}){if("undefined"!=typeof customElements&&"undefined"!=typeof document){const e=document.querySelector("[lwr-root]");r.forEach((([t,r])=>{const d=c(t);let s=document.body.querySelector(d);if(s){document.querySelectorAll(d).forEach((e=>{const t=e.dataset.lwrPropsId;if(t){const n=l[t]||{};!function(e,t,r){o(e,t,r)}(e,r,n)}else{const t=n(d,r);for(const{name:o,value:r}of e.attributes){t.setAttribute(o,r);const e=i(o);e in t&&(t[e]=r)}for(;e.childNodes.length>0;)t.appendChild(e.childNodes[0]);e.parentElement?e.parentElement.replaceChild(t,e):console&&console.error("[lwr/init] parentElement not set: %o",e)}}))}else s=n(d,r),e?e.appendChild(s):document.body.appendChild(s)}))}t({id:e})}export{i as getPropFromAttrName,d as init,c as toKebabCase};
|
|
@@ -6,11 +6,17 @@ import { BOOTSTRAP_END } from 'lwr/metrics';
|
|
|
6
6
|
import { logOperationStart } from 'lwr/profiler';
|
|
7
7
|
|
|
8
8
|
// TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted - tmp
|
|
9
|
-
import
|
|
9
|
+
import { createElement } from 'lwc';
|
|
10
|
+
|
|
11
|
+
// <hydrateComponentProxy> - This code is removed in core
|
|
12
|
+
import { hydrateComponent } from 'lwc';
|
|
13
|
+
function hydrateComponentProxy(customElement, Ctor, props) {
|
|
14
|
+
hydrateComponent(customElement, Ctor, props);
|
|
15
|
+
}
|
|
16
|
+
// </hydrateComponentProxy>
|
|
17
|
+
|
|
10
18
|
function initializeWebComponent(elementName, Ctor) {
|
|
11
|
-
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
return lwc.createElement(elementName, {
|
|
19
|
+
return createElement(elementName, {
|
|
14
20
|
is: Ctor
|
|
15
21
|
});
|
|
16
22
|
}
|
|
@@ -65,18 +71,16 @@ export function init(rootModules, ssrProps = {}) {
|
|
|
65
71
|
document.body.appendChild(el);
|
|
66
72
|
}
|
|
67
73
|
} else {
|
|
68
|
-
// We have rendered/
|
|
74
|
+
// We have rendered/ssr-ed an HTML page and we need to reify the components
|
|
69
75
|
// Due to the bug described on the header, for each custom element
|
|
70
|
-
// we collect the attributes and we replace the element with the new synthetic
|
|
76
|
+
// we collect the attributes and we replace the element with the new synthetic constructor
|
|
71
77
|
const customElements = document.querySelectorAll(elementName);
|
|
72
78
|
customElements.forEach(customElement => {
|
|
73
79
|
const propsId = customElement.dataset.lwrPropsId;
|
|
74
80
|
if (propsId) {
|
|
75
81
|
// Hydrate an SSRed component
|
|
76
82
|
const props = ssrProps[propsId] || {};
|
|
77
|
-
|
|
78
|
-
// @ts-ignore
|
|
79
|
-
lwc.hydrateComponent(customElement, ctor, props);
|
|
83
|
+
hydrateComponentProxy(customElement, ctor, props);
|
|
80
84
|
} else {
|
|
81
85
|
// Create a CSRed component
|
|
82
86
|
const newElement = initializeWebComponent(elementName, ctor);
|
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.9",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -26,18 +26,21 @@
|
|
|
26
26
|
"build/**/*.d.ts"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
|
-
"build": "
|
|
29
|
+
"build:ts": "tsc -b",
|
|
30
|
+
"build": "yarn build:ts && node ../../../bin/pack-lwc --dir modules build/modules && yarn build:locker && yarn build:bundle",
|
|
30
31
|
"build:locker": "rollup --config ./scripts/rollup.config.locker.js",
|
|
31
|
-
"build:bundle": "rollup --config scripts/rollup.moduleBundle.config.cjs"
|
|
32
|
+
"build:bundle": "rollup --config scripts/rollup.moduleBundle.config.cjs",
|
|
33
|
+
"build:platform": "node scripts/strip-for-core.js"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
36
|
"@locker/sandbox": "0.19.0",
|
|
35
|
-
"@lwrjs/shared-utils": "0.10.0-alpha.
|
|
37
|
+
"@lwrjs/shared-utils": "0.10.0-alpha.9"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
39
41
|
"@rollup/plugin-sucrase": "^5.0.1",
|
|
40
42
|
"@rollup/plugin-terser": "^0.4.1",
|
|
43
|
+
"fs-extra": "^9.1.0",
|
|
41
44
|
"rollup": "^2.78.0"
|
|
42
45
|
},
|
|
43
46
|
"lwc": {
|
|
@@ -63,5 +66,5 @@
|
|
|
63
66
|
"volta": {
|
|
64
67
|
"extends": "../../../package.json"
|
|
65
68
|
},
|
|
66
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "6da48f5164ac881396055096a6c1e3d0f8d981aa"
|
|
67
70
|
}
|