unplugin-dingtalk 1005.0.0 → 1006.0.0

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.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import {
2
+ createProxyMiddleware,
2
3
  index_default,
3
4
  resovedInfo,
4
5
  unplugin,
5
6
  unpluginFactory
6
- } from "./chunk-ZLK5HLCO.js";
7
+ } from "./chunk-EG2ZYJ3S.js";
7
8
  import "./chunk-2YQKM4BX.js";
8
9
  import "./chunk-5JBD5THX.js";
9
10
  export {
11
+ createProxyMiddleware,
10
12
  index_default as default,
11
13
  resovedInfo,
12
14
  unplugin,
@@ -0,0 +1,129 @@
1
+ import "./chunk-5JBD5THX.js";
2
+
3
+ // node_modules/.pnpm/vite-plugin-vconsole@2.1.1/node_modules/vite-plugin-vconsole/dist/main.mjs
4
+ var parseVConsoleOptions = (config) => Object.keys(config).reduce((code, key) => {
5
+ const value = config[key];
6
+ if (typeof value === "function") {
7
+ if (/^[(f]/.test(value.toString())) {
8
+ code += `${key}: ${value},`;
9
+ return code;
10
+ } else {
11
+ code += `${value},`;
12
+ return code;
13
+ }
14
+ }
15
+ code += `${key}: ${JSON.stringify(config[key])},`;
16
+ return code;
17
+ }, "");
18
+ var getEventItems = (event, id) => {
19
+ return event.map(
20
+ (ele) => `
21
+ ${id}.on('${ele.eventName}', ${ele.callback})
22
+ `
23
+ ).join(";");
24
+ };
25
+ var getDynamicConfig = (dynamicConfig) => {
26
+ let configString = "";
27
+ if (!dynamicConfig) {
28
+ return configString;
29
+ }
30
+ for (const key in dynamicConfig) {
31
+ if (typeof dynamicConfig[key] === "string") {
32
+ configString += `${key}: ${dynamicConfig[key]},`;
33
+ }
34
+ }
35
+ return configString;
36
+ };
37
+ var getPlugins = (plugin) => {
38
+ let plugins = "";
39
+ if (plugin && plugin.length) {
40
+ plugins = plugin.map(
41
+ (e) => `
42
+ const ${e.id} = new VConsole.VConsolePlugin('${e.id}', '${e.name}');
43
+ ${getEventItems(e.event, e.id)}
44
+ vConsole.addPlugin(${e.id})
45
+ `
46
+ ).join(";");
47
+ }
48
+ return plugins;
49
+ };
50
+ function viteVConsole(opt) {
51
+ const {
52
+ entry,
53
+ enabled = true,
54
+ config = {},
55
+ plugin,
56
+ customHide = false,
57
+ dynamicConfig = {},
58
+ eventListener = ""
59
+ } = opt;
60
+ let entryPath = Array.isArray(entry) ? entry : [entry];
61
+ if (process.platform === "win32")
62
+ entryPath = entryPath.map((item) => item.replace(/\\/g, "/"));
63
+ const enabledTruly = enabled;
64
+ return {
65
+ name: "vite:vconsole",
66
+ enforce: "pre",
67
+ transform(_source, id) {
68
+ if (entryPath.includes(id) && enabledTruly) {
69
+ const code = `/* eslint-disable */;
70
+ import VConsole from 'vconsole';
71
+ // config
72
+ const vConsole = new VConsole({${parseVConsoleOptions(
73
+ config
74
+ )}});
75
+ window.vConsole = vConsole;
76
+
77
+ // plugins
78
+ ${getPlugins(plugin)}
79
+
80
+ // dynamic config
81
+ window.vConsole.dynamicFunction = function() {
82
+ if (${getDynamicConfig(dynamicConfig).length > 0}) {
83
+ vConsole.setOption({${getDynamicConfig(dynamicConfig)}});
84
+ }
85
+ };
86
+
87
+ window.vConsole.dynamicChange = {
88
+ value: new Date().getTime()
89
+ };
90
+
91
+ window.vConsole.dynamicFunction();
92
+
93
+ if (${customHide}) {
94
+ vConsole.hideSwitch();
95
+ }
96
+
97
+ // In order to be compatible with old equipment, I used defineProperty. In the future, when proxy covers enough devices, proxy will be used.
98
+ Object.defineProperty(window.vConsole.dynamicChange, 'value', {
99
+ get: function() {
100
+ return this._value;
101
+ },
102
+ set: function(newValue) {
103
+ window.vConsole.dynamicFunction();
104
+ this._value = newValue;
105
+ }
106
+ });
107
+
108
+ // eventListener
109
+ ${eventListener}
110
+ /* eslint-enable */${_source}`;
111
+ return {
112
+ code,
113
+ map: null
114
+ // support source map
115
+ };
116
+ }
117
+ return {
118
+ code: _source,
119
+ map: null
120
+ // support source map
121
+ };
122
+ }
123
+ };
124
+ }
125
+ var main_default = viteVConsole;
126
+ export {
127
+ main_default as default,
128
+ viteVConsole
129
+ };