fast-vue-multi-pages 1.0.1 → 1.0.2

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,18 +3,5 @@ export declare class FastVueMultiClipboard {
3
3
  * 将内容复制到剪贴板中
4
4
  * @param content
5
5
  */
6
- static copy(content: string): Promise<void>;
7
- /**
8
- * 将blob复制到剪贴板中
9
- * @param blob
10
- */
11
- static copyBlob(blob: Blob): Promise<void>;
12
- /**
13
- * 获取剪贴板的文本内容
14
- */
15
- static getText(): Promise<string | undefined>;
16
- /**
17
- * 获取剪贴板的ClipboardItem内容
18
- */
19
- static getItems(): Promise<ClipboardItems | undefined>;
6
+ static copy(content: string): void;
20
7
  }
@@ -1,40 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FastVueMultiClipboard = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const copy_to_clipboard_1 = tslib_1.__importDefault(require("copy-to-clipboard"));
4
6
  class FastVueMultiClipboard {
5
7
  /**
6
8
  * 将内容复制到剪贴板中
7
9
  * @param content
8
10
  */
9
11
  static copy(content) {
10
- const clipboard = require("clipboard-polyfill");
11
- return clipboard.writeText(content);
12
- }
13
- /**
14
- * 将blob复制到剪贴板中
15
- * @param blob
16
- */
17
- static copyBlob(blob) {
18
- const clipboard = require("clipboard-polyfill");
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
- const clipboard = require("clipboard-polyfill");
30
- return await clipboard.readText();
31
- }
32
- /**
33
- * 获取剪贴板的ClipboardItem内容
34
- */
35
- static async getItems() {
36
- const clipboard = require("clipboard-polyfill");
37
- return await clipboard.read();
12
+ (0, copy_to_clipboard_1.default)(content);
38
13
  }
39
14
  }
40
15
  exports.FastVueMultiClipboard = FastVueMultiClipboard;
@@ -3,18 +3,5 @@ export declare class FastVueMultiClipboard {
3
3
  * 将内容复制到剪贴板中
4
4
  * @param content
5
5
  */
6
- static copy(content: string): Promise<void>;
7
- /**
8
- * 将blob复制到剪贴板中
9
- * @param blob
10
- */
11
- static copyBlob(blob: Blob): Promise<void>;
12
- /**
13
- * 获取剪贴板的文本内容
14
- */
15
- static getText(): Promise<string | undefined>;
16
- /**
17
- * 获取剪贴板的ClipboardItem内容
18
- */
19
- static getItems(): Promise<ClipboardItems | undefined>;
6
+ static copy(content: string): void;
20
7
  }
@@ -1,7 +1,8 @@
1
- define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
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
+ copy_to_clipboard_1 = tslib_1.__importDefault(copy_to_clipboard_1);
5
6
  var FastVueMultiClipboard = /** @class */ (function () {
6
7
  function FastVueMultiClipboard() {
7
8
  }
@@ -10,52 +11,7 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) {
10
11
  * @param content
11
12
  */
12
13
  FastVueMultiClipboard.copy = function (content) {
13
- var clipboard = require("clipboard-polyfill");
14
- return clipboard.writeText(content);
15
- };
16
- /**
17
- * 将blob复制到剪贴板中
18
- * @param blob
19
- */
20
- FastVueMultiClipboard.copyBlob = function (blob) {
21
- var clipboard = require("clipboard-polyfill");
22
- var contentType = blob.type;
23
- var items = {};
24
- items[contentType] = blob;
25
- var item = new clipboard.ClipboardItem(items);
26
- return clipboard.write([item]);
27
- };
28
- /**
29
- * 获取剪贴板的文本内容
30
- */
31
- FastVueMultiClipboard.getText = function () {
32
- return tslib_1.__awaiter(this, void 0, void 0, function () {
33
- var clipboard;
34
- return tslib_1.__generator(this, function (_a) {
35
- switch (_a.label) {
36
- case 0:
37
- clipboard = require("clipboard-polyfill");
38
- return [4 /*yield*/, clipboard.readText()];
39
- case 1: return [2 /*return*/, _a.sent()];
40
- }
41
- });
42
- });
43
- };
44
- /**
45
- * 获取剪贴板的ClipboardItem内容
46
- */
47
- FastVueMultiClipboard.getItems = function () {
48
- return tslib_1.__awaiter(this, void 0, void 0, function () {
49
- var clipboard;
50
- return tslib_1.__generator(this, function (_a) {
51
- switch (_a.label) {
52
- case 0:
53
- clipboard = require("clipboard-polyfill");
54
- return [4 /*yield*/, clipboard.read()];
55
- case 1: return [2 /*return*/, _a.sent()];
56
- }
57
- });
58
- });
14
+ (0, copy_to_clipboard_1.default)(content);
59
15
  };
60
16
  return FastVueMultiClipboard;
61
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.1",
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
  */