create-basicjs 0.1.5 → 0.1.6

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 (94) hide show
  1. package/README.md +10 -0
  2. package/bin/create-basicjs.js +27 -1
  3. package/package.json +1 -1
  4. package/payload/projects/tauri/.github/workflows/build.yml +86 -0
  5. package/payload/projects/tauri/.github/workflows/tests.yml +87 -0
  6. package/payload/projects/tauri/AGENTS.md +128 -0
  7. package/payload/projects/tauri/CLAUDE.md +1 -0
  8. package/payload/projects/tauri/LICENSE +201 -0
  9. package/payload/projects/tauri/NOTICE +8 -0
  10. package/payload/projects/tauri/README.md +269 -0
  11. package/payload/projects/tauri/checks/window-check.js +189 -0
  12. package/payload/projects/tauri/gitignore +8 -0
  13. package/payload/projects/tauri/handbook/01-getting-started.md +188 -0
  14. package/payload/projects/tauri/handbook/02-the-project.md +264 -0
  15. package/payload/projects/tauri/handbook/03-the-page.md +260 -0
  16. package/payload/projects/tauri/handbook/04-commands.md +265 -0
  17. package/payload/projects/tauri/handbook/05-events-and-state.md +275 -0
  18. package/payload/projects/tauri/handbook/06-plugins.md +282 -0
  19. package/payload/projects/tauri/handbook/07-the-window-and-the-app.md +431 -0
  20. package/payload/projects/tauri/handbook/08-security.md +374 -0
  21. package/payload/projects/tauri/handbook/09-tests-and-checks.md +266 -0
  22. package/payload/projects/tauri/handbook/10-building-and-releasing.md +238 -0
  23. package/payload/projects/tauri/handbook/11-troubleshooting.md +259 -0
  24. package/payload/projects/tauri/handbook/README.md +125 -0
  25. package/payload/projects/tauri/handbook/turkce/01-getting-started.md +193 -0
  26. package/payload/projects/tauri/handbook/turkce/02-the-project.md +272 -0
  27. package/payload/projects/tauri/handbook/turkce/03-the-page.md +272 -0
  28. package/payload/projects/tauri/handbook/turkce/04-commands.md +271 -0
  29. package/payload/projects/tauri/handbook/turkce/05-events-and-state.md +284 -0
  30. package/payload/projects/tauri/handbook/turkce/06-plugins.md +286 -0
  31. package/payload/projects/tauri/handbook/turkce/07-the-window-and-the-app.md +433 -0
  32. package/payload/projects/tauri/handbook/turkce/08-security.md +384 -0
  33. package/payload/projects/tauri/handbook/turkce/09-tests-and-checks.md +275 -0
  34. package/payload/projects/tauri/handbook/turkce/10-building-and-releasing.md +241 -0
  35. package/payload/projects/tauri/handbook/turkce/11-troubleshooting.md +264 -0
  36. package/payload/projects/tauri/handbook/turkce/README.md +128 -0
  37. package/payload/projects/tauri/images/app.png +0 -0
  38. package/payload/projects/tauri/src-tauri/Cargo.lock +4389 -0
  39. package/payload/projects/tauri/src-tauri/Cargo.toml +31 -0
  40. package/payload/projects/tauri/src-tauri/app-icon.svg +16 -0
  41. package/payload/projects/tauri/src-tauri/build.rs +15 -0
  42. package/payload/projects/tauri/src-tauri/capabilities/default.json +7 -0
  43. package/payload/projects/tauri/src-tauri/gitignore +5 -0
  44. package/payload/projects/tauri/src-tauri/icons/128x128.png +0 -0
  45. package/payload/projects/tauri/src-tauri/icons/128x128@2x.png +0 -0
  46. package/payload/projects/tauri/src-tauri/icons/32x32.png +0 -0
  47. package/payload/projects/tauri/src-tauri/icons/icon.icns +0 -0
  48. package/payload/projects/tauri/src-tauri/icons/icon.ico +0 -0
  49. package/payload/projects/tauri/src-tauri/src/check.rs +144 -0
  50. package/payload/projects/tauri/src-tauri/src/files.rs +255 -0
  51. package/payload/projects/tauri/src-tauri/src/main.rs +45 -0
  52. package/payload/projects/tauri/src-tauri/src/sizes.rs +214 -0
  53. package/payload/projects/tauri/src-tauri/tauri.conf.json +44 -0
  54. package/payload/projects/tauri/src-tauri/tests/project.rs +243 -0
  55. package/payload/projects/tauri/ui/app.js +459 -0
  56. package/payload/projects/tauri/ui/backend.js +196 -0
  57. package/payload/projects/tauri/ui/basic/LICENSE +14 -0
  58. package/payload/projects/tauri/ui/basic/basic.min.css +1 -0
  59. package/payload/projects/tauri/ui/basic/basic.min.js +78 -0
  60. package/payload/projects/tauri/ui/basic/font/open-sans/LICENSE.txt +206 -0
  61. package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
  62. package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
  63. package/payload/projects/tauri/ui/basic/scroll-bar.min.js +3 -0
  64. package/payload/projects/tauri/ui/comp/_sources.txt +9 -0
  65. package/payload/projects/tauri/ui/comp/components.min.js +21 -0
  66. package/payload/projects/tauri/ui/index.html +28 -0
  67. package/payload/projects/tauri/ui/sizes.js +104 -0
  68. package/payload/starter/_basic/VERSION +1 -1
  69. package/payload/starter/_basic/comp/bottom-bar.js +31 -3
  70. package/payload/starter/_basic/comp/code-editor.js +219 -1
  71. package/payload/starter/_basic/comp/context-menu.js +6 -1
  72. package/payload/starter/_basic/comp/markdown-view.js +4 -2
  73. package/payload/starter/_basic/comp/property-panel.js +1 -1
  74. package/payload/starter/_basic/comp/slider.js +27 -12
  75. package/payload/starter/_basic/comp/smart-button.js +5 -1
  76. package/payload/starter/_basic/comp/smart-table.js +8 -1
  77. package/payload/starter/_basic/comp/stepper.js +29 -3
  78. package/payload/starter/_basic/comp/toggle.js +2 -1
  79. package/payload/starter/_basic/docs/component-index.md +53 -53
  80. package/payload/starter/_basic/examples/code-editor.htm +48 -1
  81. package/payload/starter/_basic/examples/gallery-styled.htm +896 -0
  82. package/payload/starter/_basic/examples/search-input.htm +1 -1
  83. package/payload/starter/_basic/examples/select-box-2-item-view.htm +304 -0
  84. package/payload/starter/_basic/examples/{slider-2-classic.htm → slider-2-split.htm} +36 -2
  85. package/payload/starter/_basic/examples/stepper-2.htm +22 -6
  86. package/payload/starter/_basic/min/bottom-bar.min.js +1 -1
  87. package/payload/starter/_basic/min/code-editor.min.js +1 -1
  88. package/payload/starter/_basic/min/context-menu.min.js +1 -1
  89. package/payload/starter/_basic/min/markdown-view.min.js +1 -1
  90. package/payload/starter/_basic/min/slider.min.js +1 -1
  91. package/payload/starter/_basic/min/smart-button.min.js +1 -1
  92. package/payload/starter/_basic/min/smart-table.min.js +1 -1
  93. package/payload/starter/_basic/min/stepper.min.js +1 -1
  94. package/payload/starter/_basic/min/toggle.min.js +1 -1
