@recipe-book/core 0.0.3 → 0.1.1
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/CHANGELOG.md +116 -0
- package/LICENSE +21 -0
- package/README.md +50 -7
- package/dist/chunk-D5CV3UF7.cjs +2754 -0
- package/dist/chunk-D5CV3UF7.cjs.map +1 -0
- package/dist/errors.js +76 -0
- package/dist/errors.js.map +1 -0
- package/dist/format/duration.js +36 -0
- package/dist/format/duration.js.map +1 -0
- package/dist/format/ingredient.js +49 -0
- package/dist/format/ingredient.js.map +1 -0
- package/dist/format/number.js +120 -0
- package/dist/format/number.js.map +1 -0
- package/dist/format/options.js +31 -0
- package/dist/format/options.js.map +1 -0
- package/dist/format/quantity.js +144 -0
- package/dist/format/quantity.js.map +1 -0
- package/dist/format/servings.js +68 -0
- package/dist/format/servings.js.map +1 -0
- package/dist/format/temperature.js +35 -0
- package/dist/format/temperature.js.map +1 -0
- package/dist/index.cjs +476 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +994 -0
- package/dist/index.d.ts +994 -5
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -0
- package/dist/ingredient/parse.js +412 -0
- package/dist/ingredient/parse.js.map +1 -0
- package/dist/issues.js +26 -0
- package/dist/issues.js.map +1 -0
- package/dist/quantity/amount.js +78 -0
- package/dist/quantity/amount.js.map +1 -0
- package/dist/quantity/parse.js +255 -0
- package/dist/quantity/parse.js.map +1 -0
- package/dist/quantity/scale.js +23 -0
- package/dist/quantity/scale.js.map +1 -0
- package/dist/recipe/duration.js +28 -0
- package/dist/recipe/duration.js.map +1 -0
- package/dist/recipe/ids.js +68 -0
- package/dist/recipe/ids.js.map +1 -0
- package/dist/recipe/infer.js +24 -0
- package/dist/recipe/infer.js.map +1 -0
- package/dist/recipe/nutrient-units.js +18 -0
- package/dist/recipe/nutrient-units.js.map +1 -0
- package/dist/recipe/nutrition.js +26 -0
- package/dist/recipe/nutrition.js.map +1 -0
- package/dist/recipe/parse.js +854 -0
- package/dist/recipe/parse.js.map +1 -0
- package/dist/recipe/schema.js +32 -0
- package/dist/recipe/schema.js.map +1 -0
- package/dist/recipe/url.js +9 -0
- package/dist/recipe/url.js.map +1 -0
- package/dist/resolve.js +120 -0
- package/dist/resolve.js.map +1 -0
- package/dist/schema-org/find.js +158 -0
- package/dist/schema-org/find.js.map +1 -0
- package/dist/schema-org/from-json-ld.js +647 -0
- package/dist/schema-org/from-json-ld.js.map +1 -0
- package/dist/schema-org/nutrients.js +19 -0
- package/dist/schema-org/nutrients.js.map +1 -0
- package/dist/schema-org/text.js +125 -0
- package/dist/schema-org/text.js.map +1 -0
- package/dist/schema-org/to-json-ld.js +151 -0
- package/dist/schema-org/to-json-ld.js.map +1 -0
- package/dist/schema-org.cjs +1062 -0
- package/dist/schema-org.cjs.map +1 -0
- package/dist/schema-org.d.cts +223 -0
- package/dist/schema-org.d.ts +223 -0
- package/dist/schema-org.js +10 -0
- package/dist/schema-org.js.map +1 -0
- package/dist/steps/segment.js +45 -0
- package/dist/steps/segment.js.map +1 -0
- package/dist/steps/temperature.js +174 -0
- package/dist/steps/temperature.js.map +1 -0
- package/dist/suggest.js +50 -0
- package/dist/suggest.js.map +1 -0
- package/dist/types-BknM8KOd.d.cts +628 -0
- package/dist/types-BknM8KOd.d.ts +628 -0
- package/dist/units/convert.js +79 -0
- package/dist/units/convert.js.map +1 -0
- package/dist/units/lookup.js +86 -0
- package/dist/units/lookup.js.map +1 -0
- package/dist/units/registry.js +183 -0
- package/dist/units/registry.js.map +1 -0
- package/dist/units/system.js +91 -0
- package/dist/units/system.js.map +1 -0
- package/dist/units/temperature.js +40 -0
- package/dist/units/temperature.js.map +1 -0
- package/dist/validation.js +90 -0
- package/dist/validation.js.map +1 -0
- package/package.json +53 -8
- package/schema-org/package.json +5 -0
- package/dist/chunk-22RBQQWH.mjs +0 -1
- package/dist/chunk-3CSP4UZG.mjs +0 -1
- package/dist/chunk-3FFMHRB7.mjs +0 -26
- package/dist/chunk-4EB3HG6B.mjs +0 -50
- package/dist/chunk-4EHNJLGI.mjs +0 -50
- package/dist/chunk-4IA5EEKI.mjs +0 -81
- package/dist/chunk-4TATADPT.mjs +0 -51
- package/dist/chunk-6GI5KLI4.mjs +0 -22
- package/dist/chunk-6QJZOZ6W.mjs +0 -49
- package/dist/chunk-6YYQ4RYZ.mjs +0 -26
- package/dist/chunk-7BBUDI2L.mjs +0 -0
- package/dist/chunk-7KEMNCV7.mjs +0 -26
- package/dist/chunk-7MMJZZ7Z.mjs +0 -75
- package/dist/chunk-BES4V7DM.mjs +0 -26
- package/dist/chunk-BRDXRIAH.mjs +0 -50
- package/dist/chunk-C45UD45A.mjs +0 -1
- package/dist/chunk-CBLJXA6P.mjs +0 -1
- package/dist/chunk-CFR2ZBPB.mjs +0 -77
- package/dist/chunk-DYMNVFL2.mjs +0 -78
- package/dist/chunk-F6AQKXJU.mjs +0 -51
- package/dist/chunk-FW4M2R43.mjs +0 -51
- package/dist/chunk-GCCEDUST.mjs +0 -75
- package/dist/chunk-GE7KBYZR.mjs +0 -26
- package/dist/chunk-GN7ZDGYC.mjs +0 -51
- package/dist/chunk-GOO2SCQX.mjs +0 -75
- package/dist/chunk-HAVKBQLH.mjs +0 -51
- package/dist/chunk-HCBIPANU.mjs +0 -50
- package/dist/chunk-IEBAGBS7.mjs +0 -51
- package/dist/chunk-IQ6WN2V4.mjs +0 -75
- package/dist/chunk-JB4Z2FR7.mjs +0 -77
- package/dist/chunk-JMTQOTBM.mjs +0 -75
- package/dist/chunk-JRO6JUES.mjs +0 -51
- package/dist/chunk-KH3SRXET.mjs +0 -52
- package/dist/chunk-KNZMCAQZ.mjs +0 -51
- package/dist/chunk-KXFUCO3R.mjs +0 -1
- package/dist/chunk-LEBGCVCJ.mjs +0 -75
- package/dist/chunk-MAHWFCIL.mjs +0 -51
- package/dist/chunk-MPH76SLC.mjs +0 -51
- package/dist/chunk-MQGMFBJQ.mjs +0 -26
- package/dist/chunk-NMIVG7T4.mjs +0 -6
- package/dist/chunk-Q3TT3AZ4.mjs +0 -26
- package/dist/chunk-QY5HJQIL.mjs +0 -51
- package/dist/chunk-RCPLSNKM.mjs +0 -1
- package/dist/chunk-SR2KFBT3.mjs +0 -1
- package/dist/chunk-ULDLBAEG.mjs +0 -1
- package/dist/chunk-UQ3EUYFR.mjs +0 -1
- package/dist/chunk-V26OCCTL.mjs +0 -82
- package/dist/chunk-WBQAMGXK.mjs +0 -0
- package/dist/chunk-WSW6FMUL.mjs +0 -51
- package/dist/chunk-WU55SBIV.mjs +0 -75
- package/dist/chunk-XINK45P3.mjs +0 -51
- package/dist/chunk-XNOHIWI3.mjs +0 -1
- package/dist/chunk-XV4QN4LA.mjs +0 -6
- package/dist/chunk-YHBXEVUX.mjs +0 -51
- package/dist/chunk-YSZSCEI7.mjs +0 -75
- package/dist/chunk-YY3SUQ7P.mjs +0 -16
- package/dist/chunk-YZB3IG47.mjs +0 -80
- package/dist/chunk-ZPZT4LMQ.mjs +0 -25
- package/dist/const/conversion.d.mts +0 -7
- package/dist/const/conversion.d.ts +0 -7
- package/dist/const/conversion.js +0 -1
- package/dist/const/conversion.mjs +0 -1
- package/dist/const/unit.d.mts +0 -119
- package/dist/const/unit.d.ts +0 -119
- package/dist/const/unit.js +0 -1
- package/dist/const/unit.mjs +0 -1
- package/dist/index.d.mts +0 -5
- package/dist/index.mjs +0 -1
- package/dist/lib/assert.d.mts +0 -18
- package/dist/lib/assert.d.ts +0 -18
- package/dist/lib/assert.js +0 -1
- package/dist/lib/assert.mjs +0 -1
- package/dist/lib/ingredient.d.mts +0 -9
- package/dist/lib/ingredient.d.ts +0 -9
- package/dist/lib/ingredient.js +0 -1
- package/dist/lib/ingredient.mjs +0 -1
- package/dist/lib/recipe.d.mts +0 -12
- package/dist/lib/recipe.d.ts +0 -12
- package/dist/lib/recipe.js +0 -1
- package/dist/lib/recipe.mjs +0 -1
- package/dist/lib/runtime.d.mts +0 -3
- package/dist/lib/runtime.d.ts +0 -3
- package/dist/lib/runtime.js +0 -1
- package/dist/lib/runtime.mjs +0 -1
- package/dist/lib/unit.d.mts +0 -19
- package/dist/lib/unit.d.ts +0 -19
- package/dist/lib/unit.js +0 -1
- package/dist/lib/unit.mjs +0 -1
- package/dist/types.d.mts +0 -36
- package/dist/types.d.ts +0 -36
- package/dist/types.js +0 -1
- package/dist/types.mjs +0 -1
package/dist/chunk-CFR2ZBPB.mjs
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
warn
|
|
3
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
IS_DEV
|
|
6
|
-
} from "./chunk-XV4QN4LA.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/recipe.ts
|
|
9
|
-
var RecipeUtilsImpl = class {
|
|
10
|
-
scopedMessageFactory(recipe) {
|
|
11
|
-
return (message) => `${recipe.name}: ${message}`;
|
|
12
|
-
}
|
|
13
|
-
validateConfig(config) {
|
|
14
|
-
if (!IS_DEV) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const msg = this.scopedMessageFactory(config);
|
|
18
|
-
warn(
|
|
19
|
-
config.instructions,
|
|
20
|
-
(instructions) => instructions.length > 0,
|
|
21
|
-
msg("Recipe has no instructions")
|
|
22
|
-
);
|
|
23
|
-
warn(
|
|
24
|
-
config.serves,
|
|
25
|
-
(serves) => serves === void 0 || serves > 0,
|
|
26
|
-
msg("Recipe serves less than 1 person")
|
|
27
|
-
);
|
|
28
|
-
warn(
|
|
29
|
-
config.ingredients,
|
|
30
|
-
(ingredients) => ingredients.length > 0,
|
|
31
|
-
msg("Recipe has no ingredients")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
determineMeasurementSystem(config) {
|
|
35
|
-
const { ingredients } = config;
|
|
36
|
-
const hasMetric = ingredients.some(
|
|
37
|
-
(ingredient) => {
|
|
38
|
-
var _a;
|
|
39
|
-
return (_a = ingredient.conversion) == null ? void 0 : _a.metric;
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
const hasImperial = ingredients.some(
|
|
43
|
-
(ingredient) => {
|
|
44
|
-
var _a;
|
|
45
|
-
return (_a = ingredient.conversion) == null ? void 0 : _a["us-customary"];
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
if (hasMetric && hasImperial) {
|
|
49
|
-
return void 0;
|
|
50
|
-
}
|
|
51
|
-
if (hasMetric) {
|
|
52
|
-
return "metric";
|
|
53
|
-
}
|
|
54
|
-
if (hasImperial) {
|
|
55
|
-
return "us-customary";
|
|
56
|
-
}
|
|
57
|
-
return void 0;
|
|
58
|
-
}
|
|
59
|
-
create(config) {
|
|
60
|
-
this.validateConfig(config);
|
|
61
|
-
return {
|
|
62
|
-
name: config.name,
|
|
63
|
-
ingredients: config.ingredients,
|
|
64
|
-
// optional
|
|
65
|
-
thumbnail: config.thumbnail,
|
|
66
|
-
serves: config.serves ?? 1,
|
|
67
|
-
instructions: config.instructions ?? [],
|
|
68
|
-
// computed
|
|
69
|
-
measurements: this.determineMeasurementSystem(config)
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
var RecipeUtils = new RecipeUtilsImpl();
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
RecipeUtils
|
|
77
|
-
};
|
package/dist/chunk-DYMNVFL2.mjs
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
warn
|
|
3
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
IS_DEV
|
|
6
|
-
} from "./chunk-XV4QN4LA.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/recipe.ts
|
|
9
|
-
var RecipeUtilsImpl = class {
|
|
10
|
-
scopedMessageFactory(recipe) {
|
|
11
|
-
return (message) => `${recipe.name}: ${message}`;
|
|
12
|
-
}
|
|
13
|
-
validateConfig(config) {
|
|
14
|
-
if (!IS_DEV) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const msg = this.scopedMessageFactory(config);
|
|
18
|
-
warn(
|
|
19
|
-
config.instructions,
|
|
20
|
-
(instructions) => instructions.length > 0,
|
|
21
|
-
msg("Recipe has no instructions")
|
|
22
|
-
);
|
|
23
|
-
warn(
|
|
24
|
-
config.serves,
|
|
25
|
-
(serves) => serves === void 0 || serves > 0,
|
|
26
|
-
msg("Recipe serves less than 1 person")
|
|
27
|
-
);
|
|
28
|
-
warn(
|
|
29
|
-
config.ingredients,
|
|
30
|
-
(ingredients) => ingredients.length > 0,
|
|
31
|
-
msg("Recipe has no ingredients")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
determineMeasurementSystem(config) {
|
|
35
|
-
const { ingredients } = config;
|
|
36
|
-
const hasMetric = ingredients.some(
|
|
37
|
-
(ingredient) => ingredient.amount.unit === "g"
|
|
38
|
-
);
|
|
39
|
-
const hasImperial = ingredients.some(
|
|
40
|
-
(ingredient) => {
|
|
41
|
-
var _a;
|
|
42
|
-
return (_a = ingredient.conversion) == null ? void 0 : _a["us-customary"];
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
if (hasMetric && hasImperial) {
|
|
46
|
-
return void 0;
|
|
47
|
-
}
|
|
48
|
-
if (hasMetric) {
|
|
49
|
-
return "metric";
|
|
50
|
-
}
|
|
51
|
-
if (hasImperial) {
|
|
52
|
-
return "us-customary";
|
|
53
|
-
}
|
|
54
|
-
return void 0;
|
|
55
|
-
}
|
|
56
|
-
create(config) {
|
|
57
|
-
this.validateConfig(config);
|
|
58
|
-
return {
|
|
59
|
-
name: config.name,
|
|
60
|
-
ingredients: config.ingredients,
|
|
61
|
-
// optional
|
|
62
|
-
thumbnail: config.thumbnail,
|
|
63
|
-
serves: config.serves ?? 1,
|
|
64
|
-
instructions: config.instructions ?? [],
|
|
65
|
-
// computed
|
|
66
|
-
measurements: (
|
|
67
|
-
// if the user has specified a measurement system, use that
|
|
68
|
-
// otherwise, determine the measurement system based on the ingredients
|
|
69
|
-
config.measurements ?? this.determineMeasurementSystem(config)
|
|
70
|
-
)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var RecipeUtils = new RecipeUtilsImpl();
|
|
75
|
-
|
|
76
|
-
export {
|
|
77
|
-
RecipeUtils
|
|
78
|
-
};
|
package/dist/chunk-F6AQKXJU.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
warn
|
|
3
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
IS_DEV
|
|
6
|
-
} from "./chunk-XV4QN4LA.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/recipe.ts
|
|
9
|
-
var RecipeUtilsImpl = class {
|
|
10
|
-
scopedMessageFactory(recipe) {
|
|
11
|
-
return (message) => `${recipe.name}: ${message}`;
|
|
12
|
-
}
|
|
13
|
-
validateConfig(config) {
|
|
14
|
-
if (!IS_DEV) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const msg = this.scopedMessageFactory(config);
|
|
18
|
-
warn(
|
|
19
|
-
config.instructions,
|
|
20
|
-
(instructions) => instructions.length > 0,
|
|
21
|
-
msg("Recipe has no instructions")
|
|
22
|
-
);
|
|
23
|
-
warn(
|
|
24
|
-
config.serves,
|
|
25
|
-
(servings) => servings !== void 0 && servings <= 0,
|
|
26
|
-
msg("Recipe has less than one serving")
|
|
27
|
-
);
|
|
28
|
-
warn(
|
|
29
|
-
config.ingredients,
|
|
30
|
-
(ingredients) => ingredients.length > 0,
|
|
31
|
-
msg("Recipe has no ingredients")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
create(config) {
|
|
35
|
-
this.validateConfig(config);
|
|
36
|
-
return {
|
|
37
|
-
name: config.name,
|
|
38
|
-
ingredients: config.ingredients,
|
|
39
|
-
units: config.units,
|
|
40
|
-
// optional
|
|
41
|
-
thumbnail: config.thumbnail,
|
|
42
|
-
servings: config.servings ?? 1,
|
|
43
|
-
instructions: config.instructions ?? []
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var RecipeUtils = new RecipeUtilsImpl();
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
RecipeUtils
|
|
51
|
-
};
|
package/dist/chunk-FW4M2R43.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
VOLUME_CONVERSION_TABLE,
|
|
3
|
-
WEIGHT_CONVERSION_TABLE
|
|
4
|
-
} from "./chunk-V26OCCTL.mjs";
|
|
5
|
-
import {
|
|
6
|
-
UNITS
|
|
7
|
-
} from "./chunk-YZB3IG47.mjs";
|
|
8
|
-
import {
|
|
9
|
-
assert
|
|
10
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
11
|
-
|
|
12
|
-
// src/lib/unit.ts
|
|
13
|
-
var UnitUtilsImpl = class {
|
|
14
|
-
getUnit(unit) {
|
|
15
|
-
const match = UNITS.find((u) => u.abbreviation === unit || u.name === unit);
|
|
16
|
-
assert(match, (match2) => !!match2, `No unit found for key: ${unit}`);
|
|
17
|
-
return match;
|
|
18
|
-
}
|
|
19
|
-
getConversionRatio(from, to) {
|
|
20
|
-
const { type, abbreviation } = this.getUnit(from);
|
|
21
|
-
console.log({ type, abbreviation });
|
|
22
|
-
const conversionTable = type === "volume" ? VOLUME_CONVERSION_TABLE : WEIGHT_CONVERSION_TABLE;
|
|
23
|
-
const lookupTable = conversionTable[abbreviation];
|
|
24
|
-
assert(
|
|
25
|
-
lookupTable,
|
|
26
|
-
(lookupTable2) => !!lookupTable2[to],
|
|
27
|
-
`No conversion table available for unit ${from} to ${to}`
|
|
28
|
-
);
|
|
29
|
-
return lookupTable[to];
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Converts a number from one unit to another
|
|
33
|
-
*
|
|
34
|
-
* @param amount - The amount to convert
|
|
35
|
-
* @param from - The unit to convert from
|
|
36
|
-
* @param to - The unit to convert to
|
|
37
|
-
* @returns - The converted amount
|
|
38
|
-
*/
|
|
39
|
-
convert(amount, from, to) {
|
|
40
|
-
if (from === to) {
|
|
41
|
-
return amount;
|
|
42
|
-
}
|
|
43
|
-
const ratio = this.getConversionRatio(from, to);
|
|
44
|
-
return amount * ratio;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var UnitUtils = new UnitUtilsImpl();
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
UnitUtils
|
|
51
|
-
};
|
package/dist/chunk-GCCEDUST.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
warn
|
|
3
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
IS_DEV
|
|
6
|
-
} from "./chunk-XV4QN4LA.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/recipe.ts
|
|
9
|
-
var RecipeUtilsImpl = class {
|
|
10
|
-
scopedMessageFactory(recipe) {
|
|
11
|
-
return (message) => `${recipe.name}: ${message}`;
|
|
12
|
-
}
|
|
13
|
-
validateConfig(config) {
|
|
14
|
-
if (!IS_DEV) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const msg = this.scopedMessageFactory(config);
|
|
18
|
-
warn(
|
|
19
|
-
config.instructions,
|
|
20
|
-
(instructions) => instructions.length > 0,
|
|
21
|
-
msg("Recipe has no instructions")
|
|
22
|
-
);
|
|
23
|
-
warn(
|
|
24
|
-
config.serves,
|
|
25
|
-
(serves) => serves === void 0 || serves > 0,
|
|
26
|
-
msg("Recipe serves less than 1 person")
|
|
27
|
-
);
|
|
28
|
-
warn(
|
|
29
|
-
config.ingredients,
|
|
30
|
-
(ingredients) => ingredients.length > 0,
|
|
31
|
-
msg("Recipe has no ingredients")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
determineMeasurementSystem(config) {
|
|
35
|
-
const { ingredients } = config;
|
|
36
|
-
const hasMetric = ingredients.some(
|
|
37
|
-
(ingredient) => ingredient.amount.unit === "g"
|
|
38
|
-
);
|
|
39
|
-
const hasImperial = ingredients.some(
|
|
40
|
-
(ingredient) => ingredient.amount.unit === "oz" || ingredient.amount.unit === "fl oz" || ingredient.amount.unit === "lb"
|
|
41
|
-
);
|
|
42
|
-
if (hasMetric && hasImperial) {
|
|
43
|
-
return void 0;
|
|
44
|
-
}
|
|
45
|
-
if (hasMetric) {
|
|
46
|
-
return "metric";
|
|
47
|
-
}
|
|
48
|
-
if (hasImperial) {
|
|
49
|
-
return "us-customary";
|
|
50
|
-
}
|
|
51
|
-
return void 0;
|
|
52
|
-
}
|
|
53
|
-
create(config) {
|
|
54
|
-
this.validateConfig(config);
|
|
55
|
-
return {
|
|
56
|
-
name: config.name,
|
|
57
|
-
ingredients: config.ingredients,
|
|
58
|
-
// optional
|
|
59
|
-
thumbnail: config.thumbnail,
|
|
60
|
-
serves: config.serves ?? 1,
|
|
61
|
-
instructions: config.instructions ?? [],
|
|
62
|
-
// computed
|
|
63
|
-
measurements: (
|
|
64
|
-
// if the user has specified a measurement system, use that
|
|
65
|
-
// otherwise, determine the measurement system based on the ingredients
|
|
66
|
-
config.measurements ?? this.determineMeasurementSystem(config)
|
|
67
|
-
)
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var RecipeUtils = new RecipeUtilsImpl();
|
|
72
|
-
|
|
73
|
-
export {
|
|
74
|
-
RecipeUtils
|
|
75
|
-
};
|
package/dist/chunk-GE7KBYZR.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UnitUtils
|
|
3
|
-
} from "./chunk-4EHNJLGI.mjs";
|
|
4
|
-
|
|
5
|
-
// src/lib/ingredient.ts
|
|
6
|
-
var IngredientUtilsImpl = class {
|
|
7
|
-
convert(ingredient, to) {
|
|
8
|
-
const amount = UnitUtils.convert(
|
|
9
|
-
ingredient.amount.value,
|
|
10
|
-
ingredient.amount.unit,
|
|
11
|
-
to
|
|
12
|
-
);
|
|
13
|
-
return {
|
|
14
|
-
...ingredient,
|
|
15
|
-
amount: {
|
|
16
|
-
value: amount,
|
|
17
|
-
unit: to
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
var IngredientUtils = new IngredientUtilsImpl();
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
IngredientUtils
|
|
26
|
-
};
|
package/dist/chunk-GN7ZDGYC.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
VOLUME_CONVERSION_TABLE,
|
|
3
|
-
WEIGHT_CONVERSION_TABLE
|
|
4
|
-
} from "./chunk-V26OCCTL.mjs";
|
|
5
|
-
import {
|
|
6
|
-
UNITS
|
|
7
|
-
} from "./chunk-YZB3IG47.mjs";
|
|
8
|
-
import {
|
|
9
|
-
assert
|
|
10
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
11
|
-
|
|
12
|
-
// src/lib/unit.ts
|
|
13
|
-
var UnitUtilsImpl = class {
|
|
14
|
-
getUnit(unit) {
|
|
15
|
-
const match = UNITS.find((u) => u.abbreviation === unit || u.name === unit);
|
|
16
|
-
assert(match, (match2) => !!match2, `No unit found for key: ${unit}`);
|
|
17
|
-
return match;
|
|
18
|
-
}
|
|
19
|
-
getConversionRatio(from, to) {
|
|
20
|
-
const { type, abbreviation } = this.getUnit(from);
|
|
21
|
-
const conversionTable = type === "volume" ? VOLUME_CONVERSION_TABLE : WEIGHT_CONVERSION_TABLE;
|
|
22
|
-
const lookupTable = conversionTable[abbreviation];
|
|
23
|
-
const toUnit = to === "metric" ? type === "volume" ? "L" : "g" : to;
|
|
24
|
-
assert(
|
|
25
|
-
lookupTable,
|
|
26
|
-
(lookupTable2) => !!lookupTable2[toUnit],
|
|
27
|
-
`No conversion table available for unit ${from} to ${to}`
|
|
28
|
-
);
|
|
29
|
-
return lookupTable[to];
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Converts a number from one unit to another
|
|
33
|
-
*
|
|
34
|
-
* @param amount - The amount to convert
|
|
35
|
-
* @param from - The unit to convert from
|
|
36
|
-
* @param to - The unit to convert to
|
|
37
|
-
* @returns - The converted amount
|
|
38
|
-
*/
|
|
39
|
-
convert(amount, from, to) {
|
|
40
|
-
if (from === to) {
|
|
41
|
-
return amount;
|
|
42
|
-
}
|
|
43
|
-
const ratio = this.getConversionRatio(from, to);
|
|
44
|
-
return amount * ratio;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var UnitUtils = new UnitUtilsImpl();
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
UnitUtils
|
|
51
|
-
};
|
package/dist/chunk-GOO2SCQX.mjs
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
warn
|
|
3
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
IS_DEV
|
|
6
|
-
} from "./chunk-XV4QN4LA.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/recipe.ts
|
|
9
|
-
var RecipeUtilsImpl = class {
|
|
10
|
-
scopedMessageFactory(recipe) {
|
|
11
|
-
return (message) => `${recipe.name}: ${message}`;
|
|
12
|
-
}
|
|
13
|
-
validateConfig(config) {
|
|
14
|
-
if (!IS_DEV) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const msg = this.scopedMessageFactory(config);
|
|
18
|
-
warn(
|
|
19
|
-
config.instructions,
|
|
20
|
-
(instructions) => instructions.length > 0,
|
|
21
|
-
msg("Recipe has no instructions")
|
|
22
|
-
);
|
|
23
|
-
warn(
|
|
24
|
-
config.serves,
|
|
25
|
-
(serves) => serves === void 0 || serves > 0,
|
|
26
|
-
msg("Recipe serves less than 1 person")
|
|
27
|
-
);
|
|
28
|
-
warn(
|
|
29
|
-
config.ingredients,
|
|
30
|
-
(ingredients) => ingredients.length > 0,
|
|
31
|
-
msg("Recipe has no ingredients")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
determineMeasurementSystem(config) {
|
|
35
|
-
const { ingredients } = config;
|
|
36
|
-
const hasMetric = ingredients.some(
|
|
37
|
-
(ingredient) => ingredient.amount.unit === "g"
|
|
38
|
-
);
|
|
39
|
-
const hasImperial = ingredients.some(
|
|
40
|
-
(ingredient) => ingredient.amount.unit === "oz" || ingredient.amount.unit === "fl oz"
|
|
41
|
-
);
|
|
42
|
-
if (hasMetric && hasImperial) {
|
|
43
|
-
return void 0;
|
|
44
|
-
}
|
|
45
|
-
if (hasMetric) {
|
|
46
|
-
return "metric";
|
|
47
|
-
}
|
|
48
|
-
if (hasImperial) {
|
|
49
|
-
return "us-customary";
|
|
50
|
-
}
|
|
51
|
-
return void 0;
|
|
52
|
-
}
|
|
53
|
-
create(config) {
|
|
54
|
-
this.validateConfig(config);
|
|
55
|
-
return {
|
|
56
|
-
name: config.name,
|
|
57
|
-
ingredients: config.ingredients,
|
|
58
|
-
// optional
|
|
59
|
-
thumbnail: config.thumbnail,
|
|
60
|
-
serves: config.serves ?? 1,
|
|
61
|
-
instructions: config.instructions ?? [],
|
|
62
|
-
// computed
|
|
63
|
-
measurements: (
|
|
64
|
-
// if the user has specified a measurement system, use that
|
|
65
|
-
// otherwise, determine the measurement system based on the ingredients
|
|
66
|
-
config.measurements ?? this.determineMeasurementSystem(config)
|
|
67
|
-
)
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var RecipeUtils = new RecipeUtilsImpl();
|
|
72
|
-
|
|
73
|
-
export {
|
|
74
|
-
RecipeUtils
|
|
75
|
-
};
|
package/dist/chunk-HAVKBQLH.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
warn
|
|
3
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
IS_DEV
|
|
6
|
-
} from "./chunk-XV4QN4LA.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/recipe.ts
|
|
9
|
-
var RecipeUtilsImpl = class {
|
|
10
|
-
scopedMessageFactory(recipe) {
|
|
11
|
-
return (message) => `${recipe.name}: ${message}`;
|
|
12
|
-
}
|
|
13
|
-
validateConfig(config) {
|
|
14
|
-
if (!IS_DEV) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const msg = this.scopedMessageFactory(config);
|
|
18
|
-
warn(
|
|
19
|
-
config.instructions,
|
|
20
|
-
(instructions) => instructions.length > 0,
|
|
21
|
-
msg("Recipe has no instructions")
|
|
22
|
-
);
|
|
23
|
-
warn(
|
|
24
|
-
config.serves,
|
|
25
|
-
(servings) => servings !== void 0 && servings <= 0,
|
|
26
|
-
msg("Recipe serves less than 1 person")
|
|
27
|
-
);
|
|
28
|
-
warn(
|
|
29
|
-
config.ingredients,
|
|
30
|
-
(ingredients) => ingredients.length > 0,
|
|
31
|
-
msg("Recipe has no ingredients")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
create(config) {
|
|
35
|
-
this.validateConfig(config);
|
|
36
|
-
return {
|
|
37
|
-
name: config.name,
|
|
38
|
-
ingredients: config.ingredients,
|
|
39
|
-
units: config.units,
|
|
40
|
-
// optional
|
|
41
|
-
thumbnail: config.thumbnail,
|
|
42
|
-
serves: config.serves ?? 1,
|
|
43
|
-
instructions: config.instructions ?? []
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var RecipeUtils = new RecipeUtilsImpl();
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
RecipeUtils
|
|
51
|
-
};
|
package/dist/chunk-HCBIPANU.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
warn
|
|
3
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
IS_DEV
|
|
6
|
-
} from "./chunk-XV4QN4LA.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/recipe.ts
|
|
9
|
-
var RecipeUtilsImpl = class {
|
|
10
|
-
scopedMessageFactory(recipe) {
|
|
11
|
-
return (message) => `${recipe.name}: ${message}`;
|
|
12
|
-
}
|
|
13
|
-
validateConfig(config) {
|
|
14
|
-
if (!IS_DEV) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const msg = this.scopedMessageFactory(config);
|
|
18
|
-
warn(
|
|
19
|
-
config.instructions,
|
|
20
|
-
(instructions) => instructions.length > 0,
|
|
21
|
-
msg("Recipe has no instructions")
|
|
22
|
-
);
|
|
23
|
-
warn(
|
|
24
|
-
config.serves,
|
|
25
|
-
(serves) => serves === void 0 || serves > 0,
|
|
26
|
-
msg("Recipe serves less than 1 person")
|
|
27
|
-
);
|
|
28
|
-
warn(
|
|
29
|
-
config.ingredients,
|
|
30
|
-
(ingredients) => ingredients.length > 0,
|
|
31
|
-
msg("Recipe has no ingredients")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
create(config) {
|
|
35
|
-
this.validateConfig(config);
|
|
36
|
-
return {
|
|
37
|
-
name: config.name,
|
|
38
|
-
ingredients: config.ingredients,
|
|
39
|
-
// optional
|
|
40
|
-
thumbnail: config.thumbnail,
|
|
41
|
-
serves: config.serves ?? 1,
|
|
42
|
-
instructions: config.instructions ?? []
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
var RecipeUtils = new RecipeUtilsImpl();
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
RecipeUtils
|
|
50
|
-
};
|
package/dist/chunk-IEBAGBS7.mjs
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
warn
|
|
3
|
-
} from "./chunk-YY3SUQ7P.mjs";
|
|
4
|
-
import {
|
|
5
|
-
IS_DEV
|
|
6
|
-
} from "./chunk-XV4QN4LA.mjs";
|
|
7
|
-
|
|
8
|
-
// src/lib/recipe.ts
|
|
9
|
-
var RecipeUtilsImpl = class {
|
|
10
|
-
static scopedMessageFactory(recipe) {
|
|
11
|
-
return (message) => `${recipe.name}: ${message}`;
|
|
12
|
-
}
|
|
13
|
-
static validateConfig(config) {
|
|
14
|
-
if (!IS_DEV) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const msg = this.scopedMessageFactory(config);
|
|
18
|
-
warn(
|
|
19
|
-
config.instructions,
|
|
20
|
-
(instructions) => instructions.length > 0,
|
|
21
|
-
msg("Recipe has no instructions")
|
|
22
|
-
);
|
|
23
|
-
warn(
|
|
24
|
-
config.servings,
|
|
25
|
-
(servings) => servings !== void 0 && servings <= 0,
|
|
26
|
-
msg("Recipe has less than one serving")
|
|
27
|
-
);
|
|
28
|
-
warn(
|
|
29
|
-
config.ingredients,
|
|
30
|
-
(ingredients) => ingredients.length > 0,
|
|
31
|
-
msg("Recipe has no ingredients")
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
static create(config) {
|
|
35
|
-
this.validateConfig(config);
|
|
36
|
-
return {
|
|
37
|
-
name: config.name,
|
|
38
|
-
ingredients: config.ingredients,
|
|
39
|
-
units: config.units,
|
|
40
|
-
// optional
|
|
41
|
-
thumbnail: config.thumbnail,
|
|
42
|
-
servings: config.servings ?? 1,
|
|
43
|
-
instructions: config.instructions ?? []
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var RecipeUtils = new RecipeUtilsImpl();
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
RecipeUtils
|
|
51
|
-
};
|