@shijiu/jsview-vue 2.2.35 → 2.2.128

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.
Files changed (77) hide show
  1. package/bin/browser/BrowserApic.vue.mjs +2 -1
  2. package/bin/browser/BrowserApic2.vue.mjs +2 -1
  3. package/bin/browser/BrowserApicLib.mjs +2 -1
  4. package/bin/browser/BrowserQrcode.vue.mjs +3 -1
  5. package/bin/browser/BrowserTextureAnim.vue.mjs +7 -6
  6. package/bin/jsview-vue.mjs +1557 -894
  7. package/bin/types/JsViewEngineWidget/MetroWidget/Slide.d.ts +21 -0
  8. package/bin/types/JsViewEngineWidget/TemplateParser/MetroTemplate.d.ts +2 -8
  9. package/bin/types/JsViewEngineWidget/WidgetCommon.d.ts +9 -3
  10. package/bin/types/JsViewVueTools/ConstSymbol.d.ts +2 -0
  11. package/bin/types/JsViewVueTools/ForgeConstDefine.d.ts +11 -0
  12. package/bin/types/JsViewVueTools/JsvRuntimeBridge.d.ts +113 -57
  13. package/bin/types/JsViewVueTools/JsvTextureStore/CapturedTexture/CapturedTexture.d.ts +11 -0
  14. package/bin/types/JsViewVueTools/JsvTextureStore/Texture.d.ts +8 -0
  15. package/bin/types/JsViewVueWidget/JsvConnectLine/JsvConnectLine.vue.d.ts +1 -1
  16. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/ActionRefObject.d.ts +4 -0
  17. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/ActorControl.d.ts +65 -0
  18. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/ActorState.d.ts +6 -0
  19. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/CallbackManager.d.ts +11 -0
  20. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/ForgeTypeDefine.d.ts +15 -0
  21. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue.d.ts +6 -0
  22. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/SetAction.d.ts +71 -0
  23. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/SetCondition.d.ts +95 -0
  24. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/SetState.d.ts +62 -0
  25. package/bin/types/JsViewVueWidget/JsvFreeMoveActor/index.d.ts +2 -1
  26. package/bin/types/JsViewVueWidget/JsvLine/JsvLine.vue.d.ts +1 -1
  27. package/bin/types/JsViewVueWidget/JsvNativeSharedDiv.vue.d.ts +66 -28
  28. package/bin/types/JsViewVueWidget/JsvNinePatch.vue.d.ts +1 -0
  29. package/bin/types/JsViewVueWidget/JsvScrollBox/JsvScrollBox.vue.d.ts +176 -0
  30. package/bin/types/JsViewVueWidget/JsvScrollBox/ScrollSymbol.d.ts +7 -0
  31. package/bin/types/JsViewVueWidget/JsvScrollBox/index.d.ts +1 -0
  32. package/bin/types/JsViewVueWidget/JsvTextBox.vue.d.ts +3 -3
  33. package/bin/types/JsViewVueWidget/index.d.ts +1 -0
  34. package/package.json +1 -1
  35. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +10 -1
  36. package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +398 -309
  37. package/utils/JsViewEngineWidget/MetroWidget/RenderItem.ts +2 -1
  38. package/utils/JsViewEngineWidget/MetroWidget/Slide.ts +56 -0
  39. package/utils/JsViewEngineWidget/MetroWidget/TaskManager.ts +51 -10
  40. package/utils/JsViewEngineWidget/MetroWidget/TokenGenerator.ts +10 -0
  41. package/utils/JsViewEngineWidget/TemplateParser/ListMetroTemplate.ts +9 -3
  42. package/utils/JsViewEngineWidget/TemplateParser/MetroTemplate.ts +25 -35
  43. package/utils/JsViewEngineWidget/WidgetCommon.ts +20 -7
  44. package/utils/JsViewPlugin/JsvPlayer/BrowserJsvPlayer.vue +13 -1
  45. package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +470 -338
  46. package/utils/JsViewVueTools/ConstSymbol.ts +3 -0
  47. package/utils/JsViewVueTools/ForgeConstDefine.ts +11 -0
  48. package/utils/JsViewVueTools/JsvRuntimeBridge.js +172 -50
  49. package/utils/JsViewVueTools/JsvTextureStore/CapturedTexture/CapturedTexture.ts +62 -0
  50. package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +41 -7
  51. package/utils/JsViewVueTools/JsvTextureStore/Texture.ts +15 -1
  52. package/utils/JsViewVueTools/index.js +2 -0
  53. package/utils/JsViewVueWidget/JsvApic/JsvApic/BrowserApic.vue +6 -6
  54. package/utils/JsViewVueWidget/JsvApic/JsvApic2/BrowserApic2.vue +5 -6
  55. package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/ApicDataBase.js +5 -1
  56. package/utils/JsViewVueWidget/JsvFreeMoveActor/ActionRefObject.ts +1 -1
  57. package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.ts +23 -1
  58. package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorState.ts +4 -4
  59. package/utils/JsViewVueWidget/JsvFreeMoveActor/CallbackManager.ts +6 -6
  60. package/utils/JsViewVueWidget/JsvFreeMoveActor/ForgeTypeDefine.ts +1 -1
  61. package/utils/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue +43 -9
  62. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +24 -0
  63. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.ts +50 -1
  64. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +56 -0
  65. package/utils/JsViewVueWidget/JsvFreeMoveActor/index.js +3 -0
  66. package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +6 -1
  67. package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +121 -68
  68. package/utils/JsViewVueWidget/JsvNinePatch.vue +4 -1
  69. package/utils/JsViewVueWidget/JsvPosterImage.vue +22 -9
  70. package/utils/JsViewVueWidget/JsvQrcode/BrowserQrcode.vue +6 -2
  71. package/utils/JsViewVueWidget/JsvScrollBox/JsvScrollBox.vue +309 -0
  72. package/utils/JsViewVueWidget/JsvScrollBox/ScrollSymbol.ts +15 -0
  73. package/utils/JsViewVueWidget/JsvScrollBox/index.js +2 -0
  74. package/utils/JsViewVueWidget/JsvTextBox.vue +12 -4
  75. package/utils/JsViewVueWidget/JsvTextureAnim/BrowserTextureAnim.vue +9 -6
  76. package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +2 -0
  77. package/utils/JsViewVueWidget/index.js +1 -0
