proteus-sdk 0.0.0-stage → 0.1.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.
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "proteus-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for Proteus, a UI framework whose components transform into other components instead of loading new screens. Draws with WebGPU or WebGL2.",
5
+ "type": "module",
6
+ "license": "MIT OR Apache-2.0",
7
+ "author": "Blue <isaac.chellin@gmail.com>",
8
+ "homepage": "https://github.com/ichellin1/proteus/tree/main/docs",
9
+ "bugs": {
10
+ "url": "https://github.com/ichellin1/proteus/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/ichellin1/proteus.git",
15
+ "directory": "crates/proteus-sdk-web/ts"
16
+ },
17
+ "keywords": [
18
+ "proteus",
19
+ "ui",
20
+ "ui-framework",
21
+ "webgl",
22
+ "webgl2",
23
+ "webgpu",
24
+ "wasm",
25
+ "webassembly",
26
+ "animation",
27
+ "transitions",
28
+ "metamorphic"
29
+ ],
30
+ "main": "./dist/index.js",
31
+ "types": "./dist/index.d.ts",
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "pkg",
41
+ "pkg-host"
42
+ ],
43
+ "sideEffects": false,
44
+ "scripts": {
45
+ "build": "tsc",
46
+ "typecheck": "tsc --noEmit",
47
+ "prepack": "rm -f pkg/.gitignore pkg-host/.gitignore",
48
+ "check-docs": "typedoc src/index.ts --emit none --excludeInternal --validation.notDocumented --validation.invalidLink --treatValidationWarningsAsErrors",
49
+ "check-snippets": "node ../../../scripts/check-ts-snippets.mjs"
50
+ },
51
+ "devDependencies": {
52
+ "typedoc": "^0.28.20",
53
+ "typescript": "^5.6.0"
54
+ }
55
+ }
package/pkg/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # proteus-sdk-web
2
+
3
+ WebAssembly bindings that expose `proteus-sdk` to JavaScript, for the Proteus TypeScript SDK.
4
+
5
+ Part of [Proteus](https://github.com/ichellin1/proteus).
6
+
7
+ Apps don't use it directly. In TypeScript, use the [`proteus-sdk` npm package](https://www.npmjs.com/package/proteus-sdk), which is built from it; in Rust, use [`proteus-sdk`](https://crates.io/crates/proteus-sdk).
8
+
9
+ ## License
10
+
11
+ MIT or Apache-2.0, at your option.
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "proteus-sdk-web",
3
+ "type": "module",
4
+ "collaborators": [
5
+ "Blue <isaac.chellin@gmail.com>"
6
+ ],
7
+ "description": "WebAssembly bindings that expose proteus-sdk to JavaScript, for the Proteus TypeScript SDK.",
8
+ "version": "0.1.0",
9
+ "license": "MIT OR Apache-2.0",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/ichellin1/proteus"
13
+ },
14
+ "files": [
15
+ "proteus_sdk_web_bg.wasm",
16
+ "proteus_sdk_web.js",
17
+ "proteus_sdk_web_bg.js",
18
+ "proteus_sdk_web.d.ts"
19
+ ],
20
+ "main": "proteus_sdk_web.js",
21
+ "homepage": "https://ichellin1.github.io/proteus/",
22
+ "types": "proteus_sdk_web.d.ts",
23
+ "sideEffects": [
24
+ "./proteus_sdk_web.js",
25
+ "./snippets/*"
26
+ ],
27
+ "keywords": [
28
+ "ui",
29
+ "gui",
30
+ "animation",
31
+ "transitions",
32
+ "wgpu"
33
+ ]
34
+ }
@@ -0,0 +1,309 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * A handle to a component.
6
+ */
7
+ export class Handle {
8
+ private constructor();
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ /**
12
+ * Returns a handle for an ID from [`Handle::id`] or
13
+ * `ComponentData.children`. The ID isn't checked: if its component has
14
+ * been destroyed, methods that change it throw and `get` returns
15
+ * `undefined`.
16
+ */
17
+ static fromId(id: number): Handle;
18
+ /**
19
+ * The component's ID: its entity's bits as a number, which is exact for
20
+ * any realistic app (see the `dto` module). [`Handle::from_id`] turns it
21
+ * back into a handle.
22
+ */
23
+ id(): number;
24
+ }
25
+
26
+ /**
27
+ * A [`Proteus`](sdk::Proteus) app, as JavaScript sees it. Cloning shares the
28
+ * same app.
29
+ */
30
+ export class ProteusApp {
31
+ free(): void;
32
+ [Symbol.dispose](): void;
33
+ /**
34
+ * Calls [`Handle::add_child`](sdk::Handle::add_child).
35
+ */
36
+ addChild(parent: Handle, child: Handle): void;
37
+ /**
38
+ * Calls [`Handle::animate_to`](sdk::Handle::animate_to).
39
+ */
40
+ animateTo(handle: Handle, to: any, config: any): void;
41
+ /**
42
+ * Calls [`Proteus::bake_texture`](sdk::Proteus::bake_texture).
43
+ */
44
+ bakeTexture(width: number, height: number, rgba: Uint8Array, request: any): TextureHandle;
45
+ /**
46
+ * Calls [`Handle::baked_image_size`](sdk::Handle::baked_image_size).
47
+ * Returns `undefined` if there is no baked image.
48
+ */
49
+ bakedImageSize(handle: Handle): any;
50
+ /**
51
+ * Calls [`Handle::baked_text_size`](sdk::Handle::baked_text_size).
52
+ * Returns `undefined` if there is no baked text.
53
+ */
54
+ bakedTextSize(handle: Handle): any;
55
+ /**
56
+ * Calls [`TransitionChannel::destroy`](sdk::TransitionChannel::destroy). Consumes
57
+ * `channel`: the JavaScript object can't be used afterwards.
58
+ */
59
+ channelDestroy(channel: TransitionChannel): void;
60
+ /**
61
+ * Calls [`TransitionChannel::set`](sdk::TransitionChannel::set).
62
+ */
63
+ channelSet(channel: TransitionChannel, to: Handle, from: Handle, config: any, interruptible: boolean): void;
64
+ /**
65
+ * Calls [`Proteus::component`](sdk::Proteus::component). `spec` is a
66
+ * `ComponentSpec` object; its `children` are handle IDs.
67
+ */
68
+ component(spec: any): Handle;
69
+ /**
70
+ * Calls [`Handle::copy_baked_image_from`](sdk::Handle::copy_baked_image_from).
71
+ */
72
+ copyBakedImageFrom(handle: Handle, source: Handle): boolean;
73
+ /**
74
+ * Calls [`Proteus::create_video`](sdk::Proteus::create_video).
75
+ */
76
+ createVideo(): VideoHandle;
77
+ /**
78
+ * Calls [`Handle::crop_image`](sdk::Handle::crop_image). Throws if
79
+ * `crop` isn't a valid `ImageCrop`.
80
+ */
81
+ cropImage(handle: Handle, crop: any): boolean;
82
+ /**
83
+ * Calls [`Handle::destroy`](sdk::Handle::destroy). Consumes `handle`: the
84
+ * JavaScript object can't be used afterwards.
85
+ */
86
+ destroy(handle: Handle): void;
87
+ /**
88
+ * Calls [`Handle::free_resources`](sdk::Handle::free_resources).
89
+ */
90
+ freeResources(handle: Handle): void;
91
+ /**
92
+ * Calls [`Proteus::get`](sdk::Proteus::get). Returns `undefined` if the
93
+ * component has been destroyed.
94
+ */
95
+ get(handle: Handle): any;
96
+ /**
97
+ * Calls [`Handle::hide_video`](sdk::Handle::hide_video).
98
+ */
99
+ hideVideo(handle: Handle): void;
100
+ /**
101
+ * Calls [`Proteus::load_texture`](sdk::Proteus::load_texture). Returns
102
+ * `undefined` if the bytes can't be decoded.
103
+ */
104
+ loadTexture(bytes: Uint8Array, request: any): TextureHandle | undefined;
105
+ /**
106
+ * Calls [`Handle::merge_from`](sdk::Handle::merge_from). The sources
107
+ * cross as handle IDs.
108
+ */
109
+ mergeFrom(handle: Handle, source_ids: Float64Array, config: any, layout: any): void;
110
+ /**
111
+ * Calls [`Handle::merge_from_with_behavior`](sdk::Handle::merge_from_with_behavior).
112
+ * `child_behavior` is called once per source, before the merge starts.
113
+ */
114
+ mergeFromWithBehavior(handle: Handle, source_ids: Float64Array, config: any, layout: any, child_behavior: Function): void;
115
+ /**
116
+ * Creates a standalone app, with no host, that draws nothing.
117
+ */
118
+ constructor();
119
+ /**
120
+ * Calls [`Handle::on_blur`](sdk::Handle::on_blur).
121
+ */
122
+ onBlur(handle: Handle, cb: Function): void;
123
+ /**
124
+ * Calls [`Handle::on_click`](sdk::Handle::on_click).
125
+ */
126
+ onClick(handle: Handle, cb: Function): void;
127
+ /**
128
+ * Calls [`Handle::on_drag`](sdk::Handle::on_drag). `cb` receives the
129
+ * movement as two numbers, `x` and `y`.
130
+ */
131
+ onDrag(handle: Handle, cb: Function): void;
132
+ /**
133
+ * Calls [`TransitionChannel::on_dropped`](sdk::TransitionChannel::on_dropped).
134
+ */
135
+ onDropped(channel: TransitionChannel, cb: Function): void;
136
+ /**
137
+ * Calls [`Handle::on_focus`](sdk::Handle::on_focus).
138
+ */
139
+ onFocus(handle: Handle, cb: Function): void;
140
+ /**
141
+ * Calls [`Handle::on_hover_enter`](sdk::Handle::on_hover_enter).
142
+ */
143
+ onHoverEnter(handle: Handle, cb: Function): void;
144
+ /**
145
+ * Calls [`Handle::on_hover_exit`](sdk::Handle::on_hover_exit).
146
+ */
147
+ onHoverExit(handle: Handle, cb: Function): void;
148
+ /**
149
+ * Calls [`Handle::on_press`](sdk::Handle::on_press).
150
+ */
151
+ onPress(handle: Handle, cb: Function): void;
152
+ /**
153
+ * Calls [`Handle::on_release`](sdk::Handle::on_release).
154
+ */
155
+ onRelease(handle: Handle, cb: Function): void;
156
+ /**
157
+ * Calls [`Handle::on_transition_complete`](sdk::Handle::on_transition_complete).
158
+ */
159
+ onTransitionComplete(handle: Handle, cb: Function): void;
160
+ /**
161
+ * Records that the pointer left the viewport: `pointer_moved(None)`.
162
+ */
163
+ pointerLeft(): void;
164
+ /**
165
+ * Calls [`Proteus::pointer_moved`](sdk::Proteus::pointer_moved). `x` and
166
+ * `y` are world units: origin at the viewport center, y up.
167
+ */
168
+ pointerMoved(x: number, y: number): void;
169
+ /**
170
+ * Calls [`Proteus::pointer_pressed`](sdk::Proteus::pointer_pressed).
171
+ */
172
+ pointerPressed(): void;
173
+ /**
174
+ * Calls [`Proteus::pointer_released`](sdk::Proteus::pointer_released).
175
+ */
176
+ pointerReleased(): void;
177
+ /**
178
+ * Calls [`VideoHandle::release`](sdk::VideoHandle::release).
179
+ */
180
+ releaseVideo(video: VideoHandle): void;
181
+ /**
182
+ * Calls [`Handle::remove_child`](sdk::Handle::remove_child).
183
+ */
184
+ removeChild(parent: Handle, child: Handle): void;
185
+ /**
186
+ * Calls [`Handle::set_declared_geometry`](sdk::Handle::set_declared_geometry).
187
+ */
188
+ setDeclaredGeometry(handle: Handle, state: any): void;
189
+ /**
190
+ * Calls [`Handle::set_disabled`](sdk::Handle::set_disabled).
191
+ */
192
+ setDisabled(handle: Handle, disabled: boolean): void;
193
+ /**
194
+ * Calls [`Handle::set_image`](sdk::Handle::set_image).
195
+ */
196
+ setImage(handle: Handle, image: any): void;
197
+ /**
198
+ * Calls [`Handle::set_interactive`](sdk::Handle::set_interactive).
199
+ */
200
+ setInteractive(handle: Handle, interactive: boolean): void;
201
+ /**
202
+ * Calls [`Handle::set_opacity`](sdk::Handle::set_opacity).
203
+ */
204
+ setOpacity(handle: Handle, opacity: number): void;
205
+ /**
206
+ * Calls [`Handle::set_text`](sdk::Handle::set_text).
207
+ */
208
+ setText(handle: Handle, text: any): void;
209
+ /**
210
+ * Calls [`Handle::set_texture`](sdk::Handle::set_texture).
211
+ */
212
+ setTexture(handle: Handle, texture: TextureHandle): boolean;
213
+ /**
214
+ * Calls [`Handle::set_transition_interaction`](sdk::Handle::set_transition_interaction).
215
+ * `null` or `undefined` restores the default.
216
+ */
217
+ setTransitionInteraction(handle: Handle, config: any): void;
218
+ /**
219
+ * Calls [`Handle::set_video_crossfade`](sdk::Handle::set_video_crossfade).
220
+ */
221
+ setVideoCrossfade(handle: Handle, video_t: number): boolean;
222
+ /**
223
+ * Calls [`Handle::set_visible`](sdk::Handle::set_visible).
224
+ */
225
+ setVisible(handle: Handle, visible: boolean): void;
226
+ /**
227
+ * Calls [`Handle::show_video`](sdk::Handle::show_video).
228
+ */
229
+ showVideo(handle: Handle, video: VideoHandle): boolean;
230
+ /**
231
+ * Calls [`Handle::split_to`](sdk::Handle::split_to). The targets cross
232
+ * as handle IDs.
233
+ */
234
+ splitTo(handle: Handle, target_ids: Float64Array, config: any, strategy: any): void;
235
+ /**
236
+ * Calls [`Handle::split_to_with_behavior`](sdk::Handle::split_to_with_behavior).
237
+ * `child_behavior` is called once per target, before the split starts.
238
+ */
239
+ splitToWithBehavior(handle: Handle, target_ids: Float64Array, config: any, strategy: any, child_behavior: Function): void;
240
+ /**
241
+ * Calls [`Handle::split_to_with_states`](sdk::Handle::split_to_with_states).
242
+ * `targets` is an array of `{ id, state }` objects.
243
+ */
244
+ splitToWithStates(handle: Handle, targets: any, config: any, strategy: any): void;
245
+ /**
246
+ * Returns a texture handle for a texture ID.
247
+ */
248
+ texture(id: number): TextureHandle;
249
+ /**
250
+ * Calls [`TextureHandle::state`](sdk::TextureHandle::state). Returns
251
+ * `undefined` if the texture has been evicted or never existed.
252
+ */
253
+ textureState(handle: TextureHandle): any;
254
+ /**
255
+ * Calls [`Proteus::tick`](sdk::Proteus::tick). For a standalone app only:
256
+ * a host ticks the shared `Proteus` itself.
257
+ */
258
+ tick(dt: number): void;
259
+ /**
260
+ * Calls [`Proteus::transition_channel`](sdk::Proteus::transition_channel).
261
+ * `owner` is a handle ID, since `wasm-bindgen` can't take an optional
262
+ * reference.
263
+ */
264
+ transitionChannel(owner?: number | null): TransitionChannel;
265
+ /**
266
+ * Calls [`VideoHandle::upload_frame`](sdk::VideoHandle::upload_frame).
267
+ */
268
+ uploadVideoFrame(video: VideoHandle, width: number, height: number, rgba: Uint8Array): boolean;
269
+ }
270
+
271
+ /**
272
+ * A handle to a texture in the atlas.
273
+ */
274
+ export class TextureHandle {
275
+ private constructor();
276
+ free(): void;
277
+ [Symbol.dispose](): void;
278
+ /**
279
+ * Returns a handle for an ID from [`JsTextureHandle::id`]. To add a
280
+ * texture, use `loadTexture` or `bakeTexture`.
281
+ */
282
+ static fromId(id: number): TextureHandle;
283
+ /**
284
+ * The texture's ID, as a number. [`JsTextureHandle::from_id`] turns it
285
+ * back into a handle.
286
+ */
287
+ id(): number;
288
+ }
289
+
290
+ /**
291
+ * A handle to a transition channel. It has no methods of its own; it is
292
+ * passed to `channelSet`, `channelDestroy` and `onDropped`.
293
+ */
294
+ export class TransitionChannel {
295
+ private constructor();
296
+ free(): void;
297
+ [Symbol.dispose](): void;
298
+ }
299
+
300
+ /**
301
+ * A handle to a video whose frames the app supplies. It has no methods of
302
+ * its own; it is passed to `uploadVideoFrame`, `releaseVideo` and
303
+ * `showVideo`.
304
+ */
305
+ export class VideoHandle {
306
+ private constructor();
307
+ free(): void;
308
+ [Symbol.dispose](): void;
309
+ }
@@ -0,0 +1,9 @@
1
+ /* @ts-self-types="./proteus_sdk_web.d.ts" */
2
+ import * as wasm from "./proteus_sdk_web_bg.wasm";
3
+ import { __wbg_set_wasm } from "./proteus_sdk_web_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+ wasm.__wbindgen_start();
7
+ export {
8
+ Handle, ProteusApp, TextureHandle, TransitionChannel, VideoHandle
9
+ } from "./proteus_sdk_web_bg.js";