@farm.js/react 0.1.0-beta.40 → 0.1.0-beta.42

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compiler-options.ts","../src/index.ts"],"names":[],"mappings":";;;AAEA,IAAI,0BAAA,GAA6B,KAAA;AAG1B,SAAS,qBAAA,CACd,OAAA,GAA0D,EAAC,EAC3D,iBAAiB,KAAA,EAC2B;AAC5C,EAAA,MAAM,eAAe,OAAA,CAAQ,YAAA;AAC7B,EAAA,MAAM,SACJ,YAAA,IAAgB,OAAO,YAAA,KAAiB,QAAA,GACnC,aAAwC,QAAA,GACzC,MAAA;AACN,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,OAAA,CAAQ,QAAA,KAAa,MAAA,EAAW;AAC1D,IAAA,MAAM,IAAI,SAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,MAAM,QAAA,GAAW,MAAA,KAAW,MAAA,GAAY,OAAA,CAAQ,QAAA,GAAW,MAAA;AAC3D,EAAA,IACE,QAAA,KAAa,MAAA,IACb,OAAO,QAAA,KAAa,SAAA,KACnB,QAAA,KAAa,IAAA,IAAQ,OAAO,QAAA,KAAa,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,CAAA,EAC5E;AACA,IAAA,MAAM,IAAI,UAAU,8DAA8D,CAAA;AAAA,EACpF;AACA,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,cAAA,IAAkB,CAAC,0BAAA,EAA4B;AACzE,IAAA,0BAAA,GAA6B,IAAA;AAC7B,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN;AAAA,KACF;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;;;ACsBO,IAAM,0BAAA,GAA6B;AACnC,IAAM,4BAAA,GAA+B;AAE5C,SAAS,4BAA4B,KAAA,EAAwB;AAC3D,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO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ACZ,GACF;AACF","file":"index.cjs","sourcesContent":["import type { ReactCompilerOptions } from \"./index\";\n\nlet warnedExperimentalCompiler = false;\n\n// Shared by react() and the Vite adapter, including descriptors from older renderers.\nexport function resolveCompilerOption(\n options: { compiler?: unknown; experimental?: unknown } = {},\n warnDeprecated = false,\n): boolean | ReactCompilerOptions | undefined {\n const experimental = options.experimental;\n const legacy =\n experimental && typeof experimental === \"object\"\n ? (experimental as { compiler?: unknown }).compiler\n : undefined;\n if (legacy !== undefined && options.compiler !== undefined) {\n throw new TypeError(\n \"Configure the React compiler with `compiler` only; remove `experimental.compiler`.\",\n );\n }\n const compiler = legacy === undefined ? options.compiler : legacy;\n if (\n compiler !== undefined &&\n typeof compiler !== \"boolean\" &&\n (compiler === null || typeof compiler !== \"object\" || Array.isArray(compiler))\n ) {\n throw new TypeError(\"React compiler must be a boolean or compiler options object.\");\n }\n if (legacy !== undefined && warnDeprecated && !warnedExperimentalCompiler) {\n warnedExperimentalCompiler = true;\n console.warn(\n \"[farm] `react({ experimental: { compiler } })` is deprecated. Use `react({ compiler })`.\",\n );\n }\n return compiler as boolean | ReactCompilerOptions | undefined;\n}\n","import type { FarmRenderer } from \"@farm.js/core/renderer\";\nimport { resolveCompilerOption } from \"./compiler-options\";\n\nexport type ReactCompilerMode = \"infer\" | \"annotation\";\nexport type ReactCompilerReactivity = \"static\" | \"hybrid\";\nexport type UnsupportedCompilerBehavior = \"fallback\" | \"warn\" | \"error\";\n\nexport interface ReactCompilerOptions {\n /** Compile every component that the safe subset can prove eligible. */\n mode?: ReactCompilerMode;\n /** Function or module directive used only by annotation mode. */\n directive?: string;\n /** What to do when a selected component is outside the safe subset. */\n onUnsupported?: UnsupportedCompilerBehavior;\n /**\n * How compiled bindings subscribe to state. `hybrid` keeps compiler-proven\n * dependencies and narrows short-circuited reads at runtime.\n */\n reactivity?: ReactCompilerReactivity;\n /** Write a machine-readable compiler coverage report after a production build. */\n report?: boolean;\n /** Project-relative report location. Providing it also enables reporting. */\n reportFile?: string;\n /**\n * Mount the app's own `createRoot` roots without React DOM when their tree is fully compiled.\n * The build points `import { createRoot } from \"react-dom/client\"` in app modules at\n * `@farm.js/react/compiled-root`, which loads React DOM on demand for anything else.\n * While on, `onChange` rows beside conditional content or in a list between static siblings\n * compile to blocks such roots run themselves and React DOM renders through React; `false`\n * keeps them on the smaller React-owned list. Defaults to `true`.\n */\n compiledRoot?: boolean;\n}\n\nexport interface ReactRendererOptions {\n /**\n * Farm's AOT compiler. `true` enables automatic inference; an object\n * customizes selection. Unsupported components always stay on React.\n */\n compiler?: boolean | ReactCompilerOptions;\n experimental?: {\n /** @deprecated Use the top-level `compiler` option. */\n compiler?: boolean | ReactCompilerOptions;\n };\n}\n\nexport interface NormalizedReactCompilerOptions {\n mode: ReactCompilerMode;\n directive: string;\n onUnsupported: UnsupportedCompilerBehavior;\n reactivity: ReactCompilerReactivity;\n report: boolean;\n reportFile: string;\n compiledRoot: boolean;\n}\n\nexport const DEFAULT_COMPILER_DIRECTIVE = \"use compiler\";\nexport const DEFAULT_COMPILER_REPORT_FILE = \".farm/react-compiler.json\";\n\nfunction normalizeCompilerReportFile(value: unknown): string {\n if (value === undefined) return DEFAULT_COMPILER_REPORT_FILE;\n if (typeof value !== \"string\" || !value.trim()) {\n throw new TypeError(\"The React compiler report file must be a non-empty relative path.\");\n }\n const normalized = value.trim().replace(/\\\\/g, \"/\");\n if (\n normalized.startsWith(\"/\") ||\n /^[A-Za-z]:\\//.test(normalized) ||\n normalized.split(\"/\").includes(\"..\")\n ) {\n throw new TypeError(\"The React compiler report file must stay inside the project root.\");\n }\n return normalized;\n}\n\nexport function normalizeReactCompilerOptions(\n value: true | ReactCompilerOptions,\n): NormalizedReactCompilerOptions {\n const options = value === true ? {} : value;\n const mode = options.mode || \"infer\";\n\n if (mode !== \"infer\" && mode !== \"annotation\") {\n throw new TypeError(`Unknown React compiler mode: ${String(mode)}`);\n }\n\n if (options.directive !== undefined && mode !== \"annotation\") {\n throw new TypeError(\"The React compiler directive can only be configured in annotation mode.\");\n }\n\n const directive = options.directive?.trim() || DEFAULT_COMPILER_DIRECTIVE;\n const onUnsupported = options.onUnsupported || \"fallback\";\n if (!([\"fallback\", \"warn\", \"error\"] as const).includes(onUnsupported)) {\n throw new TypeError(`Unknown unsupported-component behavior: ${String(onUnsupported)}`);\n }\n\n const reactivity = options.reactivity || \"hybrid\";\n if (reactivity !== \"static\" && reactivity !== \"hybrid\") {\n throw new TypeError(`Unknown React compiler reactivity mode: ${String(reactivity)}`);\n }\n\n if (options.report !== undefined && typeof options.report !== \"boolean\") {\n throw new TypeError(\"The React compiler report option must be a boolean.\");\n }\n if (options.report === false && options.reportFile !== undefined) {\n throw new TypeError(\n \"A React compiler report file cannot be configured when reporting is false.\",\n );\n }\n const reportFile = normalizeCompilerReportFile(options.reportFile);\n const report = options.report === true || options.reportFile !== undefined;\n if (options.compiledRoot !== undefined && typeof options.compiledRoot !== \"boolean\") {\n throw new TypeError(\"The React compiler compiledRoot option must be a boolean.\");\n }\n const compiledRoot = options.compiledRoot !== false;\n\n return { mode, directive, onUnsupported, reactivity, report, reportFile, compiledRoot };\n}\n\nconst REACT_RENDERER: Readonly<FarmRenderer> = Object.freeze({\n name: \"react\",\n vite: \"@farm.js/react/vite\",\n server: \"@farm.js/react/server\",\n client: \"@farm.js/react/client\",\n jsxImportSource: \"react\",\n dedupe: [\"react\", \"react-dom\", \"react/jsx-runtime\", \"react/jsx-dev-runtime\"],\n optimizeDeps: [\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"@farm.js/react/compiler-runtime\",\n ],\n capabilities: {\n reconcilesRerenders: true,\n streaming: {\n node: true,\n web: false,\n runtimes: { edge: { node: false, web: true } },\n },\n functionComponents: true,\n },\n});\n\n/** Select React and optionally enable Farm's AOT compiler. */\nexport function react(options: ReactRendererOptions = {}): FarmRenderer {\n const compiler = resolveCompilerOption(options, true);\n const normalizedCompiler = compiler ? normalizeReactCompilerOptions(compiler) : false;\n\n return {\n ...REACT_RENDERER,\n dedupe: [...(REACT_RENDERER.dedupe || [])],\n optimizeDeps: [...(REACT_RENDERER.optimizeDeps || [])],\n capabilities: {\n reconcilesRerenders: true,\n streaming: {\n ...REACT_RENDERER.capabilities?.streaming,\n runtimes: {\n edge: { ...REACT_RENDERER.capabilities?.streaming?.runtimes?.edge },\n },\n },\n functionComponents: true,\n },\n options: {\n compiler: normalizedCompiler,\n },\n };\n}\n\nexport { REACT_RENDERER };\nexport type { FarmRenderer } from \"@farm.js/core/renderer\";\n"]}
1
+ {"version":3,"sources":["../src/compiler-options.ts","../src/index.ts"],"names":[],"mappings":";;;AAEA,IAAI,0BAAA,GAA6B,KAAA;AAG1B,SAAS,qBAAA,CACd,OAAA,GAA0D,EAAC,EAC3D,iBAAiB,KAAA,EAC2B;AAC5C,EAAA,MAAM,eAAe,OAAA,CAAQ,YAAA;AAC7B,EAAA,MAAM,SACJ,YAAA,IAAgB,OAAO,YAAA,KAAiB,QAAA,GACnC,aAAwC,QAAA,GACzC,MAAA;AACN,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,OAAA,CAAQ,QAAA,KAAa,MAAA,EAAW;AAC1D,IAAA,MAAM,IAAI,SAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,MAAM,QAAA,GAAW,MAAA,KAAW,MAAA,GAAY,OAAA,CAAQ,QAAA,GAAW,MAAA;AAC3D,EAAA,IACE,QAAA,KAAa,MAAA,IACb,OAAO,QAAA,KAAa,SAAA,KACnB,QAAA,KAAa,IAAA,IAAQ,OAAO,QAAA,KAAa,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,CAAA,EAC5E;AACA,IAAA,MAAM,IAAI,UAAU,8DAA8D,CAAA;AAAA,EACpF;AACA,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,cAAA,IAAkB,CAAC,0BAAA,EAA4B;AACzE,IAAA,0BAAA,GAA6B,I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AAG,eAAe,YAAA,EAAc,SAAA;AAAA,QAChC,QAAA,EAAU;AAAA,UACR,MAAM,EAAE,GAAG,eAAe,YAAA,EAAc,SAAA,EAAW,UAAU,IAAA;AAAK;AACpE,OACF;AAAA,MACA,kBAAA,EAAoB;AAAA,KACtB;AAAA,IACA,OAAA,EAAS;AAAA,MACP,QAAA,EAAU;AAAA;AACZ,GACF;AACF","file":"index.cjs","sourcesContent":["import type { ReactCompilerOptions } from \"./index\";\n\nlet warnedExperimentalCompiler = false;\n\n// Shared by react() and the Vite adapter, including descriptors from older renderers.\nexport function resolveCompilerOption(\n options: { compiler?: unknown; experimental?: unknown } = {},\n warnDeprecated = false,\n): boolean | ReactCompilerOptions | undefined {\n const experimental = options.experimental;\n const legacy =\n experimental && typeof experimental === \"object\"\n ? (experimental as { compiler?: unknown }).compiler\n : undefined;\n if (legacy !== undefined && options.compiler !== undefined) {\n throw new TypeError(\n \"Configure the React compiler with `compiler` only; remove `experimental.compiler`.\",\n );\n }\n const compiler = legacy === undefined ? options.compiler : legacy;\n if (\n compiler !== undefined &&\n typeof compiler !== \"boolean\" &&\n (compiler === null || typeof compiler !== \"object\" || Array.isArray(compiler))\n ) {\n throw new TypeError(\"React compiler must be a boolean or compiler options object.\");\n }\n if (legacy !== undefined && warnDeprecated && !warnedExperimentalCompiler) {\n warnedExperimentalCompiler = true;\n console.warn(\n \"[farm] `react({ experimental: { compiler } })` is deprecated. Use `react({ compiler })`.\",\n );\n }\n return compiler as boolean | ReactCompilerOptions | undefined;\n}\n","import type { FarmRenderer } from \"@farm.js/core/renderer\";\nimport { resolveCompilerOption } from \"./compiler-options\";\n\nexport type ReactCompilerMode = \"infer\" | \"annotation\";\nexport type ReactCompilerReactivity = \"static\" | \"hybrid\";\nexport type UnsupportedCompilerBehavior = \"fallback\" | \"warn\" | \"error\";\n\nexport interface ReactCompilerOptions {\n /** Compile every component that the safe subset can prove eligible. */\n mode?: ReactCompilerMode;\n /** Function or module directive used only by annotation mode. */\n directive?: string;\n /** What to do when a selected component is outside the safe subset. */\n onUnsupported?: UnsupportedCompilerBehavior;\n /**\n * How compiled bindings subscribe to state. `hybrid` keeps compiler-proven\n * dependencies and narrows short-circuited reads at runtime.\n */\n reactivity?: ReactCompilerReactivity;\n /** Write a machine-readable compiler coverage report after a production build. */\n report?: boolean;\n /** Project-relative report location. Providing it also enables reporting. */\n reportFile?: string;\n /**\n * Mount the app's own `createRoot` roots without React DOM when their tree is fully compiled.\n * The build points `import { createRoot } from \"react-dom/client\"` in app modules at\n * `@farm.js/react/compiled-root`, which loads React DOM on demand for anything else.\n * While on, `onChange` rows beside or inside conditional content or in a list between static\n * siblings compile to blocks such roots run themselves and React DOM renders through React;\n * `false` keeps them on the smaller React-owned list. Defaults to `true`.\n */\n compiledRoot?: boolean;\n}\n\nexport interface ReactRendererOptions {\n /**\n * Farm's AOT compiler. `true` enables automatic inference; an object\n * customizes selection. Unsupported components always stay on React.\n */\n compiler?: boolean | ReactCompilerOptions;\n experimental?: {\n /** @deprecated Use the top-level `compiler` option. */\n compiler?: boolean | ReactCompilerOptions;\n };\n}\n\nexport interface NormalizedReactCompilerOptions {\n mode: ReactCompilerMode;\n directive: string;\n onUnsupported: UnsupportedCompilerBehavior;\n reactivity: ReactCompilerReactivity;\n report: boolean;\n reportFile: string;\n compiledRoot: boolean;\n}\n\nexport const DEFAULT_COMPILER_DIRECTIVE = \"use compiler\";\nexport const DEFAULT_COMPILER_REPORT_FILE = \".farm/react-compiler.json\";\n\nfunction normalizeCompilerReportFile(value: unknown): string {\n if (value === undefined) return DEFAULT_COMPILER_REPORT_FILE;\n if (typeof value !== \"string\" || !value.trim()) {\n throw new TypeError(\"The React compiler report file must be a non-empty relative path.\");\n }\n const normalized = value.trim().replace(/\\\\/g, \"/\");\n if (\n normalized.startsWith(\"/\") ||\n /^[A-Za-z]:\\//.test(normalized) ||\n normalized.split(\"/\").includes(\"..\")\n ) {\n throw new TypeError(\"The React compiler report file must stay inside the project root.\");\n }\n return normalized;\n}\n\nexport function normalizeReactCompilerOptions(\n value: true | ReactCompilerOptions,\n): NormalizedReactCompilerOptions {\n const options = value === true ? {} : value;\n const mode = options.mode || \"infer\";\n\n if (mode !== \"infer\" && mode !== \"annotation\") {\n throw new TypeError(`Unknown React compiler mode: ${String(mode)}`);\n }\n\n if (options.directive !== undefined && mode !== \"annotation\") {\n throw new TypeError(\"The React compiler directive can only be configured in annotation mode.\");\n }\n\n const directive = options.directive?.trim() || DEFAULT_COMPILER_DIRECTIVE;\n const onUnsupported = options.onUnsupported || \"fallback\";\n if (!([\"fallback\", \"warn\", \"error\"] as const).includes(onUnsupported)) {\n throw new TypeError(`Unknown unsupported-component behavior: ${String(onUnsupported)}`);\n }\n\n const reactivity = options.reactivity || \"hybrid\";\n if (reactivity !== \"static\" && reactivity !== \"hybrid\") {\n throw new TypeError(`Unknown React compiler reactivity mode: ${String(reactivity)}`);\n }\n\n if (options.report !== undefined && typeof options.report !== \"boolean\") {\n throw new TypeError(\"The React compiler report option must be a boolean.\");\n }\n if (options.report === false && options.reportFile !== undefined) {\n throw new TypeError(\n \"A React compiler report file cannot be configured when reporting is false.\",\n );\n }\n const reportFile = normalizeCompilerReportFile(options.reportFile);\n const report = options.report === true || options.reportFile !== undefined;\n if (options.compiledRoot !== undefined && typeof options.compiledRoot !== \"boolean\") {\n throw new TypeError(\"The React compiler compiledRoot option must be a boolean.\");\n }\n const compiledRoot = options.compiledRoot !== false;\n\n return { mode, directive, onUnsupported, reactivity, report, reportFile, compiledRoot };\n}\n\nconst REACT_RENDERER: Readonly<FarmRenderer> = Object.freeze({\n name: \"react\",\n vite: \"@farm.js/react/vite\",\n server: \"@farm.js/react/server\",\n client: \"@farm.js/react/client\",\n jsxImportSource: \"react\",\n dedupe: [\"react\", \"react-dom\", \"react/jsx-runtime\", \"react/jsx-dev-runtime\"],\n optimizeDeps: [\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"@farm.js/react/compiler-runtime\",\n ],\n capabilities: {\n reconcilesRerenders: true,\n streaming: {\n node: true,\n web: false,\n runtimes: { edge: { node: false, web: true } },\n },\n functionComponents: true,\n },\n});\n\n/** Select React and optionally enable Farm's AOT compiler. */\nexport function react(options: ReactRendererOptions = {}): FarmRenderer {\n const compiler = resolveCompilerOption(options, true);\n const normalizedCompiler = compiler ? normalizeReactCompilerOptions(compiler) : false;\n\n return {\n ...REACT_RENDERER,\n dedupe: [...(REACT_RENDERER.dedupe || [])],\n optimizeDeps: [...(REACT_RENDERER.optimizeDeps || [])],\n capabilities: {\n reconcilesRerenders: true,\n streaming: {\n ...REACT_RENDERER.capabilities?.streaming,\n runtimes: {\n edge: { ...REACT_RENDERER.capabilities?.streaming?.runtimes?.edge },\n },\n },\n functionComponents: true,\n },\n options: {\n compiler: normalizedCompiler,\n },\n };\n}\n\nexport { REACT_RENDERER };\nexport type { FarmRenderer } from \"@farm.js/core/renderer\";\n"]}
package/dist/index.d.mts CHANGED
@@ -24,9 +24,9 @@ interface ReactCompilerOptions {
24
24
  * Mount the app's own `createRoot` roots without React DOM when their tree is fully compiled.
25
25
  * The build points `import { createRoot } from "react-dom/client"` in app modules at
26
26
  * `@farm.js/react/compiled-root`, which loads React DOM on demand for anything else.
27
- * While on, `onChange` rows beside conditional content or in a list between static siblings
28
- * compile to blocks such roots run themselves and React DOM renders through React; `false`
29
- * keeps them on the smaller React-owned list. Defaults to `true`.
27
+ * While on, `onChange` rows beside or inside conditional content or in a list between static
28
+ * siblings compile to blocks such roots run themselves and React DOM renders through React;
29
+ * `false` keeps them on the smaller React-owned list. Defaults to `true`.
30
30
  */
31
31
  compiledRoot?: boolean;
32
32
  }
