create-plasmic-app 0.0.91 → 0.0.93

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 (50) hide show
  1. package/cpa-out/nextjs-app-loader-js/pages/[[...catchall]].jsx +68 -0
  2. package/cpa-out/nextjs-app-loader-js/pages/api/hello.js +5 -0
  3. package/cpa-out/nextjs-app-loader-js/pages/plasmic-host.jsx +7 -0
  4. package/cpa-out/nextjs-app-loader-ts/pages/[[...catchall]].tsx +72 -0
  5. package/cpa-out/nextjs-app-loader-ts/pages/api/hello.ts +13 -0
  6. package/cpa-out/nextjs-app-loader-ts/pages/plasmic-host.tsx +7 -0
  7. package/cpa-out/nextjs-pages-codegen-js/components/Button.jsx +1 -3
  8. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicButton.jsx +50 -98
  9. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicDynamicPage.jsx +36 -30
  10. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.jsx +2 -14
  11. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicHomepage.jsx +25 -25
  12. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.jsx +45 -59
  13. package/cpa-out/nextjs-pages-codegen-js/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.jsx +2 -2
  14. package/cpa-out/nextjs-pages-codegen-js/package.json +9 -7
  15. package/cpa-out/nextjs-pages-codegen-js/pages/api/hello.js +1 -1
  16. package/cpa-out/nextjs-pages-codegen-js/pages/dynamic/[slug].jsx +4 -3
  17. package/cpa-out/nextjs-pages-codegen-js/pages/index.jsx +4 -3
  18. package/cpa-out/nextjs-pages-codegen-js/plasmic.json +14 -8
  19. package/cpa-out/nextjs-pages-codegen-ts/components/Button.tsx +4 -5
  20. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicButton.tsx +86 -65
  21. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicDynamicPage.tsx +74 -43
  22. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicGlobalVariant__Screen.tsx +2 -14
  23. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicHomepage.tsx +63 -37
  24. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/PlasmicRandomDynamicPageButton.tsx +84 -71
  25. package/cpa-out/nextjs-pages-codegen-ts/components/plasmic/create_plasmic_app/icons/PlasmicIcon__Checksvg.tsx +3 -3
  26. package/cpa-out/nextjs-pages-codegen-ts/package.json +13 -11
  27. package/cpa-out/nextjs-pages-codegen-ts/pages/api/hello.ts +5 -5
  28. package/cpa-out/nextjs-pages-codegen-ts/pages/dynamic/[slug].tsx +4 -4
  29. package/cpa-out/nextjs-pages-codegen-ts/pages/index.tsx +4 -4
  30. package/cpa-out/nextjs-pages-codegen-ts/plasmic.json +14 -8
  31. package/cpa-out/nextjs-pages-codegen-ts/tsconfig.json +1 -3
  32. package/cpa-out/nextjs-pages-loader-js/package.json +8 -6
  33. package/cpa-out/nextjs-pages-loader-js/pages/[[...catchall]].jsx +2 -0
  34. package/cpa-out/nextjs-pages-loader-js/pages/api/hello.js +1 -1
  35. package/cpa-out/nextjs-pages-loader-ts/package.json +12 -10
  36. package/cpa-out/nextjs-pages-loader-ts/pages/[[...catchall]].tsx +3 -1
  37. package/cpa-out/nextjs-pages-loader-ts/pages/api/hello.ts +5 -5
  38. package/cpa-out/nextjs-pages-loader-ts/tsconfig.json +1 -3
  39. package/dist/nextjs/nextjs.js +5 -23
  40. package/dist/nextjs/templates/pages-loader/catchall-page.js +1 -1
  41. package/package.json +2 -2
  42. package/src/nextjs/nextjs.ts +5 -24
  43. package/src/nextjs/templates/pages-loader/catchall-page.ts +1 -1
  44. package/.tool-versions +0 -1
  45. package/cpa-out/nextjs-app-loader-js/next.config.js +0 -13
  46. package/cpa-out/nextjs-app-loader-ts/next.config.js +0 -13
  47. package/cpa-out/nextjs-pages-codegen-js/next.config.js +0 -10
  48. package/cpa-out/nextjs-pages-codegen-ts/next.config.js +0 -10
  49. package/cpa-out/nextjs-pages-loader-js/next.config.js +0 -10
  50. package/cpa-out/nextjs-pages-loader-ts/next.config.js +0 -10
