@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,11 +0,0 @@
1
- export default class KeyframeRule {
2
- constructor(text) {
3
- let nameStartIdx = text.indexOf(KeyframeRule.KeyFramesFlag) + KeyframeRule.KeyFramesFlag.length;
4
- let nameEndIdx = text.indexOf("{");
5
- let name = text.substring(nameStartIdx, nameEndIdx);
6
- this.name = name.trim();
7
- this.cssText = text;
8
- }
9
- }
10
-
11
- KeyframeRule.KeyFramesFlag = "@keyframes"
@@ -1,609 +0,0 @@
1
- /* eslint-disable no-extra-boolean-cast */
2
- /* eslint-disable no-prototype-builtins */
3
- import {JsvLazySyncCache} from "../utils/JsvLazySyncCache"
4
- import StyleValue from "./StyleValue"
5
- import Inset from "./Inset"
6
- import BorderImage from "./BorderImage"
7
- import JsvStyleVariable from "./JsvStyleVariable"
8
- import Forge from "../../engine-js/ForgeDefine"
9
- import Log from "../utils/Log"
10
-
11
- class StyleDeclaration {
12
- constructor() {
13
- this.jsvStore = {};
14
- this.jsvLazySyncCache = new JsvLazySyncCache("style");
15
- this.jsvLockedProps = {};
16
- this.jsvNamedClassArray = null;
17
- this.jsvCustomStyles = {};
18
-
19
- this.jsvLazyPrevClassNames = null;
20
- this.jsvLazyPrevInheritedClassNames = null;
21
- this.jsvLazyClassNames = null;
22
- this.jsvLazyInheritedClassNames = null;
23
- this.jsvLazyClassAttributes = null;
24
- }
25
-
26
- setProperty(propName, propValue) {
27
- // console.log("StyleDeclaration.setPropertyValue() propName=" + propName + ", propValue=" + propValue);
28
-
29
- if (typeof document.jsvCheckStyleFormat === "function") {
30
- document.jsvCheckStyleFormat(propName, propValue);
31
- }
32
-
33
- this.jsvLockedProps[propName] = true; // 通过Style设置过的prop不被class style影响
34
-
35
- propValue = StyleDeclaration.JsvConvertPropValue(propName, propValue); // 属性规范化
36
- this.jsvUpdateProperty(propName, propValue);
37
- }
38
-
39
- getPropertyValue(propName) {
40
- if(this.jsvStore[propName] !== undefined) {
41
- return this.jsvStore[propName];
42
- }
43
-
44
- // 去class中查找, 固定值的class属性没有在jsvStore中。
45
- let propValue = this.jsvGetClassPropValue(this.jsvLazyClassNames, this.jsvLazyClassAttributes, propName)
46
- if (propValue) {
47
- // Animation和Transition设计到了Forge的处理,所以未在编译期格式化
48
- if (propName == StyleDeclaration.PROP.ANIMATION) {
49
- propValue = StyleValue.ConvertAnimation(propValue);
50
- } else if (propName == StyleDeclaration.PROP.TRANSITION) {
51
- propValue = StyleValue.ConvertTransition(propValue);
52
- }
53
-
54
- // BackgroundImage的linear-gradient设计到了Forge的处理,所以未在编译期格式化
55
- if (propName == StyleDeclaration.PROP.BACKGROUNDIMAGE) {
56
- propValue = StyleValue.ConvertGradient(propValue);
57
- }
58
- // console.log("StyleDeclaration.getPropertyValue(0) propName=" + propName + ", propValue=" + propValue);
59
- return propValue;
60
- }
61
- propValue = this.jsvGetClassPropValue(this.jsvLazyInheritedClassNames, this.jsvLazyClassAttributes, propName)
62
- if (propValue) {
63
- // Animation和Transition设计到了Forge的处理,所以未在编译期格式化
64
- if (propName == StyleDeclaration.PROP.ANIMATION) {
65
- propValue = StyleValue.ConvertAnimation(propValue);
66
- } else if (propName == StyleDeclaration.PROP.TRANSITION) {
67
- propValue = StyleValue.ConvertTransition(propValue);
68
- }
69
-
70
- // BackgroundImage的linear-gradient设计到了Forge的处理,所以未在编译期格式化
71
- if (propName == StyleDeclaration.PROP.BACKGROUNDIMAGE) {
72
- propValue = StyleValue.ConvertGradient(propValue);
73
- }
74
- // console.log("StyleDeclaration.getPropertyValue(1) propName=" + propName + ", propValue=" + propValue);
75
- return propValue;
76
- }
77
-
78
- // console.log("StyleDeclaration.getPropertyValue() propName=" + propName + ", propValue=" + propValue);
79
- return undefined;
80
- }
81
-
82
- jsvDestory() {
83
- // console.warn("StyleDeclaration.jsvDestory()");
84
- JsvStyleVariable.RemoveRefStyle(this);
85
- }
86
-
87
- jsvUpdateProperty(propName, propValue) {
88
- let type = this.jsvSetPropertySilently(propName, propValue);
89
- if(!!type) {
90
- this.jsvLazySyncCache.setCacheProperty(type, true);
91
- }
92
- }
93
-
94
- jsvSetPropertySilently(propName, propValue) {
95
- if(propName.startsWith('--')) {
96
- JsvStyleVariable.UpdateValue(propName, propValue);
97
- return;
98
- } else if(typeof(propValue) === 'string' && propValue.startsWith('var(--')) {
99
- JsvStyleVariable.AppendRefStyle(propValue, this, propName);
100
- return;
101
- }
102
-
103
- if (propName === "animation") {
104
- if (this.jsvStore[propName]?.originStr === propValue?.originStr) {
105
- return null;
106
- }
107
- } else if (this.jsvStore[propName] === propValue) { // no changed
108
- return null;
109
- }
110
- this.jsvStore[propName] = propValue;
111
- let type = StyleDeclaration.JsvGetStyleType(propName);
112
-
113
- return type
114
- }
115
-
116
- jsvApplyClasses(classNames, isInherited) {
117
- if (!classNames) {
118
- // 当className="undefined" 的用法,在reactive语法中经常遇到这种情况
119
- // TODO: 未考虑className本身是reactive场景,vue/react现行app框架未出现这种场景
120
- return;
121
- }
122
-
123
- // JsvStyle_标识的class是react的旧处理方式,如果没有此标识,用新的css-to-js方式处理
124
- if(classNames.indexOf("JsvStyle_") < 0) {
125
- if (!isInherited) {
126
- this.jsvLazyPrevClassNames = this.jsvLazyClassNames;
127
- this.jsvLazyClassNames = classNames.split(" ");
128
- } else {
129
- this.jsvLazyPrevInheritedClassNames = this.jsvLazyInheritedClassNames;
130
- this.jsvLazyInheritedClassNames = classNames.split(" ");
131
- }
132
-
133
- const type = StyleDeclaration.TYPE.CLASS_NAME;
134
- this.jsvLazySyncCache.setCacheProperty(type, true);
135
-
136
- return;
137
- }
138
-
139
- // 带JsvStyle_标识的class处理方式
140
- if (classNames) {
141
- let class_array = classNames.split(" ");
142
- let target = {};
143
-
144
- this.jsvNamedClassArray = new Array(class_array.length);
145
- let push_idx = 0;
146
-
147
- // 以此合并所有class设定
148
- for (let item of class_array) {
149
- let class_obj = null;
150
- if (Forge.ReactUtils.StyleClassMap.hasOwnProperty(item)) {
151
- // 属性转化
152
- class_obj = Forge.ReactUtils.StyleClassMap[item];
153
- let attach = class_obj.getAttach();
154
- if (attach == null) {
155
- // 首次使用,进行属性转化
156
- let styles = class_obj.getStyles();
157
- attach = {
158
- altStyles:{}, // 转化后的style
159
- hasTextMajorStyle: 0, // 0: 未检测, 1: 普通JsvStyleClass, 2:JsvTextStyleClass或者含有文字属性的JsvStyleClass
160
- textPackAttr: null,
161
- };
162
- for (let prop_name in styles) {
163
- attach.altStyles[prop_name] = StyleDeclaration.JsvConvertPropValue(prop_name, styles[prop_name]);
164
- }
165
- class_obj.updateAttach(attach);
166
- }
167
-
168
- // 文字class附加处理
169
- // 读取文字相关的custom style属性
170
- if (class_obj.classType() === "text") {
171
- attach.hasTextMajorStyle = 2;
172
-
173
- // 读出text只有属性
174
- if (attach.textPackAttr === null) {
175
- attach.textPackAttr = {
176
- textLineAlign: class_obj.getLineAlign(),
177
- textVerticalAlign: class_obj.getVerticalAlign(),
178
- };
179
- }
180
-
181
- // 更新text custom style
182
- this.jsvCustomStyles.textLineAlign = attach.textPackAttr.textLineAlign;
183
- this.jsvCustomStyles.textVerticalAlign = attach.textPackAttr.textVerticalAlign;
184
- }
185
-
186
- // 项目合并
187
- Object.assign(target, attach.altStyles);
188
- } else {
189
- console.error("Error: className not found");
190
- }
191
-
192
- // 关联className对应的class,为后续使用
193
- this.jsvNamedClassArray[push_idx] = class_obj;
194
- push_idx++;
195
- }
196
-
197
- for (let prop_name in target) {
198
- // 将未锁定的属性以此设定进style中,并触发刷新
199
- if (!this.jsvLockedProps[prop_name]) {
200
- this.jsvUpdateProperty(prop_name, target[prop_name]);
201
- }
202
- }
203
- }
204
- }
205
-
206
- jsvAppendClassAttribute(attribute) {
207
- if(!this.jsvLazyClassAttributes) {
208
- this.jsvLazyClassAttributes = new Set();
209
- }
210
- this.jsvLazyClassAttributes.add(attribute);
211
-
212
- const type = StyleDeclaration.TYPE.CLASS_NAME;
213
- this.jsvLazySyncCache.setCacheProperty(type, true);
214
- }
215
-
216
- jsvSetClassProperty(propName) {
217
- let type = StyleDeclaration.JsvGetStyleType(propName);
218
- if(!!type) {
219
- this.jsvLazySyncCache.setCacheProperty(type, true);
220
- }
221
- }
222
-
223
- jsvGetClassPropValue(classNames, classAttributes, propName) {
224
- if(!classNames) {
225
- return undefined;
226
- }
227
-
228
- const searchPropValue = (styleSheets, classNames, classAttribute, propName) => {
229
- for (let idx = classNames.length - 1; idx >= 0; idx--) {
230
- let className = classNames[idx];
231
- if(!!classAttribute) { // 添加属性选择器
232
- className += ("[" + classAttribute + "]");
233
- }
234
- if (!styleSheets.hasOwnProperty(className)) {
235
- continue;
236
- }
237
-
238
- const declarations = styleSheets[className];
239
- if(!declarations.hasOwnProperty(propName)) {
240
- continue;
241
- }
242
-
243
- let propValue = declarations[propName];
244
- if(typeof(propValue) === 'string' && propValue.startsWith('var(--')) {
245
- propValue = JsvStyleVariable.GetValue(propValue);
246
- }
247
-
248
- return propValue;
249
- }
250
- };
251
-
252
- const styleSheets = window.JsvCode.Dom.StyleSheets;
253
-
254
- // vue3通过属性选择器来实现scoped
255
- for (const classAttribute of (classAttributes ?? [])) {
256
- const propValue = searchPropValue(styleSheets, classNames, classAttribute, propName);
257
- if(!!propValue) {
258
- return propValue;
259
- }
260
- }
261
-
262
- // 查找普通class
263
- const propValue = searchPropValue(styleSheets, classNames, null, propName);
264
-
265
- return propValue;
266
- }
267
-
268
- jsvGetClassDeclarations(classNames, classAttributes) {
269
- if(!classNames) {
270
- return undefined;
271
- }
272
-
273
- const getClassDeclarations = (styleSheets, classNames, classAttribute) => {
274
- let classDeclarations = {}
275
- for (let idx = 0; idx < classNames.length; idx++) {
276
- let className = classNames[idx];
277
- if(!!classAttribute) { // 添加属性选择器
278
- className += ("[" + classAttribute + "]");
279
- }
280
- if (!styleSheets.hasOwnProperty(className)) {
281
- continue;
282
- }
283
-
284
- const declarations = styleSheets[className];
285
- Object.assign(classDeclarations, declarations);
286
- }
287
-
288
- return classDeclarations;
289
- };
290
-
291
- const styleSheets = window.JsvCode.Dom.StyleSheets;
292
-
293
- // 获取普通class
294
- let classDeclarations = getClassDeclarations(styleSheets, classNames, null);
295
-
296
- // vue3通过属性选择器来实现scoped
297
- for (const classAttribute of (classAttributes ?? [])) {
298
- const declarations = getClassDeclarations(styleSheets, classNames, classAttribute);
299
- Object.assign(classDeclarations, declarations);
300
- }
301
-
302
- return classDeclarations;
303
- }
304
-
305
- jsvUpdateChangedClasses(lazyClassNames, lazyPrevClassNames, lazyClassAttributes) {
306
- Log.D("jsvGetChangedClassTypes() classNames=" + lazyClassNames);
307
-
308
- let changedTypes = {}
309
-
310
- // 重置上一次的class
311
- if(!!lazyPrevClassNames) {
312
- JsvStyleVariable.RemoveRefStyle(this);
313
-
314
- const prevClassDeclarations = this.jsvGetClassDeclarations(lazyPrevClassNames, lazyClassAttributes);
315
- for(const propName of Object.keys(prevClassDeclarations)) {
316
- const type = StyleDeclaration.JsvGetStyleType(propName);
317
- changedTypes[type] = true;
318
- }
319
- lazyPrevClassNames = null;
320
- }
321
-
322
- // 设置本次的class
323
- if(!!lazyClassNames) {
324
- const classDeclarations = this.jsvGetClassDeclarations(lazyClassNames, lazyClassAttributes);
325
- for(const [propName, propValue] of Object.entries(classDeclarations)) {
326
- const type = StyleDeclaration.JsvGetStyleType(propName);
327
- changedTypes[type] = true;
328
-
329
- if(typeof(propValue) === 'string' && propValue.startsWith('var(--')) {
330
- JsvStyleVariable.AppendRefStyle(propValue, this, propName);
331
- }
332
- }
333
- }
334
-
335
- // TODO: 文字class加速没有实现。
336
- return changedTypes;
337
- }
338
-
339
- jsvSetChangedListener(listener) {
340
- let callback = null;
341
- if (listener) {
342
- callback = (caches) => {
343
- // console.log("StyleDeclaration.jsvSetChangedListener() keys=" + JSON.stringify(Object.keys(caches)))
344
-
345
- if (caches.hasOwnProperty(StyleDeclaration.TYPE.CLASS_NAME)) {
346
- let changedTypes = this.jsvUpdateChangedClasses(this.jsvLazyClassNames,
347
- this.jsvLazyPrevClassNames,
348
- this.jsvLazyClassAttributes);
349
- Object.assign(caches, changedTypes);
350
- changedTypes = this.jsvUpdateChangedClasses(this.jsvLazyInheritedClassNames,
351
- this.jsvLazyPrevInheritedClassNames,
352
- this.jsvLazyClassAttributes);
353
- Object.assign(caches, changedTypes);
354
-
355
- caches[StyleDeclaration.TYPE.CLASS_NAME] = undefined;
356
- }
357
-
358
- listener(caches);
359
- };
360
- }
361
- this.jsvLazySyncCache.setOnSyncCallback(callback);
362
- }
363
-
364
- static JsvContainsTextMajor(test_style) {
365
- for (let major_style of StyleDeclaration.TextClassMajorStyles) {
366
- if (test_style.hasOwnProperty(major_style))
367
- return true;
368
- }
369
-
370
- return false;
371
- }
372
-
373
- static JsvGetStyleType(propName) {
374
- switch(propName) {
375
- case StyleDeclaration.PROP.LEFT:
376
- case StyleDeclaration.PROP.RIGHT:
377
- case StyleDeclaration.PROP.TOP:
378
- case StyleDeclaration.PROP.BOTTOM:
379
- case StyleDeclaration.PROP.ZINDEX:
380
- return StyleDeclaration.TYPE.LAYOUT_POS;
381
- case StyleDeclaration.PROP.TRANSFORM:
382
- case StyleDeclaration.PROP.TRANSFORMORIGIN:
383
- return StyleDeclaration.TYPE.TRANSFORM;
384
- case StyleDeclaration.PROP.WIDTH:
385
- case StyleDeclaration.PROP.HEIGHT:
386
- case StyleDeclaration.PROP.VISIBILITY:
387
- case StyleDeclaration.PROP.DISPLAY:
388
- case StyleDeclaration.PROP.CLIPPATH:
389
- case StyleDeclaration.PROP.OVERFLOW:
390
- case StyleDeclaration.PROP.OBJECTFIT:
391
- case StyleDeclaration.PROP.PERSPECTIVE:
392
- case StyleDeclaration.PROP.PERSPECTIVEORIGIN:
393
- case StyleDeclaration.PROP.BACKFACEVISIBILITY:
394
- case StyleDeclaration.PROP.TRANSFORMSTYLE:
395
- case StyleDeclaration.PROP.JSVVIDEOROTATION:
396
- return StyleDeclaration.TYPE.LAYOUT_SIZE;
397
- case StyleDeclaration.PROP.BACKGROUNDCOLOR:
398
- case StyleDeclaration.PROP.BACKGROUNDIMAGE:
399
- case StyleDeclaration.PROP.BORDERRADIUS:
400
- return StyleDeclaration.TYPE.BACKGROUND;
401
- case StyleDeclaration.PROP.COLOR:
402
- case StyleDeclaration.PROP.LINEHEIGHT:
403
- case StyleDeclaration.PROP.WHITESPACE:
404
- case StyleDeclaration.PROP.FONTFAMILY:
405
- case StyleDeclaration.PROP.FONTSIZE:
406
- case StyleDeclaration.PROP.FONTSTYLE:
407
- case StyleDeclaration.PROP.FONTWEIGHT:
408
- case StyleDeclaration.PROP.TEXTALIGN:
409
- case StyleDeclaration.PROP.TEXTSHADOW:
410
- case StyleDeclaration.PROP.TEXTOVERFLOW:
411
- case StyleDeclaration.PROP.WEBKITTEXTSTROKE:
412
- case StyleDeclaration.PROP.DIRECTION:
413
- return StyleDeclaration.TYPE.FOREGROUND;
414
- case StyleDeclaration.PROP.BORDERIMAGE:
415
- case StyleDeclaration.PROP.BORDERIMAGEWIDTH:
416
- case StyleDeclaration.PROP.BORDERIMAGEOUTSET:
417
- return StyleDeclaration.TYPE.BORDER;
418
- case StyleDeclaration.PROP.ANIMATION:
419
- // case StyleDeclaration.PROP.ANIMATIONNAME:
420
- // case StyleDeclaration.PROP.ANIMATIONDURATION:
421
- // case StyleDeclaration.PROP.ANIMATIONTIMINGFUNCTION:
422
- // case StyleDeclaration.PROP.ANIMATIONDELAY:
423
- return StyleDeclaration.TYPE.ANIMATION;
424
- case StyleDeclaration.PROP.TRANSITION:
425
- return StyleDeclaration.TYPE.TRANSITION;
426
- case StyleDeclaration.PROP.OPACITY:
427
- // TODO
428
- break;
429
- default:
430
- console.warn("Unknown style type for: " + propName);
431
- return null;
432
- }
433
- }
434
-
435
- static JsvConvertPropValue(name, value) {
436
- if(typeof(value) == 'undefined') {
437
- return value;
438
- }
439
-
440
- if(name.startsWith('--')
441
- || value?.startsWith?.('var(--')) {
442
- return value;
443
- }
444
-
445
- switch (name) {
446
- case StyleDeclaration.PROP.TOP:
447
- case StyleDeclaration.PROP.BOTTOM:
448
- case StyleDeclaration.PROP.LEFT:
449
- case StyleDeclaration.PROP.RIGHT:
450
- case StyleDeclaration.PROP.WIDTH:
451
- case StyleDeclaration.PROP.HEIGHT:
452
- case StyleDeclaration.PROP.JSVVIDEOROTATION:
453
- return StyleValue.ConvertInt(value);
454
- case StyleDeclaration.PROP.VISIBILITY:
455
- case StyleDeclaration.PROP.DISPLAY:
456
- return value.toUpperCase(); // 传入Forge需要大写,否则无效
457
- case StyleDeclaration.PROP.OVERFLOW:
458
- return StyleValue.ConvertOverflow(value, StyleDeclaration.Overflow);
459
- case StyleDeclaration.PROP.OBJECTFIT:
460
- return StyleValue.ConvertObjectFit(value, StyleDeclaration.ObjectFit);
461
- case StyleDeclaration.PROP.TRANSFORM:
462
- return value;
463
- case StyleDeclaration.PROP.TRANSFORMORIGIN:
464
- return value;
465
- case StyleDeclaration.PROP.CLIPPATH:
466
- return new Inset(value);
467
- case StyleDeclaration.PROP.BORDERIMAGE:
468
- return new BorderImage(value);
469
- case StyleDeclaration.PROP.BORDERIMAGEWIDTH:
470
- case StyleDeclaration.PROP.BORDERIMAGEOUTSET:
471
- return StyleValue.ConvertRect(value);
472
- case StyleDeclaration.PROP.BORDERRADIUS:
473
- return StyleValue.ConvertCorner(value);
474
- case StyleDeclaration.PROP.ANIMATION:
475
- return StyleValue.ConvertAnimation(value);
476
- case StyleDeclaration.PROP.TRANSITION:
477
- return StyleValue.ConvertTransition(value);
478
- case StyleDeclaration.PROP.OPACITY:
479
- return StyleValue.ConvertFloat(value);
480
- case StyleDeclaration.PROP.BACKGROUNDIMAGE:
481
- return StyleValue.ConvertGradient(value);
482
- default:
483
- return StyleValue.ConvertPx(value);
484
- }
485
- }
486
- }
487
-
488
- StyleDeclaration.Overflow = {
489
- HIDDEN : Symbol('hidden'),
490
- VISIBLE : Symbol('visible'),
491
- };
492
-
493
- StyleDeclaration.ObjectFit = {
494
- FILL : Symbol('fill'),
495
- CONTAIN : Symbol('contain'),
496
- COVER : Symbol('cover'),
497
- NONE : Symbol('none'),
498
- SCALEDOWN : Symbol('scale-down'),
499
- };
500
-
501
- StyleDeclaration.TextClassMajorStyles = new Set([
502
- "textOverflow",
503
- "wordWrap",
504
- "textShadow",
505
- // "fontSize", // fontSize为易变属性
506
- // "lineHeight", // lineHeight同样为易变属性
507
- "color",
508
- "fontFamily",
509
- "fontStyle",
510
- "fontWeight",
511
- "textAlign",
512
- "WebkitTextStroke",
513
- "direction",
514
- ]);
515
-
516
- // type
517
- StyleDeclaration.TYPE = {
518
- LAYOUT_POS : 'layout-position',
519
- LAYOUT_SIZE : 'layout-size',
520
- FOREGROUND : 'foreground',
521
- BACKGROUND : 'background',
522
- BORDER : 'border',
523
- ANIMATION : 'animation',
524
- TRANSFORM : 'transform',
525
- TRANSITION : 'transition',
526
-
527
- CLASS_NAME : 'class-name'
528
- };
529
-
530
- StyleDeclaration.PROP = {
531
- // layout
532
- TOP : 'top',
533
- BOTTOM : 'bottom',
534
- LEFT : 'left',
535
- RIGHT : 'right',
536
- WIDTH : 'width',
537
- HEIGHT : 'height',
538
- VISIBILITY : 'visibility',
539
- DISPLAY : 'display',
540
- BACKFACEVISIBILITY: "backfaceVisibility",
541
- CLIPPATH : 'clipPath',
542
- OVERFLOW : 'overflow',
543
- OBJECTFIT : 'objectFit',
544
- TRANSFORM : 'transform',
545
- TRANSFORMORIGIN : 'transformOrigin',
546
- PERSPECTIVE : "perspective",
547
- PERSPECTIVEORIGIN: "perspectiveOrigin",
548
- ZINDEX : 'zIndex',
549
- TRANSFORMSTYLE: "transformStyle",
550
-
551
- // background
552
- BACKGROUNDCOLOR : 'backgroundColor',
553
- BACKGROUNDIMAGE : 'backgroundImage',
554
- BORDERRADIUS : 'borderRadius',
555
-
556
- // foreground
557
- COLOR : 'color',
558
- LINEHEIGHT : 'lineHeight',
559
- WHITESPACE : 'whiteSpace',
560
- FONTFAMILY : 'fontFamily',
561
- FONTSIZE : 'fontSize',
562
- FONTSTYLE : 'fontStyle',
563
- FONTWEIGHT : 'fontWeight',
564
- TEXTALIGN : 'textAlign',
565
- TEXTSHADOW : 'textShadow',
566
- TEXTOVERFLOW : 'textOverflow',
567
- WEBKITTEXTSTROKE: 'WebkitTextStroke',
568
- DIRECTON : 'direction',
569
-
570
-
571
- // border image: for ninepatch
572
- BORDERIMAGE : 'borderImage',
573
- BORDERIMAGEWIDTH : 'borderImageWidth',
574
- BORDERIMAGEOUTSET: 'borderImageOutset',
575
-
576
- // animation
577
- ANIMATION : "animation",
578
- // ANIMATIONNAME : "animationName",
579
- // ANIMATIONDURATION : "animationDuration",
580
- // ANIMATIONTIMINGFUNCTION : "animationTimingFunction",
581
- // ANIMATIONDELAY : "animationDelay",
582
- // ANIMATIONITERATIONCOUNT : "animationIterationCount",
583
- // ANIMATIONDIRECTION : "animationDirection",
584
-
585
- // transition
586
- TRANSITION : "transition",
587
- // TRANSITIONPROPERTY : "transitionProperty",
588
- // TRANSITIONDURATION : "transitionDuration",
589
- // TRANSITIONTIMINGFUNCTION : "transitionTimingFunction",
590
- // TRANSITIONDELAY : "transitionDelay",
591
-
592
- // other unprocessed
593
- OPACITY : "opacity",
594
-
595
- JSVVIDEOROTATION: "JsvVideoRotation",
596
- };
597
- for(let key in StyleDeclaration.PROP) {
598
- let propName = StyleDeclaration.PROP[key];
599
- Object.defineProperty(StyleDeclaration.prototype, propName, {
600
- set: function (value) {
601
- this.setProperty(propName, value);
602
- },
603
- get: function () {
604
- return this.getPropertyValue(propName);
605
- }
606
- })
607
- }
608
-
609
- export default StyleDeclaration;
@@ -1,51 +0,0 @@
1
- /* eslint-disable no-extra-boolean-cast */
2
- import KeyframeRule from "./KeyframeRule";
3
- //import StyleValue from "./StyleValue";
4
-
5
- export default class StyleSheet {
6
- constructor(content) {
7
- this.jsvCssRules = null;
8
- this.jsvTextContent = content;
9
- }
10
-
11
- get cssRules() {
12
- if (!!this.jsvCssRules) {
13
- return this.jsvCssRules;
14
- }
15
- this.jsvCssRules = new Array();
16
-
17
- const firstKeyFramesIdx = this.jsvTextContent.indexOf(KeyframeRule.KeyFramesFlag);
18
- if(firstKeyFramesIdx < 0) {
19
- return this.jsvCssRules;
20
- }
21
- var contentArray = this.jsvTextContent.split(KeyframeRule.KeyFramesFlag)
22
- for(let idx in contentArray) {
23
- if(idx == 0) { // first item, is empty or invalid keyframes
24
- continue;
25
- }
26
-
27
- this.insertRule(KeyframeRule.KeyFramesFlag + contentArray[idx]);
28
- }
29
-
30
- return this.jsvCssRules;
31
- }
32
-
33
- insertRule(rule, index) {
34
- // console.log("StyleSheet.insertRule() rule=" + rule);
35
- if (typeof index === 'undefined') {
36
- index = this.jsvCssRules.length;
37
- }
38
-
39
- let keyFramesIdx = rule.indexOf(KeyframeRule.KeyFramesFlag);
40
- if(keyFramesIdx < 0) {
41
- throw Error("StyleSheet.insertRule() Rule is not supported except keyframes.");
42
- }
43
- let keyFrames = new KeyframeRule(rule);
44
- this.jsvCssRules.splice(index, 0, keyFrames);
45
- }
46
-
47
- deleteRule(index) {
48
- // console.log("StyleSheet.deleteRule() index=" + index);
49
- this.jsvCssRules.splice(index, 1);
50
- }
51
- }