fast-vue-multi-pages 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,7 @@
1
- import * as clipboard from "clipboard-polyfill";
2
1
  export declare class FastVueMultiClipboard {
3
2
  /**
4
3
  * 将内容复制到剪贴板中
5
4
  * @param content
6
5
  */
7
- static copy(content: string): Promise<void>;
8
- /**
9
- * 将blob复制到剪贴板中
10
- * @param blob
11
- */
12
- static copyBlob(blob: Blob): Promise<void>;
13
- /**
14
- * 获取剪贴板的文本内容
15
- */
16
- static getText(): Promise<string | undefined>;
17
- /**
18
- * 获取剪贴板的ClipboardItem内容
19
- */
20
- static getItems(): Promise<clipboard.ClipboardItems | undefined>;
6
+ static copy(content: string): void;
21
7
  }
@@ -2,37 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FastVueMultiClipboard = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const clipboard = tslib_1.__importStar(require("clipboard-polyfill"));
5
+ const copy_to_clipboard_1 = tslib_1.__importDefault(require("copy-to-clipboard"));
6
6
  class FastVueMultiClipboard {
7
7
  /**
8
8
  * 将内容复制到剪贴板中
9
9
  * @param content
10
10
  */
11
11
  static copy(content) {
12
- return clipboard.writeText(content);
13
- }
14
- /**
15
- * 将blob复制到剪贴板中
16
- * @param blob
17
- */
18
- static copyBlob(blob) {
19
- let contentType = blob.type;
20
- let items = {};
21
- items[contentType] = blob;
22
- const item = new clipboard.ClipboardItem(items);
23
- return clipboard.write([item]);
24
- }
25
- /**
26
- * 获取剪贴板的文本内容
27
- */
28
- static async getText() {
29
- return await clipboard.readText();
30
- }
31
- /**
32
- * 获取剪贴板的ClipboardItem内容
33
- */
34
- static async getItems() {
35
- return await clipboard.read();
12
+ (0, copy_to_clipboard_1.default)(content);
36
13
  }
37
14
  }
38
15
  exports.FastVueMultiClipboard = FastVueMultiClipboard;
@@ -1,21 +1,7 @@
1
- import * as clipboard from "clipboard-polyfill";
2
1
  export declare class FastVueMultiClipboard {
3
2
  /**
4
3
  * 将内容复制到剪贴板中
5
4
  * @param content
6
5
  */
7
- static copy(content: string): Promise<void>;
8
- /**
9
- * 将blob复制到剪贴板中
10
- * @param blob
11
- */
12
- static copyBlob(blob: Blob): Promise<void>;
13
- /**
14
- * 获取剪贴板的文本内容
15
- */
16
- static getText(): Promise<string | undefined>;
17
- /**
18
- * 获取剪贴板的ClipboardItem内容
19
- */
20
- static getItems(): Promise<clipboard.ClipboardItems | undefined>;
6
+ static copy(content: string): void;
21
7
  }
