Commit Graph

55 Commits

Author SHA1 Message Date
Ryan Hamamura
358e1a8504 style: simplify container ship SVG marker
All checks were successful
CI / Build and Test (push) Successful in 35s
CI / Build and Test (pull_request) Successful in 35s
Use a cleaner silhouette with hull, cargo hold, bridge, and funnel
instead of individually colored containers.
2026-02-20 10:55:14 -10:00
7edd5ed1e6 style: replace simple ship icon with container vessel SVG (#11)
All checks were successful
CI / Build and Test (push) Successful in 36s
2026-02-20 20:53:04 +00:00
934805e707 feat: support custom HTML/SVG element markers in MapLibre (#10)
All checks were successful
CI / Build and Test (push) Successful in 34s
2026-02-20 20:40:19 +00:00
cbc5022e0d feat: sync all markers across clients in MapLibre example (#9)
All checks were successful
CI / Build and Test (push) Successful in 35s
2026-02-20 20:16:17 +00:00
cb13839157 fix: nil-close bug, stale docs, dead code, and tracked binaries (#7)
All checks were successful
CI / Build and Test (push) Successful in 34s
2026-02-20 20:00:44 +00:00
6064ddd856 style: normalize struct field alignment (#5)
All checks were successful
CI / Build and Test (push) Successful in 36s
2026-02-20 19:31:32 +00:00
c0f4782f2b fix: maplibre reactive signal bugs and stale signal re-push (#3)
Some checks failed
CI / Build and Test (push) Failing after 36s
2026-02-20 18:31:27 +00:00
Ryan Hamamura
742212fd20 feat: add maplibre subpackage for type-safe MapLibre GL JS maps
Some checks failed
CI / Build and Test (push) Has been cancelled
Provides a Go API for interactive maps within Via applications:
- Plugin serves vendored MapLibre GL JS v4.7.1 assets
- Map struct with pre/post-render source, layer, marker, popup management
- Viewport signal sync (center, zoom, bearing, pitch) via hidden inputs
- FlyTo, SetCenter, SetZoom and other viewport setters via ExecScript
- Idempotent init script with SPA cleanup via MutationObserver
- Example app demonstrating markers, GeoJSON layers, and FlyTo actions
2026-02-19 13:37:16 -10:00
Ryan Hamamura
60009124c9 feat: add declarative Options.Streams for automatic JetStream stream creation
Some checks failed
CI / Build and Test (push) Has been cancelled
Streams listed in Options.Streams are created by Start() when the
embedded NATS server initializes, replacing manual EnsureStream calls
during setup. Migrates nats-chatroom and pubsub-crud examples.
2026-02-19 12:24:44 -10:00
Ryan Hamamura
f3a9c8036f refactor: use computed signals in pubsub-crud and chatroom examples
Some checks failed
CI / Build and Test (push) Has been cancelled
2026-02-19 09:03:13 -10:00
Ryan Hamamura
719b389be6 refactor: split nats-chatroom into modules with profile, layout, and auth
Extract chat, profile, types, and user data into separate files.
Embed CSS via go:embed. Add a layout with nav, session-based profile
persistence, and a middleware guard that redirects to /profile when
no identity is set.
2026-02-13 10:55:04 -10:00
Ryan Hamamura
27b8540b71 feat: add SPA navigation with view transitions
Swap page content over the existing SSE connection without full page
loads. A persistent Context resets its page-specific state (signals,
actions, intervals, subscriptions) on navigate while preserving the
SSE stream, CSRF token, and session.

- c.Navigate(path) for programmatic SPA navigation from actions
- Injected JS intercepts same-origin <a> clicks (opt out with
  data-via-no-boost) and handles popstate for back/forward
- v.Layout() wraps pages in a shared shell for DRY nav/chrome
- View Transition API integration via WithViewTransitions() on
  PatchElements and h.DataViewTransition() helper
- POST /_navigate endpoint with CSRF validation and rate limiting
- pageStopChan cancels page-level OnInterval goroutines on navigate
- Includes SPA example with layout, counter, and live clock pages
2026-02-12 13:52:47 -10:00
Ryan Hamamura
532651552a refactor: simplify OnInterval API to auto-start and return stop func
Replace the exported OnIntervalRoutine struct (Start/Stop/UpdateInterval)
with a single function that auto-starts the goroutine and returns an
idempotent stop closure. Uses close(channel) instead of send-on-channel,
fixing a potential deadlock when the goroutine exits via context disposal.

Closes #5 item 4.
2026-02-12 12:27:50 -10:00
Ryan Hamamura
2310e45d35 feat: auto-start embedded NATS server in New()
Pub/sub now works out of the box — New() starts a process-scoped
embedded NATS server with JetStream. The PubSub interface remains
for custom backends via Config(Options{PubSub: ...}).

- Move vianats functionality into nats.go (eliminates circular import)
- Add NATSConn(), JetStream(), EnsureStream(), ReplayHistory[T]() to via
- Delete vianats/ package
- Simplify nats-chatroom and pubsub-crud examples
- Rewrite pubsub tests to use real embedded NATS
2026-02-12 08:54:44 -10:00
Ryan Hamamura
10b4838f8d feat: auto-track fields on context for zero-arg ValidateAll/ResetFields
Fields created via Context.Field are now tracked on the page context,
so ValidateAll() and ResetFields() with no arguments operate on all
fields by default. Explicit field args still work for selective use.

Also switches MinLen/MaxLen to utf8.RuneCountInString for correct
unicode handling and replaces fmt.Errorf with errors.New where
format strings are unnecessary.
2026-02-11 19:57:13 -10:00
Ryan Hamamura
5362614c3e feat: add field validation API with signup form example
Introduces Field, Rule, ValidateAll, ResetFields, and AddError for
declarative input validation. Includes built-in rules (Required,
MinLen, MaxLen, Min, Max, Email, Pattern, Custom) and a signup
example exercising the full API surface.
2026-02-11 14:42:44 -10:00
ryanhamamura
e636970f7b feat: add middleware, route groups, and codebase cleanup
* feat: add middleware example demonstrating route groups

Self-contained example covering v.Use(), v.Group(), nested groups,
Group.Use(), and middleware chaining with role-based access control.

* feat: add per-action middleware via WithMiddleware ActionOption

Reuses the existing Middleware type so the same auth/logging functions
work at both page and action level. Middleware runs after CSRF and
rate-limit checks, with full access to session and signals.

* feat: add RedirectView helper and refactor session example to use middleware

RedirectView lets middleware abort and redirect in one step. The session
example now uses an authRequired middleware on a route group instead of
an inline check inside the view.

* fix: remove dead code, fix double Load and extractParams mismatch

- Remove componentRegistry (written, never read)
- Remove unused signal methods: Bytes, Int64, Float
- Remove unreachable nil check in registerCtx
- Simplify injectRouteParams (extractParams already returns fresh map)
- Fix double sync.Map.Load in injectSignals
- Merge Shutdown/shutdown into single method
- Inline currSessionNum
- Fix extractParams: mismatched literal segment now returns nil
- Minor: new(bytes.Buffer), go c.Sync(), genRandID reads 4 bytes
2026-02-11 13:50:02 -10:00
Ryan Hamamura
2c44671d0e feat: add generic pub/sub helpers and pubsub-crud example
Add typed Publish[T] and Subscribe[T] generic helpers that handle
JSON marshaling, along with vianats.EnsureStream and ReplayHistory
helpers. Refactor nats-chatroom to use the new APIs.

Add pubsub-crud example demonstrating CRUD operations with DaisyUI
toast notifications broadcast to all connected clients via NATS.
2026-02-06 09:47:39 -10:00
Ryan Hamamura
53e5733100 feat: add keyboard grid example
8x8 grid game demonstrating OnKeyDownMap with WASD and arrow key
bindings. Arrow keys use WithPreventDefault to avoid page scrolling.
2026-02-02 08:58:03 -10:00
Ryan Hamamura
a7ace9099f feat: replace log with rs/zerolog for structured logging
Switch from the standard library log package to rs/zerolog with
ConsoleWriter for colorful terminal output in dev mode and JSON
output in production. Users can now provide their own logger via
Options.Logger or set the level via Options.LogLevel.
2026-01-31 08:18:24 -10:00
Ryan Hamamura
d8318af9c4 feat: add JetStream message replay to chatroom example
Replay stored messages from JetStream when joining or switching rooms
so users see chat history immediately.
2026-01-26 08:10:30 -10:00
Ryan Hamamura
30cc6d88e6 feat: add embedded NATS pub/sub support on Context
Define PubSub and Subscription interfaces in the core via package with
a vianats sub-package providing the embedded NATS + JetStream
implementation. Expose c.Publish() and c.Subscribe() on Context with
automatic subscription cleanup on session close. Refactor the NATS
chatroom example to use the built-in methods instead of manual
subscription tracking.
2026-01-26 08:06:50 -10:00
Ryan Hamamura
88bd0f31df feat: add NATS chatroom example with embedded server
Demonstrates pub/sub messaging as an alternative to custom Rooms
implementation. Uses delaneyj/toolbelt/embeddednats to run NATS
with JetStream inside the binary - no external server required.
2026-01-16 00:50:05 -10:00
Ryan Hamamura
82a3314089 feat: add SQLite session store support
Add NewSQLiteSessionManager helper that creates an SCS session manager
backed by SQLite, allowing sessions to persist across server restarts.
The function handles table creation automatically.
2026-01-15 08:44:27 -10:00
Ryan Hamamura
c77ccc0796 chore: rename module to github.com/ryanhamamura/via
Update module path and all internal imports to use the new repository location.
2026-01-14 10:47:11 -10:00
Ryan Hamamura
03b6d7453a feat: add Redirect and ReplaceURL methods for browser navigation
Add SSE-based navigation methods to Context:
- Redirect(url) / Redirectf() - navigate to new page
- ReplaceURL(url) / ReplaceURLf() - update URL without navigation

Update session example to demonstrate full login flow with redirects.
2026-01-12 00:47:52 -10:00
ryanhamamura
9a23188973 feat: add cookie-based session support using alexedwards/scs (#1)
- Add Session wrapper with typed getters (GetString, GetInt, GetBool, etc.)
- Add flash message support via Pop methods (PopString, PopInt, etc.)
- Add session utilities: Exists, Keys, ID, Clear, Destroy, RenewToken
- Create default session manager in New() for zero-config usage
- Allow custom session manager via Options.SessionManager
- Wrap mux with scs LoadAndSave middleware in Start()
- Add session example demonstrating login/logout with flash messages
2026-01-09 06:59:26 -10:00
Joao Goncalves
20dad802a1 feat: replace Handler() method for HTTPServeMux() for better plugin and testing integration; remove via-plugin-picocss dependency from examples; add datastar h.H nodes for data-init, data-effect, and data-ignore-morph; update realtimechart example; other small improvements 2025-12-17 17:11:59 -01:00
Joao Goncalves
81d44954a4 feat: add path params; add pathparams example 2025-12-04 17:53:06 -01:00
Joao Goncalves
26268f698a refactor: simplify oninterval routine; fix(runtime): session end handler; update realtime chart example 2025-12-04 12:40:36 -01:00
Joao Goncalves
6edace647e fix(via_test): remove signal sync test that was bocking test execution 2025-11-25 22:54:00 -01:00
Joao Goncalves
9776fe0a49 fix: shakespere example not compiling; remove sleep statements from patchChan loop 2025-11-18 13:03:21 -01:00
Jeff Winkler
3ee90b30d8 SQLite FTS example (#20)
* SQLite FTS example

* refactor: remove via cfg chaining

---------

Co-authored-by: Joao Goncalves <joao.goncalves01@gmail.com>
2025-11-18 12:09:56 -01:00
Joao Goncalves
0064150cbc fix: patchChan loop ending after switching browser tab; feat: improve realtime chart example 2025-11-18 11:17:06 -01:00
Joao Goncalves
472351d9a5 refactor: simplify signals; small optimizations 2025-11-16 19:53:51 -01:00
Jeff Winkler
f7b5b24dd5 Script, GH action to check that all go files compile, and any tests pass. (#16) 2025-11-15 17:47:49 -01:00
Jeff Winkler
762635d7d9 Signals were always being sent down - changed flag never cleared. This wiped out the user input area in chat. (#13)
Publish every 100ms

Co-authored-by: João Gonçalves <joao.goncalves01@gmail.com>
2025-11-15 10:40:07 -01:00
Joao Goncalves
03019364ca fix: component nil pointer on sync; improve realtimechart example 2025-11-15 03:01:53 -01:00
Joao Goncalves
80879216b2 fix: components not using parent page patchShan; fix: chat example nil pointer error when sync outside action 2025-11-15 02:34:27 -01:00
Joao Goncalves
808d4dd0d1 fix: try solution for race conditions; use brotli included in datastar sdk; small improvements 2025-11-14 17:16:09 -01:00
Jeff Winkler
351bed3ea1 Chatroom 2 (#10)
* Remove unused method. Don't panic if unknown room.

* Need a Connected() check for rooms publishing - don't do the work of rendering for a dead connection

* Make vars private.

* Linter issues

* Remove Connected()

* Mutation observer. Publish 4x / second.

---------

Co-authored-by: João Gonçalves <joao.goncalves01@gmail.com>
2025-11-13 14:39:37 -01:00
Joao Goncalves
b9df99889e feat: introduce ctx close mechanism using beforeunload event; small fixes and improvements; improve live reload example 2025-11-13 12:11:26 -01:00
Joao Goncalves
d282773379 fix: auto reload on multiple browser windows/tabs closes #6; fix: chatroom example not compiling 2025-11-12 02:33:22 -01:00
Jeff Winkler
779718a088 Multi-Room Chat (#4)
* # This is a combination of 4 commits.
# This is the 1st commit message:

Chatroom example

# This is the commit message #2:

Avatar styling

# This is the commit message #3:

Styling

# This is the commit message #4:

cleanup

* Chatroom example

Avatar styling

Benchmark tests

Cleanup

ignore

Files

Cleanroom chatroom impl

* Rewrite.

* changes

* Fix Deadlocks. Start the rooms. Fix styling. Random things. Bookmarklet.

* Subset data

* Rm file

* Simplify User. Just Comparable.

* Remove method.
2025-11-11 22:30:40 -01:00
Joao Goncalves
03ce9808e6 feat: add devmode flag; introduce live reload support; update examples 2025-11-11 00:15:44 -01:00
Joao Goncalves
9f9e4eb568 refactor: move document head includes out of via configuration into their own append funcs; update examples 2025-11-09 03:17:03 -01:00
Jeff Winkler
3b658ed7d0 LiveReload 2025-11-08 13:05:23 -05:00
Joao Goncalves
a46c06b467 feat: introduce support for plugins 2025-11-07 02:45:58 -01:00
Joao Goncalves
798f024743 feat: improve real-time chart example; add small refinements to via core files 2025-11-07 00:44:48 -01:00
Joao Goncalves
c167f0c74f feat: add real-time chart example 2025-11-05 17:29:29 -01:00