initial vitepress site with basic nav

This commit is contained in:
mrflos 2023-05-20 19:37:42 +03:00
parent a7df2e049d
commit 2029f16583
1900 changed files with 1014692 additions and 0 deletions

2
node_modules/preact/test-utils/dist/testUtils.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
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.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.setupRerender=n,exports.teardown=o;
//# sourceMappingURL=testUtils.js.map

1
node_modules/preact/test-utils/dist/testUtils.js.map generated vendored Normal file
View file

@ -0,0 +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":"iCAMgBA,IAGf,OAFAC,EAAOA,QAACC,EAA2BD,EAAAA,QAAQE,kBAC3CF,EAAOA,QAACE,kBAAoB,SAAAC,UAAOH,UAAQI,EAAqBD,CAAlC,EACvB,WAAA,OAAMH,EAAOA,QAACI,GAAsBJ,UAAQI,GAA5C,CACP,CAED,IAAMC,EAAa,SAAAC,GAAK,OAAa,MAATA,GAAsC,mBAAdA,EAAMC,IAAlC,EAGpBC,EAAW,EAyFR,SAASC,IACXT,EAAOA,QAACI,IAEXJ,EAAOA,QAACI,WACDJ,EAAAA,QAAQI,QAG+B,IAApCJ,UAAQC,GAClBD,EAAAA,QAAQE,kBAAoBF,EAAOA,QAACC,SAC7BD,EAAOA,QAACC,GAEfD,EAAAA,QAAQE,uBAAoBQ,CAE7B,aA3FM,SAAaP,GACnB,KAAMK,EAAW,EAAG,CAOnB,IAAMG,EAASR,IACf,OAAIE,EAAWM,GACPA,EAAOJ,KAAK,aAChBC,CACF,MAEAA,EACKI,QAAQC,UACf,CAED,IAIIC,EAAOC,EAJLC,EAAgChB,EAAOA,QAACiB,sBACxCC,EAAWnB,IAMjBC,EAAOA,QAACiB,sBAAwB,SAAAE,GAAOL,OAAAA,EAAQK,CAAb,EAElC,IAsBIC,EACAT,EAvBEU,EAAS,WACd,IAEC,IADAH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,GAQD,CANC,MAAOI,GACHF,IACJA,EAAME,EAEP,CAbD,QAcCb,GACA,CAEDT,EAAOA,QAACiB,sBAAwBD,IAC9BR,CACF,EAKD,IACCG,EAASR,GAGT,CAFC,MAAOmB,GACRF,EAAME,CACN,CAED,GAAIjB,EAAWM,GACd,OAAOA,EAAOJ,KAAKc,EAAQ,SAAAD,GAE1B,MADAC,IACMD,CACN,GAOF,GADAC,IACID,EACH,MAAMA,EAEP,OAAOR,QAAQC,SACf"}

2
node_modules/preact/test-utils/dist/testUtils.mjs generated vendored Normal file
View file

@ -0,0 +1,2 @@
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{u as act,r as setupRerender,i as teardown};
//# sourceMappingURL=testUtils.module.js.map

View file

@ -0,0 +1,2 @@
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{u as act,r as setupRerender,i as teardown};
//# sourceMappingURL=testUtils.module.js.map

View file

@ -0,0 +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":"0CAMgBA,IAGf,OAFAC,EAAQC,EAA2BD,EAAQE,kBAC3CF,EAAQE,kBAAoB,SAAAC,UAAOH,EAAQI,EAAqBD,CAAlC,EACvB,WAAA,OAAMH,EAAQI,GAAsBJ,EAAQI,GAA5C,CACP,CAED,IAAMC,EAAa,SAAAC,GAAK,OAAa,MAATA,GAAsC,mBAAdA,EAAMC,IAAlC,EAGpBC,EAAW,EAWR,SAASC,EAAIN,GACnB,KAAMK,EAAW,EAAG,CAOnB,IAAME,EAASP,IACf,OAAIE,EAAWK,GACPA,EAAOH,KAAK,aAChBC,CACF,MAEAA,EACKG,QAAQC,UACf,CAED,IAIIC,EAAOC,EAJLC,EAAgCf,EAAQgB,sBACxCC,EAAWlB,IAMjBC,EAAQgB,sBAAwB,SAAAE,GAAOL,OAAAA,EAAQK,CAAb,EAElC,IAsBIC,EACAT,EAvBEU,EAAS,WACd,IAEC,IADAH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,GAQD,CANC,MAAOI,GACHF,IACJA,EAAME,EAEP,CAbD,QAcCC,GACA,CAEDtB,EAAQgB,sBAAwBD,IAC9BP,CACF,EAKD,IACCE,EAASP,GAGT,CAFC,MAAOkB,GACRF,EAAME,CACN,CAED,GAAIhB,EAAWK,GACd,OAAOA,EAAOH,KAAKa,EAAQ,SAAAD,GAE1B,MADAC,IACMD,CACN,GAOF,GADAC,IACID,EACH,MAAMA,EAEP,OAAOR,QAAQC,SACf,CAKM,SAASU,IACXtB,EAAQI,IAEXJ,EAAQI,WACDJ,EAAQI,QAG+B,IAApCJ,EAAQC,GAClBD,EAAQE,kBAAoBF,EAAQC,SAC7BD,EAAQC,GAEfD,EAAQE,uBAAoBqB,CAE7B"}

2
node_modules/preact/test-utils/dist/testUtils.umd.js generated vendored Normal file
View file

@ -0,0 +1,2 @@
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t((n||self).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.act=function(n){if(++o>1){var f=n();return r(f)?f.then(function(){--o}):(--o,Promise.resolve())}var u,c,l=t.options.requestAnimationFrame,d=e();t.options.requestAnimationFrame=function(n){return u=n};var a,p,s=function(){try{for(d();u;)c=u,u=null,c(),d()}catch(n){a||(a=n)}finally{i()}t.options.requestAnimationFrame=l,--o};try{p=n()}catch(n){a=n}if(r(p))return p.then(s,function(n){throw s(),n});if(s(),a)throw a;return Promise.resolve()},n.setupRerender=e,n.teardown=i});
//# sourceMappingURL=testUtils.umd.js.map

View file

@ -0,0 +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":"wRAMgBA,IAGf,OAFAC,EAAOA,QAACC,EAA2BD,EAAAA,QAAQE,kBAC3CF,EAAOA,QAACE,kBAAoB,SAAAC,UAAOH,UAAQI,EAAqBD,CAAlC,EACvB,WAAA,OAAMH,EAAOA,QAACI,GAAsBJ,UAAQI,GAA5C,CACP,CAED,IAAMC,EAAa,SAAAC,GAAK,OAAa,MAATA,GAAsC,mBAAdA,EAAMC,IAAlC,EAGpBC,EAAW,EAyFR,SAASC,IACXT,EAAOA,QAACI,IAEXJ,EAAOA,QAACI,WACDJ,EAAAA,QAAQI,QAG+B,IAApCJ,UAAQC,GAClBD,EAAAA,QAAQE,kBAAoBF,EAAOA,QAACC,SAC7BD,EAAOA,QAACC,GAEfD,EAAAA,QAAQE,uBAAoBQ,CAE7B,OA3FM,SAAaP,GACnB,KAAMK,EAAW,EAAG,CAOnB,IAAMG,EAASR,IACf,OAAIE,EAAWM,GACPA,EAAOJ,KAAK,aAChBC,CACF,MAEAA,EACKI,QAAQC,UACf,CAED,IAIIC,EAAOC,EAJLC,EAAgChB,EAAOA,QAACiB,sBACxCC,EAAWnB,IAMjBC,EAAOA,QAACiB,sBAAwB,SAAAE,GAAOL,OAAAA,EAAQK,CAAb,EAElC,IAsBIC,EACAT,EAvBEU,EAAS,WACd,IAEC,IADAH,IACOJ,GACNC,EAAUD,EACVA,EAAQ,KAERC,IACAG,GAQD,CANC,MAAOI,GACHF,IACJA,EAAME,EAEP,CAbD,QAcCb,GACA,CAEDT,EAAOA,QAACiB,sBAAwBD,IAC9BR,CACF,EAKD,IACCG,EAASR,GAGT,CAFC,MAAOmB,GACRF,EAAME,CACN,CAED,GAAIjB,EAAWM,GACd,OAAOA,EAAOJ,KAAKc,EAAQ,SAAAD,GAE1B,MADAC,IACMD,CACN,GAOF,GADAC,IACID,EACH,MAAMA,EAEP,OAAOR,QAAQC,SACf"}

