@barzhsieh/nuxt-content-mermaid 2.2.3 → 3.0.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.
Files changed (62) hide show
  1. package/README.md +47 -502
  2. package/README.zh-TW.md +46 -509
  3. package/dist/module.d.mts +39 -53
  4. package/dist/module.json +3 -3
  5. package/dist/module.mjs +600 -155
  6. package/dist/runtime/built-in-renderer/BuiltInRenderer.d.vue.ts +0 -0
  7. package/dist/runtime/built-in-renderer/BuiltInRenderer.vue +597 -0
  8. package/dist/runtime/built-in-renderer/BuiltInRenderer.vue.d.ts +0 -0
  9. package/dist/runtime/component-configuration-error.d.ts +3 -0
  10. package/dist/runtime/component-configuration-error.js +7 -0
  11. package/dist/runtime/component-configuration.d.ts +23 -0
  12. package/dist/runtime/component-configuration.js +78 -0
  13. package/dist/runtime/components/ContentMermaidTransport.d.vue.ts +10 -0
  14. package/dist/runtime/components/ContentMermaidTransport.vue +21 -0
  15. package/dist/runtime/components/ContentMermaidTransport.vue.d.ts +10 -0
  16. package/dist/runtime/components/Mermaid.d.vue.ts +0 -31
  17. package/dist/runtime/components/Mermaid.vue +136 -743
  18. package/dist/runtime/components/Mermaid.vue.d.ts +0 -31
  19. package/dist/runtime/components/MermaidExpandOverlay.d.vue.ts +13 -16
  20. package/dist/runtime/components/MermaidExpandOverlay.vue +61 -53
  21. package/dist/runtime/components/MermaidExpandOverlay.vue.d.ts +13 -16
  22. package/dist/runtime/components/MermaidFullscreenPresentation.d.vue.ts +18 -0
  23. package/dist/runtime/components/MermaidFullscreenPresentation.vue +56 -0
  24. package/dist/runtime/components/MermaidFullscreenPresentation.vue.d.ts +18 -0
  25. package/dist/runtime/composables/useMermaidExpand.d.ts +16 -32
  26. package/dist/runtime/composables/useMermaidExpand.js +232 -75
  27. package/dist/runtime/composables/useMermaidFullscreen.d.ts +18 -0
  28. package/dist/runtime/composables/useMermaidFullscreen.js +242 -0
  29. package/dist/runtime/composables/useMermaidZoom.d.ts +5 -1
  30. package/dist/runtime/composables/useMermaidZoom.js +54 -28
  31. package/dist/runtime/configuration/core.d.ts +27 -0
  32. package/dist/runtime/configuration/core.js +340 -0
  33. package/dist/runtime/configuration/module.d.ts +17 -0
  34. package/dist/runtime/configuration/module.js +233 -0
  35. package/dist/runtime/configuration/runtime-options.d.ts +4 -0
  36. package/dist/runtime/configuration/runtime-options.js +57 -0
  37. package/dist/runtime/constants.d.ts +24 -0
  38. package/dist/runtime/constants.js +60 -2
  39. package/dist/runtime/direct-mermaid-config.d.ts +5 -0
  40. package/dist/runtime/direct-mermaid-config.js +216 -0
  41. package/dist/runtime/mermaid-config.d.ts +9 -5
  42. package/dist/runtime/mermaid-config.js +30 -19
  43. package/dist/runtime/mermaid-rendering.d.ts +28 -0
  44. package/dist/runtime/mermaid-rendering.js +140 -0
  45. package/dist/runtime/plugins/content-mermaid-transport.d.ts +2 -0
  46. package/dist/runtime/plugins/content-mermaid-transport.js +5 -0
  47. package/dist/runtime/plugins/mermaid.client.d.ts +0 -3
  48. package/dist/runtime/plugins/mermaid.client.js +14 -32
  49. package/dist/runtime/plugins/runtime-config.d.ts +2 -0
  50. package/dist/runtime/plugins/runtime-config.js +9 -0
  51. package/dist/runtime/rendererSelection.d.ts +43 -0
  52. package/dist/runtime/rendererSelection.js +36 -0
  53. package/dist/runtime/rendererSelectionOrchestration.d.ts +12 -0
  54. package/dist/runtime/rendererSelectionOrchestration.js +13 -0
  55. package/dist/runtime/runtime-snapshot.d.ts +3 -0
  56. package/dist/runtime/runtime-snapshot.js +26 -0
  57. package/dist/runtime/utils/index.d.ts +0 -4
  58. package/dist/runtime/utils/index.js +0 -37
  59. package/dist/types.d.mts +2 -2
  60. package/package.json +38 -32
  61. package/dist/runtime/utils/mermaid-transform.d.ts +0 -18
  62. package/dist/runtime/utils/mermaid-transform.js +0 -345
package/dist/module.d.mts CHANGED
@@ -26,37 +26,21 @@ declare module 'vue' {
26
26
  $mermaid: () => Promise<Mermaid>
27
27
  }
28
28
  interface GlobalComponents {
29
- Mermaid: DefineComponent<{
30
- config?: MermaidConfig
31
- toolbar?: MermaidToolbarOptions
32
- code?: string
33
- }>
29
+ Mermaid: DefineComponent<MermaidComponentProps>
34
30
  }
35
31
  }
36
32
 
37
- declare module 'nuxt/schema' {
33
+ declare module '@nuxt/schema' {
38
34
  interface NuxtConfig {
39
35
  contentMermaid?: ModuleOptions
40
- /**
41
- * @deprecated Use `contentMermaid`
42
- */
43
- mermaidContent?: ModuleOptions
44
36
  }
45
37
 
46
38
  interface NuxtOptions {
47
39
  contentMermaid?: ModuleOptions
48
- /**
49
- * @deprecated Use `contentMermaid`
50
- */
51
- mermaidContent?: ModuleOptions
52
40
  }
53
41
 
54
42
  interface PublicRuntimeConfig {
55
- contentMermaid?: Partial<ModuleOptions>
56
- /**
57
- * @deprecated Use `contentMermaid`
58
- */
59
- mermaidContent?: Partial<ModuleOptions>
43
+ contentMermaid?: RuntimeOptions
60
44
  }
61
45
  }
62
46
 
@@ -72,12 +56,18 @@ declare global {
72
56
  }
73
57
  }
74
58
 
