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.
Files changed (131) hide show
  1. package/build/build-favicon.d.ts +1 -0
  2. package/build/build-favicon.js +71 -0
  3. package/build/create-serverless-dev-worker.d.ts +3 -0
  4. package/build/create-serverless-dev-worker.js +99 -0
  5. package/build/get-webpack-config.js +25 -11
  6. package/build/reporter.js +0 -109
  7. package/build/serverless/create-next-app.d.ts +2 -0
  8. package/build/serverless/create-next-app.js +312 -78
  9. package/build/state/serverless-state.d.ts +26 -0
  10. package/build/state/serverless-state.js +2 -0
  11. package/build/workers/codegen-worker-script.js +33 -0
  12. package/build/workers/serverless-worker-dev-script.d.ts +1 -0
  13. package/build/workers/serverless-worker-dev-script.js +21 -0
  14. package/cli/build.dev.js +38 -7
  15. package/cli/build.prod.js +13 -1
  16. package/cli/cli.js +26 -18
  17. package/cli/display/components/DevCLIDisplay.d.ts +3 -0
  18. package/cli/display/components/DevCLIDisplay.js +20 -1
  19. package/cli/display/components/ServerlessDisplay.d.ts +9 -0
  20. package/cli/display/components/ServerlessDisplay.js +68 -0
  21. package/config/config-schema.d.ts +55 -0
  22. package/config/config-schema.js +19 -0
  23. package/config/create-schema-file.d.ts +1 -0
  24. package/config/create-schema-file.js +20 -0
  25. package/config/get-config.d.ts +39 -0
  26. package/config/get-config.js +32 -0
  27. package/config/index.d.ts +2 -0
  28. package/config/index.js +14 -0
  29. package/config/parse-config.d.ts +25 -0
  30. package/config/parse-config.js +8 -0
  31. package/config/print-zod-errors.d.ts +2 -0
  32. package/config/print-zod-errors.js +14 -0
  33. package/dev-ui/components/BreakpointColumnHeader.d.ts +11 -0
  34. package/dev-ui/components/BreakpointColumnHeader.js +47 -0
  35. package/dev-ui/components/BreakpointIndicator.d.ts +2 -0
  36. package/dev-ui/components/BreakpointIndicator.js +138 -0
  37. package/dev-ui/components/DevUI.d.ts +2 -0
  38. package/dev-ui/components/DevUI.js +28 -0
  39. package/dev-ui/components/Launcher.d.ts +98 -0
  40. package/dev-ui/components/Launcher.js +94 -0
  41. package/dev-ui/components/PanelWrapper.d.ts +8 -0
  42. package/dev-ui/components/PanelWrapper.js +37 -0
  43. package/dev-ui/components/ResponsiveLerpControl.d.ts +8 -0
  44. package/dev-ui/components/ResponsiveLerpControl.js +177 -0
  45. package/dev-ui/components/ResponsiveScaleEditor.d.ts +26 -0
  46. package/dev-ui/components/ResponsiveScaleEditor.js +233 -0
  47. package/dev-ui/components/atoms/Button.d.ts +47 -0
  48. package/dev-ui/components/atoms/Button.js +67 -0
  49. package/dev-ui/components/atoms/Dropdown.d.ts +13 -0
  50. package/dev-ui/components/atoms/Dropdown.js +50 -0
  51. package/dev-ui/components/atoms/NumberField.d.ts +12 -0
  52. package/dev-ui/components/atoms/NumberField.js +111 -0
  53. package/dev-ui/components/atoms/Spacer.d.ts +42 -0
  54. package/dev-ui/components/atoms/Spacer.js +8 -0
  55. package/dev-ui/components/atoms/Text.d.ts +45 -0
  56. package/dev-ui/components/atoms/Text.js +39 -0
  57. package/dev-ui/components/atoms/ToggleButton.d.ts +8 -0
  58. package/dev-ui/components/atoms/ToggleButton.js +41 -0
  59. package/dev-ui/components/atoms/Tooltip.d.ts +9 -0
  60. package/dev-ui/components/atoms/Tooltip.js +66 -0
  61. package/dev-ui/components/panels/PageDataDebugger.d.ts +2 -0
  62. package/dev-ui/components/panels/PageDataDebugger.js +30 -0
  63. package/dev-ui/components/panels/SpacingEditor.d.ts +2 -0
  64. package/dev-ui/components/panels/SpacingEditor.js +88 -0
  65. package/dev-ui/components/panels/TypographyEditor.d.ts +2 -0
  66. package/dev-ui/components/panels/TypographyEditor.js +88 -0
  67. package/dev-ui/hooks/useBreakpoint.d.ts +11 -0
  68. package/dev-ui/hooks/useBreakpoint.js +59 -0
  69. package/dev-ui/hooks/usePersistState.d.ts +1 -0
  70. package/dev-ui/hooks/usePersistState.js +36 -0
  71. package/dev-ui/hooks/useStylesheet.d.ts +4 -0
  72. package/dev-ui/hooks/useStylesheet.js +31 -0
  73. package/dev-ui/icons.d.ts +15 -0
  74. package/dev-ui/icons.js +29 -0
  75. package/dev-ui/index.d.ts +1 -0
  76. package/dev-ui/index.js +13 -0
  77. package/dev-ui/loader.d.ts +2 -0
  78. package/dev-ui/loader.js +42 -0
  79. package/dev-ui/panels.d.ts +11 -0
  80. package/dev-ui/panels.js +33 -0
  81. package/dev-ui/theme.d.ts +151 -0
  82. package/dev-ui/theme.js +50 -0
  83. package/entry/Root.d.ts +3 -1
  84. package/entry/Root.js +18 -6
  85. package/hooks/index.d.ts +1 -0
  86. package/hooks/index.js +1 -0
  87. package/hooks/rpc-client.d.ts +3 -0
  88. package/hooks/rpc-client.js +15 -0
  89. package/hooks/useAppData.js +0 -1
  90. package/hooks/useRPC.d.ts +4 -0
  91. package/hooks/useRPC.js +16 -0
  92. package/package.json +19 -8
  93. package/serverless/create-rpc-client.d.ts +20 -0
  94. package/serverless/create-rpc-client.js +20 -0
  95. package/serverless/define-api.d.ts +2 -0
  96. package/serverless/define-api.js +66 -0
  97. package/serverless/define-rpc-router.d.ts +6 -0
  98. package/serverless/define-rpc-router.js +35 -0
  99. package/serverless/error-codes.d.ts +2 -0
  100. package/serverless/error-codes.js +14 -0
  101. package/serverless/index.d.ts +3 -0
  102. package/serverless/index.js +15 -0
  103. package/serverless/rpc-client.d.ts +3 -0
  104. package/serverless/rpc-client.js +15 -0
  105. package/serverless/rpc-provider.d.ts +1 -0
  106. package/serverless/rpc-provider.js +5 -0
  107. package/serverless-template/_utils/PageMeta.tsx +44 -0
  108. package/serverless-template/_utils/ed-config.ts +5 -0
  109. package/serverless-template/_utils/fetch-wordpress-props.ts +36 -6
  110. package/serverless-template/_utils/fetch-wp.ts +16 -0
  111. package/serverless-template/global.d.ts +1 -0
  112. package/serverless-template/next.config.js +72 -53
  113. package/serverless-template/package.json +5 -3
  114. package/serverless-template/pages/_app.tsx +20 -4
  115. package/serverless-template/pages/_document.tsx +19 -0
  116. package/serverless-template/pages/api/rest/{[...method].ts → [method].ts} +1 -1
  117. package/serverless-template/pages/api/trpc/[...trpc].ts +26 -0
  118. package/style/createStitches.d.ts +71 -1
  119. package/style/createStitches.js +151 -45
  120. package/utils/getRepoName.d.ts +2 -2
  121. package/utils/getRepoName.js +14 -52
  122. package/utils/updateEnvFile.d.ts +1 -0
  123. package/utils/updateEnvFile.js +76 -0
  124. package/cli/prepare-next.d.ts +0 -0
  125. package/cli/prepare-next.js +0 -1
  126. package/entry/entry.serverless.dev.d.ts +0 -0
  127. package/entry/entry.serverless.dev.js +0 -2
  128. package/fields/ImageWell.d.ts +0 -8
  129. package/fields/ImageWell.js +0 -64
  130. package/serverless-template/package-lock.json +0 -641
  131. 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,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RPCProvider = void 0;
