noofpi 1.2.0 → 2.0.0
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/README.md +20 -4
- package/dist/{build-25H52PWT.js → build-PFCGDPPJ.js} +5 -4
- package/dist/chunk-3PSMWWUB.js +68 -0
- package/dist/{chunk-NALDZ3PS.js → chunk-I6TFIGFO.js} +13 -5
- package/dist/{chunk-NX6BO7UB.js → chunk-IE3WF5XF.js} +82 -2
- package/dist/{chunk-UF6YTIXD.js → chunk-LL3NO5EI.js} +361 -128
- package/dist/{chunk-FIJJ3EGL.js → chunk-MN5PVHC5.js} +4 -0
- package/dist/chunk-OKNF6XDO.js +14 -0
- package/dist/chunk-PPUFFGCH.js +168 -0
- package/dist/{chunk-WX2V6EYH.js → chunk-RUNIVVFH.js} +34 -10
- package/dist/{chunk-2XCZWFIQ.js → chunk-X3DYEZLK.js} +1 -1
- package/dist/{chunk-4YOOGEOF.js → chunk-YJVMBHNL.js} +1 -1
- package/dist/cli.js +130 -34
- package/dist/{dev-CC3RXV3G.js → dev-HTWUY27O.js} +47 -59
- package/dist/devtools-PLUN2DYV.js +958 -0
- package/dist/handler-C6NnwBfC.d.ts +17 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.js +2 -2
- package/dist/{validation-ClXd_DAW.d.ts → payload-CL6tYBin.d.ts} +2 -40
- package/dist/prepare-KKQ2AEBW.js +24 -0
- package/dist/runtime/default-app.d.ts +6 -0
- package/dist/runtime/entry-client.d.ts +3 -0
- package/dist/runtime/entry-client.js +12 -4
- package/dist/runtime/entry-server.d.ts +8 -0
- package/dist/runtime/entry-server.js +2 -2
- package/dist/runtime/index.d.ts +7 -8
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/routes.d.ts +13 -0
- package/dist/runtime/silent-diagnostics.d.ts +5 -0
- package/dist/server/bun.d.ts +15 -0
- package/dist/server/bun.js +14 -11
- package/dist/server/index.d.ts +9 -90
- package/dist/server/index.js +2 -2
- package/dist/server/node.d.ts +20 -0
- package/dist/server/node.js +2 -2
- package/dist/{start-PARBW5KN.js → start-AJKNZRJQ.js} +11 -7
- package/dist/typecheck-QACZZ6FN.js +30 -0
- package/dist/types-B6rQOOxS.d.ts +76 -0
- package/dist/validation-Dwpex2JZ.d.ts +40 -0
- package/package.json +22 -6
- package/dist/chunk-KGZP2RCF.js +0 -51
- package/dist/devtools-KTDSD5PR.js +0 -564
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ClientFetch } from 'doofpi';
|
|
2
|
+
import { h as ResolvedHead, F as FetchMode, H as HeadConfig, R as RouteRules, i as ResolvedSecurity } from './route-rules-COilNsVT.js';
|
|
3
|
+
import { b as CookieJar, P as PayloadData } from './payload-CL6tYBin.js';
|
|
4
|
+
|
|
5
|
+
declare const PROXY_PREFIX = "/_noofpi/proxy";
|
|
6
|
+
/** Server-side config (includes the remote `doofpi.url`, which is never sent to the browser for pfetch/sfetch) */
|
|
7
|
+
interface ServerConfig {
|
|
8
|
+
ssr: boolean;
|
|
9
|
+
doofpi: {
|
|
10
|
+
fetch: FetchMode;
|
|
11
|
+
url: string | undefined;
|
|
12
|
+
root: string;
|
|
13
|
+
};
|
|
14
|
+
head?: HeadConfig;
|
|
15
|
+
routeRules?: RouteRules;
|
|
16
|
+
security?: Partial<ResolvedSecurity>;
|
|
17
|
+
}
|
|
18
|
+
interface RenderContext {
|
|
19
|
+
origin: string;
|
|
20
|
+
cookie?: string;
|
|
21
|
+
/** The request's cookies; changes made while rendering are sent with the response */
|
|
22
|
+
cookies: CookieJar;
|
|
23
|
+
/** The request's `Accept-Language` header, for the `i18n` locale detection */
|
|
24
|
+
acceptLanguage?: string;
|
|
25
|
+
/** In-process fetch into the noofpi server (used for `lfetch` / `pfetch` during SSR) */
|
|
26
|
+
fetch: ClientFetch;
|
|
27
|
+
}
|
|
28
|
+
interface RenderResult {
|
|
29
|
+
html: string;
|
|
30
|
+
status: number;
|
|
31
|
+
/** Set when a route middleware redirected: the handler answers with a 302 to this path instead of HTML */
|
|
32
|
+
redirect?: string;
|
|
33
|
+
/** An unexpected error that was rendered as `app/error.vue` (status 500); the handler reports it like any server error */
|
|
34
|
+
error?: unknown;
|
|
35
|
+
/** Data gathered by `useAsyncData` while rendering, embedded in the page for the browser */
|
|
36
|
+
payload?: PayloadData;
|
|
37
|
+
/** Title, meta tags and attributes gathered by `useHead` while rendering, written into the HTML shell */
|
|
38
|
+
head?: ResolvedHead;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Optional `server/proxy.ts` default export. Mutate `headers` to change what is sent to the doofpi API
|
|
42
|
+
* (e.g. inject an `Authorization` token), or return a `Response` to short-circuit the request.
|
|
43
|
+
*/
|
|
44
|
+
type ProxyHook = (ctx: {
|
|
45
|
+
request: Request;
|
|
46
|
+
headers: Headers;
|
|
47
|
+
target: URL;
|
|
48
|
+
}) => void | Response | Promise<void | Response>;
|
|
49
|
+
interface DoofpiLike {
|
|
50
|
+
fetch(request: Request, env?: any, extra?: any): Promise<Response>;
|
|
51
|
+
}
|
|
52
|
+
interface ServerMiddlewareContext {
|
|
53
|
+
request: Request;
|
|
54
|
+
url: URL;
|
|
55
|
+
env?: unknown;
|
|
56
|
+
/** Read the request's cookies and set / remove cookies on the response (also when you return your own `Response`) */
|
|
57
|
+
cookies: CookieJar;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A `server/middleware/*.ts` default export. Runs around every request the noofpi server handles (pages, the doofpi
|
|
61
|
+
* API and the pfetch proxy). Call `next()` to continue and optionally change its response, or return your own
|
|
62
|
+
* `Response` without calling it to short-circuit. Always returns a `Response`.
|
|
63
|
+
*/
|
|
64
|
+
type ServerMiddleware = (ctx: ServerMiddlewareContext, next: () => Promise<Response>) => Response | Promise<Response>;
|
|
65
|
+
/** Shape of the generated `virtual:noofpi/server` module */
|
|
66
|
+
interface ServerModule {
|
|
67
|
+
config: ServerConfig;
|
|
68
|
+
doofpi?: DoofpiLike;
|
|
69
|
+
proxyHook?: ProxyHook;
|
|
70
|
+
/** `server/middleware/*` in file-name order, outermost first */
|
|
71
|
+
middleware?: ServerMiddleware[];
|
|
72
|
+
render?: (url: string, ctx: RenderContext) => Promise<RenderResult>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { PROXY_PREFIX as b };
|
|
76
|
+
export type { ProxyHook as P, RenderContext as R, ServerMiddleware as S, RenderResult as a, ServerConfig as c, ServerMiddlewareContext as d, ServerModule as e };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** The part of a Zod issue that noofpi reads; doofpi's `issues` and `schema.safeParse()` errors satisfy it */
|
|
2
|
+
interface ValidationIssue {
|
|
3
|
+
path: readonly PropertyKey[];
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
/** Messages by field path (`"user.email"`, `"tags.0"`). Issues about the whole value are under {@link FORM_ERROR_KEY} */
|
|
7
|
+
type FormErrors = Record<string, string[]>;
|
|
8
|
+
declare const FORM_ERROR_KEY = "";
|
|
9
|
+
/** Any schema with a Zod-style `safeParse` (Zod 3 and 4) */
|
|
10
|
+
interface FormSchema<T> {
|
|
11
|
+
safeParse(value: unknown): {
|
|
12
|
+
success: true;
|
|
13
|
+
data: T;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
error: {
|
|
17
|
+
issues: readonly ValidationIssue[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
type InferSchema<S> = S extends FormSchema<infer T> ? T : never;
|
|
22
|
+
type ValidationResult<T> = {
|
|
23
|
+
ok: true;
|
|
24
|
+
data: T;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
errors: FormErrors;
|
|
28
|
+
};
|
|
29
|
+
/** Groups issues by field path, the same shape on the server and in the browser */
|
|
30
|
+
declare function issuesToErrors(issues: readonly ValidationIssue[] | undefined): FormErrors;
|
|
31
|
+
/** Validates with the schema shared by the server endpoint and the form */
|
|
32
|
+
declare function validate<T>(schema: FormSchema<T>, value: unknown): ValidationResult<T>;
|
|
33
|
+
/**
|
|
34
|
+
* The field errors of a doofpi input validation failure (a `DoofpiClientError` with status 400 and `issues`), or
|
|
35
|
+
* `undefined` for any other failure
|
|
36
|
+
*/
|
|
37
|
+
declare function errorsFromFailure(failure: unknown): FormErrors | undefined;
|
|
38
|
+
|
|
39
|
+
export { FORM_ERROR_KEY as b, errorsFromFailure as e, issuesToErrors as i, validate as v };
|
|
40
|
+
export type { FormErrors as F, InferSchema as I, ValidationIssue as V, FormSchema as a, ValidationResult as c };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "noofpi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A minimal Vue + Vite full-stack framework built around doofpi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lior Cohen",
|
|
@@ -50,9 +50,11 @@
|
|
|
50
50
|
"default": "./dist/server/index.js"
|
|
51
51
|
},
|
|
52
52
|
"./server/node": {
|
|
53
|
+
"types": "./dist/server/node.d.ts",
|
|
53
54
|
"default": "./dist/server/node.js"
|
|
54
55
|
},
|
|
55
56
|
"./server/bun": {
|
|
57
|
+
"types": "./dist/server/bun.d.ts",
|
|
56
58
|
"default": "./dist/server/bun.js"
|
|
57
59
|
},
|
|
58
60
|
"./client": {
|
|
@@ -77,23 +79,37 @@
|
|
|
77
79
|
"prepublishOnly": "bun run build && bun run test"
|
|
78
80
|
},
|
|
79
81
|
"dependencies": {
|
|
80
|
-
"@tailwindcss/vite": "^4.3.5",
|
|
81
82
|
"@vitejs/plugin-vue": "^6.0.11",
|
|
82
83
|
"jiti": "^2.7.0",
|
|
83
|
-
"sharp": "^0.35.5",
|
|
84
|
-
"tailwindcss": "^4.3.5",
|
|
85
84
|
"unplugin-auto-import": "^21.1.0",
|
|
86
85
|
"unplugin-vue-components": "^32.1.0",
|
|
87
86
|
"vite": "^8.3.8",
|
|
88
|
-
"vue": "^3.5.
|
|
87
|
+
"vue": "^3.5.46",
|
|
89
88
|
"vue-router": "^5.5.1"
|
|
90
89
|
},
|
|
91
90
|
"peerDependencies": {
|
|
92
|
-
"
|
|
91
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
92
|
+
"doofpi": ">=1.3.1",
|
|
93
|
+
"sharp": ">=0.33.0",
|
|
94
|
+
"tailwindcss": "^4.0.0"
|
|
95
|
+
},
|
|
96
|
+
"peerDependenciesMeta": {
|
|
97
|
+
"@tailwindcss/vite": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"sharp": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"tailwindcss": {
|
|
104
|
+
"optional": true
|
|
105
|
+
}
|
|
93
106
|
},
|
|
94
107
|
"devDependencies": {
|
|
108
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
95
109
|
"@types/node": "^24.19.2",
|
|
96
110
|
"doofpi": "^1.3.1",
|
|
111
|
+
"sharp": "^0.35.5",
|
|
112
|
+
"tailwindcss": "^4.3.5",
|
|
97
113
|
"zod": "^4.6.7",
|
|
98
114
|
"prettier": "^3.10.1",
|
|
99
115
|
"tsup": "^9.0.0",
|
package/dist/chunk-KGZP2RCF.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// src/server/static.ts
|
|
2
|
-
import { stat } from "fs/promises";
|
|
3
|
-
import path from "path";
|
|
4
|
-
var MIME = {
|
|
5
|
-
".html": "text/html; charset=utf-8",
|
|
6
|
-
".js": "text/javascript; charset=utf-8",
|
|
7
|
-
".mjs": "text/javascript; charset=utf-8",
|
|
8
|
-
".css": "text/css; charset=utf-8",
|
|
9
|
-
".json": "application/json; charset=utf-8",
|
|
10
|
-
".svg": "image/svg+xml",
|
|
11
|
-
".png": "image/png",
|
|
12
|
-
".jpg": "image/jpeg",
|
|
13
|
-
".jpeg": "image/jpeg",
|
|
14
|
-
".gif": "image/gif",
|
|
15
|
-
".webp": "image/webp",
|
|
16
|
-
".avif": "image/avif",
|
|
17
|
-
".ico": "image/x-icon",
|
|
18
|
-
".woff": "font/woff",
|
|
19
|
-
".woff2": "font/woff2",
|
|
20
|
-
".txt": "text/plain; charset=utf-8",
|
|
21
|
-
".map": "application/json"
|
|
22
|
-
};
|
|
23
|
-
async function resolveStaticFile(dir, method, rawPath) {
|
|
24
|
-
if (method !== "GET" && method !== "HEAD") return null;
|
|
25
|
-
let pathname;
|
|
26
|
-
try {
|
|
27
|
-
pathname = decodeURIComponent(
|
|
28
|
-
new URL(rawPath, "http://localhost").pathname
|
|
29
|
-
);
|
|
30
|
-
} catch {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
const file = path.join(dir, pathname);
|
|
34
|
-
if (!file.startsWith(dir + path.sep) || path.basename(file) === "index.html")
|
|
35
|
-
return null;
|
|
36
|
-
const info = await stat(file).catch(() => null);
|
|
37
|
-
if (!info?.isFile()) return null;
|
|
38
|
-
return {
|
|
39
|
-
file,
|
|
40
|
-
size: info.size,
|
|
41
|
-
headers: {
|
|
42
|
-
"X-Content-Type-Options": "nosniff",
|
|
43
|
-
"Content-Type": MIME[path.extname(file).toLowerCase()] ?? "application/octet-stream",
|
|
44
|
-
"Cache-Control": pathname.startsWith("/assets/") ? "public, max-age=31536000, immutable" : "no-cache"
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
resolveStaticFile
|
|
51
|
-
};
|