@plasmicapp/nextjs-app-router 1.0.2 → 1.0.3

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
@@ -6,83 +6,119 @@ The idea here is to use the dev server's SSR instead! At SSR time (instead of RS
6
6
 
7
7
  So...
8
8
 
9
- 1. Create a `app/plasmic-ssr/[[...catchall]]/page.tsx` route, whose purpose is to perform SSR. It looks something like...
9
+ 1. Update `app/[[...catchall]]/page.tsx` to conditionally wrap the page contents inside `<ExtractPlasmicQueryData>` to extract the query data. It would look something like:
10
10
 
11
11
  ```
12
12
  import { ExtractPlasmicQueryData } from "@plasmicapp/nextjs-app-router";
13
+ import { fetchExtractedQueryData } from "@plasmicapp/nextjs-app-router/react-server";
13
14
 
14
- export default async function CatchallPrepass(props: {
15
- params?: Params;
16
- }) {
17
- const { params } = props;
18
-
19
- const plasmicPath = params.catchall ? `/${params.catchall.join("/")}` : "/";
20
- const prefetchedData = await PLASMIC.maybeFetchComponentData(plasmicPath);
21
- if (!prefetchedData || prefetchedData.entryCompMetas.length === 0) {
22
- notFound();
23
- }
24
-
25
- const pageMeta = prefetchedData.entryCompMetas[0];
26
-
27
- return (
28
- <ExtractPlasmicQueryData>
29
- <PlasmicClientRootProvider
30
- prefetchedData={prefetchedData}
31
- pageParams={pageMeta.params}
32
- >
33
- <PlasmicComponent
34
- component={pageMeta.displayName}
35
- />
36
- </PlasmicClientRootProvider>
37
- </ExtractPlasmicQueryData>
38
- )
39
- }
40
- ```
41
-
42
- `<ExtractPlasmicQueryData />` is a new client component from this package, which basically performs `extractPlasmicQueryData()` on its children, and then renders a `<script data-plasmic-prefetch-id/>` tag with the json of the extracted data.
43
-
44
- 2. From the real `app/[...catchall]/page.tsx` file, make use of this endpoint to read the extracted data:
45
-
46
- ```
47
- import { fetchExtractedQueryData } from "@plasmicapp/nextjs-app-router";
15
+ // Use revalidate if you want incremental static regeneration
16
+ export const revalidate = 60;
48
17
 
49
- export default async function Catchall(props: {
50
- params?: Params;
18
+ export default async function PlasmicLoaderPage({
19
+ params,
20
+ searchParams,
21
+ }: {
22
+ params?: { catchall: string[] | undefined };
23
+ searchParams?: Record<string, string | string[]>;
51
24
  }) {
52
- const { params } = props;
53
-
54
- const plasmicPath = params.catchall ? `/${params.catchall.join("/")}` : "/";
55
- const prefetchedData = await PLASMIC.maybeFetchComponentData(plasmicPath);
56
-
25
+ const pathname = "/" + (params?.catchall ? params.catchall.join("/") : "");
26
+ const prefetchedData = await fetchPlasmicComponentData(
27
+ params?.catchall
28
+ );
57
29
  if (!prefetchedData || prefetchedData.entryCompMetas.length === 0) {
58
30
  notFound();
59
31
  }
60
32
 
61
- const prepassHost = process.env.PLASMIC_PREPASS_HOST ?? process.env.VERCEL_URL ?? `http://localhost:${process.env.PORT ?? 3000}`;
62
-
63
- const queryData = await fetchExtractedQueryData(`${prepassHost}/plasmic-ssr/${(params?.catchall ?? []).join("/")}`);
64
-
65
33
  const pageMeta = prefetchedData.entryCompMetas[0];
66
34
 
