lecodes-sdk 2.5.1 → 2.8.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.
Files changed (50) hide show
  1. package/dist/global.d.ts +7 -7
  2. package/dist/types/gl/Foliage.d.ts +6 -0
  3. package/dist/types/inject.d.ts +1 -1
  4. package/dist/types/runtime/firstCall.d.ts +12 -0
  5. package/dist/types/runtime/rpc.d.ts +24 -0
  6. package/dist/types/runtime/wire.d.ts +11 -4
  7. package/dist/types/server/channel.d.ts +16 -0
  8. package/dist/types/server/computed.d.ts +59 -0
  9. package/dist/types/server/context.d.ts +13 -1
  10. package/dist/types/server/db/fields.d.ts +2 -1
  11. package/dist/types/server/db/marci/query.d.ts +53 -6
  12. package/dist/types/server/inject.d.ts +2 -0
  13. package/dist/types/server/ordered.d.ts +18 -0
  14. package/dist/types/ui/UIBottomSheet.d.ts +21 -14
  15. package/dist/types/ui/UIModal.d.ts +50 -22
  16. package/dist/types/version.d.ts +1 -1
  17. package/dist/types.json +1 -1
  18. package/package.json +2 -2
  19. package/src/bridges/gl.d.ts +4 -1
  20. package/src/chisel.ts +1 -1
  21. package/src/compile/compileProject.ts +7 -2
  22. package/src/compile/serverSplit.ts +8 -4
  23. package/src/compile/serverTypes.ts +17 -3
  24. package/src/gl/Foliage.ts +11 -1
  25. package/src/inject.ts +3 -2
  26. package/src/runtime/firstCall.ts +28 -0
  27. package/src/runtime/rpc.ts +141 -12
  28. package/src/runtime/wire.ts +11 -6
  29. package/src/server/channel.ts +32 -0
  30. package/src/server/channelHub.ts +246 -16
  31. package/src/server/clock.ts +50 -0
  32. package/src/server/computed.ts +84 -0
  33. package/src/server/computedHost.ts +413 -0
  34. package/src/server/context.ts +14 -2
  35. package/src/server/db/defineDb.ts +47 -7
  36. package/src/server/db/fields.ts +2 -1
  37. package/src/server/db/httpTransport.ts +37 -2
  38. package/src/server/db/httpWatch.ts +180 -0
  39. package/src/server/db/marci/query.ts +112 -7
  40. package/src/server/db/watch.ts +160 -0
  41. package/src/server/files/host.ts +2 -1
  42. package/src/server/host.ts +19 -4
  43. package/src/server/inject.ts +6 -2
  44. package/src/server/ordered.ts +41 -0
  45. package/src/server/rateLimit.ts +72 -0
  46. package/src/server/runtime.ts +127 -9
  47. package/src/ui/UIBottomSheet.ts +39 -30
  48. package/src/ui/UIModal.ts +128 -31
  49. package/src/ui/UIWidget.ts +21 -8
  50. package/src/version.ts +1 -1
@@ -1,5 +1,6 @@
1
1
  import { type UIWidget, type UIWidgetStyle, WidgetElement } from "./UIWidget";
2
2
  import { type BaseStyle, type ChildrenFn, type Color, type DrawableStyle, type UIChildArg, type UINodeChild } from "./UINode";
3
+ import { type Signal } from "../core/signals";
3
4
  export type UIModalStyle = UIWidgetStyle;
4
5
  /**
5
6
  * The modal's hidden pose: `show()` animates from it, `hide()` animates to it. `duration` (ms)
@@ -9,25 +10,45 @@ export type UIModalTransition = DrawableStyle & BaseStyle & {
9
10
  overlayColor?: Color | null;
10
11
  duration?: number;
11
12
  };
13
+ /** What `bindShow()` takes: a function of the data, or a signal the modal also writes (`false` on
14
+ * a dismissal, `show()` / `hide()` set it). */
15
+ export type UIModalShow = (() => boolean) | Signal<boolean>;
12
16
  /**
13
17
  * A dialog: a `UIWidget` with the modal boilerplate built in. Comes with a scrim
14
- * (`overlayColor: "rgba(0, 0, 0, 0.5)"` unless overridden), animates on `show()`/`hide()` and on
15
- * a state block flipping its `display` (a 200 ms fade by default — swap the pose via
16
- * `transition()`; the runtime plays it as tracks that never touch the style), and closes itself
17
- * on a scrim tap or the Android back button (disable via `dismissible(false)`). Everything else
18
- * is a plain widget: declare it where it belongs — among its screen's children, hidden until a
19
- * tap (`display: "none"`), or shown with `show()` from anywhere, which puts a parentless modal in
20
- * the app layer. A dialog bound to data (its display from a binding) is declared
21
- * `dismissible(false)` and routes `onOverlayTap` / `onBack` into the data's dismiss, so the data
22
- * stays what the screen shows.
18
+ * (`overlayColor: "rgba(0, 0, 0, 0.5)"` unless overridden), is HIDDEN until shown, animates on
19
+ * every show / hide (a 200 ms fade by default — swap the pose via `transition()`; the runtime
20
+ * plays it as tracks that never touch the style).
21
+ *
22
+ * One state, shown or not, driven one of two ways:
23
+ * - `show()` / `hide()` from code — an action sheet opened by a button;
24
+ * - `bindShow(…)`: a function of the data (`bindShow(() => data.value.confirm)` — the data is the
25
+ * truth, `show()` / `hide()` are refused) or a `Signal<boolean>` the modal reads AND writes.
26
+ *
27
+ * A dismissal — the scrim tap, the back press, a sheet dragged below its lowest detent — is ONE
28
+ * request, `onDismiss`. By default it hides an unbound modal and writes `false` into a bound
29
+ * signal; a bound function has nowhere to write, so a modal bound to one without `onDismiss`
30
+ * cannot be dismissed (a forced choice — the same as `dismissible(false)`). `display` is not a
31
+ * modal's switch: a `.style({ display })` on it throws (a bound display died on the first
32
+ * dismissal, which wrote a static `display: "none"` over the binding — the dialog never opened
33
+ * again).
23
34
  */
