@shijiu/jsview 1.9.760 → 1.9.779

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.
Files changed (34) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -1
  2. package/dom/bin/jsview-dom.min.js +1 -1
  3. package/dom/bin/jsview-engine-js-browser.min.js +1 -1
  4. package/dom/jsv-dom.js +3 -1
  5. package/loader/loader.js +3 -3
  6. package/package.json +7 -8
  7. package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +3085 -2968
  8. package/patches/node_modules/@vue/compiler-sfc/package.json +6 -6
  9. package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +8123 -8038
  10. package/patches/node_modules/@vue/runtime-core/package.json +3 -3
  11. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1681 -1663
  12. package/patches/node_modules/@vue/runtime-dom/package.json +3 -3
  13. package/patches/node_modules/react-dom/cjs/react-dom.development.js +29868 -0
  14. package/patches/node_modules/react-dom/cjs/react-dom.production.min.js +323 -0
  15. package/patches/node_modules/react-dom/package.json +62 -0
  16. package/patches/node_modules/react-scripts/config/paths.js +4 -1
  17. package/patches/node_modules/react-scripts/config/webpack.config.js +3 -3
  18. package/patches/node_modules/vite/dist/node/chunks/{dep-0fc8e132.js → dep-ed9cb113.js} +46837 -46866
  19. package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +155 -0
  20. package/patches/node_modules/vite/package.json +48 -39
  21. package/patches/node_modules/vue-router/dist/vue-router.mjs +22 -5
  22. package/patches/node_modules/vue-router/package.json +12 -12
  23. package/tools/jsview-common.js +169 -0
  24. package/tools/jsview-jsmap-serve.mjs +127 -0
  25. package/tools/jsview-post-build.js +63 -55
  26. package/tools/jsview-post-install.js +92 -42
  27. package/tools/jsview-run-android.js +46 -38
  28. package/patches/node_modules/vite/dist/node/jsview-react.vite.config.js +0 -7
  29. package/patches/node_modules/vite/dist/node/jsview-vue.vite.config.js +0 -7
  30. package/patches/node_modules/vite/dist/node/jsview.vite.config.js +0 -64
  31. package/tools/common.js +0 -63
  32. package/tools/jsview-jsmap-serve.js +0 -105
  33. package/tools/jsview-post-install-react.js +0 -15
  34. package/tools/jsview-post-install-vue.js +0 -20
