insite-subscriptions-client 2.3.5 → 2.5.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 +1 -1
- package/README.md +247 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/package.json +47 -34
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,13 +1,256 @@
|
|
|
1
|
-
#
|
|
1
|
+
# insite-subscriptions-client
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/insite-subscriptions-client)
|
|
4
|
+
|
|
5
|
+
Client-side library for subscribing to inSite publications over WebSocket. Provides reactive containers for three data shapes — object, array, and map — that apply server updates and notify your handlers.
|
|
6
|
+
|
|
7
|
+
Part of [inSite](../../README.md) — requires [insite-ws](../ws/README.md). Pairs with [insite-subscriptions-server](../subscriptions-server/README.md).
|
|
2
8
|
|
|
3
9
|
## Installation
|
|
4
10
|
|
|
5
11
|
```sh
|
|
6
|
-
|
|
12
|
+
npm install insite-subscriptions-client
|
|
7
13
|
```
|
|
8
14
|
|
|
9
|
-
Or
|
|
15
|
+
Or:
|
|
10
16
|
|
|
11
17
|
```sh
|
|
12
|
-
|
|
18
|
+
bun add insite-subscriptions-client
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Setup
|
|
22
|
+
|
|
23
|
+
Before creating any subscriptions, bind the library to your WebSocket instance:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { WS } from "insite-ws/client";
|
|
27
|
+
import { Subscription } from "insite-subscriptions-client";
|
|
28
|
+
|
|
29
|
+
const ws = new WS({ url: "wss://example.com" });
|
|
30
|
+
Subscription.bindTo(ws);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`Subscription.bindTo(ws)` wires the subscription protocol to the given `WS` instance. Without it, creating subscriptions will throw.
|
|
34
|
+
|
|
35
|
+
## Core Concepts
|
|
36
|
+
|
|
37
|
+
**Subscription** — Low-level subscription. Sends `s-s` (subscribe) and `s-u` (unsubscribe) messages, receives `s-c` (changed) updates. You typically use the higher-level containers instead.
|
|
38
|
+
|
|
39
|
+
**SubscriptionObject**, **SubscriptionArray**, **SubscriptionMap** — Reactive containers. Each applies incoming updates to its data and invokes an optional `handleUpdate` callback. Can be used standalone (you feed updates manually) or with built-in subscription.
|
|
40
|
+
|
|
41
|
+
**WithSubscription variants** — Combine container + subscription. `SubscriptionObjectWithSubscription`, `SubscriptionArrayWithSubscription`, `SubscriptionMapWithSubscription` subscribe on creation and feed updates into the container.
|
|
42
|
+
|
|
43
|
+
**SubscriptionGroup** — Manages multiple subscriptions with shared lifecycle (load, init, unload). Supports target binding (assign values to an object), debounced updates, and definition-based configuration.
|
|
44
|
+
|
|
45
|
+
## Public API
|
|
46
|
+
|
|
47
|
+
### Subscription
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
Subscription.bindTo(ws: WS): void
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Binds all subscriptions to the given WebSocket. Call once before creating any subscription.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
new Subscription(
|
|
57
|
+
type: "array" | "map" | "object",
|
|
58
|
+
publicationName: string,
|
|
59
|
+
args?: unknown[],
|
|
60
|
+
handler?: (updates: unknown) => void,
|
|
61
|
+
immediately?: boolean
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
| Property | Description |
|
|
66
|
+
|----------|-------------|
|
|
67
|
+
| `i` | Internal subscription id |
|
|
68
|
+
| `type` | `"array"` \| `"map"` \| `"object"` |
|
|
69
|
+
| `publicationName` | Publication name to subscribe to |
|
|
70
|
+
| `args` | Arguments passed to the publication |
|
|
71
|
+
| `handler` | Called when updates arrive |
|
|
72
|
+
| `immediately` | Request initial data on subscribe (default `true`) |
|
|
73
|
+
| `isActive` | `true` when data is loaded, `false` when connection is closed |
|
|
74
|
+
|
|
75
|
+
| Method | Description |
|
|
76
|
+
|--------|-------------|
|
|
77
|
+
| `cancel()` | Unsubscribes and removes the subscription |
|
|
78
|
+
| `start` | Sends subscribe message (called on reconnect) |
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
### SubscriptionObject
|
|
83
|
+
|
|
84
|
+
Plain object container. Updates merge into the object; `null` clears it.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
new SubscriptionObject(updates?: Updates, onUpdate?: UpdateHandler)
|
|
88
|
+
SubscriptionObject.WithSubscription(publicationName: string, params: unknown[], onUpdate: UpdateHandler, immediately?: boolean)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Types:**
|
|
92
|
+
|
|
93
|
+
- `Updated` — `Record<string, unknown>` (the current object state)
|
|
94
|
+
- `Updates` — `Record<string, unknown> | null` (incoming update payload)
|
|
95
|
+
- `UpdateHandler` — `(object, updated, updates) => void`
|
|
96
|
+
|
|
97
|
+
**Methods (via symbols):** `update`, `clear`, `getAsUpdates`, `getAsInitialUpdated`, `getHandleUpdate` / `setHandleUpdate`
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### SubscriptionArray
|
|
102
|
+
|
|
103
|
+
Array container. Supports add, delete, initial load, and optional sort direction.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
new SubscriptionArray<I>(updates?: Updates<I>, onUpdate?: UpdateHandler<I>)
|
|
107
|
+
SubscriptionArray.WithSubscription(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately?: boolean)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Types:**
|
|
111
|
+
|
|
112
|
+
- `Updated<I>` — `I[]` with `added: I[]` and `deleted: I[]`
|
|
113
|
+
- `Updates<I>` — Array of `["i", items[], sort?] | ["a", item] | ["d", item] | null`
|
|
114
|
+
- `UpdateHandler<I>` — `(array, updated, updates) => void`
|
|
115
|
+
|
|
116
|
+
**Properties:** `sorted`, `sortDirection` (-1 | 0 | 1), `sortCompareFunction`, `handleUpdate`
|
|
117
|
+
|
|
118
|
+
**Methods:** `update`, `clear`, `getAsUpdates`, `getAsInitialUpdated`. WithSubscription adds `subscribe`, `unsubscribe`, `renew`
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
### SubscriptionMap
|
|
123
|
+
|
|
124
|
+
Map container keyed by `_id`. Supports create, update, delete, initial load, and multi-field sorting.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
new SubscriptionMap<I>(updates?: Updates<I>, onUpdate?: UpdateHandler<I>)
|
|
128
|
+
SubscriptionMap.WithSubscription(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately?: boolean)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Types:**
|
|
132
|
+
|
|
133
|
+
- `Updated<I>` — `I[]` with `added: I[]` and `deleted: string[]` (ids)
|
|
134
|
+
- `Updates<I>` — Array of `["i", items[], sortList?] | ["c", item] | ["u", item, fields] | ["d", _id] | null`
|
|
135
|
+
- `UpdateHandler<I>` — `(map, updated, updates) => void`
|
|
136
|
+
- `SubscriptionMapItem` — Base class for custom map items (has `_id`, `update`, `delete`)
|
|
137
|
+
|
|
138
|
+
**Properties:** `sorted`, `sortList`, `sortCompareFunction`, `handleUpdate`, `Item` (setter for custom item class)
|
|
139
|
+
|
|
140
|
+
**Methods:** `update`, `clear`, `getAsUpdates`, `getAsInitialUpdated`, `sort`. WithSubscription adds `subscribe`, `unsubscribe`, `renew`
|
|
141
|
+
|
|
142
|
+
**Custom items:** Set `map.Item = MyItemClass` before or after first update. `MyItemClass` receives `(map, updates)` in constructor and must have `_id`.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### SubscriptionGroup
|
|
147
|
+
|
|
148
|
+
Manages multiple subscriptions with shared lifecycle and optional target binding.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
new SubscriptionGroup(definitions, options?)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Options:**
|
|
155
|
+
|
|
156
|
+
| Option | Type | Description |
|
|
157
|
+
|--------|------|-------------|
|
|
158
|
+
| `target` | object | Object to bind subscription values to (`target[name] = value`) |
|
|
159
|
+
| `debounce` | number | Debounce ms for `update` events (default: `SubscriptionGroup.debounceLimit` = 8) |
|
|
160
|
+
| `immediately` | boolean | Subscribe immediately on attach (default `true`) |
|
|
161
|
+
|
|
162
|
+
**Methods:**
|
|
163
|
+
|
|
164
|
+
| Method | Description |
|
|
165
|
+
|--------|-------------|
|
|
166
|
+
| `attach(definitions, shouldReload?, immediately?)` | Attach definitions, returns `Promise` of load |
|
|
167
|
+
| `detach(names, shouldUpdate?)` | Detach subscriptions by name |
|
|
168
|
+
| `redefine(definitions)` | Replace definitions, reattach changed, detach removed |
|
|
169
|
+
| `subscribe()` | Subscribe all items |
|
|
170
|
+
| `unsubscribe()` | Unsubscribe all items |
|
|
171
|
+
| `applyOptions({ target?, debounceLimit? })` | Update target or debounce |
|
|
172
|
+
| `loaded()` | Returns `StatefulPromise` resolving when all items loaded |
|
|
173
|
+
| `inited()` | Returns `StatefulPromise` resolving when all items inited |
|
|
174
|
+
| `unloaded()` | Returns `StatefulPromise` resolving when all items unloaded |
|
|
175
|
+
|
|
176
|
+
**Events:** `load`, `init`, `unload`, `update`, `update.{name}`
|
|
177
|
+
|
|
178
|
+
**Properties:** `items`, `values`, `isLoaded`, `isInited`, `target`, `emitUpdate`
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### SubscriptionGroup Definition Format
|
|
183
|
+
|
|
184
|
+
Each definition describes one subscription in the group.
|
|
185
|
+
|
|
186
|
+
**Object form:**
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
{
|
|
190
|
+
name: string;
|
|
191
|
+
type?: "object" | "array" | "map";
|
|
192
|
+
publicationName?: string; // defaults to name
|
|
193
|
+
params?: unknown[];
|
|
194
|
+
value?: SubscriptionObjectWithSubscription | SubscriptionArrayWithSubscription | SubscriptionMapWithSubscription;
|
|
195
|
+
handle?: (updated, group) => void;
|
|
196
|
+
onBeforeInit?: (value) => void;
|
|
197
|
+
debounce?: number;
|
|
198
|
+
preventBind?: boolean; // skip binding to target
|
|
199
|
+
}
|
|
13
200
|
```
|
|
201
|
+
|
|
202
|
+
**Tuple form:** `[name, type?, publicationName?, params?, handle?, onBeforeInit?, debounce?, preventBind?]`
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
### Update Protocol
|
|
207
|
+
|
|
208
|
+
**SubscriptionObject:** `Updates` is `Record<string, unknown> | null`. Non-null merges into the object; null clears.
|
|
209
|
+
|
|
210
|
+
**SubscriptionArray:** `Updates` is an array of:
|
|
211
|
+
|
|
212
|
+
| Op | Format | Description |
|
|
213
|
+
|----|--------|-------------|
|
|
214
|
+
| `"i"` | `["i", items[], sort?]` | Initial load. `sort`: -1 (desc), 0 (none), 1 (asc) |
|
|
215
|
+
| `"a"` | `["a", item]` | Add item |
|
|
216
|
+
| `"d"` | `["d", item]` | Delete item |
|
|
217
|
+
| null | — | Clear |
|
|
218
|
+
|
|
219
|
+
**SubscriptionMap:** `Updates` is an array of:
|
|
220
|
+
|
|
221
|
+
| Op | Format | Description |
|
|
222
|
+
|----|--------|-------------|
|
|
223
|
+
| `"i"` | `["i", items[], sortList?]` | Initial load. `sortList`: `{ field: -1|1 }` |
|
|
224
|
+
| `"c"` | `["c", item]` | Create item |
|
|
225
|
+
| `"u"` | `["u", item, fields]` | Update item. `fields`: array of changed keys or `true` (atomic) |
|
|
226
|
+
| `"d"` | `["d", _id]` | Delete by id |
|
|
227
|
+
| null | — | Clear |
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### Symbols
|
|
232
|
+
|
|
233
|
+
Exported for extension and integration with other inSite packages:
|
|
234
|
+
|
|
235
|
+
| Symbol | Purpose |
|
|
236
|
+
|--------|---------|
|
|
237
|
+
| `updateSymbol` | Method to apply updates |
|
|
238
|
+
| `getHandleUpdateSymbol` / `setHandleUpdateSymbol` | Get/set update handler |
|
|
239
|
+
| `getAsUpdatesSymbol` | Serialize current state as updates |
|
|
240
|
+
| `getAsInitialUpdatedSymbol` | Get current state as "initial updated" shape |
|
|
241
|
+
| `clearSymbol` | Clear container |
|
|
242
|
+
| `subscribeSymbol` / `unsubscribeSymbol` / `renewSymbol` | Subscription lifecycle |
|
|
243
|
+
| `getSubscriptionSymbol` | Get underlying Subscription |
|
|
244
|
+
| `getHandleSubscriptionSymbol` / `setHandleSubscriptionSymbol` | Handler wiring |
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Related
|
|
249
|
+
|
|
250
|
+
- [insite-ws](../ws/README.md) — provides WS
|
|
251
|
+
- [insite-subscriptions-server](../subscriptions-server/README.md) — server counterpart
|
|
252
|
+
- [insite-client](../client/README.md), [insite-users-client](../users-client/README.md) — use subscriptions
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var zt=Object.defineProperty;var wt=n=>{throw TypeError(n)};var qt=(n,s,t)=>s in n?zt(n,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[s]=t;var i=(n,s,t)=>qt(n,typeof s!="symbol"?s+"":s,t),St=(n,s,t)=>s.has(n)||wt("Cannot "+t);var a=(n,s,t)=>(St(n,s,"read from private field"),t?t.call(n):s.get(n)),f=(n,s,t)=>s.has(n)?wt("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(n):s.set(n,t),d=(n,s,t,e)=>(St(n,s,"write to private field"),e?e.call(n,t):s.set(n,t),t),g=(n,s,t)=>(St(n,s,"access private method"),t);var Tt,it,M,q=class{constructor(s,t,e=[],r,o=!0){i(this,"i");i(this,"type");i(this,"publicationName");i(this,"args");i(this,"handler");i(this,"immediately");i(this,"isActive");i(this,"start",()=>{M.sendMessage("s-s",this.type,this.publicationName,this.i,this.args,this.immediately),this.immediately=!0});if(!M)throw new Error("Subscription is not binded to WS. Do Subscription.bindTo(ws) first");this.i=Tt++,this.type=s,this.publicationName=t,this.args=e,this.handler=r,this.immediately=o&&!globalThis.__initials,it.set(this.i,this),M.on("open",this.start),M.isOpen&&this.start(),globalThis.__initials?(this.isActive=!0,this.handler(globalThis.__initials.splice(0,1)[0])):this.isActive=!1}cancel(){it.delete(this.i),M.off("open",this.start),M.sendMessage("s-u",this.i)}static bindTo(s){M=s,Tt=0,it=new Map,M.on("message:s-c",(t,e)=>{let r=it.get(t);r&&(r.isActive=!0,r.handler(e))}),M.on("close",()=>{for(let t of it.values())t.isActive=!1}),M.on("server-change",()=>{for(let t of it.values())t.handler(null)})}};function K(){}var pt=new WeakMap,y=class n extends Promise{constructor(t,e){let r,o;super((u,h)=>{r=u,o=h});i(this,"isPending",!0);i(this,"isFulfilled",!1);i(this,"isRejected",!1);i(this,"state","pending");i(this,"result");i(this,"resolve",t=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=t;let e=pt.get(this);e&&(e.resolve.call(this,t),pt.delete(this))}});i(this,"reject",t=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=t;let e=pt.get(this);e&&(e.reject.call(this,t),pt.delete(this))}});if(pt.set(this,{resolve:r,reject:o}),e?.signal)if(e.signal.aborted)this.reject(new DOMException("Aborted","AbortError"));else{let u=()=>this.reject(new DOMException("Aborted","AbortError"));e.signal.addEventListener("abort",u),this.finally(()=>e.signal?.removeEventListener("abort",u))}if(typeof e?.timeout=="number"&&Number.isFinite(e.timeout)){let u=setTimeout(()=>this.reject(new DOMException("Timeout exceeded","TimeoutError")),e.timeout);this.finally(()=>clearTimeout(u))}t?.(this.resolve,this.reject)}static resolved(t){return new n(e=>e(t))}static rejected(t){return new n((e,r)=>r(t))}};function ct(n,s=0,t={}){let{leading:e=!1,trailing:r=!0}=t,{maxWait:o=1/0}=t,u,h,l,c,b,p,m,S,ft=async()=>{let J=Date.now();J>=l?(u=void 0,l=void 0,clearTimeout(h),h=void 0,typeof m=="function"&&await m(),V.resolve(S),p=e):(clearTimeout(u),u=setTimeout(ft,l-J))},lt=Number.isFinite(o)?()=>{m===Y&&(m=!1),Y(),h=setTimeout(lt,o)}:null;async function Y(){try{return S=await n.apply(c,b),S}catch(J){throw V.reject(J),J}}e&&typeof e=="boolean"&&(e=Y),p=e,r&&typeof r=="boolean"&&(r=Y),m=r;let V=Object.assign(function(...J){return b=J,c=this,l=Date.now()+s,m=r,V.promise.isPending||(V.promise=new y((Vt,Jt)=>{V.resolve=Vt,V.reject=Jt,typeof p=="function"&&(p(),p=!1,m===Y&&(m=!1)),u||(u=setTimeout(ft,s),lt&&(h=setTimeout(lt,o)))})),V.promise},{callback:n,promise:y.resolved(void 0),resolve:K,reject:K,run:Y,clear:async J=>{clearTimeout(u),u=void 0,clearTimeout(h),h=void 0,V.resolve(J?await Y():S)}});return V}ct.noop=Object.assign(()=>{},{callback:K,promise:y.resolved(void 0),resolve:K,reject:K,run:K,clear:K});function Ot(n,s,t,e,r=!0){return Array.isArray(n)&&(n=n.length),typeof e!="string"&&(r=e??!0,e=t),(r?`${n}\xA0`:"")+Ot.raw(n,s,t,e)}Ot.raw=(n,s,t,e=t)=>{n=Math.abs(n);let r=n%10,o=n%100;return r===1&&o!==11?s:r>=2&&r<=4&&!(o>=12&&o<=15)?t:e};function Z(n,s){let t=n.indexOf(s);return t>-1?(n.splice(t,1),!0):!1}function At(n){return[...new Set(n)]}var O=Symbol("update"),A=Symbol("getHandleUpdate"),U=Symbol("setHandleUpdate"),j=Symbol("getAsUpdates"),D=Symbol("getAsInitialUpdated"),$=Symbol("clear"),x=Symbol("subscribe"),I=Symbol("unsubscribe"),k=Symbol("renew"),E=Symbol("getSubscription"),Kt=Symbol("getHandleSubscription"),Xt=Symbol("setHandleSubscription");var Qt=(n,s)=>n>s?1:n<s?-1:0,Yt=(n,s)=>n>s?-1:n<s?1:0,jt,Dt,kt,Ht,H=class extends Array{constructor(t,e){super();i(this,"sorted",[]);i(this,"handleUpdate");i(this,"sortDirection",0);i(this,"sortCompareFunction",null);i(this,Ht,this.update);i(this,kt,this.getAsUpdates);i(this,Dt,this.getAsInitialUpdated);i(this,jt,this.clear);e&&(this.handleUpdate=e),Array.isArray(t)&&this.update(t)}[A](){return this.handleUpdate}[U](t){return this.handleUpdate=t}update(t){let e=Object.assign([],{deleted:[],added:[]});if(t){let r=!1;for(let o of t)switch(o?.[0]){case"i":{let[,u,h]=o;h?(this.sortDirection=h,this.sortCompareFunction=h>0?Qt:Yt,r=!0):(this.sortDirection=0,this.sortCompareFunction=null),this.length=0;for(let l of u)this.push(l),e.push(l),e.added.push(l);break}case"a":{let[,u]=o;this.includes(u)||(this.push(u),this.sortDirection&&(r=!0),e.push(u),e.added.push(u));break}case"d":{let[,u]=o;Z(this,u)&&e.deleted.push(u);break}default:this.clear()}r&&this.sortCompareFunction&&this.sort(this.sortCompareFunction)}else this.clear();return this.handleUpdate?.(this,e,t?.[0]?t:null),this}getAsUpdates(){return this.length||this.sortDirection?[["i",[...this],this.sortDirection]]:null}getAsInitialUpdated(){return Object.assign([...this.sorted],{added:[...this.sorted],deleted:[]})}clear(){this.length=0,this.sortDirection=0,this.sortCompareFunction=null}valueOf(){return this}get[(Ht=O,kt=j,Dt=D,jt=$,Symbol.toStringTag)](){return"SubscriptionArray"}};i(H,"updateSymbol",O),i(H,"getHandleUpdateSymbol",A),i(H,"setHandleUpdateSymbol",U),i(H,"getAsUpdatesSymbol",j),i(H,"getAsInitialUpdatedSymbol",D),i(H,"clearSymbol",$),i(H,"WithSubscription");var _=class extends H{constructor(t,e,r,o=!0){super(null,r);i(this,"publicationName");i(this,"params");i(this,"subscription",null);this.publicationName=t,this.params=e,o&&this.subscribe()}subscribe(){this.subscription||(this.subscription=new q("array",this.publicationName,this.params,t=>this.update(t)))}get[x](){return this.subscribe}unsubscribe(){this.subscription&&(this.subscription.cancel(),this.subscription=null)}get[I](){return this.unsubscribe}renew(t,e){this.subscription&&(this.unsubscribe(),t&&(Array.isArray(t)?e=t:this.publicationName=t),e&&(this.params=e),this.subscribe())}get[k](){return this.renew}[E](){return this.subscription}get[Symbol.toStringTag](){return"SubscriptionArrayWithSubscription"}};i(_,"subscribeSymbol",x),i(_,"unsubscribeSymbol",I),i(_,"renewSymbol",k),i(_,"getSubscriptionSymbol",E);H.WithSubscription=_;import ee from"eventemitter3";var v={};import te from"eventemitter3";function Zt(n){let s=document.createElement("script");s.textContent=`window.__insite_subscription_map_sort_function = function sort(a, b) { return ${Object.entries(n).map(([e,r])=>(e.includes(".")&&(e=e.replaceAll(".","?.")),r>0?`a.${e} > b.${e} ? 1 : a.${e} < b.${e} ? -1 :`:`a.${e} < b.${e} ? 1 : a.${e} > b.${e} ? -1 :`)).concat("0").join(" ")};}`,document.head.append(s);let t=globalThis.__insite_subscription_map_sort_function;return s.remove(),delete globalThis.__insite_subscription_map_sort_function,t}var Pt,$t,Mt,Et,st,tt,rt,w=class extends Map{constructor(t,e){super();i(this,"handleUpdate");f(this,st,new Map);i(this,"sortList",null);i(this,"sortCompareFunction",null);f(this,tt,[]);i(this,"sorted",[]);f(this,rt);i(this,Et,this.update);i(this,Mt,this.getAsUpdates);i(this,$t,this.getAsInitialUpdated);i(this,Pt,this.clear);e&&(this.handleUpdate=e),t&&this.update(t)}sort(){this.sortCompareFunction&&this.sorted.sort(this.sortCompareFunction)}[A](){return this.handleUpdate}[U](t){return this.handleUpdate=t}set Item(t){if(d(this,rt,t),this.size)for(let[e,r]of this)this.set(e,new t(this,r))}get Item(){return a(this,rt)}update(t){let e=Object.assign([],{added:[],deleted:[]});if(t){let r=!1,o=a(this,rt),u=a(this,st);for(let h of t)switch(h?.[0]){case"i":{let[,l,c]=h;if(c?(this.sortList=c,this.sortCompareFunction=Zt(c),d(this,tt,At(Object.keys(c).map(b=>b.replace(/\..+/,"")))),r=!0):(this.sortList=null,this.sortCompareFunction=null,d(this,tt,[])),this.size){let b=new Map;for(let p of l)b.set(p._id,p);for(let[p,m]of this){let S=b.get(p);if(S){let ft=u.get(p);if(o)m.update(S);else{for(let lt in ft)delete m[lt];Object.assign(m,S)}u.set(p,S),e.push(m),b.delete(p)}else o?m.delete():this.delete(p),u.delete(p),e.deleted.push(p)}for(let[p,m]of b){let S=o?new o(this,m):{...m};this.set(p,S),u.set(p,m),e.push(S),e.added.push(S)}this.sortList&&(this.sorted=l.map(p=>this.get(p._id)))}else for(let b of l){let p=o?new o(this,b):{...b};this.set(p._id,p),this.sorted.push(p),u.set(p._id,b),e.push(p),e.added.push(p)}break}case"c":case"u":{let[,l]=h,c=this.get(l._id);if(c){let b=h[2]===!0,p=b?Object.keys(l):h[2],m=u.get(c._id);if(o)c.update(l);else{if(!b)for(let S in m)delete c[S];Object.assign(c,l)}b&&(l=Object.assign(m,l)),this.sortList&&!r&&(!p||p.some(S=>a(this,tt).includes(S)))&&(r=!0)}else c=o?new o(this,l):{...l},this.set(c._id,c),this.sorted.push(c),this.sortList&&(r=!0),e.added.push(c);u.set(c._id,l),e.push(c);break}case"d":{let[,l]=h,c=this.get(l);c&&(o?c.delete():this.delete(l),u.delete(l),Z(this.sorted,c),e.deleted.push(l));break}default:this.clear()}r&&this.sort()}else this.clear();return this.handleUpdate?.(this,e,t?.[0]?t:null),this}getAsUpdates(){return this.size||this.sortList?[["i",[...a(this,st).values()],this.sortList]]:null}getAsInitialUpdated(){return Object.assign([...this.sorted],{added:[...this.sorted],deleted:[]})}clear(){super.clear(),a(this,st).clear(),this.sorted=[],this.sortList=null,this.sortCompareFunction=null,d(this,tt,[])}valueOf(){return this.sorted}get[(Et=O,Mt=j,$t=D,Pt=$,Symbol.toStringTag)](){return"SubscriptionMap"}};st=new WeakMap,tt=new WeakMap,rt=new WeakMap,i(w,"updateSymbol",O),i(w,"getHandleUpdateSymbol",A),i(w,"setHandleUpdateSymbol",U),i(w,"getAsUpdatesSymbol",j),i(w,"getAsInitialUpdatedSymbol",D),i(w,"clearSymbol",$),i(w,"WithSubscription"),i(w,"Item");var L=class extends w{constructor(t,e,r,o=!0){super(null,r);i(this,"publicationName");i(this,"params");i(this,"subscription",null);this.publicationName=t,this.params=e,o&&this.subscribe()}subscribe(){this.subscription||(this.subscription=new q("map",this.publicationName,this.params,t=>this.update(t)))}get[x](){return this.subscribe}unsubscribe(){this.subscription&&(this.subscription.cancel(),this.subscription=null)}get[I](){return this.unsubscribe}renew(t,e){this.subscription&&(this.unsubscribe(),t&&(Array.isArray(t)?e=t:this.publicationName=t),e&&(this.params=e),this.subscribe())}get[k](){return this.renew}[E](){return this.subscription}get[Symbol.toStringTag](){return"SubscriptionMapWithSubscription"}};i(L,"subscribeSymbol",x),i(L,"unsubscribeSymbol",I),i(L,"renewSymbol",k),i(L,"getSubscriptionSymbol",E);w.WithSubscription=L;var dt,gt=class{constructor(s,t){i(this,"_id");f(this,dt);d(this,dt,s),this.update(t)}update(s){Object.assign(this,s)}delete(){a(this,dt).delete(this._id)}};dt=new WeakMap;w.Item=gt;var ht=Symbol("handleUpdate"),X=Symbol("updates"),_t,Lt,P=class{constructor(s,t){i(this,Lt);i(this,_t,null);t&&(this[ht]=t),s&&this[O](s)}[(Lt=ht,_t=X,A)](){return this[ht]}[U](s){return this[ht]=s}[O](s){if(s){for(let t in this[X])delete this[t];for(let t in s)this[t]=s[t];this[X]=s}else this[$]();return this[ht]?.(this,this,this[X]),this}[j](){return this[X]&&{...this[X]}}[D](){return this.valueOf()}[$](){for(let s in this)delete this[s];this[X]=null}valueOf(){return this[X]&&this}get[Symbol.toStringTag](){return"SubscriptionObject"}};i(P,"updateSymbol",O),i(P,"getHandleUpdateSymbol",A),i(P,"setHandleUpdateSymbol",U),i(P,"getAsUpdatesSymbol",j),i(P,"getAsInitialUpdatedSymbol",D),i(P,"clearSymbol",$),i(P,"WithSubscription");var nt,ot,G,B=class extends P{constructor(t,e,r,o=!0){super(null,r);f(this,nt);f(this,ot);f(this,G,null);d(this,nt,t),d(this,ot,e),o&&this[x]()}[x](){a(this,G)||d(this,G,new q("object",a(this,nt),a(this,ot),t=>this[O](t)))}[I](){a(this,G)&&(a(this,G).cancel(),d(this,G,null))}[k](t,e){a(this,G)&&(this[I](),t&&(Array.isArray(t)?e=t:d(this,nt,t)),e&&d(this,ot,e),this[x]())}[E](){return a(this,G)}get[Symbol.toStringTag](){return"SubscriptionObjectWithSubscription"}};nt=new WeakMap,ot=new WeakMap,G=new WeakMap,i(B,"subscribeSymbol",x),i(B,"unsubscribeSymbol",I),i(B,"renewSymbol",k),i(B,"getSubscriptionSymbol",E);P.WithSubscription=B;function Gt(n){return Array.isArray(n)}var F,Q,N,T,xt,Bt,z,at,Ft,Nt,Ut,bt=class bt extends te{constructor(t,e){super();f(this,T);i(this,"name");i(this,"group");i(this,"value");i(this,"type");i(this,"publicationName");i(this,"params");i(this,"handle");i(this,"onBeforeInit");i(this,"preventBind");i(this,"emitUpdate");i(this,"isLoaded",!1);i(this,"isInited",!1);f(this,F);f(this,Q);f(this,N);f(this,z,null);f(this,at,(t,e,r)=>{if(r)if(this.group.isLoaded){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,e,this.group);break;case"map":this.handle.call(this.group,e,this.group);break;default:this.handle.call(this.group,e,this.group)}this.emitUpdate(e)}else d(this,z,e),this.isLoaded=!0,v.groupLoad(this.group);else this.isLoaded&&(this.isLoaded=!1,v.groupUnload(this.group));this.isInited||(this.isInited=!0,v.groupInit(this.group))});this.name=t.name,this.define(t,e)}define(t,e=this.group){if(!e)throw new Error("group is undefined");let{value:r,type:o="object",publicationName:u,params:h,handle:l,onBeforeInit:c,debounce:b=bt.debounceLimit,preventBind:p}=t;if(this.group){if((!r||this.value===r)&&this.type===o&&this.publicationName===u&&JSON.stringify(this.params)===JSON.stringify(h)&&this.handle===l&&this.onBeforeInit===c)return g(this,T,xt).call(this,{debounceLimit:b,preventBind:p});this.detach(),delete this.value,delete this.publicationName,delete this.params}this.type=o,this.handle=l,this.onBeforeInit=c,r?this.value=r:(this.publicationName=u??this.name,this.params=h??[]),g(this,T,xt).call(this,{debounceLimit:b,preventBind:p}),g(this,T,Bt).call(this,e)}detach(){this.group&&(this.value?.[I](),this.isLoaded=!1,g(this,T,Ut).call(this),delete this.group.values[this.name],Z(this.group.values,this.value),delete this.group.items[this.name],Z(this.group.items,this),delete this.group)}loaded(){return a(this,F)}inited(){return a(this,Q)}unloaded(){return a(this,N)}subscribe(){if(this.value){if(this.value[x])return this.value[x]();{let t=this.value[A]();if(t){let e=this.value[D](),r=this.value[j]();switch(this.type){case"array":return t(this.value,e,r);case"map":return t(this.value,e,r);default:return t(this.value,e,r)}}}}}unsubscribe(){return this.value?.[I]?.()}renew(t,e){return this.value?.[k]?.(t,e)}valueOf(){return this.value}};F=new WeakMap,Q=new WeakMap,N=new WeakMap,T=new WeakSet,xt=function({debounceLimit:t,preventBind:e}){let r=o=>{this.emit("update",this.value,o),this.group?.emit(`update.${this.name}`,this.value,o),this.group?.emitUpdate()};if(typeof t=="number"){let o,u,h=ct(()=>{let l=!this.group;l&&(this.group=u),r(o),l&&delete this.group,o=void 0},t);this.emitUpdate=l=>{if(l!==void 0)if(Gt(l))if(Gt(o))for(let c of l)o.push(c);else o=Object.assign([...l],{added:[...l.added],deleted:[...l.deleted]});else typeof l=="object"?o?Object.assign(o,l):o={...l}:o=l;return u=this.group,h()}}else this.emitUpdate=r;this.preventBind===void 0?delete this.preventBind:this.preventBind=e},Bt=function(t){if(!this.group){switch(this.group=t,this.group.items.push(this),this.group.items[this.name]=this,(!a(this,F)||a(this,F).isFulfilled)&&d(this,F,new y),(!a(this,Q)||a(this,Q).isFulfilled)&&d(this,Q,new y),(!a(this,N)||a(this,N).isFulfilled)&&d(this,N,new y),this.type){case"array":{let e=a(this,at);this.value?this.value[U](e):this.value=new _(this.publicationName,this.params,e,!1);break}case"map":{let e=a(this,at);this.value?this.value[U](e):this.value=new L(this.publicationName,this.params,e,!1);break}default:{let e=a(this,at);this.value?this.value[U](e):this.value=new B(this.publicationName,this.params,e,!1)}}if(this.group.values.push(this.value),this.group.values[this.name]=this.value,this.onBeforeInit)switch(this.type){case"array":this.onBeforeInit.call(this.group,this.value);break;case"map":this.onBeforeInit.call(this.group,this.value);break;default:this.onBeforeInit.call(this.group,this.value)}}},z=new WeakMap,at=new WeakMap,Ft=function(){if(a(this,z)){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,a(this,z),this.group);break;case"map":this.handle.call(this.group,a(this,z),this.group);break;default:this.handle.call(this.group,a(this,z),this.group)}d(this,z,null),this.emit("load",this.value),a(this,F).resolve(this),a(this,N).isFulfilled&&d(this,N,new y)}},Nt=function(){this.emit("init",this.value),a(this,Q).resolve(this)},Ut=function(){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,null,this.group);break;case"map":this.handle.call(this.group,null,this.group);break;default:this.handle.call(this.group,null,this.group)}this.emit("unload",this.value),a(this,N).resolve(this),a(this,F).isFulfilled&&d(this,F,new y)},i(bt,"debounceLimit",4),v.itemLoad=t=>{var e;return g(e=t,T,Ft).call(e)},v.itemInit=t=>{var e;return g(e=t,T,Nt).call(e)},v.itemUnload=t=>{var e;return g(e=t,T,Ut).call(e)};var mt=bt;function ie(n){return Array.isArray(n)}function Wt(n){if(ie(n)){let s=n.slice(),t={};if(t.name=s.shift(),typeof s[0]=="object"&&!Array.isArray(s[0])){if(t.value=s.shift(),t.type=t.value.toString().match(/Subscription(Object|Array|Map)/)?.[1].toLowerCase(),!t.type)throw new Error("Unknown value type")}else typeof s[0]=="string"&&(t.type=s.shift()),typeof s[0]=="string"&&(t.publicationName=s.shift()),Array.isArray(s[0])&&(t.params=s.shift());return typeof s[0]=="function"&&(t.handle=s.shift()),typeof s[0]=="function"&&(t.onBeforeInit=s.shift()),typeof s[0]=="number"&&(t.debounce=s.shift()),typeof s[0]=="boolean"&&(t.preventBind=s.shift()),t}return n.type??(n.type="object"),n}var W,ut,C,et,R,It,Rt,vt,yt=class yt extends ee{constructor(t,{target:e,debounce:r=yt.debounceLimit,immediately:o}={}){super();f(this,R);i(this,"target");i(this,"emitUpdate");i(this,"items",[]);i(this,"values",[]);i(this,"isLoaded",!1);i(this,"isInited",!1);f(this,W);f(this,ut);f(this,C);f(this,et,null);this.applyOptions({target:e,debounceLimit:r}),d(this,ut,new y),this.attach(t,!1,o)}applyOptions({target:t,debounceLimit:e}){if(this.target!==t){if(this.target)for(let r of this.items)r.isLoaded&&!r.preventBind&&delete this.target[r.name];if(this.target=t,this.target)for(let r of this.items)r.isLoaded&&!r.preventBind&&(this.target[r.name]=r.value)}if(a(this,et)!==e)if(d(this,et,e),typeof a(this,et)=="number"){let r=ct(()=>this.emit("update",this.values),a(this,et));this.emitUpdate=()=>r()}else this.emitUpdate=()=>this.emit("update",this.values)}attach(t,e=this.isLoaded,r=!0){return e&&(this.isLoaded=!1),(!a(this,W)||a(this,W).isFulfilled)&&d(this,W,new y),(!a(this,C)||a(this,C).isFulfilled)&&d(this,C,new y),Promise.all(t.map(o=>new mt(Wt(o),this)).map(o=>(r&&o.subscribe(),o.loaded())))}detach(t,e=!0){for(let r of t)this.items[r]?.detach();e&&(g(this,R,vt).call(this),g(this,R,It).call(this))}redefine(t){let e=new Map(this.items.map(u=>[u.name,u])),r=[],o=[];for(let u of t)u=Wt(u),e.delete(u.name)?r.push(u):o.push(u);return this.isLoaded=!1,this.detach([...e.keys()],!1),Promise.all([...r.map(u=>{let h=this.items[u.name];return h.define(u),h.subscribe(),h.loaded()}),...o.length?[this.attach(o,!1)]:[]])}subscribe(){return this.items.map(t=>t.subscribe())}unsubscribe(){return this.items.map(t=>t.unsubscribe())}loaded(){return a(this,W)}inited(){return a(this,ut)}unloaded(){return a(this,C)}valueOf(){return this.values}[Symbol.iterator](){return this.values[Symbol.iterator]()}};W=new WeakMap,ut=new WeakMap,C=new WeakMap,et=new WeakMap,R=new WeakSet,It=function(){if(!this.isLoaded&&this.items.every(t=>t.isLoaded)){if(this.target)for(let t of this.items)t.preventBind||(this.target[t.name]=t.value);this.isLoaded=!0;for(let t of this.items)v.itemLoad(t);if(this.emit("load",this.values),this.isInited)if(this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();a(this,W).resolve(this),a(this,C).isFulfilled&&d(this,C,new y)}},Rt=function(){if(!this.isInited&&this.items.every(t=>t.isInited)){if(this.isInited=!0,this.isLoaded)if(this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();for(let t of this.items)v.itemInit(t);this.emit("init",this.values),a(this,ut).resolve(this)}},vt=function(){if(this.isLoaded&&this.items.every(t=>!t.isLoaded)){if(this.target)for(let t of this.items)t.preventBind||delete this.target[t.name];this.isLoaded=!1;for(let t of this.items)v.itemUnload(t);if(this.emit("unload",this.values),this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();a(this,C).resolve(this),a(this,W).isFulfilled&&d(this,W,new y)}},i(yt,"debounceLimit",8),v.groupLoad=t=>{var e;return g(e=t,R,It).call(e)},v.groupInit=t=>{var e;return g(e=t,R,Rt).call(e)},v.groupUnload=t=>{var e;return g(e=t,R,vt).call(e)};var Ct=yt;export{q as Subscription,H as SubscriptionArray,_ as SubscriptionArrayWithSubscription,Ct as SubscriptionGroup,w as SubscriptionMap,L as SubscriptionMapWithSubscription,P as SubscriptionObject,B as SubscriptionObjectWithSubscription,$ as clearSymbol,D as getAsInitialUpdatedSymbol,j as getAsUpdatesSymbol,Kt as getHandleSubscriptionSymbol,A as getHandleUpdateSymbol,E as getSubscriptionSymbol,k as renewSymbol,Xt as setHandleSubscriptionSymbol,U as setHandleUpdateSymbol,x as subscribeSymbol,I as unsubscribeSymbol,O as updateSymbol};
|
|
1
|
+
var Mt=Object.defineProperty;var ft=o=>{throw TypeError(o)};var Nt=(o,s,t)=>s in o?Mt(o,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[s]=t;var i=(o,s,t)=>Nt(o,typeof s!="symbol"?s+"":s,t),dt=(o,s,t)=>s.has(o)||ft("Cannot "+t);var n=(o,s,t)=>(dt(o,s,"read from private field"),t?t.call(o):s.get(o)),c=(o,s,t)=>s.has(o)?ft("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(o):s.set(o,t),l=(o,s,t,e)=>(dt(o,s,"write to private field"),e?e.call(o,t):s.set(o,t),t),S=(o,s,t)=>(dt(o,s,"access private method"),t);var St,Q,P,R=class{constructor(s,t,e=[],r,a=!0){i(this,"i");i(this,"type");i(this,"publicationName");i(this,"args");i(this,"handler");i(this,"immediately");i(this,"isActive");i(this,"start",()=>{P.sendMessage("s-s",this.type,this.publicationName,this.i,this.args,this.immediately),this.immediately=!0});if(!P)throw new Error("Subscription is not binded to WS. Do Subscription.bindTo(ws) first");this.i=St++,this.type=s,this.publicationName=t,this.args=e,this.handler=r,this.immediately=a&&!globalThis.__initials,Q.set(this.i,this),P.on("open",this.start),P.isOpen&&this.start(),globalThis.__initials?(this.isActive=!0,this.handler(globalThis.__initials.splice(0,1)[0])):this.isActive=!1}cancel(){Q.delete(this.i),P.off("open",this.start),P.sendMessage("s-u",this.i)}static bindTo(s){P=s,St=0,Q=new Map,P.on("message:s-c",(t,e)=>{let r=Q.get(t);r&&(r.isActive=!0,r.handler(e))}),P.on("close",()=>{for(let t of Q.values())t.isActive=!1}),P.on("server-change",()=>{for(let t of Q.values())t.handler(null)})}};import{removeOne as $t}from"@nesvet/n";var x=Symbol("update"),D=Symbol("getHandleUpdate"),y=Symbol("setHandleUpdate"),H=Symbol("getAsUpdates"),A=Symbol("getAsInitialUpdated"),G=Symbol("clear"),f=Symbol("subscribe"),g=Symbol("unsubscribe"),L=Symbol("renew"),j=Symbol("getSubscription"),Wt=Symbol("getHandleSubscription"),Ct=Symbol("setHandleSubscription");var Vt=(o,s)=>o>s?1:o<s?-1:0,Et=(o,s)=>o>s?-1:o<s?1:0,yt,gt,Ut,It,O=class extends Array{constructor(t,e){super();i(this,"sorted",[]);i(this,"handleUpdate");i(this,"sortDirection",0);i(this,"sortCompareFunction",null);i(this,It,this.update);i(this,Ut,this.getAsUpdates);i(this,gt,this.getAsInitialUpdated);i(this,yt,this.clear);e&&(this.handleUpdate=e),Array.isArray(t)&&this.update(t)}[D](){return this.handleUpdate}[y](t){return this.handleUpdate=t}update(t){let e=Object.assign([],{deleted:[],added:[]});if(t){let r=!1;for(let a of t)switch(a?.[0]){case"i":{let[,u,b]=a;b?(this.sortDirection=b,this.sortCompareFunction=b>0?Vt:Et,r=!0):(this.sortDirection=0,this.sortCompareFunction=null),this.length=0;for(let p of u)this.push(p),e.push(p),e.added.push(p);break}case"a":{let[,u]=a;this.includes(u)||(this.push(u),this.sortDirection&&(r=!0),e.push(u),e.added.push(u));break}case"d":{let[,u]=a;$t(this,u)&&e.deleted.push(u);break}default:this.clear()}r&&this.sortCompareFunction&&this.sort(this.sortCompareFunction)}else this.clear();return this.handleUpdate?.(this,e,t?.[0]?t:null),this}getAsUpdates(){return this.length||this.sortDirection?[["i",[...this],this.sortDirection]]:null}getAsInitialUpdated(){return Object.assign([...this.sorted],{added:[...this.sorted],deleted:[]})}clear(){this.length=0,this.sortDirection=0,this.sortCompareFunction=null}valueOf(){return this}get[(It=x,Ut=H,gt=A,yt=G,Symbol.toStringTag)](){return"SubscriptionArray"}};i(O,"updateSymbol",x),i(O,"getHandleUpdateSymbol",D),i(O,"setHandleUpdateSymbol",y),i(O,"getAsUpdatesSymbol",H),i(O,"getAsInitialUpdatedSymbol",A),i(O,"clearSymbol",G),i(O,"WithSubscription");var k=class extends O{constructor(t,e,r,a=!0){super(null,r);i(this,"publicationName");i(this,"params");i(this,"subscription",null);this.publicationName=t,this.params=e,a&&this.subscribe()}subscribe(){this.subscription||(this.subscription=new R("array",this.publicationName,this.params,t=>this.update(t)))}get[f](){return this.subscribe}unsubscribe(){this.subscription&&(this.subscription.cancel(),this.subscription=null)}get[g](){return this.unsubscribe}renew(t,e){this.subscription&&(this.unsubscribe(),t&&(Array.isArray(t)?e=t:this.publicationName=t),e&&(this.params=e),this.subscribe())}get[L](){return this.renew}[j](){return this.subscription}get[Symbol.toStringTag](){return"SubscriptionArrayWithSubscription"}};i(k,"subscribeSymbol",f),i(k,"unsubscribeSymbol",g),i(k,"renewSymbol",L),i(k,"getSubscriptionSymbol",j);O.WithSubscription=k;import Qt from"eventemitter3";import{debounce as Xt,StatefulPromise as ot}from"@nesvet/n";var U={};import qt from"eventemitter3";import{debounce as Kt,removeOne as At,StatefulPromise as nt}from"@nesvet/n";import{removeOne as Rt,unique as zt}from"@nesvet/n";function Jt(o){let s=document.createElement("script");s.textContent=`window.__insite_subscription_map_sort_function = function sort(a, b) { return ${Object.entries(o).map(([e,r])=>(e.includes(".")&&(e=e.replaceAll(".","?.")),r>0?`a.${e} > b.${e} ? 1 : a.${e} < b.${e} ? -1 :`:`a.${e} < b.${e} ? 1 : a.${e} > b.${e} ? -1 :`)).concat("0").join(" ")};}`,document.head.append(s);let t=globalThis.__insite_subscription_map_sort_function;return s.remove(),delete globalThis.__insite_subscription_map_sort_function,t}var vt,Tt,wt,xt,X,q,Y,I=class extends Map{constructor(t,e){super();i(this,"handleUpdate");c(this,X,new Map);i(this,"sortList",null);i(this,"sortCompareFunction",null);c(this,q,[]);i(this,"sorted",[]);c(this,Y);i(this,xt,this.update);i(this,wt,this.getAsUpdates);i(this,Tt,this.getAsInitialUpdated);i(this,vt,this.clear);e&&(this.handleUpdate=e),t&&this.update(t)}sort(){this.sortCompareFunction&&this.sorted.sort(this.sortCompareFunction)}[D](){return this.handleUpdate}[y](t){return this.handleUpdate=t}set Item(t){if(l(this,Y,t),this.size)for(let[e,r]of this)this.set(e,new t(this,r))}get Item(){return n(this,Y)}update(t){let e=Object.assign([],{added:[],deleted:[]});if(t){let r=!1,a=n(this,Y),u=n(this,X);for(let b of t)switch(b?.[0]){case"i":{let[,p,h]=b;if(h?(this.sortList=h,this.sortCompareFunction=Jt(h),l(this,q,zt(Object.keys(h).map(m=>m.replace(/\..+/,"")))),r=!0):(this.sortList=null,this.sortCompareFunction=null,l(this,q,[])),this.size){let m=new Map;for(let d of p)m.set(d._id,d);for(let[d,T]of this){let w=m.get(d);if(w){let Bt=u.get(d);if(a)T.update(w);else{for(let Ft in Bt)delete T[Ft];Object.assign(T,w)}u.set(d,w),e.push(T),m.delete(d)}else a?T.delete():this.delete(d),u.delete(d),e.deleted.push(d)}for(let[d,T]of m){let w=a?new a(this,T):{...T};this.set(d,w),u.set(d,T),e.push(w),e.added.push(w)}this.sortList&&(this.sorted=p.map(d=>this.get(d._id)))}else for(let m of p){let d=a?new a(this,m):{...m};this.set(d._id,d),this.sorted.push(d),u.set(d._id,m),e.push(d),e.added.push(d)}break}case"c":case"u":{let[,p]=b,h=this.get(p._id);if(h){let m=b[2]===!0,d=m?Object.keys(p):b[2],T=u.get(h._id);if(a)h.update(p);else{if(!m)for(let w in T)delete h[w];Object.assign(h,p)}m&&(p=Object.assign(T,p)),this.sortList&&!r&&(!d||d.some(w=>n(this,q).includes(w)))&&(r=!0)}else h=a?new a(this,p):{...p},this.set(h._id,h),this.sorted.push(h),this.sortList&&(r=!0),e.added.push(h);u.set(h._id,p),e.push(h);break}case"d":{let[,p]=b,h=this.get(p);h&&(a?h.delete():this.delete(p),u.delete(p),Rt(this.sorted,h),e.deleted.push(p));break}default:this.clear()}r&&this.sort()}else this.clear();return this.handleUpdate?.(this,e,t?.[0]?t:null),this}getAsUpdates(){return this.size||this.sortList?[["i",[...n(this,X).values()],this.sortList]]:null}getAsInitialUpdated(){return Object.assign([...this.sorted],{added:[...this.sorted],deleted:[]})}clear(){super.clear(),n(this,X).clear(),this.sorted=[],this.sortList=null,this.sortCompareFunction=null,l(this,q,[])}valueOf(){return this.sorted}get[(xt=x,wt=H,Tt=A,vt=G,Symbol.toStringTag)](){return"SubscriptionMap"}};X=new WeakMap,q=new WeakMap,Y=new WeakMap,i(I,"updateSymbol",x),i(I,"getHandleUpdateSymbol",D),i(I,"setHandleUpdateSymbol",y),i(I,"getAsUpdatesSymbol",H),i(I,"getAsInitialUpdatedSymbol",A),i(I,"clearSymbol",G),i(I,"WithSubscription"),i(I,"Item");var B=class extends I{constructor(t,e,r,a=!0){super(null,r);i(this,"publicationName");i(this,"params");i(this,"subscription",null);this.publicationName=t,this.params=e,a&&this.subscribe()}subscribe(){this.subscription||(this.subscription=new R("map",this.publicationName,this.params,t=>this.update(t)))}get[f](){return this.subscribe}unsubscribe(){this.subscription&&(this.subscription.cancel(),this.subscription=null)}get[g](){return this.unsubscribe}renew(t,e){this.subscription&&(this.unsubscribe(),t&&(Array.isArray(t)?e=t:this.publicationName=t),e&&(this.params=e),this.subscribe())}get[L](){return this.renew}[j](){return this.subscription}get[Symbol.toStringTag](){return"SubscriptionMapWithSubscription"}};i(B,"subscribeSymbol",f),i(B,"unsubscribeSymbol",g),i(B,"renewSymbol",L),i(B,"getSubscriptionSymbol",j);I.WithSubscription=B;var st,lt=class{constructor(s,t){i(this,"_id");c(this,st);l(this,st,s),this.update(t)}update(s){Object.assign(this,s)}delete(){n(this,st).delete(this._id)}};st=new WeakMap;I.Item=lt;var rt=Symbol("handleUpdate"),z=Symbol("updates"),Dt,Ht,_=class{constructor(s,t){i(this,Ht);i(this,Dt,null);t&&(this[rt]=t),s&&this[x](s)}[(Ht=rt,Dt=z,D)](){return this[rt]}[y](s){return this[rt]=s}[x](s){if(s){for(let t in this[z])delete this[t];for(let t in s)this[t]=s[t];this[z]=s}else this[G]();return this[rt]?.(this,this,this[z]),this}[H](){return this[z]&&{...this[z]}}[A](){return this.valueOf()}[G](){for(let s in this)delete this[s];this[z]=null}valueOf(){return this[z]&&this}get[Symbol.toStringTag](){return"SubscriptionObject"}};i(_,"updateSymbol",x),i(_,"getHandleUpdateSymbol",D),i(_,"setHandleUpdateSymbol",y),i(_,"getAsUpdatesSymbol",H),i(_,"getAsInitialUpdatedSymbol",A),i(_,"clearSymbol",G),i(_,"WithSubscription");var Z,tt,F,M=class extends _{constructor(t,e,r,a=!0){super(null,r);c(this,Z);c(this,tt);c(this,F,null);l(this,Z,t),l(this,tt,e),a&&this[f]()}[f](){n(this,F)||l(this,F,new R("object",n(this,Z),n(this,tt),t=>this[x](t)))}[g](){n(this,F)&&(n(this,F).cancel(),l(this,F,null))}[L](t,e){n(this,F)&&(this[g](),t&&(Array.isArray(t)?e=t:l(this,Z,t)),e&&l(this,tt,e),this[f]())}[j](){return n(this,F)}get[Symbol.toStringTag](){return"SubscriptionObjectWithSubscription"}};Z=new WeakMap,tt=new WeakMap,F=new WeakMap,i(M,"subscribeSymbol",f),i(M,"unsubscribeSymbol",g),i(M,"renewSymbol",L),i(M,"getSubscriptionSymbol",j);_.WithSubscription=M;function Lt(o){return Array.isArray(o)}var N,J,W,v,ht,Ot,E,et,_t,Gt,ct,pt=class pt extends qt{constructor(t,e){super();c(this,v);i(this,"name");i(this,"group");i(this,"value");i(this,"type");i(this,"publicationName");i(this,"params");i(this,"handle");i(this,"onBeforeInit");i(this,"preventBind");i(this,"emitUpdate");i(this,"isLoaded",!1);i(this,"isInited",!1);c(this,N);c(this,J);c(this,W);c(this,E,null);c(this,et,(t,e,r)=>{if(r)if(this.group.isLoaded){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,e,this.group);break;case"map":this.handle.call(this.group,e,this.group);break;default:this.handle.call(this.group,e,this.group)}this.emitUpdate(e)}else l(this,E,e),this.isLoaded=!0,U.groupLoad(this.group);else this.isLoaded&&(this.isLoaded=!1,U.groupUnload(this.group));this.isInited||(this.isInited=!0,U.groupInit(this.group))});this.name=t.name,this.define(t,e)}define(t,e=this.group){if(!e)throw new Error("group is undefined");let{value:r,type:a="object",publicationName:u,params:b,handle:p,onBeforeInit:h,debounce:m=pt.debounceLimit,preventBind:d}=t;if(this.group){if((!r||this.value===r)&&this.type===a&&this.publicationName===u&&JSON.stringify(this.params)===JSON.stringify(b)&&this.handle===p&&this.onBeforeInit===h)return S(this,v,ht).call(this,{debounceLimit:m,preventBind:d});this.detach(),delete this.value,delete this.publicationName,delete this.params}this.type=a,this.handle=p,this.onBeforeInit=h,r?this.value=r:(this.publicationName=u??this.name,this.params=b??[]),S(this,v,ht).call(this,{debounceLimit:m,preventBind:d}),S(this,v,Ot).call(this,e)}detach(){this.group&&(this.value?.[g](),this.isLoaded=!1,S(this,v,ct).call(this),delete this.group.values[this.name],At(this.group.values,this.value),delete this.group.items[this.name],At(this.group.items,this),delete this.group)}loaded(){return n(this,N)}inited(){return n(this,J)}unloaded(){return n(this,W)}subscribe(){if(this.value){if(this.value[f])return this.value[f]();{let t=this.value[D]();if(t){let e=this.value[A](),r=this.value[H]();switch(this.type){case"array":return t(this.value,e,r);case"map":return t(this.value,e,r);default:return t(this.value,e,r)}}}}}unsubscribe(){return this.value?.[g]?.()}renew(t,e){return this.value?.[L]?.(t,e)}valueOf(){return this.value}};N=new WeakMap,J=new WeakMap,W=new WeakMap,v=new WeakSet,ht=function({debounceLimit:t,preventBind:e}){let r=a=>{this.emit("update",this.value,a),this.group?.emit(`update.${this.name}`,this.value,a),this.group?.emitUpdate()};if(typeof t=="number"){let a,u,b=Kt(()=>{let p=!this.group;p&&(this.group=u),r(a),p&&delete this.group,a=void 0},t);this.emitUpdate=p=>{if(p!==void 0)if(Lt(p))if(Lt(a))for(let h of p)a.push(h);else a=Object.assign([...p],{added:[...p.added],deleted:[...p.deleted]});else typeof p=="object"?a?Object.assign(a,p):a={...p}:a=p;return u=this.group,b()}}else this.emitUpdate=r;this.preventBind===void 0?delete this.preventBind:this.preventBind=e},Ot=function(t){if(!this.group){switch(this.group=t,this.group.items.push(this),this.group.items[this.name]=this,(!n(this,N)||n(this,N).isFulfilled)&&l(this,N,new nt),(!n(this,J)||n(this,J).isFulfilled)&&l(this,J,new nt),(!n(this,W)||n(this,W).isFulfilled)&&l(this,W,new nt),this.type){case"array":{let e=n(this,et);this.value?this.value[y](e):this.value=new k(this.publicationName,this.params,e,!1);break}case"map":{let e=n(this,et);this.value?this.value[y](e):this.value=new B(this.publicationName,this.params,e,!1);break}default:{let e=n(this,et);this.value?this.value[y](e):this.value=new M(this.publicationName,this.params,e,!1)}}if(this.group.values.push(this.value),this.group.values[this.name]=this.value,this.onBeforeInit)switch(this.type){case"array":this.onBeforeInit.call(this.group,this.value);break;case"map":this.onBeforeInit.call(this.group,this.value);break;default:this.onBeforeInit.call(this.group,this.value)}}},E=new WeakMap,et=new WeakMap,_t=function(){if(n(this,E)){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,n(this,E),this.group);break;case"map":this.handle.call(this.group,n(this,E),this.group);break;default:this.handle.call(this.group,n(this,E),this.group)}l(this,E,null),this.emit("load",this.value),n(this,N).resolve(this),n(this,W).isFulfilled&&l(this,W,new nt)}},Gt=function(){this.emit("init",this.value),n(this,J).resolve(this)},ct=function(){if(this.handle)switch(this.type){case"array":this.handle.call(this.group,null,this.group);break;case"map":this.handle.call(this.group,null,this.group);break;default:this.handle.call(this.group,null,this.group)}this.emit("unload",this.value),n(this,W).resolve(this),n(this,N).isFulfilled&&l(this,N,new nt)},i(pt,"debounceLimit",4),U.itemLoad=t=>{var e;return S(e=t,v,_t).call(e)},U.itemInit=t=>{var e;return S(e=t,v,Gt).call(e)},U.itemUnload=t=>{var e;return S(e=t,v,ct).call(e)};var at=pt;function Yt(o){return Array.isArray(o)}function Pt(o){if(Yt(o)){let s=o.slice(),t={};if(t.name=s.shift(),typeof s[0]=="object"&&!Array.isArray(s[0])){if(t.value=s.shift(),t.type=t.value.toString().match(/Subscription(Object|Array|Map)/)?.[1].toLowerCase(),!t.type)throw new Error("Unknown value type")}else typeof s[0]=="string"&&(t.type=s.shift()),typeof s[0]=="string"&&(t.publicationName=s.shift()),Array.isArray(s[0])&&(t.params=s.shift());return typeof s[0]=="function"&&(t.handle=s.shift()),typeof s[0]=="function"&&(t.onBeforeInit=s.shift()),typeof s[0]=="number"&&(t.debounce=s.shift()),typeof s[0]=="boolean"&&(t.preventBind=s.shift()),t}return o.type??(o.type="object"),o}var C,it,$,K,V,bt,kt,mt,ut=class ut extends Qt{constructor(t,{target:e,debounce:r=ut.debounceLimit,immediately:a}={}){super();c(this,V);i(this,"target");i(this,"emitUpdate");i(this,"items",[]);i(this,"values",[]);i(this,"isLoaded",!1);i(this,"isInited",!1);c(this,C);c(this,it);c(this,$);c(this,K,null);this.applyOptions({target:e,debounceLimit:r}),l(this,it,new ot),this.attach(t,!1,a)}applyOptions({target:t,debounceLimit:e}){if(this.target!==t){if(this.target)for(let r of this.items)r.isLoaded&&!r.preventBind&&delete this.target[r.name];if(this.target=t,this.target)for(let r of this.items)r.isLoaded&&!r.preventBind&&(this.target[r.name]=r.value)}if(n(this,K)!==e)if(l(this,K,e),typeof n(this,K)=="number"){let r=Xt(()=>this.emit("update",this.values),n(this,K));this.emitUpdate=()=>r()}else this.emitUpdate=()=>this.emit("update",this.values)}attach(t,e=this.isLoaded,r=!0){return e&&(this.isLoaded=!1),(!n(this,C)||n(this,C).isFulfilled)&&l(this,C,new ot),(!n(this,$)||n(this,$).isFulfilled)&&l(this,$,new ot),Promise.all(t.map(a=>new at(Pt(a),this)).map(a=>(r&&a.subscribe(),a.loaded())))}detach(t,e=!0){for(let r of t)this.items[r]?.detach();e&&(S(this,V,mt).call(this),S(this,V,bt).call(this))}redefine(t){let e=new Map(this.items.map(u=>[u.name,u])),r=[],a=[];for(let u of t)u=Pt(u),e.delete(u.name)?r.push(u):a.push(u);return this.isLoaded=!1,this.detach([...e.keys()],!1),Promise.all([...r.map(u=>{let b=this.items[u.name];return b.define(u),b.subscribe(),b.loaded()}),...a.length?[this.attach(a,!1)]:[]])}subscribe(){return this.items.map(t=>t.subscribe())}unsubscribe(){return this.items.map(t=>t.unsubscribe())}loaded(){return n(this,C)}inited(){return n(this,it)}unloaded(){return n(this,$)}valueOf(){return this.values}[Symbol.iterator](){return this.values[Symbol.iterator]()}};C=new WeakMap,it=new WeakMap,$=new WeakMap,K=new WeakMap,V=new WeakSet,bt=function(){if(!this.isLoaded&&this.items.every(t=>t.isLoaded)){if(this.target)for(let t of this.items)t.preventBind||(this.target[t.name]=t.value);this.isLoaded=!0;for(let t of this.items)U.itemLoad(t);if(this.emit("load",this.values),this.isInited)if(this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();n(this,C).resolve(this),n(this,$).isFulfilled&&l(this,$,new ot)}},kt=function(){if(!this.isInited&&this.items.every(t=>t.isInited)){if(this.isInited=!0,this.isLoaded)if(this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();for(let t of this.items)U.itemInit(t);this.emit("init",this.values),n(this,it).resolve(this)}},mt=function(){if(this.isLoaded&&this.items.every(t=>!t.isLoaded)){if(this.target)for(let t of this.items)t.preventBind||delete this.target[t.name];this.isLoaded=!1;for(let t of this.items)U.itemUnload(t);if(this.emit("unload",this.values),this.items.length)for(let t of this.items)t.emitUpdate();else this.emitUpdate();n(this,$).resolve(this),n(this,C).isFulfilled&&l(this,C,new ot)}},i(ut,"debounceLimit",8),U.groupLoad=t=>{var e;return S(e=t,V,bt).call(e)},U.groupInit=t=>{var e;return S(e=t,V,kt).call(e)},U.groupUnload=t=>{var e;return S(e=t,V,mt).call(e)};var jt=ut;export{R as Subscription,O as SubscriptionArray,k as SubscriptionArrayWithSubscription,jt as SubscriptionGroup,I as SubscriptionMap,B as SubscriptionMapWithSubscription,_ as SubscriptionObject,M as SubscriptionObjectWithSubscription,G as clearSymbol,A as getAsInitialUpdatedSymbol,H as getAsUpdatesSymbol,Wt as getHandleSubscriptionSymbol,D as getHandleUpdateSymbol,j as getSubscriptionSymbol,L as renewSymbol,Ct as setHandleSubscriptionSymbol,y as setHandleUpdateSymbol,f as subscribeSymbol,g as unsubscribeSymbol,x as updateSymbol};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/Subscription.ts", "
|
|
4
|
-
"sourcesContent": ["import type { WS } from \"insite-ws/client\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ndeclare global {\n\tvar __initials: unknown[] | undefined;// eslint-disable-line no-var\n}\n\n\nlet i: number;\nlet subscriptions: Map<number, Subscription>;\nlet ws: WS;\n\n\nexport class Subscription {\n\tconstructor(type: \"array\" | \"map\" | \"object\", publicationName: string, args: unknown[] = [], handler: (updates: any) => void, immediately = true) {\n\t\t\n\t\tif (!ws)\n\t\t\tthrow new Error(\"Subscription is not binded to WS. Do Subscription.bindTo(ws) first\");\n\t\t\n\t\tthis.i = i++;\n\t\tthis.type = type;\n\t\tthis.publicationName = publicationName;\n\t\tthis.args = args;\n\t\tthis.handler = handler;\n\t\tthis.immediately = immediately && !globalThis.__initials;\n\t\t\n\t\tsubscriptions.set(this.i, this);\n\t\t\n\t\tws.on(\"open\", this.start);\n\t\t\n\t\tif (ws.isOpen)\n\t\t\tthis.start();\n\t\t\n\t\tif (globalThis.__initials) {\n\t\t\tthis.isActive = true;\n\t\t\tthis.handler(globalThis.__initials.splice(0, 1)[0]);\n\t\t} else\n\t\t\tthis.isActive = false;\n\t\t\n\t}\n\t\n\ti;\n\ttype;\n\tpublicationName;\n\targs;\n\thandler;\n\timmediately;\n\tisActive;\n\t\n\tstart = () => {\n\t\t\n\t\tws.sendMessage(\"s-s\"/* subscription subscribe */, this.type, this.publicationName, this.i, this.args, this.immediately);\n\t\t\n\t\tthis.immediately = true;\n\t\t\n\t};\n\t\n\tcancel() {\n\t\t\n\t\tsubscriptions.delete(this.i);\n\t\t\n\t\tws.off(\"open\", this.start);\n\t\t\n\t\tws.sendMessage(\"s-u\"/* subscription unsubscribe */, this.i);\n\t\t\n\t}\n\t\n\t\n\tstatic bindTo(_ws: WS) {\n\t\tws = _ws;\n\t\t\n\t\ti = 0;\n\t\t\n\t\tsubscriptions = new Map();\n\t\t\n\t\tws.on(\"message:s-c\"/* subscription changed */, (si: number, updates: any) => {\n\t\t\tconst subscription = subscriptions.get(si);\n\t\t\tif (subscription) {\n\t\t\t\tsubscription.isActive = true;\n\t\t\t\tsubscription.handler(updates);\n\t\t\t}\n\t\t\t\n\t\t});\n\t\t\n\t\tws.on(\"close\", () => {\n\t\t\t\n\t\t\tfor (const subscription of subscriptions.values())\n\t\t\t\tsubscription.isActive = false;\n\t\t\t\n\t\t});\n\t\t\n\t\tws.on(\"server-change\", () => {\n\t\t\t\n\t\t\tfor (const subscription of subscriptions.values())\n\t\t\t\tsubscription.handler(null);\n\t\t\t\n\t\t});\n\t\t\n\t}\n\t\n}\n", "export function noop() { /**/ }\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype Value<T> = PromiseLike<T> | T;\ntype Resolve<T> = (value: Value<T>) => void;\ntype Reject = (reason?: any) => void;\n\ntype Options = {\n\tsignal?: AbortSignal;\n\ttimeout?: number;\n};\n\nconst nativesMap = new WeakMap<StatefulPromise<any>, { resolve: Resolve<any>; reject: Reject }>();\n\n\nexport class StatefulPromise<T> extends Promise<T> {\n\tconstructor(\n\t\texecutor?: (resolve: Resolve<T>, reject: Reject) => void,\n\t\toptions?: Options\n\t) {\n\t\tlet nativeResolve: Resolve<T>;\n\t\tlet nativeReject: Reject;\n\t\t\n\t\tsuper((resolve, reject) => {\n\t\t\tnativeResolve = resolve;\n\t\t\tnativeReject = reject;\n\t\t\t\n\t\t});\n\t\t\n\t\tnativesMap.set(this, { resolve: nativeResolve!, reject: nativeReject! });\n\t\t\n\t\tif (options?.signal)\n\t\t\tif (options.signal.aborted)\n\t\t\t\tthis.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\telse {\n\t\t\t\tconst abortListener = () => this.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\t\t\n\t\t\t\toptions.signal.addEventListener(\"abort\", abortListener);\n\t\t\t\t\n\t\t\t\tthis.finally(() => options.signal?.removeEventListener(\"abort\", abortListener));\n\t\t\t}\n\t\t\n\t\tif (typeof options?.timeout === \"number\" && Number.isFinite(options.timeout)) {\n\t\t\tconst timeout = setTimeout(() => this.reject(new DOMException(\"Timeout exceeded\", \"TimeoutError\")), options.timeout);\n\t\t\t\n\t\t\tthis.finally(() => clearTimeout(timeout));\n\t\t}\n\t\t\n\t\texecutor?.(this.resolve, this.reject);\n\t\t\n\t}\n\t\n\tisPending = true;\n\tisFulfilled = false;\n\tisRejected = false;\n\t\n\tstate: \"fulfilled\" | \"pending\" | \"rejected\" = \"pending\";\n\t\n\tresult?: T | unknown;\n\t\n\treadonly resolve = (value: Value<T>) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isFulfilled = true;\n\t\t\tthis.state = \"fulfilled\";\n\t\t\tthis.result = value;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.resolve.call(this, value);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\treadonly reject = (reason?: any) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isRejected = true;\n\t\t\tthis.state = \"rejected\";\n\t\t\tthis.result = reason;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.reject.call(this, reason);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\t\n\tstatic resolved<U>(value: U): StatefulPromise<U> {\n\t\treturn new StatefulPromise<U>(resolve => resolve(value));\n\t}\n\t\n\tstatic rejected(reason: unknown): StatefulPromise<never> {\n\t\treturn new StatefulPromise((_, reject) => reject(reason));\n\t}\n\t\n}\n", "import { noop } from \"./noop.js\";\nimport { StatefulPromise } from \"./StatefulPromise.js\";\n\n\ntype Callback = (...args: any[]) => unknown;// eslint-disable-line @typescript-eslint/no-explicit-any\ntype FunctionOrBoolean = (() => unknown) | boolean;\ntype Options = { leading?: FunctionOrBoolean; maxWait?: number; trailing?: FunctionOrBoolean };\n\ntype DebouncedFunction<C extends Callback> = {\n\t(this: ThisParameterType<C>, ...args: Parameters<C>): Promise<Awaited<ReturnType<C>>>;\n};\n\nexport type Debounced<C extends Callback, R extends ReturnType<C>> = DebouncedFunction<C> & {\n\tcallback: C;\n\tpromise: StatefulPromise<R>;\n\tresolve: (value: R) => void;\n\treject: (reason?: unknown) => void;\n\trun(): Promise<R>;\n\tclear(shouldRun?: boolean): Promise<void>;\n};\n\n\nexport function debounce<C extends Callback, R extends ReturnType<C>>(callback: C, limit = 0, options: Options = {}) {\n\tlet { leading = false, trailing = true } = options;\n\tconst { maxWait = Infinity } = options;\n\t\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet maxWaitTimeout: ReturnType<typeof setTimeout> | undefined;\n\tlet end: number | undefined;\n\tlet context: ThisParameterType<C>;\n\tlet args: unknown[];\n\tlet initial: FunctionOrBoolean;\n\tlet final: FunctionOrBoolean;\n\tlet result: R;\n\t\n\tconst expired = async () => {\n\t\t\n\t\tconst n = Date.now();\n\t\t\n\t\tif (n >= end!) {\n\t\t\ttimeout = undefined;\n\t\t\tend = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tif (typeof final == \"function\")\n\t\t\t\tawait final();\n\t\t\t\n\t\t\tdebounced.resolve(result);\n\t\t\t\n\t\t\tinitial = leading;\n\t\t} else {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(expired, end! - n);\n\t\t}\n\t\t\n\t};\n\t\n\tconst maxWaitExpired = Number.isFinite(maxWait) ? () => {\n\t\t\n\t\tif (final === run)\n\t\t\tfinal = false;\n\t\t\n\t\trun();\n\t\t\n\t\tmaxWaitTimeout = setTimeout(maxWaitExpired as TimerHandler, maxWait);\n\t\t\n\t} : null;\n\t\n\tasync function run() {\n\t\ttry {\n\t\t\tresult = await callback.apply(context, args) as R;\n\t\t\t\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tdebounced.reject(error);\n\t\t\t\n\t\t\tthrow error;\n\t\t}\n\t}\n\t\n\tif (leading && typeof leading == \"boolean\")\n\t\tleading = run;\n\tinitial = leading;\n\t\n\tif (trailing && typeof trailing == \"boolean\")\n\t\ttrailing = run;\n\tfinal = trailing;\n\t\n\tconst debounced: Debounced<C, R> = Object.assign(function (..._args) {\n\t\targs = _args;\n\t\tcontext = this;// eslint-disable-line no-invalid-this\n\t\t\n\t\tend = Date.now() + limit;\n\t\tfinal = trailing;\n\t\t\n\t\tif (!debounced.promise.isPending)\n\t\t\tdebounced.promise = new StatefulPromise<R>((resolve, reject) => {\n\t\t\t\tdebounced.resolve = resolve;\n\t\t\t\tdebounced.reject = reject;\n\t\t\t\t\n\t\t\t\tif (typeof initial == \"function\") {\n\t\t\t\t\tinitial();\n\t\t\t\t\t\n\t\t\t\t\tinitial = false;\n\t\t\t\t\t\n\t\t\t\t\tif (final === run)\n\t\t\t\t\t\tfinal = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!timeout) {\n\t\t\t\t\ttimeout = setTimeout(expired, limit);\n\t\t\t\t\t\n\t\t\t\t\tif (maxWaitExpired)\n\t\t\t\t\t\tmaxWaitTimeout = setTimeout(maxWaitExpired, maxWait);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\n\t\treturn debounced.promise;\n\t} as DebouncedFunction<C>, {\n\t\tcallback,\n\t\tpromise: StatefulPromise.resolved(undefined as unknown as R),\n\t\tresolve: noop,\n\t\treject: noop,\n\t\trun,\n\t\tclear: async (shouldRun?: boolean) => {\n\t\t\t\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tdebounced.resolve(shouldRun ? await run() : result);\n\t\t\t\n\t\t}\n\t});\n\t\n\treturn debounced;\n}\n\n\ndebounce.noop = Object.assign(() => { /**/ }, {\n\tcallback: noop,\n\tpromise: StatefulPromise.resolved(undefined), // eslint-disable-line unicorn/no-useless-undefined\n\tresolve: noop,\n\treject: noop,\n\trun: noop,\n\tclear: noop\n}) as Debounced<() => void, void>;\n\n\nexport function throttle(callback: Callback, limit?: number, options?: Options) {\n\treturn debounce(callback, limit, {\n\t\tmaxWait: limit,\n\t\tleading: true,\n\t\ttrailing: true,\n\t\t...options\n\t});\n}\n", "export function howmuch(number: [] | number, one: string, two: string, five: boolean | string, shouldPrintNumber = true) {\n\tif (Array.isArray(number))\n\t\tnumber = number.length;\n\t\n\tif (typeof five != \"string\") {\n\t\tshouldPrintNumber = five ?? true;\n\t\tfive = two;\n\t}\n\t\n\t\n\treturn (shouldPrintNumber ? `${number}\u00A0` : \"\") + howmuch.raw(number, one, two, five);\n}\n\nhowmuch.raw = (number: number, one: string, two: string, five = two) => {\n\tnumber = Math.abs(number);\n\tconst u = number % 10;\n\tconst d = number % 100;\n\t\n\treturn (\n\t\t(u === 1 && d !== 11) ?\n\t\t\tone :\n\t\t\t((u >= 2 && u <= 4) && !(d >= 12 && d <= 15)) ?\n\t\t\t\ttwo :\n\t\t\t\tfive\n\t);\n};\n", "export function removeOne<T>(array: T[], item: T): boolean {\n\tconst i = array.indexOf(item);\n\tif (i > -1) {\n\t\tarray.splice(i, 1);\n\t\t\n\t\treturn true;\n\t}\n\t\n\treturn false;\n}\n", "export function unique<T>(array: T[]): T[] {\n\treturn [ ...new Set(array) ];\n}\n", "export const updateSymbol = Symbol(\"update\");\nexport const getHandleUpdateSymbol = Symbol(\"getHandleUpdate\");\nexport const setHandleUpdateSymbol = Symbol(\"setHandleUpdate\");\nexport const getAsUpdatesSymbol = Symbol(\"getAsUpdates\");\nexport const getAsInitialUpdatedSymbol = Symbol(\"getAsInitialUpdated\");\nexport const clearSymbol = Symbol(\"clear\");\nexport const subscribeSymbol = Symbol(\"subscribe\");\nexport const unsubscribeSymbol = Symbol(\"unsubscribe\");\nexport const renewSymbol = Symbol(\"renew\");\nexport const getSubscriptionSymbol = Symbol(\"getSubscription\");\nexport const getHandleSubscriptionSymbol = Symbol(\"getHandleSubscription\");\nexport const setHandleSubscriptionSymbol = Symbol(\"setHandleSubscription\");\n", "import { removeOne } from \"@nesvet/n\";\nimport { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ntype Item = unknown;\n\nexport type Updated<I extends Item = Item> = I[] & {\n\tdeleted: I[];\n\tadded: I[];\n};\n\nexport type Updates<I extends Item = Item> =\n\t(\n\t\t[ \"a\"/* add */, newItem: I ] |\n\t\t[ \"d\"/* delete */, itemToDelete: I ] |\n\t\t[ \"i\"/* initial */, items: I[], sort?: -1 | 0 | 1 ] |\n\t\tnull\n\t)[] |\n\tnull;\n\nexport type UpdateHandler<I extends Item = Item> = (array: SubscriptionArray<I>, updated: Updated<I>, updates: Updates<I>) => void;\n\nconst ascSort = (a: any, b: any) => a > b ? 1 : a < b ? -1 : 0;\nconst descSort = (a: any, b: any) => a > b ? -1 : a < b ? 1 : 0;\n\n\nexport class SubscriptionArray<I extends Item = Item> extends Array<I> {\n\tconstructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>) {\n\t\tsuper();\n\t\t\n\t\tif (onUpdate)\n\t\t\tthis.handleUpdate = onUpdate;\n\t\t\n\t\tif (Array.isArray(updates))\n\t\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\tsorted: I[] = [];\n\t\n\thandleUpdate;\n\t\n\tsortDirection: -1 | 0 | 1 = 0;\n\t\n\tsortCompareFunction: typeof ascSort | typeof descSort | null = null;\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this.handleUpdate;\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>) {\n\t\treturn (this.handleUpdate = handleUpdate);\n\t}\n\t\n\tupdate(updates: Updates<I>) {\n\t\t\n\t\tconst updated: Updated<I> = Object.assign([], {\n\t\t\tdeleted: [],\n\t\t\tadded: []\n\t\t});\n\t\t\n\t\tif (updates) {\n\t\t\tlet shouldSort = false;\n\t\t\t\n\t\t\tfor (const update of updates)\n\t\t\t\tswitch (update?.[0]) {\n\t\t\t\t\tcase \"i\"/* initial */: {\n\t\t\t\t\t\tconst [ , array, sort ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sort) {\n\t\t\t\t\t\t\tthis.sortDirection = sort;\n\t\t\t\t\t\t\tthis.sortCompareFunction = sort > 0 ? ascSort : descSort;\n\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.sortDirection = 0;\n\t\t\t\t\t\t\tthis.sortCompareFunction = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.length = 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor (const newItem of array) {\n\t\t\t\t\t\t\tthis.push(newItem);\n\t\t\t\t\t\t\tupdated.push(newItem);\n\t\t\t\t\t\t\tupdated.added.push(newItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"a\"/* add */: {\n\t\t\t\t\t\tconst [ , newItem ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (!this.includes(newItem)) {\n\t\t\t\t\t\t\tthis.push(newItem);\n\t\t\t\t\t\t\tif (this.sortDirection)\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\tupdated.push(newItem);\n\t\t\t\t\t\t\tupdated.added.push(newItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"d\"/* delete */: {\n\t\t\t\t\t\tconst [ , itemToDelete ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (removeOne(this, itemToDelete))\n\t\t\t\t\t\t\tupdated.deleted.push(itemToDelete);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.clear();\n\t\t\t\t}\n\t\t\t\n\t\t\tif (shouldSort && this.sortCompareFunction)\n\t\t\t\tthis.sort(this.sortCompareFunction);\n\t\t\t\n\t\t} else\n\t\t\tthis.clear();\n\t\t\n\t\tthis.handleUpdate?.(this, updated, updates?.[0] ? updates : null);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[updateSymbol] = this.update;\n\t\n\tgetAsUpdates(): Updates<I> {\n\t\treturn (\n\t\t\t(this.length || this.sortDirection) ?\n\t\t\t\t[ [ \"i\"/* initial */, [ ...this ], this.sortDirection ] ] :\n\t\t\t\tnull\n\t\t);\n\t}\n\t\n\t[getAsUpdatesSymbol] = this.getAsUpdates;\n\t\n\tgetAsInitialUpdated(): Updated<I> {\n\t\treturn Object.assign([ ...this.sorted ], {\n\t\t\tadded: [ ...this.sorted ],\n\t\t\tdeleted: []\n\t\t});\n\t}\n\t\n\t[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;\n\t\n\tclear() {\n\t\t\n\t\tthis.length = 0;\n\t\tthis.sortDirection = 0;\n\t\tthis.sortCompareFunction = null;\n\t\t\n\t}\n\t\n\t[clearSymbol] = this.clear;\n\t\n\tvalueOf() {\n\t\treturn this;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionArray\";\n\t}\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionArrayWithSubscription;\n\t\n}\n\n\nexport class SubscriptionArrayWithSubscription<I extends Item = Item> extends SubscriptionArray<I> {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.publicationName = publicationName;\n\t\tthis.params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis.subscribe();\n\t\t\n\t}\n\t\n\tpublicationName;\n\tparams;\n\tsubscription: Subscription | null = null;\n\t\n\tsubscribe() {\n\t\t\n\t\tif (!this.subscription)\n\t\t\tthis.subscription = new Subscription(\"array\", this.publicationName, this.params, updates => this.update(updates as Updates<I>));\n\t\t\n\t}\n\t\n\tget [subscribeSymbol]() {\n\t\treturn this.subscribe;\n\t}\n\t\n\tunsubscribe() {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.subscription.cancel();\n\t\t\tthis.subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\tget [unsubscribeSymbol]() {\n\t\treturn this.unsubscribe;\n\t}\n\t\n\trenew(publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.unsubscribe();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.params = params;\n\t\t\t\n\t\t\tthis.subscribe();\n\t\t}\n\t\t\n\t}\n\t\n\tget [renewSymbol]() {\n\t\treturn this.renew;\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionArrayWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionArray.WithSubscription = SubscriptionArrayWithSubscription;\n", "import EventEmitter from \"eventemitter3\";\nimport { debounce, StatefulPromise } from \"@nesvet/n\";\nimport { privates } from \"./common\";\nimport { SubscriptionGroupItem } from \"./SubscriptionGroupItem\";\nimport {\n\tDefinition,\n\tParseValues,\n\tSubscriptionHandle,\n\tSubscriptionOnBeforeInit,\n\tSubscriptionType,\n\tTupleDefinition,\n\tUnparsedDefinition\n} from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\nfunction isTupleDefinition<T extends SubscriptionType>(definition: UnparsedDefinition<T>): definition is TupleDefinition {\n\treturn Array.isArray(definition);\n}\n\ntype Target = any;\n\ntype Options = {\n\ttarget?: Target;\n\tdebounce?: number;\n\timmediately?: boolean;\n};\n\n\nfunction parseDefinition<T extends SubscriptionType>(definition: UnparsedDefinition<T>) {\n\tif (isTupleDefinition(definition)) {\n\t\tconst args = definition.slice();\n\t\t\n\t\tconst parsed: Partial<Definition<T>> = {};\n\t\t\n\t\tparsed.name = args.shift() as Definition<T>[\"name\"];\n\t\tif (typeof args[0] == \"object\" && !Array.isArray(args[0])) {\n\t\t\tparsed.value = args.shift() as Definition<T>[\"value\"];\n\t\t\tparsed.type = parsed.value!.toString().match(/Subscription(Object|Array|Map)/)?.[1].toLowerCase() as Definition<T>[\"type\"];\n\t\t\tif (!parsed.type)\n\t\t\t\tthrow new Error(\"Unknown value type\");\n\t\t} else {\n\t\t\tif (typeof args[0] == \"string\")\n\t\t\t\tparsed.type = args.shift() as Definition<T>[\"type\"];\n\t\t\tif (typeof args[0] == \"string\")\n\t\t\t\tparsed.publicationName = args.shift() as Definition<T>[\"publicationName\"];\n\t\t\tif (Array.isArray(args[0]))\n\t\t\t\tparsed.params = args.shift() as Definition<T>[\"params\"];\n\t\t}\n\t\t\n\t\tif (typeof args[0] == \"function\")\n\t\t\tparsed.handle = args.shift() as SubscriptionHandle<T>;\n\t\tif (typeof args[0] == \"function\")\n\t\t\tparsed.onBeforeInit = args.shift() as SubscriptionOnBeforeInit<T>;\n\t\tif (typeof args[0] == \"number\")\n\t\t\tparsed.debounce = args.shift() as Definition<T>[\"debounce\"];\n\t\tif (typeof args[0] == \"boolean\")\n\t\t\tparsed.preventBind = args.shift() as Definition<T>[\"preventBind\"];\n\t\t\n\t\treturn parsed as Definition<T>;\n\t}\n\t\n\tdefinition.type ??= \"object\" as T;\n\t\n\treturn definition;\n}\n\nexport class SubscriptionGroup<DS extends UnparsedDefinition[] = any[]> extends EventEmitter {\n\tconstructor(\n\t\tdefinitions: DS,\n\t\t{\n\t\t\ttarget,\n\t\t\tdebounce: debounceLimit = SubscriptionGroup.debounceLimit,\n\t\t\timmediately\n\t\t}: Options = {}\n\t) {\n\t\tsuper();\n\t\t\n\t\tthis.applyOptions({ target, debounceLimit });\n\t\t\n\t\tthis.#initPromise = new StatefulPromise();\n\t\t\n\t\tvoid this.attach(definitions, false, immediately);\n\t\t\n\t}\n\t\n\ttarget?: Target;\n\temitUpdate!: () => void;\n\t\n\titems = [] as unknown as Record<string, SubscriptionGroupItem> & SubscriptionGroupItem[];\n\tvalues = [] as DS extends any ? (any[] & Record<string, any>) : ParseValues<DS>;\n\t\n\tisLoaded = false;\n\tisInited = false;\n\t\n\t#loadPromise!: StatefulPromise<SubscriptionGroup>;\n\t#initPromise: StatefulPromise<SubscriptionGroup>;\n\t#unloadPromise!: StatefulPromise<SubscriptionGroup>;\n\t\n\t#debounceLimit?: number | null = null;\n\t\n\tapplyOptions({ target, debounceLimit }: { target?: Target; debounceLimit?: number }) {\n\t\t\n\t\tif (this.target !== target) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (item.isLoaded && !item.preventBind)\n\t\t\t\t\t\tdelete this.target[item.name];\n\t\t\t\n\t\t\tthis.target = target;\n\t\t\t\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (item.isLoaded && !item.preventBind)\n\t\t\t\t\t\tthis.target[item.name] = item.value;\n\t\t}\n\t\t\n\t\tif (this.#debounceLimit !== debounceLimit) {\n\t\t\tthis.#debounceLimit = debounceLimit;\n\t\t\tif (typeof this.#debounceLimit == \"number\") {\n\t\t\t\tconst emitUpdateDebounced = debounce(() => this.emit(\"update\", this.values), this.#debounceLimit);\n\t\t\t\tthis.emitUpdate = () => emitUpdateDebounced();\n\t\t\t} else\n\t\t\t\tthis.emitUpdate = () => this.emit(\"update\", this.values);\n\t\t}\n\t\t\n\t}\n\t\n\tattach(definitions: DS, shouldReload = this.isLoaded, immediately = true) {\n\t\tif (shouldReload)\n\t\t\tthis.isLoaded = false;\n\t\t\n\t\tif (!this.#loadPromise || this.#loadPromise.isFulfilled)\n\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\n\t\tif (!this.#unloadPromise || this.#unloadPromise.isFulfilled)\n\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t\n\t\treturn Promise.all(definitions.map(definition =>\n\t\t\tnew SubscriptionGroupItem(parseDefinition(definition), this)\n\t\t).map(item => {\n\t\t\t\n\t\t\tif (immediately)\n\t\t\t\titem.subscribe();\n\t\t\t\n\t\t\treturn item.loaded();\n\t\t}));\n\t}\n\t\n\tdetach(names: string[], shouldUpdate = true) {\n\t\t\n\t\tfor (const name of names)\n\t\t\tthis.items[name]?.detach();\n\t\t\n\t\tif (shouldUpdate) {\n\t\t\tthis.#unload();\n\t\t\tthis.#load();\n\t\t}\n\t\t\n\t}\n\t\n\tredefine(definitions: DS) {\n\t\t\n\t\tconst itemsToDetach = new Map(this.items.map(item => [ item.name, item ]));\n\t\tconst definitionsToRedefine = [];\n\t\tconst definitionsToAttach = [] as unknown as DS;\n\t\t\n\t\tfor (let definition of definitions) {\n\t\t\tdefinition = parseDefinition(definition);\n\t\t\tif (itemsToDetach.delete(definition.name))\n\t\t\t\tdefinitionsToRedefine.push(definition);\n\t\t\telse\n\t\t\t\tdefinitionsToAttach.push(definition);\n\t\t}\n\t\t\n\t\tthis.isLoaded = false;\n\t\t\n\t\tthis.detach([ ...itemsToDetach.keys() ], false);\n\t\t\n\t\treturn Promise.all([\n\t\t\t...definitionsToRedefine.map(definition => {\n\t\t\t\tconst item = this.items[definition.name];\n\t\t\t\titem.define(definition);\n\t\t\t\t\n\t\t\t\titem.subscribe();\n\t\t\t\t\n\t\t\t\treturn item.loaded();\n\t\t\t}),\n\t\t\t...definitionsToAttach.length ? [ this.attach(definitionsToAttach, false) ] : []\n\t\t]);\n\t}\n\t\n\tsubscribe() {\n\t\treturn this.items.map(item => item.subscribe());\n\t}\n\t\n\tunsubscribe() {\n\t\treturn this.items.map(item => item.unsubscribe());\n\t}\n\t\n\t#load() {\n\t\t\n\t\tif (!this.isLoaded && this.items.every(item => item.isLoaded)) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (!item.preventBind)\n\t\t\t\t\t\tthis.target[item.name] = item.value;\n\t\t\t\n\t\t\tthis.isLoaded = true;\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemLoad!(item);\n\t\t\t\n\t\t\tthis.emit(\"load\", this.values);\n\t\t\t\n\t\t\tif (this.isInited)\n\t\t\t\tif (this.items.length)\n\t\t\t\t\tfor (const item of this.items)\n\t\t\t\t\t\titem.emitUpdate();\n\t\t\t\telse\n\t\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\t\n\t\t\tthis.#loadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\t#init() {\n\t\t\n\t\tif (!this.isInited && this.items.every(item => item.isInited)) {\n\t\t\tthis.isInited = true;\n\t\t\t\n\t\t\tif (this.isLoaded)\n\t\t\t\tif (this.items.length)\n\t\t\t\t\tfor (const item of this.items)\n\t\t\t\t\t\titem.emitUpdate();\n\t\t\t\telse\n\t\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemInit!(item);\n\t\t\t\n\t\t\tthis.emit(\"init\", this.values);\n\t\t\t\n\t\t\tthis.#initPromise.resolve(this);\n\t\t}\n\t\t\n\t}\n\t\n\t#unload() {\n\t\t\n\t\tif (this.isLoaded && this.items.every(item => !item.isLoaded)) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (!item.preventBind)\n\t\t\t\t\t\tdelete this.target[item.name];\n\t\t\t\n\t\t\tthis.isLoaded = false;\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemUnload!(item);\n\t\t\t\n\t\t\tthis.emit(\"unload\", this.values);\n\t\t\t\n\t\t\tif (this.items.length)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\titem.emitUpdate();\n\t\t\telse\n\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\tthis.#unloadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#loadPromise.isFulfilled)\n\t\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\tloaded() {\n\t\treturn this.#loadPromise;\n\t}\n\t\n\tinited() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\tunloaded() {\n\t\treturn this.#unloadPromise;\n\t}\n\t\n\tvalueOf() {\n\t\treturn this.values;\n\t}\n\t\n\t[Symbol.iterator]() {\n\t\treturn this.values[Symbol.iterator]();\n\t}\n\t\n\t\n\tstatic debounceLimit = 8;\n\t\n\tstatic {\n\t\t\n\t\tprivates.groupLoad = (group: SubscriptionGroup) => group.#load();\n\t\tprivates.groupInit = (group: SubscriptionGroup) => group.#init();\n\t\tprivates.groupUnload = (group: SubscriptionGroup) => group.#unload();\n\t\t\n\t}\n\t\n}\n\nexport { Options as SubscriptionGroupOptions, Target as SubscriptionGroupTarget };\n", "import type { SubscriptionGroup } from \"./SubscriptionGroup\";\nimport type { SubscriptionGroupItem } from \"./SubscriptionGroupItem\";\nimport type { SubscriptionType } from \"./types\";\n\n\nexport const privates: {\n\tgroupLoad?: (group: SubscriptionGroup) => void;\n\tgroupInit?: (group: SubscriptionGroup) => void;\n\tgroupUnload?: (group: SubscriptionGroup) => void;\n\titemLoad?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n\titemInit?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n\titemUnload?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n} = {};\n", "import EventEmitter from \"eventemitter3\";\nimport { debounce, removeOne, StatefulPromise } from \"@nesvet/n\";\nimport {\n\tSubscriptionArrayWithSubscription,\n\ttype Updated as SubscriptionArrayUpdated,\n\ttype UpdateHandler as SubscriptionArrayUpdateHandler,\n\ttype Updates as SubscriptionArrayUpdates\n} from \"../SubscriptionArray\";\nimport {\n\tSubscriptionMapWithSubscription,\n\ttype Updated as SubscriptionMapUpdated,\n\ttype UpdateHandler as SubscriptionMapUpdateHandler,\n\ttype Updates as SubscriptionMapUpdates\n} from \"../SubscriptionMap\";\nimport {\n\tSubscriptionObjectWithSubscription,\n\ttype Updated as SubscriptionObjectUpdated,\n\ttype UpdateHandler as SubscriptionObjectUpdateHandler,\n\ttype Updates as SubscriptionObjectUpdates\n} from \"../SubscriptionObject\";\nimport {\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol\n} from \"../symbols\";\nimport { privates } from \"./common\";\nimport type { SubscriptionGroup } from \"./SubscriptionGroup\";\nimport type {\n\tDefinition,\n\tSubscriptionHandle,\n\tSubscriptionOnBeforeInit,\n\tSubscriptionType,\n\tSubscriptionUpdated,\n\tSubscriptionUpdates,\n\tSubscriptionValue\n} from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ntype HandleSubscription<T> = (_: any, updated: SubscriptionUpdated<T>, updates: SubscriptionUpdates<T>) => void;\n\nfunction isUpdatedMapOrArray(updated: SubscriptionUpdated<SubscriptionType>): updated is SubscriptionArrayUpdated | SubscriptionMapUpdated {\n\treturn Array.isArray(updated);\n}\n\n\nexport class SubscriptionGroupItem<T extends SubscriptionType = SubscriptionType, D extends Definition<T> = Definition<T>> extends EventEmitter {\n\tconstructor(definition: D, group: SubscriptionGroup) {\n\t\tsuper();\n\t\t\n\t\tthis.name = definition.name;\n\t\t\n\t\tthis.define(definition, group);\n\t\t\n\t}\n\t\n\tname;\n\tgroup?: SubscriptionGroup;\n\tvalue?: SubscriptionValue<T>;\n\ttype!: T | \"object\";\n\tpublicationName!: Definition<T>[\"publicationName\"];\n\tparams!: Definition<T>[\"params\"];\n\thandle!: Definition<T>[\"handle\"];\n\tonBeforeInit!: Definition<T>[\"onBeforeInit\"];\n\tpreventBind!: Definition<T>[\"preventBind\"];\n\t\n\temitUpdate!: (updated?: SubscriptionUpdated<T>) => void;\n\t\n\tisLoaded = false;\n\tisInited = false;\n\t\n\t#loadPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t#initPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t#unloadPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t\n\tdefine(definition: Definition<T>, group: SubscriptionGroup | undefined = this.group) {\n\t\tif (!group)\n\t\t\tthrow new Error(\"group is undefined\");\n\t\t\n\t\tconst {\n\t\t\tvalue,\n\t\t\ttype = \"object\",\n\t\t\tpublicationName,\n\t\t\tparams,\n\t\t\thandle,\n\t\t\tonBeforeInit,\n\t\t\tdebounce: debounceLimit = SubscriptionGroupItem.debounceLimit,\n\t\t\tpreventBind\n\t\t} = definition;\n\t\t\n\t\tif (this.group) {\n\t\t\tif (\n\t\t\t\t(!value || this.value === value) &&\n\t\t\t\tthis.type === type &&\n\t\t\t\tthis.publicationName === publicationName &&\n\t\t\t\tJSON.stringify(this.params) === JSON.stringify(params) &&\n\t\t\t\tthis.handle === handle &&\n\t\t\t\tthis.onBeforeInit === onBeforeInit\n\t\t\t)\n\t\t\t\treturn this.#applyOptions({ debounceLimit, preventBind });\n\t\t\t\n\t\t\tthis.detach();\n\t\t\tdelete this.value;\n\t\t\tdelete this.publicationName;\n\t\t\tdelete this.params;\n\t\t}\n\t\t\n\t\tthis.type = type;\n\t\tthis.handle = handle;\n\t\tthis.onBeforeInit = onBeforeInit;\n\t\tif (value)\n\t\t\tthis.value = value;\n\t\telse {\n\t\t\tthis.publicationName = publicationName ?? this.name;\n\t\t\tthis.params = params ?? [];\n\t\t}\n\t\t\n\t\tthis.#applyOptions({ debounceLimit, preventBind });\n\t\t\n\t\tthis.#attachTo(group);\n\t\t\n\t}\n\t\n\t#applyOptions({ debounceLimit, preventBind }: { debounceLimit?: number; preventBind?: boolean }) {\n\t\t\n\t\tconst emitUpdate: typeof this.emitUpdate = updated => {\n\t\t\tthis.emit(\"update\", this.value, updated);\n\t\t\tthis.group?.emit(`update.${this.name}`, this.value, updated);\n\t\t\tthis.group?.emitUpdate();\n\t\t\t\n\t\t};\n\t\t\n\t\tif (typeof debounceLimit == \"number\") {\n\t\t\tlet debouncedUpdated: SubscriptionUpdated<T> | undefined;\n\t\t\tlet group: SubscriptionGroup;\n\t\t\t\n\t\t\tconst emitUpdateDebounced = debounce(() => {\n\t\t\t\t\n\t\t\t\tconst isDetached = !this.group;\n\t\t\t\t\n\t\t\t\tif (isDetached)\n\t\t\t\t\tthis.group = group;\n\t\t\t\t\n\t\t\t\temitUpdate(debouncedUpdated);\n\t\t\t\t\n\t\t\t\tif (isDetached)\n\t\t\t\t\tdelete this.group;\n\t\t\t\t\n\t\t\t\tdebouncedUpdated = undefined;\n\t\t\t\t\n\t\t\t}, debounceLimit);\n\t\t\t\n\t\t\tthis.emitUpdate = updated => {\n\t\t\t\tif (updated !== undefined)\n\t\t\t\t\tif (isUpdatedMapOrArray(updated))\n\t\t\t\t\t\tif (isUpdatedMapOrArray(debouncedUpdated!))\n\t\t\t\t\t\t\tfor (const item of updated)\n\t\t\t\t\t\t\t\tdebouncedUpdated.push(item);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdebouncedUpdated = Object.assign([ ...updated ], {\n\t\t\t\t\t\t\t\tadded: [ ...updated.added ],\n\t\t\t\t\t\t\t\tdeleted: [ ...updated.deleted ]\n\t\t\t\t\t\t\t}) as SubscriptionUpdated<T>;\n\t\t\t\t\telse if (typeof updated == \"object\")\n\t\t\t\t\t\tif (debouncedUpdated)\n\t\t\t\t\t\t\tObject.assign(debouncedUpdated, updated);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdebouncedUpdated = { ...updated };\n\t\t\t\t\telse\n\t\t\t\t\t\tdebouncedUpdated = updated;\n\t\t\t\t\n\t\t\t\tgroup = this.group!;\n\t\t\t\t\n\t\t\t\treturn emitUpdateDebounced();\n\t\t\t};\n\t\t} else\n\t\t\tthis.emitUpdate = emitUpdate;\n\t\t\n\t\tif (this.preventBind === undefined)\n\t\t\tdelete this.preventBind;\n\t\telse\n\t\t\tthis.preventBind = preventBind;\n\t\t\n\t}\n\t\n\t#attachTo(group: SubscriptionGroup) {\n\t\tif (!this.group) {\n\t\t\tthis.group = group;\n\t\t\t\n\t\t\tthis.group.items.push(this as SubscriptionGroupItem<any>);\n\t\t\tthis.group.items[this.name] = this as SubscriptionGroupItem<any>;\n\t\t\t\n\t\t\tif (!this.#loadPromise || this.#loadPromise.isFulfilled)\n\t\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\t\n\t\t\tif (!this.#initPromise || this.#initPromise.isFulfilled)\n\t\t\t\tthis.#initPromise = new StatefulPromise();\n\t\t\t\n\t\t\tif (!this.#unloadPromise || this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t\t\n\t\t\tswitch (this.type) {\n\t\t\t\tcase \"array\": {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"array\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionArrayWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionArrayWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t\tbreak;\n\t\t\t\t} case \"map\": {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"map\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionMapWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionMapWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t\tbreak;\n\t\t\t\t} default: {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"object\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionObjectWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionObjectWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tthis.group.values.push(this.value);\n\t\t\tthis.group.values[this.name] = this.value;\n\t\t\t\n\t\t\tif (this.onBeforeInit)\n\t\t\t\tswitch (this.type) {\n\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"array\">).call(this.group, this.value as SubscriptionArrayWithSubscription);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"map\">).call(this.group, this.value as SubscriptionMapWithSubscription);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"object\">).call(this.group, this.value as SubscriptionObjectWithSubscription);\n\t\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\tdetach() {\n\t\t\n\t\tif (this.group) {\n\t\t\tthis.value?.[unsubscribeSymbol]();\n\t\t\t\n\t\t\tthis.isLoaded = false;\n\t\t\tthis.#unload();\n\t\t\t\n\t\t\tdelete this.group.values[this.name];// eslint-disable-line @typescript-eslint/no-array-delete\n\t\t\tremoveOne(this.group.values, this.value);\n\t\t\tdelete this.group.items[this.name];// eslint-disable-line @typescript-eslint/no-array-delete\n\t\t\tremoveOne(this.group.items, this as SubscriptionGroupItem<any>);\n\t\t\t\n\t\t\tdelete this.group;\n\t\t}\n\t\t\n\t}\n\t\n\t#loadUpdated: SubscriptionUpdated<T> | null = null;\n\t\n\t#handleSubscription: HandleSubscription<T> = (_, updated, updates) => {\n\t\tif (updates)\n\t\t\tif (this.group!.isLoaded) {\n\t\t\t\tif (this.handle)\n\t\t\t\t\tswitch (this.type) {\n\t\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, updated as SubscriptionArrayUpdated, this.group!);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, updated as SubscriptionMapUpdated, this.group!);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, updated as SubscriptionObjectUpdated, this.group!);\n\t\t\t\t\t}\n\t\t\t\tthis.emitUpdate(updated);\n\t\t\t} else {\n\t\t\t\tthis.#loadUpdated = updated;\n\t\t\t\tthis.isLoaded = true;\n\t\t\t\tprivates.groupLoad!(this.group!);\n\t\t\t}\n\t\telse if (this.isLoaded) {\n\t\t\tthis.isLoaded = false;\n\t\t\tprivates.groupUnload!(this.group!);\n\t\t}\n\t\t\n\t\tif (!this.isInited) {\n\t\t\tthis.isInited = true;\n\t\t\tprivates.groupInit!(this.group!);\n\t\t}\n\t\t\n\t};\n\t\n\t#load() {\n\t\t\n\t\tif (this.#loadUpdated) {\n\t\t\tif (this.handle)\n\t\t\t\tswitch (this.type) {\n\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, this.#loadUpdated as SubscriptionArrayUpdated, this.group!);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, this.#loadUpdated as SubscriptionMapUpdated, this.group!);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, this.#loadUpdated as SubscriptionObjectUpdated, this.group!);\n\t\t\t\t}\n\t\t\t\n\t\t\tthis.#loadUpdated = null;\n\t\t\t\n\t\t\tthis.emit(\"load\", this.value);\n\t\t\t\n\t\t\tthis.#loadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\t#init() {\n\t\t\n\t\tthis.emit(\"init\", this.value);\n\t\t\n\t\tthis.#initPromise.resolve(this);\n\t\t\n\t}\n\t\n\t#unload() {\n\t\t\n\t\tif (this.handle)\n\t\t\tswitch (this.type) {\n\t\t\t\tcase \"array\":\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, null, this.group!);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"map\":\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, null, this.group!);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, null, this.group!);\n\t\t\t}\n\t\t\n\t\tthis.emit(\"unload\", this.value);\n\t\t\n\t\tthis.#unloadPromise.resolve(this);\n\t\t\n\t\tif (this.#loadPromise.isFulfilled)\n\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\n\t}\n\t\n\tloaded() {\n\t\treturn this.#loadPromise;\n\t}\n\t\n\tinited() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\tunloaded() {\n\t\treturn this.#unloadPromise;\n\t}\n\t\n\tsubscribe() {\n\t\t\n\t\tif (this.value)\n\t\t\tif (this.value[subscribeSymbol])\n\t\t\t\treturn this.value[subscribeSymbol]();\n\t\t\telse {\n\t\t\t\tconst handleUpdate = this.value[getHandleUpdateSymbol]();\n\t\t\t\t\n\t\t\t\tif (handleUpdate) {\n\t\t\t\t\tconst initialUpdated = this.value[getAsInitialUpdatedSymbol]();\n\t\t\t\t\tconst updates = this.value[getAsUpdatesSymbol]();\n\t\t\t\t\t\n\t\t\t\t\tswitch (this.type) {\n\t\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionArrayUpdateHandler)(this.value as SubscriptionArrayWithSubscription, initialUpdated as SubscriptionArrayUpdated, updates as SubscriptionArrayUpdates);\n\t\t\t\t\t\t\n\t\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionMapUpdateHandler)(this.value as SubscriptionMapWithSubscription, initialUpdated as SubscriptionMapUpdated, updates as SubscriptionMapUpdates);\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionObjectUpdateHandler)(this.value as SubscriptionObjectWithSubscription, initialUpdated as SubscriptionObjectUpdated, updates as SubscriptionObjectUpdates);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t}\n\t\n\tunsubscribe() {\n\t\treturn this.value?.[unsubscribeSymbol]?.();\n\t}\n\t\n\trenew(publicationName: Definition<T>[\"publicationName\"], params: Definition<T>[\"params\"]) {\n\t\treturn this.value?.[renewSymbol]?.(publicationName, params);\n\t}\n\t\n\tvalueOf() {\n\t\treturn this.value;\n\t}\n\t\n\t\n\tstatic debounceLimit = 4;\n\t\n\tstatic {\n\t\t\n\t\tprivates.itemLoad = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#load();\n\t\tprivates.itemInit = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#init();\n\t\tprivates.itemUnload = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#unload();\n\t\t\n\t}\n\t\n}\n", "import { removeOne, unique } from \"@nesvet/n\";\nimport { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\ntype GenericItem = Record<string, any> & { _id: string };// eslint-disable-line @typescript-eslint/no-explicit-any\n\ntype Item = GenericItem | SubscriptionMapItem;\n\nexport type Updated<I extends Item = Item> = I[] & {\n\tdeleted: string[];\n\tadded: I[];\n};\n\ntype SortList = Record<string, -1 | 1>;\n\nexport type Updates<I extends Item = Item> =\n\t(\n\t\t[ \"c\"/* create */, item: I ] |\n\t\t[ \"d\"/* delete */, _id: string ] |\n\t\t[ \"i\"/* initial */, items: I[], sortList?: SortList | null ] |\n\t\t[ \"u\"/* update */, itemUpdates: Partial<I> & { _id: string }, isAtomicOrUpdatedFields: string[] | true ] |\n\t\tnull\n\t)[] |\n\tnull;\n\nexport type UpdateHandler<I extends Item = Item> = (map: SubscriptionMap<I>, updated: Updated<I>, updates: Updates<I>) => void;\n\ndeclare global {\n\tvar __insite_subscription_map_sort_function: ((a: Item, b: Item) => -1 | 0 | 1) | undefined;// eslint-disable-line no-var, @typescript-eslint/naming-convention\n}\n\nfunction createSortFunction(sortList: SortList) {\n\t\n\tconst tempScript = document.createElement(\"script\");\n\t\n\ttempScript.textContent = `window.__insite_subscription_map_sort_function = function sort(a, b) { return ${\n\t\tObject.entries(sortList)\n\t\t\t.map(([ key, value ]) => {\n\t\t\t\tif (key.includes(\".\"))\n\t\t\t\t\tkey = key.replaceAll(\".\", \"?.\");\n\t\t\t\t\n\t\t\t\treturn value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`;\n\t\t\t})\n\t\t\t.concat(\"0\")\n\t\t\t.join(\" \")\n\t};}`;\n\t\n\tdocument.head.append(tempScript);\n\t\n\tconst sortFunction = globalThis.__insite_subscription_map_sort_function!;\n\t\n\ttempScript.remove();\n\tdelete globalThis.__insite_subscription_map_sort_function;\n\t\n\treturn sortFunction;\n}\n\n// function createSortFunction(sortList: SortList) {\n// return new Function(// eslint-disable-line no-new-func\n// \t\t\"a\"/* Item */,\n// \t\t\"b\"/* Item */,\n// \t\t`return ${\n// \t\t\tObject.entries(sortList)\n// \t\t\t\t.map(([ key, value ]) => value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`)\n// \t\t\t\t.concat(\"0\")\n// \t\t\t\t.join(\" \")\n// \t\t}`\n// \t) as (a: Item, b: Item) => -1 | 0 | 1;\n// }\n\n\nexport class SubscriptionMap<I extends Item = Item> extends Map<string, I> {\n\tconstructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>) {\n\t\tsuper();\n\t\t\n\t\tif (onUpdate)\n\t\t\tthis.handleUpdate = onUpdate;\n\t\t\n\t\tif (updates)\n\t\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\thandleUpdate;\n\t\n\t#updates = new Map<string, I>();\n\t\n\tsortList: SortList | null = null;\n\t\n\tsortCompareFunction: ((a: I, b: I) => number) | null = null;\n\t\n\t#fieldsToSort: string[] = [];\n\t\n\tsorted: I[] = [];\n\t\n\tsort() {\n\t\t\n\t\tif (this.sortCompareFunction)\n\t\t\tthis.sorted.sort(this.sortCompareFunction);\n\t\t\n\t}\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this.handleUpdate;\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>) {\n\t\treturn (this.handleUpdate = handleUpdate);\n\t}\n\t\n\t#Item!: { new (map: SubscriptionMap<I>, updates: GenericItem): I };\n\t\n\tset Item(TheItem: { new (map: SubscriptionMap<I>, updates: GenericItem): I }) { // eslint-disable-line @typescript-eslint/naming-convention\n\t\tthis.#Item = TheItem;\n\t\t\n\t\tif (this.size)\n\t\t\tfor (const [ _id, item ] of this)\n\t\t\t\tthis.set(_id, new TheItem(this, item));\n\t\t\n\t}\n\t\n\tget Item() {\n\t\treturn this.#Item;\n\t}\n\t\n\tupdate(updates: Updates<I>) {\n\t\t\n\t\tconst updated: Updated<I> = Object.assign([], {\n\t\t\tadded: [],\n\t\t\tdeleted: []\n\t\t});\n\t\t\n\t\tif (updates) {\n\t\t\tlet shouldSort = false;\n\t\t\t\n\t\t\tconst TheItem = this.#Item;// eslint-disable-line @typescript-eslint/naming-convention\n\t\t\tconst prevUpdates = this.#updates;\n\t\t\t\n\t\t\tfor (const update of updates)\n\t\t\t\tswitch (update?.[0]) {\n\t\t\t\t\tcase \"i\"/* initial */: {\n\t\t\t\t\t\tconst [ , array, sortList ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sortList) {\n\t\t\t\t\t\t\tthis.sortList = sortList;\n\t\t\t\t\t\t\tthis.sortCompareFunction = createSortFunction(sortList);\n\t\t\t\t\t\t\tthis.#fieldsToSort = unique(Object.keys(sortList).map(key => key.replace(/\\..+/, \"\")));\n\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.sortList = null;\n\t\t\t\t\t\t\tthis.sortCompareFunction = null;\n\t\t\t\t\t\t\tthis.#fieldsToSort = [];\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (this.size) {\n\t\t\t\t\t\t\tconst updatesMap = new Map<string, I>();\n\t\t\t\t\t\t\tfor (const itemUpdates of array)\n\t\t\t\t\t\t\t\tupdatesMap.set(itemUpdates._id, itemUpdates);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (const [ _id, item ] of this) {\n\t\t\t\t\t\t\t\tconst itemUpdates = updatesMap.get(_id);\n\t\t\t\t\t\t\t\tif (itemUpdates) {\n\t\t\t\t\t\t\t\t\tconst prevItemUpdates = prevUpdates.get(_id);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\t\t\titem.update(itemUpdates);\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tfor (const key in prevItemUpdates)// eslint-disable-line guard-for-in\n\t\t\t\t\t\t\t\t\t\t\tdelete item[key as keyof typeof item];\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tObject.assign(item, itemUpdates);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tprevUpdates.set(_id, itemUpdates);\n\t\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\t\tupdatesMap.delete(_id);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\t\t\titem.delete();\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tthis.delete(_id);\n\t\t\t\t\t\t\t\t\tprevUpdates.delete(_id);\n\t\t\t\t\t\t\t\t\tupdated.deleted.push(_id);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (const [ _id, itemUpdates ] of updatesMap) {\n\t\t\t\t\t\t\t\tconst item = TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates };\n\t\t\t\t\t\t\t\tthis.set(_id, item);\n\t\t\t\t\t\t\t\tprevUpdates.set(_id, itemUpdates);\n\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.sortList)\n\t\t\t\t\t\t\t\tthis.sorted = array.map(newItem => this.get(newItem._id)!);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tfor (const itemUpdates of array) {\n\t\t\t\t\t\t\t\tconst item = (TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates });\n\t\t\t\t\t\t\t\tthis.set(item._id, item);\n\t\t\t\t\t\t\t\tthis.sorted.push(item);\n\t\t\t\t\t\t\t\tprevUpdates.set(item._id, itemUpdates);\n\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"c\"/* create */:\n\t\t\t\t\tcase \"u\"/* update */: {\n\t\t\t\t\t\tlet [ , itemUpdates ] = update;\n\t\t\t\t\t\tlet item = this.get(itemUpdates._id);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (item) {\n\t\t\t\t\t\t\tconst isAtomic = update[2] === true;\n\t\t\t\t\t\t\tconst updatedFields = isAtomic ? Object.keys(itemUpdates) : update[2] as string[];\n\t\t\t\t\t\t\tconst prevItemUpdates = prevUpdates.get(item._id)!;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\titem.update(itemUpdates);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (!isAtomic)\n\t\t\t\t\t\t\t\t\tfor (const key in prevItemUpdates)// eslint-disable-line guard-for-in\n\t\t\t\t\t\t\t\t\t\tdelete item[key as keyof typeof item];\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tObject.assign(item, itemUpdates);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (isAtomic)\n\t\t\t\t\t\t\t\titemUpdates = Object.assign(prevItemUpdates, itemUpdates);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.sortList && !shouldSort && (!updatedFields || updatedFields.some(fieldName => this.#fieldsToSort.includes(fieldName))))\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem = (TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates }) as I;\n\t\t\t\t\t\t\tthis.set(item._id, item);\n\t\t\t\t\t\t\tthis.sorted.push(item);\n\t\t\t\t\t\t\tif (this.sortList)\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tprevUpdates.set(item._id, itemUpdates as I);\n\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"d\"/* delete */: {\n\t\t\t\t\t\tconst [ , _id ] = update;\n\t\t\t\t\t\tconst itemToDelete = this.get(_id);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (itemToDelete) {\n\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\titemToDelete.delete();\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tthis.delete(_id);\n\t\t\t\t\t\t\tprevUpdates.delete(_id);\n\t\t\t\t\t\t\tremoveOne(this.sorted, itemToDelete);\n\t\t\t\t\t\t\tupdated.deleted.push(_id);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.clear();\n\t\t\t\t}\n\t\t\t\n\t\t\tif (shouldSort)\n\t\t\t\tthis.sort();\n\t\t\t\n\t\t} else\n\t\t\tthis.clear();\n\t\t\n\t\tthis.handleUpdate?.(this, updated, updates?.[0] ? updates : null);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[updateSymbol] = this.update;\n\t\n\tgetAsUpdates(): Updates<I> {\n\t\treturn (\n\t\t\t(this.size || this.sortList) ?\n\t\t\t\t[ [ \"i\"/* initial */, [ ...this.#updates.values() ], this.sortList ] ] :\n\t\t\t\tnull\n\t\t);\n\t}\n\t\n\t[getAsUpdatesSymbol] = this.getAsUpdates;\n\t\n\tgetAsInitialUpdated(): Updated<I> {\n\t\treturn Object.assign([ ...this.sorted ], {\n\t\t\tadded: [ ...this.sorted ],\n\t\t\tdeleted: []\n\t\t});\n\t}\n\t\n\t[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;\n\t\n\tclear() {\n\t\t\n\t\tsuper.clear();\n\t\tthis.#updates.clear();\n\t\tthis.sorted = [];\n\t\tthis.sortList = null;\n\t\tthis.sortCompareFunction = null;\n\t\tthis.#fieldsToSort = [];\n\t\t\n\t}\n\t\n\t[clearSymbol] = this.clear;\n\t\n\tvalueOf() {\n\t\treturn this.sorted;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionMap\";\n\t}\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionMapWithSubscription;\n\tstatic Item: typeof SubscriptionMapItem;\n\t\n}\n\n\nexport class SubscriptionMapWithSubscription<I extends Item = Item> extends SubscriptionMap<I> {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.publicationName = publicationName;\n\t\tthis.params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis.subscribe();\n\t\t\n\t}\n\t\n\tpublicationName;\n\tparams;\n\t\n\tsubscription: Subscription | null = null;\n\t\n\tsubscribe() {\n\t\t\n\t\tif (!this.subscription)\n\t\t\tthis.subscription = new Subscription(\"map\", this.publicationName, this.params, updates => this.update(updates as Updates<I>));\n\t\t\n\t}\n\t\n\tget [subscribeSymbol]() {\n\t\treturn this.subscribe;\n\t}\n\t\n\tunsubscribe() {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.subscription.cancel();\n\t\t\tthis.subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\tget [unsubscribeSymbol]() {\n\t\treturn this.unsubscribe;\n\t}\n\t\n\trenew(publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.unsubscribe();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.params = params;\n\t\t\t\n\t\t\tthis.subscribe();\n\t\t}\n\t\t\n\t}\n\t\n\tget [renewSymbol]() {\n\t\treturn this.renew;\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionMapWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionMap.WithSubscription = SubscriptionMapWithSubscription;\n\n\nexport class SubscriptionMapItem {\n\tconstructor(map: SubscriptionMap, updates: GenericItem) {\n\t\tthis.#map = map;\n\t\t\n\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\t_id!: string;\n\t\n\t#map;\n\t\n\tupdate(updates: GenericItem) {\n\t\tObject.assign(this, updates);\n\t\t\n\t}\n\t\n\tdelete() {\n\t\t\n\t\tthis.#map.delete(this._id);\n\t\t\n\t}\n\t\n}\n\nSubscriptionMap.Item = SubscriptionMapItem;\n", "import { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\nconst handleUpdateSymbol = Symbol(\"handleUpdate\");\nconst updatesSymbol = Symbol(\"updates\");\n\nexport type Updated = Record<string, unknown>;\nexport type Updates = Record<string, unknown> | null;\nexport type UpdateHandler = (object: SubscriptionObject, updated: Updated, updates: Updates) => void;\n\n\nexport class SubscriptionObject {\n\tconstructor(updates?: Updates, onUpdate?: UpdateHandler) {\n\t\tif (onUpdate)\n\t\t\tthis[handleUpdateSymbol] = onUpdate;\n\t\t\n\t\tif (updates)\n\t\t\tthis[updateSymbol](updates);\n\t\t\n\t}\n\t\n\t[handleUpdateSymbol]?: UpdateHandler;\n\t\n\t[updatesSymbol]: Updates = null;\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this[handleUpdateSymbol];\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler) {\n\t\treturn (this[handleUpdateSymbol] = handleUpdate);\n\t}\n\t\n\t[updateSymbol](updates: Updates) {\n\t\tif (updates) {\n\t\t\tfor (const key in this[updatesSymbol])// eslint-disable-line guard-for-in\n\t\t\t\tdelete this[key];\n\t\t\tfor (const key in updates)// eslint-disable-line guard-for-in\n\t\t\t\tthis[key] = updates[key];\n\t\t\tthis[updatesSymbol] = updates;\n\t\t} else\n\t\t\tthis[clearSymbol]();\n\t\t\n\t\tthis[handleUpdateSymbol]?.(this, this, this[updatesSymbol]);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[getAsUpdatesSymbol](): Updates {\n\t\treturn this[updatesSymbol] && { ...this[updatesSymbol] };\n\t}\n\t\n\t[getAsInitialUpdatedSymbol](): Updated {\n\t\treturn this.valueOf()!;\n\t}\n\t\n\t[clearSymbol]() {\n\t\t\n\t\tfor (const key in this)// eslint-disable-line guard-for-in\n\t\t\tdelete this[key];\n\t\tthis[updatesSymbol] = null;\n\t\t\n\t}\n\t\n\tvalueOf() {\n\t\treturn this[updatesSymbol] && this;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionObject\";\n\t}\n\t\n\t[key: string]: unknown;\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionObjectWithSubscription;\n\t\n}\n\n\nexport class SubscriptionObjectWithSubscription extends SubscriptionObject {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.#publicationName = publicationName;\n\t\tthis.#params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis[subscribeSymbol]();\n\t\t\n\t}\n\t\n\t#publicationName;\n\t#params;\n\t#subscription: Subscription | null = null;\n\t\n\t[subscribeSymbol]() {\n\t\t\n\t\tif (!this.#subscription)\n\t\t\tthis.#subscription = new Subscription(\"object\", this.#publicationName, this.#params, updates => this[updateSymbol](updates as Updates));\n\t\t\n\t}\n\t\n\t[unsubscribeSymbol]() {\n\t\t\n\t\tif (this.#subscription) {\n\t\t\tthis.#subscription.cancel();\n\t\t\tthis.#subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\t[renewSymbol](publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.#subscription) {\n\t\t\tthis[unsubscribeSymbol]();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.#publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.#params = params;\n\t\t\t\n\t\t\tthis[subscribeSymbol]();\n\t\t}\n\t\t\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.#subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionObjectWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionObject.WithSubscription = SubscriptionObjectWithSubscription;\n"],
|
|
5
|
-
"mappings": "oiBAWA,IAAIA,GACAC,GACAC,EAGSC,EAAN,KAAmB,CACzB,YAAYC,EAAkCC,EAAyBC,EAAkB,CAAC,EAAGC,EAAiCC,EAAc,GAAM,CA2BlJC,EAAA,UACAA,EAAA,aACAA,EAAA,wBACAA,EAAA,aACAA,EAAA,gBACAA,EAAA,oBACAA,EAAA,iBAEAA,EAAA,aAAQ,IAAM,CAEbP,EAAG,YAAY,MAAmC,KAAK,KAAM,KAAK,gBAAiB,KAAK,EAAG,KAAK,KAAM,KAAK,WAAW,EAEtH,KAAK,YAAc,EAEpB,GAvC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EAAAM,EAAAD,EAAM5B,EAAAC,IAAN,KAAA4B,IACnDF,EAAS,UAAaC,GAA0B,CAvTlD,IAAAC,EAuTqD,OAAAN,EAAAM,EAAAD,EAAM5B,EAAAE,IAAN,KAAA2B,IACnDF,EAAS,YAAeC,GAA0B,CAxTpD,IAAAC,EAwTuD,OAAAN,EAAAM,EAAAD,EAAM5B,EAAAG,IAAN,KAAA0B,IAnPhD,IAAMC,GAAN1B",
|
|
6
|
-
"names": ["i", "subscriptions", "ws", "Subscription", "type", "publicationName", "args", "handler", "immediately", "__publicField", "_ws", "si", "updates", "subscription", "
|
|
3
|
+
"sources": ["../src/Subscription.ts", "../src/SubscriptionArray.ts", "../src/symbols.ts", "../src/SubscriptionGroup/SubscriptionGroup.ts", "../src/SubscriptionGroup/common.ts", "../src/SubscriptionGroup/SubscriptionGroupItem.ts", "../src/SubscriptionMap.ts", "../src/SubscriptionObject.ts"],
|
|
4
|
+
"sourcesContent": ["import type { WS } from \"insite-ws/client\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ndeclare global {\n\tvar __initials: unknown[] | undefined;\n}\n\n\nlet i: number;\nlet subscriptions: Map<number, Subscription>;\nlet ws: WS;\n\n\nexport class Subscription {\n\tconstructor(type: \"array\" | \"map\" | \"object\", publicationName: string, args: unknown[] = [], handler: (updates: any) => void, immediately = true) {\n\t\t\n\t\tif (!ws)\n\t\t\tthrow new Error(\"Subscription is not binded to WS. Do Subscription.bindTo(ws) first\");\n\t\t\n\t\tthis.i = i++;\n\t\tthis.type = type;\n\t\tthis.publicationName = publicationName;\n\t\tthis.args = args;\n\t\tthis.handler = handler;\n\t\tthis.immediately = immediately && !globalThis.__initials;\n\t\t\n\t\tsubscriptions.set(this.i, this);\n\t\t\n\t\tws.on(\"open\", this.start);\n\t\t\n\t\tif (ws.isOpen)\n\t\t\tthis.start();\n\t\t\n\t\tif (globalThis.__initials) {\n\t\t\tthis.isActive = true;\n\t\t\tthis.handler(globalThis.__initials.splice(0, 1)[0]);\n\t\t} else\n\t\t\tthis.isActive = false;\n\t\t\n\t}\n\t\n\ti;\n\ttype;\n\tpublicationName;\n\targs;\n\thandler;\n\timmediately;\n\tisActive;\n\t\n\tstart = () => {\n\t\t\n\t\tws.sendMessage(\"s-s\"/* subscription subscribe */, this.type, this.publicationName, this.i, this.args, this.immediately);\n\t\t\n\t\tthis.immediately = true;\n\t\t\n\t};\n\t\n\tcancel() {\n\t\t\n\t\tsubscriptions.delete(this.i);\n\t\t\n\t\tws.off(\"open\", this.start);\n\t\t\n\t\tws.sendMessage(\"s-u\"/* subscription unsubscribe */, this.i);\n\t\t\n\t}\n\t\n\t\n\tstatic bindTo(_ws: WS) {\n\t\tws = _ws;\n\t\t\n\t\ti = 0;\n\t\t\n\t\tsubscriptions = new Map();\n\t\t\n\t\tws.on(\"message:s-c\"/* subscription changed */, (si: number, updates: any) => {\n\t\t\tconst subscription = subscriptions.get(si);\n\t\t\tif (subscription) {\n\t\t\t\tsubscription.isActive = true;\n\t\t\t\tsubscription.handler(updates);\n\t\t\t}\n\t\t\t\n\t\t});\n\t\t\n\t\tws.on(\"close\", () => {\n\t\t\t\n\t\t\tfor (const subscription of subscriptions.values())\n\t\t\t\tsubscription.isActive = false;\n\t\t\t\n\t\t});\n\t\t\n\t\tws.on(\"server-change\", () => {\n\t\t\t\n\t\t\tfor (const subscription of subscriptions.values())\n\t\t\t\tsubscription.handler(null);\n\t\t\t\n\t\t});\n\t\t\n\t}\n\t\n}\n", "import { removeOne } from \"@nesvet/n\";\nimport { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ntype Item = unknown;\n\nexport type Updated<I extends Item = Item> = I[] & {\n\tdeleted: I[];\n\tadded: I[];\n};\n\nexport type Updates<I extends Item = Item> =\n\t(\n\t\t[ \"a\"/* add */, newItem: I ] |\n\t\t[ \"d\"/* delete */, itemToDelete: I ] |\n\t\t[ \"i\"/* initial */, items: I[], sort?: -1 | 0 | 1 ] |\n\t\tnull\n\t)[] |\n\tnull;\n\nexport type UpdateHandler<I extends Item = Item> = (array: SubscriptionArray<I>, updated: Updated<I>, updates: Updates<I>) => void;\n\nconst ascSort = (a: any, b: any) => a > b ? 1 : a < b ? -1 : 0;\nconst descSort = (a: any, b: any) => a > b ? -1 : a < b ? 1 : 0;\n\n\nexport class SubscriptionArray<I extends Item = Item> extends Array<I> {\n\tconstructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>) {\n\t\tsuper();\n\t\t\n\t\tif (onUpdate)\n\t\t\tthis.handleUpdate = onUpdate;\n\t\t\n\t\tif (Array.isArray(updates))\n\t\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\tsorted: I[] = [];\n\t\n\thandleUpdate;\n\t\n\tsortDirection: -1 | 0 | 1 = 0;\n\t\n\tsortCompareFunction: typeof ascSort | typeof descSort | null = null;\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this.handleUpdate;\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>) {\n\t\treturn (this.handleUpdate = handleUpdate);\n\t}\n\t\n\tupdate(updates: Updates<I>) {\n\t\t\n\t\tconst updated: Updated<I> = Object.assign([], {\n\t\t\tdeleted: [],\n\t\t\tadded: []\n\t\t});\n\t\t\n\t\tif (updates) {\n\t\t\tlet shouldSort = false;\n\t\t\t\n\t\t\tfor (const update of updates)\n\t\t\t\tswitch (update?.[0]) {\n\t\t\t\t\tcase \"i\"/* initial */: {\n\t\t\t\t\t\tconst [ , array, sort ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sort) {\n\t\t\t\t\t\t\tthis.sortDirection = sort;\n\t\t\t\t\t\t\tthis.sortCompareFunction = sort > 0 ? ascSort : descSort;\n\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.sortDirection = 0;\n\t\t\t\t\t\t\tthis.sortCompareFunction = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.length = 0;\n\t\t\t\t\t\t\n\t\t\t\t\t\tfor (const newItem of array) {\n\t\t\t\t\t\t\tthis.push(newItem);\n\t\t\t\t\t\t\tupdated.push(newItem);\n\t\t\t\t\t\t\tupdated.added.push(newItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"a\"/* add */: {\n\t\t\t\t\t\tconst [ , newItem ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (!this.includes(newItem)) {\n\t\t\t\t\t\t\tthis.push(newItem);\n\t\t\t\t\t\t\tif (this.sortDirection)\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\tupdated.push(newItem);\n\t\t\t\t\t\t\tupdated.added.push(newItem);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"d\"/* delete */: {\n\t\t\t\t\t\tconst [ , itemToDelete ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (removeOne(this, itemToDelete))\n\t\t\t\t\t\t\tupdated.deleted.push(itemToDelete);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.clear();\n\t\t\t\t}\n\t\t\t\n\t\t\tif (shouldSort && this.sortCompareFunction)\n\t\t\t\tthis.sort(this.sortCompareFunction);\n\t\t\t\n\t\t} else\n\t\t\tthis.clear();\n\t\t\n\t\tthis.handleUpdate?.(this, updated, updates?.[0] ? updates : null);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[updateSymbol] = this.update;\n\t\n\tgetAsUpdates(): Updates<I> {\n\t\treturn (\n\t\t\t(this.length || this.sortDirection) ?\n\t\t\t\t[ [ \"i\"/* initial */, [ ...this ], this.sortDirection ] ] :\n\t\t\t\tnull\n\t\t);\n\t}\n\t\n\t[getAsUpdatesSymbol] = this.getAsUpdates;\n\t\n\tgetAsInitialUpdated(): Updated<I> {\n\t\treturn Object.assign([ ...this.sorted ], {\n\t\t\tadded: [ ...this.sorted ],\n\t\t\tdeleted: []\n\t\t});\n\t}\n\t\n\t[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;\n\t\n\tclear() {\n\t\t\n\t\tthis.length = 0;\n\t\tthis.sortDirection = 0;\n\t\tthis.sortCompareFunction = null;\n\t\t\n\t}\n\t\n\t[clearSymbol] = this.clear;\n\t\n\tvalueOf() {\n\t\treturn this;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionArray\";\n\t}\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionArrayWithSubscription;\n\t\n}\n\n\nexport class SubscriptionArrayWithSubscription<I extends Item = Item> extends SubscriptionArray<I> {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.publicationName = publicationName;\n\t\tthis.params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis.subscribe();\n\t\t\n\t}\n\t\n\tpublicationName;\n\tparams;\n\tsubscription: Subscription | null = null;\n\t\n\tsubscribe() {\n\t\t\n\t\tif (!this.subscription)\n\t\t\tthis.subscription = new Subscription(\"array\", this.publicationName, this.params, updates => this.update(updates as Updates<I>));\n\t\t\n\t}\n\t\n\tget [subscribeSymbol]() {\n\t\treturn this.subscribe;\n\t}\n\t\n\tunsubscribe() {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.subscription.cancel();\n\t\t\tthis.subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\tget [unsubscribeSymbol]() {\n\t\treturn this.unsubscribe;\n\t}\n\t\n\trenew(publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.unsubscribe();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.params = params;\n\t\t\t\n\t\t\tthis.subscribe();\n\t\t}\n\t\t\n\t}\n\t\n\tget [renewSymbol]() {\n\t\treturn this.renew;\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionArrayWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionArray.WithSubscription = SubscriptionArrayWithSubscription;\n", "export const updateSymbol = Symbol(\"update\");\nexport const getHandleUpdateSymbol = Symbol(\"getHandleUpdate\");\nexport const setHandleUpdateSymbol = Symbol(\"setHandleUpdate\");\nexport const getAsUpdatesSymbol = Symbol(\"getAsUpdates\");\nexport const getAsInitialUpdatedSymbol = Symbol(\"getAsInitialUpdated\");\nexport const clearSymbol = Symbol(\"clear\");\nexport const subscribeSymbol = Symbol(\"subscribe\");\nexport const unsubscribeSymbol = Symbol(\"unsubscribe\");\nexport const renewSymbol = Symbol(\"renew\");\nexport const getSubscriptionSymbol = Symbol(\"getSubscription\");\nexport const getHandleSubscriptionSymbol = Symbol(\"getHandleSubscription\");\nexport const setHandleSubscriptionSymbol = Symbol(\"setHandleSubscription\");\n", "import EventEmitter from \"eventemitter3\";\nimport { debounce, StatefulPromise } from \"@nesvet/n\";\nimport { privates } from \"./common\";\nimport { SubscriptionGroupItem } from \"./SubscriptionGroupItem\";\nimport {\n\tDefinition,\n\tParseValues,\n\tSubscriptionHandle,\n\tSubscriptionOnBeforeInit,\n\tSubscriptionType,\n\tTupleDefinition,\n\tUnparsedDefinition\n} from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\nfunction isTupleDefinition<T extends SubscriptionType>(definition: UnparsedDefinition<T>): definition is TupleDefinition {\n\treturn Array.isArray(definition);\n}\n\ntype Target = any;\n\ntype Options = {\n\ttarget?: Target;\n\tdebounce?: number;\n\timmediately?: boolean;\n};\n\n\nfunction parseDefinition<T extends SubscriptionType>(definition: UnparsedDefinition<T>) {\n\tif (isTupleDefinition(definition)) {\n\t\tconst args = definition.slice();\n\t\t\n\t\tconst parsed: Partial<Definition<T>> = {};\n\t\t\n\t\tparsed.name = args.shift() as Definition<T>[\"name\"];\n\t\tif (typeof args[0] == \"object\" && !Array.isArray(args[0])) {\n\t\t\tparsed.value = args.shift() as Definition<T>[\"value\"];\n\t\t\tparsed.type = parsed.value!.toString().match(/Subscription(Object|Array|Map)/)?.[1].toLowerCase() as Definition<T>[\"type\"];\n\t\t\tif (!parsed.type)\n\t\t\t\tthrow new Error(\"Unknown value type\");\n\t\t} else {\n\t\t\tif (typeof args[0] == \"string\")\n\t\t\t\tparsed.type = args.shift() as Definition<T>[\"type\"];\n\t\t\tif (typeof args[0] == \"string\")\n\t\t\t\tparsed.publicationName = args.shift() as Definition<T>[\"publicationName\"];\n\t\t\tif (Array.isArray(args[0]))\n\t\t\t\tparsed.params = args.shift() as Definition<T>[\"params\"];\n\t\t}\n\t\t\n\t\tif (typeof args[0] == \"function\")\n\t\t\tparsed.handle = args.shift() as SubscriptionHandle<T>;\n\t\tif (typeof args[0] == \"function\")\n\t\t\tparsed.onBeforeInit = args.shift() as SubscriptionOnBeforeInit<T>;\n\t\tif (typeof args[0] == \"number\")\n\t\t\tparsed.debounce = args.shift() as Definition<T>[\"debounce\"];\n\t\tif (typeof args[0] == \"boolean\")\n\t\t\tparsed.preventBind = args.shift() as Definition<T>[\"preventBind\"];\n\t\t\n\t\treturn parsed as Definition<T>;\n\t}\n\t\n\tdefinition.type ??= \"object\" as T;\n\t\n\treturn definition;\n}\n\nexport class SubscriptionGroup<DS extends UnparsedDefinition[] = any[]> extends EventEmitter {\n\tconstructor(\n\t\tdefinitions: DS,\n\t\t{\n\t\t\ttarget,\n\t\t\tdebounce: debounceLimit = SubscriptionGroup.debounceLimit,\n\t\t\timmediately\n\t\t}: Options = {}\n\t) {\n\t\tsuper();\n\t\t\n\t\tthis.applyOptions({ target, debounceLimit });\n\t\t\n\t\tthis.#initPromise = new StatefulPromise();\n\t\t\n\t\tvoid this.attach(definitions, false, immediately);\n\t\t\n\t}\n\t\n\ttarget?: Target;\n\temitUpdate!: () => void;\n\t\n\titems = [] as unknown as Record<string, SubscriptionGroupItem> & SubscriptionGroupItem[];\n\tvalues = [] as DS extends any ? (any[] & Record<string, any>) : ParseValues<DS>;\n\t\n\tisLoaded = false;\n\tisInited = false;\n\t\n\t#loadPromise!: StatefulPromise<SubscriptionGroup>;\n\t#initPromise: StatefulPromise<SubscriptionGroup>;\n\t#unloadPromise!: StatefulPromise<SubscriptionGroup>;\n\t\n\t#debounceLimit?: number | null = null;\n\t\n\tapplyOptions({ target, debounceLimit }: { target?: Target; debounceLimit?: number }) {\n\t\t\n\t\tif (this.target !== target) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (item.isLoaded && !item.preventBind)\n\t\t\t\t\t\tdelete this.target[item.name];\n\t\t\t\n\t\t\tthis.target = target;\n\t\t\t\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (item.isLoaded && !item.preventBind)\n\t\t\t\t\t\tthis.target[item.name] = item.value;\n\t\t}\n\t\t\n\t\tif (this.#debounceLimit !== debounceLimit) {\n\t\t\tthis.#debounceLimit = debounceLimit;\n\t\t\tif (typeof this.#debounceLimit == \"number\") {\n\t\t\t\tconst emitUpdateDebounced = debounce(() => this.emit(\"update\", this.values), this.#debounceLimit);\n\t\t\t\tthis.emitUpdate = () => emitUpdateDebounced();\n\t\t\t} else\n\t\t\t\tthis.emitUpdate = () => this.emit(\"update\", this.values);\n\t\t}\n\t\t\n\t}\n\t\n\tattach(definitions: DS, shouldReload = this.isLoaded, immediately = true) {\n\t\tif (shouldReload)\n\t\t\tthis.isLoaded = false;\n\t\t\n\t\tif (!this.#loadPromise || this.#loadPromise.isFulfilled)\n\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\n\t\tif (!this.#unloadPromise || this.#unloadPromise.isFulfilled)\n\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t\n\t\treturn Promise.all(definitions.map(definition =>\n\t\t\tnew SubscriptionGroupItem(parseDefinition(definition), this)\n\t\t).map(item => {\n\t\t\t\n\t\t\tif (immediately)\n\t\t\t\titem.subscribe();\n\t\t\t\n\t\t\treturn item.loaded();\n\t\t}));\n\t}\n\t\n\tdetach(names: string[], shouldUpdate = true) {\n\t\t\n\t\tfor (const name of names)\n\t\t\tthis.items[name]?.detach();\n\t\t\n\t\tif (shouldUpdate) {\n\t\t\tthis.#unload();\n\t\t\tthis.#load();\n\t\t}\n\t\t\n\t}\n\t\n\tredefine(definitions: DS) {\n\t\t\n\t\tconst itemsToDetach = new Map(this.items.map(item => [ item.name, item ]));\n\t\tconst definitionsToRedefine = [];\n\t\tconst definitionsToAttach = [] as unknown as DS;\n\t\t\n\t\tfor (let definition of definitions) {\n\t\t\tdefinition = parseDefinition(definition);\n\t\t\tif (itemsToDetach.delete(definition.name))\n\t\t\t\tdefinitionsToRedefine.push(definition);\n\t\t\telse\n\t\t\t\tdefinitionsToAttach.push(definition);\n\t\t}\n\t\t\n\t\tthis.isLoaded = false;\n\t\t\n\t\tthis.detach([ ...itemsToDetach.keys() ], false);\n\t\t\n\t\treturn Promise.all([\n\t\t\t...definitionsToRedefine.map(definition => {\n\t\t\t\tconst item = this.items[definition.name];\n\t\t\t\titem.define(definition);\n\t\t\t\t\n\t\t\t\titem.subscribe();\n\t\t\t\t\n\t\t\t\treturn item.loaded();\n\t\t\t}),\n\t\t\t...definitionsToAttach.length ? [ this.attach(definitionsToAttach, false) ] : []\n\t\t]);\n\t}\n\t\n\tsubscribe() {\n\t\treturn this.items.map(item => item.subscribe());\n\t}\n\t\n\tunsubscribe() {\n\t\treturn this.items.map(item => item.unsubscribe());\n\t}\n\t\n\t#load() {\n\t\t\n\t\tif (!this.isLoaded && this.items.every(item => item.isLoaded)) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (!item.preventBind)\n\t\t\t\t\t\tthis.target[item.name] = item.value;\n\t\t\t\n\t\t\tthis.isLoaded = true;\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemLoad!(item);\n\t\t\t\n\t\t\tthis.emit(\"load\", this.values);\n\t\t\t\n\t\t\tif (this.isInited)\n\t\t\t\tif (this.items.length)\n\t\t\t\t\tfor (const item of this.items)\n\t\t\t\t\t\titem.emitUpdate();\n\t\t\t\telse\n\t\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\t\n\t\t\tthis.#loadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\t#init() {\n\t\t\n\t\tif (!this.isInited && this.items.every(item => item.isInited)) {\n\t\t\tthis.isInited = true;\n\t\t\t\n\t\t\tif (this.isLoaded)\n\t\t\t\tif (this.items.length)\n\t\t\t\t\tfor (const item of this.items)\n\t\t\t\t\t\titem.emitUpdate();\n\t\t\t\telse\n\t\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemInit!(item);\n\t\t\t\n\t\t\tthis.emit(\"init\", this.values);\n\t\t\t\n\t\t\tthis.#initPromise.resolve(this);\n\t\t}\n\t\t\n\t}\n\t\n\t#unload() {\n\t\t\n\t\tif (this.isLoaded && this.items.every(item => !item.isLoaded)) {\n\t\t\tif (this.target)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\tif (!item.preventBind)\n\t\t\t\t\t\tdelete this.target[item.name];\n\t\t\t\n\t\t\tthis.isLoaded = false;\n\t\t\t\n\t\t\tfor (const item of this.items)\n\t\t\t\tprivates.itemUnload!(item);\n\t\t\t\n\t\t\tthis.emit(\"unload\", this.values);\n\t\t\t\n\t\t\tif (this.items.length)\n\t\t\t\tfor (const item of this.items)\n\t\t\t\t\titem.emitUpdate();\n\t\t\telse\n\t\t\t\tthis.emitUpdate();\n\t\t\t\n\t\t\tthis.#unloadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#loadPromise.isFulfilled)\n\t\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\tloaded() {\n\t\treturn this.#loadPromise;\n\t}\n\t\n\tinited() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\tunloaded() {\n\t\treturn this.#unloadPromise;\n\t}\n\t\n\tvalueOf() {\n\t\treturn this.values;\n\t}\n\t\n\t[Symbol.iterator]() {\n\t\treturn this.values[Symbol.iterator]();\n\t}\n\t\n\t\n\tstatic debounceLimit = 8;\n\t\n\tstatic {\n\t\t\n\t\tprivates.groupLoad = (group: SubscriptionGroup) => group.#load();\n\t\tprivates.groupInit = (group: SubscriptionGroup) => group.#init();\n\t\tprivates.groupUnload = (group: SubscriptionGroup) => group.#unload();\n\t\t\n\t}\n\t\n}\n\nexport { Options as SubscriptionGroupOptions, Target as SubscriptionGroupTarget };\n", "import type { SubscriptionGroup } from \"./SubscriptionGroup\";\nimport type { SubscriptionGroupItem } from \"./SubscriptionGroupItem\";\nimport type { SubscriptionType } from \"./types\";\n\n\nexport const privates: {\n\tgroupLoad?: (group: SubscriptionGroup) => void;\n\tgroupInit?: (group: SubscriptionGroup) => void;\n\tgroupUnload?: (group: SubscriptionGroup) => void;\n\titemLoad?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n\titemInit?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n\titemUnload?: <T extends SubscriptionType>(item: SubscriptionGroupItem<T>) => void;\n} = {};\n", "import EventEmitter from \"eventemitter3\";\nimport { debounce, removeOne, StatefulPromise } from \"@nesvet/n\";\nimport {\n\tSubscriptionArrayWithSubscription,\n\ttype Updated as SubscriptionArrayUpdated,\n\ttype UpdateHandler as SubscriptionArrayUpdateHandler,\n\ttype Updates as SubscriptionArrayUpdates\n} from \"../SubscriptionArray\";\nimport {\n\tSubscriptionMapWithSubscription,\n\ttype Updated as SubscriptionMapUpdated,\n\ttype UpdateHandler as SubscriptionMapUpdateHandler,\n\ttype Updates as SubscriptionMapUpdates\n} from \"../SubscriptionMap\";\nimport {\n\tSubscriptionObjectWithSubscription,\n\ttype Updated as SubscriptionObjectUpdated,\n\ttype UpdateHandler as SubscriptionObjectUpdateHandler,\n\ttype Updates as SubscriptionObjectUpdates\n} from \"../SubscriptionObject\";\nimport {\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol\n} from \"../symbols\";\nimport { privates } from \"./common\";\nimport type { SubscriptionGroup } from \"./SubscriptionGroup\";\nimport type {\n\tDefinition,\n\tSubscriptionHandle,\n\tSubscriptionOnBeforeInit,\n\tSubscriptionType,\n\tSubscriptionUpdated,\n\tSubscriptionUpdates,\n\tSubscriptionValue\n} from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\ntype HandleSubscription<T> = (_: any, updated: SubscriptionUpdated<T>, updates: SubscriptionUpdates<T>) => void;\n\nfunction isUpdatedMapOrArray(updated: SubscriptionUpdated<SubscriptionType>): updated is SubscriptionArrayUpdated | SubscriptionMapUpdated {\n\treturn Array.isArray(updated);\n}\n\n\nexport class SubscriptionGroupItem<T extends SubscriptionType = SubscriptionType, D extends Definition<T> = Definition<T>> extends EventEmitter {\n\tconstructor(definition: D, group: SubscriptionGroup) {\n\t\tsuper();\n\t\t\n\t\tthis.name = definition.name;\n\t\t\n\t\tthis.define(definition, group);\n\t\t\n\t}\n\t\n\tname;\n\tgroup?: SubscriptionGroup;\n\tvalue?: SubscriptionValue<T>;\n\ttype!: T | \"object\";\n\tpublicationName!: Definition<T>[\"publicationName\"];\n\tparams!: Definition<T>[\"params\"];\n\thandle!: Definition<T>[\"handle\"];\n\tonBeforeInit!: Definition<T>[\"onBeforeInit\"];\n\tpreventBind!: Definition<T>[\"preventBind\"];\n\t\n\temitUpdate!: (updated?: SubscriptionUpdated<T>) => void;\n\t\n\tisLoaded = false;\n\tisInited = false;\n\t\n\t#loadPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t#initPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t#unloadPromise!: StatefulPromise<SubscriptionGroupItem<T, D>>;\n\t\n\tdefine(definition: Definition<T>, group: SubscriptionGroup | undefined = this.group) {\n\t\tif (!group)\n\t\t\tthrow new Error(\"group is undefined\");\n\t\t\n\t\tconst {\n\t\t\tvalue,\n\t\t\ttype = \"object\",\n\t\t\tpublicationName,\n\t\t\tparams,\n\t\t\thandle,\n\t\t\tonBeforeInit,\n\t\t\tdebounce: debounceLimit = SubscriptionGroupItem.debounceLimit,\n\t\t\tpreventBind\n\t\t} = definition;\n\t\t\n\t\tif (this.group) {\n\t\t\tif (\n\t\t\t\t(!value || this.value === value) &&\n\t\t\t\tthis.type === type &&\n\t\t\t\tthis.publicationName === publicationName &&\n\t\t\t\tJSON.stringify(this.params) === JSON.stringify(params) &&\n\t\t\t\tthis.handle === handle &&\n\t\t\t\tthis.onBeforeInit === onBeforeInit\n\t\t\t)\n\t\t\t\treturn this.#applyOptions({ debounceLimit, preventBind });\n\t\t\t\n\t\t\tthis.detach();\n\t\t\tdelete this.value;\n\t\t\tdelete this.publicationName;\n\t\t\tdelete this.params;\n\t\t}\n\t\t\n\t\tthis.type = type;\n\t\tthis.handle = handle;\n\t\tthis.onBeforeInit = onBeforeInit;\n\t\tif (value)\n\t\t\tthis.value = value;\n\t\telse {\n\t\t\tthis.publicationName = publicationName ?? this.name;\n\t\t\tthis.params = params ?? [];\n\t\t}\n\t\t\n\t\tthis.#applyOptions({ debounceLimit, preventBind });\n\t\t\n\t\tthis.#attachTo(group);\n\t\t\n\t}\n\t\n\t#applyOptions({ debounceLimit, preventBind }: { debounceLimit?: number; preventBind?: boolean }) {\n\t\t\n\t\tconst emitUpdate: typeof this.emitUpdate = updated => {\n\t\t\tthis.emit(\"update\", this.value, updated);\n\t\t\tthis.group?.emit(`update.${this.name}`, this.value, updated);\n\t\t\tthis.group?.emitUpdate();\n\t\t\t\n\t\t};\n\t\t\n\t\tif (typeof debounceLimit == \"number\") {\n\t\t\tlet debouncedUpdated: SubscriptionUpdated<T> | undefined;\n\t\t\tlet group: SubscriptionGroup;\n\t\t\t\n\t\t\tconst emitUpdateDebounced = debounce(() => {\n\t\t\t\t\n\t\t\t\tconst isDetached = !this.group;\n\t\t\t\t\n\t\t\t\tif (isDetached)\n\t\t\t\t\tthis.group = group;\n\t\t\t\t\n\t\t\t\temitUpdate(debouncedUpdated);\n\t\t\t\t\n\t\t\t\tif (isDetached)\n\t\t\t\t\tdelete this.group;\n\t\t\t\t\n\t\t\t\tdebouncedUpdated = undefined;\n\t\t\t\t\n\t\t\t}, debounceLimit);\n\t\t\t\n\t\t\tthis.emitUpdate = updated => {\n\t\t\t\tif (updated !== undefined)\n\t\t\t\t\tif (isUpdatedMapOrArray(updated))\n\t\t\t\t\t\tif (isUpdatedMapOrArray(debouncedUpdated!))\n\t\t\t\t\t\t\tfor (const item of updated)\n\t\t\t\t\t\t\t\tdebouncedUpdated.push(item);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdebouncedUpdated = Object.assign([ ...updated ], {\n\t\t\t\t\t\t\t\tadded: [ ...updated.added ],\n\t\t\t\t\t\t\t\tdeleted: [ ...updated.deleted ]\n\t\t\t\t\t\t\t}) as SubscriptionUpdated<T>;\n\t\t\t\t\telse if (typeof updated == \"object\")\n\t\t\t\t\t\tif (debouncedUpdated)\n\t\t\t\t\t\t\tObject.assign(debouncedUpdated, updated);\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdebouncedUpdated = { ...updated };\n\t\t\t\t\telse\n\t\t\t\t\t\tdebouncedUpdated = updated;\n\t\t\t\t\n\t\t\t\tgroup = this.group!;\n\t\t\t\t\n\t\t\t\treturn emitUpdateDebounced();\n\t\t\t};\n\t\t} else\n\t\t\tthis.emitUpdate = emitUpdate;\n\t\t\n\t\tif (this.preventBind === undefined)\n\t\t\tdelete this.preventBind;\n\t\telse\n\t\t\tthis.preventBind = preventBind;\n\t\t\n\t}\n\t\n\t#attachTo(group: SubscriptionGroup) {\n\t\tif (!this.group) {\n\t\t\tthis.group = group;\n\t\t\t\n\t\t\tthis.group.items.push(this as SubscriptionGroupItem<any>);\n\t\t\tthis.group.items[this.name] = this as SubscriptionGroupItem<any>;\n\t\t\t\n\t\t\tif (!this.#loadPromise || this.#loadPromise.isFulfilled)\n\t\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\t\n\t\t\tif (!this.#initPromise || this.#initPromise.isFulfilled)\n\t\t\t\tthis.#initPromise = new StatefulPromise();\n\t\t\t\n\t\t\tif (!this.#unloadPromise || this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t\t\n\t\t\tswitch (this.type) {\n\t\t\t\tcase \"array\": {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"array\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionArrayWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionArrayWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t\tbreak;\n\t\t\t\t} case \"map\": {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"map\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionMapWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionMapWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t\tbreak;\n\t\t\t\t} default: {\n\t\t\t\t\tconst handleSubscription = this.#handleSubscription as HandleSubscription<\"object\">;\n\t\t\t\t\tif (this.value)\n\t\t\t\t\t\t(this.value as SubscriptionObjectWithSubscription)[setHandleUpdateSymbol](handleSubscription);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.value = new SubscriptionObjectWithSubscription(this.publicationName!, this.params!, handleSubscription, false) as SubscriptionValue<T>;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tthis.group.values.push(this.value);\n\t\t\tthis.group.values[this.name] = this.value;\n\t\t\t\n\t\t\tif (this.onBeforeInit)\n\t\t\t\tswitch (this.type) {\n\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"array\">).call(this.group, this.value as SubscriptionArrayWithSubscription);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"map\">).call(this.group, this.value as SubscriptionMapWithSubscription);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t(this.onBeforeInit as SubscriptionOnBeforeInit<\"object\">).call(this.group, this.value as SubscriptionObjectWithSubscription);\n\t\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\tdetach() {\n\t\t\n\t\tif (this.group) {\n\t\t\tthis.value?.[unsubscribeSymbol]();\n\t\t\t\n\t\t\tthis.isLoaded = false;\n\t\t\tthis.#unload();\n\t\t\t\n\t\t\tdelete this.group.values[this.name];// eslint-disable-line @typescript-eslint/no-array-delete\n\t\t\tremoveOne(this.group.values, this.value);\n\t\t\tdelete this.group.items[this.name];// eslint-disable-line @typescript-eslint/no-array-delete\n\t\t\tremoveOne(this.group.items, this as SubscriptionGroupItem<any>);\n\t\t\t\n\t\t\tdelete this.group;\n\t\t}\n\t\t\n\t}\n\t\n\t#loadUpdated: SubscriptionUpdated<T> | null = null;\n\t\n\t#handleSubscription: HandleSubscription<T> = (_, updated, updates) => {\n\t\tif (updates)\n\t\t\tif (this.group!.isLoaded) {\n\t\t\t\tif (this.handle)\n\t\t\t\t\tswitch (this.type) {\n\t\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, updated as SubscriptionArrayUpdated, this.group!);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, updated as SubscriptionMapUpdated, this.group!);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, updated as SubscriptionObjectUpdated, this.group!);\n\t\t\t\t\t}\n\t\t\t\tthis.emitUpdate(updated);\n\t\t\t} else {\n\t\t\t\tthis.#loadUpdated = updated;\n\t\t\t\tthis.isLoaded = true;\n\t\t\t\tprivates.groupLoad!(this.group!);\n\t\t\t}\n\t\telse if (this.isLoaded) {\n\t\t\tthis.isLoaded = false;\n\t\t\tprivates.groupUnload!(this.group!);\n\t\t}\n\t\t\n\t\tif (!this.isInited) {\n\t\t\tthis.isInited = true;\n\t\t\tprivates.groupInit!(this.group!);\n\t\t}\n\t\t\n\t};\n\t\n\t#load() {\n\t\t\n\t\tif (this.#loadUpdated) {\n\t\t\tif (this.handle)\n\t\t\t\tswitch (this.type) {\n\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, this.#loadUpdated as SubscriptionArrayUpdated, this.group!);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, this.#loadUpdated as SubscriptionMapUpdated, this.group!);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, this.#loadUpdated as SubscriptionObjectUpdated, this.group!);\n\t\t\t\t}\n\t\t\t\n\t\t\tthis.#loadUpdated = null;\n\t\t\t\n\t\t\tthis.emit(\"load\", this.value);\n\t\t\t\n\t\t\tthis.#loadPromise.resolve(this);\n\t\t\t\n\t\t\tif (this.#unloadPromise.isFulfilled)\n\t\t\t\tthis.#unloadPromise = new StatefulPromise();\n\t\t}\n\t\t\n\t}\n\t\n\t#init() {\n\t\t\n\t\tthis.emit(\"init\", this.value);\n\t\t\n\t\tthis.#initPromise.resolve(this);\n\t\t\n\t}\n\t\n\t#unload() {\n\t\t\n\t\tif (this.handle)\n\t\t\tswitch (this.type) {\n\t\t\t\tcase \"array\":\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"array\">).call(this.group!, null, this.group!);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"map\":\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"map\">).call(this.group!, null, this.group!);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\t(this.handle as SubscriptionHandle<\"object\">).call(this.group!, null, this.group!);\n\t\t\t}\n\t\t\n\t\tthis.emit(\"unload\", this.value);\n\t\t\n\t\tthis.#unloadPromise.resolve(this);\n\t\t\n\t\tif (this.#loadPromise.isFulfilled)\n\t\t\tthis.#loadPromise = new StatefulPromise();\n\t\t\n\t}\n\t\n\tloaded() {\n\t\treturn this.#loadPromise;\n\t}\n\t\n\tinited() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\tunloaded() {\n\t\treturn this.#unloadPromise;\n\t}\n\t\n\tsubscribe() {\n\t\t\n\t\tif (this.value)\n\t\t\tif (this.value[subscribeSymbol])\n\t\t\t\treturn this.value[subscribeSymbol]();\n\t\t\telse {\n\t\t\t\tconst handleUpdate = this.value[getHandleUpdateSymbol]();\n\t\t\t\t\n\t\t\t\tif (handleUpdate) {\n\t\t\t\t\tconst initialUpdated = this.value[getAsInitialUpdatedSymbol]();\n\t\t\t\t\tconst updates = this.value[getAsUpdatesSymbol]();\n\t\t\t\t\t\n\t\t\t\t\tswitch (this.type) {\n\t\t\t\t\t\tcase \"array\":\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionArrayUpdateHandler)(this.value as SubscriptionArrayWithSubscription, initialUpdated as SubscriptionArrayUpdated, updates as SubscriptionArrayUpdates);\n\t\t\t\t\t\t\n\t\t\t\t\t\tcase \"map\":\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionMapUpdateHandler)(this.value as SubscriptionMapWithSubscription, initialUpdated as SubscriptionMapUpdated, updates as SubscriptionMapUpdates);\n\t\t\t\t\t\t\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn (handleUpdate as SubscriptionObjectUpdateHandler)(this.value as SubscriptionObjectWithSubscription, initialUpdated as SubscriptionObjectUpdated, updates as SubscriptionObjectUpdates);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\n\t}\n\t\n\tunsubscribe() {\n\t\treturn this.value?.[unsubscribeSymbol]?.();\n\t}\n\t\n\trenew(publicationName: Definition<T>[\"publicationName\"], params: Definition<T>[\"params\"]) {\n\t\treturn this.value?.[renewSymbol]?.(publicationName, params);\n\t}\n\t\n\tvalueOf() {\n\t\treturn this.value;\n\t}\n\t\n\t\n\tstatic debounceLimit = 4;\n\t\n\tstatic {\n\t\t\n\t\tprivates.itemLoad = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#load();\n\t\tprivates.itemInit = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#init();\n\t\tprivates.itemUnload = <\n\t\t\tDP extends Definition<TP>,\n\t\t\tTP extends SubscriptionType\n\t\t>(item: SubscriptionGroupItem<TP, DP>) => item.#unload();\n\t\t\n\t}\n\t\n}\n", "import { removeOne, unique } from \"@nesvet/n\";\nimport { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\ntype GenericItem = Record<string, any> & { _id: string };// eslint-disable-line @typescript-eslint/no-explicit-any\n\ntype Item = GenericItem | SubscriptionMapItem;\n\nexport type Updated<I extends Item = Item> = I[] & {\n\tdeleted: string[];\n\tadded: I[];\n};\n\ntype SortList = Record<string, -1 | 1>;\n\nexport type Updates<I extends Item = Item> =\n\t(\n\t\t[ \"c\"/* create */, item: I ] |\n\t\t[ \"d\"/* delete */, _id: string ] |\n\t\t[ \"i\"/* initial */, items: I[], sortList?: SortList | null ] |\n\t\t[ \"u\"/* update */, itemUpdates: Partial<I> & { _id: string }, isAtomicOrUpdatedFields: string[] | true ] |\n\t\tnull\n\t)[] |\n\tnull;\n\nexport type UpdateHandler<I extends Item = Item> = (map: SubscriptionMap<I>, updated: Updated<I>, updates: Updates<I>) => void;\n\ndeclare global {\n\tvar __insite_subscription_map_sort_function: ((a: Item, b: Item) => -1 | 0 | 1) | undefined;// eslint-disable-line camelcase, @typescript-eslint/naming-convention\n}\n\nfunction createSortFunction(sortList: SortList) {\n\t\n\tconst tempScript = document.createElement(\"script\");\n\t\n\ttempScript.textContent = `window.__insite_subscription_map_sort_function = function sort(a, b) { return ${\n\t\tObject.entries(sortList)\n\t\t\t.map(([ key, value ]) => {\n\t\t\t\tif (key.includes(\".\"))\n\t\t\t\t\tkey = key.replaceAll(\".\", \"?.\");\n\t\t\t\t\n\t\t\t\treturn value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`;\n\t\t\t})\n\t\t\t.concat(\"0\")\n\t\t\t.join(\" \")\n\t};}`;\n\t\n\tdocument.head.append(tempScript);\n\t\n\tconst sortFunction = globalThis.__insite_subscription_map_sort_function!;\n\t\n\ttempScript.remove();\n\tdelete globalThis.__insite_subscription_map_sort_function;\n\t\n\treturn sortFunction;\n}\n\n// function createSortFunction(sortList: SortList) {\n// return new Function(// eslint-disable-line no-new-func\n// \t\t\"a\"/* Item */,\n// \t\t\"b\"/* Item */,\n// \t\t`return ${\n// \t\t\tObject.entries(sortList)\n// \t\t\t\t.map(([ key, value ]) => value > 0 ? `a.${key} > b.${key} ? 1 : a.${key} < b.${key} ? -1 :` : `a.${key} < b.${key} ? 1 : a.${key} > b.${key} ? -1 :`)\n// \t\t\t\t.concat(\"0\")\n// \t\t\t\t.join(\" \")\n// \t\t}`\n// \t) as (a: Item, b: Item) => -1 | 0 | 1;\n// }\n\n\nexport class SubscriptionMap<I extends Item = Item> extends Map<string, I> {\n\tconstructor(updates?: Updates<I>, onUpdate?: UpdateHandler<I>) {\n\t\tsuper();\n\t\t\n\t\tif (onUpdate)\n\t\t\tthis.handleUpdate = onUpdate;\n\t\t\n\t\tif (updates)\n\t\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\thandleUpdate;\n\t\n\t#updates = new Map<string, I>();\n\t\n\tsortList: SortList | null = null;\n\t\n\tsortCompareFunction: ((a: I, b: I) => number) | null = null;\n\t\n\t#fieldsToSort: string[] = [];\n\t\n\tsorted: I[] = [];\n\t\n\tsort() {\n\t\t\n\t\tif (this.sortCompareFunction)\n\t\t\tthis.sorted.sort(this.sortCompareFunction);\n\t\t\n\t}\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this.handleUpdate;\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler<I>) {\n\t\treturn (this.handleUpdate = handleUpdate);\n\t}\n\t\n\t#Item!: { new (map: SubscriptionMap<I>, updates: GenericItem): I };\n\t\n\tset Item(TheItem: { new (map: SubscriptionMap<I>, updates: GenericItem): I }) { // eslint-disable-line @typescript-eslint/naming-convention\n\t\tthis.#Item = TheItem;\n\t\t\n\t\tif (this.size)\n\t\t\tfor (const [ _id, item ] of this)\n\t\t\t\tthis.set(_id, new TheItem(this, item));\n\t\t\n\t}\n\t\n\tget Item() {\n\t\treturn this.#Item;\n\t}\n\t\n\tupdate(updates: Updates<I>) {\n\t\t\n\t\tconst updated: Updated<I> = Object.assign([], {\n\t\t\tadded: [],\n\t\t\tdeleted: []\n\t\t});\n\t\t\n\t\tif (updates) {\n\t\t\tlet shouldSort = false;\n\t\t\t\n\t\t\tconst TheItem = this.#Item;// eslint-disable-line @typescript-eslint/naming-convention\n\t\t\tconst prevUpdates = this.#updates;\n\t\t\t\n\t\t\tfor (const update of updates)\n\t\t\t\tswitch (update?.[0]) {\n\t\t\t\t\tcase \"i\"/* initial */: {\n\t\t\t\t\t\tconst [ , array, sortList ] = update;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (sortList) {\n\t\t\t\t\t\t\tthis.sortList = sortList;\n\t\t\t\t\t\t\tthis.sortCompareFunction = createSortFunction(sortList);\n\t\t\t\t\t\t\tthis.#fieldsToSort = unique(Object.keys(sortList).map(key => key.replace(/\\..+/, \"\")));\n\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.sortList = null;\n\t\t\t\t\t\t\tthis.sortCompareFunction = null;\n\t\t\t\t\t\t\tthis.#fieldsToSort = [];\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (this.size) {\n\t\t\t\t\t\t\tconst updatesMap = new Map<string, I>();\n\t\t\t\t\t\t\tfor (const itemUpdates of array)\n\t\t\t\t\t\t\t\tupdatesMap.set(itemUpdates._id, itemUpdates);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (const [ _id, item ] of this) {\n\t\t\t\t\t\t\t\tconst itemUpdates = updatesMap.get(_id);\n\t\t\t\t\t\t\t\tif (itemUpdates) {\n\t\t\t\t\t\t\t\t\tconst prevItemUpdates = prevUpdates.get(_id);\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\t\t\titem.update(itemUpdates);\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tfor (const key in prevItemUpdates)// eslint-disable-line guard-for-in\n\t\t\t\t\t\t\t\t\t\t\tdelete item[key as keyof typeof item];\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tObject.assign(item, itemUpdates);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tprevUpdates.set(_id, itemUpdates);\n\t\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\t\tupdatesMap.delete(_id);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\t\t\titem.delete();\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\tthis.delete(_id);\n\t\t\t\t\t\t\t\t\tprevUpdates.delete(_id);\n\t\t\t\t\t\t\t\t\tupdated.deleted.push(_id);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tfor (const [ _id, itemUpdates ] of updatesMap) {\n\t\t\t\t\t\t\t\tconst item = TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates };\n\t\t\t\t\t\t\t\tthis.set(_id, item);\n\t\t\t\t\t\t\t\tprevUpdates.set(_id, itemUpdates);\n\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.sortList)\n\t\t\t\t\t\t\t\tthis.sorted = array.map(newItem => this.get(newItem._id)!);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t} else\n\t\t\t\t\t\t\tfor (const itemUpdates of array) {\n\t\t\t\t\t\t\t\tconst item = (TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates });\n\t\t\t\t\t\t\t\tthis.set(item._id, item);\n\t\t\t\t\t\t\t\tthis.sorted.push(item);\n\t\t\t\t\t\t\t\tprevUpdates.set(item._id, itemUpdates);\n\t\t\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"c\"/* create */:\n\t\t\t\t\tcase \"u\"/* update */: {\n\t\t\t\t\t\tlet [ , itemUpdates ] = update;\n\t\t\t\t\t\tlet item = this.get(itemUpdates._id);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (item) {\n\t\t\t\t\t\t\tconst isAtomic = update[2] === true;\n\t\t\t\t\t\t\tconst updatedFields = isAtomic ? Object.keys(itemUpdates) : update[2] as string[];\n\t\t\t\t\t\t\tconst prevItemUpdates = prevUpdates.get(item._id)!;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\titem.update(itemUpdates);\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tif (!isAtomic)\n\t\t\t\t\t\t\t\t\tfor (const key in prevItemUpdates)// eslint-disable-line guard-for-in\n\t\t\t\t\t\t\t\t\t\tdelete item[key as keyof typeof item];\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tObject.assign(item, itemUpdates);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (isAtomic)\n\t\t\t\t\t\t\t\titemUpdates = Object.assign(prevItemUpdates, itemUpdates);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.sortList && !shouldSort && (!updatedFields || updatedFields.some(fieldName => this.#fieldsToSort.includes(fieldName))))\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\titem = (TheItem ? new TheItem(this, itemUpdates) : { ...itemUpdates }) as I;\n\t\t\t\t\t\t\tthis.set(item._id, item);\n\t\t\t\t\t\t\tthis.sorted.push(item);\n\t\t\t\t\t\t\tif (this.sortList)\n\t\t\t\t\t\t\t\tshouldSort = true;\n\t\t\t\t\t\t\tupdated.added.push(item);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tprevUpdates.set(item._id, itemUpdates as I);\n\t\t\t\t\t\tupdated.push(item);\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tcase \"d\"/* delete */: {\n\t\t\t\t\t\tconst [ , _id ] = update;\n\t\t\t\t\t\tconst itemToDelete = this.get(_id);\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (itemToDelete) {\n\t\t\t\t\t\t\tif (TheItem)\n\t\t\t\t\t\t\t\titemToDelete.delete();\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tthis.delete(_id);\n\t\t\t\t\t\t\tprevUpdates.delete(_id);\n\t\t\t\t\t\t\tremoveOne(this.sorted, itemToDelete);\n\t\t\t\t\t\t\tupdated.deleted.push(_id);\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthis.clear();\n\t\t\t\t}\n\t\t\t\n\t\t\tif (shouldSort)\n\t\t\t\tthis.sort();\n\t\t\t\n\t\t} else\n\t\t\tthis.clear();\n\t\t\n\t\tthis.handleUpdate?.(this, updated, updates?.[0] ? updates : null);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[updateSymbol] = this.update;\n\t\n\tgetAsUpdates(): Updates<I> {\n\t\treturn (\n\t\t\t(this.size || this.sortList) ?\n\t\t\t\t[ [ \"i\"/* initial */, [ ...this.#updates.values() ], this.sortList ] ] :\n\t\t\t\tnull\n\t\t);\n\t}\n\t\n\t[getAsUpdatesSymbol] = this.getAsUpdates;\n\t\n\tgetAsInitialUpdated(): Updated<I> {\n\t\treturn Object.assign([ ...this.sorted ], {\n\t\t\tadded: [ ...this.sorted ],\n\t\t\tdeleted: []\n\t\t});\n\t}\n\t\n\t[getAsInitialUpdatedSymbol] = this.getAsInitialUpdated;\n\t\n\tclear() {\n\t\t\n\t\tsuper.clear();\n\t\tthis.#updates.clear();\n\t\tthis.sorted = [];\n\t\tthis.sortList = null;\n\t\tthis.sortCompareFunction = null;\n\t\tthis.#fieldsToSort = [];\n\t\t\n\t}\n\t\n\t[clearSymbol] = this.clear;\n\t\n\tvalueOf() {\n\t\treturn this.sorted;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionMap\";\n\t}\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionMapWithSubscription;\n\tstatic Item: typeof SubscriptionMapItem;\n\t\n}\n\n\nexport class SubscriptionMapWithSubscription<I extends Item = Item> extends SubscriptionMap<I> {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler<I>, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.publicationName = publicationName;\n\t\tthis.params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis.subscribe();\n\t\t\n\t}\n\t\n\tpublicationName;\n\tparams;\n\t\n\tsubscription: Subscription | null = null;\n\t\n\tsubscribe() {\n\t\t\n\t\tif (!this.subscription)\n\t\t\tthis.subscription = new Subscription(\"map\", this.publicationName, this.params, updates => this.update(updates as Updates<I>));\n\t\t\n\t}\n\t\n\tget [subscribeSymbol]() {\n\t\treturn this.subscribe;\n\t}\n\t\n\tunsubscribe() {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.subscription.cancel();\n\t\t\tthis.subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\tget [unsubscribeSymbol]() {\n\t\treturn this.unsubscribe;\n\t}\n\t\n\trenew(publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.subscription) {\n\t\t\tthis.unsubscribe();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.params = params;\n\t\t\t\n\t\t\tthis.subscribe();\n\t\t}\n\t\t\n\t}\n\t\n\tget [renewSymbol]() {\n\t\treturn this.renew;\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionMapWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionMap.WithSubscription = SubscriptionMapWithSubscription;\n\n\nexport class SubscriptionMapItem {\n\tconstructor(map: SubscriptionMap, updates: GenericItem) {\n\t\tthis.#map = map;\n\t\t\n\t\tthis.update(updates);\n\t\t\n\t}\n\t\n\t_id!: string;\n\t\n\t#map;\n\t\n\tupdate(updates: GenericItem) {\n\t\tObject.assign(this, updates);\n\t\t\n\t}\n\t\n\tdelete() {\n\t\t\n\t\tthis.#map.delete(this._id);\n\t\t\n\t}\n\t\n}\n\nSubscriptionMap.Item = SubscriptionMapItem;\n", "import { Subscription } from \"./Subscription\";\nimport {\n\tclearSymbol,\n\tgetAsInitialUpdatedSymbol,\n\tgetAsUpdatesSymbol,\n\tgetHandleUpdateSymbol,\n\tgetSubscriptionSymbol,\n\trenewSymbol,\n\tsetHandleUpdateSymbol,\n\tsubscribeSymbol,\n\tunsubscribeSymbol,\n\tupdateSymbol\n} from \"./symbols\";\n\n\nconst handleUpdateSymbol = Symbol(\"handleUpdate\");\nconst updatesSymbol = Symbol(\"updates\");\n\nexport type Updated = Record<string, unknown>;\nexport type Updates = Record<string, unknown> | null;\nexport type UpdateHandler = (object: SubscriptionObject, updated: Updated, updates: Updates) => void;\n\n\nexport class SubscriptionObject {\n\tconstructor(updates?: Updates, onUpdate?: UpdateHandler) {\n\t\tif (onUpdate)\n\t\t\tthis[handleUpdateSymbol] = onUpdate;\n\t\t\n\t\tif (updates)\n\t\t\tthis[updateSymbol](updates);\n\t\t\n\t}\n\t\n\t[handleUpdateSymbol]?: UpdateHandler;\n\t\n\t[updatesSymbol]: Updates = null;\n\t\n\t[getHandleUpdateSymbol]() {\n\t\treturn this[handleUpdateSymbol];\n\t}\n\t\n\t[setHandleUpdateSymbol](handleUpdate: UpdateHandler) {\n\t\treturn (this[handleUpdateSymbol] = handleUpdate);\n\t}\n\t\n\t[updateSymbol](updates: Updates) {\n\t\tif (updates) {\n\t\t\tfor (const key in this[updatesSymbol])// eslint-disable-line guard-for-in\n\t\t\t\tdelete this[key];\n\t\t\tfor (const key in updates)// eslint-disable-line guard-for-in\n\t\t\t\tthis[key] = updates[key];\n\t\t\tthis[updatesSymbol] = updates;\n\t\t} else\n\t\t\tthis[clearSymbol]();\n\t\t\n\t\tthis[handleUpdateSymbol]?.(this, this, this[updatesSymbol]);\n\t\t\n\t\treturn this;\n\t}\n\t\n\t[getAsUpdatesSymbol](): Updates {\n\t\treturn this[updatesSymbol] && { ...this[updatesSymbol] };\n\t}\n\t\n\t[getAsInitialUpdatedSymbol](): Updated {\n\t\treturn this.valueOf()!;\n\t}\n\t\n\t[clearSymbol]() {\n\t\t\n\t\tfor (const key in this)// eslint-disable-line guard-for-in\n\t\t\tdelete this[key];\n\t\tthis[updatesSymbol] = null;\n\t\t\n\t}\n\t\n\tvalueOf() {\n\t\treturn this[updatesSymbol] && this;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionObject\";\n\t}\n\t\n\t[key: string]: unknown;\n\t\n\t\n\tstatic updateSymbol = updateSymbol;\n\tstatic getHandleUpdateSymbol = getHandleUpdateSymbol;\n\tstatic setHandleUpdateSymbol = setHandleUpdateSymbol;\n\tstatic getAsUpdatesSymbol = getAsUpdatesSymbol;\n\tstatic getAsInitialUpdatedSymbol = getAsInitialUpdatedSymbol;\n\tstatic clearSymbol = clearSymbol;\n\tstatic WithSubscription: typeof SubscriptionObjectWithSubscription;\n\t\n}\n\n\nexport class SubscriptionObjectWithSubscription extends SubscriptionObject {\n\tconstructor(publicationName: string, params: unknown[], onUpdate: UpdateHandler, immediately = true) {\n\t\tsuper(null, onUpdate);\n\t\t\n\t\tthis.#publicationName = publicationName;\n\t\tthis.#params = params;\n\t\t\n\t\tif (immediately)\n\t\t\tthis[subscribeSymbol]();\n\t\t\n\t}\n\t\n\t#publicationName;\n\t#params;\n\t#subscription: Subscription | null = null;\n\t\n\t[subscribeSymbol]() {\n\t\t\n\t\tif (!this.#subscription)\n\t\t\tthis.#subscription = new Subscription(\"object\", this.#publicationName, this.#params, updates => this[updateSymbol](updates as Updates));\n\t\t\n\t}\n\t\n\t[unsubscribeSymbol]() {\n\t\t\n\t\tif (this.#subscription) {\n\t\t\tthis.#subscription.cancel();\n\t\t\tthis.#subscription = null;\n\t\t}\n\t\t\n\t}\n\t\n\t[renewSymbol](publicationName?: string, params?: unknown[]) {\n\t\t\n\t\tif (this.#subscription) {\n\t\t\tthis[unsubscribeSymbol]();\n\t\t\t\n\t\t\tif (publicationName)\n\t\t\t\tif (Array.isArray(publicationName))\n\t\t\t\t\tparams = publicationName;\n\t\t\t\telse\n\t\t\t\t\tthis.#publicationName = publicationName;\n\t\t\t\n\t\t\tif (params)\n\t\t\t\tthis.#params = params;\n\t\t\t\n\t\t\tthis[subscribeSymbol]();\n\t\t}\n\t\t\n\t}\n\t\n\t[getSubscriptionSymbol]() {\n\t\treturn this.#subscription;\n\t}\n\t\n\tget [Symbol.toStringTag]() {\n\t\treturn \"SubscriptionObjectWithSubscription\";\n\t}\n\t\n\t\n\tstatic subscribeSymbol = subscribeSymbol;\n\tstatic unsubscribeSymbol = unsubscribeSymbol;\n\tstatic renewSymbol = renewSymbol;\n\tstatic getSubscriptionSymbol = getSubscriptionSymbol;\n\t\n}\n\nSubscriptionObject.WithSubscription = SubscriptionObjectWithSubscription;\n"],
|
|
5
|
+
"mappings": "oiBAWA,IAAIA,GACAC,EACAC,EAGSC,EAAN,KAAmB,CACzB,YAAYC,EAAkCC,EAAyBC,EAAkB,CAAC,EAAGC,EAAiCC,EAAc,GAAM,CA2BlJC,EAAA,UACAA,EAAA,aACAA,EAAA,wBACAA,EAAA,aACAA,EAAA,gBACAA,EAAA,oBACAA,EAA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AvTlD,IAAAC,EAuTqD,OAAAN,EAAAM,EAAAD,EAAM5B,EAAAE,IAAN,KAAA2B,IACnDF,EAAS,YAAeC,GAA0B,CAxTpD,IAAAC,EAwTuD,OAAAN,EAAAM,EAAAD,EAAM5B,EAAAG,IAAN,KAAA0B,IAnPhD,IAAMC,GAAN1B",
|
|
6
|
+
"names": ["i", "subscriptions", "ws", "Subscription", "type", "publicationName", "args", "handler", "immediately", "__publicField", "_ws", "si", "updates", "subscription", "removeOne", "updateSymbol", "getHandleUpdateSymbol", "setHandleUpdateSymbol", "getAsUpdatesSymbol", "getAsInitialUpdatedSymbol", "clearSymbol", "subscribeSymbol", "unsubscribeSymbol", "renewSymbol", "getSubscriptionSymbol", "getHandleSubscriptionSymbol", "setHandleSubscriptionSymbol", "ascSort", "a", "b", "descSort", "_a", "_b", "_c", "_d", "SubscriptionArray", "updates", "onUpdate", "__publicField", "getHandleUpdateSymbol", "setHandleUpdateSymbol", "handleUpdate", "updated", "shouldSort", "update", "array", "sort", "newItem", "itemToDelete", "removeOne", "updateSymbol", "getAsUpdatesSymbol", "getAsInitialUpdatedSymbol", "clearSymbol", "SubscriptionArrayWithSubscription", "publicationName", "params", "immediately", "Subscription", "subscribeSymbol", "unsubscribeSymbol", "renewSymbol", "getSubscriptionSymbol", "EventEmitter", "debounce", "StatefulPromise", "privates", "EventEmitter", "debounce", "removeOne", "StatefulPromise", "removeOne", "unique", "createSortFunction", "sortList", "tempScript", "key", "value", "sortFunction", "_a", "_b", "_c", "_d", "_updates", "_fieldsToSort", "_Item", "SubscriptionMap", "updates", "onUpdate", "__publicField", "__privateAdd", "getHandleUpdateSymbol", "setHandleUpdateSymbol", "handleUpdate", "TheItem", "__privateSet", "_id", "item", "__privateGet", "updated", "shouldSort", "prevUpdates", "update", "array", "unique", "updatesMap", "itemUpdates", "prevItemUpdates", "newItem", "isAtomic", "updatedFields", "fieldName", "itemToDelete", "removeOne", "updateSymbol", "getAsUpdatesSymbol", "getAsInitialUpdatedSymbol", "clearSymbol", "SubscriptionMapWithSubscription", "publicationName", "params", "immediately", "Subscription", "subscribeSymbol", "unsubscribeSymbol", "renewSymbol", "getSubscriptionSymbol", "_map", "SubscriptionMapItem", "map", "handleUpdateSymbol", "updatesSymbol", "_a", "_b", "SubscriptionObject", "updates", "onUpdate", "__publicField", "updateSymbol", "getHandleUpdateSymbol", "setHandleUpdateSymbol", "handleUpdate", "key", "clearSymbol", "getAsUpdatesSymbol", "getAsInitialUpdatedSymbol", "_publicationName", "_params", "_subscription", "SubscriptionObjectWithSubscription", "publicationName", "params", "immediately", "__privateAdd", "__privateSet", "subscribeSymbol", "__privateGet", "Subscription", "unsubscribeSymbol", "renewSymbol", "getSubscriptionSymbol", "isUpdatedMapOrArray", "updated", "_loadPromise", "_initPromise", "_unloadPromise", "_SubscriptionGroupItem_instances", "applyOptions_fn", "attachTo_fn", "_loadUpdated", "_handleSubscription", "load_fn", "init_fn", "unload_fn", "_SubscriptionGroupItem", "EventEmitter", "definition", "group", "__privateAdd", "__publicField", "_", "updates", "__privateSet", "privates", "value", "type", "publicationName", "params", "handle", "onBeforeInit", "debounceLimit", "preventBind", "__privateMethod", "unsubscribeSymbol", "removeOne", "__privateGet", "subscribeSymbol", "handleUpdate", "getHandleUpdateSymbol", "initialUpdated", "getAsInitialUpdatedSymbol", "getAsUpdatesSymbol", "renewSymbol", "emitUpdate", "debouncedUpdated", "emitUpdateDebounced", "debounce", "isDetached", "item", "StatefulPromise", "handleSubscription", "setHandleUpdateSymbol", "SubscriptionArrayWithSubscription", "SubscriptionMapWithSubscription", "SubscriptionObjectWithSubscription", "_a", "SubscriptionGroupItem", "isTupleDefinition", "definition", "parseDefinition", "args", "parsed", "_loadPromise", "_initPromise", "_unloadPromise", "_debounceLimit", "_SubscriptionGroup_instances", "load_fn", "init_fn", "unload_fn", "_SubscriptionGroup", "EventEmitter", "definitions", "target", "debounceLimit", "immediately", "__privateAdd", "__publicField", "__privateSet", "StatefulPromise", "item", "__privateGet", "emitUpdateDebounced", "debounce", "shouldReload", "SubscriptionGroupItem", "names", "shouldUpdate", "name", "__privateMethod", "itemsToDetach", "definitionsToRedefine", "definitionsToAttach", "privates", "group", "_a", "SubscriptionGroup"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
"name": "insite-subscriptions-client",
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "Client-side subscriptions/publications for inSite",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"insite",
|
|
7
|
+
"subscriptions",
|
|
8
|
+
"publications",
|
|
9
|
+
"client"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/nesvet/insite#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/nesvet/insite/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/nesvet/insite.git",
|
|
18
|
+
"directory": "packages/subscriptions-client"
|
|
19
|
+
},
|
|
20
|
+
"funding": {
|
|
21
|
+
"type": "patreon",
|
|
22
|
+
"url": "https://www.patreon.com/nesvet"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "bun .conveyer.js",
|
|
36
|
+
"postbuild": "tsc -p .",
|
|
37
|
+
"clean": "rm -rf dist",
|
|
38
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
39
|
+
"typecheck": "tsc --noEmit"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@nesvet/n": "^1.2.1",
|
|
43
|
+
"eventemitter3": "^5.0.4",
|
|
44
|
+
"insite-ws": "^2.5.0"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=20.0.0"
|
|
48
|
+
}
|
|
36
49
|
}
|