@bpmn-io/properties-panel 0.9.0 → 0.10.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.
- package/CHANGELOG.md +11 -0
- package/dist/index.esm.js +1607 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1648 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -7
- package/preact/LICENSE +21 -0
- package/preact/README.md +185 -0
- package/preact/compat/dist/compat.js +2 -0
- package/preact/compat/dist/compat.js.map +1 -0
- package/preact/compat/dist/compat.mjs +2 -0
- package/preact/compat/dist/compat.module.js +2 -0
- package/preact/compat/dist/compat.module.js.map +1 -0
- package/preact/compat/dist/compat.umd.js +2 -0
- package/preact/compat/dist/compat.umd.js.map +1 -0
- package/preact/compat/jsx-dev-runtime.js +1 -0
- package/preact/compat/jsx-dev-runtime.mjs +1 -0
- package/preact/compat/jsx-runtime.js +1 -0
- package/preact/compat/jsx-runtime.mjs +1 -0
- package/preact/compat/package.json +19 -0
- package/preact/compat/server.js +15 -0
- package/preact/compat/server.mjs +4 -0
- package/preact/compat/src/Children.js +21 -0
- package/preact/compat/src/PureComponent.js +15 -0
- package/preact/compat/src/forwardRef.js +51 -0
- package/preact/compat/src/index.d.ts +140 -0
- package/preact/compat/src/index.js +175 -0
- package/preact/compat/src/internal.d.ts +47 -0
- package/preact/compat/src/memo.js +34 -0
- package/preact/compat/src/portals.js +80 -0
- package/preact/compat/src/render.js +219 -0
- package/preact/compat/src/scheduler.js +24 -0
- package/preact/compat/src/suspense-list.d.ts +14 -0
- package/preact/compat/src/suspense-list.js +126 -0
- package/preact/compat/src/suspense.d.ts +15 -0
- package/preact/compat/src/suspense.js +270 -0
- package/preact/compat/src/util.js +28 -0
- package/preact/compat/test-utils.js +1 -0
- package/preact/debug/dist/debug.js +2 -0
- package/preact/debug/dist/debug.js.map +1 -0
- package/preact/debug/dist/debug.mjs +2 -0
- package/preact/debug/dist/debug.module.js +2 -0
- package/preact/debug/dist/debug.module.js.map +1 -0
- package/preact/debug/dist/debug.umd.js +2 -0
- package/preact/debug/dist/debug.umd.js.map +1 -0
- package/preact/debug/package.json +18 -0
- package/preact/debug/src/check-props.js +54 -0
- package/preact/debug/src/component-stack.js +146 -0
- package/preact/debug/src/constants.js +3 -0
- package/preact/debug/src/debug.js +442 -0
- package/preact/debug/src/index.js +6 -0
- package/preact/debug/src/internal.d.ts +82 -0
- package/preact/debug/src/util.js +11 -0
- package/preact/devtools/dist/devtools.js +2 -0
- package/preact/devtools/dist/devtools.js.map +1 -0
- package/preact/devtools/dist/devtools.mjs +2 -0
- package/preact/devtools/dist/devtools.module.js +2 -0
- package/preact/devtools/dist/devtools.module.js.map +1 -0
- package/preact/devtools/dist/devtools.umd.js +2 -0
- package/preact/devtools/dist/devtools.umd.js.map +1 -0
- package/preact/devtools/package.json +16 -0
- package/preact/devtools/src/devtools.js +10 -0
- package/preact/devtools/src/index.d.ts +8 -0
- package/preact/devtools/src/index.js +15 -0
- package/preact/dist/preact.js +2 -0
- package/preact/dist/preact.js.map +1 -0
- package/preact/dist/preact.min.js +2 -0
- package/preact/dist/preact.min.js.map +1 -0
- package/preact/dist/preact.mjs +2 -0
- package/preact/dist/preact.module.js +2 -0
- package/preact/dist/preact.module.js.map +1 -0
- package/preact/dist/preact.umd.js +2 -0
- package/preact/dist/preact.umd.js.map +1 -0
- package/preact/hooks/dist/hooks.js +2 -0
- package/preact/hooks/dist/hooks.js.map +1 -0
- package/preact/hooks/dist/hooks.mjs +2 -0
- package/preact/hooks/dist/hooks.module.js +2 -0
- package/preact/hooks/dist/hooks.module.js.map +1 -0
- package/preact/hooks/dist/hooks.umd.js +2 -0
- package/preact/hooks/dist/hooks.umd.js.map +1 -0
- package/preact/hooks/package.json +26 -0
- package/preact/hooks/src/index.d.ts +130 -0
- package/preact/hooks/src/index.js +386 -0
- package/preact/hooks/src/internal.d.ts +75 -0
- package/preact/jsx-runtime/dist/jsxRuntime.js +2 -0
- package/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -0
- package/preact/jsx-runtime/dist/jsxRuntime.mjs +2 -0
- package/preact/jsx-runtime/dist/jsxRuntime.module.js +2 -0
- package/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -0
- package/preact/jsx-runtime/dist/jsxRuntime.umd.js +2 -0
- package/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -0
- package/preact/jsx-runtime/package.json +19 -0
- package/preact/jsx-runtime/src/index.d.ts +50 -0
- package/preact/jsx-runtime/src/index.js +72 -0
- package/preact/package.json +268 -0
- package/preact/src/cjs.js +3 -0
- package/preact/src/clone-element.js +39 -0
- package/preact/src/component.js +225 -0
- package/preact/src/constants.js +3 -0
- package/preact/src/create-context.js +68 -0
- package/preact/src/create-element.js +100 -0
- package/preact/src/diff/catch-error.js +38 -0
- package/preact/src/diff/children.js +347 -0
- package/preact/src/diff/index.js +516 -0
- package/preact/src/diff/props.js +158 -0
- package/preact/src/index.d.ts +310 -0
- package/preact/src/index.js +13 -0
- package/preact/src/internal.d.ts +147 -0
- package/preact/src/jsx.d.ts +955 -0
- package/preact/src/options.js +17 -0
- package/preact/src/render.js +74 -0
- package/preact/src/util.js +23 -0
- package/preact/test-utils/dist/testUtils.js +2 -0
- package/preact/test-utils/dist/testUtils.js.map +1 -0
- package/preact/test-utils/dist/testUtils.mjs +2 -0
- package/preact/test-utils/dist/testUtils.module.js +2 -0
- package/preact/test-utils/dist/testUtils.module.js.map +1 -0
- package/preact/test-utils/dist/testUtils.umd.js +2 -0
- package/preact/test-utils/dist/testUtils.umd.js.map +1 -0
- package/preact/test-utils/package.json +19 -0
- package/preact/test-utils/src/index.d.ts +3 -0
- package/preact/test-utils/src/index.js +117 -0
- package/lib/PropertiesPanel.js +0 -166
- package/lib/PropertiesPanel.js.map +0 -1
- package/lib/components/DropdownButton.js +0 -109
- package/lib/components/DropdownButton.js.map +0 -1
- package/lib/components/Group.js +0 -75
- package/lib/components/Group.js.map +0 -1
- package/lib/components/Header.js +0 -49
- package/lib/components/Header.js.map +0 -1
- package/lib/components/HeaderButton.js +0 -16
- package/lib/components/HeaderButton.js.map +0 -1
- package/lib/components/ListGroup.js +0 -167
- package/lib/components/ListGroup.js.map +0 -1
- package/lib/components/ListItem.js +0 -37
- package/lib/components/ListItem.js.map +0 -1
- package/lib/components/entries/Checkbox.js +0 -83
- package/lib/components/entries/Checkbox.js.map +0 -1
- package/lib/components/entries/Collapsible.js +0 -48
- package/lib/components/entries/Collapsible.js.map +0 -1
- package/lib/components/entries/Description.js +0 -26
- package/lib/components/entries/Description.js.map +0 -1
- package/lib/components/entries/List.js +0 -204
- package/lib/components/entries/List.js.map +0 -1
- package/lib/components/entries/NumberField.js +0 -110
- package/lib/components/entries/NumberField.js.map +0 -1
- package/lib/components/entries/Select.js +0 -110
- package/lib/components/entries/Select.js.map +0 -1
- package/lib/components/entries/Simple.js +0 -56
- package/lib/components/entries/Simple.js.map +0 -1
- package/lib/components/entries/TextArea.js +0 -98
- package/lib/components/entries/TextArea.js.map +0 -1
- package/lib/components/entries/TextField.js +0 -123
- package/lib/components/entries/TextField.js.map +0 -1
- package/lib/components/entries/ToggleSwitch.js +0 -91
- package/lib/components/entries/ToggleSwitch.js.map +0 -1
- package/lib/components/icons/index.js +0 -51
- package/lib/components/icons/index.js.map +0 -1
- package/lib/context/DescriptionContext.js +0 -7
- package/lib/context/DescriptionContext.js.map +0 -1
- package/lib/context/LayoutContext.js +0 -9
- package/lib/context/LayoutContext.js.map +0 -1
- package/lib/context/index.js +0 -3
- package/lib/context/index.js.map +0 -1
- package/lib/features/debounce-input/debounceInput.js +0 -14
- package/lib/features/debounce-input/debounceInput.js.map +0 -1
- package/lib/features/debounce-input/index.js +0 -5
- package/lib/features/debounce-input/index.js.map +0 -1
- package/lib/hooks/index.js +0 -5
- package/lib/hooks/index.js.map +0 -1
- package/lib/hooks/useDescriptionContext.js +0 -25
- package/lib/hooks/useDescriptionContext.js.map +0 -1
- package/lib/hooks/useKeyFactory.js +0 -39
- package/lib/hooks/useKeyFactory.js.map +0 -1
- package/lib/hooks/useLayoutState.js +0 -36
- package/lib/hooks/useLayoutState.js.map +0 -1
- package/lib/hooks/usePrevious.js +0 -16
- package/lib/hooks/usePrevious.js.map +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { PreactContext, Ref as PreactRef } from '../..';
|
|
2
|
+
|
|
3
|
+
type Inputs = ReadonlyArray<unknown>;
|
|
4
|
+
|
|
5
|
+
export type StateUpdater<S> = (value: S | ((prevState: S) => S)) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Returns a stateful value, and a function to update it.
|
|
8
|
+
* @param initialState The initial value (or a function that returns the initial value)
|
|
9
|
+
*/
|
|
10
|
+
export function useState<S>(initialState: S | (() => S)): [S, StateUpdater<S>];
|
|
11
|
+
|
|
12
|
+
export type Reducer<S, A> = (prevState: S, action: A) => S;
|
|
13
|
+
/**
|
|
14
|
+
* An alternative to `useState`.
|
|
15
|
+
*
|
|
16
|
+
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
17
|
+
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
18
|
+
* updates because you can pass `dispatch` down instead of callbacks.
|
|
19
|
+
* @param reducer Given the current state and an action, returns the new state
|
|
20
|
+
* @param initialState The initial value to store as state
|
|
21
|
+
*/
|
|
22
|
+
export function useReducer<S, A>(
|
|
23
|
+
reducer: Reducer<S, A>,
|
|
24
|
+
initialState: S
|
|
25
|
+
): [S, (action: A) => void];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An alternative to `useState`.
|
|
29
|
+
*
|
|
30
|
+
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
|
31
|
+
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
|
32
|
+
* updates because you can pass `dispatch` down instead of callbacks.
|
|
33
|
+
* @param reducer Given the current state and an action, returns the new state
|
|
34
|
+
* @param initialArg The initial argument to pass to the `init` function
|
|
35
|
+
* @param init A function that, given the `initialArg`, returns the initial value to store as state
|
|
36
|
+
*/
|
|
37
|
+
export function useReducer<S, A, I>(
|
|
38
|
+
reducer: Reducer<S, A>,
|
|
39
|
+
initialArg: I,
|
|
40
|
+
init: (arg: I) => S
|
|
41
|
+
): [S, (action: A) => void];
|
|
42
|
+
|
|
43
|
+
type PropRef<T> = { current: T };
|
|
44
|
+
type Ref<T> = { current: T };
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
|
48
|
+
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
|
49
|
+
*
|
|
50
|
+
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
|
51
|
+
* value around similar to how you’d use instance fields in classes.
|
|
52
|
+
*/
|
|
53
|
+
export function useRef<T>(initialValue?: T | null): Ref<T>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* `useRef` without an initial value is the special case handling `ref` props.
|
|
57
|
+
* If you want a non prop-based, mutable ref, you can explicitly give it an initial value of undefined/null/etc.
|
|
58
|
+
* You should explicitly set the type parameter for the expected ref value to either a DOM Element like `HTMLInputElement` or a `Component`
|
|
59
|
+
*/
|
|
60
|
+
export function useRef<T = unknown>(): PropRef<T>;
|
|
61
|
+
|
|
62
|
+
type EffectCallback = () => void | (() => void);
|
|
63
|
+
/**
|
|
64
|
+
* Accepts a function that contains imperative, possibly effectful code.
|
|
65
|
+
* The effects run after browser paint, without blocking it.
|
|
66
|
+
*
|
|
67
|
+
* @param effect Imperative function that can return a cleanup function
|
|
68
|
+
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
|
69
|
+
*/
|
|
70
|
+
export function useEffect(effect: EffectCallback, inputs?: Inputs): void;
|
|
71
|
+
|
|
72
|
+
type CreateHandle = () => object;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param ref The ref that will be mutated
|
|
76
|
+
* @param create The function that will be executed to get the value that will be attached to
|
|
77
|
+
* ref.current
|
|
78
|
+
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
|
79
|
+
*/
|
|
80
|
+
export function useImperativeHandle<T, R extends T>(
|
|
81
|
+
ref: PreactRef<T>,
|
|
82
|
+
create: () => R,
|
|
83
|
+
inputs?: Inputs
|
|
84
|
+
): void;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Accepts a function that contains imperative, possibly effectful code.
|
|
88
|
+
* Use this to read layout from the DOM and synchronously re-render.
|
|
89
|
+
* Updates scheduled inside `useLayoutEffect` will be flushed synchronously, after all DOM mutations but before the browser has a chance to paint.
|
|
90
|
+
* Prefer the standard `useEffect` hook when possible to avoid blocking visual updates.
|
|
91
|
+
*
|
|
92
|
+
* @param effect Imperative function that can return a cleanup function
|
|
93
|
+
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
|
94
|
+
*/
|
|
95
|
+
export function useLayoutEffect(effect: EffectCallback, inputs?: Inputs): void;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Returns a memoized version of the callback that only changes if one of the `inputs`
|
|
99
|
+
* has changed (using ===).
|
|
100
|
+
*/
|
|
101
|
+
export function useCallback<T extends Function>(callback: T, inputs: Inputs): T;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Pass a factory function and an array of inputs.
|
|
105
|
+
* useMemo will only recompute the memoized value when one of the inputs has changed.
|
|
106
|
+
* This optimization helps to avoid expensive calculations on every render.
|
|
107
|
+
* If no array is provided, a new value will be computed whenever a new function instance is passed as the first argument.
|
|
108
|
+
*/
|
|
109
|
+
// for `inputs`, allow undefined, but don't make it optional as that is very likely a mistake
|
|
110
|
+
export function useMemo<T>(factory: () => T, inputs: Inputs | undefined): T;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns the current context value, as given by the nearest context provider for the given context.
|
|
114
|
+
* When the provider updates, this Hook will trigger a rerender with the latest context value.
|
|
115
|
+
*
|
|
116
|
+
* @param context The context you want to use
|
|
117
|
+
*/
|
|
118
|
+
export function useContext<T>(context: PreactContext<T>): T;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Customize the displayed value in the devtools panel.
|
|
122
|
+
*
|
|
123
|
+
* @param value Custom hook name or object that is passed to formatter
|
|
124
|
+
* @param formatter Formatter to modify value before sending it to the devtools
|
|
125
|
+
*/
|
|
126
|
+
export function useDebugValue<T>(value: T, formatter?: (value: T) => any): void;
|
|
127
|
+
|
|
128
|
+
export function useErrorBoundary(
|
|
129
|
+
callback?: (error: any) => Promise<void> | void
|
|
130
|
+
): [any, () => void];
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { options } from '../..';
|
|
2
|
+
|
|
3
|
+
/** @type {number} */
|
|
4
|
+
let currentIndex;
|
|
5
|
+
|
|
6
|
+
/** @type {import('./internal').Component} */
|
|
7
|
+
let currentComponent;
|
|
8
|
+
/**
|
|
9
|
+
* Keep track of the previous component so that we can set
|
|
10
|
+
* `currentComponent` to `null` and throw when a hook is invoked
|
|
11
|
+
* outside of render
|
|
12
|
+
* @type {import('./internal').Component}
|
|
13
|
+
*/
|
|
14
|
+
let previousComponent;
|
|
15
|
+
|
|
16
|
+
/** @type {number} */
|
|
17
|
+
let currentHook = 0;
|
|
18
|
+
|
|
19
|
+
/** @type {Array<import('./internal').Component>} */
|
|
20
|
+
let afterPaintEffects = [];
|
|
21
|
+
|
|
22
|
+
let oldBeforeDiff = options._diff;
|
|
23
|
+
let oldBeforeRender = options._render;
|
|
24
|
+
let oldAfterDiff = options.diffed;
|
|
25
|
+
let oldCommit = options._commit;
|
|
26
|
+
let oldBeforeUnmount = options.unmount;
|
|
27
|
+
|
|
28
|
+
const RAF_TIMEOUT = 100;
|
|
29
|
+
let prevRaf;
|
|
30
|
+
|
|
31
|
+
options._diff = vnode => {
|
|
32
|
+
currentComponent = null;
|
|
33
|
+
if (oldBeforeDiff) oldBeforeDiff(vnode);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
options._render = vnode => {
|
|
37
|
+
if (oldBeforeRender) oldBeforeRender(vnode);
|
|
38
|
+
|
|
39
|
+
currentComponent = vnode._component;
|
|
40
|
+
currentIndex = 0;
|
|
41
|
+
|
|
42
|
+
const hooks = currentComponent.__hooks;
|
|
43
|
+
if (hooks) {
|
|
44
|
+
hooks._pendingEffects.forEach(invokeCleanup);
|
|
45
|
+
hooks._pendingEffects.forEach(invokeEffect);
|
|
46
|
+
hooks._pendingEffects = [];
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
options.diffed = vnode => {
|
|
51
|
+
if (oldAfterDiff) oldAfterDiff(vnode);
|
|
52
|
+
|
|
53
|
+
const c = vnode._component;
|
|
54
|
+
if (c && c.__hooks && c.__hooks._pendingEffects.length) {
|
|
55
|
+
afterPaint(afterPaintEffects.push(c));
|
|
56
|
+
}
|
|
57
|
+
currentComponent = previousComponent;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
options._commit = (vnode, commitQueue) => {
|
|
61
|
+
commitQueue.some(component => {
|
|
62
|
+
try {
|
|
63
|
+
component._renderCallbacks.forEach(invokeCleanup);
|
|
64
|
+
component._renderCallbacks = component._renderCallbacks.filter(cb =>
|
|
65
|
+
cb._value ? invokeEffect(cb) : true
|
|
66
|
+
);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
commitQueue.some(c => {
|
|
69
|
+
if (c._renderCallbacks) c._renderCallbacks = [];
|
|
70
|
+
});
|
|
71
|
+
commitQueue = [];
|
|
72
|
+
options._catchError(e, component._vnode);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (oldCommit) oldCommit(vnode, commitQueue);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
options.unmount = vnode => {
|
|
80
|
+
if (oldBeforeUnmount) oldBeforeUnmount(vnode);
|
|
81
|
+
|
|
82
|
+
const c = vnode._component;
|
|
83
|
+
if (c && c.__hooks) {
|
|
84
|
+
try {
|
|
85
|
+
c.__hooks._list.forEach(invokeCleanup);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
options._catchError(e, c._vnode);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Get a hook's state from the currentComponent
|
|
94
|
+
* @param {number} index The index of the hook to get
|
|
95
|
+
* @param {number} type The index of the hook to get
|
|
96
|
+
* @returns {any}
|
|
97
|
+
*/
|
|
98
|
+
function getHookState(index, type) {
|
|
99
|
+
if (options._hook) {
|
|
100
|
+
options._hook(currentComponent, index, currentHook || type);
|
|
101
|
+
}
|
|
102
|
+
currentHook = 0;
|
|
103
|
+
|
|
104
|
+
// Largely inspired by:
|
|
105
|
+
// * https://github.com/michael-klein/funcy.js/blob/f6be73468e6ec46b0ff5aa3cc4c9baf72a29025a/src/hooks/core_hooks.mjs
|
|
106
|
+
// * https://github.com/michael-klein/funcy.js/blob/650beaa58c43c33a74820a3c98b3c7079cf2e333/src/renderer.mjs
|
|
107
|
+
// Other implementations to look at:
|
|
108
|
+
// * https://codesandbox.io/s/mnox05qp8
|
|
109
|
+
const hooks =
|
|
110
|
+
currentComponent.__hooks ||
|
|
111
|
+
(currentComponent.__hooks = {
|
|
112
|
+
_list: [],
|
|
113
|
+
_pendingEffects: []
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (index >= hooks._list.length) {
|
|
117
|
+
hooks._list.push({});
|
|
118
|
+
}
|
|
119
|
+
return hooks._list[index];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {import('./index').StateUpdater<any>} [initialState]
|
|
124
|
+
*/
|
|
125
|
+
export function useState(initialState) {
|
|
126
|
+
currentHook = 1;
|
|
127
|
+
return useReducer(invokeOrReturn, initialState);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @param {import('./index').Reducer<any, any>} reducer
|
|
132
|
+
* @param {import('./index').StateUpdater<any>} initialState
|
|
133
|
+
* @param {(initialState: any) => void} [init]
|
|
134
|
+
* @returns {[ any, (state: any) => void ]}
|
|
135
|
+
*/
|
|
136
|
+
export function useReducer(reducer, initialState, init) {
|
|
137
|
+
/** @type {import('./internal').ReducerHookState} */
|
|
138
|
+
const hookState = getHookState(currentIndex++, 2);
|
|
139
|
+
hookState._reducer = reducer;
|
|
140
|
+
if (!hookState._component) {
|
|
141
|
+
hookState._value = [
|
|
142
|
+
!init ? invokeOrReturn(undefined, initialState) : init(initialState),
|
|
143
|
+
|
|
144
|
+
action => {
|
|
145
|
+
const nextValue = hookState._reducer(hookState._value[0], action);
|
|
146
|
+
if (hookState._value[0] !== nextValue) {
|
|
147
|
+
hookState._value = [nextValue, hookState._value[1]];
|
|
148
|
+
hookState._component.setState({});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
hookState._component = currentComponent;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return hookState._value;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @param {import('./internal').Effect} callback
|
|
161
|
+
* @param {any[]} args
|
|
162
|
+
*/
|
|
163
|
+
export function useEffect(callback, args) {
|
|
164
|
+
/** @type {import('./internal').EffectHookState} */
|
|
165
|
+
const state = getHookState(currentIndex++, 3);
|
|
166
|
+
if (!options._skipEffects && argsChanged(state._args, args)) {
|
|
167
|
+
state._value = callback;
|
|
168
|
+
state._args = args;
|
|
169
|
+
|
|
170
|
+
currentComponent.__hooks._pendingEffects.push(state);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @param {import('./internal').Effect} callback
|
|
176
|
+
* @param {any[]} args
|
|
177
|
+
*/
|
|
178
|
+
export function useLayoutEffect(callback, args) {
|
|
179
|
+
/** @type {import('./internal').EffectHookState} */
|
|
180
|
+
const state = getHookState(currentIndex++, 4);
|
|
181
|
+
if (!options._skipEffects && argsChanged(state._args, args)) {
|
|
182
|
+
state._value = callback;
|
|
183
|
+
state._args = args;
|
|
184
|
+
|
|
185
|
+
currentComponent._renderCallbacks.push(state);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function useRef(initialValue) {
|
|
190
|
+
currentHook = 5;
|
|
191
|
+
return useMemo(() => ({ current: initialValue }), []);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @param {object} ref
|
|
196
|
+
* @param {() => object} createHandle
|
|
197
|
+
* @param {any[]} args
|
|
198
|
+
*/
|
|
199
|
+
export function useImperativeHandle(ref, createHandle, args) {
|
|
200
|
+
currentHook = 6;
|
|
201
|
+
useLayoutEffect(
|
|
202
|
+
() => {
|
|
203
|
+
if (typeof ref == 'function') ref(createHandle());
|
|
204
|
+
else if (ref) ref.current = createHandle();
|
|
205
|
+
},
|
|
206
|
+
args == null ? args : args.concat(ref)
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @param {() => any} factory
|
|
212
|
+
* @param {any[]} args
|
|
213
|
+
*/
|
|
214
|
+
export function useMemo(factory, args) {
|
|
215
|
+
/** @type {import('./internal').MemoHookState} */
|
|
216
|
+
const state = getHookState(currentIndex++, 7);
|
|
217
|
+
if (argsChanged(state._args, args)) {
|
|
218
|
+
state._value = factory();
|
|
219
|
+
state._args = args;
|
|
220
|
+
state._factory = factory;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return state._value;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @param {() => void} callback
|
|
228
|
+
* @param {any[]} args
|
|
229
|
+
*/
|
|
230
|
+
export function useCallback(callback, args) {
|
|
231
|
+
currentHook = 8;
|
|
232
|
+
return useMemo(() => callback, args);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @param {import('./internal').PreactContext} context
|
|
237
|
+
*/
|
|
238
|
+
export function useContext(context) {
|
|
239
|
+
const provider = currentComponent.context[context._id];
|
|
240
|
+
// We could skip this call here, but than we'd not call
|
|
241
|
+
// `options._hook`. We need to do that in order to make
|
|
242
|
+
// the devtools aware of this hook.
|
|
243
|
+
/** @type {import('./internal').ContextHookState} */
|
|
244
|
+
const state = getHookState(currentIndex++, 9);
|
|
245
|
+
// The devtools needs access to the context object to
|
|
246
|
+
// be able to pull of the default value when no provider
|
|
247
|
+
// is present in the tree.
|
|
248
|
+
state._context = context;
|
|
249
|
+
if (!provider) return context._defaultValue;
|
|
250
|
+
// This is probably not safe to convert to "!"
|
|
251
|
+
if (state._value == null) {
|
|
252
|
+
state._value = true;
|
|
253
|
+
provider.sub(currentComponent);
|
|
254
|
+
}
|
|
255
|
+
return provider.props.value;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Display a custom label for a custom hook for the devtools panel
|
|
260
|
+
* @type {<T>(value: T, cb?: (value: T) => string | number) => void}
|
|
261
|
+
*/
|
|
262
|
+
export function useDebugValue(value, formatter) {
|
|
263
|
+
if (options.useDebugValue) {
|
|
264
|
+
options.useDebugValue(formatter ? formatter(value) : value);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* @param {(error: any) => void} cb
|
|
270
|
+
*/
|
|
271
|
+
export function useErrorBoundary(cb) {
|
|
272
|
+
/** @type {import('./internal').ErrorBoundaryHookState} */
|
|
273
|
+
const state = getHookState(currentIndex++, 10);
|
|
274
|
+
const errState = useState();
|
|
275
|
+
state._value = cb;
|
|
276
|
+
if (!currentComponent.componentDidCatch) {
|
|
277
|
+
currentComponent.componentDidCatch = err => {
|
|
278
|
+
if (state._value) state._value(err);
|
|
279
|
+
errState[1](err);
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
return [
|
|
283
|
+
errState[0],
|
|
284
|
+
() => {
|
|
285
|
+
errState[1](undefined);
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* After paint effects consumer.
|
|
292
|
+
*/
|
|
293
|
+
function flushAfterPaintEffects() {
|
|
294
|
+
afterPaintEffects.forEach(component => {
|
|
295
|
+
if (component._parentDom) {
|
|
296
|
+
try {
|
|
297
|
+
component.__hooks._pendingEffects.forEach(invokeCleanup);
|
|
298
|
+
component.__hooks._pendingEffects.forEach(invokeEffect);
|
|
299
|
+
component.__hooks._pendingEffects = [];
|
|
300
|
+
} catch (e) {
|
|
301
|
+
component.__hooks._pendingEffects = [];
|
|
302
|
+
options._catchError(e, component._vnode);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
afterPaintEffects = [];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
let HAS_RAF = typeof requestAnimationFrame == 'function';
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Schedule a callback to be invoked after the browser has a chance to paint a new frame.
|
|
313
|
+
* Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after
|
|
314
|
+
* the next browser frame.
|
|
315
|
+
*
|
|
316
|
+
* Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked
|
|
317
|
+
* even if RAF doesn't fire (for example if the browser tab is not visible)
|
|
318
|
+
*
|
|
319
|
+
* @param {() => void} callback
|
|
320
|
+
*/
|
|
321
|
+
function afterNextFrame(callback) {
|
|
322
|
+
const done = () => {
|
|
323
|
+
clearTimeout(timeout);
|
|
324
|
+
if (HAS_RAF) cancelAnimationFrame(raf);
|
|
325
|
+
setTimeout(callback);
|
|
326
|
+
};
|
|
327
|
+
const timeout = setTimeout(done, RAF_TIMEOUT);
|
|
328
|
+
|
|
329
|
+
let raf;
|
|
330
|
+
if (HAS_RAF) {
|
|
331
|
+
raf = requestAnimationFrame(done);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Note: if someone used options.debounceRendering = requestAnimationFrame,
|
|
336
|
+
// then effects will ALWAYS run on the NEXT frame instead of the current one, incurring a ~16ms delay.
|
|
337
|
+
// Perhaps this is not such a big deal.
|
|
338
|
+
/**
|
|
339
|
+
* Schedule afterPaintEffects flush after the browser paints
|
|
340
|
+
* @param {number} newQueueLength
|
|
341
|
+
*/
|
|
342
|
+
function afterPaint(newQueueLength) {
|
|
343
|
+
if (newQueueLength === 1 || prevRaf !== options.requestAnimationFrame) {
|
|
344
|
+
prevRaf = options.requestAnimationFrame;
|
|
345
|
+
(prevRaf || afterNextFrame)(flushAfterPaintEffects);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* @param {import('./internal').EffectHookState} hook
|
|
351
|
+
*/
|
|
352
|
+
function invokeCleanup(hook) {
|
|
353
|
+
// A hook cleanup can introduce a call to render which creates a new root, this will call options.vnode
|
|
354
|
+
// and move the currentComponent away.
|
|
355
|
+
const comp = currentComponent;
|
|
356
|
+
if (typeof hook._cleanup == 'function') hook._cleanup();
|
|
357
|
+
currentComponent = comp;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Invoke a Hook's effect
|
|
362
|
+
* @param {import('./internal').EffectHookState} hook
|
|
363
|
+
*/
|
|
364
|
+
function invokeEffect(hook) {
|
|
365
|
+
// A hook call can introduce a call to render which creates a new root, this will call options.vnode
|
|
366
|
+
// and move the currentComponent away.
|
|
367
|
+
const comp = currentComponent;
|
|
368
|
+
hook._cleanup = hook._value();
|
|
369
|
+
currentComponent = comp;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @param {any[]} oldArgs
|
|
374
|
+
* @param {any[]} newArgs
|
|
375
|
+
*/
|
|
376
|
+
function argsChanged(oldArgs, newArgs) {
|
|
377
|
+
return (
|
|
378
|
+
!oldArgs ||
|
|
379
|
+
oldArgs.length !== newArgs.length ||
|
|
380
|
+
newArgs.some((arg, index) => arg !== oldArgs[index])
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function invokeOrReturn(arg, f) {
|
|
385
|
+
return typeof f == 'function' ? f(arg) : f;
|
|
386
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component as PreactComponent,
|
|
3
|
+
PreactContext
|
|
4
|
+
} from '../../src/internal';
|
|
5
|
+
import { Reducer } from '.';
|
|
6
|
+
|
|
7
|
+
export { PreactContext };
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The type of arguments passed to a Hook function. While this type is not
|
|
11
|
+
* strictly necessary, they are given a type name to make it easier to read
|
|
12
|
+
* the following types and trace the flow of data.
|
|
13
|
+
*/
|
|
14
|
+
export type HookArgs = any;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The return type of a Hook function. While this type is not
|
|
18
|
+
* strictly necessary, they are given a type name to make it easier to read
|
|
19
|
+
* the following types and trace the flow of data.
|
|
20
|
+
*/
|
|
21
|
+
export type HookReturnValue = any;
|
|
22
|
+
|
|
23
|
+
/** The public function a user invokes to use a Hook */
|
|
24
|
+
export type Hook = (...args: HookArgs[]) => HookReturnValue;
|
|
25
|
+
|
|
26
|
+
// Hook tracking
|
|
27
|
+
|
|
28
|
+
export interface ComponentHooks {
|
|
29
|
+
/** The list of hooks a component uses */
|
|
30
|
+
_list: HookState[];
|
|
31
|
+
/** List of Effects to be invoked after the next frame is rendered */
|
|
32
|
+
_pendingEffects: EffectHookState[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface Component extends PreactComponent<any, any> {
|
|
36
|
+
__hooks?: ComponentHooks;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type HookState =
|
|
40
|
+
| EffectHookState
|
|
41
|
+
| MemoHookState
|
|
42
|
+
| ReducerHookState
|
|
43
|
+
| ContextHookState
|
|
44
|
+
| ErrorBoundaryHookState;
|
|
45
|
+
|
|
46
|
+
export type Effect = () => void | Cleanup;
|
|
47
|
+
export type Cleanup = () => void;
|
|
48
|
+
|
|
49
|
+
export interface EffectHookState {
|
|
50
|
+
_value?: Effect;
|
|
51
|
+
_args?: any[];
|
|
52
|
+
_cleanup?: Cleanup | void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface MemoHookState {
|
|
56
|
+
_value?: any;
|
|
57
|
+
_args?: any[];
|
|
58
|
+
_factory?: () => any;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface ReducerHookState {
|
|
62
|
+
_value?: any;
|
|
63
|
+
_component?: Component;
|
|
64
|
+
_reducer?: Reducer<any, any>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ContextHookState {
|
|
68
|
+
/** Whether this hooks as subscribed to updates yet */
|
|
69
|
+
_value?: boolean;
|
|
70
|
+
_context?: PreactContext;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ErrorBoundaryHookState {
|
|
74
|
+
_value?: (error: any) => void;
|
|
75
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var r=require("../..");function _(_,e,o,n,t){var l={};for(var u in e)"ref"!=u&&(l[u]=e[u]);var f,i,p={type:_,props:l,key:o,ref:e&&e.ref,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:++r.options.__v,__source:n,__self:t};if("function"==typeof _&&(f=_.defaultProps))for(i in f)void 0===l[i]&&(l[i]=f[i]);return r.options.vnode&&r.options.vnode(p),p}exports.Fragment=r.Fragment,exports.jsx=_,exports.jsxs=_,exports.jsxDEV=_;
|
|
2
|
+
//# sourceMappingURL=jsxRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsxRuntime.js","sources":["../src/index.js"],"sourcesContent":["import { options, Fragment } from '../..';\n\n/** @typedef {import('preact').VNode} VNode */\n\n/**\n * @fileoverview\n * This file exports various methods that implement Babel's \"automatic\" JSX runtime API:\n * - jsx(type, props, key)\n * - jsxs(type, props, key)\n * - jsxDEV(type, props, key, __source, __self)\n *\n * The implementation of createVNode here is optimized for performance.\n * Benchmarks: https://esbench.com/bench/5f6b54a0b4632100a7dcd2b3\n */\n\n/**\n * JSX.Element factory used by Babel's {runtime:\"automatic\"} JSX transform\n * @param {VNode['type']} type\n * @param {VNode['props']} props\n * @param {VNode['key']} [key]\n * @param {string} [__source]\n * @param {string} [__self]\n */\nfunction createVNode(type, props, key, __source, __self) {\n\t// We'll want to preserve `ref` in props to get rid of the need for\n\t// forwardRef components in the future, but that should happen via\n\t// a separate PR.\n\tlet normalizedProps = {};\n\tfor (let i in props) {\n\t\tif (i != 'ref') {\n\t\t\tnormalizedProps[i] = props[i];\n\t\t}\n\t}\n\n\tconst vnode = {\n\t\ttype,\n\t\tprops: normalizedProps,\n\t\tkey,\n\t\tref: props && props.ref,\n\t\t_children: null,\n\t\t_parent: null,\n\t\t_depth: 0,\n\t\t_dom: null,\n\t\t_nextDom: undefined,\n\t\t_component: null,\n\t\t_hydrating: null,\n\t\tconstructor: undefined,\n\t\t_original: ++options._vnodeId,\n\t\t__source,\n\t\t__self\n\t};\n\n\t// If a Component VNode, check for and apply defaultProps.\n\t// Note: `type` is often a String, and can be `undefined` in development.\n\tlet defaults, i;\n\tif (typeof type === 'function' && (defaults = type.defaultProps)) {\n\t\tfor (i in defaults)\n\t\t\tif (normalizedProps[i] === undefined) {\n\t\t\t\tnormalizedProps[i] = defaults[i];\n\t\t\t}\n\t}\n\n\tif (options.vnode) options.vnode(vnode);\n\treturn vnode;\n}\n\nexport {\n\tcreateVNode as jsx,\n\tcreateVNode as jsxs,\n\tcreateVNode as jsxDEV,\n\tFragment\n};\n"],"names":["createVNode","type","props","key","__source","__self","normalizedProps","i","defaults","vnode","ref","undefined","constructor","options","defaultProps"],"mappings":"wBAuBA,SAASA,EAAYC,EAAMC,EAAOC,EAAKC,EAAUC,OAI5CC,EAAkB,OACjB,IAAIC,KAAKL,EACJ,OAALK,IACHD,EAAgBC,GAAKL,EAAMK,QAwBzBC,EAAUD,EApBRE,EAAQ,CACbR,KAAAA,EACAC,MAAOI,EACPH,IAAAA,EACAO,IAAKR,GAASA,EAAMQ,QACT,QACF,SACD,MACF,cACIC,MACE,SACA,KACZC,iBAAaD,QACAE,cACbT,SAAAA,EACAC,OAAAA,MAMmB,mBAATJ,IAAwBO,EAAWP,EAAKa,kBAC7CP,KAAKC,OACkBG,IAAvBL,EAAgBC,KACnBD,EAAgBC,GAAKC,EAASD,WAI7BM,UAAQJ,OAAOI,UAAQJ,MAAMA,GAC1BA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{options as r,Fragment as _}from"../..";export{Fragment}from"../..";function o(_,o,e,n,t){var f={};for(var l in o)"ref"!=l&&(f[l]=o[l]);var s,u,a={type:_,props:f,key:e,ref:o&&o.ref,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:++r.__v,__source:n,__self:t};if("function"==typeof _&&(s=_.defaultProps))for(u in s)void 0===f[u]&&(f[u]=s[u]);return r.vnode&&r.vnode(a),a}export{o as jsx,o as jsxs,o as jsxDEV};
|
|
2
|
+
//# sourceMappingURL=jsxRuntime.module.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{options as r,Fragment as _}from"../..";export{Fragment}from"../..";function o(_,o,e,n,t){var f={};for(var l in o)"ref"!=l&&(f[l]=o[l]);var s,u,a={type:_,props:f,key:e,ref:o&&o.ref,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:++r.__v,__source:n,__self:t};if("function"==typeof _&&(s=_.defaultProps))for(u in s)void 0===f[u]&&(f[u]=s[u]);return r.vnode&&r.vnode(a),a}export{o as jsx,o as jsxs,o as jsxDEV};
|
|
2
|
+
//# sourceMappingURL=jsxRuntime.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsxRuntime.module.js","sources":["../src/index.js"],"sourcesContent":["import { options, Fragment } from '../..';\n\n/** @typedef {import('preact').VNode} VNode */\n\n/**\n * @fileoverview\n * This file exports various methods that implement Babel's \"automatic\" JSX runtime API:\n * - jsx(type, props, key)\n * - jsxs(type, props, key)\n * - jsxDEV(type, props, key, __source, __self)\n *\n * The implementation of createVNode here is optimized for performance.\n * Benchmarks: https://esbench.com/bench/5f6b54a0b4632100a7dcd2b3\n */\n\n/**\n * JSX.Element factory used by Babel's {runtime:\"automatic\"} JSX transform\n * @param {VNode['type']} type\n * @param {VNode['props']} props\n * @param {VNode['key']} [key]\n * @param {string} [__source]\n * @param {string} [__self]\n */\nfunction createVNode(type, props, key, __source, __self) {\n\t// We'll want to preserve `ref` in props to get rid of the need for\n\t// forwardRef components in the future, but that should happen via\n\t// a separate PR.\n\tlet normalizedProps = {};\n\tfor (let i in props) {\n\t\tif (i != 'ref') {\n\t\t\tnormalizedProps[i] = props[i];\n\t\t}\n\t}\n\n\tconst vnode = {\n\t\ttype,\n\t\tprops: normalizedProps,\n\t\tkey,\n\t\tref: props && props.ref,\n\t\t_children: null,\n\t\t_parent: null,\n\t\t_depth: 0,\n\t\t_dom: null,\n\t\t_nextDom: undefined,\n\t\t_component: null,\n\t\t_hydrating: null,\n\t\tconstructor: undefined,\n\t\t_original: ++options._vnodeId,\n\t\t__source,\n\t\t__self\n\t};\n\n\t// If a Component VNode, check for and apply defaultProps.\n\t// Note: `type` is often a String, and can be `undefined` in development.\n\tlet defaults, i;\n\tif (typeof type === 'function' && (defaults = type.defaultProps)) {\n\t\tfor (i in defaults)\n\t\t\tif (normalizedProps[i] === undefined) {\n\t\t\t\tnormalizedProps[i] = defaults[i];\n\t\t\t}\n\t}\n\n\tif (options.vnode) options.vnode(vnode);\n\treturn vnode;\n}\n\nexport {\n\tcreateVNode as jsx,\n\tcreateVNode as jsxs,\n\tcreateVNode as jsxDEV,\n\tFragment\n};\n"],"names":["createVNode","type","props","key","__source","__self","normalizedProps","i","defaults","vnode","ref","undefined","constructor","options","defaultProps"],"mappings":"4EAuBA,SAASA,EAAYC,EAAMC,EAAOC,EAAKC,EAAUC,OAI5CC,EAAkB,OACjB,IAAIC,KAAKL,EACJ,OAALK,IACHD,EAAgBC,GAAKL,EAAMK,QAwBzBC,EAAUD,EApBRE,EAAQ,CACbR,KAAAA,EACAC,MAAOI,EACPH,IAAAA,EACAO,IAAKR,GAASA,EAAMQ,QACT,QACF,SACD,MACF,cACIC,MACE,SACA,KACZC,iBAAaD,QACAE,MACbT,SAAAA,EACAC,OAAAA,MAMmB,mBAATJ,IAAwBO,EAAWP,EAAKa,kBAC7CP,KAAKC,OACkBG,IAAvBL,EAAgBC,KACnBD,EAAgBC,GAAKC,EAASD,WAI7BM,EAAQJ,OAAOI,EAAQJ,MAAMA,GAC1BA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("../..")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n(e.jsxRuntime={},e.preact)}(this,function(e,n){function o(e,o,r,t,_){var f={};for(var i in o)"ref"!=i&&(f[i]=o[i]);var u,c,l={type:e,props:f,key:r,ref:o&&o.ref,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:++n.options.__v,__source:t,__self:_};if("function"==typeof e&&(u=e.defaultProps))for(c in u)void 0===f[c]&&(f[c]=u[c]);return n.options.vnode&&n.options.vnode(l),l}e.Fragment=n.Fragment,e.jsx=o,e.jsxs=o,e.jsxDEV=o});
|
|
2
|
+
//# sourceMappingURL=jsxRuntime.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsxRuntime.umd.js","sources":["../src/index.js"],"sourcesContent":["import { options, Fragment } from '../..';\n\n/** @typedef {import('preact').VNode} VNode */\n\n/**\n * @fileoverview\n * This file exports various methods that implement Babel's \"automatic\" JSX runtime API:\n * - jsx(type, props, key)\n * - jsxs(type, props, key)\n * - jsxDEV(type, props, key, __source, __self)\n *\n * The implementation of createVNode here is optimized for performance.\n * Benchmarks: https://esbench.com/bench/5f6b54a0b4632100a7dcd2b3\n */\n\n/**\n * JSX.Element factory used by Babel's {runtime:\"automatic\"} JSX transform\n * @param {VNode['type']} type\n * @param {VNode['props']} props\n * @param {VNode['key']} [key]\n * @param {string} [__source]\n * @param {string} [__self]\n */\nfunction createVNode(type, props, key, __source, __self) {\n\t// We'll want to preserve `ref` in props to get rid of the need for\n\t// forwardRef components in the future, but that should happen via\n\t// a separate PR.\n\tlet normalizedProps = {};\n\tfor (let i in props) {\n\t\tif (i != 'ref') {\n\t\t\tnormalizedProps[i] = props[i];\n\t\t}\n\t}\n\n\tconst vnode = {\n\t\ttype,\n\t\tprops: normalizedProps,\n\t\tkey,\n\t\tref: props && props.ref,\n\t\t_children: null,\n\t\t_parent: null,\n\t\t_depth: 0,\n\t\t_dom: null,\n\t\t_nextDom: undefined,\n\t\t_component: null,\n\t\t_hydrating: null,\n\t\tconstructor: undefined,\n\t\t_original: ++options._vnodeId,\n\t\t__source,\n\t\t__self\n\t};\n\n\t// If a Component VNode, check for and apply defaultProps.\n\t// Note: `type` is often a String, and can be `undefined` in development.\n\tlet defaults, i;\n\tif (typeof type === 'function' && (defaults = type.defaultProps)) {\n\t\tfor (i in defaults)\n\t\t\tif (normalizedProps[i] === undefined) {\n\t\t\t\tnormalizedProps[i] = defaults[i];\n\t\t\t}\n\t}\n\n\tif (options.vnode) options.vnode(vnode);\n\treturn vnode;\n}\n\nexport {\n\tcreateVNode as jsx,\n\tcreateVNode as jsxs,\n\tcreateVNode as jsxDEV,\n\tFragment\n};\n"],"names":["createVNode","type","props","key","__source","__self","normalizedProps","i","defaults","vnode","ref","undefined","constructor","options","defaultProps"],"mappings":"sNAuBA,SAASA,EAAYC,EAAMC,EAAOC,EAAKC,EAAUC,OAI5CC,EAAkB,OACjB,IAAIC,KAAKL,EACJ,OAALK,IACHD,EAAgBC,GAAKL,EAAMK,QAwBzBC,EAAUD,EApBRE,EAAQ,CACbR,KAAAA,EACAC,MAAOI,EACPH,IAAAA,EACAO,IAAKR,GAASA,EAAMQ,QACT,QACF,SACD,MACF,cACIC,MACE,SACA,KACZC,iBAAaD,QACAE,cACbT,SAAAA,EACAC,OAAAA,MAMmB,mBAATJ,IAAwBO,EAAWP,EAAKa,kBAC7CP,KAAKC,OACkBG,IAAvBL,EAAgBC,KACnBD,EAAgBC,GAAKC,EAASD,WAI7BM,UAAQJ,OAAOI,UAAQJ,MAAMA,GAC1BA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jsx-runtime",
|
|
3
|
+
"amdName": "jsxRuntime",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"private": true,
|
|
6
|
+
"description": "Preact JSX runtime",
|
|
7
|
+
"main": "dist/jsxRuntime.js",
|
|
8
|
+
"module": "dist/jsxRuntime.module.js",
|
|
9
|
+
"umd:main": "dist/jsxRuntime.umd.js",
|
|
10
|
+
"source": "src/index.js",
|
|
11
|
+
"types": "src/index.d.ts",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"preact": "^10.0.0"
|
|
15
|
+
},
|
|
16
|
+
"mangle": {
|
|
17
|
+
"regex": "^_"
|
|
18
|
+
}
|
|
19
|
+
}
|