@refrakt-md/vue 0.9.2
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/dist/Renderer.d.ts +47 -0
- package/dist/Renderer.d.ts.map +1 -0
- package/dist/Renderer.js +120 -0
- package/dist/Renderer.js.map +1 -0
- package/dist/elements/Pre.d.ts +19 -0
- package/dist/elements/Pre.d.ts.map +1 -0
- package/dist/elements/Pre.js +31 -0
- package/dist/elements/Pre.js.map +1 -0
- package/dist/elements/Table.d.ts +18 -0
- package/dist/elements/Table.d.ts.map +1 -0
- package/dist/elements/Table.js +23 -0
- package/dist/elements/Table.js.map +1 -0
- package/dist/elements.d.ts +10 -0
- package/dist/elements.d.ts.map +1 -0
- package/dist/elements.js +13 -0
- package/dist/elements.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/registry.d.ts +11 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +9 -0
- package/dist/registry.js.map +1 -0
- package/dist/theme.d.ts +17 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +2 -0
- package/dist/theme.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type VNode, type Component } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Vue Renderer component for refrakt.md content (ADR-008).
|
|
4
|
+
*
|
|
5
|
+
* Recursively renders a RendererNode tree as Vue vnodes.
|
|
6
|
+
*
|
|
7
|
+
* When a tag has a `data-rune` attribute matching a registered component:
|
|
8
|
+
* 1. `extractComponentInterface` partitions children into properties, named refs, and content
|
|
9
|
+
* 2. Properties become component props (scalar strings)
|
|
10
|
+
* 3. Named refs become named slots (pre-rendered HTML)
|
|
11
|
+
* 4. Anonymous content becomes the default slot
|
|
12
|
+
* 5. The original `tag` is passed as a prop for escape-hatch access
|
|
13
|
+
*/
|
|
14
|
+
export declare const Renderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
15
|
+
node: {
|
|
16
|
+
type: any;
|
|
17
|
+
default: null;
|
|
18
|
+
};
|
|
19
|
+
components: {
|
|
20
|
+
type: () => Record<string, Component>;
|
|
21
|
+
default: undefined;
|
|
22
|
+
};
|
|
23
|
+
elements: {
|
|
24
|
+
type: () => Record<string, Component>;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
}>, () => string | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
30
|
+
node: {
|
|
31
|
+
type: any;
|
|
32
|
+
default: null;
|
|
33
|
+
};
|
|
34
|
+
components: {
|
|
35
|
+
type: () => Record<string, Component>;
|
|
36
|
+
default: undefined;
|
|
37
|
+
};
|
|
38
|
+
elements: {
|
|
39
|
+
type: () => Record<string, Component>;
|
|
40
|
+
default: undefined;
|
|
41
|
+
};
|
|
42
|
+
}>> & Readonly<{}>, {
|
|
43
|
+
components: Record<string, Component>;
|
|
44
|
+
node: any;
|
|
45
|
+
elements: Record<string, Component>;
|
|
46
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
47
|
+
//# sourceMappingURL=Renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../src/Renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAiHrE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ;;cAG8B,GAAG;;;;cACtB,MAAM,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;;;;cACjC,MAAM,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;;;;;;;cAFV,GAAG;;;;cACtB,MAAM,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;;;;cACjC,MAAM,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;;;;;;;4EAK3D,CAAC"}
|
package/dist/Renderer.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { isTag, extractComponentInterface, renderToHtml } from '@refrakt-md/transform';
|
|
3
|
+
const VOID_ELEMENTS = new Set([
|
|
4
|
+
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
|
|
5
|
+
'link', 'meta', 'param', 'source', 'track', 'wbr',
|
|
6
|
+
]);
|
|
7
|
+
/**
|
|
8
|
+
* Convert serialized tag attributes to Vue-compatible props.
|
|
9
|
+
* - Strips internal `$$mdtype` attribute
|
|
10
|
+
* - Drops null/undefined/false values
|
|
11
|
+
* - Converts `true` to empty string (bare HTML attribute)
|
|
12
|
+
*/
|
|
13
|
+
function toVueProps(attrs) {
|
|
14
|
+
const result = {};
|
|
15
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
16
|
+
if (k === '$$mdtype' || v === undefined || v === null || v === false)
|
|
17
|
+
continue;
|
|
18
|
+
result[k] = v === true ? '' : v;
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Render a single RendererNode to a VNode tree.
|
|
24
|
+
*/
|
|
25
|
+
function renderNode(node, components, elements) {
|
|
26
|
+
if (node === null || node === undefined)
|
|
27
|
+
return null;
|
|
28
|
+
if (typeof node === 'string')
|
|
29
|
+
return node;
|
|
30
|
+
if (typeof node === 'number')
|
|
31
|
+
return String(node);
|
|
32
|
+
if (Array.isArray(node)) {
|
|
33
|
+
const children = node.map(child => renderNode(child, components, elements)).filter(Boolean);
|
|
34
|
+
return children.length === 1 ? children[0] : h('template', null, children);
|
|
35
|
+
}
|
|
36
|
+
if (!isTag(node))
|
|
37
|
+
return null;
|
|
38
|
+
// Component override dispatch via data-rune attribute
|
|
39
|
+
const runeType = node.attributes?.['data-rune'];
|
|
40
|
+
const Comp = runeType && components?.[runeType];
|
|
41
|
+
if (Comp) {
|
|
42
|
+
const iface = extractComponentInterface(node);
|
|
43
|
+
// Build named slots from refs (pre-rendered HTML)
|
|
44
|
+
const slots = {};
|
|
45
|
+
for (const [name, tags] of Object.entries(iface.refs)) {
|
|
46
|
+
const html = tags.map(t => renderToHtml(t)).join('');
|
|
47
|
+
slots[name] = () => h('div', { 'data-ref': name, innerHTML: html });
|
|
48
|
+
}
|
|
49
|
+
// Default slot from anonymous children
|
|
50
|
+
if (iface.children.length > 0) {
|
|
51
|
+
const childVnodes = iface.children
|
|
52
|
+
.map(child => renderNode(child, components, elements))
|
|
53
|
+
.filter(Boolean);
|
|
54
|
+
slots.default = () => h('template', null, childVnodes);
|
|
55
|
+
}
|
|
56
|
+
return h(Comp, { ...iface.properties, tag: node }, slots);
|
|
57
|
+
}
|
|
58
|
+
// Element override dispatch via tag name
|
|
59
|
+
const ElementOverride = elements?.[node.name];
|
|
60
|
+
if (ElementOverride) {
|
|
61
|
+
const childVnodes = node.children
|
|
62
|
+
.map(child => renderNode(child, components, elements))
|
|
63
|
+
.filter(Boolean);
|
|
64
|
+
return h(ElementOverride, { tag: node }, { default: () => childVnodes });
|
|
65
|
+
}
|
|
66
|
+
// SVG — render as raw HTML to avoid namespace issues
|
|
67
|
+
if (node.name === 'svg') {
|
|
68
|
+
return h('span', { innerHTML: renderToHtml(node) });
|
|
69
|
+
}
|
|
70
|
+
// Null-named tags (Markdoc document root) — render children without wrapper
|
|
71
|
+
if (!node.name) {
|
|
72
|
+
const childVnodes = node.children
|
|
73
|
+
.map(child => renderNode(child, components, elements))
|
|
74
|
+
.filter(Boolean);
|
|
75
|
+
return h('template', null, childVnodes);
|
|
76
|
+
}
|
|
77
|
+
// Void elements
|
|
78
|
+
if (VOID_ELEMENTS.has(node.name)) {
|
|
79
|
+
return h(node.name, toVueProps(node.attributes));
|
|
80
|
+
}
|
|
81
|
+
// Raw HTML content (code blocks, raw-html attribute)
|
|
82
|
+
const isRaw = node.attributes?.['data-codeblock'] || node.attributes?.['data-raw-html'];
|
|
83
|
+
if (isRaw) {
|
|
84
|
+
const html = node.children.map(child => {
|
|
85
|
+
if (typeof child === 'string')
|
|
86
|
+
return child;
|
|
87
|
+
return renderToHtml(child);
|
|
88
|
+
}).join('');
|
|
89
|
+
return h(node.name, { ...toVueProps(node.attributes), innerHTML: html });
|
|
90
|
+
}
|
|
91
|
+
// Regular HTML element — recursively render children
|
|
92
|
+
const childVnodes = node.children
|
|
93
|
+
.map(child => renderNode(child, components, elements))
|
|
94
|
+
.filter(Boolean);
|
|
95
|
+
return h(node.name, toVueProps(node.attributes), childVnodes);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Vue Renderer component for refrakt.md content (ADR-008).
|
|
99
|
+
*
|
|
100
|
+
* Recursively renders a RendererNode tree as Vue vnodes.
|
|
101
|
+
*
|
|
102
|
+
* When a tag has a `data-rune` attribute matching a registered component:
|
|
103
|
+
* 1. `extractComponentInterface` partitions children into properties, named refs, and content
|
|
104
|
+
* 2. Properties become component props (scalar strings)
|
|
105
|
+
* 3. Named refs become named slots (pre-rendered HTML)
|
|
106
|
+
* 4. Anonymous content becomes the default slot
|
|
107
|
+
* 5. The original `tag` is passed as a prop for escape-hatch access
|
|
108
|
+
*/
|
|
109
|
+
export const Renderer = defineComponent({
|
|
110
|
+
name: 'RfRenderer',
|
|
111
|
+
props: {
|
|
112
|
+
node: { type: [Object, String, Number, Array], default: null },
|
|
113
|
+
components: { type: Object, default: undefined },
|
|
114
|
+
elements: { type: Object, default: undefined },
|
|
115
|
+
},
|
|
116
|
+
setup(props) {
|
|
117
|
+
return () => renderNode(props.node, props.components, props.elements);
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=Renderer.js.map
|
|
@@ -0,0 +1 @@
|
|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M,QAAQ,GAAG,eAAe,CAAC;IACvC,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE;QACN,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAQ,EAAE,OAAO,EAAE,IAAI,EAAE;QACrE,UAAU,EAAE,EAAE,IAAI,EAAE,MAAyC,EAAE,OAAO,EAAE,SAAS,EAAE;QACnF,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAyC,EAAE,OAAO,EAAE,SAAS,EAAE;KACjF;IACD,KAAK,CAAC,KAAK;QACV,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvE,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SerializedTag } from '@refrakt-md/types';
|
|
2
|
+
/**
|
|
3
|
+
* Pre element override — wraps code blocks in the rf-codeblock structure
|
|
4
|
+
* that @refrakt-md/behaviors enhances with a copy button.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Pre: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
7
|
+
tag: {
|
|
8
|
+
type: () => SerializedTag;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
+
tag: {
|
|
15
|
+
type: () => SerializedTag;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
19
|
+
//# sourceMappingURL=Pre.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pre.d.ts","sourceRoot":"","sources":["../../src/elements/Pre.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,GAAG;;cAGS,MAAM,aAAa;;;;;;;cAAnB,MAAM,aAAa;;;iGAgB1C,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Pre element override — wraps code blocks in the rf-codeblock structure
|
|
4
|
+
* that @refrakt-md/behaviors enhances with a copy button.
|
|
5
|
+
*/
|
|
6
|
+
export const Pre = defineComponent({
|
|
7
|
+
name: 'RfPre',
|
|
8
|
+
props: {
|
|
9
|
+
tag: { type: Object, required: true },
|
|
10
|
+
},
|
|
11
|
+
setup(props, { slots }) {
|
|
12
|
+
return () => {
|
|
13
|
+
const isCodeBlock = 'data-language' in (props.tag.attributes || {});
|
|
14
|
+
const attrs = filterAttrs(props.tag.attributes);
|
|
15
|
+
if (isCodeBlock) {
|
|
16
|
+
return h('div', { class: 'rf-codeblock' }, h('pre', attrs, slots.default?.()));
|
|
17
|
+
}
|
|
18
|
+
return h('pre', attrs, slots.default?.());
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
function filterAttrs(attrs) {
|
|
23
|
+
const result = {};
|
|
24
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
25
|
+
if (k === '$$mdtype' || v === undefined || v === null || v === false)
|
|
26
|
+
continue;
|
|
27
|
+
result[k] = v === true ? '' : v;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=Pre.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pre.js","sourceRoot":"","sources":["../../src/elements/Pre.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,E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ACf,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SerializedTag } from '@refrakt-md/types';
|
|
2
|
+
/**
|
|
3
|
+
* Table element override — wraps <table> in a scrollable container.
|
|
4
|
+
*/
|
|
5
|
+
export declare const Table: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
6
|
+
tag: {
|
|
7
|
+
type: () => SerializedTag;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
13
|
+
tag: {
|
|
14
|
+
type: () => SerializedTag;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
18
|
+
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/elements/Table.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,KAAK;;cAGO,MAAM,aAAa;;;;;;;cAAnB,MAAM,aAAa;;;iGAO1C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Table element override — wraps <table> in a scrollable container.
|
|
4
|
+
*/
|
|
5
|
+
export const Table = defineComponent({
|
|
6
|
+
name: 'RfTable',
|
|
7
|
+
props: {
|
|
8
|
+
tag: { type: Object, required: true },
|
|
9
|
+
},
|
|
10
|
+
setup(props, { slots }) {
|
|
11
|
+
return () => h('div', { class: 'rf-table-wrapper' }, h('table', filterAttrs(props.tag.attributes), slots.default?.()));
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
function filterAttrs(attrs) {
|
|
15
|
+
const result = {};
|
|
16
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
17
|
+
if (k === '$$mdtype' || v === undefined || v === null || v === false)
|
|
18
|
+
continue;
|
|
19
|
+
result[k] = v === true ? '' : v;
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=Table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.js","sourceRoot":"","sources":["../../src/elements/Table.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGzC;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,eAAe,CAAC;IACpC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE;QACN,GAAG,EAAE,EAAE,IAAI,EAAE,MAA6B,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC5D;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACrB,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAClD,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAChE,CAAC;IACH,CAAC;CACD,CAAC,CAAC;AAEH,SAAS,WAAW,CAAC,KAA0B;IAC9C,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK;YAAE,SAAS;QAC/E,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
export type ElementOverrides = Record<string, Component>;
|
|
3
|
+
/**
|
|
4
|
+
* Default element overrides for the Vue renderer.
|
|
5
|
+
*
|
|
6
|
+
* - `table`: Wraps in scrollable container
|
|
7
|
+
* - `pre`: Wraps code blocks in rf-codeblock structure for behaviors
|
|
8
|
+
*/
|
|
9
|
+
export declare const elements: ElementOverrides;
|
|
10
|
+
//# sourceMappingURL=elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../src/elements.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAIrC,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,gBAGtB,CAAC"}
|
package/dist/elements.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Table } from './elements/Table.js';
|
|
2
|
+
import { Pre } from './elements/Pre.js';
|
|
3
|
+
/**
|
|
4
|
+
* Default element overrides for the Vue renderer.
|
|
5
|
+
*
|
|
6
|
+
* - `table`: Wraps in scrollable container
|
|
7
|
+
* - `pre`: Wraps code blocks in rf-codeblock structure for behaviors
|
|
8
|
+
*/
|
|
9
|
+
export const elements = {
|
|
10
|
+
table: Table,
|
|
11
|
+
pre: Pre,
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=elements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.js","sourceRoot":"","sources":["../src/elements.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAIxC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAqB;IACzC,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,GAAG;CACR,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Renderer } from './Renderer.js';
|
|
2
|
+
export type { VueTheme } from './theme.js';
|
|
3
|
+
export { registry } from './registry.js';
|
|
4
|
+
export type { ComponentRegistry } from './registry.js';
|
|
5
|
+
export { elements } from './elements.js';
|
|
6
|
+
export type { ElementOverrides } from './elements.js';
|
|
7
|
+
export { Table } from './elements/Table.js';
|
|
8
|
+
export { Pre } from './elements/Pre.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Renderer
|
|
2
|
+
export { Renderer } from './Renderer.js';
|
|
3
|
+
// Component registry
|
|
4
|
+
export { registry } from './registry.js';
|
|
5
|
+
// Element overrides
|
|
6
|
+
export { elements } from './elements.js';
|
|
7
|
+
// Element override components
|
|
8
|
+
export { Table } from './elements/Table.js';
|
|
9
|
+
export { Pre } from './elements/Pre.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKzC,qBAAqB;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,oBAAoB;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,8BAA8B;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
export type ComponentRegistry = Record<string, Component>;
|
|
3
|
+
/**
|
|
4
|
+
* Default component registry — empty by default.
|
|
5
|
+
*
|
|
6
|
+
* All runes render through the identity transform + @refrakt-md/behaviors.
|
|
7
|
+
* Theme authors register component overrides for runes that need
|
|
8
|
+
* custom Vue rendering.
|
|
9
|
+
*/
|
|
10
|
+
export declare const registry: ComponentRegistry;
|
|
11
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,EAAE,iBAAsB,CAAC"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default component registry — empty by default.
|
|
3
|
+
*
|
|
4
|
+
* All runes render through the identity transform + @refrakt-md/behaviors.
|
|
5
|
+
* Theme authors register component overrides for runes that need
|
|
6
|
+
* custom Vue rendering.
|
|
7
|
+
*/
|
|
8
|
+
export const registry = {};
|
|
9
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAsB,EAAE,CAAC"}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ThemeManifest } from '@refrakt-md/types';
|
|
2
|
+
import type { LayoutConfig } from '@refrakt-md/transform';
|
|
3
|
+
import type { Component } from 'vue';
|
|
4
|
+
/**
|
|
5
|
+
* A resolved Vue theme: the manifest plus live component references.
|
|
6
|
+
* This is the runtime contract between a theme package and the Vue renderer.
|
|
7
|
+
*/
|
|
8
|
+
export interface VueTheme {
|
|
9
|
+
manifest: ThemeManifest;
|
|
10
|
+
/** Layout name → declarative LayoutConfig */
|
|
11
|
+
layouts: Record<string, LayoutConfig>;
|
|
12
|
+
/** typeof name → Vue component (the component registry) */
|
|
13
|
+
components: Record<string, Component>;
|
|
14
|
+
/** HTML element name → Vue component (element-level overrides) */
|
|
15
|
+
elements?: Record<string, Component>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACxB,QAAQ,EAAE,aAAa,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACrC"}
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@refrakt-md/vue",
|
|
3
|
+
"description": "Vue renderer for refrakt.md content — ADR-008 component interface with props and named slots",
|
|
4
|
+
"version": "0.9.2",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/refrakt-md/refrakt.git",
|
|
10
|
+
"directory": "packages/vue"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/refrakt-md/refrakt/issues",
|
|
13
|
+
"homepage": "https://github.com/refrakt-md/refrakt",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@refrakt-md/transform": "0.9.2",
|
|
33
|
+
"@refrakt-md/types": "0.9.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"vue": "^3.5.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"vue": "^3.4.0"
|
|
40
|
+
}
|
|
41
|
+
}
|