@akashjs/runtime 0.2.0 → 0.2.1

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.
Files changed (84) hide show
  1. package/dist/animate.d.cts +145 -0
  2. package/dist/animate.d.ts +145 -0
  3. package/dist/{chunk-V7VG23IO.cjs → chunk-3AL2DVPZ.cjs} +3 -3
  4. package/dist/{chunk-V7VG23IO.cjs.map → chunk-3AL2DVPZ.cjs.map} +1 -1
  5. package/dist/{chunk-CHF5LH56.cjs → chunk-6NX6JRSV.cjs} +3 -3
  6. package/dist/{chunk-CHF5LH56.cjs.map → chunk-6NX6JRSV.cjs.map} +1 -1
  7. package/dist/chunk-772SU4MG.js +2 -0
  8. package/dist/chunk-772SU4MG.js.map +1 -0
  9. package/dist/chunk-7LQZF3XA.cjs +2 -0
  10. package/dist/chunk-7LQZF3XA.cjs.map +1 -0
  11. package/dist/{chunk-DYJUCZXA.js → chunk-BT6HNBE7.js} +4 -4
  12. package/dist/chunk-BT6HNBE7.js.map +1 -0
  13. package/dist/{chunk-CGKMCVEZ.js → chunk-D6QQYZIC.js} +2 -2
  14. package/dist/{chunk-CGKMCVEZ.js.map → chunk-D6QQYZIC.js.map} +1 -1
  15. package/dist/{chunk-R3W5W647.cjs → chunk-H4SAK7A5.cjs} +2 -2
  16. package/dist/{chunk-R3W5W647.cjs.map → chunk-H4SAK7A5.cjs.map} +1 -1
  17. package/dist/{chunk-VFOAULHK.js → chunk-IM2VW4TK.js} +3 -3
  18. package/dist/{chunk-VFOAULHK.js.map → chunk-IM2VW4TK.js.map} +1 -1
  19. package/dist/chunk-NQVWTQ2I.cjs +5 -0
  20. package/dist/chunk-NQVWTQ2I.cjs.map +1 -0
  21. package/dist/{chunk-5EFX654I.cjs → chunk-NVZLEJXB.cjs} +2 -2
  22. package/dist/{chunk-5EFX654I.cjs.map → chunk-NVZLEJXB.cjs.map} +1 -1
  23. package/dist/{chunk-DPJ6RJ7A.js → chunk-ODDXU5DO.js} +2 -2
  24. package/dist/chunk-ODDXU5DO.js.map +1 -0
  25. package/dist/{chunk-EUKRTV4W.js → chunk-POLTPHUA.js} +3 -3
  26. package/dist/{chunk-EUKRTV4W.js.map → chunk-POLTPHUA.js.map} +1 -1
  27. package/dist/{chunk-4HAE7H7W.cjs → chunk-YIB4EKVI.cjs} +2 -2
  28. package/dist/chunk-YIB4EKVI.cjs.map +1 -0
  29. package/dist/{chunk-SRPWGLOQ.js → chunk-Z5LQV5ND.js} +2 -2
  30. package/dist/{chunk-SRPWGLOQ.js.map → chunk-Z5LQV5ND.js.map} +1 -1
  31. package/dist/component-C1WnFcRp.d.cts +59 -0
  32. package/dist/component-C1WnFcRp.d.ts +59 -0
  33. package/dist/context-2uQ6fuxu.d.cts +57 -0
  34. package/dist/context-2uQ6fuxu.d.ts +57 -0
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.d.cts +65 -0
  37. package/dist/core.d.ts +65 -0
  38. package/dist/core.js +1 -1
  39. package/dist/index.cjs +8 -8
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +3218 -0
  42. package/dist/index.d.ts +3218 -0
  43. package/dist/index.js +8 -8
  44. package/dist/index.js.map +1 -1
  45. package/dist/machine.cjs +1 -1
  46. package/dist/machine.d.cts +87 -0
  47. package/dist/machine.d.ts +87 -0
  48. package/dist/machine.js +1 -1
  49. package/dist/offline.cjs +1 -1
  50. package/dist/offline.d.cts +73 -0
  51. package/dist/offline.d.ts +73 -0
  52. package/dist/offline.js +1 -1
  53. package/dist/pwa.cjs +1 -1
  54. package/dist/pwa.d.cts +80 -0
  55. package/dist/pwa.d.ts +80 -0
  56. package/dist/pwa.js +1 -1
  57. package/dist/signals-C7XfOHHR.d.cts +55 -0
  58. package/dist/signals-C7XfOHHR.d.ts +55 -0
  59. package/dist/ssr.cjs +1 -1
  60. package/dist/ssr.d.cts +78 -0
  61. package/dist/ssr.d.ts +78 -0
  62. package/dist/ssr.js +1 -1
  63. package/dist/store.cjs +1 -1
  64. package/dist/store.d.cts +88 -0
  65. package/dist/store.d.ts +88 -0
  66. package/dist/store.js +1 -1
  67. package/dist/sync.cjs +1 -1
  68. package/dist/sync.d.cts +128 -0
  69. package/dist/sync.d.ts +128 -0
  70. package/dist/sync.js +1 -1
  71. package/dist/test.cjs +2 -2
  72. package/dist/test.d.cts +109 -0
  73. package/dist/test.d.ts +109 -0
  74. package/dist/test.js +1 -1
  75. package/package.json +1 -1
  76. package/dist/chunk-4HAE7H7W.cjs.map +0 -1
  77. package/dist/chunk-DPJ6RJ7A.js.map +0 -1
  78. package/dist/chunk-DYJUCZXA.js.map +0 -1
  79. package/dist/chunk-P5GADKQS.cjs +0 -2
  80. package/dist/chunk-P5GADKQS.cjs.map +0 -1
  81. package/dist/chunk-Q5BER4ZB.js +0 -2
  82. package/dist/chunk-Q5BER4ZB.js.map +0 -1
  83. package/dist/chunk-QDCIW4YE.cjs +0 -5
  84. package/dist/chunk-QDCIW4YE.cjs.map +0 -1
