@shijiu/jsview-vue 2.3.0 → 2.3.151-test.0

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 (56) hide show
  1. package/bin/browser/BrowserAudio.vue.mjs +4 -1
  2. package/bin/jsview-vue.mjs +2200 -466
  3. package/bin/types/utils/JsViewEngineWidget/JsvFocus/JsvFocusHub.d.ts +21 -1
  4. package/bin/types/utils/JsViewEngineWidget/MetroWidget/RenderItem.d.ts +5 -1
  5. package/bin/types/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.d.ts +2 -1
  6. package/bin/types/utils/JsViewEngineWidget/WidgetCommon.d.ts +10 -7
  7. package/bin/types/utils/JsViewVueTools/ForgeHandles.d.ts +1 -0
  8. package/bin/types/utils/JsViewVueTools/JsvRuntimeBridge.d.ts +37 -1
  9. package/bin/types/utils/JsViewVueTools/JsvTextureStore/CapturedTexture/CapturedTexture.d.ts +3 -3
  10. package/bin/types/utils/JsViewVueTools/JsvTextureStore/DominantColor/GetDominantColor.d.ts +7 -0
  11. package/bin/types/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.d.ts +14 -1
  12. package/bin/types/utils/JsViewVueTools/JsvTextureStore/Store.d.ts +2 -0
  13. package/bin/types/utils/JsViewVueTools/JsvTextureStore/Texture.d.ts +4 -0
  14. package/bin/types/utils/JsViewVueWidget/JsvDashPath.vue.d.ts +11 -0
  15. package/bin/types/utils/JsViewVueWidget/JsvFragShaderView/JsvFragShaderView.vue.d.ts +2 -1
  16. package/bin/types/utils/JsViewVueWidget/JsvSmoothSlideContainer.vue.d.ts +72 -0
  17. package/bin/types/utils/JsViewVueWidget/JsvSoundPool.d.ts +26 -0
  18. package/bin/types/utils/JsViewVueWidget/JsvSwiper/JsvSmoothSwiper.vue.d.ts +112 -0
  19. package/bin/types/utils/JsViewVueWidget/JsvSwiper/JsvSwiper2.vue.d.ts +142 -0
  20. package/bin/types/utils/JsViewVueWidget/JsvSwiper/index.d.ts +3 -1
  21. package/bin/types/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue.d.ts +2 -2
  22. package/bin/types/utils/JsViewVueWidget/index.d.ts +2 -1
  23. package/package.json +1 -1
  24. package/utils/JsViewEngineWidget/JsvFocus/JsvFocusHub.ts +27 -1
  25. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +35 -3
  26. package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +736 -386
  27. package/utils/JsViewEngineWidget/MetroWidget/RenderItem.ts +13 -2
  28. package/utils/JsViewEngineWidget/MetroWidget/TaskManager.ts +38 -26
  29. package/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.ts +144 -73
  30. package/utils/JsViewEngineWidget/WidgetCommon.ts +12 -0
  31. package/utils/JsViewPlugin/JsvAudio/BrowserAudio/BrowserAudio.vue +4 -0
  32. package/utils/JsViewPlugin/JsvAudio/BrowserAudio/JsvSystemAudio.vue +13 -13
  33. package/utils/JsViewPlugin/JsvPlayer/BrowserJsvPlayer.vue +1 -1
  34. package/utils/JsViewVueTools/FeatureActive.ts +2 -1
  35. package/utils/JsViewVueTools/ForgeHandles.ts +5 -2
  36. package/utils/JsViewVueTools/JsvRuntimeBridge.js +97 -1
  37. package/utils/JsViewVueTools/JsvTextTools.ts +3 -1
  38. package/utils/JsViewVueTools/JsvTextureStore/CapturedTexture/CapturedTexture.ts +15 -12
  39. package/utils/JsViewVueTools/JsvTextureStore/DominantColor/GetDominantColor.ts +36 -0
  40. package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +23 -2
  41. package/utils/JsViewVueTools/JsvTextureStore/Store.ts +33 -21
  42. package/utils/JsViewVueTools/JsvTextureStore/Texture.ts +56 -41
  43. package/utils/JsViewVueWidget/JsvDashPath.vue +150 -0
  44. package/utils/JsViewVueWidget/JsvFlexCell/JsvFullScrAdjust.vue +3 -1
  45. package/utils/JsViewVueWidget/JsvFragShaderView/JsvFragShaderView.vue +26 -22
  46. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +1 -1
  47. package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +1 -0
  48. package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +2 -2
  49. package/utils/JsViewVueWidget/JsvSmoothSlideContainer.vue +108 -0
  50. package/utils/JsViewVueWidget/JsvSoundPool.js +75 -12
  51. package/utils/JsViewVueWidget/JsvSwiper/JsvSmoothSwiper.vue +543 -0
  52. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +3 -3
  53. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper2.vue +644 -0
  54. package/utils/JsViewVueWidget/JsvSwiper/index.js +3 -1
  55. package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +14 -8
  56. package/utils/JsViewVueWidget/index.js +2 -1
