@farm.js/react 0.1.0-beta.0
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/LICENSE +22 -0
- package/README.md +75 -0
- package/dist/client.cjs +24 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.mts +2 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.mjs +4 -0
- package/dist/client.mjs.map +1 -0
- package/dist/compiler-runtime.cjs +140 -0
- package/dist/compiler-runtime.cjs.map +1 -0
- package/dist/compiler-runtime.d.mts +36 -0
- package/dist/compiler-runtime.d.ts +36 -0
- package/dist/compiler-runtime.mjs +134 -0
- package/dist/compiler-runtime.mjs.map +1 -0
- package/dist/index.cjs +61 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.mjs +56 -0
- package/dist/index.mjs.map +1 -0
- package/dist/server.cjs +24 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.mts +3 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.mjs +4 -0
- package/dist/server.mjs.map +1 -0
- package/dist/vite.cjs +573 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.mts +9 -0
- package/dist/vite.d.ts +9 -0
- package/dist/vite.mjs +571 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +85 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { FarmRenderer } from '@farm.js/core/renderer';
|
|
2
|
+
export { FarmRenderer } from '@farm.js/core/renderer';
|
|
3
|
+
|
|
4
|
+
type ReactCompilerMode = "infer" | "annotation";
|
|
5
|
+
type UnsupportedCompilerBehavior = "fallback" | "warn" | "error";
|
|
6
|
+
interface ReactCompilerOptions {
|
|
7
|
+
/** Compile every component that the safe subset can prove eligible. */
|
|
8
|
+
mode?: ReactCompilerMode;
|
|
9
|
+
/** Function or module directive used only by annotation mode. */
|
|
10
|
+
directive?: string;
|
|
11
|
+
/** What to do when a selected component is outside the safe subset. */
|
|
12
|
+
onUnsupported?: UnsupportedCompilerBehavior;
|
|
13
|
+
}
|
|
14
|
+
interface ReactRendererOptions {
|
|
15
|
+
experimental?: {
|
|
16
|
+
/** `true` enables automatic inference; an object customizes selection. */
|
|
17
|
+
compiler?: boolean | ReactCompilerOptions;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface NormalizedReactCompilerOptions {
|
|
21
|
+
mode: ReactCompilerMode;
|
|
22
|
+
directive: string;
|
|
23
|
+
onUnsupported: UnsupportedCompilerBehavior;
|
|
24
|
+
}
|
|
25
|
+
declare const DEFAULT_COMPILER_DIRECTIVE = "use compiler";
|
|
26
|
+
declare function normalizeReactCompilerOptions(value: true | ReactCompilerOptions): NormalizedReactCompilerOptions;
|
|
27
|
+
declare const REACT_RENDERER: Readonly<FarmRenderer>;
|
|
28
|
+
/** Select React and optionally enable Farm's experimental AOT compiler. */
|
|
29
|
+
declare function react(options?: ReactRendererOptions): FarmRenderer;
|
|
30
|
+
|
|
31
|
+
export { DEFAULT_COMPILER_DIRECTIVE, type NormalizedReactCompilerOptions, REACT_RENDERER, type ReactCompilerMode, type ReactCompilerOptions, type ReactRendererOptions, type UnsupportedCompilerBehavior, normalizeReactCompilerOptions, react };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var DEFAULT_COMPILER_DIRECTIVE = "use compiler";
|
|
3
|
+
function normalizeReactCompilerOptions(value) {
|
|
4
|
+
const options = value === true ? {} : value;
|
|
5
|
+
const mode = options.mode || "infer";
|
|
6
|
+
if (mode !== "infer" && mode !== "annotation") {
|
|
7
|
+
throw new TypeError(`Unknown React compiler mode: ${String(mode)}`);
|
|
8
|
+
}
|
|
9
|
+
if (options.directive !== void 0 && mode !== "annotation") {
|
|
10
|
+
throw new TypeError("The React compiler directive can only be configured in annotation mode.");
|
|
11
|
+
}
|
|
12
|
+
const directive = options.directive?.trim() || DEFAULT_COMPILER_DIRECTIVE;
|
|
13
|
+
const onUnsupported = options.onUnsupported || "fallback";
|
|
14
|
+
if (!["fallback", "warn", "error"].includes(onUnsupported)) {
|
|
15
|
+
throw new TypeError(`Unknown unsupported-component behavior: ${String(onUnsupported)}`);
|
|
16
|
+
}
|
|
17
|
+
return { mode, directive, onUnsupported };
|
|
18
|
+
}
|
|
19
|
+
var REACT_RENDERER = Object.freeze({
|
|
20
|
+
name: "react",
|
|
21
|
+
vite: "@farm.js/react/vite",
|
|
22
|
+
server: "@farm.js/react/server",
|
|
23
|
+
client: "@farm.js/react/client",
|
|
24
|
+
jsxImportSource: "react",
|
|
25
|
+
dedupe: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"],
|
|
26
|
+
optimizeDeps: [
|
|
27
|
+
"react",
|
|
28
|
+
"react-dom",
|
|
29
|
+
"react-dom/client",
|
|
30
|
+
"react/jsx-runtime",
|
|
31
|
+
"react/jsx-dev-runtime",
|
|
32
|
+
"@farm.js/react/compiler-runtime"
|
|
33
|
+
],
|
|
34
|
+
capabilities: {
|
|
35
|
+
streaming: { node: true, web: false }
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
function react(options = {}) {
|
|
39
|
+
const compiler = options.experimental?.compiler;
|
|
40
|
+
const normalizedCompiler = compiler ? normalizeReactCompilerOptions(compiler) : false;
|
|
41
|
+
return {
|
|
42
|
+
...REACT_RENDERER,
|
|
43
|
+
dedupe: [...REACT_RENDERER.dedupe || []],
|
|
44
|
+
optimizeDeps: [...REACT_RENDERER.optimizeDeps || []],
|
|
45
|
+
capabilities: {
|
|
46
|
+
streaming: { ...REACT_RENDERER.capabilities?.streaming }
|
|
47
|
+
},
|
|
48
|
+
options: {
|
|
49
|
+
experimental: { compiler: normalizedCompiler }
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { DEFAULT_COMPILER_DIRECTIVE, REACT_RENDERER,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,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.mjs","sourcesContent":["import type { FarmRenderer } from \"@farm.js/core/renderer\";\n\nexport type ReactCompilerMode = \"infer\" | \"annotation\";\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\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}\n\nexport const DEFAULT_COMPILER_DIRECTIVE = \"use compiler\";\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 return { mode, directive, onUnsupported };\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/server.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var server = require('@farm.js/core/renderer/react/server');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var server__default = /*#__PURE__*/_interopDefault(server);
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, "default", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return server__default.default; }
|
|
16
|
+
});
|
|
17
|
+
Object.keys(server).forEach(function (k) {
|
|
18
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return server[k]; }
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=server.cjs.map
|
|
24
|
+
//# sourceMappingURL=server.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"server.cjs","sourcesContent":[]}
|
package/dist/server.d.ts
ADDED
package/dist/server.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"server.mjs","sourcesContent":[]}
|