@shijiu/jsview 2.3.0 → 2.3.151-test.0

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.
@@ -95,6 +95,7 @@ function updateOptions(options)
95
95
  options.appPrivKey = privKey;
96
96
  options.appPubKey = pubKey;
97
97
  options.appEntryMd5 = appEntryMd5;
98
+ options.appEntryFileName = `main.jsv.${options.appEntryMd5.slice(0, 8)}.js`;
98
99
  }
99
100
 
100
101
  function getOtherSignVerifyKeys(options)
@@ -333,7 +334,8 @@ function redirectBurdenResource(options)
333
334
  let sourceContent = fs.readFileSync(filePath, 'utf8');
334
335
 
335
336
  for(const burdenFilePath of burdenFilePathList) {
336
- const relativeBurdenFilePath = path.relative(options.distJsDir, burdenFilePath);
337
+ let relativeBurdenFilePath = path.relative(options.distJsDir, burdenFilePath);
338
+ relativeBurdenFilePath = relativeBurdenFilePath.replaceAll('\\', '/'); // 更正windows分隔符
337
339
  if(!sourceContent.includes(relativeBurdenFilePath)) {
338
340
  continue;
339
341
  }
@@ -395,14 +397,13 @@ function makeMainJsvMjs(options, framework)
395
397
 
396
398
  // 更新entry hash
397
399
  const jsEntryFilePath = getEntryFilePath(options);
398
- const newEntryFileName = `main.jsv.${options.appEntryMd5.slice(0, 8)}.js`;
399
- const newEntryFilePath = path.resolve(path.dirname(jsEntryFilePath), newEntryFileName);
400
+ const newEntryFilePath = path.resolve(options.distJsDir, options.appEntryFileName);
400
401
  Logger.Info(' -> ' + path.relative(options.projectDir, newEntryFilePath));
401
402
  fs.renameSync(jsEntryFilePath, newEntryFilePath);
402
403
 
403
404
  // 更新index.html hash
404
405
  var indexContent = fs.readFileSync(options.distJsIndexFile, 'utf8');
405
- indexContent = indexContent.replace(path.basename(jsEntryFilePath), newEntryFileName);
406
+ indexContent = indexContent.replace(path.basename(jsEntryFilePath), options.appEntryFileName);
406
407
  Logger.Info(' -> ' + path.relative(options.projectDir, options.distJsIndexFile));
407
408
  fs.writeFileSync(options.distJsIndexFile, indexContent, 'utf8');
408
409
 
@@ -478,6 +479,25 @@ function makeDebugMap(options, framework)
478
479
  fs.copyFileSync(jsmapServePath, to);
479
480
  }
480
481
 
482
+ async function makeJsvConfig(options)
483
+ {
484
+ const jsviewVersionURL = url.pathToFileURL(options.jsviewDomRevisionFile);
485
+ const { default: jsviewTargetVersion } = await import(jsviewVersionURL);
486
+ const appEntryFilePath = path.resolve(options.distJsDir, options.appEntryFileName);
487
+ let appEntryFileName = `./${path.relative(options.distDir, appEntryFilePath)}`;
488
+ // appEntryFileName = appEntryFileName.replace(/\.js$/, '.mjs'); // deprecated
489
+ appEntryFileName = appEntryFileName.replaceAll('\\', '/'); // windows平台适配
490
+
491
+ const jsvConfig = {
492
+ "COREVERSIONRANGE": jsviewTargetVersion.CoreRevisionAndBranch,
493
+ "ENGINE": jsviewTargetVersion.JseUrl,
494
+ "URL": appEntryFileName,
495
+ };
496
+
497
+ const content = JSON.stringify(jsvConfig, null, 2);
498
+ fs.writeFileSync(options.distJsvConfigFile, content, 'utf8');
499
+ }
500
+
481
501
  function makeJsvList(options)
482
502
  {
483
503
  let jsvList = makeFileListRecusive(options.distDir);
@@ -551,6 +571,10 @@ async function main(argv)
551
571
  await checkDomDebugDisabled(options);
552
572
 
553
573
  Logger.Info();
574
+ const jsviewPkgJson = loadPackageObject(options.jsviewDir);
575
+ Logger.Info(`JsView version: ${jsviewPkgJson.version}`);
576
+ Logger.Info();
577
+
554
578
  Logger.Info('Redirecting JsView burden resource...');
555
579
  redirectBurdenResource(options)
556
580
  Logger.Info('Redirected JsView burden resource...');
@@ -578,13 +602,16 @@ async function main(argv)
578
602
  makeDebugMap(options, argv.framework);
579
603
  Logger.Info('Made JsView Debug map.');
580
604
 
605
+ Logger.Info('Cleaning JsView Burden Resource...');
606
+ cleanupBurdenResource(options);
607
+ Logger.Info('Cleaned JsView Burden Resource...');
608
+
581
609
  Logger.Info('Making JsView info...');
610
+ await makeJsvConfig(options);
582
611
  makeJsvList(options);
583
612
  await makeJsvInfo(options);
584
613
  Logger.Info('Made JsView info...');
585
614
 
586
- cleanupBurdenResource(options);
587
-
588
615
  Logger.Info('Done...');
589
616
  }
590
617
 
@@ -250,6 +250,11 @@ function doPostInstall(framework, pkgNeedPatch, skipCheckVersion, skipCheckNpmcm
250
250
  const options = getOptions(framework);
251
251
  options.projectDir = process.cwd();
252
252
 
253
+ Logger.Info();
254
+ const jsviewPkgJson = loadPackageObject(options.jsviewDir);
255
+ Logger.Info(`JsView version: ${jsviewPkgJson.version}`);
256
+ Logger.Info();
257
+
253
258
  const linkablePkgNames = [
254
259
  '@shijiu/jsview',
255
260
  '@shijiu/jsview-vue',