mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
Compare commits
6 Commits
@mermaid-j
...
sidv/Confi
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ea7d28bf1c | ||
![]() |
159d85e7f7 | ||
![]() |
d7ce7aecf3 | ||
![]() |
453802d4ce | ||
![]() |
cee1cf0ce2 | ||
![]() |
70198ffefa |
@@ -1,7 +1,10 @@
|
||||
import { load, JSON_SCHEMA } from 'js-yaml';
|
||||
import assert from 'node:assert';
|
||||
import Ajv2019, { type JSONSchemaType } from 'ajv/dist/2019.js';
|
||||
import type { MermaidConfig, BaseDiagramConfig } from '../packages/mermaid/src/config.type.js';
|
||||
import type {
|
||||
MermaidConfigWithDefaults,
|
||||
BaseDiagramConfig,
|
||||
} from '../packages/mermaid/src/config.type.js';
|
||||
|
||||
/**
|
||||
* All of the keys in the mermaid config that have a mermaid diagram config.
|
||||
@@ -36,7 +39,7 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [
|
||||
* @param mermaidConfigSchema - The Mermaid JSON Schema to use.
|
||||
* @returns The default mermaid config object.
|
||||
*/
|
||||
function generateDefaults(mermaidConfigSchema: JSONSchemaType<MermaidConfig>) {
|
||||
function generateDefaults(mermaidConfigSchema: JSONSchemaType<MermaidConfigWithDefaults>) {
|
||||
const ajv = new Ajv2019({
|
||||
useDefaults: true,
|
||||
allowUnionTypes: true,
|
||||
@@ -105,20 +108,23 @@ function generateDefaults(mermaidConfigSchema: JSONSchemaType<MermaidConfig>) {
|
||||
return mermaidDefaultConfig;
|
||||
}
|
||||
|
||||
export const loadSchema = (src: string, filename: string): JSONSchemaType<MermaidConfig> => {
|
||||
export const loadSchema = (
|
||||
src: string,
|
||||
filename: string
|
||||
): JSONSchemaType<MermaidConfigWithDefaults> => {
|
||||
const jsonSchema = load(src, {
|
||||
filename,
|
||||
// only allow JSON types in our YAML doc (will probably be default in YAML 1.3)
|
||||
// e.g. `true` will be parsed a boolean `true`, `True` will be parsed as string `"True"`.
|
||||
schema: JSON_SCHEMA,
|
||||
}) as JSONSchemaType<MermaidConfig>;
|
||||
}) as JSONSchemaType<MermaidConfigWithDefaults>;
|
||||
return jsonSchema;
|
||||
};
|
||||
|
||||
export const getDefaults = (schema: JSONSchemaType<MermaidConfig>) => {
|
||||
export const getDefaults = (schema: JSONSchemaType<MermaidConfigWithDefaults>) => {
|
||||
return `export default ${JSON.stringify(generateDefaults(schema), undefined, 2)};`;
|
||||
};
|
||||
|
||||
export const getSchema = (schema: JSONSchemaType<MermaidConfig>) => {
|
||||
export const getSchema = (schema: JSONSchemaType<MermaidConfigWithDefaults>) => {
|
||||
return `export default ${JSON.stringify(schema, undefined, 2)};`;
|
||||
};
|
||||
|
@@ -83,6 +83,7 @@ NODIR
|
||||
NSTR
|
||||
outdir
|
||||
Qcontrolx
|
||||
regexes
|
||||
reinit
|
||||
rels
|
||||
reqs
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import type { JSONSchemaType } from 'ajv/dist/2019.js';
|
||||
import type { MermaidConfig } from '../packages/mermaid/src/config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../packages/mermaid/src/config.type.js';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { getDefaults, getSchema, loadSchema } from '../.build/jsonSchema.js';
|
||||
|
||||
@@ -12,13 +12,13 @@ import { getDefaults, getSchema, loadSchema } from '../.build/jsonSchema.js';
|
||||
export const jsonSchemaPlugin = {
|
||||
name: 'json-schema-plugin',
|
||||
setup(build) {
|
||||
let schema: JSONSchemaType<MermaidConfig> | undefined = undefined;
|
||||
let schema: JSONSchemaType<MermaidConfigWithDefaults> | undefined = undefined;
|
||||
let content = '';
|
||||
|
||||
build.onLoad({ filter: /config\.schema\.yaml$/ }, async (args) => {
|
||||
// Load the file from the file system
|
||||
const source = await readFile(args.path, 'utf8');
|
||||
const resolvedSchema: JSONSchemaType<MermaidConfig> =
|
||||
const resolvedSchema: JSONSchemaType<MermaidConfigWithDefaults> =
|
||||
content === source && schema ? schema : loadSchema(source, args.path);
|
||||
if (content !== source) {
|
||||
content = source;
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
### defaultConfig
|
||||
|
||||
• `Const` **defaultConfig**: `MermaidConfig`
|
||||
• `Const` **defaultConfig**: `MermaidConfigWithDefaults`
|
||||
|
||||
#### Defined in
|
||||
|
||||
@@ -26,9 +26,9 @@ Pushes in a directive to the configuration
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :---------- | :-------------- | :----------------------- |
|
||||
| `directive` | `MermaidConfig` | The directive to push in |
|
||||
| Name | Type | Description |
|
||||
| :---------- | :--------------------------------------------------- | :----------------------- |
|
||||
| `directive` | `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}> | The directive to push in |
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -36,13 +36,13 @@ Pushes in a directive to the configuration
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:188](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L188)
|
||||
[config.ts:191](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L191)
|
||||
|
||||
---
|
||||
|
||||
### getConfig
|
||||
|
||||
▸ **getConfig**(): `MermaidConfig`
|
||||
▸ **getConfig**(): `MermaidConfigWithDefaults`
|
||||
|
||||
## getConfig
|
||||
|
||||
@@ -54,19 +54,19 @@ Pushes in a directive to the configuration
|
||||
|
||||
#### Returns
|
||||
|
||||
`MermaidConfig`
|
||||
`MermaidConfigWithDefaults`
|
||||
|
||||
The currentConfig
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:131](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L131)
|
||||
[config.ts:134](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L134)
|
||||
|
||||
---
|
||||
|
||||
### getSiteConfig
|
||||
|
||||
▸ **getSiteConfig**(): `MermaidConfig`
|
||||
▸ **getSiteConfig**(): `MermaidConfigWithDefaults`
|
||||
|
||||
## getSiteConfig
|
||||
|
||||
@@ -78,13 +78,13 @@ The currentConfig
|
||||
|
||||
#### Returns
|
||||
|
||||
`MermaidConfig`
|
||||
`MermaidConfigWithDefaults`
|
||||
|
||||
The siteConfig
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:96](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L96)
|
||||
[config.ts:99](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L99)
|
||||
|
||||
---
|
||||
|
||||
@@ -108,9 +108,9 @@ The siteConfig
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| :------- | :-------------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `config` | `MermaidConfig` | `siteConfig` | base set of values, which currentConfig could be **reset** to. Defaults to the current siteConfig (e.g returned by [getSiteConfig](config.md#getsiteconfig)). |
|
||||
| Name | Type | Default value | Description |
|
||||
| :------- | :-------------------------- | :------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `config` | `MermaidConfigWithDefaults` | `siteConfig` | base set of values, which currentConfig could be **reset** to. Defaults to the current siteConfig (e.g returned by [getSiteConfig](config.md#getsiteconfig)). |
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -118,7 +118,7 @@ The siteConfig
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:218](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L218)
|
||||
[config.ts:221](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L221)
|
||||
|
||||
---
|
||||
|
||||
@@ -147,7 +147,7 @@ options in-place
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:146](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L146)
|
||||
[config.ts:149](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L149)
|
||||
|
||||
---
|
||||
|
||||
@@ -157,9 +157,9 @@ options in-place
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :----- | :-------------- |
|
||||
| `conf` | `MermaidConfig` |
|
||||
| Name | Type |
|
||||
| :----- | :--------------------------------------------------- |
|
||||
| `conf` | `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}> |
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -167,13 +167,13 @@ options in-place
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:75](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L75)
|
||||
[config.ts:78](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L78)
|
||||
|
||||
---
|
||||
|
||||
### setConfig
|
||||
|
||||
▸ **setConfig**(`conf`): `MermaidConfig`
|
||||
▸ **setConfig**(`conf`): `MermaidConfigWithDefaults`
|
||||
|
||||
## setConfig
|
||||
|
||||
@@ -187,25 +187,25 @@ corresponding siteConfig value.
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :----- | :-------------- | :-------------------------- |
|
||||
| `conf` | `MermaidConfig` | The potential currentConfig |
|
||||
| Name | Type | Description |
|
||||
| :----- | :--------------------------------------------------- | :-------------------------- |
|
||||
| `conf` | `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}> | The potential currentConfig |
|
||||
|
||||
#### Returns
|
||||
|
||||
`MermaidConfig`
|
||||
`MermaidConfigWithDefaults`
|
||||
|
||||
The currentConfig merged with the sanitized conf
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:113](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L113)
|
||||
[config.ts:116](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L116)
|
||||
|
||||
---
|
||||
|
||||
### setSiteConfig
|
||||
|
||||
▸ **setSiteConfig**(`conf`): `MermaidConfig`
|
||||
▸ **setSiteConfig**(`conf`): `MermaidConfigWithDefaults`
|
||||
|
||||
## setSiteConfig
|
||||
|
||||
@@ -220,36 +220,36 @@ function _Default value: At default, will mirror Global Config_
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
| :----- | :-------------- | :------------------------------------------ |
|
||||
| `conf` | `MermaidConfig` | The base currentConfig to use as siteConfig |
|
||||
| Name | Type | Description |
|
||||
| :----- | :--------------------------------------------------- | :------------------------------------------ |
|
||||
| `conf` | `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}> | The base currentConfig to use as siteConfig |
|
||||
|
||||
#### Returns
|
||||
|
||||
`MermaidConfig`
|
||||
`MermaidConfigWithDefaults`
|
||||
|
||||
The new siteConfig
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:61](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L61)
|
||||
[config.ts:64](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L64)
|
||||
|
||||
---
|
||||
|
||||
### updateCurrentConfig
|
||||
|
||||
▸ **updateCurrentConfig**(`siteCfg`, `_directives`): `MermaidConfig`
|
||||
▸ **updateCurrentConfig**(`siteCfg`, `_directives`): `MermaidConfigWithDefaults`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------------ | :----------------- |
|
||||
| `siteCfg` | `MermaidConfig` |
|
||||
| `_directives` | `MermaidConfig`\[] |
|
||||
| Name | Type |
|
||||
| :------------ | :------------------------------------------------------ |
|
||||
| `siteCfg` | `MermaidConfigWithDefaults` |
|
||||
| `_directives` | `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}>\[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`MermaidConfig`
|
||||
`MermaidConfigWithDefaults`
|
||||
|
||||
#### Defined in
|
||||
|
||||
@@ -259,18 +259,18 @@ The new siteConfig
|
||||
|
||||
### updateSiteConfig
|
||||
|
||||
▸ **updateSiteConfig**(`conf`): `MermaidConfig`
|
||||
▸ **updateSiteConfig**(`conf`): `MermaidConfigWithDefaults`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :----- | :-------------- |
|
||||
| `conf` | `MermaidConfig` |
|
||||
| Name | Type |
|
||||
| :----- | :--------------------------------------------------- |
|
||||
| `conf` | `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}> |
|
||||
|
||||
#### Returns
|
||||
|
||||
`MermaidConfig`
|
||||
`MermaidConfigWithDefaults`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[config.ts:79](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L79)
|
||||
[config.ts:82](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.ts#L82)
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
### default
|
||||
|
||||
• `Const` **default**: `RequiredDeep`<`MermaidConfig`>
|
||||
• `Const` **default**: `RequiredDeep`<`MermaidConfigWithDefaults`>
|
||||
|
||||
Default mermaid configuration options.
|
||||
|
||||
|
@@ -32,7 +32,7 @@ Renames and re-exports [mermaidAPI](mermaidAPI.md#mermaidapi)
|
||||
|
||||
### mermaidAPI
|
||||
|
||||
• `Const` **mermaidAPI**: `Readonly`<{ `defaultConfig`: `MermaidConfig` = configApi.defaultConfig; `getConfig`: () => `MermaidConfig` = configApi.getConfig; `getDiagramFromText`: (`text`: `string`, `metadata`: `Pick`<`DiagramMetadata`, `"title"`>) => `Promise`<`Diagram`> ; `getSiteConfig`: () => `MermaidConfig` = configApi.getSiteConfig; `globalReset`: () => `void` ; `initialize`: (`options`: `MermaidConfig`) => `void` ; `parse`: (`text`: `string`, `parseOptions`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md) & { `suppressErrors`: `true` }) => `Promise`<[`ParseResult`](../interfaces/mermaidAPI.ParseResult.md) | `false`>(`text`: `string`, `parseOptions?`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md)) => `Promise`<[`ParseResult`](../interfaces/mermaidAPI.ParseResult.md)> ; `render`: (`id`: `string`, `text`: `string`, `svgContainingElement?`: `Element`) => `Promise`<[`RenderResult`](../interfaces/mermaidAPI.RenderResult.md)> ; `reset`: () => `void` ; `setConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.setConfig; `updateSiteConfig`: (`conf`: `MermaidConfig`) => `MermaidConfig` = configApi.updateSiteConfig }>
|
||||
• `Const` **mermaidAPI**: `Readonly`<{ `defaultConfig`: `MermaidConfigWithDefaults` = configApi.defaultConfig; `getConfig`: () => `MermaidConfigWithDefaults` = configApi.getConfig; `getDiagramFromText`: (`text`: `string`, `metadata`: `Pick`<`DiagramMetadata`, `"title"`>) => `Promise`<`Diagram`> ; `getSiteConfig`: () => `MermaidConfigWithDefaults` = configApi.getSiteConfig; `globalReset`: () => `void` ; `initialize`: (`options`: `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}>) => `void` ; `parse`: (`text`: `string`, `parseOptions`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md) & { `suppressErrors`: `true` }) => `Promise`<[`ParseResult`](../interfaces/mermaidAPI.ParseResult.md) | `false`>(`text`: `string`, `parseOptions?`: [`ParseOptions`](../interfaces/mermaidAPI.ParseOptions.md)) => `Promise`<[`ParseResult`](../interfaces/mermaidAPI.ParseResult.md)> ; `render`: (`id`: `string`, `text`: `string`, `svgContainingElement?`: `Element`) => `Promise`<[`RenderResult`](../interfaces/mermaidAPI.RenderResult.md)> ; `reset`: () => `void` ; `setConfig`: (`conf`: `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}>) => `MermaidConfigWithDefaults` = configApi.setConfig; `updateSiteConfig`: (`conf`: `PartialObjectDeep`<`MermaidConfigWithDefaults`, {}>) => `MermaidConfigWithDefaults` = configApi.updateSiteConfig }>
|
||||
|
||||
## mermaidAPI configuration defaults
|
||||
|
||||
@@ -169,7 +169,7 @@ Create the user styles
|
||||
|
||||
| Name | Type | Description |
|
||||
| :---------- | :------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `config` | `MermaidConfig` | configuration that has style and theme settings to use |
|
||||
| `config` | `MermaidConfigWithDefaults` | configuration that has style and theme settings to use |
|
||||
| `classDefs` | `undefined` \| `null` \| `Record`<`string`, `DiagramStyleClassDef`> | the classDefs in the diagram text. Might be null if none were defined. Usually is the result of a call to getClasses(...) |
|
||||
|
||||
#### Returns
|
||||
@@ -192,7 +192,7 @@ the string with all the user styles
|
||||
|
||||
| Name | Type |
|
||||
| :---------- | :-------------------------------------------------------- |
|
||||
| `config` | `MermaidConfig` |
|
||||
| `config` | `MermaidConfigWithDefaults` |
|
||||
| `graphType` | `string` |
|
||||
| `classDefs` | `undefined` \| `Record`<`string`, `DiagramStyleClassDef`> |
|
||||
| `svgId` | `string` |
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import type { MermaidConfig } from 'mermaid';
|
||||
import type { MermaidConfigWithDefaults } from 'mermaid';
|
||||
|
||||
const warning = (s: string) => {
|
||||
// Todo remove debug code
|
||||
@@ -27,7 +27,7 @@ export const log: Record<keyof typeof LEVELS, typeof console.log> = {
|
||||
};
|
||||
|
||||
export let setLogLevel: (level: keyof typeof LEVELS | number | string) => void;
|
||||
export let getConfig: () => MermaidConfig;
|
||||
export let getConfig: () => MermaidConfigWithDefaults;
|
||||
export let sanitizeText: (str: string) => string;
|
||||
// eslint-disable @typescript-eslint/no-explicit-any
|
||||
export let setupGraphViewbox: (
|
||||
|
@@ -114,7 +114,7 @@
|
||||
"jison": "^0.4.18",
|
||||
"js-base64": "^3.7.7",
|
||||
"jsdom": "^24.0.0",
|
||||
"json-schema-to-typescript": "^13.1.2",
|
||||
"json-schema-to-typescript": "^14.0.4",
|
||||
"micromatch": "^4.0.5",
|
||||
"path-browserify": "^1.0.1",
|
||||
"prettier": "^3.2.5",
|
||||
|
@@ -25,7 +25,7 @@ import prettier from 'prettier';
|
||||
const Ajv2019 = _Ajv2019 as unknown as typeof _Ajv2019.default;
|
||||
|
||||
// !!! -- The config.type.js file is created by this script -- !!!
|
||||
import type { MermaidConfig } from '../src/config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../src/config.type.js';
|
||||
|
||||
// options for running the main command
|
||||
const verifyOnly = process.argv.includes('--verify');
|
||||
@@ -33,7 +33,7 @@ const verifyOnly = process.argv.includes('--verify');
|
||||
const git = process.argv.includes('--git');
|
||||
|
||||
/**
|
||||
* Loads the MermaidConfig JSON schema YAML file.
|
||||
* Loads the MermaidConfigWithDefaults JSON schema YAML file.
|
||||
*
|
||||
* @returns The loaded JSON Schema, use {@link validateSchema} to confirm it is a valid JSON Schema.
|
||||
*/
|
||||
@@ -55,7 +55,9 @@ async function loadJsonSchemaFromYaml() {
|
||||
* @param jsonSchema - The value to validate as JSON Schema 2019-09
|
||||
* @throws {Error} if the given object is invalid.
|
||||
*/
|
||||
function validateSchema(jsonSchema: unknown): asserts jsonSchema is JSONSchemaType<MermaidConfig> {
|
||||
function validateSchema(
|
||||
jsonSchema: unknown
|
||||
): asserts jsonSchema is JSONSchemaType<MermaidConfigWithDefaults> {
|
||||
if (typeof jsonSchema !== 'object') {
|
||||
throw new Error(`jsonSchema param is not an object: actual type is ${typeof jsonSchema}`);
|
||||
}
|
||||
@@ -85,7 +87,7 @@ function validateSchema(jsonSchema: unknown): asserts jsonSchema is JSONSchemaTy
|
||||
*
|
||||
* @param mermaidConfigSchema - The input JSON Schema.
|
||||
*/
|
||||
async function generateTypescript(mermaidConfigSchema: JSONSchemaType<MermaidConfig>) {
|
||||
async function generateTypescript(mermaidConfigSchema: JSONSchemaType<MermaidConfigWithDefaults>) {
|
||||
/**
|
||||
* Replace all usages of `allOf` with `extends`.
|
||||
*
|
||||
@@ -107,37 +109,19 @@ async function generateTypescript(mermaidConfigSchema: JSONSchemaType<MermaidCon
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* For backwards compatibility with older Mermaid Typescript defs,
|
||||
* we need to make all value optional instead of required.
|
||||
*
|
||||
* This is because the `MermaidConfig` type is used as an input, and everything is optional,
|
||||
* since all the required values have default values.s
|
||||
*
|
||||
* In the future, we should make make the input to Mermaid `Partial<MermaidConfig>`.
|
||||
*
|
||||
* @todo TODO: Remove this function when Mermaid releases a new breaking change.
|
||||
* @param schema - The input schema.
|
||||
* @returns The schema with all required values removed.
|
||||
*/
|
||||
function removeRequired(schema: JSONSchemaType<Record<string, any>>) {
|
||||
return { ...schema, required: [] };
|
||||
}
|
||||
|
||||
assert.ok(mermaidConfigSchema.$defs);
|
||||
const modifiedSchema = {
|
||||
...removeRequired(mermaidConfigSchema),
|
||||
|
||||
...mermaidConfigSchema,
|
||||
$defs: Object.fromEntries(
|
||||
Object.entries(mermaidConfigSchema.$defs).map(([key, subSchema]) => {
|
||||
return [key, removeRequired(replaceAllOfWithExtends(subSchema))];
|
||||
return [key, replaceAllOfWithExtends(subSchema as JSONSchemaType<Record<string, any>>)];
|
||||
})
|
||||
),
|
||||
};
|
||||
|
||||
const typescriptFile = await compile(
|
||||
modifiedSchema as JSONSchema, // json-schema-to-typescript only allows JSON Schema 4 as input type
|
||||
'MermaidConfig',
|
||||
modifiedSchema as unknown as JSONSchema, // json-schema-to-typescript only allows JSON Schema 4 as input type
|
||||
'MermaidConfigWithDefaults',
|
||||
{
|
||||
additionalProperties: false, // in JSON Schema 2019-09, these are called `unevaluatedProperties`
|
||||
unreachableDefinitions: true, // definition for FontConfig is unreachable
|
||||
@@ -191,6 +175,7 @@ async function main() {
|
||||
}
|
||||
|
||||
const configJsonSchema = await loadJsonSchemaFromYaml();
|
||||
// TODO: Add code to mark objects with default values as required
|
||||
|
||||
removeProp(configJsonSchema, 'default');
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import { expect, it } from 'vitest';
|
||||
import * as configApi from './config.js';
|
||||
import type { MermaidConfig } from './config.type.js';
|
||||
import type { MermaidConfig, MermaidConfigWithDefaults } from './config.type.js';
|
||||
|
||||
describe('when working with site config', () => {
|
||||
beforeEach(() => {
|
||||
@@ -17,12 +18,12 @@ describe('when working with site config', () => {
|
||||
expect(config_1).toEqual(config_2);
|
||||
});
|
||||
it('should respect secure keys when applying directives', () => {
|
||||
const config_0: MermaidConfig = {
|
||||
const config_0 = {
|
||||
fontFamily: 'foo-font',
|
||||
securityLevel: 'strict', // can't be changed
|
||||
fontSize: 12345, // can't be changed
|
||||
secure: [...configApi.defaultConfig.secure!, 'fontSize'],
|
||||
};
|
||||
} as MermaidConfigWithDefaults;
|
||||
configApi.setSiteConfig(config_0);
|
||||
const directive: MermaidConfig = {
|
||||
fontFamily: 'baf',
|
||||
@@ -30,7 +31,7 @@ describe('when working with site config', () => {
|
||||
fontSize: 54321,
|
||||
securityLevel: 'loose',
|
||||
};
|
||||
const cfg: MermaidConfig = configApi.updateCurrentConfig(config_0, [directive]);
|
||||
const cfg: MermaidConfigWithDefaults = configApi.updateCurrentConfig(config_0, [directive]);
|
||||
expect(cfg.fontFamily).toEqual(directive.fontFamily);
|
||||
expect(cfg.fontSize).toBe(config_0.fontSize);
|
||||
expect(cfg.securityLevel).toBe(config_0.securityLevel);
|
||||
|
@@ -1,20 +1,23 @@
|
||||
import assignWithDepth from './assignWithDepth.js';
|
||||
import type { MermaidConfigWithDefaults, MermaidConfig } from './config.type.js';
|
||||
import config from './defaultConfig.js';
|
||||
import { log } from './logger.js';
|
||||
import theme from './themes/index.js';
|
||||
import config from './defaultConfig.js';
|
||||
import type { MermaidConfig } from './config.type.js';
|
||||
import { sanitizeDirective } from './utils/sanitizeDirective.js';
|
||||
|
||||
export const defaultConfig: MermaidConfig = Object.freeze(config);
|
||||
export const defaultConfig: MermaidConfigWithDefaults = Object.freeze(config);
|
||||
|
||||
let siteConfig: MermaidConfig = assignWithDepth({}, defaultConfig);
|
||||
let siteConfig: MermaidConfigWithDefaults = assignWithDepth({}, defaultConfig);
|
||||
let configFromInitialize: MermaidConfig;
|
||||
let directives: MermaidConfig[] = [];
|
||||
let currentConfig: MermaidConfig = assignWithDepth({}, defaultConfig);
|
||||
let currentConfig: MermaidConfigWithDefaults = assignWithDepth({}, defaultConfig);
|
||||
|
||||
export const updateCurrentConfig = (siteCfg: MermaidConfig, _directives: MermaidConfig[]) => {
|
||||
export const updateCurrentConfig = (
|
||||
siteCfg: MermaidConfigWithDefaults,
|
||||
_directives: MermaidConfig[]
|
||||
) => {
|
||||
// start with config being the siteConfig
|
||||
let cfg: MermaidConfig = assignWithDepth({}, siteCfg);
|
||||
let cfg: MermaidConfigWithDefaults = assignWithDepth({}, siteCfg);
|
||||
// let sCfg = assignWithDepth(defaultConfig, siteConfigDelta);
|
||||
|
||||
// Join directives
|
||||
@@ -58,7 +61,7 @@ export const updateCurrentConfig = (siteCfg: MermaidConfig, _directives: Mermaid
|
||||
* @param conf - The base currentConfig to use as siteConfig
|
||||
* @returns The new siteConfig
|
||||
*/
|
||||
export const setSiteConfig = (conf: MermaidConfig): MermaidConfig => {
|
||||
export const setSiteConfig = (conf: MermaidConfig): MermaidConfigWithDefaults => {
|
||||
siteConfig = assignWithDepth({}, defaultConfig);
|
||||
siteConfig = assignWithDepth(siteConfig, conf);
|
||||
|
||||
@@ -76,7 +79,7 @@ export const saveConfigFromInitialize = (conf: MermaidConfig): void => {
|
||||
configFromInitialize = assignWithDepth({}, conf);
|
||||
};
|
||||
|
||||
export const updateSiteConfig = (conf: MermaidConfig): MermaidConfig => {
|
||||
export const updateSiteConfig = (conf: MermaidConfig): MermaidConfigWithDefaults => {
|
||||
siteConfig = assignWithDepth(siteConfig, conf);
|
||||
updateCurrentConfig(siteConfig, directives);
|
||||
|
||||
@@ -93,7 +96,7 @@ export const updateSiteConfig = (conf: MermaidConfig): MermaidConfig => {
|
||||
*
|
||||
* @returns The siteConfig
|
||||
*/
|
||||
export const getSiteConfig = (): MermaidConfig => {
|
||||
export const getSiteConfig = (): MermaidConfigWithDefaults => {
|
||||
return assignWithDepth({}, siteConfig);
|
||||
};
|
||||
/**
|
||||
@@ -110,7 +113,7 @@ export const getSiteConfig = (): MermaidConfig => {
|
||||
* @param conf - The potential currentConfig
|
||||
* @returns The currentConfig merged with the sanitized conf
|
||||
*/
|
||||
export const setConfig = (conf: MermaidConfig): MermaidConfig => {
|
||||
export const setConfig = (conf: MermaidConfig): MermaidConfigWithDefaults => {
|
||||
checkConfig(conf);
|
||||
assignWithDepth(currentConfig, conf);
|
||||
|
||||
@@ -128,7 +131,7 @@ export const setConfig = (conf: MermaidConfig): MermaidConfig => {
|
||||
*
|
||||
* @returns The currentConfig
|
||||
*/
|
||||
export const getConfig = (): MermaidConfig => {
|
||||
export const getConfig = (): MermaidConfigWithDefaults => {
|
||||
return assignWithDepth({}, currentConfig);
|
||||
};
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,5 @@
|
||||
import type { RequiredDeep } from 'type-fest';
|
||||
|
||||
import type { MermaidConfigWithDefaults } from './config.type.js';
|
||||
import theme from './themes/index.js';
|
||||
import type { MermaidConfig } from './config.type.js';
|
||||
|
||||
// Uses our custom Vite jsonSchemaPlugin to load only the default values from
|
||||
// our JSON Schema
|
||||
// @ts-expect-error This file is automatically generated via a custom Vite plugin
|
||||
@@ -15,7 +12,7 @@ import defaultConfigJson from './schemas/config.schema.yaml?only-defaults=true';
|
||||
* Non-JSON JS default values are listed in this file, e.g. functions, or
|
||||
* `undefined` (explicitly set so that `configKeys` finds them).
|
||||
*/
|
||||
const config: RequiredDeep<MermaidConfig> = {
|
||||
const config: MermaidConfigWithDefaults = {
|
||||
...defaultConfigJson,
|
||||
// Set, even though they're `undefined` so that `configKeys` finds these keys
|
||||
// TODO: Should we replace these with `null` so that they can go in the JSON Schema?
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import type { MermaidConfig } from '../config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../config.type.js';
|
||||
import { UnknownDiagramError } from '../errors.js';
|
||||
import { log } from '../logger.js';
|
||||
import { anyCommentRegex, directiveRegex, frontMatterRegex } from './regexes.js';
|
||||
import type {
|
||||
DetectorRecord,
|
||||
DiagramDetector,
|
||||
DiagramLoader,
|
||||
ExternalDiagramDefinition,
|
||||
} from './types.js';
|
||||
import { anyCommentRegex, directiveRegex, frontMatterRegex } from './regexes.js';
|
||||
import { UnknownDiagramError } from '../errors.js';
|
||||
|
||||
export const detectors: Record<string, DetectorRecord> = {};
|
||||
|
||||
@@ -33,7 +33,7 @@ export const detectors: Record<string, DetectorRecord> = {};
|
||||
* @param config - The mermaid config.
|
||||
* @returns A graph definition key
|
||||
*/
|
||||
export const detectType = function (text: string, config?: MermaidConfig): string {
|
||||
export const detectType = function (text: string, config?: MermaidConfigWithDefaults): string {
|
||||
text = text
|
||||
.replace(frontMatterRegex, '')
|
||||
.replace(directiveRegex, '')
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { it, describe, expect } from 'vitest';
|
||||
import { describe, expect, it, beforeAll } from 'vitest';
|
||||
import type { MermaidConfigWithDefaults } from '../config.type.js';
|
||||
import { detectType } from './detectType.js';
|
||||
import { addDiagrams } from './diagram-orchestration.js';
|
||||
|
||||
@@ -46,30 +47,40 @@ describe('diagram-orchestration', () => {
|
||||
// graph & dagre-d3 => flowchart
|
||||
expect(detectType('graph TD; A-->B')).toBe('flowchart');
|
||||
// graph & dagre-d3 => flowchart
|
||||
expect(detectType('graph TD; A-->B', { flowchart: { defaultRenderer: 'dagre-d3' } })).toBe(
|
||||
'flowchart'
|
||||
);
|
||||
expect(
|
||||
detectType('graph TD; A-->B', {
|
||||
flowchart: { defaultRenderer: 'dagre-d3' },
|
||||
} as MermaidConfigWithDefaults)
|
||||
).toBe('flowchart');
|
||||
// flowchart & dagre-d3 => error
|
||||
expect(() =>
|
||||
detectType('flowchart TD; A-->B', { flowchart: { defaultRenderer: 'dagre-d3' } })
|
||||
detectType('flowchart TD; A-->B', {
|
||||
flowchart: { defaultRenderer: 'dagre-d3' },
|
||||
} as MermaidConfigWithDefaults)
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`[UnknownDiagramError: No diagram type detected matching given configuration for text: flowchart TD; A-->B]`
|
||||
);
|
||||
|
||||
// graph & dagre-wrapper => flowchart-v2
|
||||
expect(
|
||||
detectType('graph TD; A-->B', { flowchart: { defaultRenderer: 'dagre-wrapper' } })
|
||||
detectType('graph TD; A-->B', {
|
||||
flowchart: { defaultRenderer: 'dagre-wrapper' },
|
||||
} as MermaidConfigWithDefaults)
|
||||
).toBe('flowchart-v2');
|
||||
// flowchart ==> flowchart-v2
|
||||
expect(detectType('flowchart TD; A-->B')).toBe('flowchart-v2');
|
||||
// flowchart && dagre-wrapper ==> flowchart-v2
|
||||
expect(
|
||||
detectType('flowchart TD; A-->B', { flowchart: { defaultRenderer: 'dagre-wrapper' } })
|
||||
detectType('flowchart TD; A-->B', {
|
||||
flowchart: { defaultRenderer: 'dagre-wrapper' },
|
||||
} as MermaidConfigWithDefaults)
|
||||
).toBe('flowchart-v2');
|
||||
// flowchart && elk ==> flowchart-elk
|
||||
expect(detectType('flowchart TD; A-->B', { flowchart: { defaultRenderer: 'elk' } })).toBe(
|
||||
'flowchart-elk'
|
||||
);
|
||||
expect(
|
||||
detectType('flowchart TD; A-->B', {
|
||||
flowchart: { defaultRenderer: 'elk' },
|
||||
} as MermaidConfigWithDefaults)
|
||||
).toBe('flowchart-elk');
|
||||
});
|
||||
|
||||
it('should not detect flowchart if pie contains flowchart', () => {
|
||||
|
@@ -5,7 +5,7 @@ import {
|
||||
} from 'd3';
|
||||
import type { Diagram } from '../../Diagram.js';
|
||||
import * as configApi from '../../config.js';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../../config.type.js';
|
||||
import insertMarkers from '../../dagre-wrapper/markers.js';
|
||||
import { log } from '../../logger.js';
|
||||
import { configureSvgSize } from '../../setupGraphViewbox.js';
|
||||
@@ -75,7 +75,7 @@ export const draw = async function (
|
||||
const magicFactor = Math.max(1, Math.round(0.125 * (bounds2.width / bounds2.height)));
|
||||
const height = bounds2.height + magicFactor + 10;
|
||||
const width = bounds2.width + 10;
|
||||
const { useMaxWidth } = conf as Exclude<MermaidConfig['block'], undefined>;
|
||||
const { useMaxWidth } = conf as Exclude<MermaidConfigWithDefaults['block'], undefined>;
|
||||
configureSvgSize(svg, height, width, !!useMaxWidth);
|
||||
log.debug('Here Bounds', bounds, bounds2);
|
||||
svg.attr(
|
||||
|
@@ -1,17 +1,16 @@
|
||||
// @ts-ignore: JISON doesn't support types
|
||||
import parser from './parser/c4Diagram.jison';
|
||||
import type { DiagramDefinition } from '../../diagram-api/types.js';
|
||||
import db from './c4Db.js';
|
||||
import renderer from './c4Renderer.js';
|
||||
// @ts-ignore: JISON doesn't support types
|
||||
import parser from './parser/c4Diagram.jison';
|
||||
import styles from './styles.js';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import type { DiagramDefinition } from '../../diagram-api/types.js';
|
||||
|
||||
export const diagram: DiagramDefinition = {
|
||||
parser,
|
||||
db,
|
||||
renderer,
|
||||
styles,
|
||||
init: ({ c4, wrap }: MermaidConfig) => {
|
||||
init: ({ c4, wrap }) => {
|
||||
renderer.setConf(c4);
|
||||
db.setWrap(wrap);
|
||||
},
|
||||
|
@@ -1,4 +1,6 @@
|
||||
import { sanitizeText, removeScript, parseGenericTypes, countOccurrence } from './common.js';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { MermaidConfigWithDefaults } from '../../config.type.js';
|
||||
import { countOccurrence, parseGenericTypes, removeScript, sanitizeText } from './common.js';
|
||||
|
||||
describe('when securityLevel is antiscript, all script must be removed', () => {
|
||||
/**
|
||||
@@ -67,7 +69,7 @@ describe('Sanitize text', () => {
|
||||
const result = sanitizeText(maliciousStr, {
|
||||
securityLevel: 'strict',
|
||||
flowchart: { htmlLabels: true },
|
||||
});
|
||||
} as MermaidConfigWithDefaults);
|
||||
expect(result).not.toContain('javascript:alert(1)');
|
||||
});
|
||||
});
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import DOMPurify from 'dompurify';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../../config.type.js';
|
||||
|
||||
// Remove and ignore br:s
|
||||
export const lineBreakRegex = /<br\s*\/?>/gi;
|
||||
@@ -63,7 +63,7 @@ export const removeScript = (txt: string): string => {
|
||||
return sanitizedText;
|
||||
};
|
||||
|
||||
const sanitizeMore = (text: string, config: MermaidConfig) => {
|
||||
const sanitizeMore = (text: string, config: MermaidConfigWithDefaults) => {
|
||||
if (config.flowchart?.htmlLabels !== false) {
|
||||
const level = config.securityLevel;
|
||||
if (level === 'antiscript' || level === 'strict') {
|
||||
@@ -78,7 +78,7 @@ const sanitizeMore = (text: string, config: MermaidConfig) => {
|
||||
return text;
|
||||
};
|
||||
|
||||
export const sanitizeText = (text: string, config: MermaidConfig): string => {
|
||||
export const sanitizeText = (text: string, config: MermaidConfigWithDefaults): string => {
|
||||
if (!text) {
|
||||
return text;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ export const sanitizeText = (text: string, config: MermaidConfig): string => {
|
||||
|
||||
export const sanitizeTextOrArray = (
|
||||
a: string | string[] | string[][],
|
||||
config: MermaidConfig
|
||||
config: MermaidConfigWithDefaults
|
||||
): string | string[] => {
|
||||
if (typeof a === 'string') {
|
||||
return sanitizeText(a, config);
|
||||
@@ -310,7 +310,10 @@ export const hasKatex = (text: string): boolean => (text.match(katexRegex)?.leng
|
||||
* @param config - Configuration for Mermaid
|
||||
* @returns Object containing \{width, height\}
|
||||
*/
|
||||
export const calculateMathMLDimensions = async (text: string, config: MermaidConfig) => {
|
||||
export const calculateMathMLDimensions = async (
|
||||
text: string,
|
||||
config: MermaidConfigWithDefaults
|
||||
) => {
|
||||
text = await renderKatex(text, config);
|
||||
const divElem = document.createElement('div');
|
||||
divElem.innerHTML = text;
|
||||
@@ -332,7 +335,10 @@ export const calculateMathMLDimensions = async (text: string, config: MermaidCon
|
||||
* @param config - Configuration for Mermaid
|
||||
* @returns String containing MathML if KaTeX is supported, or an error message if it is not and stylesheets aren't present
|
||||
*/
|
||||
export const renderKatex = async (text: string, config: MermaidConfig): Promise<string> => {
|
||||
export const renderKatex = async (
|
||||
text: string,
|
||||
config: MermaidConfigWithDefaults
|
||||
): Promise<string> => {
|
||||
if (!hasKatex(text)) {
|
||||
return text;
|
||||
}
|
||||
|
@@ -1,17 +1,17 @@
|
||||
// @ts-ignore: JISON doesn't support types
|
||||
import flowParser from './parser/flow.jison';
|
||||
import { setConfig } from '../../diagram-api/diagramAPI.js';
|
||||
import type { DiagramDefinition } from '../../diagram-api/types.js';
|
||||
import flowDb from './flowDb.js';
|
||||
import flowRendererV2 from './flowRenderer-v2.js';
|
||||
// @ts-ignore: JISON doesn't support types
|
||||
import flowParser from './parser/flow.jison';
|
||||
import flowStyles from './styles.js';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import { setConfig } from '../../diagram-api/diagramAPI.js';
|
||||
|
||||
export const diagram = {
|
||||
export const diagram: DiagramDefinition = {
|
||||
parser: flowParser,
|
||||
db: flowDb,
|
||||
renderer: flowRendererV2,
|
||||
styles: flowStyles,
|
||||
init: (cnf: MermaidConfig) => {
|
||||
init: (cnf) => {
|
||||
if (!cnf.flowchart) {
|
||||
cnf.flowchart = {};
|
||||
}
|
||||
|
@@ -1,17 +1,17 @@
|
||||
import type { DiagramDefinition } from '../../diagram-api/types.js';
|
||||
import flowDb from './flowDb.js';
|
||||
import flowRendererV2 from './flowRenderer-v2.js';
|
||||
import flowRenderer from './flowRenderer.js';
|
||||
// @ts-ignore: JISON doesn't support types
|
||||
import flowParser from './parser/flow.jison';
|
||||
import flowDb from './flowDb.js';
|
||||
import flowRenderer from './flowRenderer.js';
|
||||
import flowRendererV2 from './flowRenderer-v2.js';
|
||||
import flowStyles from './styles.js';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
|
||||
export const diagram = {
|
||||
export const diagram: DiagramDefinition = {
|
||||
parser: flowParser,
|
||||
db: flowDb,
|
||||
renderer: flowRendererV2,
|
||||
styles: flowStyles,
|
||||
init: (cnf: MermaidConfig) => {
|
||||
init: (cnf) => {
|
||||
if (!cnf.flowchart) {
|
||||
cnf.flowchart = {};
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import cytoscape from 'cytoscape';
|
||||
// @ts-expect-error No types available
|
||||
// @ts-ignore Types for cose-bilkent are not present
|
||||
import coseBilkent from 'cytoscape-cose-bilkent';
|
||||
import { select } from 'd3';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../../config.type.js';
|
||||
import { getConfig } from '../../diagram-api/diagramAPI.js';
|
||||
import type { DrawDefinition } from '../../diagram-api/types.js';
|
||||
import { log } from '../../logger.js';
|
||||
@@ -21,7 +21,7 @@ function drawNodes(
|
||||
svg: D3Element,
|
||||
mindmap: FilledMindMapNode,
|
||||
section: number,
|
||||
conf: MermaidConfig
|
||||
conf: MermaidConfigWithDefaults
|
||||
) {
|
||||
drawNode(db, svg, mindmap, section, conf);
|
||||
if (mindmap.children) {
|
||||
@@ -64,7 +64,12 @@ function drawEdges(edgesEl: D3Element, cy: cytoscape.Core) {
|
||||
});
|
||||
}
|
||||
|
||||
function addNodes(mindmap: MindmapNode, cy: cytoscape.Core, conf: MermaidConfig, level: number) {
|
||||
function addNodes(
|
||||
mindmap: MindmapNode,
|
||||
cy: cytoscape.Core,
|
||||
conf: MermaidConfigWithDefaults,
|
||||
level: number
|
||||
) {
|
||||
cy.add({
|
||||
group: 'nodes',
|
||||
data: {
|
||||
@@ -99,7 +104,10 @@ function addNodes(mindmap: MindmapNode, cy: cytoscape.Core, conf: MermaidConfig,
|
||||
}
|
||||
}
|
||||
|
||||
function layoutMindmap(node: MindmapNode, conf: MermaidConfig): Promise<cytoscape.Core> {
|
||||
function layoutMindmap(
|
||||
node: MindmapNode,
|
||||
conf: MermaidConfigWithDefaults
|
||||
): Promise<cytoscape.Core> {
|
||||
return new Promise((resolve) => {
|
||||
// Add temporary render element
|
||||
const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');
|
||||
|
@@ -3,7 +3,7 @@ import { createText } from '../../rendering-util/createText.js';
|
||||
import type { FilledMindMapNode, MindmapDB } from './mindmapTypes.js';
|
||||
import type { Point } from '../../types.js';
|
||||
import { parseFontSize } from '../../utils.js';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../../config.type.js';
|
||||
|
||||
const MAX_SECTIONS = 12;
|
||||
|
||||
@@ -180,7 +180,7 @@ export const drawNode = function (
|
||||
elem: D3Element,
|
||||
node: FilledMindMapNode,
|
||||
fullSection: number,
|
||||
conf: MermaidConfig
|
||||
conf: MermaidConfigWithDefaults
|
||||
): number {
|
||||
const htmlLabels = conf.htmlLabels;
|
||||
const section = fullSection % (MAX_SECTIONS - 1);
|
||||
|
@@ -6,7 +6,7 @@ import { getConfig } from '../../diagram-api/diagramAPI.js';
|
||||
import { cleanAndMerge, parseFontSize } from '../../utils.js';
|
||||
import type { DrawDefinition, Group, SVG } from '../../diagram-api/types.js';
|
||||
import type { D3Section, PieDB, Sections } from './pieTypes.js';
|
||||
import type { MermaidConfig, PieDiagramConfig } from '../../config.type.js';
|
||||
import type { MermaidConfigWithDefaults, PieDiagramConfig } from '../../config.type.js';
|
||||
import { selectSvgElement } from '../../rendering-util/selectSvgElement.js';
|
||||
|
||||
const createPieArcs = (sections: Sections): d3.PieArcDatum<D3Section>[] => {
|
||||
@@ -38,7 +38,7 @@ const createPieArcs = (sections: Sections): d3.PieArcDatum<D3Section>[] => {
|
||||
export const draw: DrawDefinition = (text, id, _version, diagObj) => {
|
||||
log.debug('rendering pie chart\n' + text);
|
||||
const db = diagObj.db as PieDB;
|
||||
const globalConfig: MermaidConfig = getConfig();
|
||||
const globalConfig: MermaidConfigWithDefaults = getConfig();
|
||||
const pieConfig: Required<PieDiagramConfig> = cleanAndMerge(db.getConfig(), globalConfig.pie);
|
||||
const MARGIN = 40;
|
||||
const LEGEND_RECT_SIZE = 18;
|
||||
|
@@ -6,7 +6,7 @@ import { log } from '../../logger.js';
|
||||
import { getConfig } from '../../diagram-api/diagramAPI.js';
|
||||
import { setupGraphViewbox } from '../../setupGraphViewbox.js';
|
||||
import type { Diagram } from '../../Diagram.js';
|
||||
import type { MermaidConfig } from '../../config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../../config.type.js';
|
||||
|
||||
interface Block<TDesc, TSection> {
|
||||
number: number;
|
||||
@@ -241,7 +241,7 @@ export const drawTasks = function (
|
||||
masterX: number,
|
||||
masterY: number,
|
||||
maxTaskHeight: number,
|
||||
conf: MermaidConfig,
|
||||
conf: MermaidConfigWithDefaults,
|
||||
maxEventCount: number,
|
||||
maxEventLineLength: number,
|
||||
maxSectionHeight: number,
|
||||
@@ -318,7 +318,7 @@ export const drawEvents = function (
|
||||
sectionColor: number,
|
||||
masterX: number,
|
||||
masterY: number,
|
||||
conf: MermaidConfig
|
||||
conf: MermaidConfigWithDefaults
|
||||
) {
|
||||
let maxEventHeight = 0;
|
||||
const eventBeginY = masterY;
|
||||
|
@@ -1,9 +1,13 @@
|
||||
import mermaid, { type MermaidConfig } from 'mermaid';
|
||||
import mermaid, { type MermaidConfigWithDefaults } from 'mermaid';
|
||||
import zenuml from '../../../../../mermaid-zenuml/dist/mermaid-zenuml.core.mjs';
|
||||
|
||||
const init = mermaid.registerExternalDiagrams([zenuml]);
|
||||
|
||||
export const render = async (id: string, code: string, config: MermaidConfig): Promise<string> => {
|
||||
export const render = async (
|
||||
id: string,
|
||||
code: string,
|
||||
config: MermaidConfigWithDefaults
|
||||
): Promise<string> => {
|
||||
await init;
|
||||
mermaid.initialize(config);
|
||||
const { svg } = await mermaid.render(id, code);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* functionality and to render the diagrams to svg code!
|
||||
*/
|
||||
import { dedent } from 'ts-dedent';
|
||||
import type { MermaidConfig } from './config.type.js';
|
||||
import type { MermaidConfigWithDefaults, MermaidConfig } from './config.type.js';
|
||||
import { log } from './logger.js';
|
||||
import utils from './utils.js';
|
||||
import type { ParseOptions, ParseResult, RenderResult } from './mermaidAPI.js';
|
||||
@@ -18,6 +18,7 @@ import type { UnknownDiagramError } from './errors.js';
|
||||
import { addDiagrams } from './diagram-api/diagram-orchestration.js';
|
||||
|
||||
export type {
|
||||
MermaidConfigWithDefaults,
|
||||
MermaidConfig,
|
||||
DetailedError,
|
||||
ExternalDiagramDefinition,
|
||||
@@ -330,8 +331,8 @@ const executeQueue = async () => {
|
||||
* // throws Error
|
||||
* ```
|
||||
*/
|
||||
const parse: typeof mermaidAPI.parse = async (text, parseOptions) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const parse = async (text: string, parseOptions?: ParseOptions & { suppressErrors: true }) => {
|
||||
return new Promise<ParseResult | false>((resolve, reject) => {
|
||||
// This promise will resolve when the render call is done.
|
||||
// It will be queued first and will be executed when it is first in line
|
||||
const performCall = () =>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { vi, it, expect, describe, beforeEach } from 'vitest';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
// -------------------------------------
|
||||
// Mocks and mocking
|
||||
@@ -35,7 +35,7 @@ vi.mock('./diagrams/state/stateRenderer-v2.js');
|
||||
// -------------------------------------
|
||||
|
||||
import assignWithDepth from './assignWithDepth.js';
|
||||
import type { MermaidConfig } from './config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from './config.type.js';
|
||||
import mermaid from './mermaid.js';
|
||||
import mermaidAPI, {
|
||||
appendDivSvgG,
|
||||
@@ -67,8 +67,8 @@ vi.mock('stylis', () => {
|
||||
});
|
||||
|
||||
import { compile, serialize } from 'stylis';
|
||||
import { decodeEntities, encodeEntities } from './utils.js';
|
||||
import { Diagram } from './Diagram.js';
|
||||
import { decodeEntities, encodeEntities } from './utils.js';
|
||||
|
||||
/**
|
||||
* @see https://vitest.dev/guide/mocking.html Mock part of a module
|
||||
@@ -283,12 +283,12 @@ describe('mermaidAPI', () => {
|
||||
describe('createCssStyles', () => {
|
||||
const serif = 'serif';
|
||||
const sansSerif = 'sans-serif';
|
||||
const mocked_config_with_htmlLabels: MermaidConfig = {
|
||||
const mocked_config_with_htmlLabels = {
|
||||
themeCSS: 'default',
|
||||
fontFamily: serif,
|
||||
altFontFamily: sansSerif,
|
||||
htmlLabels: true,
|
||||
};
|
||||
} as MermaidConfigWithDefaults;
|
||||
|
||||
it('gets the cssStyles from the theme', () => {
|
||||
const styles = createCssStyles(mocked_config_with_htmlLabels, null);
|
||||
@@ -367,7 +367,7 @@ describe('mermaidAPI', () => {
|
||||
}
|
||||
|
||||
// common suite and tests to verify that the right styles are created with the right htmlElements
|
||||
function expect_correct_styles_with_htmlElements(mocked_config: MermaidConfig) {
|
||||
function expect_correct_styles_with_htmlElements(mocked_config: MermaidConfigWithDefaults) {
|
||||
describe('creates styles for "> *" and "span" elements', () => {
|
||||
const htmlElements = ['> *', 'span'];
|
||||
|
||||
@@ -389,14 +389,14 @@ describe('mermaidAPI', () => {
|
||||
});
|
||||
|
||||
it('there are flowchart.htmlLabels in the configuration', () => {
|
||||
const mocked_config_flowchart_htmlLabels: MermaidConfig = {
|
||||
const mocked_config_flowchart_htmlLabels = {
|
||||
themeCSS: 'default',
|
||||
fontFamily: 'serif',
|
||||
altFontFamily: 'sans-serif',
|
||||
flowchart: {
|
||||
htmlLabels: true,
|
||||
},
|
||||
};
|
||||
} as MermaidConfigWithDefaults;
|
||||
expect_correct_styles_with_htmlElements(mocked_config_flowchart_htmlLabels);
|
||||
});
|
||||
|
||||
@@ -405,7 +405,7 @@ describe('mermaidAPI', () => {
|
||||
themeCSS: 'default',
|
||||
fontFamily: 'serif',
|
||||
altFontFamily: 'sans-serif',
|
||||
};
|
||||
} as MermaidConfigWithDefaults;
|
||||
|
||||
describe('creates styles for shape elements "rect", "polygon", "ellipse", and "circle"', () => {
|
||||
const htmlElements = ['rect', 'polygon', 'ellipse', 'circle'];
|
||||
@@ -430,7 +430,7 @@ describe('mermaidAPI', () => {
|
||||
themeCSS: 'default',
|
||||
htmlLabels: true,
|
||||
themeVariables: { fontFamily: 'serif' },
|
||||
};
|
||||
} as MermaidConfigWithDefaults;
|
||||
|
||||
const classDef1 = { id: 'classDef1', styles: ['style1-1'], textStyles: [] };
|
||||
|
||||
|
@@ -14,22 +14,22 @@
|
||||
import { select } from 'd3';
|
||||
import { compile, serialize, stringify } from 'stylis';
|
||||
// @ts-ignore: TODO Fix ts errors
|
||||
import DOMPurify from 'dompurify';
|
||||
import isEmpty from 'lodash-es/isEmpty.js';
|
||||
import { version } from '../package.json';
|
||||
import * as configApi from './config.js';
|
||||
import { addDiagrams } from './diagram-api/diagram-orchestration.js';
|
||||
import { Diagram } from './Diagram.js';
|
||||
import { addSVGa11yTitleDescription, setA11yDiagramInfo } from './accessibility.js';
|
||||
import * as configApi from './config.js';
|
||||
import type { MermaidConfigWithDefaults, MermaidConfig } from './config.type.js';
|
||||
import { addDiagrams } from './diagram-api/diagram-orchestration.js';
|
||||
import type { DiagramMetadata, DiagramStyleClassDef } from './diagram-api/types.js';
|
||||
import { evaluate } from './diagrams/common/common.js';
|
||||
import errorRenderer from './diagrams/error/errorRenderer.js';
|
||||
import { attachFunctions } from './interactionDb.js';
|
||||
import { log, setLogLevel } from './logger.js';
|
||||
import { preprocessDiagram } from './preprocess.js';
|
||||
import getStyles from './styles.js';
|
||||
import theme from './themes/index.js';
|
||||
import DOMPurify from 'dompurify';
|
||||
import type { MermaidConfig } from './config.type.js';
|
||||
import { evaluate } from './diagrams/common/common.js';
|
||||
import isEmpty from 'lodash-es/isEmpty.js';
|
||||
import { setA11yDiagramInfo, addSVGa11yTitleDescription } from './accessibility.js';
|
||||
import type { DiagramMetadata, DiagramStyleClassDef } from './diagram-api/types.js';
|
||||
import { preprocessDiagram } from './preprocess.js';
|
||||
import { decodeEntities } from './utils.js';
|
||||
|
||||
const MAX_TEXTLENGTH = 50_000;
|
||||
@@ -151,7 +151,7 @@ export const cssImportantStyles = (
|
||||
* @returns the string with all the user styles
|
||||
*/
|
||||
export const createCssStyles = (
|
||||
config: MermaidConfig,
|
||||
config: MermaidConfigWithDefaults,
|
||||
classDefs: Record<string, DiagramStyleClassDef> | null | undefined = {}
|
||||
): string => {
|
||||
let cssStyles = '';
|
||||
@@ -198,7 +198,7 @@ export const createCssStyles = (
|
||||
};
|
||||
|
||||
export const createUserStyles = (
|
||||
config: MermaidConfig,
|
||||
config: MermaidConfigWithDefaults,
|
||||
graphType: string,
|
||||
classDefs: Record<string, DiagramStyleClassDef> | undefined,
|
||||
svgId: string
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import type { MermaidConfig } from './config.type.js';
|
||||
import { cleanupComments } from './diagram-api/comments.js';
|
||||
import { extractFrontMatter } from './diagram-api/frontmatter.js';
|
||||
import type { DiagramMetadata } from './diagram-api/types.js';
|
||||
@@ -30,7 +31,7 @@ const processFrontmatter = (code: string) => {
|
||||
};
|
||||
|
||||
const processDirectives = (code: string) => {
|
||||
const initDirective = utils.detectInit(code) ?? {};
|
||||
const initDirective: MermaidConfig = utils.detectInit(code) ?? {};
|
||||
const wrapDirectives = utils.detectDirective(code, 'wrap');
|
||||
if (Array.isArray(wrapDirectives)) {
|
||||
initDirective.wrap = wrapDirectives.some(({ type }) => {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
// @ts-nocheck TODO: Fix types
|
||||
import type { MermaidConfig } from '../config.type.js';
|
||||
import type { MermaidConfigWithDefaults } from '../config.type.js';
|
||||
import type { Group } from '../diagram-api/types.js';
|
||||
import type { D3TSpanElement, D3TextElement } from '../diagrams/common/commonTypes.js';
|
||||
import { log } from '../logger.js';
|
||||
@@ -195,7 +195,7 @@ export const createText = (
|
||||
width = 200,
|
||||
addSvgBackground = false,
|
||||
} = {},
|
||||
config: MermaidConfig
|
||||
config: MermaidConfigWithDefaults
|
||||
) => {
|
||||
log.info('createText', text, style, isTitle, classes, useHtmlLabels, isNode, addSvgBackground);
|
||||
if (useHtmlLabels) {
|
||||
|
@@ -1,14 +1,16 @@
|
||||
import type { Content } from 'mdast';
|
||||
import { fromMarkdown } from 'mdast-util-from-markdown';
|
||||
import { dedent } from 'ts-dedent';
|
||||
import type { MermaidConfigWithDefaults } from '../config.type.js';
|
||||
import type { MarkdownLine, MarkdownWordType } from './types.js';
|
||||
import type { MermaidConfig } from '../config.type.js';
|
||||
import { RootContent } from 'mdast';
|
||||
|
||||
type MarkdownConfig = Partial<Pick<MermaidConfigWithDefaults, 'markdownAutoWrap'>>;
|
||||
|
||||
/**
|
||||
* @param markdown - markdown to process
|
||||
* @returns processed markdown
|
||||
*/
|
||||
function preprocessMarkdown(markdown: string, { markdownAutoWrap }: MermaidConfig): string {
|
||||
function preprocessMarkdown(markdown: string, { markdownAutoWrap }: MarkdownConfig): string {
|
||||
// Replace multiple newlines with a single newline
|
||||
const withoutMultipleNewlines = markdown.replace(/\n{2,}/g, '\n');
|
||||
// Remove extra spaces at the beginning of each line
|
||||
@@ -22,13 +24,13 @@ function preprocessMarkdown(markdown: string, { markdownAutoWrap }: MermaidConfi
|
||||
/**
|
||||
* @param markdown - markdown to split into lines
|
||||
*/
|
||||
export function markdownToLines(markdown: string, config: MermaidConfig = {}): MarkdownLine[] {
|
||||
export function markdownToLines(markdown: string, config: MarkdownConfig = {}): MarkdownLine[] {
|
||||
const preprocessedMarkdown = preprocessMarkdown(markdown, config);
|
||||
const { children } = fromMarkdown(preprocessedMarkdown);
|
||||
const lines: MarkdownLine[] = [[]];
|
||||
let currentLine = 0;
|
||||
|
||||
function processNode(node: Content, parentType: MarkdownWordType = 'normal') {
|
||||
function processNode(node: RootContent, parentType: MarkdownWordType = 'normal') {
|
||||
if (node.type === 'text') {
|
||||
const textLines = node.value.split('\n');
|
||||
textLines.forEach((textLine, index) => {
|
||||
@@ -60,10 +62,10 @@ export function markdownToLines(markdown: string, config: MermaidConfig = {}): M
|
||||
return lines;
|
||||
}
|
||||
|
||||
export function markdownToHTML(markdown: string, { markdownAutoWrap }: MermaidConfig = {}) {
|
||||
export function markdownToHTML(markdown: string, { markdownAutoWrap }: MarkdownConfig = {}) {
|
||||
const { children } = fromMarkdown(markdown);
|
||||
|
||||
function output(node: Content): string {
|
||||
function output(node: RootContent): string {
|
||||
if (node.type === 'text') {
|
||||
if (markdownAutoWrap === false) {
|
||||
return node.value.replace(/\n/g, '<br/>').replace(/ /g, ' ');
|
||||
|
@@ -1,11 +1,11 @@
|
||||
# Used for VS Code's YAML plugin to automatically error on invalid types
|
||||
# yaml-language-server: $schema=https://json-schema.org/draft/2019-09/schema
|
||||
|
||||
# This file defines the MermaidConfig JSON Schema as a YAML file.
|
||||
# This file defines the MermaidConfigWithDefaults JSON Schema as a YAML file.
|
||||
#
|
||||
# From this file, the following things can be generated:
|
||||
# - `scripts/create-types-from-json-schema.mjs`
|
||||
# Used to generate the `src/config.type.ts` TypeScript types for MermaidConfig
|
||||
# Used to generate the `src/config.type.ts` TypeScript types for MermaidConfigWithDefaults
|
||||
# with the `json-schema-to-typescript` NPM package.
|
||||
# - `.build/jsonSchema.ts`
|
||||
# Used to generate the default values from the `default` keys in this
|
||||
@@ -20,13 +20,13 @@
|
||||
# - Use the `|` character for multi-line strings
|
||||
# - Use `meta:enum` to document enum values (from jsonschema2md)
|
||||
# - Use `tsType` to override the TypeScript type (from json-schema-to-typescript)
|
||||
# - If adding a new object to `MermaidConfig` (e.g. a new diagram type),
|
||||
# - If adding a new object to `MermaidConfigWithDefaults` (e.g. a new diagram type),
|
||||
# you may need to add it to `.build/jsonSchema.ts`, `src/docs.mts`
|
||||
# and `scripts/create-types-from-json-schema.mjs`
|
||||
# to get the default values/docs/types to generate properly.
|
||||
$id: https://mermaid.js.org/schemas/config.schema.json
|
||||
$schema: https://json-schema.org/draft/2019-09/schema
|
||||
title: Mermaid Config
|
||||
title: MermaidConfigWithDefaults
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
@@ -261,6 +261,11 @@ properties:
|
||||
This is useful when you want to control how to handle syntax errors in your application.
|
||||
|
||||
$defs: # JSON Schema definition (maybe we should move these to a separate file)
|
||||
MermaidConfig:
|
||||
title: MermaidConfig
|
||||
description: MermaidConfigWithDefaults with all fields optional
|
||||
type: object
|
||||
tsType: "import('type-fest').PartialDeep<MermaidConfigWithDefaults>"
|
||||
BaseDiagramConfig:
|
||||
# TODO: More config needs to be moved here
|
||||
title: Base Diagram Config
|
||||
|
@@ -7,12 +7,12 @@ import {
|
||||
curveBumpX,
|
||||
curveBumpY,
|
||||
curveBundle,
|
||||
curveCardinal,
|
||||
curveCardinalClosed,
|
||||
curveCardinalOpen,
|
||||
curveCardinal,
|
||||
curveCatmullRom,
|
||||
curveCatmullRomClosed,
|
||||
curveCatmullRomOpen,
|
||||
curveCatmullRom,
|
||||
curveLinear,
|
||||
curveLinearClosed,
|
||||
curveMonotoneX,
|
||||
@@ -23,17 +23,17 @@ import {
|
||||
curveStepBefore,
|
||||
select,
|
||||
} from 'd3';
|
||||
import common from './diagrams/common/common.js';
|
||||
import { sanitizeDirective } from './utils/sanitizeDirective.js';
|
||||
import { log } from './logger.js';
|
||||
import { detectType } from './diagram-api/detectType.js';
|
||||
import assignWithDepth from './assignWithDepth.js';
|
||||
import type { MermaidConfig } from './config.type.js';
|
||||
import memoize from 'lodash-es/memoize.js';
|
||||
import merge from 'lodash-es/merge.js';
|
||||
import assignWithDepth from './assignWithDepth.js';
|
||||
import type { MermaidConfigWithDefaults, MermaidConfig } from './config.type.js';
|
||||
import { detectType } from './diagram-api/detectType.js';
|
||||
import { directiveRegex } from './diagram-api/regexes.js';
|
||||
import common from './diagrams/common/common.js';
|
||||
import { log } from './logger.js';
|
||||
import type { D3Element } from './mermaidAPI.js';
|
||||
import type { Point, TextDimensionConfig, TextDimensions } from './types.js';
|
||||
import { sanitizeDirective } from './utils/sanitizeDirective.js';
|
||||
|
||||
export const ZERO_WIDTH_SPACE = '\u200b';
|
||||
|
||||
@@ -97,10 +97,7 @@ const directiveWithoutOpen =
|
||||
* @param config - Optional mermaid configuration object.
|
||||
* @returns The json object representing the init passed to mermaid.initialize()
|
||||
*/
|
||||
export const detectInit = function (
|
||||
text: string,
|
||||
config?: MermaidConfig
|
||||
): MermaidConfig | undefined {
|
||||
export const detectInit = function (text: string): MermaidConfig | undefined {
|
||||
const inits = detectDirective(text, /(?:init\b)|(?:initialize\b)/);
|
||||
let results: MermaidConfig & { config?: unknown } = {};
|
||||
|
||||
@@ -116,7 +113,7 @@ export const detectInit = function (
|
||||
return;
|
||||
}
|
||||
|
||||
let type = detectType(text, config);
|
||||
let type = detectType(text);
|
||||
|
||||
// Move the `config` value to appropriate diagram type value
|
||||
const prop = 'config';
|
||||
@@ -124,7 +121,7 @@ export const detectInit = function (
|
||||
if (type === 'flowchart-v2') {
|
||||
type = 'flowchart';
|
||||
}
|
||||
results[type as keyof MermaidConfig] = results[prop];
|
||||
results[type as keyof MermaidConfigWithDefaults] = results[prop];
|
||||
delete results[prop];
|
||||
}
|
||||
|
||||
@@ -250,7 +247,10 @@ export function interpolateToCurve(
|
||||
* @param config - Configuration passed to MermaidJS
|
||||
* @returns The formatted URL or `undefined`.
|
||||
*/
|
||||
export function formatUrl(linkStr: string, config: MermaidConfig): string | undefined {
|
||||
export function formatUrl(
|
||||
linkStr: string,
|
||||
config: Pick<MermaidConfigWithDefaults, 'securityLevel'>
|
||||
): string | undefined {
|
||||
const url = linkStr.trim();
|
||||
|
||||
if (!url) {
|
||||
|
@@ -3,7 +3,7 @@ import type { FlowchartDiagramConfig } from '../config.type.js';
|
||||
export const getSubGraphTitleMargins = ({
|
||||
flowchart,
|
||||
}: {
|
||||
flowchart: FlowchartDiagramConfig;
|
||||
flowchart: Pick<FlowchartDiagramConfig, 'subGraphTitleMargin'>;
|
||||
}): {
|
||||
subGraphTitleTopMargin: number;
|
||||
subGraphTitleBottomMargin: number;
|
||||
|
96
pnpm-lock.yaml
generated
96
pnpm-lock.yaml
generated
@@ -336,8 +336,8 @@ importers:
|
||||
specifier: ^24.0.0
|
||||
version: 24.0.0
|
||||
json-schema-to-typescript:
|
||||
specifier: ^13.1.2
|
||||
version: 13.1.2
|
||||
specifier: ^14.0.4
|
||||
version: 14.0.4
|
||||
micromatch:
|
||||
specifier: ^4.0.5
|
||||
version: 4.0.5
|
||||
@@ -757,6 +757,15 @@ packages:
|
||||
leven: 3.1.0
|
||||
dev: true
|
||||
|
||||
/@apidevtools/json-schema-ref-parser@11.6.1:
|
||||
resolution: {integrity: sha512-DxjgKBCoyReu4p5HMvpmgSOfRhhBcuf5V5soDDRgOTZMwsA4KSFzol1abFZgiCTE11L2kKGca5Md9GwDdXVBwQ==}
|
||||
engines: {node: '>= 16'}
|
||||
dependencies:
|
||||
'@jsdevtools/ono': 7.1.3
|
||||
'@types/json-schema': 7.0.15
|
||||
js-yaml: 4.1.0
|
||||
dev: true
|
||||
|
||||
/@applitools/core-base@1.10.1:
|
||||
resolution: {integrity: sha512-s4q72eyPLaV1D5xXH1He72y/yCdSihL4oNs6vRe+IxP2CSDH8b42B+8Ps2nAPMNxatp7nzpHq/jRfXHv24Z1ZQ==}
|
||||
engines: {node: '>=12.13.0'}
|
||||
@@ -2381,16 +2390,6 @@ packages:
|
||||
'@babel/helper-validator-identifier': 7.24.5
|
||||
to-fast-properties: 2.0.0
|
||||
|
||||
/@bcherny/json-schema-ref-parser@10.0.5-fork:
|
||||
resolution: {integrity: sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==}
|
||||
engines: {node: '>= 16'}
|
||||
dependencies:
|
||||
'@jsdevtools/ono': 7.1.3
|
||||
'@types/json-schema': 7.0.15
|
||||
call-me-maybe: 1.0.2
|
||||
js-yaml: 4.1.0
|
||||
dev: true
|
||||
|
||||
/@bcoe/v8-coverage@0.2.3:
|
||||
resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==}
|
||||
dev: true
|
||||
@@ -4447,13 +4446,6 @@ packages:
|
||||
resolution: {integrity: sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg==}
|
||||
dev: true
|
||||
|
||||
/@types/glob@7.2.0:
|
||||
resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==}
|
||||
dependencies:
|
||||
'@types/minimatch': 5.1.2
|
||||
'@types/node': 20.12.10
|
||||
dev: true
|
||||
|
||||
/@types/glob@8.1.0:
|
||||
resolution: {integrity: sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==}
|
||||
dependencies:
|
||||
@@ -4621,10 +4613,6 @@ packages:
|
||||
resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==}
|
||||
dev: true
|
||||
|
||||
/@types/prettier@2.7.3:
|
||||
resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==}
|
||||
dev: true
|
||||
|
||||
/@types/prettier@3.0.0:
|
||||
resolution: {integrity: sha512-mFMBfMOz8QxhYVbuINtswBp9VL2b4Y0QqYHwqLz3YbgtfAcat2Dl6Y1o4e22S/OVE6Ebl9m7wWiMT2lSbAs1wA==}
|
||||
deprecated: This is a stub types definition. prettier provides its own type definitions, so you do not need this installed.
|
||||
@@ -6647,10 +6635,6 @@ packages:
|
||||
set-function-length: 1.2.2
|
||||
dev: true
|
||||
|
||||
/call-me-maybe@1.0.2:
|
||||
resolution: {integrity: sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==}
|
||||
dev: true
|
||||
|
||||
/callsites@3.1.0:
|
||||
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -9595,11 +9579,6 @@ packages:
|
||||
engines: {node: '>=0.12.0'}
|
||||
dev: true
|
||||
|
||||
/get-stdin@8.0.0:
|
||||
resolution: {integrity: sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==}
|
||||
engines: {node: '>=10'}
|
||||
dev: true
|
||||
|
||||
/get-stdin@9.0.0:
|
||||
resolution: {integrity: sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -9672,16 +9651,6 @@ packages:
|
||||
dependencies:
|
||||
is-glob: 4.0.3
|
||||
|
||||
/glob-promise@4.2.2(glob@7.2.3):
|
||||
resolution: {integrity: sha512-xcUzJ8NWN5bktoTIX7eOclO1Npxd/dyVqUJxlLIDasT4C7KZyqlPIwkdJ0Ypiy3p2ZKahTjK4M9uC3sNSfNMzw==}
|
||||
engines: {node: '>=12'}
|
||||
peerDependencies:
|
||||
glob: ^7.1.6
|
||||
dependencies:
|
||||
'@types/glob': 7.2.0
|
||||
glob: 7.2.3
|
||||
dev: true
|
||||
|
||||
/glob-to-regexp@0.4.1:
|
||||
resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==}
|
||||
dev: true
|
||||
@@ -9708,7 +9677,6 @@ packages:
|
||||
minimatch: 9.0.4
|
||||
minipass: 7.0.4
|
||||
path-scurry: 1.10.2
|
||||
dev: false
|
||||
|
||||
/glob@7.2.3:
|
||||
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
|
||||
@@ -11295,25 +11263,24 @@ packages:
|
||||
resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}
|
||||
dev: true
|
||||
|
||||
/json-schema-to-typescript@13.1.2:
|
||||
resolution: {integrity: sha512-17G+mjx4nunvOpkPvcz7fdwUwYCEwyH8vR3Ym3rFiQ8uzAL3go+c1306Kk7iGRk8HuXBXqy+JJJmpYl0cvOllw==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
/json-schema-to-typescript@14.0.4:
|
||||
resolution: {integrity: sha512-covPOp3hrbD+oEcMvDxP5Rh6xNZj7lOTZkXAeQoDyu1PuEl1A6oRZ3Sy05HN11vXXmdJ6gLh5P3Qz0mgMPTzzw==}
|
||||
engines: {node: '>=16.0.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@bcherny/json-schema-ref-parser': 10.0.5-fork
|
||||
'@apidevtools/json-schema-ref-parser': 11.6.1
|
||||
'@types/json-schema': 7.0.15
|
||||
'@types/lodash': 4.17.0
|
||||
'@types/prettier': 2.7.3
|
||||
'@types/lodash': 4.17.1
|
||||
cli-color: 2.0.4
|
||||
get-stdin: 8.0.0
|
||||
glob: 7.2.3
|
||||
glob-promise: 4.2.2(glob@7.2.3)
|
||||
glob: 10.3.12
|
||||
is-glob: 4.0.3
|
||||
js-yaml: 4.1.0
|
||||
lodash: 4.17.21
|
||||
minimist: 1.2.8
|
||||
mkdirp: 1.0.4
|
||||
mkdirp: 3.0.1
|
||||
mz: 2.7.0
|
||||
prettier: 2.8.8
|
||||
node-fetch: 3.3.2
|
||||
prettier: 3.2.5
|
||||
dev: true
|
||||
|
||||
/json-schema-traverse@0.4.1:
|
||||
@@ -11715,7 +11682,6 @@ packages:
|
||||
/lru-cache@10.2.1:
|
||||
resolution: {integrity: sha512-tS24spDe/zXhWbNPErCHs/AGOzbKGHT+ybSBqmdLm8WZ1xXLWvH8Qn71QPAlqVhd0qUTWjy+Kl9JmISgDdEjsA==}
|
||||
engines: {node: 14 || >=16.14}
|
||||
dev: false
|
||||
|
||||
/lru-cache@5.1.1:
|
||||
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
|
||||
@@ -12376,8 +12342,8 @@ packages:
|
||||
minimist: 1.2.8
|
||||
dev: true
|
||||
|
||||
/mkdirp@1.0.4:
|
||||
resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==}
|
||||
/mkdirp@3.0.1:
|
||||
resolution: {integrity: sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
@@ -12487,6 +12453,15 @@ packages:
|
||||
formdata-polyfill: 4.0.10
|
||||
dev: true
|
||||
|
||||
/node-fetch@3.3.2:
|
||||
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dependencies:
|
||||
data-uri-to-buffer: 4.0.1
|
||||
fetch-blob: 3.2.0
|
||||
formdata-polyfill: 4.0.10
|
||||
dev: true
|
||||
|
||||
/node-forge@1.3.1:
|
||||
resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==}
|
||||
engines: {node: '>= 6.13.0'}
|
||||
@@ -12944,7 +12919,6 @@ packages:
|
||||
dependencies:
|
||||
lru-cache: 10.2.1
|
||||
minipass: 7.0.4
|
||||
dev: false
|
||||
|
||||
/path-to-regexp@0.1.7:
|
||||
resolution: {integrity: sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==}
|
||||
@@ -13219,12 +13193,6 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/prettier@2.8.8:
|
||||
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/prettier@3.2.5:
|
||||
resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==}
|
||||
engines: {node: '>=14'}
|
||||
|
Reference in New Issue
Block a user