@rohal12/spindle 0.52.7 → 0.52.9

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 (47) hide show
  1. package/README.md +26 -0
  2. package/dist/pkg/format.js +1 -1
  3. package/dist/pkg/headless.js +986 -854
  4. package/dist/pkg/macro-registry.json +18 -0
  5. package/package.json +1 -1
  6. package/src/action-registry.ts +9 -0
  7. package/src/class-registry.ts +1 -5
  8. package/src/components/Passage.tsx +35 -39
  9. package/src/components/PassageDialog.tsx +2 -2
  10. package/src/components/StoryInterface.tsx +2 -2
  11. package/src/components/macros/Checkbox.tsx +3 -8
  12. package/src/components/macros/Computed.tsx +1 -1
  13. package/src/components/macros/Cycle.tsx +3 -6
  14. package/src/components/macros/ExprDisplay.tsx +12 -29
  15. package/src/components/macros/If.tsx +35 -41
  16. package/src/components/macros/Include.tsx +2 -1
  17. package/src/components/macros/Listbox.tsx +5 -7
  18. package/src/components/macros/Print.tsx +3 -5
  19. package/src/components/macros/Radiobutton.tsx +3 -5
  20. package/src/components/macros/Repeat.tsx +2 -1
  21. package/src/components/macros/Switch.tsx +6 -13
  22. package/src/components/macros/Timed.tsx +14 -18
  23. package/src/components/macros/Type.tsx +2 -1
  24. package/src/components/macros/VarDisplay.tsx +12 -32
  25. package/src/components/macros/Widget.tsx +49 -20
  26. package/src/components/macros/branches.ts +18 -0
  27. package/src/components/macros/display.ts +19 -0
  28. package/src/components/macros/input-macro.ts +33 -11
  29. package/src/components/macros/macro-args.ts +7 -0
  30. package/src/components/macros/option-utils.ts +10 -7
  31. package/src/define-macro.ts +4 -6
  32. package/src/expression.ts +58 -40
  33. package/src/hooks/use-action.ts +7 -15
  34. package/src/index.tsx +5 -15
  35. package/src/interpolation.ts +34 -41
  36. package/src/markup/ast.ts +4 -3
  37. package/src/markup/render.tsx +121 -65
  38. package/src/parser.ts +119 -13
  39. package/src/registry.ts +13 -12
  40. package/src/saves/save-manager.ts +18 -13
  41. package/src/saves/storage.ts +19 -20
  42. package/src/story-api.ts +30 -73
  43. package/src/structural.ts +1 -18
  44. package/src/types-drift-check.ts +37 -50
  45. package/src/utils/macro-names.ts +40 -0
  46. package/src/utils/namespace.ts +17 -0
  47. package/src/widgets/widget-registry.ts +5 -4
package/README.md CHANGED
@@ -67,8 +67,34 @@ bun run build # build format
67
67
  bun run preview # build + compile dev story
68
68
  bun run docs:dev # local docs dev server
69
69
  bun run docs:build # build docs for deployment
70
+ bun run duplication # code duplication checks (CPD needs PMD_BIN)
70
71
  ```
71
72
 
73
+ ### Code duplication
74
+
75
+ CI measures duplication in `src/` with three tools, each a separate check:
76
+ jscpd and PMD CPD (exact copies) and fallow (copies with renamed
77
+ identifiers). A pull request fails when it adds duplication compared with
78
+ `main` or exceeds `duplication-budget.json`. The settings are in
79
+ `.jscpd.json` and `.fallowrc.json`; `scripts/duplication.ts` runs the
80
+ checks and compares against a base (`--base main`). Locally, CPD needs
81
+ [PMD](https://pmd.github.io/) 7 with `PMD_BIN` set to its `bin/pmd`.
82
+
83
+ Before adding a helper, parser or hook, look for the one that already does
84
+ the job and extend it; most fixes then land in one place. The shared modules:
85
+
86
+ | Job | Module |
87
+ | -------------------------------------------------------- | ------------------------------------------------------------------ |
88
+ | Name-keyed storage, own-key reads (`hasOwn`, `ownValue`) | `src/utils/namespace.ts` |
89
+ | Case-insensitive macro/widget names | `src/utils/macro-names.ts` |
90
+ | Clone, equality, structural diff and merge | `src/structural.ts` |
91
+ | Macro arguments: declared `parameters`, `ctx.args` | `src/components/macros/macro-args.ts` |
92
+ | Quoting, splitting, string scanning | `src/components/macros/arg-utils.ts` |
93
+ | JavaScript scanning (`findCodeEnd`, `lexJs`) | `src/js-lexer.ts` |
94
+ | Sigils and scopes (`SIGIL_SCOPES`, `SCOPE_SIGILS`) | `src/markup/tokenizer.ts` |
95
+ | Reading story state / render contexts in components | `src/hooks/use-story-fields.ts`, `src/hooks/use-render-options.ts` |
96
+ | Save storage operations | `src/saves/storage.ts` (`createBackend`) |
97
+
72
98
  ## License
73
99
 
74
100
  This is free and unencumbered software released into the public domain. See [UNLICENSE](UNLICENSE).