@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.
Files changed (56) hide show
  1. package/package.json +24 -0
  2. package/src/adapters/es3-video-player.js +828 -0
  3. package/src/components/Modal.js +119 -0
  4. package/src/components/QtAnimationView.js +678 -0
  5. package/src/components/QtBaseComponent.js +165 -0
  6. package/src/components/QtFastListView.js +1920 -0
  7. package/src/components/QtFlexView.js +799 -0
  8. package/src/components/QtImage.js +203 -0
  9. package/src/components/QtItemFrame.js +239 -0
  10. package/src/components/QtItemStoreView.js +93 -0
  11. package/src/components/QtItemView.js +125 -0
  12. package/src/components/QtListView.js +331 -0
  13. package/src/components/QtLoadingView.js +55 -0
  14. package/src/components/QtPageRootView.js +19 -0
  15. package/src/components/QtPlayMark.js +168 -0
  16. package/src/components/QtProgressBar.js +199 -0
  17. package/src/components/QtQRCode.js +78 -0
  18. package/src/components/QtReplaceChild.js +149 -0
  19. package/src/components/QtRippleView.js +166 -0
  20. package/src/components/QtSeekBar.js +409 -0
  21. package/src/components/QtText.js +679 -0
  22. package/src/components/QtTransitionImage.js +170 -0
  23. package/src/components/QtView.js +706 -0
  24. package/src/components/QtWebView.js +613 -0
  25. package/src/components/TabsView.js +420 -0
  26. package/src/components/ViewPager.js +206 -0
  27. package/src/components/index.js +24 -0
  28. package/src/components/plugins/TextV2Component.js +70 -0
  29. package/src/components/plugins/index.js +7 -0
  30. package/src/core/SceneBuilder.js +58 -0
  31. package/src/core/TVFocusManager.js +2014 -0
  32. package/src/core/asyncLocalStorage.js +175 -0
  33. package/src/core/autoProxy.js +165 -0
  34. package/src/core/componentRegistry.js +84 -0
  35. package/src/core/constants.js +6 -0
  36. package/src/core/index.js +8 -0
  37. package/src/core/moduleUtils.js +36 -0
  38. package/src/core/patches.js +958 -0
  39. package/src/core/templateBinding.js +666 -0
  40. package/src/index.js +246 -0
  41. package/src/modules/AndroidDevelopModule.js +101 -0
  42. package/src/modules/AndroidDeviceModule.js +341 -0
  43. package/src/modules/AndroidNetworkModule.js +178 -0
  44. package/src/modules/AndroidSharedPreferencesModule.js +100 -0
  45. package/src/modules/ESDeviceInfoModule.js +450 -0
  46. package/src/modules/ESGroupDataModule.js +195 -0
  47. package/src/modules/ESIJKAudioPlayerModule.js +477 -0
  48. package/src/modules/ESLocalStorageModule.js +100 -0
  49. package/src/modules/ESLogModule.js +65 -0
  50. package/src/modules/ESModule.js +106 -0
  51. package/src/modules/ESNetworkSpeedModule.js +117 -0
  52. package/src/modules/ESToastModule.js +172 -0
  53. package/src/modules/EsNativeModule.js +117 -0
  54. package/src/modules/FastListModule.js +101 -0
  55. package/src/modules/FocusModule.js +145 -0
  56. package/src/modules/RuntimeDeviceModule.js +176 -0
