@artisan-commerce/state 0.3.0-canary.1 → 0.3.0-canary.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [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)
7
+
8
+ **Note:** Version bump only for package @artisan-commerce/state
9
+
10
+
11
+
12
+
13
+
6
14
  ## [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)
7
15
 
8
16
 
@@ -0,0 +1,47 @@
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
@@ -0,0 +1 @@
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;;;;;;;"}
@@ -9,26 +9,27 @@ declare type State = Record<string, any>;
9
9
  * @since 0.1.0
10
10
  * @param {T} initialState Initial global state
11
11
  */
12
- export declare const initState: <T extends State>(initialState: T) => void;
12
+ declare const initState: <T extends State>(initialState: T) => void;
13
13
  /**
14
14
  * Updates the global state.
15
15
  *
16
16
  * @since 0.1.0
17
17
  * @param {T} overrides Global state overrides
18
18
  */
19
- export declare const setState: <T extends State>(overrides: Partial<T>) => void;
19
+ declare const setState: <T extends State>(overrides: Partial<T>) => void;
20
20
  /**
21
21
  * Returns the global state.
22
22
  *
23
23
  * @since 0.1.0
24
24
  * @returns {T} The global state
25
25
  */
26
- export declare const getState: <T extends State>() => T;
26
+ declare const getState: <T extends State>() => T;
27
27
  /**
28
28
  * Returns whether the state has been initialized.
29
29
  *
30
30
  * @since 0.1.0
31
31
  * @returns {boolean} Whether the state has been initialized
32
32
  */
