@rohal12/spindle 0.59.32 → 0.60.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.
Files changed (51) hide show
  1. package/README.md +20 -18
  2. package/dist/pkg/format.js +1 -1
  3. package/dist/pkg/headless.js +635 -98
  4. package/dist/pkg/story-variables.js +830 -54
  5. package/dist/pkg/tooling.js +1 -0
  6. package/package.json +4 -2
  7. package/src/action-registry.ts +84 -2
  8. package/src/automation/load-yaml.ts +10 -55
  9. package/src/automation/runner.ts +2 -14
  10. package/src/automation/types.ts +2 -8
  11. package/src/components/PassageDialog.tsx +8 -3
  12. package/src/components/dialog-close-context.ts +10 -0
  13. package/src/components/macros/Checkbox.tsx +2 -1
  14. package/src/components/macros/Cycle.tsx +2 -1
  15. package/src/components/macros/Listbox.tsx +2 -1
  16. package/src/components/macros/Radiobutton.tsx +3 -1
  17. package/src/components/macros/detached-body.tsx +19 -8
  18. package/src/components/macros/input-macro.ts +2 -1
  19. package/src/define-macro.ts +42 -16
  20. package/src/display-only.ts +30 -0
  21. package/src/format/format-passage.ts +626 -0
  22. package/src/format/placeholders.ts +316 -0
  23. package/src/format/prettier.ts +62 -0
  24. package/src/format/segment.ts +126 -0
  25. package/src/headless.ts +81 -1
  26. package/src/hooks/use-action.ts +31 -9
  27. package/src/index.tsx +16 -4
  28. package/src/js-lexer.ts +36 -6
  29. package/src/markup/code-end.ts +97 -41
  30. package/src/markup/parse.ts +6 -6
  31. package/src/observe/observable-text.ts +147 -0
  32. package/src/observe/observe.ts +160 -0
  33. package/src/store.ts +1 -0
  34. package/src/story-api.ts +21 -1
  35. package/src/story-context-passage.ts +132 -0
  36. package/src/tooling.ts +23 -1
  37. package/src/triggers.ts +32 -8
  38. package/src/twine-editor/builtin-macros.ts +11 -0
  39. package/src/twine-editor/commands.ts +173 -0
  40. package/src/twine-editor/highlight.ts +471 -0
  41. package/src/twine-editor/icons.ts +35 -0
  42. package/src/twine-editor/index.ts +19 -0
  43. package/src/twine-editor/mode.ts +137 -0
  44. package/src/twine-editor/references.ts +34 -0
  45. package/src/twine-editor/snippets.ts +74 -0
  46. package/src/twine-editor/toolbar.ts +85 -0
  47. package/src/types-drift-check.ts +12 -0
  48. package/src/utils/field-checks.ts +46 -0
  49. package/types/headless.d.ts +43 -2
  50. package/types/index.d.ts +71 -0
  51. package/types/tooling.d.ts +68 -0
