shortcutkit 0.7.0 → 0.8.1

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
@@ -34,13 +34,16 @@ files you are using.
34
34
  typed, and the `AppIntentDescriptor` the file needs is added for you.
35
35
  - **Parameters checked before you run anything.** `{ WFStoredContentGlobalValue: "yes" }` is a
36
36
  compile error; a switch takes a boolean or a reference. Enumeration choices are suggested.
37
- Any plain value slot also accepts an attachment, because that is how Shortcuts works. Every
38
- action has a named parameter type (`ShowresultParams`, `RemindersCreateReminderParams`), and
39
- its output content types are on `ACTIONS[id].outputTypes` and on the returned `Action`.
37
+ A plain value slot also accepts a reference where the engine reads one, and the type says
38
+ which: a Filter action's sort key takes none, a variable picker takes any except Ask, and the
39
+ engine was asked about every key (`PARAM_VARIABLE_TYPES`). Every action has a named
40
+ parameter type (`ShowresultParams`, `RemindersCreateReminderParams`), and its output content
41
+ types are on `ACTIONS[id].outputTypes` and on the returned `Action`.
40
42
  - **Value helpers that match the engine's serialization.** `ref()` to another action's output,
41
- `variable()`, `shortcutInput()`, `clipboard()`, `currentDate()`, `ask()`, `text()` for
42
- strings with embedded references, and `picker()` for variable-picker parameters. A bare
43
- `ref()` given to a text parameter is wrapped into the token string the engine writes.
43
+ `variable()`, `shortcutInput()`, `clipboard()`, `currentDate()`, `ask()`, `deviceDetails()`,
44
+ `currentApp()`, `text()` for strings with embedded references. A bare `ref()` is what every
45
+ picker parameter takes; for a text parameter it is wrapped into the token string the engine
46
+ writes, and for an If subject into the form the app writes.
44
47
  - **Control flow.** `if()` / `otherwise()` / `endIf()`, `repeatEach()` / `endRepeatEach()`,
45
48
  `repeatCount()` / `endRepeatCount()` and `chooseFromMenu()` / `menuItem()` / `endMenu()`
46
49
  manage the grouping identifiers for you.
@@ -92,7 +95,7 @@ pip install shortcutkit
92
95
  ## Usage
93
96
 
94
97
  ```ts
95
- import { Shortcut, actions, ref, text } from "shortcutkit";
98
+ import { Shortcut, actions, ref, text, shortcutInput } from "shortcutkit";
96
99
 
97
100
  const s = new Shortcut("Greeting", { color: "Teal" });
98
101
  const got = s.action(actions.getstoredcontent, { WFStoredContentKey: "greeting" });
@@ -103,6 +106,20 @@ Shortcut.sign("Greeting.shortcut", "Greeting-signed.shortcut");
103
106
 
104
107
  Open the signed file and Shortcuts imports it.
105
108
 
109
+ ### Share sheet
110
+
111
+ A shortcut offered from the share sheet declares its surfaces and the input it accepts, and
112
+ reads that input with `shortcutInput()`:
113
+
114
+ ```ts
115
+ const s = new Shortcut("Page Links", { types: ["ActionExtension"], inputClasses: ["WFSafariWebPageContentItem"] });
116
+ const links = s.action(actions.runjavascriptonwebpage, { WFInput: shortcutInput(), WFJavaScript: "completion(document.links.length)" });
117
+ s.action(actions.showresult, { Text: text("Links: ", ref(links)) });
118
+ ```
119
+
120
+ `types` takes `ActionExtension` (share sheet), `QuickActions` (Finder and Services menus),
121
+ `MenuBar`, `NCWidget`, `WatchKit`, `Sleep` and `ReceivesOnScreenContent`.
122
+
106
123
  ### Control flow
107
124
 
108
125
  `if()` returns a grouping identifier that the matching `otherwise()` and `endIf()` calls take
@@ -190,9 +207,23 @@ cd python && python3 -m venv .venv && .venv/bin/pip install -e .
190
207
  .venv/bin/python -m shortcutkit demo /tmp/Demo.shortcut
191
208
  ```
192
209
 
193
- CI runs the type check, the tests, a Node import of the built package, a Python install and an
194
- unsigned build of the demo shortcut on macOS. Signing is not exercised in CI because the runner
195
- has no iCloud login.
210
+ CI runs the type check, the tests, a Node import of the built package, a Python install, the
211
+ engine verification below and an unsigned build of the demo shortcut on macOS. Signing is not
212
+ exercised in CI because the runner has no iCloud login.
213
+
214
+ ### Verifying against the engine
215
+
216
+ ```bash
217
+ bun run verify # ~3 min on a Mac that has opened Shortcuts.app once
218
+ ```
219
+
220
+ Both packages are driven over every action, every parameter key and every value form their
221
+ types admit, and the results are diffed against each other and then loaded through the
222
+ Shortcuts engine's own action objects, which report whether each value was read. Forms the
223
+ library refuses are written raw too, and the engine must refuse them as well. Whole shortcuts
224
+ built through every block helper are imported the way the app imports a file. The run fails on
225
+ any case the engine does not read; see `docs/extraction.md` for what it reports instead of
226
+ failing.
196
227
 
197
228
  ### Repository layout
198
229