@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
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img alt="Eagle Eye" height="150px" src="logo.png" width="250px" />
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="https://typescriptlang.org">
|
|
6
|
+
<img alt="TypeScript" src="https://badgen.net/badge/icon/typescript?icon=typescript&label">
|
|
7
|
+
</a>
|
|
8
|
+
<a href="https://github.com/webKrafters/eagleeye.js/actions">
|
|
9
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/webKrafters/eagleeye.js/test.yml">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://coveralls.io/github/webKrafters/eagleeye.js">
|
|
12
|
+
<img alt="coverage" src="https://img.shields.io/coveralls/github/webKrafters/eagleeye.js">
|
|
13
|
+
</a>
|
|
14
|
+
<img alt="NPM" src="https://img.shields.io/npm/l/@webkrafters/eagleeye.js">
|
|
15
|
+
<img alt="Maintenance" src="https://img.shields.io/maintenance/yes/2032">
|
|
16
|
+
<img alt="build size" src="https://img.shields.io/bundlephobia/minzip/@webkrafters/eagleeye.js?label=bundle%20size">
|
|
17
|
+
<a href="https://www.npmjs.com/package/@webKrafters/eagleeye.js">
|
|
18
|
+
<img alt="Downloads" src="https://img.shields.io/npm/dt/@webkrafters/eagleeye.js.svg">
|
|
19
|
+
</a>
|
|
20
|
+
<img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/webKrafters/eagleeye.js">
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
# Eagle Eye.
|
|
24
|
+
|
|
25
|
+
**Name:** Eagle Eye.
|
|
26
|
+
|
|
27
|
+
**Install:**\
|
|
28
|
+
npm install --save @webkrafters/eagleeye
|
|
29
|
+
|
|
30
|
+
## Usage:
|
|
31
|
+
### Create (the FP way).
|
|
32
|
+
```tsx
|
|
33
|
+
import { createEagleEye } from '@webkrafters/eagleeye';
|
|
34
|
+
const context = createEagleEye({
|
|
35
|
+
prehooks?: Prehooks<T>,
|
|
36
|
+
storage?: Storage<T>,
|
|
37
|
+
value?: T|AutoImmutable<T>
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
### Create (the OOP way).
|
|
41
|
+
```tsx
|
|
42
|
+
import { EagleEyeContext } from '@webkrafters/eagleeye';
|
|
43
|
+
const context = new EagleEyeContext<T>(
|
|
44
|
+
T?|AutoImmutable<T>?,
|
|
45
|
+
Prehooks<T>?,
|
|
46
|
+
Storage<T>?
|
|
47
|
+
);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Releasing context resources.
|
|
51
|
+
```tsx
|
|
52
|
+
context.dispose();
|
|
53
|
+
```
|
|
54
|
+
Deactivates this context by:
|
|
55
|
+
<ol>
|
|
56
|
+
<li>unsubscribing all observers to it</li>
|
|
57
|
+
<li>severing connections to data stores</li>
|
|
58
|
+
<li>unsetting all resources</li>
|
|
59
|
+
</ol>
|
|
60
|
+
|
|
61
|
+
### Accessing external store reference.
|
|
62
|
+
```tsx
|
|
63
|
+
const store = context.store;
|
|
64
|
+
// https://eagleeye.js.org/concepts/store/resetstate/
|
|
65
|
+
store.resetState( Array<string>? );
|
|
66
|
+
// https://eagleeye.js.org/concepts/store/setstate/
|
|
67
|
+
store.setState( Changes<T> );
|
|
68
|
+
// https://eagleeye.js.org/concepts/store/getstate/
|
|
69
|
+
const state = store.getState( Array<string> );
|
|
70
|
+
// https://eagleeye.js.org/concepts/store/subscribe/
|
|
71
|
+
const unsubscribeFn = store.subscribe( eventType, listener );
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Connecting to context stream.
|
|
75
|
+
A context stream allows for a client to set up automatic update to to be automatically pushed to it whenever its slice of state changes.
|
|
76
|
+
```tsx
|
|
77
|
+
const useStream = context.stream;
|
|
78
|
+
// joining the stream twice
|
|
79
|
+
// for more on selectorMap - https://eagleeye.js.org/concepts/selector-map/
|
|
80
|
+
const streamer1 = useStream(SelectorMap?);
|
|
81
|
+
const streamer2 = useStream(SelectorMap?);
|
|
82
|
+
// check whether a streamer still defunct or still active
|
|
83
|
+
if( streamer1.closed ) { ... };
|
|
84
|
+
// access the current data value monitored by this streamer
|
|
85
|
+
console.log( 'data', streamer1.data );
|
|
86
|
+
// access the streamer current lifecycle
|
|
87
|
+
console.log( 'life cycle', streamer1.phase );
|
|
88
|
+
// check if the streamer is streaming
|
|
89
|
+
if( streamer1.streaming ) { ... };
|
|
90
|
+
// change a streamer's selector map
|
|
91
|
+
streamer1.seletorMap = SelectorMap<T>?;
|
|
92
|
+
// add listener to a streamer to react to live updates to selected data.
|
|
93
|
+
streamer1.addListener( 'data-changed', listener );
|
|
94
|
+
// be notified of a streamer's exist from streaming.
|
|
95
|
+
streamer1.addListener( 'stream-ending', listener );
|
|
96
|
+
// remove listener from a streamer activities
|
|
97
|
+
streamer1.removeListener( 'data-changed'|'stream-ending', listener );
|
|
98
|
+
// https://eagleeye.js.org/concepts/store/resetstate/
|
|
99
|
+
streamer1.resetState( Array<string>? ); // changes are context-wide
|
|
100
|
+
// https://eagleeye.js.org/concepts/store/setstate/
|
|
101
|
+
streamer1.setState( Changes<T> ); // changes are context-wide
|
|
102
|
+
// exit streamer from streaming
|
|
103
|
+
streamer1.endStream();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Accessing underlying cache.
|
|
107
|
+
```tsx
|
|
108
|
+
const cache = context.cache;
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Accessing `close` status.
|
|
112
|
+
```tsx
|
|
113
|
+
const closed = context.closed;
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Accessing current state update `prehooks`.
|
|
117
|
+
```tsx
|
|
118
|
+
const prehooks = context.prehooks;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Updating state update `prehooks`.
|
|
122
|
+
```tsx
|
|
123
|
+
context.prehooks = Prehooks<T>?;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Accessing context `storage`.
|
|
127
|
+
```tsx
|
|
128
|
+
const storage = context.storage;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Updating context `storage`.
|
|
132
|
+
```tsx
|
|
133
|
+
context.storage = storage<T>?;
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Notable Mentions:
|
|
137
|
+
<ul>
|
|
138
|
+
<li>Facilitates sharing of underlying immutable data structure among multiple applications</li>
|
|
139
|
+
<li>Update-friendly Auto-immutable bearing context. See <a href="https://eagleeye.js.org/concepts/store/setstate"><code>store.setState</code></a>.</li>
|
|
140
|
+
<li> Recognizes <b>negative array indexing</b>. Please see <a href="https://eagleeye.js.org/concepts/property-path">Property Path</a> and <code>store.setState</code> <a href="https://eagleeye.js.org/concepts/store/setstate#indexing">Indexing</a>.</li>
|
|
141
|
+
<li> Only automatically notifying subscribing or stream (<a href="https://eagleeye.js.org/concepts/client">clients</a>) on context state changes.</li>
|
|
142
|
+
<li> Subscribers decide which exact context state properties' changes to monitor.</li>
|
|
143
|
+
</ul>
|
|
144
|
+
|
|
145
|
+
## Please see more documentation here:
|
|
146
|
+
**[eagleeye.js.org](https://eagleeye.js.org)**
|
|
147
|
+
|
|
148
|
+
# License
|
|
149
|
+
|
|
150
|
+
GPLv3
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FULL_STATE_SELECTOR = exports.Tag = exports.SPLICE_TAG = exports.SET_TAG = exports.REPLACE_TAG = exports.PUSH_TAG = exports.NULL_SELECTOR = exports.MOVE_TAG = exports.GLOBAL_SELECTOR = exports.DELETE_TAG = exports.CLEAR_TAG = void 0;
|
|
7
|
+
var auto_immutable_1 = require("@webkrafters/auto-immutable");
|
|
8
|
+
Object.defineProperty(exports, "CLEAR_TAG", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return auto_immutable_1.CLEAR_TAG;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "DELETE_TAG", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return auto_immutable_1.DELETE_TAG;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "GLOBAL_SELECTOR", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return auto_immutable_1.GLOBAL_SELECTOR;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "MOVE_TAG", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return auto_immutable_1.MOVE_TAG;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "NULL_SELECTOR", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return auto_immutable_1.NULL_SELECTOR;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(exports, "PUSH_TAG", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function get() {
|
|
41
|
+
return auto_immutable_1.PUSH_TAG;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "REPLACE_TAG", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function get() {
|
|
47
|
+
return auto_immutable_1.REPLACE_TAG;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(exports, "SET_TAG", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function get() {
|
|
53
|
+
return auto_immutable_1.SET_TAG;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "SPLICE_TAG", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function get() {
|
|
59
|
+
return auto_immutable_1.SPLICE_TAG;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(exports, "Tag", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function get() {
|
|
65
|
+
return auto_immutable_1.Tag;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
exports.FULL_STATE_SELECTOR = '@@STATE';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Changes as BaseChanges, Immutable as AutoImmutable, Value } from '@webkrafters/auto-immutable';
|
|
2
|
+
import { FULL_STATE_SELECTOR } from './constants';
|
|
3
|
+
import { createEagleEye, Streamer } from './main';
|
|
4
|
+
export type { BaseType, ClearCommand, KeyType, MoveCommand, PushCommand, ReplaceCommand, SetCommand, SpliceCommand, TagCommand, TagType, UpdateStats, UpdatePayload, UpdatePayloadArray } from '@webkrafters/auto-immutable';
|
|
5
|
+
export type State = Value;
|
|
6
|
+
export type ShutdownMonitor = (reason: ShutdownReason) => void;
|
|
7
|
+
export type Listener = <T extends State>(changes: Changes<T>, changedPathsTokens: Readonly<Array<Array<string>>>, netChanges: Readonly<T>, mayHaveChangesAt: (pathTokens: Array<string>) => boolean) => void;
|
|
8
|
+
export interface ContextInfra<T extends State> {
|
|
9
|
+
prehooks?: Prehooks<T>;
|
|
10
|
+
storage?: IStorage<T>;
|
|
11
|
+
}
|
|
12
|
+
export interface RawProviderProps<T extends State> extends ContextInfra<T> {
|
|
13
|
+
value?: T;
|
|
14
|
+
}
|
|
15
|
+
export interface ProviderProps<T extends State> extends ContextInfra<T> {
|
|
16
|
+
value?: AutoImmutable<T>;
|
|
17
|
+
}
|
|
18
|
+
export type Text = string | number;
|
|
19
|
+
export type FullStateSelector = typeof FULL_STATE_SELECTOR;
|
|
20
|
+
export type ObjectSelector = Record<Text, Text | FullStateSelector>;
|
|
21
|
+
export type ArraySelector = Array<Text | FullStateSelector>;
|
|
22
|
+
export type SelectorMap = ObjectSelector | ArraySelector | void;
|
|
23
|
+
type ReplacePathSeps<P extends Text, T extends string> = P extends `${infer U}${T}${infer V}` ? ReplacePathSeps<`${U}.${V}`, T> : P;
|
|
24
|
+
type TrimPathSep<P extends Text> = P extends `${infer U}]${never}` ? U : P;
|
|
25
|
+
type NormalizePath<P extends Text> = TrimPathSep<ReplacePathSeps<ReplacePathSeps<ReplacePathSeps<P, ']['>, '].'>, '['>>;
|
|
26
|
+
type Datum<P extends Text, S extends Record<Text, any> = State> = P extends `${infer K}.${infer P_1}` ? Datum<P_1, S[K]> : P extends '' ? S : any;
|
|
27
|
+
type DataPoint<P extends Text, S extends State> = P extends FullStateSelector ? S : Datum<NormalizePath<P>, S>;
|
|
28
|
+
export type Data<SELECTOR_MAP extends SelectorMap, STATE extends State = State> = (SELECTOR_MAP extends void ? {} : SELECTOR_MAP extends ObjectSelector ? {
|
|
29
|
+
[S_KEY in keyof SELECTOR_MAP]: DataPoint<SELECTOR_MAP[S_KEY], STATE>;
|
|
30
|
+
} : SELECTOR_MAP extends ArraySelector ? {
|
|
31
|
+
[S_NUM: number]: DataPoint<SELECTOR_MAP[number], STATE>;
|
|
32
|
+
} : Array<any>);
|
|
33
|
+
export type Changes<T extends State = State> = BaseChanges<T>;
|
|
34
|
+
interface StorageGetter<T extends State = State> {
|
|
35
|
+
(key: null): T;
|
|
36
|
+
(key: string): T;
|
|
37
|
+
}
|
|
38
|
+
interface StorageDeleteFn {
|
|
39
|
+
(key: null): void;
|
|
40
|
+
(key: string): void;
|
|
41
|
+
}
|
|
42
|
+
interface StorageSetter<T extends State = State> {
|
|
43
|
+
(key: null, data: T): void;
|
|
44
|
+
(key: string, data: T): void;
|
|
45
|
+
}
|
|
46
|
+
export interface IStorage<T extends State = State> {
|
|
47
|
+
clone: (data: T) => T;
|
|
48
|
+
getItem: StorageGetter<T>;
|
|
49
|
+
removeItem: StorageDeleteFn;
|
|
50
|
+
setItem: StorageSetter<T>;
|
|
51
|
+
}
|
|
52
|
+
export interface CurrentStorage<T extends State> extends IStorage<T> {
|
|
53
|
+
isKeyRequired?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface Prehooks<T extends State = State> {
|
|
56
|
+
resetState?: (resetData: Partial<T>, state: {
|
|
57
|
+
current: T;
|
|
58
|
+
original: T;
|
|
59
|
+
}) => boolean;
|
|
60
|
+
setState?: (newChanges: Changes<T>) => boolean;
|
|
61
|
+
}
|
|
62
|
+
export type Unsubscribe = (...args: Array<unknown>) => void;
|
|
63
|
+
export declare const enum Phase {
|
|
64
|
+
UN_OPENED = -1,
|
|
65
|
+
CLOSED = 0,
|
|
66
|
+
OPENED = 1,
|
|
67
|
+
CLOSING = 2
|
|
68
|
+
}
|
|
69
|
+
export declare const enum ShutdownReason {
|
|
70
|
+
CACHE = "CACHE DATA SHUTDOWN",
|
|
71
|
+
CONTEXT = "CONTEXT-WIDE SHUTDOWN",
|
|
72
|
+
LOCAL = "CURRENT STORE INITIATED SHUTDOWN"
|
|
73
|
+
}
|
|
74
|
+
export interface IStore<T extends State = State> {
|
|
75
|
+
resetState: (propertyPaths?: Array<string>) => void;
|
|
76
|
+
setState: (changes: Changes<T>) => void;
|
|
77
|
+
}
|
|
78
|
+
export interface Store<T extends State = State, SELECTOR_MAP extends SelectorMap = SelectorMap> extends IStore<T> {
|
|
79
|
+
data: Data<SELECTOR_MAP>;
|
|
80
|
+
}
|
|
81
|
+
export interface StoreRef<T extends State = State> extends IStore<T> {
|
|
82
|
+
getState: (propertyPaths?: Array<string>) => T;
|
|
83
|
+
subscribe: {
|
|
84
|
+
(eventType: "closing", listener: ShutdownMonitor): Unsubscribe;
|
|
85
|
+
(eventType: "data-updated", listener: Listener): Unsubscribe;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface StoreInternal<T extends State = State> extends StoreRef<T> {
|
|
89
|
+
close: () => void;
|
|
90
|
+
closed: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface BaseStream<T extends State = State> {
|
|
93
|
+
<S extends SelectorMap>(selectorMap?: S): Streamer<T, S>;
|
|
94
|
+
}
|
|
95
|
+
export interface Stream<T extends State = State> extends BaseStream<T> {
|
|
96
|
+
<S extends SelectorMap>(selectorMap?: S): Store<T, S>;
|
|
97
|
+
}
|
|
98
|
+
export { CLEAR_TAG, DELETE_TAG, FULL_STATE_SELECTOR, MOVE_TAG, NULL_SELECTOR, PUSH_TAG, REPLACE_TAG, SET_TAG, SPLICE_TAG, Tag, } from './constants';
|
|
99
|
+
export { createEagleEye, EagleEyeContext, Streamer } from './main';
|
|
100
|
+
export default createEagleEye;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Streamer = exports.EagleEyeContext = exports.createEagleEye = exports.Tag = exports.SPLICE_TAG = exports.SET_TAG = exports.REPLACE_TAG = exports.PUSH_TAG = exports.NULL_SELECTOR = exports.MOVE_TAG = exports.FULL_STATE_SELECTOR = exports.DELETE_TAG = exports.CLEAR_TAG = exports.ShutdownReason = exports.Phase = void 0;
|
|
7
|
+
var main_1 = require("./main");
|
|
8
|
+
;
|
|
9
|
+
;
|
|
10
|
+
;
|
|
11
|
+
;
|
|
12
|
+
var Phase;
|
|
13
|
+
(function (Phase) {
|
|
14
|
+
Phase[Phase["UN_OPENED"] = -1] = "UN_OPENED";
|
|
15
|
+
Phase[Phase["CLOSED"] = 0] = "CLOSED";
|
|
16
|
+
Phase[Phase["OPENED"] = 1] = "OPENED";
|
|
17
|
+
Phase[Phase["CLOSING"] = 2] = "CLOSING";
|
|
18
|
+
})(Phase || (exports.Phase = Phase = {}));
|
|
19
|
+
;
|
|
20
|
+
var ShutdownReason;
|
|
21
|
+
(function (ShutdownReason) {
|
|
22
|
+
ShutdownReason["CACHE"] = "CACHE DATA SHUTDOWN";
|
|
23
|
+
ShutdownReason["CONTEXT"] = "CONTEXT-WIDE SHUTDOWN";
|
|
24
|
+
ShutdownReason["LOCAL"] = "CURRENT STORE INITIATED SHUTDOWN";
|
|
25
|
+
})(ShutdownReason || (exports.ShutdownReason = ShutdownReason = {}));
|
|
26
|
+
;
|
|
27
|
+
;
|
|
28
|
+
var constants_1 = require("./constants");
|
|
29
|
+
Object.defineProperty(exports, "CLEAR_TAG", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function get() {
|
|
32
|
+
return constants_1.CLEAR_TAG;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "DELETE_TAG", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function get() {
|
|
38
|
+
return constants_1.DELETE_TAG;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "FULL_STATE_SELECTOR", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function get() {
|
|
44
|
+
return constants_1.FULL_STATE_SELECTOR;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "MOVE_TAG", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function get() {
|
|
50
|
+
return constants_1.MOVE_TAG;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(exports, "NULL_SELECTOR", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function get() {
|
|
56
|
+
return constants_1.NULL_SELECTOR;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(exports, "PUSH_TAG", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function get() {
|
|
62
|
+
return constants_1.PUSH_TAG;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(exports, "REPLACE_TAG", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function get() {
|
|
68
|
+
return constants_1.REPLACE_TAG;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(exports, "SET_TAG", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
get: function get() {
|
|
74
|
+
return constants_1.SET_TAG;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "SPLICE_TAG", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function get() {
|
|
80
|
+
return constants_1.SPLICE_TAG;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(exports, "Tag", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function get() {
|
|
86
|
+
return constants_1.Tag;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
var main_2 = require("./main");
|
|
90
|
+
Object.defineProperty(exports, "createEagleEye", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return main_2.createEagleEye;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "EagleEyeContext", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function get() {
|
|
99
|
+
return main_2.EagleEyeContext;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.defineProperty(exports, "Streamer", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function get() {
|
|
105
|
+
return main_2.Streamer;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
exports["default"] = main_1.createEagleEye;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Connection } from '@webkrafters/auto-immutable';
|
|
2
|
+
import type { BaseStream, Changes, Data, IStorage, Listener, Prehooks, ProviderProps, RawProviderProps, SelectorMap, ShutdownMonitor, State, Store, StoreInternal, StoreRef, Unsubscribe } from '..';
|
|
3
|
+
import AutoImmutable from '@webkrafters/auto-immutable';
|
|
4
|
+
import { Phase, ShutdownReason } from '..';
|
|
5
|
+
export declare const deps: {
|
|
6
|
+
createStorageKey: () => string;
|
|
7
|
+
};
|
|
8
|
+
export declare const ACCESS_SYM: unique symbol;
|
|
9
|
+
export declare class Streamer<T extends State = State, S extends SelectorMap = SelectorMap> implements Store<T, S> {
|
|
10
|
+
private _context;
|
|
11
|
+
private _internalStore;
|
|
12
|
+
private _data;
|
|
13
|
+
private eventMap;
|
|
14
|
+
private _phase;
|
|
15
|
+
private _selectorMap;
|
|
16
|
+
private _unsubClosing;
|
|
17
|
+
private _unsubscribe;
|
|
18
|
+
constructor(context: EagleEyeContext<T>, selectorMap?: S);
|
|
19
|
+
get closed(): boolean;
|
|
20
|
+
get data(): Data<S, T>;
|
|
21
|
+
get phase(): Phase;
|
|
22
|
+
get streaming(): boolean;
|
|
23
|
+
set selectorMap(selectorMap: S);
|
|
24
|
+
addListener(eventType: 'stream-ending', listener: ShutdownMonitor): void;
|
|
25
|
+
addListener(eventType: 'data-changed', listener: () => void): void;
|
|
26
|
+
endStream(): void;
|
|
27
|
+
removeListener(eventType: 'stream-ending', listener: ShutdownMonitor): void;
|
|
28
|
+
removeListener(eventType: 'data-changed', listener: () => void): void;
|
|
29
|
+
resetState(propertyPaths?: string[]): void;
|
|
30
|
+
setState(changes: Changes<T>): void;
|
|
31
|
+
protected subscribe(): void;
|
|
32
|
+
protected unsubscribe(): void;
|
|
33
|
+
private get _renderKeys();
|
|
34
|
+
private _dataSourceListener;
|
|
35
|
+
private _integrateSelectors;
|
|
36
|
+
private _reclaim;
|
|
37
|
+
private _refreshDataRef;
|
|
38
|
+
private _setupInternalStore;
|
|
39
|
+
private _updateData;
|
|
40
|
+
private _updateInternalStore;
|
|
41
|
+
}
|
|
42
|
+
export declare class EagleEyeContext<T extends State = State> {
|
|
43
|
+
private _cache;
|
|
44
|
+
private _cacheCloseMonitor;
|
|
45
|
+
private _prehooks;
|
|
46
|
+
private _storage;
|
|
47
|
+
private _store;
|
|
48
|
+
private _storeRef;
|
|
49
|
+
private eventMap;
|
|
50
|
+
private inchoateValue;
|
|
51
|
+
private storageKey;
|
|
52
|
+
protected _stream: BaseStream<T>;
|
|
53
|
+
constructor(value?: AutoImmutable<T>, prehooks?: Prehooks<T>, storage?: IStorage<T>);
|
|
54
|
+
constructor(value?: T, prehooks?: Prehooks<T>, storage?: IStorage<T>);
|
|
55
|
+
get cache(): AutoImmutable<T>;
|
|
56
|
+
get closed(): boolean;
|
|
57
|
+
get prehooks(): Prehooks<T>;
|
|
58
|
+
get storage(): IStorage<T>;
|
|
59
|
+
get store(): StoreRef<T>;
|
|
60
|
+
get stream(): BaseStream<T>;
|
|
61
|
+
set prehooks(prehooks: Prehooks<T>);
|
|
62
|
+
set storage(storage: IStorage<T>);
|
|
63
|
+
createInternalStore(access?: Symbol): StoreInternal<T>;
|
|
64
|
+
dispose(): void;
|
|
65
|
+
protected createUpdateEmitterFor(changes: Changes<T>): (netChanges: Readonly<Partial<T>>, changedPathsTokens: Array<Array<string>>) => void;
|
|
66
|
+
protected disconnectInternalStore(connection: Connection<T>): void;
|
|
67
|
+
protected getState(connection: Connection<T>, propertyPaths: Array<string>): Readonly<Partial<T>>;
|
|
68
|
+
protected notifyClosing(reason: ShutdownReason): void;
|
|
69
|
+
protected resetState(connection: Connection<T>, propertyPaths: Array<string>): void;
|
|
70
|
+
protected setState(connection: Connection<T>, changes: Changes<T>): void;
|
|
71
|
+
protected subscribe(eventType: 'closing', listener: ShutdownMonitor): Unsubscribe;
|
|
72
|
+
protected subscribe(eventType: 'data-updated', listener: Listener): Unsubscribe;
|
|
73
|
+
private _createInternalStore;
|
|
74
|
+
private _reclaim;
|
|
75
|
+
}
|
|
76
|
+
export declare function createEagleEye<T extends State = State>(props?: RawProviderProps<T>): EagleEyeContext<T>;
|
|
77
|
+
export declare function createEagleEye<T extends State = State>(props?: ProviderProps<T>): EagleEyeContext<T>;
|
|
78
|
+
export declare function mkReadonly(v: any): any;
|