@ray-js/t-agent-ui-ray 0.2.3-beta-1 → 0.2.3-beta-3
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/dist/LazyScrollView/LazyItem/index.d.ts +0 -1
- package/dist/LazyScrollView/LazyItem/index.js +6 -12
- package/dist/LazyScrollView/LazyItem/index.tyml +7 -7
- package/dist/LazyScrollView/get-visible-items.sjs +53 -0
- package/dist/LazyScrollView/index.d.ts +1 -0
- package/dist/LazyScrollView/index.js +18 -1
- package/dist/LazyScrollView/index.tyml +2 -0
- package/dist/LazyScrollView/lazy-item-context.sjs +90 -0
- package/dist/LazyScrollView/lazy-scroll-view.sjs +20 -256
- package/dist/LazyScrollView/ordered-list.sjs +57 -0
- package/dist/LazyScrollView/scroll-view-context.sjs +237 -0
- package/dist/MessageActionBar/back.svg +1 -0
- package/dist/MessageActionBar/delete.svg +1 -0
- package/dist/MessageActionBar/index.d.ts +4 -0
- package/dist/MessageActionBar/index.js +79 -0
- package/dist/MessageActionBar/index.less +68 -0
- package/dist/MessageInput/MessageInputAIStream/index.js +4 -3
- package/dist/MessageInput/MessageInputAssistant/asr.d.ts +30 -0
- package/dist/MessageInput/MessageInputAssistant/asr.js +126 -0
- package/dist/MessageInput/MessageInputAssistant/index.js +5 -2
- package/dist/MessageInput/MessageInputAssistant/useAsrInput.js +1 -1
- package/dist/MessageList/PartRender.d.ts +15 -0
- package/dist/MessageList/PartRender.js +25 -0
- package/dist/MessageList/ScrollBottomView.d.ts +1 -0
- package/dist/MessageList/ScrollBottomView.js +4 -0
- package/dist/MessageList/index.d.ts +3 -5
- package/dist/MessageList/index.js +30 -47
- package/dist/MessageList/index.less +2 -22
- package/dist/MessageRender/index.d.ts +1 -2
- package/dist/MessageRender/index.js +0 -4
- package/dist/hooks/context.js +0 -1
- package/dist/hooks/useLongPress.js +1 -1
- package/dist/i18n/strings.d.ts +48 -16
- package/dist/i18n/strings.js +48 -16
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/utils/abort.d.ts +38 -0
- package/dist/utils/abort.js +177 -0
- package/dist/utils/ttt.d.ts +98 -0
- package/dist/utils/ttt.js +54 -0
- package/package.json +2 -2
- package/dist/LazyScrollView/weak-ref.sjs +0 -45
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ChatContainer from './ChatContainer';
|
|
2
2
|
import MessageInput from './MessageInput';
|
|
3
3
|
import MessageList from './MessageList';
|
|
4
|
+
import MessageActionBar from './MessageActionBar';
|
|
4
5
|
import MessageRender from './MessageRender';
|
|
5
6
|
import TileRender from './TileRender';
|
|
6
7
|
import PrivateImage from './PrivateImage';
|
|
@@ -11,4 +12,4 @@ export * from './contexts';
|
|
|
11
12
|
export * from './renderOption';
|
|
12
13
|
export * from './types';
|
|
13
14
|
export * from './hooks';
|
|
14
|
-
export { ChatContainer, MessageInput, MessageList, MessageRender, MarkdownRender, TileRender, PrivateImage, tileMap, };
|
|
15
|
+
export { ChatContainer, MessageInput, MessageList, MessageRender, MessageActionBar, MarkdownRender, TileRender, PrivateImage, tileMap, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ChatContainer from './ChatContainer';
|
|
2
2
|
import MessageInput from './MessageInput';
|
|
3
3
|
import MessageList from './MessageList';
|
|
4
|
+
import MessageActionBar from './MessageActionBar';
|
|
4
5
|
import MessageRender from './MessageRender';
|
|
5
6
|
import TileRender from './TileRender';
|
|
6
7
|
import PrivateImage from './PrivateImage';
|
|
@@ -11,4 +12,4 @@ export * from './contexts';
|
|
|
11
12
|
export * from './renderOption';
|
|
12
13
|
export * from './types';
|
|
13
14
|
export * from './hooks';
|
|
14
|
-
export { ChatContainer, MessageInput, MessageList, MessageRender, MarkdownRender, TileRender, PrivateImage, tileMap };
|
|
15
|
+
export { ChatContainer, MessageInput, MessageList, MessageRender, MessageActionBar, MarkdownRender, TileRender, PrivateImage, tileMap };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Emitter, EmitterEvent, AbortSignalObject } from '@ray-js/t-agent';
|
|
2
|
+
type EventCallback = (event: EmitterEvent) => void;
|
|
3
|
+
export declare class AbortSignal extends Emitter implements AbortSignalObject {
|
|
4
|
+
aborted: boolean;
|
|
5
|
+
onabort: EventCallback;
|
|
6
|
+
reason: any;
|
|
7
|
+
constructor();
|
|
8
|
+
toString(): string;
|
|
9
|
+
dispatchEvent(event: EmitterEvent): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
|
|
12
|
+
*/
|
|
13
|
+
throwIfAborted(): void;
|
|
14
|
+
/**
|
|
15
|
+
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
|
|
16
|
+
* @param {number} time The "active" time in milliseconds before the returned {@link AbortSignalObject} will abort.
|
|
17
|
+
* The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
|
|
18
|
+
* @returns {AbortSignalObject} The signal will abort with its {@link AbortSignalObject.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
|
|
19
|
+
* or an `AbortError` {@link DOMException} if the operation was user-triggered.
|
|
20
|
+
*/
|
|
21
|
+
static timeout(time: number): AbortSignal;
|
|
22
|
+
/**
|
|
23
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
|
|
24
|
+
* @param {Iterable<AbortSignalObject>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
|
|
25
|
+
* @returns {AbortSignalObject} - **Already aborted**, if any of the abort signals given is already aborted.
|
|
26
|
+
* The returned {@link AbortSignalObject}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
|
|
27
|
+
* - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
|
|
28
|
+
* The `reason` will be set to the reason of the first abort signal that is aborted.
|
|
29
|
+
*/
|
|
30
|
+
static any(iterable: Iterable<AbortSignal>): AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
export declare class AbortController {
|
|
33
|
+
signal: AbortSignal;
|
|
34
|
+
constructor();
|
|
35
|
+
abort(reason: any): void;
|
|
36
|
+
toString(): string;
|
|
37
|
+
}
|
|
38
|
+
export default AbortController;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import "core-js/modules/es.symbol.description.js";
|
|
2
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
3
|
+
// source: https://github.com/mo/abortcontroller-polyfill
|
|
4
|
+
import { Emitter } from '@ray-js/t-agent';
|
|
5
|
+
function createAbortEvent(reason) {
|
|
6
|
+
let event;
|
|
7
|
+
try {
|
|
8
|
+
event = new Event('abort');
|
|
9
|
+
} catch (e) {
|
|
10
|
+
if (typeof document !== 'undefined') {
|
|
11
|
+
if (!document.createEvent) {
|
|
12
|
+
// For Internet Explorer 8:
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
event = document.createEventObject();
|
|
15
|
+
event.type = 'abort';
|
|
16
|
+
} else {
|
|
17
|
+
// For Internet Explorer 11:
|
|
18
|
+
event = document.createEvent('Event');
|
|
19
|
+
event.initEvent('abort', false, false);
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
// Fallback where document isn't available:
|
|
23
|
+
event = {
|
|
24
|
+
type: 'abort',
|
|
25
|
+
bubbles: false,
|
|
26
|
+
cancelable: false
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
event.reason = reason;
|
|
31
|
+
return event;
|
|
32
|
+
}
|
|
33
|
+
function normalizeAbortReason(reason) {
|
|
34
|
+
if (reason === undefined) {
|
|
35
|
+
if (typeof document === 'undefined') {
|
|
36
|
+
reason = new Error('This operation was aborted');
|
|
37
|
+
reason.name = 'AbortError';
|
|
38
|
+
} else {
|
|
39
|
+
try {
|
|
40
|
+
reason = new DOMException('signal is aborted without reason');
|
|
41
|
+
// The DOMException does not support setting the name property directly.
|
|
42
|
+
Object.defineProperty(reason, 'name', {
|
|
43
|
+
value: 'AbortError'
|
|
44
|
+
});
|
|
45
|
+
} catch (err) {
|
|
46
|
+
// IE 11 does not support calling the DOMException constructor, use a
|
|
47
|
+
// regular error object on it instead.
|
|
48
|
+
reason = new Error('This operation was aborted');
|
|
49
|
+
reason.name = 'AbortError';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return reason;
|
|
54
|
+
}
|
|
55
|
+
export class AbortSignal extends Emitter {
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
58
|
+
// Some versions of babel does not transpile super() correctly for IE <= 10, if the parent
|
|
59
|
+
// constructor has failed to run, then "this.listeners" will still be undefined and then we call
|
|
60
|
+
// the parent constructor directly instead as a workaround. For general details, see babel bug:
|
|
61
|
+
// https://github.com/babel/babel/issues/3041
|
|
62
|
+
// This hack was added as a fix for the issue described here:
|
|
63
|
+
// https://github.com/Financial-Times/polyfill-library/pull/59#issuecomment-477558042
|
|
64
|
+
if (!this.listeners) {
|
|
65
|
+
Emitter.call(this);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Compared to assignment, Object.defineProperty makes properties non-enumerable by default and
|
|
69
|
+
// we want Object.keys(new AbortController().signal) to be [] for compat with the native impl
|
|
70
|
+
Object.defineProperty(this, 'aborted', {
|
|
71
|
+
value: false,
|
|
72
|
+
writable: true,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(this, 'onabort', {
|
|
76
|
+
value: null,
|
|
77
|
+
writable: true,
|
|
78
|
+
configurable: true
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(this, 'reason', {
|
|
81
|
+
value: undefined,
|
|
82
|
+
writable: true,
|
|
83
|
+
configurable: true
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
toString() {
|
|
87
|
+
return '[object AbortSignal]';
|
|
88
|
+
}
|
|
89
|
+
dispatchEvent(event) {
|
|
90
|
+
if (event.type === 'abort') {
|
|
91
|
+
this.aborted = true;
|
|
92
|
+
if (typeof this.onabort === 'function') {
|
|
93
|
+
this.onabort.call(this, event);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return super.dispatchEvent(event);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
|
|
101
|
+
*/
|
|
102
|
+
throwIfAborted() {
|
|
103
|
+
const {
|
|
104
|
+
aborted,
|
|
105
|
+
reason = 'Aborted'
|
|
106
|
+
} = this;
|
|
107
|
+
if (!aborted) return;
|
|
108
|
+
throw reason;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
|
|
113
|
+
* @param {number} time The "active" time in milliseconds before the returned {@link AbortSignalObject} will abort.
|
|
114
|
+
* The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
|
|
115
|
+
* @returns {AbortSignalObject} The signal will abort with its {@link AbortSignalObject.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
|
|
116
|
+
* or an `AbortError` {@link DOMException} if the operation was user-triggered.
|
|
117
|
+
*/
|
|
118
|
+
static timeout(time) {
|
|
119
|
+
const controller = new AbortController();
|
|
120
|
+
setTimeout(() => controller.abort(new DOMException("This signal is timeout in ".concat(time, "ms"), 'TimeoutError')), time);
|
|
121
|
+
return controller.signal;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
|
|
126
|
+
* @param {Iterable<AbortSignalObject>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
|
|
127
|
+
* @returns {AbortSignalObject} - **Already aborted**, if any of the abort signals given is already aborted.
|
|
128
|
+
* The returned {@link AbortSignalObject}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
|
|
129
|
+
* - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
|
|
130
|
+
* The `reason` will be set to the reason of the first abort signal that is aborted.
|
|
131
|
+
*/
|
|
132
|
+
static any(iterable) {
|
|
133
|
+
const controller = new AbortController();
|
|
134
|
+
function clean() {
|
|
135
|
+
for (const signal of iterable) signal.removeEventListener('abort', abort);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @this AbortSignalObject
|
|
139
|
+
*/
|
|
140
|
+
function abort() {
|
|
141
|
+
controller.abort(this.reason);
|
|
142
|
+
clean();
|
|
143
|
+
}
|
|
144
|
+
for (const signal of iterable) if (signal.aborted) {
|
|
145
|
+
controller.abort(signal.reason);
|
|
146
|
+
break;
|
|
147
|
+
} else signal.addEventListener('abort', abort);
|
|
148
|
+
return controller.signal;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export class AbortController {
|
|
152
|
+
constructor() {
|
|
153
|
+
// Compared to assignment, Object.defineProperty makes properties non-enumerable by default and
|
|
154
|
+
// we want Object.keys(new AbortController()) to be [] for compat with the native impl
|
|
155
|
+
Object.defineProperty(this, 'signal', {
|
|
156
|
+
value: new AbortSignal(),
|
|
157
|
+
writable: true,
|
|
158
|
+
configurable: true
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
abort(reason) {
|
|
162
|
+
const signalReason = normalizeAbortReason(reason);
|
|
163
|
+
const event = createAbortEvent(signalReason);
|
|
164
|
+
this.signal.reason = signalReason;
|
|
165
|
+
this.signal.dispatchEvent(event);
|
|
166
|
+
}
|
|
167
|
+
toString() {
|
|
168
|
+
return '[object AbortController]';
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
172
|
+
// These are necessary to make sure that we get correct output for:
|
|
173
|
+
// Object.prototype.toString.call(new AbortController())
|
|
174
|
+
AbortController.prototype[Symbol.toStringTag] = 'AbortController';
|
|
175
|
+
AbortSignal.prototype[Symbol.toStringTag] = 'AbortSignal';
|
|
176
|
+
}
|
|
177
|
+
export default AbortController;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export declare const authorize: ({ scope }: {
|
|
2
|
+
scope: string;
|
|
3
|
+
}) => Promise<boolean>;
|
|
4
|
+
export declare const getAppInfo: () => Promise<{
|
|
5
|
+
regionCode: string;
|
|
6
|
+
}>;
|
|
7
|
+
export interface AsrListenerManager {
|
|
8
|
+
/**
|
|
9
|
+
* 状态
|
|
10
|
+
*/
|
|
11
|
+
getAsrActive(params: {
|
|
12
|
+
complete?: () => void;
|
|
13
|
+
success?: (params: {
|
|
14
|
+
/** 状态 */
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
}) => void;
|
|
17
|
+
failure?: (params: {
|
|
18
|
+
errorMsg: string;
|
|
19
|
+
errorCode: string | number;
|
|
20
|
+
innerError: {
|
|
21
|
+
errorCode: string | number;
|
|
22
|
+
errorMsg: string;
|
|
23
|
+
};
|
|
24
|
+
}) => void;
|
|
25
|
+
}): void;
|
|
26
|
+
/**
|
|
27
|
+
* 关闭麦克风,关闭后识音要等到全部识别完成才结束
|
|
28
|
+
*/
|
|
29
|
+
stopDetect(params: {
|
|
30
|
+
complete?: () => void;
|
|
31
|
+
success?: (params: null) => void;
|
|
32
|
+
fail?: (params: {
|
|
33
|
+
errorMsg: string;
|
|
34
|
+
errorCode: string | number;
|
|
35
|
+
innerError: {
|
|
36
|
+
errorCode: string | number;
|
|
37
|
+
errorMsg: string;
|
|
38
|
+
};
|
|
39
|
+
}) => void;
|
|
40
|
+
}): void;
|
|
41
|
+
/**
|
|
42
|
+
* 关闭麦克风,关闭后识音要等到全部识别完成才结束
|
|
43
|
+
*/
|
|
44
|
+
startDetect(params: {
|
|
45
|
+
complete?: () => void;
|
|
46
|
+
success?: (params: null) => void;
|
|
47
|
+
fail?: (params: {
|
|
48
|
+
errorMsg: string;
|
|
49
|
+
errorCode: string | number;
|
|
50
|
+
innerError: {
|
|
51
|
+
errorCode: string | number;
|
|
52
|
+
errorMsg: string;
|
|
53
|
+
};
|
|
54
|
+
}) => void;
|
|
55
|
+
}): void;
|
|
56
|
+
/**
|
|
57
|
+
* 开始监听 + 识音
|
|
58
|
+
*/
|
|
59
|
+
onDetect(listener: (params: {
|
|
60
|
+
/** managerId */
|
|
61
|
+
managerId: number;
|
|
62
|
+
/** 拾音状态 0. 未开启 1.进行中 2.结束 3.发送错误 */
|
|
63
|
+
state: number;
|
|
64
|
+
/** 语言转换内容 */
|
|
65
|
+
text: string;
|
|
66
|
+
/** 错误码 0. 录音时间太短 */
|
|
67
|
+
errorCode: number;
|
|
68
|
+
}) => void): void;
|
|
69
|
+
/**
|
|
70
|
+
* 取消监听
|
|
71
|
+
*/
|
|
72
|
+
offDetect(listener: (params: {
|
|
73
|
+
/** managerId */
|
|
74
|
+
managerId: number;
|
|
75
|
+
/** 拾音状态 0. 未开启 1.进行中 2.结束 3.发送错误 */
|
|
76
|
+
state: number;
|
|
77
|
+
/** 语言转换内容 */
|
|
78
|
+
text: string;
|
|
79
|
+
/** 错误码 0. 录音时间太短 */
|
|
80
|
+
errorCode: number;
|
|
81
|
+
}) => void): void;
|
|
82
|
+
}
|
|
83
|
+
export declare const getAsrListenerManager: (params: {
|
|
84
|
+
/** 家庭id */
|
|
85
|
+
homeId: string;
|
|
86
|
+
/** 码率,eg:u律传8000,pcm传16000 */
|
|
87
|
+
sampleRate: number;
|
|
88
|
+
/** 通道, eg:1 */
|
|
89
|
+
channels: number;
|
|
90
|
+
/** 编码格式,eg:ThingAudioAsrCodeTypePCM = 0 ,ThingAudioAsrCodeTypePCMU = 1 */
|
|
91
|
+
codec: string | number;
|
|
92
|
+
/** 云端asr解析选项,注意不要设置其他跟文本无关的参数,本检测只会处理跟文本相关的数据,nlp,skill,tts不包含。 */
|
|
93
|
+
options: string;
|
|
94
|
+
}) => Promise<AsrListenerManager>;
|
|
95
|
+
export declare const getCurrentHomeInfo: () => Promise<{
|
|
96
|
+
homeId: string;
|
|
97
|
+
homeName: string;
|
|
98
|
+
}>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
export const authorize = _ref => {
|
|
3
|
+
let {
|
|
4
|
+
scope
|
|
5
|
+
} = _ref;
|
|
6
|
+
return new Promise(resolve => {
|
|
7
|
+
ty.authorize({
|
|
8
|
+
scope,
|
|
9
|
+
success() {
|
|
10
|
+
resolve(true);
|
|
11
|
+
},
|
|
12
|
+
fail() {
|
|
13
|
+
resolve(false);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export const getAppInfo = () => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
ty.getAppInfo({
|
|
21
|
+
success(res) {
|
|
22
|
+
resolve(res);
|
|
23
|
+
},
|
|
24
|
+
fail(error) {
|
|
25
|
+
reject(error);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export const getAsrListenerManager = params => {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
ty.getAsrListenerManager(_objectSpread(_objectSpread({}, params), {}, {
|
|
34
|
+
success(res) {
|
|
35
|
+
resolve(res);
|
|
36
|
+
},
|
|
37
|
+
failure(err) {
|
|
38
|
+
reject(err);
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export const getCurrentHomeInfo = () => {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
ty.home.getCurrentHomeInfo({
|
|
46
|
+
success(res) {
|
|
47
|
+
resolve(res);
|
|
48
|
+
},
|
|
49
|
+
fail(error) {
|
|
50
|
+
reject(error);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-ui-ray",
|
|
3
|
-
"version": "0.2.3-beta-
|
|
3
|
+
"version": "0.2.3-beta-3",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@types/echarts": "^4.9.22",
|
|
41
41
|
"@types/markdown-it": "^14.1.1"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "84e4e7b2ec8f91fe56b3b8499d549175893f9fe3"
|
|
44
44
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export function createWeakRefPonyfill() {
|
|
2
|
-
if (typeof globalThis.WeakRef === 'function') {
|
|
3
|
-
return globalThis.WeakRef; // 用原生的
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
console.warn('[ponyfill] WeakRef not supported. Using WeakMap + FinalizationRegistry fallback.');
|
|
7
|
-
|
|
8
|
-
const _refs = new WeakMap(); // WeakRef实例 -> target
|
|
9
|
-
const _reverse = new WeakMap(); // target -> WeakRef实例数组
|
|
10
|
-
|
|
11
|
-
const registry = typeof FinalizationRegistry !== 'undefined'
|
|
12
|
-
? new FinalizationRegistry((heldValue) => {
|
|
13
|
-
const { targetKey } = heldValue;
|
|
14
|
-
const refs = _reverse.get(targetKey);
|
|
15
|
-
if (refs) {
|
|
16
|
-
for (const ref of refs) {
|
|
17
|
-
_refs.delete(ref);
|
|
18
|
-
}
|
|
19
|
-
_reverse.delete(targetKey);
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
: null;
|
|
23
|
-
|
|
24
|
-
return class WeakRefPonyfill {
|
|
25
|
-
constructor(target) {
|
|
26
|
-
if (typeof target !== 'object' || target === null) {
|
|
27
|
-
throw new TypeError('WeakRef target must be an object');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
_refs.set(this, target);
|
|
31
|
-
|
|
32
|
-
if (registry) {
|
|
33
|
-
registry.register(target, { targetKey: target });
|
|
34
|
-
|
|
35
|
-
const existing = _reverse.get(target) || [];
|
|
36
|
-
existing.push(this);
|
|
37
|
-
_reverse.set(target, existing);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
deref() {
|
|
42
|
-
return _refs.get(this);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|