package/dist/ssr.d.cts ADDED
@@ -0,0 +1,78 @@
1
+ import { C as Component } from './component-C1WnFcRp.cjs';
2
+
3
+ /**
4
+ * Server-Side Rendering.
5
+ *
6
+ * Renders components to HTML strings (or streams) on the server.
7
+ * No DOM APIs are used — everything is string concatenation.
8
+ *
9
+ * - Effects do NOT run on the server (they are DOM-side only)
10
+ * - Signals and computeds work synchronously
11
+ * - Components run their setup + initial render, producing HTML
12
+ */
13
+
14
+ declare function escapeHtml(str: string): string;
15
+ /** Check if we're currently in an SSR render */
16
+ declare function isServerRendering(): boolean;
17
+ /**
18
+ * Render a component to an HTML string on the server.
19
+ *
20
+ * ```ts
21
+ * import { renderToString } from '@akashjs/runtime/ssr';
22
+ * const html = await renderToString(App, { title: 'Home' });
23
+ * ```
24
+ */
25
+ declare function renderToString<P extends Record<string, unknown>>(component: Component<P>, props?: P): Promise<string>;
26
+ /**
27
+ * Synchronous version of renderToString.
28
+ */
29
+ declare function renderToStringSync<P extends Record<string, unknown>>(component: Component<P>, props?: P): string;
30
+ /**
31
+ * Render a component to a ReadableStream of HTML chunks.
32
+ *
33
+ * Useful for streaming SSR — flush HTML as data becomes available.
34
+ *
35
+ * ```ts
36
+ * const stream = renderToStream(App, { title: 'Home' });
37
+ * // Pipe to HTTP response
38
+ * ```
39
+ */
40
+ declare function renderToStream<P extends Record<string, unknown>>(component: Component<P>, props?: P): ReadableStream<string>;
41
+ interface SSRElement {
42
+ type: 'element';
43
+ tag: string;
44
+ attrs: Record<string, string>;
45
+ children: SSRNode[];
46
+ selfClosing?: boolean;
47
+ }
48
+ interface SSRText {
49
+ type: 'text';
50
+ content: string;
51
+ }
52
+ interface SSRRaw {
53
+ type: 'raw';
54
+ html: string;
55
+ }
56
+ type SSRNode = SSRElement | SSRText | SSRRaw;
57
+ /**
58
+ * Create an SSR element (replaces document.createElement on the server).
59
+ */
60
+ declare function ssrElement(tag: string, attrs?: Record<string, string | boolean>, ...rest: (SSRNode | SSRNode[])[]): SSRElement;
61
+ /**
62
+ * Create an SSR text node.
63
+ */
64
+ declare function ssrText(content: string): SSRText;
65
+ /**
66
+ * Create a raw HTML SSR node (no escaping).
67
+ */
68
+ declare function ssrRaw(html: string): SSRRaw;
69
+ /**
70
+ * Serialize an SSR node tree to an HTML string.
71
+ */
72
+ declare function nodeToHtml(node: SSRNode): string;
73
+ /**
74
+ * Render a tree of SSR nodes (convenience for arrays).
75
+ */
76
+ declare function renderNodes(nodes: SSRNode[]): string;
77
+
78
+ export { type SSRElement, type SSRNode, type SSRRaw, type SSRText, escapeHtml, isServerRendering, nodeToHtml, renderNodes, renderToStream, renderToString, renderToStringSync, ssrElement, ssrRaw, ssrText };
package/dist/ssr.d.ts ADDED
@@ -0,0 +1,78 @@
1
+ import { C as Component } from './component-C1WnFcRp.js';
2
+
3
+ /**
4
+ * Server-Side Rendering.
5
+ *
6
+ * Renders components to HTML strings (or streams) on the server.
7
+ * No DOM APIs are used — everything is string concatenation.
8
+ *
9
+ * - Effects do NOT run on the server (they are DOM-side only)
10
+ * - Signals and computeds work synchronously
11
+ * - Components run their setup + initial render, producing HTML
12
+ */
13
+
14
+ declare function escapeHtml(str: string): string;
15
+ /** Check if we're currently in an SSR render */
16
+ declare function isServerRendering(): boolean;
17
+ /**
18
+ * Render a component to an HTML string on the server.
19
+ *
20
+ * ```ts
21
+ * import { renderToString } from '@akashjs/runtime/ssr';
22
+ * const html = await renderToString(App, { title: 'Home' });
23
+ * ```
24
+ */
25
+ declare function renderToString<P extends Record<string, unknown>>(component: Component<P>, props?: P): Promise<string>;
26
+ /**
27
+ * Synchronous version of renderToString.
28
+ */
29
+ declare function renderToStringSync<P extends Record<string, unknown>>(component: Component<P>, props?: P): string;
30
+ /**
31
+ * Render a component to a ReadableStream of HTML chunks.
32
+ *
33
+ * Useful for streaming SSR — flush HTML as data becomes available.
34
+ *
35
+ * ```ts
36
+ * const stream = renderToStream(App, { title: 'Home' });
37
+ * // Pipe to HTTP response
38
+ * ```
39
+ */
40
+ declare function renderToStream<P extends Record<string, unknown>>(component: Component<P>, props?: P): ReadableStream<string>;
41
+ interface SSRElement {
42
+ type: 'element';
43
+ tag: string;
44
+ attrs: Record<string, string>;
45
+ children: SSRNode[];
46
+ selfClosing?: boolean;
47
+ }
48
+ interface SSRText {
49
+ type: 'text';
50
+ content: string;
51
+ }
52
+ interface SSRRaw {
53
+ type: 'raw';
54
+ html: string;
55
+ }
56
+ type SSRNode = SSRElement | SSRText | SSRRaw;
57
+ /**
58
+ * Create an SSR element (replaces document.createElement on the server).
59
+ */
60
+ declare function ssrElement(tag: string, attrs?: Record<string, string | boolean>, ...rest: (SSRNode | SSRNode[])[]): SSRElement;
61
+ /**
62
+ * Create an SSR text node.
63
+ */
64
+ declare function ssrText(content: string): SSRText;
65
+ /**
66
+ * Create a raw HTML SSR node (no escaping).
67
+ */
68
+ declare function ssrRaw(html: string): SSRRaw;
69
+ /**
70
+ * Serialize an SSR node tree to an HTML string.
71
+ */
72
+ declare function nodeToHtml(node: SSRNode): string;
73
+ /**
74
+ * Render a tree of SSR nodes (convenience for arrays).
75
+ */
76
+ declare function renderNodes(nodes: SSRNode[]): string;
77
+
78
+ export { type SSRElement, type SSRNode, type SSRRaw, type SSRText, escapeHtml, isServerRendering, nodeToHtml, renderNodes, renderToStream, renderToString, renderToStringSync, ssrElement, ssrRaw, ssrText };
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-EUKRTV4W.js';//# sourceMappingURL=ssr.js.map
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-POLTPHUA.js';//# sourceMappingURL=ssr.js.map
2
2
  //# sourceMappingURL=ssr.js.map
