wenay-common2 1.0.62 → 1.0.63

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.
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.managedStore = void 0;
4
+ exports.createStoreManager = createStoreManager;
5
+ const Listen_1 = require("../events/Listen");
6
+ const store_1 = require("./store");
7
+ const store_offline_1 = require("./store-offline");
8
+ const store_replay_1 = require("./store-replay");
9
+ function kindOf(resource) {
10
+ return resource.kind ?? 'mirror';
11
+ }
12
+ function hasAnyTag(resourceTags, tags) {
13
+ if (!tags?.length)
14
+ return true;
15
+ if (!resourceTags?.length)
16
+ return false;
17
+ return tags.some(tag => resourceTags.includes(tag));
18
+ }
19
+ function resourceScore(key, resource, usage, now) {
20
+ const base = typeof resource.priority == 'function'
21
+ ? resource.priority({ key, usage, now })
22
+ : resource.priority ?? 0;
23
+ const usageScore = usage ? usage.weight + Math.min(usage.count, 50) : 0;
24
+ const recency = usage?.lastUsedAt ? Math.max(0, 1_000_000 - (now - usage.lastUsedAt)) / 1_000_000 : 0;
25
+ return base + usageScore + recency;
26
+ }
27
+ exports.managedStore = {
28
+ mirror(resource) {
29
+ return { ...resource, kind: 'mirror' };
30
+ },
31
+ replay(resource) {
32
+ return { ...resource, kind: 'replay' };
33
+ },
34
+ offline(resource) {
35
+ return { ...resource, kind: 'offline' };
36
+ },
37
+ };
38
+ function createStoreManager(resources) {
39
+ const usages = new Map();
40
+ const [emitStatus, statusListen] = (0, Listen_1.listen)();
41
+ function usageFor(key, resource) {
42
+ const usageKey = resource.usageKey ?? key;
43
+ let usage = usages.get(usageKey);
44
+ if (!usage) {
45
+ usage = { count: 0, weight: 0 };
46
+ usages.set(usageKey, usage);
47
+ }
48
+ return usage;
49
+ }
50
+ function createHandle(key, resource) {
51
+ const kind = kindOf(resource);
52
+ let state = 'idle';
53
+ let store;
54
+ let stopSync;
55
+ let pending;
56
+ let error;
57
+ let startedAt;
58
+ let stoppedAt;
59
+ function setState(next, nextError) {
60
+ state = next;
61
+ error = nextError;
62
+ if (next == 'ready')
63
+ startedAt = Date.now();
64
+ if (next == 'stopped')
65
+ stoppedAt = Date.now();
66
+ emitStatus(status());
67
+ }
68
+ function status() {
69
+ return { key, state, kind, error, startedAt, stoppedAt };
70
+ }
71
+ async function start(opts = {}) {
72
+ if (resource.explicitOnly && !opts.explicit) {
73
+ throw new Error(`store manager: ${key} is explicitOnly`);
74
+ }
75
+ if (state == 'ready' && store)
76
+ return store;
77
+ if (pending)
78
+ return pending;
79
+ pending = (async () => {
80
+ setState('starting');
81
+ try {
82
+ if (kind == 'mirror') {
83
+ const r = resource;
84
+ store ??= (0, store_1.createStoreMirror)(r.remote, r.initial, r.storeOpts);
85
+ const mode = r.sync?.mode ?? 'pull';
86
+ const opts = r.sync?.opts;
87
+ stopSync = mode == 'patches'
88
+ ? await store.syncPatches(r.mask, opts)
89
+ : mode == 'changedData'
90
+ ? await store.syncChangedData(r.mask, opts)
91
+ : await store.sync(r.mask, opts);
92
+ }
93
+ else if (kind == 'replay') {
94
+ const r = resource;
95
+ store ??= (0, store_1.createStore)(r.initial, r.storeOpts);
96
+ const sub = (0, store_replay_1.syncStoreReplay)(store, r.remote, r.syncOpts);
97
+ stopSync = sub;
98
+ await sub.ready;
99
+ }
100
+ else {
101
+ const r = resource;
102
+ store = await (0, store_offline_1.createOfflineStore)({
103
+ key: r.storageKey ?? key,
104
+ remote: r.remote,
105
+ initial: r.initial,
106
+ storage: r.storage,
107
+ version: r.version,
108
+ debounceMs: r.debounceMs,
109
+ storeOpts: r.storeOpts,
110
+ syncOpts: r.syncOpts,
111
+ migrate: r.migrate,
112
+ });
113
+ await store.ready;
114
+ }
115
+ setState('ready');
116
+ return store;
117
+ }
118
+ catch (e) {
119
+ setState('error', e);
120
+ throw e;
121
+ }
122
+ finally {
123
+ pending = undefined;
124
+ }
125
+ })();
126
+ return pending;
127
+ }
128
+ function stop() {
129
+ stopSync?.();
130
+ stopSync = undefined;
131
+ if (kind == 'offline') {
132
+ store?.close?.();
133
+ store = undefined;
134
+ }
135
+ if (state != 'idle')
136
+ setState('stopped');
137
+ }
138
+ function touch(weight = 1) {
139
+ const usage = usageFor(key, resource);
140
+ usage.count++;
141
+ usage.weight += weight;
142
+ usage.lastUsedAt = Date.now();
143
+ }
144
+ return { key, kind, start, stop, get: () => store, status, touch };
145
+ }
146
+ const handles = {};
147
+ for (const key of Object.keys(resources))
148
+ handles[key] = createHandle(key, resources[key]);
149
+ function plan(opts = {}) {
150
+ const now = opts.now ?? Date.now();
151
+ const keySet = opts.keys ? new Set([...opts.keys].map(String)) : null;
152
+ const out = [];
153
+ for (const key of Object.keys(resources)) {
154
+ if (keySet && !keySet.has(key))
155
+ continue;
156
+ const resource = resources[key];
157
+ if (!hasAnyTag(resource.tags, opts.tags))
158
+ continue;
159
+ if (resource.explicitOnly && !opts.includeExplicit)
160
+ continue;
161
+ if (resource.large && !opts.includeLarge)
162
+ continue;
163
+ const usage = usages.get(resource.usageKey ?? key);
164
+ out.push({
165
+ key,
166
+ kind: kindOf(resource),
167
+ score: resourceScore(key, resource, usage, now),
168
+ state: handles[key].status().state,
169
+ large: !!resource.large,
170
+ explicitOnly: !!resource.explicitOnly,
171
+ tags: resource.tags ?? [],
172
+ });
173
+ }
174
+ out.sort((a, b) => b.score - a.score || a.key.localeCompare(b.key));
175
+ return opts.limit == null ? out : out.slice(0, opts.limit);
176
+ }
177
+ async function start(key, opts) {
178
+ const handle = handles[key];
179
+ if (!handle)
180
+ throw new Error(`store manager: unknown resource ${key}`);
181
+ return handle.start(opts);
182
+ }
183
+ async function startMany(keys, opts) {
184
+ const out = {};
185
+ for (const key of keys)
186
+ out[key] = await start(key, opts);
187
+ return out;
188
+ }
189
+ async function startPlanned(opts = {}) {
190
+ const out = {};
191
+ for (const item of plan(opts))
192
+ out[item.key] = await handles[item.key].start(opts);
193
+ return out;
194
+ }
195
+ function stop(key) {
196
+ const handle = handles[key];
197
+ if (!handle)
198
+ throw new Error(`store manager: unknown resource ${key}`);
199
+ handle.stop();
200
+ }
201
+ function stopAll() {
202
+ for (const handle of Object.values(handles))
203
+ handle.stop();
204
+ }
205
+ function get(key) {
206
+ return handles[key]?.get();
207
+ }
208
+ function touch(key, weight) {
209
+ const handle = handles[key];
210
+ if (!handle)
211
+ throw new Error(`store manager: unknown resource ${key}`);
212
+ handle.touch(weight);
213
+ }
214
+ return {
215
+ handles: handles,
216
+ statusListen,
217
+ plan,
218
+ start,
219
+ startMany,
220
+ startPlanned,
221
+ stop,
222
+ stopAll,
223
+ get,
224
+ touch,
225
+ usage: () => new Map(usages),
226
+ };
227
+ }
@@ -68,20 +68,20 @@ export declare function persistStore<T extends object>(store: Store<T>, opts: Pe
68
68
  seq: () => number;
69
69
  status: () => OfflineStoreStatus;
70
70
  statusListen: {
71
- on: import("../events/Listen3").ListenOnCurrent<[OfflineStoreStatus]>;
72
- once: (cb: import("../events/Listen3").Listener<[OfflineStoreStatus]>, opts?: {
73
- key?: import("../events/Listen3").ListenKey;
74
- current?: import("../events/Listen3").ListenCurrent<[OfflineStoreStatus]> | undefined;
75
- }) => import("../events/Listen3").ListenOff;
76
- emit: import("../events/Listen3").Listener<[OfflineStoreStatus]>;
77
- has(key: import("../events/Listen3").ListenKey): boolean;
78
- off(keyOrCallback: import("../events/Listen3").ListenKey | import("../events/Listen3").Listener<[OfflineStoreStatus]> | null): void;
71
+ on: import("../events/Listen").ListenOnCurrent<[OfflineStoreStatus]>;
72
+ once: (cb: import("../events/Listen").Listener<[OfflineStoreStatus]>, opts?: {
73
+ key?: import("../events/Listen").ListenKey;
74
+ current?: import("../events/Listen").ListenCurrent<[OfflineStoreStatus]> | undefined;
75
+ }) => import("../events/Listen").ListenOff;
76
+ emit: import("../events/Listen").Listener<[OfflineStoreStatus]>;
77
+ has(key: import("../events/Listen").ListenKey): boolean;
78
+ off(keyOrCallback: import("../events/Listen").ListenKey | import("../events/Listen").Listener<[OfflineStoreStatus]> | null): void;
79
79
  close(): void;
80
80
  count(): number;
81
- keys(): import("../events/Listen3").ListenKey[];
81
+ keys(): import("../events/Listen").ListenKey[];
82
82
  isRunning(): boolean;
83
83
  run(): void;
84
- onClose(cb: () => void): import("../events/Listen3").ListenOff;
84
+ onClose(cb: () => void): import("../events/Listen").ListenOff;
85
85
  };
86
86
  setSyncStatus: (patch: Partial<OfflineStoreStatus>) => void;
87
87
  };
