New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@koishijs/loader

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koishijs/loader - npm Package Compare versions

Comparing version 2.4.3 to 2.5.0

1

lib/browser.d.ts

@@ -13,4 +13,5 @@ import { Loader } from './shared';

writeConfig(): void;
resolve(name: string): Promise<string>;
resolvePlugin(name: string): Promise<any>;
fullReload(): void;
}

7

lib/node.d.ts

@@ -1,2 +0,2 @@

import { Context } from 'koishi';
import { Context } from '@koishijs/core';
import { Loader } from './shared';

@@ -10,10 +10,13 @@ import ns from 'ns-require';

scope: ns.Scope;
ctxData: {
env: NodeJS.ProcessEnv;
};
constructor(filename?: string);
private checkWritable;
private findConfig;
interpolate(source: any): any;
readConfig(): Context.Config;
writeConfig(): void;
resolve(name: string): Promise<string>;
resolvePlugin(name: string): Promise<any>;
fullReload(code?: number): void;
}

@@ -35,3 +35,3 @@ var __create = Object.create;

var import_path = require("path");
var import_koishi = require("koishi");
var import_core = require("@koishijs/core");
var import_shared = require("./shared");

@@ -42,6 +42,3 @@ var dotenv = __toESM(require("dotenv"));

__reExport(node_exports, require("./shared"), module.exports);
var logger = new import_koishi.Logger("app");
var context = {
env: process.env
};
var logger = new import_core.Logger("app");
var writableExts = [".json", ".yml", ".yaml"];

@@ -54,2 +51,5 @@ var supportedExts = [".js", ".json", ".ts", ".coffee", ".yaml", ".yml"];

this.baseDir = process.cwd();
this.ctxData = {
env: process.env
};
if (filename) {

@@ -104,15 +104,2 @@ filename = (0, import_path.resolve)(this.baseDir, filename);

}
interpolate(source) {
if (!this.writable)
return source;
if (typeof source === "string") {
return (0, import_koishi.interpolate)(source, context, /\$\{\{(.+?)\}\}/g);
} else if (!source || typeof source !== "object") {
return source;
} else if (Array.isArray(source)) {
return source.map((item) => this.interpolate(item));
} else {
return (0, import_koishi.valueMap)(source, (item) => this.interpolate(item));
}
}
readConfig() {

@@ -128,3 +115,3 @@ dotenv.config({ path: this.envfile });

}
return new import_koishi.Context.Config(this.interpolate(this.config));
return new import_core.Context.Config(this.interpolate(this.config));
}

