@lwc/ssr-runtime 0.0.1 → 6.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.md +88 -0
- package/dist/index.cjs.js +144 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +137 -0
- package/dist/index.js.map +1 -0
- package/package.json +45 -6
- package/README.md +0 -3
package/LICENSE.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# LWC core license
|
2
|
+
|
3
|
+
MIT LICENSE
|
4
|
+
|
5
|
+
Copyright (c) 2024, Salesforce, Inc.
|
6
|
+
All rights reserved.
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
13
|
+
|
14
|
+
# Licenses of bundled dependencies
|
15
|
+
|
16
|
+
## @parse5/tools
|
17
|
+
|
18
|
+
MIT license defined in package.json in v0.4.0.
|
19
|
+
|
20
|
+
## entities
|
21
|
+
|
22
|
+
Copyright (c) Felix Böhm
|
23
|
+
All rights reserved.
|
24
|
+
|
25
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
26
|
+
|
27
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
28
|
+
|
29
|
+
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
30
|
+
|
31
|
+
THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
|
32
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
|
34
|
+
## estree-walker
|
35
|
+
|
36
|
+
Copyright (c) 2015-20 [these people](https://github.com/Rich-Harris/estree-walker/graphs/contributors)
|
37
|
+
|
38
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
39
|
+
|
40
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
43
|
+
|
44
|
+
## observable-membrane
|
45
|
+
|
46
|
+
MIT License
|
47
|
+
|
48
|
+
Copyright (c) 2017 Salesforce
|
49
|
+
|
50
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
51
|
+
of this software and associated documentation files (the "Software"), to deal
|
52
|
+
in the Software without restriction, including without limitation the rights
|
53
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
54
|
+
copies of the Software, and to permit persons to whom the Software is
|
55
|
+
furnished to do so, subject to the following conditions:
|
56
|
+
|
57
|
+
The above copyright notice and this permission notice shall be included in all
|
58
|
+
copies or substantial portions of the Software.
|
59
|
+
|
60
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
61
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
62
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
63
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
64
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
65
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
66
|
+
SOFTWARE.
|
67
|
+
|
68
|
+
## parse5
|
69
|
+
|
70
|
+
Copyright (c) 2013-2019 Ivan Nikulin (ifaaan@gmail.com, https://github.com/inikulin)
|
71
|
+
|
72
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
73
|
+
of this software and associated documentation files (the "Software"), to deal
|
74
|
+
in the Software without restriction, including without limitation the rights
|
75
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
76
|
+
copies of the Software, and to permit persons to whom the Software is
|
77
|
+
furnished to do so, subject to the following conditions:
|
78
|
+
|
79
|
+
The above copyright notice and this permission notice shall be included in
|
80
|
+
all copies or substantial portions of the Software.
|
81
|
+
|
82
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
83
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
84
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
85
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
86
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
87
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
88
|
+
THE SOFTWARE.
|
@@ -0,0 +1,144 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2024 Salesforce, Inc.
|
3
|
+
*/
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
7
|
+
|
8
|
+
/*
|
9
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
10
|
+
* All rights reserved.
|
11
|
+
* SPDX-License-Identifier: MIT
|
12
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
13
|
+
*/
|
14
|
+
const MULTI_SPACE = /\s+/g;
|
15
|
+
class ClassList {
|
16
|
+
constructor(el) {
|
17
|
+
this.el = el;
|
18
|
+
}
|
19
|
+
add(...newClassNames) {
|
20
|
+
const className = this.el.className;
|
21
|
+
const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
|
22
|
+
for (const newClassName of newClassNames) {
|
23
|
+
set.add(newClassName);
|
24
|
+
}
|
25
|
+
this.el.className = Array.from(set).join(' ');
|
26
|
+
}
|
27
|
+
contains(className) {
|
28
|
+
const currentClassNameStr = this.el.className;
|
29
|
+
return currentClassNameStr.split(MULTI_SPACE).includes(className);
|
30
|
+
}
|
31
|
+
remove(...classNamesToRemove) {
|
32
|
+
const className = this.el.className;
|
33
|
+
const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
|
34
|
+
for (const newClassName of classNamesToRemove) {
|
35
|
+
set.delete(newClassName);
|
36
|
+
}
|
37
|
+
this.el.className = Array.from(set).join(' ');
|
38
|
+
}
|
39
|
+
replace(oldClassName, newClassName) {
|
40
|
+
let classWasReplaced = false;
|
41
|
+
const className = this.el.className;
|
42
|
+
const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
|
43
|
+
listOfClasses.forEach((value, idx) => {
|
44
|
+
if (value === oldClassName) {
|
45
|
+
classWasReplaced = true;
|
46
|
+
listOfClasses[idx] = newClassName;
|
47
|
+
}
|
48
|
+
});
|
49
|
+
this.el.className = listOfClasses.join(' ');
|
50
|
+
return classWasReplaced;
|
51
|
+
}
|
52
|
+
toggle(classNameToToggle, force) {
|
53
|
+
const classNameStr = this.el.className;
|
54
|
+
const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
|
55
|
+
if (!set.has(classNameToToggle) && force !== false) {
|
56
|
+
set.add(classNameToToggle);
|
57
|
+
}
|
58
|
+
else if (set.has(classNameToToggle) && force !== true) {
|
59
|
+
set.delete(classNameToToggle);
|
60
|
+
}
|
61
|
+
this.el.className = Array.from(set).join(' ');
|
62
|
+
return set.has(classNameToToggle);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
class LightningElement {
|
66
|
+
constructor(propsAvailableAtConstruction) {
|
67
|
+
this.isConnected = false;
|
68
|
+
this.className = '';
|
69
|
+
this.__classList = null;
|
70
|
+
Object.assign(this, propsAvailableAtConstruction);
|
71
|
+
}
|
72
|
+
// TODO [W-14977927]: protect internals from userland
|
73
|
+
__internal__setState(props, reflectedProps, attrs) {
|
74
|
+
Object.assign(this, props);
|
75
|
+
this.__attrs = attrs;
|
76
|
+
// Whenever a reflected prop changes, we'll update the original props object
|
77
|
+
// that was passed in. That'll be referenced when the attrs are rendered later.
|
78
|
+
for (const reflectedPropName of reflectedProps) {
|
79
|
+
Object.defineProperty(this, reflectedPropName, {
|
80
|
+
get() {
|
81
|
+
return props[reflectedPropName] ?? null;
|
82
|
+
},
|
83
|
+
set(newValue) {
|
84
|
+
props[reflectedPropName] = newValue;
|
85
|
+
},
|
86
|
+
enumerable: true,
|
87
|
+
});
|
88
|
+
}
|
89
|
+
Object.defineProperty(this, 'className', {
|
90
|
+
get() {
|
91
|
+
return props.class ?? '';
|
92
|
+
},
|
93
|
+
set(newVal) {
|
94
|
+
props.class = newVal;
|
95
|
+
attrs.class = newVal;
|
96
|
+
},
|
97
|
+
});
|
98
|
+
}
|
99
|
+
get classList() {
|
100
|
+
if (this.__classList) {
|
101
|
+
return this.__classList;
|
102
|
+
}
|
103
|
+
return (this.__classList = new ClassList(this));
|
104
|
+
}
|
105
|
+
getAttribute(attrName) {
|
106
|
+
const value = this.__attrs?.[attrName];
|
107
|
+
return value === true ? '' : value ?? null;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&').replaceAll('"', '"');
|
111
|
+
function* renderAttrs(attrs) {
|
112
|
+
if (!attrs) {
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
for (const [key, val] of Object.entries(attrs)) {
|
116
|
+
if (val) {
|
117
|
+
if (typeof val === 'string') {
|
118
|
+
yield ` ${key}="${escapeAttrVal(val)}"`;
|
119
|
+
}
|
120
|
+
else {
|
121
|
+
yield ` ${key}`;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
|
127
|
+
if (Cmp.renderMode !== 'light') {
|
128
|
+
yield '<template shadowrootmode="open"></template>';
|
129
|
+
}
|
130
|
+
}
|
131
|
+
async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props) {
|
132
|
+
let markup = '';
|
133
|
+
for await (const segment of compiledGenerateMarkup(tagName, props, null, null)) {
|
134
|
+
markup += segment;
|
135
|
+
}
|
136
|
+
return markup;
|
137
|
+
}
|
138
|
+
|
139
|
+
exports.LightningElement = LightningElement;
|
140
|
+
exports.fallbackTmpl = fallbackTmpl;
|
141
|
+
exports.renderAttrs = renderAttrs;
|
142
|
+
exports.serverSideRenderComponent = serverSideRenderComponent;
|
143
|
+
/** version: 6.6.0 */
|
144
|
+
//# sourceMappingURL=index.cjs.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAAA;;;;;AAKG;AAEH,MAAM,WAAW,GAAG,MAAM,CAAC;AAM3B,MAAM,SAAS,CAAA;AAGX,IAAA,WAAA,CAAY,EAAoB,EAAA;AAC5B,QAAA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;KAChB;IAED,GAAG,CAAC,GAAG,aAAuB,EAAA;AAC1B,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;AACpC,QAAA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,QAAA,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;AACtC,YAAA,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;SACzB;AACD,QAAA,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC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AAEhD,UAAE,WAAW,CAAC,KAAiB,EAAA;IAC1C,IAAI,CAAC,KAAK,EAAE;QACR,OAAO;KACV;AACD,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC5C,IAAI,GAAG,EAAE;AACL,YAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;gBACzB,MAAM,CAAA,CAAA,EAAI,GAAG,CAAK,EAAA,EAAA,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;aAC3C;iBAAM;gBACH,MAAM,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,CAAC;aACnB;SACJ;KACJ;AACL,CAAC;AAEc,UAAE,YAAY,CACzB,MAAe,EACf,MAAe,EACf,QAAiB,EACjB,GAAgC,EAChC,SAAkB,EAAA;AAElB,IAAA,IAAI,GAAG,CAAC,UAAU,KAAK,OAAO,EAAE;AAC5B,QAAA,MAAM,6CAA6C,CAAC;KACvD;AACL,CAAC;AASM,eAAe,yBAAyB,CAC3C,OAAe,EACf,sBAAwC,EACxC,KAA0B,EAAA;IAE1B,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,IAAA,WAAW,MAAM,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;QAC5E,MAAM,IAAI,OAAO,CAAC;KACrB;AAED,IAAA,OAAO,MAAM,CAAC;AAClB;;;;;;;;;;"}
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
type Attributes = Record<string, string | true>;
|
2
|
+
type LightningElementConstructor = typeof LightningElement;
|
3
|
+
declare class ClassList {
|
4
|
+
el: LightningElement;
|
5
|
+
constructor(el: LightningElement);
|
6
|
+
add(...newClassNames: string[]): void;
|
7
|
+
contains(className: string): boolean;
|
8
|
+
remove(...classNamesToRemove: string[]): void;
|
9
|
+
replace(oldClassName: string, newClassName: string): boolean;
|
10
|
+
toggle(classNameToToggle: string, force?: boolean): boolean;
|
11
|
+
}
|
12
|
+
export declare class LightningElement {
|
13
|
+
static renderMode?: 'light' | 'shadow';
|
14
|
+
isConnected: boolean;
|
15
|
+
className: string;
|
16
|
+
__attrs?: Attributes;
|
17
|
+
__classList: ClassList | null;
|
18
|
+
constructor(propsAvailableAtConstruction: Record<string, any>);
|
19
|
+
__internal__setState(props: Record<string, any>, reflectedProps: string[], attrs: Record<string, any>): void;
|
20
|
+
get classList(): ClassList;
|
21
|
+
getAttribute(attrName: string): string | null;
|
22
|
+
}
|
23
|
+
export declare function renderAttrs(attrs: Attributes): Generator<string, void, unknown>;
|
24
|
+
export declare function fallbackTmpl(_props: unknown, _attrs: unknown, _slotted: unknown, Cmp: LightningElementConstructor, _instance: unknown): Generator<string, void, unknown>;
|
25
|
+
export type GenerateMarkupFn = (tagName: string, props: Record<string, any> | null, attrs: Attributes | null, slotted: Record<number | string, AsyncGenerator<string>> | null) => AsyncGenerator<string>;
|
26
|
+
export declare function serverSideRenderComponent(tagName: string, compiledGenerateMarkup: GenerateMarkupFn, props: Record<string, any>): Promise<string>;
|
27
|
+
export {};
|
package/dist/index.js
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2024 Salesforce, Inc.
|
3
|
+
*/
|
4
|
+
/*
|
5
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
6
|
+
* All rights reserved.
|
7
|
+
* SPDX-License-Identifier: MIT
|
8
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
9
|
+
*/
|
10
|
+
const MULTI_SPACE = /\s+/g;
|
11
|
+
class ClassList {
|
12
|
+
constructor(el) {
|
13
|
+
this.el = el;
|
14
|
+
}
|
15
|
+
add(...newClassNames) {
|
16
|
+
const className = this.el.className;
|
17
|
+
const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
|
18
|
+
for (const newClassName of newClassNames) {
|
19
|
+
set.add(newClassName);
|
20
|
+
}
|
21
|
+
this.el.className = Array.from(set).join(' ');
|
22
|
+
}
|
23
|
+
contains(className) {
|
24
|
+
const currentClassNameStr = this.el.className;
|
25
|
+
return currentClassNameStr.split(MULTI_SPACE).includes(className);
|
26
|
+
}
|
27
|
+
remove(...classNamesToRemove) {
|
28
|
+
const className = this.el.className;
|
29
|
+
const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
|
30
|
+
for (const newClassName of classNamesToRemove) {
|
31
|
+
set.delete(newClassName);
|
32
|
+
}
|
33
|
+
this.el.className = Array.from(set).join(' ');
|
34
|
+
}
|
35
|
+
replace(oldClassName, newClassName) {
|
36
|
+
let classWasReplaced = false;
|
37
|
+
const className = this.el.className;
|
38
|
+
const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
|
39
|
+
listOfClasses.forEach((value, idx) => {
|
40
|
+
if (value === oldClassName) {
|
41
|
+
classWasReplaced = true;
|
42
|
+
listOfClasses[idx] = newClassName;
|
43
|
+
}
|
44
|
+
});
|
45
|
+
this.el.className = listOfClasses.join(' ');
|
46
|
+
return classWasReplaced;
|
47
|
+
}
|
48
|
+
toggle(classNameToToggle, force) {
|
49
|
+
const classNameStr = this.el.className;
|
50
|
+
const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
|
51
|
+
if (!set.has(classNameToToggle) && force !== false) {
|
52
|
+
set.add(classNameToToggle);
|
53
|
+
}
|
54
|
+
else if (set.has(classNameToToggle) && force !== true) {
|
55
|
+
set.delete(classNameToToggle);
|
56
|
+
}
|
57
|
+
this.el.className = Array.from(set).join(' ');
|
58
|
+
return set.has(classNameToToggle);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
class LightningElement {
|
62
|
+
constructor(propsAvailableAtConstruction) {
|
63
|
+
this.isConnected = false;
|
64
|
+
this.className = '';
|
65
|
+
this.__classList = null;
|
66
|
+
Object.assign(this, propsAvailableAtConstruction);
|
67
|
+
}
|
68
|
+
// TODO [W-14977927]: protect internals from userland
|
69
|
+
__internal__setState(props, reflectedProps, attrs) {
|
70
|
+
Object.assign(this, props);
|
71
|
+
this.__attrs = attrs;
|
72
|
+
// Whenever a reflected prop changes, we'll update the original props object
|
73
|
+
// that was passed in. That'll be referenced when the attrs are rendered later.
|
74
|
+
for (const reflectedPropName of reflectedProps) {
|
75
|
+
Object.defineProperty(this, reflectedPropName, {
|
76
|
+
get() {
|
77
|
+
return props[reflectedPropName] ?? null;
|
78
|
+
},
|
79
|
+
set(newValue) {
|
80
|
+
props[reflectedPropName] = newValue;
|
81
|
+
},
|
82
|
+
enumerable: true,
|
83
|
+
});
|
84
|
+
}
|
85
|
+
Object.defineProperty(this, 'className', {
|
86
|
+
get() {
|
87
|
+
return props.class ?? '';
|
88
|
+
},
|
89
|
+
set(newVal) {
|
90
|
+
props.class = newVal;
|
91
|
+
attrs.class = newVal;
|
92
|
+
},
|
93
|
+
});
|
94
|
+
}
|
95
|
+
get classList() {
|
96
|
+
if (this.__classList) {
|
97
|
+
return this.__classList;
|
98
|
+
}
|
99
|
+
return (this.__classList = new ClassList(this));
|
100
|
+
}
|
101
|
+
getAttribute(attrName) {
|
102
|
+
const value = this.__attrs?.[attrName];
|
103
|
+
return value === true ? '' : value ?? null;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&').replaceAll('"', '"');
|
107
|
+
function* renderAttrs(attrs) {
|
108
|
+
if (!attrs) {
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
for (const [key, val] of Object.entries(attrs)) {
|
112
|
+
if (val) {
|
113
|
+
if (typeof val === 'string') {
|
114
|
+
yield ` ${key}="${escapeAttrVal(val)}"`;
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
yield ` ${key}`;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
|
123
|
+
if (Cmp.renderMode !== 'light') {
|
124
|
+
yield '<template shadowrootmode="open"></template>';
|
125
|
+
}
|
126
|
+
}
|
127
|
+
async function serverSideRenderComponent(tagName, compiledGenerateMarkup, props) {
|
128
|
+
let markup = '';
|
129
|
+
for await (const segment of compiledGenerateMarkup(tagName, props, null, null)) {
|
130
|
+
markup += segment;
|
131
|
+
}
|
132
|
+
return markup;
|
133
|
+
}
|
134
|
+
|
135
|
+
export { LightningElement, fallbackTmpl, renderAttrs, serverSideRenderComponent };
|
136
|
+
/** version: 6.6.0 */
|
137
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAEH,MAAM,WAAW,GAAG,MAAM,CAAC;AAM3B,MAAM,SAAS,CAAA;AAGX,IAAA,WAAA,CAAY,EAAoB,EAAA;AAC5B,QAAA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;KAChB;IAED,GAAG,CAAC,GAAG,aAAuB,EAAA;AAC1B,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;AACpC,QAAA,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,QAAA,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;AACtC,YAAA,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;SACzB;AACD,QAAA,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACjD;AAED,IAAA,QAAQ,CAAC,SAAiB,EAAA;AACtB,QAAA,MAAM,mBAAmB,GAAG,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC;QAC9C,OAAO,mBAAmB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,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L,YAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;gBACzB,MAAM,CAAA,CAAA,EAAI,GAAG,CAAK,EAAA,EAAA,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;aAC3C;iBAAM;gBACH,MAAM,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,CAAC;aACnB;SACJ;KACJ;AACL,CAAC;AAEc,UAAE,YAAY,CACzB,MAAe,EACf,MAAe,EACf,QAAiB,EACjB,GAAgC,EAChC,SAAkB,EAAA;AAElB,IAAA,IAAI,GAAG,CAAC,UAAU,KAAK,OAAO,EAAE;AAC5B,QAAA,MAAM,6CAA6C,CAAC;KACvD;AACL,CAAC;AASM,eAAe,yBAAyB,CAC3C,OAAe,EACf,sBAAwC,EACxC,KAA0B,EAAA;IAE1B,IAAI,MAAM,GAAG,EAAE,CAAC;AAEhB,IAAA,WAAW,MAAM,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;QAC5E,MAAM,IAAI,OAAO,CAAC;KACrB;AAED,IAAA,OAAO,MAAM,CAAC;AAClB;;;;;;;"}
|
package/package.json
CHANGED
@@ -1,8 +1,47 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
"//": [
|
3
|
+
"THIS FILE IS AUTOGENERATED. If you modify it, it will be rewritten by check-and-rewrite-package-json.js",
|
4
|
+
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
|
5
|
+
],
|
6
|
+
"name": "@lwc/ssr-runtime",
|
7
|
+
"version": "6.6.0",
|
8
|
+
"description": "Runtime complement to @lwc/ssr-compiler",
|
9
|
+
"keywords": [
|
10
|
+
"lwc",
|
11
|
+
"runtime",
|
12
|
+
"ssr"
|
13
|
+
],
|
14
|
+
"homepage": "https://lwc.dev",
|
15
|
+
"repository": {
|
16
|
+
"type": "git",
|
17
|
+
"url": "https://github.com/salesforce/lwc.git",
|
18
|
+
"directory": "packages/@lwc/ssr-runtime"
|
19
|
+
},
|
20
|
+
"bugs": {
|
21
|
+
"url": "https://github.com/salesforce/lwc/issues"
|
22
|
+
},
|
23
|
+
"license": "MIT",
|
24
|
+
"publishConfig": {
|
25
|
+
"access": "public"
|
26
|
+
},
|
27
|
+
"main": "dist/index.cjs.js",
|
28
|
+
"module": "dist/index.js",
|
29
|
+
"types": "dist/index.d.ts",
|
30
|
+
"files": [
|
31
|
+
"dist"
|
32
|
+
],
|
33
|
+
"scripts": {
|
34
|
+
"build": "rollup --config ../../../scripts/rollup/rollup.config.js",
|
35
|
+
"dev": "rollup --config ../../../scripts/rollup/rollup.config.js --watch --no-watch.clearScreen"
|
36
|
+
},
|
37
|
+
"nx": {
|
38
|
+
"targets": {
|
39
|
+
"build": {
|
40
|
+
"outputs": [
|
41
|
+
"{projectRoot}/dist"
|
42
|
+
]
|
43
|
+
}
|
44
|
+
}
|
45
|
+
},
|
46
|
+
"dependencies": {}
|
8
47
|
}
|
package/README.md
DELETED