isomorfeus-preact 10.8.2 → 22.9.0.rc1
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
- metadata +42 -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 -140
- 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 -155
- data/node_modules/preact/compat/src/index.js +0 -187
- 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 -1013
- 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,187 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
createElement,
|
3
|
-
render as preactRender,
|
4
|
-
cloneElement as preactCloneElement,
|
5
|
-
createRef,
|
6
|
-
Component,
|
7
|
-
createContext,
|
8
|
-
Fragment
|
9
|
-
} from 'preact';
|
10
|
-
import {
|
11
|
-
useState,
|
12
|
-
useReducer,
|
13
|
-
useEffect,
|
14
|
-
useLayoutEffect,
|
15
|
-
useRef,
|
16
|
-
useImperativeHandle,
|
17
|
-
useMemo,
|
18
|
-
useCallback,
|
19
|
-
useContext,
|
20
|
-
useDebugValue
|
21
|
-
} from 'preact/hooks';
|
22
|
-
import { PureComponent } from './PureComponent';
|
23
|
-
import { memo } from './memo';
|
24
|
-
import { forwardRef } from './forwardRef';
|
25
|
-
import { Children } from './Children';
|
26
|
-
import { Suspense, lazy } from './suspense';
|
27
|
-
import { SuspenseList } from './suspense-list';
|
28
|
-
import { createPortal } from './portals';
|
29
|
-
import {
|
30
|
-
hydrate,
|
31
|
-
render,
|
32
|
-
REACT_ELEMENT_TYPE,
|
33
|
-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
34
|
-
} from './render';
|
35
|
-
|
36
|
-
const version = '17.0.2'; // trick libraries to think we are react
|
37
|
-
|
38
|
-
/**
|
39
|
-
* Legacy version of createElement.
|
40
|
-
* @param {import('./internal').VNode["type"]} type The node name or Component constructor
|
41
|
-
*/
|
42
|
-
function createFactory(type) {
|
43
|
-
return createElement.bind(null, type);
|
44
|
-
}
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Check if the passed element is a valid (p)react node.
|
48
|
-
* @param {*} element The element to check
|
49
|
-
* @returns {boolean}
|
50
|
-
*/
|
51
|
-
function isValidElement(element) {
|
52
|
-
return !!element && element.$$typeof === REACT_ELEMENT_TYPE;
|
53
|
-
}
|
54
|
-
|
55
|
-
/**
|
56
|
-
* Wrap `cloneElement` to abort if the passed element is not a valid element and apply
|
57
|
-
* all vnode normalizations.
|
58
|
-
* @param {import('./internal').VNode} element The vnode to clone
|
59
|
-
* @param {object} props Props to add when cloning
|
60
|
-
* @param {Array<import('./internal').ComponentChildren>} rest Optional component children
|
61
|
-
*/
|
62
|
-
function cloneElement(element) {
|
63
|
-
if (!isValidElement(element)) return element;
|
64
|
-
return preactCloneElement.apply(null, arguments);
|
65
|
-
}
|
66
|
-
|
67
|
-
/**
|
68
|
-
* Remove a component tree from the DOM, including state and event handlers.
|
69
|
-
* @param {import('./internal').PreactElement} container
|
70
|
-
* @returns {boolean}
|
71
|
-
*/
|
72
|
-
function unmountComponentAtNode(container) {
|
73
|
-
if (container._children) {
|
74
|
-
preactRender(null, container);
|
75
|
-
return true;
|
76
|
-
}
|
77
|
-
return false;
|
78
|
-
}
|
79
|
-
|
80
|
-
/**
|
81
|
-
* Get the matching DOM node for a component
|
82
|
-
* @param {import('./internal').Component} component
|
83
|
-
* @returns {import('./internal').PreactElement | null}
|
84
|
-
*/
|
85
|
-
function findDOMNode(component) {
|
86
|
-
return (
|
87
|
-
(component &&
|
88
|
-
(component.base || (component.nodeType === 1 && component))) ||
|
89
|
-
null
|
90
|
-
);
|
91
|
-
}
|
92
|
-
|
93
|
-
/**
|
94
|
-
* Deprecated way to control batched rendering inside the reconciler, but we
|
95
|
-
* already schedule in batches inside our rendering code
|
96
|
-
* @template Arg
|
97
|
-
* @param {(arg: Arg) => void} callback function that triggers the updated
|
98
|
-
* @param {Arg} [arg] Optional argument that can be passed to the callback
|
99
|
-
*/
|
100
|
-
// eslint-disable-next-line camelcase
|
101
|
-
const unstable_batchedUpdates = (callback, arg) => callback(arg);
|
102
|
-
|
103
|
-
/**
|
104
|
-
* In React, `flushSync` flushes the entire tree and forces a rerender. It's
|
105
|
-
* implmented here as a no-op.
|
106
|
-
* @template Arg
|
107
|
-
* @template Result
|
108
|
-
* @param {(arg: Arg) => Result} callback function that runs before the flush
|
109
|
-
* @param {Arg} [arg] Optional arugment that can be passed to the callback
|
110
|
-
* @returns
|
111
|
-
*/
|
112
|
-
const flushSync = (callback, arg) => callback(arg);
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Strict Mode is not implemented in Preact, so we provide a stand-in for it
|
116
|
-
* that just renders its children without imposing any restrictions.
|
117
|
-
*/
|
118
|
-
const StrictMode = Fragment;
|
119
|
-
|
120
|
-
export * from 'preact/hooks';
|
121
|
-
export {
|
122
|
-
version,
|
123
|
-
Children,
|
124
|
-
render,
|
125
|
-
hydrate,
|
126
|
-
unmountComponentAtNode,
|
127
|
-
createPortal,
|
128
|
-
createElement,
|
129
|
-
createContext,
|
130
|
-
createFactory,
|
131
|
-
cloneElement,
|
132
|
-
createRef,
|
133
|
-
Fragment,
|
134
|
-
isValidElement,
|
135
|
-
findDOMNode,
|
136
|
-
Component,
|
137
|
-
PureComponent,
|
138
|
-
memo,
|
139
|
-
forwardRef,
|
140
|
-
flushSync,
|
141
|
-
// eslint-disable-next-line camelcase
|
142
|
-
unstable_batchedUpdates,
|
143
|
-
StrictMode,
|
144
|
-
Suspense,
|
145
|
-
SuspenseList,
|
146
|
-
lazy,
|
147
|
-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
148
|
-
};
|
149
|
-
|
150
|
-
// React copies the named exports to the default one.
|
151
|
-
export default {
|
152
|
-
useState,
|
153
|
-
useReducer,
|
154
|
-
useEffect,
|
155
|
-
useLayoutEffect,
|
156
|
-
useRef,
|
157
|
-
useImperativeHandle,
|
158
|
-
useMemo,
|
159
|
-
useCallback,
|
160
|
-
useContext,
|
161
|
-
useDebugValue,
|
162
|
-
version,
|
163
|
-
Children,
|
164
|
-
render,
|
165
|
-
hydrate,
|
166
|
-
unmountComponentAtNode,
|
167
|
-
createPortal,
|
168
|
-
createElement,
|
169
|
-
createContext,
|
170
|
-
createFactory,
|
171
|
-
cloneElement,
|
172
|
-
createRef,
|
173
|
-
Fragment,
|
174
|
-
isValidElement,
|
175
|
-
findDOMNode,
|
176
|
-
Component,
|
177
|
-
PureComponent,
|
178
|
-
memo,
|
179
|
-
forwardRef,
|
180
|
-
flushSync,
|
181
|
-
unstable_batchedUpdates,
|
182
|
-
StrictMode,
|
183
|
-
Suspense,
|
184
|
-
SuspenseList,
|
185
|
-
lazy,
|
186
|
-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
|
187
|
-
};
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
Component as PreactComponent,
|
3
|
-
VNode as PreactVNode,
|
4
|
-
FunctionComponent as PreactFunctionComponent
|
5
|
-
} from '../../src/internal';
|
6
|
-
import { SuspenseProps } from './suspense';
|
7
|
-
|
8
|
-
export { ComponentChildren } from '../..';
|
9
|
-
|
10
|
-
export { PreactElement } from '../../src/internal';
|
11
|
-
|
12
|
-
export interface Component<P = {}, S = {}> extends PreactComponent<P, S> {
|
13
|
-
isReactComponent?: object;
|
14
|
-
isPureReactComponent?: true;
|
15
|
-
_patchedLifecycles?: true;
|
16
|
-
|
17
|
-
// Suspense internal properties
|
18
|
-
_childDidSuspend?(error: Promise<void>, suspendingVNode: VNode): void;
|
19
|
-
_suspended: (vnode: VNode) => (unsuspend: () => void) => void;
|
20
|
-
_onResolve?(): void;
|
21
|
-
|
22
|
-
// Portal internal properties
|
23
|
-
_temp: any;
|
24
|
-
_container: PreactElement;
|
25
|
-
}
|
26
|
-
|
27
|
-
export interface FunctionComponent<P = {}> extends PreactFunctionComponent<P> {
|
28
|
-
shouldComponentUpdate?(nextProps: Readonly<P>): boolean;
|
29
|
-
_forwarded?: boolean;
|
30
|
-
_patchedLifecycles?: true;
|
31
|
-
}
|
32
|
-
|
33
|
-
export interface VNode<T = any> extends PreactVNode<T> {
|
34
|
-
$$typeof?: symbol | string;
|
35
|
-
preactCompatNormalized?: boolean;
|
36
|
-
}
|
37
|
-
|
38
|
-
export interface SuspenseState {
|
39
|
-
_suspended?: null | VNode<any>;
|
40
|
-
}
|
41
|
-
|
42
|
-
export interface SuspenseComponent
|
43
|
-
extends PreactComponent<SuspenseProps, SuspenseState> {
|
44
|
-
_pendingSuspensionCount: number;
|
45
|
-
_suspenders: Component[];
|
46
|
-
_detachOnNextRender: null | VNode<any>;
|
47
|
-
}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import { createElement } from 'preact';
|
2
|
-
import { shallowDiffers } from './util';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Memoize a component, so that it only updates when the props actually have
|
6
|
-
* changed. This was previously known as `React.pure`.
|
7
|
-
* @param {import('./internal').FunctionComponent} c functional component
|
8
|
-
* @param {(prev: object, next: object) => boolean} [comparer] Custom equality function
|
9
|
-
* @returns {import('./internal').FunctionComponent}
|
10
|
-
*/
|
11
|
-
export function memo(c, comparer) {
|
12
|
-
function shouldUpdate(nextProps) {
|
13
|
-
let ref = this.props.ref;
|
14
|
-
let updateRef = ref == nextProps.ref;
|
15
|
-
if (!updateRef && ref) {
|
16
|
-
ref.call ? ref(null) : (ref.current = null);
|
17
|
-
}
|
18
|
-
|
19
|
-
if (!comparer) {
|
20
|
-
return shallowDiffers(this.props, nextProps);
|
21
|
-
}
|
22
|
-
|
23
|
-
return !comparer(this.props, nextProps) || !updateRef;
|
24
|
-
}
|
25
|
-
|
26
|
-
function Memoed(props) {
|
27
|
-
this.shouldComponentUpdate = shouldUpdate;
|
28
|
-
return createElement(c, props);
|
29
|
-
}
|
30
|
-
Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
|
31
|
-
Memoed.prototype.isReactComponent = true;
|
32
|
-
Memoed._forwarded = true;
|
33
|
-
return Memoed;
|
34
|
-
}
|
@@ -1,82 +0,0 @@
|
|
1
|
-
import { createElement, render } from 'preact';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* @param {import('../../src/index').RenderableProps<{ context: any }>} props
|
5
|
-
*/
|
6
|
-
function ContextProvider(props) {
|
7
|
-
this.getChildContext = () => props.context;
|
8
|
-
return props.children;
|
9
|
-
}
|
10
|
-
|
11
|
-
/**
|
12
|
-
* Portal component
|
13
|
-
* @this {import('./internal').Component}
|
14
|
-
* @param {object | null | undefined} props
|
15
|
-
*
|
16
|
-
* TODO: use createRoot() instead of fake root
|
17
|
-
*/
|
18
|
-
function Portal(props) {
|
19
|
-
const _this = this;
|
20
|
-
let container = props._container;
|
21
|
-
|
22
|
-
_this.componentWillUnmount = function() {
|
23
|
-
render(null, _this._temp);
|
24
|
-
_this._temp = null;
|
25
|
-
_this._container = null;
|
26
|
-
};
|
27
|
-
|
28
|
-
// When we change container we should clear our old container and
|
29
|
-
// indicate a new mount.
|
30
|
-
if (_this._container && _this._container !== container) {
|
31
|
-
_this.componentWillUnmount();
|
32
|
-
}
|
33
|
-
|
34
|
-
// When props.vnode is undefined/false/null we are dealing with some kind of
|
35
|
-
// conditional vnode. This should not trigger a render.
|
36
|
-
if (props._vnode) {
|
37
|
-
if (!_this._temp) {
|
38
|
-
_this._container = container;
|
39
|
-
|
40
|
-
// Create a fake DOM parent node that manages a subset of `container`'s children:
|
41
|
-
_this._temp = {
|
42
|
-
nodeType: 1,
|
43
|
-
parentNode: container,
|
44
|
-
childNodes: [],
|
45
|
-
appendChild(child) {
|
46
|
-
this.childNodes.push(child);
|
47
|
-
_this._container.appendChild(child);
|
48
|
-
},
|
49
|
-
insertBefore(child, before) {
|
50
|
-
this.childNodes.push(child);
|
51
|
-
_this._container.appendChild(child);
|
52
|
-
},
|
53
|
-
removeChild(child) {
|
54
|
-
this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);
|
55
|
-
_this._container.removeChild(child);
|
56
|
-
}
|
57
|
-
};
|
58
|
-
}
|
59
|
-
|
60
|
-
// Render our wrapping element into temp.
|
61
|
-
render(
|
62
|
-
createElement(ContextProvider, { context: _this.context }, props._vnode),
|
63
|
-
_this._temp
|
64
|
-
);
|
65
|
-
}
|
66
|
-
// When we come from a conditional render, on a mounted
|
67
|
-
// portal we should clear the DOM.
|
68
|
-
else if (_this._temp) {
|
69
|
-
_this.componentWillUnmount();
|
70
|
-
}
|
71
|
-
}
|
72
|
-
|
73
|
-
/**
|
74
|
-
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
75
|
-
* @param {import('./internal').VNode} vnode The vnode to render
|
76
|
-
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
77
|
-
*/
|
78
|
-
export function createPortal(vnode, container) {
|
79
|
-
const el = createElement(Portal, { _vnode: vnode, _container: container });
|
80
|
-
el.containerInfo = container;
|
81
|
-
return el;
|
82
|
-
}
|
@@ -1,238 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
render as preactRender,
|
3
|
-
hydrate as preactHydrate,
|
4
|
-
options,
|
5
|
-
toChildArray,
|
6
|
-
Component
|
7
|
-
} from 'preact';
|
8
|
-
|
9
|
-
export const REACT_ELEMENT_TYPE =
|
10
|
-
(typeof Symbol != 'undefined' && Symbol.for && Symbol.for('react.element')) ||
|
11
|
-
0xeac7;
|
12
|
-
|
13
|
-
const CAMEL_PROPS = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|shape|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
|
14
|
-
|
15
|
-
const IS_DOM = typeof document !== 'undefined';
|
16
|
-
|
17
|
-
// Input types for which onchange should not be converted to oninput.
|
18
|
-
// type="file|checkbox|radio", plus "range" in IE11.
|
19
|
-
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
|
20
|
-
const onChangeInputType = type =>
|
21
|
-
(typeof Symbol != 'undefined' && typeof Symbol() == 'symbol'
|
22
|
-
? /fil|che|rad/i
|
23
|
-
: /fil|che|ra/i
|
24
|
-
).test(type);
|
25
|
-
|
26
|
-
// Some libraries like `react-virtualized` explicitly check for this.
|
27
|
-
Component.prototype.isReactComponent = {};
|
28
|
-
|
29
|
-
// `UNSAFE_*` lifecycle hooks
|
30
|
-
// Preact only ever invokes the unprefixed methods.
|
31
|
-
// Here we provide a base "fallback" implementation that calls any defined UNSAFE_ prefixed method.
|
32
|
-
// - If a component defines its own `componentDidMount()` (including via defineProperty), use that.
|
33
|
-
// - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.
|
34
|
-
// - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.
|
35
|
-
// See https://github.com/preactjs/preact/issues/1941
|
36
|
-
[
|
37
|
-
'componentWillMount',
|
38
|
-
'componentWillReceiveProps',
|
39
|
-
'componentWillUpdate'
|
40
|
-
].forEach(key => {
|
41
|
-
Object.defineProperty(Component.prototype, key, {
|
42
|
-
configurable: true,
|
43
|
-
get() {
|
44
|
-
return this['UNSAFE_' + key];
|
45
|
-
},
|
46
|
-
set(v) {
|
47
|
-
Object.defineProperty(this, key, {
|
48
|
-
configurable: true,
|
49
|
-
writable: true,
|
50
|
-
value: v
|
51
|
-
});
|
52
|
-
}
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
/**
|
57
|
-
* Proxy render() since React returns a Component reference.
|
58
|
-
* @param {import('./internal').VNode} vnode VNode tree to render
|
59
|
-
* @param {import('./internal').PreactElement} parent DOM node to render vnode tree into
|
60
|
-
* @param {() => void} [callback] Optional callback that will be called after rendering
|
61
|
-
* @returns {import('./internal').Component | null} The root component reference or null
|
62
|
-
*/
|
63
|
-
export function render(vnode, parent, callback) {
|
64
|
-
// React destroys any existing DOM nodes, see #1727
|
65
|
-
// ...but only on the first render, see #1828
|
66
|
-
if (parent._children == null) {
|
67
|
-
parent.textContent = '';
|
68
|
-
}
|
69
|
-
|
70
|
-
preactRender(vnode, parent);
|
71
|
-
if (typeof callback == 'function') callback();
|
72
|
-
|
73
|
-
return vnode ? vnode._component : null;
|
74
|
-
}
|
75
|
-
|
76
|
-
export function hydrate(vnode, parent, callback) {
|
77
|
-
preactHydrate(vnode, parent);
|
78
|
-
if (typeof callback == 'function') callback();
|
79
|
-
|
80
|
-
return vnode ? vnode._component : null;
|
81
|
-
}
|
82
|
-
|
83
|
-
let oldEventHook = options.event;
|
84
|
-
options.event = e => {
|
85
|
-
if (oldEventHook) e = oldEventHook(e);
|
86
|
-
e.persist = empty;
|
87
|
-
e.isPropagationStopped = isPropagationStopped;
|
88
|
-
e.isDefaultPrevented = isDefaultPrevented;
|
89
|
-
return (e.nativeEvent = e);
|
90
|
-
};
|
91
|
-
|
92
|
-
function empty() {}
|
93
|
-
|
94
|
-
function isPropagationStopped() {
|
95
|
-
return this.cancelBubble;
|
96
|
-
}
|
97
|
-
|
98
|
-
function isDefaultPrevented() {
|
99
|
-
return this.defaultPrevented;
|
100
|
-
}
|
101
|
-
|
102
|
-
let classNameDescriptor = {
|
103
|
-
configurable: true,
|
104
|
-
get() {
|
105
|
-
return this.class;
|
106
|
-
}
|
107
|
-
};
|
108
|
-
|
109
|
-
let oldVNodeHook = options.vnode;
|
110
|
-
options.vnode = vnode => {
|
111
|
-
let type = vnode.type;
|
112
|
-
let props = vnode.props;
|
113
|
-
let normalizedProps = props;
|
114
|
-
|
115
|
-
// only normalize props on Element nodes
|
116
|
-
if (typeof type === 'string') {
|
117
|
-
const nonCustomElement = type.indexOf('-') === -1;
|
118
|
-
normalizedProps = {};
|
119
|
-
|
120
|
-
for (let i in props) {
|
121
|
-
let value = props[i];
|
122
|
-
|
123
|
-
if (IS_DOM && i === 'children' && type === 'noscript') {
|
124
|
-
// Emulate React's behavior of not rendering the contents of noscript tags on the client.
|
125
|
-
continue;
|
126
|
-
} else if (i === 'value' && 'defaultValue' in props && value == null) {
|
127
|
-
// Skip applying value if it is null/undefined and we already set
|
128
|
-
// a default value
|
129
|
-
continue;
|
130
|
-
} else if (
|
131
|
-
i === 'defaultValue' &&
|
132
|
-
'value' in props &&
|
133
|
-
props.value == null
|
134
|
-
) {
|
135
|
-
// `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
|
136
|
-
// `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
|
137
|
-
i = 'value';
|
138
|
-
} else if (i === 'download' && value === true) {
|
139
|
-
// Calling `setAttribute` with a truthy value will lead to it being
|
140
|
-
// passed as a stringified value, e.g. `download="true"`. React
|
141
|
-
// converts it to an empty string instead, otherwise the attribute
|
142
|
-
// value will be used as the file name and the file will be called
|
143
|
-
// "true" upon downloading it.
|
144
|
-
value = '';
|
145
|
-
} else if (/ondoubleclick/i.test(i)) {
|
146
|
-
i = 'ondblclick';
|
147
|
-
} else if (
|
148
|
-
/^onchange(textarea|input)/i.test(i + type) &&
|
149
|
-
!onChangeInputType(props.type)
|
150
|
-
) {
|
151
|
-
i = 'oninput';
|
152
|
-
} else if (/^onfocus$/i.test(i)) {
|
153
|
-
i = 'onfocusin';
|
154
|
-
} else if (/^onblur$/i.test(i)) {
|
155
|
-
i = 'onfocusout';
|
156
|
-
} else if (/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(i)) {
|
157
|
-
i = i.toLowerCase();
|
158
|
-
} else if (nonCustomElement && CAMEL_PROPS.test(i)) {
|
159
|
-
i = i.replace(/[A-Z0-9]/, '-$&').toLowerCase();
|
160
|
-
} else if (value === null) {
|
161
|
-
value = undefined;
|
162
|
-
}
|
163
|
-
|
164
|
-
// Add support for onInput and onChange, see #3561
|
165
|
-
// if we have an oninput prop already change it to oninputCapture
|
166
|
-
if (/^oninput$/i.test(i)) {
|
167
|
-
i = i.toLowerCase();
|
168
|
-
if (normalizedProps[i]) {
|
169
|
-
i = 'oninputCapture';
|
170
|
-
}
|
171
|
-
}
|
172
|
-
|
173
|
-
normalizedProps[i] = value;
|
174
|
-
}
|
175
|
-
|
176
|
-
// Add support for array select values: <select multiple value={[]} />
|
177
|
-
if (
|
178
|
-
type == 'select' &&
|
179
|
-
normalizedProps.multiple &&
|
180
|
-
Array.isArray(normalizedProps.value)
|
181
|
-
) {
|
182
|
-
// forEach() always returns undefined, which we abuse here to unset the value prop.
|
183
|
-
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
184
|
-
child.props.selected =
|
185
|
-
normalizedProps.value.indexOf(child.props.value) != -1;
|
186
|
-
});
|
187
|
-
}
|
188
|
-
|
189
|
-
// Adding support for defaultValue in select tag
|
190
|
-
if (type == 'select' && normalizedProps.defaultValue != null) {
|
191
|
-
normalizedProps.value = toChildArray(props.children).forEach(child => {
|
192
|
-
if (normalizedProps.multiple) {
|
193
|
-
child.props.selected =
|
194
|
-
normalizedProps.defaultValue.indexOf(child.props.value) != -1;
|
195
|
-
} else {
|
196
|
-
child.props.selected =
|
197
|
-
normalizedProps.defaultValue == child.props.value;
|
198
|
-
}
|
199
|
-
});
|
200
|
-
}
|
201
|
-
|
202
|
-
vnode.props = normalizedProps;
|
203
|
-
|
204
|
-
if (props.class != props.className) {
|
205
|
-
classNameDescriptor.enumerable = 'className' in props;
|
206
|
-
if (props.className != null) normalizedProps.class = props.className;
|
207
|
-
Object.defineProperty(normalizedProps, 'className', classNameDescriptor);
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
vnode.$$typeof = REACT_ELEMENT_TYPE;
|
212
|
-
|
213
|
-
if (oldVNodeHook) oldVNodeHook(vnode);
|
214
|
-
};
|
215
|
-
|
216
|
-
// Only needed for react-relay
|
217
|
-
let currentComponent;
|
218
|
-
const oldBeforeRender = options._render;
|
219
|
-
options._render = function(vnode) {
|
220
|
-
if (oldBeforeRender) {
|
221
|
-
oldBeforeRender(vnode);
|
222
|
-
}
|
223
|
-
currentComponent = vnode._component;
|
224
|
-
};
|
225
|
-
|
226
|
-
// This is a very very private internal function for React it
|
227
|
-
// is used to sort-of do runtime dependency injection. So far
|
228
|
-
// only `react-relay` makes use of it. It uses it to read the
|
229
|
-
// context value.
|
230
|
-
export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
231
|
-
ReactCurrentDispatcher: {
|
232
|
-
current: {
|
233
|
-
readContext(context) {
|
234
|
-
return currentComponent._globalContext[context._id].props.value;
|
235
|
-
}
|
236
|
-
}
|
237
|
-
}
|
238
|
-
};
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { Component, ComponentChild, ComponentChildren } from '../../src';
|
2
|
-
|
3
|
-
//
|
4
|
-
// SuspenseList
|
5
|
-
// -----------------------------------
|
6
|
-
|
7
|
-
export interface SuspenseListProps {
|
8
|
-
children?: ComponentChildren;
|
9
|
-
revealOrder?: 'forwards' | 'backwards' | 'together';
|
10
|
-
}
|
11
|
-
|
12
|
-
export class SuspenseList extends Component<SuspenseListProps> {
|
13
|
-
render(): ComponentChild;
|
14
|
-
}
|