feat(types): sync published types with source StoryAPI#135
Merged
Conversation
…ce StoryAPI Create src/types-drift-check.ts that asserts bidirectional assignability between the source StoryAPI and published types/index.d.ts, so any drift is caught by `npx tsc --noEmit`. Update types/index.d.ts with all missing supporting types (event map, transitions, watch options, actions, storage info, macro definition types) and all missing StoryAPI members (registerClass, defineMacro, storage, actions, events, triggers, transitions, PRNG, config, deferred render). Fix existing types: add prng field to HistoryMoment and SavePayload, make visited/hasVisited/rendered/hasRendered name parameter optional, add getToggle/getList/getRange to SettingsAPI for structural compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Release preview: merging this PR will publish v0.42.0 (minor bump from v0.41.0) |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
5 tasks
rohal12
added a commit
that referenced
this pull request
Mar 27, 2026
…142) ## Summary - **Published types sync (#135):** Hand-update `types/index.d.ts` with ~17 missing `StoryAPI` members + compile-time drift-detection test - **Transient variables (#137):** New `%` sigil for reactive variables excluded from persistence, routed through tokenizer, expression engine, store, rendering, and published types - **Computed + for-loop infinite loop (#140):** Memoize `ForIteration`/`WidgetBody` local state to prevent infinite reactive loops when `{computed}` reads `@` locals - **Computed @-target (#140 reopened):** Extend `{computed}` to accept `@var` targets that write to per-iteration local scope via `LocalsUpdateContext`, fixing shared values across `{for}` iterations ## Test plan - [ ] `npx vitest run` — 1087 tests pass - [ ] `npx tsc --noEmit` — typecheck clean - [ ] Verify `{computed @cls = @item.status == 'ok' ? 'green' : 'red'}` inside `{for}` produces per-iteration values - [ ] Verify `{computed _cls = ...}` inside `{for}` still works (last-write-wins, no hang) - [ ] Verify `{computed @cls = ...}` outside a local scope logs an error 🤖 Generated with [Claude Code](https://claude.com/claude-code)
4 tasks
rohal12
added a commit
that referenced
this pull request
Mar 27, 2026
…143) (#144) ## Summary - **Performance fix for issue #143**: Extend the `renderNodes` fast path to skip the micromark + innerHTML pipeline when all text nodes contain only whitespace (indentation, newlines between HTML tags) - Eliminates ~97 redundant pipeline calls per render in `{for}` loops over HTML + macro content, addressing 89% of wall time in Chrome CPU profiles - Preserves blank-line (`\n\n`) detection to maintain paragraph separation semantics ## Also includes (prior work on this branch) - Published types sync (#135) - Mutation buffer (#136) - Transient variables (#137, #138) - Computed @-target in for-loops (#140) ## Test plan - [x] 3 new correctness baseline tests for the fast path - [x] Full test suite passes (1090 tests) - [x] Type check clean (`tsc --noEmit`) - [ ] Manual verification: re-profile the 23-item for-loop passage in Chrome to confirm wall time reduction 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StoryAPImembers totypes/index.d.ts:on(),deferRender(),ready(),setNobr(),setCSS(),setTransition(),setNextTransition(),defineMacro(),getMacroRegistry(),registerClass(),getActions(),performAction(),waitForActions(),watch(),unwatch(),random(),randomInt(),config,prng, andstoragenamespacesStoryEventMap,StoryEvent,StoryEventCallback,TransitionConfig,WatchOptions,StoryAction,StorageInfo,StorageQuota,MacroDefinition,MacroContext,MacroProps,MacroMetadatavisited/hasVisited/rendered/hasRenderedto accept optionalnamearg; fixHistoryMoment/SavePayloadto include optionalprngfieldsrc/types-drift-check.ts— compile-time check that failstsc --noEmitif published and sourceStoryAPIinterfaces divergeFixes #134
Test Plan
npx tsc --noEmitpasses (drift check confirms bidirectional compatibility)npx vitest run— all 1059 tests passimport type { StoryAPI } from '@rohal12/spindle'exposes all new members🤖 Generated with Claude Code