@ray-js/t-agent-ui-ray 0.2.7-beta.6 → 0.2.7-beta.8

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.
@@ -196,7 +196,8 @@ export class BlockParser {
196
196
  }
197
197
  const map = new Map();
198
198
  const ids = [];
199
- for (const item of this.pendingBlocks) {
199
+ for (let i = 0; i < this.pendingBlocks.length; i++) {
200
+ const item = this.pendingBlocks[i];
200
201
  map.set("<".concat(item.id, " />"), item);
201
202
  ids.push(item.id);
202
203
  }
@@ -177,7 +177,8 @@ export default function MessageInputAIStream(props) {
177
177
  }
178
178
  attachmentInput.loadBlocks(blocks);
179
179
  let t = '';
180
- for (const block of blocks) {
180
+ for (let i = 0; i < blocks.length; i++) {
181
+ const block = blocks[i];
181
182
  if (block.type === 'text') {
182
183
  t = block.text;
183
184
  }
@@ -8,6 +8,7 @@ import { chooseImage, chooseVideo, uploadImage, uploadVideo } from '../utils/fil
8
8
  import { generateId } from '@ray-js/t-agent';
9
9
  import { useRenderOptions } from './context';
10
10
  import { useTranslate } from './useTranslate';
11
+ import { authorize } from '../utils/ttt';
11
12
  export function useAttachmentInput() {
12
13
  let {
13
14
  local
@@ -20,7 +21,8 @@ export function useAttachmentInput() {
20
21
  const blocks = useMemo(() => {
21
22
  const b = [];
22
23
  if (uploaded.length) {
23
- for (const uploadFile of uploaded) {
24
+ for (let i = 0; i < uploaded.length; i++) {
25
+ const uploadFile = uploaded[i];
24
26
  if (uploadFile.type === 'image') {
25
27
  if (local) {
26
28
  b.push({
@@ -65,7 +67,8 @@ export function useAttachmentInput() {
65
67
  }, [uploaded, local]);
66
68
  const loadBlocks = useCallback((blocks, append) => {
67
69
  const uploaded = [];
68
- for (const block of blocks) {
70
+ for (let i = 0; i < blocks.length; i++) {
71
+ const block = blocks[i];
69
72
  if (block.type === 'image_url') {
70
73
  uploaded.push({
71
74
  id: generateId(),
@@ -148,6 +151,15 @@ export function useAttachmentInput() {
148
151
  if (!sourceType) {
149
152
  return;
150
153
  }
154
+ const result = await authorize({
155
+ scope: 'scope.writePhotosAlbum'
156
+ });
157
+ if (!result) {
158
+ ty.showToast({
159
+ title: t('t-agent.input.upload.source-type.album.require-permission')
160
+ });
161
+ return;
162
+ }
151
163
  file = await chooseImage(count, sourceType);
152
164
  } catch (err) {
153
165
  return;
@@ -155,30 +167,41 @@ export function useAttachmentInput() {
155
167
  }
156
168
  if (type === 'camera') {
157
169
  try {
158
- const allowUseCamera = await new Promise(resolve => {
159
- ty.authorize({
160
- scope: 'scope.camera',
161
- success() {
162
- resolve(true);
163
- },
164
- fail() {
165
- ty.showToast({
166
- title: t('t-agent.input.upload.source-type.camera.require-permission'),
167
- icon: 'none'
168
- });
169
- resolve(false);
170
- }
170
+ const allowUseCamera = authorize({
171
+ scope: 'scope.camera'
172
+ });
173
+ if (!allowUseCamera) {
174
+ ty.showToast({
175
+ title: t('t-agent.input.upload.source-type.camera.require-permission'),
176
+ icon: 'none'
171
177
  });
178
+ return;
179
+ }
180
+ const result = await authorize({
181
+ scope: 'scope.writePhotosAlbum'
172
182
  });
173
- if (allowUseCamera) {
174
- file = await chooseImage(count, 'camera');
183
+ if (!result) {
184
+ ty.showToast({
185
+ title: t('t-agent.input.upload.source-type.album.require-permission')
186
+ });
187
+ return;
175
188
  }
189
+ file = await chooseImage(count, 'camera');
176
190
  } catch (err) {
177
191
  return;
178
192
  }
179
193
  }
180
194
  if (type === 'album') {
181
195
  try {
196
+ const result = await authorize({
197
+ scope: 'scope.writePhotosAlbum'
198
+ });
199
+ if (!result) {
200
+ ty.showToast({
201
+ title: t('t-agent.input.upload.source-type.album.require-permission')
202
+ });
203
+ return;
204
+ }
182
205
  file = await chooseImage(count, 'album');
183
206
  } catch (err) {
184
207
  return;
@@ -24,7 +24,8 @@ const normalizeLanguage = lang => {
24
24
  if (cache.has(lang)) {
25
25
  return cache.get(lang);
26
26
  }
27
- for (const key of keys) {
27
+ for (let i = 0; i < keys.length; i++) {
28
+ const key = keys[i];
28
29
  if (langRE[key].test(lang)) {
29
30
  cache.set(lang, key);
30
31
  return key;
@@ -3,7 +3,6 @@ import "core-js/modules/esnext.iterator.constructor.js";
3
3
  import "core-js/modules/esnext.iterator.find.js";
4
4
  import "core-js/modules/esnext.iterator.map.js";
5
5
  import "core-js/modules/esnext.iterator.some.js";
6
- import "core-js/modules/web.dom-collections.iterator.js";
7
6
  import './index.less';
8
7
  import { View } from '@ray-js/components';
9
8
  import React, { memo, useCallback, useMemo } from 'react';
@@ -61,7 +60,8 @@ const BubbleTile = props => {
61
60
  const longPressBlock = renderLongPressAs(longPressRes);
62
61
  const isErrorBubble = useMemo(() => {
63
62
  let empty = true;
64
- for (const child of children) {
63
+ for (let i = 0; i < children.length; i++) {
64
+ const child = children[i];
65
65
  // 如果子元素是文本类型,并且文本不为空,则不是空消息
66
66
  if (child.type === 'text') {
67
67
  if (child.data.text !== '') {
@@ -16,7 +16,9 @@ export function createSharedStore() {
16
16
  setValue(newValue) {
17
17
  const oldValue = storeRef.current.value;
18
18
  storeRef.current.value = newValue;
19
- for (const key of Object.keys(newValue)) {
19
+ const keys = Object.keys(newValue);
20
+ for (let i = 0; i < keys.length; i++) {
21
+ const key = keys[i];
20
22
  if (oldValue[key] !== newValue[key]) {
21
23
  var _storeRef$current$lis;
22
24
  (_storeRef$current$lis = storeRef.current.listeners.get(key)) === null || _storeRef$current$lis === void 0 || _storeRef$current$lis.forEach(fn => fn());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-ui-ray",
3
- "version": "0.2.7-beta.6",
3
+ "version": "0.2.7-beta.8",
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": "8c74cd727802f09ac6294a88ee72464fc39db49c"
43
+ "gitHead": "31a0d88f88eddae8bfd802e4861c76cd02c07692"
44
44
  }