67
- return (
35
+ return withExtractPlasmicQueryData(
68
36
  <PlasmicClientRootProvider
69
37
  prefetchedData={prefetchedData}
70
- prefetchedQueryData={queryData}
38
+ pageRoute={pageMeta.path}
71
39
  pageParams={pageMeta.params}
40
+ pageQuery={searchParams}
72
41
  >
73
- <PlasmicComponent
74
- component={pageMeta.displayName}
75
- />
76
- </PlasmicClientRootProvider>
77
- )
42
+ <PlasmicComponent component={pageMeta.displayName} />
43
+ </PlasmicClientRootProvider>,
44
+ {
45
+ pathname,
46
+ searchParams,
47
+ }
48
+ );
49
+ }
50
+
51
+ async function fetchPlasmicComponentData(catchall: string[] | undefined) {
52
+ const plasmicPath = "/" + (catchall ? catchall.join("/") : "");
53
+ return PLASMIC.maybeFetchComponentData(plasmicPath);;
54
+ }
55
+
56
+ /**
57
+ * Helper function to extract Plasmic data.
58
+ *
59
+ * Given the <PlasmicClientRootProvider> element and current pathname + search
60
+ * params, returns:
61
+ * - The extracted query data, if `plasmicSsr` search param is set
62
+ * - A copy of the root provider element with the extracted query data, otherwise
63
+ */
64
+ async function withExtractPlasmicQueryData(
65
+ plasmicRootProvider: React.ReactElement,
66
+ {
67
+ pathname,
68
+ searchParams,
69
+ }: {
70
+ pathname: string;
71
+ searchParams: Record<string, string | string[]> | undefined;
72
+ }
73
+ ) {
74
+ const isPlasmicSsr =
75
+ !!searchParams?.["plasmicSsr"] && searchParams?.["plasmicSsr"] !== "false";
76
+
77
+ // If `plasmicSsr` search param is set, just wrap the root provider inside
78
+ // <ExtractPlasmicQueryData>
79
+ if (isPlasmicSsr) {
80
+ return (
81
+ <ExtractPlasmicQueryData>{plasmicRootProvider}</ExtractPlasmicQueryData>
82
+ );
83
+ }
84
+
85
+ // Otherwise, fetch the same endpoint, but setting `plasmicSsr` to extract the
86
+ // query data.
87
+ const prepassHost =
88
+ process.env.PLASMIC_PREPASS_HOST ??
89
+ process.env.VERCEL_URL ??
90
+ `http://localhost:${process.env.PORT ?? 3000}`;
91
+
92
+ // Build a copy of the search params
93
+ const newSearchParams = new URLSearchParams(
94
+ Object.entries(searchParams ?? {}).flatMap(([key, values]) =>
95
+ Array.isArray(values) ? values.map((v) => [key, v]) : [[key, values]]
96
+ )
97
+ );
98
+
99
+ // Set `plasmicSsr` search param to indicate you are using this endpoint
100
+ // to extract query data.
101
+ newSearchParams.set("plasmicSsr", "true");
102
+
103
+ // Fetch the data from the endpoint using the new search params
104
+ const prefetchedQueryData = await fetchExtractedQueryData(
105
+ `${prepassHost}/${pathname}?${newSearchParams.toString()}`
106
+ );
107
+
108
+ // Provide the query data to <PlasmicClientRootProvider>
109
+ return React.cloneElement(plasmicRootProvider, {
110
+ prefetchedQueryData,
111
+ });
78
112
  }
79
113
  ```
80
114
 
81
- Here, `fetchExtractedQueryData()` basically just hits the `/plasmic-ssr/` endpoint, and extracts the data from the json embedded in the `<script/>`.
115
+ `<ExtractPlasmicQueryData />` is a new client component from this package, which basically performs `extractPlasmicQueryData()` on its children, and then renders a `<script data-plasmic-prefetch-id/>` tag with the json of the extracted data. The helper function `withExtractPlasmicQueryData` will likely be moved into the package in the future.
116
+
117
+ Here, `fetchExtractedQueryData()` basically just hits the same endpoint with `?plasmicSsr=true`, and extracts the data from the json embedded in the `<script/>`.
82
118
 
83
119
  The `prepassHost` to use is read from `PLASMIC_PREPASS_HOST` or `VERCEL_URL`. `VERCEL_URL` is available when your site is deployed on Vercel; it is the generated deployment url.
84
120
 
85
- `@plasmicapp/nextjs-app-router` also comes with a `with-plasmic-prepass` command that you can use like this in your package.json:
121
+ 2. If you have static generation at build time, `@plasmicapp/nextjs-app-router` also comes with a `with-plasmic-prepass` command that you can use like this in your package.json:
86
122
 
87
123
  ```
88
124
  "script": {
@@ -105,5 +141,5 @@ The `PLASMIC_PREPASS_SERVER` environment variable will be set by with-plasmic-pr
105
141
  So...
106
142
 
107
143
  - At dev time, uses itself for extracting query data (hits `localhost:${PORT}`)
108
- - At build time, we start a parallel dev server.
144
+ - At build time, we start a parallel dev server via `with-plasmic-prepass`.
109
145
  - In production, with revalidation, it will also use itself for extracting query data (using `VERCEL_URL` as the prepass host).
package/dist/index.d.ts CHANGED
@@ -13,6 +13,4 @@ export declare function ExtractPlasmicQueryData(props: {
13
13
  children?: React_2.ReactNode;
14
14
  }): React_2.JSX.Element | null;
15
15
 
16
- export declare function fetchExtractedQueryData(url: string): Promise<any>;
17
-
18
16
  export { }
package/dist/index.esm.js CHANGED
@@ -1,42 +1,4 @@
1
1
  "use client";
2
- var __async = (__this, __arguments, generator) => {
3
- return new Promise((resolve, reject) => {
4
- var fulfilled = (value) => {
5
- try {
6
- step(generator.next(value));
7
- } catch (e) {
8
- reject(e);
9
- }
10
- };
11
- var rejected = (value) => {
12
- try {
13
- step(generator.throw(value));
14
- } catch (e) {
15
- reject(e);
16
- }
17
- };
18
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
19
- step((generator = generator.apply(__this, __arguments)).next());
20
- });
21
- };
22
-
23
- // src/extracted-data-fetcher.ts
24
- import { parse as parseHtml } from "node-html-parser";
25
- function fetchExtractedQueryData(url) {
26
- return __async(this, null, function* () {
27
- const res = yield fetch(url);
28
- if (res.status !== 200) {
29
- return void 0;
30
- }
31
- const html = yield res.text();
32
- const root = parseHtml(html);
33
- const script = root.querySelector("script[data-plasmic-prefetch-id]");
34
- if (script) {
35
- return JSON.parse(script.innerHTML);
36
- }
37
- return void 0;
38
- });
39
- }
40
2
 
41
3
  // src/ExtractPlasmicQueryData.tsx
42
4
  import { extractPlasmicQueryData } from "@plasmicapp/prepass";
@@ -49,7 +11,6 @@ function ExtractPlasmicQueryData(props) {
49
11
  );
50
12
  }
51
13
  const scriptId = `plasmic-prefetch-${React.useId()}`;
