eddev 0.2.0-beta.5 → 0.2.0-beta.52
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/build/build-favicon.d.ts +1 -0
- package/build/build-favicon.js +71 -0
- package/build/create-serverless-dev-worker.d.ts +3 -0
- package/build/create-serverless-dev-worker.js +99 -0
- package/build/get-webpack-config.js +26 -11
- package/build/manifests/manifest-views.js +1 -1
- package/build/reporter.js +0 -109
- package/build/serverless/create-next-app.d.ts +2 -0
- package/build/serverless/create-next-app.js +326 -86
- package/build/state/serverless-state.d.ts +26 -0
- package/build/state/serverless-state.js +2 -0
- package/build/workers/codegen-worker-script.js +33 -0
- package/build/workers/serverless-worker-dev-script.d.ts +1 -0
- package/build/workers/serverless-worker-dev-script.js +21 -0
- package/cli/build.dev.js +38 -7
- package/cli/build.prod.js +13 -1
- package/cli/cli.js +26 -18
- package/cli/display/components/DevCLIDisplay.d.ts +3 -0
- package/cli/display/components/DevCLIDisplay.js +20 -1
- package/cli/display/components/ServerlessDisplay.d.ts +9 -0
- package/cli/display/components/ServerlessDisplay.js +68 -0
- package/components/NextRouter.js +3 -2
- package/config/config-schema.d.ts +55 -0
- package/config/config-schema.js +19 -0
- package/config/create-schema-file.d.ts +1 -0
- package/config/create-schema-file.js +20 -0
- package/config/get-config.d.ts +39 -0
- package/config/get-config.js +32 -0
- package/config/index.d.ts +2 -0
- package/config/index.js +14 -0
- package/config/parse-config.d.ts +25 -0
- package/config/parse-config.js +8 -0
- package/config/print-zod-errors.d.ts +2 -0
- package/config/print-zod-errors.js +14 -0
- package/dev-ui/components/BreakpointColumnHeader.d.ts +11 -0
- package/dev-ui/components/BreakpointColumnHeader.js +47 -0
- package/dev-ui/components/BreakpointIndicator.d.ts +2 -0
- package/dev-ui/components/BreakpointIndicator.js +138 -0
- package/dev-ui/components/DevUI.d.ts +2 -0
- package/dev-ui/components/DevUI.js +28 -0
- package/dev-ui/components/Launcher.d.ts +98 -0
- package/dev-ui/components/Launcher.js +94 -0
- package/dev-ui/components/PanelWrapper.d.ts +8 -0
- package/dev-ui/components/PanelWrapper.js +37 -0
- package/dev-ui/components/ResponsiveLerpControl.d.ts +8 -0
- package/dev-ui/components/ResponsiveLerpControl.js +177 -0
- package/dev-ui/components/ResponsiveScaleEditor.d.ts +26 -0
- package/dev-ui/components/ResponsiveScaleEditor.js +233 -0
- package/dev-ui/components/atoms/Button.d.ts +47 -0
- package/dev-ui/components/atoms/Button.js +67 -0
- package/dev-ui/components/atoms/Dropdown.d.ts +13 -0
- package/dev-ui/components/atoms/Dropdown.js +50 -0
- package/dev-ui/components/atoms/NumberField.d.ts +12 -0
- package/dev-ui/components/atoms/NumberField.js +111 -0
- package/dev-ui/components/atoms/Spacer.d.ts +42 -0
- package/dev-ui/components/atoms/Spacer.js +8 -0
- package/dev-ui/components/atoms/Text.d.ts +45 -0
- package/dev-ui/components/atoms/Text.js +39 -0
- package/dev-ui/components/atoms/ToggleButton.d.ts +8 -0
- package/dev-ui/components/atoms/ToggleButton.js +41 -0
- package/dev-ui/components/atoms/Tooltip.d.ts +9 -0
- package/dev-ui/components/atoms/Tooltip.js +66 -0
- package/dev-ui/components/panels/PageDataDebugger.d.ts +2 -0
- package/dev-ui/components/panels/PageDataDebugger.js +30 -0
- package/dev-ui/components/panels/SpacingEditor.d.ts +2 -0
- package/dev-ui/components/panels/SpacingEditor.js +88 -0
- package/dev-ui/components/panels/TypographyEditor.d.ts +2 -0
- package/dev-ui/components/panels/TypographyEditor.js +88 -0
- package/dev-ui/hooks/useBreakpoint.d.ts +11 -0
- package/dev-ui/hooks/useBreakpoint.js +59 -0
- package/dev-ui/hooks/usePersistState.d.ts +1 -0
- package/dev-ui/hooks/usePersistState.js +36 -0
- package/dev-ui/hooks/useStylesheet.d.ts +4 -0
- package/dev-ui/hooks/useStylesheet.js +31 -0
- package/dev-ui/icons.d.ts +15 -0
- package/dev-ui/icons.js +29 -0
- package/dev-ui/index.d.ts +1 -0
- package/dev-ui/index.js +13 -0
- package/dev-ui/loader.d.ts +2 -0
- package/dev-ui/loader.js +42 -0
- package/dev-ui/panels.d.ts +11 -0
- package/dev-ui/panels.js +33 -0
- package/dev-ui/theme.d.ts +151 -0
- package/dev-ui/theme.js +50 -0
- package/entry/Root.d.ts +3 -1
- package/entry/Root.js +18 -6
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/rpc-client.d.ts +3 -0
- package/hooks/rpc-client.js +15 -0
- package/hooks/useAppData.js +0 -1
- package/hooks/useRPC.d.ts +32 -0
- package/hooks/useRPC.js +18 -0
- package/package.json +19 -8
- package/routing/routing.js +1 -1
- package/serverless/create-rpc-client.d.ts +20 -0
- package/serverless/create-rpc-client.js +20 -0
- package/serverless/define-api.d.ts +2 -0
- package/serverless/define-api.js +66 -0
- package/serverless/define-rpc-router.d.ts +6 -0
- package/serverless/define-rpc-router.js +35 -0
- package/serverless/error-codes.d.ts +2 -0
- package/serverless/error-codes.js +14 -0
- package/serverless/index.d.ts +5 -0
- package/serverless/index.js +18 -0
- package/serverless/rpc-client.d.ts +3 -0
- package/serverless/rpc-client.js +15 -0
- package/serverless/rpc-provider.d.ts +1 -0
- package/serverless/rpc-provider.js +5 -0
- package/serverless-template/_utils/PageMeta.tsx +44 -0
- package/serverless-template/_utils/ed-config.ts +5 -0
- package/serverless-template/_utils/fetch-wordpress-props.ts +40 -8
- package/serverless-template/_utils/fetch-wp.ts +16 -0
- package/serverless-template/global.d.ts +7 -1
- package/serverless-template/next.config.js +73 -53
- package/serverless-template/package.json +5 -3
- package/serverless-template/pages/404.tsx +12 -0
- package/serverless-template/pages/[...slug].tsx +7 -2
- package/serverless-template/pages/_app.tsx +32 -12
- package/serverless-template/pages/_document.tsx +19 -0
- package/serverless-template/pages/api/rest/{[...method].ts → [method].ts} +4 -2
- package/serverless-template/pages/api/trpc/[...trpc].ts +26 -0
- package/serverless-template/pages/index.tsx +2 -2
- package/style/createStitches.d.ts +71 -1
- package/style/createStitches.js +151 -45
- package/utils/getRepoName.d.ts +2 -2
- package/utils/getRepoName.js +14 -52
- package/utils/updateEnvFile.d.ts +1 -0
- package/utils/updateEnvFile.js +76 -0
- package/cli/prepare-next.d.ts +0 -0
- package/cli/prepare-next.js +0 -1
- package/entry/entry.serverless.dev.d.ts +0 -0
- package/entry/entry.serverless.dev.js +0 -2
- package/fields/ImageWell.d.ts +0 -8
- package/fields/ImageWell.js +0 -64
- package/serverless-template/package-lock.json +0 -641
- package/serverless-template/pages/api/hello.ts +0 -10
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// export const RESTErrorCodes = {
|
|
3
|
+
// notfound: 404,
|
|
4
|
+
// badrequest: 400,
|
|
5
|
+
// unauthorized: 401,
|
|
6
|
+
// forbidden: 403,
|
|
7
|
+
// invalidverb: 400,
|
|
8
|
+
// querystring: 400,
|
|
9
|
+
// body: 400,
|
|
10
|
+
// params: 400,
|
|
11
|
+
// internal: 500,
|
|
12
|
+
// }
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.default = {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RPCError = void 0;
|
|
14
|
+
var server_1 = require("@trpc/server");
|
|
15
|
+
__exportStar(require("./define-api"), exports);
|
|
16
|
+
__exportStar(require("./define-rpc-router"), exports);
|
|
17
|
+
__exportStar(require("./error-codes"), exports);
|
|
18
|
+
exports.RPCError = server_1.TRPCError;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const useRPCQuery: <TPath extends string>(pathAndInput: [TPath, (null | undefined)?], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath, RPCRouter, RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>> | undefined) => import("react-query").UseQueryResult<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>>;
|
|
2
|
+
export declare const useRPCMutation: <TPath_1 extends string>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>, RPCRouter> | undefined) => import("react-query").UseMutationResult<RPCRouter, import("@trpc/react").TRPCClientErrorLike<RPCRouter>, RPCRouter, unknown>;
|
|
3
|
+
export declare const rpcClient: import("@trpc/react").TRPCClient<RPCRouter>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rpcClient = exports.useRPCMutation = exports.useRPCQuery = void 0;
|
|
4
|
+
var react_1 = require("@trpc/react");
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
var _a = (0, react_1.createReactQueryHooks)({
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
url: process.serverlessEndpoint + "/api/trpc",
|
|
9
|
+
}), useQuery = _a.useQuery, useMutation = _a.useMutation, createClient = _a.createClient;
|
|
10
|
+
exports.useRPCQuery = useQuery;
|
|
11
|
+
exports.useRPCMutation = useMutation;
|
|
12
|
+
exports.rpcClient = createClient({
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
url: process.serverlessEndpoint + "/api/trpc",
|
|
15
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function RPCProvider(): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ParsedRouteTags } from "eddev/routing/remoteProps"
|
|
2
|
+
import Head from "next/head"
|
|
3
|
+
import { Fragment } from "react"
|
|
4
|
+
|
|
5
|
+
type Props = ParsedRouteTags
|
|
6
|
+
|
|
7
|
+
export function PageMeta(props: Props) {
|
|
8
|
+
return (
|
|
9
|
+
<Head>
|
|
10
|
+
{props.title?.map((tag, i) => (
|
|
11
|
+
<title key={"title" + i}>{tag.__code}</title>
|
|
12
|
+
))}
|
|
13
|
+
{/* {props.style?.map((tag, i) => {
|
|
14
|
+
return (
|
|
15
|
+
<style
|
|
16
|
+
key={"style" + i}
|
|
17
|
+
className={tag["class"]}
|
|
18
|
+
type={tag.type}
|
|
19
|
+
id={tag.id}
|
|
20
|
+
dangerouslySetInnerHTML={{ __html: tag.__code }}
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
})}
|
|
24
|
+
{props.script?.map((tag, i) => {
|
|
25
|
+
return (
|
|
26
|
+
<script
|
|
27
|
+
key={"script" + i}
|
|
28
|
+
className={tag["class"]}
|
|
29
|
+
type={tag.type}
|
|
30
|
+
id={tag.id}
|
|
31
|
+
dangerouslySetInnerHTML={{ __html: tag.__code }}
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
})} */}
|
|
35
|
+
{props.meta?.map((tag, i) => {
|
|
36
|
+
return <meta key={"meta" + i} {...tag} />
|
|
37
|
+
})}
|
|
38
|
+
{props.link?.map((tag, i) => {
|
|
39
|
+
if (tag.rel === "stylesheet") return <Fragment key={"link" + i} />
|
|
40
|
+
return <link key={"link" + i} {...tag} />
|
|
41
|
+
})}
|
|
42
|
+
</Head>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -1,17 +1,49 @@
|
|
|
1
|
+
import config from "./ed-config"
|
|
2
|
+
import { fetchWP } from "./fetch-wp"
|
|
3
|
+
|
|
4
|
+
const settings = config.serverless
|
|
5
|
+
|
|
1
6
|
export async function fetchWordpressProps(pathname: string) {
|
|
7
|
+
// Determine the URL for fetching
|
|
2
8
|
const origin = (process.env.SITE_URL as string).replace(/\/$/, "")
|
|
3
9
|
pathname = pathname.replace(/(^\/|\/$)/g, "")
|
|
4
|
-
|
|
5
10
|
const propsURL = origin + ("/" + pathname + "/?_props=all").replace(/\/+/, "/")
|
|
6
|
-
|
|
11
|
+
|
|
12
|
+
// Make the request
|
|
13
|
+
let response = await fetchWP(propsURL, {})
|
|
14
|
+
|
|
15
|
+
// Convert to text, rather than JSON — so we can do find-and-replace
|
|
7
16
|
let text = await response.text()
|
|
8
17
|
|
|
9
18
|
// Convert absolute site URL details to relative paths
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
text = text.replace(new RegExp(origin.replace(/(http|https)/, `https?`) + "([a-z0-9-_./]+)", "g"), (url) => {
|
|
20
|
+
const path = url.replace(/https?:\/\/[^\/]+/, "")
|
|
21
|
+
if (path.startsWith("/wp-content/uploads/")) {
|
|
22
|
+
if (settings?.uploads === "proxy") {
|
|
23
|
+
return path
|
|
24
|
+
} else if (settings?.uploads === "remote") {
|
|
25
|
+
return url
|
|
26
|
+
}
|
|
27
|
+
} else if (path.startsWith("/wp-content/themes/")) {
|
|
28
|
+
if (settings?.uploads === "proxy") {
|
|
29
|
+
return path
|
|
30
|
+
} else if (settings?.uploads === "remote") {
|
|
31
|
+
return url
|
|
32
|
+
}
|
|
33
|
+
} else if (path.startsWith("/wp-content/plugins/")) {
|
|
34
|
+
if (settings?.uploads === "proxy") {
|
|
35
|
+
return path
|
|
36
|
+
} else if (settings?.uploads === "remote") {
|
|
37
|
+
return url
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
return path
|
|
41
|
+
}
|
|
42
|
+
return url
|
|
43
|
+
})
|
|
15
44
|
|
|
16
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
status: response.status,
|
|
47
|
+
data: JSON.parse(text),
|
|
48
|
+
}
|
|
17
49
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Agent } from "https"
|
|
2
|
+
|
|
3
|
+
// Used to allow self-signed certificates
|
|
4
|
+
const agent = new Agent({
|
|
5
|
+
rejectUnauthorized: false,
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export const fetchWP: typeof fetch = async (url, opts) => {
|
|
9
|
+
// TODO — basic auth via env variable
|
|
10
|
+
// https://stackoverflow.com/questions/43842793/basic-authentication-with-fetch
|
|
11
|
+
return fetch(url, {
|
|
12
|
+
...opts,
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
agent: url.includes("https") ? agent : undefined,
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -1,58 +1,78 @@
|
|
|
1
1
|
const withTM = require("next-transpile-modules")
|
|
2
|
-
const { resolve } = require("path")
|
|
2
|
+
const { resolve, join } = require("path")
|
|
3
3
|
const { DefinePlugin } = require("webpack")
|
|
4
|
+
const settings = require("./ed.config.json")
|
|
5
|
+
const { getRepoName } = require("eddev/utils/getRepoName")
|
|
6
|
+
const { existsSync } = require("fs")
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
module.exports = (() => {
|
|
9
|
+
const cwd = process.cwd()
|
|
10
|
+
const REPO_NAME = getRepoName(cwd.replace(/\/\.serverless/, "")).repoName
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
return withTM(["eddev"])({
|
|
13
|
+
rewrites() {
|
|
14
|
+
return {
|
|
15
|
+
afterFiles: [
|
|
16
|
+
settings.serverless.uploads === "proxy" && {
|
|
17
|
+
source: "/wp-content/uploads/:path*",
|
|
18
|
+
destination: process.env.SITE_URL + "/wp-content/uploads/:path*",
|
|
19
|
+
},
|
|
20
|
+
settings.serverless.plugin === "proxy" && {
|
|
21
|
+
source: "/wp-content/plugins/:path*",
|
|
22
|
+
destination: process.env.SITE_URL + "/wp-content/plugins/:path*",
|
|
23
|
+
},
|
|
24
|
+
settings.serverless.theme === "proxy" && {
|
|
25
|
+
source: "/wp-content/themes/:path*",
|
|
26
|
+
destination: process.env.SITE_URL + "/wp-content/themes/:path*",
|
|
27
|
+
},
|
|
28
|
+
].filter(Boolean),
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
experimental: {},
|
|
32
|
+
typescript: {
|
|
33
|
+
ignoreBuildErrors: true,
|
|
34
|
+
},
|
|
35
|
+
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
|
|
36
|
+
config.resolve.alias = {
|
|
37
|
+
...config.resolve.alias,
|
|
38
|
+
"@manifest/views": resolve(cwd, "manifest_views.ts"),
|
|
39
|
+
"@manifest/blocks": resolve(cwd, "manifest_blocks.ts"),
|
|
40
|
+
"@theme": resolve(cwd, "theme.css.tsx"),
|
|
41
|
+
"@wordpress/components": resolve(cwd, "null.ts"),
|
|
42
|
+
"@wordpress/element": resolve(cwd, "null.ts"),
|
|
43
|
+
"@wordpress/blocks": resolve(cwd, "null.ts"),
|
|
44
|
+
"@wordpress/utils": resolve(cwd, "null.ts"),
|
|
45
|
+
"@wordpress/data": resolve(cwd, "null.ts"),
|
|
46
|
+
"@wordpress/hooks": resolve(cwd, "null.ts"),
|
|
47
|
+
"@wordpress/block-editor": resolve(cwd, "null.ts"),
|
|
48
|
+
}
|
|
49
|
+
// config.defines["process.dev"] = isDev ? "true" : "false"
|
|
50
|
+
const define = config.plugins.find((plugin) => plugin instanceof DefinePlugin)
|
|
51
|
+
define.definitions["process.serverless"] = "true"
|
|
52
|
+
define.definitions["process.admin"] = "false"
|
|
53
|
+
define.definitions["process.client"] = isServer ? "false" : "true"
|
|
54
|
+
define.definitions["process.dev"] = process.env.NODE_ENV === "development"
|
|
8
55
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// "@hooks/*": resolve(cwd, "hooks/*"),
|
|
33
|
-
// "@queries/*": resolve(cwd, "hooks/queries/*"),
|
|
34
|
-
"@theme": resolve(cwd, "theme.css.tsx"),
|
|
35
|
-
"@wordpress/components": resolve(cwd, "null.ts"),
|
|
36
|
-
"@wordpress/element": resolve(cwd, "null.ts"),
|
|
37
|
-
"@wordpress/blocks": resolve(cwd, "null.ts"),
|
|
38
|
-
"@wordpress/utils": resolve(cwd, "null.ts"),
|
|
39
|
-
"@wordpress/data": resolve(cwd, "null.ts"),
|
|
40
|
-
"@wordpress/hooks": resolve(cwd, "null.ts"),
|
|
41
|
-
"@wordpress/block-editor": resolve(cwd, "null.ts"),
|
|
42
|
-
}
|
|
43
|
-
// config.defines["process.dev"] = isDev ? "true" : "false"
|
|
44
|
-
const define = config.plugins.find((plugin) => plugin instanceof DefinePlugin)
|
|
45
|
-
define.definitions["process.serverless"] = "true"
|
|
46
|
-
define.definitions["process.admin"] = "false"
|
|
47
|
-
define.definitions["process.dev"] = process.env.NODE_ENV === "development"
|
|
48
|
-
// config.plugins.push(
|
|
49
|
-
// new DefinePlugin({
|
|
50
|
-
// "process.serverless": "true",
|
|
51
|
-
// "process.admin": "false",
|
|
52
|
-
// // "process.env.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
53
|
-
// // "process.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
54
|
-
// })
|
|
55
|
-
// )
|
|
56
|
-
return config
|
|
57
|
-
},
|
|
58
|
-
})
|
|
56
|
+
const themePath =
|
|
57
|
+
(settings.serverless.theme === "remote" ? process.env.SITE_URL : "") + "/wp-content/themes/" + REPO_NAME
|
|
58
|
+
|
|
59
|
+
define.definitions["process.env.themePath"] = JSON.stringify(themePath)
|
|
60
|
+
define.definitions["process.themePath"] = JSON.stringify(themePath)
|
|
61
|
+
define.definitions["process.devUI"] = settings.devUI === "enabled"
|
|
62
|
+
define.definitions["process.serverlessEndpoint"] = JSON.stringify("/")
|
|
63
|
+
|
|
64
|
+
const rpcExists =
|
|
65
|
+
existsSync(join(process.cwd(), "apis/_rpc.ts")) || existsSync(join(process.cwd(), "apis/_rpc/index.ts"))
|
|
66
|
+
define.definitions["process.rpcEnabled"] = rpcExists ? "true" : "false"
|
|
67
|
+
// config.plugins.push(
|
|
68
|
+
// new DefinePlugin({
|
|
69
|
+
// "process.serverless": "true",
|
|
70
|
+
// "process.admin": "false",
|
|
71
|
+
// // "process.env.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
72
|
+
// // "process.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
73
|
+
// })
|
|
74
|
+
// )
|
|
75
|
+
return config
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
})()
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
"start": "next start"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"next": "12.0.10",
|
|
12
11
|
"react": "17.0.2",
|
|
13
|
-
"react-dom": "17.0.2"
|
|
12
|
+
"react-dom": "17.0.2",
|
|
13
|
+
"@trpc/next": "^9.19.0",
|
|
14
|
+
"@trpc/server": "^9.19.0"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/react": "17.0.39",
|
|
17
|
-
"typescript": "4.5.5"
|
|
18
|
+
"typescript": "4.5.5",
|
|
19
|
+
"next": "^12.1.0"
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { fetchWordpressProps } from "../_utils/fetch-wordpress-props"
|
|
2
|
+
|
|
3
|
+
export default function Home() {
|
|
4
|
+
return <div />
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export async function getStaticProps({ params }: any) {
|
|
8
|
+
const result = await fetchWordpressProps("/404")
|
|
9
|
+
return {
|
|
10
|
+
props: result.data,
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -2,7 +2,7 @@ import { GetStaticPathsResult, GetStaticPropsContext, GetStaticPropsResult } fro
|
|
|
2
2
|
import { fetchWordpressProps } from "../_utils/fetch-wordpress-props"
|
|
3
3
|
|
|
4
4
|
export default function Home(props: any) {
|
|
5
|
-
return <div
|
|
5
|
+
return <div />
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export async function getStaticPaths(): Promise<GetStaticPathsResult> {
|
|
@@ -14,7 +14,12 @@ export async function getStaticPaths(): Promise<GetStaticPathsResult> {
|
|
|
14
14
|
|
|
15
15
|
export async function getStaticProps({ params }: GetStaticPropsContext): Promise<GetStaticPropsResult<any>> {
|
|
16
16
|
const result = await fetchWordpressProps((params?.slug as string[]).join("/"))
|
|
17
|
+
if (result.status === 404) {
|
|
18
|
+
return {
|
|
19
|
+
notFound: true,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
17
22
|
return {
|
|
18
|
-
props: result,
|
|
23
|
+
props: result.data,
|
|
19
24
|
}
|
|
20
25
|
}
|
|
@@ -5,30 +5,50 @@ import { NextRouter } from "eddev/components/NextRouter"
|
|
|
5
5
|
import { ServerlessAppDataProvider } from "eddev/utils/serverlessAppContext"
|
|
6
6
|
import { useMemo } from "react"
|
|
7
7
|
import { useRouter } from "next/router"
|
|
8
|
+
import { DevUILoader } from "eddev/dev-ui/loader"
|
|
9
|
+
import { PageMeta } from "../_utils/PageMeta"
|
|
10
|
+
import { withTRPC } from "@trpc/next"
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
if (!pageProps.appData) return <div />
|
|
11
|
-
|
|
12
|
-
const appData = useMemo(() => {
|
|
13
|
-
return pageProps.appData.data
|
|
14
|
-
}, [])
|
|
12
|
+
let appData: any
|
|
15
13
|
|
|
14
|
+
function Root({ Component, pageProps }: AppProps) {
|
|
16
15
|
const route = useRouter()
|
|
17
16
|
|
|
17
|
+
if (!appData) appData = pageProps?.appData?.data
|
|
18
|
+
|
|
19
|
+
// const appData = useMemo(() => {
|
|
20
|
+
// return pageProps?.appData?.data
|
|
21
|
+
// }, [])
|
|
22
|
+
|
|
18
23
|
const viewProps = pageProps?.viewData?.data
|
|
19
24
|
|
|
20
|
-
const View = manifest[pageProps.view]
|
|
25
|
+
const View = manifest[pageProps.view || "404"]
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
if (!appData) return <div />
|
|
28
|
+
|
|
29
|
+
console.log(`Could not load view named "${pageProps.view}"`)
|
|
23
30
|
|
|
24
31
|
return (
|
|
25
32
|
<ServerlessAppDataProvider value={appData}>
|
|
26
33
|
<NextRouter data={pageProps} path={route.pathname}>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
{pageProps?.meta?.head && <PageMeta {...pageProps?.meta?.head} />}
|
|
35
|
+
{pageProps?.meta?.footer && <PageMeta {...pageProps?.meta?.footer} />}
|
|
36
|
+
{process.devUI ? <DevUILoader /> : null}
|
|
37
|
+
<App>{View && <View {...viewProps} />}</App>
|
|
30
38
|
</NextRouter>
|
|
31
39
|
</ServerlessAppDataProvider>
|
|
32
40
|
)
|
|
33
41
|
}
|
|
34
|
-
|
|
42
|
+
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
export default process.rpcEnabled
|
|
45
|
+
? withTRPC({
|
|
46
|
+
config({ ctx }) {
|
|
47
|
+
return {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
url: process.serverlessEndpoint + "api/trpc",
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
ssr: false,
|
|
53
|
+
})(Root)
|
|
54
|
+
: Root
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import NextDocument, { Html, Head, Main, NextScript } from "next/document"
|
|
3
|
+
import { getCssText } from "@theme"
|
|
4
|
+
|
|
5
|
+
export default class Document extends NextDocument {
|
|
6
|
+
render() {
|
|
7
|
+
return (
|
|
8
|
+
<Html lang="en">
|
|
9
|
+
<Head>
|
|
10
|
+
<style id="stitches" dangerouslySetInnerHTML={{ __html: getCssText() }} />
|
|
11
|
+
</Head>
|
|
12
|
+
<body>
|
|
13
|
+
<Main />
|
|
14
|
+
<NextScript />
|
|
15
|
+
</body>
|
|
16
|
+
</Html>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { fetchWP } from "../../../_utils/fetch-wp"
|
|
2
|
+
|
|
1
3
|
const validProxyPaths = {
|
|
2
4
|
"form-submit": {
|
|
3
5
|
path: "/wp-json/ed/v1/gf/submit",
|
|
@@ -15,7 +17,7 @@ const validProxyPaths = {
|
|
|
15
17
|
|
|
16
18
|
export default async function (req: any, res: any) {
|
|
17
19
|
// Ensure that the request is for a proxy path
|
|
18
|
-
const proxyPath = validProxyPaths[req.query.method
|
|
20
|
+
const proxyPath = validProxyPaths[req.query.method as keyof typeof validProxyPaths]!
|
|
19
21
|
|
|
20
22
|
if (!proxyPath) {
|
|
21
23
|
return res.status(404).json({
|
|
@@ -25,7 +27,7 @@ export default async function (req: any, res: any) {
|
|
|
25
27
|
|
|
26
28
|
const finalPath = proxyPath.path.replace("*", req.query.method.slice(1).join("/"))
|
|
27
29
|
|
|
28
|
-
const response = await
|
|
30
|
+
const response = await fetchWP(process.env.SITE_URL + finalPath, {
|
|
29
31
|
method: proxyPath.method,
|
|
30
32
|
headers: {
|
|
31
33
|
"Content-Type": "application/json",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import { router, createContext } from "../../../apis/_rpc"
|
|
3
|
+
import * as trpcNext from "@trpc/server/adapters/next"
|
|
4
|
+
import type { NextApiRequest, NextApiResponse } from "next"
|
|
5
|
+
|
|
6
|
+
const handler = trpcNext.createNextApiHandler({
|
|
7
|
+
router: router,
|
|
8
|
+
createContext: createContext,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
export default function (req: NextApiRequest, res: NextApiResponse) {
|
|
12
|
+
// TODO: Use an origin whitelist
|
|
13
|
+
const origin = req.headers.origin
|
|
14
|
+
if (origin) {
|
|
15
|
+
res.setHeader("Access-Control-Allow-Origin", "*")
|
|
16
|
+
res.setHeader("Access-Control-Request-Method", "*")
|
|
17
|
+
res.setHeader("Access-Control-Request-Method", "OPTIONS, GET, POST")
|
|
18
|
+
res.setHeader("Access-Control-Allow-Headers", "*")
|
|
19
|
+
if (req.method === "OPTIONS") {
|
|
20
|
+
res.writeHead(200)
|
|
21
|
+
res.end()
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return handler(req, res)
|
|
26
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { fetchWordpressProps } from "../_utils/fetch-wordpress-props"
|
|
2
2
|
|
|
3
3
|
export default function Home() {
|
|
4
|
-
return <div
|
|
4
|
+
return <div />
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export async function getStaticProps({ params }: any) {
|
|
8
8
|
const result = await fetchWordpressProps("/")
|
|
9
9
|
return {
|
|
10
|
-
props: result,
|
|
10
|
+
props: result.data,
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -18,6 +18,12 @@ declare type TypographyConfig<Theme extends ConfigType.Theme<{}>, Media extends
|
|
|
18
18
|
lineHeight?: ResponsiveValue<Media, Theme["lineHeights"] extends {} ? `$${Extract<keyof Theme["lineHeights"], string>}` | CSS["lineHeight"] : CSS["lineHeight"]>;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
+
export declare type BreakpointArray = {
|
|
22
|
+
key: string;
|
|
23
|
+
min: string | null;
|
|
24
|
+
max: string | null;
|
|
25
|
+
}[];
|
|
26
|
+
export declare function parseBreakpoints(names: string[], medias: any): BreakpointArray;
|
|
21
27
|
interface GridConfig<Theme extends ConfigType.Theme<{}>, Media extends ConfigType.Media<{}>> {
|
|
22
28
|
columns: number;
|
|
23
29
|
breakpoints: {
|
|
@@ -36,7 +42,49 @@ declare type ResponsiveScale<Media extends ConfigType.Media<{}>, T extends {}> =
|
|
|
36
42
|
declare type ResponsiveConfig<Media extends ConfigType.Media<{}>, T extends {}> = {
|
|
37
43
|
[Scale in keyof T]: ResponsiveScale<Media, T[Scale]>;
|
|
38
44
|
};
|
|
39
|
-
|
|
45
|
+
declare type ResponsiveAtom = {
|
|
46
|
+
lerpStart: boolean;
|
|
47
|
+
} & ({
|
|
48
|
+
type: "multiplier";
|
|
49
|
+
value: number;
|
|
50
|
+
} | {
|
|
51
|
+
type: "percent";
|
|
52
|
+
value: number;
|
|
53
|
+
} | {
|
|
54
|
+
type: "px";
|
|
55
|
+
value: number;
|
|
56
|
+
} | {
|
|
57
|
+
type: "number";
|
|
58
|
+
value: number;
|
|
59
|
+
} | {
|
|
60
|
+
type: "unknown";
|
|
61
|
+
value: string | number;
|
|
62
|
+
} | {
|
|
63
|
+
type: "undefined";
|
|
64
|
+
});
|
|
65
|
+
export declare type ResponsiveAtomCalc = ResponsiveAtom & {
|
|
66
|
+
defined: boolean;
|
|
67
|
+
breakpoint: string;
|
|
68
|
+
baseBreakpoint: string;
|
|
69
|
+
lastBreakpoint: string;
|
|
70
|
+
lerping?: {
|
|
71
|
+
fromBP: string | null;
|
|
72
|
+
toBP: string | null;
|
|
73
|
+
minMedia: number;
|
|
74
|
+
maxMedia: number;
|
|
75
|
+
minValue: number;
|
|
76
|
+
maxValue: number;
|
|
77
|
+
};
|
|
78
|
+
concreteValue: number | null;
|
|
79
|
+
};
|
|
80
|
+
export declare function parseResponsiveObject(breakpoints: ReturnType<typeof parseBreakpoints>, object: any): ResponsiveAtomCalc[];
|
|
81
|
+
export declare function getResponsiveObjectStyles(breakpoints: ReturnType<typeof parseBreakpoints>, object: any, varName: string, unit?: string): any[];
|
|
82
|
+
export declare function parseResponsiveTokens(theme: any, breakpoints: any): {
|
|
83
|
+
initialResponsive: any;
|
|
84
|
+
globalResponsive: any;
|
|
85
|
+
};
|
|
86
|
+
export declare function createStitches<Prefix extends string = "", Media extends {} = {}, Breakpoints extends (keyof Media)[] = [], Theme extends {} = {}, Responsive extends {} = {}, ThemeMap extends {} = DefaultThemeMap, Utils extends {} = {}, Typography extends {} = {}>(config: {
|
|
87
|
+
breakpoints: Breakpoints;
|
|
40
88
|
prefix?: ConfigType.Prefix<Prefix>;
|
|
41
89
|
media: ConfigType.Media<Media>;
|
|
42
90
|
theme: ConfigType.Theme<Theme>;
|
|
@@ -55,12 +103,34 @@ export declare function createStitches<Prefix extends string = "", Media extends
|
|
|
55
103
|
themeMap?: ConfigType.ThemeMap<ThemeMap>;
|
|
56
104
|
utils: ConfigType.Utils<Utils>;
|
|
57
105
|
}): {
|
|
106
|
+
originalConfig: {
|
|
107
|
+
breakpoints: Breakpoints;
|
|
108
|
+
prefix?: ConfigType.Prefix<Prefix> | undefined;
|
|
109
|
+
media: ConfigType.Media<Media>;
|
|
110
|
+
theme: ConfigType.Theme<Theme>;
|
|
111
|
+
responsive: ResponsiveConfig<Media & {
|
|
112
|
+
initial: string;
|
|
113
|
+
editor: string;
|
|
114
|
+
}, Responsive>;
|
|
115
|
+
typography: TypographyConfig<Theme, Media & {
|
|
116
|
+
initial: string;
|
|
117
|
+
editor: string;
|
|
118
|
+
}, Typography>;
|
|
119
|
+
grid: GridConfig<Theme, Media & {
|
|
120
|
+
initial: string;
|
|
121
|
+
editor: string;
|
|
122
|
+
}>;
|
|
123
|
+
themeMap?: ConfigType.ThemeMap<ThemeMap> | undefined;
|
|
124
|
+
utils: ConfigType.Utils<Utils>;
|
|
125
|
+
};
|
|
126
|
+
breakpoints: BreakpointArray;
|
|
58
127
|
typeVariants: { [key in keyof TypographyConfig<Theme, Media & {
|
|
59
128
|
initial: string;
|
|
60
129
|
editor: string;
|
|
61
130
|
}, Typography>]: any; };
|
|
62
131
|
gridVariants: {};
|
|
63
132
|
responsiveTokens: { [Scale in keyof Responsive]: { [T in keyof Responsive[Scale]]: number; }; };
|
|
133
|
+
responsiveGlobals: any;
|
|
64
134
|
config: {
|
|
65
135
|
prefix: "";
|
|
66
136
|
media: {
|