gram/packages/renderer/CHANGELOG.md
abiwab bca30e7a9d
All checks were successful
CI / ci (push) Successful in 2m3s
chore: release v1.0.0
2026-08-06 12:00:19 +02:00

25 KiB
Raw Permalink Blame History

@gram-lang/renderer

1.0.0

Major Changes

  • Gram v1.0.0 Official Launch! 🎉

    This milestone release marks the official 1.0.0 launch of Gram:

    • Brand-New Website & Documentation: Rebuilt using Astro and Starlight with refined guides and an integrated blog.
    • Refreshed Visual Identity: Brand-new logo.
    • Infrastructure & Stability: Monorepo stability, test coverage, and migration to self-hosted Forgejo (git.gram-lang.org) mirrored to GitHub and Codeberg.

1.0.0-beta.5

Minor Changes

  • 2ed4707: The Markdown, HTML, and printable/PDF outputs now show the same information consistently:

    • Markdown recipes now include a nutrition summary (calories, carbs, protein, fat, etc.), which was previously only shown in HTML and print.
    • Recipe comments now appear as numbered footnotes in Markdown and print output too, instead of only in HTML.
    • When a shopping-list ingredient's purchasing weight differs from what actually goes in the bowl (e.g. "1 avocado" vs. its usable flesh), Markdown and print now show the extra "gross weight" note, matching HTML.
    • When the same ingredient appears in incompatible units that can't be combined (e.g. "100g" and "1 cup" with no density available), Markdown and print now group them together with a "mixed units" warning, matching HTML.
  • 938afcd: Add an interactive Gantt Chart view to the VS Code extension and export reusable Gantt chart rendering helpers (toGanttHTML, attachGanttInteractivity) from @gram-lang/renderer. Provides a real-time timeline visualization of recipe steps, background timers, and target serving times directly in your editor and the web playground.