@@ -142,2 +129,5 @@ writeConfig() {

}
async resolve(name) {
return this.scope.resolve(name);
}
async resolvePlugin(name) {

@@ -144,0 +134,0 @@ var _a;

@@ -1,4 +0,4 @@

import { Context, Dict, SharedData } from 'koishi';
import { Context, Dict, EnvData } from '@koishijs/core';
export * from './utils';
declare module 'koishi' {
declare module '@koishijs/core' {
interface Context {

@@ -26,3 +26,4 @@ loader: Loader;

static readonly exitCode = 51;
envData: SharedData;
envData: EnvData;
ctxData: {};
app: Context;

@@ -39,2 +40,3 @@ baseDir: string;

abstract writeConfig(): void;
abstract resolve(name: string): Promise<string>;
abstract resolvePlugin(name: string): Promise<any>;

@@ -44,2 +46,3 @@ abstract fullReload(): void;

private forkPlugin;
isTruthyLike(expr: any): boolean;
reloadPlugin(parent: Context, key: string, config: any): Promise<import("cordis").ForkScope<Context>>;

@@ -46,0 +49,0 @@ unloadPlugin(ctx: Context, key: string): void;

@@ -25,3 +25,2 @@ var __defProp = Object.defineProperty;

Modifier: () => Modifier,
isDefiniteFalsy: () => isDefiniteFalsy,
patch: () => patch,

@@ -32,10 +31,6 @@ select: () => select,

module.exports = __toCommonJS(shared_exports);
var import_koishi2 = require("koishi");
var import_core2 = require("@koishijs/core");
// koishi/packages/loader/src/utils.ts
var import_koishi = require("koishi");
function isDefiniteFalsy(value) {
return !(0, import_koishi.isNullable)(value) && !value;
}
__name(isDefiniteFalsy, "isDefiniteFalsy");
var import_core = require("@koishijs/core");
function unwrapExports(module2) {

@@ -69,3 +64,3 @@ return (module2 == null ? void 0 : module2.default) || module2;

} else if (value !== void 0) {
ctx = ctx[type](...(0, import_koishi.makeArray)(value).map((item) => "" + item));
ctx = ctx[type](...(0, import_core.makeArray)(value).map((item) => "" + item));
}

@@ -104,4 +99,4 @@ }

var kUpdate = Symbol("update");
import_koishi2.Context.service("loader");
var logger = new import_koishi2.Logger("app");
import_core2.Context.service("loader");
var logger = new import_core2.Logger("app");
var group = {

@@ -137,2 +132,3 @@ name: "group",

constructor() {
this.ctxData = {};
this.suspend = false;

@@ -143,3 +139,13 @@ this.writable = true;

interpolate(source) {
return source;
if (!this.writable)
return source;
if (typeof source === "string") {
return (0, import_core2.interpolate)(source, this.ctxData, /\$\{\{(.+?)\}\}/g);
} else if (!source || typeof source !== "object") {
return source;
} else if (Array.isArray(source)) {
return source.map((item) => this.interpolate(item));
} else {
return (0, import_core2.valueMap)(source, (item) => this.interpolate(item));
}
}

@@ -150,9 +156,14 @@ async forkPlugin(name, config, parent) {

return;
(0, import_koishi2.resolveConfig)(plugin, config);
(0, import_core2.resolveConfig)(plugin, config);
return parent.plugin(plugin, this.interpolate(config));
}
isTruthyLike(expr) {
if ((0, import_core2.isNullable)(expr))
return true;
return !!this.interpolate(`\${{ ${expr} }}`);
}
async reloadPlugin(parent, key, config) {
let fork = parent.state[_Loader.kRecord][key];
if (fork) {
if (isDefiniteFalsy(config == null ? void 0 : config.$if)) {
if (!this.isTruthyLike(config == null ? void 0 : config.$if)) {
this.unloadPlugin(parent, key);

@@ -168,3 +179,3 @@ return;

} else {
if (isDefiniteFalsy(config == null ? void 0 : config.$if))
if (!this.isTruthyLike(config == null ? void 0 : config.$if))
return;

@@ -197,6 +208,6 @@ logger.info(`apply plugin %c`, key);

async createApp() {
const app = this.app = new import_koishi2.Context(this.interpolate(this.config));
const app = this.app = new import_core2.Context(this.interpolate(this.config));
app.loader = this;
app.baseDir = this.baseDir;
app.shared = app.envData = this.envData;
app.envData = this.envData;
app.state[_Loader.kRecord] = /* @__PURE__ */ Object.create(null);

@@ -249,3 +260,2 @@ const fork = await this.reloadPlugin(app, "group:entry", this.config.plugins);

Modifier,
isDefiniteFalsy,
patch,

@@ -252,0 +262,0 @@ select,

@@ -1,3 +0,2 @@

import { Context, MaybeArray } from 'koishi';
export declare function isDefiniteFalsy(value: any): boolean;
import { Context, MaybeArray } from '@koishijs/core';
export declare function unwrapExports(module: any): any;

@@ -4,0 +3,0 @@ export interface Modifier {

{
"name": "@koishijs/loader",
"description": "Config Loader for Koishi",
"version": "2.4.3",
"version": "2.5.0",
"main": "lib/node.js",

@@ -41,8 +41,8 @@ "typings": "lib/index.d.ts",

"peerDependencies": {
"koishi": "^4.10.10"
"@koishijs/core": "^4.11.0"
},
"devDependencies": {
"@koishijs/registry": "^4.2.1",
"@types/js-yaml": "^4.0.5",
"koishi": "^4.10.10"
"@koishijs/core": "^4.11.0",
"@koishijs/registry": "^4.2.7",
"@types/js-yaml": "^4.0.5"
},

@@ -49,0 +49,0 @@ "dependencies": {

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc