@vtj/local 0.12.18 → 0.12.20

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.
package/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const vite = require('vite');
3
4
  const cli = require('@vtj/cli');
4
5
  const node = require('@vtj/node');
5
6
  const path = require('path');
@@ -541,6 +542,17 @@ async function saveLogs(e) {
541
542
  async function getExtension(_body, opts) {
542
543
  const root = path.resolve("./");
543
544
  const pkg = node.readJsonSync(path.resolve(root, "package.json"));
545
+ const { name = "VTJEnhance", outDir = "enhance" } = typeof opts.enhance === "boolean" ? {} : opts.enhance || {};
546
+ const outputDir = `${opts.nodeModulesDir}/${opts.packageName}/dist/${outDir}`;
547
+ const enhance = {
548
+ name,
549
+ urls: []
550
+ };
551
+ const enhanceDir = path.resolve(root, outputDir);
552
+ if (node.pathExistsSync(enhanceDir)) {
553
+ const files = node.readdirSync(enhanceDir) || [];
554
+ enhance.urls = files.map((n) => `${outDir}/${n}`);
555
+ }
544
556
  const { vtj = {} } = pkg || {};
545
557
  const __ACCESS__ = {
546
558
  auth: "https://lcdp.vtj.pro/auth.html",
@@ -549,6 +561,7 @@ async function getExtension(_body, opts) {
549
561
  };
550
562
  const config = {
551
563
  remote: "https://lcdp.vtj.pro",
564
+ enhance,
552
565
  ...vtj,
553
566
  history: vtj.history || "hash",
554
567
  base: vtj.base || "/",
@@ -1124,6 +1137,72 @@ const aliasPlugin = function(options) {
1124
1137
  }
1125
1138
  };
1126
1139
  };
1140
+ const umdBuildPlugin = function(options) {
1141
+ const {
1142
+ entry = "src/enhance.ts",
1143
+ name = "VTJEnhance",
1144
+ fileName = "enhance",
1145
+ external = [],
1146
+ globals = {},
1147
+ outDir = "enhance"
1148
+ } = typeof options.enhance === "boolean" ? {} : options.enhance || {};
1149
+ const outputDir = `${options.nodeModulesDir}/${options.packageName}/dist/${outDir}`;
1150
+ return {
1151
+ name: "vtj-umd-build-plugin",
1152
+ configureServer(server) {
1153
+ const buildUmd = async () => {
1154
+ await vite.build({
1155
+ configFile: false,
1156
+ build: {
1157
+ outDir: outputDir,
1158
+ emptyOutDir: false,
1159
+ copyPublicDir: false,
1160
+ lib: {
1161
+ entry,
1162
+ name,
1163
+ formats: ["umd"],
1164
+ cssFileName: fileName,
1165
+ fileName: () => {
1166
+ return `${fileName}.umd.js`;
1167
+ }
1168
+ },
1169
+ watch: {},
1170
+ minify: false,
1171
+ rollupOptions: {
1172
+ external: [
1173
+ "vue",
1174
+ "vue-router",
1175
+ "@vtj/icons",
1176
+ "@vtj/utils",
1177
+ "uni-app",
1178
+ "uni-h5",
1179
+ ...external
1180
+ ],
1181
+ output: {
1182
+ exports: "auto",
1183
+ globals: {
1184
+ vue: "Vue",
1185
+ "vue-router": "VueRouter",
1186
+ "@vtj/icons": "VtjIcons",
1187
+ "@vtj/utils": "VtjUtils",
1188
+ "uni-app": "UniApp",
1189
+ "uni-h5": "UniH5",
1190
+ ...globals
1191
+ }
1192
+ }
1193
+ }
1194
+ }
1195
+ });
1196
+ };
1197
+ buildUmd();
1198
+ server.watcher.on("change", async (path) => {
1199
+ if (path.endsWith("src/enhance.ts")) {
1200
+ await buildUmd();
1201
+ }
1202
+ });
1203
+ }
1204
+ };
1205
+ };
1127
1206
  function parsePresetPlugins(options) {
1128
1207
  const {
1129
1208
  presetPlugins = [],
@@ -1176,6 +1255,7 @@ function createDevTools(options = {}) {
1176
1255
  extensionDir: "",
1177
1256
  materialDirs: [],
1178
1257
  hm: "42f2469b4aa27c3f8978f634c0c19d24",
1258
+ enhance: false,
1179
1259
  ...options
1180
1260
  };
1181
1261
  const plugins = [aliasPlugin(opts)];
@@ -1277,6 +1357,9 @@ function createDevTools(options = {}) {
1277
1357
  if (opts.hm) {
1278
1358
  plugins.push(hmPlugin(opts));
1279
1359
  }
1360
+ if (opts.enhance) {
1361
+ plugins.push(umdBuildPlugin(opts));
1362
+ }
1280
1363
  return plugins;
1281
1364
  }
1282
1365
 
package/dist/index.d.cts CHANGED
@@ -20,6 +20,15 @@ interface DevToolsOptions {
20
20
  extensionDir: string;
21
21
  materialDirs: string[];
22
22
  hm?: string;
23
+ enhance?: boolean | EnhanceOptions;
24
+ }
25
+ interface EnhanceOptions {
26
+ entry?: string;
27
+ name?: string;
28
+ fileName?: string;
29
+ external?: string[];
30
+ globals?: Record<string, string>;
31
+ outDir?: string;
23
32
  }
24
33
  interface LinkOptions {
25
34
  entry?: string;
@@ -33,4 +42,4 @@ declare function parsePresetPlugins(options: DevToolsOptions): {
33
42
  declare function createDevTools(options?: Partial<DevToolsOptions>): Plugin<any>[];
34
43
 
35
44
  export { createDevTools, parsePresetPlugins };
36
- export type { DevToolsOptions, LinkOptions };
45
+ export type { DevToolsOptions, EnhanceOptions, LinkOptions };
package/dist/index.d.mts CHANGED
@@ -20,6 +20,15 @@ interface DevToolsOptions {
20
20
  extensionDir: string;
21
21
  materialDirs: string[];
22
22
  hm?: string;
23
+ enhance?: boolean | EnhanceOptions;
24
+ }
25
+ interface EnhanceOptions {
26
+ entry?: string;
27
+ name?: string;
28
+ fileName?: string;
29
+ external?: string[];
30
+ globals?: Record<string, string>;
31
+ outDir?: string;
23
32
  }
24
33
  interface LinkOptions {
25
34
  entry?: string;
@@ -33,4 +42,4 @@ declare function parsePresetPlugins(options: DevToolsOptions): {
33
42
  declare function createDevTools(options?: Partial<DevToolsOptions>): Plugin<any>[];
34
43
 
35
44
  export { createDevTools, parsePresetPlugins };
36
- export type { DevToolsOptions, LinkOptions };
45
+ export type { DevToolsOptions, EnhanceOptions, LinkOptions };
package/dist/index.d.ts CHANGED
@@ -20,6 +20,15 @@ interface DevToolsOptions {
20
20
  extensionDir: string;
21
21
  materialDirs: string[];
22
22
  hm?: string;
23
+ enhance?: boolean | EnhanceOptions;
24
+ }
25
+ interface EnhanceOptions {
26
+ entry?: string;
27
+ name?: string;
28
+ fileName?: string;
29
+ external?: string[];
30
+ globals?: Record<string, string>;
31
+ outDir?: string;
23
32
  }
24
33
  interface LinkOptions {
25
34
  entry?: string;
@@ -33,4 +42,4 @@ declare function parsePresetPlugins(options: DevToolsOptions): {
33
42
  declare function createDevTools(options?: Partial<DevToolsOptions>): Plugin<any>[];
34
43
 
35
44
  export { createDevTools, parsePresetPlugins };
36
- export type { DevToolsOptions, LinkOptions };
45
+ export type { DevToolsOptions, EnhanceOptions, LinkOptions };
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { build } from 'vite';
1
2
  import { copyPlugin, staticPlugin } from '@vtj/cli';
2
3
  import { pathExistsSync, ensureFileSync, writeJsonSync, readJsonSync, removeSync, outputFileSync, readdirSync, moveSync, upperFirstCamelCase, camelCase, fs, timestamp, uuid } from '@vtj/node';
3
4
  import { resolve, join } from 'path';
@@ -534,6 +535,17 @@ async function saveLogs(e) {
534
535
  async function getExtension(_body, opts) {
535
536
  const root = resolve("./");
536
537
  const pkg = readJsonSync(resolve(root, "package.json"));
538
+ const { name = "VTJEnhance", outDir = "enhance" } = typeof opts.enhance === "boolean" ? {} : opts.enhance || {};
539
+ const outputDir = `${opts.nodeModulesDir}/${opts.packageName}/dist/${outDir}`;
540
+ const enhance = {
541
+ name,
542
+ urls: []
543
+ };
544
+ const enhanceDir = resolve(root, outputDir);
545
+ if (pathExistsSync(enhanceDir)) {
546
+ const files = readdirSync(enhanceDir) || [];
547
+ enhance.urls = files.map((n) => `${outDir}/${n}`);
548
+ }
537
549
  const { vtj = {} } = pkg || {};
538
550
  const __ACCESS__ = {
539
551
  auth: "https://lcdp.vtj.pro/auth.html",
@@ -542,6 +554,7 @@ async function getExtension(_body, opts) {
542
554
  };
543
555
  const config = {
544
556
  remote: "https://lcdp.vtj.pro",
557
+ enhance,
545
558
  ...vtj,
546
559
  history: vtj.history || "hash",
547
560
  base: vtj.base || "/",
@@ -1117,6 +1130,72 @@ const aliasPlugin = function(options) {
1117
1130
  }
1118
1131
  };
1119
1132
  };
1133
+ const umdBuildPlugin = function(options) {
1134
+ const {
1135
+ entry = "src/enhance.ts",
1136
+ name = "VTJEnhance",
1137
+ fileName = "enhance",
1138
+ external = [],
1139
+ globals = {},
1140
+ outDir = "enhance"
1141
+ } = typeof options.enhance === "boolean" ? {} : options.enhance || {};
1142
+ const outputDir = `${options.nodeModulesDir}/${options.packageName}/dist/${outDir}`;
1143
+ return {
1144
+ name: "vtj-umd-build-plugin",
1145
+ configureServer(server) {
1146
+ const buildUmd = async () => {
1147
+ await build({
1148
+ configFile: false,
1149
+ build: {
1150
+ outDir: outputDir,
1151
+ emptyOutDir: false,
1152
+ copyPublicDir: false,
1153
+ lib: {
1154
+ entry,
1155
+ name,
1156
+ formats: ["umd"],
1157
+ cssFileName: fileName,
1158
+ fileName: () => {
1159
+ return `${fileName}.umd.js`;
1160
+ }
1161
+ },
1162
+ watch: {},
1163
+ minify: false,
1164
+ rollupOptions: {
1165
+ external: [
1166
+ "vue",
1167
+ "vue-router",
1168
+ "@vtj/icons",
1169
+ "@vtj/utils",
1170
+ "uni-app",
1171
+ "uni-h5",
1172
+ ...external
1173
+ ],
1174
+ output: {
1175
+ exports: "auto",
1176
+ globals: {
1177
+ vue: "Vue",
1178
+ "vue-router": "VueRouter",
1179
+ "@vtj/icons": "VtjIcons",
1180
+ "@vtj/utils": "VtjUtils",
1181
+ "uni-app": "UniApp",
1182
+ "uni-h5": "UniH5",
1183
+ ...globals
1184
+ }
1185
+ }
1186
+ }
1187
+ }
1188
+ });
1189
+ };
1190
+ buildUmd();
1191
+ server.watcher.on("change", async (path) => {
1192
+ if (path.endsWith("src/enhance.ts")) {
1193
+ await buildUmd();
1194
+ }
1195
+ });
1196
+ }
1197
+ };
1198
+ };
1120
1199
  function parsePresetPlugins(options) {
1121
1200
  const {
1122
1201
  presetPlugins = [],
@@ -1169,6 +1248,7 @@ function createDevTools(options = {}) {
1169
1248
  extensionDir: "",
1170
1249
  materialDirs: [],
1171
1250
  hm: "42f2469b4aa27c3f8978f634c0c19d24",
1251
+ enhance: false,
1172
1252
  ...options
1173
1253
  };
1174
1254
  const plugins = [aliasPlugin(opts)];
@@ -1270,6 +1350,9 @@ function createDevTools(options = {}) {
1270
1350
  if (opts.hm) {
1271
1351
  plugins.push(hmPlugin(opts));
1272
1352
  }
1353
+ if (opts.enhance) {
1354
+ plugins.push(umdBuildPlugin(opts));
1355
+ }
1273
1356
  return plugins;
1274
1357
  }
1275
1358
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtj/local",
3
3
  "private": false,
4
- "version": "0.12.18",
4
+ "version": "0.12.20",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "低代码引擎",
@@ -22,10 +22,10 @@
22
22
  "license": "MIT",
23
23
  "dependencies": {
24
24
  "formidable": "~3.5.1",
25
- "@vtj/core": "~0.12.18",
26
- "@vtj/coder": "~0.12.18",
25
+ "@vtj/coder": "~0.12.20",
26
+ "@vtj/core": "~0.12.20",
27
27
  "@vtj/node": "~0.12.0",
28
- "@vtj/parser": "~0.12.18"
28
+ "@vtj/parser": "~0.12.20"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/formidable": "~3.4.5",