@farm.js/react 0.1.0-beta.33 → 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/README.md +7 -0
- package/dist/compiler-runtime.cjs +9 -0
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +2 -1
- package/dist/compiler-runtime.d.ts +2 -1
- package/dist/compiler-runtime.mjs +9 -1
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +56 -7
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +56 -7
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
package/dist/vite.cjs
CHANGED
|
@@ -76,6 +76,7 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
|
|
|
76
76
|
"keyed-rows-hinted": "keyedRowsHintedRuntimeFeature",
|
|
77
77
|
"keyed-rows-append-only": "keyedRowsAppendOnlyRuntimeFeature",
|
|
78
78
|
"keyed-rows-position-hinted": "keyedRowsPositionHintedRuntimeFeature",
|
|
79
|
+
"keyed-rows-plain-position-hinted": "keyedRowsPlainPositionHintedRuntimeFeature",
|
|
79
80
|
"keyed-rows-batch-position-hinted": "keyedRowsBatchPositionHintedRuntimeFeature",
|
|
80
81
|
"keyed-rows-window-position-hinted": "keyedRowsWindowPositionHintedRuntimeFeature",
|
|
81
82
|
"keyed-rows-reorder-hinted": "keyedRowsReorderHintedRuntimeFeature",
|
|
@@ -187,6 +188,8 @@ function runtimeFeaturesForPlans(plans, keyedUpdateHints, keyedArrayFilterHints,
|
|
|
187
188
|
features.add("keyed-rows-filter-only");
|
|
188
189
|
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-prepend-hinted" && keyedTargetKinds.size === 0 && !keyedMapOrAppendHints) {
|
|
189
190
|
features.add("keyed-rows-prepend-only");
|
|
191
|
+
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-position-hinted" && keyedTargetKinds.size === 0) {
|
|
192
|
+
features.add("keyed-rows-plain-position-hinted");
|
|
190
193
|
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-reorder-hinted" && keyedTargetKinds.size === 0) {
|
|
191
194
|
features.add("keyed-rows-plain-reorder-hinted");
|
|
192
195
|
} else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-map-reorder-hinted" && keyedTargetKinds.size === 0) {
|
|
@@ -3285,6 +3288,43 @@ function stabilizeDeferredEventCurrentTargets(root, compilerSetters) {
|
|
|
3285
3288
|
const expression = file.program.body[0].expression;
|
|
3286
3289
|
return core.types.isJSXElement(expression) ? expression : core.types.cloneNode(root, true);
|
|
3287
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
|
+
}
|
|
3288
3328
|
function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters, keyedTargetReactiveByValue) {
|
|
3289
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])) {
|
|
3290
3330
|
return {
|
|
@@ -3304,7 +3344,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3304
3344
|
if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3305
3345
|
return "compiled keyed rows support host elements only";
|
|
3306
3346
|
}
|
|
3307
|
-
if (
|
|
3347
|
+
if (isForeignContent(element)) return "compiled keyed rows do not support SVG yet";
|
|
3308
3348
|
const attributeNames = new Set(
|
|
3309
3349
|
element.openingElement.attributes.filter((attribute) => core.types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
|
|
3310
3350
|
);
|
|
@@ -3334,7 +3374,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
|
|
|
3334
3374
|
}
|
|
3335
3375
|
const name = jsxAttributeName(attribute);
|
|
3336
3376
|
if (!name) return "compiled keyed rows do not support namespaced JSX attributes";
|
|
3337
|
-
if (name === "ref" || name === "dangerouslySetInnerHTML") {
|
|
3377
|
+
if (name === "ref" || name === "dangerouslySetInnerHTML" || reactOwnedAttribute(name, attribute)) {
|
|
3338
3378
|
return `compiled keyed row ${name} requires React ownership`;
|
|
3339
3379
|
}
|
|
3340
3380
|
if (name === "key") continue;
|
|
@@ -3702,7 +3742,7 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
|
|
|
3702
3742
|
if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3703
3743
|
return "compiler-owned conditionals support host elements only";
|
|
3704
3744
|
}
|
|
3705
|
-
if (
|
|
3745
|
+
if (isForeignContent(element)) return "compiler-owned conditionals do not support SVG yet";
|
|
3706
3746
|
for (const attribute of element.openingElement.attributes) {
|
|
3707
3747
|
if (core.types.isJSXSpreadAttribute(attribute)) {
|
|
3708
3748
|
if (statefulOnly && !needsStaticBinding(attribute.argument)) continue;
|
|
@@ -3710,6 +3750,9 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
|
|
|
3710
3750
|
}
|
|
3711
3751
|
const name = jsxAttributeName(attribute);
|
|
3712
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
|
+
}
|
|
3713
3756
|
if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
|
|
3714
3757
|
if (statefulOnly && (!core.types.isJSXExpressionContainer(attribute.value) || core.types.isJSXEmptyExpression(attribute.value.expression) || !needsStaticBinding(attribute.value.expression))) {
|
|
3715
3758
|
continue;
|
|
@@ -3822,13 +3865,18 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
|
|
|
3822
3865
|
if (!core.types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
|
|
3823
3866
|
return "recursive compiler-owned blocks support host elements only";
|
|
3824
3867
|
}
|
|
3825
|
-
if (
|
|
3868
|
+
if (isForeignContent(element)) {
|
|
3869
|
+
return "recursive compiler-owned blocks do not support SVG yet";
|
|
3870
|
+
}
|
|
3826
3871
|
for (const attribute of element.openingElement.attributes) {
|
|
3827
3872
|
if (core.types.isJSXSpreadAttribute(attribute)) {
|
|
3828
3873
|
return "recursive compiler-owned blocks do not support JSX attribute spreads";
|
|
3829
3874
|
}
|
|
3830
3875
|
const name = jsxAttributeName(attribute);
|
|
3831
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
|
+
}
|
|
3832
3880
|
if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
|
|
3833
3881
|
return `recursive compiler-owned block ${name} requires React ownership`;
|
|
3834
3882
|
}
|
|
@@ -4189,7 +4237,7 @@ function analyzeCompilerOwnedKeyedRowHostBlocks(shape, statesByValue, safeGlobal
|
|
|
4189
4237
|
}
|
|
4190
4238
|
function analyzeHostConditionalContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
|
|
4191
4239
|
const containerName = container.openingElement.name;
|
|
4192
|
-
if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) ||
|
|
4240
|
+
if (!core.types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container)) {
|
|
4193
4241
|
return void 0;
|
|
4194
4242
|
}
|
|
4195
4243
|
if (container.openingElement.attributes.some(
|
|
@@ -4254,7 +4302,7 @@ function analyzeHostConditionalContainer(container, statesByValue, safeGlobals,
|
|
|
4254
4302
|
}
|
|
4255
4303
|
function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals, allowSingleRange, listNames, parent, allocateId) {
|
|
4256
4304
|
const containerName = container.openingElement.name;
|
|
4257
|
-
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(
|
|
4258
4306
|
(attribute) => core.types.isJSXSpreadAttribute(attribute) || core.types.isJSXAttribute(attribute) && core.types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
|
|
4259
4307
|
)) {
|
|
4260
4308
|
return void 0;
|
|
@@ -4350,7 +4398,7 @@ function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals
|
|
|
4350
4398
|
}
|
|
4351
4399
|
function analyzeMixedRangesContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
|
|
4352
4400
|
const containerName = container.openingElement.name;
|
|
4353
|
-
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(
|
|
4354
4402
|
(attribute) => core.types.isJSXSpreadAttribute(attribute) || core.types.isJSXAttribute(attribute) && core.types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
|
|
4355
4403
|
)) {
|
|
4356
4404
|
return void 0;
|
|
@@ -7535,6 +7583,7 @@ async function compileReactModule(code, id, options) {
|
|
|
7535
7583
|
visitor: {
|
|
7536
7584
|
Program(programPath) {
|
|
7537
7585
|
const moduleDirectives = new Set(directiveValues(programPath.node));
|
|
7586
|
+
markForeignContent(programPath);
|
|
7538
7587
|
const useStateNames = /* @__PURE__ */ new Set();
|
|
7539
7588
|
const reactNames = /* @__PURE__ */ new Set();
|
|
7540
7589
|
const listNames = /* @__PURE__ */ new Set();
|