Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Thirdeye
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
Koishi Thirdeye
Commits
241407ea
Commit
241407ea
authored
Nov 21, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
catchup
parent
71918c5c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
498 additions
and
240 deletions
+498
-240
index.ts
index.ts
+1
-1
package-lock.json
package-lock.json
+486
-206
package.json
package.json
+8
-7
src/decorators.ts
src/decorators.ts
+1
-2
src/register.ts
src/register.ts
+2
-24
No files found.
index.ts
View file @
241407ea
...
@@ -2,4 +2,4 @@ import 'reflect-metadata';
...
@@ -2,4 +2,4 @@ import 'reflect-metadata';
export
*
from
'
./src/register
'
;
export
*
from
'
./src/register
'
;
export
*
from
'
./src/decorators
'
;
export
*
from
'
./src/decorators
'
;
export
*
from
'
./src/def/interfaces
'
;
export
*
from
'
./src/def/interfaces
'
;
export
*
from
'
koishi-utils-schema
gen
'
;
export
*
from
'
schemastery-
gen
'
;
package-lock.json
View file @
241407ea
This source diff could not be displayed because it is too large. You can
view the blob
instead.
package.json
View file @
241407ea
...
@@ -28,24 +28,25 @@
...
@@ -28,24 +28,25 @@
"author"
:
"Nanahira <nanahira@momobako.com>"
,
"author"
:
"Nanahira <nanahira@momobako.com>"
,
"license"
:
"
MIT
"
,
"license"
:
"
MIT
"
,
"devDependencies"
:
{
"devDependencies"
:
{
"
@koishijs/plugin-adapter-onebot
"
:
"
^4.0.0-beta.
0
"
,
"
@koishijs/plugin-adapter-onebot
"
:
"
^4.0.0-beta.
2
"
,
"
@types/node
"
:
"
^16.11.
7
"
,
"
@types/node
"
:
"
^16.11.
9
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.33.0
"
,
"
@typescript-eslint/eslint-plugin
"
:
"
^4.33.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.33.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.33.0
"
,
"
eslint
"
:
"
^7.32.0
"
,
"
eslint
"
:
"
^7.32.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-config-prettier
"
:
"
^8.3.0
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
"
eslint-plugin-prettier
"
:
"
^3.4.1
"
,
"
koishi
"
:
"
^4.0.0-beta.
1
"
,
"
koishi
"
:
"
^4.0.0-beta.
2
"
,
"
prettier
"
:
"
^2.4.1
"
,
"
prettier
"
:
"
^2.4.1
"
,
"
typescript
"
:
"
^4.
4.4
"
,
"
typescript
"
:
"
^4.
5.2
"
,
"
ws
"
:
"
^8.2.3
"
"
ws
"
:
"
^8.2.3
"
},
},
"peerDependencies"
:
{
"peerDependencies"
:
{
"
koishi
"
:
"
^4.0.0-beta.
1
"
"
koishi
"
:
"
^4.0.0-beta.
2
"
},
},
"dependencies"
:
{
"dependencies"
:
{
"
koishi-utils-schemagen
"
:
"
^1.1.9
"
,
"
reflect-metadata
"
:
"
^0.1.13
"
,
"
reflect-metadata
"
:
"
^0.1.13
"
,
"
typed-reflector
"
:
"
^1.0.4
"
"
schemastery
"
:
"
^1.0.0
"
,
"
schemastery-gen
"
:
"
^1.0.1
"
,
"
typed-reflector
"
:
"
^1.0.5
"
}
}
}
}
src/decorators.ts
View file @
241407ea
...
@@ -225,8 +225,7 @@ export const InjectContext = (select?: Selection) =>
...
@@ -225,8 +225,7 @@ export const InjectContext = (select?: Selection) =>
}
}
});
});
export
const
InjectApp
=
()
=>
InjectSystem
((
obj
)
=>
obj
.
__ctx
.
app
);
export
const
InjectApp
=
()
=>
InjectSystem
((
obj
)
=>
obj
.
__ctx
.
app
);
export
const
InjectConfig
=
(
raw
=
false
)
=>
export
const
InjectConfig
=
()
=>
InjectSystem
((
obj
)
=>
obj
.
__config
);
InjectSystem
((
obj
)
=>
(
raw
?
obj
.
__rawConfig
:
obj
.
__config
));
export
const
InjectLogger
=
(
name
?:
string
)
=>
export
const
InjectLogger
=
(
name
?:
string
)
=>
InjectSystem
((
obj
,
config
)
=>
InjectSystem
((
obj
,
config
)
=>
obj
.
__ctx
.
logger
(
obj
.
__ctx
.
logger
(
...
...
src/register.ts
View file @
241407ea
...
@@ -15,7 +15,6 @@ import {
...
@@ -15,7 +15,6 @@ import {
OnContextFunction
,
OnContextFunction
,
Type
,
Type
,
}
from
'
./def
'
;
}
from
'
./def
'
;
import
{
schemaFromClass
,
schemaTransform
}
from
'
koishi-utils-schemagen
'
;
import
{
reflector
}
from
'
./meta/meta-fetch
'
;
import
{
reflector
}
from
'
./meta/meta-fetch
'
;
import
{
applySelector
}
from
'
./utility/utility
'
;
import
{
applySelector
}
from
'
./utility/utility
'
;
...
@@ -27,7 +26,6 @@ export interface KoishiPluginRegistrationOptions<T = any> {
...
@@ -27,7 +26,6 @@ export interface KoishiPluginRegistrationOptions<T = any> {
export
interface
PluginClass
<
T
=
any
>
{
export
interface
PluginClass
<
T
=
any
>
{
__ctx
:
Context
;
__ctx
:
Context
;
__config
:
T
;
__config
:
T
;
__rawConfig
:
T
;
__pluginOptions
:
KoishiPluginRegistrationOptions
<
T
>
;
__pluginOptions
:
KoishiPluginRegistrationOptions
<
T
>
;
}
}
...
@@ -51,16 +49,6 @@ function getContextFromFilters(ctx: Context, filters: OnContextFunction[]) {
...
@@ -51,16 +49,6 @@ function getContextFromFilters(ctx: Context, filters: OnContextFunction[]) {
return
targetCtx
;
return
targetCtx
;
}
}
function
getSchemaFromOption
<
T
>
(
schema
:
Schema
<
T
>
|
Type
<
T
>
):
Schema
<
T
>
{
if
(
!
schema
)
{
return
;
}
if
(
typeof
schema
!==
'
function
'
)
{
return
schema
;
}
return
schemaFromClass
(
schema
);
}
export
function
KoishiPlugin
<
T
=
any
>
(
export
function
KoishiPlugin
<
T
=
any
>
(
options
:
KoishiPluginRegistrationOptions
<
T
>
=
{},
options
:
KoishiPluginRegistrationOptions
<
T
>
=
{},
)
{
)
{
...
@@ -68,12 +56,9 @@ export function KoishiPlugin<T = any>(
...
@@ -68,12 +56,9 @@ export function KoishiPlugin<T = any>(
C
extends
{
new
(...
args
:
any
[]):
any
;
schema
?:
Schema
;
name
?:
string
}
C
extends
{
new
(...
args
:
any
[]):
any
;
schema
?:
Schema
;
name
?:
string
}
>
(
originalClass
:
C
)
{
>
(
originalClass
:
C
)
{
const
newClass
=
class
extends
originalClass
implements
PluginClass
{
const
newClass
=
class
extends
originalClass
implements
PluginClass
{
static
schema
=
getSchemaFromOption
(
static
schema
=
options
.
schema
;
options
.
schema
||
originalClass
.
schema
,
);
__ctx
:
Context
;
__ctx
:
Context
;
__config
:
T
;
__config
:
T
;
__rawConfig
:
T
;
__pluginOptions
:
KoishiPluginRegistrationOptions
<
T
>
;
__pluginOptions
:
KoishiPluginRegistrationOptions
<
T
>
;
_handleSystemInjections
()
{
_handleSystemInjections
()
{
...
@@ -323,21 +308,14 @@ export function KoishiPlugin<T = any>(
...
@@ -323,21 +308,14 @@ export function KoishiPlugin<T = any>(
constructor
(...
args
:
any
[])
{
constructor
(...
args
:
any
[])
{
const
originalCtx
:
Context
=
args
[
0
];
const
originalCtx
:
Context
=
args
[
0
];
const
rawC
onfig
=
args
[
1
];
const
c
onfig
=
args
[
1
];
const
contextFilters
=
[
const
contextFilters
=
[
...
reflector
.
getArray
(
KoishiOnContextScope
,
originalClass
),
...
reflector
.
getArray
(
KoishiOnContextScope
,
originalClass
),
...
reflector
.
getArray
(
KoishiOnContextScope
,
newClass
),
...
reflector
.
getArray
(
KoishiOnContextScope
,
newClass
),
];
];
const
ctx
=
getContextFromFilters
(
originalCtx
,
contextFilters
);
const
ctx
=
getContextFromFilters
(
originalCtx
,
contextFilters
);
const
config
=
typeof
options
.
schema
===
'
function
'
?
schemaTransform
(
options
.
schema
,
rawConfig
)
:
options
.
schema
?
Schema
.
validate
(
rawConfig
,
options
.
schema
)
:
rawConfig
;
super
(
ctx
,
config
,
...
args
.
slice
(
2
));
super
(
ctx
,
config
,
...
args
.
slice
(
2
));
this
.
__ctx
=
ctx
;
this
.
__ctx
=
ctx
;
this
.
__rawConfig
=
rawConfig
;
this
.
__config
=
config
;
this
.
__config
=
config
;
this
.
__pluginOptions
=
options
;
this
.
__pluginOptions
=
options
;
this
.
_initializePluginClass
().
then
();
this
.
_initializePluginClass
().
then
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment