@runic-artifex/vue 0.0.0-stage → 0.6.0-preview.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.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Runic Artifex contributors
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.
22
+
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # `@runic-artifex/vue`
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
+ Vue composable for clients generated by Runic Views. The generated modules
4
+ import `@runic-artifex/views`, so install both:
5
+
6
+ ```sh
7
+ npm install @runic-artifex/vue@preview @runic-artifex/views@preview
8
+ pnpm add @runic-artifex/vue@preview @runic-artifex/views@preview
9
+ bun add @runic-artifex/vue@preview @runic-artifex/views@preview
10
+ ```
11
+
12
+ Previews are published under the `preview` dist-tag. Install the versions that
13
+ match your Runic SDK packages. Vue 3.5 or later is supported.
14
+
15
+ ```vue
16
+ <script setup lang="ts">
17
+ import { useView } from "@runic-artifex/vue";
18
+ import type { CounterPageReference } from "./generated/counter.js";
19
+
20
+ const props = defineProps<{ page: CounterPageReference }>();
21
+ const { state, client, error } = useView(() => props.page);
22
+ </script>
23
+
24
+ <template>
25
+ <button :disabled="!client" @click="client?.increment()">{{ state?.count ?? "…" }}</button>
26
+ <p v-if="error" role="alert">{{ error }}</p>
27
+ </template>
28
+ ```
29
+
30
+ `useView(source)` returns shallow refs `{ state, client, error }` and `retry()`:
31
+
32
+ - A generated page reference, or `{ connect: connect<Name> }` for a root
33
+ ViewModel, is connected while the current effect scope (normally the
34
+ component) is active. Disposing the scope or changing the reference disposes
35
+ the client. A reference is identified by its `connect` function, so a getter
36
+ that returns a new `{ connect: connectWorkspace }` object does not reconnect.
37
+ - An already connected client is observed and left to its owner.
38
+ - The source can be a value, a ref or a getter such as `() => props.page`.
39
+ - `error` holds a failed connection; `retry()` connects again.
@@ -0,0 +1,38 @@
1
+ import { type MaybeRefOrGetter, type Ref } from "vue";
2
+ /** The framework-neutral surface of a generated `<Name>Client`. */
3
+ export interface ViewClient<TState = unknown> {
4
+ readonly snapshot: TState;
5
+ subscribe(listener: (state: TState) => void): () => void;
6
+ dispose(): void;
7
+ }
8
+ /** A generated content reference, or `{ connect: connect<Name> }` for a root ViewModel. */
9
+ export interface ViewReference<TClient extends ViewClient = ViewClient> {
10
+ connect(): Promise<TClient>;
11
+ }
12
+ /**
13
+ * A reference is connected and disposed by the composable. An already
14
+ * connected client is only observed; its owner disposes it.
15
+ */
16
+ export type ViewSource<TClient extends ViewClient> = ViewReference<TClient> | TClient | null | undefined;
17
+ export interface ViewHandle<TClient extends ViewClient> {
18
+ /** The latest state, or undefined until the client connects. */
19
+ readonly state: Readonly<Ref<TClient["snapshot"] | undefined>>;
20
+ /** The connected client for commands, or undefined until it connects. */
21
+ readonly client: Readonly<Ref<TClient | undefined>>;
22
+ /** The connection failure, if any. */
23
+ readonly error: Readonly<Ref<unknown>>;
24
+ /** Connects a reference again after a failure. */
25
+ retry(): void;
26
+ }
27
+ /**
28
+ * Connects a generated View reference while the current effect scope (for
29
+ * example a component) is active and exposes its state as shallow refs. A
30
+ * changed reference disposes the previous client; disposing the scope
31
+ * disposes the current one.
32
+ *
33
+ * Pass a getter such as `() => props.page` to follow a prop. A reference is
34
+ * identified by its `connect` function, so a getter returning a new
35
+ * `{ connect: connectWorkspace }` object does not reconnect.
36
+ */
37
+ export declare function useView<TClient extends ViewClient>(source: MaybeRefOrGetter<ViewSource<TClient>>): ViewHandle<TClient>;
38
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+D,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAEnH,mEAAmE;AACnE,MAAM,WAAW,UAAU,CAAC,MAAM,GAAG,OAAO;IAC1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACzD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,2FAA2F;AAC3F,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU;IACpE,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,UAAU,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAEzG,MAAM,WAAW,UAAU,CAAC,OAAO,SAAS,UAAU;IACpD,gEAAgE;IAChE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;IAC/D,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC;IACpD,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACvC,kDAAkD;IAClD,KAAK,IAAI,IAAI,CAAC;CACf;AAMD;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,OAAO,SAAS,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,CAwCtH"}
package/dist/index.js ADDED
@@ -0,0 +1,63 @@
1
+ import { getCurrentScope, onScopeDispose, shallowRef, toValue, watch } from "vue";
2
+ function isClient(source) {
3
+ return typeof source.subscribe === "function";
4
+ }
5
+ /**
6
+ * Connects a generated View reference while the current effect scope (for
7
+ * example a component) is active and exposes its state as shallow refs. A
8
+ * changed reference disposes the previous client; disposing the scope
9
+ * disposes the current one.
10
+ *
11
+ * Pass a getter such as `() => props.page` to follow a prop. A reference is
12
+ * identified by its `connect` function, so a getter returning a new
13
+ * `{ connect: connectWorkspace }` object does not reconnect.
14
+ */
15
+ export function useView(source) {
16
+ const state = shallowRef();
17
+ const client = shallowRef();
18
+ const error = shallowRef();
19
+ let release;
20
+ function start() {
21
+ release?.();
22
+ release = undefined;
23
+ const value = toValue(source);
24
+ state.value = undefined;
25
+ client.value = undefined;
26
+ error.value = undefined;
27
+ if (!value)
28
+ return;
29
+ let active = true;
30
+ let connected;
31
+ let unsubscribe;
32
+ const observe = (next) => {
33
+ client.value = next;
34
+ unsubscribe = next.subscribe(update => { if (active)
35
+ state.value = update; });
36
+ };
37
+ release = () => {
38
+ active = false;
39
+ unsubscribe?.();
40
+ connected?.dispose();
41
+ };
42
+ if (isClient(value))
43
+ observe(value);
44
+ else
45
+ value.connect().then(next => {
46
+ if (!active) {
47
+ next.dispose();
48
+ return;
49
+ }
50
+ connected = next;
51
+ observe(next);
52
+ }, cause => { if (active)
53
+ error.value = cause; });
54
+ }
55
+ watch(() => {
56
+ const value = toValue(source);
57
+ return value ? isClient(value) ? value : value.connect : undefined;
58
+ }, start, { immediate: true });
59
+ if (getCurrentScope())
60
+ onScopeDispose(() => { release?.(); release = undefined; });
61
+ return { state, client, error, retry: start };
62
+ }
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAmC,MAAM,KAAK,CAAC;AA+BnH,SAAS,QAAQ,CAA6B,MAAwC;IACpF,OAAO,OAAQ,MAA8B,CAAC,SAAS,KAAK,UAAU,CAAC;AACzE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAA6B,MAA6C;IAC/F,MAAM,KAAK,GAAG,UAAU,EAAmC,CAAC;IAC5D,MAAM,MAAM,GAAG,UAAU,EAAuB,CAAC;IACjD,MAAM,KAAK,GAAG,UAAU,EAAW,CAAC;IACpC,IAAI,OAAiC,CAAC;IAEtC,SAAS,KAAK;QACZ,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO,GAAG,SAAS,CAAC;QACpB,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9B,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;QACxB,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC;QACzB,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,IAAI,SAA8B,CAAC;QACnC,IAAI,WAAqC,CAAC;QAC1C,MAAM,OAAO,GAAG,CAA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C,CAAC,CAAC,CAAC,CAAC;IACnF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAChD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@runic-artifex/vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.6.0-preview.1",
4
+ "description": "Vue composables for generated Runic Views clients",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "packageManager": "bun@1.4.2",
8
+ "sideEffects": false,
9
+ "files": [
10
+ "dist",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "scripts": {
24
+ "clean": "bun -e \"import('node:fs').then(({rmSync}) => rmSync('dist', { recursive: true, force: true }))\"",
25
+ "build": "bun run --bun clean && tsc -p tsconfig.build.json",
26
+ "check": "tsc -p tsconfig.json --noEmit",
27
+ "test": "bun run --bun build && vitest run",
28
+ "pack:check": "bun pm pack --dry-run"
29
+ },
30
+ "peerDependencies": {
31
+ "vue": ">=3.5.0 <4"
32
+ },
33
+ "devDependencies": {
34
+ "typescript": "6.0.3",
35
+ "vitest": "5.0.3",
36
+ "vue": "3.5.43"
37
+ },
38
+ "engines": {
39
+ "node": ">=24.18.0 <25"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "tag": "preview"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/Runic-Artifex/runic-sdk.git",
48
+ "directory": "packages/web/vue"
49
+ },
50
+ "homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/main/packages/web/vue#readme",
51
+ "bugs": {
52
+ "url": "https://github.com/Runic-Artifex/runic-sdk/issues"
53
+ },
54
+ "keywords": [
55
+ "runic-artifex",
56
+ "runic",
57
+ "views",
58
+ "vue"
59
+ ],
60
+ "gitHead": "3026ada4e531cf58ba5081d8ee53b32b60f1ab6a"
61
+ }