@@ -0,0 +1,155 @@
1
+ import { defineConfig } from 'vite'
2
+ import fs from 'fs'
3
+ import path from 'path'
4
+ import fullReload from 'vite-plugin-full-reload';
5
+
6
+ // https://vitejs.dev/config/
7
+ const jsviewConfig = defineConfig({
8
+ assetsInclude: ['**/*.bmp'],
9
+ build: {
10
+ assetsInlineLimit: 0,
11
+ //cssTarget: 'css/', // 未生效
12
+ commonjsOptions: {
13
+ include: [
14
+ /js-binary-schema-parser/,
15
+ /gifuct-js/,
16
+ /qr.js/
17
+ ],
18
+ },
19
+ emptyOutDir: true,
20
+ minify: true,
21
+ modulePreload: {
22
+ polyfill: false
23
+ },
24
+ rollupOptions: {
25
+ output: {
26
+ format: 'esm',
27
+ entryFileNames: 'js/main.jsv.[hash].js',
28
+ //chunkFileNames: 'js/[name].[hash].js',
29
+ chunkFileNames: 'js/chunk.jsv.[hash].js',
30
+ assetFileNames: (chunkInfo) => chunkInfo.name.endsWith('.css')
31
+ ? 'css/[name].[hash].css' : 'assets/[name].[hash].[ext]'
32
+ },
33
+ },
34
+ sourcemap: true,
35
+ target: 'es2022', // 不转译async/await
36
+ },
37
+ isCustomElement: (tag) => {
38
+ return tag == 'fdiv' || tag.startsWith('jsv-')
39
+ },
40
+ optimizeDeps: {
41
+ include: [
42
+ 'gifuct-js',
43
+ 'qr.js'
44
+ ],
45
+ exclude: [
46
+ '@shijiu/jsview/loader/jsview-main.js', // 解决windows上出现解析异常的问题。
47
+ 'jsview',
48
+ 'jsview-vue',
49
+ 'jsview-vue-samples',
50
+ 'jsview-react-samples',
51
+ 'jsview-vue-samples',
52
+ 'node_modules/@shijiu',
53
+ ],
54
+ },
55
+ plugins: [
56
+ fullReload('node_modules/@shijiu/**/*'),
57
+ ],
58
+ resolve: {
59
+ alias: {
60
+ // 'jsview': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview'),
61
+ 'jsview-vue': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview-vue'),
62
+ 'jsview-vue-samples': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview-vue-samples'),
63
+ 'jsview-react': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview-react'),
64
+ 'jsview-react-samples': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview-react-samples'),
65
+ '/js/main.jsv.js': path.resolve(process.cwd(), 'node_modules/@shijiu/jsview/loader/jsview-main.js'),
66
+ },
67
+ preserveSymlinks: true
68
+ },
69
+ server: {
70
+ host: true,
71
+ open: process.platform === "darwin",
72
+ watch: {
73
+ ignored: [
74
+ '!**/node_modules/@shijiu/**',
75
+ ],
76
+ }
77
+ },
78
+ });
79
+
80
+ function getModuleDir() {
81
+ const moduleDir = path.resolve(process.cwd(), 'node_modules');
82
+ return moduleDir;
83
+ }
84
+
85
+ function ensureFramework(originConfig) {
86
+ const checkFramework = function (name) {
87
+ if (name.indexOf('vue') >= 0) {
88
+ return 'vue';
89
+ } else if (name.indexOf('react') >= 0) {
90
+ return 'react';
91
+ }
92
+
93
+ return null;
94
+
95
+ };
96
+
97
+ let framework = 'unknown';
98
+ for (const plugins of originConfig.plugins) {
99
+ if (Array.isArray(plugins)) {
100
+ for (const plugin of plugins) {
101
+ framework = checkFramework(plugin.name);
102
+ if (framework) {
103
+ break;
104
+ }
105
+ }
106
+ } else {
107
+ const plugin = plugins;
108
+ framework = checkFramework(plugin.name);
109
+ }
110
+ if (framework) {
111
+ break;
112
+ }
113
+ }
114
+
115
+ return framework;
116
+ }
117
+
118
+ function jsvCreateJsViewViteConfig(originConfig) {
119
+ let aliasJsView;
120
+
121
+ const moduleDir = getModuleDir();
122
+ const framework = ensureFramework(originConfig);
123
+ switch (framework) {
124
+ case 'vue':
125
+ aliasJsView = path.resolve(moduleDir, '@shijiu/jsview-vue');
126
+ break;
127
+ case 'react':
128
+ aliasJsView = path.resolve(moduleDir, '@shijiu/jsview-react');
129
+ break;
130
+ default:
131
+ throw new Error('JsView Error: Failed to support framework: ' + framework);
132
+ }
133
+
134
+ jsviewConfig.resolve.alias['jsview'] = aliasJsView;
135
+
136
+ return jsviewConfig;
137
+ }
138
+
139
+ function jsvSaveUrlToCache(urls) {
140
+ if ((urls?.network?.length ?? -1 )<= 0) {
141
+ console.error("JsView Error: Failed to find network info.");
142
+ return;
143
+ }
144
+
145
+ const moduleDir = getModuleDir();
146
+ const urlCacheDir = path.resolve(moduleDir, '.vite', 'jsview')
147
+ const urlCacheFilePath = path.resolve(urlCacheDir, 'network.mjs')
148
+ fs.mkdirSync(urlCacheDir, { recursive: true });
149
+ fs.writeFileSync(urlCacheFilePath, `export default "${urls.network[0]}"`)
150
+ }
151
+
152
+ export {
153
+ jsvCreateJsViewViteConfig,
154
+ jsvSaveUrlToCache,
155
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "3.0.9",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -28,7 +28,6 @@
28
28
  "dist",
29
29
  "client.d.ts",
30
30
  "index.cjs",
31
- "src/client",
32
31
  "types"
33
32
  ],
