eddev 2.0.0-beta.6 → 2.0.0-beta.61
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/dist/app/entry/MetaTags.d.ts +7 -0
- package/dist/app/entry/MetaTags.js +17 -0
- package/dist/app/entry/boot-admin.d.ts +1 -0
- package/dist/app/entry/boot-admin.js +14 -0
- package/dist/app/entry/spa-root.d.ts +1 -0
- package/dist/app/entry/spa-root.js +8 -0
- package/dist/app/entry/ssr-root-client.d.ts +6 -0
- package/dist/app/entry/ssr-root-client.js +26 -0
- package/dist/app/entry/ssr-root.d.ts +10 -0
- package/dist/app/entry/ssr-root.js +23 -0
- package/dist/app/lib/admin/index.d.ts +2 -2
- package/dist/app/lib/admin/index.js +2 -2
- package/dist/app/lib/admin/installFieldTypes.js +1 -1
- package/dist/app/lib/admin/runWidgets.js +1 -1
- package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
- package/dist/app/lib/blocks/ContentBlocks.js +5 -5
- package/dist/app/lib/blocks/EditableText.d.ts +1 -1
- package/dist/app/lib/blocks/EditableText.js +3 -3
- package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
- package/dist/app/lib/blocks/InnerBlocks.js +13 -5
- package/dist/app/lib/blocks/block-utils.d.ts +2 -2
- package/dist/app/lib/blocks/block-utils.js +2 -2
- package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
- package/dist/app/lib/blocks/editor/editor-config.d.ts +16 -3
- package/dist/app/lib/blocks/editor/editor-config.js +2 -4
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +17 -13
- package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
- package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
- package/dist/app/lib/blocks/index.d.ts +9 -9
- package/dist/app/lib/blocks/index.js +9 -9
- package/dist/app/lib/blocks/inline-editing.d.ts +1 -1
- package/dist/app/lib/blocks/inline-editing.js +7 -5
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +6 -4
- package/dist/app/lib/devtools/components/DevUI.js +4 -3
- package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
- package/dist/app/lib/devtools/components/GridIndicator.js +24 -0
- package/dist/app/lib/devtools/dev-tools-store.d.ts +9 -0
- package/dist/app/lib/devtools/dev-tools-store.js +8 -0
- package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
- package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1094 -1095
- package/dist/app/lib/devtools/hooks/useTailwind.js +6 -3
- package/dist/app/lib/devtools/index.d.ts +1 -0
- package/dist/app/lib/devtools/index.js +1 -1
- package/dist/app/lib/devtools/loader.js +8 -7
- package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
- package/dist/app/lib/devtools/useQueryDebug.js +5 -8
- package/dist/app/lib/dynamic/index.d.ts +1 -1
- package/dist/app/lib/dynamic/index.js +1 -1
- package/dist/app/lib/hooks/index.d.ts +4 -5
- package/dist/app/lib/hooks/index.js +4 -5
- package/dist/app/lib/hooks/queryUtils.d.ts +37 -3
- package/dist/app/lib/hooks/queryUtils.js +63 -26
- package/dist/app/lib/hooks/useAppData.js +1 -1
- package/dist/app/lib/hooks/useRPC.d.ts +0 -4
- package/dist/app/lib/hooks/useRPC.js +1 -8
- package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
- package/dist/app/lib/internal/finalize-rpc.js +3 -0
- package/dist/app/lib/internal/index.d.ts +5 -4
- package/dist/app/lib/internal/index.js +5 -4
- package/dist/app/lib/internal/internal-store.d.ts +0 -2
- package/dist/app/lib/internal/internal-store.js +1 -3
- package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
- package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
- package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/index.js +1 -1
- package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
- package/dist/app/lib/routing/components/BackButton.js +47 -0
- package/dist/app/lib/routing/components/BrowserRouter.d.ts +4 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +79 -11
- package/dist/app/lib/routing/components/ClientOnly.js +1 -1
- package/dist/app/lib/routing/components/Link.d.ts +1 -0
- package/dist/app/lib/routing/components/Link.js +9 -10
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
- package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
- package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
- package/dist/app/lib/routing/components/SSRRouter.js +5 -6
- package/dist/app/lib/routing/components/ScrollRestoration.js +1 -1
- package/dist/app/lib/routing/context.d.ts +8 -5
- package/dist/app/lib/routing/context.js +13 -96
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
- package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
- package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
- package/dist/app/lib/routing/hooks/useRoute.js +22 -1
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
- package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouter.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
- package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
- package/dist/app/lib/routing/index.d.ts +14 -13
- package/dist/app/lib/routing/index.js +14 -13
- package/dist/app/lib/routing/loader.d.ts +2 -2
- package/dist/app/lib/routing/loader.js +7 -5
- package/dist/app/lib/routing/types.d.ts +35 -9
- package/dist/app/lib/routing/utils.d.ts +3 -1
- package/dist/app/lib/routing/utils.js +12 -1
- package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
- package/dist/app/lib/runtime/apiConfig.js +6 -0
- package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
- package/dist/app/lib/runtime/errorHandling.js +6 -0
- package/dist/app/lib/runtime/index.d.ts +2 -0
- package/dist/app/lib/runtime/index.js +2 -0
- package/dist/app/lib/views/index.d.ts +1 -1
- package/dist/app/lib/views/index.js +1 -1
- package/dist/app/server/defineRouter.d.ts +2 -0
- package/dist/app/server/defineRouter.js +4 -0
- package/dist/app/server/index.d.ts +5 -0
- package/dist/app/server/index.js +5 -0
- package/dist/app/server/proxy-wp-admin.d.ts +2 -0
- package/dist/app/server/proxy-wp-admin.js +112 -0
- package/dist/app/server/render-ssr-page.d.ts +11 -0
- package/dist/app/server/render-ssr-page.js +100 -0
- package/dist/app/server/rpc.d.ts +56 -0
- package/dist/app/server/rpc.js +18 -0
- package/dist/app/server/server-context.d.ts +53 -0
- package/dist/app/server/server-context.js +149 -0
- package/dist/app/server/utils/headers.d.ts +1 -0
- package/dist/app/server/utils/headers.js +17 -0
- package/dist/app/server/utils/replace-host.d.ts +6 -4
- package/dist/app/server/utils/replace-host.js +58 -11
- package/dist/app/utils/APIProvider.d.ts +2 -0
- package/dist/app/utils/APIProvider.js +5 -0
- package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
- package/dist/app/utils/BlockErrorBoundary.js +38 -0
- package/dist/app/utils/ErrorMessage.d.ts +5 -0
- package/dist/app/utils/ErrorMessage.js +14 -0
- package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
- package/dist/app/utils/RouteErrorBoundary.js +38 -0
- package/dist/app/utils/query-client.d.ts +2 -0
- package/dist/app/utils/query-client.js +5 -1
- package/dist/app/utils/trpc-client.d.ts +2 -0
- package/dist/app/utils/trpc-client.js +34 -0
- package/dist/node/cli/cli-worker.d.ts +1 -1
- package/dist/node/cli/cli-worker.js +12 -3
- package/dist/node/cli/cli.js +91 -13
- package/dist/node/cli/display/CLIApp.d.ts +1 -1
- package/dist/node/cli/display/CLIApp.js +4 -7
- package/dist/node/cli/display/components/LogEntries.d.ts +1 -1
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -1
- package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
- package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
- package/dist/node/cli/display/tools/cli-tools.js +9 -9
- package/dist/node/cli/display/util/colors.d.ts +2 -2
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/build-vinxi.d.ts +8 -0
- package/dist/node/compiler/build-vinxi.js +38 -0
- package/dist/node/compiler/bundler.admin.d.ts +2 -2
- package/dist/node/compiler/bundler.admin.js +3 -4
- package/dist/node/compiler/bundler.frontend.d.ts +1 -1
- package/dist/node/compiler/bundler.frontend.js +3 -4
- package/dist/node/compiler/{serverless.dev.d.ts → dev-server.d.ts} +7 -5
- package/dist/node/compiler/dev-server.js +106 -0
- package/dist/node/compiler/get-vite-config.d.ts +19 -0
- package/dist/node/compiler/get-vite-config.js +200 -0
- package/dist/node/compiler/vinxi-app.d.ts +20 -0
- package/dist/node/compiler/vinxi-app.js +186 -0
- package/dist/node/compiler/vinxi-codegen.d.ts +12 -0
- package/dist/node/compiler/vinxi-codegen.js +515 -0
- package/dist/node/graphql/graphql-codegen.d.ts +12 -2
- package/dist/node/graphql/graphql-codegen.js +213 -36
- package/dist/node/graphql/graphql-schema-loader.js +15 -18
- package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
- package/dist/node/graphql/query-files-loader.d.ts +3 -0
- package/dist/node/graphql/query-files-loader.js +5 -0
- package/dist/node/project/config.d.ts +31 -37
- package/dist/node/project/config.js +13 -11
- package/dist/node/project/env.d.ts +1 -1
- package/dist/node/project/env.js +1 -1
- package/dist/node/project/manifest/block-manifest.js +3 -2
- package/dist/node/project/manifest/manifest.d.ts +2 -1
- package/dist/node/project/manifest/manifest.js +15 -11
- package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
- package/dist/node/project/manifest/routes-manifest.js +74 -0
- package/dist/node/project/manifest/view-manifest.js +2 -2
- package/dist/node/project/project.d.ts +5 -2
- package/dist/node/project/project.js +21 -20
- package/dist/node/project/wp-info.js +3 -2
- package/dist/node/types/block-type.d.ts +5 -0
- package/dist/node/types/block-type.js +1 -0
- package/dist/node/types/view-type.js +3 -4
- package/dist/node/utils/fs-codegen.d.ts +42 -0
- package/dist/node/utils/fs-codegen.js +98 -0
- package/dist/node/utils/fs.js +2 -0
- package/dist/node/utils/{selfSignedCert.js → self-signed-cert.js} +1 -1
- package/dist/node/utils/{statefulLog.js → stateful-log.js} +1 -1
- package/dist/node/utils/watch-file-tree.d.ts +25 -0
- package/dist/node/utils/{watchFileTree.js → watch-file-tree.js} +12 -5
- package/package.json +39 -32
- package/types.app.d.ts +4 -2
- package/types.app.internal.d.ts +2 -2
- package/types.node.d.ts +3 -3
- package/dist/app/entry/Root.d.ts +0 -1
- package/dist/app/entry/Root.js +0 -9
- package/dist/app/entry/main.admin.d.ts +0 -3
- package/dist/app/entry/main.admin.js +0 -10
- package/dist/app/entry/main.frontend.spa.d.ts +0 -3
- package/dist/app/entry/main.frontend.spa.js +0 -13
- package/dist/app/entry/main.frontend.ssr.d.ts +0 -21
- package/dist/app/entry/main.frontend.ssr.js +0 -79
- package/dist/app/entry/main.serverless.dev.d.ts +0 -4
- package/dist/app/entry/main.serverless.dev.js +0 -21
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
- package/dist/app/lib/hooks/apiConfig.js +0 -4
- package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
- package/dist/app/lib/hooks/usePageLoad.js +0 -5
- package/dist/app/server/create-api-builtin-hono.d.ts +0 -8
- package/dist/app/server/create-api-builtin-hono.js +0 -80
- package/dist/app/server/create-ssr-hono.d.ts +0 -18
- package/dist/app/server/create-ssr-hono.js +0 -104
- package/dist/app/server/utils/index.html.d.ts +0 -2
- package/dist/app/server/utils/index.html.js +0 -14
- package/dist/node/compiler/index.html.d.ts +0 -2
- package/dist/node/compiler/index.html.js +0 -15
- package/dist/node/compiler/serverless.dev.js +0 -222
- package/dist/node/compiler/vite/get-vite-config.d.ts +0 -13
- package/dist/node/compiler/vite/get-vite-config.js +0 -315
- package/dist/node/compiler/vite/plugin-admin.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-admin.js +0 -67
- package/dist/node/compiler/vite/plugin-blocks.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-blocks.js +0 -73
- package/dist/node/compiler/vite/plugin-entry.d.ts +0 -6
- package/dist/node/compiler/vite/plugin-entry.js +0 -16
- package/dist/node/compiler/vite/plugin-resolved-tailwind.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-resolved-tailwind.js +0 -29
- package/dist/node/compiler/vite/plugin-theme.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-theme.js +0 -40
- package/dist/node/compiler/vite/plugin-views.d.ts +0 -4
- package/dist/node/compiler/vite/plugin-views.js +0 -51
- package/dist/node/utils/console.d.ts +0 -21
- package/dist/node/utils/console.js +0 -28
- package/dist/node/utils/unsafe-fetch.d.ts +0 -2
- package/dist/node/utils/unsafe-fetch.js +0 -19
- package/dist/node/utils/watchFileTree.d.ts +0 -11
- package/tsup.config.ts +0 -40
- package/types.manifests.d.ts +0 -22
- /package/dist/node/utils/{formatZodError.d.ts → format-zod-error.d.ts} +0 -0
- /package/dist/node/utils/{formatZodError.js → format-zod-error.js} +0 -0
- /package/dist/node/utils/{getRepoInfo.d.ts → get-repo-info.d.ts} +0 -0
- /package/dist/node/utils/{getRepoInfo.js → get-repo-info.js} +0 -0
- /package/dist/node/utils/{highlightCode.d.ts → highlight-code.d.ts} +0 -0
- /package/dist/node/utils/{highlightCode.js → highlight-code.js} +0 -0
- /package/dist/node/utils/{isDeploying.d.ts → is-deploying.d.ts} +0 -0
- /package/dist/node/utils/{isDeploying.js → is-deploying.js} +0 -0
- /package/dist/node/utils/{selfSignedCert.d.ts → self-signed-cert.d.ts} +0 -0
- /package/dist/node/utils/{statefulLog.d.ts → stateful-log.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.d.ts → ts-export-extractor.d.ts} +0 -0
- /package/dist/node/utils/{export-extractor.js → ts-export-extractor.js} +0 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AnyProcedure } from "@trpc/server";
|
|
2
|
+
import { FetchCreateContextFnOptions } from "@trpc/server/adapters/fetch";
|
|
3
|
+
export declare const rpcApi: {
|
|
4
|
+
_config: import("@trpc/server/unstable-core-do-not-import").RootConfig<{
|
|
5
|
+
ctx: RPCContext;
|
|
6
|
+
meta: object;
|
|
7
|
+
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
8
|
+
transformer: true;
|
|
9
|
+
}>;
|
|
10
|
+
procedure: import("@trpc/server/unstable-core-do-not-import").ProcedureBuilder<RPCContext, object, object, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, false>;
|
|
11
|
+
middleware: <$ContextOverrides>(fn: import("@trpc/server/unstable-core-do-not-import").MiddlewareFunction<RPCContext, object, object, $ContextOverrides, unknown>) => import("@trpc/server/unstable-core-do-not-import").MiddlewareBuilder<RPCContext, object, $ContextOverrides, unknown>;
|
|
12
|
+
router: {
|
|
13
|
+
<TInput extends import("@trpc/server").RouterRecord>(input: TInput): import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{
|
|
14
|
+
ctx: RPCContext;
|
|
15
|
+
meta: object;
|
|
16
|
+
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
17
|
+
transformer: true;
|
|
18
|
+
}, TInput>;
|
|
19
|
+
<TInput extends import("@trpc/server/unstable-core-do-not-import").CreateRouterOptions>(input: TInput): import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{
|
|
20
|
+
ctx: RPCContext;
|
|
21
|
+
meta: object;
|
|
22
|
+
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
23
|
+
transformer: true;
|
|
24
|
+
}, import("@trpc/server/unstable-core-do-not-import").DecorateCreateRouterOptions<TInput>>;
|
|
25
|
+
};
|
|
26
|
+
mergeRouters: typeof import("@trpc/server/unstable-core-do-not-import").mergeRouters;
|
|
27
|
+
createCallerFactory: <TRecord extends import("@trpc/server").RouterRecord>(router: Pick<import("@trpc/server/unstable-core-do-not-import").Router<{
|
|
28
|
+
ctx: RPCContext;
|
|
29
|
+
meta: object;
|
|
30
|
+
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
31
|
+
transformer: true;
|
|
32
|
+
}, TRecord>, "_def">) => import("@trpc/server/unstable-core-do-not-import").RouterCaller<{
|
|
33
|
+
ctx: RPCContext;
|
|
34
|
+
meta: object;
|
|
35
|
+
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
36
|
+
transformer: true;
|
|
37
|
+
}, TRecord>;
|
|
38
|
+
};
|
|
39
|
+
type RouterSchema = Record<string, Record<string, AnyProcedure> | AnyProcedure>;
|
|
40
|
+
export declare const rpc: {
|
|
41
|
+
middleware: <$ContextOverrides>(fn: import("@trpc/server/unstable-core-do-not-import").MiddlewareFunction<RPCContext, object, object, $ContextOverrides, unknown>) => import("@trpc/server/unstable-core-do-not-import").MiddlewareBuilder<RPCContext, object, $ContextOverrides, unknown>;
|
|
42
|
+
procedure: import("@trpc/server/unstable-core-do-not-import").ProcedureBuilder<RPCContext, object, object, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, typeof import("@trpc/server/unstable-core-do-not-import").unsetMarker, false>;
|
|
43
|
+
router<T extends RouterSchema>(routes: T): T;
|
|
44
|
+
};
|
|
45
|
+
export declare function defineServerContext<T>(func: (opts: FetchCreateContextFnOptions) => T): (opts: FetchCreateContextFnOptions) => T;
|
|
46
|
+
export declare function instantiateRouter<T extends RouterSchema>(routes: T): import("@trpc/server/unstable-core-do-not-import").BuiltRouter<{
|
|
47
|
+
ctx: RPCContext;
|
|
48
|
+
meta: object;
|
|
49
|
+
errorShape: import("@trpc/server/unstable-core-do-not-import").DefaultErrorShape;
|
|
50
|
+
transformer: true;
|
|
51
|
+
}, T>;
|
|
52
|
+
export type InferRPCServerContext<TFunc extends null | ((opts: FetchCreateContextFnOptions) => any)> = {
|
|
53
|
+
req: Request;
|
|
54
|
+
resHeaders: Headers;
|
|
55
|
+
} & (TFunc extends (opts: FetchCreateContextFnOptions) => infer T ? T : {});
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { initTRPC } from "@trpc/server";
|
|
2
|
+
import superjson from "superjson";
|
|
3
|
+
export const rpcApi = initTRPC.context().create({
|
|
4
|
+
transformer: superjson,
|
|
5
|
+
});
|
|
6
|
+
export const rpc = {
|
|
7
|
+
middleware: rpcApi.middleware,
|
|
8
|
+
procedure: rpcApi.procedure,
|
|
9
|
+
router(routes) {
|
|
10
|
+
return routes;
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export function defineServerContext(func) {
|
|
14
|
+
return func;
|
|
15
|
+
}
|
|
16
|
+
export function instantiateRouter(routes) {
|
|
17
|
+
return rpcApi.router(routes);
|
|
18
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { RequestHeaders } from "vinxi/http";
|
|
2
|
+
import { UrlReplacerConf } from "./utils/replace-host.js";
|
|
3
|
+
import { Manifest } from "vinxi/dist/types/types/manifest";
|
|
4
|
+
import { TrackerTags } from "../lib/routing/types.js";
|
|
5
|
+
export type ServerContextArgs = {
|
|
6
|
+
dev: boolean;
|
|
7
|
+
origin: string;
|
|
8
|
+
replaceUrls?: UrlReplacerConf;
|
|
9
|
+
rpcBases?: string[];
|
|
10
|
+
};
|
|
11
|
+
export type ServerContextRuntime = {
|
|
12
|
+
getManifest: (name: string) => Manifest;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Data returned from WordPress origin /_appdata route
|
|
16
|
+
*/
|
|
17
|
+
type ServerAppData = {
|
|
18
|
+
appData: any;
|
|
19
|
+
trackers: TrackerTags;
|
|
20
|
+
};
|
|
21
|
+
export declare class ServerContext {
|
|
22
|
+
dev: boolean;
|
|
23
|
+
origin: string;
|
|
24
|
+
replaceUrls?: (text: string) => string;
|
|
25
|
+
rpcBases: string[];
|
|
26
|
+
static main: ServerContext;
|
|
27
|
+
constructor(conf: ServerContextArgs);
|
|
28
|
+
get runtime(): ServerContextRuntime;
|
|
29
|
+
static setRuntime(rt: ServerContextRuntime): void;
|
|
30
|
+
getOriginUrl(url: string): string;
|
|
31
|
+
fetchOrigin(url: string, opts?: RequestInit & {
|
|
32
|
+
replaceUrls?: boolean;
|
|
33
|
+
}): Promise<Response>;
|
|
34
|
+
fetchRouteData(req: {
|
|
35
|
+
pathname: string;
|
|
36
|
+
query?: Record<string, any>;
|
|
37
|
+
headers?: RequestHeaders;
|
|
38
|
+
withAppData?: boolean;
|
|
39
|
+
}): Promise<Response>;
|
|
40
|
+
fetchAppData(): Promise<ServerAppData>;
|
|
41
|
+
extractRequestHeaders(req?: RequestHeaders): Partial<Record<import("vinxi/http").HTTPHeaderName, string | undefined>>;
|
|
42
|
+
fetchNamedQuery(req: {
|
|
43
|
+
name: string;
|
|
44
|
+
params: object;
|
|
45
|
+
headers: RequestHeaders;
|
|
46
|
+
}): Promise<Response>;
|
|
47
|
+
fetchMutation(req: {
|
|
48
|
+
name: string;
|
|
49
|
+
body: object;
|
|
50
|
+
headers: RequestHeaders;
|
|
51
|
+
}): Promise<Response>;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { parseURL, stringifyParsedURL, withQuery } from "ufo";
|
|
2
|
+
import { filterHeader } from "./utils/headers.js";
|
|
3
|
+
import { createUrlReplacer } from "./utils/replace-host.js";
|
|
4
|
+
const PROXY_RESPONSE_HEADERS = ["content-type", "set-cookie", /^x-/, "cache-control", /woocommerce/];
|
|
5
|
+
const PROXY_REQUEST_HEADERS = [
|
|
6
|
+
"content-type",
|
|
7
|
+
"accept",
|
|
8
|
+
"accept-encoding",
|
|
9
|
+
"accept-language",
|
|
10
|
+
"origin",
|
|
11
|
+
"referer",
|
|
12
|
+
"user-agent",
|
|
13
|
+
"authorization",
|
|
14
|
+
"woocommerce-session",
|
|
15
|
+
];
|
|
16
|
+
let runtime;
|
|
17
|
+
export class ServerContext {
|
|
18
|
+
dev;
|
|
19
|
+
origin;
|
|
20
|
+
replaceUrls;
|
|
21
|
+
rpcBases = [];
|
|
22
|
+
static main;
|
|
23
|
+
constructor(conf) {
|
|
24
|
+
this.dev = conf.dev;
|
|
25
|
+
this.origin = conf.origin;
|
|
26
|
+
this.rpcBases = conf.rpcBases ?? [];
|
|
27
|
+
if (conf.replaceUrls) {
|
|
28
|
+
this.replaceUrls = createUrlReplacer(conf.replaceUrls);
|
|
29
|
+
}
|
|
30
|
+
ServerContext.main = this;
|
|
31
|
+
}
|
|
32
|
+
get runtime() {
|
|
33
|
+
return runtime;
|
|
34
|
+
}
|
|
35
|
+
static setRuntime(rt) {
|
|
36
|
+
runtime = rt;
|
|
37
|
+
}
|
|
38
|
+
getOriginUrl(url) {
|
|
39
|
+
const parsed = parseURL(url);
|
|
40
|
+
const parsedOrigin = parseURL(this.origin);
|
|
41
|
+
parsed.host = parsedOrigin.host;
|
|
42
|
+
parsed.protocol = parsedOrigin.protocol;
|
|
43
|
+
return stringifyParsedURL(parsed);
|
|
44
|
+
}
|
|
45
|
+
async fetchOrigin(url, opts) {
|
|
46
|
+
url = this.getOriginUrl(url);
|
|
47
|
+
const response = await fetch(url, {
|
|
48
|
+
...opts,
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/json",
|
|
51
|
+
Accept: "application/json",
|
|
52
|
+
...opts?.headers,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
// console.log("Response headers", response.headers)
|
|
59
|
+
const headers = {};
|
|
60
|
+
response.headers.forEach((value, key) => {
|
|
61
|
+
if (filterHeader(key, PROXY_RESPONSE_HEADERS)) {
|
|
62
|
+
headers[key] = value;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// console.log("Returning headers", headers)
|
|
66
|
+
let text = await response.text();
|
|
67
|
+
if (opts?.replaceUrls && this.replaceUrls) {
|
|
68
|
+
text = this.replaceUrls(text);
|
|
69
|
+
}
|
|
70
|
+
return new Response(text, {
|
|
71
|
+
status: response.status,
|
|
72
|
+
statusText: response.statusText,
|
|
73
|
+
headers,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async fetchRouteData(req) {
|
|
77
|
+
const fetchUrl = withQuery(req.pathname, {
|
|
78
|
+
...req.query,
|
|
79
|
+
_props: "1",
|
|
80
|
+
_ssr: "1",
|
|
81
|
+
_debug: this.dev ? "1" : undefined,
|
|
82
|
+
});
|
|
83
|
+
// console.log("Fetching route data", req.pathname)
|
|
84
|
+
const result = this.fetchOrigin(fetchUrl, {
|
|
85
|
+
cache: "no-cache",
|
|
86
|
+
replaceUrls: true,
|
|
87
|
+
headers: {
|
|
88
|
+
"Content-Type": "application/json",
|
|
89
|
+
Accept: "application/json",
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
// console.log("Finished fetching route data")
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
async fetchAppData() {
|
|
96
|
+
// console.log("Fetching app data")
|
|
97
|
+
const response = await this.fetchOrigin("/_appdata", {
|
|
98
|
+
cache: "no-cache",
|
|
99
|
+
replaceUrls: true,
|
|
100
|
+
headers: {
|
|
101
|
+
"Content-Type": "application/json",
|
|
102
|
+
Accept: "application/json",
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
// console.log("Decoding app data")
|
|
106
|
+
const result = await response.json();
|
|
107
|
+
// console.log("Done with app done")
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
extractRequestHeaders(req) {
|
|
111
|
+
const headers = {};
|
|
112
|
+
if (req) {
|
|
113
|
+
for (let key of PROXY_REQUEST_HEADERS) {
|
|
114
|
+
if (req[key]) {
|
|
115
|
+
headers[key] = req[key];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return headers;
|
|
120
|
+
}
|
|
121
|
+
async fetchNamedQuery(req) {
|
|
122
|
+
const url = `/wp-json/ed/v1/query/${req.name}?params=${encodeURIComponent(JSON.stringify(req.params))}`;
|
|
123
|
+
return this.fetchOrigin(url, {
|
|
124
|
+
cache: "no-cache",
|
|
125
|
+
replaceUrls: true,
|
|
126
|
+
headers: {
|
|
127
|
+
...this.extractRequestHeaders(req.headers),
|
|
128
|
+
"Content-Type": "application/json",
|
|
129
|
+
Accept: "application/json",
|
|
130
|
+
},
|
|
131
|
+
redirect: "manual",
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
async fetchMutation(req) {
|
|
135
|
+
const url = `/wp-json/ed/v1/mutation/${req.name}`;
|
|
136
|
+
return this.fetchOrigin(url, {
|
|
137
|
+
method: "POST",
|
|
138
|
+
cache: "no-cache",
|
|
139
|
+
replaceUrls: true,
|
|
140
|
+
headers: {
|
|
141
|
+
...this.extractRequestHeaders(req.headers),
|
|
142
|
+
"Content-Type": "application/json",
|
|
143
|
+
Accept: "application/json",
|
|
144
|
+
},
|
|
145
|
+
body: JSON.stringify(req.body),
|
|
146
|
+
redirect: "manual",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -9,3 +9,20 @@ export function filterHeader(key, allowed) {
|
|
|
9
9
|
export const BRANDED_HEADERS = {
|
|
10
10
|
"X-Powered-By": "ed.studio",
|
|
11
11
|
};
|
|
12
|
+
const IGNORE_REQUEST_HEADERS = [
|
|
13
|
+
"host",
|
|
14
|
+
"connection",
|
|
15
|
+
"accept-encoding",
|
|
16
|
+
"accept-language",
|
|
17
|
+
"origin",
|
|
18
|
+
"referer",
|
|
19
|
+
"user-agent",
|
|
20
|
+
];
|
|
21
|
+
export function extractHeaders(rawHeaders) {
|
|
22
|
+
const headers = {};
|
|
23
|
+
rawHeaders.forEach((value, key) => {
|
|
24
|
+
headers[key] = value;
|
|
25
|
+
});
|
|
26
|
+
IGNORE_REQUEST_HEADERS.forEach((key) => delete headers[key]);
|
|
27
|
+
return headers;
|
|
28
|
+
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export type UrlReplacerConf = {
|
|
2
2
|
from: string;
|
|
3
3
|
to: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/** A dictionary of prefixes (eg /wp-content), and whether to replace them (true/false) */
|
|
5
|
+
prefixes: {
|
|
6
|
+
prefix: string;
|
|
7
|
+
replace: boolean;
|
|
8
|
+
}[];
|
|
7
9
|
};
|
|
8
|
-
export declare function createUrlReplacer(conf: UrlReplacerConf): (
|
|
10
|
+
export declare function createUrlReplacer(conf: UrlReplacerConf): (text: string) => string;
|
|
@@ -1,14 +1,61 @@
|
|
|
1
1
|
export function createUrlReplacer(conf) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
// Create a regular expression to match the URL
|
|
3
|
+
// Note that that the regex doesn't necessarily match the entire URL
|
|
4
|
+
const lookup = new RegExp(conf.from.replace(/https?[:\\\/]+/, "https?[:\\/\\\\]+") + "([a-z0-9\\-_/\\\\]+)", "ig");
|
|
5
|
+
return (text) => {
|
|
6
|
+
return text.replace(lookup, (url) => {
|
|
7
|
+
// Strip out the origin, to create a relative path
|
|
8
|
+
const path = url.replace(/https?:[\/\\]+[^\/\\]+/, "");
|
|
9
|
+
const isEscaped = url.includes(":\\/\\/");
|
|
10
|
+
const key = "/" +
|
|
11
|
+
path
|
|
12
|
+
.split(/[\/\\]+/g)
|
|
13
|
+
.filter((v) => v)
|
|
14
|
+
.join("/");
|
|
15
|
+
for (let item of conf.prefixes) {
|
|
16
|
+
if (key.startsWith(item.prefix)) {
|
|
17
|
+
if (item.replace) {
|
|
18
|
+
return url;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return path;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return path;
|
|
26
|
+
// if (path.startsWith("/wp-content/uploads/")) {
|
|
27
|
+
// if (!conf.ignoreUploads) {
|
|
28
|
+
// return path
|
|
29
|
+
// } else {
|
|
30
|
+
// return url
|
|
31
|
+
// }
|
|
32
|
+
// // } else if (path.startsWith("/wp-content/themes/")) {
|
|
33
|
+
// // if (settings?.uploads === "proxy") {
|
|
34
|
+
// // return path
|
|
35
|
+
// // } else if (settings?.uploads === "remote") {
|
|
36
|
+
// // return url
|
|
37
|
+
// // }
|
|
38
|
+
// // } else if (path.startsWith("/wp-content/plugins/")) {
|
|
39
|
+
// // if (settings?.uploads === "proxy") {
|
|
40
|
+
// // return path
|
|
41
|
+
// // } else if (settings?.uploads === "remote") {
|
|
42
|
+
// // return url
|
|
43
|
+
// // }
|
|
44
|
+
// } else {
|
|
45
|
+
// return path
|
|
46
|
+
// }
|
|
47
|
+
});
|
|
13
48
|
};
|
|
49
|
+
// const from = conf.from
|
|
50
|
+
// const to = conf.to
|
|
51
|
+
// const https = conf.https
|
|
52
|
+
// const ignoreUploads = conf.ignoreUploads
|
|
53
|
+
// const ignorePlugins = conf.ignorePlugins
|
|
54
|
+
// const replaceTargetString = from.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\/")
|
|
55
|
+
// const replaceTargetEscapedString = from.replaceAll(/https?:/g, "https?:").replaceAll("/", "\\\\/")
|
|
56
|
+
// const replaceTarget = new RegExp(replaceTargetString, "g")
|
|
57
|
+
// const replaceTargetEscaped = new RegExp(replaceTargetEscapedString, "g")
|
|
58
|
+
// return (value: string) => {
|
|
59
|
+
// return value.replaceAll(replaceTarget, to).replace(replaceTargetEscaped, to.replaceAll("/", "\\/"))
|
|
60
|
+
// }
|
|
14
61
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component, ErrorInfo, ReactNode } from "react";
|
|
2
|
+
import { BlocksContext, ContentBlock } from "../lib/blocks/ContentBlocks.js";
|
|
3
|
+
interface Props {
|
|
4
|
+
block: ContentBlock;
|
|
5
|
+
blockContext: BlocksContext;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
interface State {
|
|
9
|
+
hasError: boolean;
|
|
10
|
+
error?: Error;
|
|
11
|
+
errorInfo?: ErrorInfo;
|
|
12
|
+
}
|
|
13
|
+
export declare class BlockErrorBoundary extends Component<Props, State> {
|
|
14
|
+
state: State;
|
|
15
|
+
static getDerivedStateFromError(error: Error): State;
|
|
16
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
17
|
+
render(): ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
import { errorHandling } from "../lib/runtime/errorHandling.js";
|
|
4
|
+
import { ErrorMessage } from "./ErrorMessage.js";
|
|
5
|
+
export class BlockErrorBoundary extends Component {
|
|
6
|
+
state = {
|
|
7
|
+
hasError: false,
|
|
8
|
+
};
|
|
9
|
+
static getDerivedStateFromError(error) {
|
|
10
|
+
// Update state so the next render will show the fallback UI.
|
|
11
|
+
return { hasError: true, error: error };
|
|
12
|
+
}
|
|
13
|
+
componentDidCatch(error, errorInfo) {
|
|
14
|
+
if (errorHandling.onReactError) {
|
|
15
|
+
errorHandling.onReactError({
|
|
16
|
+
type: "block",
|
|
17
|
+
block: this.props.block,
|
|
18
|
+
error,
|
|
19
|
+
componentStack: errorInfo.componentStack,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
if (this.state.hasError) {
|
|
25
|
+
const err = this.state.error;
|
|
26
|
+
let display = env.dev ? _jsx(ErrorMessage, { error: err }) : null;
|
|
27
|
+
if (errorHandling.renderFallback) {
|
|
28
|
+
display = errorHandling.renderFallback({
|
|
29
|
+
type: "block",
|
|
30
|
+
block: this.props.block,
|
|
31
|
+
error: err,
|
|
32
|
+
}, display);
|
|
33
|
+
}
|
|
34
|
+
return display;
|
|
35
|
+
}
|
|
36
|
+
return this.props.children;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function ErrorMessage({ error }) {
|
|
3
|
+
return (_jsx("pre", { style: {
|
|
4
|
+
backgroundColor: "#060309",
|
|
5
|
+
fontSize: "12px",
|
|
6
|
+
color: "#d92a0b",
|
|
7
|
+
outline: "1px solid #d92a0b",
|
|
8
|
+
outlineOffset: "-4px",
|
|
9
|
+
borderRadius: "6px",
|
|
10
|
+
padding: "12px 16px",
|
|
11
|
+
overflowX: "auto",
|
|
12
|
+
fontFamily: '"Roboto Mono", Menlo, monospace',
|
|
13
|
+
}, children: error.stack ?? String(error) }));
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component, ErrorInfo, ReactNode } from "react";
|
|
2
|
+
import { RouteState } from "../lib/routing/types.js";
|
|
3
|
+
interface Props {
|
|
4
|
+
route: RouteState;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
interface State {
|
|
8
|
+
hasError: boolean;
|
|
9
|
+
error?: Error;
|
|
10
|
+
errorInfo?: ErrorInfo;
|
|
11
|
+
}
|
|
12
|
+
export declare class RouteErrorBoundary extends Component<Props, State> {
|
|
13
|
+
state: State;
|
|
14
|
+
static getDerivedStateFromError(error: Error): State;
|
|
15
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
16
|
+
render(): ReactNode;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
import { errorHandling } from "../lib/runtime/errorHandling.js";
|
|
4
|
+
import { ErrorMessage } from "./ErrorMessage.js";
|
|
5
|
+
export class RouteErrorBoundary extends Component {
|
|
6
|
+
state = {
|
|
7
|
+
hasError: false,
|
|
8
|
+
};
|
|
9
|
+
static getDerivedStateFromError(error) {
|
|
10
|
+
// Update state so the next render will show the fallback UI.
|
|
11
|
+
return { hasError: true, error: error };
|
|
12
|
+
}
|
|
13
|
+
componentDidCatch(error, errorInfo) {
|
|
14
|
+
if (errorHandling.onReactError) {
|
|
15
|
+
errorHandling.onReactError({
|
|
16
|
+
type: "route",
|
|
17
|
+
route: this.props.route,
|
|
18
|
+
error,
|
|
19
|
+
componentStack: errorInfo.componentStack,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
render() {
|
|
24
|
+
if (this.state.hasError) {
|
|
25
|
+
const err = this.state.error;
|
|
26
|
+
let display = env.dev ? _jsx(ErrorMessage, { error: err }) : null;
|
|
27
|
+
if (errorHandling.renderFallback) {
|
|
28
|
+
display = errorHandling.renderFallback({
|
|
29
|
+
type: "route",
|
|
30
|
+
route: this.props.route,
|
|
31
|
+
error: err,
|
|
32
|
+
}, display);
|
|
33
|
+
}
|
|
34
|
+
return display;
|
|
35
|
+
}
|
|
36
|
+
return this.props.children;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
|
|
2
3
|
let queryClient = null;
|
|
3
4
|
export function getQueryClient() {
|
|
4
5
|
if (!queryClient) {
|
|
@@ -14,3 +15,6 @@ export function getQueryClient() {
|
|
|
14
15
|
}
|
|
15
16
|
return queryClient;
|
|
16
17
|
}
|
|
18
|
+
export function QueryProvider(props) {
|
|
19
|
+
return _jsx(QueryClientProvider, { client: getQueryClient(), children: props.children });
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createTRPCUntypedClient, httpLink, splitLink, unstable_httpSubscriptionLink, } from "@trpc/client";
|
|
2
|
+
import SuperJSON from "superjson";
|
|
3
|
+
import { parseURL, stringifyParsedURL } from "ufo";
|
|
4
|
+
let client;
|
|
5
|
+
export function getRPCClient() {
|
|
6
|
+
if (env.rpcEnabled) {
|
|
7
|
+
if (!client) {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
const endpoint = env.serverless ? "/" : window.SERVERLESS_ENDPOINT ?? "/";
|
|
10
|
+
client = createTRPCUntypedClient({
|
|
11
|
+
links: [
|
|
12
|
+
splitLink({
|
|
13
|
+
// uses the httpSubscriptionLink for subscriptions
|
|
14
|
+
condition: (op) => op.type === "subscription",
|
|
15
|
+
true: unstable_httpSubscriptionLink({
|
|
16
|
+
url: endpoint,
|
|
17
|
+
transformer: SuperJSON,
|
|
18
|
+
}),
|
|
19
|
+
false: httpLink({
|
|
20
|
+
url: endpoint,
|
|
21
|
+
fetch: (input, init) => {
|
|
22
|
+
const parsed = parseURL(input);
|
|
23
|
+
parsed.pathname = "/" + parsed.pathname.replace(/(^\/|\/$)/g, "").replace(/\./g, "/") + "/";
|
|
24
|
+
return fetch(stringifyParsedURL(parsed), init);
|
|
25
|
+
},
|
|
26
|
+
transformer: SuperJSON,
|
|
27
|
+
}),
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return client;
|
|
34
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Worker } from "node:worker_threads";
|
|
2
|
-
import { StatefulLog } from "../utils/
|
|
2
|
+
import { StatefulLog } from "../utils/stateful-log.js";
|
|
3
3
|
type WorkerMode = "admin" | "frontend" | "graphql" | "serverless";
|
|
4
4
|
export declare class CLIWorker {
|
|
5
5
|
worker: Worker;
|
|
@@ -46,6 +46,8 @@ export class CLIWorker {
|
|
|
46
46
|
}
|
|
47
47
|
if (!isMainThread) {
|
|
48
48
|
const mode = workerData.mode;
|
|
49
|
+
/** Ignore self-signed certificate errors in dev mode */
|
|
50
|
+
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
|
|
49
51
|
configureCliMode({
|
|
50
52
|
interactive: true,
|
|
51
53
|
readonly: false,
|
|
@@ -84,24 +86,31 @@ if (!isMainThread) {
|
|
|
84
86
|
}
|
|
85
87
|
function pipeLog(log) {
|
|
86
88
|
log.subscribe((log) => {
|
|
89
|
+
// We ignore SSL errors in dev mode.
|
|
87
90
|
parentPort?.postMessage(JSON.stringify({ type: "log", log: serializeLogData(log) }));
|
|
88
91
|
});
|
|
89
92
|
}
|
|
90
93
|
if (mode === "admin") {
|
|
91
|
-
new AdminBundler(project, {
|
|
94
|
+
const bundler = new AdminBundler(project, {
|
|
92
95
|
mode: "development",
|
|
93
96
|
});
|
|
97
|
+
bundler.start();
|
|
94
98
|
pipeLog(adminLog);
|
|
95
99
|
}
|
|
96
100
|
else if (mode === "frontend") {
|
|
97
|
-
new FrontendBundler(project, {
|
|
101
|
+
const bundler = new FrontendBundler(project, {
|
|
98
102
|
mode: "development",
|
|
99
103
|
watch: true,
|
|
100
104
|
});
|
|
105
|
+
bundler.start();
|
|
101
106
|
pipeLog(frontendLog);
|
|
102
107
|
}
|
|
103
108
|
else if (mode === "graphql") {
|
|
104
|
-
const codegen = new GraphQLGenerator(project
|
|
109
|
+
const codegen = new GraphQLGenerator(project, {
|
|
110
|
+
generate: true,
|
|
111
|
+
optimize: true,
|
|
112
|
+
watch: true,
|
|
113
|
+
});
|
|
105
114
|
codegen.start();
|
|
106
115
|
pipeLog(graphqlLog);
|
|
107
116
|
}
|