28
node_modules/preact/test-utils/package.json generated vendored Normal file
View file

@ -0,0 +1,28 @@
{
"name": "test-utils",
"amdName": "preactTestUtils",
"version": "0.1.0",
"private": true,
"description": "Test-utils for Preact",
"main": "dist/testUtils.js",
"module": "dist/testUtils.module.js",
"umd:main": "dist/testUtils.umd.js",
"source": "src/index.js",
"license": "MIT",
"types": "src/index.d.ts",
"peerDependencies": {
"preact": "^10.0.0"
},
"mangle": {
"regex": "^_"
},
"exports": {
".": {
"types": "./src/index.d.ts",
"browser": "./dist/testUtils.module.js",
"umd": "./dist/testUtils.umd.js",
"import": "./dist/testUtils.mjs",
"require": "./dist/testUtils.js"
}
}
}

3
node_modules/preact/test-utils/src/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,3 @@
export function setupRerender(): () => void;
export function act(callback: () => void | Promise<void>): Promise<void>;
export function teardown(): void;

118
node_modules/preact/test-utils/src/index.js generated vendored Normal file
View file

@ -0,0 +1,118 @@
import { options } from 'preact';
/**
* Setup a rerender function that will drain the queue of pending renders
* @returns {() => void}
*/
export function setupRerender() {
options.__test__previousDebounce = options.debounceRendering;
options.debounceRendering = cb => (options.__test__drainQueue = cb);
return () => options.__test__drainQueue && options.__test__drainQueue();
}
const isThenable = value => value != null && typeof value.then == 'function';
/** Depth of nested calls to `act`. */
let actDepth = 0;
/**
* Run a test function, and flush all effects and rerenders after invoking it.
*
* Returns a Promise which resolves "immediately" if the callback is
* synchronous or when the callback's result resolves if it is asynchronous.
*
* @param {() => void|Promise<void>} cb The function under test. This may be sync or async.
* @return {Promise<void>}
*/
export function act(cb) {
if (++actDepth > 1) {
// If calls to `act` are nested, a flush happens only when the
// outermost call returns. In the inner call, we just execute the
// callback and return since the infrastructure for flushing has already
// been set up.
//
// If an exception occurs, the outermost `act` will handle cleanup.
const result = cb();
if (isThenable(result)) {
return result.then(() => {
--actDepth;
});
}
--actDepth;
return Promise.resolve();
}
const previousRequestAnimationFrame = options.requestAnimationFrame;
const rerender = setupRerender();
/** @type {() => void} */
let flush, toFlush;
// Override requestAnimationFrame so we can flush pending hooks.
options.requestAnimationFrame = fc => (flush = fc);
const finish = () => {
try {
rerender();
while (flush) {
toFlush = flush;
flush = null;
toFlush();
rerender();
}
} catch (e) {
if (!err) {
err = e;
}
} finally {
teardown();
}
options.requestAnimationFrame = previousRequestAnimationFrame;
--actDepth;
};
let err;
let result;
try {
result = cb();
} catch (e) {
err = e;
}
if (isThenable(result)) {
return result.then(finish, err => {
finish();
throw err;
});
}
// nb. If the callback is synchronous, effects must be flushed before
// `act` returns, so that the caller does not have to await the result,
// even though React recommends this.
finish();
if (err) {
throw err;
}
return Promise.resolve();
}
/**
* Teardown test environment and reset preact's internal state
*/
export function teardown() {
if (options.__test__drainQueue) {
// Flush any pending updates leftover by test
options.__test__drainQueue();
delete options.__test__drainQueue;
}
if (typeof options.__test__previousDebounce != 'undefined') {
options.debounceRendering = options.__test__previousDebounce;
delete options.__test__previousDebounce;
} else {
options.debounceRendering = undefined;
}
}