@shijiu/jsview 1.9.731 → 1.9.759

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 (124) hide show
  1. package/dom/jsv-browser-debug-dom.js +12 -5
  2. package/dom/jsv-code-debug.mjs +14 -0
  3. package/dom/jsv-dom.js +12 -5
  4. package/dom/jsv-engine-js-browser.js +12 -5
  5. package/dom/jsv-forge-define.js +17 -5
  6. package/package.json +14 -17
  7. package/patches/node_modules/react-scripts/config/paths.js +161 -0
  8. package/patches/node_modules/react-scripts/config/webpack.config.js +825 -0
  9. package/patches/node_modules/react-scripts/package.json +108 -0
  10. package/patches/node_modules/vite/dist/node/chunks/dep-0fc8e132.js +8 -1
  11. package/patches/node_modules/vite/dist/node/jsview.vite.config.js +15 -7
  12. package/tools/common.js +7 -2
  13. package/tools/jsview-post-build.js +3 -3
  14. package/tools/jsview-post-install-react.js +1 -3
  15. package/tools/jsview-post-install.js +1 -1
  16. package/dom/jsview-dom/README.md +0 -5
  17. package/dom/jsview-dom/package-lock.json-perfect +0 -3898
  18. package/dom/jsview-dom/package.json +0 -23
  19. package/dom/jsview-dom/rollup/browser-debug-dom.rollup.config.js +0 -15
  20. package/dom/jsview-dom/rollup/dom.rollup.config.js +0 -14
  21. package/dom/jsview-dom/rollup/engine-js-browser.rollup.config.js +0 -14
  22. package/dom/jsview-dom/rollup/forge-define.rollup.config.js +0 -14
  23. package/dom/jsview-dom/scripts/release_dist.sh +0 -36
  24. package/dom/jsview-dom/src/dom-browser-hook/HookDocument.js +0 -118
  25. package/dom/jsview-dom/src/dom-browser-hook/OriginDocument.js +0 -19
  26. package/dom/jsview-dom/src/dom-browser-hook/StyleFormatCheck.js +0 -559
  27. package/dom/jsview-dom/src/dom-browser-hook/index.js +0 -6
  28. package/dom/jsview-dom/src/dom-wrapper/ForgeExtension.js +0 -226
  29. package/dom/jsview-dom/src/dom-wrapper/JsViewForgeApp.js +0 -85
  30. package/dom/jsview-dom/src/dom-wrapper/JsViewProxy.js +0 -51
  31. package/dom/jsview-dom/src/dom-wrapper/event/AnimationEvent.js +0 -7
  32. package/dom/jsview-dom/src/dom-wrapper/event/Event.js +0 -12
  33. package/dom/jsview-dom/src/dom-wrapper/event/FocusEvent.js +0 -9
  34. package/dom/jsview-dom/src/dom-wrapper/event/KeyboardEvent.js +0 -43
  35. package/dom/jsview-dom/src/dom-wrapper/event/LoadEvent.js +0 -8
  36. package/dom/jsview-dom/src/dom-wrapper/index.js +0 -16
  37. package/dom/jsview-dom/src/dom-wrapper/node/AnchorElement.js +0 -24
  38. package/dom/jsview-dom/src/dom-wrapper/node/AudioElement.js +0 -60
  39. package/dom/jsview-dom/src/dom-wrapper/node/Comment.js +0 -10
  40. package/dom/jsview-dom/src/dom-wrapper/node/DivElement.js +0 -498
  41. package/dom/jsview-dom/src/dom-wrapper/node/Document.js +0 -274
  42. package/dom/jsview-dom/src/dom-wrapper/node/Element.js +0 -852
  43. package/dom/jsview-dom/src/dom-wrapper/node/FDivElement.js +0 -48
  44. package/dom/jsview-dom/src/dom-wrapper/node/HeadElement.js +0 -47
  45. package/dom/jsview-dom/src/dom-wrapper/node/ImageElement.js +0 -203
  46. package/dom/jsview-dom/src/dom-wrapper/node/JsvAudioTrackElement.js +0 -22
  47. package/dom/jsview-dom/src/dom-wrapper/node/JsvElement.js +0 -40
  48. package/dom/jsview-dom/src/dom-wrapper/node/LinkElement.js +0 -48
  49. package/dom/jsview-dom/src/dom-wrapper/node/MediaElement.js +0 -230
  50. package/dom/jsview-dom/src/dom-wrapper/node/Node.js +0 -178
  51. package/dom/jsview-dom/src/dom-wrapper/node/SVGElement.js +0 -9
  52. package/dom/jsview-dom/src/dom-wrapper/node/ScriptElement.js +0 -45
  53. package/dom/jsview-dom/src/dom-wrapper/node/StyleElement.js +0 -33
  54. package/dom/jsview-dom/src/dom-wrapper/node/StyleElementCache.js +0 -41
  55. package/dom/jsview-dom/src/dom-wrapper/node/Text.js +0 -22
  56. package/dom/jsview-dom/src/dom-wrapper/node/UnknownElement.js +0 -4
  57. package/dom/jsview-dom/src/dom-wrapper/node/VideoElement.js +0 -237
  58. package/dom/jsview-dom/src/dom-wrapper/style/BorderImage.js +0 -25
  59. package/dom/jsview-dom/src/dom-wrapper/style/Inset.js +0 -26
  60. package/dom/jsview-dom/src/dom-wrapper/style/JsvStyleVariable.js +0 -65
  61. package/dom/jsview-dom/src/dom-wrapper/style/KeyframeRule.js +0 -11
  62. package/dom/jsview-dom/src/dom-wrapper/style/StyleDeclaration.js +0 -609
  63. package/dom/jsview-dom/src/dom-wrapper/style/StyleSheet.js +0 -51
  64. package/dom/jsview-dom/src/dom-wrapper/style/StyleValue.js +0 -385
  65. package/dom/jsview-dom/src/dom-wrapper/style/TextStylePackMap.js +0 -43
  66. package/dom/jsview-dom/src/dom-wrapper/style/URL.js +0 -144
  67. package/dom/jsview-dom/src/dom-wrapper/utils/EventHandler.js +0 -42
  68. package/dom/jsview-dom/src/dom-wrapper/utils/FDivRoot.js +0 -86
  69. package/dom/jsview-dom/src/dom-wrapper/utils/JsvLazySyncCache.js +0 -64
  70. package/dom/jsview-dom/src/dom-wrapper/utils/Log.js +0 -42
  71. package/dom/jsview-dom/src/dom-wrapper/utils/MutationObserver.js +0 -32
  72. package/dom/jsview-dom/src/dom-wrapper/utils/focusableNode.js +0 -715
  73. package/dom/jsview-dom/src/engine-js/ForgeDefine.js +0 -8
  74. package/dom/jsview-dom/src/engine-js/ForgeExtensionDefine.js +0 -14
  75. package/dom/jsview-dom/src/engine-js/browser/PlatformUtils.js +0 -100
  76. package/dom/jsview-dom/src/engine-js/browser/animation_base.js +0 -313
  77. package/dom/jsview-dom/src/engine-js/browser/animation_keyframe.js +0 -64
  78. package/dom/jsview-dom/src/engine-js/browser/animation_progress.js +0 -287
  79. package/dom/jsview-dom/src/engine-js/browser/animation_proxy.js +0 -906
  80. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/demux.js +0 -143
  81. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/gifDecoder.js +0 -12
  82. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/libwebp-0.6.0.min.js +0 -160
  83. package/dom/jsview-dom/src/engine-js/browser/console_log.js +0 -25
  84. package/dom/jsview-dom/src/engine-js/browser/dynamic_key_frames.js +0 -95
  85. package/dom/jsview-dom/src/engine-js/browser/easing.js +0 -114
  86. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/element_transform.js +0 -122
  87. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/gjk.js +0 -450
  88. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/mat.js +0 -102
  89. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/range_model.js +0 -296
  90. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/test_collide.js +0 -10
  91. package/dom/jsview-dom/src/engine-js/browser/index.js +0 -38
  92. package/dom/jsview-dom/src/engine-js/browser/latex_parse.js +0 -336
  93. package/dom/jsview-dom/src/engine-js/browser/layout_params.js +0 -113
  94. package/dom/jsview-dom/src/engine-js/browser/layout_view.js +0 -3545
  95. package/dom/jsview-dom/src/engine-js/browser/layout_view_debug.js +0 -15
  96. package/dom/jsview-dom/src/engine-js/browser/media.js +0 -379
  97. package/dom/jsview-dom/src/engine-js/browser/page_base.js +0 -941
  98. package/dom/jsview-dom/src/engine-js/browser/particle_view.js +0 -526
  99. package/dom/jsview-dom/src/engine-js/browser/platform_timer.js +0 -61
  100. package/dom/jsview-dom/src/engine-js/browser/react_utils.js +0 -5
  101. package/dom/jsview-dom/src/engine-js/browser/rect_utils.js +0 -91
  102. package/dom/jsview-dom/src/engine-js/browser/render_bridge.js +0 -128
  103. package/dom/jsview-dom/src/engine-js/browser/render_texture_proxy.js +0 -155
  104. package/dom/jsview-dom/src/engine-js/browser/renderer_deprecated.js +0 -75
  105. package/dom/jsview-dom/src/engine-js/browser/sound_pool.js +0 -139
  106. package/dom/jsview-dom/src/engine-js/browser/steps_animation.js +0 -192
  107. package/dom/jsview-dom/src/engine-js/browser/text_style_cache.js +0 -454
  108. package/dom/jsview-dom/src/engine-js/browser/text_utils.js +0 -299
  109. package/dom/jsview-dom/src/engine-js/browser/text_view.js +0 -428
  110. package/dom/jsview-dom/src/engine-js/browser/texture_manager.js +0 -1060
  111. package/dom/jsview-dom/src/engine-js/browser/url.js +0 -69
  112. package/dom/jsview-dom/src/engine-js/browser/velocity.js +0 -40
  113. package/dom/jsview-dom/src/engine-js/browser/view_sensor/autofroze_sensor.js +0 -77
  114. package/dom/jsview-dom/src/engine-js/browser/view_sensor/drag_impact_sensor.js +0 -67
  115. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor.js +0 -98
  116. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_callback.js +0 -21
  117. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_manager.js +0 -24
  118. package/dom/jsview-dom/src/engine-js/browser/view_sensor/index.js +0 -9
  119. package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor.js +0 -268
  120. package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor_manager.js +0 -84
  121. package/dom/jsview-dom/src/engine-js/browser/view_sensor/visible_sensor.js +0 -213
  122. package/dom/jsview-dom/src/engine-js/browser/view_store.js +0 -41
  123. package/dom/jsview-dom/src/engine-js/index.js +0 -2
  124. package/dom/jsview-dom/src/engine-js/native/README.md +0 -1
