eddev 2.0.0-beta.6 → 2.0.0-beta.61
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/dist/app/entry/MetaTags.d.ts +7 -0
- package/dist/app/entry/MetaTags.js +17 -0
- package/dist/app/entry/boot-admin.d.ts +1 -0
- package/dist/app/entry/boot-admin.js +14 -0
- package/dist/app/entry/spa-root.d.ts +1 -0
- package/dist/app/entry/spa-root.js +8 -0
- package/dist/app/entry/ssr-root-client.d.ts +6 -0
- package/dist/app/entry/ssr-root-client.js +26 -0
- package/dist/app/entry/ssr-root.d.ts +10 -0
- package/dist/app/entry/ssr-root.js +23 -0
- package/dist/app/lib/admin/index.d.ts +2 -2
- package/dist/app/lib/admin/index.js +2 -2
- package/dist/app/lib/admin/installFieldTypes.js +1 -1
- package/dist/app/lib/admin/runWidgets.js +1 -1
- package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
- package/dist/app/lib/blocks/ContentBlocks.js +5 -5
- package/dist/app/lib/blocks/EditableText.d.ts +1 -1
- package/dist/app/lib/blocks/EditableText.js +3 -3
- package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
- package/dist/app/lib/blocks/InnerBlocks.js +13 -5
- package/dist/app/lib/blocks/block-utils.d.ts +2 -2
- package/dist/app/lib/blocks/block-utils.js +2 -2
- package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
- package/dist/app/lib/blocks/editor/editor-config.d.ts +16 -3
- package/dist/app/lib/blocks/editor/editor-config.js +2 -4
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +17 -13
- package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
- package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
- package/dist/app/lib/blocks/index.d.ts +9 -9
- package/dist/app/lib/blocks/index.js +9 -9
- package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
- package/dist/app/lib/blocks/inline-editing.js +7 -5
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
- package/dist/app/lib/devtools/components/DevUI.js +4 -3
- package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
- package/dist/app/lib/devtools/components/GridIndicator.js +24 -0
- package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
- package/dist/app/lib/devtools/dev-tools-store.js +8 -0
- package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
- package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1094 -1095
- package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
- package/dist/app/lib/devtools/index.d.ts +1 -0
- package/dist/app/lib/devtools/index.js +1 -1
- package/dist/app/lib/devtools/loader.js +8 -7
- package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
- package/dist/app/lib/devtools/useQueryDebug.js +5 -8
- package/dist/app/lib/dynamic/index.d.ts +1 -1
- package/dist/app/lib/dynamic/index.js +1 -1
- package/dist/app/lib/hooks/index.d.ts +4 -5
- package/dist/app/lib/hooks/index.js +4 -5
- package/dist/app/lib/hooks/queryUtils.d.ts +37 -3
- package/dist/app/lib/hooks/queryUtils.js +63 -26
- package/dist/app/lib/hooks/useAppData.js +1 -1
- package/dist/app/lib/hooks/useRPC.d.ts +0 -4
- package/dist/app/lib/hooks/useRPC.js +1 -8
- package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
- package/dist/app/lib/internal/finalize-rpc.js +3 -0
- package/dist/app/lib/internal/index.d.ts +5 -4
- package/dist/app/lib/internal/index.js +5 -4
- package/dist/app/lib/internal/internal-store.d.ts +0 -2
- package/dist/app/lib/internal/internal-store.js +1 -3
- package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
- package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
- package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/index.js +1 -1
- package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
- package/dist/app/lib/routing/components/BackButton.js +47 -0
- package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +79 -11
- package/dist/app/lib/routing/components/ClientOnly.js +1 -1
- package/dist/app/lib/routing/components/Link.d.ts +1 -0
- package/dist/app/lib/routing/components/Link.js +9 -10
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
- package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
- package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
- package/dist/app/lib/routing/components/SSRRouter.js +5 -6
- package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
- package/dist/app/lib/routing/context.d.ts +8 -5
- package/dist/app/lib/routing/context.js +13 -96
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
- package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
- package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
- package/dist/app/lib/routing/hooks/useRoute.js +22 -1
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
- package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouter.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
- package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
- package/dist/app/lib/routing/index.d.ts +14 -13
- package/dist/app/lib/routing/index.js +14 -13
- package/dist/app/lib/routing/loader.d.ts +2 -2
- package/dist/app/lib/routing/loader.js +7 -5
- package/dist/app/lib/routing/types.d.ts +35 -9
- package/dist/app/lib/routing/utils.d.ts +3 -1
- package/dist/app/lib/routing/utils.js +12 -1
- package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
- package/dist/app/lib/runtime/apiConfig.js +6 -0
- package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
- package/dist/app/lib/runtime/errorHandling.js +6 -0
- package/dist/app/lib/runtime/index.d.ts +2 -0
- package/dist/app/lib/runtime/index.js +2 -0
- package/dist/app/lib/views/index.d.ts +1 -1
- package/dist/app/lib/views/index.js +1 -1
- package/dist/app/server/defineRouter.d.ts +2 -0
- package/dist/app/server/defineRouter.js +4 -0
- package/dist/app/server/index.d.ts +5 -0
- package/dist/app/server/index.js +5 -0
- package/dist/app/server/proxy-wp-admin.d.ts +2 -0
- package/dist/app/server/proxy-wp-admin.js +112 -0
- package/dist/app/server/render-ssr-page.d.ts +11 -0
- package/dist/app/server/render-ssr-page.js +100 -0
- package/dist/app/server/rpc.d.ts +56 -0
- package/dist/app/server/rpc.js +18 -0
- package/dist/app/server/server-context.d.ts +53 -0
- package/dist/app/server/server-context.js +149 -0
- package/dist/app/server/utils/headers.d.ts +1 -0
- package/dist/app/server/utils/headers.js +17 -0
- package/dist/app/server/utils/replace-host.d.ts +6 -4
- package/dist/app/server/utils/replace-host.js +58 -11
- package/dist/app/utils/APIProvider.d.ts +2 -0
- package/dist/app/utils/APIProvider.js +5 -0
- package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
- package/dist/app/utils/BlockErrorBoundary.js +38 -0
- package/dist/app/utils/ErrorMessage.d.ts +5 -0
- package/dist/app/utils/ErrorMessage.js +14 -0
- package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
- package/dist/app/utils/RouteErrorBoundary.js +38 -0
- package/dist/app/utils/query-client.d.ts +2 -0
- package/dist/app/utils/query-client.js +5 -1
- package/dist/app/utils/trpc-client.d.ts +2 -0
- package/dist/app/utils/trpc-client.js +34 -0
- package/dist/node/cli/cli-worker.d.ts +1 -1
- package/dist/node/cli/cli-worker.js +12 -3
- package/dist/node/cli/cli.js +91 -13
- package/dist/node/cli/display/CLIApp.d.ts +1 -1
- package/dist/node/cli/display/CLIApp.js +4 -7
- package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
- package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
- package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
- package/dist/node/cli/display/tools/cli-tools.js +9 -9
- package/dist/node/cli/display/util/colors.d.ts +2 -2
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/build-vinxi.d.ts +8 -0
- package/dist/node/compiler/build-vinxi.js +38 -0
- package/dist/node/compiler/bundler.admin.d.ts +2 -2
- package/dist/node/compiler/bundler.admin.js +3 -4
- package/dist/node/compiler/bundler.frontend.d.ts +1 -1
- package/dist/node/compiler/bundler.frontend.js +3 -4
- package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
- package/dist/node/compiler/dev-server.js +106 -0
- package/dist/node/compiler/get-vite-config.d.ts +19 -0
- package/dist/node/compiler/get-vite-config.js +200 -0
- package/dist/node/compiler/vinxi-app.d.ts +20 -0
- package/dist/node/compiler/vinxi-app.js +186 -0
- package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
- package/dist/node/compiler/vinxi-codegen.js +515 -0
- package/dist/node/graphql/graphql-codegen.d.ts +12 -2
- package/dist/node/graphql/graphql-codegen.js +213 -36
- package/dist/node/graphql/graphql-schema-loader.js +15 -18
- package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
- package/dist/node/graphql/query-files-loader.d.ts +3 -0
- package/dist/node/graphql/query-files-loader.js +5 -0
- package/dist/node/project/config.d.ts +31 -37
- package/dist/node/project/config.js +13 -11
- package/dist/node/project/env.d.ts +1 -1
- package/dist/node/project/env.js +1 -1
- package/dist/node/project/manifest/block-manifest.js +3 -2
- package/dist/node/project/manifest/manifest.d.ts +2 -1
- package/dist/node/project/manifest/manifest.js +15 -11
- package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
- package/dist/node/project/manifest/routes-manifest.js +74 -0
- package/dist/node/project/manifest/view-manifest.js +2 -2
- package/dist/node/project/project.d.ts +5 -2
- package/dist/node/project/project.js +21 -20
- package/dist/node/project/wp-info.js +3 -2
- package/dist/node/types/block-type.d.ts +5 -0
- package/dist/node/types/block-type.js +1 -0
- package/dist/node/types/view-type.js +3 -4
- package/dist/node/utils/fs-codegen.d.ts +42 -0
- package/dist/node/utils/fs-codegen.js +98 -0
- package/dist/node/utils/fs.js +2 -0
- package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
- package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
- package/dist/node/utils/watch-file-tree.d.ts +25 -0
- package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +12 -5
- package/package.json +39 -32
- package/types.app.d.ts +4 -2
- package/types.app.internal.d.ts +2 -2
- package/types.node.d.ts +3 -3
- package/dist/app/entry/Root.d.ts +0 -1
- package/dist/app/entry/Root.js +0 -9
- package/dist/app/entry/main.admin.d.ts +0 -3
- package/dist/app/entry/main.admin.js +0 -10
- package/dist/app/entry/main.frontend.spa.d.ts +0 -3
- package/dist/app/entry/main.frontend.spa.js +0 -13
- package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
- package/dist/app/entry/main.frontend.ssr.js +0 -79
- package/dist/app/entry/main.serverless.dev.d.ts +0 -4
- package/dist/app/entry/main.serverless.dev.js +0 -21
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
- package/dist/app/lib/hooks/apiConfig.js +0 -4
- package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
- package/dist/app/lib/hooks/usePageLoad.js +0 -5
- package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
- package/dist/app/server/create-api-builtin-hono.js +0 -80
- package/dist/app/server/create-ssr-hono.d.ts +0 -18
- package/dist/app/server/create-ssr-hono.js +0 -104
- package/dist/app/server/utils/index.html.d.ts +0 -2
- package/dist/app/server/utils/index.html.js +0 -14
- package/dist/node/compiler/index.html.d.ts +0 -2
- package/dist/node/compiler/index.html.js +0 -15
- package/dist/node/compiler/serverless.dev.js +0 -222
- package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
- package/dist/node/compiler/vite/get-vite-config.js +0 -315
- package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-admin.js +0 -67
- package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-blocks.js +0 -73
- package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
- package/dist/node/compiler/vite/plugin-entry.js +0 -16
- package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
- package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-theme.js +0 -40
- package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-views.js +0 -51
- package/dist/node/utils/console.d.ts +0 -21
- package/dist/node/utils/console.js +0 -28
- package/dist/node/utils/unsafe-fetch.d.ts +0 -2
- package/dist/node/utils/unsafe-fetch.js +0 -19
- package/dist/node/utils/watchFileTree.d.ts +0 -11
- package/tsup.config.ts +0 -40
- package/types.manifests.d.ts +0 -22
- /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
- /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
- /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
- /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
- /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
- /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
- /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
- /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
- /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
- /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
import { code, imp } from "ts-poet";
|
|
2
|
+
import { FSCodegen } from "../utils/fs-codegen.js";
|
|
3
|
+
import { camelCase } from "change-case-all";
|
|
4
|
+
export function getVinxiFolder(opts) {
|
|
5
|
+
return (opts.mode === "development" ? "dev" : "prod") + (opts.serverless ? "" : "-spa");
|
|
6
|
+
}
|
|
7
|
+
export async function runVinxiCodegen(opts) {
|
|
8
|
+
const codegen = createVinxiCodegen(opts);
|
|
9
|
+
await codegen.run();
|
|
10
|
+
codegen.stop();
|
|
11
|
+
}
|
|
12
|
+
export function createVinxiCodegen(opts) {
|
|
13
|
+
const project = opts.project;
|
|
14
|
+
const folder = ".eddev/" + getVinxiFolder(opts);
|
|
15
|
+
const codegen = new FSCodegen(opts.project, {
|
|
16
|
+
outDir: folder,
|
|
17
|
+
});
|
|
18
|
+
if (opts.serverless) {
|
|
19
|
+
codegen.registerFile({
|
|
20
|
+
name: "context.ts",
|
|
21
|
+
generate: async () => {
|
|
22
|
+
const args = {
|
|
23
|
+
dev: true,
|
|
24
|
+
origin: project.origin,
|
|
25
|
+
replaceUrls: {
|
|
26
|
+
from: project.origin,
|
|
27
|
+
to: opts.endpoint ?? "",
|
|
28
|
+
prefixes: [
|
|
29
|
+
{ prefix: "/wp-content/uploads", replace: project.config?.serverless.uploads === "proxy" },
|
|
30
|
+
{ prefix: "/wp-content/plugins", replace: project.config?.serverless.plugins === "proxy" },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
rpcBases: (await project.serverRoutes.get()).bases ?? [],
|
|
34
|
+
};
|
|
35
|
+
return code /* tsx */ `
|
|
36
|
+
import { ServerContext } from "eddev/server"
|
|
37
|
+
import { getManifest } from "vinxi/manifest"
|
|
38
|
+
|
|
39
|
+
ServerContext.setRuntime({
|
|
40
|
+
getManifest
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
export const serverContext = new ServerContext({${Object.entries(args)
|
|
44
|
+
.map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
|
|
45
|
+
.join(",\n")}
|
|
46
|
+
})
|
|
47
|
+
`.toString();
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (opts.serverless) {
|
|
52
|
+
codegen.registerFile({
|
|
53
|
+
name: "react-shim.js",
|
|
54
|
+
generate: code /* tsx */ `
|
|
55
|
+
import React from "react"
|
|
56
|
+
import ReactDOM from "react-dom/client"
|
|
57
|
+
Object.assign(React, window.React)
|
|
58
|
+
Object.assign(ReactDOM, window.ReactDOM)
|
|
59
|
+
`,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (opts.serverless) {
|
|
63
|
+
// codegen.registerFile({
|
|
64
|
+
// name: "manifest/extra-routes.ts",
|
|
65
|
+
// generate: code/* tsx */ `
|
|
66
|
+
// import { createRouter, eventHandler, getRouterParam, getQuery, getWebRequest, getRequestHeaders } from "vinxi/http"
|
|
67
|
+
// import { serverContext } from "./context.js"
|
|
68
|
+
// export const routes = [
|
|
69
|
+
// {
|
|
70
|
+
// pattern: '/test1',
|
|
71
|
+
// handler: () => import('../../../test.ts')
|
|
72
|
+
// }
|
|
73
|
+
// ]
|
|
74
|
+
// export default eventHandler((event) => {
|
|
75
|
+
// routes
|
|
76
|
+
// })
|
|
77
|
+
// `,
|
|
78
|
+
// })
|
|
79
|
+
}
|
|
80
|
+
codegen.registerFile({
|
|
81
|
+
name: "entry.admin.tsx",
|
|
82
|
+
generate: () => {
|
|
83
|
+
return code /* tsx */ `
|
|
84
|
+
${opts.serverless ? `import "./react-shim.js"` : ""}
|
|
85
|
+
${opts.serverless ? `import "vinxi/client"` : ""}
|
|
86
|
+
import "../../views/index.css"
|
|
87
|
+
import "./manifest/admin"
|
|
88
|
+
import "./manifest/blocks"
|
|
89
|
+
import "./manifest/styles"
|
|
90
|
+
import bootAdmin from "eddev/_internal/boot-admin.js"
|
|
91
|
+
|
|
92
|
+
bootAdmin()
|
|
93
|
+
`;
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
codegen.registerFile({
|
|
97
|
+
name: "entry.client.tsx",
|
|
98
|
+
generate: () => {
|
|
99
|
+
if (opts.serverless) {
|
|
100
|
+
/**
|
|
101
|
+
* Client entry for SSR mode
|
|
102
|
+
*/
|
|
103
|
+
return code /* tsx */ `
|
|
104
|
+
/// <reference types="vinxi/types/client" />
|
|
105
|
+
/**
|
|
106
|
+
* SSR-mode frontend entry.
|
|
107
|
+
* Hydrates the main app, including the html/head/body elements.
|
|
108
|
+
* Also ensures that the assets used during SSR are loaded.
|
|
109
|
+
*/
|
|
110
|
+
import "vinxi/client"
|
|
111
|
+
import "../../views/index.css"
|
|
112
|
+
import "./manifest/blocks"
|
|
113
|
+
import "./manifest/views"
|
|
114
|
+
|
|
115
|
+
import * as React from "react"
|
|
116
|
+
import { Root, hydrateRoot } from "react-dom/client"
|
|
117
|
+
import { SSRClientRoot } from "eddev/_internal/ssr-root-client.js"
|
|
118
|
+
import { getManifest } from "vinxi/manifest"
|
|
119
|
+
import { createAssets } from "@vinxi/react"
|
|
120
|
+
import { devToolsStore } from 'eddev/devtools'
|
|
121
|
+
|
|
122
|
+
// Set up a dynamic entry which will load the configured tailwind manifest
|
|
123
|
+
devToolsStore.loadTailwindConfig = () => import('./manifest/tailwind-config.js')
|
|
124
|
+
|
|
125
|
+
// Create the asset renderer, which will ensure scripts/styles are mounted correctly
|
|
126
|
+
function getAssets() {
|
|
127
|
+
const Assets = createAssets(getManifest("client").handler, getManifest("client"))
|
|
128
|
+
return <React.Suspense><Assets /></React.Suspense>
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
window.$reactRoot =
|
|
132
|
+
window.$reactRoot ||
|
|
133
|
+
hydrateRoot(
|
|
134
|
+
document,
|
|
135
|
+
<SSRClientRoot assets={getAssets()} metaTags={window._PAGE_DATA.meta.head} />,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
if (import.meta.hot) {
|
|
139
|
+
import.meta.hot.accept((mod) => {
|
|
140
|
+
if (mod) {
|
|
141
|
+
const Assets = createAssets(getManifest("client").handler, getManifest("client"))
|
|
142
|
+
const app = <SSRClientRoot assets={getAssets()} metaTags={window._PAGE_DATA.meta.head} />
|
|
143
|
+
window.$reactRoot?.render(app)
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare global {
|
|
149
|
+
interface Window {
|
|
150
|
+
$reactRoot?: Root
|
|
151
|
+
_PAGE_DATA: any
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
return code /* tsx */ `
|
|
159
|
+
/**
|
|
160
|
+
* SPA-mode frontend entry.
|
|
161
|
+
* Renders the main app into the empty <div id='root'> element, and expects window._PAGE_DATA to be set.
|
|
162
|
+
*/
|
|
163
|
+
import "./manifest/blocks"
|
|
164
|
+
import "./manifest/views"
|
|
165
|
+
import "../../views/index.css"
|
|
166
|
+
import { devToolsStore } from 'eddev/devtools'
|
|
167
|
+
import { createRoot } from "react-dom/client"
|
|
168
|
+
import { SPARoot } from "eddev/_internal/spa-root.js"
|
|
169
|
+
import * as React from "react"
|
|
170
|
+
|
|
171
|
+
devToolsStore.loadTailwindConfig = () => import('./manifest/tailwind-config')
|
|
172
|
+
|
|
173
|
+
createRoot(document.getElementById("root")!).render(<SPARoot />)
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
if (opts.serverless) {
|
|
179
|
+
codegen.registerFile({
|
|
180
|
+
name: "handler.data-api.ts",
|
|
181
|
+
generate: code /* tsx */ `
|
|
182
|
+
/// <reference types="vinxi/types/server" />
|
|
183
|
+
import { createRouter, eventHandler, getRouterParam, getQuery, getWebRequest, getRequestHeaders } from "vinxi/http"
|
|
184
|
+
import { serverContext } from "./context.js"
|
|
185
|
+
|
|
186
|
+
const router = createRouter()
|
|
187
|
+
.get(
|
|
188
|
+
"/route/",
|
|
189
|
+
eventHandler(async (event) => {
|
|
190
|
+
const id = "/"
|
|
191
|
+
|
|
192
|
+
return await serverContext.fetchRouteData({
|
|
193
|
+
pathname: id,
|
|
194
|
+
withAppData: false,
|
|
195
|
+
})
|
|
196
|
+
}),
|
|
197
|
+
)
|
|
198
|
+
.get(
|
|
199
|
+
"/route/**:name",
|
|
200
|
+
eventHandler(async (event) => {
|
|
201
|
+
const id = "/" + getRouterParam(event, "name")
|
|
202
|
+
|
|
203
|
+
return await serverContext.fetchRouteData({
|
|
204
|
+
pathname: id,
|
|
205
|
+
withAppData: false,
|
|
206
|
+
})
|
|
207
|
+
}),
|
|
208
|
+
)
|
|
209
|
+
.get(
|
|
210
|
+
"/query/**:name",
|
|
211
|
+
eventHandler(async (event) => {
|
|
212
|
+
const id = "/" + getRouterParam(event, "name")
|
|
213
|
+
const paramString = getQuery(event).params
|
|
214
|
+
|
|
215
|
+
const params = typeof paramString === "string" && paramString.length ? JSON.parse(paramString) : {}
|
|
216
|
+
|
|
217
|
+
return await serverContext.fetchNamedQuery({
|
|
218
|
+
name: id,
|
|
219
|
+
params: params,
|
|
220
|
+
headers: getRequestHeaders(event),
|
|
221
|
+
})
|
|
222
|
+
}),
|
|
223
|
+
)
|
|
224
|
+
.post(
|
|
225
|
+
"/mutation/**:name",
|
|
226
|
+
eventHandler(async (event) => {
|
|
227
|
+
const id = "/" + getRouterParam(event, "name")
|
|
228
|
+
const body = await getWebRequest(event).json()
|
|
229
|
+
return await serverContext.fetchMutation({
|
|
230
|
+
name: id,
|
|
231
|
+
body,
|
|
232
|
+
headers: getRequestHeaders(event),
|
|
233
|
+
})
|
|
234
|
+
}),
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
export default router.handler
|
|
238
|
+
|
|
239
|
+
`,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
if (opts.serverless) {
|
|
243
|
+
codegen.registerFile({
|
|
244
|
+
name: "handler.ssr-page.ts",
|
|
245
|
+
generate: code /* tsx */ `
|
|
246
|
+
/// <reference types="vinxi/types/server" />
|
|
247
|
+
import "../../views/index.css"
|
|
248
|
+
import "./manifest/blocks.js"
|
|
249
|
+
import "./manifest/styles.js"
|
|
250
|
+
import "./manifest/views.js"
|
|
251
|
+
import "./context.js"
|
|
252
|
+
import { handleRPC } from "./rpc.js"
|
|
253
|
+
import { proxyWpAdmin, ServerContext, renderPage } from "eddev/server"
|
|
254
|
+
import { eventHandler, getRequestURL } from "vinxi/http"
|
|
255
|
+
|
|
256
|
+
export default eventHandler({
|
|
257
|
+
handler: async (event) => {
|
|
258
|
+
const serverContext = ServerContext.main
|
|
259
|
+
const url = getRequestURL(event)
|
|
260
|
+
|
|
261
|
+
const isRPC = serverContext.rpcBases.some((base) => url.pathname.startsWith(base))
|
|
262
|
+
if (isRPC) {
|
|
263
|
+
return handleRPC(event)
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (url.pathname.includes(".")) {
|
|
267
|
+
return proxyWpAdmin(event)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return renderPage({ pathname: url.pathname })
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
`,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
if (opts.serverless) {
|
|
277
|
+
codegen.registerFile({
|
|
278
|
+
name: "handler.wp-proxy.ts",
|
|
279
|
+
generate: code /* tsx */ `
|
|
280
|
+
/// <reference types="vinxi/types/server" />
|
|
281
|
+
import { proxyWpAdmin } from "eddev/server"
|
|
282
|
+
import { eventHandler } from "vinxi/http"
|
|
283
|
+
import "./context.js"
|
|
284
|
+
|
|
285
|
+
export default eventHandler(async (event) => {
|
|
286
|
+
return proxyWpAdmin(event)
|
|
287
|
+
})
|
|
288
|
+
`,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
codegen.registerFile({
|
|
292
|
+
name: "manifest/blocks.ts",
|
|
293
|
+
generate: async () => {
|
|
294
|
+
const blockManifest = await project.blocks.get();
|
|
295
|
+
return code /* ts */ `
|
|
296
|
+
import { blockManifestReader } from 'eddev/_internal'
|
|
297
|
+
import { dynamic } from 'eddev/dynamic'
|
|
298
|
+
import core from '../../../blocks/_core'
|
|
299
|
+
|
|
300
|
+
const manifest = {
|
|
301
|
+
${Object.entries(blockManifest.blocks)
|
|
302
|
+
.filter(([name]) => !name.match(/^_[a-z]+$/i))
|
|
303
|
+
.map(([name, block]) => {
|
|
304
|
+
const importStatement = `dynamic(() => import(${JSON.stringify("../../../" + block.fileName)}))`;
|
|
305
|
+
return JSON.stringify(block.acfName) + ": " + importStatement;
|
|
306
|
+
})
|
|
307
|
+
.join(",\n")},
|
|
308
|
+
...core
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const info = {
|
|
312
|
+
${Object.entries(blockManifest.blocks)
|
|
313
|
+
.filter(([name]) => !name.match(/^_[a-z]+$/i))
|
|
314
|
+
.map(([name, block]) => {
|
|
315
|
+
return (JSON.stringify(block.acfName) +
|
|
316
|
+
": " +
|
|
317
|
+
JSON.stringify({
|
|
318
|
+
slug: block.slug,
|
|
319
|
+
tags: block.tags,
|
|
320
|
+
flags: block.flags ?? {},
|
|
321
|
+
}));
|
|
322
|
+
})
|
|
323
|
+
.join(",\n")}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
blockManifestReader.set(manifest, info)
|
|
327
|
+
|
|
328
|
+
export default manifest
|
|
329
|
+
|
|
330
|
+
if (import.meta.hot) {
|
|
331
|
+
import.meta.hot.accept()
|
|
332
|
+
}
|
|
333
|
+
`;
|
|
334
|
+
},
|
|
335
|
+
subscribe: project.blocks.subscribe,
|
|
336
|
+
});
|
|
337
|
+
codegen.registerFile({
|
|
338
|
+
name: "manifest/admin.ts",
|
|
339
|
+
generate: async () => {
|
|
340
|
+
const fieldManifest = await project.fields.get();
|
|
341
|
+
const widgetManifest = await project.widgets.get();
|
|
342
|
+
return code /* ts */ `
|
|
343
|
+
import { adminManifestReader } from 'eddev/_internal'
|
|
344
|
+
import editorConfig from '../../../blocks/_editor'
|
|
345
|
+
|
|
346
|
+
const fields = {${Object.entries(fieldManifest.fields)
|
|
347
|
+
.map(([name, field]) => {
|
|
348
|
+
const importStatement = `() => import(${JSON.stringify("../../../" + field.fileName)}).then(m => m.default)`;
|
|
349
|
+
return JSON.stringify(field.slug) + ": " + importStatement;
|
|
350
|
+
})
|
|
351
|
+
.join(",\n")}}
|
|
352
|
+
const widgets = {${Object.entries(widgetManifest.widgets)
|
|
353
|
+
.map(([name, widget]) => {
|
|
354
|
+
const importStatement = `() => import(${JSON.stringify("../../../" + widget.fileName)}).then(m => m.default)`;
|
|
355
|
+
return JSON.stringify(widget.slug) + ": " + importStatement;
|
|
356
|
+
})
|
|
357
|
+
.join(",\n")}}
|
|
358
|
+
|
|
359
|
+
const manifest = {
|
|
360
|
+
fields,
|
|
361
|
+
widgets,
|
|
362
|
+
editorConfig
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
adminManifestReader.set(manifest)
|
|
366
|
+
|
|
367
|
+
export default manifest
|
|
368
|
+
|
|
369
|
+
export { editorConfig }
|
|
370
|
+
|
|
371
|
+
if (import.meta.hot) {
|
|
372
|
+
import.meta.hot.accept()
|
|
373
|
+
}
|
|
374
|
+
`;
|
|
375
|
+
},
|
|
376
|
+
subscribe: (callback) => {
|
|
377
|
+
const unsub = [project.fields.subscribe(callback), project.widgets.subscribe(callback)];
|
|
378
|
+
return () => unsub.forEach((u) => u());
|
|
379
|
+
},
|
|
380
|
+
});
|
|
381
|
+
codegen.registerFile({
|
|
382
|
+
name: "manifest/views.ts",
|
|
383
|
+
generate: async () => {
|
|
384
|
+
const viewManifest = await project.views.get();
|
|
385
|
+
return code /* ts */ `
|
|
386
|
+
import { viewManifestReader } from 'eddev/_internal'
|
|
387
|
+
import { dynamic } from 'eddev/dynamic'
|
|
388
|
+
const manifest = {${Object.entries(viewManifest.views).map(([name, view]) => {
|
|
389
|
+
const src = "../../../" + view.fileName;
|
|
390
|
+
let importStatement;
|
|
391
|
+
if (name.startsWith("_")) {
|
|
392
|
+
importStatement = imp(name + "=" + src);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
importStatement = code `dynamic(() => import(${JSON.stringify(src)}))`;
|
|
396
|
+
}
|
|
397
|
+
return code `${JSON.stringify(view.slug)}: ${importStatement},\n`;
|
|
398
|
+
})}}
|
|
399
|
+
|
|
400
|
+
viewManifestReader.value = manifest
|
|
401
|
+
|
|
402
|
+
export default manifest
|
|
403
|
+
|
|
404
|
+
if (import.meta.hot) {
|
|
405
|
+
import.meta.hot.accept()
|
|
406
|
+
}
|
|
407
|
+
`;
|
|
408
|
+
},
|
|
409
|
+
subscribe: project.views.subscribe,
|
|
410
|
+
});
|
|
411
|
+
codegen.registerFile({
|
|
412
|
+
name: "manifest/styles.ts",
|
|
413
|
+
generate: async () => {
|
|
414
|
+
return code /* ts */ `
|
|
415
|
+
export const getCssText = undefined
|
|
416
|
+
export const editorGlobalStyles = () => {}
|
|
417
|
+
`;
|
|
418
|
+
},
|
|
419
|
+
});
|
|
420
|
+
codegen.registerFile({
|
|
421
|
+
name: "manifest/tailwind-config.ts",
|
|
422
|
+
generate: async () => {
|
|
423
|
+
return code /* ts */ `
|
|
424
|
+
import tw from "../../../tailwind.config.ts"
|
|
425
|
+
import resolveConfig from 'tailwindcss/resolveConfig'
|
|
426
|
+
import { devToolsStore } from 'eddev/devtools'
|
|
427
|
+
|
|
428
|
+
const value = resolveConfig(tw)
|
|
429
|
+
devToolsStore.tailwindConfig = value
|
|
430
|
+
|
|
431
|
+
if (import.meta.hot) {
|
|
432
|
+
import.meta.hot.accept()
|
|
433
|
+
}
|
|
434
|
+
`;
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
if (opts.serverless) {
|
|
438
|
+
codegen.registerFile({
|
|
439
|
+
name: "manifest/routes.ts",
|
|
440
|
+
generate: async () => {
|
|
441
|
+
const routeManifest = await project.serverRoutes.get();
|
|
442
|
+
return code /* ts */ `
|
|
443
|
+
import { instantiateRouter } from "eddev/server"
|
|
444
|
+
${routeManifest.contextFileName
|
|
445
|
+
? code /*ts*/ `
|
|
446
|
+
import createContext from "../../../${routeManifest.contextFileName}"
|
|
447
|
+
`
|
|
448
|
+
: code /*ts*/ `
|
|
449
|
+
const createContext = () => ({})
|
|
450
|
+
`}
|
|
451
|
+
|
|
452
|
+
const router = instantiateRouter({${Object.entries(routeManifest.routes).map(([name, route]) => {
|
|
453
|
+
const src = "../../../" + route.fileName;
|
|
454
|
+
const importStatement = imp(camelCase(name) + "=" + src);
|
|
455
|
+
return code `${JSON.stringify(route.prefix)}: ${importStatement},\n`;
|
|
456
|
+
})}})
|
|
457
|
+
|
|
458
|
+
export { createContext, router }
|
|
459
|
+
`;
|
|
460
|
+
},
|
|
461
|
+
subscribe: project.serverRoutes.subscribe,
|
|
462
|
+
});
|
|
463
|
+
codegen.registerFile({
|
|
464
|
+
name: "rpc.ts",
|
|
465
|
+
generate: code /* tsx */ `
|
|
466
|
+
/// <reference types="vinxi/types/server" />
|
|
467
|
+
import "./context.js"
|
|
468
|
+
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"
|
|
469
|
+
import { parseURL, stringifyParsedURL } from "ufo"
|
|
470
|
+
import { EventHandlerRequest, getWebRequest, H3Event } from "vinxi/http"
|
|
471
|
+
import { createContext, router } from "./manifest/routes.ts"
|
|
472
|
+
|
|
473
|
+
export function handleRPC(event: H3Event<EventHandlerRequest>) {
|
|
474
|
+
// Update URLs with dots, which tRPC prefers
|
|
475
|
+
const originalReq = getWebRequest(event)
|
|
476
|
+
const parsed = parseURL(originalReq.url)
|
|
477
|
+
parsed.pathname = "/" + parsed.pathname.replace(/(^\\/|\\/$)/g, "").replace(/\\//, ".")
|
|
478
|
+
const req = new Request(stringifyParsedURL(parsed), originalReq)
|
|
479
|
+
|
|
480
|
+
// Handle any early results which are Responses
|
|
481
|
+
function processEarlyResult(value: any): Response | undefined {
|
|
482
|
+
if (value instanceof Response) {
|
|
483
|
+
return value
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
return new Promise(async (resolve) => {
|
|
488
|
+
let sent = false
|
|
489
|
+
const defaultResponse = await fetchRequestHandler({
|
|
490
|
+
endpoint: "/",
|
|
491
|
+
req: req,
|
|
492
|
+
router: router,
|
|
493
|
+
createContext,
|
|
494
|
+
onError: (err) => console.error(err),
|
|
495
|
+
batching: { enabled: false },
|
|
496
|
+
// If a Response object is returned by a route, it will be sent as the response
|
|
497
|
+
responseMeta(opts) {
|
|
498
|
+
const value = opts?.data?.[0]?.["result"]?.["data"]
|
|
499
|
+
const response = processEarlyResult(value)
|
|
500
|
+
if (response) {
|
|
501
|
+
sent = true
|
|
502
|
+
resolve(response)
|
|
503
|
+
}
|
|
504
|
+
return {}
|
|
505
|
+
},
|
|
506
|
+
})
|
|
507
|
+
if (sent) return
|
|
508
|
+
resolve(defaultResponse)
|
|
509
|
+
})
|
|
510
|
+
}
|
|
511
|
+
`,
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
return codegen;
|
|
515
|
+
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Project } from "../project/project.js";
|
|
2
|
-
export declare const graphqlLog: import("../utils/
|
|
2
|
+
export declare const graphqlLog: import("../utils/stateful-log.js").StatefulLog<GraphQLGenerator>;
|
|
3
|
+
type GraphQLGeneratorOptions = {
|
|
4
|
+
watch?: boolean;
|
|
5
|
+
optimize?: boolean;
|
|
6
|
+
generate?: boolean;
|
|
7
|
+
};
|
|
3
8
|
export declare class GraphQLGenerator {
|
|
4
9
|
project: Project;
|
|
10
|
+
opts: GraphQLGeneratorOptions;
|
|
5
11
|
private needsRegenerate;
|
|
6
12
|
private needsReload;
|
|
7
13
|
private regenerateReason;
|
|
@@ -9,22 +15,26 @@ export declare class GraphQLGenerator {
|
|
|
9
15
|
private isGenerating;
|
|
10
16
|
private schemaLoader;
|
|
11
17
|
private fileLoader;
|
|
18
|
+
private optimizeWriter;
|
|
12
19
|
private debouncer?;
|
|
13
20
|
private retryTimer?;
|
|
14
|
-
constructor(project: Project);
|
|
21
|
+
constructor(project: Project, opts: GraphQLGeneratorOptions);
|
|
15
22
|
queueRegenerate(full: boolean, reason: string, info?: string | string[]): Promise<void>;
|
|
16
23
|
start(): Promise<void>;
|
|
17
24
|
private listen;
|
|
18
25
|
scheduleRetry(): void;
|
|
19
26
|
generate(): Promise<void>;
|
|
27
|
+
private getOptimizedQueries;
|
|
20
28
|
/**
|
|
21
29
|
* Validates a GraphQL manifest against a schema, ensuring there are no user errors.
|
|
22
30
|
*/
|
|
23
31
|
private validateGraphQLFiles;
|
|
24
32
|
private generateTS;
|
|
25
33
|
generateUtilTypes(): Promise<unknown[]>;
|
|
34
|
+
generateAPITypes(): Promise<unknown[]>;
|
|
26
35
|
/**
|
|
27
36
|
* Saves the schema to a file, for use by the VSCode GraphQL extension
|
|
28
37
|
*/
|
|
29
38
|
private writeSchemaFile;
|
|
30
39
|
}
|
|
40
|
+
export {};
|