@koishijs/loader
Advanced tools
Comparing version 4.0.5 to 4.1.0
/// <reference types="node" /> | ||
import { Context, Dict, ForkScope, Logger } from '@koishijs/core'; | ||
import { Context, Dict, EffectScope, ForkScope, Logger } from '@koishijs/core'; | ||
declare module '@koishijs/core' { | ||
@@ -72,4 +72,5 @@ interface Events { | ||
getRefName(fork: ForkScope): string; | ||
paths(scope: EffectScope, suffix?: string[]): string[]; | ||
createApp(): Promise<Context>; | ||
} | ||
export {}; |
@@ -284,2 +284,19 @@ var __create = Object.create; | ||
} | ||
paths(scope, suffix = []) { | ||
if (scope === scope.parent.scope) { | ||
return [suffix.slice(1).join("/")]; | ||
} | ||
if (scope.runtime === scope) { | ||
return [].concat(...scope.runtime.children.map((child2) => this.paths(child2, suffix))); | ||
} | ||
const child = scope; | ||
scope = scope.parent.scope; | ||
const record = scope[_Loader.kRecord]; | ||
if (!record) | ||
return this.paths(scope, suffix); | ||
const entry = Object.entries(record).find(([, value]) => value === child); | ||
if (!entry) | ||
return []; | ||
return this.paths(scope, [entry[0], ...suffix]); | ||
} | ||
async createApp() { | ||
@@ -286,0 +303,0 @@ new import_core.Logger("app").info("%C", `Koishi/${import_core.version}`); |
{ | ||
"name": "@koishijs/loader", | ||
"description": "Config Loader for Koishi", | ||
"version": "4.0.5", | ||
"version": "4.1.0", | ||
"main": "lib/index.js", | ||
@@ -42,6 +42,6 @@ "module": "lib/shared.mjs", | ||
"peerDependencies": { | ||
"@koishijs/core": "4.13.9" | ||
"@koishijs/core": "4.14.0" | ||
}, | ||
"devDependencies": { | ||
"@koishijs/core": "4.13.9", | ||
"@koishijs/core": "4.14.0", | ||
"@types/js-yaml": "^4.0.5" | ||
@@ -48,0 +48,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
72482
886