@quicktvui/web-cli 1.0.0-beta.11 → 1.0.0-beta.12
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/lib/entry-package.js +18 -38
- package/lib/webpack.config.js +4 -35
- package/package.json +1 -1
package/lib/entry-package.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
// @quicktvui/web-cli - web entry
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// 初始化流程参考 main-web.js
|
|
1
|
+
// @quicktvui/web-cli - web entry
|
|
2
|
+
// 通过 @quicktvui/web-renderer 导入所有依赖
|
|
3
|
+
// 主入口通过 webpack 多入口配置自动加载
|
|
6
4
|
|
|
7
|
-
console.log('[Web Renderer] === Starting initialization
|
|
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,40 @@ import {
|
|
|
19
16
|
IJKPlayerComponent,
|
|
20
17
|
} from '@quicktvui/web-renderer'
|
|
21
18
|
|
|
22
|
-
//
|
|
19
|
+
// 初始化 async localStorage
|
|
23
20
|
initAsyncLocalStorage()
|
|
24
21
|
|
|
25
|
-
//
|
|
22
|
+
// 初始化自动代理
|
|
26
23
|
initAutoProxy()
|
|
27
24
|
|
|
28
|
-
//
|
|
25
|
+
// 注册 IJKPlayerComponent
|
|
29
26
|
global.__WEB_COMPONENTS__ = global.__WEB_COMPONENTS__ || {}
|
|
30
27
|
global.__WEB_COMPONENTS__['IJKPlayerComponent'] = IJKPlayerComponent
|
|
31
28
|
|
|
32
|
-
//
|
|
29
|
+
// 设置 SceneBuilder
|
|
33
30
|
setupSceneBuilder()
|
|
34
31
|
|
|
35
|
-
//
|
|
32
|
+
// 创建 Web 引擎
|
|
36
33
|
const engine = createWebEngine()
|
|
37
34
|
|
|
38
|
-
//
|
|
35
|
+
// 应用所有补丁
|
|
39
36
|
applyAllPatches(engine)
|
|
40
37
|
|
|
41
|
-
//
|
|
42
|
-
|
|
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
|
-
//
|
|
42
|
+
// 注入全局 CSS
|
|
47
43
|
const styleEl = document.createElement('style')
|
|
48
44
|
styleEl.id = 'web-platform-reset'
|
|
49
45
|
styleEl.textContent = `
|
|
50
|
-
|
|
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
|
|
50
|
+
console.log('[Web Renderer] Global CSS reset injected')
|
|
66
51
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
// Step 6: Start the engine
|
|
52
|
+
// 启动引擎
|
|
70
53
|
console.log('[Web Renderer] Starting engine...')
|
|
71
54
|
startWebEngine(engine, APP_NAME)
|
|
72
|
-
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
console.log('[Web Renderer] === Initialization complete ===')
|
|
75
|
-
}, 1000)
|
|
55
|
+
console.log('[Web Renderer] === Initialization complete ===')
|
package/lib/webpack.config.js
CHANGED
|
@@ -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
|
-
|
|
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 初始化,再加载用户主入口
|
|
90
|
+
const entryPackageFile = path.resolve(__dirname, 'entry-package.js')
|
|
91
|
+
const entryFiles = ['regenerator-runtime/runtime', entryPackageFile, mainEntry]
|
|
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,
|