@shijiu/jsview-vue 2.2.426-test.0 → 2.3.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.
- package/bin/jsview-vue-common.mjs +1 -1
- package/bin/jsview-vue.mjs +7506 -6980
- package/bin/types/utils/JsViewEngineWidget/JsvFocus/JsvFocusManager.d.ts +11 -2
- package/bin/types/utils/JsViewEngineWidget/MetroWidget/DebugFrame.vue.d.ts +8 -0
- package/bin/types/utils/JsViewEngineWidget/MetroWidget/DebugTools.d.ts +5 -0
- package/bin/types/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue.d.ts +24 -6
- package/bin/types/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue.d.ts +24 -6
- package/bin/types/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.d.ts +9 -2
- package/bin/types/utils/JsViewEngineWidget/MetroWidget/RenderItem.d.ts +3 -0
- package/bin/types/utils/JsViewPlugin/JsvAudio/version.d.mts +1 -0
- package/bin/types/utils/JsViewPlugin/JsvAudio/version.d.ts +1 -0
- package/bin/types/utils/JsViewPlugin/JsvLatex/BrowserJsvLatex.vue.d.ts +1 -1
- package/bin/types/utils/JsViewPlugin/JsvLatex/JsvLatex.vue.d.ts +1 -1
- package/bin/types/utils/JsViewPlugin/JsvPlayer/AckEventDefine.d.ts +10 -0
- package/bin/types/utils/JsViewPlugin/JsvPlayer/BrowserJsvPlayer.vue.d.ts +1 -2
- package/bin/types/utils/JsViewPlugin/JsvPlayer/JsvMedia.d.ts +2 -2
- package/bin/types/utils/JsViewVueTools/JsvRuntimeBridge.d.ts +6 -0
- package/bin/types/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/Path.d.ts +21 -0
- package/bin/types/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.d.ts +1 -1
- package/bin/types/utils/JsViewVueTools/index.d.ts +0 -1
- package/bin/types/utils/JsViewVueWidget/Jsv3dDiv.vue.d.ts +120 -0
- package/bin/types/utils/JsViewVueWidget/Jsv3dStage.vue.d.ts +144 -0
- package/bin/types/utils/JsViewVueWidget/JsvApic/JsvApic/index.d.ts +50 -2
- package/bin/types/utils/JsViewVueWidget/JsvApic/JsvApic2/index.d.ts +23 -2
- package/bin/types/utils/JsViewVueWidget/JsvDriftScope/JsvDriftScope.vue.d.ts +4 -4
- package/bin/types/utils/JsViewVueWidget/JsvFilterView.vue.d.ts +3 -3
- package/bin/types/utils/JsViewVueWidget/JsvFlexCell/JsvFullScrAdjust.vue.d.ts +78 -0
- package/bin/types/utils/JsViewVueWidget/JsvFlexCell/index.d.ts +1 -0
- package/bin/types/utils/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue.d.ts +3 -3
- package/bin/types/utils/JsViewVueWidget/JsvFreeMoveActor/JsvEnvBlocker.vue.d.ts +3 -3
- package/bin/types/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.d.ts +1 -0
- package/bin/types/utils/JsViewVueWidget/JsvInput/Cursor.vue.d.ts +1 -1
- package/bin/types/utils/JsViewVueWidget/JsvMindMap/JsvMindMap.vue.d.ts +3 -3
- package/bin/types/utils/JsViewVueWidget/JsvNinePatch.vue.d.ts +4 -4
- package/bin/types/utils/JsViewVueWidget/JsvPosterDiv.vue.d.ts +3 -0
- package/bin/types/utils/JsViewVueWidget/JsvPosterImage.vue.d.ts +3 -0
- package/bin/types/utils/JsViewVueWidget/JsvRipple/JsvRipple.vue.d.ts +3 -3
- package/bin/types/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue.d.ts +10 -37
- package/bin/types/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue.d.ts +1 -1
- package/bin/types/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue.d.ts +1 -1
- package/bin/types/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue.d.ts +3 -3
- package/bin/types/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue.d.ts +3 -2
- package/bin/types/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue.d.ts +3 -3
- package/bin/types/utils/JsViewVueWidget/JsvVisibleSensor/index.d.ts +3 -3
- package/bin/types/utils/JsViewVueWidget/index.d.ts +2 -0
- package/package.json +1 -1
- package/utils/JsViewEngineWidget/CheckType.js +3 -3
- package/utils/JsViewEngineWidget/JsvFocus/JsvFocusBlock.vue +25 -6
- package/utils/JsViewEngineWidget/JsvFocus/JsvFocusManager.ts +22 -3
- package/utils/JsViewEngineWidget/MetroWidget/DebugFrame.vue +22 -0
- package/utils/JsViewEngineWidget/MetroWidget/DebugTools.ts +37 -0
- package/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue +42 -7
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +62 -10
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +205 -91
- package/utils/JsViewEngineWidget/MetroWidget/RenderItem.ts +30 -0
- package/utils/JsViewPlugin/JsvAudio/version.js +1 -1
- package/utils/JsViewPlugin/JsvAudio/version.mjs +1 -1
- package/utils/JsViewPlugin/JsvPlayer/AckEventDefine.ts +82 -0
- package/utils/JsViewPlugin/JsvPlayer/BrowserJsvPlayer.vue +49 -31
- package/utils/JsViewVueTools/JsvRuntimeBridge.js +12 -3
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/Path.ts +38 -2
- package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +1 -1
- package/utils/JsViewVueTools/index.js +0 -1
- package/utils/JsViewVueWidget/Jsv3dDiv.vue +85 -0
- package/utils/JsViewVueWidget/Jsv3dStage.vue +50 -0
- package/utils/JsViewVueWidget/JsvApic/JsvApic/index.js +1 -8
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/index.js +1 -8
- package/utils/JsViewVueWidget/JsvFlexCell/JsvFlexDiv.vue +1 -1
- package/utils/JsViewVueWidget/JsvFlexCell/JsvFullScrAdjust.vue +151 -0
- package/utils/JsViewVueWidget/JsvFlexCell/JsvScreenFlex.vue +2 -2
- package/utils/JsViewVueWidget/JsvFlexCell/index.js +1 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +8 -0
- package/utils/JsViewVueWidget/JsvInput/EditViewOperator.ts +1 -1
- package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +0 -9
- package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +57 -71
- package/utils/JsViewVueWidget/JsvPosterDiv.vue +15 -8
- package/utils/JsViewVueWidget/JsvPosterImage.vue +11 -1
- package/utils/JsViewVueWidget/JsvQrcode/JsvQrcode.vue +1 -1
- package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +99 -61
- package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +48 -48
- package/utils/JsViewVueWidget/index.js +2 -0
- package/bin/browser/BrowserApic.vue.mjs +0 -114
- package/bin/browser/BrowserApic2.vue.mjs +0 -108
- package/bin/browser/BrowserApicLib.mjs +0 -431
- package/bin/types/utils/JsViewVueTools/JsvDemoTester.d.ts +0 -2
- package/utils/JsViewVueTools/JsvDemoTester.js +0 -81
|
@@ -1,431 +0,0 @@
|
|
|
1
|
-
import { a as LoopToolBase, L as LoopType, A as ApicEndState } from '../jsview-vue-common.mjs';
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
+ @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/PartLoopTool.js}
|
|
5
|
-
*/
|
|
6
|
-
class PartLoopTool extends LoopToolBase {
|
|
7
|
-
constructor(info_list) {
|
|
8
|
-
super();
|
|
9
|
-
this.mLoopPeriod = 0;
|
|
10
|
-
this.mCurLoopStartFrame = 0;
|
|
11
|
-
this.mCurLoopEndFrame = 0;
|
|
12
|
-
this.mCurLoopNum = 0;
|
|
13
|
-
this.mCurLoopCount = 0;
|
|
14
|
-
if (info_list == null) {
|
|
15
|
-
console.error("PartLoopTool info is null.");
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
this.mLoopInfo = info_list;
|
|
19
|
-
}
|
|
20
|
-
getNextIndex(curIndex) {
|
|
21
|
-
if (!this.mValid) {
|
|
22
|
-
return -1;
|
|
23
|
-
}
|
|
24
|
-
let next_index = -1;
|
|
25
|
-
let loop_period_num = this.mLoopInfo.length;
|
|
26
|
-
if (this.mLoopPeriod < loop_period_num) {
|
|
27
|
-
if (curIndex < this.mCurLoopEndFrame) {
|
|
28
|
-
next_index = curIndex + 1;
|
|
29
|
-
} else {
|
|
30
|
-
if (this.mCurLoopNum <= 0) {
|
|
31
|
-
next_index = this.mCurLoopStartFrame;
|
|
32
|
-
} else {
|
|
33
|
-
this.mCurLoopCount++;
|
|
34
|
-
if (this.mCurLoopCount >= this.mCurLoopNum) {
|
|
35
|
-
this.mLoopPeriod++;
|
|
36
|
-
if (this.mLoopPeriod < loop_period_num) {
|
|
37
|
-
this.mValid = this.updateLoop();
|
|
38
|
-
if (this.mValid) {
|
|
39
|
-
this.mCurLoopCount = 0;
|
|
40
|
-
next_index = this.mCurLoopStartFrame;
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
next_index = this.mCurLoopStartFrame;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
}
|
|
51
|
-
return next_index;
|
|
52
|
-
}
|
|
53
|
-
updateLoop() {
|
|
54
|
-
let loop = this.mLoopInfo[this.mLoopPeriod];
|
|
55
|
-
this.mCurLoopNum = loop[0];
|
|
56
|
-
this.mCurLoopStartFrame = loop[1];
|
|
57
|
-
this.mCurLoopEndFrame = loop[2];
|
|
58
|
-
if (isNaN(this.mCurLoopNum) || isNaN(this.mCurLoopStartFrame) || isNaN(this.mCurLoopEndFrame) || this.mCurLoopStartFrame >= this.mTotalFrameNum || this.mCurLoopEndFrame >= this.mTotalFrameNum || this.mCurLoopStartFrame >= this.mCurLoopEndFrame) {
|
|
59
|
-
console.error("data error, frame number out of size.", this.mLoopInfo);
|
|
60
|
-
return false;
|
|
61
|
-
} else {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
setApicInfo(frameNum, loopNum) {
|
|
66
|
-
this.mTotalFrameNum = frameNum;
|
|
67
|
-
this.mValid = this.updateLoop();
|
|
68
|
-
if (!this.mValid) {
|
|
69
|
-
console.log("PartLoopTool init loop info error." + this.mLoopInfo.toString());
|
|
70
|
-
} else {
|
|
71
|
-
this.mNextFrameIndex = this.mCurLoopStartFrame;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/*
|
|
77
|
-
+ @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/NormalLoopTool.js}
|
|
78
|
-
*/
|
|
79
|
-
class NormalLoopTool extends LoopToolBase {
|
|
80
|
-
constructor(loop_type, loop_num) {
|
|
81
|
-
super();
|
|
82
|
-
this.mLoopType = loop_type;
|
|
83
|
-
this.mLoopNum = loop_num;
|
|
84
|
-
this.mLoopCount = 0;
|
|
85
|
-
}
|
|
86
|
-
getNextIndex(curFrame) {
|
|
87
|
-
if (!this.mValid) {
|
|
88
|
-
return -1;
|
|
89
|
-
}
|
|
90
|
-
let next_index = -1;
|
|
91
|
-
switch (this.mLoopType) {
|
|
92
|
-
case LoopType.LOOP_DEFAULT:
|
|
93
|
-
if (this.mLoopNum <= 0) {
|
|
94
|
-
next_index = (curFrame + 1) % this.mTotalFrameNum;
|
|
95
|
-
} else {
|
|
96
|
-
if (curFrame == this.mTotalFrameNum - 1) {
|
|
97
|
-
this.mLoopCount++;
|
|
98
|
-
}
|
|
99
|
-
next_index = this.mLoopCount >= this.mLoopNum ? -1 : (curFrame + 1) % this.mTotalFrameNum;
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
case LoopType.LOOP_INFINITE:
|
|
103
|
-
next_index = (curFrame + 1) % this.mTotalFrameNum;
|
|
104
|
-
break;
|
|
105
|
-
case LoopType.LOOP_FINITE:
|
|
106
|
-
if (curFrame == this.mTotalFrameNum - 1) {
|
|
107
|
-
this.mLoopCount++;
|
|
108
|
-
}
|
|
109
|
-
next_index = this.mLoopCount >= this.mLoopNum ? -1 : (curFrame + 1) % this.mTotalFrameNum;
|
|
110
|
-
break;
|
|
111
|
-
default:
|
|
112
|
-
}
|
|
113
|
-
return next_index;
|
|
114
|
-
}
|
|
115
|
-
setApicInfo(frameNum, loopNum) {
|
|
116
|
-
this.mTotalFrameNum = frameNum;
|
|
117
|
-
this.mLoopNum = this.mLoopType == LoopType.LOOP_DEFAULT ? loopNum : this.mLoopNum;
|
|
118
|
-
this.mNextFrameIndex = 0;
|
|
119
|
-
this.mValid = true;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/*
|
|
124
|
-
+ @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/SingleLoopTool.js}
|
|
125
|
-
*/
|
|
126
|
-
class SingleLoopTool extends LoopToolBase {
|
|
127
|
-
constructor(index) {
|
|
128
|
-
super();
|
|
129
|
-
this.mTargetIndex = index;
|
|
130
|
-
}
|
|
131
|
-
getNextIndex(curIndex) {
|
|
132
|
-
return -1;
|
|
133
|
-
}
|
|
134
|
-
setApicInfo(frame_num, loop_num) {
|
|
135
|
-
this.mTotalFrameNum = frame_num;
|
|
136
|
-
this.mNextFrameIndex = this.mTargetIndex;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/*
|
|
141
|
-
+ @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/Viewer.js}
|
|
142
|
-
*/
|
|
143
|
-
class Viewer {
|
|
144
|
-
constructor(apic_data, canvas, listener) {
|
|
145
|
-
this._ApicData = apic_data;
|
|
146
|
-
this._Canvas = canvas;
|
|
147
|
-
this._Context = this._Canvas.getContext("2d");
|
|
148
|
-
this._Listener = listener;
|
|
149
|
-
this._TimeoutId = -1;
|
|
150
|
-
this._EndState = ApicEndState.LAST_FRAME;
|
|
151
|
-
this._CurrentIndex = -1;
|
|
152
|
-
}
|
|
153
|
-
_createLoopTool(loop_type, loop_info) {
|
|
154
|
-
let loop_num = null;
|
|
155
|
-
switch (loop_type) {
|
|
156
|
-
case LoopType.LOOP_DEFAULT:
|
|
157
|
-
case LoopType.LOOP_INFINITE:
|
|
158
|
-
case LoopType.LOOP_FINITE:
|
|
159
|
-
loop_num = loop_type == LoopType.LOOP_DEFAULT ? this._ApicData.LoopCount : loop_info[0][0];
|
|
160
|
-
this._LoopTool = new NormalLoopTool(
|
|
161
|
-
loop_type,
|
|
162
|
-
loop_num
|
|
163
|
-
);
|
|
164
|
-
break;
|
|
165
|
-
case LoopType.LOOP_PART:
|
|
166
|
-
this._LoopTool = new PartLoopTool(
|
|
167
|
-
loop_info,
|
|
168
|
-
this._ApicData.FrameCount
|
|
169
|
-
);
|
|
170
|
-
break;
|
|
171
|
-
case LoopType.LOOP_SINGLE:
|
|
172
|
-
this._LoopTool = new SingleLoopTool(loop_info[0][1]);
|
|
173
|
-
break;
|
|
174
|
-
default:
|
|
175
|
-
this._LoopTool = new NormalLoopTool(
|
|
176
|
-
LoopType.LOOP_DEFAULT,
|
|
177
|
-
-1
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
this._LoopTool.setApicInfo(this._ApicData.FrameCount, this._ApicData.LoopCount);
|
|
181
|
-
}
|
|
182
|
-
stop(frameCount = -1) {
|
|
183
|
-
clearTimeout(this._TimeoutId);
|
|
184
|
-
if (frameCount >= 0 && this._CurrentIndex !== frameCount) {
|
|
185
|
-
this._CurrentIndex = frameCount;
|
|
186
|
-
this.renderFrame(frameCount);
|
|
187
|
-
}
|
|
188
|
-
if (this._Listener?.onend) {
|
|
189
|
-
this._Listener.onend();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
play(loopType, loopInfo, endState = ApicEndState.LAST_FRAME) {
|
|
193
|
-
this._EndState = endState;
|
|
194
|
-
let lInfo;
|
|
195
|
-
if (loopInfo instanceof Array) {
|
|
196
|
-
lInfo = loopInfo;
|
|
197
|
-
} else if (!isNaN(loopInfo)) {
|
|
198
|
-
lInfo = [[loopInfo, 0, 0]];
|
|
199
|
-
} else {
|
|
200
|
-
lInfo = [[0, 0, 0]];
|
|
201
|
-
}
|
|
202
|
-
this._createLoopTool(loopType, lInfo);
|
|
203
|
-
clearTimeout(this._TimeoutId);
|
|
204
|
-
this.renderLoop();
|
|
205
|
-
if (this._Listener?.onstart) {
|
|
206
|
-
this._Listener.onstart();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
renderLoop() {
|
|
210
|
-
if (this._LoopTool.hasNext()) {
|
|
211
|
-
this._CurrentIndex = this._LoopTool.next();
|
|
212
|
-
let duration = this.renderFrame(this._CurrentIndex);
|
|
213
|
-
this._TimeoutId = setTimeout(() => {
|
|
214
|
-
this.renderLoop();
|
|
215
|
-
}, duration);
|
|
216
|
-
} else {
|
|
217
|
-
console.log("loop finished");
|
|
218
|
-
if (this._EndState == ApicEndState.HIDE) {
|
|
219
|
-
this._Context.clearRect(0, 0, this._Canvas.width, this._Canvas.height);
|
|
220
|
-
}
|
|
221
|
-
if (this._Listener?.onend) {
|
|
222
|
-
this._Listener.onend();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
renderFrame(frame_index) {
|
|
227
|
-
return this._ApicData.toImage(frame_index, this._Canvas, this._Context);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/*
|
|
232
|
-
+ @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/ApicDataBase.js}
|
|
233
|
-
*/
|
|
234
|
-
const renderDocument = window.JsvCode.Dom.RenderDocument ? window.JsvCode.Dom.RenderDocument : window.JsvCode.Dom.BrowserDocument;
|
|
235
|
-
class ApicDataBase {
|
|
236
|
-
constructor(arrayBuffer) {
|
|
237
|
-
this.LoopCount = 0;
|
|
238
|
-
this.FrameCount = 0;
|
|
239
|
-
this.Width = 0;
|
|
240
|
-
this.Height = 0;
|
|
241
|
-
this._Canvas = renderDocument.createElement("canvas");
|
|
242
|
-
this._Context = this._Canvas.getContext("2d");
|
|
243
|
-
this._DecodedData = null;
|
|
244
|
-
this.decode(arrayBuffer);
|
|
245
|
-
}
|
|
246
|
-
decode(arrayBuffer) {
|
|
247
|
-
console.log("decode need override ", arrayBuffer);
|
|
248
|
-
}
|
|
249
|
-
toImage(frameIndex, canvas, canvasCtx) {
|
|
250
|
-
console.log("toImage need override ", frameIndex, canvas, canvasCtx);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/*
|
|
255
|
-
+ @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/WebpData.js}
|
|
256
|
-
*/
|
|
257
|
-
class WebpData extends ApicDataBase {
|
|
258
|
-
decode(array_buffer) {
|
|
259
|
-
let webp_data = new Uint8Array(array_buffer);
|
|
260
|
-
let webp_decoder = new window.WebPDecoder();
|
|
261
|
-
let image_data = window.WebPRiffParser(webp_data, 0);
|
|
262
|
-
let blend = false;
|
|
263
|
-
let header = image_data["header"] ? image_data["header"] : null;
|
|
264
|
-
let frames = image_data["frames"] ? image_data["frames"] : null;
|
|
265
|
-
if (header) {
|
|
266
|
-
this.LoopCount = header["loop_count"];
|
|
267
|
-
header["loop_counter"] = header["loop_count"];
|
|
268
|
-
this._Canvas.height = header["canvas_height"];
|
|
269
|
-
this._Canvas.width = header["canvas_width"];
|
|
270
|
-
this.Width = header["canvas_width"];
|
|
271
|
-
this.Height = header["canvas_height"];
|
|
272
|
-
for (let f = 0; f < frames.length; f++) {
|
|
273
|
-
if (frames[f]["blend"] === 0) {
|
|
274
|
-
blend = true;
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
this.FrameCount = frames.length;
|
|
280
|
-
for (let f = 0; f < frames.length; f++) {
|
|
281
|
-
let height = [0];
|
|
282
|
-
let width = [0];
|
|
283
|
-
let frame = frames[f];
|
|
284
|
-
let rgba = webp_decoder.WebPDecodeRGBA(
|
|
285
|
-
webp_data,
|
|
286
|
-
frame["src_off"],
|
|
287
|
-
frame["src_size"],
|
|
288
|
-
width,
|
|
289
|
-
height
|
|
290
|
-
);
|
|
291
|
-
frame["rgba"] = rgba;
|
|
292
|
-
frame["imgwidth"] = width[0];
|
|
293
|
-
frame["imgheight"] = height[0];
|
|
294
|
-
let oldimagedata = [];
|
|
295
|
-
if (!header) {
|
|
296
|
-
this._Canvas.height = height[0];
|
|
297
|
-
this._Canvas.width = width[0];
|
|
298
|
-
} else {
|
|
299
|
-
if (blend) {
|
|
300
|
-
let oldimagedata_ = this._Context.getImageData(
|
|
301
|
-
frame["offset_x"],
|
|
302
|
-
frame["offset_y"],
|
|
303
|
-
width[0],
|
|
304
|
-
height[0]
|
|
305
|
-
);
|
|
306
|
-
for (let i = 0; i < width[0] * height[0] * 4; i++) {
|
|
307
|
-
oldimagedata[i] = oldimagedata_.data[i];
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
let imagedata = this._Context.createImageData(width[0], height[0]);
|
|
312
|
-
if (frames.length === 1 && typeof frame["blend"] === "undefined" || frame["blend"] === 1) {
|
|
313
|
-
for (let i = 0; i < width[0] * height[0] * 4; i++)
|
|
314
|
-
imagedata.data[i] = rgba[i];
|
|
315
|
-
} else {
|
|
316
|
-
for (let i = 0; i < width[0] * height[0] * 4; i += 4) {
|
|
317
|
-
if (rgba[i + 3] > 0) {
|
|
318
|
-
imagedata.data[i + 3] = rgba[i + 3];
|
|
319
|
-
imagedata.data[i] = rgba[i];
|
|
320
|
-
imagedata.data[i + 1] = rgba[i + 1];
|
|
321
|
-
imagedata.data[i + 2] = rgba[i + 2];
|
|
322
|
-
} else {
|
|
323
|
-
imagedata.data[i + 3] = oldimagedata[i + 3];
|
|
324
|
-
imagedata.data[i] = oldimagedata[i];
|
|
325
|
-
imagedata.data[i + 1] = oldimagedata[i + 1];
|
|
326
|
-
imagedata.data[i + 2] = oldimagedata[i + 2];
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (frames.length === 1) {
|
|
331
|
-
this._Context.putImageData(imagedata, 0, 0);
|
|
332
|
-
} else {
|
|
333
|
-
this._Context.putImageData(
|
|
334
|
-
imagedata,
|
|
335
|
-
frame["offset_x"],
|
|
336
|
-
frame["offset_y"]
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
frame["frameData"] = frame["rgba"] ? header ? this._Context.getImageData(
|
|
340
|
-
0,
|
|
341
|
-
0,
|
|
342
|
-
header["canvas_width"],
|
|
343
|
-
header["canvas_height"]
|
|
344
|
-
).data : rgba : null;
|
|
345
|
-
if (frame["dispose"] === 1) {
|
|
346
|
-
this._Context.clearRect(
|
|
347
|
-
frame["offset_x"],
|
|
348
|
-
frame["offset_y"],
|
|
349
|
-
width[0],
|
|
350
|
-
height[0]
|
|
351
|
-
);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
this._DecodedData = image_data;
|
|
355
|
-
}
|
|
356
|
-
toImage(frame_index, canvas, canvas_ctx) {
|
|
357
|
-
let frame = this._DecodedData["frames"][frame_index];
|
|
358
|
-
let width = this._DecodedData["header"] ? this._DecodedData["header"]["canvas_width"] : frame["imgwidth"];
|
|
359
|
-
let height = this._DecodedData["header"] ? this._DecodedData["header"]["canvas_height"] : frame["imgheight"];
|
|
360
|
-
canvas.width = width;
|
|
361
|
-
canvas.height = height;
|
|
362
|
-
let image_data = canvas_ctx.createImageData(width, height);
|
|
363
|
-
let frame_data = frame["frameData"];
|
|
364
|
-
image_data.data.set(frame_data);
|
|
365
|
-
canvas_ctx.putImageData(image_data, 0, 0);
|
|
366
|
-
return frame["duration"];
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/*
|
|
371
|
-
+ @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/GifData.js}
|
|
372
|
-
*/
|
|
373
|
-
class GifData extends ApicDataBase {
|
|
374
|
-
decode(array_buffer) {
|
|
375
|
-
const gif = window.ApicTools.parseGIF(array_buffer);
|
|
376
|
-
this._DecodedData = window.ApicTools.decompressFrames(gif, true);
|
|
377
|
-
this.LoopCount = 0;
|
|
378
|
-
this.FrameCount = this._DecodedData.length;
|
|
379
|
-
this.Width = this._DecodedData[0].dims.width;
|
|
380
|
-
this.Height = this._DecodedData[0].dims.height;
|
|
381
|
-
for (let i = 0; i < this._DecodedData.length; i++) {
|
|
382
|
-
let frame = this._DecodedData[i];
|
|
383
|
-
if (frame["dims"]["width"] !== this.Width || frame["dims"]["height"] !== this.Height) {
|
|
384
|
-
let pre_frame_data = this._DecodedData[i - 1]["frameData"];
|
|
385
|
-
let left = frame["dims"]["left"];
|
|
386
|
-
let top = frame["dims"]["top"];
|
|
387
|
-
let width = frame["dims"]["width"];
|
|
388
|
-
let height = frame["dims"]["height"];
|
|
389
|
-
let patch_data = frame["patch"];
|
|
390
|
-
let image_data = new Uint8ClampedArray(this.Width * this.Height * 4);
|
|
391
|
-
for (let x = 0; x < this.Width; x++) {
|
|
392
|
-
for (let y = 0; y < this.Height; y++) {
|
|
393
|
-
let patch_x = x - left;
|
|
394
|
-
let patch_y = y - top;
|
|
395
|
-
let pixel_index = y * this.Width + x;
|
|
396
|
-
let patch_pixel_index = patch_y * width + patch_x;
|
|
397
|
-
if (x >= left && x < left + width && y >= top && y < top + height && patch_data[patch_pixel_index * 4 + 3] > 0) {
|
|
398
|
-
image_data[pixel_index * 4] = patch_data[patch_pixel_index * 4];
|
|
399
|
-
image_data[pixel_index * 4 + 1] = patch_data[patch_pixel_index * 4 + 1];
|
|
400
|
-
image_data[pixel_index * 4 + 2] = patch_data[patch_pixel_index * 4 + 2];
|
|
401
|
-
image_data[pixel_index * 4 + 3] = patch_data[patch_pixel_index * 4 + 3];
|
|
402
|
-
} else {
|
|
403
|
-
image_data[pixel_index * 4] = pre_frame_data[pixel_index * 4];
|
|
404
|
-
image_data[pixel_index * 4 + 1] = pre_frame_data[pixel_index * 4 + 1];
|
|
405
|
-
image_data[pixel_index * 4 + 2] = pre_frame_data[pixel_index * 4 + 2];
|
|
406
|
-
image_data[pixel_index * 4 + 3] = pre_frame_data[pixel_index * 4 + 3];
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
frame["frameData"] = image_data;
|
|
411
|
-
} else {
|
|
412
|
-
frame["frameData"] = frame["patch"];
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
toImage(frame_index, canvas, canvas_ctx) {
|
|
417
|
-
canvas.width = this.Width;
|
|
418
|
-
canvas.height = this.Height;
|
|
419
|
-
let frame = this._DecodedData[frame_index];
|
|
420
|
-
let image_data = canvas_ctx.createImageData(this.Width, this.Height);
|
|
421
|
-
image_data.data.set(frame["frameData"]);
|
|
422
|
-
canvas_ctx.putImageData(image_data, 0, 0);
|
|
423
|
-
return frame["delay"];
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/*
|
|
428
|
-
+ @file {@link file://./../../../../../utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/BrowserApicLib.js}
|
|
429
|
-
*/
|
|
430
|
-
|
|
431
|
-
export { GifData as G, Viewer as V, WebpData as W };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
let interfaceLoaded = false;
|
|
2
|
-
let idGeneratoer = 1;
|
|
3
|
-
let idObjectMap = {};
|
|
4
|
-
|
|
5
|
-
const ensureInterface = ()=>{
|
|
6
|
-
return new Promise((resolve, reject)=>{
|
|
7
|
-
if (interfaceLoaded) {
|
|
8
|
-
// 已经加载完成
|
|
9
|
-
resolve();
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (window.JsView) {
|
|
14
|
-
let cb = ()=>{
|
|
15
|
-
// dynamic加载完成
|
|
16
|
-
if (window.jJsvDemoTester) {
|
|
17
|
-
console.log("window.jJsvDemoTester ready")
|
|
18
|
-
} else {
|
|
19
|
-
console.log("window.jJsvDemoTester failed")
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
console.log("remove cb=" + cb);
|
|
23
|
-
|
|
24
|
-
// 移除回调
|
|
25
|
-
window.JsView.removeEventListener(cb);
|
|
26
|
-
|
|
27
|
-
// 无论成功失败,暂且都论为加载完成
|
|
28
|
-
interfaceLoaded = true;
|
|
29
|
-
resolve();
|
|
30
|
-
};
|
|
31
|
-
window.JsView.addEventListener("__DemoTesterReady", cb);
|
|
32
|
-
window.JsView.ensureTesterUtils();
|
|
33
|
-
} else {
|
|
34
|
-
interfaceLoaded = true;
|
|
35
|
-
resolve(); // 非JsView场景,默认为完成状态
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const enableNativeViewListener = (nativeViewId,info)=>{
|
|
41
|
-
let listenerId = idGeneratoer;
|
|
42
|
-
idGeneratoer++;
|
|
43
|
-
idObjectMap[listenerId] = {
|
|
44
|
-
eventCallback: (ret)=>{
|
|
45
|
-
info.value=ret.info
|
|
46
|
-
console.log(`JsvDemoTester nativeView info=${info.value}`);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
(async ()=>{
|
|
51
|
-
await ensureInterface();
|
|
52
|
-
|
|
53
|
-
if (idObjectMap.hasOwnProperty(listenerId)) {
|
|
54
|
-
let eventName = "__enableNativeViewListener_" + listenerId;
|
|
55
|
-
|
|
56
|
-
window.JsView?.addEventListener(eventName, idObjectMap[listenerId].eventCallback);
|
|
57
|
-
window.jJsvDemoTester?.enableNativeViewListener(nativeViewId, listenerId, eventName);
|
|
58
|
-
}
|
|
59
|
-
})();
|
|
60
|
-
|
|
61
|
-
return listenerId; // 用于 disableNativeViewListener() 调用
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const disableNativeViewListener = (listenerId)=>{
|
|
65
|
-
(async ()=>{
|
|
66
|
-
await ensureInterface();
|
|
67
|
-
|
|
68
|
-
if (idObjectMap.hasOwnProperty(listenerId)) {
|
|
69
|
-
window.JsView?.removeEventListener(idObjectMap[listenerId].eventCallback);
|
|
70
|
-
window.jJsvDemoTester?.disableNativeViewListener(listenerId);
|
|
71
|
-
delete idObjectMap[listenerId];
|
|
72
|
-
} else {
|
|
73
|
-
console.warn("disableNativeViewListener id gone");
|
|
74
|
-
}
|
|
75
|
-
})();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export {
|
|
79
|
-
enableNativeViewListener,
|
|
80
|
-
disableNativeViewListener,
|
|
81
|
-
}
|