@quicktvui/web-renderer 1.0.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/package.json +24 -0
- package/src/adapters/es3-video-player.js +828 -0
- package/src/components/Modal.js +119 -0
- package/src/components/QtAnimationView.js +678 -0
- package/src/components/QtBaseComponent.js +165 -0
- package/src/components/QtFastListView.js +1920 -0
- package/src/components/QtFlexView.js +799 -0
- package/src/components/QtImage.js +203 -0
- package/src/components/QtItemFrame.js +239 -0
- package/src/components/QtItemStoreView.js +93 -0
- package/src/components/QtItemView.js +125 -0
- package/src/components/QtListView.js +331 -0
- package/src/components/QtLoadingView.js +55 -0
- package/src/components/QtPageRootView.js +19 -0
- package/src/components/QtPlayMark.js +168 -0
- package/src/components/QtProgressBar.js +199 -0
- package/src/components/QtQRCode.js +78 -0
- package/src/components/QtReplaceChild.js +149 -0
- package/src/components/QtRippleView.js +166 -0
- package/src/components/QtSeekBar.js +409 -0
- package/src/components/QtText.js +679 -0
- package/src/components/QtTransitionImage.js +170 -0
- package/src/components/QtView.js +706 -0
- package/src/components/QtWebView.js +613 -0
- package/src/components/TabsView.js +420 -0
- package/src/components/ViewPager.js +206 -0
- package/src/components/index.js +24 -0
- package/src/components/plugins/TextV2Component.js +70 -0
- package/src/components/plugins/index.js +7 -0
- package/src/core/SceneBuilder.js +58 -0
- package/src/core/TVFocusManager.js +2014 -0
- package/src/core/asyncLocalStorage.js +175 -0
- package/src/core/autoProxy.js +165 -0
- package/src/core/componentRegistry.js +84 -0
- package/src/core/constants.js +6 -0
- package/src/core/index.js +8 -0
- package/src/core/moduleUtils.js +36 -0
- package/src/core/patches.js +958 -0
- package/src/core/templateBinding.js +666 -0
- package/src/index.js +246 -0
- package/src/modules/AndroidDevelopModule.js +101 -0
- package/src/modules/AndroidDeviceModule.js +341 -0
- package/src/modules/AndroidNetworkModule.js +178 -0
- package/src/modules/AndroidSharedPreferencesModule.js +100 -0
- package/src/modules/ESDeviceInfoModule.js +450 -0
- package/src/modules/ESGroupDataModule.js +195 -0
- package/src/modules/ESIJKAudioPlayerModule.js +477 -0
- package/src/modules/ESLocalStorageModule.js +100 -0
- package/src/modules/ESLogModule.js +65 -0
- package/src/modules/ESModule.js +106 -0
- package/src/modules/ESNetworkSpeedModule.js +117 -0
- package/src/modules/ESToastModule.js +172 -0
- package/src/modules/EsNativeModule.js +117 -0
- package/src/modules/FastListModule.js +101 -0
- package/src/modules/FocusModule.js +145 -0
- package/src/modules/RuntimeDeviceModule.js +176 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QtBaseComponent - Base class for all QuickTV UI components
|
|
3
|
+
* Provides common property handling (visible, visibility, etc.)
|
|
4
|
+
*/
|
|
5
|
+
import { HippyWebView } from '@hippy/web-renderer'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Visibility enum values
|
|
9
|
+
* @typedef {'visible' | 'invisible' | 'gone'} QTVisibility
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export class QtBaseComponent extends HippyWebView {
|
|
13
|
+
constructor(context, id, pId) {
|
|
14
|
+
super(context, id, pId)
|
|
15
|
+
// Store original display value for visibility toggle
|
|
16
|
+
this._originalDisplay = undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Override updateProperty to handle common properties first
|
|
21
|
+
* Subclasses should call super.updateProperty(key, value) for unhandled properties
|
|
22
|
+
*/
|
|
23
|
+
updateProperty(key, value) {
|
|
24
|
+
if (key === 'type' && this.dom) {
|
|
25
|
+
if (value !== null && value !== undefined && value !== '') {
|
|
26
|
+
const typeValue = String(value)
|
|
27
|
+
this.dom.setAttribute('type', typeValue)
|
|
28
|
+
this.dom.setAttribute('data-template-type', typeValue)
|
|
29
|
+
} else {
|
|
30
|
+
this.dom.removeAttribute('type')
|
|
31
|
+
this.dom.removeAttribute('data-template-type')
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (this._handleCommonProperty(key, value)) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
super.updateProperty(key, value)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Handle common properties
|
|
42
|
+
* @param {string} key - Property name
|
|
43
|
+
* @param {*} value - Property value
|
|
44
|
+
* @returns {boolean} - True if handled
|
|
45
|
+
*/
|
|
46
|
+
_handleCommonProperty(key, value) {
|
|
47
|
+
switch (key) {
|
|
48
|
+
case 'visible':
|
|
49
|
+
this._setVisible(value)
|
|
50
|
+
return true
|
|
51
|
+
|
|
52
|
+
case 'visibility':
|
|
53
|
+
this._setVisibility(value)
|
|
54
|
+
return true
|
|
55
|
+
|
|
56
|
+
case 'autofocus':
|
|
57
|
+
// 将 autofocus 属性设置到 DOM 元素上,供 TVFocusManager 识别
|
|
58
|
+
if (value === true || value === 'true' || value === 1 || value === '1') {
|
|
59
|
+
this.dom.setAttribute('autofocus', 'true')
|
|
60
|
+
} else {
|
|
61
|
+
this.dom.removeAttribute('autofocus')
|
|
62
|
+
}
|
|
63
|
+
return true
|
|
64
|
+
|
|
65
|
+
default:
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Set component visibility via boolean
|
|
72
|
+
* @param {boolean} visible - true to show, false to hide
|
|
73
|
+
*/
|
|
74
|
+
_setVisible(visible) {
|
|
75
|
+
if (visible === true) {
|
|
76
|
+
// Restore original display value if saved
|
|
77
|
+
if (this._originalDisplay !== undefined) {
|
|
78
|
+
this.dom.style.display = this._originalDisplay
|
|
79
|
+
} else {
|
|
80
|
+
// In Hippy, all elements default to flex layout
|
|
81
|
+
// Check if the element has flex properties and set display: flex accordingly
|
|
82
|
+
const style = this.dom.style
|
|
83
|
+
const hasFlexProperties =
|
|
84
|
+
style.flexDirection ||
|
|
85
|
+
style.justifyContent ||
|
|
86
|
+
style.alignItems ||
|
|
87
|
+
style.flexWrap ||
|
|
88
|
+
style.flexGrow ||
|
|
89
|
+
style.flexShrink
|
|
90
|
+
|
|
91
|
+
// Default to 'flex' for Hippy compatibility, unless display is already set
|
|
92
|
+
if (!style.display || style.display === 'none') {
|
|
93
|
+
style.display = hasFlexProperties ? 'flex' : 'flex'
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
// Save current display value before hiding
|
|
98
|
+
if (this._originalDisplay === undefined) {
|
|
99
|
+
const currentDisplay = this.dom.style.display
|
|
100
|
+
if (currentDisplay && currentDisplay !== 'none') {
|
|
101
|
+
this._originalDisplay = currentDisplay
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this.dom.style.display = 'none'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Set component visibility via enum
|
|
110
|
+
* @param {QTVisibility} visibility - 'visible' | 'invisible' | 'gone'
|
|
111
|
+
*/
|
|
112
|
+
_setVisibility(visibility) {
|
|
113
|
+
switch (visibility) {
|
|
114
|
+
case 'visible':
|
|
115
|
+
// Restore display and ensure visibility
|
|
116
|
+
if (this._originalDisplay !== undefined) {
|
|
117
|
+
this.dom.style.display = this._originalDisplay
|
|
118
|
+
} else {
|
|
119
|
+
// In Hippy, all elements default to flex layout
|
|
120
|
+
// Default to 'flex' for Hippy compatibility
|
|
121
|
+
const style = this.dom.style
|
|
122
|
+
if (!style.display || style.display === 'none') {
|
|
123
|
+
style.display = 'flex'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
this.dom.style.visibility = ''
|
|
127
|
+
break
|
|
128
|
+
|
|
129
|
+
case 'invisible':
|
|
130
|
+
// Hidden but takes space
|
|
131
|
+
this.dom.style.visibility = 'hidden'
|
|
132
|
+
break
|
|
133
|
+
|
|
134
|
+
case 'gone':
|
|
135
|
+
// Completely hidden, doesn't take space
|
|
136
|
+
if (this._originalDisplay === undefined) {
|
|
137
|
+
const currentDisplay = this.dom.style.display
|
|
138
|
+
if (currentDisplay && currentDisplay !== 'none') {
|
|
139
|
+
this._originalDisplay = currentDisplay
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
this.dom.style.display = 'none'
|
|
143
|
+
break
|
|
144
|
+
|
|
145
|
+
default:
|
|
146
|
+
break
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Public method to set visibility via boolean
|
|
152
|
+
* @param {boolean} visible - true to show, false to hide
|
|
153
|
+
*/
|
|
154
|
+
setVisible(visible) {
|
|
155
|
+
this._setVisible(visible)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Public method to set visibility via enum
|
|
160
|
+
* @param {QTVisibility} visibility - 'visible' | 'invisible' | 'gone'
|
|
161
|
+
*/
|
|
162
|
+
setVisibility(visibility) {
|
|
163
|
+
this._setVisibility(visibility)
|
|
164
|
+
}
|
|
165
|
+
}
|