lecodes-sdk 2.0.4 → 2.0.6

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 (72) hide show
  1. package/README.md +104 -76
  2. package/dist/global.d.ts +2 -5
  3. package/dist/host.d.ts +3 -0
  4. package/dist/types/inject.d.ts +3 -3
  5. package/dist/types/runtime/device.d.ts +7 -0
  6. package/dist/types/runtime/rpc.d.ts +11 -17
  7. package/dist/types/runtime/wire.d.ts +53 -0
  8. package/dist/types/server/auth/api.d.ts +42 -0
  9. package/dist/types/server/auth/appConfig.d.ts +1 -5
  10. package/dist/types/server/auth/models.d.ts +119 -70
  11. package/dist/types/server/auth/types.d.ts +19 -43
  12. package/dist/types/server/channel.d.ts +57 -19
  13. package/dist/types/server/context.d.ts +2 -2
  14. package/dist/types/server/db/defineDb.d.ts +10 -0
  15. package/dist/types/server/db/index.d.ts +1 -1
  16. package/dist/types/server/db/types.d.ts +76 -6
  17. package/dist/types/server/inject.d.ts +0 -1
  18. package/dist/types/ui/UINode.d.ts +19 -5
  19. package/dist/types/ui/UIScreen.d.ts +1 -0
  20. package/dist/types/ui/UITabs.d.ts +8 -6
  21. package/dist/types/ui/theme.d.ts +48 -13
  22. package/dist/types/version.d.ts +1 -1
  23. package/dist/types.json +1 -1
  24. package/package.json +3 -2
  25. package/prompts/README.md +1 -1
  26. package/prompts/design.md +19 -19
  27. package/prompts/dist/2d-game.md +45 -31
  28. package/prompts/dist/3d-app.md +45 -31
  29. package/prompts/dist/ar-app.md +45 -31
  30. package/prompts/dist/design.md +25 -24
  31. package/prompts/dist/ui-app.md +45 -31
  32. package/prompts/ui-design.md +6 -5
  33. package/prompts/ui.md +25 -22
  34. package/src/bridges/device.d.ts +9 -0
  35. package/src/bridges/tree.d.ts +5 -0
  36. package/src/chisel.ts +1 -1
  37. package/src/compile/bundler.ts +6 -0
  38. package/src/compile/compileProject.ts +3 -1
  39. package/src/compile/index.ts +3 -1
  40. package/src/compile/serverSplit.ts +58 -11
  41. package/src/compile/serverTypes.ts +189 -8
  42. package/src/host.d.ts +3 -0
  43. package/src/inject.ts +6 -6
  44. package/src/runtime/device.ts +12 -0
  45. package/src/runtime/rpc.ts +101 -40
  46. package/src/runtime/wire.ts +35 -0
  47. package/src/server/auth/api.ts +94 -0
  48. package/src/server/auth/appConfig.ts +2 -3
  49. package/src/server/auth/host.ts +244 -174
  50. package/src/server/auth/models.ts +45 -62
  51. package/src/server/auth/types.ts +19 -34
  52. package/src/server/channel.ts +97 -29
  53. package/src/server/channelHub.ts +153 -0
  54. package/src/server/context.ts +2 -2
  55. package/src/server/db/defineDb.ts +96 -36
  56. package/src/server/db/index.ts +1 -1
  57. package/src/server/db/types.ts +76 -8
  58. package/src/server/host.ts +25 -10
  59. package/src/server/inject.ts +2 -2
  60. package/src/server/runtime.ts +34 -12
  61. package/src/ui/UINode.ts +22 -5
  62. package/src/ui/UIScreen.ts +5 -0
  63. package/src/ui/UITabs.ts +19 -17
  64. package/src/ui/styleColor.ts +10 -1
  65. package/src/ui/theme.ts +96 -41
  66. package/src/version.ts +1 -1
  67. package/tests/helpers/fakeTree.ts +1 -0
  68. package/dist/types/plugins/oauth.d.ts +0 -25
  69. package/dist/types/server/auth/global.d.ts +0 -56
  70. package/src/plugins/oauth.ts +0 -61
  71. package/src/server/auth/global.ts +0 -80
  72. package/tests/helpers/memoryMarci.ts +0 -124
