@farm.js/react 0.1.0-beta.21 → 0.1.0-beta.22

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
@@ -4785,6 +4785,19 @@ function keyedRowConditionalObject(conditional, parameters) {
4785
4785
  }
4786
4786
  return types.objectExpression(properties);
4787
4787
  }
4788
+ var UNCLONEABLE_KEYED_ROW_TAGS = /* @__PURE__ */ new Set(["input", "option", "select", "textarea"]);
4789
+ function canCloneKeyedRows(plan) {
4790
+ if (plan.descriptorBlocks?.size || plan.conditionals.length > 0) return false;
4791
+ if (plan.bindings.some((binding) => binding.kind === "style")) return false;
4792
+ const cloneable = (element) => {
4793
+ const tag = element.openingElement.name;
4794
+ if (!types.isJSXIdentifier(tag) || tag.name.includes("-") || UNCLONEABLE_KEYED_ROW_TAGS.has(tag.name)) {
4795
+ return false;
4796
+ }
4797
+ return element.children.every((child) => !types.isJSXElement(child) || cloneable(child));
4798
+ };
4799
+ return cloneable(plan.row);
4800
+ }
4788
4801
  function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFilterHintedStateIndices, keyedArrayPrependHintedStateIndices, keyedArrayPositionHintedStateIndices, keyedArrayReorderHintedStateIndices) {
4789
4802
  const name = types.jsxMemberExpression(
4790
4803
  types.jsxIdentifier(blockRuntime.name),
@@ -4921,6 +4934,12 @@ function keyedRowsBoundary(blockRuntime, plan, keyedMapUpdateHints, keyedArrayFi
4921
4934
  types.jsxIdentifier("hostBlocks"),
4922
4935
  types.jsxExpressionContainer(types.booleanLiteral(true))
4923
4936
  )
4937
+ ] : [],
4938
+ ...canCloneKeyedRows(plan) ? [
4939
+ types.jsxAttribute(
4940
+ types.jsxIdentifier("cloneRows"),
4941
+ types.jsxExpressionContainer(types.booleanLiteral(true))
4942
+ )
4924
4943
  ] : []
4925
4944
  ],
4926
4945
  true
@@ -7702,6 +7721,29 @@ async function compileReactModule(code, id, options) {
7702
7721
  optimizations: optimizationCounts
7703
7722
  };
7704
7723
  }
7724
+
7725
+ // src/compiler-options.ts
7726
+ var warnedExperimentalCompiler = false;
7727
+ function resolveCompilerOption(options = {}, warnDeprecated = false) {
7728
+ const experimental = options.experimental;
7729
+ const legacy = experimental && typeof experimental === "object" ? experimental.compiler : void 0;
7730
+ if (legacy !== void 0 && options.compiler !== void 0) {
7731
+ throw new TypeError(
7732
+ "Configure the React compiler with `compiler` only; remove `experimental.compiler`."
7733
+ );
7734
+ }
7735
+ const compiler = legacy === void 0 ? options.compiler : legacy;
7736
+ if (compiler !== void 0 && typeof compiler !== "boolean" && (compiler === null || typeof compiler !== "object" || Array.isArray(compiler))) {
7737
+ throw new TypeError("React compiler must be a boolean or compiler options object.");
7738
+ }
7739
+ if (legacy !== void 0 && warnDeprecated && !warnedExperimentalCompiler) {
7740
+ warnedExperimentalCompiler = true;
7741
+ console.warn(
7742
+ "[farm] `react({ experimental: { compiler } })` is deprecated. Use `react({ compiler })`."
7743
+ );
7744
+ }
7745
+ return compiler;
7746
+ }
7705
7747
  function projectRelativeId(projectRoot, id) {
7706
7748
  return relative(projectRoot, id).replace(/\\/g, "/");
7707
7749
  }
@@ -7871,16 +7913,9 @@ function normalizeReactCompilerOptions(value) {
7871
7913
 
7872
7914
  // src/vite.ts
7873
7915
  function readCompilerOptions(rendererOptions) {
7874
- const experimental = rendererOptions?.experimental;
7875
- if (!experimental || typeof experimental !== "object") return false;
7876
- const compiler = experimental.compiler;
7916
+ const compiler = resolveCompilerOption(rendererOptions);
7877
7917
  if (!compiler) return false;
7878
7918
  if (compiler === true) return normalizeReactCompilerOptions(true);
7879
- if (typeof compiler !== "object") {
7880
- throw new TypeError(
7881
- "React experimental.compiler must be a boolean or compiler options object."
7882
- );
7883
- }
7884
7919
  const normalized = compiler;
7885
7920
  if ((normalized.mode === "infer" || normalized.mode === "annotation") && typeof normalized.directive === "string" && (normalized.reactivity === "static" || normalized.reactivity === "hybrid") && (normalized.onUnsupported === "fallback" || normalized.onUnsupported === "warn" || normalized.onUnsupported === "error")) {
7886
7921
  return normalized;