34
33
  "engines": {
@@ -47,87 +46,94 @@
47
46
  "dev": "rimraf dist && pnpm run build-bundle -w",
48
47
  "build": "rimraf dist && run-s build-bundle build-types",
49
48
  "build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",
50
- "build-types": "run-s build-temp-types patch-types roll-types check-dist-types",
51
- "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
52
- "patch-types": "tsx scripts/patchTypes.ts",
53
- "roll-types": "api-extractor run && rimraf temp",
54
- "check-dist-types": "tsc --project tsconfig.check.json",
49
+ "build-types": "run-s build-types-temp build-types-pre-patch build-types-roll build-types-post-patch build-types-check",
50
+ "build-types-temp": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
51
+ "build-types-pre-patch": "tsx scripts/prePatchTypes.ts",
52
+ "build-types-roll": "api-extractor run && rimraf temp",
53
+ "build-types-post-patch": "tsx scripts/postPatchTypes.ts",
54
+ "build-types-check": "tsx scripts/checkBuiltTypes.ts && tsc --project tsconfig.check.json",
55
55
  "lint": "eslint --cache --ext .ts src/**",
56
56
  "format": "prettier --write --cache --parser typescript \"src/**/*.ts\"",
57
57
  "prepublishOnly": "npm run build"
58
58
  },
59
59
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
60
60
  "dependencies": {
61
- "esbuild": "^0.14.47",
62
- "postcss": "^8.4.16",
61
+ "esbuild": "^0.16.3",
62
+ "postcss": "^8.4.19",
63
63
  "resolve": "^1.22.1",
64
- "rollup": ">=2.75.6 <2.77.0 || ~2.77.0"
64
+ "rollup": "^3.7.0"
65
65
  },
