@ingredient-icons/core 0.2.0 → 0.4.0
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/README.md +89 -24
- package/dist/data.d.ts +3 -2
- package/dist/data.js +6 -5
- package/dist/index.d.ts +13 -6
- package/dist/index.js +13 -5
- package/icons/webp/128/en_balsamic-vinegar.webp +0 -0
- package/icons/webp/128/en_beef-broth.webp +0 -0
- package/icons/webp/128/en_bulgur.webp +0 -0
- package/icons/webp/128/en_camembert.webp +0 -0
- package/icons/webp/128/en_cashew-nuts.webp +0 -0
- package/icons/webp/128/en_cheese.webp +0 -0
- package/icons/webp/128/en_cherry-tomato.webp +0 -0
- package/icons/webp/128/en_chicken-fillet.webp +0 -0
- package/icons/webp/128/en_chicken-thigh.webp +0 -0
- package/icons/webp/128/en_chopped-tomato.webp +0 -0
- package/icons/webp/128/en_chorizo.webp +0 -0
- package/icons/webp/128/en_coconut.webp +0 -0
- package/icons/webp/128/en_coriander-seed.webp +0 -0
- package/icons/webp/128/en_corn.webp +0 -0
- package/icons/webp/128/en_cream-cheese.webp +0 -0
- package/icons/webp/128/en_curry-powder.webp +0 -0
- package/icons/webp/128/en_dill.webp +0 -0
- package/icons/webp/128/en_dough.webp +0 -0
- package/icons/webp/128/en_dried-thyme.webp +0 -0
- package/icons/webp/128/en_dried-tomatoes.webp +0 -0
- package/icons/webp/128/en_fish-sauce.webp +0 -0
- package/icons/webp/128/en_fish.webp +0 -0
- package/icons/webp/128/en_fruit.webp +0 -0
- package/icons/webp/128/en_green-olive.webp +0 -0
- package/icons/webp/128/en_harissa.webp +0 -0
- package/icons/webp/128/en_herb.webp +0 -0
- package/icons/webp/128/en_honey.webp +0 -0
- package/icons/webp/128/en_hummus.webp +0 -0
- package/icons/webp/128/en_kale.webp +0 -0
- package/icons/webp/128/en_ketchup.webp +0 -0
- package/icons/webp/128/en_kiwifruit.webp +0 -0
- package/icons/webp/128/en_nut.webp +0 -0
- package/icons/webp/128/en_oregano.webp +0 -0
- package/icons/webp/128/en_pak-choi.webp +0 -0
- package/icons/webp/128/en_pastry.webp +0 -0
- package/icons/webp/128/en_peanut.webp +0 -0
- package/icons/webp/128/en_pecorino.webp +0 -0
- package/icons/webp/128/en_pepper.webp +0 -0
- package/icons/webp/128/en_pesto.webp +0 -0
- package/icons/webp/128/en_pine-nuts.webp +0 -0
- package/icons/webp/128/en_pistachio-nuts.webp +0 -0
- package/icons/webp/128/en_pork.webp +0 -0
- package/icons/webp/128/en_poultry-broth.webp +0 -0
- package/icons/webp/128/en_pulse.webp +0 -0
- package/icons/webp/128/en_red-bean.webp +0 -0
- package/icons/webp/128/en_red-wine-vinegar.webp +0 -0
- package/icons/webp/128/en_rice-vinegar.webp +0 -0
- package/icons/webp/128/en_romaine-lettuce.webp +0 -0
- package/icons/webp/128/en_salad.webp +0 -0
- package/icons/webp/128/en_sauce.webp +0 -0
- package/icons/webp/128/en_sausage.webp +0 -0
- package/icons/webp/128/en_seed.webp +0 -0
- package/icons/webp/128/en_semolina.webp +0 -0
- package/icons/webp/128/en_sesame-oil.webp +0 -0
- package/icons/webp/128/en_sesame.webp +0 -0
- package/icons/webp/128/en_spice.webp +0 -0
- package/icons/webp/128/en_tortilla.webp +0 -0
- package/icons/webp/128/en_turmeric.webp +0 -0
- package/icons/webp/128/en_white-beans.webp +0 -0
- package/icons/webp/128/generic.webp +0 -0
- package/icons/webp/256/en_balsamic-vinegar.webp +0 -0
- package/icons/webp/256/en_beef-broth.webp +0 -0
- package/icons/webp/256/en_bulgur.webp +0 -0
- package/icons/webp/256/en_camembert.webp +0 -0
- package/icons/webp/256/en_cashew-nuts.webp +0 -0
- package/icons/webp/256/en_cheese.webp +0 -0
- package/icons/webp/256/en_cherry-tomato.webp +0 -0
- package/icons/webp/256/en_chicken-fillet.webp +0 -0
- package/icons/webp/256/en_chicken-thigh.webp +0 -0
- package/icons/webp/256/en_chopped-tomato.webp +0 -0
- package/icons/webp/256/en_chorizo.webp +0 -0
- package/icons/webp/256/en_coconut.webp +0 -0
- package/icons/webp/256/en_coriander-seed.webp +0 -0
- package/icons/webp/256/en_corn.webp +0 -0
- package/icons/webp/256/en_cream-cheese.webp +0 -0
- package/icons/webp/256/en_curry-powder.webp +0 -0
- package/icons/webp/256/en_dill.webp +0 -0
- package/icons/webp/256/en_dough.webp +0 -0
- package/icons/webp/256/en_dried-thyme.webp +0 -0
- package/icons/webp/256/en_dried-tomatoes.webp +0 -0
- package/icons/webp/256/en_fish-sauce.webp +0 -0
- package/icons/webp/256/en_fish.webp +0 -0
- package/icons/webp/256/en_fruit.webp +0 -0
- package/icons/webp/256/en_green-olive.webp +0 -0
- package/icons/webp/256/en_harissa.webp +0 -0
- package/icons/webp/256/en_herb.webp +0 -0
- package/icons/webp/256/en_honey.webp +0 -0
- package/icons/webp/256/en_hummus.webp +0 -0
- package/icons/webp/256/en_kale.webp +0 -0
- package/icons/webp/256/en_ketchup.webp +0 -0
- package/icons/webp/256/en_kiwifruit.webp +0 -0
- package/icons/webp/256/en_nut.webp +0 -0
- package/icons/webp/256/en_oregano.webp +0 -0
- package/icons/webp/256/en_pak-choi.webp +0 -0
- package/icons/webp/256/en_pastry.webp +0 -0
- package/icons/webp/256/en_peanut.webp +0 -0
- package/icons/webp/256/en_pecorino.webp +0 -0
- package/icons/webp/256/en_pepper.webp +0 -0
- package/icons/webp/256/en_pesto.webp +0 -0
- package/icons/webp/256/en_pine-nuts.webp +0 -0
- package/icons/webp/256/en_pistachio-nuts.webp +0 -0
- package/icons/webp/256/en_pork.webp +0 -0
- package/icons/webp/256/en_poultry-broth.webp +0 -0
- package/icons/webp/256/en_pulse.webp +0 -0
- package/icons/webp/256/en_red-bean.webp +0 -0
- package/icons/webp/256/en_red-wine-vinegar.webp +0 -0
- package/icons/webp/256/en_rice-vinegar.webp +0 -0
- package/icons/webp/256/en_romaine-lettuce.webp +0 -0
- package/icons/webp/256/en_salad.webp +0 -0
- package/icons/webp/256/en_sauce.webp +0 -0
- package/icons/webp/256/en_sausage.webp +0 -0
- package/icons/webp/256/en_seed.webp +0 -0
- package/icons/webp/256/en_semolina.webp +0 -0
- package/icons/webp/256/en_sesame-oil.webp +0 -0
- package/icons/webp/256/en_sesame.webp +0 -0
- package/icons/webp/256/en_spice.webp +0 -0
- package/icons/webp/256/en_tortilla.webp +0 -0
- package/icons/webp/256/en_turmeric.webp +0 -0
- package/icons/webp/256/en_white-beans.webp +0 -0
- package/icons/webp/256/generic.webp +0 -0
- package/icons/webp/64/en_balsamic-vinegar.webp +0 -0
- package/icons/webp/64/en_beef-broth.webp +0 -0
- package/icons/webp/64/en_bulgur.webp +0 -0
- package/icons/webp/64/en_camembert.webp +0 -0
- package/icons/webp/64/en_cashew-nuts.webp +0 -0
- package/icons/webp/64/en_cheese.webp +0 -0
- package/icons/webp/64/en_cherry-tomato.webp +0 -0
- package/icons/webp/64/en_chicken-fillet.webp +0 -0
- package/icons/webp/64/en_chicken-thigh.webp +0 -0
- package/icons/webp/64/en_chopped-tomato.webp +0 -0
- package/icons/webp/64/en_chorizo.webp +0 -0
- package/icons/webp/64/en_coconut.webp +0 -0
- package/icons/webp/64/en_coriander-seed.webp +0 -0
- package/icons/webp/64/en_corn.webp +0 -0
- package/icons/webp/64/en_cream-cheese.webp +0 -0
- package/icons/webp/64/en_curry-powder.webp +0 -0
- package/icons/webp/64/en_dill.webp +0 -0
- package/icons/webp/64/en_dough.webp +0 -0
- package/icons/webp/64/en_dried-thyme.webp +0 -0
- package/icons/webp/64/en_dried-tomatoes.webp +0 -0
- package/icons/webp/64/en_fish-sauce.webp +0 -0
- package/icons/webp/64/en_fish.webp +0 -0
- package/icons/webp/64/en_fruit.webp +0 -0
- package/icons/webp/64/en_green-olive.webp +0 -0
- package/icons/webp/64/en_harissa.webp +0 -0
- package/icons/webp/64/en_herb.webp +0 -0
- package/icons/webp/64/en_honey.webp +0 -0
- package/icons/webp/64/en_hummus.webp +0 -0
- package/icons/webp/64/en_kale.webp +0 -0
- package/icons/webp/64/en_ketchup.webp +0 -0
- package/icons/webp/64/en_kiwifruit.webp +0 -0
- package/icons/webp/64/en_nut.webp +0 -0
- package/icons/webp/64/en_oregano.webp +0 -0
- package/icons/webp/64/en_pak-choi.webp +0 -0
- package/icons/webp/64/en_pastry.webp +0 -0
- package/icons/webp/64/en_peanut.webp +0 -0
- package/icons/webp/64/en_pecorino.webp +0 -0
- package/icons/webp/64/en_pepper.webp +0 -0
- package/icons/webp/64/en_pesto.webp +0 -0
- package/icons/webp/64/en_pine-nuts.webp +0 -0
- package/icons/webp/64/en_pistachio-nuts.webp +0 -0
- package/icons/webp/64/en_pork.webp +0 -0
- package/icons/webp/64/en_poultry-broth.webp +0 -0
- package/icons/webp/64/en_pulse.webp +0 -0
- package/icons/webp/64/en_red-bean.webp +0 -0
- package/icons/webp/64/en_red-wine-vinegar.webp +0 -0
- package/icons/webp/64/en_rice-vinegar.webp +0 -0
- package/icons/webp/64/en_romaine-lettuce.webp +0 -0
- package/icons/webp/64/en_salad.webp +0 -0
- package/icons/webp/64/en_sauce.webp +0 -0
- package/icons/webp/64/en_sausage.webp +0 -0
- package/icons/webp/64/en_seed.webp +0 -0
- package/icons/webp/64/en_semolina.webp +0 -0
- package/icons/webp/64/en_sesame-oil.webp +0 -0
- package/icons/webp/64/en_sesame.webp +0 -0
- package/icons/webp/64/en_spice.webp +0 -0
- package/icons/webp/64/en_tortilla.webp +0 -0
- package/icons/webp/64/en_turmeric.webp +0 -0
- package/icons/webp/64/en_white-beans.webp +0 -0
- package/icons/webp/64/generic.webp +0 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import { SIZES } from "./data.js";
|
|
2
|
-
export { STYLE, TAXONOMY_COMMIT, VERSION } from "./data.js";
|
|
2
|
+
export { STYLE, TAXONOMY_COMMIT, TAXONOMY_RELEASE, VERSION } from "./data.js";
|
|
3
3
|
/** Sizes shipped in the package, in pixels, as square WebP files. */
|
|
4
4
|
export type IconSize = (typeof SIZES)[number];
|
|
5
5
|
export declare const sizes: readonly IconSize[];
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Id of the generic icon: a cluster of fresh ingredients, for an ingredient that cannot be placed
|
|
8
|
+
* at all. Not an Open Food Facts id. Show it when `findIcon` returns undefined:
|
|
9
|
+
* `iconUrl(id) ?? iconUrl(GENERIC_ID)`.
|
|
10
|
+
*/
|
|
11
|
+
export declare const GENERIC_ID = "generic";
|
|
12
|
+
/** Every id that has its own icon: Open Food Facts ids, plus `GENERIC_ID`. */
|
|
7
13
|
export declare const ids: readonly string[];
|
|
8
14
|
export interface Icon {
|
|
9
15
|
/** The id whose icon this is: the one asked for, or the closest ancestor that has one. */
|
|
10
16
|
id: string;
|
|
11
17
|
/** File name without extension: "en_shallot". */
|
|
12
18
|
file: string;
|
|
13
|
-
/** False when the icon is an ancestor's:
|
|
19
|
+
/** False when the icon is an ancestor's: peeled tomatoes get the tomato. */
|
|
14
20
|
exact: boolean;
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
23
|
* The icon of an Open Food Facts ingredient id ("en:shallot"), or of its closest
|
|
18
|
-
* ancestor in the taxonomy when it has none of its own.
|
|
24
|
+
* ancestor in the taxonomy when it has none of its own. Undefined when neither has one:
|
|
25
|
+
* the caller picks the fallback, such as the generic icon (`GENERIC_ID`).
|
|
19
26
|
*/
|
|
20
27
|
export declare function findIcon(id: string): Icon | undefined;
|
|
21
28
|
/** Path of an icon inside the package: "icons/webp/128/en_shallot.webp". */
|
|
22
29
|
export declare function iconPath(id: string, size?: IconSize): string | undefined;
|
|
23
30
|
/** Default CDN, pinned to this package's version so URLs never change under you. */
|
|
24
|
-
export declare const CDN_URL = "https://cdn.jsdelivr.net/npm/@ingredient-icons/core@0.
|
|
31
|
+
export declare const CDN_URL = "https://cdn.jsdelivr.net/npm/@ingredient-icons/core@0.4.0";
|
|
25
32
|
/**
|
|
26
33
|
* URL of an icon. Pass `baseUrl` to serve the package's `icons/` folder yourself
|
|
27
34
|
* instead of the public CDN.
|
|
@@ -30,5 +37,5 @@ export declare function iconUrl(id: string, { size, baseUrl }?: {
|
|
|
30
37
|
size?: IconSize;
|
|
31
38
|
baseUrl?: string;
|
|
32
39
|
}): string | undefined;
|
|
33
|
-
/** Name of an id that has an icon, from the Open Food Facts taxonomy. */
|
|
40
|
+
/** Name of an id that has an icon, from the Open Food Facts taxonomy ("Ingredient" for `GENERIC_ID`). */
|
|
34
41
|
export declare function iconName(id: string, locale?: "en" | "fr"): string | undefined;
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { FILES, NAMES, PARENTS, SIZES, VERSION } from "./data.js";
|
|
2
|
-
export { STYLE, TAXONOMY_COMMIT, VERSION } from "./data.js";
|
|
2
|
+
export { STYLE, TAXONOMY_COMMIT, TAXONOMY_RELEASE, VERSION } from "./data.js";
|
|
3
3
|
export const sizes = SIZES;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Id of the generic icon: a cluster of fresh ingredients, for an ingredient that cannot be placed
|
|
6
|
+
* at all. Not an Open Food Facts id. Show it when `findIcon` returns undefined:
|
|
7
|
+
* `iconUrl(id) ?? iconUrl(GENERIC_ID)`.
|
|
8
|
+
*/
|
|
9
|
+
export const GENERIC_ID = "generic";
|
|
10
|
+
/** Every id that has its own icon: Open Food Facts ids, plus `GENERIC_ID`. */
|
|
5
11
|
export const ids = Object.keys(FILES);
|
|
6
12
|
const MAX_DEPTH = 6;
|
|
7
13
|
/**
|
|
8
14
|
* The icon of an Open Food Facts ingredient id ("en:shallot"), or of its closest
|
|
9
|
-
* ancestor in the taxonomy when it has none of its own.
|
|
15
|
+
* ancestor in the taxonomy when it has none of its own. Undefined when neither has one:
|
|
16
|
+
* the caller picks the fallback, such as the generic icon (`GENERIC_ID`).
|
|
10
17
|
*/
|
|
11
18
|
export function findIcon(id) {
|
|
12
19
|
let level = [id];
|
|
@@ -43,7 +50,8 @@ export function iconUrl(id, { size = 128, baseUrl = CDN_URL } = {}) {
|
|
|
43
50
|
const relative = iconPath(id, size);
|
|
44
51
|
return relative && `${baseUrl.replace(/\/$/, "")}/${relative}`;
|
|
45
52
|
}
|
|
46
|
-
|
|
53
|
+
const GENERIC_NAMES = { en: "Ingredient", fr: "Ingrédient" };
|
|
54
|
+
/** Name of an id that has an icon, from the Open Food Facts taxonomy ("Ingredient" for `GENERIC_ID`). */
|
|
47
55
|
export function iconName(id, locale = "en") {
|
|
48
|
-
return NAMES[id]?.[locale];
|
|
56
|
+
return id === GENERIC_ID ? GENERIC_NAMES[locale] : NAMES[id]?.[locale];
|
|
49
57
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ingredient-icons/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Soft 3D icons for cooking ingredients, keyed by the Open Food Facts taxonomy, with ancestor fallback",
|
|
5
5
|
"license": "(MIT AND CC0-1.0 AND ODbL-1.0)",
|
|
6
6
|
"type": "module",
|