@elaraai/e3-cloud-ui 0.0.0-stage → 1.0.90

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 (63) hide show
  1. package/LICENSE.md +54 -0
  2. package/README.md +256 -2
  3. package/dist/src/authoring/app.d.ts +84 -0
  4. package/dist/src/authoring/app.d.ts.map +1 -0
  5. package/dist/src/authoring/app.js +38 -0
  6. package/dist/src/authoring/app.js.map +1 -0
  7. package/dist/src/authoring/link.d.ts +206 -0
  8. package/dist/src/authoring/link.d.ts.map +1 -0
  9. package/dist/src/authoring/link.js +114 -0
  10. package/dist/src/authoring/link.js.map +1 -0
  11. package/dist/src/authoring/page.d.ts +115 -0
  12. package/dist/src/authoring/page.d.ts.map +1 -0
  13. package/dist/src/authoring/page.js +113 -0
  14. package/dist/src/authoring/page.js.map +1 -0
  15. package/dist/src/browser.d.ts +19 -0
  16. package/dist/src/browser.d.ts.map +1 -0
  17. package/dist/src/browser.js +19 -0
  18. package/dist/src/browser.js.map +1 -0
  19. package/dist/src/build.d.ts +67 -0
  20. package/dist/src/build.d.ts.map +1 -0
  21. package/dist/src/build.js +228 -0
  22. package/dist/src/build.js.map +1 -0
  23. package/dist/src/check/check.d.ts +46 -0
  24. package/dist/src/check/check.d.ts.map +1 -0
  25. package/dist/src/check/check.js +342 -0
  26. package/dist/src/check/check.js.map +1 -0
  27. package/dist/src/check/index.d.ts +19 -0
  28. package/dist/src/check/index.d.ts.map +1 -0
  29. package/dist/src/check/index.js +19 -0
  30. package/dist/src/check/index.js.map +1 -0
  31. package/dist/src/check/package-view.d.ts +85 -0
  32. package/dist/src/check/package-view.d.ts.map +1 -0
  33. package/dist/src/check/package-view.js +87 -0
  34. package/dist/src/check/package-view.js.map +1 -0
  35. package/dist/src/check/scan.d.ts +99 -0
  36. package/dist/src/check/scan.d.ts.map +1 -0
  37. package/dist/src/check/scan.js +223 -0
  38. package/dist/src/check/scan.js.map +1 -0
  39. package/dist/src/check/types-equal.d.ts +31 -0
  40. package/dist/src/check/types-equal.d.ts.map +1 -0
  41. package/dist/src/check/types-equal.js +35 -0
  42. package/dist/src/check/types-equal.js.map +1 -0
  43. package/dist/src/index.d.ts +28 -0
  44. package/dist/src/index.d.ts.map +1 -0
  45. package/dist/src/index.js +28 -0
  46. package/dist/src/index.js.map +1 -0
  47. package/dist/src/runtime.d.ts +7 -0
  48. package/dist/src/runtime.d.ts.map +1 -0
  49. package/dist/src/runtime.js +7 -0
  50. package/dist/src/runtime.js.map +1 -0
  51. package/dist/src/types.d.ts +7169 -0
  52. package/dist/src/types.d.ts.map +1 -0
  53. package/dist/src/types.js +156 -0
  54. package/dist/src/types.js.map +1 -0
  55. package/dist/test/acme.examples.d.ts +99 -0
  56. package/dist/test/acme.examples.d.ts.map +1 -0
  57. package/dist/test/acme.examples.js +100 -0
  58. package/dist/test/acme.examples.js.map +1 -0
  59. package/dist/test/pages.examples.d.ts +33 -0
  60. package/dist/test/pages.examples.d.ts.map +1 -0
  61. package/dist/test/pages.examples.js +127 -0
  62. package/dist/test/pages.examples.js.map +1 -0
  63. package/package.json +71 -3
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `PageLink` and `Nav`: moving between an app's pages.
7
+ *
8
+ * `<PageLink to={page} params={…}>text</PageLink>` is a link within the app,
9
+ * drawn as east-ui's `Link` is. It is an extension component whose payload is
10
+ * an East value: the target's name and its params as a beast2 value of the
11
+ * target's params type. `Nav.go(page, params)` and `Nav.back()` are platform
12
+ * functions for event handlers. The web app implements all three: a link and
13
+ * `Nav.go` push the page's URL, and `Nav.back` is the browser's Back.
14
+ * TypeScript holds a link's params to its target's type.
15
+ *
16
+ * @packageDocumentation
17
+ */
18
+ import { BlobType, East, NullType, OptionType, StringType, StructType, none, some, variant, } from '@elaraai/east';
19
+ import { EastUI, Link } from '@elaraai/east-ui';
20
+ import { PAGE_BACK, PAGE_GO, PAGE_LINK_KIND } from '../types.js';
21
+ import { inSignaturePass } from './page.js';
22
+ /** The style a page link takes: east-ui `Link`'s. */
23
+ const LinkStyleType = Link.Types.Style;
24
+ /**
25
+ * A page link's payload: the target page, its params as a beast2 value of the
26
+ * target's params type, the link's text and east-ui `Link`'s style.
27
+ */
28
+ export const PageLinkType = StructType({
29
+ to: StringType,
30
+ params: OptionType(BlobType),
31
+ value: StringType,
32
+ style: OptionType(LinkStyleType),
33
+ });
34
+ /** The page link component, which a host implements (`implementUIComponent`). */
35
+ export const PageLinkComponent = EastUI.component(PAGE_LINK_KIND, PageLinkType, { optional: true });
36
+ /** A link style with every field absent but those given. */
37
+ function linkStyle(variantName, colorPalette) {
38
+ if (variantName === undefined && colorPalette === undefined)
39
+ return none;
40
+ const fields = {};
41
+ for (const field of Object.keys(LinkStyleType.fields))
42
+ fields[field] = none;
43
+ fields.variant = variantName === undefined ? none : some(variant(variantName, null));
44
+ fields.colorPalette = colorPalette === undefined ? none : some(colorPalette);
45
+ return some(fields);
46
+ }
47
+ /**
48
+ * A link to a page of the app, drawn as east-ui's `Link`.
49
+ *
50
+ * @param props - The target page, its params when it takes any, the text and the style
51
+ * @returns The link
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * {ls.read().map(($, key) => (
56
+ * <PageLink to={line} params={key}>{East.str`${key.site} · ${key.line}`}</PageLink>
57
+ * ))}
58
+ * ```
59
+ */
60
+ export function PageLink(props) {
61
+ const { to, children, params } = props;
62
+ // A signature pass builds a page's body for its params type alone: the
63
+ // target's type isn't asked for, so pages that link to each other resolve
64
+ const target = inSignaturePass() ? null : to.params;
65
+ const encoded = target === null
66
+ ? none
67
+ : some(East.Blob.encodeBeast(East.value(params, target), 'v2'));
68
+ return PageLinkComponent.Root({
69
+ to: to.name,
70
+ params: encoded,
71
+ value: children,
72
+ style: linkStyle(props.variant, props.colorPalette),
73
+ });
74
+ }
75
+ /** `Nav.go`'s platform function: `[P](page: String, params: P) -> Null`. */
76
+ const pageGo = East.genericPlatform(PAGE_GO, ['P'], [StringType, 'P'], NullType, { optional: true });
77
+ /** `Nav.back`'s platform function: `() -> Null`. */
78
+ const pageBack = East.platform(PAGE_BACK, [], NullType, { optional: true });
79
+ /**
80
+ * Moving between an app's pages from an event handler.
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * <Button onClick={East.function([], NullType, $ => { $(Nav.go(line, key)); })}>Open</Button>
85
+ * <Button onClick={East.function([], NullType, $ => { $(Nav.back()); })}>Back</Button>
86
+ * ```
87
+ */
88
+ export const Nav = {
89
+ /**
90
+ * Opens a page of the app, pushing its URL.
91
+ *
92
+ * @param page - The page
93
+ * @param params - Its params, when it takes any
94
+ * @returns Null
95
+ */
96
+ go(page, ...params) {
97
+ // In a signature pass the target's type isn't asked for (see PageLink)
98
+ const target = inSignaturePass() ? null : page.params;
99
+ const type = (target ?? NullType);
100
+ const value = target === null ? null : params[0];
101
+ return pageGo([type], page.name, value);
102
+ },
103
+ /**
104
+ * Goes back to the page before, as the browser's Back does.
105
+ *
106
+ * @returns Null
107
+ */
108
+ back() {
109
+ return pageBack();
110
+ },
111
+ /** The platform functions a host implements: `go` and `back`. */
112
+ platform: { go: pageGo, back: pageBack },
113
+ };
114
+ //# sourceMappingURL=link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/authoring/link.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,GAElF,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAmB,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,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GAAG,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACjD,OAAQ,MAA6F,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClI,CAAC;IACD;;;;OAIG;IACH,IAAI;QACF,OAAO,QAAQ,EAAE,CAAC;IACpB,CAAC;IACD,iEAAiE;IACjE,QAAQ,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;CAChC,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `Page`: a page of an app.
7
+ *
8
+ * A page is a `ui()` body: an `East.function` returning exactly
9
+ * `UIComponentType`, which runs in the browser when the page opens. Its one
10
+ * argument, if any, is the page's params, where a `ui()` task has its
11
+ * compute-time inputs; TypeScript takes their type from the function, so an
12
+ * author never writes a type. `Page.task` shows a `ui()` task's output, which
13
+ * the dataflow computes.
14
+ *
15
+ * The body is given as a thunk, `() => East.function(…)`, and built when the
16
+ * app builds: East builds a function's body as the function is made, so a
17
+ * body made at once could link only to pages defined above it, and pages link
18
+ * both ways (a page down to its detail, the detail back up). A page's params
19
+ * type comes from a signature pass of its thunk, in which links don't ask for
20
+ * their targets' types, so two pages that link to each other resolve.
21
+ *
22
+ * @packageDocumentation
23
+ */
24
+ import { type CallableFunctionExpr, type EastType } from '@elaraai/east';
25
+ import { UIComponentType, type IconName } from '@elaraai/east-ui';
26
+ import type { TaskDef } from '@elaraai/e3/browser';
27
+ /** What a page shows besides its body. */
28
+ export interface PageMeta {
29
+ /** The bar's title, the sidebar's label and the crumb */
30
+ title: string;
31
+ /** Its icon in the sidebar: a Font Awesome solid icon's name */
32
+ icon?: IconName;
33
+ /** The page above it: the crumbs, and the sidebar's active item */
34
+ parent?: PageDef<string, any>;
35
+ }
36
+ /** A page's body, built when it is first asked for. */
37
+ export interface PageDefEastBody {
38
+ readonly kind: 'east';
39
+ /** The body's function, built once */
40
+ build(): CallableFunctionExpr<any, UIComponentType>;
41
+ }
42
+ /** What a page renders: a body, or a `ui()` task's output. */
43
+ export type PageDefBody = PageDefEastBody | {
44
+ readonly kind: 'task';
45
+ readonly task: TaskDef<UIComponentType>;
46
+ };
47
+ /**
48
+ * A page of an app, as `Page` and `Page.task` define it.
49
+ *
50
+ * @typeParam Name - The page's name
51
+ * @typeParam P - Its params' East type, or `null` when it takes none
52
+ */
53
+ export interface PageDef<Name extends string = string, P extends EastType | null = EastType | null> {
54
+ readonly kind: 'page';
55
+ readonly name: Name;
56
+ readonly title: string;
57
+ readonly icon: IconName | undefined;
58
+ readonly parent: PageDef<string, any> | undefined;
59
+ /** Its params' type, or null: read from its body's function, which a signature pass builds */
60
+ readonly params: P;
61
+ readonly body: PageDefBody;
62
+ }
63
+ /** A page that takes no params: what a menu and an app's home hold. */
64
+ export type PlainPageDef = PageDef<string, null>;
65
+ /**
66
+ * Whether a page's body is being built only for its signature: then
67
+ * `PageLink` and `Nav.go` build their calls without their targets' params
68
+ * types, which the signature never holds.
69
+ *
70
+ * @returns true inside a signature pass
71
+ */
72
+ export declare function inSignaturePass(): boolean;
73
+ /**
74
+ * Defines a page whose body takes no params.
75
+ *
76
+ * @param name - Its URL segment, unique in its app (e3's name rules)
77
+ * @param meta - Its title, icon and parent
78
+ * @param body - Builds its body: an East function of no arguments returning
79
+ * `UIComponentType`, built when the app builds
80
+ * @returns The page
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * const overview = Page('overview', { title: 'Overview', icon: 'gauge-high' },
85
+ * () => East.function([], UIComponentType, _$ => (
86
+ * <Reactive>{$ => {
87
+ * const f = $.let(Data.bind(forecast));
88
+ * return <Stat label="Lines forecast" value={East.print(f.read().size())} />;
89
+ * }}</Reactive>
90
+ * )));
91
+ * ```
92
+ */
93
+ export declare function Page<const Name extends string>(name: Name, meta: PageMeta, body: () => CallableFunctionExpr<[], UIComponentType>): PageDef<Name, null>;
94
+ /**
95
+ * Defines a page whose body takes params: its one argument.
96
+ *
97
+ * @param name - Its URL segment, unique in its app (e3's name rules)
98
+ * @param meta - Its title, icon and parent
99
+ * @param body - Builds its body: an East function of one argument returning
100
+ * `UIComponentType` (a struct for several params), built when the app builds
101
+ * @returns The page
102
+ *
103
+ * @example
104
+ * ```tsx
105
+ * const line = Page('line', { title: 'Line', parent: lines },
106
+ * () => East.function([LineKey], UIComponentType, (_$, key) => (
107
+ * <Text>{East.str`${key.site} · ${key.line}`}</Text>
108
+ * )));
109
+ * ```
110
+ */
111
+ export declare function Page<const Name extends string, P extends EastType>(name: Name, meta: PageMeta, body: () => CallableFunctionExpr<[P], UIComponentType>): PageDef<Name, P>;
112
+ export declare namespace Page {
113
+ var task: <const Name extends string>(name: Name, task: TaskDef<UIComponentType>, meta: PageMeta) => PageDef<Name, null>;
114
+ }
115
+ //# sourceMappingURL=page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/authoring/page.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEL,KAAK,oBAAoB,EAAE,KAAK,QAAQ,EACzC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IACvB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,mEAAmE;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,uDAAuD;AACvD,MAAM,W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;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,IAAI,CAAC,KAAK,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,SAAS,QAAQ,EAChE,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,QAAQ,EACd,IAAI,EAAE,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAC,EAAE,eAAe,CAAC,GACrD,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;yBAJJ,IAAI;qBAmDY,IAAI,SAAS,MAAM,QAC3C,IAAI,QACJ,OAAO,CAAC,eAAe,CAAC,QACxB,QAAQ,KACb,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `Page`: a page of an app.
7
+ *
8
+ * A page is a `ui()` body: an `East.function` returning exactly
9
+ * `UIComponentType`, which runs in the browser when the page opens. Its one
10
+ * argument, if any, is the page's params, where a `ui()` task has its
11
+ * compute-time inputs; TypeScript takes their type from the function, so an
12
+ * author never writes a type. `Page.task` shows a `ui()` task's output, which
13
+ * the dataflow computes.
14
+ *
15
+ * The body is given as a thunk, `() => East.function(…)`, and built when the
16
+ * app builds: East builds a function's body as the function is made, so a
17
+ * body made at once could link only to pages defined above it, and pages link
18
+ * both ways (a page down to its detail, the detail back up). A page's params
19
+ * type comes from a signature pass of its thunk, in which links don't ask for
20
+ * their targets' types, so two pages that link to each other resolve.
21
+ *
22
+ * @packageDocumentation
23
+ */
24
+ import { Expr, isTypeEqual, printTypeSummary, } from '@elaraai/east';
25
+ import { UIComponentType } from '@elaraai/east-ui';
26
+ /** The depth of signature passes under way: inside one, links don't ask for their targets' types. */
27
+ let signaturePasses = 0;
28
+ /**
29
+ * Whether a page's body is being built only for its signature: then
30
+ * `PageLink` and `Nav.go` build their calls without their targets' params
31
+ * types, which the signature never holds.
32
+ *
33
+ * @returns true inside a signature pass
34
+ */
35
+ export function inSignaturePass() {
36
+ return signaturePasses > 0;
37
+ }
38
+ /**
39
+ * A page body's function, checked: it returns `UIComponentType`, and takes no
40
+ * argument or one.
41
+ */
42
+ function checked(name, fn) {
43
+ const { inputs, output } = Expr.type(fn);
44
+ if (!isTypeEqual(output, UIComponentType)) {
45
+ throw new Error(`Page '${name}': its function returns ${printTypeSummary(output)}, not UIComponentType — a page's function returns UIComponentType`);
46
+ }
47
+ if (inputs.length > 1) {
48
+ throw new Error(`Page '${name}': its function takes ${inputs.length} arguments — a page takes one, its params (a struct for several), or none`);
49
+ }
50
+ return { fn, params: inputs[0] ?? null };
51
+ }
52
+ export function Page(name, meta, body) {
53
+ let built;
54
+ let signature;
55
+ return {
56
+ kind: 'page',
57
+ name,
58
+ title: meta.title,
59
+ icon: meta.icon,
60
+ parent: meta.parent,
61
+ get params() {
62
+ if (built !== undefined)
63
+ return built.params;
64
+ if (signature === undefined) {
65
+ signaturePasses++;
66
+ try {
67
+ signature = checked(name, body()).params;
68
+ }
69
+ finally {
70
+ signaturePasses--;
71
+ }
72
+ }
73
+ return signature;
74
+ },
75
+ body: {
76
+ kind: 'east',
77
+ build: () => {
78
+ built ??= checked(name, body());
79
+ return built.fn;
80
+ },
81
+ },
82
+ };
83
+ }
84
+ /**
85
+ * Defines a page that shows a `ui()` task's output: a UI the dataflow
86
+ * computes, the same for every viewer. It takes no params.
87
+ *
88
+ * @param name - Its URL segment, unique in its app (e3's name rules)
89
+ * @param task - The `ui()` task, by its def
90
+ * @param meta - Its title, icon and parent
91
+ * @returns The page
92
+ * @throws {Error} When the task's role isn't `ui`
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * const board = Page.task('board', boardTask, { title: 'Board', icon: 'table-columns' });
97
+ * ```
98
+ */
99
+ Page.task = function task(name, task, meta) {
100
+ if (task.kind !== 'task' || task.role.type !== 'ui') {
101
+ throw new Error(`Page.task '${name}': ${task.kind === 'task' ? `task '${task.name}' isn't a UI task` : 'it takes a task'} — Page.task shows a ui() task's output`);
102
+ }
103
+ return {
104
+ kind: 'page',
105
+ name,
106
+ title: meta.title,
107
+ icon: meta.icon,
108
+ parent: meta.parent,
109
+ params: null,
110
+ body: { kind: 'task', task },
111
+ };
112
+ };
113
+ //# sourceMappingURL=page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.js","sourceRoot":"","sources":["../../../src/authoring/page.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,IAAI,EAAE,WAAW,EAAE,gBAAgB,GAEpC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAiB,MAAM,kBAAkB,CAAC;AA6ClE,qGAAqG;AACrG,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,eAAe,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,SAAS,OAAO,CAAC,IAAY,EAAE,EAA8C;IAC3E,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,EAA0B,CAAwD,CAAC;IACxH,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,2BAA2B,gBAAgB,CAAC,MAAM,CAAC,mEAAmE,CAAC,CAAC;IACvJ,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,yBAAyB,MAAM,CAAC,MAAM,2EAA2E,CAAC,CAAC;IAClJ,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;AAC3C,CAAC;AAiDD,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,IAAc,EAAE,I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,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;KAC7B,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `@elaraai/e3-cloud-ui/browser`: authoring an app, browser-safe.
7
+ *
8
+ * Everything the main entry has but the build, which runs e3's export
9
+ * through a file: `App`, `Page`, `Menu`, `PageLink` and `Nav`, and the East
10
+ * types. A host that draws apps (the e3-cloud web app) imports `PageLink` and
11
+ * `Nav` from here to implement them.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ export * from './types.js';
16
+ export { Page, inSignaturePass, type PageDef, type PageMeta, type PageDefBody, type PageDefEastBody, type PlainPageDef } from './authoring/page.js';
17
+ export { App, Menu, type AppConfig, type AppDef, type MenuGroupDef } from './authoring/app.js';
18
+ export { PageLink, PageLinkComponent, PageLinkType, Nav, type PageLinkProps } from './authoring/link.js';
19
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACpJ,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `@elaraai/e3-cloud-ui/browser`: authoring an app, browser-safe.
7
+ *
8
+ * Everything the main entry has but the build, which runs e3's export
9
+ * through a file: `App`, `Page`, `Menu`, `PageLink` and `Nav`, and the East
10
+ * types. A host that draws apps (the e3-cloud web app) imports `PageLink` and
11
+ * `Nav` from here to implement them.
12
+ *
13
+ * @packageDocumentation
14
+ */
15
+ export * from './types.js';
16
+ export { Page, inSignaturePass } from './authoring/page.js';
17
+ export { App, Menu } from './authoring/app.js';
18
+ export { PageLink, PageLinkComponent, PageLinkType, Nav } from './authoring/link.js';
19
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,eAAe,EAA0F,MAAM,qBAAqB,CAAC;AACpJ,OAAO,EAAE,GAAG,EAAE,IAAI,EAAkD,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,YAAY,EAAE,GAAG,EAAsB,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import { export as exportPackage } from '@elaraai/e3';
6
+ import { type AppProblem } from '@elaraai/e3-cloud-types';
7
+ import { type App, type AppBundle } from './types.js';
8
+ import { type PackageView } from './check/package-view.js';
9
+ import type { AppDef } from './authoring/app.js';
10
+ /** An app the build refuses, with every problem. */
11
+ export declare class AppBuildError extends Error {
12
+ /** Why the app doesn't build */
13
+ readonly problems: readonly AppProblem[];
14
+ constructor(app: string, pkg: string, problems: readonly AppProblem[]);
15
+ }
16
+ /** Options for {@link buildApp}: the package's export's, as `e3.export` takes them (its function manifests). */
17
+ export type BuildAppOptions = NonNullable<Parameters<typeof exportPackage>[2]>;
18
+ /**
19
+ * Builds an app into its bundle: the app, and its package as `e3.export`
20
+ * writes it.
21
+ *
22
+ * @param app - The app
23
+ * @param options - Function manifests for the package's export
24
+ * @returns The bundle
25
+ * @throws {AppBuildError} When the app doesn't fit its own package, or isn't a
26
+ * well-formed app, naming every problem
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import ops from './src/apps/ops.js';
31
+ * const bundle = await buildApp(ops);
32
+ * ```
33
+ */
34
+ export declare function buildApp(app: AppDef, options?: BuildAppOptions): Promise<AppBundle>;
35
+ /**
36
+ * Builds an app and writes its bundle to a file, as beast2.
37
+ *
38
+ * @param app - The app
39
+ * @param path - Where to write the bundle
40
+ * @param options - Function manifests for the package's export
41
+ * @returns The bundle
42
+ * @throws {AppBuildError} When the app doesn't build
43
+ */
44
+ export declare function exportApp(app: AppDef, path: string, options?: BuildAppOptions): Promise<AppBundle>;
45
+ /**
46
+ * Reads a bundle `exportApp` wrote.
47
+ *
48
+ * @param bytes - The bundle's bytes
49
+ * @returns The bundle
50
+ */
51
+ export declare function decodeAppBundle(bytes: Uint8Array): AppBundle;
52
+ /**
53
+ * What the checks need of a bundle's package, read from its zip: what the
54
+ * build checks the app against.
55
+ *
56
+ * @param bundle - The bundle
57
+ * @returns Its package's view
58
+ */
59
+ export declare function bundlePackageView(bundle: AppBundle): Promise<PackageView>;
60
+ /**
61
+ * An app as the object an app deploy uploads: the bundle without its package.
62
+ *
63
+ * @param app - The app
64
+ * @returns Its beast2 bytes
65
+ */
66
+ export declare function encodeAppObject(app: App): Uint8Array;
67
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@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