@@ -12,6 +12,7 @@
12
12
  * @prop {Array} uniforms uniform参数, [{ name: string, value: number }]
13
13
  * @prop {Array} textures texture参数, [{ name: string, resource: string }]
14
14
  * @prop {() => void} onStart 动画开始回调
15
+ * @prop {boolean} reverseAnimate 是否反向动画
15
16
  * @prop {(int,boolean) => void} onEnd
16
17
  * 动画结束回调,
17
18
  * 返回值1号 int: 回到参数为动画的序列号,和startAnim的返回值匹配
@@ -65,6 +66,10 @@ const rProps = defineProps({
65
66
  type: Boolean,
66
67
  default: false,
67
68
  },
69
+ reverseAnimate: {
70
+ type: Boolean,
71
+ default: false,
72
+ },
68
73
  shaderStr: {
69
74
  type: String,
70
75
  required: true,
@@ -88,8 +93,6 @@ const rProps = defineProps({
88
93
  // 激活引擎中的功能支持
89
94
  JsvUseFeature("JsvFragShaderView", FeatureNames.CustomFragShader);
90
95
 
91
- console.log("LudlDebug using JsvFragShaderView...");
92
-
93
96
  let rAnimRunning = shallowRef(false); // 动画是否在执行,画面只在动画进行时进行显示
94
97
  let vPreloadHandler = null;
95
98
  let vPreloadDone = false;
@@ -133,26 +136,25 @@ if (rProps.textures) {
133
136
  });
134
137
  preload_textures.push(new JsvTextureLoadTool.ItemSet(image_url));
135
138
  }
139
+ }
140
+ // 对图片进行预加载,等所有图片预加载完成后才能开始动画,以确保动画的完整性
136
141
 
137
- // 对图片进行预加载,等所有图片预加载完成后才能开始动画,以确保动画的完整性
138
-
139
- vPreloadHandler = JsvTextureLoadTool.preload(preload_textures, () => {
140
- vPreloadDone = true;
142
+ vPreloadHandler = JsvTextureLoadTool.preload(preload_textures, () => {
143
+ vPreloadDone = true;
141
144
 
142
- // 加载完成后直接释放句柄即可
143
- vPreloadHandler.recycleResource();
144
- vPreloadHandler = null;
145
+ // 加载完成后直接释放句柄即可
146
+ vPreloadHandler.recycleResource();
147
+ vPreloadHandler = null;
145
148
 
146
- if (vStartingPromise != null) {
147
- vStartingPromise.resolve();
148
- }
149
- });
150
- if (vPreloadHandler == null) {
151
- // 无需要preload的内容,直接视为preloadDone
152
- vPreloadDone = true;
153
- if (vStartingPromise != null) {
154
- vStartingPromise.resolve();
155
- }
149
+ if (vStartingPromise != null) {
150
+ vStartingPromise.resolve();
151
+ }
152
+ });
153
+ if (vPreloadHandler == null) {
154
+ // 无需要preload的内容,直接视为preloadDone
155
+ vPreloadDone = true;
156
+ if (vStartingPromise != null) {
157
+ vStartingPromise.resolve();
156
158
  }
157
159
  }
158
160
  }
@@ -178,7 +180,7 @@ function clearStartAnimTimeout() {
178
180
  }
179
181
  }
180
182
 
181
- const startAnim = (alt_duration, on_timeout_func) => {
183
+ const startAnim = (alt_duration, on_timeout_func, reverse = false) => {
182
184
  vStartingPromise = null; // 重置promise回执处理
183
185
  rAnimRunning.value = false;
184
186
  vStartToken++;
@@ -223,7 +225,9 @@ const startAnim = (alt_duration, on_timeout_func) => {
223
225
 
224
226
  if (duration > 0) {
225
227
  let shaderAnimation = new Forge.ShaderAnimation(duration, null);
226
- shaderAnimation.Enable(0x1); // ReleaseAfterEndCallback
228
+ shaderAnimation.Enable(
229
+ 0x1 | (reverse ? Forge.AnimationEnable.Reverse : 0)
230
+ ); // ReleaseAfterEndCallback
227
231
  shaderAnimation.SetAnimationListener(
228
232
  new Forge.AnimationListener(
229
233
  null /* animation的onStart目前不调用 */,
@@ -263,7 +267,7 @@ const stopAnim = () => {
263
267
 
264
268
  onMounted(() => {
265
269
  if (rProps.autoplay) {
266
- startAnim(rProps.duration);
270
+ startAnim(rProps.duration, undefined, rProps.reverseAnimate);
267
271
  }
268
272
  });
269
273
 
@@ -280,7 +280,7 @@ class ActorPackBuilder {
280
280
  ActOnGetToSpeed(
281
281
  this,
282
282
  xSpeed, ySpeed,
283
- [ActionCmdBuilder.ResetAcc(0, 0),
283
+ [ActionCmdBuilder.SetAccel(0, 0),
284
284
  this._NexusRecv ? StateCmdBuilder.FireNexusEvent(ActEventDefine.ActFinish, this._NexusRecv.token) : null
285
285
  ],
286
286
  true, // isFinal
@@ -157,6 +157,7 @@ function _OnTextChanged(input_final_text, dsp_text) {
157
157
  );
158
158
  rInputFinalText.value = dsp_text;
159
159
  rInputFinalTextLenth.value = dsp_text.length;
160
+ rProps.onTextChange?.(dsp_text);
160
161
  }
161
162
 
162
163
  function _OnCursorPositionChanged(text_left, cursor_left) {
@@ -197,13 +197,13 @@ const _getPreloadViewIdList = () => {
197
197
  return;
198
198
  }
199
199
  const callback_token = texture.RegisterLoadImageCallback(null, (params) => {
200
- console.log(`preload succeed ${image_url}`, params);
200
+ // console.log(`preload succeed ${image_url}`, params);
201
201
  preloadStateList[index] = true;
202
202
  preloadResultMap[item.url] = {
203
203
  width: params.width,
204
204
  height: params.height,
205
205
  };
206
- console.log(`preload succeed ${item.url}, params:${params}`);
206
+ // console.log(`preload succeed ${item.url}, params:${params}`);
207
207
  _checkPreload();
208
208
  });
209
209
  texture.EnableBackgroundLoad();
@@ -0,0 +1,108 @@
1
+ <template>
2
+ <div ref="root">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <script setup>
8
+ import ActorControl from "./JsvFreeMoveActor/ActorControl";
9
+ import { shallowRef, onMounted, computed, ref } from "vue";
10
+
11
+ const props = defineProps({
12
+ initPosition: {
13
+ type: Array,
14
+ default: () => [0, 0],
15
+ },
16
+ });
17
+
18
+ const ReachConditionGroup = 2;
19
+
20
+ const root = shallowRef();
21
+ const actorControl = new ActorControl();
22
+ let preTarget = props.initPosition;
23
+ let curTarget = props.initPosition;
24
+
25
+ onMounted(() => {
26
+ actorControl.bindForgeView(root.value.jsvGetProxyView(), true);
27
+ // 初始化位置
28
+ actorControl.run((cmds) => [
29
+ cmds.action().teleportTo(props.initPosition[0], props.initPosition[1]),
30
+ ]);
31
+ });
32
+
33
+ let curSpeed = 0;
34
+
35
+ /**
36
+ * 移动到指定位置
37
+ * @param speed 速度
38
+ * @param x 目标x坐标
39
+ * @param y 目标y坐标
40
+ * @param onReach 到达目标位置后的回调
41
+ * @param prex 到达前x坐标
42
+ * @param prey 到达前y坐标
43
+ * @param onPreReach 到达前回调
44
+ */
45
+ const moveTo = (speed, x, y, onReach, prex, prey, onPreReach) => {
46
+ if (x == curTarget[0] && y == curTarget[1] && curSpeed == speed) {
47
+ return;
48
+ }
49
+ curSpeed = speed;
50
+ let targetX = undefined;
51
+ let targetY = undefined;
52
+ let preTargetX = undefined;
53
+ let preTargetY = undefined;
54
+ let speedX = undefined;
55
+ let speedY = undefined;
56
+
57
+ preTarget = [curTarget[0], curTarget[1]];
58
+ curTarget = [x, y];
59
+ const vec = [x - preTarget[0], y - preTarget[1]];
60
+ const module = Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
61
+ if (vec[0] != 0) {
62
+ speedX = (vec[0] / module) * speed;
63
+ targetX = x;
64
+ preTargetX = prex;
65
+ } else if (vec[1] != 0) {
66
+ speedY = (vec[1] / module) * speed;
67
+ targetY = y;
68
+ preTargetY = prey;
69
+ }
70
+
71
+ actorControl.run((cmds) => [
72
+ cmds.state().removeConditionByGroup(ReachConditionGroup),
73
+ cmds.action(0, 0).setSpeed(speedX, speedY),
74
+ cmds
75
+ .condition(ReachConditionGroup)
76
+ .reachPosition(preTargetX, preTargetY)
77
+ .then([onPreReach]),
78
+ cmds
79
+ .condition(ReachConditionGroup)
80
+ .reachPosition(targetX, targetY)
81
+ .then([onReach]),
82
+ ]);
83
+ };
84
+
85
+ /**
86
+ * 刹车到指定位置
87
+ * @param x 目标x坐标
88
+ * @param y 目标y坐标
89
+ */
90
+ const brakeTo = (x, y) => {
91
+ actorControl.run((cmds) => [cmds.action(3, 0).brakeToPosition(x, y)]);
92
+ };
93
+
94
+ const stop = () => {
95
+ actorControl.run((cmds) => [cmds.action().setSpeed(0, 0)]);
96
+ };
97
+
98
+ const setSpeed = (speedX, speedY) => {
99
+ actorControl.run((cmds) => [cmds.action().setSpeed(speedX, speedY)]);
100
+ };
101
+
102
+ defineExpose({
103
+ moveTo,
104
+ brakeTo,
105
+ stop,
106
+ setSpeed,
107
+ });
108
+ </script>
@@ -49,22 +49,57 @@ class AudioController {
49
49
  this._SoundId = soundId;
50
50
  this._Url = url;
51
51
  this._StreamId = -1;
52
+ this._StreamStartTime = 0;
53
+ this._SubStreamId = -1; // 快速重复播放的第二路音轨
54
+ this._SubStreamStartTime = 0;
55
+ this._LatestStreamStartTime = 0;
52
56
 
53
57
  this._Rate = 1;
54
58
  this._Loop = 0;
55
59
  this._LeftVolume = 1;
56
60
  this._RightVolume = 1;
57
61
  this._Priority = 0;
62
+ this._FastRepeatGap = 0;
63
+ }
64
+
65
+ enableFastRepeat(mini_gap) {
66
+ this._FastRepeatGap = mini_gap;
58
67
  }
59
68
 
60
69
  /**
61
70
  * @description: 播放音频
62
71
  */
63
72
  play() {
73
+ if (this._FastRepeatGap == 0) {
74
+ this._playMainStream(0);
75
+ } else {
76
+ let now = Date.now();
77
+ if (now - this._LatestStreamStartTime > this._FastRepeatGap / 2 && now - this._StreamStartTime > this._FastRepeatGap) {
78
+ this._playMainStream(now);
79
+ } else {
80
+ if (now - this._LatestStreamStartTime > this._FastRepeatGap / 2 && now - this._SubStreamStartTime > this._FastRepeatGap) {
81
+ this._playSubStream(now);
82
+ }
83
+ }
84
+ }
85
+ }
86
+
87
+ _playMainStream(now) {
64
88
  if (this._StreamId !== -1) {
65
89
  this._SoundPool.stop(this._StreamId);
66
90
  }
67
91
  this._StreamId = this._SoundPool.play(this._SoundId, this._LeftVolume, this._RightVolume, this._Priority, this._Loop, this._Rate);
92
+ this._StreamStartTime = now;
93
+ this._LatestStreamStartTime = now;
94
+ }
95
+
96
+ _playSubStream(now) {
97
+ if (this._SubStreamId !== -1) {
98
+ this._SoundPool.stop(this._SubStreamId);
99
+ }
100
+ this._SubStreamId = this._SoundPool.play(this._SoundId, this._LeftVolume, this._RightVolume, this._Priority, this._Loop, this._Rate);
101
+ this._SubStreamStartTime = now;
102
+ this._LatestStreamStartTime = now;
68
103
  }
69
104
 
70
105
  /**
@@ -74,6 +109,11 @@ class AudioController {
74
109
  if (this._StreamId !== -1) {
75
110
  this._SoundPool.pause(this._StreamId);
76
111
  }
112
+ // 第二路直接停止即可
113
+ if (this._SubStreamId !== -1) {
114
+ this._SoundPool.stop(this._SubStreamId);
115
+ this._SubStreamId = -1;
116
+ }
77
117
  }
78
118
 
79
119
  /**
@@ -93,6 +133,10 @@ class AudioController {
93
133
  this._SoundPool.stop(this._StreamId);
94
134
  this._StreamId = -1;
95
135
  }
136
+ if (this._SubStreamId !== -1) {
137
+ this._SoundPool.stop(this._SubStreamId);
138
+ this._SubStreamId = -1;
139
+ }
96
140
  }
97
141
 
98
142
  /**
@@ -100,10 +144,8 @@ class AudioController {
100
144
  * @param {float} rate 播放的倍率
101
145
  */
102
146
  setRate(rate) {
147
+ // 在起播前设置
103
148
  this._Rate = rate;
104
- if (this._Streamid !== -1) {
105
- this._SoundPool.setRate(this._StreamId, this._Rate);
106
- }
107
149
  }
108
150
 
109
151
  /**
@@ -112,11 +154,9 @@ class AudioController {
112
154
  * @param {float} rightVolume 右声道音量
113
155
  */
114
156
  setVolume(leftVolume, rightVolume) {
157
+ // 在起播前设置
115
158
  this._LeftVolume = leftVolume;
116
159
  this._RightVolume = rightVolume;
117
- if (this._StreamId !== -1) {
118
- this._SoundPool.setVolume(this._StreamId, this._LeftVolume, this._RightVolume);
119
- }
120
160
  }
121
161
 
122
162
  /**
@@ -124,10 +164,8 @@ class AudioController {
124
164
  * @param {int} loop 循环次数
125
165
  */
126
166
  setLoop(loop) {
167
+ // 在起播前设置
127
168
  this._Loop = loop;
128
- if (this._StreamId !== -1) {
129
- this._SoundPool.setLoop(this._StreamId, this._Loop);
130
- }
131
169
  }
132
170
 
133
171
  /**
@@ -135,10 +173,8 @@ class AudioController {
135
173
  * @param {int} priority 优先级
136
174
  */
137
175
  setPriority(priority) {
176
+ // 在起播前设置
138
177
  this._Priority = priority;
139
- if (this._StreamId !== -1) {
140
- this._SoundPool.setPriority(this._StreamId, this._Priority);
141
- }
142
178
  }
143
179
  }
144
180
 
@@ -161,6 +197,30 @@ class JsvSoundPool {
161
197
  * @param {function} callback 资源加载完成回调 function(int state, AudioController controller) {}
162
198
  */
163
199
  request(url, netSetting, priority, callback) {
200
+ this._request(url, 0, netSetting, priority, callback);
201
+ }
202
+
203
+ /**
204
+ * @description: 准备音频资源
205
+ * @param {string} url 音频url
206
+ * @param {int} fastRepeatGap 最小间隔时间, 如果不为0则启用快速重复播放, 用两路音轨解决快速播放的漏音问题
207
+ * @param {string} netSetting http请求配置
208
+ * @param {int} priority 优先级
209
+ * @param {function} callback 资源加载完成回调 function(int state, AudioController controller) {}
210
+ */
211
+ requestInRepeatMode(url, fastRepeatGap, netSetting, priority, callback) {
212
+ this._request(url, fastRepeatGap, netSetting, priority, callback);
213
+ }
214
+
215
+ /**
216
+ * @description: 准备音频资源
217
+ * @param {string} url 音频url
218
+ * @param {int} repeatFastMiniGap 最小间隔时间, 如果不为0则启用快速重复播放, 用两路音轨解决快速播放的漏音问题
219
+ * @param {string} netSetting http请求配置
220
+ * @param {int} priority 优先级
221
+ * @param {function} callback 资源加载完成回调 function(int state, AudioController controller) {}
222
+ */
223
+ _request(url, repeatFastMiniGap, netSetting, priority, callback) {
164
224
  if (!supportSoundPool) {
165
225
  callback(-1, null);
166
226
  console.log("not support sound pool.");
@@ -181,6 +241,9 @@ class JsvSoundPool {
181
241
  referCount: 1
182
242
  };
183
243
  const controller = new AudioController(this._SoundPool, sound_id, realUrl);
244
+ if (repeatFastMiniGap > 0) {
245
+ controller.enableFastRepeat(repeatFastMiniGap);
246
+ }
184
247
  this._StreamIdMap.add(controller);
185
248
  callback(state, controller);
186
249
  } else {