Patch Changes

  • 7b246ae: Removed all uses of any from the physical/nutrition analysis layer's internal types, typing them against the real shapes already exported by @gram-lang/kitchen and this package's own AnalyzedUsage/NutritionItem. No behavior change for this package beyond the fixes already released separately (see the relative-quantity type changeset). The renderer's printable/PDF view gained one internal any to stay compatible with the analyzer's now-stricter shopping-list type — purely a type-level adjustment, no output change.
  • 19a9f19: The hideStepQty rendering option (hides ingredient quantities from step text) now works with toHTML and toMarkdown, not just toPrintHTML — it was previously silently ignored by the other two.
  • 73fde5e: Fixed an HTML injection vulnerability (XSS) in toHTML's timing-card tooltips: a section title or named timer containing HTML would render unescaped in the "Active Time" / "Total Time" tooltips, exploitable via the playground or the VS Code preview. Both are now properly escaped like every other text field.
  • 3fae598: toHTML, toMarkdown, and toPrintHTML now type their data parameter instead of accepting any. Typing it surfaced two real bugs, now fixed: the HTML nutrition panel's "incomplete data" warning was never actually shown (it read a field that never existed, always showing a blank 0-calorie panel instead), and the printable/PDF view displayed sodium in grams instead of milligrams (1000x too high).
  • a55dca8: toMarkdown now neutralizes raw HTML (< and &) in recipe titles, ingredient names, and step text. Previously, a recipe containing something like <img onerror=...> in its title would pass through untouched, which could run as a script if that Markdown was later converted to HTML — this is now escaped automatically, closing that gap for imported or shared recipes.
  • d61d786: QuantityValueAST (the parser's internal representation of a parsed number/fraction/range) is now a proper discriminated union instead of a flat interface with every field optional. This is an internal type-safety improvement with no behavior change — it's what would have caught, at compile time, a real bug fixed earlier in diffRecipes (checking qty.from/qty.to, fields that never existed on any variant).
  • Updated dependencies [b1aa8db]
  • Updated dependencies [3afd970]
  • Updated dependencies [8f7e887]
  • Updated dependencies [5194ba4]
  • Updated dependencies [1d86e74]
  • Updated dependencies [7b246ae]
  • Updated dependencies [f147b25]
  • Updated dependencies [9553678]
  • Updated dependencies [68a2a45]
  • Updated dependencies [7c83cf8]
  • Updated dependencies [dcaadd7]
  • Updated dependencies [0c2e818]
  • Updated dependencies [943e9f8]
  • Updated dependencies [24a108c]
  • Updated dependencies [970c32b]
  • Updated dependencies [23e4286]
  • Updated dependencies [901e90e]
  • Updated dependencies [064ba9f]
  • Updated dependencies [b1aa8db]
  • Updated dependencies [79d835c]
  • Updated dependencies [d61d786]
    • @gram-lang/analyzer@1.0.0-beta.5
    • @gram-lang/parser@1.0.0-beta.5
    • @gram-lang/i18n@1.0.0-beta.5
    • @gram-lang/kitchen@1.0.0-beta.5

1.0.0-beta.4

Major Changes

  • 68365c4: Section retro-planning (e.g. ## Section ~{-2h}) now enforces a strict signed-duration syntax instead of accepting arbitrary free text, preventing invalid timeline calculations. Added support for the d (day) time unit.

Patch Changes

  • 7487b09: Fixed the display of alternative ingredient and cookware groups (@egg|@tofu). They now correctly render inline as a single joined line in shopping and section lists, rather than being dropped or rendered as oddly-wrapped sub-lists.
  • 0bee2b2: Added support for bare single-word children in composite ingredients (e.g., @juice<@lemon), and allowed independent preparation instructions on the parent side. Fixed section ingredient lists silently dropping the parent reference.
  • cb6b794: Fixed an issue where scaled fractions resulting in values below 1 (e.g., 0.5) were rendered as raw decimals instead of common fractions (e.g., 1/2) in the section ingredient list.
  • fc47a86: Renamed the cookTime metric to idleTime across the ecosystem to better reflect hands-off wait time. Additionally, passive timers sharing the same name are now automatically sequenced one after another on the same background track.
  • b546f96: Fixed shopping list ingredient names defaulting to the database's canonical wording when the recipe used a valid alias. The lists now correctly preserve the recipe's original wording or translated alias, ensuring consistent language throughout.
  • 55430e4: Added detailed per-contribution time breakdowns (Active, Prep, Total) to compiled recipe metrics, and surfaced them as explanatory tooltips on the time summary badges in the HTML renderer.
  • Updated dependencies [06039f2]
  • Updated dependencies [7487b09]
  • Updated dependencies [0bee2b2]
  • Updated dependencies [e659677]
  • Updated dependencies [aa0c082]
  • Updated dependencies [fc47a86]
  • Updated dependencies [68365c4]
  • Updated dependencies [c1c9b53]
  • Updated dependencies [68365c4]
  • Updated dependencies [55430e4]
    • @gram-lang/kitchen@1.0.0-beta.4
    • @gram-lang/parser@1.0.0-beta.4
    • @gram-lang/i18n@1.0.0-beta.4

1.0.0-beta.3

Patch Changes

  • Updated deployment configuration to automate npmjs packages publication
  • Updated dependencies
    • @gram-lang/i18n@1.0.0-beta.3
    • @gram-lang/kitchen@1.0.0-beta.3
    • @gram-lang/parser@1.0.0-beta.3

1.0.0-beta.2

Minor Changes

  • 8fca04c: toHTML no longer stamps footnote anchor ids with Math.random(). Output is now deterministic by default (ids like note-1), which is required for byte-stable golden/conformance testing. If you render multiple recipes on the same page and relied on random ids to avoid anchor collisions, pass a new renderId option (e.g. a recipe slug) to disambiguate.
  • a46c24f: Upgraded all monorepo dependencies to their latest versions and implemented a TypeScript 7 dual setup for faster typechecking while preserving compilation toolchain compatibility. Fixed type errors arising from Node 26 and VS Code LSP v10 updates.

Patch Changes

  • 0aec389: Fix _usageId leaking a global counter across separate compile() calls in the same process (affected the language server and gram scale's parallel compiles, making ids non-deterministic for an unchanged recipe). Fix nutrition analysis always reporting isEstimate: true regardless of actual data precision. Fix the section mass badge in HTML output missing its scale icon.

  • f5f1efe: chore: declare sideEffects: false so bundlers can tree-shake unused exports from these packages

    No package previously declared this, so third-party bundlers had to assume every module might have side effects and couldn't safely drop unused code.

  • 0ccfc99: Compiler warnings (CompilationResult.warnings, NutritionMetrics.warnings) are now always structured Warning objects ({ code, message, item?, loc?, section? }) instead of sometimes being plain strings depending on call order — a latent inconsistency that could previously produce "[object Object]" in some rendered output. Usage.composite, Usage.options, and ProcessedStep.content are now properly typed instead of any. Also fixes range-based timer quantities (e.g. ~{5-10min}) never displaying correctly in gram diff output, due to a pre-existing typo checking non-existent fields.

  • Updated dependencies [0aec389]

  • Updated dependencies [e192fe2]

  • Updated dependencies [404198a]

  • Updated dependencies [d837da3]

  • Updated dependencies [f5f1efe]

  • Updated dependencies [8dc9c60]

  • Updated dependencies [6eab9b3]

  • Updated dependencies [e55940f]

  • Updated dependencies [a46c24f]

  • Updated dependencies [0ccfc99]

    • @gram-lang/kitchen@1.0.0-beta.2
    • @gram-lang/parser@1.0.0-beta.2
    • @gram-lang/i18n@1.0.0-beta.2

1.0.0-beta.1

Major Changes

  • a1e6fe9: refactor: rename isAsync to isPassive to align with domain terminology

    To better align the codebase with the actual domain model of a kitchen, the "asynchronous" timer concept has been completely renamed to "passive". This introduces the following breaking changes for tool builders:

    • AST: The TimerAST node property isAsync: boolean is now isPassive: boolean.
    • CSS: The .timer.async class generated by the renderer has been renamed to .timer.passive.
    • Kitchen Metrics: All internal variables and comments referring to async background tasks have been updated to passive.

Minor Changes

  • a244341: Major overhaul of the documentation and playground infrastructure:

    • Documentation Rewrite & i18n: The documentation has been completely rewritten, thoroughly verified, and is now fully translated into French (in addition to the English version).
    • Advanced Vue 3 Playground: The legacy playground has been removed and rebuilt from the ground up using Vue 3. This new version is directly integrated into the documentation and introduces powerful new features, including recipe scaling and baker's math.
  • 8921d9d: Fixed several correctness bugs found during a documentation audit, and added alias-aware cross-unit shopping list aggregation.

    • @gram-lang/analyzer: unit_weight-based conversions (e.g. @avocado{1}) were being double-divided by yield — the whole-unit weight is now correctly treated as Gross Mass, with Net Mass derived forward (Gross × yield), while explicit mass/volume entries keep deriving Gross backward (Net ÷ yield) as before. Optional ingredients (?) are no longer counted in nutrition totals. New resolveCanonicalId() resolves an ingredient name/alias to its database key, and a new aggregateShoppingList() step re-groups the shopping list by canonical id — merging aliased ingredients (e.g. beurre/butter) and cross-unit quantities (e.g. 100g + 1 cup) into a single gram total whenever every entry resolves to a mass, falling back to separate entries flagged multiUnit: true when a density is missing.
    • @gram-lang/renderer: The HTML shopping list now clusters consecutive multiUnit-flagged entries for the same ingredient under one heading with a "⚠️ Mixed units" badge, instead of listing them as unrelated lines.
    • @gram-lang/cli: shopper's alias resolution now reuses @gram-lang/analyzer's resolveCanonicalId() instead of a separate, duplicated alias map.
  • fbe648e: Improve ingredient preparation tracking and display.

    • Kitchen: aggregateSectionIngredients now groups ingredients by both id and preparation, creating separate entries for the same ingredient if it requires different preparations (e.g. cold vs melted).
    • Renderer: A new formatMode option in the render context controls preparation rendering. Preparations remain visible in inline text to prevent information loss. In the section's ingredient list (Mise-en-place), they are cleanly displayed with an em-dash. In the global shopping list, they remain hidden.
  • 2476140: Added a centralized ScaleEngine in @gram-lang/kitchen to make recipe scaling (--scale) and Baker's Percentage math safer and more consistent everywhere.

    • @gram-lang/kitchen: New resolveScaleFactor()/applyScale() API validates a --scale target before computing a factor — rejecting fixed (@=) ingredients, relative quantities, ingredients only used inside a sub-recipe, ingredients inside an alternative-ingredient group, and ingredients split across incompatible units, with a clear error instead of a silently wrong number. A sub-recipe's own total (e.g. "2 lemons") is itself a valid scale target. Scaling is now a pure operation (never mutates the original recipe), and the compiled recipe now carries an explicit scaleFactor field. Covered by a new unit test suite.
    • @gram-lang/analyzer: Fixed the @* Baker's-reference auto-detection (it silently never matched before), and it now refuses to use a relative-quantity ingredient as the 100% base instead of computing bogus percentages. The enriched JSON AST now natively includes a bakersPercentage field for all ingredients if a reference ingredient is declared or passed via the bakersReference option. convertUnit() now accepts an optional density (g/mL) to bridge mass ↔ volume conversions; new resolveIngredientDensity() and parseDensityOverrides() helpers resolve that density from a recipe's densities: frontmatter. Also includes a critical null-safety fix when parsing recipes containing standalone comments.
    • @gram-lang/renderer: Natively supports formatting Baker's Percentages provided by the analyzer (for HTML and Markdown exports, and the Playground), removing its legacy calculation logic. Fixed gram print --bakers-math-only having no effect.
    • @gram-lang/cli: The CLI now cleanly acts as a presentation layer for Baker's Math, reading percentages directly from the AST. Added --bakers-math, --bakers-reference, and --bakers-math-only flags to the view, print and export commands. --scale id=value now supports same-family unit conversion and cross-family conversion when a density is available; suggests the closest matching ingredient name on a typo; no longer shows corrupted comparison rows for an ingredient split across multiple units in gram scale.

Patch Changes

  • e6cf842: Refined formatting and mass normalization for relative quantities:

    • Cleaner Display: Relative quantities are now seamlessly displayed without internal @ or & markers (e.g., 125% of lemon juice). The redundant formula brackets [125% of...] have been removed from inline instructions.
    • Robust Shopping List Aggregation: The compiler (@gram-lang/kitchen) now strictly tracks ingredient lineage using _usageIds. This allows the analyzer (@gram-lang/analyzer) to flawlessly compute exact masses for complex items in the shopping list without confusing standard ingredients and their alternatives.
    • Shopping List Accuracy: When mass normalization is enabled, the shopping list will now accurately display the fully resolved physical mass for relative quantities (e.g., sugar (156 g)) instead of falling back to the formula string.
  • Updated dependencies [a244341]

  • Updated dependencies [1eafa64]

  • Updated dependencies [a1e6fe9]

  • Updated dependencies [fbe648e]

  • Updated dependencies [6013e64]

  • Updated dependencies [e6cf842]

  • Updated dependencies [2476140]

  • Updated dependencies [3f7bc5d]

  • Updated dependencies [979f32b]

    • @gram-lang/kitchen@1.0.0-beta.1
    • @gram-lang/parser@1.0.0-beta.1

1.0.0-beta.0

Major Changes

  • 2dcd766: Introduction of the official GRAM CLI (@gram-lang/cli), a comprehensive command-line tool to manage, compile, and interact with your recipes.

    Project & Recipe Management:

    • Project Setup: gram init safely scaffolds a .gram environment, including interactive AI provider setup (Google, OpenAI, Anthropic, Ollama) and secret management.
    • Automated Import: gram import scrapes recipes from any URL and uses AI to flawlessly translate and convert them into native .gram syntax.
    • Validation & Compilation: gram check instantly validates syntax and database integrity. gram build compiles recipes to robust JSON with full physical and nutritional enrichment.
    • Smart Scaling & Diff: gram scale dynamically resizes recipes (e.g., --scale flour=300g) with a visual before/after comparison. gram diff provides a semantic "git diff" for cooking, tracking changes in quantities, timings, and steps.
    • Export & Print: gram print generates a beautifully typeset A4 HTML recipe card. gram export converts recipes to clean Markdown or static HTML.
    • Auto-formatting & Watcher: gram format automatically enforces .gram language styling standards. gram watch provides real-time validation upon saving.

    Interactive Cooking & Daily Use:

    • Terminal Cooking Assistant (gram cook): A step-by-step interactive TUI (Terminal User Interface) that guides you through the recipe, featuring a dynamic ingredient checklist and live background timers.
    • Smart Shopping List (gram shop): Aggregates ingredients across multiple recipes, automatically converting volumes to masses and sorting them by supermarket aisle.
    • Recipe Search (gram suggest): An alias-aware search engine to find recipes based on your available ingredients (e.g., --with "butter, eggs" --without "milk").
    • Rich Terminal Preview (gram view): Renders recipes directly in the terminal with color coding, active timers, and nutritional tables.

    AI-Powered Database Management (gram db):

    • Smart Database Sync & Enrichment: gram db sync automatically tracks new ingredients across your project. gram db enrich uses AI to automatically fill in missing densities, unit weights, categories, and nutrition facts.
    • Semantic Linting & Conflict Resolution: gram db lint uses AI to detect plural mistakes and semantic duplicates (e.g., scallion vs green onion). gram db merge handles conflicts when integrating external community databases.

Minor Changes

  • 79105ce: Complete overhaul of the VS Code Extension with Language Server, Live Preview, and advanced assistance

    Major New Features:

    • Full Language Server (LSP): The extension now ships with a complete language server. All advanced features activate instantly upon opening a .gram file.
    • Dynamic Live Preview: A side-by-side WebView panel displaying the real-time HTML render of the recipe as you type.
      • Gracefully handles syntax errors via a visual fallback.
      • Integrates the official Playground styles for perfect consistency.
    • CodeLens & Inlay Hints:
      • Inlay Hints: Displays the cumulative total time in gray next to section titles.
      • CodeLens: Clickable buttons ▶ Preview and 📊 Macros above the main recipe title for quick access.

    Ingredient Database & Nutrition:

    • Automatic Loading: Automatically detects and loads .gram/ingredients.yaml from the workspace root (or via the path configured in gram.ingredientDatabase.path settings). Optimized indexing (O(1)) for maximum performance.
    • Seamless Plural Management: The extension silently handles plurals (e.g., @carrots{3} will automatically match carrot). No error diagnostics are raised, everything is transparent.
    • Nutritional Hover & Macros Panel:
      • Hovering over an ingredient displays a complete nutritional table (calories, proteins, carbs, fats, etc.).
      • The Live Preview integrates a Macros panel (hidden by default) that can be shown via CodeLens, featuring clear visual alerts for ingredients missing data.
    • Fuzzy Matching "Did you mean?": Levenshtein algorithm (distance ≤ 2) suggests corrections if an ingredient is misspelled (e.g., @tomaato suggests @tomato). Directly integrated into Quick Fix code actions.
    • On-Hover Unit Conversion: Automatically converts volumes (ml, tbsp, etc.) to grams when hovering over an ingredient if its density is known in the database.

    Editing Assistance & Navigation:

    • Advanced Contextual Autocompletion:
      • After @: Suggests ingredients and their aliases from the YAML database. Automatically adds curly braces {} for multi-word names.
      • After &: Suggests only the existing intermediate declarations in the document.
      • Inside {}: Suggests canonical units (mass, volume, time) and their aliases (French/English) as soon as a digit is typed.
    • Smart Navigation:
      • Go to Definition (Ctrl+Click / F12) on a &ref reference to jump to its ->&ref declaration.
      • Find All References (Shift+F12) to list all usages of an intermediate.
      • Rename Symbol (F2) to atomically rename an intermediate (declaration + references).
      • Outline Panel showing the hierarchy of sections and elements, with foldable code in the gutter.
    • Intermediate Hover: Displays the full text of the step where the intermediate was created.

    Diagnostics & Code Actions (Quick Fixes):

    • Real-Time Diagnostics:
      • Red underline for an orphaned &ref reference.
      • Warning for an unused ->&ref declaration.
      • Warning if the frontmatter (title) is missing.
    • Code Actions (💡):
      • Quick Fix: Insert the missing title: in the frontmatter.
      • Quick Fix: Remove an unused intermediate declaration.
      • Quick Fix: Declare a missing intermediate for an existing reference.
      • Refactor: Convert a volume quantity to mass directly in the code.
      • Refactor: Replace a misspelled ingredient with the closest Fuzzy match suggestion.

    Semantic Highlighting, Formatting & Snippets:

    • Semantic Tokens: Regex-based syntax highlighting (TextMate) is replaced by AST-driven highlighting. Offers surgical precision for ingredients, timers, temperatures, comments, and nested units (e.g., precise separation of value and unit in {10g}).
    • Auto-formatting (Alt+Shift+F):
      • Normalization of spaces inside curly braces ({ 200 g } → {200g}).
      • Normalization of composite ingredients (@a < @b → @a<@b).
      • Alignment of section titles and tab-to-space conversions.
    • Built-in Snippets: Keyboard shortcuts for the basic structure (frontmatter, sections, steps), ingredient variants (@ing, @?, @-), cookware (#cw), and timers/temperatures.
  • babbb20: Core language update to enforce new syntax adjustments (breaking changes).

    • Grammar & Parsing:
      • Made {} optional for single-word ingredients.
      • Replaced temperature symbol with °.
      • Replaced async timers with ~&{}.
      • Replaced aliases brackets with :.
      • Tightened <@ with no spaces allowed.
      • Added fixed modifier =.
      • Mandatory @& inside relative quantities declarations. (e.g: @water{60% @&flour})
      • Top-Level Support: Allowed writing comments and recipe steps globally, anywhere in the document (even before the first ## Section).
    • Compiler Analysis:
      • Added INVALID_MODIFIER_COMBINATION warnings.
      • Updated AST transformations to support the new modifiers parsing rules and the implicit top-level sections grouping.
  • babbb20: Aligned visual tooling and test recipes with the new grammar.

    • GramHighlight.ts (Playground & VSCode): Updated all syntax highlighting regular expressions to accurately match the new syntax (new temperature symbols, updated modifiers, etc.).
    • Examples (basquaise_chicken.gram, lemon_meringue_pie.gram, torture.gram): Fully migrated recipe code to comply with the new grammar.
  • caf1630: Major architecture refactoring, ESM Migration, performance optimizations and code cleanup

  • babbb20: Complete overhaul of the documentation to reflect the new syntax changes.

Patch Changes

  • b2a235c: NutritionMetrics output field renamed from salt to sodium to match the ingredient database schema
  • Updated dependencies [6e95e35]
  • Updated dependencies [79105ce]
  • Updated dependencies [babbb20]
  • Updated dependencies [babbb20]
  • Updated dependencies [caf1630]
  • Updated dependencies [babbb20]
  • Updated dependencies [2dcd766]
    • @gram-lang/kitchen@1.0.0-beta.0
    • @gram-lang/parser@1.0.0-beta.0

0.10.1

Patch Changes

  • Cleaned up and updated dependencies.
  • Implemented Turborepo to optimize and simplify project building.

0.10.0

Minor Changes

  • d89c2a4: Created a new shared @gram-lang/renderer package to handle HTML and Markdown generation.

Patch Changes

  • 3720644: Added Zod to automatically catch invalid data and prevent crashes.
  • 69870cc: Standardized how recipe elements are identified across the system to prevent typos and errors.