@shijiu/jsview 1.9.829 → 1.9.839

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,6 +1,6 @@
1
1
  import './browser-root-style.css'
2
2
 
3
- import JsvCodeDebug from './jsv-code-debug'
3
+ import JsvCodeDebug from './jsv-code-debug.mjs'
4
4
 
5
5
  let domBrowser;
6
6
 
package/dom/jsv-dom.js CHANGED
@@ -1,4 +1,4 @@
1
- import JsvCodeDebug from './jsv-code-debug'
1
+ import JsvCodeDebug from './jsv-code-debug.mjs'
2
2
 
3
3
  let domNative;
4
4
 
@@ -1,4 +1,4 @@
1
- import JsvCodeDebug from "./jsv-code-debug"
1
+ import JsvCodeDebug from "./jsv-code-debug.mjs"
2
2
 
3
3
  let engineBrowser;
4
4
 
@@ -1,4 +1,4 @@
1
- import JsvCodeDebug from './jsv-code-debug'
1
+ import JsvCodeDebug from './jsv-code-debug.mjs'
2
2
 
3
3
  let forgeDefine;
4
4
 
@@ -52,6 +52,9 @@ export default class JsViewLoader {
52
52
  // 加载jsv-dom的调试版本
53
53
  await import("../dom/jsv-browser-debug-dom.js");
54
54
 
55
+ // 将jsv-forge-define单独做chunk, 解决npm run build后出现的循环import问题。
56
+ await import("../dom/jsv-forge-define.js");
57
+
55
58
  this.#forgeAppClass = JsViewBrowserForgeApp;
56
59
  }