66
66
  "optionalDependencies": {
67
67
  "fsevents": "~2.3.2"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@ampproject/remapping": "^2.2.0",
71
- "@babel/parser": "^7.18.11",
72
- "@babel/types": "^7.18.10",
73
- "@jridgewell/trace-mapping": "^0.3.15",
74
- "@rollup/plugin-alias": "^3.1.9",
75
- "@rollup/plugin-commonjs": "^22.0.2",
76
- "@rollup/plugin-dynamic-import-vars": "^1.4.4",
77
- "@rollup/plugin-json": "^4.1.0",
78
- "@rollup/plugin-node-resolve": "13.3.0",
79
- "@rollup/plugin-typescript": "^8.3.4",
80
- "@rollup/pluginutils": "^4.2.1",
81
- "@vue/compiler-dom": "^3.2.37",
82
- "acorn": "^8.8.0",
83
- "cac": "^6.7.12",
71
+ "@babel/parser": "^7.20.5",
72
+ "@babel/types": "^7.20.5",
73
+ "@jridgewell/trace-mapping": "^0.3.17",
74
+ "@rollup/plugin-alias": "^4.0.2",
75
+ "@rollup/plugin-commonjs": "^23.0.3",
76
+ "@rollup/plugin-dynamic-import-vars": "^2.0.1",
77
+ "@rollup/plugin-json": "^5.0.2",
78
+ "@rollup/plugin-node-resolve": "15.0.1",
79
+ "@rollup/plugin-typescript": "^10.0.1",
80
+ "@rollup/pluginutils": "^5.0.2",
81
+ "acorn": "^8.8.1",
82
+ "acorn-walk": "^8.2.0",
83
+ "cac": "^6.7.14",
84
84
  "chokidar": "^3.5.3",
85
85
  "connect": "^3.7.0",
86
86
  "connect-history-api-fallback": "^2.0.0",
87
- "convert-source-map": "^1.8.0",
87
+ "convert-source-map": "^1.9.0",
88
88
  "cors": "^2.8.5",
89
89
  "cross-spawn": "^7.0.3",
90
90
  "debug": "^4.3.4",
91
- "dotenv": "^14.3.2",
92
- "dotenv-expand": "^5.1.0",
93
- "es-module-lexer": "^1.0.3",
91
+ "dep-types": "link:./src/types",
92
+ "dotenv": "^16.0.3",
93
+ "dotenv-expand": "^9.0.0",
94
+ "es-module-lexer": "^1.1.0",
94
95
  "estree-walker": "^3.0.1",
95
96
  "etag": "^1.8.1",
96
- "fast-glob": "^3.2.11",
97
+ "fast-glob": "^3.2.12",
97
98
  "http-proxy": "^1.18.1",
98
- "json5": "^2.2.1",
99
- "launch-editor-middleware": "^2.5.0",
100
- "magic-string": "^0.26.2",
99
+ "launch-editor-middleware": "^2.6.0",
100
+ "magic-string": "^0.27.0",
101
101
  "micromatch": "^4.0.5",
102
- "mlly": "^0.5.12",
102
+ "mlly": "^0.5.17",
103
103
  "mrmime": "^1.0.1",
104
104
  "okie": "^1.0.1",
105
105
  "open": "^8.4.0",
106
+ "parse5": "^7.1.2",
106
107
  "periscopic": "^3.0.4",
107
108
  "picocolors": "^1.0.0",
108
- "postcss-import": "^14.1.0",
109
+ "picomatch": "^2.3.1",
110
+ "postcss-import": "^15.0.1",
109
111
  "postcss-load-config": "^4.0.1",
110
- "postcss-modules": "^4.3.1",
112
+ "postcss-modules": "^6.0.0",
111
113
  "resolve.exports": "^1.1.0",
112
- "rollup-plugin-license": "^2.8.1",
113
114
  "sirv": "^2.0.2",
114
115
  "source-map-js": "^1.0.2",
115
116
  "source-map-support": "^0.5.21",
116
117
  "strip-ansi": "^7.0.1",
117
- "strip-literal": "^0.4.0",
118
+ "strip-literal": "^0.4.2",
118
119
  "tsconfck": "^2.0.1",
119
- "tslib": "^2.4.0",
120
+ "tslib": "^2.4.1",
120
121
  "types": "link:./types",
121
- "ufo": "^0.8.5",
122
- "ws": "^8.8.1"
122
+ "ufo": "^0.8.6",
123
+ "ws": "^8.11.0"
123
124
  },
124
125
  "peerDependencies": {
126
+ "@types/node": ">= 14",
125
127
  "less": "*",
126
128
  "sass": "*",
127
129
  "stylus": "*",
130
+ "sugarss": "*",
128
131
  "terser": "^5.4.0"
129
132
  },
