@4kk11/cooklang-sankey 0.1.2 → 0.1.4

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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { CooklangRecipe, Step } from '@cooklang/cooklang';
2
- export { Content, CooklangParser, CooklangRecipe, FlatCookware, FlatIngredient, FlatTimer, Ingredient, Item, Quantity, Section, Step, Value, cookware_display_name, getFlatCookware, getFlatIngredients, getFlatTimers, ingredient_display_name, quantity_display } from '@cooklang/cooklang';
1
+ import { CooklangRecipe, Value, Quantity, Step } from '@cooklang/cooklang';
2
+ export { Content, CooklangParser, CooklangRecipe, Ingredient, Item, Quantity, Section, Step, Value, getNumericValue, quantity_display } from '@cooklang/cooklang';
3
3
 
4
4
  /**
5
5
  * Cooklang Parser wrapper using official @cooklang/cooklang package.
@@ -339,178 +339,78 @@ declare const generateSankeyData: (recipe: CooklangRecipe, options?: SankeyGener
339
339
  declare const optimizeSankeyData: (data: SankeyData) => SankeyData;
340
340
 
341
341
  /**
342
- * Step text generation utilities using official @cooklang/cooklang package.
342
+ * Value formatting utilities using official @cooklang/cooklang package.
343
343
  *
344
344
  * @remarks
345
- * Provides utilities for converting Cooklang step items into human-readable
346
- * string representations using official display functions.
345
+ * Provides utilities for converting Cooklang quantity and value types
346
+ * into human-readable string representations.
347
347
  *
348
348
  * @packageDocumentation
349
349
  */
350
350
 
351
351
  /**
352
- * Generates complete text from step items by resolving references.
353
- *
354
- * @remarks
355
- * Converts a Step's items array into a readable string by:
356
- * - Keeping text items as-is
357
- * - Resolving ingredient references to "name(quantity)" format using official display functions
358
- * - Resolving cookware references to their display names
359
- * - Resolving timer references to their display values
360
- *
361
- * @param step - The Step object containing items to format
362
- * @param recipe - The parent CooklangRecipe for resolving references
363
- * @returns A concatenated string of all step items
352
+ * Formats a Cooklang Value to a string representation.
364
353
  *
365
- * @example
366
- * ```ts
367
- * // For a step with text "Cook " + ingredient(pasta, 400g) + " until done"
368
- * generateStepText(step, recipe);
369
- * // "Cook pasta(400 g) until done"
370
- * ```
371
- */
372
- declare const generateStepText: (step: Step, recipe: CooklangRecipe) => string;
373
-
374
- /**
375
- * Display-ready recipe types for UI rendering.
354
+ * @param value - The Value object to format (number, range, or text)
355
+ * @returns A string representation of the value, or empty string if null/undefined
376
356
  *
377
357
  * @remarks
378
- * These types represent formatted recipe data suitable for direct UI display.
379
- * They use simple string values for quantities and units, making them easy
380
- * to render without additional formatting logic.
381
- *
382
- * @packageDocumentation
383
- */
384
- /**
385
- * Ingredient formatted for display.
358
+ * Handles both Regular and Fraction number types from the WASM parser.
359
+ * Fractions are displayed in their natural form (e.g., "1/2", "2 1/2").
386
360
  *
387
361
  * @example
388
362
  * ```ts
389
- * const ingredient: DisplayIngredient = {
390
- * name: "小麦粉",
391
- * quantity: "200",
392
- * unit: "g"
393
- * };
363
+ * // Regular number
364
+ * formatValue({ type: "number", value: { type: "regular", value: 200 } }); // "200"
365
+ * // Fraction
366
+ * formatValue({ type: "number", value: { type: "fraction", value: { whole: 0, num: 1, den: 2, err: 0 } } }); // "1/2"
367
+ * // Range with fractions
368
+ * formatValue({ type: "range", value: { start: { type: "regular", value: 2 }, end: { type: "regular", value: 3 } } }); // "2-3"
369
+ * formatValue({ type: "text", value: "some" }); // "some"
370
+ * formatValue(null); // ""
394
371
  * ```
395
372
  */