24
35
  export interface UIModal extends UIWidget {
25
- /** Show and play the entrance transition. No-op while already open. */
36
+ /**
37
+ * Bind the shown state. A function: the modal follows the data, and `show()` / `hide()` are
38
+ * errors — flip the data (`onDismiss` is where a dismissal goes). A signal: read and written —
39
+ * a dismissal sets it `false`, `show()` / `hide()` set it.
40
+ *
41
+ * ```ts
42
+ * UIModal(...).bindShow(() => data.value.confirm).onDismiss(on.cancel) // the data is the truth
43
+ * UIModal(...).bindShow(confirmOpen) // a Signal<boolean>
44
+ * ```
45
+ */
46
+ bindShow(value: UIModalShow): this;
47
+ /** Show and play the entrance transition. No-op while already shown. Bound to a signal: writes
48
+ * `true` into it; bound to a function: an error (flip the data). */
26
49
  show(): void;
27
- /** Play the exit transition, then hide. No-op while closed or already closing. */
50
+ /** Play the exit transition, then hide. No-op while hidden. Bound: as `show()`. */
28
51
  hide(): void;
29
- /** True from `show()` until `hide()` starts (already false during the exit animation). */
30
- readonly isOpen: boolean;
31
52
  /**
32
53
  * Replace the show/hide animation. `hidden` is the off-screen pose — `show()` animates from
33
54
  * it, `hide()` animates to it. Default `{ opacity: 0, duration: 200 }` (a fade); the pose
@@ -39,13 +60,17 @@ export interface UIModal extends UIWidget {
39
60
  * ```
40
61
  */
41
62
  transition(hidden: UIModalTransition): this;
42
- /** Called when the modal opens — `show()`, or a state block flipping its display. */
63
+ /** The user asked to close: a scrim tap, the back press, a sheet dragged below its lowest
64
+ * detent. Replaces the default (hide, or `false` into the signal): the callback decides —
65
+ * usually the action that flips the data the modal is bound to. */
66
+ onDismiss(callback: () => void): this;
67
+ /** Called when the modal is shown — whoever showed it. */
43
68
  onOpen(callback: () => void): this;
44
- /** Called when the modal starts closing — scrim tap, back button, a `hide()` call, or a state
45
- * block flipping its display. */
69
+ /** Called when the modal starts hiding — whoever hid it. */
46
70
  onClose(callback: () => void): this;
47
- /** `dismissible(false)` keeps scrim taps and the back button from closing the modal
48
- * (forced-choice dialogs, a dialog whose display is bound to data). Default `true`. */
71
+ /** `dismissible(false)`: the dismissal gestures are off — the scrim tap does nothing, the back
72
+ * press is swallowed, a sheet resists below its lowest detent (a forced choice, the persistent
73
+ * map sheet). Default `true`. */
49
74
  dismissible(enabled: boolean): this;
50
75
  }
51
76
  export declare class ModalElement extends WidgetElement {
@@ -53,20 +78,23 @@ export declare class ModalElement extends WidgetElement {
53
78
  _transition: UIModalTransition;
54
79
  readonly _openListeners: (() => void)[];
55
80
  readonly _closeListeners: (() => void)[];
81
+ readonly _dismissListeners: (() => void)[];
56
82
  private _poseObj?;
57
83
  private _poseKey;
58
84
  constructor(style: UIModalStyle, children: UINodeChild[] | ChildrenFn);
59
85
  private _pose;
60
86
  transition(hidden: UIModalTransition): this;
87
+ bindShow(value: UIModalShow): this;
61
88
  show(): void;
62
89
  hide(): void;
63
- get isOpen(): boolean;
90
+ _setOpen(open: boolean): void;
91
+ onDismiss(callback: () => void): this;
64
92
  onOpen(callback: () => void): this;
65
93
  onClose(callback: () => void): this;
66
94
  dismissible(enabled: boolean): this;
67
95
  }
68
- /** Create a modal dialog (see {@link UIModal}): declare it among its screen's children with
69
- * `display: "none"` and `show()` it from a tap, or `show()` a parentless one from anywhere.
70
- * Same argument forms as `UIColumn`. */
96
+ /** Create a modal dialog (see {@link UIModal}): give it to its screen (`.widgets(dialog)`) and
97
+ * `show()` it from a tap, bind it to the data with `bindShow(() => …)`, or `show()` a parentless
98
+ * one from anywhere. Same argument forms as `UIColumn`. */
71
99
  export declare function UIModal(...children: UIChildArg[]): UIModal;
72
100
  export declare function UIModal(children: UINodeChild[] | ChildrenFn): UIModal;
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "2.5.1";
1
+ export declare const SDK_VERSION = "2.8.0";
2
2
  /** The major of a semver string, or null when it is not one. */
3
3
  export declare const sdkMajor: (version: string | null | undefined) => number | null;
4
4
  /** The `// sdk: <version>` line of a compiled bundle's header (sdk/src/compile/header.ts), read from