eddev 0.2.0-beta.0 → 0.2.0-beta.12
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 +19 -11
- package/build/reporter.js +0 -109
- package/build/serverless/create-next-app.d.ts +3 -0
- package/build/serverless/create-next-app.js +213 -70
- package/build/state/serverless-state.d.ts +26 -0
- package/build/state/serverless-state.js +2 -0
- package/build/workers/serverless-worker-dev-script.d.ts +1 -0
- package/build/workers/serverless-worker-dev-script.js +21 -0
- package/{cli/prepare-next.d.ts → build/workers/serverless-worker-script.d.ts} +0 -0
- package/{cli/prepare-next.js → build/workers/serverless-worker-script.js} +0 -0
- package/cli/build.dev.js +30 -7
- package/cli/build.prod.js +5 -0
- package/cli/cli.js +24 -5
- 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.d.ts +9 -0
- package/components/NextRouter.js +36 -0
- package/config/config-schema.d.ts +50 -0
- package/config/config-schema.js +18 -0
- package/config/create-schema-file.d.ts +1 -0
- package/config/create-schema-file.js +20 -0
- package/config/get-config.d.ts +36 -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 +23 -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/BreakpointItemHeader.d.ts +11 -0
- package/dev-ui/components/BreakpointItemHeader.js +50 -0
- package/dev-ui/components/BreakpointList.d.ts +6 -0
- package/dev-ui/components/BreakpointList.js +38 -0
- package/dev-ui/components/DevUI.d.ts +2 -0
- package/dev-ui/components/DevUI.js +19 -0
- package/dev-ui/components/Launcher.d.ts +9 -0
- package/dev-ui/components/Launcher.js +118 -0
- package/dev-ui/components/PanelWrapper.d.ts +4 -0
- package/dev-ui/components/PanelWrapper.js +21 -0
- package/dev-ui/components/Pill.d.ts +0 -0
- package/dev-ui/components/Pill.js +1 -0
- package/dev-ui/components/SpacingEditor.d.ts +2 -0
- package/dev-ui/components/SpacingEditor.js +10 -0
- package/dev-ui/components/Text.d.ts +39 -0
- package/dev-ui/components/Text.js +13 -0
- package/dev-ui/components/panels/SpacingEditor.d.ts +2 -0
- package/dev-ui/components/panels/SpacingEditor.js +56 -0
- package/dev-ui/hooks/usePersistState.d.ts +1 -0
- package/dev-ui/hooks/usePersistState.js +28 -0
- package/dev-ui/icons.d.ts +11 -0
- package/dev-ui/icons.js +25 -0
- package/dev-ui/index.d.ts +1 -0
- package/dev-ui/index.js +5 -0
- package/dev-ui/panels.d.ts +11 -0
- package/dev-ui/panels.js +31 -0
- package/dev-ui/theme.d.ts +135 -0
- package/dev-ui/theme.js +45 -0
- package/entry/Root.js +6 -5
- package/hooks/useAppData.js +0 -1
- package/package.json +8 -7
- package/serverless/create-rpc-client.d.ts +32 -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 +2 -0
- package/serverless/define-rpc-router.js +27 -0
- package/serverless/error-codes.d.ts +2 -0
- package/serverless/error-codes.js +14 -0
- package/serverless/index.d.ts +4 -0
- package/serverless/index.js +16 -0
- package/serverless/rpc-provider.d.ts +1 -0
- package/serverless/rpc-provider.js +5 -0
- package/serverless-template/_utils/ed-config.ts +5 -0
- package/serverless-template/_utils/fetch-wordpress-props.ts +39 -0
- package/serverless-template/next.config.js +63 -42
- package/serverless-template/pages/[...slug].tsx +6 -7
- package/serverless-template/pages/_app.tsx +9 -5
- package/serverless-template/pages/_document.tsx +19 -0
- package/serverless-template/pages/index.tsx +3 -2
- package/style/createStitches.d.ts +63 -1
- package/style/createStitches.js +182 -40
- package/utils/getRepoName.d.ts +2 -2
- package/utils/getRepoName.js +14 -52
- package/build/prepare-next.d.ts +0 -1
- package/build/prepare-next.js +0 -5
- package/serverless-template/package-lock.json +0 -641
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineAPI = void 0;
|
|
4
|
+
// import { ZodSchema, z, AnyZodObject, ZodError } from "zod"
|
|
5
|
+
// import { RESTErrorCodes } from "./error-codes"
|
|
6
|
+
function defineAPI(handler) {
|
|
7
|
+
return handler;
|
|
8
|
+
}
|
|
9
|
+
exports.defineAPI = defineAPI;
|
|
10
|
+
// type RESTAPIRequest<
|
|
11
|
+
// TQuery extends ZodSchema<any> | undefined,
|
|
12
|
+
// TBody extends ZodSchema<any> | undefined
|
|
13
|
+
// > = NextApiRequest & {
|
|
14
|
+
// query: TQuery extends AnyZodObject ? z.infer<TQuery> : NextApiRequest["query"]
|
|
15
|
+
// body: TBody extends AnyZodObject ? z.infer<TBody> : NextApiRequest["body"]
|
|
16
|
+
// }
|
|
17
|
+
// type RESTAPIResponse = NextApiResponse & {
|
|
18
|
+
// error(type: keyof typeof RESTErrorCodes, message: string, data: any): void
|
|
19
|
+
// }
|
|
20
|
+
// type AnyRESTAPIRequest = RESTAPIRequest<any, any>
|
|
21
|
+
// const CacheKeyGenerators = {
|
|
22
|
+
// url: (req: AnyRESTAPIRequest) => req.url,
|
|
23
|
+
// query: (req: AnyRESTAPIRequest) => req.url + "." + JSON.stringify(req.query),
|
|
24
|
+
// }
|
|
25
|
+
// type RESTOptions<TResult, TQuery extends ZodSchema<any> | undefined, TBody extends ZodSchema<any> | undefined> = {
|
|
26
|
+
// method: "get" | "post" | "put" | "delete" | "patch"
|
|
27
|
+
// cacheKey?: keyof typeof CacheKeyGenerators
|
|
28
|
+
// cacheTime?: number
|
|
29
|
+
// querystring?: TQuery
|
|
30
|
+
// handle(req: RESTAPIRequest<TQuery, TBody>, res: RESTAPIResponse): void
|
|
31
|
+
// }
|
|
32
|
+
// function stringifyZodError(err: ZodError) {
|
|
33
|
+
// return err.toString()
|
|
34
|
+
// }
|
|
35
|
+
// export function defineRESTAPI<
|
|
36
|
+
// TResult,
|
|
37
|
+
// TQuery extends ZodSchema<any> | undefined,
|
|
38
|
+
// TBody extends ZodSchema<any> | undefined
|
|
39
|
+
// >(opts: RESTOptions<TResult, TQuery, TBody>) {
|
|
40
|
+
// return (_req: NextApiRequest, _res: NextApiResponse) => {
|
|
41
|
+
// // Standard function for error codes/messages
|
|
42
|
+
// const sendError = (type: keyof typeof RESTErrorCodes, message: string, details?: any) => {
|
|
43
|
+
// _res.status(RESTErrorCodes[type] || 500)
|
|
44
|
+
// _res.json({
|
|
45
|
+
// error: true,
|
|
46
|
+
// message,
|
|
47
|
+
// details,
|
|
48
|
+
// })
|
|
49
|
+
// }
|
|
50
|
+
// // Ensure the correct method
|
|
51
|
+
// if (_req.method?.toLowerCase() !== opts.method) {
|
|
52
|
+
// return sendError("invalidverb", `Invalid verb: ${_req.method}`)
|
|
53
|
+
// }
|
|
54
|
+
// // Validate the querystring
|
|
55
|
+
// try {
|
|
56
|
+
// _req.query = opts.querystring ? (opts.querystring.safeParse(_req.query) as any) : _req.query
|
|
57
|
+
// } catch (err) {
|
|
58
|
+
// if (err instanceof ZodError) {
|
|
59
|
+
// return sendError("querystring", stringifyZodError(err), _req.query)
|
|
60
|
+
// } else {
|
|
61
|
+
// return sendError("querystring", err instanceof Error ? err.message : String(err))
|
|
62
|
+
// }
|
|
63
|
+
// }
|
|
64
|
+
// opts.handle(req, res)
|
|
65
|
+
// }
|
|
66
|
+
// }
|
|
@@ -0,0 +1,27 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.defineRPC = void 0;
|
|
23
|
+
var trpc = __importStar(require("@trpc/server"));
|
|
24
|
+
function defineRPC() {
|
|
25
|
+
return trpc.router();
|
|
26
|
+
}
|
|
27
|
+
exports.defineRPC = defineRPC;
|
|
@@ -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,16 @@
|
|
|
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
|
+
__exportStar(require("./define-api"), exports);
|
|
14
|
+
__exportStar(require("./define-rpc-router"), exports);
|
|
15
|
+
__exportStar(require("./create-rpc-client"), exports);
|
|
16
|
+
__exportStar(require("./error-codes"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function RPCProvider(): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import config from "./ed-config"
|
|
2
|
+
|
|
3
|
+
const settings = config.serverless
|
|
4
|
+
|
|
5
|
+
export async function fetchWordpressProps(pathname: string) {
|
|
6
|
+
const origin = (process.env.SITE_URL as string).replace(/\/$/, "")
|
|
7
|
+
pathname = pathname.replace(/(^\/|\/$)/g, "")
|
|
8
|
+
const propsURL = origin + ("/" + pathname + "/?_props=all").replace(/\/+/, "/")
|
|
9
|
+
console.log("Fetching", propsURL)
|
|
10
|
+
let response = await fetch(propsURL)
|
|
11
|
+
let text = await response.text()
|
|
12
|
+
|
|
13
|
+
// Convert absolute site URL details to relative paths
|
|
14
|
+
text = text.replace(new RegExp(origin.replace(/(http|https)/, `https?`) + "([a-z0-9-_./]+)", "g"), (url) => {
|
|
15
|
+
const path = url.replace(/https?:\/\/[a-z0-9\-\_\.]+/, "")
|
|
16
|
+
if (path.startsWith("/wp-content/uploads/")) {
|
|
17
|
+
if (settings?.uploads === "proxy") {
|
|
18
|
+
return path
|
|
19
|
+
} else if (settings?.uploads === "remote") {
|
|
20
|
+
return url
|
|
21
|
+
}
|
|
22
|
+
} else if (path.startsWith("/wp-content/themes/")) {
|
|
23
|
+
if (settings?.uploads === "proxy") {
|
|
24
|
+
return path
|
|
25
|
+
} else if (settings?.uploads === "remote") {
|
|
26
|
+
return url
|
|
27
|
+
}
|
|
28
|
+
} else if (path.startsWith("/wp-content/plugins/")) {
|
|
29
|
+
if (settings?.uploads === "proxy") {
|
|
30
|
+
return path
|
|
31
|
+
} else if (settings?.uploads === "remote") {
|
|
32
|
+
return url
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return url
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return JSON.parse(text)
|
|
39
|
+
}
|
|
@@ -1,48 +1,69 @@
|
|
|
1
1
|
const withTM = require("next-transpile-modules")
|
|
2
2
|
const { resolve } = require("path")
|
|
3
3
|
const { DefinePlugin } = require("webpack")
|
|
4
|
+
const settings = require("./ed.config.json")
|
|
5
|
+
const { getRepoName } = require("eddev/utils/getRepoName")
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
module.exports = (() => {
|
|
8
|
+
const cwd = process.cwd()
|
|
9
|
+
const REPO_NAME = getRepoName(cwd.replace(/\/\.serverless/, "")).repoName
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
return withTM(["eddev"])({
|
|
12
|
+
rewrites() {
|
|
13
|
+
return {
|
|
14
|
+
afterFiles: [
|
|
15
|
+
settings.serverless.uploads === "proxy" && {
|
|
16
|
+
source: "/wp-content/uploads/:path*",
|
|
17
|
+
destination: process.env.SITE_URL + "/wp-content/uploads/:path*",
|
|
18
|
+
},
|
|
19
|
+
settings.serverless.plugin === "proxy" && {
|
|
20
|
+
source: "/wp-content/plugins/:path*",
|
|
21
|
+
destination: process.env.SITE_URL + "/wp-content/plugins/:path*",
|
|
22
|
+
},
|
|
23
|
+
settings.serverless.theme === "proxy" && {
|
|
24
|
+
source: "/wp-content/themes/:path*",
|
|
25
|
+
destination: process.env.SITE_URL + "/wp-content/themes/:path*",
|
|
26
|
+
},
|
|
27
|
+
].filter(Boolean),
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
typescript: {
|
|
31
|
+
ignoreBuildErrors: true,
|
|
32
|
+
},
|
|
33
|
+
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
|
|
34
|
+
config.resolve.alias = {
|
|
35
|
+
...config.resolve.alias,
|
|
36
|
+
"@manifest/views": resolve(cwd, "manifest_views.ts"),
|
|
37
|
+
"@manifest/blocks": resolve(cwd, "manifest_blocks.ts"),
|
|
38
|
+
"@theme": resolve(cwd, "theme.css.tsx"),
|
|
39
|
+
"@wordpress/components": resolve(cwd, "null.ts"),
|
|
40
|
+
"@wordpress/element": resolve(cwd, "null.ts"),
|
|
41
|
+
"@wordpress/blocks": resolve(cwd, "null.ts"),
|
|
42
|
+
"@wordpress/utils": resolve(cwd, "null.ts"),
|
|
43
|
+
"@wordpress/data": resolve(cwd, "null.ts"),
|
|
44
|
+
"@wordpress/hooks": resolve(cwd, "null.ts"),
|
|
45
|
+
"@wordpress/block-editor": resolve(cwd, "null.ts"),
|
|
46
|
+
}
|
|
47
|
+
// config.defines["process.dev"] = isDev ? "true" : "false"
|
|
48
|
+
const define = config.plugins.find((plugin) => plugin instanceof DefinePlugin)
|
|
49
|
+
define.definitions["process.serverless"] = "true"
|
|
50
|
+
define.definitions["process.admin"] = "false"
|
|
51
|
+
define.definitions["process.dev"] = process.env.NODE_ENV === "development"
|
|
8
52
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"@wordpress/element": resolve(cwd, "null.ts"),
|
|
27
|
-
"@wordpress/blocks": resolve(cwd, "null.ts"),
|
|
28
|
-
"@wordpress/utils": resolve(cwd, "null.ts"),
|
|
29
|
-
"@wordpress/data": resolve(cwd, "null.ts"),
|
|
30
|
-
"@wordpress/hooks": resolve(cwd, "null.ts"),
|
|
31
|
-
"@wordpress/block-editor": resolve(cwd, "null.ts"),
|
|
32
|
-
}
|
|
33
|
-
// config.defines["process.dev"] = isDev ? "true" : "false"
|
|
34
|
-
const define = config.plugins.find((plugin) => plugin instanceof DefinePlugin)
|
|
35
|
-
define.definitions["process.serverless"] = "true"
|
|
36
|
-
define.definitions["process.admin"] = "false"
|
|
37
|
-
define.definitions["process.dev"] = process.env.NODE_ENV === "development"
|
|
38
|
-
// config.plugins.push(
|
|
39
|
-
// new DefinePlugin({
|
|
40
|
-
// "process.serverless": "true",
|
|
41
|
-
// "process.admin": "false",
|
|
42
|
-
// // "process.env.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
43
|
-
// // "process.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
44
|
-
// })
|
|
45
|
-
// )
|
|
46
|
-
return config
|
|
47
|
-
},
|
|
48
|
-
})
|
|
53
|
+
const themePath =
|
|
54
|
+
(settings.serverless.theme === "remote" ? process.env.SITE_URL : "") + "/wp-content/themes/" + REPO_NAME
|
|
55
|
+
|
|
56
|
+
define.definitions["process.env.themePath"] = JSON.stringify(themePath)
|
|
57
|
+
define.definitions["process.themePath"] = JSON.stringify(themePath)
|
|
58
|
+
// config.plugins.push(
|
|
59
|
+
// new DefinePlugin({
|
|
60
|
+
// "process.serverless": "true",
|
|
61
|
+
// "process.admin": "false",
|
|
62
|
+
// // "process.env.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
63
|
+
// // "process.themePath": JSON.stringify(`/wp-content/themes/${opts.themeName}`),
|
|
64
|
+
// })
|
|
65
|
+
// )
|
|
66
|
+
return config
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
})()
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
+
import { GetStaticPathsResult, GetStaticPropsContext, GetStaticPropsResult } from "next"
|
|
2
|
+
import { fetchWordpressProps } from "../_utils/fetch-wordpress-props"
|
|
3
|
+
|
|
1
4
|
export default function Home(props: any) {
|
|
2
5
|
return <div>{JSON.stringify(props)}</div>
|
|
3
6
|
}
|
|
4
7
|
|
|
5
|
-
export async function getStaticPaths() {
|
|
8
|
+
export async function getStaticPaths(): Promise<GetStaticPathsResult> {
|
|
6
9
|
return {
|
|
7
|
-
// paths: [{ params: { slug: ["tees"] } }],
|
|
8
10
|
paths: [],
|
|
9
11
|
fallback: true,
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export async function getStaticProps({ params }:
|
|
14
|
-
|
|
15
|
-
const response = await fetch(process.env.SITE_URL + "/" + params.slug.join("/") + "/?_props=all")
|
|
16
|
-
const result = await response.json()
|
|
17
|
-
console.log("Result is", result)
|
|
15
|
+
export async function getStaticProps({ params }: GetStaticPropsContext): Promise<GetStaticPropsResult<any>> {
|
|
16
|
+
const result = await fetchWordpressProps((params?.slug as string[]).join("/"))
|
|
18
17
|
return {
|
|
19
18
|
props: result,
|
|
20
19
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { AppProps } from "next/app"
|
|
2
2
|
import { App } from "@manifest/views"
|
|
3
3
|
import manifest from "@manifest/views"
|
|
4
|
+
import { NextRouter } from "eddev/components/NextRouter"
|
|
4
5
|
import { ServerlessAppDataProvider } from "eddev/utils/serverlessAppContext"
|
|
5
6
|
import { useMemo } from "react"
|
|
6
|
-
|
|
7
|
-
console.log("FF", ServerlessAppDataProvider)
|
|
7
|
+
import { useRouter } from "next/router"
|
|
8
8
|
|
|
9
9
|
function MyApp({ Component, pageProps }: AppProps) {
|
|
10
10
|
if (!pageProps.appData) return <div />
|
|
@@ -13,15 +13,19 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|
|
13
13
|
return pageProps.appData.data
|
|
14
14
|
}, [])
|
|
15
15
|
|
|
16
|
+
const route = useRouter()
|
|
17
|
+
|
|
16
18
|
const viewProps = pageProps?.viewData?.data
|
|
17
19
|
|
|
18
20
|
const View = manifest[pageProps.view]
|
|
19
21
|
|
|
20
22
|
return (
|
|
21
23
|
<ServerlessAppDataProvider value={appData}>
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
|
|
24
|
+
<NextRouter data={pageProps} path={route.pathname}>
|
|
25
|
+
<App>
|
|
26
|
+
<View {...viewProps} />
|
|
27
|
+
</App>
|
|
28
|
+
</NextRouter>
|
|
25
29
|
</ServerlessAppDataProvider>
|
|
26
30
|
)
|
|
27
31
|
}
|
|
@@ -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,10 +1,11 @@
|
|
|
1
|
+
import { fetchWordpressProps } from "../_utils/fetch-wordpress-props"
|
|
2
|
+
|
|
1
3
|
export default function Home() {
|
|
2
4
|
return <div>Test</div>
|
|
3
5
|
}
|
|
4
6
|
|
|
5
7
|
export async function getStaticProps({ params }: any) {
|
|
6
|
-
const
|
|
7
|
-
const result = await response.json()
|
|
8
|
+
const result = await fetchWordpressProps("/")
|
|
8
9
|
return {
|
|
9
10
|
props: result,
|
|
10
11
|
}
|
|
@@ -17,6 +17,12 @@ declare type TypographyConfig<Theme extends ConfigType.Theme<{}>, Media extends
|
|
|
17
17
|
lineHeight?: ResponsiveValue<Media, Theme["lineHeights"] extends {} ? `$${Extract<keyof Theme["lineHeights"], string>}` | CSS["lineHeight"] : CSS["lineHeight"]>;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
+
declare type BreakpointArray = {
|
|
21
|
+
key: string;
|
|
22
|
+
min: string | null;
|
|
23
|
+
max: string | null;
|
|
24
|
+
}[];
|
|
25
|
+
export declare function parseBreakpoints(names: string[], medias: any): BreakpointArray;
|
|
20
26
|
interface GridConfig<Theme extends ConfigType.Theme<{}>, Media extends ConfigType.Media<{}>> {
|
|
21
27
|
columns: number;
|
|
22
28
|
breakpoints: {
|
|
@@ -35,7 +41,41 @@ declare type ResponsiveScale<Media extends ConfigType.Media<{}>, T extends {}> =
|
|
|
35
41
|
declare type ResponsiveConfig<Media extends ConfigType.Media<{}>, T extends {}> = {
|
|
36
42
|
[Scale in keyof T]: ResponsiveScale<Media, T[Scale]>;
|
|
37
43
|
};
|
|
38
|
-
|
|
44
|
+
declare type ResponsiveAtom = {
|
|
45
|
+
lerpStart: boolean;
|
|
46
|
+
} & ({
|
|
47
|
+
type: "multiplier";
|
|
48
|
+
value: number;
|
|
49
|
+
} | {
|
|
50
|
+
type: "px";
|
|
51
|
+
value: number;
|
|
52
|
+
} | {
|
|
53
|
+
type: "number";
|
|
54
|
+
value: number;
|
|
55
|
+
} | {
|
|
56
|
+
type: "unknown";
|
|
57
|
+
value: string | number;
|
|
58
|
+
} | {
|
|
59
|
+
type: "undefined";
|
|
60
|
+
});
|
|
61
|
+
declare type ResponsiveAtomCalc = (ResponsiveAtom & {
|
|
62
|
+
defined: boolean;
|
|
63
|
+
breakpoint: string;
|
|
64
|
+
baseBreakpoint: string;
|
|
65
|
+
lerping?: {
|
|
66
|
+
fromBP: string | null;
|
|
67
|
+
toBP: string | null;
|
|
68
|
+
minMedia: number;
|
|
69
|
+
maxMedia: number;
|
|
70
|
+
minValue: number;
|
|
71
|
+
maxValue: number;
|
|
72
|
+
};
|
|
73
|
+
concreteValue: number | null;
|
|
74
|
+
})[];
|
|
75
|
+
export declare function parseResponsiveObject(breakpoints: ReturnType<typeof parseBreakpoints>, object: any): ResponsiveAtomCalc;
|
|
76
|
+
export declare function getResponsiveObjectStyles(theme: any, breakpoints: ReturnType<typeof parseBreakpoints>, object: any, varName: string, scale?: string, unit?: string): any[];
|
|
77
|
+
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: {
|
|
78
|
+
breakpoints: Breakpoints;
|
|
39
79
|
prefix?: ConfigType.Prefix<Prefix>;
|
|
40
80
|
media: ConfigType.Media<Media>;
|
|
41
81
|
theme: ConfigType.Theme<Theme>;
|
|
@@ -54,12 +94,34 @@ export declare function createStitches<Prefix extends string = "", Media extends
|
|
|
54
94
|
themeMap?: ConfigType.ThemeMap<ThemeMap>;
|
|
55
95
|
utils: ConfigType.Utils<Utils>;
|
|
56
96
|
}): {
|
|
97
|
+
originalConfig: {
|
|
98
|
+
breakpoints: Breakpoints;
|
|
99
|
+
prefix?: ConfigType.Prefix<Prefix> | undefined;
|
|
100
|
+
media: ConfigType.Media<Media>;
|
|
101
|
+
theme: ConfigType.Theme<Theme>;
|
|
102
|
+
responsive: ResponsiveConfig<Media & {
|
|
103
|
+
initial: string;
|
|
104
|
+
editor: string;
|
|
105
|
+
}, Responsive>;
|
|
106
|
+
typography: TypographyConfig<Theme, Media & {
|
|
107
|
+
initial: string;
|
|
108
|
+
editor: string;
|
|
109
|
+
}, Typography>;
|
|
110
|
+
grid: GridConfig<Theme, Media & {
|
|
111
|
+
initial: string;
|
|
112
|
+
editor: string;
|
|
113
|
+
}>;
|
|
114
|
+
themeMap?: ConfigType.ThemeMap<ThemeMap> | undefined;
|
|
115
|
+
utils: ConfigType.Utils<Utils>;
|
|
116
|
+
};
|
|
117
|
+
breakpoints: BreakpointArray;
|
|
57
118
|
typeVariants: { [key in keyof TypographyConfig<Theme, Media & {
|
|
58
119
|
initial: string;
|
|
59
120
|
editor: string;
|
|
60
121
|
}, Typography>]: any; };
|
|
61
122
|
gridVariants: {};
|
|
62
123
|
responsiveTokens: { [Scale in keyof Responsive]: { [T in keyof Responsive[Scale]]: number; }; };
|
|
124
|
+
responsiveGlobals: any;
|
|
63
125
|
config: {
|
|
64
126
|
prefix: "";
|
|
65
127
|
media: {
|