@rectify-dev/core 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +31 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +32 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ A lightweight React-like UI library built from scratch — fiber reconciler, con
|
|
|
13
13
|
| `useRef` (object + callback refs) | ✅ |
|
|
14
14
|
| `useMemo`, `useCallback` | ✅ |
|
|
15
15
|
| `useContext` + `createContext` | ✅ |
|
|
16
|
-
| `useId
|
|
16
|
+
| `useId` | ✅ |
|
|
17
17
|
| `memo()` with custom comparator | ✅ |
|
|
18
18
|
| `lazy()` + `<Suspense>` | ✅ |
|
|
19
19
|
| SVG elements | ✅ |
|
package/dist/index.cjs
CHANGED
|
@@ -72,6 +72,10 @@ function unmarkContainerAsRoot(node) {
|
|
|
72
72
|
node[internalContainerInstanceKey] = null;
|
|
73
73
|
}
|
|
74
74
|
chunkAJJIEZ7G_cjs.__name(unmarkContainerAsRoot, "unmarkContainerAsRoot");
|
|
75
|
+
function isContainerMarkedAsRoot(node) {
|
|
76
|
+
return !!node[internalContainerInstanceKey];
|
|
77
|
+
}
|
|
78
|
+
chunkAJJIEZ7G_cjs.__name(isContainerMarkedAsRoot, "isContainerMarkedAsRoot");
|
|
75
79
|
var precacheFiberNode = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber, node) => {
|
|
76
80
|
if (!node) return;
|
|
77
81
|
node[internalInstanceKey] = fiber;
|
|
@@ -135,6 +139,11 @@ var dispatchEvent = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((domEventName, targ
|
|
|
135
139
|
const targetNode = getEventTarget(nativeEvent);
|
|
136
140
|
const targetFiber = getFiberNodeCached(targetNode);
|
|
137
141
|
if (!targetFiber) return;
|
|
142
|
+
let domCursor = targetNode.parentNode;
|
|
143
|
+
while (domCursor && domCursor !== targetContainer) {
|
|
144
|
+
if (isContainerMarkedAsRoot(domCursor)) return;
|
|
145
|
+
domCursor = domCursor.parentNode;
|
|
146
|
+
}
|
|
138
147
|
const syntheticEvent = new SyntheticEvent_default(nativeEvent);
|
|
139
148
|
const path = [];
|
|
140
149
|
let fiber = targetFiber;
|
|
@@ -321,6 +330,7 @@ var ContextProvider = /* @__PURE__ */ Symbol.for("rectify.context_provider");
|
|
|
321
330
|
var MemoComponent = /* @__PURE__ */ Symbol.for("rectify.memo_component");
|
|
322
331
|
var LazyComponent = /* @__PURE__ */ Symbol.for("rectify.lazy_component");
|
|
323
332
|
var SuspenseComponent = /* @__PURE__ */ Symbol.for("rectify.suspense_component");
|
|
333
|
+
var PortalComponent = /* @__PURE__ */ Symbol.for("rectify.portal_component");
|
|
324
334
|
var addFlagToFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber, flag) => {
|
|
325
335
|
if (hasFlagOnFiber(fiber, flag)) return;
|
|
326
336
|
fiber.flags |= flag;
|
|
@@ -335,6 +345,8 @@ var hasFlagOnFiber = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber, flag) => {
|
|
|
335
345
|
}, "hasFlagOnFiber");
|
|
336
346
|
var getFiberTagFromElement = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((element) => {
|
|
337
347
|
switch (element.$$typeof) {
|
|
348
|
+
case shared.RECTIFY_PORTAL_TYPE:
|
|
349
|
+
return PortalComponent;
|
|
338
350
|
case shared.RECTIFY_ELEMENT_TYPE:
|
|
339
351
|
if (shared.isFunction(element.type) && element.type?._context === element.type) {
|
|
340
352
|
return ContextProvider;
|
|
@@ -416,6 +428,7 @@ var getParentDom = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((fiber) => {
|
|
|
416
428
|
while (p) {
|
|
417
429
|
if (p.workTag === HostComponent) return p.stateNode;
|
|
418
430
|
if (p.workTag === HostRoot) return p.stateNode;
|
|
431
|
+
if (p.workTag === PortalComponent) return p.stateNode;
|
|
419
432
|
p = p.return;
|
|
420
433
|
}
|
|
421
434
|
throw new Error("No parent DOM found.");
|
|
@@ -1358,6 +1371,11 @@ var beginWork = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((wip) => {
|
|
|
1358
1371
|
}
|
|
1359
1372
|
throw lazy2._promise;
|
|
1360
1373
|
}
|
|
1374
|
+
case PortalComponent: {
|
|
1375
|
+
wip.stateNode = wip.pendingProps.containerInfo;
|
|
1376
|
+
reconcileChildren(wip, wip.pendingProps.children);
|
|
1377
|
+
break;
|
|
1378
|
+
}
|
|
1361
1379
|
}
|
|
1362
1380
|
return wip.child;
|
|
1363
1381
|
}, "beginWork");
|
|
@@ -1768,6 +1786,18 @@ var createRoot = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((container) => {
|
|
|
1768
1786
|
}, "unmount")
|
|
1769
1787
|
};
|
|
1770
1788
|
}, "createRoot");
|
|
1789
|
+
var createPortal = /* @__PURE__ */ chunkAJJIEZ7G_cjs.__name((children, container, key = null) => {
|
|
1790
|
+
listenToAllEventSupported(container);
|
|
1791
|
+
return {
|
|
1792
|
+
$$typeof: shared.RECTIFY_PORTAL_TYPE,
|
|
1793
|
+
type: null,
|
|
1794
|
+
key,
|
|
1795
|
+
props: {
|
|
1796
|
+
children,
|
|
1797
|
+
containerInfo: container
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
}, "createPortal");
|
|
1771
1801
|
|
|
1772
1802
|
// src/RectifyMemo.ts
|
|
1773
1803
|
function memo(Component2, compare) {
|
|
@@ -1856,6 +1886,7 @@ exports.Component = Component;
|
|
|
1856
1886
|
exports.Suspense = Suspense;
|
|
1857
1887
|
exports.SyntheticEvent = SyntheticEvent_default;
|
|
1858
1888
|
exports.createContext = createContext;
|
|
1889
|
+
exports.createPortal = createPortal;
|
|
1859
1890
|
exports.createRoot = createRoot;
|
|
1860
1891
|
exports.lazy = lazy;
|
|
1861
1892
|
exports.memo = memo;
|