create-linkdesk-plugin 0.1.9 → 0.1.11

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 CHANGED
@@ -21,7 +21,7 @@ The generated project has **the same shape as an official plugin** — README /
21
21
  ```
22
22
  my-cool-plugin/
23
23
  ├── plugin.json # plugin manifest (JSONC: comments + trailing commas allowed, sectioned example fields, VS Code $schema validation)
24
- ├── package.json # scripts: dev / dev:real / build / publish / validate / lint / verify / test
24
+ ├── package.json # deps: @linkdesk/ui (resolves the shell's current version line) · scripts: dev / dev:real / build / publish / validate / lint / verify / test
25
25
  ├── tsconfig.json # jsx: react-jsx + window.linkdesk.* types (@linkdesk/plugin-sdk)
26
26
  ├── AGENTS.md # what this project is + the iron rules + where the docs are (for your AI assistant)
27
27
  ├── .gitignore # node_modules / dist / *.linkdesk-plugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-linkdesk-plugin",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "LinkDesk 插件脚手架——`npm create linkdesk-plugin@latest my-cool-plugin` 一行生成你的第一个插件项目(对标 yo code)。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,7 +28,7 @@ You do not need to pre-create empty folders (git does not track them). **Create
28
28
  | `src/styles/` | **Multiple** CSS files — keep them together here (a single file next to the entry is fine too) | When needed |
29
29
  | `src/__tests__/` | Unit tests (run `npm i -D vitest` yourself if you want them — the scaffold does not preinstall test tooling) | When needed |
30
30
 
31
- > 🔴 **Shared things do not belong here** — components/hooks reused across plugins come from `@linkdesk/ui` (the public package the shell provides). **Do not write a second copy inside your plugin.** Only logic that belongs to this plugin stays local.
31
+ > 🔴 **Shared things do not belong here** — components/hooks reused across plugins come from `@linkdesk/ui` (the public package the shell provides; it is already declared in `package.json` as `"latest"`, which resolves to the shell's current version line when you install — pin it to a specific shell version if you need a floor). The shell supplies that one instance at runtime, so **do not import its css** and **do not write a second copy inside your plugin**. Only logic that belongs to this plugin stays local.
32
32
  > 🔴 **Assets always live in `resources/` — no loose images in the plugin root.** What gets into the install package is what is **referenced by the README** or **declared by `icon` / `marketIcon`**; the directory name itself has no magic.
33
33
 
34
34
  ## Three rules for this plugin
@@ -4,6 +4,9 @@
4
4
  "private": true,
5
5
  "description": "{{displayName}}——LinkDesk 插件(由 create-linkdesk-plugin 生成)",
6
6
  "type": "module",
7
+ "dependencies": {
8
+ "@linkdesk/ui": "latest"
9
+ },
7
10
  "scripts": {
8
11
  "dev": "linkdesk-plugin-sdk dev",
9
12
  "dev:real": "linkdesk-plugin-sdk dev --real",
@@ -11,6 +11,8 @@
11
11
  // ── 插件身份 ──
12
12
  // 🔴 插件 ID:**显式声明**。它是安装目录名 / 卸载墓碑 / 更新对账的唯一键,**发布后永不可变**。
13
13
  // 它与插件所在的目录名**无关**(目录可以随便改)——所以别拿目录名当它的替身。
14
+ // ⚠️ 且**不得以 `ldk-` 开头**:`ldk-` 是宿主与共享组件的命名空间,而你在 index.css 里的
15
+ // 类名前缀正是由它派生(`<pluginId>-你的类名`)——以 `ldk-` 开头 = 把自己的名字落进宿主空间。
14
16
  "pluginId": "{{pluginName}}",
15
17
  "name": "{{displayName}}", // 显示名——标签页 / 插件详情等 UI 出现处
16
18
  "version": "0.1.0", // 语义化版本 x.y.z——市场更新比较靠它;+1 时务必同笔补 CHANGELOG.md 的新段
@@ -1,30 +1,33 @@
1
- /* {{displayName}} 样式示例(`npm run lint` 会照着下面三条查)。
2
- 三条纪律:
3
- · 颜色一律 var(--xxx),禁硬编码 hex——用户换主题时你的插件要跟着变;
4
- · 字号一律 var(--font-size-*)——用户调全局字号时它才跟着缩放,裸 px 不会;
5
- · padding / margin / gap 走 4px 节奏(4 的倍数)。 */
6
-
7
- .starter {
8
- padding: 24px;
9
- font-family: inherit;
10
- }
11
-
12
- .starter__title {
13
- margin: 0 0 8px;
14
- color: var(--text);
15
- }
16
-
17
- .starter__text {
18
- margin: 0 0 4px;
19
- color: var(--text-muted);
20
- }
21
-
22
- .starter__hint {
23
- margin: 0;
24
- color: var(--text-muted);
25
- font-size: var(--font-size-xs);
26
- }
27
-
28
- .starter__hint code {
29
- font-family: var(--font-mono, monospace);
30
- }
1
+ /* {{displayName}} 样式示例(`npm run lint` 会照着下面四条查)。
2
+ 四条纪律:
3
+ · 颜色一律 var(--xxx),禁硬编码 hex——用户换主题时你的插件要跟着变;
4
+ · 字号一律 var(--font-size-*)——用户调全局字号时它才跟着缩放,裸 px 不会;
5
+ · padding / margin / gap 走 4px 节奏(4 的倍数);
6
+ · 类名一律以 {{pluginName}}- 开头——插件视图里宿主、共享组件与**所有已加载插件**的
7
+ CSS 在同一张样式表里,裸类名(如 .starter)是全局标识符,会和别人的同名规则
8
+ 互相覆盖(不报错、只是长得不对)。 */
9
+
10
+ .{{pluginName}}-starter {
11
+ padding: 24px;
12
+ font-family: inherit;
13
+ }
14
+
15
+ .{{pluginName}}-starter__title {
16
+ margin: 0 0 8px;
17
+ color: var(--text);
18
+ }
19
+
20
+ .{{pluginName}}-starter__text {
21
+ margin: 0 0 4px;
22
+ color: var(--text-muted);
23
+ }
24
+
25
+ .{{pluginName}}-starter__hint {
26
+ margin: 0;
27
+ color: var(--text-muted);
28
+ font-size: var(--font-size-xs);
29
+ }
30
+
31
+ .{{pluginName}}-starter__hint code {
32
+ font-family: var(--font-mono, monospace);
33
+ }
@@ -1,35 +1,35 @@
1
- /**
2
- * {{displayName}}——LinkDesk 插件主视图(由 create-linkdesk-plugin 生成)。
3
- *
4
- * 视图插件契约(作者文档 01-plugin-api-contract.md):壳以 { isActive, tabId?, sourceId? }
5
- * 渲染本文件 default 导出的组件:
6
- * - isActive 本标签当前是否聚焦。keep-alive 下非聚焦标签仍在渲染,isActive 只用于
7
- * gate「聚焦才跑」的副作用(如自动保存),切勿用它整块 blank 掉内容。
8
- * - tabId 本标签页 id。
9
- * - sourceId 上下文数据(文件路径 / 数据源等),编辑器类插件用它定位内容。
10
- *
11
- * 样式:LinkDesk 主题色一律走 CSS 变量 var(--xxx)(见 index.css 示例),禁硬编码 hex。
12
- * 文案:用 t() 读——key 就是中文原文,英文译文放 i18n/en.json(见作者文档 05-ui-conventions.md)。
13
- * 壳已 external react/react-dom/react-i18next/i18next——构建不会打进包,插件工程无需 npm i 它们。
14
- */
15
-
16
- import { useTranslation } from "react-i18next";
17
- import "./index.css";
18
-
19
- export default function HelloPlugin(_props: { isActive?: boolean; tabId?: string; sourceId?: string }) {
20
- const { t } = useTranslation();
21
-
22
- return (
23
- <div className="starter">
24
- <h2 className="starter__title">{t("插件跑起来了 ✨")}</h2>
25
- <p className="starter__text">{t("这是你的第一个 LinkDesk 插件。")}</p>
26
- <p className="starter__hint">
27
- <code>src/index.tsx</code> {t("是插件本体——改它,浏览器预览即时刷新。")}
28
- </p>
29
- <p className="starter__hint">
30
- <code>npm run build</code> {t("打包出分发文件,可装进 LinkDesk 或发布到市场。")}
31
- </p>
32
- <p className="starter__hint">{t("目录该放哪、发布怎么做,都写在 README.md 里。")}</p>
33
- </div>
34
- );
35
- }
1
+ /**
2
+ * {{displayName}}——LinkDesk 插件主视图(由 create-linkdesk-plugin 生成)。
3
+ *
4
+ * 视图插件契约(作者文档 01-plugin-api-contract.md):壳以 { isActive, tabId?, sourceId? }
5
+ * 渲染本文件 default 导出的组件:
6
+ * - isActive 本标签当前是否聚焦。keep-alive 下非聚焦标签仍在渲染,isActive 只用于
7
+ * gate「聚焦才跑」的副作用(如自动保存),切勿用它整块 blank 掉内容。
8
+ * - tabId 本标签页 id。
9
+ * - sourceId 上下文数据(文件路径 / 数据源等),编辑器类插件用它定位内容。
10
+ *
11
+ * 样式:LinkDesk 主题色一律走 CSS 变量 var(--xxx)(见 index.css 示例),禁硬编码 hex。
12
+ * 文案:用 t() 读——key 就是中文原文,英文译文放 i18n/en.json(见作者文档 05-ui-conventions.md)。
13
+ * 壳已 external react/react-dom/react-i18next/i18next——构建不会打进包,插件工程无需 npm i 它们。
14
+ */
15
+
16
+ import { useTranslation } from "react-i18next";
17
+ import "./index.css";
18
+
19
+ export default function HelloPlugin(_props: { isActive?: boolean; tabId?: string; sourceId?: string }) {
20
+ const { t } = useTranslation();
21
+
22
+ return (
23
+ <div className="{{pluginName}}-starter">
24
+ <h2 className="{{pluginName}}-starter__title">{t("插件跑起来了 ✨")}</h2>
25
+ <p className="{{pluginName}}-starter__text">{t("这是你的第一个 LinkDesk 插件。")}</p>
26
+ <p className="{{pluginName}}-starter__hint">
27
+ <code>src/index.tsx</code> {t("是插件本体——改它,浏览器预览即时刷新。")}
28
+ </p>
29
+ <p className="{{pluginName}}-starter__hint">
30
+ <code>npm run build</code> {t("打包出分发文件,可装进 LinkDesk 或发布到市场。")}
31
+ </p>
32
+ <p className="{{pluginName}}-starter__hint">{t("目录该放哪、发布怎么做,都写在 README.md 里。")}</p>
33
+ </div>
34
+ );
35
+ }