devstar插件
This commit is contained in:
13
node_modules/preact/compat/client.d.ts
generated
vendored
Normal file
13
node_modules/preact/compat/client.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Intentionally not using a relative path to take advantage of
|
||||
// the TS version resolution mechanism
|
||||
import * as preact from 'preact';
|
||||
|
||||
export function createRoot(container: preact.ContainerNode): {
|
||||
render(children: preact.ComponentChild): void;
|
||||
unmount(): void;
|
||||
};
|
||||
|
||||
export function hydrateRoot(
|
||||
container: preact.ContainerNode,
|
||||
children: preact.ComponentChild
|
||||
): ReturnType<typeof createRoot>;
|
21
node_modules/preact/compat/client.js
generated
vendored
Normal file
21
node_modules/preact/compat/client.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
const { render, hydrate, unmountComponentAtNode } = require('preact/compat');
|
||||
|
||||
function createRoot(container) {
|
||||
return {
|
||||
// eslint-disable-next-line
|
||||
render: function (children) {
|
||||
render(children, container);
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
unmount: function () {
|
||||
unmountComponentAtNode(container);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.createRoot = createRoot;
|
||||
|
||||
exports.hydrateRoot = function (container, children) {
|
||||
hydrate(children, container);
|
||||
return createRoot(container);
|
||||
};
|
24
node_modules/preact/compat/client.mjs
generated
vendored
Normal file
24
node_modules/preact/compat/client.mjs
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { render, hydrate, unmountComponentAtNode } from 'preact/compat';
|
||||
|
||||
export function createRoot(container) {
|
||||
return {
|
||||
// eslint-disable-next-line
|
||||
render: function (children) {
|
||||
render(children, container);
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
unmount: function () {
|
||||
unmountComponentAtNode(container);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function hydrateRoot(container, children) {
|
||||
hydrate(children, container);
|
||||
return createRoot(container);
|
||||
}
|
||||
|
||||
export default {
|
||||
createRoot,
|
||||
hydrateRoot
|
||||
};
|
2
node_modules/preact/compat/dist/compat.js
generated
vendored
Normal file
2
node_modules/preact/compat/dist/compat.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/preact/compat/dist/compat.js.map
generated
vendored
Normal file
1
node_modules/preact/compat/dist/compat.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/preact/compat/dist/compat.mjs
generated
vendored
Normal file
2
node_modules/preact/compat/dist/compat.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/preact/compat/dist/compat.module.js
generated
vendored
Normal file
2
node_modules/preact/compat/dist/compat.module.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/preact/compat/dist/compat.module.js.map
generated
vendored
Normal file
1
node_modules/preact/compat/dist/compat.module.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/preact/compat/dist/compat.umd.js
generated
vendored
Normal file
2
node_modules/preact/compat/dist/compat.umd.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/preact/compat/dist/compat.umd.js.map
generated
vendored
Normal file
1
node_modules/preact/compat/dist/compat.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/preact/compat/jsx-dev-runtime.js
generated
vendored
Normal file
3
node_modules/preact/compat/jsx-dev-runtime.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
require('preact/compat');
|
||||
|
||||
module.exports = require('preact/jsx-runtime');
|
3
node_modules/preact/compat/jsx-dev-runtime.mjs
generated
vendored
Normal file
3
node_modules/preact/compat/jsx-dev-runtime.mjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import 'preact/compat';
|
||||
|
||||
export * from 'preact/jsx-runtime';
|
3
node_modules/preact/compat/jsx-runtime.js
generated
vendored
Normal file
3
node_modules/preact/compat/jsx-runtime.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
require('preact/compat');
|
||||
|
||||
module.exports = require('preact/jsx-runtime');
|
3
node_modules/preact/compat/jsx-runtime.mjs
generated
vendored
Normal file
3
node_modules/preact/compat/jsx-runtime.mjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import 'preact/compat';
|
||||
|
||||
export * from 'preact/jsx-runtime';
|
55
node_modules/preact/compat/package.json
generated
vendored
Normal file
55
node_modules/preact/compat/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "preact-compat",
|
||||
"amdName": "preactCompat",
|
||||
"version": "4.0.0",
|
||||
"private": true,
|
||||
"description": "A React compatibility layer for Preact",
|
||||
"main": "dist/compat.js",
|
||||
"module": "dist/compat.module.js",
|
||||
"umd:main": "dist/compat.umd.js",
|
||||
"source": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
"license": "MIT",
|
||||
"mangle": {
|
||||
"regex": "^_"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"preact": "^10.0.0"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.d.ts",
|
||||
"browser": "./dist/compat.module.js",
|
||||
"umd": "./dist/compat.umd.js",
|
||||
"import": "./dist/compat.mjs",
|
||||
"require": "./dist/compat.js"
|
||||
},
|
||||
"./client": {
|
||||
"types": "./client.d.ts",
|
||||
"import": "./client.mjs",
|
||||
"require": "./client.js"
|
||||
},
|
||||
"./server": {
|
||||
"browser": "./server.browser.js",
|
||||
"import": "./server.mjs",
|
||||
"require": "./server.js"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
"import": "./jsx-runtime.mjs",
|
||||
"require": "./jsx-runtime.js"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
"import": "./jsx-dev-runtime.mjs",
|
||||
"require": "./jsx-dev-runtime.js"
|
||||
},
|
||||
"./scheduler": {
|
||||
"import": "./scheduler.mjs",
|
||||
"require": "./scheduler.js"
|
||||
},
|
||||
"./test-utils": {
|
||||
"import": "./test-utils.mjs",
|
||||
"require": "./test-utils.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
}
|
||||
}
|
15
node_modules/preact/compat/scheduler.js
generated
vendored
Normal file
15
node_modules/preact/compat/scheduler.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// see scheduler.mjs
|
||||
|
||||
function unstable_runWithPriority(priority, callback) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
unstable_ImmediatePriority: 1,
|
||||
unstable_UserBlockingPriority: 2,
|
||||
unstable_NormalPriority: 3,
|
||||
unstable_LowPriority: 4,
|
||||
unstable_IdlePriority: 5,
|
||||
unstable_runWithPriority,
|
||||
unstable_now: performance.now.bind(performance)
|
||||
};
|
23
node_modules/preact/compat/scheduler.mjs
generated
vendored
Normal file
23
node_modules/preact/compat/scheduler.mjs
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/* eslint-disable */
|
||||
|
||||
// This file includes experimental React APIs exported from the "scheduler"
|
||||
// npm package. Despite being explicitely marked as unstable some libraries
|
||||
// already make use of them. This file is not a full replacement for the
|
||||
// scheduler package, but includes the necessary shims to make those libraries
|
||||
// work with Preact.
|
||||
|
||||
export var unstable_ImmediatePriority = 1;
|
||||
export var unstable_UserBlockingPriority = 2;
|
||||
export var unstable_NormalPriority = 3;
|
||||
export var unstable_LowPriority = 4;
|
||||
export var unstable_IdlePriority = 5;
|
||||
|
||||
/**
|
||||
* @param {number} priority
|
||||
* @param {() => void} callback
|
||||
*/
|
||||
export function unstable_runWithPriority(priority, callback) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
export var unstable_now = performance.now.bind(performance);
|
11
node_modules/preact/compat/server.browser.js
generated
vendored
Normal file
11
node_modules/preact/compat/server.browser.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import { renderToString } from 'preact-render-to-string';
|
||||
|
||||
export {
|
||||
renderToString,
|
||||
renderToString as renderToStaticMarkup
|
||||
} from 'preact-render-to-string';
|
||||
|
||||
export default {
|
||||
renderToString,
|
||||
renderToStaticMarkup: renderToString
|
||||
};
|
36
node_modules/preact/compat/server.js
generated
vendored
Normal file
36
node_modules/preact/compat/server.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/* eslint-disable */
|
||||
var renderToString;
|
||||
try {
|
||||
const mod = require('preact-render-to-string');
|
||||
renderToString = mod.default || mod.renderToString || mod;
|
||||
} catch (e) {
|
||||
throw Error(
|
||||
'renderToString() error: missing "preact-render-to-string" dependency.'
|
||||
);
|
||||
}
|
||||
|
||||
var renderToReadableStream;
|
||||
try {
|
||||
const mod = require('preact-render-to-string/stream');
|
||||
renderToReadableStream = mod.default || mod.renderToReadableStream || mod;
|
||||
} catch (e) {
|
||||
throw Error(
|
||||
'renderToReadableStream() error: update "preact-render-to-string" dependency to at least 6.5.0.'
|
||||
);
|
||||
}
|
||||
var renderToPipeableStream;
|
||||
try {
|
||||
const mod = require('preact-render-to-string/stream-node');
|
||||
renderToPipeableStream = mod.default || mod.renderToPipeableStream || mod;
|
||||
} catch (e) {
|
||||
throw Error(
|
||||
'renderToPipeableStream() error: update "preact-render-to-string" dependency to at least 6.5.0.'
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
renderToString: renderToString,
|
||||
renderToStaticMarkup: renderToString,
|
||||
renderToPipeableStream: renderToPipeableStream,
|
||||
renderToReadableStream: renderToReadableStream
|
||||
};
|
17
node_modules/preact/compat/server.mjs
generated
vendored
Normal file
17
node_modules/preact/compat/server.mjs
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { renderToString } from 'preact-render-to-string';
|
||||
import { renderToPipeableStream } from 'preact-render-to-string/stream-node';
|
||||
import { renderToReadableStream } from 'preact-render-to-string/stream';
|
||||
|
||||
export {
|
||||
renderToString,
|
||||
renderToString as renderToStaticMarkup
|
||||
} from 'preact-render-to-string';
|
||||
|
||||
export { renderToPipeableStream } from 'preact-render-to-string/stream-node';
|
||||
export { renderToReadableStream } from 'preact-render-to-string/stream';
|
||||
export default {
|
||||
renderToString,
|
||||
renderToStaticMarkup: renderToString,
|
||||
renderToPipeableStream,
|
||||
renderToReadableStream
|
||||
};
|
21
node_modules/preact/compat/src/Children.js
generated
vendored
Normal file
21
node_modules/preact/compat/src/Children.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { toChildArray } from 'preact';
|
||||
|
||||
const mapFn = (children, fn) => {
|
||||
if (children == null) return null;
|
||||
return toChildArray(toChildArray(children).map(fn));
|
||||
};
|
||||
|
||||
// This API is completely unnecessary for Preact, so it's basically passthrough.
|
||||
export const Children = {
|
||||
map: mapFn,
|
||||
forEach: mapFn,
|
||||
count(children) {
|
||||
return children ? toChildArray(children).length : 0;
|
||||
},
|
||||
only(children) {
|
||||
const normalized = toChildArray(children);
|
||||
if (normalized.length !== 1) throw 'Children.only';
|
||||
return normalized[0];
|
||||
},
|
||||
toArray: toChildArray
|
||||
};
|
16
node_modules/preact/compat/src/PureComponent.js
generated
vendored
Normal file
16
node_modules/preact/compat/src/PureComponent.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Component } from 'preact';
|
||||
import { shallowDiffers } from './util';
|
||||
|
||||
/**
|
||||
* Component class with a predefined `shouldComponentUpdate` implementation
|
||||
*/
|
||||
export function PureComponent(p, c) {
|
||||
this.props = p;
|
||||
this.context = c;
|
||||
}
|
||||
PureComponent.prototype = new Component();
|
||||
// Some third-party libraries check if this property is present
|
||||
PureComponent.prototype.isPureReactComponent = true;
|
||||
PureComponent.prototype.shouldComponentUpdate = function (props, state) {
|
||||
return shallowDiffers(this.props, props) || shallowDiffers(this.state, state);
|
||||
};
|
44
node_modules/preact/compat/src/forwardRef.js
generated
vendored
Normal file
44
node_modules/preact/compat/src/forwardRef.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import { options } from 'preact';
|
||||
import { assign } from './util';
|
||||
|
||||
let oldDiffHook = options._diff;
|
||||
options._diff = vnode => {
|
||||
if (vnode.type && vnode.type._forwarded && vnode.ref) {
|
||||
vnode.props.ref = vnode.ref;
|
||||
vnode.ref = null;
|
||||
}
|
||||
if (oldDiffHook) oldDiffHook(vnode);
|
||||
};
|
||||
|
||||
export const REACT_FORWARD_SYMBOL =
|
||||
(typeof Symbol != 'undefined' &&
|
||||
Symbol.for &&
|
||||
Symbol.for('react.forward_ref')) ||
|
||||
0xf47;
|
||||
|
||||
/**
|
||||
* Pass ref down to a child. This is mainly used in libraries with HOCs that
|
||||
* wrap components. Using `forwardRef` there is an easy way to get a reference
|
||||
* of the wrapped component instead of one of the wrapper itself.
|
||||
* @param {import('./index').ForwardFn} fn
|
||||
* @returns {import('./internal').FunctionComponent}
|
||||
*/
|
||||
export function forwardRef(fn) {
|
||||
function Forwarded(props) {
|
||||
let clone = assign({}, props);
|
||||
delete clone.ref;
|
||||
return fn(clone, props.ref || null);
|
||||
}
|
||||
|
||||
// mobx-react checks for this being present
|
||||
Forwarded.$$typeof = REACT_FORWARD_SYMBOL;
|
||||
// mobx-react heavily relies on implementation details.
|
||||
// It expects an object here with a `render` property,
|
||||
// and prototype.render will fail. Without this
|
||||
// mobx-react throws.
|
||||
Forwarded.render = Forwarded;
|
||||
|
||||
Forwarded.prototype.isReactComponent = Forwarded._forwarded = true;
|
||||
Forwarded.displayName = 'ForwardRef(' + (fn.displayName || fn.name) + ')';
|
||||
return Forwarded;
|
||||
}
|
70
node_modules/preact/compat/src/hooks.js
generated
vendored
Normal file
70
node_modules/preact/compat/src/hooks.js
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import { useState, useLayoutEffect, useEffect } from 'preact/hooks';
|
||||
import { is } from './util';
|
||||
|
||||
/**
|
||||
* This is taken from https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L84
|
||||
* on a high level this cuts out the warnings, ... and attempts a smaller implementation
|
||||
* @typedef {{ _value: any; _getSnapshot: () => any }} Store
|
||||
*/
|
||||
export function useSyncExternalStore(subscribe, getSnapshot) {
|
||||
const value = getSnapshot();
|
||||
|
||||
/**
|
||||
* @typedef {{ _instance: Store }} StoreRef
|
||||
* @type {[StoreRef, (store: StoreRef) => void]}
|
||||
*/
|
||||
const [{ _instance }, forceUpdate] = useState({
|
||||
_instance: { _value: value, _getSnapshot: getSnapshot }
|
||||
});
|
||||
|
||||
useLayoutEffect(() => {
|
||||
_instance._value = value;
|
||||
_instance._getSnapshot = getSnapshot;
|
||||
|
||||
if (didSnapshotChange(_instance)) {
|
||||
forceUpdate({ _instance });
|
||||
}
|
||||
}, [subscribe, value, getSnapshot]);
|
||||
|
||||
useEffect(() => {
|
||||
if (didSnapshotChange(_instance)) {
|
||||
forceUpdate({ _instance });
|
||||
}
|
||||
|
||||
return subscribe(() => {
|
||||
if (didSnapshotChange(_instance)) {
|
||||
forceUpdate({ _instance });
|
||||
}
|
||||
});
|
||||
}, [subscribe]);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/** @type {(inst: Store) => boolean} */
|
||||
function didSnapshotChange(inst) {
|
||||
const latestGetSnapshot = inst._getSnapshot;
|
||||
const prevValue = inst._value;
|
||||
try {
|
||||
const nextValue = latestGetSnapshot();
|
||||
return !is(prevValue, nextValue);
|
||||
} catch (error) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export function startTransition(cb) {
|
||||
cb();
|
||||
}
|
||||
|
||||
export function useDeferredValue(val) {
|
||||
return val;
|
||||
}
|
||||
|
||||
export function useTransition() {
|
||||
return [false, startTransition];
|
||||
}
|
||||
|
||||
// TODO: in theory this should be done after a VNode is diffed as we want to insert
|
||||
// styles/... before it attaches
|
||||
export const useInsertionEffect = useLayoutEffect;
|
349
node_modules/preact/compat/src/index.d.ts
generated
vendored
Normal file
349
node_modules/preact/compat/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,349 @@
|
||||
import * as _hooks from '../../hooks';
|
||||
// Intentionally not using a relative path to take advantage of
|
||||
// the TS version resolution mechanism
|
||||
import * as preact from 'preact';
|
||||
import { JSXInternal } from '../../src/jsx';
|
||||
import * as _Suspense from './suspense';
|
||||
import * as _SuspenseList from './suspense-list';
|
||||
|
||||
// export default React;
|
||||
export = React;
|
||||
export as namespace React;
|
||||
declare namespace React {
|
||||
// Export JSX
|
||||
export import JSX = JSXInternal;
|
||||
|
||||
// Hooks
|
||||
export import CreateHandle = _hooks.CreateHandle;
|
||||
export import EffectCallback = _hooks.EffectCallback;
|
||||
export import Inputs = _hooks.Inputs;
|
||||
export import PropRef = _hooks.PropRef;
|
||||
export import Reducer = _hooks.Reducer;
|
||||
export import Dispatch = _hooks.Dispatch;
|
||||
export import SetStateAction = _hooks.StateUpdater;
|
||||
export import useCallback = _hooks.useCallback;
|
||||
export import useContext = _hooks.useContext;
|
||||
export import useDebugValue = _hooks.useDebugValue;
|
||||
export import useEffect = _hooks.useEffect;
|
||||
export import useImperativeHandle = _hooks.useImperativeHandle;
|
||||
export import useId = _hooks.useId;
|
||||
export import useLayoutEffect = _hooks.useLayoutEffect;
|
||||
export import useMemo = _hooks.useMemo;
|
||||
export import useReducer = _hooks.useReducer;
|
||||
export import useRef = _hooks.useRef;
|
||||
export import useState = _hooks.useState;
|
||||
// React 18 hooks
|
||||
export import useInsertionEffect = _hooks.useLayoutEffect;
|
||||
export function useTransition(): [false, typeof startTransition];
|
||||
export function useDeferredValue<T = any>(val: T): T;
|
||||
export function useSyncExternalStore<T>(
|
||||
subscribe: (flush: () => void) => () => void,
|
||||
getSnapshot: () => T
|
||||
): T;
|
||||
|
||||
// Preact Defaults
|
||||
export import Context = preact.Context;
|
||||
export import ContextType = preact.ContextType;
|
||||
export import RefObject = preact.RefObject;
|
||||
export import Component = preact.Component;
|
||||
export import FunctionComponent = preact.FunctionComponent;
|
||||
export import ComponentType = preact.ComponentType;
|
||||
export import ComponentClass = preact.ComponentClass;
|
||||
export import FC = preact.FunctionComponent;
|
||||
export import createContext = preact.createContext;
|
||||
export import Ref = preact.Ref;
|
||||
export import createRef = preact.createRef;
|
||||
export import Fragment = preact.Fragment;
|
||||
export import createElement = preact.createElement;
|
||||
export import cloneElement = preact.cloneElement;
|
||||
export import ComponentProps = preact.ComponentProps;
|
||||
export import ReactNode = preact.ComponentChild;
|
||||
export import ReactElement = preact.VNode;
|
||||
export import Consumer = preact.Consumer;
|
||||
export import ErrorInfo = preact.ErrorInfo;
|
||||
|
||||
// Suspense
|
||||
export import Suspense = _Suspense.Suspense;
|
||||
export import lazy = _Suspense.lazy;
|
||||
export import SuspenseList = _SuspenseList.SuspenseList;
|
||||
|
||||
// Compat
|
||||
export import StrictMode = preact.Fragment;
|
||||
export const version: string;
|
||||
export function startTransition(cb: () => void): void;
|
||||
|
||||
// HTML
|
||||
export interface HTMLAttributes<T extends EventTarget>
|
||||
extends JSXInternal.HTMLAttributes<T> {}
|
||||
export interface HTMLProps<T extends EventTarget>
|
||||
extends JSXInternal.AllHTMLAttributes<T>,
|
||||
preact.ClassAttributes<T> {}
|
||||
export interface AllHTMLAttributes<T extends EventTarget>
|
||||
extends JSXInternal.AllHTMLAttributes<T> {}
|
||||
export import DetailedHTMLProps = JSXInternal.DetailedHTMLProps;
|
||||
export import CSSProperties = JSXInternal.CSSProperties;
|
||||
|
||||
export interface SVGProps<T extends EventTarget>
|
||||
extends JSXInternal.SVGAttributes<T>,
|
||||
preact.ClassAttributes<T> {}
|
||||
|
||||
interface SVGAttributes extends JSXInternal.SVGAttributes {}
|
||||
|
||||
interface ReactSVG extends JSXInternal.IntrinsicSVGElements {}
|
||||
|
||||
export import AriaAttributes = JSXInternal.AriaAttributes;
|
||||
|
||||
export import HTMLAttributeReferrerPolicy = JSXInternal.HTMLAttributeReferrerPolicy;
|
||||
export import HTMLAttributeAnchorTarget = JSXInternal.HTMLAttributeAnchorTarget;
|
||||
export import HTMLInputTypeAttribute = JSXInternal.HTMLInputTypeAttribute;
|
||||
export import HTMLAttributeCrossOrigin = JSXInternal.HTMLAttributeCrossOrigin;
|
||||
|
||||
export import AnchorHTMLAttributes = JSXInternal.AnchorHTMLAttributes;
|
||||
export import AudioHTMLAttributes = JSXInternal.AudioHTMLAttributes;
|
||||
export import AreaHTMLAttributes = JSXInternal.AreaHTMLAttributes;
|
||||
export import BaseHTMLAttributes = JSXInternal.BaseHTMLAttributes;
|
||||
export import BlockquoteHTMLAttributes = JSXInternal.BlockquoteHTMLAttributes;
|
||||
export import ButtonHTMLAttributes = JSXInternal.ButtonHTMLAttributes;
|
||||
export import CanvasHTMLAttributes = JSXInternal.CanvasHTMLAttributes;
|
||||
export import ColHTMLAttributes = JSXInternal.ColHTMLAttributes;
|
||||
export import ColgroupHTMLAttributes = JSXInternal.ColgroupHTMLAttributes;
|
||||
export import DataHTMLAttributes = JSXInternal.DataHTMLAttributes;
|
||||
export import DetailsHTMLAttributes = JSXInternal.DetailsHTMLAttributes;
|
||||
export import DelHTMLAttributes = JSXInternal.DelHTMLAttributes;
|
||||
export import DialogHTMLAttributes = JSXInternal.DialogHTMLAttributes;
|
||||
export import EmbedHTMLAttributes = JSXInternal.EmbedHTMLAttributes;
|
||||
export import FieldsetHTMLAttributes = JSXInternal.FieldsetHTMLAttributes;
|
||||
export import FormHTMLAttributes = JSXInternal.FormHTMLAttributes;
|
||||
export import IframeHTMLAttributes = JSXInternal.IframeHTMLAttributes;
|
||||
export import ImgHTMLAttributes = JSXInternal.ImgHTMLAttributes;
|
||||
export import InsHTMLAttributes = JSXInternal.InsHTMLAttributes;
|
||||
export import InputHTMLAttributes = JSXInternal.InputHTMLAttributes;
|
||||
export import KeygenHTMLAttributes = JSXInternal.KeygenHTMLAttributes;
|
||||
export import LabelHTMLAttributes = JSXInternal.LabelHTMLAttributes;
|
||||
export import LiHTMLAttributes = JSXInternal.LiHTMLAttributes;
|
||||
export import LinkHTMLAttributes = JSXInternal.LinkHTMLAttributes;
|
||||
export import MapHTMLAttributes = JSXInternal.MapHTMLAttributes;
|
||||
export import MenuHTMLAttributes = JSXInternal.MenuHTMLAttributes;
|
||||
export import MediaHTMLAttributes = JSXInternal.MediaHTMLAttributes;
|
||||
export import MetaHTMLAttributes = JSXInternal.MetaHTMLAttributes;
|
||||
export import MeterHTMLAttributes = JSXInternal.MeterHTMLAttributes;
|
||||
export import QuoteHTMLAttributes = JSXInternal.QuoteHTMLAttributes;
|
||||
export import ObjectHTMLAttributes = JSXInternal.ObjectHTMLAttributes;
|
||||
export import OlHTMLAttributes = JSXInternal.OlHTMLAttributes;
|
||||
export import OptgroupHTMLAttributes = JSXInternal.OptgroupHTMLAttributes;
|
||||
export import OptionHTMLAttributes = JSXInternal.OptionHTMLAttributes;
|
||||
export import OutputHTMLAttributes = JSXInternal.OutputHTMLAttributes;
|
||||
export import ParamHTMLAttributes = JSXInternal.ParamHTMLAttributes;
|
||||
export import ProgressHTMLAttributes = JSXInternal.ProgressHTMLAttributes;
|
||||
export import SlotHTMLAttributes = JSXInternal.SlotHTMLAttributes;
|
||||
export import ScriptHTMLAttributes = JSXInternal.ScriptHTMLAttributes;
|
||||
export import SelectHTMLAttributes = JSXInternal.SelectHTMLAttributes;
|
||||
export import SourceHTMLAttributes = JSXInternal.SourceHTMLAttributes;
|
||||
export import StyleHTMLAttributes = JSXInternal.StyleHTMLAttributes;
|
||||
export import TableHTMLAttributes = JSXInternal.TableHTMLAttributes;
|
||||
export import TextareaHTMLAttributes = JSXInternal.TextareaHTMLAttributes;
|
||||
export import TdHTMLAttributes = JSXInternal.TdHTMLAttributes;
|
||||
export import ThHTMLAttributes = JSXInternal.ThHTMLAttributes;
|
||||
export import TimeHTMLAttributes = JSXInternal.TimeHTMLAttributes;
|
||||
export import TrackHTMLAttributes = JSXInternal.TrackHTMLAttributes;
|
||||
export import VideoHTMLAttributes = JSXInternal.VideoHTMLAttributes;
|
||||
|
||||
// Events
|
||||
export import TargetedEvent = JSXInternal.TargetedEvent;
|
||||
export import ChangeEvent = JSXInternal.TargetedEvent;
|
||||
export import ClipboardEvent = JSXInternal.TargetedClipboardEvent;
|
||||
export import CompositionEvent = JSXInternal.TargetedCompositionEvent;
|
||||
export import DragEvent = JSXInternal.TargetedDragEvent;
|
||||
export import PointerEvent = JSXInternal.TargetedPointerEvent;
|
||||
export import FocusEvent = JSXInternal.TargetedFocusEvent;
|
||||
export import FormEvent = JSXInternal.TargetedEvent;
|
||||
export import InvalidEvent = JSXInternal.TargetedEvent;
|
||||
export import KeyboardEvent = JSXInternal.TargetedKeyboardEvent;
|
||||
export import MouseEvent = JSXInternal.TargetedMouseEvent;
|
||||
export import TouchEvent = JSXInternal.TargetedTouchEvent;
|
||||
export import UIEvent = JSXInternal.TargetedUIEvent;
|
||||
export import AnimationEvent = JSXInternal.TargetedAnimationEvent;
|
||||
export import TransitionEvent = JSXInternal.TargetedTransitionEvent;
|
||||
|
||||
// Event Handler Types
|
||||
export import EventHandler = JSXInternal.EventHandler;
|
||||
export import ChangeEventHandler = JSXInternal.GenericEventHandler;
|
||||
export import ClipboardEventHandler = JSXInternal.ClipboardEventHandler;
|
||||
export import CompositionEventHandler = JSXInternal.CompositionEventHandler;
|
||||
export import DragEventHandler = JSXInternal.DragEventHandler;
|
||||
export import PointerEventHandler = JSXInternal.PointerEventHandler;
|
||||
export import FocusEventHandler = JSXInternal.FocusEventHandler;
|
||||
export import FormEventHandler = JSXInternal.GenericEventHandler;
|
||||
export import InvalidEventHandler = JSXInternal.GenericEventHandler;
|
||||
export import KeyboardEventHandler = JSXInternal.KeyboardEventHandler;
|
||||
export import MouseEventHandler = JSXInternal.MouseEventHandler;
|
||||
export import TouchEventHandler = JSXInternal.TouchEventHandler;
|
||||
export import UIEventHandler = JSXInternal.UIEventHandler;
|
||||
export import AnimationEventHandler = JSXInternal.AnimationEventHandler;
|
||||
export import TransitionEventHandler = JSXInternal.TransitionEventHandler;
|
||||
|
||||
export function createPortal(
|
||||
vnode: preact.ComponentChildren,
|
||||
container: preact.ContainerNode
|
||||
): preact.VNode<any>;
|
||||
|
||||
export function render(
|
||||
vnode: preact.ComponentChild,
|
||||
parent: preact.ContainerNode,
|
||||
callback?: () => void
|
||||
): Component | null;
|
||||
|
||||
export function hydrate(
|
||||
vnode: preact.ComponentChild,
|
||||
parent: preact.ContainerNode,
|
||||
callback?: () => void
|
||||
): Component | null;
|
||||
|
||||
export function unmountComponentAtNode(
|
||||
container: preact.ContainerNode
|
||||
): boolean;
|
||||
|
||||
export function createFactory(
|
||||
type: preact.VNode<any>['type']
|
||||
): (
|
||||
props?: any,
|
||||
...children: preact.ComponentChildren[]
|
||||
) => preact.VNode<any>;
|
||||
export function isValidElement(element: any): boolean;
|
||||
export function isFragment(element: any): boolean;
|
||||
export function isMemo(element: any): boolean;
|
||||
export function findDOMNode(
|
||||
component: preact.Component | Element
|
||||
): Element | null;
|
||||
|
||||
export abstract class PureComponent<
|
||||
P = {},
|
||||
S = {},
|
||||
SS = any
|
||||
> extends preact.Component<P, S> {
|
||||
isPureReactComponent: boolean;
|
||||
}
|
||||
|
||||
export type MemoExoticComponent<C extends preact.FunctionalComponent<any>> =
|
||||
preact.FunctionComponent<ComponentProps<C>> & {
|
||||
readonly type: C;
|
||||
};
|
||||
|
||||
export function memo<P = {}>(
|
||||
component: preact.FunctionalComponent<P>,
|
||||
comparer?: (prev: P, next: P) => boolean
|
||||
): preact.FunctionComponent<P>;
|
||||
export function memo<C extends preact.FunctionalComponent<any>>(
|
||||
component: C,
|
||||
comparer?: (
|
||||
prev: preact.ComponentProps<C>,
|
||||
next: preact.ComponentProps<C>
|
||||
) => boolean
|
||||
): C;
|
||||
|
||||
export interface RefAttributes<R> extends preact.Attributes {
|
||||
ref?: preact.Ref<R> | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use `ForwardRefRenderFunction` instead.
|
||||
*/
|
||||
export interface ForwardFn<P = {}, T = any> {
|
||||
(props: P, ref: ForwardedRef<T>): preact.ComponentChild;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
export interface ForwardRefRenderFunction<T = any, P = {}> {
|
||||
(props: P, ref: ForwardedRef<T>): preact.ComponentChild;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
export interface ForwardRefExoticComponent<P>
|
||||
extends preact.FunctionComponent<P> {
|
||||
defaultProps?: Partial<P> | undefined;
|
||||
}
|
||||
|
||||
export function forwardRef<R, P = {}>(
|
||||
fn: ForwardRefRenderFunction<R, P>
|
||||
): preact.FunctionalComponent<PropsWithoutRef<P> & { ref?: preact.Ref<R> }>;
|
||||
|
||||
export type PropsWithoutRef<P> = Omit<P, 'ref'>;
|
||||
|
||||
interface MutableRefObject<T> {
|
||||
current: T;
|
||||
}
|
||||
|
||||
export type ForwardedRef<T> =
|
||||
| ((instance: T | null) => void)
|
||||
| MutableRefObject<T | null>
|
||||
| null;
|
||||
|
||||
export type ElementType<
|
||||
P = any,
|
||||
Tag extends keyof JSX.IntrinsicElements = keyof JSX.IntrinsicElements
|
||||
> =
|
||||
| { [K in Tag]: P extends JSX.IntrinsicElements[K] ? K : never }[Tag]
|
||||
| ComponentType<P>;
|
||||
|
||||
export type ComponentPropsWithoutRef<T extends ElementType> = PropsWithoutRef<
|
||||
ComponentProps<T>
|
||||
>;
|
||||
|
||||
export type ComponentPropsWithRef<C extends ElementType> = C extends new (
|
||||
props: infer P
|
||||
) => Component<any, any>
|
||||
? PropsWithoutRef<P> & RefAttributes<InstanceType<C>>
|
||||
: ComponentProps<C>;
|
||||
|
||||
export type ElementRef<
|
||||
C extends
|
||||
| ForwardRefExoticComponent<any>
|
||||
| { new (props: any): Component<any, any> }
|
||||
| ((props: any) => ReactNode)
|
||||
| keyof JSXInternal.IntrinsicElements
|
||||
> = 'ref' extends keyof ComponentPropsWithRef<C>
|
||||
? NonNullable<ComponentPropsWithRef<C>['ref']> extends RefAttributes<
|
||||
infer Instance
|
||||
>['ref']
|
||||
? Instance
|
||||
: never
|
||||
: never;
|
||||
|
||||
export function flushSync<R>(fn: () => R): R;
|
||||
export function flushSync<A, R>(fn: (a: A) => R, a: A): R;
|
||||
|
||||
export function unstable_batchedUpdates(
|
||||
callback: (arg?: any) => void,
|
||||
arg?: any
|
||||
): void;
|
||||
|
||||
export type PropsWithChildren<P = unknown> = P & {
|
||||
children?: preact.ComponentChildren | undefined;
|
||||
};
|
||||
|
||||
export const Children: {
|
||||
map<T extends preact.ComponentChild, R>(
|
||||
children: T | T[],
|
||||
fn: (child: T, i: number) => R
|
||||
): R[];
|
||||
forEach<T extends preact.ComponentChild>(
|
||||
children: T | T[],
|
||||
fn: (child: T, i: number) => void
|
||||
): void;
|
||||
count: (children: preact.ComponentChildren) => number;
|
||||
only: (children: preact.ComponentChildren) => preact.ComponentChild;
|
||||
toArray: (children: preact.ComponentChildren) => preact.VNode<{}>[];
|
||||
};
|
||||
|
||||
// scheduler
|
||||
export const unstable_ImmediatePriority: number;
|
||||
export const unstable_UserBlockingPriority: number;
|
||||
export const unstable_NormalPriority: number;
|
||||
export const unstable_LowPriority: number;
|
||||
export const unstable_IdlePriority: number;
|
||||
export function unstable_runWithPriority(
|
||||
priority: number,
|
||||
callback: () => void
|
||||
): void;
|
||||
export const unstable_now: () => number;
|
||||
}
|
238
node_modules/preact/compat/src/index.js
generated
vendored
Normal file
238
node_modules/preact/compat/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
import {
|
||||
createElement,
|
||||
render as preactRender,
|
||||
cloneElement as preactCloneElement,
|
||||
createRef,
|
||||
Component,
|
||||
createContext,
|
||||
Fragment
|
||||
} from 'preact';
|
||||
import {
|
||||
useState,
|
||||
useId,
|
||||
useReducer,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useRef,
|
||||
useImperativeHandle,
|
||||
useMemo,
|
||||
useCallback,
|
||||
useContext,
|
||||
useDebugValue
|
||||
} from 'preact/hooks';
|
||||
import {
|
||||
useInsertionEffect,
|
||||
startTransition,
|
||||
useDeferredValue,
|
||||
useSyncExternalStore,
|
||||
useTransition
|
||||
} from './hooks';
|
||||
import { PureComponent } from './PureComponent';
|
||||
import { memo } from './memo';
|
||||
import { forwardRef } from './forwardRef';
|
||||
import { Children } from './Children';
|
||||
import { Suspense, lazy } from './suspense';
|
||||
import { SuspenseList } from './suspense-list';
|
||||
import { createPortal } from './portals';
|
||||
import {
|
||||
hydrate,
|
||||
render,
|
||||
REACT_ELEMENT_TYPE,
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
||||
} from './render';
|
||||
|
||||
const version = '18.3.1'; // trick libraries to think we are react
|
||||
|
||||
/**
|
||||
* Legacy version of createElement.
|
||||
* @param {import('./internal').VNode["type"]} type The node name or Component constructor
|
||||
*/
|
||||
function createFactory(type) {
|
||||
return createElement.bind(null, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the passed element is a valid (p)react node.
|
||||
* @param {*} element The element to check
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isValidElement(element) {
|
||||
return !!element && element.$$typeof === REACT_ELEMENT_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the passed element is a Fragment node.
|
||||
* @param {*} element The element to check
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isFragment(element) {
|
||||
return isValidElement(element) && element.type === Fragment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the passed element is a Memo node.
|
||||
* @param {*} element The element to check
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isMemo(element) {
|
||||
return (
|
||||
!!element &&
|
||||
!!element.displayName &&
|
||||
(typeof element.displayName === 'string' ||
|
||||
element.displayName instanceof String) &&
|
||||
element.displayName.startsWith('Memo(')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap `cloneElement` to abort if the passed element is not a valid element and apply
|
||||
* all vnode normalizations.
|
||||
* @param {import('./internal').VNode} element The vnode to clone
|
||||
* @param {object} props Props to add when cloning
|
||||
* @param {Array<import('./internal').ComponentChildren>} rest Optional component children
|
||||
*/
|
||||
function cloneElement(element) {
|
||||
if (!isValidElement(element)) return element;
|
||||
return preactCloneElement.apply(null, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a component tree from the DOM, including state and event handlers.
|
||||
* @param {import('./internal').PreactElement} container
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function unmountComponentAtNode(container) {
|
||||
if (container._children) {
|
||||
preactRender(null, container);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the matching DOM node for a component
|
||||
* @param {import('./internal').Component} component
|
||||
* @returns {import('./internal').PreactElement | null}
|
||||
*/
|
||||
function findDOMNode(component) {
|
||||
return (
|
||||
(component &&
|
||||
(component.base || (component.nodeType === 1 && component))) ||
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated way to control batched rendering inside the reconciler, but we
|
||||
* already schedule in batches inside our rendering code
|
||||
* @template Arg
|
||||
* @param {(arg: Arg) => void} callback function that triggers the updated
|
||||
* @param {Arg} [arg] Optional argument that can be passed to the callback
|
||||
*/
|
||||
// eslint-disable-next-line camelcase
|
||||
const unstable_batchedUpdates = (callback, arg) => callback(arg);
|
||||
|
||||
/**
|
||||
* In React, `flushSync` flushes the entire tree and forces a rerender. It's
|
||||
* implmented here as a no-op.
|
||||
* @template Arg
|
||||
* @template Result
|
||||
* @param {(arg: Arg) => Result} callback function that runs before the flush
|
||||
* @param {Arg} [arg] Optional argument that can be passed to the callback
|
||||
* @returns
|
||||
*/
|
||||
const flushSync = (callback, arg) => callback(arg);
|
||||
|
||||
/**
|
||||
* Strict Mode is not implemented in Preact, so we provide a stand-in for it
|
||||
* that just renders its children without imposing any restrictions.
|
||||
*/
|
||||
const StrictMode = Fragment;
|
||||
|
||||
// compat to react-is
|
||||
export const isElement = isValidElement;
|
||||
|
||||
export * from 'preact/hooks';
|
||||
export {
|
||||
version,
|
||||
Children,
|
||||
render,
|
||||
hydrate,
|
||||
unmountComponentAtNode,
|
||||
createPortal,
|
||||
createElement,
|
||||
createContext,
|
||||
createFactory,
|
||||
cloneElement,
|
||||
createRef,
|
||||
Fragment,
|
||||
isValidElement,
|
||||
isFragment,
|
||||
isMemo,
|
||||
findDOMNode,
|
||||
Component,
|
||||
PureComponent,
|
||||
memo,
|
||||
forwardRef,
|
||||
flushSync,
|
||||
useInsertionEffect,
|
||||
startTransition,
|
||||
useDeferredValue,
|
||||
useSyncExternalStore,
|
||||
useTransition,
|
||||
// eslint-disable-next-line camelcase
|
||||
unstable_batchedUpdates,
|
||||
StrictMode,
|
||||
Suspense,
|
||||
SuspenseList,
|
||||
lazy,
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
||||
};
|
||||
|
||||
// React copies the named exports to the default one.
|
||||
export default {
|
||||
useState,
|
||||
useId,
|
||||
useReducer,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useInsertionEffect,
|
||||
useTransition,
|
||||
useDeferredValue,
|
||||
useSyncExternalStore,
|
||||
startTransition,
|
||||
useRef,
|
||||
useImperativeHandle,
|
||||
useMemo,
|
||||
useCallback,
|
||||
useContext,
|
||||
useDebugValue,
|
||||
version,
|
||||
Children,
|
||||
render,
|
||||
hydrate,
|
||||
unmountComponentAtNode,
|
||||
createPortal,
|
||||
createElement,
|
||||
createContext,
|
||||
createFactory,
|
||||
cloneElement,
|
||||
createRef,
|
||||
Fragment,
|
||||
isValidElement,
|
||||
isElement,
|
||||
isFragment,
|
||||
isMemo,
|
||||
findDOMNode,
|
||||
Component,
|
||||
PureComponent,
|
||||
memo,
|
||||
forwardRef,
|
||||
flushSync,
|
||||
unstable_batchedUpdates,
|
||||
StrictMode,
|
||||
Suspense,
|
||||
SuspenseList,
|
||||
lazy,
|
||||
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
||||
};
|
48
node_modules/preact/compat/src/internal.d.ts
generated
vendored
Normal file
48
node_modules/preact/compat/src/internal.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
Component as PreactComponent,
|
||||
VNode as PreactVNode,
|
||||
FunctionComponent as PreactFunctionComponent,
|
||||
PreactElement
|
||||
} from '../../src/internal';
|
||||
import { SuspenseProps } from './suspense';
|
||||
|
||||
export { ComponentChildren } from '../..';
|
||||
|
||||
export { PreactElement };
|
||||
|
||||
export interface Component<P = {}, S = {}> extends PreactComponent<P, S> {
|
||||
isReactComponent?: object;
|
||||
isPureReactComponent?: true;
|
||||
_patchedLifecycles?: true;
|
||||
|
||||
// Suspense internal properties
|
||||
_childDidSuspend?(error: Promise<void>, suspendingVNode: VNode): void;
|
||||
_suspended: (vnode: VNode) => (unsuspend: () => void) => void;
|
||||
_onResolve?(): void;
|
||||
|
||||
// Portal internal properties
|
||||
_temp: any;
|
||||
_container: PreactElement;
|
||||
}
|
||||
|
||||
export interface FunctionComponent<P = {}> extends PreactFunctionComponent<P> {
|
||||
shouldComponentUpdate?(nextProps: Readonly<P>): boolean;
|
||||
_forwarded?: boolean;
|
||||
_patchedLifecycles?: true;
|
||||
}
|
||||
|
||||
export interface VNode<T = any> extends PreactVNode<T> {
|
||||
$$typeof?: symbol | string;
|
||||
preactCompatNormalized?: boolean;
|
||||
}
|
||||
|
||||
export interface SuspenseState {
|
||||
_suspended?: null | VNode<any>;
|
||||
}
|
||||
|
||||
export interface SuspenseComponent
|
||||
extends PreactComponent<SuspenseProps, SuspenseState> {
|
||||
_pendingSuspensionCount: number;
|
||||
_suspenders: Component[];
|
||||
_detachOnNextRender: null | VNode<any>;
|
||||
}
|
34
node_modules/preact/compat/src/memo.js
generated
vendored
Normal file
34
node_modules/preact/compat/src/memo.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { createElement } from 'preact';
|
||||
import { shallowDiffers } from './util';
|
||||
|
||||
/**
|
||||
* Memoize a component, so that it only updates when the props actually have
|
||||
* changed. This was previously known as `React.pure`.
|
||||
* @param {import('./internal').FunctionComponent} c functional component
|
||||
* @param {(prev: object, next: object) => boolean} [comparer] Custom equality function
|
||||
* @returns {import('./internal').FunctionComponent}
|
||||
*/
|
||||
export function memo(c, comparer) {
|
||||
function shouldUpdate(nextProps) {
|
||||
let ref = this.props.ref;
|
||||
let updateRef = ref == nextProps.ref;
|
||||
if (!updateRef && ref) {
|
||||
ref.call ? ref(null) : (ref.current = null);
|
||||
}
|
||||
|
||||
if (!comparer) {
|
||||
return shallowDiffers(this.props, nextProps);
|
||||
}
|
||||
|
||||
return !comparer(this.props, nextProps) || !updateRef;
|
||||
}
|
||||
|
||||
function Memoed(props) {
|
||||
this.shouldComponentUpdate = shouldUpdate;
|
||||
return createElement(c, props);
|
||||
}
|
||||
Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
|
||||
Memoed.prototype.isReactComponent = true;
|
||||
Memoed._forwarded = true;
|
||||
return Memoed;
|
||||
}
|
77
node_modules/preact/compat/src/portals.js
generated
vendored
Normal file
77
node_modules/preact/compat/src/portals.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import { createElement, render } from 'preact';
|
||||
|
||||
/**
|
||||
* @param {import('../../src/index').RenderableProps<{ context: any }>} props
|
||||
*/
|
||||
function ContextProvider(props) {
|
||||
this.getChildContext = () => props.context;
|
||||
return props.children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Portal component
|
||||
* @this {import('./internal').Component}
|
||||
* @param {object | null | undefined} props
|
||||
*
|
||||
* TODO: use createRoot() instead of fake root
|
||||
*/
|
||||
function Portal(props) {
|
||||
const _this = this;
|
||||
let container = props._container;
|
||||
|
||||
_this.componentWillUnmount = function () {
|
||||
render(null, _this._temp);
|
||||
_this._temp = null;
|
||||
_this._container = null;
|
||||
};
|
||||
|
||||
// When we change container we should clear our old container and
|
||||
// indicate a new mount.
|
||||
if (_this._container && _this._container !== container) {
|
||||
_this.componentWillUnmount();
|
||||
}
|
||||
|
||||
if (!_this._temp) {
|
||||
// Ensure the element has a mask for useId invocations
|
||||
let root = _this._vnode;
|
||||
while (root !== null && !root._mask && root._parent !== null) {
|
||||
root = root._parent;
|
||||
}
|
||||
|
||||
_this._container = container;
|
||||
|
||||
// Create a fake DOM parent node that manages a subset of `container`'s children:
|
||||
_this._temp = {
|
||||
nodeType: 1,
|
||||
parentNode: container,
|
||||
childNodes: [],
|
||||
_children: { _mask: root._mask },
|
||||
contains: () => true,
|
||||
insertBefore(child, before) {
|
||||
this.childNodes.push(child);
|
||||
_this._container.insertBefore(child, before);
|
||||
},
|
||||
removeChild(child) {
|
||||
this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);
|
||||
_this._container.removeChild(child);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Render our wrapping element into temp.
|
||||
render(
|
||||
createElement(ContextProvider, { context: _this.context }, props._vnode),
|
||||
_this._temp
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
||||
* @param {import('./internal').VNode} vnode The vnode to render
|
||||
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
||||
*/
|
||||
export function createPortal(vnode, container) {
|
||||
const el = createElement(Portal, { _vnode: vnode, _container: container });
|
||||
el.containerInfo = container;
|
||||
return el;
|
||||
}
|
313
node_modules/preact/compat/src/render.js
generated
vendored
Normal file
313
node_modules/preact/compat/src/render.js
generated
vendored
Normal file
@@ -0,0 +1,313 @@
|
||||
import {
|
||||
render as preactRender,
|
||||
hydrate as preactHydrate,
|
||||
options,
|
||||
toChildArray,
|
||||
Component
|
||||
} from 'preact';
|
||||
import {
|
||||
useCallback,
|
||||
useContext,
|
||||
useDebugValue,
|
||||
useEffect,
|
||||
useId,
|
||||
useImperativeHandle,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useReducer,
|
||||
useRef,
|
||||
useState
|
||||
} from 'preact/hooks';
|
||||
import {
|
||||
useDeferredValue,
|
||||
useInsertionEffect,
|
||||
useSyncExternalStore,
|
||||
useTransition
|
||||
} from './index';
|
||||
|
||||
export const REACT_ELEMENT_TYPE =
|
||||
(typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||
|
||||
0xeac7;
|
||||
|
||||
const CAMEL_PROPS =
|
||||
/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
|
||||
const ON_ANI = /^on(Ani|Tra|Tou|BeforeInp|Compo)/;
|
||||
const CAMEL_REPLACE = /[A-Z0-9]/g;
|
||||
const IS_DOM = typeof document !== 'undefined';
|
||||
|
||||
// Input types for which onchange should not be converted to oninput.
|
||||
// type="file|checkbox|radio", plus "range" in IE11.
|
||||
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
|
||||
const onChangeInputType = type =>
|
||||
(typeof Symbol != 'undefined' && typeof Symbol() == 'symbol'
|
||||
? /fil|che|rad/
|
||||
: /fil|che|ra/
|
||||
).test(type);
|
||||
|
||||
// Some libraries like `react-virtualized` explicitly check for this.
|
||||
Component.prototype.isReactComponent = {};
|
||||
|
||||
// `UNSAFE_*` lifecycle hooks
|
||||
// Preact only ever invokes the unprefixed methods.
|
||||
// Here we provide a base "fallback" implementation that calls any defined UNSAFE_ prefixed method.
|
||||
// - If a component defines its own `componentDidMount()` (including via defineProperty), use that.
|
||||
// - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.
|
||||
// - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.
|
||||
// See https://github.com/preactjs/preact/issues/1941
|
||||
[
|
||||
'componentWillMount',
|
||||
'componentWillReceiveProps',
|
||||
'componentWillUpdate'
|
||||
].forEach(key => {
|
||||
Object.defineProperty(Component.prototype, key, {
|
||||
configurable: true,
|
||||
get() {
|
||||
return this['UNSAFE_' + key];
|
||||
},
|
||||
set(v) {
|
||||
Object.defineProperty(this, key, {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: v
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Proxy render() since React returns a Component reference.
|
||||
* @param {import('./internal').VNode} vnode VNode tree to render
|
||||
* @param {import('./internal').PreactElement} parent DOM node to render vnode tree into
|
||||
* @param {() => void} [callback] Optional callback that will be called after rendering
|
||||
* @returns {import('./internal').Component | null} The root component reference or null
|
||||
*/
|
||||
export function render(vnode, parent, callback) {
|
||||
// React destroys any existing DOM nodes, see #1727
|
||||
// ...but only on the first render, see #1828
|
||||
if (parent._children == null) {
|
||||
parent.textContent = '';
|
||||
}
|
||||
|
||||
preactRender(vnode, parent);
|
||||
if (typeof callback == 'function') callback();
|
||||
|
||||
return vnode ? vnode._component : null;
|
||||
}
|
||||
|
||||
export function hydrate(vnode, parent, callback) {
|
||||
preactHydrate(vnode, parent);
|
||||
if (typeof callback == 'function') callback();
|
||||
|
||||
return vnode ? vnode._component : null;
|
||||
}
|
||||
|
||||
let oldEventHook = options.event;
|
||||
options.event = e => {
|
||||
if (oldEventHook) e = oldEventHook(e);
|
||||
|
||||
e.persist = empty;
|
||||
e.isPropagationStopped = isPropagationStopped;
|
||||
e.isDefaultPrevented = isDefaultPrevented;
|
||||
return (e.nativeEvent = e);
|
||||
};
|
||||
|
||||
function empty() {}
|
||||
|
||||
function isPropagationStopped() {
|
||||
return this.cancelBubble;
|
||||
}
|
||||
|
||||
function isDefaultPrevented() {
|
||||
return this.defaultPrevented;
|
||||
}
|
||||
|
||||
const classNameDescriptorNonEnumberable = {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
get() {
|
||||
return this.class;
|
||||
}
|
||||
};
|
||||
|
||||
function handleDomVNode(vnode) {
|
||||
let props = vnode.props,
|
||||
type = vnode.type,
|
||||
normalizedProps = {};
|
||||
|
||||
let isNonDashedType = type.indexOf('-') === -1;
|
||||
for (let i in props) {
|
||||
let value = props[i];
|
||||
|
||||
if (
|
||||
(i === 'value' && 'defaultValue' in props && value == null) ||
|
||||
// Emulate React's behavior of not rendering the contents of noscript tags on the client.
|
||||
(IS_DOM && i === 'children' && type === 'noscript') ||
|
||||
i === 'class' ||
|
||||
i === 'className'
|
||||
) {
|
||||
// Skip applying value if it is null/undefined and we already set
|
||||
// a default value
|
||||
continue;
|
||||
}
|
||||
|
||||
let lowerCased = i.toLowerCase();
|
||||
if (i === 'defaultValue' && 'value' in props && props.value == null) {
|
||||
// `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
|
||||
// `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
|
||||
i = 'value';
|
||||
} else if (i === 'download' && value === true) {
|
||||
// Calling `setAttribute` with a truthy value will lead to it being
|
||||
// passed as a stringified value, e.g. `download="true"`. React
|
||||
// converts it to an empty string instead, otherwise the attribute
|
||||
// value will be used as the file name and the file will be called
|
||||
// "true" upon downloading it.
|
||||
value = '';
|
||||
} else if (lowerCased === 'translate' && value === 'no') {
|
||||
value = false;
|
||||
} else if (lowerCased[0] === 'o' && lowerCased[1] === 'n') {
|
||||
if (lowerCased === 'ondoubleclick') {
|
||||
i = 'ondblclick';
|
||||
} else if (
|
||||
lowerCased === 'onchange' &&
|
||||
(type === 'input' || type === 'textarea') &&
|
||||
!onChangeInputType(props.type)
|
||||
) {
|
||||
lowerCased = i = 'oninput';
|
||||
} else if (lowerCased === 'onfocus') {
|
||||
i = 'onfocusin';
|
||||
} else if (lowerCased === 'onblur') {
|
||||
i = 'onfocusout';
|
||||
} else if (ON_ANI.test(i)) {
|
||||
i = lowerCased;
|
||||
}
|
||||
} else if (isNonDashedType && CAMEL_PROPS.test(i)) {
|
||||
i = i.replace(CAMEL_REPLACE, '-$&').toLowerCase();
|
||||
} else if (value === null) {
|
||||
value = undefined;
|
||||
}
|
||||
|
||||
// Add support for onInput and onChange, see #3561
|
||||
// if we have an oninput prop already change it to oninputCapture
|
||||
if (lowerCased === 'oninput') {
|
||||
i = lowerCased;
|
||||
if (normalizedProps[i]) {
|
||||
i = 'oninputCapture';
|
||||
}
|
||||
}
|
||||
|
||||
normalizedProps[i] = value;
|
||||
}
|
||||
|
||||
// Add support for array select values: <select multiple value={[]} />
|
||||
if (
|
||||
type == 'select' &&
|
||||
normalizedProps.multiple &&
|
||||
Array.isArray(normalizedProps.value)
|
||||
) {
|
||||
// forEach() always returns undefined, which we abuse here to unset the value prop.
|
||||
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
||||
child.props.selected =
|
||||
normalizedProps.value.indexOf(child.props.value) != -1;
|
||||
});
|
||||
}
|
||||
|
||||
// Adding support for defaultValue in select tag
|
||||
if (type == 'select' && normalizedProps.defaultValue != null) {
|
||||
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
||||
if (normalizedProps.multiple) {
|
||||
child.props.selected =
|
||||
normalizedProps.defaultValue.indexOf(child.props.value) != -1;
|
||||
} else {
|
||||
child.props.selected =
|
||||
normalizedProps.defaultValue == child.props.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (props.class && !props.className) {
|
||||
normalizedProps.class = props.class;
|
||||
Object.defineProperty(
|
||||
normalizedProps,
|
||||
'className',
|
||||
classNameDescriptorNonEnumberable
|
||||
);
|
||||
} else if (props.className && !props.class) {
|
||||
normalizedProps.class = normalizedProps.className = props.className;
|
||||
} else if (props.class && props.className) {
|
||||
normalizedProps.class = normalizedProps.className = props.className;
|
||||
}
|
||||
|
||||
vnode.props = normalizedProps;
|
||||
}
|
||||
|
||||
let oldVNodeHook = options.vnode;
|
||||
options.vnode = vnode => {
|
||||
// only normalize props on Element nodes
|
||||
if (typeof vnode.type === 'string') {
|
||||
handleDomVNode(vnode);
|
||||
}
|
||||
|
||||
vnode.$$typeof = REACT_ELEMENT_TYPE;
|
||||
|
||||
if (oldVNodeHook) oldVNodeHook(vnode);
|
||||
};
|
||||
|
||||
// Only needed for react-relay
|
||||
let currentComponent;
|
||||
const oldBeforeRender = options._render;
|
||||
options._render = function (vnode) {
|
||||
if (oldBeforeRender) {
|
||||
oldBeforeRender(vnode);
|
||||
}
|
||||
currentComponent = vnode._component;
|
||||
};
|
||||
|
||||
const oldDiffed = options.diffed;
|
||||
/** @type {(vnode: import('./internal').VNode) => void} */
|
||||
options.diffed = function (vnode) {
|
||||
if (oldDiffed) {
|
||||
oldDiffed(vnode);
|
||||
}
|
||||
|
||||
const props = vnode.props;
|
||||
const dom = vnode._dom;
|
||||
|
||||
if (
|
||||
dom != null &&
|
||||
vnode.type === 'textarea' &&
|
||||
'value' in props &&
|
||||
props.value !== dom.value
|
||||
) {
|
||||
dom.value = props.value == null ? '' : props.value;
|
||||
}
|
||||
|
||||
currentComponent = null;
|
||||
};
|
||||
|
||||
// This is a very very private internal function for React it
|
||||
// is used to sort-of do runtime dependency injection.
|
||||
export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
||||
ReactCurrentDispatcher: {
|
||||
current: {
|
||||
readContext(context) {
|
||||
return currentComponent._globalContext[context._id].props.value;
|
||||
},
|
||||
useCallback,
|
||||
useContext,
|
||||
useDebugValue,
|
||||
useDeferredValue,
|
||||
useEffect,
|
||||
useId,
|
||||
useImperativeHandle,
|
||||
useInsertionEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
// useMutableSource, // experimental-only and replaced by uSES, likely not worth supporting
|
||||
useReducer,
|
||||
useRef,
|
||||
useState,
|
||||
useSyncExternalStore,
|
||||
useTransition
|
||||
}
|
||||
}
|
||||
};
|
16
node_modules/preact/compat/src/suspense-list.d.ts
generated
vendored
Normal file
16
node_modules/preact/compat/src/suspense-list.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// Intentionally not using a relative path to take advantage of
|
||||
// the TS version resolution mechanism
|
||||
import { Component, ComponentChild, ComponentChildren } from 'preact';
|
||||
|
||||
//
|
||||
// SuspenseList
|
||||
// -----------------------------------
|
||||
|
||||
export interface SuspenseListProps {
|
||||
children?: ComponentChildren;
|
||||
revealOrder?: 'forwards' | 'backwards' | 'together';
|
||||
}
|
||||
|
||||
export class SuspenseList extends Component<SuspenseListProps> {
|
||||
render(): ComponentChild;
|
||||
}
|
127
node_modules/preact/compat/src/suspense-list.js
generated
vendored
Normal file
127
node_modules/preact/compat/src/suspense-list.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
import { Component, toChildArray } from 'preact';
|
||||
import { suspended } from './suspense.js';
|
||||
|
||||
// Indexes to linked list nodes (nodes are stored as arrays to save bytes).
|
||||
const SUSPENDED_COUNT = 0;
|
||||
const RESOLVED_COUNT = 1;
|
||||
const NEXT_NODE = 2;
|
||||
|
||||
// Having custom inheritance instead of a class here saves a lot of bytes.
|
||||
export function SuspenseList() {
|
||||
this._next = null;
|
||||
this._map = null;
|
||||
}
|
||||
|
||||
// Mark one of child's earlier suspensions as resolved.
|
||||
// Some pending callbacks may become callable due to this
|
||||
// (e.g. the last suspended descendant gets resolved when
|
||||
// revealOrder === 'together'). Process those callbacks as well.
|
||||
const resolve = (list, child, node) => {
|
||||
if (++node[RESOLVED_COUNT] === node[SUSPENDED_COUNT]) {
|
||||
// The number a child (or any of its descendants) has been suspended
|
||||
// matches the number of times it's been resolved. Therefore we
|
||||
// mark the child as completely resolved by deleting it from ._map.
|
||||
// This is used to figure out when *all* children have been completely
|
||||
// resolved when revealOrder is 'together'.
|
||||
list._map.delete(child);
|
||||
}
|
||||
|
||||
// If revealOrder is falsy then we can do an early exit, as the
|
||||
// callbacks won't get queued in the node anyway.
|
||||
// If revealOrder is 'together' then also do an early exit
|
||||
// if all suspended descendants have not yet been resolved.
|
||||
if (
|
||||
!list.props.revealOrder ||
|
||||
(list.props.revealOrder[0] === 't' && list._map.size)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Walk the currently suspended children in order, calling their
|
||||
// stored callbacks on the way. Stop if we encounter a child that
|
||||
// has not been completely resolved yet.
|
||||
node = list._next;
|
||||
while (node) {
|
||||
while (node.length > 3) {
|
||||
node.pop()();
|
||||
}
|
||||
if (node[RESOLVED_COUNT] < node[SUSPENDED_COUNT]) {
|
||||
break;
|
||||
}
|
||||
list._next = node = node[NEXT_NODE];
|
||||
}
|
||||
};
|
||||
|
||||
// Things we do here to save some bytes but are not proper JS inheritance:
|
||||
// - call `new Component()` as the prototype
|
||||
// - do not set `Suspense.prototype.constructor` to `Suspense`
|
||||
SuspenseList.prototype = new Component();
|
||||
|
||||
SuspenseList.prototype._suspended = function (child) {
|
||||
const list = this;
|
||||
const delegated = suspended(list._vnode);
|
||||
|
||||
let node = list._map.get(child);
|
||||
node[SUSPENDED_COUNT]++;
|
||||
|
||||
return unsuspend => {
|
||||
const wrappedUnsuspend = () => {
|
||||
if (!list.props.revealOrder) {
|
||||
// Special case the undefined (falsy) revealOrder, as there
|
||||
// is no need to coordinate a specific order or unsuspends.
|
||||
unsuspend();
|
||||
} else {
|
||||
node.push(unsuspend);
|
||||
resolve(list, child, node);
|
||||
}
|
||||
};
|
||||
if (delegated) {
|
||||
delegated(wrappedUnsuspend);
|
||||
} else {
|
||||
wrappedUnsuspend();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
SuspenseList.prototype.render = function (props) {
|
||||
this._next = null;
|
||||
this._map = new Map();
|
||||
|
||||
const children = toChildArray(props.children);
|
||||
if (props.revealOrder && props.revealOrder[0] === 'b') {
|
||||
// If order === 'backwards' (or, well, anything starting with a 'b')
|
||||
// then flip the child list around so that the last child will be
|
||||
// the first in the linked list.
|
||||
children.reverse();
|
||||
}
|
||||
// Build the linked list. Iterate through the children in reverse order
|
||||
// so that `_next` points to the first linked list node to be resolved.
|
||||
for (let i = children.length; i--; ) {
|
||||
// Create a new linked list node as an array of form:
|
||||
// [suspended_count, resolved_count, next_node]
|
||||
// where suspended_count and resolved_count are numeric counters for
|
||||
// keeping track how many times a node has been suspended and resolved.
|
||||
//
|
||||
// Note that suspended_count starts from 1 instead of 0, so we can block
|
||||
// processing callbacks until componentDidMount has been called. In a sense
|
||||
// node is suspended at least until componentDidMount gets called!
|
||||
//
|
||||
// Pending callbacks are added to the end of the node:
|
||||
// [suspended_count, resolved_count, next_node, callback_0, callback_1, ...]
|
||||
this._map.set(children[i], (this._next = [1, 0, this._next]));
|
||||
}
|
||||
return props.children;
|
||||
};
|
||||
|
||||
SuspenseList.prototype.componentDidUpdate =
|
||||
SuspenseList.prototype.componentDidMount = function () {
|
||||
// Iterate through all children after mounting for two reasons:
|
||||
// 1. As each node[SUSPENDED_COUNT] starts from 1, this iteration increases
|
||||
// each node[RELEASED_COUNT] by 1, therefore balancing the counters.
|
||||
// The nodes can now be completely consumed from the linked list.
|
||||
// 2. Handle nodes that might have gotten resolved between render and
|
||||
// componentDidMount.
|
||||
this._map.forEach((node, child) => {
|
||||
resolve(this, child, node);
|
||||
});
|
||||
};
|
19
node_modules/preact/compat/src/suspense.d.ts
generated
vendored
Normal file
19
node_modules/preact/compat/src/suspense.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Intentionally not using a relative path to take advantage of
|
||||
// the TS version resolution mechanism
|
||||
import { Component, ComponentChild, ComponentChildren } from 'preact';
|
||||
|
||||
//
|
||||
// Suspense/lazy
|
||||
// -----------------------------------
|
||||
export function lazy<T>(
|
||||
loader: () => Promise<{ default: T } | T>
|
||||
): T extends { default: infer U } ? U : T;
|
||||
|
||||
export interface SuspenseProps {
|
||||
children?: ComponentChildren;
|
||||
fallback: ComponentChildren;
|
||||
}
|
||||
|
||||
export class Suspense extends Component<SuspenseProps> {
|
||||
render(): ComponentChild;
|
||||
}
|
276
node_modules/preact/compat/src/suspense.js
generated
vendored
Normal file
276
node_modules/preact/compat/src/suspense.js
generated
vendored
Normal file
@@ -0,0 +1,276 @@
|
||||
import { Component, createElement, options, Fragment } from 'preact';
|
||||
import { MODE_HYDRATE } from '../../src/constants';
|
||||
import { assign } from './util';
|
||||
|
||||
const oldCatchError = options._catchError;
|
||||
options._catchError = function (error, newVNode, oldVNode, errorInfo) {
|
||||
if (error.then) {
|
||||
/** @type {import('./internal').Component} */
|
||||
let component;
|
||||
let vnode = newVNode;
|
||||
|
||||
for (; (vnode = vnode._parent); ) {
|
||||
if ((component = vnode._component) && component._childDidSuspend) {
|
||||
if (newVNode._dom == null) {
|
||||
newVNode._dom = oldVNode._dom;
|
||||
newVNode._children = oldVNode._children;
|
||||
}
|
||||
// Don't call oldCatchError if we found a Suspense
|
||||
return component._childDidSuspend(error, newVNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
oldCatchError(error, newVNode, oldVNode, errorInfo);
|
||||
};
|
||||
|
||||
const oldUnmount = options.unmount;
|
||||
options.unmount = function (vnode) {
|
||||
/** @type {import('./internal').Component} */
|
||||
const component = vnode._component;
|
||||
if (component && component._onResolve) {
|
||||
component._onResolve();
|
||||
}
|
||||
|
||||
// if the component is still hydrating
|
||||
// most likely it is because the component is suspended
|
||||
// we set the vnode.type as `null` so that it is not a typeof function
|
||||
// so the unmount will remove the vnode._dom
|
||||
if (component && vnode._flags & MODE_HYDRATE) {
|
||||
vnode.type = null;
|
||||
}
|
||||
|
||||
if (oldUnmount) oldUnmount(vnode);
|
||||
};
|
||||
|
||||
function detachedClone(vnode, detachedParent, parentDom) {
|
||||
if (vnode) {
|
||||
if (vnode._component && vnode._component.__hooks) {
|
||||
vnode._component.__hooks._list.forEach(effect => {
|
||||
if (typeof effect._cleanup == 'function') effect._cleanup();
|
||||
});
|
||||
|
||||
vnode._component.__hooks = null;
|
||||
}
|
||||
|
||||
vnode = assign({}, vnode);
|
||||
if (vnode._component != null) {
|
||||
if (vnode._component._parentDom === parentDom) {
|
||||
vnode._component._parentDom = detachedParent;
|
||||
}
|
||||
|
||||
vnode._component._force = true;
|
||||
|
||||
vnode._component = null;
|
||||
}
|
||||
|
||||
vnode._children =
|
||||
vnode._children &&
|
||||
vnode._children.map(child =>
|
||||
detachedClone(child, detachedParent, parentDom)
|
||||
);
|
||||
}
|
||||
|
||||
return vnode;
|
||||
}
|
||||
|
||||
function removeOriginal(vnode, detachedParent, originalParent) {
|
||||
if (vnode && originalParent) {
|
||||
vnode._original = null;
|
||||
vnode._children =
|
||||
vnode._children &&
|
||||
vnode._children.map(child =>
|
||||
removeOriginal(child, detachedParent, originalParent)
|
||||
);
|
||||
|
||||
if (vnode._component) {
|
||||
if (vnode._component._parentDom === detachedParent) {
|
||||
if (vnode._dom) {
|
||||
originalParent.appendChild(vnode._dom);
|
||||
}
|
||||
vnode._component._force = true;
|
||||
vnode._component._parentDom = originalParent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vnode;
|
||||
}
|
||||
|
||||
// having custom inheritance instead of a class here saves a lot of bytes
|
||||
export function Suspense() {
|
||||
// we do not call super here to golf some bytes...
|
||||
this._pendingSuspensionCount = 0;
|
||||
this._suspenders = null;
|
||||
this._detachOnNextRender = null;
|
||||
}
|
||||
|
||||
// Things we do here to save some bytes but are not proper JS inheritance:
|
||||
// - call `new Component()` as the prototype
|
||||
// - do not set `Suspense.prototype.constructor` to `Suspense`
|
||||
Suspense.prototype = new Component();
|
||||
|
||||
/**
|
||||
* @this {import('./internal').SuspenseComponent}
|
||||
* @param {Promise} promise The thrown promise
|
||||
* @param {import('./internal').VNode<any, any>} suspendingVNode The suspending component
|
||||
*/
|
||||
Suspense.prototype._childDidSuspend = function (promise, suspendingVNode) {
|
||||
const suspendingComponent = suspendingVNode._component;
|
||||
|
||||
/** @type {import('./internal').SuspenseComponent} */
|
||||
const c = this;
|
||||
|
||||
if (c._suspenders == null) {
|
||||
c._suspenders = [];
|
||||
}
|
||||
c._suspenders.push(suspendingComponent);
|
||||
|
||||
const resolve = suspended(c._vnode);
|
||||
|
||||
let resolved = false;
|
||||
const onResolved = () => {
|
||||
if (resolved) return;
|
||||
|
||||
resolved = true;
|
||||
suspendingComponent._onResolve = null;
|
||||
|
||||
if (resolve) {
|
||||
resolve(onSuspensionComplete);
|
||||
} else {
|
||||
onSuspensionComplete();
|
||||
}
|
||||
};
|
||||
|
||||
suspendingComponent._onResolve = onResolved;
|
||||
|
||||
const onSuspensionComplete = () => {
|
||||
if (!--c._pendingSuspensionCount) {
|
||||
// If the suspension was during hydration we don't need to restore the
|
||||
// suspended children into the _children array
|
||||
if (c.state._suspended) {
|
||||
const suspendedVNode = c.state._suspended;
|
||||
c._vnode._children[0] = removeOriginal(
|
||||
suspendedVNode,
|
||||
suspendedVNode._component._parentDom,
|
||||
suspendedVNode._component._originalParentDom
|
||||
);
|
||||
}
|
||||
|
||||
c.setState({ _suspended: (c._detachOnNextRender = null) });
|
||||
|
||||
let suspended;
|
||||
while ((suspended = c._suspenders.pop())) {
|
||||
suspended.forceUpdate();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* We do not set `suspended: true` during hydration because we want the actual markup
|
||||
* to remain on screen and hydrate it when the suspense actually gets resolved.
|
||||
* While in non-hydration cases the usual fallback -> component flow would occour.
|
||||
*/
|
||||
if (
|
||||
!c._pendingSuspensionCount++ &&
|
||||
!(suspendingVNode._flags & MODE_HYDRATE)
|
||||
) {
|
||||
c.setState({ _suspended: (c._detachOnNextRender = c._vnode._children[0]) });
|
||||
}
|
||||
promise.then(onResolved, onResolved);
|
||||
};
|
||||
|
||||
Suspense.prototype.componentWillUnmount = function () {
|
||||
this._suspenders = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* @this {import('./internal').SuspenseComponent}
|
||||
* @param {import('./internal').SuspenseComponent["props"]} props
|
||||
* @param {import('./internal').SuspenseState} state
|
||||
*/
|
||||
Suspense.prototype.render = function (props, state) {
|
||||
if (this._detachOnNextRender) {
|
||||
// When the Suspense's _vnode was created by a call to createVNode
|
||||
// (i.e. due to a setState further up in the tree)
|
||||
// it's _children prop is null, in this case we "forget" about the parked vnodes to detach
|
||||
if (this._vnode._children) {
|
||||
const detachedParent = document.createElement('div');
|
||||
const detachedComponent = this._vnode._children[0]._component;
|
||||
this._vnode._children[0] = detachedClone(
|
||||
this._detachOnNextRender,
|
||||
detachedParent,
|
||||
(detachedComponent._originalParentDom = detachedComponent._parentDom)
|
||||
);
|
||||
}
|
||||
|
||||
this._detachOnNextRender = null;
|
||||
}
|
||||
|
||||
// Wrap fallback tree in a VNode that prevents itself from being marked as aborting mid-hydration:
|
||||
/** @type {import('./internal').VNode} */
|
||||
const fallback =
|
||||
state._suspended && createElement(Fragment, null, props.fallback);
|
||||
if (fallback) fallback._flags &= ~MODE_HYDRATE;
|
||||
|
||||
return [
|
||||
createElement(Fragment, null, state._suspended ? null : props.children),
|
||||
fallback
|
||||
];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks and calls the parent component's _suspended method, passing in the
|
||||
* suspended vnode. This is a way for a parent (e.g. SuspenseList) to get notified
|
||||
* that one of its children/descendants suspended.
|
||||
*
|
||||
* The parent MAY return a callback. The callback will get called when the
|
||||
* suspension resolves, notifying the parent of the fact.
|
||||
* Moreover, the callback gets function `unsuspend` as a parameter. The resolved
|
||||
* child descendant will not actually get unsuspended until `unsuspend` gets called.
|
||||
* This is a way for the parent to delay unsuspending.
|
||||
*
|
||||
* If the parent does not return a callback then the resolved vnode
|
||||
* gets unsuspended immediately when it resolves.
|
||||
*
|
||||
* @param {import('./internal').VNode} vnode
|
||||
* @returns {((unsuspend: () => void) => void)?}
|
||||
*/
|
||||
export function suspended(vnode) {
|
||||
/** @type {import('./internal').Component} */
|
||||
let component = vnode._parent._component;
|
||||
return component && component._suspended && component._suspended(vnode);
|
||||
}
|
||||
|
||||
export function lazy(loader) {
|
||||
let prom;
|
||||
let component;
|
||||
let error;
|
||||
|
||||
function Lazy(props) {
|
||||
if (!prom) {
|
||||
prom = loader();
|
||||
prom.then(
|
||||
exports => {
|
||||
component = exports.default || exports;
|
||||
},
|
||||
e => {
|
||||
error = e;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!component) {
|
||||
throw prom;
|
||||
}
|
||||
|
||||
return createElement(component, props);
|
||||
}
|
||||
|
||||
Lazy.displayName = 'Lazy';
|
||||
Lazy._forwarded = true;
|
||||
return Lazy;
|
||||
}
|
33
node_modules/preact/compat/src/util.js
generated
vendored
Normal file
33
node_modules/preact/compat/src/util.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Assign properties from `props` to `obj`
|
||||
* @template O, P The obj and props types
|
||||
* @param {O} obj The object to copy properties to
|
||||
* @param {P} props The object to copy properties from
|
||||
* @returns {O & P}
|
||||
*/
|
||||
export function assign(obj, props) {
|
||||
for (let i in props) obj[i] = props[i];
|
||||
return /** @type {O & P} */ (obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two objects have a different shape
|
||||
* @param {object} a
|
||||
* @param {object} b
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function shallowDiffers(a, b) {
|
||||
for (let i in a) if (i !== '__source' && !(i in b)) return true;
|
||||
for (let i in b) if (i !== '__source' && a[i] !== b[i]) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two values are the same value
|
||||
* @param {*} x
|
||||
* @param {*} y
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function is(x, y) {
|
||||
return (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y);
|
||||
}
|
1
node_modules/preact/compat/test-utils.js
generated
vendored
Normal file
1
node_modules/preact/compat/test-utils.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('preact/test-utils');
|
1
node_modules/preact/compat/test-utils.mjs
generated
vendored
Normal file
1
node_modules/preact/compat/test-utils.mjs
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from 'preact/test-utils';
|
Reference in New Issue
Block a user