@farm.js/react 0.1.0-beta.39 → 0.1.0-beta.40
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/compiled-root.cjs +17 -0
- package/dist/compiled-root.cjs.map +1 -0
- package/dist/compiled-root.d.mts +12 -0
- package/dist/compiled-root.d.ts +12 -0
- package/dist/compiled-root.mjs +14 -0
- package/dist/compiled-root.mjs.map +1 -0
- package/dist/compiler-runtime.cjs +434 -12
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +51 -2
- package/dist/compiler-runtime.d.ts +51 -2
- package/dist/compiler-runtime.mjs +434 -13
- 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 +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/dist/vite.cjs +488 -66
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.mts +8 -1
- package/dist/vite.d.ts +8 -1
- package/dist/vite.mjs +488 -67
- package/dist/vite.mjs.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var compilerRuntime = require('@farm.js/react/compiler-runtime');
|
|
4
|
+
|
|
5
|
+
// src/compiled-root.ts
|
|
6
|
+
var loadReactDOM = () => import('react-dom/client');
|
|
7
|
+
function createCompiledRoot(container, options = {}) {
|
|
8
|
+
return compilerRuntime.createCompiledRoot(container, options, loadReactDOM);
|
|
9
|
+
}
|
|
10
|
+
function createRoot(container, options) {
|
|
11
|
+
return createCompiledRoot(container, { reactRootOptions: options });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.createCompiledRoot = createCompiledRoot;
|
|
15
|
+
exports.createRoot = createRoot;
|
|
16
|
+
//# sourceMappingURL=compiled-root.cjs.map
|
|
17
|
+
//# sourceMappingURL=compiled-root.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/compiled-root.ts"],"names":["createCompiledRootWithLoader"],"mappings":";;;;;AAYA,IAAM,YAAA,GAAe,MAAM,OAAO,kBAAkB,CAAA;AAG7C,SAAS,kBAAA,CACd,SAAA,EACA,OAAA,GAA+B,EAAC,EAClB;AACd,EAAA,OAAOA,kCAAA,CAA6B,SAAA,EAAW,OAAA,EAAS,YAAY,CAAA;AACtE;AAMO,SAAS,UAAA,CAAW,WAAoB,OAAA,EAAiC;AAC9E,EAAA,OAAO,kBAAA,CAAmB,SAAA,EAAW,EAAE,gBAAA,EAAkB,SAAS,CAAA;AACpE","file":"compiled-root.cjs","sourcesContent":["// Experimental: mount fully compiled trees without React DOM; see createCompiledRoot() in the\n// compiler runtime. The build points the runtime import at @farm.js/react/compiler-runtime, so an\n// app shares one copy of the compiler runtime with the components it compiled.\nimport {\n createCompiledRoot as createCompiledRootWithLoader,\n type CompiledRoot,\n type CompiledRootOptions,\n} from \"./compiler-runtime\";\n\nexport type { CompiledRoot, CompiledRootOptions };\n\n// React DOM is loaded only when a root needs it.\nconst loadReactDOM = () => import(\"react-dom/client\");\n\n/** Mounts a fully compiled tree without React DOM, falling back to React DOM when it must. */\nexport function createCompiledRoot(\n container: Element,\n options: CompiledRootOptions = {},\n): CompiledRoot {\n return createCompiledRootWithLoader(container, options, loadReactDOM);\n}\n\n/**\n * Drop-in for `createRoot` from `react-dom/client`. With the compiler on, the build points an\n * app's own `createRoot` import here. React DOM's root options apply if the root falls back to it.\n */\nexport function createRoot(container: Element, options?: unknown): CompiledRoot {\n return createCompiledRoot(container, { reactRootOptions: options });\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CompiledRootOptions, CompiledRoot } from './compiler-runtime.mjs';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
/** Mounts a fully compiled tree without React DOM, falling back to React DOM when it must. */
|
|
5
|
+
declare function createCompiledRoot(container: Element, options?: CompiledRootOptions): CompiledRoot;
|
|
6
|
+
/**
|
|
7
|
+
* Drop-in for `createRoot` from `react-dom/client`. With the compiler on, the build points an
|
|
8
|
+
* app's own `createRoot` import here. React DOM's root options apply if the root falls back to it.
|
|
9
|
+
*/
|
|
10
|
+
declare function createRoot(container: Element, options?: unknown): CompiledRoot;
|
|
11
|
+
|
|
12
|
+
export { CompiledRoot, CompiledRootOptions, createCompiledRoot, createRoot };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CompiledRootOptions, CompiledRoot } from './compiler-runtime.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
/** Mounts a fully compiled tree without React DOM, falling back to React DOM when it must. */
|
|
5
|
+
declare function createCompiledRoot(container: Element, options?: CompiledRootOptions): CompiledRoot;
|
|
6
|
+
/**
|
|
7
|
+
* Drop-in for `createRoot` from `react-dom/client`. With the compiler on, the build points an
|
|
8
|
+
* app's own `createRoot` import here. React DOM's root options apply if the root falls back to it.
|
|
9
|
+
*/
|
|
10
|
+
declare function createRoot(container: Element, options?: unknown): CompiledRoot;
|
|
11
|
+
|
|
12
|
+
export { CompiledRoot, CompiledRootOptions, createCompiledRoot, createRoot };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createCompiledRoot as createCompiledRoot$1 } from '@farm.js/react/compiler-runtime';
|
|
2
|
+
|
|
3
|
+
// src/compiled-root.ts
|
|
4
|
+
var loadReactDOM = () => import('react-dom/client');
|
|
5
|
+
function createCompiledRoot(container, options = {}) {
|
|
6
|
+
return createCompiledRoot$1(container, options, loadReactDOM);
|
|
7
|
+
}
|
|
8
|
+
function createRoot(container, options) {
|
|
9
|
+
return createCompiledRoot(container, { reactRootOptions: options });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { createCompiledRoot, createRoot };
|
|
13
|
+
//# sourceMappingURL=compiled-root.mjs.map
|
|
14
|
+
//# sourceMappingURL=compiled-root.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/compiled-root.ts"],"names":["createCompiledRootWithLoader"],"mappings":";;;AAYA,IAAM,YAAA,GAAe,MAAM,OAAO,kBAAkB,CAAA;AAG7C,SAAS,kBAAA,CACd,SAAA,EACA,OAAA,GAA+B,EAAC,EAClB;AACd,EAAA,OAAOA,oBAAA,CAA6B,SAAA,EAAW,OAAA,EAAS,YAAY,CAAA;AACtE;AAMO,SAAS,UAAA,CAAW,WAAoB,OAAA,EAAiC;AAC9E,EAAA,OAAO,kBAAA,CAAmB,SAAA,EAAW,EAAE,gBAAA,EAAkB,SAAS,CAAA;AACpE","file":"compiled-root.mjs","sourcesContent":["// Experimental: mount fully compiled trees without React DOM; see createCompiledRoot() in the\n// compiler runtime. The build points the runtime import at @farm.js/react/compiler-runtime, so an\n// app shares one copy of the compiler runtime with the components it compiled.\nimport {\n createCompiledRoot as createCompiledRootWithLoader,\n type CompiledRoot,\n type CompiledRootOptions,\n} from \"./compiler-runtime\";\n\nexport type { CompiledRoot, CompiledRootOptions };\n\n// React DOM is loaded only when a root needs it.\nconst loadReactDOM = () => import(\"react-dom/client\");\n\n/** Mounts a fully compiled tree without React DOM, falling back to React DOM when it must. */\nexport function createCompiledRoot(\n container: Element,\n options: CompiledRootOptions = {},\n): CompiledRoot {\n return createCompiledRootWithLoader(container, options, loadReactDOM);\n}\n\n/**\n * Drop-in for `createRoot` from `react-dom/client`. With the compiler on, the build points an\n * app's own `createRoot` import here. React DOM's root options apply if the root falls back to it.\n */\nexport function createRoot(container: Element, options?: unknown): CompiledRoot {\n return createCompiledRoot(container, { reactRootOptions: options });\n}\n"]}
|
|
@@ -1731,7 +1731,7 @@ function updateAttribute(element, name, value) {
|
|
|
1731
1731
|
if (name === "value" && (isInputElement(element) || isTextAreaElement(element))) {
|
|
1732
1732
|
const nextValue = value === null || value === void 0 ? "" : String(value);
|
|
1733
1733
|
if (element.value !== nextValue) element.value = nextValue;
|
|
1734
|
-
if (value != null && isInputElement(element) && (element.type !== "number" || element.ownerDocument.activeElement !== element) && element.defaultValue !== nextValue) {
|
|
1734
|
+
if (value != null && (isTextAreaElement(element) || isInputElement(element) && (element.type !== "number" || element.ownerDocument.activeElement !== element)) && element.defaultValue !== nextValue) {
|
|
1735
1735
|
element.defaultValue = nextValue;
|
|
1736
1736
|
}
|
|
1737
1737
|
return;
|
|
@@ -1867,10 +1867,18 @@ function createKeyedListBlockComponent(owner) {
|
|
|
1867
1867
|
function isCompilerHostElement(value) {
|
|
1868
1868
|
return typeof value === "object" && value !== null && value.kind === "element";
|
|
1869
1869
|
}
|
|
1870
|
-
function
|
|
1871
|
-
|
|
1870
|
+
function initializeFieldDefault(element, name, value) {
|
|
1871
|
+
if (name === "value" && value != null && (isInputElement(element) || isTextAreaElement(element))) {
|
|
1872
|
+
element.defaultValue = String(value);
|
|
1873
|
+
} else if (name === "checked" && isInputElement(element)) {
|
|
1874
|
+
element.defaultChecked = Boolean(value);
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
function createCompilerHostElement(document2, descriptor) {
|
|
1878
|
+
const element = document2.createElement(descriptor.tag);
|
|
1872
1879
|
for (const attribute of descriptor.attributes) {
|
|
1873
1880
|
updateAttribute(element, attribute.name, attribute.value);
|
|
1881
|
+
initializeFieldDefault(element, attribute.name, attribute.value);
|
|
1874
1882
|
}
|
|
1875
1883
|
for (const style of descriptor.styles) updateStyle(element, style.name, style.value);
|
|
1876
1884
|
const appendChild = (child) => {
|
|
@@ -1879,11 +1887,11 @@ function createCompilerHostElement(document, descriptor) {
|
|
|
1879
1887
|
return;
|
|
1880
1888
|
}
|
|
1881
1889
|
if (isCompilerHostElement(child)) {
|
|
1882
|
-
element.append(createCompilerHostElement(
|
|
1890
|
+
element.append(createCompilerHostElement(document2, child));
|
|
1883
1891
|
return;
|
|
1884
1892
|
}
|
|
1885
1893
|
const text = renderTextValue(child);
|
|
1886
|
-
if (text) element.append(
|
|
1894
|
+
if (text) element.append(document2.createTextNode(text));
|
|
1887
1895
|
};
|
|
1888
1896
|
for (const child of materializeCompilerHostChildren(descriptor)) appendChild(child);
|
|
1889
1897
|
for (const attribute of descriptor.attributes) {
|
|
@@ -2548,9 +2556,9 @@ function readKeyedRowBindingValues(props, item, index) {
|
|
|
2548
2556
|
return values;
|
|
2549
2557
|
}
|
|
2550
2558
|
var KEYED_ROW_TEMPLATES = /* @__PURE__ */ new WeakMap();
|
|
2551
|
-
function createKeyedRowInstance(props,
|
|
2559
|
+
function createKeyedRowInstance(props, document2, key, item, index) {
|
|
2552
2560
|
const template = props.cloneRows && KEYED_ROW_TEMPLATES.get(props);
|
|
2553
|
-
const element = template ? template.element.cloneNode(true) : createCompilerHostElement(
|
|
2561
|
+
const element = template ? template.element.cloneNode(true) : createCompilerHostElement(document2, props.create(item, index));
|
|
2554
2562
|
const instance = {
|
|
2555
2563
|
key,
|
|
2556
2564
|
element,
|
|
@@ -6144,7 +6152,13 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6144
6152
|
class FarmKeyedRowsBlock extends React__default.default.Component {
|
|
6145
6153
|
constructor() {
|
|
6146
6154
|
super(...arguments);
|
|
6147
|
-
|
|
6155
|
+
// Host-block rows have no React-owned mode, so rows whose events the container cannot run
|
|
6156
|
+
// here (onChange under React DOM) are rendered by React from the start.
|
|
6157
|
+
this.state = {
|
|
6158
|
+
fallback: Boolean(
|
|
6159
|
+
this.props.hostBlocks && this.props.events?.length && !(this.props.delegateEvents && this.props.events.every((event) => event.path !== void 0))
|
|
6160
|
+
)
|
|
6161
|
+
};
|
|
6148
6162
|
this.root = null;
|
|
6149
6163
|
this.mounted = false;
|
|
6150
6164
|
this.fallbackRequested = false;
|
|
@@ -7058,7 +7072,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
7058
7072
|
componentDidMount() {
|
|
7059
7073
|
this.mounted = true;
|
|
7060
7074
|
this.listen();
|
|
7061
|
-
if (!this.adopt()) this.activateFallback();
|
|
7075
|
+
if (!this.state.fallback && !this.adopt()) this.activateFallback();
|
|
7062
7076
|
}
|
|
7063
7077
|
componentWillUnmount() {
|
|
7064
7078
|
this.mounted = false;
|
|
@@ -7101,11 +7115,39 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
7101
7115
|
keyedTargets: createKeyedTargetRuntime
|
|
7102
7116
|
});
|
|
7103
7117
|
}
|
|
7118
|
+
function dispatchKeyedRowEvent(descriptors, instance, name, event) {
|
|
7119
|
+
const target = event.target;
|
|
7120
|
+
const capture = name.endsWith("Capture");
|
|
7121
|
+
const matches = [];
|
|
7122
|
+
for (const descriptor of descriptors) {
|
|
7123
|
+
if (descriptor.name !== name || descriptor.path === void 0) continue;
|
|
7124
|
+
const host = findCompilerHostTarget(instance.element, descriptor.path);
|
|
7125
|
+
if (host && (host === target || host.contains(target))) matches.push({ descriptor, host });
|
|
7126
|
+
}
|
|
7127
|
+
matches.sort(
|
|
7128
|
+
(left, right) => capture ? left.descriptor.path.length - right.descriptor.path.length : right.descriptor.path.length - left.descriptor.path.length
|
|
7129
|
+
);
|
|
7130
|
+
for (const { descriptor, host } of matches) {
|
|
7131
|
+
const own = Object.getOwnPropertyDescriptor(event, "currentTarget");
|
|
7132
|
+
try {
|
|
7133
|
+
Object.defineProperty(event, "currentTarget", { configurable: true, value: host });
|
|
7134
|
+
descriptor.invoke(instance.item, instance.index, event);
|
|
7135
|
+
} finally {
|
|
7136
|
+
if (own) Object.defineProperty(event, "currentTarget", own);
|
|
7137
|
+
else Reflect.deleteProperty(event, "currentTarget");
|
|
7138
|
+
}
|
|
7139
|
+
if (event.isPropagationStopped()) break;
|
|
7140
|
+
}
|
|
7141
|
+
}
|
|
7104
7142
|
function createKeyedRangesBlockComponent(owner) {
|
|
7105
7143
|
class FarmKeyedRangesBlock extends React__default.default.Component {
|
|
7106
7144
|
constructor() {
|
|
7107
7145
|
super(...arguments);
|
|
7108
|
-
|
|
7146
|
+
// Rows whose events the container runs only without React DOM (onChange) are rendered by
|
|
7147
|
+
// React here, from the start, with their own handlers.
|
|
7148
|
+
this.state = {
|
|
7149
|
+
fallback: Boolean(this.props.delegateEventsWithoutReact && !this.props.delegateEvents)
|
|
7150
|
+
};
|
|
7109
7151
|
this.root = null;
|
|
7110
7152
|
this.mounted = false;
|
|
7111
7153
|
this.fallbackRequested = false;
|
|
@@ -7124,6 +7166,9 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
7124
7166
|
this.refresh = (afterCommit) => {
|
|
7125
7167
|
this.reconcile(afterCommit);
|
|
7126
7168
|
};
|
|
7169
|
+
// React renders rows with their handlers only while it owns them (fallback). Otherwise the
|
|
7170
|
+
// container dispatches each event to the row the runtime knows, with its current item.
|
|
7171
|
+
this.rowEvent = (item, index, eventId, rangeIndex) => this.state.fallback || !this.currentProps.delegateEvents ? (event) => this.currentProps.ranges[rangeIndex]?.events?.[eventId]?.invoke(item, index, event) : void 0;
|
|
7127
7172
|
}
|
|
7128
7173
|
readRange(range) {
|
|
7129
7174
|
const items = materializeIterable(range.items());
|
|
@@ -7322,7 +7367,7 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
7322
7367
|
componentDidMount() {
|
|
7323
7368
|
this.mounted = true;
|
|
7324
7369
|
this.listen();
|
|
7325
|
-
if (!this.adopt()) this.activateFallback();
|
|
7370
|
+
if (!this.state.fallback && !this.adopt()) this.activateFallback();
|
|
7326
7371
|
}
|
|
7327
7372
|
componentDidUpdate() {
|
|
7328
7373
|
this.listen();
|
|
@@ -7340,14 +7385,44 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
7340
7385
|
this.staticSegments = [];
|
|
7341
7386
|
this.staticValues.length = 0;
|
|
7342
7387
|
}
|
|
7388
|
+
dispatchRowEvent(name, event) {
|
|
7389
|
+
const target = event.target;
|
|
7390
|
+
if (!this.root || !target) return;
|
|
7391
|
+
let element = target.nodeType === 1 ? target : target.parentElement;
|
|
7392
|
+
while (element && element.parentElement !== this.root) element = element.parentElement;
|
|
7393
|
+
if (!element) return;
|
|
7394
|
+
for (let rangeIndex = 0; rangeIndex < this.rangeInstances.length; rangeIndex += 1) {
|
|
7395
|
+
for (const instance of this.rangeInstances[rangeIndex].values()) {
|
|
7396
|
+
if (instance.element !== element) continue;
|
|
7397
|
+
dispatchKeyedRowEvent(
|
|
7398
|
+
this.currentProps.ranges[rangeIndex].events || [],
|
|
7399
|
+
instance,
|
|
7400
|
+
name,
|
|
7401
|
+
event
|
|
7402
|
+
);
|
|
7403
|
+
return;
|
|
7404
|
+
}
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7343
7407
|
render() {
|
|
7344
|
-
const container = this.currentProps.render();
|
|
7408
|
+
const container = this.currentProps.render(this.rowEvent);
|
|
7345
7409
|
if (!React__default.default.isValidElement(container) || typeof container.type !== "string") {
|
|
7346
7410
|
throw new TypeError(
|
|
7347
7411
|
`Compiled keyed ranges ${this.currentProps.id} must own one host container.`
|
|
7348
7412
|
);
|
|
7349
7413
|
}
|
|
7414
|
+
const delegated = {};
|
|
7415
|
+
if (this.currentProps.delegateEvents && !this.state.fallback) {
|
|
7416
|
+
for (const range of this.currentProps.ranges) {
|
|
7417
|
+
for (const { name } of range.events || []) {
|
|
7418
|
+
delegated[name] = (event) => {
|
|
7419
|
+
if (!event.isPropagationStopped()) this.dispatchRowEvent(name, event);
|
|
7420
|
+
};
|
|
7421
|
+
}
|
|
7422
|
+
}
|
|
7423
|
+
}
|
|
7350
7424
|
return React__default.default.cloneElement(container, {
|
|
7425
|
+
...delegated,
|
|
7351
7426
|
key: this.state.fallback ? `react-${this.fallbackVersion}` : "compiled",
|
|
7352
7427
|
ref: this.captureRoot
|
|
7353
7428
|
});
|
|
@@ -8797,6 +8872,352 @@ var COMPLETE_RUNTIME_FEATURES = [
|
|
|
8797
8872
|
function createCompiledComponent(definition) {
|
|
8798
8873
|
return createCompiledComponentWithFeatures(definition, COMPLETE_RUNTIME_FEATURES);
|
|
8799
8874
|
}
|
|
8875
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
8876
|
+
var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
|
|
8877
|
+
var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
|
|
8878
|
+
var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
|
|
8879
|
+
var COMPILED_ROOT_EVENTS = {
|
|
8880
|
+
onClick: "click",
|
|
8881
|
+
onDoubleClick: "dblclick",
|
|
8882
|
+
onContextMenu: "contextmenu",
|
|
8883
|
+
onMouseDown: "mousedown",
|
|
8884
|
+
onMouseUp: "mouseup",
|
|
8885
|
+
onMouseMove: "mousemove",
|
|
8886
|
+
onMouseOver: "mouseover",
|
|
8887
|
+
onMouseOut: "mouseout",
|
|
8888
|
+
onMouseEnter: "mouseenter",
|
|
8889
|
+
onMouseLeave: "mouseleave",
|
|
8890
|
+
onPointerDown: "pointerdown",
|
|
8891
|
+
onPointerUp: "pointerup",
|
|
8892
|
+
onPointerMove: "pointermove",
|
|
8893
|
+
onPointerOver: "pointerover",
|
|
8894
|
+
onPointerOut: "pointerout",
|
|
8895
|
+
onPointerEnter: "pointerenter",
|
|
8896
|
+
onPointerLeave: "pointerleave",
|
|
8897
|
+
onPointerCancel: "pointercancel",
|
|
8898
|
+
onKeyDown: "keydown",
|
|
8899
|
+
onKeyUp: "keyup",
|
|
8900
|
+
onInput: "input",
|
|
8901
|
+
onSubmit: "submit",
|
|
8902
|
+
onReset: "reset",
|
|
8903
|
+
// React's onFocus and onBlur bubble, like focusin and focusout.
|
|
8904
|
+
onFocus: "focusin",
|
|
8905
|
+
onBlur: "focusout"
|
|
8906
|
+
};
|
|
8907
|
+
var COMPILED_ROOT_CAMEL_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
8908
|
+
"className",
|
|
8909
|
+
"htmlFor",
|
|
8910
|
+
"tabIndex",
|
|
8911
|
+
"readOnly",
|
|
8912
|
+
"maxLength",
|
|
8913
|
+
"minLength",
|
|
8914
|
+
"colSpan",
|
|
8915
|
+
"rowSpan",
|
|
8916
|
+
"autoComplete",
|
|
8917
|
+
"inputMode",
|
|
8918
|
+
"enterKeyHint"
|
|
8919
|
+
]);
|
|
8920
|
+
var CompiledRootUnsupported = class extends Error {
|
|
8921
|
+
};
|
|
8922
|
+
function renderWithoutHooks(name, render) {
|
|
8923
|
+
const internals = React__default.default;
|
|
8924
|
+
const react19 = internals.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
8925
|
+
const react18 = internals.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentDispatcher;
|
|
8926
|
+
const rejectHooks = new Proxy(
|
|
8927
|
+
{},
|
|
8928
|
+
{
|
|
8929
|
+
get() {
|
|
8930
|
+
throw new CompiledRootUnsupported(`${name}, which calls hooks`);
|
|
8931
|
+
}
|
|
8932
|
+
}
|
|
8933
|
+
);
|
|
8934
|
+
const previous = react19 ? react19.H : react18?.current;
|
|
8935
|
+
if (react19) react19.H = rejectHooks;
|
|
8936
|
+
else if (react18) react18.current = rejectHooks;
|
|
8937
|
+
try {
|
|
8938
|
+
return render();
|
|
8939
|
+
} catch (error) {
|
|
8940
|
+
if (error instanceof CompiledRootUnsupported) throw error;
|
|
8941
|
+
throw new CompiledRootUnsupported(`${name}: ${error}`);
|
|
8942
|
+
} finally {
|
|
8943
|
+
if (react19) react19.H = previous;
|
|
8944
|
+
else if (react18) react18.current = previous;
|
|
8945
|
+
}
|
|
8946
|
+
}
|
|
8947
|
+
function isFarmCompilerClass(type) {
|
|
8948
|
+
if (typeof type !== "function" || !type.prototype?.isReactComponent) return false;
|
|
8949
|
+
const displayName = type.displayName;
|
|
8950
|
+
return typeof displayName === "string" && displayName.startsWith("FarmCompiled");
|
|
8951
|
+
}
|
|
8952
|
+
function compiledRootUpdatesWithoutReact(displayName, props) {
|
|
8953
|
+
if (displayName.startsWith("FarmCompiled(")) return true;
|
|
8954
|
+
if (displayName === "FarmCompiledKeyedRanges") return true;
|
|
8955
|
+
if (displayName !== "FarmCompiledKeyedRows") return false;
|
|
8956
|
+
const rows = props;
|
|
8957
|
+
const delegated = Boolean(
|
|
8958
|
+
(rows.delegateEvents || rows.delegateEventsWithoutReact) && rows.events?.length && rows.events.every((event) => event.path !== void 0)
|
|
8959
|
+
);
|
|
8960
|
+
return !rows.conditionals?.length && (!rows.events?.length || delegated);
|
|
8961
|
+
}
|
|
8962
|
+
function toCompiledRootEvent(nativeEvent, currentTarget, type) {
|
|
8963
|
+
let propagationStopped = false;
|
|
8964
|
+
const own = {
|
|
8965
|
+
nativeEvent,
|
|
8966
|
+
currentTarget,
|
|
8967
|
+
type,
|
|
8968
|
+
stopPropagation() {
|
|
8969
|
+
propagationStopped = true;
|
|
8970
|
+
nativeEvent.stopPropagation();
|
|
8971
|
+
},
|
|
8972
|
+
isPropagationStopped: () => propagationStopped,
|
|
8973
|
+
isDefaultPrevented: () => nativeEvent.defaultPrevented,
|
|
8974
|
+
persist() {
|
|
8975
|
+
}
|
|
8976
|
+
};
|
|
8977
|
+
return new Proxy(own, {
|
|
8978
|
+
get(target, key) {
|
|
8979
|
+
if (key in target) return target[key];
|
|
8980
|
+
const value = nativeEvent[key];
|
|
8981
|
+
return typeof value === "function" ? value.bind(nativeEvent) : value;
|
|
8982
|
+
}
|
|
8983
|
+
});
|
|
8984
|
+
}
|
|
8985
|
+
function compiledRootChangeEvent(element) {
|
|
8986
|
+
if (element instanceof HTMLSelectElement) return "change";
|
|
8987
|
+
if (element instanceof HTMLInputElement) {
|
|
8988
|
+
return element.type === "checkbox" || element.type === "radio" || element.type === "file" ? "change" : "input";
|
|
8989
|
+
}
|
|
8990
|
+
return element instanceof HTMLTextAreaElement ? "input" : "";
|
|
8991
|
+
}
|
|
8992
|
+
function setCompiledRootEvent(element, name, handler) {
|
|
8993
|
+
if (handler === null || handler === void 0) return;
|
|
8994
|
+
if (typeof handler !== "function") throw new CompiledRootUnsupported(`${name} value`);
|
|
8995
|
+
const capture = name.endsWith("Capture");
|
|
8996
|
+
const reactName = capture ? name.slice(0, -"Capture".length) : name;
|
|
8997
|
+
if (reactName === "onChange" && !compiledRootChangeEvent(element)) {
|
|
8998
|
+
for (const type of ["input", "change"]) {
|
|
8999
|
+
element.addEventListener(
|
|
9000
|
+
type,
|
|
9001
|
+
(event) => {
|
|
9002
|
+
const target = event.target;
|
|
9003
|
+
if (target instanceof Element && compiledRootChangeEvent(target) === type) {
|
|
9004
|
+
handler(toCompiledRootEvent(event, element, "change"));
|
|
9005
|
+
}
|
|
9006
|
+
},
|
|
9007
|
+
capture
|
|
9008
|
+
);
|
|
9009
|
+
}
|
|
9010
|
+
return;
|
|
9011
|
+
}
|
|
9012
|
+
const nativeType = reactName === "onChange" ? compiledRootChangeEvent(element) : COMPILED_ROOT_EVENTS[reactName];
|
|
9013
|
+
if (!nativeType) throw new CompiledRootUnsupported(`the ${name} event`);
|
|
9014
|
+
const reactType = reactName === "onFocus" ? "focus" : reactName === "onBlur" ? "blur" : reactName === "onChange" ? "change" : nativeType;
|
|
9015
|
+
element.addEventListener(
|
|
9016
|
+
nativeType,
|
|
9017
|
+
(event) => handler(toCompiledRootEvent(event, element, reactType)),
|
|
9018
|
+
capture
|
|
9019
|
+
);
|
|
9020
|
+
}
|
|
9021
|
+
function setCompiledRootProp(element, name, value) {
|
|
9022
|
+
if (name === "children" || name === "key" || name === "ref") return;
|
|
9023
|
+
if (name === "suppressHydrationWarning" || name === "suppressContentEditableWarning") return;
|
|
9024
|
+
if (/^on[A-Z]/.test(name)) return setCompiledRootEvent(element, name, value);
|
|
9025
|
+
if (name === "style") {
|
|
9026
|
+
if (value === null || value === void 0) return;
|
|
9027
|
+
if (typeof value !== "object") throw new CompiledRootUnsupported("a non-object style");
|
|
9028
|
+
for (const [property, styleValue] of Object.entries(value)) {
|
|
9029
|
+
updateStyle(element, property, styleValue);
|
|
9030
|
+
}
|
|
9031
|
+
return;
|
|
9032
|
+
}
|
|
9033
|
+
if (name === "dangerouslySetInnerHTML") {
|
|
9034
|
+
const html = value?.__html;
|
|
9035
|
+
if (html !== null && html !== void 0) element.innerHTML = String(html);
|
|
9036
|
+
return;
|
|
9037
|
+
}
|
|
9038
|
+
if (value !== null && value !== void 0 && typeof value === "object") {
|
|
9039
|
+
throw new CompiledRootUnsupported(`an object ${name} value`);
|
|
9040
|
+
}
|
|
9041
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
9042
|
+
throw new CompiledRootUnsupported(`a ${typeof value} ${name} value`);
|
|
9043
|
+
}
|
|
9044
|
+
const svg = element.namespaceURI === SVG_NAMESPACE;
|
|
9045
|
+
if (/[A-Z]/.test(name) && (svg || !COMPILED_ROOT_CAMEL_ATTRIBUTES.has(name))) {
|
|
9046
|
+
if (!(svg && (name === "className" || name === "viewBox"))) {
|
|
9047
|
+
throw new CompiledRootUnsupported(`the ${name} prop`);
|
|
9048
|
+
}
|
|
9049
|
+
}
|
|
9050
|
+
updateAttribute(element, name, value);
|
|
9051
|
+
initializeFieldDefault(element, name, value);
|
|
9052
|
+
}
|
|
9053
|
+
function mountCompiledRootNode(node, parent, namespace, mount, updater) {
|
|
9054
|
+
if (node === null || node === void 0 || typeof node === "boolean") return;
|
|
9055
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "bigint") {
|
|
9056
|
+
parent.appendChild(document.createTextNode(String(node)));
|
|
9057
|
+
return;
|
|
9058
|
+
}
|
|
9059
|
+
if (Array.isArray(node) || typeof node === "object" && Symbol.iterator in node) {
|
|
9060
|
+
for (const child of node) {
|
|
9061
|
+
mountCompiledRootNode(child, parent, namespace, mount, updater);
|
|
9062
|
+
}
|
|
9063
|
+
return;
|
|
9064
|
+
}
|
|
9065
|
+
if (!React__default.default.isValidElement(node)) {
|
|
9066
|
+
throw new CompiledRootUnsupported(
|
|
9067
|
+
node?.$$typeof === REACT_PORTAL_TYPE ? "a portal" : "a child"
|
|
9068
|
+
);
|
|
9069
|
+
}
|
|
9070
|
+
const { type } = node;
|
|
9071
|
+
const props = node.props;
|
|
9072
|
+
if (type === React__default.default.Fragment || type === React__default.default.StrictMode) {
|
|
9073
|
+
return mountCompiledRootNode(props.children, parent, namespace, mount, updater);
|
|
9074
|
+
}
|
|
9075
|
+
if (typeof type === "string") {
|
|
9076
|
+
const elementNamespace = type === "svg" ? SVG_NAMESPACE : namespace;
|
|
9077
|
+
const element = elementNamespace ? document.createElementNS(elementNamespace, type) : document.createElement(type);
|
|
9078
|
+
if (props.type !== void 0) setCompiledRootProp(element, "type", props.type);
|
|
9079
|
+
for (const name in props) {
|
|
9080
|
+
if (name === "type" || name === "value" && type === "select") continue;
|
|
9081
|
+
setCompiledRootProp(element, name, props[name]);
|
|
9082
|
+
}
|
|
9083
|
+
if (props.dangerouslySetInnerHTML === void 0) {
|
|
9084
|
+
mountCompiledRootNode(
|
|
9085
|
+
props.children,
|
|
9086
|
+
element,
|
|
9087
|
+
type === "foreignObject" ? null : elementNamespace,
|
|
9088
|
+
mount,
|
|
9089
|
+
updater
|
|
9090
|
+
);
|
|
9091
|
+
}
|
|
9092
|
+
if (type === "select" && props.value !== void 0) {
|
|
9093
|
+
setCompiledRootProp(element, "value", props.value);
|
|
9094
|
+
}
|
|
9095
|
+
parent.appendChild(element);
|
|
9096
|
+
const ref = props.ref ?? node.ref;
|
|
9097
|
+
if (typeof ref === "function") mount.effects.push(() => ref(element));
|
|
9098
|
+
else if (ref && typeof ref === "object") {
|
|
9099
|
+
mount.effects.push(() => {
|
|
9100
|
+
ref.current = element;
|
|
9101
|
+
});
|
|
9102
|
+
}
|
|
9103
|
+
return;
|
|
9104
|
+
}
|
|
9105
|
+
if (isFarmCompilerClass(type)) {
|
|
9106
|
+
const displayName = type.displayName;
|
|
9107
|
+
if (!compiledRootUpdatesWithoutReact(displayName, props)) {
|
|
9108
|
+
throw new CompiledRootUnsupported(`${displayName}, which updates through React`);
|
|
9109
|
+
}
|
|
9110
|
+
const Component = type;
|
|
9111
|
+
const instanceProps = props.delegateEventsWithoutReact ? { ...props, delegateEvents: true } : props;
|
|
9112
|
+
const instance = new Component(instanceProps);
|
|
9113
|
+
instance.props = instanceProps;
|
|
9114
|
+
instance.updater = updater;
|
|
9115
|
+
const derived = type.getDerivedStateFromProps;
|
|
9116
|
+
if (derived) {
|
|
9117
|
+
const next = derived(props, instance.state);
|
|
9118
|
+
if (next) instance.state = { ...instance.state, ...next };
|
|
9119
|
+
}
|
|
9120
|
+
mountCompiledRootNode(instance.render(), parent, namespace, mount, updater);
|
|
9121
|
+
mount.instances.push(instance);
|
|
9122
|
+
if (instance.componentDidMount) mount.effects.push(() => instance.componentDidMount());
|
|
9123
|
+
return;
|
|
9124
|
+
}
|
|
9125
|
+
if (typeof type === "function" && !type.prototype?.isReactComponent) {
|
|
9126
|
+
const rendered = renderWithoutHooks(
|
|
9127
|
+
type.name || "a function component",
|
|
9128
|
+
() => type(props)
|
|
9129
|
+
);
|
|
9130
|
+
return mountCompiledRootNode(rendered, parent, namespace, mount, updater);
|
|
9131
|
+
}
|
|
9132
|
+
const typeTag = type?.$$typeof;
|
|
9133
|
+
if (typeTag === REACT_MEMO_TYPE) {
|
|
9134
|
+
const inner = type.type;
|
|
9135
|
+
return mountCompiledRootNode(
|
|
9136
|
+
React__default.default.createElement(inner, props),
|
|
9137
|
+
parent,
|
|
9138
|
+
namespace,
|
|
9139
|
+
mount,
|
|
9140
|
+
updater
|
|
9141
|
+
);
|
|
9142
|
+
}
|
|
9143
|
+
if (typeTag === REACT_FORWARD_REF_TYPE) {
|
|
9144
|
+
const rendered = renderWithoutHooks(
|
|
9145
|
+
"a forwardRef component",
|
|
9146
|
+
() => type.render(
|
|
9147
|
+
props,
|
|
9148
|
+
props.ref ?? null
|
|
9149
|
+
)
|
|
9150
|
+
);
|
|
9151
|
+
return mountCompiledRootNode(rendered, parent, namespace, mount, updater);
|
|
9152
|
+
}
|
|
9153
|
+
throw new CompiledRootUnsupported("a component React DOM must render");
|
|
9154
|
+
}
|
|
9155
|
+
function createCompiledRoot(container, options, loadReactDOM) {
|
|
9156
|
+
let mode = "idle";
|
|
9157
|
+
let element = null;
|
|
9158
|
+
let instances = [];
|
|
9159
|
+
let reactRoot;
|
|
9160
|
+
let unmounted = false;
|
|
9161
|
+
const stopCompiled = () => {
|
|
9162
|
+
for (const instance of instances.slice().reverse()) {
|
|
9163
|
+
instance.componentWillUnmount?.();
|
|
9164
|
+
}
|
|
9165
|
+
instances = [];
|
|
9166
|
+
};
|
|
9167
|
+
const handOff = (reason) => {
|
|
9168
|
+
if (mode === "pending" || mode === "react") return;
|
|
9169
|
+
if (reason) options.onFallback?.(reason);
|
|
9170
|
+
stopCompiled();
|
|
9171
|
+
mode = "pending";
|
|
9172
|
+
void loadReactDOM().then((client) => {
|
|
9173
|
+
if (unmounted) return;
|
|
9174
|
+
reactRoot = client.createRoot(container, options.reactRootOptions);
|
|
9175
|
+
mode = "react";
|
|
9176
|
+
reactRoot.render(element);
|
|
9177
|
+
});
|
|
9178
|
+
};
|
|
9179
|
+
const updater = {
|
|
9180
|
+
isMounted: () => mode === "compiled",
|
|
9181
|
+
enqueueSetState: () => handOff("a compiled component needs a React update"),
|
|
9182
|
+
enqueueReplaceState: () => handOff("a compiled component needs a React update"),
|
|
9183
|
+
enqueueForceUpdate: () => handOff("a compiled component needs a React update")
|
|
9184
|
+
};
|
|
9185
|
+
return {
|
|
9186
|
+
render(next) {
|
|
9187
|
+
element = next;
|
|
9188
|
+
if (unmounted) return;
|
|
9189
|
+
if (mode === "react") return reactRoot.render(next);
|
|
9190
|
+
if (mode === "pending") return;
|
|
9191
|
+
if (mode === "compiled") return handOff("render() was called again");
|
|
9192
|
+
if (typeof globalThis.$RefreshReg$ === "function") {
|
|
9193
|
+
return handOff();
|
|
9194
|
+
}
|
|
9195
|
+
const mount = {
|
|
9196
|
+
fragment: document.createDocumentFragment(),
|
|
9197
|
+
effects: [],
|
|
9198
|
+
instances: []
|
|
9199
|
+
};
|
|
9200
|
+
try {
|
|
9201
|
+
mountCompiledRootNode(next, mount.fragment, null, mount, updater);
|
|
9202
|
+
} catch (error) {
|
|
9203
|
+
if (!(error instanceof CompiledRootUnsupported)) throw error;
|
|
9204
|
+
return handOff(`it contains ${error.message}`);
|
|
9205
|
+
}
|
|
9206
|
+
container.replaceChildren(mount.fragment);
|
|
9207
|
+
instances = mount.instances;
|
|
9208
|
+
mode = "compiled";
|
|
9209
|
+
for (const effect of mount.effects) effect();
|
|
9210
|
+
},
|
|
9211
|
+
unmount() {
|
|
9212
|
+
unmounted = true;
|
|
9213
|
+
if (mode === "react") reactRoot.unmount();
|
|
9214
|
+
else {
|
|
9215
|
+
stopCompiled();
|
|
9216
|
+
container.replaceChildren();
|
|
9217
|
+
}
|
|
9218
|
+
}
|
|
9219
|
+
};
|
|
9220
|
+
}
|
|
8800
9221
|
|
|
8801
9222
|
exports.applyCompilerKeyedCollectionMutation = applyCompilerKeyedCollectionMutation;
|
|
8802
9223
|
exports.componentRuntimeFeature = componentRuntimeFeature;
|
|
@@ -8805,6 +9226,7 @@ exports.conditionalRuntimeFeature = conditionalRuntimeFeature;
|
|
|
8805
9226
|
exports.createCompiledComponent = createCompiledComponent;
|
|
8806
9227
|
exports.createCompiledComponentWithFeatures = createCompiledComponentWithFeatures;
|
|
8807
9228
|
exports.createCompiledComponentWithoutRefresh = createCompiledComponentWithoutRefresh;
|
|
9229
|
+
exports.createCompiledRoot = createCompiledRoot;
|
|
8808
9230
|
exports.createCompilerKeyedArrayAppend = createCompilerKeyedArrayAppend;
|
|
8809
9231
|
exports.createCompilerKeyedArrayBatchInsert = createCompilerKeyedArrayBatchInsert;
|
|
8810
9232
|
exports.createCompilerKeyedArrayFilter = createCompilerKeyedArrayFilter;
|