396
- interface DisplayIngredient {
397
- readonly name: string;
398
- readonly quantity: string;
399
- readonly unit: string;
400
- }
373
+ declare const formatValue: (value: Value | null | undefined) => string;
401
374
  /**
402
- * Cookware formatted for display.
375
+ * Formats a Cooklang Quantity into separate value and unit strings.
403
376
  *
404
- * @example
405
- * ```ts
406
- * const cookware: DisplayCookware = {
407
- * name: "フライパン",
408
- * note: "26cm"
409
- * };
410
- * ```
411
- */
412
- interface DisplayCookware {
413
- readonly name: string;
414
- readonly note: string;
415
- }
416
- /**
417
- * Timer formatted for display.
377
+ * @param quantity - The Quantity object to format
378
+ * @returns An object with `quantity` (numeric string) and `unit` (unit string)
418
379
  *
419
380
  * @example
420
381
  * ```ts
421
- * const timer: DisplayTimer = {
422
- * name: "煮込み",
423
- * quantity: "30",
424
- * unit: "分"
425
- * };
426
- * ```
427
- */
428
- interface DisplayTimer {
429
- readonly name: string;
430
- readonly quantity: string;
431
- readonly unit: string;
432
- }
433
- /**
434
- * Step formatted for display.
382
+ * formatQuantityAmount({ value: { type: "number", value: 200 }, unit: "g" });
383
+ * // { quantity: "200", unit: "g" }
435
384
  *
436
- * @example
437
- * ```ts
438
- * const step: DisplayStep = {
439
- * text: "小麦粉(200g)と卵(2個)を混ぜる"
440
- * };
385
+ * formatQuantityAmount(null);
386
+ * // { quantity: "", unit: "" }
441
387
  * ```
442
388
  */
443
- interface DisplayStep {
444
- readonly text: string;
445
- }
446
- /**
447
- * Complete recipe data formatted for UI display.
448
- *
449
- * @remarks
450
- * This interface represents a fully parsed and formatted recipe
451
- * ready for rendering in a UI component. All values are strings
452
- * for easy display without additional formatting.
453
- *
454
- * @example
455
- * ```ts
456
- * import { parseRecipeForDisplay } from '@4kk11/cooklang-sankey';
457
- *
458
- * const displayData = parseRecipeForDisplay(recipe);
459
- * displayData.ingredients.forEach(ing => {
460
- * console.log(`${ing.name}: ${ing.quantity}${ing.unit}`);
461
- * });
462
- * ```
463
- */
464
- interface DisplayRecipe {
465
- readonly ingredients: readonly DisplayIngredient[];
466
- readonly cookware: readonly DisplayCookware[];
467
- readonly timers: readonly DisplayTimer[];
468
- readonly steps: readonly DisplayStep[];
469
- }
470
-
471
- /**
472
- * Recipe display utilities for UI rendering.
473
- *
474
- * @remarks
475
- * Provides utilities for converting parsed CooklangRecipe objects into
476
- * display-ready data structures suitable for UI rendering.
477
- *
478
- * Uses the official @cooklang/cooklang package's convenience functions
479
- * for accurate quantity aggregation and formatting.
480
- *
481
- * @packageDocumentation
482
- */
483
-
389
+ declare const formatQuantityAmount: (quantity: Quantity | null | undefined) => {
390
+ quantity: string;
391
+ unit: string;
392
+ };
484
393
  /**
485
- * Parses a CooklangRecipe into a display-ready format.
394
+ * Generates complete text from step items by resolving references.
486
395
  *
487
396
  * @remarks
488
- * Uses the official @cooklang/cooklang package's convenience functions
489
- * (`getFlatIngredients`, `getFlatCookware`, `getFlatTimers`) for proper
490
- * handling of grouped quantities.
397
+ * Converts a Step's items array into a readable string by:
398
+ * - Keeping text items as-is
399
+ * - Resolving ingredient references to "name(quantity)" format
400
+ * - Resolving cookware references to their names
401
+ * - Resolving timer references to their display values
491
402
  *
492
- * @param recipe - The parsed CooklangRecipe object
493
- * @returns DisplayRecipe with formatted data for UI rendering
403
+ * @param step - The Step object containing items to format
404
+ * @param recipe - The parent CooklangRecipe for resolving references
405
+ * @returns A concatenated string of all step items
494
406
  *
495
407
  * @example
496
408
  * ```ts
497
- * import { CooklangParser, parseRecipeForDisplay } from '@4kk11/cooklang-sankey';
498
- *
499
- * const parser = new CooklangParser();
500
- * const [recipe] = parser.parse(recipeText);
501
- * const displayData = parseRecipeForDisplay(recipe);
502
- *
503
- * // Render ingredients
504
- * displayData.ingredients.forEach(ing => {
505
- * console.log(`${ing.name}: ${ing.quantity}${ing.unit}`);
506
- * });
507
- *
508
- * // Render steps
509
- * displayData.steps.forEach((step, i) => {
510
- * console.log(`${i + 1}. ${step.text}`);
511
- * });
409
+ * // For a step with text "Cook " + ingredient(pasta, 400g) + " until done"
410
+ * generateStepText(step, recipe);
411
+ * // "Cook pasta(400g) until done"
512
412
  * ```
513
413
  */
