@shijiu/jsview-vue 2.1.200 → 2.1.339-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.
- package/bin/browser/BrowserApic.vue.mjs +124 -0
- package/bin/browser/BrowserApic2.vue.mjs +118 -0
- package/bin/browser/BrowserApicLib.mjs +424 -0
- package/bin/browser/BrowserAudio.vue.mjs +263 -0
- package/bin/browser/BrowserJsvLatex.vue.mjs +110 -0
- package/bin/browser/BrowserJsvPlayer.vue.mjs +573 -0
- package/bin/browser/BrowserPreload.vue.mjs +154 -0
- package/bin/browser/BrowserQrcode.vue.mjs +178 -0
- package/bin/browser/BrowserSpray.vue.mjs +66 -0
- package/bin/browser/BrowserTextureAnim.vue.mjs +324 -0
- package/bin/export-sfc.mjs +12 -0
- package/bin/jsview-common.mjs +39 -0
- package/bin/jsview-vue.mjs +21106 -0
- package/index.js +3 -4
- package/package.json +1 -2
- package/tools/config/rollup.config.mjs +52 -0
- package/tools/config/tsconfig.json +18 -0
- package/tools/config/vite.config.ts +60 -0
- package/tools/jsview-vue-build.mjs +125 -0
- package/utils/JsViewEngineWidget/{JsvFocusBlock.vue → JsvFocus/JsvFocusBlock.vue} +11 -11
- package/utils/JsViewEngineWidget/{JsvFocusHub.ts → JsvFocus/JsvFocusHub.ts} +9 -3
- package/utils/JsViewEngineWidget/{JsvFocusManager.js → JsvFocus/JsvFocusManager.js} +6 -5
- package/utils/JsViewEngineWidget/MetroWidget/AnimationManager.ts +33 -10
- package/utils/JsViewEngineWidget/MetroWidget/ListWidget.vue +89 -57
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +118 -62
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidgetSetup.js +504 -60
- package/utils/JsViewEngineWidget/MetroWidget/RenderItem.ts +11 -1
- package/utils/JsViewEngineWidget/MetroWidget/SlotComponent.vue +13 -0
- package/utils/JsViewEngineWidget/TemplateParser/CommonMetroTemplate.ts +1 -1
- package/utils/JsViewEngineWidget/TemplateParser/ListMetroTemplate.ts +1 -1
- package/utils/JsViewEngineWidget/TemplateParser/MetroTemplate.ts +34 -1
- package/utils/JsViewEngineWidget/TemplateParser/TemplateItemAdder.ts +52 -11
- package/utils/JsViewEngineWidget/index.js +3 -3
- package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +9 -0
- package/utils/JsViewPlugin/JsvAudio/BrowserAudio/BrowserAudio.vue +11 -3
- package/utils/JsViewPlugin/JsvAudio/JsvAudio.vue +1 -0
- package/utils/JsViewPlugin/JsvAudio/JsvAudioBridgeProxy.js +8 -0
- package/utils/JsViewPlugin/JsvAudio/ScreenLockManager.js +16 -0
- package/utils/JsViewPlugin/JsvAudio/version.js +3 -3
- package/utils/JsViewPlugin/JsvAudio/version.mjs +3 -3
- package/utils/JsViewPlugin/JsvLatex/index.js +1 -1
- package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +1 -1
- package/utils/JsViewPlugin/JsvPlayer/index-0.9.js +3 -3
- package/utils/JsViewPlugin/JsvPlayer/index.js +2 -2
- package/utils/JsViewVueTools/DebugTool.js +2 -2
- package/utils/JsViewVueTools/DefaultKeyMap.js +1 -1
- package/utils/JsViewVueTools/JsvDynamicCssStyle.js +1 -1
- package/utils/JsViewVueTools/JsvDynamicKeyFrames.js +2 -2
- package/utils/JsViewVueTools/JsvImpactTracer.js +7 -7
- package/utils/JsViewVueTools/JsvPreDownloader.ts +1 -1
- package/utils/JsViewVueTools/JsvRefTaker.js +2 -1
- package/utils/JsViewVueTools/JsvRuntimeBridge.js +29 -29
- package/utils/JsViewVueTools/JsvStyleClass.js +3 -3
- package/utils/JsViewVueTools/JsvStyleSheetsDeclarer.js +1 -1
- package/utils/JsViewVueTools/JsvTextTools.js +4 -4
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CanvasTexture.ts +29 -1
- package/utils/JsViewVueTools/JsvTextureStore/CanvasTexture/CommandList.ts +6 -5
- package/utils/JsViewVueTools/JsvTextureStore/JsvTextureStore.ts +60 -2
- package/utils/JsViewVueTools/NinePatchHelper.js +1 -1
- package/utils/JsViewVueWidget/JsvActorMove/ActorControlBase.js +1 -1
- package/utils/JsViewVueWidget/JsvActorMove/JsvActorMoveControl.js +1 -1
- package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvApic}/BrowserApic.vue +20 -23
- package/utils/JsViewVueWidget/JsvApic/{JsvApic.vue → JsvApic/JsvApic.vue} +3 -14
- package/utils/JsViewVueWidget/JsvApic/{index.js → JsvApic/index.js} +2 -4
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/BrowserApic2.vue +116 -0
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/JsvApic2.vue +137 -0
- package/utils/JsViewVueWidget/JsvApic/JsvApic2/index.js +17 -0
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/BrowserApicLib.js +4 -0
- package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvBrowserApicLib}/NormalLoopTool.js +16 -18
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/PartLoopTool.js +90 -0
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/SingleLoopTool.js +17 -0
- package/utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/Viewer.js +111 -0
- package/utils/JsViewVueWidget/JsvApic/JsvCommonLoopToolBase.js +48 -0
- package/utils/JsViewVueWidget/JsvConnectLine/ArcLineManager.js +71 -0
- package/utils/JsViewVueWidget/JsvConnectLine/JsvConnectLine.vue +354 -0
- package/utils/JsViewVueWidget/JsvConnectLine/index.js +2 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ActorControl.ts +37 -18
- package/utils/JsViewVueWidget/JsvFreeMoveActor/ForgeTypeDefine.ts +7 -3
- package/utils/JsViewVueWidget/JsvFreeMoveActor/FreeMoveActor.vue +28 -2
- package/utils/JsViewVueWidget/JsvFreeMoveActor/JsvEnvBlocker.vue +12 -5
- package/utils/JsViewVueWidget/JsvFreeMoveActor/NexusNode.ts +21 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetAction.ts +47 -59
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetCondition.ts +129 -12
- package/utils/JsViewVueWidget/JsvFreeMoveActor/SetState.ts +45 -0
- package/utils/JsViewVueWidget/JsvFreeMoveActor/index.js +10 -2
- package/utils/JsViewVueWidget/JsvGrid.vue +1 -1
- package/utils/JsViewVueWidget/JsvHole.js +1 -1
- package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +1 -1
- package/utils/JsViewVueWidget/JsvLine/JsvLine.vue +2 -2
- package/utils/JsViewVueWidget/JsvLine/LineManager.js +6 -4
- package/utils/JsViewVueWidget/JsvMarquee.vue +7 -4
- package/utils/JsViewVueWidget/JsvPieChart.vue +1 -1
- package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +1 -1
- package/utils/JsViewVueWidget/JsvPreload/index.js +1 -1
- package/utils/JsViewVueWidget/JsvProgressBar.vue +172 -0
- package/utils/JsViewVueWidget/JsvQrcode/JsvQrcode.vue +0 -1
- package/utils/JsViewVueWidget/JsvQrcode/index.js +1 -1
- package/utils/JsViewVueWidget/JsvRadarChart.vue +1 -1
- package/utils/JsViewVueWidget/JsvScaleTextBox.vue +0 -2
- package/utils/JsViewVueWidget/JsvSector.vue +1 -1
- package/utils/JsViewVueWidget/JsvSoundPool.js +1 -1
- package/utils/JsViewVueWidget/JsvSpray/index.js +1 -1
- package/utils/JsViewVueWidget/JsvSpriteAnim/FrameBuidler.ts +235 -0
- package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +433 -401
- package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteLoader.vue +120 -0
- package/utils/JsViewVueWidget/JsvSpriteAnim/index.js +2 -2
- package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +5 -5
- package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +425 -422
- package/utils/JsViewVueWidget/JsvVisibleSensor/index.js +1 -1
- package/utils/JsViewVueWidget/index.js +7 -3
- package/utils/index.js +4 -0
- package/utils/JsViewVueWidget/JsvApic/BrowserApic/LoopToolBase.js +0 -25
- package/utils/JsViewVueWidget/JsvApic/BrowserApic/PartLoopTool.js +0 -119
- package/utils/JsViewVueWidget/JsvApic/BrowserApic/Viewer.js +0 -106
- /package/utils/JsViewPlugin/JsvLatex/{JsvLatexBrowser.vue → BrowserJsvLatex.vue} +0 -0
- /package/utils/JsViewPlugin/JsvPlayer/{JsvPlayerBrowser-0.9.vue → BrowserJsvPlayer-0.9.vue} +0 -0
- /package/utils/JsViewPlugin/JsvPlayer/{JsvPlayerBrowser.vue → BrowserJsvPlayer.vue} +0 -0
- /package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvBrowserApicLib}/ApicDataBase.js +0 -0
- /package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvBrowserApicLib}/GifData.js +0 -0
- /package/utils/JsViewVueWidget/JsvApic/{BrowserApic → JsvBrowserApicLib}/WebpData.js +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { shallowRef, onMounted, openBlock, normalizeStyle, createElementBlock } from 'vue';
|
|
2
|
+
import { W as WebpData, G as GifData, V as Viewer } from './BrowserApicLib.mjs';
|
|
3
|
+
import { L as LoopType } from '../jsview-common.mjs';
|
|
4
|
+
|
|
5
|
+
//!
|
|
6
|
+
//! utils/JsViewVueWidget/JsvApic/JsvApic/BrowserApic.vue;
|
|
7
|
+
//!
|
|
8
|
+
/*! <!--
|
|
9
|
+
* @Author: ChenChanghua
|
|
10
|
+
* @Date: 2021-10-13 13:14:49
|
|
11
|
+
* @LastEditors: ChenChanghua
|
|
12
|
+
* @LastEditTime: 2021-10-13 17:13:24
|
|
13
|
+
* @Description: file content
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
const _sfc_main = {
|
|
20
|
+
__name: "BrowserApic",
|
|
21
|
+
props: {
|
|
22
|
+
src: String,
|
|
23
|
+
style: Object,
|
|
24
|
+
autoPlay: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
loopType: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: LoopType.LOOP_DEFAULT
|
|
31
|
+
},
|
|
32
|
+
loopInfo: {
|
|
33
|
+
type: Array,
|
|
34
|
+
default: () => [[-1, -1, -1]]
|
|
35
|
+
},
|
|
36
|
+
onStart: Function,
|
|
37
|
+
onEnd: Function,
|
|
38
|
+
onLoad: Function
|
|
39
|
+
},
|
|
40
|
+
setup(__props, { expose }) {
|
|
41
|
+
const props = __props;
|
|
42
|
+
const loadImage = (url) => {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
let xhr = new XMLHttpRequest();
|
|
45
|
+
xhr.open("GET", url);
|
|
46
|
+
xhr.responseType = "arraybuffer";
|
|
47
|
+
xhr.onreadystatechange = () => {
|
|
48
|
+
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
49
|
+
if (xhr.status == 200) {
|
|
50
|
+
let apic_data;
|
|
51
|
+
if (url.indexOf(".webp") > 0) {
|
|
52
|
+
apic_data = new WebpData(xhr.response);
|
|
53
|
+
resolve(apic_data);
|
|
54
|
+
} else if (url.indexOf(".gif") > 0) {
|
|
55
|
+
apic_data = new GifData(xhr.response);
|
|
56
|
+
resolve(apic_data);
|
|
57
|
+
} else {
|
|
58
|
+
reject("unsupport file " + url);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
reject("get image data failed. " + url + " " + xhr.status);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
xhr.send();
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const getUrl = (base_url) => {
|
|
69
|
+
let url_trim = base_url.trim();
|
|
70
|
+
if (url_trim.indexOf("http") === 0) {
|
|
71
|
+
return url_trim;
|
|
72
|
+
} else if (url_trim.indexOf("url") === 0) {
|
|
73
|
+
let index_1 = url_trim.indexOf("(");
|
|
74
|
+
let index_2 = url_trim.indexOf(")");
|
|
75
|
+
return url_trim.substring(index_1 + 1, index_2);
|
|
76
|
+
} else {
|
|
77
|
+
return url_trim;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
let viewer = null;
|
|
81
|
+
let canvasProxyRef = shallowRef(null);
|
|
82
|
+
const play = () => {
|
|
83
|
+
viewer?.play(props.loopType, props.loopInfo);
|
|
84
|
+
};
|
|
85
|
+
const stop = () => {
|
|
86
|
+
viewer?.stop();
|
|
87
|
+
};
|
|
88
|
+
onMounted(() => {
|
|
89
|
+
let domLayoutView = canvasProxyRef.value.jsvGetProxyView();
|
|
90
|
+
domLayoutView.RegisterOnProxyReady(() => {
|
|
91
|
+
let canvas = window.originDocument.createElement("canvas");
|
|
92
|
+
canvas.style.width = props.style.width + "px";
|
|
93
|
+
canvas.style.height = props.style.height + "px";
|
|
94
|
+
domLayoutView.HtmlGetElement().appendChild(canvas);
|
|
95
|
+
loadImage(getUrl(props.src)).then((data) => {
|
|
96
|
+
let listener = {
|
|
97
|
+
onstart: props.onStart,
|
|
98
|
+
onend: props.onEnd
|
|
99
|
+
};
|
|
100
|
+
viewer = new Viewer(data, canvas, listener);
|
|
101
|
+
if (props.onLoad) {
|
|
102
|
+
props.onLoad();
|
|
103
|
+
}
|
|
104
|
+
if (props.autoPlay) {
|
|
105
|
+
play();
|
|
106
|
+
}
|
|
107
|
+
}).catch((err) => console.error(err));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
expose({
|
|
111
|
+
play,
|
|
112
|
+
stop
|
|
113
|
+
});
|
|
114
|
+
return (_ctx, _cache) => {
|
|
115
|
+
return openBlock(), createElementBlock("div", {
|
|
116
|
+
ref_key: "canvasProxyRef",
|
|
117
|
+
ref: canvasProxyRef,
|
|
118
|
+
style: normalizeStyle(props.style)
|
|
119
|
+
}, null, 4);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { shallowRef, onMounted, openBlock, normalizeStyle, createElementBlock } from 'vue';
|
|
2
|
+
import { W as WebpData, G as GifData, V as Viewer } from './BrowserApicLib.mjs';
|
|
3
|
+
import { L as LoopType } from '../jsview-common.mjs';
|
|
4
|
+
|
|
5
|
+
//!
|
|
6
|
+
//! utils/JsViewVueWidget/JsvApic/JsvApic2/BrowserApic2.vue;
|
|
7
|
+
//!
|
|
8
|
+
/*! <!--
|
|
9
|
+
* @Author: ChenChanghua
|
|
10
|
+
* @Date: 2021-10-13 13:14:49
|
|
11
|
+
* @LastEditors: ChenChanghua
|
|
12
|
+
* @LastEditTime: 2021-10-13 17:13:24
|
|
13
|
+
* @Description: file content
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
const _sfc_main = {
|
|
20
|
+
__name: "BrowserApic2",
|
|
21
|
+
props: {
|
|
22
|
+
src: String,
|
|
23
|
+
style: Object,
|
|
24
|
+
onStart: Function,
|
|
25
|
+
onEnd: Function,
|
|
26
|
+
onLoad: Function
|
|
27
|
+
},
|
|
28
|
+
setup(__props, { expose }) {
|
|
29
|
+
const props = __props;
|
|
30
|
+
let waitForPlayInfo = null;
|
|
31
|
+
const loadImage = (url) => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
let xhr = new XMLHttpRequest();
|
|
34
|
+
xhr.open("GET", url);
|
|
35
|
+
xhr.responseType = "arraybuffer";
|
|
36
|
+
xhr.onreadystatechange = () => {
|
|
37
|
+
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
38
|
+
if (xhr.status == 200) {
|
|
39
|
+
let apic_data;
|
|
40
|
+
if (url.indexOf(".webp") > 0) {
|
|
41
|
+
apic_data = new WebpData(xhr.response);
|
|
42
|
+
resolve(apic_data);
|
|
43
|
+
} else if (url.indexOf(".gif") > 0) {
|
|
44
|
+
apic_data = new GifData(xhr.response);
|
|
45
|
+
resolve(apic_data);
|
|
46
|
+
} else {
|
|
47
|
+
reject("unsupport file " + url);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
reject("get image data failed. " + url + " " + xhr.status);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
xhr.send();
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const getUrl = (base_url) => {
|
|
58
|
+
let url_trim = base_url.trim();
|
|
59
|
+
if (url_trim.indexOf("http") === 0) {
|
|
60
|
+
return url_trim;
|
|
61
|
+
} else if (url_trim.indexOf("url") === 0) {
|
|
62
|
+
let index_1 = url_trim.indexOf("(");
|
|
63
|
+
let index_2 = url_trim.indexOf(")");
|
|
64
|
+
return url_trim.substring(index_1 + 1, index_2);
|
|
65
|
+
} else {
|
|
66
|
+
return url_trim;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
let viewer = null;
|
|
70
|
+
let canvasProxyRef = shallowRef(null);
|
|
71
|
+
onMounted(() => {
|
|
72
|
+
let domLayoutView = canvasProxyRef.value.jsvGetProxyView();
|
|
73
|
+
domLayoutView.RegisterOnProxyReady(() => {
|
|
74
|
+
let canvas = window.originDocument.createElement("canvas");
|
|
75
|
+
canvas.style.width = props.style.width + "px";
|
|
76
|
+
canvas.style.height = props.style.height + "px";
|
|
77
|
+
domLayoutView.HtmlGetElement().appendChild(canvas);
|
|
78
|
+
loadImage(getUrl(props.src)).then((data) => {
|
|
79
|
+
let listener = {
|
|
80
|
+
onstart: props.onStart,
|
|
81
|
+
onend: props.onEnd
|
|
82
|
+
};
|
|
83
|
+
viewer = new Viewer(data, canvas, listener);
|
|
84
|
+
if (props.onLoad) {
|
|
85
|
+
props.onLoad();
|
|
86
|
+
}
|
|
87
|
+
if (waitForPlayInfo) {
|
|
88
|
+
viewer.play(...waitForPlayInfo);
|
|
89
|
+
waitForPlayInfo = null;
|
|
90
|
+
}
|
|
91
|
+
}).catch((err) => console.error(err));
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
expose({
|
|
95
|
+
show: (frameIndex = 0) => {
|
|
96
|
+
if (!isNaN(frameIndex)) {
|
|
97
|
+
viewer?.play(LoopType.LOOP_SINGLE, [[0, frameIndex, 0]]);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
play: (...args) => {
|
|
101
|
+
waitForPlayInfo = args;
|
|
102
|
+
viewer?.play(...args);
|
|
103
|
+
},
|
|
104
|
+
stop: () => {
|
|
105
|
+
viewer?.stop();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return (_ctx, _cache) => {
|
|
109
|
+
return openBlock(), createElementBlock("div", {
|
|
110
|
+
ref_key: "canvasProxyRef",
|
|
111
|
+
ref: canvasProxyRef,
|
|
112
|
+
style: normalizeStyle(props.style)
|
|
113
|
+
}, null, 4);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { a as LoopToolBase, L as LoopType, A as ApicEndState } from '../jsview-common.mjs';
|
|
2
|
+
|
|
3
|
+
//!
|
|
4
|
+
//! 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
|
+
Log.e(TAG, "PartLoopTool init loop info error." + this.mLoopInfo.toString());
|
|
70
|
+
} else {
|
|
71
|
+
this.mNextFrameIndex = this.mCurLoopStartFrame;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//!
|
|
77
|
+
//! 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
|
+
//! 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
|
+
//! 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
|
+
}
|
|
152
|
+
_createLoopTool(loop_type, loop_info) {
|
|
153
|
+
let loop_num = null;
|
|
154
|
+
switch (loop_type) {
|
|
155
|
+
case LoopType.LOOP_DEFAULT:
|
|
156
|
+
case LoopType.LOOP_INFINITE:
|
|
157
|
+
case LoopType.LOOP_FINITE:
|
|
158
|
+
loop_num = loop_type == LoopType.LOOP_DEFAULT ? this._ApicData.LoopCount : loop_info[0][0];
|
|
159
|
+
this._LoopTool = new NormalLoopTool(
|
|
160
|
+
loop_type,
|
|
161
|
+
loop_num
|
|
162
|
+
);
|
|
163
|
+
break;
|
|
164
|
+
case LoopType.LOOP_PART:
|
|
165
|
+
this._LoopTool = new PartLoopTool(
|
|
166
|
+
loop_info,
|
|
167
|
+
this._ApicData.FrameCount
|
|
168
|
+
);
|
|
169
|
+
break;
|
|
170
|
+
case LoopType.LOOP_SINGLE:
|
|
171
|
+
this._LoopTool = new SingleLoopTool(loop_info[0][1]);
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
this._LoopTool = new NormalLoopTool(
|
|
175
|
+
LoopType.LOOP_DEFAULT,
|
|
176
|
+
-1
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
this._LoopTool.setApicInfo(this._ApicData.FrameCount, this._ApicData.LoopCount);
|
|
180
|
+
}
|
|
181
|
+
stop() {
|
|
182
|
+
clearTimeout(this._TimeoutId);
|
|
183
|
+
if (this._Listener?.onend) {
|
|
184
|
+
this._Listener.onend();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
play(loopType, loopInfo, endState = ApicEndState.LAST_FRAME) {
|
|
188
|
+
this._EndState = endState;
|
|
189
|
+
let lInfo;
|
|
190
|
+
if (loopInfo instanceof Array) {
|
|
191
|
+
lInfo = loopInfo;
|
|
192
|
+
} else if (!isNaN(loopInfo)) {
|
|
193
|
+
lInfo = [[loopInfo, 0, 0]];
|
|
194
|
+
} else {
|
|
195
|
+
lInfo = [[0, 0, 0]];
|
|
196
|
+
}
|
|
197
|
+
this._createLoopTool(loopType, lInfo);
|
|
198
|
+
clearTimeout(this._TimeoutId);
|
|
199
|
+
this.renderLoop();
|
|
200
|
+
if (this._Listener?.onstart) {
|
|
201
|
+
this._Listener.onstart();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
renderLoop() {
|
|
205
|
+
if (this._LoopTool.hasNext()) {
|
|
206
|
+
let duration = this.renderFrame(this._LoopTool.next());
|
|
207
|
+
this._TimeoutId = setTimeout(() => {
|
|
208
|
+
this.renderLoop();
|
|
209
|
+
}, duration);
|
|
210
|
+
} else {
|
|
211
|
+
console.log("loop finished");
|
|
212
|
+
if (this._EndState == ApicEndState.HIDE) {
|
|
213
|
+
this._Context.clearRect(0, 0, this._Canvas.width, this._Canvas.height);
|
|
214
|
+
}
|
|
215
|
+
if (this._Listener?.onend) {
|
|
216
|
+
this._Listener.onend();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
renderFrame(frame_index) {
|
|
221
|
+
return this._ApicData.toImage(frame_index, this._Canvas, this._Context);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
//!
|
|
226
|
+
//! utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/ApicDataBase.js;
|
|
227
|
+
//!
|
|
228
|
+
class ApicDataBase {
|
|
229
|
+
constructor(arrayBuffer) {
|
|
230
|
+
this.LoopCount = 0;
|
|
231
|
+
this.FrameCount = 0;
|
|
232
|
+
this.Width = 0;
|
|
233
|
+
this.Height = 0;
|
|
234
|
+
this._Canvas = window.originDocument.createElement("canvas");
|
|
235
|
+
this._Context = this._Canvas.getContext("2d");
|
|
236
|
+
this._DecodedData = null;
|
|
237
|
+
this.decode(arrayBuffer);
|
|
238
|
+
}
|
|
239
|
+
decode(arrayBuffer) {
|
|
240
|
+
console.log("decode need override ", arrayBuffer);
|
|
241
|
+
}
|
|
242
|
+
toImage(frameIndex, canvas, canvasCtx) {
|
|
243
|
+
console.log("toImage need override ", frameIndex, canvas, canvasCtx);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
//!
|
|
248
|
+
//! utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/WebpData.js;
|
|
249
|
+
//!
|
|
250
|
+
class WebpData extends ApicDataBase {
|
|
251
|
+
decode(array_buffer) {
|
|
252
|
+
let webp_data = new Uint8Array(array_buffer);
|
|
253
|
+
let webp_decoder = new window.WebPDecoder();
|
|
254
|
+
let image_data = window.WebPRiffParser(webp_data, 0);
|
|
255
|
+
let blend = false;
|
|
256
|
+
let header = image_data["header"] ? image_data["header"] : null;
|
|
257
|
+
let frames = image_data["frames"] ? image_data["frames"] : null;
|
|
258
|
+
if (header) {
|
|
259
|
+
this.LoopCount = header["loop_count"];
|
|
260
|
+
header["loop_counter"] = header["loop_count"];
|
|
261
|
+
this._Canvas.height = header["canvas_height"];
|
|
262
|
+
this._Canvas.width = header["canvas_width"];
|
|
263
|
+
this.Width = header["canvas_width"];
|
|
264
|
+
this.Height = header["canvas_height"];
|
|
265
|
+
for (let f = 0; f < frames.length; f++) {
|
|
266
|
+
if (frames[f]["blend"] === 0) {
|
|
267
|
+
blend = true;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
this.FrameCount = frames.length;
|
|
273
|
+
for (let f = 0; f < frames.length; f++) {
|
|
274
|
+
let height = [0];
|
|
275
|
+
let width = [0];
|
|
276
|
+
let frame = frames[f];
|
|
277
|
+
let rgba = webp_decoder.WebPDecodeRGBA(
|
|
278
|
+
webp_data,
|
|
279
|
+
frame["src_off"],
|
|
280
|
+
frame["src_size"],
|
|
281
|
+
width,
|
|
282
|
+
height
|
|
283
|
+
);
|
|
284
|
+
frame["rgba"] = rgba;
|
|
285
|
+
frame["imgwidth"] = width[0];
|
|
286
|
+
frame["imgheight"] = height[0];
|
|
287
|
+
let oldimagedata = [];
|
|
288
|
+
if (!header) {
|
|
289
|
+
this._Canvas.height = height[0];
|
|
290
|
+
this._Canvas.width = width[0];
|
|
291
|
+
} else {
|
|
292
|
+
if (blend) {
|
|
293
|
+
let oldimagedata_ = this._Context.getImageData(
|
|
294
|
+
frame["offset_x"],
|
|
295
|
+
frame["offset_y"],
|
|
296
|
+
width[0],
|
|
297
|
+
height[0]
|
|
298
|
+
);
|
|
299
|
+
for (let i = 0; i < width[0] * height[0] * 4; i++) {
|
|
300
|
+
oldimagedata[i] = oldimagedata_.data[i];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
let imagedata = this._Context.createImageData(width[0], height[0]);
|
|
305
|
+
if (frames.length === 1 && typeof frame["blend"] === "undefined" || frame["blend"] === 1) {
|
|
306
|
+
for (let i = 0; i < width[0] * height[0] * 4; i++)
|
|
307
|
+
imagedata.data[i] = rgba[i];
|
|
308
|
+
} else {
|
|
309
|
+
for (let i = 0; i < width[0] * height[0] * 4; i += 4) {
|
|
310
|
+
if (rgba[i + 3] > 0) {
|
|
311
|
+
imagedata.data[i + 3] = rgba[i + 3];
|
|
312
|
+
imagedata.data[i] = rgba[i];
|
|
313
|
+
imagedata.data[i + 1] = rgba[i + 1];
|
|
314
|
+
imagedata.data[i + 2] = rgba[i + 2];
|
|
315
|
+
} else {
|
|
316
|
+
imagedata.data[i + 3] = oldimagedata[i + 3];
|
|
317
|
+
imagedata.data[i] = oldimagedata[i];
|
|
318
|
+
imagedata.data[i + 1] = oldimagedata[i + 1];
|
|
319
|
+
imagedata.data[i + 2] = oldimagedata[i + 2];
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (frames.length === 1) {
|
|
324
|
+
this._Context.putImageData(imagedata, 0, 0);
|
|
325
|
+
} else {
|
|
326
|
+
this._Context.putImageData(
|
|
327
|
+
imagedata,
|
|
328
|
+
frame["offset_x"],
|
|
329
|
+
frame["offset_y"]
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
frame["frameData"] = frame["rgba"] ? header ? this._Context.getImageData(
|
|
333
|
+
0,
|
|
334
|
+
0,
|
|
335
|
+
header["canvas_width"],
|
|
336
|
+
header["canvas_height"]
|
|
337
|
+
).data : rgba : null;
|
|
338
|
+
if (frame["dispose"] === 1) {
|
|
339
|
+
this._Context.clearRect(
|
|
340
|
+
frame["offset_x"],
|
|
341
|
+
frame["offset_y"],
|
|
342
|
+
width[0],
|
|
343
|
+
height[0]
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
this._DecodedData = image_data;
|
|
348
|
+
}
|
|
349
|
+
toImage(frame_index, canvas, canvas_ctx) {
|
|
350
|
+
let frame = this._DecodedData["frames"][frame_index];
|
|
351
|
+
let width = this._DecodedData["header"] ? this._DecodedData["header"]["canvas_width"] : frame["imgwidth"];
|
|
352
|
+
let height = this._DecodedData["header"] ? this._DecodedData["header"]["canvas_height"] : frame["imgheight"];
|
|
353
|
+
canvas.width = width;
|
|
354
|
+
canvas.height = height;
|
|
355
|
+
let image_data = canvas_ctx.createImageData(width, height);
|
|
356
|
+
let frame_data = frame["frameData"];
|
|
357
|
+
image_data.data.set(frame_data);
|
|
358
|
+
canvas_ctx.putImageData(image_data, 0, 0);
|
|
359
|
+
return frame["duration"];
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
//!
|
|
364
|
+
//! utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/GifData.js;
|
|
365
|
+
//!
|
|
366
|
+
class GifData extends ApicDataBase {
|
|
367
|
+
decode(array_buffer) {
|
|
368
|
+
const gif = window.ApicTools.parseGIF(array_buffer);
|
|
369
|
+
this._DecodedData = window.ApicTools.decompressFrames(gif, true);
|
|
370
|
+
this.LoopCount = 0;
|
|
371
|
+
this.FrameCount = this._DecodedData.length;
|
|
372
|
+
this.Width = this._DecodedData[0].dims.width;
|
|
373
|
+
this.Height = this._DecodedData[0].dims.height;
|
|
374
|
+
for (let i = 0; i < this._DecodedData.length; i++) {
|
|
375
|
+
let frame = this._DecodedData[i];
|
|
376
|
+
if (frame["dims"]["width"] !== this.Width || frame["dims"]["height"] !== this.Height) {
|
|
377
|
+
let pre_frame_data = this._DecodedData[i - 1]["frameData"];
|
|
378
|
+
let left = frame["dims"]["left"];
|
|
379
|
+
let top = frame["dims"]["top"];
|
|
380
|
+
let width = frame["dims"]["width"];
|
|
381
|
+
let height = frame["dims"]["height"];
|
|
382
|
+
let patch_data = frame["patch"];
|
|
383
|
+
let image_data = new Uint8ClampedArray(this.Width * this.Height * 4);
|
|
384
|
+
for (let x = 0; x < this.Width; x++) {
|
|
385
|
+
for (let y = 0; y < this.Height; y++) {
|
|
386
|
+
let patch_x = x - left;
|
|
387
|
+
let patch_y = y - top;
|
|
388
|
+
let pixel_index = y * this.Width + x;
|
|
389
|
+
let patch_pixel_index = patch_y * width + patch_x;
|
|
390
|
+
if (x >= left && x < left + width && y >= top && y < top + height && patch_data[patch_pixel_index * 4 + 3] > 0) {
|
|
391
|
+
image_data[pixel_index * 4] = patch_data[patch_pixel_index * 4];
|
|
392
|
+
image_data[pixel_index * 4 + 1] = patch_data[patch_pixel_index * 4 + 1];
|
|
393
|
+
image_data[pixel_index * 4 + 2] = patch_data[patch_pixel_index * 4 + 2];
|
|
394
|
+
image_data[pixel_index * 4 + 3] = patch_data[patch_pixel_index * 4 + 3];
|
|
395
|
+
} else {
|
|
396
|
+
image_data[pixel_index * 4] = pre_frame_data[pixel_index * 4];
|
|
397
|
+
image_data[pixel_index * 4 + 1] = pre_frame_data[pixel_index * 4 + 1];
|
|
398
|
+
image_data[pixel_index * 4 + 2] = pre_frame_data[pixel_index * 4 + 2];
|
|
399
|
+
image_data[pixel_index * 4 + 3] = pre_frame_data[pixel_index * 4 + 3];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
frame["frameData"] = image_data;
|
|
404
|
+
} else {
|
|
405
|
+
frame["frameData"] = frame["patch"];
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
toImage(frame_index, canvas, canvas_ctx) {
|
|
410
|
+
canvas.width = this.Width;
|
|
411
|
+
canvas.height = this.Height;
|
|
412
|
+
let frame = this._DecodedData[frame_index];
|
|
413
|
+
let image_data = canvas_ctx.createImageData(this.Width, this.Height);
|
|
414
|
+
image_data.data.set(frame["frameData"]);
|
|
415
|
+
canvas_ctx.putImageData(image_data, 0, 0);
|
|
416
|
+
return frame["delay"];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
//!
|
|
421
|
+
//! utils/JsViewVueWidget/JsvApic/JsvBrowserApicLib/BrowserApicLib.js;
|
|
422
|
+
//!
|
|
423
|
+
|
|
424
|
+
export { GifData as G, Viewer as V, WebpData as W };
|