@shijiu/jsview-vue 0.9.359-alpha.0 → 0.9.422

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 (47) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -1
  2. package/dom/bin/jsview-dom.min.js +1 -1
  3. package/dom/target_core_revision.js +3 -3
  4. package/loader/jsview.config.default.js +1 -1
  5. package/loader/jsview.default.config.js +1 -1
  6. package/loader/loader.js +2 -1
  7. package/package.json +1 -1
  8. package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +1 -1
  9. package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +20 -7
  10. package/samples/Basic/App.vue +37 -29
  11. package/samples/Basic/components/ContentBlock.vue +1 -1
  12. package/samples/Basic/components/FontStyle.css +6 -0
  13. package/samples/Basic/components/div/DivBackground.vue +1 -1
  14. package/samples/Basic/components/div/DivCssScoped.vue +6 -13
  15. package/samples/Basic/components/div/DivCssVar.vue +3 -7
  16. package/samples/Basic/components/div/DivGroup2.vue +7 -2
  17. package/samples/Basic/components/div/DivLayout.vue +3 -3
  18. package/samples/Basic/components/div/DivTransform.vue +27 -0
  19. package/samples/Basic/components/img/ImageGroup.vue +31 -0
  20. package/samples/Basic/components/img/ImgLayout.vue +41 -0
  21. package/samples/Basic/components/panel/Panel1.vue +53 -0
  22. package/samples/Basic/components/panel/Panel2.vue +35 -0
  23. package/samples/Basic/components/panel/TitleBar.vue +29 -0
  24. package/samples/Basic/components/text/TextEmoji.vue +30 -0
  25. package/samples/Basic/components/text/{TextGroup.vue → TextGroup1.vue} +0 -0
  26. package/samples/Basic/components/text/TextGroup2.vue +31 -0
  27. package/utils/JsViewEngineWidget/JsvFocusBlock.vue +13 -0
  28. package/utils/JsViewEngineWidget/MetroWidget/ContentView.vue +63 -0
  29. package/utils/JsViewEngineWidget/MetroWidget/Dispatcher.js +19 -0
  30. package/utils/JsViewEngineWidget/MetroWidget/DivWrapper.vue +51 -0
  31. package/utils/JsViewEngineWidget/MetroWidget/ItemView.vue +220 -0
  32. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +1860 -0
  33. package/utils/JsViewEngineWidget/MetroWidget/RootView.vue +153 -0
  34. package/utils/JsViewEngineWidget/SimpleWidget/SimpleWidget.vue +137 -118
  35. package/utils/JsViewEngineWidget/TemplateParser.js +212 -158
  36. package/utils/JsViewEngineWidget/index.js +3 -2
  37. package/utils/JsViewPlugin/BrowserPluginLoader.js +14 -0
  38. package/utils/JsViewPlugin/JsvPlayer/JsvMedia.js +502 -108
  39. package/utils/JsViewPlugin/JsvPlayer/JsvMediaBrowserInterface.js +101 -0
  40. package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +262 -92
  41. package/utils/JsViewPlugin/JsvPlayer/JsvPlayerBrowser.vue +40 -0
  42. package/utils/JsViewPlugin/JsvPlayer/index.js +27 -0
  43. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +1 -2
  44. package/utils/JsViewVueWidget/JsvMarquee.vue +18 -10
  45. package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +3 -3
  46. package/utils/JsViewVueWidget/JsvNinePatch.vue +28 -10
  47. package/samples/Basic/components/TitleBar.vue +0 -27