130
133
  "peerDependenciesMeta": {
134
+ "@types/node": {
135
+ "optional": true
136
+ },
131
137
  "sass": {
132
138
  "optional": true
133
139
  },
@@ -137,6 +143,9 @@
137
143
  "less": {
138
144
  "optional": true
139
145
  },
146
+ "sugarss": {
147
+ "optional": true
148
+ },
140
149
  "terser": {
141
150
  "optional": true
142
151
  }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-router v4.1.4
2
+ * vue-router v4.1.6
3
3
  * (c) 2022 Eduardo San Martin Morote
4
4
  * @license MIT
5
5
  */
@@ -1349,7 +1349,14 @@ function createRouterMatcher(routes, globalOptions) {
1349
1349
  // if (parent && isAliasRecord(originalRecord)) {
1350
1350
  // parent.children.push(originalRecord)
1351
1351
  // }
1352
- insertMatcher(matcher);
1352
+ // Avoid adding a record that doesn't display anything. This allows passing through records without a component to
1353
+ // not be reached and pass through the catch all route
1354
+ if ((matcher.record.components &&
1355
+ Object.keys(matcher.record.components).length) ||
1356
+ matcher.record.name ||
1357
+ matcher.record.redirect) {
1358
+ insertMatcher(matcher);
1359
+ }
1353
1360
  }
1354
1361
  return originalMatcher
1355
1362
  ? () => {
@@ -1407,6 +1414,13 @@ function createRouterMatcher(routes, globalOptions) {
1407
1414
  throw createRouterError(1 /* ErrorTypes.MATCHER_NOT_FOUND */, {
1408
1415
  location,
1409
1416
  });
1417
+ // warn if the user is passing invalid params so they can debug it better when they get removed
1418
+ if ((process.env.NODE_ENV !== 'production')) {
1419
+ const invalidParams = Object.keys(location.params || {}).filter(paramName => !matcher.keys.find(k => k.name === paramName));
1420
+ if (invalidParams.length) {
1421
+ warn(`Discarded invalid param(s) "${invalidParams.join('", "')}" when navigating. See https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#414-2022-08-22 for more details.`);
1422
+ }
1423
+ }
1410
1424
  name = matcher.record.name;
1411
1425
  params = assign(
1412
1426
  // paramsFromLocation is a new object
@@ -1566,11 +1580,11 @@ function isSameParam(a, b) {
1566
1580
  function checkSameParams(a, b) {
1567
1581
  for (const key of a.keys) {
1568
1582
  if (!key.optional && !b.keys.find(isSameParam.bind(null, key)))
1569
- return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" should have the exact same param named "${key.name}"`);
1583
+ return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
1570
1584
  }
1571
1585
  for (const key of b.keys) {
1572
1586
  if (!key.optional && !a.keys.find(isSameParam.bind(null, key)))
1573
- return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" should have the exact same param named "${key.name}"`);
1587
+ return warn(`Alias "${b.record.path}" and the original record: "${a.record.path}" must have the exact same param named "${key.name}"`);
1574
1588
  }
1575
1589
  }
1576
1590
  /**
@@ -1590,7 +1604,7 @@ function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
1590
1604
  function checkMissingParamsInAbsolutePath(record, parent) {
1591
1605
  for (const key of parent.keys) {
1592
1606
  if (!record.keys.find(isSameParam.bind(null, key)))
1593
- return warn(`Absolute path "${record.record.path}" should have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
1607
+ return warn(`Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
1594
1608
  }
1595
1609
  }
1596
1610
  function isRecordChildOf(record, parent) {
@@ -2198,6 +2212,9 @@ function useLink(props) {
2198
2212
  }, { flush: 'post' });
2199
2213
  }
2200
2214
  }
2215
+ /**
2216
+ * NOTE: update {@link _RouterLinkI}'s `$slots` type when updating this
2217
+ */
2201
2218
  return {
2202
2219
  route,
2203
2220
  href: computed(() => route.value.href),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-router",
3
- "version": "4.1.4",
3
+ "version": "4.1.6",
4
4
  "main": "index.js",
5
5
  "unpkg": "dist/vue-router.global.js",
6
6
  "jsdelivr": "dist/vue-router.global.js",
@@ -55,7 +55,7 @@
55
55
  "attributes": "vetur/attributes.json"
56
56
  },
57
57
  "dependencies": {
58
- "@vue/devtools-api": "^6.1.4"
58
+ "@vue/devtools-api": "^6.4.5"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@microsoft/api-extractor": "^7.29.2",
@@ -66,21 +66,21 @@
66
66
  "@sucrase/jest-plugin": "^2.1.1",
67
67
  "@types/jest": "^27.4.1",
68
68
  "@types/jsdom": "^16.2.13",
69
- "@types/nightwatch": "^2.3.3",
69
+ "@types/nightwatch": "^2.3.12",
70
70
  "@vitejs/plugin-vue": "^2.3.3",
71
- "@vue/compiler-sfc": "^3.2.31",
72
- "@vue/server-renderer": "^3.2.37",
73
- "@vue/test-utils": "^2.0.2",
71
+ "@vue/compiler-sfc": "^3.2.41",
72
+ "@vue/server-renderer": "^3.2.41",
73
+ "@vue/test-utils": "^2.2.0",
74
74
  "browserstack-local": "^1.4.5",
75
- "chromedriver": "^102.0.0",
75
+ "chromedriver": "^106.0.1",
76
76
  "connect-history-api-fallback": "^1.6.0",
77
77
  "conventional-changelog-cli": "^2.1.1",
78
- "dotenv": "^16.0.0",
78
+ "dotenv": "^16.0.3",
79
79
  "faked-promise": "^2.2.2",
80
- "geckodriver": "^3.0.2",
80
+ "geckodriver": "^3.2.0",
81
81
  "jest": "^27.5.1",
82
82
  "jest-mock-warn": "^1.1.0",
83
- "nightwatch": "^2.3.0",
83
+ "nightwatch": "^2.4.1",
84
84
  "nightwatch-helpers": "^1.2.0",
85
85
  "rimraf": "^3.0.2",
86
86
  "rollup": "^2.78.0",
@@ -88,8 +88,8 @@
88
88
  "rollup-plugin-terser": "^7.0.2",
89
89
  "rollup-plugin-typescript2": "^0.32.1",
90
90
  "typescript": "~4.7.4",
91
- "vite": "^2.9.9",
92
- "vue": "^3.2.37"
91
+ "vite": "^3.1.8",
92
+ "vue": "^3.2.41"
93
93
  },
94
94
  "scripts": {
95
95
  "dev": "jest --watch",
@@ -0,0 +1,169 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+
7
+ function parseArguments(beginWithHyphen = true)
8
+ {
9
+ let options = {
10
+ unparsed: []
11
+ };
12
+
13
+ // arg0: node
14
+ // arg1: script.js
15
+ const arguList = process.argv.slice(2);
16
+ for (const argu of arguList) {
17
+ let [key, value] = argu.split('=');
18
+ if (argu.includes('=') == false) {
19
+ value = true;
20
+ }
21
+ if (key.startsWith('-') == false) {
22
+ if (beginWithHyphen) {
23
+ console.error('Failed to parse argument: ' + argu);
24
+ process.exit(1);
25
+ } else {
26
+ options.unparsed.push(key);
27
+ continue;
28
+ }
29
+ }
30
+
31
+ let formattedKey = key.replace(/^-*/, '');
32
+ formattedKey = formattedKey.replace(/-(.)/g, (x) => x[1].toUpperCase())
33
+
34
+ let formattedValue = value;
35
+ if (value === undefined
36
+ || value === null
37
+ || value === 'undefined'
38
+ || value === 'null'
39
+ || value === '') {
40
+ formattedValue = null;
41
+ }
42
+
43
+ options[formattedKey] = formattedValue;
44
+ }
45
+
46
+ return options;
47
+ }
48
+
49
+ /**************************************************
50
+ * jsview-test-project
51
+ * ├── dist
52
+ * │   ├── debug
53
+ * │   │   └── map
54
+ * │   └── js
55
+ * ├── node_modules
56
+ * │   ├── .vite
57
+ * │   │   └── jsview
58
+ * │   ├── @shijiu
59
+ * │   │   ├── jsview -> ../../../../@shijiu/jsview
60
+ * │   │   │   ├── dom
61
+ * │   │   │   │   ├── bin
62
+ * │   │   │   │   ├── code
63
+ * │   │   │   ├── loader
64
+ * │   │   │   ├── patches
65
+ * │   │   │   │   └── node_modules
66
+ * │   │   │   ├── tools
67
+ * │   │   ├── jsview-vue -> ../../../../@shijiu/jsview-vue
68
+ * │   │   │   └── utils
69
+ * │   │   └── jsview-vue-samples -> ../../../../@shijiu/jsview-vue-samples
70
+ * └── src
71
+ *    └── appConfig
72
+ **************************************************/
73
+ function getOptions(framework)
74
+ {
75
+ const options = {};
76
+
77
+ options.projectDir = process.cwd();
78
+
79
+ options.modulesDir = path.resolve(options.projectDir, 'node_modules');
80
+ options.jsviewDir = path.resolve(options.modulesDir, '@shijiu', 'jsview');
81
+ options.jsviewPatchesDir = path.resolve(options.jsviewDir, 'patches');
82
+ options.jsviewPatchModulesDir = path.resolve(options.jsviewPatchesDir, 'node_modules');
83
+ options.jsviewToolsDir = path.resolve(options.jsviewDir, 'tools');
84
+ options.jsviewRevisionFile = path.resolve(options.jsviewDir, 'dom', 'target_core_revision.mjs');
85
+
86
+ options.jsviewVueDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-vue');
87
+ options.jsviewReactDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-react');
88
+ if (framework) {
89
+ options.jsviewFrameworkDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-' + framework);
90
+ }
91
+
92
+ options.appConfigDir = path.resolve(options.projectDir, 'src', 'appConfig');
93
+
94
+ options.distDir = path.resolve(options.projectDir, 'dist');
95
+ options.distJsDir = path.resolve(options.distDir, 'js');
96
+ options.distDebugDir = path.resolve(options.distDir, 'debug');
97
+ options.distDebugMapDir = path.resolve(options.distDebugDir, 'map');
98
+
99
+ const cacheName = (framework == 'vue' ? '.vite' : '.cache');
100
+ options.cacheDir = path.resolve(options.modulesDir, cacheName);
101
+ options.baseUrlFile = path.resolve(options.cacheDir, 'jsview', 'network.mjs');
102
+
103
+ return options;
104
+ }
105
+
106
+ function getPackageObject(modulePath)
107
+ {
108
+ const pkgFullFile = path.resolve(modulePath, 'package.json');
109
+ if (!fs.existsSync(pkgFullFile)) {
110
+ console.error('Error: Failed to get ' + modulePath + ', file is not exists.');
111
+ process.exit(1);
112
+ }
113
+ const pkgObj = require(pkgFullFile);
114
+
115
+ return pkgObj;
116
+ }
117
+
118
+ function cpSync(workDir, src, dest, ignore=[])
119
+ {
120
+ const exists = fs.existsSync(src);
121
+ const stats = exists && fs.statSync(src);
122
+ const isDirectory = exists && stats.isDirectory();
123
+ if (isDirectory) {
124
+ if (fs.existsSync(dest) == false) {
125
+ fs.mkdirSync(dest);
126
+ }
127
+ const childFileNames = fs.readdirSync(src);
128
+ for (const childName of childFileNames) {
129
+ cpSync(
130
+ workDir,
131
+ path.join(src, childName),
132
+ path.join(dest, childName),
133
+ ignore
134
+ );
135
+ };
136
+ } else {
137
+ const filename = path.basename(src);
138
+ if (ignore && ignore.includes(filename)) {
139
+ return;
140
+ }
141
+ console.info(
142
+ ' ' + path.relative(workDir, src) + ' -> ' + path.relative(workDir, dest)
143
+ );
144
+ fs.copyFileSync(src, dest);
145
+ }
146
+ }
147
+
148
+ function rmSync(path)
149
+ {
150
+ fs.rmSync(path, { recursive: true, force: true });
151
+ }
152
+
153
+ function symlinkSync(target, to)
154
+ {
155
+ rmSync(to);
156
+
157
+ const targetPath = path.relative(path.dirname(to), target);
158
+
159
+ fs.symlinkSync(targetPath, to, 'dir');
160
+ }
161
+
162
+ module.exports = {
163
+ cpSync,
164
+ getOptions,
165
+ getPackageObject,
166
+ parseArguments,
167
+ rmSync,
168
+ symlinkSync,
169
+ }