@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,450 @@
|
|
|
1
|
+
// ESDeviceInfoModule - Web adapter for device information
|
|
2
|
+
// Provides device info for web browser environment
|
|
3
|
+
|
|
4
|
+
import { resolveAddon, createModuleInit } from '../core/moduleUtils'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get browser and device info from navigator and screen APIs
|
|
8
|
+
*/
|
|
9
|
+
function getBrowserDeviceInfo() {
|
|
10
|
+
const ua = navigator.userAgent
|
|
11
|
+
const platform = navigator.platform
|
|
12
|
+
|
|
13
|
+
// Detect browser
|
|
14
|
+
let browser = 'unknown'
|
|
15
|
+
let browserVersion = ''
|
|
16
|
+
if (/Chrome\/(\d+\.?\d*)/i.test(ua) && !/Edge|Edg/i.test(ua)) {
|
|
17
|
+
browser = 'Chrome'
|
|
18
|
+
browserVersion = RegExp.$1
|
|
19
|
+
} else if (/Safari\/(\d+\.?\d*)/i.test(ua) && !/Chrome/i.test(ua)) {
|
|
20
|
+
browser = 'Safari'
|
|
21
|
+
browserVersion = RegExp.$1
|
|
22
|
+
} else if (/Firefox\/(\d+\.?\d*)/i.test(ua)) {
|
|
23
|
+
browser = 'Firefox'
|
|
24
|
+
browserVersion = RegExp.$1
|
|
25
|
+
} else if (/Edge?\/(\d+\.?\d*)/i.test(ua)) {
|
|
26
|
+
browser = 'Edge'
|
|
27
|
+
browserVersion = RegExp.$1
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Detect OS
|
|
31
|
+
let os = 'unknown'
|
|
32
|
+
let osVersion = ''
|
|
33
|
+
if (/Windows NT (\d+\.?\d*)/i.test(ua)) {
|
|
34
|
+
os = 'Windows'
|
|
35
|
+
osVersion = RegExp.$1
|
|
36
|
+
} else if (/Mac OS X (\d+[._]\d+[._]?\d*)/i.test(ua)) {
|
|
37
|
+
os = 'macOS'
|
|
38
|
+
osVersion = RegExp.$1.replace(/_/g, '.')
|
|
39
|
+
} else if (/Android (\d+\.?\d*\.?\d*)/i.test(ua)) {
|
|
40
|
+
os = 'Android'
|
|
41
|
+
osVersion = RegExp.$1
|
|
42
|
+
} else if (/iOS|iPhone OS|iPad/i.test(ua)) {
|
|
43
|
+
os = 'iOS'
|
|
44
|
+
const match = ua.match(/OS (\d+_\d+_?\d*)/i)
|
|
45
|
+
if (match) osVersion = match[1].replace(/_/g, '.')
|
|
46
|
+
} else if (/Linux/i.test(ua)) {
|
|
47
|
+
os = 'Linux'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Screen info
|
|
51
|
+
const screenWidth = window.screen.width || 0
|
|
52
|
+
const screenHeight = window.screen.height || 0
|
|
53
|
+
const devicePixelRatio = window.devicePixelRatio || 1
|
|
54
|
+
const colorDepth = window.screen.colorDepth || 24
|
|
55
|
+
|
|
56
|
+
// Hardware concurrency (CPU cores)
|
|
57
|
+
const cpuCores = navigator.hardwareConcurrency || 4
|
|
58
|
+
|
|
59
|
+
// Memory (if available - Chrome only)
|
|
60
|
+
const memory = navigator.deviceMemory || 4
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
browser,
|
|
64
|
+
browserVersion,
|
|
65
|
+
os,
|
|
66
|
+
osVersion,
|
|
67
|
+
platform,
|
|
68
|
+
screenWidth,
|
|
69
|
+
screenHeight,
|
|
70
|
+
devicePixelRatio,
|
|
71
|
+
colorDepth,
|
|
72
|
+
cpuCores,
|
|
73
|
+
memory,
|
|
74
|
+
ua,
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get network info from navigator.connection API
|
|
80
|
+
*/
|
|
81
|
+
function getNetworkInfo() {
|
|
82
|
+
const connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection
|
|
83
|
+
if (connection) {
|
|
84
|
+
return {
|
|
85
|
+
effectiveType: connection.effectiveType || 'unknown', // '4g', '3g', '2g', 'slow-2g'
|
|
86
|
+
type: connection.type || 'unknown',
|
|
87
|
+
downlink: connection.downlink || 0, // Mbps
|
|
88
|
+
rtt: connection.rtt || 0, // ms
|
|
89
|
+
saveData: connection.saveData || false,
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
effectiveType: 'unknown',
|
|
94
|
+
type: 'unknown',
|
|
95
|
+
downlink: 0,
|
|
96
|
+
rtt: 0,
|
|
97
|
+
saveData: false,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Cache device info
|
|
102
|
+
let cachedDeviceInfo = null
|
|
103
|
+
|
|
104
|
+
function getDeviceInfo() {
|
|
105
|
+
if (!cachedDeviceInfo) {
|
|
106
|
+
cachedDeviceInfo = getBrowserDeviceInfo()
|
|
107
|
+
}
|
|
108
|
+
return cachedDeviceInfo
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export class ESDeviceInfoModule {
|
|
112
|
+
constructor(context) {
|
|
113
|
+
this.context = context
|
|
114
|
+
this.name = ''
|
|
115
|
+
this.mode = 'normal'
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Device Brand
|
|
119
|
+
async getDeviceBrand(...args) {
|
|
120
|
+
const info = getDeviceInfo()
|
|
121
|
+
return resolveAddon(args, 'Web')
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Device Model
|
|
125
|
+
async getDeviceModel(...args) {
|
|
126
|
+
const info = getDeviceInfo()
|
|
127
|
+
return resolveAddon(args, info.browser || 'Browser')
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// CPU Info
|
|
131
|
+
async getDeviceCpu(...args) {
|
|
132
|
+
const info = getDeviceInfo()
|
|
133
|
+
return resolveAddon(args, `${info.cpuCores} cores`)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// CPU Cores
|
|
137
|
+
async getDeviceCpuCores(...args) {
|
|
138
|
+
const info = getDeviceInfo()
|
|
139
|
+
return resolveAddon(args, info.cpuCores)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Device Memory (GB)
|
|
143
|
+
async getDeviceMemory(...args) {
|
|
144
|
+
const info = getDeviceInfo()
|
|
145
|
+
return resolveAddon(args, info.memory)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Device Storage (not available in web)
|
|
149
|
+
async getDeviceStorage(...args) {
|
|
150
|
+
// Try to estimate storage using Storage API
|
|
151
|
+
if (navigator.storage && navigator.storage.estimate) {
|
|
152
|
+
try {
|
|
153
|
+
const estimate = await navigator.storage.estimate()
|
|
154
|
+
return resolveAddon(args, estimate.quota || 0)
|
|
155
|
+
} catch (e) {
|
|
156
|
+
// Ignore errors
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return resolveAddon(args, 0)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Device Resolution
|
|
163
|
+
async getDeviceResolution(...args) {
|
|
164
|
+
const info = getDeviceInfo()
|
|
165
|
+
return resolveAddon(args, `${info.screenWidth}x${info.screenHeight}`)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 5G Support
|
|
169
|
+
async getDevice5G(...args) {
|
|
170
|
+
const netInfo = getNetworkInfo()
|
|
171
|
+
// Check if connection is 5g (not well supported in browsers)
|
|
172
|
+
return resolveAddon(args, false)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Link Speed
|
|
176
|
+
async getDeviceLinkSpeed(...args) {
|
|
177
|
+
const netInfo = getNetworkInfo()
|
|
178
|
+
return resolveAddon(args, netInfo.downlink)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Device Manufacturer
|
|
182
|
+
async getDeviceManufacture(...args) {
|
|
183
|
+
return resolveAddon(args, 'Web')
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Device Board
|
|
187
|
+
async getDeviceBoard(...args) {
|
|
188
|
+
return resolveAddon(args, 'Web')
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Device Platform
|
|
192
|
+
async getDevicePlatform(...args) {
|
|
193
|
+
const info = getDeviceInfo()
|
|
194
|
+
return resolveAddon(args, info.platform || 'Web')
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Device Hardware
|
|
198
|
+
async getDeviceHard(...args) {
|
|
199
|
+
return resolveAddon(args, 'Web')
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Device Architecture
|
|
203
|
+
async getDeviceArchitecture(...args) {
|
|
204
|
+
// Try to get architecture from ua or platform
|
|
205
|
+
const info = getDeviceInfo()
|
|
206
|
+
if (/arm|aarch64/i.test(info.ua)) return resolveAddon(args, 'arm64')
|
|
207
|
+
if (/x86_64|amd64/i.test(info.ua)) return resolveAddon(args, 'x86_64')
|
|
208
|
+
return resolveAddon(args, 'unknown')
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Clock Speed
|
|
212
|
+
async getDeviceClockSpeed(...args) {
|
|
213
|
+
return resolveAddon(args, 0)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Android Version
|
|
217
|
+
async getDeviceAndroidVersion(...args) {
|
|
218
|
+
const info = getDeviceInfo()
|
|
219
|
+
if (info.os === 'Android') {
|
|
220
|
+
return resolveAddon(args, info.osVersion)
|
|
221
|
+
}
|
|
222
|
+
return resolveAddon(args, '')
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// API Version
|
|
226
|
+
async getDeviceApiVersion(...args) {
|
|
227
|
+
return resolveAddon(args, 0)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Android ID
|
|
231
|
+
async getDeviceAndroidId(...args) {
|
|
232
|
+
// Not available in web
|
|
233
|
+
return resolveAddon(args, '')
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Build ID
|
|
237
|
+
async getDeviceBuildId(...args) {
|
|
238
|
+
return resolveAddon(args, 'web')
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Root Status
|
|
242
|
+
async getDeviceRoot(...args) {
|
|
243
|
+
return resolveAddon(args, false)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Free Storage
|
|
247
|
+
async getDeviceFreeStore(...args) {
|
|
248
|
+
if (navigator.storage && navigator.storage.estimate) {
|
|
249
|
+
try {
|
|
250
|
+
const estimate = await navigator.storage.estimate()
|
|
251
|
+
return resolveAddon(args, (estimate.quota || 0) - (estimate.usage || 0))
|
|
252
|
+
} catch (e) {
|
|
253
|
+
// Ignore errors
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return resolveAddon(args, 0)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Network State
|
|
260
|
+
async getNetworkState(...args) {
|
|
261
|
+
const netInfo = getNetworkInfo()
|
|
262
|
+
return resolveAddon(args, {
|
|
263
|
+
connected: navigator.onLine,
|
|
264
|
+
type: netInfo.effectiveType,
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Network Type
|
|
269
|
+
async getNetworkType(...args) {
|
|
270
|
+
const netInfo = getNetworkInfo()
|
|
271
|
+
return resolveAddon(args, netInfo.effectiveType)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// SSID (not available in web)
|
|
275
|
+
async getSSID(...args) {
|
|
276
|
+
return resolveAddon(args, '')
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// MAC Address (not available in web)
|
|
280
|
+
async getMac(...args) {
|
|
281
|
+
return resolveAddon(args, '')
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// IP Address (not directly available in web)
|
|
285
|
+
async getIp(...args) {
|
|
286
|
+
return resolveAddon(args, '')
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// DNS (not available in web)
|
|
290
|
+
async getDeviceDns(...args) {
|
|
291
|
+
return resolveAddon(args, '')
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// WiFi Version
|
|
295
|
+
async getWifiVersion(...args) {
|
|
296
|
+
return resolveAddon(args, '')
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Display Information
|
|
300
|
+
async getDisplayInformation(...args) {
|
|
301
|
+
const info = getDeviceInfo()
|
|
302
|
+
return resolveAddon(args, {
|
|
303
|
+
width: info.screenWidth,
|
|
304
|
+
height: info.screenHeight,
|
|
305
|
+
density: info.devicePixelRatio,
|
|
306
|
+
colorDepth: info.colorDepth,
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// GPU Info (limited info available via WebGL)
|
|
311
|
+
async getGpuInfo(...args) {
|
|
312
|
+
try {
|
|
313
|
+
const canvas = document.createElement('canvas')
|
|
314
|
+
const gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl')
|
|
315
|
+
if (gl) {
|
|
316
|
+
const debugInfo = gl.getExtension('WEBGL_debug_renderer_info')
|
|
317
|
+
if (debugInfo) {
|
|
318
|
+
return resolveAddon(args, {
|
|
319
|
+
vendor: gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL),
|
|
320
|
+
renderer: gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL),
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
} catch (e) {
|
|
325
|
+
// Ignore errors
|
|
326
|
+
}
|
|
327
|
+
return resolveAddon(args, { vendor: 'unknown', renderer: 'unknown' })
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Base Info - comprehensive device info
|
|
331
|
+
async getBaseInfo(...args) {
|
|
332
|
+
const info = getDeviceInfo()
|
|
333
|
+
const netInfo = getNetworkInfo()
|
|
334
|
+
return resolveAddon(args, {
|
|
335
|
+
brand: 'Web',
|
|
336
|
+
model: info.browser,
|
|
337
|
+
os: info.os,
|
|
338
|
+
osVersion: info.osVersion,
|
|
339
|
+
platform: info.platform,
|
|
340
|
+
screenWidth: info.screenWidth,
|
|
341
|
+
screenHeight: info.screenHeight,
|
|
342
|
+
density: info.devicePixelRatio,
|
|
343
|
+
cpuCores: info.cpuCores,
|
|
344
|
+
memory: info.memory,
|
|
345
|
+
networkType: netInfo.effectiveType,
|
|
346
|
+
})
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// System Info
|
|
350
|
+
async getSystemInfo(...args) {
|
|
351
|
+
const info = getDeviceInfo()
|
|
352
|
+
return resolveAddon(args, {
|
|
353
|
+
os: info.os,
|
|
354
|
+
osVersion: info.osVersion,
|
|
355
|
+
browser: info.browser,
|
|
356
|
+
browserVersion: info.browserVersion,
|
|
357
|
+
platform: info.platform,
|
|
358
|
+
language: navigator.language,
|
|
359
|
+
userAgent: info.ua,
|
|
360
|
+
})
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// CPU Info
|
|
364
|
+
async getCpuInfo(...args) {
|
|
365
|
+
const info = getDeviceInfo()
|
|
366
|
+
return resolveAddon(args, {
|
|
367
|
+
cores: info.cpuCores,
|
|
368
|
+
memory: info.memory,
|
|
369
|
+
})
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Android Info
|
|
373
|
+
async getAndroidInfo(...args) {
|
|
374
|
+
return resolveAddon(args, null)
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Store Info
|
|
378
|
+
async getStoreInfo(...args) {
|
|
379
|
+
if (navigator.storage && navigator.storage.estimate) {
|
|
380
|
+
try {
|
|
381
|
+
const estimate = await navigator.storage.estimate()
|
|
382
|
+
return resolveAddon(args, {
|
|
383
|
+
total: estimate.quota || 0,
|
|
384
|
+
used: estimate.usage || 0,
|
|
385
|
+
free: (estimate.quota || 0) - (estimate.usage || 0),
|
|
386
|
+
})
|
|
387
|
+
} catch (e) {
|
|
388
|
+
// Ignore errors
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return resolveAddon(args, { total: 0, used: 0, free: 0 })
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Net Info
|
|
395
|
+
async getNetInfo(...args) {
|
|
396
|
+
const netInfo = getNetworkInfo()
|
|
397
|
+
return resolveAddon(args, {
|
|
398
|
+
online: navigator.onLine,
|
|
399
|
+
type: netInfo.effectiveType,
|
|
400
|
+
downlink: netInfo.downlink,
|
|
401
|
+
rtt: netInfo.rtt,
|
|
402
|
+
saveData: netInfo.saveData,
|
|
403
|
+
})
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Out IP (not available directly)
|
|
407
|
+
async getOutIp(...args) {
|
|
408
|
+
return resolveAddon(args, '')
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// USB Info
|
|
412
|
+
async getUsbInfo(...args) {
|
|
413
|
+
return resolveAddon(args, [])
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// Bluetooth Info
|
|
417
|
+
async getBluetoothInfo(...args) {
|
|
418
|
+
// Check if Web Bluetooth is available
|
|
419
|
+
const hasBluetooth = 'bluetooth' in navigator
|
|
420
|
+
return resolveAddon(args, {
|
|
421
|
+
available: hasBluetooth,
|
|
422
|
+
devices: [],
|
|
423
|
+
})
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// Permission Handler
|
|
427
|
+
async permissionHandler(...args) {
|
|
428
|
+
return resolveAddon(args, { granted: true })
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Network Protocol
|
|
432
|
+
async getNetworkProtocol(...args) {
|
|
433
|
+
return resolveAddon(args, location.protocol === 'https:' ? 'https' : 'http')
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Network Speed
|
|
437
|
+
async getNetworkSpeed(...args) {
|
|
438
|
+
const netInfo = getNetworkInfo()
|
|
439
|
+
return resolveAddon(args, netInfo.downlink)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
async init(...args) {
|
|
443
|
+
return createModuleInit(args)
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
destroy() {}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// Export singleton instance
|
|
450
|
+
export const esDeviceInfoModuleInstance = new ESDeviceInfoModule()
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// ESGroupDataModule - Web adapter for shared data storage
|
|
2
|
+
// Provides cross-package data sharing using localStorage
|
|
3
|
+
|
|
4
|
+
import { resolveAddon, createModuleInit } from '../core/moduleUtils'
|
|
5
|
+
|
|
6
|
+
// Storage key prefix for group data
|
|
7
|
+
const GROUP_DATA_PREFIX = 'es_group_data_'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Build storage key for a package
|
|
11
|
+
*/
|
|
12
|
+
function buildStorageKey(params, key) {
|
|
13
|
+
if (!params || !params.packageName) {
|
|
14
|
+
return null
|
|
15
|
+
}
|
|
16
|
+
return `${GROUP_DATA_PREFIX}${params.packageName}_${key}`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get data from localStorage
|
|
21
|
+
*/
|
|
22
|
+
function getFromStorage(params, key, defValue) {
|
|
23
|
+
const storageKey = buildStorageKey(params, key)
|
|
24
|
+
if (!storageKey) {
|
|
25
|
+
return Promise.resolve(defValue)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const stored = localStorage.getItem(storageKey)
|
|
30
|
+
if (stored && stored !== '') {
|
|
31
|
+
const shareData = JSON.parse(stored)
|
|
32
|
+
if (shareData && shareData.data !== undefined) {
|
|
33
|
+
return Promise.resolve(shareData.data)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.warn('[ESGroupDataModule] Error reading from storage:', e)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return Promise.resolve(defValue)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Put data to localStorage
|
|
45
|
+
*/
|
|
46
|
+
function putToStorage(params, key, value, mode, type) {
|
|
47
|
+
const storageKey = buildStorageKey(params, key)
|
|
48
|
+
if (!storageKey) {
|
|
49
|
+
return Promise.resolve(false)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const shareData = {
|
|
54
|
+
mode: mode || 0,
|
|
55
|
+
type: type,
|
|
56
|
+
secretKey: params?.secretKey || '',
|
|
57
|
+
data: value,
|
|
58
|
+
}
|
|
59
|
+
localStorage.setItem(storageKey, JSON.stringify(shareData))
|
|
60
|
+
return Promise.resolve(true)
|
|
61
|
+
} catch (e) {
|
|
62
|
+
console.warn('[ESGroupDataModule] Error writing to storage:', e)
|
|
63
|
+
return Promise.resolve(false)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ESSharedDataType constants
|
|
68
|
+
const ESSharedDataType = {
|
|
69
|
+
ES_SHARED_DATA_TYPE_INT: 0,
|
|
70
|
+
ES_SHARED_DATA_TYPE_LONG: 1,
|
|
71
|
+
ES_SHARED_DATA_TYPE_FLOAT: 2,
|
|
72
|
+
ES_SHARED_DATA_TYPE_STRING: 3,
|
|
73
|
+
ES_SHARED_DATA_TYPE_BOOLEAN: 4,
|
|
74
|
+
ES_SHARED_DATA_TYPE_MAP: 5,
|
|
75
|
+
ES_SHARED_DATA_TYPE_ARRAY: 6,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class ESGroupDataModule {
|
|
79
|
+
constructor(context) {
|
|
80
|
+
this.context = context
|
|
81
|
+
this.name = ''
|
|
82
|
+
this.mode = 'normal'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Boolean
|
|
86
|
+
async getBoolean(params, key, defValue, ...args) {
|
|
87
|
+
const result = await getFromStorage(params, key, defValue)
|
|
88
|
+
return resolveAddon(args, result)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async putBoolean(params, key, value, mode, ...args) {
|
|
92
|
+
const result = await putToStorage(
|
|
93
|
+
params,
|
|
94
|
+
key,
|
|
95
|
+
value,
|
|
96
|
+
mode,
|
|
97
|
+
ESSharedDataType.ES_SHARED_DATA_TYPE_BOOLEAN
|
|
98
|
+
)
|
|
99
|
+
return resolveAddon(args, result)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Int
|
|
103
|
+
async getInt(params, key, defValue, ...args) {
|
|
104
|
+
const result = await getFromStorage(params, key, defValue)
|
|
105
|
+
return resolveAddon(args, result)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async putInt(params, key, value, mode, ...args) {
|
|
109
|
+
const result = await putToStorage(
|
|
110
|
+
params,
|
|
111
|
+
key,
|
|
112
|
+
value,
|
|
113
|
+
mode,
|
|
114
|
+
ESSharedDataType.ES_SHARED_DATA_TYPE_INT
|
|
115
|
+
)
|
|
116
|
+
return resolveAddon(args, result)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Long
|
|
120
|
+
async getLong(params, key, defValue, ...args) {
|
|
121
|
+
const result = await getFromStorage(params, key, defValue)
|
|
122
|
+
return resolveAddon(args, result)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async putLong(params, key, value, mode, ...args) {
|
|
126
|
+
const result = await putToStorage(
|
|
127
|
+
params,
|
|
128
|
+
key,
|
|
129
|
+
value,
|
|
130
|
+
mode,
|
|
131
|
+
ESSharedDataType.ES_SHARED_DATA_TYPE_LONG
|
|
132
|
+
)
|
|
133
|
+
return resolveAddon(args, result)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// String
|
|
137
|
+
async getString(params, key, defValue, ...args) {
|
|
138
|
+
const result = await getFromStorage(params, key, defValue)
|
|
139
|
+
return resolveAddon(args, result)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async putString(params, key, value, mode, ...args) {
|
|
143
|
+
const result = await putToStorage(
|
|
144
|
+
params,
|
|
145
|
+
key,
|
|
146
|
+
value,
|
|
147
|
+
mode,
|
|
148
|
+
ESSharedDataType.ES_SHARED_DATA_TYPE_STRING
|
|
149
|
+
)
|
|
150
|
+
return resolveAddon(args, result)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Array
|
|
154
|
+
async getArray(params, key, defValue, ...args) {
|
|
155
|
+
const result = await getFromStorage(params, key, defValue)
|
|
156
|
+
return resolveAddon(args, result)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async putArray(params, key, value, mode, ...args) {
|
|
160
|
+
const result = await putToStorage(
|
|
161
|
+
params,
|
|
162
|
+
key,
|
|
163
|
+
value,
|
|
164
|
+
mode,
|
|
165
|
+
ESSharedDataType.ES_SHARED_DATA_TYPE_ARRAY
|
|
166
|
+
)
|
|
167
|
+
return resolveAddon(args, result)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Map/Object
|
|
171
|
+
async getMap(params, key, defValue, ...args) {
|
|
172
|
+
const result = await getFromStorage(params, key, defValue)
|
|
173
|
+
return resolveAddon(args, result)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
async putMap(params, key, value, mode, ...args) {
|
|
177
|
+
const result = await putToStorage(
|
|
178
|
+
params,
|
|
179
|
+
key,
|
|
180
|
+
value,
|
|
181
|
+
mode,
|
|
182
|
+
ESSharedDataType.ES_SHARED_DATA_TYPE_MAP
|
|
183
|
+
)
|
|
184
|
+
return resolveAddon(args, result)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async init(...args) {
|
|
188
|
+
return createModuleInit(args)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
destroy() {}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Export singleton instance
|
|
195
|
+
export const esGroupDataModuleInstance = new ESGroupDataModule()
|