514
- declare function parseRecipeForDisplay(recipe: CooklangRecipe): DisplayRecipe;
414
+ declare const generateStepText: (step: Step, recipe: CooklangRecipe) => string;
515
415
 
516
- export { type BaseLinkMetadata, type BaseNodeMetadata, type BaseSankeyLink, type BaseSankeyNode, type DAGEdge, type DAGNode, type DisplayCookware, type DisplayIngredient, type DisplayRecipe, type DisplayStep, type DisplayTimer, type ExtractedValue, type NodeCategory, type RecipeMetadata, type SankeyData, type SankeyGeneratorOptions, type SankeyLink, type SankeyNode, type TransformationType, extractMetadata, generateSankeyData, generateStepText, optimizeSankeyData, parseRecipeForDisplay };
416
+ export { type BaseLinkMetadata, type BaseNodeMetadata, type BaseSankeyLink, type BaseSankeyNode, type DAGEdge, type DAGNode, type ExtractedValue, type NodeCategory, type RecipeMetadata, type SankeyData, type SankeyGeneratorOptions, type SankeyLink, type SankeyNode, type TransformationType, extractMetadata, formatQuantityAmount, formatValue, generateSankeyData, generateStepText, optimizeSankeyData };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { CooklangRecipe, Step } from '@cooklang/cooklang';
2
- export { Content, CooklangParser, CooklangRecipe, FlatCookware, FlatIngredient, FlatTimer, Ingredient, Item, Quantity, Section, Step, Value, cookware_display_name, getFlatCookware, getFlatIngredients, getFlatTimers, ingredient_display_name, quantity_display } from '@cooklang/cooklang';
1
+ import { CooklangRecipe, Value, Quantity, Step } from '@cooklang/cooklang';
2
+ export { Content, CooklangParser, CooklangRecipe, Ingredient, Item, Quantity, Section, Step, Value, getNumericValue, quantity_display } from '@cooklang/cooklang';
3
3
 
4
4
  /**
5
5
  * Cooklang Parser wrapper using official @cooklang/cooklang package.
@@ -339,178 +339,78 @@ declare const generateSankeyData: (recipe: CooklangRecipe, options?: SankeyGener
339
339
  declare const optimizeSankeyData: (data: SankeyData) => SankeyData;
340
340
 
341
341
  /**
342
- * Step text generation utilities using official @cooklang/cooklang package.
342
+ * Value formatting utilities using official @cooklang/cooklang package.
343
343
  *
344
344
  * @remarks
345
- * Provides utilities for converting Cooklang step items into human-readable
346
- * string representations using official display functions.
345
+ * Provides utilities for converting Cooklang quantity and value types
346
+ * into human-readable string representations.
347
347
  *
348
348
  * @packageDocumentation
349
349
  */
350
350
 
