sygnal 5.2.0 → 5.3.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.
package/dist/index.d.ts CHANGED
@@ -378,6 +378,40 @@ export function enableHMR<STATE = any, DRIVERS = {}>(
378
378
  export function classes(...classes: ClassesType): string
379
379
  export function exactState<STATE>(): <ACTUAL extends STATE>(state: ExactShape<STATE, ACTUAL>) => STATE
380
380
 
381
+ // ── Reducer helpers ────────────────────────────────────────────────
382
+
383
+ /**
384
+ * Create a reducer that merges a partial update into state.
385
+ *
386
+ * Static form — merge a fixed object:
387
+ * `set({ isEditing: true })`
388
+ *
389
+ * Dynamic form — function receives (state, data, next, props) and
390
+ * returns the partial update to merge:
391
+ * `set((state, title) => ({ title }))`
392
+ */
393
+ export function set<S = any>(
394
+ partial: Partial<S> | ((state: S, data: any, next: Function, props: any) => Partial<S>)
395
+ ): (state: S, data: any, next: Function, props: any) => S
396
+
397
+ /**
398
+ * Create a reducer that toggles a boolean field on state.
399
+ *
400
+ * `toggle('showModal')`
401
+ */
402
+ export function toggle<S = any>(field: keyof S & string): (state: S) => S
403
+
404
+ /**
405
+ * Create a model entry that emits an EVENTS bus event.
406
+ *
407
+ * `emit('DELETE_LANE', (state) => ({ laneId: state.id }))`
408
+ * `emit('REFRESH')`
409
+ */
410
+ export function emit(
411
+ type: string,
412
+ data?: any | ((state: any, actionData: any, next: Function, props: any) => any)
413
+ ): { EVENTS: (state: any, actionData: any, next: Function, props: any) => { type: string; data: any } }
414
+
381
415
  /**
382
416
  * Any object with an events() method (e.g., DOM.select('form')).
383
417
  * Uses permissive signature to be compatible with MainDOMSource's overloaded events().
@@ -561,6 +595,35 @@ export interface CommandSource {
561
595
 
562
596
  export function createCommand(): Command
563
597
 
598
+ // ── PWA Helpers ──────────────────────────────────────────────
599
+
600
+ export interface ServiceWorkerSource {
601
+ select(type?: 'installed' | 'activated' | 'waiting' | 'controlling' | 'error' | 'message' | string): Stream<any>;
602
+ }
603
+
604
+ export interface ServiceWorkerCommand {
605
+ action: 'skipWaiting' | 'postMessage' | 'unregister';
606
+ data?: any;
607
+ }
608
+
609
+ export interface ServiceWorkerOptions {
610
+ scope?: string;
611
+ }
612
+
613
+ export function makeServiceWorkerDriver(
614
+ scriptUrl: string,
615
+ options?: ServiceWorkerOptions
616
+ ): (sink$: Stream<ServiceWorkerCommand>) => ServiceWorkerSource
617
+
618
+ export function onlineStatus$(): Stream<boolean>
619
+
620
+ export interface InstallPrompt {
621
+ select(type: 'beforeinstallprompt' | 'appinstalled'): Stream<any>;
622
+ prompt(): Promise<any> | undefined;
623
+ }
624
+
625
+ export function createInstallPrompt(): InstallPrompt
626
+
564
627
  export interface RenderOptions {
565
628
  /** Override initial state (defaults to component's .initialState) */
566
629
  initialState?: any;