@farm.js/react 0.1.0-beta.3 → 0.1.0-beta.5
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 +133 -37
- package/dist/compiler-runtime.cjs +2052 -188
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +106 -4
- package/dist/compiler-runtime.d.ts +106 -4
- package/dist/compiler-runtime.mjs +2041 -189
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/list.cjs +18 -1
- package/dist/list.cjs.map +1 -1
- package/dist/list.mjs +18 -1
- package/dist/list.mjs.map +1 -1
- package/dist/vite.cjs +1224 -87
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +1224 -87
- package/dist/vite.mjs.map +1 -1
- package/package.json +6 -3
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,10 @@ function normalizeReactCompilerOptions(value) {
|
|
|
28
28
|
if (!["fallback", "warn", "error"].includes(onUnsupported)) {
|
|
29
29
|
throw new TypeError(`Unknown unsupported-component behavior: ${String(onUnsupported)}`);
|
|
30
30
|
}
|
|
31
|
+
const reactivity = options.reactivity || "hybrid";
|
|
32
|
+
if (reactivity !== "static" && reactivity !== "hybrid") {
|
|
33
|
+
throw new TypeError(`Unknown React compiler reactivity mode: ${String(reactivity)}`);
|
|
34
|
+
}
|
|
31
35
|
if (options.report !== void 0 && typeof options.report !== "boolean") {
|
|
32
36
|
throw new TypeError("The React compiler report option must be a boolean.");
|
|
33
37
|
}
|
|
@@ -38,7 +42,7 @@ function normalizeReactCompilerOptions(value) {
|
|
|
38
42
|
}
|
|
39
43
|
const reportFile = normalizeCompilerReportFile(options.reportFile);
|
|
40
44
|
const report = options.report === true || options.reportFile !== void 0;
|
|
41
|
-
return { mode, directive, onUnsupported, report, reportFile };
|
|
45
|
+
return { mode, directive, onUnsupported, reactivity, report, reportFile };
|
|
42
46
|
}
|
|
43
47
|
var REACT_RENDERER = Object.freeze({
|
|
44
48
|
name: "react",
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;AAwCO,IAAM,0BAAA,GAA6B;AACnC,IAAM,4BAAA,GAA+B;AAE5C,SAAS,4BAA4B,KAAA,EAAwB;AAC3D,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO,4BAAA;AAChC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,MAAK,EAAG;AAC9C,IAAA,MAAM,IAAI,UAAU,mEAAmE,CAAA;AAAA,EACzF;AACA,EAAA,MAAM,aAAa,KAAA,CAAM,IAAA,EAAK,CAAE,OAAA,CAAQ,OAAO,GAAG,CAAA;AAClD,EAAA,IACE,UAAA,CAAW,UAAA,CAAW,GAAG,CAAA,IACzB,eAAe,IAAA,CAAK,UAAU,CAAA,IAC9B,UAAA,CAAW,KAAA,CAAM,GAAG,CAAA,CAAE,QAAA,CAAS,IAAI,CAAA,EACnC;AACA,IAAA,MAAM,IAAI,UAAU,mEAAmE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,UAAA;AACT;AAEO,SAAS,8BACd,KAAA,EACgC;AAChC,EAAA,MAAM,OAAA,GAAU,KAAA,KAAU,IAAA,GAAO,EAAC,GAAI,KAAA;AACtC,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,IAAQ,OAAA;AAE7B,EAAA,IAAI,IAAA,KAAS,OAAA,IAAW,IAAA,KAAS,YAAA,EAAc;AAC7C,IAAA,MAAM,IAAI,SAAA,CAAU,CAAA,6BAAA,EAAgC,MAAA,CAAO,IAAI,CAAC,CAAA,CAAE,CAAA;AAA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EAAW,aAAA,EAAe,UAAA,EAAY,QAAQ,UAAA,EAAW;AAC1E;AAEA,IAAM,cAAA,GAAyC,OAAO,MAAA,CAAO;AAAA,EAC3D,IAAA,EAAM,OAAA;AAAA,EACN,IAAA,EAAM,qBAAA;AAAA,EACN,MAAA,EAAQ,uBAAA;AAAA,EACR,MAAA,EAAQ,uBAAA;AAAA,EACR,eAAA,EAAiB,OAAA;AAAA,EACjB,MAAA,EAAQ,CAAC,OAAA,EAAS,WAAA,EAAa,qBAAqB,uBAAuB,CAAA;AAAA,EAC3E,YAAA,EAAc;AAAA,IACZ,OAAA;AAAA,IACA,WAAA;AAAA,IACA,kBAAA;AAAA,IACA,mBAAA;AAAA,IACA,uBAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA,YAAA,EAAc;AAAA,IACZ,SAAA,EAAW,EAAE,IAAA,EAAM,IAAA,EAAM,KAAK,KAAA;AAAM;AAExC,CAAC;AAGM,SAAS,KAAA,CAAM,OAAA,GAAgC,EAAC,EAAiB;AACtE,EAAA,MAAM,QAAA,GAAW,QAAQ,YAAA,EAAc,QAAA;AACvC,EAAA,MAAM,kBAAA,GAAqB,QAAA,GAAW,6BAAA,CAA8B,QAAQ,CAAA,GAAI,KAAA;AAEhF,EAAA,OAAO;AAAA,IACL,GAAG,cAAA;AAAA,IACH,QAAQ,CAAC,GAAI,cAAA,CAAe,MAAA,IAAU,EAAG,CAAA;AAAA,IACzC,cAAc,CAAC,GAAI,cAAA,CAAe,YAAA,IAAgB,EAAG,CAAA;AAAA,IACrD,YAAA,EAAc;AAAA,MACZ,SAAA,EAAW,EAAE,GAAG,cAAA,CAAe,cAAc,SAAA;AAAU,KACzD;AAAA,IACA,OAAA,EAAS;AAAA,MACP,YAAA,EAAc,EAAE,QAAA,EAAU,kBAAA;AAAmB;AAC/C,GACF;AACF","file":"index.cjs","sourcesContent":["import type { FarmRenderer } from \"@farm.js/core/renderer\";\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\nexport interface ReactRendererOptions {\n experimental?: {\n /** `true` enables automatic inference; an object customizes selection. */\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}\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\n return { mode, directive, onUnsupported, reactivity, report, reportFile };\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 streaming: { node: true, web: false },\n },\n});\n\n/** Select React and optionally enable Farm's experimental AOT compiler. */\nexport function react(options: ReactRendererOptions = {}): FarmRenderer {\n const compiler = options.experimental?.compiler;\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 streaming: { ...REACT_RENDERER.capabilities?.streaming },\n },\n options: {\n experimental: { compiler: normalizedCompiler },\n },\n };\n}\n\nexport { REACT_RENDERER };\nexport type { FarmRenderer } from \"@farm.js/core/renderer\";\n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -2,6 +2,7 @@ import { FarmRenderer } from '@farm.js/core/renderer';
|
|
|
2
2
|
export { FarmRenderer } from '@farm.js/core/renderer';
|
|
3
3
|
|
|
4
4
|
type ReactCompilerMode = "infer" | "annotation";
|
|
5
|
+
type ReactCompilerReactivity = "static" | "hybrid";
|
|
5
6
|
type UnsupportedCompilerBehavior = "fallback" | "warn" | "error";
|
|
6
7
|
interface ReactCompilerOptions {
|
|
7
8
|
/** Compile every component that the safe subset can prove eligible. */
|
|
@@ -10,6 +11,11 @@ interface ReactCompilerOptions {
|
|
|
10
11
|
directive?: string;
|
|
11
12
|
/** What to do when a selected component is outside the safe subset. */
|
|
12
13
|
onUnsupported?: UnsupportedCompilerBehavior;
|
|
14
|
+
/**
|
|
15
|
+
* How compiled bindings subscribe to state. `hybrid` keeps compiler-proven
|
|
16
|
+
* dependencies and narrows short-circuited reads at runtime.
|
|
17
|
+
*/
|
|
18
|
+
reactivity?: ReactCompilerReactivity;
|
|
13
19
|
/** Write a machine-readable compiler coverage report after a production build. */
|
|
14
20
|
report?: boolean;
|
|
15
21
|
/** Project-relative report location. Providing it also enables reporting. */
|
|
@@ -25,6 +31,7 @@ interface NormalizedReactCompilerOptions {
|
|
|
25
31
|
mode: ReactCompilerMode;
|
|
26
32
|
directive: string;
|
|
27
33
|
onUnsupported: UnsupportedCompilerBehavior;
|
|
34
|
+
reactivity: ReactCompilerReactivity;
|
|
28
35
|
report: boolean;
|
|
29
36
|
reportFile: string;
|
|
30
37
|
}
|
|
@@ -35,4 +42,4 @@ declare const REACT_RENDERER: Readonly<FarmRenderer>;
|
|
|
35
42
|
/** Select React and optionally enable Farm's experimental AOT compiler. */
|
|
36
43
|
declare function react(options?: ReactRendererOptions): FarmRenderer;
|
|
37
44
|
|
|
38
|
-
export { DEFAULT_COMPILER_DIRECTIVE, DEFAULT_COMPILER_REPORT_FILE, type NormalizedReactCompilerOptions, REACT_RENDERER, type ReactCompilerMode, type ReactCompilerOptions, type ReactRendererOptions, type UnsupportedCompilerBehavior, normalizeReactCompilerOptions, react };
|
|
45
|
+
export { DEFAULT_COMPILER_DIRECTIVE, DEFAULT_COMPILER_REPORT_FILE, type NormalizedReactCompilerOptions, REACT_RENDERER, type ReactCompilerMode, type ReactCompilerOptions, type ReactCompilerReactivity, type ReactRendererOptions, type UnsupportedCompilerBehavior, normalizeReactCompilerOptions, react };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { FarmRenderer } from '@farm.js/core/renderer';
|
|
|
2
2
|
export { FarmRenderer } from '@farm.js/core/renderer';
|
|
3
3
|
|
|
4
4
|
type ReactCompilerMode = "infer" | "annotation";
|
|
5
|
+
type ReactCompilerReactivity = "static" | "hybrid";
|
|
5
6
|
type UnsupportedCompilerBehavior = "fallback" | "warn" | "error";
|
|
6
7
|
interface ReactCompilerOptions {
|
|
7
8
|
/** Compile every component that the safe subset can prove eligible. */
|
|
@@ -10,6 +11,11 @@ interface ReactCompilerOptions {
|
|
|
10
11
|
directive?: string;
|
|
11
12
|
/** What to do when a selected component is outside the safe subset. */
|
|
12
13
|
onUnsupported?: UnsupportedCompilerBehavior;
|
|
14
|
+
/**
|
|
15
|
+
* How compiled bindings subscribe to state. `hybrid` keeps compiler-proven
|
|
16
|
+
* dependencies and narrows short-circuited reads at runtime.
|
|
17
|
+
*/
|
|
18
|
+
reactivity?: ReactCompilerReactivity;
|
|
13
19
|
/** Write a machine-readable compiler coverage report after a production build. */
|
|
14
20
|
report?: boolean;
|
|
15
21
|
/** Project-relative report location. Providing it also enables reporting. */
|
|
@@ -25,6 +31,7 @@ interface NormalizedReactCompilerOptions {
|
|
|
25
31
|
mode: ReactCompilerMode;
|
|
26
32
|
directive: string;
|
|
27
33
|
onUnsupported: UnsupportedCompilerBehavior;
|
|
34
|
+
reactivity: ReactCompilerReactivity;
|
|
28
35
|
report: boolean;
|
|
29
36
|
reportFile: string;
|
|
30
37
|
}
|
|
@@ -35,4 +42,4 @@ declare const REACT_RENDERER: Readonly<FarmRenderer>;
|
|
|
35
42
|
/** Select React and optionally enable Farm's experimental AOT compiler. */
|
|
36
43
|
declare function react(options?: ReactRendererOptions): FarmRenderer;
|
|
37
44
|
|
|
38
|
-
export { DEFAULT_COMPILER_DIRECTIVE, DEFAULT_COMPILER_REPORT_FILE, type NormalizedReactCompilerOptions, REACT_RENDERER, type ReactCompilerMode, type ReactCompilerOptions, type ReactRendererOptions, type UnsupportedCompilerBehavior, normalizeReactCompilerOptions, react };
|
|
45
|
+
export { DEFAULT_COMPILER_DIRECTIVE, DEFAULT_COMPILER_REPORT_FILE, type NormalizedReactCompilerOptions, REACT_RENDERER, type ReactCompilerMode, type ReactCompilerOptions, type ReactCompilerReactivity, type ReactRendererOptions, type UnsupportedCompilerBehavior, normalizeReactCompilerOptions, react };
|
package/dist/index.mjs
CHANGED
|
@@ -26,6 +26,10 @@ function normalizeReactCompilerOptions(value) {
|
|
|
26
26
|
if (!["fallback", "warn", "error"].includes(onUnsupported)) {
|
|
27
27
|
throw new TypeError(`Unknown unsupported-component behavior: ${String(onUnsupported)}`);
|
|
28
28
|
}
|
|
29
|
+
const reactivity = options.reactivity || "hybrid";
|
|
30
|
+
if (reactivity !== "static" && reactivity !== "hybrid") {
|
|
31
|
+
throw new TypeError(`Unknown React compiler reactivity mode: ${String(reactivity)}`);
|
|
32
|
+
}
|
|
29
33
|
if (options.report !== void 0 && typeof options.report !== "boolean") {
|
|
30
34
|
throw new TypeError("The React compiler report option must be a boolean.");
|
|
31
35
|
}
|
|
@@ -36,7 +40,7 @@ function normalizeReactCompilerOptions(value) {
|
|
|
36
40
|
}
|
|
37
41
|
const reportFile = normalizeCompilerReportFile(options.reportFile);
|
|
38
42
|
const report = options.report === true || options.reportFile !== void 0;
|
|
39
|
-
return { mode, directive, onUnsupported, report, reportFile };
|
|
43
|
+
return { mode, directive, onUnsupported, reactivity, report, reportFile };
|
|
40
44
|
}
|
|
41
45
|
var REACT_RENDERER = Object.freeze({
|
|
42
46
|
name: "react",
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAwCO,IAAM,0BAAA,GAA6B;AACnC,IAAM,4BAAA,GAA+B;AAE5C,SAAS,4BAA4B,KAAA,EAAwB;AAC3D,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO,4BAAA;AAChC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,KAAA,CAAM,MAAK,EAAG;AAC9C,IAAA,MAAM,IAAI,UAAU,mEAAmE,CAAA;AAAA,EACzF;AACA,EAAA,MAAM,aAAa,KAAA,CAAM,IAAA,EAAK,CAAE,OAAA,CAAQ,OAAO,GAAG,CAAA;AAClD,EAAA,IACE,UAAA,CAAW,UAAA,CAAW,GAAG,CAAA,IACzB,eAAe,IAAA,CAAK,UAAU,CAAA,IAC9B,UAAA,CAAW,KAAA,CAAM,GAAG,CAAA,CAAE,QAAA,CAAS,IAAI,CAAA,EACnC;AACA,IAAA,MAAM,IAAI,UAAU,mEAAmE,CAAA;AAAA,EACzF;AACA,EAAA,OAAO,UAAA;AACT;AAEO,SAAS,8BACd,KAAA,EACgC;AAChC,EAAA,MAAM,OAAA,GAAU,KAAA,KAAU,IAAA,GAAO,EAAC,GAAI,KAAA;AACtC,EAAA,MAAM,IAAA,GAAO,QAAQ,IAAA,IAAQ,OAAA;AAE7B,EAAA,IAAI,IAAA,KAAS,OAAA,IAAW,IAAA,KAAS,YAAA,EAAc;AAC7C,IAAA,MAAM,IAAI,SAAA,CAAU,CAAA,6BAAA,EAAgC,MAAA,CAAO,IAAI,CAAC,CAAA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"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\nexport interface ReactRendererOptions {\n experimental?: {\n /** `true` enables automatic inference; an object customizes selection. */\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}\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\n return { mode, directive, onUnsupported, reactivity, report, reportFile };\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 streaming: { node: true, web: false },\n },\n});\n\n/** Select React and optionally enable Farm's experimental AOT compiler. */\nexport function react(options: ReactRendererOptions = {}): FarmRenderer {\n const compiler = options.experimental?.compiler;\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 streaming: { ...REACT_RENDERER.capabilities?.streaming },\n },\n options: {\n experimental: { compiler: normalizedCompiler },\n },\n };\n}\n\nexport { REACT_RENDERER };\nexport type { FarmRenderer } from \"@farm.js/core/renderer\";\n"]}
|
package/dist/list.cjs
CHANGED
|
@@ -6,9 +6,26 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
6
6
|
|
|
7
7
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
8
8
|
|
|
9
|
+
// src/list.tsx
|
|
10
|
+
|
|
11
|
+
// src/iterable.ts
|
|
12
|
+
var oneShotSnapshots = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function materializeIterable(source) {
|
|
14
|
+
if (source == null) return [];
|
|
15
|
+
const iterator = source[Symbol.iterator]();
|
|
16
|
+
const oneShot = iterator === source && (typeof source === "object" || typeof source === "function");
|
|
17
|
+
if (oneShot) {
|
|
18
|
+
const cached = oneShotSnapshots.get(source);
|
|
19
|
+
if (cached) return cached;
|
|
20
|
+
}
|
|
21
|
+
const items = Array.from({ [Symbol.iterator]: () => iterator });
|
|
22
|
+
if (oneShot) oneShotSnapshots.set(source, items);
|
|
23
|
+
return items;
|
|
24
|
+
}
|
|
25
|
+
|
|
9
26
|
// src/list.tsx
|
|
10
27
|
function List({ each, by, children }) {
|
|
11
|
-
const rows =
|
|
28
|
+
const rows = materializeIterable(each);
|
|
12
29
|
return React__default.default.createElement(
|
|
13
30
|
React__default.default.Fragment,
|
|
14
31
|
null,
|
package/dist/list.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/list.tsx"],"names":["React"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/iterable.ts","../src/list.tsx"],"names":["React"],"mappings":";;;;;;;;;;;AAAA,IAAM,gBAAA,uBAAuB,OAAA,EAAoC;AAG1D,SAAS,oBAA0B,MAAA,EAAmD;AAC3F,EAAA,IAAI,MAAA,IAAU,IAAA,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[]>();\n\n/** Materialize an iterable without consuming a one-shot iterator more than once. */\nexport function materializeIterable<Item>(source: Iterable<Item> | null | undefined): Item[] {\n if (source == null) return [];\n\n const iterator = source[Symbol.iterator]();\n const oneShot =\n iterator === (source as unknown) &&\n (typeof source === \"object\" || typeof source === \"function\");\n if (oneShot) {\n const cached = oneShotSnapshots.get(source as object);\n if (cached) return cached as Item[];\n }\n\n const items = Array.from({ [Symbol.iterator]: () => iterator });\n if (oneShot) oneShotSnapshots.set(source as object, items);\n return items;\n}\n","import React from \"react\";\nimport { materializeIterable } from \"./iterable\";\n\nexport interface ListProps<Item> {\n /** Items to render. Nullish collections are treated as empty. */\n each: Iterable<Item> | null | undefined;\n /** Returns the stable React key for one item. */\n by(item: Item, index: number): React.Key;\n /** Renders one keyed row. */\n children(item: Item, index: number): React.ReactElement;\n}\n\n/**\n * An explicit keyed collection boundary for advanced list expressions.\n *\n * It behaves like ordinary React when the compiler is disabled. With the\n * experimental compiler enabled, eligible usages are isolated so local list\n * updates do not execute the surrounding user component.\n */\nexport function List<Item>({ each, by, children }: ListProps<Item>): React.ReactElement {\n const rows = materializeIterable(each);\n return React.createElement(\n React.Fragment,\n null,\n ...rows.map((item, index) => {\n const row = children(item, index);\n if (!React.isValidElement(row)) {\n throw new TypeError(\"@farm.js/react List children must return one React element.\");\n }\n return React.cloneElement(row, { key: by(item, index) } as React.Attributes);\n }),\n );\n}\n"]}
|
package/dist/list.mjs
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
+
// src/list.tsx
|
|
4
|
+
|
|
5
|
+
// src/iterable.ts
|
|
6
|
+
var oneShotSnapshots = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function materializeIterable(source) {
|
|
8
|
+
if (source == null) return [];
|
|
9
|
+
const iterator = source[Symbol.iterator]();
|
|
10
|
+
const oneShot = iterator === source && (typeof source === "object" || typeof source === "function");
|
|
11
|
+
if (oneShot) {
|
|
12
|
+
const cached = oneShotSnapshots.get(source);
|
|
13
|
+
if (cached) return cached;
|
|
14
|
+
}
|
|
15
|
+
const items = Array.from({ [Symbol.iterator]: () => iterator });
|
|
16
|
+
if (oneShot) oneShotSnapshots.set(source, items);
|
|
17
|
+
return items;
|
|
18
|
+
}
|
|
19
|
+
|
|
3
20
|
// src/list.tsx
|
|
4
21
|
function List({ each, by, children }) {
|
|
5
|
-
const rows =
|
|
22
|
+
const rows = materializeIterable(each);
|
|
6
23
|
return React.createElement(
|
|
7
24
|
React.Fragment,
|
|
8
25
|
null,
|
package/dist/list.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/list.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/iterable.ts","../src/list.tsx"],"names":[],"mappings":";;;;;AAAA,IAAM,gBAAA,uBAAuB,OAAA,EAAoC;AAG1D,SAAS,oBAA0B,MAAA,EAAmD;AAC3F,EAAA,IAAI,MAAA,IAAU,IAAA,EAAM,OAAO,EAAC;AAE5B,EAAA,MAAM,QAAA,GAAW,MAAA,CAAO,MAAA,CAAO,QAAQ,CAAA,EAAE;AACzC,EAAA,MAAM,UACJ,QAAA,KAAc,MAAA,KACb,OAAO,MAAA,KAAW,QAAA,IAAY,OAAO,MAAA,KAAW,UAAA,CAAA;AACnD,EAAA,IAAI,OAAA,EAAS;AACX,IAAA,MAAM,MAAA,GAAS,gBAAA,CAAiB,GAAA,CAAI,MAAgB,CAAA;AACpD,IAAA,IAAI,QAAQ,OAAO,MAAA;AAAA,EACrB;AAEA,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,IAAA,CAAK,EAAE,CAAC,OAAO,QAAQ,GAAG,MAAM,QAAA,EAAU,CAAA;AAC9D,EAAA,IAAI,OAAA,EAAS,gBAAA,CAAiB,GAAA,CAAI,MAAA,EAAkB,KAAK,CAAA;AACzD,EAAA,OAAO,KAAA;AACT;;;ACCO,SAAS,IAAA,CAAW,EAAE,IAAA,EAAM,EAAA,EAAI,UAAS,EAAwC;AACtF,EAAA,MAAM,IAAA,GAAO,oBAAoB,IAAI,CAAA;AACrC,EAAA,OAAO,KAAA,CAAM,aAAA;AAAA,IACX,KAAA,CAAM,QAAA;AAAA,IACN,IAAA;AAAA,IACA,GAAG,IAAA,CAAK,GAAA,CAAI,CAAC,MAAM,KAAA,KAAU;AAC3B,MAAA,MAAM,GAAA,GAAM,QAAA,CAAS,IAAA,EAAM,KAAK,CAAA;AAChC,MAAA,IAAI,CAAC,KAAA,CAAM,cAAA,CAAe,GAAG,CAAA,EAAG;AAC9B,QAAA,MAAM,IAAI,UAAU,6DAA6D,CAAA;AAAA,MACnF;AACA,MAAA,OAAO,KAAA,CAAM,aAAa,GAAA,EAAK,EAAE,KAAK,EAAA,CAAG,IAAA,EAAM,KAAK,CAAA,EAAuB,CAAA;AAAA,IAC7E,CAAC;AAAA,GACH;AACF","file":"list.mjs","sourcesContent":["const oneShotSnapshots = new WeakMap<object, readonly unknown[]>();\n\n/** Materialize an iterable without consuming a one-shot iterator more than once. */\nexport function materializeIterable<Item>(source: Iterable<Item> | null | undefined): Item[] {\n if (source == null) return [];\n\n const iterator = source[Symbol.iterator]();\n const oneShot =\n iterator === (source as unknown) &&\n (typeof source === \"object\" || typeof source === \"function\");\n if (oneShot) {\n const cached = oneShotSnapshots.get(source as object);\n if (cached) return cached as Item[];\n }\n\n const items = Array.from({ [Symbol.iterator]: () => iterator });\n if (oneShot) oneShotSnapshots.set(source as object, items);\n return items;\n}\n","import React from \"react\";\nimport { materializeIterable } from \"./iterable\";\n\nexport interface ListProps<Item> {\n /** Items to render. Nullish collections are treated as empty. */\n each: Iterable<Item> | null | undefined;\n /** Returns the stable React key for one item. */\n by(item: Item, index: number): React.Key;\n /** Renders one keyed row. */\n children(item: Item, index: number): React.ReactElement;\n}\n\n/**\n * An explicit keyed collection boundary for advanced list expressions.\n *\n * It behaves like ordinary React when the compiler is disabled. With the\n * experimental compiler enabled, eligible usages are isolated so local list\n * updates do not execute the surrounding user component.\n */\nexport function List<Item>({ each, by, children }: ListProps<Item>): React.ReactElement {\n const rows = materializeIterable(each);\n return React.createElement(\n React.Fragment,\n null,\n ...rows.map((item, index) => {\n const row = children(item, index);\n if (!React.isValidElement(row)) {\n throw new TypeError(\"@farm.js/react List children must return one React element.\");\n }\n return React.cloneElement(row, { key: by(item, index) } as React.Attributes);\n }),\n );\n}\n"]}
|