@quazardous/quarkernel-svelte 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -0
- package/dist/index.cjs +67 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +160 -0
- package/dist/index.d.ts +160 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @quazardous/quarkernel-svelte
|
|
2
|
+
|
|
3
|
+
Svelte 5 adapter for QuarKernel - context API and composables for seamless event kernel integration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @quazardous/quarkernel @quazardous/quarkernel-svelte
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Context API**: `setKernel()`/`getKernel()` for dependency injection
|
|
14
|
+
- **Auto-cleanup**: `onEvent()` composable with automatic unsubscribe on destroy
|
|
15
|
+
- **Type-safe**: Full TypeScript support
|
|
16
|
+
- **Svelte 5**: Designed for Svelte 5+ with modern context system
|
|
17
|
+
- **Zero runtime deps**: Only peer dependencies on Svelte and QuarKernel
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Basic Setup
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<!-- App.svelte (root component) -->
|
|
25
|
+
<script>
|
|
26
|
+
import { createKernel } from '@quazardous/quarkernel';
|
|
27
|
+
import { setKernel } from '@quazardous/quarkernel-svelte';
|
|
28
|
+
|
|
29
|
+
const qk = createKernel();
|
|
30
|
+
setKernel(kernel);
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<ChildComponent />
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Using in Child Components
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<!-- ChildComponent.svelte -->
|
|
40
|
+
<script>
|
|
41
|
+
import { getKernel, onEvent } from '@quazardous/quarkernel-svelte';
|
|
42
|
+
|
|
43
|
+
// Get kernel from context
|
|
44
|
+
const qk = getKernel();
|
|
45
|
+
|
|
46
|
+
// Register listener with auto-cleanup
|
|
47
|
+
onEvent('user:login', async (event) => {
|
|
48
|
+
console.log('User logged in:', event.data);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Manual emit
|
|
52
|
+
function handleClick() {
|
|
53
|
+
qk.emit('button:clicked', { timestamp: Date.now() });
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<button on:click={handleClick}>Click me</button>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Wildcard Patterns
|
|
61
|
+
|
|
62
|
+
```svelte
|
|
63
|
+
<script>
|
|
64
|
+
import { onEvent } from '@quazardous/quarkernel-svelte';
|
|
65
|
+
|
|
66
|
+
// Listen to all user events
|
|
67
|
+
onEvent('user:*', (event) => {
|
|
68
|
+
console.log('User event:', event);
|
|
69
|
+
});
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Manual Cleanup
|
|
74
|
+
|
|
75
|
+
```svelte
|
|
76
|
+
<script>
|
|
77
|
+
import { onEvent } from '@quazardous/quarkernel-svelte';
|
|
78
|
+
|
|
79
|
+
// onEvent returns unsubscribe function
|
|
80
|
+
const unsubscribe = onEvent('temp:event', (event) => {
|
|
81
|
+
console.log('Temporary listener');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function cleanup() {
|
|
85
|
+
unsubscribe(); // Remove listener before component destroys
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## API
|
|
91
|
+
|
|
92
|
+
### `setKernel(kernel)`
|
|
93
|
+
|
|
94
|
+
Store kernel instance in Svelte context. Must be called during component initialization.
|
|
95
|
+
|
|
96
|
+
**Parameters:**
|
|
97
|
+
- `kernel`: Kernel instance to provide to child components
|
|
98
|
+
|
|
99
|
+
**Throws:**
|
|
100
|
+
- Error if kernel is null/undefined
|
|
101
|
+
|
|
102
|
+
### `getKernel()`
|
|
103
|
+
|
|
104
|
+
Retrieve kernel instance from Svelte context.
|
|
105
|
+
|
|
106
|
+
**Returns:**
|
|
107
|
+
- Kernel instance
|
|
108
|
+
|
|
109
|
+
**Throws:**
|
|
110
|
+
- `KernelContextError` if called outside context or before `setKernel()`
|
|
111
|
+
|
|
112
|
+
### `onEvent(pattern, handler)`
|
|
113
|
+
|
|
114
|
+
Register event listener with automatic cleanup on component destroy.
|
|
115
|
+
|
|
116
|
+
**Parameters:**
|
|
117
|
+
- `pattern`: Event name or wildcard pattern (e.g., `'user:*'`)
|
|
118
|
+
- `handler`: Event handler function `(event, ctx) => void | Promise<void>`
|
|
119
|
+
|
|
120
|
+
**Returns:**
|
|
121
|
+
- Unsubscribe function for manual cleanup
|
|
122
|
+
|
|
123
|
+
**Throws:**
|
|
124
|
+
- `KernelContextError` if kernel not in context
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var svelte = require('svelte');
|
|
4
|
+
var store = require('svelte/store');
|
|
5
|
+
|
|
6
|
+
// src/context.ts
|
|
7
|
+
var KERNEL_CONTEXT_KEY = /* @__PURE__ */ Symbol("quarkernel");
|
|
8
|
+
var KernelContextError = class extends Error {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(
|
|
11
|
+
"getKernel() must be called within a component where setKernel() was used. Ensure you call setKernel(kernel) in a parent component."
|
|
12
|
+
);
|
|
13
|
+
this.name = "KernelContextError";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function setKernel(kernel) {
|
|
17
|
+
if (!kernel) {
|
|
18
|
+
throw new Error("[QuarKernel Svelte] setKernel() requires a kernel instance");
|
|
19
|
+
}
|
|
20
|
+
svelte.setContext(KERNEL_CONTEXT_KEY, kernel);
|
|
21
|
+
}
|
|
22
|
+
function getKernel() {
|
|
23
|
+
const kernel = svelte.getContext(KERNEL_CONTEXT_KEY);
|
|
24
|
+
if (!kernel) {
|
|
25
|
+
throw new KernelContextError();
|
|
26
|
+
}
|
|
27
|
+
return kernel;
|
|
28
|
+
}
|
|
29
|
+
function onEvent(pattern, handler) {
|
|
30
|
+
const kernel = getKernel();
|
|
31
|
+
const unsubscribe = kernel.on(pattern, handler);
|
|
32
|
+
svelte.onDestroy(() => {
|
|
33
|
+
unsubscribe();
|
|
34
|
+
});
|
|
35
|
+
return unsubscribe;
|
|
36
|
+
}
|
|
37
|
+
function eventStore(pattern) {
|
|
38
|
+
return store.readable(void 0, (set) => {
|
|
39
|
+
const kernel = getKernel();
|
|
40
|
+
const unsubscribe = kernel.on(pattern, async (event, _context) => {
|
|
41
|
+
set(event);
|
|
42
|
+
});
|
|
43
|
+
return () => {
|
|
44
|
+
unsubscribe();
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function contextStore(pattern) {
|
|
49
|
+
return store.readable(void 0, (set) => {
|
|
50
|
+
const kernel = getKernel();
|
|
51
|
+
const unsubscribe = kernel.on(pattern, async (_event, ctx) => {
|
|
52
|
+
set(ctx);
|
|
53
|
+
});
|
|
54
|
+
return () => {
|
|
55
|
+
unsubscribe();
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.KernelContextError = KernelContextError;
|
|
61
|
+
exports.contextStore = contextStore;
|
|
62
|
+
exports.eventStore = eventStore;
|
|
63
|
+
exports.getKernel = getKernel;
|
|
64
|
+
exports.onEvent = onEvent;
|
|
65
|
+
exports.setKernel = setKernel;
|
|
66
|
+
//# sourceMappingURL=index.cjs.map
|
|
67
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.ts","../src/stores.ts"],"names":["setContext","getContext","onDestroy","readable"],"mappings":";;;;;;AAcA,IAAM,kBAAA,0BAA4B,YAAY,CAAA;AAKvC,IAAM,kBAAA,GAAN,cAAiC,KAAA,CAAM;AAAA,EAC5C,WAAA,GAAc;AACZ,IAAA,KAAA;AAAA,MACE;AAAA,KAEF;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AAAA,EACd;AACF;AAqBO,SAAS,UAAU,MAAA,EAAsB;AAC9C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,MAAM,4DAA4D,CAAA;AAAA,EAC9E;AAEA,EAAAA,iBAAA,CAAW,oBAAoB,MAAM,CAAA;AACvC;AAuBO,SAAS,SAAA,GAA0C;AACxD,EAAA,MAAM,MAAA,GAASC,kBAAc,kBAAkB,CAAA;AAE/C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,kBAAA,EAAmB;AAAA,EAC/B;AAEA,EAAA,OAAO,MAAA;AACT;AAoCO,SAAS,OAAA,CACd,SACA,OAAA,EACY;AACZ,EAAA,MAAM,SAAS,SAAA,EAAU;AAGzB,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,OAAO,CAAA;AAG9C,EAAAC,gBAAA,CAAU,MAAM;AACd,IAAA,WAAA,EAAY;AAAA,EACd,CAAC,CAAA;AAED,EAAA,OAAO,WAAA;AACT;AC/FO,SAAS,WAAoB,OAAA,EAAwD;AAC1F,EAAA,OAAOC,cAAA,CAAsC,MAAA,EAAW,CAAC,GAAA,KAAQ;AAC/D,IAAA,MAAM,SAAS,SAAA,EAAU;AAGzB,IAAA,MAAM,cAAc,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,OAAO,OAAO,QAAA,KAAa;AAChE,MAAA,GAAA,CAAI,KAAK,CAAA;AAAA,IACX,CAAC,CAAA;AAGD,IAAA,OAAO,MAAM;AACX,MAAA,WAAA,EAAY;AAAA,IACd,CAAA;AAAA,EACF,CAAC,CAAA;AACH;AA4BO,SAAS,aAAa,OAAA,EAAyD;AACpF,EAAA,OAAOA,cAAA,CAAuC,MAAA,EAAW,CAAC,GAAA,KAAQ;AAChE,IAAA,MAAM,SAAS,SAAA,EAAU;AAGzB,IAAA,MAAM,cAAc,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,OAAO,QAAQ,GAAA,KAAQ;AAC5D,MAAA,GAAA,CAAI,GAAG,CAAA;AAAA,IACT,CAAC,CAAA;AAGD,IAAA,OAAO,MAAM;AACX,MAAA,WAAA,EAAY;AAAA,IACd,CAAA;AAAA,EACF,CAAC,CAAA;AACH","file":"index.cjs","sourcesContent":["/**\n * Svelte context API for QuarKernel integration\n *\n * Provides setKernel/getKernel for dependency injection and onEvent\n * composable for event subscriptions with automatic cleanup.\n */\n\nimport { getContext, setContext, onDestroy } from 'svelte';\nimport type { Kernel } from '@quazardous/quarkernel';\n\n/**\n * Context key for kernel instance\n * @internal\n */\nconst KERNEL_CONTEXT_KEY = Symbol('quarkernel');\n\n/**\n * Error thrown when getKernel is called outside context\n */\nexport class KernelContextError extends Error {\n constructor() {\n super(\n 'getKernel() must be called within a component where setKernel() was used. ' +\n 'Ensure you call setKernel(kernel) in a parent component.'\n );\n this.name = 'KernelContextError';\n }\n}\n\n/**\n * Store kernel instance in Svelte context\n *\n * Must be called during component initialization (top level of component script).\n * Makes kernel available to all child components via getKernel().\n *\n * @param kernel - Kernel instance to provide to child components\n *\n * @example\n * ```svelte\n * <script>\n * import { createKernel } from '@quazardous/quarkernel';\n * import { setKernel } from '@quazardous/quarkernel-svelte';\n *\n * const kernel = createKernel();\n * setKernel(kernel);\n * </script>\n * ```\n */\nexport function setKernel(kernel: Kernel): void {\n if (!kernel) {\n throw new Error('[QuarKernel Svelte] setKernel() requires a kernel instance');\n }\n\n setContext(KERNEL_CONTEXT_KEY, kernel);\n}\n\n/**\n * Retrieve kernel instance from Svelte context\n *\n * Must be called within a component where a parent called setKernel().\n * Throws KernelContextError if kernel not found in context.\n *\n * @throws {KernelContextError} If called outside context or before setKernel()\n * @returns The kernel instance\n *\n * @example\n * ```svelte\n * <script>\n * import { getKernel } from '@quazardous/quarkernel-svelte';\n *\n * const kernel = getKernel();\n *\n * // Use kernel directly\n * kernel.emit('user:login', { id: 123 });\n * </script>\n * ```\n */\nexport function getKernel<T extends Kernel = Kernel>(): T {\n const kernel = getContext<T>(KERNEL_CONTEXT_KEY);\n\n if (!kernel) {\n throw new KernelContextError();\n }\n\n return kernel;\n}\n\n/**\n * Register an event listener with automatic cleanup on component destroy\n *\n * Convenience wrapper around kernel.on() that:\n * - Retrieves kernel from context\n * - Registers the listener\n * - Automatically unsubscribes when component is destroyed\n * - Returns unsubscribe function for manual cleanup\n *\n * @param pattern - Event name or pattern (supports wildcards)\n * @param handler - Event handler function\n * @returns Unsubscribe function to manually remove listener before destroy\n *\n * @example\n * ```svelte\n * <script>\n * import { onEvent } from '@quazardous/quarkernel-svelte';\n *\n * // Auto-cleanup on component destroy\n * onEvent('user:*', async (event) => {\n * console.log('User event:', event.data);\n * });\n *\n * // Manual cleanup if needed\n * const unsubscribe = onEvent('cart:update', (event) => {\n * console.log('Cart updated');\n * });\n *\n * function handleClick() {\n * unsubscribe(); // Remove listener early\n * }\n * </script>\n * ```\n */\nexport function onEvent(\n pattern: string,\n handler: (event: any, ctx: any) => void | Promise<void>\n): () => void {\n const kernel = getKernel();\n\n // Register listener and get unsubscribe function\n const unsubscribe = kernel.on(pattern, handler);\n\n // Auto-cleanup on component destroy\n onDestroy(() => {\n unsubscribe();\n });\n\n return unsubscribe;\n}\n","/**\n * Reactive Svelte stores for QuarKernel events\n *\n * Provides eventStore and contextStore factories that wrap kernel events\n * in Svelte readable stores with automatic subscription management.\n */\n\nimport { readable } from 'svelte/store';\nimport type { Readable } from 'svelte/store';\nimport type { IKernelEvent, IListenerContext } from '@quazardous/quarkernel';\nimport { getKernel } from './context.js';\n\n/**\n * Create a readable store that updates when matching events occur\n *\n * The store subscribes to kernel events matching the pattern and updates\n * with the latest event data. Automatically manages kernel subscriptions\n * based on store subscription lifecycle.\n *\n * @param pattern - Event name or wildcard pattern to match\n * @returns Readable store containing latest event data (or undefined initially)\n *\n * @example\n * ```svelte\n * <script>\n * import { eventStore } from '@quazardous/quarkernel-svelte';\n *\n * const userEvents = eventStore('user:*');\n *\n * // Svelte 5 runes\n * $: console.log('Latest user event:', $userEvents);\n * </script>\n *\n * <div>\n * {#if $userEvents}\n * <p>Event: {$userEvents.name}</p>\n * <p>Data: {JSON.stringify($userEvents.data)}</p>\n * {/if}\n * </div>\n * ```\n */\nexport function eventStore<T = any>(pattern: string): Readable<IKernelEvent<T> | undefined> {\n return readable<IKernelEvent<T> | undefined>(undefined, (set) => {\n const kernel = getKernel();\n\n // Subscribe to kernel events and update store\n const unsubscribe = kernel.on(pattern, async (event, _context) => {\n set(event);\n });\n\n // Return cleanup function - called when store has no subscribers\n return () => {\n unsubscribe();\n };\n });\n}\n\n/**\n * Create a readable store that updates with current listener context\n *\n * Useful for accessing context data in reactive Svelte components.\n * The store updates whenever an event matching the pattern is processed\n * and provides access to the listener context object.\n *\n * @param pattern - Event name or wildcard pattern to match\n * @returns Readable store containing latest listener context (or undefined initially)\n *\n * @example\n * ```svelte\n * <script>\n * import { contextStore } from '@quazardous/quarkernel-svelte';\n *\n * const ctx = contextStore('cart:*');\n * </script>\n *\n * <div>\n * {#if $ctx}\n * <p>Listener ID: {$ctx.id}</p>\n * <p>Context data: {JSON.stringify($ctx)}</p>\n * {/if}\n * </div>\n * ```\n */\nexport function contextStore(pattern: string): Readable<IListenerContext | undefined> {\n return readable<IListenerContext | undefined>(undefined, (set) => {\n const kernel = getKernel();\n\n // Subscribe to kernel events and update store with context\n const unsubscribe = kernel.on(pattern, async (_event, ctx) => {\n set(ctx);\n });\n\n // Return cleanup function - called when store has no subscribers\n return () => {\n unsubscribe();\n };\n });\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Kernel, IKernelEvent, IListenerContext } from '@quazardous/quarkernel';
|
|
2
|
+
import { Readable } from 'svelte/store';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Svelte context API for QuarKernel integration
|
|
6
|
+
*
|
|
7
|
+
* Provides setKernel/getKernel for dependency injection and onEvent
|
|
8
|
+
* composable for event subscriptions with automatic cleanup.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when getKernel is called outside context
|
|
13
|
+
*/
|
|
14
|
+
declare class KernelContextError extends Error {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Store kernel instance in Svelte context
|
|
19
|
+
*
|
|
20
|
+
* Must be called during component initialization (top level of component script).
|
|
21
|
+
* Makes kernel available to all child components via getKernel().
|
|
22
|
+
*
|
|
23
|
+
* @param kernel - Kernel instance to provide to child components
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```svelte
|
|
27
|
+
* <script>
|
|
28
|
+
* import { createKernel } from '@quazardous/quarkernel';
|
|
29
|
+
* import { setKernel } from '@quazardous/quarkernel-svelte';
|
|
30
|
+
*
|
|
31
|
+
* const kernel = createKernel();
|
|
32
|
+
* setKernel(kernel);
|
|
33
|
+
* </script>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function setKernel(kernel: Kernel): void;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve kernel instance from Svelte context
|
|
39
|
+
*
|
|
40
|
+
* Must be called within a component where a parent called setKernel().
|
|
41
|
+
* Throws KernelContextError if kernel not found in context.
|
|
42
|
+
*
|
|
43
|
+
* @throws {KernelContextError} If called outside context or before setKernel()
|
|
44
|
+
* @returns The kernel instance
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```svelte
|
|
48
|
+
* <script>
|
|
49
|
+
* import { getKernel } from '@quazardous/quarkernel-svelte';
|
|
50
|
+
*
|
|
51
|
+
* const kernel = getKernel();
|
|
52
|
+
*
|
|
53
|
+
* // Use kernel directly
|
|
54
|
+
* kernel.emit('user:login', { id: 123 });
|
|
55
|
+
* </script>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare function getKernel<T extends Kernel = Kernel>(): T;
|
|
59
|
+
/**
|
|
60
|
+
* Register an event listener with automatic cleanup on component destroy
|
|
61
|
+
*
|
|
62
|
+
* Convenience wrapper around kernel.on() that:
|
|
63
|
+
* - Retrieves kernel from context
|
|
64
|
+
* - Registers the listener
|
|
65
|
+
* - Automatically unsubscribes when component is destroyed
|
|
66
|
+
* - Returns unsubscribe function for manual cleanup
|
|
67
|
+
*
|
|
68
|
+
* @param pattern - Event name or pattern (supports wildcards)
|
|
69
|
+
* @param handler - Event handler function
|
|
70
|
+
* @returns Unsubscribe function to manually remove listener before destroy
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```svelte
|
|
74
|
+
* <script>
|
|
75
|
+
* import { onEvent } from '@quazardous/quarkernel-svelte';
|
|
76
|
+
*
|
|
77
|
+
* // Auto-cleanup on component destroy
|
|
78
|
+
* onEvent('user:*', async (event) => {
|
|
79
|
+
* console.log('User event:', event.data);
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* // Manual cleanup if needed
|
|
83
|
+
* const unsubscribe = onEvent('cart:update', (event) => {
|
|
84
|
+
* console.log('Cart updated');
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* function handleClick() {
|
|
88
|
+
* unsubscribe(); // Remove listener early
|
|
89
|
+
* }
|
|
90
|
+
* </script>
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
declare function onEvent(pattern: string, handler: (event: any, ctx: any) => void | Promise<void>): () => void;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Reactive Svelte stores for QuarKernel events
|
|
97
|
+
*
|
|
98
|
+
* Provides eventStore and contextStore factories that wrap kernel events
|
|
99
|
+
* in Svelte readable stores with automatic subscription management.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Create a readable store that updates when matching events occur
|
|
104
|
+
*
|
|
105
|
+
* The store subscribes to kernel events matching the pattern and updates
|
|
106
|
+
* with the latest event data. Automatically manages kernel subscriptions
|
|
107
|
+
* based on store subscription lifecycle.
|
|
108
|
+
*
|
|
109
|
+
* @param pattern - Event name or wildcard pattern to match
|
|
110
|
+
* @returns Readable store containing latest event data (or undefined initially)
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```svelte
|
|
114
|
+
* <script>
|
|
115
|
+
* import { eventStore } from '@quazardous/quarkernel-svelte';
|
|
116
|
+
*
|
|
117
|
+
* const userEvents = eventStore('user:*');
|
|
118
|
+
*
|
|
119
|
+
* // Svelte 5 runes
|
|
120
|
+
* $: console.log('Latest user event:', $userEvents);
|
|
121
|
+
* </script>
|
|
122
|
+
*
|
|
123
|
+
* <div>
|
|
124
|
+
* {#if $userEvents}
|
|
125
|
+
* <p>Event: {$userEvents.name}</p>
|
|
126
|
+
* <p>Data: {JSON.stringify($userEvents.data)}</p>
|
|
127
|
+
* {/if}
|
|
128
|
+
* </div>
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
declare function eventStore<T = any>(pattern: string): Readable<IKernelEvent<T> | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Create a readable store that updates with current listener context
|
|
134
|
+
*
|
|
135
|
+
* Useful for accessing context data in reactive Svelte components.
|
|
136
|
+
* The store updates whenever an event matching the pattern is processed
|
|
137
|
+
* and provides access to the listener context object.
|
|
138
|
+
*
|
|
139
|
+
* @param pattern - Event name or wildcard pattern to match
|
|
140
|
+
* @returns Readable store containing latest listener context (or undefined initially)
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```svelte
|
|
144
|
+
* <script>
|
|
145
|
+
* import { contextStore } from '@quazardous/quarkernel-svelte';
|
|
146
|
+
*
|
|
147
|
+
* const ctx = contextStore('cart:*');
|
|
148
|
+
* </script>
|
|
149
|
+
*
|
|
150
|
+
* <div>
|
|
151
|
+
* {#if $ctx}
|
|
152
|
+
* <p>Listener ID: {$ctx.id}</p>
|
|
153
|
+
* <p>Context data: {JSON.stringify($ctx)}</p>
|
|
154
|
+
* {/if}
|
|
155
|
+
* </div>
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function contextStore(pattern: string): Readable<IListenerContext | undefined>;
|
|
159
|
+
|
|
160
|
+
export { KernelContextError, contextStore, eventStore, getKernel, onEvent, setKernel };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Kernel, IKernelEvent, IListenerContext } from '@quazardous/quarkernel';
|
|
2
|
+
import { Readable } from 'svelte/store';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Svelte context API for QuarKernel integration
|
|
6
|
+
*
|
|
7
|
+
* Provides setKernel/getKernel for dependency injection and onEvent
|
|
8
|
+
* composable for event subscriptions with automatic cleanup.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when getKernel is called outside context
|
|
13
|
+
*/
|
|
14
|
+
declare class KernelContextError extends Error {
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Store kernel instance in Svelte context
|
|
19
|
+
*
|
|
20
|
+
* Must be called during component initialization (top level of component script).
|
|
21
|
+
* Makes kernel available to all child components via getKernel().
|
|
22
|
+
*
|
|
23
|
+
* @param kernel - Kernel instance to provide to child components
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```svelte
|
|
27
|
+
* <script>
|
|
28
|
+
* import { createKernel } from '@quazardous/quarkernel';
|
|
29
|
+
* import { setKernel } from '@quazardous/quarkernel-svelte';
|
|
30
|
+
*
|
|
31
|
+
* const kernel = createKernel();
|
|
32
|
+
* setKernel(kernel);
|
|
33
|
+
* </script>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function setKernel(kernel: Kernel): void;
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve kernel instance from Svelte context
|
|
39
|
+
*
|
|
40
|
+
* Must be called within a component where a parent called setKernel().
|
|
41
|
+
* Throws KernelContextError if kernel not found in context.
|
|
42
|
+
*
|
|
43
|
+
* @throws {KernelContextError} If called outside context or before setKernel()
|
|
44
|
+
* @returns The kernel instance
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```svelte
|
|
48
|
+
* <script>
|
|
49
|
+
* import { getKernel } from '@quazardous/quarkernel-svelte';
|
|
50
|
+
*
|
|
51
|
+
* const kernel = getKernel();
|
|
52
|
+
*
|
|
53
|
+
* // Use kernel directly
|
|
54
|
+
* kernel.emit('user:login', { id: 123 });
|
|
55
|
+
* </script>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare function getKernel<T extends Kernel = Kernel>(): T;
|
|
59
|
+
/**
|
|
60
|
+
* Register an event listener with automatic cleanup on component destroy
|
|
61
|
+
*
|
|
62
|
+
* Convenience wrapper around kernel.on() that:
|
|
63
|
+
* - Retrieves kernel from context
|
|
64
|
+
* - Registers the listener
|
|
65
|
+
* - Automatically unsubscribes when component is destroyed
|
|
66
|
+
* - Returns unsubscribe function for manual cleanup
|
|
67
|
+
*
|
|
68
|
+
* @param pattern - Event name or pattern (supports wildcards)
|
|
69
|
+
* @param handler - Event handler function
|
|
70
|
+
* @returns Unsubscribe function to manually remove listener before destroy
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```svelte
|
|
74
|
+
* <script>
|
|
75
|
+
* import { onEvent } from '@quazardous/quarkernel-svelte';
|
|
76
|
+
*
|
|
77
|
+
* // Auto-cleanup on component destroy
|
|
78
|
+
* onEvent('user:*', async (event) => {
|
|
79
|
+
* console.log('User event:', event.data);
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* // Manual cleanup if needed
|
|
83
|
+
* const unsubscribe = onEvent('cart:update', (event) => {
|
|
84
|
+
* console.log('Cart updated');
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* function handleClick() {
|
|
88
|
+
* unsubscribe(); // Remove listener early
|
|
89
|
+
* }
|
|
90
|
+
* </script>
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
declare function onEvent(pattern: string, handler: (event: any, ctx: any) => void | Promise<void>): () => void;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Reactive Svelte stores for QuarKernel events
|
|
97
|
+
*
|
|
98
|
+
* Provides eventStore and contextStore factories that wrap kernel events
|
|
99
|
+
* in Svelte readable stores with automatic subscription management.
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Create a readable store that updates when matching events occur
|
|
104
|
+
*
|
|
105
|
+
* The store subscribes to kernel events matching the pattern and updates
|
|
106
|
+
* with the latest event data. Automatically manages kernel subscriptions
|
|
107
|
+
* based on store subscription lifecycle.
|
|
108
|
+
*
|
|
109
|
+
* @param pattern - Event name or wildcard pattern to match
|
|
110
|
+
* @returns Readable store containing latest event data (or undefined initially)
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```svelte
|
|
114
|
+
* <script>
|
|
115
|
+
* import { eventStore } from '@quazardous/quarkernel-svelte';
|
|
116
|
+
*
|
|
117
|
+
* const userEvents = eventStore('user:*');
|
|
118
|
+
*
|
|
119
|
+
* // Svelte 5 runes
|
|
120
|
+
* $: console.log('Latest user event:', $userEvents);
|
|
121
|
+
* </script>
|
|
122
|
+
*
|
|
123
|
+
* <div>
|
|
124
|
+
* {#if $userEvents}
|
|
125
|
+
* <p>Event: {$userEvents.name}</p>
|
|
126
|
+
* <p>Data: {JSON.stringify($userEvents.data)}</p>
|
|
127
|
+
* {/if}
|
|
128
|
+
* </div>
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
declare function eventStore<T = any>(pattern: string): Readable<IKernelEvent<T> | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Create a readable store that updates with current listener context
|
|
134
|
+
*
|
|
135
|
+
* Useful for accessing context data in reactive Svelte components.
|
|
136
|
+
* The store updates whenever an event matching the pattern is processed
|
|
137
|
+
* and provides access to the listener context object.
|
|
138
|
+
*
|
|
139
|
+
* @param pattern - Event name or wildcard pattern to match
|
|
140
|
+
* @returns Readable store containing latest listener context (or undefined initially)
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```svelte
|
|
144
|
+
* <script>
|
|
145
|
+
* import { contextStore } from '@quazardous/quarkernel-svelte';
|
|
146
|
+
*
|
|
147
|
+
* const ctx = contextStore('cart:*');
|
|
148
|
+
* </script>
|
|
149
|
+
*
|
|
150
|
+
* <div>
|
|
151
|
+
* {#if $ctx}
|
|
152
|
+
* <p>Listener ID: {$ctx.id}</p>
|
|
153
|
+
* <p>Context data: {JSON.stringify($ctx)}</p>
|
|
154
|
+
* {/if}
|
|
155
|
+
* </div>
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
declare function contextStore(pattern: string): Readable<IListenerContext | undefined>;
|
|
159
|
+
|
|
160
|
+
export { KernelContextError, contextStore, eventStore, getKernel, onEvent, setKernel };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { setContext, getContext, onDestroy } from 'svelte';
|
|
2
|
+
import { readable } from 'svelte/store';
|
|
3
|
+
|
|
4
|
+
// src/context.ts
|
|
5
|
+
var KERNEL_CONTEXT_KEY = /* @__PURE__ */ Symbol("quarkernel");
|
|
6
|
+
var KernelContextError = class extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(
|
|
9
|
+
"getKernel() must be called within a component where setKernel() was used. Ensure you call setKernel(kernel) in a parent component."
|
|
10
|
+
);
|
|
11
|
+
this.name = "KernelContextError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
function setKernel(kernel) {
|
|
15
|
+
if (!kernel) {
|
|
16
|
+
throw new Error("[QuarKernel Svelte] setKernel() requires a kernel instance");
|
|
17
|
+
}
|
|
18
|
+
setContext(KERNEL_CONTEXT_KEY, kernel);
|
|
19
|
+
}
|
|
20
|
+
function getKernel() {
|
|
21
|
+
const kernel = getContext(KERNEL_CONTEXT_KEY);
|
|
22
|
+
if (!kernel) {
|
|
23
|
+
throw new KernelContextError();
|
|
24
|
+
}
|
|
25
|
+
return kernel;
|
|
26
|
+
}
|
|
27
|
+
function onEvent(pattern, handler) {
|
|
28
|
+
const kernel = getKernel();
|
|
29
|
+
const unsubscribe = kernel.on(pattern, handler);
|
|
30
|
+
onDestroy(() => {
|
|
31
|
+
unsubscribe();
|
|
32
|
+
});
|
|
33
|
+
return unsubscribe;
|
|
34
|
+
}
|
|
35
|
+
function eventStore(pattern) {
|
|
36
|
+
return readable(void 0, (set) => {
|
|
37
|
+
const kernel = getKernel();
|
|
38
|
+
const unsubscribe = kernel.on(pattern, async (event, _context) => {
|
|
39
|
+
set(event);
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
unsubscribe();
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function contextStore(pattern) {
|
|
47
|
+
return readable(void 0, (set) => {
|
|
48
|
+
const kernel = getKernel();
|
|
49
|
+
const unsubscribe = kernel.on(pattern, async (_event, ctx) => {
|
|
50
|
+
set(ctx);
|
|
51
|
+
});
|
|
52
|
+
return () => {
|
|
53
|
+
unsubscribe();
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { KernelContextError, contextStore, eventStore, getKernel, onEvent, setKernel };
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.ts","../src/stores.ts"],"names":[],"mappings":";;;;AAcA,IAAM,kBAAA,0BAA4B,YAAY,CAAA;AAKvC,IAAM,kBAAA,GAAN,cAAiC,KAAA,CAAM;AAAA,EAC5C,WAAA,GAAc;AACZ,IAAA,KAAA;AAAA,MACE;AAAA,KAEF;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,oBAAA;AAAA,EACd;AACF;AAqBO,SAAS,UAAU,MAAA,EAAsB;AAC9C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,MAAM,4DAA4D,CAAA;AAAA,EAC9E;AAEA,EAAA,UAAA,CAAW,oBAAoB,MAAM,CAAA;AACvC;AAuBO,SAAS,SAAA,GAA0C;AACxD,EAAA,MAAM,MAAA,GAAS,WAAc,kBAAkB,CAAA;AAE/C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,kBAAA,EAAmB;AAAA,EAC/B;AAEA,EAAA,OAAO,MAAA;AACT;AAoCO,SAAS,OAAA,CACd,SACA,OAAA,EACY;AACZ,EAAA,MAAM,SAAS,SAAA,EAAU;AAGzB,EAAA,MAAM,WAAA,GAAc,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,OAAO,CAAA;AAG9C,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,WAAA,EAAY;AAAA,EACd,CAAC,CAAA;AAED,EAAA,OAAO,WAAA;AACT;AC/FO,SAAS,WAAoB,OAAA,EAAwD;AAC1F,EAAA,OAAO,QAAA,CAAsC,MAAA,EAAW,CAAC,GAAA,KAAQ;AAC/D,IAAA,MAAM,SAAS,SAAA,EAAU;AAGzB,IAAA,MAAM,cAAc,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,OAAO,OAAO,QAAA,KAAa;AAChE,MAAA,GAAA,CAAI,KAAK,CAAA;AAAA,IACX,CAAC,CAAA;AAGD,IAAA,OAAO,MAAM;AACX,MAAA,WAAA,EAAY;AAAA,IACd,CAAA;AAAA,EACF,CAAC,CAAA;AACH;AA4BO,SAAS,aAAa,OAAA,EAAyD;AACpF,EAAA,OAAO,QAAA,CAAuC,MAAA,EAAW,CAAC,GAAA,KAAQ;AAChE,IAAA,MAAM,SAAS,SAAA,EAAU;AAGzB,IAAA,MAAM,cAAc,MAAA,CAAO,EAAA,CAAG,OAAA,EAAS,OAAO,QAAQ,GAAA,KAAQ;AAC5D,MAAA,GAAA,CAAI,GAAG,CAAA;AAAA,IACT,CAAC,CAAA;AAGD,IAAA,OAAO,MAAM;AACX,MAAA,WAAA,EAAY;AAAA,IACd,CAAA;AAAA,EACF,CAAC,CAAA;AACH","file":"index.js","sourcesContent":["/**\n * Svelte context API for QuarKernel integration\n *\n * Provides setKernel/getKernel for dependency injection and onEvent\n * composable for event subscriptions with automatic cleanup.\n */\n\nimport { getContext, setContext, onDestroy } from 'svelte';\nimport type { Kernel } from '@quazardous/quarkernel';\n\n/**\n * Context key for kernel instance\n * @internal\n */\nconst KERNEL_CONTEXT_KEY = Symbol('quarkernel');\n\n/**\n * Error thrown when getKernel is called outside context\n */\nexport class KernelContextError extends Error {\n constructor() {\n super(\n 'getKernel() must be called within a component where setKernel() was used. ' +\n 'Ensure you call setKernel(kernel) in a parent component.'\n );\n this.name = 'KernelContextError';\n }\n}\n\n/**\n * Store kernel instance in Svelte context\n *\n * Must be called during component initialization (top level of component script).\n * Makes kernel available to all child components via getKernel().\n *\n * @param kernel - Kernel instance to provide to child components\n *\n * @example\n * ```svelte\n * <script>\n * import { createKernel } from '@quazardous/quarkernel';\n * import { setKernel } from '@quazardous/quarkernel-svelte';\n *\n * const kernel = createKernel();\n * setKernel(kernel);\n * </script>\n * ```\n */\nexport function setKernel(kernel: Kernel): void {\n if (!kernel) {\n throw new Error('[QuarKernel Svelte] setKernel() requires a kernel instance');\n }\n\n setContext(KERNEL_CONTEXT_KEY, kernel);\n}\n\n/**\n * Retrieve kernel instance from Svelte context\n *\n * Must be called within a component where a parent called setKernel().\n * Throws KernelContextError if kernel not found in context.\n *\n * @throws {KernelContextError} If called outside context or before setKernel()\n * @returns The kernel instance\n *\n * @example\n * ```svelte\n * <script>\n * import { getKernel } from '@quazardous/quarkernel-svelte';\n *\n * const kernel = getKernel();\n *\n * // Use kernel directly\n * kernel.emit('user:login', { id: 123 });\n * </script>\n * ```\n */\nexport function getKernel<T extends Kernel = Kernel>(): T {\n const kernel = getContext<T>(KERNEL_CONTEXT_KEY);\n\n if (!kernel) {\n throw new KernelContextError();\n }\n\n return kernel;\n}\n\n/**\n * Register an event listener with automatic cleanup on component destroy\n *\n * Convenience wrapper around kernel.on() that:\n * - Retrieves kernel from context\n * - Registers the listener\n * - Automatically unsubscribes when component is destroyed\n * - Returns unsubscribe function for manual cleanup\n *\n * @param pattern - Event name or pattern (supports wildcards)\n * @param handler - Event handler function\n * @returns Unsubscribe function to manually remove listener before destroy\n *\n * @example\n * ```svelte\n * <script>\n * import { onEvent } from '@quazardous/quarkernel-svelte';\n *\n * // Auto-cleanup on component destroy\n * onEvent('user:*', async (event) => {\n * console.log('User event:', event.data);\n * });\n *\n * // Manual cleanup if needed\n * const unsubscribe = onEvent('cart:update', (event) => {\n * console.log('Cart updated');\n * });\n *\n * function handleClick() {\n * unsubscribe(); // Remove listener early\n * }\n * </script>\n * ```\n */\nexport function onEvent(\n pattern: string,\n handler: (event: any, ctx: any) => void | Promise<void>\n): () => void {\n const kernel = getKernel();\n\n // Register listener and get unsubscribe function\n const unsubscribe = kernel.on(pattern, handler);\n\n // Auto-cleanup on component destroy\n onDestroy(() => {\n unsubscribe();\n });\n\n return unsubscribe;\n}\n","/**\n * Reactive Svelte stores for QuarKernel events\n *\n * Provides eventStore and contextStore factories that wrap kernel events\n * in Svelte readable stores with automatic subscription management.\n */\n\nimport { readable } from 'svelte/store';\nimport type { Readable } from 'svelte/store';\nimport type { IKernelEvent, IListenerContext } from '@quazardous/quarkernel';\nimport { getKernel } from './context.js';\n\n/**\n * Create a readable store that updates when matching events occur\n *\n * The store subscribes to kernel events matching the pattern and updates\n * with the latest event data. Automatically manages kernel subscriptions\n * based on store subscription lifecycle.\n *\n * @param pattern - Event name or wildcard pattern to match\n * @returns Readable store containing latest event data (or undefined initially)\n *\n * @example\n * ```svelte\n * <script>\n * import { eventStore } from '@quazardous/quarkernel-svelte';\n *\n * const userEvents = eventStore('user:*');\n *\n * // Svelte 5 runes\n * $: console.log('Latest user event:', $userEvents);\n * </script>\n *\n * <div>\n * {#if $userEvents}\n * <p>Event: {$userEvents.name}</p>\n * <p>Data: {JSON.stringify($userEvents.data)}</p>\n * {/if}\n * </div>\n * ```\n */\nexport function eventStore<T = any>(pattern: string): Readable<IKernelEvent<T> | undefined> {\n return readable<IKernelEvent<T> | undefined>(undefined, (set) => {\n const kernel = getKernel();\n\n // Subscribe to kernel events and update store\n const unsubscribe = kernel.on(pattern, async (event, _context) => {\n set(event);\n });\n\n // Return cleanup function - called when store has no subscribers\n return () => {\n unsubscribe();\n };\n });\n}\n\n/**\n * Create a readable store that updates with current listener context\n *\n * Useful for accessing context data in reactive Svelte components.\n * The store updates whenever an event matching the pattern is processed\n * and provides access to the listener context object.\n *\n * @param pattern - Event name or wildcard pattern to match\n * @returns Readable store containing latest listener context (or undefined initially)\n *\n * @example\n * ```svelte\n * <script>\n * import { contextStore } from '@quazardous/quarkernel-svelte';\n *\n * const ctx = contextStore('cart:*');\n * </script>\n *\n * <div>\n * {#if $ctx}\n * <p>Listener ID: {$ctx.id}</p>\n * <p>Context data: {JSON.stringify($ctx)}</p>\n * {/if}\n * </div>\n * ```\n */\nexport function contextStore(pattern: string): Readable<IListenerContext | undefined> {\n return readable<IListenerContext | undefined>(undefined, (set) => {\n const kernel = getKernel();\n\n // Subscribe to kernel events and update store with context\n const unsubscribe = kernel.on(pattern, async (_event, ctx) => {\n set(ctx);\n });\n\n // Return cleanup function - called when store has no subscribers\n return () => {\n unsubscribe();\n };\n });\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quazardous/quarkernel-svelte",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Svelte 5 adapter for QuarKernel - event kernel integration with Svelte context",
|
|
6
|
+
"author": "quazardous <berliozdavid@gmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/quazardous/quarkernel.git",
|
|
11
|
+
"directory": "packages/svelte"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/quazardous/quarkernel/issues"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/quazardous/quarkernel#readme",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"quarkernel",
|
|
19
|
+
"svelte",
|
|
20
|
+
"svelte5",
|
|
21
|
+
"event",
|
|
22
|
+
"events",
|
|
23
|
+
"kernel",
|
|
24
|
+
"context",
|
|
25
|
+
"composable",
|
|
26
|
+
"reactivity"
|
|
27
|
+
],
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"main": "./dist/index.cjs",
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18.0.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsup",
|
|
49
|
+
"build:watch": "tsup --watch",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"test:watch": "vitest",
|
|
52
|
+
"clean": "rm -rf dist"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@quazardous/quarkernel": "^2.1.0",
|
|
56
|
+
"svelte": "^5.0.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@quazardous/quarkernel": "file:../quarkernel",
|
|
60
|
+
"svelte": "^5.0.0",
|
|
61
|
+
"tsup": "^8.0.0",
|
|
62
|
+
"typescript": "^5.3.0",
|
|
63
|
+
"vitest": "^1.0.0"
|
|
64
|
+
}
|
|
65
|
+
}
|