@recipe-book/core 0.1.1 → 0.1.2

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/{chunk-D5CV3UF7.cjs → chunk-ISRDJR2O.cjs} +42 -9
  3. package/dist/chunk-ISRDJR2O.cjs.map +1 -0
  4. package/dist/errors.js +29 -1
  5. package/dist/errors.js.map +1 -1
  6. package/dist/format/duration.js.map +1 -1
  7. package/dist/format/ingredient.js.map +1 -1
  8. package/dist/format/quantity.js.map +1 -1
  9. package/dist/format/servings.js.map +1 -1
  10. package/dist/format/temperature.js.map +1 -1
  11. package/dist/index.cjs +62 -58
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +38 -11
  14. package/dist/index.d.ts +38 -11
  15. package/dist/index.js +6 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/quantity/parse.js.map +1 -1
  18. package/dist/quantity/scale.js.map +1 -1
  19. package/dist/recipe/ids.js.map +1 -1
  20. package/dist/recipe/parse.js +11 -6
  21. package/dist/recipe/parse.js.map +1 -1
  22. package/dist/resolve.js.map +1 -1
  23. package/dist/schema-org/from-json-ld.js +16 -23
  24. package/dist/schema-org/from-json-ld.js.map +1 -1
  25. package/dist/schema-org/to-json-ld.js.map +1 -1
  26. package/dist/schema-org.cjs +75 -82
  27. package/dist/schema-org.cjs.map +1 -1
  28. package/dist/schema-org.d.cts +3 -2
  29. package/dist/schema-org.d.ts +3 -2
  30. package/dist/steps/segment.js.map +1 -1
  31. package/dist/steps/temperature.js +1 -1
  32. package/dist/steps/temperature.js.map +1 -1
  33. package/dist/{types-BknM8KOd.d.cts → types-CKIoWsz8.d.cts} +21 -4
  34. package/dist/{types-BknM8KOd.d.ts → types-CKIoWsz8.d.ts} +21 -4
  35. package/dist/units/convert.js.map +1 -1
  36. package/dist/units/temperature.js.map +1 -1
  37. package/dist/validation.js.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/chunk-D5CV3UF7.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @recipe-book/core
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - `docsUrl`, and the link at the end of every error message, now end with a slash, such as `https://recipe-book.siraj.page/errors/unknown_unit/`, so they open the page without a redirect. ([#1377](https://github.com/SirajChokshi/recipe-book/pull/1377) by [@SirajChokshi](https://github.com/SirajChokshi))
8
+
9
+ - `RecipeBookError` now sets `cause` from its options in browsers whose built-in `Error` ignores them. ([#1217](https://github.com/SirajChokshi/recipe-book/pull/1217) by [@SirajChokshi](https://github.com/SirajChokshi))
10
+
11
+ - In Chrome and Edge before 93, Firefox before 91, and Safari before 15, `error.cause` was `undefined`.
12
+
13
+ - The TSDoc for core's conversion, format, and resolve functions now says which inputs pass through an error thrown by a getter or proxy. ([#1368](https://github.com/SirajChokshi/recipe-book/pull/1368) by [@SirajChokshi](https://github.com/SirajChokshi))
14
+
15
+ - The input and options: `resolveIngredient`, `formatQuantity`, `formatQuantityToParts`, `formatIngredient`, `formatServings`, `formatYield`, and `formatTemperature`.
16
+ - The input: `scaleQuantity`, `convert`, `toSystem`, and `convertTemperature`.
17
+ - The options: `segmentStepText`, `formatDuration`, and `toJsonLd`.
18
+
19
+ - Add `isRecipeValidationError`, which checks whether a caught value is a `RecipeValidationError` and narrows its type, so `issues` needs no cast. ([#1266](https://github.com/SirajChokshi/recipe-book/pull/1266) by [@SirajChokshi](https://github.com/SirajChokshi))
20
+
21
+ - It checks the error's `name`, `code`, and `issues` rather than using `instanceof`, so it also recognizes errors from another installed copy of `@recipe-book/core`, as `isRecipeBookError` does.
22
+
23
+ - Add `ParsedRecipe`, the same type as `Recipe` under another name. ([#924](https://github.com/SirajChokshi/recipe-book/pull/924) by [@SirajChokshi](https://github.com/SirajChokshi))
24
+
25
+ - A file that imports `@recipe-book/react` as `Recipe` can import `ParsedRecipe` from `@recipe-book/react/core` instead of renaming the type with `import type { Recipe as ParsedRecipe }`.
26
+
27
+ - `parseRecipe` and `recipeSchema` now list `duplicate_id` warnings in input order when a repeated section id follows repeated item ids in earlier sections. ([#1221](https://github.com/SirajChokshi/recipe-book/pull/1221) by [@SirajChokshi](https://github.com/SirajChokshi))
28
+
29
+ - Before, when no other issue came between them, the section's warning came before the items' warnings.
30
+
31
+ - The TSDoc for `ResolvedRecipe.servings` and `yield` now says that at a scale within 1e-9 of 1, including one the `servings` option sets, they're the authored servings and yield. ([#1368](https://github.com/SirajChokshi/recipe-book/pull/1368) by [@SirajChokshi](https://github.com/SirajChokshi))
32
+
33
+ - `segmentStepText` no longer reads a "-" right after a number with no unit of its own, or with only a degree sign, as a minus sign. ([#919](https://github.com/SirajChokshi/recipe-book/pull/919) by [@SirajChokshi](https://github.com/SirajChokshi))
34
+
35
+ - In `Bake at 350 -375°F.` and `Bake at 350° -375°F.`, it read the second end as a negative temperature, −375 °F. Such a range now stays text, as `350–375°F` does.
36
+ - After a unit, as in `350°F -375°F`, the "-" is still a minus sign.
37
+
3
38
  ## 0.1.1
4
39
 
5
40
  ### Patch Changes
@@ -17,9 +17,16 @@ var ERROR_NAMES = /* @__PURE__ */ new Set([
17
17
  ]);
18
18
  var RecipeBookError = class extends Error {
19
19
  constructor(code, message, options) {
20
- const docsUrl = `${DOCS_ORIGIN}/errors/${code}`;
20
+ const docsUrl = `${DOCS_ORIGIN}/errors/${code}/`;
21
21
  super(`${message}
22
22
  See ${docsUrl}`, options);
23
+ if ("cause" in Object(options)) {
24
+ Object.defineProperty(this, "cause", {
25
+ value: options?.cause,
26
+ writable: true,
27
+ configurable: true
28
+ });
29
+ }
23
30
  this.name = "RecipeBookError";
24
31
  this.code = code;
25
32
  this.docsUrl = docsUrl;
@@ -36,6 +43,26 @@ function isRecipeBookError(error2) {
36
43
  return false;
37
44
  }
38
45
  }
46
+ var VALIDATION_CODES = /* @__PURE__ */ new Set([
47
+ "invalid_recipe",
48
+ "invalid_quantity",
49
+ "invalid_ingredient"
50
+ ]);
51
+ function isRecipeValidationError(error2) {
52
+ if (typeof error2 !== "object" || error2 === null) {
53
+ return false;
54
+ }
55
+ try {
56
+ const {
57
+ name,
58
+ code,
59
+ issues
60
+ } = error2;
61
+ return name === "RecipeValidationError" && VALIDATION_CODES.has(code) && Array.isArray(issues);
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
39
66
  var MAX_ECHOED = 60;
40
67
  function describeValue(value) {
41
68
  if (typeof value === "string") {
@@ -1099,10 +1126,10 @@ function readList(issues, pending, value, path, noun, readItem) {
1099
1126
  const sections = [];
1100
1127
  let loose;
1101
1128
  let count2 = 0;
1102
- const read = (entry, entryPath) => readItem(issues, entry, entryPath, ++count2);
1103
- const visit = (entry, i) => {
1129
+ const read = (entry2, entryPath) => readItem(issues, entry2, entryPath, ++count2);
1130
+ const visit = (entry2, i) => {
1104
1131
  const entryPath = [...path, i];
1105
- const section = asSection(entry);
1132
+ const section = asSection(entry2);
1106
1133
  if (section) {
1107
1134
  loose = void 0;
1108
1135
  sections.push(readSection(issues, section, entryPath, noun, read));
@@ -1119,7 +1146,7 @@ function readList(issues, pending, value, path, noun, readItem) {
1119
1146
  };
1120
1147
  sections.push(loose);
1121
1148
  }
1122
- const item = read(entry, entryPath);
1149
+ const item = read(entry2, entryPath);
1123
1150
  if (item) {
1124
1151
  loose.items.push(item);
1125
1152
  }
@@ -1131,11 +1158,16 @@ function readList(issues, pending, value, path, noun, readItem) {
1131
1158
  warning(issues, "empty_list", path, `Recipe has no ${noun}.`);
1132
1159
  return [];
1133
1160
  }
1134
- const sectionIds = assignIds(sections, pending);
1161
+ const renamed = [];
1162
+ const sectionIds = assignIds(sections, renamed);
1135
1163
  const itemIds = assignIds(
1136
1164
  sections.flatMap((section) => section.items),
1137
- pending
1165
+ renamed
1138
1166
  );
1167
+ const entry = ({ issue: issue2 }) => issue2.path[path.length];
1168
+ for (const issue2 of renamed.sort((a, b) => entry(a) - entry(b))) {
1169
+ pending.push(issue2);
1170
+ }
1139
1171
  let next = 0;
1140
1172
  return sections.map(
1141
1173
  (section, i) => defined({
@@ -2726,6 +2758,7 @@ exports.hasOwn = hasOwn;
2726
2758
  exports.inSystem = inSystem;
2727
2759
  exports.isNative = isNative;
2728
2760
  exports.isRecipeBookError = isRecipeBookError;
2761
+ exports.isRecipeValidationError = isRecipeValidationError;
2729
2762
  exports.isRecord = isRecord;
2730
2763
  exports.issue = issue;
2731
2764
  exports.lookupUnit = lookupUnit;
@@ -2750,5 +2783,5 @@ exports.toResult = toResult;
2750
2783
  exports.units = units;
2751
2784
  exports.unknownUnitError = unknownUnitError;
2752
2785
  exports.warning = warning;
2753
- //# sourceMappingURL=chunk-D5CV3UF7.cjs.map
2754
- //# sourceMappingURL=chunk-D5CV3UF7.cjs.map
2786
+ //# sourceMappingURL=chunk-ISRDJR2O.cjs.map
2787
+ //# sourceMappingURL=chunk-ISRDJR2O.cjs.map