unplugin-dingtalk 0.1.6 → 0.1.9

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
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
8
  var __export = (target, all) => {
12
9
  for (var name in all)
13
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -30,64 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
27
  ));
31
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
29
 
33
- // node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
34
- var require_picocolors = __commonJS({
35
- "node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
36
- "use strict";
37
- var argv = process.argv || [];
38
- var env = process.env;
39
- var isColorSupported = !("NO_COLOR" in env || argv.includes("--no-color")) && ("FORCE_COLOR" in env || argv.includes("--color") || process.platform === "win32" || require != null && require("tty").isatty(1) && env.TERM !== "dumb" || "CI" in env);
40
- var formatter = (open, close, replace = open) => (input) => {
41
- let string = "" + input;
42
- let index = string.indexOf(close, open.length);
43
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
44
- };
45
- var replaceClose = (string, close, replace, index) => {
46
- let result = "";
47
- let cursor = 0;
48
- do {
49
- result += string.substring(cursor, index) + replace;
50
- cursor = index + close.length;
51
- index = string.indexOf(close, cursor);
52
- } while (~index);
53
- return result + string.substring(cursor);
54
- };
55
- var createColors = (enabled = isColorSupported) => {
56
- let init = enabled ? formatter : () => String;
57
- return {
58
- isColorSupported: enabled,
59
- reset: init("\x1B[0m", "\x1B[0m"),
60
- bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
61
- dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
62
- italic: init("\x1B[3m", "\x1B[23m"),
63
- underline: init("\x1B[4m", "\x1B[24m"),
64
- inverse: init("\x1B[7m", "\x1B[27m"),
65
- hidden: init("\x1B[8m", "\x1B[28m"),
66
- strikethrough: init("\x1B[9m", "\x1B[29m"),
67
- black: init("\x1B[30m", "\x1B[39m"),
68
- red: init("\x1B[31m", "\x1B[39m"),
69
- green: init("\x1B[32m", "\x1B[39m"),
70
- yellow: init("\x1B[33m", "\x1B[39m"),
71
- blue: init("\x1B[34m", "\x1B[39m"),
72
- magenta: init("\x1B[35m", "\x1B[39m"),
73
- cyan: init("\x1B[36m", "\x1B[39m"),
74
- white: init("\x1B[37m", "\x1B[39m"),
75
- gray: init("\x1B[90m", "\x1B[39m"),
76
- bgBlack: init("\x1B[40m", "\x1B[49m"),
77
- bgRed: init("\x1B[41m", "\x1B[49m"),
78
- bgGreen: init("\x1B[42m", "\x1B[49m"),
79
- bgYellow: init("\x1B[43m", "\x1B[49m"),
80
- bgBlue: init("\x1B[44m", "\x1B[49m"),
81
- bgMagenta: init("\x1B[45m", "\x1B[49m"),
82
- bgCyan: init("\x1B[46m", "\x1B[49m"),
83
- bgWhite: init("\x1B[47m", "\x1B[49m")
84
- };
85
- };
86
- module2.exports = createColors();
87
- module2.exports.createColors = createColors;
88
- }
89
- });
90
-
91
30
  // src/index.ts
92
31
  var src_exports = {};
