@mythetech/hermes-svelte 0.0.0-stage → 1.5.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mythetech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,32 @@
1
- # Temporary Holding Version
1
+ # @mythetech/hermes-svelte
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Svelte stores for the .NET host of a [Hermes](https://github.com/Mythetech/Hermes) desktop app, built on [`@mythetech/hermes-bridge`](https://www.npmjs.com/package/@mythetech/hermes-bridge). The package ships its TypeScript sources.
4
+
5
+ ```sh
6
+ npm install @mythetech/hermes-svelte @mythetech/hermes-bridge
7
+ ```
8
+
9
+ ```svelte
10
+ <script lang="ts">
11
+ import { createInvokeStore, createEventStore } from '@mythetech/hermes-svelte';
12
+
13
+ const runtime = createInvokeStore<string>('getRuntime');
14
+ const progress = createEventStore<number>('progress', 0);
15
+ </script>
16
+
17
+ {#if $runtime.loading}
18
+ <p>Loading</p>
19
+ {:else if $runtime.error}
20
+ <p>{$runtime.error.message}</p>
21
+ {:else}
22
+ <p>{$runtime.data}</p>
23
+ {/if}
24
+
25
+ <progress value={$progress} max="100"></progress>
26
+ ```
27
+
28
+ `createInvokeStore` calls the handler when the store gets its first subscriber, and `createEventStore` holds the latest value the host sent with `app.Bridge.Send`. `hermesConnected` is false outside a Hermes window.
29
+
30
+ ## License
31
+
32
+ MIT
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@mythetech/hermes-svelte",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.5.0",
4
+ "description": "Svelte reactive stores for Hermes desktop framework bridge",
5
+ "type": "module",
6
+ "main": "./src/index.ts",
7
+ "types": "./src/index.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./src/index.ts",
11
+ "types": "./src/index.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "src"
16
+ ],
17
+ "peerDependencies": {
18
+ "@mythetech/hermes-bridge": "^1.5.0",
19
+ "svelte": "^5.0.0"
20
+ },
21
+ "devDependencies": {
22
+ "svelte": "^5.0.0",
23
+ "typescript": "^5.7.0"
24
+ },
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/Mythetech/Hermes.git",
29
+ "directory": "packages/hermes-svelte"
30
+ },
31
+ "keywords": [
32
+ "hermes",
33
+ "svelte",
34
+ "desktop",
35
+ "webview",
36
+ "interop",
37
+ "bridge",
38
+ "stores"
39
+ ]
40
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ // Copyright (c) Mythetech. Licensed under the MIT License.
2
+ export { hermesConnected, createInvokeStore, createEventStore } from './stores.js';
3
+ export type { InvokeState } from './stores.js';
package/src/stores.ts ADDED
@@ -0,0 +1,36 @@
1
+ // Copyright (c) Mythetech. Licensed under the MIT License.
2
+ import { readable, type Readable } from 'svelte/store';
3
+ import { bridge } from '@mythetech/hermes-bridge';
4
+
5
+ export interface InvokeState<T> {
6
+ loading: boolean;
7
+ data?: T;
8
+ error?: Error;
9
+ }
10
+
11
+ export const hermesConnected: Readable<boolean> = readable(false, (set) => {
12
+ set(bridge.isHermes);
13
+ });
14
+
15
+ export function createInvokeStore<T>(method: string, ...args: unknown[]): Readable<InvokeState<T>> {
16
+ return readable<InvokeState<T>>({ loading: true }, (set) => {
17
+ if (!bridge.isHermes) {
18
+ set({ loading: false, error: new Error('Not running in Hermes') });
19
+ return;
20
+ }
21
+
22
+ bridge.invoke<T>(method, ...args)
23
+ .then((data) => set({ loading: false, data }))
24
+ .catch((error) => set({ loading: false, error: error instanceof Error ? error : new Error(String(error)) }));
25
+ });
26
+ }
27
+
28
+ export function createEventStore<T>(eventName: string, initialValue?: T): Readable<T | undefined> {
29
+ return readable<T | undefined>(initialValue, (set) => {
30
+ if (!bridge.isHermes) return;
31
+
32
+ return bridge.on<T>(eventName, (data) => {
33
+ set(data);
34
+ });
35
+ });
36
+ }