eddev 0.2.0-beta.0 → 0.2.0-beta.1
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/serverless/create-next-app.d.ts +1 -0
- package/build/serverless/create-next-app.js +10 -3
- package/cli/cli.js +11 -0
- package/components/NextRouter.d.ts +9 -0
- package/components/NextRouter.js +36 -0
- package/dynamic/dynamic-component.d.ts +1 -0
- package/fields/ImageWell.d.ts +8 -0
- package/fields/ImageWell.js +64 -0
- package/package.json +2 -1
- package/serverless-template/_utils/fetch-wordpress-props.ts +15 -0
- package/serverless-template/next.config.js +10 -0
- package/serverless-template/pages/[...slug].tsx +6 -7
- package/serverless-template/pages/_app.tsx +11 -5
- package/serverless-template/pages/index.tsx +3 -2
- package/style/createStitches.d.ts +1 -0
- package/build/prepare-next.d.ts +0 -1
- package/build/prepare-next.js +0 -5
|
@@ -106,12 +106,18 @@ function createNextApp(opts) {
|
|
|
106
106
|
_a.sent();
|
|
107
107
|
// Create manifests
|
|
108
108
|
initManifests(serverlessDirectory, opts.dev);
|
|
109
|
-
|
|
109
|
+
if (!opts.dev) return [3 /*break*/, 7];
|
|
110
110
|
return [4 /*yield*/, runScript(serverlessDirectory, "dev")];
|
|
111
111
|
case 6:
|
|
112
|
-
// Start
|
|
113
112
|
_a.sent();
|
|
114
|
-
return [
|
|
113
|
+
return [3 /*break*/, 9];
|
|
114
|
+
case 7:
|
|
115
|
+
if (!opts.build) return [3 /*break*/, 9];
|
|
116
|
+
return [4 /*yield*/, runScript(serverlessDirectory, "build")];
|
|
117
|
+
case 8:
|
|
118
|
+
_a.sent();
|
|
119
|
+
_a.label = 9;
|
|
120
|
+
case 9: return [2 /*return*/];
|
|
115
121
|
}
|
|
116
122
|
});
|
|
117
123
|
});
|
|
@@ -216,6 +222,7 @@ function syncFiles(sourceFolder, targetFolder) {
|
|
|
216
222
|
"types.graphql.ts",
|
|
217
223
|
"types.views.ts",
|
|
218
224
|
"types.blocks.ts",
|
|
225
|
+
"utils",
|
|
219
226
|
];
|
|
220
227
|
return [4 /*yield*/, Promise.all(links.map(function (file) {
|
|
221
228
|
var src = (0, path_1.resolve)(sourceFolder, file);
|
package/cli/cli.js
CHANGED
|
@@ -66,6 +66,16 @@ program
|
|
|
66
66
|
serverless: options.serverless,
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
|
+
program
|
|
70
|
+
.command("vercel-build")
|
|
71
|
+
.description("Create and build a Next.js project in .serverless")
|
|
72
|
+
.action(function (options) {
|
|
73
|
+
(0, create_next_app_1.createNextApp)({
|
|
74
|
+
baseDirectory: process.cwd(),
|
|
75
|
+
dev: false,
|
|
76
|
+
build: true,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
69
79
|
program
|
|
70
80
|
.command("next")
|
|
71
81
|
.description("Create a Next.js project in .serverless")
|
|
@@ -73,6 +83,7 @@ program
|
|
|
73
83
|
(0, create_next_app_1.createNextApp)({
|
|
74
84
|
baseDirectory: process.cwd(),
|
|
75
85
|
dev: true,
|
|
86
|
+
build: false,
|
|
76
87
|
});
|
|
77
88
|
});
|
|
78
89
|
program
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { RouteData } from "../routing/remoteProps";
|
|
3
|
+
declare type Props = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
path: string;
|
|
6
|
+
data: RouteData;
|
|
7
|
+
};
|
|
8
|
+
export declare function NextRouter({ children, path, data }: Props): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.NextRouter = void 0;
|
|
15
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
var routing_1 = require("../routing");
|
|
17
|
+
var router_1 = require("next/router");
|
|
18
|
+
function NextRouter(_a) {
|
|
19
|
+
var children = _a.children, path = _a.path, data = _a.data;
|
|
20
|
+
var route = (0, router_1.useRouter)();
|
|
21
|
+
return ((0, jsx_runtime_1.jsx)(routing_1.RouterRoot, __assign({ url: path, data: data, onNavigateRequest: function (url) {
|
|
22
|
+
route.push(url);
|
|
23
|
+
// setPendingUrl({ popped: false, url })
|
|
24
|
+
}, onPreload: function (url) {
|
|
25
|
+
// if (isSameOrigin(url)) {
|
|
26
|
+
// fetchProps(url)
|
|
27
|
+
// }
|
|
28
|
+
}, onNavigated: function () {
|
|
29
|
+
// if (pending && typeof pending.scrollPosition === "number") {
|
|
30
|
+
// setScrollPosition({ value: pending.scrollPosition })
|
|
31
|
+
// } else {
|
|
32
|
+
// setScrollPosition({ value: 0 })
|
|
33
|
+
// }
|
|
34
|
+
} }, { children: children }), void 0));
|
|
35
|
+
}
|
|
36
|
+
exports.NextRouter = NextRouter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const dynamic: {
|
|
2
3
|
<Props, Module = import("@loadable/component").DefaultComponent<Props>>(loadFn: (props: Props) => Promise<Module>, options: import("@loadable/component").OptionsWithResolver<Props, Module>): import("@loadable/component").LoadableComponent<Props>;
|
|
3
4
|
<Props_1>(loadFn: (props: Props_1) => Promise<import("@loadable/component").DefaultComponent<Props_1>>, options?: import("@loadable/component").OptionsWithoutResolver<Props_1> | undefined): import("@loadable/component").LoadableComponent<Props_1>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageWell = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var react_1 = require("@stitches/react");
|
|
6
|
+
var react_2 = require("react");
|
|
7
|
+
function ImageWell(props) {
|
|
8
|
+
var _a = (0, react_2.useState)(null), selectedImage = _a[0], setSelectedImage = _a[1];
|
|
9
|
+
var _b = (0, react_2.useState)(false), imageIsLoading = _b[0], setImageIsLoading = _b[1];
|
|
10
|
+
(0, react_2.useEffect)(function () {
|
|
11
|
+
if (props.value) {
|
|
12
|
+
var cancelled = false;
|
|
13
|
+
setImageIsLoading(true);
|
|
14
|
+
fetch("/wp-json/ed/v1/media/" + Number(props.value))
|
|
15
|
+
.then(function (response) { return response.json(); })
|
|
16
|
+
.then(function (image) {
|
|
17
|
+
setImageIsLoading(false);
|
|
18
|
+
setSelectedImage(image);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}, [props.value]);
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(Wrapper, { children: [imageIsLoading ? ((0, jsx_runtime_1.jsx)(Loading, { children: (0, jsx_runtime_1.jsx)(Spinner, {}, void 0) }, void 0)) : selectedImage ? ((0, jsx_runtime_1.jsx)(ImageContainer, { children: (0, jsx_runtime_1.jsx)("img", { src: selectedImage.sizes[props.previewSize] || selectedImage.sizes["thumbnail"] }, void 0) }, void 0)) : null, (0, jsx_runtime_1.jsx)(Toolbar, { children: selectedImage || imageIsLoading ? ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button, { children: "Remove" }, void 0), (0, jsx_runtime_1.jsx)(Button, { children: "Edit" }, void 0), (0, jsx_runtime_1.jsx)(Button, { children: "View" }, void 0)] }, void 0)) : null }, void 0)] }, void 0));
|
|
23
|
+
}
|
|
24
|
+
exports.ImageWell = ImageWell;
|
|
25
|
+
var Wrapper = (0, react_1.styled)("div", {
|
|
26
|
+
position: "relative",
|
|
27
|
+
display: "block",
|
|
28
|
+
width: "100%",
|
|
29
|
+
border: "1px solid #aaaaaa",
|
|
30
|
+
});
|
|
31
|
+
var ImageContainer = (0, react_1.styled)("div", {
|
|
32
|
+
padding: "4px",
|
|
33
|
+
img: {
|
|
34
|
+
maxWidth: "100%",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
var spin = (0, react_1.keyframes)({
|
|
38
|
+
from: {
|
|
39
|
+
transform: "rotate(0deg)",
|
|
40
|
+
},
|
|
41
|
+
to: {
|
|
42
|
+
transform: "rotate(360deg)",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
var Spinner = (0, react_1.styled)("div", {
|
|
46
|
+
display: "block",
|
|
47
|
+
width: "32px",
|
|
48
|
+
height: "32px",
|
|
49
|
+
border: "4px solid transparent",
|
|
50
|
+
borderTop: "currentColor",
|
|
51
|
+
animation: "".concat(spin, " 1s linear infinite"),
|
|
52
|
+
});
|
|
53
|
+
var Loading = (0, react_1.styled)("div", {
|
|
54
|
+
display: "flex",
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
padding: "8px",
|
|
58
|
+
});
|
|
59
|
+
var Toolbar = (0, react_1.styled)("div", {
|
|
60
|
+
position: "absolute",
|
|
61
|
+
top: 0,
|
|
62
|
+
right: 0,
|
|
63
|
+
padding: "4px",
|
|
64
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eddev",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.1",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@types/url-parse": "^1.4.4",
|
|
27
27
|
"@types/webpack-dev-server": "^3.11.2",
|
|
28
28
|
"csstype": "^3.0.9",
|
|
29
|
+
"next": "^12.0.10",
|
|
29
30
|
"react-html-props": "^1.0.32"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export async function fetchWordpressProps(pathname: string) {
|
|
2
|
+
const origin = (process.env.SITE_URL as string).replace(/\/$/, "")
|
|
3
|
+
pathname = pathname.replace(/(^\/|\/$)/g, "")
|
|
4
|
+
|
|
5
|
+
let response = await fetch(origin + "/" + pathname + "/?_props=all")
|
|
6
|
+
let text = await response.text()
|
|
7
|
+
|
|
8
|
+
// Convert absolute site URL details to relative paths
|
|
9
|
+
// console.log("WAS", text)
|
|
10
|
+
console.log("REPLACING", origin)
|
|
11
|
+
text = text.replaceAll(origin, "")
|
|
12
|
+
console.log("NOW", text)
|
|
13
|
+
|
|
14
|
+
return JSON.parse(text)
|
|
15
|
+
}
|
|
@@ -7,6 +7,16 @@ const { DefinePlugin } = require("webpack")
|
|
|
7
7
|
module.exports = {}
|
|
8
8
|
|
|
9
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
|
+
},
|
|
10
20
|
typescript: {
|
|
11
21
|
ignoreBuildErrors: true,
|
|
12
22
|
},
|
|
@@ -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,21 @@ 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
|
|
|
22
|
+
console.log("ROUTE", pageProps, route.pathname)
|
|
23
|
+
|
|
20
24
|
return (
|
|
21
25
|
<ServerlessAppDataProvider value={appData}>
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
|
|
26
|
+
<NextRouter data={pageProps} path={route.pathname}>
|
|
27
|
+
<App>
|
|
28
|
+
<View {...viewProps} />
|
|
29
|
+
</App>
|
|
30
|
+
</NextRouter>
|
|
25
31
|
</ServerlessAppDataProvider>
|
|
26
32
|
)
|
|
27
33
|
}
|
|
@@ -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
|
}
|
package/build/prepare-next.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function prepareNextDirectory(): void;
|