@@ -1,8 +1,8 @@
1
- define(["require", "exports", "tslib", "clipboard-polyfill"], function (require, exports, tslib_1, clipboard) {
1
+ define(["require", "exports", "tslib", "copy-to-clipboard"], function (require, exports, tslib_1, copy_to_clipboard_1) {
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.FastVueMultiClipboard = void 0;
5
- clipboard = tslib_1.__importStar(clipboard);
5
+ copy_to_clipboard_1 = tslib_1.__importDefault(copy_to_clipboard_1);
6
6
  var FastVueMultiClipboard = /** @class */ (function () {
7
7
  function FastVueMultiClipboard() {
8
8
  }
@@ -11,44 +11,7 @@ define(["require", "exports", "tslib", "clipboard-polyfill"], function (require,
11
11
  * @param content
12
12
  */
13
13
  FastVueMultiClipboard.copy = function (content) {
14
- return clipboard.writeText(content);
15
- };
16
- /**
17
- * 将blob复制到剪贴板中
18
- * @param blob
19
- */
20
- FastVueMultiClipboard.copyBlob = function (blob) {
21
- var contentType = blob.type;
22
- var items = {};
23
- items[contentType] = blob;
24
- var item = new clipboard.ClipboardItem(items);
25
- return clipboard.write([item]);
26
- };
27
- /**
28
- * 获取剪贴板的文本内容
29
- */
30
- FastVueMultiClipboard.getText = function () {
31
- return tslib_1.__awaiter(this, void 0, void 0, function () {
32
- return tslib_1.__generator(this, function (_a) {
33
- switch (_a.label) {
34
- case 0: return [4 /*yield*/, clipboard.readText()];
35
- case 1: return [2 /*return*/, _a.sent()];
36
- }
37
- });
38
- });
39
- };
40
- /**
41
- * 获取剪贴板的ClipboardItem内容
42
- */
43
- FastVueMultiClipboard.getItems = function () {
44
- return tslib_1.__awaiter(this, void 0, void 0, function () {
45
- return tslib_1.__generator(this, function (_a) {
46
- switch (_a.label) {
47
- case 0: return [4 /*yield*/, clipboard.read()];
48
- case 1: return [2 /*return*/, _a.sent()];
49
- }
50
- });
51
- });
14
+ (0, copy_to_clipboard_1.default)(content);
52
15
  };
53
16
  return FastVueMultiClipboard;
54
17
  }());
@@ -0,0 +1,2 @@
1
+ declare const htmlparser2: any;
2
+ declare const singleTag: string[];
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ const htmlparser2 = require("htmlparser2");
3
+ const singleTag = ["br", "hr", "img", "input", "param", "meta", "link", "slot"];
4
+ /**
5
+ * 标签builder插件,用来处理是否排除标签内的代码
6
+ * @author Janesen
7
+ * @param source
8
+ */
9
+ module.exports = function (source) {
10
+ //对应配置的options
11
+ // @ts-ignore
12
+ let legacyLoaderConfig = this.query;
13
+ let parseNewHtml = "";
14
+ let isBreak = false, hasResolve = false;
15
+ const tagName = legacyLoaderConfig.buildLevelTagName;
16
+ const parser = new htmlparser2.Parser({
17
+ onopentag(name, attributes) {
18
+ if (isBreak) {
19
+ return;
20
+ }
21
+ let attr = "";
22
+ let buildConfig = {
23
+ level: 1,
24
+ };
25
+ for (let attributesKey in attributes) {
26
+ let attributesValue = attributes[attributesKey];
27
+ if (attributesValue.length === 0) {
28
+ attr += " " + attributesKey;
29
+ continue;
30
+ }
31
+ if (attributesKey === "level") {
32
+ buildConfig.level = parseInt(attributesValue);
33
+ }
34
+ attr += " " + attributesKey + "=\"" + attributesValue + "\"";
35
+ }
36
+ if (name === tagName) {
37
+ hasResolve = true;
38
+ if (legacyLoaderConfig.buildLevel < buildConfig.level) {
39
+ isBreak = true;
40
+ }
41
+ }
42
+ else {
43
+ if (attr.length > 0) {
44
+ parseNewHtml += "<" + name + " " + attr + " ";
45
+ }
46
+ else {
47
+ parseNewHtml += "<" + name;
48
+ }
49
+ if (singleTag.indexOf(name) >= 0) {
50
+ parseNewHtml += "/>";
51
+ }
52
+ else {
53
+ parseNewHtml += ">";
54
+ }
55
+ }
56
+ },
57
+ ontext(text) {
58
+ if (isBreak) {
59
+ return;
60
+ }
61
+ parseNewHtml += text;
62
+ },
63
+ onclosetag(name) {
64
+ if (name === tagName) {
65
+ isBreak = false;
66
+ }
67
+ if (isBreak) {
68
+ return;
69
+ }
70
+ if (singleTag.indexOf(name) >= 0) {
71
+ return;
72
+ }
73
+ if (name === tagName) {
74
+ return;
75
+ }
76
+ parseNewHtml += "</" + name + ">";
77
+ },
78
+ }, {
79
+ recognizeSelfClosing: true,
80
+ lowerCaseTags: false,
81
+ lowerCaseAttributeNames: false
82
+ });
83
+ parser.write(source);
84
+ parser.end();
85
+ if (hasResolve) {
86
+ return parseNewHtml;
87
+ }
88
+ return source;
89
+ };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "fast-vue-multi-pages",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "author": "janesen",
5
5
  "description": "快速搭建VUE项目工具类的基本库,主要用于每个功能页面独立生成html",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/esm/index.js",
8
8
  "scripts": {
9
- "tsc": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && tsc -p ./src/vue/tsconfig-cjs.json",
9
+ "tsc": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && tsc -p ./src/vue/tsconfig-cjs.json && tsc -p ./src/loader/tsconfig-cjs.json",
10
10
  "login": "npm login",
11
11
  "buildLocal": "npm run tsc",
12
12
  "push-fastchar-appjs": "npm run buildLocal && npm publish"
@@ -29,8 +29,8 @@
29
29
  "store2": "^2.14.3",
30
30
  "moment": "^2.30.1",
31
31
  "@types/js-cookie": "^3.0.6",
32
- "clipboard-polyfill": "^4.1.0",
33
- "@types/lodash": "^4.17.6"
32
+ "@types/lodash": "^4.17.6",
33
+ "copy-to-clipboard": "^3.3.3"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@typescript-eslint/eslint-plugin": "^7.16.0",
@@ -43,7 +43,8 @@
43
43
  "files": [
44
44
  "dist/cjs",
45
45
  "dist/esm",
46
- "vue"
46
+ "vue",
47
+ "loader"
47
48
  ],
48
49
  "eslintConfig": {
49
50
  "root": true,
@@ -10,7 +10,7 @@ export declare class FastVueMultiPages {
10
10
  * @param dirName 项目根目录,建议取值 {@link __dirname}
11
11
  * @param options 更多选项配置 {@link FastBuildOption}
12
12
  */
13
- static getDefaultVueConfig(dirName: string, options: FastBuildOption): any;
13
+ static getVueConfig(dirName: string, options: FastBuildOption): any;
14
14
  /**
15
15
  * 设置全局变量值
16
16
  * @param key 变量名
@@ -42,14 +42,6 @@ export declare class FastVueMultiPages {
42
42
  * @param argument
43
43
  */
44
44
  static getScriptArgumentValue(argument: string): string | null;
45
- /**
46
- * 获取命令参数 --src
47
- */
48
- static getSrcPageDir(): string | null;
49
- /**
50
- * 获取命令参数 --out
51
- */
52
- static getOutPageDir(): string | null;
53
45
  /**
54
46
  * 获取命令参数 --debug 的值
55
47
  */
@@ -15,7 +15,7 @@ class FastVueMultiPages {
15
15
  * @param dirName 项目根目录,建议取值 {@link __dirname}
16
16
  * @param options 更多选项配置 {@link FastBuildOption}
17
17
  */
18
- static getDefaultVueConfig(dirName, options) {
18
+ static getVueConfig(dirName, options) {
19
19
  if (options) {
20
20
  options = FastBuildOption_1.FastBuildOption.merge(options, new FastBuildOption_1.FastBuildOption());
21
21
  }
@@ -74,13 +74,9 @@ class FastVueMultiPages {
74
74
  const cacheDir = path.join(dirName, options.nodeModulesDir, ".cache", "vue-loader");
75
75
  this.removeFile(cacheDir);
76
76
  }
77
- let outPageDir = this.getOutPageDir();
78
- if (!outPageDir) {
79
- outPageDir = options.projectOutDir;
80
- }
81
77
  const { defineConfig } = require('@vue/cli-service');
82
78
  return defineConfig({
83
- outputDir: outPageDir,
79
+ outputDir: options.projectOutDir,
84
80
  assetsDir: options.projectAssetsDir,
85
81
  productionSourceMap: false,
86
82
  publicPath: this.isVueCliServerBuild() ? "./" : '/',
@@ -90,7 +86,7 @@ class FastVueMultiPages {
90
86
  extract: false, //取消css单独生成文件
91
87
  },
92
88
  chainWebpack: (config) => {
93
- let tagLoaderPath = "fast-vue-multi-pages/dist/cjs/loader/FastTagBuilderLoader";
89
+ let tagLoaderPath = "fast-vue-multi-pages/loader";
94
90
  //版本标签加载器
95
91
  config.module
96
92
  .rule('vue')
@@ -244,18 +240,6 @@ class FastVueMultiPages {
244
240
  }
245
241
  return null;
246
242
  }
247
- /**
248
- * 获取命令参数 --src
249
- */
250
- static getSrcPageDir() {
251
- return this.getScriptArgumentValue("--src");
252
- }
253
- /**
254
- * 获取命令参数 --out
255
- */
256
- static getOutPageDir() {
257
- return this.getScriptArgumentValue("--out");
258
- }
259
243
  /**
260
244
  * 获取命令参数 --debug 的值
261
245
  */
@@ -1,13 +0,0 @@
1
- export declare class FastVueMultiStore {
2
- /**
3
- * 设置缓存的值
4
- * @param key 键
5
- * @param value 值
6
- */
7
- static setValue(key: string, value: any): void;
8
- /**
9
- * 获取缓存的值
10
- * @param key 键
11
- */
12
- static getValue(key: string): any;
13
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FastVueMultiStore = void 0;
4
- const tslib_1 = require("tslib");
5
- const store2_1 = tslib_1.__importDefault(require("store2"));
6
- class FastVueMultiStore {
7
- /**
8
- * 设置缓存的值
9
- * @param key 键
10
- * @param value 值
11
- */
12
- static setValue(key, value) {
13
- store2_1.default.set(key, value, true);
14
- }
15
- /**
16
- * 获取缓存的值
17
- * @param key 键
18
- */
19
- static getValue(key) {
20
- return store2_1.default.get(key);
21
- }
22
- }
23
- exports.FastVueMultiStore = FastVueMultiStore;
@@ -1,13 +0,0 @@
1
- export declare class FastVueMultiStore {
2
- /**
3
- * 设置缓存的值
4
- * @param key 键
5
- * @param value 值
6
- */
7
- static setValue(key: string, value: any): void;
8
- /**
9
- * 获取缓存的值
10
- * @param key 键
11
- */
12
- static getValue(key: string): any;
13
- }
@@ -1,27 +0,0 @@
1
- define(["require", "exports", "tslib", "store2"], function (require, exports, tslib_1, store2_1) {
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.FastVueMultiStore = void 0;
5
- store2_1 = tslib_1.__importDefault(store2_1);
6
- var FastVueMultiStore = /** @class */ (function () {
7
- function FastVueMultiStore() {
8
- }
9
- /**
10
- * 设置缓存的值
11
- * @param key 键
12
- * @param value 值
13
- */
14
- FastVueMultiStore.setValue = function (key, value) {
15
- store2_1.default.set(key, value, true);
16
- };
17
- /**
18
- * 获取缓存的值
19
- * @param key 键
20
- */
21
- FastVueMultiStore.getValue = function (key) {
22
- return store2_1.default.get(key);
23
- };
24
- return FastVueMultiStore;
25
- }());
26
- exports.FastVueMultiStore = FastVueMultiStore;
27
- });