@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
|
@@ -1725,7 +1725,7 @@ function updateAttribute(element, name, value) {
|
|
|
1725
1725
|
if (name === "value" && (isInputElement(element) || isTextAreaElement(element))) {
|
|
1726
1726
|
const nextValue = value === null || value === void 0 ? "" : String(value);
|
|
1727
1727
|
if (element.value !== nextValue) element.value = nextValue;
|
|
1728
|
-
if (value != null && isInputElement(element) && (element.type !== "number" || element.ownerDocument.activeElement !== element) && element.defaultValue !== nextValue) {
|
|
1728
|
+
if (value != null && (isTextAreaElement(element) || isInputElement(element) && (element.type !== "number" || element.ownerDocument.activeElement !== element)) && element.defaultValue !== nextValue) {
|
|
1729
1729
|
element.defaultValue = nextValue;
|
|
1730
1730
|
}
|
|
1731
1731
|
return;
|
|
@@ -1861,10 +1861,18 @@ function createKeyedListBlockComponent(owner) {
|
|
|
1861
1861
|
function isCompilerHostElement(value) {
|
|
1862
1862
|
return typeof value === "object" && value !== null && value.kind === "element";
|
|
1863
1863
|
}
|
|
1864
|
-
function
|
|
1865
|
-
|
|
1864
|
+
function initializeFieldDefault(element, name, value) {
|
|
1865
|
+
if (name === "value" && value != null && (isInputElement(element) || isTextAreaElement(element))) {
|
|
1866
|
+
element.defaultValue = String(value);
|
|
1867
|
+
} else if (name === "checked" && isInputElement(element)) {
|
|
1868
|
+
element.defaultChecked = Boolean(value);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
function createCompilerHostElement(document2, descriptor) {
|
|
1872
|
+
const element = document2.createElement(descriptor.tag);
|
|
1866
1873
|
for (const attribute of descriptor.attributes) {
|
|
1867
1874
|
updateAttribute(element, attribute.name, attribute.value);
|
|
1875
|
+
initializeFieldDefault(element, attribute.name, attribute.value);
|
|
1868
1876
|
}
|
|
1869
1877
|
for (const style of descriptor.styles) updateStyle(element, style.name, style.value);
|
|
1870
1878
|
const appendChild = (child) => {
|
|
@@ -1873,11 +1881,11 @@ function createCompilerHostElement(document, descriptor) {
|
|
|
1873
1881
|
return;
|
|
1874
1882
|
}
|
|
1875
1883
|
if (isCompilerHostElement(child)) {
|
|
1876
|
-
element.append(createCompilerHostElement(
|
|
1884
|
+
element.append(createCompilerHostElement(document2, child));
|
|
1877
1885
|
return;
|
|
1878
1886
|
}
|
|
1879
1887
|
const text = renderTextValue(child);
|
|
1880
|
-
if (text) element.append(
|
|
1888
|
+
if (text) element.append(document2.createTextNode(text));
|
|
1881
1889
|
};
|
|
1882
1890
|
for (const child of materializeCompilerHostChildren(descriptor)) appendChild(child);
|
|
1883
1891
|
for (const attribute of descriptor.attributes) {
|
|
@@ -2542,9 +2550,9 @@ function readKeyedRowBindingValues(props, item, index) {
|
|
|
2542
2550
|
return values;
|
|
2543
2551
|
}
|
|
2544
2552
|
var KEYED_ROW_TEMPLATES = /* @__PURE__ */ new WeakMap();
|
|
2545
|
-
function createKeyedRowInstance(props,
|
|
2553
|
+
function createKeyedRowInstance(props, document2, key, item, index) {
|
|
2546
2554
|
const template = props.cloneRows && KEYED_ROW_TEMPLATES.get(props);
|
|
2547
|
-
const element = template ? template.element.cloneNode(true) : createCompilerHostElement(
|
|
2555
|
+
const element = template ? template.element.cloneNode(true) : createCompilerHostElement(document2, props.create(item, index));
|
|
2548
2556
|
const instance = {
|
|
2549
2557
|
key,
|
|
2550
2558
|
element,
|
|
@@ -6138,7 +6146,13 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
6138
6146
|
class FarmKeyedRowsBlock extends React.Component {
|
|
6139
6147
|
constructor() {
|
|
6140
6148
|
super(...arguments);
|
|
6141
|
-
|
|
6149
|
+
// Host-block rows have no React-owned mode, so rows whose events the container cannot run
|
|
6150
|
+
// here (onChange under React DOM) are rendered by React from the start.
|
|
6151
|
+
this.state = {
|
|
6152
|
+
fallback: Boolean(
|
|
6153
|
+
this.props.hostBlocks && this.props.events?.length && !(this.props.delegateEvents && this.props.events.every((event) => event.path !== void 0))
|
|
6154
|
+
)
|
|
6155
|
+
};
|
|
6142
6156
|
this.root = null;
|
|
6143
6157
|
this.mounted = false;
|
|
6144
6158
|
this.fallbackRequested = false;
|
|
@@ -7052,7 +7066,7 @@ function createKeyedRowsBlockComponentCore(owner, options = {}) {
|
|
|
7052
7066
|
componentDidMount() {
|
|
7053
7067
|
this.mounted = true;
|
|
7054
7068
|
this.listen();
|
|
7055
|
-
if (!this.adopt()) this.activateFallback();
|
|
7069
|
+
if (!this.state.fallback && !this.adopt()) this.activateFallback();
|
|
7056
7070
|
}
|
|
7057
7071
|
componentWillUnmount() {
|
|
7058
7072
|
this.mounted = false;
|
|
@@ -7095,11 +7109,39 @@ function createKeyedRowsBlockComponent(owner, options = {}) {
|
|
|
7095
7109
|
keyedTargets: createKeyedTargetRuntime
|
|
7096
7110
|
});
|
|
7097
7111
|
}
|
|
7112
|
+
function dispatchKeyedRowEvent(descriptors, instance, name, event) {
|
|
7113
|
+
const target = event.target;
|
|
7114
|
+
const capture = name.endsWith("Capture");
|
|
7115
|
+
const matches = [];
|
|
7116
|
+
for (const descriptor of descriptors) {
|
|
7117
|
+
if (descriptor.name !== name || descriptor.path === void 0) continue;
|
|
7118
|
+
const host = findCompilerHostTarget(instance.element, descriptor.path);
|
|
7119
|
+
if (host && (host === target || host.contains(target))) matches.push({ descriptor, host });
|
|
7120
|
+
}
|
|
7121
|
+
matches.sort(
|
|
7122
|
+
(left, right) => capture ? left.descriptor.path.length - right.descriptor.path.length : right.descriptor.path.length - left.descriptor.path.length
|
|
7123
|
+
);
|
|
7124
|
+
for (const { descriptor, host } of matches) {
|
|
7125
|
+
const own = Object.getOwnPropertyDescriptor(event, "currentTarget");
|
|
7126
|
+
try {
|
|
7127
|
+
Object.defineProperty(event, "currentTarget", { configurable: true, value: host });
|
|
7128
|
+
descriptor.invoke(instance.item, instance.index, event);
|
|
7129
|
+
} finally {
|
|
7130
|
+
if (own) Object.defineProperty(event, "currentTarget", own);
|
|
7131
|
+
else Reflect.deleteProperty(event, "currentTarget");
|
|
7132
|
+
}
|
|
7133
|
+
if (event.isPropagationStopped()) break;
|
|
7134
|
+
}
|
|
7135
|
+
}
|
|
7098
7136
|
function createKeyedRangesBlockComponent(owner) {
|
|
7099
7137
|
class FarmKeyedRangesBlock extends React.Component {
|
|
7100
7138
|
constructor() {
|
|
7101
7139
|
super(...arguments);
|
|
7102
|
-
|
|
7140
|
+
// Rows whose events the container runs only without React DOM (onChange) are rendered by
|
|
7141
|
+
// React here, from the start, with their own handlers.
|
|
7142
|
+
this.state = {
|
|
7143
|
+
fallback: Boolean(this.props.delegateEventsWithoutReact && !this.props.delegateEvents)
|
|
7144
|
+
};
|
|
7103
7145
|
this.root = null;
|
|
7104
7146
|
this.mounted = false;
|
|
7105
7147
|
this.fallbackRequested = false;
|
|
@@ -7118,6 +7160,9 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
7118
7160
|
this.refresh = (afterCommit) => {
|
|
7119
7161
|
this.reconcile(afterCommit);
|
|
7120
7162
|
};
|
|
7163
|
+
// React renders rows with their handlers only while it owns them (fallback). Otherwise the
|
|
7164
|
+
// container dispatches each event to the row the runtime knows, with its current item.
|
|
7165
|
+
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;
|
|
7121
7166
|
}
|
|
7122
7167
|
readRange(range) {
|
|
7123
7168
|
const items = materializeIterable(range.items());
|
|
@@ -7316,7 +7361,7 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
7316
7361
|
componentDidMount() {
|
|
7317
7362
|
this.mounted = true;
|
|
7318
7363
|
this.listen();
|
|
7319
|
-
if (!this.adopt()) this.activateFallback();
|
|
7364
|
+
if (!this.state.fallback && !this.adopt()) this.activateFallback();
|
|
7320
7365
|
}
|
|
7321
7366
|
componentDidUpdate() {
|
|
7322
7367
|
this.listen();
|
|
@@ -7334,14 +7379,44 @@ function createKeyedRangesBlockComponent(owner) {
|
|
|
7334
7379
|
this.staticSegments = [];
|
|
7335
7380
|
this.staticValues.length = 0;
|
|
7336
7381
|
}
|
|
7382
|
+
dispatchRowEvent(name, event) {
|
|
7383
|
+
const target = event.target;
|
|
7384
|
+
if (!this.root || !target) return;
|
|
7385
|
+
let element = target.nodeType === 1 ? target : target.parentElement;
|
|
7386
|
+
while (element && element.parentElement !== this.root) element = element.parentElement;
|
|
7387
|
+
if (!element) return;
|
|
7388
|
+
for (let rangeIndex = 0; rangeIndex < this.rangeInstances.length; rangeIndex += 1) {
|
|
7389
|
+
for (const instance of this.rangeInstances[rangeIndex].values()) {
|
|
7390
|
+
if (instance.element !== element) continue;
|
|
7391
|
+
dispatchKeyedRowEvent(
|
|
7392
|
+
this.currentProps.ranges[rangeIndex].events || [],
|
|
7393
|
+
instance,
|
|
7394
|
+
name,
|
|
7395
|
+
event
|
|
7396
|
+
);
|
|
7397
|
+
return;
|
|
7398
|
+
}
|
|
7399
|
+
}
|
|
7400
|
+
}
|
|
7337
7401
|
render() {
|
|
7338
|
-
const container = this.currentProps.render();
|
|
7402
|
+
const container = this.currentProps.render(this.rowEvent);
|
|
7339
7403
|
if (!React.isValidElement(container) || typeof container.type !== "string") {
|
|
7340
7404
|
throw new TypeError(
|
|
7341
7405
|
`Compiled keyed ranges ${this.currentProps.id} must own one host container.`
|
|
7342
7406
|
);
|
|
7343
7407
|
}
|
|
7408
|
+
const delegated = {};
|
|
7409
|
+
if (this.currentProps.delegateEvents && !this.state.fallback) {
|
|
7410
|
+
for (const range of this.currentProps.ranges) {
|
|
7411
|
+
for (const { name } of range.events || []) {
|
|
7412
|
+
delegated[name] = (event) => {
|
|
7413
|
+
if (!event.isPropagationStopped()) this.dispatchRowEvent(name, event);
|
|
7414
|
+
};
|
|
7415
|
+
}
|
|
7416
|
+
}
|
|
7417
|
+
}
|
|
7344
7418
|
return React.cloneElement(container, {
|
|
7419
|
+
...delegated,
|
|
7345
7420
|
key: this.state.fallback ? `react-${this.fallbackVersion}` : "compiled",
|
|
7346
7421
|
ref: this.captureRoot
|
|
7347
7422
|
});
|
|
@@ -8791,7 +8866,353 @@ var COMPLETE_RUNTIME_FEATURES = [
|
|
|
8791
8866
|
function createCompiledComponent(definition) {
|
|
8792
8867
|
return createCompiledComponentWithFeatures(definition, COMPLETE_RUNTIME_FEATURES);
|
|
8793
8868
|
}
|
|
8869
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
8870
|
+
var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
|
|
8871
|
+
var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
|
|
8872
|
+
var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
|
|
8873
|
+
var COMPILED_ROOT_EVENTS = {
|
|
8874
|
+
onClick: "click",
|
|
8875
|
+
onDoubleClick: "dblclick",
|
|
8876
|
+
onContextMenu: "contextmenu",
|
|
8877
|
+
onMouseDown: "mousedown",
|
|
8878
|
+
onMouseUp: "mouseup",
|
|
8879
|
+
onMouseMove: "mousemove",
|
|
8880
|
+
onMouseOver: "mouseover",
|
|
8881
|
+
onMouseOut: "mouseout",
|
|
8882
|
+
onMouseEnter: "mouseenter",
|
|
8883
|
+
onMouseLeave: "mouseleave",
|
|
8884
|
+
onPointerDown: "pointerdown",
|
|
8885
|
+
onPointerUp: "pointerup",
|
|
8886
|
+
onPointerMove: "pointermove",
|
|
8887
|
+
onPointerOver: "pointerover",
|
|
8888
|
+
onPointerOut: "pointerout",
|
|
8889
|
+
onPointerEnter: "pointerenter",
|
|
8890
|
+
onPointerLeave: "pointerleave",
|
|
8891
|
+
onPointerCancel: "pointercancel",
|
|
8892
|
+
onKeyDown: "keydown",
|
|
8893
|
+
onKeyUp: "keyup",
|
|
8894
|
+
onInput: "input",
|
|
8895
|
+
onSubmit: "submit",
|
|
8896
|
+
onReset: "reset",
|
|
8897
|
+
// React's onFocus and onBlur bubble, like focusin and focusout.
|
|
8898
|
+
onFocus: "focusin",
|
|
8899
|
+
onBlur: "focusout"
|
|
8900
|
+
};
|
|
8901
|
+
var COMPILED_ROOT_CAMEL_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
8902
|
+
"className",
|
|
8903
|
+
"htmlFor",
|
|
8904
|
+
"tabIndex",
|
|
8905
|
+
"readOnly",
|
|
8906
|
+
"maxLength",
|
|
8907
|
+
"minLength",
|
|
8908
|
+
"colSpan",
|
|
8909
|
+
"rowSpan",
|
|
8910
|
+
"autoComplete",
|
|
8911
|
+
"inputMode",
|
|
8912
|
+
"enterKeyHint"
|
|
8913
|
+
]);
|
|
8914
|
+
var CompiledRootUnsupported = class extends Error {
|
|
8915
|
+
};
|
|
8916
|
+
function renderWithoutHooks(name, render) {
|
|
8917
|
+
const internals = React;
|
|
8918
|
+
const react19 = internals.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
8919
|
+
const react18 = internals.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentDispatcher;
|
|
8920
|
+
const rejectHooks = new Proxy(
|
|
8921
|
+
{},
|
|
8922
|
+
{
|
|
8923
|
+
get() {
|
|
8924
|
+
throw new CompiledRootUnsupported(`${name}, which calls hooks`);
|
|
8925
|
+
}
|
|
8926
|
+
}
|
|
8927
|
+
);
|
|
8928
|
+
const previous = react19 ? react19.H : react18?.current;
|
|
8929
|
+
if (react19) react19.H = rejectHooks;
|
|
8930
|
+
else if (react18) react18.current = rejectHooks;
|
|
8931
|
+
try {
|
|
8932
|
+
return render();
|
|
8933
|
+
} catch (error) {
|
|
8934
|
+
if (error instanceof CompiledRootUnsupported) throw error;
|
|
8935
|
+
throw new CompiledRootUnsupported(`${name}: ${error}`);
|
|
8936
|
+
} finally {
|
|
8937
|
+
if (react19) react19.H = previous;
|
|
8938
|
+
else if (react18) react18.current = previous;
|
|
8939
|
+
}
|
|
8940
|
+
}
|
|
8941
|
+
function isFarmCompilerClass(type) {
|
|
8942
|
+
if (typeof type !== "function" || !type.prototype?.isReactComponent) return false;
|
|
8943
|
+
const displayName = type.displayName;
|
|
8944
|
+
return typeof displayName === "string" && displayName.startsWith("FarmCompiled");
|
|
8945
|
+
}
|
|
8946
|
+
function compiledRootUpdatesWithoutReact(displayName, props) {
|
|
8947
|
+
if (displayName.startsWith("FarmCompiled(")) return true;
|
|
8948
|
+
if (displayName === "FarmCompiledKeyedRanges") return true;
|
|
8949
|
+
if (displayName !== "FarmCompiledKeyedRows") return false;
|
|
8950
|
+
const rows = props;
|
|
8951
|
+
const delegated = Boolean(
|
|
8952
|
+
(rows.delegateEvents || rows.delegateEventsWithoutReact) && rows.events?.length && rows.events.every((event) => event.path !== void 0)
|
|
8953
|
+
);
|
|
8954
|
+
return !rows.conditionals?.length && (!rows.events?.length || delegated);
|
|
8955
|
+
}
|
|
8956
|
+
function toCompiledRootEvent(nativeEvent, currentTarget, type) {
|
|
8957
|
+
let propagationStopped = false;
|
|
8958
|
+
const own = {
|
|
8959
|
+
nativeEvent,
|
|
8960
|
+
currentTarget,
|
|
8961
|
+
type,
|
|
8962
|
+
stopPropagation() {
|
|
8963
|
+
propagationStopped = true;
|
|
8964
|
+
nativeEvent.stopPropagation();
|
|
8965
|
+
},
|
|
8966
|
+
isPropagationStopped: () => propagationStopped,
|
|
8967
|
+
isDefaultPrevented: () => nativeEvent.defaultPrevented,
|
|
8968
|
+
persist() {
|
|
8969
|
+
}
|
|
8970
|
+
};
|
|
8971
|
+
return new Proxy(own, {
|
|
8972
|
+
get(target, key) {
|
|
8973
|
+
if (key in target) return target[key];
|
|
8974
|
+
const value = nativeEvent[key];
|
|
8975
|
+
return typeof value === "function" ? value.bind(nativeEvent) : value;
|
|
8976
|
+
}
|
|
8977
|
+
});
|
|
8978
|
+
}
|
|
8979
|
+
function compiledRootChangeEvent(element) {
|
|
8980
|
+
if (element instanceof HTMLSelectElement) return "change";
|
|
8981
|
+
if (element instanceof HTMLInputElement) {
|
|
8982
|
+
return element.type === "checkbox" || element.type === "radio" || element.type === "file" ? "change" : "input";
|
|
8983
|
+
}
|
|
8984
|
+
return element instanceof HTMLTextAreaElement ? "input" : "";
|
|
8985
|
+
}
|
|
8986
|
+
function setCompiledRootEvent(element, name, handler) {
|
|
8987
|
+
if (handler === null || handler === void 0) return;
|
|
8988
|
+
if (typeof handler !== "function") throw new CompiledRootUnsupported(`${name} value`);
|
|
8989
|
+
const capture = name.endsWith("Capture");
|
|
8990
|
+
const reactName = capture ? name.slice(0, -"Capture".length) : name;
|
|
8991
|
+
if (reactName === "onChange" && !compiledRootChangeEvent(element)) {
|
|
8992
|
+
for (const type of ["input", "change"]) {
|
|
8993
|
+
element.addEventListener(
|
|
8994
|
+
type,
|
|
8995
|
+
(event) => {
|
|
8996
|
+
const target = event.target;
|
|
8997
|
+
if (target instanceof Element && compiledRootChangeEvent(target) === type) {
|
|
8998
|
+
handler(toCompiledRootEvent(event, element, "change"));
|
|
8999
|
+
}
|
|
9000
|
+
},
|
|
9001
|
+
capture
|
|
9002
|
+
);
|
|
9003
|
+
}
|
|
9004
|
+
return;
|
|
9005
|
+
}
|
|
9006
|
+
const nativeType = reactName === "onChange" ? compiledRootChangeEvent(element) : COMPILED_ROOT_EVENTS[reactName];
|
|
9007
|
+
if (!nativeType) throw new CompiledRootUnsupported(`the ${name} event`);
|
|
9008
|
+
const reactType = reactName === "onFocus" ? "focus" : reactName === "onBlur" ? "blur" : reactName === "onChange" ? "change" : nativeType;
|
|
9009
|
+
element.addEventListener(
|
|
9010
|
+
nativeType,
|
|
9011
|
+
(event) => handler(toCompiledRootEvent(event, element, reactType)),
|
|
9012
|
+
capture
|
|
9013
|
+
);
|
|
9014
|
+
}
|
|
9015
|
+
function setCompiledRootProp(element, name, value) {
|
|
9016
|
+
if (name === "children" || name === "key" || name === "ref") return;
|
|
9017
|
+
if (name === "suppressHydrationWarning" || name === "suppressContentEditableWarning") return;
|
|
9018
|
+
if (/^on[A-Z]/.test(name)) return setCompiledRootEvent(element, name, value);
|
|
9019
|
+
if (name === "style") {
|
|
9020
|
+
if (value === null || value === void 0) return;
|
|
9021
|
+
if (typeof value !== "object") throw new CompiledRootUnsupported("a non-object style");
|
|
9022
|
+
for (const [property, styleValue] of Object.entries(value)) {
|
|
9023
|
+
updateStyle(element, property, styleValue);
|
|
9024
|
+
}
|
|
9025
|
+
return;
|
|
9026
|
+
}
|
|
9027
|
+
if (name === "dangerouslySetInnerHTML") {
|
|
9028
|
+
const html = value?.__html;
|
|
9029
|
+
if (html !== null && html !== void 0) element.innerHTML = String(html);
|
|
9030
|
+
return;
|
|
9031
|
+
}
|
|
9032
|
+
if (value !== null && value !== void 0 && typeof value === "object") {
|
|
9033
|
+
throw new CompiledRootUnsupported(`an object ${name} value`);
|
|
9034
|
+
}
|
|
9035
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
9036
|
+
throw new CompiledRootUnsupported(`a ${typeof value} ${name} value`);
|
|
9037
|
+
}
|
|
9038
|
+
const svg = element.namespaceURI === SVG_NAMESPACE;
|
|
9039
|
+
if (/[A-Z]/.test(name) && (svg || !COMPILED_ROOT_CAMEL_ATTRIBUTES.has(name))) {
|
|
9040
|
+
if (!(svg && (name === "className" || name === "viewBox"))) {
|
|
9041
|
+
throw new CompiledRootUnsupported(`the ${name} prop`);
|
|
9042
|
+
}
|
|
9043
|
+
}
|
|
9044
|
+
updateAttribute(element, name, value);
|
|
9045
|
+
initializeFieldDefault(element, name, value);
|
|
9046
|
+
}
|
|
9047
|
+
function mountCompiledRootNode(node, parent, namespace, mount, updater) {
|
|
9048
|
+
if (node === null || node === void 0 || typeof node === "boolean") return;
|
|
9049
|
+
if (typeof node === "string" || typeof node === "number" || typeof node === "bigint") {
|
|
9050
|
+
parent.appendChild(document.createTextNode(String(node)));
|
|
9051
|
+
return;
|
|
9052
|
+
}
|
|
9053
|
+
if (Array.isArray(node) || typeof node === "object" && Symbol.iterator in node) {
|
|
9054
|
+
for (const child of node) {
|
|
9055
|
+
mountCompiledRootNode(child, parent, namespace, mount, updater);
|
|
9056
|
+
}
|
|
9057
|
+
return;
|
|
9058
|
+
}
|
|
9059
|
+
if (!React.isValidElement(node)) {
|
|
9060
|
+
throw new CompiledRootUnsupported(
|
|
9061
|
+
node?.$$typeof === REACT_PORTAL_TYPE ? "a portal" : "a child"
|
|
9062
|
+
);
|
|
9063
|
+
}
|
|
9064
|
+
const { type } = node;
|
|
9065
|
+
const props = node.props;
|
|
9066
|
+
if (type === React.Fragment || type === React.StrictMode) {
|
|
9067
|
+
return mountCompiledRootNode(props.children, parent, namespace, mount, updater);
|
|
9068
|
+
}
|
|
9069
|
+
if (typeof type === "string") {
|
|
9070
|
+
const elementNamespace = type === "svg" ? SVG_NAMESPACE : namespace;
|
|
9071
|
+
const element = elementNamespace ? document.createElementNS(elementNamespace, type) : document.createElement(type);
|
|
9072
|
+
if (props.type !== void 0) setCompiledRootProp(element, "type", props.type);
|
|
9073
|
+
for (const name in props) {
|
|
9074
|
+
if (name === "type" || name === "value" && type === "select") continue;
|
|
9075
|
+
setCompiledRootProp(element, name, props[name]);
|
|
9076
|
+
}
|
|
9077
|
+
if (props.dangerouslySetInnerHTML === void 0) {
|
|
9078
|
+
mountCompiledRootNode(
|
|
9079
|
+
props.children,
|
|
9080
|
+
element,
|
|
9081
|
+
type === "foreignObject" ? null : elementNamespace,
|
|
9082
|
+
mount,
|
|
9083
|
+
updater
|
|
9084
|
+
);
|
|
9085
|
+
}
|
|
9086
|
+
if (type === "select" && props.value !== void 0) {
|
|
9087
|
+
setCompiledRootProp(element, "value", props.value);
|
|
9088
|
+
}
|
|
9089
|
+
parent.appendChild(element);
|
|
9090
|
+
const ref = props.ref ?? node.ref;
|
|
9091
|
+
if (typeof ref === "function") mount.effects.push(() => ref(element));
|
|
9092
|
+
else if (ref && typeof ref === "object") {
|
|
9093
|
+
mount.effects.push(() => {
|
|
9094
|
+
ref.current = element;
|
|
9095
|
+
});
|
|
9096
|
+
}
|
|
9097
|
+
return;
|
|
9098
|
+
}
|
|
9099
|
+
if (isFarmCompilerClass(type)) {
|
|
9100
|
+
const displayName = type.displayName;
|
|
9101
|
+
if (!compiledRootUpdatesWithoutReact(displayName, props)) {
|
|
9102
|
+
throw new CompiledRootUnsupported(`${displayName}, which updates through React`);
|
|
9103
|
+
}
|
|
9104
|
+
const Component = type;
|
|
9105
|
+
const instanceProps = props.delegateEventsWithoutReact ? { ...props, delegateEvents: true } : props;
|
|
9106
|
+
const instance = new Component(instanceProps);
|
|
9107
|
+
instance.props = instanceProps;
|
|
9108
|
+
instance.updater = updater;
|
|
9109
|
+
const derived = type.getDerivedStateFromProps;
|
|
9110
|
+
if (derived) {
|
|
9111
|
+
const next = derived(props, instance.state);
|
|
9112
|
+
if (next) instance.state = { ...instance.state, ...next };
|
|
9113
|
+
}
|
|
9114
|
+
mountCompiledRootNode(instance.render(), parent, namespace, mount, updater);
|
|
9115
|
+
mount.instances.push(instance);
|
|
9116
|
+
if (instance.componentDidMount) mount.effects.push(() => instance.componentDidMount());
|
|
9117
|
+
return;
|
|
9118
|
+
}
|
|
9119
|
+
if (typeof type === "function" && !type.prototype?.isReactComponent) {
|
|
9120
|
+
const rendered = renderWithoutHooks(
|
|
9121
|
+
type.name || "a function component",
|
|
9122
|
+
() => type(props)
|
|
9123
|
+
);
|
|
9124
|
+
return mountCompiledRootNode(rendered, parent, namespace, mount, updater);
|
|
9125
|
+
}
|
|
9126
|
+
const typeTag = type?.$$typeof;
|
|
9127
|
+
if (typeTag === REACT_MEMO_TYPE) {
|
|
9128
|
+
const inner = type.type;
|
|
9129
|
+
return mountCompiledRootNode(
|
|
9130
|
+
React.createElement(inner, props),
|
|
9131
|
+
parent,
|
|
9132
|
+
namespace,
|
|
9133
|
+
mount,
|
|
9134
|
+
updater
|
|
9135
|
+
);
|
|
9136
|
+
}
|
|
9137
|
+
if (typeTag === REACT_FORWARD_REF_TYPE) {
|
|
9138
|
+
const rendered = renderWithoutHooks(
|
|
9139
|
+
"a forwardRef component",
|
|
9140
|
+
() => type.render(
|
|
9141
|
+
props,
|
|
9142
|
+
props.ref ?? null
|
|
9143
|
+
)
|
|
9144
|
+
);
|
|
9145
|
+
return mountCompiledRootNode(rendered, parent, namespace, mount, updater);
|
|
9146
|
+
}
|
|
9147
|
+
throw new CompiledRootUnsupported("a component React DOM must render");
|
|
9148
|
+
}
|
|
9149
|
+
function createCompiledRoot(container, options, loadReactDOM) {
|
|
9150
|
+
let mode = "idle";
|
|
9151
|
+
let element = null;
|
|
9152
|
+
let instances = [];
|
|
9153
|
+
let reactRoot;
|
|
9154
|
+
let unmounted = false;
|
|
9155
|
+
const stopCompiled = () => {
|
|
9156
|
+
for (const instance of instances.slice().reverse()) {
|
|
9157
|
+
instance.componentWillUnmount?.();
|
|
9158
|
+
}
|
|
9159
|
+
instances = [];
|
|
9160
|
+
};
|
|
9161
|
+
const handOff = (reason) => {
|
|
9162
|
+
if (mode === "pending" || mode === "react") return;
|
|
9163
|
+
if (reason) options.onFallback?.(reason);
|
|
9164
|
+
stopCompiled();
|
|
9165
|
+
mode = "pending";
|
|
9166
|
+
void loadReactDOM().then((client) => {
|
|
9167
|
+
if (unmounted) return;
|
|
9168
|
+
reactRoot = client.createRoot(container, options.reactRootOptions);
|
|
9169
|
+
mode = "react";
|
|
9170
|
+
reactRoot.render(element);
|
|
9171
|
+
});
|
|
9172
|
+
};
|
|
9173
|
+
const updater = {
|
|
9174
|
+
isMounted: () => mode === "compiled",
|
|
9175
|
+
enqueueSetState: () => handOff("a compiled component needs a React update"),
|
|
9176
|
+
enqueueReplaceState: () => handOff("a compiled component needs a React update"),
|
|
9177
|
+
enqueueForceUpdate: () => handOff("a compiled component needs a React update")
|
|
9178
|
+
};
|
|
9179
|
+
return {
|
|
9180
|
+
render(next) {
|
|
9181
|
+
element = next;
|
|
9182
|
+
if (unmounted) return;
|
|
9183
|
+
if (mode === "react") return reactRoot.render(next);
|
|
9184
|
+
if (mode === "pending") return;
|
|
9185
|
+
if (mode === "compiled") return handOff("render() was called again");
|
|
9186
|
+
if (typeof globalThis.$RefreshReg$ === "function") {
|
|
9187
|
+
return handOff();
|
|
9188
|
+
}
|
|
9189
|
+
const mount = {
|
|
9190
|
+
fragment: document.createDocumentFragment(),
|
|
9191
|
+
effects: [],
|
|
9192
|
+
instances: []
|
|
9193
|
+
};
|
|
9194
|
+
try {
|
|
9195
|
+
mountCompiledRootNode(next, mount.fragment, null, mount, updater);
|
|
9196
|
+
} catch (error) {
|
|
9197
|
+
if (!(error instanceof CompiledRootUnsupported)) throw error;
|
|
9198
|
+
return handOff(`it contains ${error.message}`);
|
|
9199
|
+
}
|
|
9200
|
+
container.replaceChildren(mount.fragment);
|
|
9201
|
+
instances = mount.instances;
|
|
9202
|
+
mode = "compiled";
|
|
9203
|
+
for (const effect of mount.effects) effect();
|
|
9204
|
+
},
|
|
9205
|
+
unmount() {
|
|
9206
|
+
unmounted = true;
|
|
9207
|
+
if (mode === "react") reactRoot.unmount();
|
|
9208
|
+
else {
|
|
9209
|
+
stopCompiled();
|
|
9210
|
+
container.replaceChildren();
|
|
9211
|
+
}
|
|
9212
|
+
}
|
|
9213
|
+
};
|
|
9214
|
+
}
|
|
8794
9215
|
|
|
8795
|
-
export { applyCompilerKeyedCollectionMutation, componentRuntimeFeature, conditionalRangesRuntimeFeature, conditionalRuntimeFeature, createCompiledComponent, createCompiledComponentWithFeatures, createCompiledComponentWithoutRefresh, createCompilerKeyedArrayAppend, createCompilerKeyedArrayBatchInsert, createCompilerKeyedArrayFilter, createCompilerKeyedArrayMapPipeline, createCompilerKeyedArrayMapReorder, createCompilerKeyedArrayMappedRollingWindow, createCompilerKeyedArrayMappedStructuralAppend, createCompilerKeyedArrayMappedStructuralPrepend, createCompilerKeyedArrayPositionUpdate, createCompilerKeyedArrayPrepend, createCompilerKeyedArrayQueuedMapPipeline, createCompilerKeyedArrayReorder, createCompilerKeyedArrayRollingWindow, createCompilerKeyedArrayRollingWindowMapPipeline, createCompilerKeyedArraySlice, createCompilerKeyedArraySort, createCompilerKeyedArrayStructuralAppend, createCompilerKeyedArrayStructuralAppendMapPipeline, createCompilerKeyedArrayStructuralPrepend, createCompilerKeyedArrayStructuralPrependMapPipeline, createCompilerKeyedArrayStructuralReorder, createCompilerKeyedArrayStructuralSort, createCompilerKeyedArrayWindowReplace, createCompilerKeyedCollectionUpdate, createCompilerKeyedMapUpdate, finalizeCompilerKeyedArrayMappedStructuralUpdate, hostConditionalRuntimeFeature, keyedListRuntimeFeature, keyedRangesRuntimeFeature, keyedRowsAllHintedRuntimeFeature, keyedRowsAppendOnlyRuntimeFeature, keyedRowsBatchEveryHintedRuntimeFeature, keyedRowsBatchPositionHintedRuntimeFeature, keyedRowsCompleteAllHintedRuntimeFeature, keyedRowsCompleteBatchEveryHintedRuntimeFeature, keyedRowsCompleteBatchPositionHintedRuntimeFeature, keyedRowsCompleteEveryHintedRuntimeFeature, keyedRowsCompleteFilterHintedRuntimeFeature, keyedRowsCompleteFilterPrependHintedRuntimeFeature, keyedRowsCompleteHintedRuntimeFeature, keyedRowsCompleteMappedRollingWindowHintedRuntimeFeature, keyedRowsCompletePositionHintedRuntimeFeature, keyedRowsCompletePrependHintedRuntimeFeature, keyedRowsCompleteReorderHintedRuntimeFeature, keyedRowsCompleteRuntimeFeature, keyedRowsCompleteStructuralAppendHintedRuntimeFeature, keyedRowsCompleteStructuralAppendMapHintedRuntimeFeature, keyedRowsCompleteStructuralPrependHintedRuntimeFeature, keyedRowsCompleteStructuralPrependMapHintedRuntimeFeature, keyedRowsCompleteWindowEveryHintedRuntimeFeature, keyedRowsCompleteWindowPositionHintedRuntimeFeature, keyedRowsConditionalAllHintedRuntimeFeature, keyedRowsConditionalBatchEveryHintedRuntimeFeature, keyedRowsConditionalBatchPositionHintedRuntimeFeature, keyedRowsConditionalEveryHintedRuntimeFeature, keyedRowsConditionalFilterHintedRuntimeFeature, keyedRowsConditionalFilterPrependHintedRuntimeFeature, keyedRowsConditionalHintedRuntimeFeature, keyedRowsConditionalMappedRollingWindowHintedRuntimeFeature, keyedRowsConditionalPositionHintedRuntimeFeature, keyedRowsConditionalPrependHintedRuntimeFeature, keyedRowsConditionalReorderHintedRuntimeFeature, keyedRowsConditionalRuntimeFeature, keyedRowsConditionalStructuralAppendHintedRuntimeFeature, keyedRowsConditionalStructuralAppendMapHintedRuntimeFeature, keyedRowsConditionalStructuralPrependHintedRuntimeFeature, keyedRowsConditionalStructuralPrependMapHintedRuntimeFeature, keyedRowsConditionalWindowEveryHintedRuntimeFeature, keyedRowsConditionalWindowPositionHintedRuntimeFeature, keyedRowsEveryHintedRuntimeFeature, keyedRowsFilterHintedRuntimeFeature, keyedRowsFilterOnlyRuntimeFeature, keyedRowsFilterPrependHintedRuntimeFeature, keyedRowsHintedRuntimeFeature, keyedRowsHostAllHintedRuntimeFeature, keyedRowsHostBatchEveryHintedRuntimeFeature, keyedRowsHostBatchPositionHintedRuntimeFeature, keyedRowsHostEveryHintedRuntimeFeature, keyedRowsHostFilterHintedRuntimeFeature, keyedRowsHostFilterPrependHintedRuntimeFeature, keyedRowsHostHintedRuntimeFeature, keyedRowsHostMappedRollingWindowHintedRuntimeFeature, keyedRowsHostPositionHintedRuntimeFeature, keyedRowsHostPrependHintedRuntimeFeature, keyedRowsHostReorderHintedRuntimeFeature, keyedRowsHostRuntimeFeature, keyedRowsHostStructuralAppendHintedRuntimeFeature, keyedRowsHostStructuralAppendMapHintedRuntimeFeature, keyedRowsHostStructuralPrependHintedRuntimeFeature, keyedRowsHostStructuralPrependMapHintedRuntimeFeature, keyedRowsHostWindowEveryHintedRuntimeFeature, keyedRowsHostWindowPositionHintedRuntimeFeature, keyedRowsIdentityFilterHintedRuntimeFeature, keyedRowsIdentityFilterOnlyRuntimeFeature, keyedRowsIdentityRuntimeFeature, keyedRowsMapLookupRuntimeFeature, keyedRowsMapReorderHintedRuntimeFeature, keyedRowsMappedRollingWindowHintedRuntimeFeature, keyedRowsMembershipRuntimeFeature, keyedRowsPlainMapReorderHintedRuntimeFeature, keyedRowsPlainPositionHintedRuntimeFeature, keyedRowsPlainReorderHintedRuntimeFeature, keyedRowsPlainRuntimeFeature, keyedRowsPositionHintedRuntimeFeature, keyedRowsPrependHintedRuntimeFeature, keyedRowsPrependOnlyRuntimeFeature, keyedRowsReorderHintedRuntimeFeature, keyedRowsRuntimeFeature, keyedRowsStructuralAppendHintedRuntimeFeature, keyedRowsStructuralAppendMapHintedRuntimeFeature, keyedRowsStructuralPrependHintedRuntimeFeature, keyedRowsStructuralPrependMapHintedRuntimeFeature, keyedRowsWindowEveryHintedRuntimeFeature, keyedRowsWindowPositionHintedRuntimeFeature, mixedRangesRuntimeFeature };
|
|
9216
|
+
export { applyCompilerKeyedCollectionMutation, componentRuntimeFeature, conditionalRangesRuntimeFeature, conditionalRuntimeFeature, createCompiledComponent, createCompiledComponentWithFeatures, createCompiledComponentWithoutRefresh, createCompiledRoot, createCompilerKeyedArrayAppend, createCompilerKeyedArrayBatchInsert, createCompilerKeyedArrayFilter, createCompilerKeyedArrayMapPipeline, createCompilerKeyedArrayMapReorder, createCompilerKeyedArrayMappedRollingWindow, createCompilerKeyedArrayMappedStructuralAppend, createCompilerKeyedArrayMappedStructuralPrepend, createCompilerKeyedArrayPositionUpdate, createCompilerKeyedArrayPrepend, createCompilerKeyedArrayQueuedMapPipeline, createCompilerKeyedArrayReorder, createCompilerKeyedArrayRollingWindow, createCompilerKeyedArrayRollingWindowMapPipeline, createCompilerKeyedArraySlice, createCompilerKeyedArraySort, createCompilerKeyedArrayStructuralAppend, createCompilerKeyedArrayStructuralAppendMapPipeline, createCompilerKeyedArrayStructuralPrepend, createCompilerKeyedArrayStructuralPrependMapPipeline, createCompilerKeyedArrayStructuralReorder, createCompilerKeyedArrayStructuralSort, createCompilerKeyedArrayWindowReplace, createCompilerKeyedCollectionUpdate, createCompilerKeyedMapUpdate, finalizeCompilerKeyedArrayMappedStructuralUpdate, hostConditionalRuntimeFeature, keyedListRuntimeFeature, keyedRangesRuntimeFeature, keyedRowsAllHintedRuntimeFeature, keyedRowsAppendOnlyRuntimeFeature, keyedRowsBatchEveryHintedRuntimeFeature, keyedRowsBatchPositionHintedRuntimeFeature, keyedRowsCompleteAllHintedRuntimeFeature, keyedRowsCompleteBatchEveryHintedRuntimeFeature, keyedRowsCompleteBatchPositionHintedRuntimeFeature, keyedRowsCompleteEveryHintedRuntimeFeature, keyedRowsCompleteFilterHintedRuntimeFeature, keyedRowsCompleteFilterPrependHintedRuntimeFeature, keyedRowsCompleteHintedRuntimeFeature, keyedRowsCompleteMappedRollingWindowHintedRuntimeFeature, keyedRowsCompletePositionHintedRuntimeFeature, keyedRowsCompletePrependHintedRuntimeFeature, keyedRowsCompleteReorderHintedRuntimeFeature, keyedRowsCompleteRuntimeFeature, keyedRowsCompleteStructuralAppendHintedRuntimeFeature, keyedRowsCompleteStructuralAppendMapHintedRuntimeFeature, keyedRowsCompleteStructuralPrependHintedRuntimeFeature, keyedRowsCompleteStructuralPrependMapHintedRuntimeFeature, keyedRowsCompleteWindowEveryHintedRuntimeFeature, keyedRowsCompleteWindowPositionHintedRuntimeFeature, keyedRowsConditionalAllHintedRuntimeFeature, keyedRowsConditionalBatchEveryHintedRuntimeFeature, keyedRowsConditionalBatchPositionHintedRuntimeFeature, keyedRowsConditionalEveryHintedRuntimeFeature, keyedRowsConditionalFilterHintedRuntimeFeature, keyedRowsConditionalFilterPrependHintedRuntimeFeature, keyedRowsConditionalHintedRuntimeFeature, keyedRowsConditionalMappedRollingWindowHintedRuntimeFeature, keyedRowsConditionalPositionHintedRuntimeFeature, keyedRowsConditionalPrependHintedRuntimeFeature, keyedRowsConditionalReorderHintedRuntimeFeature, keyedRowsConditionalRuntimeFeature, keyedRowsConditionalStructuralAppendHintedRuntimeFeature, keyedRowsConditionalStructuralAppendMapHintedRuntimeFeature, keyedRowsConditionalStructuralPrependHintedRuntimeFeature, keyedRowsConditionalStructuralPrependMapHintedRuntimeFeature, keyedRowsConditionalWindowEveryHintedRuntimeFeature, keyedRowsConditionalWindowPositionHintedRuntimeFeature, keyedRowsEveryHintedRuntimeFeature, keyedRowsFilterHintedRuntimeFeature, keyedRowsFilterOnlyRuntimeFeature, keyedRowsFilterPrependHintedRuntimeFeature, keyedRowsHintedRuntimeFeature, keyedRowsHostAllHintedRuntimeFeature, keyedRowsHostBatchEveryHintedRuntimeFeature, keyedRowsHostBatchPositionHintedRuntimeFeature, keyedRowsHostEveryHintedRuntimeFeature, keyedRowsHostFilterHintedRuntimeFeature, keyedRowsHostFilterPrependHintedRuntimeFeature, keyedRowsHostHintedRuntimeFeature, keyedRowsHostMappedRollingWindowHintedRuntimeFeature, keyedRowsHostPositionHintedRuntimeFeature, keyedRowsHostPrependHintedRuntimeFeature, keyedRowsHostReorderHintedRuntimeFeature, keyedRowsHostRuntimeFeature, keyedRowsHostStructuralAppendHintedRuntimeFeature, keyedRowsHostStructuralAppendMapHintedRuntimeFeature, keyedRowsHostStructuralPrependHintedRuntimeFeature, keyedRowsHostStructuralPrependMapHintedRuntimeFeature, keyedRowsHostWindowEveryHintedRuntimeFeature, keyedRowsHostWindowPositionHintedRuntimeFeature, keyedRowsIdentityFilterHintedRuntimeFeature, keyedRowsIdentityFilterOnlyRuntimeFeature, keyedRowsIdentityRuntimeFeature, keyedRowsMapLookupRuntimeFeature, keyedRowsMapReorderHintedRuntimeFeature, keyedRowsMappedRollingWindowHintedRuntimeFeature, keyedRowsMembershipRuntimeFeature, keyedRowsPlainMapReorderHintedRuntimeFeature, keyedRowsPlainPositionHintedRuntimeFeature, keyedRowsPlainReorderHintedRuntimeFeature, keyedRowsPlainRuntimeFeature, keyedRowsPositionHintedRuntimeFeature, keyedRowsPrependHintedRuntimeFeature, keyedRowsPrependOnlyRuntimeFeature, keyedRowsReorderHintedRuntimeFeature, keyedRowsRuntimeFeature, keyedRowsStructuralAppendHintedRuntimeFeature, keyedRowsStructuralAppendMapHintedRuntimeFeature, keyedRowsStructuralPrependHintedRuntimeFeature, keyedRowsStructuralPrependMapHintedRuntimeFeature, keyedRowsWindowEveryHintedRuntimeFeature, keyedRowsWindowPositionHintedRuntimeFeature, mixedRangesRuntimeFeature };
|
|
8796
9217
|
//# sourceMappingURL=compiler-runtime.mjs.map
|
|
8797
9218
|
//# sourceMappingURL=compiler-runtime.mjs.map
|