@zhin.js/core 1.1.39 → 1.1.41
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/lib/built/ai-trigger.js +2 -2
- package/lib/built/html-segment-fallback.d.ts +4 -2
- package/lib/built/html-segment-fallback.js +1 -1
- package/lib/built/interactive-segments/resolve.js +1 -1
- package/lib/built/interactive-segments/types.d.ts +2 -2
- package/lib/built/interactive-segments/types.js +22 -2
- package/lib/built/outbound-content-arrays.d.ts +4 -0
- package/lib/built/outbound-content-arrays.js +32 -0
- package/lib/built/outbound-media-utils.d.ts +5 -3
- package/lib/built/outbound-media-utils.js +5 -3
- package/lib/built/segment-contract/assert.js +5 -0
- package/lib/built/segment-contract/json-schema.d.ts +1 -1
- package/lib/built/segment-contract/json-schema.js +30 -2
- package/lib/feature/component.d.ts +1 -0
- package/lib/feature/component.js +1 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +2 -1
- package/lib/jsx-dev-runtime.d.ts +1 -2
- package/lib/jsx-dev-runtime.js +1 -2
- package/lib/jsx-runtime.d.ts +1 -12
- package/lib/jsx-runtime.js +1 -10
- package/lib/jsx.d.ts +1 -30
- package/lib/jsx.js +1 -93
- package/lib/message.d.ts +0 -11
- package/lib/plugin-runtime/im/contracts.d.ts +14 -6
- package/lib/plugin-runtime/im/contracts.js +28 -6
- package/lib/plugin-runtime/im/endpoint-runtime.d.ts +6 -1
- package/lib/plugin-runtime/im/endpoint-runtime.js +27 -5
- package/lib/plugin-runtime/im/inbound-runtime.js +30 -6
- package/lib/plugin-runtime/im/message-dispatcher.js +28 -5
- package/lib/plugin-runtime/im/outbound-delivery-runtime.d.ts +1 -1
- package/lib/plugin-runtime/im/outbound-delivery-runtime.js +90 -29
- package/lib/plugin-runtime/im/outbound-renderer.d.ts +7 -2
- package/lib/plugin-runtime/im/outbound-renderer.js +31 -6
- package/lib/plugin-runtime/im/outbound-segments.d.ts +7 -0
- package/lib/plugin-runtime/im/outbound-segments.js +33 -6
- package/lib/plugin-runtime/im/runtime-middleware.js +1 -1
- package/lib/types.d.ts +5 -7
- package/lib/utils.d.ts +4 -4
- package/lib/utils.js +9 -17
- package/package.json +16 -14
- package/lib/component.d.ts +0 -26
- package/lib/component.js +0 -583
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MessageChannel
|
|
1
|
+
import type { MessageChannel } from './message.js';
|
|
2
2
|
import type { Message } from './plugin-runtime/im/contracts.js';
|
|
3
3
|
import { SystemLog } from './models/system-log.js';
|
|
4
4
|
import { User } from './models/user.js';
|
|
@@ -16,11 +16,8 @@ export type ObjectItem<T extends object> = T[keyof T];
|
|
|
16
16
|
/**
|
|
17
17
|
* 消息段结构,支持 text/image/at/face 等类型
|
|
18
18
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
data: Record<string, any>;
|
|
22
|
-
}
|
|
23
|
-
export type MessageElement = MessageSegment | MessageComponent<any>;
|
|
19
|
+
export type { Segment as MessageSegment } from './built/segment-contract/types.js';
|
|
20
|
+
export type MessageElement = import('./built/segment-contract/types.js').Segment;
|
|
24
21
|
/**
|
|
25
22
|
* 单个或数组类型
|
|
26
23
|
*/
|
|
@@ -28,7 +25,8 @@ export type MaybeArray<T> = T | T[];
|
|
|
28
25
|
/**
|
|
29
26
|
* 消息发送内容类型
|
|
30
27
|
*/
|
|
31
|
-
export type SendContent
|
|
28
|
+
export type { SendContent } from './plugin-runtime/im/contracts.js';
|
|
29
|
+
import type { SendContent } from './plugin-runtime/im/contracts.js';
|
|
32
30
|
/** 可选:编辑已发送消息(交互式棋盘更新) */
|
|
33
31
|
export interface EditMessageOptions {
|
|
34
32
|
messageId: string;
|
package/lib/utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* IM-specific utilities (compose, segment) remain here.
|
|
6
6
|
*/
|
|
7
7
|
export { evaluate, execute, getValueWithRuntime, compiler, remove, isEmpty, Time, supportedPluginExtensions, resolveEntry, sleep, } from '@zhin.js/kernel';
|
|
8
|
-
import {
|
|
8
|
+
import { MessageElement, MessageMiddleware } from "./types.js";
|
|
9
9
|
import type { Message } from "./plugin-runtime/im/contracts.js";
|
|
10
10
|
import { KeyboardSegment } from "./built/interactive-segments/keyboard-segment.js";
|
|
11
11
|
import { ButtonSpec, type KeyboardRowInput } from "./built/interactive-segments/button-spec.js";
|
|
@@ -126,7 +126,7 @@ export declare namespace segment {
|
|
|
126
126
|
function keyboard(rows: KeyboardRowInput[], options?: {
|
|
127
127
|
fallback?: KeyboardFallback;
|
|
128
128
|
}): KeyboardSegment;
|
|
129
|
-
function from(content:
|
|
130
|
-
function raw(content:
|
|
131
|
-
function toString(content:
|
|
129
|
+
function from(content: string | MessageElement | readonly (string | MessageElement)[]): MessageElement[];
|
|
130
|
+
function raw(content: string | MessageElement | readonly (string | MessageElement)[]): string;
|
|
131
|
+
function toString(content: string | MessageElement | readonly (string | MessageElement)[]): string;
|
|
132
132
|
}
|
package/lib/utils.js
CHANGED
|
@@ -125,12 +125,11 @@ export function segment(type, data) {
|
|
|
125
125
|
}
|
|
126
126
|
segment.keyboard = keyboard;
|
|
127
127
|
function from(content) {
|
|
128
|
-
|
|
129
|
-
content = [content];
|
|
128
|
+
const items = Array.isArray(content) ? content : [content];
|
|
130
129
|
const toString = (template) => {
|
|
131
130
|
if (typeof template !== "string")
|
|
132
131
|
return [template];
|
|
133
|
-
/** ReDoS 防护:仅约束 segment.from
|
|
132
|
+
/** ReDoS 防护:仅约束 segment.from 的字符串模板解析,不是附件大小上限;结构化段出站直接走统一渲染链路,避免文本往返 */
|
|
134
133
|
const MAX_TEMPLATE_LENGTH = 400000;
|
|
135
134
|
if (template.length > MAX_TEMPLATE_LENGTH) {
|
|
136
135
|
throw new Error(`Template too large: ${template.length} > ${MAX_TEMPLATE_LENGTH}`);
|
|
@@ -214,39 +213,32 @@ export function segment(type, data) {
|
|
|
214
213
|
}
|
|
215
214
|
return result;
|
|
216
215
|
};
|
|
217
|
-
return
|
|
216
|
+
return items.reduce((result, item) => {
|
|
218
217
|
result.push(...toString(item));
|
|
219
218
|
return result;
|
|
220
219
|
}, []);
|
|
221
220
|
}
|
|
222
221
|
segment.from = from;
|
|
223
222
|
function raw(content) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return content
|
|
223
|
+
const items = Array.isArray(content) ? content : [content];
|
|
224
|
+
return items
|
|
227
225
|
.map((item) => {
|
|
228
226
|
if (typeof item === "string")
|
|
229
227
|
return item;
|
|
230
228
|
const { type, data } = item;
|
|
231
|
-
if (typeof type === "function") {
|
|
232
|
-
return `{${type.name || "Component"}}`;
|
|
233
|
-
}
|
|
234
229
|
return formatSegmentPreview({ type, data: data ?? {} });
|
|
235
230
|
})
|
|
236
231
|
.join("");
|
|
237
232
|
}
|
|
238
233
|
segment.raw = raw;
|
|
239
234
|
function toString(content) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return content
|
|
235
|
+
const items = Array.isArray(content) ? content : [content];
|
|
236
|
+
return items
|
|
243
237
|
.map((item) => {
|
|
244
238
|
if (typeof item === "string")
|
|
245
239
|
return item;
|
|
246
|
-
|
|
247
|
-
const
|
|
248
|
-
if (typeof type === "function")
|
|
249
|
-
type = type.name;
|
|
240
|
+
const { type } = item;
|
|
241
|
+
const data = item.data;
|
|
250
242
|
if (type === "text")
|
|
251
243
|
return data.text;
|
|
252
244
|
const keys = Object.keys(data).filter((key) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.41",
|
|
4
4
|
"description": "Zhin机器人核心框架",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -68,27 +68,29 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"qrcode": "^1.5.4",
|
|
70
70
|
"segment-matcher": "^1.0.5",
|
|
71
|
-
"@zhin.js/adapter": "1.1.
|
|
72
|
-
"@zhin.js/command": "1.1.
|
|
73
|
-
"@zhin.js/component": "1.1.
|
|
71
|
+
"@zhin.js/adapter": "1.1.17",
|
|
72
|
+
"@zhin.js/command": "1.1.5",
|
|
73
|
+
"@zhin.js/component": "1.1.4",
|
|
74
74
|
"@zhin.js/database": "1.1.2",
|
|
75
|
-
"@zhin.js/handler": "1.1.
|
|
76
|
-
"@zhin.js/im-contract": "1.1.
|
|
75
|
+
"@zhin.js/handler": "1.1.3",
|
|
76
|
+
"@zhin.js/im-contract": "1.1.3",
|
|
77
77
|
"@zhin.js/interaction": "1.1.0",
|
|
78
|
-
"@zhin.js/kernel": "1.1.
|
|
78
|
+
"@zhin.js/kernel": "1.1.2",
|
|
79
79
|
"@zhin.js/logger": "1.1.1",
|
|
80
|
-
"@zhin.js/middleware": "1.1.
|
|
81
|
-
"@zhin.js/permission": "1.1.
|
|
82
|
-
"@zhin.js/plugin-runtime": "1.1.
|
|
83
|
-
"@zhin.js/schedule-feature": "1.1.
|
|
84
|
-
"@zhin.js/schema": "1.1.1"
|
|
80
|
+
"@zhin.js/middleware": "1.1.4",
|
|
81
|
+
"@zhin.js/permission": "1.1.4",
|
|
82
|
+
"@zhin.js/plugin-runtime": "1.1.12",
|
|
83
|
+
"@zhin.js/schedule-feature": "1.1.3",
|
|
84
|
+
"@zhin.js/schema": "1.1.1",
|
|
85
|
+
"@zhin.js/jsx": "1.1.1",
|
|
86
|
+
"@zhin.js/feature-kit": "1.1.3"
|
|
85
87
|
},
|
|
86
88
|
"devDependencies": {
|
|
87
89
|
"@types/node": "^26.1.2",
|
|
88
90
|
"@types/qrcode": "^1.5.6",
|
|
89
91
|
"ajv": "8.18.0",
|
|
90
92
|
"typescript": "^6.0.3",
|
|
91
|
-
"@zhin.js/ai": "1.1.
|
|
93
|
+
"@zhin.js/ai": "1.1.37"
|
|
92
94
|
},
|
|
93
95
|
"repository": {
|
|
94
96
|
"type": "git",
|
|
@@ -143,7 +145,7 @@
|
|
|
143
145
|
"plugins": []
|
|
144
146
|
},
|
|
145
147
|
"scripts": {
|
|
146
|
-
"build": "tsc",
|
|
148
|
+
"build": "rimraf lib && tsc",
|
|
147
149
|
"clean": "rimraf lib"
|
|
148
150
|
}
|
|
149
151
|
}
|
package/lib/component.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Dict, SendContent, SendOptions } from './types.js';
|
|
2
|
-
export declare const CapWithChild: unique symbol;
|
|
3
|
-
export declare const CapWithClose: unique symbol;
|
|
4
|
-
export type Component<P = any> = {
|
|
5
|
-
(props: P, context: ComponentContext): SendContent | Promise<SendContent>;
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
export interface ComponentContext {
|
|
9
|
-
render: (template: string, context?: Partial<ComponentContext>) => Promise<SendContent>;
|
|
10
|
-
props: Readonly<Dict>;
|
|
11
|
-
parent?: Readonly<ComponentContext>;
|
|
12
|
-
root: string;
|
|
13
|
-
children?: string;
|
|
14
|
-
getValue: (template: string) => any;
|
|
15
|
-
compile: (template: string) => string;
|
|
16
|
-
}
|
|
17
|
-
export declare function defineComponent<P = any>(component: Component<P>, name?: string): Component<P>;
|
|
18
|
-
export declare function matchComponent<P = any>(comp: Component<P>, template: string): string;
|
|
19
|
-
export declare function getProps<P = any>(comp: Component<P>, template: string, context?: ComponentContext): P;
|
|
20
|
-
export declare function createComponentContext(props?: Dict, parent?: ComponentContext, root?: string): ComponentContext;
|
|
21
|
-
export declare function renderComponent<P = any>(component: Component<P>, template: string, context: ComponentContext): Promise<SendContent>;
|
|
22
|
-
export declare function renderComponents(componentMap: Map<string, Component>, options: SendOptions, customContext?: ComponentContext): Promise<SendOptions>;
|
|
23
|
-
export declare const Fragment: Component<{
|
|
24
|
-
children?: SendContent;
|
|
25
|
-
}>;
|
|
26
|
-
export declare const Fetch: Component<any>;
|