isomorfeus-preact 10.7.1 → 10.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lucid_prop_declaration/mixin.rb +3 -3
  3. data/lib/preact/version.rb +1 -1
  4. data/node_modules/.package-lock.json +6 -6
  5. data/node_modules/preact/README.md +39 -38
  6. data/node_modules/preact/compat/client.js +11 -5
  7. data/node_modules/preact/compat/client.mjs +7 -3
  8. data/node_modules/preact/compat/dist/compat.js +1 -1
  9. data/node_modules/preact/compat/dist/compat.js.map +1 -1
  10. data/node_modules/preact/compat/dist/compat.mjs +1 -1
  11. data/node_modules/preact/compat/dist/compat.module.js +1 -1
  12. data/node_modules/preact/compat/dist/compat.module.js.map +1 -1
  13. data/node_modules/preact/compat/dist/compat.umd.js +1 -1
  14. data/node_modules/preact/compat/dist/compat.umd.js.map +1 -1
  15. data/node_modules/preact/compat/package.json +47 -17
  16. data/node_modules/preact/compat/server.browser.js +4 -0
  17. data/node_modules/preact/compat/src/index.d.ts +15 -1
  18. data/node_modules/preact/compat/src/portals.js +3 -1
  19. data/node_modules/preact/compat/src/render.js +9 -0
  20. data/node_modules/preact/debug/package.json +24 -16
  21. data/node_modules/preact/devtools/dist/devtools.js +1 -1
  22. data/node_modules/preact/devtools/dist/devtools.js.map +1 -1
  23. data/node_modules/preact/devtools/dist/devtools.mjs +1 -1
  24. data/node_modules/preact/devtools/dist/devtools.module.js +1 -1
  25. data/node_modules/preact/devtools/dist/devtools.module.js.map +1 -1
  26. data/node_modules/preact/devtools/dist/devtools.umd.js +1 -1
  27. data/node_modules/preact/devtools/dist/devtools.umd.js.map +1 -1
  28. data/node_modules/preact/devtools/package.json +9 -0
  29. data/node_modules/preact/devtools/src/devtools.js +1 -1
  30. data/node_modules/preact/dist/preact.js +1 -1
  31. data/node_modules/preact/dist/preact.js.map +1 -1
  32. data/node_modules/preact/dist/preact.min.js +1 -1
  33. data/node_modules/preact/dist/preact.min.js.map +1 -1
  34. data/node_modules/preact/dist/preact.mjs +1 -1
  35. data/node_modules/preact/dist/preact.module.js +1 -1
  36. data/node_modules/preact/dist/preact.module.js.map +1 -1
  37. data/node_modules/preact/dist/preact.umd.js +1 -1
  38. data/node_modules/preact/dist/preact.umd.js.map +1 -1
  39. data/node_modules/preact/hooks/dist/hooks.js +1 -1
  40. data/node_modules/preact/hooks/dist/hooks.js.map +1 -1
  41. data/node_modules/preact/hooks/dist/hooks.mjs +1 -1
  42. data/node_modules/preact/hooks/dist/hooks.module.js +1 -1
  43. data/node_modules/preact/hooks/dist/hooks.module.js.map +1 -1
  44. data/node_modules/preact/hooks/dist/hooks.umd.js +1 -1
  45. data/node_modules/preact/hooks/dist/hooks.umd.js.map +1 -1
  46. data/node_modules/preact/hooks/package.json +33 -24
  47. data/node_modules/preact/hooks/src/index.js +17 -4
  48. data/node_modules/preact/jsx-runtime/package.json +9 -0
  49. data/node_modules/preact/package.json +9 -1
  50. data/node_modules/preact/src/diff/index.js +20 -6
  51. data/node_modules/preact/src/index.d.ts +3 -0
  52. data/node_modules/preact/src/jsx.d.ts +7 -1
  53. data/node_modules/preact/test-utils/dist/testUtils.js +1 -1
  54. data/node_modules/preact/test-utils/dist/testUtils.js.map +1 -1
  55. data/node_modules/preact/test-utils/dist/testUtils.mjs +1 -1
  56. data/node_modules/preact/test-utils/dist/testUtils.module.js +1 -1
  57. data/node_modules/preact/test-utils/dist/testUtils.module.js.map +1 -1
  58. data/node_modules/preact/test-utils/dist/testUtils.umd.js +1 -1
  59. data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +1 -1
  60. data/node_modules/preact/test-utils/package.json +26 -17
  61. data/node_modules/preact/test-utils/src/index.js +2 -1
  62. data/node_modules/preact-render-to-string/dist/commonjs.js +1 -1
  63. data/node_modules/preact-render-to-string/dist/commonjs.js.map +1 -1
  64. data/node_modules/preact-render-to-string/dist/index.js.map +1 -1
  65. data/node_modules/preact-render-to-string/dist/index.mjs +1 -1
  66. data/node_modules/preact-render-to-string/dist/index.module.js +1 -1
  67. data/node_modules/preact-render-to-string/dist/index.module.js.map +1 -1
  68. data/node_modules/preact-render-to-string/dist/jsx-entry.js +1 -1
  69. data/node_modules/preact-render-to-string/dist/jsx-entry.js.map +1 -1
  70. data/node_modules/preact-render-to-string/dist/jsx.js.map +1 -1
  71. data/node_modules/preact-render-to-string/dist/jsx.mjs +1 -1
  72. data/node_modules/preact-render-to-string/dist/jsx.modern.js +1 -1
  73. data/node_modules/preact-render-to-string/dist/jsx.modern.js.map +1 -1
  74. data/node_modules/preact-render-to-string/dist/jsx.module.js +1 -1
  75. data/node_modules/preact-render-to-string/dist/jsx.module.js.map +1 -1
  76. data/node_modules/preact-render-to-string/package.json +1 -1
  77. data/node_modules/preact-render-to-string/src/index.js +23 -6
  78. data/package.json +2 -2
  79. metadata +9 -8
