Commit 1474b71d authored by nanahira's avatar nanahira

change classification

parent a13fa723
import { defaultRegistrar } from '../registrar'; import { defaultRegistrar } from '../registrar';
export const { Isolate, UsingService } = defaultRegistrar.scopeDecorators(); export const { Isolate, UsingService, If, For } =
defaultRegistrar.scopeDecorators();
export const { UsePlugin, Apply } = defaultRegistrar.methodDecorators(); export const { UsePlugin, Apply } = defaultRegistrar.methodDecorators();
...@@ -5,8 +5,6 @@ import { PluginRegistrar } from '../plugin-def'; ...@@ -5,8 +5,6 @@ import { PluginRegistrar } from '../plugin-def';
const pluginDecorators = defaultRegistrar.pluginDecorators(); const pluginDecorators = defaultRegistrar.pluginDecorators();
export const { export const {
If,
For,
PluginName, PluginName,
PluginSchema, PluginSchema,
Reusable, Reusable,
......
...@@ -453,6 +453,24 @@ export class Registrar<Ctx extends Context> { ...@@ -453,6 +453,24 @@ export class Registrar<Ctx extends Context> {
scopeDecorators() { scopeDecorators() {
return { return {
If: <T>(
func: Condition<boolean, T, [Record<string, any>]>,
): MethodDecorator =>
this.metadata.append('CordisControl', {
type: 'if',
condition: func,
}),
For: <T>(
func: Condition<
Iterable<Record<string, any>>,
T,
[Record<string, any>]
>,
): MethodDecorator =>
this.metadata.append('CordisControl', {
type: 'for',
condition: func,
}),
Isolate: (...services: string[]) => Isolate: (...services: string[]) =>
this.decorateTransformer((ctx, r) => ctx.isolate(r(services))), this.decorateTransformer((ctx, r) => ctx.isolate(r(services))),
UsingService: ( UsingService: (
...@@ -488,24 +506,6 @@ export class Registrar<Ctx extends Context> { ...@@ -488,24 +506,6 @@ export class Registrar<Ctx extends Context> {
this.metadata.set('CordisPluginReusable', reusable), this.metadata.set('CordisPluginReusable', reusable),
Fork: (fork: PluginRegistrar.PluginClass<Ctx>) => Fork: (fork: PluginRegistrar.PluginClass<Ctx>) =>
this.metadata.set('CordisPluginFork', fork), this.metadata.set('CordisPluginFork', fork),
If: <T>(
func: Condition<boolean, T, [Record<string, any>]>,
): MethodDecorator =>
this.metadata.append('CordisControl', {
type: 'if',
condition: func,
}),
For: <T>(
func: Condition<
Iterable<Record<string, any>>,
T,
[Record<string, any>]
>,
): MethodDecorator =>
this.metadata.append('CordisControl', {
type: 'for',
condition: func,
}),
Provide: ( Provide: (
name: string, name: string,
options?: Registrar.ProvideOptions, options?: Registrar.ProvideOptions,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment