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