unplugin-dingtalk 0.2.0 → 0.3.1
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/README.md +33 -3
- package/dist/astro.cjs +6573 -55
- package/dist/astro.d.cts +1 -0
- package/dist/astro.d.ts +1 -0
- package/dist/astro.js +2 -1
- package/dist/chunk-E34H52KV.js +1493 -0
- package/dist/chunk-OVAVOVTT.js +83 -0
- package/dist/chunk-PMOTCIQR.js +4834 -0
- package/dist/chunk-Q26XYG3E.js +19 -0
- package/dist/esbuild.cjs +6572 -54
- package/dist/esbuild.d.cts +1 -0
- package/dist/esbuild.d.ts +1 -0
- package/dist/esbuild.js +2 -1
- package/dist/index.cjs +6575 -55
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +4 -1
- package/dist/multipart-parser-HI4LNJC5.js +368 -0
- package/dist/nuxt.cjs +6654 -58
- package/dist/nuxt.d.cts +1 -0
- package/dist/nuxt.d.ts +1 -0
- package/dist/nuxt.js +4 -3
- package/dist/rollup.cjs +6572 -54
- package/dist/rollup.d.cts +1 -0
- package/dist/rollup.d.ts +1 -0
- package/dist/rollup.js +2 -1
- package/dist/rspack.cjs +6572 -54
- package/dist/rspack.d.cts +1 -0
- package/dist/rspack.d.ts +1 -0
- package/dist/rspack.js +2 -1
- package/dist/types.d.cts +4 -1
- package/dist/types.d.ts +4 -1
- package/dist/vite.cjs +6580 -54
- package/dist/vite.d.cts +3 -2
- package/dist/vite.d.ts +3 -2
- package/dist/vite.js +3 -2
- package/dist/webpack.cjs +6639 -53
- package/dist/webpack.d.cts +3 -2
- package/dist/webpack.d.ts +3 -2
- package/dist/webpack.js +3 -2
- package/package.json +4 -2
- package/dist/chunk-GRAT7SP7.js +0 -166
- package/dist/chunk-IN7LDV4O.js +0 -11
- package/dist/chunk-N4ZALPAK.js +0 -11
package/dist/webpack.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as webpack from 'webpack';
|
|
2
|
-
import { Options } from './types.cjs';
|
|
2
|
+
import { Options, SetupMiddlewares } from './types.cjs';
|
|
3
|
+
import 'webpack-dev-server';
|
|
3
4
|
import 'vite-plugin-vconsole';
|
|
4
5
|
|
|
5
|
-
declare const _default: (options
|
|
6
|
+
declare const _default: (options: Options) => readonly [SetupMiddlewares, webpack.WebpackPluginInstance];
|
|
6
7
|
|
|
7
8
|
export { _default as default };
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as webpack from 'webpack';
|
|
2
|
-
import { Options } from './types.js';
|
|
2
|
+
import { Options, SetupMiddlewares } from './types.js';
|
|
3
|
+
import 'webpack-dev-server';
|
|
3
4
|
import 'vite-plugin-vconsole';
|
|
4
5
|
|
|
5
|
-
declare const _default: (options
|
|
6
|
+
declare const _default: (options: Options) => readonly [SetupMiddlewares, webpack.WebpackPluginInstance];
|
|
6
7
|
|
|
7
8
|
export { _default as default };
|
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-dingtalk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/zcf0508/unplugin-dingtalk#readme",
|
|
@@ -136,13 +136,15 @@
|
|
|
136
136
|
"eslint": "^8.55.0",
|
|
137
137
|
"esno": "^4.0.0",
|
|
138
138
|
"fast-glob": "^3.3.2",
|
|
139
|
+
"node-fetch": "^3.3.2",
|
|
139
140
|
"nodemon": "^3.0.2",
|
|
140
141
|
"rimraf": "^5.0.5",
|
|
141
142
|
"rollup": "^4.6.1",
|
|
142
143
|
"tsup": "^8.0.1",
|
|
143
144
|
"vite": "^5.0.4",
|
|
144
145
|
"vitest": "^0.34.6",
|
|
145
|
-
"webpack": "^5.89.0"
|
|
146
|
+
"webpack": "^5.89.0",
|
|
147
|
+
"webpack-dev-server": "^5.0.4"
|
|
146
148
|
},
|
|
147
149
|
"scripts": {
|
|
148
150
|
"build": "tsup",
|
package/dist/chunk-GRAT7SP7.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import { exec } from "child_process";
|
|
3
|
-
import process from "process";
|
|
4
|
-
import { createUnplugin } from "unplugin";
|
|
5
|
-
import c from "picocolors";
|
|
6
|
-
import { viteVConsole } from "vite-plugin-vconsole";
|
|
7
|
-
import cookie from "cookie";
|
|
8
|
-
import { start } from "chii";
|
|
9
|
-
import { getRandomPort } from "get-port-please";
|
|
10
|
-
var config;
|
|
11
|
-
var devtoolsInstance;
|
|
12
|
-
var colorUrl = (url) => c.green(url.replace(/:(\d+)\//, (_, port) => `:${c.bold(port)}/`));
|
|
13
|
-
var availablePort;
|
|
14
|
-
var unpluginFactory = (options) => {
|
|
15
|
-
var _a;
|
|
16
|
-
const {
|
|
17
|
-
chii: enableChii = true
|
|
18
|
-
} = options || {};
|
|
19
|
-
function debug(...args) {
|
|
20
|
-
if (options == null ? void 0 : options.debug) {
|
|
21
|
-
console.log(` ${c.yellow("DEBUG")} `, ...args);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const unpluginDing = {
|
|
25
|
-
name: "unplugin-dingtalk",
|
|
26
|
-
enforce: "pre",
|
|
27
|
-
transformInclude(id) {
|
|
28
|
-
return id.endsWith("main.ts") || id.endsWith("main.js");
|
|
29
|
-
},
|
|
30
|
-
async transform(_source) {
|
|
31
|
-
var _a2, _b, _c;
|
|
32
|
-
if ((options == null ? void 0 : options.enable) && enableChii) {
|
|
33
|
-
availablePort = await getRandomPort();
|
|
34
|
-
debug(`chii server port: ${JSON.stringify({ availablePort })}`);
|
|
35
|
-
start({
|
|
36
|
-
port: availablePort
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if ((options == null ? void 0 : options.enable) && ((_a2 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a2.enable)) {
|
|
40
|
-
const codes = [
|
|
41
|
-
`/* eslint-disable */;
|
|
42
|
-
import { devtools } from '@vue/devtools'
|
|
43
|
-
devtools.connect(${(_b = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _b.host}, ${(_c = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _c.port});`,
|
|
44
|
-
(options == null ? void 0 : options.enable) && enableChii ? `(() => {
|
|
45
|
-
const script = document.createElement('script');
|
|
46
|
-
script.src="http://localhost:${availablePort}/target.js";
|
|
47
|
-
document.body.appendChild(script);
|
|
48
|
-
})()` : "",
|
|
49
|
-
`/* eslint-enable */${_source};`
|
|
50
|
-
];
|
|
51
|
-
return {
|
|
52
|
-
code: codes.join("\n"),
|
|
53
|
-
map: null
|
|
54
|
-
// support source map
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
code: _source,
|
|
59
|
-
map: null
|
|
60
|
-
// support source map
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
vite: {
|
|
64
|
-
configResolved(_config) {
|
|
65
|
-
config = _config;
|
|
66
|
-
},
|
|
67
|
-
async configureServer(server) {
|
|
68
|
-
var _a2, _b;
|
|
69
|
-
if (!(options == null ? void 0 : options.enable)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const _printUrls = server.printUrls.bind(server);
|
|
73
|
-
let source = `localhost:${config.server.port || 5173}`;
|
|
74
|
-
const url = (_a2 = server.resolvedUrls) == null ? void 0 : _a2.local[0];
|
|
75
|
-
if (url) {
|
|
76
|
-
const u = new URL(url);
|
|
77
|
-
source = u.host;
|
|
78
|
-
}
|
|
79
|
-
const base = server.config.base || "/";
|
|
80
|
-
const _targetUrl = (_b = options == null ? void 0 : options.targetUrl) != null ? _b : `http://${source}${base}`;
|
|
81
|
-
server.printUrls = () => {
|
|
82
|
-
var _a3;
|
|
83
|
-
_printUrls();
|
|
84
|
-
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
85
|
-
`Open in dingtalk${((_a3 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a3.enable) ? " (with vue-devtools)" : ""}`
|
|
86
|
-
)}: ${colorUrl(`http://${source}${base}open-dingtalk`)}`);
|
|
87
|
-
if (enableChii) {
|
|
88
|
-
console.log(` ${c.green("\u279C")} ${c.bold(
|
|
89
|
-
"Click to open chrome devtools"
|
|
90
|
-
)}: ${colorUrl(`http://${source}${base}__chrome_devtools`)}`);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const targetURL = new URL(_targetUrl);
|
|
94
|
-
targetURL.searchParams.append("ddtab", "true");
|
|
95
|
-
if (options == null ? void 0 : options.corpId) {
|
|
96
|
-
targetURL.searchParams.append("corpId", options.corpId);
|
|
97
|
-
}
|
|
98
|
-
if (options.debugCookies && options.debugCookies.length > 0) {
|
|
99
|
-
server.middlewares.use((req, res, next) => {
|
|
100
|
-
const cookies = cookie.parse(req.headers.cookie || "");
|
|
101
|
-
for (const [name, value] of Object.entries(cookies)) {
|
|
102
|
-
if (options.debugCookies && options.debugCookies.length > 0 && options.debugCookies.includes(name)) {
|
|
103
|
-
const serializedCookie = cookie.serialize(name, value, {
|
|
104
|
-
httpOnly: false
|
|
105
|
-
});
|
|
106
|
-
res.setHeader("Set-Cookie", serializedCookie);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
next();
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
if (enableChii) {
|
|
113
|
-
server.middlewares.use("/__chrome_devtools", async (_req, res) => {
|
|
114
|
-
try {
|
|
115
|
-
const raw = await fetch(`http://localhost:${availablePort}/targets`);
|
|
116
|
-
const data = await raw.json();
|
|
117
|
-
if ((data == null ? void 0 : data.targets.length) > 0) {
|
|
118
|
-
const devToolsUrl = `http://localhost:${availablePort}/front_end/chii_app.html?ws=localhost:${availablePort}/client/${Math.random().toString(20).substring(2, 8)}?target=${data.targets[0].id}&rtc=false`;
|
|
119
|
-
res.writeHead(302, { Location: devToolsUrl });
|
|
120
|
-
res.end();
|
|
121
|
-
}
|
|
122
|
-
} catch (error) {
|
|
123
|
-
debug(`${error}`);
|
|
124
|
-
res.writeHead(502);
|
|
125
|
-
res.end();
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
server.middlewares.use("/open-dingtalk", (req, res) => {
|
|
130
|
-
var _a3;
|
|
131
|
-
debug(targetURL.toString());
|
|
132
|
-
res.writeHead(302, {
|
|
133
|
-
Location: `dingtalk://dingtalkclient/page/link?url=${encodeURIComponent(targetURL.toString())}`
|
|
134
|
-
});
|
|
135
|
-
if (((_a3 = options == null ? void 0 : options.vueDevtools) == null ? void 0 : _a3.enable) && !devtoolsInstance) {
|
|
136
|
-
devtoolsInstance = exec("npx vue-devtools");
|
|
137
|
-
console.log(` ${c.green("\u279C")} vue-devtools is running. If the devtools has no data, please refresh the page in dingtalk.`);
|
|
138
|
-
devtoolsInstance.on("exit", () => {
|
|
139
|
-
devtoolsInstance = void 0;
|
|
140
|
-
});
|
|
141
|
-
process.on("exit", () => {
|
|
142
|
-
if (devtoolsInstance) {
|
|
143
|
-
devtoolsInstance.kill();
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
res.end();
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
const plugins = [];
|
|
153
|
-
if ((options == null ? void 0 : options.enable) && ((_a = options == null ? void 0 : options.vconsole) == null ? void 0 : _a.enabled)) {
|
|
154
|
-
plugins.push(viteVConsole(options == null ? void 0 : options.vconsole));
|
|
155
|
-
}
|
|
156
|
-
plugins.push(unpluginDing);
|
|
157
|
-
return plugins;
|
|
158
|
-
};
|
|
159
|
-
var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
160
|
-
var src_default = unplugin;
|
|
161
|
-
|
|
162
|
-
export {
|
|
163
|
-
unpluginFactory,
|
|
164
|
-
unplugin,
|
|
165
|
-
src_default
|
|
166
|
-
};
|
package/dist/chunk-IN7LDV4O.js
DELETED