@barefootjs/client 0.1.3 → 0.3.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/runtime/apply-rest-attrs.d.ts.map +1 -1
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/index.js +219 -111
- package/dist/runtime/map-array.d.ts.map +1 -1
- package/dist/runtime/render.d.ts.map +1 -1
- package/dist/runtime/spread-attrs.d.ts +4 -7
- package/dist/runtime/spread-attrs.d.ts.map +1 -1
- package/dist/runtime/standalone.js +219 -111
- package/package.json +3 -4
- package/src/runtime/apply-rest-attrs.ts +28 -42
- package/src/runtime/component.ts +31 -20
- package/src/runtime/hydrate.ts +6 -0
- package/src/runtime/map-array.ts +11 -0
- package/src/runtime/render.ts +32 -10
- package/src/runtime/spread-attrs.ts +13 -63
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-rest-attrs.d.ts","sourceRoot":"","sources":["../../src/runtime/apply-rest-attrs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"apply-rest-attrs.d.ts","sourceRoot":"","sources":["../../src/runtime/apply-rest-attrs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,OAAO,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,WAAW,EAAE,MAAM,EAAE,GACpB,IAAI,CA4DN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAExD;AAWD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;GAGG;AACH;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAA;IACd,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,GAAG,YAAY,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,IAAI,CAAC,EAAE,uBAAuB,GAC7B,WAAW,
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAS3C,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAExD;AAWD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;;;GAGG;AACH;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAA;IACd,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAA;CACd;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,GAAG,YAAY,EAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,IAAI,CAAC,EAAE,uBAAuB,GAC7B,WAAW,CAoIb;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAE3F;AAuBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAE7G;AAGD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EACrB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAiDR;AA+DD;;;;;GAKG;AACH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAcjF"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -123,6 +123,156 @@ var BF_KEY = "data-key";
|
|
|
123
123
|
var BF_ASYNC = "bf-async";
|
|
124
124
|
var BF_ASYNC_RESOLVE = "bf-async-resolve";
|
|
125
125
|
var BF_PARENT_SCOPE_PLACEHOLDER = "__BF_PARENT_SCOPE__";
|
|
126
|
+
// ../shared/src/dom-prop.ts
|
|
127
|
+
var BOOLEAN_ATTRS = new Set([
|
|
128
|
+
"checked",
|
|
129
|
+
"disabled",
|
|
130
|
+
"readonly",
|
|
131
|
+
"selected",
|
|
132
|
+
"required",
|
|
133
|
+
"hidden",
|
|
134
|
+
"autofocus",
|
|
135
|
+
"autoplay",
|
|
136
|
+
"controls",
|
|
137
|
+
"loop",
|
|
138
|
+
"muted",
|
|
139
|
+
"open",
|
|
140
|
+
"multiple",
|
|
141
|
+
"novalidate",
|
|
142
|
+
"formnovalidate"
|
|
143
|
+
]);
|
|
144
|
+
var SVG_CAMEL_TO_KEBAB = {
|
|
145
|
+
strokeWidth: "stroke-width",
|
|
146
|
+
strokeLinecap: "stroke-linecap",
|
|
147
|
+
strokeLinejoin: "stroke-linejoin",
|
|
148
|
+
strokeDasharray: "stroke-dasharray",
|
|
149
|
+
strokeDashoffset: "stroke-dashoffset",
|
|
150
|
+
strokeMiterlimit: "stroke-miterlimit",
|
|
151
|
+
strokeOpacity: "stroke-opacity",
|
|
152
|
+
fillOpacity: "fill-opacity",
|
|
153
|
+
fillRule: "fill-rule",
|
|
154
|
+
stopColor: "stop-color",
|
|
155
|
+
stopOpacity: "stop-opacity",
|
|
156
|
+
textAnchor: "text-anchor",
|
|
157
|
+
dominantBaseline: "dominant-baseline",
|
|
158
|
+
alignmentBaseline: "alignment-baseline",
|
|
159
|
+
fontFamily: "font-family",
|
|
160
|
+
fontSize: "font-size",
|
|
161
|
+
fontWeight: "font-weight",
|
|
162
|
+
fontStyle: "font-style",
|
|
163
|
+
letterSpacing: "letter-spacing",
|
|
164
|
+
wordSpacing: "word-spacing",
|
|
165
|
+
pointerEvents: "pointer-events",
|
|
166
|
+
vectorEffect: "vector-effect",
|
|
167
|
+
colorInterpolation: "color-interpolation",
|
|
168
|
+
clipPath: "clip-path",
|
|
169
|
+
clipRule: "clip-rule",
|
|
170
|
+
markerStart: "marker-start",
|
|
171
|
+
markerMid: "marker-mid",
|
|
172
|
+
markerEnd: "marker-end"
|
|
173
|
+
};
|
|
174
|
+
var SVG_XML_CAMEL_ATTRS = new Set([
|
|
175
|
+
"allowReorder",
|
|
176
|
+
"attributeName",
|
|
177
|
+
"attributeType",
|
|
178
|
+
"autoReverse",
|
|
179
|
+
"baseFrequency",
|
|
180
|
+
"baseProfile",
|
|
181
|
+
"calcMode",
|
|
182
|
+
"clipPathUnits",
|
|
183
|
+
"contentScriptType",
|
|
184
|
+
"contentStyleType",
|
|
185
|
+
"diffuseConstant",
|
|
186
|
+
"edgeMode",
|
|
187
|
+
"externalResourcesRequired",
|
|
188
|
+
"filterRes",
|
|
189
|
+
"filterUnits",
|
|
190
|
+
"glyphRef",
|
|
191
|
+
"gradientTransform",
|
|
192
|
+
"gradientUnits",
|
|
193
|
+
"kernelMatrix",
|
|
194
|
+
"kernelUnitLength",
|
|
195
|
+
"keyPoints",
|
|
196
|
+
"keySplines",
|
|
197
|
+
"keyTimes",
|
|
198
|
+
"lengthAdjust",
|
|
199
|
+
"limitingConeAngle",
|
|
200
|
+
"markerHeight",
|
|
201
|
+
"markerUnits",
|
|
202
|
+
"markerWidth",
|
|
203
|
+
"maskContentUnits",
|
|
204
|
+
"maskUnits",
|
|
205
|
+
"numOctaves",
|
|
206
|
+
"pathLength",
|
|
207
|
+
"patternContentUnits",
|
|
208
|
+
"patternTransform",
|
|
209
|
+
"patternUnits",
|
|
210
|
+
"pointsAtX",
|
|
211
|
+
"pointsAtY",
|
|
212
|
+
"pointsAtZ",
|
|
213
|
+
"preserveAlpha",
|
|
214
|
+
"preserveAspectRatio",
|
|
215
|
+
"primitiveUnits",
|
|
216
|
+
"refX",
|
|
217
|
+
"refY",
|
|
218
|
+
"repeatCount",
|
|
219
|
+
"repeatDur",
|
|
220
|
+
"requiredExtensions",
|
|
221
|
+
"requiredFeatures",
|
|
222
|
+
"specularConstant",
|
|
223
|
+
"specularExponent",
|
|
224
|
+
"spreadMethod",
|
|
225
|
+
"startOffset",
|
|
226
|
+
"stdDeviation",
|
|
227
|
+
"stitchTiles",
|
|
228
|
+
"surfaceScale",
|
|
229
|
+
"systemLanguage",
|
|
230
|
+
"tableValues",
|
|
231
|
+
"targetX",
|
|
232
|
+
"targetY",
|
|
233
|
+
"textLength",
|
|
234
|
+
"viewBox",
|
|
235
|
+
"viewTarget",
|
|
236
|
+
"xChannelSelector",
|
|
237
|
+
"yChannelSelector",
|
|
238
|
+
"zoomAndPan"
|
|
239
|
+
]);
|
|
240
|
+
function isEventProp(key) {
|
|
241
|
+
return key.length > 2 && key[0] === "o" && key[1] === "n" && key[2] >= "A" && key[2] <= "Z";
|
|
242
|
+
}
|
|
243
|
+
function classifyDOMProp(key) {
|
|
244
|
+
if (key === "children")
|
|
245
|
+
return { kind: "skip", attrName: key };
|
|
246
|
+
if (key === "ref")
|
|
247
|
+
return { kind: "ref", attrName: key };
|
|
248
|
+
if (isEventProp(key))
|
|
249
|
+
return { kind: "event", attrName: key };
|
|
250
|
+
const attrName = toHTMLAttrNameRuntime(key);
|
|
251
|
+
if (attrName === "style")
|
|
252
|
+
return { kind: "style", attrName };
|
|
253
|
+
if (attrName === "value")
|
|
254
|
+
return { kind: "property", attrName };
|
|
255
|
+
if (attrName === "checked")
|
|
256
|
+
return { kind: "property", attrName };
|
|
257
|
+
if (BOOLEAN_ATTRS.has(attrName.toLowerCase()))
|
|
258
|
+
return { kind: "boolean", attrName };
|
|
259
|
+
return { kind: "attr", attrName };
|
|
260
|
+
}
|
|
261
|
+
function toHTMLAttrNameRuntime(key) {
|
|
262
|
+
if (key === "className")
|
|
263
|
+
return "class";
|
|
264
|
+
if (key === "htmlFor")
|
|
265
|
+
return "for";
|
|
266
|
+
const svgKebab = SVG_CAMEL_TO_KEBAB[key];
|
|
267
|
+
if (svgKebab !== undefined)
|
|
268
|
+
return svgKebab;
|
|
269
|
+
if (SVG_XML_CAMEL_ATTRS.has(key))
|
|
270
|
+
return key;
|
|
271
|
+
if (key.startsWith("data") || key.startsWith("aria")) {
|
|
272
|
+
return key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
273
|
+
}
|
|
274
|
+
return key;
|
|
275
|
+
}
|
|
126
276
|
// src/context.ts
|
|
127
277
|
function createContext(defaultValue) {
|
|
128
278
|
return {
|
|
@@ -766,6 +916,8 @@ function hydrateCommentScope(comment) {
|
|
|
766
916
|
const proxyEl = nextElementSibling2(comment) ?? comment.parentElement;
|
|
767
917
|
if (!proxyEl)
|
|
768
918
|
return;
|
|
919
|
+
if (hydratedScopes.has(proxyEl))
|
|
920
|
+
return;
|
|
769
921
|
commentScopeRegistry.set(proxyEl, { commentNode: comment, scopeId });
|
|
770
922
|
const parsed = parseProps(propsJson || null, `comment scope ${scopeId}`);
|
|
771
923
|
const props = parsed[name] ?? {};
|
|
@@ -820,9 +972,14 @@ function createComponent(nameOrDef, props, key, slot) {
|
|
|
820
972
|
}
|
|
821
973
|
return result;
|
|
822
974
|
});
|
|
975
|
+
const def = getRegisteredDef(name);
|
|
976
|
+
const isCommentWrapper = def?.comment === true;
|
|
977
|
+
const scopeId = isCommentWrapper ? null : `${name}_${generateId()}`;
|
|
823
978
|
const prevParentScopeId = _parentScopeId;
|
|
824
979
|
if (slot?.parent) {
|
|
825
980
|
_parentScopeId = slot.parent;
|
|
981
|
+
} else if (scopeId) {
|
|
982
|
+
_parentScopeId = scopeId;
|
|
826
983
|
}
|
|
827
984
|
let html;
|
|
828
985
|
try {
|
|
@@ -835,10 +992,8 @@ function createComponent(nameOrDef, props, key, slot) {
|
|
|
835
992
|
console.warn(`[BarefootJS] Template returned empty HTML for component: ${name}`);
|
|
836
993
|
return createPlaceholder(name, key);
|
|
837
994
|
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
if (!isCommentWrapper) {
|
|
841
|
-
element.setAttribute(BF_SCOPE, `${name}_${generateId()}`);
|
|
995
|
+
if (scopeId) {
|
|
996
|
+
element.setAttribute(BF_SCOPE, scopeId);
|
|
842
997
|
}
|
|
843
998
|
if (slot) {
|
|
844
999
|
if (slot.parent)
|
|
@@ -1483,6 +1638,17 @@ function mapArray(accessor, container, getKey, renderItem, markerId) {
|
|
|
1483
1638
|
scopes.set(key, scope);
|
|
1484
1639
|
insertScope(scope, container, anchor);
|
|
1485
1640
|
}
|
|
1641
|
+
for (let i = items.length;i < existingRanges.length; i++) {
|
|
1642
|
+
const range = existingRanges[i];
|
|
1643
|
+
if (range.startMarker?.parentNode)
|
|
1644
|
+
range.startMarker.remove();
|
|
1645
|
+
if (range.primaryEl.parentNode)
|
|
1646
|
+
range.primaryEl.remove();
|
|
1647
|
+
for (const ex of range.extras) {
|
|
1648
|
+
if (ex.parentNode)
|
|
1649
|
+
ex.remove();
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1486
1652
|
return;
|
|
1487
1653
|
}
|
|
1488
1654
|
}
|
|
@@ -1580,13 +1746,6 @@ function styleToCss(value) {
|
|
|
1580
1746
|
}
|
|
1581
1747
|
|
|
1582
1748
|
// src/runtime/apply-rest-attrs.ts
|
|
1583
|
-
function toAttrName(key) {
|
|
1584
|
-
if (key === "className")
|
|
1585
|
-
return "class";
|
|
1586
|
-
if (key === "htmlFor")
|
|
1587
|
-
return "for";
|
|
1588
|
-
return key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1589
|
-
}
|
|
1590
1749
|
var jsxToDomEventMap = { doubleclick: "dblclick" };
|
|
1591
1750
|
function toEventName(jsxPropName) {
|
|
1592
1751
|
const raw = (jsxPropName[2].toLowerCase() + jsxPropName.slice(3)).toLowerCase();
|
|
@@ -1594,127 +1753,61 @@ function toEventName(jsxPropName) {
|
|
|
1594
1753
|
}
|
|
1595
1754
|
function applyRestAttrs(el, source, excludeKeys) {
|
|
1596
1755
|
const exclude = new Set(excludeKeys);
|
|
1756
|
+
const classified = [];
|
|
1597
1757
|
for (const key of Object.keys(source)) {
|
|
1598
1758
|
if (exclude.has(key))
|
|
1599
1759
|
continue;
|
|
1600
|
-
|
|
1760
|
+
classified.push({ key, c: classifyDOMProp(key) });
|
|
1761
|
+
}
|
|
1762
|
+
for (const { key, c } of classified) {
|
|
1763
|
+
if (c.kind === "ref") {
|
|
1601
1764
|
const ref = source[key];
|
|
1602
1765
|
if (typeof ref === "function")
|
|
1603
1766
|
ref(el);
|
|
1604
|
-
|
|
1605
|
-
}
|
|
1606
|
-
if (key.startsWith("on") && key.length > 2 && key[2] === key[2].toUpperCase()) {
|
|
1767
|
+
} else if (c.kind === "event") {
|
|
1607
1768
|
const handler = source[key];
|
|
1608
1769
|
if (typeof handler === "function") {
|
|
1609
1770
|
el.addEventListener(toEventName(key), handler);
|
|
1610
1771
|
}
|
|
1611
1772
|
}
|
|
1612
1773
|
}
|
|
1774
|
+
const attrEntries = classified.filter(({ c }) => c.kind !== "ref" && c.kind !== "event" && c.kind !== "skip");
|
|
1613
1775
|
createEffect2(() => {
|
|
1614
|
-
for (const key of
|
|
1615
|
-
if (exclude.has(key))
|
|
1616
|
-
continue;
|
|
1617
|
-
if (key === "ref")
|
|
1618
|
-
continue;
|
|
1619
|
-
if (key === "children")
|
|
1620
|
-
continue;
|
|
1621
|
-
if (key.startsWith("on") && key.length > 2 && key[2] === key[2].toUpperCase())
|
|
1622
|
-
continue;
|
|
1776
|
+
for (const { key, c } of attrEntries) {
|
|
1623
1777
|
const value = source[key];
|
|
1624
|
-
const attr = toAttrName(key);
|
|
1625
1778
|
if (value != null && value !== false) {
|
|
1626
|
-
if (
|
|
1779
|
+
if (c.kind === "property" && c.attrName === "value" && "value" in el) {
|
|
1627
1780
|
const strVal = String(value);
|
|
1628
1781
|
if (el.value !== strVal)
|
|
1629
1782
|
el.value = strVal;
|
|
1630
|
-
} else if (
|
|
1783
|
+
} else if (c.kind === "property" && c.attrName === "checked" && "checked" in el) {
|
|
1631
1784
|
el.checked = !!value;
|
|
1632
|
-
} else if (
|
|
1785
|
+
} else if (c.kind === "boolean") {
|
|
1786
|
+
el.setAttribute(c.attrName, "");
|
|
1787
|
+
} else if (c.kind === "style") {
|
|
1633
1788
|
const css = styleToCss(value);
|
|
1634
1789
|
if (css == null)
|
|
1635
1790
|
el.removeAttribute("style");
|
|
1636
1791
|
else
|
|
1637
1792
|
el.setAttribute("style", css);
|
|
1638
1793
|
} else {
|
|
1639
|
-
el.setAttribute(
|
|
1794
|
+
el.setAttribute(c.attrName, String(value));
|
|
1640
1795
|
}
|
|
1641
1796
|
} else {
|
|
1642
|
-
if (
|
|
1797
|
+
if (c.kind === "property" && c.attrName === "value" && "value" in el) {
|
|
1798
|
+
el.value = "";
|
|
1799
|
+
} else if (c.kind === "property" && c.attrName === "checked" && "checked" in el) {
|
|
1643
1800
|
el.checked = false;
|
|
1801
|
+
} else if (c.kind === "boolean") {
|
|
1802
|
+
el.removeAttribute(c.attrName);
|
|
1644
1803
|
} else {
|
|
1645
|
-
el.removeAttribute(
|
|
1804
|
+
el.removeAttribute(c.attrName);
|
|
1646
1805
|
}
|
|
1647
1806
|
}
|
|
1648
1807
|
}
|
|
1649
1808
|
});
|
|
1650
1809
|
}
|
|
1651
1810
|
// src/runtime/spread-attrs.ts
|
|
1652
|
-
var SVG_CAMEL_CASE_ATTRS = new Set([
|
|
1653
|
-
"allowReorder",
|
|
1654
|
-
"attributeName",
|
|
1655
|
-
"attributeType",
|
|
1656
|
-
"autoReverse",
|
|
1657
|
-
"baseFrequency",
|
|
1658
|
-
"baseProfile",
|
|
1659
|
-
"calcMode",
|
|
1660
|
-
"clipPathUnits",
|
|
1661
|
-
"contentScriptType",
|
|
1662
|
-
"contentStyleType",
|
|
1663
|
-
"diffuseConstant",
|
|
1664
|
-
"edgeMode",
|
|
1665
|
-
"externalResourcesRequired",
|
|
1666
|
-
"filterRes",
|
|
1667
|
-
"filterUnits",
|
|
1668
|
-
"glyphRef",
|
|
1669
|
-
"gradientTransform",
|
|
1670
|
-
"gradientUnits",
|
|
1671
|
-
"kernelMatrix",
|
|
1672
|
-
"kernelUnitLength",
|
|
1673
|
-
"keyPoints",
|
|
1674
|
-
"keySplines",
|
|
1675
|
-
"keyTimes",
|
|
1676
|
-
"lengthAdjust",
|
|
1677
|
-
"limitingConeAngle",
|
|
1678
|
-
"markerHeight",
|
|
1679
|
-
"markerUnits",
|
|
1680
|
-
"markerWidth",
|
|
1681
|
-
"maskContentUnits",
|
|
1682
|
-
"maskUnits",
|
|
1683
|
-
"numOctaves",
|
|
1684
|
-
"pathLength",
|
|
1685
|
-
"patternContentUnits",
|
|
1686
|
-
"patternTransform",
|
|
1687
|
-
"patternUnits",
|
|
1688
|
-
"pointsAtX",
|
|
1689
|
-
"pointsAtY",
|
|
1690
|
-
"pointsAtZ",
|
|
1691
|
-
"preserveAlpha",
|
|
1692
|
-
"preserveAspectRatio",
|
|
1693
|
-
"primitiveUnits",
|
|
1694
|
-
"refX",
|
|
1695
|
-
"refY",
|
|
1696
|
-
"repeatCount",
|
|
1697
|
-
"repeatDur",
|
|
1698
|
-
"requiredExtensions",
|
|
1699
|
-
"requiredFeatures",
|
|
1700
|
-
"specularConstant",
|
|
1701
|
-
"specularExponent",
|
|
1702
|
-
"spreadMethod",
|
|
1703
|
-
"startOffset",
|
|
1704
|
-
"stdDeviation",
|
|
1705
|
-
"stitchTiles",
|
|
1706
|
-
"surfaceScale",
|
|
1707
|
-
"systemLanguage",
|
|
1708
|
-
"tableValues",
|
|
1709
|
-
"targetX",
|
|
1710
|
-
"targetY",
|
|
1711
|
-
"textLength",
|
|
1712
|
-
"viewBox",
|
|
1713
|
-
"viewTarget",
|
|
1714
|
-
"xChannelSelector",
|
|
1715
|
-
"yChannelSelector",
|
|
1716
|
-
"zoomAndPan"
|
|
1717
|
-
]);
|
|
1718
1811
|
function spreadAttrs(obj) {
|
|
1719
1812
|
if (!obj || typeof obj !== "object")
|
|
1720
1813
|
return "";
|
|
@@ -1722,18 +1815,20 @@ function spreadAttrs(obj) {
|
|
|
1722
1815
|
for (const [key, value] of Object.entries(obj)) {
|
|
1723
1816
|
if (value == null || value === false)
|
|
1724
1817
|
continue;
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
if (key === "children")
|
|
1818
|
+
const c = classifyDOMProp(key);
|
|
1819
|
+
if (c.kind === "event" || c.kind === "skip" || c.kind === "ref")
|
|
1728
1820
|
continue;
|
|
1729
|
-
if (
|
|
1821
|
+
if (c.kind === "style") {
|
|
1730
1822
|
const css = styleToCss(value);
|
|
1731
1823
|
if (css != null)
|
|
1732
1824
|
parts.push(`style="${css}"`);
|
|
1733
1825
|
continue;
|
|
1734
1826
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1827
|
+
if (c.kind === "boolean" && value === true) {
|
|
1828
|
+
parts.push(c.attrName);
|
|
1829
|
+
} else {
|
|
1830
|
+
parts.push(`${c.attrName}="${value}"`);
|
|
1831
|
+
}
|
|
1737
1832
|
}
|
|
1738
1833
|
return parts.join(" ");
|
|
1739
1834
|
}
|
|
@@ -1996,17 +2091,30 @@ function render(container, nameOrDef, props = {}) {
|
|
|
1996
2091
|
}
|
|
1997
2092
|
const tpl = document.createElement("template");
|
|
1998
2093
|
tpl.innerHTML = html;
|
|
1999
|
-
const
|
|
2000
|
-
if (
|
|
2094
|
+
const rootElements = Array.from(tpl.content.childNodes).filter((n) => n.nodeType === Node.ELEMENT_NODE);
|
|
2095
|
+
if (rootElements.length === 0) {
|
|
2001
2096
|
throw new Error("[BarefootJS] render(): template returned empty HTML");
|
|
2002
2097
|
}
|
|
2003
|
-
if (!element.getAttribute(BF_SCOPE)) {
|
|
2004
|
-
element.setAttribute(BF_SCOPE, scopeId);
|
|
2005
|
-
}
|
|
2006
2098
|
container.innerHTML = "";
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2099
|
+
if (rootElements.length === 1) {
|
|
2100
|
+
const element = rootElements[0];
|
|
2101
|
+
if (!element.getAttribute(BF_SCOPE)) {
|
|
2102
|
+
element.setAttribute(BF_SCOPE, scopeId);
|
|
2103
|
+
}
|
|
2104
|
+
container.appendChild(element);
|
|
2105
|
+
init(element, props);
|
|
2106
|
+
hydratedScopes.add(element);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
const commentNode = document.createComment(`${BF_SCOPE_COMMENT_PREFIX}${scopeId}`);
|
|
2110
|
+
container.appendChild(commentNode);
|
|
2111
|
+
for (const node of Array.from(tpl.content.childNodes)) {
|
|
2112
|
+
container.appendChild(node);
|
|
2113
|
+
}
|
|
2114
|
+
const proxyEl = rootElements[0];
|
|
2115
|
+
commentScopeRegistry.set(proxyEl, { commentNode, scopeId });
|
|
2116
|
+
init(proxyEl, props);
|
|
2117
|
+
hydratedScopes.add(proxyEl);
|
|
2010
2118
|
}
|
|
2011
2119
|
// src/runtime/streaming.ts
|
|
2012
2120
|
function __bf_swap(id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-array.d.ts","sourceRoot":"","sources":["../../src/runtime/map-array.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA4LH;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,QAAQ,EAAE,MAAM,CAAC,EAAE,EACnB,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,EACnD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,KAAK,WAAW,EACjF,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,
|
|
1
|
+
{"version":3,"file":"map-array.d.ts","sourceRoot":"","sources":["../../src/runtime/map-array.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AA4LH;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,QAAQ,EAAE,MAAM,CAAC,EAAE,EACnB,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,EACnD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,KAAK,WAAW,EACjF,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAwKN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/runtime/render.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/runtime/render.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,KAAK,EAAE,YAAY,EAAU,MAAM,SAAS,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,MAAM,CACpB,SAAS,EAAE,WAAW,EACtB,SAAS,EAAE,MAAM,GAAG,YAAY,EAChC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,IAAI,CAiFN"}
|
|
@@ -7,13 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* Convert an object to an HTML attribute string.
|
|
10
|
-
*
|
|
11
|
-
* event handlers,
|
|
12
|
-
* prop is routed through `styleToCss` so object
|
|
13
|
-
* a real CSS string
|
|
14
|
-
*
|
|
15
|
-
* SVG attributes listed in `SVG_CAMEL_CASE_ATTRS` are preserved
|
|
16
|
-
* verbatim — the SVG XML spec is case-sensitive for those names.
|
|
10
|
+
* Uses the shared classifyDOMProp classifier to determine how each prop
|
|
11
|
+
* maps to the DOM. Skips null/undefined/false, event handlers, ref, and
|
|
12
|
+
* children. The `style` prop is routed through `styleToCss` so object
|
|
13
|
+
* literals serialize to a real CSS string.
|
|
17
14
|
*/
|
|
18
15
|
export declare function spreadAttrs(obj: Record<string, unknown>): string;
|
|
19
16
|
//# sourceMappingURL=spread-attrs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spread-attrs.d.ts","sourceRoot":"","sources":["../../src/runtime/spread-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"spread-attrs.d.ts","sourceRoot":"","sources":["../../src/runtime/spread-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAmBhE"}
|