@nsshunt/stsvueutils 0.0.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 nsshunt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # stsvueutils
2
+ Vue 3 framework utilities and plugins
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./plugins/stsPluginKeys"), exports);
18
+ __exportStar(require("./plugins/emitter"), exports);
19
+ __exportStar(require("./plugins/storage"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC;AAEvC,oDAAiC;AACjC,oDAAiC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ describe("Test Latency Controller", () => {
3
+ test('Testing Module', async () => {
4
+ expect.assertions(1);
5
+ expect(1).toEqual(1);
6
+ });
7
+ });
8
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":";AACA,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IAExC,IAAI,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;QAEjC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.STSEmitterPlugin = exports.useSTSEmitterPlugin = void 0;
27
+ const vue_1 = require("vue");
28
+ const stsPluginKeys_1 = require("./stsPluginKeys");
29
+ const te = __importStar(require("tiny-emitter"));
30
+ // Create our use composable. This pattern is also used by vue router library with the useRoute and useRouter composables.
31
+ // https://skirtles-code.github.io/vue-examples/patterns/global-properties.html#application-level-provide-inject
32
+ const useSTSEmitterPlugin = () => (0, vue_1.inject)(stsPluginKeys_1.STSEmitterPluginKey);
33
+ exports.useSTSEmitterPlugin = useSTSEmitterPlugin;
34
+ // https://learnvue.co/2021/06/building-your-own-vue-3-plugin-a-full-guide/
35
+ exports.STSEmitterPlugin = {
36
+ install: (app) => {
37
+ const tinyEmitter = new te.TinyEmitter();
38
+ // Assign plugin instance to global $sts object (legacy method - see below)
39
+ if (!app.config.globalProperties.$sts) {
40
+ app.config.globalProperties.$sts = {};
41
+ }
42
+ app.config.globalProperties.$sts[stsPluginKeys_1.STSEmitterPluginKey] = tinyEmitter;
43
+ // Assign App level provide for this STS plugin using symbol keys
44
+ // https://vuejs.org/guide/components/provide-inject.html#working-with-symbol-keys
45
+ app.provide(stsPluginKeys_1.STSEmitterPluginKey, tinyEmitter);
46
+ }
47
+ };
48
+ //# sourceMappingURL=emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/plugins/emitter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA4B;AAE5B,mDAAsD;AAEtD,iDAAmC;AAEnC,0HAA0H;AAC1H,gHAAgH;AACzG,MAAM,mBAAmB,GAAG,GAAmB,EAAE,CAAC,IAAA,YAAM,EAAC,mCAAmB,CAAmB,CAAA;AAAzF,QAAA,mBAAmB,uBAAsE;AAEtG,2EAA2E;AAC9D,QAAA,gBAAgB,GAAG;IAC/B,OAAO,EAAE,CAAC,GAAQ,EAAE,EAAE;QACrB,MAAM,WAAW,GAAmB,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAEzD,2EAA2E;QAC3E,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;YACtC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,GAAG,EAAG,CAAC;SACvC;QACD,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,mCAAmB,CAAC,GAAG,WAAW,CAAC;QAEpE,iEAAiE;QACjE,kFAAkF;QAClF,GAAG,CAAC,OAAO,CAAC,mCAAmB,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC;CACD,CAAA"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STSStoragePlugin = exports.useSTSStoragePlugin = void 0;
4
+ const vue_1 = require("vue");
5
+ // Declare STS plugin keys (for provide)
6
+ // https://vuejs.org/guide/components/provide-inject.html#working-with-symbol-keys
7
+ const stsPluginKeys_1 = require("./stsPluginKeys");
8
+ const stsStorage_1 = require("./stsStorage");
9
+ // Create our use composable. This pattern is also used by vue router library with the useRoute and useRouter composables.
10
+ // https://skirtles-code.github.io/vue-examples/patterns/global-properties.html#application-level-provide-inject
11
+ const useSTSStoragePlugin = () => (0, vue_1.inject)(stsPluginKeys_1.STSStoragePluginKey);
12
+ exports.useSTSStoragePlugin = useSTSStoragePlugin;
13
+ // https://learnvue.co/2021/06/building-your-own-vue-3-plugin-a-full-guide/
14
+ exports.STSStoragePlugin = {
15
+ install: (app, options) => {
16
+ const cs = new stsStorage_1.ClientStorageFactory({ clientStorageType: options.clientStorageType, usePrefix: true });
17
+ const pluginInstance = cs.GetStorage();
18
+ // Assign plugin instance to global $sts object (legacy method - see below)
19
+ // This allows access to the $sts property within templates.
20
+ // Also, outside of script setup or setup(), this.$sts can be used.
21
+ // If access is required within script setup, use the useSTSStoragePlugin composable function. Example;
22
+ // import { useSTSStoragePlugin } from './storage';
23
+ // const STSStorageString = useSTSStoragePlugin<string>();
24
+ //
25
+ // Note: An alternate to get access to this global is to use the hidden API call such as;
26
+ // const app: ComponentInternalInstance | null = getCurrentInstance();
27
+ // Assign the $sts plugin helper (legacy method - see below (injects) for updated usage)
28
+ // let $sts: any
29
+ // if (app) $sts = app.appContext.config.globalProperties.$sts;
30
+ if (!app.config.globalProperties.$sts) {
31
+ app.config.globalProperties.$sts = {};
32
+ }
33
+ app.config.globalProperties.$sts[stsPluginKeys_1.STSStoragePluginKey] = pluginInstance;
34
+ // Assign App level provide for this STS plugin using symbol keys
35
+ // https://vuejs.org/guide/components/provide-inject.html#working-with-symbol-keys
36
+ app.provide(stsPluginKeys_1.STSStoragePluginKey, pluginInstance);
37
+ }
38
+ };
39
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/plugins/storage.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,wCAAwC;AACxC,kFAAkF;AAClF,mDAAsD;AAEtD,6CAAwF;AAMxF,0HAA0H;AAC1H,gHAAgH;AACzG,MAAM,mBAAmB,GAAG,GAAsB,EAAE,CAAC,IAAA,YAAM,EAAC,mCAAmB,CAAmB,CAAA;AAA5F,QAAA,mBAAmB,uBAAyE;AAEzG,2EAA2E;AAC9D,QAAA,gBAAgB,GAAG;IAC/B,OAAO,EAAE,CAAI,GAAQ,EAAE,OAAiC,EAAE,EAAE;QAC3D,MAAM,EAAE,GAAG,IAAI,iCAAoB,CAAI,EAAC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;QAExG,MAAM,cAAc,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC;QAEvC,2EAA2E;QAC3E,4DAA4D;QAC5D,mEAAmE;QACnE,uGAAuG;QACvG,mDAAmD;QACnD,0DAA0D;QAC1D,EAAE;QACF,yFAAyF;QACzF,sEAAsE;QACtE,wFAAwF;QACxF,gBAAgB;QAChB,+DAA+D;QAE/D,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;YACtC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,GAAG,EAAG,CAAC;SACvC;QACD,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,mCAAmB,CAAC,GAAG,cAAc,CAAC;QAEvE,iEAAiE;QACjE,kFAAkF;QAClF,GAAG,CAAC,OAAO,CAAC,mCAAmB,EAAE,cAAc,CAAC,CAAC;IAClD,CAAC;CACD,CAAA"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.STSEmitterPluginKey = exports.STSStoragePluginKey = void 0;
4
+ // Individual STS plugin keys for provide/inject logic
5
+ exports.STSStoragePluginKey = Symbol('storage');
6
+ exports.STSEmitterPluginKey = Symbol('emitter');
7
+ //# sourceMappingURL=stsPluginKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsPluginKeys.js","sourceRoot":"","sources":["../../src/plugins/stsPluginKeys.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACzC,QAAA,mBAAmB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;AACvC,QAAA,mBAAmB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ClientStorageFactory = exports.ClientStorageType = void 0;
7
+ const debug_1 = __importDefault(require("debug"));
8
+ const debug = (0, debug_1.default)(`proc:${process.pid}:storage.ts`);
9
+ const js_cookie_1 = __importDefault(require("js-cookie"));
10
+ let PREFIX = '_ststra_';
11
+ var ClientStorageType;
12
+ (function (ClientStorageType) {
13
+ ClientStorageType["LOCAL_STORAGE"] = "LocalStorage";
14
+ ClientStorageType["SESSION_STORAGE"] = "SessionStorage";
15
+ ClientStorageType["COOKIE_STORAGE"] = "CookieStorage";
16
+ ClientStorageType["MEMORY_STORAGE"] = "MemoryStorage"; //@@ todo
17
+ })(ClientStorageType = exports.ClientStorageType || (exports.ClientStorageType = {}));
18
+ class CookieStorage {
19
+ get = (key) => {
20
+ const raw = js_cookie_1.default.get(PREFIX + key);
21
+ if (raw) {
22
+ return JSON.parse(raw);
23
+ }
24
+ else {
25
+ return null;
26
+ }
27
+ };
28
+ set = (key, value, options = {}) => {
29
+ let cookieAttributes = {};
30
+ if ('https:' === window.location.protocol) {
31
+ cookieAttributes = {
32
+ secure: true,
33
+ sameSite: 'none'
34
+ };
35
+ }
36
+ if (options && options.daysUntilExpire) {
37
+ cookieAttributes.expires = options.daysUntilExpire;
38
+ }
39
+ else {
40
+ cookieAttributes.expires = 1;
41
+ }
42
+ debug(`CookieStorage.set: key: ${key}, value: [${value}]`);
43
+ js_cookie_1.default.set(PREFIX + key, JSON.stringify(value), cookieAttributes);
44
+ };
45
+ remove = (key) => {
46
+ js_cookie_1.default.remove(PREFIX + key);
47
+ };
48
+ }
49
+ class SessionStorage {
50
+ get = (key) => {
51
+ const value = sessionStorage.getItem(PREFIX + key);
52
+ if (value) {
53
+ return JSON.parse(value);
54
+ }
55
+ else {
56
+ return null;
57
+ }
58
+ };
59
+ set = (key, value) => {
60
+ debug(`SessionStorage.set: key: ${key}, value: [${value}]`);
61
+ sessionStorage.setItem(PREFIX + key, JSON.stringify(value));
62
+ };
63
+ remove = (key) => {
64
+ sessionStorage.removeItem(PREFIX + key);
65
+ };
66
+ }
67
+ class LocalStorage {
68
+ get = (key) => {
69
+ const value = localStorage.getItem(PREFIX + key);
70
+ if (value) {
71
+ return JSON.parse(value);
72
+ }
73
+ else {
74
+ return null;
75
+ }
76
+ };
77
+ set = (key, value) => {
78
+ debug(`LocalStorage.set: key: ${key}, value: [${value}]`);
79
+ localStorage.setItem(PREFIX + key, JSON.stringify(value));
80
+ };
81
+ remove = (key) => {
82
+ localStorage.removeItem(PREFIX + key);
83
+ };
84
+ }
85
+ class MemoryStorage {
86
+ #store = {};
87
+ get = (key) => {
88
+ const value = this.#store[PREFIX + key];
89
+ if (value) {
90
+ return value;
91
+ }
92
+ else {
93
+ return null;
94
+ }
95
+ };
96
+ set = (key, value) => {
97
+ debug(`MemoryStorage.set: key: ${key}, value: [${value}]`);
98
+ this.#store[PREFIX + key] = value;
99
+ };
100
+ remove = (key) => {
101
+ delete this.#store[PREFIX + key];
102
+ };
103
+ }
104
+ class ClientStorageFactory {
105
+ #storage;
106
+ constructor(options) {
107
+ if (options.usePrefix === false) {
108
+ PREFIX = '';
109
+ }
110
+ switch (options.clientStorageType) {
111
+ case ClientStorageType.SESSION_STORAGE:
112
+ this.#storage = new SessionStorage();
113
+ break;
114
+ case ClientStorageType.LOCAL_STORAGE:
115
+ this.#storage = new LocalStorage();
116
+ break;
117
+ case ClientStorageType.COOKIE_STORAGE:
118
+ this.#storage = new CookieStorage();
119
+ break;
120
+ case ClientStorageType.MEMORY_STORAGE:
121
+ this.#storage = new MemoryStorage();
122
+ break;
123
+ default:
124
+ throw new Error(`Unknown [${options.clientStorageType}] storage type.`);
125
+ }
126
+ return;
127
+ }
128
+ GetStorage() {
129
+ return this.#storage;
130
+ }
131
+ }
132
+ exports.ClientStorageFactory = ClientStorageFactory;
133
+ //# sourceMappingURL=stsStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsStorage.js","sourceRoot":"","sources":["../../src/plugins/stsStorage.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,QAAQ,OAAO,CAAC,GAAG,aAAa,CAAC,CAAC;AAEtD,0DAA+B;AAG/B,IAAI,MAAM,GAAG,UAAU,CAAC;AAQxB,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC5B,mDAA8B,CAAA;IAC9B,uDAAkC,CAAA;IAClC,qDAAgC,CAAA;IAChC,qDAAgC,CAAA,CAAC,SAAS;AAC3C,CAAC,EALW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAK5B;AAED,MAAM,aAAa;IAElB,GAAG,GAAG,CAAC,GAAW,EAAY,EAAE;QAC/B,MAAM,GAAG,GAAG,mBAAO,CAAC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;QACtC,IAAI,GAAG,EAAE;YACR,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACvB;aAAM;YACN,OAAO,IAAI,CAAC;SACZ;IACF,CAAC,CAAA;IAED,GAAG,GAAG,CAAC,GAAW,EAAE,KAAQ,EAAE,UAAsB,EAAG,EAAE,EAAE;QAC1D,IAAI,gBAAgB,GAA6B,EAAG,CAAC;QACrD,IAAI,QAAQ,KAAK,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE;YAC1C,gBAAgB,GAAG;gBAClB,MAAM,EAAE,IAAI;gBACZ,QAAQ,EAAE,MAAM;aAChB,CAAC;SACF;QAED,IAAI,OAAO,IAAI,OAAO,CAAC,eAAe,EAAE;YACvC,gBAAgB,CAAC,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;SACnD;aAAM;YACN,gBAAgB,CAAC,OAAO,GAAG,CAAC,CAAC;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AI,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAK,CAAC;gBACxC,MAAM;YACP,KAAK,iBAAiB,CAAC,aAAa;gBACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAK,CAAC;gBACtC,MAAM;YACP,KAAK,iBAAiB,CAAC,cAAc;gBACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAK,CAAC;gBACvC,MAAM;YACP,KAAK,iBAAiB,CAAC,cAAc;gBACpC,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,EAAK,CAAC;gBACvC,MAAM;YACP;gBACC,MAAM,IAAI,KAAK,CAAC,YAAY,OAAO,CAAC,iBAAiB,iBAAiB,CAAC,CAAC;SACxE;QACD,OAAO;IACR,CAAC;IAED,UAAU;QAET,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;CACD;AA/BD,oDA+BC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@nsshunt/stsvueutils",
3
+ "version": "0.0.6",
4
+ "description": "Vue 3 framework utilities and plugins",
5
+ "main": "dist/index.js",
6
+ "types": "./types/index.d.ts",
7
+ "scripts": {
8
+ "lint": "eslint . --ext js,jsx,ts,tsx --fix",
9
+ "test": "jest --detectOpenHandles --no-cache",
10
+ "testwatch": "jest --watchAll --detectOpenHandles --no-cache",
11
+ "build": "tsc"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/nsshunt/stsvueutils.git"
16
+ },
17
+ "files": [
18
+ "dist/*",
19
+ "types/*",
20
+ "LICENSE",
21
+ "README.md"
22
+ ],
23
+ "author": "STS",
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/nsshunt/stsvueutils/issues"
27
+ },
28
+ "homepage": "https://github.com/nsshunt/stsvueutils#readme",
29
+ "devDependencies": {
30
+ "@babel/preset-env": "^7.20.2",
31
+ "@babel/preset-typescript": "^7.21.0",
32
+ "@tsconfig/node18": "^1.0.1",
33
+ "@types/debug": "^4.1.7",
34
+ "@types/jest": "^29.4.0",
35
+ "@types/js-cookie": "^3.0.3",
36
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
37
+ "@typescript-eslint/parser": "^5.54.1",
38
+ "eslint": "^8.35.0",
39
+ "jest": "^29.5.0",
40
+ "prettier": "^2.8.4",
41
+ "supertest": "^6.3.3",
42
+ "ts-loader": "^9.4.2",
43
+ "typescript": "^4.9.5",
44
+ "vue": "^3.2.47"
45
+ },
46
+ "dependencies": {
47
+ "@nsshunt/stsutils": "^1.15.6",
48
+ "js-cookie": "^3.0.1",
49
+ "tiny-emitter": "^2.1.0"
50
+ }
51
+ }
@@ -0,0 +1,4 @@
1
+ export * from './plugins/stsPluginKeys';
2
+ export * from './plugins/emitter';
3
+ export * from './plugins/storage';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AAEvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import * as te from 'tiny-emitter';
2
+ export declare const useSTSEmitterPlugin: () => te.TinyEmitter;
3
+ export declare const STSEmitterPlugin: {
4
+ install: (app: any) => void;
5
+ };
6
+ //# sourceMappingURL=emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/plugins/emitter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,cAAc,CAAC;AAInC,eAAO,MAAM,mBAAmB,QAAO,GAAG,WAA4D,CAAA;AAGtG,eAAO,MAAM,gBAAgB;mBACb,GAAG;CAalB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { ClientStorageType, type IStsStorage } from './stsStorage';
2
+ export interface ISTSStoragePluginOptions {
3
+ clientStorageType: ClientStorageType;
4
+ }
5
+ export declare const useSTSStoragePlugin: <T>() => IStsStorage<T>;
6
+ export declare const STSStoragePlugin: {
7
+ install: <T>(app: any, options: ISTSStoragePluginOptions) => void;
8
+ };
9
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/plugins/storage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAwB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAExF,MAAM,WAAW,wBAAwB;IACxC,iBAAiB,EAAE,iBAAiB,CAAA;CACpC;AAID,eAAO,MAAM,mBAAmB,yBAAyE,CAAA;AAGzG,eAAO,MAAM,gBAAgB;sBACV,GAAG,WAAW,wBAAwB;CA2BxD,CAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const STSStoragePluginKey: unique symbol;
2
+ export declare const STSEmitterPluginKey: unique symbol;
3
+ //# sourceMappingURL=stsPluginKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsPluginKeys.d.ts","sourceRoot":"","sources":["../../src/plugins/stsPluginKeys.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,mBAAmB,eAAoB,CAAA;AACpD,eAAO,MAAM,mBAAmB,eAAoB,CAAA"}
@@ -0,0 +1,23 @@
1
+ import type { JSONObject } from "@nsshunt/stsutils";
2
+ export interface IStsStorage<T> {
3
+ get(key: string): T | null;
4
+ set(key: string, value: T, options?: JSONObject): void;
5
+ remove(key: string): void;
6
+ }
7
+ export declare enum ClientStorageType {
8
+ LOCAL_STORAGE = "LocalStorage",
9
+ SESSION_STORAGE = "SessionStorage",
10
+ COOKIE_STORAGE = "CookieStorage",
11
+ MEMORY_STORAGE = "MemoryStorage"
12
+ }
13
+ export interface IClientStorageOptions {
14
+ clientStorageType: ClientStorageType;
15
+ usePrefix: boolean;
16
+ storageOptions?: JSONObject;
17
+ }
18
+ export declare class ClientStorageFactory<T> {
19
+ #private;
20
+ constructor(options: IClientStorageOptions);
21
+ GetStorage(): IStsStorage<T>;
22
+ }
23
+ //# sourceMappingURL=stsStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stsStorage.d.ts","sourceRoot":"","sources":["../../src/plugins/stsStorage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAAA;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IACtD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,oBAAY,iBAAiB;IAC5B,aAAa,iBAAiB;IAC9B,eAAe,mBAAmB;IAClC,cAAc,kBAAkB;IAChC,cAAc,kBAAkB;CAChC;AAqGD,MAAM,WAAW,qBAAqB;IACrC,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,CAAC,EAAE,UAAU,CAAA;CAC3B;AAED,qBAAa,oBAAoB,CAAC,CAAC;;gBAItB,OAAO,EAAE,qBAAqB;IAuB1C,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC;CAI5B"}