-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into bug/5123_allow-attribute-names-to-be-esca…
…ped-on-ER-diagram
- Loading branch information
Showing
760 changed files
with
69,810 additions
and
27,549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export interface PackageOptions { | ||
name: string; | ||
packageName: string; | ||
file: string; | ||
} | ||
|
||
/** | ||
* Shared common options for both ESBuild and Vite | ||
*/ | ||
export const packageOptions = { | ||
parser: { | ||
name: 'mermaid-parser', | ||
packageName: 'parser', | ||
file: 'index.ts', | ||
}, | ||
mermaid: { | ||
name: 'mermaid', | ||
packageName: 'mermaid', | ||
file: 'mermaid.ts', | ||
}, | ||
'mermaid-example-diagram': { | ||
name: 'mermaid-example-diagram', | ||
packageName: 'mermaid-example-diagram', | ||
file: 'detector.ts', | ||
}, | ||
'mermaid-zenuml': { | ||
name: 'mermaid-zenuml', | ||
packageName: 'mermaid-zenuml', | ||
file: 'detector.ts', | ||
}, | ||
'mermaid-layout-elk': { | ||
name: 'mermaid-layout-elk', | ||
packageName: 'mermaid-layout-elk', | ||
file: 'layouts.ts', | ||
}, | ||
} as const satisfies Record<string, PackageOptions>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { generate } from 'langium-cli'; | ||
|
||
export async function generateLangium() { | ||
await generate({ file: `./packages/parser/langium-config.json` }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
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'; | ||
|
||
/** | ||
* All of the keys in the mermaid config that have a mermaid diagram config. | ||
*/ | ||
const MERMAID_CONFIG_DIAGRAM_KEYS = [ | ||
'flowchart', | ||
'sequence', | ||
'gantt', | ||
'journey', | ||
'class', | ||
'state', | ||
'er', | ||
'pie', | ||
'quadrantChart', | ||
'xyChart', | ||
'requirement', | ||
'mindmap', | ||
'kanban', | ||
'timeline', | ||
'gitGraph', | ||
'c4', | ||
'sankey', | ||
'block', | ||
'packet', | ||
'architecture', | ||
] as const; | ||
|
||
/** | ||
* Generate default values from the JSON Schema. | ||
* | ||
* AJV does not support nested default values yet (or default values with $ref), | ||
* so we need to manually find them (this may be fixed in ajv v9). | ||
* | ||
* @param mermaidConfigSchema - The Mermaid JSON Schema to use. | ||
* @returns The default mermaid config object. | ||
*/ | ||
function generateDefaults(mermaidConfigSchema: JSONSchemaType<MermaidConfig>) { | ||
const ajv = new Ajv2019({ | ||
useDefaults: true, | ||
allowUnionTypes: true, | ||
strict: true, | ||
}); | ||
|
||
ajv.addKeyword({ | ||
keyword: 'meta:enum', // used by jsonschema2md | ||
errors: false, | ||
}); | ||
ajv.addKeyword({ | ||
keyword: 'tsType', // used by json-schema-to-typescript | ||
errors: false, | ||
}); | ||
|
||
// ajv currently doesn't support nested default values, see https://github.com/ajv-validator/ajv/issues/1718 | ||
// (may be fixed in v9) so we need to manually use sub-schemas | ||
const mermaidDefaultConfig = {}; | ||
|
||
assert.ok(mermaidConfigSchema.$defs); | ||
const baseDiagramConfig = mermaidConfigSchema.$defs.BaseDiagramConfig; | ||
|
||
for (const key of MERMAID_CONFIG_DIAGRAM_KEYS) { | ||
const subSchemaRef = mermaidConfigSchema.properties[key].$ref; | ||
const [root, defs, defName] = subSchemaRef.split('/'); | ||
assert.strictEqual(root, '#'); | ||
assert.strictEqual(defs, '$defs'); | ||
const subSchema = { | ||
$schema: mermaidConfigSchema.$schema, | ||
$defs: mermaidConfigSchema.$defs, | ||
...mermaidConfigSchema.$defs[defName], | ||
} as JSONSchemaType<BaseDiagramConfig>; | ||
|
||
const validate = ajv.compile(subSchema); | ||
|
||
mermaidDefaultConfig[key] = {}; | ||
|
||
for (const required of subSchema.required ?? []) { | ||
if (subSchema.properties[required] === undefined && baseDiagramConfig.properties[required]) { | ||
mermaidDefaultConfig[key][required] = baseDiagramConfig.properties[required].default; | ||
} | ||
} | ||
if (!validate(mermaidDefaultConfig[key])) { | ||
throw new Error( | ||
`schema for subconfig ${key} does not have valid defaults! Errors were ${JSON.stringify( | ||
validate.errors, | ||
undefined, | ||
2 | ||
)}` | ||
); | ||
} | ||
} | ||
|
||
const validate = ajv.compile(mermaidConfigSchema); | ||
|
||
if (!validate(mermaidDefaultConfig)) { | ||
throw new Error( | ||
`Mermaid config JSON Schema does not have valid defaults! Errors were ${JSON.stringify( | ||
validate.errors, | ||
undefined, | ||
2 | ||
)}` | ||
); | ||
} | ||
|
||
return mermaidDefaultConfig; | ||
} | ||
|
||
export const loadSchema = (src: string, filename: string): JSONSchemaType<MermaidConfig> => { | ||
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>; | ||
return jsonSchema; | ||
}; | ||
|
||
export const getDefaults = (schema: JSONSchemaType<MermaidConfig>) => { | ||
return `export default ${JSON.stringify(generateDefaults(schema), undefined, 2)};`; | ||
}; | ||
|
||
export const getSchema = (schema: JSONSchemaType<MermaidConfig>) => { | ||
return `export default ${JSON.stringify(schema, undefined, 2)};`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable no-console */ | ||
import { packageOptions } from './common.js'; | ||
import { execSync } from 'child_process'; | ||
|
||
const buildType = (packageName: string) => { | ||
console.log(`Building types for ${packageName}`); | ||
try { | ||
const out = execSync(`tsc -p ./packages/${packageName}/tsconfig.json --emitDeclarationOnly`); | ||
if (out.length > 0) { | ||
console.log(out.toString()); | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
if (e.stdout.length > 0) { | ||
console.error(e.stdout.toString()); | ||
} | ||
if (e.stderr.length > 0) { | ||
console.error(e.stderr.toString()); | ||
} | ||
} | ||
}; | ||
|
||
for (const { packageName } of Object.values(packageOptions)) { | ||
buildType(packageName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'mermaid': patch | ||
--- | ||
|
||
fix: architecture diagrams no longer grow to extreme heights due to conflicting alignments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": ["@changesets/changelog-github", { "repo": "mermaid-js/mermaid" }], | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "master", | ||
"updateInternalDependencies": "patch", | ||
"bumpVersionsWithWorkspaceProtocolOnly": true, | ||
"ignore": ["@mermaid-js/docs", "@mermaid-js/webpack-test", "@mermaid-js/mermaid-example-diagram"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'mermaid': minor | ||
--- | ||
|
||
Adding support for animation of flowchart edges |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
# This file contains coding related terms | ||
ALPHANUM | ||
antiscript | ||
APPLYCLASS | ||
ARROWHEADSTYLE | ||
ARROWTYPE | ||
autonumber | ||
axisl-line | ||
Bigdecimal | ||
birel | ||
BIREL | ||
bqstring | ||
BQUOTE | ||
bramp | ||
BRKT | ||
brotli | ||
callbackargs | ||
callbackname | ||
classdef | ||
classdefid | ||
classentity | ||
classname | ||
COLONSEP | ||
COMPOSIT_STATE | ||
concat | ||
controlx | ||
controly | ||
CSSCLASS | ||
curv | ||
CYLINDEREND | ||
CYLINDERSTART | ||
DAGA | ||
datakey | ||
DEND | ||
descr | ||
distp | ||
distq | ||
divs | ||
docref | ||
DOMID | ||
doublecircle | ||
DOUBLECIRCLEEND | ||
DOUBLECIRCLESTART | ||
DQUOTE | ||
DSTART | ||
edgesep | ||
EMPTYSTR | ||
enddate | ||
ERDIAGRAM | ||
flatmap | ||
forwardable | ||
frontmatter | ||
funs | ||
gantt | ||
GENERICTYPE | ||
getBoundarys | ||
grammr | ||
graphtype | ||
halign | ||
iife | ||
interp | ||
introdcued | ||
INVTRAPEND | ||
INVTRAPSTART | ||
JDBC | ||
jison | ||
Kaufmann | ||
keyify | ||
LABELPOS | ||
LABELTYPE | ||
layoutstop | ||
lcov | ||
LEFTOF | ||
Lexa | ||
linebreak | ||
LINETYPE | ||
LINKSTYLE | ||
LLABEL | ||
loglevel | ||
LOGMSG | ||
lookaheads | ||
mdast | ||
metafile | ||
minlen | ||
Mstartx | ||
MULT | ||
NODIR | ||
NSTR | ||
outdir | ||
Qcontrolx | ||
reinit | ||
rels | ||
reqs | ||
rewritelinks | ||
rgba | ||
RIGHTOF | ||
roughjs | ||
sankey | ||
sequencenumber | ||
shrc | ||
signaltype | ||
someclass | ||
SPACELINE | ||
SPACELIST | ||
STADIUMEND | ||
STADIUMSTART | ||
startdate | ||
startx | ||
starty | ||
STMNT | ||
stopx | ||
stopy | ||
strikethrough | ||
stringifying | ||
struct | ||
STYLECLASS | ||
STYLEDEF | ||
STYLEOPTS | ||
subcomponent | ||
subcomponents | ||
subconfig | ||
SUBROUTINEEND | ||
SUBROUTINESTART | ||
Subschemas | ||
substr | ||
SVGG | ||
SVGSVG | ||
TAGEND | ||
TAGSTART | ||
techn | ||
TESTSTR | ||
TEXTDATA | ||
TEXTLENGTH | ||
titlevalue | ||
topbar | ||
TRAPEND | ||
TRAPSTART | ||
treemap | ||
ts-nocheck | ||
tsdoc | ||
typeof | ||
typestr | ||
unshift | ||
urlsafe | ||
verifymethod | ||
VERIFYMTHD | ||
WARN_DOCSDIR_DOESNT_MATCH | ||
xhost | ||
yaxis | ||
yfunc | ||
yytext | ||
zenuml |
Oops, something went wrong.