eddev 2.0.0-beta.3 → 2.0.0-beta.30
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 +6 -0
- package/dist/app/entry/MetaTags.js +17 -0
- package/dist/app/entry/boot-admin.d.ts +1 -0
- package/dist/app/entry/{main.admin.js → boot-admin.js} +3 -5
- package/dist/app/entry/spa-root.d.ts +1 -0
- package/dist/app/entry/{Root.js → spa-root.js} +4 -4
- package/dist/app/entry/ssr-root-client.d.ts +6 -0
- package/dist/app/entry/ssr-root-client.js +16 -0
- package/dist/app/entry/ssr-root.d.ts +10 -0
- package/dist/app/entry/ssr-root.js +24 -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.js +4 -4
- package/dist/app/lib/blocks/EditableText.d.ts +1 -1
- package/dist/app/lib/blocks/EditableText.js +3 -3
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +1 -0
- 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 +1 -1
- package/dist/app/lib/blocks/block-utils.js +1 -1
- package/dist/app/lib/blocks/editor/EditorSupport.js +3 -3
- package/dist/app/lib/blocks/editor/editor-config.d.ts +1 -1
- package/dist/app/lib/blocks/editor/editor-config.js +1 -1
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +5 -5
- 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 +3 -3
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +5 -3
- package/dist/app/lib/devtools/components/DevUI.js +1 -1
- 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/useTailwind.d.ts +1078 -1079
- 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 +4 -4
- 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/apiConfig.d.ts +3 -1
- package/dist/app/lib/hooks/apiConfig.js +9 -4
- 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 +5 -2
- package/dist/app/lib/hooks/queryUtils.js +19 -20
- package/dist/app/lib/hooks/useAppData.js +1 -1
- package/dist/app/lib/internal/index.d.ts +4 -4
- package/dist/app/lib/internal/index.js +4 -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 +39 -0
- package/dist/app/lib/routing/components/BackButton.js +45 -0
- package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +68 -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 +2 -2
- package/dist/app/lib/routing/context.js +6 -96
- 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 +20 -8
- package/dist/app/lib/routing/utils.d.ts +3 -1
- package/dist/app/lib/routing/utils.js +11 -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 +4 -0
- package/dist/app/server/index.js +4 -0
- package/dist/app/server/proxy-wp-admin.d.ts +3 -0
- package/dist/app/server/proxy-wp-admin.js +105 -0
- package/dist/app/server/render-ssr-page.d.ts +3 -0
- package/dist/app/server/render-ssr-page.js +29 -0
- package/dist/app/server/server-context.d.ts +43 -0
- package/dist/app/server/server-context.js +140 -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/node/cli/cli-worker.d.ts +1 -1
- package/dist/node/cli/cli-worker.js +7 -2
- package/dist/node/cli/cli.js +84 -12
- package/dist/node/cli/display/CLIApp.d.ts +1 -1
- package/dist/node/cli/display/CLIApp.js +3 -6
- 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 +37 -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 +97 -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 +19 -0
- package/dist/node/compiler/vinxi-app.js +153 -0
- package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
- package/dist/node/compiler/vinxi-codegen.js +458 -0
- package/dist/node/graphql/graphql-codegen.d.ts +1 -1
- package/dist/node/graphql/graphql-codegen.js +7 -4
- package/dist/node/graphql/graphql-schema-loader.js +15 -18
- package/dist/node/project/config.js +1 -1
- 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 +2 -2
- package/dist/node/project/manifest/manifest.d.ts +1 -1
- package/dist/node/project/manifest/manifest.js +1 -1
- package/dist/node/project/manifest/view-manifest.js +2 -2
- package/dist/node/project/project.d.ts +3 -2
- package/dist/node/project/project.js +18 -20
- package/dist/node/project/wp-info.js +3 -2
- package/dist/node/types/view-type.js +3 -4
- package/dist/node/utils/fs-codegen.d.ts +40 -0
- package/dist/node/utils/fs-codegen.js +97 -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/package.json +30 -32
- package/types.app.d.ts +2 -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/main.admin.d.ts +0 -3
- 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/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 -215
- 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/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
- /package/dist/node/utils/{watchFileTree.d.ts → watch-file-tree.d.ts} +0 -0
- /package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +0 -0
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { code } from "ts-poet";
|
|
2
|
+
import { FSCodegen } from "../utils/fs-codegen.js";
|
|
3
|
+
export function getVinxiFolder(opts) {
|
|
4
|
+
return (opts.mode === "development" ? "dev" : "prod") + (opts.serverless ? "" : "-spa");
|
|
5
|
+
}
|
|
6
|
+
export async function runVinxiCodegen(opts) {
|
|
7
|
+
const codegen = createVinxiCodegen(opts);
|
|
8
|
+
await codegen.run();
|
|
9
|
+
codegen.stop();
|
|
10
|
+
}
|
|
11
|
+
export function createVinxiCodegen(opts) {
|
|
12
|
+
const project = opts.project;
|
|
13
|
+
const folder = ".eddev/" + getVinxiFolder(opts);
|
|
14
|
+
const codegen = new FSCodegen(opts.project, {
|
|
15
|
+
outDir: folder,
|
|
16
|
+
});
|
|
17
|
+
if (opts.serverless) {
|
|
18
|
+
codegen.registerFile({
|
|
19
|
+
name: "context.ts",
|
|
20
|
+
generate: () => {
|
|
21
|
+
const args = {
|
|
22
|
+
dev: true,
|
|
23
|
+
origin: project.origin,
|
|
24
|
+
replaceUrls: {
|
|
25
|
+
from: project.origin,
|
|
26
|
+
to: opts.endpoint ?? "",
|
|
27
|
+
prefixes: [
|
|
28
|
+
{ prefix: "/wp-content/uploads", replace: project.config?.serverless.uploads === "proxy" },
|
|
29
|
+
{ prefix: "/wp-content/plugins", replace: project.config?.serverless.plugins === "proxy" },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
return code /* tsx */ `
|
|
34
|
+
import { ServerContext } from "eddev/server"
|
|
35
|
+
import { getManifest } from "vinxi/manifest"
|
|
36
|
+
|
|
37
|
+
ServerContext.setRuntime({
|
|
38
|
+
getManifest
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
export const serverContext = new ServerContext({${Object.entries(args)
|
|
42
|
+
.map(([key, value]) => `${key}: ${JSON.stringify(value)}`)
|
|
43
|
+
.join(",\n")}
|
|
44
|
+
})
|
|
45
|
+
`.toString();
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (opts.serverless) {
|
|
50
|
+
codegen.registerFile({
|
|
51
|
+
name: "react-shim.js",
|
|
52
|
+
generate: code /* tsx */ `
|
|
53
|
+
import React from "react"
|
|
54
|
+
import ReactDOM from "react-dom/client"
|
|
55
|
+
Object.assign(React, window.React)
|
|
56
|
+
Object.assign(ReactDOM, window.ReactDOM)
|
|
57
|
+
`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (opts.serverless) {
|
|
61
|
+
// codegen.registerFile({
|
|
62
|
+
// name: "manifest/extra-routes.ts",
|
|
63
|
+
// generate: code/* tsx */ `
|
|
64
|
+
// import { createRouter, eventHandler, getRouterParam, getQuery, getWebRequest, getRequestHeaders } from "vinxi/http"
|
|
65
|
+
// import { serverContext } from "./context.js"
|
|
66
|
+
// export const routes = [
|
|
67
|
+
// {
|
|
68
|
+
// pattern: '/test1',
|
|
69
|
+
// handler: () => import('../../../test.ts')
|
|
70
|
+
// }
|
|
71
|
+
// ]
|
|
72
|
+
// export default eventHandler((event) => {
|
|
73
|
+
// routes
|
|
74
|
+
// })
|
|
75
|
+
// `,
|
|
76
|
+
// })
|
|
77
|
+
}
|
|
78
|
+
codegen.registerFile({
|
|
79
|
+
name: "entry.admin.tsx",
|
|
80
|
+
generate: () => {
|
|
81
|
+
return code /* tsx */ `
|
|
82
|
+
${opts.serverless ? `import "./react-shim.js"` : ""}
|
|
83
|
+
${opts.serverless ? `import "vinxi/client"` : ""}
|
|
84
|
+
import "../../views/index.css"
|
|
85
|
+
import "./manifest/admin"
|
|
86
|
+
import "./manifest/blocks"
|
|
87
|
+
import "./manifest/styles"
|
|
88
|
+
import bootAdmin from "eddev/_internal/boot-admin.js"
|
|
89
|
+
|
|
90
|
+
bootAdmin()
|
|
91
|
+
`;
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
codegen.registerFile({
|
|
95
|
+
name: "entry.client.tsx",
|
|
96
|
+
generate: () => {
|
|
97
|
+
if (opts.serverless) {
|
|
98
|
+
/**
|
|
99
|
+
* Client entry for SSR mode
|
|
100
|
+
*/
|
|
101
|
+
return code /* tsx */ `
|
|
102
|
+
/// <reference types="vinxi/types/client" />
|
|
103
|
+
/**
|
|
104
|
+
* SSR-mode frontend entry.
|
|
105
|
+
* Hydrates the main app, including the html/head/body elements.
|
|
106
|
+
* Also ensures that the assets used during SSR are loaded.
|
|
107
|
+
*/
|
|
108
|
+
import "vinxi/client"
|
|
109
|
+
import "../../views/index.css"
|
|
110
|
+
import "./manifest/blocks"
|
|
111
|
+
import "./manifest/views"
|
|
112
|
+
|
|
113
|
+
import * as React from "react"
|
|
114
|
+
import { Root, hydrateRoot } from "react-dom/client"
|
|
115
|
+
import { SSRClientRoot } from "eddev/_internal/ssr-root-client.js"
|
|
116
|
+
import { getManifest } from "vinxi/manifest"
|
|
117
|
+
import { createAssets } from "@vinxi/react"
|
|
118
|
+
import { devToolsStore } from 'eddev/devtools'
|
|
119
|
+
|
|
120
|
+
// Set up a dynamic entry which will load the configured tailwind manifest
|
|
121
|
+
devToolsStore.loadTailwindConfig = () => import('./manifest/tailwind-config.js')
|
|
122
|
+
|
|
123
|
+
// Create the asset renderer, which will ensure scripts/styles are mounted correctly
|
|
124
|
+
function getAssets() {
|
|
125
|
+
const Assets = createAssets(getManifest("client").handler, getManifest("client"))
|
|
126
|
+
return <React.Suspense><Assets /></React.Suspense>
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
window.$reactRoot =
|
|
130
|
+
window.$reactRoot ||
|
|
131
|
+
hydrateRoot(
|
|
132
|
+
document,
|
|
133
|
+
<SSRClientRoot assets={getAssets()} metaTags={window._PAGE_DATA.meta.head} />,
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
if (import.meta.hot) {
|
|
137
|
+
import.meta.hot.accept((mod) => {
|
|
138
|
+
if (mod) {
|
|
139
|
+
const Assets = createAssets(getManifest("client").handler, getManifest("client"))
|
|
140
|
+
const app = <SSRClientRoot assets={getAssets()} metaTags={window._PAGE_DATA.meta.head} />
|
|
141
|
+
window.$reactRoot?.render(app)
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
declare global {
|
|
147
|
+
interface Window {
|
|
148
|
+
$reactRoot?: Root
|
|
149
|
+
_PAGE_DATA: any
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return code /* tsx */ `
|
|
157
|
+
/**
|
|
158
|
+
* SPA-mode frontend entry.
|
|
159
|
+
* Renders the main app into the empty <div id='root'> element, and expects window._PAGE_DATA to be set.
|
|
160
|
+
*/
|
|
161
|
+
import "./manifest/blocks"
|
|
162
|
+
import "./manifest/views"
|
|
163
|
+
import "../../views/index.css"
|
|
164
|
+
import { devToolsStore } from 'eddev/devtools'
|
|
165
|
+
import { createRoot } from "react-dom/client"
|
|
166
|
+
import { SPARoot } from "eddev/_internal/spa-root.js"
|
|
167
|
+
import * as React from "react"
|
|
168
|
+
|
|
169
|
+
devToolsStore.loadTailwindConfig = () => import('./manifest/tailwind-config')
|
|
170
|
+
|
|
171
|
+
createRoot(document.getElementById("root")!).render(<SPARoot />)
|
|
172
|
+
`;
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
if (opts.serverless) {
|
|
177
|
+
codegen.registerFile({
|
|
178
|
+
name: "handler.data-api.ts",
|
|
179
|
+
generate: code /* tsx */ `
|
|
180
|
+
/// <reference types="vinxi/types/server" />
|
|
181
|
+
import { createRouter, eventHandler, getRouterParam, getQuery, getWebRequest, getRequestHeaders } from "vinxi/http"
|
|
182
|
+
import { serverContext } from "./context.js"
|
|
183
|
+
|
|
184
|
+
const router = createRouter()
|
|
185
|
+
.get(
|
|
186
|
+
"/route/",
|
|
187
|
+
eventHandler(async (event) => {
|
|
188
|
+
const id = "/"
|
|
189
|
+
|
|
190
|
+
return await serverContext.fetchRouteData({
|
|
191
|
+
pathname: id,
|
|
192
|
+
withAppData: false,
|
|
193
|
+
})
|
|
194
|
+
}),
|
|
195
|
+
)
|
|
196
|
+
.get(
|
|
197
|
+
"/route/**:name",
|
|
198
|
+
eventHandler(async (event) => {
|
|
199
|
+
const id = "/" + getRouterParam(event, "name")
|
|
200
|
+
|
|
201
|
+
return await serverContext.fetchRouteData({
|
|
202
|
+
pathname: id,
|
|
203
|
+
withAppData: false,
|
|
204
|
+
})
|
|
205
|
+
}),
|
|
206
|
+
)
|
|
207
|
+
.get(
|
|
208
|
+
"/query/**:name",
|
|
209
|
+
eventHandler(async (event) => {
|
|
210
|
+
const id = "/" + getRouterParam(event, "name")
|
|
211
|
+
const paramString = getQuery(event).params
|
|
212
|
+
|
|
213
|
+
const params = typeof paramString === "string" && paramString.length ? JSON.parse(paramString) : {}
|
|
214
|
+
|
|
215
|
+
return await serverContext.fetchNamedQuery({
|
|
216
|
+
name: id,
|
|
217
|
+
params: params,
|
|
218
|
+
headers: getRequestHeaders(event),
|
|
219
|
+
})
|
|
220
|
+
}),
|
|
221
|
+
)
|
|
222
|
+
.post(
|
|
223
|
+
"/mutation/**:name",
|
|
224
|
+
eventHandler(async (event) => {
|
|
225
|
+
const id = "/" + getRouterParam(event, "name")
|
|
226
|
+
const body = await getWebRequest(event).json()
|
|
227
|
+
return await serverContext.fetchMutation({
|
|
228
|
+
name: id,
|
|
229
|
+
body,
|
|
230
|
+
headers: getRequestHeaders(event),
|
|
231
|
+
})
|
|
232
|
+
}),
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
export default router.handler
|
|
236
|
+
|
|
237
|
+
`,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
if (opts.serverless) {
|
|
241
|
+
codegen.registerFile({
|
|
242
|
+
name: "handler.ssr-page.ts",
|
|
243
|
+
generate: code /* tsx */ `
|
|
244
|
+
/// <reference types="vinxi/types/server" />
|
|
245
|
+
import "../../views/index.css"
|
|
246
|
+
import "./manifest/blocks.js"
|
|
247
|
+
import "./manifest/styles.js"
|
|
248
|
+
import "./manifest/views.js"
|
|
249
|
+
|
|
250
|
+
import { proxyWpAdmin, renderPageToSSRStream } from "eddev/server"
|
|
251
|
+
import { eventHandler, getRequestURL, setResponseHeader, setResponseStatus } from "vinxi/http"
|
|
252
|
+
import { serverContext } from "./context.js"
|
|
253
|
+
import { RouteData } from "eddev/routing"
|
|
254
|
+
|
|
255
|
+
export default eventHandler({
|
|
256
|
+
handler: async (event) => {
|
|
257
|
+
const url = getRequestURL(event)
|
|
258
|
+
|
|
259
|
+
if (url.pathname.includes(".")) {
|
|
260
|
+
return proxyWpAdmin(event, serverContext)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
try {
|
|
264
|
+
const [appData, response] = await Promise.all([
|
|
265
|
+
serverContext.fetchAppData(),
|
|
266
|
+
serverContext.fetchRouteData({
|
|
267
|
+
pathname: url.pathname,
|
|
268
|
+
withAppData: true,
|
|
269
|
+
headers: {},
|
|
270
|
+
query: {},
|
|
271
|
+
}),
|
|
272
|
+
])
|
|
273
|
+
|
|
274
|
+
let data: RouteData
|
|
275
|
+
try {
|
|
276
|
+
data = await response.json()
|
|
277
|
+
data.appData = appData
|
|
278
|
+
} catch (err) {
|
|
279
|
+
data = {
|
|
280
|
+
view: "_error",
|
|
281
|
+
viewType: "react",
|
|
282
|
+
viewData: {},
|
|
283
|
+
appData: appData,
|
|
284
|
+
}
|
|
285
|
+
console.error(err)
|
|
286
|
+
setResponseStatus(event, 500)
|
|
287
|
+
}
|
|
288
|
+
setResponseHeader(event, "Content-Type", "text/html; charset=utf-8")
|
|
289
|
+
return renderPageToSSRStream(url.pathname, data, serverContext)
|
|
290
|
+
} catch (err) {
|
|
291
|
+
console.error(err)
|
|
292
|
+
setResponseStatus(event, 500)
|
|
293
|
+
setResponseHeader(event, "Content-Type", "text/html; charset=utf-8")
|
|
294
|
+
return '<!DOCTYPE html><html><head><title>500 Internal Server Error</title></head><body><h1>500 Internal Server Error</h1><p>"'+err.message+'"</p></body></html>'
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
})
|
|
298
|
+
`,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
if (opts.serverless) {
|
|
302
|
+
codegen.registerFile({
|
|
303
|
+
name: "handler.wp-proxy.ts",
|
|
304
|
+
generate: code /* tsx */ `
|
|
305
|
+
/// <reference types="vinxi/types/server" />
|
|
306
|
+
import { proxyWpAdmin } from "eddev/server"
|
|
307
|
+
import { eventHandler } from "vinxi/http"
|
|
308
|
+
import { serverContext } from "./context.js"
|
|
309
|
+
|
|
310
|
+
export default eventHandler(async (event) => {
|
|
311
|
+
return proxyWpAdmin(event, serverContext)
|
|
312
|
+
})
|
|
313
|
+
`,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
codegen.registerFile({
|
|
317
|
+
name: "manifest/blocks.ts",
|
|
318
|
+
generate: async () => {
|
|
319
|
+
const blockManifest = await project.blocks.get();
|
|
320
|
+
return code /* ts */ `
|
|
321
|
+
import { blockManifestReader } from 'eddev/_internal'
|
|
322
|
+
import { dynamic } from 'eddev/dynamic'
|
|
323
|
+
import core from '../../../blocks/_core'
|
|
324
|
+
|
|
325
|
+
const manifest = {
|
|
326
|
+
${Object.entries(blockManifest.blocks)
|
|
327
|
+
.filter(([name]) => !name.match(/^_[a-z]+$/i))
|
|
328
|
+
.map(([name, block]) => {
|
|
329
|
+
const importStatement = `dynamic(() => import(${JSON.stringify("../../../" + block.fileName)}))`;
|
|
330
|
+
return JSON.stringify(block.acfName) + ": " + importStatement;
|
|
331
|
+
})
|
|
332
|
+
.join(",\n")},
|
|
333
|
+
...core
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const info = {
|
|
337
|
+
${Object.entries(blockManifest.blocks)
|
|
338
|
+
.filter(([name]) => !name.match(/^_[a-z]+$/i))
|
|
339
|
+
.map(([name, block]) => {
|
|
340
|
+
return (JSON.stringify(block.acfName) +
|
|
341
|
+
": " +
|
|
342
|
+
JSON.stringify({
|
|
343
|
+
slug: block.slug,
|
|
344
|
+
tags: block.tags,
|
|
345
|
+
flags: block.flags ?? {},
|
|
346
|
+
}));
|
|
347
|
+
})
|
|
348
|
+
.join(",\n")}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
blockManifestReader.set(manifest, info)
|
|
352
|
+
|
|
353
|
+
export default manifest
|
|
354
|
+
|
|
355
|
+
if (import.meta.hot) {
|
|
356
|
+
import.meta.hot.accept()
|
|
357
|
+
}
|
|
358
|
+
`;
|
|
359
|
+
},
|
|
360
|
+
subscribe: project.blocks.subscribe,
|
|
361
|
+
});
|
|
362
|
+
codegen.registerFile({
|
|
363
|
+
name: "manifest/admin.ts",
|
|
364
|
+
generate: async () => {
|
|
365
|
+
const fieldManifest = await project.fields.get();
|
|
366
|
+
const widgetManifest = await project.widgets.get();
|
|
367
|
+
return code /* ts */ `
|
|
368
|
+
import { adminManifestReader } from 'eddev/_internal'
|
|
369
|
+
import editorConfig from '../../../blocks/_editor'
|
|
370
|
+
|
|
371
|
+
const fields = {${Object.entries(fieldManifest.fields)
|
|
372
|
+
.map(([name, field]) => {
|
|
373
|
+
const importStatement = `() => import(${JSON.stringify("../../../" + field.fileName)}).then(m => m.default)`;
|
|
374
|
+
return JSON.stringify(field.slug) + ": " + importStatement;
|
|
375
|
+
})
|
|
376
|
+
.join(",\n")}}
|
|
377
|
+
const widgets = {${Object.entries(widgetManifest.widgets)
|
|
378
|
+
.map(([name, widget]) => {
|
|
379
|
+
const importStatement = `() => import(${JSON.stringify("../../../" + widget.fileName)}).then(m => m.default)`;
|
|
380
|
+
return JSON.stringify(widget.slug) + ": " + importStatement;
|
|
381
|
+
})
|
|
382
|
+
.join(",\n")}}
|
|
383
|
+
|
|
384
|
+
const manifest = {
|
|
385
|
+
fields,
|
|
386
|
+
widgets,
|
|
387
|
+
editorConfig
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
adminManifestReader.set(manifest)
|
|
391
|
+
|
|
392
|
+
export default manifest
|
|
393
|
+
|
|
394
|
+
export { editorConfig }
|
|
395
|
+
|
|
396
|
+
if (import.meta.hot) {
|
|
397
|
+
import.meta.hot.accept()
|
|
398
|
+
}
|
|
399
|
+
`;
|
|
400
|
+
},
|
|
401
|
+
subscribe: (callback) => {
|
|
402
|
+
const unsub = [project.fields.subscribe(callback), project.widgets.subscribe(callback)];
|
|
403
|
+
return () => unsub.forEach((u) => u());
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
codegen.registerFile({
|
|
407
|
+
name: "manifest/views.ts",
|
|
408
|
+
generate: async () => {
|
|
409
|
+
const viewManifest = await project.views.get();
|
|
410
|
+
return code /* ts */ `
|
|
411
|
+
import { viewManifestReader } from 'eddev/_internal'
|
|
412
|
+
import { dynamic } from 'eddev/dynamic'
|
|
413
|
+
const manifest = {${Object.entries(viewManifest.views)
|
|
414
|
+
.map(([name, view]) => {
|
|
415
|
+
const importStatement = `dynamic(() => import(${JSON.stringify("../../../" + view.fileName)}))`;
|
|
416
|
+
return JSON.stringify(view.slug) + ": " + importStatement;
|
|
417
|
+
})
|
|
418
|
+
.join(",\n")}}
|
|
419
|
+
|
|
420
|
+
viewManifestReader.value = manifest
|
|
421
|
+
|
|
422
|
+
export default manifest
|
|
423
|
+
|
|
424
|
+
if (import.meta.hot) {
|
|
425
|
+
import.meta.hot.accept()
|
|
426
|
+
}
|
|
427
|
+
`;
|
|
428
|
+
},
|
|
429
|
+
subscribe: project.views.subscribe,
|
|
430
|
+
});
|
|
431
|
+
codegen.registerFile({
|
|
432
|
+
name: "manifest/styles.ts",
|
|
433
|
+
generate: async () => {
|
|
434
|
+
return code /* ts */ `
|
|
435
|
+
export const getCssText = undefined
|
|
436
|
+
export const editorGlobalStyles = () => {}
|
|
437
|
+
`;
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
codegen.registerFile({
|
|
441
|
+
name: "manifest/tailwind-config.ts",
|
|
442
|
+
generate: async () => {
|
|
443
|
+
return code /* ts */ `
|
|
444
|
+
import tw from "../../../tailwind.config.ts"
|
|
445
|
+
import resolveConfig from 'tailwindcss/resolveConfig'
|
|
446
|
+
import { devToolsStore } from 'eddev/devtools'
|
|
447
|
+
|
|
448
|
+
const value = resolveConfig(tw)
|
|
449
|
+
devToolsStore.tailwindConfig = value
|
|
450
|
+
|
|
451
|
+
if (import.meta.hot) {
|
|
452
|
+
import.meta.hot.accept()
|
|
453
|
+
}
|
|
454
|
+
`;
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
return codegen;
|
|
458
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
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
3
|
export declare class GraphQLGenerator {
|
|
4
4
|
project: Project;
|
|
5
5
|
private needsRegenerate;
|
|
@@ -10,9 +10,9 @@ import * as typescriptPlugin from "@graphql-codegen/typescript";
|
|
|
10
10
|
import * as typescriptOperationsPlugin from "@graphql-codegen/typescript-operations";
|
|
11
11
|
import chalk from "chalk";
|
|
12
12
|
import { code } from "ts-poet";
|
|
13
|
-
import { highlightCode } from "../utils/
|
|
14
|
-
import { createConsole } from "../utils/
|
|
15
|
-
import { watchFileTreeForChanges } from "../utils/
|
|
13
|
+
import { highlightCode } from "../utils/highlight-code.js";
|
|
14
|
+
import { createConsole } from "../utils/stateful-log.js";
|
|
15
|
+
import { watchFileTreeForChanges } from "../utils/watch-file-tree.js";
|
|
16
16
|
import pluginFiles from "./plugins/gql-plugin-files.js";
|
|
17
17
|
import pluginNoDuplicates from "./plugins/gql-plugin-no-duplicates.js";
|
|
18
18
|
import pluginQueries from "./plugins/gql-plugin-queries.js";
|
|
@@ -227,6 +227,9 @@ export class GraphQLGenerator {
|
|
|
227
227
|
documents: getDocuments(["queries", "views", "blocks", "fragments"]),
|
|
228
228
|
hasDocuments: true,
|
|
229
229
|
banner: `import { ContentBlock } from "eddev/blocks"`,
|
|
230
|
+
footer: Object.keys(wp.scalarTypes)
|
|
231
|
+
.map((name) => `export type ${name}Scalar = Scalars["${name}"]["output"]`)
|
|
232
|
+
.join("\n"),
|
|
230
233
|
plugins: {
|
|
231
234
|
typescript: [typescriptPlugin, {}],
|
|
232
235
|
typescriptOperations: [typescriptOperationsPlugin, {}],
|
|
@@ -400,7 +403,7 @@ export class GraphQLGenerator {
|
|
|
400
403
|
errors.push(String(err));
|
|
401
404
|
}
|
|
402
405
|
if (args.banner) {
|
|
403
|
-
output = args.banner + "\n\n" + output;
|
|
406
|
+
output = args.banner + "\n\n" + output + "\n" + (args.footer ?? "");
|
|
404
407
|
}
|
|
405
408
|
if (errors.length === 0) {
|
|
406
409
|
const didWrite = await fs.writeIfUnchanged(config.filename, output);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { loadSchema } from "@graphql-tools/load";
|
|
2
2
|
import { UrlLoader } from "@graphql-tools/url-loader";
|
|
3
3
|
import { introspectionFromSchema } from "graphql";
|
|
4
|
-
import { Agent } from "https";
|
|
5
|
-
import fetch from "node-fetch";
|
|
6
4
|
import { graphqlLog as console } from "./graphql-codegen.js";
|
|
7
5
|
import chalk from "chalk";
|
|
8
6
|
import { hash } from "object-code";
|
|
@@ -23,22 +21,21 @@ export class GraphQLSchemaLoader {
|
|
|
23
21
|
console.info(`${this.lastHash ? "Reloading" : "Loading"} GraphQL schema from ${chalk.yellowBright(this.url)}`);
|
|
24
22
|
const rawSchema = await loadSchema(this.url, {
|
|
25
23
|
loaders: [new UrlLoader()],
|
|
26
|
-
fetch: (url, opts) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
24
|
+
// fetch: (url: string, opts: any) => {
|
|
25
|
+
// const httpsAgent = new Agent({
|
|
26
|
+
// rejectUnauthorized: false,
|
|
27
|
+
// })
|
|
28
|
+
// return fetch(url, {
|
|
29
|
+
// ...opts,
|
|
30
|
+
// agent: function (_parsedURL) {
|
|
31
|
+
// if (_parsedURL.protocol == "http:") {
|
|
32
|
+
// return undefined
|
|
33
|
+
// } else {
|
|
34
|
+
// return httpsAgent
|
|
35
|
+
// }
|
|
36
|
+
// },
|
|
37
|
+
// })
|
|
38
|
+
// },
|
|
42
39
|
}).catch((e) => {
|
|
43
40
|
return e;
|
|
44
41
|
});
|
|
@@ -4,7 +4,7 @@ import { z } from "zod";
|
|
|
4
4
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
5
5
|
import { cliMode } from "../cli/cli-mode.js";
|
|
6
6
|
import { fs } from "../utils/fs.js";
|
|
7
|
-
import { isDeploying } from "../utils/
|
|
7
|
+
import { isDeploying } from "../utils/is-deploying.js";
|
|
8
8
|
import { projectLog as console } from "./project.js";
|
|
9
9
|
export const EDConfigSchema = z.object({
|
|
10
10
|
$schema: z.string().optional(),
|
|
@@ -35,5 +35,5 @@ export declare const ProjectEnvUtils: {
|
|
|
35
35
|
valid: false;
|
|
36
36
|
};
|
|
37
37
|
getSafe<T extends ProjectEnvKey>(key: T): Required<ProjectEnvMap[T]> | undefined;
|
|
38
|
-
get<T extends ProjectEnvKey>(key: T, cons?: import("../utils/
|
|
38
|
+
get<T extends ProjectEnvKey>(key: T, cons?: import("../utils/stateful-log.js").StatefulLog<import("./project.js").Project>): z.infer<(typeof fields)[T]>;
|
|
39
39
|
};
|
package/dist/node/project/env.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { cliMode } from "../cli/cli-mode.js";
|
|
3
3
|
import { projectLog as console } from "./project.js";
|
|
4
|
-
import { formatZodError } from "../utils/
|
|
4
|
+
import { formatZodError } from "../utils/format-zod-error.js";
|
|
5
5
|
const portNumber = z
|
|
6
6
|
.string()
|
|
7
7
|
.default("0")
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { camelCase, kebabCase } from "change-case-all";
|
|
2
2
|
import { cliMode } from "../../cli/cli-mode.js";
|
|
3
3
|
import { BlockMetaSchema } from "../../types/block-type.js";
|
|
4
|
-
import { metaExtractor } from "../../utils/export-extractor.js";
|
|
5
|
-
import { formatZodError } from "../../utils/
|
|
4
|
+
import { metaExtractor } from "../../utils/ts-export-extractor.js";
|
|
5
|
+
import { formatZodError } from "../../utils/format-zod-error.js";
|
|
6
6
|
import { fs } from "../../utils/fs.js";
|
|
7
7
|
import { createManifestGenerator } from "./manifest.js";
|
|
8
8
|
export function loadBlockManifest(project) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { basename } from "node:path";
|
|
2
2
|
import { cliMode } from "../../cli/cli-mode.js";
|
|
3
3
|
import { ViewMetaSchema } from "../../types/view-type.js";
|
|
4
|
-
import {
|
|
5
|
-
import { formatZodError } from "../../utils/formatZodError.js";
|
|
4
|
+
import { formatZodError } from "../../utils/format-zod-error.js";
|
|
6
5
|
import { fs } from "../../utils/fs.js";
|
|
6
|
+
import { metaExtractor } from "../../utils/ts-export-extractor.js";
|
|
7
7
|
import { createManifestGenerator } from "./manifest.js";
|
|
8
8
|
export function loadViewManifest(project) {
|
|
9
9
|
return createManifestGenerator({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EDConfig } from "./config.js";
|
|
2
2
|
import { BlockManifestGenerator } from "./manifest/block-manifest.js";
|
|
3
|
-
import { ViewManifestGenerator } from "./manifest/view-manifest.js";
|
|
4
3
|
import { FieldManifestGenerator } from "./manifest/field-manifest.js";
|
|
4
|
+
import { ViewManifestGenerator } from "./manifest/view-manifest.js";
|
|
5
5
|
import { WidgetManifestGenerator } from "./manifest/widget-manifest.js";
|
|
6
|
-
export declare const projectLog: import("../utils/
|
|
6
|
+
export declare const projectLog: import("../utils/stateful-log.js").StatefulLog<Project>;
|
|
7
7
|
type ProjectArgs = {
|
|
8
8
|
rootDir: string;
|
|
9
9
|
reportPluginCompatibility?: boolean;
|
|
@@ -18,6 +18,7 @@ export declare class Project {
|
|
|
18
18
|
publicUrl: string;
|
|
19
19
|
repoUrl: string;
|
|
20
20
|
configFile: string;
|
|
21
|
+
origin: string;
|
|
21
22
|
config?: EDConfig;
|
|
22
23
|
blocks: BlockManifestGenerator;
|
|
23
24
|
views: ViewManifestGenerator;
|