@@ -1,498 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- /* eslint-disable no-extra-boolean-cast */
3
- import Forge from "../../engine-js/ForgeDefine";
4
- import Element from "./Element";
5
- import ForgeExtension from "../ForgeExtension";
6
- import StyleDeclaration from "../style/StyleDeclaration";
7
- import sTextStylePackMap from "../style/TextStylePackMap";
8
- import StyleValue from "../style/StyleValue";
9
- class DivElement extends Element {
10
- constructor() {
11
- super();
12
-
13
- this.jsvContentView = null;
14
- this.jsvRefedImgTex = null;
15
- this.jsvTextLatexEnable = false;
16
- this.jsvEmoji = false;
17
- this.jsvTextAlignMinWidth = NaN;
18
- this.jsvEmptyRect = null;
19
- }
20
-
21
- jsvGetTagName() {
22
- return Element.TAG.DIV;
23
- }
24
-
25
- get textContent() {
26
- return this.jsvStore.textContent;
27
- }
28
-
29
- set textContent(text) {
30
- // console.log("Element.set textContent() ========================= parent=" + this.parentNode, " text=" + text);
31
- if (!text && !this.jsvStore.textContent) {
32
- // vue 中无文字节点也会触发textContext,在此避免多余处理
33
- return;
34
- }
35
-
36
- this.jsvStore.textContent = text;
37
- this.jsvStore.clientWidth = NaN;
38
-
39
- if (!this.jsvContentView) {
40
- this.jsvContentView = new Forge.LayoutView();
41
- this.jsvMainView.AddView(this.jsvContentView);
42
- }
43
- if (!!this.parentElement) {
44
- this.jsvFlushViewForeground();
45
- }
46
- }
47
-
48
- // 重载clientWidth,用于触发获取文字宽度这个比较花费性能的API
49
- // 达到按需调用的目的
50
- get clientWidth() {
51
- const width = this.style.width;
52
- if (!!width || width === 0) {
53
- return width;
54
- }
55
-
56
- if (!!this.jsvStore.textContent) {
57
- if (!isNaN(this.jsvStore.clientWidth)) {
58
- return this.jsvStore.clientWidth;
59
- }
60
-
61
- const textParams = {
62
- str: this.jsvStore.textContent,
63
- font: this.style.fontFamily,
64
- size: this.style.fontSize,
65
- italic: this.style.fontStyle,
66
- bold: this.style.fontWeight,
67
- };
68
-
69
- this.jsvStore.clientWidth = ForgeExtension.GetTextWidth(textParams);
70
- // console.warn("DivElement.clientWidth() clientWidth=" + this.jsvStore.clientWidth);
71
- return this.jsvStore.clientWidth;
72
- }
73
-
74
- return super.clientWidth;
75
- }
76
-
77
- jsvOnLoadForgeView() {
78
- if (!!this.style.borderImage) {
79
- this.jsvMaskView = new Forge.NinePatchView();
80
- }
81
-
82
- super.jsvOnLoadForgeView();
83
- }
84
-
85
- jsvCallbackOnUnloadForgeView() {
86
- return this.jsvOnUnloadForgeView.bind(this);
87
- }
88
-
89
- jsvOnUnloadForgeView() {
90
- ForgeExtension.UnrefImgTexSize(this.jsvRefedImgTex);
91
- this.jsvRefedImgTex = null;
92
- }
93
-
94
- jsvOnStyleChanged(styleTypes) {
95
- // console.log("DivElement.jsvOnStyleChanged() styleTypes=", styleTypes);
96
- super.jsvOnStyleChanged(styleTypes);
97
-
98
- this.jsvStore.textStylePack = null; // 当Style更新时,用于描画文字的stylePack属性需要重做
99
-
100
- let flushedInForeground = !!styleTypes[StyleDeclaration.TYPE.FOREGROUND];
101
- if (styleTypes[StyleDeclaration.TYPE.LAYOUT_SIZE]) {
102
- if (!flushedInForeground) {
103
- this.jsvFlushViewForeground();
104
- }
105
- }
106
- if (styleTypes[StyleDeclaration.TYPE.FOREGROUND]) {
107
- this.jsvFlushViewForeground();
108
- }
109
- if (styleTypes[StyleDeclaration.TYPE.BORDER]) {
110
- this.jsvFlushViewBorder();
111
- }
112
- }
113
-
114
- jsvFlushViewForeground() {
115
- // console.log("DivElement.jsvFlushViewForeground() this=", this);
116
- if (!this.jsvContentView) {
117
- return;
118
- }
119
-
120
- this.jsvContentView.ClearViews();
121
- if (!!this.jsvStore.textContent) {
122
- let auto_height = typeof this.style.height == 'undefined' || this.style.height == 0;
123
- let text_load_callback = auto_height ? (texture_info, params) => {
124
- this.jsvStore.clientHeight = texture_info.height
125
- } : null;
126
-
127
- let text_view = this.jsvBuildTextView(text_load_callback);
128
-
129
- // 自动适配高度
130
- if (auto_height) {
131
- text_view.EnableAutoHeight();
132
- }
133
-
134
- this.jsvContentView.AddView(text_view);
135
- }
136
- }
137
-
138
- jsvBuildTextView(text_load_callback) {
139
- // 若文字Style未变化,仅文字内容发生变化,则可以沿用上一次的style pack
140
- let style_pack = this.jsvStore.textStylePack;
141
-
142
- // 尝试使用 JsvStyleClass 来直接构建 TextStylePack
143
- if (style_pack === null) {
144
- style_pack = this._jsvGetClassNameCache();
145
- }
146
-
147
- if (style_pack === null) {
148
- // (慢速)解析 style 属性来创建 style_pack
149
-
150
- // 补填文字JsView附加属性
151
- if (!this.style.jsvCustomStyles.textLineAlign) {
152
- // 若设置了line height,则进行行内居中
153
- // TODO: lineHeight后续调整后不会跟随,因为不好识别设置的的这个textLineAlign是来自JsvStyleClass还是lineHeight
154
- // TODO: 若后续需要识别,或许需要新加一个叫textAutoLineAlign来专门识别来自lineHeight的?
155
- this.style.jsvCustomStyles.textLineAlign = (!!this.style.lineHeight ? 'middle' : 'top');
156
- }
157
- if (!this.style.jsvCustomStyles.textVerticalAlign) {
158
- this.style.jsvCustomStyles.textVerticalAlign = "top";
159
- }
160
- let pack_data = DivElement._jsvStyleToPackData(
161
- this.style
162
- );
163
-
164
- let map_token = JSON.stringify(pack_data);
165
- let cached_pack = sTextStylePackMap.getTempPack(map_token);
166
- if (!cached_pack) {
167
- // 创建cache pack
168
- cached_pack = Forge.sTextStyleCache.StyleToPack(pack_data);
169
-
170
- // 记录临时缓存
171
- sTextStylePackMap.putTempPack(map_token, cached_pack);
172
- }
173
-
174
- style_pack = cached_pack;
175
- }
176
-
177
- // 缓存style pack
178
- this.jsvStore.textStylePack = style_pack;
179
-
180
- // Line height:
181
- // 优先使用设置的lineHeight,
182
- // 其次使用FontSize计算一个,
183
- // FontSize和LineHeight都未设置场景,使用14px作为lineHeight
184
- // ParseInt(lineHeight)的作用: lineHeight经常被写成字符串"??px"
185
- let line_height = (!!this.style.lineHeight ? parseInt(this.style.lineHeight) : (!!this.style.fontSize ? this.style.fontSize * 1.3 : 14));
186
-
187
- // Text Area
188
- let text_width = this.style.width;
189
- let text_auto_width = false;
190
- if (typeof text_width == "undefined") {
191
- text_width = this.clientWidth; // 触发通过native接口量取文字程度处理
192
- text_auto_width = true;
193
- }
194
-
195
- if (this.jsvTextAlignMinWidth) {
196
- if (text_width < this.jsvTextAlignMinWidth) {
197
- text_width = this.jsvTextAlignMinWidth;
198
- }
199
- }
200
-
201
- if (text_width > 3000) {
202
- // 文字过长,大于GL描画最大宽度,将分段排列
203
- if (!text_auto_width) {
204
- console.error(`text too long. str=${this.jsvStore.textContent}`);
205
- return null;
206
- } else {
207
- console.log(`text too long, start to break down. width(${text_width})`)
208
- }
209
-
210
- let text_view = new Forge.LayoutView();
211
-
212
- // 未考虑DesigneMapWidth 和 text scale的情况下先初略计算
213
- let max_text_len = Math.floor(2048 / this.style.fontSize);
214
- let left_text_len = this.jsvStore.textContent.length;
215
- let text_read_idx = 0;
216
- let view_left = 0;
217
-
218
- let textParams = {
219
- str: null,
220
- font: this.style.fontFamily,
221
- size: this.style.fontSize,
222
- italic: this.style.fontStyle,
223
- bold: this.style.fontWeight,
224
- };
225
-
226
- while (left_text_len > 0) {
227
- // 使用 style_pack 创建 TextView
228
- let sub_len = max_text_len < left_text_len ? max_text_len : left_text_len;
229
- let sub_text = this.jsvStore.textContent.substr(text_read_idx, sub_len);
230
- text_read_idx += sub_len;
231
-
232
- // 计算区域宽度
233
- textParams.str = sub_text;
234
- let client_width = ForgeExtension.GetTextWidth(textParams);
235
-
236
- let sub_text_view = Forge.sTextUtils.BuildTextView(
237
- ForgeExtension.TextureManager,
238
- sub_text,
239
- style_pack,
240
- text_read_idx === 0 ? text_load_callback : null, // 仅首个请求发送text callback来计算height
241
- { width: client_width, height: this.style.height },
242
- this.style.fontSize,
243
- line_height,
244
- true,
245
- this.jsvTextLatexEnable,
246
- this.jsvEmoji, this.jsvEmptyRect);
247
-
248
- text_view.AddView(sub_text_view, { x: view_left, y:0, width: client_width, height: this.style.height});
249
- view_left += client_width; // 下一个view相对横移clientWidth
250
-
251
- left_text_len -= sub_len;
252
- }
253
-
254
- return text_view;
255
- } else {
256
- // 使用 style_pack 创建 TextView
257
- let text_view = Forge.sTextUtils.BuildTextView(
258
- ForgeExtension.TextureManager,
259
- this.jsvStore.textContent,
260
- style_pack,
261
- text_load_callback,
262
- { width: text_width, height: this.style.height },
263
- this.style.fontSize,
264
- line_height,
265
- true,
266
- this.jsvTextLatexEnable,
267
- this.jsvEmoji, this.jsvEmptyRect);
268
-
269
- return text_view;
270
- }
271
- }
272
-
273
- _jsvGetClassNameCache() {
274
- // 返回由JsvStyleClass为关键字进行缓存的文字属性设置
275
- // 条件:
276
- // 1. 文字的主要属性全由 JsvStyleClass 提供,无直接通过style进行单独的设置项
277
- // 2. JsvStyleClass 中确实有文字主要属性设置项
278
-
279
- if (this.style.jsvNamedClassArray === null) {
280
- // 无Class,不能使用Cache
281
- return null;
282
- }
283
-
284
- // 检查是否有独立的文字主要属性
285
- if (StyleDeclaration.JsvContainsTextMajor(this.style.jsvLockedProps)) {
286
- return null;
287
- }
288
-
289
- let map_token = "";
290
- for (let single_class of this.style.jsvNamedClassArray) {
291
- // 检测普通JsvStyleClass也含有文字属性(attach.hasTextMajorStyle仍然为0的项目)
292
- // PS: JsvTextStyleClass已经在StyleDeclaration.jsvApplyClasses中进行识别处理
293
- let attach = single_class.getAttach();
294
- if (attach.hasTextMajorStyle === 0) {
295
- // 对普通JsvStyleClass进行检测文字属性
296
- if (StyleDeclaration.JsvContainsTextMajor(single_class.getStyles())) {
297
- // 含有
298
- attach.hasTextMajorStyle = 2;
299
- } else {
300
- // 不含
301
- attach.hasTextMajorStyle = 1;
302
- }
303
- }
304
-
305
- if (attach.hasTextMajorStyle === 2) {
306
- // 所有含有文字主要属性的Class
307
- map_token += single_class.getName();
308
- }
309
- }
310
-
311
- if (map_token.length > 0) {
312
- let cached_pack = sTextStylePackMap.getPersistPack(map_token);
313
- if (!cached_pack) {
314
- // 创建 Forge.TextStylePack
315
- let pack_data = DivElement._jsvStyleToPackData(
316
- this.style
317
- );
318
-
319
- cached_pack = Forge.sTextStyleCache.StyleToPack(pack_data);
320
-
321
- // 记录Persist Pack Map
322
- sTextStylePackMap.putPersistPack(map_token, cached_pack);
323
- }
324
-
325
- return cached_pack;
326
- } else {
327
- // 不能使用 ClassName 做出的Cache
328
- return null;
329
- }
330
- }
331
-
332
- static _jsvStyleToPackData(obj_style) {
333
- // 将 element.style 转化成 TextStyleCache.StyleToPack 所需要的 style
334
- let style_pack_data = {
335
- textColor: obj_style.color ? obj_style.color : "#000000", // 默认黑色
336
- font: obj_style.fontFamily,
337
- italic: obj_style.fontStyle === 'italic',
338
- bold: obj_style.fontWeight === 'bold',
339
- hAlign: (!!obj_style.textAlign ? obj_style.textAlign : "start"),
340
- vAlign: (!!obj_style.jsvCustomStyles.textLineAlign ? obj_style.jsvCustomStyles.textLineAlign : "middle"),
341
- vAreaAlign: (!!obj_style.jsvCustomStyles.textVerticalAlign ? obj_style.jsvCustomStyles.textVerticalAlign : "top"),
342
- textOverflow: (!!obj_style.textOverflow ? obj_style.textOverflow : "clip"),
343
- wordWrap: (obj_style.wordWrap === 'break-word' ? 'break_word' : "normal"),
344
- direction: (obj_style.direction === 'rtl' ? 'rtl' : 'ltr'),
345
- };
346
-
347
- if (obj_style.whiteSpace === 'nowrap') {
348
- style_pack_data.wordWrap = "none"; // 强制不换行
349
- }
350
-
351
- // console.log("DivElement._jsvStyleToPackData() textContent=" + this.jsvStore.textContent + " style=", textStyle);
352
- // Shadow解析
353
- let text_shadow = (!!obj_style.textShadow ? obj_style.textShadow.split(" ") : undefined);
354
- if (!!text_shadow) {
355
- style_pack_data.shadow = {
356
- shadowOffsetX: parseInt(text_shadow[0]),
357
- shadowOffsetY: parseInt(text_shadow[1]),
358
- shadowBlur: parseFloat(text_shadow[2]),
359
- shadowColor: text_shadow[3],
360
- };
361
- }
362
-
363
- // Stroke解析
364
- let text_stroke = (obj_style.WebkitTextStroke ? obj_style.WebkitTextStroke.split(" ") : undefined);
365
- if (text_stroke) {
366
- style_pack_data.stroke = {
367
- strokeWidth: parseInt(text_stroke[0]),
368
- strokeColor: text_stroke[1]
369
- }
370
- }
371
-
372
- return style_pack_data;
373
- }
374
-
375
- jsvFlushViewBorder() {
376
- // console.warn("DivElement.jsvFlushViewBorder() borderImage=", this.style.borderImage);
377
- if (!this.jsvMaskView) {
378
- return;
379
- }
380
- if (!!this.style.clipPath) {
381
- console.error("BorderImage is conflicting with ClipPath.");
382
- return;
383
- }
384
-
385
- if (!!this.style.borderImage) {
386
- if (!(this.jsvMaskView instanceof Forge.NinePatchView)) {
387
- console.error("Error: style.borderImage NOT support dynamic adding");
388
- return;
389
- }
390
-
391
- let imageWidth = StyleValue.ConvertPx(this.getAttribute("jsv-borderimage-width"));
392
- let imageHeight = StyleValue.ConvertPx(this.getAttribute("jsv-borderimage-height"));
393
- ForgeExtension.UnrefImgTexSize(this.jsvRefedImgTex);
394
- if (!this.jsvRefedImgTex
395
- || this.jsvRefedImgTex.Source !== this.style.borderImage.source.href) {
396
- let size = (!!imageWidth && !!imageHeight) ? { width: imageWidth, height: imageHeight } : null;
397
- if (this.style.borderImage.source.href) {
398
- this.jsvRefedImgTex = ForgeExtension.TextureManager.GetImage2(
399
- this.style.borderImage.source.href,
400
- false, size, Forge.ColorSpace.RGBA_8888);
401
- } else {
402
- // 无效href, 不显示view
403
- this.jsvMaskView.ResetTexture(null);
404
- return;
405
- }
406
- }
407
-
408
- if (!!imageWidth && !!imageHeight) {
409
- console.log("Custom cache image size with: " + imageWidth + "/" + imageHeight);
410
- ForgeExtension.SetImgTexSize(this.jsvRefedImgTex, {
411
- width: imageWidth,
412
- height: imageHeight,
413
- })
414
- }
415
-
416
- const textureSetting = new Forge.ExternalTextureSetting(this.jsvRefedImgTex);
417
- this.jsvMaskView.ResetTexture(textureSetting);
418
- this.jsvMaskView.WaitTextureToResize(true);
419
-
420
- // 添加引用,防止其他view延迟使用
421
- ForgeExtension.RefImgTexSize(this.jsvRefedImgTex, function (imageSize) {
422
- if (!this.jsvMaskView) {
423
- console.log("Found border view gone");
424
- return;
425
- }
426
-
427
- // 获取slice和width
428
- let border_image_wide = this.style.borderImageWidth;
429
- let border_image_slice = this.style.borderImage.slice;
430
-
431
- // 对原图进行缩放处理(原图和显示图的比例在width和slice比例中体现)
432
- let dsp_image_width = Math.floor(imageSize.width * border_image_wide.top / border_image_slice.top);
433
- let dsp_image_height = Math.floor(imageSize.height * border_image_wide.left / border_image_slice.left);
434
- this.jsvMaskView.SetImageDspSize(dsp_image_width, dsp_image_height);
435
-
436
- let outset = (!!this.style.borderImageOutset
437
- ? this.style.borderImageOutset
438
- : StyleValue.ConvertRect());
439
- // NinePatchView的Padding的意思和html不同,这里的padding指的是内容填充区域在图片中的位置
440
- this.jsvMaskView.SetPadding({
441
- start: outset.left,
442
- width: Math.max(0, dsp_image_width - outset.left - outset.right),
443
- }, {
444
- start: outset.top,
445
- width: Math.max(0, dsp_image_height - outset.top - outset.bottom),
446
- });
447
-
448
- // NinePatchView的repeat指的是拉伸区域, repeat区域最小尺度为1
449
- this.jsvMaskView.SetRepeat([{
450
- start: border_image_wide.left,
451
- width: Math.max(0, dsp_image_width - border_image_wide.left * 2),
452
- }], [{
453
- start: border_image_wide.top,
454
- width: Math.max(0, dsp_image_height - border_image_wide.top * 2),
455
- }]);
456
- // console.warn("DivElement.jsvFlushViewBorder(). style=", this.style);
457
-
458
- this.jsvMaskView.WaitTextureToResize(false);
459
- }.bind(this));
460
- }
461
- }
462
-
463
- setAttribute(name, value) {
464
- // 拦截文字处理信息
465
- if (this.jsvTakeTextAttribute(name, value)) {
466
- return;
467
- }
468
-
469
- super.setAttribute(name, value);
470
- }
471
-
472
- jsvTakeTextAttribute(name, value) {
473
- if (name === "jsv_text_vertical_align") {
474
- this.style.jsvCustomStyles.textVerticalAlign = value;
475
- return true;
476
- } else if (name === "jsv_text_line_align") {
477
- this.style.jsvCustomStyles.textLineAlign = value;
478
- return true;
479
- } else if (name === "jsv_text_latex_enable") {
480
- // 启动Latex文字显示模式
481
- this.jsvTextLatexEnable = value === "true";
482
- return true;
483
- } else if (name === "jsv_text_align_minwidth") {
484
- // 启用文字对齐的最小距离,用于不定长文字进行居中显示场景
485
- this.jsvTextAlignMinWidth = parseInt(value);
486
- return true;
487
- } else if (name === "jsv_text_emoji") {
488
- this.jsvEmoji = value === "true" || value === true;
489
- return true;
490
- } else if (name === "jsv_text_empty_rect") {
491
- this.jsvEmptyRect = JSON.parse(value);
492
- }
493
-
494
- return false;
495
- }
496
- }
497
-
498
- export default DivElement;