@markdy/core 1.4.15 → 1.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -1
- package/dist/index.js +83 -13
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,10 @@ type ResolvedPlayer = {
|
|
|
67
67
|
progressColor?: string;
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
+
type DefaultThemesConfig = {
|
|
71
|
+
light?: string;
|
|
72
|
+
dark?: string;
|
|
73
|
+
};
|
|
70
74
|
type SceneMeta = {
|
|
71
75
|
title?: string;
|
|
72
76
|
width: number;
|
|
@@ -81,6 +85,8 @@ type SceneMeta = {
|
|
|
81
85
|
explicitHeight?: boolean;
|
|
82
86
|
/** Whether theme was explicitly specified by the author in the script. */
|
|
83
87
|
explicitTheme?: boolean;
|
|
88
|
+
/** Default theme names for light and dark modes when following host environment. */
|
|
89
|
+
defaultThemes?: DefaultThemesConfig;
|
|
84
90
|
/** Whether layout direction was explicitly specified by the author in the script. */
|
|
85
91
|
explicitDirection?: boolean;
|
|
86
92
|
/** Layout mode: explicit fixed direction or adaptive auto. */
|
|
@@ -1138,4 +1144,4 @@ interface AutoHealResult {
|
|
|
1138
1144
|
*/
|
|
1139
1145
|
declare function autoHealArchitectureDrift(ast: DiagramAST, report: ArchitectureDriftReport, existingFiles?: string[]): AutoHealResult;
|
|
1140
1146
|
|
|
1141
|
-
export { ARCHITECTURE_RECIPES, ARCH_RULE_PRESETS, type AnnotationDecl, type ArchRuleType, type ArchitectureDriftReport, type ArchitecturePreset, type ArchitectureRecipe, type ArchitectureRecommendation, type ArchitectureRule, type ArchitectureViolation, type AutoHealResult, type AutoRepairResult, BEAT_CUE_KEYWORDS, type BeatDecl, type BeatRange, type Box, type BrokenAnchorDrift, type C4Level, type C4LevelViewExport, type C4ModelReport, type C4NodeMeta, CUE_ALIASES, type CardinalPort, type CodeProvenanceAnchor, type CodeProvenanceDiagnostic, type CodeProvenanceVerificationReport, type Cue, DIAGRAM_TYPES, type Diagnostic, type DiagnosticIssue, type DiagramAST, type DiagramContext, type DiagramDiffResult, type DiagramQualityMetrics, type DiagramType, type DiffChangeType, EDGE_OPERATORS, type EdgeDecl, type EdgeDiff, type EdgeKind, type EdgeSelector, type ExtractedBeat, type ExtractedGroup, type ExtractedNode, type FlowSegment, type GhostTextSuggestion, type GroupBoundary, type GroupDecl, type GroupDiff, type IntelliCodeItem, type IntelliCodeItemKind, type LayoutDirection, type MarkdyConfig, NODE_ALIASES, NODE_KINDS, type NodeDecl, type NodeDiff, type NodeSelector, type NodeShape, OUTPUT_PRESETS, type OrphanCodeServiceDrift, type OutputPreset, PLAYER_FLAT_KEYS, PLAYER_GROUPS, POPULAR_TECHS, ParseError, type ParseOptions, type ParseResult, type PatternDecl, type PatternRecommendationResult, type PlayerChromeConfig, type PlayerConfig, type PlayerControlsConfig, type PlayerInteractionConfig, type PlayerOverrides, type PlayerPlaybackConfig, type PlayerProgress, type PlayerScope, type Point, type PortLane, type PositionedNode, type QualityCheckItem, type QualityGateOptions, type QualityGateReport, type QualityProfile, type RenderPlan, type RepairPromptBundle, type ResolvedPlayer, type RouteOptions, type RoutedEdge, type RoutedPath, type RuleSeverity, SCENE_KEYS, type SceneMeta, type SemanticProfile, type SequenceActivation, type SequenceMessage, type StyleDecl, type SyntaxDiagnosticReport, type SynthesizedRecipeResult, TECHNICAL_NODE_KINDS, TECHNICAL_NODE_TYPES, THEMES, type TechPreset, type ThemeGeneratorOptions, type ThemeTokens, type TimedCue, type TreeBus, VECTOR_SYMBOLS, VISUAL_PRIMITIVE_TYPES, type VectorSymbol, allocatePortLanes, analyzeAndBuildRepairPrompt, analyzeC4Model, applyPlayerSetting, autoHealArchitectureDrift, buildSmoothSvgPath, canonicalNodeKind, classifyTechnology, compile, compilePlan, compressMarkdyToUrlHash, computeAdaptiveDimensions, computeNodeDimensions, damerauLevenshteinDistance, decompressMarkdyFromUrlHash, detectArchitectureDrift, diagnoseMarkdyCode, diffDiagramASTs, exportC4LevelViews, extractDiagramCodeAnchors, extractDiagramContext, filterC4Hierarchy, findClosestMatch, formatScene, generateC4Storyboard, generateThemeFromBrand, getArchitectureRecipe, getArchitectureSuggestions, getBoxPortPosition, getIntelliCodeCompletions, humanizeId, inferNodeC4Level, listArchitectureRecipes, listAvailableSymbols, listOutputPresets, nodeRole, parse, parseAndCompile, parseCodeAnchor, predictNextLineSuggestion, recommendArchitecturePattern, renderSymbolSvg, repairMarkdyCode, resolveArchitectureConfig, resolveOutputPreset, resolvePlayer, resolveTheme, resolveVectorSymbol, routeOrthogonalEdge, selectOptimalPorts, synthesizeCustomRecipe, validateArchitecture, validateC4Containment, verifyCodeAnchorsWithReader, verifyDiagramQuality };
|
|
1147
|
+
export { ARCHITECTURE_RECIPES, ARCH_RULE_PRESETS, type AnnotationDecl, type ArchRuleType, type ArchitectureDriftReport, type ArchitecturePreset, type ArchitectureRecipe, type ArchitectureRecommendation, type ArchitectureRule, type ArchitectureViolation, type AutoHealResult, type AutoRepairResult, BEAT_CUE_KEYWORDS, type BeatDecl, type BeatRange, type Box, type BrokenAnchorDrift, type C4Level, type C4LevelViewExport, type C4ModelReport, type C4NodeMeta, CUE_ALIASES, type CardinalPort, type CodeProvenanceAnchor, type CodeProvenanceDiagnostic, type CodeProvenanceVerificationReport, type Cue, DIAGRAM_TYPES, type DefaultThemesConfig, type Diagnostic, type DiagnosticIssue, type DiagramAST, type DiagramContext, type DiagramDiffResult, type DiagramQualityMetrics, type DiagramType, type DiffChangeType, EDGE_OPERATORS, type EdgeDecl, type EdgeDiff, type EdgeKind, type EdgeSelector, type ExtractedBeat, type ExtractedGroup, type ExtractedNode, type FlowSegment, type GhostTextSuggestion, type GroupBoundary, type GroupDecl, type GroupDiff, type IntelliCodeItem, type IntelliCodeItemKind, type LayoutDirection, type MarkdyConfig, NODE_ALIASES, NODE_KINDS, type NodeDecl, type NodeDiff, type NodeSelector, type NodeShape, OUTPUT_PRESETS, type OrphanCodeServiceDrift, type OutputPreset, PLAYER_FLAT_KEYS, PLAYER_GROUPS, POPULAR_TECHS, ParseError, type ParseOptions, type ParseResult, type PatternDecl, type PatternRecommendationResult, type PlayerChromeConfig, type PlayerConfig, type PlayerControlsConfig, type PlayerInteractionConfig, type PlayerOverrides, type PlayerPlaybackConfig, type PlayerProgress, type PlayerScope, type Point, type PortLane, type PositionedNode, type QualityCheckItem, type QualityGateOptions, type QualityGateReport, type QualityProfile, type RenderPlan, type RepairPromptBundle, type ResolvedPlayer, type RouteOptions, type RoutedEdge, type RoutedPath, type RuleSeverity, SCENE_KEYS, type SceneMeta, type SemanticProfile, type SequenceActivation, type SequenceMessage, type StyleDecl, type SyntaxDiagnosticReport, type SynthesizedRecipeResult, TECHNICAL_NODE_KINDS, TECHNICAL_NODE_TYPES, THEMES, type TechPreset, type ThemeGeneratorOptions, type ThemeTokens, type TimedCue, type TreeBus, VECTOR_SYMBOLS, VISUAL_PRIMITIVE_TYPES, type VectorSymbol, allocatePortLanes, analyzeAndBuildRepairPrompt, analyzeC4Model, applyPlayerSetting, autoHealArchitectureDrift, buildSmoothSvgPath, canonicalNodeKind, classifyTechnology, compile, compilePlan, compressMarkdyToUrlHash, computeAdaptiveDimensions, computeNodeDimensions, damerauLevenshteinDistance, decompressMarkdyFromUrlHash, detectArchitectureDrift, diagnoseMarkdyCode, diffDiagramASTs, exportC4LevelViews, extractDiagramCodeAnchors, extractDiagramContext, filterC4Hierarchy, findClosestMatch, formatScene, generateC4Storyboard, generateThemeFromBrand, getArchitectureRecipe, getArchitectureSuggestions, getBoxPortPosition, getIntelliCodeCompletions, humanizeId, inferNodeC4Level, listArchitectureRecipes, listAvailableSymbols, listOutputPresets, nodeRole, parse, parseAndCompile, parseCodeAnchor, predictNextLineSuggestion, recommendArchitecturePattern, renderSymbolSvg, repairMarkdyCode, resolveArchitectureConfig, resolveOutputPreset, resolvePlayer, resolveTheme, resolveVectorSymbol, routeOrthogonalEdge, selectOptimalPorts, synthesizeCustomRecipe, validateArchitecture, validateC4Containment, verifyCodeAnchorsWithReader, verifyDiagramQuality };
|
package/dist/index.js
CHANGED
|
@@ -614,8 +614,11 @@ function resolvePlayer(config = {}, overrides = {}) {
|
|
|
614
614
|
const chrome = config.chrome ?? {};
|
|
615
615
|
const controlsAllowed = overrides.controls !== false;
|
|
616
616
|
const hostControlDefault = overrides.controls === true;
|
|
617
|
-
const
|
|
618
|
-
|
|
617
|
+
const controlsExplicitlyDeclared = Boolean(
|
|
618
|
+
config.controls && Object.keys(config.controls).length > 0 || overrideControls && Object.keys(overrideControls).length > 0
|
|
619
|
+
);
|
|
620
|
+
const unconfiguredFallback = controlsExplicitlyDeclared ? false : hostControlDefault;
|
|
621
|
+
const resolveControl = (value, fallback = unconfiguredFallback) => controlsAllowed && (value ?? fallback);
|
|
619
622
|
const requestedControls = {
|
|
620
623
|
seek: resolveControl(configuredControls.seek, false),
|
|
621
624
|
speed: resolveControl(configuredControls.speed),
|
|
@@ -626,7 +629,7 @@ function resolvePlayer(config = {}, overrides = {}) {
|
|
|
626
629
|
gif: resolveControl(configuredControls.gif),
|
|
627
630
|
share: resolveControl(configuredControls.share),
|
|
628
631
|
code: resolveControl(configuredControls.code, false),
|
|
629
|
-
theme: resolveControl(configuredControls.theme
|
|
632
|
+
theme: resolveControl(configuredControls.theme)
|
|
630
633
|
};
|
|
631
634
|
const hasExplicitInteraction = config.interaction !== void 0;
|
|
632
635
|
const fallbackGesture = overrides.interactiveViewport === true || overrides.controls === true;
|
|
@@ -726,6 +729,14 @@ var SCENE_KEYS = /* @__PURE__ */ new Set([
|
|
|
726
729
|
"height",
|
|
727
730
|
"fps",
|
|
728
731
|
"theme",
|
|
732
|
+
"theme.light",
|
|
733
|
+
"theme.dark",
|
|
734
|
+
"theme_light",
|
|
735
|
+
"theme_dark",
|
|
736
|
+
"light_theme",
|
|
737
|
+
"dark_theme",
|
|
738
|
+
"default_themes",
|
|
739
|
+
"default_theme",
|
|
729
740
|
"duration",
|
|
730
741
|
"direction",
|
|
731
742
|
"layout",
|
|
@@ -3252,6 +3263,36 @@ var ParseError = class extends Error {
|
|
|
3252
3263
|
}
|
|
3253
3264
|
};
|
|
3254
3265
|
var FLOW_OP_RE = /(->|<-|~>|--|\.\.>|<->)/;
|
|
3266
|
+
function parseThemeSpecification(raw) {
|
|
3267
|
+
const trimmed = raw.trim();
|
|
3268
|
+
const lightMatch = trimmed.match(/(?:^|[\s,;])(?:light|light_theme|theme\.light)\s*[:=]\s*([a-zA-Z0-9_-]+)/i);
|
|
3269
|
+
const darkMatch = trimmed.match(/(?:^|[\s,;])(?:dark|dark_theme|theme\.dark)\s*[:=]\s*([a-zA-Z0-9_-]+)/i);
|
|
3270
|
+
if (lightMatch || darkMatch) {
|
|
3271
|
+
return {
|
|
3272
|
+
theme: "auto",
|
|
3273
|
+
explicitTheme: false,
|
|
3274
|
+
defaultThemes: {
|
|
3275
|
+
...lightMatch ? { light: lightMatch[1].toLowerCase() } : {},
|
|
3276
|
+
...darkMatch ? { dark: darkMatch[1].toLowerCase() } : {}
|
|
3277
|
+
}
|
|
3278
|
+
};
|
|
3279
|
+
}
|
|
3280
|
+
if (trimmed.includes("/")) {
|
|
3281
|
+
const parts = trimmed.split("/").map((s) => s.trim().toLowerCase());
|
|
3282
|
+
if (parts.length >= 2 && parts[0] && parts[1]) {
|
|
3283
|
+
return {
|
|
3284
|
+
theme: "auto",
|
|
3285
|
+
explicitTheme: false,
|
|
3286
|
+
defaultThemes: { light: parts[0], dark: parts[1] }
|
|
3287
|
+
};
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
const lower = trimmed.toLowerCase();
|
|
3291
|
+
return {
|
|
3292
|
+
theme: lower,
|
|
3293
|
+
explicitTheme: lower !== "auto"
|
|
3294
|
+
};
|
|
3295
|
+
}
|
|
3255
3296
|
function stripComment(line) {
|
|
3256
3297
|
let inString = false;
|
|
3257
3298
|
let escaped = false;
|
|
@@ -4061,9 +4102,21 @@ function parse(source, opts = {}) {
|
|
|
4061
4102
|
meta.fps = Number(v);
|
|
4062
4103
|
} else if (k === "duration") meta.duration = Number(v);
|
|
4063
4104
|
else if (k === "theme") {
|
|
4064
|
-
const
|
|
4065
|
-
meta.theme =
|
|
4066
|
-
meta.explicitTheme =
|
|
4105
|
+
const parsed = parseThemeSpecification(String(v));
|
|
4106
|
+
if (parsed.theme) meta.theme = parsed.theme;
|
|
4107
|
+
if (parsed.explicitTheme !== void 0) meta.explicitTheme = parsed.explicitTheme;
|
|
4108
|
+
if (parsed.defaultThemes) {
|
|
4109
|
+
meta.defaultThemes = { ...meta.defaultThemes, ...parsed.defaultThemes };
|
|
4110
|
+
}
|
|
4111
|
+
} else if (k === "theme.light" || k === "theme_light" || k === "light_theme") {
|
|
4112
|
+
meta.defaultThemes = { ...meta.defaultThemes, light: String(v).toLowerCase().trim() };
|
|
4113
|
+
} else if (k === "theme.dark" || k === "theme_dark" || k === "dark_theme") {
|
|
4114
|
+
meta.defaultThemes = { ...meta.defaultThemes, dark: String(v).toLowerCase().trim() };
|
|
4115
|
+
} else if (k === "default_themes" || k === "default_theme") {
|
|
4116
|
+
const parsed = parseThemeSpecification(String(v));
|
|
4117
|
+
if (parsed.defaultThemes) {
|
|
4118
|
+
meta.defaultThemes = { ...meta.defaultThemes, ...parsed.defaultThemes };
|
|
4119
|
+
}
|
|
4067
4120
|
} else if (k === "direction" || k === "layout" || k === "rankdir") {
|
|
4068
4121
|
const val = String(v).toUpperCase();
|
|
4069
4122
|
if (val === "AUTO") {
|
|
@@ -4094,12 +4147,28 @@ function parse(source, opts = {}) {
|
|
|
4094
4147
|
i++;
|
|
4095
4148
|
continue;
|
|
4096
4149
|
}
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4150
|
+
const themeDirectMatch = line.match(
|
|
4151
|
+
/^(?:(theme(?:\.(?:light|dark)|_(?:light|dark))?|default_themes?)|(light_theme|dark_theme))\s*[:=]?\s*(.+)$/i
|
|
4152
|
+
);
|
|
4153
|
+
if (themeDirectMatch) {
|
|
4154
|
+
const propKey = (themeDirectMatch[1] || themeDirectMatch[2]).toLowerCase();
|
|
4155
|
+
const rawVal = themeDirectMatch[3].trim();
|
|
4156
|
+
if (propKey === "theme.light" || propKey === "theme_light" || propKey === "light_theme") {
|
|
4157
|
+
meta.defaultThemes = { ...meta.defaultThemes, light: rawVal.toLowerCase() };
|
|
4158
|
+
} else if (propKey === "theme.dark" || propKey === "theme_dark" || propKey === "dark_theme") {
|
|
4159
|
+
meta.defaultThemes = { ...meta.defaultThemes, dark: rawVal.toLowerCase() };
|
|
4160
|
+
} else if (propKey === "default_themes" || propKey === "default_theme") {
|
|
4161
|
+
const parsed = parseThemeSpecification(rawVal);
|
|
4162
|
+
if (parsed.defaultThemes) {
|
|
4163
|
+
meta.defaultThemes = { ...meta.defaultThemes, ...parsed.defaultThemes };
|
|
4164
|
+
}
|
|
4165
|
+
} else {
|
|
4166
|
+
const parsed = parseThemeSpecification(rawVal);
|
|
4167
|
+
if (parsed.theme) meta.theme = parsed.theme;
|
|
4168
|
+
if (parsed.explicitTheme !== void 0) meta.explicitTheme = parsed.explicitTheme;
|
|
4169
|
+
if (parsed.defaultThemes) {
|
|
4170
|
+
meta.defaultThemes = { ...meta.defaultThemes, ...parsed.defaultThemes };
|
|
4171
|
+
}
|
|
4103
4172
|
}
|
|
4104
4173
|
i++;
|
|
4105
4174
|
continue;
|
|
@@ -4293,7 +4362,8 @@ function parse(source, opts = {}) {
|
|
|
4293
4362
|
return ast;
|
|
4294
4363
|
}
|
|
4295
4364
|
function compile(ast) {
|
|
4296
|
-
|
|
4365
|
+
const initialTheme = ast.meta.explicitTheme === false && ast.meta.defaultThemes?.light ? ast.meta.defaultThemes.light : ast.meta.theme;
|
|
4366
|
+
return compilePlan(ast, resolveTheme(initialTheme));
|
|
4297
4367
|
}
|
|
4298
4368
|
function parseAndCompile(source) {
|
|
4299
4369
|
const ast = parse(source);
|
package/package.json
CHANGED