@md2ui/vue 0.0.0-stage → 0.1.0-alpha.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 alexrvarela
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,63 @@
1
- # Temporary Holding Version
1
+ # @md2ui/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
+ `Md2uiView`: a thin Vue component over `@md2ui/dom`'s `<md2ui-view>`, which turns a
4
+ Markdown document and an optional `THEME.md` into a painted, interactive UI.
5
+
6
+ **Experimental alpha**; the API may change between any two releases. Part of
7
+ [md2ui-ts](https://github.com/md2ui/md2ui-ts), the client for
8
+ [md2ui](https://github.com/md2ui/md2ui). Home: [md2ui.org](https://md2ui.org).
9
+
10
+ ## Install
11
+
12
+ ```sh
13
+ npm i @md2ui/dom@alpha @md2ui/vue@alpha # or: pnpm add, yarn add, bun add
14
+ ```
15
+
16
+ Peer: `vue ^3.5`. Install `@md2ui/dom` beside it, at the same version. With Vite, use
17
+ the settings in `@md2ui/dom`'s README.
18
+
19
+ ## Example
20
+
21
+ ```vue
22
+ <script setup lang="ts">
23
+ import { type Md2uiAction, Md2uiView } from "@md2ui/vue";
24
+
25
+ defineProps<{ id: string; markdown: string }>();
26
+
27
+ function onAction(event: CustomEvent<Md2uiAction>) {
28
+ console.log(event.detail);
29
+ }
30
+ </script>
31
+
32
+ <template>
33
+ <Md2uiView :markdown="markdown" :message-id="id" style="height: 480px" @action="onAction" />
34
+ </template>
35
+ ```
36
+
37
+ More in the [md2ui-ts README](https://github.com/md2ui/md2ui-ts#vue).
38
+
39
+ ## API
40
+
41
+ | Export | What it is |
42
+ |---|---|
43
+ | `Md2uiView` | The component. Its root, `$el`, is the `Md2uiViewElement`: through a template ref, `view.value.$el.release(ordinals)` |
44
+ | `FontSource`, `Md2uiAction`, `Md2uiLoadError`, `Md2uiViewElement`, `Md2uiViewProperties` | Re-exported from `@md2ui/dom` |
45
+
46
+ | Prop or event | Type |
47
+ |---|---|
48
+ | `markdown`, `messageId`, `themeSrc`, `themeText`, `assetBase`, `fonts`, `disabled`, `streaming`, `motion` | as the element's properties, each optional |
49
+ | `@action` | `CustomEvent<Md2uiAction>`; `event.preventDefault()` cancels what the view would do |
50
+ | `@error` | `CustomEvent<Md2uiLoadError>` |
51
+
52
+ No `isCustomElement` setting is needed. The component registers `<md2ui-view>` when it
53
+ mounts; to pass options, call `defineMd2uiView({ worker })` from `@md2ui/dom` before
54
+ mounting the app.
55
+
56
+ ## Requirements
57
+
58
+ Vue 3.5; current Chrome, Edge, Firefox and Safari; an ESM bundler that ships module
59
+ Workers.
60
+
61
+ ## Licence
62
+
63
+ MIT, in [`LICENSE`](LICENSE).
@@ -0,0 +1,103 @@
1
+ import { FontSource, FontSource as FontSource$1, Md2uiAction, Md2uiAction as Md2uiAction$1, Md2uiLoadError, Md2uiLoadError as Md2uiLoadError$1, Md2uiViewElement, Md2uiViewProperties, Md2uiViewProperties as Md2uiViewProperties$1 } from "@md2ui/dom";
2
+ import * as vue0 from "vue";
3
+ import { PropType } from "vue";
4
+
5
+ //#region src/index.d.ts
6
+ /** `<md2ui-view>` as a Vue component. */
7
+ declare const Md2uiView: vue0.DefineComponent<vue0.ExtractPropTypes<{
8
+ markdown: {
9
+ type: StringConstructor;
10
+ default: undefined;
11
+ };
12
+ messageId: {
13
+ type: PropType<string | null>;
14
+ default: undefined;
15
+ };
16
+ themeSrc: {
17
+ type: PropType<string | null>;
18
+ default: undefined;
19
+ };
20
+ themeText: {
21
+ type: PropType<string | null>;
22
+ default: undefined;
23
+ };
24
+ assetBase: {
25
+ type: PropType<string | null>;
26
+ default: undefined;
27
+ };
28
+ fonts: {
29
+ type: PropType<readonly FontSource$1[]>;
30
+ default: undefined;
31
+ };
32
+ disabled: {
33
+ type: BooleanConstructor;
34
+ default: undefined;
35
+ };
36
+ streaming: {
37
+ type: BooleanConstructor;
38
+ default: undefined;
39
+ };
40
+ motion: {
41
+ type: PropType<Md2uiViewProperties$1["motion"]>;
42
+ default: undefined;
43
+ };
44
+ }>, () => vue0.VNode<vue0.RendererNode, vue0.RendererElement, {
45
+ [key: string]: any;
46
+ }>, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {
47
+ /** `md2ui-action`: call `event.preventDefault()` to cancel what the view would do. */
48
+ action: (event: CustomEvent<Md2uiAction$1>) => boolean;
49
+ /** `md2ui-error`: a theme, font or image that could not load. */
50
+ error: (event: CustomEvent<Md2uiLoadError$1>) => boolean;
51
+ }, string, vue0.PublicProps, Readonly<vue0.ExtractPropTypes<{
52
+ markdown: {
53
+ type: StringConstructor;
54
+ default: undefined;
55
+ };
56
+ messageId: {
57
+ type: PropType<string | null>;
58
+ default: undefined;
59
+ };
60
+ themeSrc: {
61
+ type: PropType<string | null>;
62
+ default: undefined;
63
+ };
64
+ themeText: {
65
+ type: PropType<string | null>;
66
+ default: undefined;
67
+ };
68
+ assetBase: {
69
+ type: PropType<string | null>;
70
+ default: undefined;
71
+ };
72
+ fonts: {
73
+ type: PropType<readonly FontSource$1[]>;
74
+ default: undefined;
75
+ };
76
+ disabled: {
77
+ type: BooleanConstructor;
78
+ default: undefined;
79
+ };
80
+ streaming: {
81
+ type: BooleanConstructor;
82
+ default: undefined;
83
+ };
84
+ motion: {
85
+ type: PropType<Md2uiViewProperties$1["motion"]>;
86
+ default: undefined;
87
+ };
88
+ }>> & Readonly<{
89
+ onAction?: (event: CustomEvent<Md2uiAction$1>) => any;
90
+ onError?: (event: CustomEvent<Md2uiLoadError$1>) => any;
91
+ }>, {
92
+ motion: "auto" | "page" | "edit";
93
+ markdown: string;
94
+ messageId: string | null;
95
+ themeSrc: string | null;
96
+ themeText: string | null;
97
+ assetBase: string | null;
98
+ fonts: readonly FontSource$1[];
99
+ disabled: boolean;
100
+ streaming: boolean;
101
+ }, {}, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
102
+ //#endregion
103
+ export { type FontSource, type Md2uiAction, type Md2uiLoadError, Md2uiView, type Md2uiViewElement, type Md2uiViewProperties };
@@ -0,0 +1,91 @@
1
+ import { defineMd2uiView } from "@md2ui/dom";
2
+ import { defineComponent, h, onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
3
+
4
+ //#region src/index.ts
5
+ /**
6
+ * The order properties are set in: the theme and fonts first, then the document, then
7
+ * its message id, so a document and its id reach the view together.
8
+ */
9
+ const ORDER = Object.freeze([
10
+ "themeSrc",
11
+ "themeText",
12
+ "assetBase",
13
+ "fonts",
14
+ "disabled",
15
+ "streaming",
16
+ "motion",
17
+ "markdown",
18
+ "messageId"
19
+ ]);
20
+ /** A prop left unset leaves the element's own default. */
21
+ const text = () => ({
22
+ type: String,
23
+ default: void 0
24
+ });
25
+ const nullableText = () => ({
26
+ type: String,
27
+ default: void 0
28
+ });
29
+ /** `<md2ui-view>` as a Vue component. */
30
+ const Md2uiView = defineComponent({
31
+ name: "Md2uiView",
32
+ props: {
33
+ markdown: text(),
34
+ messageId: nullableText(),
35
+ themeSrc: nullableText(),
36
+ themeText: nullableText(),
37
+ assetBase: nullableText(),
38
+ fonts: {
39
+ type: Array,
40
+ default: void 0
41
+ },
42
+ disabled: {
43
+ type: Boolean,
44
+ default: void 0
45
+ },
46
+ streaming: {
47
+ type: Boolean,
48
+ default: void 0
49
+ },
50
+ motion: {
51
+ type: String,
52
+ default: void 0
53
+ }
54
+ },
55
+ emits: {
56
+ action: (event) => event instanceof CustomEvent,
57
+ error: (event) => event instanceof CustomEvent
58
+ },
59
+ setup(props, { emit }) {
60
+ const element = shallowRef(null);
61
+ /** What each property was last set to, so an unchanged prop is not set again. */
62
+ const applied = /* @__PURE__ */ new Map();
63
+ const apply = () => {
64
+ const node = element.value;
65
+ if (node === null) return;
66
+ for (const name of ORDER) {
67
+ const value = props[name];
68
+ if (value === void 0 || applied.get(name) === value) continue;
69
+ applied.set(name, value);
70
+ Reflect.set(node, name, value);
71
+ }
72
+ };
73
+ const action = (event) => emit("action", event);
74
+ const error = (event) => emit("error", event);
75
+ onMounted(() => {
76
+ defineMd2uiView();
77
+ apply();
78
+ element.value?.addEventListener("md2ui-action", action);
79
+ element.value?.addEventListener("md2ui-error", error);
80
+ });
81
+ watch(() => ORDER.map((name) => props[name]), apply, { flush: "post" });
82
+ onBeforeUnmount(() => {
83
+ element.value?.removeEventListener("md2ui-action", action);
84
+ element.value?.removeEventListener("md2ui-error", error);
85
+ });
86
+ return () => h("md2ui-view", { ref: element });
87
+ }
88
+ });
89
+
90
+ //#endregion
91
+ export { Md2uiView };
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@md2ui/vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "Thin Vue binding over <md2ui-view>.",
5
+ "keywords": [
6
+ "md2ui",
7
+ "markdown",
8
+ "vue",
9
+ "generative-ui",
10
+ "agent"
11
+ ],
12
+ "homepage": "https://md2ui.org",
13
+ "bugs": {
14
+ "url": "https://github.com/md2ui/md2ui-ts/issues"
15
+ },
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/md2ui/md2ui-ts.git",
20
+ "directory": "packages/vue"
21
+ },
22
+ "type": "module",
23
+ "sideEffects": false,
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/lib/index.d.ts",
27
+ "default": "./dist/lib/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist/lib"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public",
35
+ "tag": "alpha"
36
+ },
37
+ "devDependencies": {
38
+ "vue": "3.5.43"
39
+ },
40
+ "dependencies": {
41
+ "@md2ui/dom": "0.1.0-alpha.1"
42
+ },
43
+ "peerDependencies": {
44
+ "vue": "^3.5"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -b && tsdown"
48
+ }
6
49
  }