@@ -0,0 +1,269 @@
1
+ # Tauri Starter: a desktop app with OzdenUI and Rust
2
+
3
+ [![Tests](https://github.com/bug7a/ozdenui-tauri-template/actions/workflows/tests.yml/badge.svg)](https://github.com/bug7a/ozdenui-tauri-template/actions/workflows/tests.yml)
4
+ [![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
5
+
6
+ A desktop app made with [Tauri 2](https://tauri.app/) (OzdenUI for Tauri): the window is a page written with OzdenUI
7
+ ([basic.js](https://bug7a.github.io/basic.js/) and its components) in plain JavaScript, and the work is done in
8
+ Rust. The page has no npm, no bundler and no build step: its files are served as they are. The app is 3.6 MB on macOS.
9
+
10
+ <p align="center">
11
+ <img src="images/app.png" width="800"
12
+ alt="The window of Tauri Starter on macOS: a top bar with the buttons Up, Home, Open... and Sizes, the path of the folder, a Hidden files check box, a table of the folders and files with their kind, size and date, and a status bar">
13
+ </p>
14
+
15
+ The app is a small file browser. Each of its three parts is one way the page and Rust work together:
16
+
17
+ 1. **Folders: the page asks, Rust answers.** Rust reads a folder (`list_folder`), the page shows it in a table with
18
+ its path, a filter and "Hidden files". The keys: ↑ ↓, Page Up / Page Down, Home / End, Enter opens a folder,
19
+ Cmd / Ctrl + ↑ goes up.
20
+ 2. **Sizes: Rust sends events.** Rust measures every folder inside in a thread; the rows get their sizes one by one,
21
+ the status bar counts the files, "Stop" stops the job.
22
+ 3. **Open...: a plugin of Tauri.** The folder dialog of the system, from `tauri-plugin-dialog`, with no Rust code of
23
+ the app (Cmd / Ctrl + O).
24
+
25
+ - **The site:** https://bug7a.github.io/ozdenui-tauri-template/
26
+ - **The handbook** (11 chapters, from the first run to a release):
27
+ [English](handbook/README.md) · [Türkçe](handbook/turkce/README.md) · or as a web page:
28
+ https://bug7a.github.io/ozdenui-tauri-template/handbook/
29
+ - **With an AI assistant:** [AGENTS.md](AGENTS.md) (below).
30
+
31
+ A community template: it is not an official project of Tauri.
32
+
33
+ ## What you need (once)
34
+
35
+ 1. **Rust** 1.90 or newer: https://rustup.rs/
36
+ 2. **The tools of your system:**
37
+ - macOS: `xcode-select --install`
38
+ - Windows: "Desktop development with C++" of the Microsoft C++ Build Tools, and WebView2 (it is in Windows 11, and
39
+ in Windows 10 from version 1803).
40
+ - Linux (Debian / Ubuntu):
41
+ `sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev`.
42
+ Other systems: https://tauri.app/start/prerequisites/
43
+ 3. **The Tauri CLI:** `cargo install tauri-cli --version "^2" --locked` (it compiles for some minutes).
44
+
45
+ ## Start a project
46
+
47
+ - On GitHub: **Use this template** (https://github.com/bug7a/ozdenui-tauri-template/generate), then clone your new
48
+ repository.
49
+ - With npm: `npm create basicjs@latest my-app -- --template tauri`
50
+ - Or download this repository and copy its folder.
51
+
52
+ ## Run it
53
+
54
+ In the folder of the project:
55
+
56
+ ```sh
57
+ cargo tauri dev
58
+ ```
59
+
60
+ The first run compiles about 250 to 290 crates (56 seconds on an Apple Silicon Mac; some minutes on a slower
61
+ computer); the next runs take seconds. A change in `ui/` reloads the window; a change in `src-tauri/src/` compiles
62
+ and starts the app again.
63
+
64
+ The page opens in a browser too, without Rust (through a web server, Ex: Live Server of VS Code): it shows sample
65
+ folders and a sample measure there (`Backend.isInApp()` in `ui/backend.js`), so the look of the page can be made
66
+ without the app.
67
+
68
+ ## Build the app
69
+
70
+ ```sh
71
+ cargo tauri build
72
+ ```
73
+
74
+ | System (2026-11-20) | Time | The app | The installers |
75
+ |---|---|---|---|
76
+ | macOS (Apple Silicon) | 2 min 7 s | `Tauri Starter.app` 3.6 MB | `.dmg` 1.7 MB |
77
+ | Windows 11 (x64) | 2 min 14 s | `tauri-starter.exe` 3.6 MB | `-setup.exe` 1.4 MB, `.msi` 1.9 MB |
78
+ | Linux | | | `.deb`, `.rpm`, `.AppImage` |
79
+
80
+ The files are in `src-tauri/target/release/bundle/`. `src-tauri/Cargo.toml` asks for a small app
81
+ (`[profile.release]`), so a release build takes longer than a dev build.
82
+
83
+ **A release on GitHub:** write the version in `src-tauri/Cargo.toml` (`version = "0.1.0"`), commit, then push a tag
84
+ of the same version:
85
+
86
+ ```sh
87
+ git tag v0.1.0
88
+ git push origin v0.1.0
89
+ ```
90
+
91
+ `.github/workflows/build.yml` builds the app for macOS (Apple Silicon and Intel), Windows and Linux and puts the
92
+ installers into a **draft** release: look at it on the Releases page, then publish it.
93
+
94
+ **Not signed with a certificate:** the system of a user asks once before it opens the app. macOS: System Settings >
95
+ Privacy & Security > "Open Anyway" (on macOS 14 and older: right click on the app > Open). Windows: "More info" >
96
+ "Run anyway". A certificate removes the question: https://tauri.app/distribute/ (chapter 10 of the handbook).
97
+
98
+ ## The three patterns in short
99
+
100
+ **1. A command.** Rust (`src-tauri/src/files.rs`):
101
+
102
+ ```rust
103
+ #[tauri::command(async)]
104
+ pub fn list_folder(app: tauri::AppHandle, path: String, show_hidden: bool) -> Result<Folder, String> { ... }
105
+ ```
106
+
107
+ It is added to the app in `src-tauri/src/main.rs`, and the page calls it in `ui/backend.js`:
108
+
109
+ ```rust
110
+ .invoke_handler(tauri::generate_handler![files::list_folder, sizes::measure_folder, sizes::stop_measure])
111
+ ```
112
+
113
+ ```js
114
+ Backend.listFolder = function (path, showHidden) {
115
+ if (!Backend.isInApp()) return Backend.listSampleFolder(path, showHidden);
116
+ return window.__TAURI__.core.invoke("list_folder", { path: path, showHidden: showHidden });
117
+ };
118
+ ```
119
+
120
+ The arguments are camelCase in JavaScript and snake_case in Rust (`showHidden` is `show_hidden`); an `Err` of Rust
121
+ is the error of the promise. `window.__TAURI__` is there because of `"withGlobalTauri": true` in
122
+ `src-tauri/tauri.conf.json`.
123
+
124
+ **2. Events.** The command starts a thread and answers at once; the thread sends events (`src-tauri/src/sizes.rs`)
125
+ and the page listens to them (`ui/sizes.js`):
126
+
127
+ ```rust
128
+ let _ = app.emit("measure-folder", folder_size);
129
+ ```
130
+
131
+ ```js
132
+ Backend.listen("measure-folder", Sizes.showFolderSize);
133
+ ```
134
+
135
+ **3. A plugin.** `cargo tauri add dialog` wrote the line of `Cargo.toml`, the `.plugin(...)` line of `main.rs` and the
136
+ permission `"dialog:default"` in `src-tauri/capabilities/default.json` (made narrower there: `"dialog:allow-open"`,
137
+ the only dialog the page opens). The page calls it:
138
+
139
+ ```js
140
+ Backend.chooseFolder = function (startPath) {
141
+ if (!Backend.isInApp()) return Promise.resolve(Backend.SAMPLE_CHOSEN_FOLDER);
142
+ return window.__TAURI__.dialog.open({ directory: true, defaultPath: startPath });
143
+ };
144
+ ```
145
+
146
+ Each pattern, step by step, with a new command, a new event and a second plugin: chapters 4, 5 and 6 of the handbook.
147
+
148
+ ## Tests
149
+
150
+ In `src-tauri/`:
151
+
152
+ ```sh
153
+ cargo test # 10 tests: the Rust functions, and 4 that read the page and Rust together
154
+ cargo run --features window-check # the page in its real window
155
+ cargo fmt --check
156
+ cargo clippy --all-targets --features window-check
157
+ ```
158
+
159
+ - The work of the commands is in functions without Tauri (`read_folder`, `add_folder`), so `cargo test` tests them
160
+ without a window. `src-tauri/tests/project.rs` reads the files: a command the page calls that Rust does not have, a
161
+ command that is not in `generate_handler!`, a plugin without its permission, a `<script>` in a page of `ui/` that
162
+ holds code or a web address.
163
+ - **The window check** opens the real window for a few seconds, uses the page as a person would (a folder, Hidden
164
+ files, an error, Sizes, Up, the plugin, the security policy, a file named like an HTML tag), prints a `PASS` or
165
+ `FAIL` line for every step and closes the app: 17 lines on macOS, 15 on Windows (a name with `<` or `>` can not
166
+ be made there, so the two steps of the tag are left out), then `WINDOW CHECK: ALL PASS`. Its steps are in
167
+ `checks/window-check.js`; add one for a feature of yours.
168
+ - `.github/workflows/tests.yml` runs all four on Linux, macOS and Windows at every push.
169
+
170
+ ## With an AI assistant
171
+
172
+ [AGENTS.md](AGENTS.md) is what an AI assistant (Claude Code, Codex, Cursor, Copilot...) must know to change this app:
173
+ where the truth is, the three patterns, the rules of a basic.js page, the mistakes to avoid and the checks to run
174
+ before it says it is done. Claude Code reads it through `CLAUDE.md` (one line: `@AGENTS.md`); most other tools read
175
+ `AGENTS.md` by themselves. An assistant that can not read the files (a chat) can read the same text on the site:
176
+ https://bug7a.github.io/ozdenui-tauri-template/llms.txt
177
+
178
+ Keep `AGENTS.md` true when your app grows: a new pattern or a rule of your own goes there.
179
+
180
+ ## The files
181
+
182
+ ```text
183
+ ui/ THE PAGE
184
+ index.html loads the files below, in this order
185
+ basic/ basic.js v26.11.10 (a copy: do not edit it)
186
+ comp/components.min.js the components of the page (a copy; comp/_sources.txt lists them)
187
+ backend.js every call to Rust and every event of Rust; the sample data of a browser
188
+ app.js the page, example 1 (Folders) and 3 (Open...)
189
+ sizes.js example 2 (Sizes)
190
+ src-tauri/ THE RUST SIDE
191
+ Cargo.toml the name and the version of the app, the crates
192
+ tauri.conf.json the window, the security policy (CSP), the installers
193
+ capabilities/default.json what the page may use (core:default, dialog:allow-open)
194
+ src/main.rs starts the app: the plugin, the state, the commands
195
+ src/files.rs example 1: the command list_folder, and its tests
196
+ src/sizes.rs example 2: the commands measure_folder and stop_measure, the events, and their tests
197
+ src/check.rs the window check (only with --features window-check)
198
+ tests/project.rs the tests that read the page and Rust together
199
+ app-icon.svg, icons/ the icon
200
+ checks/window-check.js the steps of the window check
201
+ .github/workflows/ tests.yml (every push), build.yml (a tag: the release)
202
+ handbook/ the handbook (English, turkce/)
203
+ AGENTS.md, CLAUDE.md the rules for an AI assistant
204
+ ```
205
+
206
+ ## Make it your own
207
+
208
+ 1. `src-tauri/tauri.conf.json`: `productName`, `identifier` (a reversed domain of yours, Ex:
209
+ `com.yourname.notes`), the window (`title`, `width`, `height`) and `bundle` (`publisher`, `copyright`,
210
+ `homepage`, `shortDescription`).
211
+ 2. `src-tauri/Cargo.toml`: `name`, `version`, `description`, `authors`.
212
+ 3. The icon: `cargo tauri icon my-icon.svg` in `src-tauri/` (a square SVG, or a PNG of 1024 px) writes every size
213
+ into `src-tauri/icons/`; keep the five files that `tauri.conf.json` names and delete the others.
214
+ 4. The page: `ui/app.js` (`start()` runs first). Keep `ui/backend.js` as the one place that calls Rust.
215
+ 5. Another component: put its file from the `comp/` folder of [js-components](https://github.com/bug7a/js-components)
216
+ into `ui/comp/` and load it in `ui/index.html` after `components.min.js`
217
+ (`<script src="comp/tooltip.js" type="text/javascript" charset="utf-8"></script>`). A component that extends
218
+ another loads after it. A component file needs a basic.js at least as new as the one it was written for.
219
+ 6. Without an example: take out its files and its lines. Sizes: `ui/sizes.js` and its `<script>`,
220
+ `src-tauri/src/sizes.rs`, its lines in `main.rs`, the `Sizes.` lines of `ui/app.js` and the measure functions of
221
+ `ui/backend.js`, then its steps in `checks/window-check.js`. `cargo test` and the window check tell what is left.
222
+ 7. The files of the template itself: this README, `images/`, `handbook/` and `docs/` (the site). Write your own
223
+ README; keep the handbook if it helps you.
224
+
225
+ ## Security
226
+
227
+ - **The security policy** (`csp` in `src-tauri/tauri.conf.json`): scripts only from the files of the app (no `eval`,
228
+ no script made from a text, no `onclick` attribute, no script from the web), styles from code (basic.js writes
229
+ them), pictures from the app and from `data:` / `blob:` addresses (the icons are SVG texts), and the calls to Rust.
230
+ The window check proves that a text does not run as code. (A `<script>` written in `ui/index.html` itself, with
231
+ code or with a web address, would run: Tauri adds its hash or a nonce to the policy when it builds the app. A
232
+ project test of `cargo test` stops both.)
233
+ - **The permissions** (`src-tauri/capabilities/default.json`): the core of Tauri and the folder dialog of the plugin
234
+ (`dialog:allow-open`: not its save or message dialogs, which the page does not use). The
235
+ commands of the app need no line; each new plugin adds its own.
236
+ - **A name is shown as text:** the page writes every name that comes from Rust with `plainText`, so a file named like
237
+ an HTML tag stays a name.
238
+ - `list_folder` reads any folder the page asks for: right for a file browser, a thing to limit in another app
239
+ (chapter 8 of the handbook).
240
+
241
+ ## Speed (2026-11-04, the release build, Apple M1 with 8 GB)
242
+
243
+ | A folder of | Rust reads it | The answer reaches the page | The rows are on the screen |
244
+ |---|---|---|---|
245
+ | 23 entries | 0.3 ms | 1 ms | 80 ms |
246
+ | 932 entries (`/usr/bin`) | 5 ms | 6 ms | 66 ms |
247
+ | 10,000 entries | 22 ms | 29 ms | 62 ms |
248
+ | 100,000 entries | 226 ms | 302 ms | 89 ms |
249
+
250
+ - `SmartTable` makes only the rows that are seen, so the time of the table does not grow with the folder.
251
+ - Rust sends at most 100,000 entries of a folder (`MAX_ENTRIES` in `files.rs`).
252
+ - "Sizes" on `/usr` (68,000 files, 3.2 GB) took 1.7 s, with 17 progress events; the page drew 60 frames a second
253
+ meanwhile.
254
+
255
+ ## Good to know
256
+
257
+ - macOS asks once before the app reads Desktop, Documents or Downloads (under `cargo tauri dev` it asks for your
258
+ terminal or editor). A refused folder gives an error message; "Sizes" skips the folders it can not read.
259
+ - "Sizes" counts the bytes of the files (as the "Size" of Finder, not the room on the disk) and does not follow links.
260
+ - `src-tauri/target/` is the compiled app (some GB). It is not in git; `cargo clean` in `src-tauri/` deletes it.
261
+ - Tried on macOS (Apple Silicon) and Windows 11 on 2026-11-20: the tests, the window check and the release build.
262
+ Linux is built and checked by the workflows of this repository.
263
+
264
+ ## License
265
+
266
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
267
+ Licensed under the Apache License, Version 2.0 (see `LICENSE` and `NOTICE`), the same as basic.js.
268
+
269
+ Developed with the help of Claude Code (Anthropic).
@@ -0,0 +1,189 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ window-check.js - Tauri Starter v0.1 (OzdenUI for Tauri)
6
+
7
+ THE WINDOW CHECK: this script plays the page in the real window of the app and tells Rust what it saw.
8
+ Run it in src-tauri/: cargo run --features window-check
9
+ Rust (src-tauri/src/check.rs) makes a small folder (window.CHECK.folder: "b-folder" with a file of 3 bytes in it,
10
+ "a-file.txt" of 5 bytes, ".hidden-file" and, not on Windows, a folder whose name is an HTML tag: window.CHECK.tagName),
11
+ runs this script when the page is loaded, prints its lines and closes the app. The exit code is 0 when no line failed.
12
+ The errors of the page are kept by check.rs from its first line (window.CHECK_PAGE_ERRORS), also the ones of its load.
13
+
14
+ A CHECK OF YOUR OWN: add a step to WindowCheck.run() below. A step waits for what the page shows
15
+ (await WindowCheck.until(...)) and says what it saw (WindowCheck.expect(...)).
16
+ It must not open a dialog of the system: that waits for a person.
17
+
18
+ Started Date: November 2026
19
+ Webpage: https://bug7a.github.io/ozdenui-tauri-template/
20
+
21
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
22
+ Licensed under the Apache License, Version 2.0
23
+ SPDX-License-Identifier: Apache-2.0
24
+
25
+ */
26
+
27
+ "use strict";
28
+
29
+ const WindowCheck = {};
30
+
31
+ WindowCheck.WAIT_LIMIT = 10000; // ms: the longest wait for one step
32
+ WindowCheck.WAIT_STEP = 50; // ms
33
+ WindowCheck.lines = [];
34
+ WindowCheck.failed = 0;
35
+ // WHY from check.rs: it keeps the errors of the page from its first line, also the ones while the page loaded
36
+ WindowCheck.pageErrors = window.CHECK_PAGE_ERRORS || [];
37
+
38
+ // USAGE: WindowCheck.expect(names.length == 2, "the folder has two entries")
39
+ WindowCheck.expect = function (isTrue, text) {
40
+ WindowCheck.lines.push((isTrue ? "PASS " : "FAIL ") + text);
41
+ if (!isTrue) WindowCheck.failed++;
42
+ };
43
+
44
+ // Waits until isReady() is true. A step that never comes is a FAIL line, and the check goes on.
45
+ WindowCheck.until = function (isReady, text) {
46
+ return new Promise(function (resolve) {
47
+ const started = Date.now();
48
+ const look = function () {
49
+ if (isReady()) return resolve(true);
50
+ if (Date.now() - started > WindowCheck.WAIT_LIMIT) {
51
+ WindowCheck.expect(false, "waited " + (WindowCheck.WAIT_LIMIT / 1000) + " s for: " + text);
52
+ return resolve(false);
53
+ }
54
+ setTimeout(look, WindowCheck.WAIT_STEP);
55
+ };
56
+ look();
57
+ });
58
+ };
59
+
60
+ WindowCheck.namesOf = function (folder) {
61
+ return folder.entries.map(function (entry) { return entry.name; }).join(", ");
62
+ };
63
+
64
+ WindowCheck.entryOf = function (name) {
65
+ return currentFolder.entries.find(function (entry) { return entry.name == name; });
66
+ };
67
+
68
+ WindowCheck.tableShows = function (text) {
69
+ return table.elem.textContent.includes(text);
70
+ };
71
+
72
+ WindowCheck.isShown = function (path) {
73
+ return Boolean(currentFolder) && currentFolder.path == path;
74
+ };
75
+
76
+ WindowCheck.open = function (path) {
77
+ openFolder(path);
78
+ return WindowCheck.until(function () { return WindowCheck.isShown(path); }, "the folder " + path);
79
+ };
80
+
81
+ // A style that the code of the page makes (basic.js and the components do) must pass the security policy
82
+ WindowCheck.isCodeStyleApplied = function () {
83
+ const style = document.createElement("style");
84
+ style.textContent = ".window-check-probe { width: 7px; }";
85
+ const probe = document.createElement("div");
86
+ probe.className = "window-check-probe";
87
+ document.head.appendChild(style);
88
+ document.body.appendChild(probe);
89
+ const isApplied = getComputedStyle(probe).width == "7px";
90
+ style.remove();
91
+ probe.remove();
92
+ return isApplied;
93
+ };
94
+
95
+ // The security policy lets no text run as code (no 'unsafe-eval'): where it does, the policy is off
96
+ WindowCheck.canRunTextAsCode = function () {
97
+ try {
98
+ return new Function("return 1")() == 1;
99
+ } catch (error) {
100
+ return false;
101
+ }
102
+ };
103
+
104
+ // WHY getAttribute: an icon that has no file yet (a row that is not filled) is not a broken picture
105
+ WindowCheck.pictures = function () {
106
+ return Array.from(document.images).filter(function (image) {
107
+ return Boolean(image.getAttribute("src"));
108
+ });
109
+ };
110
+
111
+ WindowCheck.pictureCount = function () {
112
+ return WindowCheck.pictures().length;
113
+ };
114
+
115
+ WindowCheck.brokenPictureCount = function () {
116
+ return WindowCheck.pictures().filter(function (image) {
117
+ return image.complete && image.naturalWidth == 0;
118
+ }).length;
119
+ };
120
+
121
+ WindowCheck.run = async function () {
122
+
123
+ const folderPath = CHECK.folder;
124
+
125
+ // The page in the app
126
+ WindowCheck.expect(Backend.isInApp(), "the page runs in the app (window.__TAURI__)");
127
+ await WindowCheck.until(function () { return Boolean(currentFolder); }, "the home folder");
128
+ WindowCheck.expect(Boolean(currentFolder) && currentFolder.crumbs.length > 0, "the home folder is listed by Rust");
129
+ // The content security policy of tauri.conf.json (app.security.csp): it is on, and the page works with it
130
+ WindowCheck.expect(!WindowCheck.canRunTextAsCode(), "the security policy is on (a text does not run as code)");
131
+ WindowCheck.expect(WindowCheck.isCodeStyleApplied(), "a style made by the code is applied (style-src of the security policy)");
132
+ WindowCheck.expect(WindowCheck.pictureCount() > 0 && WindowCheck.brokenPictureCount() == 0, "the icons are drawn (img-src of the security policy): " + WindowCheck.pictureCount() + " pictures, " + WindowCheck.brokenPictureCount() + " broken");
133
+
134
+ // THE FIRST EXAMPLE: the page asks, Rust answers
135
+ await WindowCheck.open(folderPath);
136
+ const expectedNames = ["b-folder", "a-file.txt"];
137
+ // WHY first: the folders come first, and "<" is before the letters
138
+ if (CHECK.tagName) expectedNames.unshift(CHECK.tagName);
139
+ WindowCheck.expect(WindowCheck.namesOf(currentFolder) == expectedNames.join(", "), "the folders come first, the hidden file is not listed: " + WindowCheck.namesOf(currentFolder));
140
+ WindowCheck.expect(WindowCheck.entryOf("b-folder").isFolder === true && WindowCheck.entryOf("a-file.txt").size == 5, "an entry tells its kind and its size (isFolder, size)");
141
+ // WHY a wait: the table draws its rows a moment after it gets them
142
+ await WindowCheck.until(function () { return WindowCheck.tableShows("a-file.txt"); }, "the rows of the table");
143
+ WindowCheck.expect(WindowCheck.tableShows("a-file.txt") && WindowCheck.tableShows("b-folder"), "the table shows the entries");
144
+
145
+ chkHidden.setChecked(1);
146
+ await WindowCheck.until(function () { return Boolean(WindowCheck.entryOf(".hidden-file")); }, "the hidden file");
147
+ WindowCheck.expect(currentFolder.entries.length == expectedNames.length + 1, "Hidden files: the hidden file is listed too");
148
+
149
+ const missingError = await Backend.listFolder(folderPath + "-missing", false).then(function () { return ""; }, String);
150
+ WindowCheck.expect(missingError.includes("-missing"), "a folder that is not there is an error with a text: " + missingError);
151
+
152
+ // A name is a text, never HTML: the table, the path and an error toast show the name of the tag folder
153
+ if (CHECK.tagName) {
154
+ const tagPath = WindowCheck.entryOf(CHECK.tagName).path;
155
+ await WindowCheck.open(tagPath);
156
+ showError(tagPath + ": an error of the check");
157
+ WindowCheck.expect(crumbs.elem.textContent.includes(CHECK.tagName), "the path shows a name with a tag in it as it is written");
158
+ WindowCheck.expect(!document.querySelector('img[src="x"]') && !window.CHECK_TAG_RAN, "a name with a tag in it does not become HTML (the table, the path, a toast)");
159
+ await WindowCheck.open(folderPath);
160
+ }
161
+
162
+ // THE SECOND EXAMPLE: Rust sends events
163
+ const insidePath = WindowCheck.entryOf("b-folder").path;
164
+ Sizes.start();
165
+ await WindowCheck.until(function () { return Sizes.job == 0 && Sizes.sizeOf(insidePath) != NO_SIZE; }, "the events of the measure");
166
+ WindowCheck.expect(Sizes.sizeOf(insidePath) == 3, "Sizes: the events give the folder inside its size (3 bytes): " + Sizes.sizeOf(insidePath));
167
+ WindowCheck.expect(lblSpeed.elem.textContent.includes("Measured by Rust"), "Sizes: the status bar tells the end: " + lblSpeed.elem.textContent);
168
+
169
+ // THE THIRD EXAMPLE: a plugin of Tauri (the dialog itself waits for a person: only its function is looked at)
170
+ const dialog = window.__TAURI__.dialog;
171
+ WindowCheck.expect(Boolean(dialog) && typeof dialog.open == "function", "the dialog plugin is in the page (window.__TAURI__.dialog.open)");
172
+
173
+ openParent();
174
+ await WindowCheck.until(function () { return !WindowCheck.isShown(folderPath); }, "the folder above");
175
+ WindowCheck.expect(btnUp.enabled == 1 && currentFolder.entries.length > 0, "Up opens the folder above");
176
+
177
+ WindowCheck.expect(WindowCheck.pageErrors.length == 0, "no error in the page" + (WindowCheck.pageErrors.length ? ": " + WindowCheck.pageErrors.join(" | ") : ""));
178
+
179
+ };
180
+
181
+ WindowCheck.run()
182
+ .catch(function (error) {
183
+ // WHY the errors of the page too: a mistake in a script shows here first as a name that is missing
184
+ const pageErrors = WindowCheck.pageErrors.length ? " (errors of the page: " + WindowCheck.pageErrors.join(" | ") + ")" : "";
185
+ WindowCheck.expect(false, "the check stopped: " + error + pageErrors);
186
+ })
187
+ .then(function () {
188
+ window.__TAURI__.event.emit("check-done", { lines: WindowCheck.lines, failed: WindowCheck.failed });
189
+ });
@@ -0,0 +1,8 @@
1
+ # The compiled app and the schemas of the editor are named in src-tauri/.gitignore
2
+
3
+ # The files of the systems
4
+ .DS_Store
5
+ Thumbs.db
6
+
7
+ # Your own notes
8
+ _notes*.md
@@ -0,0 +1,188 @@
1
+ # 1. Getting started
2
+
3
+ *Türkçe: [1. Başlarken](turkce/01-getting-started.md)*
4
+
5
+ This chapter sets up your computer once, makes your copy of the template and runs it. At the end you change a text of
6
+ the page and a line of Rust, and see both in the window.
7
+
8
+ ## What you make
9
+
10
+ A desktop app: one program of a few MB (the app of the template is 3.6 MB on an Apple Silicon Mac, 2026-11-20), with
11
+ its installers for macOS, Windows and Linux.
12
+
13
+ - **The page** is what the window shows: plain JavaScript files in `ui/`, written with
14
+ [basic.js](https://bug7a.github.io/basic.js/). No npm, no bundler, no build step for the page: its files are used as
15
+ they are.
16
+ - **The Rust side** in `src-tauri/` does what a page can not do by itself: it reads the folders of the computer, runs a
17
+ long job in a thread, opens a dialog of the system.
18
+ - **[Tauri 2](https://tauri.app/)** joins the two: it opens the window with the web view of the system (WebKit on
19
+ macOS, WebView2 on Windows, WebKitGTK on Linux) and carries the calls between the page and Rust.
20
+
21
+ The app of the template is a small file browser. Each of its three parts is one way the page and Rust work together;
22
+ chapters 4, 5 and 6 take them one by one.
23
+
24
+ ## Set up once
25
+
26
+ **1. Rust**, 1.90 or newer: https://rustup.rs/. It brings `cargo`, the tool that downloads the crates, compiles the
27
+ app and runs it. A *crate* is a package of Rust code: Tauri itself and every library of the app are crates, and
28
+ `cargo` takes them from crates.io the first time they are needed.
29
+
30
+ **2. The tools of your system:**
31
+
32
+ - macOS:
33
+
34
+ ```sh
35
+ xcode-select --install
36
+ ```
37
+
38
+ - Windows: "Desktop development with C++" of the Microsoft C++ Build Tools, and WebView2 (it is in Windows 11, and in
39
+ Windows 10 from version 1803).
40
+ - Linux (Debian / Ubuntu):
41
+
42
+ ```sh
43
+ sudo apt install libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev \
44
+ libssl-dev libayatana-appindicator3-dev librsvg2-dev
45
+ ```
46
+
47
+ - Other systems: https://tauri.app/start/prerequisites/
48
+
49
+ **3. The Tauri CLI:**
50
+
51
+ ```sh
52
+ cargo install tauri-cli --version "^2" --locked
53
+ ```
54
+
55
+ It compiles for some minutes. `--version "^2"` asks for a version 2 of the CLI, the one of Tauri 2. It adds the
56
+ command `cargo tauri`, which the handbook uses everywhere: `cargo tauri dev` runs the app while you work,
57
+ `cargo tauri build` makes the app and its installers (chapter 10), `cargo tauri add` adds a plugin (chapter 6).
58
+
59
+ Is everything there? Each of these prints a version:
60
+
61
+ ```sh
62
+ rustc --version
63
+ cargo tauri --version
64
+ ```
65
+
66
+ `rustc` must be 1.90 or newer (`rustup update` brings a newer one), and the CLI `tauri-cli 2.` and more numbers. When
67
+ the terminal does not know a command, open a new terminal and try again: an install changes only the terminals opened
68
+ after it. Chapter 11 has the rest.
69
+
70
+ ## Your copy of the template
71
+
72
+ Three ways; each gives the same folder:
73
+
74
+ - On GitHub: **Use this template** (https://github.com/bug7a/ozdenui-tauri-template/generate) makes a repository of
75
+ yours from it. Then clone your new repository to your computer.
76
+ - With npm. npm is needed only for this one command (the project itself has no npm); it makes the folder `my-app`:
77
+
78
+ ```sh
79
+ npm create basicjs@latest my-app -- --template tauri
80
+ ```
81
+
82
+ - Or download the repository (https://github.com/bug7a/ozdenui-tauri-template) and copy its folder.
83
+
84
+ The folder of the project, its *root*, holds `ui/` (the page), `src-tauri/` (the Rust side), `checks/` (the window
85
+ check), `handbook/` (this handbook), `README.md` and `AGENTS.md`. Chapter 2 goes through every file.
86
+
87
+ ## Run it
88
+
89
+ In the root of the project:
90
+
91
+ ```sh
92
+ cargo tauri dev
93
+ ```
94
+
95
+ The first run downloads and compiles about 250 to 290 crates: 56 seconds on an Apple Silicon Mac (2026-11-20), some
96
+ minutes on a slower computer. The next runs take seconds: the compiled crates are kept in `src-tauri/target/`.
97
+
98
+ The window opens (960 x 640) with your home folder in it:
99
+
100
+ - **The top bar:** the buttons Up, Home, Open... and Sizes, the path of the folder (click a part of it to go there)
101
+ and Hidden files.
102
+ - **The table:** the folders first, then the files, with their kind, size and date. A click on a title sorts by it;
103
+ "Filter" under the rows looks at the names.
104
+ - **The status bar:** the counts on the left; on the right, the time Rust took to read the folder
105
+ (Ex: "Read by Rust in 0.4 ms").
106
+
107
+ Try the three examples:
108
+
109
+ 1. **Folders: the page asks, Rust answers.** Click a folder. Every folder you open is one call to Rust
110
+ (`list_folder`), and its answer is the list of the table.
111
+ 2. **Sizes: Rust sends events.** Click Sizes. Rust measures every folder inside in a thread; the rows get their sizes
112
+ one by one and the status bar counts the files. The button says Stop while it works.
113
+ 3. **Open...: a plugin of Tauri.** The folder dialog of the system opens; the folder you choose is listed.
114
+
115
+ The keys: click a row, then ↑ ↓, Page Up / Page Down, Home / End; Enter opens a folder; Cmd / Ctrl + ↑ goes to the
116
+ folder above; Cmd / Ctrl + O is "Open...".
117
+
118
+ ## A first change in the page
119
+
120
+ Leave the app running. In `ui/app.js`, find `showSpeed` and change its last text:
121
+
122
+ ```js
123
+ // "Rust read it in 0.4 ms". In a browser: the sample data.
124
+ const showSpeed = function (folder) {
125
+ if (!Backend.isInApp()) {
126
+ lblSpeed.plainText = "Sample data: run the app with cargo tauri dev";
127
+ return;
128
+ }
129
+ lblSpeed.plainText = "Rust read it in " + formatMillis(folder.millis);
130
+ };
131
+ ```
132
+
133
+ Save the file: the window loads the page again and the status bar shows the new text. Nothing is compiled for a
134
+ change in `ui/`.
135
+
136
+ ## A first change in Rust
137
+
138
+ `src-tauri/src/files.rs` sends at most 100,000 entries of a folder to the page:
139
+
140
+ ```rust
141
+ const MAX_ENTRIES: usize = 100_000;
142
+ ```
143
+
144
+ Make it 3 and save. `cargo tauri dev` sees the change, compiles the app again (some seconds) and starts it again.
145
+ The window opens your home folder, and the table has only its first 3 entries. The status bar tells it (Ex: a home
146
+ folder of 25 entries):
147
+
148
+ ```text
149
+ The first 3 of 25 items: 3 folders, 0 files
150
+ ```
151
+
152
+ Then write `100_000` again.
153
+
154
+ - `const` is a value with a name that never changes. `usize` is its type: a whole number that is never below 0, the
155
+ type Rust uses for counts. `100_000` is 100000: the `_` only makes it easier to read.
156
+ - A change in `src-tauri/src/` builds the program again and starts a new window; a change in `ui/` only reloads the
157
+ page. So a page that is being made is faster to try than Rust.
158
+ - A mistake in the Rust code is shown in the terminal, with its file and its line.
159
+
160
+ ## The page in a browser
161
+
162
+ The page also opens in a browser, without Rust: open `ui/index.html` through a web server (Ex: Live Server of VS
163
+ Code). `Backend.isInApp()` in `ui/backend.js` tells that there is no Rust, and the page gets sample answers instead:
164
+ a few folders under `/Users/you`, a sample measure for Sizes, and a sample answer of the folder dialog. The status
165
+ bar says:
166
+
167
+ ```text
168
+ Sample data: run the app with cargo tauri dev
169
+ ```
170
+
171
+ It is useful while you make the look of the page: it needs only a browser, also on a computer without Rust. The
172
+ sample answers are not a test of Rust, and the security policy of the window is not there in a browser: try the
173
+ result in the window too ([3. The page](03-the-page.md), [9. Tests and checks](09-tests-and-checks.md)).
174
+
175
+ ## Stopping the app
176
+
177
+ Close the window: the app ends. Or press Ctrl + C in the terminal where `cargo tauri dev` runs.
178
+
179
+ ## What macOS asks the first time
180
+
181
+ macOS asks once before the app reads Desktop, Documents or Downloads. Under `cargo tauri dev` it asks for your
182
+ terminal or your editor, the program that started the app. A folder you refused gives an error message in the window
183
+ ("The folder could not be opened"), and Sizes skips the folders it can not read.
184
+
185
+ ## Next
186
+
187
+ [2. The project](02-the-project.md): every file of the template, what happens when the app starts, and how to make it
188
+ your own.