57
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shijiu/jsview",
3
- "version": "1.9.829",
3
+ "version": "1.9.839",
4
4
  "bin": {
5
5
  "jsview-post-build": "./tools/jsview-post-build.js",
6
6
  "jsview-post-install": "./tools/jsview-post-install.js"
@@ -0,0 +1,125 @@
1
+ import path, { resolve } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { readFileSync } from 'node:fs';
4
+
5
+ const { version } = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url)).toString());
6
+ const VERSION = version;
7
+ const DEFAULT_MAIN_FIELDS = [
8
+ 'module',
9
+ 'jsnext:main',
10
+ 'jsnext',
11
+ ];
12
+ // Baseline support browserslist
13
+ // "defaults and supports es6-module and supports es6-module-dynamic-import"
14
+ // Higher browser versions may be needed for extra features.
15
+ const ESBUILD_MODULES_TARGET = [
16
+ // JsView Modified >>>
17
+ // 解决对top-level-await的原生支持问题。
18
+ //'es2020',
19
+ //'edge88',
20
+ //'firefox78',
21
+ //'chrome87',
22
+ //'safari14',
23
+ 'es2022',
24
+ // JsView Modified <<<
25
+ ];
26
+ const DEFAULT_EXTENSIONS = [
27
+ '.mjs',
28
+ '.js',
29
+ '.mts',
30
+ '.ts',
31
+ '.jsx',
32
+ '.tsx',
33
+ '.json',
34
+ ];
35
+ const DEFAULT_CONFIG_FILES = [
36
+ 'vite.config.js',
37
+ 'vite.config.mjs',
38
+ 'vite.config.ts',
39
+ 'vite.config.cjs',
40
+ 'vite.config.mts',
41
+ 'vite.config.cts',
42
+ ];
43
+ const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
44
+ const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
45
+ const OPTIMIZABLE_ENTRY_RE = /\.[cm]?[jt]s$/;
46
+ const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
47
+ /**
48
+ * Prefix for resolved fs paths, since windows paths may not be valid as URLs.
49
+ */
50
+ const FS_PREFIX = `/@fs/`;
51
+ /**
52
+ * Prefix for resolved Ids that are not valid browser import specifiers
53
+ */
54
+ const VALID_ID_PREFIX = `/@id/`;
55
+ /**
56
+ * Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
57
+ * module ID with `\0`, a convention from the rollup ecosystem.
58
+ * This prevents other plugins from trying to process the id (like node resolution),
59
+ * and core features like sourcemaps can use this info to differentiate between
60
+ * virtual modules and regular files.
61
+ * `\0` is not a permitted char in import URLs so we have to replace them during
62
+ * import analysis. The id will be decoded back before entering the plugins pipeline.
63
+ * These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
64
+ * modules in the browser end up encoded as `/@id/__x00__{id}`
65
+ */
66
+ const NULL_BYTE_PLACEHOLDER = `__x00__`;
67
+ const CLIENT_PUBLIC_PATH = `/@vite/client`;
68
+ const ENV_PUBLIC_PATH = `/@vite/env`;
69
+ const VITE_PACKAGE_DIR = resolve(
70
+ // import.meta.url is `dist/node/constants.js` after bundle
71
+ fileURLToPath(import.meta.url), '../../..');
72
+ const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
73
+ const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
74
+ const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
75
+ // ** READ THIS ** before editing `KNOWN_ASSET_TYPES`.
76
+ // If you add an asset to `KNOWN_ASSET_TYPES`, make sure to also add it
77
+ // to the TypeScript declaration file `packages/vite/client.d.ts` and
78
+ // add a mime type to the `registerCustomMime` in
79
+ // `packages/vite/src/node/plugin/assets.ts` if mime type cannot be
80
+ // looked up by mrmime.
81
+ const KNOWN_ASSET_TYPES = [
82
+ // images
83
+ 'png',
84
+ 'jpe?g',
85
+ 'jfif',
86
+ 'pjpeg',
87
+ 'pjp',
88
+ 'gif',
89
+ 'svg',
90
+ 'ico',
91
+ 'webp',
92
+ 'avif',
93
+ // media
94
+ 'mp4',
95
+ 'webm',
96
+ 'ogg',
97
+ 'mp3',
98
+ 'wav',
99
+ 'flac',
100
+ 'aac',
101
+ // fonts
102
+ 'woff2?',
103
+ 'eot',
104
+ 'ttf',
105
+ 'otf',
106
+ // other
107
+ 'webmanifest',
108
+ 'pdf',
109
+ 'txt',
110
+ ];
111
+ const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
112
+ const DEP_VERSION_RE = /[?&](v=[\w.-]+)\b/;
113
+ const loopbackHosts = new Set([
114
+ 'localhost',
115
+ '127.0.0.1',
116
+ '::1',
117
+ '0000:0000:0000:0000:0000:0000:0000:0001',
118
+ ]);
119
+ const wildcardHosts = new Set([
120
+ '0.0.0.0',
121
+ '::',
122
+ '0000:0000:0000:0000:0000:0000:0000:0000',
123
+ ]);
124
+
125
+ export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
@@ -24,12 +24,16 @@ const jsviewConfig = defineConfig({
24
24
  },
25
25
  rollupOptions: {
26
26
  output: {
27
- format: 'esm',
28
- entryFileNames: 'js/main.jsv.[hash].js',
27
+ assetFileNames: (chunkInfo) => chunkInfo.name.endsWith('.css')
28
+ ? 'css/[name].[hash].css' : 'assets/[name].[hash].[ext]',
29
29
  //chunkFileNames: 'js/[name].[hash].js',
30
30
  chunkFileNames: 'js/chunk.jsv.[hash].js',
31
- assetFileNames: (chunkInfo) => chunkInfo.name.endsWith('.css')
32
- ? 'css/[name].[hash].css' : 'assets/[name].[hash].[ext]'
31
+ entryFileNames: 'js/main.jsv.[hash].js',
32
+ format: 'esm',
33
+ manualChunks: {
34
+ 'export-sfc': ['\0plugin-vue:export-helper'], // 将_export_sfc独立出来,防止被集成在jsview-vue中导致import deadloop.
35
+ 'vue': ['vue'], // 将vue独立出来,防止被集成在main.js中导致import deadloop.
36
+ },
33
37
  },
34
38
  },
35
39
  sourcemap: true,
@@ -179,7 +179,7 @@ function getOptions(framework)
179
179
  options.jsviewPatchesDir = path.resolve(options.jsviewDir, 'patches');
180
180
  options.jsviewPatchModulesDir = path.resolve(options.jsviewPatchesDir, 'node_modules');
181
181
  options.jsviewToolsDir = path.resolve(options.jsviewDir, 'tools');
182
- options.jsviewRevisionFile = path.resolve(options.jsviewDir, 'dom', 'target_core_revision.mjs');
182
+ options.jsviewDomRevisionFile = path.resolve(options.jsviewDir, 'dom', 'target_core_revision.mjs');
183
183
 
184
184
  options.jsviewVueDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-vue');
185
185
  options.jsviewReactDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-react');
@@ -286,7 +286,20 @@ function execCommand(cmdline, withOutput)
286
286
  }
