@onderwijsin/nuxt-loops-renderer 0.2.6 → 0.2.8

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/module.d.mts CHANGED
@@ -1,18 +1,24 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
- import { EvaluateLoopsLmxOptions } from '@onderwijsin/loops-core';
3
-
4
- interface ModuleOptions {
5
- /** Indicates whether the module should register its runtime features. */
6
- enabled?: boolean;
7
- /** Enables inline styles derived from LMX node attributes by default. */
8
- applyInlineStyles?: boolean;
9
- /** Fallbacks used when conditional Section rules cannot be evaluated. */
10
- evaluate?: EvaluateLoopsLmxOptions;
11
- }
12
2
 
13
3
  /**
14
4
  * Provides the Nuxt runtime foundation for rendering Loops LMX email content.
15
5
  */
16
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
6
+ declare const _default: _nuxt_schema.NuxtModule<{
7
+ enabled?: boolean | undefined;
8
+ applyInlineStyles?: boolean | undefined;
9
+ evaluate?: {
10
+ onMissingVariable?: boolean | undefined;
11
+ onInvalidCondition?: boolean | undefined;
12
+ onInvalidComparison?: boolean | undefined;
13
+ } | undefined;
14
+ }, {
15
+ enabled?: boolean | undefined;
16
+ applyInlineStyles?: boolean | undefined;
17
+ evaluate?: {
18
+ onMissingVariable?: boolean | undefined;
19
+ onInvalidCondition?: boolean | undefined;
20
+ onInvalidComparison?: boolean | undefined;
21
+ } | undefined;
22
+ }, false>;
17
23
 
18
24
  export { _default as default };
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.6",
4
+ "version": "0.2.8",
5
5
  "compatibility": {
6
6
  "nuxt": "^4.0.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -1,7 +1,26 @@
1
1
  import { defineNuxtModule, useLogger, createResolver, addComponentsDir } from '@nuxt/kit';
2
- import { resolveModuleName, resolveLoggerScope, moduleSetup, transpileRuntime, moduleDependenciesWhenEnabled } from '@onderwijsin/nuxt-module-utils/shared';
2
+ import { enabled, resolveModuleName, resolveLoggerScope, moduleSetup, transpileRuntime, moduleDependenciesWhenEnabled } from '@onderwijsin/nuxt-module-utils/build';
3
+ import { z } from 'zod';
3
4
 
4
- const version = "0.2.6";
5
+ const version = "0.2.8";
6
+
7
+ const EVALUATE_DEFAULTS = {
8
+ onMissingVariable: false,
9
+ onInvalidCondition: false,
10
+ onInvalidComparison: false
11
+ };
12
+ const loopsRendererOptionsSchema = z.strictObject({
13
+ enabled,
14
+ applyInlineStyles: z.boolean().default(true),
15
+ evaluate: z.strictObject({
16
+ /** Result for a valid variable whose value is null or undefined. */
17
+ onMissingVariable: z.boolean().default(EVALUATE_DEFAULTS.onMissingVariable),
18
+ /** Result for malformed rules, unsupported variables, or unknown operations. */
19
+ onInvalidCondition: z.boolean().default(EVALUATE_DEFAULTS.onInvalidCondition),
20
+ /** Result when an operation cannot compare the resolved value. */
21
+ onInvalidComparison: z.boolean().default(EVALUATE_DEFAULTS.onInvalidComparison)
22
+ }).default(EVALUATE_DEFAULTS)
23
+ });
5
24
 
6
25
  const MODULE_KEY = "loopsRenderer";
7
26
  const MODULE_NAME = resolveModuleName(MODULE_KEY);
@@ -15,7 +34,9 @@ const module$1 = defineNuxtModule({
15
34
  }
16
35
  },
17
36
  defaults: {
18
- // applyInlineStyles: true
37
+ enabled: true,
38
+ applyInlineStyles: true,
39
+ evaluate: EVALUATE_DEFAULTS
19
40
  },
20
41
  moduleDependencies: (nuxt) => moduleDependenciesWhenEnabled(nuxt.options.loopsRenderer, {
21
42
  "@nuxt/ui": { version: ">=4.0.0" }
@@ -27,12 +48,11 @@ const module$1 = defineNuxtModule({
27
48
  if (!isEnabled()) {
28
49
  return;
29
50
  }
51
+ const validatedOptions = loopsRendererOptionsSchema.parse(options);
30
52
  nuxt.options.appConfig.loopsRenderer = {
31
- applyInlineStyles: options.applyInlineStyles ?? true
53
+ applyInlineStyles: validatedOptions.applyInlineStyles,
54
+ evaluate: validatedOptions.evaluate
32
55
  };
33
- Object.assign(nuxt.options.appConfig.loopsRenderer, {
34
- evaluate: options.evaluate
35
- });
36
56
  const resolver = createResolver(import.meta.url);
37
57
  const runtimeDir = resolver.resolve("./runtime");
38
58
  transpileRuntime(nuxt, runtimeDir);
@@ -1,10 +1,6 @@
1
- import type { EvaluateLoopsLmxOptions } from "@onderwijsin/loops-core";
1
+ import type { ModuleOptions } from "../config/options.schema.js";
2
2
  /** Options shared by the root renderer and every recursive LMX node renderer. */
3
- export interface LoopsRendererConfig {
3
+ export type LoopsRendererConfig = Partial<Pick<ModuleOptions, "applyInlineStyles" | "evaluate">> & {
4
4
  /** Render unsupported nodes in an inline developer-only block. */
5
5
  debug?: boolean;
6
- /** Overrides the module default for applying LMX node styles inline. */
7
- applyInlineStyles?: boolean;
8
- /** Overrides the module defaults for conditional Section evaluation. */
9
- evaluate?: EvaluateLoopsLmxOptions;
10
- }
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-loops-renderer",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Nuxt module for rendering Loops LMX email content.",
5
5
  "homepage": "https://github.com/onderwijsin/nuxt-modules#readme",
6
6
  "bugs": {
@@ -43,7 +43,7 @@
43
43
  "simple-icons": "16.28.0",
44
44
  "tailwindcss": "4.3.3",
45
45
  "zod": "4.4.3",
46
- "@onderwijsin/nuxt-module-utils": "^0.2.1"
46
+ "@onderwijsin/nuxt-module-utils": "^0.4.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@nuxt/module-builder": "1.0.3",
@@ -59,6 +59,6 @@
59
59
  "typecheck": "tsc --noEmit --project tsconfig.json",
60
60
  "dev": "pnpm run dev:prepare && nuxt dev playground",
61
61
  "dev:build": "nuxt build playground",
62
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground"
62
+ "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && nuxt prepare playground"
63
63
  }
64
64
  }