package/dist/index.d.ts CHANGED
@@ -24,9 +24,9 @@ interface ReactCompilerOptions {
24
24
  * Mount the app's own `createRoot` roots without React DOM when their tree is fully compiled.
25
25
  * The build points `import { createRoot } from "react-dom/client"` in app modules at
26
26
  * `@farm.js/react/compiled-root`, which loads React DOM on demand for anything else.
27
- * While on, `onChange` rows beside conditional content or in a list between static siblings
28
- * compile to blocks such roots run themselves and React DOM renders through React; `false`
29
- * keeps them on the smaller React-owned list. Defaults to `true`.
27
+ * While on, `onChange` rows beside or inside conditional content or in a list between static
28
+ * siblings compile to blocks such roots run themselves and React DOM renders through React;
29
+ * `false` keeps them on the smaller React-owned list. Defaults to `true`.
30
30
  */
31
31
  compiledRoot?: boolean;
32
32
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compiler-options.ts","../src/index.ts"],"names":[],"mappings":";AAEA,IAAI,0BAAA,GAA6B,KAAA;AAG1B,SAAS,qBAAA,CACd,OAAA,GAA0D,EAAC,EAC3D,iBAAiB,KAAA,EAC2B;AAC5C,EAAA,MAAM,eAAe,OAAA,CAAQ,YAAA;AAC7B,EAAA,MAAM,SACJ,YAAA,IAAgB,OAAO,YAAA,KAAiB,QAAA,GACnC,aAAwC,QAAA,GACzC,MAAA;AACN,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,OAAA,CAAQ,QAAA,KAAa,MAAA,EAAW;AAC1D,IAAA,MAAM,IAAI,SAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,MAAM,QAAA,GAAW,MAAA,KAAW,MAAA,GAAY,OAAA,CAAQ,QAAA,GAAW,MAAA;AAC3D,EAAA,IACE,QAAA,KAAa,MAAA,IACb,OAAO,QAAA,KAAa,SAAA,KACnB,QAAA,KAAa,IAAA,IAAQ,OAAO,QAAA,KAAa,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,CAAA,EAC5E;AACA,IAAA,MAAM,IAAI,UAAU,8DAA8D,CAAA;AAAA,EACpF;AACA,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,cAAA,IAAkB,CAAC,0BAAA,EAA4B;AACzE,IAAA,0BAAA,GAA6B,IAAA;AAC7B,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN;AAAA,KACF;AAAA,EACF;AACA,EAAA,OAAO,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,YAAA,EAAc,SAAA,EAAW,UAAU,IAAA;AAAK;AACpE,OACF;AAAA,MACA,kBAAA,EAAoB;AAAA,KACtB;AAAA,IACA,OAAA,EAAS;AAAA,MACP,QAAA,EAAU;AAAA;AACZ,GACF;AACF","file":"index.mjs","sourcesContent":["import type { ReactCompilerOptions } from \"./index\";\n\nlet warnedExperimentalCompiler = false;\n\n// Shared by react() and the Vite adapter, including descriptors from older renderers.\nexport function resolveCompilerOption(\n options: { compiler?: unknown; experimental?: unknown } = {},\n warnDeprecated = false,\n): boolean | ReactCompilerOptions | undefined {\n const experimental = options.experimental;\n const legacy =\n experimental && typeof experimental === \"object\"\n ? (experimental as { compiler?: unknown }).compiler\n : undefined;\n if (legacy !== undefined && options.compiler !== undefined) {\n throw new TypeError(\n \"Configure the React compiler with `compiler` only; remove `experimental.compiler`.\",\n );\n }\n const compiler = legacy === undefined ? options.compiler : legacy;\n if (\n compiler !== undefined &&\n typeof compiler !== \"boolean\" &&\n (compiler === null || typeof compiler !== \"object\" || Array.isArray(compiler))\n ) {\n throw new TypeError(\"React compiler must be a boolean or compiler options object.\");\n }\n if (legacy !== undefined && warnDeprecated && !warnedExperimentalCompiler) {\n warnedExperimentalCompiler = true;\n console.warn(\n \"[farm] `react({ experimental: { compiler } })` is deprecated. Use `react({ compiler })`.\",\n );\n }\n return compiler as boolean | ReactCompilerOptions | undefined;\n}\n","import type { FarmRenderer } from \"@farm.js/core/renderer\";\nimport { resolveCompilerOption } from \"./compiler-options\";\n\nexport type ReactCompilerMode = \"infer\" | \"annotation\";\nexport type ReactCompilerReactivity = \"static\" | \"hybrid\";\nexport type UnsupportedCompilerBehavior = \"fallback\" | \"warn\" | \"error\";\n\nexport interface ReactCompilerOptions {\n /** Compile every component that the safe subset can prove eligible. */\n mode?: ReactCompilerMode;\n /** Function or module directive used only by annotation mode. */\n directive?: string;\n /** What to do when a selected component is outside the safe subset. */\n onUnsupported?: UnsupportedCompilerBehavior;\n /**\n * How compiled bindings subscribe to state. `hybrid` keeps compiler-proven\n * dependencies and narrows short-circuited reads at runtime.\n */\n reactivity?: ReactCompilerReactivity;\n /** Write a machine-readable compiler coverage report after a production build. */\n report?: boolean;\n /** Project-relative report location. Providing it also enables reporting. */\n reportFile?: string;\n /**\n * Mount the app's own `createRoot` roots without React DOM when their tree is fully compiled.\n * The build points `import { createRoot } from \"react-dom/client\"` in app modules at\n * `@farm.js/react/compiled-root`, which loads React DOM on demand for anything else.\n * While on, `onChange` rows beside conditional content or in a list between static siblings\n * compile to blocks such roots run themselves and React DOM renders through React; `false`\n * keeps them on the smaller React-owned list. Defaults to `true`.\n */\n compiledRoot?: boolean;\n}\n\nexport interface ReactRendererOptions {\n /**\n * Farm's AOT compiler. `true` enables automatic inference; an object\n * customizes selection. Unsupported components always stay on React.\n */\n compiler?: boolean | ReactCompilerOptions;\n experimental?: {\n /** @deprecated Use the top-level `compiler` option. */\n compiler?: boolean | ReactCompilerOptions;\n };\n}\n\nexport interface NormalizedReactCompilerOptions {\n mode: ReactCompilerMode;\n directive: string;\n onUnsupported: UnsupportedCompilerBehavior;\n reactivity: ReactCompilerReactivity;\n report: boolean;\n reportFile: string;\n compiledRoot: boolean;\n}\n\nexport const DEFAULT_COMPILER_DIRECTIVE = \"use compiler\";\nexport const DEFAULT_COMPILER_REPORT_FILE = \".farm/react-compiler.json\";\n\nfunction normalizeCompilerReportFile(value: unknown): string {\n if (value === undefined) return DEFAULT_COMPILER_REPORT_FILE;\n if (typeof value !== \"string\" || !value.trim()) {\n throw new TypeError(\"The React compiler report file must be a non-empty relative path.\");\n }\n const normalized = value.trim().replace(/\\\\/g, \"/\");\n if (\n normalized.startsWith(\"/\") ||\n /^[A-Za-z]:\\//.test(normalized) ||\n normalized.split(\"/\").includes(\"..\")\n ) {\n throw new TypeError(\"The React compiler report file must stay inside the project root.\");\n }\n return normalized;\n}\n\nexport function normalizeReactCompilerOptions(\n value: true | ReactCompilerOptions,\n): NormalizedReactCompilerOptions {\n const options = value === true ? {} : value;\n const mode = options.mode || \"infer\";\n\n if (mode !== \"infer\" && mode !== \"annotation\") {\n throw new TypeError(`Unknown React compiler mode: ${String(mode)}`);\n }\n\n if (options.directive !== undefined && mode !== \"annotation\") {\n throw new TypeError(\"The React compiler directive can only be configured in annotation mode.\");\n }\n\n const directive = options.directive?.trim() || DEFAULT_COMPILER_DIRECTIVE;\n const onUnsupported = options.onUnsupported || \"fallback\";\n if (!([\"fallback\", \"warn\", \"error\"] as const).includes(onUnsupported)) {\n throw new TypeError(`Unknown unsupported-component behavior: ${String(onUnsupported)}`);\n }\n\n const reactivity = options.reactivity || \"hybrid\";\n if (reactivity !== \"static\" && reactivity !== \"hybrid\") {\n throw new TypeError(`Unknown React compiler reactivity mode: ${String(reactivity)}`);\n }\n\n if (options.report !== undefined && typeof options.report !== \"boolean\") {\n throw new TypeError(\"The React compiler report option must be a boolean.\");\n }\n if (options.report === false && options.reportFile !== undefined) {\n throw new TypeError(\n \"A React compiler report file cannot be configured when reporting is false.\",\n );\n }\n const reportFile = normalizeCompilerReportFile(options.reportFile);\n const report = options.report === true || options.reportFile !== undefined;\n if (options.compiledRoot !== undefined && typeof options.compiledRoot !== \"boolean\") {\n throw new TypeError(\"The React compiler compiledRoot option must be a boolean.\");\n }\n const compiledRoot = options.compiledRoot !== false;\n\n return { mode, directive, onUnsupported, reactivity, report, reportFile, compiledRoot };\n}\n\nconst REACT_RENDERER: Readonly<FarmRenderer> = Object.freeze({\n name: \"react\",\n vite: \"@farm.js/react/vite\",\n server: \"@farm.js/react/server\",\n client: \"@farm.js/react/client\",\n jsxImportSource: \"react\",\n dedupe: [\"react\", \"react-dom\", \"react/jsx-runtime\", \"react/jsx-dev-runtime\"],\n optimizeDeps: [\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"@farm.js/react/compiler-runtime\",\n ],\n capabilities: {\n reconcilesRerenders: true,\n streaming: {\n node: true,\n web: false,\n runtimes: { edge: { node: false, web: true } },\n },\n functionComponents: true,\n },\n});\n\n/** Select React and optionally enable Farm's AOT compiler. */\nexport function react(options: ReactRendererOptions = {}): FarmRenderer {\n const compiler = resolveCompilerOption(options, true);\n const normalizedCompiler = compiler ? normalizeReactCompilerOptions(compiler) : false;\n\n return {\n ...REACT_RENDERER,\n dedupe: [...(REACT_RENDERER.dedupe || [])],\n optimizeDeps: [...(REACT_RENDERER.optimizeDeps || [])],\n capabilities: {\n reconcilesRerenders: true,\n streaming: {\n ...REACT_RENDERER.capabilities?.streaming,\n runtimes: {\n edge: { ...REACT_RENDERER.capabilities?.streaming?.runtimes?.edge },\n },\n },\n functionComponents: true,\n },\n options: {\n compiler: normalizedCompiler,\n },\n };\n}\n\nexport { REACT_RENDERER };\nexport type { FarmRenderer } from \"@farm.js/core/renderer\";\n"]}
1
+ {"version":3,"sources":["../src/compiler-options.ts","../src/index.ts"],"names":[],"mappings":";AAEA,IAAI,0BAAA,GAA6B,KAAA;AAG1B,SAAS,qBAAA,CACd,OAAA,GAA0D,EAAC,EAC3D,iBAAiB,KAAA,EAC2B;AAC5C,EAAA,MAAM,eAAe,OAAA,CAAQ,YAAA;AAC7B,EAAA,MAAM,SACJ,YAAA,IAAgB,OAAO,YAAA,KAAiB,QAAA,GACnC,aAAwC,QAAA,GACzC,MAAA;AACN,EAAA,IAAI,MAAA,KAAW,MAAA,IAAa,OAAA,CAAQ,QAAA,KAAa,MAAA,EAAW;AAC1D,IAAA,MAAM,IAAI,SAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,MAAM,QAAA,GAAW,MAAA,KAAW,MAAA,GAAY,OAAA,CAAQ,QAAA,GAAW,MAAA;AAC3D,EAAA,IACE,QAAA,KAAa,MAAA,IACb,OAAO,QAAA,KAAa,SAAA,KACnB,QAAA,KAAa,IAAA,IAAQ,OAAO,QAAA,KAAa,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,CAAA,EAC5E;AACA,IAAA,MAAM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CAAC,GAAI,cAAA,CAAe,YAAA,IAAgB,EAAG,CAAA;AAAA,IACrD,YAAA,EAAc;AAAA,MACZ,mBAAA,EAAqB,IAAA;AAAA,MACrB,SAAA,EAAW;AAAA,QACT,GAAG,eAAe,YAAA,EAAc,SAAA;AAAA,QAChC,QAAA,EAAU;AAAA,UACR,MAAM,EAAE,GAAG,eAAe,YAAA,EAAc,SAAA,EAAW,UAAU,IAAA;AAAK;AACpE,OACF;AAAA,MACA,kBAAA,EAAoB;AAAA,KACtB;AAAA,IACA,OAAA,EAAS;AAAA,MACP,QAAA,EAAU;AAAA;AACZ,GACF;AACF","file":"index.mjs","sourcesContent":["import type { ReactCompilerOptions } from \"./index\";\n\nlet warnedExperimentalCompiler = false;\n\n// Shared by react() and the Vite adapter, including descriptors from older renderers.\nexport function resolveCompilerOption(\n options: { compiler?: unknown; experimental?: unknown } = {},\n warnDeprecated = false,\n): boolean | ReactCompilerOptions | undefined {\n const experimental = options.experimental;\n const legacy =\n experimental && typeof experimental === \"object\"\n ? (experimental as { compiler?: unknown }).compiler\n : undefined;\n if (legacy !== undefined && options.compiler !== undefined) {\n throw new TypeError(\n \"Configure the React compiler with `compiler` only; remove `experimental.compiler`.\",\n );\n }\n const compiler = legacy === undefined ? options.compiler : legacy;\n if (\n compiler !== undefined &&\n typeof compiler !== \"boolean\" &&\n (compiler === null || typeof compiler !== \"object\" || Array.isArray(compiler))\n ) {\n throw new TypeError(\"React compiler must be a boolean or compiler options object.\");\n }\n if (legacy !== undefined && warnDeprecated && !warnedExperimentalCompiler) {\n warnedExperimentalCompiler = true;\n console.warn(\n \"[farm] `react({ experimental: { compiler } })` is deprecated. Use `react({ compiler })`.\",\n );\n }\n return compiler as boolean | ReactCompilerOptions | undefined;\n}\n","import type { FarmRenderer } from \"@farm.js/core/renderer\";\nimport { resolveCompilerOption } from \"./compiler-options\";\n\nexport type ReactCompilerMode = \"infer\" | \"annotation\";\nexport type ReactCompilerReactivity = \"static\" | \"hybrid\";\nexport type UnsupportedCompilerBehavior = \"fallback\" | \"warn\" | \"error\";\n\nexport interface ReactCompilerOptions {\n /** Compile every component that the safe subset can prove eligible. */\n mode?: ReactCompilerMode;\n /** Function or module directive used only by annotation mode. */\n directive?: string;\n /** What to do when a selected component is outside the safe subset. */\n onUnsupported?: UnsupportedCompilerBehavior;\n /**\n * How compiled bindings subscribe to state. `hybrid` keeps compiler-proven\n * dependencies and narrows short-circuited reads at runtime.\n */\n reactivity?: ReactCompilerReactivity;\n /** Write a machine-readable compiler coverage report after a production build. */\n report?: boolean;\n /** Project-relative report location. Providing it also enables reporting. */\n reportFile?: string;\n /**\n * Mount the app's own `createRoot` roots without React DOM when their tree is fully compiled.\n * The build points `import { createRoot } from \"react-dom/client\"` in app modules at\n * `@farm.js/react/compiled-root`, which loads React DOM on demand for anything else.\n * While on, `onChange` rows beside or inside conditional content or in a list between static\n * siblings compile to blocks such roots run themselves and React DOM renders through React;\n * `false` keeps them on the smaller React-owned list. Defaults to `true`.\n */\n compiledRoot?: boolean;\n}\n\nexport interface ReactRendererOptions {\n /**\n * Farm's AOT compiler. `true` enables automatic inference; an object\n * customizes selection. Unsupported components always stay on React.\n */\n compiler?: boolean | ReactCompilerOptions;\n experimental?: {\n /** @deprecated Use the top-level `compiler` option. */\n compiler?: boolean | ReactCompilerOptions;\n };\n}\n\nexport interface NormalizedReactCompilerOptions {\n mode: ReactCompilerMode;\n directive: string;\n onUnsupported: UnsupportedCompilerBehavior;\n reactivity: ReactCompilerReactivity;\n report: boolean;\n reportFile: string;\n compiledRoot: boolean;\n}\n\nexport const DEFAULT_COMPILER_DIRECTIVE = \"use compiler\";\nexport const DEFAULT_COMPILER_REPORT_FILE = \".farm/react-compiler.json\";\n\nfunction normalizeCompilerReportFile(value: unknown): string {\n if (value === undefined) return DEFAULT_COMPILER_REPORT_FILE;\n if (typeof value !== \"string\" || !value.trim()) {\n throw new TypeError(\"The React compiler report file must be a non-empty relative path.\");\n }\n const normalized = value.trim().replace(/\\\\/g, \"/\");\n if (\n normalized.startsWith(\"/\") ||\n /^[A-Za-z]:\\//.test(normalized) ||\n normalized.split(\"/\").includes(\"..\")\n ) {\n throw new TypeError(\"The React compiler report file must stay inside the project root.\");\n }\n return normalized;\n}\n\nexport function normalizeReactCompilerOptions(\n value: true | ReactCompilerOptions,\n): NormalizedReactCompilerOptions {\n const options = value === true ? {} : value;\n const mode = options.mode || \"infer\";\n\n if (mode !== \"infer\" && mode !== \"annotation\") {\n throw new TypeError(`Unknown React compiler mode: ${String(mode)}`);\n }\n\n if (options.directive !== undefined && mode !== \"annotation\") {\n throw new TypeError(\"The React compiler directive can only be configured in annotation mode.\");\n }\n\n const directive = options.directive?.trim() || DEFAULT_COMPILER_DIRECTIVE;\n const onUnsupported = options.onUnsupported || \"fallback\";\n if (!([\"fallback\", \"warn\", \"error\"] as const).includes(onUnsupported)) {\n throw new TypeError(`Unknown unsupported-component behavior: ${String(onUnsupported)}`);\n }\n\n const reactivity = options.reactivity || \"hybrid\";\n if (reactivity !== \"static\" && reactivity !== \"hybrid\") {\n throw new TypeError(`Unknown React compiler reactivity mode: ${String(reactivity)}`);\n }\n\n if (options.report !== undefined && typeof options.report !== \"boolean\") {\n throw new TypeError(\"The React compiler report option must be a boolean.\");\n }\n if (options.report === false && options.reportFile !== undefined) {\n throw new TypeError(\n \"A React compiler report file cannot be configured when reporting is false.\",\n );\n }\n const reportFile = normalizeCompilerReportFile(options.reportFile);\n const report = options.report === true || options.reportFile !== undefined;\n if (options.compiledRoot !== undefined && typeof options.compiledRoot !== \"boolean\") {\n throw new TypeError(\"The React compiler compiledRoot option must be a boolean.\");\n }\n const compiledRoot = options.compiledRoot !== false;\n\n return { mode, directive, onUnsupported, reactivity, report, reportFile, compiledRoot };\n}\n\nconst REACT_RENDERER: Readonly<FarmRenderer> = Object.freeze({\n name: \"react\",\n vite: \"@farm.js/react/vite\",\n server: \"@farm.js/react/server\",\n client: \"@farm.js/react/client\",\n jsxImportSource: \"react\",\n dedupe: [\"react\", \"react-dom\", \"react/jsx-runtime\", \"react/jsx-dev-runtime\"],\n optimizeDeps: [\n \"react\",\n \"react-dom\",\n \"react-dom/client\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"@farm.js/react/compiler-runtime\",\n ],\n capabilities: {\n reconcilesRerenders: true,\n streaming: {\n node: true,\n web: false,\n runtimes: { edge: { node: false, web: true } },\n },\n functionComponents: true,\n },\n});\n\n/** Select React and optionally enable Farm's AOT compiler. */\nexport function react(options: ReactRendererOptions = {}): FarmRenderer {\n const compiler = resolveCompilerOption(options, true);\n const normalizedCompiler = compiler ? normalizeReactCompilerOptions(compiler) : false;\n\n return {\n ...REACT_RENDERER,\n dedupe: [...(REACT_RENDERER.dedupe || [])],\n optimizeDeps: [...(REACT_RENDERER.optimizeDeps || [])],\n capabilities: {\n reconcilesRerenders: true,\n streaming: {\n ...REACT_RENDERER.capabilities?.streaming,\n runtimes: {\n edge: { ...REACT_RENDERER.capabilities?.streaming?.runtimes?.edge },\n },\n },\n functionComponents: true,\n },\n options: {\n compiler: normalizedCompiler,\n },\n };\n}\n\nexport { REACT_RENDERER };\nexport type { FarmRenderer } from \"@farm.js/core/renderer\";\n"]}