isomorfeus-preact 10.9.0 → 22.9.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +14 -3
- data/README.md +23 -39
- data/lib/browser/delegate_native.rb +94 -72
- data/lib/browser/document.rb +38 -0
- data/lib/browser/element.rb +160 -176
- data/lib/browser/event.rb +99 -94
- data/lib/browser/history.rb +40 -20
- data/lib/browser/location.rb +59 -0
- data/lib/browser/window.rb +58 -0
- data/lib/data_uri/open_uri.rb +18 -0
- data/lib/data_uri/uri.rb +61 -0
- data/lib/data_uri.rb +4 -0
- data/lib/isomorfeus/preact/config.rb +42 -54
- data/lib/isomorfeus/preact/imports.rb +5 -20
- data/lib/isomorfeus/preact/ssr.rb +34 -0
- data/lib/isomorfeus/preact/thread_local_component_cache.rb +9 -11
- data/lib/isomorfeus/preact/version.rb +5 -0
- data/lib/isomorfeus/preact/view_helper.rb +72 -0
- data/lib/isomorfeus/props/validator.rb +19 -11
- data/lib/isomorfeus/top_level.rb +55 -33
- data/lib/isomorfeus-preact.rb +78 -103
- data/lib/link.rb +52 -0
- data/lib/lucid_app.rb +117 -0
- data/lib/lucid_component.rb +154 -0
- data/lib/nano_css.rb +282 -465
- data/lib/preact/component.rb +222 -0
- data/lib/preact/component_resolution.rb +49 -83
- data/lib/preact/context.rb +68 -0
- data/lib/preact/elements.rb +2 -9
- data/lib/preact/module_component_resolution.rb +50 -0
- data/lib/preact/prop_declaration_mixin.rb +73 -0
- data/lib/preact.rb +1548 -257
- data/lib/redirect.rb +34 -0
- data/lib/route.rb +15 -0
- data/lib/router.rb +145 -0
- data/lib/switch.rb +70 -0
- data/opal/iso_uri.rb +29 -0
- data/opal/uri/common.rb +18 -0
- data/opal/uri/generic.rb +47 -0
- metadata +45 -309
- data/lib/isomorfeus/preact/memcached_component_cache.rb +0 -19
- data/lib/isomorfeus/preact/redis_component_cache.rb +0 -19
- data/lib/isomorfeus/preact/ssr/history.rb +0 -23
- data/lib/isomorfeus/preact/ssr/render_core.rb +0 -117
- data/lib/isomorfeus/preact/ssr/top_level.rb +0 -37
- data/lib/isomorfeus/preact_view_helper.rb +0 -129
- data/lib/isomorfeus_preact/lucid_app/api.rb +0 -38
- data/lib/isomorfeus_preact/lucid_app/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_app/mixin.rb +0 -14
- data/lib/isomorfeus_preact/lucid_app/native_component_constructor.rb +0 -101
- data/lib/isomorfeus_preact/lucid_component/api.rb +0 -123
- data/lib/isomorfeus_preact/lucid_component/app_store_proxy.rb +0 -32
- data/lib/isomorfeus_preact/lucid_component/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_component/class_store_proxy.rb +0 -37
- data/lib/isomorfeus_preact/lucid_component/initializer.rb +0 -9
- data/lib/isomorfeus_preact/lucid_component/mixin.rb +0 -13
- data/lib/isomorfeus_preact/lucid_component/native_component_constructor.rb +0 -87
- data/lib/isomorfeus_preact/lucid_component/styles_wrapper.rb +0 -40
- data/lib/isomorfeus_preact/lucid_func/base.rb +0 -7
- data/lib/isomorfeus_preact/lucid_func/initializer.rb +0 -8
- data/lib/isomorfeus_preact/lucid_func/mixin.rb +0 -10
- data/lib/isomorfeus_preact/lucid_func/native_component_constructor.rb +0 -56
- data/lib/isomorfeus_preact/preact/function_component/api.rb +0 -164
- data/lib/isomorfeus_preact/preact/function_component/base.rb +0 -7
- data/lib/isomorfeus_preact/preact/function_component/initializer.rb +0 -6
- data/lib/isomorfeus_preact/preact/function_component/mixin.rb +0 -8
- data/lib/isomorfeus_preact/preact/function_component/native_component_constructor.rb +0 -47
- data/lib/lucid_app/context.rb +0 -24
- data/lib/lucid_prop_declaration/mixin.rb +0 -126
- data/lib/preact/component/api.rb +0 -137
- data/lib/preact/component/base.rb +0 -7
- data/lib/preact/component/callbacks.rb +0 -111
- data/lib/preact/component/initializer.rb +0 -7
- data/lib/preact/component/mixin.rb +0 -11
- data/lib/preact/component/native_component_constructor.rb +0 -77
- data/lib/preact/context_wrapper.rb +0 -48
- data/lib/preact/native_constant_wrapper.rb +0 -29
- data/lib/preact/option_hooks.rb +0 -98
- data/lib/preact/params.rb +0 -16
- data/lib/preact/props.rb +0 -69
- data/lib/preact/ref.rb +0 -17
- data/lib/preact/state.rb +0 -87
- data/lib/preact/version.rb +0 -3
- data/node_modules/.package-lock.json +0 -38
- data/node_modules/preact/LICENSE +0 -21
- data/node_modules/preact/README.md +0 -188
- data/node_modules/preact/compat/LICENSE +0 -21
- data/node_modules/preact/compat/client.js +0 -19
- data/node_modules/preact/compat/client.mjs +0 -17
- data/node_modules/preact/compat/dist/compat.js +0 -2
- data/node_modules/preact/compat/dist/compat.js.map +0 -1
- data/node_modules/preact/compat/dist/compat.mjs +0 -2
- data/node_modules/preact/compat/dist/compat.module.js +0 -2
- data/node_modules/preact/compat/dist/compat.module.js.map +0 -1
- data/node_modules/preact/compat/dist/compat.umd.js +0 -2
- data/node_modules/preact/compat/dist/compat.umd.js.map +0 -1
- data/node_modules/preact/compat/jsx-dev-runtime.js +0 -3
- data/node_modules/preact/compat/jsx-dev-runtime.mjs +0 -3
- data/node_modules/preact/compat/jsx-runtime.js +0 -3
- data/node_modules/preact/compat/jsx-runtime.mjs +0 -3
- data/node_modules/preact/compat/package.json +0 -49
- data/node_modules/preact/compat/scheduler.js +0 -15
- data/node_modules/preact/compat/scheduler.mjs +0 -23
- data/node_modules/preact/compat/server.browser.js +0 -4
- data/node_modules/preact/compat/server.js +0 -15
- data/node_modules/preact/compat/server.mjs +0 -4
- data/node_modules/preact/compat/src/Children.js +0 -21
- data/node_modules/preact/compat/src/PureComponent.js +0 -15
- data/node_modules/preact/compat/src/forwardRef.js +0 -44
- data/node_modules/preact/compat/src/index.d.ts +0 -164
- data/node_modules/preact/compat/src/index.js +0 -223
- data/node_modules/preact/compat/src/internal.d.ts +0 -47
- data/node_modules/preact/compat/src/memo.js +0 -34
- data/node_modules/preact/compat/src/portals.js +0 -82
- data/node_modules/preact/compat/src/render.js +0 -238
- data/node_modules/preact/compat/src/suspense-list.d.ts +0 -14
- data/node_modules/preact/compat/src/suspense-list.js +0 -126
- data/node_modules/preact/compat/src/suspense.d.ts +0 -15
- data/node_modules/preact/compat/src/suspense.js +0 -270
- data/node_modules/preact/compat/src/util.js +0 -28
- data/node_modules/preact/compat/test-utils.js +0 -1
- data/node_modules/preact/debug/LICENSE +0 -21
- data/node_modules/preact/debug/dist/debug.js +0 -2
- data/node_modules/preact/debug/dist/debug.js.map +0 -1
- data/node_modules/preact/debug/dist/debug.mjs +0 -2
- data/node_modules/preact/debug/dist/debug.module.js +0 -2
- data/node_modules/preact/debug/dist/debug.module.js.map +0 -1
- data/node_modules/preact/debug/dist/debug.umd.js +0 -2
- data/node_modules/preact/debug/dist/debug.umd.js.map +0 -1
- data/node_modules/preact/debug/package.json +0 -26
- data/node_modules/preact/debug/src/check-props.js +0 -54
- data/node_modules/preact/debug/src/component-stack.js +0 -146
- data/node_modules/preact/debug/src/constants.js +0 -3
- data/node_modules/preact/debug/src/debug.js +0 -437
- data/node_modules/preact/debug/src/index.js +0 -6
- data/node_modules/preact/debug/src/internal.d.ts +0 -82
- data/node_modules/preact/debug/src/util.js +0 -11
- data/node_modules/preact/devtools/LICENSE +0 -21
- data/node_modules/preact/devtools/dist/devtools.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.js.map +0 -1
- data/node_modules/preact/devtools/dist/devtools.mjs +0 -2
- data/node_modules/preact/devtools/dist/devtools.module.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.module.js.map +0 -1
- data/node_modules/preact/devtools/dist/devtools.umd.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.umd.js.map +0 -1
- data/node_modules/preact/devtools/package.json +0 -25
- data/node_modules/preact/devtools/src/devtools.js +0 -10
- data/node_modules/preact/devtools/src/index.d.ts +0 -8
- data/node_modules/preact/devtools/src/index.js +0 -15
- data/node_modules/preact/dist/preact.js +0 -2
- data/node_modules/preact/dist/preact.js.map +0 -1
- data/node_modules/preact/dist/preact.min.js +0 -2
- data/node_modules/preact/dist/preact.min.js.map +0 -1
- data/node_modules/preact/dist/preact.mjs +0 -2
- data/node_modules/preact/dist/preact.module.js +0 -2
- data/node_modules/preact/dist/preact.module.js.map +0 -1
- data/node_modules/preact/dist/preact.umd.js +0 -2
- data/node_modules/preact/dist/preact.umd.js.map +0 -1
- data/node_modules/preact/hooks/LICENSE +0 -21
- data/node_modules/preact/hooks/dist/hooks.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.js.map +0 -1
- data/node_modules/preact/hooks/dist/hooks.mjs +0 -2
- data/node_modules/preact/hooks/dist/hooks.module.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.module.js.map +0 -1
- data/node_modules/preact/hooks/dist/hooks.umd.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.umd.js.map +0 -1
- data/node_modules/preact/hooks/package.json +0 -35
- data/node_modules/preact/hooks/src/index.d.ts +0 -139
- data/node_modules/preact/hooks/src/index.js +0 -417
- data/node_modules/preact/hooks/src/internal.d.ts +0 -78
- data/node_modules/preact/jsx-runtime/LICENSE +0 -21
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +0 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +0 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +0 -1
- data/node_modules/preact/jsx-runtime/package.json +0 -28
- data/node_modules/preact/jsx-runtime/src/index.d.ts +0 -50
- data/node_modules/preact/jsx-runtime/src/index.js +0 -77
- data/node_modules/preact/package.json +0 -304
- data/node_modules/preact/src/cjs.js +0 -3
- data/node_modules/preact/src/clone-element.js +0 -34
- data/node_modules/preact/src/component.js +0 -225
- data/node_modules/preact/src/constants.js +0 -3
- data/node_modules/preact/src/create-context.js +0 -68
- data/node_modules/preact/src/create-element.js +0 -98
- data/node_modules/preact/src/diff/catch-error.js +0 -40
- data/node_modules/preact/src/diff/children.js +0 -335
- data/node_modules/preact/src/diff/index.js +0 -533
- data/node_modules/preact/src/diff/props.js +0 -158
- data/node_modules/preact/src/index.d.ts +0 -317
- data/node_modules/preact/src/index.js +0 -13
- data/node_modules/preact/src/internal.d.ts +0 -155
- data/node_modules/preact/src/jsx.d.ts +0 -1014
- data/node_modules/preact/src/options.js +0 -16
- data/node_modules/preact/src/render.js +0 -75
- data/node_modules/preact/src/util.js +0 -27
- data/node_modules/preact/test-utils/dist/testUtils.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.js.map +0 -1
- data/node_modules/preact/test-utils/dist/testUtils.mjs +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.module.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.module.js.map +0 -1
- data/node_modules/preact/test-utils/dist/testUtils.umd.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +0 -1
- data/node_modules/preact/test-utils/package.json +0 -28
- data/node_modules/preact/test-utils/src/index.d.ts +0 -3
- data/node_modules/preact/test-utils/src/index.js +0 -118
- data/node_modules/preact-render-to-string/LICENSE +0 -21
- data/node_modules/preact-render-to-string/README.md +0 -102
- data/node_modules/preact-render-to-string/dist/commonjs.js +0 -2
- data/node_modules/preact-render-to-string/dist/commonjs.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/index.d.ts +0 -16
- data/node_modules/preact-render-to-string/dist/index.js +0 -1
- data/node_modules/preact-render-to-string/dist/index.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/index.mjs +0 -2
- data/node_modules/preact-render-to-string/dist/index.module.js +0 -2
- data/node_modules/preact-render-to-string/dist/index.module.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx-entry.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx-entry.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.d.ts +0 -13
- data/node_modules/preact-render-to-string/dist/jsx.js +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.mjs +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.modern.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.modern.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/jsx.module.js +0 -2
- data/node_modules/preact-render-to-string/dist/jsx.module.js.map +0 -1
- data/node_modules/preact-render-to-string/dist/preact-render-to-string-tests.d.ts +0 -1
- data/node_modules/preact-render-to-string/jsx.js +0 -1
- data/node_modules/preact-render-to-string/package.json +0 -142
- data/node_modules/preact-render-to-string/src/index.d.ts +0 -16
- data/node_modules/preact-render-to-string/src/index.js +0 -462
- data/node_modules/preact-render-to-string/src/jsx.d.ts +0 -13
- data/node_modules/preact-render-to-string/src/jsx.js +0 -76
- data/node_modules/preact-render-to-string/src/polyfills.js +0 -8
- data/node_modules/preact-render-to-string/src/preact-render-to-string-tests.d.ts +0 -1
- data/node_modules/preact-render-to-string/src/util.js +0 -78
- data/node_modules/preact-render-to-string/typings.json +0 -5
- data/node_modules/pretty-format/.npmignore +0 -3
- data/node_modules/pretty-format/LICENSE.md +0 -15
- data/node_modules/pretty-format/README.md +0 -94
- data/node_modules/pretty-format/index.js +0 -343
- data/node_modules/pretty-format/package.json +0 -26
- data/node_modules/pretty-format/plugins/ReactElement.js +0 -74
- data/node_modules/pretty-format/plugins/ReactTestComponent.js +0 -58
- data/node_modules/pretty-format/printString.js +0 -7
- data/node_modules/wouter-preact/cjs/index.js +0 -180
- data/node_modules/wouter-preact/cjs/matcher.js +0 -72
- data/node_modules/wouter-preact/cjs/package.json +0 -1
- data/node_modules/wouter-preact/cjs/react-deps.js +0 -75
- data/node_modules/wouter-preact/cjs/static-location.js +0 -21
- data/node_modules/wouter-preact/cjs/use-location.js +0 -94
- data/node_modules/wouter-preact/index.d.ts +0 -110
- data/node_modules/wouter-preact/index.js +0 -178
- data/node_modules/wouter-preact/matcher.d.ts +0 -30
- data/node_modules/wouter-preact/matcher.js +0 -66
- data/node_modules/wouter-preact/package.json +0 -33
- data/node_modules/wouter-preact/react-deps.js +0 -15
- data/node_modules/wouter-preact/static-location.d.ts +0 -16
- data/node_modules/wouter-preact/static-location.js +0 -17
- data/node_modules/wouter-preact/use-location.d.ts +0 -43
- data/node_modules/wouter-preact/use-location.js +0 -86
- data/package.json +0 -8
@@ -1,35 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "preact-hooks",
|
3
|
-
"amdName": "preactHooks",
|
4
|
-
"version": "0.1.0",
|
5
|
-
"private": true,
|
6
|
-
"description": "Hook addon for Preact",
|
7
|
-
"main": "dist/hooks.js",
|
8
|
-
"module": "dist/hooks.module.js",
|
9
|
-
"umd:main": "dist/hooks.umd.js",
|
10
|
-
"source": "src/index.js",
|
11
|
-
"license": "MIT",
|
12
|
-
"types": "src/index.d.ts",
|
13
|
-
"scripts": {
|
14
|
-
"build": "microbundle build --raw",
|
15
|
-
"dev": "microbundle watch --raw --format cjs",
|
16
|
-
"test": "npm-run-all build --parallel test:karma",
|
17
|
-
"test:karma": "karma start test/karma.conf.js --single-run",
|
18
|
-
"test:karma:watch": "karma start test/karma.conf.js --no-single-run"
|
19
|
-
},
|
20
|
-
"peerDependencies": {
|
21
|
-
"preact": "^10.0.0"
|
22
|
-
},
|
23
|
-
"mangle": {
|
24
|
-
"regex": "^_"
|
25
|
-
},
|
26
|
-
"exports": {
|
27
|
-
".": {
|
28
|
-
"types": "./src/index.d.ts",
|
29
|
-
"browser": "./dist/hooks.module.js",
|
30
|
-
"umd": "./dist/hooks.umd.js",
|
31
|
-
"import": "./dist/hooks.mjs",
|
32
|
-
"require": "./dist/hooks.js"
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
@@ -1,139 +0,0 @@
|
|
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 function useState<S = undefined>(): [
|
13
|
-
S | undefined,
|
14
|
-
StateUpdater<S | undefined>
|
15
|
-
];
|
16
|
-
|
17
|
-
export type Reducer<S, A> = (prevState: S, action: A) => S;
|
18
|
-
/**
|
19
|
-
* An alternative to `useState`.
|
20
|
-
*
|
21
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
22
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
23
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
24
|
-
* @param reducer Given the current state and an action, returns the new state
|
25
|
-
* @param initialState The initial value to store as state
|
26
|
-
*/
|
27
|
-
export function useReducer<S, A>(
|
28
|
-
reducer: Reducer<S, A>,
|
29
|
-
initialState: S
|
30
|
-
): [S, (action: A) => void];
|
31
|
-
|
32
|
-
/**
|
33
|
-
* An alternative to `useState`.
|
34
|
-
*
|
35
|
-
* `useReducer` is usually preferable to `useState` when you have complex state logic that involves
|
36
|
-
* multiple sub-values. It also lets you optimize performance for components that trigger deep
|
37
|
-
* updates because you can pass `dispatch` down instead of callbacks.
|
38
|
-
* @param reducer Given the current state and an action, returns the new state
|
39
|
-
* @param initialArg The initial argument to pass to the `init` function
|
40
|
-
* @param init A function that, given the `initialArg`, returns the initial value to store as state
|
41
|
-
*/
|
42
|
-
export function useReducer<S, A, I>(
|
43
|
-
reducer: Reducer<S, A>,
|
44
|
-
initialArg: I,
|
45
|
-
init: (arg: I) => S
|
46
|
-
): [S, (action: A) => void];
|
47
|
-
|
48
|
-
/** @deprecated Use the `Ref` type instead. */
|
49
|
-
type PropRef<T> = MutableRef<T>;
|
50
|
-
interface Ref<T> {
|
51
|
-
readonly current: T | null;
|
52
|
-
}
|
53
|
-
|
54
|
-
interface MutableRef<T> {
|
55
|
-
current: T;
|
56
|
-
}
|
57
|
-
|
58
|
-
/**
|
59
|
-
* `useRef` returns a mutable ref object whose `.current` property is initialized to the passed argument
|
60
|
-
* (`initialValue`). The returned object will persist for the full lifetime of the component.
|
61
|
-
*
|
62
|
-
* Note that `useRef()` is useful for more than the `ref` attribute. It’s handy for keeping any mutable
|
63
|
-
* value around similar to how you’d use instance fields in classes.
|
64
|
-
*
|
65
|
-
* @param initialValue the initial value to store in the ref object
|
66
|
-
*/
|
67
|
-
export function useRef<T>(initialValue: T): MutableRef<T>;
|
68
|
-
export function useRef<T>(initialValue: T | null): Ref<T>;
|
69
|
-
export function useRef<T = undefined>(): MutableRef<T | undefined>;
|
70
|
-
|
71
|
-
type EffectCallback = () => void | (() => void);
|
72
|
-
/**
|
73
|
-
* Accepts a function that contains imperative, possibly effectful code.
|
74
|
-
* The effects run after browser paint, without blocking it.
|
75
|
-
*
|
76
|
-
* @param effect Imperative function that can return a cleanup function
|
77
|
-
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
78
|
-
*/
|
79
|
-
export function useEffect(effect: EffectCallback, inputs?: Inputs): void;
|
80
|
-
|
81
|
-
type CreateHandle = () => object;
|
82
|
-
|
83
|
-
/**
|
84
|
-
* @param ref The ref that will be mutated
|
85
|
-
* @param create The function that will be executed to get the value that will be attached to
|
86
|
-
* ref.current
|
87
|
-
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
88
|
-
*/
|
89
|
-
export function useImperativeHandle<T, R extends T>(
|
90
|
-
ref: PreactRef<T>,
|
91
|
-
create: () => R,
|
92
|
-
inputs?: Inputs
|
93
|
-
): void;
|
94
|
-
|
95
|
-
/**
|
96
|
-
* Accepts a function that contains imperative, possibly effectful code.
|
97
|
-
* Use this to read layout from the DOM and synchronously re-render.
|
98
|
-
* Updates scheduled inside `useLayoutEffect` will be flushed synchronously, after all DOM mutations but before the browser has a chance to paint.
|
99
|
-
* Prefer the standard `useEffect` hook when possible to avoid blocking visual updates.
|
100
|
-
*
|
101
|
-
* @param effect Imperative function that can return a cleanup function
|
102
|
-
* @param inputs If present, effect will only activate if the values in the list change (using ===).
|
103
|
-
*/
|
104
|
-
export function useLayoutEffect(effect: EffectCallback, inputs?: Inputs): void;
|
105
|
-
|
106
|
-
/**
|
107
|
-
* Returns a memoized version of the callback that only changes if one of the `inputs`
|
108
|
-
* has changed (using ===).
|
109
|
-
*/
|
110
|
-
export function useCallback<T extends Function>(callback: T, inputs: Inputs): T;
|
111
|
-
|
112
|
-
/**
|
113
|
-
* Pass a factory function and an array of inputs.
|
114
|
-
* useMemo will only recompute the memoized value when one of the inputs has changed.
|
115
|
-
* This optimization helps to avoid expensive calculations on every render.
|
116
|
-
* If no array is provided, a new value will be computed whenever a new function instance is passed as the first argument.
|
117
|
-
*/
|
118
|
-
// for `inputs`, allow undefined, but don't make it optional as that is very likely a mistake
|
119
|
-
export function useMemo<T>(factory: () => T, inputs: Inputs | undefined): T;
|
120
|
-
|
121
|
-
/**
|
122
|
-
* Returns the current context value, as given by the nearest context provider for the given context.
|
123
|
-
* When the provider updates, this Hook will trigger a rerender with the latest context value.
|
124
|
-
*
|
125
|
-
* @param context The context you want to use
|
126
|
-
*/
|
127
|
-
export function useContext<T>(context: PreactContext<T>): T;
|
128
|
-
|
129
|
-
/**
|
130
|
-
* Customize the displayed value in the devtools panel.
|
131
|
-
*
|
132
|
-
* @param value Custom hook name or object that is passed to formatter
|
133
|
-
* @param formatter Formatter to modify value before sending it to the devtools
|
134
|
-
*/
|
135
|
-
export function useDebugValue<T>(value: T, formatter?: (value: T) => any): void;
|
136
|
-
|
137
|
-
export function useErrorBoundary(
|
138
|
-
callback?: (error: any) => Promise<void> | void
|
139
|
-
): [any, () => void];
|
@@ -1,417 +0,0 @@
|
|
1
|
-
import { options } from 'preact';
|
2
|
-
|
3
|
-
/** @type {number} */
|
4
|
-
let currentIndex;
|
5
|
-
|
6
|
-
/** @type {import('./internal').Component} */
|
7
|
-
let currentComponent;
|
8
|
-
|
9
|
-
/** @type {import('./internal').Component} */
|
10
|
-
let previousComponent;
|
11
|
-
|
12
|
-
/** @type {number} */
|
13
|
-
let currentHook = 0;
|
14
|
-
|
15
|
-
/** @type {Array<import('./internal').Component>} */
|
16
|
-
let afterPaintEffects = [];
|
17
|
-
|
18
|
-
let EMPTY = [];
|
19
|
-
|
20
|
-
let oldBeforeDiff = options._diff;
|
21
|
-
let oldBeforeRender = options._render;
|
22
|
-
let oldAfterDiff = options.diffed;
|
23
|
-
let oldCommit = options._commit;
|
24
|
-
let oldBeforeUnmount = options.unmount;
|
25
|
-
|
26
|
-
const RAF_TIMEOUT = 100;
|
27
|
-
let prevRaf;
|
28
|
-
|
29
|
-
options._diff = vnode => {
|
30
|
-
currentComponent = null;
|
31
|
-
if (oldBeforeDiff) oldBeforeDiff(vnode);
|
32
|
-
};
|
33
|
-
|
34
|
-
options._render = vnode => {
|
35
|
-
if (oldBeforeRender) oldBeforeRender(vnode);
|
36
|
-
|
37
|
-
currentComponent = vnode._component;
|
38
|
-
currentIndex = 0;
|
39
|
-
|
40
|
-
const hooks = currentComponent.__hooks;
|
41
|
-
if (hooks) {
|
42
|
-
if (previousComponent === currentComponent) {
|
43
|
-
hooks._pendingEffects = [];
|
44
|
-
currentComponent._renderCallbacks = [];
|
45
|
-
hooks._list.forEach(hookItem => {
|
46
|
-
hookItem._pendingValue = EMPTY;
|
47
|
-
hookItem._pendingArgs = undefined;
|
48
|
-
});
|
49
|
-
} else {
|
50
|
-
hooks._pendingEffects.forEach(invokeCleanup);
|
51
|
-
hooks._pendingEffects.forEach(invokeEffect);
|
52
|
-
hooks._pendingEffects = [];
|
53
|
-
}
|
54
|
-
}
|
55
|
-
previousComponent = currentComponent;
|
56
|
-
};
|
57
|
-
|
58
|
-
options.diffed = vnode => {
|
59
|
-
if (oldAfterDiff) oldAfterDiff(vnode);
|
60
|
-
|
61
|
-
const c = vnode._component;
|
62
|
-
if (c && c.__hooks) {
|
63
|
-
if (c.__hooks._pendingEffects.length) afterPaint(afterPaintEffects.push(c));
|
64
|
-
c.__hooks._list.forEach(hookItem => {
|
65
|
-
if (hookItem._pendingArgs) {
|
66
|
-
hookItem._args = hookItem._pendingArgs;
|
67
|
-
}
|
68
|
-
if (hookItem._pendingValue !== EMPTY) {
|
69
|
-
hookItem._value = hookItem._pendingValue;
|
70
|
-
}
|
71
|
-
hookItem._pendingArgs = undefined;
|
72
|
-
hookItem._pendingValue = EMPTY;
|
73
|
-
});
|
74
|
-
}
|
75
|
-
previousComponent = currentComponent = null;
|
76
|
-
};
|
77
|
-
|
78
|
-
options._commit = (vnode, commitQueue) => {
|
79
|
-
commitQueue.some(component => {
|
80
|
-
try {
|
81
|
-
component._renderCallbacks.forEach(invokeCleanup);
|
82
|
-
component._renderCallbacks = component._renderCallbacks.filter(cb =>
|
83
|
-
cb._value ? invokeEffect(cb) : true
|
84
|
-
);
|
85
|
-
} catch (e) {
|
86
|
-
commitQueue.some(c => {
|
87
|
-
if (c._renderCallbacks) c._renderCallbacks = [];
|
88
|
-
});
|
89
|
-
commitQueue = [];
|
90
|
-
options._catchError(e, component._vnode);
|
91
|
-
}
|
92
|
-
});
|
93
|
-
|
94
|
-
if (oldCommit) oldCommit(vnode, commitQueue);
|
95
|
-
};
|
96
|
-
|
97
|
-
options.unmount = vnode => {
|
98
|
-
if (oldBeforeUnmount) oldBeforeUnmount(vnode);
|
99
|
-
|
100
|
-
const c = vnode._component;
|
101
|
-
if (c && c.__hooks) {
|
102
|
-
let hasErrored;
|
103
|
-
c.__hooks._list.forEach(s => {
|
104
|
-
try {
|
105
|
-
invokeCleanup(s);
|
106
|
-
} catch (e) {
|
107
|
-
hasErrored = e;
|
108
|
-
}
|
109
|
-
});
|
110
|
-
if (hasErrored) options._catchError(hasErrored, c._vnode);
|
111
|
-
}
|
112
|
-
};
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Get a hook's state from the currentComponent
|
116
|
-
* @param {number} index The index of the hook to get
|
117
|
-
* @param {number} type The index of the hook to get
|
118
|
-
* @returns {any}
|
119
|
-
*/
|
120
|
-
function getHookState(index, type) {
|
121
|
-
if (options._hook) {
|
122
|
-
options._hook(currentComponent, index, currentHook || type);
|
123
|
-
}
|
124
|
-
currentHook = 0;
|
125
|
-
|
126
|
-
// Largely inspired by:
|
127
|
-
// * https://github.com/michael-klein/funcy.js/blob/f6be73468e6ec46b0ff5aa3cc4c9baf72a29025a/src/hooks/core_hooks.mjs
|
128
|
-
// * https://github.com/michael-klein/funcy.js/blob/650beaa58c43c33a74820a3c98b3c7079cf2e333/src/renderer.mjs
|
129
|
-
// Other implementations to look at:
|
130
|
-
// * https://codesandbox.io/s/mnox05qp8
|
131
|
-
const hooks =
|
132
|
-
currentComponent.__hooks ||
|
133
|
-
(currentComponent.__hooks = {
|
134
|
-
_list: [],
|
135
|
-
_pendingEffects: []
|
136
|
-
});
|
137
|
-
|
138
|
-
if (index >= hooks._list.length) {
|
139
|
-
hooks._list.push({ _pendingValue: EMPTY });
|
140
|
-
}
|
141
|
-
return hooks._list[index];
|
142
|
-
}
|
143
|
-
|
144
|
-
/**
|
145
|
-
* @param {import('./index').StateUpdater<any>} [initialState]
|
146
|
-
*/
|
147
|
-
export function useState(initialState) {
|
148
|
-
currentHook = 1;
|
149
|
-
return useReducer(invokeOrReturn, initialState);
|
150
|
-
}
|
151
|
-
|
152
|
-
/**
|
153
|
-
* @param {import('./index').Reducer<any, any>} reducer
|
154
|
-
* @param {import('./index').StateUpdater<any>} initialState
|
155
|
-
* @param {(initialState: any) => void} [init]
|
156
|
-
* @returns {[ any, (state: any) => void ]}
|
157
|
-
*/
|
158
|
-
export function useReducer(reducer, initialState, init) {
|
159
|
-
/** @type {import('./internal').ReducerHookState} */
|
160
|
-
const hookState = getHookState(currentIndex++, 2);
|
161
|
-
hookState._reducer = reducer;
|
162
|
-
if (!hookState._component) {
|
163
|
-
hookState._value = [
|
164
|
-
!init ? invokeOrReturn(undefined, initialState) : init(initialState),
|
165
|
-
|
166
|
-
action => {
|
167
|
-
const nextValue = hookState._reducer(hookState._value[0], action);
|
168
|
-
if (hookState._value[0] !== nextValue) {
|
169
|
-
hookState._value = [nextValue, hookState._value[1]];
|
170
|
-
hookState._component.setState({});
|
171
|
-
}
|
172
|
-
}
|
173
|
-
];
|
174
|
-
|
175
|
-
hookState._component = currentComponent;
|
176
|
-
}
|
177
|
-
|
178
|
-
return hookState._value;
|
179
|
-
}
|
180
|
-
|
181
|
-
/**
|
182
|
-
* @param {import('./internal').Effect} callback
|
183
|
-
* @param {any[]} args
|
184
|
-
*/
|
185
|
-
export function useEffect(callback, args) {
|
186
|
-
/** @type {import('./internal').EffectHookState} */
|
187
|
-
const state = getHookState(currentIndex++, 3);
|
188
|
-
if (!options._skipEffects && argsChanged(state._args, args)) {
|
189
|
-
state._value = callback;
|
190
|
-
state._pendingArgs = args;
|
191
|
-
|
192
|
-
currentComponent.__hooks._pendingEffects.push(state);
|
193
|
-
}
|
194
|
-
}
|
195
|
-
|
196
|
-
/**
|
197
|
-
* @param {import('./internal').Effect} callback
|
198
|
-
* @param {any[]} args
|
199
|
-
*/
|
200
|
-
export function useLayoutEffect(callback, args) {
|
201
|
-
/** @type {import('./internal').EffectHookState} */
|
202
|
-
const state = getHookState(currentIndex++, 4);
|
203
|
-
if (!options._skipEffects && argsChanged(state._args, args)) {
|
204
|
-
state._value = callback;
|
205
|
-
state._pendingArgs = args;
|
206
|
-
|
207
|
-
currentComponent._renderCallbacks.push(state);
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
export function useRef(initialValue) {
|
212
|
-
currentHook = 5;
|
213
|
-
return useMemo(() => ({ current: initialValue }), []);
|
214
|
-
}
|
215
|
-
|
216
|
-
/**
|
217
|
-
* @param {object} ref
|
218
|
-
* @param {() => object} createHandle
|
219
|
-
* @param {any[]} args
|
220
|
-
*/
|
221
|
-
export function useImperativeHandle(ref, createHandle, args) {
|
222
|
-
currentHook = 6;
|
223
|
-
useLayoutEffect(
|
224
|
-
() => {
|
225
|
-
if (typeof ref == 'function') {
|
226
|
-
ref(createHandle());
|
227
|
-
return () => ref(null);
|
228
|
-
} else if (ref) {
|
229
|
-
ref.current = createHandle();
|
230
|
-
return () => (ref.current = null);
|
231
|
-
}
|
232
|
-
},
|
233
|
-
args == null ? args : args.concat(ref)
|
234
|
-
);
|
235
|
-
}
|
236
|
-
|
237
|
-
/**
|
238
|
-
* @param {() => any} factory
|
239
|
-
* @param {any[]} args
|
240
|
-
*/
|
241
|
-
export function useMemo(factory, args) {
|
242
|
-
/** @type {import('./internal').MemoHookState} */
|
243
|
-
const state = getHookState(currentIndex++, 7);
|
244
|
-
if (argsChanged(state._args, args)) {
|
245
|
-
state._pendingValue = factory();
|
246
|
-
state._pendingArgs = args;
|
247
|
-
state._factory = factory;
|
248
|
-
return state._pendingValue;
|
249
|
-
}
|
250
|
-
|
251
|
-
return state._value;
|
252
|
-
}
|
253
|
-
|
254
|
-
/**
|
255
|
-
* @param {() => void} callback
|
256
|
-
* @param {any[]} args
|
257
|
-
*/
|
258
|
-
export function useCallback(callback, args) {
|
259
|
-
currentHook = 8;
|
260
|
-
return useMemo(() => callback, args);
|
261
|
-
}
|
262
|
-
|
263
|
-
/**
|
264
|
-
* @param {import('./internal').PreactContext} context
|
265
|
-
*/
|
266
|
-
export function useContext(context) {
|
267
|
-
const provider = currentComponent.context[context._id];
|
268
|
-
// We could skip this call here, but than we'd not call
|
269
|
-
// `options._hook`. We need to do that in order to make
|
270
|
-
// the devtools aware of this hook.
|
271
|
-
/** @type {import('./internal').ContextHookState} */
|
272
|
-
const state = getHookState(currentIndex++, 9);
|
273
|
-
// The devtools needs access to the context object to
|
274
|
-
// be able to pull of the default value when no provider
|
275
|
-
// is present in the tree.
|
276
|
-
state._context = context;
|
277
|
-
if (!provider) return context._defaultValue;
|
278
|
-
// This is probably not safe to convert to "!"
|
279
|
-
if (state._value == null) {
|
280
|
-
state._value = true;
|
281
|
-
provider.sub(currentComponent);
|
282
|
-
}
|
283
|
-
return provider.props.value;
|
284
|
-
}
|
285
|
-
|
286
|
-
/**
|
287
|
-
* Display a custom label for a custom hook for the devtools panel
|
288
|
-
* @type {<T>(value: T, cb?: (value: T) => string | number) => void}
|
289
|
-
*/
|
290
|
-
export function useDebugValue(value, formatter) {
|
291
|
-
if (options.useDebugValue) {
|
292
|
-
options.useDebugValue(formatter ? formatter(value) : value);
|
293
|
-
}
|
294
|
-
}
|
295
|
-
|
296
|
-
/**
|
297
|
-
* @param {(error: any) => void} cb
|
298
|
-
*/
|
299
|
-
export function useErrorBoundary(cb) {
|
300
|
-
/** @type {import('./internal').ErrorBoundaryHookState} */
|
301
|
-
const state = getHookState(currentIndex++, 10);
|
302
|
-
const errState = useState();
|
303
|
-
state._value = cb;
|
304
|
-
if (!currentComponent.componentDidCatch) {
|
305
|
-
currentComponent.componentDidCatch = err => {
|
306
|
-
if (state._value) state._value(err);
|
307
|
-
errState[1](err);
|
308
|
-
};
|
309
|
-
}
|
310
|
-
return [
|
311
|
-
errState[0],
|
312
|
-
() => {
|
313
|
-
errState[1](undefined);
|
314
|
-
}
|
315
|
-
];
|
316
|
-
}
|
317
|
-
|
318
|
-
/**
|
319
|
-
* After paint effects consumer.
|
320
|
-
*/
|
321
|
-
function flushAfterPaintEffects() {
|
322
|
-
let component;
|
323
|
-
while ((component = afterPaintEffects.shift())) {
|
324
|
-
if (!component._parentDom) continue;
|
325
|
-
try {
|
326
|
-
component.__hooks._pendingEffects.forEach(invokeCleanup);
|
327
|
-
component.__hooks._pendingEffects.forEach(invokeEffect);
|
328
|
-
component.__hooks._pendingEffects = [];
|
329
|
-
} catch (e) {
|
330
|
-
component.__hooks._pendingEffects = [];
|
331
|
-
options._catchError(e, component._vnode);
|
332
|
-
}
|
333
|
-
}
|
334
|
-
}
|
335
|
-
|
336
|
-
let HAS_RAF = typeof requestAnimationFrame == 'function';
|
337
|
-
|
338
|
-
/**
|
339
|
-
* Schedule a callback to be invoked after the browser has a chance to paint a new frame.
|
340
|
-
* Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after
|
341
|
-
* the next browser frame.
|
342
|
-
*
|
343
|
-
* Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked
|
344
|
-
* even if RAF doesn't fire (for example if the browser tab is not visible)
|
345
|
-
*
|
346
|
-
* @param {() => void} callback
|
347
|
-
*/
|
348
|
-
function afterNextFrame(callback) {
|
349
|
-
const done = () => {
|
350
|
-
clearTimeout(timeout);
|
351
|
-
if (HAS_RAF) cancelAnimationFrame(raf);
|
352
|
-
setTimeout(callback);
|
353
|
-
};
|
354
|
-
const timeout = setTimeout(done, RAF_TIMEOUT);
|
355
|
-
|
356
|
-
let raf;
|
357
|
-
if (HAS_RAF) {
|
358
|
-
raf = requestAnimationFrame(done);
|
359
|
-
}
|
360
|
-
}
|
361
|
-
|
362
|
-
// Note: if someone used options.debounceRendering = requestAnimationFrame,
|
363
|
-
// then effects will ALWAYS run on the NEXT frame instead of the current one, incurring a ~16ms delay.
|
364
|
-
// Perhaps this is not such a big deal.
|
365
|
-
/**
|
366
|
-
* Schedule afterPaintEffects flush after the browser paints
|
367
|
-
* @param {number} newQueueLength
|
368
|
-
*/
|
369
|
-
function afterPaint(newQueueLength) {
|
370
|
-
if (newQueueLength === 1 || prevRaf !== options.requestAnimationFrame) {
|
371
|
-
prevRaf = options.requestAnimationFrame;
|
372
|
-
(prevRaf || afterNextFrame)(flushAfterPaintEffects);
|
373
|
-
}
|
374
|
-
}
|
375
|
-
|
376
|
-
/**
|
377
|
-
* @param {import('./internal').EffectHookState} hook
|
378
|
-
*/
|
379
|
-
function invokeCleanup(hook) {
|
380
|
-
// A hook cleanup can introduce a call to render which creates a new root, this will call options.vnode
|
381
|
-
// and move the currentComponent away.
|
382
|
-
const comp = currentComponent;
|
383
|
-
let cleanup = hook._cleanup;
|
384
|
-
if (typeof cleanup == 'function') {
|
385
|
-
hook._cleanup = undefined;
|
386
|
-
cleanup();
|
387
|
-
}
|
388
|
-
currentComponent = comp;
|
389
|
-
}
|
390
|
-
|
391
|
-
/**
|
392
|
-
* Invoke a Hook's effect
|
393
|
-
* @param {import('./internal').EffectHookState} hook
|
394
|
-
*/
|
395
|
-
function invokeEffect(hook) {
|
396
|
-
// A hook call can introduce a call to render which creates a new root, this will call options.vnode
|
397
|
-
// and move the currentComponent away.
|
398
|
-
const comp = currentComponent;
|
399
|
-
hook._cleanup = hook._value();
|
400
|
-
currentComponent = comp;
|
401
|
-
}
|
402
|
-
|
403
|
-
/**
|
404
|
-
* @param {any[]} oldArgs
|
405
|
-
* @param {any[]} newArgs
|
406
|
-
*/
|
407
|
-
function argsChanged(oldArgs, newArgs) {
|
408
|
-
return (
|
409
|
-
!oldArgs ||
|
410
|
-
oldArgs.length !== newArgs.length ||
|
411
|
-
newArgs.some((arg, index) => arg !== oldArgs[index])
|
412
|
-
);
|
413
|
-
}
|
414
|
-
|
415
|
-
function invokeOrReturn(arg, f) {
|
416
|
-
return typeof f == 'function' ? f(arg) : f;
|
417
|
-
}
|
@@ -1,78 +0,0 @@
|
|
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
|
-
_pendingArgs?: any[];
|
53
|
-
_cleanup?: Cleanup | void;
|
54
|
-
}
|
55
|
-
|
56
|
-
export interface MemoHookState {
|
57
|
-
_value?: any;
|
58
|
-
_pendingValue?: any;
|
59
|
-
_args?: any[];
|
60
|
-
_pendingArgs?: any[];
|
61
|
-
_factory?: () => any;
|
62
|
-
}
|
63
|
-
|
64
|
-
export interface ReducerHookState {
|
65
|
-
_value?: any;
|
66
|
-
_component?: Component;
|
67
|
-
_reducer?: Reducer<any, any>;
|
68
|
-
}
|
69
|
-
|
70
|
-
export interface ContextHookState {
|
71
|
-
/** Whether this hooks as subscribed to updates yet */
|
72
|
-
_value?: boolean;
|
73
|
-
_context?: PreactContext;
|
74
|
-
}
|
75
|
-
|
76
|
-
export interface ErrorBoundaryHookState {
|
77
|
-
_value?: (error: any) => void;
|
78
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015-present Jason Miller
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
@@ -1,2 +0,0 @@
|
|
1
|
-
var r=require("preact"),_=0;function e(e,o,n,t,l){var u,f,i={};for(f in o)"ref"==f?u=o[f]:i[f]=o[f];var p={type:e,props:i,key:n,ref:u,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--_,__source:l,__self:t};if("function"==typeof e&&(u=e.defaultProps))for(f in u)void 0===i[f]&&(i[f]=u[f]);return r.options.vnode&&r.options.vnode(p),p}exports.Fragment=r.Fragment,exports.jsx=e,exports.jsxs=e,exports.jsxDEV=e;
|
2
|
-
//# sourceMappingURL=jsxRuntime.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"jsxRuntime.js","sources":["../src/index.js"],"sourcesContent":["import { options, Fragment } from 'preact';\n\n/** @typedef {import('preact').VNode} VNode */\n\nlet vnodeId = 0;\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} [__self]\n * @param {string} [__source]\n */\nfunction createVNode(type, props, key, __self, __source) {\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\t\tref,\n\t\ti;\n\tfor (i in props) {\n\t\tif (i == 'ref') {\n\t\t\tref = props[i];\n\t\t} else {\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,\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: --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\tif (typeof type === 'function' && (ref = type.defaultProps)) {\n\t\tfor (i in ref)\n\t\t\tif (typeof normalizedProps[i] === 'undefined') {\n\t\t\t\tnormalizedProps[i] = ref[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":["vnodeId","createVNode","type","props","key","__self","__source","ref","i","normalizedProps","vnode","undefined","constructor","defaultProps","options"],"mappings":"wBAIIA,EAAU,EAqBd,SAASC,EAAYC,EAAMC,EAAOC,EAAKC,EAAQC,OAK7CC,EACAC,EAFGC,EAAkB,OAGjBD,KAAKL,EACA,OAALK,EACHD,EAAMJ,EAAMK,GAEZC,EAAgBD,GAAKL,EAAMK,OAIvBE,EAAQ,CACbR,KAAAA,EACAC,MAAOM,EACPL,IAAAA,EACAG,IAAAA,MACW,QACF,SACD,MACF,cACII,MACE,SACA,KACZC,iBAAaD,QACAX,EACbM,SAAAA,EACAD,OAAAA,MAKmB,mBAATH,IAAwBK,EAAML,EAAKW,kBACxCL,KAAKD,OACyB,IAAvBE,EAAgBD,KAC1BC,EAAgBD,GAAKD,EAAIC,WAIxBM,UAAQJ,OAAOI,UAAQJ,MAAMA,GAC1BA"}
|