@mobile-reality/mdma-renderer-vue 0.2.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 +21 -0
- package/README.md +117 -0
- package/dist/components/ApprovalGateRenderer.d.ts +40 -0
- package/dist/components/ApprovalGateRenderer.d.ts.map +1 -0
- package/dist/components/ApprovalGateRenderer.js +48 -0
- package/dist/components/ApprovalGateRenderer.js.map +1 -0
- package/dist/components/ButtonRenderer.d.ts +40 -0
- package/dist/components/ButtonRenderer.d.ts.map +1 -0
- package/dist/components/ButtonRenderer.js +28 -0
- package/dist/components/ButtonRenderer.js.map +1 -0
- package/dist/components/CalloutRenderer.d.ts +40 -0
- package/dist/components/CalloutRenderer.d.ts.map +1 -0
- package/dist/components/CalloutRenderer.js +39 -0
- package/dist/components/CalloutRenderer.js.map +1 -0
- package/dist/components/ChartRenderer.d.ts +45 -0
- package/dist/components/ChartRenderer.d.ts.map +1 -0
- package/dist/components/ChartRenderer.js +66 -0
- package/dist/components/ChartRenderer.js.map +1 -0
- package/dist/components/CustomRenderer.d.ts +45 -0
- package/dist/components/CustomRenderer.d.ts.map +1 -0
- package/dist/components/CustomRenderer.js +32 -0
- package/dist/components/CustomRenderer.js.map +1 -0
- package/dist/components/FormRenderer.d.ts +41 -0
- package/dist/components/FormRenderer.d.ts.map +1 -0
- package/dist/components/FormRenderer.js +291 -0
- package/dist/components/FormRenderer.js.map +1 -0
- package/dist/components/MdastRenderer.d.ts +37 -0
- package/dist/components/MdastRenderer.d.ts.map +1 -0
- package/dist/components/MdastRenderer.js +102 -0
- package/dist/components/MdastRenderer.js.map +1 -0
- package/dist/components/MdmaBlock.d.ts +36 -0
- package/dist/components/MdmaBlock.d.ts.map +1 -0
- package/dist/components/MdmaBlock.js +40 -0
- package/dist/components/MdmaBlock.js.map +1 -0
- package/dist/components/MdmaBlockLoading.d.ts +29 -0
- package/dist/components/MdmaBlockLoading.d.ts.map +1 -0
- package/dist/components/MdmaBlockLoading.js +30 -0
- package/dist/components/MdmaBlockLoading.js.map +1 -0
- package/dist/components/MdmaDocument.d.ts +109 -0
- package/dist/components/MdmaDocument.d.ts.map +1 -0
- package/dist/components/MdmaDocument.js +190 -0
- package/dist/components/MdmaDocument.js.map +1 -0
- package/dist/components/TableRenderer.d.ts +40 -0
- package/dist/components/TableRenderer.d.ts.map +1 -0
- package/dist/components/TableRenderer.js +65 -0
- package/dist/components/TableRenderer.js.map +1 -0
- package/dist/components/TasklistRenderer.d.ts +40 -0
- package/dist/components/TasklistRenderer.d.ts.map +1 -0
- package/dist/components/TasklistRenderer.js +49 -0
- package/dist/components/TasklistRenderer.js.map +1 -0
- package/dist/components/ThinkingRenderer.d.ts +45 -0
- package/dist/components/ThinkingRenderer.d.ts.map +1 -0
- package/dist/components/ThinkingRenderer.js +48 -0
- package/dist/components/ThinkingRenderer.js.map +1 -0
- package/dist/components/WebhookRenderer.d.ts +40 -0
- package/dist/components/WebhookRenderer.d.ts.map +1 -0
- package/dist/components/WebhookRenderer.js +41 -0
- package/dist/components/WebhookRenderer.js.map +1 -0
- package/dist/composables/use-document-store.d.ts +22 -0
- package/dist/composables/use-document-store.d.ts.map +1 -0
- package/dist/composables/use-document-store.js +84 -0
- package/dist/composables/use-document-store.js.map +1 -0
- package/dist/context/CustomVariantContext.d.ts +41 -0
- package/dist/context/CustomVariantContext.d.ts.map +1 -0
- package/dist/context/CustomVariantContext.js +17 -0
- package/dist/context/CustomVariantContext.js.map +1 -0
- package/dist/context/ElementOverridesContext.d.ts +111 -0
- package/dist/context/ElementOverridesContext.d.ts.map +1 -0
- package/dist/context/ElementOverridesContext.js +31 -0
- package/dist/context/ElementOverridesContext.js.map +1 -0
- package/dist/context/MdmaProvider.d.ts +50 -0
- package/dist/context/MdmaProvider.d.ts.map +1 -0
- package/dist/context/MdmaProvider.js +35 -0
- package/dist/context/MdmaProvider.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/renderers/renderer-props.d.ts +51 -0
- package/dist/renderers/renderer-props.d.ts.map +1 -0
- package/dist/renderers/renderer-props.js +30 -0
- package/dist/renderers/renderer-props.js.map +1 -0
- package/dist/renderers/renderer-registry.d.ts +18 -0
- package/dist/renderers/renderer-registry.d.ts.map +1 -0
- package/dist/renderers/renderer-registry.js +52 -0
- package/dist/renderers/renderer-registry.js.map +1 -0
- package/dist/theme/MdmaThemeProvider.d.ts +152 -0
- package/dist/theme/MdmaThemeProvider.d.ts.map +1 -0
- package/dist/theme/MdmaThemeProvider.js +169 -0
- package/dist/theme/MdmaThemeProvider.js.map +1 -0
- package/package.json +60 -0
- package/styles.css +1045 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAIb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,SAAS,EAAuB,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAA2B,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAA8B,MAAM,kCAAkC,CAAC;AAChG,OAAO,EACL,YAAY,EACZ,cAAc,GAGf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,SAAS,GAKV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,wBAAwB,EACxB,kBAAkB,GAUnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,GACX,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,GAGnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAKlB,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Component, PropType } from 'vue';
|
|
2
|
+
import type { MdmaComponent, StoreAction } from '@mobile-reality/mdma-spec';
|
|
3
|
+
import type { ComponentState } from '@mobile-reality/mdma-runtime';
|
|
4
|
+
/** The props every block renderer receives from `MdmaBlock`. */
|
|
5
|
+
export interface MdmaBlockRendererProps {
|
|
6
|
+
component: MdmaComponent;
|
|
7
|
+
componentState: ComponentState | undefined;
|
|
8
|
+
dispatch: (action: StoreAction) => void;
|
|
9
|
+
resolveBinding: (expr: string) => unknown;
|
|
10
|
+
}
|
|
11
|
+
/** A Vue component that accepts {@link MdmaBlockRendererProps}. */
|
|
12
|
+
export type MdmaBlockRenderer = Component;
|
|
13
|
+
/**
|
|
14
|
+
* Runtime prop declaration matching {@link MdmaBlockRendererProps}. Spread it
|
|
15
|
+
* into a `defineComponent` so a custom renderer declares exactly the props
|
|
16
|
+
* `MdmaBlock` passes — Vue would otherwise drop them onto the root element as
|
|
17
|
+
* attributes.
|
|
18
|
+
*
|
|
19
|
+
* This lives apart from `renderer-registry.ts` on purpose: the registry imports
|
|
20
|
+
* every built-in renderer, and each renderer needs this declaration, so keeping
|
|
21
|
+
* them in one module would be a cycle. Unlike React's type-only props, this
|
|
22
|
+
* value is read while the component modules evaluate, so the cycle would
|
|
23
|
+
* actually break at runtime.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* defineComponent({
|
|
28
|
+
* props: blockRendererProps,
|
|
29
|
+
* setup(props) { ... },
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const blockRendererProps: {
|
|
34
|
+
component: {
|
|
35
|
+
type: PropType<MdmaComponent>;
|
|
36
|
+
required: true;
|
|
37
|
+
};
|
|
38
|
+
componentState: {
|
|
39
|
+
type: PropType<ComponentState>;
|
|
40
|
+
default: undefined;
|
|
41
|
+
};
|
|
42
|
+
dispatch: {
|
|
43
|
+
type: PropType<(action: StoreAction) => void>;
|
|
44
|
+
required: true;
|
|
45
|
+
};
|
|
46
|
+
resolveBinding: {
|
|
47
|
+
type: PropType<(expr: string) => unknown>;
|
|
48
|
+
required: true;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=renderer-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-props.d.ts","sourceRoot":"","sources":["../../src/renderers/renderer-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,gEAAgE;AAChE,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,aAAa,CAAC;IACzB,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;IAC3C,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3C;AAED,mEAAmE;AACnE,MAAM,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,kBAAkB;;cACA,QAAQ,CAAC,aAAa,CAAC;;;;cAClB,QAAQ,CAAC,cAAc,CAAC;;;;cAC5B,QAAQ,CAAC,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;;;;cAEjD,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;;;CAGxD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime prop declaration matching {@link MdmaBlockRendererProps}. Spread it
|
|
3
|
+
* into a `defineComponent` so a custom renderer declares exactly the props
|
|
4
|
+
* `MdmaBlock` passes — Vue would otherwise drop them onto the root element as
|
|
5
|
+
* attributes.
|
|
6
|
+
*
|
|
7
|
+
* This lives apart from `renderer-registry.ts` on purpose: the registry imports
|
|
8
|
+
* every built-in renderer, and each renderer needs this declaration, so keeping
|
|
9
|
+
* them in one module would be a cycle. Unlike React's type-only props, this
|
|
10
|
+
* value is read while the component modules evaluate, so the cycle would
|
|
11
|
+
* actually break at runtime.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* defineComponent({
|
|
16
|
+
* props: blockRendererProps,
|
|
17
|
+
* setup(props) { ... },
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const blockRendererProps = {
|
|
22
|
+
component: { type: Object, required: true },
|
|
23
|
+
componentState: { type: Object, default: undefined },
|
|
24
|
+
dispatch: { type: Function, required: true },
|
|
25
|
+
resolveBinding: {
|
|
26
|
+
type: Function,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=renderer-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-props.js","sourceRoot":"","sources":["../../src/renderers/renderer-props.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS,EAAE,EAAE,IAAI,EAAE,MAAiC,EAAE,QAAQ,EAAE,IAAa,EAAE;IAC/E,cAAc,EAAE,EAAE,IAAI,EAAE,MAAkC,EAAE,OAAO,EAAE,SAAS,EAAE;IAChF,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAmD,EAAE,QAAQ,EAAE,IAAa,EAAE;IAChG,cAAc,EAAE;QACd,IAAI,EAAE,QAA+C;QACrD,QAAQ,EAAE,IAAa;KACxB;CACF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MdmaBlockRenderer } from './renderer-props.js';
|
|
2
|
+
export { blockRendererProps, type MdmaBlockRenderer, type MdmaBlockRendererProps, } from './renderer-props.js';
|
|
3
|
+
export declare class RendererRegistry {
|
|
4
|
+
private renderers;
|
|
5
|
+
register(type: string, renderer: MdmaBlockRenderer): void;
|
|
6
|
+
get(type: string): MdmaBlockRenderer | undefined;
|
|
7
|
+
has(type: string): boolean;
|
|
8
|
+
/** Convert to a plain record for passing as the `renderers` prop. */
|
|
9
|
+
toRecord(): Record<string, MdmaBlockRenderer>;
|
|
10
|
+
}
|
|
11
|
+
/** Built-in renderers for all core MDMA component types. */
|
|
12
|
+
export declare const defaultRenderers: Record<string, MdmaBlockRenderer>;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new RendererRegistry pre-populated with all built-in renderers.
|
|
15
|
+
* Register additional renderers to extend or override defaults.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createRendererRegistry(): RendererRegistry;
|
|
18
|
+
//# sourceMappingURL=renderer-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-registry.d.ts","sourceRoot":"","sources":["../../src/renderers/renderer-registry.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EACL,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAwC;IAEzD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAIzD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAIhD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1B,qEAAqE;IACrE,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC;CAG9C;AAED,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAW9D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CAMzD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FormRenderer } from '../components/FormRenderer.js';
|
|
2
|
+
import { ButtonRenderer } from '../components/ButtonRenderer.js';
|
|
3
|
+
import { TasklistRenderer } from '../components/TasklistRenderer.js';
|
|
4
|
+
import { TableRenderer } from '../components/TableRenderer.js';
|
|
5
|
+
import { CalloutRenderer } from '../components/CalloutRenderer.js';
|
|
6
|
+
import { ApprovalGateRenderer } from '../components/ApprovalGateRenderer.js';
|
|
7
|
+
import { WebhookRenderer } from '../components/WebhookRenderer.js';
|
|
8
|
+
import { ChartRenderer } from '../components/ChartRenderer.js';
|
|
9
|
+
import { ThinkingRenderer } from '../components/ThinkingRenderer.js';
|
|
10
|
+
import { CustomRenderer } from '../components/CustomRenderer.js';
|
|
11
|
+
export { blockRendererProps, } from './renderer-props.js';
|
|
12
|
+
export class RendererRegistry {
|
|
13
|
+
renderers = new Map();
|
|
14
|
+
register(type, renderer) {
|
|
15
|
+
this.renderers.set(type, renderer);
|
|
16
|
+
}
|
|
17
|
+
get(type) {
|
|
18
|
+
return this.renderers.get(type);
|
|
19
|
+
}
|
|
20
|
+
has(type) {
|
|
21
|
+
return this.renderers.has(type);
|
|
22
|
+
}
|
|
23
|
+
/** Convert to a plain record for passing as the `renderers` prop. */
|
|
24
|
+
toRecord() {
|
|
25
|
+
return Object.fromEntries(this.renderers);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Built-in renderers for all core MDMA component types. */
|
|
29
|
+
export const defaultRenderers = {
|
|
30
|
+
form: FormRenderer,
|
|
31
|
+
button: ButtonRenderer,
|
|
32
|
+
tasklist: TasklistRenderer,
|
|
33
|
+
table: TableRenderer,
|
|
34
|
+
callout: CalloutRenderer,
|
|
35
|
+
'approval-gate': ApprovalGateRenderer,
|
|
36
|
+
webhook: WebhookRenderer,
|
|
37
|
+
chart: ChartRenderer,
|
|
38
|
+
thinking: ThinkingRenderer,
|
|
39
|
+
custom: CustomRenderer,
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Create a new RendererRegistry pre-populated with all built-in renderers.
|
|
43
|
+
* Register additional renderers to extend or override defaults.
|
|
44
|
+
*/
|
|
45
|
+
export function createRendererRegistry() {
|
|
46
|
+
const registry = new RendererRegistry();
|
|
47
|
+
for (const [type, renderer] of Object.entries(defaultRenderers)) {
|
|
48
|
+
registry.register(type, renderer);
|
|
49
|
+
}
|
|
50
|
+
return registry;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=renderer-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer-registry.js","sourceRoot":"","sources":["../../src/renderers/renderer-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,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Q,EAAE,gBAAgB;IAC1B,MAAM,EAAE,cAAc;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAChE,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type ComputedRef, type CSSProperties, type InjectionKey, type PropType } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Design tokens for the web renderer. This is the typed mirror of the CSS
|
|
4
|
+
* custom properties in `styles.css`: the same token shape the React and React
|
|
5
|
+
* Native renderers expose, so a theme object is portable between all three.
|
|
6
|
+
*
|
|
7
|
+
* You rarely need to read these tokens directly — the components are styled via
|
|
8
|
+
* `.mdma-*` classes that read the matching `--mdma-*` CSS variables. A custom
|
|
9
|
+
* theme just rewrites those variables (see {@link MdmaThemeProvider}).
|
|
10
|
+
*/
|
|
11
|
+
export interface MdmaTheme {
|
|
12
|
+
colors: {
|
|
13
|
+
background: string;
|
|
14
|
+
surface: string;
|
|
15
|
+
text: string;
|
|
16
|
+
textMuted: string;
|
|
17
|
+
border: string;
|
|
18
|
+
primary: string;
|
|
19
|
+
onPrimary: string;
|
|
20
|
+
secondary: string;
|
|
21
|
+
onSecondary: string;
|
|
22
|
+
danger: string;
|
|
23
|
+
onDanger: string;
|
|
24
|
+
/** Callout variant accents + soft backgrounds. */
|
|
25
|
+
info: string;
|
|
26
|
+
infoBg: string;
|
|
27
|
+
warning: string;
|
|
28
|
+
warningBg: string;
|
|
29
|
+
error: string;
|
|
30
|
+
errorBg: string;
|
|
31
|
+
success: string;
|
|
32
|
+
successBg: string;
|
|
33
|
+
};
|
|
34
|
+
spacing: {
|
|
35
|
+
xs: number;
|
|
36
|
+
sm: number;
|
|
37
|
+
md: number;
|
|
38
|
+
lg: number;
|
|
39
|
+
};
|
|
40
|
+
radius: {
|
|
41
|
+
sm: number;
|
|
42
|
+
md: number;
|
|
43
|
+
};
|
|
44
|
+
fontSize: {
|
|
45
|
+
small: number;
|
|
46
|
+
body: number;
|
|
47
|
+
label: number;
|
|
48
|
+
title: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Built-in light palette — matches the default `--mdma-*` values in `styles.css`. */
|
|
52
|
+
export declare const lightTheme: MdmaTheme;
|
|
53
|
+
/** Built-in dark palette — matches the `[data-theme='dark']` block in `styles.css`. */
|
|
54
|
+
export declare const darkTheme: MdmaTheme;
|
|
55
|
+
/**
|
|
56
|
+
* What can be passed as a `theme`:
|
|
57
|
+
* - `'light'` / `'dark'` — the built-in palettes (applied via `data-theme`).
|
|
58
|
+
* - `'auto'` — follows the OS `prefers-color-scheme`.
|
|
59
|
+
* - a full {@link MdmaTheme} — custom tokens, written inline as CSS variables.
|
|
60
|
+
* - `undefined` — no theme; the stylesheet's default (light) tokens apply.
|
|
61
|
+
*/
|
|
62
|
+
export type MdmaThemeInput = MdmaTheme | 'light' | 'dark' | 'auto';
|
|
63
|
+
export interface ResolvedThemeProps {
|
|
64
|
+
/** `data-theme` attribute value, when a built-in palette is selected. */
|
|
65
|
+
dataTheme?: 'light' | 'dark' | 'auto';
|
|
66
|
+
/** Inline CSS variables, when a custom theme object is provided. */
|
|
67
|
+
style?: CSSProperties;
|
|
68
|
+
/** The resolved token object exposed via {@link useMdmaTheme}. */
|
|
69
|
+
theme: MdmaTheme;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Injection key for the nearest resolved theme. Holds the full
|
|
73
|
+
* {@link ResolvedThemeProps} (not just the tokens) so a descendant
|
|
74
|
+
* `MdmaDocument` with no `theme` prop of its own can inherit the ancestor's
|
|
75
|
+
* `data-theme` / inline variables and re-apply them to its own root.
|
|
76
|
+
*/
|
|
77
|
+
export declare const MdmaThemeKey: InjectionKey<ComputedRef<ResolvedThemeProps>>;
|
|
78
|
+
/**
|
|
79
|
+
* The nearest resolved theme props, or the unthemed light default. Internal —
|
|
80
|
+
* `MdmaDocument` uses it to inherit an ancestor provider's theme.
|
|
81
|
+
*/
|
|
82
|
+
export declare function useResolvedTheme(): ComputedRef<ResolvedThemeProps>;
|
|
83
|
+
/**
|
|
84
|
+
* The resolved token object for the nearest theme (defaults to {@link lightTheme}).
|
|
85
|
+
*
|
|
86
|
+
* Unlike the React renderer's `useMdmaTheme`, this returns a `ComputedRef` so the
|
|
87
|
+
* tokens stay reactive when an ancestor's `theme` prop changes — read it as
|
|
88
|
+
* `theme.value` in `setup`, or unwrapped in a template.
|
|
89
|
+
*/
|
|
90
|
+
export declare function useMdmaTheme(): ComputedRef<MdmaTheme>;
|
|
91
|
+
/**
|
|
92
|
+
* Convert an {@link MdmaTheme} into the inline CSS-variable style object the
|
|
93
|
+
* `.mdma-*` classes read. Numeric scales are emitted as `px`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function themeToCssVars(theme: MdmaTheme): CSSProperties;
|
|
96
|
+
/**
|
|
97
|
+
* Resolve a {@link MdmaThemeInput} into the DOM props that apply it: a
|
|
98
|
+
* `data-theme` attribute for built-in palettes, or inline CSS variables for a
|
|
99
|
+
* custom theme. Shared by {@link MdmaThemeProvider} and `MdmaDocument`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function resolveThemeProps(theme: MdmaThemeInput | undefined): ResolvedThemeProps;
|
|
102
|
+
/**
|
|
103
|
+
* Standalone theme wrapper for rendering MDMA components *without* `MdmaDocument`
|
|
104
|
+
* (e.g. a lone `<MdmaBlock>`). Renders a `.mdma-theme-root` element carrying the
|
|
105
|
+
* theme so the `--mdma-*` variables cascade to everything inside. When you use
|
|
106
|
+
* `MdmaDocument`, pass `theme` to it directly instead — it themes its own root.
|
|
107
|
+
*/
|
|
108
|
+
export declare const MdmaThemeProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
109
|
+
/** `'light'` | `'dark'` | `'auto'`, or a full {@link MdmaTheme}. */
|
|
110
|
+
theme: {
|
|
111
|
+
type: PropType<MdmaThemeInput>;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
/** Extra class names for the wrapper element. */
|
|
115
|
+
class: {
|
|
116
|
+
type: StringConstructor;
|
|
117
|
+
default: undefined;
|
|
118
|
+
};
|
|
119
|
+
/** Extra inline styles, merged after the theme's CSS variables. */
|
|
120
|
+
style: {
|
|
121
|
+
type: PropType<CSSProperties>;
|
|
122
|
+
default: undefined;
|
|
123
|
+
};
|
|
124
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
125
|
+
[key: string]: any;
|
|
126
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
127
|
+
/** `'light'` | `'dark'` | `'auto'`, or a full {@link MdmaTheme}. */
|
|
128
|
+
theme: {
|
|
129
|
+
type: PropType<MdmaThemeInput>;
|
|
130
|
+
default: undefined;
|
|
131
|
+
};
|
|
132
|
+
/** Extra class names for the wrapper element. */
|
|
133
|
+
class: {
|
|
134
|
+
type: StringConstructor;
|
|
135
|
+
default: undefined;
|
|
136
|
+
};
|
|
137
|
+
/** Extra inline styles, merged after the theme's CSS variables. */
|
|
138
|
+
style: {
|
|
139
|
+
type: PropType<CSSProperties>;
|
|
140
|
+
default: undefined;
|
|
141
|
+
};
|
|
142
|
+
}>> & Readonly<{}>, {
|
|
143
|
+
theme: MdmaThemeInput;
|
|
144
|
+
class: string;
|
|
145
|
+
style: CSSProperties;
|
|
146
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
147
|
+
export type MdmaThemeProviderProps = {
|
|
148
|
+
theme?: MdmaThemeInput;
|
|
149
|
+
class?: string;
|
|
150
|
+
style?: CSSProperties;
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=MdmaThemeProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MdmaThemeProvider.d.ts","sourceRoot":"","sources":["../../src/theme/MdmaThemeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,KAAK,CAAC;AAEb;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,kDAAkD;QAClD,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5D,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,QA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AmE;;cAC1C,QAAQ,CAAC,aAAa,CAAC;;;;;;;4EAiBlD,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { computed, defineComponent, h, inject, provide, } from 'vue';
|
|
2
|
+
/** Built-in light palette — matches the default `--mdma-*` values in `styles.css`. */
|
|
3
|
+
export const lightTheme = {
|
|
4
|
+
colors: {
|
|
5
|
+
background: '#ffffff',
|
|
6
|
+
surface: '#f8f9fa',
|
|
7
|
+
text: '#333333',
|
|
8
|
+
textMuted: '#666666',
|
|
9
|
+
border: '#e0e0e0',
|
|
10
|
+
primary: '#6c5ce7',
|
|
11
|
+
onPrimary: '#ffffff',
|
|
12
|
+
secondary: '#dfe6e9',
|
|
13
|
+
onSecondary: '#2d3436',
|
|
14
|
+
danger: '#e74c3c',
|
|
15
|
+
onDanger: '#ffffff',
|
|
16
|
+
info: '#3498db',
|
|
17
|
+
infoBg: '#ebf5fb',
|
|
18
|
+
warning: '#f39c12',
|
|
19
|
+
warningBg: '#fef9e7',
|
|
20
|
+
error: '#e74c3c',
|
|
21
|
+
errorBg: '#fdedec',
|
|
22
|
+
success: '#27ae60',
|
|
23
|
+
successBg: '#eafaf1',
|
|
24
|
+
},
|
|
25
|
+
spacing: { xs: 4, sm: 8, md: 12, lg: 16 },
|
|
26
|
+
radius: { sm: 6, md: 10 },
|
|
27
|
+
fontSize: { small: 13, body: 14, label: 15, title: 18 },
|
|
28
|
+
};
|
|
29
|
+
/** Built-in dark palette — matches the `[data-theme='dark']` block in `styles.css`. */
|
|
30
|
+
export const darkTheme = {
|
|
31
|
+
colors: {
|
|
32
|
+
background: '#151a26',
|
|
33
|
+
surface: '#1c2333',
|
|
34
|
+
text: '#e5e7eb',
|
|
35
|
+
textMuted: '#9ca3af',
|
|
36
|
+
border: '#2a3140',
|
|
37
|
+
primary: '#8b7ff0',
|
|
38
|
+
onPrimary: '#ffffff',
|
|
39
|
+
secondary: '#2a3140',
|
|
40
|
+
onSecondary: '#e5e7eb',
|
|
41
|
+
danger: '#ef4444',
|
|
42
|
+
onDanger: '#ffffff',
|
|
43
|
+
info: '#5dade2',
|
|
44
|
+
infoBg: '#16283a',
|
|
45
|
+
warning: '#f5b041',
|
|
46
|
+
warningBg: '#2a2412',
|
|
47
|
+
error: '#ef4444',
|
|
48
|
+
errorBg: '#2a1717',
|
|
49
|
+
success: '#2ecc71',
|
|
50
|
+
successBg: '#12251a',
|
|
51
|
+
},
|
|
52
|
+
spacing: { xs: 4, sm: 8, md: 12, lg: 16 },
|
|
53
|
+
radius: { sm: 6, md: 10 },
|
|
54
|
+
fontSize: { small: 13, body: 14, label: 15, title: 18 },
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Injection key for the nearest resolved theme. Holds the full
|
|
58
|
+
* {@link ResolvedThemeProps} (not just the tokens) so a descendant
|
|
59
|
+
* `MdmaDocument` with no `theme` prop of its own can inherit the ancestor's
|
|
60
|
+
* `data-theme` / inline variables and re-apply them to its own root.
|
|
61
|
+
*/
|
|
62
|
+
export const MdmaThemeKey = Symbol('mdma-theme');
|
|
63
|
+
/**
|
|
64
|
+
* The nearest resolved theme props, or the unthemed light default. Internal —
|
|
65
|
+
* `MdmaDocument` uses it to inherit an ancestor provider's theme.
|
|
66
|
+
*/
|
|
67
|
+
export function useResolvedTheme() {
|
|
68
|
+
return inject(MdmaThemeKey, computed(() => ({ theme: lightTheme })));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The resolved token object for the nearest theme (defaults to {@link lightTheme}).
|
|
72
|
+
*
|
|
73
|
+
* Unlike the React renderer's `useMdmaTheme`, this returns a `ComputedRef` so the
|
|
74
|
+
* tokens stay reactive when an ancestor's `theme` prop changes — read it as
|
|
75
|
+
* `theme.value` in `setup`, or unwrapped in a template.
|
|
76
|
+
*/
|
|
77
|
+
export function useMdmaTheme() {
|
|
78
|
+
const resolved = useResolvedTheme();
|
|
79
|
+
return computed(() => resolved.value.theme);
|
|
80
|
+
}
|
|
81
|
+
function camelToKebab(key) {
|
|
82
|
+
return key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Convert an {@link MdmaTheme} into the inline CSS-variable style object the
|
|
86
|
+
* `.mdma-*` classes read. Numeric scales are emitted as `px`.
|
|
87
|
+
*/
|
|
88
|
+
export function themeToCssVars(theme) {
|
|
89
|
+
const vars = {};
|
|
90
|
+
for (const [key, value] of Object.entries(theme.colors)) {
|
|
91
|
+
vars[`--mdma-color-${camelToKebab(key)}`] = value;
|
|
92
|
+
}
|
|
93
|
+
for (const [key, value] of Object.entries(theme.spacing)) {
|
|
94
|
+
vars[`--mdma-spacing-${key}`] = `${value}px`;
|
|
95
|
+
}
|
|
96
|
+
for (const [key, value] of Object.entries(theme.radius)) {
|
|
97
|
+
vars[`--mdma-radius-${key}`] = `${value}px`;
|
|
98
|
+
}
|
|
99
|
+
for (const [key, value] of Object.entries(theme.fontSize)) {
|
|
100
|
+
vars[`--mdma-font-size-${camelToKebab(key)}`] = `${value}px`;
|
|
101
|
+
}
|
|
102
|
+
return vars;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resolve a {@link MdmaThemeInput} into the DOM props that apply it: a
|
|
106
|
+
* `data-theme` attribute for built-in palettes, or inline CSS variables for a
|
|
107
|
+
* custom theme. Shared by {@link MdmaThemeProvider} and `MdmaDocument`.
|
|
108
|
+
*/
|
|
109
|
+
export function resolveThemeProps(theme) {
|
|
110
|
+
if (theme === undefined)
|
|
111
|
+
return { theme: lightTheme };
|
|
112
|
+
if (theme === 'light')
|
|
113
|
+
return { dataTheme: 'light', theme: lightTheme };
|
|
114
|
+
if (theme === 'dark')
|
|
115
|
+
return { dataTheme: 'dark', theme: darkTheme };
|
|
116
|
+
// `auto` follows the OS preference at the CSS layer; the resolved token
|
|
117
|
+
// object is a best-effort light default for any JS consumer of useMdmaTheme.
|
|
118
|
+
if (theme === 'auto')
|
|
119
|
+
return { dataTheme: 'auto', theme: lightTheme };
|
|
120
|
+
// A custom theme sets the public tokens inline, but the stylesheet also has
|
|
121
|
+
// internal derived vars (heading text, code backgrounds, …) that aren't on
|
|
122
|
+
// the public type. Pick the light/dark base by the theme's own background so
|
|
123
|
+
// those derived vars match — otherwise a custom *dark* theme would render,
|
|
124
|
+
// e.g., near-black heading text on a dark surface.
|
|
125
|
+
return {
|
|
126
|
+
dataTheme: isDarkTheme(theme) ? 'dark' : 'light',
|
|
127
|
+
style: themeToCssVars(theme),
|
|
128
|
+
theme,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** Heuristic: is this theme's background dark? (relative luminance < 50%). */
|
|
132
|
+
function isDarkTheme(theme) {
|
|
133
|
+
const hex = theme.colors.background.replace('#', '');
|
|
134
|
+
if (hex.length < 6)
|
|
135
|
+
return false;
|
|
136
|
+
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
137
|
+
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
138
|
+
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
139
|
+
if (Number.isNaN(r + g + b))
|
|
140
|
+
return false;
|
|
141
|
+
return 0.299 * r + 0.587 * g + 0.114 * b < 128;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Standalone theme wrapper for rendering MDMA components *without* `MdmaDocument`
|
|
145
|
+
* (e.g. a lone `<MdmaBlock>`). Renders a `.mdma-theme-root` element carrying the
|
|
146
|
+
* theme so the `--mdma-*` variables cascade to everything inside. When you use
|
|
147
|
+
* `MdmaDocument`, pass `theme` to it directly instead — it themes its own root.
|
|
148
|
+
*/
|
|
149
|
+
export const MdmaThemeProvider = defineComponent({
|
|
150
|
+
name: 'MdmaThemeProvider',
|
|
151
|
+
props: {
|
|
152
|
+
/** `'light'` | `'dark'` | `'auto'`, or a full {@link MdmaTheme}. */
|
|
153
|
+
theme: { type: [String, Object], default: undefined },
|
|
154
|
+
/** Extra class names for the wrapper element. */
|
|
155
|
+
class: { type: String, default: undefined },
|
|
156
|
+
/** Extra inline styles, merged after the theme's CSS variables. */
|
|
157
|
+
style: { type: Object, default: undefined },
|
|
158
|
+
},
|
|
159
|
+
setup(props, { slots }) {
|
|
160
|
+
const resolved = computed(() => resolveThemeProps(props.theme));
|
|
161
|
+
provide(MdmaThemeKey, resolved);
|
|
162
|
+
return () => h('div', {
|
|
163
|
+
class: `mdma-theme-root ${props.class ?? ''}`.trim(),
|
|
164
|
+
'data-theme': resolved.value.dataTheme,
|
|
165
|
+
style: { ...resolved.value.style, ...props.style },
|
|
166
|
+
}, slots.default?.());
|
|
167
|
+
},
|
|
168
|
+
});
|
|
169
|
+
//# sourceMappingURL=MdmaThemeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MdmaThemeProvider.js","sourceRoot":"","sources":["../../src/theme/MdmaThemeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,MAAM,EACN,OAAO,GAKR,MAAM,KAAK,CAAC;AAuCb,sFAAsF;AACtF,MAAM,CAAC,MAAM,UAAU,GAAc;IACnC,MAAM,EAAE;QACN,UAAU,EAAE,SAAS;QACrB,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,SAAS;QACf,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,SAAS;QAClB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,WAAW,EAAE,SAAS;QACtB,MAAM,EAAE,SAAS;QACjB,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,SAAS;QAClB,SAAS,EAAE,SAAS;QACpB,KA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AO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAEhC,OAAO,GAAG,EAAE,CACV,CAAC,CACC,KAAK,EACL;YACE,KAAK,EAAE,mBAAmB,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE;YACpD,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;YACtC,KAAK,EAAE,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE;SACnD,EACD,KAAK,CAAC,OAAO,EAAE,EAAE,CAClB,CAAC;IACN,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mobile-reality/mdma-renderer-vue",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"mdma",
|
|
6
|
+
"markdown",
|
|
7
|
+
"ai",
|
|
8
|
+
"llm",
|
|
9
|
+
"interactive-document",
|
|
10
|
+
"vue",
|
|
11
|
+
"vue3",
|
|
12
|
+
"forms",
|
|
13
|
+
"ui"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./styles.css": "./styles.css"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@mobile-reality/mdma-runtime": "0.4.0",
|
|
25
|
+
"@mobile-reality/mdma-spec": "0.4.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"vue": "^3.4.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@vue/test-utils": "^2.4.11",
|
|
32
|
+
"happy-dom": "^20.0.0",
|
|
33
|
+
"remark-gfm": "^4.0.0",
|
|
34
|
+
"remark-parse": "^11.0.0",
|
|
35
|
+
"typescript": "^5.7.0",
|
|
36
|
+
"unified": "^11.0.0",
|
|
37
|
+
"vitest": "^3.2.0",
|
|
38
|
+
"vue": "^3.5.0",
|
|
39
|
+
"@mobile-reality/mdma-attachables-core": "0.2.6",
|
|
40
|
+
"@mobile-reality/mdma-parser": "0.3.0"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"styles.css"
|
|
45
|
+
],
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/MobileReality/mdma.git",
|
|
52
|
+
"directory": "packages/renderer-vue"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsc -p tsconfig.json",
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"lint": "biome lint src/",
|
|
58
|
+
"typecheck": "tsc --noEmit"
|
|
59
|
+
}
|
|
60
|
+
}
|