351
351
  /**
352
- * Generates complete text from step items by resolving references.
353
- *
354
- * @remarks
355
- * Converts a Step's items array into a readable string by:
356
- * - Keeping text items as-is
357
- * - Resolving ingredient references to "name(quantity)" format using official display functions
358
- * - Resolving cookware references to their display names
359
- * - Resolving timer references to their display values
360
- *
361
- * @param step - The Step object containing items to format
362
- * @param recipe - The parent CooklangRecipe for resolving references
363
- * @returns A concatenated string of all step items
352
+ * Formats a Cooklang Value to a string representation.
364
353
  *
365
- * @example
366
- * ```ts
367
- * // For a step with text "Cook " + ingredient(pasta, 400g) + " until done"
368
- * generateStepText(step, recipe);
369
- * // "Cook pasta(400 g) until done"
370
- * ```
371
- */
372
- declare const generateStepText: (step: Step, recipe: CooklangRecipe) => string;
373
-
374
- /**
375
- * Display-ready recipe types for UI rendering.
354
+ * @param value - The Value object to format (number, range, or text)
355
+ * @returns A string representation of the value, or empty string if null/undefined
376
356
  *
377
357
  * @remarks
378
- * These types represent formatted recipe data suitable for direct UI display.
379
- * They use simple string values for quantities and units, making them easy
380
- * to render without additional formatting logic.
381
- *
382
- * @packageDocumentation
383
- */
384
- /**
385
- * Ingredient formatted for display.
358
+ * Handles both Regular and Fraction number types from the WASM parser.
359
+ * Fractions are displayed in their natural form (e.g., "1/2", "2 1/2").
386
360
  *
387
361
  * @example
388
362
  * ```ts
389
- * const ingredient: DisplayIngredient = {
390
- * name: "小麦粉",
391
- * quantity: "200",
392
- * unit: "g"
393
- * };
363
+ * // Regular number
364
+ * formatValue({ type: "number", value: { type: "regular", value: 200 } }); // "200"
365
+ * // Fraction
366
+ * formatValue({ type: "number", value: { type: "fraction", value: { whole: 0, num: 1, den: 2, err: 0 } } }); // "1/2"
367
+ * // Range with fractions
368
+ * formatValue({ type: "range", value: { start: { type: "regular", value: 2 }, end: { type: "regular", value: 3 } } }); // "2-3"
369
+ * formatValue({ type: "text", value: "some" }); // "some"
370
+ * formatValue(null); // ""
394
371
  * ```
395
372
  */
396
- interface DisplayIngredient {
397
- readonly name: string;
398
- readonly quantity: string;
399
- readonly unit: string;
400
- }
373
+ declare const formatValue: (value: Value | null | undefined) => string;
401
374
  /**
402
- * Cookware formatted for display.
375
+ * Formats a Cooklang Quantity into separate value and unit strings.
403
376
  *
404
- * @example
405
- * ```ts
406
- * const cookware: DisplayCookware = {
407
- * name: "フライパン",
408
- * note: "26cm"
409
- * };
410
- * ```
411
- */
412
- interface DisplayCookware {
413
- readonly name: string;
414
- readonly note: string;
415
- }
416
- /**
417
- * Timer formatted for display.
377
+ * @param quantity - The Quantity object to format
378
+ * @returns An object with `quantity` (numeric string) and `unit` (unit string)
418
379
  *
419
380
  * @example
420
381
  * ```ts
421
- * const timer: DisplayTimer = {
422
- * name: "煮込み",
423
- * quantity: "30",
424
- * unit: "分"
425
- * };
426
- * ```
427
- */
428
- interface DisplayTimer {
429
- readonly name: string;
430
- readonly quantity: string;
431
- readonly unit: string;
432
- }
433
- /**
434
- * Step formatted for display.
382
+ * formatQuantityAmount({ value: { type: "number", value: 200 }, unit: "g" });
383
+ * // { quantity: "200", unit: "g" }
435
384
  *
436
- * @example
437
- * ```ts
438
- * const step: DisplayStep = {
439
- * text: "小麦粉(200g)と卵(2個)を混ぜる"
440
- * };
385
+ * formatQuantityAmount(null);
386
+ * // { quantity: "", unit: "" }
441
387
  * ```
442
388
  */
