@mapl/web 0.3.17 → 0.3.18
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/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +19 -20
- package/utils/cors.d.ts +9 -9
- package/utils/cors.js +1 -1
- package/utils/stream.d.ts +0 -5
- package/utils/stream.js +0 -1
package/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const router: <
|
|
|
16
16
|
export * as layer from "./core/middleware.js";
|
|
17
17
|
export * as handle from "./core/handler.js";
|
|
18
18
|
export * as cors from "./utils/cors.js";
|
|
19
|
-
export * as
|
|
19
|
+
export * as bearerAuth from "./utils/bearer-auth.js";
|
|
20
20
|
export * as basicAuth from "./utils/basic-auth.js";
|
|
21
21
|
export * as bodyLimit from "./utils/body-limit.js";
|
|
22
22
|
export { default as redirect } from "./utils/redirect.js";
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{routerImpl}from"./core/index.js";export let router=routerImpl;export*as layer from"./core/middleware.js";export*as handle from"./core/handler.js";export*as cors from"./utils/cors.js";export*as
|
|
1
|
+
import{routerImpl}from"./core/index.js";export let router=routerImpl;export*as layer from"./core/middleware.js";export*as handle from"./core/handler.js";export*as cors from"./utils/cors.js";export*as bearerAuth from"./utils/bearer-auth.js";export*as basicAuth from"./utils/basic-auth.js";export*as bodyLimit from"./utils/body-limit.js";export{default as redirect}from"./utils/redirect.js";export{default as staticHeaders}from"./utils/static-headers.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapl/web",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
4
4
|
"description": "A compiled web framework for all runtimes",
|
|
5
5
|
"keywords": ["fast", "lightweight", "cross-runtime", "framework", "web", "backend"],
|
|
6
6
|
"repository": {
|
|
@@ -14,31 +14,30 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@mapl/framework": "^0.6.2",
|
|
16
16
|
"@mapl/router": "^0.6.4",
|
|
17
|
-
"@safe-std/error": "^2.0.
|
|
17
|
+
"@safe-std/error": "^2.0.4",
|
|
18
18
|
"runtime-compiler": "^1.2.6"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
21
|
"./constants": "./constants.js",
|
|
22
|
-
".": "./index.js",
|
|
23
|
-
"./core": "./core/index.js",
|
|
24
|
-
"./core/utils": "./core/utils.js",
|
|
25
|
-
"./core/context": "./core/context.js",
|
|
26
|
-
"./core/handler": "./core/handler.js",
|
|
27
|
-
"./utils/stream": "./utils/stream.js",
|
|
28
|
-
"./core/middleware": "./core/middleware.js",
|
|
29
|
-
"./utils/cors": "./utils/cors.js",
|
|
30
|
-
"./utils/redirect": "./utils/redirect.js",
|
|
31
|
-
"./utils/body-limit": "./utils/body-limit.js",
|
|
32
|
-
"./utils/bearer-auth": "./utils/bearer-auth.js",
|
|
33
22
|
"./utils/static-headers": "./utils/static-headers.js",
|
|
34
|
-
"./utils/
|
|
35
|
-
"./
|
|
36
|
-
"./
|
|
37
|
-
"./
|
|
23
|
+
"./utils/bearer-auth": "./utils/bearer-auth.js",
|
|
24
|
+
"./compiler/aot": "./compiler/aot.js",
|
|
25
|
+
"./utils/body-limit": "./utils/body-limit.js",
|
|
26
|
+
"./compiler/jit": "./compiler/jit.js",
|
|
27
|
+
"./utils/redirect": "./utils/redirect.js",
|
|
28
|
+
"./build/rolldown": "./build/rolldown.js",
|
|
38
29
|
"./build/utils": "./build/utils.js",
|
|
39
30
|
"./bun/compiler/router": "./bun/compiler/router.js",
|
|
40
|
-
"./
|
|
41
|
-
"./
|
|
42
|
-
"./
|
|
31
|
+
"./utils/cors": "./utils/cors.js",
|
|
32
|
+
"./core/context": "./core/context.js",
|
|
33
|
+
"./bun/compiler/aot": "./bun/compiler/aot.js",
|
|
34
|
+
"./core/middleware": "./core/middleware.js",
|
|
35
|
+
"./bun/compiler/jit": "./bun/compiler/jit.js",
|
|
36
|
+
"./core": "./core/index.js",
|
|
37
|
+
"./core/handler": "./core/handler.js",
|
|
38
|
+
"./bun": "./bun/index.js",
|
|
39
|
+
"./core/utils": "./core/utils.js",
|
|
40
|
+
".": "./index.js",
|
|
41
|
+
"./utils/basic-auth": "./utils/basic-auth.js"
|
|
43
42
|
}
|
|
44
43
|
}
|
package/utils/cors.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { type MiddlewareTypes } from "../core/middleware.js";
|
|
2
2
|
import type { RequestMethod } from "../core/utils.js";
|
|
3
|
-
|
|
3
|
+
import type { Header } from "../core/context.js";
|
|
4
4
|
declare const _: unique symbol;
|
|
5
|
-
export type
|
|
5
|
+
export type CORSHeader = Header & {
|
|
6
6
|
[_]: 0
|
|
7
7
|
};
|
|
8
|
-
export type
|
|
8
|
+
export type CORSPreflightHeader = Header & {
|
|
9
9
|
[_]: 1
|
|
10
10
|
};
|
|
11
|
-
export declare const allowMethods: (v: RequestMethod[] | RequestMethod) =>
|
|
12
|
-
export declare const allowHeaders: (v: string[] | string) =>
|
|
13
|
-
export declare const maxAge: (v: number) =>
|
|
14
|
-
export declare const allowCredentials:
|
|
15
|
-
export declare const exposeHeaders: (v: string
|
|
16
|
-
export declare const init: (origins:
|
|
11
|
+
export declare const allowMethods: (v: [RequestMethod, RequestMethod, ...RequestMethod[]] | RequestMethod | "*") => CORSPreflightHeader;
|
|
12
|
+
export declare const allowHeaders: (v: string[] | string) => CORSPreflightHeader;
|
|
13
|
+
export declare const maxAge: (v: number) => CORSPreflightHeader;
|
|
14
|
+
export declare const allowCredentials: CORSHeader;
|
|
15
|
+
export declare const exposeHeaders: (v: "*" | (string & {}) | [string, string, ...string[]]) => CORSHeader;
|
|
16
|
+
export declare const init: (origins: "*" | (string & {}) | [string, string, ...string[]], preflightHeaders?: CORSPreflightHeader[], headers?: Header[]) => MiddlewareTypes<any, never, {}>;
|
|
17
17
|
export {};
|
package/utils/cors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{injectDependency}from"runtime-compiler";import{
|
|
1
|
+
import{injectDependency}from"runtime-compiler";import{isHydrating}from"runtime-compiler/config";import{createContext}from"@mapl/framework";import{macro}from"../core/middleware.js";import{injectList}from"./static-headers.js";export let allowMethods=v=>[`access-control-allow-methods`,``+v];export let allowHeaders=v=>[`access-control-allow-headers`,``+v];export let maxAge=v=>[`access-control-max-age`,``+v];export let allowCredentials=[`access-control-allow-credentials`,`true`];export let exposeHeaders=v=>[`access-control-expose-headers`,``+v];let createContextMacro=macro(createContext);export let init=isHydrating?()=>createContextMacro:(origins,preflightHeaders=[],headers=[])=>{if(origins!==`*`){headers.push([`vary`,`origin`]);if(Array.isArray(origins))return macro(scope=>{let originList=injectDependency(JSON.stringify(origins));return createContext(scope)+(injectDependency(`(r,h)=>{let o=r.headers.get("origin");h.push(["access-control-allow-origin",typeof o==="string"&&`+originList+`.includes(o)?o:`+originList+`[0]]);`+(headers.length>0?`h.push(`+injectList(headers)+`);`:``)+(preflightHeaders.length>0?`r.method==="OPTIONS"&&h.push(`+injectList(preflightHeaders)+`)}`:`}`))+`(r,h);`)})}headers.push([`access-control-allow-origin`,origins]);return macro(scope=>{let pushHeaders=headers.length>0?`h.push(`+injectList(headers)+`);`:``;return createContext(scope)+(preflightHeaders.length>0?injectDependency(`(r,h)=>{`+pushHeaders+`r.method==="OPTIONS"&&h.push(`+injectList(preflightHeaders)+`)}`)+`(r,h);`:pushHeaders)})};
|
package/utils/stream.d.ts
DELETED
package/utils/stream.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function start(controller){this.controller=controller}export let source=queueingStrategy=>{let source={controller:null,stream:null,start};source.stream=new ReadableStream(source,queueingStrategy);return source};
|