@beetlebug/ztk 0.0.0-stage → 0.2.0-beta

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.
@@ -0,0 +1,193 @@
1
+ musl as a whole is licensed under the following standard MIT license:
2
+
3
+ ----------------------------------------------------------------------
4
+ Copyright © 2005-2020 Rich Felker, et al.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ ----------------------------------------------------------------------
25
+
26
+ Authors/contributors include:
27
+
28
+ A. Wilcox
29
+ Ada Worcester
30
+ Alex Dowad
31
+ Alex Suykov
32
+ Alexander Monakov
33
+ Andre McCurdy
34
+ Andrew Kelley
35
+ Anthony G. Basile
36
+ Aric Belsito
37
+ Arvid Picciani
38
+ Bartosz Brachaczek
39
+ Benjamin Peterson
40
+ Bobby Bingham
41
+ Boris Brezillon
42
+ Brent Cook
43
+ Chris Spiegel
44
+ Clément Vasseur
45
+ Daniel Micay
46
+ Daniel Sabogal
47
+ Daurnimator
48
+ David Carlier
49
+ David Edelsohn
50
+ Denys Vlasenko
51
+ Dmitry Ivanov
52
+ Dmitry V. Levin
53
+ Drew DeVault
54
+ Emil Renner Berthing
55
+ Fangrui Song
56
+ Felix Fietkau
57
+ Felix Janda
58
+ Gianluca Anzolin
59
+ Hauke Mehrtens
60
+ He X
61
+ Hiltjo Posthuma
62
+ Isaac Dunham
63
+ Jaydeep Patil
64
+ Jens Gustedt
65
+ Jeremy Huntwork
66
+ Jo-Philipp Wich
67
+ Joakim Sindholt
68
+ John Spencer
69
+ Julien Ramseier
70
+ Justin Cormack
71
+ Kaarle Ritvanen
72
+ Khem Raj
73
+ Kylie McClain
74
+ Leah Neukirchen
75
+ Luca Barbato
76
+ Luka Perkov
77
+ M Farkas-Dyck (Strake)
78
+ Mahesh Bodapati
79
+ Markus Wichmann
80
+ Masanori Ogino
81
+ Michael Clark
82
+ Michael Forney
83
+ Mikhail Kremnyov
84
+ Natanael Copa
85
+ Nicholas J. Kain
86
+ orc
87
+ Pascal Cuoq
88
+ Patrick Oppenlander
89
+ Petr Hosek
90
+ Petr Skocik
91
+ Pierre Carrier
92
+ Reini Urban
93
+ Rich Felker
94
+ Richard Pennington
95
+ Ryan Fairfax
96
+ Samuel Holland
97
+ Segev Finer
98
+ Shiz
99
+ sin
100
+ Solar Designer
101
+ Stefan Kristiansson
102
+ Stefan O'Rear
103
+ Szabolcs Nagy
104
+ Timo Teräs
105
+ Trutz Behn
106
+ Valentin Ochs
107
+ Will Dietz
108
+ William Haddon
109
+ William Pitcock
110
+
111
+ Portions of this software are derived from third-party works licensed
112
+ under terms compatible with the above MIT license:
113
+
114
+ The TRE regular expression implementation (src/regex/reg* and
115
+ src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
116
+ under a 2-clause BSD license (license text in the source files). The
117
+ included version has been heavily modified by Rich Felker in 2012, in
118
+ the interests of size, simplicity, and namespace cleanliness.
119
+
120
+ Much of the math library code (src/math/* and src/complex/*) is
121
+ Copyright © 1993,2004 Sun Microsystems or
122
+ Copyright © 2003-2011 David Schultz or
123
+ Copyright © 2003-2009 Steven G. Kargl or
124
+ Copyright © 2003-2009 Bruce D. Evans or
125
+ Copyright © 2008 Stephen L. Moshier or
126
+ Copyright © 2017-2018 Arm Limited
127
+ and labelled as such in comments in the individual source files. All
128
+ have been licensed under extremely permissive terms.
129
+
130
+ The ARM memcpy code (src/string/arm/memcpy.S) is Copyright © 2008
131
+ The Android Open Source Project and is licensed under a two-clause BSD
132
+ license. It was taken from Bionic libc, used on Android.
133
+
134
+ The AArch64 memcpy and memset code (src/string/aarch64/*) are
135
+ Copyright © 1999-2019, Arm Limited.
136
+
137
+ The implementation of DES for crypt (src/crypt/crypt_des.c) is
138
+ Copyright © 1994 David Burren. It is licensed under a BSD license.
139
+
140
+ The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was
141
+ originally written by Solar Designer and placed into the public
142
+ domain. The code also comes with a fallback permissive license for use
143
+ in jurisdictions that may not recognize the public domain.
144
+
145
+ The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
146
+ Valentin Ochs and is licensed under an MIT-style license.
147
+
148
+ The x86_64 port was written by Nicholas J. Kain and is licensed under
149
+ the standard MIT terms.
150
+
151
+ The mips and microblaze ports were originally written by Richard
152
+ Pennington for use in the ellcc project. The original code was adapted
153
+ by Rich Felker for build system and code conventions during upstream
154
+ integration. It is licensed under the standard MIT terms.
155
+
156
+ The mips64 port was contributed by Imagination Technologies and is
157
+ licensed under the standard MIT terms.
158
+
159
+ The powerpc port was also originally written by Richard Pennington,
160
+ and later supplemented and integrated by John Spencer. It is licensed
161
+ under the standard MIT terms.
162
+
163
+ All other files which have no copyright comments are original works
164
+ produced specifically for use as part of this library, written either
165
+ by Rich Felker, the main author of the library, or by one or more
166
+ contibutors listed above. Details on authorship of individual files
167
+ can be found in the git version control history of the project. The
168
+ omission of copyright and license comments in each file is in the
169
+ interest of source tree size.
170
+
171
+ In addition, permission is hereby granted for all public header files
172
+ (include/* and arch/*/bits/*) and crt files intended to be linked into
173
+ applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
174
+ the copyright notice and permission notice otherwise required by the
175
+ license, and to use these files without any requirement of
176
+ attribution. These files include substantial contributions from:
177
+
178
+ Bobby Bingham
179
+ John Spencer
180
+ Nicholas J. Kain
181
+ Rich Felker
182
+ Richard Pennington
183
+ Stefan Kristiansson
184
+ Szabolcs Nagy
185
+
186
+ all of whom have explicitly granted such permission.
187
+
188
+ This file previously contained text expressing a belief that most of
189
+ the files covered by the above exception were sufficiently trivial not
190
+ to be subject to copyright, resulting in confusion over whether it
191
+ negated the permissions granted in the license. In the spirit of
192
+ permissive licensing, and of not having licensing issues being an
193
+ obstacle to adoption, that text has been removed.
@@ -0,0 +1,40 @@
1
+ This software is copyrighted by the Regents of the University of
2
+ California, Sun Microsystems, Inc., Scriptics Corporation, ActiveState
3
+ Corporation and other parties. The following terms apply to all files
4
+ associated with the software unless explicitly disclaimed in
5
+ individual files.
6
+
7
+ The authors hereby grant permission to use, copy, modify, distribute,
8
+ and license this software and its documentation for any purpose, provided
9
+ that existing copyright notices are retained in all copies and that this
10
+ notice is included verbatim in any distributions. No written agreement,
11
+ license, or royalty fee is required for any of the authorized uses.
12
+ Modifications to this software may be copyrighted by their authors
13
+ and need not follow the licensing terms described here, provided that
14
+ the new terms are clearly indicated on the first page of each file where
15
+ they apply.
16
+
17
+ IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
18
+ FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
19
+ ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
20
+ DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
21
+ POSSIBILITY OF SUCH DAMAGE.
22
+
23
+ THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
24
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
26
+ IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
27
+ NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
28
+ MODIFICATIONS.
29
+
30
+ GOVERNMENT USE: If you are acquiring this software on behalf of the
31
+ U.S. government, the Government shall have only "Restricted Rights"
32
+ in the software and related documentation as defined in the Federal
33
+ Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
34
+ are acquiring the software on behalf of the Department of Defense, the
35
+ software shall be classified as "Commercial Computer Software" and the
36
+ Government shall have only "Restricted Rights" as defined in Clause
37
+ 252.227-7014 (b) (3) of DFARs. Notwithstanding the foregoing, the
38
+ authors grant the U.S. Government and others acting in its behalf
39
+ permission to use and distribute the software in accordance with the
40
+ terms specified in this license.
@@ -0,0 +1,21 @@
1
+ The MIT License (Expat)
2
+
3
+ Copyright (c) Zig contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,44 @@
1
1
  {
2
2
  "name": "@beetlebug/ztk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0-beta",
4
+ "description": "Tk widgets for the web: Tcl scripts with Tk commands, drawn by ztk in WebAssembly",
5
+ "license": "BSD-2-Clause",
6
+ "author": "The ztk authors",
7
+ "homepage": "https://beetlebug.org/ztk/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/beetlebugorg/ztk.git"
11
+ },
12
+ "bugs": "https://github.com/beetlebugorg/ztk/issues",
13
+ "keywords": [
14
+ "tk",
15
+ "tcl",
16
+ "gui",
17
+ "widgets",
18
+ "webassembly",
19
+ "wasm",
20
+ "webgl"
21
+ ],
22
+ "type": "module",
23
+ "main": "./ztk.js",
24
+ "types": "./ztk.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./ztk.d.ts",
28
+ "default": "./ztk.js"
29
+ },
30
+ "./ztk.wasm": "./ztk.wasm",
31
+ "./package.json": "./package.json"
32
+ },
33
+ "files": [
34
+ "ztk.js",
35
+ "ztk.wasm",
36
+ "ztk.d.ts",
37
+ "NOTICE",
38
+ "licenses/"
39
+ ],
40
+ "sideEffects": false,
41
+ "engines": {
42
+ "node": ">=22.3"
43
+ }
44
+ }
package/ztk.d.ts ADDED
@@ -0,0 +1,121 @@
1
+ // Types of ztk.js: Tk widgets in a browser, drawn by ztk.wasm.
2
+ // SPDX-License-Identifier: BSD-2-Clause
3
+
4
+ /** A renderer. "auto" selects the first one that the browser has, in the order of {@link renderers}. */
5
+ export type Renderer = "auto" | "webgpu" | "webgl2" | "cpu";
6
+
7
+ /** The color scheme of the app. "auto" follows `prefers-color-scheme` of the page. */
8
+ export type Theme = "auto" | "light" | "dark";
9
+
10
+ /**
11
+ * The size of the window of the script, in logical pixels.
12
+ *
13
+ * - "auto": the size of the element at the start. Then the window gets
14
+ * the size of its widgets, as a Tk toplevel does.
15
+ * - "fill": the window follows the size of the element. Give the element a size.
16
+ * - `[width, height]` or `{ width, height }`: a fixed logical size. The
17
+ * canvas shows the window at the CSS size that the page gives it.
18
+ */
19
+ export type Size = "auto" | "fill" | [number, number] | { width: number; height: number };
20
+
21
+ /** The result of one `eval`. */
22
+ export interface EvalResult {
23
+ /** True when the script ended with no error. */
24
+ ok: boolean;
25
+ /** The value of the script, or the error message when `ok` is false. */
26
+ result: string;
27
+ }
28
+
29
+ /** The options of {@link mount}. */
30
+ export interface MountOptions {
31
+ /** Tcl text with Tk commands. It runs after `files` are added. */
32
+ script?: string;
33
+ /** Files by name for `ztk::style load`, for example `{ "app.css": text }`. */
34
+ files?: Record<string, string>;
35
+ /** The color scheme. The default is "auto". */
36
+ theme?: Theme;
37
+ /** The size of the window. The default is "auto". */
38
+ size?: Size;
39
+ /** The renderer. The default is "auto". This version has no WebGPU renderer. */
40
+ renderer?: Renderer;
41
+ /** The device pixels in one logical pixel. The default is `devicePixelRatio`. */
42
+ scale?: number;
43
+ /** A module from {@link compileModule}, so that many apps compile `ztk.wasm` one time. */
44
+ module?: WebAssembly.Module;
45
+ /** The URL of `ztk.wasm`. The default is {@link wasmURL}. */
46
+ wasm?: string | URL;
47
+ /** Gets the text of `puts` and the error messages. The default is `console.log`. */
48
+ log?: (text: string) => void;
49
+ }
50
+
51
+ /** The options of {@link start}. */
52
+ export interface StartOptions {
53
+ module?: WebAssembly.Module;
54
+ wasm?: string | URL;
55
+ renderer?: Renderer;
56
+ /** True for dark, false for light, undefined for the color scheme of the page. */
57
+ dark?: boolean;
58
+ /** A fixed logical width. Give it with `height`. */
59
+ width?: number;
60
+ /** A fixed logical height. Give it with `width`. */
61
+ height?: number;
62
+ scale?: number;
63
+ log?: (text: string) => void;
64
+ }
65
+
66
+ /** A running ztk app on a canvas. */
67
+ export interface App {
68
+ /** Runs Tcl text in the interpreter of the app. The next frame shows the change. */
69
+ eval(script: string): EvalResult;
70
+ /** Adds a file by name for `ztk::style load`. */
71
+ addFile(name: string, text: string): boolean;
72
+ /** Gives the window of the script a new logical size. */
73
+ resize(width: number, height: number): void;
74
+ /** Sets the color scheme. */
75
+ setTheme(theme: Theme): void;
76
+ /**
77
+ * Stops the frame loop, removes the event listeners and the elements
78
+ * that the app added, and frees the renderer. Drop the object after this call.
79
+ */
80
+ destroy(): void;
81
+ /** Runs the events and draws one frame now, at the time `ms`. Returns the count of quads, or -1 when no frame was drawn. */
82
+ frame(ms: number): number;
83
+ /** The canvas of the app. */
84
+ readonly canvas: HTMLCanvasElement;
85
+ /** The renderer in use. */
86
+ readonly renderer: "webgl2" | "cpu";
87
+ /** The hidden elements with ARIA roles that follow the widgets. */
88
+ readonly tree: HTMLDivElement;
89
+ /** Aborts when the app is destroyed. */
90
+ readonly signal: AbortSignal;
91
+ /** The exports of the WebAssembly instance, for tests and tools. */
92
+ readonly exports: WebAssembly.Exports;
93
+ }
94
+
95
+ /**
96
+ * Mounts a ztk app on an element.
97
+ * @param el A canvas, or an element that gets a new canvas.
98
+ * @returns The app, after the script ran and the first frame is drawn.
99
+ * A script error destroys the app and rejects with the error message,
100
+ * and the error has the field `result`.
101
+ *
102
+ * @example
103
+ * const app = await mount(document.getElementById("app"), {
104
+ * script: "button .b -text Hello; pack .b",
105
+ * });
106
+ * app.eval(".b configure -text Bye");
107
+ * app.destroy();
108
+ */
109
+ export function mount(el: HTMLElement, options?: MountOptions): Promise<App>;
110
+
111
+ /** Starts ztk.wasm on a canvas. {@link mount} is the API for a page. */
112
+ export function start(canvas: HTMLCanvasElement, options?: StartOptions): Promise<App>;
113
+
114
+ /** Compiles `ztk.wasm` one time for each URL. The default is {@link wasmURL}. */
115
+ export function compileModule(url?: string | URL): Promise<WebAssembly.Module>;
116
+
117
+ /** The URL of the `ztk.wasm` file next to `ztk.js`. */
118
+ export function wasmURL(): URL;
119
+
120
+ /** The renderers of this version, in the order of "auto". */
121
+ export const renderers: readonly ("webgl2" | "cpu")[];