@@ -0,0 +1,178 @@
1
+ // AndroidNetworkModule - Web adapter for network info
2
+ // Provides network information using Navigator.connection API
3
+
4
+ import { resolveAddon, createModuleInit } from '../core/moduleUtils'
5
+
6
+ // Network type constants (matching ESNetworkInfoType)
7
+ const ESNetworkInfoType = {
8
+ ES_NETWORK_INFO_TYPE_NONE: -1,
9
+ ES_NETWORK_INFO_TYPE_MOBILE: 0,
10
+ ES_NETWORK_INFO_TYPE_WIFI: 1,
11
+ ES_NETWORK_INFO_TYPE_ETHERNET: 9,
12
+ }
13
+
14
+ // Network state constants
15
+ const ESNetworkInfoState = {
16
+ ES_NETWORK_INFO_STATE_UNKNOWN: 0,
17
+ ES_NETWORK_INFO_STATE_DISCONNECTED: 1,
18
+ ES_NETWORK_INFO_STATE_CONNECTING: 2,
19
+ ES_NETWORK_INFO_STATE_CONNECTED: 3,
20
+ ES_NETWORK_INFO_STATE_SUSPENDED: 4,
21
+ }
22
+
23
+ /**
24
+ * Detect network type from Navigator.connection
25
+ * @private
26
+ */
27
+ function detectNetworkType() {
28
+ if (typeof navigator === 'undefined' || !navigator.connection) {
29
+ return ESNetworkInfoType.ES_NETWORK_INFO_TYPE_ETHERNET // Default to ethernet for web
30
+ }
31
+
32
+ const connection = navigator.connection
33
+ const type = connection.type || connection.effectiveType
34
+
35
+ // Map connection types
36
+ if (type === 'wifi') {
37
+ return ESNetworkInfoType.ES_NETWORK_INFO_TYPE_WIFI
38
+ } else if (type === 'cellular' || type === '2g' || type === '3g' || type === '4g') {
39
+ return ESNetworkInfoType.ES_NETWORK_INFO_TYPE_MOBILE
40
+ } else if (type === 'ethernet') {
41
+ return ESNetworkInfoType.ES_NETWORK_INFO_TYPE_ETHERNET
42
+ }
43
+
44
+ // Fallback based on effectiveType
45
+ if (connection.effectiveType) {
46
+ if (['4g', '3g', '2g', 'slow-2g'].includes(connection.effectiveType)) {
47
+ return ESNetworkInfoType.ES_NETWORK_INFO_TYPE_MOBILE
48
+ }
49
+ }
50
+
51
+ return ESNetworkInfoType.ES_NETWORK_INFO_TYPE_ETHERNET
52
+ }
53
+
54
+ /**
55
+ * Check if network is connected
56
+ * @private
57
+ */
58
+ function isOnline() {
59
+ if (typeof navigator === 'undefined') {
60
+ return true // Assume online for SSR
61
+ }
62
+ return navigator.onLine
63
+ }
64
+
65
+ /**
66
+ * Get connection info from Navigator.connection
67
+ * @private
68
+ */
69
+ function getConnectionInfo() {
70
+ if (typeof navigator === 'undefined' || !navigator.connection) {
71
+ return {
72
+ downlink: 10, // Mbps
73
+ effectiveType: '4g',
74
+ rtt: 50, // ms
75
+ saveData: false,
76
+ }
77
+ }
78
+
79
+ const connection = navigator.connection
80
+ return {
81
+ downlink: connection.downlink || 10,
82
+ effectiveType: connection.effectiveType || '4g',
83
+ rtt: connection.rtt || 50,
84
+ saveData: connection.saveData || false,
85
+ }
86
+ }
87
+
88
+ class AndroidNetworkModuleClass {
89
+ constructor(context) {
90
+ this.context = context
91
+ this.name = ''
92
+ this.mode = 'normal'
93
+ }
94
+
95
+ /**
96
+ * Get active network info
97
+ * @returns {Promise<Object>}
98
+ */
99
+ async getActiveNetworkInfo(...args) {
100
+ const isConnected = isOnline()
101
+ const networkType = detectNetworkType()
102
+ const connectionInfo = getConnectionInfo()
103
+
104
+ const result = {
105
+ type: networkType,
106
+ typeName: this._getTypeName(networkType),
107
+ subtype: 0,
108
+ state: isConnected
109
+ ? ESNetworkInfoState.ES_NETWORK_INFO_STATE_CONNECTED
110
+ : ESNetworkInfoState.ES_NETWORK_INFO_STATE_DISCONNECTED,
111
+ extraInfo: '',
112
+ isAvailable: isConnected,
113
+ isConnected: isConnected,
114
+ isConnectedOrConnecting: isConnected,
115
+ isFailover: false,
116
+ isRoaming: false,
117
+ detailedState: isConnected ? 1 : 0,
118
+ describeContents: 0,
119
+ // Additional web-specific info
120
+ downlink: connectionInfo.downlink,
121
+ effectiveType: connectionInfo.effectiveType,
122
+ rtt: connectionInfo.rtt,
123
+ saveData: connectionInfo.saveData,
124
+ }
125
+
126
+ return resolveAddon(args, result)
127
+ }
128
+
129
+ /**
130
+ * Get WiFi info (limited in web browser)
131
+ * @returns {Promise<Object>}
132
+ */
133
+ async getWifiInfo(...args) {
134
+ // Web browsers cannot access WiFi SSID due to security restrictions
135
+ // Only available if connection type is WiFi
136
+ const networkType = detectNetworkType()
137
+ const connectionInfo = getConnectionInfo()
138
+
139
+ const result = {
140
+ ssid: '', // Not available in web browsers
141
+ strength:
142
+ networkType === ESNetworkInfoType.ES_NETWORK_INFO_TYPE_WIFI
143
+ ? Math.round((connectionInfo.downlink / 10) * 100) // Estimate strength from downlink
144
+ : 0,
145
+ }
146
+
147
+ return resolveAddon(args, result)
148
+ }
149
+
150
+ /**
151
+ * Get type name from type constant
152
+ * @private
153
+ */
154
+ _getTypeName(type) {
155
+ switch (type) {
156
+ case ESNetworkInfoType.ES_NETWORK_INFO_TYPE_WIFI:
157
+ return 'WIFI'
158
+ case ESNetworkInfoType.ES_NETWORK_INFO_TYPE_MOBILE:
159
+ return 'MOBILE'
160
+ case ESNetworkInfoType.ES_NETWORK_INFO_TYPE_ETHERNET:
161
+ return 'ETHERNET'
162
+ default:
163
+ return 'UNKNOWN'
164
+ }
165
+ }
166
+
167
+ destroy() {}
168
+
169
+ async init(...args) {
170
+ return createModuleInit(args)
171
+ }
172
+ }
173
+
174
+ // Export class for HippyWebEngine (needs constructor)
175
+ export { AndroidNetworkModuleClass as AndroidNetworkModule }
176
+
177
+ // Also export singleton instance for patches.js
178
+ export const androidNetworkModuleInstance = new AndroidNetworkModuleClass()
@@ -0,0 +1,100 @@
1
+ import { resolveAddon, createModuleInit } from '../core/moduleUtils'
2
+
3
+ function getRawStorage() {
4
+ const g = globalThis
5
+ return (g && g.__localStorage) || (g && g.localStorage) || null
6
+ }
7
+
8
+ async function readStorage(key) {
9
+ const s = getRawStorage()
10
+ if (!s || !s.getItem) return null
11
+ const v = s.getItem(key)
12
+ return v && typeof v.then === 'function' ? await v : v
13
+ }
14
+
15
+ async function writeStorage(key, value) {
16
+ const s = getRawStorage()
17
+ if (!s || !s.setItem) return false
18
+ const r = s.setItem(key, value)
19
+ if (r && typeof r.then === 'function') await r
20
+ return true
21
+ }
22
+
23
+ export class AndroidSharedPreferencesModule {
24
+ constructor(context) {
25
+ this.context = context
26
+ this.name = 'AndroidSharedPreferencesModule'
27
+ this.mode = 'normal'
28
+ this._name = ''
29
+ }
30
+
31
+ _key(key) {
32
+ if (!this._name) return key
33
+ return `${this._name}:${key}`
34
+ }
35
+
36
+ async initSharedPreferences(name, ...args) {
37
+ this._name = String(name ?? '')
38
+ return resolveAddon(args, true)
39
+ }
40
+
41
+ async initESSharedPreferences(name, ...args) {
42
+ this._name = String(name ?? '')
43
+ return resolveAddon(args, true)
44
+ }
45
+
46
+ async getBoolean(key, defValue, ...args) {
47
+ const v = await readStorage(this._key(String(key)))
48
+ if (v === null || v === undefined) return resolveAddon(args, !!defValue)
49
+ if (v === 'true') return resolveAddon(args, true)
50
+ if (v === 'false') return resolveAddon(args, false)
51
+ if (v === '1') return resolveAddon(args, true)
52
+ if (v === '0') return resolveAddon(args, false)
53
+ return resolveAddon(args, !!defValue)
54
+ }
55
+
56
+ async putBoolean(key, value, ...args) {
57
+ const ok = await writeStorage(this._key(String(key)), value ? 'true' : 'false')
58
+ return resolveAddon(args, ok)
59
+ }
60
+
61
+ async getInt(key, defValue, ...args) {
62
+ const v = await readStorage(this._key(String(key)))
63
+ if (v === null || v === undefined || v === '') return resolveAddon(args, Number(defValue) || 0)
64
+ const n = Number.parseInt(String(v), 10)
65
+ return resolveAddon(args, Number.isFinite(n) ? n : Number(defValue) || 0)
66
+ }
67
+
68
+ async putInt(key, value, ...args) {
69
+ const ok = await writeStorage(this._key(String(key)), String(Number(value) | 0))
70
+ return resolveAddon(args, ok)
71
+ }
72
+
73
+ async getLong(key, defValue, ...args) {
74
+ const v = await readStorage(this._key(String(key)))
75
+ if (v === null || v === undefined || v === '') return resolveAddon(args, Number(defValue) || 0)
76
+ const n = Number.parseInt(String(v), 10)
77
+ return resolveAddon(args, Number.isFinite(n) ? n : Number(defValue) || 0)
78
+ }
79
+
80
+ async putLong(key, value, ...args) {
81
+ const ok = await writeStorage(this._key(String(key)), String(Math.trunc(Number(value))))
82
+ return resolveAddon(args, ok)
83
+ }
84
+
85
+ async getString(key, defValue, ...args) {
86
+ const v = await readStorage(this._key(String(key)))
87
+ return resolveAddon(args, v === null || v === undefined ? String(defValue ?? '') : String(v))
88
+ }
89
+
90
+ async putString(key, value, ...args) {
91
+ const ok = await writeStorage(this._key(String(key)), String(value ?? ''))
92
+ return resolveAddon(args, ok)
93
+ }
94
+
95
+ async init(...args) {
96
+ return createModuleInit(args)
97
+ }
98
+
99
+ destroy() {}
100
+ }