|
| 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> |
0 commit comments