create-ax-trusted-plugin 1.0.15 → 1.0.16
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/package.json +1 -1
- package/template/README.md +7 -5
- package/template/_gitignore +4 -3
- package/template/manifest.config.ts +28 -0
- package/template/package.json +1 -1
- package/template/tsconfig.json +15 -15
- package/template/manifest.json +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ax-trusted-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "可信(internal)插件脚手架:一条命令生成一个基于 @ax-npm/host-trusted-sdk-v4 的可信插件骨架(ESM 直出 activate + 自带 Vue,dev 裸 vite 原生 sourcemap)。用法:npm create ax-trusted-plugin <id>。生成器本身无机密,公网可装;生成出的工程仍走私有源拉 @ax-npm/* 依赖。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/template/README.md
CHANGED
|
@@ -9,12 +9,13 @@ export GITLAB_TOKEN=<读权限 PAT> # bash / git-bash
|
|
|
9
9
|
# $env:GITLAB_TOKEN="<读权限 PAT>" # PowerShell(别用 set / %VAR%)
|
|
10
10
|
# set GITLAB_TOKEN=<读权限 PAT> # cmd
|
|
11
11
|
npm install
|
|
12
|
-
npm run dev # concurrently: vite(:5174
|
|
12
|
+
npm run dev # concurrently: vite(:5174,本插件 dev 服务) + host-dev 真宿主/编排器(:5173)
|
|
13
13
|
```
|
|
14
|
-
浏览器打开 `http://localhost:5173`,锚点出现「__TITLE__」面板。**改代码 →
|
|
14
|
+
浏览器打开 `http://localhost:5173`,锚点出现「__TITLE__」面板。**改代码 → HMR/刷新即生效**(原生 sourcemap)。
|
|
15
15
|
|
|
16
|
-
> dev 走裸 `vite`:`vite.config.ts` 一行调 `trustedPluginConfig`
|
|
17
|
-
>
|
|
16
|
+
> dev 走裸 `vite`:`vite.config.ts` 一行调 `trustedPluginConfig` 预设(只做编译/资源内联/清单落盘,**不再伪装市场根**)。
|
|
17
|
+
> `host-dev` 是唯一市场根(编排器):它抓本插件 `/manifest.json`、按 `devEntry` 把入口顶替为 `src/index.ts` 并 302 重定向到本 vite,
|
|
18
|
+
> 同时带上默认插件集(head-info/func-panel)一起跑。多插件并行:各自 `trustedPluginConfig({ port: 5175 })` + 追加 `--plugin`(或用 `axdev.json`)。
|
|
18
19
|
|
|
19
20
|
## 构建 / 上架
|
|
20
21
|
```bash
|
|
@@ -23,7 +24,8 @@ npm run build # → dist/main.js(+ main.js.map)
|
|
|
23
24
|
把 `dist/main.js`(+ `.map`)+ `manifest.json` 部署到静态源,在宿主市场 `plugins.json` 登记本插件 id(及 `baseUrl`)即可加载。
|
|
24
25
|
|
|
25
26
|
## 关键约定
|
|
26
|
-
- 入口 `src/index.ts` 必须 `export function activate(ctx)`(可选 `elementTag`/`deactivate`);`manifest.entry`=`main.js
|
|
27
|
+
- 入口 `src/index.ts` 必须 `export function activate(ctx)`(可选 `elementTag`/`deactivate`);`manifest.entry`=`main.js`(运行产物)、`manifest.devEntry`=`src/index.ts`(dev 联调,host-dev 编排器据此顶替入口)。
|
|
28
|
+
- **清单源在 `manifest.config.ts`**(非手写 `manifest.json`)。`uses`/`contributes` 里的宿主能力直接引用**能力 token**(如 `MAP_COMMANDS.FLY_TO`),即唯一事实源——能力改名会编译期报错,不再手抄字符串;自有能力(`__ID__/...`)仍写字符串。预设据此:**dev/build 都把清单写到项目根 `manifest.json`(已 `.gitignore`),由本插件 vite 静态托管供 host-dev 编排器抓取**;`npm run build` 另拷一份进 `dist/` 供依赖包化与部署。
|
|
27
29
|
- 预设的 `vue({customElement:true})` 把样式注入 shadow root;Vue 自带打包,不与宿主共享。
|
|
28
30
|
- 静态资源:直接 `import x from './x.png'`(无需 `?inline`),预设保证 dev/build 都内联成 data URI(可信插件跑在宿主 origin,普通 URL 会裂图);大图用 `new URL('./big.png', import.meta.url).href`。
|
|
29
31
|
- 提供能力须命名空间化(`__ID__/...`)且在 `contributes.capabilities` 声明;消费(含**调自己提供的能力**)须在 `uses.capabilities` 声明——contributes 与 uses 是两道独立门,`execute` 一律过 uses 闸。
|
package/template/_gitignore
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
dist
|
|
3
|
-
*.tgz
|
|
1
|
+
node_modules
|
|
2
|
+
dist
|
|
3
|
+
*.tgz
|
|
4
|
+
manifest.json
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// 可信插件清单的「源」—— 唯一事实源在此。`uses`/`contributes` 直接引用能力 token
|
|
2
|
+
//(如 MAP_COMMANDS.FLY_TO),能力改名即编译期报错,不必手抄字符串。
|
|
3
|
+
// vite 预设(trustedPluginConfig)据此:dev/build 都把清单写到项目根 manifest.json(已 .gitignore),
|
|
4
|
+
// 由本插件自身 vite 静态托管供 host-dev 编排器抓取;build 另拷进 dist/ 供依赖包化与部署。
|
|
5
|
+
import { defineManifest, MAP_COMMANDS } from '@ax-npm/host-trusted-sdk-v4';
|
|
6
|
+
|
|
7
|
+
export default defineManifest({
|
|
8
|
+
id: '__ID__',
|
|
9
|
+
version: '0.1.0',
|
|
10
|
+
trust: 'internal',
|
|
11
|
+
host: '^1.0.0',
|
|
12
|
+
entry: 'main.js', // 运行产物(宿主壳只读此入口)
|
|
13
|
+
devEntry: 'src/index.ts', // dev 联调:host-dev 编排器顶替 entry,插件 vite 实时转译(HMR/sourcemap)
|
|
14
|
+
activationEvents: ['onStartup'],
|
|
15
|
+
// 提供侧:本插件注册的能力 id(自有,命名空间化),register 的 id 须在此声明。
|
|
16
|
+
contributes: { capabilities: ['__ID__/ping'] },
|
|
17
|
+
// 消费侧:要调用的能力。宿主能力写 token(SSOT);自有能力写字符串。
|
|
18
|
+
uses: { capabilities: [MAP_COMMANDS.FLY_TO, '__ID__/ping'] },
|
|
19
|
+
component: {
|
|
20
|
+
anchor: '__ANCHOR__',
|
|
21
|
+
width: 320,
|
|
22
|
+
height: 220,
|
|
23
|
+
title: '__TITLE__',
|
|
24
|
+
visible: true,
|
|
25
|
+
pinned: true,
|
|
26
|
+
passthrough: true,
|
|
27
|
+
},
|
|
28
|
+
});
|
package/template/package.json
CHANGED
package/template/tsconfig.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "Bundler",
|
|
6
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
-
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"noEmit": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"types": []
|
|
13
|
-
},
|
|
14
|
-
"include": ["src", "vite.config.ts"]
|
|
15
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"noEmit": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"types": []
|
|
13
|
+
},
|
|
14
|
+
"include": ["src", "vite.config.ts", "manifest.config.ts"]
|
|
15
|
+
}
|
package/template/manifest.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "__ID__",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"trust": "internal",
|
|
5
|
-
"host": "^1.0.0",
|
|
6
|
-
"entry": "main.js",
|
|
7
|
-
"activationEvents": ["onStartup"],
|
|
8
|
-
"contributes": { "capabilities": ["__ID__/ping"] },
|
|
9
|
-
"uses": { "capabilities": ["map.flyTo", "__ID__/ping"] },
|
|
10
|
-
"component": {
|
|
11
|
-
"anchor": "__ANCHOR__",
|
|
12
|
-
"width": 320,
|
|
13
|
-
"height": 220,
|
|
14
|
-
"title": "__TITLE__",
|
|
15
|
-
"visible": true,
|
|
16
|
-
"pinned": true,
|
|
17
|
-
"passthrough": true
|
|
18
|
-
}
|
|
19
|
-
}
|