@onderwijsin/nuxt-loops-renderer 0.2.0 → 0.2.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/README.md CHANGED
@@ -2,14 +2,13 @@
2
2
 
3
3
  # @onderwijsin/nuxt-loops-renderer
4
4
 
5
- Render Loops LMX email content in a Nuxt 4 application. This module turns the
6
- renderer-neutral AST produced by `@onderwijsin/loops-core` into safe, styled
7
- Vue components that can be used in campaign archives, previews, and other
8
- presentation surfaces.
5
+ Render Loops LMX email content in a Nuxt 4 application. This module turns the renderer-neutral AST
6
+ produced by `@onderwijsin/loops-core` into safe, styled Vue components that can be used in campaign
7
+ archives, previews, and other presentation surfaces.
9
8
 
10
- The module is designed for content that has already been parsed on a trusted
11
- server. It validates the AST again at the browser boundary, resolves supported
12
- variables and URLs safely, and silently omits invalid or unsupported content.
9
+ The module is designed for content that has already been parsed on a trusted server. It validates
10
+ the AST again at the browser boundary, resolves supported variables and URLs safely, and silently
11
+ omits invalid or unsupported content.
13
12
 
14
13
  ## Getting started
15
14
 
@@ -27,11 +26,27 @@ export default defineNuxtConfig({
27
26
  });
28
27
  ```
29
28
 
30
- `@nuxt/ui` is registered as a Nuxt module dependency automatically. The
31
- renderer uses its `UButton` and `UIcon` components.
29
+ Import the module stylesheet in the consuming application's main CSS file after `@nuxt/ui`:
32
30
 
33
- Parse LMX with `@onderwijsin/loops-core` on the server, then pass the resulting
34
- AST and variables to the auto-imported `LoopsRenderer` component:
31
+ ```css
32
+ @import "tailwindcss";
33
+ @import "@nuxt/ui";
34
+ @import "@onderwijsin/nuxt-loops-renderer";
35
+ ```
36
+
37
+ ## Agent skill
38
+
39
+ Install the consumer-facing skill for this module with:
40
+
41
+ ```sh
42
+ npx skills add onderwijsin/nuxt-modules --skill nuxt-loops-renderer
43
+ ```
44
+
45
+ `@nuxt/ui` is registered as a Nuxt module dependency automatically. The renderer uses its `UButton`
46
+ and `UIcon` components.
47
+
48
+ Parse LMX with `@onderwijsin/loops-core` on the server, then pass the resulting AST and variables to
49
+ the auto-imported `LoopsRenderer` component:
35
50
 
36
51
  ```vue
37
52
  <script setup lang="ts">
@@ -73,8 +88,8 @@ The renderer supports the LMX presentation nodes used by Loops, including:
73
88
  - sections, columns, reusable components, and conditional sections;
74
89
  - safe URL handling, merge-tag resolution, and constrained inline styles.
75
90
 
76
- Set `debug: true` during development to show unsupported nodes in the Nuxt
77
- development overlay. Unsupported content is not rendered as raw HTML.
91
+ Set `debug: true` during development to show unsupported nodes in the Nuxt development overlay.
92
+ Unsupported content is not rendered as raw HTML.
78
93
 