@@ -0,0 +1,153 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2021-09-22 14:03:32
4
+ * @LastEditors: ChenChanghua
5
+ * @LastEditTime: 2022-03-25 14:29:31
6
+ * @Description: file content
7
+ -->
8
+ <script>
9
+ import ContentView from "./ContentView.vue";
10
+ import Forge from "../ForgeDefine";
11
+
12
+ export default {
13
+ props: {
14
+ tokenForRefresh: Number,
15
+ dataUpdateToken: Number,
16
+ onItemEdge: Function,
17
+ onLoad: Function,
18
+ register: Function,
19
+ widgetHandler: Object,
20
+ placeHolderSetting: Object,
21
+
22
+ x: Number,
23
+ y: Number,
24
+ width: Number,
25
+ height: Number,
26
+
27
+ loadAll: Boolean,
28
+ enableTouch: Boolean,
29
+ touchListener: Object,
30
+ flingPageWidth: Number,
31
+ flingPageEdge: Number,
32
+ slidePile: Object,
33
+ direction: Number, //Forge.DragSetting的方向是数字类型
34
+ enableItemRenderBreak: Boolean,
35
+ },
36
+ components: {
37
+ ContentView,
38
+ },
39
+ data() {
40
+ return {
41
+ innerX: 0,
42
+ innerY: 0,
43
+ };
44
+ },
45
+ setup() {
46
+ let element = {};
47
+ return {
48
+ element,
49
+ };
50
+ },
51
+ methods: {
52
+ $_rootView_initTouch_() {
53
+ if (this.touchListener && this.$refs.element) {
54
+ let view = this.$refs.element.jsvMaskView;
55
+ let page_width = this.flingPageWidth;
56
+ let page_edge = this.flingPageEdge;
57
+ let slide_pile = this.slidePile;
58
+ var drag_setting = new Forge.DragSetting(
59
+ this.direction,
60
+ 20,
61
+ false,
62
+ slide_pile,
63
+ page_width,
64
+ page_edge
65
+ );
66
+ view.EnableDrag(
67
+ drag_setting,
68
+ this.touchListener,
69
+ "translateMat(dx,dy,0)"
70
+ );
71
+ }
72
+ },
73
+ updatePosition(x, y, anim_info) {
74
+ if (this.$refs.element) {
75
+ let pre_pos = this.$refs.element.jsvMaskView.GetLayoutParams();
76
+ //jsvMaskView的位置更新时会被设置位0,因此不能通过ResetLayoutParams设置位置
77
+ this.innerX = x;
78
+ this.innerY = y;
79
+ if (anim_info) {
80
+ let delta_x = Math.abs(pre_pos.MarginLeft - x);
81
+ let delta_y = Math.abs(pre_pos.MarginTop - y);
82
+ let duration = Math.round(
83
+ delta_x === 0
84
+ ? delta_y / anim_info.speed
85
+ : delta_x / anim_info.speed
86
+ );
87
+ let slide_animation = new Forge.TranslateAnimation(
88
+ pre_pos.MarginLeft - x,
89
+ 0,
90
+ pre_pos.MarginTop - y,
91
+ 0,
92
+ duration,
93
+ anim_info.easing
94
+ );
95
+ slide_animation.SetAnimationListener(
96
+ new Forge.AnimationListener(
97
+ anim_info.onstart,
98
+ anim_info.onend,
99
+ null
100
+ )
101
+ );
102
+ this.$refs.element.jsvMaskView.StartAnimation(slide_animation);
103
+ }
104
+ }
105
+ },
106
+ updateData(data) {
107
+ this.$refs?.contentView?.updateData(data);
108
+ },
109
+ getLocateDiv() {
110
+ return this.$refs.locateDiv;
111
+ },
112
+ },
113
+ created() {
114
+ if (this.register) {
115
+ this.register(this);
116
+ }
117
+ },
118
+ mounted() {
119
+ //TODO 触控的处理有待添加
120
+ // this.$_rootView_initTouch_();
121
+ },
122
+ };
123
+ </script>
124
+
125
+ <template>
126
+ <div :style="{ left: x, top: y }">
127
+ <div
128
+ key="touchcontainer"
129
+ ref="element"
130
+ :style="{ left: innerX, top: innerY, width: width, height: height }"
131
+ >
132
+ <!-- 用于定位的div -->
133
+ <div ref="locateDiv">
134
+ <content-view
135
+ ref="contentView"
136
+ :tokenForRefresh="tokenForRefresh"
137
+ :dataUpdateToken="dataUpdateToken"
138
+ :onItemEdge="onItemEdge"
139
+ :loadAll="loadAll"
140
+ :enableTouch="enableTouch"
141
+ :onLoad="onLoad"
142
+ :widgetHandler="widgetHandler"
143
+ :enableItemRenderBreak="enableItemRenderBreak"
144
+ :placeHolderSetting="placeHolderSetting"
145
+ >
146
+ <template v-slot:renderItem="slotProps">
147
+ <slot name="renderItem" v-bind="slotProps"></slot>
148
+ </template>
149
+ </content-view>
150
+ </div>
151
+ </div>
152
+ </div>
153
+ </template>
@@ -2,7 +2,7 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2021-09-22 16:08:58
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-02-11 15:44:05
5
+ * @LastEditTime: 2022-02-28 18:14:29
6
6
  * @Description: file content