@@ -0,0 +1,3 @@
1
+
2
+ export const VERTICAL: Symbol = Symbol("vertical");
3
+ export const HORIZONTAL: Symbol = Symbol("horizontal");
@@ -0,0 +1,11 @@
1
+ export namespace ForgeConst {
2
+ export namespace DragFlags {
3
+ export const TOUCH_RECV_CLICK_BIT: number = 0b1;
4
+ export const TOUCH_RECV_LONGPRESS_BIT: number = 0b10;
5
+ export const TOUCH_RECV_MOVE_BIT: number = 0b100;
6
+ export const TOUCH_RECV_FLING_BIT: number = 0b100000;
7
+ export const TOUCH_RECV_FIRST_START: number = 0b1000;
8
+ export const TOUCH_RECV_LAST_END: number = 0b10000;
9
+ export const DRAG_ANY: number = 0xFFFFFF;
10
+ }
11
+ }
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-prototype-builtins */
2
-
3
1
  let feature_supports = null;
4
2
 
5
3
  let direct_call_map = {};
@@ -25,7 +23,7 @@ function direct_call(name, ...args) {
25
23
  return null;
26
24
  }
27
25
 
28
- /*!
26
+ /**
29
27
  * 获取当前集成JsView的APP目前支持的扩展功能列表
30
28
  *
31
29
  * @returns {string} 功能列表,以逗号隔开,包含:
@@ -40,7 +38,7 @@ function getExtFeatureSupports() {
40
38
  return feature_supports;
41
39
  }
42
40
 
43
- /*!
41
+ /**
44
42
  * 获取设备mac地址,优先获取有线mac,无则获取wifi mac
45
43
  * @returns {string} mac address
46
44
  *
@@ -49,7 +47,7 @@ function getMac(){
49
47
  return direct_call("getMac");
50
48
  }
51
49
 
52
- /*!
50
+ /**
53
51
  * 获取设备有线mac地址
54
52
  * @returns {string} mac address
55
53
  *
@@ -58,7 +56,7 @@ function getWireMac(){
58
56
  return direct_call("getWireMac");
59
57
  }
60
58
 
61
- /*!
59
+ /**
62
60
  * 获取设备wifi mac地址
63
61
  * @returns {string} mac address
64
62
  *
@@ -67,7 +65,7 @@ function getWifiMac(){
67
65
  return direct_call("getWifiMac");
68
66
  }
69
67
 
70
- /*!
68
+ /**
71
69
  * 获取设备UUID
72
70
  * @returns {string} UUID
73
71
  *
@@ -76,7 +74,7 @@ function getDeviceUUID(){
76
74
  return direct_call("getDeviceUUID");
77
75
  }
78
76
 
79
- /*!
77
+ /**
80
78
  * 获取设备Android ID
81
79
  * @returns {string} Android ID
82
80
  *
@@ -85,31 +83,87 @@ function getAndroidId(){
85
83
  return direct_call("getAndroidId");
86
84
  }
87
85
 
88
- /*!
86
+ /**
89
87
  * 打开另外一个小程序
90
88
  * @param {string} url 小程序url
91
89
  * @param {string} startup_image 启动图url
92
90
  * @param {string} startup_video 启动视频url
93
91
  * @param {int} startup_duration 启动图时长,默认0
94
92
  * @param {int} add_history 是否添加历史,0不添加,1添加
95
- *
93
+ * @returns {Promise} 可用于监听新的小程序返回的结果
96
94
  */
