@standardagents/code-web 0.14.1-branch.02dea02c.1bc066

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 ADDED
@@ -0,0 +1,102 @@
1
+ # Standard viewer runtime for the browser
2
+
3
+ `@standardagents/code-web` is the Standard TUI compiled to `wasm32-unknown-unknown`
4
+ with its wasm-bindgen glue and the fonts it draws with. It is a viewer and
5
+ controller for panes that live on native Standard hosts; it never hosts panes.
6
+ The package ships the runtime only: the site owns the page, the canvas, and the
7
+ event wiring.
8
+
9
+ ## Versions
10
+
11
+ Every version is built from the exact commit of a native `@standardagents/code`
12
+ build and publishes under that build's version and dist-tag (`canary`,
13
+ `latest`, `issue-*`, `branch-*`), after the native packages are on npm. So
14
+ `@standardagents/code-web@1.2.3-canary.abcdef` is the viewer for the fleet
15
+ running `@standardagents/code@1.2.3-canary.abcdef`; the wire protocol has no
16
+ negotiation, so a site pins the runtime that matches a fleet version exactly.
17
+ The runtime is built in the publication workflow on GitHub Actions and is not
18
+ yet signed by the native artifact key; depend on it by exact version.
19
+
20
+ ## Contents
21
+
22
+ ```
23
+ dist/pkg/standard_web.js wasm-bindgen glue (ES module, `--target web`)
24
+ dist/pkg/standard_web.d.ts its types
25
+ dist/pkg/standard_web_bg.wasm the module
26
+ dist/fonts/*.ttf JetBrains Mono Nerd Font (Mono): Regular, Bold, Italic, BoldItalic
27
+ dist/licenses/*.txt font licenses (OFL 1.1; Nerd Fonts patch MIT)
28
+ dist/build.json {schema, commit, version} of the native build
29
+ ```
30
+
31
+ Exports:
32
+
33
+ | Specifier | File |
34
+ |---|---|
35
+ | `@standardagents/code-web` | `dist/pkg/standard_web.js` (types alongside) |
36
+ | `@standardagents/code-web/standard_web_bg.wasm` | `dist/pkg/standard_web_bg.wasm` |
37
+ | `@standardagents/code-web/fonts/<file>.ttf` | `dist/fonts/<file>.ttf` |
38
+ | `@standardagents/code-web/licenses/<file>.txt` | `dist/licenses/<file>.txt` |
39
+ | `@standardagents/code-web/build.json` | `dist/build.json` |
40
+
41
+ ## Using it from a Vite app
42
+
43
+ Import the glue, hand `init` the wasm URL, then drive the exported classes.
44
+ The consumer declares the `@font-face` rules for the four bundled fonts and
45
+ waits for them before the first frame, so the grid is measured with the right
46
+ metrics.
47
+
48
+ ```js
49
+ import init, { DeviceLogin, Session, forget_browser } from "@standardagents/code-web";
50
+ import wasmUrl from "@standardagents/code-web/standard_web_bg.wasm?url";
51
+
52
+ await init(wasmUrl);
53
+ // Create a Session against the page's canvas and wire keyboard, pointer,
54
+ // resize, and visibility events to it.
55
+ ```
56
+
57
+ ```css
58
+ @font-face {
59
+ font-family: "JetBrainsMono Nerd Font Mono";
60
+ src: url("@standardagents/code-web/fonts/JetBrainsMonoNerdFontMono-Regular.ttf") format("truetype");
61
+ font-weight: 400;
62
+ font-style: normal;
63
+ }
64
+ /* Bold (700/normal), Italic (400/italic), BoldItalic (700/italic) likewise. */
65
+ ```
66
+
67
+ `packages/web/viewer.js` and `viewer.css` in the repository are the reference
68
+ wiring: the canvas and focus handling, input translation, the font preload,
69
+ device-flow sign-in with `DeviceLogin`, the `Session` lifecycle, and the
70
+ notices the runtime raises. They are the development preview only and are not
71
+ part of the package.
72
+
73
+ ## Serving it
74
+
75
+ The runtime needs wasm execution and same-origin fonts and scripts; the site
76
+ plan (`docs/plans/standard-web-viewer.md`, E2) serves the terminal document
77
+ with
78
+
79
+ ```
80
+ default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self';
81
+ font-src 'self'; img-src 'self' data: blob:;
82
+ connect-src 'self' wss://relay.standardcode.ai; worker-src 'self';
83
+ object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'
84
+ ```
85
+
86
+ plus `Cross-Origin-Opener-Policy: same-origin`. `Session` takes the URL it
87
+ reads the relay issuer keys from; the preview passes `/relay-keys` on its own
88
+ origin and `scripts/serve.mjs` proxies it, so a site proxies that endpoint the
89
+ same way.
90
+
91
+ ## Building locally
92
+
93
+ `node scripts/build.mjs` runs `cargo build --locked --release --target
94
+ wasm32-unknown-unknown -p standard-web`, `wasm-bindgen --target web`, fetches
95
+ and verifies the pinned fonts, and copies the licenses and the preview page
96
+ into `dist/`. The `wasm-bindgen` CLI must be the version `Cargo.lock` pins;
97
+ `node scripts/build.mjs --check` verifies that and names the `cargo install`
98
+ command otherwise. `node scripts/serve.mjs [host] [port]` serves `dist/` as
99
+ the preview.
100
+
101
+ The version in this package's `package.json` is a placeholder; the publisher
102
+ sets the native build's version at publication time.
@@ -0,0 +1 @@
1
+ {"schema":1,"commit":"1bc066ab298b33cef2c14d660af424f6d71a8bb6","version":"0.14.1-branch.02dea02c.1bc066"}
@@ -0,0 +1,94 @@
1
+ JetBrains Mono
2
+ Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
3
+
4
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
5
+ This license is copied below, and is also available with a FAQ at:
6
+ https://openfontlicense.org
7
+
8
+
9
+ -----------------------------------------------------------
10
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
11
+ -----------------------------------------------------------
12
+
13
+ PREAMBLE
14
+ The goals of the Open Font License (OFL) are to stimulate worldwide
15
+ development of collaborative font projects, to support the font creation
16
+ efforts of academic and linguistic communities, and to provide a free and
17
+ open framework in which fonts may be shared and improved in partnership
18
+ with others.
19
+
20
+ The OFL allows the licensed fonts to be used, studied, modified and
21
+ redistributed freely as long as they are not sold by themselves. The
22
+ fonts, including any derivative works, can be bundled, embedded,
23
+ redistributed and/or sold with any software provided that any reserved
24
+ names are not used by derivative works. The fonts and derivatives,
25
+ however, cannot be released under any other type of license. The
26
+ requirement for fonts to remain under this license does not apply
27
+ to any document created using the fonts or their derivatives.
28
+
29
+ DEFINITIONS
30
+ "Font Software" refers to the set of files released by the Copyright
31
+ Holder(s) under this license and clearly marked as such. This may
32
+ include source files, build scripts and documentation.
33
+
34
+ "Reserved Font Name" refers to any names specified as such after the
35
+ copyright statement(s).
36
+
37
+ "Original Version" refers to the collection of Font Software components as
38
+ distributed by the Copyright Holder(s).
39
+
40
+ "Modified Version" refers to any derivative made by adding to, deleting,
41
+ or substituting -- in part or in whole -- any of the components of the
42
+ Original Version, by changing formats or by porting the Font Software to a
43
+ new environment.
44
+
45
+ "Author" refers to any designer, engineer, programmer, technical
46
+ writer or other person who contributed to the Font Software.
47
+
48
+ PERMISSION & CONDITIONS
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
51
+ redistribute, and sell modified and unmodified copies of the Font
52
+ Software, subject to the following conditions:
53
+
54
+ 1) Neither the Font Software nor any of its individual components,
55
+ in Original or Modified Versions, may be sold by itself.
56
+
57
+ 2) Original or Modified Versions of the Font Software may be bundled,
58
+ redistributed and/or sold with any software, provided that each copy
59
+ contains the above copyright notice and this license. These can be
60
+ included either as stand-alone text files, human-readable headers or
61
+ in the appropriate machine-readable metadata fields within text or
62
+ binary files as long as those fields can be easily viewed by the user.
63
+
64
+ 3) No Modified Version of the Font Software may use the Reserved Font
65
+ Name(s) unless explicit written permission is granted by the corresponding
66
+ Copyright Holder. This restriction only applies to the primary font name as
67
+ presented to the users.
68
+
69
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
70
+ Software shall not be used to promote, endorse or advertise any
71
+ Modified Version, except to acknowledge the contribution(s) of the
72
+ Copyright Holder(s) and the Author(s) or with their explicit written
73
+ permission.
74
+
75
+ 5) The Font Software, modified or unmodified, in part or in whole,
76
+ must be distributed entirely under this license, and must not be
77
+ distributed under any other license. The requirement for fonts to
78
+ remain under this license does not apply to any document created
79
+ using the Font Software.
80
+
81
+ TERMINATION
82
+ This license becomes null and void if any of the above conditions are
83
+ not met.
84
+
85
+ DISCLAIMER
86
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
87
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
88
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
89
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
90
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
91
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
92
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
93
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
94
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,29 @@
1
+ Nerd Fonts (the glyph patching applied to the JetBrains Mono files in fonts/)
2
+ https://github.com/ryanoasis/nerd-fonts
3
+
4
+ The patched font files remain under the JetBrains Mono license in
5
+ JetBrainsMono-OFL.txt. The Nerd Fonts patcher and the added glyph sets are
6
+ distributed under the MIT License below; the glyph sets carry their own
7
+ upstream licenses, listed at the repository above.
8
+
9
+ MIT License
10
+
11
+ Copyright (c) 2014 Ryan L McIntyre
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
@@ -0,0 +1,156 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * One device login in progress.
6
+ */
7
+ export class DeviceLogin {
8
+ private constructor();
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ /**
12
+ * Resolves to the credential once approved, or `undefined` while the
13
+ * login is still pending. Rejects when it was denied or has expired.
14
+ */
15
+ poll(): Promise<any>;
16
+ /**
17
+ * Starts a login against `api_origin`, e.g. `https://api.standardcode.ai`.
18
+ */
19
+ static start(api_origin: string): Promise<DeviceLogin>;
20
+ /**
21
+ * The code the person confirms on the verification page.
22
+ */
23
+ readonly code: string;
24
+ /**
25
+ * How long to wait between polls, in milliseconds.
26
+ */
27
+ readonly intervalMs: number;
28
+ /**
29
+ * Where the person approves this login.
30
+ */
31
+ readonly verificationUrl: string;
32
+ }
33
+
34
+ export class Session {
35
+ free(): void;
36
+ [Symbol.dispose](): void;
37
+ columns(): number;
38
+ focus(focused: boolean): void;
39
+ /**
40
+ * One animation frame. Returns `true` once the session has ended.
41
+ */
42
+ frame(): boolean;
43
+ /**
44
+ * A `keydown` or `keyup`. Returns whether the viewer consumed it, so
45
+ * the page can suppress the browser's default action.
46
+ */
47
+ key(key: string, code: string, ctrl: boolean, alt: boolean, shift: boolean, meta: boolean, repeat: boolean, release: boolean): boolean;
48
+ /**
49
+ * Starts the viewer on `canvas`, whose backing store is already sized in
50
+ * device pixels. `font_px` is the font size in device pixels.
51
+ * With an `api_origin` and a `token` the viewer shows that account;
52
+ * without them it runs on the built-in demo account. `relay_keys_url`
53
+ * is where the relay's public issuer keyset is read from: the issuer
54
+ * sends no CORS headers, so the site serves it from its own origin.
55
+ */
56
+ constructor(canvas: HTMLCanvasElement, family: string, font_px: number, api_origin?: string | null, token?: string | null, relay_keys_url?: string | null);
57
+ paste(text: string): void;
58
+ /**
59
+ * `action` is 0 down, 1 up, 2 move; `x` and `y` are device pixels
60
+ * relative to the canvas.
61
+ */
62
+ pointer(action: number, button: number, x: number, y: number, ctrl: boolean, alt: boolean, shift: boolean): void;
63
+ /**
64
+ * The page resized the canvas backing store or changed the font size
65
+ * (a device-pixel-ratio change does both).
66
+ */
67
+ resize(font_px: number): void;
68
+ rows(): number;
69
+ /**
70
+ * Text copied since the last call. The page writes it to the system
71
+ * clipboard from inside the event handler that produced it.
72
+ */
73
+ take_clipboard(): string | undefined;
74
+ /**
75
+ * Wheel deltas in device pixels.
76
+ */
77
+ wheel(delta_x: number, delta_y: number, x: number, y: number, ctrl: boolean, alt: boolean, shift: boolean): void;
78
+ }
79
+
80
+ /**
81
+ * Revokes this browser's machine in the account and discards its stored
82
+ * identity. The page clears the credential and reloads afterwards.
83
+ */
84
+ export function forget_browser(api_origin: string, token: string): Promise<void>;
85
+
86
+ /**
87
+ * Runs the secure link end to end inside this page and reports the result.
88
+ */
89
+ export function link_check(): string;
90
+
91
+ /**
92
+ * Panics reach the console with their message from the first call on, not
93
+ * only once a session exists.
94
+ */
95
+ export function start(): void;
96
+
97
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
98
+
99
+ export interface InitOutput {
100
+ readonly memory: WebAssembly.Memory;
101
+ readonly __wbg_devicelogin_free: (a: number, b: number) => void;
102
+ readonly devicelogin_code: (a: number, b: number) => void;
103
+ readonly devicelogin_intervalMs: (a: number) => number;
104
+ readonly devicelogin_poll: (a: number) => number;
105
+ readonly devicelogin_start: (a: number, b: number) => number;
106
+ readonly devicelogin_verificationUrl: (a: number, b: number) => void;
107
+ readonly forget_browser: (a: number, b: number, c: number, d: number) => number;
108
+ readonly __wbg_session_free: (a: number, b: number) => void;
109
+ readonly link_check: (a: number) => void;
110
+ readonly session_columns: (a: number) => number;
111
+ readonly session_focus: (a: number, b: number, c: number) => void;
112
+ readonly session_frame: (a: number, b: number) => void;
113
+ readonly session_key: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
114
+ readonly session_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
115
+ readonly session_paste: (a: number, b: number, c: number, d: number) => void;
116
+ readonly session_pointer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
117
+ readonly session_resize: (a: number, b: number, c: number) => void;
118
+ readonly session_rows: (a: number) => number;
119
+ readonly session_take_clipboard: (a: number, b: number) => void;
120
+ readonly session_wheel: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
121
+ readonly start: () => void;
122
+ readonly __wasm_bindgen_func_elem_9261: (a: number, b: number, c: number, d: number) => void;
123
+ readonly __wasm_bindgen_func_elem_9263: (a: number, b: number, c: number, d: number) => void;
124
+ readonly __wasm_bindgen_func_elem_586: (a: number, b: number, c: number) => void;
125
+ readonly __wasm_bindgen_func_elem_586_2: (a: number, b: number, c: number) => void;
126
+ readonly __wasm_bindgen_func_elem_586_3: (a: number, b: number, c: number) => void;
127
+ readonly __wbindgen_export: (a: number, b: number) => number;
128
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
129
+ readonly __wbindgen_export3: (a: number) => void;
130
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
131
+ readonly __wbindgen_export5: (a: number, b: number) => void;
132
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
133
+ readonly __wbindgen_start: () => void;
134
+ }
135
+
136
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
137
+
138
+ /**
139
+ * Instantiates the given `module`, which can either be bytes or
140
+ * a precompiled `WebAssembly.Module`.
141
+ *
142
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
143
+ *
144
+ * @returns {InitOutput}
145
+ */
146
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
147
+
148
+ /**
149
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
150
+ * for everything else, calls `WebAssembly.instantiate` directly.
151
+ *
152
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
153
+ *
154
+ * @returns {Promise<InitOutput>}
155
+ */
156
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;