@@ -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,r,o,i=0,c=[],f=t.options.__b,e=t.options.__r,a=t.options.diffed,v=t.options.__c,l=t.options.unmount;function p(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 d(n){return i=1,m(F,n)}function m(n,t,o){var i=p(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 y(n,o){var i=p(u++,4);!t.options.__s&&A(i.__H,o)&&(i.__=n,i.__H=o,r.__h.push(i))}function s(n,t){var r=p(u++,7);return A(r.__H,t)&&(r.__=n(),r.__H=t,r.__h=n),r.__}function h(){for(var n;n=c.shift();)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){l&&l(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=d,n.useReducer=m,n.useEffect=function(n,o){var i=p(u++,3);!t.options.__s&&A(i.__H,o)&&(i.__=n,i.__H=o,r.__H.__h.push(i))},n.useLayoutEffect=y,n.useRef=function(n){return i=5,s(function(){return{current:n}},[])},n.useImperativeHandle=function(n,t,u){i=6,y(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},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=p(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=p(u++,10),o=d();return t.__=n,r.componentDidCatch||(r.componentDidCatch=function(n){t.__&&t.__(n),o[1](n)}),[o[0],function(){o[1](void 0)}]}});
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,c=0,f=[],e=t.options.__b,a=t.options.__r,v=t.options.diffed,l=t.options.__c,p=t.options.unmount;function d(n,u){t.options.__h&&t.options.__h(r,n,c||u),c=0;var o=r.__H||(r.__H={__:[],__h:[]});return n>=o.__.length&&o.__.push({}),o.__[n]}function m(n){return c=1,y(T,n)}function y(n,t,o){var i=d(u++,2);return i.t=n,i.__c||(i.__=[o?o(t):T(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 s(n,o){var i=d(u++,4);!t.options.__s&&F(i.__H,o)&&(i.__=n,i.__H=o,r.__h.push(i))}function h(n,t){var r=d(u++,7);return F(r.__H,t)&&(r.__=n(),r.__H=t,r.__h=n),r.__}function _(){for(var n;n=f.shift();)if(n.__P)try{n.__H.__h.forEach(x),n.__H.__h.forEach(A),n.__H.__h=[]}catch(u){n.__H.__h=[],t.options.__e(u,n.__v)}}t.options.__b=function(n){r=null,e&&e(n)},t.options.__r=function(n){a&&a(n),u=0;var t=(r=n.__c).__H;t&&(o===r?(t.__h=[],r.__h=[],t.__.forEach(function(n){n.__H&&(n.__H=void 0)})):(t.__h.forEach(x),t.__h.forEach(A),t.__h=[])),o=r},t.options.diffed=function(n){v&&v(n);var u=n.__c;u&&u.__H&&u.__H.__h.length&&(1!==f.push(u)&&i===t.options.requestAnimationFrame||((i=t.options.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),q&&cancelAnimationFrame(t),setTimeout(n)},r=setTimeout(u,100);q&&(t=requestAnimationFrame(u))})(_)),r=null,o=null},t.options.__c=function(n,u){u.some(function(n){try{n.__h.forEach(x),n.__h=n.__h.filter(function(n){return!n.__||A(n)})}catch(r){u.some(function(n){n.__h&&(n.__h=[])}),u=[],t.options.__e(r,n.__v)}}),l&&l(n,u)},t.options.unmount=function(n){p&&p(n);var u,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{x(n)}catch(n){u=n}}),u&&t.options.__e(u,r.__v))};var q="function"==typeof requestAnimationFrame;function x(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function A(n){var t=r;n.__c=n.__(),r=t}function F(n,t){return!n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}function T(n,t){return"function"==typeof t?t(n):t}n.useState=m,n.useReducer=y,n.useEffect=function(n,o){var i=d(u++,3);!t.options.__s&&F(i.__H,o)&&(i.__=n,i.__H=o,r.__H.__h.push(i))},n.useLayoutEffect=s,n.useRef=function(n){return c=5,h(function(){return{current:n}},[])},n.useImperativeHandle=function(n,t,u){c=6,s(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==u?u:u.concat(n))},n.useMemo=h,n.useCallback=function(n,t){return c=8,h(function(){return n},t)},n.useContext=function(n){var t=r.context[n.__c],o=d(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=d(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') {\n\t\t\t\tref(createHandle());\n\t\t\t\treturn () => ref(null);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = createHandle();\n\t\t\t\treturn () => ref.current = null;\n\t\t\t}\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\tlet component;\n\twhile ((component = afterPaintEffects.shift())) {\n\t\tif (!component._parentDom) continue;\n\t\ttry {\n\t\t\tcomponent.__hooks._pendingEffects.forEach(invokeCleanup);\n\t\t\tcomponent.__hooks._pendingEffects.forEach(invokeEffect);\n\t\t\tcomponent.__hooks._pendingEffects = [];\n\t\t} catch (e) {\n\t\t\tcomponent.__hooks._pendingEffects = [];\n\t\t\toptions._catchError(e, component._vnode);\n\t\t}\n\t}\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","component","shift","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":"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"}
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 {import('./internal').Component} */\nlet previousComponent;\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\tif (previousComponent === currentComponent) {\n\t\t\thooks._pendingEffects = [];\n\t\t\tcurrentComponent._renderCallbacks = [];\n\t\t\thooks._list.forEach(hookItem => {\n\t\t\t\tif (hookItem._args) hookItem._args = undefined;\n\t\t\t});\n\t\t} else {\n\t\t\thooks._pendingEffects.forEach(invokeCleanup);\n\t\t\thooks._pendingEffects.forEach(invokeEffect);\n\t\t\thooks._pendingEffects = [];\n\t\t}\n\t}\n\tpreviousComponent = currentComponent;\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\tpreviousComponent = 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') {\n\t\t\t\tref(createHandle());\n\t\t\t\treturn () => ref(null);\n\t\t\t} else if (ref) {\n\t\t\t\tref.current = createHandle();\n\t\t\t\treturn () => (ref.current = null);\n\t\t\t}\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\tlet component;\n\twhile ((component = afterPaintEffects.shift())) {\n\t\tif (!component._parentDom) continue;\n\t\ttry {\n\t\t\tcomponent.__hooks._pendingEffects.forEach(invokeCleanup);\n\t\t\tcomponent.__hooks._pendingEffects.forEach(invokeEffect);\n\t\t\tcomponent.__hooks._pendingEffects = [];\n\t\t} catch (e) {\n\t\t\tcomponent.__hooks._pendingEffects = [];\n\t\t\toptions._catchError(e, component._vnode);\n\t\t}\n\t}\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","previousComponent","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","shift","forEach","invokeCleanup","invokeEffect","e","vnode","hookItem","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":"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"}
@@ -1,26 +1,35 @@
1
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
- }
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
+ }
26
35
  }
@@ -6,6 +6,9 @@ let currentIndex;
6
6
  /** @type {import('./internal').Component} */
7
7
  let currentComponent;
8
8
 
9
+ /** @type {import('./internal').Component} */
10
+ let previousComponent;
11
+
9
12
  /** @type {number} */
10
13
  let currentHook = 0;
11
14
 
@@ -34,10 +37,19 @@ options._render = vnode => {
34
37
 
35
38
  const hooks = currentComponent.__hooks;
36
39
  if (hooks) {
37
- hooks._pendingEffects.forEach(invokeCleanup);
38
- hooks._pendingEffects.forEach(invokeEffect);
39
- hooks._pendingEffects = [];
40
+ if (previousComponent === currentComponent) {
41
+ hooks._pendingEffects = [];
42
+ currentComponent._renderCallbacks = [];
43
+ hooks._list.forEach(hookItem => {
44
+ if (hookItem._args) hookItem._args = undefined;
45
+ });
46
+ } else {
47
+ hooks._pendingEffects.forEach(invokeCleanup);
48
+ hooks._pendingEffects.forEach(invokeEffect);
49
+ hooks._pendingEffects = [];
50
+ }
40
51
  }
52
+ previousComponent = currentComponent;
41
53
  };
42
54
 
43
55
  options.diffed = vnode => {
@@ -48,6 +60,7 @@ options.diffed = vnode => {
48
60
  afterPaint(afterPaintEffects.push(c));
49
61
  }
50
62
  currentComponent = null;
63
+ previousComponent = null;
51
64
  };
52
65
 
53
66
  options._commit = (vnode, commitQueue) => {
@@ -202,7 +215,7 @@ export function useImperativeHandle(ref, createHandle, args) {
202
215
  return () => ref(null);
203
216
  } else if (ref) {
204
217
  ref.current = createHandle();
205
- return () => ref.current = null;
218
+ return () => (ref.current = null);
206
219
  }
207
220
  },
208
221
  args == null ? args : args.concat(ref)
@@ -15,5 +15,14 @@
15
15
  },
16
16
  "mangle": {
17
17
  "regex": "^_"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./src/index.d.ts",
22
+ "browser": "./dist/jsxRuntime.module.js",
23
+ "umd": "./dist/jsxRuntime.umd.js",
24
+ "import": "./dist/jsxRuntime.mjs",
25
+ "require": "./dist/jsxRuntime.js"
26
+ }
18
27
  }
19
28
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "preact",
3
3
  "amdName": "preact",
4
- "version": "10.7.1",
4
+ "version": "10.8.0",
5
5
  "private": false,
6
6
  "description": "Fast 3kb React-compatible Virtual DOM library.",
7
7
  "main": "dist/preact.js",
@@ -11,12 +11,14 @@
11
11
  "source": "src/index.js",
12
12
  "exports": {
13
13
  ".": {
14
+ "types": "./src/index.d.ts",
14
15
  "browser": "./dist/preact.module.js",
15
16
  "umd": "./dist/preact.umd.js",
16
17
  "import": "./dist/preact.mjs",
17
18
  "require": "./dist/preact.js"
18
19
  },
19
20
  "./compat": {
21
+ "types": "./compat/src/index.d.ts",
20
22
  "browser": "./compat/dist/compat.module.js",
21
23
  "umd": "./compat/dist/compat.umd.js",
22
24
  "import": "./compat/dist/compat.mjs",
@@ -29,24 +31,28 @@
29
31
  "require": "./debug/dist/debug.js"
30
32
  },
31
33
  "./devtools": {
34
+ "types": "./devtools/src/index.d.ts",
32
35
  "browser": "./devtools/dist/devtools.module.js",
33
36
  "umd": "./devtools/dist/devtools.umd.js",
34
37
  "import": "./devtools/dist/devtools.mjs",
35
38
  "require": "./devtools/dist/devtools.js"
36
39
  },
37
40
  "./hooks": {
41
+ "types": "./hooks/src/index.d.ts",
38
42
  "browser": "./hooks/dist/hooks.module.js",
39
43
  "umd": "./hooks/dist/hooks.umd.js",
40
44
  "import": "./hooks/dist/hooks.mjs",
41
45
  "require": "./hooks/dist/hooks.js"
42
46
  },
43
47
  "./test-utils": {
48
+ "types": "./test-utils/src/index.d.ts",
44
49
  "browser": "./test-utils/dist/testUtils.module.js",
45
50
  "umd": "./test-utils/dist/testUtils.umd.js",
46
51
  "import": "./test-utils/dist/testUtils.mjs",
47
52
  "require": "./test-utils/dist/testUtils.js"
48
53
  },
49
54
  "./jsx-runtime": {
55
+ "types": "./jsx-runtime/src/index.d.ts",
50
56
  "browser": "./jsx-runtime/dist/jsxRuntime.module.js",
51
57
  "umd": "./jsx-runtime/dist/jsxRuntime.umd.js",
52
58
  "import": "./jsx-runtime/dist/jsxRuntime.mjs",
@@ -63,6 +69,7 @@
63
69
  "require": "./compat/client.js"
64
70
  },
65
71
  "./compat/server": {
72
+ "browser": "./compat/server.browser.js",
66
73
  "import": "./compat/server.mjs",
67
74
  "require": "./compat/server.js"
68
75
  },
@@ -196,6 +203,7 @@
196
203
  "compat/src",
197
204
  "compat/client.js",
198
205
  "compat/client.mjs",
206
+ "compat/server.browser.js",
199
207
  "compat/server.js",
200
208
  "compat/server.mjs",
201
209
  "compat/scheduler.js",
@@ -170,15 +170,29 @@ export function diff(
170
170
 
171
171
  c.context = componentContext;
172
172
  c.props = newProps;
173
- c.state = c._nextState;
174
-
175
- if ((tmp = options._render)) tmp(newVNode);
176
-
177
- c._dirty = false;
178
173
  c._vnode = newVNode;
179
174
  c._parentDom = parentDom;
180
175
 
181
- tmp = c.render(c.props, c.state, c.context);
176
+ let renderHook = options._render,
177
+ count = 0;
178
+ if ('prototype' in newType && newType.prototype.render) {
179
+ c.state = c._nextState;
180
+ c._dirty = false;
181
+
182
+ if (renderHook) renderHook(newVNode);
183
+
184
+ tmp = c.render(c.props, c.state, c.context);
185
+ } else {
186
+ do {
187
+ c._dirty = false;
188
+ if (renderHook) renderHook(newVNode);
189
+
190
+ tmp = c.render(c.props, c.state, c.context);
191
+
192
+ // Handle setState called in render, see #2553
193
+ c.state = c._nextState;
194
+ } while (c._dirty && ++count < 25);
195
+ }
182
196
 
183
197
  // Handle setState called in render, see #2553
184
198
  c.state = c._nextState;
@@ -303,6 +303,9 @@ export interface Provider<T>
303
303
  children: ComponentChildren;
304
304
  }> {}
305
305
  export interface PreactProvider<T> extends Provider<T> {}
306
+ export type ContextType<C extends Context<any>> = C extends Context<infer T>
307
+ ? T
308
+ : never;
306
309
 
307
310
  export interface Context<T> {
308
311
  Consumer: Consumer<T>;
@@ -821,6 +821,11 @@ export namespace JSXInternal {
821
821
  itemRef?: string;
822
822
  }
823
823
 
824
+ export type DetailedHTMLProps<
825
+ HA extends HTMLAttributes<RefType>,
826
+ RefType extends EventTarget = EventTarget
827
+ > = HA;
828
+
824
829
  export interface HTMLMarqueeElement extends HTMLElement {
825
830
  behavior?: 'scroll' | 'slide' | 'alternate';
826
831
  bgColor?: string;
@@ -890,7 +895,7 @@ export namespace JSXInternal {
890
895
  i: HTMLAttributes<HTMLElement>;
891
896
  iframe: HTMLAttributes<HTMLIFrameElement>;
892
897
  img: HTMLAttributes<HTMLImageElement>;
893
- input: HTMLAttributes<HTMLInputElement>;
898
+ input: HTMLAttributes<HTMLInputElement> & { defaultValue?: string };
894
899
  ins: HTMLAttributes<HTMLModElement>;
895
900
  kbd: HTMLAttributes<HTMLElement>;
896
901
  keygen: HTMLAttributes<HTMLUnknownElement>;
@@ -1001,6 +1006,7 @@ export namespace JSXInternal {
1001
1006
  stop: SVGAttributes<SVGStopElement>;
1002
1007
  symbol: SVGAttributes<SVGSymbolElement>;
1003
1008
  text: SVGAttributes<SVGTextElement>;
1009
+ textPath: SVGAttributes<SVGTextPathElement>;
1004
1010
  tspan: SVGAttributes<SVGTSpanElement>;
1005
1011
  use: SVGAttributes<SVGUseElement>;
1006
1012
  }
@@ -1,2 +1,2 @@
1
- var r=require("preact");function n(){return r.options.t=r.options.debounceRendering,r.options.debounceRendering=function(n){return r.options.o=n},function(){return r.options.o&&r.options.o()}}var t=function(r){return null!=r&&"function"==typeof r.then},e=0;function o(){r.options.o&&(r.options.o(),delete r.options.o),void 0!==r.options.t?(r.options.debounceRendering=r.options.t,delete r.options.t):r.options.debounceRendering=void 0}exports.setupRerender=n,exports.act=function(u){if(++e>1){var i=u();return t(i)?i.then(function(){--e}):(--e,Promise.resolve())}var c,f,a=r.options.requestAnimationFrame,v=n();r.options.requestAnimationFrame=function(r){return c=r};var l,p,s=function(){try{for(v();c;)f=c,c=null,f(),v();o()}catch(r){l||(l=r)}r.options.requestAnimationFrame=a,--e};try{p=u()}catch(r){l=r}if(t(p))return p.then(s,function(r){throw s(),r});if(s(),l)throw l;return Promise.resolve()},exports.teardown=o;
1
+ var r=require("preact");function n(){return r.options.t=r.options.debounceRendering,r.options.debounceRendering=function(n){return r.options.o=n},function(){return r.options.o&&r.options.o()}}var t=function(r){return null!=r&&"function"==typeof r.then},e=0;function o(){r.options.o&&(r.options.o(),delete r.options.o),void 0!==r.options.t?(r.options.debounceRendering=r.options.t,delete r.options.t):r.options.debounceRendering=void 0}exports.setupRerender=n,exports.act=function(u){if(++e>1){var i=u();return t(i)?i.then(function(){--e}):(--e,Promise.resolve())}var f,c,a=r.options.requestAnimationFrame,l=n();r.options.requestAnimationFrame=function(r){return f=r};var v,p,s=function(){try{for(l();f;)c=f,f=null,c(),l()}catch(r){v||(v=r)}finally{o()}r.options.requestAnimationFrame=a,--e};try{p=u()}catch(r){v=r}if(t(p))return p.then(s,function(r){throw s(),r});if(s(),v)throw v;return Promise.resolve()},exports.teardown=o;
2
2
  //# sourceMappingURL=testUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testUtils.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t\tteardown();\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","teardown","undefined","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","e"],"mappings":"wBAMA,SAAgBA,WACfC,UAAQC,EAA2BD,UAAQE,kBAC3CF,UAAQE,kBAAoB,SAAAC,UAAOH,UAAQI,EAAqBD,GACzD,kBAAMH,UAAQI,GAAsBJ,UAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAwFf,SAAgBC,IACXT,UAAQI,IAEXJ,UAAQI,WACDJ,UAAQI,QAG+B,IAApCJ,UAAQC,GAClBD,UAAQE,kBAAoBF,UAAQC,SAC7BD,UAAQC,GAEfD,UAAQE,uBAAoBQ,sCAxFvB,SAAaP,QACbK,EAAW,EAAG,KAObG,EAASR,WACXE,EAAWM,GACPA,EAAOJ,KAAK,aAChBC,OAGFA,EACKI,QAAQC,eAOZC,EAAOC,EAJLC,EAAgChB,UAAQiB,sBACxCC,EAAWnB,IAMjBC,UAAQiB,sBAAwB,SAAAE,UAAOL,EAAQK,OAuB3CC,EACAT,EAtBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEDT,IACC,MAAOa,GACHF,IACJA,EAAME,GAIRtB,UAAQiB,sBAAwBD,IAC9BR,OAOFG,EAASR,IACR,MAAOmB,GACRF,EAAME,KAGHjB,EAAWM,UACPA,EAAOJ,KAAKc,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC"}
1
+ {"version":3,"file":"testUtils.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t} finally {\n\t\t\tteardown();\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","teardown","undefined","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","e"],"mappings":"wBAMA,SAAgBA,WACfC,UAAQC,EAA2BD,UAAQE,kBAC3CF,UAAQE,kBAAoB,SAAAC,UAAOH,UAAQI,EAAqBD,GACzD,kBAAMH,UAAQI,GAAsBJ,UAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAyFf,SAAgBC,IACXT,UAAQI,IAEXJ,UAAQI,WACDJ,UAAQI,QAG+B,IAApCJ,UAAQC,GAClBD,UAAQE,kBAAoBF,UAAQC,SAC7BD,UAAQC,GAEfD,UAAQE,uBAAoBQ,sCAzFvB,SAAaP,QACbK,EAAW,EAAG,KAObG,EAASR,WACXE,EAAWM,GACPA,EAAOJ,KAAK,aAChBC,OAGFA,EACKI,QAAQC,eAOZC,EAAOC,EAJLC,EAAgChB,UAAQiB,sBACxCC,EAAWnB,IAMjBC,UAAQiB,sBAAwB,SAAAE,UAAOL,EAAQK,OAwB3CC,EACAT,EAvBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEA,MAAOI,GACHF,IACJA,EAAME,WAGPb,IAGDT,UAAQiB,sBAAwBD,IAC9BR,OAOFG,EAASR,IACR,MAAOmB,GACRF,EAAME,KAGHjB,EAAWM,UACPA,EAAOJ,KAAKc,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC"}
@@ -1,2 +1,2 @@
1
- import{options as n}from"preact";function r(){return n.t=n.debounceRendering,n.debounceRendering=function(r){return n.o=r},function(){return n.o&&n.o()}}var t=function(n){return null!=n&&"function"==typeof n.then},o=0;function u(u){if(++o>1){var i=u();return t(i)?i.then(function(){--o}):(--o,Promise.resolve())}var f,c,a=n.requestAnimationFrame,l=r();n.requestAnimationFrame=function(n){return f=n};var v,d,h=function(){try{for(l();f;)c=f,f=null,c(),l();e()}catch(n){v||(v=n)}n.requestAnimationFrame=a,--o};try{d=u()}catch(n){v=n}if(t(d))return d.then(h,function(n){throw h(),n});if(h(),v)throw v;return Promise.resolve()}function e(){n.o&&(n.o(),delete n.o),void 0!==n.t?(n.debounceRendering=n.t,delete n.t):n.debounceRendering=void 0}export{r as setupRerender,u as act,e as teardown};
1
+ import{options as n}from"preact";function r(){return n.t=n.debounceRendering,n.debounceRendering=function(r){return n.o=r},function(){return n.o&&n.o()}}var t=function(n){return null!=n&&"function"==typeof n.then},o=0;function u(u){if(++o>1){var e=u();return t(e)?e.then(function(){--o}):(--o,Promise.resolve())}var f,c,a=n.requestAnimationFrame,l=r();n.requestAnimationFrame=function(n){return f=n};var v,d,h=function(){try{for(l();f;)c=f,f=null,c(),l()}catch(n){v||(v=n)}finally{i()}n.requestAnimationFrame=a,--o};try{d=u()}catch(n){v=n}if(t(d))return d.then(h,function(n){throw h(),n});if(h(),v)throw v;return Promise.resolve()}function i(){n.o&&(n.o(),delete n.o),void 0!==n.t?(n.debounceRendering=n.t,delete n.t):n.debounceRendering=void 0}export{r as setupRerender,u as act,i as teardown};
2
2
  //# sourceMappingURL=testUtils.module.js.map
@@ -1,2 +1,2 @@
1
- import{options as n}from"preact";function r(){return n.t=n.debounceRendering,n.debounceRendering=function(r){return n.o=r},function(){return n.o&&n.o()}}var t=function(n){return null!=n&&"function"==typeof n.then},o=0;function u(u){if(++o>1){var i=u();return t(i)?i.then(function(){--o}):(--o,Promise.resolve())}var f,c,a=n.requestAnimationFrame,l=r();n.requestAnimationFrame=function(n){return f=n};var v,d,h=function(){try{for(l();f;)c=f,f=null,c(),l();e()}catch(n){v||(v=n)}n.requestAnimationFrame=a,--o};try{d=u()}catch(n){v=n}if(t(d))return d.then(h,function(n){throw h(),n});if(h(),v)throw v;return Promise.resolve()}function e(){n.o&&(n.o(),delete n.o),void 0!==n.t?(n.debounceRendering=n.t,delete n.t):n.debounceRendering=void 0}export{r as setupRerender,u as act,e as teardown};
1
+ import{options as n}from"preact";function r(){return n.t=n.debounceRendering,n.debounceRendering=function(r){return n.o=r},function(){return n.o&&n.o()}}var t=function(n){return null!=n&&"function"==typeof n.then},o=0;function u(u){if(++o>1){var e=u();return t(e)?e.then(function(){--o}):(--o,Promise.resolve())}var f,c,a=n.requestAnimationFrame,l=r();n.requestAnimationFrame=function(n){return f=n};var v,d,h=function(){try{for(l();f;)c=f,f=null,c(),l()}catch(n){v||(v=n)}finally{i()}n.requestAnimationFrame=a,--o};try{d=u()}catch(n){v=n}if(t(d))return d.then(h,function(n){throw h(),n});if(h(),v)throw v;return Promise.resolve()}function i(){n.o&&(n.o(),delete n.o),void 0!==n.t?(n.debounceRendering=n.t,delete n.t):n.debounceRendering=void 0}export{r as setupRerender,u as act,i as teardown};
2
2
  //# sourceMappingURL=testUtils.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testUtils.module.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t\tteardown();\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","act","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","teardown","e","undefined"],"mappings":"iCAMA,SAAgBA,WACfC,EAAQC,EAA2BD,EAAQE,kBAC3CF,EAAQE,kBAAoB,SAAAC,UAAOH,EAAQI,EAAqBD,GACzD,kBAAMH,EAAQI,GAAsBJ,EAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAWR,SAASC,EAAIN,QACbK,EAAW,EAAG,KAObE,EAASP,WACXE,EAAWK,GACPA,EAAOH,KAAK,aAChBC,OAGFA,EACKG,QAAQC,eAOZC,EAAOC,EAJLC,EAAgCf,EAAQgB,sBACxCC,EAAWlB,IAMjBC,EAAQgB,sBAAwB,SAAAE,UAAOL,EAAQK,OAuB3CC,EACAT,EAtBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEDI,IACC,MAAOC,GACHH,IACJA,EAAMG,GAIRtB,EAAQgB,sBAAwBD,IAC9BP,OAOFE,EAASP,IACR,MAAOmB,GACRH,EAAMG,KAGHjB,EAAWK,UACPA,EAAOH,KAAKa,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC,UAMhB,SAAgBS,IACXrB,EAAQI,IAEXJ,EAAQI,WACDJ,EAAQI,QAG+B,IAApCJ,EAAQC,GAClBD,EAAQE,kBAAoBF,EAAQC,SAC7BD,EAAQC,GAEfD,EAAQE,uBAAoBqB"}
1
+ {"version":3,"file":"testUtils.module.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t} finally {\n\t\t\tteardown();\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","act","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","e","teardown","undefined"],"mappings":"iCAMA,SAAgBA,WACfC,EAAQC,EAA2BD,EAAQE,kBAC3CF,EAAQE,kBAAoB,SAAAC,UAAOH,EAAQI,EAAqBD,GACzD,kBAAMH,EAAQI,GAAsBJ,EAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAWR,SAASC,EAAIN,QACbK,EAAW,EAAG,KAObE,EAASP,WACXE,EAAWK,GACPA,EAAOH,KAAK,aAChBC,OAGFA,EACKG,QAAQC,eAOZC,EAAOC,EAJLC,EAAgCf,EAAQgB,sBACxCC,EAAWlB,IAMjBC,EAAQgB,sBAAwB,SAAAE,UAAOL,EAAQK,OAwB3CC,EACAT,EAvBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEA,MAAOI,GACHF,IACJA,EAAME,WAGPC,IAGDtB,EAAQgB,sBAAwBD,IAC9BP,OAOFE,EAASP,IACR,MAAOkB,GACRF,EAAME,KAGHhB,EAAWK,UACPA,EAAOH,KAAKa,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC,UAMhB,SAAgBU,IACXtB,EAAQI,IAEXJ,EAAQI,WACDJ,EAAQI,QAG+B,IAApCJ,EAAQC,GAClBD,EAAQE,kBAAoBF,EAAQC,SAC7BD,EAAQC,GAEfD,EAAQE,uBAAoBqB"}
@@ -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.preactTestUtils={},n.preact)}(this,function(n,t){function e(){return t.options.t=t.options.debounceRendering,t.options.debounceRendering=function(n){return t.options.o=n},function(){return t.options.o&&t.options.o()}}var r=function(n){return null!=n&&"function"==typeof n.then},o=0;function i(){t.options.o&&(t.options.o(),delete t.options.o),void 0!==t.options.t?(t.options.debounceRendering=t.options.t,delete t.options.t):t.options.debounceRendering=void 0}n.setupRerender=e,n.act=function(n){if(++o>1){var u=n();return r(u)?u.then(function(){--o}):(--o,Promise.resolve())}var f,c,d=t.options.requestAnimationFrame,p=e();t.options.requestAnimationFrame=function(n){return f=n};var a,l,s=function(){try{for(p();f;)c=f,f=null,c(),p();i()}catch(n){a||(a=n)}t.options.requestAnimationFrame=d,--o};try{l=n()}catch(n){a=n}if(r(l))return l.then(s,function(n){throw s(),n});if(s(),a)throw a;return Promise.resolve()},n.teardown=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.preactTestUtils={},n.preact)}(this,function(n,t){function e(){return t.options.t=t.options.debounceRendering,t.options.debounceRendering=function(n){return t.options.o=n},function(){return t.options.o&&t.options.o()}}var r=function(n){return null!=n&&"function"==typeof n.then},o=0;function i(){t.options.o&&(t.options.o(),delete t.options.o),void 0!==t.options.t?(t.options.debounceRendering=t.options.t,delete t.options.t):t.options.debounceRendering=void 0}n.setupRerender=e,n.act=function(n){if(++o>1){var f=n();return r(f)?f.then(function(){--o}):(--o,Promise.resolve())}var u,c,d=t.options.requestAnimationFrame,a=e();t.options.requestAnimationFrame=function(n){return u=n};var l,p,y=function(){try{for(a();u;)c=u,u=null,c(),a()}catch(n){l||(l=n)}finally{i()}t.options.requestAnimationFrame=d,--o};try{p=n()}catch(n){l=n}if(r(p))return p.then(y,function(n){throw y(),n});if(y(),l)throw l;return Promise.resolve()},n.teardown=i});
2
2
  //# sourceMappingURL=testUtils.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testUtils.umd.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t\tteardown();\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","teardown","undefined","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","e"],"mappings":"2NAMO,SAASA,WACfC,UAAQC,EAA2BD,UAAQE,kBAC3CF,UAAQE,kBAAoB,SAAAC,UAAOH,UAAQI,EAAqBD,GACzD,kBAAMH,UAAQI,GAAsBJ,UAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAwFR,SAASC,IACXT,UAAQI,IAEXJ,UAAQI,WACDJ,UAAQI,QAG+B,IAApCJ,UAAQC,GAClBD,UAAQE,kBAAoBF,UAAQC,SAC7BD,UAAQC,GAEfD,UAAQE,uBAAoBQ,0BAxFvB,SAAaP,QACbK,EAAW,EAAG,KAObG,EAASR,WACXE,EAAWM,GACPA,EAAOJ,KAAK,aAChBC,OAGFA,EACKI,QAAQC,eAOZC,EAAOC,EAJLC,EAAgChB,UAAQiB,sBACxCC,EAAWnB,IAMjBC,UAAQiB,sBAAwB,SAAAE,UAAOL,EAAQK,OAuB3CC,EACAT,EAtBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEDT,IACC,MAAOa,GACHF,IACJA,EAAME,GAIRtB,UAAQiB,sBAAwBD,IAC9BR,OAOFG,EAASR,IACR,MAAOmB,GACRF,EAAME,KAGHjB,EAAWM,UACPA,EAAOJ,KAAKc,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC"}
1
+ {"version":3,"file":"testUtils.umd.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\n\n/**\n * Setup a rerender function that will drain the queue of pending renders\n * @returns {() => void}\n */\nexport function setupRerender() {\n\toptions.__test__previousDebounce = options.debounceRendering;\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\n}\n\nconst isThenable = value => value != null && typeof value.then == 'function';\n\n/** Depth of nested calls to `act`. */\nlet actDepth = 0;\n\n/**\n * Run a test function, and flush all effects and rerenders after invoking it.\n *\n * Returns a Promise which resolves \"immediately\" if the callback is\n * synchronous or when the callback's result resolves if it is asynchronous.\n *\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\n * @return {Promise<void>}\n */\nexport function act(cb) {\n\tif (++actDepth > 1) {\n\t\t// If calls to `act` are nested, a flush happens only when the\n\t\t// outermost call returns. In the inner call, we just execute the\n\t\t// callback and return since the infrastructure for flushing has already\n\t\t// been set up.\n\t\t//\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\n\t\tconst result = cb();\n\t\tif (isThenable(result)) {\n\t\t\treturn result.then(() => {\n\t\t\t\t--actDepth;\n\t\t\t});\n\t\t}\n\t\t--actDepth;\n\t\treturn Promise.resolve();\n\t}\n\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\n\tconst rerender = setupRerender();\n\n\t/** @type {() => void} */\n\tlet flush, toFlush;\n\n\t// Override requestAnimationFrame so we can flush pending hooks.\n\toptions.requestAnimationFrame = fc => (flush = fc);\n\n\tconst finish = () => {\n\t\ttry {\n\t\t\trerender();\n\t\t\twhile (flush) {\n\t\t\t\ttoFlush = flush;\n\t\t\t\tflush = null;\n\n\t\t\t\ttoFlush();\n\t\t\t\trerender();\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tif (!err) {\n\t\t\t\terr = e;\n\t\t\t}\n\t\t} finally {\n\t\t\tteardown();\n\t\t}\n\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\n\t\t--actDepth;\n\t};\n\n\tlet err;\n\tlet result;\n\n\ttry {\n\t\tresult = cb();\n\t} catch (e) {\n\t\terr = e;\n\t}\n\n\tif (isThenable(result)) {\n\t\treturn result.then(finish, err => {\n\t\t\tfinish();\n\t\t\tthrow err;\n\t\t});\n\t}\n\n\t// nb. If the callback is synchronous, effects must be flushed before\n\t// `act` returns, so that the caller does not have to await the result,\n\t// even though React recommends this.\n\tfinish();\n\tif (err) {\n\t\tthrow err;\n\t}\n\treturn Promise.resolve();\n}\n\n/**\n * Teardown test environment and reset preact's internal state\n */\nexport function teardown() {\n\tif (options.__test__drainQueue) {\n\t\t// Flush any pending updates leftover by test\n\t\toptions.__test__drainQueue();\n\t\tdelete options.__test__drainQueue;\n\t}\n\n\tif (typeof options.__test__previousDebounce != 'undefined') {\n\t\toptions.debounceRendering = options.__test__previousDebounce;\n\t\tdelete options.__test__previousDebounce;\n\t} else {\n\t\toptions.debounceRendering = undefined;\n\t}\n}\n"],"names":["setupRerender","options","__test__previousDebounce","debounceRendering","cb","__test__drainQueue","isThenable","value","then","actDepth","teardown","undefined","result","Promise","resolve","flush","toFlush","previousRequestAnimationFrame","requestAnimationFrame","rerender","fc","err","finish","e"],"mappings":"2NAMO,SAASA,WACfC,UAAQC,EAA2BD,UAAQE,kBAC3CF,UAAQE,kBAAoB,SAAAC,UAAOH,UAAQI,EAAqBD,GACzD,kBAAMH,UAAQI,GAAsBJ,UAAQI,KAGpD,IAAMC,EAAa,SAAAC,UAAkB,MAATA,GAAsC,mBAAdA,EAAMC,MAGtDC,EAAW,EAyFR,SAASC,IACXT,UAAQI,IAEXJ,UAAQI,WACDJ,UAAQI,QAG+B,IAApCJ,UAAQC,GAClBD,UAAQE,kBAAoBF,UAAQC,SAC7BD,UAAQC,GAEfD,UAAQE,uBAAoBQ,0BAzFvB,SAAaP,QACbK,EAAW,EAAG,KAObG,EAASR,WACXE,EAAWM,GACPA,EAAOJ,KAAK,aAChBC,OAGFA,EACKI,QAAQC,eAOZC,EAAOC,EAJLC,EAAgChB,UAAQiB,sBACxCC,EAAWnB,IAMjBC,UAAQiB,sBAAwB,SAAAE,UAAOL,EAAQK,OAwB3CC,EACAT,EAvBEU,EAAS,mBAEbH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,IAEA,MAAOI,GACHF,IACJA,EAAME,WAGPb,IAGDT,UAAQiB,sBAAwBD,IAC9BR,OAOFG,EAASR,IACR,MAAOmB,GACRF,EAAME,KAGHjB,EAAWM,UACPA,EAAOJ,KAAKc,EAAQ,SAAAD,SAC1BC,IACMD,OAORC,IACID,QACGA,SAEAR,QAAQC"}
@@ -1,19 +1,28 @@
1
1
  {
2
- "name": "test-utils",
3
- "amdName": "preactTestUtils",
4
- "version": "0.1.0",
5
- "private": true,
6
- "description": "Test-utils for Preact",
7
- "main": "dist/testUtils.js",
8
- "module": "dist/testUtils.module.js",
9
- "umd:main": "dist/testUtils.umd.js",
10
- "source": "src/index.js",
11
- "license": "MIT",
12
- "types": "src/index.d.ts",
13
- "peerDependencies": {
14
- "preact": "^10.0.0"
15
- },
16
- "mangle": {
17
- "regex": "^_"
18
- }
2
+ "name": "test-utils",
3
+ "amdName": "preactTestUtils",
4
+ "version": "0.1.0",
5
+ "private": true,
6
+ "description": "Test-utils for Preact",
7
+ "main": "dist/testUtils.js",
8
+ "module": "dist/testUtils.module.js",
9
+ "umd:main": "dist/testUtils.umd.js",
10
+ "source": "src/index.js",
11
+ "license": "MIT",
12
+ "types": "src/index.d.ts",
13
+ "peerDependencies": {
14
+ "preact": "^10.0.0"
15
+ },
16
+ "mangle": {
17
+ "regex": "^_"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./src/index.d.ts",
22
+ "browser": "./dist/testUtils.module.js",
23
+ "umd": "./dist/testUtils.umd.js",
24
+ "import": "./dist/testUtils.mjs",
25
+ "require": "./dist/testUtils.js"
26
+ }
27
+ }
19
28
  }
