isomorfeus-preact 10.6.2 → 10.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/preact/version.rb +1 -1
- data/node_modules/.package-lock.json +3 -3
- data/node_modules/preact/LICENSE +21 -21
- data/node_modules/preact/README.md +187 -187
- data/node_modules/preact/compat/dist/compat.js +1 -1
- data/node_modules/preact/compat/dist/compat.js.map +1 -1
- data/node_modules/preact/compat/dist/compat.mjs +1 -1
- data/node_modules/preact/compat/dist/compat.module.js +1 -1
- data/node_modules/preact/compat/dist/compat.module.js.map +1 -1
- data/node_modules/preact/compat/dist/compat.umd.js +1 -1
- data/node_modules/preact/compat/dist/compat.umd.js.map +1 -1
- data/node_modules/preact/compat/jsx-dev-runtime.js +1 -1
- data/node_modules/preact/compat/jsx-dev-runtime.mjs +1 -1
- data/node_modules/preact/compat/jsx-runtime.js +1 -1
- data/node_modules/preact/compat/jsx-runtime.mjs +1 -1
- data/node_modules/preact/compat/package.json +19 -19
- data/node_modules/preact/compat/scheduler.js +15 -15
- data/node_modules/preact/compat/scheduler.mjs +23 -23
- data/node_modules/preact/compat/server.js +15 -15
- data/node_modules/preact/compat/server.mjs +4 -4
- data/node_modules/preact/compat/src/Children.js +21 -21
- data/node_modules/preact/compat/src/PureComponent.js +15 -15
- data/node_modules/preact/compat/src/forwardRef.js +51 -51
- data/node_modules/preact/compat/src/index.d.ts +141 -141
- data/node_modules/preact/compat/src/index.js +187 -187
- data/node_modules/preact/compat/src/internal.d.ts +47 -47
- data/node_modules/preact/compat/src/memo.js +34 -34
- data/node_modules/preact/compat/src/portals.js +80 -80
- data/node_modules/preact/compat/src/render.js +230 -226
- data/node_modules/preact/compat/src/suspense-list.d.ts +14 -14
- data/node_modules/preact/compat/src/suspense-list.js +126 -126
- data/node_modules/preact/compat/src/suspense.d.ts +15 -15
- data/node_modules/preact/compat/src/suspense.js +270 -270
- data/node_modules/preact/compat/src/util.js +28 -28
- data/node_modules/preact/compat/test-utils.js +1 -1
- data/node_modules/preact/debug/dist/debug.js.map +1 -1
- data/node_modules/preact/debug/dist/debug.module.js.map +1 -1
- data/node_modules/preact/debug/dist/debug.umd.js.map +1 -1
- data/node_modules/preact/debug/package.json +18 -18
- data/node_modules/preact/debug/src/check-props.js +54 -54
- data/node_modules/preact/debug/src/component-stack.js +146 -146
- data/node_modules/preact/debug/src/constants.js +3 -3
- data/node_modules/preact/debug/src/debug.js +442 -442
- data/node_modules/preact/debug/src/index.js +6 -6
- data/node_modules/preact/debug/src/internal.d.ts +82 -82
- data/node_modules/preact/debug/src/util.js +11 -11
- data/node_modules/preact/devtools/dist/devtools.js +1 -1
- data/node_modules/preact/devtools/dist/devtools.js.map +1 -1
- data/node_modules/preact/devtools/dist/devtools.mjs +1 -1
- data/node_modules/preact/devtools/dist/devtools.module.js +1 -1
- data/node_modules/preact/devtools/dist/devtools.module.js.map +1 -1
- data/node_modules/preact/devtools/dist/devtools.umd.js +1 -1
- data/node_modules/preact/devtools/dist/devtools.umd.js.map +1 -1
- data/node_modules/preact/devtools/package.json +16 -16
- data/node_modules/preact/devtools/src/devtools.js +10 -10
- data/node_modules/preact/devtools/src/index.d.ts +8 -8
- data/node_modules/preact/devtools/src/index.js +15 -15
- data/node_modules/preact/dist/preact.js.map +1 -1
- data/node_modules/preact/dist/preact.min.js.map +1 -1
- data/node_modules/preact/dist/preact.module.js.map +1 -1
- data/node_modules/preact/dist/preact.umd.js.map +1 -1
- data/node_modules/preact/hooks/dist/hooks.js +1 -1
- data/node_modules/preact/hooks/dist/hooks.js.map +1 -1
- data/node_modules/preact/hooks/dist/hooks.mjs +1 -1
- data/node_modules/preact/hooks/dist/hooks.module.js +1 -1
- data/node_modules/preact/hooks/dist/hooks.module.js.map +1 -1
- data/node_modules/preact/hooks/dist/hooks.umd.js +1 -1
- data/node_modules/preact/hooks/dist/hooks.umd.js.map +1 -1
- data/node_modules/preact/hooks/package.json +26 -26
- data/node_modules/preact/hooks/src/index.d.ts +139 -139
- data/node_modules/preact/hooks/src/index.js +388 -387
- data/node_modules/preact/hooks/src/internal.d.ts +75 -75
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -1
- data/node_modules/preact/jsx-runtime/package.json +19 -19
- data/node_modules/preact/jsx-runtime/src/index.d.ts +50 -50
- data/node_modules/preact/jsx-runtime/src/index.js +77 -77
- data/node_modules/preact/package.json +287 -287
- data/node_modules/preact/src/cjs.js +3 -3
- data/node_modules/preact/src/clone-element.js +34 -34
- data/node_modules/preact/src/component.js +225 -225
- data/node_modules/preact/src/constants.js +3 -3
- data/node_modules/preact/src/create-context.js +68 -68
- data/node_modules/preact/src/create-element.js +98 -98
- data/node_modules/preact/src/diff/catch-error.js +38 -38
- data/node_modules/preact/src/diff/children.js +335 -335
- data/node_modules/preact/src/diff/index.js +516 -516
- data/node_modules/preact/src/diff/props.js +158 -158
- data/node_modules/preact/src/index.d.ts +310 -310
- data/node_modules/preact/src/index.js +13 -13
- data/node_modules/preact/src/internal.d.ts +146 -146
- data/node_modules/preact/src/jsx.d.ts +1005 -1005
- data/node_modules/preact/src/options.js +16 -16
- data/node_modules/preact/src/render.js +75 -75
- data/node_modules/preact/src/util.js +27 -27
- data/node_modules/preact/test-utils/dist/testUtils.js.map +1 -1
- data/node_modules/preact/test-utils/dist/testUtils.module.js.map +1 -1
- data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +1 -1
- data/node_modules/preact/test-utils/package.json +19 -19
- data/node_modules/preact/test-utils/src/index.d.ts +3 -3
- data/node_modules/preact/test-utils/src/index.js +117 -117
- data/package.json +1 -1
- metadata +17 -37
- data/node_modules/preact/compat/dist/compat.mjs.map +0 -1
- data/node_modules/preact/compat/dist/compat.modern.js +0 -2
- data/node_modules/preact/compat/dist/compat.modern.js.map +0 -1
- data/node_modules/preact/debug/dist/debug.mjs.map +0 -1
- data/node_modules/preact/debug/dist/debug.modern.js +0 -2
- data/node_modules/preact/debug/dist/debug.modern.js.map +0 -1
- data/node_modules/preact/devtools/dist/devtools.mjs.map +0 -1
- data/node_modules/preact/devtools/dist/devtools.modern.js +0 -2
- data/node_modules/preact/devtools/dist/devtools.modern.js.map +0 -1
- data/node_modules/preact/dist/index.d.ts +0 -1295
- data/node_modules/preact/dist/preact.mjs.map +0 -1
- data/node_modules/preact/hooks/dist/hooks.mjs.map +0 -1
- data/node_modules/preact/hooks/dist/hooks.modern.js +0 -2
- data/node_modules/preact/hooks/dist/hooks.modern.js.map +0 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs.map +0 -1
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.modern.js +0 -2
- data/node_modules/preact/jsx-runtime/dist/jsxRuntime.modern.js.map +0 -1
- data/node_modules/preact/test-utils/dist/testUtils.mjs.map +0 -1
- data/node_modules/preact/test-utils/dist/testUtils.modern.js +0 -2
- data/node_modules/preact/test-utils/dist/testUtils.modern.js.map +0 -1
@@ -1,2 +1,2 @@
|
|
1
|
-
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t(n.preactHooks={},n.preact)}(this,function(n,t){var u,o,i
|
1
|
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t(n.preactHooks={},n.preact)}(this,function(n,t){var u,r,o,i=0,c=[],f=t.options.__b,e=t.options.__r,a=t.options.diffed,v=t.options.__c,p=t.options.unmount;function l(n,u){t.options.__h&&t.options.__h(r,n,i||u),i=0;var o=r.__H||(r.__H={__:[],__h:[]});return n>=o.__.length&&o.__.push({}),o.__[n]}function m(n){return i=1,y(F,n)}function y(n,t,o){var i=l(u++,2);return i.t=n,i.__c||(i.__=[o?o(t):F(void 0,t),function(n){var t=i.t(i.__[0],n);i.__[0]!==t&&(i.__=[t,i.__[1]],i.__c.setState({}))}],i.__c=r),i.__}function d(n,o){var i=l(u++,4);!t.options.__s&&A(i.__H,o)&&(i.__=n,i.__H=o,r.__h.push(i))}function s(n,t){var r=l(u++,7);return A(r.__H,t)&&(r.__=n(),r.__H=t,r.__h=n),r.__}function h(){var n;for(c.sort(function(n,t){return n.__v.__b-t.__v.__b});n=c.pop();)if(n.__P)try{n.__H.__h.forEach(q),n.__H.__h.forEach(x),n.__H.__h=[]}catch(u){n.__H.__h=[],t.options.__e(u,n.__v)}}t.options.__b=function(n){r=null,f&&f(n)},t.options.__r=function(n){e&&e(n),u=0;var t=(r=n.__c).__H;t&&(t.__h.forEach(q),t.__h.forEach(x),t.__h=[])},t.options.diffed=function(n){a&&a(n);var u=n.__c;u&&u.__H&&u.__H.__h.length&&(1!==c.push(u)&&o===t.options.requestAnimationFrame||((o=t.options.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),_&&cancelAnimationFrame(t),setTimeout(n)},r=setTimeout(u,100);_&&(t=requestAnimationFrame(u))})(h)),r=null},t.options.__c=function(n,u){u.some(function(n){try{n.__h.forEach(q),n.__h=n.__h.filter(function(n){return!n.__||x(n)})}catch(r){u.some(function(n){n.__h&&(n.__h=[])}),u=[],t.options.__e(r,n.__v)}}),v&&v(n,u)},t.options.unmount=function(n){p&&p(n);var u,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{q(n)}catch(n){u=n}}),u&&t.options.__e(u,r.__v))};var _="function"==typeof requestAnimationFrame;function q(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function x(n){var t=r;n.__c=n.__(),r=t}function A(n,t){return!n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}function F(n,t){return"function"==typeof t?t(n):t}n.useState=m,n.useReducer=y,n.useEffect=function(n,o){var i=l(u++,3);!t.options.__s&&A(i.__H,o)&&(i.__=n,i.__H=o,r.__H.__h.push(i))},n.useLayoutEffect=d,n.useRef=function(n){return i=5,s(function(){return{current:n}},[])},n.useImperativeHandle=function(n,t,u){i=6,d(function(){"function"==typeof n?n(t()):n&&(n.current=t())},null==u?u:u.concat(n))},n.useMemo=s,n.useCallback=function(n,t){return i=8,s(function(){return n},t)},n.useContext=function(n){var t=r.context[n.__c],o=l(u++,9);return o.c=n,t?(null==o.__&&(o.__=!0,t.sub(r)),t.props.value):n.__},n.useDebugValue=function(n,u){t.options.useDebugValue&&t.options.useDebugValue(u?u(n):n)},n.useErrorBoundary=function(n){var t=l(u++,10),o=m();return t.__=n,r.componentDidCatch||(r.componentDidCatch=function(n){t.__&&t.__(n),o[1](n)}),[o[0],function(){o[1](void 0)}]}});
|
2
2
|
//# sourceMappingURL=hooks.umd.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"hooks.umd.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\n\n/** @type {number} */\nlet currentIndex;\n\n/** @type {import('./internal').Component} */\nlet currentComponent;\n\n/** @type {number} */\nlet currentHook = 0;\n\n/** @type {Array<import('./internal').Component>} */\nlet afterPaintEffects = [];\n\nlet oldBeforeDiff = options._diff;\nlet oldBeforeRender = options._render;\nlet oldAfterDiff = options.diffed;\nlet oldCommit = options._commit;\nlet oldBeforeUnmount = options.unmount;\n\nconst RAF_TIMEOUT = 100;\nlet prevRaf;\n\noptions._diff = vnode => {\n\tcurrentComponent = null;\n\tif (oldBeforeDiff) oldBeforeDiff(vnode);\n};\n\noptions._render = vnode => {\n\tif (oldBeforeRender) oldBeforeRender(vnode);\n\n\tcurrentComponent = vnode._component;\n\tcurrentIndex = 0;\n\n\tconst hooks = currentComponent.__hooks;\n\tif (hooks) {\n\t\thooks._pendingEffects.forEach(invokeCleanup);\n\t\thooks._pendingEffects.forEach(invokeEffect);\n\t\thooks._pendingEffects = [];\n\t}\n};\n\noptions.diffed = vnode => {\n\tif (oldAfterDiff) oldAfterDiff(vnode);\n\n\tconst c = vnode._component;\n\tif (c && c.__hooks && c.__hooks._pendingEffects.length) {\n\t\tafterPaint(afterPaintEffects.push(c));\n\t}\n\tcurrentComponent = null;\n};\n\noptions._commit = (vnode, commitQueue) => {\n\tcommitQueue.some(component => {\n\t\ttry {\n\t\t\tcomponent._renderCallbacks.forEach(invokeCleanup);\n\t\t\tcomponent._renderCallbacks = component._renderCallbacks.filter(cb =>\n\t\t\t\tcb._value ? invokeEffect(cb) : true\n\t\t\t);\n\t\t} catch (e) {\n\t\t\tcommitQueue.some(c => {\n\t\t\t\tif (c._renderCallbacks) c._renderCallbacks = [];\n\t\t\t});\n\t\t\tcommitQueue = [];\n\t\t\toptions._catchError(e, component._vnode);\n\t\t}\n\t});\n\n\tif (oldCommit) oldCommit(vnode, commitQueue);\n};\n\noptions.unmount = vnode => {\n\tif (oldBeforeUnmount) oldBeforeUnmount(vnode);\n\n\tconst c = vnode._component;\n\tif (c && c.__hooks) {\n\t\tlet hasErrored;\n\t\tc.__hooks._list.forEach(s => {\n\t\t\ttry {\n\t\t\t\tinvokeCleanup(s);\n\t\t\t} catch (e) {\n\t\t\t\thasErrored = e;\n\t\t\t}\n\t\t});\n\t\tif (hasErrored) options._catchError(hasErrored, c._vnode);\n\t}\n};\n\n/**\n * Get a hook's state from the currentComponent\n * @param {number} index The index of the hook to get\n * @param {number} type The index of the hook to get\n * @returns {any}\n */\nfunction getHookState(index, type) {\n\tif (options._hook) {\n\t\toptions._hook(currentComponent, index, currentHook || type);\n\t}\n\tcurrentHook = 0;\n\n\t// Largely inspired by:\n\t// * https://github.com/michael-klein/funcy.js/blob/f6be73468e6ec46b0ff5aa3cc4c9baf72a29025a/src/hooks/core_hooks.mjs\n\t// * https://github.com/michael-klein/funcy.js/blob/650beaa58c43c33a74820a3c98b3c7079cf2e333/src/renderer.mjs\n\t// Other implementations to look at:\n\t// * https://codesandbox.io/s/mnox05qp8\n\tconst hooks =\n\t\tcurrentComponent.__hooks ||\n\t\t(currentComponent.__hooks = {\n\t\t\t_list: [],\n\t\t\t_pendingEffects: []\n\t\t});\n\n\tif (index >= hooks._list.length) {\n\t\thooks._list.push({});\n\t}\n\treturn hooks._list[index];\n}\n\n/**\n * @param {import('./index').StateUpdater<any>} [initialState]\n */\nexport function useState(initialState) {\n\tcurrentHook = 1;\n\treturn useReducer(invokeOrReturn, initialState);\n}\n\n/**\n * @param {import('./index').Reducer<any, any>} reducer\n * @param {import('./index').StateUpdater<any>} initialState\n * @param {(initialState: any) => void} [init]\n * @returns {[ any, (state: any) => void ]}\n */\nexport function useReducer(reducer, initialState, init) {\n\t/** @type {import('./internal').ReducerHookState} */\n\tconst hookState = getHookState(currentIndex++, 2);\n\thookState._reducer = reducer;\n\tif (!hookState._component) {\n\t\thookState._value = [\n\t\t\t!init ? invokeOrReturn(undefined, initialState) : init(initialState),\n\n\t\t\taction => {\n\t\t\t\tconst nextValue = hookState._reducer(hookState._value[0], action);\n\t\t\t\tif (hookState._value[0] !== nextValue) {\n\t\t\t\t\thookState._value = [nextValue, hookState._value[1]];\n\t\t\t\t\thookState._component.setState({});\n\t\t\t\t}\n\t\t\t}\n\t\t];\n\n\t\thookState._component = currentComponent;\n\t}\n\n\treturn hookState._value;\n}\n\n/**\n * @param {import('./internal').Effect} callback\n * @param {any[]} args\n */\nexport function useEffect(callback, args) {\n\t/** @type {import('./internal').EffectHookState} */\n\tconst state = getHookState(currentIndex++, 3);\n\tif (!options._skipEffects && argsChanged(state._args, args)) {\n\t\tstate._value = callback;\n\t\tstate._args = args;\n\n\t\tcurrentComponent.__hooks._pendingEffects.push(state);\n\t}\n}\n\n/**\n * @param {import('./internal').Effect} callback\n * @param {any[]} args\n */\nexport function useLayoutEffect(callback, args) {\n\t/** @type {import('./internal').EffectHookState} */\n\tconst state = getHookState(currentIndex++, 4);\n\tif (!options._skipEffects && argsChanged(state._args, args)) {\n\t\tstate._value = callback;\n\t\tstate._args = args;\n\n\t\tcurrentComponent._renderCallbacks.push(state);\n\t}\n}\n\nexport function useRef(initialValue) {\n\tcurrentHook = 5;\n\treturn useMemo(() => ({ current: initialValue }), []);\n}\n\n/**\n * @param {object} ref\n * @param {() => object} createHandle\n * @param {any[]} args\n */\nexport function useImperativeHandle(ref, createHandle, args) {\n\tcurrentHook = 6;\n\tuseLayoutEffect(\n\t\t() => {\n\t\t\tif (typeof ref == 'function') ref(createHandle());\n\t\t\telse if (ref) ref.current = createHandle();\n\t\t},\n\t\targs == null ? args : args.concat(ref)\n\t);\n}\n\n/**\n * @param {() => any} factory\n * @param {any[]} args\n */\nexport function useMemo(factory, args) {\n\t/** @type {import('./internal').MemoHookState} */\n\tconst state = getHookState(currentIndex++, 7);\n\tif (argsChanged(state._args, args)) {\n\t\tstate._value = factory();\n\t\tstate._args = args;\n\t\tstate._factory = factory;\n\t}\n\n\treturn state._value;\n}\n\n/**\n * @param {() => void} callback\n * @param {any[]} args\n */\nexport function useCallback(callback, args) {\n\tcurrentHook = 8;\n\treturn useMemo(() => callback, args);\n}\n\n/**\n * @param {import('./internal').PreactContext} context\n */\nexport function useContext(context) {\n\tconst provider = currentComponent.context[context._id];\n\t// We could skip this call here, but than we'd not call\n\t// `options._hook`. We need to do that in order to make\n\t// the devtools aware of this hook.\n\t/** @type {import('./internal').ContextHookState} */\n\tconst state = getHookState(currentIndex++, 9);\n\t// The devtools needs access to the context object to\n\t// be able to pull of the default value when no provider\n\t// is present in the tree.\n\tstate._context = context;\n\tif (!provider) return context._defaultValue;\n\t// This is probably not safe to convert to \"!\"\n\tif (state._value == null) {\n\t\tstate._value = true;\n\t\tprovider.sub(currentComponent);\n\t}\n\treturn provider.props.value;\n}\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {<T>(value: T, cb?: (value: T) => string | number) => void}\n */\nexport function useDebugValue(value, formatter) {\n\tif (options.useDebugValue) {\n\t\toptions.useDebugValue(formatter ? formatter(value) : value);\n\t}\n}\n\n/**\n * @param {(error: any) => void} cb\n */\nexport function useErrorBoundary(cb) {\n\t/** @type {import('./internal').ErrorBoundaryHookState} */\n\tconst state = getHookState(currentIndex++, 10);\n\tconst errState = useState();\n\tstate._value = cb;\n\tif (!currentComponent.componentDidCatch) {\n\t\tcurrentComponent.componentDidCatch = err => {\n\t\t\tif (state._value) state._value(err);\n\t\t\terrState[1](err);\n\t\t};\n\t}\n\treturn [\n\t\terrState[0],\n\t\t() => {\n\t\t\terrState[1](undefined);\n\t\t}\n\t];\n}\n\n/**\n * After paint effects consumer.\n */\nfunction flushAfterPaintEffects() {\n\tafterPaintEffects.forEach(component => {\n\t\tif (component._parentDom) {\n\t\t\ttry {\n\t\t\t\tcomponent.__hooks._pendingEffects.forEach(invokeCleanup);\n\t\t\t\tcomponent.__hooks._pendingEffects.forEach(invokeEffect);\n\t\t\t\tcomponent.__hooks._pendingEffects = [];\n\t\t\t} catch (e) {\n\t\t\t\tcomponent.__hooks._pendingEffects = [];\n\t\t\t\toptions._catchError(e, component._vnode);\n\t\t\t}\n\t\t}\n\t});\n\tafterPaintEffects = [];\n}\n\nlet HAS_RAF = typeof requestAnimationFrame == 'function';\n\n/**\n * Schedule a callback to be invoked after the browser has a chance to paint a new frame.\n * Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after\n * the next browser frame.\n *\n * Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked\n * even if RAF doesn't fire (for example if the browser tab is not visible)\n *\n * @param {() => void} callback\n */\nfunction afterNextFrame(callback) {\n\tconst done = () => {\n\t\tclearTimeout(timeout);\n\t\tif (HAS_RAF) cancelAnimationFrame(raf);\n\t\tsetTimeout(callback);\n\t};\n\tconst timeout = setTimeout(done, RAF_TIMEOUT);\n\n\tlet raf;\n\tif (HAS_RAF) {\n\t\traf = requestAnimationFrame(done);\n\t}\n}\n\n// Note: if someone used options.debounceRendering = requestAnimationFrame,\n// then effects will ALWAYS run on the NEXT frame instead of the current one, incurring a ~16ms delay.\n// Perhaps this is not such a big deal.\n/**\n * Schedule afterPaintEffects flush after the browser paints\n * @param {number} newQueueLength\n */\nfunction afterPaint(newQueueLength) {\n\tif (newQueueLength === 1 || prevRaf !== options.requestAnimationFrame) {\n\t\tprevRaf = options.requestAnimationFrame;\n\t\t(prevRaf || afterNextFrame)(flushAfterPaintEffects);\n\t}\n}\n\n/**\n * @param {import('./internal').EffectHookState} hook\n */\nfunction invokeCleanup(hook) {\n\t// A hook cleanup can introduce a call to render which creates a new root, this will call options.vnode\n\t// and move the currentComponent away.\n\tconst comp = currentComponent;\n\tlet cleanup = hook._cleanup;\n\tif (typeof cleanup == 'function') {\n\t\thook._cleanup = undefined;\n\t\tcleanup();\n\t}\n\tcurrentComponent = comp;\n}\n\n/**\n * Invoke a Hook's effect\n * @param {import('./internal').EffectHookState} hook\n */\nfunction invokeEffect(hook) {\n\t// A hook call can introduce a call to render which creates a new root, this will call options.vnode\n\t// and move the currentComponent away.\n\tconst comp = currentComponent;\n\thook._cleanup = hook._value();\n\tcurrentComponent = comp;\n}\n\n/**\n * @param {any[]} oldArgs\n * @param {any[]} newArgs\n */\nfunction argsChanged(oldArgs, newArgs) {\n\treturn (\n\t\t!oldArgs ||\n\t\toldArgs.length !== newArgs.length ||\n\t\tnewArgs.some((arg, index) => arg !== oldArgs[index])\n\t);\n}\n\nfunction invokeOrReturn(arg, f) {\n\treturn typeof f == 'function' ? f(arg) : f;\n}\n"],"names":["currentIndex","currentComponent","prevRaf","currentHook","afterPaintEffects","oldBeforeDiff","options","oldBeforeRender","oldAfterDiff","diffed","oldCommit","oldBeforeUnmount","unmount","getHookState","index","type","hooks","length","push","useState","initialState","useReducer","invokeOrReturn","reducer","init","hookState","_reducer","undefined","action","nextValue","setState","useLayoutEffect","callback","args","state","argsChanged","useMemo","factory","flushAfterPaintEffects","forEach","component","invokeCleanup","invokeEffect","e","vnode","c","requestAnimationFrame","raf","done","clearTimeout","timeout","HAS_RAF","cancelAnimationFrame","setTimeout","commitQueue","some","filter","cb","hasErrored","s","hook","comp","cleanup","oldArgs","newArgs","arg","f","initialValue","current","ref","createHandle","concat","context","provider","sub","props","value","formatter","useDebugValue","errState","componentDidCatch","err"],"mappings":"uNAGA,IAAI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QT,KAAK,SAACU,EAAKnD,UAAUmD,IAAQF,EAAQjD,KAI/C,SAASQ,EAAe2C,EAAKC,SACT,mBAALA,EAAkBA,EAAED,GAAOC,0CAlOnC,SAAmBlC,EAAUC,OAE7BC,EAAQrB,EAAab,IAAgB,IACtCM,eAAwB6B,EAAYD,MAAaD,KACrDC,KAAeF,EACfE,MAAcD,EAEdhC,UAAyCiB,KAAKgB,kCAmBzC,SAAgBiC,UACtBhE,EAAc,EACPiC,EAAQ,iBAAO,CAAEgC,QAASD,IAAiB,2BAQ5C,SAA6BE,EAAKC,EAAcrC,GACtD9B,EAAc,EACd4B,EACC,WACmB,mBAAPsC,EAAmBA,EAAIC,KACzBD,IAAKA,EAAID,QAAUE,MAErB,MAARrC,EAAeA,EAAOA,EAAKsC,OAAOF,+BAwB7B,SAAqBrC,EAAUC,UACrC9B,EAAc,EACPiC,EAAQ,kBAAMJ,GAAUC,iBAMzB,SAAoBuC,OACpBC,EAAWxE,EAAiBuE,QAAQA,OAKpCtC,EAAQrB,EAAab,IAAgB,UAI3CkC,IAAiBsC,EACZC,GAEe,MAAhBvC,OACHA,MAAe,EACfuC,EAASC,IAAIzE,IAEPwE,EAASE,MAAMC,OANAJ,sBAahB,SAAuBI,EAAOC,GAChCvE,UAAQwE,eACXxE,UAAQwE,cAAcD,EAAYA,EAAUD,GAASA,uBAOhD,SAA0BnB,OAE1BvB,EAAQrB,EAAab,IAAgB,IACrC+E,EAAW5D,WACjBe,KAAeuB,EACVxD,EAAiB+E,oBACrB/E,EAAiB+E,kBAAoB,SAAAC,GAChC/C,MAAcA,KAAa+C,GAC/BF,EAAS,GAAGE,KAGP,CACNF,EAAS,GACT,WACCA,EAAS,QAAGpD"}
|
1
|
+
{"version":3,"file":"hooks.umd.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\r\n\r\n/** @type {number} */\r\nlet currentIndex;\r\n\r\n/** @type {import('./internal').Component} */\r\nlet currentComponent;\r\n\r\n/** @type {number} */\r\nlet currentHook = 0;\r\n\r\n/** @type {Array<import('./internal').Component>} */\r\nlet afterPaintEffects = [];\r\n\r\nlet oldBeforeDiff = options._diff;\r\nlet oldBeforeRender = options._render;\r\nlet oldAfterDiff = options.diffed;\r\nlet oldCommit = options._commit;\r\nlet oldBeforeUnmount = options.unmount;\r\n\r\nconst RAF_TIMEOUT = 100;\r\nlet prevRaf;\r\n\r\noptions._diff = vnode => {\r\n\tcurrentComponent = null;\r\n\tif (oldBeforeDiff) oldBeforeDiff(vnode);\r\n};\r\n\r\noptions._render = vnode => {\r\n\tif (oldBeforeRender) oldBeforeRender(vnode);\r\n\r\n\tcurrentComponent = vnode._component;\r\n\tcurrentIndex = 0;\r\n\r\n\tconst hooks = currentComponent.__hooks;\r\n\tif (hooks) {\r\n\t\thooks._pendingEffects.forEach(invokeCleanup);\r\n\t\thooks._pendingEffects.forEach(invokeEffect);\r\n\t\thooks._pendingEffects = [];\r\n\t}\r\n};\r\n\r\noptions.diffed = vnode => {\r\n\tif (oldAfterDiff) oldAfterDiff(vnode);\r\n\r\n\tconst c = vnode._component;\r\n\tif (c && c.__hooks && c.__hooks._pendingEffects.length) {\r\n\t\tafterPaint(afterPaintEffects.push(c));\r\n\t}\r\n\tcurrentComponent = null;\r\n};\r\n\r\noptions._commit = (vnode, commitQueue) => {\r\n\tcommitQueue.some(component => {\r\n\t\ttry {\r\n\t\t\tcomponent._renderCallbacks.forEach(invokeCleanup);\r\n\t\t\tcomponent._renderCallbacks = component._renderCallbacks.filter(cb =>\r\n\t\t\t\tcb._value ? invokeEffect(cb) : true\r\n\t\t\t);\r\n\t\t} catch (e) {\r\n\t\t\tcommitQueue.some(c => {\r\n\t\t\t\tif (c._renderCallbacks) c._renderCallbacks = [];\r\n\t\t\t});\r\n\t\t\tcommitQueue = [];\r\n\t\t\toptions._catchError(e, component._vnode);\r\n\t\t}\r\n\t});\r\n\r\n\tif (oldCommit) oldCommit(vnode, commitQueue);\r\n};\r\n\r\noptions.unmount = vnode => {\r\n\tif (oldBeforeUnmount) oldBeforeUnmount(vnode);\r\n\r\n\tconst c = vnode._component;\r\n\tif (c && c.__hooks) {\r\n\t\tlet hasErrored;\r\n\t\tc.__hooks._list.forEach(s => {\r\n\t\t\ttry {\r\n\t\t\t\tinvokeCleanup(s);\r\n\t\t\t} catch (e) {\r\n\t\t\t\thasErrored = e;\r\n\t\t\t}\r\n\t\t});\r\n\t\tif (hasErrored) options._catchError(hasErrored, c._vnode);\r\n\t}\r\n};\r\n\r\n/**\r\n * Get a hook's state from the currentComponent\r\n * @param {number} index The index of the hook to get\r\n * @param {number} type The index of the hook to get\r\n * @returns {any}\r\n */\r\nfunction getHookState(index, type) {\r\n\tif (options._hook) {\r\n\t\toptions._hook(currentComponent, index, currentHook || type);\r\n\t}\r\n\tcurrentHook = 0;\r\n\r\n\t// Largely inspired by:\r\n\t// * https://github.com/michael-klein/funcy.js/blob/f6be73468e6ec46b0ff5aa3cc4c9baf72a29025a/src/hooks/core_hooks.mjs\r\n\t// * https://github.com/michael-klein/funcy.js/blob/650beaa58c43c33a74820a3c98b3c7079cf2e333/src/renderer.mjs\r\n\t// Other implementations to look at:\r\n\t// * https://codesandbox.io/s/mnox05qp8\r\n\tconst hooks =\r\n\t\tcurrentComponent.__hooks ||\r\n\t\t(currentComponent.__hooks = {\r\n\t\t\t_list: [],\r\n\t\t\t_pendingEffects: []\r\n\t\t});\r\n\r\n\tif (index >= hooks._list.length) {\r\n\t\thooks._list.push({});\r\n\t}\r\n\treturn hooks._list[index];\r\n}\r\n\r\n/**\r\n * @param {import('./index').StateUpdater<any>} [initialState]\r\n */\r\nexport function useState(initialState) {\r\n\tcurrentHook = 1;\r\n\treturn useReducer(invokeOrReturn, initialState);\r\n}\r\n\r\n/**\r\n * @param {import('./index').Reducer<any, any>} reducer\r\n * @param {import('./index').StateUpdater<any>} initialState\r\n * @param {(initialState: any) => void} [init]\r\n * @returns {[ any, (state: any) => void ]}\r\n */\r\nexport function useReducer(reducer, initialState, init) {\r\n\t/** @type {import('./internal').ReducerHookState} */\r\n\tconst hookState = getHookState(currentIndex++, 2);\r\n\thookState._reducer = reducer;\r\n\tif (!hookState._component) {\r\n\t\thookState._value = [\r\n\t\t\t!init ? invokeOrReturn(undefined, initialState) : init(initialState),\r\n\r\n\t\t\taction => {\r\n\t\t\t\tconst nextValue = hookState._reducer(hookState._value[0], action);\r\n\t\t\t\tif (hookState._value[0] !== nextValue) {\r\n\t\t\t\t\thookState._value = [nextValue, hookState._value[1]];\r\n\t\t\t\t\thookState._component.setState({});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t];\r\n\r\n\t\thookState._component = currentComponent;\r\n\t}\r\n\r\n\treturn hookState._value;\r\n}\r\n\r\n/**\r\n * @param {import('./internal').Effect} callback\r\n * @param {any[]} args\r\n */\r\nexport function useEffect(callback, args) {\r\n\t/** @type {import('./internal').EffectHookState} */\r\n\tconst state = getHookState(currentIndex++, 3);\r\n\tif (!options._skipEffects && argsChanged(state._args, args)) {\r\n\t\tstate._value = callback;\r\n\t\tstate._args = args;\r\n\r\n\t\tcurrentComponent.__hooks._pendingEffects.push(state);\r\n\t}\r\n}\r\n\r\n/**\r\n * @param {import('./internal').Effect} callback\r\n * @param {any[]} args\r\n */\r\nexport function useLayoutEffect(callback, args) {\r\n\t/** @type {import('./internal').EffectHookState} */\r\n\tconst state = getHookState(currentIndex++, 4);\r\n\tif (!options._skipEffects && argsChanged(state._args, args)) {\r\n\t\tstate._value = callback;\r\n\t\tstate._args = args;\r\n\r\n\t\tcurrentComponent._renderCallbacks.push(state);\r\n\t}\r\n}\r\n\r\nexport function useRef(initialValue) {\r\n\tcurrentHook = 5;\r\n\treturn useMemo(() => ({ current: initialValue }), []);\r\n}\r\n\r\n/**\r\n * @param {object} ref\r\n * @param {() => object} createHandle\r\n * @param {any[]} args\r\n */\r\nexport function useImperativeHandle(ref, createHandle, args) {\r\n\tcurrentHook = 6;\r\n\tuseLayoutEffect(\r\n\t\t() => {\r\n\t\t\tif (typeof ref == 'function') ref(createHandle());\r\n\t\t\telse if (ref) ref.current = createHandle();\r\n\t\t},\r\n\t\targs == null ? args : args.concat(ref)\r\n\t);\r\n}\r\n\r\n/**\r\n * @param {() => any} factory\r\n * @param {any[]} args\r\n */\r\nexport function useMemo(factory, args) {\r\n\t/** @type {import('./internal').MemoHookState} */\r\n\tconst state = getHookState(currentIndex++, 7);\r\n\tif (argsChanged(state._args, args)) {\r\n\t\tstate._value = factory();\r\n\t\tstate._args = args;\r\n\t\tstate._factory = factory;\r\n\t}\r\n\r\n\treturn state._value;\r\n}\r\n\r\n/**\r\n * @param {() => void} callback\r\n * @param {any[]} args\r\n */\r\nexport function useCallback(callback, args) {\r\n\tcurrentHook = 8;\r\n\treturn useMemo(() => callback, args);\r\n}\r\n\r\n/**\r\n * @param {import('./internal').PreactContext} context\r\n */\r\nexport function useContext(context) {\r\n\tconst provider = currentComponent.context[context._id];\r\n\t// We could skip this call here, but than we'd not call\r\n\t// `options._hook`. We need to do that in order to make\r\n\t// the devtools aware of this hook.\r\n\t/** @type {import('./internal').ContextHookState} */\r\n\tconst state = getHookState(currentIndex++, 9);\r\n\t// The devtools needs access to the context object to\r\n\t// be able to pull of the default value when no provider\r\n\t// is present in the tree.\r\n\tstate._context = context;\r\n\tif (!provider) return context._defaultValue;\r\n\t// This is probably not safe to convert to \"!\"\r\n\tif (state._value == null) {\r\n\t\tstate._value = true;\r\n\t\tprovider.sub(currentComponent);\r\n\t}\r\n\treturn provider.props.value;\r\n}\r\n\r\n/**\r\n * Display a custom label for a custom hook for the devtools panel\r\n * @type {<T>(value: T, cb?: (value: T) => string | number) => void}\r\n */\r\nexport function useDebugValue(value, formatter) {\r\n\tif (options.useDebugValue) {\r\n\t\toptions.useDebugValue(formatter ? formatter(value) : value);\r\n\t}\r\n}\r\n\r\n/**\r\n * @param {(error: any) => void} cb\r\n */\r\nexport function useErrorBoundary(cb) {\r\n\t/** @type {import('./internal').ErrorBoundaryHookState} */\r\n\tconst state = getHookState(currentIndex++, 10);\r\n\tconst errState = useState();\r\n\tstate._value = cb;\r\n\tif (!currentComponent.componentDidCatch) {\r\n\t\tcurrentComponent.componentDidCatch = err => {\r\n\t\t\tif (state._value) state._value(err);\r\n\t\t\terrState[1](err);\r\n\t\t};\r\n\t}\r\n\treturn [\r\n\t\terrState[0],\r\n\t\t() => {\r\n\t\t\terrState[1](undefined);\r\n\t\t}\r\n\t];\r\n}\r\n\r\n/**\r\n * After paint effects consumer.\r\n */\r\nfunction flushAfterPaintEffects() {\r\n\tlet component;\r\n\t// sort the queue by depth (outermost to innermost)\r\n\tafterPaintEffects.sort((a, b) => a._vnode._depth - b._vnode._depth);\r\n\twhile (component = afterPaintEffects.pop()) {\r\n\t\tif (!component._parentDom) continue;\r\n\t\ttry {\r\n\t\t\tcomponent.__hooks._pendingEffects.forEach(invokeCleanup);\r\n\t\t\tcomponent.__hooks._pendingEffects.forEach(invokeEffect);\r\n\t\t\tcomponent.__hooks._pendingEffects = [];\r\n\t\t} catch (e) {\r\n\t\t\tcomponent.__hooks._pendingEffects = [];\r\n\t\t\toptions._catchError(e, component._vnode);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nlet HAS_RAF = typeof requestAnimationFrame == 'function';\r\n\r\n/**\r\n * Schedule a callback to be invoked after the browser has a chance to paint a new frame.\r\n * Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after\r\n * the next browser frame.\r\n *\r\n * Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked\r\n * even if RAF doesn't fire (for example if the browser tab is not visible)\r\n *\r\n * @param {() => void} callback\r\n */\r\nfunction afterNextFrame(callback) {\r\n\tconst done = () => {\r\n\t\tclearTimeout(timeout);\r\n\t\tif (HAS_RAF) cancelAnimationFrame(raf);\r\n\t\tsetTimeout(callback);\r\n\t};\r\n\tconst timeout = setTimeout(done, RAF_TIMEOUT);\r\n\r\n\tlet raf;\r\n\tif (HAS_RAF) {\r\n\t\traf = requestAnimationFrame(done);\r\n\t}\r\n}\r\n\r\n// Note: if someone used options.debounceRendering = requestAnimationFrame,\r\n// then effects will ALWAYS run on the NEXT frame instead of the current one, incurring a ~16ms delay.\r\n// Perhaps this is not such a big deal.\r\n/**\r\n * Schedule afterPaintEffects flush after the browser paints\r\n * @param {number} newQueueLength\r\n */\r\nfunction afterPaint(newQueueLength) {\r\n\tif (newQueueLength === 1 || prevRaf !== options.requestAnimationFrame) {\r\n\t\tprevRaf = options.requestAnimationFrame;\r\n\t\t(prevRaf || afterNextFrame)(flushAfterPaintEffects);\r\n\t}\r\n}\r\n\r\n/**\r\n * @param {import('./internal').EffectHookState} hook\r\n */\r\nfunction invokeCleanup(hook) {\r\n\t// A hook cleanup can introduce a call to render which creates a new root, this will call options.vnode\r\n\t// and move the currentComponent away.\r\n\tconst comp = currentComponent;\r\n\tlet cleanup = hook._cleanup;\r\n\tif (typeof cleanup == 'function') {\r\n\t\thook._cleanup = undefined;\r\n\t\tcleanup();\r\n\t}\r\n\tcurrentComponent = comp;\r\n}\r\n\r\n/**\r\n * Invoke a Hook's effect\r\n * @param {import('./internal').EffectHookState} hook\r\n */\r\nfunction invokeEffect(hook) {\r\n\t// A hook call can introduce a call to render which creates a new root, this will call options.vnode\r\n\t// and move the currentComponent away.\r\n\tconst comp = currentComponent;\r\n\thook._cleanup = hook._value();\r\n\tcurrentComponent = comp;\r\n}\r\n\r\n/**\r\n * @param {any[]} oldArgs\r\n * @param {any[]} newArgs\r\n */\r\nfunction argsChanged(oldArgs, newArgs) {\r\n\treturn (\r\n\t\t!oldArgs ||\r\n\t\toldArgs.length !== newArgs.length ||\r\n\t\tnewArgs.some((arg, index) => arg !== oldArgs[index])\r\n\t);\r\n}\r\n\r\nfunction invokeOrReturn(arg, f) {\r\n\treturn typeof f == 'function' ? f(arg) : f;\r\n}\r\n"],"names":["currentIndex","currentComponent","prevRaf","currentHook","afterPaintEffects","oldBeforeDiff","options","oldBeforeRender","oldAfterDiff","diffed","oldCommit","oldBeforeUnmount","unmount","getHookState","index","type","hooks","length","push","useState","initialState","useReducer","invokeOrReturn","reducer","init","hookState","_reducer","undefined","action","nextValue","setState","useLayoutEffect","callback","args","state","argsChanged","useMemo","factory","flushAfterPaintEffects","component","sort","a","b","pop","forEach","invokeCleanup","invokeEffect","e","vnode","c","requestAnimationFrame","raf","done","clearTimeout","timeout","HAS_RAF","cancelAnimationFrame","setTimeout","commitQueue","some","filter","cb","hasErrored","s","hook","comp","cleanup","oldArgs","newArgs","arg","f","initialValue","current","ref","createHandle","concat","context","provider","sub","props","value","formatter","useDebugValue","errState","componentDidCatch","err"],"mappings":"uNAGA,IAAIA,EAGAC,EAeAC,EAZAC,EAAc,EAGdC,EAAoB,GAEpBC,EAAgBC,cAChBC,EAAkBD,cAClBE,EAAeF,UAAQG,OACvBC,EAAYJ,cACZK,EAAmBL,UAAQM,QA4E/B,SAASC,EAAaC,EAAOC,GACxBT,eACHA,cAAcL,EAAkBa,EAAOX,GAAeY,GAEvDZ,EAAc,MAORa,EACLf,QACCA,MAA2B,IACpB,OACU,YAGfa,GAASE,KAAYC,QACxBD,KAAYE,KAAK,IAEXF,KAAYF,GAMb,SAASK,EAASC,UACxBjB,EAAc,EACPkB,EAAWC,EAAgBF,GAS5B,SAASC,EAAWE,EAASH,EAAcI,OAE3CC,EAAYZ,EAAab,IAAgB,UAC/CyB,EAAUC,EAAWH,EAChBE,QACJA,KAAmB,CACjBD,EAAiDA,EAAKJ,GAA/CE,OAAeK,EAAWP,GAElC,SAAAQ,OACOC,EAAYJ,EAAUC,EAASD,KAAiB,GAAIG,GACtDH,KAAiB,KAAOI,IAC3BJ,KAAmB,CAACI,EAAWJ,KAAiB,IAChDA,MAAqBK,SAAS,OAKjCL,MAAuBxB,GAGjBwB,KAsBD,SAASM,EAAgBC,EAAUC,OAEnCC,EAAQrB,EAAab,IAAgB,IACtCM,eAAwB6B,EAAYD,MAAaD,KACrDC,KAAeF,EACfE,MAAcD,EAEdhC,MAAkCiB,KAAKgB,IA6BlC,SAASE,EAAQC,EAAS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AAUD,GAASA,uBAOhD,SAA0BnB,OAE1B3B,EAAQrB,EAAab,IAAgB,IACrCmF,EAAWhE,WACjBe,KAAe2B,EACV5D,EAAiBmF,oBACrBnF,EAAiBmF,kBAAoB,SAAAC,GAChCnD,MAAcA,KAAamD,GAC/BF,EAAS,GAAGE,KAGP,CACNF,EAAS,GACT,WACCA,EAAS,QAAGxD"}
|
@@ -1,26 +1,26 @@
|
|
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
|
-
}
|
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
|
+
}
|
@@ -1,139 +1,139 @@
|
|
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
|
+
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];
|