@sweidos/eidos 1.0.12 → 1.0.17

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/dist/index.d.ts CHANGED
@@ -44,6 +44,16 @@ export declare type CacheStrategy = 'cache-first' | 'stale-while-revalidate' | '
44
44
  /** Remove all items from the action queue (IDB + in-memory store). */
45
45
  export declare function clearQueue(): Promise<void>;
46
46
 
47
+ /**
48
+ * Live state for a single queue item by ID. Returns `undefined` once the item
49
+ * is removed from the queue (after a successful replay or `clearQueue()`).
50
+ * @example
51
+ * // Svelte
52
+ * const item = eidosAction(queuedResult.id)
53
+ * $: status = $item?.status // 'pending' | 'replaying' | 'succeeded' | 'failed' | undefined
54
+ */
55
+ export declare function eidosAction(id: string): EidosReadable<ActionQueueItem | undefined>;
56
+
47
57
  declare interface EidosConfig {
48
58
  /** Path to the eidos service worker. Defaults to '/eidos-sw.js'. */
49
59
  swPath?: string;
@@ -66,6 +76,36 @@ declare interface EidosProviderProps extends EidosConfig {
66
76
  children: ReactNode;
67
77
  }
68
78
 
79
+ /** The action queue. Re-notifies on every queue mutation. */
80
+ export declare const eidosQueue: EidosReadable<ActionQueueItem[]>;
81
+
82
+ /**
83
+ * Queue counts. Re-notifies on any queue mutation — compare values inside the
84
+ * subscriber callback to skip work when counts haven't changed.
85
+ */
86
+ export declare const eidosQueueStats: EidosReadable<{
87
+ pending: number;
88
+ failed: number;
89
+ replaying: number;
90
+ total: number;
91
+ }>;
92
+
93
+ export declare interface EidosReadable<T> {
94
+ /** Subscribe to value changes. Returns an unsubscribe function. */
95
+ subscribe(run: (value: T) => void): () => void;
96
+ /** Read the current value synchronously without subscribing. */
97
+ getState(): T;
98
+ }
99
+
100
+ /**
101
+ * Live cache state for a single registered resource URL.
102
+ * @example
103
+ * // Svelte
104
+ * const entry = eidosResource('/api/products')
105
+ * $: hits = $entry?.cacheHits ?? 0
106
+ */
107
+ export declare function eidosResource(url: string): EidosReadable<ResourceEntry | undefined>;
108
+
69
109
  export declare interface EidosState {
70
110
  isOnline: boolean;
71
111
  swStatus: 'idle' | 'registering' | 'active' | 'error' | 'unsupported';
@@ -74,6 +114,17 @@ export declare interface EidosState {
74
114
  queue: ActionQueueItem[];
75
115
  }
76
116
 
117
+ /**
118
+ * Online status + SW lifecycle.
119
+ * Object identity changes on every notification — destructure or compare fields
120
+ * in the subscriber if you need to avoid unnecessary work.
121
+ */
122
+ export declare const eidosStatus: EidosReadable<{
123
+ isOnline: boolean;
124
+ swStatus: EidosStore['swStatus'];
125
+ swError: string | undefined;
126
+ }>;
127
+
77
128
  export declare interface EidosStore extends EidosState {
78
129
  setOnline: (online: boolean) => void;
79
130
  setSwStatus: (status: EidosState['swStatus'], error?: string) => void;
@@ -86,6 +137,9 @@ export declare interface EidosStore extends EidosState {
86
137
  hydrateQueue: (items: ActionQueueItem[]) => void;
87
138
  }
88
139
 
140
+ /** Full Eidos state snapshot. Prefer the narrower stores below. */
141
+ export declare const eidosStore: EidosReadable<EidosStore>;
142
+
89
143
  export declare interface GeneratedStrategy {
90
144
  name: string;
91
145
  swStrategy: CacheStrategy;
@@ -102,6 +156,8 @@ declare function _getState(): EidosStore;
102
156
 
103
157
  export declare function initEidos(config?: EidosConfig): Promise<void>;
104
158
 
159
+ export declare function isBgSyncSupported(): boolean;
160
+
105
161
  declare type Listener = () => void;
106
162
 
107
163
  export declare interface QueuedResult {
@@ -221,26 +277,12 @@ export declare function useEidosStatus(): {
221
277
  swError: string | undefined;
222
278
  };
223
279
 
224
- export declare const useEidosStore: typeof _useStore;
225
-
226
- declare function _useStore(): EidosStore;
227
-
228
- declare function _useStore<T>(selector: (state: EidosStore) => T): T;
229
-
230
- declare namespace _useStore {
231
- var getState: typeof _getState;
232
- var subscribe: typeof _subscribe;
233
- var setState: (partial: Partial<EidosStore> | ((s: EidosStore) => Partial<EidosStore>)) => void;
234
- }
280
+ export declare const useEidosStore: {
281
+ getState: typeof _getState;
282
+ subscribe: typeof _subscribe;
283
+ setState: (partial: Partial<EidosStore> | ((s: EidosStore) => Partial<EidosStore>)) => void;
284
+ };
235
285
 
236
286
  export declare const VERSION = "1.0.12";
237
287
 
238
288
  export { }
239
-
240
-
241
- declare namespace _useStore {
242
- var getState: typeof _getState;
243
- var subscribe: typeof _subscribe;
244
- var setState: (partial: Partial<EidosStore> | ((s: EidosStore) => Partial<EidosStore>)) => void;
245
- }
246
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sweidos/eidos",
3
- "version": "1.0.12",
3
+ "version": "1.0.17",
4
4
  "description": "Describe intent. The runtime figures out how. An abstraction layer for offline-first web apps.",
5
5
  "author": "Aditya Raj",
6
6
  "license": "MIT",