@webkrafters/eagleeye 1.0.0-beta.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/LICENSE +674 -0
- package/README.md +150 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +68 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +108 -0
- package/dist/main/index.d.ts +78 -0
- package/dist/main/index.js +1062 -0
- package/dist/model/storage/index.d.ts +20 -0
- package/dist/model/storage/index.js +108 -0
- package/logo.png +0 -0
- package/package.json +104 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IStorage, State } from '../..';
|
|
2
|
+
export declare class MemoryStorage<T extends State> implements IStorage<T> {
|
|
3
|
+
private _data;
|
|
4
|
+
constructor();
|
|
5
|
+
clone(data: T): T;
|
|
6
|
+
getItem(key: string): T;
|
|
7
|
+
removeItem(key: string): void;
|
|
8
|
+
setItem(key: string, data: T): void;
|
|
9
|
+
}
|
|
10
|
+
declare class Storage<T extends State> implements IStorage<T> {
|
|
11
|
+
private _storage;
|
|
12
|
+
static supportsSession: boolean;
|
|
13
|
+
constructor();
|
|
14
|
+
get isKeyRequired(): boolean;
|
|
15
|
+
clone(data: any): T;
|
|
16
|
+
getItem(key: string): T;
|
|
17
|
+
removeItem(key: string): void;
|
|
18
|
+
setItem(key: string, data: T): void;
|
|
19
|
+
}
|
|
20
|
+
export default Storage;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _globalThis$sessionSt;
|
|
4
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
6
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
7
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : {
|
|
12
|
+
"default": mod
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
exports.MemoryStorage = void 0;
|
|
19
|
+
var clone_total_1 = __importDefault(require("@webkrafters/clone-total"));
|
|
20
|
+
var MemoryStorage = /*#__PURE__*/function () {
|
|
21
|
+
function MemoryStorage() {
|
|
22
|
+
_classCallCheck(this, MemoryStorage);
|
|
23
|
+
this._data = null;
|
|
24
|
+
}
|
|
25
|
+
return _createClass(MemoryStorage, [{
|
|
26
|
+
key: "clone",
|
|
27
|
+
value: function clone(data) {
|
|
28
|
+
return (0, clone_total_1["default"])(data);
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
key: "getItem",
|
|
32
|
+
value: function getItem(key) {
|
|
33
|
+
return this._data;
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
key: "removeItem",
|
|
37
|
+
value: function removeItem(key) {
|
|
38
|
+
this._data = null;
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "setItem",
|
|
42
|
+
value: function setItem(key, data) {
|
|
43
|
+
this._data = data;
|
|
44
|
+
}
|
|
45
|
+
}]);
|
|
46
|
+
}();
|
|
47
|
+
exports.MemoryStorage = MemoryStorage;
|
|
48
|
+
var SessionStorage = /*#__PURE__*/function () {
|
|
49
|
+
function SessionStorage() {
|
|
50
|
+
_classCallCheck(this, SessionStorage);
|
|
51
|
+
this._storage = globalThis.sessionStorage;
|
|
52
|
+
}
|
|
53
|
+
return _createClass(SessionStorage, [{
|
|
54
|
+
key: "clone",
|
|
55
|
+
value: function clone(data) {
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "getItem",
|
|
60
|
+
value: function getItem(key) {
|
|
61
|
+
return JSON.parse(this._storage.getItem(key));
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "removeItem",
|
|
65
|
+
value: function removeItem(key) {
|
|
66
|
+
return this._storage.removeItem(key);
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "setItem",
|
|
70
|
+
value: function setItem(key, data) {
|
|
71
|
+
return this._storage.setItem(key, JSON.stringify(data));
|
|
72
|
+
}
|
|
73
|
+
}]);
|
|
74
|
+
}();
|
|
75
|
+
var Storage = /*#__PURE__*/function () {
|
|
76
|
+
function Storage() {
|
|
77
|
+
_classCallCheck(this, Storage);
|
|
78
|
+
this._storage = Storage.supportsSession ? new SessionStorage() : new MemoryStorage();
|
|
79
|
+
}
|
|
80
|
+
return _createClass(Storage, [{
|
|
81
|
+
key: "isKeyRequired",
|
|
82
|
+
get: function get() {
|
|
83
|
+
return this._storage instanceof SessionStorage;
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
86
|
+
key: "clone",
|
|
87
|
+
value: function clone(data) {
|
|
88
|
+
return this._storage.clone(data);
|
|
89
|
+
}
|
|
90
|
+
}, {
|
|
91
|
+
key: "getItem",
|
|
92
|
+
value: function getItem(key) {
|
|
93
|
+
return this._storage.getItem(key);
|
|
94
|
+
}
|
|
95
|
+
}, {
|
|
96
|
+
key: "removeItem",
|
|
97
|
+
value: function removeItem(key) {
|
|
98
|
+
this._storage.removeItem(key);
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "setItem",
|
|
102
|
+
value: function setItem(key, data) {
|
|
103
|
+
this._storage.setItem(key, data);
|
|
104
|
+
}
|
|
105
|
+
}]);
|
|
106
|
+
}();
|
|
107
|
+
Storage.supportsSession = typeof ((_globalThis$sessionSt = globalThis.sessionStorage) === null || _globalThis$sessionSt === void 0 ? void 0 : _globalThis$sessionSt.setItem) !== 'undefined';
|
|
108
|
+
exports["default"] = Storage;
|
package/logo.png
ADDED
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"alias": "Eagle eye context",
|
|
3
|
+
"author": "Stephen Isienyi <stephen.isienyi@webkrafting.com>",
|
|
4
|
+
"bugs": {
|
|
5
|
+
"url": "https://github.com/webKrafters/eagleeye.js/issues"
|
|
6
|
+
},
|
|
7
|
+
"contributors": [
|
|
8
|
+
"steveswork <stephen.isienyi@gmail.com> (https://github.com/steveswork)"
|
|
9
|
+
],
|
|
10
|
+
"description": "Context stream - Observable and Update-friendly immutable data.",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@babel/cli": "^7.17.0",
|
|
13
|
+
"@babel/core": "^7.20.5",
|
|
14
|
+
"@babel/node": "^7.12.10",
|
|
15
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
|
16
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
17
|
+
"@babel/preset-env": "^7.20.2",
|
|
18
|
+
"@testing-library/jest-dom": "^6.4.5",
|
|
19
|
+
"@testing-library/user-event": "^14.4.3",
|
|
20
|
+
"@types/jest": "^29.5.12",
|
|
21
|
+
"@types/jest-cli": "^24.3.0",
|
|
22
|
+
"@types/lodash.isempty": "^4.4.9",
|
|
23
|
+
"@types/lodash.isplainobject": "^4.0.9",
|
|
24
|
+
"@types/node": "^20.11.28",
|
|
25
|
+
"@webkrafters/clone-total": "^1.0.1",
|
|
26
|
+
"@webkrafters/get-property": "^2.0.0",
|
|
27
|
+
"@webkrafters/path-dotize": "0.0.2",
|
|
28
|
+
"@webkrafters/timed-map": "^2.0.0",
|
|
29
|
+
"babel-loader": "^9.1.3",
|
|
30
|
+
"eslint": "^8.57.0",
|
|
31
|
+
"eslint-config-standard": "^17.1.0",
|
|
32
|
+
"eslint-plugin-import": "^2.22.1",
|
|
33
|
+
"eslint-plugin-jest": "^28.5.0",
|
|
34
|
+
"eslint-plugin-node": "^11.1.0",
|
|
35
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
36
|
+
"eslint-plugin-standard": "^5.0.0",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"jest-cli": "^29.7.0",
|
|
39
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
40
|
+
"lodash.clonedeep": "^4.5.0",
|
|
41
|
+
"lodash.clonedeepwith": "^4.5.0",
|
|
42
|
+
"lodash.isboolean": "^3.0.3",
|
|
43
|
+
"lodash.isempty": "^4.4.0",
|
|
44
|
+
"lodash.isequal": "^4.5.0",
|
|
45
|
+
"lodash.isinteger": "^4.0.4",
|
|
46
|
+
"lodash.isobject": "^3.0.2",
|
|
47
|
+
"lodash.isplainobject": "^4.0.6",
|
|
48
|
+
"lodash.omit": "^4.5.0",
|
|
49
|
+
"lodash.set": "^4.3.2",
|
|
50
|
+
"setimmediate": "^1.0.5",
|
|
51
|
+
"ts-jest": "^29.1.2",
|
|
52
|
+
"ts-node": "^10.9.2",
|
|
53
|
+
"typescript": "^5.4.5"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"logo.png",
|
|
57
|
+
"dist"
|
|
58
|
+
],
|
|
59
|
+
"homepage": "https://eagleeye.js.org",
|
|
60
|
+
"keywords": [
|
|
61
|
+
"context",
|
|
62
|
+
"eagle eye",
|
|
63
|
+
"observable",
|
|
64
|
+
"observable context",
|
|
65
|
+
"immutable",
|
|
66
|
+
"immutable context",
|
|
67
|
+
"context stream",
|
|
68
|
+
"state",
|
|
69
|
+
"state management",
|
|
70
|
+
"state manager"
|
|
71
|
+
],
|
|
72
|
+
"license": "MIT",
|
|
73
|
+
"main": "dist/index.js",
|
|
74
|
+
"name": "@webkrafters/eagleeye",
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"@webkrafters/clone-total": ">= 1.0.1",
|
|
77
|
+
"@webkrafters/path-dotize": ">= 0.0.2",
|
|
78
|
+
"lodash.isboolean": ">= 0.1.0",
|
|
79
|
+
"lodash.isempty": ">= 0.1.0",
|
|
80
|
+
"lodash.isequal": ">= 0.1.0",
|
|
81
|
+
"lodash.isplainobject": ">= 0.8.0",
|
|
82
|
+
"lodash.omit": ">= 0.1.0",
|
|
83
|
+
"lodash.set": ">= 0.1.0"
|
|
84
|
+
},
|
|
85
|
+
"publishConfig": {
|
|
86
|
+
"access": "public"
|
|
87
|
+
},
|
|
88
|
+
"repository": {
|
|
89
|
+
"type": "git",
|
|
90
|
+
"url": "git+https://github.com/webKrafters/eagleeye.js.git"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "eslint --fix && rm -rf dist && tsc && babel dist -d dist",
|
|
94
|
+
"test": "eslint --fix && jest --coverage --updateSnapshot",
|
|
95
|
+
"test:clean": "jest --clearCache",
|
|
96
|
+
"test:core": "jest --updateSnapshot",
|
|
97
|
+
"test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
|
|
98
|
+
},
|
|
99
|
+
"types": "dist/index.d.ts",
|
|
100
|
+
"version": "1.0.0-beta.0",
|
|
101
|
+
"dependencies": {
|
|
102
|
+
"@webkrafters/auto-immutable": "^2.0.5"
|
|
103
|
+
}
|
|
104
|
+
}
|