@evjs/create-app 0.1.0 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evjs/create-app",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Scaffold a new evjs project",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-api-routes",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-basic",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-complex-routing",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-custom-ws-transport",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-mpa",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,21 +1,27 @@
1
- import { utoopack } from "@evjs/bundler-utoopack";
1
+ import { merge, utoopack } from "@evjs/bundler-utoopack";
2
2
  import { defineConfig } from "@evjs/ev";
3
3
 
4
4
  /**
5
5
  * Example: evjs plugin system.
6
6
  *
7
7
  * Demonstrates all available plugin hooks:
8
+ * - `config` — update framework config before defaults are resolved
8
9
  * - `bundlerConfig` — modify the underlying bundler config (type-safe via utoopack() helper)
9
10
  * - `buildStart` — run logic before compilation begins
10
11
  * - `buildEnd` — run logic after compilation completes
11
12
  * - `transformHtml` — modify the output HTML document after asset injection
12
13
  */
13
14
  export default defineConfig({
14
- server: false,
15
-
16
15
  plugins: [
17
16
  {
18
17
  name: "example-txt-plugin",
18
+ config(config) {
19
+ config.server = {
20
+ ...(typeof config.server === "object" ? config.server : {}),
21
+ endpoint: "/api/rpc",
22
+ };
23
+ return config;
24
+ },
19
25
  setup(ctx) {
20
26
  console.log(`[example-txt-plugin] mode: ${ctx.mode}`);
21
27
 
@@ -26,14 +32,12 @@ export default defineConfig({
26
32
 
27
33
  // Type-safe bundler config mutation via the utoopack helper.
28
34
  // This hook only runs when utoopack is the active bundler.
29
- bundlerConfig(config, ctx) {
30
- utoopack((cfg) => {
31
- // Add custom loaders or rules to utoopack
32
- cfg.module ??= {};
33
- cfg.module.rules ??= {};
34
- cfg.module.rules[".txt"] = { type: "raw" };
35
- })(config, ctx);
36
- },
35
+ bundlerConfig: utoopack((cfg) => {
36
+ // Add custom loaders or rules to utoopack
37
+ merge(cfg, {
38
+ module: { rules: { ".txt": { type: "raw" } } },
39
+ });
40
+ }),
37
41
 
38
42
  buildEnd(result) {
39
43
  console.log(
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-plugin-authoring",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -0,0 +1,8 @@
1
+ "use server";
2
+
3
+ export async function getPluginMessage() {
4
+ return {
5
+ message: "Plugin endpoint configured by config hook",
6
+ nodeEnv: process.env.NODE_ENV,
7
+ };
8
+ }
@@ -1,7 +1,10 @@
1
- import { createRoute } from "@evjs/client";
1
+ import { createRoute, useQuery } from "@evjs/client";
2
+ import { getPluginMessage } from "../api/plugin.server";
2
3
  import { rootRoute } from "./__root";
3
4
 
4
5
  function Home() {
6
+ const { data, isLoading } = useQuery(getPluginMessage);
7
+
5
8
  return (
6
9
  <div>
7
10
  <h1>Plugin Example</h1>
@@ -13,6 +16,15 @@ function Home() {
13
16
  View the page source to see the HTML comment injected by{" "}
14
17
  <code>transformHtml</code>.
15
18
  </p>
19
+ {isLoading ? (
20
+ <p>Loading plugin message...</p>
21
+ ) : (
22
+ <div>
23
+ <p>Server function: {data?.message}</p>
24
+ <p>Client mode: {process.env.NODE_ENV}</p>
25
+ <p>Server mode: {data?.nodeEnv}</p>
26
+ </div>
27
+ )}
16
28
  </div>
17
29
  );
18
30
  }
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-with-sqlite",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-with-tailwind",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-with-trpc",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "npx ev dev",
7
- "build": "npx ev build",
6
+ "dev": "ev dev",
7
+ "build": "ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,30 +1,26 @@
1
1
  "use server";
2
- import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
2
+ import { callTRPCProcedure } from "@trpc/server";
3
3
  import { appRouter } from "../trpc";
4
4
 
5
5
  /**
6
- * A Server Function that acts as a tRPC handler.
6
+ * A Server Function that dispatches into the tRPC router.
7
7
  * This demonstrates how to combine tRPC's type-safety with
8
8
  * @evjs's RPC infrastructure.
9
9
  */
10
- export async function trpcHandler(reqBody: unknown) {
11
- // We simulate a fetch request for tRPC
12
- const url = new URL("http://localhost/trpc");
13
-
14
- const response = await fetchRequestHandler({
15
- endpoint: "/trpc",
16
- req: new Request(url, {
17
- method: "POST",
18
- body: JSON.stringify(reqBody),
19
- headers: {
20
- "Content-Type": "application/json",
21
- },
22
- }),
10
+ export async function trpcHandler(op: {
11
+ path: string;
12
+ input: unknown;
13
+ type: "query" | "mutation" | "subscription";
14
+ }) {
15
+ return callTRPCProcedure({
23
16
  router: appRouter,
24
- createContext: () => ({}),
17
+ path: op.path,
18
+ type: op.type,
19
+ ctx: {},
20
+ getRawInput: async () => op.input,
21
+ signal: undefined,
22
+ batchIndex: 0,
25
23
  });
26
-
27
- return await response.json();
28
24
  }
29
25
 
30
26
  // standard server function examples
@@ -13,9 +13,9 @@ const serverFnLink = (): TRPCLink<AppRouter> => {
13
13
  return () => {
14
14
  return ({ op }) => {
15
15
  return observable((observer) => {
16
- trpcHandler(op)
17
- .then((res) => {
18
- observer.next({ result: { data: res.result.data } });
16
+ trpcHandler({ path: op.path, input: op.input, type: op.type })
17
+ .then((data) => {
18
+ observer.next({ result: { data } });
19
19
  observer.complete();
20
20
  })
21
21
  .catch((err) => {