@weftui/core 0.26.3 → 0.27.1

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/README.md CHANGED
@@ -9,21 +9,23 @@ This package is renderer-agnostic — pair it with [`@weftui/dom`](https://weftu
9
9
  ## Installation
10
10
 
11
11
  ```bash
12
- npm install @weftui/core effect
12
+ npm install @weftui/core effect@beta
13
13
  ```
14
14
 
15
+ Weft tracks Effect 4's beta line. This release is built and tested against `effect@4.0.0-beta.98`; the peer range accepts newer 4.0 betas, which may contain upstream breaking changes.
16
+
15
17
  `effect` is a peer dependency. To render, add [`@weftui/dom`](https://www.npmjs.com/package/@weftui/dom).
16
18
 
17
19
  ## Key exports
18
20
 
19
- | Export | What it is |
20
- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
21
- | `h` | Proxy namespace of element builders — `h.div`, `h.span`, `h.button`, … plus `h.fragment` for wrapper-less groups. |
22
- | `Component` | `Component.gen` / `Component.make` — reusable components whose reactive prop channels propagate to the call site. |
23
- | `Boundary` | Error boundaries (`catchAll`, `catchTag`, `catchTags`, `catchSome`, `catchIf`, `catchAllCause`), plus `Boundary.suspend` (async fallbacks) and `Boundary.rpc` (server-data seam). |
24
- | `List` | `List.each` — the keyed list combinator; renders once per key and reconciles across emissions. |
25
- | `Source` | The reactive prop vocabulary (`A \| Effect \| Stream \| Subscribable`) + `Source.toSubscribable`. |
26
- | `Node<E,R>` | The core tree type — an alias for `Effect.Effect<ElementDescriptor, E, R>`. |
21
+ | Export | What it is |
22
+ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
23
+ | `h` | Proxy namespace of element builders — `h.div`, `h.span`, `h.button`, … plus `h.fragment` for wrapper-less groups. |
24
+ | `Component` | `Component.gen` / `Component.make` — reusable components whose reactive prop channels propagate to the call site. |
25
+ | `Boundary` | Error boundaries (`catch`, `catchTag`, `catchTags`, `catchFilter`, `catchIf`, `catchCause`), plus `Boundary.suspend` (async fallbacks) and `Boundary.rpc` (server-data seam). |
26
+ | `List` | `List.each` — the keyed list combinator; renders once per key and reconciles across emissions. |
27
+ | `Source` | The reactive prop vocabulary (`A \| Effect \| Stream \| Subscribable`) + `Source.toSubscribable`. |
28
+ | `Node<E,R>` | The core tree type — an alias for `Effect.Effect<ElementDescriptor, E, R>`. |
27
29
 
28
30
  ## Example
29
31
 
@@ -37,7 +39,7 @@ const Counter = () =>
37
39
  const count = yield* SubscriptionRef.make(0);
38
40
 
39
41
  return yield* h.div([
40
- h.span([count.changes]),
42
+ h.span([SubscriptionRef.changes(count)]),
41
43
  h.button({ onclick: () => SubscriptionRef.update(count, (n) => n + 1) }, "+"),
42
44
  h.button({ onclick: () => SubscriptionRef.update(count, (n) => n - 1) }, "-"),
43
45
  ]);
@@ -1,5 +1,66 @@
1
- import { Cause, Effect, Option, Ref, Scope, Stream, Subscribable } from "effect";
1
+ import { Cause, Effect, Option, Scope, Stream, SubscriptionRef } from "effect";
2
2
 
3
+ //#region src/subscribable/index.d.ts
4
+ declare namespace index_d_exports {
5
+ export { Subscribable, TypeId, changes, get, isSubscribable, make };
6
+ }
7
+ /**
8
+ * Unique brand identifying a {@link Subscribable}, and the key under which its
9
+ * `get`/`changes` channels are held. Effect 4 dropped its own
10
+ * `Subscribable`/`Readable` modules, so Weft carries this reactivity interface
11
+ * locally; the string brand mirrors Effect 4's `"~effect/*"` TypeId convention
12
+ * (e.g. `SubscriptionRef`) and backs the {@link isSubscribable} guard.
13
+ */
14
+ declare const TypeId = "~@weftui/core/Subscribable";
15
+ /**
16
+ * Type of the {@link TypeId} brand.
17
+ */
18
+ type TypeId = typeof TypeId;
19
+ /**
20
+ * A hot, await-first reactive value: `get` reads the current value as an
21
+ * `Effect`, `changes` is a `Stream` of every value (including the current one).
22
+ * Read them either directly or through the {@link get} / {@link changes} module
23
+ * accessors, which mirror Effect 4's `SubscriptionRef.get` / `.changes` so a
24
+ * `Subscribable` and a `SubscriptionRef` read the same way at a call site.
25
+ *
26
+ * This is Weft's local replacement for Effect 3's `Subscribable`, preserved as
27
+ * public API so `Source`, `Boundary`, and the DOM renderers keep the same
28
+ * reactivity surface across the Effect 4 migration.
29
+ */
30
+ interface Subscribable<A, E = never, R = never> {
31
+ readonly [TypeId]: TypeId;
32
+ /** Read the current value; also reachable via the {@link get} accessor. */
33
+ readonly get: Effect.Effect<A, E, R>;
34
+ /** Stream of every value; also reachable via the {@link changes} accessor. */
35
+ readonly changes: Stream.Stream<A, E, R>;
36
+ }
37
+ /**
38
+ * Build a {@link Subscribable} from a `get` effect and a `changes` stream. The
39
+ * caller owns the semantics of the two channels (e.g. hot vs. cold, whether
40
+ * `changes` replays the current value); `make` only stamps the brand.
41
+ */
42
+ declare const make: <A, E = never, R = never>(options: {
43
+ readonly get: Effect.Effect<A, E, R>;
44
+ readonly changes: Stream.Stream<A, E, R>;
45
+ }) => Subscribable<A, E, R>;
46
+ /**
47
+ * Read the current value of a {@link Subscribable} as an `Effect`. Mirrors
48
+ * `SubscriptionRef.get`, so call sites read `Subscribable`s and
49
+ * `SubscriptionRef`s the same way.
50
+ */
51
+ declare const get: <A, E, R>(self: Subscribable<A, E, R>) => Effect.Effect<A, E, R>;
52
+ /**
53
+ * The `Stream` of every value of a {@link Subscribable}, starting with the
54
+ * current one. Mirrors `SubscriptionRef.changes`.
55
+ */
56
+ declare const changes: <A, E, R>(self: Subscribable<A, E, R>) => Stream.Stream<A, E, R>;
57
+ /**
58
+ * Refinement guard: `true` when `u` carries the {@link TypeId} brand, i.e. was
59
+ * produced by {@link make}. Used by `Source.toSubscribable` to thread an
60
+ * existing `Subscribable` through by reference instead of re-wrapping it.
61
+ */
62
+ declare const isSubscribable: (u: unknown) => u is Subscribable<unknown, unknown, unknown>;
63
+ //#endregion
3
64
  //#region ../../node_modules/.pnpm/csstype@3.2.3/node_modules/csstype/index.d.ts
4
65
  interface StandardLonghandProperties<TLength = (string & {}) | 0, TTime = string & {}> {
5
66
  /**
@@ -10447,7 +10508,7 @@ declare namespace Source {
10447
10508
  * caller can switch between them freely. An incoming `Subscribable` is threaded
10448
10509
  * through by reference (no re-wrap); the rest normalize via `toSubscribable`.
10449
10510
  */
10450
- type Source<A, E = any, R = any> = A | Stream.Stream<A, E, R> | Effect.Effect<A, E, R> | Subscribable.Subscribable<A, E, R>;
10511
+ type Source<A, E = any, R = any> = A | Stream.Stream<A, E, R> | Effect.Effect<A, E, R> | Subscribable<A, E, R>;
10451
10512
  /**
10452
10513
  * Extract the emitted value type `A` from any {@link Source} kind, mirroring
10453
10514
  * Effect's `Effect.Effect.Success`. A `Stream`/`Effect`/`Subscribable`
@@ -10457,11 +10518,11 @@ declare namespace Source {
10457
10518
  * `Effect` — which is itself iterable for generators — never reaches the static
10458
10519
  * fallback. The props-object analog is `PropsE`/`PropsR` in `combinator/types.ts`.
10459
10520
  */
10460
- type Success<S> = S extends Stream.Stream<infer A, any, any> ? A : S extends Effect.Effect<infer A, any, any> ? A : S extends Subscribable.Subscribable<infer A, any, any> ? A : S;
10521
+ type Success<S> = S extends Stream.Stream<infer A, any, any> ? A : S extends Effect.Effect<infer A, any, any> ? A : S extends Subscribable<infer A, any, any> ? A : S;
10461
10522
  /** Extract the error channel `E` from any {@link Source} kind; a static value ⇒ `never`. */
10462
- type Error<S> = S extends Stream.Stream<any, infer E, any> ? E : S extends Effect.Effect<any, infer E, any> ? E : S extends Subscribable.Subscribable<any, infer E, any> ? E : never;
10523
+ type Error<S> = S extends Stream.Stream<any, infer E, any> ? E : S extends Effect.Effect<any, infer E, any> ? E : S extends Subscribable<any, infer E, any> ? E : never;
10463
10524
  /** Extract the requirement channel `R` from any {@link Source} kind; a static value ⇒ `never`. */
10464
- type Context<S> = S extends Stream.Stream<any, any, infer R> ? R : S extends Effect.Effect<any, any, infer R> ? R : S extends Subscribable.Subscribable<any, any, infer R> ? R : never;
10525
+ type Context<S> = S extends Stream.Stream<any, any, infer R> ? R : S extends Effect.Effect<any, any, infer R> ? R : S extends Subscribable<any, any, infer R> ? R : never;
10465
10526
  /**
10466
10527
  * Normalize a `Source<A>` into an await-first, hot `Subscribable`.
10467
10528
  *
@@ -10477,7 +10538,7 @@ declare namespace Source {
10477
10538
  * @param source - The caller-supplied value.
10478
10539
  * @param key - Optional key carried on `NoPropValue` for diagnostics.
10479
10540
  */
10480
- function toSubscribable<A, E = never, R = never>(source: Source.Source<A, E, R>, key?: string): Effect.Effect<Subscribable.Subscribable<A, E | NoPropValue, R>, never, Scope.Scope>;
10541
+ function toSubscribable<A, E = never, R = never>(source: Source.Source<A, E, R>, key?: string): Effect.Effect<Subscribable<A, E | NoPropValue, R>, never, Scope.Scope>;
10481
10542
  }
10482
10543
  //#endregion
10483
10544
  //#region src/types/html/attributes.d.ts
@@ -10783,7 +10844,7 @@ type HTMLReferrerPolicy = "no-referrer" | "no-referrer-when-downgrade" | "origin
10783
10844
  type HTMLRole = "alert" | "alertdialog" | "application" | "article" | "banner" | "blockquote" | "button" | "caption" | "cell" | "checkbox" | "code" | "columnheader" | "combobox" | "command" | "complementary" | "composite" | "contentinfo" | "definition" | "deletion" | "dialog" | "directory" | "document" | "emphasis" | "feed" | "figure" | "form" | "generic" | "grid" | "gridcell" | "group" | "heading" | "img" | "input" | "insertion" | "landmark" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "meter" | "navigation" | "none" | "note" | "option" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "range" | "region" | "roletype" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "section" | "sectionhead" | "select" | "separator" | "slider" | "spinbutton" | "status" | "strong" | "structure" | "subscript" | "superscript" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "time" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem" | "widget" | "window";
10784
10845
  interface HTMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
10785
10846
  children?: HTMLAttributeSource<Renderable>;
10786
- ref?: Ref.Ref<Option.Option<T>>;
10847
+ ref?: SubscriptionRef.SubscriptionRef<Option.Option<T>>;
10787
10848
  /**
10788
10849
  * Provides a hint for generating a keyboard shortcut for the current element. This attribute consists of a space-separated list of characters. The browser should use the first one that exists on the computer keyboard layout.
10789
10850
  */
@@ -14661,7 +14722,7 @@ type ImagePreserveAspectRatio = SVGPreserveAspectRatio | "defer none" | "defer x
14661
14722
  type SVGUnits = "userSpaceOnUse" | "objectBoundingBox";
14662
14723
  interface SVGAttributes<T> extends DOMAttributes<T> {
14663
14724
  children?: HTMLAttributeSource<Renderable>;
14664
- ref?: Ref.Ref<Option.Option<T>>;
14725
+ ref?: SubscriptionRef.SubscriptionRef<Option.Option<T>>;
14665
14726
  id?: HTMLAttributeSource<string>;
14666
14727
  lang?: HTMLAttributeSource<string>;
14667
14728
  /**
@@ -15151,4 +15212,4 @@ interface ElementDescriptor {
15151
15212
  */
15152
15213
  type Renderable = void | null | undefined | string | number | bigint | boolean | ElementDescriptor | Iterable<Renderable> | Stream.Stream<unknown, any, any> | Effect.Effect<unknown, any, any>;
15153
15214
  //#endregion
15154
- export { StyleAttributeValue as C, Source as E, HTMLAttributeSource as S, NoPropValue as T, HTMLFormMethod as _, SVGElements as a, HTMLReferrerPolicy as b, HTMLRole as c, EventHandlerFn as d, HTMLAutocapitalize as f, HTMLFormEncType as g, HTMLDir as h, SVGAttributes as i, DOMAttributes as l, HTMLCrossorigin as m, ElementType as n, HTMLAttributes as o, HTMLAutocomplete as p, Renderable as r, HTMLElements as s, ElementDescriptor as t, EventHandler as u, HTMLIframeSandbox as v, StyleProperties as w, AriaAttributes as x, HTMLLinkAs as y };
15215
+ export { StyleAttributeValue as C, Subscribable as D, Source as E, index_d_exports as O, HTMLAttributeSource as S, NoPropValue as T, HTMLFormMethod as _, SVGElements as a, HTMLReferrerPolicy as b, HTMLRole as c, EventHandlerFn as d, HTMLAutocapitalize as f, HTMLFormEncType as g, HTMLDir as h, SVGAttributes as i, DOMAttributes as l, HTMLCrossorigin as m, ElementType as n, HTMLAttributes as o, HTMLAutocomplete as p, Renderable as r, HTMLElements as s, ElementDescriptor as t, EventHandler as u, HTMLIframeSandbox as v, StyleProperties as w, AriaAttributes as x, HTMLLinkAs as y };