@public-tauri/raycast-convert 1.0.1 → 1.1.0

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  将 Raycast 插件转换为 Public Tauri 插件。
4
4
 
5
- 当前阶段暂时只支持 Raycast `no-view` 命令;Raycast view 插件的适配正在进行中。
5
+ 转换器支持 Raycast `no-view` **view(MVP)** 命令:`no-view` 走 Node Worker + 浏览器 `public-main`;`view` 在 Worker 内用 React reconciler 执行组件,通过 snapshot 协议由 wujie 加载 **`@public-tauri/template`** 中的 **`raycast.html`** 入口(Vue 渲染;构建产物拷贝到插件 **`dist/view/`**)。
6
6
 
7
7
  仓库根目录提供了以下脚本:
8
8
 
@@ -17,33 +17,51 @@ pnpm raycast:convert:production <raycast-plugin-dir> --out <public-plugin-dir> [
17
17
  raycast-convert <raycast-plugin-dir> --out <public-plugin-dir> [--build] [--mode development|production]
18
18
  ```
19
19
 
20
+ ## 关键步骤(转换逻辑)
21
+
22
+ 转换器按固定顺序处理,核心步骤如下:
23
+
24
+ 1. **准备输出目录**
25
+ 删除目标 `outDir`(若存在),保证输出是一次干净的生成结果。
26
+
27
+ 2. **复制 Raycast 源码树**
28
+ 将输入插件目录下的文件与子目录**递归复制**到 `outDir`。
29
+ **不复制** `package.json`(由下一步生成)。
30
+ 为便于在 `outDir` 内重新解析依赖,同时**跳过** `node_modules` 以及常见 lockfile(`pnpm-lock.yaml`、`package-lock.json`、`yarn.lock`)。
31
+ 其它文件(含 `src/`、`assets/`、`tsconfig.json` 等)原样保留。
32
+
33
+ 3. **生成 Public 插件清单与打包入口**
34
+ - 写入 **`package.json`**:`publicPlugin` manifest、`@public-tauri/api` 依赖、合并后的 `dependencies` / `devDependencies`(仅移除 **`@raycast/api`**;**`@raycast/utils`** 若存在则保留原声明)、以及 `build` 脚本等。
35
+ - 存在 **no-view** 命令时写入 **`.raycast-build/public-main.ts`**(浏览器侧 `raycast:run` 桥接)。
36
+ - 写入 **`.raycast-build/server.ts`**(Node / Worker 侧入口:`raycast:run` 与 `raycast:view:*`)。
37
+ - 存在 **view** 命令时写入 `.raycast-build/raycast-view-protocol.ts`、Worker 侧 **`raycast-worker-runtime.ts`**(及宿主序列化等)。**`development`**(CLI 默认):`publicPlugin.html` 为 **`http://localhost:5173/raycast.html`**,指向本仓库 **`@public-tauri/template`** 的 Vite 开发服务器,**不**拷贝 `dist/view`,便于先执行 `pnpm --filter @public-tauri/template dev` 再打开 `/raycast.html` 调试 view。**`production`**(或 `pnpm raycast:convert:production`):将 **`packages/template` 的 `dist/`** 复制到插件 **`dist/view/`**,`publicPlugin.html` 为 **`./dist/view/raycast.html`**。浏览器逻辑(wujie、`channel`、Markdown)均在模板应用 bundle 内;插件侧 **tsdown 只打 `server.js`**(及可选 **`public-main.js`**)。依赖侧为 Worker 补充 **`react`** / **`react-reconciler`**。
38
+ - 写入 **`tsdown.config.ts`**:no-view 时的 browser 入口 + **node(server)入口**,产出写入 **`dist/`**(与 **`dist/view/`** 并列)。
39
+ - 写入 **`raycast-conversion-report.json`**:已转换命令、跳过命令与 warnings。
40
+
41
+ 4. **安装依赖并打包(可选)**
42
+ 若传入 `--build`,在 **`outDir`** 内依次执行:
43
+ `pnpm install` → `pnpm exec tsdown --config tsdown.config.ts` → **再次将 `packages/template` 的构建产物拷入 `dist/view/`**(tsdown 会清空 `dist/`)。
44
+
45
+ 原始 Raycast 插件目录不会被修改;依赖安装与构建仅在生成的 `outDir` 中进行。
46
+
20
47
  ## 功能
21
48
 
22
49
  转换器读取一个 Raycast 插件目录,并生成一个 Public Tauri 插件目录。
23
50
 
51
+ 转换后 `package.json` 的 `name` 固定为 `@public-tauri-raycast/<slug>`(由 Raycast 包名或输入目录名推导),与 Public 应用商店中已发布的包名空间区分。`raycast-conversion-report.json` 中记录 `sourcePackageName`(源 `package.json` 的 `name`,可能缺失)与 `convertedPackageName`。
52
+
24
53
  生成的插件包含:
25
54
 
26
- - `package.json`,包含 `publicPlugin` manifest
27
- - `.raycast-build/public-main.ts`,浏览器侧桥接入口。
28
- - `.raycast-build/server.ts`,Node 侧命令运行入口。
55
+ - `package.json`,包含 `publicPlugin` manifest(含 `server`;有 no-view 时有 `main`;有 view 时有 `html` 指向 **`dist/view/raycast.html`**)。
56
+ - `.raycast-build/server.ts`,Node / Worker 命令与 view session 入口。
57
+ - 有 no-view 命令时:`.raycast-build/public-main.ts`。
58
+ - 有 view 命令时:**`dist/view/`**(完整 Vite 子应用)及 `.raycast-build` 内 Worker runtime / protocol 等源码。
29
59
  - `tsdown.config.ts`,用于打包转换后的插件。
30
60
  - `raycast-conversion-report.json`,记录已转换命令、跳过命令和 warnings。
31
- - `assets/`,当 Raycast 插件存在资源目录时会复制过来。
61
+ - Raycast 插件目录复制的其余源码与资源(不含上述跳过项)。
32
62
 
33
63
  如果传入 `--build`,转换器会在生成的 Public Tauri 插件目录中安装依赖,并执行 `tsdown` 构建。
34
64
 
35
- ## 转换流程
36
-
37
- ```text
38
- Raycast 插件源码
39
- -> 生成 Public Tauri 插件文件
40
- -> 写入 package.json 和 tsdown.config.ts
41
- -> 在生成的插件目录执行 pnpm install
42
- -> pnpm exec tsdown --config tsdown.config.ts
43
- ```
44
-
45
- 原始 Raycast 插件源码目录不会被安装依赖,也不会被修改。
46
-
47
65
  ## 模式
48
66
 
49
67
  ### development
@@ -74,31 +92,36 @@ Raycast 插件源码
74
92
 
75
93
  ## Raycast API 映射
76
94
 
77
- 生成的 `tsdown.config.ts` 会将 Raycast API 映射到 Public Tauri 的兼容层:
95
+ - **Node(server)入口**(no-view 与 view 相同):将 **`@raycast/api`** 解析到已安装的 **`@public-tauri/api/src/raycast.ts`**(与包导出 **`@public-tauri/api/raycast`** 同源)。**`@raycast/utils`** 不配置别名,仍使用 `package.json` 中的 npm 包。**浏览器(public-main)入口** 不使用 `@raycast/api` 别名。
96
+ - **含 view 命令**:**`server.ts`** 会引入 **`.raycast-build/raycast-worker-runtime.ts`**,其中提供 **`createRaycastViewSession`** / **`__setRaycastViewContext`**:在 Worker 内挂 **React reconciler**,把业务组件树打成 snapshot,经 `channel` 交给 wujie 里 **`@public-tauri/template`** 的 **`raycast.html`**(`dist/view/raycast.html`)用 Vue 渲染。业务代码仍只从 **`@raycast/api`** 导入 `List`、`Detail`、`Action` 等与 API,与 no-view 一致。
78
97
 
79
- ```ts
80
- alias: {
81
- '@raycast/api': '@public-tauri/api/raycast',
82
- '@raycast/utils': '@public-tauri/api/raycast/utils',
83
- }
84
- ```
85
-
86
- 原 Raycast 插件中的其它依赖会保留。
98
+ 原 Raycast 插件中除 **`@raycast/api`**(由 `@public-tauri/api` + 上述别名替代)外的其它依赖会保留在生成的 `package.json` 中。
87
99
 
88
100
  ## 当前支持范围
89
101
 
90
- 目前暂时只转换以下类型的 Raycast 命令:
102
+ 转换器支持:
91
103
 
92
- ```json
93
- {
94
- "mode": "no-view"
95
- }
96
- ```
104
+ - Raycast `mode: "no-view"`:转换为 Public Tauri 命令 `mode: "none"`,由 Node Worker 执行默认导出函数。
105
+ - Raycast `mode: "view"`(未写 `mode` 时 Raycast 默认为 view):转换为 Public Tauri `mode: "view"`,React 组件在 Worker 内执行,snapshot 由 wujie 加载的 **`packages/template`**(`raycast.html`)子应用以 Vue 渲染。
106
+
107
+ **MVP 已支持:**
108
+
109
+ - `List`、`List.Item`、`Detail`、`ActionPanel`、`Action`
110
+ - Raycast command `arguments`(`text` / `password` / `dropdown`)参数表单前置并透传至 `LaunchProps.arguments`
111
+ - `Detail.markdown` 在浏览器侧由 **`packages/template`** 产物内的 `markdown-it` 渲染为 HTML(禁用 raw HTML)
112
+ - React 函数组件、`useState`、`useEffect`
113
+ - Worker 侧 action 回调与 snapshot 更新
114
+ - `CopyToClipboard`、`Paste`、`OpenInBrowser`、`ShowInFinder`、`Action.Pop`(`Action.Push` 会抛出明确错误)
115
+
116
+ **暂不支持:**
117
+
118
+ - `Grid`、`Form`、`MenuBarExtra`
119
+ - OAuth / BrowserExtension
120
+ - 依赖完整 Raycast runtime 的复杂 `@raycast/utils` hooks
97
121
 
98
- 其它 command mode 会被跳过,并写入 `raycast-conversion-report.json`。这不是该包的长期边界,Raycast view 插件的适配正在进行中。
122
+ 其它 command mode(如 `menuBar`)会被跳过并记入 `raycast-conversion-report.json`。
99
123
 
100
124
  ## 限制
101
125
 
102
- - 暂时不转换 Raycast React UI 命令。
103
- - 命令入口文件需要符合常见 Raycast 布局,例如 `src/<command>.ts`、`src/<command>.tsx` `src/<command>/index.ts`。
104
- - 运行时能力取决于 `@public-tauri/api/raycast` 提供的兼容层。
126
+ - 命令入口文件需符合常见 Raycast 布局,例如 `src/<command>.ts`、`src/<command>.tsx` 或 `src/<command>/index.ts`。
127
+ - Worker 侧兼容能力仍受 `@public-tauri/api/raycast` 与上述 MVP 组件集合约束。
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as convertRaycastPlugin } from "./src-DPoXoCnp.mjs";
2
+ import { n as convertRaycastPlugin } from "./src-Re0YIJP-.mjs";
3
3
  import path from "node:path";