@@ -4,7 +4,7 @@ exports.createMemoryOfflineStorage = createMemoryOfflineStorage;
4
4
  exports.persistStore = persistStore;
5
5
  exports.createOfflineStore = createOfflineStore;
6
6
  const common_1 = require("../core/common");
7
- const Listen3_1 = require("../events/Listen3");
7
+ const Listen_1 = require("../events/Listen");
8
8
  const store_1 = require("./store");
9
9
  const store_replay_1 = require("./store-replay");
10
10
  function isRecord(v) {
@@ -66,7 +66,7 @@ function persistStore(store, opts) {
66
66
  seq,
67
67
  savedAt,
68
68
  };
69
- const [emitStatus, statusListen] = (0, Listen3_1.listenStore)({
69
+ const [emitStatus, statusListen] = (0, Listen_1.listenStore)({
70
70
  current: () => [copyStatus(status)],
71
71
  });
72
72
  function updateStatus(patch = {}) {
@@ -1,5 +1,5 @@
1
1
  import { createListen } from "../events/Listen";
2
- import { listenUpdate, listenUpdatePaths, reactive, ReactiveChange } from "./reactive2";
2
+ import { listenUpdate, listenUpdatePaths, reactive, ReactiveChange } from "./reactive";
3
3
  export type StorePath = readonly PropertyKey[];
4
4
  export type StoreDrain = "micro" | "immediate" | number | ((flush: () => void) => void);
5
5
  export type StoreSubOpts = {
@@ -7,7 +7,7 @@ exports.createStore = createStore;
7
7
  exports.exposeStore = exposeStore;
8
8
  exports.createStoreMirror = createStoreMirror;
9
9
  const Listen_1 = require("../events/Listen");
10
- const reactive2_1 = require("./reactive2");
10
+ const reactive_1 = require("./reactive");
11
11
  const hasSetImmediate = typeof setImmediate == "function";
12
12
  function pathText(path) {
13
13
  return path.map(String).join(".");
@@ -119,7 +119,7 @@ function setAt(root, path, value) {
119
119
  p[path[path.length - 1]] = value;
120
120
  }
121
121
  function snapshotValue(value, seen = new WeakMap()) {
122
- value = (0, reactive2_1.toRaw)(value);
122
+ value = (0, reactive_1.toRaw)(value);
123
123
  if (!isObj(value))
124
124
  return value;
125
125
  const old = seen.get(value);
@@ -158,7 +158,7 @@ function maskPaths(mask, base = []) {
158
158
  return out;
159
159
  }
160
160
  function pickSnapshot(root, mask, base = []) {
161
- root = (0, reactive2_1.toRaw)(root);
161
+ root = (0, reactive_1.toRaw)(root);
162
162
  if (mask === true || mask == null)
163
163
  return snapshotValue(getAt(root, base));
164
164
  const out = {};
@@ -259,7 +259,7 @@ function maskFromPaths(paths) {
259
259
  return out ?? true;
260
260
  }
261
261
  function makePatch(root, path) {
262
- root = (0, reactive2_1.toRaw)(root);
262
+ root = (0, reactive_1.toRaw)(root);
263
263
  const exists = hasAt(root, path);
264
264
  return {
265
265
  path: [...path],
@@ -311,9 +311,9 @@ function createEachListen(store, opts = {}) {
311
311
  if (opts.depth != null && opts.depth != 1)
312
312
  throw new Error("store.each: only depth 1 is supported (reserved option)");
313
313
  return (0, Listen_1.createListen)((emit) => {
314
- const known = new Set(Reflect.ownKeys((0, reactive2_1.toRaw)(store.state)));
314
+ const known = new Set(Reflect.ownKeys((0, reactive_1.toRaw)(store.state)));
315
315
  function emitKey(key) {
316
- const raw = (0, reactive2_1.toRaw)(store.state);
316
+ const raw = (0, reactive_1.toRaw)(store.state);
317
317
  const exists = isObj(raw) && key in raw;
318
318
  if (exists)
319
319
  known.add(key);
@@ -331,7 +331,7 @@ function createEachListen(store, opts = {}) {
331
331
  keys.add(path[0]);
332
332
  }
333
333
  if (root) {
334
- for (const key of Reflect.ownKeys((0, reactive2_1.toRaw)(store.state)))
334
+ for (const key of Reflect.ownKeys((0, reactive_1.toRaw)(store.state)))
335
335
  keys.add(key);
336
336
  for (const key of known)
337
337
  keys.add(key);
@@ -372,7 +372,7 @@ function watchTarget(root, path) {
372
372
  if (!isObj(cur) || !(k in cur))
373
373
  return lastReactive;
374
374
  const next = cur[k];
375
- if ((0, reactive2_1.isReactive)(next)) {
375
+ if ((0, reactive_1.isReactive)(next)) {
376
376
  cur = next;
377
377
  lastReactive = next;
378
378
  }
@@ -427,10 +427,10 @@ function subscribePath(store, path, cb, opts = {}, once = false) {
427
427
  function attach() {
428
428
  offUpdate?.();
429
429
  const target = watchTarget(store._state, path);
430
- offUpdate = (0, reactive2_1.onUpdate)(target, () => {
430
+ offUpdate = (0, reactive_1.onUpdate)(target, () => {
431
431
  const exists = hasAt(store._state, path);
432
432
  const value = getAt(store._state, path);
433
- const valueIsObject = (0, reactive2_1.isReactive)(value);
433
+ const valueIsObject = (0, reactive_1.isReactive)(value);
434
434
  const watchedSelf = target === value;
435
435
  if (!valueIsObject && !watchedSelf && sameLeaf(lastValue, value, lastExists, exists))
436
436
  return;
@@ -541,7 +541,7 @@ function createSelection(store, base, mask, defaults = {}) {
541
541
  };
542
542
  }
543
543
  function createStore(initial, opts = {}) {
544
- const state = (0, reactive2_1.reactive)(initial, opts);
544
+ const state = (0, reactive_1.reactive)(initial, opts);
545
545
  let store;
546
546
  store = {
547
547
  _state: state,
@@ -556,8 +556,8 @@ function createStore(initial, opts = {}) {
556
556
  once: (cb, opts) => getNode(store, []).once(cb, opts),
557
557
  update: (mask, opts) => createSelection(store, [], mask, opts),
558
558
  each: (opts) => createEachListen(store, opts),
559
- listen: () => (0, reactive2_1.listenUpdate)(state),
560
- listenPaths: () => (0, reactive2_1.listenUpdatePaths)(state),
559
+ listen: () => (0, reactive_1.listenUpdate)(state),
560
+ listenPaths: () => (0, reactive_1.listenUpdatePaths)(state),
561
561
  count: () => Array.from(store._counts.values()).reduce((a, b) => a + b, 0),
562
562
  };
563
563
  return store;
@@ -1,6 +1,6 @@
1
1
  export declare function promiseProgress<T extends any = unknown>(array: ((() => Promise<T>) | (() => any) | Promise<T>)[]): {
2
- onOk: (cb: (...data: [data: T, i: number, countOk: number, countError: number, count: number]) => any) => import("../events/Listen3").ListenOff;
3
- onError: (cb: (...data: [error: any, i: number, countOk: number, countError: number, count: number]) => any) => import("../events/Listen3").ListenOff;
2
+ onOk: (cb: (...data: [data: T, i: number, countOk: number, countError: number, count: number]) => any) => import("../events/Listen").ListenOff;
3
+ onError: (cb: (...data: [error: any, i: number, countOk: number, countError: number, count: number]) => any) => import("../events/Listen").ListenOff;
4
4
  all: () => Promise<any[]>;
5
5
  allSettled: () => Promise<PromiseSettledResult<any>[]>;
6
6
  items: () => Promise<any>[];
@@ -1 +1,129 @@
1
- export * from "./Listen3";
1
+ export type Listener<T extends any[]> = (...args: T) => void;
2
+ export type NormalizeTuple<T> = T extends any[] ? T : [T];
3
+ export type ListenKey = string | symbol;
4
+ export type ListenOff = () => void;
5
+ type CloseCallback = () => void;
6
+ declare const LISTEN_ON_BRAND: unique symbol;
7
+ export type ListenOn<Z extends any[] = any[]> = ((cb: Listener<Z>, opts?: {
8
+ cbClose?: CloseCallback;
9
+ key?: ListenKey;
10
+ }) => ListenOff) & {
11
+ readonly [LISTEN_ON_BRAND]: Z;
12
+ };
13
+ export type ListenOnCurrent<Z extends any[] = any[]> = ((cb: Listener<Z>, opts?: {
14
+ cbClose?: CloseCallback;
15
+ key?: ListenKey;
16
+ current?: ListenCurrent<Z>;
17
+ }) => ListenOff) & {
18
+ readonly [LISTEN_ON_BRAND]: Z;
19
+ };
20
+ export type ListenCurrentProvider<Z extends any[]> = () => Z | undefined;
21
+ export type ListenCurrent<Z extends any[]> = boolean | ListenCurrentProvider<Z>;
22
+ export type ListenCoreApi<T = any> = {
23
+ emit: Listener<NormalizeTuple<T>>;
24
+ has(key: ListenKey): boolean;
25
+ on: ListenOn<NormalizeTuple<T>>;
26
+ off(keyOrCallback: Listener<NormalizeTuple<T>> | null | ListenKey): void;
27
+ once(cb: Listener<NormalizeTuple<T>>, opts?: {
28
+ key?: ListenKey;
29
+ }): ListenOff;
30
+ close(): void;
31
+ count(): number;
32
+ keys(): ListenKey[];
33
+ };
34
+ export type ListenApi<T = any> = ListenCoreApi<T> & {
35
+ isRunning(): boolean;
36
+ run(): void;
37
+ onClose(cb: CloseCallback): ListenOff;
38
+ };
39
+ export type ListenCoreOptions<T = any> = {
40
+ fast?: boolean;
41
+ onRemove?: (key: ListenKey) => void;
42
+ event?: (type: 'add' | 'remove', count: number, api: ListenCoreApi<T>) => void;
43
+ };
44
+ export type ListenOptions<T = any> = {
45
+ event?: (type: 'add' | 'remove', count: number, api: ListenApi<T>) => void;
46
+ fast?: boolean;
47
+ closeOn?: ListenApi<any>;
48
+ };
49
+ export type ListenStoreOptions<T> = ListenOptions<T> & {
50
+ current: ListenCurrentProvider<NormalizeTuple<T>>;
51
+ };
52
+ export type ListenOnBrand<Z extends any[] = any[]> = {
53
+ readonly [LISTEN_ON_BRAND]: Z;
54
+ };
55
+ export declare function getListenByOn(fn: any): any;
56
+ export declare function isListenOn(fn: any): boolean;
57
+ export declare function registerListenOn(on: Function, api: any): void;
58
+ export declare function createListenCore<T>(options?: ListenCoreOptions<T>): ListenCoreApi<T>;
59
+ export declare function createListen<T>(producer: (emit: Listener<NormalizeTuple<T>>) => (void | ListenOff), options?: ListenOptions<T>): ListenApi<T>;
60
+ export declare function createFastListen<T>(producer: (emit: Listener<NormalizeTuple<T>>) => (void | ListenOff)): ListenApi<T>;
61
+ export declare function listen<T>(options?: ListenOptions<T>): readonly [Listener<NormalizeTuple<T>>, ListenApi<T>];
62
+ export declare function withStoreListen<T>(base: ListenApi<T>, currentProvider: ListenCurrentProvider<NormalizeTuple<T>>): {
63
+ on: ListenOnCurrent<NormalizeTuple<T>>;
64
+ once: (cb: Listener<NormalizeTuple<T>>, opts?: {
65
+ key?: ListenKey;
66
+ current?: ListenCurrent<NormalizeTuple<T>>;
67
+ }) => ListenOff;
68
+ emit: Listener<NormalizeTuple<T>>;
69
+ has(key: ListenKey): boolean;
70
+ off(keyOrCallback: ListenKey | Listener<NormalizeTuple<T>> | null): void;
71
+ close(): void;
72
+ count(): number;
73
+ keys(): ListenKey[];
74
+ isRunning(): boolean;
75
+ run(): void;
76
+ onClose(cb: CloseCallback): ListenOff;
77
+ };
78
+ export type ListenStoreApi<T> = ReturnType<typeof withStoreListen<T>>;
79
+ export declare function createStoreListen<T>(producer: (emit: Listener<NormalizeTuple<T>>) => (void | ListenOff), options: ListenStoreOptions<T>): {
80
+ on: ListenOnCurrent<NormalizeTuple<T>>;
81
+ once: (cb: Listener<NormalizeTuple<T>>, opts?: {
82
+ key?: ListenKey;
83
+ current?: ListenCurrent<NormalizeTuple<T>> | undefined;
84
+ }) => ListenOff;
85
+ emit: Listener<NormalizeTuple<T>>;
86
+ has(key: ListenKey): boolean;
87
+ off(keyOrCallback: ListenKey | Listener<NormalizeTuple<T>> | null): void;
88
+ close(): void;
89
+ count(): number;
90
+ keys(): ListenKey[];
91
+ isRunning(): boolean;
92
+ run(): void;
93
+ onClose(cb: CloseCallback): ListenOff;
94
+ };
95
+ export declare function listenStore<T>(options: ListenStoreOptions<T>): readonly [Listener<NormalizeTuple<T>>, {
96
+ on: ListenOnCurrent<NormalizeTuple<T>>;
97
+ once: (cb: Listener<NormalizeTuple<T>>, opts?: {
98
+ key?: ListenKey;
99
+ current?: ListenCurrent<NormalizeTuple<T>> | undefined;
100
+ }) => ListenOff;
101
+ emit: Listener<NormalizeTuple<T>>;
102
+ has(key: ListenKey): boolean;
103
+ off(keyOrCallback: ListenKey | Listener<NormalizeTuple<T>> | null): void;
104
+ close(): void;
105
+ count(): number;
106
+ keys(): ListenKey[];
107
+ isRunning(): boolean;
108
+ run(): void;
109
+ onClose(cb: CloseCallback): ListenOff;
110
+ }];
111
+ export declare function toSlimListen<T>(full: ListenApi<T>): {
112
+ on: (cb: Listener<NormalizeTuple<T>>, opts?: {
113
+ key?: ListenKey;
114
+ }) => ListenOff;
115
+ off: (keyOrCallback: Listener<NormalizeTuple<T>> | null | ListenKey) => void;
116
+ close: () => void;
117
+ count: () => number;
118
+ };
119
+ export type SlimListen<T> = ReturnType<typeof toSlimListen<T>>;
120
+ export declare function slimListen<T>(options?: ListenOptions<T>): readonly [Listener<NormalizeTuple<T>>, {
121
+ on: (cb: Listener<NormalizeTuple<T>>, opts?: {
122
+ key?: ListenKey;
123
+ } | undefined) => ListenOff;
124
+ off: (keyOrCallback: ListenKey | Listener<NormalizeTuple<T>> | null) => void;
125
+ close: () => void;
126
+ count: () => number;
127
+ }];
128
+ export declare function isListenCallback(obj: any): obj is ListenApi;
129
+ export {};