@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.
Files changed (186) hide show
  1. package/README.md +89 -24
  2. package/dist/data.d.ts +3 -2
  3. package/dist/data.js +6 -5
  4. package/dist/index.d.ts +13 -6
  5. package/dist/index.js +13 -5
  6. package/icons/webp/128/en_balsamic-vinegar.webp +0 -0
  7. package/icons/webp/128/en_beef-broth.webp +0 -0
  8. package/icons/webp/128/en_bulgur.webp +0 -0
  9. package/icons/webp/128/en_camembert.webp +0 -0
  10. package/icons/webp/128/en_cashew-nuts.webp +0 -0
  11. package/icons/webp/128/en_cheese.webp +0 -0
  12. package/icons/webp/128/en_cherry-tomato.webp +0 -0
  13. package/icons/webp/128/en_chicken-fillet.webp +0 -0
  14. package/icons/webp/128/en_chicken-thigh.webp +0 -0
  15. package/icons/webp/128/en_chopped-tomato.webp +0 -0
  16. package/icons/webp/128/en_chorizo.webp +0 -0
  17. package/icons/webp/128/en_coconut.webp +0 -0
  18. package/icons/webp/128/en_coriander-seed.webp +0 -0
  19. package/icons/webp/128/en_corn.webp +0 -0
  20. package/icons/webp/128/en_cream-cheese.webp +0 -0
  21. package/icons/webp/128/en_curry-powder.webp +0 -0
  22. package/icons/webp/128/en_dill.webp +0 -0
  23. package/icons/webp/128/en_dough.webp +0 -0
  24. package/icons/webp/128/en_dried-thyme.webp +0 -0
  25. package/icons/webp/128/en_dried-tomatoes.webp +0 -0
  26. package/icons/webp/128/en_fish-sauce.webp +0 -0
  27. package/icons/webp/128/en_fish.webp +0 -0
  28. package/icons/webp/128/en_fruit.webp +0 -0
  29. package/icons/webp/128/en_green-olive.webp +0 -0
  30. package/icons/webp/128/en_harissa.webp +0 -0
  31. package/icons/webp/128/en_herb.webp +0 -0
  32. package/icons/webp/128/en_honey.webp +0 -0
  33. package/icons/webp/128/en_hummus.webp +0 -0
  34. package/icons/webp/128/en_kale.webp +0 -0
  35. package/icons/webp/128/en_ketchup.webp +0 -0
  36. package/icons/webp/128/en_kiwifruit.webp +0 -0
  37. package/icons/webp/128/en_nut.webp +0 -0
  38. package/icons/webp/128/en_oregano.webp +0 -0
  39. package/icons/webp/128/en_pak-choi.webp +0 -0
  40. package/icons/webp/128/en_pastry.webp +0 -0
  41. package/icons/webp/128/en_peanut.webp +0 -0
  42. package/icons/webp/128/en_pecorino.webp +0 -0
  43. package/icons/webp/128/en_pepper.webp +0 -0
  44. package/icons/webp/128/en_pesto.webp +0 -0
  45. package/icons/webp/128/en_pine-nuts.webp +0 -0
  46. package/icons/webp/128/en_pistachio-nuts.webp +0 -0
  47. package/icons/webp/128/en_pork.webp +0 -0
  48. package/icons/webp/128/en_poultry-broth.webp +0 -0
  49. package/icons/webp/128/en_pulse.webp +0 -0
  50. package/icons/webp/128/en_red-bean.webp +0 -0
  51. package/icons/webp/128/en_red-wine-vinegar.webp +0 -0
  52. package/icons/webp/128/en_rice-vinegar.webp +0 -0
  53. package/icons/webp/128/en_romaine-lettuce.webp +0 -0
  54. package/icons/webp/128/en_salad.webp +0 -0
  55. package/icons/webp/128/en_sauce.webp +0 -0
  56. package/icons/webp/128/en_sausage.webp +0 -0
  57. package/icons/webp/128/en_seed.webp +0 -0
  58. package/icons/webp/128/en_semolina.webp +0 -0
  59. package/icons/webp/128/en_sesame-oil.webp +0 -0
  60. package/icons/webp/128/en_sesame.webp +0 -0
  61. package/icons/webp/128/en_spice.webp +0 -0
  62. package/icons/webp/128/en_tortilla.webp +0 -0
  63. package/icons/webp/128/en_turmeric.webp +0 -0
  64. package/icons/webp/128/en_white-beans.webp +0 -0
  65. package/icons/webp/128/generic.webp +0 -0
  66. package/icons/webp/256/en_balsamic-vinegar.webp +0 -0
  67. package/icons/webp/256/en_beef-broth.webp +0 -0
  68. package/icons/webp/256/en_bulgur.webp +0 -0
  69. package/icons/webp/256/en_camembert.webp +0 -0
  70. package/icons/webp/256/en_cashew-nuts.webp +0 -0
  71. package/icons/webp/256/en_cheese.webp +0 -0
  72. package/icons/webp/256/en_cherry-tomato.webp +0 -0
  73. package/icons/webp/256/en_chicken-fillet.webp +0 -0
  74. package/icons/webp/256/en_chicken-thigh.webp +0 -0
  75. package/icons/webp/256/en_chopped-tomato.webp +0 -0
  76. package/icons/webp/256/en_chorizo.webp +0 -0
  77. package/icons/webp/256/en_coconut.webp +0 -0
  78. package/icons/webp/256/en_coriander-seed.webp +0 -0
  79. package/icons/webp/256/en_corn.webp +0 -0
  80. package/icons/webp/256/en_cream-cheese.webp +0 -0
  81. package/icons/webp/256/en_curry-powder.webp +0 -0
  82. package/icons/webp/256/en_dill.webp +0 -0
  83. package/icons/webp/256/en_dough.webp +0 -0
  84. package/icons/webp/256/en_dried-thyme.webp +0 -0
  85. package/icons/webp/256/en_dried-tomatoes.webp +0 -0
  86. package/icons/webp/256/en_fish-sauce.webp +0 -0
  87. package/icons/webp/256/en_fish.webp +0 -0
  88. package/icons/webp/256/en_fruit.webp +0 -0
  89. package/icons/webp/256/en_green-olive.webp +0 -0
  90. package/icons/webp/256/en_harissa.webp +0 -0
  91. package/icons/webp/256/en_herb.webp +0 -0
  92. package/icons/webp/256/en_honey.webp +0 -0
  93. package/icons/webp/256/en_hummus.webp +0 -0
  94. package/icons/webp/256/en_kale.webp +0 -0
  95. package/icons/webp/256/en_ketchup.webp +0 -0
  96. package/icons/webp/256/en_kiwifruit.webp +0 -0
  97. package/icons/webp/256/en_nut.webp +0 -0
  98. package/icons/webp/256/en_oregano.webp +0 -0
  99. package/icons/webp/256/en_pak-choi.webp +0 -0
  100. package/icons/webp/256/en_pastry.webp +0 -0
  101. package/icons/webp/256/en_peanut.webp +0 -0
  102. package/icons/webp/256/en_pecorino.webp +0 -0
  103. package/icons/webp/256/en_pepper.webp +0 -0
  104. package/icons/webp/256/en_pesto.webp +0 -0
  105. package/icons/webp/256/en_pine-nuts.webp +0 -0
  106. package/icons/webp/256/en_pistachio-nuts.webp +0 -0
  107. package/icons/webp/256/en_pork.webp +0 -0
  108. package/icons/webp/256/en_poultry-broth.webp +0 -0
  109. package/icons/webp/256/en_pulse.webp +0 -0
  110. package/icons/webp/256/en_red-bean.webp +0 -0
  111. package/icons/webp/256/en_red-wine-vinegar.webp +0 -0
  112. package/icons/webp/256/en_rice-vinegar.webp +0 -0
  113. package/icons/webp/256/en_romaine-lettuce.webp +0 -0
  114. package/icons/webp/256/en_salad.webp +0 -0
  115. package/icons/webp/256/en_sauce.webp +0 -0
  116. package/icons/webp/256/en_sausage.webp +0 -0
  117. package/icons/webp/256/en_seed.webp +0 -0
  118. package/icons/webp/256/en_semolina.webp +0 -0
  119. package/icons/webp/256/en_sesame-oil.webp +0 -0
  120. package/icons/webp/256/en_sesame.webp +0 -0
  121. package/icons/webp/256/en_spice.webp +0 -0
  122. package/icons/webp/256/en_tortilla.webp +0 -0
  123. package/icons/webp/256/en_turmeric.webp +0 -0
  124. package/icons/webp/256/en_white-beans.webp +0 -0
  125. package/icons/webp/256/generic.webp +0 -0
  126. package/icons/webp/64/en_balsamic-vinegar.webp +0 -0
  127. package/icons/webp/64/en_beef-broth.webp +0 -0
  128. package/icons/webp/64/en_bulgur.webp +0 -0
  129. package/icons/webp/64/en_camembert.webp +0 -0
  130. package/icons/webp/64/en_cashew-nuts.webp +0 -0
  131. package/icons/webp/64/en_cheese.webp +0 -0
  132. package/icons/webp/64/en_cherry-tomato.webp +0 -0
  133. package/icons/webp/64/en_chicken-fillet.webp +0 -0
  134. package/icons/webp/64/en_chicken-thigh.webp +0 -0
  135. package/icons/webp/64/en_chopped-tomato.webp +0 -0
  136. package/icons/webp/64/en_chorizo.webp +0 -0
  137. package/icons/webp/64/en_coconut.webp +0 -0
  138. package/icons/webp/64/en_coriander-seed.webp +0 -0
  139. package/icons/webp/64/en_corn.webp +0 -0
  140. package/icons/webp/64/en_cream-cheese.webp +0 -0
  141. package/icons/webp/64/en_curry-powder.webp +0 -0
  142. package/icons/webp/64/en_dill.webp +0 -0
  143. package/icons/webp/64/en_dough.webp +0 -0
  144. package/icons/webp/64/en_dried-thyme.webp +0 -0
  145. package/icons/webp/64/en_dried-tomatoes.webp +0 -0
  146. package/icons/webp/64/en_fish-sauce.webp +0 -0
  147. package/icons/webp/64/en_fish.webp +0 -0
  148. package/icons/webp/64/en_fruit.webp +0 -0
  149. package/icons/webp/64/en_green-olive.webp +0 -0
  150. package/icons/webp/64/en_harissa.webp +0 -0
  151. package/icons/webp/64/en_herb.webp +0 -0
  152. package/icons/webp/64/en_honey.webp +0 -0
  153. package/icons/webp/64/en_hummus.webp +0 -0
  154. package/icons/webp/64/en_kale.webp +0 -0
  155. package/icons/webp/64/en_ketchup.webp +0 -0
  156. package/icons/webp/64/en_kiwifruit.webp +0 -0
  157. package/icons/webp/64/en_nut.webp +0 -0
  158. package/icons/webp/64/en_oregano.webp +0 -0
  159. package/icons/webp/64/en_pak-choi.webp +0 -0
  160. package/icons/webp/64/en_pastry.webp +0 -0
  161. package/icons/webp/64/en_peanut.webp +0 -0
  162. package/icons/webp/64/en_pecorino.webp +0 -0
  163. package/icons/webp/64/en_pepper.webp +0 -0
  164. package/icons/webp/64/en_pesto.webp +0 -0
  165. package/icons/webp/64/en_pine-nuts.webp +0 -0
  166. package/icons/webp/64/en_pistachio-nuts.webp +0 -0
  167. package/icons/webp/64/en_pork.webp +0 -0
  168. package/icons/webp/64/en_poultry-broth.webp +0 -0
  169. package/icons/webp/64/en_pulse.webp +0 -0
  170. package/icons/webp/64/en_red-bean.webp +0 -0
  171. package/icons/webp/64/en_red-wine-vinegar.webp +0 -0
  172. package/icons/webp/64/en_rice-vinegar.webp +0 -0
  173. package/icons/webp/64/en_romaine-lettuce.webp +0 -0
  174. package/icons/webp/64/en_salad.webp +0 -0
  175. package/icons/webp/64/en_sauce.webp +0 -0
  176. package/icons/webp/64/en_sausage.webp +0 -0
  177. package/icons/webp/64/en_seed.webp +0 -0
  178. package/icons/webp/64/en_semolina.webp +0 -0
  179. package/icons/webp/64/en_sesame-oil.webp +0 -0
  180. package/icons/webp/64/en_sesame.webp +0 -0
  181. package/icons/webp/64/en_spice.webp +0 -0
  182. package/icons/webp/64/en_tortilla.webp +0 -0
  183. package/icons/webp/64/en_turmeric.webp +0 -0
  184. package/icons/webp/64/en_white-beans.webp +0 -0
  185. package/icons/webp/64/generic.webp +0 -0
  186. 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
- /** Every Open Food Facts id that has its own icon. */
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: cherry tomatoes get the tomato. */
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.2.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
- /** Every Open Food Facts id that has its own icon. */
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
- /** Name of an id that has an icon, from the Open Food Facts taxonomy. */
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ingredient-icons/core",
3
- "version": "0.2.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",