443
- interface DisplayStep {
444
- readonly text: string;
445
- }
446
- /**
447
- * Complete recipe data formatted for UI display.
448
- *
449
- * @remarks
450
- * This interface represents a fully parsed and formatted recipe
451
- * ready for rendering in a UI component. All values are strings
452
- * for easy display without additional formatting.
453
- *
454
- * @example
455
- * ```ts
456
- * import { parseRecipeForDisplay } from '@4kk11/cooklang-sankey';
457
- *
458
- * const displayData = parseRecipeForDisplay(recipe);
459
- * displayData.ingredients.forEach(ing => {
460
- * console.log(`${ing.name}: ${ing.quantity}${ing.unit}`);
461
- * });
462
- * ```
463
- */
464
- interface DisplayRecipe {
465
- readonly ingredients: readonly DisplayIngredient[];
466
- readonly cookware: readonly DisplayCookware[];
467
- readonly timers: readonly DisplayTimer[];
468
- readonly steps: readonly DisplayStep[];
469
- }
470
-
471
- /**
472
- * Recipe display utilities for UI rendering.
473
- *
474
- * @remarks
475
- * Provides utilities for converting parsed CooklangRecipe objects into
476
- * display-ready data structures suitable for UI rendering.
477
- *
478
- * Uses the official @cooklang/cooklang package's convenience functions
479
- * for accurate quantity aggregation and formatting.
480
- *
481
- * @packageDocumentation
482
- */
483
-
389
+ declare const formatQuantityAmount: (quantity: Quantity | null | undefined) => {
390
+ quantity: string;
391
+ unit: string;
392
+ };
484
393
  /**
485
- * Parses a CooklangRecipe into a display-ready format.
394
+ * Generates complete text from step items by resolving references.
486
395
  *
487
396
  * @remarks
488
- * Uses the official @cooklang/cooklang package's convenience functions
489
- * (`getFlatIngredients`, `getFlatCookware`, `getFlatTimers`) for proper
490
- * handling of grouped quantities.
397
+ * Converts a Step's items array into a readable string by:
398
+ * - Keeping text items as-is
399
+ * - Resolving ingredient references to "name(quantity)" format
400
+ * - Resolving cookware references to their names
401
+ * - Resolving timer references to their display values
491
402
  *
492
- * @param recipe - The parsed CooklangRecipe object
493
- * @returns DisplayRecipe with formatted data for UI rendering
403
+ * @param step - The Step object containing items to format
404
+ * @param recipe - The parent CooklangRecipe for resolving references
405
+ * @returns A concatenated string of all step items
494
406
  *
495
407
  * @example
496
408
  * ```ts
497
- * import { CooklangParser, parseRecipeForDisplay } from '@4kk11/cooklang-sankey';
498
- *
499
- * const parser = new CooklangParser();
500
- * const [recipe] = parser.parse(recipeText);
501
- * const displayData = parseRecipeForDisplay(recipe);
502
- *
503
- * // Render ingredients
504
- * displayData.ingredients.forEach(ing => {
505
- * console.log(`${ing.name}: ${ing.quantity}${ing.unit}`);
506
- * });
507
- *
508
- * // Render steps
509
- * displayData.steps.forEach((step, i) => {
510
- * console.log(`${i + 1}. ${step.text}`);
511
- * });
409
+ * // For a step with text "Cook " + ingredient(pasta, 400g) + " until done"
410
+ * generateStepText(step, recipe);
411
+ * // "Cook pasta(400g) until done"
512
412
  * ```
513
413
  */
514
- declare function parseRecipeForDisplay(recipe: CooklangRecipe): DisplayRecipe;
414
+ declare const generateStepText: (step: Step, recipe: CooklangRecipe) => string;
515
415
 
516
- export { type BaseLinkMetadata, type BaseNodeMetadata, type BaseSankeyLink, type BaseSankeyNode, type DAGEdge, type DAGNode, type DisplayCookware, type DisplayIngredient, type DisplayRecipe, type DisplayStep, type DisplayTimer, type ExtractedValue, type NodeCategory, type RecipeMetadata, type SankeyData, type SankeyGeneratorOptions, type SankeyLink, type SankeyNode, type TransformationType, extractMetadata, generateSankeyData, generateStepText, optimizeSankeyData, parseRecipeForDisplay };
416
+ export { type BaseLinkMetadata, type BaseNodeMetadata, type BaseSankeyLink, type BaseSankeyNode, type DAGEdge, type DAGNode, type ExtractedValue, type NodeCategory, type RecipeMetadata, type SankeyData, type SankeyGeneratorOptions, type SankeyLink, type SankeyNode, type TransformationType, extractMetadata, formatQuantityAmount, formatValue, generateSankeyData, generateStepText, optimizeSankeyData };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ingredient_display_name, quantity_display, cookware_display_name, getFlatIngredients, getFlatCookware, getFlatTimers, grouped_quantity_is_empty, grouped_quantity_display, getNumericValue } from '@cooklang/cooklang';
2
- export { CooklangParser, CooklangRecipe, cookware_display_name, getFlatCookware, getFlatIngredients, getFlatTimers, ingredient_display_name, quantity_display } from '@cooklang/cooklang';
1
+ import { quantity_display, grouped_quantity_is_empty, grouped_quantity_display, getNumericValue } from '@cooklang/cooklang';
2
+ export { CooklangParser, CooklangRecipe, getNumericValue, quantity_display } from '@cooklang/cooklang';
3
3
  import toposort from 'toposort';
4
4
 
5
5
  // src/parser.ts
@@ -136,20 +136,63 @@ var calculateNodeValues = (nodes, sortedNodeIds) => {
136
136
  }
137
137
  return valueMap;
138
138
  };