@@ -0,0 +1,68 @@
1
+ import * as React from "react";
2
+ import {
3
+ PlasmicComponent,
4
+ extractPlasmicQueryData,
5
+ ComponentRenderData,
6
+ PlasmicRootProvider,
7
+ } from "@plasmicapp/loader-nextjs";
8
+
9
+ import Error from "next/error";
10
+ import { useRouter } from "next/router";
11
+ import { PLASMIC } from "@/plasmic-init";
12
+
13
+ export default function PlasmicLoaderPage(props) {
14
+ const { plasmicData, queryCache } = props;
15
+ const router = useRouter();
16
+ if (!plasmicData || plasmicData.entryCompMetas.length === 0) {
17
+ return <Error statusCode={404} />;
18
+ }
19
+ const pageMeta = plasmicData.entryCompMetas[0];
20
+ return (
21
+ <PlasmicRootProvider
22
+ loader={PLASMIC}
23
+ prefetchedData={plasmicData}
24
+ prefetchedQueryData={queryCache}
25
+ pageRoute={pageMeta.path}
26
+ pageParams={pageMeta.params}
27
+ pageQuery={router.query}
28
+ >
29
+ <PlasmicComponent component={pageMeta.displayName} />
30
+ </PlasmicRootProvider>
31
+ );
32
+ }
33
+
34
+ export const getStaticProps = async (context) => {
35
+ const { catchall } = context.params ?? {};
36
+ const plasmicPath = typeof catchall === 'string' ? catchall : Array.isArray(catchall) ? `/${catchall.join('/')}` : '/';
37
+ const plasmicData = await PLASMIC.maybeFetchComponentData(plasmicPath);
38
+ if (!plasmicData) {
39
+ // non-Plasmic catch-all
40
+ return { props: {} };
41
+ }
42
+ const pageMeta = plasmicData.entryCompMetas[0];
43
+ // Cache the necessary data fetched for the page
44
+ const queryCache = await extractPlasmicQueryData(
45
+ <PlasmicRootProvider
46
+ loader={PLASMIC}
47
+ prefetchedData={plasmicData}
48
+ pageRoute={pageMeta.path}
49
+ pageParams={pageMeta.params}
50
+ >
51
+ <PlasmicComponent component={pageMeta.displayName} />
52
+ </PlasmicRootProvider>
53
+ );
54
+ // Use revalidate if you want incremental static regeneration
55
+ return { props: { plasmicData, queryCache }, revalidate: 60 };
56
+ }
57
+
58
+ export const getStaticPaths = async () => {
59
+ const pageModules = await PLASMIC.fetchPages();
60
+ return {
61
+ paths: pageModules.map((mod) => ({
62
+ params: {
63
+ catchall: mod.path.substring(1).split("/"),
64
+ },
65
+ })),
66
+ fallback: "blocking",
67
+ };
68
+ }
@@ -0,0 +1,5 @@
1
+ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2
+
3
+ export default function handler(req, res) {
4
+ res.status(200).json({ name: "John Doe" });
5
+ }
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { PlasmicCanvasHost } from '@plasmicapp/loader-nextjs';
3
+ import { PLASMIC } from '@/plasmic-init';
4
+
5
+ export default function PlasmicHost() {
6
+ return PLASMIC && <PlasmicCanvasHost />;
7
+ }
@@ -0,0 +1,72 @@
1
+ import * as React from "react";
2
+ import {
3
+ PlasmicComponent,
4
+ extractPlasmicQueryData,
5
+ ComponentRenderData,
6
+ PlasmicRootProvider,
7
+ } from "@plasmicapp/loader-nextjs";
8
+ import type { GetStaticPaths, GetStaticProps } from "next";
9
+
10
+ import Error from "next/error";
11
+ import { useRouter } from "next/router";
12
+ import { PLASMIC } from "@/plasmic-init";
13
+
14
+ export default function PlasmicLoaderPage(props: {
15
+ plasmicData?: ComponentRenderData;
16
+ queryCache?: Record<string, unknown>;
17
+ }) {
18
+ const { plasmicData, queryCache } = props;
19
+ const router = useRouter();
20
+ if (!plasmicData || plasmicData.entryCompMetas.length === 0) {
21
+ return <Error statusCode={404} />;
22
+ }
23
+ const pageMeta = plasmicData.entryCompMetas[0];
24
+ return (
25
+ <PlasmicRootProvider
26
+ loader={PLASMIC}
27
+ prefetchedData={plasmicData}
28
+ prefetchedQueryData={queryCache}
29
+ pageRoute={pageMeta.path}
30
+ pageParams={pageMeta.params}
31
+ pageQuery={router.query}
32
+ >
33
+ <PlasmicComponent component={pageMeta.displayName} />
34
+ </PlasmicRootProvider>
35
+ );
36
+ }
37
+
38
+ export const getStaticProps: GetStaticProps = async (context) => {
39
+ const { catchall } = context.params ?? {};
40
+ const plasmicPath = typeof catchall === 'string' ? catchall : Array.isArray(catchall) ? `/${catchall.join('/')}` : '/';
41
+ const plasmicData = await PLASMIC.maybeFetchComponentData(plasmicPath);
42
+ if (!plasmicData) {
43
+ // non-Plasmic catch-all
44
+ return { props: {} };
45
+ }
46
+ const pageMeta = plasmicData.entryCompMetas[0];
47
+ // Cache the necessary data fetched for the page
48
+ const queryCache = await extractPlasmicQueryData(
49
+ <PlasmicRootProvider
50
+ loader={PLASMIC}
51
+ prefetchedData={plasmicData}
52
+ pageRoute={pageMeta.path}
53
+ pageParams={pageMeta.params}
54
+ >
55
+ <PlasmicComponent component={pageMeta.displayName} />
56
+ </PlasmicRootProvider>
57
+ );
58
+ // Use revalidate if you want incremental static regeneration
59
+ return { props: { plasmicData, queryCache }, revalidate: 60 };
60
+ }
61
+
62
+ export const getStaticPaths: GetStaticPaths = async () => {
63
+ const pageModules = await PLASMIC.fetchPages();
64
+ return {
65
+ paths: pageModules.map((mod) => ({
66
+ params: {
67
+ catchall: mod.path.substring(1).split("/"),
68
+ },
69
+ })),
70
+ fallback: "blocking",
71
+ };
72
+ }
@@ -0,0 +1,13 @@
1
+ // Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2
+ import type { NextApiRequest, NextApiResponse } from "next";
3
+
4
+ type Data = {
5
+ name: string;
6
+ };
7
+
8
+ export default function handler(
9
+ req: NextApiRequest,
10
+ res: NextApiResponse<Data>,
11
+ ) {
12
+ res.status(200).json({ name: "John Doe" });
13
+ }
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { PlasmicCanvasHost } from '@plasmicapp/loader-nextjs';
3
+ import { PLASMIC } from '@/plasmic-init';
4
+
5
+ export default function PlasmicHost() {
6
+ return PLASMIC && <PlasmicCanvasHost />;
7
+ }
@@ -8,6 +8,4 @@ function Button_(props, ref) {
8
8
 
9
9
  const Button = React.forwardRef(Button_);
10
10
 
11
- export default Object.assign(Button, {
12
- __plumeType: "button"
13
- });
11
+ export default Object.assign(Button, { __plumeType: "button" });