@quicktvui/web-renderer 1.0.2 → 1.0.4
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 +59 -5
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -7,6 +7,15 @@ export * from './core'
|
|
|
7
7
|
// Components
|
|
8
8
|
export * from './components'
|
|
9
9
|
|
|
10
|
+
// Import functions needed for initWebRenderer
|
|
11
|
+
import {
|
|
12
|
+
setupSceneBuilder,
|
|
13
|
+
applyAllPatches,
|
|
14
|
+
TVFocusManager,
|
|
15
|
+
initAutoProxy,
|
|
16
|
+
initAsyncLocalStorage
|
|
17
|
+
} from './core'
|
|
18
|
+
|
|
10
19
|
// Create component registry for web renderer
|
|
11
20
|
import { HippyWebEngine } from '@hippy/web-renderer'
|
|
12
21
|
import { QtView, createNamedComponent } from './components/QtView'
|
|
@@ -249,6 +258,7 @@ let _webEngine = null
|
|
|
249
258
|
/**
|
|
250
259
|
* Initialize the web renderer (convenience function)
|
|
251
260
|
* Creates and prepares the engine, applies patches
|
|
261
|
+
* This matches the initialization flow in main-web.js
|
|
252
262
|
*/
|
|
253
263
|
export function initWebRenderer() {
|
|
254
264
|
if (_webEngine) {
|
|
@@ -256,11 +266,54 @@ export function initWebRenderer() {
|
|
|
256
266
|
return _webEngine
|
|
257
267
|
}
|
|
258
268
|
|
|
259
|
-
console.log('[Web Renderer]
|
|
269
|
+
console.log('[Web Renderer] === Starting initialization ===')
|
|
270
|
+
|
|
271
|
+
// Step 0: Initialize async localStorage (must be first)
|
|
272
|
+
initAsyncLocalStorage()
|
|
273
|
+
|
|
274
|
+
// Step 0.1: Initialize auto proxy for development
|
|
275
|
+
initAutoProxy()
|
|
276
|
+
|
|
277
|
+
// Step 0.2: Register IJKPlayerComponent for web video
|
|
278
|
+
global.__WEB_COMPONENT__ = global.__WEB_COMPONENTS__ || {}
|
|
279
|
+
global.__WEB_COMPONENTS__['IJKPlayerComponent'] = IJKPlayerComponent
|
|
280
|
+
|
|
281
|
+
// Step 1: Setup SceneBuilder (must be done before main.ts loads)
|
|
282
|
+
setupSceneBuilder()
|
|
283
|
+
|
|
284
|
+
console.log('[Web Renderer] Component mappings:', Object.keys(quicktvuiComponents))
|
|
285
|
+
|
|
286
|
+
// Step 2: Create the web engine
|
|
260
287
|
_webEngine = createWebEngine()
|
|
261
288
|
|
|
262
|
-
// Apply all patches
|
|
263
|
-
|
|
289
|
+
// Step 3: Apply all patches BEFORE starting
|
|
290
|
+
applyAllPatches(_webEngine)
|
|
291
|
+
|
|
292
|
+
// Step 4: Initialize TV Focus Manager
|
|
293
|
+
const focusManager = new TVFocusManager()
|
|
294
|
+
global.__TV_FOCUS_MANAGER__ = focusManager
|
|
295
|
+
console.log('[Web Renderer] TVFocusManager initialized')
|
|
296
|
+
|
|
297
|
+
// Step 5: Inject global CSS to match Android layout behavior
|
|
298
|
+
const styleEl = document.createElement('style')
|
|
299
|
+
styleEl.id = 'web-platform-reset'
|
|
300
|
+
styleEl.textContent = `
|
|
301
|
+
/* Web-Android Layout Compatibility Reset */
|
|
302
|
+
|
|
303
|
+
/* Disable flex cross-axis stretching (Android behavior) */
|
|
304
|
+
/* In Android, children don't auto-fill parent's cross dimension */
|
|
305
|
+
#app,
|
|
306
|
+
#app * {
|
|
307
|
+
align-items: flex-start;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/* Elements with explicit style should override the reset */
|
|
311
|
+
[style*="align-items"] {
|
|
312
|
+
align-items: var(--align-items, center) !important;
|
|
313
|
+
}
|
|
314
|
+
`
|
|
315
|
+
document.head.appendChild(styleEl)
|
|
316
|
+
console.log('[Web Renderer] Global CSS reset injected for Android-compatible layout')
|
|
264
317
|
|
|
265
318
|
console.log('[Web Renderer] Initialization complete')
|
|
266
319
|
return _webEngine
|
|
@@ -272,10 +325,11 @@ export function initWebRenderer() {
|
|
|
272
325
|
*/
|
|
273
326
|
export function startWebRenderer() {
|
|
274
327
|
if (!_webEngine) {
|
|
275
|
-
console.log('[Web Renderer] No engine found,
|
|
276
|
-
|
|
328
|
+
console.log('[Web Renderer] No engine found, initializing...')
|
|
329
|
+
initWebRenderer()
|
|
277
330
|
}
|
|
278
331
|
|
|
332
|
+
console.log('[Web Renderer] Starting engine...')
|
|
279
333
|
startWebEngine(_webEngine)
|
|
280
334
|
return _webEngine
|
|
281
335
|
}
|