apps 0.0.1-beta.79 → 0.0.1-beta.80

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.
@@ -1,5 +1,5 @@
1
1
  /** Browser-to-host operations bind identity and authentication outside authored app code. */
2
- import { Schema } from "effect";
2
+ import { Schema, type Effect, type Stream } from "effect";
3
3
  import { HttpApi, HttpApiEndpoint, HttpApiGroup, HttpApiSchema } from "effect/http-api";
4
4
  /** Non-secret page context injected by the serving host. */
5
5
  export declare const UiContext: Schema.Struct<{
@@ -26,10 +26,26 @@ export interface UiAccountNotice {
26
26
  readonly choose: string;
27
27
  }
28
28
  /** Retained browser bytes. Hosts authorize access before reading or rendering them. */
29
- export interface AppUiAsset {
29
+ export interface AppUiFile {
30
30
  readonly body: Uint8Array;
31
31
  readonly contentType: string;
32
32
  }
33
+ /** One byte range of a stored file, already within its size. */
34
+ export interface AppUiRange {
35
+ readonly offset: number;
36
+ readonly length: number;
37
+ }
38
+ /**
39
+ * A public file the deployment's source served from `ui/public/`, which the host copied to its
40
+ * own store. `etag` names its exact bytes. Hosts authorize access before reading it.
41
+ */
42
+ export interface AppUiStoredFile {
43
+ readonly contentType: string;
44
+ readonly size: number;
45
+ readonly etag: string;
46
+ readonly read: (range: AppUiRange | undefined) => Effect.Effect<Stream.Stream<Uint8Array, UiFailed>, UiFailed>;
47
+ }
48
+ export type AppUiAsset = AppUiFile | AppUiStoredFile;
33
49
  /** Requests name an operation on this app and the page's deployment, never another app or account. */
34
50
  export declare const UiOperation: Schema.Struct<{
35
51
  readonly name: Schema.NonEmptyString;
@@ -1,6 +1,6 @@
1
- import { Effect } from "effect";
1
+ import { Effect, Option, Stream } from "effect";
2
2
  import { HttpServerRequest, HttpServerResponse } from "effect/http";
3
- import { UiForbidden, type AppUiAsset, type UiAccountNotice } from "../contracts/ui.js";
3
+ import { UiFailed, UiForbidden, type AppUiAsset, type AppUiRange, type AppUiStoredFile, type UiAccountNotice } from "../contracts/ui.js";
4
4
  /**
5
5
  * Render an authorized deployment with a host-owned deployment watcher. Account problems that stop
6
6
  * the app replace its document with a page that links to their fix; others add a dismissible card.
@@ -12,11 +12,24 @@ export declare const appDocument: <E, R>(options: {
12
12
  readonly origin: string;
13
13
  readonly accounts?: UiAccountNotice | undefined;
14
14
  readonly asset: (path: string) => Effect.Effect<AppUiAsset | undefined, E, R>;
15
- }) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
15
+ }) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiFailed | UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
16
+ /**
17
+ * A deployment's public file, read from the host's store. The deployment lists it, so bytes that
18
+ * are gone are a storage fault, never a missing page.
19
+ */
20
+ export declare const storedAppFile: <E1, E2>(stored: {
21
+ readonly contentType: string;
22
+ readonly size: number;
23
+ readonly etag: string;
24
+ }, read: (range: AppUiRange | undefined) => Effect.Effect<Option.Option<{
25
+ readonly body: Stream.Stream<Uint8Array, E1>;
26
+ }>, E2>) => AppUiStoredFile;
27
+ /** The file a URL path names: each segment percent-decoded, or none when one does not decode. */
28
+ export declare const assetPath: (path: string) => Option.Option<string>;
16
29
  /** Serve an asset only after the host has checked current access and file existence.
17
30
  * Asset URLs name their deployment, so their bytes never change: the browser keeps them for a year
18
31
  * and does not ask again. Shared proxies never store them. Revoking access stops every new request
19
32
  * and all app data, while bytes a browser already downloaded stay in its cache.
20
- * HTML remains an uncached host-rendered entry point.
33
+ * HTML remains an uncached host-rendered entry point; other HTML files are served as they are.
21
34
  */
22
- export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, never, HttpServerRequest.HttpServerRequest>;
35
+ export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiFailed, HttpServerRequest.HttpServerRequest>;
@@ -1,3 +1,3 @@
1
1
  /** Host-only rendering utilities; the host supplies authorized retained assets. */
2
- export { appDocument, appAsset } from "./implementation/ui-serving.js";
2
+ export { appDocument, appAsset, assetPath, storedAppFile } from "./implementation/ui-serving.js";
3
3
  export { appWatchScript } from "./implementation/ui-watch.js";