isomorfeus-preact 10.6.14 → 10.6.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isomorfeus-preact.rb +4 -4
  3. data/lib/isomorfeus_preact/lucid_component/api.rb +1 -1
  4. data/lib/isomorfeus_preact/lucid_component/initializer.rb +2 -4
  5. data/lib/isomorfeus_preact/lucid_func/initializer.rb +1 -1
  6. data/lib/isomorfeus_preact/preact/function_component/initializer.rb +1 -1
  7. data/lib/preact/component/api.rb +2 -2
  8. data/lib/preact/component/callbacks.rb +6 -6
  9. data/lib/preact/component/initializer.rb +2 -2
  10. data/lib/preact/component/native_component_constructor.rb +1 -1
  11. data/lib/preact/component/resolution.rb +2 -2
  12. data/lib/preact/params.rb +16 -0
  13. data/lib/preact/props.rb +69 -0
  14. data/lib/preact/state.rb +87 -0
  15. data/lib/preact/version.rb +1 -1
  16. data/lib/preact.rb +4 -2
  17. data/node_modules/.package-lock.json +3 -3
  18. data/node_modules/preact/LICENSE +21 -21
  19. data/node_modules/preact/README.md +187 -187
  20. data/node_modules/preact/compat/dist/compat.js +1 -1
  21. data/node_modules/preact/compat/dist/compat.js.map +1 -1
  22. data/node_modules/preact/compat/dist/compat.mjs +1 -1
  23. data/node_modules/preact/compat/dist/compat.module.js +1 -1
  24. data/node_modules/preact/compat/dist/compat.module.js.map +1 -1
  25. data/node_modules/preact/compat/dist/compat.umd.js +1 -1
  26. data/node_modules/preact/compat/dist/compat.umd.js.map +1 -1
  27. data/node_modules/preact/compat/jsx-dev-runtime.js +1 -1
  28. data/node_modules/preact/compat/jsx-dev-runtime.mjs +1 -1
  29. data/node_modules/preact/compat/jsx-runtime.js +1 -1
  30. data/node_modules/preact/compat/jsx-runtime.mjs +1 -1
  31. data/node_modules/preact/compat/package.json +19 -19
  32. data/node_modules/preact/compat/scheduler.js +15 -15
  33. data/node_modules/preact/compat/scheduler.mjs +23 -23
  34. data/node_modules/preact/compat/server.js +15 -15
  35. data/node_modules/preact/compat/server.mjs +4 -4
  36. data/node_modules/preact/compat/src/Children.js +21 -21
  37. data/node_modules/preact/compat/src/PureComponent.js +15 -15
  38. data/node_modules/preact/compat/src/forwardRef.js +51 -51
  39. data/node_modules/preact/compat/src/index.d.ts +141 -141
  40. data/node_modules/preact/compat/src/index.js +187 -187
  41. data/node_modules/preact/compat/src/internal.d.ts +47 -47
  42. data/node_modules/preact/compat/src/memo.js +34 -34
  43. data/node_modules/preact/compat/src/portals.js +80 -80
  44. data/node_modules/preact/compat/src/render.js +229 -230
  45. data/node_modules/preact/compat/src/suspense-list.d.ts +14 -14
  46. data/node_modules/preact/compat/src/suspense-list.js +126 -126
  47. data/node_modules/preact/compat/src/suspense.d.ts +15 -15
  48. data/node_modules/preact/compat/src/suspense.js +270 -270
  49. data/node_modules/preact/compat/src/util.js +28 -28
  50. data/node_modules/preact/compat/test-utils.js +1 -1
  51. data/node_modules/preact/debug/dist/debug.js.map +1 -1
  52. data/node_modules/preact/debug/dist/debug.module.js.map +1 -1
  53. data/node_modules/preact/debug/dist/debug.umd.js.map +1 -1
  54. data/node_modules/preact/debug/package.json +18 -18
  55. data/node_modules/preact/debug/src/check-props.js +54 -54
  56. data/node_modules/preact/debug/src/component-stack.js +146 -146
  57. data/node_modules/preact/debug/src/constants.js +3 -3
  58. data/node_modules/preact/debug/src/debug.js +442 -442
  59. data/node_modules/preact/debug/src/index.js +6 -6
  60. data/node_modules/preact/debug/src/internal.d.ts +82 -82
  61. data/node_modules/preact/debug/src/util.js +11 -11
  62. data/node_modules/preact/devtools/dist/devtools.js +1 -1
  63. data/node_modules/preact/devtools/dist/devtools.js.map +1 -1
  64. data/node_modules/preact/devtools/dist/devtools.mjs +1 -1
  65. data/node_modules/preact/devtools/dist/devtools.module.js +1 -1
  66. data/node_modules/preact/devtools/dist/devtools.module.js.map +1 -1
  67. data/node_modules/preact/devtools/dist/devtools.umd.js +1 -1
  68. data/node_modules/preact/devtools/dist/devtools.umd.js.map +1 -1
  69. data/node_modules/preact/devtools/package.json +16 -16
  70. data/node_modules/preact/devtools/src/devtools.js +10 -10
  71. data/node_modules/preact/devtools/src/index.d.ts +8 -8
  72. data/node_modules/preact/devtools/src/index.js +15 -15
  73. data/node_modules/preact/dist/preact.js.map +1 -1
  74. data/node_modules/preact/dist/preact.min.js.map +1 -1
  75. data/node_modules/preact/dist/preact.module.js.map +1 -1
  76. data/node_modules/preact/dist/preact.umd.js.map +1 -1
  77. data/node_modules/preact/hooks/dist/hooks.js +1 -1
  78. data/node_modules/preact/hooks/dist/hooks.js.map +1 -1
  79. data/node_modules/preact/hooks/dist/hooks.mjs +1 -1
  80. data/node_modules/preact/hooks/dist/hooks.module.js +1 -1
  81. data/node_modules/preact/hooks/dist/hooks.module.js.map +1 -1
  82. data/node_modules/preact/hooks/dist/hooks.umd.js +1 -1
  83. data/node_modules/preact/hooks/dist/hooks.umd.js.map +1 -1
  84. data/node_modules/preact/hooks/package.json +26 -26
  85. data/node_modules/preact/hooks/src/index.d.ts +139 -139
  86. data/node_modules/preact/hooks/src/index.js +386 -388
  87. data/node_modules/preact/hooks/src/internal.d.ts +75 -75
  88. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.js.map +1 -1
  89. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js.map +1 -1
  90. data/node_modules/preact/jsx-runtime/dist/jsxRuntime.umd.js.map +1 -1
  91. data/node_modules/preact/jsx-runtime/package.json +19 -19
  92. data/node_modules/preact/jsx-runtime/src/index.d.ts +50 -50
  93. data/node_modules/preact/jsx-runtime/src/index.js +77 -77
  94. data/node_modules/preact/package.json +291 -287
  95. data/node_modules/preact/src/cjs.js +3 -3
  96. data/node_modules/preact/src/clone-element.js +34 -34
  97. data/node_modules/preact/src/component.js +225 -225
  98. data/node_modules/preact/src/constants.js +3 -3
  99. data/node_modules/preact/src/create-context.js +68 -68
  100. data/node_modules/preact/src/create-element.js +98 -98
  101. data/node_modules/preact/src/diff/catch-error.js +38 -38
  102. data/node_modules/preact/src/diff/children.js +335 -335
  103. data/node_modules/preact/src/diff/index.js +516 -516
  104. data/node_modules/preact/src/diff/props.js +158 -158
  105. data/node_modules/preact/src/index.d.ts +310 -310
  106. data/node_modules/preact/src/index.js +13 -13
  107. data/node_modules/preact/src/internal.d.ts +146 -146
  108. data/node_modules/preact/src/jsx.d.ts +1005 -1005
  109. data/node_modules/preact/src/options.js +16 -16
  110. data/node_modules/preact/src/render.js +75 -75
  111. data/node_modules/preact/src/util.js +27 -27
  112. data/node_modules/preact/test-utils/dist/testUtils.js.map +1 -1
  113. data/node_modules/preact/test-utils/dist/testUtils.module.js.map +1 -1
  114. data/node_modules/preact/test-utils/dist/testUtils.umd.js.map +1 -1
  115. data/node_modules/preact/test-utils/package.json +19 -19
  116. data/node_modules/preact/test-utils/src/index.d.ts +3 -3
  117. data/node_modules/preact/test-utils/src/index.js +117 -117
  118. data/package.json +1 -1
  119. metadata +7 -7
  120. data/lib/preact/component/params.rb +0 -18
  121. data/lib/preact/component/props.rb +0 -55
  122. data/lib/preact/component/state.rb +0 -58
@@ -1,16 +1,16 @@
1
- import { _catchError } from './diff/catch-error';
2
-
3
- /**
4
- * The `option` object can potentially contain callback functions
5
- * that are called during various stages of our renderer. This is the
6
- * foundation on which all our addons like `preact/debug`, `preact/compat`,
7
- * and `preact/hooks` are based on. See the `Options` type in `internal.d.ts`
8
- * for a full list of available option hooks (most editors/IDEs allow you to
9
- * ctrl+click or cmd+click on mac the type definition below).
10
- * @type {import('./internal').Options}
11
- */
12
- const options = {
13
- _catchError
14
- };
15
-
16
- export default options;
1
+ import { _catchError } from './diff/catch-error';
2
+
3
+ /**
4
+ * The `option` object can potentially contain callback functions
5
+ * that are called during various stages of our renderer. This is the
6
+ * foundation on which all our addons like `preact/debug`, `preact/compat`,
7
+ * and `preact/hooks` are based on. See the `Options` type in `internal.d.ts`
8
+ * for a full list of available option hooks (most editors/IDEs allow you to
9
+ * ctrl+click or cmd+click on mac the type definition below).
10
+ * @type {import('./internal').Options}
11
+ */
12
+ const options = {
13
+ _catchError
14
+ };
15
+
16
+ export default options;
@@ -1,75 +1,75 @@
1
- import { EMPTY_OBJ } from './constants';
2
- import { commitRoot, diff } from './diff/index';
3
- import { createElement, Fragment } from './create-element';
4
- import options from './options';
5
- import { slice } from './util';
6
-
7
- /**
8
- * Render a Preact virtual node into a DOM element
9
- * @param {import('./internal').ComponentChild} vnode The virtual node to render
10
- * @param {import('./internal').PreactElement} parentDom The DOM element to
11
- * render into
12
- * @param {import('./internal').PreactElement | object} [replaceNode] Optional: Attempt to re-use an
13
- * existing DOM tree rooted at `replaceNode`
14
- */
15
- export function render(vnode, parentDom, replaceNode) {
16
- if (options._root) options._root(vnode, parentDom);
17
-
18
- // We abuse the `replaceNode` parameter in `hydrate()` to signal if we are in
19
- // hydration mode or not by passing the `hydrate` function instead of a DOM
20
- // element..
21
- let isHydrating = typeof replaceNode === 'function';
22
-
23
- // To be able to support calling `render()` multiple times on the same
24
- // DOM node, we need to obtain a reference to the previous tree. We do
25
- // this by assigning a new `_children` property to DOM nodes which points
26
- // to the last rendered tree. By default this property is not present, which
27
- // means that we are mounting a new tree for the first time.
28
- let oldVNode = isHydrating
29
- ? null
30
- : (replaceNode && replaceNode._children) || parentDom._children;
31
-
32
- vnode = (
33
- (!isHydrating && replaceNode) ||
34
- parentDom
35
- )._children = createElement(Fragment, null, [vnode]);
36
-
37
- // List of effects that need to be called after diffing.
38
- let commitQueue = [];
39
- diff(
40
- parentDom,
41
- // Determine the new vnode tree and store it on the DOM element on
42
- // our custom `_children` property.
43
- vnode,
44
- oldVNode || EMPTY_OBJ,
45
- EMPTY_OBJ,
46
- parentDom.ownerSVGElement !== undefined,
47
- !isHydrating && replaceNode
48
- ? [replaceNode]
49
- : oldVNode
50
- ? null
51
- : parentDom.firstChild
52
- ? slice.call(parentDom.childNodes)
53
- : null,
54
- commitQueue,
55
- !isHydrating && replaceNode
56
- ? replaceNode
57
- : oldVNode
58
- ? oldVNode._dom
59
- : parentDom.firstChild,
60
- isHydrating
61
- );
62
-
63
- // Flush all queued effects
64
- commitRoot(commitQueue, vnode);
65
- }
66
-
67
- /**
68
- * Update an existing DOM element with data from a Preact virtual node
69
- * @param {import('./internal').ComponentChild} vnode The virtual node to render
70
- * @param {import('./internal').PreactElement} parentDom The DOM element to
71
- * update
72
- */
73
- export function hydrate(vnode, parentDom) {
74
- render(vnode, parentDom, hydrate);
75
- }
1
+ import { EMPTY_OBJ } from './constants';
2
+ import { commitRoot, diff } from './diff/index';
3
+ import { createElement, Fragment } from './create-element';
4
+ import options from './options';
5
+ import { slice } from './util';
6
+
7
+ /**
8
+ * Render a Preact virtual node into a DOM element
9
+ * @param {import('./internal').ComponentChild} vnode The virtual node to render
10
+ * @param {import('./internal').PreactElement} parentDom The DOM element to
11
+ * render into
12
+ * @param {import('./internal').PreactElement | object} [replaceNode] Optional: Attempt to re-use an
13
+ * existing DOM tree rooted at `replaceNode`
14
+ */
15
+ export function render(vnode, parentDom, replaceNode) {
16
+ if (options._root) options._root(vnode, parentDom);
17
+
18
+ // We abuse the `replaceNode` parameter in `hydrate()` to signal if we are in
19
+ // hydration mode or not by passing the `hydrate` function instead of a DOM
20
+ // element..
21
+ let isHydrating = typeof replaceNode === 'function';
22
+
23
+ // To be able to support calling `render()` multiple times on the same
24
+ // DOM node, we need to obtain a reference to the previous tree. We do
25
+ // this by assigning a new `_children` property to DOM nodes which points
26
+ // to the last rendered tree. By default this property is not present, which
27
+ // means that we are mounting a new tree for the first time.
28
+ let oldVNode = isHydrating
29
+ ? null
30
+ : (replaceNode && replaceNode._children) || parentDom._children;
31
+
32
+ vnode = (
33
+ (!isHydrating && replaceNode) ||
34
+ parentDom
35
+ )._children = createElement(Fragment, null, [vnode]);
36
+
37
+ // List of effects that need to be called after diffing.
38
+ let commitQueue = [];
39
+ diff(
40
+ parentDom,
41
+ // Determine the new vnode tree and store it on the DOM element on
42
+ // our custom `_children` property.
43
+ vnode,
44
+ oldVNode || EMPTY_OBJ,
45
+ EMPTY_OBJ,
46
+ parentDom.ownerSVGElement !== undefined,
47
+ !isHydrating && replaceNode
48
+ ? [replaceNode]
49
+ : oldVNode
50
+ ? null
51
+ : parentDom.firstChild
52
+ ? slice.call(parentDom.childNodes)
53
+ : null,
54
+ commitQueue,
55
+ !isHydrating && replaceNode
56
+ ? replaceNode
57
+ : oldVNode
58
+ ? oldVNode._dom
59
+ : parentDom.firstChild,
60
+ isHydrating
61
+ );
62
+
63
+ // Flush all queued effects
64
+ commitRoot(commitQueue, vnode);
65
+ }
66
+
67
+ /**
68
+ * Update an existing DOM element with data from a Preact virtual node
69
+ * @param {import('./internal').ComponentChild} vnode The virtual node to render
70
+ * @param {import('./internal').PreactElement} parentDom The DOM element to
71
+ * update
72
+ */
73
+ export function hydrate(vnode, parentDom) {
74
+ render(vnode, parentDom, hydrate);
75
+ }
@@ -1,27 +1,27 @@
1
- import { EMPTY_ARR } from "./constants";
2
-
3
- /**
4
- * Assign properties from `props` to `obj`
5
- * @template O, P The obj and props types
6
- * @param {O} obj The object to copy properties to
7
- * @param {P} props The object to copy properties from
8
- * @returns {O & P}
9
- */
10
- export function assign(obj, props) {
11
- // @ts-ignore We change the type of `obj` to be `O & P`
12
- for (let i in props) obj[i] = props[i];
13
- return /** @type {O & P} */ (obj);
14
- }
15
-
16
- /**
17
- * Remove a child node from its parent if attached. This is a workaround for
18
- * IE11 which doesn't support `Element.prototype.remove()`. Using this function
19
- * is smaller than including a dedicated polyfill.
20
- * @param {Node} node The node to remove
21
- */
22
- export function removeNode(node) {
23
- let parentNode = node.parentNode;
24
- if (parentNode) parentNode.removeChild(node);
25
- }
26
-
27
- export const slice = EMPTY_ARR.slice;
1
+ import { EMPTY_ARR } from "./constants";
2
+
3
+ /**
4
+ * Assign properties from `props` to `obj`
5
+ * @template O, P The obj and props types
6
+ * @param {O} obj The object to copy properties to
7
+ * @param {P} props The object to copy properties from
8
+ * @returns {O & P}
9
+ */
10
+ export function assign(obj, props) {
11
+ // @ts-ignore We change the type of `obj` to be `O & P`
12
+ for (let i in props) obj[i] = props[i];
13
+ return /** @type {O & P} */ (obj);
14
+ }
15
+
16
+ /**
17
+ * Remove a child node from its parent if attached. This is a workaround for
18
+ * IE11 which doesn't support `Element.prototype.remove()`. Using this function
19
+ * is smaller than including a dedicated polyfill.
20
+ * @param {Node} node The node to remove
21
+ */
22
+ export function removeNode(node) {
23
+ let parentNode = node.parentNode;
24
+ if (parentNode) parentNode.removeChild(node);
25
+ }
26
+
27
+ export const slice = EMPTY_ARR.slice;
@@ -1 +1 @@
1
- {"version":3,"file":"testUtils.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\r\n\r\n/**\r\n * Setup a rerender function that will drain the queue of pending renders\r\n * @returns {() => void}\r\n */\r\nexport function setupRerender() {\r\n\toptions.__test__previousDebounce = options.debounceRendering;\r\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\r\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\r\n}\r\n\r\nconst isThenable = value => value != null && typeof value.then == 'function';\r\n\r\n/** Depth of nested calls to `act`. */\r\nlet actDepth = 0;\r\n\r\n/**\r\n * Run a test function, and flush all effects and rerenders after invoking it.\r\n *\r\n * Returns a Promise which resolves \"immediately\" if the callback is\r\n * synchronous or when the callback's result resolves if it is asynchronous.\r\n *\r\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\r\n * @return {Promise<void>}\r\n */\r\nexport function act(cb) {\r\n\tif (++actDepth > 1) {\r\n\t\t// If calls to `act` are nested, a flush happens only when the\r\n\t\t// outermost call returns. In the inner call, we just execute the\r\n\t\t// callback and return since the infrastructure for flushing has already\r\n\t\t// been set up.\r\n\t\t//\r\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\r\n\t\tconst result = cb();\r\n\t\tif (isThenable(result)) {\r\n\t\t\treturn result.then(() => {\r\n\t\t\t\t--actDepth;\r\n\t\t\t});\r\n\t\t}\r\n\t\t--actDepth;\r\n\t\treturn Promise.resolve();\r\n\t}\r\n\r\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\r\n\tconst rerender = setupRerender();\r\n\r\n\t/** @type {() => void} */\r\n\tlet flush, toFlush;\r\n\r\n\t// Override requestAnimationFrame so we can flush pending hooks.\r\n\toptions.requestAnimationFrame = fc => (flush = fc);\r\n\r\n\tconst finish = () => {\r\n\t\ttry {\r\n\t\t\trerender();\r\n\t\t\twhile (flush) {\r\n\t\t\t\ttoFlush = flush;\r\n\t\t\t\tflush = null;\r\n\r\n\t\t\t\ttoFlush();\r\n\t\t\t\trerender();\r\n\t\t\t}\r\n\t\t\tteardown();\r\n\t\t} catch (e) {\r\n\t\t\tif (!err) {\r\n\t\t\t\terr = e;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\r\n\t\t--actDepth;\r\n\t};\r\n\r\n\tlet err;\r\n\tlet result;\r\n\r\n\ttry {\r\n\t\tresult = cb();\r\n\t} catch (e) {\r\n\t\terr = e;\r\n\t}\r\n\r\n\tif (isThenable(result)) {\r\n\t\treturn result.then(finish, err => {\r\n\t\t\tfinish();\r\n\t\t\tthrow err;\r\n\t\t});\r\n\t}\r\n\r\n\t// nb. If the callback is synchronous, effects must be flushed before\r\n\t// `act` returns, so that the caller does not have to await the result,\r\n\t// even though React recommends this.\r\n\tfinish();\r\n\tif (err) {\r\n\t\tthrow err;\r\n\t}\r\n\treturn Promise.resolve();\r\n}\r\n\r\n/**\r\n * Teardown test environment and reset preact's internal state\r\n */\r\nexport function teardown() {\r\n\tif (options.__test__drainQueue) {\r\n\t\t// Flush any pending updates leftover by test\r\n\t\toptions.__test__drainQueue();\r\n\t\tdelete options.__test__drainQueue;\r\n\t}\r\n\r\n\tif (typeof options.__test__previousDebounce != 'undefined') {\r\n\t\toptions.debounceRendering = options.__test__previousDebounce;\r\n\t\tdelete options.__test__previousDebounce;\r\n\t} else {\r\n\t\toptions.debounceRendering = undefined;\r\n\t}\r\n}\r\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\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 +1 @@
1
- {"version":3,"file":"testUtils.module.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\r\n\r\n/**\r\n * Setup a rerender function that will drain the queue of pending renders\r\n * @returns {() => void}\r\n */\r\nexport function setupRerender() {\r\n\toptions.__test__previousDebounce = options.debounceRendering;\r\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\r\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\r\n}\r\n\r\nconst isThenable = value => value != null && typeof value.then == 'function';\r\n\r\n/** Depth of nested calls to `act`. */\r\nlet actDepth = 0;\r\n\r\n/**\r\n * Run a test function, and flush all effects and rerenders after invoking it.\r\n *\r\n * Returns a Promise which resolves \"immediately\" if the callback is\r\n * synchronous or when the callback's result resolves if it is asynchronous.\r\n *\r\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\r\n * @return {Promise<void>}\r\n */\r\nexport function act(cb) {\r\n\tif (++actDepth > 1) {\r\n\t\t// If calls to `act` are nested, a flush happens only when the\r\n\t\t// outermost call returns. In the inner call, we just execute the\r\n\t\t// callback and return since the infrastructure for flushing has already\r\n\t\t// been set up.\r\n\t\t//\r\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\r\n\t\tconst result = cb();\r\n\t\tif (isThenable(result)) {\r\n\t\t\treturn result.then(() => {\r\n\t\t\t\t--actDepth;\r\n\t\t\t});\r\n\t\t}\r\n\t\t--actDepth;\r\n\t\treturn Promise.resolve();\r\n\t}\r\n\r\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\r\n\tconst rerender = setupRerender();\r\n\r\n\t/** @type {() => void} */\r\n\tlet flush, toFlush;\r\n\r\n\t// Override requestAnimationFrame so we can flush pending hooks.\r\n\toptions.requestAnimationFrame = fc => (flush = fc);\r\n\r\n\tconst finish = () => {\r\n\t\ttry {\r\n\t\t\trerender();\r\n\t\t\twhile (flush) {\r\n\t\t\t\ttoFlush = flush;\r\n\t\t\t\tflush = null;\r\n\r\n\t\t\t\ttoFlush();\r\n\t\t\t\trerender();\r\n\t\t\t}\r\n\t\t\tteardown();\r\n\t\t} catch (e) {\r\n\t\t\tif (!err) {\r\n\t\t\t\terr = e;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\r\n\t\t--actDepth;\r\n\t};\r\n\r\n\tlet err;\r\n\tlet result;\r\n\r\n\ttry {\r\n\t\tresult = cb();\r\n\t} catch (e) {\r\n\t\terr = e;\r\n\t}\r\n\r\n\tif (isThenable(result)) {\r\n\t\treturn result.then(finish, err => {\r\n\t\t\tfinish();\r\n\t\t\tthrow err;\r\n\t\t});\r\n\t}\r\n\r\n\t// nb. If the callback is synchronous, effects must be flushed before\r\n\t// `act` returns, so that the caller does not have to await the result,\r\n\t// even though React recommends this.\r\n\tfinish();\r\n\tif (err) {\r\n\t\tthrow err;\r\n\t}\r\n\treturn Promise.resolve();\r\n}\r\n\r\n/**\r\n * Teardown test environment and reset preact's internal state\r\n */\r\nexport function teardown() {\r\n\tif (options.__test__drainQueue) {\r\n\t\t// Flush any pending updates leftover by test\r\n\t\toptions.__test__drainQueue();\r\n\t\tdelete options.__test__drainQueue;\r\n\t}\r\n\r\n\tif (typeof options.__test__previousDebounce != 'undefined') {\r\n\t\toptions.debounceRendering = options.__test__previousDebounce;\r\n\t\tdelete options.__test__previousDebounce;\r\n\t} else {\r\n\t\toptions.debounceRendering = undefined;\r\n\t}\r\n}\r\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\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 +1 @@
1
- {"version":3,"file":"testUtils.umd.js","sources":["../src/index.js"],"sourcesContent":["import { options } from 'preact';\r\n\r\n/**\r\n * Setup a rerender function that will drain the queue of pending renders\r\n * @returns {() => void}\r\n */\r\nexport function setupRerender() {\r\n\toptions.__test__previousDebounce = options.debounceRendering;\r\n\toptions.debounceRendering = cb => (options.__test__drainQueue = cb);\r\n\treturn () => options.__test__drainQueue && options.__test__drainQueue();\r\n}\r\n\r\nconst isThenable = value => value != null && typeof value.then == 'function';\r\n\r\n/** Depth of nested calls to `act`. */\r\nlet actDepth = 0;\r\n\r\n/**\r\n * Run a test function, and flush all effects and rerenders after invoking it.\r\n *\r\n * Returns a Promise which resolves \"immediately\" if the callback is\r\n * synchronous or when the callback's result resolves if it is asynchronous.\r\n *\r\n * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.\r\n * @return {Promise<void>}\r\n */\r\nexport function act(cb) {\r\n\tif (++actDepth > 1) {\r\n\t\t// If calls to `act` are nested, a flush happens only when the\r\n\t\t// outermost call returns. In the inner call, we just execute the\r\n\t\t// callback and return since the infrastructure for flushing has already\r\n\t\t// been set up.\r\n\t\t//\r\n\t\t// If an exception occurs, the outermost `act` will handle cleanup.\r\n\t\tconst result = cb();\r\n\t\tif (isThenable(result)) {\r\n\t\t\treturn result.then(() => {\r\n\t\t\t\t--actDepth;\r\n\t\t\t});\r\n\t\t}\r\n\t\t--actDepth;\r\n\t\treturn Promise.resolve();\r\n\t}\r\n\r\n\tconst previousRequestAnimationFrame = options.requestAnimationFrame;\r\n\tconst rerender = setupRerender();\r\n\r\n\t/** @type {() => void} */\r\n\tlet flush, toFlush;\r\n\r\n\t// Override requestAnimationFrame so we can flush pending hooks.\r\n\toptions.requestAnimationFrame = fc => (flush = fc);\r\n\r\n\tconst finish = () => {\r\n\t\ttry {\r\n\t\t\trerender();\r\n\t\t\twhile (flush) {\r\n\t\t\t\ttoFlush = flush;\r\n\t\t\t\tflush = null;\r\n\r\n\t\t\t\ttoFlush();\r\n\t\t\t\trerender();\r\n\t\t\t}\r\n\t\t\tteardown();\r\n\t\t} catch (e) {\r\n\t\t\tif (!err) {\r\n\t\t\t\terr = e;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\toptions.requestAnimationFrame = previousRequestAnimationFrame;\r\n\t\t--actDepth;\r\n\t};\r\n\r\n\tlet err;\r\n\tlet result;\r\n\r\n\ttry {\r\n\t\tresult = cb();\r\n\t} catch (e) {\r\n\t\terr = e;\r\n\t}\r\n\r\n\tif (isThenable(result)) {\r\n\t\treturn result.then(finish, err => {\r\n\t\t\tfinish();\r\n\t\t\tthrow err;\r\n\t\t});\r\n\t}\r\n\r\n\t// nb. If the callback is synchronous, effects must be flushed before\r\n\t// `act` returns, so that the caller does not have to await the result,\r\n\t// even though React recommends this.\r\n\tfinish();\r\n\tif (err) {\r\n\t\tthrow err;\r\n\t}\r\n\treturn Promise.resolve();\r\n}\r\n\r\n/**\r\n * Teardown test environment and reset preact's internal state\r\n */\r\nexport function teardown() {\r\n\tif (options.__test__drainQueue) {\r\n\t\t// Flush any pending updates leftover by test\r\n\t\toptions.__test__drainQueue();\r\n\t\tdelete options.__test__drainQueue;\r\n\t}\r\n\r\n\tif (typeof options.__test__previousDebounce != 'undefined') {\r\n\t\toptions.debounceRendering = options.__test__previousDebounce;\r\n\t\tdelete options.__test__previousDebounce;\r\n\t} else {\r\n\t\toptions.debounceRendering = undefined;\r\n\t}\r\n}\r\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\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,19 +1,19 @@
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
- }
19
- }
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
+ }
19
+ }
@@ -1,3 +1,3 @@
1
- export function setupRerender(): () => void;
2
- export function act(callback: () => void | Promise<void>): Promise<void>;
3
- export function teardown(): void;
1
+ export function setupRerender(): () => void;
2
+ export function act(callback: () => void | Promise<void>): Promise<void>;
3
+ export function teardown(): void;
@@ -1,117 +1,117 @@
1
- import { options } from 'preact';
2
-
3
- /**
4
- * Setup a rerender function that will drain the queue of pending renders
5
- * @returns {() => void}
6
- */
7
- export function setupRerender() {
8
- options.__test__previousDebounce = options.debounceRendering;
9
- options.debounceRendering = cb => (options.__test__drainQueue = cb);
10
- return () => options.__test__drainQueue && options.__test__drainQueue();
11
- }
12
-
13
- const isThenable = value => value != null && typeof value.then == 'function';
14
-
15
- /** Depth of nested calls to `act`. */
16
- let actDepth = 0;
17
-
18
- /**
19
- * Run a test function, and flush all effects and rerenders after invoking it.
20
- *
21
- * Returns a Promise which resolves "immediately" if the callback is
22
- * synchronous or when the callback's result resolves if it is asynchronous.
23
- *
24
- * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.
25
- * @return {Promise<void>}
26
- */
27
- export function act(cb) {
28
- if (++actDepth > 1) {
29
- // If calls to `act` are nested, a flush happens only when the
30
- // outermost call returns. In the inner call, we just execute the
31
- // callback and return since the infrastructure for flushing has already
32
- // been set up.
33
- //
34
- // If an exception occurs, the outermost `act` will handle cleanup.
35
- const result = cb();
36
- if (isThenable(result)) {
37
- return result.then(() => {
38
- --actDepth;
39
- });
40
- }
41
- --actDepth;
42
- return Promise.resolve();
43
- }
44
-
45
- const previousRequestAnimationFrame = options.requestAnimationFrame;
46
- const rerender = setupRerender();
47
-
48
- /** @type {() => void} */
49
- let flush, toFlush;
50
-
51
- // Override requestAnimationFrame so we can flush pending hooks.
52
- options.requestAnimationFrame = fc => (flush = fc);
53
-
54
- const finish = () => {
55
- try {
56
- rerender();
57
- while (flush) {
58
- toFlush = flush;
59
- flush = null;
60
-
61
- toFlush();
62
- rerender();
63
- }
64
- teardown();
65
- } catch (e) {
66
- if (!err) {
67
- err = e;
68
- }
69
- }
70
-
71
- options.requestAnimationFrame = previousRequestAnimationFrame;
72
- --actDepth;
73
- };
74
-
75
- let err;
76
- let result;
77
-
78
- try {
79
- result = cb();
80
- } catch (e) {
81
- err = e;
82
- }
83
-
84
- if (isThenable(result)) {
85
- return result.then(finish, err => {
86
- finish();
87
- throw err;
88
- });
89
- }
90
-
91
- // nb. If the callback is synchronous, effects must be flushed before
92
- // `act` returns, so that the caller does not have to await the result,
93
- // even though React recommends this.
94
- finish();
95
- if (err) {
96
- throw err;
97
- }
98
- return Promise.resolve();
99
- }
100
-
101
- /**
102
- * Teardown test environment and reset preact's internal state
103
- */
104
- export function teardown() {
105
- if (options.__test__drainQueue) {
106
- // Flush any pending updates leftover by test
107
- options.__test__drainQueue();
108
- delete options.__test__drainQueue;
109
- }
110
-
111
- if (typeof options.__test__previousDebounce != 'undefined') {
112
- options.debounceRendering = options.__test__previousDebounce;
113
- delete options.__test__previousDebounce;
114
- } else {
115
- options.debounceRendering = undefined;
116
- }
117
- }
1
+ import { options } from 'preact';
2
+
3
+ /**
4
+ * Setup a rerender function that will drain the queue of pending renders
5
+ * @returns {() => void}
6
+ */
7
+ export function setupRerender() {
8
+ options.__test__previousDebounce = options.debounceRendering;
9
+ options.debounceRendering = cb => (options.__test__drainQueue = cb);
10
+ return () => options.__test__drainQueue && options.__test__drainQueue();
11
+ }
12
+
13
+ const isThenable = value => value != null && typeof value.then == 'function';
14
+
15
+ /** Depth of nested calls to `act`. */
16
+ let actDepth = 0;
17
+
18
+ /**
19
+ * Run a test function, and flush all effects and rerenders after invoking it.
20
+ *
21
+ * Returns a Promise which resolves "immediately" if the callback is
22
+ * synchronous or when the callback's result resolves if it is asynchronous.
23
+ *
24
+ * @param {() => void|Promise<void>} cb The function under test. This may be sync or async.
25
+ * @return {Promise<void>}
26
+ */
27
+ export function act(cb) {
28
+ if (++actDepth > 1) {
29
+ // If calls to `act` are nested, a flush happens only when the
30
+ // outermost call returns. In the inner call, we just execute the
31
+ // callback and return since the infrastructure for flushing has already
32
+ // been set up.
33
+ //
34
+ // If an exception occurs, the outermost `act` will handle cleanup.
35
+ const result = cb();
36
+ if (isThenable(result)) {
37
+ return result.then(() => {
38
+ --actDepth;
39
+ });
40
+ }
41
+ --actDepth;
42
+ return Promise.resolve();
43
+ }
44
+
45
+ const previousRequestAnimationFrame = options.requestAnimationFrame;
46
+ const rerender = setupRerender();
47
+
48
+ /** @type {() => void} */
49
+ let flush, toFlush;
50
+
51
+ // Override requestAnimationFrame so we can flush pending hooks.
52
+ options.requestAnimationFrame = fc => (flush = fc);
53
+
54
+ const finish = () => {
55
+ try {
56
+ rerender();
57
+ while (flush) {
58
+ toFlush = flush;
59
+ flush = null;
60
+
61
+ toFlush();
62
+ rerender();
63
+ }
64
+ teardown();
65
+ } catch (e) {
66
+ if (!err) {
67
+ err = e;
68
+ }
69
+ }
70
+
71
+ options.requestAnimationFrame = previousRequestAnimationFrame;
72
+ --actDepth;
73
+ };
74
+
75
+ let err;
76
+ let result;
77
+
78
+ try {
79
+ result = cb();
80
+ } catch (e) {
81
+ err = e;
82
+ }
83
+
84
+ if (isThenable(result)) {
85
+ return result.then(finish, err => {
86
+ finish();
87
+ throw err;
88
+ });
89
+ }
90
+
91
+ // nb. If the callback is synchronous, effects must be flushed before
92
+ // `act` returns, so that the caller does not have to await the result,
93
+ // even though React recommends this.
94
+ finish();
95
+ if (err) {
96
+ throw err;
97
+ }
98
+ return Promise.resolve();
99
+ }
100
+
101
+ /**
102
+ * Teardown test environment and reset preact's internal state
103
+ */
104
+ export function teardown() {
105
+ if (options.__test__drainQueue) {
106
+ // Flush any pending updates leftover by test
107
+ options.__test__drainQueue();
108
+ delete options.__test__drainQueue;
109
+ }
110
+
111
+ if (typeof options.__test__previousDebounce != 'undefined') {
112
+ options.debounceRendering = options.__test__previousDebounce;
113
+ delete options.__test__previousDebounce;
114
+ } else {
115
+ options.debounceRendering = undefined;
116
+ }
117
+ }
data/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "isomorfeus-preact",
3
3
  "dependencies": {
4
- "preact": "10.6.4",
4
+ "preact": "10.6.5",
5
5
  "preact-render-to-string": "5.1.19",
6
6
  "wouter-preact": "2.7.5"
7
7
  }