@quicktvui/web-renderer 1.0.1 → 1.0.3
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 +1 -1
- package/src/index.js +96 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -243,4 +243,100 @@ export function startWebEngine(engine) {
|
|
|
243
243
|
console.log('[Web Renderer] Engine started')
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
// Global engine instance for convenience functions
|
|
247
|
+
let _webEngine = null
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Initialize the web renderer (convenience function)
|
|
251
|
+
* Creates and prepares the engine, applies patches
|
|
252
|
+
* This matches the initialization flow in main-web.js
|
|
253
|
+
*/
|
|
254
|
+
export function initWebRenderer() {
|
|
255
|
+
if (_webEngine) {
|
|
256
|
+
console.log('[Web Renderer] Engine already initialized')
|
|
257
|
+
return _webEngine
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
console.log('[Web Renderer] === Starting initialization ===')
|
|
261
|
+
|
|
262
|
+
// Step 0: Initialize async localStorage (must be first)
|
|
263
|
+
initAsyncLocalStorage()
|
|
264
|
+
|
|
265
|
+
// Step 0.1: Initialize auto proxy for development
|
|
266
|
+
initAutoProxy()
|
|
267
|
+
|
|
268
|
+
// Step 0.2: Register IJKPlayerComponent for web video
|
|
269
|
+
global.__WEB_COMPONENT__ = global.__WEB_COMPONENTS__ || {}
|
|
270
|
+
global.__WEB_COMPONENTS__['IJKPlayerComponent'] = IJKPlayerComponent
|
|
271
|
+
|
|
272
|
+
// Step 1: Setup SceneBuilder (must be done before main.ts loads)
|
|
273
|
+
setupSceneBuilder()
|
|
274
|
+
|
|
275
|
+
console.log('[Web Renderer] Component mappings:', Object.keys(quicktvuiComponents))
|
|
276
|
+
|
|
277
|
+
// Step 2: Create the web engine
|
|
278
|
+
_webEngine = createWebEngine()
|
|
279
|
+
|
|
280
|
+
// Step 3: Apply all patches BEFORE starting
|
|
281
|
+
applyAllPatches(_webEngine)
|
|
282
|
+
|
|
283
|
+
// Step 4: Initialize TV Focus Manager
|
|
284
|
+
const focusManager = new TVFocusManager()
|
|
285
|
+
global.__TV_FOCUS_MANAGER__ = focusManager
|
|
286
|
+
console.log('[Web Renderer] TVFocusManager initialized')
|
|
287
|
+
|
|
288
|
+
// Step 5: Inject global CSS to match Android layout behavior
|
|
289
|
+
const styleEl = document.createElement('style')
|
|
290
|
+
styleEl.id = 'web-platform-reset'
|
|
291
|
+
styleEl.textContent = `
|
|
292
|
+
/* Web-Android Layout Compatibility Reset */
|
|
293
|
+
|
|
294
|
+
/* Disable flex cross-axis stretching (Android behavior) */
|
|
295
|
+
/* In Android, children don't auto-fill parent's cross dimension */
|
|
296
|
+
#app,
|
|
297
|
+
#app * {
|
|
298
|
+
align-items: flex-start;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* Elements with explicit style should override the reset */
|
|
302
|
+
[style*="align-items"] {
|
|
303
|
+
align-items: var(--align-items, center) !important;
|
|
304
|
+
}
|
|
305
|
+
`
|
|
306
|
+
document.head.appendChild(styleEl)
|
|
307
|
+
console.log('[Web Renderer] Global CSS reset injected for Android-compatible layout')
|
|
308
|
+
|
|
309
|
+
console.log('[Web Renderer] Initialization complete')
|
|
310
|
+
return _webEngine
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Start the web renderer (convenience function)
|
|
315
|
+
* Starts the previously initialized engine
|
|
316
|
+
*/
|
|
317
|
+
export function startWebRenderer() {
|
|
318
|
+
if (!_webEngine) {
|
|
319
|
+
console.log('[Web Renderer] No engine found, initializing...')
|
|
320
|
+
initWebRenderer()
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
console.log('[Web Renderer] Starting engine...')
|
|
324
|
+
startWebEngine(_webEngine)
|
|
325
|
+
return _webEngine
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Get the current web engine instance
|
|
330
|
+
*/
|
|
331
|
+
export function getWebEngine() {
|
|
332
|
+
return _webEngine
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Set the web engine instance
|
|
337
|
+
*/
|
|
338
|
+
export function setWebEngine(engine) {
|
|
339
|
+
_webEngine = engine
|
|
340
|
+
}
|
|
341
|
+
|
|
246
342
|
export { APP_NAME }
|