Commit Graph

382 Commits

Author SHA1 Message Date
hypercross 1c69bf394c feat: add support for stat templates
Introduces a new `template` stat type that allows for table-based
lookups via CSV blocks in markdown files. When a template stat is
rolled, it uses a dice expression defined in the template to select
an entry, applies a label, and automatically updates associated
modifier stats using relative values.
2026-07-09 10:26:54 +08:00
hypercross 19c66640b5 refactor: extract stat parsing logic to shared module
Move YAML and CSV stat parsing logic from CLI and journal components
into a new shared `stat-parser.ts` module to enable reuse between
the CLI scanner and the client-side frontend.
2026-07-09 10:00:17 +08:00
hypercross ef8b56e5b6 feat: add stat completion source
Implement a new completion source that extracts stat definitions
from markdown files using `yaml` or `csv` code blocks with
`role=stat`.
2026-07-09 09:52:34 +08:00
hypercross 45cd9a01ac feat: add CSV support for journal stat blocks 2026-07-09 09:47:17 +08:00
hypercross 138c089514 feat: implement scoped stat system with player/global support
Introduces a scoping mechanism for statistics, allowing properties
to be defined as either "player" (prefixed with player name) or
"global".

- Adds `scope` property to StatDef
- Implements key resolution to handle bare keys vs full keys
- Updates `canModifyStat` to enforce player-specific permissions
- Enhances `makeStatLookup` to resolve scoped references in formulas
- Adds documentation for the new stat system
2026-07-09 09:41:16 +08:00
hypercross 44e4e15f3f feat: implement command autocomplete for journal input
Refactor journal input command parsing into a dedicated module and
add a `CompletionsDropdown` component to provide real-time suggestions
for commands (/roll, /spark, /link, /stat) and their arguments.
2026-07-09 09:31:19 +08:00
hypercross 9747409a1f feat: implement stat system and StatsView
Introduces a comprehensive stat management system including:
- `/stat` command support (set, del, roll)
- `StatsView` component for displaying grouped stat tables
- Formula evaluation for derived stats (supporting arithmetic and
  functions)
- Stat definition parsing from YAML blocks
- Permission checking for stat modification based on roles
2026-07-09 09:22:14 +08:00
hypercross 4faff9a391 feat(journal): allow players to emit roll messages 2026-07-09 09:06:25 +08:00
hypercross ae3045f96b fix(cli): preserve inline blocks without file or as attributes 2026-07-08 16:49:01 +08:00
hypercross 6ab6b76978 feat: pass source path to markdown parser for icon resolution
Pass the file's base path through the markdown parsing pipeline to
allow the icon directive to resolve relative asset paths correctly
using an absolute fallback chain.
2026-07-08 16:38:19 +08:00
hypercross 2dba19e1f8 feat: implement icon directive with relative path fallback
Refactor icon rendering to use a custom `marked-directive` instead of
a global icon prefix. This allows icons to use a CSS-based fallback
chain (searching up to 10 directory levels for an `assets/` folder),
making icon paths more robust and removing the need to pass path
prefixes through the component tree.
2026-07-08 16:24:09 +08:00
hypercross 749b1a6a4b feat: support multiple attributes and `as` directive in inline blocks
Update the inline block parser to support arbitrary key-value pairs.
If an `as` attribute is provided, the block is replaced with a
directive (e.g., `:directive[path]{attrs}`) instead of being
stripped. If no `as` attribute is present, the block is removed.
Additionally, filenames are now automatically generated using a
content hash if the `file` attribute is missing.
2026-07-08 16:02:19 +08:00
hypercross 2a9eee6410 feat: extract and index inline file blocks in markdown 2026-07-08 15:46:19 +08:00
hypercross 9a5ee695c2 docs: clarify dev environment index loading behavior
Update file-index.ts documentation and implementation to specify
that webpackContext loading is restricted to development mode.
This ensures the code block is tree-shaken during production builds.
2026-07-08 15:19:50 +08:00
hypercross e0c3b8f4a0 feat: add bundle analysis support
Add `webpack-bundle-analyzer` and a new `analyze` script to allow
visualizing bundle composition via `npm run analyze`.
2026-07-08 15:16:12 +08:00
hypercross d95615f210 refactor: remove token and token-viewer components
Remove the `md-token` and `md-token-viewer` components along with their
associated 3D generation and image tracing utilities. Update
documentation and project metadata to reflect these changes and rename
the project title to "Tabletop Tools".
2026-07-08 15:09:22 +08:00
hypercross 5097aba842 refactor: implement scroll container context and flex layout
Switch from fixed positioning to a flexbox-based layout for the
main application structure. This introduces a `ScrollContainerCtx` to
provide access to the main scrollable element, allowing child
components like `FileTree` and `RevealManager` to perform accurate
scrolling and positioning relative to the container instead of the
window.

