@chatluna/patchbay 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +57 -2
- package/lib/apply.d.ts +5 -0
- package/lib/apply.js +59 -0
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +33 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +4 -0
- package/lib/manifest.d.ts +24 -0
- package/lib/manifest.js +13 -0
- package/lib/patch.d.ts +7 -0
- package/lib/patch.js +43 -0
- package/lib/sync.d.ts +31 -0
- package/lib/sync.js +144 -0
- package/package.json +54 -4
- package/patchbay.json +69 -0
- package/patches/@cordisjs+plugin-cli-cordis@1.0.5.patch +56 -0
- package/patches/@cordisjs+plugin-database@4.1.1.patch +15 -0
- package/patches/@cordisjs+plugin-http@1.5.2.patch +13 -0
- package/patches/@cordisjs+plugin-loader@1.0.0-rc.9.patch +82 -0
- package/patches/@cordisjs+plugin-server@1.7.0.patch +22 -0
- package/patches/@cordisjs+unyaml@2.0.3.patch +69 -0
- package/patches/@koishijs+core@4.18.11.patch +1144 -0
- package/patches/@satorijs+core@4.6.1.patch +584 -0
- package/patches/koishi-plugin-adapter-onebot@6.9.5.patch +194 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
diff --git a/lib/index.js b/lib/index.js
|
|
2
|
+
index 47b64a6..46865f0 100644
|
|
3
|
+
--- a/lib/index.js
|
|
4
|
+
+++ b/lib/index.js
|
|
5
|
+
@@ -985,6 +985,10 @@ var Database = class _Database extends Service {
|
|
6
|
+
migrateTasks = /* @__PURE__ */ Object.create(null);
|
|
7
|
+
constructor(ctx) {
|
|
8
|
+
super(ctx, "model");
|
|
9
|
+
+ // chatluna: `database` resolves only after the driver fiber is active, so tables extended while it started were skipped; prepare them now.
|
|
10
|
+
+ ctx.on("internal/service", (name) => {
|
|
11
|
+
+ if (name === "database") this.refresh();
|
|
12
|
+
+ });
|
|
13
|
+
}
|
|
14
|
+
refresh() {
|
|
15
|
+
for (const name in this.tables) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
diff --git a/lib/index.js b/lib/index.js
|
|
2
|
+
index 3acbdff..56c9913 100644
|
|
3
|
+
--- a/lib/index.js
|
|
4
|
+
+++ b/lib/index.js
|
|
5
|
+
@@ -202,7 +202,7 @@ var Http = class _Http extends Service {
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
resolveConfig(init) {
|
|
9
|
+
- return this[Service.resolveConfig](this.config, init);
|
|
10
|
+
+ return { ...this[Service.resolveIntercept](), ...this.config, ...init };
|
|
11
|
+
}
|
|
12
|
+
resolveURL(url, config, isWebSocket = false) {
|
|
13
|
+
try {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
diff --git a/lib/config/group.d.ts b/lib/config/group.d.ts
|
|
2
|
+
index 2ae7a04..0ade21f 100644
|
|
3
|
+
--- a/lib/config/group.d.ts
|
|
4
|
+
+++ b/lib/config/group.d.ts
|
|
5
|
+
@@ -5,6 +5,7 @@ export declare class EntryGroup {
|
|
6
|
+
ctx: Context;
|
|
7
|
+
tree: EntryTree;
|
|
8
|
+
static readonly key: unique symbol;
|
|
9
|
+
+ static readonly prelude: unique symbol;
|
|
10
|
+
data: EntryOptions[];
|
|
11
|
+
constructor(ctx: Context, tree: EntryTree);
|
|
12
|
+
get context(): Context;
|
|
13
|
+
diff --git a/lib/index.js b/lib/index.js
|
|
14
|
+
index 1e2197d..688f658 100644
|
|
15
|
+
--- a/lib/index.js
|
|
16
|
+
+++ b/lib/index.js
|
|
17
|
+
@@ -175,6 +175,7 @@ var EntryGroup = class {
|
|
18
|
+
__name(this, "EntryGroup");
|
|
19
|
+
}
|
|
20
|
+
static key = /* @__PURE__ */ Symbol.for("cordis.group");
|
|
21
|
+
+ static prelude = /* @__PURE__ */ Symbol.for("cordis.loader.prelude");
|
|
22
|
+
data = [];
|
|
23
|
+
get context() {
|
|
24
|
+
return this.ctx;
|
|
25
|
+
@@ -230,13 +231,33 @@ var EntryGroup = class {
|
|
26
|
+
const oldMap = Object.fromEntries(oldConfig.map((options) => [options?.id, options]));
|
|
27
|
+
const newMap = Object.fromEntries(config.map((options) => [options?.id ?? /* @__PURE__ */ Symbol("anonymous"), options]));
|
|
28
|
+
const ids = Reflect.ownKeys({ ...oldMap, ...newMap });
|
|
29
|
+
+ for (const id of ids) {
|
|
30
|
+
+ if (!newMap[id]) this.remove(id);
|
|
31
|
+
+ }
|
|
32
|
+
+ const prelude = new Set();
|
|
33
|
+
+ // Sequential: a CJS require() of an ESM module a parallel import() is still loading throws ERR_REQUIRE_ESM_RACE_CONDITION.
|
|
34
|
+
+ for (const options of config) {
|
|
35
|
+
+ if (options.disabled) continue;
|
|
36
|
+
+ let plugin;
|
|
37
|
+
+ try {
|
|
38
|
+
+ plugin = this.ctx.loader.unwrapExports(await this.tree.import(options.name));
|
|
39
|
+
+ } catch {
|
|
40
|
+
+ // Entry.init owns import-failure reporting with the outer stack.
|
|
41
|
+
+ continue;
|
|
42
|
+
+ }
|
|
43
|
+
+ if (!plugin?.[EntryGroup.prelude]) continue;
|
|
44
|
+
+ prelude.add(options);
|
|
45
|
+
+ const id = await this.create(options);
|
|
46
|
+
+ // group.create returns the fully qualified id; resolve() walks subtrees.
|
|
47
|
+
+ const fiber = this.ctx.loader.resolve(id)?.fiber;
|
|
48
|
+
+ await fiber?.await();
|
|
49
|
+
+ if (fiber?.state !== 2) throw new Error(`prelude entry ${id} is not active`);
|
|
50
|
+
+ }
|
|
51
|
+
await Promise.all(ids.map(async (id) => {
|
|
52
|
+
- if (newMap[id]) {
|
|
53
|
+
+ if (newMap[id] && !prelude.has(newMap[id])) {
|
|
54
|
+
await this.create(newMap[id]).catch((error) => {
|
|
55
|
+
this.ctx.logger.error(error);
|
|
56
|
+
});
|
|
57
|
+
- } else {
|
|
58
|
+
- this.remove(id);
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
@@ -864,14 +885,18 @@ var Loader = class extends EntryTree {
|
|
63
|
+
if (!fiber.entry || fiber.parent.fiber?.entry === fiber.entry) return config2;
|
|
64
|
+
sources.set(fiber, config2);
|
|
65
|
+
if (fiber.runtime.callback[EntryGroup.key]) return config2;
|
|
66
|
+
- return interpolate(fiber.ctx, config2);
|
|
67
|
+
+ const holder = { value: interpolate(fiber.ctx, config2) };
|
|
68
|
+
+ this.ctx.emit("loader/resolve-config", fiber.entry, holder);
|
|
69
|
+
+ return holder.value;
|
|
70
|
+
});
|
|
71
|
+
ctx.on("internal/commit", (fiber, config2) => {
|
|
72
|
+
if (!fiber.entry || fiber.parent.fiber?.entry === fiber.entry) return;
|
|
73
|
+
const unparse = fiber.runtime?.Config?.["simplify"];
|
|
74
|
+
const { entry } = fiber;
|
|
75
|
+
const legacy = { ...entry.options };
|
|
76
|
+
- entry.options.config = unparse ? unparse(config2) : config2;
|
|
77
|
+
+ const holder = { value: unparse ? unparse(config2) : config2 };
|
|
78
|
+
+ this.ctx.emit("loader/persist-config", entry, holder);
|
|
79
|
+
+ entry.options.config = holder.value;
|
|
80
|
+
entry.parent.tree.commit({ id: entry.options.id, group: entry.parent, options: entry.options, legacy });
|
|
81
|
+
});
|
|
82
|
+
ctx.on("internal/update", function(config2, next) {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
diff --git a/lib/index.js b/lib/index.js
|
|
2
|
+
index 4ff0ca1..4886ec6 100644
|
|
3
|
+
--- a/lib/index.js
|
|
4
|
+
+++ b/lib/index.js
|
|
5
|
+
@@ -210,7 +210,7 @@ var Route = class {
|
|
6
|
+
this.server = server;
|
|
7
|
+
this.path = path;
|
|
8
|
+
this.options = options;
|
|
9
|
+
- this.config = server[Server.resolveConfig]();
|
|
10
|
+
+ this.config = server[Server.resolveIntercept]();
|
|
11
|
+
this.fiber = server.ctx.fiber;
|
|
12
|
+
const paths = [path];
|
|
13
|
+
if (this.config.path) paths.unshift(this.config.path);
|
|
14
|
+
@@ -462,7 +462,7 @@ var Server = class _Server extends Service2 {
|
|
15
|
+
yield () => this.ctx.logger?.info(`server closing at %C`, `http://${this.host}:${this.port}`);
|
|
16
|
+
}
|
|
17
|
+
get baseUrl() {
|
|
18
|
+
- const intercept = this[Service2.resolveConfig]();
|
|
19
|
+
+ const intercept = this[Service2.resolveIntercept]();
|
|
20
|
+
const pathPrefix = intercept.path ?? "";
|
|
21
|
+
if (this.config.baseUrl) return this.config.baseUrl + pathPrefix;
|
|
22
|
+
const wildcard = ["0.0.0.0", "::"];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
diff --git a/lib/vite.js b/lib/vite.js
|
|
2
|
+
index b16d836..b1c6380 100644
|
|
3
|
+
--- a/lib/vite.js
|
|
4
|
+
+++ b/lib/vite.js
|
|
5
|
+
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
-var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
@@ -15,10 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
- // If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
- // file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
- // compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
- // "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
@@ -26,16 +21,36 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
25
|
+
// src/vite.ts
|
|
26
|
+
var yaml = __toESM(require("js-yaml"));
|
|
27
|
+
var import_tosource = __toESM(require("tosource"));
|
|
28
|
+
-var import_esbuild = __toESM(require("./esbuild"));
|
|
29
|
+
function unyaml(options = {}) {
|
|
30
|
+
const { filter = /\.ya?ml(?:\?.*)?$/, ...loadOptions } = options;
|
|
31
|
+
return {
|
|
32
|
+
name: "unyaml",
|
|
33
|
+
config() {
|
|
34
|
+
+ // Vite dependency optimization uses Rolldown, not the retired esbuildOptions hook.
|
|
35
|
+
return {
|
|
36
|
+
optimizeDeps: {
|
|
37
|
+
- esbuildOptions: {
|
|
38
|
+
- plugins: [(0, import_esbuild.default)({ filter, ...loadOptions })]
|
|
39
|
+
+ rolldownOptions: {
|
|
40
|
+
+ plugins: [{
|
|
41
|
+
+ name: "unyaml",
|
|
42
|
+
+ async resolveId(id, importer) {
|
|
43
|
+
+ if (!filter.test(id)) return;
|
|
44
|
+
+ // The scanner resolves nothing itself: a relative id has to be joined to its importer, not the process cwd.
|
|
45
|
+
+ if (id.startsWith(".") && importer) {
|
|
46
|
+
+ const path = require("node:path");
|
|
47
|
+
+ return path.resolve(path.dirname(importer), id);
|
|
48
|
+
+ }
|
|
49
|
+
+ const resolved = await this.resolve(id, importer, { skipSelf: true });
|
|
50
|
+
+ return resolved?.id ?? id;
|
|
51
|
+
+ },
|
|
52
|
+
+ async load(id) {
|
|
53
|
+
+ if (!filter.test(id)) return;
|
|
54
|
+
+ const text = await import("node:fs/promises").then((m) => m.readFile(id, "utf8"));
|
|
55
|
+
+ const data = yaml.load(text, { ...loadOptions, filename: id });
|
|
56
|
+
+ return {
|
|
57
|
+
+ code: `export default ${(0, import_tosource.default)(data)}`
|
|
58
|
+
+ };
|
|
59
|
+
+ }
|
|
60
|
+
+ }]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
@@ -50,5 +65,4 @@ function unyaml(options = {}) {
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
-__name(unyaml, "unyaml");
|
|
69
|
+
module.exports = unyaml;
|