create-plasmic-app 0.0.143 → 0.0.145

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 (90) hide show
  1. package/cpa-out/gatsby-codegen-js/package.json +2 -2
  2. package/cpa-out/gatsby-codegen-js/plasmic.json +2 -2
  3. package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicButton.jsx +1 -0
  4. package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +1 -0
  5. package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +7 -2
  6. package/cpa-out/gatsby-codegen-ts/package.json +2 -2
  7. package/cpa-out/gatsby-codegen-ts/plasmic.json +2 -2
  8. package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicButton.tsx +1 -0
  9. package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +1 -0
  10. package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +7 -2
  11. package/cpa-out/gatsby-loader-js/gatsby-config.js +25 -21
  12. package/cpa-out/gatsby-loader-js/gatsby-node.js +58 -0
  13. package/cpa-out/gatsby-loader-js/package.json +1 -1
  14. package/cpa-out/gatsby-loader-js/src/plasmic-init.js +4 -4
  15. package/cpa-out/gatsby-loader-js/src/templates/defaultPlasmicPage.jsx +2 -1
  16. package/cpa-out/gatsby-loader-ts/gatsby-config.ts +20 -22
  17. package/cpa-out/gatsby-loader-ts/gatsby-node.ts +61 -0
  18. package/cpa-out/gatsby-loader-ts/package.json +1 -1
  19. package/cpa-out/gatsby-loader-ts/src/templates/defaultPlasmicPage.tsx +6 -2
  20. package/cpa-out/nextjs-app-codegen-js/app/dynamic/[slug]/page.jsx +11 -3
  21. package/cpa-out/nextjs-app-codegen-js/app/layout.jsx +3 -4
  22. package/cpa-out/nextjs-app-codegen-js/app/page.jsx +4 -3
  23. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicButton.jsx +1 -0
  24. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +1 -0
  25. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.jsx +1 -1
  26. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +7 -2
  27. package/cpa-out/nextjs-app-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepageServer.jsx +1 -1
  28. package/cpa-out/nextjs-app-codegen-js/package.json +2 -2
  29. package/cpa-out/nextjs-app-codegen-js/plasmic-init-client.jsx +0 -1
  30. package/cpa-out/nextjs-app-codegen-js/plasmic.json +2 -2
  31. package/cpa-out/nextjs-app-codegen-ts/app/dynamic/[slug]/page.tsx +12 -4
  32. package/cpa-out/nextjs-app-codegen-ts/app/layout.tsx +3 -4
  33. package/cpa-out/nextjs-app-codegen-ts/app/page.tsx +4 -4
  34. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicButton.tsx +1 -0
  35. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +1 -0
  36. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPageServer.tsx +1 -1
  37. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +7 -2
  38. package/cpa-out/nextjs-app-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepageServer.tsx +1 -1
  39. package/cpa-out/nextjs-app-codegen-ts/package.json +2 -2
  40. package/cpa-out/nextjs-app-codegen-ts/plasmic-init-client.tsx +1 -1
  41. package/cpa-out/nextjs-app-codegen-ts/plasmic.json +2 -2
  42. package/cpa-out/nextjs-app-loader-js/package.json +1 -1
  43. package/cpa-out/nextjs-app-loader-js/plasmic-init.js +5 -0
  44. package/cpa-out/nextjs-app-loader-ts/package.json +1 -1
  45. package/cpa-out/nextjs-app-loader-ts/plasmic-init.ts +5 -0
  46. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicButton.jsx +1 -0
  47. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +1 -0
  48. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +7 -2
  49. package/cpa-out/nextjs-pages-codegen-js/package.json +2 -2
  50. package/cpa-out/nextjs-pages-codegen-js/plasmic.json +2 -2
  51. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicButton.tsx +1 -0
  52. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +1 -0
  53. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +7 -2
  54. package/cpa-out/nextjs-pages-codegen-ts/package.json +2 -2
  55. package/cpa-out/nextjs-pages-codegen-ts/plasmic.json +2 -2
  56. package/cpa-out/nextjs-pages-loader-js/package.json +1 -1
  57. package/cpa-out/nextjs-pages-loader-ts/package.json +1 -1
  58. package/cpa-out/react-codegen-js/package.json +2 -2
  59. package/cpa-out/react-codegen-js/plasmic.json +2 -2
  60. package/cpa-out/react-codegen-ts/package.json +2 -2
  61. package/cpa-out/react-codegen-ts/plasmic.json +2 -2
  62. package/cpa-out/tanstack-codegen-ts/package.json +7 -8
  63. package/cpa-out/tanstack-codegen-ts/plasmic.json +2 -2
  64. package/cpa-out/tanstack-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicButton.tsx +1 -5
  65. package/cpa-out/tanstack-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +1 -2
  66. package/cpa-out/tanstack-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +7 -5
  67. package/cpa-out/tanstack-codegen-ts/src/components/plasmic/create_plasmic_app/PlasmicStyleTokensProvider.tsx +2 -0
  68. package/cpa-out/tanstack-codegen-ts/src/router.tsx +0 -1
  69. package/cpa-out/tanstack-codegen-ts/tsconfig.json +0 -1
  70. package/cpa-out/tanstack-codegen-ts/vite.config.ts +1 -2
  71. package/dist/gatsby/gatsby.js +4 -67
  72. package/dist/gatsby/template.d.ts +2 -1
  73. package/dist/gatsby/template.js +122 -25
  74. package/dist/nextjs/nextjs.js +2 -0
  75. package/dist/nextjs/templates/app-codegen/plasmic-init-client.js +1 -2
  76. package/dist/tanstack/tanstack.js +11 -1
  77. package/package.json +2 -2
  78. package/src/gatsby/gatsby.ts +16 -28
  79. package/src/gatsby/template.ts +139 -29
  80. package/src/nextjs/nextjs.ts +3 -0
  81. package/src/nextjs/templates/app-codegen/plasmic-init-client.ts +4 -2
  82. package/src/tanstack/tanstack.ts +11 -1
  83. package/cpa-out/nextjs-app-codegen-js/app/layout.js +0 -28
  84. package/cpa-out/tanstack-codegen-ts/src/components/Footer.tsx +0 -44
  85. package/cpa-out/tanstack-codegen-ts/src/components/Header.tsx +0 -78
  86. package/cpa-out/tanstack-codegen-ts/src/components/ThemeToggle.tsx +0 -81
  87. /package/cpa-out/gatsby-codegen-js/src/components/plasmic/create_plasmic_app/icons/{PlasmicIcon__Checksvg.jsx → PlasmicIcon__CheckSvg.jsx} +0 -0
  88. /package/cpa-out/gatsby-codegen-ts/src/components/plasmic/create_plasmic_app/icons/{PlasmicIcon__Checksvg.tsx → PlasmicIcon__CheckSvg.tsx} +0 -0
  89. /package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/icons/{PlasmicIcon__Checksvg.jsx → PlasmicIcon__CheckSvg.jsx} +0 -0
  90. /package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/icons/{PlasmicIcon__Checksvg.tsx → PlasmicIcon__CheckSvg.tsx} +0 -0