4
+ function RPCProvider() { }
5
+ exports.RPCProvider = RPCProvider;
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ // @ts-ignore
2
+ const settings = require("../ed.config.json")
3
+ import { EDConfig } from "eddev/config"
4
+
5
+ export default settings as EDConfig
@@ -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
- let response = await fetch(propsURL)
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
- // console.log("WAS", text)
11
- console.log("REPLACING", origin, propsURL, response.status, response.statusText)
12
- text = text.replaceAll(origin, "")
13
- console.log("NOW", text)
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
+ }
@@ -4,6 +4,7 @@ declare global {
4
4
  browser: boolean
5
5
  serverless: boolean
6
6
  dev: boolean
7
+ devUI: boolean
7
8
  }
8
9
  }
9
10
  }
@@ -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
- // console.log("PATH", process.cwd().replace(/\.serverless/, ""))
8
+ module.exports = (() => {
9
+ const cwd = process.cwd()
10
+ const REPO_NAME = getRepoName(cwd.replace(/\/\.serverless/, "")).repoName
6
11
 
7
- module.exports = {}
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
- module.exports = withTM(["eddev"])({
10
- async rewrites() {
11
- return {
12
- afterFiles: [
13
- {
14
- source: "/wp-content/uploads/:path*",
15
- destination: process.env.SITE_URL + "/wp-content/uploads/:path*",
16
- },
17
- ],
18
- }
19
- },
20
- typescript: {
21
- ignoreBuildErrors: true,
22
- },
23
- webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
24
- const cwd = process.cwd()
25
- console.log(resolve(cwd, "manifest_blocks.ts"))
26
- config.resolve.alias = {
27
- ...config.resolve.alias,
28
- "@manifest/views": resolve(cwd, "manifest_views.ts"),
29
- "@manifest/blocks": resolve(cwd, "manifest_blocks.ts"),
30
- // "@components/*": resolve(cwd, "components/*"),
31
- // "@views/*": resolve(cwd, "views/*"),
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 MyApp({ Component, pageProps }: AppProps) {
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
- export default MyApp
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[0] as keyof typeof validProxyPaths]!
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
- export declare function createStitches<Prefix extends string = "", Media extends {} = {}, Theme extends {} = {}, Responsive extends {} = {}, ThemeMap extends {} = DefaultThemeMap, Utils extends {} = {}, Typography extends {} = {}>(config: {
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: {