@recipe-book/core 0.0.1 → 0.0.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 (73) hide show
  1. package/dist/{chunk-2WUP3JQY.mjs → chunk-3FFMHRB7.mjs} +3 -2
  2. package/dist/{chunk-IEYO4T4T.mjs → chunk-4EHNJLGI.mjs} +9 -8
  3. package/dist/chunk-4IA5EEKI.mjs +81 -0
  4. package/dist/chunk-4TATADPT.mjs +51 -0
  5. package/dist/chunk-6GI5KLI4.mjs +22 -0
  6. package/dist/chunk-6YYQ4RYZ.mjs +26 -0
  7. package/dist/chunk-7BBUDI2L.mjs +0 -0
  8. package/dist/chunk-7KEMNCV7.mjs +26 -0
  9. package/dist/chunk-7MMJZZ7Z.mjs +75 -0
  10. package/dist/chunk-BES4V7DM.mjs +26 -0
  11. package/dist/{chunk-OBJ5JUVG.mjs → chunk-BRDXRIAH.mjs} +5 -4
  12. package/dist/chunk-CFR2ZBPB.mjs +77 -0
  13. package/dist/chunk-DYMNVFL2.mjs +78 -0
  14. package/dist/{chunk-NJQRYZC2.mjs → chunk-F6AQKXJU.mjs} +7 -4
  15. package/dist/chunk-FW4M2R43.mjs +51 -0
  16. package/dist/chunk-GCCEDUST.mjs +75 -0
  17. package/dist/chunk-GE7KBYZR.mjs +26 -0
  18. package/dist/chunk-GN7ZDGYC.mjs +51 -0
  19. package/dist/chunk-GOO2SCQX.mjs +75 -0
  20. package/dist/chunk-HAVKBQLH.mjs +51 -0
  21. package/dist/chunk-HCBIPANU.mjs +50 -0
  22. package/dist/chunk-IEBAGBS7.mjs +51 -0
  23. package/dist/chunk-IQ6WN2V4.mjs +75 -0
  24. package/dist/chunk-JB4Z2FR7.mjs +77 -0
  25. package/dist/chunk-JMTQOTBM.mjs +75 -0
  26. package/dist/{chunk-JPGZ2MYF.mjs → chunk-JRO6JUES.mjs} +9 -6
  27. package/dist/chunk-KH3SRXET.mjs +52 -0
  28. package/dist/chunk-KNZMCAQZ.mjs +51 -0
  29. package/dist/chunk-LEBGCVCJ.mjs +75 -0
  30. package/dist/chunk-MAHWFCIL.mjs +51 -0
  31. package/dist/chunk-MPH76SLC.mjs +51 -0
  32. package/dist/chunk-MQGMFBJQ.mjs +26 -0
  33. package/dist/chunk-NMIVG7T4.mjs +6 -0
  34. package/dist/chunk-Q3TT3AZ4.mjs +26 -0
  35. package/dist/chunk-QY5HJQIL.mjs +51 -0
  36. package/dist/chunk-RCPLSNKM.mjs +1 -0
  37. package/dist/chunk-UQ3EUYFR.mjs +1 -0
  38. package/dist/chunk-WSW6FMUL.mjs +51 -0
  39. package/dist/chunk-WU55SBIV.mjs +75 -0
  40. package/dist/chunk-XINK45P3.mjs +51 -0
  41. package/dist/chunk-XNOHIWI3.mjs +1 -0
  42. package/dist/chunk-YHBXEVUX.mjs +51 -0
  43. package/dist/chunk-YSZSCEI7.mjs +75 -0
  44. package/dist/const/conversion.d.mts +2 -2
  45. package/dist/const/conversion.d.ts +2 -2
  46. package/dist/index.d.mts +1 -1
  47. package/dist/index.d.ts +1 -1
  48. package/dist/index.js +1 -1
  49. package/dist/index.mjs +1 -1
  50. package/dist/lib/ingredient.d.mts +3 -2
  51. package/dist/lib/ingredient.d.ts +3 -2
  52. package/dist/lib/ingredient.js +1 -1
  53. package/dist/lib/ingredient.mjs +1 -1
  54. package/dist/lib/recipe.d.mts +4 -2
  55. package/dist/lib/recipe.d.ts +4 -2
  56. package/dist/lib/recipe.js +1 -1
  57. package/dist/lib/recipe.mjs +1 -1
  58. package/dist/lib/unit.d.mts +5 -4
  59. package/dist/lib/unit.d.ts +5 -4
  60. package/dist/lib/unit.js +1 -1
  61. package/dist/lib/unit.mjs +1 -1
  62. package/dist/types.d.mts +17 -12
  63. package/dist/types.d.ts +17 -12
  64. package/dist/types.js +1 -1
  65. package/package.json +6 -4
  66. package/dist/chunk-4AN32V3Z.mjs +0 -1
  67. package/dist/chunk-5ZCZ6LQB.mjs +0 -1
  68. package/dist/chunk-BOG6H6FE.mjs +0 -1
  69. package/dist/chunk-CEPTOQUR.mjs +0 -1
  70. package/dist/chunk-EKLUF5ED.mjs +0 -1
  71. package/dist/chunk-LLHRB3T7.mjs +0 -1
  72. package/dist/chunk-MUILH2IA.mjs +0 -1
  73. package/dist/chunk-YHBHNGQX.mjs +0 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { RecipeUtils } from './lib/recipe.js';