refactor: set JournalPanel height to full
2026-07-08 15:03:31 +08:00
hypercross b54f7ab1fa chore: add uuid dependency 2026-07-08 11:48:25 +08:00
hypercross c13f66153a feat: implement session creation flow
Refactor `CreateSessionDialog` to be controlled by its parent instead
of using an internal `open` prop. Lift the state up to `JournalPanel`
and pass the creation callback through `JournalHeader` to
`SessionDropdown`.
2026-07-08 00:39:29 +08:00
hypercross 376dde44b5 feat: add range support for spark table cell matching 2026-07-08 00:37:01 +08:00
hypercross 03671583cd feat: allow closing dialogs by clicking backdrop 2026-07-08 00:35:01 +08:00
hypercross 2c2b7b781d feat(journal): implement session management UI components
Add a suite of dialogs and header components to manage journal
sessions, including:

- ConnectDialog for joining sessions with name and role selection
- CreateSessionDialog for starting new sessions
- InviteDialog for generating and copying player invite links
- SessionDropdown for switching between sessions (GM only)
- JournalHeader for displaying connection status and user info
2026-07-08 00:31:35 +08:00
hypercross 3d957706e9 feat(journal): add JournalContext to allow closing panel on mobile 2026-07-08 00:11:16 +08:00
hypercross 57ffb35f2b feat: publish initial manifest on startup and improve UI focus
- Publish the existing session manifest via the broker on startup
- Automatically focus the new session input field when it is shown
- Prevent event propagation when clicking to create a new session
2026-07-08 00:08:12 +08:00
hypercross 3eba8b3279 fix(ui): increase z-index for DocDialog elements
Update z-index from 50 to 60 for the dialog overlay and dropdown
to ensure they appear above other UI components.
2026-07-07 23:59:57 +08:00
hypercross c10b088fb1 feat: add Journal server documentation to DocDialog
Introduce a new documentation set for Journal server functionality,
including a dropdown selector in the DocDialog to switch between
"directives" and "journal" documentation modes.
2026-07-07 23:57:31 +08:00
hypercross 1ef41f04fc feat: localize journal components to Chinese 2026-07-07 23:51:35 +08:00
hypercross 9a41f541e9 feat: improve server startup logs and simplify journal input labels
- Add logic to detect the best LAN IPv4 address for easier network
  access
- Display both localhost and LAN access URLs in the CLI
- Remove file path from journal input autocomplete labels
2026-07-07 23:48:04 +08:00
hypercross 45c8722af8 fix: decode URI components before path processing
Ensure path normalization and encoding handle URI-encoded segments
correctly by decoding them first.
2026-07-07 23:43:02 +08:00
hypercross e6d74cc318 fix: remove command prefix from action prefill text 2026-07-07 23:32:33 +08:00
hypercross 779722fe85 refactor: preserve URL search params during navigation
Introduce `useNavigateWithParams` to ensure that existing URL search
parameters are maintained when navigating between pages. This is
applied to the Article component, FileTree, and journal links to
prevent losing state (like session or player info) during client-side
navigation.

Also intercepts markdown anchor links in the Article component to use
client-side navigation.
2026-07-07 23:26:44 +08:00
hypercross 48776424a7 fix(RevealManager): prevent GM listeners when disconnected
Only initialize GM hover listeners if the user is both a GM and
connected.
2026-07-07 23:17:57 +08:00
hypercross 4eaf6aab16 refactor: move GM action buttons to Solid components
Migrate GM action button injection from imperative DOM manipulation to
a reactive Solid component (`RevealManager`) using `Portal`. This
improves cleanup reliability and ensures buttons are proper Solid
components rather than raw HTML strings injected into the DOM.

Also adds URI encoding for link paths and simplifies the reveal
store logic.
2026-07-07 23:14:04 +08:00
hypercross aa326f38a0 refactor: introduce RevealManager and Article DOM context
Decouple the reveal logic from the `Article` component by introducing
a `RevealManager` component and an `ArticleDomCtx`. This allows the
reveal logic to reactively manage DOM injections and classes without
polluting the `Article` component's props or lifecycle.

Additionally, implements a robust `cleanupInjections` mechanism to
ensure that injected buttons and styling artifacts are properly removed
during navigation, role changes, or disconnections.
2026-07-07 22:19:04 +08:00
hypercross 1ef2560faa fix: normalize line endings in frontmatter parsing
Normalize CRLF line endings to LF before parsing frontmatter
to ensure regex matching works consistently across different platforms.
2026-07-07 21:47:25 +08:00
hypercross 6b3a915350 refactor: simplify spark button injection logic
Update the spark button injection to use `data-spark` slugs on
`md-table` elements instead of manual table parsing. This improves
reliability by leveraging the slug generated during markdown
rendering.
2026-07-07 21:44:00 +08:00
hypercross 56af7dea42 feat: add spark table roll buttons for GMs
Introduces the ability for GMs to inject spark roll buttons into
tables that match existing spark completions.