33
- export declare const checkInit: () => boolean;
34
- export {};
33
+ declare const checkInit: () => boolean;
34
+
35
+ export { checkInit, getState, initState, setState };
@@ -0,0 +1,40 @@
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
@@ -0,0 +1 @@
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;;;;"}
@@ -0,0 +1,53 @@
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.ArtisnState = {}));
5
+ })(this, (function (exports) { 'use strict';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ let state = null;
24
+ const initState = (initialState) => {
25
+ Object.freeze(initialState);
26
+ state = __spreadValues({}, initialState);
27
+ Object.seal(state);
28
+ };
29
+ const setState = (overrides) => {
30
+ const tempState = state ? __spreadValues({}, state) : {};
31
+ state = null;
32
+ state = __spreadValues(__spreadValues({}, tempState), overrides);
33
+ Object.seal(state);
34
+ };
35
+ const getState = () => {
36
+ if (state === null) {
37
+ throw new Error("The state has not been initialized, make sure to call initState beforehand");
38
+ }
39
+ return __spreadValues({}, state);
40
+ };
41
+ const checkInit = () => {
42
+ return !!state;
43
+ };
44
+
45
+ exports.checkInit = checkInit;
46
+ exports.getState = getState;
47
+ exports.initState = initState;
48
+ exports.setState = setState;
49
+
50
+ Object.defineProperty(exports, '__esModule', { value: true });
51
+
52
+ }));
53
+ //# sourceMappingURL=bundle.umd.js.map
@@ -0,0 +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 */\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":";;;;;;;;;;;;;;;;;;;;;;EAYA,IAAI,QAAsB;QAQb,YAAY,CAAkB,iBAAoB;EAC7D,SAAO,OAAO;EACd,UAAQ,mBAAK;EACb,SAAO,KAAK;EAAA;QASD,WAAW,CAAkB,cAA0B;EAClE,QAAM,YAAY,QAAQ,mBAAK,SAAU;EACzC,UAAQ;EACR,UAAQ,kCAAK,YAAc;EAC3B,SAAO,KAAK;EAAA;QASD,WAAW,MAAuB;EAC7C,MAAI,UAAU,MAAM;EAClB,UAAM,IAAI,MACR;EAAA;EAGJ,SAAO,mBAAK;EAAA;QASD,YAAY,MAAM;EAC7B,SAAO,CAAC,CAAC;EAAA;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,19 +1,28 @@
1
1
  {
2
2
  "name": "@artisan-commerce/state",
3
3
  "description": "Library used to share state functionality",
4
- "version": "0.3.0-canary.1",
5
- "main": "./build/main.bundle.js",
6
- "types": "./build/index.d.ts",
4
+ "version": "0.3.0-canary.2",
5
+ "main": "./dist/bundle.cjs.js",
6
+ "module": "./dist/bundle.esm.js",
7
+ "types": "./dist/bundle.d.ts",
7
8
  "files": [
8
- "build/",
9
- "LICENSE",
10
- "README.md"
9
+ "dist"
11
10
  ],
11
+ "sideEffects": false,
12
+ "type": "module",
13
+ "exports": {
14
+ "node": {
15
+ "import": "./dist/bundle.esm.js",
16
+ "require": "./dist/bundle.cjs.js"
17
+ },
18
+ "default": "./dist/bundle.esm.js"
19
+ },
12
20
  "scripts": {
13
- "compile": "webpack --config webpack.dev.js",
14
- "dev": "yarn compile",
15
- "build": "webpack --config webpack.prod.js",
16
- "compile:build": "nodemon ./build/main.bundle.js",
21
+ "compile": "rollup -c",
22
+ "dev": "yarn compile -w",
23
+ "clean": "rimraf dist",
24
+ "prebuild": "yarn clean",
25
+ "build": "yarn compile",
17
26
  "test": "jest --watchAll --runInBand",
18
27
  "test:all": "yarn test --watchAll=false --coverage",
19
28
  "test:ci": "cross-env CI=true jest --runInBand",
@@ -41,8 +50,6 @@
41
50
  "@typescript-eslint/parser": "^3.7.0",
42
51
  "avn": "^0.2.4",
43
52
  "avn-nvm": "^0.2.2",
44
- "clean-webpack-plugin": "^3.0.0",
45
- "dotenv-webpack": "^2.0.0",
46
53
  "env-cmd": "^10.1.0",
47
54
  "eslint": "^7.5.0",
48
55
  "eslint-config-prettier": "^6.11.0",
@@ -64,11 +71,7 @@
64
71
  "start-server-and-test": "^1.11.2",
65
72
  "test-data-bot": "^0.8.0",
66
73
  "ts-jest": "^26.1.4",
67
- "ts-loader": "^8.0.2",
68
- "webpack": "^4.43.0",
69
- "webpack-cli": "^3.3.12",
70
- "webpack-dev-server": "^3.11.0",
71
- "webpack-merge": "^5.0.9"
74
+ "ts-loader": "^8.0.2"
72
75
  },
73
- "gitHead": "8377bd39d1bc808b70f373295ad9197508c0f83a"
76
+ "gitHead": "c5ed66350df0202200e49ecb988dea46970e87fd"
74
77
  }
@@ -1,2 +0,0 @@
1
- declare const CONSTANTS: {};
2
- export default CONSTANTS;
package/build/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { checkInit, getState, initState, setState } from "./lib/state";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("state",[],t):"object"==typeof exports?exports.state=t():e.state=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([,function(e,t,n){"use strict";n.r(t),n.d(t,"checkInit",(function(){return c})),n.d(t,"getState",(function(){return f})),n.d(t,"initState",(function(){return u})),n.d(t,"setState",(function(){return i}));var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=null,u=function(e){Object.freeze(e),o=r({},e),Object.seal(o)},i=function(e){var t=o?r({},o):{};o=null,o=r(r({},t),e),Object.seal(o)},f=function(){if(null===o)throw new Error("The state has not been initialized, make sure to call initState beforehand");return r({},o)},c=function(){return!!o}}])}));
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("state",[],t):"object"==typeof exports?exports.state=t():e.state=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t)}])}));
@@ -1 +0,0 @@
1
- export {};