eddev 0.2.0-beta.4 → 0.2.0-beta.42
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 +25 -11
- package/build/reporter.js +0 -109
- package/build/serverless/create-next-app.d.ts +2 -0
- package/build/serverless/create-next-app.js +312 -78
- 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/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 +4 -0
- package/hooks/useRPC.js +16 -0
- package/package.json +19 -8
- 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 +3 -0
- package/serverless/index.js +15 -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 +36 -6
- package/serverless-template/_utils/fetch-wp.ts +16 -0
- package/serverless-template/global.d.ts +1 -0
- package/serverless-template/next.config.js +72 -53
- package/serverless-template/package.json +5 -3
- package/serverless-template/pages/_app.tsx +20 -4
- package/serverless-template/pages/_document.tsx +19 -0
- package/serverless-template/pages/api/rest/{[...method].ts → [method].ts} +1 -1
- package/serverless-template/pages/api/trpc/[...trpc].ts +26 -0
- 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,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,16 +1,46 @@
|
|
|
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
|
+
console.log("Fetching props", propsURL)
|
|
13
|
+
|
|
14
|
+
// Make the request
|
|
15
|
+
let response = await fetchWP(propsURL, {})
|
|
16
|
+
|
|
17
|
+
// Convert to text, rather than JSON — so we can do find-and-replace
|
|
7
18
|
let text = await response.text()
|
|
8
19
|
|
|
9
20
|
// Convert absolute site URL details to relative paths
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
text = text.replace(new RegExp(origin.replace(/(http|https)/, `https?`) + "([a-z0-9-_./]+)", "g"), (url) => {
|
|
22
|
+
const path = url.replace(/https?:\/\/[^\/]+/, "")
|
|
23
|
+
if (path.startsWith("/wp-content/uploads/")) {
|
|
24
|
+
if (settings?.uploads === "proxy") {
|
|
25
|
+
return path
|
|
26
|
+
} else if (settings?.uploads === "remote") {
|
|
27
|
+
return url
|
|
28
|
+
}
|
|
29
|
+
} else if (path.startsWith("/wp-content/themes/")) {
|
|
30
|
+
if (settings?.uploads === "proxy") {
|
|
31
|
+
return path
|
|
32
|
+
} else if (settings?.uploads === "remote") {
|
|
33
|
+
return url
|
|
34
|
+
}
|
|
35
|
+
} else if (path.startsWith("/wp-content/plugins/")) {
|
|
36
|
+
if (settings?.uploads === "proxy") {
|
|
37
|
+
return path
|
|
38
|
+
} else if (settings?.uploads === "remote") {
|
|
39
|
+
return url
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return url
|
|
43
|
+
})
|
|
14
44
|
|
|
15
45
|
return JSON.parse(text)
|
|
16
46
|
}
|
|
@@ -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,77 @@
|
|
|
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.dev"] = process.env.NODE_ENV === "development"
|
|
8
54
|
|
|
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
|
-
})
|
|
55
|
+
const themePath =
|
|
56
|
+
(settings.serverless.theme === "remote" ? process.env.SITE_URL : "") + "/wp-content/themes/" + REPO_NAME
|
|
57
|
+
|
|
58
|
+
define.definitions["process.env.themePath"] = JSON.stringify(themePath)
|
|
59
|
+
define.definitions["process.themePath"] = JSON.stringify(themePath)
|
|
60
|
+
define.definitions["process.devUI"] = settings.devUI === "enabled"
|
|
61
|
+
define.definitions["process.serverlessEndpoint"] = JSON.stringify("/")
|
|
62
|
+
|
|
63
|
+
const rpcExists =
|
|
64
|
+
existsSync(join(process.cwd(), "apis/_rpc.ts")) || existsSync(join(process.cwd(), "apis/_rpc/index.ts"))
|
|
65
|
+
define.definitions["process.rpcEnabled"] = rpcExists ? "true" : "false"
|
|
66
|
+
// config.plugins.push(
|
|
67
|
+
// new DefinePlugin({
|
|
68
|
+
// "process.serverless": "true",
|
|
69
|
+
// "process.admin": "false",
|
|
70
|
+
// // "process.env.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
71
|
+
// // "process.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
72
|
+
// })
|
|
73
|
+
// )
|
|
74
|
+
return config
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
})()
|
|
@@ -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
|
}
|
|
@@ -5,8 +5,11 @@ 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
|
-
function
|
|
12
|
+
function Root({ Component, pageProps }: AppProps) {
|
|
10
13
|
if (!pageProps.appData) return <div />
|
|
11
14
|
|
|
12
15
|
const appData = useMemo(() => {
|
|
@@ -19,11 +22,12 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|
|
19
22
|
|
|
20
23
|
const View = manifest[pageProps.view]
|
|
21
24
|
|
|
22
|
-
console.log("ROUTE", pageProps, route.pathname)
|
|
23
|
-
|
|
24
25
|
return (
|
|
25
26
|
<ServerlessAppDataProvider value={appData}>
|
|
26
27
|
<NextRouter data={pageProps} path={route.pathname}>
|
|
28
|
+
{pageProps?.meta?.head && <PageMeta {...pageProps?.meta?.head} />}
|
|
29
|
+
{pageProps?.meta?.footer && <PageMeta {...pageProps?.meta?.footer} />}
|
|
30
|
+
{process.devUI && <DevUILoader />}
|
|
27
31
|
<App>
|
|
28
32
|
<View {...viewProps} />
|
|
29
33
|
</App>
|
|
@@ -31,4 +35,16 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|
|
31
35
|
</ServerlessAppDataProvider>
|
|
32
36
|
)
|
|
33
37
|
}
|
|
34
|
-
|
|
38
|
+
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
export default process.rpcEnabled
|
|
41
|
+
? withTRPC({
|
|
42
|
+
config({ ctx }) {
|
|
43
|
+
return {
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
url: process.serverlessEndpoint + "api/trpc",
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
ssr: false,
|
|
49
|
+
})(Root)
|
|
50
|
+
: 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
|
+
}
|
|
@@ -15,7 +15,7 @@ const validProxyPaths = {
|
|
|
15
15
|
|
|
16
16
|
export default async function (req: any, res: any) {
|
|
17
17
|
// Ensure that the request is for a proxy path
|
|
18
|
-
const proxyPath = validProxyPaths[req.query.method
|
|
18
|
+
const proxyPath = validProxyPaths[req.query.method as keyof typeof validProxyPaths]!
|
|
19
19
|
|
|
20
20
|
if (!proxyPath) {
|
|
21
21
|
return res.status(404).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
|
+
}
|
|
@@ -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: {
|