package/README.md CHANGED
@@ -59,6 +59,7 @@ Full docs at **[rohal12.github.io/spindle](https://rohal12.github.io/spindle/)**
59
59
  - [Story API](https://rohal12.github.io/spindle/story-api) — The `window.Story` JavaScript API
60
60
  - [Widgets](https://rohal12.github.io/spindle/widgets) — Reusable content blocks
61
61
  - [npm Package](https://rohal12.github.io/spindle/story-format-packages) — Packaging guide
62
+ - [Twine Editor Extensions](https://rohal12.github.io/spindle/twine-editor) — Highlighting, references and a toolbar in Twine's passage editor
62
63
 
63
64
  ## Development
64
65
 
@@ -85,24 +86,25 @@ checks and compares against a base (`--base main`). Locally, CPD needs
85
86
  Before adding a helper, parser or hook, look for the one that already does
86
87
  the job and extend it; most fixes then land in one place. The shared modules:
87
88
 
88
- | Job | Module |
89
- | -------------------------------------------------------- | ------------------------------------------------------------------ |
90
- | Name-keyed storage, own-key reads (`hasOwn`, `ownValue`) | `src/utils/namespace.ts` |
91
- | Case-insensitive macro/widget names | `src/utils/macro-names.ts` |
92
- | Clone, equality, structural diff and merge | `src/structural.ts` |
93
- | Macro arguments: declared `parameters`, `ctx.args` | `src/components/macros/macro-args.ts` |
94
- | Quoting, splitting, string scanning | `src/components/macros/arg-utils.ts` |
95
- | JavaScript scanning (`findCodeEnd`, `lexJs`) | `src/js-lexer.ts` |
96
- | Which declaration a variable names (`Bindings`) | `src/js-bindings.ts` |
97
- | Sigils and scopes (`SIGIL_SCOPES`, `SCOPE_SIGILS`) | `src/markup/tokens.ts` |
98
- | Passage markup (`parseMarkup`, `tokenizeMarkup`) | `src/markup/parse.ts` (grammar: `src/markup/spindle.peggy`) |
99
- | Where code in `{…}` ends (`closeBrace`, `rawBodyEnd`) | `src/markup/code-end.ts` |
100
- | Which closer closes which opener (`pairMarkup`, the AST) | `src/markup/pair.ts` (`buildAst` in `src/markup/ast.ts`) |
101
- | Code, passage names and markup text in a passage | `src/code-check.ts` (`passagePiecesOf`) |
102
- | Declarations of `StoryVariables` (`parseDeclarations`) | `src/story-variables.ts` (literals: `src/static-literal.ts`) |
103
- | Reading story state / render contexts in components | `src/hooks/use-story-fields.ts`, `src/hooks/use-render-options.ts` |
104
- | Save storage operations | `src/saves/storage.ts` (`createBackend`) |
105
- | Listeners to notify (`createListeners`) | `src/utils/listeners.ts` |
89
+ | Job | Module |
90
+ | -------------------------------------------------------- | ------------------------------------------------------------------- |
91
+ | Name-keyed storage, own-key reads (`hasOwn`, `ownValue`) | `src/utils/namespace.ts` |
92
+ | Case-insensitive macro/widget names | `src/utils/macro-names.ts` |
93
+ | Clone, equality, structural diff and merge | `src/structural.ts` |
94
+ | Macro arguments: declared `parameters`, `ctx.args` | `src/components/macros/macro-args.ts` |
95
+ | Quoting, splitting, string scanning | `src/components/macros/arg-utils.ts` |
96
+ | JavaScript scanning (`findCodeEnd`, `lexJs`) | `src/js-lexer.ts` |
97
+ | Which declaration a variable names (`Bindings`) | `src/js-bindings.ts` |
98
+ | Sigils and scopes (`SIGIL_SCOPES`, `SCOPE_SIGILS`) | `src/markup/tokens.ts` |
99
+ | Passage markup (`parseMarkup`, `tokenizeMarkup`) | `src/markup/parse.ts` (grammar: `src/markup/spindle.peggy`) |
100
+ | Where code in `{…}` ends (`closeBrace`, `rawBodyEnd`) | `src/markup/code-end.ts` |
101
+ | Which closer closes which opener (`pairMarkup`, the AST) | `src/markup/pair.ts` (`buildAst` in `src/markup/ast.ts`) |
102
+ | Code, passage names and markup text in a passage | `src/code-check.ts` (`passagePiecesOf`) |
103
+ | Declarations of `StoryVariables` (`parseDeclarations`) | `src/story-variables.ts` (literals: `src/static-literal.ts`) |
104
+ | Reading story state / render contexts in components | `src/hooks/use-story-fields.ts`, `src/hooks/use-render-options.ts` |
105
+ | Save storage operations | `src/saves/storage.ts` (`createBackend`) |
106
+ | Listeners to notify (`createListeners`) | `src/utils/listeners.ts` |
107
+ | Checking plain data handed in (`checkObject`, matchers) | `src/utils/field-checks.ts` (`checkActionMatcher`: action registry) |
106
108
 
107
109
  ## License
108
110