eddev 0.2.0-beta.43 → 0.2.0-beta.46

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.
@@ -323,6 +323,7 @@ function getWebpackConfig(opts) {
323
323
  }
324
324
  // Define some values
325
325
  DEFINES["process.browser"] = JSON.stringify(isBrowser);
326
+ DEFINES["process.client"] = JSON.stringify(isBrowser);
326
327
  DEFINES["process.serverless"] = "false";
327
328
  DEFINES["process.ssr"] = JSON.stringify(isServerless && !isBrowser);
328
329
  DEFINES["process.LOADABLE_STATS_FILE"] = JSON.stringify(loadableManifestFile);
@@ -164,7 +164,7 @@ function beginWork(opts) {
164
164
  });
165
165
  }); };
166
166
  // Create RPC/API types
167
- (0, promises_1.writeFile)(Path.join(opts.baseDirectory, "types.api.ts"), "\n import type { router, createContext } from \"./apis/_rpc\"\n import { createReactQueryHooks } from \"@trpc/react\"\n export {}\n \n const createQueryHooks = () => createReactQueryHooks<typeof router>()\n \n declare global {\n type RPCUse = ReturnType<typeof createQueryHooks>\n type RPCRouter = typeof router\n type RPCContextType = Awaited<ReturnType<typeof createContext>>\n type RPCClient = ReturnType<RPCUse[\"createClient\"]>\n type RPCUseQuery = RPCUse[\"useQuery\"]\n type RPCUseMutation = RPCUse[\"useMutation\"]\n type RPCUseInfiniteQuery = RPCUse[\"useInfiniteQuery\"]\n } \n ");
167
+ (0, promises_1.writeFile)(Path.join(opts.baseDirectory, "types.api.ts"), "\n import type { router, createContext } from \"./apis/_rpc\"\n import { createReactQueryHooks } from \"@trpc/react\"\n export {}\n \n const createQueryHooks = () => createReactQueryHooks<typeof router>()\n \n declare global {\n type RPCUse = ReturnType<typeof createQueryHooks>\n type RPCRouter = typeof router\n type RPCContextType = Awaited<ReturnType<typeof createContext>>\n type RPCClient = ReturnType<RPCUse[\"createClient\"]>\n type RPCUseQuery = RPCUse[\"useQuery\"]\n type RPCUseMutation = RPCUse[\"useMutation\"]\n type RPCUseInfiniteQuery = RPCUse[\"useInfiniteQuery\"]\n }\n\n declare global {\n namespace NodeJS {\n interface Process {\n // @ts-ignore\n browser: boolean\n dev: boolean\n admin: boolean\n serverless: boolean\n }\n }\n }\n \n ");
168
168
  regenerate = debounce(100, function () { return __awaiter(_this, void 0, void 0, function () {
169
169
  var startTime, hasChanged, err_1, documentSets, parseErrors, _loop_1, _a, _b, _i, key, generates, errors, _c, _d, _e, file, base, config, output, err_2;
170
170
  var _this = this;
@@ -17,8 +17,9 @@ var routing_1 = require("../routing");
17
17
  var router_1 = require("next/router");
18
18
  function NextRouter(_a) {
19
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) {
20
+ var nextRoute = (0, router_1.useRouter)();
21
+ var route = __assign(__assign({}, nextRoute), { pathname: nextRoute.asPath });
22
+ return ((0, jsx_runtime_1.jsx)(routing_1.RouterRoot, __assign({ url: nextRoute.asPath, data: data, onNavigateRequest: function (url) {
22
23
  route.push(url);
23
24
  // setPendingUrl({ popped: false, url })
24
25
  }, onPreload: function (url) {
package/hooks/useRPC.js CHANGED
@@ -11,6 +11,6 @@ exports.useRPCMutation = trpc.useQuery;
11
11
  exports.useRPCMutation = trpc.useInfiniteQuery;
12
12
  exports.rpcClient = trpc.createClient({
13
13
  // @ts-ignore
14
- url: process.serverlessEndpoint + "/api/trpc",
14
+ url: process.serverlessEndpoint.replace(/\/$/, "") + "/api/trpc",
15
15
  // @ts-ignore
16
16
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "0.2.0-beta.43",
3
+ "version": "0.2.0-beta.46",
4
4
  "main": "./index.js",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -329,7 +329,7 @@ exports.Link = (0, react_1.forwardRef)(function (props, ref) {
329
329
  // @ts-ignore
330
330
  if (process.serverless) {
331
331
  var NextLink = require("next/link").default;
332
- return ((0, jsx_runtime_1.jsx)(NextLink, __assign({ href: props.href, passHref: true }, { children: (0, jsx_runtime_1.jsx)("a", __assign({}, props, { href: undefined }), void 0) }), void 0));
332
+ return ((0, jsx_runtime_1.jsx)(NextLink, __assign({ href: props.href, passHref: true }, { children: (0, jsx_runtime_1.jsx)("a", __assign({ ref: ref }, props, { href: undefined }), void 0) }), void 0));
333
333
  }
334
334
  var localRef = (0, react_1.useRef)();
335
335
  var router = (0, react_1.useContext)(RouterContext);
@@ -1,3 +1,5 @@
1
+ import { TRPCError } from "@trpc/server";
1
2
  export * from "./define-api";
2
3
  export * from "./define-rpc-router";
3
4
  export * from "./error-codes";
5
+ export declare const RPCError: typeof TRPCError;
@@ -10,6 +10,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.RPCError = void 0;
14
+ var server_1 = require("@trpc/server");
13
15
  __exportStar(require("./define-api"), exports);
14
16
  __exportStar(require("./define-rpc-router"), exports);
15
17
  __exportStar(require("./error-codes"), exports);
18
+ exports.RPCError = server_1.TRPCError;
@@ -9,8 +9,6 @@ export async function fetchWordpressProps(pathname: string) {
9
9
  pathname = pathname.replace(/(^\/|\/$)/g, "")
10
10
  const propsURL = origin + ("/" + pathname + "/?_props=all").replace(/\/+/, "/")
11
11
 
12
- console.log("Fetching props", propsURL)
13
-
14
12
  // Make the request
15
13
  let response = await fetchWP(propsURL, {})
16
14
 
@@ -20,7 +18,6 @@ export async function fetchWordpressProps(pathname: string) {
20
18
  // Convert absolute site URL details to relative paths
21
19
  text = text.replace(new RegExp(origin.replace(/(http|https)/, `https?`) + "([a-z0-9-_./]+)", "g"), (url) => {
22
20
  const path = url.replace(/https?:\/\/[^\/]+/, "")
23
- console.log("URL", url, path)
24
21
  if (path.startsWith("/wp-content/uploads/")) {
25
22
  if (settings?.uploads === "proxy") {
26
23
  return path
@@ -50,6 +50,7 @@ module.exports = (() => {
50
50
  const define = config.plugins.find((plugin) => plugin instanceof DefinePlugin)
51
51
  define.definitions["process.serverless"] = "true"
52
52
  define.definitions["process.admin"] = "false"
53
+ define.definitions["process.client"] = isServer ? "false" : "true"
53
54
  define.definitions["process.dev"] = process.env.NODE_ENV === "development"
54
55
 
55
56
  const themePath =
@@ -1,3 +1,5 @@
1
+ import { fetchWP } from "../../../_utils/fetch-wp"
2
+
1
3
  const validProxyPaths = {
2
4
  "form-submit": {
3
5
  path: "/wp-json/ed/v1/gf/submit",
@@ -25,7 +27,7 @@ export default async function (req: any, res: any) {
25
27
 
26
28
  const finalPath = proxyPath.path.replace("*", req.query.method.slice(1).join("/"))
27
29
 
28
- const response = await fetch(process.env.SITE_URL + finalPath, {
30
+ const response = await fetchWP(process.env.SITE_URL + finalPath, {
29
31
  method: proxyPath.method,
30
32
  headers: {
31
33
  "Content-Type": "application/json",