- Replaces `linkPrefill` with a more flexible `actionPrefill` system
  to support multiple command types (e.g., `/link`, `/spark`).
- Implements `injectSparkButtons` to identify spark tables in the
  DOM and insert action buttons.
- Updates `JournalInput` to handle structured prefill actions.
2026-07-07 21:38:43 +08:00
hypercross e801ac9b5f refactor: improve spark table lookup and error reporting
Replace the heuristic-based slug parsing with a more robust
combined-slug lookup to correctly handle page names containing
hyphens. Added `scanSparkTables` to provide better error messages
when a table is not found.
2026-07-07 19:13:11 +08:00
hypercross 9a312f76ad fix(completions): instantiate Slugger per file
Move Slugger instantiation inside the file loops to prevent
state leakage between files, as Slugger is stateful.
2026-07-07 19:07:37 +08:00
hypercross 97148aa010 refactor: improve column slug extraction logic 2026-07-07 19:05:47 +08:00
hypercross 2f29f8774d feat: add spark table completion and rolling support
Implement "spark tables" functionality, which allows users to roll
dice against markdown tables to retrieve specific values.

- Add `sparkTablesSource` to scan markdown files for tables starting
  with a dice notation (e.g., d6, d20).
- Implement `/spark` command in the journal to resolve and roll
  spark tables.
- Add a new message type `spark` with a dedicated UI component to
  render the results.
- Update completions API to include spark table metadata.
2026-07-07 19:02:17 +08:00
hypercross 3690d13407 refactor: extract persistence and reveal logic into new stores
Move localStorage and URL parameter management from `journalStream`
to a dedicated `persistence` store. Relocate DOM reveal and heading
injection logic to a new `reveal` store to improve separation of
concerns.
2026-07-07 18:10:43 +08:00
hypercross ef7295ff7a fix(sidebar): add correct node identity to heading set 2026-07-07 13:26:35 +08:00
hypercross 574d17f201 refactor: improve heading revelation logic
Rewrite `addRevealedClasses` to use a two-pass approach that correctly
cascades revealed status from child headings to parent headings. This
ensures that if a sub-heading is revealed, its parent headings are
also treated as revealed, maintaining proper visibility hierarchy.
2026-07-07 12:56:28 +08:00
hypercross ced9a4f8f2 feat: implement content reveal mechanism via DOM traversal
Add `addRevealedClasses` to apply `revealed` or `concealed` CSS classes
to article elements based on the current heading hierarchy and
revealed paths. Update `Article` to expose its DOM element via an
`onDom` callback.
2026-07-07 10:56:19 +08:00
hypercross adf28a7cf1 feat: implement visibility logic for sidebar nodes
Add support for hiding file tree nodes and headings based on path
revelation status. This allows the sidebar to dynamically show only
the relevant parts of the file structure and table of contents.
2026-07-07 09:27:04 +08:00
hypercross c5e1167beb feat: implement granular section visibility control
Introduce the ability to reveal specific sections of a document
rather than entire files. This includes:

- Updating `revealedPaths` to map normalized file paths to sets of
  revealed section slugs.
- Adding `isPathRevealed` to handle visibility logic for connected
  clients and GMs.
- Enhancing `extractHeadings` to calculate `startLine` and `endLine`
  for each TOC node to support precise section identification.
2026-07-07 07:44:57 +08:00
hypercross 7cfc0fd4f3 feat: add player invitation and autojoin functionality
Implement a system to invite players via generated URLs that
automatically configure their name and role.

- Add `InviteDialog` to allow users to generate and copy invite links
- Implement autojoin logic in `ConnectDialog` based on URL parameters
- Add an "+ invite" button to the `JournalPanel` player list
- Ensure `autojoin` parameter is stripped on disconnect to allow
  manual connection later
2026-07-06 18:41:40 +08:00
hypercross 1d0f2f7c3e feat: add plain text dice roll detail
Introduces `plainDetail` to the dice engine to provide a non-HTML
version of the roll results. This allows components to display
the roll breakdown without needing to parse or render HTML.
2026-07-06 18:18:16 +08:00
hypercross 0fc61e2f94 refactor: simplify journal message types and implement GM rolls
Refactor journal message types to use flatter, more intuitive names:
- `narrative` becomes `chat`
- `article.reveal` becomes `reveal`
- `roll.request`/`roll.result` becomes a single `roll` type

Implement client-side dice roll resolution for GMs. When a GM uses
the `/roll` command, the result is now calculated locally using
`resolveRollPayload` before being sent to the stream, rather than
requesting a roll from the server.
2026-07-06 18:06:32 +08:00