wc-compiler 0.8.0 → 0.9.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.
- package/dist/wcc.dist.cjs +8 -4
- package/package.json +1 -1
- package/src/wcc.js +8 -4
package/dist/wcc.dist.cjs
CHANGED
|
@@ -28098,7 +28098,7 @@ async function getTagName(moduleURL) {
|
|
|
28098
28098
|
return tagName;
|
|
28099
28099
|
}
|
|
28100
28100
|
|
|
28101
|
-
async function initializeCustomElement(elementURL, tagName, attrs = [], definitions = [], isEntry) {
|
|
28101
|
+
async function initializeCustomElement(elementURL, tagName, attrs = [], definitions = [], isEntry, props = {}) {
|
|
28102
28102
|
if (!tagName) {
|
|
28103
28103
|
const depth = isEntry ? 1 : 0;
|
|
28104
28104
|
registerDependencies(elementURL, definitions, depth);
|
|
@@ -28110,7 +28110,11 @@ async function initializeCustomElement(elementURL, tagName, attrs = [], definiti
|
|
|
28110
28110
|
? customElements.get(tagName)
|
|
28111
28111
|
: (await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(pathname)).default;
|
|
28112
28112
|
const dataLoader = (await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(pathname)).getData;
|
|
28113
|
-
const data =
|
|
28113
|
+
const data = props
|
|
28114
|
+
? props
|
|
28115
|
+
: dataLoader
|
|
28116
|
+
? await dataLoader(props)
|
|
28117
|
+
: {};
|
|
28114
28118
|
|
|
28115
28119
|
if (element) {
|
|
28116
28120
|
const elementInstance = new element(data); // eslint-disable-line new-cap
|
|
@@ -28132,11 +28136,11 @@ async function initializeCustomElement(elementURL, tagName, attrs = [], definiti
|
|
|
28132
28136
|
}
|
|
28133
28137
|
}
|
|
28134
28138
|
|
|
28135
|
-
async function renderToString(elementURL, wrappingEntryTag = true) {
|
|
28139
|
+
async function renderToString(elementURL, wrappingEntryTag = true, props = {}) {
|
|
28136
28140
|
const definitions = [];
|
|
28137
28141
|
const elementTagName = wrappingEntryTag && await getTagName(elementURL);
|
|
28138
28142
|
const isEntry = !!elementTagName;
|
|
28139
|
-
const elementInstance = await initializeCustomElement(elementURL, undefined, undefined, definitions, isEntry);
|
|
28143
|
+
const elementInstance = await initializeCustomElement(elementURL, undefined, undefined, definitions, isEntry, props);
|
|
28140
28144
|
|
|
28141
28145
|
const elementHtml = elementInstance.shadowRoot
|
|
28142
28146
|
? elementInstance.getInnerHTML({ includeShadowRoots: true })
|
package/package.json
CHANGED
package/src/wcc.js
CHANGED
|
@@ -126,7 +126,7 @@ async function getTagName(moduleURL) {
|
|
|
126
126
|
return tagName;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
async function initializeCustomElement(elementURL, tagName, attrs = [], definitions = [], isEntry) {
|
|
129
|
+
async function initializeCustomElement(elementURL, tagName, attrs = [], definitions = [], isEntry, props = {}) {
|
|
130
130
|
if (!tagName) {
|
|
131
131
|
const depth = isEntry ? 1 : 0;
|
|
132
132
|
registerDependencies(elementURL, definitions, depth);
|
|
@@ -138,7 +138,11 @@ async function initializeCustomElement(elementURL, tagName, attrs = [], definiti
|
|
|
138
138
|
? customElements.get(tagName)
|
|
139
139
|
: (await import(pathname)).default;
|
|
140
140
|
const dataLoader = (await import(pathname)).getData;
|
|
141
|
-
const data =
|
|
141
|
+
const data = props
|
|
142
|
+
? props
|
|
143
|
+
: dataLoader
|
|
144
|
+
? await dataLoader(props)
|
|
145
|
+
: {};
|
|
142
146
|
|
|
143
147
|
if (element) {
|
|
144
148
|
const elementInstance = new element(data); // eslint-disable-line new-cap
|
|
@@ -160,11 +164,11 @@ async function initializeCustomElement(elementURL, tagName, attrs = [], definiti
|
|
|
160
164
|
}
|
|
161
165
|
}
|
|
162
166
|
|
|
163
|
-
async function renderToString(elementURL, wrappingEntryTag = true) {
|
|
167
|
+
async function renderToString(elementURL, wrappingEntryTag = true, props = {}) {
|
|
164
168
|
const definitions = [];
|
|
165
169
|
const elementTagName = wrappingEntryTag && await getTagName(elementURL);
|
|
166
170
|
const isEntry = !!elementTagName;
|
|
167
|
-
const elementInstance = await initializeCustomElement(elementURL, undefined, undefined, definitions, isEntry);
|
|
171
|
+
const elementInstance = await initializeCustomElement(elementURL, undefined, undefined, definitions, isEntry, props);
|
|
168
172
|
|
|
169
173
|
const elementHtml = elementInstance.shadowRoot
|
|
170
174
|
? elementInstance.getInnerHTML({ includeShadowRoots: true })
|