@@ -1,7 +1,9 @@
1
1
  import type { FetchResponse } from "../runtime/fetch";
2
+ import type { SvgSourceValue } from "../runtime/misc";
2
3
  import type { ColorInput } from "../core/color";
3
4
  import type { Animation } from "../animate/tween/Animation";
4
5
  import { type TweenMeta } from "../animate/tween/spec";
6
+ import { type ThemeRoles } from "./theme";
5
7
  import { type TreeElement } from "./tree";
6
8
  export interface UINode {
7
9
  readonly type: string;
@@ -18,7 +20,7 @@ export type UINodeChild = UINode | null | undefined | false;
18
20
  * needs no spread. */
19
21
  export type UIChildArg = UINodeChild | UINodeChild[];
20
22
  /** A color: any CSS color string (`"#1c1c1e"`, `"rgba(0,0,0,0.5)"`, `"green"`, `"hsl(210 50% 40%)"`),
21
- * a theme reference (`"var(--primaryColor)"`), an opaque `0xRRGGBB` number or `[r, g, b(, a)]` in
23
+ * a theme reference (`"var(--accent)"`), an opaque `0xRRGGBB` number or `[r, g, b(, a)]` in
22
24
  * 0..1; `null` clears. A string is the core's to parse (an unknown one is transparent, as in
23
25
  * CSS); a number or an array that is not a color throws at the write. */
24
26
  export type Color = ColorInput | null;
@@ -37,12 +39,13 @@ export type BaseStyle = {
37
39
  };
38
40
  /** Painted-box props: background, gradient, border, radius. */
39
41
  export type DrawableStyle = {
40
- backgroundImage?: FetchResponse | File | string | null;
42
+ backgroundImage?: FetchResponse | File | SvgSourceValue | string | null;
41
43
  bgGradient?: string;
42
44
  backgroundGradient?: string;
43
- bgImage?: FetchResponse | File | string | null;
44
- backgroundSize?: "cover" | "contain" | "tile";
45
- bgSize?: "cover" | "contain" | "tile";
45
+ bgImage?: FetchResponse | File | SvgSourceValue | string | null;
46
+ /** How the image fills the box. "tile": repeated at its own size from the top-left corner. */
47
+ backgroundSize?: "cover" | "contain" | "fill" | "tile";
48
+ bgSize?: "cover" | "contain" | "fill" | "tile";
46
49
  border?: string | number | null;
47
50
  borderWidth?: number;
48
51
  borderColor?: Color;
@@ -223,6 +226,16 @@ export interface UIElementBase<S extends object, A extends object = S> {
223
226
  name?: string;
224
227
  /** Set the semantic name (chainable). */
225
228
  named(name: string): this;
229
+ /** Theme variables for THIS element's subtree (chainable): the same keys as the app-wide
230
+ * `theme()`, read by everything under the element — and by the kit components there — before
231
+ * the app's table. `null` takes a key out of the scope. Reaches the element's descendants in
232
+ * the tree (a pager's pages and a list's items included); a screen pushed over it and a widget
233
+ * are roots of their own. Re-calling restyles the live subtree.
234
+ * ```ts
235
+ * promo.theme({ accent: "#FF3B30" }) // one card in another accent
236
+ * sheet.theme({ bg: "#000", text: "#FFF" }) // a dark screen in a light app
237
+ * ``` */
238
+ theme(values: ThemeRoles & Record<string, string | number | null>): this;
226
239
  /** Tween to the target style — meta keys `duration`/`delay`/`loop`/…, see {@link AnimateStyle}. */
227
240
  animateTo: AnimateStyle<this, A>;
228
241
  /** Tween from the given style to the current one (entrance animations). */
@@ -305,6 +318,7 @@ export declare class Element<T extends string> implements TreeElement {
305
318
  get name(): string | undefined;
306
319
  set name(value: string | undefined);
307
320
  named(name: string): this;
321
+ theme(values: Record<string, string | number | null>): this;
308
322
  get style(): any;
309
323
  /** Tween to the target style and commit it (unless `commit: false` or looping — a loop is an
310
324
  * effect, not a state change). A prop value may be an array of keyframes; meta keys
@@ -48,6 +48,7 @@ export interface UIScreen extends UIContainerBase<UIScreenStyle, DrawableStyle &
48
48
  onTouchStart(callback: (ev: TouchStartEvent<UIScreen>) => void): this;
49
49
  }
50
50
  export declare class ScreenElement extends ContainerElement<"screen"> {
51
+ constructor(type: "screen", style: any, children: any);
51
52
  open(options?: PresentOptions): void;
52
53
  close(options?: DismissOptions): void;
53
54
  protected ol: (() => void)[];
@@ -23,8 +23,9 @@ export type UITabDef = {
23
23
  * ```
24
24
  *
25
25
  * In-tab navigation stays the pager's: `UIPager.push(detail)` from any screen (bar stays);
26
- * `Router.push` opens above the shell (bar covered). Restyle via `theme()` (primaryColor,
27
- * mutedColor, tabbarBg, …) or the `bar` handle; for a fully custom bar build on `UIPager`.
26
+ * `Router.push` opens above the shell (bar covered). The bar is colored by the theme's roles
27
+ * (`accent`, `textMuted`, `surface`, `border`); `tabs.bar.theme({...})` overrides them for this
28
+ * bar alone, the `bar` handle restyles its box; for a fully custom bar build on `UIPager`.
28
29
  */
29
30
  export interface UITabs extends UIScreen {
30
31
  /** The active tab id. */
@@ -37,7 +38,8 @@ export interface UITabs extends UIScreen {
37
38
  badge(id: string, value: number | string | boolean | null): this;
38
39
  /** The pager under the bar — in-tab stacks (`push`/`pop`/`depth`). */
39
40
  readonly pager: UIPager;
40
- /** The bar row (named "tabbar") — for restyling beyond the theme variables. */
41
+ /** The bar row (named "tabbar") — `bar.theme({ accent, textMuted, surface, border })` for this
42
+ * bar's own colors, `bar.style({...})` for its box. */
41
43
  readonly bar: UIRowType;
42
44
  }
43
45
  export declare class TabsElement extends ScreenElement {
@@ -89,8 +91,8 @@ export type TabsHandle<T extends Record<string, TabDef>> = {
89
91
  * export default () => mainTabs.screen("home", [ ...content ])
90
92
  * ```
91
93
  *
92
- * Restyle through the theme — `theme({ primaryColor, mutedColor, tabbarBg, screenBg })` recolors
93
- * every bar at once. The built app passes the same keys (plus each tab's root screen) to `UITabs`,
94
- * which renders the identical bar interactively.
94
+ * The bar reads the theme's roles (`accent`, `textMuted`, `surface`, `border`), the screen its
95
+ * `bg` — one `theme({...})` colors every bar at once. The built app passes the same keys (plus
96
+ * each tab's root screen) to `UITabs`, which renders the identical bar interactively.
95
97
  */
96
98
  export declare function defineTabs<T extends Record<string, TabDef>>(tabs: T): TabsHandle<T>;
@@ -1,21 +1,56 @@
1
1
  import type { Transition } from "./presentable";
2
2
  export type ThemeValues = Record<string, string | number | null>;
3
+ /** The keys the SDK itself reads — the ROLES of a theme. An app's own keys sit beside them in the
4
+ * same call; kit components (`UITabs`) and the defaults of screens and text read these and nothing
5
+ * else, so one palette colors the app and the kit alike. A color is a string, never a number. */
6
+ export type ThemeRoles = {
7
+ /** The background of every screen. */
8
+ bg?: string | null;
9
+ /** A raised surface — cards, bars, sheets. The tab bar's background (without it: `bg`). */
10
+ surface?: string | null;
11
+ /** Hairlines and outlines. The tab bar's top line. */
12
+ border?: string | null;
13
+ /** Text that names no `color` of its own. */
14
+ text?: string | null;
15
+ /** Secondary text and inactive controls. The tab bar's inactive tabs. */
16
+ textMuted?: string | null;
17
+ /** The brand / active color. The tab bar's active tab. */
18
+ accent?: string | null;
19
+ /** The font of text that names no `fontFamily` of its own. */
20
+ fontFamily?: string | null;
21
+ };
22
+ /** What only the app-wide `theme()` takes: the comfort knobs (logical px) and the Router's default
23
+ * `replace` transition. */
24
+ export type ThemeAppKeys = {
25
+ "comfort-top"?: number | string | null;
26
+ "comfort-bottom"?: number | string | null;
27
+ "comfort-left"?: number | string | null;
28
+ "comfort-right"?: number | string | null;
29
+ replaceTransition?: Transition | null;
30
+ };
31
+ /** The `var(--key)` strings of the keys a `theme()` call defined — plain strings, so a helper's
32
+ * `(color = colors.accent)` parameter takes any color. */
3
33
  export type ThemeAccessors<T> = {
4
- readonly [K in keyof T]: K extends string ? `var(--${K})` : never;
34
+ readonly [K in Exclude<keyof T, "replaceTransition">]: string;
5
35
  };
6
36
  /** App theme: callable to merge variables (`theme({...})` — re-calling re-styles the live UI, so
7
- * dark mode is just a second call), with the system vars as static properties
8
- * (`theme.primaryColor`, `theme["comfort-top"]`, …). */
9
- export declare const theme: (<T extends Record<string, string | number | Transition | null>>(values: T & { [K in Exclude<keyof T, "replaceTransition">]: string | number | null; }) => ThemeAccessors<Omit<T, "replaceTransition">>) & {
10
- /** The app accent color. Kit components will read it via `var(--primaryColor, <fallback>)`. */
11
- readonly primaryColor: "var(--primaryColor)";
12
- /** Secondary / inactive content color for kit components. */
13
- readonly mutedColor: "var(--mutedColor)";
14
- /** DEFAULT text color — text without an explicit `color` follows it (hosts source their
15
- * default from the theme; unset = the host default, white on dark screens). Set it once for
16
- * a light theme instead of `color: "black"` on every label. */
17
- readonly color: "var(--color)";
18
- /** DEFAULT text font — text without an explicit `fontFamily` follows it. */
37
+ * dark mode is just a second call), with the roles as static properties (`theme.accent`,
38
+ * `theme["comfort-top"]`, …) for code that has no tokens module to import. */
39
+ export declare const theme: (<T extends ThemeRoles & ThemeAppKeys & Record<string, string | number | Transition | null>>(values: T & { [K in Exclude<keyof T, "replaceTransition">]: string | number | null; }) => ThemeAccessors<T>) & {
40
+ /** The background of every screen. */
41
+ readonly bg: "var(--bg)";
42
+ /** A raised surface — cards, bars, sheets. */
43
+ readonly surface: "var(--surface)";
44
+ /** Hairlines and outlines. */
45
+ readonly border: "var(--border)";
46
+ /** DEFAULT text color — text without a `color` of its own follows it (unset = the host's
47
+ * default: white). Set it once for a light theme instead of a color on every label. */
48
+ readonly text: "var(--text)";
49
+ /** Secondary text and inactive controls. */
50
+ readonly textMuted: "var(--textMuted)";
51
+ /** The brand / active color. */
52
+ readonly accent: "var(--accent)";
53
+ /** DEFAULT text font — text without a `fontFamily` of its own follows it. */
19
54
  readonly fontFamily: "var(--fontFamily)";
20
55
  /** Raw comfort knobs (logical px). The bare `comfort-top` style TOKEN applies the safe-area
21
56
  * formula — these accessors read the knob value itself, for manual composition. */
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "2.0.4";
1
+ export declare const SDK_VERSION = "2.0.6";
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