@@ -14,8 +14,8 @@
14
14
  "clean": "gatsby clean"
15
15
  },
16
16
  "dependencies": {
17
- "@plasmicapp/cli": "^0.1.359",
18
- "@plasmicapp/react-web": "^0.2.425",
17
+ "@plasmicapp/cli": "^0.1.361",
18
+ "@plasmicapp/react-web": "^1.0.6",
19
19
  "gatsby": "^5.14.6",
20
20
  "gatsby-plugin-react-helmet": "^6.16.0",
21
21
  "react": "^18.2.0",
@@ -135,6 +135,6 @@
135
135
  "gatsbyConfig": {
136
136
  "pagesDir": "../pages"
137
137
  },
138
- "cliVersion": "0.1.359",
139
- "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.359/dist/plasmic.schema.json"
138
+ "cliVersion": "0.1.361",
139
+ "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.361/dist/plasmic.schema.json"
140
140
  }
@@ -137,6 +137,7 @@ function PlasmicButton__RenderFunc(props) {
137
137
  className={classNames(
138
138
  projectcss.all,
139
139
  projectcss.button,
140
+ projectcss.button__47tFX,
140
141
  projectcss.root_reset,
141
142
  projectcss.plasmic_default_styles,
142
143
  projectcss.plasmic_mixins,
@@ -111,6 +111,7 @@ function PlasmicDynamicPage__RenderFunc(props) {
111
111
  className={classNames(
112
112
  projectcss.all,
113
113
  projectcss.h1,
114
+ projectcss.h1__47tFX,
114
115
  projectcss.__wab_text,
115
116
  sty.h1
116
117
  )}
@@ -114,6 +114,7 @@ function PlasmicHomepage__RenderFunc(props) {
114
114
  className={classNames(
115
115
  projectcss.all,
116
116
  projectcss.h1,
117
+ projectcss.h1__47tFX,
117
118
  projectcss.__wab_text,
118
119
  sty.h1
119
120
  )}
@@ -137,7 +138,9 @@ function PlasmicHomepage__RenderFunc(props) {
137
138
  }
138
139
  </React.Fragment>
139
140
  <span
140
- className={"plasmic_default__all plasmic_default__span"}
141
+ className={
142
+ "plasmic_default__all plasmic_default__span plasmic_default__span__47tFX"
143
+ }
141
144
  style={{ fontWeight: 700 }}
142
145
  >
143
146
  {"Therefore, please avoid changing this project."}
@@ -151,7 +154,9 @@ function PlasmicHomepage__RenderFunc(props) {
151
154
  }
152
155
  </React.Fragment>
153
156
  <span
154
- className={"plasmic_default__all plasmic_default__span"}
157
+ className={
158
+ "plasmic_default__all plasmic_default__span plasmic_default__span__47tFX"
159
+ }
155
160
  style={{ fontWeight: 700 }}
156
161
  >
157
162
  {"Code"}
@@ -15,8 +15,8 @@
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
17
  "dependencies": {
18
- "@plasmicapp/cli": "^0.1.359",
19
- "@plasmicapp/react-web": "^0.2.425",
18
+ "@plasmicapp/cli": "^0.1.361",
19
+ "@plasmicapp/react-web": "^1.0.6",
20
20
  "gatsby": "^5.14.6",
21
21
  "gatsby-plugin-react-helmet": "^6.16.0",
22
22
  "react": "^18.2.0",
@@ -135,6 +135,6 @@
135
135
  "gatsbyConfig": {
136
136
  "pagesDir": "../pages"
137
137
  },
138
- "cliVersion": "0.1.359",
139
- "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.359/dist/plasmic.schema.json"
138
+ "cliVersion": "0.1.361",
139
+ "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.361/dist/plasmic.schema.json"
140
140
  }
@@ -275,6 +275,7 @@ function PlasmicButton__RenderFunc(props: {
275
275
  className={classNames(
276
276
  projectcss.all,
277
277
  projectcss.button,
278
+ projectcss.button__47tFX,
278
279
  projectcss.root_reset,
279
280
  projectcss.plasmic_default_styles,
280
281
  projectcss.plasmic_mixins,
@@ -193,6 +193,7 @@ function PlasmicDynamicPage__RenderFunc(props: {
193
193
  className={classNames(
194
194
  projectcss.all,
195
195
  projectcss.h1,
196
+ projectcss.h1__47tFX,
196
197
  projectcss.__wab_text,
197
198
  sty.h1
198
199
  )}
@@ -197,6 +197,7 @@ function PlasmicHomepage__RenderFunc(props: {
197
197
  className={classNames(
198
198
  projectcss.all,
199
199
  projectcss.h1,
200
+ projectcss.h1__47tFX,
200
201
  projectcss.__wab_text,
201
202
  sty.h1
202
203
  )}
@@ -220,7 +221,9 @@ function PlasmicHomepage__RenderFunc(props: {
220
221
  }
221
222
  </React.Fragment>
222
223
  <span
223
- className={"plasmic_default__all plasmic_default__span"}
224
+ className={
225
+ "plasmic_default__all plasmic_default__span plasmic_default__span__47tFX"
226
+ }
224
227
  style={{ fontWeight: 700 }}
225
228
  >
226
229
  {"Therefore, please avoid changing this project."}
@@ -234,7 +237,9 @@ function PlasmicHomepage__RenderFunc(props: {
234
237
  }
235
238
  </React.Fragment>
236
239
  <span
237
- className={"plasmic_default__all plasmic_default__span"}
240
+ className={
241
+ "plasmic_default__all plasmic_default__span plasmic_default__span__47tFX"
242
+ }
238
243
  style={{ fontWeight: 700 }}
239
244
  >
240
245
  {"Code"}
@@ -1,25 +1,29 @@
1
- /**
2
- * @type {import('gatsby').GatsbyConfig}
3
- */
4
- module.exports = {
1
+ const path = require("path");
2
+
3
+ /** @type {import("gatsby").GatsbyConfig} */
4
+ const config = {
5
5
  siteMetadata: {
6
6
  siteUrl: `https://www.yourdomain.tld`,
7
7
  },
8
- plugins: [{
9
- resolve: "@plasmicapp/loader-gatsby",
10
- options: {
11
- projects: [
12
- {
13
- id: "47tFXWjN2C4NyHFGGpaYQ3",
14
- token: "7BRFratDxPLMGZHnd2grV5QP6mlHcZ1AK3BJSIeh7xzUlHgWh25XpgXvUaKAqHXFMXQQuzpADqboibF6nqNWQ",
8
+ graphqlTypegen: true,
9
+ plugins: [
10
+ {
11
+ resolve: "@plasmicapp/loader-gatsby",
12
+ options: {
13
+ projects: [
14
+ {
15
+ id: "47tFXWjN2C4NyHFGGpaYQ3",
16
+ token: "7BRFratDxPLMGZHnd2grV5QP6mlHcZ1AK3BJSIeh7xzUlHgWh25XpgXvUaKAqHXFMXQQuzpADqboibF6nqNWQ",
17
+ },
18
+ ], // An array of project ids.
19
+ preview: false,
20
+ defaultPlasmicPage: path.resolve("./src/templates/defaultPlasmicPage.jsx"),
15
21
  },
16
- ], // An array of project ids.
17
- preview: false,
18
- defaultPlasmicPage: require.resolve("./src/templates/defaultPlasmicPage.jsx"),
19
- },
20
- },
21
- {
22
- resolve: "gatsby-plugin-react-helmet",
23
- }
24
- ]
25
- }
22
+ },
23
+ {
24
+ resolve: "gatsby-plugin-react-helmet",
25
+ },
26
+ ],
27
+ };
28
+
29
+ module.exports = config;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Implement Gatsby's Node APIs in this file.
3
+ *
4
+ * See: https://www.gatsbyjs.com/docs/node-apis/
5
+ *
6
+ * `onCreatePage` runs `extractPlasmicQueryData` at build time so that the
7
+ * SSG'd HTML for each Plasmic page contains its actual rendered content,
8
+ * rather than the `<Suspense fallback>` ("Loading...") of unresolved data
9
+ * queries.
10
+ */
11
+ const React = require("react");
12
+ const {
13
+ extractPlasmicQueryData,
14
+ PlasmicComponent,
15
+ PlasmicRootProvider,
16
+ } = require("@plasmicapp/loader-gatsby");
17
+ const gatsbyConfig = require("./gatsby-config");
18
+ const { initPlasmicLoaderWithRegistrations } = require("./src/plasmic-init");
19
+
20
+ const plasmicLoaderOptions = gatsbyConfig.plugins.find(
21
+ (p) => p && p.resolve === "@plasmicapp/loader-gatsby"
22
+ ).options;
23
+ const PLASMIC = initPlasmicLoaderWithRegistrations(plasmicLoaderOptions);
24
+
25
+ exports.onCreatePage = async ({ page, actions }) => {
26
+ if (page.component !== plasmicLoaderOptions.defaultPlasmicPage) {
27
+ return;
28
+ }
29
+ if (page.context?.queryCache) {
30
+ return;
31
+ }
32
+
33
+ const componentData = await PLASMIC.maybeFetchComponentData(page.path);
34
+ if (!componentData) {
35
+ return;
36
+ }
37
+ const meta = componentData.entryCompMetas[0];
38
+
39
+ const queryCache = await extractPlasmicQueryData(
40
+ React.createElement(
41
+ PlasmicRootProvider,
42
+ {
43
+ loader: PLASMIC,
44
+ prefetchedData: componentData,
45
+ pageRoute: meta.path,
46
+ pageParams: meta.params,
47
+ pageQuery: {},
48
+ },
49
+ React.createElement(PlasmicComponent, { component: meta.displayName })
50
+ )
51
+ );
52
+
53
+ actions.deletePage(page);
54
+ actions.createPage({
55
+ ...page,
56
+ context: { ...page.context, queryCache },
57
+ });
58
+ };
@@ -14,7 +14,7 @@
14
14
  "clean": "gatsby clean"
15
15
  },
16
16
  "dependencies": {
17
- "@plasmicapp/loader-gatsby": "^1.0.418",
17
+ "@plasmicapp/loader-gatsby": "^2.0.3",
18
18
  "gatsby": "^5.14.6",
19
19
  "gatsby-plugin-react-helmet": "^6.16.0",
20
20
  "react": "^18.2.0",
@@ -1,8 +1,6 @@
1
- import {
2
- initPlasmicLoader,
3
- } from "@plasmicapp/loader-gatsby";
1
+ const { initPlasmicLoader } = require("@plasmicapp/loader-gatsby");
4
2
 
5
- export function initPlasmicLoaderWithRegistrations(plasmicOptions) {
3
+ function initPlasmicLoaderWithRegistrations(plasmicOptions) {
6
4
  const PLASMIC = initPlasmicLoader(plasmicOptions);
7
5
 
8
6
  // You can register any code components that you want to use here; see
@@ -16,3 +14,5 @@ export function initPlasmicLoaderWithRegistrations(plasmicOptions) {
16
14
 
17
15
  return PLASMIC;
18
16
  }
17
+
18
+ module.exports = { initPlasmicLoaderWithRegistrations };
@@ -15,7 +15,7 @@ export const query = graphql`
15
15
  `;
16
16
 
17
17
 
18
- const PlasmicGatsbyPage = ({ data, location }) => {
18
+ const PlasmicGatsbyPage = ({ data, location, pageContext }) => {
19
19
  const {
20
20
  plasmicComponents,
21
21
  plasmicOptions,
@@ -26,6 +26,7 @@ const PlasmicGatsbyPage = ({ data, location }) => {
26
26
  <PlasmicRootProvider
27
27
  loader={initPlasmicLoaderWithRegistrations(plasmicOptions)}
28
28
  prefetchedData={plasmicComponents}
29
+ prefetchedQueryData={pageContext.queryCache}
29
30
  pageRoute={pageMeta.path}
30
31
  pageParams={pageMeta.params}
31
32
  pageQuery={Object.fromEntries(new URLSearchParams(location.search))}
@@ -1,31 +1,29 @@
1
1
  import path from "path";
2
- import type { GatsbyConfig } from "gatsby"
2
+ import type { GatsbyConfig } from "gatsby";
3
3
 
4
4
  const config: GatsbyConfig = {
5
5
  siteMetadata: {
6
6
  siteUrl: `https://www.yourdomain.tld`,
7
7
  },
8
- // More easily incorporate content into your pages through automatic TypeScript type generation and better GraphQL IntelliSense.
9
- // If you use VSCode you can also use the GraphQL plugin
10
- // Learn more at: https://gatsby.dev/graphql-typegen
11
8
  graphqlTypegen: true,
12
- plugins: [{
13
- resolve: "@plasmicapp/loader-gatsby",
14
- options: {
15
- projects: [
16
- {
17
- id: "47tFXWjN2C4NyHFGGpaYQ3",
18
- token: "7BRFratDxPLMGZHnd2grV5QP6mlHcZ1AK3BJSIeh7xzUlHgWh25XpgXvUaKAqHXFMXQQuzpADqboibF6nqNWQ",
9
+ plugins: [
10
+ {
11
+ resolve: "@plasmicapp/loader-gatsby",
12
+ options: {
13
+ projects: [
14
+ {
15
+ id: "47tFXWjN2C4NyHFGGpaYQ3",
16
+ token: "7BRFratDxPLMGZHnd2grV5QP6mlHcZ1AK3BJSIeh7xzUlHgWh25XpgXvUaKAqHXFMXQQuzpADqboibF6nqNWQ",
17
+ },
18
+ ], // An array of project ids.
19
+ preview: false,
20
+ defaultPlasmicPage: path.resolve("./src/templates/defaultPlasmicPage.tsx"),
19
21
  },
20
- ], // An array of project ids.
21
- preview: false,
22
- defaultPlasmicPage: path.resolve("./src/templates/defaultPlasmicPage.tsx"),
23
- },
24
- },
25
- {
26
- resolve: "gatsby-plugin-react-helmet",
27
- }
28
- ]
29
- }
22
+ },
23
+ {
24
+ resolve: "gatsby-plugin-react-helmet",
25
+ },
26
+ ],
27
+ };
30
28
 
31
- export default config
29
+ export default config;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Implement Gatsby's Node APIs in this file.
3
+ *
4
+ * See: https://www.gatsbyjs.com/docs/node-apis/
5
+ *
6
+ * `onCreatePage` runs `extractPlasmicQueryData` at build time so that the
7
+ * SSG'd HTML for each Plasmic page contains its actual rendered content,
8
+ * rather than the `<Suspense fallback>` ("Loading...") of unresolved data
9
+ * queries.
10
+ */
11
+ import type { CreatePageArgs } from "gatsby";
12
+ import * as React from "react";
13
+ import {
14
+ extractPlasmicQueryData,
15
+ PlasmicComponent,
16
+ PlasmicRootProvider,
17
+ } from "@plasmicapp/loader-gatsby";
18
+ import type { GatsbyPluginOptions } from "@plasmicapp/loader-gatsby";
19
+ import gatsbyConfig from "./gatsby-config";
20
+ import { initPlasmicLoaderWithRegistrations } from "./src/plasmic-init";
21
+ import type { PlasmicGatsbyPageProps } from "./src/templates/defaultPlasmicPage";
22
+
23
+ const plasmicLoaderOptions = gatsbyConfig.plugins.find(
24
+ (p) => p && p.resolve === "@plasmicapp/loader-gatsby"
25
+ )!.options as GatsbyPluginOptions;
26
+ const PLASMIC = initPlasmicLoaderWithRegistrations(plasmicLoaderOptions);
27
+
28
+ export const onCreatePage = async ({ page, actions }: CreatePageArgs<PlasmicGatsbyPageProps["pageContext"]>) => {
29
+ if (page.component !== plasmicLoaderOptions.defaultPlasmicPage) {
30
+ return;
31
+ }
32
+ if (page.context?.queryCache) {
33
+ return;
34
+ }
35
+
36
+ const componentData = await PLASMIC.maybeFetchComponentData(page.path);
37
+ if (!componentData) {
38
+ return;
39
+ }
40
+ const meta = componentData.entryCompMetas[0];
41
+
42
+ const queryCache = await extractPlasmicQueryData(
43
+ React.createElement(
44
+ PlasmicRootProvider,
45
+ {
46
+ loader: PLASMIC,
47
+ prefetchedData: componentData,
48
+ pageRoute: meta.path,
49
+ pageParams: meta.params,
50
+ pageQuery: {},
51
+ },
52
+ React.createElement(PlasmicComponent, { component: meta.displayName })
53
+ )
54
+ );
55
+
56
+ actions.deletePage(page);
57
+ actions.createPage({
58
+ ...page,
59
+ context: { ...page.context, queryCache },
60
+ });
61
+ };
@@ -15,7 +15,7 @@
15
15
  "typecheck": "tsc --noEmit"
16
16
  },
17
17
  "dependencies": {
18
- "@plasmicapp/loader-gatsby": "^1.0.418",
18
+ "@plasmicapp/loader-gatsby": "^2.0.3",
19
19
  "gatsby": "^5.14.6",
20
20
  "gatsby-plugin-react-helmet": "^6.16.0",
21
21
  "react": "^18.2.0",
@@ -16,14 +16,17 @@ export const query = graphql`
16
16
  }
17
17
  `;
18
18
 
19
- interface PlasmicGatsbyPageProps extends PageProps {
19
+ export interface PlasmicGatsbyPageProps extends PageProps {
20
20
  data: {
21
21
  plasmicOptions: InitOptions
22
22
  plasmicComponents: ComponentRenderData
23
23
  }
24
+ pageContext: {
25
+ queryCache?: Record<string, any>
26
+ }
24
27
  }
25
28
 
26
- const PlasmicGatsbyPage = ({ data, location }: PlasmicGatsbyPageProps) => {
29
+ const PlasmicGatsbyPage = ({ data, location, pageContext }: PlasmicGatsbyPageProps) => {
27
30
  const {
28
31
  plasmicComponents,
29
32
  plasmicOptions,
@@ -34,6 +37,7 @@ const PlasmicGatsbyPage = ({ data, location }: PlasmicGatsbyPageProps) => {
34
37
  <PlasmicRootProvider
35
38
  loader={initPlasmicLoaderWithRegistrations(plasmicOptions)}
36
39
  prefetchedData={plasmicComponents}
40
+ prefetchedQueryData={pageContext.queryCache}
37
41
  pageRoute={pageMeta.path}
38
42
  pageParams={pageMeta.params}
39
43
  pageQuery={Object.fromEntries(new URLSearchParams(location.search))}
@@ -7,6 +7,13 @@ import {
7
7
  makeAppRouterPageCtx,
8
8
  generateDynamicMetadata
9
9
  } from "../../../components/plasmic/create_plasmic_app/PlasmicDynamicPageServer";
10
+ // Uncomment and populate to statically pre-render this route at build time.
11
+ // Each entry should be an object whose keys match the dynamic segments in the route path.
12
+ // See https://nextjs.org/docs/app/api-reference/functions/generate-static-params
13
+ //
14
+ // export async function generateStaticParams() {
15
+ // return [];
16
+ // }
10
17
 
11
18
  export async function generateMetadata({ params, searchParams }, parent) {
12
19
  const ctx = await makeAppRouterPageCtx({ params, searchParams });
@@ -31,11 +38,12 @@ async function DynamicPage({ params, searchParams }) {
31
38
  // variant context providers. These wrappers may be moved to
32
39
  // Next.js Custom App component
33
40
  // (https://nextjs.org/docs/advanced-features/custom-app).
41
+ const ctx = await makeAppRouterPageCtx({ params, searchParams });
34
42
  return (
35
43
  <PageParamsProvider__
36
- route="/dynamic/[slug]"
37
- params={await params}
38
- query={await searchParams}
44
+ route={ctx.pageRoute}
45
+ params={ctx.params}
46
+ query={ctx.query}
39
47
  >
40
48
  <PlasmicDynamicPageServer />
41
49
  </PageParamsProvider__>
@@ -1,6 +1,5 @@
1
1
  import '@/app/globals.css'
2
- import { PlasmicRootProvider } from "@plasmicapp/react-web";
3
- import Link from "next/link";
2
+ import { ClientPlasmicRootProvider } from "@/plasmic-init-client";
4
3
 
5
4
  export default function RootLayout({
6
5
  children,
@@ -8,9 +7,9 @@ export default function RootLayout({
8
7
  return (
9
8
  <html lang="en">
10
9
  <body>
11
- <PlasmicRootProvider Link={Link}>
10
+ <ClientPlasmicRootProvider>
12
11
  {children}
13
- </PlasmicRootProvider>
12
+ </ClientPlasmicRootProvider>
14
13
  </body>
15
14
  </html>
16
15
  );
@@ -31,11 +31,12 @@ async function Homepage({ params, searchParams }) {
31
31
  // variant context providers. These wrappers may be moved to
32
32
  // Next.js Custom App component
33
33
  // (https://nextjs.org/docs/advanced-features/custom-app).
34
+ const ctx = await makeAppRouterPageCtx({ params, searchParams });
34
35
  return (
35
36
  <PageParamsProvider__
36
- route="/"
37
- params={await params}
38
- query={await searchParams}
37
+ route={ctx.pageRoute}
38
+ params={ctx.params}
39
+ query={ctx.query}
39
40
  >
40
41
  <PlasmicHomepageServer />
41
42
  </PageParamsProvider__>
@@ -147,6 +147,7 @@ function PlasmicButton__RenderFunc(props) {
147
147
  className={classNames(
148
148
  projectcss.all,
149
149
  projectcss.button,
150
+ projectcss.button__47tFX,
150
151
  projectcss.root_reset,
151
152
  projectcss.plasmic_default_styles,
152
153
  projectcss.plasmic_mixins,
@@ -116,6 +116,7 @@ function PlasmicDynamicPage__RenderFunc(props) {
116
116
  className={classNames(
117
117
  projectcss.all,
118
118
  projectcss.h1,
119
+ projectcss.h1__47tFX,
119
120
  projectcss.__wab_text,
120
121
  sty.h1
121
122
  )}
@@ -46,7 +46,7 @@ export async function makeAppRouterPageCtx({ params, searchParams }) {
46
46
  pageRoute,
47
47
  pagePath,
48
48
  params: pageParams,
49
- query: (await searchParams) ?? {}
49
+ query: {}
50
50
  };
51
51
  return ctx;
52
52
  }
@@ -119,6 +119,7 @@ function PlasmicHomepage__RenderFunc(props) {
119
119
  className={classNames(
120
120
  projectcss.all,
121
121
  projectcss.h1,
122
+ projectcss.h1__47tFX,
122
123
  projectcss.__wab_text,
123
124
  sty.h1
124
125
  )}
@@ -142,7 +143,9 @@ function PlasmicHomepage__RenderFunc(props) {
142
143
  }
143
144
  </React.Fragment>
144
145
  <span
145
- className={"plasmic_default__all plasmic_default__span"}
146
+ className={
147
+ "plasmic_default__all plasmic_default__span plasmic_default__span__47tFX"
148
+ }
146
149
  style={{ fontWeight: 700 }}
147
150
  >
148
151
  {"Therefore, please avoid changing this project."}
@@ -156,7 +159,9 @@ function PlasmicHomepage__RenderFunc(props) {
156
159
  }
157
160
  </React.Fragment>
158
161
  <span
159
- className={"plasmic_default__all plasmic_default__span"}
162
+ className={
163
+ "plasmic_default__all plasmic_default__span plasmic_default__span__47tFX"
164
+ }
160
165
  style={{ fontWeight: 700 }}
161
166
  >
162
167
  {"Code"}
@@ -46,7 +46,7 @@ export async function makeAppRouterPageCtx({ params, searchParams }) {
46
46
  pageRoute,
47
47
  pagePath,
48
48
  params: pageParams,
49
- query: (await searchParams) ?? {}
49
+ query: {}
50
50
  };
51
51
  return ctx;
52
52
  }
@@ -9,8 +9,8 @@
9
9
  "lint": "next lint"
10
10
  },
11
11
  "dependencies": {
12
- "@plasmicapp/cli": "^0.1.359",
13
- "@plasmicapp/react-web": "^0.2.425",
12
+ "@plasmicapp/cli": "^0.1.361",
13
+ "@plasmicapp/react-web": "^1.0.6",
14
14
  "next": "14.2.35",
15
15
  "react": "^18",
16
16
  "react-dom": "^18"
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
 
3
- import * as React from "react";
4
3
  import { PlasmicRootProvider } from "@plasmicapp/react-web";
5
4
  import Link from "next/link";
6
5
 
@@ -143,6 +143,6 @@
143
143
  "nextjsConfig": {
144
144
  "pagesDir": "../app"
145
145
  },
146
- "cliVersion": "0.1.359",
147
- "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.359/dist/plasmic.schema.json"
146
+ "cliVersion": "0.1.361",
147
+ "$schema": "https://unpkg.com/@plasmicapp/cli@0.1.361/dist/plasmic.schema.json"
148
148
  }
@@ -9,9 +9,16 @@ import {
9
9
  generateDynamicMetadata,
10
10
  DynamicPageServerSkeletonProps
11
11
  } from "../../../components/plasmic/create_plasmic_app/PlasmicDynamicPageServer";
12
-
13
12
  import type { Metadata, ResolvingMetadata } from "next";
14
13
 
14
+ // Uncomment and populate to statically pre-render this route at build time.
15
+ // Each entry should be an object whose keys match the dynamic segments in the route path.
16
+ // See https://nextjs.org/docs/app/api-reference/functions/generate-static-params
17
+ //
18
+ // export async function generateStaticParams() {
19
+ // return [];
20
+ // }
21
+
15
22
  export async function generateMetadata(
16
23
  { params, searchParams }: DynamicPageServerSkeletonProps,
17
24
  parent: ResolvingMetadata
@@ -43,11 +50,12 @@ async function DynamicPage({
43
50
  // Next.js Custom App component
44
51
  // (https://nextjs.org/docs/advanced-features/custom-app).
45
52
 
53
+ const ctx = await makeAppRouterPageCtx({ params, searchParams });
46
54
  return (
47
55
  <PageParamsProvider__
48
- route="/dynamic/[slug]"
49
- params={await params}
50
- query={await searchParams}
56
+ route={ctx.pageRoute}
57
+ params={ctx.params}
58
+ query={ctx.query}
51
59
  >
52
60
  <PlasmicDynamicPageServer />
53
61
  </PageParamsProvider__>