@wordpress/element 8.0.0 → 8.0.2-next.v.202606191442.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.
@@ -1,132 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/element/src/react-polyfill-base.ts
21
- var react_polyfill_base_exports = {};
22
- __export(react_polyfill_base_exports, {
23
- findDOMNode: () => findDOMNode,
24
- hydrate: () => hydrate,
25
- render: () => render,
26
- unmountComponentAtNode: () => unmountComponentAtNode
27
- });
28
- module.exports = __toCommonJS(react_polyfill_base_exports);
29
- var import_react_dom = require("react-dom");
30
- var import_client = require("react-dom/client");
31
- var internalsKey = "_reactInternals";
32
- var HostComponent = 5;
33
- var HostText = 6;
34
- function findCurrentFiber(fiber) {
35
- if (!fiber.alternate) {
36
- return fiber;
37
- }
38
- let node = fiber;
39
- while (node.return) {
40
- node = node.return;
41
- }
42
- if (node.stateNode.current === node) {
43
- return fiber;
44
- }
45
- return fiber.alternate;
46
- }
47
- function findHostFiber(fiber) {
48
- const current = findCurrentFiber(fiber);
49
- if (!current) {
50
- return null;
51
- }
52
- return findHostFiberImpl(current);
53
- }
54
- function findHostFiberImpl(fiber) {
55
- if (fiber.tag === HostComponent || fiber.tag === HostText) {
56
- return fiber;
57
- }
58
- let child = fiber.child;
59
- while (child) {
60
- const hostFiber = findHostFiberImpl(child);
61
- if (hostFiber) {
62
- return hostFiber;
63
- }
64
- child = child.sibling;
65
- }
66
- return null;
67
- }
68
- function findDOMNode(instance) {
69
- if (instance === null || instance === void 0) {
70
- return null;
71
- }
72
- if (instance.nodeType !== void 0) {
73
- return instance;
74
- }
75
- const fiber = instance[internalsKey];
76
- if (fiber === void 0) {
77
- if (typeof instance.render === "function") {
78
- throw new Error("Unable to find node on an unmounted component.");
79
- }
80
- const keys = Object.keys(instance).join(",");
81
- throw new Error(
82
- `Argument appears to not be a ReactComponent. Keys: ${keys}`
83
- );
84
- }
85
- const hostFiber = findHostFiber(fiber);
86
- return hostFiber?.stateNode ?? null;
87
- }
88
- var roots = /* @__PURE__ */ new WeakMap();
89
- function render(element, container, callback) {
90
- let root = roots.get(container);
91
- if (!root) {
92
- root = (0, import_client.createRoot)(container);
93
- roots.set(container, root);
94
- }
95
- (0, import_react_dom.flushSync)(() => {
96
- root.render(element);
97
- });
98
- if (typeof callback === "function") {
99
- callback();
100
- }
101
- }
102
- function hydrate(element, container, callback) {
103
- let root = roots.get(container);
104
- if (!root) {
105
- root = (0, import_client.hydrateRoot)(container, element);
106
- roots.set(container, root);
107
- } else {
108
- root.render(element);
109
- }
110
- if (typeof callback === "function") {
111
- callback();
112
- }
113
- }
114
- function unmountComponentAtNode(container) {
115
- const root = roots.get(container);
116
- if (!root) {
117
- return false;
118
- }
119
- (0, import_react_dom.flushSync)(() => {
120
- root.unmount();
121
- });
122
- roots.delete(container);
123
- return true;
124
- }
125
- // Annotate the CommonJS export names for ESM import in node:
126
- 0 && (module.exports = {
127
- findDOMNode,
128
- hydrate,
129
- render,
130
- unmountComponentAtNode
131
- });
132
- //# sourceMappingURL=react-polyfill-base.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/react-polyfill-base.ts"],
4
- "sourcesContent": ["import { flushSync } from 'react-dom';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport type { Root } from 'react-dom/client';\n\nconst internalsKey = '_reactInternals';\n\n// HostComponent fiber tag, represents a DOM element like <div>.\nconst HostComponent = 5;\nconst HostText = 6;\n\nfunction findCurrentFiber( fiber: any ): any {\n\tif ( ! fiber.alternate ) {\n\t\t// First mount \u2014 only one version exists, and it's current.\n\t\treturn fiber;\n\t}\n\n\t// Walk up to the HostRoot to figure out which tree this fiber is on.\n\tlet node = fiber;\n\twhile ( node.return ) {\n\t\tnode = node.return;\n\t}\n\n\t// The root's stateNode.current points to the current tree's root fiber.\n\tif ( node.stateNode.current === node ) {\n\t\t// We walked up the current tree, so `fiber` is already current.\n\t\treturn fiber;\n\t}\n\n\t// We walked up the alternate tree \u2014 switch to the current version.\n\treturn fiber.alternate;\n}\n\nfunction findHostFiber( fiber: any ): any {\n\tconst current = findCurrentFiber( fiber );\n\tif ( ! current ) {\n\t\treturn null;\n\t}\n\treturn findHostFiberImpl( current );\n}\n\nfunction findHostFiberImpl( fiber: any ): any {\n\tif ( fiber.tag === HostComponent || fiber.tag === HostText ) {\n\t\treturn fiber;\n\t}\n\n\tlet child = fiber.child;\n\twhile ( child ) {\n\t\tconst hostFiber = findHostFiberImpl( child );\n\t\tif ( hostFiber ) {\n\t\t\treturn hostFiber;\n\t\t}\n\t\tchild = child.sibling;\n\t}\n\n\treturn null;\n}\n\nexport function findDOMNode( instance: any ): Element | Text | null {\n\tif ( instance === null || instance === undefined ) {\n\t\treturn null;\n\t}\n\n\tif ( instance.nodeType !== undefined ) {\n\t\treturn instance as Element | Text;\n\t}\n\n\tconst fiber = instance[ internalsKey ];\n\tif ( fiber === undefined ) {\n\t\tif ( typeof instance.render === 'function' ) {\n\t\t\tthrow new Error( 'Unable to find node on an unmounted component.' );\n\t\t}\n\t\tconst keys = Object.keys( instance ).join( ',' );\n\t\tthrow new Error(\n\t\t\t`Argument appears to not be a ReactComponent. Keys: ${ keys }`\n\t\t);\n\t}\n\n\tconst hostFiber = findHostFiber( fiber );\n\treturn hostFiber?.stateNode ?? null;\n}\n\nconst roots = new WeakMap< Element, Root >();\n\nexport function render(\n\telement: React.ReactNode,\n\tcontainer: Element,\n\tcallback?: () => void\n): void {\n\tlet root = roots.get( container );\n\tif ( ! root ) {\n\t\troot = createRoot( container );\n\t\troots.set( container, root );\n\t}\n\n\tflushSync( () => {\n\t\troot.render( element );\n\t} );\n\n\tif ( typeof callback === 'function' ) {\n\t\tcallback();\n\t}\n}\n\nexport function hydrate(\n\telement: React.ReactNode,\n\tcontainer: Element,\n\tcallback?: () => void\n): void {\n\tlet root = roots.get( container );\n\tif ( ! root ) {\n\t\troot = hydrateRoot( container, element );\n\t\troots.set( container, root );\n\t} else {\n\t\troot.render( element );\n\t}\n\n\tif ( typeof callback === 'function' ) {\n\t\tcallback();\n\t}\n}\n\nexport function unmountComponentAtNode( container: Element ): boolean {\n\tconst root = roots.get( container );\n\tif ( ! root ) {\n\t\treturn false;\n\t}\n\n\tflushSync( () => {\n\t\troot.unmount();\n\t} );\n\troots.delete( container );\n\treturn true;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0B;AAC1B,oBAAwC;AAGxC,IAAM,eAAe;AAGrB,IAAM,gBAAgB;AACtB,IAAM,WAAW;AAEjB,SAAS,iBAAkB,OAAkB;AAC5C,MAAK,CAAE,MAAM,WAAY;AAExB,WAAO;AAAA,EACR;AAGA,MAAI,OAAO;AACX,SAAQ,KAAK,QAAS;AACrB,WAAO,KAAK;AAAA,EACb;AAGA,MAAK,KAAK,UAAU,YAAY,MAAO;AAEtC,WAAO;AAAA,EACR;AAGA,SAAO,MAAM;AACd;AAEA,SAAS,cAAe,OAAkB;AACzC,QAAM,UAAU,iBAAkB,KAAM;AACxC,MAAK,CAAE,SAAU;AAChB,WAAO;AAAA,EACR;AACA,SAAO,kBAAmB,OAAQ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K,OAAQ,OAAQ;AAAA,EACtB;AAEA,MAAK,OAAO,aAAa,YAAa;AACrC,aAAS;AAAA,EACV;AACD;AAEO,SAAS,uBAAwB,WAA8B;AACrE,QAAM,OAAO,MAAM,IAAK,SAAU;AAClC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,kCAAW,MAAM;AAChB,SAAK,QAAQ;AAAA,EACd,CAAE;AACF,QAAM,OAAQ,SAAU;AACxB,SAAO;AACR;",
6
- "names": []
7
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/element/src/react-polyfill.ts
31
- var react_polyfill_exports = {};
32
- __export(react_polyfill_exports, {
33
- findDOMNode: () => findDOMNode,
34
- hydrate: () => hydrate,
35
- render: () => render,
36
- unmountComponentAtNode: () => unmountComponentAtNode
37
- });
38
- module.exports = __toCommonJS(react_polyfill_exports);
39
- var import_deprecated = __toESM(require("@wordpress/deprecated"));
40
- var import_react_polyfill_base = require("./react-polyfill-base.cjs");
41
- function findDOMNode(instance) {
42
- (0, import_deprecated.default)("wp.element.findDOMNode", {
43
- since: "7.1",
44
- alternative: "DOM refs",
45
- link: "https://react.dev/reference/react-dom/findDOMNode"
46
- });
47
- return (0, import_react_polyfill_base.findDOMNode)(instance);
48
- }
49
- function render(element, container, callback) {
50
- (0, import_deprecated.default)("wp.element.render", {
51
- since: "6.2",
52
- alternative: "wp.element.createRoot",
53
- link: "https://react.dev/reference/react-dom/client/createRoot"
54
- });
55
- (0, import_react_polyfill_base.render)(element, container, callback);
56
- }
57
- function hydrate(element, container, callback) {
58
- (0, import_deprecated.default)("wp.element.hydrate", {
59
- since: "6.2",
60
- alternative: "wp.element.hydrateRoot",
61
- link: "https://react.dev/reference/react-dom/client/hydrateRoot"
62
- });
63
- (0, import_react_polyfill_base.hydrate)(element, container, callback);
64
- }
65
- function unmountComponentAtNode(container) {
66
- (0, import_deprecated.default)("wp.element.unmountComponentAtNode", {
67
- since: "6.2",
68
- alternative: "root.unmount()",
69
- link: "https://react.dev/reference/react-dom/client/createRoot#root-unmount"
70
- });
71
- return (0, import_react_polyfill_base.unmountComponentAtNode)(container);
72
- }
73
- // Annotate the CommonJS export names for ESM import in node:
74
- 0 && (module.exports = {
75
- findDOMNode,
76
- hydrate,
77
- render,
78
- unmountComponentAtNode
79
- });
80
- //# sourceMappingURL=react-polyfill.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/react-polyfill.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport {\n\tfindDOMNode as findDOMNodeBase,\n\trender as renderBase,\n\thydrate as hydrateBase,\n\tunmountComponentAtNode as unmountComponentAtNodeBase,\n} from './react-polyfill-base';\n\n/**\n * Finds the DOM node of a React component instance.\n *\n * @deprecated since WordPress 7.1.0. Use DOM refs instead.\n * @see https://react.dev/reference/react-dom/findDOMNode\n *\n * @param instance Component's instance.\n */\nexport function findDOMNode( instance: any ): Element | Text | null {\n\tdeprecated( 'wp.element.findDOMNode', {\n\t\tsince: '7.1',\n\t\talternative: 'DOM refs',\n\t\tlink: 'https://react.dev/reference/react-dom/findDOMNode',\n\t} );\n\n\treturn findDOMNodeBase( instance );\n}\n\n/**\n * Renders a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `createRoot` instead.\n * @see https://react.dev/reference/react-dom/render\n *\n * @param element Element to render.\n * @param container DOM node into which to render.\n * @param callback Optional callback called after render.\n */\nexport function render(\n\telement: React.ReactNode,\n\tcontainer: Element,\n\tcallback?: () => void\n): void {\n\tdeprecated( 'wp.element.render', {\n\t\tsince: '6.2',\n\t\talternative: 'wp.element.createRoot',\n\t\tlink: 'https://react.dev/reference/react-dom/client/createRoot',\n\t} );\n\n\trenderBase( element, container, callback );\n}\n\n/**\n * Hydrates a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.\n * @see https://react.dev/reference/react-dom/hydrate\n *\n * @param element Element to hydrate.\n * @param container DOM node to hydrate.\n * @param callback Optional callback called after hydration.\n */\nexport function hydrate(\n\telement: React.ReactNode,\n\tcontainer: Element,\n\tcallback?: () => void\n): void {\n\tdeprecated( 'wp.element.hydrate', {\n\t\tsince: '6.2',\n\t\talternative: 'wp.element.hydrateRoot',\n\t\tlink: 'https://react.dev/reference/react-dom/client/hydrateRoot',\n\t} );\n\n\thydrateBase( element, container, callback );\n}\n\n/**\n * Removes any mounted element from the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.\n * @see https://react.dev/reference/react-dom/unmountComponentAtNode\n *\n * @param container DOM node in which to unmount.\n * @return Whether the node was unmounted.\n */\nexport function unmountComponentAtNode( container: Element ): boolean {\n\tdeprecated( 'wp.element.unmountComponentAtNode', {\n\t\tsince: '6.2',\n\t\talternative: 'root.unmount()',\n\t\tlink: 'https://react.dev/reference/react-dom/client/createRoot#root-unmount',\n\t} );\n\n\treturn unmountComponentAtNodeBase( container );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAuB;AAKvB,iCAKO;AAUA,SAAS,YAAa,UAAuC;AACnE,wBAAAA,SAAY,0BAA0B;AAAA,IACrC,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACP,CAAE;AAEF,aAAO,2BAAAC,aAAiB,QAAS;AAClC;AAYO,SAAS,OACf,SACA,WACA,UACO;AACP,wBAAAD,SAAY,qBAAqB;AAAA,IAChC,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACP,CAAE;AAEF,iCAAAE,QAAY,SAAS,WAAW,QAAS;AAC1C;AAYO,SAAS,QACf,SACA,WACA,UACO;AACP,wBAAAF,SAAY,sBAAsB;AAAA,IACjC,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACP,CAAE;AAEF,iCAAAG,SAAa,SAAS,WAAW,QAAS;AAC3C;AAWO,SAAS,uBAAwB,WAA8B;AACrE,wBAAAH,SAAY,qCAAqC;AAAA,IAChD,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACP,CAAE;AAEF,aAAO,2BAAAI,wBAA4B,SAAU;AAC9C;",
6
- "names": ["deprecated", "findDOMNodeBase", "renderBase", "hydrateBase", "unmountComponentAtNodeBase"]
7
- }
@@ -1,104 +0,0 @@
1
- // packages/element/src/react-polyfill-base.ts
2
- import { flushSync } from "react-dom";
3
- import { createRoot, hydrateRoot } from "react-dom/client";
4
- var internalsKey = "_reactInternals";
5
- var HostComponent = 5;
6
- var HostText = 6;
7
- function findCurrentFiber(fiber) {
8
- if (!fiber.alternate) {
9
- return fiber;
10
- }
11
- let node = fiber;
12
- while (node.return) {
13
- node = node.return;
14
- }
15
- if (node.stateNode.current === node) {
16
- return fiber;
17
- }
18
- return fiber.alternate;
19
- }
20
- function findHostFiber(fiber) {
21
- const current = findCurrentFiber(fiber);
22
- if (!current) {
23
- return null;
24
- }
25
- return findHostFiberImpl(current);
26
- }
27
- function findHostFiberImpl(fiber) {
28
- if (fiber.tag === HostComponent || fiber.tag === HostText) {
29
- return fiber;
30
- }
31
- let child = fiber.child;
32
- while (child) {
33
- const hostFiber = findHostFiberImpl(child);
34
- if (hostFiber) {
35
- return hostFiber;
36
- }
37
- child = child.sibling;
38
- }
39
- return null;
40
- }
41
- function findDOMNode(instance) {
42
- if (instance === null || instance === void 0) {
43
- return null;
44
- }
45
- if (instance.nodeType !== void 0) {
46
- return instance;
47
- }
48
- const fiber = instance[internalsKey];
49
- if (fiber === void 0) {
50
- if (typeof instance.render === "function") {
51
- throw new Error("Unable to find node on an unmounted component.");
52
- }
53
- const keys = Object.keys(instance).join(",");
54
- throw new Error(
55
- `Argument appears to not be a ReactComponent. Keys: ${keys}`
56
- );
57
- }
58
- const hostFiber = findHostFiber(fiber);
59
- return hostFiber?.stateNode ?? null;
60
- }
61
- var roots = /* @__PURE__ */ new WeakMap();
62
- function render(element, container, callback) {
63
- let root = roots.get(container);
64
- if (!root) {
65
- root = createRoot(container);
66
- roots.set(container, root);
67
- }
68
- flushSync(() => {
69
- root.render(element);
70
- });
71
- if (typeof callback === "function") {
72
- callback();
73
- }
74
- }
75
- function hydrate(element, container, callback) {
76
- let root = roots.get(container);
77
- if (!root) {
78
- root = hydrateRoot(container, element);
79
- roots.set(container, root);
80
- } else {
81
- root.render(element);
82
- }
83
- if (typeof callback === "function") {
84
- callback();
85
- }
86
- }
87
- function unmountComponentAtNode(container) {
88
- const root = roots.get(container);
89
- if (!root) {
90
- return false;
91
- }
92
- flushSync(() => {
93
- root.unmount();
94
- });
95
- roots.delete(container);
96
- return true;
97
- }
98
- export {
99
- findDOMNode,
100
- hydrate,
101
- render,
102
- unmountComponentAtNode
103
- };
104
- //# sourceMappingURL=react-polyfill-base.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/react-polyfill-base.ts"],
4
- "sourcesContent": ["import { flushSync } from 'react-dom';\nimport { createRoot, hydrateRoot } from 'react-dom/client';\nimport type { Root } from 'react-dom/client';\n\nconst internalsKey = '_reactInternals';\n\n// HostComponent fiber tag, represents a DOM element like <div>.\nconst HostComponent = 5;\nconst HostText = 6;\n\nfunction findCurrentFiber( fiber: any ): any {\n\tif ( ! fiber.alternate ) {\n\t\t// First mount \u2014 only one version exists, and it's current.\n\t\treturn fiber;\n\t}\n\n\t// Walk up to the HostRoot to figure out which tree this fiber is on.\n\tlet node = fiber;\n\twhile ( node.return ) {\n\t\tnode = node.return;\n\t}\n\n\t// The root's stateNode.current points to the current tree's root fiber.\n\tif ( node.stateNode.current === node ) {\n\t\t// We walked up the current tree, so `fiber` is already current.\n\t\treturn fiber;\n\t}\n\n\t// We walked up the alternate tree \u2014 switch to the current version.\n\treturn fiber.alternate;\n}\n\nfunction findHostFiber( fiber: any ): any {\n\tconst current = findCurrentFiber( fiber );\n\tif ( ! current ) {\n\t\treturn null;\n\t}\n\treturn findHostFiberImpl( current );\n}\n\nfunction findHostFiberImpl( fiber: any ): any {\n\tif ( fiber.tag === HostComponent || fiber.tag === HostText ) {\n\t\treturn fiber;\n\t}\n\n\tlet child = fiber.child;\n\twhile ( child ) {\n\t\tconst hostFiber = findHostFiberImpl( child );\n\t\tif ( hostFiber ) {\n\t\t\treturn hostFiber;\n\t\t}\n\t\tchild = child.sibling;\n\t}\n\n\treturn null;\n}\n\nexport function findDOMNode( instance: any ): Element | Text | null {\n\tif ( instance === null || instance === undefined ) {\n\t\treturn null;\n\t}\n\n\tif ( instance.nodeType !== undefined ) {\n\t\treturn instance as Element | Text;\n\t}\n\n\tconst fiber = instance[ internalsKey ];\n\tif ( fiber === undefined ) {\n\t\tif ( typeof instance.render === 'function' ) {\n\t\t\tthrow new Error( 'Unable to find node on an unmounted component.' );\n\t\t}\n\t\tconst keys = Object.keys( instance ).join( ',' );\n\t\tthrow new Error(\n\t\t\t`Argument appears to not be a ReactComponent. Keys: ${ keys }`\n\t\t);\n\t}\n\n\tconst hostFiber = findHostFiber( fiber );\n\treturn hostFiber?.stateNode ?? null;\n}\n\nconst roots = new WeakMap< Element, Root >();\n\nexport function render(\n\telement: React.ReactNode,\n\tcontainer: Element,\n\tcallback?: () => void\n): void {\n\tlet root = roots.get( container );\n\tif ( ! root ) {\n\t\troot = createRoot( container );\n\t\troots.set( container, root );\n\t}\n\n\tflushSync( () => {\n\t\troot.render( element );\n\t} );\n\n\tif ( typeof callback === 'function' ) {\n\t\tcallback();\n\t}\n}\n\nexport function hydrate(\n\telement: React.ReactNode,\n\tcontainer: Element,\n\tcallback?: () => void\n): void {\n\tlet root = roots.get( container );\n\tif ( ! root ) {\n\t\troot = hydrateRoot( container, element );\n\t\troots.set( container, root );\n\t} else {\n\t\troot.render( element );\n\t}\n\n\tif ( typeof callback === 'function' ) {\n\t\tcallback();\n\t}\n}\n\nexport function unmountComponentAtNode( container: Element ): boolean {\n\tconst root = roots.get( container );\n\tif ( ! root ) {\n\t\treturn false;\n\t}\n\n\tflushSync( () => {\n\t\troot.unmount();\n\t} );\n\troots.delete( container );\n\treturn true;\n}\n"],
5
- "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,YAAY,mBAAmB;AAGxC,IAAM,eAAe;AAGrB,IAAM,gBAAgB;AACtB,IAAM,WAAW;AAEjB,SAAS,iBAAkB,OAAkB;AAC5C,MAAK,CAAE,MAAM,WAAY;AAExB,WAAO;AAAA,EACR;AAGA,MAAI,OAAO;AACX,SAAQ,KAAK,QAAS;AACrB,WAAO,KAAK;AAAA,EACb;AAGA,MAAK,KAAK,UAAU,YAAY,MAAO;AAEtC,WAAO;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A,WACA,UACO;AACP,MAAI,OAAO,MAAM,IAAK,SAAU;AAChC,MAAK,CAAE,MAAO;AACb,WAAO,YAAa,WAAW,OAAQ;AACvC,UAAM,IAAK,WAAW,IAAK;AAAA,EAC5B,OAAO;AACN,SAAK,OAAQ,OAAQ;AAAA,EACtB;AAEA,MAAK,OAAO,aAAa,YAAa;AACrC,aAAS;AAAA,EACV;AACD;AAEO,SAAS,uBAAwB,WAA8B;AACrE,QAAM,OAAO,MAAM,IAAK,SAAU;AAClC,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,YAAW,MAAM;AAChB,SAAK,QAAQ;AAAA,EACd,CAAE;AACF,QAAM,OAAQ,SAAU;AACxB,SAAO;AACR;",
6
- "names": []
7
- }
@@ -1,47 +0,0 @@
1
- // packages/element/src/react-polyfill.ts
2
- import deprecated from "@wordpress/deprecated";
3
- import {
4
- findDOMNode as findDOMNodeBase,
5
- render as renderBase,
6
- hydrate as hydrateBase,
7
- unmountComponentAtNode as unmountComponentAtNodeBase
8
- } from "./react-polyfill-base.mjs";
9
- function findDOMNode(instance) {
10
- deprecated("wp.element.findDOMNode", {
11
- since: "7.1",
12
- alternative: "DOM refs",
13
- link: "https://react.dev/reference/react-dom/findDOMNode"
14
- });
15
- return findDOMNodeBase(instance);
16
- }
17
- function render(element, container, callback) {
18
- deprecated("wp.element.render", {
19
- since: "6.2",
20
- alternative: "wp.element.createRoot",
21
- link: "https://react.dev/reference/react-dom/client/createRoot"
22
- });
23
- renderBase(element, container, callback);
24
- }
25
- function hydrate(element, container, callback) {
26
- deprecated("wp.element.hydrate", {
27
- since: "6.2",
28
- alternative: "wp.element.hydrateRoot",
29
- link: "https://react.dev/reference/react-dom/client/hydrateRoot"
30
- });
31
- hydrateBase(element, container, callback);
32
- }
33
- function unmountComponentAtNode(container) {
34
- deprecated("wp.element.unmountComponentAtNode", {
35
- since: "6.2",
36
- alternative: "root.unmount()",
37
- link: "https://react.dev/reference/react-dom/client/createRoot#root-unmount"
38
- });
39
- return unmountComponentAtNodeBase(container);
40
- }
41
- export {
42
- findDOMNode,
43
- hydrate,
44
- render,
45
- unmountComponentAtNode
46
- };
47
- //# sourceMappingURL=react-polyfill.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/react-polyfill.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport {\n\tfindDOMNode as findDOMNodeBase,\n\trender as renderBase,\n\thydrate as hydrateBase,\n\tunmountComponentAtNode as unmountComponentAtNodeBase,\n} from './react-polyfill-base';\n\n/**\n * Finds the DOM node of a React component instance.\n *\n * @deprecated since WordPress 7.1.0. Use DOM refs instead.\n * @see https://react.dev/reference/react-dom/findDOMNode\n *\n * @param instance Component's instance.\n */\nexport function findDOMNode( instance: any ): Element | Text | null {\n\tdeprecated( 'wp.element.findDOMNode', {\n\t\tsince: '7.1',\n\t\talternative: 'DOM refs',\n\t\tlink: 'https://react.dev/reference/react-dom/findDOMNode',\n\t} );\n\n\treturn findDOMNodeBase( instance );\n}\n\n/**\n * Renders a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `createRoot` instead.\n * @see https://react.dev/reference/react-dom/render\n *\n * @param element Element to render.\n * @param container DOM node into which to render.\n * @param callback Optional callback called after render.\n */\nexport function render(\n\telement: React.ReactNode,\n\tcontainer: Element,\n\tcallback?: () => void\n): void {\n\tdeprecated( 'wp.element.render', {\n\t\tsince: '6.2',\n\t\talternative: 'wp.element.createRoot',\n\t\tlink: 'https://react.dev/reference/react-dom/client/createRoot',\n\t} );\n\n\trenderBase( element, container, callback );\n}\n\n/**\n * Hydrates a given element into the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.\n * @see https://react.dev/reference/react-dom/hydrate\n *\n * @param element Element to hydrate.\n * @param container DOM node to hydrate.\n * @param callback Optional callback called after hydration.\n */\nexport function hydrate(\n\telement: React.ReactNode,\n\tcontainer: Element,\n\tcallback?: () => void\n): void {\n\tdeprecated( 'wp.element.hydrate', {\n\t\tsince: '6.2',\n\t\talternative: 'wp.element.hydrateRoot',\n\t\tlink: 'https://react.dev/reference/react-dom/client/hydrateRoot',\n\t} );\n\n\thydrateBase( element, container, callback );\n}\n\n/**\n * Removes any mounted element from the target DOM node.\n *\n * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.\n * @see https://react.dev/reference/react-dom/unmountComponentAtNode\n *\n * @param container DOM node in which to unmount.\n * @return Whether the node was unmounted.\n */\nexport function unmountComponentAtNode( container: Element ): boolean {\n\tdeprecated( 'wp.element.unmountComponentAtNode', {\n\t\tsince: '6.2',\n\t\talternative: 'root.unmount()',\n\t\tlink: 'https://react.dev/reference/react-dom/client/createRoot#root-unmount',\n\t} );\n\n\treturn unmountComponentAtNodeBase( container );\n}\n"],
5
- "mappings": ";AAGA,OAAO,gBAAgB;AAKvB;AAAA,EACC,eAAe;AAAA,EACf,UAAU;AAAA,EACV,WAAW;AAAA,EACX,0BAA0B;AAAA,OACpB;AAUA,SAAS,YAAa,UAAuC;AACnE,aAAY,0BAA0B;AAAA,IACrC,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACP,CAAE;AAEF,SAAO,gBAAiB,QAAS;AAClC;AAYO,SAAS,OACf,SACA,WACA,UACO;AACP,aAAY,qBAAqB;AAAA,IAChC,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACP,CAAE;AAEF,aAAY,SAAS,WAAW,QAAS;AAC1C;AAYO,SAAS,QACf,SACA,WACA,UACO;AACP,aAAY,sBAAsB;AAAA,IACjC,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACP,CAAE;AAEF,cAAa,SAAS,WAAW,QAAS;AAC3C;AAWO,SAAS,uBAAwB,WAA8B;AACrE,aAAY,qCAAqC;AAAA,IAChD,OAAO;AAAA,IACP,aAAa;AAAA,IACb,MAAM;AAAA,EACP,CAAE;AAEF,SAAO,2BAA4B,SAAU;AAC9C;",
6
- "names": []
7
- }
@@ -1,5 +0,0 @@
1
- export declare function findDOMNode(instance: any): Element | Text | null;
2
- export declare function render(element: React.ReactNode, container: Element, callback?: () => void): void;
3
- export declare function hydrate(element: React.ReactNode, container: Element, callback?: () => void): void;
4
- export declare function unmountComponentAtNode(container: Element): boolean;
5
- //# sourceMappingURL=react-polyfill-base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-polyfill-base.d.ts","sourceRoot":"","sources":["../src/react-polyfill-base.ts"],"names":[],"mappings":"AAyDA,wBAAgB,WAAW,CAAE,QAAQ,EAAE,GAAG,GAAI,OAAO,GAAG,IAAI,GAAG,IAAI,CAsBlE;AAID,wBAAgB,MAAM,CACrB,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,GACnB,IAAI,CAcN;AAED,wBAAgB,OAAO,CACtB,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,GACnB,IAAI,CAYN;AAED,wBAAgB,sBAAsB,CAAE,SAAS,EAAE,OAAO,GAAI,OAAO,CAWpE"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Finds the DOM node of a React component instance.
3
- *
4
- * @deprecated since WordPress 7.1.0. Use DOM refs instead.
5
- * @see https://react.dev/reference/react-dom/findDOMNode
6
- *
7
- * @param instance Component's instance.
8
- */
9
- export declare function findDOMNode(instance: any): Element | Text | null;
10
- /**
11
- * Renders a given element into the target DOM node.
12
- *
13
- * @deprecated since WordPress 6.2.0. Use `createRoot` instead.
14
- * @see https://react.dev/reference/react-dom/render
15
- *
16
- * @param element Element to render.
17
- * @param container DOM node into which to render.
18
- * @param callback Optional callback called after render.
19
- */
20
- export declare function render(element: React.ReactNode, container: Element, callback?: () => void): void;
21
- /**
22
- * Hydrates a given element into the target DOM node.
23
- *
24
- * @deprecated since WordPress 6.2.0. Use `hydrateRoot` instead.
25
- * @see https://react.dev/reference/react-dom/hydrate
26
- *
27
- * @param element Element to hydrate.
28
- * @param container DOM node to hydrate.
29
- * @param callback Optional callback called after hydration.
30
- */
31
- export declare function hydrate(element: React.ReactNode, container: Element, callback?: () => void): void;
32
- /**
33
- * Removes any mounted element from the target DOM node.
34
- *
35
- * @deprecated since WordPress 6.2.0. Use `root.unmount()` instead.
36
- * @see https://react.dev/reference/react-dom/unmountComponentAtNode
37
- *
38
- * @param container DOM node in which to unmount.
39
- * @return Whether the node was unmounted.
40
- */
41
- export declare function unmountComponentAtNode(container: Element): boolean;
42
- //# sourceMappingURL=react-polyfill.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-polyfill.d.ts","sourceRoot":"","sources":["../src/react-polyfill.ts"],"names":[],"mappings":"AAeA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAE,QAAQ,EAAE,GAAG,GAAI,OAAO,GAAG,IAAI,GAAG,IAAI,CAQlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CACrB,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,GACnB,IAAI,CAQN;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACtB,OAAO,EAAE,KAAK,CAAC,SAAS,EACxB,SAAS,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,GACnB,IAAI,CAQN;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAE,SAAS,EAAE,OAAO,GAAI,OAAO,CAQpE"}
@@ -1,21 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { Platform as OriginalPlatform } from 'react-native';
5
-
6
- const Platform = {
7
- ...OriginalPlatform,
8
- OS: 'native',
9
- select: ( spec ) => {
10
- if ( 'android' in spec ) {
11
- return spec.android;
12
- } else if ( 'native' in spec ) {
13
- return spec.native;
14
- }
15
- return spec.default;
16
- },
17
- isNative: true,
18
- isAndroid: true,
19
- };
20
-
21
- export default Platform;
@@ -1,21 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { Platform as OriginalPlatform } from 'react-native';
5
-
6
- const Platform = {
7
- ...OriginalPlatform,
8
- OS: 'native',
9
- select: ( spec ) => {
10
- if ( 'ios' in spec ) {
11
- return spec.ios;
12
- } else if ( 'native' in spec ) {
13
- return spec.native;
14
- }
15
- return spec.default;
16
- },
17
- isNative: true,
18
- isIOS: true,
19
- };
20
-
21
- export default Platform;
@@ -1,14 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { AppRegistry } from 'react-native';
5
-
6
- /**
7
- * Registers an app root component allowing the native system to run the app.
8
- *
9
- * @param {string} appKey Unique app name identifier.
10
- * @param {Function} componentProvider Function returning the app root React component.
11
- */
12
- export const registerComponent = ( appKey, componentProvider ) => {
13
- AppRegistry.registerComponent( appKey, componentProvider );
14
- };