75
- interface ModuleOptions {
76
- /**
77
- * Whether to enable the entire Mermaid process
78
- * @default true
79
- */
80
- enabled?: boolean;
59
+ type JsonPrimitive = string | number | boolean | null;
60
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
61
+ type JsonObject = {
62
+ [key: string]: JsonValue;
63
+ };
64
+ type IsAny<T> = 0 extends (1 & T) ? true : false;
65
+ type RuntimeDataMember<T> = IsAny<T> extends true ? never : T extends JsonPrimitive ? T : T extends (...args: never[]) => unknown ? never : T extends readonly (infer Item)[] ? RuntimeDataMember<Item>[] : T extends object ? {
66
+ [Key in keyof T]: RuntimeDataMember<T[Key]>;
67
+ } : never;
68
+ type RuntimeMermaidConfig = RuntimeDataMember<MermaidConfig> & JsonObject;
69
+ type PageMermaidConfig = RuntimeMermaidConfig;
70
+ interface RuntimeOptions {
81
71
  /**
82
72
  * Enable debug mode for detailed logging and error reporting
83
73
  * @default false
@@ -88,9 +78,9 @@ interface ModuleOptions {
88
78
  */
89
79
  loader?: {
90
80
  /**
91
- * Pass-through to `mermaid.initialize`
81
+ * Pure-data configuration passed through Nuxt public runtime config.
92
82
  */
93
- init?: MermaidConfig;
83
+ init?: RuntimeMermaidConfig;
94
84
  /**
95
85
  * Whether to lazy load the diagram when it enters the viewport.
96
86
  * Can be a boolean or an object with IntersectionObserver options.
@@ -104,10 +94,7 @@ interface ModuleOptions {
104
94
  * Options related to theme handling
105
95
  */
106
96
  theme?: {
107
- /**
108
- * @deprecated The module now automatically detects and syncs with @nuxtjs/color-mode.
109
- * This option no longer has any effect and will be removed in a future version.
110
- */
97
+ /** @deprecated No effect; retained for 3.0 compatibility. */
111
98
  useColorModeTheme?: boolean;
112
99
  light?: MermaidConfig['theme'];
113
100
  dark?: MermaidConfig['theme'];
@@ -116,28 +103,10 @@ interface ModuleOptions {
116
103
  * Names for custom implementation components
117
104
  */
118
105
  components?: {
119
- /**
120
- * Custom Mermaid implementation component name (e.g., 'MyMermaid').
121
- * The Markdown transformation phase always outputs `<Mermaid>`, this setting only affects
122
- * which component implementation `Mermaid.vue` delegates to at runtime.
123
- */
124
106
  renderer?: string;
125
- /**
126
- * Spinner component name to use while Mermaid is loading.
127
- * This should be a globally available component name (e.g., under the project `components/` directory).
128
- * If not provided, the module's built-in `Spinner.vue` will be used.
129
- */
130
107
  spinner?: string;
131
- /**
132
- * Error component name to display when Mermaid rendering fails.
133
- * This should be a globally available component name (e.g., under the project `components/` directory).
134
- * If not provided, the module's built-in fallback message will be used.
135
- */
136
108
  error?: string;
137
109
  };
138
- /**
139
- * Options related to SVG expand (lightbox) interactions
140
- */
141
110
  /**
142
111
  * Expand configuration. `false` disables expand, `true` uses defaults.
143
112
  */
@@ -147,9 +116,26 @@ interface ModuleOptions {
147
116
  */
148
117
  toolbar?: MermaidToolbarOptions;
149
118
  }
150
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
119
+ interface ModuleOptions extends RuntimeOptions {
120
+ /**
121
+ * Whether to enable the entire Mermaid process at build time.
122
+ * @default true
123
+ */
124
+ enabled?: boolean;
125
+ }
126
+ interface MermaidComponentBaseProps {
127
+ toolbar?: MermaidToolbarOptions;
128
+ code?: string;
129
+ }
130
+ type MermaidComponentProps = MermaidComponentBaseProps & ({
131
+ pageConfig?: PageMermaidConfig;
132
+ config?: never;
133
+ } | {
134
+ pageConfig?: never;
135
+ config?: MermaidConfig;
136
+ });
151
137
 
152
- declare function transformMermaidCodeBlocks(body: string, componentName: string, frontmatterConfigKey?: string): string;
138
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
153
139
 
154
- export { _default as default, transformMermaidCodeBlocks };
155
- export type { ModuleOptions };
140
+ export { _default as default };
141
+ export type { MermaidComponentProps, ModuleOptions, PageMermaidConfig, RuntimeMermaidConfig, RuntimeOptions };
package/dist/module.json CHANGED
@@ -2,11 +2,11 @@
2
2
  "name": "@barzhsieh/nuxt-content-mermaid",
3
3
  "configKey": "contentMermaid",
4
4
  "compatibility": {
5
- "nuxt": "^3.20.1 || ^4.1.0"
5
+ "nuxt": "^4.1.0"
6
6
  },
7
- "version": "2.2.3",
7
+ "version": "3.0.2",
8
8
  "builder": {
9
- "@nuxt/module-builder": "1.0.2",
9
+ "@nuxt/module-builder": "1.0.3",
10
10
  "unbuild": "3.6.1"
11
11
  }
12
12
  }