package/dist/store.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkP5GADKQS_cjs=require('./chunk-P5GADKQS.cjs');require('./chunk-V7VG23IO.cjs');Object.defineProperty(exports,"__getStoreInstances",{enumerable:true,get:function(){return chunkP5GADKQS_cjs.d}});Object.defineProperty(exports,"clearStores",{enumerable:true,get:function(){return chunkP5GADKQS_cjs.c}});Object.defineProperty(exports,"configureStores",{enumerable:true,get:function(){return chunkP5GADKQS_cjs.a}});Object.defineProperty(exports,"defineStore",{enumerable:true,get:function(){return chunkP5GADKQS_cjs.b}});//# sourceMappingURL=store.cjs.map
1
+ 'use strict';var chunk7LQZF3XA_cjs=require('./chunk-7LQZF3XA.cjs');require('./chunk-3AL2DVPZ.cjs');Object.defineProperty(exports,"__getStoreInstances",{enumerable:true,get:function(){return chunk7LQZF3XA_cjs.d}});Object.defineProperty(exports,"clearStores",{enumerable:true,get:function(){return chunk7LQZF3XA_cjs.c}});Object.defineProperty(exports,"configureStores",{enumerable:true,get:function(){return chunk7LQZF3XA_cjs.a}});Object.defineProperty(exports,"defineStore",{enumerable:true,get:function(){return chunk7LQZF3XA_cjs.b}});//# sourceMappingURL=store.cjs.map
2
2
  //# sourceMappingURL=store.cjs.map
