Skip to content

Commit 35c7aac

Browse files
committed
feat(sketch): add Sketch protocol launcher support
1 parent 6121c83 commit 35c7aac

21 files changed

Lines changed: 754 additions & 242 deletions

File tree

.changeset/whole-mails-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'protocol-launcher': minor
3+
---
4+
5+
feat(sketch): add Sketch protocol launcher support

apps/docs/.vitepress/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export default defineConfig({
6161
'en/apps/quark.md': 'apps/quark.md',
6262
'en/apps/rustrover.md': 'apps/rustrover.md',
6363
'en/apps/shortcuts.md': 'apps/shortcuts.md',
64+
'en/apps/sketch.md': 'apps/sketch.md',
6465
'en/apps/soulver.md': 'apps/soulver.md',
6566
'en/apps/sourcetree.md': 'apps/sourcetree.md',
6667
'en/apps/telegram.md': 'apps/telegram.md',
@@ -164,6 +165,7 @@ export default defineConfig({
164165
{ text: 'Quark', link: '/apps/quark' },
165166
{ text: 'RustRover', link: '/apps/rustrover' },
166167
{ text: 'Shortcuts', link: '/apps/shortcuts' },
168+
{ text: 'Sketch', link: '/apps/sketch' },
167169
{ text: 'Soulver', link: '/apps/soulver' },
168170
{ text: 'SourceTree', link: '/apps/sourcetree' },
169171
{ text: 'Telegram', link: '/apps/telegram' },
@@ -272,6 +274,7 @@ export default defineConfig({
272274
{ text: 'Quark', link: '/apps/quark' },
273275
{ text: 'RustRover', link: '/apps/rustrover' },
274276
{ text: 'Shortcuts', link: '/apps/shortcuts' },
277+
{ text: 'Sketch', link: '/apps/sketch' },
275278
{ text: 'Soulver', link: '/apps/soulver' },
276279
{ text: 'SourceTree', link: '/apps/sourcetree' },
277280
{ text: 'Telegram', link: '/apps/telegram' },
@@ -350,6 +353,7 @@ export default defineConfig({
350353
{ text: 'Quark', link: '/zh/apps/quark' },
351354
{ text: 'RustRover', link: '/zh/apps/rustrover' },
352355
{ text: 'Shortcuts', link: '/zh/apps/shortcuts' },
356+
{ text: 'Sketch', link: '/zh/apps/sketch' },
353357
{ text: 'Soulver', link: '/zh/apps/soulver' },
354358
{ text: 'SourceTree', link: '/zh/apps/sourcetree' },
355359
{ text: 'Telegram', link: '/zh/apps/telegram' },
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const openFileParams = {
2+
path: '/Users/name/Documents/design.sketch',
3+
}
4+
5+
export const openFileWithLayerParams = {
6+
path: '/Users/name/Documents/design.sketch',
7+
centerOnLayer: 'layer-123',
8+
zoom: 2,
9+
}
10+
11+
export const addLibraryParams = {
12+
url: 'https://developer.apple.com/design/downloads/sketch.rss',
13+
}
14+
15+
export const runPluginParams = {
16+
pluginId: 'com.example.sketch.messenger',
17+
commandId: 'message.show',
18+
}
19+
20+
export const runPluginWithQueryParams = {
21+
pluginId: 'com.example.sketch.messenger',
22+
commandId: 'message.show',
23+
query: { msg: 'Hello World' },
24+
}

apps/docs/en/apps/sketch.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
layout: doc
3+
---
4+
5+
<script setup lang="ts">
6+
import { ref, computed } from 'vue';
7+
import VPLink from 'vitepress/dist/client/theme-default/components/VPLink.vue';
8+
import { open, openFile, addLibrary, runPlugin } from 'protocol-launcher/sketch';
9+
import { SelectInstallationMethod } from '../../.vitepress/components';
10+
import { openFileParams, openFileWithLayerParams, addLibraryParams, runPluginParams, runPluginWithQueryParams } from '../../.vitepress/constants/sketch';
11+
12+
const currentMethod = ref('On-Demand');
13+
const importPath = computed(() => currentMethod.value === 'On-Demand' ? 'protocol-launcher/sketch' : 'protocol-launcher');
14+
</script>
15+
16+
# Sketch
17+
18+
[Sketch](https://www.sketch.com/) is a vector graphics editor for macOS primarily used for user interface and icon design. **Protocol Launcher** allows you to generate deep links to open files, add libraries, and run plugins in Sketch.
19+
20+
## Usage
21+
22+
There are two ways to use this library:
23+
24+
- On-Demand import from subpaths enables tree-shaking and keeps bundles small.
25+
- Full Import from the root package is convenient but includes all app modules.
26+
27+
Pick On-Demand for production builds; Full Import is fine for quick scripts or demos.
28+
29+
<SelectInstallationMethod v-model="currentMethod" />
30+
31+
### Open Sketch
32+
33+
```ts-vue [{{currentMethod}}]
34+
import { {{ currentMethod === 'On-Demand' ? 'open' : 'sketch' }} } from '{{ importPath }}'
35+
36+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}open()
37+
```
38+
39+
<div class="flex justify-center">
40+
<VPLink :href="open()" target="_self">
41+
Open Sketch
42+
</VPLink>
43+
</div>
44+
45+
### Open File
46+
47+
```ts-vue [{{currentMethod}}]
48+
import { {{ currentMethod === 'On-Demand' ? 'openFile' : 'sketch' }} } from '{{ importPath }}'
49+
50+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}openFile({
51+
path: '/Users/name/Documents/design.sketch',
52+
})
53+
```
54+
55+
<div class="flex justify-center">
56+
<VPLink :href="openFile(openFileParams)" target="_self">
57+
Open File in Sketch
58+
</VPLink>
59+
</div>
60+
61+
### Open File with Layer Focus and Zoom
62+
63+
```ts-vue [{{currentMethod}}]
64+
import { {{ currentMethod === 'On-Demand' ? 'openFile' : 'sketch' }} } from '{{ importPath }}'
65+
66+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}openFile({
67+
path: '/Users/name/Documents/design.sketch',
68+
centerOnLayer: 'layer-123',
69+
zoom: 2,
70+
})
71+
```
72+
73+
<div class="flex justify-center">
74+
<VPLink :href="openFile(openFileWithLayerParams)" target="_self">
75+
Open File with Layer Focus in Sketch
76+
</VPLink>
77+
</div>
78+
79+
### Add Library
80+
81+
```ts-vue [{{currentMethod}}]
82+
import { {{ currentMethod === 'On-Demand' ? 'addLibrary' : 'sketch' }} } from '{{ importPath }}'
83+
84+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}addLibrary({
85+
url: 'https://developer.apple.com/design/downloads/sketch.rss',
86+
})
87+
```
88+
89+
<div class="flex justify-center">
90+
<VPLink :href="addLibrary(addLibraryParams)" target="_self">
91+
Add Library to Sketch
92+
</VPLink>
93+
</div>
94+
95+
### Run Plugin
96+
97+
```ts-vue [{{currentMethod}}]
98+
import { {{ currentMethod === 'On-Demand' ? 'runPlugin' : 'sketch' }} } from '{{ importPath }}'
99+
100+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}runPlugin({
101+
pluginId: 'com.example.sketch.messenger',
102+
commandId: 'message.show',
103+
})
104+
```
105+
106+
<div class="flex justify-center">
107+
<VPLink :href="runPlugin(runPluginParams)" target="_self">
108+
Run Plugin in Sketch
109+
</VPLink>
110+
</div>
111+
112+
### Run Plugin with Query Parameters
113+
114+
```ts-vue [{{currentMethod}}]
115+
import { {{ currentMethod === 'On-Demand' ? 'runPlugin' : 'sketch' }} } from '{{ importPath }}'
116+
117+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}runPlugin({
118+
pluginId: 'com.example.sketch.messenger',
119+
commandId: 'message.show',
120+
query: { msg: 'Hello World' },
121+
})
122+
```
123+
124+
<div class="flex justify-center">
125+
<VPLink :href="runPlugin(runPluginWithQueryParams)" target="_self">
126+
Run Plugin with Query in Sketch
127+
</VPLink>
128+
</div>

apps/docs/en/guide/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ For detailed usage instructions for each application, please refer to their resp
161161
- [Quark](../apps/quark.md)
162162
- [RustRover](../apps/rustrover.md)
163163
- [Shortcuts](../apps/shortcuts.md)
164+
- [Sketch](../apps/sketch.md)
164165
- [Soulver](../apps/soulver.md)
165166
- [SourceTree](../apps/sourcetree.md)
166167
- [Telegram](../apps/telegram.md)

apps/docs/en/guide/what-is-it.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Currently, we support the following applications:
6464
- [Quark](../apps/quark.md)
6565
- [RustRover](../apps/rustrover.md)
6666
- [Shortcuts](../apps/shortcuts.md)
67+
- [Sketch](../apps/sketch.md)
6768
- [Soulver](../apps/soulver.md)
6869
- [SourceTree](../apps/sourcetree.md)
6970
- [Telegram](../apps/telegram.md)

apps/docs/zh/apps/sketch.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
layout: doc
3+
---
4+
5+
<script setup lang="ts">
6+
import { ref, computed } from 'vue';
7+
import VPLink from 'vitepress/dist/client/theme-default/components/VPLink.vue';
8+
import { open, openFile, addLibrary, runPlugin } from 'protocol-launcher/sketch';
9+
import { SelectInstallationMethod } from '../../.vitepress/components';
10+
import { openFileParams, openFileWithLayerParams, addLibraryParams, runPluginParams, runPluginWithQueryParams } from '../../.vitepress/constants/sketch';
11+
12+
const currentMethod = ref('On-Demand');
13+
const importPath = computed(() => currentMethod.value === 'On-Demand' ? 'protocol-launcher/sketch' : 'protocol-launcher');
14+
</script>
15+
16+
# Sketch
17+
18+
[Sketch](https://www.sketch.com/) 是一款专为 macOS 设计的矢量图形编辑器,主要用于用户界面和图标设计。**Protocol Launcher** 允许您生成深度链接以在 Sketch 中打开文件、添加库和运行插件。
19+
20+
## 使用方式
21+
22+
有两种使用此库的方式:
23+
24+
- 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
25+
- 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。
26+
27+
生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。
28+
29+
<SelectInstallationMethod v-model="currentMethod" />
30+
31+
### 打开 Sketch
32+
33+
```ts-vue [{{currentMethod}}]
34+
import { {{ currentMethod === 'On-Demand' ? 'open' : 'sketch' }} } from '{{ importPath }}'
35+
36+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}open()
37+
```
38+
39+
<div class="flex justify-center">
40+
<VPLink :href="open()" target="_self">
41+
打开 Sketch
42+
</VPLink>
43+
</div>
44+
45+
### 打开文件
46+
47+
```ts-vue [{{currentMethod}}]
48+
import { {{ currentMethod === 'On-Demand' ? 'openFile' : 'sketch' }} } from '{{ importPath }}'
49+
50+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}openFile({
51+
path: '/Users/name/Documents/design.sketch',
52+
})
53+
```
54+
55+
<div class="flex justify-center">
56+
<VPLink :href="openFile(openFileParams)" target="_self">
57+
在 Sketch 中打开文件
58+
</VPLink>
59+
</div>
60+
61+
### 打开文件并聚焦图层和缩放
62+
63+
```ts-vue [{{currentMethod}}]
64+
import { {{ currentMethod === 'On-Demand' ? 'openFile' : 'sketch' }} } from '{{ importPath }}'
65+
66+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}openFile({
67+
path: '/Users/name/Documents/design.sketch',
68+
centerOnLayer: 'layer-123',
69+
zoom: 2,
70+
})
71+
```
72+
73+
<div class="flex justify-center">
74+
<VPLink :href="openFile(openFileWithLayerParams)" target="_self">
75+
在 Sketch 中打开文件并聚焦图层
76+
</VPLink>
77+
</div>
78+
79+
### 添加库
80+
81+
```ts-vue [{{currentMethod}}]
82+
import { {{ currentMethod === 'On-Demand' ? 'addLibrary' : 'sketch' }} } from '{{ importPath }}'
83+
84+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}addLibrary({
85+
url: 'https://developer.apple.com/design/downloads/sketch.rss',
86+
})
87+
```
88+
89+
<div class="flex justify-center">
90+
<VPLink :href="addLibrary(addLibraryParams)" target="_self">
91+
添加库到 Sketch
92+
</VPLink>
93+
</div>
94+
95+
### 运行插件
96+
97+
```ts-vue [{{currentMethod}}]
98+
import { {{ currentMethod === 'On-Demand' ? 'runPlugin' : 'sketch' }} } from '{{ importPath }}'
99+
100+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}runPlugin({
101+
pluginId: 'com.example.sketch.messenger',
102+
commandId: 'message.show',
103+
})
104+
```
105+
106+
<div class="flex justify-center">
107+
<VPLink :href="runPlugin(runPluginParams)" target="_self">
108+
在 Sketch 中运行插件
109+
</VPLink>
110+
</div>
111+
112+
### 运行插件并传递参数
113+
114+
```ts-vue [{{currentMethod}}]
115+
import { {{ currentMethod === 'On-Demand' ? 'runPlugin' : 'sketch' }} } from '{{ importPath }}'
116+
117+
const url = {{currentMethod === 'On-Demand' ? '' : 'sketch.'}}runPlugin({
118+
pluginId: 'com.example.sketch.messenger',
119+
commandId: 'message.show',
120+
query: { msg: 'Hello World' },
121+
})
122+
```
123+
124+
<div class="flex justify-center">
125+
<VPLink :href="runPlugin(runPluginWithQueryParams)" target="_self">
126+
在 Sketch 中运行插件并传递参数
127+
</VPLink>
128+
</div>

apps/docs/zh/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export default defineAdditionalConfig({
7373
{ text: 'Quark', link: '/zh/apps/quark' },
7474
{ text: 'RustRover', link: '/zh/apps/rustrover' },
7575
{ text: 'Shortcuts', link: '/zh/apps/shortcuts' },
76+
{ text: 'Sketch', link: '/zh/apps/sketch' },
7677
{ text: 'Soulver', link: '/zh/apps/soulver' },
7778
{ text: 'SourceTree', link: '/zh/apps/sourcetree' },
7879
{ text: 'Telegram', link: '/zh/apps/telegram' },

apps/docs/zh/guide/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ import { cherryStudio, cursor, githubDesktop } from 'protocol-launcher'
161161
- [Quark](../apps/quark.md)
162162
- [RustRover](../apps/rustrover.md)
163163
- [Shortcuts](../apps/shortcuts.md)
164+
- [Sketch](../apps/sketch.md)
164165
- [Soulver](../apps/soulver.md)
165166
- [SourceTree](../apps/sourcetree.md)
166167
- [Telegram](../apps/telegram.md)

apps/docs/zh/guide/what-is-it.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ layout: doc
6464
- [Quark](../apps/quark.md)
6565
- [RustRover](../apps/rustrover.md)
6666
- [Shortcuts](../apps/shortcuts.md)
67+
- [Sketch](../apps/sketch.md)
6768
- [Soulver](../apps/soulver.md)
6869
- [SourceTree](../apps/sourcetree.md)
6970
- [Telegram](../apps/telegram.md)

0 commit comments

Comments
 (0)