7
7
  -->
8
8
 
@@ -149,9 +149,9 @@ import {
149
149
  EdgeDirection,
150
150
  VERTICAL,
151
151
  HORIZONTAL,
152
- getPositionRelativeToView,
153
152
  SlideSetting,
154
153
  SeamlessSlide,
154
+ getPositionRelativeToView,
155
155
  } from "../WidgetCommon";
156
156
 
157
157
  let emptyFunc = () => {};
@@ -326,7 +326,6 @@ const SimpleWidget = {
326
326
  },
327
327
  data: {
328
328
  type: Array,
329
- required: true,
330
329
  },
331
330
  left: {
332
331
  type: Number,
@@ -360,7 +359,10 @@ const SimpleWidget = {
360
359
  enableItemRenderBreak: {
361
360
  type: Boolean,
362
361
  default: false,
363
- }
362
+ },
363
+ provideData: {
364
+ type: Function,
365
+ },
364
366
  },
365
367
  watch: {
366
368
  data: function (value, oldValue) {
@@ -372,6 +374,7 @@ const SimpleWidget = {
372
374
  token: ref(0),
373
375
  templateParser: null,
374
376
  innerData: [],
377
+ dataList: [],
375
378
 
376
379
  enterFocusId: -1,
377
380
  enterFocusRect: null,
@@ -593,6 +596,126 @@ const SimpleWidget = {
593
596
  }
594
597
  },
595
598
 
599
+ freshData(force_update) {
600
+ //由于data不支持reactive, 因此数据的更新只通过provideData
601
+ if (!this.provideData) {
602
+ console.error("freshData: provideData is null.");
603
+ return;
604
+ }
605
+ let new_list = this.provideData();
606
+ let new_index = 0;
607
+ let template_list = this.templateParser.GetTemplate().List;
608
+ if (!force_update) {
609
+ for (new_index = 0; new_index < new_list.length; ++new_index) {
610
+ let already_add = false;
611
+ for (let j = 0; j < template_list.length; ++j) {
612
+ if (new_list[new_index] === template_list[j].data) {
613
+ already_add = true;
614
+ break;
615
+ }
616
+ }
617
+ if (!already_add) {
618
+ break;
619
+ }
620
+ }
621
+ }
622
+ let need_update_content = false;
623
+ if (new_index === template_list.length) {
624
+ //原始数据都在
625
+ if (new_index !== new_list.length) {
626
+ //增加数据
627
+ need_update_content = true;
628
+ _AddTemplateItem(
629
+ new_list,
630
+ this.measures,
631
+ this.templateParser,
632
+ new_index
633
+ );
634
+ } else {
635
+ //数据没变
636
+ }
637
+ } else {
638
+ //数据更改
639
+ need_update_content = true;
640
+ let template_parser = _getTemplateParser(
641
+ this.width,
642
+ this.height,
643
+ this.direction,
644
+ this.padding,
645
+ this.supportHistoryPath,
646
+ this.layoutType
647
+ );
648
+ _AddTemplateItem(new_list, this.measures, template_parser, 0);
649
+ this.templateParser = template_parser;
650
+ }
651
+ if (need_update_content) {
652
+ let template_list = this.templateParser.GetTemplate().List;
653
+ let last_item = template_list[template_list.length - 1];
654
+ this.touchListener = this._getTouchListener();
655
+ this.innerPadding = _getPadding(this.padding);
656
+ this.touchContainerW =
657
+ this.direction === VERTICAL
658
+ ? this.width
659
+ : last_item.xPos + last_item.width;
660
+ this.touchContainerH =
661
+ this.direction === VERTICAL
662
+ ? last_item.yPos + last_item.height
663
+ : this.height;
664
+ this.slidePile = new Forge.RectArea(
665
+ 0,
666
+ 0,
667
+ this.width - this.innerPadding.left - this.innerPadding.right,
668
+ this.height - this.innerPadding.top - this.innerPadding.bottom
669
+ );
670
+ this.dragDirection =
671
+ this.direction === VERTICAL
672
+ ? Forge.DragSetting.DIRECTION_VERTICAL
673
+ : Forge.DragSetting.DIRECTION_HORIZONTAL;
674
+ this.innerData = template_list.map((item, index) => {
675
+ return {
676
+ data: item,
677
+ index: index,
678
+ controller: reactive({
679
+ visible: false,
680
+ zIndex: 0,
681
+ }),
682
+ mounted: false,
683
+ itemRef: null,
684
+ //之前的update时itemView不一定会重新create,因此注册的函数可以重复使用。若create了则会覆盖。
685
+ itemHandler: this.innerData[index]
686
+ ? { ...this.innerData[index].itemHandler }
687
+ : {},
688
+ itemConfig: this.itemConfig?.(item.data),
689
+ };
690
+ });
691
+ this.token++;
692
+ }
693
+ if (this.focusId >= new_list.length) {
694
+ this.focusId = 0;
695
+ this.preFocusId = -1;
696
+ this.visibleRangeSearchBaseItem = 0;
697
+ if (this.visibleStart !== 0) {
698
+ this.visibleStart = 0;
699
+ this._slideTo(0, null);
700
+ }
701
+ }
702
+ //重新获取可视itemlist
703
+ this.visibleItemIndexList = this._getVisibleItemIndexList(
704
+ this.visibleRangeSearchBaseItem,
705
+ this.visibleStart,
706
+ this.visibleStart + this.visibleRange - 1
707
+ );
708
+ if (
709
+ this.isFocus &&
710
+ this.innerData[this.templateParser.FocusIdToIndex(this.focusId)].mounted
711
+ ) {
712
+ this._updateFocusItem();
713
+ this.innerData[
714
+ this.templateParser.FocusIdToIndex(this.focusId)
715
+ ].itemHandler.onFocus?.(null);
716
+ }
717
+ },
718
+
596
719
  _getVisibleItemIndexList(id, start, end) {
597
720
  // 扩展可视范围,避免快速滚动时闪烁
598
721
  let s = start - 100 > 0 ? start - 100 : 0;
@@ -909,6 +1032,8 @@ const SimpleWidget = {
909
1032
  cur_visible_start,
910
1033
  cur_visible_start + this.visibleRangeWithPadding - 1
911
1034
  );
1035
+ } else {
1036
+ // 无滚动, 通知父滚动
912
1037
  }
913
1038
 
914
1039
  let rect;
@@ -1250,7 +1375,7 @@ const SimpleWidget = {
1250
1375
  _updateFocusItem() {
1251
1376
  this._setZIndex(
1252
1377
  this.templateParser.FocusIdToIndex(this.focusId),
1253
- this.data.length
1378
+ this.innerData.length
1254
1379
  );
1255
1380
  },
1256
1381
 
@@ -1377,7 +1502,12 @@ const SimpleWidget = {
1377
1502
  this.supportHistoryPath,
1378
1503
  this.layoutType
1379
1504
  );
1380
- _AddTemplateItem(this.data, this.measures, template_parser, 0);
1505
+ if (this.provideData) {
1506
+ this.dataList = this.provideData();
1507
+ } else if (this.data) {
1508
+ this.dataList = this.data;
1509
+ }
1510
+ _AddTemplateItem(this.dataList, this.measures, template_parser, 0);
1381
1511
  this.templateParser = template_parser;
1382
1512
  let template_list = this.templateParser.GetTemplate().List;
1383
1513
  let last_item = template_list[template_list.length - 1];
@@ -1441,118 +1571,7 @@ const SimpleWidget = {
1441
1571
  this.focusId = init_focus_id;
1442
1572
  this.visibleStart = cur_visible_start;
1443
1573
  },
1444
- updated() {
1445
- let template_list = this.templateParser.GetTemplate().List;
1446
- let new_list = this.data;
1447
- let new_index = 0;
1448
- for (new_index = 0; new_index < new_list.length; ++new_index) {
1449
- let already_add = false;
1450
- for (let j = 0; j < template_list.length; ++j) {
1451
- if (new_list[new_index] === template_list[j].data) {
1452
- already_add = true;
1453
- break;
1454
- }
1455
- }
1456
- if (!already_add) {
1457
- break;
1458
- }
1459
- }
1460
- let need_update_content = false;
1461
- if (new_index === template_list.length) {
1462
- //原始数据都在
1463
- if (new_index !== new_list.length) {
1464
- //增加数据
1465
- need_update_content = true;
1466
- _AddTemplateItem(
1467
- this.data,
1468
- this.measures,
1469
- this.templateParser,
1470
- new_index
1471
- );
1472
- } else {
1473
- //数据没变
1474
- }
1475
- } else {
1476
- //数据更改
1477
- need_update_content = true;
1478
- let template_parser = _getTemplateParser(
1479
- this.width,
1480
- this.height,
1481
- this.direction,
1482
- this.padding,
1483
- this.supportHistoryPath,
1484
- this.layoutType
1485
- );
1486
- _AddTemplateItem(this.data, this.measures, template_parser, 0);
1487
- this.templateParser = template_parser;
1488
- }
1489
- if (need_update_content) {
1490
- let template_list = this.templateParser.GetTemplate().List;
1491
- let last_item = template_list[template_list.length - 1];
1492
- this.touchListener = this._getTouchListener();
1493
- this.innerPadding = _getPadding(this.padding);
1494
- this.touchContainerW =
1495
- this.direction === VERTICAL
1496
- ? this.width
1497
- : last_item.xPos + last_item.width;
1498
- this.touchContainerH =
1499
- this.direction === VERTICAL
1500
- ? last_item.yPos + last_item.height
1501
- : this.height;
1502
- this.slidePile = new Forge.RectArea(
1503
- 0,
1504
- 0,
1505
- this.width - this.innerPadding.left - this.innerPadding.right,
1506
- this.height - this.innerPadding.top - this.innerPadding.bottom
1507
- );
1508
- this.dragDirection =
1509
- this.direction === VERTICAL
1510
- ? Forge.DragSetting.DIRECTION_VERTICAL
1511
- : Forge.DragSetting.DIRECTION_HORIZONTAL;
1512
- this.innerData = template_list.map((item, index) => {
1513
- return {
1514
- data: item,
1515
- index: index,
1516
- controller: reactive({
1517
- visible: false,
1518
- zIndex: 0,
1519
- }),
1520
- mounted: false,
1521
- itemRef: null,
1522
- //之前的update时itemView不一定会重新create,因此注册的函数可以重复使用。若create了则会覆盖。
1523
- itemHandler: this.innerData[index]
1524
- ? { ...this.innerData[index].itemHandler }
1525
- : {},
1526
- itemConfig: this.itemConfig?.(item.data),
1527
- };
1528
- });
1529
- this.token++;
1530
- }
1531
- if (this.focusId >= this.data.length) {
1532
- this.focusId = 0;
1533
- this.preFocusId = -1;
1534
- this.visibleRangeSearchBaseItem = 0;
1535
- if (this.visibleStart !== 0) {
1536
- this.visibleStart = 0;
1537
- this._slideTo(0, null);
1538
- }
1539
- }
1540
- //重新获取可视itemlist
1541
- this.visibleItemIndexList = this._getVisibleItemIndexList(
1542
- this.visibleRangeSearchBaseItem,
1543
- this.visibleStart,
1544
- this.visibleStart + this.visibleRange - 1
1545
- );
1546
- if (
1547
- this.isFocus &&
1548
- this.innerData[this.templateParser.FocusIdToIndex(this.focusId)].mounted
1549
- ) {
1550
- this._updateFocusItem();
1551
- this.innerData[
1552
- this.templateParser.FocusIdToIndex(this.focusId)
1553
- ].itemHandler.onFocus?.(null);
1554
- }
1555
- },
1574
+ updated() {},
1556
1575
  mounted() {
1557
1576
  if (this.visibleStart) {
1558
1577
  this._slideTo(this.visibleStart, null);