52
- console.log("SCRIPT ID", scriptId);
53
14
  if (typeof window === "undefined") {
54
15
  const data = React.use(
55
16
  extractPlasmicQueryData(/* @__PURE__ */ React.createElement(React.Fragment, null, children))
@@ -68,7 +29,6 @@ function ExtractPlasmicQueryData(props) {
68
29
  }
69
30
  }
70
31
  export {
71
- ExtractPlasmicQueryData,
72
- fetchExtractedQueryData
32
+ ExtractPlasmicQueryData
73
33
  };
74
34
  //# sourceMappingURL=index.esm.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/extracted-data-fetcher.ts", "../src/ExtractPlasmicQueryData.tsx"],
4
- "sourcesContent": ["import { parse as parseHtml } from \"node-html-parser\";\n\nexport async function fetchExtractedQueryData(url: string) {\n const res = await fetch(url);\n if (res.status !== 200) {\n return undefined;\n }\n\n const html = await res.text();\n const root = parseHtml(html);\n const script = root.querySelector(\"script[data-plasmic-prefetch-id]\");\n if (script) {\n return JSON.parse(script.innerHTML);\n }\n return undefined;\n}\n", "import { extractPlasmicQueryData } from \"@plasmicapp/prepass\";\nimport * as React from \"react\";\n\n/**\n * EXPERIMENTAL\n *\n * A component that serves the same purpose as extractPlasmicQueryData(), but from\n * React server components. This only works from frameworks that support\n * React.useId() and React.use() (like Next.js 13).\n *\n * The children of this component will be run through `extractPlasmicQueryData()`.\n */\nexport function ExtractPlasmicQueryData(props: { children?: React.ReactNode }) {\n const { children } = props;\n if (!React.useId || !(React as any).use) {\n throw new Error(\n `You can only use <ExtractPlasmicQueryData /> from server components.`\n );\n }\n const scriptId = `plasmic-prefetch-${React.useId()}`;\n console.log(\"SCRIPT ID\", scriptId);\n if (typeof window === \"undefined\") {\n const data: Record<string, any> = (React as any).use(\n extractPlasmicQueryData(<>{children}</>)\n );\n return (\n <>\n <script\n type=\"application/json\"\n dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }}\n data-plasmic-prefetch-id={scriptId}\n suppressHydrationWarning={true}\n />\n </>\n );\n } else {\n return null;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,iBAAiB;AAEnC,SAAsB,wBAAwB,KAAa;AAAA;AACzD,UAAM,MAAM,MAAM,MAAM,GAAG;AAC3B,QAAI,IAAI,WAAW,KAAK;AACtB,aAAO;AAAA,IACT;AAEA,UAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAM,OAAO,UAAU,IAAI;AAC3B,UAAM,SAAS,KAAK,cAAc,kCAAkC;AACpE,QAAI,QAAQ;AACV,aAAO,KAAK,MAAM,OAAO,SAAS;AAAA,IACpC;AACA,WAAO;AAAA,EACT;AAAA;;;ACfA,SAAS,+BAA+B;AACxC,YAAY,WAAW;AAWhB,SAAS,wBAAwB,OAAuC;AAC7E,QAAM,EAAE,SAAS,IAAI;AACrB,MAAI,CAAO,eAAS,CAAgB,WAAK;AACvC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,oBAA0B,YAAM;AACjD,UAAQ,IAAI,aAAa,QAAQ;AACjC,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,OAA2C;AAAA,MAC/C,wBAAwB,0DAAG,QAAS,CAAG;AAAA,IACzC;AACA,WACE,0DACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,yBAAyB,EAAE,QAAQ,KAAK,UAAU,IAAI,EAAE;AAAA,QACxD,4BAA0B;AAAA,QAC1B,0BAA0B;AAAA;AAAA,IAC5B,CACF;AAAA,EAEJ,OAAO;AACL,WAAO;AAAA,EACT;AACF;",
3
+ "sources": ["../src/ExtractPlasmicQueryData.tsx"],
4
+ "sourcesContent": ["import { extractPlasmicQueryData } from \"@plasmicapp/prepass\";\nimport * as React from \"react\";\n\n/**\n * EXPERIMENTAL\n *\n * A component that serves the same purpose as extractPlasmicQueryData(), but from\n * React server components. This only works from frameworks that support\n * React.useId() and React.use() (like Next.js 13).\n *\n * The children of this component will be run through `extractPlasmicQueryData()`.\n */\nexport function ExtractPlasmicQueryData(props: { children?: React.ReactNode }) {\n const { children } = props;\n if (!React.useId || !(React as any).use) {\n throw new Error(\n `You can only use <ExtractPlasmicQueryData /> from server components.`\n );\n }\n const scriptId = `plasmic-prefetch-${React.useId()}`;\n if (typeof window === \"undefined\") {\n const data: Record<string, any> = (React as any).use(\n extractPlasmicQueryData(<>{children}</>)\n );\n return (\n <>\n <script\n type=\"application/json\"\n dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }}\n data-plasmic-prefetch-id={scriptId}\n suppressHydrationWarning={true}\n />\n </>\n );\n } else {\n return null;\n }\n}\n"],
5
+ "mappings": ";;;AAAA,SAAS,+BAA+B;AACxC,YAAY,WAAW;AAWhB,SAAS,wBAAwB,OAAuC;AAC7E,QAAM,EAAE,SAAS,IAAI;AACrB,MAAI,CAAO,eAAS,CAAgB,WAAK;AACvC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,oBAA0B,YAAM;AACjD,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,OAA2C;AAAA,MAC/C,wBAAwB,0DAAG,QAAS,CAAG;AAAA,IACzC;AACA,WACE,0DACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,yBAAyB,EAAE,QAAQ,KAAK,UAAU,IAAI,EAAE;AAAA,QACxD,4BAA0B;AAAA,QAC1B,0BAA0B;AAAA;AAAA,IAC5B,CACF;AAAA,EAEJ,OAAO;AACL,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
package/dist/index.js CHANGED
@@ -27,53 +27,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  mod
28
28
  ));
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __async = (__this, __arguments, generator) => {
31
- return new Promise((resolve, reject) => {
32
- var fulfilled = (value) => {
33
- try {
34
- step(generator.next(value));
35
- } catch (e) {
36
- reject(e);
37
- }
38
- };
39
- var rejected = (value) => {
40
- try {
41
- step(generator.throw(value));
42
- } catch (e) {
43
- reject(e);
44
- }
45
- };
46
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
47
- step((generator = generator.apply(__this, __arguments)).next());
48
- });
49
- };
50
30
 
51
31
  // src/index.ts
52
32
  var src_exports = {};
53
33
  __export(src_exports, {
54
- ExtractPlasmicQueryData: () => ExtractPlasmicQueryData,
55
- fetchExtractedQueryData: () => fetchExtractedQueryData
34
+ ExtractPlasmicQueryData: () => ExtractPlasmicQueryData
56
35
  });