139
+ var formatNumber = (num) => {
140
+ if (num.type === "regular") {
141
+ return num.value.toString();
142
+ } else if (num.type === "fraction") {
143
+ const { whole, num: numerator, den } = num.value;
144
+ if (whole === 0 && numerator === 0) {
145
+ return "0";
146
+ }
147
+ if (numerator === 0) {
148
+ return whole.toString();
149
+ }
150
+ if (whole === 0) {
151
+ return `${numerator}/${den}`;
152
+ }
153
+ return `${whole} ${numerator}/${den}`;
154
+ }
155
+ return "";
156
+ };
157
+ var formatValue = (value) => {
158
+ if (!value) return "";
159
+ if (value.type === "number") {
160
+ const numValue = value.value;
161
+ return formatNumber(numValue);
162
+ } else if (value.type === "range") {
163
+ const rangeValue = value.value;
164
+ const startStr = formatNumber(rangeValue.start);
165
+ const endStr = formatNumber(rangeValue.end);
166
+ if (startStr && endStr) {
167
+ return `${startStr}-${endStr}`;
168
+ }
169
+ return "";
170
+ } else if (value.type === "text") {
171
+ return value.value;
172
+ }
173
+ return "";
174
+ };
175
+ var formatQuantityAmount = (quantity) => {
176
+ if (!quantity) {
177
+ return { quantity: "", unit: "" };
178
+ }
179
+ return {
180
+ quantity: formatValue(quantity.value),
181
+ unit: quantity.unit || ""
182
+ };
183
+ };
139
184
  var generateStepText = (step, recipe) => {
140
185
  return step.items.map((item) => {
141
186
  if (item.type === "text") {
142
187
  return item.value;
143
188
  } else if (item.type === "ingredient") {
144
- const ingredient = recipe.ingredients[item.index];
145
- if (!ingredient) return "";
146
- const name = ingredient_display_name(ingredient);
147
- const quantityText = ingredient.quantity ? `(${quantity_display(ingredient.quantity)})` : "";
148
- return `${name}${quantityText}`;
189
+ const originalIngredient = recipe.ingredients[item.index];
190
+ if (!originalIngredient) return "";
191
+ const formatted = formatQuantityAmount(originalIngredient.quantity);
192
+ const quantityText = formatted.quantity && formatted.unit ? `(${formatted.quantity}${formatted.unit})` : formatted.quantity ? `(${formatted.quantity})` : "";
193
+ return `${originalIngredient.name}${quantityText}`;
149
194
  } else if (item.type === "cookware") {
150
- const cookware = recipe.cookware[item.index];
151
- if (!cookware) return "";
152
- return cookware_display_name(cookware);
195
+ return recipe.cookware[item.index]?.name || "";
153
196
  } else if (item.type === "timer") {
154
197
  const timer = recipe.timers[item.index];
155
198
  if (!timer) return "";
@@ -435,41 +478,7 @@ var optimizeSankeyData = (data) => {
435
478
  links: normalizedLinks
436
479
  };
437
480
  };
438
- function parseRecipeForDisplay(recipe) {
439
- const flatIngredients = getFlatIngredients(recipe);
440
- const ingredients = flatIngredients.map((ing) => ({
441
- name: ing.name,
442
- quantity: ing.quantity !== null ? String(ing.quantity) : "",
443
- unit: ing.unit || ""
444
- }));
445
- const flatCookware = getFlatCookware(recipe);
446
- const cookware = flatCookware.map((cw) => ({
447
- name: cw.name,
448
- note: cw.note || ""
449
- }));
450
- const flatTimers = getFlatTimers(recipe);
451
- const timers = flatTimers.map((timer) => ({
452
- name: timer.name || "",
453
- quantity: timer.quantity !== null ? String(timer.quantity) : "",
454
- unit: timer.unit || "minutes"
455
- }));
456
- const steps = [];
457
- for (const section of recipe.sections) {
458
- for (const content of section.content) {
459
- if (content.type === "step") {
460
- const stepText = generateStepText(content.value, recipe);
461
- steps.push({ text: stepText });
462
- }
463
- }
464
- }
465
- return {
466
- ingredients,
467
- cookware,
468
- timers,
469
- steps
470
- };
471
- }
472
481
 
473
- export { extractMetadata, generateSankeyData, generateStepText, optimizeSankeyData, parseRecipeForDisplay };
482
+ export { extractMetadata, formatQuantityAmount, formatValue, generateSankeyData, generateStepText, optimizeSankeyData };
474
483
  //# sourceMappingURL=index.js.map
475
484
  //# sourceMappingURL=index.js.map