eddev 0.2.0-beta.15 → 0.2.0-beta.16
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/get-webpack-config.js +1 -0
- package/build/serverless/create-next-app.js +60 -56
- package/cli/cli.js +4 -4
- package/components/PageHead.d.ts +1 -0
- package/components/PageHead.js +2 -0
- package/components/PageMeta.d.ts +1 -0
- package/components/PageMeta.js +2 -0
- package/components/PageMeta.monolith.d.ts +1 -0
- package/components/PageMeta.monolith.js +2 -0
- package/components/ServerlessPageMeta.d.ts +1 -0
- package/components/ServerlessPageMeta.js +2 -0
- package/config/config-schema.d.ts +5 -0
- package/config/config-schema.js +1 -0
- package/config/get-config.d.ts +3 -0
- package/config/parse-config.d.ts +2 -0
- package/dev-ui/hooks/usePersistState.js +3 -0
- package/dev-ui/loader.d.ts +2 -0
- package/dev-ui/loader.js +42 -0
- package/entry/Root.js +2 -18
- package/package.json +11 -1
- package/serverless/create-rpc-client.d.ts +5 -17
- package/serverless-template/_utils/PageMeta.tsx +44 -0
- package/serverless-template/_utils/fetch-wordpress-props.ts +10 -3
- package/serverless-template/_utils/fetch-wp.ts +16 -0
- package/serverless-template/global.d.ts +1 -0
- package/serverless-template/next.config.js +2 -0
- package/serverless-template/pages/_app.tsx +7 -0
- package/utils/updateEnvFile.d.ts +1 -0
- package/utils/updateEnvFile.js +76 -0
|
@@ -332,6 +332,7 @@ function getWebpackConfig(opts) {
|
|
|
332
332
|
DEFINES["process.BLOCK_MANIFEST_FILE"] = JSON.stringify(ALIAS["@manifest/blocks"]);
|
|
333
333
|
}
|
|
334
334
|
DEFINES["process.devUI"] = config.devUI === "enabled";
|
|
335
|
+
DEFINES["process.serverlessEndpoint"] = "window.SERVERLESS_ENDPOINT";
|
|
335
336
|
if (isBrowser) {
|
|
336
337
|
DEFINES["process.env.themePath"] = "window.THEME_PATH || ".concat(DEFINES["process.env.themePath"]);
|
|
337
338
|
}
|
|
@@ -88,6 +88,7 @@ var manifest_blocks_1 = require("../manifests/manifest-blocks");
|
|
|
88
88
|
var promises_1 = require("fs/promises");
|
|
89
89
|
var manifest_views_1 = require("../manifests/manifest-views");
|
|
90
90
|
var getRepoName_1 = require("../../utils/getRepoName");
|
|
91
|
+
var updateEnvFile_1 = require("../../utils/updateEnvFile");
|
|
91
92
|
function requireConfig(dir) {
|
|
92
93
|
var configPath = (0, path_1.resolve)(dir, "ed.config.json");
|
|
93
94
|
return require(configPath);
|
|
@@ -123,7 +124,7 @@ function createNextApp(opts) {
|
|
|
123
124
|
_b.sent();
|
|
124
125
|
_b.label = 5;
|
|
125
126
|
case 5:
|
|
126
|
-
if (!!isVercel) return [3 /*break*/,
|
|
127
|
+
if (!!isVercel) return [3 /*break*/, 10];
|
|
127
128
|
// Sync important files during development, as they change
|
|
128
129
|
return [4 /*yield*/, syncFiles(opts.baseDirectory, serverlessDirectory, __spreadArray([
|
|
129
130
|
"blocks/**/*",
|
|
@@ -152,40 +153,58 @@ function createNextApp(opts) {
|
|
|
152
153
|
// Also sync APIs into the APIs folder
|
|
153
154
|
_b.sent();
|
|
154
155
|
// And public folder
|
|
155
|
-
return [4 /*yield*/, syncFiles((0, path_1.join)(opts.baseDirectory, "assets"), (0, path_1.join)(serverlessDirectory, "public/wp-content/themes/".concat(repoName.repoName, "/assets")), ["**/*"])
|
|
156
|
+
return [4 /*yield*/, syncFiles((0, path_1.join)(opts.baseDirectory, "assets"), (0, path_1.join)(serverlessDirectory, "public/wp-content/themes/".concat(repoName.repoName, "/assets")), ["**/*"])
|
|
157
|
+
// Sync favicon
|
|
158
|
+
];
|
|
156
159
|
case 8:
|
|
157
160
|
// And public folder
|
|
158
161
|
_b.sent();
|
|
159
|
-
|
|
162
|
+
// Sync favicon
|
|
163
|
+
return [4 /*yield*/, syncFiles((0, path_1.join)(opts.baseDirectory), (0, path_1.join)(serverlessDirectory, "public/"), ["favicon.ico"])];
|
|
160
164
|
case 9:
|
|
161
|
-
|
|
165
|
+
// Sync favicon
|
|
166
|
+
_b.sent();
|
|
167
|
+
_b.label = 10;
|
|
168
|
+
case 10:
|
|
169
|
+
if (!!isVercel) return [3 /*break*/, 12];
|
|
162
170
|
sendSignal({ code: "packaging" });
|
|
163
171
|
return [4 /*yield*/, updatePackages(serverlessDirectory)];
|
|
164
|
-
case 10:
|
|
165
|
-
_b.sent();
|
|
166
|
-
_b.label = 11;
|
|
167
172
|
case 11:
|
|
173
|
+
_b.sent();
|
|
174
|
+
_b.label = 12;
|
|
175
|
+
case 12:
|
|
168
176
|
sendSignal({ code: "compiling" });
|
|
169
177
|
// Create manifests
|
|
170
|
-
initManifests(serverlessDirectory, opts.dev)
|
|
171
|
-
|
|
172
|
-
return [4 /*yield*/, getPort(3000)];
|
|
173
|
-
case 12:
|
|
174
|
-
port = _b.sent();
|
|
175
|
-
sendSignal({ code: "url", url: "http://127.0.0.1:".concat(port) });
|
|
176
|
-
return [4 /*yield*/, devNext(serverlessDirectory, port)
|
|
177
|
-
// await runScript(serverlessDirectory, "dev")
|
|
178
|
+
return [4 /*yield*/, initManifests(serverlessDirectory, opts.dev)
|
|
179
|
+
// Start
|
|
178
180
|
];
|
|
179
181
|
case 13:
|
|
182
|
+
// Create manifests
|
|
180
183
|
_b.sent();
|
|
181
|
-
return [3 /*break*/, 16];
|
|
184
|
+
if (!opts.dev) return [3 /*break*/, 16];
|
|
185
|
+
return [4 /*yield*/, getPort(3000)
|
|
186
|
+
// Write the endpoint URL to .env
|
|
187
|
+
];
|
|
182
188
|
case 14:
|
|
183
|
-
|
|
184
|
-
|
|
189
|
+
port = _b.sent();
|
|
190
|
+
// Write the endpoint URL to .env
|
|
191
|
+
(0, updateEnvFile_1.updateEnvFile)({
|
|
192
|
+
DEBUG_SERVERLESS_ENDPOINT: "http://localhost:".concat(port),
|
|
193
|
+
}, opts.baseDirectory);
|
|
194
|
+
sendSignal({ code: "url", url: "http://127.0.0.1:".concat(port) });
|
|
195
|
+
// await devNext(serverlessDirectory, port)
|
|
196
|
+
return [4 /*yield*/, runScript(serverlessDirectory, ["dev", "--port", String(port)])];
|
|
185
197
|
case 15:
|
|
198
|
+
// await devNext(serverlessDirectory, port)
|
|
199
|
+
_b.sent();
|
|
200
|
+
return [3 /*break*/, 18];
|
|
201
|
+
case 16:
|
|
202
|
+
if (!opts.build) return [3 /*break*/, 18];
|
|
203
|
+
return [4 /*yield*/, runScript(serverlessDirectory, ["build"])];
|
|
204
|
+
case 17:
|
|
186
205
|
_b.sent();
|
|
187
|
-
_b.label =
|
|
188
|
-
case
|
|
206
|
+
_b.label = 18;
|
|
207
|
+
case 18: return [2 /*return*/];
|
|
189
208
|
}
|
|
190
209
|
});
|
|
191
210
|
});
|
|
@@ -261,7 +280,7 @@ function updatePackagesFile(sourceFolder, targetFolder) {
|
|
|
261
280
|
targetPackageFile = (0, path_1.resolve)(targetFolder, "package.json");
|
|
262
281
|
sourcePackage = require(sourcePackageFile);
|
|
263
282
|
targetPackage = require(targetPackageFile);
|
|
264
|
-
mergedPackage = __assign(__assign({}, targetPackage), { dependencies: __assign(__assign({}, (
|
|
283
|
+
mergedPackage = __assign(__assign({}, targetPackage), { dependencies: __assign(__assign({}, (targetPackage.dependencies || {})), (sourcePackage.dependencies || {})), devDependencies: __assign(__assign({}, (targetPackage.devDependencies || {})), (sourcePackage.devDependencies || {})) });
|
|
265
284
|
(0, fs_extra_1.writeJSON)(targetPackageFile, mergedPackage, {
|
|
266
285
|
spaces: 2,
|
|
267
286
|
});
|
|
@@ -303,45 +322,30 @@ function syncFiles(sourceFolder, targetFolder, patterns) {
|
|
|
303
322
|
});
|
|
304
323
|
});
|
|
305
324
|
}
|
|
306
|
-
function devNext(dir, port) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
port: port,
|
|
326
|
-
});
|
|
327
|
-
handle = app.getRequestHandler();
|
|
328
|
-
app.prepare().then(function () {
|
|
329
|
-
console.log("http://127.0.0.1:".concat(port));
|
|
330
|
-
createServer(function (req, res) {
|
|
331
|
-
handle(req, res, parse(req.url || "", true));
|
|
332
|
-
}).listen(app.port);
|
|
333
|
-
});
|
|
334
|
-
return [2 /*return*/];
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
function runScript(dir, script) {
|
|
325
|
+
// async function devNext(dir: string, port: number) {
|
|
326
|
+
// const { createServer } = await import("http")
|
|
327
|
+
// const { parse } = await import("url")
|
|
328
|
+
// const { default: next } = await import("next")
|
|
329
|
+
// const app = next({
|
|
330
|
+
// dev: true,
|
|
331
|
+
// dir: dir,
|
|
332
|
+
// minimalMode: true,
|
|
333
|
+
// customServer: true,
|
|
334
|
+
// port: port,
|
|
335
|
+
// })
|
|
336
|
+
// const handle = app.getRequestHandler()
|
|
337
|
+
// app.prepare().then(() => {
|
|
338
|
+
// createServer((req, res) => {
|
|
339
|
+
// handle(req, res, parse(req.url || "", true))
|
|
340
|
+
// }).listen(app.port)
|
|
341
|
+
// })
|
|
342
|
+
// }
|
|
343
|
+
function runScript(dir, args) {
|
|
340
344
|
var _a, _b;
|
|
341
345
|
return __awaiter(this, void 0, void 0, function () {
|
|
342
346
|
var proc;
|
|
343
347
|
return __generator(this, function (_c) {
|
|
344
|
-
proc = (0, child_process_1.spawn)("yarn",
|
|
348
|
+
proc = (0, child_process_1.spawn)("yarn", args, {
|
|
345
349
|
cwd: dir,
|
|
346
350
|
});
|
|
347
351
|
(_a = proc.stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout);
|
package/cli/cli.js
CHANGED
|
@@ -38,8 +38,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
var commander_1 = require("commander");
|
|
40
40
|
var create_next_app_1 = require("../build/serverless/create-next-app");
|
|
41
|
-
var build_dev_1 = require("./build.dev");
|
|
42
|
-
var build_prod_1 = require("./build.prod");
|
|
43
41
|
var setup_1 = require("./setup");
|
|
44
42
|
var program = new commander_1.Command();
|
|
45
43
|
program.version("0.0.1");
|
|
@@ -51,7 +49,8 @@ program
|
|
|
51
49
|
.option("-m, --mode <mode>", 'Defaults to all modes, but use "frontend", "admin" or "codegen" to run in just one mode', undefined)
|
|
52
50
|
.option("--verbose", "Enables log retention", false)
|
|
53
51
|
.action(function (options) {
|
|
54
|
-
(
|
|
52
|
+
var devCommand = require("./build.dev").devCommand;
|
|
53
|
+
devCommand({
|
|
55
54
|
serverless: options.serverless,
|
|
56
55
|
mode: options.mode,
|
|
57
56
|
retainLog: options.verbose,
|
|
@@ -69,7 +68,8 @@ program
|
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
else {
|
|
72
|
-
(
|
|
71
|
+
var prodCommand = require("./build.prod").prodCommand;
|
|
72
|
+
prodCommand({
|
|
73
73
|
serverless: options.serverless,
|
|
74
74
|
});
|
|
75
75
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PageMeta(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PageMeta(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PageMeta(): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PageMeta(): any;
|
|
@@ -8,6 +8,7 @@ export declare const EDConfigSchema: z.ZodObject<{
|
|
|
8
8
|
theme: z.ZodEnum<["proxy", "copy", "remote"]>;
|
|
9
9
|
devAssets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
10
|
apiOnly: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
endpoints: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
11
12
|
}, "strip", z.ZodTypeAny, {
|
|
12
13
|
devAssets?: string[] | undefined;
|
|
13
14
|
apiOnly?: boolean | undefined;
|
|
@@ -15,6 +16,7 @@ export declare const EDConfigSchema: z.ZodObject<{
|
|
|
15
16
|
uploads: "proxy" | "remote";
|
|
16
17
|
plugins: "proxy" | "remote";
|
|
17
18
|
theme: "copy" | "proxy" | "remote";
|
|
19
|
+
endpoints: Record<string, string>;
|
|
18
20
|
}, {
|
|
19
21
|
devAssets?: string[] | undefined;
|
|
20
22
|
apiOnly?: boolean | undefined;
|
|
@@ -22,6 +24,7 @@ export declare const EDConfigSchema: z.ZodObject<{
|
|
|
22
24
|
uploads: "proxy" | "remote";
|
|
23
25
|
plugins: "proxy" | "remote";
|
|
24
26
|
theme: "copy" | "proxy" | "remote";
|
|
27
|
+
endpoints: Record<string, string>;
|
|
25
28
|
}>>;
|
|
26
29
|
devUI: z.ZodEnum<["disabled", "enabled"]>;
|
|
27
30
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -33,6 +36,7 @@ export declare const EDConfigSchema: z.ZodObject<{
|
|
|
33
36
|
uploads: "proxy" | "remote";
|
|
34
37
|
plugins: "proxy" | "remote";
|
|
35
38
|
theme: "copy" | "proxy" | "remote";
|
|
39
|
+
endpoints: Record<string, string>;
|
|
36
40
|
} | undefined;
|
|
37
41
|
devUI: "disabled" | "enabled";
|
|
38
42
|
}, {
|
|
@@ -44,6 +48,7 @@ export declare const EDConfigSchema: z.ZodObject<{
|
|
|
44
48
|
uploads: "proxy" | "remote";
|
|
45
49
|
plugins: "proxy" | "remote";
|
|
46
50
|
theme: "copy" | "proxy" | "remote";
|
|
51
|
+
endpoints: Record<string, string>;
|
|
47
52
|
} | undefined;
|
|
48
53
|
devUI: "disabled" | "enabled";
|
|
49
54
|
}>;
|
package/config/config-schema.js
CHANGED
|
@@ -12,6 +12,7 @@ exports.EDConfigSchema = zod_1.z.object({
|
|
|
12
12
|
theme: zod_1.z.enum(["proxy", "copy", "remote"]),
|
|
13
13
|
devAssets: zod_1.z.array(zod_1.z.string()).optional(),
|
|
14
14
|
apiOnly: zod_1.z.boolean().optional(),
|
|
15
|
+
endpoints: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
|
|
15
16
|
})
|
|
16
17
|
.optional(),
|
|
17
18
|
devUI: zod_1.z.enum(["disabled", "enabled"]),
|
package/config/get-config.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare function getEDConfig(dir?: string): import("zod").SafeParseReturn
|
|
|
7
7
|
uploads: "proxy" | "remote";
|
|
8
8
|
plugins: "proxy" | "remote";
|
|
9
9
|
theme: "copy" | "proxy" | "remote";
|
|
10
|
+
endpoints: Record<string, string>;
|
|
10
11
|
} | undefined;
|
|
11
12
|
devUI: "disabled" | "enabled";
|
|
12
13
|
}, {
|
|
@@ -18,6 +19,7 @@ export declare function getEDConfig(dir?: string): import("zod").SafeParseReturn
|
|
|
18
19
|
uploads: "proxy" | "remote";
|
|
19
20
|
plugins: "proxy" | "remote";
|
|
20
21
|
theme: "copy" | "proxy" | "remote";
|
|
22
|
+
endpoints: Record<string, string>;
|
|
21
23
|
} | undefined;
|
|
22
24
|
devUI: "disabled" | "enabled";
|
|
23
25
|
}>;
|
|
@@ -30,6 +32,7 @@ export declare function getEDConfigUnwrapped(dir?: string): {
|
|
|
30
32
|
uploads: "proxy" | "remote";
|
|
31
33
|
plugins: "proxy" | "remote";
|
|
32
34
|
theme: "copy" | "proxy" | "remote";
|
|
35
|
+
endpoints: Record<string, string>;
|
|
33
36
|
} | undefined;
|
|
34
37
|
devUI: "disabled" | "enabled";
|
|
35
38
|
};
|
package/config/parse-config.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare function parseConfig(config: any): import("zod").SafeParseReturnT
|
|
|
7
7
|
uploads: "proxy" | "remote";
|
|
8
8
|
plugins: "proxy" | "remote";
|
|
9
9
|
theme: "copy" | "proxy" | "remote";
|
|
10
|
+
endpoints: Record<string, string>;
|
|
10
11
|
} | undefined;
|
|
11
12
|
devUI: "disabled" | "enabled";
|
|
12
13
|
}, {
|
|
@@ -18,6 +19,7 @@ export declare function parseConfig(config: any): import("zod").SafeParseReturnT
|
|
|
18
19
|
uploads: "proxy" | "remote";
|
|
19
20
|
plugins: "proxy" | "remote";
|
|
20
21
|
theme: "copy" | "proxy" | "remote";
|
|
22
|
+
endpoints: Record<string, string>;
|
|
21
23
|
} | undefined;
|
|
22
24
|
devUI: "disabled" | "enabled";
|
|
23
25
|
}>;
|
|
@@ -4,6 +4,9 @@ exports.usePersistState = void 0;
|
|
|
4
4
|
var react_1 = require("react");
|
|
5
5
|
var get = function (id, fallback) {
|
|
6
6
|
if (fallback === void 0) { fallback = undefined; }
|
|
7
|
+
if (typeof localStorage === "undefined") {
|
|
8
|
+
return fallback;
|
|
9
|
+
}
|
|
7
10
|
var value = localStorage.getItem("devui_" + id);
|
|
8
11
|
if (value !== null) {
|
|
9
12
|
try {
|
package/dev-ui/loader.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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.DevUILoader = void 0;
|
|
23
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
24
|
+
var react_1 = require("react");
|
|
25
|
+
var dynamic_1 = require("../dynamic");
|
|
26
|
+
var usePersistState_1 = require("./hooks/usePersistState");
|
|
27
|
+
var DevUI = (0, dynamic_1.dynamic)(function () { return Promise.resolve().then(function () { return __importStar(require("./components/DevUI")); }); }, { ssr: false });
|
|
28
|
+
function DevUILoader() {
|
|
29
|
+
var _a = (0, usePersistState_1.usePersistState)("enable_devui", process.dev || (typeof window !== "undefined" && window["ENABLE_DEV_UI"])), render = _a[0], setRender = _a[1];
|
|
30
|
+
(0, react_1.useEffect)(function () {
|
|
31
|
+
if (document.location.search.includes("activate-dev-ui")) {
|
|
32
|
+
setRender(true);
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
if (render) {
|
|
36
|
+
return (0, jsx_runtime_1.jsx)(DevUI, {}, void 0);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.DevUILoader = DevUILoader;
|
package/entry/Root.js
CHANGED
|
@@ -33,31 +33,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
33
33
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
34
34
|
// @ts-ignore
|
|
35
35
|
var views_1 = __importStar(require("@manifest/views"));
|
|
36
|
-
var dynamic_1 = require("../dynamic");
|
|
37
36
|
var react_1 = require("react");
|
|
38
37
|
var routing_1 = require("../routing");
|
|
39
|
-
var
|
|
40
|
-
var DevUI = (0, dynamic_1.dynamic)(function () { return Promise.resolve().then(function () { return __importStar(require("../dev-ui/components/DevUI")); }); });
|
|
38
|
+
var loader_1 = require("../dev-ui/loader");
|
|
41
39
|
function Root() {
|
|
42
40
|
var route = (0, routing_1.useRoute)();
|
|
43
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [process.devUI && (0, jsx_runtime_1.jsx)(DevUILoader, {}, void 0), (0, jsx_runtime_1.jsx)(views_1.App, { children: (0, jsx_runtime_1.jsx)(routing_1.Switch, { children: Object.entries(views_1.default).map(function (_a) {
|
|
41
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [process.devUI && (0, jsx_runtime_1.jsx)(loader_1.DevUILoader, {}, void 0), (0, jsx_runtime_1.jsx)(views_1.App, { children: (0, jsx_runtime_1.jsx)(routing_1.Switch, { children: Object.entries(views_1.default).map(function (_a) {
|
|
44
42
|
var _b, _c;
|
|
45
43
|
var name = _a[0], Component = _a[1];
|
|
46
44
|
return ((0, jsx_runtime_1.jsx)(routing_1.Route, __assign({ match: function (route) { var _a; return ((_a = route.data) === null || _a === void 0 ? void 0 : _a.view) === name; } }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({}, (_c = (_b = route.data) === null || _b === void 0 ? void 0 : _b.viewData) === null || _c === void 0 ? void 0 : _c.data), void 0) }), name));
|
|
47
45
|
}) }, void 0) }, void 0)] }, void 0));
|
|
48
46
|
}
|
|
49
47
|
exports.default = Root;
|
|
50
|
-
function DevUILoader() {
|
|
51
|
-
var _a = (0, usePersistState_1.usePersistState)("enable_devui", process.dev || (typeof window !== "undefined" && window["ENABLE_DEV_UI"])), render = _a[0], setRender = _a[1];
|
|
52
|
-
(0, react_1.useEffect)(function () {
|
|
53
|
-
if (document.location.search.includes("activate-dev-ui")) {
|
|
54
|
-
setRender(true);
|
|
55
|
-
}
|
|
56
|
-
}, []);
|
|
57
|
-
if (render) {
|
|
58
|
-
return (0, jsx_runtime_1.jsx)(DevUI, {}, void 0);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
}
|
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.16",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -50,6 +50,10 @@
|
|
|
50
50
|
"@soda/friendly-errors-webpack-plugin": "^1.8.0",
|
|
51
51
|
"@stitches/core": "^1.2.6",
|
|
52
52
|
"@stitches/react": "^1.2.6",
|
|
53
|
+
"@trpc/client": "^9.19.0",
|
|
54
|
+
"@trpc/next": "^9.19.0",
|
|
55
|
+
"@trpc/react": "^9.19.0",
|
|
56
|
+
"@trpc/server": "^9.19.0",
|
|
53
57
|
"autoprefixer": "^10.3.4",
|
|
54
58
|
"babel-loader": "^8.2.2",
|
|
55
59
|
"chalk": "^4.1.2",
|
|
@@ -71,12 +75,14 @@
|
|
|
71
75
|
"ink": "^3.2.0",
|
|
72
76
|
"inquirer": "^8.1.2",
|
|
73
77
|
"mini-css-extract-plugin": "^2.2.2",
|
|
78
|
+
"next": "^12.1.0",
|
|
74
79
|
"next-transpile-modules": "^9.0.0",
|
|
75
80
|
"postcss-loader": "^6.1.1",
|
|
76
81
|
"qs": "^6.10.1",
|
|
77
82
|
"react-error-overlay": "^6.0.9",
|
|
78
83
|
"react-inspector": "^5.1.1",
|
|
79
84
|
"react-merge-refs": "^1.1.0",
|
|
85
|
+
"react-query": "^3.34.16",
|
|
80
86
|
"react-refresh": "^0.10.0",
|
|
81
87
|
"rimraf": "^3.0.2",
|
|
82
88
|
"swr": "^1.0.1",
|
|
@@ -93,6 +99,10 @@
|
|
|
93
99
|
"zustand": "^3.5.10"
|
|
94
100
|
},
|
|
95
101
|
"peerDependencies": {
|
|
102
|
+
"@trpc/client": "^9.19.0",
|
|
103
|
+
"@trpc/next": "^9.19.0",
|
|
104
|
+
"@trpc/react": "^9.19.0",
|
|
105
|
+
"@trpc/server": "^9.19.0",
|
|
96
106
|
"react": "^18.0.0-rc.0",
|
|
97
107
|
"react-dom": "^18.0.0-rc.0"
|
|
98
108
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare function createRPCClient(): {
|
|
3
3
|
Provider: ({ client, queryClient, children, isPrepass, ssrContext, }: {
|
|
4
|
-
queryClient: QueryClient;
|
|
4
|
+
queryClient: import("react-query").QueryClient;
|
|
5
5
|
client: import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>;
|
|
6
6
|
children: import("react").ReactNode;
|
|
7
7
|
isPrepass?: boolean | undefined;
|
|
@@ -9,25 +9,13 @@ export declare function createRPCClient(): {
|
|
|
9
9
|
}) => JSX.Element;
|
|
10
10
|
createClient: (opts: import("@trpc/react").CreateTRPCClientOptions<import("@trpc/server").AnyRouter<any>>) => import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>;
|
|
11
11
|
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>;
|
|
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) => import("react-query").UseQueryResult<any, import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>>;
|
|
13
|
+
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
14
|
useSubscription: <TPath_2 extends string, TOutput extends any>(pathAndInput: [TPath_2, (null | undefined)?], opts: {
|
|
24
15
|
enabled?: boolean | undefined;
|
|
25
16
|
onError?: ((err: import("@trpc/react").TRPCClientErrorLike<import("@trpc/server").AnyRouter<any>>) => void) | undefined;
|
|
26
17
|
onNext: (data: TOutput) => void;
|
|
27
18
|
}) => 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>>;
|
|
19
|
+
useDehydratedState: (client: import("@trpc/react").TRPCClient<import("@trpc/server").AnyRouter<any>>, trpcState: import("react-query").DehydratedState | undefined) => import("react-query").DehydratedState | undefined;
|
|
20
|
+
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
21
|
};
|
|
@@ -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
|
+
console.log("Meta", props)
|
|
9
|
+
return (
|
|
10
|
+
<Head>
|
|
11
|
+
{props.title?.map((tag, i) => (
|
|
12
|
+
<title key={"title" + i}>{tag.__code}</title>
|
|
13
|
+
))}
|
|
14
|
+
{props.style?.map((tag, i) => {
|
|
15
|
+
return (
|
|
16
|
+
<style
|
|
17
|
+
key={"style" + i}
|
|
18
|
+
className={tag["class"]}
|
|
19
|
+
type={tag.type}
|
|
20
|
+
id={tag.id}
|
|
21
|
+
dangerouslySetInnerHTML={{ __html: tag.__code }}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
})}
|
|
25
|
+
{props.script?.map((tag, i) => {
|
|
26
|
+
return (
|
|
27
|
+
<script
|
|
28
|
+
key={"script" + i}
|
|
29
|
+
className={tag["class"]}
|
|
30
|
+
type={tag.type}
|
|
31
|
+
id={tag.id}
|
|
32
|
+
dangerouslySetInnerHTML={{ __html: tag.__code }}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
})}
|
|
36
|
+
{props.meta?.map((tag, i) => {
|
|
37
|
+
return <meta key={"meta" + i} {...tag} />
|
|
38
|
+
})}
|
|
39
|
+
{props.link?.map((tag, i) => {
|
|
40
|
+
return <link key={"link" + i} {...tag} />
|
|
41
|
+
})}
|
|
42
|
+
</Head>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import config from "./ed-config"
|
|
2
|
+
import { fetchWP } from "./fetch-wp"
|
|
2
3
|
|
|
3
4
|
const settings = config.serverless
|
|
4
5
|
|
|
5
6
|
export async function fetchWordpressProps(pathname: string) {
|
|
7
|
+
// Determine the URL for fetching
|
|
6
8
|
const origin = (process.env.SITE_URL as string).replace(/\/$/, "")
|
|
7
9
|
pathname = pathname.replace(/(^\/|\/$)/g, "")
|
|
8
10
|
const propsURL = origin + ("/" + pathname + "/?_props=all").replace(/\/+/, "/")
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
11
18
|
let text = await response.text()
|
|
12
19
|
|
|
13
20
|
// Convert absolute site URL details to relative paths
|
|
14
21
|
text = text.replace(new RegExp(origin.replace(/(http|https)/, `https?`) + "([a-z0-9-_./]+)", "g"), (url) => {
|
|
15
|
-
const path = url.replace(/https?:\/\/[
|
|
22
|
+
const path = url.replace(/https?:\/\/[^\/]+/, "")
|
|
16
23
|
if (path.startsWith("/wp-content/uploads/")) {
|
|
17
24
|
if (settings?.uploads === "proxy") {
|
|
18
25
|
return path
|
|
@@ -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
|
+
}
|
|
@@ -55,6 +55,8 @@ module.exports = (() => {
|
|
|
55
55
|
|
|
56
56
|
define.definitions["process.env.themePath"] = JSON.stringify(themePath)
|
|
57
57
|
define.definitions["process.themePath"] = JSON.stringify(themePath)
|
|
58
|
+
define.definitions["process.devUI"] = settings.devUI === "enabled"
|
|
59
|
+
define.definitions["process.serverlessEndpoint"] = JSON.stringify("/")
|
|
58
60
|
// config.plugins.push(
|
|
59
61
|
// new DefinePlugin({
|
|
60
62
|
// "process.serverless": "true",
|
|
@@ -5,6 +5,8 @@ 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"
|
|
8
10
|
|
|
9
11
|
function MyApp({ Component, pageProps }: AppProps) {
|
|
10
12
|
if (!pageProps.appData) return <div />
|
|
@@ -19,9 +21,14 @@ function MyApp({ Component, pageProps }: AppProps) {
|
|
|
19
21
|
|
|
20
22
|
const View = manifest[pageProps.view]
|
|
21
23
|
|
|
24
|
+
// console.log("PAGE", pageProps)
|
|
25
|
+
|
|
22
26
|
return (
|
|
23
27
|
<ServerlessAppDataProvider value={appData}>
|
|
24
28
|
<NextRouter data={pageProps} path={route.pathname}>
|
|
29
|
+
{pageProps?.meta?.head && <PageMeta {...pageProps?.meta?.head} />}
|
|
30
|
+
{pageProps?.meta?.footer && <PageMeta {...pageProps?.meta?.footer} />}
|
|
31
|
+
{process.devUI && <DevUILoader />}
|
|
25
32
|
<App>
|
|
26
33
|
<View {...viewProps} />
|
|
27
34
|
</App>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function updateEnvFile(data: Record<string, string | number>, directory?: string): Promise<void>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.updateEnvFile = void 0;
|
|
40
|
+
var fs_1 = require("fs");
|
|
41
|
+
var promises_1 = require("fs/promises");
|
|
42
|
+
var path_1 = require("path");
|
|
43
|
+
function updateEnvFile(data, directory) {
|
|
44
|
+
if (directory === void 0) { directory = process.cwd(); }
|
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
+
var path, contents, lines, key;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
path = (0, path_1.join)(directory, ".env");
|
|
51
|
+
if (!(0, fs_1.existsSync)(path)) return [3 /*break*/, 3];
|
|
52
|
+
return [4 /*yield*/, (0, promises_1.readFile)(path, "utf8")];
|
|
53
|
+
case 1:
|
|
54
|
+
contents = (_a.sent()).toString();
|
|
55
|
+
lines = contents.split(/\n/g);
|
|
56
|
+
lines = lines.filter(function (line) {
|
|
57
|
+
for (var key in data) {
|
|
58
|
+
if (line.startsWith("".concat(key, "="))) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
});
|
|
64
|
+
for (key in data) {
|
|
65
|
+
lines.push("".concat(key, "=").concat(data[key]));
|
|
66
|
+
}
|
|
67
|
+
return [4 /*yield*/, (0, promises_1.writeFile)(path, lines.join("\n"))];
|
|
68
|
+
case 2:
|
|
69
|
+
_a.sent();
|
|
70
|
+
_a.label = 3;
|
|
71
|
+
case 3: return [2 /*return*/];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.updateEnvFile = updateEnvFile;
|