@wrdagency/react-islands 0.1.1 → 0.2.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 CHANGED
@@ -28,12 +28,10 @@ On the client you can then render each of those islands. They'll automatically h
28
28
  ```
29
29
  // index.ts
30
30
  import * as islands from "./islands";
31
+ import { hydrateIslands } from "@wrdagency/react-islands";
31
32
 
32
- const isDev = (process.env.NODE_ENV || "development").trim() === "development";
33
+ hydrateIslands( islands );
33
34
 
34
- for (const island of Object.values(islands)) {
35
- island.render({ hydrate: !isDev });
36
- }
37
35
  ```
38
36
 
39
37
  Create a pre-render script. You can configure your build tool to use this as a seperate entrypoint.
package/dist/index.d.mts CHANGED
@@ -1,12 +1,40 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import { FC } from 'react';
3
- import { I as IslandOpts, a as Island } from './types-Dn7YlQVB.mjs';
2
+ import { I as Island, a as IslandOpts } from './types-BWtowKeL.mjs';
4
3
 
5
- declare function createIsland(component: FC, opts: IslandOpts): Island;
4
+ /**
5
+ * Create a higher-order component with certain fixed.
6
+ *
7
+ * Useful for quickly creating multiple variants of the same component to use as islands.
8
+ *
9
+ * @param component FC<T>
10
+ * @param setProps Partial<T>
11
+ * @returns FC<T>
12
+ */
6
13
  declare function withProps<T>(component: FC<T>, setProps: Partial<T>): FC<T>;
14
+ /**
15
+ * Render all Islands in a record.
16
+ *
17
+ * Useful if you are importing * from an islands directory.
18
+ *
19
+ * @param islands Record<string, Island>
20
+ */
21
+ declare function hydrateIslands(islands: Record<string, Island>): void;
22
+
23
+ /**
24
+ * Create a React Island.
25
+ *
26
+ * You can render the island using the Island.render function.
27
+ *
28
+ * @param component React.FC
29
+ * @param opts IslandOpts
30
+ * @returns Island
31
+ */
32
+ declare function createIsland(component: FC, opts: IslandOpts): Island;
33
+ /**
34
+ * Checks if the current script is running in a pre-render.
35
+ *
36
+ * @returns boolean
37
+ */
7
38
  declare function isServer(): boolean;
8
- declare function RawHTML({ html }: {
9
- html: string;
10
- }): react_jsx_runtime.JSX.Element;
11
39
 
12
- export { RawHTML, createIsland, isServer, withProps };
40
+ export { Island, createIsland, hydrateIslands, isServer, withProps };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,40 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
1
  import { FC } from 'react';
3
- import { I as IslandOpts, a as Island } from './types-Dn7YlQVB.js';
2
+ import { I as Island, a as IslandOpts } from './types-BWtowKeL.js';
4
3
 
5
- declare function createIsland(component: FC, opts: IslandOpts): Island;
4
+ /**
5
+ * Create a higher-order component with certain fixed.
6
+ *
7
+ * Useful for quickly creating multiple variants of the same component to use as islands.
8
+ *
9
+ * @param component FC<T>
10
+ * @param setProps Partial<T>
11
+ * @returns FC<T>
12
+ */
6
13
  declare function withProps<T>(component: FC<T>, setProps: Partial<T>): FC<T>;
14
+ /**
15
+ * Render all Islands in a record.
16
+ *
17
+ * Useful if you are importing * from an islands directory.
18
+ *
19
+ * @param islands Record<string, Island>
20
+ */
21
+ declare function hydrateIslands(islands: Record<string, Island>): void;
22
+
23
+ /**
24
+ * Create a React Island.
25
+ *
26
+ * You can render the island using the Island.render function.
27
+ *
28
+ * @param component React.FC
29
+ * @param opts IslandOpts
30
+ * @returns Island
31
+ */
32
+ declare function createIsland(component: FC, opts: IslandOpts): Island;
33
+ /**
34
+ * Checks if the current script is running in a pre-render.
35
+ *
36
+ * @returns boolean
37
+ */
7
38
  declare function isServer(): boolean;
8
- declare function RawHTML({ html }: {
9
- html: string;
10
- }): react_jsx_runtime.JSX.Element;
11
39
 
12
- export { RawHTML, createIsland, isServer, withProps };
40
+ export { Island, createIsland, hydrateIslands, isServer, withProps };