57
36
  module.exports = __toCommonJS(src_exports);
58
37
 
59
- // src/extracted-data-fetcher.ts
60
- var import_node_html_parser = require("node-html-parser");
61
- function fetchExtractedQueryData(url) {
62
- return __async(this, null, function* () {
63
- const res = yield fetch(url);
64
- if (res.status !== 200) {
65
- return void 0;
66
- }
67
- const html = yield res.text();
68
- const root = (0, import_node_html_parser.parse)(html);
69
- const script = root.querySelector("script[data-plasmic-prefetch-id]");
70
- if (script) {
71
- return JSON.parse(script.innerHTML);
72
- }
73
- return void 0;
74
- });
75
- }
76
-
77
38
  // src/ExtractPlasmicQueryData.tsx
78
39
  var import_prepass = require("@plasmicapp/prepass");
79
40
  var React = __toESM(require("react"));
@@ -85,7 +46,6 @@ function ExtractPlasmicQueryData(props) {
85
46
  );
86
47
  }
87
48
  const scriptId = `plasmic-prefetch-${React.useId()}`;
88
- console.log("SCRIPT ID", scriptId);
89
49
  if (typeof window === "undefined") {
90
50
  const data = React.use(
91
51
  (0, import_prepass.extractPlasmicQueryData)(/* @__PURE__ */ React.createElement(React.Fragment, null, children))
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "../src/extracted-data-fetcher.ts", "../src/ExtractPlasmicQueryData.tsx"],
4
- "sourcesContent": ["export * from \"./extracted-data-fetcher\";\nexport * from \"./ExtractPlasmicQueryData\";\n", "import { parse as parseHtml } from \"node-html-parser\";\n\nexport async function fetchExtractedQueryData(url: string) {\n const res = await fetch(url);\n if (res.status !== 200) {\n return undefined;\n }\n\n const html = await res.text();\n const root = parseHtml(html);\n const script = root.querySelector(\"script[data-plasmic-prefetch-id]\");\n if (script) {\n return JSON.parse(script.innerHTML);\n }\n return undefined;\n}\n", "import { extractPlasmicQueryData } from \"@plasmicapp/prepass\";\nimport * as React from \"react\";\n\n/**\n * EXPERIMENTAL\n *\n * A component that serves the same purpose as extractPlasmicQueryData(), but from\n * React server components. This only works from frameworks that support\n * React.useId() and React.use() (like Next.js 13).\n *\n * The children of this component will be run through `extractPlasmicQueryData()`.\n */\nexport function ExtractPlasmicQueryData(props: { children?: React.ReactNode }) {\n const { children } = props;\n if (!React.useId || !(React as any).use) {\n throw new Error(\n `You can only use <ExtractPlasmicQueryData /> from server components.`\n );\n }\n const scriptId = `plasmic-prefetch-${React.useId()}`;\n console.log(\"SCRIPT ID\", scriptId);\n if (typeof window === \"undefined\") {\n const data: Record<string, any> = (React as any).use(\n extractPlasmicQueryData(<>{children}</>)\n );\n return (\n <>\n <script\n type=\"application/json\"\n dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }}\n data-plasmic-prefetch-id={scriptId}\n suppressHydrationWarning={true}\n />\n </>\n );\n } else {\n return null;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,8BAAmC;AAEnC,SAAsB,wBAAwB,KAAa;AAAA;AACzD,UAAM,MAAM,MAAM,MAAM,GAAG;AAC3B,QAAI,IAAI,WAAW,KAAK;AACtB,aAAO;AAAA,IACT;AAEA,UAAM,OAAO,MAAM,IAAI,KAAK;AAC5B,UAAM,WAAO,wBAAAA,OAAU,IAAI;AAC3B,UAAM,SAAS,KAAK,cAAc,kCAAkC;AACpE,QAAI,QAAQ;AACV,aAAO,KAAK,MAAM,OAAO,SAAS;AAAA,IACpC;AACA,WAAO;AAAA,EACT;AAAA;;;ACfA,qBAAwC;AACxC,YAAuB;AAWhB,SAAS,wBAAwB,OAAuC;AAC7E,QAAM,EAAE,SAAS,IAAI;AACrB,MAAI,CAAO,eAAS,CAAgB,WAAK;AACvC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,oBAA0B,YAAM;AACjD,UAAQ,IAAI,aAAa,QAAQ;AACjC,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,OAA2C;AAAA,UAC/C,wCAAwB,0DAAG,QAAS,CAAG;AAAA,IACzC;AACA,WACE,0DACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,yBAAyB,EAAE,QAAQ,KAAK,UAAU,IAAI,EAAE;AAAA,QACxD,4BAA0B;AAAA,QAC1B,0BAA0B;AAAA;AAAA,IAC5B,CACF;AAAA,EAEJ,OAAO;AACL,WAAO;AAAA,EACT;AACF;",
6
- "names": ["parseHtml"]
3
+ "sources": ["../src/index.ts", "../src/ExtractPlasmicQueryData.tsx"],
4
+ "sourcesContent": ["export * from \"./ExtractPlasmicQueryData\";\n", "import { extractPlasmicQueryData } from \"@plasmicapp/prepass\";\nimport * as React from \"react\";\n\n/**\n * EXPERIMENTAL\n *\n * A component that serves the same purpose as extractPlasmicQueryData(), but from\n * React server components. This only works from frameworks that support\n * React.useId() and React.use() (like Next.js 13).\n *\n * The children of this component will be run through `extractPlasmicQueryData()`.\n */\nexport function ExtractPlasmicQueryData(props: { children?: React.ReactNode }) {\n const { children } = props;\n if (!React.useId || !(React as any).use) {\n throw new Error(\n `You can only use <ExtractPlasmicQueryData /> from server components.`\n );\n }\n const scriptId = `plasmic-prefetch-${React.useId()}`;\n if (typeof window === \"undefined\") {\n const data: Record<string, any> = (React as any).use(\n extractPlasmicQueryData(<>{children}</>)\n );\n return (\n <>\n <script\n type=\"application/json\"\n dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }}\n data-plasmic-prefetch-id={scriptId}\n suppressHydrationWarning={true}\n />\n </>\n );\n } else {\n return null;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,qBAAwC;AACxC,YAAuB;AAWhB,SAAS,wBAAwB,OAAuC;AAC7E,QAAM,EAAE,SAAS,IAAI;AACrB,MAAI,CAAO,eAAS,CAAgB,WAAK;AACvC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,oBAA0B,YAAM;AACjD,MAAI,OAAO,WAAW,aAAa;AACjC,UAAM,OAA2C;AAAA,UAC/C,wCAAwB,0DAAG,QAAS,CAAG;AAAA,IACzC;AACA,WACE,0DACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,yBAAyB,EAAE,QAAQ,KAAK,UAAU,IAAI,EAAE;AAAA,QACxD,4BAA0B;AAAA,QAC1B,0BAA0B;AAAA;AAAA,IAC5B,CACF;AAAA,EAEJ,OAAO;AACL,WAAO;AAAA,EACT;AACF;",
6
+ "names": []
7
7
  }
@@ -7561,14 +7561,17 @@ async function startDevServer(command2, port) {
7561
7561
  let started = false;
7562
7562
  return new Promise((resolve5, reject) => {
7563
7563
  devServerProcess.stdout?.on("data", (data) => {
7564
- if (!started && data.toString().includes("ready")) {
7564
+ if (!started && data.toString().toLowerCase().includes("ready")) {
7565
7565
  started = true;
7566
7566
  console.log(`Plasmic: Dev server started`);
7567
7567
  resolve5(devServerProcess);
7568
7568
  }
7569
7569
  });
7570
7570
  devServerProcess.stderr?.on("data", (data) => {
7571
- reject(new Error(`Error starting dev server: ${data.toString()}`));
7571
+ if (data.toString().toLowerCase().includes("error")) {
7572
+ console.log(`Plasmic: Dev server failed to start`);
7573
+ reject(new Error(`Error starting dev server: ${data.toString()}`));
7574
+ }
7572
7575
  });
7573
7576
  });
7574
7577
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/nextjs-app-router",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -25,7 +25,7 @@
25
25
  "prepare": "if-env PREPARE_NO_BUILD=true || yarn build"
26
26
  },
27
27
  "dependencies": {
28
- "@plasmicapp/prepass": "1.0.14",
28
+ "@plasmicapp/prepass": "1.0.16",
29
29
  "fkill": "^8.1.0",
30
30
  "get-port": "^7.0.0",
31
31
  "node-html-parser": "^6.1.5",
@@ -70,5 +70,5 @@
70
70
  "react": "^18.2.0",
71
71
  "typescript": "^5.2.2"
72
72
  },
73
- "gitHead": "d2b7e30940121148fb5bd9055246e77f74503f80"
73
+ "gitHead": "c49dab6784fc0e4658cc673be1a031f7424a3bfa"
74
74
  }