New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lwrjs/client-modules

Package Overview
Dependencies
Maintainers
5
Versions
489
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lwrjs/client-modules - npm Package Compare versions

Comparing version 0.17.2-alpha.4 to 0.17.2-alpha.5

2

build/bundle/prod/lwr/init/init.js

@@ -1,2 +0,2 @@

import{BOOTSTRAP_END as e,INIT as r,INIT_MODULE as t}from"lwr/metrics";import{logOperationStart as o,logOperationEnd as n}from"lwr/profiler";import{hydrateComponent as i,createElement as c}from"lwc";function d(e,r,t){i(e,r,t)}const s=50;let f=performance.now();function p(){const e=performance.now();return e-f>s&&(f=e,!0)}function a(e,r){return c(e,{is:r})}function l(e){return e.replace(/\/v\/[a-zA-Z0-9-_.]+$/,"").replace("/","-").replace(/([A-Z])/g,(e=>`-${e.toLowerCase()}`))}const u=/-([a-z])/g;function m(e){return e.replace(u,(e=>e[1].toUpperCase()))}function w(i,c={}){if("undefined"==typeof customElements||"undefined"==typeof document)return void o({id:e});o({id:r});let s=0;for(const[e,r]of i){const i=l(e);if(!document.body.querySelector(i)){o({id:t,specifier:e,specifierIndex:++s});const c=a(i,r),d=document.querySelector("[lwr-root]");d?d.appendChild(c):document.body.appendChild(c),n({id:t,specifier:e,specifierIndex:s,metadata:{renderMode:"spa"}});continue}const f=document.querySelectorAll(i);for(const l of f){o({id:t,specifier:e,specifierIndex:++s});const f=l.dataset.lwrPropsId;if(f){p()?setTimeout((()=>{d(l,r,c[f]||{})}),0):d(l,r,c[f]||{}),n({id:t,specifier:e,specifierIndex:s,metadata:{renderMode:"ssr"}});continue}const u=a(i,r);for(const{name:e,value:r}of l.attributes){u.setAttribute(e,r);const t=m(e);t in u&&(u[t]=r)}for(;l.childNodes.length>0;)u.appendChild(l.childNodes[0]);const w=l.parentElement;w&&w.replaceChild(u,l),n({id:t,specifier:e,specifierIndex:s,metadata:{renderMode:"csr"}})}}n({id:r}),o({id:e})}export{m as getPropFromAttrName,w as init,l as toKebabCase};
import{BOOTSTRAP_END as e,INIT as o,INIT_MODULE as r}from"lwr/metrics";import{logOperationStart as i,logOperationEnd as t}from"lwr/profiler";import{hydrateComponent as n,createElement as c}from"lwc";function s(e,o,r){n(e,o,r)}const d=(()=>{if(!globalThis.performance)return()=>!1;let e=globalThis.performance.now();return()=>{const o=globalThis.performance.now();return o-e>50&&(e=o,!0)}})();function l(e,o){return c(e,{is:o})}function a(e){return e.replace(/\/v\/[a-zA-Z0-9-_.]+$/,"").replace("/","-").replace(/([A-Z])/g,(e=>`-${e.toLowerCase()}`))}const p=/-([a-z])/g;function f(e){return e.replace(p,(e=>e[1].toUpperCase()))}function u(n,c={}){if(void 0===globalThis.customElements||void 0===globalThis.document)return void i({id:e});i({id:o});let p=0;const u=globalThis.document;for(const[e,o]of n){const n=a(e);if(!u.body.querySelector(n)){i({id:r,specifier:e,specifierIndex:++p});const c=l(n,o),s=u.querySelector("[lwr-root]");s?s.appendChild(c):u.body.appendChild(c),t({id:r,specifier:e,specifierIndex:p,metadata:{renderMode:"spa"}});continue}const m=u.querySelectorAll(n);for(const a of m){i({id:r,specifier:e,specifierIndex:++p});const u=a.dataset.lwrPropsId;if(u){d()&&void 0!==globalThis.setTimeout?globalThis.setTimeout((()=>{s(a,o,c[u]||{})}),0):s(a,o,c[u]||{}),t({id:r,specifier:e,specifierIndex:p,metadata:{renderMode:"ssr"}});continue}const m=l(n,o);for(const{name:e,value:o}of a.attributes){m.setAttribute(e,o);const r=f(e);r in m&&(m[r]=o)}for(;a.childNodes.length>0;)m.appendChild(a.childNodes[0]);const h=a.parentElement;h&&h.replaceChild(m,a),t({id:r,specifier:e,specifierIndex:p,metadata:{renderMode:"csr"}})}}t({id:o}),i({id:e})}export{f as getPropFromAttrName,u as init,a as toKebabCase};
//# sourceMappingURL=init.js.map
import { BOOTSTRAP_END, INIT, INIT_MODULE } from 'lwr/metrics';
import { logOperationStart, logOperationEnd } from 'lwr/profiler';
// TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted - tmp
// eslint-disable-next-line lwr/only-allowed-imports
import { createElement } from 'lwc';
// <hydrateComponentProxy> - This code is removed in core
// Note: a build step uses these comments to strip the code for core.
// eslint-disable-next-line lwr/only-allowed-imports
import { hydrateComponent } from 'lwc';

