@lwrjs/client-modules 0.10.0-alpha.6 → 0.10.0-alpha.8

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{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 d(e){return e.replace(l,(e=>e[1].toUpperCase()))}function i(r,l={}){if("undefined"!=typeof customElements&&"undefined"!=typeof document){const e=document.querySelector("[lwr-root]");r.forEach((([t,r])=>{const i=c(t);let p=document.body.querySelector(i);if(p){document.querySelectorAll(i).forEach((e=>{const t=e.dataset.lwrPropsId;if(t){const n=l[t]||{};o(e,r,n)}else{const t=n(i,r);for(const{name:o,value:r}of e.attributes){t.setAttribute(o,r);const e=d(o);e in t&&(t[e]=r)}for(;e.childNodes.length>0;)t.appendChild(e.childNodes[0]);e.parentElement.replaceChild(t,e)}}))}else p=n(i,r),e?e.appendChild(p):document.body.appendChild(p)}))}t({id:e})}export{d as getPropFromAttrName,i as init,c as toKebabCase};
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};
@@ -1,10 +1,20 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore
1
3
  import { BOOTSTRAP_END } from 'lwr/metrics';
2
- import { logOperationStart } from 'lwr/profiler';
3
-
4
- // TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted
5
4
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
5
  // @ts-ignore
7
- import { createElement, hydrateComponent } from 'lwc';
6
+ import { logOperationStart } from 'lwr/profiler';
7
+
8
+ // TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted - tmp
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
+
8
18
  function initializeWebComponent(elementName, Ctor) {
9
19
  return createElement(elementName, {
10
20
  is: Ctor
@@ -61,16 +71,16 @@ export function init(rootModules, ssrProps = {}) {
61
71
  document.body.appendChild(el);
62
72
  }
63
73
  } else {
64
- // We have rendered/ssred an HTML page and we need to reify the components
74
+ // We have rendered/ssr-ed an HTML page and we need to reify the components
65
75
  // Due to the bug described on the header, for each custom element
66
- // we collect the attributes and we replace the element with the new synthetic contructor
76
+ // we collect the attributes and we replace the element with the new synthetic constructor
67
77
  const customElements = document.querySelectorAll(elementName);
68
78
  customElements.forEach(customElement => {
69
79
  const propsId = customElement.dataset.lwrPropsId;
70
80
  if (propsId) {
71
81
  // Hydrate an SSRed component
72
82
  const props = ssrProps[propsId] || {};
73
- hydrateComponent(customElement, ctor, props);
83
+ hydrateComponentProxy(customElement, ctor, props);
74
84
  } else {
75
85
  // Create a CSRed component
76
86
  const newElement = initializeWebComponent(elementName, ctor);
@@ -90,7 +100,11 @@ export function init(rootModules, ssrProps = {}) {
90
100
  while (customElement.childNodes.length > 0) {
91
101
  newElement.appendChild(customElement.childNodes[0]);
92
102
  }
93
- customElement.parentElement.replaceChild(newElement, customElement);
103
+ if (customElement.parentElement) {
104
+ customElement.parentElement.replaceChild(newElement, customElement);
105
+ } else if (console) {
106
+ console.error(`[lwr/init] parentElement not set: %o`, customElement);
107
+ }
94
108
  }
95
109
  });
96
110
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.10.0-alpha.6",
7
+ "version": "0.10.0-alpha.8",
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": "node ../../../bin/pack-lwc --dir modules build/modules && yarn build:locker && yarn build:bundle",
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.6"
37
+ "@lwrjs/shared-utils": "0.10.0-alpha.8"
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": "9592d07bd5204eb85c9cb8b576e2a267a798ce00"
69
+ "gitHead": "46bd72343e1db7c72470033320921df3a7eff18a"
67
70
  }