93
32
  __export(src_exports, {
@@ -99,132 +38,9 @@ module.exports = __toCommonJS(src_exports);
99
38
  var import_node_child_process = require("child_process");
100
39
  var import_node_process = __toESM(require("process"), 1);
101
40
  var import_unplugin = require("unplugin");
102
- var import_picocolors = __toESM(require_picocolors(), 1);
103
-
104
- // node_modules/.pnpm/vite-plugin-vconsole@2.1.1/node_modules/vite-plugin-vconsole/dist/main.mjs
105
- var parseVConsoleOptions = (config2) => Object.keys(config2).reduce((code, key) => {
106
- const value = config2[key];
107
- if (typeof value === "function") {
108
- if (/^[(f]/.test(value.toString())) {
109
- code += `${key}: ${value},`;
110
- return code;
111
- } else {
112
- code += `${value},`;
113
- return code;
114
- }
115
- }
116
- code += `${key}: ${JSON.stringify(config2[key])},`;
117
- return code;
118
- }, "");
119
- var getEventItems = (event, id) => {
120
- return event.map(
121
- (ele) => `
122
- ${id}.on('${ele.eventName}', ${ele.callback})
123
- `
124
- ).join(";");
125
- };
126
- var getDynamicConfig = (dynamicConfig) => {
127
- let configString = "";
128
- if (!dynamicConfig) {
129
- return configString;
130
- }
131
- for (const key in dynamicConfig) {
132
- if (typeof dynamicConfig[key] === "string") {
133
- configString += `${key}: ${dynamicConfig[key]},`;
134
- }
135
- }
136
- return configString;
137
- };
138
- var getPlugins = (plugin) => {
139
- let plugins = "";
140
- if (plugin && plugin.length) {
141
- plugins = plugin.map(
142
- (e) => `
143
- const ${e.id} = new VConsole.VConsolePlugin('${e.id}', '${e.name}');
144
- ${getEventItems(e.event, e.id)}
145
- vConsole.addPlugin(${e.id})
146
- `
147
- ).join(";");
148
- }
149
- return plugins;
150
- };
151
- function viteVConsole(opt) {
152
- const {
153
- entry,
154
- enabled = true,
155
- config: config2 = {},
156
- plugin,
157
- customHide = false,
158
- dynamicConfig = {},
159
- eventListener = ""
160
- } = opt;
161
- let entryPath = Array.isArray(entry) ? entry : [entry];
162
- if (process.platform === "win32")
163
- entryPath = entryPath.map((item) => item.replace(/\\/g, "/"));
164
- const enabledTruly = enabled;
165
- return {
166
- name: "vite:vconsole",
167
- enforce: "pre",
168
- transform(_source, id) {
169
- if (entryPath.includes(id) && enabledTruly) {
170
- const code = `/* eslint-disable */;
171
- import VConsole from 'vconsole';
172
- // config
173
- const vConsole = new VConsole({${parseVConsoleOptions(
174
- config2
175
- )}});
176
- window.vConsole = vConsole;
177
-
178
- // plugins
179
- ${getPlugins(plugin)}
180
-
181
- // dynamic config
182
- window.vConsole.dynamicFunction = function() {
183
- if (${getDynamicConfig(dynamicConfig).length > 0}) {
184
- vConsole.setOption({${getDynamicConfig(dynamicConfig)}});
185
- }
186
- };
187
-
188
- window.vConsole.dynamicChange = {
189
- value: new Date().getTime()
190
- };
191
-
192
- window.vConsole.dynamicFunction();
193
-
194
- if (${customHide}) {
195
- vConsole.hideSwitch();
196
- }
197
-
198
- // In order to be compatible with old equipment, I used defineProperty. In the future, when proxy covers enough devices, proxy will be used.
199
- Object.defineProperty(window.vConsole.dynamicChange, 'value', {
200
- get: function() {
201
- return this._value;
202
- },
203
- set: function(newValue) {
204
- window.vConsole.dynamicFunction();
205
- this._value = newValue;
206
- }
207
- });
208
-
209
- // eventListener
210
- ${eventListener}
211
- /* eslint-enable */${_source}`;
212
- return {
213
- code,
214
- map: null
215
- // support source map
216
- };
217
- }
218
- return {
219
- code: _source,
220
- map: null
221
- // support source map
222
- };
223
- }
224
- };
225
- }
226
-
227
- // src/index.ts
41
+ var import_picocolors = __toESM(require("picocolors"), 1);
42
+ var import_vite_plugin_vconsole = require("vite-plugin-vconsole");
43
+ var import_cookie = __toESM(require("cookie"), 1);
228
44
  var config;
229
45
  var devtoolsInstance;
230
46
  var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
@@ -291,6 +107,20 @@ var unpluginFactory = (options) => {
291
107
  if (options == null ? void 0 : options.corpId) {
292
108
  targetURL.searchParams.append("corpId", options.corpId);
293
109
  }
110
+ if (options.debugCookies && options.debugCookies.length > 0) {
111
+ server.middlewares.use((req, res, next) => {
112
+ const cookies = import_cookie.default.parse(req.headers.cookie || "");
113
+ for (const [name, value] of Object.entries(cookies)) {
114
+ if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
115
+ const serializedCookie = import_cookie.default.serialize(name, value, {
116
+ httpOnly: false
117
+ });
118
+ res.setHeader("Set-Cookie", serializedCookie);
119
+ }
120
+ }
121
+ next();
122
+ });
123
+ }
294
124
  server.middlewares.use("/open-dingtalk", (req, res) => {
295
125
  var _a3;
296
126
  debug(targetURL.toString());
@@ -315,7 +145,7 @@ var unpluginFactory = (options) => {
315
145
  }
316
146
  };
317
147
  if ((options == null ? void 0 : options.enable) && ((_a = options == null ? void 0 : options.vconsole) == null ? void 0 : _a.enabled)) {
318
- return [viteVConsole(options == null ? void 0 : options.vconsole), unpluginDing];
148
+ return [(0, import_vite_plugin_vconsole.viteVConsole)(options == null ? void 0 : options.vconsole), unpluginDing];
319
149
  } else {
320
150
  return unpluginDing;
321
151
  }
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  src_default,
3
3
  unplugin,
4
4
  unpluginFactory
5
- } from "./chunk-QTZOG6NL.js";
5
+ } from "./chunk-PSBADVC6.js";
6
6
  export {
7
7
  src_default as default,
8
8
  unplugin,
package/dist/nuxt.cjs CHANGED
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
- };
11
8
  var __export = (target, all) => {
12
9
  for (var name in all)
13
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -30,64 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
27
  ));
31
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
29
 
33
- // node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js
34
- var require_picocolors = __commonJS({
35
- "node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js"(exports2, module2) {
36
- "use strict";
37
- var argv = process.argv || [];
38
- var env = process.env;
39
- var isColorSupported = !("NO_COLOR" in env || argv.includes("--no-color")) && ("FORCE_COLOR" in env || argv.includes("--color") || process.platform === "win32" || require != null && require("tty").isatty(1) && env.TERM !== "dumb" || "CI" in env);
40
- var formatter = (open, close, replace = open) => (input) => {
41
- let string = "" + input;
42
- let index = string.indexOf(close, open.length);
43
- return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
44
- };
45
- var replaceClose = (string, close, replace, index) => {
46
- let result = "";
47
- let cursor = 0;
48
- do {
49
- result += string.substring(cursor, index) + replace;
50
- cursor = index + close.length;
51
- index = string.indexOf(close, cursor);
52
- } while (~index);
53
- return result + string.substring(cursor);
54
- };
55
- var createColors = (enabled = isColorSupported) => {
56
- let init = enabled ? formatter : () => String;
57
- return {
58
- isColorSupported: enabled,
59
- reset: init("\x1B[0m", "\x1B[0m"),
60
- bold: init("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
61
- dim: init("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
62
- italic: init("\x1B[3m", "\x1B[23m"),
63
- underline: init("\x1B[4m", "\x1B[24m"),
64
- inverse: init("\x1B[7m", "\x1B[27m"),
65
- hidden: init("\x1B[8m", "\x1B[28m"),
66
- strikethrough: init("\x1B[9m", "\x1B[29m"),
67
- black: init("\x1B[30m", "\x1B[39m"),
68
- red: init("\x1B[31m", "\x1B[39m"),
69
- green: init("\x1B[32m", "\x1B[39m"),
70
- yellow: init("\x1B[33m", "\x1B[39m"),
71
- blue: init("\x1B[34m", "\x1B[39m"),
72
- magenta: init("\x1B[35m", "\x1B[39m"),
73
- cyan: init("\x1B[36m", "\x1B[39m"),
74
- white: init("\x1B[37m", "\x1B[39m"),
75
- gray: init("\x1B[90m", "\x1B[39m"),
76
- bgBlack: init("\x1B[40m", "\x1B[49m"),
77
- bgRed: init("\x1B[41m", "\x1B[49m"),
78
- bgGreen: init("\x1B[42m", "\x1B[49m"),
79
- bgYellow: init("\x1B[43m", "\x1B[49m"),
80
- bgBlue: init("\x1B[44m", "\x1B[49m"),
81
- bgMagenta: init("\x1B[45m", "\x1B[49m"),
82
- bgCyan: init("\x1B[46m", "\x1B[49m"),
83
- bgWhite: init("\x1B[47m", "\x1B[49m")
84
- };
85
- };
86
- module2.exports = createColors();
87
- module2.exports.createColors = createColors;
88
- }
89
- });
90
-
91
30
  // src/nuxt.ts
92
31
  var nuxt_exports = {};
93
32
  __export(nuxt_exports, {
@@ -103,132 +42,9 @@ var import_unplugin2 = require("unplugin");
103
42
  var import_node_child_process = require("child_process");
104
43
  var import_node_process = __toESM(require("process"), 1);
105
44
  var import_unplugin = require("unplugin");
106
- var import_picocolors = __toESM(require_picocolors(), 1);
107
-
108
- // node_modules/.pnpm/vite-plugin-vconsole@2.1.1/node_modules/vite-plugin-vconsole/dist/main.mjs
109
- var parseVConsoleOptions = (config2) => Object.keys(config2).reduce((code, key) => {
110
- const value = config2[key];
111
- if (typeof value === "function") {
112
- if (/^[(f]/.test(value.toString())) {
113
- code += `${key}: ${value},`;
114
- return code;
115
- } else {
116
- code += `${value},`;
117
- return code;
118
- }
119
- }
120
- code += `${key}: ${JSON.stringify(config2[key])},`;
121
- return code;
122
- }, "");
123
- var getEventItems = (event, id) => {
124
- return event.map(
125
- (ele) => `
126
- ${id}.on('${ele.eventName}', ${ele.callback})
127
- `
128
- ).join(";");
129
- };
130
- var getDynamicConfig = (dynamicConfig) => {
131
- let configString = "";
132
- if (!dynamicConfig) {
133
- return configString;
134
- }
135
- for (const key in dynamicConfig) {
136
- if (typeof dynamicConfig[key] === "string") {
137
- configString += `${key}: ${dynamicConfig[key]},`;
138
- }
139
- }
140
- return configString;
141
- };
142
- var getPlugins = (plugin) => {
143
- let plugins = "";
144
- if (plugin && plugin.length) {
145
- plugins = plugin.map(
146
- (e) => `
147
- const ${e.id} = new VConsole.VConsolePlugin('${e.id}', '${e.name}');
148
- ${getEventItems(e.event, e.id)}
149
- vConsole.addPlugin(${e.id})
150
- `
151
- ).join(";");
152
- }
153
- return plugins;
154
- };
155
- function viteVConsole(opt) {
156
- const {
157
- entry,
158
- enabled = true,
159
- config: config2 = {},
160
- plugin,
161
- customHide = false,
162
- dynamicConfig = {},
163
- eventListener = ""
164
- } = opt;
165
- let entryPath = Array.isArray(entry) ? entry : [entry];
166
- if (process.platform === "win32")
167
- entryPath = entryPath.map((item) => item.replace(/\\/g, "/"));
168
- const enabledTruly = enabled;
169
- return {
170
- name: "vite:vconsole",
171
- enforce: "pre",
172
- transform(_source, id) {
173
- if (entryPath.includes(id) && enabledTruly) {
174
- const code = `/* eslint-disable */;
175
- import VConsole from 'vconsole';
176
- // config
177
- const vConsole = new VConsole({${parseVConsoleOptions(
178
- config2
179
- )}});
180
- window.vConsole = vConsole;
181
-
182
- // plugins
183
- ${getPlugins(plugin)}
184
-
185
- // dynamic config
186
- window.vConsole.dynamicFunction = function() {
187
- if (${getDynamicConfig(dynamicConfig).length > 0}) {
188
- vConsole.setOption({${getDynamicConfig(dynamicConfig)}});
189
- }
190
- };
191
-
192
- window.vConsole.dynamicChange = {
193
- value: new Date().getTime()
194
- };
195
-
196
- window.vConsole.dynamicFunction();
197
-
198
- if (${customHide}) {
199
- vConsole.hideSwitch();
200
- }
201
-
202
- // In order to be compatible with old equipment, I used defineProperty. In the future, when proxy covers enough devices, proxy will be used.
203
- Object.defineProperty(window.vConsole.dynamicChange, 'value', {
204
- get: function() {
205
- return this._value;
206
- },
207
- set: function(newValue) {
208
- window.vConsole.dynamicFunction();
209
- this._value = newValue;
210
- }
211
- });
212
-
213
- // eventListener
214
- ${eventListener}
215
- /* eslint-enable */${_source}`;
216
- return {
217
- code,
218
- map: null
219
- // support source map
220
- };
221
- }
222
- return {
223
- code: _source,
224
- map: null
225
- // support source map
226
- };
227
- }
228
- };
229
- }
230
-
231
- // src/index.ts
45
+ var import_picocolors = __toESM(require("picocolors"), 1);
46
+ var import_vite_plugin_vconsole = require("vite-plugin-vconsole");
47
+ var import_cookie = __toESM(require("cookie"), 1);
232
48
  var config;
233
49
  var devtoolsInstance;
234
50
  var colorUrl = (url) => import_picocolors.default.green(url.replace(/:(\d+)\//, (_, port) => `:${import_picocolors.default.bold(port)}/`));
@@ -295,6 +111,20 @@ var unpluginFactory = (options) => {
295
111
  if (options == null ? void 0 : options.corpId) {
296
112
  targetURL.searchParams.append("corpId", options.corpId);
297
113
  }
114
+ if (options.debugCookies && options.debugCookies.length > 0) {
115
+ server.middlewares.use((req, res, next) => {
116
+ const cookies = import_cookie.default.parse(req.headers.cookie || "");
117
+ for (const [name, value] of Object.entries(cookies)) {
118
+ if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
119
+ const serializedCookie = import_cookie.default.serialize(name, value, {
120
+ httpOnly: false
121
+ });
122
+ res.setHeader("Set-Cookie", serializedCookie);
123
+ }
124
+ }
125
+ next();
126
+ });
127
+ }
298
128
  server.middlewares.use("/open-dingtalk", (req, res) => {
299
129
  var _a3;
300
130
  debug(targetURL.toString());
@@ -319,7 +149,7 @@ var unpluginFactory = (options) => {
319
149
  }
320
150
  };
321
151
  if ((options == null ? void 0 : options.enable) && ((_a = options == null ? void 0 : options.vconsole) == null ? void 0 : _a.enabled)) {
322
- return [viteVConsole(options == null ? void 0 : options.vconsole), unpluginDing];
152
+ return [(0, import_vite_plugin_vconsole.viteVConsole)(options == null ? void 0 : options.vconsole), unpluginDing];
323
153
  } else {
324
154
  return unpluginDing;
325
155
  }
package/dist/nuxt.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  webpack_default
3
- } from "./chunk-BNQALGGL.js";
3
+ } from "./chunk-3GLWV5IZ.js";
4
4
  import {
5
5
  vite_default
6
- } from "./chunk-KEG2NDRE.js";
7
- import "./chunk-QTZOG6NL.js";
6
+ } from "./chunk-U5NNQ27H.js";
7
+ import "./chunk-PSBADVC6.js";
8
8
 
9
9
  // src/nuxt.ts
10
10
  import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";