@shijiu/jsview-vue 2.2.426-test.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 (126) hide show
  1. package/bin/browser/BrowserAudio.vue.mjs +4 -1
  2. package/bin/jsview-vue-common.mjs +1 -1
  3. package/bin/jsview-vue.mjs +9771 -7511
  4. package/bin/types/utils/JsViewEngineWidget/JsvFocus/JsvFocusHub.d.ts +21 -1
  5. package/bin/types/utils/JsViewEngineWidget/JsvFocus/JsvFocusManager.d.ts +11 -2
  6. package/bin/types/utils/JsViewEngineWidget/MetroWidget/DebugFrame.vue.d.ts +8 -0
  7. package/bin/types/utils/JsViewEngineWidget/MetroWidget/DebugTools.d.ts +5 -0
  8. package/bin/types/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue.d.ts +24 -6
  9. package/bin/types/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue.d.ts +24 -6
  10. package/bin/types/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.d.ts +9 -2
  11. package/bin/types/utils/JsViewEngineWidget/MetroWidget/RenderItem.d.ts +8 -1
  12. package/bin/types/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.d.ts +2 -1
  13. package/bin/types/utils/JsViewEngineWidget/WidgetCommon.d.ts +10 -7
  14. package/bin/types/utils/JsViewPlugin/JsvAudio/version.d.mts +1 -0
  15. package/bin/types/utils/JsViewPlugin/JsvAudio/version.d.ts +1 -0
  16. package/bin/types/utils/JsViewPlugin/JsvLatex/BrowserJsvLatex.vue.d.ts +1 -1
  17. package/bin/types/utils/JsViewPlugin/JsvLatex/JsvLatex.vue.d.ts +1 -1
  18. package/bin/types/utils/JsViewPlugin/JsvPlayer/AckEventDefine.d.ts +10 -0
  19. package/bin/types/utils/JsViewPlugin/JsvPlayer/BrowserJsvPlayer.vue.d.ts +1 -2
  20. package/bin/types/utils/JsViewPlugin/JsvPlayer/JsvMedia.d.ts +2 -2
  21. package/bin/types/utils/JsViewVueTools/ForgeHandles.d.ts +1 -0
  22. package/bin/types/utils/JsViewVueTools/JsvRuntimeBridge.d.ts +43 -1
  23. package/bin/types/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/Path.d.ts +21 -0
  24. package/bin/types/utils/JsViewVueTools/JsvTextureStore/CapturedTexture/CapturedTexture.d.ts +3 -3
  25. package/bin/types/utils/JsViewVueTools/JsvTextureStore/DominantColor/GetDominantColor.d.ts +7 -0
  26. package/bin/types/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.d.ts +15 -2
  27. package/bin/types/utils/JsViewVueTools/JsvTextureStore/Store.d.ts +2 -0
  28. package/bin/types/utils/JsViewVueTools/JsvTextureStore/Texture.d.ts +4 -0
  29. package/bin/types/utils/JsViewVueTools/index.d.ts +0 -1
  30. package/bin/types/utils/JsViewVueWidget/Jsv3dDiv.vue.d.ts +120 -0
  31. package/bin/types/utils/JsViewVueWidget/Jsv3dStage.vue.d.ts +144 -0
  32. package/bin/types/utils/JsViewVueWidget/JsvApic/JsvApic/index.d.ts +50 -2
  33. package/bin/types/utils/JsViewVueWidget/JsvApic/JsvApic2/index.d.ts +23 -2
  34. package/bin/types/utils/JsViewVueWidget/JsvDashPath.vue.d.ts +11 -0
  35. package/bin/types/utils/JsViewVueWidget/JsvDriftScope/JsvDriftScope.vue.d.ts +4 -4
  36. package/bin/types/utils/JsViewVueWidget/JsvFilterView.vue.d.ts +3 -3
  37. package/bin/types/utils/JsViewVueWidget/JsvFlexCell/JsvFullScrAdjust.vue.d.ts +78 -0
  38. package/bin/types/utils/JsViewVueWidget/JsvFlexCell/index.d.ts +1 -0
  39. package/bin/types/utils/JsViewVueWidget/JsvFragShaderView/JsvFragShaderView.vue.d.ts +2 -1
  40. package/bin/types/utils/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue.d.ts +3 -3
  41. package/bin/types/utils/JsViewVueWidget/JsvFreeMoveActor/JsvEnvBlocker.vue.d.ts +3 -3
  42. package/bin/types/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.d.ts +1 -0
  43. package/bin/types/utils/JsViewVueWidget/JsvInput/Cursor.vue.d.ts +1 -1
  44. package/bin/types/utils/JsViewVueWidget/JsvMindMap/JsvMindMap.vue.d.ts +3 -3
  45. package/bin/types/utils/JsViewVueWidget/JsvNinePatch.vue.d.ts +4 -4
  46. package/bin/types/utils/JsViewVueWidget/JsvPosterDiv.vue.d.ts +3 -0
  47. package/bin/types/utils/JsViewVueWidget/JsvPosterImage.vue.d.ts +3 -0
  48. package/bin/types/utils/JsViewVueWidget/JsvRipple/JsvRipple.vue.d.ts +3 -3
  49. package/bin/types/utils/JsViewVueWidget/JsvSmoothSlideContainer.vue.d.ts +72 -0
  50. package/bin/types/utils/JsViewVueWidget/JsvSoundPool.d.ts +26 -0
  51. package/bin/types/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue.d.ts +10 -37
  52. package/bin/types/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue.d.ts +1 -1
  53. package/bin/types/utils/JsViewVueWidget/JsvSwiper/JsvSmoothSwiper.vue.d.ts +112 -0
  54. package/bin/types/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue.d.ts +1 -1
  55. package/bin/types/utils/JsViewVueWidget/JsvSwiper/JsvSwiper2.vue.d.ts +142 -0
  56. package/bin/types/utils/JsViewVueWidget/JsvSwiper/index.d.ts +3 -1
  57. package/bin/types/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue.d.ts +3 -3
  58. package/bin/types/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue.d.ts +4 -3
  59. package/bin/types/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue.d.ts +3 -3
  60. package/bin/types/utils/JsViewVueWidget/JsvVisibleSensor/index.d.ts +3 -3
  61. package/bin/types/utils/JsViewVueWidget/index.d.ts +4 -1
  62. package/package.json +1 -1
  63. package/utils/JsViewEngineWidget/CheckType.js +3 -3
  64. package/utils/JsViewEngineWidget/JsvFocus/JsvFocusBlock.vue +25 -6
  65. package/utils/JsViewEngineWidget/JsvFocus/JsvFocusHub.ts +27 -1
  66. package/utils/JsViewEngineWidget/JsvFocus/JsvFocusManager.ts +22 -3
  67. package/utils/JsViewEngineWidget/MetroWidget/DebugFrame.vue +22 -0
  68. package/utils/JsViewEngineWidget/MetroWidget/DebugTools.ts +37 -0
  69. package/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue +42 -7
  70. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +97 -13
  71. package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +876 -412
  72. package/utils/JsViewEngineWidget/MetroWidget/RenderItem.ts +43 -2
  73. package/utils/JsViewEngineWidget/MetroWidget/TaskManager.ts +38 -26
  74. package/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.ts +144 -73
  75. package/utils/JsViewEngineWidget/WidgetCommon.ts +12 -0
  76. package/utils/JsViewPlugin/JsvAudio/BrowserAudio/BrowserAudio.vue +4 -0
  77. package/utils/JsViewPlugin/JsvAudio/BrowserAudio/JsvSystemAudio.vue +13 -13
  78. package/utils/JsViewPlugin/JsvAudio/version.js +1 -1
  79. package/utils/JsViewPlugin/JsvAudio/version.mjs +1 -1
  80. package/utils/JsViewPlugin/JsvPlayer/AckEventDefine.ts +82 -0
  81. package/utils/JsViewPlugin/JsvPlayer/BrowserJsvPlayer.vue +50 -32
  82. package/utils/JsViewVueTools/FeatureActive.ts +2 -1
  83. package/utils/JsViewVueTools/ForgeHandles.ts +5 -2
  84. package/utils/JsViewVueTools/JsvRuntimeBridge.js +109 -4
  85. package/utils/JsViewVueTools/JsvTextTools.ts +3 -1
  86. package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/Path.ts +38 -2
  87. package/utils/JsViewVueTools/JsvTextureStore/CapturedTexture/CapturedTexture.ts +15 -12
  88. package/utils/JsViewVueTools/JsvTextureStore/DominantColor/GetDominantColor.ts +36 -0
  89. package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +24 -3
  90. package/utils/JsViewVueTools/JsvTextureStore/Store.ts +33 -21
  91. package/utils/JsViewVueTools/JsvTextureStore/Texture.ts +56 -41
  92. package/utils/JsViewVueTools/index.js +0 -1
  93. package/utils/JsViewVueWidget/Jsv3dDiv.vue +85 -0
  94. package/utils/JsViewVueWidget/Jsv3dStage.vue +50 -0
  95. package/utils/JsViewVueWidget/JsvApic/JsvApic/index.js +1 -8
  96. package/utils/JsViewVueWidget/JsvApic/JsvApic2/index.js +1 -8
  97. package/utils/JsViewVueWidget/JsvDashPath.vue +150 -0
  98. package/utils/JsViewVueWidget/JsvFlexCell/JsvFlexDiv.vue +1 -1
  99. package/utils/JsViewVueWidget/JsvFlexCell/JsvFullScrAdjust.vue +153 -0
  100. package/utils/JsViewVueWidget/JsvFlexCell/JsvScreenFlex.vue +2 -2
  101. package/utils/JsViewVueWidget/JsvFlexCell/index.js +1 -0
  102. package/utils/JsViewVueWidget/JsvFragShaderView/JsvFragShaderView.vue +26 -22
  103. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +1 -1
  104. package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +8 -0
  105. package/utils/JsViewVueWidget/JsvInput/EditViewOperator.ts +1 -1
  106. package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +1 -0
  107. package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +0 -9
  108. package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +57 -71
  109. package/utils/JsViewVueWidget/JsvPosterDiv.vue +15 -8
  110. package/utils/JsViewVueWidget/JsvPosterImage.vue +11 -1
  111. package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +2 -2
  112. package/utils/JsViewVueWidget/JsvQrcode/JsvQrcode.vue +1 -1
  113. package/utils/JsViewVueWidget/JsvSmoothSlideContainer.vue +108 -0
  114. package/utils/JsViewVueWidget/JsvSoundPool.js +75 -12
  115. package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +99 -61
  116. package/utils/JsViewVueWidget/JsvSwiper/JsvSmoothSwiper.vue +543 -0
  117. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +3 -3
  118. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper2.vue +644 -0
  119. package/utils/JsViewVueWidget/JsvSwiper/index.js +3 -1
  120. package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +56 -50
  121. package/utils/JsViewVueWidget/index.js +4 -1
  122. package/bin/browser/BrowserApic.vue.mjs +0 -114
  123. package/bin/browser/BrowserApic2.vue.mjs +0 -108
  124. package/bin/browser/BrowserApicLib.mjs +0 -431
  125. package/bin/types/utils/JsViewVueTools/JsvDemoTester.d.ts +0 -2
  126. package/utils/JsViewVueTools/JsvDemoTester.js +0 -81