4
4
  import { parseArgs } from "node:util";
5
5
  //#region src/cli.ts
@@ -36,8 +36,7 @@ const runCli = async () => {
36
36
  inputDir: path.resolve(inputArg),
37
37
  outputDir: values.out,
38
38
  build: values.build,
39
- mode: getConvertMode(values.mode),
40
- invocationDir: process.cwd()
39
+ mode: getConvertMode(values.mode)
41
40
  });
42
41
  console.log(`Converted ${report.convertedCommands.length} command(s) to ${report.output}`);
43
42
  if (report.skippedCommands.length) console.log(`Skipped ${report.skippedCommands.length} command(s). See raycast-conversion-report.json`);
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as convertRaycastPlugin } from "./src-DPoXoCnp.mjs";
2
- export { convertRaycastPlugin };
1
+ import { a as resolveRaycastSlug, i as resolveConvertedPackageName, n as convertRaycastPlugin, o as sanitizeSlug, r as RAYCAST_CONVERTED_SCOPE, t as RAYCAST_VIEW_TEMPLATE_DEV_ENTRY } from "./src-Re0YIJP-.mjs";
2
+ export { RAYCAST_CONVERTED_SCOPE, RAYCAST_VIEW_TEMPLATE_DEV_ENTRY, convertRaycastPlugin, resolveConvertedPackageName, resolveRaycastSlug, sanitizeSlug };