@artisan-commerce/state 0.3.0-canary.3 → 0.3.0-canary.34
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/bundle.cjs +50 -0
- package/dist/bundle.cjs.map +1 -0
- package/dist/bundle.d.ts +46 -24
- package/dist/bundle.mjs +48 -0
- package/dist/bundle.mjs.map +1 -0
- package/dist/bundle.umd.js +28 -25
- package/dist/bundle.umd.js.map +1 -1
- package/package.json +28 -47
- package/CHANGELOG.md +0 -192
- package/dist/bundle.cjs.js +0 -47
- package/dist/bundle.cjs.js.map +0 -1
- package/dist/bundle.esm.js +0 -40
- package/dist/bundle.esm.js.map +0 -1
package/dist/bundle.cjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
const _State = class {
|
|
20
|
+
constructor(state) {
|
|
21
|
+
this._state = state;
|
|
22
|
+
this._initialState = state;
|
|
23
|
+
}
|
|
24
|
+
static getInstance(initialState) {
|
|
25
|
+
if (!_State._instance) {
|
|
26
|
+
_State._instance = new _State(initialState);
|
|
27
|
+
}
|
|
28
|
+
return _State._instance;
|
|
29
|
+
}
|
|
30
|
+
setState(overrides) {
|
|
31
|
+
this._state = __spreadValues(__spreadValues({}, this._state), overrides);
|
|
32
|
+
}
|
|
33
|
+
get state() {
|
|
34
|
+
if (this._state === null) {
|
|
35
|
+
throw new Error("The state has not been initialized, make sure to call State.init beforehand");
|
|
36
|
+
}
|
|
37
|
+
return this._state;
|
|
38
|
+
}
|
|
39
|
+
checkInit() {
|
|
40
|
+
return !!this._state;
|
|
41
|
+
}
|
|
42
|
+
reset() {
|
|
43
|
+
this._state = this._initialState;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
let State = _State;
|
|
47
|
+
State._instance = null;
|
|
48
|
+
|
|
49
|
+
exports.State = State;
|
|
50
|
+
//# sourceMappingURL=bundle.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.cjs","sources":["../src/lib/state.ts"],"sourcesContent":["// Common functions and data\n\n/**\n * @since 0.1.0\n * @typedef State\n */\nexport type GlobalState = Record<string, any>;\n\n/**\n *\n * Create a global state.\n *\n * @example\n * interface Animal {\n * walk: () => void;\n * name: string;\n * }\n *\n * function getDogState(): State<Animal> {\n * return State.getInstance({ name: \"Rancho\", walk: () => {} });\n * }\n *\n * const dogState = getDogState();\n */\nexport class State<T extends GlobalState> {\n static _instance: State<any> | null = null;\n private _initialState: T;\n private _state: T;\n\n private constructor(state: T) {\n this._state = state;\n this._initialState = state;\n }\n\n public static getInstance<T extends GlobalState>(initialState: T): State<T> {\n if (!State._instance) {\n State._instance = new State<T>(initialState);\n }\n return State._instance as State<T>;\n }\n\n /**\n * Updates the global state.\n *\n * @since 0.1.0\n * @param {T} overrides Global state overrides\n */\n public setState(overrides: Partial<T>) {\n this._state = { ...this._state, ...overrides };\n }\n\n /**\n * Returns the global state.\n *\n * @since 0.1.0\n * @returns {T} The global state\n */\n public get state(): T {\n if (this._state === null) {\n throw new Error(\n \"The state has not been initialized, make sure to call State.init beforehand\"\n );\n }\n return this._state;\n }\n\n /**\n * Returns whether the state has been initialized.\n *\n * @since 0.1.0\n * @returns {boolean} Whether the state has been initialized\n */\n public checkInit(): boolean {\n return !!this._state;\n }\n\n /**\n * Reset state to the given initial state.\n *\n * @since 0.1.0\n */\n public reset() {\n this._state = this._initialState;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,MAAmC,MAAA,GAAA,MAAA;AAAA,EAKhC,YAAY,KAAU,EAAA;AAC5B,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA;AACd,IAAA,IAAA,CAAK,aAAgB,GAAA,KAAA;AAAA;AAAA,EAAA,OAGT,YAAmC,YAA2B,EAAA;AAC1E,IAAI,IAAA,CAAC,OAAM,SAAW,EAAA;AACpB,MAAM,MAAA,CAAA,SAAA,GAAY,IAAI,MAAS,CAAA,YAAA,CAAA;AAAA;AAEjC,IAAA,OAAO,MAAM,CAAA,SAAA;AAAA;AAAA,EASR,SAAS,SAAuB,EAAA;AACrC,IAAK,IAAA,CAAA,MAAA,GAAS,cAAK,CAAA,cAAA,CAAA,EAAA,EAAA,IAAA,CAAK,MAAW,CAAA,EAAA,SAAA,CAAA;AAAA;AAAA,EAAA,IAS1B,KAAW,GAAA;AACpB,IAAI,IAAA,IAAA,CAAK,WAAW,IAAM,EAAA;AACxB,MAAA,MAAM,IAAI,KACR,CAAA,6EAAA,CAAA;AAAA;AAGJ,IAAA,OAAO,IAAK,CAAA,MAAA;AAAA;AAAA,EASP,SAAqB,GAAA;AAC1B,IAAO,OAAA,CAAC,CAAC,IAAK,CAAA,MAAA;AAAA;AAAA,EAQT,KAAQ,GAAA;AACb,IAAA,IAAA,CAAK,SAAS,IAAK,CAAA,aAAA;AAAA;AAAA,CAAA;AA1DhB,IAAA,KAAA,GAAA;AAAA,MACE,SAA+B,GAAA,IAAA;;;;"}
|
package/dist/bundle.d.ts
CHANGED
|
@@ -2,34 +2,56 @@
|
|
|
2
2
|
* @since 0.1.0
|
|
3
3
|
* @typedef State
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
type GlobalState = Record<string, any>;
|
|
6
6
|
/**
|
|
7
|
-
* Initializes the global state.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
* @param {T} initialState Initial global state
|
|
11
|
-
*/
|
|
12
|
-
declare const initState: <T extends State>(initialState: T) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Updates the global state.
|
|
8
|
+
* Create a global state.
|
|
15
9
|
*
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* Returns the global state.
|
|
10
|
+
* @example
|
|
11
|
+
* interface Animal {
|
|
12
|
+
* walk: () => void;
|
|
13
|
+
* name: string;
|
|
14
|
+
* }
|
|
22
15
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
declare const getState: <T extends State>() => T;
|
|
27
|
-
/**
|
|
28
|
-
* Returns whether the state has been initialized.
|
|
16
|
+
* function getDogState(): State<Animal> {
|
|
17
|
+
* return State.getInstance({ name: "Rancho", walk: () => {} });
|
|
18
|
+
* }
|
|
29
19
|
*
|
|
30
|
-
*
|
|
31
|
-
* @returns {boolean} Whether the state has been initialized
|
|
20
|
+
* const dogState = getDogState();
|
|
32
21
|
*/
|
|
33
|
-
declare
|
|
22
|
+
declare class State<T extends GlobalState> {
|
|
23
|
+
static _instance: State<any> | null;
|
|
24
|
+
private _initialState;
|
|
25
|
+
private _state;
|
|
26
|
+
private constructor();
|
|
27
|
+
static getInstance<T extends GlobalState>(initialState: T): State<T>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates the global state.
|
|
30
|
+
*
|
|
31
|
+
* @since 0.1.0
|
|
32
|
+
* @param {T} overrides Global state overrides
|
|
33
|
+
*/
|
|
34
|
+
setState(overrides: Partial<T>): void;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the global state.
|
|
37
|
+
*
|
|
38
|
+
* @since 0.1.0
|
|
39
|
+
* @returns {T} The global state
|
|
40
|
+
*/
|
|
41
|
+
get state(): T;
|
|
42
|
+
/**
|
|
43
|
+
* Returns whether the state has been initialized.
|
|
44
|
+
*
|
|
45
|
+
* @since 0.1.0
|
|
46
|
+
* @returns {boolean} Whether the state has been initialized
|
|
47
|
+
*/
|
|
48
|
+
checkInit(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Reset state to the given initial state.
|
|
51
|
+
*
|
|
52
|
+
* @since 0.1.0
|
|
53
|
+
*/
|
|
54
|
+
reset(): void;
|
|
55
|
+
}
|
|
34
56
|
|
|
35
|
-
export {
|
|
57
|
+
export { State };
|
package/dist/bundle.mjs
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
const _State = class {
|
|
18
|
+
constructor(state) {
|
|
19
|
+
this._state = state;
|
|
20
|
+
this._initialState = state;
|
|
21
|
+
}
|
|
22
|
+
static getInstance(initialState) {
|
|
23
|
+
if (!_State._instance) {
|
|
24
|
+
_State._instance = new _State(initialState);
|
|
25
|
+
}
|
|
26
|
+
return _State._instance;
|
|
27
|
+
}
|
|
28
|
+
setState(overrides) {
|
|
29
|
+
this._state = __spreadValues(__spreadValues({}, this._state), overrides);
|
|
30
|
+
}
|
|
31
|
+
get state() {
|
|
32
|
+
if (this._state === null) {
|
|
33
|
+
throw new Error("The state has not been initialized, make sure to call State.init beforehand");
|
|
34
|
+
}
|
|
35
|
+
return this._state;
|
|
36
|
+
}
|
|
37
|
+
checkInit() {
|
|
38
|
+
return !!this._state;
|
|
39
|
+
}
|
|
40
|
+
reset() {
|
|
41
|
+
this._state = this._initialState;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
let State = _State;
|
|
45
|
+
State._instance = null;
|
|
46
|
+
|
|
47
|
+
export { State };
|
|
48
|
+
//# sourceMappingURL=bundle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.mjs","sources":["../src/lib/state.ts"],"sourcesContent":["// Common functions and data\n\n/**\n * @since 0.1.0\n * @typedef State\n */\nexport type GlobalState = Record<string, any>;\n\n/**\n *\n * Create a global state.\n *\n * @example\n * interface Animal {\n * walk: () => void;\n * name: string;\n * }\n *\n * function getDogState(): State<Animal> {\n * return State.getInstance({ name: \"Rancho\", walk: () => {} });\n * }\n *\n * const dogState = getDogState();\n */\nexport class State<T extends GlobalState> {\n static _instance: State<any> | null = null;\n private _initialState: T;\n private _state: T;\n\n private constructor(state: T) {\n this._state = state;\n this._initialState = state;\n }\n\n public static getInstance<T extends GlobalState>(initialState: T): State<T> {\n if (!State._instance) {\n State._instance = new State<T>(initialState);\n }\n return State._instance as State<T>;\n }\n\n /**\n * Updates the global state.\n *\n * @since 0.1.0\n * @param {T} overrides Global state overrides\n */\n public setState(overrides: Partial<T>) {\n this._state = { ...this._state, ...overrides };\n }\n\n /**\n * Returns the global state.\n *\n * @since 0.1.0\n * @returns {T} The global state\n */\n public get state(): T {\n if (this._state === null) {\n throw new Error(\n \"The state has not been initialized, make sure to call State.init beforehand\"\n );\n }\n return this._state;\n }\n\n /**\n * Returns whether the state has been initialized.\n *\n * @since 0.1.0\n * @returns {boolean} Whether the state has been initialized\n */\n public checkInit(): boolean {\n return !!this._state;\n }\n\n /**\n * Reset state to the given initial state.\n *\n * @since 0.1.0\n */\n public reset() {\n this._state = this._initialState;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAwBO,MAAmC,MAAA,GAAA,MAAA;AAAA,EAKhC,YAAY,KAAU,EAAA;AAC5B,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA;AACd,IAAA,IAAA,CAAK,aAAgB,GAAA,KAAA;AAAA;AAAA,EAAA,OAGT,YAAmC,YAA2B,EAAA;AAC1E,IAAI,IAAA,CAAC,OAAM,SAAW,EAAA;AACpB,MAAM,MAAA,CAAA,SAAA,GAAY,IAAI,MAAS,CAAA,YAAA,CAAA;AAAA;AAEjC,IAAA,OAAO,MAAM,CAAA,SAAA;AAAA;AAAA,EASR,SAAS,SAAuB,EAAA;AACrC,IAAK,IAAA,CAAA,MAAA,GAAS,cAAK,CAAA,cAAA,CAAA,EAAA,EAAA,IAAA,CAAK,MAAW,CAAA,EAAA,SAAA,CAAA;AAAA;AAAA,EAAA,IAS1B,KAAW,GAAA;AACpB,IAAI,IAAA,IAAA,CAAK,WAAW,IAAM,EAAA;AACxB,MAAA,MAAM,IAAI,KACR,CAAA,6EAAA,CAAA;AAAA;AAGJ,IAAA,OAAO,IAAK,CAAA,MAAA;AAAA;AAAA,EASP,SAAqB,GAAA;AAC1B,IAAO,OAAA,CAAC,CAAC,IAAK,CAAA,MAAA;AAAA;AAAA,EAQT,KAAQ,GAAA;AACb,IAAA,IAAA,CAAK,SAAS,IAAK,CAAA,aAAA;AAAA;AAAA,CAAA;AA1DhB,IAAA,KAAA,GAAA;AAAA,MACE,SAA+B,GAAA,IAAA;;;;"}
|
package/dist/bundle.umd.js
CHANGED
|
@@ -20,34 +20,37 @@
|
|
|
20
20
|
}
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
const _State = class {
|
|
24
|
+
constructor(state) {
|
|
25
|
+
this._state = state;
|
|
26
|
+
this._initialState = state;
|
|
27
|
+
}
|
|
28
|
+
static getInstance(initialState) {
|
|
29
|
+
if (!_State._instance) {
|
|
30
|
+
_State._instance = new _State(initialState);
|
|
31
|
+
}
|
|
32
|
+
return _State._instance;
|
|
33
|
+
}
|
|
34
|
+
setState(overrides) {
|
|
35
|
+
this._state = __spreadValues(__spreadValues({}, this._state), overrides);
|
|
36
|
+
}
|
|
37
|
+
get state() {
|
|
38
|
+
if (this._state === null) {
|
|
39
|
+
throw new Error("The state has not been initialized, make sure to call State.init beforehand");
|
|
40
|
+
}
|
|
41
|
+
return this._state;
|
|
42
|
+
}
|
|
43
|
+
checkInit() {
|
|
44
|
+
return !!this._state;
|
|
45
|
+
}
|
|
46
|
+
reset() {
|
|
47
|
+
this._state = this._initialState;
|
|
38
48
|
}
|
|
39
|
-
return __spreadValues({}, state);
|
|
40
|
-
};
|
|
41
|
-
const checkInit = () => {
|
|
42
|
-
return !!state;
|
|
43
49
|
};
|
|
50
|
+
let State = _State;
|
|
51
|
+
State._instance = null;
|
|
44
52
|
|
|
45
|
-
exports.
|
|
46
|
-
exports.getState = getState;
|
|
47
|
-
exports.initState = initState;
|
|
48
|
-
exports.setState = setState;
|
|
49
|
-
|
|
50
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
53
|
+
exports.State = State;
|
|
51
54
|
|
|
52
55
|
}));
|
|
53
56
|
//# sourceMappingURL=bundle.umd.js.map
|
package/dist/bundle.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.umd.js","sources":["../src/lib/state.ts"],"sourcesContent":["// Common functions and data\n\n/**\n * @since 0.1.0\n * @typedef State\n */\
|
|
1
|
+
{"version":3,"file":"bundle.umd.js","sources":["../src/lib/state.ts"],"sourcesContent":["// Common functions and data\n\n/**\n * @since 0.1.0\n * @typedef State\n */\nexport type GlobalState = Record<string, any>;\n\n/**\n *\n * Create a global state.\n *\n * @example\n * interface Animal {\n * walk: () => void;\n * name: string;\n * }\n *\n * function getDogState(): State<Animal> {\n * return State.getInstance({ name: \"Rancho\", walk: () => {} });\n * }\n *\n * const dogState = getDogState();\n */\nexport class State<T extends GlobalState> {\n static _instance: State<any> | null = null;\n private _initialState: T;\n private _state: T;\n\n private constructor(state: T) {\n this._state = state;\n this._initialState = state;\n }\n\n public static getInstance<T extends GlobalState>(initialState: T): State<T> {\n if (!State._instance) {\n State._instance = new State<T>(initialState);\n }\n return State._instance as State<T>;\n }\n\n /**\n * Updates the global state.\n *\n * @since 0.1.0\n * @param {T} overrides Global state overrides\n */\n public setState(overrides: Partial<T>) {\n this._state = { ...this._state, ...overrides };\n }\n\n /**\n * Returns the global state.\n *\n * @since 0.1.0\n * @returns {T} The global state\n */\n public get state(): T {\n if (this._state === null) {\n throw new Error(\n \"The state has not been initialized, make sure to call State.init beforehand\"\n );\n }\n return this._state;\n }\n\n /**\n * Returns whether the state has been initialized.\n *\n * @since 0.1.0\n * @returns {boolean} Whether the state has been initialized\n */\n public checkInit(): boolean {\n return !!this._state;\n }\n\n /**\n * Reset state to the given initial state.\n *\n * @since 0.1.0\n */\n public reset() {\n this._state = this._initialState;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;EAwBO,MAAmC,MAAA,GAAA,MAAA;EAAA,EAKhC,YAAY,KAAU,EAAA;EAC5B,IAAA,IAAA,CAAK,MAAS,GAAA,KAAA;EACd,IAAA,IAAA,CAAK,aAAgB,GAAA,KAAA;EAAA;EAAA,EAAA,OAGT,YAAmC,YAA2B,EAAA;EAC1E,IAAI,IAAA,CAAC,OAAM,SAAW,EAAA;EACpB,MAAM,MAAA,CAAA,SAAA,GAAY,IAAI,MAAS,CAAA,YAAA,CAAA;EAAA;EAEjC,IAAA,OAAO,MAAM,CAAA,SAAA;EAAA;EAAA,EASR,SAAS,SAAuB,EAAA;EACrC,IAAK,IAAA,CAAA,MAAA,GAAS,cAAK,CAAA,cAAA,CAAA,EAAA,EAAA,IAAA,CAAK,MAAW,CAAA,EAAA,SAAA,CAAA;EAAA;EAAA,EAAA,IAS1B,KAAW,GAAA;EACpB,IAAI,IAAA,IAAA,CAAK,WAAW,IAAM,EAAA;EACxB,MAAA,MAAM,IAAI,KACR,CAAA,6EAAA,CAAA;EAAA;EAGJ,IAAA,OAAO,IAAK,CAAA,MAAA;EAAA;EAAA,EASP,SAAqB,GAAA;EAC1B,IAAO,OAAA,CAAC,CAAC,IAAK,CAAA,MAAA;EAAA;EAAA,EAQT,KAAQ,GAAA;EACb,IAAA,IAAA,CAAK,SAAS,IAAK,CAAA,aAAA;EAAA;EAAA,CAAA;AA1DhB,MAAA,KAAA,GAAA;EAAA,MACE,SAA+B,GAAA,IAAA;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artisan-commerce/state",
|
|
3
3
|
"description": "Library used to share state functionality",
|
|
4
|
-
"version": "0.3.0-canary.
|
|
5
|
-
"
|
|
6
|
-
"
|
|
4
|
+
"version": "0.3.0-canary.34",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/bundle.cjs",
|
|
7
|
+
"module": "./dist/bundle.mjs",
|
|
7
8
|
"types": "./dist/bundle.d.ts",
|
|
8
9
|
"files": [
|
|
9
10
|
"dist"
|
|
10
11
|
],
|
|
11
12
|
"sideEffects": false,
|
|
12
|
-
"exports": {
|
|
13
|
-
"node": {
|
|
14
|
-
"import": "./dist/bundle.esm.js",
|
|
15
|
-
"require": "./dist/bundle.cjs.js"
|
|
16
|
-
},
|
|
17
|
-
"default": "./dist/bundle.esm.js"
|
|
18
|
-
},
|
|
19
13
|
"scripts": {
|
|
20
|
-
"compile": "rollup -c",
|
|
14
|
+
"compile": "rollup -c && npx agadoo",
|
|
21
15
|
"dev": "yarn compile -w",
|
|
22
16
|
"clean": "rimraf dist",
|
|
23
17
|
"prebuild": "yarn clean",
|
|
@@ -25,9 +19,9 @@
|
|
|
25
19
|
"test": "jest --watchAll --runInBand",
|
|
26
20
|
"test:all": "yarn test --watchAll=false --coverage",
|
|
27
21
|
"test:ci": "cross-env CI=true jest --runInBand",
|
|
28
|
-
"test:staged": "yarn test:ci
|
|
22
|
+
"test:staged": "yarn test:ci",
|
|
29
23
|
"check-types": "tsc --noEmit",
|
|
30
|
-
"lint": "eslint --ignore-path .gitignore --ignore-pattern !cypress/.eslintrc.
|
|
24
|
+
"lint": "eslint --ignore-path .gitignore --ignore-pattern !cypress/.eslintrc.cjs --ext .js,jsx,.ts,.tsx .",
|
|
31
25
|
"lint:staged": "yarn lint --max-warnings=0",
|
|
32
26
|
"prettier": "prettier --ignore-path .gitignore \"**/*.+(js|jsx|ts|tsx|json|css|scss|html)\"",
|
|
33
27
|
"format": "yarn prettier --write",
|
|
@@ -37,40 +31,27 @@
|
|
|
37
31
|
},
|
|
38
32
|
"author": "Santiago Benítez",
|
|
39
33
|
"license": "MIT",
|
|
34
|
+
"nx": {
|
|
35
|
+
"targets": {
|
|
36
|
+
"build": {
|
|
37
|
+
"outputs": [
|
|
38
|
+
"{projectRoot}/dist"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"compile": {
|
|
42
|
+
"outputs": [
|
|
43
|
+
"{projectRoot}/dist"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"test:all": {
|
|
47
|
+
"outputs": [
|
|
48
|
+
"{projectRoot}/coverage"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
40
53
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@babel/preset-env": "^7.10.4",
|
|
43
|
-
"@babel/preset-react": "^7.10.4",
|
|
44
|
-
"@types/faker": "^4.1.12",
|
|
45
|
-
"@types/jest": "^26.0.5",
|
|
46
|
-
"@types/jest-in-case": "^1.0.2",
|
|
47
|
-
"@types/node": "^14.0.24",
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^3.7.0",
|
|
49
|
-
"@typescript-eslint/parser": "^3.7.0",
|
|
50
|
-
"avn": "^0.2.4",
|
|
51
|
-
"avn-nvm": "^0.2.2",
|
|
52
|
-
"env-cmd": "^10.1.0",
|
|
53
|
-
"eslint": "^7.5.0",
|
|
54
|
-
"eslint-config-prettier": "^6.11.0",
|
|
55
|
-
"eslint-config-react-app": "^5.2.1",
|
|
56
|
-
"eslint-config-universe": "^4.0.0",
|
|
57
|
-
"eslint-plugin-cypress": "^2.11.1",
|
|
58
|
-
"eslint-plugin-flowtype": "^5.2.0",
|
|
59
|
-
"eslint-plugin-import": "^2.22.0",
|
|
60
|
-
"eslint-plugin-jsx-a11y": "^6.3.1",
|
|
61
|
-
"eslint-plugin-react": "^7.20.3",
|
|
62
|
-
"eslint-plugin-react-hooks": "^4.0.8",
|
|
63
|
-
"is-ci-cli": "^2.1.2",
|
|
64
|
-
"jest-axe": "^3.5.0",
|
|
65
|
-
"jest-in-case": "^1.0.2",
|
|
66
|
-
"jest-styled-components": "^7.0.2",
|
|
67
|
-
"nodemon": "^2.0.4",
|
|
68
|
-
"npm-run-all": "^4.1.5",
|
|
69
|
-
"prettier": "^2.2.1",
|
|
70
|
-
"start-server-and-test": "^1.11.2",
|
|
71
|
-
"test-data-bot": "^0.8.0",
|
|
72
|
-
"ts-jest": "^26.1.4",
|
|
73
|
-
"ts-loader": "^8.0.2"
|
|
54
|
+
"@artisan-commerce/types": "0.14.0-canary.62"
|
|
74
55
|
},
|
|
75
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "da3b607a50be5f075bfc8bebc8d737ab151e42b5"
|
|
76
57
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [0.3.0-canary.3](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/state@0.3.0-canary.2...@artisan-commerce/state@0.3.0-canary.3) (2021-10-14)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* **global:** make export not module by default ([4e701b1](https://bitbucket.org/tradesystem/artisn_sdk/commit/4e701b1b59df89cf8358cf500984b1c2c4f42c60))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## [0.3.0-canary.2](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/state@0.3.0-canary.1...@artisan-commerce/state@0.3.0-canary.2) (2021-10-14)
|
|
16
|
-
|
|
17
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## [0.3.0-canary.1](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/state@0.3.0-canary.0...@artisan-commerce/state@0.3.0-canary.1) (2021-10-04)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Features
|
|
27
|
-
|
|
28
|
-
* **global:** update registerModifiersForm function, control state error ([c3534cf](https://bitbucket.org/tradesystem/artisn_sdk/commit/c3534cf2eac5f7d90176888ad5b6dd575998e2f1))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## [0.3.0-canary.0](https://bitbucket.org/tradesystem/artisn_sdk/compare/@artisan-commerce/state@0.2.2...@artisan-commerce/state@0.3.0-canary.0) (2021-08-11)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
### Features
|
|
36
|
-
|
|
37
|
-
* **global:** rebrand artisan-commerce to artisn ([b2688b1](https://bitbucket.org/tradesystem/artisn_sdk/commit/b2688b107757ed82791c0be49439e9fb28f78b6d))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### [0.2.2](https://bitbucket.org/tradesystem/artisan_sdk/compare/@artisan-commerce/state@0.2.2-canary.4...@artisan-commerce/state@0.2.2) (2021-07-30)
|
|
42
|
-
|
|
43
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
### [0.2.2-canary.4](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.2-canary.3...@artisan-commerce/state@0.2.2-canary.4) (2021-04-27)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### Bug Fixes
|
|
53
|
-
|
|
54
|
-
* **global:** fix updateActiveVendor utility function and state lib ([e5d9c52](https://bitbucket.org/tradesystem/artisan_monorepo/commit/e5d9c52455929782ada1762b03abb3363efe88cf))
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### [0.2.2-canary.3](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.2-canary.2...@artisan-commerce/state@0.2.2-canary.3) (2021-04-16)
|
|
59
|
-
|
|
60
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
### [0.2.2-canary.2](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.2-canary.1...@artisan-commerce/state@0.2.2-canary.2) (2021-04-06)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
### Performance Improvements
|
|
70
|
-
|
|
71
|
-
* **global:** move typescript to be a global dependency ([32370e1](https://bitbucket.org/tradesystem/artisan_monorepo/commit/32370e134f1bcc4f79c55e2bae0ee22fee193e77))
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
### [0.2.2-canary.1](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.2-canary.0...@artisan-commerce/state@0.2.2-canary.1) (2021-03-30)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
### Performance Improvements
|
|
79
|
-
|
|
80
|
-
* **global:** add esbuild opt-in for dev ([f760449](https://bitbucket.org/tradesystem/artisan_monorepo/commit/f7604492fc17967bad75583a49d91a51cd6241aa))
|
|
81
|
-
* **global:** improve jest performance ([8c36173](https://bitbucket.org/tradesystem/artisan_monorepo/commit/8c36173df7e7cbfad40888499c81fcf7d11a7105))
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
### [0.2.2-canary.0](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.1...@artisan-commerce/state@0.2.2-canary.0) (2021-03-12)
|
|
86
|
-
|
|
87
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
### [0.2.1](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.1-canary.1...@artisan-commerce/state@0.2.1) (2021-03-02)
|
|
94
|
-
|
|
95
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
### [0.2.1-canary.1](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.1-canary.0...@artisan-commerce/state@0.2.1-canary.1) (2021-02-25)
|
|
102
|
-
|
|
103
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
### [0.2.1-canary.0](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.0...@artisan-commerce/state@0.2.1-canary.0) (2021-02-25)
|
|
110
|
-
|
|
111
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
## [0.2.0](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.0-canary.1...@artisan-commerce/state@0.2.0) (2021-02-25)
|
|
118
|
-
|
|
119
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
## [0.2.0-canary.1](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.2.0-canary.0...@artisan-commerce/state@0.2.0-canary.1) (2021-02-25)
|
|
126
|
-
|
|
127
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
## [0.2.0-canary.0](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.1.1-canary.6...@artisan-commerce/state@0.2.0-canary.0) (2021-02-25)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
### Features
|
|
137
|
-
|
|
138
|
-
* added commentaries ([400127f](https://bitbucket.org/tradesystem/artisan_monorepo/commit/400127f878abdafc2236cee866300a765956e0ce))
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
### [0.1.1-canary.6](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.1.1-canary.5...@artisan-commerce/state@0.1.1-canary.6) (2021-02-23)
|
|
143
|
-
|
|
144
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### [0.1.1-canary.5](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.1.1-canary.4...@artisan-commerce/state@0.1.1-canary.5) (2021-02-04)
|
|
151
|
-
|
|
152
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
### [0.1.1-canary.4](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.1.1-canary.3...@artisan-commerce/state@0.1.1-canary.4) (2021-02-04)
|
|
159
|
-
|
|
160
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
### [0.1.1-canary.3](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.1.1-canary.2...@artisan-commerce/state@0.1.1-canary.3) (2021-02-04)
|
|
167
|
-
|
|
168
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
### [0.1.1-canary.2](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.1.1-canary.1...@artisan-commerce/state@0.1.1-canary.2) (2021-02-04)
|
|
175
|
-
|
|
176
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
### [0.1.1-canary.1](https://bitbucket.org/tradesystem/artisan_monorepo/compare/@artisan-commerce/state@0.1.1-canary.0...@artisan-commerce/state@0.1.1-canary.1) (2021-02-04)
|
|
183
|
-
|
|
184
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
## 0.1.1-canary.0 (2021-02-03)
|
|
191
|
-
|
|
192
|
-
**Note:** Version bump only for package @artisan-commerce/state
|
package/dist/bundle.cjs.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
|
-
let state = null;
|
|
22
|
-
const initState = (initialState) => {
|
|
23
|
-
Object.freeze(initialState);
|
|
24
|
-
state = __spreadValues({}, initialState);
|
|
25
|
-
Object.seal(state);
|
|
26
|
-
};
|
|
27
|
-
const setState = (overrides) => {
|
|
28
|
-
const tempState = state ? __spreadValues({}, state) : {};
|
|
29
|
-
state = null;
|
|
30
|
-
state = __spreadValues(__spreadValues({}, tempState), overrides);
|
|
31
|
-
Object.seal(state);
|
|
32
|
-
};
|
|
33
|
-
const getState = () => {
|
|
34
|
-
if (state === null) {
|
|
35
|
-
throw new Error("The state has not been initialized, make sure to call initState beforehand");
|
|
36
|
-
}
|
|
37
|
-
return __spreadValues({}, state);
|
|
38
|
-
};
|
|
39
|
-
const checkInit = () => {
|
|
40
|
-
return !!state;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
exports.checkInit = checkInit;
|
|
44
|
-
exports.getState = getState;
|
|
45
|
-
exports.initState = initState;
|
|
46
|
-
exports.setState = setState;
|
|
47
|
-
//# sourceMappingURL=bundle.cjs.js.map
|
package/dist/bundle.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.cjs.js","sources":["../src/lib/state.ts"],"sourcesContent":["// Common functions and data\n\n/**\n * @since 0.1.0\n * @typedef State\n */\ntype State = Record<string, any>;\n\n/**\n * Global state.\n * @since 0.1.0\n */\nlet state: State | null = null;\n\n/**\n * Initializes the global state.\n *\n * @since 0.1.0\n * @param {T} initialState Initial global state\n */\nexport const initState = <T extends State>(initialState: T) => {\n Object.freeze(initialState);\n state = { ...initialState } as T;\n Object.seal(state);\n};\n\n/**\n * Updates the global state.\n *\n * @since 0.1.0\n * @param {T} overrides Global state overrides\n */\nexport const setState = <T extends State>(overrides: Partial<T>) => {\n const tempState = state ? { ...state } : {};\n state = null;\n state = { ...tempState, ...overrides } as T;\n Object.seal(state);\n};\n\n/**\n * Returns the global state.\n *\n * @since 0.1.0\n * @returns {T} The global state\n */\nexport const getState = <T extends State>() => {\n if (state === null) {\n throw new Error(\n \"The state has not been initialized, make sure to call initState beforehand\"\n );\n }\n return { ...state } as T;\n};\n\n/**\n * Returns whether the state has been initialized.\n *\n * @since 0.1.0\n * @returns {boolean} Whether the state has been initialized\n */\nexport const checkInit = () => {\n return !!state;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAYA,IAAI,QAAsB;MAQb,YAAY,CAAkB,iBAAoB;AAC7D,SAAO,OAAO;AACd,UAAQ,mBAAK;AACb,SAAO,KAAK;AAAA;MASD,WAAW,CAAkB,cAA0B;AAClE,QAAM,YAAY,QAAQ,mBAAK,SAAU;AACzC,UAAQ;AACR,UAAQ,kCAAK,YAAc;AAC3B,SAAO,KAAK;AAAA;MASD,WAAW,MAAuB;AAC7C,MAAI,UAAU,MAAM;AAClB,UAAM,IAAI,MACR;AAAA;AAGJ,SAAO,mBAAK;AAAA;MASD,YAAY,MAAM;AAC7B,SAAO,CAAC,CAAC;AAAA;;;;;;;"}
|
package/dist/bundle.esm.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
|
-
let state = null;
|
|
18
|
-
const initState = (initialState) => {
|
|
19
|
-
Object.freeze(initialState);
|
|
20
|
-
state = __spreadValues({}, initialState);
|
|
21
|
-
Object.seal(state);
|
|
22
|
-
};
|
|
23
|
-
const setState = (overrides) => {
|
|
24
|
-
const tempState = state ? __spreadValues({}, state) : {};
|
|
25
|
-
state = null;
|
|
26
|
-
state = __spreadValues(__spreadValues({}, tempState), overrides);
|
|
27
|
-
Object.seal(state);
|
|
28
|
-
};
|
|
29
|
-
const getState = () => {
|
|
30
|
-
if (state === null) {
|
|
31
|
-
throw new Error("The state has not been initialized, make sure to call initState beforehand");
|
|
32
|
-
}
|
|
33
|
-
return __spreadValues({}, state);
|
|
34
|
-
};
|
|
35
|
-
const checkInit = () => {
|
|
36
|
-
return !!state;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { checkInit, getState, initState, setState };
|
|
40
|
-
//# sourceMappingURL=bundle.esm.js.map
|
package/dist/bundle.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.esm.js","sources":["../src/lib/state.ts"],"sourcesContent":["// Common functions and data\n\n/**\n * @since 0.1.0\n * @typedef State\n */\ntype State = Record<string, any>;\n\n/**\n * Global state.\n * @since 0.1.0\n */\nlet state: State | null = null;\n\n/**\n * Initializes the global state.\n *\n * @since 0.1.0\n * @param {T} initialState Initial global state\n */\nexport const initState = <T extends State>(initialState: T) => {\n Object.freeze(initialState);\n state = { ...initialState } as T;\n Object.seal(state);\n};\n\n/**\n * Updates the global state.\n *\n * @since 0.1.0\n * @param {T} overrides Global state overrides\n */\nexport const setState = <T extends State>(overrides: Partial<T>) => {\n const tempState = state ? { ...state } : {};\n state = null;\n state = { ...tempState, ...overrides } as T;\n Object.seal(state);\n};\n\n/**\n * Returns the global state.\n *\n * @since 0.1.0\n * @returns {T} The global state\n */\nexport const getState = <T extends State>() => {\n if (state === null) {\n throw new Error(\n \"The state has not been initialized, make sure to call initState beforehand\"\n );\n }\n return { ...state } as T;\n};\n\n/**\n * Returns whether the state has been initialized.\n *\n * @since 0.1.0\n * @returns {boolean} Whether the state has been initialized\n */\nexport const checkInit = () => {\n return !!state;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,IAAI,QAAsB;MAQb,YAAY,CAAkB,iBAAoB;AAC7D,SAAO,OAAO;AACd,UAAQ,mBAAK;AACb,SAAO,KAAK;AAAA;MASD,WAAW,CAAkB,cAA0B;AAClE,QAAM,YAAY,QAAQ,mBAAK,SAAU;AACzC,UAAQ;AACR,UAAQ,kCAAK,YAAc;AAC3B,SAAO,KAAK;AAAA;MASD,WAAW,MAAuB;AAC7C,MAAI,UAAU,MAAM;AAClB,UAAM,IAAI,MACR;AAAA;AAGJ,SAAO,mBAAK;AAAA;MASD,YAAY,MAAM;AAC7B,SAAO,CAAC,CAAC;AAAA;;;;"}
|