2
2
  export { UnitUtils } from './lib/unit.js';
3
3
  export { IngredientUtils } from './lib/ingredient.js';
4
- export { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from './types.js';
4
+ export { ConversionTables, GlobalRecipeConfig, Ingredient, IngredientAmount, Instruction, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from './types.js';
5
5
  import './const/unit.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var l=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var f=(o,e)=>{for(var t in e)l(o,t,{get:e[t],enumerable:!0})},U=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of y(e))!L.call(o,i)&&i!==t&&l(o,i,{get:()=>e[i],enumerable:!(n=T(e,i))||n.enumerable});return o};var d=o=>U(l({},"__esModule",{value:!0}),o);var R={};f(R,{IngredientUtils:()=>p,RecipeUtils:()=>s,UnitUtils:()=>a});module.exports=d(R);function b(o,e,t){if(!e(o))throw new Error(t)}function r(o,e,t){e(o)||console.warn(t)}var s=class{scopedMessageFactory(e){return t=>`${e.name}: ${t}`}validateConfig(e){if(!!0)return;let t=this.scopedMessageFactory(e);r(e.instructions,n=>n.length>0,t("Recipe has no instructions")),r(e.servings,n=>n!==void 0&&n<=0,t("Recipe has less than one serving")),r(e.ingredients,n=>n.length>0,t("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,units:e.units,thumbnail:e.thumbnail,servings:e.servings??1,instructions:e.instructions??[]}}};var u={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},v={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var h=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],C=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],c=[...h,...C];var a=class{static getUnit(e){let t=c.find(n=>n.abbreviation===e||n.name===e);return b(t,n=>!!n,`No unit found for key: ${e}`),t}static getConversionRatio(e,t){let{type:n,abbreviation:i}=this.getUnit(e),m=(n==="volume"?v:u)[i];return b(m,g=>!!g[t],`No conversion table available for unit ${e} to ${t}`),m[t]}static convert(e,t,n){if(t===n)return e;let i=this.getConversionRatio(t,n);return e*i}};var p=class{convert(e,t){let n=a.convert(e.amount.value,e.amount.unit,t);return{...e,amount:{value:n,unit:t}}}};0&&(module.exports={IngredientUtils,RecipeUtils,UnitUtils});
1
+ var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var E=(o,e)=>{for(var t in e)m(o,t,{get:e[t],enumerable:!0})},w=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of h(e))!R.call(o,i)&&i!==t&&m(o,i,{get:()=>e[i],enumerable:!(n=d(e,i))||n.enumerable});return o};var I=o=>w(m({},"__esModule",{value:!0}),o);var C={};E(C,{IngredientUtils:()=>T,RecipeUtils:()=>g,UnitUtils:()=>s});module.exports=I(C);function u(o,e,t){if(!e(o))throw new Error(t)}function a(o,e,t){e(o)||console.warn(t)}var p=class{scopedMessageFactory(e){return t=>`${e.name}: ${t}`}validateConfig(e){if(!!0)return;let t=this.scopedMessageFactory(e);a(e.instructions,n=>n.length>0,t("Recipe has no instructions")),a(e.serves,n=>n===void 0||n>0,t("Recipe serves less than 1 person")),a(e.ingredients,n=>n.length>0,t("Recipe has no ingredients"))}determineMeasurementSystem(e){let{ingredients:t}=e,n=t.some(r=>r.amount.unit==="g"),i=t.some(r=>r.amount.unit==="oz"||r.amount.unit==="fl oz"||r.amount.unit==="lb"||r.amount.unit==="cup");if(!(n&&i)){if(n)return"metric";if(i)return"us-customary"}}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,thumbnail:e.thumbnail,serves:e.serves??1,instructions:e.instructions??[],measurements:e.measurements??this.determineMeasurementSystem(e)}}},g=new p;var y={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},f={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var N=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],x=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],L=[...N,...x];var l=class{getUnit(e){let t=L.find(n=>n.abbreviation===e||n.name===e);return u(t,n=>!!n,`No unit found for key: ${e}`),t}getConversionRatio(e,t){let{type:n,abbreviation:i}=this.getUnit(e),b=(n==="volume"?f:y)[i],v=t==="metric"?n==="volume"?"L":"g":t;return u(b,U=>!!U[v],`No conversion table available for unit ${e} to ${t}`),b[v]}convert(e,t,n){if(t===n)return e;let i=this.getConversionRatio(t,n),r=e*i;return Math.round(r*100)/100}},s=new l;var c=class{convert(e,t){let n=s.convert(e.amount.value,e.amount.unit,t);return{...e,amount:{value:n,unit:t}}}},T=new c;0&&(module.exports={IngredientUtils,RecipeUtils,UnitUtils});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import"./chunk-WBQAMGXK.mjs";import{a as i}from"./chunk-ULDLBAEG.mjs";import{a as t}from"./chunk-SR2KFBT3.mjs";import"./chunk-KXFUCO3R.mjs";import"./chunk-22RBQQWH.mjs";import{a as r}from"./chunk-CBLJXA6P.mjs";import"./chunk-C45UD45A.mjs";import"./chunk-3CSP4UZG.mjs";export{i as IngredientUtils,r as RecipeUtils,t as UnitUtils};
1
+ import"./chunk-WBQAMGXK.mjs";import{a as i}from"./chunk-RCPLSNKM.mjs";import{a as t}from"./chunk-XNOHIWI3.mjs";import"./chunk-KXFUCO3R.mjs";import"./chunk-22RBQQWH.mjs";import{a as r}from"./chunk-UQ3EUYFR.mjs";import"./chunk-C45UD45A.mjs";import"./chunk-3CSP4UZG.mjs";export{i as IngredientUtils,r as RecipeUtils,t as UnitUtils};
@@ -1,8 +1,9 @@
1
1
  import { Ingredient, UnitKey } from '../types.mjs';
2
2
  import '../const/unit.mjs';
3
3
 
4
- declare abstract class IngredientUtils {
5
- convert<TConversionTableKey extends string>(ingredient: Ingredient<TConversionTableKey>, to: UnitKey): Ingredient<TConversionTableKey>;
4
+ declare class IngredientUtilsImpl {
5
+ convert(ingredient: Ingredient, to: UnitKey): Ingredient;
6
6
  }
7
+ declare const IngredientUtils: IngredientUtilsImpl;
7
8
 
8
9
  export { IngredientUtils };
@@ -1,8 +1,9 @@
1
1
  import { Ingredient, UnitKey } from '../types.js';
2
2
  import '../const/unit.js';
3
3
 
4
- declare abstract class IngredientUtils {
5
- convert<TConversionTableKey extends string>(ingredient: Ingredient<TConversionTableKey>, to: UnitKey): Ingredient<TConversionTableKey>;
4
+ declare class IngredientUtilsImpl {
5
+ convert(ingredient: Ingredient, to: UnitKey): Ingredient;
6
6
  }
7
+ declare const IngredientUtils: IngredientUtilsImpl;
7
8
 
8
9
  export { IngredientUtils };
@@ -1 +1 @@
1
- var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var t in e)r(n,t,{get:e[t],enumerable:!0})},L=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of g(e))!T.call(n,a)&&a!==t&&r(n,a,{get:()=>e[a],enumerable:!(o=c(e,a))||o.enumerable});return n};var U=n=>L(r({},"__esModule",{value:!0}),n);var N={};y(N,{IngredientUtils:()=>b});module.exports=U(N);var p={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},v={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var f=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],E=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],u=[...f,...E];function s(n,e,t){if(!e(n))throw new Error(t)}var i=class{static getUnit(e){let t=u.find(o=>o.abbreviation===e||o.name===e);return s(t,o=>!!o,`No unit found for key: ${e}`),t}static getConversionRatio(e,t){let{type:o,abbreviation:a}=this.getUnit(e),l=(o==="volume"?v:p)[a];return s(l,m=>!!m[t],`No conversion table available for unit ${e} to ${t}`),l[t]}static convert(e,t,o){if(t===o)return e;let a=this.getConversionRatio(t,o);return e*a}};var b=class{convert(e,t){let o=i.convert(e.amount.value,e.amount.unit,t);return{...e,amount:{value:o,unit:t}}}};0&&(module.exports={IngredientUtils});
1
+ var i=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var f=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},E=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of T(e))!U.call(n,a)&&a!==t&&i(n,a,{get:()=>e[a],enumerable:!(o=L(e,a))||o.enumerable});return n};var N=n=>E(i({},"__esModule",{value:!0}),n);var h={};f(h,{IngredientUtils:()=>I});module.exports=N(h);var v={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},m={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var k=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],w=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],c=[...k,...w];function r(n,e,t){if(!e(n))throw new Error(t)}var s=class{getUnit(e){let t=c.find(o=>o.abbreviation===e||o.name===e);return r(t,o=>!!o,`No unit found for key: ${e}`),t}getConversionRatio(e,t){let{type:o,abbreviation:a}=this.getUnit(e),p=(o==="volume"?m:v)[a],u=t==="metric"?o==="volume"?"L":"g":t;return r(p,y=>!!y[u],`No conversion table available for unit ${e} to ${t}`),p[u]}convert(e,t,o){if(t===o)return e;let a=this.getConversionRatio(t,o),b=e*a;return Math.round(b*100)/100}},g=new s;var l=class{convert(e,t){let o=g.convert(e.amount.value,e.amount.unit,t);return{...e,amount:{value:o,unit:t}}}},I=new l;0&&(module.exports={IngredientUtils});
@@ -1 +1 @@
1
- import{a}from"../chunk-ULDLBAEG.mjs";import"../chunk-SR2KFBT3.mjs";import"../chunk-KXFUCO3R.mjs";import"../chunk-22RBQQWH.mjs";import"../chunk-C45UD45A.mjs";export{a as IngredientUtils};
1
+ import{a}from"../chunk-RCPLSNKM.mjs";import"../chunk-XNOHIWI3.mjs";import"../chunk-KXFUCO3R.mjs";import"../chunk-22RBQQWH.mjs";import"../chunk-C45UD45A.mjs";export{a as IngredientUtils};
@@ -1,10 +1,12 @@
1
1
  import { RecipeConfig, Recipe } from '../types.mjs';
2
2
  import '../const/unit.mjs';
3
3
 
4
- declare abstract class RecipeUtils {
4
+ declare class RecipeUtilsImpl {
5
5
  private scopedMessageFactory;
6
6
  private validateConfig;
7
- create<TConversionTableKey extends string>(config: RecipeConfig<TConversionTableKey>): Recipe<TConversionTableKey>;
7
+ private determineMeasurementSystem;
8
+ create(config: RecipeConfig): Recipe;
8
9
  }
10
+ declare const RecipeUtils: RecipeUtilsImpl;
9
11
 
10
12
  export { RecipeUtils };
@@ -1,10 +1,12 @@
1
1
  import { RecipeConfig, Recipe } from '../types.js';
2
2
  import '../const/unit.js';
3
3
 
4
- declare abstract class RecipeUtils {
4
+ declare class RecipeUtilsImpl {
5
5
  private scopedMessageFactory;
6
6
  private validateConfig;
7
- create<TConversionTableKey extends string>(config: RecipeConfig<TConversionTableKey>): Recipe<TConversionTableKey>;
7
+ private determineMeasurementSystem;
8
+ create(config: RecipeConfig): Recipe;
8
9
  }
10
+ declare const RecipeUtils: RecipeUtilsImpl;
9
11
 
10
12
  export { RecipeUtils };
@@ -1 +1 @@
1
- var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var l=(i,e)=>{for(var n in e)a(i,n,{get:e[n],enumerable:!0})},c=(i,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of u(e))!g.call(i,r)&&r!==n&&a(i,r,{get:()=>e[r],enumerable:!(t=p(e,r))||t.enumerable});return i};var m=i=>c(a({},"__esModule",{value:!0}),i);var v={};l(v,{RecipeUtils:()=>o});module.exports=m(v);function s(i,e,n){e(i)||console.warn(n)}var o=class{scopedMessageFactory(e){return n=>`${e.name}: ${n}`}validateConfig(e){if(!!0)return;let n=this.scopedMessageFactory(e);s(e.instructions,t=>t.length>0,n("Recipe has no instructions")),s(e.servings,t=>t!==void 0&&t<=0,n("Recipe has less than one serving")),s(e.ingredients,t=>t.length>0,n("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,units:e.units,thumbnail:e.thumbnail,servings:e.servings??1,instructions:e.instructions??[]}}};0&&(module.exports={RecipeUtils});
1
+ var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(s,e)=>{for(var t in e)o(s,t,{get:e[t],enumerable:!0})},d=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!c.call(s,r)&&r!==t&&o(s,r,{get:()=>e[r],enumerable:!(n=m(e,r))||n.enumerable});return s};var h=s=>d(o({},"__esModule",{value:!0}),s);var v={};l(v,{RecipeUtils:()=>f});module.exports=h(v);function a(s,e,t){e(s)||console.warn(t)}var u=class{scopedMessageFactory(e){return t=>`${e.name}: ${t}`}validateConfig(e){if(!!0)return;let t=this.scopedMessageFactory(e);a(e.instructions,n=>n.length>0,t("Recipe has no instructions")),a(e.serves,n=>n===void 0||n>0,t("Recipe serves less than 1 person")),a(e.ingredients,n=>n.length>0,t("Recipe has no ingredients"))}determineMeasurementSystem(e){let{ingredients:t}=e,n=t.some(i=>i.amount.unit==="g"),r=t.some(i=>i.amount.unit==="oz"||i.amount.unit==="fl oz"||i.amount.unit==="lb"||i.amount.unit==="cup");if(!(n&&r)){if(n)return"metric";if(r)return"us-customary"}}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,thumbnail:e.thumbnail,serves:e.serves??1,instructions:e.instructions??[],measurements:e.measurements??this.determineMeasurementSystem(e)}}},f=new u;0&&(module.exports={RecipeUtils});
@@ -1 +1 @@
1
- import{a}from"../chunk-CBLJXA6P.mjs";import"../chunk-C45UD45A.mjs";import"../chunk-3CSP4UZG.mjs";export{a as RecipeUtils};
1
+ import{a}from"../chunk-UQ3EUYFR.mjs";import"../chunk-C45UD45A.mjs";import"../chunk-3CSP4UZG.mjs";export{a as RecipeUtils};
@@ -1,9 +1,9 @@
1
1
  import { UnitKey } from '../types.mjs';
2
2
  import '../const/unit.mjs';
3
3
 
4
- declare abstract class UnitUtils {
5
- private static getUnit;
6
- private static getConversionRatio;
4
+ declare class UnitUtilsImpl {
5
+ private getUnit;
6
+ private getConversionRatio;
7
7
  /**
8
8
  * Converts a number from one unit to another
9
9
  *
@@ -12,7 +12,8 @@ declare abstract class UnitUtils {
12
12
  * @param to - The unit to convert to
13
13
  * @returns - The converted amount
14
14
  */
15
- static convert(amount: number, from: UnitKey, to: UnitKey): number;
15
+ convert(amount: number, from: UnitKey, to: UnitKey): number;
16
16
  }
17
+ declare const UnitUtils: UnitUtilsImpl;
17
18
 
18
19
  export { UnitUtils };
@@ -1,9 +1,9 @@
1
1
  import { UnitKey } from '../types.js';
2
2
  import '../const/unit.js';
3
3
 
4
- declare abstract class UnitUtils {
5
- private static getUnit;
6
- private static getConversionRatio;
4
+ declare class UnitUtilsImpl {
5
+ private getUnit;
6
+ private getConversionRatio;
7
7
  /**
8
8
  * Converts a number from one unit to another
9
9
  *
@@ -12,7 +12,8 @@ declare abstract class UnitUtils {
12
12
  * @param to - The unit to convert to
13
13
  * @returns - The converted amount
14
14
  */
15
- static convert(amount: number, from: UnitKey, to: UnitKey): number;
15
+ convert(amount: number, from: UnitKey, to: UnitKey): number;
16
16
  }
17
+ declare const UnitUtils: UnitUtilsImpl;
17
18
 
18
19
  export { UnitUtils };
package/dist/lib/unit.js CHANGED
@@ -1 +1 @@
1
- var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var T=(a,e)=>{for(var t in e)i(a,t,{get:e[t],enumerable:!0})},L=(a,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of m(e))!g.call(a,n)&&n!==t&&i(a,n,{get:()=>e[n],enumerable:!(o=c(e,n))||o.enumerable});return a};var y=a=>L(i({},"__esModule",{value:!0}),a);var N={};T(N,{UnitUtils:()=>b});module.exports=y(N);var l={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},p={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var E=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],U=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],v=[...E,...U];function r(a,e,t){if(!e(a))throw new Error(t)}var b=class{static getUnit(e){let t=v.find(o=>o.abbreviation===e||o.name===e);return r(t,o=>!!o,`No unit found for key: ${e}`),t}static getConversionRatio(e,t){let{type:o,abbreviation:n}=this.getUnit(e),s=(o==="volume"?p:l)[n];return r(s,u=>!!u[t],`No conversion table available for unit ${e} to ${t}`),s[t]}static convert(e,t,o){if(t===o)return e;let n=this.getConversionRatio(t,o);return e*n}};0&&(module.exports={UnitUtils});
1
+ var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},U=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of L(e))!T.call(n,a)&&a!==t&&i(n,a,{get:()=>e[a],enumerable:!(o=g(e,a))||o.enumerable});return n};var E=n=>U(i({},"__esModule",{value:!0}),n);var h={};y(h,{UnitUtils:()=>k});module.exports=E(h);var v={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},u={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var N=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],f=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],c=[...N,...f];function r(n,e,t){if(!e(n))throw new Error(t)}var b=class{getUnit(e){let t=c.find(o=>o.abbreviation===e||o.name===e);return r(t,o=>!!o,`No unit found for key: ${e}`),t}getConversionRatio(e,t){let{type:o,abbreviation:a}=this.getUnit(e),l=(o==="volume"?u:v)[a],p=t==="metric"?o==="volume"?"L":"g":t;return r(l,m=>!!m[p],`No conversion table available for unit ${e} to ${t}`),l[p]}convert(e,t,o){if(t===o)return e;let a=this.getConversionRatio(t,o),s=e*a;return Math.round(s*100)/100}},k=new b;0&&(module.exports={UnitUtils});
package/dist/lib/unit.mjs CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-SR2KFBT3.mjs";import"../chunk-KXFUCO3R.mjs";import"../chunk-22RBQQWH.mjs";import"../chunk-C45UD45A.mjs";export{a as UnitUtils};
1
+ import{a}from"../chunk-XNOHIWI3.mjs";import"../chunk-KXFUCO3R.mjs";import"../chunk-22RBQQWH.mjs";import"../chunk-C45UD45A.mjs";export{a as UnitUtils};
package/dist/types.d.mts CHANGED
@@ -1,31 +1,36 @@
1
1
  import { UNITS } from './const/unit.mjs';
2
2
 
3
+ type ConversionTables = 'us-customary' | 'metric';
3
4
  type Unit = (typeof UNITS)[number];
4
- type UnitName = Unit["name"];
5
- type UnitAbbreviation = Unit["abbreviation"];
5
+ type UnitName = Unit['name'];
6
+ type UnitAbbreviation = Unit['abbreviation'];
6
7
  type UnitKey = UnitName | UnitAbbreviation;
7
8
  type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
8
9
  type IngredientAmount = {
9
10
  value: number;
10
11
  unit: UnitKey;
11
12
  };
12
- type Ingredient<TConversionTableKey extends string> = {
13
+ type Ingredient = {
13
14
  name: string;
14
15
  amount: IngredientAmount;
15
- conversion?: Record<TConversionTableKey, IngredientAmount | UnitKey>;
16
+ conversion?: Partial<Record<ConversionTables, IngredientAmount | UnitKey>>;
16
17
  notes?: string;
17
18
  };
18
- type GlobalRecipeConfig<TConversionTableKey extends string> = {
19
- units: TConversionTableKey[];
19
+ type Instruction = {
20
+ name: string;
21
+ description: string;
22
+ image?: string;
20
23
  };
21
- type Recipe<TConversionTableKey extends string> = GlobalRecipeConfig<TConversionTableKey> & {
24
+ type GlobalRecipeConfig = {};
25
+ type Recipe = GlobalRecipeConfig & {
22
26
  name: string;
23
27
  thumbnail?: string;
24
- ingredients: Ingredient<TConversionTableKey>[];
25
- servings: number;
28
+ ingredients: Ingredient[];
29
+ serves: number;
26
30
  instructions: string[];
31
+ measurements?: ConversionTables;
27
32
  };
28
- type recipeOmittableKeys = "servings";
29
- type RecipeConfig<TConversionTableKey extends string> = PartialBy<Recipe<TConversionTableKey>, recipeOmittableKeys>;
33
+ type recipeOmittableKeys = 'serves';
34
+ type RecipeConfig = PartialBy<Recipe, recipeOmittableKeys>;
30
35
 
31
- export type { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName };
36
+ export type { ConversionTables, GlobalRecipeConfig, Ingredient, IngredientAmount, Instruction, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName };
package/dist/types.d.ts CHANGED
@@ -1,31 +1,36 @@
1
1
  import { UNITS } from './const/unit.js';
2
2
 
3
+ type ConversionTables = 'us-customary' | 'metric';
3
4
  type Unit = (typeof UNITS)[number];
4
- type UnitName = Unit["name"];
5
- type UnitAbbreviation = Unit["abbreviation"];
5
+ type UnitName = Unit['name'];
6
+ type UnitAbbreviation = Unit['abbreviation'];
6
7
  type UnitKey = UnitName | UnitAbbreviation;
7
8
  type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
8
9
  type IngredientAmount = {
9
10
  value: number;
10
11
  unit: UnitKey;
11
12
  };
12
- type Ingredient<TConversionTableKey extends string> = {
13
+ type Ingredient = {
13
14
  name: string;
14
15
  amount: IngredientAmount;
15
- conversion?: Record<TConversionTableKey, IngredientAmount | UnitKey>;
16
+ conversion?: Partial<Record<ConversionTables, IngredientAmount | UnitKey>>;
16
17
  notes?: string;
17
18
  };
18
- type GlobalRecipeConfig<TConversionTableKey extends string> = {
19
- units: TConversionTableKey[];
19
+ type Instruction = {
20
+ name: string;
21
+ description: string;
22
+ image?: string;
20
23
  };
21
- type Recipe<TConversionTableKey extends string> = GlobalRecipeConfig<TConversionTableKey> & {
24
+ type GlobalRecipeConfig = {};
25
+ type Recipe = GlobalRecipeConfig & {
22
26
  name: string;
23
27
  thumbnail?: string;
24
- ingredients: Ingredient<TConversionTableKey>[];
25
- servings: number;
28
+ ingredients: Ingredient[];
29
+ serves: number;
26
30
  instructions: string[];
31
+ measurements?: ConversionTables;
27
32
  };
28
- type recipeOmittableKeys = "servings";
29
- type RecipeConfig<TConversionTableKey extends string> = PartialBy<Recipe<TConversionTableKey>, recipeOmittableKeys>;
33
+ type recipeOmittableKeys = 'serves';
34
+ type RecipeConfig = PartialBy<Recipe, recipeOmittableKeys>;
30
35
 
31
- export type { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName };
36
+ export type { ConversionTables, GlobalRecipeConfig, Ingredient, IngredientAmount, Instruction, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName };
package/dist/types.js CHANGED
@@ -1 +1 @@
1
- var r=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var y=(n,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of a(e))!p.call(n,t)&&t!==o&&r(n,t,{get:()=>e[t],enumerable:!(i=s(e,t))||i.enumerable});return n};var T=n=>y(r({},"__esModule",{value:!0}),n);var b={};module.exports=T(b);
1
+ var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var m=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!a.call(t,n)&&n!==o&&r(t,n,{get:()=>e[n],enumerable:!(i=p(e,n))||i.enumerable});return t};var y=t=>m(r({},"__esModule",{value:!0}),t);var g={};module.exports=y(g);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recipe-book/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -8,9 +8,11 @@
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
- "sideEffects": false,
12
11
  "scripts": {
12
+ "prepublishOnly": "cp ../README.md . && pnpm build",
13
+ "postpublish": "rm README.md",
13
14
  "build": "tsup src",
14
15
  "dev": "tsup src --watch"
15
- }
16
- }
16
+ },
17
+ "sideEffects": false
18
+ }
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-SR2KFBT3.mjs";var r=class{convert(t,n){let m=o.convert(t.amount.value,t.amount.unit,n);return{...t,amount:{value:m,unit:n}}}};export{r as a};
@@ -1 +0,0 @@
1
- var o=process.env.NODE_ENV!=="production";export{o as a};
@@ -1 +0,0 @@
1
- import{b as s}from"./chunk-C45UD45A.mjs";import{a as r}from"./chunk-3CSP4UZG.mjs";var t=class{scopedMessageFactory(e){return i=>`${e.name}: ${i}`}validateConfig(e){if(!!0)return;let i=this.scopedMessageFactory(e);s(e.instructions,n=>n.length>0,i("Recipe has no instructions")),s(e.servings,n=>n!==void 0&&n<=0,i("Recipe has less than one serving")),s(e.ingredients,n=>n.length>0,i("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,servings:e.servings??1,instructions:e.instructions??[],units:e.units}}};export{t as a};
@@ -1 +0,0 @@
1
- import{c}from"./chunk-22RBQQWH.mjs";import{a as o}from"./chunk-C45UD45A.mjs";import{a,b as s}from"./chunk-KXFUCO3R.mjs";var b=class{static getUnit(t){let e=c.find(n=>n.abbreviation===t||n.name===t);return o(e,n=>!!n,`No unit found for key: ${t}`),e}static getConversionRatio(t,e){let{type:n,abbreviation:i}=this.getUnit(t),r=(n==="volume"?s:a)[i];return o(r,v=>!!v[e],`No conversion table available for unit ${t} to ${e}`),r[e]}static convert(t,e,n){if(e===n)return t;let i=this.getConversionRatio(e,n);return t*i}};export{b as a};
@@ -1 +0,0 @@
1
- import{b as s}from"./chunk-C45UD45A.mjs";import{a as r}from"./chunk-3CSP4UZG.mjs";var t=class{scopedMessageFactory(e){return n=>`${e.name}: ${n}`}validateConfig(e){if(!0)return;let n=this.scopedMessageFactory(e);s(e.instructions,i=>i.length>0,n("Recipe has no instructions")),s(e.servings,i=>i!==void 0&&i<=0,n("Recipe has less than one serving")),s(e.ingredients,i=>i.length>0,n("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,servings:e.servings??1,instructions:e.instructions??[]}}};export{t as a};
@@ -1 +0,0 @@
1
- import{a as r}from"./chunk-3CSP4UZG.mjs";import{b as s}from"./chunk-C45UD45A.mjs";var t=class{scopedMessageFactory(e){return n=>`${e.name}: ${n}`}validateConfig(e){if(!0)return;let n=this.scopedMessageFactory(e);s(e.instructions,i=>i.length>0,n("Recipe has no instructions")),s(e.servings,i=>i!==void 0&&i<=0,n("Recipe has less than one serving")),s(e.ingredients,i=>i.length>0,n("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,servings:e.servings??1,instructions:e.instructions??[]}}};export{t as a};
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-CEPTOQUR.mjs";var r=class{convert(t,n){let m=o.convert(t.amount.value,t.amount.unit,n);return{...t,amount:{value:m,unit:n}}}};export{r as a};
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-5ZCZ6LQB.mjs";import{b as s}from"./chunk-C45UD45A.mjs";var r=class{scopedMessageFactory(e){return n=>`${e.name}: ${n}`}validateConfig(e){if(t)return;let n=this.scopedMessageFactory(e);s(e.instructions,i=>i.length>0,n("Recipe has no instructions")),s(e.servings,i=>i!==void 0&&i<=0,n("Recipe has less than one serving")),s(e.ingredients,i=>i.length>0,n("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,servings:e.servings??1,instructions:e.instructions??[]}}};export{r as a};