79
94
  ```vue
80
95
  <LoopsRenderer :data="parsedAst" :variables="variables" :config="{ debug: import.meta.dev }" />
@@ -106,19 +121,18 @@ Available module options are:
106
121
  | `applyInlineStyles` | `true` | Apply validated LMX presentation attributes as inline styles. |
107
122
  | `evaluate` | See above | Fallbacks for missing variables and invalid conditional rules. |
108
123
 
109
- The same `applyInlineStyles` and `evaluate` options can be overridden for an
110
- individual `LoopsRenderer` with its `config` prop. `debug` is a per-renderer
111
- option and is intended for development diagnostics.
124
+ The same `applyInlineStyles` and `evaluate` options can be overridden for an individual
125
+ `LoopsRenderer` with its `config` prop. `debug` is a per-renderer option and is intended for
126
+ development diagnostics.
112
127
 
113
- Conditional sections use LMX attributes such as `if`, `ifOperation`, and
114
- `ifValue`. Evaluation never throws; missing variables and invalid conditions
115
- use the configured fallbacks, which default to `false`.
128
+ Conditional sections use LMX attributes such as `if`, `ifOperation`, and `ifValue`. Evaluation never
129
+ throws; missing variables and invalid conditions use the configured fallbacks, which default to
130
+ `false`.
116
131
 
117
132
  ## Relationship with `@onderwijsin/loops-core`
118
133
 
119
- `@onderwijsin/loops-core` is the framework-agnostic foundation. It parses LMX
120
- into a JSON-serializable AST and provides the shared safety and interpretation
121
- helpers for:
134
+ `@onderwijsin/loops-core` is the framework-agnostic foundation. It parses LMX into a
135
+ JSON-serializable AST and provides the shared safety and interpretation helpers for:
122
136
 
123
137
  - parsing and component expansion;
124
138
  - AST validation;
@@ -126,13 +140,13 @@ helpers for:
126
140
  - conditional evaluation;
127
141
  - supported-node detection and constrained style values.
128
142
 
129
- `@onderwijsin/nuxt-loops-renderer` is the presentation layer. It does not
130
- parse raw LMX, call the Loops API, or provide a general-purpose HTML renderer.
131
- Instead, it maps a validated core AST to Nuxt/Vue components, applies the
132
- application’s UI system, and chooses how supported LMX nodes appear on screen.
143
+ `@onderwijsin/nuxt-loops-renderer` is the presentation layer. It does not parse raw LMX, call the
144
+ Loops API, or provide a general-purpose HTML renderer. Instead, it maps a validated core AST to
145
+ Nuxt/Vue components, applies the application’s UI system, and chooses how supported LMX nodes appear
146
+ on screen.
133
147
 
134
- Keep API keys and raw-LMX parsing on a trusted server. Pass only the parsed AST
135
- and the variables needed by the current presentation to the client renderer.
148
+ Keep API keys and raw-LMX parsing on a trusted server. Pass only the parsed AST and the variables
149
+ needed by the current presentation to the client renderer.
136
150
 
137
151
  ## Compatibility
138
152
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-loops-renderer",
3
3
  "configKey": "loopsRenderer",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "compatibility": {
6
6
  "nuxt": "^4.0.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { defineNuxtModule, useLogger, createResolver, addComponentsDir } from '@nuxt/kit';
2
+ import { z } from 'zod';
2
3
 
3
4
  var NUMBER_CHAR_RE = /\d/;
4
5
  var STR_SPLITTERS = ["-", "_", "/", "."];
@@ -48,19 +49,19 @@ function splitByCase(str, separators) {
48
49
  function kebabCase(str, joiner) {
49
50
  return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join("-") : "";
50
51
  }
52
+ z.boolean().default(true);
51
53
  function resolveModuleName(moduleKey) {
52
54
  return `@onderwijsin/nuxt-${kebabCase(moduleKey)}`;
53
55
  }
54
56
  function resolveLoggerScope(moduleKey) {
55
57
  return kebabCase(moduleKey);
56
58
  }
59
+ function transpileRuntime(nuxt, runtimeDir) {
60
+ nuxt.options.build.transpile.push(runtimeDir);
61
+ }
57
62
  function moduleSetup(MODULE_NAME, options, log) {
58
- const start = () => {
59
- log.start(`Loading module ${MODULE_NAME}`);
60
- };
61
- const end = () => {
62
- log.success(`Module ${MODULE_NAME} Loaded`);
63
- };
63
+ const start = () => log.start(`Loading module ${MODULE_NAME}`);
64
+ const end = () => log.success(`Module ${MODULE_NAME} Loaded`);
64
65
  const isEnabled = () => {
65
66
  if ("enabled" in options && options.enabled === false) {
66
67
  log.info(`Module ${MODULE_NAME} is disabled. Skipping setup...`);
@@ -68,14 +69,10 @@ function moduleSetup(MODULE_NAME, options, log) {
68
69
  }
69
70
  return true;
70
71
  };
71
- return {
72
- start,
73
- end,
74
- isEnabled
75
- };
72
+ return { start, end, isEnabled };
76
73
  }
77
74
 
78
- const version = "0.2.0";
75
+ const version = "0.2.2";
79
76
 
80
77
  const MODULE_KEY = "loopsRenderer";
81
78
  const MODULE_NAME = resolveModuleName(MODULE_KEY);
@@ -89,7 +86,7 @@ const module$1 = defineNuxtModule({
89
86
  }
90
87
  },
91
88
  defaults: {
92
- applyInlineStyles: true
89
+ // applyInlineStyles: true
93
90
  },
94
91
  moduleDependencies: {
95
92
  "@nuxt/ui": {
@@ -111,7 +108,7 @@ const module$1 = defineNuxtModule({
111
108
  });
112
109
  const resolver = createResolver(import.meta.url);
113
110
  const runtimeDir = resolver.resolve("./runtime");
114
- nuxt.options.build.transpile.push(runtimeDir);
111
+ transpileRuntime(nuxt, runtimeDir);
115
112
  addComponentsDir({
116
113
  path: resolver.resolve(runtimeDir, "app", "components"),
117
114
  pathPrefix: false
@@ -1,13 +1,12 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed, useAppConfig } from "#imports";
3
3
  import {
4
4
  loopsLmxAstSchema,
5
5
  getUnsupportedLoopsLmxNodes,
6
6
  hasRenderableLoopsLmxNodes,
7
7
  hasUnsupportedLoopsLmxNodes
8
8
  } from "@onderwijsin/loops-core";
9
- import { useAppConfig } from "nuxt/app";
10
- import { createLoopsRendererConfig, hasRendererSpecificContent } from "../utils/renderer";
9
+ import { createLoopsRendererConfig } from "../utils/renderer";
11
10
  const props = defineProps({
12
11
  data: { type: Object, required: true },
13
12
  variables: { type: Object, required: true },
@@ -20,7 +19,7 @@ const rendererConfig = computed(
20
19
  const parsedContent = computed(() => loopsLmxAstSchema.safeParse(props.data));
21
20
  const ast = computed(() => parsedContent.value.success ? parsedContent.value.data : null);
22
21
  const hasRenderableContent = computed(
23
- () => ast.value !== null && (hasRenderableLoopsLmxNodes(ast.value.children) || hasRendererSpecificContent(ast.value.children))
22
+ () => ast.value !== null && hasRenderableLoopsLmxNodes(ast.value.children)
24
23
  );
25
24
  const hasUnsupportedContent = computed(
26
25
  () => ast.value !== null && hasUnsupportedLoopsLmxNodes(ast.value.children)
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  import {
4
4
  getLoopsLmxPixels,
5
5
  resolveSafeLoopsLmxUrl,
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  import {
4
4
  resolveSafeLoopsLmxUrl,
5
5
  resolveLoopsLmxVariables,
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  import {
4
4
  getLoopsLmxColumnsLayout,
5
5
  applyInlineStyles
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  import {
4
4
  applyInlineStyles
5
5
  } from "@onderwijsin/loops-core";
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  import {
4
4
  getLoopsLmxImageWidth,
5
5
  resolveSafeLoopsLmxUrl,
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  import {
4
4
  isRenderableLoopsLmxElement,
5
5
  resolveSafeLoopsLmxUrl,
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  import {
4
4
  evaluate,
5
5
  applyInlineStyles
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  import {
4
4
  applyInlineStyles
5
5
  } from "@onderwijsin/loops-core";
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { computed } from "vue";
2
+ import { computed } from "#imports";
3
3
  const props = defineProps({
4
4
  nodes: { type: Array, required: true },
5
5
  config: { type: Object, required: true }
@@ -1,4 +1,3 @@
1
- import type { LoopsLmxAst } from "@onderwijsin/loops-core";
2
1
  import type { LoopsRendererConfig } from "../../types.js";
3
2
  /**
4
3
  * Combines per-renderer settings, Nuxt app config, and safe renderer defaults.
@@ -8,11 +7,3 @@ import type { LoopsRendererConfig } from "../../types.js";
8
7
  * @returns The effective renderer settings.
9
8
  */
10
9
  export declare function createLoopsRendererConfig(rendererConfig?: LoopsRendererConfig, appConfig?: LoopsRendererConfig): LoopsRendererConfig;
11
- /**
12
- * Detects visible nodes handled by this renderer but intentionally omitted from core's generic
13
- * visibility helper. Quote and Br are renderer-specific LMX presentation nodes.
14
- *
15
- * @param nodes - Nodes in an LMX tree.
16
- * @returns Whether the tree contains renderer-specific visible content.
17
- */
18
- export declare function hasRendererSpecificContent(nodes: LoopsLmxAst["children"]): boolean;
@@ -9,8 +9,3 @@ export function createLoopsRendererConfig(rendererConfig, appConfig) {
9
9
  }
10
10
  });
11
11
  }
12
- export function hasRendererSpecificContent(nodes) {
13
- return nodes.some(
14
- (node) => node.type === "element" && (["Quote", "Br"].includes(node.name) || node.name === "Component" && hasRendererSpecificContent(node.children))
15
- );
16
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-loops-renderer",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Nuxt module for rendering Loops LMX email content.",
5
5
  "homepage": "https://github.com/onderwijsin/nuxt-modules#readme",
6
6
  "bugs": {
@@ -30,18 +30,19 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@nuxt/kit": "4.5.1",
34
- "@nuxt/schema": "4.5.1",
33
+ "@nuxt/kit": "4.5.2",
34
+ "@nuxt/schema": "4.5.2",
35
35
  "@nuxt/ui": "4.10.0",
36
- "@onderwijsin/loops-core": "1.2.0",
36
+ "@onderwijsin/loops-core": "1.3.0",
37
37
  "@tailwindcss/typography": "0.5.20",
38
38
  "defu": "6.1.7",
39
39
  "simple-icons": "16.28.0",
40
- "tailwindcss": "4.3.3"
40
+ "tailwindcss": "4.3.3",
41
+ "zod": "4.4.3"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@nuxt/module-builder": "1.0.3",
44
- "nuxt": "4.5.1",
45
+ "nuxt": "4.5.2",
45
46
  "typescript": "5.9.3",
46
47
  "unbuild": "3.6.1",
47
48
  "module-utils": "0.0.0"
@@ -51,8 +52,9 @@
51
52
  },
52
53
  "scripts": {
53
54
  "build": "nuxt-module-build build",
54
- "predev:playground": "nuxt-module-build build --stub",
55
55
  "typecheck": "tsc --noEmit --project tsconfig.json",
56
- "dev:playground": "nuxt dev playground"
56
+ "dev": "npm run dev:prepare && nuxt dev playground",
57
+ "dev:build": "nuxt build playground",
58
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground"
57
59
  }
58
60
  }