Skip to content

Commit cafedb5

Browse files
committed
feat(scriptable): add scriptable protocol launcher support
1 parent 41c8e3c commit cafedb5

File tree

18 files changed

+475
-0
lines changed

18 files changed

+475
-0
lines changed

.changeset/modern-bananas-work.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(scriptable): add scriptable protocol launcher support

apps/docs/.vitepress/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export default defineConfig({
9696
'en/apps/qoder.md': 'apps/qoder.md',
9797
'en/apps/quark.md': 'apps/quark.md',
9898
'en/apps/rustrover.md': 'apps/rustrover.md',
99+
'en/apps/scriptable.md': 'apps/scriptable.md',
99100
'en/apps/shopi.md': 'apps/shopi.md',
100101
'en/apps/shortcuts.md': 'apps/shortcuts.md',
101102
'en/apps/simple-scan.md': 'apps/simple-scan.md',
@@ -249,6 +250,7 @@ export default defineConfig({
249250
{ text: 'Qoder', link: '/apps/qoder' },
250251
{ text: 'Quark', link: '/apps/quark' },
251252
{ text: 'RustRover', link: '/apps/rustrover' },
253+
{ text: 'Scriptable', link: '/apps/scriptable' },
252254
{ text: 'Shopi', link: '/apps/shopi' },
253255
{ text: 'Shortcuts', link: '/apps/shortcuts' },
254256
{ text: 'Simple Scan', link: '/apps/simple-scan' },
@@ -408,6 +410,7 @@ export default defineConfig({
408410
{ text: 'Qoder', link: '/apps/qoder' },
409411
{ text: 'Quark', link: '/apps/quark' },
410412
{ text: 'RustRover', link: '/apps/rustrover' },
413+
{ text: 'Scriptable', link: '/apps/scriptable' },
411414
{ text: 'Shopi', link: '/apps/shopi' },
412415
{ text: 'Shortcuts', link: '/apps/shortcuts' },
413416
{ text: 'Simple Scan', link: '/apps/simple-scan' },
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export const openScriptParams = {
2+
scriptName: 'Example',
3+
}
4+
5+
export const openScriptWithSettingsParams = {
6+
scriptName: 'Example',
7+
openSettings: true,
8+
}
9+
10+
export const runScriptParams = {
11+
scriptName: 'Example',
12+
}
13+
14+
export const runScriptWithEditorParams = {
15+
scriptName: 'Example',
16+
openEditor: true,
17+
}

apps/docs/en/apps/scriptable.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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, openScript, addScript, runScript } from 'protocol-launcher/scriptable';
9+
import { SelectInstallationMethod } from '../../.vitepress/components';
10+
import { openScriptParams, openScriptWithSettingsParams, runScriptParams, runScriptWithEditorParams } from '../../.vitepress/constants/scriptable';
11+
12+
const currentMethod = ref('On-Demand');
13+
const importPath = computed(() => currentMethod.value === 'On-Demand' ? 'protocol-launcher/scriptable' : 'protocol-launcher');
14+
</script>
15+
16+
# Scriptable
17+
18+
[Scriptable](https://www.scriptable.app/) is an automation app for iOS that lets you write JavaScript scripts to interact with native iOS APIs. **Protocol Launcher** allows you to generate deep links to open Scriptable, create new scripts, or run existing scripts.
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 App
32+
33+
```ts-vue [{{currentMethod}}]
34+
import { {{ currentMethod === 'On-Demand' ? 'open' : 'scriptable' }} } from '{{ importPath }}'
35+
36+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}open()
37+
```
38+
39+
<div class="flex justify-center">
40+
<VPLink :href="open()" target="_self">
41+
Open Scriptable
42+
</VPLink>
43+
</div>
44+
45+
### Add Script
46+
47+
```ts-vue [{{currentMethod}}]
48+
import { {{ currentMethod === 'On-Demand' ? 'addScript' : 'scriptable' }} } from '{{ importPath }}'
49+
50+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}addScript()
51+
```
52+
53+
<div class="flex justify-center">
54+
<VPLink :href="addScript()" target="_self">
55+
Add New Script
56+
</VPLink>
57+
</div>
58+
59+
### Open Script
60+
61+
```ts-vue [{{currentMethod}}]
62+
import { {{ currentMethod === 'On-Demand' ? 'openScript' : 'scriptable' }} } from '{{ importPath }}'
63+
64+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}openScript({
65+
scriptName: 'Example',
66+
})
67+
```
68+
69+
<div class="flex justify-center">
70+
<VPLink :href="openScript(openScriptParams)" target="_self">
71+
Open Script in Scriptable
72+
</VPLink>
73+
</div>
74+
75+
### Open Script with Settings
76+
77+
```ts-vue [{{currentMethod}}]
78+
import { {{ currentMethod === 'On-Demand' ? 'openScript' : 'scriptable' }} } from '{{ importPath }}'
79+
80+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}openScript({
81+
scriptName: 'Example',
82+
openSettings: true,
83+
})
84+
```
85+
86+
<div class="flex justify-center">
87+
<VPLink :href="openScript(openScriptWithSettingsParams)" target="_self">
88+
Open Script with Settings
89+
</VPLink>
90+
</div>
91+
92+
### Run Script
93+
94+
```ts-vue [{{currentMethod}}]
95+
import { {{ currentMethod === 'On-Demand' ? 'runScript' : 'scriptable' }} } from '{{ importPath }}'
96+
97+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}runScript({
98+
scriptName: 'Example',
99+
})
100+
```
101+
102+
<div class="flex justify-center">
103+
<VPLink :href="runScript(runScriptParams)" target="_self">
104+
Run Script
105+
</VPLink>
106+
</div>
107+
108+
### Run Script with Editor
109+
110+
```ts-vue [{{currentMethod}}]
111+
import { {{ currentMethod === 'On-Demand' ? 'runScript' : 'scriptable' }} } from '{{ importPath }}'
112+
113+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}runScript({
114+
scriptName: 'Example',
115+
openEditor: true,
116+
})
117+
```
118+
119+
<div class="flex justify-center">
120+
<VPLink :href="runScript(runScriptWithEditorParams)" target="_self">
121+
Run Script with Editor
122+
</VPLink>
123+
</div>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ For detailed usage instructions for each application, please refer to their resp
201201
- [Qoder](../apps/qoder.md)
202202
- [Quark](../apps/quark.md)
203203
- [RustRover](../apps/rustrover.md)
204+
- [Scriptable](../apps/scriptable.md)
204205
- [Shopi](../apps/shopi.md)
205206
- [Shortcuts](../apps/shortcuts.md)
206207
- [Simple Scan](../apps/simple-scan.md)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Currently, we support the following applications:
9999
- [Qoder](../apps/qoder.md)
100100
- [Quark](../apps/quark.md)
101101
- [RustRover](../apps/rustrover.md)
102+
- [Scriptable](../apps/scriptable.md)
102103
- [Shopi](../apps/shopi.md)
103104
- [Shortcuts](../apps/shortcuts.md)
104105
- [Simple Scan](../apps/simple-scan.md)

apps/docs/zh/apps/scriptable.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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, openScript, addScript, runScript } from 'protocol-launcher/scriptable';
9+
import { SelectInstallationMethod } from '../../.vitepress/components';
10+
import { openScriptParams, openScriptWithSettingsParams, runScriptParams, runScriptWithEditorParams } from '../../.vitepress/constants/scriptable';
11+
12+
const currentMethod = ref('On-Demand');
13+
const importPath = computed(() => currentMethod.value === 'On-Demand' ? 'protocol-launcher/scriptable' : 'protocol-launcher');
14+
</script>
15+
16+
# Scriptable
17+
18+
[Scriptable](https://www.scriptable.app/) 是一款 iOS 自动化应用,允许您编写 JavaScript 脚本来与原生 iOS API 交互。**Protocol Launcher** 允许您生成深度链接以打开 Scriptable、创建新脚本或运行现有脚本。
19+
20+
## 使用方式
21+
22+
有两种使用此库的方式:
23+
24+
- 按需导入(On-Demand):从子路径导入支持 tree-shaking,保持较小的打包体积。
25+
- 完整导入(Full Import):从根包导入更方便,但会包含所有应用模块。
26+
27+
生产构建建议选择按需导入;快速脚本或演示可以使用完整导入。
28+
29+
<SelectInstallationMethod v-model="currentMethod" />
30+
31+
### 打开应用
32+
33+
```ts-vue [{{currentMethod}}]
34+
import { {{ currentMethod === 'On-Demand' ? 'open' : 'scriptable' }} } from '{{ importPath }}'
35+
36+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}open()
37+
```
38+
39+
<div class="flex justify-center">
40+
<VPLink :href="open()" target="_self">
41+
打开 Scriptable
42+
</VPLink>
43+
</div>
44+
45+
### 添加脚本
46+
47+
```ts-vue [{{currentMethod}}]
48+
import { {{ currentMethod === 'On-Demand' ? 'addScript' : 'scriptable' }} } from '{{ importPath }}'
49+
50+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}addScript()
51+
```
52+
53+
<div class="flex justify-center">
54+
<VPLink :href="addScript()" target="_self">
55+
添加新脚本
56+
</VPLink>
57+
</div>
58+
59+
### 打开脚本
60+
61+
```ts-vue [{{currentMethod}}]
62+
import { {{ currentMethod === 'On-Demand' ? 'openScript' : 'scriptable' }} } from '{{ importPath }}'
63+
64+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}openScript({
65+
scriptName: 'Example',
66+
})
67+
```
68+
69+
<div class="flex justify-center">
70+
<VPLink :href="openScript(openScriptParams)" target="_self">
71+
在 Scriptable 中打开脚本
72+
</VPLink>
73+
</div>
74+
75+
### 打开脚本并显示设置
76+
77+
```ts-vue [{{currentMethod}}]
78+
import { {{ currentMethod === 'On-Demand' ? 'openScript' : 'scriptable' }} } from '{{ importPath }}'
79+
80+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}openScript({
81+
scriptName: 'Example',
82+
openSettings: true,
83+
})
84+
```
85+
86+
<div class="flex justify-center">
87+
<VPLink :href="openScript(openScriptWithSettingsParams)" target="_self">
88+
打开脚本并显示设置
89+
</VPLink>
90+
</div>
91+
92+
### 运行脚本
93+
94+
```ts-vue [{{currentMethod}}]
95+
import { {{ currentMethod === 'On-Demand' ? 'runScript' : 'scriptable' }} } from '{{ importPath }}'
96+
97+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}runScript({
98+
scriptName: 'Example',
99+
})
100+
```
101+
102+
<div class="flex justify-center">
103+
<VPLink :href="runScript(runScriptParams)" target="_self">
104+
运行脚本
105+
</VPLink>
106+
</div>
107+
108+
### 运行脚本并打开编辑器
109+
110+
```ts-vue [{{currentMethod}}]
111+
import { {{ currentMethod === 'On-Demand' ? 'runScript' : 'scriptable' }} } from '{{ importPath }}'
112+
113+
const url = {{currentMethod === 'On-Demand' ? '' : 'scriptable.'}}runScript({
114+
scriptName: 'Example',
115+
openEditor: true,
116+
})
117+
```
118+
119+
<div class="flex justify-center">
120+
<VPLink :href="runScript(runScriptWithEditorParams)" target="_self">
121+
运行脚本并打开编辑器
122+
</VPLink>
123+
</div>

apps/docs/zh/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export default defineAdditionalConfig({
108108
{ text: 'Qoder', link: '/zh/apps/qoder' },
109109
{ text: 'Quark', link: '/zh/apps/quark' },
110110
{ text: 'RustRover', link: '/zh/apps/rustrover' },
111+
{ text: 'Scriptable', link: '/zh/apps/scriptable' },
111112
{ text: 'Shopi', link: '/zh/apps/shopi' },
112113
{ text: 'Shortcuts', link: '/zh/apps/shortcuts' },
113114
{ text: 'Simple Scan', link: '/zh/apps/simple-scan' },

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ import { cherryStudio, cursor, githubDesktop } from 'protocol-launcher'
201201
- [Qoder](../apps/qoder.md)
202202
- [Quark](../apps/quark.md)
203203
- [RustRover](../apps/rustrover.md)
204+
- [Scriptable](../apps/scriptable.md)
204205
- [Shopi](../apps/shopi.md)
205206
- [Shortcuts](../apps/shortcuts.md)
206207
- [Simple Scan](../apps/simple-scan.md)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ layout: doc
9999
- [Qoder](../apps/qoder.md)
100100
- [Quark](../apps/quark.md)
101101
- [RustRover](../apps/rustrover.md)
102+
- [Scriptable](../apps/scriptable.md)
102103
- [Shopi](../apps/shopi.md)
103104
- [Shortcuts](../apps/shortcuts.md)
104105
- [Simple Scan](../apps/simple-scan.md)

0 commit comments

Comments
 (0)