@@ -84,6 +84,11 @@ const TexAlignAnchor = {
84
84
  };
85
85
  export { TexAlignAnchor };
86
86
 
87
+ const STATE_IDLE = 0;
88
+ const STATE_RUNNING = 1;
89
+ const STATE_PAUSED = 2;
90
+ const STATE_END = 3;
91
+
87
92
  export default {
88
93
  props: {
89
94
  src: String,
@@ -125,10 +130,15 @@ export default {
125
130
  },
126
131
  deep: true,
127
132
  },
133
+ transform: {
134
+ handler(newValue, oldValue) {
135
+ this.innerView.ResetTextureCssTransform(newValue, this.transformOrigin);
136
+ },
137
+ },
128
138
  },
129
139
  setup() {
130
140
  return {
131
- forgeAnimation: null,
141
+ runningState: STATE_IDLE, // 0:未开始, 1:运行中, 2:暂停, 3:正常结束
132
142
  innerViewId: -1,
133
143
  };
134
144
  },
@@ -244,8 +254,11 @@ export default {
244
254
  return new Forge.LayoutView(texture_set);
245
255
  },
246
256
 
247
- _onAnimationEnd() {
248
- this.onAnimationEnd?.();
257
+ _onAnimationEnd(normal_end) {
258
+ if (normal_end) {
259
+ this.runningState = STATE_END;
260
+ }
261
+ this.onAnimationEnd?.(normal_end);
249
262
  },
250
263
 
251
264
  _updateTexCoord() {
@@ -273,9 +286,35 @@ export default {
273
286
  }
274
287
  },
275
288
 
276
- start() {
277
- if (this.forgeAnimation && this.innerView) {
278
- this.innerView.StartTextureAnimation(this.forgeAnimation);
289
+ _buildAnimation(a) {
290
+ if (a) {
291
+ let anim = new Forge.CssKeyframeAnimation(
292
+ "@keyframes texAnimDef" + a,
293
+ this.duration,
294
+ Forge.Easing.str2Easing(this.easing),
295
+ 1,
296
+ 1
297
+ );
298
+ anim.EnableDelay(this.delay).SetRepeat(this.repeat);
299
+ anim.Enable(Forge.AnimationEnable.ReleaseAfterEndCallback);
300
+ anim.SetAnimationListener(
301
+ new Forge.AnimationListener(null, this._onAnimationEnd, null)
302
+ );
303
+
304
+ return anim;
305
+ } else {
306
+ return null;
307
+ }
308
+ },
309
+
310
+ start(customAnim) {
311
+ if (this.innerView) {
312
+ const a = customAnim ?? this.animation;
313
+ let anim = this._buildAnimation(a);
314
+ if (anim) {
315
+ this.runningState = STATE_RUNNING;
316
+ this.innerView.StartTextureAnimation(anim);
317
+ }
279
318
  }
280
319
  },
281
320
 
@@ -311,9 +350,9 @@ export default {
311
350
  );
312
351
  // 1.1 兼容border转为decorate
313
352
  let decorate = this.$props.decorate;
314
- // if (this.$props.borderRadius) {
315
- // decorate = this._readRadius(this.$props.borderRadius);
316
- // }
353
+ if (this.$props.borderRadius) {
354
+ decorate = this._readRadius(this.$props.borderRadius);
355
+ }
317
356
 
318
357
  // 2.创建view
319
358
  this.innerView = this._createForgeView(view_texture, decorate);
@@ -326,26 +365,7 @@ export default {
326
365
  }
327
366
  this._updateTexCoord();
328
367
 
329
- // 4.设置texture的动画形变
330
- if (this.animation) {
331
- this.forgeAnimation = new Forge.CssKeyframeAnimation(
332
- "@keyframes texAnimDef" + this.animation,
333
- this.duration,
334
- null,
335
- 1,
336
- 1
337
- );
338
- this.forgeAnimation.EnableDelay(this.delay).SetRepeat(this.repeat);
339
- this.forgeAnimation.Enable(Forge.AnimationEnable.ReleaseAfterEndCallback);
340
- this.forgeAnimation.SetAnimationListener(
341
- new Forge.AnimationListener(null, this._onAnimationEnd, null)
342
- );
343
- } else {
344
- this.forgeAnimation = null;
345
- }
346
-
347
- // 5. inner view标准处理
348
-
368
+ // 4. inner view标准处理
349
369
  this.innerViewId = Forge.sViewStore.add(new Forge.ViewInfo(this.innerView));
350
370
  },
351
371
  beforeUnmount() {
@@ -360,33 +380,19 @@ export default {
360
380
  }
361
381
  },
362
382
  activated() {
363
- if (this.innerView) {
364
- if (this.animation && this.forgeAnimation == null) {
365
- this.forgeAnimation = new Forge.CssKeyframeAnimation(
366
- "@keyframes texAnimDef" + this.animation,
367
- this.duration,
368
- null,
369
- 1,
370
- 1
371
- );
372
- this.forgeAnimation.EnableDelay(this.delay).SetRepeat(this.repeat);
373
- this.forgeAnimation.Enable(
374
- Forge.AnimationEnable.ReleaseAfterEndCallback
375
- );
376
- this.forgeAnimation.SetAnimationListener(
377
- new Forge.AnimationListener(null, this._onAnimationEnd, null)
378
- );
379
- this.innerView.StartTextureAnimation(this.forgeAnimation);
380
- } else {
381
- this.forgeAnimation = null;
382
- }
383
+ if (this.innerView && this.runningState == STATE_PAUSED) {
384
+ // 动画未正常结束,重新开始动画
385
+ let anim = this._buildAnimation(this.animation);
386
+ this.innerView.StartTextureAnimation(anim); // pause状态,一定有值
383
387
  }
384
388
  },
385
389
  deactivated() {
386
390
  if (this.innerView) {
387
391
  this.innerView.StopTextureAnimation();
392
+ if (this.runningState == STATE_RUNNING) {
393
+ this.runningState = STATE_PAUSED;
394
+ }
388
395
  }
389
- this.forgeAnimation = null;
390
396
  },
391
397
  };
392
398
  </script>
@@ -20,7 +20,7 @@ export {
20
20
  export { default as JsvQrcode } from "./JsvQrcode/JsvQrcode.vue";
21
21
  export { default as JsvSpray } from "./JsvSpray/JsvSpray.vue"
22
22
  export * from "./JsvSpriteAnim";
23
- export { default as JsvSwiper } from "./JsvSwiper";
23
+ export { JsvSwiper, JsvSwiper2, JsvSmoothSwiper } from "./JsvSwiper";
24
24
  export { default as JsvSwiper3D } from "./JsvSwiper3D";
25
25
  export { default as JsvTextureAnim, TexAlignAnchor, DECORATE_NINEPATCH_ALPHA_MIX, DECORATE_BORDER_RADIUS } from "./JsvTextureAnim";
26
26
  export { default as JsvVisibleSensor } from "./JsvVisibleSensor";
@@ -63,3 +63,6 @@ export * from "./JsvClipDiv"
63
63
  export * from "./JsvDriftScope"
64
64
  export { default as JsvTouchModeSwitcher } from "./JsvTouchModeSwitcher.vue"
65
65
  export { default as JsvDragBox } from "./JsvDragBox/JsvDragBox.vue"
66
+ export { default as Jsv3dDiv } from "./Jsv3dDiv.vue";
67
+ export { default as Jsv3dStage } from "./Jsv3dStage.vue";
68
+ export { default as JsvDashPath } from "./JsvDashPath.vue";
@@ -1,114 +0,0 @@
1
- import { shallowRef, onMounted, openBlock, createElementBlock, normalizeStyle } from 'vue';
2
- import { W as WebpData, G as GifData, V as Viewer } from './BrowserApicLib.mjs';
3
- import { L as LoopType } from '../jsview-vue-common.mjs';
4
-
5
- /*
6
- + @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvApic/BrowserApic.vue}
7
- */
8
- const _sfc_main = {
9
- __name: "BrowserApic",
10
- props: {
11
- src: String,
12
- style: Object,
13
- autoPlay: {
14
- type: Boolean,
15
- default: true
16
- },
17
- loopType: {
18
- type: Number,
19
- default: LoopType.LOOP_DEFAULT
20
- },
21
- loopInfo: {
22
- type: Array,
23
- default: () => [[-1, -1, -1]]
24
- },
25
- onStart: Function,
26
- onEnd: Function,
27
- onLoad: Function
28
- },
29
- setup(__props, { expose }) {
30
- const props = __props;
31
- const renderDocument = window.JsvCode.Dom.RenderDocument ? window.JsvCode.Dom.RenderDocument : window.JsvCode.Dom.BrowserDocument;
32
- const loadImage = (url) => {
33
- return new Promise((resolve, reject) => {
34
- let xhr = new XMLHttpRequest();
35
- xhr.open("GET", url);
36
- xhr.responseType = "arraybuffer";
37
- xhr.onreadystatechange = () => {
38
- if (xhr.readyState === 4 && xhr.status === 200) {
39
- if (xhr.status == 200) {
40
- let apic_data;
41
- if (url.indexOf(".webp") > 0) {
42
- apic_data = new WebpData(xhr.response);
43
- resolve(apic_data);
44
- } else if (url.indexOf(".gif") > 0) {
45
- apic_data = new GifData(xhr.response);
46
- resolve(apic_data);
47
- } else {
48
- reject("unsupport file " + url);
49
- }
50
- } else {
51
- reject("get image data failed. " + url + " " + xhr.status);
52
- }
53
- }
54
- };
55
- xhr.send();
56
- });
57
- };
58
- const getUrl = (base_url) => {
59
- let url_trim = base_url.trim();
60
- if (url_trim.indexOf("http") === 0) {
61
- return url_trim;
62
- } else if (url_trim.indexOf("url") === 0) {
63
- let index_1 = url_trim.indexOf("(");
64
- let index_2 = url_trim.indexOf(")");
65
- return url_trim.substring(index_1 + 1, index_2);
66
- } else {
67
- return url_trim;
68
- }
69
- };
70
- let viewer = null;
71
- let canvasProxyRef = shallowRef(null);
72
- const play = () => {
73
- viewer?.play(props.loopType, props.loopInfo);
74
- };
75
- const stop = (frameCount = -1) => {
76
- viewer?.stop(frameCount);
77
- };
78
- onMounted(() => {
79
- let domLayoutView = canvasProxyRef.value.jsvGetProxyView();
80
- domLayoutView.RegisterOnProxyReady(() => {
81
- let canvas = renderDocument.createElement("canvas");
82
- canvas.style.width = props.style.width + "px";
83
- canvas.style.height = props.style.height + "px";
84
- domLayoutView.HtmlGetElement().appendChild(canvas);
85
- loadImage(getUrl(props.src)).then((data) => {
86
- let listener = {
87
- onstart: props.onStart,
88
- onend: props.onEnd
89
- };
90
- viewer = new Viewer(data, canvas, listener);
91
- if (props.onLoad) {
92
- props.onLoad();
93
- }
94
- if (props.autoPlay) {
95
- play();
96
- }
97
- }).catch((err) => console.error(err));
98
- });
99
- });
100
- expose({
101
- play,
102
- stop
103
- });
104
- return (_ctx, _cache) => {
105
- return openBlock(), createElementBlock("div", {
106
- ref_key: "canvasProxyRef",
107
- ref: canvasProxyRef,
108
- style: normalizeStyle(props.style)
109
- }, null, 4);
110
- };
111
- }
112
- };
113
-
114
- export { _sfc_main as default };
@@ -1,108 +0,0 @@
1
- import { shallowRef, onMounted, openBlock, createElementBlock, normalizeStyle } from 'vue';
2
- import { W as WebpData, G as GifData, V as Viewer } from './BrowserApicLib.mjs';
3
- import { L as LoopType } from '../jsview-vue-common.mjs';
4
-
5
- /*
6
- + @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvApic2/BrowserApic2.vue}
7
- */
8
- const _sfc_main = {
9
- __name: "BrowserApic2",
10
- props: {
11
- src: String,
12
- style: Object,
13
- onStart: Function,
14
- onEnd: Function,
15
- onLoad: Function
16
- },
17
- setup(__props, { expose }) {
18
- const props = __props;
19
- let waitForPlayInfo = null;
20
- const renderDocument = window.JsvCode.Dom.RenderDocument ? window.JsvCode.Dom.RenderDocument : window.JsvCode.Dom.BrowserDocument;
21
- const loadImage = (url) => {
22
- return new Promise((resolve, reject) => {
23
- let xhr = new XMLHttpRequest();
24
- xhr.open("GET", url);
25
- xhr.responseType = "arraybuffer";
26
- xhr.onreadystatechange = () => {
27
- if (xhr.readyState === 4 && xhr.status === 200) {
28
- if (xhr.status == 200) {
29
- let apic_data;
30
- if (url.indexOf(".webp") > 0) {
31
- apic_data = new WebpData(xhr.response);
32
- resolve(apic_data);
33
- } else if (url.indexOf(".gif") > 0) {
34
- apic_data = new GifData(xhr.response);
35
- resolve(apic_data);
36
- } else {
37
- reject("unsupport file " + url);
38
- }
39
- } else {
40
- reject("get image data failed. " + url + " " + xhr.status);
41
- }
42
- }
43
- };
44
- xhr.send();
45
- });
46
- };
47
- const getUrl = (base_url) => {
48
- let url_trim = base_url.trim();
49
- if (url_trim.indexOf("http") === 0) {
50
- return url_trim;
51
- } else if (url_trim.indexOf("url") === 0) {
52
- let index_1 = url_trim.indexOf("(");
53
- let index_2 = url_trim.indexOf(")");
54
- return url_trim.substring(index_1 + 1, index_2);
55
- } else {
56
- return url_trim;
57
- }
58
- };
59
- let viewer = null;
60
- let canvasProxyRef = shallowRef(null);
61
- onMounted(() => {
62
- let domLayoutView = canvasProxyRef.value.jsvGetProxyView();
63
- domLayoutView.RegisterOnProxyReady(() => {
64
- let canvas = renderDocument.createElement("canvas");
65
- canvas.style.width = props.style.width + "px";
66
- canvas.style.height = props.style.height + "px";
67
- domLayoutView.HtmlGetElement().appendChild(canvas);
68
- loadImage(getUrl(props.src)).then((data) => {
69
- let listener = {
70
- onstart: props.onStart,
71
- onend: props.onEnd
72
- };
73
- viewer = new Viewer(data, canvas, listener);
74
- if (props.onLoad) {
75
- props.onLoad();
76
- }
77
- if (waitForPlayInfo) {
78
- viewer.play(...waitForPlayInfo);
79
- waitForPlayInfo = null;
80
- }
81
- }).catch((err) => console.error(err));
82
- });
83
- });
84
- expose({
85
- show: (frameIndex = 0) => {
86
- if (!isNaN(frameIndex)) {
87
- viewer?.play(LoopType.LOOP_SINGLE, [[0, frameIndex, 0]]);
88
- }
89
- },
90
- play: (...args) => {
91
- waitForPlayInfo = args;
92
- viewer?.play(...args);
93
- },
94
- stop: (frameCount = -1) => {
95
- viewer?.stop(frameCount);
96
- }
97
- });
98
- return (_ctx, _cache) => {
99
- return openBlock(), createElementBlock("div", {
100
- ref_key: "canvasProxyRef",
101
- ref: canvasProxyRef,
102
- style: normalizeStyle(props.style)
103
- }, null, 4);
104
- };
105
- }
106
- };
107
-
108
- export { _sfc_main as default };