@shijiu/jsview 2.1.6-alpha.0 → 2.1.23

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.
@@ -3,11 +3,11 @@
3
3
  */
4
4
 
5
5
  const TargetRevision = {
6
- "CoreRevision": 1021500,
7
- "CoreRevisionAndBranch": "1021500",
8
- "JseRevision": "1.0.891",
6
+ "CoreRevision": 1021540,
7
+ "CoreRevisionAndBranch": "1021540",
8
+ "JseRevision": "1.0.894",
9
9
  "JseUrl":
10
- "http://cdn.release.qcast.cn/forge_js/master/JsViewES6_js2c_r891.jsv.1be123f4.js"
10
+ "http://cdn.release.qcast.cn/forge_js/master/JsViewES6_js2c_r894.jsv.efbd22ea.js"
11
11
  };
12
12
 
13
13
  // 版本是否存在测试方法
@@ -84,7 +84,29 @@ export default class JsViewLoader {
84
84
  window.JsView.addKeysMap(this.#config.vendorConfig.bindKeys);
85
85
 
86
86
  // (可选配置)localStorage支持
87
- window.JsView.setStorageDomain(this.#config.jsviewConfig.localStorage.domain ?? appName); // Domain为app包名
87
+ let storageDomain = this.#config.jsviewConfig.localStorage.domain;
88
+ if (!storageDomain || storageDomain === "default") {
89
+ // 兼容历史版本出现的default字符串设置
90
+ storageDomain = appName; // null/default场景,不和其他应用共享localStorage, 也规避了考虑同名item问题
91
+ } else if (storageDomain === "follow-url") {
92
+ if (window.location.protocol == "file:") {
93
+ // file方式加载,使用appName
94
+ storageDomain = appName;
95
+ console.warn("Storage domain follow-url not support file://");
96
+ } else {
97
+ storageDomain = window.location.hostname;
98
+
99
+ const ipv4Regex = /^(\d{1,3}\.){3}\d{1,3}$/;
100
+ const ipv6Regex = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
101
+ if (ipv4Regex.test(storageDomain) || ipv6Regex.test(storageDomain)) {
102
+ // ip形式, 不能作为合格domain, 使用appName作为domain
103
+ storageDomain = appName;
104
+ console.warn("Storage domain follow-url not support host with ip");
105
+ }
106
+ }
107
+ }
108
+ console.log(`Storage domain [${storageDomain}]`);
109
+ window.JsView.setStorageDomain(storageDomain); // Domain为app包名
88
110
 
89
111
  const localStorageKeys = this.#config.jsviewConfig.localStorage.presetKeys;
90
112
  window.JsView.enableStorageNames(...localStorageKeys);
@@ -115,7 +137,7 @@ export default class JsViewLoader {
115
137
  // 检查配套引擎的版本
116
138
  if (window.JsView.CodeRevision !== TargetRevision.CoreRevision /* Native引擎版本(由APK启动参数 CORE 决定) */
117
139
  || window.Forge.Version !== TargetRevision.JseRevision) {/* JS引擎版本(由APK启动参数 ENGINEJS 决定) */
118
- console.warn(`Warning: JsView Engine version miss matched, some effect will be lost. url should be ${TargetRevision.JseUrl}`);
140
+ console.warn(`Warning: JsView Engine version miss matched, some effect will be lost. core should be ${TargetRevision.CoreRevision}, url should be ${TargetRevision.JseUrl}`);
119
141
  }
120
142
  }
121
143
 
@@ -1,37 +1,50 @@
1
+ // 同主工程中的 jsview.config.mjs 默认值
1
2
  export default {
2
3
  jsviewConfig: {
4
+ // (可选配置)remote loader
5
+ remoteLoader: null,
6
+
3
7
  // (可选配置)localStorage支持
4
- // domain可以为任意字符串,各Domain的localStorage互相隔离, 默认值是hostname
5
- // presetKeys为预置key,可以直接使用localStorage.xxx的形式,避免undefined错误
6
8
  localStorage: {
7
- domain: "default",
9
+ // 默认自动使用app.config.mjs的AppName作为domain, 可取值:
10
+ // null, 'defualt': 使用 app.config.mjs 中的AppName作为Domain, 和其他小程序数据完全隔离,不担心重名问题
11
+ // 'follow-url': 使用运行时的 window.location.hostname 作为domain
12
+ // 其他字符串: 使用给定字符串作为domain
13
+ domain: null,
14
+
15
+ // presetKeys为预置key,可以直接使用localStorage.xxx的形式,避免undefined错误
8
16
  presetKeys: [
9
- "value1",
10
- "value2"
11
- ],
17
+ // 例如: 设置 value1, value3
18
+ // 'value1',
19
+ // 'value3'
20
+ ]
21
+ },
22
+
23
+ cookies: {
24
+ domain: '' // 当非null非空时,激活cookie功能,使ajax请求时自动带上cookies,并且document.cookie的get/set可用
12
25
  },
13
26
 
14
27
  // (可选配置)填写main.js或者bundle.js相对于index.html的相对位置,
15
28
  // 用于image/import.then的相对寻址, vue3默认值是/js/
16
- jsSubPath: "/js/",
29
+ jsSubPath: '/js/'
17
30
  },
18
31
 
19
32
  vendorConfig: {
20
33
  // (可选配置)设置屏幕坐标映射值,screenWidth为屏幕画布定义的宽度,displayScale为清晰度,
21
- // 默认值是画布宽度1280px, 清晰度为1.0
34
+ // 默认值是画布宽度1280px, 清晰度为1.5
22
35
  designedMap: {
23
36
  screenWidth: 1280,
24
- displayScale: 1.0
37
+ displayScale: 1.5
25
38
  },
26
39
 
27
40
  // (可选配置)按键接受的扩展,例如将静音按键(JAVA键值为164)映射为JS键值20001,
28
- // PS:注意"164"的引号
41
+ // PS:注意'164'的引号
29
42
  bindKeys: {
30
43
  keys: {
31
- "164": 20001
44
+ '164': 20001
32
45
  },
33
46
  syncKeys: {
34
47
  }
35
- },
48
+ }
36
49
  }
37
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shijiu/jsview",
3
- "version": "2.1.6-alpha.0",
3
+ "version": "2.1.23",
4
4
  "bin": {
5
5
  "jsview-post-build": "./tools/jsview-post-build.js",
6
6
  "jsview-post-install": "./tools/jsview-post-install.js"
@@ -6231,6 +6231,16 @@ function baseCreateRenderer(options, createHydrationFns) {
6231
6231
  }
6232
6232
  };
6233
6233
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
6234
+ const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
6235
+ // unset ref
6236
+ if (ref != null) {
6237
+ setRef(ref, null, parentSuspense, vnode, true);
6238
+ }
6239
+ if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
6240
+ parentComponent.ctx.deactivate(vnode);
6241
+ return;
6242
+ }
6243
+
6234
6244
  // JsView Added >>>
6235
6245
  if (!vnode.jsvPatchedFlag) {
6236
6246
  // unmount动作要进行的是vnode中的子节点进行unmount,但是vnode本身没有去进行创建,所以也不用去销毁
@@ -6249,15 +6259,6 @@ function baseCreateRenderer(options, createHydrationFns) {
6249
6259
  }
6250
6260
  // JsView Added <<<
6251
6261
 
6252
- const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs } = vnode;
6253
- // unset ref
6254
- if (ref != null) {
6255
- setRef(ref, null, parentSuspense, vnode, true);
6256
- }
6257
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
6258
- parentComponent.ctx.deactivate(vnode);
6259
- return;
6260
- }
6261
6262
  const shouldInvokeDirs = shapeFlag & 1 /* ShapeFlags.ELEMENT */ && dirs;
