@adep/vite-plugin 0.1.7 → 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/LICENSE +58 -0
- package/dist/ide-proxy.d.ts +3 -1
- package/dist/index.js +6 -6
- package/package.json +12 -15
package/LICENSE
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 yunke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Commercial Modules Reservation
|
|
26
|
+
|
|
27
|
+
The MIT license above applies to this repository EXCEPT the following
|
|
28
|
+
directories, which are proprietary commercial modules and are NOT licensed
|
|
29
|
+
under MIT (2026-10-05 decision, dual-track licensing):
|
|
30
|
+
|
|
31
|
+
- server/domains/billing/
|
|
32
|
+
- server/domains/appbuild/
|
|
33
|
+
- server/domains/license/
|
|
34
|
+
- server/domains/wallet/
|
|
35
|
+
- server/domains/voucher/
|
|
36
|
+
|
|
37
|
+
Each of these directories contains its own LICENSE.md stating the applicable
|
|
38
|
+
terms. They are licensed exclusively under the AgentDeploy Commercial License
|
|
39
|
+
and distributed under separate commercial agreements. All rights reserved.
|
|
40
|
+
No part of these modules may be copied, modified, distributed, or used
|
|
41
|
+
outside the terms of such commercial agreements.
|
|
42
|
+
|
|
43
|
+
Everything else in this repository — including the platform core, all
|
|
44
|
+
packages published to npm as `@adep/*`, the frontend application, and public
|
|
45
|
+
documentation — is licensed under the MIT license stated above.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
Trademark Notice
|
|
50
|
+
|
|
51
|
+
This license grants rights to use, copy, modify and distribute the source code
|
|
52
|
+
and software of this repository only. It does not grant any right, title or
|
|
53
|
+
interest in the trademarks, service marks, logos or brand names of the project
|
|
54
|
+
(including but not limited to "AgentDeploy", "云柯驿站" and related marks),
|
|
55
|
+
which remain the exclusive property of the project owner. Use of project
|
|
56
|
+
trademarks for purposes of identifying forked deployments must comply with
|
|
57
|
+
fair-use principles and must not suggest endorsement by or affiliation with
|
|
58
|
+
the project.
|
package/dist/ide-proxy.d.ts
CHANGED
|
@@ -44,8 +44,10 @@ export declare const FN_FETCH_INTERCEPTOR_SCRIPT = "(function () {\n if (window
|
|
|
44
44
|
*
|
|
45
45
|
* 信封 `{ source: 'adep-ide-preview', kind: 'console', level, text }` 由 IDE 的
|
|
46
46
|
* `FrontendPreview.onMessage` 消费;`window.parent === window`(直接打开 / 分享链接)不发。
|
|
47
|
+
* 另侦测 vite 构建错误浮层(`vite-error-overlay`),以 `{ kind: 'build-error', message,
|
|
48
|
+
* file?, line?, column? }` 回传——报错收件箱 `source: 'build'` 的生产端(VIBE-011)。
|
|
47
49
|
*/
|
|
48
|
-
export declare const CONSOLE_RELAY_SCRIPT = "(function () {\n if (window.__adepErrorRelayInstalled) return;\n window.__adepErrorRelayInstalled = true;\n var LEVELS = { log: \"log\", info: \"info\", warn: \"warn\", error: \"error\", debug: \"log\" };\n function fmt(value) {\n try {\n if (typeof value === \"string\") return value;\n if (value === undefined) return \"undefined\";\n var seen = [];\n var json = JSON.stringify(value, function (key, val) {\n if (val instanceof Error) return val.stack || (val.name + \": \" + val.message);\n if (typeof val === \"function\") return \"[Function \" + (val.name || \"anonymous\") + \"]\";\n if (typeof val === \"bigint\") return String(val) + \"n\";\n if (val && typeof val === \"object\") {\n if (seen.indexOf(val) !== -1) return \"[Circular]\";\n seen.push(val);\n }\n return val;\n });\n return json === undefined ? String(value) : json;\n } catch {\n return String(value);\n }\n }\n function send(level, args) {\n try {\n if (window.parent === window) return;\n var text = Array.prototype.map.call(args, fmt).join(\" \");\n window.parent.postMessage({ source: \"adep-ide-preview\", kind: \"console\", level: level, text: text }, \"*\");\n } catch {\n }\n }\n Object.keys(LEVELS).forEach(function (name) {\n var native = console[name];\n console[name] = function () {\n send(LEVELS[name], arguments);\n native.apply(console, arguments);\n };\n });\n window.addEventListener('error', function (event) {\n var text = event.message || \"Script error\";\n if (event.filename) {\n text += \" (\" + event.filename + \":\" + event.lineno + \":\" + event.colno + \")\";\n }\n send(\"error\", [text]);\n });\n window.addEventListener('unhandledrejection', function (event) {\n var reason = event.reason;\n var text = reason && reason.stack ? String(reason.stack) : \"Unhandled rejection: \" + fmt(reason);\n send(\"error\", [text]);\n });\n})();\n";
|
|
50
|
+
export declare const CONSOLE_RELAY_SCRIPT = "(function () {\n if (window.__adepErrorRelayInstalled) return;\n window.__adepErrorRelayInstalled = true;\n var LEVELS = { log: \"log\", info: \"info\", warn: \"warn\", error: \"error\", debug: \"log\" };\n function fmt(value) {\n try {\n if (typeof value === \"string\") return value;\n if (value === undefined) return \"undefined\";\n var seen = [];\n var json = JSON.stringify(value, function (key, val) {\n if (val instanceof Error) return val.stack || (val.name + \": \" + val.message);\n if (typeof val === \"function\") return \"[Function \" + (val.name || \"anonymous\") + \"]\";\n if (typeof val === \"bigint\") return String(val) + \"n\";\n if (val && typeof val === \"object\") {\n if (seen.indexOf(val) !== -1) return \"[Circular]\";\n seen.push(val);\n }\n return val;\n });\n return json === undefined ? String(value) : json;\n } catch {\n return String(value);\n }\n }\n function send(level, args) {\n try {\n if (window.parent === window) return;\n var text = Array.prototype.map.call(args, fmt).join(\" \");\n window.parent.postMessage({ source: \"adep-ide-preview\", kind: \"console\", level: level, text: text }, \"*\");\n } catch {\n }\n }\n Object.keys(LEVELS).forEach(function (name) {\n var native = console[name];\n console[name] = function () {\n send(LEVELS[name], arguments);\n native.apply(console, arguments);\n };\n });\n window.addEventListener('error', function (event) {\n var text = event.message || \"Script error\";\n if (event.filename) {\n text += \" (\" + event.filename + \":\" + event.lineno + \":\" + event.colno + \")\";\n }\n send(\"error\", [text]);\n });\n window.addEventListener('unhandledrejection', function (event) {\n var reason = event.reason;\n var text = reason && reason.stack ? String(reason.stack) : \"Unhandled rejection: \" + fmt(reason);\n send(\"error\", [text]);\n });\n function reportBuildError(overlay) {\n try {\n if (window.parent === window) return;\n var root = overlay.shadowRoot;\n if (!root) return;\n var msgEl = root.querySelector(\".message\");\n var message = msgEl ? String(msgEl.textContent || \"\").trim() : \"\";\n if (!message) return;\n var payload = { source: \"adep-ide-preview\", kind: \"build-error\", message: message };\n var fileEl = root.querySelector(\".file\");\n if (fileEl) {\n var loc = /^(.*?):(\\d+):(\\d+)$/.exec(String(fileEl.textContent || \"\").trim());\n if (loc) {\n payload.file = loc[1];\n payload.line = Number(loc[2]);\n payload.column = Number(loc[3]);\n }\n }\n window.parent.postMessage(payload, \"*\");\n } catch {\n }\n }\n function watchOverlays(scope) {\n if (!scope || typeof MutationObserver === \"undefined\") return;\n new MutationObserver(function (records) {\n for (var i = 0; i < records.length; i++) {\n var added = records[i].addedNodes;\n for (var j = 0; j < added.length; j++) {\n var node = added[j];\n if (node.nodeType === 1 && /^vite-error-overlay$/i.test(node.tagName || \"\")) reportBuildError(node);\n }\n }\n }).observe(scope, { childList: true, subtree: true });\n }\n if (typeof document !== \"undefined\" && document.documentElement) watchOverlays(document.documentElement);\n})();\n";
|
|
49
51
|
/**
|
|
50
52
|
* 构造中间件:serve `/@adep/fn-proxy.js`(返回上面的拦截器脚本)。
|
|
51
53
|
* vite dev / preview server 均挂;路径未命中则 next() 放行。
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// src/dev-server.ts
|
|
1
|
+
// packages/vite-plugin/src/dev-server.ts
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
|
|
4
|
-
// src/prefix.ts
|
|
4
|
+
// packages/vite-plugin/src/prefix.ts
|
|
5
5
|
function normalizeFunctionPrefix(raw) {
|
|
6
6
|
const value = (raw ?? "").trim();
|
|
7
7
|
if (value.length === 0 || value === "/") return "";
|
|
8
8
|
return value.replace(/^\/+|\/+$/g, "");
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
// src/proxy.ts
|
|
11
|
+
// packages/vite-plugin/src/proxy.ts
|
|
12
12
|
import { request as httpRequest } from "node:http";
|
|
13
13
|
function isAddrInUse(error) {
|
|
14
14
|
return typeof error === "object" && error !== null && "code" in error && error.code === "EADDRINUSE";
|
|
@@ -48,7 +48,7 @@ function createAdepProxyMiddleware(prefix, targetBase) {
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
// src/preview-automation.ts
|
|
51
|
+
// packages/vite-plugin/src/preview-automation.ts
|
|
52
52
|
var PREVIEW_AUTOMATION_SCRIPT = `(function () {
|
|
53
53
|
if (window.__adepAutomationInstalled) return;
|
|
54
54
|
window.__adepAutomationInstalled = true;
|
|
@@ -519,7 +519,7 @@ var PREVIEW_AUTOMATION_SCRIPT = `(function () {
|
|
|
519
519
|
})();
|
|
520
520
|
`;
|
|
521
521
|
|
|
522
|
-
// src/ide-proxy.ts
|
|
522
|
+
// packages/vite-plugin/src/ide-proxy.ts
|
|
523
523
|
var FN_FETCH_INTERCEPTOR_SCRIPT = `(function () {
|
|
524
524
|
if (window.__adepFnProxyInstalled) return;
|
|
525
525
|
window.__adepFnProxyInstalled = true;
|
|
@@ -704,7 +704,7 @@ function injectAutomationScriptTag(html) {
|
|
|
704
704
|
return html.replace("</head>", '<script src="/@adep/automation.js"></script></head>');
|
|
705
705
|
}
|
|
706
706
|
|
|
707
|
-
// src/dev-server.ts
|
|
707
|
+
// packages/vite-plugin/src/dev-server.ts
|
|
708
708
|
function adepPlugin(options = {}) {
|
|
709
709
|
const cwd = resolve(options.cwd ?? process.cwd());
|
|
710
710
|
let dev;
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adep/vite-plugin",
|
|
3
|
-
"
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://gitcode.com/yunqiang_wu/ai-yunke.git"
|
|
7
|
+
},
|
|
8
|
+
"homepage": "https://adep.top",
|
|
9
|
+
"bugs": "https://gitcode.com/yunqiang_wu/ai-yunke/issues",
|
|
10
|
+
"version": "0.1.9",
|
|
4
11
|
"private": false,
|
|
5
12
|
"type": "module",
|
|
6
13
|
"description": "云函数 Vite 插件(IDE-030,自 CLI-014 @adep/cli/vite 抽出):vite dev 进程内启动本地 adep dev server 并代理 /{prefix}/* 到云函数;同时 serve /@adep/fn-proxy.js(Web IDE 预览 fetch 拦截器)。本地运行时与配置加载经 createDevServer / loadConfig 注入端口接入,供 CLI / Web IDE / 非 CLI 用户独立使用。",
|
|
7
|
-
"main": "./
|
|
8
|
-
"types": "./
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
9
16
|
"exports": {
|
|
10
17
|
".": {
|
|
11
|
-
"types": "./
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
12
19
|
"default": "./dist/index.js"
|
|
13
20
|
}
|
|
14
21
|
},
|
|
@@ -18,15 +25,5 @@
|
|
|
18
25
|
"scripts": {
|
|
19
26
|
"test": "vitest run",
|
|
20
27
|
"build": "bun run ../../scripts/build-package.ts vite-plugin"
|
|
21
|
-
},
|
|
22
|
-
"publishConfig": {
|
|
23
|
-
"main": "./dist/index.js",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"exports": {
|
|
26
|
-
".": {
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
28
|
-
"default": "./dist/index.js"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
28
|
}
|
|
32
|
-
}
|
|
29
|
+
}
|