@akashjs/runtime 0.2.1 → 0.2.6
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/{chunk-NVZLEJXB.cjs → chunk-2Q6SYE5O.cjs} +2 -2
- package/dist/{chunk-NVZLEJXB.cjs.map → chunk-2Q6SYE5O.cjs.map} +1 -1
- package/dist/chunk-2U643GJZ.cjs +2 -0
- package/dist/chunk-2U643GJZ.cjs.map +1 -0
- package/dist/chunk-35DJOBEO.cjs +2 -0
- package/dist/chunk-35DJOBEO.cjs.map +1 -0
- package/dist/{chunk-POLTPHUA.js → chunk-3GRR4VW2.js} +3 -3
- package/dist/{chunk-3AL2DVPZ.cjs.map → chunk-3GRR4VW2.js.map} +1 -1
- package/dist/{chunk-Z5LQV5ND.js → chunk-5A7KDBDU.js} +2 -2
- package/dist/{chunk-Z5LQV5ND.js.map → chunk-5A7KDBDU.js.map} +1 -1
- package/dist/{chunk-D6QQYZIC.js → chunk-5NHDEY2C.js} +2 -2
- package/dist/chunk-5NHDEY2C.js.map +1 -0
- package/dist/{chunk-NQVWTQ2I.cjs → chunk-6GGYM5SF.cjs} +3 -3
- package/dist/{chunk-NQVWTQ2I.cjs.map → chunk-6GGYM5SF.cjs.map} +1 -1
- package/dist/chunk-AVVJKYT3.cjs +2 -0
- package/dist/chunk-AVVJKYT3.cjs.map +1 -0
- package/dist/{chunk-3AL2DVPZ.cjs → chunk-EEILP4OL.cjs} +3 -3
- package/dist/chunk-EEILP4OL.cjs.map +1 -0
- package/dist/{chunk-BT6HNBE7.js → chunk-FTTNKDZQ.js} +3 -3
- package/dist/{chunk-BT6HNBE7.js.map → chunk-FTTNKDZQ.js.map} +1 -1
- package/dist/chunk-H2HNKYN2.js +2 -0
- package/dist/chunk-H2HNKYN2.js.map +1 -0
- package/dist/chunk-TKFJGLUO.js +2 -0
- package/dist/chunk-TKFJGLUO.js.map +1 -0
- package/dist/chunk-U53YRJNV.js +36 -0
- package/dist/chunk-U53YRJNV.js.map +1 -0
- package/dist/chunk-ZYVQQ5VR.cjs +36 -0
- package/dist/chunk-ZYVQQ5VR.cjs.map +1 -0
- package/dist/{context-2uQ6fuxu.d.ts → context-CB1mCq2h.d.cts} +1 -1
- package/dist/{context-2uQ6fuxu.d.cts → context-CB1mCq2h.d.ts} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/devtools-overlay-CJWKBTP4.js +57 -0
- package/dist/devtools-overlay-CJWKBTP4.js.map +1 -0
- package/dist/devtools-overlay-EQ3G755P.cjs +57 -0
- package/dist/devtools-overlay-EQ3G755P.cjs.map +1 -0
- package/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -7
- package/dist/index.d.ts +11 -7
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/machine.cjs +1 -1
- package/dist/machine.js +1 -1
- package/dist/offline.cjs +1 -1
- package/dist/offline.d.cts +2 -0
- package/dist/offline.d.ts +2 -0
- package/dist/offline.js +1 -1
- package/dist/pwa.cjs +1 -1
- package/dist/pwa.d.cts +5 -1
- package/dist/pwa.d.ts +5 -1
- package/dist/pwa.js +1 -1
- package/dist/ssr.cjs +1 -1
- package/dist/ssr.js +1 -1
- package/dist/store.cjs +1 -1
- package/dist/store.d.cts +35 -36
- package/dist/store.d.ts +35 -36
- package/dist/store.js +1 -1
- package/dist/sync.cjs +1 -1
- package/dist/sync.d.cts +59 -4
- package/dist/sync.d.ts +59 -4
- package/dist/sync.js +1 -1
- package/dist/test.cjs +4 -4
- package/dist/test.cjs.map +1 -1
- package/dist/test.d.cts +71 -3
- package/dist/test.d.ts +71 -3
- package/dist/test.js +4 -4
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-6NX6JRSV.cjs +0 -32
- package/dist/chunk-6NX6JRSV.cjs.map +0 -1
- package/dist/chunk-772SU4MG.js +0 -2
- package/dist/chunk-772SU4MG.js.map +0 -1
- package/dist/chunk-7LQZF3XA.cjs +0 -2
- package/dist/chunk-7LQZF3XA.cjs.map +0 -1
- package/dist/chunk-D6QQYZIC.js.map +0 -1
- package/dist/chunk-H4SAK7A5.cjs +0 -2
- package/dist/chunk-H4SAK7A5.cjs.map +0 -1
- package/dist/chunk-IM2VW4TK.js +0 -32
- package/dist/chunk-IM2VW4TK.js.map +0 -1
- package/dist/chunk-ODDXU5DO.js +0 -2
- package/dist/chunk-ODDXU5DO.js.map +0 -1
- package/dist/chunk-POLTPHUA.js.map +0 -1
- package/dist/chunk-YIB4EKVI.cjs +0 -2
- package/dist/chunk-YIB4EKVI.cjs.map +0 -1
package/dist/machine.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk2Q6SYE5O_cjs=require('./chunk-2Q6SYE5O.cjs');require('./chunk-EEILP4OL.cjs');Object.defineProperty(exports,"createMachine",{enumerable:true,get:function(){return chunk2Q6SYE5O_cjs.a}});//# sourceMappingURL=machine.cjs.map
|
|
2
2
|
//# sourceMappingURL=machine.cjs.map
|
package/dist/machine.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as createMachine}from'./chunk-
|
|
1
|
+
export{a as createMachine}from'./chunk-5A7KDBDU.js';import'./chunk-3GRR4VW2.js';//# sourceMappingURL=machine.js.map
|
|
2
2
|
//# sourceMappingURL=machine.js.map
|
package/dist/offline.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk2U643GJZ_cjs=require('./chunk-2U643GJZ.cjs');require('./chunk-EEILP4OL.cjs');Object.defineProperty(exports,"createOfflineStore",{enumerable:true,get:function(){return chunk2U643GJZ_cjs.a}});//# sourceMappingURL=offline.cjs.map
|
|
2
2
|
//# sourceMappingURL=offline.cjs.map
|
package/dist/offline.d.cts
CHANGED
|
@@ -42,6 +42,8 @@ interface OfflineStoreOptions<T> {
|
|
|
42
42
|
interface OfflineStore<T extends Record<string, unknown>> {
|
|
43
43
|
/** All items (reactive) */
|
|
44
44
|
items: ReadonlySignal<T[]>;
|
|
45
|
+
/** Alias for items (reactive) */
|
|
46
|
+
data: ReadonlySignal<T[]>;
|
|
45
47
|
/** Get a single item by key */
|
|
46
48
|
get(key: string): T | undefined;
|
|
47
49
|
/** Add or update an item */
|
package/dist/offline.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ interface OfflineStoreOptions<T> {
|
|
|
42
42
|
interface OfflineStore<T extends Record<string, unknown>> {
|
|
43
43
|
/** All items (reactive) */
|
|
44
44
|
items: ReadonlySignal<T[]>;
|
|
45
|
+
/** Alias for items (reactive) */
|
|
46
|
+
data: ReadonlySignal<T[]>;
|
|
45
47
|
/** Get a single item by key */
|
|
46
48
|
get(key: string): T | undefined;
|
|
47
49
|
/** Add or update an item */
|
package/dist/offline.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as createOfflineStore}from'./chunk-
|
|
1
|
+
export{a as createOfflineStore}from'./chunk-5NHDEY2C.js';import'./chunk-3GRR4VW2.js';//# sourceMappingURL=offline.js.map
|
|
2
2
|
//# sourceMappingURL=offline.js.map
|
package/dist/pwa.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkZYVQQ5VR_cjs=require('./chunk-ZYVQQ5VR.cjs');require('./chunk-EEILP4OL.cjs');Object.defineProperty(exports,"generateSWScript",{enumerable:true,get:function(){return chunkZYVQQ5VR_cjs.b}});Object.defineProperty(exports,"registerServiceWorker",{enumerable:true,get:function(){return chunkZYVQQ5VR_cjs.a}});Object.defineProperty(exports,"subscribePush",{enumerable:true,get:function(){return chunkZYVQQ5VR_cjs.c}});//# sourceMappingURL=pwa.cjs.map
|
|
2
2
|
//# sourceMappingURL=pwa.cjs.map
|
package/dist/pwa.d.cts
CHANGED
|
@@ -71,7 +71,11 @@ interface CacheRoute {
|
|
|
71
71
|
* ]);
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
|
-
declare function generateSWScript(
|
|
74
|
+
declare function generateSWScript(routesOrConfig: CacheRoute[] | {
|
|
75
|
+
cacheName?: string;
|
|
76
|
+
precache?: string[];
|
|
77
|
+
runtimeCache?: CacheRoute[];
|
|
78
|
+
}): string;
|
|
75
79
|
/**
|
|
76
80
|
* Request push notification permission and subscribe.
|
|
77
81
|
*/
|
package/dist/pwa.d.ts
CHANGED
|
@@ -71,7 +71,11 @@ interface CacheRoute {
|
|
|
71
71
|
* ]);
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
|
-
declare function generateSWScript(
|
|
74
|
+
declare function generateSWScript(routesOrConfig: CacheRoute[] | {
|
|
75
|
+
cacheName?: string;
|
|
76
|
+
precache?: string[];
|
|
77
|
+
runtimeCache?: CacheRoute[];
|
|
78
|
+
}): string;
|
|
75
79
|
/**
|
|
76
80
|
* Request push notification permission and subscribe.
|
|
77
81
|
*/
|
package/dist/pwa.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as generateSWScript,a as registerServiceWorker,c as subscribePush}from'./chunk-
|
|
1
|
+
export{b as generateSWScript,a as registerServiceWorker,c as subscribePush}from'./chunk-U53YRJNV.js';import'./chunk-3GRR4VW2.js';//# sourceMappingURL=pwa.js.map
|
|
2
2
|
//# sourceMappingURL=pwa.js.map
|
package/dist/ssr.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkUOD4PYAN_cjs=require('./chunk-UOD4PYAN.cjs');require('./chunk-
|
|
1
|
+
'use strict';var chunkUOD4PYAN_cjs=require('./chunk-UOD4PYAN.cjs');require('./chunk-EEILP4OL.cjs');Object.defineProperty(exports,"escapeHtml",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.a}});Object.defineProperty(exports,"isServerRendering",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.b}});Object.defineProperty(exports,"nodeToHtml",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.i}});Object.defineProperty(exports,"renderNodes",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.j}});Object.defineProperty(exports,"renderToStream",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.e}});Object.defineProperty(exports,"renderToString",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.c}});Object.defineProperty(exports,"renderToStringSync",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.d}});Object.defineProperty(exports,"ssrElement",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.f}});Object.defineProperty(exports,"ssrRaw",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.h}});Object.defineProperty(exports,"ssrText",{enumerable:true,get:function(){return chunkUOD4PYAN_cjs.g}});//# sourceMappingURL=ssr.cjs.map
|
|
2
2
|
//# sourceMappingURL=ssr.cjs.map
|
package/dist/ssr.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as escapeHtml,b as isServerRendering,i as nodeToHtml,j as renderNodes,e as renderToStream,c as renderToString,d as renderToStringSync,f as ssrElement,h as ssrRaw,g as ssrText}from'./chunk-QTPP343X.js';import'./chunk-
|
|
1
|
+
export{a as escapeHtml,b as isServerRendering,i as nodeToHtml,j as renderNodes,e as renderToStream,c as renderToString,d as renderToStringSync,f as ssrElement,h as ssrRaw,g as ssrText}from'./chunk-QTPP343X.js';import'./chunk-3GRR4VW2.js';//# sourceMappingURL=ssr.js.map
|
|
2
2
|
//# sourceMappingURL=ssr.js.map
|
package/dist/store.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkAVVJKYT3_cjs=require('./chunk-AVVJKYT3.cjs');require('./chunk-35DJOBEO.cjs'),require('./chunk-EEILP4OL.cjs');Object.defineProperty(exports,"__getStoreInstances",{enumerable:true,get:function(){return chunkAVVJKYT3_cjs.d}});Object.defineProperty(exports,"clearStores",{enumerable:true,get:function(){return chunkAVVJKYT3_cjs.c}});Object.defineProperty(exports,"configureStores",{enumerable:true,get:function(){return chunkAVVJKYT3_cjs.a}});Object.defineProperty(exports,"defineStore",{enumerable:true,get:function(){return chunkAVVJKYT3_cjs.b}});//# sourceMappingURL=store.cjs.map
|
|
2
2
|
//# sourceMappingURL=store.cjs.map
|
package/dist/store.d.cts
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
|
+
import { SyncTransport } from './sync.cjs';
|
|
1
2
|
import { S as Signal, R as ReadonlySignal } from './signals-C7XfOHHR.cjs';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Global state management via defineStore().
|
|
5
|
-
*
|
|
6
|
-
* Stores are singleton signal containers that persist across
|
|
7
|
-
* components. They provide shared state, computed getters,
|
|
8
|
-
* and actions — no external library needed.
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* const useCounterStore = defineStore('counter', {
|
|
12
|
-
* state: () => ({ count: 0, name: 'Counter' }),
|
|
13
|
-
* getters: {
|
|
14
|
-
* doubled: (state) => state.count() * 2,
|
|
15
|
-
* },
|
|
16
|
-
* actions: {
|
|
17
|
-
* increment() { this.count.update(c => c + 1); },
|
|
18
|
-
* reset() { this.count.set(0); },
|
|
19
|
-
* },
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // In any component:
|
|
23
|
-
* const store = useCounterStore();
|
|
24
|
-
* store.count(); // 0
|
|
25
|
-
* store.doubled(); // 0
|
|
26
|
-
* store.increment();
|
|
27
|
-
* store.count(); // 1
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
4
|
type StateFactory<S> = () => S;
|
|
32
5
|
type Getters<S, G> = {
|
|
33
6
|
[K in keyof G]: (state: SignalifiedState<S>) => G[K];
|
|
@@ -53,17 +26,43 @@ type Store<S, G, A> = SignalifiedState<S> & {
|
|
|
53
26
|
/** Store ID */
|
|
54
27
|
$id: string;
|
|
55
28
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
29
|
+
interface PersistOptions<S> {
|
|
30
|
+
/** Only persist these state keys (default: all) */
|
|
31
|
+
pick?: (keyof S)[];
|
|
32
|
+
/** Storage backend (default: 'localStorage') */
|
|
33
|
+
storage?: 'localStorage' | 'sessionStorage';
|
|
34
|
+
/** Custom storage key (default: 'akash-store:{storeId}') */
|
|
35
|
+
key?: string;
|
|
36
|
+
/** Custom serializer (default: JSON.stringify) */
|
|
37
|
+
serialize?: (value: unknown) => string;
|
|
38
|
+
/** Custom deserializer (default: JSON.parse) */
|
|
39
|
+
deserialize?: (value: string) => unknown;
|
|
40
|
+
}
|
|
41
|
+
interface StoreSyncOptions {
|
|
42
|
+
/** Sync transport (WebSocket, local, etc.) */
|
|
43
|
+
transport?: SyncTransport;
|
|
44
|
+
/** Enable sync — uses provided or default transport */
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
/** Sync room/channel name (default: store ID) */
|
|
47
|
+
room?: string;
|
|
48
|
+
/** Unique peer ID */
|
|
49
|
+
peerId?: string;
|
|
50
|
+
/** Enable presence tracking */
|
|
51
|
+
presence?: boolean;
|
|
52
|
+
/** Only sync these state keys (default: all) */
|
|
53
|
+
pick?: string[];
|
|
54
|
+
}
|
|
62
55
|
interface StoreDefinition<S, G, A> {
|
|
63
56
|
state: StateFactory<S>;
|
|
64
57
|
getters?: Getters<S, G>;
|
|
65
|
-
actions?:
|
|
58
|
+
actions?: A & ThisType<SignalifiedState<S> & {
|
|
59
|
+
[K in keyof G]: ReadonlySignal<G[K]>;
|
|
60
|
+
} & A>;
|
|
66
61
|
plugins?: StorePlugin[];
|
|
62
|
+
/** Auto-persist state to storage. true = persist all to localStorage. */
|
|
63
|
+
persist?: boolean | PersistOptions<S> | PersistOptions<S>[];
|
|
64
|
+
/** Sync state across peers via CRDT. Adds real-time collaboration to any store. */
|
|
65
|
+
sync?: StoreSyncOptions;
|
|
67
66
|
}
|
|
68
67
|
interface StorePlugin {
|
|
69
68
|
init?(store: Store<any, any, any>): void;
|
|
@@ -85,4 +84,4 @@ declare function clearStores(): void;
|
|
|
85
84
|
/** @internal — exposes store registry for devtools */
|
|
86
85
|
declare function __getStoreInstances(): Record<string, Store<any, any, any>>;
|
|
87
86
|
|
|
88
|
-
export { type Store, type StoreDefinition, type StorePlugin, __getStoreInstances, clearStores, configureStores, defineStore };
|
|
87
|
+
export { type PersistOptions, type Store, type StoreDefinition, type StorePlugin, type StoreSyncOptions, __getStoreInstances, clearStores, configureStores, defineStore };
|
package/dist/store.d.ts
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
|
+
import { SyncTransport } from './sync.js';
|
|
1
2
|
import { S as Signal, R as ReadonlySignal } from './signals-C7XfOHHR.js';
|
|
2
3
|
|
|
3
|
-
/**
|
|
4
|
-
* Global state management via defineStore().
|
|
5
|
-
*
|
|
6
|
-
* Stores are singleton signal containers that persist across
|
|
7
|
-
* components. They provide shared state, computed getters,
|
|
8
|
-
* and actions — no external library needed.
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* const useCounterStore = defineStore('counter', {
|
|
12
|
-
* state: () => ({ count: 0, name: 'Counter' }),
|
|
13
|
-
* getters: {
|
|
14
|
-
* doubled: (state) => state.count() * 2,
|
|
15
|
-
* },
|
|
16
|
-
* actions: {
|
|
17
|
-
* increment() { this.count.update(c => c + 1); },
|
|
18
|
-
* reset() { this.count.set(0); },
|
|
19
|
-
* },
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // In any component:
|
|
23
|
-
* const store = useCounterStore();
|
|
24
|
-
* store.count(); // 0
|
|
25
|
-
* store.doubled(); // 0
|
|
26
|
-
* store.increment();
|
|
27
|
-
* store.count(); // 1
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
4
|
type StateFactory<S> = () => S;
|
|
32
5
|
type Getters<S, G> = {
|
|
33
6
|
[K in keyof G]: (state: SignalifiedState<S>) => G[K];
|
|
@@ -53,17 +26,43 @@ type Store<S, G, A> = SignalifiedState<S> & {
|
|
|
53
26
|
/** Store ID */
|
|
54
27
|
$id: string;
|
|
55
28
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
29
|
+
interface PersistOptions<S> {
|
|
30
|
+
/** Only persist these state keys (default: all) */
|
|
31
|
+
pick?: (keyof S)[];
|
|
32
|
+
/** Storage backend (default: 'localStorage') */
|
|
33
|
+
storage?: 'localStorage' | 'sessionStorage';
|
|
34
|
+
/** Custom storage key (default: 'akash-store:{storeId}') */
|
|
35
|
+
key?: string;
|
|
36
|
+
/** Custom serializer (default: JSON.stringify) */
|
|
37
|
+
serialize?: (value: unknown) => string;
|
|
38
|
+
/** Custom deserializer (default: JSON.parse) */
|
|
39
|
+
deserialize?: (value: string) => unknown;
|
|
40
|
+
}
|
|
41
|
+
interface StoreSyncOptions {
|
|
42
|
+
/** Sync transport (WebSocket, local, etc.) */
|
|
43
|
+
transport?: SyncTransport;
|
|
44
|
+
/** Enable sync — uses provided or default transport */
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
/** Sync room/channel name (default: store ID) */
|
|
47
|
+
room?: string;
|
|
48
|
+
/** Unique peer ID */
|
|
49
|
+
peerId?: string;
|
|
50
|
+
/** Enable presence tracking */
|
|
51
|
+
presence?: boolean;
|
|
52
|
+
/** Only sync these state keys (default: all) */
|
|
53
|
+
pick?: string[];
|
|
54
|
+
}
|
|
62
55
|
interface StoreDefinition<S, G, A> {
|
|
63
56
|
state: StateFactory<S>;
|
|
64
57
|
getters?: Getters<S, G>;
|
|
65
|
-
actions?:
|
|
58
|
+
actions?: A & ThisType<SignalifiedState<S> & {
|
|
59
|
+
[K in keyof G]: ReadonlySignal<G[K]>;
|
|
60
|
+
} & A>;
|
|
66
61
|
plugins?: StorePlugin[];
|
|
62
|
+
/** Auto-persist state to storage. true = persist all to localStorage. */
|
|
63
|
+
persist?: boolean | PersistOptions<S> | PersistOptions<S>[];
|
|
64
|
+
/** Sync state across peers via CRDT. Adds real-time collaboration to any store. */
|
|
65
|
+
sync?: StoreSyncOptions;
|
|
67
66
|
}
|
|
68
67
|
interface StorePlugin {
|
|
69
68
|
init?(store: Store<any, any, any>): void;
|
|
@@ -85,4 +84,4 @@ declare function clearStores(): void;
|
|
|
85
84
|
/** @internal — exposes store registry for devtools */
|
|
86
85
|
declare function __getStoreInstances(): Record<string, Store<any, any, any>>;
|
|
87
86
|
|
|
88
|
-
export { type Store, type StoreDefinition, type StorePlugin, __getStoreInstances, clearStores, configureStores, defineStore };
|
|
87
|
+
export { type PersistOptions, type Store, type StoreDefinition, type StorePlugin, type StoreSyncOptions, __getStoreInstances, clearStores, configureStores, defineStore };
|
package/dist/store.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{d as __getStoreInstances,c as clearStores,a as configureStores,b as defineStore}from'./chunk-
|
|
1
|
+
export{d as __getStoreInstances,c as clearStores,a as configureStores,b as defineStore}from'./chunk-TKFJGLUO.js';import'./chunk-H2HNKYN2.js';import'./chunk-3GRR4VW2.js';//# sourceMappingURL=store.js.map
|
|
2
2
|
//# sourceMappingURL=store.js.map
|
package/dist/sync.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunk35DJOBEO_cjs=require('./chunk-35DJOBEO.cjs');require('./chunk-EEILP4OL.cjs');Object.defineProperty(exports,"LWWRegister",{enumerable:true,get:function(){return chunk35DJOBEO_cjs.a}});Object.defineProperty(exports,"createLocalTransport",{enumerable:true,get:function(){return chunk35DJOBEO_cjs.c}});Object.defineProperty(exports,"createSync",{enumerable:true,get:function(){return chunk35DJOBEO_cjs.d}});Object.defineProperty(exports,"createWebSocketTransport",{enumerable:true,get:function(){return chunk35DJOBEO_cjs.b}});Object.defineProperty(exports,"useCursor",{enumerable:true,get:function(){return chunk35DJOBEO_cjs.e}});Object.defineProperty(exports,"useTypingIndicator",{enumerable:true,get:function(){return chunk35DJOBEO_cjs.f}});//# sourceMappingURL=sync.cjs.map
|
|
2
2
|
//# sourceMappingURL=sync.cjs.map
|
package/dist/sync.d.cts
CHANGED
|
@@ -65,8 +65,8 @@ interface SyncTransport {
|
|
|
65
65
|
onReceive(handler: (op: SyncOp) => void): () => void;
|
|
66
66
|
/** Listen for peer presence updates */
|
|
67
67
|
onPresence?(handler: (peerId: string, data: unknown) => void): () => void;
|
|
68
|
-
/** Send presence data */
|
|
69
|
-
sendPresence?(data: unknown): void;
|
|
68
|
+
/** Send presence data (peerId passed by createSync internals) */
|
|
69
|
+
sendPresence?(data: unknown, peerId?: string): void;
|
|
70
70
|
/** Connect to the sync channel */
|
|
71
71
|
connect(): void;
|
|
72
72
|
/** Disconnect */
|
|
@@ -79,11 +79,23 @@ interface WebSocketTransportOptions {
|
|
|
79
79
|
}
|
|
80
80
|
declare function createWebSocketTransport(options: WebSocketTransportOptions): SyncTransport;
|
|
81
81
|
declare function createLocalTransport(): SyncTransport;
|
|
82
|
+
interface SyncConflict {
|
|
83
|
+
key: string;
|
|
84
|
+
localValue: unknown;
|
|
85
|
+
remoteValue: unknown;
|
|
86
|
+
localTimestamp: number;
|
|
87
|
+
remoteTimestamp: number;
|
|
88
|
+
remotePeerId: string;
|
|
89
|
+
}
|
|
82
90
|
interface SyncOptions {
|
|
83
91
|
/** Transport for sending/receiving operations */
|
|
84
92
|
transport?: SyncTransport;
|
|
85
93
|
/** Unique peer ID (default: random) */
|
|
86
94
|
peerId?: string;
|
|
95
|
+
/** Initial presence data — broadcast on connect */
|
|
96
|
+
presence?: Record<string, unknown>;
|
|
97
|
+
/** Custom conflict resolver. Return the winning value, or undefined to queue for manual resolution. */
|
|
98
|
+
onConflict?: (conflict: SyncConflict) => unknown | undefined;
|
|
87
99
|
}
|
|
88
100
|
interface SyncDoc<T extends Record<string, unknown>> {
|
|
89
101
|
/** Reactive synced state — each key is a Signal */
|
|
@@ -96,6 +108,10 @@ interface SyncDoc<T extends Record<string, unknown>> {
|
|
|
96
108
|
presence: Signal<Record<string, unknown>>;
|
|
97
109
|
/** Peer presence map (reactive) */
|
|
98
110
|
peerPresence: ReadonlySignal<Map<string, unknown>>;
|
|
111
|
+
/** Unresolved conflicts (reactive) */
|
|
112
|
+
conflicts: ReadonlySignal<SyncConflict[]>;
|
|
113
|
+
/** Resolve a conflict by choosing a value for a key */
|
|
114
|
+
resolveConflict: (key: string, value: unknown) => void;
|
|
99
115
|
/** This peer's ID */
|
|
100
116
|
peerId: string;
|
|
101
117
|
/** Whether connected */
|
|
@@ -123,6 +139,45 @@ interface PeerInfo {
|
|
|
123
139
|
* doc.peers(); // connected users
|
|
124
140
|
* ```
|
|
125
141
|
*/
|
|
126
|
-
declare function createSync<T extends Record<string, unknown>>(
|
|
142
|
+
declare function createSync<T extends Record<string, unknown>>(initialState: T, options?: SyncOptions): SyncDoc<T>;
|
|
143
|
+
/**
|
|
144
|
+
* Track cursor position and broadcast via sync presence.
|
|
145
|
+
* Throttles updates to avoid flooding the transport.
|
|
146
|
+
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* const cursor = useCursor(doc, { throttle: 50 });
|
|
149
|
+
* // Automatically tracks mousemove and broadcasts { cursor: { x, y } }
|
|
150
|
+
* // Other peers: doc.peerPresence().get(peerId).cursor
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare function useCursor(doc: SyncDoc<any>, options?: {
|
|
154
|
+
throttle?: number;
|
|
155
|
+
target?: HTMLElement;
|
|
156
|
+
}): {
|
|
157
|
+
x: ReadonlySignal<number>;
|
|
158
|
+
y: ReadonlySignal<number>;
|
|
159
|
+
dispose: () => void;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Typing indicator — broadcasts typing state with auto-timeout.
|
|
163
|
+
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const typing = useTypingIndicator(doc, { timeout: 2000 });
|
|
166
|
+
* typing.start(); // broadcasts { typing: true }
|
|
167
|
+
* // Auto-stops after 2s of inactivity
|
|
168
|
+
* typing.stop(); // manual stop
|
|
169
|
+
*
|
|
170
|
+
* // Other peers typing:
|
|
171
|
+
* typing.othersTyping(); // string[] of peer IDs currently typing
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare function useTypingIndicator(doc: SyncDoc<any>, options?: {
|
|
175
|
+
timeout?: number;
|
|
176
|
+
}): {
|
|
177
|
+
isTyping: ReadonlySignal<boolean>;
|
|
178
|
+
othersTyping: ReadonlySignal<string[]>;
|
|
179
|
+
start: () => void;
|
|
180
|
+
stop: () => void;
|
|
181
|
+
};
|
|
127
182
|
|
|
128
|
-
export { type LWWEntry, LWWRegister, type PeerInfo, type SyncDoc, type SyncOp, type SyncOptions, type SyncTransport, type WebSocketTransportOptions, createLocalTransport, createSync, createWebSocketTransport };
|
|
183
|
+
export { type LWWEntry, LWWRegister, type PeerInfo, type SyncConflict, type SyncDoc, type SyncOp, type SyncOptions, type SyncTransport, type WebSocketTransportOptions, createLocalTransport, createSync, createWebSocketTransport, useCursor, useTypingIndicator };
|
package/dist/sync.d.ts
CHANGED
|
@@ -65,8 +65,8 @@ interface SyncTransport {
|
|
|
65
65
|
onReceive(handler: (op: SyncOp) => void): () => void;
|
|
66
66
|
/** Listen for peer presence updates */
|
|
67
67
|
onPresence?(handler: (peerId: string, data: unknown) => void): () => void;
|
|
68
|
-
/** Send presence data */
|
|
69
|
-
sendPresence?(data: unknown): void;
|
|
68
|
+
/** Send presence data (peerId passed by createSync internals) */
|
|
69
|
+
sendPresence?(data: unknown, peerId?: string): void;
|
|
70
70
|
/** Connect to the sync channel */
|
|
71
71
|
connect(): void;
|
|
72
72
|
/** Disconnect */
|
|
@@ -79,11 +79,23 @@ interface WebSocketTransportOptions {
|
|
|
79
79
|
}
|
|
80
80
|
declare function createWebSocketTransport(options: WebSocketTransportOptions): SyncTransport;
|
|
81
81
|
declare function createLocalTransport(): SyncTransport;
|
|
82
|
+
interface SyncConflict {
|
|
83
|
+
key: string;
|
|
84
|
+
localValue: unknown;
|
|
85
|
+
remoteValue: unknown;
|
|
86
|
+
localTimestamp: number;
|
|
87
|
+
remoteTimestamp: number;
|
|
88
|
+
remotePeerId: string;
|
|
89
|
+
}
|
|
82
90
|
interface SyncOptions {
|
|
83
91
|
/** Transport for sending/receiving operations */
|
|
84
92
|
transport?: SyncTransport;
|
|
85
93
|
/** Unique peer ID (default: random) */
|
|
86
94
|
peerId?: string;
|
|
95
|
+
/** Initial presence data — broadcast on connect */
|
|
96
|
+
presence?: Record<string, unknown>;
|
|
97
|
+
/** Custom conflict resolver. Return the winning value, or undefined to queue for manual resolution. */
|
|
98
|
+
onConflict?: (conflict: SyncConflict) => unknown | undefined;
|
|
87
99
|
}
|
|
88
100
|
interface SyncDoc<T extends Record<string, unknown>> {
|
|
89
101
|
/** Reactive synced state — each key is a Signal */
|
|
@@ -96,6 +108,10 @@ interface SyncDoc<T extends Record<string, unknown>> {
|
|
|
96
108
|
presence: Signal<Record<string, unknown>>;
|
|
97
109
|
/** Peer presence map (reactive) */
|
|
98
110
|
peerPresence: ReadonlySignal<Map<string, unknown>>;
|
|
111
|
+
/** Unresolved conflicts (reactive) */
|
|
112
|
+
conflicts: ReadonlySignal<SyncConflict[]>;
|
|
113
|
+
/** Resolve a conflict by choosing a value for a key */
|
|
114
|
+
resolveConflict: (key: string, value: unknown) => void;
|
|
99
115
|
/** This peer's ID */
|
|
100
116
|
peerId: string;
|
|
101
117
|
/** Whether connected */
|
|
@@ -123,6 +139,45 @@ interface PeerInfo {
|
|
|
123
139
|
* doc.peers(); // connected users
|
|
124
140
|
* ```
|
|
125
141
|
*/
|
|
126
|
-
declare function createSync<T extends Record<string, unknown>>(
|
|
142
|
+
declare function createSync<T extends Record<string, unknown>>(initialState: T, options?: SyncOptions): SyncDoc<T>;
|
|
143
|
+
/**
|
|
144
|
+
* Track cursor position and broadcast via sync presence.
|
|
145
|
+
* Throttles updates to avoid flooding the transport.
|
|
146
|
+
*
|
|
147
|
+
* ```ts
|
|
148
|
+
* const cursor = useCursor(doc, { throttle: 50 });
|
|
149
|
+
* // Automatically tracks mousemove and broadcasts { cursor: { x, y } }
|
|
150
|
+
* // Other peers: doc.peerPresence().get(peerId).cursor
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare function useCursor(doc: SyncDoc<any>, options?: {
|
|
154
|
+
throttle?: number;
|
|
155
|
+
target?: HTMLElement;
|
|
156
|
+
}): {
|
|
157
|
+
x: ReadonlySignal<number>;
|
|
158
|
+
y: ReadonlySignal<number>;
|
|
159
|
+
dispose: () => void;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Typing indicator — broadcasts typing state with auto-timeout.
|
|
163
|
+
*
|
|
164
|
+
* ```ts
|
|
165
|
+
* const typing = useTypingIndicator(doc, { timeout: 2000 });
|
|
166
|
+
* typing.start(); // broadcasts { typing: true }
|
|
167
|
+
* // Auto-stops after 2s of inactivity
|
|
168
|
+
* typing.stop(); // manual stop
|
|
169
|
+
*
|
|
170
|
+
* // Other peers typing:
|
|
171
|
+
* typing.othersTyping(); // string[] of peer IDs currently typing
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
declare function useTypingIndicator(doc: SyncDoc<any>, options?: {
|
|
175
|
+
timeout?: number;
|
|
176
|
+
}): {
|
|
177
|
+
isTyping: ReadonlySignal<boolean>;
|
|
178
|
+
othersTyping: ReadonlySignal<string[]>;
|
|
179
|
+
start: () => void;
|
|
180
|
+
stop: () => void;
|
|
181
|
+
};
|
|
127
182
|
|
|
128
|
-
export { type LWWEntry, LWWRegister, type PeerInfo, type SyncDoc, type SyncOp, type SyncOptions, type SyncTransport, type WebSocketTransportOptions, createLocalTransport, createSync, createWebSocketTransport };
|
|
183
|
+
export { type LWWEntry, LWWRegister, type PeerInfo, type SyncConflict, type SyncDoc, type SyncOp, type SyncOptions, type SyncTransport, type WebSocketTransportOptions, createLocalTransport, createSync, createWebSocketTransport, useCursor, useTypingIndicator };
|
package/dist/sync.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as LWWRegister,c as createLocalTransport,d as createSync,b as createWebSocketTransport}from'./chunk-
|
|
1
|
+
export{a as LWWRegister,c as createLocalTransport,d as createSync,b as createWebSocketTransport,e as useCursor,f as useTypingIndicator}from'./chunk-H2HNKYN2.js';import'./chunk-3GRR4VW2.js';//# sourceMappingURL=sync.js.map
|
|
2
2
|
//# sourceMappingURL=sync.js.map
|
package/dist/test.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var
|
|
2
|
-
Container HTML: ${
|
|
3
|
-
Container HTML: ${
|
|
4
|
-
Container HTML: ${
|
|
1
|
+
'use strict';var chunk6GGYM5SF_cjs=require('./chunk-6GGYM5SF.cjs'),chunkAVVJKYT3_cjs=require('./chunk-AVVJKYT3.cjs');require('./chunk-35DJOBEO.cjs');var chunkEEILP4OL_cjs=require('./chunk-EEILP4OL.cjs');function A(e,n){let t=document.createElement("div");t.setAttribute("data-akash-test-root","");let r=n?.props??{},o=n?.provide,i;return o&&o.size>0?i=chunk6GGYM5SF_cjs.B(()=>{for(let[a,u]of o)chunk6GGYM5SF_cjs.h(a,u);return ()=>e(r)})({}):i=e(r),t.appendChild(i),document.body.appendChild(t),f.push(t),{container:t,unmount(){t.remove();},getByText(s){let a=k(t,s);if(!a)throw new Error(`[AkashJS Test] Could not find element with text: "${s}"
|
|
2
|
+
Container HTML: ${t.innerHTML.slice(0,200)}`);return a},getByRole(s){let a=t.querySelector(`[role="${s}"]`)??x(t,s);if(!a)throw new Error(`[AkashJS Test] Could not find element with role: "${s}"
|
|
3
|
+
Container HTML: ${t.innerHTML.slice(0,200)}`);return a},getByTestId(s){let a=t.querySelector(`[data-testid="${s}"]`);if(!a)throw new Error(`[AkashJS Test] Could not find element with data-testid: "${s}"
|
|
4
|
+
Container HTML: ${t.innerHTML.slice(0,200)}`);return a},queryAll(s){return Array.from(t.querySelectorAll(s))},query(s){return t.querySelector(s)}}}var O={async click(e){e.dispatchEvent(new MouseEvent("click",{bubbles:true,cancelable:true})),await c();},async input(e,n){let t=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;t?t.call(e,n):e.value=n,e.dispatchEvent(new Event("input",{bubbles:true})),e.dispatchEvent(new Event("change",{bubbles:true})),await c();},async submit(e){e.dispatchEvent(new Event("submit",{bubbles:true,cancelable:true})),await c();},async focus(e){e.focus(),e.dispatchEvent(new FocusEvent("focus",{bubbles:true})),await c();},async blur(e){e.blur(),e.dispatchEvent(new FocusEvent("blur",{bubbles:true})),await c();},async keyDown(e,n,t){e.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:true,...t})),await c();},async keyUp(e,n,t){e.dispatchEvent(new KeyboardEvent("keyup",{key:n,bubbles:true,...t})),await c();}};function c(){return new Promise(e=>queueMicrotask(e))}function k(e,n){let t=null,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT),o=r.nextNode();for(;o;)o instanceof HTMLElement&&o.textContent?.includes(n)&&(t=o),o=r.nextNode();return !t&&e.textContent?.includes(n)&&(t=e),t}var H={button:["button"],a:["link"],input:["textbox","checkbox","radio","spinbutton","slider"],select:["combobox","listbox"],textarea:["textbox"],img:["img"],form:["form"],nav:["navigation"],main:["main"],header:["banner"],footer:["contentinfo"],aside:["complementary"],section:["region"],article:["article"],ul:["list"],ol:["list"],li:["listitem"],table:["table"],th:["columnheader"],td:["cell"],h1:["heading"],h2:["heading"],h3:["heading"],h4:["heading"],h5:["heading"],h6:["heading"]};function x(e,n){let t=[];for(let[o,i]of Object.entries(H))i.includes(n)&&t.push(o);if(t.length===0)return null;let r=t.join(", ");return e.querySelector(r)}async function S(e,n){let{timeout:t=1e3,interval:r=50}=n??{},o=Date.now();for(;;)try{await e();return}catch(i){if(Date.now()-o>=t)throw i;await new Promise(s=>setTimeout(s,r));}}async function q(e,n,t){let r=null;return await S(()=>{if(r=e.querySelector(n),!r)throw new Error(`Element "${n}" not found`)},t),r}function N(e){let n=chunkEEILP4OL_cjs.l(e),t=[e],r=0,o=(()=>n());return o.set=i=>{n.set(i),t.push(i),r++;},o.update=i=>{let s=i(n.peek());o.set(s);},o.peek=()=>n.peek(),Object.defineProperty(o,"history",{get:()=>[...t]}),Object.defineProperty(o,"setCount",{get:()=>r}),o.resetHistory=()=>{t.length=0,t.push(n.peek()),r=0;},o}var f=[];function j(){for(let e of f)e.remove();f.length=0,chunkAVVJKYT3_cjs.c();}function D(e){chunkAVVJKYT3_cjs.c();let n=e();return chunkAVVJKYT3_cjs.c(),n}function B(e={},n=200){let t=[],r=async(o,i)=>{let s=typeof o=="string"?o:o instanceof URL?o.toString():o.url,a=i?.method??"GET",u;if(i?.body)try{u=JSON.parse(String(i.body));}catch{u=i.body;}let y={};i?.headers&&new Headers(i.headers).forEach((p,v)=>{y[v]=p;}),t.push({url:s,method:a,body:u,headers:y});let M=s.replace(/^https?:\/\/[^/]+/,"").split("?")[0],h=e[M]??e[s];if(h===void 0)return new Response("Not Found",{status:404});let d=n,l=h;if(l&&typeof l=="object"&&!Array.isArray(l)&&"_status"in l){let{_status:g,...p}=l;d=Number(g),l=p;}let T=d===204||d===304;return new Response(T?null:JSON.stringify(l),{status:d,headers:T?{}:{"Content-Type":"application/json"}})};return r.calls=()=>[...t],r.callCount=()=>t.length,r.reset=()=>{t.length=0;},r}function _(){let e=new Map;return {invalidate:()=>{},setQueryData:()=>{},getQueryData:()=>{},removeQuery:n=>{e.delete(JSON.stringify(n));},clear:()=>{e.clear();},_cache:e,_options:{defaultStaleTime:0}}}Object.defineProperty(exports,"flush",{enumerable:true,get:function(){return chunkEEILP4OL_cjs.b}});exports.cleanup=j;exports.createTestSignal=N;exports.createTestStore=D;exports.fireEvent=O;exports.mockFetch=B;exports.mockQueryClient=_;exports.mount=A;exports.waitFor=S;exports.waitForElement=q;//# sourceMappingURL=test.cjs.map
|
|
5
5
|
//# sourceMappingURL=test.cjs.map
|