@markdy/core 1.4.16 → 1.4.18

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 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
@@ -729,6 +729,14 @@ var SCENE_KEYS = /* @__PURE__ */ new Set([
729
729
  "height",
730
730
  "fps",
731
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",
732
740
  "duration",
733
741
  "direction",
734
742
  "layout",
@@ -3255,6 +3263,36 @@ var ParseError = class extends Error {
3255
3263
  }
3256
3264
  };
3257
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
+ }
3258
3296
  function stripComment(line) {
3259
3297
  let inString = false;
3260
3298
  let escaped = false;
@@ -4064,9 +4102,21 @@ function parse(source, opts = {}) {
4064
4102
  meta.fps = Number(v);
4065
4103
  } else if (k === "duration") meta.duration = Number(v);
4066
4104
  else if (k === "theme") {
4067
- const val = String(v).toLowerCase();
4068
- meta.theme = val;
4069
- meta.explicitTheme = val !== "auto";
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
+ }
4070
4120
  } else if (k === "direction" || k === "layout" || k === "rankdir") {
4071
4121
  const val = String(v).toUpperCase();
4072
4122
  if (val === "AUTO") {
@@ -4097,12 +4147,28 @@ function parse(source, opts = {}) {
4097
4147
  i++;
4098
4148
  continue;
4099
4149
  }
4100
- if (/^theme\s*[:=]?\s*([a-zA-Z0-9_-]+)/i.test(line)) {
4101
- const match = line.match(/^theme\s*[:=]?\s*([a-zA-Z0-9_-]+)/i);
4102
- if (match) {
4103
- const val = match[1].toLowerCase();
4104
- meta.theme = val;
4105
- meta.explicitTheme = val !== "auto";
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
+ }
4106
4172
  }
4107
4173
  i++;
4108
4174
  continue;
@@ -4296,7 +4362,8 @@ function parse(source, opts = {}) {
4296
4362
  return ast;
4297
4363
  }
4298
4364
  function compile(ast) {
4299
- return compilePlan(ast, resolveTheme(ast.meta.theme));
4365
+ const initialTheme = ast.meta.explicitTheme === false && ast.meta.defaultThemes?.light ? ast.meta.defaultThemes.light : ast.meta.theme;
4366
+ return compilePlan(ast, resolveTheme(initialTheme));
4300
4367
  }
4301
4368
  function parseAndCompile(source) {
4302
4369
  const ast = parse(source);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markdy/core",
3
- "version": "1.4.16",
3
+ "version": "1.4.18",
4
4
  "description": "Diagram-native MarkdyScript parser and compiler (auto-layout, edge routing, cue scheduling) — zero runtime dependencies.",
5
5
  "license": "MIT",
6
6
  "type": "module",