eddev 0.2.0-beta.40 → 0.2.0-beta.43
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.js +39 -38
- package/hooks/rpc-client.d.ts +3 -0
- package/hooks/rpc-client.js +15 -0
- package/package.json +1 -1
- package/serverless/create-rpc-client.d.ts +5 -18
- package/serverless/rpc-client.d.ts +3 -0
- package/serverless/rpc-client.js +15 -0
- package/serverless-template/_utils/fetch-wordpress-props.ts +3 -0
- package/entry/entry.serverless.dev.d.ts +0 -0
- package/entry/entry.serverless.dev.js +0 -2
|
@@ -108,14 +108,13 @@ function createNextApp(opts) {
|
|
|
108
108
|
case 3:
|
|
109
109
|
// Copy the template folder
|
|
110
110
|
_b.sent();
|
|
111
|
-
|
|
112
|
-
return [4 /*yield*/, updatePackagesFile(
|
|
111
|
+
// Update package.json
|
|
112
|
+
return [4 /*yield*/, updatePackagesFile((0, path_1.resolve)(__dirname, "../../serverless-template"), serverlessDirectory)];
|
|
113
113
|
case 4:
|
|
114
|
+
// Update package.json
|
|
114
115
|
_b.sent();
|
|
115
|
-
_b.label = 5;
|
|
116
|
-
case 5:
|
|
117
116
|
assetPaths = ((_a = requireConfig(opts.baseDirectory).serverless) === null || _a === void 0 ? void 0 : _a.themeAssets) || [];
|
|
118
|
-
if (!!isVercel) return [3 /*break*/,
|
|
117
|
+
if (!!isVercel) return [3 /*break*/, 11];
|
|
119
118
|
// Sync important files during development, as they change
|
|
120
119
|
return [4 /*yield*/, syncFiles(opts.baseDirectory, serverlessDirectory, [
|
|
121
120
|
"blocks/**/*",
|
|
@@ -134,50 +133,50 @@ function createNextApp(opts) {
|
|
|
134
133
|
])
|
|
135
134
|
// Also sync APIs into the APIs folder
|
|
136
135
|
];
|
|
137
|
-
case
|
|
136
|
+
case 5:
|
|
138
137
|
// Sync important files during development, as they change
|
|
139
138
|
_b.sent();
|
|
140
139
|
// Also sync APIs into the APIs folder
|
|
141
140
|
return [4 /*yield*/, syncFiles((0, path_1.join)(opts.baseDirectory, "apis"), (0, path_1.join)(serverlessDirectory, "apis"), ["**/*.{tsx,ts,js,jsx}"])];
|
|
142
|
-
case
|
|
141
|
+
case 6:
|
|
143
142
|
// Also sync APIs into the APIs folder
|
|
144
143
|
_b.sent();
|
|
145
144
|
return [4 /*yield*/, syncAPIProxies((0, path_1.join)(opts.baseDirectory, "apis"), (0, path_1.join)(serverlessDirectory, "pages/api"))
|
|
146
145
|
// Sync the public folder
|
|
147
146
|
];
|
|
148
|
-
case
|
|
147
|
+
case 7:
|
|
149
148
|
_b.sent();
|
|
150
|
-
if (!assetPaths.length) return [3 /*break*/,
|
|
149
|
+
if (!assetPaths.length) return [3 /*break*/, 9];
|
|
151
150
|
return [4 /*yield*/, syncFiles(opts.baseDirectory, (0, path_1.join)(serverlessDirectory, "public/wp-content/themes/".concat(repoName.repoName)), assetPaths)];
|
|
152
|
-
case
|
|
151
|
+
case 8:
|
|
153
152
|
_b.sent();
|
|
154
|
-
_b.label =
|
|
155
|
-
case
|
|
153
|
+
_b.label = 9;
|
|
154
|
+
case 9:
|
|
156
155
|
// Sync favicon
|
|
157
156
|
return [4 /*yield*/, syncFiles((0, path_1.join)(opts.baseDirectory), (0, path_1.join)(serverlessDirectory, "public/"), ["favicon.ico"])];
|
|
158
|
-
case
|
|
157
|
+
case 10:
|
|
159
158
|
// Sync favicon
|
|
160
159
|
_b.sent();
|
|
161
|
-
return [3 /*break*/,
|
|
162
|
-
case
|
|
163
|
-
if (!assetPaths.length) return [3 /*break*/,
|
|
160
|
+
return [3 /*break*/, 16];
|
|
161
|
+
case 11:
|
|
162
|
+
if (!assetPaths.length) return [3 /*break*/, 13];
|
|
164
163
|
return [4 /*yield*/, copyFiles(opts.baseDirectory, (0, path_1.join)(serverlessDirectory, "public/wp-content/themes/".concat(repoName.repoName)), assetPaths)];
|
|
165
|
-
case
|
|
164
|
+
case 12:
|
|
166
165
|
_b.sent();
|
|
167
|
-
_b.label =
|
|
168
|
-
case
|
|
166
|
+
_b.label = 13;
|
|
167
|
+
case 13:
|
|
169
168
|
// Sync favicon
|
|
170
169
|
return [4 /*yield*/, copyFiles((0, path_1.join)(opts.baseDirectory), (0, path_1.join)(serverlessDirectory, "public/"), ["favicon.ico"])
|
|
171
170
|
// Write APIs proxy code
|
|
172
171
|
];
|
|
173
|
-
case
|
|
172
|
+
case 14:
|
|
174
173
|
// Sync favicon
|
|
175
174
|
_b.sent();
|
|
176
175
|
// Write APIs proxy code
|
|
177
176
|
return [4 /*yield*/, writeAPIProxies((0, path_1.join)(opts.baseDirectory, "apis"), (0, path_1.join)(serverlessDirectory, "pages/api"))
|
|
178
177
|
// Remove pages/api/trpc directory if no _rpc is found
|
|
179
178
|
];
|
|
180
|
-
case
|
|
179
|
+
case 15:
|
|
181
180
|
// Write APIs proxy code
|
|
182
181
|
_b.sent();
|
|
183
182
|
// Remove pages/api/trpc directory if no _rpc is found
|
|
@@ -189,28 +188,28 @@ function createNextApp(opts) {
|
|
|
189
188
|
!(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc.ts"))) {
|
|
190
189
|
// removeSync(join(serverlessDirectory, "pages/api/trpc"))
|
|
191
190
|
}
|
|
192
|
-
_b.label =
|
|
193
|
-
case
|
|
191
|
+
_b.label = 16;
|
|
192
|
+
case 16:
|
|
194
193
|
// Create manifests
|
|
195
194
|
return [4 /*yield*/, initManifests(serverlessDirectory, opts.dev)
|
|
196
195
|
// Update packages
|
|
197
196
|
];
|
|
198
|
-
case
|
|
197
|
+
case 17:
|
|
199
198
|
// Create manifests
|
|
200
199
|
_b.sent();
|
|
201
|
-
if (!!isVercel) return [3 /*break*/,
|
|
200
|
+
if (!!isVercel) return [3 /*break*/, 19];
|
|
202
201
|
sendSignal({ code: "packaging" });
|
|
203
202
|
return [4 /*yield*/, updatePackages(serverlessDirectory)];
|
|
204
|
-
case
|
|
203
|
+
case 18:
|
|
205
204
|
_b.sent();
|
|
206
|
-
_b.label =
|
|
207
|
-
case
|
|
205
|
+
_b.label = 19;
|
|
206
|
+
case 19:
|
|
208
207
|
sendSignal({ code: "compiling" });
|
|
209
|
-
if (!opts.dev) return [3 /*break*/,
|
|
208
|
+
if (!opts.dev) return [3 /*break*/, 22];
|
|
210
209
|
return [4 /*yield*/, getPort(3000)
|
|
211
210
|
// Write the endpoint URL to .env
|
|
212
211
|
];
|
|
213
|
-
case
|
|
212
|
+
case 20:
|
|
214
213
|
port = _b.sent();
|
|
215
214
|
// Write the endpoint URL to .env
|
|
216
215
|
(0, updateEnvFile_1.updateEnvFile)({
|
|
@@ -219,17 +218,17 @@ function createNextApp(opts) {
|
|
|
219
218
|
sendSignal({ code: "url", url: "http://127.0.0.1:".concat(port) });
|
|
220
219
|
// await devNext(serverlessDirectory, port)
|
|
221
220
|
return [4 /*yield*/, runScript(serverlessDirectory, ["dev", "--port", String(port)])];
|
|
222
|
-
case
|
|
221
|
+
case 21:
|
|
223
222
|
// await devNext(serverlessDirectory, port)
|
|
224
223
|
_b.sent();
|
|
225
|
-
return [3 /*break*/,
|
|
226
|
-
case
|
|
227
|
-
if (!opts.build) return [3 /*break*/,
|
|
224
|
+
return [3 /*break*/, 24];
|
|
225
|
+
case 22:
|
|
226
|
+
if (!opts.build) return [3 /*break*/, 24];
|
|
228
227
|
return [4 /*yield*/, runScript(serverlessDirectory, ["build"])];
|
|
229
|
-
case
|
|
228
|
+
case 23:
|
|
230
229
|
_b.sent();
|
|
231
|
-
_b.label =
|
|
232
|
-
case
|
|
230
|
+
_b.label = 24;
|
|
231
|
+
case 24: return [2 /*return*/];
|
|
233
232
|
}
|
|
234
233
|
});
|
|
235
234
|
});
|
|
@@ -269,6 +268,8 @@ function copyTemplate(targetFolder) {
|
|
|
269
268
|
case 1:
|
|
270
269
|
files = _a.sent();
|
|
271
270
|
return [4 /*yield*/, Promise.all(files.map(function (src) {
|
|
271
|
+
if (src.includes("package.json"))
|
|
272
|
+
return null;
|
|
272
273
|
var dest = src.replace(sourceFolder, targetFolder);
|
|
273
274
|
return (0, fs_extra_1.copy)(src, dest);
|
|
274
275
|
}))];
|
|
@@ -305,7 +306,7 @@ function updatePackagesFile(sourceFolder, targetFolder) {
|
|
|
305
306
|
targetPackageFile = (0, path_1.resolve)(targetFolder, "package.json");
|
|
306
307
|
sourcePackage = require(sourcePackageFile);
|
|
307
308
|
targetPackage = require(targetPackageFile);
|
|
308
|
-
mergedPackage = __assign(__assign({},
|
|
309
|
+
mergedPackage = __assign(__assign({}, sourcePackage), { dependencies: __assign(__assign({}, (sourcePackage.dependencies || {})), (targetPackage.dependencies || {})), devDependencies: __assign(__assign({}, (sourcePackage.devDependencies || {})), (targetPackage.devDependencies || {})) });
|
|
309
310
|
(0, fs_extra_1.writeJSON)(targetPackageFile, mergedPackage, {
|
|
310
311
|
spaces: 2,
|
|
311
312
|
});
|
|
@@ -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
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export declare function createRPCClient(): {
|
|
3
2
|
Provider: ({ client, queryClient, children, isPrepass, ssrContext, }: {
|
|
4
|
-
queryClient: QueryClient;
|
|
3
|
+
queryClient: import("react-query").QueryClient;
|
|
5
4
|
client: import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>;
|
|
6
5
|
children: import("react").ReactNode;
|
|
7
6
|
isPrepass?: boolean | undefined;
|
|
@@ -9,25 +8,13 @@ export declare function createRPCClient(): {
|
|
|
9
8
|
}) => JSX.Element;
|
|
10
9
|
createClient: (opts: import("@trpc/react").CreateTRPCClientOptions<import("@trpc/server").AnyRouter<any>>) => import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>;
|
|
11
10
|
useContext: () => import("@trpc/react/dist/declarations/src/internals/context").TRPCContextState<import("@trpc/server").AnyRouter<any>, unknown>;
|
|
12
|
-
useQuery: <TPath extends string>(pathAndInput: [TPath, (null | undefined)?], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath, unknown, any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>> | undefined) => UseQueryResult<
|
|
13
|
-
|
|
14
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
15
|
-
}; }[TPath_2]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
16
|
-
useMutation: <TPath_1 extends string>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<unknown, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>, any> | undefined) => UseMutationResult<{ [TPath_3 in keyof TRouter["_def"]["mutations"]]: {
|
|
17
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_3]>;
|
|
18
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_3]["call"]>>;
|
|
19
|
-
}; }[TPath_1_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>, { [TPath_3 in keyof TRouter["_def"]["mutations"]]: {
|
|
20
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["mutations"][TPath_3]>;
|
|
21
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["mutations"][TPath_3]["call"]>>;
|
|
22
|
-
}; }[TPath_1_1]["input"], unknown>;
|
|
11
|
+
useQuery: <TPath extends string>(pathAndInput: [TPath, (null | undefined)?], opts?: import("@trpc/react").UseTRPCQueryOptions<TPath, unknown, any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>> | undefined) => import("react-query").UseQueryResult<any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>>;
|
|
12
|
+
useMutation: <TPath_1 extends string>(path: TPath_1 | [TPath_1], opts?: import("@trpc/react").UseTRPCMutationOptions<unknown, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>, any> | undefined) => import("react-query").UseMutationResult<any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>, unknown, unknown>;
|
|
23
13
|
useSubscription: <TPath_2 extends string, TOutput extends any>(pathAndInput: [TPath_2, (null | undefined)?], opts: {
|
|
24
14
|
enabled?: boolean | undefined;
|
|
25
15
|
onError?: ((err: import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>) => void) | undefined;
|
|
26
16
|
onNext: (data: TOutput) => void;
|
|
27
17
|
}) => void;
|
|
28
|
-
useDehydratedState: (client: import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>, trpcState:
|
|
29
|
-
useInfiniteQuery: <TPath_3 extends never>(pathAndInput: [path: TPath_3, input: Omit<unknown, "cursor">], opts?: import("@trpc/react").UseTRPCInfiniteQueryOptions<TPath_3, Omit<unknown, "cursor">, any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>> | undefined) => UseInfiniteQueryResult<
|
|
30
|
-
input: import("@trpc/server").inferProcedureInput<TRouter["_def"]["queries"][TPath_1]>;
|
|
31
|
-
output: import("@trpc/server").ThenArg<ReturnType<TRouter["_def"]["queries"][TPath_1]["call"]>>;
|
|
32
|
-
}; }[TPath_3_1]["output"], import("@trpc/react").TRPCClientErrorLike<TRouter>>;
|
|
18
|
+
useDehydratedState: (client: import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>, trpcState: import("react-query").DehydratedState | undefined) => import("react-query").DehydratedState | undefined;
|
|
19
|
+
useInfiniteQuery: <TPath_3 extends never>(pathAndInput: [path: TPath_3, input: Omit<unknown, "cursor">], opts?: import("@trpc/react").UseTRPCInfiniteQueryOptions<TPath_3, Omit<unknown, "cursor">, any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>> | undefined) => import("react-query").UseInfiniteQueryResult<any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>>;
|
|
33
20
|
};
|
|
@@ -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
|
+
});
|
|
@@ -20,6 +20,7 @@ export async function fetchWordpressProps(pathname: string) {
|
|
|
20
20
|
// Convert absolute site URL details to relative paths
|
|
21
21
|
text = text.replace(new RegExp(origin.replace(/(http|https)/, `https?`) + "([a-z0-9-_./]+)", "g"), (url) => {
|
|
22
22
|
const path = url.replace(/https?:\/\/[^\/]+/, "")
|
|
23
|
+
console.log("URL", url, path)
|
|
23
24
|
if (path.startsWith("/wp-content/uploads/")) {
|
|
24
25
|
if (settings?.uploads === "proxy") {
|
|
25
26
|
return path
|
|
@@ -38,6 +39,8 @@ export async function fetchWordpressProps(pathname: string) {
|
|
|
38
39
|
} else if (settings?.uploads === "remote") {
|
|
39
40
|
return url
|
|
40
41
|
}
|
|
42
|
+
} else {
|
|
43
|
+
return path
|
|
41
44
|
}
|
|
42
45
|
return url
|
|
43
46
|
})
|
|
File without changes
|