@varlet/cli 2.0.5 → 2.1.0-alpha.1666877950844

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 (143) hide show
  1. package/README.en-US.md +2 -2
  2. package/README.md +2 -2
  3. package/cjs/babel.config.cjs +29 -0
  4. package/cjs/babel.sfc.transform.cjs +18 -0
  5. package/cjs/jest.config.cjs +33 -0
  6. package/cjs/jest.media.mock.cjs +1 -0
  7. package/cjs/jest.style.mock.cjs +1 -0
  8. package/client.d.ts +1 -0
  9. package/client.js +1 -0
  10. package/lib/client/appType.d.ts +4 -0
  11. package/lib/client/appType.js +7 -0
  12. package/lib/client/index.d.ts +17 -0
  13. package/lib/client/index.js +106 -0
  14. package/lib/{bin.d.ts → node/bin.d.ts} +2 -2
  15. package/lib/node/bin.js +122 -0
  16. package/lib/{commands → node/commands}/build.d.ts +1 -1
  17. package/lib/node/commands/build.js +15 -0
  18. package/lib/{commands → node/commands}/changelog.d.ts +6 -6
  19. package/lib/node/commands/changelog.js +20 -0
  20. package/lib/{commands → node/commands}/commitLint.d.ts +1 -1
  21. package/lib/node/commands/commitLint.js +45 -0
  22. package/lib/{commands → node/commands}/compile.d.ts +7 -7
  23. package/lib/node/commands/compile.js +35 -0
  24. package/lib/{commands → node/commands}/create.d.ts +8 -8
  25. package/lib/node/commands/create.js +91 -0
  26. package/lib/{commands → node/commands}/dev.d.ts +5 -5
  27. package/lib/node/commands/dev.js +38 -0
  28. package/lib/{commands → node/commands}/gen.d.ts +8 -8
  29. package/lib/node/commands/gen.js +75 -0
  30. package/lib/{commands → node/commands}/jest.d.ts +8 -8
  31. package/lib/node/commands/jest.js +27 -0
  32. package/lib/{commands → node/commands}/lint.d.ts +1 -1
  33. package/lib/node/commands/lint.js +41 -0
  34. package/lib/{commands → node/commands}/preview.d.ts +1 -1
  35. package/lib/node/commands/preview.js +18 -0
  36. package/lib/{commands → node/commands}/release.d.ts +5 -5
  37. package/lib/node/commands/release.js +146 -0
  38. package/lib/{commands → node/commands}/vite.d.ts +3 -3
  39. package/lib/node/commands/vite.js +13 -0
  40. package/lib/{compiler → node/compiler}/compileModule.d.ts +5 -5
  41. package/lib/node/compiler/compileModule.js +74 -0
  42. package/lib/{compiler → node/compiler}/compileSFC.d.ts +2 -2
  43. package/lib/node/compiler/compileSFC.js +79 -0
  44. package/lib/{compiler → node/compiler}/compileScript.d.ts +17 -17
  45. package/lib/node/compiler/compileScript.js +141 -0
  46. package/lib/{compiler → node/compiler}/compileSiteEntry.d.ts +13 -13
  47. package/lib/node/compiler/compileSiteEntry.js +128 -0
  48. package/lib/{compiler → node/compiler}/compileStyle.d.ts +11 -11
  49. package/lib/node/compiler/compileStyle.js +39 -0
  50. package/lib/{compiler → node/compiler}/compileTemplateHighlight.d.ts +10 -10
  51. package/lib/node/compiler/compileTemplateHighlight.js +133 -0
  52. package/lib/{compiler → node/compiler}/compileTypes.d.ts +2 -2
  53. package/lib/node/compiler/compileTypes.js +45 -0
  54. package/lib/{config → node/config}/varlet.config.d.ts +45 -44
  55. package/lib/node/config/varlet.config.js +27 -0
  56. package/lib/node/config/varlet.default.config.d.ts +2 -0
  57. package/lib/node/config/varlet.default.config.js +264 -0
  58. package/lib/node/config/vite.config.d.ts +6 -0
  59. package/lib/node/config/vite.config.js +144 -0
  60. package/lib/node/index.d.ts +1 -0
  61. package/lib/node/index.js +1 -0
  62. package/lib/{shared → node/shared}/constant.d.ts +42 -43
  63. package/lib/node/shared/constant.js +47 -0
  64. package/lib/{shared → node/shared}/fsUtils.d.ts +13 -12
  65. package/lib/node/shared/fsUtils.js +48 -0
  66. package/lib/{shared → node/shared}/logger.d.ts +8 -8
  67. package/lib/node/shared/logger.js +18 -0
  68. package/package.json +22 -19
  69. package/{preset.js → preset.cjs} +1 -1
  70. package/site/components/button/index.ts +10 -10
  71. package/site/components/cell/index.ts +10 -10
  72. package/site/components/code-example/CodeExample.vue +2 -1
  73. package/site/components/code-example/codeExample.less +41 -41
  74. package/site/components/code-example/index.ts +10 -10
  75. package/site/components/context/zIndex.ts +20 -20
  76. package/site/components/icon/icon.less +26 -26
  77. package/site/components/icon/index.ts +10 -10
  78. package/site/components/icon/props.ts +24 -24
  79. package/site/components/loading/index.ts +10 -10
  80. package/site/components/progress/index.ts +10 -10
  81. package/site/components/snackbar/snackbar.less +135 -135
  82. package/site/components/styles/common.less +64 -64
  83. package/site/components/styles/elevation.less +126 -126
  84. package/site/components/styles/var.less +27 -27
  85. package/site/components/utils/components.ts +1 -4
  86. package/site/components/utils/elements.ts +1 -1
  87. package/site/index.html +49 -49
  88. package/site/mobile/App.vue +27 -26
  89. package/site/mobile/components/AppHome.vue +2 -1
  90. package/site/mobile/components/app-bar/index.ts +10 -10
  91. package/site/mobile/components/app-bar/props.ts +25 -25
  92. package/site/mobile.html +41 -41
  93. package/site/module.d.ts +5 -5
  94. package/site/pc/App.vue +2 -1
  95. package/site/pc/Layout.vue +2 -1
  96. package/site/pc/components/AppHeader.vue +4 -2
  97. package/site/pc/pages/index/index.vue +8 -4
  98. package/site/tsconfig.json +11 -11
  99. package/site/useProgress.ts +2 -1
  100. package/site/utils.ts +6 -137
  101. package/template/generators/config/default/base/{varlet.config.js → varlet.config.mjs} +2 -2
  102. package/template/generators/config/i18n/base/{varlet.config.js → varlet.config.mjs} +2 -2
  103. package/tsconfig.json +2 -9
  104. package/lib/bin.js +0 -102
  105. package/lib/commands/build.js +0 -67
  106. package/lib/commands/changelog.js +0 -27
  107. package/lib/commands/commitLint.js +0 -21
  108. package/lib/commands/compile.js +0 -119
  109. package/lib/commands/create.js +0 -166
  110. package/lib/commands/dev.js +0 -123
  111. package/lib/commands/gen.js +0 -138
  112. package/lib/commands/jest.js +0 -85
  113. package/lib/commands/lint.js +0 -123
  114. package/lib/commands/preview.js +0 -74
  115. package/lib/commands/release.js +0 -270
  116. package/lib/commands/vite.js +0 -69
  117. package/lib/compiler/compileModule.js +0 -190
  118. package/lib/compiler/compileSFC.js +0 -135
  119. package/lib/compiler/compileScript.js +0 -194
  120. package/lib/compiler/compileSiteEntry.js +0 -237
  121. package/lib/compiler/compileStyle.js +0 -91
  122. package/lib/compiler/compileTemplateHighlight.js +0 -193
  123. package/lib/compiler/compileTypes.js +0 -85
  124. package/lib/config/babel.config.d.ts +0 -2
  125. package/lib/config/babel.config.js +0 -31
  126. package/lib/config/babel.sfc.transform.d.ts +0 -1
  127. package/lib/config/babel.sfc.transform.js +0 -18
  128. package/lib/config/jest.config.d.ts +0 -1
  129. package/lib/config/jest.config.js +0 -37
  130. package/lib/config/jest.media.mock.d.ts +0 -0
  131. package/lib/config/jest.media.mock.js +0 -2
  132. package/lib/config/jest.style.mock.d.ts +0 -0
  133. package/lib/config/jest.style.mock.js +0 -2
  134. package/lib/config/varlet.config.js +0 -35
  135. package/lib/config/vite.config.d.ts +0 -5
  136. package/lib/config/vite.config.js +0 -162
  137. package/lib/index.d.ts +0 -1
  138. package/lib/index.js +0 -5
  139. package/lib/shared/constant.js +0 -50
  140. package/lib/shared/fsUtils.js +0 -108
  141. package/lib/shared/logger.js +0 -23
  142. package/site/mobile/components/AppType.vue +0 -22
  143. package/varlet.default.config.js +0 -267
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.compileLess = exports.extractStyleDependencies = exports.normalizeStyleDependency = exports.clearEmptyLine = exports.STYLE_IMPORT_RE = exports.REQUIRE_LESS_RE = exports.REQUIRE_CSS_RE = exports.IMPORT_LESS_RE = exports.IMPORT_CSS_RE = exports.EMPTY_LINE_RE = exports.EMPTY_SPACE_RE = void 0;
40
- var fs_extra_1 = require("fs-extra");
41
- var less_1 = require("less");
42
- var fsUtils_1 = require("../shared/fsUtils");
43
- var path_1 = require("path");
44
- exports.EMPTY_SPACE_RE = /[\s]+/g;
45
- exports.EMPTY_LINE_RE = /[\n\r]*/g;
46
- exports.IMPORT_CSS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.css)['"]\s*;?(?!\s*['"`])/g;
47
- exports.IMPORT_LESS_RE = /(?<!['"`])import\s+['"](\.{1,2}\/.+\.less)['"]\s*;?(?!\s*['"`])/g;
48
- exports.REQUIRE_CSS_RE = /(?<!['"`])require\(\s*['"](\.{1,2}\/.+\.css)['"]\s*\);?(?!\s*['"`])/g;
49
- exports.REQUIRE_LESS_RE = /(?<!['"`])require\(\s*['"](\.{1,2}\/.+\.less)['"]\s*\);?(?!\s*['"`])/g;
50
- exports.STYLE_IMPORT_RE = /@import\s+['"](.+)['"]\s*;/g;
51
- var clearEmptyLine = function (s) { return s.replace(exports.EMPTY_LINE_RE, '').replace(exports.EMPTY_SPACE_RE, ' '); };
52
- exports.clearEmptyLine = clearEmptyLine;
53
- function normalizeStyleDependency(styleImport, reg) {
54
- var relativePath = styleImport.replace(reg, '$1');
55
- relativePath = relativePath.replace(/(\.less)|(\.css)/, '');
56
- if (relativePath.startsWith('./')) {
57
- return '.' + relativePath;
58
- }
59
- return '../' + relativePath;
60
- }
61
- exports.normalizeStyleDependency = normalizeStyleDependency;
62
- function extractStyleDependencies(file, code, styleReg) {
63
- var _a;
64
- var styleImports = (_a = code.match(styleReg)) !== null && _a !== void 0 ? _a : [];
65
- var cssFile = (0, path_1.resolve)((0, path_1.parse)(file).dir, './style/index.js');
66
- var modules = process.env.BABEL_MODULE;
67
- styleImports.forEach(function (styleImport) {
68
- var normalizedPath = normalizeStyleDependency(styleImport, styleReg);
69
- (0, fsUtils_1.smartAppendFileSync)(cssFile, modules === 'commonjs' ? "require('".concat(normalizedPath, ".css')\n") : "import '".concat(normalizedPath, ".css'\n"));
70
- });
71
- return code.replace(styleReg, '');
72
- }
73
- exports.extractStyleDependencies = extractStyleDependencies;
74
- function compileLess(file) {
75
- return __awaiter(this, void 0, void 0, function () {
76
- var source, css;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0:
80
- source = (0, fs_extra_1.readFileSync)(file, 'utf-8');
81
- return [4 /*yield*/, (0, less_1.render)(source, { filename: file })];
82
- case 1:
83
- css = (_a.sent()).css;
84
- (0, fs_extra_1.removeSync)(file);
85
- (0, fs_extra_1.writeFileSync)((0, fsUtils_1.replaceExt)(file, '.css'), (0, exports.clearEmptyLine)(css), 'utf-8');
86
- return [2 /*return*/];
87
- }
88
- });
89
- });
90
- }
91
- exports.compileLess = compileLess;
@@ -1,193 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.compileTemplateHighlight = exports.compileDir = exports.compileMD = exports.compileWebTypes = exports.compileAttributes = exports.compileTags = exports.compileTable = exports.parseTable = exports.replaceUnderline = exports.replaceDot = void 0;
40
- var fs_extra_1 = require("fs-extra");
41
- var constant_1 = require("../shared/constant");
42
- var path_1 = require("path");
43
- var fsUtils_1 = require("../shared/fsUtils");
44
- var lodash_1 = require("lodash");
45
- var varlet_config_1 = require("../config/varlet.config");
46
- var TABLE_HEAD_RE = /\s*\|.*\|\s*\n\s*\|.*---+\s*\|\s*\n+/;
47
- var TABLE_FOOT_RE = /(\|\s*$)|(\|\s*\n(?!\s*\|))/;
48
- var replaceDot = function (s) { return s.replace(/`/g, ''); };
49
- exports.replaceDot = replaceDot;
50
- var replaceUnderline = function (s) { return s.replace(/_/g, ''); };
51
- exports.replaceUnderline = replaceUnderline;
52
- function parseTable(table) {
53
- var rows = table.split('\n').filter(Boolean);
54
- return rows.map(function (row) {
55
- var cols = row.split('|');
56
- cols.shift();
57
- cols.pop();
58
- return cols.map(function (col) { return col.replace(/__varlet_axis__/g, '|').trim(); });
59
- });
60
- }
61
- exports.parseTable = parseTable;
62
- function compileTable(md, titleRe) {
63
- var apiMatched = md.match(constant_1.HL_API_RE);
64
- if (!apiMatched) {
65
- return '';
66
- }
67
- md = md.slice(apiMatched.index + apiMatched[0].length);
68
- var titleMatched = md.match(titleRe);
69
- if (!titleMatched) {
70
- return '';
71
- }
72
- md = md.slice(titleMatched.index + titleMatched[0].length);
73
- var tableHeadMatched = md.match(TABLE_HEAD_RE);
74
- if (!tableHeadMatched) {
75
- return '';
76
- }
77
- md = md.slice(tableHeadMatched.index + tableHeadMatched[0].length);
78
- var tableFootMatched = md.match(TABLE_FOOT_RE);
79
- if (!tableFootMatched) {
80
- return '';
81
- }
82
- md = md.slice(0, tableFootMatched.index + tableFootMatched[0].length);
83
- return md.replace(/\\\|/g, '__varlet_axis__').trim();
84
- }
85
- exports.compileTable = compileTable;
86
- function compileTags(table, tags, componentName, varletConfig) {
87
- tags["".concat((0, lodash_1.get)(varletConfig, 'namespace'), "-").concat(componentName)] = {
88
- attributes: table.attributesTable.map(function (row) { return (0, exports.replaceDot)(row[0]); }),
89
- };
90
- }
91
- exports.compileTags = compileTags;
92
- function compileAttributes(table, attributes, componentName, varletConfig) {
93
- table.attributesTable.forEach(function (row) {
94
- var attrNamespace = "".concat((0, lodash_1.get)(varletConfig, 'namespace'), "-").concat(componentName, "/").concat((0, exports.replaceDot)(row[0]));
95
- attributes[attrNamespace] = {
96
- type: (0, exports.replaceUnderline)(row[2]),
97
- description: "".concat(row[1], " \u9ED8\u8BA4\u503C\uFF1A").concat((0, exports.replaceDot)(row[3])),
98
- };
99
- });
100
- }
101
- exports.compileAttributes = compileAttributes;
102
- function compileWebTypes(table, webTypes, componentName, varletConfig) {
103
- var attributesTable = table.attributesTable, eventsTable = table.eventsTable, slotsTable = table.slotsTable;
104
- var attributes = attributesTable.map(function (row) { return ({
105
- name: (0, exports.replaceDot)(row[0]),
106
- description: row[1],
107
- default: (0, exports.replaceDot)(row[3]),
108
- value: {
109
- type: (0, exports.replaceUnderline)(row[2]),
110
- kind: 'expression',
111
- },
112
- }); });
113
- var events = eventsTable.map(function (row) { return ({
114
- name: (0, exports.replaceDot)(row[0]),
115
- description: row[1],
116
- }); });
117
- var slots = slotsTable.map(function (row) { return ({
118
- name: (0, exports.replaceDot)(row[0]),
119
- description: row[1],
120
- }); });
121
- webTypes.contributions.html.tags.push({
122
- name: "".concat((0, lodash_1.get)(varletConfig, 'namespace'), "-").concat(componentName),
123
- attributes: attributes,
124
- events: events,
125
- slots: slots,
126
- });
127
- }
128
- exports.compileWebTypes = compileWebTypes;
129
- function compileMD(path, tags, attributes, webTypes, varletConfig) {
130
- if (!path.endsWith(constant_1.HL_MD)) {
131
- return;
132
- }
133
- var md = (0, fs_extra_1.readFileSync)(path, 'utf-8');
134
- var componentName = path.match(constant_1.HL_COMPONENT_NAME_RE)[2];
135
- var attributesTable = parseTable(compileTable(md, constant_1.HL_TITLE_ATTRIBUTES_RE));
136
- var eventsTable = parseTable(compileTable(md, constant_1.HL_TITLE_EVENTS_RE));
137
- var slotsTable = parseTable(compileTable(md, constant_1.HL_TITLE_SLOTS_RE));
138
- var table = {
139
- attributesTable: attributesTable,
140
- eventsTable: eventsTable,
141
- slotsTable: slotsTable,
142
- };
143
- compileWebTypes(table, webTypes, componentName, varletConfig);
144
- compileTags(table, tags, componentName, varletConfig);
145
- compileAttributes(table, attributes, componentName, varletConfig);
146
- }
147
- exports.compileMD = compileMD;
148
- function compileDir(path, tags, attributes, webTypes, varletConfig) {
149
- var dir = (0, fs_extra_1.readdirSync)(path);
150
- dir.forEach(function (filename) {
151
- var filePath = (0, path_1.resolve)(path, filename);
152
- (0, fsUtils_1.isDir)(filePath) && compileDir(filePath, tags, attributes, webTypes, varletConfig);
153
- (0, fsUtils_1.isMD)(filePath) && compileMD(filePath, tags, attributes, webTypes, varletConfig);
154
- });
155
- }
156
- exports.compileDir = compileDir;
157
- function compileTemplateHighlight() {
158
- return __awaiter(this, void 0, void 0, function () {
159
- var varletConfig, tags, attributes, webTypes;
160
- return __generator(this, function (_a) {
161
- switch (_a.label) {
162
- case 0: return [4 /*yield*/, (0, fs_extra_1.ensureDir)(constant_1.HL_DIR)];
163
- case 1:
164
- _a.sent();
165
- varletConfig = (0, varlet_config_1.getVarletConfig)();
166
- tags = {};
167
- attributes = {};
168
- webTypes = {
169
- $schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
170
- framework: 'vue',
171
- version: require(constant_1.CLI_PACKAGE_JSON).version,
172
- name: (0, lodash_1.get)(varletConfig, 'title'),
173
- contributions: {
174
- html: {
175
- tags: [],
176
- 'types-syntax': 'typescript',
177
- },
178
- },
179
- };
180
- compileDir(constant_1.SRC_DIR, tags, attributes, webTypes, varletConfig);
181
- return [4 /*yield*/, Promise.all([
182
- (0, fs_extra_1.writeFile)(constant_1.HL_WEB_TYPES_JSON, JSON.stringify(webTypes, null, 2)),
183
- (0, fs_extra_1.writeFile)(constant_1.HL_TAGS_JSON, JSON.stringify(tags, null, 2)),
184
- (0, fs_extra_1.writeFile)(constant_1.HL_ATTRIBUTES_JSON, JSON.stringify(attributes, null, 2)),
185
- ])];
186
- case 2:
187
- _a.sent();
188
- return [2 /*return*/];
189
- }
190
- });
191
- });
192
- }
193
- exports.compileTemplateHighlight = compileTemplateHighlight;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.compileTypes = exports.generateReference = void 0;
40
- var fs_extra_1 = require("fs-extra");
41
- var constant_1 = require("../shared/constant");
42
- var shared_1 = require("@varlet/shared");
43
- var path_1 = require("path");
44
- var varlet_config_1 = require("../config/varlet.config");
45
- var lodash_1 = require("lodash");
46
- function generateReference(moduleDir) {
47
- (0, fs_extra_1.writeFileSync)((0, path_1.resolve)(moduleDir, 'index.d.ts'), "export * from '".concat((0, path_1.relative)(moduleDir, constant_1.TYPES_DIR), "'\n"));
48
- }
49
- exports.generateReference = generateReference;
50
- function compileTypes() {
51
- return __awaiter(this, void 0, void 0, function () {
52
- var varletConfig, namespace, name, dir, ignoreEntryDir, exports, declares, globalDeclares, template;
53
- return __generator(this, function (_a) {
54
- switch (_a.label) {
55
- case 0:
56
- varletConfig = (0, varlet_config_1.getVarletConfig)();
57
- namespace = (0, lodash_1.get)(varletConfig, 'namespace');
58
- name = require(constant_1.UI_PACKAGE_JSON).name;
59
- return [4 /*yield*/, (0, fs_extra_1.ensureDir)(constant_1.TYPES_DIR)];
60
- case 1:
61
- _a.sent();
62
- return [4 /*yield*/, (0, fs_extra_1.readdir)(constant_1.TYPES_DIR)];
63
- case 2:
64
- dir = _a.sent();
65
- ignoreEntryDir = dir.filter(function (filename) { return filename !== 'index.d.ts' && filename !== 'global.d.ts'; });
66
- exports = [];
67
- declares = [];
68
- ignoreEntryDir.forEach(function (filename) {
69
- var componentName = filename.slice(0, filename.indexOf('.d.ts'));
70
- exports.push("export * from './".concat(componentName, "'"));
71
- if (!componentName.startsWith(namespace)) {
72
- declares.push("".concat((0, shared_1.bigCamelize)(namespace)).concat((0, shared_1.bigCamelize)(componentName), ": typeof import('").concat(name, "')['_").concat((0, shared_1.bigCamelize)(componentName), "Component']"));
73
- }
74
- });
75
- globalDeclares = "declare module 'vue' {\n export interface GlobalComponents {\n ".concat(declares.join('\n '), "\n }\n}");
76
- template = "import type { App } from 'vue'\n\nexport const install: (app: App) => void\n\n".concat(exports.join('\n'), "\n\n").concat(globalDeclares, "\n");
77
- return [4 /*yield*/, Promise.all([(0, fs_extra_1.writeFile)((0, path_1.resolve)(constant_1.TYPES_DIR, 'index.d.ts'), template)])];
78
- case 3:
79
- _a.sent();
80
- return [2 /*return*/];
81
- }
82
- });
83
- });
84
- }
85
- exports.compileTypes = compileTypes;
@@ -1,2 +0,0 @@
1
- declare const _default: any;
2
- export default _default;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- module.exports = function (api, options) {
4
- if (options === void 0) { options = {}; }
5
- if (api) {
6
- api.cache.never();
7
- }
8
- var isCommonJS = process.env.NODE_ENV === 'test' || process.env.BABEL_MODULE === 'commonjs';
9
- return {
10
- presets: [
11
- [
12
- require.resolve('@babel/preset-env'),
13
- {
14
- modules: isCommonJS ? 'commonjs' : false,
15
- loose: options.loose,
16
- },
17
- ],
18
- require.resolve('@babel/preset-typescript'),
19
- require('./babel.sfc.transform'),
20
- ],
21
- plugins: [
22
- [
23
- require.resolve('@vue/babel-plugin-jsx'),
24
- {
25
- enableObjectSlots: options.enableObjectSlots,
26
- },
27
- ],
28
- ],
29
- };
30
- };
31
- exports.default = module.exports;
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var fs_1 = require("fs");
4
- var helper_plugin_utils_1 = require("@babel/helper-plugin-utils");
5
- module.exports = (0, helper_plugin_utils_1.declare)(function () { return ({
6
- overrides: [
7
- {
8
- test: function (file) {
9
- if (/\.vue$/.test(file)) {
10
- var code = (0, fs_1.readFileSync)(file, 'utf8');
11
- return code.includes('lang="ts"') || code.includes("lang='ts'");
12
- }
13
- return false;
14
- },
15
- plugins: ['@babel/plugin-transform-typescript'],
16
- },
17
- ],
18
- }); });
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var constant_1 = require("../shared/constant");
15
- var path_1 = require("path");
16
- var fs_extra_1 = require("fs-extra");
17
- function getRootConfig() {
18
- var file = (0, path_1.resolve)(constant_1.CWD, 'jest.config.js');
19
- if ((0, fs_extra_1.pathExistsSync)(file)) {
20
- delete require.cache[require.resolve(file)];
21
- return require(file);
22
- }
23
- return {};
24
- }
25
- module.exports = __assign({ moduleNameMapper: {
26
- '^@config$': '<rootDir>/.varlet/site.config.json',
27
- '\\.(css|less)$': constant_1.JEST_STYLE_MOCK,
28
- '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': constant_1.JEST_MEDIA_MOCK,
29
- }, transform: {
30
- '\\.(vue)$': 'vue-jest',
31
- '\\.(js|jsx|ts|tsx)$': 'babel-jest',
32
- }, collectCoverage: true, collectCoverageFrom: [
33
- 'src/**/*.{js,jsx,ts,tsx,vue}',
34
- "!**/".concat(constant_1.EXAMPLE_DIR_NAME, "/**"),
35
- "!**/".concat(constant_1.DOCS_DIR_NAME, "/**"),
36
- "!**/".concat(constant_1.TESTS_DIR_NAME, "/**"),
37
- ], moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'vue'], transformIgnorePatterns: [] }, getRootConfig());
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- module.exports = {};
File without changes
@@ -1,2 +0,0 @@
1
- "use strict";
2
- module.exports = {};
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVarletConfig = exports.mergeStrategy = exports.defineConfig = void 0;
4
- var fs_extra_1 = require("fs-extra");
5
- var lodash_1 = require("lodash");
6
- var constant_1 = require("../shared/constant");
7
- var fsUtils_1 = require("../shared/fsUtils");
8
- var shared_1 = require("@varlet/shared");
9
- function defineConfig(conf) {
10
- return conf;
11
- }
12
- exports.defineConfig = defineConfig;
13
- function mergeStrategy(value, srcValue, key) {
14
- if (key === 'features' && (0, shared_1.isArray)(srcValue)) {
15
- return srcValue;
16
- }
17
- }
18
- exports.mergeStrategy = mergeStrategy;
19
- function getVarletConfig(emit) {
20
- if (emit === void 0) { emit = false; }
21
- var config = {};
22
- if ((0, fs_extra_1.pathExistsSync)(constant_1.VARLET_CONFIG)) {
23
- delete require.cache[require.resolve(constant_1.VARLET_CONFIG)];
24
- config = require(constant_1.VARLET_CONFIG);
25
- }
26
- delete require.cache[require.resolve('../../varlet.default.config.js')];
27
- var defaultConfig = require('../../varlet.default.config.js');
28
- var mergedConfig = (0, lodash_1.mergeWith)(defaultConfig, config, mergeStrategy);
29
- if (emit) {
30
- var source = JSON.stringify(mergedConfig, null, 2);
31
- (0, fsUtils_1.outputFileSyncOnChange)(constant_1.SITE_CONFIG, source);
32
- }
33
- return mergedConfig;
34
- }
35
- exports.getVarletConfig = getVarletConfig;
@@ -1,5 +0,0 @@
1
- import { InlineConfig } from 'vite';
2
- export declare function getDevConfig(varletConfig: Record<string, any>): InlineConfig;
3
- export declare function getBuildConfig(varletConfig: Record<string, any>): InlineConfig;
4
- export declare function getESMBundleConfig(varletConfig: Record<string, any>): InlineConfig;
5
- export declare function getUMDConfig(varletConfig: Record<string, any>): InlineConfig;