6262
6263
  const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
6263
6264
  let vnodeHook;
@@ -52,6 +52,8 @@ const jsviewConfig = defineConfig({
52
52
  ],
53
53
  exclude: [
54
54
  '@shijiu/jsview/loader/jsview-main.mjs', // 解决windows上出现解析异常的问题。
55
+ '@shijiu/jsview-vue',
56
+ '@shijiu/jsview-vue-samples',
55
57
  'jsview',
56
58
  'jsview-vue',
57
59
  'jsview-vue-samples',
@@ -78,18 +78,38 @@ async function prepareMainAppData(options, fileMd5)
78
78
  if (!fs.existsSync(appConfigFilePath)) {
79
79
  Logger.ErrorAndExit('Failed to open app config file from ' + appConfigFilePath);
80
80
  }
81
- // const appConfigText = fs.readFileSync(appConfigFile);
82
- // const appDataOriginJson = JSON.parse(appConfigText);
83
81
  const appConfigFileUrl = url.pathToFileURL(appConfigFilePath);
84
- const appDataOriginJson = await import(appConfigFileUrl);
82
+ const { default: appConfig } = await import(appConfigFileUrl);
85
83
 
86
84
  // 组装AppData
87
- let targetAppData = {};
88
- Object.assign(targetAppData, appDataOriginJson.default); // 同步包括AppName在内的所有信息
89
- targetAppData.PublicKeys = [publicKeyDerText]; // 使用签名数组,支持后续追加签名
90
- targetAppData.EncryptCodes = [encryptCodeBase64]; // 同样使用数组,支持后续追加
85
+ appConfig.PublicKeys = [publicKeyDerText]; // 使用签名数组,支持后续追加签名
86
+ appConfig.EncryptCodes = [encryptCodeBase64]; // 同样使用数组,支持后续追加
91
87
 
92
- return JSON.stringify(targetAppData);
88
+ return JSON.stringify(appConfig);
89
+ }
90
+
91
+ async function checkAppConfig(options)
92
+ {
93
+ const appConfigFilePath = path.resolve(options.appConfigDir, 'app.config.mjs');
94
+ const appConfigRelativePath = path.relative(options.projectDir, appConfigFilePath);
95
+ if (!fs.existsSync(appConfigFilePath)) {
96
+ Logger.ErrorAndExitNoException('Failed to open app config file from ' + appConfigRelativePath);
97
+ }
98
+ const appConfigFileUrl = url.pathToFileURL(appConfigFilePath);
99
+ const { default: appConfig } = await import(appConfigFileUrl);
100
+
101
+ if(typeof appConfig.AppName !== 'string'
102
+ || appConfig.AppName.trim().length <= 0
103
+ || appConfig.AppName.trim() == '-') {
104
+ Logger.ErrorNoException('Failed to check [' + appConfigRelativePath + '], AppName is not valid.');
105
+ Logger.ErrorAndExitNoException('Please refer to: http://jsview-dev.shijiutv.com/guide/2.environments/2.6.deploy.html');
106
+ }
107
+ if(typeof appConfig.AppTitle !== 'string'
108
+ || appConfig.AppTitle.trim().length <= 0
109
+ || appConfig.AppTitle.trim() == '-') {
110
+ Logger.ErrorNoException('Failed to check [' + appConfigRelativePath + '], AppTitle is not valid.');
111
+ Logger.ErrorAndExitNoException('Please refer to: http://jsview-dev.shijiutv.com/guide/2.environments/2.6.deploy.html');
112
+ }
93
113
  }
94
114
 
95
115
  async function signApp(options)
@@ -263,6 +283,10 @@ async function main(argv)
263
283
  redirectSourceMappingURL(options)
264
284
  Logger.Info('Redirected JsView source map...');
265
285
 
286
+ Logger.Info('Checking JsView app config...');
287
+ await checkAppConfig(options);
288
+ Logger.Info('Checked JsView app config...');
289
+
266
290
  Logger.Info('Signing JsView App...');
267
291
  await signApp(options);
268
292
  Logger.Info('Signed JsView App.');
@@ -39,7 +39,9 @@ function checkNpmLinkForDebug(options, linkablePkgNames)
39
39
  let missingDepPkgs = '';
40
40
  for (const linkableName of linkablePkgNames) {
41
41
  let linkableTarget = pkgObj.dependencies?.[linkableName];
42
- if (!linkableTarget || !linkableTarget.startsWith('file:')) {
42
+ if (!linkableTarget?.startsWith('file:')
43
+ && !linkableTarget?.startsWith('http:')
44
+ && !linkableTarget?.startsWith('https:')) {
43
45
  continue;
44
46
  }
45
47