clear-router 2.5.8 → 2.5.10
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/{bindings-T0FKpWyi.cjs → bindings--vhubKAz.cjs} +46 -2
- package/dist/{bindings-DJDdQv1q.mjs → bindings-BQMqEHcR.mjs} +46 -2
- package/dist/{bindings-CV1e5jho.d.mts → bindings-CNL7bpz5.d.mts} +5 -0
- package/dist/{bindings-NV0CdqGl.d.cts → bindings-CxvtC8XS.d.cts} +5 -0
- package/dist/core/index.cjs +2 -2
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.mts +1 -1
- package/dist/core/index.mjs +2 -2
- package/dist/decorators/index.cjs +1 -1
- package/dist/decorators/index.d.cts +1 -1
- package/dist/decorators/index.d.mts +1 -1
- package/dist/decorators/index.mjs +1 -1
- package/dist/decorators/setup.cjs +2 -2
- package/dist/decorators/setup.d.cts +1 -1
- package/dist/decorators/setup.d.mts +2 -1
- package/dist/decorators/setup.mjs +2 -2
- package/dist/express/index.cjs +3 -3
- package/dist/express/index.d.cts +1 -1
- package/dist/express/index.d.mts +1 -1
- package/dist/express/index.mjs +3 -3
- package/dist/fastify/index.cjs +3 -3
- package/dist/fastify/index.d.cts +1 -1
- package/dist/fastify/index.d.mts +1 -1
- package/dist/fastify/index.mjs +3 -3
- package/dist/h3/index.cjs +3 -3
- package/dist/h3/index.d.cts +1 -1
- package/dist/h3/index.d.mts +1 -1
- package/dist/h3/index.mjs +3 -3
- package/dist/hono/index.cjs +3 -3
- package/dist/hono/index.d.cts +1 -1
- package/dist/hono/index.d.mts +1 -1
- package/dist/hono/index.mjs +3 -3
- package/dist/index.cjs +47 -2
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +47 -2
- package/dist/koa/index.cjs +3 -3
- package/dist/koa/index.d.cts +1 -1
- package/dist/koa/index.d.mts +1 -1
- package/dist/koa/index.mjs +3 -3
- package/dist/{responses-B184V5nj.mjs → responses-BuQBx5wu.mjs} +1 -1
- package/dist/{responses-CfCmLLo9.cjs → responses-DBIiiAmd.cjs} +1 -1
- package/dist/{router-B8l8jerS.d.mts → router-BkYtqjYr.d.mts} +2 -1
- package/dist/{router-we2Hw9nA.mjs → router-C04c3Lom.mjs} +2 -1
- package/dist/{router-DbPFGTYG.cjs → router-CdchSCSK.cjs} +2 -1
- package/dist/{router-CiGcLUZD.d.cts → router-DCGZNRNj.d.cts} +2 -1
- package/package.json +1 -1
|
@@ -117,14 +117,58 @@ var Container = class {
|
|
|
117
117
|
this.registry.clear();
|
|
118
118
|
}
|
|
119
119
|
static has(token) {
|
|
120
|
-
return this.registry.has(token);
|
|
120
|
+
return this.registry.has(token) || Boolean(this.findEquivalentToken(token));
|
|
121
|
+
}
|
|
122
|
+
static bindings() {
|
|
123
|
+
return Object.fromEntries(this.registry.entries());
|
|
121
124
|
}
|
|
122
125
|
static async resolve(token, ctx, autoDiscover = false) {
|
|
123
126
|
if (token === Request) return ctx.clearRequest;
|
|
124
127
|
if (token === Response) return ctx.clearResponse;
|
|
125
|
-
|
|
128
|
+
const binding = this.getBinding(token);
|
|
129
|
+
if (binding) return this.resolveBinding(binding, ctx, autoDiscover);
|
|
126
130
|
if (autoDiscover && typeof token === "function") return new token();
|
|
127
131
|
}
|
|
132
|
+
static getBinding(token) {
|
|
133
|
+
if (this.registry.has(token)) return this.registry.get(token);
|
|
134
|
+
const equivalent = this.findEquivalentToken(token);
|
|
135
|
+
return equivalent ? this.registry.get(equivalent) : void 0;
|
|
136
|
+
}
|
|
137
|
+
static findEquivalentToken(token) {
|
|
138
|
+
const name = token.name;
|
|
139
|
+
if (!name) return;
|
|
140
|
+
const tokenParent = Object.getPrototypeOf(token);
|
|
141
|
+
const tokenProps = this.getComparableStaticProps(token);
|
|
142
|
+
for (const registered of this.registry.keys()) {
|
|
143
|
+
if (registered === token) continue;
|
|
144
|
+
if (registered.name !== name) continue;
|
|
145
|
+
const registeredParent = Object.getPrototypeOf(registered);
|
|
146
|
+
if (tokenParent && registeredParent && tokenParent.name !== registeredParent.name) continue;
|
|
147
|
+
const registeredProps = this.getComparableStaticProps(registered);
|
|
148
|
+
if (!this.staticPropsMatch(token, registered, tokenProps, registeredProps)) continue;
|
|
149
|
+
return registered;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
static getComparableStaticProps(token) {
|
|
153
|
+
return Object.getOwnPropertyNames(token).filter((prop) => {
|
|
154
|
+
return ![
|
|
155
|
+
"length",
|
|
156
|
+
"name",
|
|
157
|
+
"prototype",
|
|
158
|
+
"arguments",
|
|
159
|
+
"caller"
|
|
160
|
+
].includes(prop);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
static staticPropsMatch(token, registered, tokenProps, registeredProps) {
|
|
164
|
+
if (tokenProps.length !== registeredProps.length) return false;
|
|
165
|
+
console.log(token, registered);
|
|
166
|
+
for (const prop of tokenProps) {
|
|
167
|
+
if (!registeredProps.includes(prop)) return false;
|
|
168
|
+
if (Reflect.get(token, prop) !== Reflect.get(registered, prop)) return false;
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
128
172
|
static async resolveBinding(binding, ctx, autoDiscover) {
|
|
129
173
|
if (!binding) return void 0;
|
|
130
174
|
if (typeof binding !== "function") return binding;
|
|
@@ -116,14 +116,58 @@ var Container = class {
|
|
|
116
116
|
this.registry.clear();
|
|
117
117
|
}
|
|
118
118
|
static has(token) {
|
|
119
|
-
return this.registry.has(token);
|
|
119
|
+
return this.registry.has(token) || Boolean(this.findEquivalentToken(token));
|
|
120
|
+
}
|
|
121
|
+
static bindings() {
|
|
122
|
+
return Object.fromEntries(this.registry.entries());
|
|
120
123
|
}
|
|
121
124
|
static async resolve(token, ctx, autoDiscover = false) {
|
|
122
125
|
if (token === Request) return ctx.clearRequest;
|
|
123
126
|
if (token === Response) return ctx.clearResponse;
|
|
124
|
-
|
|
127
|
+
const binding = this.getBinding(token);
|
|
128
|
+
if (binding) return this.resolveBinding(binding, ctx, autoDiscover);
|
|
125
129
|
if (autoDiscover && typeof token === "function") return new token();
|
|
126
130
|
}
|
|
131
|
+
static getBinding(token) {
|
|
132
|
+
if (this.registry.has(token)) return this.registry.get(token);
|
|
133
|
+
const equivalent = this.findEquivalentToken(token);
|
|
134
|
+
return equivalent ? this.registry.get(equivalent) : void 0;
|
|
135
|
+
}
|
|
136
|
+
static findEquivalentToken(token) {
|
|
137
|
+
const name = token.name;
|
|
138
|
+
if (!name) return;
|
|
139
|
+
const tokenParent = Object.getPrototypeOf(token);
|
|
140
|
+
const tokenProps = this.getComparableStaticProps(token);
|
|
141
|
+
for (const registered of this.registry.keys()) {
|
|
142
|
+
if (registered === token) continue;
|
|
143
|
+
if (registered.name !== name) continue;
|
|
144
|
+
const registeredParent = Object.getPrototypeOf(registered);
|
|
145
|
+
if (tokenParent && registeredParent && tokenParent.name !== registeredParent.name) continue;
|
|
146
|
+
const registeredProps = this.getComparableStaticProps(registered);
|
|
147
|
+
if (!this.staticPropsMatch(token, registered, tokenProps, registeredProps)) continue;
|
|
148
|
+
return registered;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
static getComparableStaticProps(token) {
|
|
152
|
+
return Object.getOwnPropertyNames(token).filter((prop) => {
|
|
153
|
+
return ![
|
|
154
|
+
"length",
|
|
155
|
+
"name",
|
|
156
|
+
"prototype",
|
|
157
|
+
"arguments",
|
|
158
|
+
"caller"
|
|
159
|
+
].includes(prop);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
static staticPropsMatch(token, registered, tokenProps, registeredProps) {
|
|
163
|
+
if (tokenProps.length !== registeredProps.length) return false;
|
|
164
|
+
console.log(token, registered);
|
|
165
|
+
for (const prop of tokenProps) {
|
|
166
|
+
if (!registeredProps.includes(prop)) return false;
|
|
167
|
+
if (Reflect.get(token, prop) !== Reflect.get(registered, prop)) return false;
|
|
168
|
+
}
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
127
171
|
static async resolveBinding(binding, ctx, autoDiscover) {
|
|
128
172
|
if (!binding) return void 0;
|
|
129
173
|
if (typeof binding !== "function") return binding;
|
|
@@ -12,7 +12,12 @@ declare class Container {
|
|
|
12
12
|
static unbind<T>(token: BindToken<T>): void;
|
|
13
13
|
static clear(): void;
|
|
14
14
|
static has<T>(token: BindToken<T>): boolean;
|
|
15
|
+
static bindings<V = any>(): Record<string, BindValue<V>>;
|
|
15
16
|
static resolve<T>(token: BindToken<T>, ctx: any, autoDiscover?: boolean): Promise<T | undefined>;
|
|
17
|
+
private static getBinding;
|
|
18
|
+
private static findEquivalentToken;
|
|
19
|
+
private static getComparableStaticProps;
|
|
20
|
+
private static staticPropsMatch;
|
|
16
21
|
private static resolveBinding;
|
|
17
22
|
}
|
|
18
23
|
declare function Bind(...tokens: BindToken[]): BindDecorator;
|
|
@@ -12,7 +12,12 @@ declare class Container {
|
|
|
12
12
|
static unbind<T>(token: BindToken<T>): void;
|
|
13
13
|
static clear(): void;
|
|
14
14
|
static has<T>(token: BindToken<T>): boolean;
|
|
15
|
+
static bindings<V = any>(): Record<string, BindValue<V>>;
|
|
15
16
|
static resolve<T>(token: BindToken<T>, ctx: any, autoDiscover?: boolean): Promise<T | undefined>;
|
|
17
|
+
private static getBinding;
|
|
18
|
+
private static findEquivalentToken;
|
|
19
|
+
private static getComparableStaticProps;
|
|
20
|
+
private static staticPropsMatch;
|
|
16
21
|
private static resolveBinding;
|
|
17
22
|
}
|
|
18
23
|
declare function Bind(...tokens: BindToken[]): BindDecorator;
|
package/dist/core/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_bindings = require('../bindings
|
|
3
|
-
const require_router = require('../router-
|
|
2
|
+
const require_bindings = require('../bindings--vhubKAz.cjs');
|
|
3
|
+
const require_router = require('../router-CdchSCSK.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/core/plugins.ts
|
|
6
6
|
function definePlugin(plugin) {
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ClearRouterPluginRequestContext, c as PluginBindValue, d as Request, i as ClearRouterPluginInput, l as PluginSetupResult, n as ClearRouterPlugin, o as PluginBind, r as ClearRouterPluginContext, s as PluginBindFactory, t as CoreRouter, u as definePlugin, w as Response } from "../router-
|
|
1
|
+
import { a as ClearRouterPluginRequestContext, c as PluginBindValue, d as Request, i as ClearRouterPluginInput, l as PluginSetupResult, n as ClearRouterPlugin, o as PluginBind, r as ClearRouterPluginContext, s as PluginBindFactory, t as CoreRouter, u as definePlugin, w as Response } from "../router-DCGZNRNj.cjs";
|
|
2
2
|
export { ClearRouterPlugin, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, CoreRouter, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, definePlugin };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ClearRouterPluginRequestContext, c as PluginBindValue, d as Request, i as ClearRouterPluginInput, l as PluginSetupResult, n as ClearRouterPlugin, o as PluginBind, r as ClearRouterPluginContext, s as PluginBindFactory, t as CoreRouter, u as definePlugin, w as Response } from "../router-
|
|
1
|
+
import { a as ClearRouterPluginRequestContext, c as PluginBindValue, d as Request, i as ClearRouterPluginInput, l as PluginSetupResult, n as ClearRouterPlugin, o as PluginBind, r as ClearRouterPluginContext, s as PluginBindFactory, t as CoreRouter, u as definePlugin, w as Response } from "../router-BkYtqjYr.mjs";
|
|
2
2
|
export { ClearRouterPlugin, ClearRouterPluginContext, ClearRouterPluginInput, ClearRouterPluginRequestContext, CoreRouter, PluginBind, PluginBindFactory, PluginBindValue, PluginSetupResult, Request, Response, definePlugin };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as Request, s as Response } from "../bindings-
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { c as Request, s as Response } from "../bindings-BQMqEHcR.mjs";
|
|
2
|
+
import { t as CoreRouter } from "../router-C04c3Lom.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/core/plugins.ts
|
|
5
5
|
function definePlugin(plugin) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_bindings = require('../bindings
|
|
2
|
+
const require_bindings = require('../bindings--vhubKAz.cjs');
|
|
3
3
|
|
|
4
4
|
exports.Bind = require_bindings.Bind;
|
|
5
5
|
exports.Container = require_bindings.Container;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as BindValue, i as BindToken, n as BindDecorator, o as Container, r as BindFactory, t as Bind } from "../bindings-
|
|
1
|
+
import { a as BindValue, i as BindToken, n as BindDecorator, o as Container, r as BindFactory, t as Bind } from "../bindings-CxvtC8XS.cjs";
|
|
2
2
|
export { Bind, type BindDecorator, type BindFactory, type BindToken, type BindValue, Container };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as BindValue, i as BindToken, n as BindDecorator, o as Container, r as BindFactory, t as Bind } from "../bindings-
|
|
1
|
+
import { a as BindValue, i as BindToken, n as BindDecorator, o as Container, r as BindFactory, t as Bind } from "../bindings-CNL7bpz5.mjs";
|
|
2
2
|
export { Bind, type BindDecorator, type BindFactory, type BindToken, type BindValue, Container };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_bindings = require('../bindings
|
|
3
|
-
const require_router = require('../router-
|
|
2
|
+
const require_bindings = require('../bindings--vhubKAz.cjs');
|
|
3
|
+
const require_router = require('../router-CdchSCSK.cjs');
|
|
4
4
|
require('./index.cjs');
|
|
5
5
|
require("reflect-metadata");
|
|
6
6
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as BindValue, i as BindToken, n as BindDecorator, o as Container, r as BindFactory, t as Bind } from "../bindings-
|
|
1
|
+
import { a as BindValue, i as BindToken, n as BindDecorator, o as Container, r as BindFactory, t as Bind } from "../bindings-CxvtC8XS.cjs";
|
|
2
2
|
export { Bind, BindDecorator, BindFactory, BindToken, BindValue, Container };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { a as BindValue, i as BindToken, n as BindDecorator, o as Container, r as BindFactory, t as Bind } from "../bindings-
|
|
1
|
+
import { a as BindValue, i as BindToken, n as BindDecorator, o as Container, r as BindFactory, t as Bind } from "../bindings-CNL7bpz5.mjs";
|
|
2
|
+
import "reflect-metadata";
|
|
2
3
|
export { Bind, BindDecorator, BindFactory, BindToken, BindValue, Container };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as Container, t as Bind } from "../bindings-
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
1
|
+
import { n as Container, t as Bind } from "../bindings-BQMqEHcR.mjs";
|
|
2
|
+
import { t as CoreRouter } from "../router-C04c3Lom.mjs";
|
|
3
3
|
import "./index.mjs";
|
|
4
4
|
import "reflect-metadata";
|
|
5
5
|
|
package/dist/express/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
require('../bindings
|
|
3
|
-
const require_router = require('../router-
|
|
4
|
-
const require_responses = require('../responses-
|
|
2
|
+
require('../bindings--vhubKAz.cjs');
|
|
3
|
+
const require_router = require('../router-CdchSCSK.cjs');
|
|
4
|
+
const require_responses = require('../responses-DBIiiAmd.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/express/router.ts
|
|
7
7
|
/**
|
package/dist/express/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, _ as Handler, b as ApiResourceMiddleware, f as Route, t as CoreRouter, v as HttpContext, x as ControllerAction, y as Middleware } from "../router-
|
|
1
|
+
import { C as HttpMethod, _ as Handler, b as ApiResourceMiddleware, f as Route, t as CoreRouter, v as HttpContext, x as ControllerAction, y as Middleware } from "../router-DCGZNRNj.cjs";
|
|
2
2
|
import { Router as Router$1 } from "express";
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.d.ts
|
package/dist/express/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, _ as Handler, b as ApiResourceMiddleware, f as Route, t as CoreRouter, v as HttpContext, x as ControllerAction, y as Middleware } from "../router-
|
|
1
|
+
import { C as HttpMethod, _ as Handler, b as ApiResourceMiddleware, f as Route, t as CoreRouter, v as HttpContext, x as ControllerAction, y as Middleware } from "../router-BkYtqjYr.mjs";
|
|
2
2
|
import { Router as Router$1 } from "express";
|
|
3
3
|
|
|
4
4
|
//#region src/express/router.d.ts
|
package/dist/express/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../bindings-
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
3
|
-
import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-
|
|
1
|
+
import "../bindings-BQMqEHcR.mjs";
|
|
2
|
+
import { t as CoreRouter } from "../router-C04c3Lom.mjs";
|
|
3
|
+
import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-BuQBx5wu.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/express/router.ts
|
|
6
6
|
/**
|
package/dist/fastify/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
require('../bindings
|
|
3
|
-
const require_router = require('../router-
|
|
4
|
-
const require_responses = require('../responses-
|
|
2
|
+
require('../bindings--vhubKAz.cjs');
|
|
3
|
+
const require_router = require('../router-CdchSCSK.cjs');
|
|
4
|
+
const require_responses = require('../responses-DBIiiAmd.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/fastify/router.ts
|
|
7
7
|
/**
|
package/dist/fastify/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-
|
|
1
|
+
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-DCGZNRNj.cjs";
|
|
2
2
|
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
3
3
|
|
|
4
4
|
//#region types/fastify.d.ts
|
package/dist/fastify/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-
|
|
1
|
+
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-BkYtqjYr.mjs";
|
|
2
2
|
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
3
3
|
|
|
4
4
|
//#region types/fastify.d.ts
|
package/dist/fastify/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../bindings-
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
3
|
-
import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-
|
|
1
|
+
import "../bindings-BQMqEHcR.mjs";
|
|
2
|
+
import { t as CoreRouter } from "../router-C04c3Lom.mjs";
|
|
3
|
+
import { n as resolveResponseMeta, r as responseWasSent, t as isFetchResponse } from "../responses-BuQBx5wu.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/fastify/router.ts
|
|
6
6
|
/**
|
package/dist/h3/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
require('../bindings
|
|
3
|
-
const require_router = require('../router-
|
|
4
|
-
const require_responses = require('../responses-
|
|
2
|
+
require('../bindings--vhubKAz.cjs');
|
|
3
|
+
const require_router = require('../router-CdchSCSK.cjs');
|
|
4
|
+
const require_responses = require('../responses-DBIiiAmd.cjs');
|
|
5
5
|
let h3 = require("h3");
|
|
6
6
|
|
|
7
7
|
//#region src/h3/router.ts
|
package/dist/h3/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, b as ApiResourceMiddleware, f as Route, g as Middleware, h as HttpContext, m as Handler, p as H3App, t as CoreRouter, x as ControllerAction } from "../router-
|
|
1
|
+
import { C as HttpMethod, b as ApiResourceMiddleware, f as Route, g as Middleware, h as HttpContext, m as Handler, p as H3App, t as CoreRouter, x as ControllerAction } from "../router-DCGZNRNj.cjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/h3/router.d.ts
|
package/dist/h3/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, b as ApiResourceMiddleware, f as Route, g as Middleware, h as HttpContext, m as Handler, p as H3App, t as CoreRouter, x as ControllerAction } from "../router-
|
|
1
|
+
import { C as HttpMethod, b as ApiResourceMiddleware, f as Route, g as Middleware, h as HttpContext, m as Handler, p as H3App, t as CoreRouter, x as ControllerAction } from "../router-BkYtqjYr.mjs";
|
|
2
2
|
import { H3 } from "h3";
|
|
3
3
|
|
|
4
4
|
//#region src/h3/router.d.ts
|
package/dist/h3/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../bindings-
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
3
|
-
import { n as resolveResponseMeta } from "../responses-
|
|
1
|
+
import "../bindings-BQMqEHcR.mjs";
|
|
2
|
+
import { t as CoreRouter } from "../router-C04c3Lom.mjs";
|
|
3
|
+
import { n as resolveResponseMeta } from "../responses-BuQBx5wu.mjs";
|
|
4
4
|
import { HTTPResponse, getQuery, getRouterParams, readBody } from "h3";
|
|
5
5
|
|
|
6
6
|
//#region src/h3/router.ts
|
package/dist/hono/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
require('../bindings
|
|
3
|
-
const require_router = require('../router-
|
|
4
|
-
const require_responses = require('../responses-
|
|
2
|
+
require('../bindings--vhubKAz.cjs');
|
|
3
|
+
const require_router = require('../router-CdchSCSK.cjs');
|
|
4
|
+
const require_responses = require('../responses-DBIiiAmd.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/hono/router.ts
|
|
7
7
|
/**
|
package/dist/hono/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-
|
|
1
|
+
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-DCGZNRNj.cjs";
|
|
2
2
|
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
3
3
|
|
|
4
4
|
//#region types/hono.d.ts
|
package/dist/hono/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-
|
|
1
|
+
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-BkYtqjYr.mjs";
|
|
2
2
|
import { Context, HonoRequest, MiddlewareHandler } from "hono";
|
|
3
3
|
|
|
4
4
|
//#region types/hono.d.ts
|
package/dist/hono/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../bindings-
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
3
|
-
import { n as resolveResponseMeta } from "../responses-
|
|
1
|
+
import "../bindings-BQMqEHcR.mjs";
|
|
2
|
+
import { t as CoreRouter } from "../router-C04c3Lom.mjs";
|
|
3
|
+
import { n as resolveResponseMeta } from "../responses-BuQBx5wu.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/hono/router.ts
|
|
6
6
|
/**
|
package/dist/index.cjs
CHANGED
|
@@ -163,14 +163,58 @@ var Container = class {
|
|
|
163
163
|
this.registry.clear();
|
|
164
164
|
}
|
|
165
165
|
static has(token) {
|
|
166
|
-
return this.registry.has(token);
|
|
166
|
+
return this.registry.has(token) || Boolean(this.findEquivalentToken(token));
|
|
167
|
+
}
|
|
168
|
+
static bindings() {
|
|
169
|
+
return Object.fromEntries(this.registry.entries());
|
|
167
170
|
}
|
|
168
171
|
static async resolve(token, ctx, autoDiscover = false) {
|
|
169
172
|
if (token === Request) return ctx.clearRequest;
|
|
170
173
|
if (token === Response) return ctx.clearResponse;
|
|
171
|
-
|
|
174
|
+
const binding = this.getBinding(token);
|
|
175
|
+
if (binding) return this.resolveBinding(binding, ctx, autoDiscover);
|
|
172
176
|
if (autoDiscover && typeof token === "function") return new token();
|
|
173
177
|
}
|
|
178
|
+
static getBinding(token) {
|
|
179
|
+
if (this.registry.has(token)) return this.registry.get(token);
|
|
180
|
+
const equivalent = this.findEquivalentToken(token);
|
|
181
|
+
return equivalent ? this.registry.get(equivalent) : void 0;
|
|
182
|
+
}
|
|
183
|
+
static findEquivalentToken(token) {
|
|
184
|
+
const name = token.name;
|
|
185
|
+
if (!name) return;
|
|
186
|
+
const tokenParent = Object.getPrototypeOf(token);
|
|
187
|
+
const tokenProps = this.getComparableStaticProps(token);
|
|
188
|
+
for (const registered of this.registry.keys()) {
|
|
189
|
+
if (registered === token) continue;
|
|
190
|
+
if (registered.name !== name) continue;
|
|
191
|
+
const registeredParent = Object.getPrototypeOf(registered);
|
|
192
|
+
if (tokenParent && registeredParent && tokenParent.name !== registeredParent.name) continue;
|
|
193
|
+
const registeredProps = this.getComparableStaticProps(registered);
|
|
194
|
+
if (!this.staticPropsMatch(token, registered, tokenProps, registeredProps)) continue;
|
|
195
|
+
return registered;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
static getComparableStaticProps(token) {
|
|
199
|
+
return Object.getOwnPropertyNames(token).filter((prop) => {
|
|
200
|
+
return ![
|
|
201
|
+
"length",
|
|
202
|
+
"name",
|
|
203
|
+
"prototype",
|
|
204
|
+
"arguments",
|
|
205
|
+
"caller"
|
|
206
|
+
].includes(prop);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
static staticPropsMatch(token, registered, tokenProps, registeredProps) {
|
|
210
|
+
if (tokenProps.length !== registeredProps.length) return false;
|
|
211
|
+
console.log(token, registered);
|
|
212
|
+
for (const prop of tokenProps) {
|
|
213
|
+
if (!registeredProps.includes(prop)) return false;
|
|
214
|
+
if (Reflect.get(token, prop) !== Reflect.get(registered, prop)) return false;
|
|
215
|
+
}
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
174
218
|
static async resolveBinding(binding, ctx, autoDiscover) {
|
|
175
219
|
if (!binding) return void 0;
|
|
176
220
|
if (typeof binding !== "function") return binding;
|
|
@@ -385,6 +429,7 @@ var CoreRouter = class {
|
|
|
385
429
|
const ctx = {
|
|
386
430
|
container: Container,
|
|
387
431
|
bind: this.createPluginBind(),
|
|
432
|
+
bindings: Container.bindings(),
|
|
388
433
|
configure: this.configure.bind(this),
|
|
389
434
|
configureDefaults: this.configureDefaults.bind(this),
|
|
390
435
|
get request() {
|
package/dist/index.d.cts
CHANGED
|
@@ -138,7 +138,12 @@ declare class Container {
|
|
|
138
138
|
static unbind<T>(token: BindToken<T>): void;
|
|
139
139
|
static clear(): void;
|
|
140
140
|
static has<T>(token: BindToken<T>): boolean;
|
|
141
|
+
static bindings<V = any>(): Record<string, BindValue<V>>;
|
|
141
142
|
static resolve<T>(token: BindToken<T>, ctx: any, autoDiscover?: boolean): Promise<T | undefined>;
|
|
143
|
+
private static getBinding;
|
|
144
|
+
private static findEquivalentToken;
|
|
145
|
+
private static getComparableStaticProps;
|
|
146
|
+
private static staticPropsMatch;
|
|
142
147
|
private static resolveBinding;
|
|
143
148
|
}
|
|
144
149
|
//#endregion
|
|
@@ -156,6 +161,7 @@ type PluginBind = <T>(token: BindToken<T>, value: PluginBindValue<T>) => void;
|
|
|
156
161
|
interface ClearRouterPluginContext<Options = any> {
|
|
157
162
|
container: typeof Container;
|
|
158
163
|
bind: PluginBind;
|
|
164
|
+
bindings: Record<string, BindValue>;
|
|
159
165
|
configure: (options: RouterConfig) => void;
|
|
160
166
|
configureDefaults: (options: RouterConfig) => void;
|
|
161
167
|
readonly request?: Request;
|
package/dist/index.d.mts
CHANGED
|
@@ -138,7 +138,12 @@ declare class Container {
|
|
|
138
138
|
static unbind<T>(token: BindToken<T>): void;
|
|
139
139
|
static clear(): void;
|
|
140
140
|
static has<T>(token: BindToken<T>): boolean;
|
|
141
|
+
static bindings<V = any>(): Record<string, BindValue<V>>;
|
|
141
142
|
static resolve<T>(token: BindToken<T>, ctx: any, autoDiscover?: boolean): Promise<T | undefined>;
|
|
143
|
+
private static getBinding;
|
|
144
|
+
private static findEquivalentToken;
|
|
145
|
+
private static getComparableStaticProps;
|
|
146
|
+
private static staticPropsMatch;
|
|
142
147
|
private static resolveBinding;
|
|
143
148
|
}
|
|
144
149
|
//#endregion
|
|
@@ -156,6 +161,7 @@ type PluginBind = <T>(token: BindToken<T>, value: PluginBindValue<T>) => void;
|
|
|
156
161
|
interface ClearRouterPluginContext<Options = any> {
|
|
157
162
|
container: typeof Container;
|
|
158
163
|
bind: PluginBind;
|
|
164
|
+
bindings: Record<string, BindValue>;
|
|
159
165
|
configure: (options: RouterConfig) => void;
|
|
160
166
|
configureDefaults: (options: RouterConfig) => void;
|
|
161
167
|
readonly request?: Request;
|
package/dist/index.mjs
CHANGED
|
@@ -162,14 +162,58 @@ var Container = class {
|
|
|
162
162
|
this.registry.clear();
|
|
163
163
|
}
|
|
164
164
|
static has(token) {
|
|
165
|
-
return this.registry.has(token);
|
|
165
|
+
return this.registry.has(token) || Boolean(this.findEquivalentToken(token));
|
|
166
|
+
}
|
|
167
|
+
static bindings() {
|
|
168
|
+
return Object.fromEntries(this.registry.entries());
|
|
166
169
|
}
|
|
167
170
|
static async resolve(token, ctx, autoDiscover = false) {
|
|
168
171
|
if (token === Request) return ctx.clearRequest;
|
|
169
172
|
if (token === Response) return ctx.clearResponse;
|
|
170
|
-
|
|
173
|
+
const binding = this.getBinding(token);
|
|
174
|
+
if (binding) return this.resolveBinding(binding, ctx, autoDiscover);
|
|
171
175
|
if (autoDiscover && typeof token === "function") return new token();
|
|
172
176
|
}
|
|
177
|
+
static getBinding(token) {
|
|
178
|
+
if (this.registry.has(token)) return this.registry.get(token);
|
|
179
|
+
const equivalent = this.findEquivalentToken(token);
|
|
180
|
+
return equivalent ? this.registry.get(equivalent) : void 0;
|
|
181
|
+
}
|
|
182
|
+
static findEquivalentToken(token) {
|
|
183
|
+
const name = token.name;
|
|
184
|
+
if (!name) return;
|
|
185
|
+
const tokenParent = Object.getPrototypeOf(token);
|
|
186
|
+
const tokenProps = this.getComparableStaticProps(token);
|
|
187
|
+
for (const registered of this.registry.keys()) {
|
|
188
|
+
if (registered === token) continue;
|
|
189
|
+
if (registered.name !== name) continue;
|
|
190
|
+
const registeredParent = Object.getPrototypeOf(registered);
|
|
191
|
+
if (tokenParent && registeredParent && tokenParent.name !== registeredParent.name) continue;
|
|
192
|
+
const registeredProps = this.getComparableStaticProps(registered);
|
|
193
|
+
if (!this.staticPropsMatch(token, registered, tokenProps, registeredProps)) continue;
|
|
194
|
+
return registered;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
static getComparableStaticProps(token) {
|
|
198
|
+
return Object.getOwnPropertyNames(token).filter((prop) => {
|
|
199
|
+
return ![
|
|
200
|
+
"length",
|
|
201
|
+
"name",
|
|
202
|
+
"prototype",
|
|
203
|
+
"arguments",
|
|
204
|
+
"caller"
|
|
205
|
+
].includes(prop);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
static staticPropsMatch(token, registered, tokenProps, registeredProps) {
|
|
209
|
+
if (tokenProps.length !== registeredProps.length) return false;
|
|
210
|
+
console.log(token, registered);
|
|
211
|
+
for (const prop of tokenProps) {
|
|
212
|
+
if (!registeredProps.includes(prop)) return false;
|
|
213
|
+
if (Reflect.get(token, prop) !== Reflect.get(registered, prop)) return false;
|
|
214
|
+
}
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
173
217
|
static async resolveBinding(binding, ctx, autoDiscover) {
|
|
174
218
|
if (!binding) return void 0;
|
|
175
219
|
if (typeof binding !== "function") return binding;
|
|
@@ -384,6 +428,7 @@ var CoreRouter = class {
|
|
|
384
428
|
const ctx = {
|
|
385
429
|
container: Container,
|
|
386
430
|
bind: this.createPluginBind(),
|
|
431
|
+
bindings: Container.bindings(),
|
|
387
432
|
configure: this.configure.bind(this),
|
|
388
433
|
configureDefaults: this.configureDefaults.bind(this),
|
|
389
434
|
get request() {
|
package/dist/koa/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
require('../bindings
|
|
3
|
-
const require_router = require('../router-
|
|
4
|
-
const require_responses = require('../responses-
|
|
2
|
+
require('../bindings--vhubKAz.cjs');
|
|
3
|
+
const require_router = require('../router-CdchSCSK.cjs');
|
|
4
|
+
const require_responses = require('../responses-DBIiiAmd.cjs');
|
|
5
5
|
|
|
6
6
|
//#region src/koa/router.ts
|
|
7
7
|
/**
|
package/dist/koa/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-
|
|
1
|
+
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-DCGZNRNj.cjs";
|
|
2
2
|
import Koa from "koa";
|
|
3
3
|
import Router$1 from "@koa/router";
|
|
4
4
|
|
package/dist/koa/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-
|
|
1
|
+
import { C as HttpMethod, S as ControllerHandler, b as ApiResourceMiddleware, d as Request, f as Route, t as CoreRouter, w as Response, x as ControllerAction } from "../router-BkYtqjYr.mjs";
|
|
2
2
|
import Koa from "koa";
|
|
3
3
|
import Router$1 from "@koa/router";
|
|
4
4
|
|
package/dist/koa/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../bindings-
|
|
2
|
-
import { t as CoreRouter } from "../router-
|
|
3
|
-
import { n as resolveResponseMeta, t as isFetchResponse } from "../responses-
|
|
1
|
+
import "../bindings-BQMqEHcR.mjs";
|
|
2
|
+
import { t as CoreRouter } from "../router-C04c3Lom.mjs";
|
|
3
|
+
import { n as resolveResponseMeta, t as isFetchResponse } from "../responses-BuQBx5wu.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/koa/router.ts
|
|
6
6
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BindValue, i as BindToken, o as Container } from "./bindings-
|
|
1
|
+
import { a as BindValue, i as BindToken, o as Container } from "./bindings-CNL7bpz5.mjs";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
import { EventHandlerRequest, H3, H3Event, Middleware, TypedServerRequest } from "h3";
|
|
4
4
|
import { NextFunction, Request, Response as Response$1 } from "express";
|
|
@@ -203,6 +203,7 @@ type PluginBind = <T>(token: BindToken<T>, value: PluginBindValue<T>) => void;
|
|
|
203
203
|
interface ClearRouterPluginContext<Options = any> {
|
|
204
204
|
container: typeof Container;
|
|
205
205
|
bind: PluginBind;
|
|
206
|
+
bindings: Record<string, BindValue>;
|
|
206
207
|
configure: (options: RouterConfig) => void;
|
|
207
208
|
configureDefaults: (options: RouterConfig) => void;
|
|
208
209
|
readonly request?: Request$1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getStandardMetadata, c as Request, i as getDesignParamTypes, n as Container, o as isClass, r as getBindingMetadataFromTargets, s as Response } from "./bindings-
|
|
1
|
+
import { a as getStandardMetadata, c as Request, i as getDesignParamTypes, n as Container, o as isClass, r as getBindingMetadataFromTargets, s as Response } from "./bindings-BQMqEHcR.mjs";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
|
|
4
4
|
//#region src/Route.ts
|
|
@@ -208,6 +208,7 @@ var CoreRouter = class {
|
|
|
208
208
|
const ctx = {
|
|
209
209
|
container: Container,
|
|
210
210
|
bind: this.createPluginBind(),
|
|
211
|
+
bindings: Container.bindings(),
|
|
211
212
|
configure: this.configure.bind(this),
|
|
212
213
|
configureDefaults: this.configureDefaults.bind(this),
|
|
213
214
|
get request() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_bindings = require('./bindings
|
|
1
|
+
const require_bindings = require('./bindings--vhubKAz.cjs');
|
|
2
2
|
let node_async_hooks = require("node:async_hooks");
|
|
3
3
|
|
|
4
4
|
//#region src/Route.ts
|
|
@@ -208,6 +208,7 @@ var CoreRouter = class {
|
|
|
208
208
|
const ctx = {
|
|
209
209
|
container: require_bindings.Container,
|
|
210
210
|
bind: this.createPluginBind(),
|
|
211
|
+
bindings: require_bindings.Container.bindings(),
|
|
211
212
|
configure: this.configure.bind(this),
|
|
212
213
|
configureDefaults: this.configureDefaults.bind(this),
|
|
213
214
|
get request() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as BindValue, i as BindToken, o as Container } from "./bindings-
|
|
1
|
+
import { a as BindValue, i as BindToken, o as Container } from "./bindings-CxvtC8XS.cjs";
|
|
2
2
|
import { NextFunction, Request, Response as Response$1 } from "express";
|
|
3
3
|
import { EventHandlerRequest, H3, H3Event, Middleware, TypedServerRequest } from "h3";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -203,6 +203,7 @@ type PluginBind = <T>(token: BindToken<T>, value: PluginBindValue<T>) => void;
|
|
|
203
203
|
interface ClearRouterPluginContext<Options = any> {
|
|
204
204
|
container: typeof Container;
|
|
205
205
|
bind: PluginBind;
|
|
206
|
+
bindings: Record<string, BindValue>;
|
|
206
207
|
configure: (options: RouterConfig) => void;
|
|
207
208
|
configureDefaults: (options: RouterConfig) => void;
|
|
208
209
|
readonly request?: Request$1;
|
package/package.json
CHANGED