@shijiu/jsview 1.9.783 → 1.9.829
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/dom/bin/jsview-browser-debug-dom.min.js +1 -1
- package/dom/bin/jsview-dom.min.js +1 -1
- package/dom/bin/jsview-engine-js-browser.min.js +1 -1
- package/dom/jsv-browser-debug-dom.js +6 -3
- package/dom/jsv-code-debug.mjs +5 -5
- package/dom/jsv-dom.js +5 -2
- package/dom/jsv-engine-js-browser.js +3 -0
- package/dom/jsv-forge-define.js +5 -2
- package/dom/target_core_revision.mjs +4 -4
- package/loader/jsview-browser-forgeapp.js +13 -0
- package/loader/jsview-loader.js +198 -0
- package/loader/jsview-main.js +14 -33
- package/loader/jsview-react-main.js +36 -0
- package/loader/{header_script_loader.js → jsview-react-script-loader.js} +0 -0
- package/package.json +1 -1
- package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +925 -921
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1 -0
- package/patches/node_modules/postcss-js/objectifier.js +1 -0
- package/patches/node_modules/react-dev-utils/WebpackDevServerUtils.js +450 -0
- package/patches/node_modules/react-dev-utils/package.json +88 -0
- package/patches/node_modules/react-scripts/config/paths.js +22 -7
- package/patches/node_modules/react-scripts/config/webpack.config.js +36 -15
- package/patches/node_modules/vite/dist/node/chunks/dep-ed9cb113.js +12 -8
- package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +2 -1
- package/patches/node_modules/vue-router/dist/vue-router.mjs +1 -0
- package/patches/node_modules/webpack-dev-server/client/utils/reloadApp.js +76 -0
- package/patches/node_modules/webpack-dev-server/client/utils/sendMessage.js +21 -0
- package/patches/node_modules/webpack-dev-server/package.json +141 -0
- package/tools/jsview-common.js +54 -21
- package/tools/jsview-post-build.js +16 -6
- package/tools/jsview-post-install.js +50 -4
- package/loader/jsview.default.config.js +0 -37
- package/loader/loader.js +0 -183
- package/loader/loader_webkit.js +0 -40
- package/tools/index.js +0 -209
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './browser-root-style.css'
|
|
2
2
|
|
|
3
|
-
import JsvCodeDebug from
|
|
3
|
+
import JsvCodeDebug from './jsv-code-debug'
|
|
4
4
|
|
|
5
5
|
let domBrowser;
|
|
6
6
|
|
|
7
7
|
if (!JsvCodeDebug.enableDebug) {
|
|
8
8
|
// Release entry
|
|
9
|
-
domBrowser = await import(
|
|
9
|
+
domBrowser = await import('./bin/jsview-browser-debug-dom.min');
|
|
10
10
|
} else {
|
|
11
11
|
// Debug entry
|
|
12
12
|
domBrowser = await import(JsvCodeDebug.domBrowserPath);
|
|
13
|
+
|
|
14
|
+
// for Webpack
|
|
15
|
+
// domBrowser = await import('./code/src/dom-browser-hook');
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
export default domBrowser;
|
package/dom/jsv-code-debug.mjs
CHANGED
|
@@ -5,10 +5,10 @@ const JsvCodeDebug = {
|
|
|
5
5
|
// TODO: 进行编译(yarn build)时,需要设置为fasle。
|
|
6
6
|
enableDebug: false,
|
|
7
7
|
|
|
8
|
-
domBrowserPath:
|
|
9
|
-
domNativePath:
|
|
10
|
-
engineBrowserPath:
|
|
11
|
-
forgeDefinePath:
|
|
8
|
+
domBrowserPath: './code/src/dom-browser-hook',
|
|
9
|
+
domNativePath: './code/src/dom-wrapper',
|
|
10
|
+
engineBrowserPath: './code/src/engine-js/browser',
|
|
11
|
+
forgeDefinePath: './code/src/engine-js',
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export default JsvCodeDebug;
|
|
14
|
+
export default JsvCodeDebug;
|
package/dom/jsv-dom.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import JsvCodeDebug from
|
|
1
|
+
import JsvCodeDebug from './jsv-code-debug'
|
|
2
2
|
|
|
3
3
|
let domNative;
|
|
4
4
|
|
|
5
5
|
if (!JsvCodeDebug.enableDebug) {
|
|
6
6
|
// Release entry
|
|
7
|
-
domNative = await import(
|
|
7
|
+
domNative = await import('./bin/jsview-dom.min');
|
|
8
8
|
} else {
|
|
9
9
|
// Debug entry
|
|
10
10
|
domNative = await import(JsvCodeDebug.domNativePath);
|
|
11
|
+
|
|
12
|
+
// for Webpack
|
|
13
|
+
// domNative = await import('./code/src/dom-wrapper');
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export {
|
package/dom/jsv-forge-define.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import JsvCodeDebug from
|
|
1
|
+
import JsvCodeDebug from './jsv-code-debug'
|
|
2
2
|
|
|
3
3
|
let forgeDefine;
|
|
4
4
|
|
|
5
5
|
if (!JsvCodeDebug.enableDebug) {
|
|
6
6
|
// Release entry
|
|
7
|
-
forgeDefine = await import(
|
|
7
|
+
forgeDefine = await import('./bin/jsview-forge-define.min');
|
|
8
8
|
} else {
|
|
9
9
|
// Debug entry
|
|
10
10
|
forgeDefine = await import(JsvCodeDebug.forgeDefinePath);
|
|
11
|
+
|
|
12
|
+
// for Webpack
|
|
13
|
+
// forgeDefine = await import('./code/src/engine-js');
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
const Forge = forgeDefine.Forge;
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
const TargetRevision = {
|
|
6
|
-
"CoreRevision":
|
|
7
|
-
"CoreRevisionAndBranch": "
|
|
8
|
-
"JseRevision": "1.0.
|
|
6
|
+
"CoreRevision": 1021253,
|
|
7
|
+
"CoreRevisionAndBranch": "1021253",
|
|
8
|
+
"JseRevision": "1.0.827",
|
|
9
9
|
"JseUrl":
|
|
10
|
-
"http://cdn.release.qcast.cn/forge_js/master/
|
|
10
|
+
"http://cdn.release.qcast.cn/forge_js/master/JsViewES6_react_r827.jsv.6825753b.js"
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// 不要用export default,update-env脚本不能解析
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import JsViewDefConfig from "./jsview.config.default"
|
|
2
|
+
import JsViewBrowserForgeApp from './jsview-browser-forgeapp'
|
|
3
|
+
import TargetRevision from "../dom/target_core_revision"
|
|
4
|
+
|
|
5
|
+
export default class JsViewLoader {
|
|
6
|
+
constructor() {
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
mergeConfig(newConfig) {
|
|
10
|
+
this.#config = this.#deepMergeConfig(this.#config, newConfig);
|
|
11
|
+
|
|
12
|
+
return this.#config;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
initForgeEnv() {
|
|
16
|
+
if (typeof window.Forge === 'undefined') { // Browser没有默认Forge
|
|
17
|
+
window.Forge = {};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
window.Forge.DesignMap = this.#makeForgeDesignedMap.bind(this);
|
|
21
|
+
window.Forge.RunApp = this.#runForgeApp.bind(this);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async initJsViewEnv(appName, onLoaded) {
|
|
25
|
+
// 参数说明:
|
|
26
|
+
await this.#initJsViewDom();
|
|
27
|
+
|
|
28
|
+
this.#loadJsViewEnvAsync(appName, onLoaded);
|
|
29
|
+
|
|
30
|
+
// 环境启动后,动态加载React框架和main
|
|
31
|
+
this.#checkEngineVersion();
|
|
32
|
+
this.#jsviewInited = true;
|
|
33
|
+
this.#tryStartForgeApp();
|
|
34
|
+
|
|
35
|
+
console.log("JsView Loader: Load done. AppName=" + appName);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async #initJsViewDom() {
|
|
39
|
+
if (window.JsView) {
|
|
40
|
+
// initHeaderScriptLoader(js_sub_path);
|
|
41
|
+
let { domNative } = await import("../dom/jsv-dom.js");
|
|
42
|
+
|
|
43
|
+
this.#forgeAppClass = domNative.JsViewForgeApp;
|
|
44
|
+
window.JsView.ForgeExt = domNative.ForgeExtension;
|
|
45
|
+
|
|
46
|
+
// /static/js/: (可选配置)填写main.js或者bundle.js相对于index.html的相对位置,用于image/import.then的相对寻址
|
|
47
|
+
window.JsView.Dom.JsSubPath = this.#config.jsviewConfig.jsSubPath;
|
|
48
|
+
} else {
|
|
49
|
+
// 在PC环境下没有处理加载EngineJs, 所以在此加载一下
|
|
50
|
+
await import("../dom/jsv-engine-js-browser.js");
|
|
51
|
+
|
|
52
|
+
// 加载jsv-dom的调试版本
|
|
53
|
+
await import("../dom/jsv-browser-debug-dom.js");
|
|
54
|
+
|
|
55
|
+
this.#forgeAppClass = JsViewBrowserForgeApp;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#deepMergeConfig(target, source) {
|
|
60
|
+
const isObject = (obj) => obj && typeof obj === 'object';
|
|
61
|
+
|
|
62
|
+
if (!isObject(target) || !isObject(source)) {
|
|
63
|
+
throw new Error('JsView Error: Failed to merge config:', source);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
for (const key in source) {
|
|
67
|
+
const targetValue = target[key];
|
|
68
|
+
const sourceValue = source[key];
|
|
69
|
+
|
|
70
|
+
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
71
|
+
target[key] = targetValue.concat(sourceValue);
|
|
72
|
+
} else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
73
|
+
target[key] = this.#deepMergeConfig({...targetValue}, sourceValue);
|
|
74
|
+
} else {
|
|
75
|
+
target[key] = sourceValue;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
#loadJsViewEnvAsync(appName, onLoaded) {
|
|
83
|
+
console.log("StartApp...");
|
|
84
|
+
|
|
85
|
+
// 运行在Native中
|
|
86
|
+
if (window.JsView) {
|
|
87
|
+
if (appName) {
|
|
88
|
+
window.JsView.notifyAppName?.(appName);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// (可选配置)按键接受的扩展,例如将静音按键(JAVA键值为164)映射为JS键值20001,PS:注意"164"的引号
|
|
92
|
+
window.JsView.addKeysMap(this.#config.vendorConfig.bindKeys);
|
|
93
|
+
|
|
94
|
+
// (可选配置)localStorage支持
|
|
95
|
+
let storageDomain = this.#config.jsviewConfig.localStorage.domain;
|
|
96
|
+
if (storageDomain == "default") {
|
|
97
|
+
storageDomain = this.#getHostName();
|
|
98
|
+
}
|
|
99
|
+
window.JsView.setStorageDomain(storageDomain); // Domain可以为任意字符串,各Domain的localStorage互相隔离
|
|
100
|
+
|
|
101
|
+
const localStorageKeys = this.#config.jsviewConfig.localStorage.presetKeys;
|
|
102
|
+
window.JsView.enableStorageNames(...localStorageKeys);
|
|
103
|
+
|
|
104
|
+
// (可选设置)cookies的支持
|
|
105
|
+
const cookiesDomain = this.#config.jsviewConfig.cookies?.domain;
|
|
106
|
+
if (cookiesDomain) {
|
|
107
|
+
console.log("Enable cookie for domain " + cookiesDomain);
|
|
108
|
+
window.JsView.setCookieDomain?.(cookiesDomain);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// JsView Dom相关配置
|
|
112
|
+
window.JsView.Dom.Render = function () {
|
|
113
|
+
onLoaded()
|
|
114
|
+
};
|
|
115
|
+
} else {
|
|
116
|
+
JsViewBrowserForgeApp.setRender(function () {
|
|
117
|
+
onLoaded();
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#checkEngineVersion() {
|
|
123
|
+
if (!window.JsView) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 检查配套引擎的版本
|
|
128
|
+
if (window.JsView.CodeRevision !== TargetRevision.CoreRevision /* Native引擎版本(由APK启动参数 CORE 决定) */
|
|
129
|
+
|| window.Forge.Version !== TargetRevision.JseRevision) {/* JS引擎版本(由APK启动参数 ENGINEJS 决定) */
|
|
130
|
+
console.warn(`Warning: JsView Engine version miss matched, some effect will be lost. url should be ${TargetRevision.JseUrl}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
#getHostName() {
|
|
135
|
+
const fullUrl = window.location.href;
|
|
136
|
+
let idx = fullUrl.indexOf("://");
|
|
137
|
+
// const protocol = (idx > 0 ? fullUrl.substring(0, idx + 1) : "");
|
|
138
|
+
const hostPath = idx > 1 ? fullUrl.substring(idx + 3) : "";
|
|
139
|
+
|
|
140
|
+
idx = hostPath.indexOf("/");
|
|
141
|
+
const host = idx > 0 ? hostPath.substring(0, idx) : "";
|
|
142
|
+
|
|
143
|
+
return host;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
#makeForgeDesignedMap() {
|
|
147
|
+
// {screenWidth:1280, displayScale:1.0}: (可选配置)设置屏幕坐标映射值,前者为屏幕画布定义的宽度,后者为清晰度,
|
|
148
|
+
// 默认值是画布宽度1280px, 清晰度为1.0
|
|
149
|
+
const inputDesignedMap = this.#config.vendorConfig.designedMap;
|
|
150
|
+
let designMap = { width: 1280, displayScale: 1.0 };
|
|
151
|
+
try {
|
|
152
|
+
if (inputDesignedMap) {
|
|
153
|
+
const newDesignedMap = {
|
|
154
|
+
width: inputDesignedMap.screenWidth,
|
|
155
|
+
displayScale: inputDesignedMap.displayScale
|
|
156
|
+
};
|
|
157
|
+
designMap = newDesignedMap;
|
|
158
|
+
}
|
|
159
|
+
} catch (e) {
|
|
160
|
+
console.error("JsView Error: Load designed map failed");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// 设置播放器的屏幕坐标尺寸
|
|
164
|
+
if (window.JsView) {
|
|
165
|
+
window.JsView.setVideoDesignMapWidth?.(designMap.width);
|
|
166
|
+
} else {
|
|
167
|
+
// 借助Audio标签设置基类BaseMedia的屏幕尺寸配置,绕开react的unref语法检测
|
|
168
|
+
if (Audio.setDesignMapWidth) {
|
|
169
|
+
Audio.setDesignMapWidth(designMap.width);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return designMap;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
#runForgeApp(activityManager) {
|
|
177
|
+
console.log("JsView Loader: Run forge app.");
|
|
178
|
+
this.#forgeActivityManager = activityManager;
|
|
179
|
+
this.#tryStartForgeApp();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
#tryStartForgeApp() {
|
|
183
|
+
if (!this.#forgeActivityManager ||
|
|
184
|
+
this.#jsviewInited == false) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
console.log("JsView Loader: Start forge app.");
|
|
189
|
+
// eslint-disable-next-line new-cap
|
|
190
|
+
this.#forgeApp = new this.#forgeAppClass(this.#forgeActivityManager);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
#config = JsViewDefConfig;
|
|
194
|
+
#jsviewInited = false;
|
|
195
|
+
#forgeActivityManager = null;
|
|
196
|
+
#forgeAppClass = null
|
|
197
|
+
#forgeApp = null;
|
|
198
|
+
}
|
package/loader/jsview-main.js
CHANGED
|
@@ -1,41 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import JsViewLoader from './jsview-loader'
|
|
2
|
+
import AppData from '/src/appConfig/app.config'
|
|
2
3
|
import JsViewVendorConfig from "/src/appConfig/jsview.config"
|
|
3
|
-
import { loadJsViewEnv } from './loader'
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
if (!isObject(target) || !isObject(source)) {
|
|
9
|
-
return source;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
Object.keys(source).forEach(key => {
|
|
13
|
-
const targetValue = target[key];
|
|
14
|
-
const sourceValue = source[key];
|
|
15
|
-
|
|
16
|
-
if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
|
|
17
|
-
target[key] = targetValue.concat(sourceValue);
|
|
18
|
-
} else if (isObject(targetValue) && isObject(sourceValue)) {
|
|
19
|
-
target[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
|
|
20
|
-
} else {
|
|
21
|
-
target[key] = sourceValue;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
5
|
+
function main() {
|
|
6
|
+
const jsviewLoader = new JsViewLoader();
|
|
24
7
|
|
|
25
|
-
|
|
26
|
-
|
|
8
|
+
// 使用vendor配置值覆盖默认配置。
|
|
9
|
+
const config = jsviewLoader.mergeConfig(JsViewVendorConfig);
|
|
10
|
+
console.log("JsView config: " + JSON.stringify(config));
|
|
27
11
|
|
|
28
|
-
|
|
29
|
-
// 使用vendor配置值覆盖默认配置。
|
|
30
|
-
let config = JsViewDefConfig;
|
|
31
|
-
deepMerge(config, JsViewVendorConfig);
|
|
32
|
-
console.log("JsView config: " + JSON.stringify(config));
|
|
12
|
+
jsviewLoader.initForgeEnv();
|
|
33
13
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
14
|
+
// 初始化jsview运行环境。
|
|
15
|
+
const onInitJsViewEnv = function () {
|
|
16
|
+
// JsView环境加载完毕后,加载vue/react的main.js文件。
|
|
17
|
+
import('/src/main.tsx');
|
|
18
|
+
};
|
|
19
|
+
jsviewLoader.initJsViewEnv(AppData.AppName, onInitJsViewEnv);
|
|
39
20
|
}
|
|
40
21
|
|
|
41
22
|
// webpack/vite运行入口
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import JsViewLoader from './jsview-loader'
|
|
2
|
+
import AppData from '/src/appConfig/app.config'
|
|
3
|
+
import JsViewVendorConfig from "/src/appConfig/jsview.config"
|
|
4
|
+
import initHeaderScriptLoader from "./jsview-react-script-loader";
|
|
5
|
+
|
|
6
|
+
function main() {
|
|
7
|
+
const jsviewLoader = new JsViewLoader();
|
|
8
|
+
|
|
9
|
+
// 使用vendor配置值覆盖默认配置。
|
|
10
|
+
const config = jsviewLoader.mergeConfig(JsViewVendorConfig);
|
|
11
|
+
console.log("JsView config: " + JSON.stringify(config));
|
|
12
|
+
|
|
13
|
+
jsviewLoader.initForgeEnv();
|
|
14
|
+
|
|
15
|
+
// Webpack 并不能直接运行import语法,需要一个Script加载器
|
|
16
|
+
if (window.JsView) {
|
|
17
|
+
initHeaderScriptLoader(config.jsviewConfig.jsSubPath);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 初始化jsview运行环境。
|
|
21
|
+
const onInitJsViewEnv = async function () {
|
|
22
|
+
// workaround: 因为React的npm run build后,不能支持top-level-await,
|
|
23
|
+
// 所以只能在这里加载 JsViewReactWidget/BrowserDebugWidget, 导致了反向依赖问题。
|
|
24
|
+
// 期待下一个版本的Webpack能修复此问题。
|
|
25
|
+
if (!window.JsView) {
|
|
26
|
+
await import("../../jsview-react/utils/JsViewReactWidget/BrowserDebugWidget/WidgetLoader");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// JsView环境加载完毕后,加载vue/react的main.js文件。
|
|
30
|
+
import('/src/main.tsx');
|
|
31
|
+
};
|
|
32
|
+
jsviewLoader.initJsViewEnv(AppData.AppName, onInitJsViewEnv);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// webpack/vite运行入口
|
|
36
|
+
main();
|
|
File without changes
|