@@ -12,14 +14,22 @@ function hydrateComponentProxy(customElement, Ctor, props) {

// </hydrateComponentProxy>
// Break up hydration tasks into timed batches.
// Borrowed from https://tinyurl.com/5b4fw7eb
const HYDRATION_TASK_BATCH_DURATION = 50;
let timeOfLastYield = performance.now();
function shouldYield() {
const now = performance.now();
if (now - timeOfLastYield > HYDRATION_TASK_BATCH_DURATION) {
timeOfLastYield = now;
return true;
const shouldYield = (() => {
// eslint-disable-next-line lwr/no-unguarded-apis
if (!globalThis.performance) {
return () => false;
}
return false;
}
// Break up hydration tasks into timed batches.
// Borrowed from https://tinyurl.com/5b4fw7eb
const HYDRATION_TASK_BATCH_DURATION = 50;
// eslint-disable-next-line lwr/no-unguarded-apis
let timeOfLastYield = globalThis.performance.now();
return () => {
// eslint-disable-next-line lwr/no-unguarded-apis
const now = globalThis.performance.now();
if (now - timeOfLastYield > HYDRATION_TASK_BATCH_DURATION) {
timeOfLastYield = now;
return true;
}
return false;
};
})();
function initializeWebComponent(elementName, Ctor) {

@@ -60,3 +70,4 @@ return createElement(elementName, { is: Ctor });

export function init(rootModules, serverData = {}) {
if (typeof customElements === 'undefined' || typeof document === 'undefined') {
// eslint-disable-next-line lwr/no-unguarded-apis
if (typeof globalThis.customElements === 'undefined' || typeof globalThis.document === 'undefined') {
logOperationStart({ id: BOOTSTRAP_END });

@@ -67,5 +78,8 @@ return;

let index = 0;
// eslint-disable-next-line lwr/no-unguarded-apis
const document = globalThis.document;
for (const [specifier, ctor] of rootModules) {
const elementName = toKebabCase(specifier);
// initialize and inject the root module into the LWR Root or DOM if it is missing
// eslint-disable-next-line lwr/no-unguarded-apis
if (!document.body.querySelector(elementName)) {

@@ -75,3 +89,5 @@ logOperationStart({ id: INIT_MODULE, specifier, specifierIndex: ++index });

const component = initializeWebComponent(elementName, ctor);
// eslint-disable-next-line lwr/no-unguarded-apis
const container = document.querySelector('[lwr-root]');
// eslint-disable-next-line lwr/no-unguarded-apis
container ? container.appendChild(component) : document.body.appendChild(component);

@@ -87,2 +103,3 @@ logOperationEnd({

// the page has been rendered or SSR'd, and each component needs to initialized(or hydrated)
// eslint-disable-next-line lwr/no-unguarded-apis
const elements = document.querySelectorAll(elementName);

@@ -94,5 +111,7 @@ for (const element of elements) {

if (propsId) {
if (shouldYield()) {
// eslint-disable-next-line lwr/no-unguarded-apis
if (shouldYield() && globalThis.setTimeout !== undefined) {
// give room for the browser to render during long hydration tasks
setTimeout(() => {
// eslint-disable-next-line lwr/no-unguarded-apis
globalThis.setTimeout(() => {
hydrateComponentProxy(element, ctor, serverData[propsId] || {});

@@ -99,0 +118,0 @@ }, 0);

@@ -13,2 +13,3 @@ var Phase;

// e.g. JSDom (used in Jest) doesn't implement these
// eslint-disable-next-line
const perf = globalThis.performance;

@@ -15,0 +16,0 @@ const isPerfSupported = typeof perf !== 'undefined' &&

@@ -0,1 +1,3 @@

// eslint-disable-next-line lwr/only-allowed-type-imports
import { BOOTSTRAP_END, INIT, INIT_MODULE } from 'lwr/metrics';

@@ -5,2 +7,3 @@ import { logOperationStart, logOperationEnd } from 'lwr/profiler';

// TODO: This is a temporal workaround until https://github.com/salesforce/lwc/pull/2083 is sorted - tmp
// eslint-disable-next-line lwr/only-allowed-imports
import { createElement } from 'lwc';

@@ -10,2 +13,3 @@

// Note: a build step uses these comments to strip the code for core.
// eslint-disable-next-line lwr/only-allowed-imports
import { hydrateComponent } from 'lwc';

@@ -17,14 +21,23 @@ function hydrateComponentProxy(customElement, Ctor, props) {

// Break up hydration tasks into timed batches.
// Borrowed from https://tinyurl.com/5b4fw7eb
const HYDRATION_TASK_BATCH_DURATION = 50;
let timeOfLastYield = performance.now();
function shouldYield() {
const now = performance.now();
if (now - timeOfLastYield > HYDRATION_TASK_BATCH_DURATION) {
timeOfLastYield = now;
return true;
const shouldYield = (() => {
// eslint-disable-next-line lwr/no-unguarded-apis
if (!globalThis.performance) {
return () => false;
}
return false;
}
// Break up hydration tasks into timed batches.
// Borrowed from https://tinyurl.com/5b4fw7eb
const HYDRATION_TASK_BATCH_DURATION = 50;
// eslint-disable-next-line lwr/no-unguarded-apis
let timeOfLastYield = globalThis.performance.now();
return () => {
// eslint-disable-next-line lwr/no-unguarded-apis
const now = globalThis.performance.now();
if (now - timeOfLastYield > HYDRATION_TASK_BATCH_DURATION) {
timeOfLastYield = now;
return true;
}
return false;
};
})();
function initializeWebComponent(elementName, Ctor) {

@@ -67,3 +80,4 @@ return createElement(elementName, {

export function init(rootModules, serverData = {}) {
if (typeof customElements === 'undefined' || typeof document === 'undefined') {
// eslint-disable-next-line lwr/no-unguarded-apis
if (typeof globalThis.customElements === 'undefined' || typeof globalThis.document === 'undefined') {
logOperationStart({

@@ -78,2 +92,4 @@ id: BOOTSTRAP_END

let index = 0;
// eslint-disable-next-line lwr/no-unguarded-apis
const document = globalThis.document;
for (const [specifier, ctor] of rootModules) {

@@ -83,2 +99,3 @@ const elementName = toKebabCase(specifier);

// initialize and inject the root module into the LWR Root or DOM if it is missing
// eslint-disable-next-line lwr/no-unguarded-apis
if (!document.body.querySelector(elementName)) {

@@ -93,3 +110,5 @@ logOperationStart({

const component = initializeWebComponent(elementName, ctor);
// eslint-disable-next-line lwr/no-unguarded-apis
const container = document.querySelector('[lwr-root]');
// eslint-disable-next-line lwr/no-unguarded-apis
container ? container.appendChild(component) : document.body.appendChild(component);

@@ -108,2 +127,3 @@ logOperationEnd({

// the page has been rendered or SSR'd, and each component needs to initialized(or hydrated)
// eslint-disable-next-line lwr/no-unguarded-apis
const elements = document.querySelectorAll(elementName);

@@ -120,5 +140,7 @@ for (const element of elements) {

if (propsId) {
if (shouldYield()) {
// eslint-disable-next-line lwr/no-unguarded-apis
if (shouldYield() && globalThis.setTimeout !== undefined) {
// give room for the browser to render during long hydration tasks
setTimeout(() => {
// eslint-disable-next-line lwr/no-unguarded-apis
globalThis.setTimeout(() => {
hydrateComponentProxy(element, ctor, serverData[propsId] || {});

@@ -125,0 +147,0 @@ }, 0);

@@ -14,2 +14,3 @@ var Phase = /*#__PURE__*/function (Phase) {

// e.g. JSDom (used in Jest) doesn't implement these
// eslint-disable-next-line
const perf = globalThis.performance;

@@ -16,0 +17,0 @@ const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';

@@ -7,3 +7,3 @@ {

},
"version": "0.17.2-alpha.4",
"version": "0.17.2-alpha.5",
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",

@@ -38,6 +38,6 @@ "repository": {

"@locker/sandbox": "0.23.6",
"@lwrjs/shared-utils": "0.17.2-alpha.4"
"@lwrjs/shared-utils": "0.17.2-alpha.5"
},
"devDependencies": {
"@lwrjs/types": "0.17.2-alpha.4",
"@lwrjs/types": "0.17.2-alpha.5",
"@rollup/plugin-node-resolve": "^15.2.3",

@@ -75,3 +75,3 @@ "@rollup/plugin-sucrase": "^5.0.2",

},
"gitHead": "d7fb1605cec0bf9fef18e3daeb17dc28b35a80d3"
"gitHead": "b87daf19f22c54126ccaf01e0f899aabe6265885"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc