@recipe-book/react 0.1.0 → 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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @recipe-book/react
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - `<Recipe.Ingredient>` and the function `useFormatIngredient()` returns now throw a `RecipeBookError` with code `invalid_argument` for an item that isn't `{ ingredient, quantity? }`, such as `{}`, `null`, or an authored ingredient, instead of a bare `TypeError`. ([#925](https://github.com/SirajChokshi/recipe-book/pull/925) by [@SirajChokshi](https://github.com/SirajChokshi))
8
+
9
+ - The error is the one `formatIngredient` from `@recipe-book/react/core` throws: its message says what it expects and what it received, and links to the error's page.
10
+
11
+ - Passing `dangerouslySetInnerHTML` to a part that always renders content now fails typecheck instead of throwing when React renders it. ([#906](https://github.com/SirajChokshi/recipe-book/pull/906) by [@SirajChokshi](https://github.com/SirajChokshi))
12
+
13
+ - That's every part except four. `<Recipe.Root>` and `<Recipe.JsonLd>` already failed typecheck with it. `<Recipe.Image>` and `<Recipe.ServingsInput>` still typecheck with it, as a plain `<img>` or `<input>` does, and React still throws when it renders them.
14
+ - A wrapper that spreads its element's props into a part typechecks as before.
15
+
16
+ - Add `@recipe-book/react/core` and `@recipe-book/react/core/schema-org`, which re-export `@recipe-book/core` and `@recipe-book/core/schema-org`, so a React app installs one package. ([#888](https://github.com/SirajChokshi/recipe-book/pull/888) by [@SirajChokshi](https://github.com/SirajChokshi))
17
+
18
+ - The re-exports are core's own values, not copies. While an app's `@recipe-book/core` is on the same version as `@recipe-book/react`, the two packages share one copy of core, so code can mix imports from both. With different versions, the app gets a second copy of core.
19
+ - Neither is a `'use client'` module, so in a Server Component `parseRecipe`, `toJsonLd`, and core's other functions run on the server, as they do from core.
20
+ - `@recipe-book/react` still re-exports nothing from core, and its parts and hooks stay client references.
21
+ - Errors that said to call `parseRecipe()` or `formatIngredient()` from `@recipe-book/core` now name `@recipe-book/react/core`.
22
+
23
+ - `setServings`, `servings`, and `defaultServings` accept a number at either end of the servings window, such as 700000 for a recipe with 0.7 servings, as `resolveRecipe` now does. ([#911](https://github.com/SirajChokshi/recipe-book/pull/911) by [@SirajChokshi](https://github.com/SirajChokshi))
24
+
25
+ - The development warning for a number outside the window rounds the bounds it names to six digits inside the window, so it never names a number that's rejected: for a recipe with ⅔ servings, it names 666666 rather than 666667.
26
+
27
+ - `SystemOption` now sets `autoComplete="off"`, so when going back reloads the page, Firefox no longer re-enables an option that the server rendered disabled and the page enabled later, and its new `autoComplete` prop lets you pass your own value. ([#905](https://github.com/SirajChokshi/recipe-book/pull/905) by [@SirajChokshi](https://github.com/SirajChokshi))
28
+
3
29
  ## 0.1.0
4
30
 
5
31
  - `<Recipe.Root>` holds a parsed recipe's servings and measurement system, controlled or not, and `useRecipe()` reads them. `useRecipeState()` does the same without a Root. With `parse={parseRecipe}`, a Root parses recipe input in the browser.
package/README.md CHANGED
@@ -5,15 +5,17 @@ Unstyled React components for recipes. Scale servings, switch between metric and
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- npm i @recipe-book/react @recipe-book/core
8
+ npm i @recipe-book/react
9
9
  ```
10
10
 
11
+ Core's functions and types, such as `parseRecipe`, come from `@recipe-book/react/core`, so you don't install `@recipe-book/core` yourself. If your app also installs `@recipe-book/core`, keep it on the same version as `@recipe-book/react`, or the app gets a second copy of core.
12
+
11
13
  ## Usage
12
14
 
13
- Parse recipe input with `parseRecipe` from `@recipe-book/core` and pass the parsed recipe to `<Recipe.Root>`. The parts inside it render the recipe at the chosen servings and measurement system.
15
+ Parse recipe input with `parseRecipe` and pass the parsed recipe to `<Recipe.Root>`. The parts inside it render the recipe at the chosen servings and measurement system.
14
16
 
15
17
  ```tsx
16
- import { parseRecipe } from '@recipe-book/core'
18
+ import { parseRecipe } from '@recipe-book/react/core'
17
19
  import * as Recipe from '@recipe-book/react'
18
20
 
19
21
  const result = parseRecipe({
@@ -47,7 +49,7 @@ export function Pancakes() {
47
49
  }
48
50
  ```
49
51
 
50
- Parse where you load the recipe, such as in a Server Component or at build time, so the parser stays out of the browser bundle. With Next.js, and with Vite when each page loads as its own chunk, such as a lazy route, a page that parses in the browser with `import { parseRecipe } from '@recipe-book/core'` doesn't put the parser on other pages. Otherwise, such as with esbuild's code splitting or with Vite without lazy routes, parse on the server on every page: one page that parses in the browser can put the parser on other pages. Calling `import('@recipe-book/core')` can also download it, as [Why parse on the server](https://recipe-book.siraj.page/guides/render-a-recipe-in-react/#why-parse-on-the-server) describes.
52
+ Parse where you load the recipe, such as in a Server Component or at build time, so the parser stays out of the browser bundle. [Render a recipe on the server](https://recipe-book.siraj.page/guides/render-a-recipe-on-the-server/) shows how with Next.js and React Router. With Next.js, and with Vite when each page loads as its own chunk, such as a lazy route, a page that parses in the browser with `import { parseRecipe } from '@recipe-book/react/core'` doesn't put the parser on other pages. Otherwise, such as with esbuild's code splitting or with Vite without lazy routes, parse on the server on every page: one page that parses in the browser can put the parser on other pages. Calling `import('@recipe-book/react/core')` can also download it, as [Why parse on the server](https://recipe-book.siraj.page/guides/render-a-recipe-in-react/#why-parse-on-the-server) describes.
51
53
 
52
54
  ## Documentation
53
55
 
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../dist/core.cjs",
3
+ "module": "../dist/core.js",
4
+ "types": "../dist/core.d.cts"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../dist/core/schema-org.cjs",
3
+ "module": "../../dist/core/schema-org.js",
4
+ "types": "../../dist/core/schema-org.d.cts"
5
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/core/schema-org.ts
18
+ var schema_org_exports = {};
19
+ module.exports = __toCommonJS(schema_org_exports);
20
+ __reExport(schema_org_exports, require("@recipe-book/core/schema-org"), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require("@recipe-book/core/schema-org")
24
+ });
25
+ //# sourceMappingURL=schema-org.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/schema-org.ts"],"sourcesContent":["export * from '@recipe-book/core/schema-org'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,yCAAd;","names":[]}
@@ -0,0 +1 @@
1
+ export * from '@recipe-book/core/schema-org';
@@ -0,0 +1 @@
1
+ export * from '@recipe-book/core/schema-org';
@@ -0,0 +1,3 @@
1
+ // src/core/schema-org.ts
2
+ export * from "@recipe-book/core/schema-org";
3
+ //# sourceMappingURL=schema-org.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/schema-org.ts"],"sourcesContent":["export * from '@recipe-book/core/schema-org'\n"],"mappings":";AAAA,cAAc;","names":[]}
package/dist/core.cjs ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+
17
+ // src/core.ts
18
+ var core_exports = {};
19
+ module.exports = __toCommonJS(core_exports);
20
+ __reExport(core_exports, require("@recipe-book/core"), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require("@recipe-book/core")
24
+ });
25
+ //# sourceMappingURL=core.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core.ts"],"sourcesContent":["export * from '@recipe-book/core'\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,8BAAd;","names":[]}
@@ -0,0 +1 @@
1
+ export * from '@recipe-book/core';
package/dist/core.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@recipe-book/core';
package/dist/core.js ADDED
@@ -0,0 +1,3 @@
1
+ // src/core.ts
2
+ export * from "@recipe-book/core";
3
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core.ts"],"sourcesContent":["export * from '@recipe-book/core'\n"],"mappings":";AAAA,cAAc;","names":[]}