@quicktvui/web-cli 1.0.0-beta.11 → 1.0.0-beta.13

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.
@@ -1,12 +1,9 @@
1
- // @quicktvui/web-cli - web entry (package)
2
- // 此文件由 CLI 自动加载,使用 @quicktvui/web-renderer
3
- // 主入口路径通过 webpack 多入口配置自动加载,无需在此处 import
4
- //
5
- // 初始化流程参考 main-web.js
1
+ // @quicktvui/web-cli - web entry
2
+ // 通过 @quicktvui/web-renderer 导入所有依赖
3
+ // 动态加载主入口,确保初始化顺序正确
6
4
 
7
- console.log('[Web Renderer] === Starting initialization (package) ===')
5
+ console.log('[Web Renderer] === Starting initialization ===')
8
6
 
9
- // 直接从 @quicktvui/web-renderer 导入所有需要的函数
10
7
  import {
11
8
  initAsyncLocalStorage,
12
9
  initAutoProxy,
@@ -19,57 +16,48 @@ import {
19
16
  IJKPlayerComponent,
20
17
  } from '@quicktvui/web-renderer'
21
18
 
22
- // Step 0: Initialize async localStorage (must be first, before any code uses localStorage)
19
+ // 初始化 async localStorage
23
20
  initAsyncLocalStorage()
24
21
 
25
- // Step 0.1: Initialize auto proxy for development
22
+ // 初始化自动代理
26
23
  initAutoProxy()
27
24
 
28
- // Step 0.2: Register IJKPlayerComponent for web video
25
+ // 注册 IJKPlayerComponent
29
26
  global.__WEB_COMPONENTS__ = global.__WEB_COMPONENTS__ || {}
30
27
  global.__WEB_COMPONENTS__['IJKPlayerComponent'] = IJKPlayerComponent
31
28
 
32
- // Step 1: Setup SceneBuilder (must be done before main.ts loads)
29
+ // 设置 SceneBuilder
33
30
  setupSceneBuilder()
34
31
 
35
- // Step 2: Create the web engine
32
+ // 创建 Web 引擎
36
33
  const engine = createWebEngine()
37
34
 
38
- // Step 3: Apply all patches BEFORE starting
35
+ // 应用所有补丁
39
36
  applyAllPatches(engine)
40
37
 
41
- // Step 4: Initialize TV Focus Manager
42
- const focusManager = new TVFocusManager()
43
- global.__TV_FOCUS_MANAGER__ = focusManager
38
+ // 初始化 TV 焦点管理器
39
+ global.__TV_FOCUS_MANAGER__ = new TVFocusManager()
44
40
  console.log('[Web Renderer] TVFocusManager initialized')
45
41
 
46
- // Step 5: Inject global CSS to match Android layout behavior
42
+ // 注入全局 CSS
47
43
  const styleEl = document.createElement('style')
48
44
  styleEl.id = 'web-platform-reset'
49
45
  styleEl.textContent = `
50
- /* Web-Android Layout Compatibility Reset */
51
-
52
- /* Disable flex cross-axis stretching (Android behavior) */
53
- /* In Android, children don't auto-fill parent's cross dimension */
54
- #app,
55
- #app * {
56
- align-items: flex-start;
57
- }
58
-
59
- /* Elements with explicit style should override the reset */
60
- [style*="align-items"] {
61
- align-items: var(--align-items, center) !important;
62
- }
46
+ #app, #app * { align-items: flex-start; }
47
+ [style*="align-items"] { align-items: var(--align-items, center) !important; }
63
48
  `
64
49
  document.head.appendChild(styleEl)
65
- console.log('[Web Renderer] Global CSS reset injected for Android-compatible layout')
66
-
67
- // 注意:主入口文件已通过 webpack 多入口配置自动加载,无需在此处 import
68
-
69
- // Step 6: Start the engine
70
- console.log('[Web Renderer] Starting engine...')
71
- startWebEngine(engine, APP_NAME)
72
-
73
- setTimeout(() => {
74
- console.log('[Web Renderer] === Initialization complete ===')
75
- }, 1000)
50
+ console.log('[Web Renderer] Global CSS reset injected')
51
+
52
+ // 动态加载主入口,等待加载完成后再启动引擎
53
+ console.log('[Web Renderer] Importing main module...')
54
+ import(__QUICKTVUI_MAIN_ENTRY__).then(() => {
55
+ console.log('[Web Renderer] Main module loaded')
56
+ console.log('[Web Renderer] Starting engine...')
57
+ startWebEngine(engine, APP_NAME)
58
+ setTimeout(() => {
59
+ console.log('[Web Renderer] === Initialization complete ===')
60
+ }, 1000)
61
+ }).catch(err => {
62
+ console.error('[Web Renderer] Failed to load main module:', err)
63
+ })
@@ -9,7 +9,6 @@ const fs = require('fs')
9
9
  // 从环境变量获取配置
10
10
  const projectRoot = process.env.QUICKTVUI_PROJECT_ROOT || process.cwd()
11
11
  const mainEntry = process.env.QUICKTVUI_MAIN_ENTRY || path.resolve(projectRoot, 'src/main.ts')
12
- const entryType = process.env.QUICKTVUI_ENTRY_TYPE || 'package'
13
12
  const port = parseInt(process.env.QUICKTVUI_PORT || '39001', 10)
14
13
 
15
14
  // 尝试加载项目的 package.json
@@ -87,21 +86,9 @@ function detectCSSLoader() {
87
86
 
88
87
  const cssLoader = detectCSSLoader()
89
88
 
90
- // 根据类型选择入口文件
91
- let entryFiles
92
-
93
- if (entryType === 'webmain') {
94
- // 直接使用 webMain 作为入口
95
- entryFiles = ['regenerator-runtime/runtime', mainEntry]
96
- } else if (entryType === 'local') {
97
- // 使用 entry-local.js + main 入口
98
- const entryLocalFile = path.resolve(__dirname, 'entry-local.js')
99
- entryFiles = ['regenerator-runtime/runtime', entryLocalFile, mainEntry]
100
- } else {
101
- // 使用 entry-package.js + main 入口
102
- const entryPackageFile = path.resolve(__dirname, 'entry-package.js')
103
- entryFiles = ['regenerator-runtime/runtime', entryPackageFile, mainEntry]
104
- }
89
+ // 入口文件:只加载 entry-package.js,主入口通过动态 import 加载
90
+ const entryPackageFile = path.resolve(__dirname, 'entry-package.js')
91
+ const entryFiles = ['regenerator-runtime/runtime', entryPackageFile]
105
92
 
106
93
  module.exports = {
107
94
  mode: 'development',
@@ -175,28 +162,10 @@ module.exports = {
175
162
  template: path.resolve(__dirname, '../templates/web-renderer.html'),
176
163
  title: pkg.name || 'QuickTVUI Web',
177
164
  }),
178
- // 注入主入口路径和项目根目录,以及预计算的模块路径
165
+ // 注入主入口路径和环境变量
179
166
  new (require('webpack').DefinePlugin)({
180
167
  __QUICKTVUI_PROJECT_ROOT__: JSON.stringify(projectRoot),
181
168
  __QUICKTVUI_MAIN_ENTRY__: JSON.stringify(mainEntry),
182
- // 预计算 src/web 模块路径(浏览器环境无法使用 path 模块)
183
- __QUICKTVUI_MODULE_ASYNC_LOCAL_STORAGE__: JSON.stringify(
184
- path.join(projectRoot, 'src/web/core/asyncLocalStorage')
185
- ),
186
- __QUICKTVUI_MODULE_AUTO_PROXY__: JSON.stringify(
187
- path.join(projectRoot, 'src/web/core/autoProxy')
188
- ),
189
- __QUICKTVUI_MODULE_SCENE_BUILDER__: JSON.stringify(
190
- path.join(projectRoot, 'src/web/core/SceneBuilder')
191
- ),
192
- __QUICKTVUI_MODULE_WEB_ENGINE__: JSON.stringify(path.join(projectRoot, 'src/web')),
193
- __QUICKTVUI_MODULE_PATCHES__: JSON.stringify(path.join(projectRoot, 'src/web/core/patches')),
194
- __QUICKTVUI_MODULE_TV_FOCUS_MANAGER__: JSON.stringify(
195
- path.join(projectRoot, 'src/web/core/TVFocusManager')
196
- ),
197
- __QUICKTVUI_MODULE_PAGE_LIFECYCLE__: JSON.stringify(
198
- path.join(projectRoot, 'src/web/core/pageLifecycle')
199
- ),
200
169
  process: JSON.stringify({
201
170
  env: { NODE_ENV: 'development' },
202
171
  browser: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quicktvui/web-cli",
3
- "version": "1.0.0-beta.11",
3
+ "version": "1.0.0-beta.13",
4
4
  "description": "CLI tool for QuickTVUI web development - zero configuration",
5
5
  "author": "QuickTVUI Team",
6
6
  "license": "Apache-2.0",