287
287
  }
288
288
 
289
+ function checkNodeVersion(minMajorVersion = 16)
290
+ {
291
+ const versions = process.version.replace('v', '').split('.');
292
+ const [majorVersion, minorVersion, patchVersion] = versions;
293
+
294
+ console.log(`Node version: v${majorVersion}.${minorVersion}.${patchVersion}`);
295
+ if (majorVersion < minMajorVersion) {
296
+ console.error('JsView Error: Node version is too low! Please upgrade your Node.js first.');
297
+ process.exit(1);
298
+ }
299
+ }
300
+
289
301
  module.exports = {
302
+ checkNodeVersion,
290
303
  cpSync,
291
304
  execCommand,
292
305
  getOptions,
@@ -4,7 +4,10 @@
4
4
  const crypto = require('crypto');
5
5
  const fs = require('fs');
6
6
  const path = require('path');
7
- const { getOptions } = require('./jsview-common');
7
+ const {
8
+ checkNodeVersion,
9
+ getOptions,
10
+ } = require('./jsview-common');
8
11
 
9
12
  // main.js处理AppData信息
10
13
  async function prepareMainAppData(options, fileMd5)
@@ -175,6 +178,8 @@ function makeDebugMap(options)
175
178
 
176
179
  async function main()
177
180
  {
181
+ checkNodeVersion();
182
+
178
183
  const options = getOptions();
179
184
 
180
185
  const vueConfigFile = path.resolve(options.projectDir, 'vue.config.js');
@@ -5,6 +5,7 @@ const fs = require('fs');
5
5
  const path = require('path');
6
6
  const url = require('url');
7
7
  const {
8
+ checkNodeVersion,
8
9
  cpSync,
9
10
  execCommand,
10
11
  getOptions,
@@ -127,7 +128,7 @@ function installPatches(options, pkgNeedPatch)
127
128
 
128
129
  async function printRevision(options)
129
130
  {
130
- const jsviewVersionURL = url.pathToFileURL(options.jsviewRevisionFile);
131
+ const jsviewVersionURL = url.pathToFileURL(options.jsviewDomRevisionFile);
131
132
  const { default: jsviewTargetVersion } = await import(jsviewVersionURL);
132
133
 
133
134
  console.log('**************************************************');
@@ -188,6 +189,8 @@ function doPostInstall(framework, pkgNeedPatch, skipCheckVersion)
188
189
 
189
190
  function main(argv)
190
191
  {
192
+ checkNodeVersion();
193
+
191
194
  let pkgNeedPatch;
192
195
 
193
196
  switch (argv.framework) {
@@ -5,6 +5,7 @@ const childProcess = require('child_process');
5
5
  const path = require('path');
6
6
  const url = require('url');
7
7
  const {
8
+ checkNodeVersion,
8
9
  getOptions,
9
10
  parseArguments
10
11
  } = require('./jsview-common');
@@ -21,8 +22,8 @@ async function getExtraOptions(argv)
21
22
  options.androidPackage = argv.unparsed[0];
22
23
  }
23
24
 
24
- const jsviewRevisionFile = url.pathToFileURL(options.jsviewRevisionFile);
25
- const { default: jsviewTargetRevision } = await import(jsviewRevisionFile);
25
+ const jsviewDomRevisionFile = url.pathToFileURL(options.jsviewDomRevisionFile);
26
+ const { default: jsviewTargetRevision } = await import(jsviewDomRevisionFile);
26
27
  options.jsviewCoreRevision = jsviewTargetRevision.CoreRevision;
27
28
  options.jsviewEngineUrl = jsviewTargetRevision.JseUrl;
28
29
 
@@ -65,6 +66,8 @@ function androidStartActivity(options)
65
66
 
66
67
  async function main(argv)
67
68
  {
69
+ checkNodeVersion();
70
+
68
71
  const options = await getExtraOptions(argv);
69
72
 
70
73
  printRevision(options);