97
95
  function openWindow(url, startup_image, startup_video, startup_duration, add_history){
98
96
  let setting = {};
99
- if(typeof startup_image !== undefined && startup_image !== null && startup_image !== "")
97
+ if(startup_image !== null && startup_image !== "")
98
+ setting.startupImage = startup_image;
99
+
100
+ if(startup_video !== null && startup_video !== ""){
101
+ setting.startupVideo = startup_video;
102
+ }
103
+
104
+ setting.startupDuration = startup_duration;
105
+ setting.addHistory = (add_history ? 1 : 0); // 兼容true/false传值
106
+
107
+ // direct_call("openWindow", url, JSON.stringify(setting));
108
+ return window.jJsvRuntimeBridge.openWindow(url, JSON.stringify(setting))
109
+ }
110
+
111
+ /**
112
+ * 用新的进程打开另外一个小程序
113
+ * @param {string} url 小程序url
114
+ * @param {string} startup_image 启动图url
115
+ * @param {string} startup_video 启动视频url
116
+ * @param {int} startup_duration 启动图时长,默认0
117
+ * @param {int} add_history 是否添加历史,0不添加,1添加
118
+ * @returns {Promise} 可用于监听新的小程序返回的结果
119
+ */
120
+ function startUrlInNewTab(url, startup_image, startup_video, startup_duration, add_history){
121
+ let setting = {};
122
+ if(startup_image !== null && startup_image !== "")
123
+ setting.startupImage = startup_image;
124
+
125
+ if(startup_video !== null && startup_video !== ""){
126
+ setting.startupVideo = startup_video;
127
+ }
128
+
129
+ setting.startupDuration = startup_duration;
130
+ setting.addHistory = (add_history ? 1 : 0); // 兼容true/false传值
131
+
132
+ return window.jJsvRuntimeBridge.startUrlInNewTab(url, JSON.stringify(setting))
133
+ }
134
+
135
+ /**
136
+ * 用于给上一个小程序返回结果,通常与startUrlInNewTab和openWindow配合使用
137
+ * @param {string} data 返回给上一个小程序的结果
138
+ */
139
+ function onWindowResult(data){
140
+ direct_call("onWindowResult",data)
141
+ }
142
+
143
+ /**
144
+ * 重新加载一个小程序覆盖当前小程序
145
+ * @param {string} url 小程序url
146
+ * @param {string} startup_image 启动图url
147
+ * @param {string} startup_video 启动视频url
148
+ * @param {int} startup_duration 启动图时长,默认0
149
+ * @param {int} add_history 是否添加历史,0不添加,1添加
150
+ */
151
+ function reloadWindow(url, startup_image, startup_video, startup_duration, add_history){
152
+ let setting = {};
153
+ if(startup_image !== null && startup_image !== "")
100
154
  setting.startupImage = startup_image;
101
155
 
102
- if(typeof startup_video !== undefined && startup_video !== null && startup_video !== ""){
156
+ if(startup_video !== null && startup_video !== ""){
103
157
  setting.startupVideo = startup_video;
104
158
  }
105
159
 
106
160
  setting.startupDuration = startup_duration;
107
161
  setting.addHistory = (add_history ? 1 : 0); // 兼容true/false传值
108
162
 
109
- direct_call("openWindow", url, JSON.stringify(setting));
163
+ return window.jJsvRuntimeBridge.reloadWindow(url, JSON.stringify(setting))
110
164
  }
111
165
 
112
- /*!
166
+ /**
113
167
  * 关闭当前小程序
114
168
  *
115
169
  */
@@ -117,9 +171,9 @@ function closePage(){
117
171
  direct_call("closePage");
118
172
  }
119
173
 
120
- /*!
121
- * 获取设备UUID
122
- * @param {string} key 属性名称
174
+ /**
175
+ * 获取系统属性
176
+ * @param {string} key 属性名称,比如:ro.product.model。
123
177
  * @returns {string} 属性值
124
178
  *
125
179
  */
@@ -127,7 +181,7 @@ function getSystemProperty(key){
127
181
  return direct_call("getSystemProperty", key);
128
182
  }
129
183
 
130
- /*!
184
+ /**
131
185
  * 获取已安装应用列表
132
186
  * @returns {string} 应用列表,JSON结构的数组
133
187
  *
@@ -136,39 +190,49 @@ function getInstalledApps(){
136
190
  return direct_call("getInstalledApps");
137
191
  }
138
192
 
139
- /*!
193
+ /**
140
194
  * 启动安卓APP
141
195
  * @param {string} package_name 包名
142
196
  * @param {string} activity Activity方式启动
143
197
  * @param {string} action Action方式启动
144
198
  * @param {string} uri Uri方式启动
145
199
  * @param {Array} flags 数组,用于intent.addFlags
146
- * @param {Array} param JSON格式数组,用于intent.putExtra
200
+ * @param {Array} param JSON格式数组,数组元素是 object ,object中的内容用于intent.putExtra
147
201
  *
148
202
  */
149
203
  function startNativeApp(package_name, activity, action, uri, flags, param){
150
204
  var obj = {};
151
- if(typeof package_name != undefined && package_name !== null && package_name !== "")
205
+ if(package_name !== null && package_name !== "")
152
206
  obj.packageName = package_name;
153
207
 
154
- if(typeof activity != undefined && activity !== null && activity !== "")
208
+ if(activity !== null && activity !== "")
155
209
  obj.activity = activity;
156
210
 
157
- if(typeof action != undefined && action !== null && action !== "")
211
+ if(action !== null && action !== "")
158
212
  obj.action = action;
159
213
 
160
- if(typeof uri != undefined && uri !== null && uri !== "")
214
+ if(uri !== null && uri !== "")
161
215
  obj.uri = uri;
162
216
 
163
- if(typeof flags != undefined && flags !== null && flags.length > 0)
217
+ if(flags !== null && flags.length > 0)
164
218
  obj.flags = flags;
165
219
 
166
- if(typeof param != undefined && param !== null && param.length > 0)
220
+ if(param !== null && param.length > 0)
167
221
  obj.param = param;
168
222
 
169
223
  direct_call("startNativeApp", JSON.stringify(obj));
170
224
  }
171
225
 
226
+ /**
227
+ * 发送安卓广播
228
+ * @param {string} package_name 包名
229
+ * @param {string} broadcast 广播类名,比如“com.qcode.MyBroadcastReceiver”,用于intent.setComponent()
230
+ * @param {string} action 对应 intent.setAction()
231
+ * @param {string} uri 对应intent.setData()
232
+ * @param {Array} flags 数组,用于intent.addFlags
233
+ * @param {Array} param JSON格式数组,数组元素是 object ,object中的内容用于intent.putExtra
234
+ *
235
+ */
172
236
  function sendNativeBroadcast(package_name, broadcast, action, uri, flags, param){
173
237
 
174
238
  var obj = {};
@@ -192,7 +256,41 @@ function sendNativeBroadcast(package_name, broadcast, action, uri, flags, param)
192
256
  direct_call("sendNativeBroadcast", JSON.stringify(obj));
193
257
  }
194
258
 
195
- /*!
259
+ /**
260
+ * 启动Android 服务
261
+ * @param {string} package_name 包名
262
+ * @param {string} services 服务类名,比如“com.qcode.MyService”,用于intent.setComponent()
263
+ * @param {string} action 对应 intent.setAction()
264
+ * @param {string} uri 对应intent.setData()
265
+ * @param {Array} flags 数组,用于intent.addFlags
266
+ * @param {Array} param JSON格式数组,数组元素是 object ,object中的内容用于intent.putExtra
267
+ * @param {boolean} is_foreground 是否使用startForegroundService
268
+ *
269
+ */
270
+ function startService(package_name, services, action, uri, flags, param,is_foreground){
271
+
272
+ var obj = {};
273
+ if(typeof package_name != undefined && package_name !== null && package_name !== "")
274
+ obj.packageName = package_name;
275
+
276
+ if(typeof services != undefined && services !== null && services !== "")
277
+ obj.services = services;
278
+
279
+ if(typeof action != undefined && action !== null && action !== "")
280
+ obj.action = action;
281
+
282
+ if(typeof uri != undefined && uri !== null && uri !== "")
283
+ obj.uri = uri;
284
+
285
+ if(typeof flags != undefined && flags !== null && flags.length > 0)
286
+ obj.flags = flags;
287
+
288
+ if(typeof param != undefined && param !== null && param.length > 0)
289
+ obj.param = param;
290
+ direct_call("startServices", JSON.stringify(obj),is_foreground);
291
+ }
292
+
293
+ /**
196
294
  * 获取设备信息
197
295
  * @returns {string} 终端设备信息,JSON数据结构
198
296
  *
@@ -201,7 +299,7 @@ function getDeviceInfo() {
201
299
  return direct_call("getDeviceInfo");
202
300
  }
203
301
 
204
- /*!
302
+ /**
205
303
  * 获取自己的app信息
206
304
  * @returns
207
305
  */
@@ -209,7 +307,7 @@ function getAppInfo(){
209
307
  return direct_call("getAppInfo");
210
308
  }
211
309
 
212
- /*!
310
+ /**
213
311
  * 页面加载成功后调用去除启动图
214
312
  *
215
313
  */
@@ -224,7 +322,7 @@ function notifyPageLoaded() {
224
322
  direct_call("notifyPageLoaded");
225
323
  }
226
324
 
227
- /*!
325
+ /**
228
326
  * 是否支持收藏功能
229
327
  * @returns {boolean} true支持,false不支持
230
328
  *
@@ -237,7 +335,7 @@ function hasFavouriteFunction(){
237
335
  return false;
238
336
  }
239
337
 
240
- /*!
338
+ /**
241
339
  * 获取启动内核版本和引擎
242
340
  * @returns {Object} 包含
243
341
  * COREVERSIONRANGE: 启动时设定的内核版本范围
@@ -252,7 +350,7 @@ function getStartParams() {
252
350
  }
253
351
  }
254
352
 
255
- /*!
353
+ /**
256
354
  * 添加收藏
257
355
  * @param {string} url 收藏的url
258
356
  * @param {function} callback 执行接口回调, 处理可能被用户否决
@@ -273,7 +371,7 @@ function addFavourite(url, callback) {
273
371
  }
274
372
  }
275
373
 
276
- /*!
374
+ /**
277
375
  * 更新收藏
278
376
  * @param {string} url 收藏的url
279
377
  * @param {function} callback 执行接口回调, 处理可能被用户否决
@@ -294,7 +392,7 @@ function updateFavourite(url, callback) {
294
392
  }
295
393
  }
296
394
 
297
- /*!
395
+ /**
298
396
  * 删除指定收藏
299
397
  * @param {string} app_name app name 唯一标识
300
398
  * @param {function} callback 执行接口回调, 处理可能被用户否决
@@ -315,7 +413,7 @@ function removeFavourite(app_name, callback) {
315
413
  }
316
414
  }
317
415
 
318
- /*!
416
+ /**
319
417
  * 获取指定收藏
320
418
  * @param {string} app_name app name 唯一标识
321
419
  */
@@ -326,7 +424,7 @@ function getFavourite(app_name) {
326
424
  return null;
327
425
  }
328
426
 
329
- /*!
427
+ /**
330
428
  * 获取所有收藏
331
429
  *
332
430
  */
@@ -337,7 +435,7 @@ function getFavouriteAll() {
337
435
  return null;
338
436
  }
339
437
 
340
- /*!
438
+ /**
341
439
  * 浮窗控制接口,设置从本浮窗界面进行预热的二级浮窗的启动默认尺寸(若不设置则为全屏)
342
440
  * @param {string} mode 全屏模式还是需要Resize的模式。取值范围: "full" 或者 "mini"
343
441
  * 设置成 "mini" 模式后,启动后的界面内需要调用popupResizePosition来调整尺寸才能可见
@@ -346,7 +444,7 @@ function setPopupInitSize(mode) {
346
444
  direct_call("setPopupInitSize", mode);
347
445
  }
348
446
 
349
- /*!
447
+ /**
350
448
  * 浮窗控制接口,设置浮窗显示区域,以相对定位的方式调整弹出框的位置(弹出框弹出后先以尺寸1x1的方式展现)
351
449
  * @param {string} align 横纵对齐方式,有left, right, bottom, top, center可选择
352
450
  * 例如: 右下角"right bottom", 居中"center center"
@@ -359,7 +457,7 @@ function popupResizePosition(align, max_width, max_height, aspect) {
359
457
  direct_call("popupResizePosition", align, max_width, max_height, aspect);
360
458
  }
361
459
 
362
- /*!
460
+ /**
363
461
  * 浮窗系统认为自己准备好后,调用此接口,获取设备的焦点。若不调用的话,默认浮窗系统捕获的焦点
364
462
  */
365
463
  function popupGainFocus() {
@@ -370,7 +468,7 @@ function popupDiscardFocus(){
370
468
  direct_call("popupGainFocus");
371
469
  }
372
470
 
373
- /*!
471
+ /**
374
472
  * 页面预热接口,预热页面将会将以一个新的FrameLayout(内含JsView)的方式加载一个新的应用
375
473
  * 但这个应用在warmLoadView之前,不会创建texture/surface的实际描画资源,也不会加载图片
376
474
  * 仅加载所有JS代码,并正常走完所有启动逻辑(包括描画逻辑),但不会走setTimeout对应的延时逻辑,也不会显示
@@ -380,7 +478,7 @@ function popupDiscardFocus(){
380
478
  * 【特别注意】warmUp起来的view,在warmLoadView调用之前,若启动者JsView关闭的话,此View应该在
381
479
  * View管理模块被清理掉,以防泄露,但在warmLoadView完成后,就不需要进行关联清理,请管理模块务必保证此机制。
382
480
  * [参数]
383
- * int mode 预热模式,1:全预热,2:半预热
481
+ * int mode 预热模式,1:全预热,目前只支持1
384
482
  * String app_url 要预热的app_url,当半预热时,可以为null
385
483
  * [返回值]
386
484
  * int: 为view_refer_id值,预热后的View的ID,用于后续的warmLoadView和closeWarmView使用
@@ -399,20 +497,20 @@ function warmUpView(mode, app_url) {
399
497
  return direct_call("warmUpView", mode, app_url);
400
498
  }
401
499
 
402
- /*!
500
+ /**
403
501
  * 将warmUpView后的View展示出来
404
- * 若warmUpView中app_url不为null,进行了全预热,则本调用的app_url可以为null
405
502
  * 当warmUpView中设置了app_url时,仍可以新的app_url调整history hash(#)部分进行子页面切换
406
503
  *
407
504
  * @param {number} view_refer_id warmUpView调用后返回来的View ID
408
- * @param {string} app_url 界面的应用地址,支持?(search)和#(hash)字段
505
+ * @param {string} app_url 无意义,请传固定值 null
409
506
  * @param {boolean} add_history 启动的界面是否进访问历史列表
507
+ * @returns {Promise} 可用于监听新的小程序返回的结果
410
508
  */
411
509
  function warmLoadView(view_refer_id, app_url, add_history) {
412
510
  direct_call("warmLoadView", view_refer_id, app_url, !!add_history);
413
511
  }
414
512
 
415
- /*!
513
+ /**
416
514
  * 关闭warmUp后未进行warmLoad的View,释放资源
417
515
  * @param {number} view_refer_id warmUpView调用后返回来的View ID
418
516
  */
@@ -420,7 +518,7 @@ function closeWarmedView(view_refer_id) {
420
518
  direct_call("closeWarmedView", view_refer_id);
421
519
  }
422
520
 
423
- /*!
521
+ /**
424
522
  * 触发预下载内核
425
523
  * @param {string} core_version 带branch(主分支版本不带此信息)和版本信息的内核版本,
426
524
  * 例如: 1021265_release_build_xxx
@@ -430,20 +528,37 @@ function preDownloadSdk(core_version){
430
528
  return direct_call("preDownloadSdk", core_version);
431
529
  }
432
530
 
433
- //! 显示声明,可以提高执行速度和利用上编辑器的成员名提示功能
434
- export const jJsvRuntimeBridge = {
531
+ function getNetworkTypeStatusImmediate(){
532
+ return direct_call("getNetworkTypeStatusImmediate");
533
+ }
534
+
535
+ function registerNetStateListener(callback){
536
+ return direct_call("registerNetStateListener", callback);
537
+ }
538
+
539
+ function unRegisterNetStateListener(callback){
540
+ return direct_call("unRegisterNetStateListener", callback);
541
+ }
542
+
543
+
544
+ // 显示声明,可以提高执行速度和利用上编辑器的成员名提示功能
545
+ const bridge = {
435
546
  getMac,
436
547
  getWireMac,
437
548
  getWifiMac,
438
549
  getDeviceUUID,
439
550
  getAndroidId,
440
551
  openWindow,
552
+ startUrlInNewTab,
553
+ onWindowResult,
554
+ reloadWindow,
441
555
  closePage,
442
556
  getStartParams,
443
557
  getSystemProperty,
444
558
  getInstalledApps,
445
559
  startNativeApp,
446
560
  sendNativeBroadcast,
561
+ startService,
447
562
  getDeviceInfo,
448
563
  getAppInfo,
449
564
  notifyPageLoadDone,
@@ -461,5 +576,12 @@ export const jJsvRuntimeBridge = {
461
576
  warmUpView,
462
577
  warmLoadView,
463
578
  closeWarmedView,
464
- preDownloadSdk
465
- };
579
+ preDownloadSdk,
580
+ getNetworkTypeStatusImmediate,
581
+ registerNetStateListener,
582
+ unRegisterNetStateListener
583
+ };
584
+
585
+ export {
586
+ bridge as jJsvRuntimeBridge
587
+ };
@@ -0,0 +1,62 @@
1
+ import ForgeHandles from "../../../JsViewVueTools/ForgeHandles";
2
+ import { TextureBase } from "../Texture"
3
+
4
+ export type CapturedCallback = (
5
+ textureAccessName: string,
6
+ autoRecycleSet: boolean,
7
+ width: number,
8
+ height: number) => void;
9
+
10
+ export class CapturedTexture extends TextureBase {
11
+ private _AutoRecycle: boolean;
12
+ private _Callback: CapturedCallback | null;
13
+ private _CaptureDiv: any;
14
+ private _Canceled: boolean = false;
15
+
16
+ constructor(
17
+ captureDiv: any,
18
+ callback: CapturedCallback,
19
+ autoRecycle: boolean) {
20
+ super(null);
21
+
22
+ this._CaptureDiv = captureDiv;
23
+ this._Callback = callback;
24
+ this._AutoRecycle = autoRecycle;
25
+ }
26
+
27
+ // 清理对Callback和div的引用,防止泄露
28
+ cancel() {
29
+ if (!this._Canceled) {
30
+ this._Callback = null;
31
+ this._CaptureDiv = null;
32
+ this._Canceled = true;
33
+ }
34
+ }
35
+
36
+ override commit(): String {
37
+ this.textureRef = (ForgeHandles.TextureManager as any).GetCapturedTexture();
38
+ this._CaptureDiv.jsvGetProxyView(true).Capture2Texture(this.textureRef,
39
+ (result: string) => {
40
+ let resultObj: any = JSON.parse(result);
41
+
42
+ if (this._Canceled) {
43
+ return;
44
+ }
45
+
46
+ // 处理自动回收
47
+ if (!this._AutoRecycle) {
48
+ this.textureRef.DisableAutoRecycle(); // 取消自动清理
49
+ this.addToStore(); // 用TextureStore来跟进引用状态
50
+ }
51
+
52
+ // 回调
53
+ this._Callback?.(
54
+ this.getStoreName(),
55
+ this._AutoRecycle,
56
+ resultObj.width as number,
57
+ resultObj.height as number);
58
+ }
59
+ );
60
+ return '';
61
+ }
62
+ }
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import CanvasTexture from "./CanvasTexture/CanvasTexture";
19
+ import { CapturedTexture, CapturedCallback } from "./CapturedTexture/CapturedTexture";
19
20
  import sStore from "./Store";
20
21
 
21
22
  let sJsvTextureConst = {
@@ -29,30 +30,63 @@ let sTextureStoreApi: Object = {
29
30
  /**
30
31
  * canvasTexture
31
32
  * 创建CanvasTexture句柄,执行commit()后, 获取访问名(访问名规则: 输入参数 baseName + 分配id)
32
- * 可以在 img.src 或者 div.backgroundImage 通过 "texturestore://访问名"
33
+ * 可以在 img.src 或者 div.backgroundImage 通过 "texturestore://访问名" 来使用
33
34
  *
34
35
  * @param {int} width 此Canvas画布的宽度
35
36
  * @param {int} height 此Canvas画布的高度
36
37
  * @param {String|null} baseName 可选, 访问名的前缀信息
37
38
  * @return {CanvasTexture}
38
39
  */
39
- canvasTexture: (width: Number, height: Number, baseName: String | null): Object => {
40
+ canvasTexture: (width: Number, height: Number, baseName: String | null): CanvasTexture => {
40
41
  return new CanvasTexture(width, height, baseName);
41
42
  },
42
43
 
44
+ /**
45
+ * capture2Texture
46
+ * 对给定div做截图并生成一个Texture, 在回调函数中返回此Texture的访问名,
47
+ * 此访问名可以在 img.src 或者 div.backgroundImage 通过 "texturestore://访问名" 来使用
48
+ * 注意: PC模拟环境下,无法截取运动物体的中间状态,但盒子端可以正常截取
49
+ *
50
+ * 关于 autoRecycle:
51
+ * true(默认值): 收到callback的访问名后,请立即设置给使用的地方,若此宏任务结束(其触发的所有微任务全完成后)时,
52
+ * 若资源未被div和img使用,则会自动回收,回收后此访问名对应内容为黑屏
53
+ * false: 截图资源永久存在,可被反复使用,直到 JsvTextureStoreApi.deleteTexture(访问名) 进行清理
54
+ *
55
+ * @param {DivVueRef} captureDiv 要截图的div
56
+ * @param {CapturedCallback} callback 完成截屏后的回调, 函数参数:
57
+ * (textureAccessName: string, // 访问名
58
+ * autoRecycleSet: boolean, // 通知是否为自动删除(和入参时一致)
59
+ * width: number, // 截取div的宽
60
+ * height: number) => void // 截取div的高
61
+ * @param {boolean} autoRecycle 可选, 是否当无div/img引用时会自动释放
62
+ * 为true的场景在callback收到资源名后, 需要使用完毕后调用 deleteTexture 手动释放
63
+ * 在手动释放之前,可以赋给其他div/img来复用
64
+ * @return {CapturedTexture} 用于cancel的句柄,当cancel时,会清理对div和Callback的引用
65
+ */
66
+ capture2Texture: (
67
+ captureDiv: any,
68
+ callback: CapturedCallback,
69
+ autoRecycle: boolean = true): CapturedTexture => {
70
+
71
+ let texture = new CapturedTexture(captureDiv, callback, autoRecycle);
72
+ texture.commit();
73
+
74
+ return texture;
75
+ },
76
+
43
77
  /**
44
78
  * deleteTexture
45
- * 删除commit后的texture
79
+ * 删除访问名对应的texture资源
46
80
  *
47
- * @param {String} storeName 此Texture的应用名称, 是canvasTexture.commit()后的返回值
81
+ * @param {String} accessName 此Texture的访问名,访问名来自: CanvasTexture.commit 或 capture2Texture 的回调
48
82
  */
49
- deleteTexture: (storeName: String) => {
50
- let textureRef = sStore.getFromStore(storeName);
83
+ deleteTexture: (accessName: String) => {
84
+ let textureRef = sStore.getFromStore(accessName);
51
85
  if (textureRef) {
52
86
  // 释放native端的texture实体
53
87
  textureRef.recycle();
54
88
  }
55
- }
89
+ },
56
90
  }
57
91
 
58
92
  export {
@@ -12,10 +12,14 @@ export class TextureBase {
12
12
  }
13
13
 
14
14
  protected addToStore() {
15
- this.storeName = `${this.baseName}-${this.textureRef?.GetTextureId()}`;
15
+ this.storeName = this.getStoreName();
16
16
  sStore.addToStore(this.storeName, this);
17
17
  }
18
18
 
19
+ protected getStoreName() {
20
+ return `${this.baseName}-${this.textureRef?.GetTextureId()}`;
21
+ }
22
+
19
23
  /**
20
24
  * commit
21
25
  * 完成绘制设置,出发制作目标texture
@@ -27,6 +31,16 @@ export class TextureBase {
27
31
  return this.storeName;
28
32
  }
29
33
 
34
+ /**
35
+ * getTextureRef
36
+ * 内部接口,获取内联的Forge.ImageTexture的句柄
37
+ *
38
+ * @return {String} BaseName-textureId 格式的名字,用于 jsvtexturestore:// 的访问链接
39
+ */
40
+ public getTextureRef(): any {
41
+ return this.textureRef;
42
+ }
43
+
30
44
  public recycle() {
31
45
  // 释放native端的texture实体
32
46
  let textureRef = sStore.removeFromStore(this.storeName);
@@ -24,3 +24,5 @@ export * from "./JsvPerformance.ts"
24
24
  export * from "./JsvTextureStore/JsvTextureStore.ts"
25
25
  export * from "./JsvTextureDefines.ts"
26
26
  export * from "./JsvFederationTools.ts"
27
+ export * from "./ConstSymbol.ts"
28
+ export * from "./ForgeConstDefine.ts"