@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/dist/vite.mjs CHANGED
@@ -74,6 +74,7 @@ var COMPILER_RUNTIME_FEATURE_EXPORTS = {
74
74
  "keyed-rows-hinted": "keyedRowsHintedRuntimeFeature",
75
75
  "keyed-rows-append-only": "keyedRowsAppendOnlyRuntimeFeature",
76
76
  "keyed-rows-position-hinted": "keyedRowsPositionHintedRuntimeFeature",
77
+ "keyed-rows-plain-position-hinted": "keyedRowsPlainPositionHintedRuntimeFeature",
77
78
  "keyed-rows-batch-position-hinted": "keyedRowsBatchPositionHintedRuntimeFeature",
78
79
  "keyed-rows-window-position-hinted": "keyedRowsWindowPositionHintedRuntimeFeature",
79
80
  "keyed-rows-reorder-hinted": "keyedRowsReorderHintedRuntimeFeature",
@@ -185,6 +186,8 @@ function runtimeFeaturesForPlans(plans, keyedUpdateHints, keyedArrayFilterHints,
185
186
  features.add("keyed-rows-filter-only");
186
187
  } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-prepend-hinted" && keyedTargetKinds.size === 0 && !keyedMapOrAppendHints) {
187
188
  features.add("keyed-rows-prepend-only");
189
+ } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-position-hinted" && keyedTargetKinds.size === 0) {
190
+ features.add("keyed-rows-plain-position-hinted");
188
191
  } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-reorder-hinted" && keyedTargetKinds.size === 0) {
189
192
  features.add("keyed-rows-plain-reorder-hinted");
190
193
  } else if (keyedRowsFeature === "keyed-rows" && hintSuffix === "-map-reorder-hinted" && keyedTargetKinds.size === 0) {
@@ -3283,6 +3286,43 @@ function stabilizeDeferredEventCurrentTargets(root, compilerSetters) {
3283
3286
  const expression = file.program.body[0].expression;
3284
3287
  return types.isJSXElement(expression) ? expression : types.cloneNode(root, true);
3285
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
+ }
3286
3326
  function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters, keyedTargetReactiveByValue) {
3287
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])) {
3288
3328
  return {
@@ -3302,7 +3342,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
3302
3342
  if (!types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
3303
3343
  return "compiled keyed rows support host elements only";
3304
3344
  }
3305
- if (tag.name === "svg") return "compiled keyed rows do not support SVG yet";
3345
+ if (isForeignContent(element)) return "compiled keyed rows do not support SVG yet";
3306
3346
  const attributeNames = new Set(
3307
3347
  element.openingElement.attributes.filter((attribute) => types.isJSXAttribute(attribute)).map(jsxAttributeName).filter((name) => name !== void 0)
3308
3348
  );
@@ -3332,7 +3372,7 @@ function analyzeKeyedRowTree(row, renderCallback, safeGlobals, compilerSetters,
3332
3372
  }
3333
3373
  const name = jsxAttributeName(attribute);
3334
3374
  if (!name) return "compiled keyed rows do not support namespaced JSX attributes";
3335
- if (name === "ref" || name === "dangerouslySetInnerHTML") {
3375
+ if (name === "ref" || name === "dangerouslySetInnerHTML" || reactOwnedAttribute(name, attribute)) {
3336
3376
  return `compiled keyed row ${name} requires React ownership`;
3337
3377
  }
3338
3378
  if (name === "key") continue;
@@ -3700,7 +3740,7 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
3700
3740
  if (!types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
3701
3741
  return "compiler-owned conditionals support host elements only";
3702
3742
  }
3703
- if (tag.name === "svg") return "compiler-owned conditionals do not support SVG yet";
3743
+ if (isForeignContent(element)) return "compiler-owned conditionals do not support SVG yet";
3704
3744
  for (const attribute of element.openingElement.attributes) {
3705
3745
  if (types.isJSXSpreadAttribute(attribute)) {
3706
3746
  if (statefulOnly && !needsStaticBinding(attribute.argument)) continue;
@@ -3708,6 +3748,9 @@ function analyzeHostConditionalTree(branch, safeGlobals, allowStaticEvents = fal
3708
3748
  }
3709
3749
  const name = jsxAttributeName(attribute);
3710
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
+ }
3711
3754
  if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
3712
3755
  if (statefulOnly && (!types.isJSXExpressionContainer(attribute.value) || types.isJSXEmptyExpression(attribute.value.expression) || !needsStaticBinding(attribute.value.expression))) {
3713
3756
  continue;
@@ -3820,13 +3863,18 @@ function analyzeRecursiveHostTree(branch, statesByValue, safeGlobals, listNames,
3820
3863
  if (!types.isJSXIdentifier(tag) || !/^[a-z]/.test(tag.name)) {
3821
3864
  return "recursive compiler-owned blocks support host elements only";
3822
3865
  }
3823
- if (tag.name === "svg") return "recursive compiler-owned blocks do not support SVG yet";
3866
+ if (isForeignContent(element)) {
3867
+ return "recursive compiler-owned blocks do not support SVG yet";
3868
+ }
3824
3869
  for (const attribute of element.openingElement.attributes) {
3825
3870
  if (types.isJSXSpreadAttribute(attribute)) {
3826
3871
  return "recursive compiler-owned blocks do not support JSX attribute spreads";
3827
3872
  }
3828
3873
  const name = jsxAttributeName(attribute);
3829
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
+ }
3830
3878
  if (name === "ref" || name === "dangerouslySetInnerHTML" || name === "key") {
3831
3879
  return `recursive compiler-owned block ${name} requires React ownership`;
3832
3880
  }
@@ -4187,7 +4235,7 @@ function analyzeCompilerOwnedKeyedRowHostBlocks(shape, statesByValue, safeGlobal
4187
4235
  }
4188
4236
  function analyzeHostConditionalContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
4189
4237
  const containerName = container.openingElement.name;
4190
- if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg") {
4238
+ if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container)) {
4191
4239
  return void 0;
4192
4240
  }
4193
4241
  if (container.openingElement.attributes.some(
@@ -4252,7 +4300,7 @@ function analyzeHostConditionalContainer(container, statesByValue, safeGlobals,
4252
4300
  }
4253
4301
  function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals, allowSingleRange, listNames, parent, allocateId) {
4254
4302
  const containerName = container.openingElement.name;
4255
- if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg" || container.openingElement.attributes.some(
4303
+ if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container) || container.openingElement.attributes.some(
4256
4304
  (attribute) => types.isJSXSpreadAttribute(attribute) || types.isJSXAttribute(attribute) && types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
4257
4305
  )) {
4258
4306
  return void 0;
@@ -4348,7 +4396,7 @@ function analyzeConditionalRangesContainer(container, statesByValue, safeGlobals
4348
4396
  }
4349
4397
  function analyzeMixedRangesContainer(container, statesByValue, safeGlobals, listNames, parent, allocateId) {
4350
4398
  const containerName = container.openingElement.name;
4351
- if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || containerName.name === "svg" || container.openingElement.attributes.some(
4399
+ if (!types.isJSXIdentifier(containerName) || !/^[a-z]/.test(containerName.name) || isForeignContent(container) || container.openingElement.attributes.some(
4352
4400
  (attribute) => types.isJSXSpreadAttribute(attribute) || types.isJSXAttribute(attribute) && types.isJSXIdentifier(attribute.name) && (attribute.name.name === "ref" || attribute.name.name === "dangerouslySetInnerHTML")
4353
4401
  )) {
4354
4402
  return void 0;
@@ -7533,6 +7581,7 @@ async function compileReactModule(code, id, options) {
7533
7581
  visitor: {
7534
7582
  Program(programPath) {
7535
7583
  const moduleDirectives = new Set(directiveValues(programPath.node));
7584
+ markForeignContent(programPath);
7536
7585
  const useStateNames = /* @__PURE__ */ new Set();
7537
7586
  const reactNames = /* @__PURE__ */ new Set();
7538
7587
  const listNames = /* @__PURE__ */ new Set();