@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.
- package/README.md +47 -502
- package/README.zh-TW.md +46 -509
- package/dist/module.d.mts +39 -53
- package/dist/module.json +3 -3
- package/dist/module.mjs +600 -155
- package/dist/runtime/built-in-renderer/BuiltInRenderer.d.vue.ts +0 -0
- package/dist/runtime/built-in-renderer/BuiltInRenderer.vue +597 -0
- package/dist/runtime/built-in-renderer/BuiltInRenderer.vue.d.ts +0 -0
- package/dist/runtime/component-configuration-error.d.ts +3 -0
- package/dist/runtime/component-configuration-error.js +7 -0
- package/dist/runtime/component-configuration.d.ts +23 -0
- package/dist/runtime/component-configuration.js +78 -0
- package/dist/runtime/components/ContentMermaidTransport.d.vue.ts +10 -0
- package/dist/runtime/components/ContentMermaidTransport.vue +21 -0
- package/dist/runtime/components/ContentMermaidTransport.vue.d.ts +10 -0
- package/dist/runtime/components/Mermaid.d.vue.ts +0 -31
- package/dist/runtime/components/Mermaid.vue +136 -743
- package/dist/runtime/components/Mermaid.vue.d.ts +0 -31
- package/dist/runtime/components/MermaidExpandOverlay.d.vue.ts +13 -16
- package/dist/runtime/components/MermaidExpandOverlay.vue +61 -53
- package/dist/runtime/components/MermaidExpandOverlay.vue.d.ts +13 -16
- package/dist/runtime/components/MermaidFullscreenPresentation.d.vue.ts +18 -0
- package/dist/runtime/components/MermaidFullscreenPresentation.vue +56 -0
- package/dist/runtime/components/MermaidFullscreenPresentation.vue.d.ts +18 -0
- package/dist/runtime/composables/useMermaidExpand.d.ts +16 -32
- package/dist/runtime/composables/useMermaidExpand.js +232 -75
- package/dist/runtime/composables/useMermaidFullscreen.d.ts +18 -0
- package/dist/runtime/composables/useMermaidFullscreen.js +242 -0
- package/dist/runtime/composables/useMermaidZoom.d.ts +5 -1
- package/dist/runtime/composables/useMermaidZoom.js +54 -28
- package/dist/runtime/configuration/core.d.ts +27 -0
- package/dist/runtime/configuration/core.js +340 -0
- package/dist/runtime/configuration/module.d.ts +17 -0
- package/dist/runtime/configuration/module.js +233 -0
- package/dist/runtime/configuration/runtime-options.d.ts +4 -0
- package/dist/runtime/configuration/runtime-options.js +57 -0
- package/dist/runtime/constants.d.ts +24 -0
- package/dist/runtime/constants.js +60 -2
- package/dist/runtime/direct-mermaid-config.d.ts +5 -0
- package/dist/runtime/direct-mermaid-config.js +216 -0
- package/dist/runtime/mermaid-config.d.ts +9 -5
- package/dist/runtime/mermaid-config.js +30 -19
- package/dist/runtime/mermaid-rendering.d.ts +28 -0
- package/dist/runtime/mermaid-rendering.js +140 -0
- package/dist/runtime/plugins/content-mermaid-transport.d.ts +2 -0
- package/dist/runtime/plugins/content-mermaid-transport.js +5 -0
- package/dist/runtime/plugins/mermaid.client.d.ts +0 -3
- package/dist/runtime/plugins/mermaid.client.js +14 -32
- package/dist/runtime/plugins/runtime-config.d.ts +2 -0
- package/dist/runtime/plugins/runtime-config.js +9 -0
- package/dist/runtime/rendererSelection.d.ts +43 -0
- package/dist/runtime/rendererSelection.js +36 -0
- package/dist/runtime/rendererSelectionOrchestration.d.ts +12 -0
- package/dist/runtime/rendererSelectionOrchestration.js +13 -0
- package/dist/runtime/runtime-snapshot.d.ts +3 -0
- package/dist/runtime/runtime-snapshot.js +26 -0
- package/dist/runtime/utils/index.d.ts +0 -4
- package/dist/runtime/utils/index.js +0 -37
- package/dist/types.d.mts +2 -2
- package/package.json +38 -32
- package/dist/runtime/utils/mermaid-transform.d.ts +0 -18
- package/dist/runtime/utils/mermaid-transform.js +0 -345
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { assertStrictData, cloneOwnedData } from "./configuration/core.js";
|
|
2
|
+
import { PAGE_MERMAID_CONFIG_PHASE } from "./constants.js";
|
|
3
|
+
import { createMermaidComponentConfigurationError } from "./component-configuration-error.js";
|
|
4
|
+
import {
|
|
5
|
+
assertDirectMermaidConfig,
|
|
6
|
+
collectDirectMermaidConfigDependencies
|
|
7
|
+
} from "./direct-mermaid-config.js";
|
|
8
|
+
function resolveSourceKind(input) {
|
|
9
|
+
const hasPageConfig = input.pageConfig !== void 0;
|
|
10
|
+
const hasDirectConfig = input.config !== void 0;
|
|
11
|
+
if (hasPageConfig && hasDirectConfig) return "conflict";
|
|
12
|
+
if (hasPageConfig) return "page";
|
|
13
|
+
if (hasDirectConfig) return "direct";
|
|
14
|
+
return "runtime-only";
|
|
15
|
+
}
|
|
16
|
+
function ownValue(value, key) {
|
|
17
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
18
|
+
return descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
19
|
+
}
|
|
20
|
+
function validateInterpretedPageFields(value) {
|
|
21
|
+
const theme = ownValue(value, "theme");
|
|
22
|
+
if (theme !== void 0 && typeof theme !== "string") {
|
|
23
|
+
throw createMermaidComponentConfigurationError("`pageConfig.theme` must be a string.");
|
|
24
|
+
}
|
|
25
|
+
const logLevel = ownValue(value, "logLevel");
|
|
26
|
+
if (logLevel !== void 0 && typeof logLevel !== "string" && typeof logLevel !== "number") {
|
|
27
|
+
throw createMermaidComponentConfigurationError("`pageConfig.logLevel` must be a string or number.");
|
|
28
|
+
}
|
|
29
|
+
const suppressErrorRendering = ownValue(value, "suppressErrorRendering");
|
|
30
|
+
if (suppressErrorRendering !== void 0 && typeof suppressErrorRendering !== "boolean") {
|
|
31
|
+
throw createMermaidComponentConfigurationError("`pageConfig.suppressErrorRendering` must be a boolean.");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function requirePageConfigObject(value) {
|
|
35
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
36
|
+
throw createMermaidComponentConfigurationError("`pageConfig` must be a plain object.");
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
assertStrictData(value, PAGE_MERMAID_CONFIG_PHASE);
|
|
40
|
+
} catch {
|
|
41
|
+
throw createMermaidComponentConfigurationError("`pageConfig` must contain only strict pure data.");
|
|
42
|
+
}
|
|
43
|
+
validateInterpretedPageFields(value);
|
|
44
|
+
return cloneOwnedData(value);
|
|
45
|
+
}
|
|
46
|
+
function requireDirectConfigObject(value) {
|
|
47
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
48
|
+
throw createMermaidComponentConfigurationError("`config` must be an object.");
|
|
49
|
+
}
|
|
50
|
+
assertDirectMermaidConfig(value);
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
export function resolveMermaidComponentSource(input) {
|
|
54
|
+
const sourceKind = resolveSourceKind(input);
|
|
55
|
+
if (sourceKind === "conflict") {
|
|
56
|
+
return {
|
|
57
|
+
kind: "conflict",
|
|
58
|
+
error: createMermaidComponentConfigurationError(
|
|
59
|
+
"`pageConfig` and `config` cannot be supplied together."
|
|
60
|
+
)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (sourceKind === "page") return { kind: "page", config: requirePageConfigObject(input.pageConfig) };
|
|
64
|
+
if (sourceKind === "direct") return { kind: "direct", config: requireDirectConfigObject(input.config) };
|
|
65
|
+
return { kind: "runtime-only" };
|
|
66
|
+
}
|
|
67
|
+
export function collectMermaidComponentSourceDependencies(input) {
|
|
68
|
+
const sourceKind = resolveSourceKind(input);
|
|
69
|
+
const sourceReferences = [input.pageConfig, input.config];
|
|
70
|
+
if (sourceKind === "conflict" || sourceKind === "runtime-only")
|
|
71
|
+
return sourceReferences;
|
|
72
|
+
return [
|
|
73
|
+
...sourceReferences,
|
|
74
|
+
...collectDirectMermaidConfigDependencies(
|
|
75
|
+
sourceKind === "page" ? input.pageConfig : input.config
|
|
76
|
+
)
|
|
77
|
+
];
|
|
78
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PageMermaidConfig } from '../../types/config.js';
|
|
2
|
+
import type { MermaidToolbarOptions } from '../../types/mermaid.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
pageConfig?: PageMermaidConfig | null;
|
|
5
|
+
toolbar?: MermaidToolbarOptions;
|
|
6
|
+
code?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, resolveComponent } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
pageConfig: { type: [Object, null], required: false },
|
|
5
|
+
toolbar: { type: Object, required: false },
|
|
6
|
+
code: { type: String, required: false }
|
|
7
|
+
});
|
|
8
|
+
const normalizedPageConfig = computed(
|
|
9
|
+
() => props.pageConfig === null ? void 0 : props.pageConfig
|
|
10
|
+
);
|
|
11
|
+
const MermaidComponent = resolveComponent("Mermaid");
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<component
|
|
16
|
+
:is="MermaidComponent"
|
|
17
|
+
:page-config="normalizedPageConfig"
|
|
18
|
+
:toolbar="props.toolbar"
|
|
19
|
+
:code="props.code"
|
|
20
|
+
/>
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PageMermaidConfig } from '../../types/config.js';
|
|
2
|
+
import type { MermaidToolbarOptions } from '../../types/mermaid.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
pageConfig?: PageMermaidConfig | null;
|
|
5
|
+
toolbar?: MermaidToolbarOptions;
|
|
6
|
+
code?: string;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { MermaidConfig } from 'mermaid';
|
|
2
|
-
import type { MermaidToolbarOptions } from '../../types/mermaid.js';
|
|
3
|
-
type __VLS_Props = {
|
|
4
|
-
config?: MermaidConfig | string | unknown;
|
|
5
|
-
toolbar?: MermaidToolbarOptions;
|
|
6
|
-
code?: string;
|
|
7
|
-
};
|
|
8
|
-
declare var __VLS_1: {}, __VLS_9: {}, __VLS_51: {}, __VLS_53: {}, __VLS_60: {
|
|
9
|
-
error: unknown;
|
|
10
|
-
source: string;
|
|
11
|
-
};
|
|
12
|
-
type __VLS_Slots = {} & {
|
|
13
|
-
default?: (props: typeof __VLS_1) => any;
|
|
14
|
-
} & {
|
|
15
|
-
default?: (props: typeof __VLS_9) => any;
|
|
16
|
-
} & {
|
|
17
|
-
default?: (props: typeof __VLS_51) => any;
|
|
18
|
-
} & {
|
|
19
|
-
loading?: (props: typeof __VLS_53) => any;
|
|
20
|
-
} & {
|
|
21
|
-
error?: (props: typeof __VLS_60) => any;
|
|
22
|
-
};
|
|
23
|
-
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
-
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
25
|
-
declare const _default: typeof __VLS_export;
|
|
26
|
-
export default _default;
|
|
27
|
-
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
-
new (): {
|
|
29
|
-
$slots: S;
|
|
30
|
-
};
|
|
31
|
-
};
|