@farm.js/react 0.1.0-beta.34 → 0.1.0-beta.35
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/vite.cjs +53 -7
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +53 -7
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
package/dist/vite.cjs
CHANGED
|
@@ -3288,6 +3288,43 @@ function stabilizeDeferredEventCurrentTargets(root, compilerSetters) {
|
|
|
3288
3288
|
const expression = file.program.body[0].expression;
|
|
3289
3289
|
return core.types.isJSXElement(expression) ? expression : core.types.cloneNode(root, true);
|
|
3290
3290
|
}
|
|
3291
|
+
var foreignContentElements = /* @__PURE__ */ new WeakSet();
|
|
3292
|
+
var FOREIGN_ELEMENT_NAMES = new Set(
|
|
3293
|
+
[
|
|
3294
|
+
"animate animateMotion animateTransform circle clipPath defs desc ellipse",
|
|
3295
|
+
"feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix",
|
|
3296
|
+
"feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood",
|
|
3297
|
+
"feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode",
|
|
3298
|
+
"feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile",
|
|
3299
|
+
"feTurbulence filter foreignObject g image line linearGradient marker mask",
|
|
3300
|
+
"metadata mpath path pattern polygon polyline radialGradient rect set stop svg",
|
|
3301
|
+
"switch symbol text textPath tspan use view",
|
|
3302
|
+
"math maction menclose merror mfrac mi mmultiscripts mn mo mover mpadded",
|
|
3303
|
+
"mphantom mprescripts mroot mrow ms mspace msqrt mstyle msub msubsup msup",
|
|
3304
|
+
"mtable mtd mtext mtr munder munderover semantics annotation"
|
|
3305
|
+
].join(" ").split(" ")
|
|
3306
|
+
);
|
|
3307
|
+
function markForeignContent(programPath) {
|
|
3308
|
+
programPath.traverse({
|
|
3309
|
+
JSXElement(path) {
|
|
3310
|
+
const name = path.node.openingElement.name;
|
|
3311
|
+
if (!core.types.isJSXIdentifier(name) || name.name !== "svg" && name.name !== "math") return;
|
|
3312
|
+
path.traverse({
|
|
3313
|
+
JSXElement(inner) {
|
|
3314
|
+
foreignContentElements.add(inner.node);
|
|
3315
|
+
}
|
|
3316
|
+
});
|
|
3317
|
+
}
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
function isForeignContent(element) {
|
|
3321
|
+
const name = element.openingElement.name;
|
|
3322
|
+
return foreignContentElements.has(element) || core.types.isJSXIdentifier(name) && FOREIGN_ELEMENT_NAMES.has(name.name);
|
|
3323
|
+
}
|
|
3324
|
+
function reactOwnedAttribute(name, attribute) {
|
|
3325
|
+
if (name === "defaultValue" || name === "defaultChecked") return true;
|
|
3326
|
+
return (name === "spellCheck" || name === "draggable") && !core.types.isStringLiteral(attribute.value);
|
|
3327
|
+
}
|
|
3291
3328
|
function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters, keyedTargetReactiveByValue) {
|
|
3292
3329
|
if (renderCallback.async || renderCallback.generator || renderCallback.params.length < 1 || renderCallback.params.length > 2 || !core.types.isIdentifier(renderCallback.params[0]) || renderCallback.params[1] !== void 0 && !core.types.isIdentifier(renderCallback.params[1])) {
|
|
3293
3330
|
return {
|
|
@@ -3307,7 +3344,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3307
3344
|
if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3308
3345
|
return "compiled keyed rows support host elements only";
|
|
3309
3346
|
}
|
|
3310
|
-
if (
|
|
3347
|
+
if (isForeignContent(element)) return "compiled keyed rows do not support SVG yet";
|
|
3311
3348
|
const attributeNames = new Set(
|
|
3312
3349
|
element.openingElement.attributes.filter((attribute) => core.types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
|
|
3313
3350
|
);
|
|
@@ -3337,7 +3374,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3337
3374
|
}
|
|
3338
3375
|
const name = jsxAttributeName(attribute);
|
|
3339
3376
|
if (!name) return "compiled keyed rows do not support namespaced JSX attributes";
|
|
3340
|
-
if (name === "ref" || name === "dangerouslySetInnerHTML") {
|
|
3377
|
+
if (name === "ref" || name === "dangerouslySetInnerHTML" || reactOwnedAttribute(name, attribute)) {
|
|
3341
3378
|
return `compiled keyed row ${name} requires React ownership`;
|
|
3342
3379
|
}
|
|
3343
3380
|
if (name === "key") continue;
|
|
@@ -3705,7 +3742,7 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
|
|
|
3705
3742
|
if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3706
3743
|
return "compiler-owned conditionals support host elements only";
|
|
3707
3744
|
}
|
|
3708
|
-
if (
|
|
3745
|
+
if (isForeignContent(element)) return "compiler-owned conditionals do not support SVG yet";
|
|
3709
3746
|
for (const attribute of element.openingElement.attributes) {
|
|
3710
3747
|
if (core.types.isJSXSpreadAttribute(attribute)) {
|
|
3711
3748
|
if (statefulOnly && !needsStaticBinding(attribute.argument)) continue;
|
|
@@ -3713,6 +3750,9 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
|
|
|
3713
3750
|
}
|
|
3714
3751
|
const name = jsxAttributeName(attribute);
|
|
3715
3752
|
if (!name) return "compiler-owned conditionals do not support namespaced JSX attributes";
|
|
3753
|
+
if (reactOwnedAttribute(name, attribute)) {
|
|
3754
|
+
return `compiler-owned conditional ${name} requires React ownership`;
|
|
3755
|
+
}
|
|
3716
3756
|
if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
|
|
3717
3757
|
if (statefulOnly && (!core.types.isJSXExpressionContainer(attribute.value) || core.types.isJSXEmptyExpression(attribute.value.expression) || !needsStaticBinding(attribute.value.expression))) {
|
|
3718
3758
|
continue;
|
|
@@ -3825,13 +3865,18 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
|
|
|
3825
3865
|
if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3826
3866
|
return "recursive compiler-owned blocks support host elements only";
|
|
3827
3867
|
}
|
|
3828
|
-
if (
|
|
3868
|
+
if (isForeignContent(element)) {
|
|
3869
|
+
return "recursive compiler-owned blocks do not support SVG yet";
|
|
3870
|
+
}
|
|
3829
3871
|
for (const attribute of element.openingElement.attributes) {
|
|
3830
3872
|
if (core.types.isJSXSpreadAttribute(attribute)) {
|
|
3831
3873
|
return "recursive compiler-owned blocks do not support JSX attribute spreads";
|
|
3832
3874
|
}
|
|
3833
3875
|
const name = jsxAttributeName(attribute);
|
|
3834
3876
|
if (!name) return "recursive compiler-owned blocks do not support namespaced attributes";
|
|
3877
|
+
if (reactOwnedAttribute(name, attribute)) {
|
|
3878
|
+
return `recursive compiler-owned block ${name} requires React ownership`;
|
|
3879
|
+
}
|
|
3835
3880
|
if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
|
|
3836
3881
|
return `recursive compiler-owned block ${name} requires React ownership`;
|
|
3837
3882
|
}
|
|
@@ -4192,7 +4237,7 @@ function analyzeCompilerOwnedKeyedRowHostBlocks(shape, statesByValue, safeGlobal
|
|
|
4192
4237
|
}
|
|
4193
4238
|
function analyzeHostConditionalContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
|
|
4194
4239
|
const containerName = container.openingElement.name;
|
|
4195
|
-
if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) ||
|
|
4240
|
+
if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container)) {
|
|
4196
4241
|
return void 0;
|
|
4197
4242
|
}
|
|
4198
4243
|
if (container.openingElement.attributes.some(
|
|
@@ -4257,7 +4302,7 @@ function analyzeHostConditionalContainer(container, statesByValue, safeGlobals,
|
|
|
4257
4302
|
}
|
|
4258
4303
|
function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals, allowSingleRange, listNames, parent, allocateId) {
|
|
4259
4304
|
const containerName = container.openingElement.name;
|
|
4260
|
-
if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) ||
|
|
4305
|
+
if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container) || container.openingElement.attributes.some(
|
|
4261
4306
|
(attribute) => core.types.isJSXSpreadAttribute(attribute) || core.types.isJSXAttribute(attribute) && core.types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
|
|
4262
4307
|
)) {
|
|
4263
4308
|
return void 0;
|
|
@@ -4353,7 +4398,7 @@ function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals
|
|
|
4353
4398
|
}
|
|
4354
4399
|
function analyzeMixedRangesContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
|
|
4355
4400
|
const containerName = container.openingElement.name;
|
|
4356
|
-
if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) ||
|
|
4401
|
+
if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container) || container.openingElement.attributes.some(
|
|
4357
4402
|
(attribute) => core.types.isJSXSpreadAttribute(attribute) || core.types.isJSXAttribute(attribute) && core.types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
|
|
4358
4403
|
)) {
|
|
4359
4404
|
return void 0;
|
|
@@ -7538,6 +7583,7 @@ async function compileReactModule(code, id, options) {
|
|
|
7538
7583
|
visitor: {
|
|
7539
7584
|
Program(programPath) {
|
|
7540
7585
|
const moduleDirectives = new Set(directiveValues(programPath.node));
|
|
7586
|
+
markForeignContent(programPath);
|
|
7541
7587
|
const useStateNames = /* @__PURE__ */ new Set();
|
|
7542
7588
|
const reactNames = /* @__PURE__ */ new Set();
|
|
7543
7589
|
const listNames = /* @__PURE__ */ new Set();
|