@@ -61,11 +61,12 @@ export function act(cb) {
61
61
  toFlush();
62
62
  rerender();
63
63
  }
64
- teardown();
65
64
  } catch (e) {
66
65
  if (!err) {
67
66
  err = e;
68
67
  }
68
+ } finally {
69
+ teardown();
69
70
  }
70
71
 
71
72
  options.requestAnimationFrame = previousRequestAnimationFrame;
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t((e||self).preactRenderToString={},e.preact)}(this,function(e,t){var n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,r=/[&<>"]/;function o(e){var t=String(e);return r.test(t)?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):t}var i=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},a=function(e,t,n){return String(e).length>(t||40)||!n&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},l={};function s(e){var t="";for(var r in e){var o=e[r];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==r[0]?r:l[r]||(l[r]=r.replace(/([A-Z])/g,"-$1").toLowerCase()),t+=": ",t+=o,"number"==typeof o&&!1===n.test(r)&&(t+="px"),t+=";")}return t||void 0}function f(e,t){for(var n in t)e[n]=t[n];return e}function p(e,t){return Array.isArray(t)?t.reduce(p,e):null!=t&&!1!==t&&e.push(t),e}var u={shallow:!0},c=[],_=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,d=/[\s\n\\/='"\0<>]/,v=function(){};y.render=y;var g=function(e,t){return y(e,t,u)},h=[];function y(e,n,r){n=n||{},r=r||{};var o=t.options.__s;t.options.__s=!0;var i=m(e,n,r);return t.options.__c&&t.options.__c(e,h),h.length=0,t.options.__s=o,i}function m(e,n,r,l,u,g){if(null==e||"boolean"==typeof e)return"";if("object"!=typeof e)return o(e);var h=r.pretty,y=h&&"string"==typeof h?h:"\t";if(Array.isArray(e)){for(var x="",b=0;b<e.length;b++)h&&b>0&&(x+="\n"),x+=m(e[b],n,r,l,u,g);return x}var S,w=e.type,k=e.props,O=!1;if("function"==typeof w){if(O=!0,!r.shallow||!l&&!1!==r.renderRootComponent){if(w===t.Fragment){var T=[];return p(T,e.props.children),m(T,n,r,!1!==r.shallowHighOrder,u,g)}var C,A=e.__c={__v:e,context:n,props:e.props,setState:v,forceUpdate:v,__h:[]};if(t.options.__b&&t.options.__b(e),t.options.__r&&t.options.__r(e),w.prototype&&"function"==typeof w.prototype.render){var j=w.contextType,F=j&&n[j.__c],H=null!=j?F?F.props.value:j.__:n;(A=e.__c=new w(k,H)).__v=e,A._dirty=A.__d=!0,A.props=k,null==A.state&&(A.state={}),null==A._nextState&&null==A.__s&&(A._nextState=A.__s=A.state),A.context=H,w.getDerivedStateFromProps?A.state=f(f({},A.state),w.getDerivedStateFromProps(A.props,A.state)):A.componentWillMount&&(A.componentWillMount(),A.state=A._nextState!==A.state?A._nextState:A.__s!==A.state?A.__s:A.state),C=A.render(A.props,A.state,A.context)}else{var M=w.contextType,$=M&&n[M.__c];C=w.call(e.__c,k,null!=M?$?$.props.value:M.__:n)}return A.getChildContext&&(n=f(f({},n),A.getChildContext())),t.options.diffed&&t.options.diffed(e),m(C,n,r,!1!==r.shallowHighOrder,u,g)}w=(S=w).displayName||S!==Function&&S.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var n=-1,r=c.length;r--;)if(c[r]===e){n=r;break}n<0&&(n=c.push(e)-1),t="UnnamedComponent"+n}return t}(S)}var L,R,E="<"+w;if(k){var q=Object.keys(k);r&&!0===r.sortAttributes&&q.sort();for(var D=0;D<q.length;D++){var N=q[D],P=k[N];if("children"!==N){if(!d.test(N)&&(r&&r.allAttributes||"key"!==N&&"ref"!==N&&"__self"!==N&&"__source"!==N)){if("defaultValue"===N)N="value";else if("className"===N){if(void 0!==k.class)continue;N="class"}else u&&N.match(/^xlink:?./)&&(N=N.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===N){if(k.for)continue;N="for"}"style"===N&&P&&"object"==typeof P&&(P=s(P)),"a"===N[0]&&"r"===N[1]&&"boolean"==typeof P&&(P=String(P));var U=r.attributeHook&&r.attributeHook(N,P,n,r,O);if(U||""===U)E+=U;else if("dangerouslySetInnerHTML"===N)R=P&&P.__html;else if("textarea"===w&&"value"===N)L=P;else if((P||0===P||""===P)&&"function"!=typeof P){if(!(!0!==P&&""!==P||(P=N,r&&r.xml))){E+=" "+N;continue}if("value"===N){if("select"===w){g=P;continue}"option"===w&&g==P&&void 0===k.selected&&(E+=" selected")}E+=" "+N+'="'+o(P)+'"'}}}else L=P}}if(h){var W=E.replace(/\n\s*/," ");W===E||~W.indexOf("\n")?h&&~E.indexOf("\n")&&(E+="\n"):E=W}if(E+=">",d.test(w))throw new Error(w+" is not a valid HTML tag name in "+E);var z,I=_.test(w)||r.voidElements&&r.voidElements.test(w),V=[];if(R)h&&a(R)&&(R="\n"+y+i(R,y)),E+=R;else if(null!=L&&p(z=[],L).length){for(var Z=h&&~E.indexOf("\n"),B=!1,G=0;G<z.length;G++){var J=z[G];if(null!=J&&!1!==J){var K=m(J,n,r,!0,"svg"===w||"foreignObject"!==w&&u,g);if(h&&!Z&&a(K)&&(Z=!0),K)if(h){var Q=K.length>0&&"<"!=K[0];B&&Q?V[V.length-1]+=K:V.push(K),B=Q}else V.push(K)}}if(h&&Z)for(var X=V.length;X--;)V[X]="\n"+y+i(V[X],y)}if(V.length||R)E+=V.join("");else if(r&&r.xml)return E.substring(0,E.length-1)+" />";return!I||z||R?(h&&~E.indexOf("\n")&&(E+="\n"),E+="</"+w+">"):E=E.replace(/>$/," />"),E}y.shallowRender=g,e.default=y,e.render=y,e.renderToStaticMarkup=y,e.renderToString=y,e.shallowRender=g});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t((e||self).preactRenderToString={},e.preact)}(this,function(e,t){var n=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i,r=/[&<>"]/;function o(e){var t=String(e);return r.test(t)?t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):t}var i=function(e,t){return String(e).replace(/(\n+)/g,"$1"+(t||"\t"))},a=function(e,t,n){return String(e).length>(t||40)||!n&&-1!==String(e).indexOf("\n")||-1!==String(e).indexOf("<")},l={};function s(e){var t="";for(var r in e){var o=e[r];null!=o&&""!==o&&(t&&(t+=" "),t+="-"==r[0]?r:l[r]||(l[r]=r.replace(/([A-Z])/g,"-$1").toLowerCase()),t+=": ",t+=o,"number"==typeof o&&!1===n.test(r)&&(t+="px"),t+=";")}return t||void 0}function f(e,t){for(var n in t)e[n]=t[n];return e}function p(e,t){return Array.isArray(t)?t.reduce(p,e):null!=t&&!1!==t&&e.push(t),e}var u={shallow:!0},c=[],_=/^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/,d=/[\s\n\\/='"\0<>]/;function v(){this.__d=!0}y.render=y;var g=function(e,t){return y(e,t,u)},h=[];function y(e,n,r){n=n||{},r=r||{};var o=t.options.__s;t.options.__s=!0;var i=m(e,n,r);return t.options.__c&&t.options.__c(e,h),h.length=0,t.options.__s=o,i}function m(e,n,r,l,u,g){if(null==e||"boolean"==typeof e)return"";if("object"!=typeof e)return o(e);var h=r.pretty,y=h&&"string"==typeof h?h:"\t";if(Array.isArray(e)){for(var x="",b=0;b<e.length;b++)h&&b>0&&(x+="\n"),x+=m(e[b],n,r,l,u,g);return x}var S,w=e.type,k=e.props,O=!1;if("function"==typeof w){if(O=!0,!r.shallow||!l&&!1!==r.renderRootComponent){if(w===t.Fragment){var T=[];return p(T,e.props.children),m(T,n,r,!1!==r.shallowHighOrder,u,g)}var C,A=e.__c={__v:e,context:n,props:e.props,setState:v,forceUpdate:v,__d:!0,__h:[]};t.options.__b&&t.options.__b(e);var j=t.options.__r;if(w.prototype&&"function"==typeof w.prototype.render){var F=w.contextType,H=F&&n[F.__c],M=null!=F?H?H.props.value:F.__:n;(A=e.__c=new w(k,M)).__v=e,A._dirty=A.__d=!0,A.props=k,null==A.state&&(A.state={}),null==A._nextState&&null==A.__s&&(A._nextState=A.__s=A.state),A.context=M,w.getDerivedStateFromProps?A.state=f(f({},A.state),w.getDerivedStateFromProps(A.props,A.state)):A.componentWillMount&&(A.componentWillMount(),A.state=A._nextState!==A.state?A._nextState:A.__s!==A.state?A.__s:A.state),j&&j(e),C=A.render(A.props,A.state,A.context)}else for(var $=w.contextType,L=$&&n[$.__c],R=null!=$?L?L.props.value:$.__:n,E=0;A.__d&&E++<25;)A.__d=!1,j&&j(e),C=w.call(e.__c,k,R);return A.getChildContext&&(n=f(f({},n),A.getChildContext())),t.options.diffed&&t.options.diffed(e),m(C,n,r,!1!==r.shallowHighOrder,u,g)}w=(S=w).displayName||S!==Function&&S.name||function(e){var t=(Function.prototype.toString.call(e).match(/^\s*function\s+([^( ]+)/)||"")[1];if(!t){for(var n=-1,r=c.length;r--;)if(c[r]===e){n=r;break}n<0&&(n=c.push(e)-1),t="UnnamedComponent"+n}return t}(S)}var q,D,N="<"+w;if(k){var P=Object.keys(k);r&&!0===r.sortAttributes&&P.sort();for(var U=0;U<P.length;U++){var W=P[U],z=k[W];if("children"!==W){if(!d.test(W)&&(r&&r.allAttributes||"key"!==W&&"ref"!==W&&"__self"!==W&&"__source"!==W)){if("defaultValue"===W)W="value";else if("className"===W){if(void 0!==k.class)continue;W="class"}else u&&W.match(/^xlink:?./)&&(W=W.toLowerCase().replace(/^xlink:?/,"xlink:"));if("htmlFor"===W){if(k.for)continue;W="for"}"style"===W&&z&&"object"==typeof z&&(z=s(z)),"a"===W[0]&&"r"===W[1]&&"boolean"==typeof z&&(z=String(z));var I=r.attributeHook&&r.attributeHook(W,z,n,r,O);if(I||""===I)N+=I;else if("dangerouslySetInnerHTML"===W)D=z&&z.__html;else if("textarea"===w&&"value"===W)q=z;else if((z||0===z||""===z)&&"function"!=typeof z){if(!(!0!==z&&""!==z||(z=W,r&&r.xml))){N+=" "+W;continue}if("value"===W){if("select"===w){g=z;continue}"option"===w&&g==z&&void 0===k.selected&&(N+=" selected")}N+=" "+W+'="'+o(z)+'"'}}}else q=z}}if(h){var V=N.replace(/\n\s*/," ");V===N||~V.indexOf("\n")?h&&~N.indexOf("\n")&&(N+="\n"):N=V}if(N+=">",d.test(w))throw new Error(w+" is not a valid HTML tag name in "+N);var Z,B=_.test(w)||r.voidElements&&r.voidElements.test(w),G=[];if(D)h&&a(D)&&(D="\n"+y+i(D,y)),N+=D;else if(null!=q&&p(Z=[],q).length){for(var J=h&&~N.indexOf("\n"),K=!1,Q=0;Q<Z.length;Q++){var X=Z[Q];if(null!=X&&!1!==X){var Y=m(X,n,r,!0,"svg"===w||"foreignObject"!==w&&u,g);if(h&&!J&&a(Y)&&(J=!0),Y)if(h){var ee=Y.length>0&&"<"!=Y[0];K&&ee?G[G.length-1]+=Y:G.push(Y),K=ee}else G.push(Y)}}if(h&&J)for(var te=G.length;te--;)G[te]="\n"+y+i(G[te],y)}if(G.length||D)N+=G.join("");else if(r&&r.xml)return N.substring(0,N.length-1)+" />";return!B||Z||D?(h&&~N.indexOf("\n")&&(N+="\n"),N+="</"+w+">"):N=N.replace(/>$/," />"),N}y.shallowRender=g,e.default=y,e.render=y,e.renderToStaticMarkup=y,e.renderToString=y,e.shallowRender=g});
2
2
  //# sourceMappingURL=index.js.map