@treygrr/vjml 0.1.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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -0
  3. package/dist/types/components/VjmlRenderFrame.vue.d.ts +69 -0
  4. package/dist/types/composables/useVjml.d.ts +1 -0
  5. package/dist/types/index.d.ts +15 -0
  6. package/dist/types/metadata.d.ts +24 -0
  7. package/dist/types/metadata.generated.d.ts +1231 -0
  8. package/dist/types/plugin.d.ts +14 -0
  9. package/dist/types/runtime/client/renderVjmlToDebugTree.d.ts +5 -0
  10. package/dist/types/runtime/client/renderVjmlToHtml.d.ts +5 -0
  11. package/dist/types/runtime/client/useVjmlRenderer.d.ts +10 -0
  12. package/dist/types/runtime/component-types.generated.d.ts +581 -0
  13. package/dist/types/runtime/components/Accordion.d.ts +2 -0
  14. package/dist/types/runtime/components/AccordionElement.d.ts +2 -0
  15. package/dist/types/runtime/components/AccordionText.d.ts +2 -0
  16. package/dist/types/runtime/components/AccordionTitle.d.ts +2 -0
  17. package/dist/types/runtime/components/All.d.ts +2 -0
  18. package/dist/types/runtime/components/Attributes.d.ts +2 -0
  19. package/dist/types/runtime/components/Body.d.ts +2 -0
  20. package/dist/types/runtime/components/Breakpoint.d.ts +2 -0
  21. package/dist/types/runtime/components/Button.d.ts +2 -0
  22. package/dist/types/runtime/components/Carousel.d.ts +2 -0
  23. package/dist/types/runtime/components/CarouselImage.d.ts +2 -0
  24. package/dist/types/runtime/components/Class.d.ts +2 -0
  25. package/dist/types/runtime/components/Column.d.ts +2 -0
  26. package/dist/types/runtime/components/Divider.d.ts +2 -0
  27. package/dist/types/runtime/components/Font.d.ts +2 -0
  28. package/dist/types/runtime/components/Group.d.ts +2 -0
  29. package/dist/types/runtime/components/Head.d.ts +2 -0
  30. package/dist/types/runtime/components/Hero.d.ts +2 -0
  31. package/dist/types/runtime/components/HtmlAttribute.d.ts +2 -0
  32. package/dist/types/runtime/components/HtmlAttributes.d.ts +2 -0
  33. package/dist/types/runtime/components/Image.d.ts +2 -0
  34. package/dist/types/runtime/components/Mjml.d.ts +2 -0
  35. package/dist/types/runtime/components/Navbar.d.ts +2 -0
  36. package/dist/types/runtime/components/NavbarLink.d.ts +2 -0
  37. package/dist/types/runtime/components/Preview.d.ts +2 -0
  38. package/dist/types/runtime/components/Raw.d.ts +2 -0
  39. package/dist/types/runtime/components/Section.d.ts +2 -0
  40. package/dist/types/runtime/components/Selector.d.ts +2 -0
  41. package/dist/types/runtime/components/Social.d.ts +2 -0
  42. package/dist/types/runtime/components/SocialElement.d.ts +2 -0
  43. package/dist/types/runtime/components/Spacer.d.ts +2 -0
  44. package/dist/types/runtime/components/Style.d.ts +2 -0
  45. package/dist/types/runtime/components/Table.d.ts +2 -0
  46. package/dist/types/runtime/components/Text.d.ts +2 -0
  47. package/dist/types/runtime/components/Title.d.ts +2 -0
  48. package/dist/types/runtime/components/Wrapper.d.ts +2 -0
  49. package/dist/types/runtime/components.generated.d.ts +77 -0
  50. package/dist/types/runtime/composables/useVjml.d.ts +2 -0
  51. package/dist/types/runtime/composables/useVjmlComponentName.d.ts +2 -0
  52. package/dist/types/runtime/internal/browserDocument.d.ts +2 -0
  53. package/dist/types/runtime/internal/browserRendering.d.ts +3 -0
  54. package/dist/types/runtime/internal/componentMetadata.d.ts +2 -0
  55. package/dist/types/runtime/internal/content.d.ts +3 -0
  56. package/dist/types/runtime/internal/context.d.ts +82 -0
  57. package/dist/types/runtime/internal/factory.d.ts +54 -0
  58. package/dist/types/runtime/internal/head.d.ts +3 -0
  59. package/dist/types/runtime/internal/helpers/conditional.d.ts +10 -0
  60. package/dist/types/runtime/internal/helpers/documentShared.d.ts +10 -0
  61. package/dist/types/runtime/internal/helpers/measurements.d.ts +10 -0
  62. package/dist/types/runtime/internal/helpers/shorthand.d.ts +3 -0
  63. package/dist/types/runtime/internal/interactive.d.ts +36 -0
  64. package/dist/types/runtime/internal/layout.d.ts +76 -0
  65. package/dist/types/runtime/internal/renderless.d.ts +1 -0
  66. package/dist/types/runtime/internal/vnodes.d.ts +11 -0
  67. package/dist/types/runtime/manifest.generated.d.ts +412 -0
  68. package/dist/types/runtime/types.d.ts +1 -0
  69. package/dist/types/vjml.d.ts +93 -0
  70. package/dist/vjml.cjs +154 -0
  71. package/dist/vjml.js +5056 -0
  72. package/package.json +73 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 VJML 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.
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # vjml
2
+
3
+ [![CI](https://github.com/treygrr/vjml/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/treygrr/vjml/actions/workflows/ci.yml)
4
+
5
+ VJML is a Vue-only MJML-style email component library for standard Vue apps. It provides a plugin for global component registration, typed component exports, and browser-side render helpers for turning Vue email components into email-safe HTML.
6
+
7
+ It includes:
8
+
9
+ - the copied MJML-style runtime components
10
+ - plugin-based global registration for Vue apps
11
+ - metadata and typed component prop exports
12
+ - browser-side render helpers for converting a Vue email component into email-safe HTML
13
+
14
+ ## Repository layout
15
+
16
+ - `src` contains the publishable component library and is the only code compiled into `dist`.
17
+ - `test` contains the component parity suites, shared test utilities, and end-to-end sample email fixtures.
18
+ - `website` contains the Nuxt documentation site and is managed as a workspace from the repository root.
19
+ - `playground` contains the local development app used for previewing and testing the library.
20
+ - The playground imports the library through the local `vjml` source alias, while the published npm package name is `@treygrr/vjml`.
21
+
22
+ Run `npm install` from the repository root. The root package manages both the publishable library and the `website` workspace.
23
+
24
+ ## Scripts
25
+
26
+ - `npm run dev` starts the local playground.
27
+ - `npm run dev:playground` also starts the local playground explicitly.
28
+ - `npm run dev:website` starts the Nuxt docs site from the root workspace.
29
+ - `npm run docs:dev` is an alias for `npm run dev:website`.
30
+ - `npm run docs:build` builds the docs site from the root workspace.
31
+ - `npm run docs:generate` generates the static docs output from the root workspace.
32
+ - `npm run docs:preview` previews the built docs site locally.
33
+ - `npm run build` builds both the library and the website from the repository root.
34
+ - `npm run build:lib` runs the library build directly.
35
+ - `npm run build:website` runs only the Nuxt docs build.
36
+ - `npm run test` runs the renderer parity test suite.
37
+ - `npm run test:accordion` runs the first component parity suite against the accordion fixtures.
38
+ - `npm run typecheck` validates the playground and library source.
39
+ - `npm run typecheck:website` runs the Nuxt workspace typecheck from the repository root.
40
+
41
+ ## Component parity tests
42
+
43
+ The parity harness lives under `test/components`.
44
+
45
+ - Each component gets its own folder.
46
+ - Each variant is represented by a `.vue` fixture and a matching `.mjml` fixture.
47
+ - The component test renders both sides, normalizes the generated HTML, and compares the results.
48
+
49
+ ## Contributing
50
+
51
+ Contributions go through GitHub pull requests. Before opening a pull request, make sure the change is covered by tests, run the relevant verification commands, and update docs or generated metadata when the public surface changes.
52
+
53
+ - Changes to existing behavior need updated coverage.
54
+ - New features and new components need new coverage.
55
+ - Runtime and component changes should update parity fixtures under `test/components` or `test/samples`.
56
+ - Library changes should be verified with `npm run typecheck`, `npm run test`, and `npm run build`.
57
+ - Docs changes live under `website/` and should be verified with `cd website && npm run build`.
58
+
59
+ See `CONTRIBUTING.md` for the full contributor workflow and GitHub merge policy.
60
+
61
+ ## License
62
+
63
+ MIT. See `LICENSE`.
64
+
65
+ ## Install the plugin
66
+
67
+ ```ts
68
+ import { createApp } from 'vue'
69
+ import App from './App.vue'
70
+ import VjmlPlugin from '@treygrr/vjml'
71
+
72
+ createApp(App)
73
+ .use(VjmlPlugin, {
74
+ includeUnprefixedAliases: true,
75
+ prefix: 'VJ',
76
+ render: {
77
+ validation: 'warn',
78
+ },
79
+ })
80
+ .mount('#app')
81
+ ```
82
+
83
+ Set `includeUnprefixedAliases: true` when you want both `VJText`-style prefixed names and bare aliases such as `Text` or `Mjml` available from the plugin.
84
+
85
+ You can also import components directly:
86
+
87
+ ```ts
88
+ import { Body, Button, Column, Mjml, Section, Text } from '@treygrr/vjml'
89
+ ```
90
+
91
+ ## Preview in the browser
92
+
93
+ The main `@treygrr/vjml` entry now includes a browser-side renderer and an iframe preview component.
94
+
95
+ ```vue
96
+ <script setup lang="ts">
97
+ import WelcomeEmail from './WelcomeEmail.vue'
98
+ import { VjmlRenderFrame } from '@treygrr/vjml'
99
+ </script>
100
+
101
+ <template>
102
+ <VjmlRenderFrame :component="WelcomeEmail" />
103
+ </template>
104
+ ```
105
+
106
+ If you want the generated HTML directly in a browser runtime, use `createVjmlRenderer()` from `@treygrr/vjml`.
107
+
108
+ ```ts
109
+ import WelcomeEmail from './WelcomeEmail.vue'
110
+ import { createVjmlRenderer } from '@treygrr/vjml'
111
+
112
+ const { renderToHtml } = createVjmlRenderer()
113
+ const { html, issues } = await renderToHtml(WelcomeEmail)
114
+ ```
115
+
116
+ ## Render an email component
117
+
118
+ ```ts
119
+ import WelcomeEmail from './WelcomeEmail.vue'
120
+ import { createVjmlRenderer } from '@treygrr/vjml'
121
+
122
+ const { renderToHtml } = createVjmlRenderer({
123
+ render: {
124
+ validation: 'strict',
125
+ },
126
+ })
127
+
128
+ const { html, issues } = await renderToHtml(WelcomeEmail, {
129
+ props: {
130
+ firstName: 'Ada',
131
+ },
132
+ })
133
+ ```
134
+
135
+ Inside a setup context, `useVjmlRenderer()` is also available from `@treygrr/vjml` and merges the injected plugin config automatically.
136
+
137
+ ## Important entries
138
+
139
+ - `src/index.ts` exports the plugin, components, metadata, and shared utilities.
140
+ - `src/runtime/components` contains the copied VJML component implementations.
141
+ - `src/runtime/internal` contains the browser render pipeline and document/context helpers.
142
+ - `src/metadata.ts` and `src/metadata.generated.ts` provide component metadata used by validation and serialization.
143
+ - `playground/App.vue` is the development catalog that imports and exercises the library.
@@ -0,0 +1,69 @@
1
+ import { type Component, type PropType } from 'vue';
2
+ import type { VjmlRuntimeConfigInput, VjmlValidationIssue } from '../vjml';
3
+ declare function renderFrame(): Promise<void>;
4
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
5
+ component: {
6
+ required: true;
7
+ type: PropType<Component>;
8
+ };
9
+ height: {
10
+ default: string;
11
+ type: (NumberConstructor | StringConstructor)[];
12
+ };
13
+ renderProps: {
14
+ default: () => {};
15
+ type: PropType<Record<string, unknown>>;
16
+ };
17
+ runtime: {
18
+ default: () => {};
19
+ type: PropType<VjmlRuntimeConfigInput>;
20
+ };
21
+ title: {
22
+ default: string;
23
+ type: StringConstructor;
24
+ };
25
+ }>, {
26
+ html: import("vue").Ref<string, string>;
27
+ issues: import("vue").Ref<{
28
+ code: string;
29
+ message: string;
30
+ severity: import("..").VjmlValidationSeverity;
31
+ path?: string | undefined;
32
+ tagName?: string | undefined;
33
+ }[], VjmlValidationIssue[] | {
34
+ code: string;
35
+ message: string;
36
+ severity: import("..").VjmlValidationSeverity;
37
+ path?: string | undefined;
38
+ tagName?: string | undefined;
39
+ }[]>;
40
+ renderFrame: typeof renderFrame;
41
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
42
+ component: {
43
+ required: true;
44
+ type: PropType<Component>;
45
+ };
46
+ height: {
47
+ default: string;
48
+ type: (NumberConstructor | StringConstructor)[];
49
+ };
50
+ renderProps: {
51
+ default: () => {};
52
+ type: PropType<Record<string, unknown>>;
53
+ };
54
+ runtime: {
55
+ default: () => {};
56
+ type: PropType<VjmlRuntimeConfigInput>;
57
+ };
58
+ title: {
59
+ default: string;
60
+ type: StringConstructor;
61
+ };
62
+ }>> & Readonly<{}>, {
63
+ title: string;
64
+ height: string | number;
65
+ renderProps: Record<string, unknown>;
66
+ runtime: VjmlRuntimeConfigInput;
67
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
68
+ declare const _default: typeof __VLS_export;
69
+ export default _default;
@@ -0,0 +1 @@
1
+ export { useVjml } from '../runtime/composables/useVjml';
@@ -0,0 +1,15 @@
1
+ export { default, VjmlPlugin, registerVjmlComponents, resolveVjmlPluginConfig } from './plugin';
2
+ export { default as VjmlRenderFrame } from './components/VjmlRenderFrame.vue';
3
+ export { DEFAULT_VJML_FONTS, DEFAULT_VJML_PREFIX, DEFAULT_VJML_RENDER_OPTIONS, VJML_COMPONENT_NAME_EXAMPLES, mergeVjmlRuntimeConfig, resolveVjmlRenderOptions, resolveVjmlRuntimeConfig, toVjmlComponentBaseName, toVjmlComponentName, } from './vjml';
4
+ export { VJML_COMPONENT_METADATA, VJML_COMPONENT_METADATA_BY_TAG_NAME, VJML_MANUAL_COMPONENT_TAG_NAMES, getVjmlComponentMetadata, } from './metadata';
5
+ export { VJML_RUNTIME_COMPONENTS } from './runtime/manifest.generated';
6
+ export { useVjml } from './runtime/composables/useVjml';
7
+ export { useVjmlComponentName } from './runtime/composables/useVjmlComponentName';
8
+ export { createVjmlRenderer, useVjmlRenderer } from './runtime/client/useVjmlRenderer';
9
+ export { renderVjmlToDebugTree } from './runtime/client/renderVjmlToDebugTree';
10
+ export { renderVjmlToHtml } from './runtime/client/renderVjmlToHtml';
11
+ export * from './runtime/components.generated';
12
+ export * from './runtime/component-types.generated';
13
+ export type { RenderVjmlToHtmlOptions, VjmlDebugDocumentState, VjmlDebugNode, VjmlDebugRenderResult, VjmlFontMap, VjmlRenderMode, VjmlRenderOptions, VjmlRenderResult, VjmlRuntimeConfig, VjmlRuntimeConfigInput, VjmlValidationIssue, VjmlValidationMode, VjmlValidationSeverity, } from './vjml';
14
+ export type { VjmlComponentMetadata, VjmlComponentMetadataSource, VjmlComponentSerializationMetadata, VjmlComponentSlotKind, } from './metadata';
15
+ export type { VjmlPluginOptions } from './plugin';
@@ -0,0 +1,24 @@
1
+ export type VjmlComponentMetadataSource = 'manual' | 'preset-core';
2
+ export type VjmlComponentSlotKind = 'html' | 'mjml' | 'none' | 'text';
3
+ export interface VjmlComponentSerializationMetadata {
4
+ allowsArbitraryAttributes: boolean;
5
+ preservesRawContent: boolean;
6
+ slotKind: VjmlComponentSlotKind;
7
+ }
8
+ export interface VjmlComponentMetadata {
9
+ tagName: string;
10
+ componentBaseName: string;
11
+ source: VjmlComponentMetadataSource;
12
+ allowedAttributes: Record<string, string>;
13
+ defaultAttributes: Record<string, string>;
14
+ allowedChildTagNames: string[];
15
+ allowedParentTagNames: string[];
16
+ supportsAnyChildTag: boolean;
17
+ endingTag: boolean;
18
+ rawElement: boolean;
19
+ serialization: VjmlComponentSerializationMetadata;
20
+ }
21
+ export declare const VJML_COMPONENT_METADATA: readonly VjmlComponentMetadata[];
22
+ export declare const VJML_COMPONENT_METADATA_BY_TAG_NAME: Readonly<Record<string, VjmlComponentMetadata>>;
23
+ export declare const VJML_MANUAL_COMPONENT_TAG_NAMES: readonly string[];
24
+ export declare function getVjmlComponentMetadata(tagName: string): VjmlComponentMetadata | null;