vast 1.0.11 → 1.1.0-dev-f30a30
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vest-utils");exports.createState=function(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("vest-utils");exports.createState=function(n){var r={references:[]},t=[];return{registerStateKey:function(e,n){var r=t.length;return t.push([e,n]),u(r,e)},reset:function(){var e=c();r.references=[],t.forEach((function(n,r){return u(r,n[0],e[r])}))}};function u(n,r,t){return c().push(),i(n,e.optionalFunctionValue(r,t)),function(){return[c()[n],function(r){return i(n,e.optionalFunctionValue(r,c()[n]))}]}}function c(){return r.references}function i(u,c){var i=r.references[u];r.references[u]=c;var o=t[u][1];e.isFunction(o)&&o(c,i),e.isFunction(n)&&n()}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{optionalFunctionValue as e,isFunction as r}from"vest-utils";
|
|
1
|
+
import{optionalFunctionValue as e,isFunction as r}from"vest-utils";function n(n){var t={references:[]},u=[];return{registerStateKey:function(e,r){var n=u.length;return u.push([e,r]),f(n,e)},reset:function(){var e=c();t.references=[],u.forEach((function(r,n){return f(n,r[0],e[n])}))}};function f(r,n,t){return c().push(),o(r,e(n,t)),function(){return[c()[r],function(n){return o(r,e(n,c()[r]))}]}}function c(){return t.references}function o(e,f){var c=t.references[e];t.references[e]=f;var o=u[e][1];r(o)&&o(f,c),r(n)&&n()}}export{n as createState};
|
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vast = {}));
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function isFunction(value) {
|
|
8
|
-
return typeof value === 'function';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function optionalFunctionValue(value) {
|
|
12
|
-
var args = [];
|
|
13
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
14
|
-
args[_i - 1] = arguments[_i];
|
|
15
|
-
}
|
|
16
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
17
|
-
}
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vest-utils')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vest-utils'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vast = {}, global["vest-utils"]));
|
|
5
|
+
})(this, (function (exports, vestUtils) { 'use strict';
|
|
18
6
|
|
|
19
7
|
// eslint-disable-next-line max-lines-per-function
|
|
20
8
|
function createState(onStateChange) {
|
|
@@ -54,12 +42,12 @@
|
|
|
54
42
|
}
|
|
55
43
|
function initKey(key, initialState, prevState) {
|
|
56
44
|
current().push();
|
|
57
|
-
set(key, optionalFunctionValue(initialState, prevState));
|
|
45
|
+
set(key, vestUtils.optionalFunctionValue(initialState, prevState));
|
|
58
46
|
return function useStateKey() {
|
|
59
47
|
return [
|
|
60
48
|
current()[key],
|
|
61
49
|
function (nextState) {
|
|
62
|
-
return set(key, optionalFunctionValue(nextState, current()[key]));
|
|
50
|
+
return set(key, vestUtils.optionalFunctionValue(nextState, current()[key]));
|
|
63
51
|
},
|
|
64
52
|
];
|
|
65
53
|
};
|
|
@@ -71,10 +59,10 @@
|
|
|
71
59
|
var prevValue = state.references[index];
|
|
72
60
|
state.references[index] = value;
|
|
73
61
|
var _a = registrations[index], onUpdate = _a[1];
|
|
74
|
-
if (isFunction(onUpdate)) {
|
|
62
|
+
if (vestUtils.isFunction(onUpdate)) {
|
|
75
63
|
onUpdate(value, prevValue);
|
|
76
64
|
}
|
|
77
|
-
if (isFunction(onStateChange)) {
|
|
65
|
+
if (vestUtils.isFunction(onStateChange)) {
|
|
78
66
|
onStateChange();
|
|
79
67
|
}
|
|
80
68
|
}
|
|
@@ -84,4 +72,4 @@
|
|
|
84
72
|
|
|
85
73
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
86
74
|
|
|
87
|
-
}))
|
|
75
|
+
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vest-utils")):"function"==typeof define&&define.amd?define(["exports","vest-utils"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).vast={},e["vest-utils"])}(this,(function(e,n){"use strict";e.createState=function(e){var t={references:[]},r=[];return{registerStateKey:function(e,n){var t=r.length;return r.push([e,n]),u(t,e)},reset:function(){var e=i();t.references=[],r.forEach((function(n,t){return u(t,n[0],e[t])}))}};function u(e,t,r){return i().push(),o(e,n.optionalFunctionValue(t,r)),function(){return[i()[e],function(t){return o(e,n.optionalFunctionValue(t,i()[e]))}]}}function i(){return t.references}function o(u,i){var o=t.references[u];t.references[u]=i;var f=r[u][1];n.isFunction(f)&&f(i,o),n.isFunction(e)&&e()}},Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0
|
|
2
|
+
"version": "1.1.0-dev-f30a30",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/vast.js",
|
|
5
5
|
"types": "./types/vast.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"url": "https://github.com/ealush/vest.git/issues"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"vest-utils": "^0.0
|
|
22
|
+
"vest-utils": "^0.1.0-dev-f30a30"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
package/tsconfig.json
CHANGED
package/types/vast.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare function createState(onStateChange?: (...args: unknown[]) => unknown): CreateStateReturn;
|
|
2
2
|
type StateInput<S> = S | ((prevState?: S) => S);
|
|
3
3
|
type SetStateInput<S> = S | ((prevState: S) => S);
|
|
4
|
-
type State =
|
|
4
|
+
type State = CreateStateReturn;
|
|
5
5
|
type StateHandlerReturn<S> = [S, (nextState: SetStateInput<S>) => void];
|
|
6
6
|
type UseState<S> = () => StateHandlerReturn<S>;
|
|
7
7
|
type CreateStateReturn = {
|
|
@@ -9,3 +9,4 @@ type CreateStateReturn = {
|
|
|
9
9
|
registerStateKey: <S>(initialState?: StateInput<S> | undefined, onUpdate?: (() => void) | undefined) => () => StateHandlerReturn<S>;
|
|
10
10
|
};
|
|
11
11
|
export { createState, State, StateHandlerReturn, UseState };
|
|
12
|
+
//# sourceMappingURL=vast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vast.d.ts","sourceRoot":"","sources":["../src/vast.ts"],"names":[],"mappings":"AAGA,iBAAgB,WAAW,CACzB,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GAC9C,iBAAiB,CAkFnB;AAED,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAChD,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAElD,KAAY,KAAK,GAAG,iBAAiB,CAAC;AACtC,KAAY,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;AAC/E,KAAY,QAAQ,CAAC,CAAC,IAAI,MAAM,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAEtD,KAAK,iBAAiB,GAAG;IACvB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,gBAAgB,EAAE,CAAC,CAAC,EAClB,YAAY,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,SAAS,EACxC,QAAQ,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,KAChC,MAAM,kBAAkB,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC"}
|