@@ -0,0 +1,88 @@
1
+ import { S as Signal, R as ReadonlySignal } from './signals-C7XfOHHR.cjs';
2
+
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
+ type StateFactory<S> = () => S;
32
+ type Getters<S, G> = {
33
+ [K in keyof G]: (state: SignalifiedState<S>) => G[K];
34
+ };
35
+ /** Maps plain state values to signals */
36
+ type SignalifiedState<S> = {
37
+ [K in keyof S]: Signal<S[K]>;
38
+ };
39
+ /** The store instance returned to consumers */
40
+ type Store<S, G, A> = SignalifiedState<S> & {
41
+ [K in keyof G]: ReadonlySignal<G[K]>;
42
+ } & {
43
+ [K in keyof A]: A[K] extends (...args: infer P) => infer R ? (...args: P) => R : never;
44
+ } & {
45
+ /** Reset all state to initial values */
46
+ $reset(): void;
47
+ /** Merge partial state into the store, or apply changes via callback */
48
+ $patch(partialOrFn: Partial<S> | ((state: SignalifiedState<S>) => void)): void;
49
+ /** Subscribe to all state changes */
50
+ $subscribe(callback: (state: S) => void): () => void;
51
+ /** Get a plain snapshot of current state */
52
+ $snapshot(): S;
53
+ /** Store ID */
54
+ $id: string;
55
+ };
56
+ /** Actions with `this` typed to include state signals, getters, and other actions */
57
+ type StoreActions<S, G, A> = {
58
+ [K in keyof A]: A[K] extends (...args: infer P) => infer R ? (this: SignalifiedState<S> & {
59
+ [GK in keyof G]: ReadonlySignal<G[GK]>;
60
+ } & A, ...args: P) => R : never;
61
+ };
62
+ interface StoreDefinition<S, G, A> {
63
+ state: StateFactory<S>;
64
+ getters?: Getters<S, G>;
65
+ actions?: StoreActions<S, G, A>;
66
+ plugins?: StorePlugin[];
67
+ }
68
+ interface StorePlugin {
69
+ init?(store: Store<any, any, any>): void;
70
+ onAction?(store: Store<any, any, any>, actionName: string, args: unknown[]): void;
71
+ }
72
+ /** Register global plugins that apply to all stores */
73
+ declare function configureStores(options: {
74
+ plugins: StorePlugin[];
75
+ }): void;
76
+ /**
77
+ * Define a global store. Returns a composable function that
78
+ * always returns the same store instance (singleton).
79
+ */
80
+ declare function defineStore<S extends Record<string, unknown>, G extends Record<string, unknown> = {}, A extends Record<string, (...args: any[]) => any> = {}>(id: string, definition: StoreDefinition<S, G, A>): () => Store<S, G, A>;
81
+ /**
82
+ * Clear all store instances (useful for testing).
83
+ */
84
+ declare function clearStores(): void;
85
+ /** @internal — exposes store registry for devtools */
86
+ declare function __getStoreInstances(): Record<string, Store<any, any, any>>;
87
+
88
+ export { type Store, type StoreDefinition, type StorePlugin, __getStoreInstances, clearStores, configureStores, defineStore };
@@ -0,0 +1,88 @@
1
+ import { S as Signal, R as ReadonlySignal } from './signals-C7XfOHHR.js';
2
+
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
+ type StateFactory<S> = () => S;
32
+ type Getters<S, G> = {
33
+ [K in keyof G]: (state: SignalifiedState<S>) => G[K];
34
+ };
35
+ /** Maps plain state values to signals */
36
+ type SignalifiedState<S> = {
37
+ [K in keyof S]: Signal<S[K]>;
38
+ };
39
+ /** The store instance returned to consumers */
40
+ type Store<S, G, A> = SignalifiedState<S> & {
41
+ [K in keyof G]: ReadonlySignal<G[K]>;
42
+ } & {
43
+ [K in keyof A]: A[K] extends (...args: infer P) => infer R ? (...args: P) => R : never;
44
+ } & {
45
+ /** Reset all state to initial values */
46
+ $reset(): void;
47
+ /** Merge partial state into the store, or apply changes via callback */
48
+ $patch(partialOrFn: Partial<S> | ((state: SignalifiedState<S>) => void)): void;
49
+ /** Subscribe to all state changes */
50
+ $subscribe(callback: (state: S) => void): () => void;
51
+ /** Get a plain snapshot of current state */
52
+ $snapshot(): S;
53
+ /** Store ID */
54
+ $id: string;
55
+ };
56
+ /** Actions with `this` typed to include state signals, getters, and other actions */
57
+ type StoreActions<S, G, A> = {
58
+ [K in keyof A]: A[K] extends (...args: infer P) => infer R ? (this: SignalifiedState<S> & {
59
+ [GK in keyof G]: ReadonlySignal<G[GK]>;
60
+ } & A, ...args: P) => R : never;
61
+ };
62
+ interface StoreDefinition<S, G, A> {
63
+ state: StateFactory<S>;
64
+ getters?: Getters<S, G>;
65
+ actions?: StoreActions<S, G, A>;
66
+ plugins?: StorePlugin[];
67
+ }
68
+ interface StorePlugin {
69
+ init?(store: Store<any, any, any>): void;
70
+ onAction?(store: Store<any, any, any>, actionName: string, args: unknown[]): void;
71
+ }
72
+ /** Register global plugins that apply to all stores */
73
+ declare function configureStores(options: {
74
+ plugins: StorePlugin[];
75
+ }): void;
76
+ /**
77
+ * Define a global store. Returns a composable function that
78
+ * always returns the same store instance (singleton).
79
+ */
80
+ declare function defineStore<S extends Record<string, unknown>, G extends Record<string, unknown> = {}, A extends Record<string, (...args: any[]) => any> = {}>(id: string, definition: StoreDefinition<S, G, A>): () => Store<S, G, A>;
81
+ /**
82
+ * Clear all store instances (useful for testing).
83
+ */
84
+ declare function clearStores(): void;
85
+ /** @internal — exposes store registry for devtools */
86
+ declare function __getStoreInstances(): Record<string, Store<any, any, any>>;
87
+
88
+ export { type Store, type StoreDefinition, type StorePlugin, __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-Q5BER4ZB.js';import'./chunk-EUKRTV4W.js';//# sourceMappingURL=store.js.map
1
+ export{d as __getStoreInstances,c as clearStores,a as configureStores,b as defineStore}from'./chunk-772SU4MG.js';import'./chunk-POLTPHUA.js';//# sourceMappingURL=store.js.map
2
2
  //# sourceMappingURL=store.js.map
package/dist/sync.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk4HAE7H7W_cjs=require('./chunk-4HAE7H7W.cjs');require('./chunk-V7VG23IO.cjs');Object.defineProperty(exports,"LWWRegister",{enumerable:true,get:function(){return chunk4HAE7H7W_cjs.a}});Object.defineProperty(exports,"createLocalTransport",{enumerable:true,get:function(){return chunk4HAE7H7W_cjs.c}});Object.defineProperty(exports,"createSync",{enumerable:true,get:function(){return chunk4HAE7H7W_cjs.d}});Object.defineProperty(exports,"createWebSocketTransport",{enumerable:true,get:function(){return chunk4HAE7H7W_cjs.b}});//# sourceMappingURL=sync.cjs.map
1
+ 'use strict';var chunkYIB4EKVI_cjs=require('./chunk-YIB4EKVI.cjs');require('./chunk-3AL2DVPZ.cjs');Object.defineProperty(exports,"LWWRegister",{enumerable:true,get:function(){return chunkYIB4EKVI_cjs.a}});Object.defineProperty(exports,"createLocalTransport",{enumerable:true,get:function(){return chunkYIB4EKVI_cjs.c}});Object.defineProperty(exports,"createSync",{enumerable:true,get:function(){return chunkYIB4EKVI_cjs.d}});Object.defineProperty(exports,"createWebSocketTransport",{enumerable:true,get:function(){return chunkYIB4EKVI_cjs.b}});//# sourceMappingURL=sync.cjs.map
2
2
  //# sourceMappingURL=sync.cjs.map
@@ -0,0 +1,128 @@
1
+ import { S as Signal, R as ReadonlySignal } from './signals-C7XfOHHR.cjs';
2
+
3
+ /**
4
+ * Collaborative signals with CRDT.
5
+ *
6
+ * Make any signal multiplayer with one line. Multiple users can
7
+ * edit the same state simultaneously with automatic conflict
8
+ * resolution via Last-Writer-Wins Register and Operation-based CRDTs.
9
+ *
10
+ * ```ts
11
+ * const doc = createSync('doc-123', {
12
+ * title: '',
13
+ * blocks: [],
14
+ * cursor: { x: 0, y: 0 },
15
+ * });
16
+ *
17
+ * doc.state.title.set('Hello'); // syncs to all peers
18
+ * doc.peers(); // list of connected users
19
+ * doc.presence.set({ cursor: { x: 10, y: 20 } });
20
+ * ```
21
+ */
22
+
23
+ interface LWWEntry<T> {
24
+ value: T;
25
+ timestamp: number;
26
+ peerId: string;
27
+ }
28
+ /**
29
+ * Last-Writer-Wins Register — simplest CRDT for single values.
30
+ * The write with the highest timestamp wins on conflict.
31
+ */
32
+ declare class LWWRegister<T> {
33
+ private entry;
34
+ constructor(initialValue: T, peerId: string);
35
+ get value(): T;
36
+ get timestamp(): number;
37
+ set(value: T, peerId: string): boolean;
38
+ merge(remote: LWWEntry<T>): boolean;
39
+ toEntry(): LWWEntry<T>;
40
+ }
41
+ type SyncOp = {
42
+ type: 'set';
43
+ key: string;
44
+ value: unknown;
45
+ timestamp: number;
46
+ peerId: string;
47
+ } | {
48
+ type: 'insert';
49
+ key: string;
50
+ index: number;
51
+ value: unknown;
52
+ timestamp: number;
53
+ peerId: string;
54
+ } | {
55
+ type: 'delete';
56
+ key: string;
57
+ index: number;
58
+ timestamp: number;
59
+ peerId: string;
60
+ };
61
+ interface SyncTransport {
62
+ /** Send an operation to peers */
63
+ send(op: SyncOp): void;
64
+ /** Listen for operations from peers */
65
+ onReceive(handler: (op: SyncOp) => void): () => void;
66
+ /** Listen for peer presence updates */
67
+ onPresence?(handler: (peerId: string, data: unknown) => void): () => void;
68
+ /** Send presence data */
69
+ sendPresence?(data: unknown): void;
70
+ /** Connect to the sync channel */
71
+ connect(): void;
72
+ /** Disconnect */
73
+ disconnect(): void;
74
+ }
75
+ interface WebSocketTransportOptions {
76
+ url: string;
77
+ room: string;
78
+ protocols?: string | string[];
79
+ }
80
+ declare function createWebSocketTransport(options: WebSocketTransportOptions): SyncTransport;
81
+ declare function createLocalTransport(): SyncTransport;
82
+ interface SyncOptions {
83
+ /** Transport for sending/receiving operations */
84
+ transport?: SyncTransport;
85
+ /** Unique peer ID (default: random) */
86
+ peerId?: string;
87
+ }
88
+ interface SyncDoc<T extends Record<string, unknown>> {
89
+ /** Reactive synced state — each key is a Signal */
90
+ state: {
91
+ [K in keyof T]: Signal<T[K]>;
92
+ };
93
+ /** Connected peers (reactive) */
94
+ peers: ReadonlySignal<PeerInfo[]>;
95
+ /** Local presence data */
96
+ presence: Signal<Record<string, unknown>>;
97
+ /** Peer presence map (reactive) */
98
+ peerPresence: ReadonlySignal<Map<string, unknown>>;
99
+ /** This peer's ID */
100
+ peerId: string;
101
+ /** Whether connected */
102
+ connected: ReadonlySignal<boolean>;
103
+ /** Connect to the sync channel */
104
+ connect(): void;
105
+ /** Disconnect */
106
+ disconnect(): void;
107
+ /** Dispose the sync doc */
108
+ dispose(): void;
109
+ }
110
+ interface PeerInfo {
111
+ id: string;
112
+ joinedAt: number;
113
+ }
114
+ /**
115
+ * Create a collaborative synced document.
116
+ *
117
+ * ```ts
118
+ * const doc = createSync('room-1', { title: '', count: 0 }, {
119
+ * transport: createWebSocketTransport({ url: 'wss://sync.example.com', room: 'room-1' }),
120
+ * });
121
+ *
122
+ * doc.state.title.set('Hello'); // auto-syncs to all peers
123
+ * doc.peers(); // connected users
124
+ * ```
125
+ */
126
+ declare function createSync<T extends Record<string, unknown>>(roomId: string, initialState: T, options?: SyncOptions): SyncDoc<T>;
127
+
128
+ export { type LWWEntry, LWWRegister, type PeerInfo, type SyncDoc, type SyncOp, type SyncOptions, type SyncTransport, type WebSocketTransportOptions, createLocalTransport, createSync, createWebSocketTransport };
package/dist/sync.d.ts ADDED
@@ -0,0 +1,128 @@
1
+ import { S as Signal, R as ReadonlySignal } from './signals-C7XfOHHR.js';
2
+
3
+ /**
4
+ * Collaborative signals with CRDT.
5
+ *
6
+ * Make any signal multiplayer with one line. Multiple users can
7
+ * edit the same state simultaneously with automatic conflict
8
+ * resolution via Last-Writer-Wins Register and Operation-based CRDTs.
9
+ *
10
+ * ```ts
11
+ * const doc = createSync('doc-123', {
12
+ * title: '',
13
+ * blocks: [],
14
+ * cursor: { x: 0, y: 0 },
15
+ * });
16
+ *
17
+ * doc.state.title.set('Hello'); // syncs to all peers
18
+ * doc.peers(); // list of connected users
19
+ * doc.presence.set({ cursor: { x: 10, y: 20 } });
20
+ * ```
21
+ */
22
+
23
+ interface LWWEntry<T> {
24
+ value: T;
25
+ timestamp: number;
26
+ peerId: string;
27
+ }
28
+ /**
29
+ * Last-Writer-Wins Register — simplest CRDT for single values.
30
+ * The write with the highest timestamp wins on conflict.
31
+ */
32
+ declare class LWWRegister<T> {
33
+ private entry;
34
+ constructor(initialValue: T, peerId: string);
35
+ get value(): T;
36
+ get timestamp(): number;
37
+ set(value: T, peerId: string): boolean;
38
+ merge(remote: LWWEntry<T>): boolean;
39
+ toEntry(): LWWEntry<T>;
40
+ }
41
+ type SyncOp = {
42
+ type: 'set';
43
+ key: string;
44
+ value: unknown;
45
+ timestamp: number;
46
+ peerId: string;
47
+ } | {
48
+ type: 'insert';
49
+ key: string;
50
+ index: number;
51
+ value: unknown;
52
+ timestamp: number;
53
+ peerId: string;
54
+ } | {
55
+ type: 'delete';
56
+ key: string;
57
+ index: number;
58
+ timestamp: number;
59
+ peerId: string;
60
+ };
61
+ interface SyncTransport {
62
+ /** Send an operation to peers */
63
+ send(op: SyncOp): void;
64
+ /** Listen for operations from peers */
65
+ onReceive(handler: (op: SyncOp) => void): () => void;
66
+ /** Listen for peer presence updates */
67
+ onPresence?(handler: (peerId: string, data: unknown) => void): () => void;
68
+ /** Send presence data */
69
+ sendPresence?(data: unknown): void;
70
+ /** Connect to the sync channel */
71
+ connect(): void;
72
+ /** Disconnect */
73
+ disconnect(): void;
74
+ }
75
+ interface WebSocketTransportOptions {
76
+ url: string;
77
+ room: string;
78
+ protocols?: string | string[];
79
+ }
80
+ declare function createWebSocketTransport(options: WebSocketTransportOptions): SyncTransport;
81
+ declare function createLocalTransport(): SyncTransport;
82
+ interface SyncOptions {
83
+ /** Transport for sending/receiving operations */
84
+ transport?: SyncTransport;
85
+ /** Unique peer ID (default: random) */
86
+ peerId?: string;
87
+ }
88
+ interface SyncDoc<T extends Record<string, unknown>> {
89
+ /** Reactive synced state — each key is a Signal */
90
+ state: {
91
+ [K in keyof T]: Signal<T[K]>;
92
+ };
93
+ /** Connected peers (reactive) */
94
+ peers: ReadonlySignal<PeerInfo[]>;
95
+ /** Local presence data */
96
+ presence: Signal<Record<string, unknown>>;
97
+ /** Peer presence map (reactive) */
98
+ peerPresence: ReadonlySignal<Map<string, unknown>>;
99
+ /** This peer's ID */
100
+ peerId: string;
101
+ /** Whether connected */
102
+ connected: ReadonlySignal<boolean>;
103
+ /** Connect to the sync channel */
104
+ connect(): void;
105
+ /** Disconnect */
106
+ disconnect(): void;
107
+ /** Dispose the sync doc */
108
+ dispose(): void;
109
+ }
110
+ interface PeerInfo {
111
+ id: string;
112
+ joinedAt: number;
113
+ }
114
+ /**
115
+ * Create a collaborative synced document.
116
+ *
117
+ * ```ts
118
+ * const doc = createSync('room-1', { title: '', count: 0 }, {
119
+ * transport: createWebSocketTransport({ url: 'wss://sync.example.com', room: 'room-1' }),
120
+ * });
121
+ *
122
+ * doc.state.title.set('Hello'); // auto-syncs to all peers
123
+ * doc.peers(); // connected users
124
+ * ```
125
+ */
126
+ declare function createSync<T extends Record<string, unknown>>(roomId: string, initialState: T, options?: SyncOptions): SyncDoc<T>;
127
+
128
+ export { type LWWEntry, LWWRegister, type PeerInfo, type SyncDoc, type SyncOp, type SyncOptions, type SyncTransport, type WebSocketTransportOptions, createLocalTransport, createSync, createWebSocketTransport };
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-DPJ6RJ7A.js';import'./chunk-EUKRTV4W.js';//# sourceMappingURL=sync.js.map
1
+ export{a as LWWRegister,c as createLocalTransport,d as createSync,b as createWebSocketTransport}from'./chunk-ODDXU5DO.js';import'./chunk-POLTPHUA.js';//# sourceMappingURL=sync.js.map
2
2
  //# sourceMappingURL=sync.js.map
package/dist/test.cjs CHANGED
@@ -1,5 +1,5 @@
1
- 'use strict';var chunkQDCIW4YE_cjs=require('./chunk-QDCIW4YE.cjs'),chunkV7VG23IO_cjs=require('./chunk-V7VG23IO.cjs');function H(t,n){let e=document.createElement("div");e.setAttribute("data-akash-test-root","");let i=n?.props??{},r=n?.provide,s;return r&&r.size>0?s=chunkQDCIW4YE_cjs.B(()=>{for(let[l,d]of r)chunkQDCIW4YE_cjs.h(l,d);return ()=>t(i)})({}):s=t(i),e.appendChild(s),document.body.appendChild(e),{container:e,unmount(){e.remove();},getByText(o){let l=T(e,o);if(!l)throw new Error(`[AkashJS Test] Could not find element with text: "${o}"
1
+ 'use strict';var chunkNQVWTQ2I_cjs=require('./chunk-NQVWTQ2I.cjs'),chunk3AL2DVPZ_cjs=require('./chunk-3AL2DVPZ.cjs');function H(t,n){let e=document.createElement("div");e.setAttribute("data-akash-test-root","");let i=n?.props??{},r=n?.provide,s;return r&&r.size>0?s=chunkNQVWTQ2I_cjs.B(()=>{for(let[l,d]of r)chunkNQVWTQ2I_cjs.h(l,d);return ()=>t(i)})({}):s=t(i),e.appendChild(s),document.body.appendChild(e),{container:e,unmount(){e.remove();},getByText(o){let l=T(e,o);if(!l)throw new Error(`[AkashJS Test] Could not find element with text: "${o}"
2
2
  Container HTML: ${e.innerHTML.slice(0,200)}`);return l},getByRole(o){let l=e.querySelector(`[role="${o}"]`)??f(e,o);if(!l)throw new Error(`[AkashJS Test] Could not find element with role: "${o}"
3
3
  Container HTML: ${e.innerHTML.slice(0,200)}`);return l},getByTestId(o){let l=e.querySelector(`[data-testid="${o}"]`);if(!l)throw new Error(`[AkashJS Test] Could not find element with data-testid: "${o}"
4
- Container HTML: ${e.innerHTML.slice(0,200)}`);return l},queryAll(o){return Array.from(e.querySelectorAll(o))},query(o){return e.querySelector(o)}}}var L={async click(t){t.dispatchEvent(new MouseEvent("click",{bubbles:true,cancelable:true})),await a();},async input(t,n){let e=Object.getOwnPropertyDescriptor(t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;e?e.call(t,n):t.value=n,t.dispatchEvent(new Event("input",{bubbles:true})),t.dispatchEvent(new Event("change",{bubbles:true})),await a();},async submit(t){t.dispatchEvent(new Event("submit",{bubbles:true,cancelable:true})),await a();},async focus(t){t.focus(),t.dispatchEvent(new FocusEvent("focus",{bubbles:true})),await a();},async blur(t){t.blur(),t.dispatchEvent(new FocusEvent("blur",{bubbles:true})),await a();},async keyDown(t,n,e){t.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:true,...e})),await a();},async keyUp(t,n,e){t.dispatchEvent(new KeyboardEvent("keyup",{key:n,bubbles:true,...e})),await a();}};function a(){return new Promise(t=>queueMicrotask(t))}function T(t,n){let e=null,i=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),r=i.nextNode();for(;r;)r instanceof HTMLElement&&r.textContent?.includes(n)&&(e=r),r=i.nextNode();return !e&&t.textContent?.includes(n)&&(e=t),e}var E={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 f(t,n){let e=[];for(let[r,s]of Object.entries(E))s.includes(n)&&e.push(r);if(e.length===0)return null;let i=e.join(", ");return t.querySelector(i)}async function y(t,n){let{timeout:e=1e3,interval:i=50}=n??{},r=Date.now();for(;;)try{await t();return}catch(s){if(Date.now()-r>=e)throw s;await new Promise(o=>setTimeout(o,i));}}async function w(t,n,e){let i=null;return await y(()=>{if(i=t.querySelector(n),!i)throw new Error(`Element "${n}" not found`)},e),i}function v(t){let n=chunkV7VG23IO_cjs.l(t),e=[t],i=0,r=(()=>n());return r.set=s=>{n.set(s),e.push(s),i++;},r.update=s=>{let o=s(n.peek());r.set(o);},r.peek=()=>n.peek(),Object.defineProperty(r,"history",{get:()=>[...e]}),Object.defineProperty(r,"setCount",{get:()=>i}),r.resetHistory=()=>{e.length=0,e.push(n.peek()),i=0;},r}Object.defineProperty(exports,"flush",{enumerable:true,get:function(){return chunkV7VG23IO_cjs.b}});exports.createTestSignal=v;exports.fireEvent=L;exports.mount=H;exports.waitFor=y;exports.waitForElement=w;//# sourceMappingURL=test.cjs.map
4
+ Container HTML: ${e.innerHTML.slice(0,200)}`);return l},queryAll(o){return Array.from(e.querySelectorAll(o))},query(o){return e.querySelector(o)}}}var L={async click(t){t.dispatchEvent(new MouseEvent("click",{bubbles:true,cancelable:true})),await a();},async input(t,n){let e=Object.getOwnPropertyDescriptor(t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;e?e.call(t,n):t.value=n,t.dispatchEvent(new Event("input",{bubbles:true})),t.dispatchEvent(new Event("change",{bubbles:true})),await a();},async submit(t){t.dispatchEvent(new Event("submit",{bubbles:true,cancelable:true})),await a();},async focus(t){t.focus(),t.dispatchEvent(new FocusEvent("focus",{bubbles:true})),await a();},async blur(t){t.blur(),t.dispatchEvent(new FocusEvent("blur",{bubbles:true})),await a();},async keyDown(t,n,e){t.dispatchEvent(new KeyboardEvent("keydown",{key:n,bubbles:true,...e})),await a();},async keyUp(t,n,e){t.dispatchEvent(new KeyboardEvent("keyup",{key:n,bubbles:true,...e})),await a();}};function a(){return new Promise(t=>queueMicrotask(t))}function T(t,n){let e=null,i=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),r=i.nextNode();for(;r;)r instanceof HTMLElement&&r.textContent?.includes(n)&&(e=r),r=i.nextNode();return !e&&t.textContent?.includes(n)&&(e=t),e}var E={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 f(t,n){let e=[];for(let[r,s]of Object.entries(E))s.includes(n)&&e.push(r);if(e.length===0)return null;let i=e.join(", ");return t.querySelector(i)}async function y(t,n){let{timeout:e=1e3,interval:i=50}=n??{},r=Date.now();for(;;)try{await t();return}catch(s){if(Date.now()-r>=e)throw s;await new Promise(o=>setTimeout(o,i));}}async function w(t,n,e){let i=null;return await y(()=>{if(i=t.querySelector(n),!i)throw new Error(`Element "${n}" not found`)},e),i}function v(t){let n=chunk3AL2DVPZ_cjs.l(t),e=[t],i=0,r=(()=>n());return r.set=s=>{n.set(s),e.push(s),i++;},r.update=s=>{let o=s(n.peek());r.set(o);},r.peek=()=>n.peek(),Object.defineProperty(r,"history",{get:()=>[...e]}),Object.defineProperty(r,"setCount",{get:()=>i}),r.resetHistory=()=>{e.length=0,e.push(n.peek()),i=0;},r}Object.defineProperty(exports,"flush",{enumerable:true,get:function(){return chunk3AL2DVPZ_cjs.b}});exports.createTestSignal=v;exports.fireEvent=L;exports.mount=H;exports.waitFor=y;exports.waitForElement=w;//# sourceMappingURL=test.cjs.map
5
5
  //# sourceMappingURL=test.cjs.map