Initial project import
This commit is contained in:
2
node_modules/its-fine/dist/index.cjs
generated
vendored
Normal file
2
node_modules/its-fine/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react");function y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const o=y(m),f=(()=>{var e,t;return typeof window!="undefined"&&(((e=window.document)==null?void 0:e.createElement)||((t=window.navigator)==null?void 0:t.product)==="ReactNative")})()?o.useLayoutEffect:o.useEffect;function i(e,t,n){if(!e)return;if(n(e)===!0)return e;let r=t?e.return:e.child;for(;r;){const u=i(r,t,n);if(u)return u;r=t?null:r.sibling}}function l(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch(t){return e}}const a=l(o.createContext(null));class d extends o.Component{render(){return o.createElement(a.Provider,{value:this._reactInternals},this.props.children)}}function s(){const e=o.useContext(a);if(e===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const t=o.useId();return o.useMemo(()=>{for(const r of[e,e==null?void 0:e.alternate]){if(!r)continue;const u=i(r,!1,p=>{let c=p.memoizedState;for(;c;){if(c.memoizedState===t)return!0;c=c.next}});if(u)return u}},[e,t])}function h(){const e=s(),t=o.useMemo(()=>i(e,!0,n=>{var r;return((r=n.stateNode)==null?void 0:r.containerInfo)!=null}),[e]);return t==null?void 0:t.stateNode.containerInfo}function v(e){const t=s(),n=o.useRef(void 0);return f(()=>{var r;n.current=(r=i(t,!1,u=>typeof u.type=="string"&&(e===void 0||u.type===e)))==null?void 0:r.stateNode},[t]),n}function C(e){const t=s(),n=o.useRef(void 0);return f(()=>{var r;n.current=(r=i(t,!0,u=>typeof u.type=="string"&&(e===void 0||u.type===e)))==null?void 0:r.stateNode},[t]),n}const w=Symbol.for("react.context"),g=e=>e!==null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===w;function b(){const e=s(),[t]=o.useState(()=>new Map);t.clear();let n=e;for(;n;){const r=n.type;g(r)&&r!==a&&!t.has(r)&&t.set(r,o.use(l(r))),n=n.return}return t}function x(){const e=b();return o.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>r=>o.createElement(t,null,o.createElement(n.Provider,{...r,value:e.get(n)})),t=>o.createElement(d,{...t})),[e])}exports.FiberProvider=d;exports.traverseFiber=i;exports.useContainer=h;exports.useContextBridge=x;exports.useContextMap=b;exports.useFiber=s;exports.useNearestChild=v;exports.useNearestParent=C;
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
1
node_modules/its-fine/dist/index.cjs.map
generated
vendored
Normal file
1
node_modules/its-fine/dist/index.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
82
node_modules/its-fine/dist/index.d.ts
generated
vendored
Normal file
82
node_modules/its-fine/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import * as React from 'react';
|
||||
import type ReactReconciler from 'react-reconciler';
|
||||
/**
|
||||
* Represents a react-internal Fiber node.
|
||||
*/
|
||||
export type Fiber<T = any> = Omit<ReactReconciler.Fiber, 'stateNode'> & {
|
||||
stateNode: T;
|
||||
};
|
||||
/**
|
||||
* Represents a {@link Fiber} node selector for traversal.
|
||||
*/
|
||||
export type FiberSelector<T = any> = (
|
||||
/** The current {@link Fiber} node. */
|
||||
node: Fiber<T | null>) => boolean | void;
|
||||
/**
|
||||
* Traverses up or down a {@link Fiber}, return `true` to stop and select a node.
|
||||
*/
|
||||
export declare function traverseFiber<T = any>(
|
||||
/** Input {@link Fiber} to traverse. */
|
||||
fiber: Fiber | undefined,
|
||||
/** Whether to ascend and walk up the tree. Will walk down if `false`. */
|
||||
ascending: boolean,
|
||||
/** A {@link Fiber} node selector, returns the first match when `true` is passed. */
|
||||
selector: FiberSelector<T>): Fiber<T> | undefined;
|
||||
/**
|
||||
* A react-internal {@link Fiber} provider. This component binds React children to the React Fiber tree. Call its-fine hooks within this.
|
||||
*/
|
||||
export declare class FiberProvider extends React.Component<{
|
||||
children?: React.ReactNode;
|
||||
}> {
|
||||
private _reactInternals;
|
||||
render(): React.JSX.Element;
|
||||
}
|
||||
/**
|
||||
* Returns the current react-internal {@link Fiber}. This is an implementation detail of [react-reconciler](https://github.com/facebook/react/tree/main/packages/react-reconciler).
|
||||
*/
|
||||
export declare function useFiber(): Fiber<null> | undefined;
|
||||
/**
|
||||
* Represents a react-reconciler container instance.
|
||||
*/
|
||||
export interface ContainerInstance<T = any> {
|
||||
containerInfo: T;
|
||||
}
|
||||
/**
|
||||
* Returns the current react-reconciler container info passed to {@link ReactReconciler.Reconciler.createContainer}.
|
||||
*
|
||||
* In react-dom, a container will point to the root DOM element; in react-three-fiber, it will point to the root Zustand store.
|
||||
*/
|
||||
export declare function useContainer<T = any>(): T | undefined;
|
||||
/**
|
||||
* Returns the nearest react-reconciler child instance or the node created from {@link ReactReconciler.HostConfig.createInstance}.
|
||||
*
|
||||
* In react-dom, this would be a DOM element; in react-three-fiber this would be an instance descriptor.
|
||||
*/
|
||||
export declare function useNearestChild<T = any>(
|
||||
/** An optional element type to filter to. */
|
||||
type?: keyof React.JSX.IntrinsicElements): React.RefObject<T | undefined>;
|
||||
/**
|
||||
* Returns the nearest react-reconciler parent instance or the node created from {@link ReactReconciler.HostConfig.createInstance}.
|
||||
*
|
||||
* In react-dom, this would be a DOM element; in react-three-fiber this would be an instance descriptor.
|
||||
*/
|
||||
export declare function useNearestParent<T = any>(
|
||||
/** An optional element type to filter to. */
|
||||
type?: keyof React.JSX.IntrinsicElements): React.RefObject<T | undefined>;
|
||||
export type ContextMap = Map<React.Context<any>, any> & {
|
||||
get<T>(context: React.Context<T>): T | undefined;
|
||||
};
|
||||
/**
|
||||
* Returns a map of all contexts and their values.
|
||||
*/
|
||||
export declare function useContextMap(): ContextMap;
|
||||
/**
|
||||
* Represents a react-context bridge provider component.
|
||||
*/
|
||||
export type ContextBridge = React.FC<React.PropsWithChildren<{}>>;
|
||||
/**
|
||||
* React Context currently cannot be shared across [React renderers](https://reactjs.org/docs/codebase-overview.html#renderers) but explicitly forwarded between providers (see [react#17275](https://github.com/facebook/react/issues/17275)). This hook returns a {@link ContextBridge} of live context providers to pierce Context across renderers.
|
||||
*
|
||||
* Pass {@link ContextBridge} as a component to a secondary renderer to enable context-sharing within its children.
|
||||
*/
|
||||
export declare function useContextBridge(): ContextBridge;
|
||||
125
node_modules/its-fine/dist/index.js
generated
vendored
Normal file
125
node_modules/its-fine/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
import * as o from "react";
|
||||
const f = /* @__PURE__ */ (() => {
|
||||
var e, t;
|
||||
return typeof window != "undefined" && (((e = window.document) == null ? void 0 : e.createElement) || ((t = window.navigator) == null ? void 0 : t.product) === "ReactNative");
|
||||
})() ? o.useLayoutEffect : o.useEffect;
|
||||
function i(e, t, r) {
|
||||
if (!e) return;
|
||||
if (r(e) === !0) return e;
|
||||
let n = t ? e.return : e.child;
|
||||
for (; n; ) {
|
||||
const u = i(n, t, r);
|
||||
if (u) return u;
|
||||
n = t ? null : n.sibling;
|
||||
}
|
||||
}
|
||||
function l(e) {
|
||||
try {
|
||||
return Object.defineProperties(e, {
|
||||
_currentRenderer: {
|
||||
get() {
|
||||
return null;
|
||||
},
|
||||
set() {
|
||||
}
|
||||
},
|
||||
_currentRenderer2: {
|
||||
get() {
|
||||
return null;
|
||||
},
|
||||
set() {
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (t) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
const a = /* @__PURE__ */ l(/* @__PURE__ */ o.createContext(null));
|
||||
class m extends o.Component {
|
||||
render() {
|
||||
return /* @__PURE__ */ o.createElement(a.Provider, { value: this._reactInternals }, this.props.children);
|
||||
}
|
||||
}
|
||||
function c() {
|
||||
const e = o.useContext(a);
|
||||
if (e === null) throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");
|
||||
const t = o.useId();
|
||||
return o.useMemo(() => {
|
||||
for (const n of [e, e == null ? void 0 : e.alternate]) {
|
||||
if (!n) continue;
|
||||
const u = i(n, !1, (d) => {
|
||||
let s = d.memoizedState;
|
||||
for (; s; ) {
|
||||
if (s.memoizedState === t) return !0;
|
||||
s = s.next;
|
||||
}
|
||||
});
|
||||
if (u) return u;
|
||||
}
|
||||
}, [e, t]);
|
||||
}
|
||||
function w() {
|
||||
const e = c(), t = o.useMemo(
|
||||
() => i(e, !0, (r) => {
|
||||
var n;
|
||||
return ((n = r.stateNode) == null ? void 0 : n.containerInfo) != null;
|
||||
}),
|
||||
[e]
|
||||
);
|
||||
return t == null ? void 0 : t.stateNode.containerInfo;
|
||||
}
|
||||
function v(e) {
|
||||
const t = c(), r = o.useRef(void 0);
|
||||
return f(() => {
|
||||
var n;
|
||||
r.current = (n = i(
|
||||
t,
|
||||
!1,
|
||||
(u) => typeof u.type == "string" && (e === void 0 || u.type === e)
|
||||
)) == null ? void 0 : n.stateNode;
|
||||
}, [t]), r;
|
||||
}
|
||||
function y(e) {
|
||||
const t = c(), r = o.useRef(void 0);
|
||||
return f(() => {
|
||||
var n;
|
||||
r.current = (n = i(
|
||||
t,
|
||||
!0,
|
||||
(u) => typeof u.type == "string" && (e === void 0 || u.type === e)
|
||||
)) == null ? void 0 : n.stateNode;
|
||||
}, [t]), r;
|
||||
}
|
||||
const p = Symbol.for("react.context"), b = (e) => e !== null && typeof e == "object" && "$$typeof" in e && e.$$typeof === p;
|
||||
function h() {
|
||||
const e = c(), [t] = o.useState(() => /* @__PURE__ */ new Map());
|
||||
t.clear();
|
||||
let r = e;
|
||||
for (; r; ) {
|
||||
const n = r.type;
|
||||
b(n) && n !== a && !t.has(n) && t.set(n, o.use(l(n))), r = r.return;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
function x() {
|
||||
const e = h();
|
||||
return o.useMemo(
|
||||
() => Array.from(e.keys()).reduce(
|
||||
(t, r) => (n) => /* @__PURE__ */ o.createElement(t, null, /* @__PURE__ */ o.createElement(r.Provider, { ...n, value: e.get(r) })),
|
||||
(t) => /* @__PURE__ */ o.createElement(m, { ...t })
|
||||
),
|
||||
[e]
|
||||
);
|
||||
}
|
||||
export {
|
||||
m as FiberProvider,
|
||||
i as traverseFiber,
|
||||
w as useContainer,
|
||||
x as useContextBridge,
|
||||
h as useContextMap,
|
||||
c as useFiber,
|
||||
v as useNearestChild,
|
||||
y as useNearestParent
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/its-fine/dist/index.js.map
generated
vendored
Normal file
1
node_modules/its-fine/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user