vest 4.4.2 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/classnames.development.js +16 -90
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +5 -58
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +8 -51
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +5 -57
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +15 -89
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +2 -26
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +197 -452
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +14 -88
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -54
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +2 -45
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +1 -53
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +14 -88
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +1 -25
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +131 -387
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +27 -56
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +111 -94
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +185 -168
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +134 -117
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +27 -56
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/vest.development.js +398 -386
- package/dist/umd/vest.production.js +1 -1
- package/package.json +4 -3
- package/testUtils/__tests__/partition.test.ts +21 -0
- package/testUtils/mockThrowError.ts +2 -1
- package/testUtils/partition.ts +13 -0
- package/testUtils/suiteDummy.ts +1 -1
- package/types/enforce/compose.d.ts +17 -32
- package/types/enforce/compounds.d.ts +17 -32
- package/types/enforce/schema.d.ts +17 -32
- package/types/parser.d.ts +8 -7
- package/types/promisify.d.ts +20 -35
- package/types/vest.d.ts +45 -60
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as t}from"context";export{enforce}from"n4s";var n,r=(n=0,function(){return"".concat(n++)});function e(t){return String(t)===t}function u(t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return!t.apply(void 0,n)}}var i=Object.assign;function o(t){var n=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(n))}function s(t,n){return o(t)&&o(n)&&Number(t)===Number(n)}function a(t,n){return o(t)&&o(n)&&Number(t)>Number(n)}function c(t){function n(r,u){var i=n.get(r);return i?i[1]:(u=u(),e.unshift([r.concat(),u]),a(e.length,t)&&(e.length=t),u)}function r(t){return e.findIndex((function(n){var r=n[0];return s(t.length,r.length)&&t.every((function(t,n){return t===r[n]}))}))}void 0===t&&(t=1);var e=[];return n.invalidate=function(t){-1<(t=r(t))&&e.splice(t,1)},n.get=function(t){return e[r(t)]||null},n}var f=u((function(t){return null===t}));function l(t){return"function"==typeof t}function d(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return l(t)?t.apply(void 0,n):t}function p(t,n){var r;return null!==(r=d(t))&&void 0!==r?r:d(n)}function v(t){return(t=[].concat(t))[t.length-1]}function h(t,n){for(var r=[],e=0;e<t.length;e++){var u=t[e];Array.isArray(u)?r.push(h(u,n)):(u=n(u),f(u)&&r.push(u))}return r}function E(t){return[].concat(t).reduce((function(t,n){return Array.isArray(n)?t.concat(E(n)):[].concat(t).concat(n)}),[])}function g(t,n){var r=0;for(n=n.slice(0,-1);r<n.length;r++){var e=n[r];t[e]=p(t[e],[]),t=t[e]}return t}var N,m=N||(N={});m[m.DEFAULT=0]="DEFAULT",m[m.SUITE=1]="SUITE",m[m.EACH=2]="EACH",m[m.SKIP_WHEN=3]="SKIP_WHEN",m[m.OMIT_WHEN=4]="OMIT_WHEN",m[m.GROUP=5]="GROUP";var y,R=y||(y={});function b(){var t=0;return{current:function(){return t},next:function(){t++}}}function S(t,n){return void 0===n&&(n=[]),{cursor:b(),keys:{current:{},prev:{}},path:n,type:t}}R[R.ALL=0]="ALL",R[R.EAGER=1]="EAGER";var T=t((function(t,n){return n?null:i({},{exclusion:{tests:{},groups:{}},inclusion:{},isolate:S(N.DEFAULT),mode:[y.ALL]},t)}));function O(){return T.useX().stateRef}function C(t){return O().optionalFields()[0][t]}function A(t,n){(0,O().optionalFields()[1])((function(r){var e;return i(r,((e={})[t]=d(n,r[t]),e))}))}function I(t){var n;return null===(n=C(t))||void 0===n?void 0:n[0]}function _(){k((function(t){return t}))}function k(t){(0,O().testObjects()[1])((function(n){return{prev:n.prev,current:[].concat(t(n.current))}}))}function F(){return U().filter((function(t){return t.isPending()}))}var L=c();function U(){var t=O().testObjects()[0].current;return L([t],(function(){return E(t)}))}var G,P=G||(G={});P.Error="error",P.Warning="warning";var W=function(){function t(t,n,e){var u=void 0===e?{}:e;e=u.message;var i=u.groupName;u=u.key,this.key=null,this.id=r(),this.severity=G.Error,this.status=w,this.fieldName=t,this.testFn=n,i&&(this.groupName=i),e&&(this.message=e),u&&(this.key=u)}return t.prototype.run=function(){try{var t=this.testFn()}catch(n){t=n,void 0===this.message&&e(t)&&(this.message=n),t=!1}return!1===t&&this.fail(),t},t.prototype.setStatus=function(t){this.isFinalStatus()&&t!==M||(this.status=t)},t.prototype.warns=function(){return this.severity===G.Warning},t.prototype.setPending=function(){this.setStatus(H)},t.prototype.fail=function(){this.setStatus(this.warns()?X:x)},t.prototype.done=function(){this.isFinalStatus()||this.setStatus(j)},t.prototype.warn=function(){this.severity=G.Warning},t.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},t.prototype.skip=function(t){this.isPending()&&!t||this.setStatus(D)},t.prototype.cancel=function(){this.setStatus(K),_()},t.prototype.reset=function(){this.status=w,_()},t.prototype.omit=function(){this.setStatus(M)},t.prototype.valueOf=function(){return!this.isFailing()},t.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},t.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},t.prototype.isPending=function(){return this.statusEquals(H)},t.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},t.prototype.isOmitted=function(){return this.statusEquals(M)},t.prototype.isUntested=function(){return this.statusEquals(w)},t.prototype.isFailing=function(){return this.statusEquals(x)},t.prototype.isCanceled=function(){return this.statusEquals(K)},t.prototype.isSkipped=function(){return this.statusEquals(D)},t.prototype.isPassing=function(){return this.statusEquals(j)},t.prototype.isWarning=function(){return this.statusEquals(X)},t.prototype.statusEquals=function(t){return this.status===t},t}(),w="UNTESTED",D="SKIPPED",x="FAILED",X="WARNING",j="PASSING",H="PENDING",K="CANCELED",M="OMITTED";function q(t,n){if(!t)throw n instanceof String?n.valueOf():Error(n?d(n):n)}function B(t){function n(t,n,u){return e.references.push(),r(t,d(n,u)),function(){return[e.references[t],function(n){return r(t,d(n,e.references[t]))}]}}function r(n,r){var i=e.references[n];e.references[n]=r,l(n=u[n][1])&&n(r,i),l(t)&&t()}var e={references:[]},u=[];return{registerStateKey:function(t,r){var e=u.length;return u.push([t,r]),n(e,t)},reset:function(){var t=e.references;e.references=[],u.forEach((function(r,e){return n(e,r[0],t[e])}))}}}function V(t,n){var r=n.suiteId;return n=n.suiteName,{optionalFields:t.registerStateKey((function(){return{}})),suiteId:t.registerStateKey(r),suiteName:t.registerStateKey(n),testCallbacks:t.registerStateKey((function(){return{fieldCallbacks:{},doneCallbacks:[]}})),testObjects:t.registerStateKey((function(t){return{prev:t?t.current:[],current:[]}}))}}function Y(t){return null==t}function J(t){setTimeout((function(){throw Error(t)}),0)}function z(t,n){t=void 0===(t=t.type)?N.DEFAULT:t,q(l(n));var r=S(t,Z());return t=T.run({isolate:r},(function(){return r.keys.prev=function(){var t=O().testObjects()[0].prev;return[].concat(g(t,Z())).reduce((function(t,n){return n instanceof W&&!Y(n.key)?(t[n.key]=n,t):t}),{})}(),k((function(t){var n=r.path;return g(t,n)[v(n)]=[],t})),n()})),Q().cursor.next(),t}function Q(){return T.useX().isolate}function Z(){var t=Q();return t.path.concat(t.cursor.current())}var $,tt=$||($={});tt.WARNINGS="warnings",tt.ERRORS="errors";var nt,rt=nt||(nt={});function et(t){return t===$.ERRORS?nt.ERROR_COUNT:nt.WARN_COUNT}function ut(t){return!t||(Object.prototype.hasOwnProperty.call(t,"length")?s(t.length,0):"object"==typeof t&&s((t=Object.keys(t)).length,0))}rt.ERROR_COUNT="errorCount",rt.WARN_COUNT="warnCount";var it=u(ut);function ot(t,n){return!(!n||t.fieldName!==n)}var st=u((function(t,n){return t.groupName===n}));function at(t,n){return U().some((function(r){return ct(r,t,n)}))}function ct(t,n,r){return(r=!t.hasFailures()||r&&!ot(t,r))||(t=t.warns(),r=n===$.WARNINGS!=!!t),!r}function ft(t){return!!lt(t)||!at($.ERRORS,t)&&(!ut(U())&&!function(t){return it(F().filter((function(n){return dt(n,t)})))}(t)&&function(t){return U().every((function(n){return!(!t||ot(n,t))||pt(n,t)}))}(t))}function lt(t){return!!t&&!0===(null===(n=C(t))||void 0===n?void 0:n[1]);var n}function dt(t,n){return!(n&&!ot(t,n))&&!0!==I(t.fieldName)}function pt(t,n){return!(!n||ot(t,n))||(!0===I(t.fieldName)||t.isTested()||t.isOmitted())}function vt(){var t=T.useX().summary;return q(t),t}function ht(){var t=U(),n=i({errorCount:0,warnCount:0,testCount:0},{groups:{},tests:{},valid:!1});return t.reduce((function(t,n){var r=t.tests;r[n.fieldName]=Et(r,n),r[n.fieldName].valid=!1!==r[n.fieldName].valid&&ft(n.fieldName);var e=t.groups,u=n.groupName;return u&&(e[u]=e[u]||{},e[u][n.fieldName]=Et(e[u],n),r=e[u][n.fieldName],!1===e[u][n.fieldName].valid?n=!1:n=!!lt(n=n.fieldName)||!function(t,n,r){return U().some((function(e){return!st(e,n)&&ct(e,t,r)}))}($.ERRORS,u,n)&&!function(t,n){return it(F().filter((function(r){return!st(r,t)&&dt(r,n)})))}(u,n)&&function(t,n){return U().every((function(r){return!!st(r,t)||pt(r,n)}))}(u,n),r.valid=n),t}),n),n.valid=ft(),function(t){for(var n in t.tests)t.errorCount+=t.tests[n].errorCount,t.warnCount+=t.tests[n].warnCount,t.testCount+=t.tests[n].testCount;return t}(n)}function Et(t,n){function r(t){var n=et(t);o[n]++,u&&(o[t]=(o[t]||[]).concat(u))}var e=n.fieldName,u=n.message;t[e]=t[e]||i({errorCount:0,warnCount:0,testCount:0},{errors:[],warnings:[]});var o=t[e];return n.isNonActionable()||(t[e].testCount++,n.isFailing()?r($.ERRORS):n.isWarning()&&r($.WARNINGS)),o}function gt(t,n,r){var e;return(null===(e=null==t?void 0:t[r])||void 0===e?void 0:e[n])||[]}function Nt(t,n){var r,e={},u=et(n);for(r in t)a(t[r][u],0)&&(e[r]=t[r][n]||[]);return e}function mt(t){return Rt($.ERRORS,t)}function yt(t){return Rt($.WARNINGS,t)}function Rt(t,n){var r=vt().tests;return n?gt(r,t,n):Nt(r,t)}function bt(t,n){return Tt(t,$.ERRORS,n)}function St(t,n){return Tt(t,$.WARNINGS,n)}function Tt(t,n,r){return t=vt().groups[t],r?gt(t,n,r):Nt(t,n)}function Ot(t){return At(nt.ERROR_COUNT,t)}function Ct(t){return At(nt.WARN_COUNT,t)}function At(t,n){var r,e=vt();return a(n?null===(r=e.tests[n])||void 0===r?void 0:r[t]:e[t],0)}function It(t,n){return kt($.ERRORS,t,n)}function _t(t,n){return kt($.WARNINGS,t,n)}function kt(t,n,r){var e,u,i=vt();if(t=et(t),!(n=i.groups[n]))return!1;if(r)return a(null===(e=n[r])||void 0===e?void 0:e[t],0);for(var o in n)if(a(null===(u=n[o])||void 0===u?void 0:u[t],0))return!0;return!1}function Ft(t){var n=vt();return t?!!Ut(n.tests,t):n.valid}function Lt(t,n){if(!(t=vt().groups[t]))return!1;if(n)return Ut(t,n);for(var r in t)if(!Ut(t,r))return!1;return!0}function Ut(t,n){var r;return!(null===(r=t[n])||void 0===r||!r.valid)}var Gt=c(1);function Pt(){var t=U(),n={stateRef:O()};return Gt([t],T.bind(n,(function(){var t=ht(),n=O().suiteName()[0],r={summary:t};return i(t,{getErrors:T.bind(r,mt),getErrorsByGroup:T.bind(r,bt),getWarnings:T.bind(r,yt),getWarningsByGroup:T.bind(r,St),hasErrors:T.bind(r,Ot),hasErrorsByGroup:T.bind(r,It),hasWarnings:T.bind(r,Ct),hasWarningsByGroup:T.bind(r,_t),isValid:T.bind(r,Ft),isValidByGroup:T.bind(r,Lt),suiteName:n})})))}function Wt(t){var n=F();return!ut(n)&&(t?n.some((function(n){return ot(n,t)})):it(n))}var wt=c(20);function Dt(){var t=U(),n={stateRef:O()};return wt([t],T.bind(n,(function(){return i({},Pt(),{done:T.bind(n,jt)})})))}function xt(t,n,r){return!(l(t)&&(!n||r.tests[n]&&!ut(r.tests[n].testCount)))}function Xt(t){return!(Wt()&&(!t||Wt(t)))}function jt(){function t(){return e(Pt())}for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var e=(n=n.reverse())[0];return n=n[1],r=Dt(),xt(e,n,r)?r:Xt(n)?(t(),r):(Ht(t,n),r)}function Ht(t,n){(0,O().testCallbacks()[1])((function(r){return n?r.fieldCallbacks[n]=(r.fieldCallbacks[n]||[]).concat(t):r.doneCallbacks.push(t),r}))}function Kt(t){return t.forEach((function(t){return t()}))}function Mt(){var t=function(){var t={};return{emit:function(n,r){(t[n]||[]).forEach((function(t){t(r)}))},on:function(n,r){return t[n]=(t[n]||[]).concat(r),{off:function(){t[n]=(t[n]||[]).filter((function(t){return t!==r}))}}}}}();return t.on(Bt.TEST_COMPLETED,(function(n){if(!n.isCanceled()){n.done(),n=n.fieldName;var r=O().testCallbacks()[0].fieldCallbacks;n&&!Wt(n)&&Array.isArray(r[n])&&Kt(r[n]),Wt()||t.emit(Bt.ALL_RUNNING_TESTS_FINISHED)}})),t.on(Bt.SUITE_CALLBACK_DONE_RUNNING,(function(){!function(){function t(t){n[t.fieldName]&&(t.omit(),A(t.fieldName,(function(t){return[t[0],!0]})))}if(!ut(O().optionalFields()[0])){var n={};k((function(r){return h(r,(function(r){if(Object.prototype.hasOwnProperty.call(n,r.fieldName))t(r);else{var e=I(r.fieldName);l(e)&&(n[r.fieldName]=e(),t(r))}return r}))}))}}()})),t.on(Bt.ALL_RUNNING_TESTS_FINISHED,(function(){Kt(O().testCallbacks()[0].doneCallbacks)})),t.on(Bt.REMOVE_FIELD,(function(t){U().forEach((function(n){ot(n,t)&&(n.cancel(),function(t){k((function(n){return h(n,(function(n){return t!==n?n:null}))}))}(n))}))})),t.on(Bt.RESET_FIELD,(function(t){U().forEach((function(n){ot(n,t)&&n.reset()}))})),t}function qt(){var t=T.useX();return q(t.bus),t.bus}var Bt,Vt=Bt||(Bt={});function Yt(t){return zt(0,"tests",t)}function Jt(t){return zt(1,"tests",t)}function zt(t,n,r){var u=T.useX("hook called outside of a running suite.");r&&[].concat(r).forEach((function(r){e(r)&&(u.exclusion[n][r]=0===t)}))}function Qt(t){for(var n in t)if(!0===t[n])return!0;return!1}function Zt(){var t,n=T.useX().exclusion;for(t in n.groups)if(n.groups[t])return!0;return!1}function $t(t){return"Wrong arguments passed to group. Group ".concat(t,".")}function tn(t,n,r){if(r||2===arguments.length)for(var e,u=0,i=n.length;u<i;u++)!e&&u in n||(e||(e=Array.prototype.slice.call(n,0,u)),e[u]=n[u]);return t.concat(e||Array.prototype.slice.call(n))}function nn(t){var n=t.asyncTest,r=t.message;if(n&&l(n.then)){var u=qt().emit,i=O(),o=T.bind({stateRef:i},(function(){_(),u(Bt.TEST_COMPLETED,t)}));i=T.bind({stateRef:i},(function(n){t.isCanceled()||(t.message=e(n)?n:r,t.fail(),o())}));try{n.then(o,i)}catch(t){i()}}}function rn(t){var n=O().testObjects()[0].prev;if(ut(n))return en(t),t;var r=Z();if(n=g(n,r)[v(r)],!Y(t.key)){n=t.key,(r=Q().keys.prev[n])&&(t=r),r=t;var e=Q().keys.current;return Y(e[n])?e[n]=r:J('Encountered the same test key "'.concat(n,"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted.")),en(t),t}return!it(r=n)||r.fieldName===t.fieldName&&r.groupName===t.groupName||(Q().type===N.EACH||J("Vest Critical Error: Tests called in different order than previous run.\n expected: ".concat(n.fieldName,"\n received: ").concat(t.fieldName,'\n This can happen on one of two reasons:\n 1. You\'re using if/else statements to conditionally select tests. Instead, use "skipWhen".\n 2. You are iterating over a list of tests, and their order changed. Use "each" and a custom key prop so that Vest retains their state.')),function(){var t=Q().cursor.current();k((function(n){return n.splice(t),n}))}(),n=null),en(t=p(n,t)),t}function en(t){var n=Z();k((function(r){return g(r,n)[v(n)]=t,r}))}function un(t){var n=Q().cursor,r=y.EAGER;if(T.useX().mode[0]===r&&at($.ERRORS,t.fieldName))return t.skip(),rn(t),n.next(),t;if(r=rn(t),T.useX().omitted)return r.omit(),n.next(),r;if(function(t){var n=t.fieldName;if(t=t.groupName,T.useX().skipped)return!0;var r=T.useX(),e=r.exclusion;r=r.inclusion;var u=e.tests,i=u[n];if(!1===i)return!0;if(i=!0===i,t){var o=T.useX().exclusion.groups;if(o=Object.prototype.hasOwnProperty.call(o,t)?!1===o[t]:Zt())return!0;if(!0===e.groups[t])return!(i||!Qt(u)&&!1!==u[n])}return!!(t=!!Zt()&&!t)||!i&&!!Qt(u)&&!d(r[n])}(t))return r.skip(!!T.useX().skipped),n.next(),r;if(t!==r&&r.fieldName===t.fieldName&&r.groupName===t.groupName&&r.isPending()&&r.cancel(),en(t),t.isUntested()){r=qt();var e=function(t){return T.run({currentTest:t},(function(){return t.run()}))}(t);try{e&&l(e.then)?(t.asyncTest=e,t.setPending(),nn(t)):r.emit(Bt.TEST_COMPLETED,t)}catch(n){throw Error("Unexpected error encountered during test registration.\n Test Object: ".concat(JSON.stringify(t),".\n Error: ").concat(n,"."))}}else(r=t.asyncTest)&&l(r.then)&&(t.setPending(),nn(t));return n.next(),t}function on(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var u=l(n[1])?n:tn([void 0],n,!0);n=u[0],r=u[1],u=u[2],q(e(t),an("fieldName","string")),q(l(r),an("Test callback","function"));var i=T.useX();return un(n=new W(t,r,{message:n,groupName:i.groupName,key:u}))}Vt.TEST_COMPLETED="test_completed",Vt.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",Vt.REMOVE_FIELD="remove_field",Vt.RESET_FIELD="reset_field",Vt.SUITE_CALLBACK_DONE_RUNNING="suite_callback_done_running",Yt.group=function(t){return zt(0,"groups",t)},Jt.group=function(t){return zt(1,"groups",t)};var sn=i(on,{memo:function(t){var n=c(10);return function(r){for(var e=[],u=1;u<arguments.length;u++)e[u-1]=arguments[u];u=Q().cursor.current();var i=(e=e.reverse())[0],o=e[1],s=e[2];return u=[O().suiteId()[0],r,u].concat(i),null===(e=n.get(u))?n(u,(function(){return t(r,s,o)})):e[1].isCanceled()?(n.invalidate(u),n(u,(function(){return t(r,s,o)}))):un(e[1])}}(on)});function an(t,n){return"Incompatible params passed to test function. ".concat(t," must be a ").concat(n)}var cn="4.4.2";function fn(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=(t=t.reverse())[0];t=t[1],q(l(e),"vest.create: Expected callback to be a function.");var u=Mt(),o=B();return t={stateRef:V(o,{suiteId:r(),suiteName:t}),bus:u},i(T.bind(t,(function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return o.reset(),z({type:N.SUITE},(function(){e.apply(void 0,t)})),u.emit(Bt.SUITE_CALLBACK_DONE_RUNNING),Dt()})),{get:T.bind(t,Pt),remove:T.bind(t,(function(t){u.emit(Bt.REMOVE_FIELD,t)})),reset:o.reset,resetField:T.bind(t,(function(t){u.emit(Bt.RESET_FIELD,t)}))})}function ln(t,n){q(l(n),"each callback must be a function"),z({type:N.EACH},(function(){t.forEach((function(t,r){n(t,r)}))}))}function dn(){var t=y.EAGER;T.useX().mode[0]=t}function pn(t,n){q(e(t),$t("name must be a string")),q(l(n),$t("callback must be a function")),z({type:N.GROUP},(function(){T.run({groupName:t},n)}))}function vn(t){var n=T.useX(),r=n.inclusion;return n=n.exclusion,q(e(t)),r[t]=p(n.tests[t],!0),{when:function(n){var r=T.useX(),u=r.exclusion;r.inclusion[t]=function(){return Object.prototype.hasOwnProperty.call(u.tests,t)?p(u.tests[t],!0):e(n)?!!u.tests[n]:d(n,d(Pt))}}}}function hn(t,n){z({type:N.OMIT_WHEN},(function(){T.run({omitted:!!T.useX().omitted||d(t,d(Pt))},(function(){return n()}))}))}function En(t){if(Array.isArray(t)||e(t))[].concat(t).forEach((function(t){A(t,[!0,!1])}));else for(var n in t)A(n,[t[n],!1])}function gn(t,n){z({type:N.SKIP_WHEN},(function(){T.run({skipped:!!T.useX().skipped||d(t,d(Pt))},(function(){return n()}))}))}function Nn(){var t=T.useX("warn hook called outside of a running suite.");q(t.currentTest,"warn called outside of a test."),t.currentTest.warn()}export{cn as VERSION,T as context,fn as create,ln as each,dn as eager,pn as group,vn as include,hn as omitWhen,Yt as only,En as optional,Jt as skip,gn as skipWhen,sn as test,Nn as warn};
|
|
1
|
+
import{createContext as t}from"context";import{isUndefined as n,isStringValue as e,assign as r,cache as i,optionalFunctionValue as u,nestedArray as o,asArray as s,seq as a,isFunction as c,isNullish as f,deferThrow as l,invariant as d,bindNot as p,either as v,isEmpty as E,isNotEmpty as N,isPositive as h,numberEquals as g,hasOwnProperty as m,isArray as y,callEach as R,bus as S,defaultTo as C,isPromise as T,isNull as _}from"vest-utils";export{enforce}from"n4s";var O,I=O||(O={});I[I.DEFAULT=0]="DEFAULT",I[I.SUITE=1]="SUITE",I[I.EACH=2]="EACH",I[I.SKIP_WHEN=3]="SKIP_WHEN",I[I.OMIT_WHEN=4]="OMIT_WHEN",I[I.GROUP=5]="GROUP";var A,b=A||(A={});function k(){var t=0;return{current:function(){return t},next:function(){t++}}}function L(t,n){return void 0===n&&(n=[]),{cursor:k(),keys:{current:{},prev:{}},path:n,type:t}}b[b.ALL=0]="ALL",b[b.EAGER=1]="EAGER";var U=t((function(t,n){return n?null:r({exclusion:{tests:{},groups:{}},inclusion:{},isolate:L(O.DEFAULT),mode:[A.ALL]},t)}));function F(){return U.useX().stateRef}function W(t){return F().optionalFields()[0][t]}function G(t,n){(0,F().optionalFields()[1])((function(e){var i;return r(e,((i={})[t]=u(n,e[t]),i))}))}function P(t){var n;return null===(n=W(t))||void 0===n?void 0:n[0]}function D(){x((function(t){return t}))}function x(t){(0,F().testObjects()[1])((function(n){return{prev:n.prev,current:s(t(n.current))}}))}function w(){return H().filter((function(t){return t.isPending()}))}var X=i();function H(){var t=F().testObjects()[0].current;return X([t],(function(){return o.flatten(t)}))}var K,M=K||(K={});M.Error="error",M.Warning="warning";var q=function(){function t(t,n,e){var r=void 0===e?{}:e;e=r.message;var i=r.groupName;r=r.key,this.key=null,this.id=a(),this.severity=K.Error,this.status=B,this.fieldName=t,this.testFn=n,i&&(this.groupName=i),e&&(this.message=e),r&&(this.key=r)}return t.prototype.run=function(){try{var t=this.testFn()}catch(r){t=r,n(this.message)&&e(t)&&(this.message=r),t=!1}return!1===t&&this.fail(),t},t.prototype.setStatus=function(t){this.isFinalStatus()&&t!==Z||(this.status=t)},t.prototype.warns=function(){return this.severity===K.Warning},t.prototype.setPending=function(){this.setStatus(z)},t.prototype.fail=function(){this.setStatus(this.warns()?Y:j)},t.prototype.done=function(){this.isFinalStatus()||this.setStatus(J)},t.prototype.warn=function(){this.severity=K.Warning},t.prototype.isFinalStatus=function(){return this.hasFailures()||this.isCanceled()||this.isPassing()},t.prototype.skip=function(t){this.isPending()&&!t||this.setStatus(V)},t.prototype.cancel=function(){this.setStatus(Q),D()},t.prototype.reset=function(){this.status=B,D()},t.prototype.omit=function(){this.setStatus(Z)},t.prototype.valueOf=function(){return!this.isFailing()},t.prototype.hasFailures=function(){return this.isFailing()||this.isWarning()},t.prototype.isNonActionable=function(){return this.isSkipped()||this.isOmitted()||this.isCanceled()},t.prototype.isPending=function(){return this.statusEquals(z)},t.prototype.isTested=function(){return this.hasFailures()||this.isPassing()},t.prototype.isOmitted=function(){return this.statusEquals(Z)},t.prototype.isUntested=function(){return this.statusEquals(B)},t.prototype.isFailing=function(){return this.statusEquals(j)},t.prototype.isCanceled=function(){return this.statusEquals(Q)},t.prototype.isSkipped=function(){return this.statusEquals(V)},t.prototype.isPassing=function(){return this.statusEquals(J)},t.prototype.isWarning=function(){return this.statusEquals(Y)},t.prototype.statusEquals=function(t){return this.status===t},t}(),B="UNTESTED",V="SKIPPED",j="FAILED",Y="WARNING",J="PASSING",z="PENDING",Q="CANCELED",Z="OMITTED";function $(t){function n(t,n,i){return r.references.push(),e(t,u(n,i)),function(){return[r.references[t],function(n){return e(t,u(n,r.references[t]))}]}}function e(n,e){var u=r.references[n];r.references[n]=e,n=i[n][1],c(n)&&n(e,u),c(t)&&t()}var r={references:[]},i=[];return{registerStateKey:function(t,e){var r=i.length;return i.push([t,e]),n(r,t)},reset:function(){var t=r.references;r.references=[],i.forEach((function(e,r){return n(r,e[0],t[r])}))}}}function tt(t,n){var e=n.suiteId;return n=n.suiteName,{optionalFields:t.registerStateKey((function(){return{}})),suiteId:t.registerStateKey(e),suiteName:t.registerStateKey(n),testCallbacks:t.registerStateKey((function(){return{fieldCallbacks:{},doneCallbacks:[]}})),testObjects:t.registerStateKey((function(t){return{prev:t?t.current:[],current:[]}}))}}function nt(){return U.useX().isolate}function et(){var t=nt();return t.path.concat(t.cursor.current())}function rt(t,n){t=void 0===(t=t.type)?O.DEFAULT:t,d(c(n));var e=L(t,et());return t=U.run({isolate:e},(function(){return e.keys.prev=function(){var t=F().testObjects()[0].prev;return s(o.getCurrent(t,et())).reduce((function(t,n){return n instanceof q&&!f(n.key)?(t[n.key]=n,t):t}),{})}(),x((function(t){return o.setValueAtPath(t,e.path,[])})),n()})),nt().cursor.next(),t}var it,ut=it||(it={});ut.WARNINGS="warnings",ut.ERRORS="errors";var ot,st=ot||(ot={});function at(t,n){return!(!n||t.fieldName!==n)}st.ERROR_COUNT="errorCount",st.WARN_COUNT="warnCount";var ct=p((function(t,n){return t.groupName===n}));function ft(t,n){return H().some((function(e){return lt(e,t,n)}))}function lt(t,n,e){return!(!t.hasFailures()||e&&!at(t,e)||v(n===it.WARNINGS,t.warns()))}function dt(t){if(pt(t))return!0;if(ft(it.ERRORS,t))return!1;var n=H();return!E(n)&&!function(t){return N(w().filter((function(n){return vt(n,t)})))}(t)&&function(t){return H().every((function(n){return!(!t||at(n,t))||Et(n,t)}))}(t)}function pt(t){return!!t&&!0===(null===(n=W(t))||void 0===n?void 0:n[1]);var n}function vt(t,n){return!(n&&!at(t,n))&&!0!==P(t.fieldName)}function Et(t,n){return!(!n||at(t,n))||(!0===P(t.fieldName)||t.isTested()||t.isOmitted())}function Nt(){var t=H(),n=r({errorCount:0,warnCount:0,testCount:0},{groups:{},tests:{},valid:!1});return t.reduce((function(t,n){var e=t.tests;e[n.fieldName]=ht(e,n),e[n.fieldName].valid=!1!==e[n.fieldName].valid&&dt(n.fieldName);var r=t.groups,i=n.groupName;return i&&(r[i]=r[i]||{},r[i][n.fieldName]=ht(r[i],n),e=r[i][n.fieldName],!1===r[i][n.fieldName].valid?n=!1:n=!!pt(n=n.fieldName)||!function(t,n,e){return H().some((function(r){return!ct(r,n)&<(r,t,e)}))}(it.ERRORS,i,n)&&!function(t,n){return N(w().filter((function(e){return!ct(e,t)&&vt(e,n)})))}(i,n)&&function(t,n){return H().every((function(e){return!!ct(e,t)||Et(e,n)}))}(i,n),e.valid=n),t}),n),n.valid=dt(),function(t){for(var n in t.tests)t.errorCount+=t.tests[n].errorCount,t.warnCount+=t.tests[n].warnCount,t.testCount+=t.tests[n].testCount;return t}(n)}function ht(t,n){function e(t){o[t===it.ERRORS?ot.ERROR_COUNT:ot.WARN_COUNT]++,u&&(o[t]=(o[t]||[]).concat(u))}var i=n.fieldName,u=n.message;t[i]=t[i]||r({errorCount:0,warnCount:0,testCount:0},{errors:[],warnings:[]});var o=t[i];return n.isNonActionable()||(t[i].testCount++,n.isFailing()?e(it.ERRORS):n.isWarning()&&e(it.WARNINGS)),o}function gt(t,n,e){if(e){var r;t=(null===(r=null==t?void 0:t[e])||void 0===r?void 0:r[n])||[]}else{for(var i in r={},e=n===it.ERRORS?ot.ERROR_COUNT:ot.WARN_COUNT,t)h(t[i][e])&&(r[i]=t[i][n]||[]);t=r}return t}function mt(t){return{getErrors:function(n){return gt(t.tests,it.ERRORS,n)},getErrorsByGroup:function(n,e){return gt(t.groups[n],it.ERRORS,e)},getWarnings:function(n){return gt(t.tests,it.WARNINGS,n)},getWarningsByGroup:function(n,e){return gt(t.groups[n],it.WARNINGS,e)},hasErrors:function(n){return St(t,ot.ERROR_COUNT,n)},hasErrorsByGroup:function(n,e){return Rt(t,ot.ERROR_COUNT,n,e)},hasWarnings:function(n){return St(t,ot.WARN_COUNT,n)},hasWarningsByGroup:function(n,e){return Rt(t,ot.WARN_COUNT,n,e)},isValid:function(n){var e;return n?!(null===(e=t.tests[n])||void 0===e||!e.valid):t.valid},isValidByGroup:function(n,e){if(!(n=t.groups[n]))return!1;if(e)return yt(n,e);for(var r in n)if(!yt(n,r))return!1;return!0}}}function yt(t,n){var e;return!(null===(e=t[n])||void 0===e||!e.valid)}function Rt(t,n,e,r){var i,u;if(!(t=t.groups[e]))return!1;if(r)return h(null===(i=t[r])||void 0===i?void 0:i[n]);for(var o in t)if(h(null===(u=t[o])||void 0===u?void 0:u[n]))return!0;return!1}function St(t,n,e){var r;return t=e?null===(r=t.tests[e])||void 0===r?void 0:r[n]:t[n]||0,h(t)}var Ct=i(1);function Tt(){var t=H(),n={stateRef:F()};return Ct([t],U.bind(n,(function(){var t=Nt(),n=F().suiteName()[0];return r(t,mt(t),{suiteName:n})})))}function _t(t){var n=w();return!E(n)&&(!t||n.some((function(n){return at(n,t)})))}var Ot=i(20);function It(){var t=H(),n={stateRef:F()};return Ot([t],U.bind(n,(function(){return r({},Tt(),{done:U.bind(n,kt)})})))}function At(t,n,e){var r;return!!(!c(t)||n&&g(null===(r=e.tests[n])||void 0===r?void 0:r.testCount,0))}function bt(t){return!(_t()&&(!t||_t(t)))}function kt(){function t(){return r(Tt())}for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var r=(n=n.reverse())[0];return n=n[1],e=It(),At(r,n,e)?e:bt(n)?(t(),e):(Lt(t,n),e)}function Lt(t,n){(0,F().testCallbacks()[1])((function(e){return n?e.fieldCallbacks[n]=(e.fieldCallbacks[n]||[]).concat(t):e.doneCallbacks.push(t),e}))}function Ut(){var t=S.createBus();return t.on(Wt.TEST_COMPLETED,(function(n){if(!n.isCanceled()){n.done(),n=n.fieldName;var e=F().testCallbacks()[0].fieldCallbacks;n&&!_t(n)&&y(e[n])&&R(e[n]),_t()||t.emit(Wt.ALL_RUNNING_TESTS_FINISHED)}})),t.on(Wt.SUITE_CALLBACK_DONE_RUNNING,(function(){!function(){function t(t){e[t.fieldName]&&(t.omit(),G(t.fieldName,(function(t){return[t[0],!0]})))}var n=F().optionalFields()[0];if(!E(n)){var e={};x((function(n){return o.transform(n,(function(n){if(m(e,n.fieldName))t(n);else{var r=P(n.fieldName);c(r)&&(e[n.fieldName]=r(),t(n))}return n}))}))}}()})),t.on(Wt.ALL_RUNNING_TESTS_FINISHED,(function(){var t=F().testCallbacks()[0].doneCallbacks;R(t)})),t.on(Wt.REMOVE_FIELD,(function(t){H().forEach((function(n){at(n,t)&&(n.cancel(),function(t){x((function(n){return o.transform(n,(function(n){return t!==n?n:null}))}))}(n))}))})),t.on(Wt.RESET_FIELD,(function(t){H().forEach((function(n){at(n,t)&&n.reset()}))})),t}function Ft(){var t=U.useX();return d(t.bus),t.bus}var Wt,Gt=Wt||(Wt={});function Pt(t){return xt(0,"tests",t)}function Dt(t){return xt(1,"tests",t)}function xt(t,n,r){var i=U.useX("hook called outside of a running suite.");r&&s(r).forEach((function(r){e(r)&&(i.exclusion[n][r]=0===t)}))}function wt(t){for(var n in t)if(!0===t[n])return!0;return!1}function Xt(){var t,n=U.useX().exclusion;for(t in n.groups)if(n.groups[t])return!0;return!1}function Ht(t){return"Wrong arguments passed to group. Group ".concat(t,".")}function Kt(t,n,e){if(e||2===arguments.length)for(var r,i=0,u=n.length;i<u;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))}function Mt(t){var n=t.asyncTest,r=t.message;if(T(n)){var i=Ft().emit,u=F(),o=U.bind({stateRef:u},(function(){D(),i(Wt.TEST_COMPLETED,t)}));u=U.bind({stateRef:u},(function(n){t.isCanceled()||(t.message=e(n)?n:r,t.fail(),o())}));try{n.then(o,u)}catch(t){u()}}}function qt(t){var n=F().testObjects()[0].prev;if(E(n))return Bt(t),t;var e=et();if(n=o.valueAtPath(n,e),!f(t.key)){n=t.key,(e=nt().keys.prev[n])&&(t=e),e=t;var r=nt().keys.current;return f(r[n])?r[n]=e:l('Encountered the same test key "'.concat(n,"\" twice. This may lead to tests overriding each other's results, or to tests being unexpectedly omitted.")),Bt(t),t}return!N(e=n)||e.fieldName===t.fieldName&&e.groupName===t.groupName||(nt().type===O.EACH||l("Vest Critical Error: Tests called in different order than previous run.\n expected: ".concat(n.fieldName,"\n received: ").concat(t.fieldName,'\n This can happen on one of two reasons:\n 1. You\'re using if/else statements to conditionally select tests. Instead, use "skipWhen".\n 2. You are iterating over a list of tests, and their order changed. Use "each" and a custom key prop so that Vest retains their state.')),function(){var t=nt().cursor.current();x((function(n){return n.splice(t),n}))}(),n=null),Bt(t=C(n,t)),t}function Bt(t){var n=et();x((function(e){return o.setValueAtPath(e,n,t)}))}function Vt(t){var n=nt().cursor,e=A.EAGER;if(U.useX().mode[0]===e&&ft(it.ERRORS,t.fieldName))return t.skip(),qt(t),n.next(),t;if(e=qt(t),U.useX().omitted)return e.omit(),n.next(),e;if(function(t){var n=t.fieldName;if(t=t.groupName,U.useX().skipped)return!0;var e=U.useX(),r=e.exclusion;e=e.inclusion;var i=r.tests,o=i[n];if(!1===o)return!0;if(o=!0===o,t){var s=U.useX().exclusion.groups;if(s=m(s,t)?!1===s[t]:Xt())return!0;if(!0===r.groups[t])return!(o||!wt(i)&&!1!==i[n])}return!!(t=!!Xt()&&!t)||!o&&!!wt(i)&&!u(e[n])}(t))return e.skip(!!U.useX().skipped),n.next(),e;if(t!==e&&e.fieldName===t.fieldName&&e.groupName===t.groupName&&e.isPending()&&e.cancel(),Bt(t),t.isUntested()){e=Ft();var r=function(t){return U.run({currentTest:t},(function(){return t.run()}))}(t);try{T(r)?(t.asyncTest=r,t.setPending(),Mt(t)):e.emit(Wt.TEST_COMPLETED,t)}catch(n){throw Error("Unexpected error encountered during test registration.\n Test Object: ".concat(JSON.stringify(t),".\n Error: ").concat(n,"."))}}else T(t.asyncTest)&&(t.setPending(),Mt(t));return n.next(),t}function jt(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=c(n[1])?n:Kt([void 0],n,!0);n=i[0],r=i[1],i=i[2],d(e(t),Qt("fieldName","string")),d(c(r),Qt("Test callback","function"));var u=U.useX();return Vt(n=new q(t,r,{message:n,groupName:u.groupName,key:i}))}Gt.TEST_COMPLETED="test_completed",Gt.ALL_RUNNING_TESTS_FINISHED="all_running_tests_finished",Gt.REMOVE_FIELD="remove_field",Gt.RESET_FIELD="reset_field",Gt.SUITE_CALLBACK_DONE_RUNNING="suite_callback_done_running",Pt.group=function(t){return xt(0,"groups",t)},Dt.group=function(t){return xt(1,"groups",t)},p(e);var Yt,Jt,zt=r(jt,{memo:(Yt=jt,Jt=i(10),function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];e=nt().cursor.current();var r=(n=n.reverse())[0],i=n[1],u=n[2];return e=[F().suiteId()[0],t,e].concat(r),n=Jt.get(e),_(n)?Jt(e,(function(){return Yt(t,u,i)})):n[1].isCanceled()?(Jt.invalidate(e),Jt(e,(function(){return Yt(t,u,i)}))):Vt(n[1])})});function Qt(t,n){return"Incompatible params passed to test function. ".concat(t," must be a ").concat(n)}var Zt="4.5.0";function $t(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=(t=t.reverse())[0];t=t[1],d(c(e),"vest.create: Expected callback to be a function.");var i=Ut(),u=$();return t={stateRef:tt(u,{suiteId:a(),suiteName:t}),bus:i},r(U.bind(t,(function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return u.reset(),rt({type:O.SUITE},(function(){e.apply(void 0,t)})),i.emit(Wt.SUITE_CALLBACK_DONE_RUNNING),It()})),{get:U.bind(t,Tt),remove:U.bind(t,(function(t){i.emit(Wt.REMOVE_FIELD,t)})),reset:u.reset,resetField:U.bind(t,(function(t){i.emit(Wt.RESET_FIELD,t)}))})}function tn(t,n){d(c(n),"each callback must be a function"),rt({type:O.EACH},(function(){t.forEach((function(t,e){n(t,e)}))}))}function nn(){var t=A.EAGER;U.useX().mode[0]=t}function en(t,n){d(e(t),Ht("name must be a string")),d(c(n),Ht("callback must be a function")),rt({type:O.GROUP},(function(){U.run({groupName:t},n)}))}function rn(t){var n=U.useX(),r=n.inclusion;return n=n.exclusion,d(e(t)),r[t]=C(n.tests[t],!0),{when:function(n){var r=U.useX(),i=r.exclusion;r.inclusion[t]=function(){return m(i.tests,t)?C(i.tests[t],!0):e(n)?!!i.tests[n]:u(n,u(Tt))}}}}function un(t,n){rt({type:O.OMIT_WHEN},(function(){U.run({omitted:!!U.useX().omitted||u(t,u(Tt))},(function(){return n()}))}))}function on(t){if(y(t)||e(t))s(t).forEach((function(t){G(t,[!0,!1])}));else for(var n in t)G(n,[t[n],!1])}function sn(t,n){rt({type:O.SKIP_WHEN},(function(){U.run({skipped:!!U.useX().skipped||u(t,u(Tt))},(function(){return n()}))}))}function an(){var t=U.useX("warn hook called outside of a running suite.");d(t.currentTest,"warn called outside of a test."),t.currentTest.warn()}export{Zt as VERSION,U as context,$t as create,tn as each,nn as eager,en as group,rn as include,un as omitWhen,Pt as only,on as optional,Dt as skip,sn as skipWhen,mt as suiteSelectors,zt as test,an as warn};
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.classnames = factory());
|
|
5
|
-
}(this, (function () { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vest')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['vest'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.classnames = factory(global.vest));
|
|
5
|
+
}(this, (function (vest) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function isNumeric(value) {
|
|
8
|
+
var str = String(value);
|
|
9
|
+
var num = Number(value);
|
|
10
|
+
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
11
|
+
return Boolean(result);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function greaterThan(value, gt) {
|
|
15
|
+
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
16
|
+
}
|
|
6
17
|
|
|
7
18
|
function isFunction(value) {
|
|
8
19
|
return typeof value === 'function';
|
|
@@ -16,11 +27,6 @@
|
|
|
16
27
|
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
17
28
|
}
|
|
18
29
|
|
|
19
|
-
function defaultTo(value, defaultValue) {
|
|
20
|
-
var _a;
|
|
21
|
-
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
30
|
/**
|
|
25
31
|
* A safe hasOwnProperty access
|
|
26
32
|
*/
|
|
@@ -42,72 +48,37 @@
|
|
|
42
48
|
: new Error(message ? optionalFunctionValue(message) : message);
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
function isNumeric(value) {
|
|
46
|
-
var str = String(value);
|
|
47
|
-
var num = Number(value);
|
|
48
|
-
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
49
|
-
return Boolean(result);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function greaterThan(value, gt) {
|
|
53
|
-
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
51
|
function isPositive(value) {
|
|
57
52
|
return greaterThan(value, 0);
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})(Severity || (Severity = {}));
|
|
65
|
-
var SeverityCount;
|
|
66
|
-
(function (SeverityCount) {
|
|
67
|
-
SeverityCount["ERROR_COUNT"] = "errorCount";
|
|
68
|
-
SeverityCount["WARN_COUNT"] = "warnCount";
|
|
69
|
-
})(SeverityCount || (SeverityCount = {}));
|
|
70
|
-
|
|
71
|
-
// eslint-disable-next-line max-lines-per-function
|
|
72
|
-
function parse(res) {
|
|
73
|
-
invariant(res && hasOwnProperty(res, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
|
|
55
|
+
// eslint-disable-next-line max-statements
|
|
56
|
+
function parse(summary) {
|
|
57
|
+
invariant(summary && hasOwnProperty(summary, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
|
|
58
|
+
var sel = vest.suiteSelectors(summary);
|
|
74
59
|
var testedStorage = {};
|
|
75
60
|
var selectors = {
|
|
76
|
-
invalid: hasErrors,
|
|
61
|
+
invalid: sel.hasErrors,
|
|
77
62
|
tested: isTested,
|
|
78
63
|
untested: isUntested,
|
|
79
|
-
valid: isValid,
|
|
80
|
-
warning: hasWarnings
|
|
64
|
+
valid: sel.isValid,
|
|
65
|
+
warning: sel.hasWarnings
|
|
81
66
|
};
|
|
82
67
|
return selectors;
|
|
68
|
+
// Booleans
|
|
83
69
|
function isTested(fieldName) {
|
|
84
70
|
if (!fieldName) {
|
|
85
|
-
return isPositive(
|
|
71
|
+
return isPositive(summary.testCount);
|
|
86
72
|
}
|
|
87
73
|
if (hasOwnProperty(testedStorage, fieldName))
|
|
88
74
|
return testedStorage[fieldName];
|
|
89
75
|
testedStorage[fieldName] =
|
|
90
|
-
hasOwnProperty(
|
|
91
|
-
isPositive(
|
|
76
|
+
hasOwnProperty(summary.tests, fieldName) &&
|
|
77
|
+
isPositive(summary.tests[fieldName].testCount);
|
|
92
78
|
return selectors.tested(fieldName);
|
|
93
79
|
}
|
|
94
80
|
function isUntested(fieldName) {
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
function isValid(fieldName) {
|
|
98
|
-
var _a;
|
|
99
|
-
return fieldName ? Boolean((_a = res.tests[fieldName]) === null || _a === void 0 ? void 0 : _a.valid) : res.valid;
|
|
100
|
-
}
|
|
101
|
-
function hasWarnings(fieldName) {
|
|
102
|
-
return hasFailures(SeverityCount.WARN_COUNT, fieldName);
|
|
103
|
-
}
|
|
104
|
-
function hasErrors(fieldName) {
|
|
105
|
-
return hasFailures(SeverityCount.ERROR_COUNT, fieldName);
|
|
106
|
-
}
|
|
107
|
-
function hasFailures(countKey, fieldName) {
|
|
108
|
-
var _a;
|
|
109
|
-
var failureCount = defaultTo(fieldName ? (_a = res.tests[fieldName]) === null || _a === void 0 ? void 0 : _a[countKey] : res[countKey], 0);
|
|
110
|
-
return isPositive(failureCount);
|
|
81
|
+
return !(isPositive(summary.testCount) && selectors.tested(fieldName));
|
|
111
82
|
}
|
|
112
83
|
}
|
|
113
84
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(t,
|
|
1
|
+
"use strict";!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vest")):"function"==typeof define&&define.amd?define(["vest"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).classnames=e(t.vest)}(this,(function(t){function e(t){var e=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(e))}function n(t,n){return e(t)&&e(n)&&Number(t)>Number(n)}function r(e){!function(t,e){if(!t)throw e instanceof String?e.valueOf():Error(e?function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return"function"==typeof t?t.apply(void 0,e):t}(e):e)}(e&&Object.prototype.hasOwnProperty.call(e,"valid"),"Vest parser: expected argument at position 0 to be Vest's result object.");var r=t.suiteSelectors(e),o={},i={invalid:r.hasErrors,tested:function(t){return t?Object.prototype.hasOwnProperty.call(o,t)?o[t]:(o[t]=Object.prototype.hasOwnProperty.call(e.tests,t)&&n(e.tests[t].testCount,0),i.tested(t)):n(e.testCount,0)},untested:function(t){return!(n(e.testCount,0)&&i.tested(t))},valid:r.isValid,warning:r.hasWarnings};return i}return function(t,e){void 0===e&&(e={});var n=r(t);return function(t){var r,o=[];for(r in e){var i=r;"function"==typeof n[i]&&n[i](t)&&o.push(e[i])}return o.join(" ")}}}));
|
|
@@ -4,7 +4,56 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.compose = factory());
|
|
5
5
|
}(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function bindNot(fn) {
|
|
8
|
+
return function () {
|
|
9
|
+
var args = [];
|
|
10
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11
|
+
args[_i] = arguments[_i];
|
|
12
|
+
}
|
|
13
|
+
return !fn.apply(void 0, args);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isNumeric(value) {
|
|
18
|
+
var str = String(value);
|
|
19
|
+
var num = Number(value);
|
|
20
|
+
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
21
|
+
return Boolean(result);
|
|
22
|
+
}
|
|
23
|
+
var isNotNumeric = bindNot(isNumeric);
|
|
24
|
+
|
|
25
|
+
function numberEquals(value, eq) {
|
|
26
|
+
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
27
|
+
}
|
|
28
|
+
var numberNotEquals = bindNot(numberEquals);
|
|
29
|
+
|
|
30
|
+
function lengthEquals(value, arg1) {
|
|
31
|
+
return numberEquals(value.length, arg1);
|
|
32
|
+
}
|
|
33
|
+
var lengthNotEquals = bindNot(lengthEquals);
|
|
34
|
+
|
|
35
|
+
function greaterThan(value, gt) {
|
|
36
|
+
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function longerThan(value, arg1) {
|
|
40
|
+
return greaterThan(value.length, arg1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isNull(value) {
|
|
44
|
+
return value === null;
|
|
45
|
+
}
|
|
46
|
+
var isNotNull = bindNot(isNull);
|
|
47
|
+
|
|
48
|
+
function isUndefined(value) {
|
|
49
|
+
return value === undefined;
|
|
50
|
+
}
|
|
51
|
+
var isNotUndefined = bindNot(isUndefined);
|
|
52
|
+
|
|
53
|
+
function isNullish(value) {
|
|
54
|
+
return isNull(value) || isUndefined(value);
|
|
55
|
+
}
|
|
56
|
+
var isNotNullish = bindNot(isNullish);
|
|
8
57
|
|
|
9
58
|
function isFunction(value) {
|
|
10
59
|
return typeof value === 'function';
|
|
@@ -18,6 +67,28 @@
|
|
|
18
67
|
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
19
68
|
}
|
|
20
69
|
|
|
70
|
+
function defaultTo(value, defaultValue) {
|
|
71
|
+
var _a;
|
|
72
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// The module is named "isArrayValue" since it
|
|
76
|
+
// is conflicting with a nested npm dependency.
|
|
77
|
+
// We may need to revisit this in the future.
|
|
78
|
+
function isArray(value) {
|
|
79
|
+
return Boolean(Array.isArray(value));
|
|
80
|
+
}
|
|
81
|
+
var isNotArray = bindNot(isArray);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A safe hasOwnProperty access
|
|
85
|
+
*/
|
|
86
|
+
function hasOwnProperty(obj, key) {
|
|
87
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var assign = Object.assign;
|
|
91
|
+
|
|
21
92
|
function invariant(condition,
|
|
22
93
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
23
94
|
message) {
|
|
@@ -36,6 +107,14 @@
|
|
|
36
107
|
return new String(optionalFunctionValue(value));
|
|
37
108
|
}
|
|
38
109
|
|
|
110
|
+
function isStringValue(v) {
|
|
111
|
+
return String(v) === v;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function isBoolean(value) {
|
|
115
|
+
return !!value === value;
|
|
116
|
+
}
|
|
117
|
+
|
|
39
118
|
function mapFirst(array, callback) {
|
|
40
119
|
var broke = false;
|
|
41
120
|
var breakoutValue = null;
|
|
@@ -53,33 +132,22 @@
|
|
|
53
132
|
}
|
|
54
133
|
}
|
|
55
134
|
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return value === null;
|
|
68
|
-
}
|
|
69
|
-
var isNotNull = bindNot(isNull);
|
|
70
|
-
|
|
71
|
-
function isUndefined(value) {
|
|
72
|
-
return value === undefined;
|
|
73
|
-
}
|
|
74
|
-
var isNotUndefined = bindNot(isUndefined);
|
|
75
|
-
|
|
76
|
-
function isNullish(value) {
|
|
77
|
-
return isNull(value) || isUndefined(value);
|
|
135
|
+
function isEmpty(value) {
|
|
136
|
+
if (!value) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
else if (hasOwnProperty(value, 'length')) {
|
|
140
|
+
return lengthEquals(value, 0);
|
|
141
|
+
}
|
|
142
|
+
else if (typeof value === 'object') {
|
|
143
|
+
return lengthEquals(Object.keys(value), 0);
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
78
146
|
}
|
|
79
|
-
var
|
|
147
|
+
var isNotEmpty = bindNot(isEmpty);
|
|
80
148
|
|
|
81
|
-
function
|
|
82
|
-
return
|
|
149
|
+
function isPositive(value) {
|
|
150
|
+
return greaterThan(value, 0);
|
|
83
151
|
}
|
|
84
152
|
|
|
85
153
|
function endsWith(value, arg1) {
|
|
@@ -92,35 +160,10 @@
|
|
|
92
160
|
}
|
|
93
161
|
var notEquals = bindNot(equals);
|
|
94
162
|
|
|
95
|
-
function isNumeric(value) {
|
|
96
|
-
var str = String(value);
|
|
97
|
-
var num = Number(value);
|
|
98
|
-
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
99
|
-
return Boolean(result);
|
|
100
|
-
}
|
|
101
|
-
var isNotNumeric = bindNot(isNumeric);
|
|
102
|
-
|
|
103
|
-
function greaterThan(value, gt) {
|
|
104
|
-
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function numberEquals(value, eq) {
|
|
108
|
-
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
109
|
-
}
|
|
110
|
-
var numberNotEquals = bindNot(numberEquals);
|
|
111
|
-
|
|
112
163
|
function greaterThanOrEquals(value, gte) {
|
|
113
164
|
return numberEquals(value, gte) || greaterThan(value, gte);
|
|
114
165
|
}
|
|
115
166
|
|
|
116
|
-
// The module is named "isArrayValue" since it
|
|
117
|
-
// is conflicting with a nested npm dependency.
|
|
118
|
-
// We may need to revisit this in the future.
|
|
119
|
-
function isArray(value) {
|
|
120
|
-
return Boolean(Array.isArray(value));
|
|
121
|
-
}
|
|
122
|
-
var isNotArray = bindNot(isArray);
|
|
123
|
-
|
|
124
167
|
function inside(value, arg1) {
|
|
125
168
|
if (isArray(arg1)) {
|
|
126
169
|
return arg1.indexOf(value) !== -1;
|
|
@@ -151,38 +194,8 @@
|
|
|
151
194
|
}
|
|
152
195
|
var isNotBlank = bindNot(isBlank);
|
|
153
196
|
|
|
154
|
-
function isBoolean(value) {
|
|
155
|
-
return !!value === value;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
197
|
var isNotBoolean = bindNot(isBoolean);
|
|
159
198
|
|
|
160
|
-
/**
|
|
161
|
-
* A safe hasOwnProperty access
|
|
162
|
-
*/
|
|
163
|
-
function hasOwnProperty(obj, key) {
|
|
164
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function lengthEquals(value, arg1) {
|
|
168
|
-
return numberEquals(value.length, arg1);
|
|
169
|
-
}
|
|
170
|
-
var lengthNotEquals = bindNot(lengthEquals);
|
|
171
|
-
|
|
172
|
-
function isEmpty(value) {
|
|
173
|
-
if (!value) {
|
|
174
|
-
return true;
|
|
175
|
-
}
|
|
176
|
-
else if (hasOwnProperty(value, 'length')) {
|
|
177
|
-
return lengthEquals(value, 0);
|
|
178
|
-
}
|
|
179
|
-
else if (typeof value === 'object') {
|
|
180
|
-
return lengthEquals(Object.keys(value), 0);
|
|
181
|
-
}
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
var isNotEmpty = bindNot(isEmpty);
|
|
185
|
-
|
|
186
199
|
/**
|
|
187
200
|
* Validates that a given value is an even number
|
|
188
201
|
*/
|
|
@@ -222,10 +235,6 @@
|
|
|
222
235
|
return false;
|
|
223
236
|
};
|
|
224
237
|
|
|
225
|
-
function isPositive(value) {
|
|
226
|
-
return greaterThan(value, 0);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
238
|
var isNotString = bindNot(isStringValue);
|
|
230
239
|
|
|
231
240
|
function isTruthy(value) {
|
|
@@ -246,10 +255,6 @@
|
|
|
246
255
|
}
|
|
247
256
|
var isNotValueOf = bindNot(isValueOf);
|
|
248
257
|
|
|
249
|
-
function longerThan(value, arg1) {
|
|
250
|
-
return greaterThan(value.length, arg1);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
258
|
function longerThanOrEquals(value, arg1) {
|
|
254
259
|
return greaterThanOrEquals(value.length, arg1);
|
|
255
260
|
}
|
|
@@ -370,11 +375,6 @@
|
|
|
370
375
|
}
|
|
371
376
|
}
|
|
372
377
|
|
|
373
|
-
function defaultTo(value, defaultValue) {
|
|
374
|
-
var _a;
|
|
375
|
-
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
378
|
// eslint-disable-next-line max-lines-per-function
|
|
379
379
|
function createContext(init) {
|
|
380
380
|
var storage = { ancestry: [] };
|
|
@@ -532,30 +532,47 @@
|
|
|
532
532
|
|
|
533
533
|
function enforceEager(value) {
|
|
534
534
|
var target = {};
|
|
535
|
+
// This condition is for when we don't have proxy support (ES5).
|
|
536
|
+
// In this case, we need to manually assign the rules to the target object on runtime.
|
|
537
|
+
// The follow up proxy block is used in case we do have proxy support, and we can assign each rule upon invocation.
|
|
535
538
|
if (!isProxySupported()) {
|
|
539
|
+
// We iterate over each of the rules, and add them to the target object being return by enforce
|
|
536
540
|
eachEnforceRule(function (ruleName, ruleFn) {
|
|
541
|
+
// We then wrap the rule with `genRuleCall` that adds the base enforce behavior
|
|
537
542
|
target[ruleName] = genRuleCall(target, ruleFn, ruleName);
|
|
538
543
|
});
|
|
539
544
|
return target;
|
|
540
545
|
}
|
|
546
|
+
// We create a proxy intercepting access to the target object (which is empty).
|
|
541
547
|
var proxy = new Proxy(target, {
|
|
542
548
|
get: function (_, ruleName) {
|
|
549
|
+
// On property access, we identify if it is a rule or not.
|
|
543
550
|
var rule = getRule(ruleName);
|
|
551
|
+
// If it is a rule, we wrap it with `genRuleCall` that adds the base enforce behavior
|
|
544
552
|
if (rule) {
|
|
545
553
|
return genRuleCall(proxy, rule, ruleName);
|
|
546
554
|
}
|
|
547
555
|
}
|
|
548
556
|
});
|
|
549
557
|
return proxy;
|
|
558
|
+
// This function is used to wrap a rule with the base enforce behavior
|
|
559
|
+
// It takes the target object, the rule function, and the rule name
|
|
560
|
+
// It then returns the rule, in a manner that can be used by enforce
|
|
550
561
|
function genRuleCall(target, rule, ruleName) {
|
|
551
562
|
return function ruleCall() {
|
|
552
563
|
var args = [];
|
|
553
564
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
554
565
|
args[_i] = arguments[_i];
|
|
555
566
|
}
|
|
567
|
+
// Order of operation:
|
|
568
|
+
// 1. Create a context with the value being enforced
|
|
569
|
+
// 2. Call the rule within the context, and pass over the arguments passed to it
|
|
570
|
+
// 3. Transform the result to the correct output format
|
|
556
571
|
var transformedResult = ctx.run({ value: value }, function () {
|
|
557
572
|
return transformResult.apply(void 0, __spreadArray([rule.apply(void 0, __spreadArray([value], args, false)), ruleName, value], args, false));
|
|
558
573
|
});
|
|
574
|
+
// On rule failure (the result is false), we either throw an error
|
|
575
|
+
// or throw a string value if the rule has a message defined in it.
|
|
559
576
|
invariant(transformedResult.pass, isNullish(transformedResult.message)
|
|
560
577
|
? "enforce/".concat(ruleName, " failed with ").concat(JSON.stringify(value))
|
|
561
578
|
: StringObject(transformedResult.message));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).compose=t()}(this,(function(){function n(n){return
|
|
1
|
+
"use strict";!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).compose=t()}(this,(function(){function n(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return!n.apply(void 0,t)}}function t(n){var t=Number(n);return!(isNaN(parseFloat(String(n)))||isNaN(Number(n))||!isFinite(t))}function r(n,r){return t(n)&&t(r)&&Number(n)===Number(r)}function e(n,t){return r(n.length,t)}function u(n,r){return t(n)&&t(r)&&Number(n)>Number(r)}function i(n){return null===n}function o(n){return void 0===n}function s(n){return null===n||o(n)}function f(n){return"function"==typeof n}function a(n){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return f(n)?n.apply(void 0,t):n}function c(n,t){var r;return null!==(r=a(n))&&void 0!==r?r:a(t)}function l(n){return!!Array.isArray(n)}function p(n,t){if(!n)throw t instanceof String?t.valueOf():Error(t?a(t):t)}function v(n){return String(n)===n}function h(n){return!!n===n}function g(n,t){function r(n,t){n&&(e=!0,u=t)}for(var e=!1,u=null,i=0;i<n.length;i++)if(t(n[i],r,i),e)return u}function N(n){return!n||(Object.prototype.hasOwnProperty.call(n,"length")?e(n,0):"object"==typeof n&&e(Object.keys(n),0))}function y(n,t){return v(n)&&v(t)&&n.endsWith(t)}function d(n,t){return n===t}function m(n,t){return r(n,t)||u(n,t)}function b(n,t){return!!(l(t)||v(t)&&v(n))&&-1!==t.indexOf(n)}function O(n,r){return t(n)&&t(r)&&Number(n)<Number(r)}function E(n,t){return r(n,t)||O(n,t)}function x(n,t,r){return m(n,t)&&E(n,r)}function w(n){return s(n)||v(n)&&!n.trim()}function T(n,t){return n in t}function q(n){return Number.isNaN(n)}function S(n){return"number"==typeof n}function j(n){return!!n}function A(n,t){if(s(t))return!1;for(var r in t)if(t[r]===n)return!0;return!1}function B(n,t){return t instanceof RegExp?t.test(n):!!v(t)&&new RegExp(t).test(n)}function P(n,t){return v(n)&&v(t)&&n.startsWith(t)}function W(n){for(var t in an){var r=an[t];f(r)&&n(t,r)}}function k(){return null}function F(n,t,r){if(r||2===arguments.length)for(var e,u=0,i=t.length;u<i;u++)!e&&u in t||(e||(e=Array.prototype.slice.call(t,0,u)),e[u]=t[u]);return n.concat(e||Array.prototype.slice.call(t))}function I(){try{return f(Proxy)}catch(n){return!1}}function J(n,t){return n={pass:n},t&&(n.message=t),n}function K(n,t,r){for(var e=[],u=3;u<arguments.length;u++)e[u-3]=arguments[u];return p(h(n)||n&&h(n.pass),"Incorrect return value for rule: "+JSON.stringify(n)),h(n)?J(n):J(n.pass,a.apply(void 0,F([n.message,t,r],e,!1)))}function R(n){function t(t,r,e){return function(){for(var u=[],i=0;i<arguments.length;i++)u[i]=arguments[i];return p((i=cn.run({value:n},(function(){return K.apply(void 0,F([r.apply(void 0,F([n],u,!1)),e,n],u,!1))}))).pass,s(i.message)?"enforce/".concat(e," failed with ").concat(JSON.stringify(n)):new String(a(i.message))),t}}var r={};if(!I())return W((function(n,e){r[n]=t(r,e,n)})),r;var e=new Proxy(r,{get:function(n,r){if(n=an[r])return t(e,n,r)}});return e}function U(n){var t,r=[];return function n(e){return function(){for(var u=[],i=0;i<arguments.length;i++)u[i]=arguments[i];var o=an[e];r.push((function(n){return K.apply(void 0,F([o.apply(void 0,F([n],u,!1)),e,n],u,!1))}));var s={run:function(n){return c(g(r,(function(r,e){var u,i=cn.run({value:n},(function(){return r(n)}));e(!i.pass,J(!!i.pass,null!==(u=a(t,n,i.message))&&void 0!==u?u:i.message))})),J(!0))},test:function(n){return s.run(n).pass},message:function(n){return n&&(t=n),s}};return I()?s=new Proxy(s,{get:function(t,r){return an[r]?n(r):t[r]}}):(W((function(t){s[t]=n(t)})),s)}}(n)}var V=n(t),X=n(r),z=n(e),C=n(i),M=n(o),D=n(s),G=n(l),H=Object.assign,L=n(N),Q=n(y),Y=n(d),Z=n(b),$=n(x),_=n(w),nn=n(h),tn=n(T),rn=n(q),en=n(S),un=n(v),on=n(j),sn=n(A),fn=n(B),an={condition:function(n,t){try{return t(n)}catch(n){return!1}},doesNotEndWith:Q,doesNotStartWith:n(P),endsWith:y,equals:d,greaterThan:u,greaterThanOrEquals:m,gt:u,gte:m,inside:b,isArray:l,isBetween:x,isBlank:w,isBoolean:h,isEmpty:N,isEven:function(n){return!!t(n)&&0==n%2},isFalsy:on,isKeyOf:T,isNaN:q,isNegative:function(n){return O(n,0)},isNotArray:G,isNotBetween:$,isNotBlank:_,isNotBoolean:nn,isNotEmpty:L,isNotKeyOf:tn,isNotNaN:rn,isNotNull:C,isNotNullish:D,isNotNumber:en,isNotNumeric:V,isNotString:un,isNotUndefined:M,isNotValueOf:sn,isNull:i,isNullish:s,isNumber:S,isNumeric:t,isOdd:function(n){return!!t(n)&&0!=n%2},isPositive:function(n){return u(n,0)},isString:v,isTruthy:j,isUndefined:o,isValueOf:A,lengthEquals:e,lengthNotEquals:z,lessThan:O,lessThanOrEquals:E,longerThan:function(n,t){return u(n.length,t)},longerThanOrEquals:function(n,t){return m(n.length,t)},lt:O,lte:E,matches:B,notEquals:Y,notInside:Z,notMatches:fn,numberEquals:r,numberNotEquals:X,shorterThan:function(n,t){return O(n.length,t)},shorterThanOrEquals:function(n,t){return E(n.length,t)},startsWith:P},cn=function(n){function t(t,u){var i,o,s=r();return t=H({},s||{},null!==(i=a(n,t,s))&&void 0!==i?i:t),i=e.ctx=Object.freeze(t),e.ancestry.unshift(i),u=u(i),e.ancestry.shift(),e.ctx=null!==(o=e.ancestry[0])&&void 0!==o?o:null,u}function r(){return e.ctx}var e={ancestry:[]};return{bind:function(n,r){return function(){for(var e=[],u=0;u<arguments.length;u++)e[u]=arguments[u];return t(n,(function(){return r.apply(void 0,e)}))}},run:t,use:r,useX:function(n){var t=r();return p(t,c(n,"Context was used after it was closed")),t}}}((function(n,t){var r={value:n.value,meta:n.meta||{}};return t?n.set?H(r,{parent:function(){return t?{value:t.value,meta:t.meta,parent:t.parent}:t}}):t:H(r,{parent:k})}));return function(){function n(){if(!I())return W((function(n){t[n]=U(n)})),H(R,t)}var t={context:function(){return cn.useX()},extend:function(t){H(an,t),n()}};n(),new Proxy(H(R,t),{get:function(n,t){return t in n?n[t]:an[t]?U(t):void 0}})}(),function(){function n(n){return cn.run({value:n},(function(){return c(g(t,(function(t,r){try{var e=t.run(n)}catch(n){e=J(!1)}r(!e.pass,e)})),J(!0))}))}for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return H((function(t){p((t=n(t)).pass,new String(a(t.message)))}),{run:n,test:function(t){return n(t).pass}})}}));
|