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
package/README.md CHANGED
@@ -17,6 +17,16 @@ npm create basicjs@latest my-shop -- --template shop # shop, booking, coffee
17
17
  npm create basicjs@latest -- --list
18
18
  ```
19
19
 
20
+ A desktop app (Tauri 2: a basic.js page and a Rust side; it needs Rust and the Tauri CLI):
21
+
22
+ ```sh
23
+ npm create basicjs@latest my-app -- --template tauri
24
+ cd my-app
25
+ cargo tauri dev
26
+ ```
27
+
28
+ Its documents: [OzdenUI for Tauri](https://bug7a.github.io/ozdenui-tauri-template/).
29
+
20
30
  ## Tools in a project
21
31
 
22
32
  | Command | What it does |
@@ -3,6 +3,7 @@
3
3
 
4
4
  // npm create basicjs@latest my-app
5
5
  // npm create basicjs@latest my-app -- --template shop
6
+ // npm create basicjs@latest my-app -- --template tauri (a desktop app: a whole project of its own)
6
7
  // npx create-basicjs@latest update (in a project: replaces only _basic/)
7
8
 
8
9
  const crypto = require("crypto");
@@ -12,6 +13,8 @@ const path = require("path");
12
13
  const PACKAGE = path.resolve(__dirname, "..");
13
14
  const STARTER = path.join(PACKAGE, "payload", "starter");
14
15
  const TEMPLATES = path.join(PACKAGE, "payload", "templates");
16
+ // WHY a folder of its own: these are whole projects (a desktop app with its Rust side), not pages over the starter
17
+ const PROJECTS = path.join(PACKAGE, "payload", "projects");
15
18
  const VERSION = JSON.parse(fs.readFileSync(path.join(PACKAGE, "package.json"), "utf8")).version;
16
19
  const DEFAULT_FOLDER = "my-app";
17
20
 
@@ -19,6 +22,7 @@ const HELP = `create-basicjs ${VERSION}
19
22
 
20
23
  npm create basicjs@latest my-app a new project
21
24
  npm create basicjs@latest my-app -- --template shop a project from a template
25
+ npm create basicjs@latest my-app -- --template tauri a desktop app (Tauri 2 and Rust)
22
26
  npm create basicjs@latest -- --list the templates
23
27
  npx create-basicjs@latest update in a project: replaces only _basic/
24
28
  `;
@@ -28,8 +32,13 @@ const stop = function (text) {
28
32
  process.exit(1);
29
33
  };
30
34
 
35
+ const foldersOf = function (folder) {
36
+ if (!fs.existsSync(folder)) return [];
37
+ return fs.readdirSync(folder, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
38
+ };
39
+
31
40
  const templateNames = function () {
32
- return fs.readdirSync(TEMPLATES, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
41
+ return foldersOf(TEMPLATES).concat(foldersOf(PROJECTS));
33
42
  };
34
43
 
35
44
  const readArguments = function () {
@@ -63,10 +72,27 @@ const addTemplate = function (target, name) {
63
72
  fs.cpSync(from, target, { recursive: true, force: true });
64
73
  };
65
74
 
75
+ // A whole project (Ex: tauri): its own files only, no starter under it
76
+ const createProject = function (folder, target, name) {
77
+ fs.cpSync(path.join(PROJECTS, name), target, { recursive: true });
78
+ // WHY: npm leaves a .gitignore out of a package
79
+ ["gitignore", path.join("src-tauri", "gitignore")].forEach(function (fileName) {
80
+ const file = path.join(target, fileName);
81
+ if (fs.existsSync(file)) fs.renameSync(file, path.join(path.dirname(file), ".gitignore"));
82
+ });
83
+ console.log("Ready: " + folder + " (template: " + name + ")");
84
+ console.log("\n cd " + folder + "\n cargo tauri dev\n");
85
+ console.log("It needs Rust and the Tauri CLI once: README.md, \"What you need\". The rules for an AI coding tool: AGENTS.md");
86
+ };
87
+
66
88
  const create = function (options) {
67
89
  const folder = options.folder || DEFAULT_FOLDER;
68
90
  const target = path.resolve(folder);
69
91
  if (fs.existsSync(target) && fs.readdirSync(target).length) stop(folder + " is not empty: choose another folder.");
92
+ if (options.template && fs.existsSync(path.join(PROJECTS, options.template))) {
93
+ createProject(folder, target, options.template);
94
+ return;
95
+ }
70
96
 
71
97
  fs.cpSync(STARTER, target, { recursive: true });
72
98
  fs.renameSync(path.join(target, "gitignore"), path.join(target, ".gitignore")); // WHY: npm leaves a .gitignore out of a package
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-basicjs",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Create a project with basic.js and OzdenUI, ready to build with AI tools.",
5
5
  "bin": {
6
6
  "create-basicjs": "bin/create-basicjs.js"
@@ -0,0 +1,86 @@
1
+ # Bismillah
2
+ #
3
+ # build.yml - Tauri Starter v0.1 (OzdenUI for Tauri)
4
+ # A tag builds the app for every system: push a tag that is the version of src-tauri/Cargo.toml (0.1.0 -> v0.1.0),
5
+ # and GitHub makes a draft release with the installers of macOS (Apple Silicon and Intel), Windows and Linux.
6
+ # Look at the draft on the Releases page of the repository, then publish it.
7
+ # git tag v0.1.0
8
+ # git push origin v0.1.0
9
+ # "Run workflow" on the Actions page builds the same files without a release (they are kept with the run).
10
+ # The apps are not signed with a certificate: the system of a user asks once before it opens them (README.md).
11
+ #
12
+ # Started Date: November 2026
13
+ # Webpage: https://bug7a.github.io/ozdenui-tauri-template/
14
+ #
15
+ # Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
16
+ # Licensed under the Apache License, Version 2.0
17
+ # SPDX-License-Identifier: Apache-2.0
18
+
19
+ name: Build
20
+
21
+ on:
22
+ push:
23
+ tags: ["v*"]
24
+ workflow_dispatch:
25
+
26
+ # WHY write: the workflow makes the release and puts the files into it
27
+ permissions:
28
+ contents: write
29
+
30
+ jobs:
31
+ build:
32
+ name: ${{ matrix.name }}
33
+ runs-on: ${{ matrix.os }}
34
+ timeout-minutes: 60
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ include:
39
+ - { name: macOS (Apple Silicon), os: macos-latest, target: aarch64-apple-darwin }
40
+ - { name: macOS (Intel), os: macos-latest, target: x86_64-apple-darwin }
41
+ # WHY a fixed Ubuntu: an app built on a newer Linux does not start on an older one. When GitHub retires
42
+ # this one, write the oldest Ubuntu of its list (https://github.com/actions/runner-images).
43
+ - { name: Linux, os: ubuntu-24.04, target: x86_64-unknown-linux-gnu }
44
+ - { name: Windows, os: windows-latest, target: x86_64-pc-windows-msvc }
45
+ steps:
46
+ - uses: actions/checkout@v7
47
+
48
+ - name: The tag is the version of Cargo.toml
49
+ if: startsWith(github.ref, 'refs/tags/')
50
+ shell: bash
51
+ run: |
52
+ version="$(grep -m1 '^version' src-tauri/Cargo.toml | cut -d'"' -f2)"
53
+ if [ "v$version" != "$GITHUB_REF_NAME" ]; then
54
+ echo "::error::The tag is $GITHUB_REF_NAME, but the version of src-tauri/Cargo.toml is $version. Write ${GITHUB_REF_NAME#v} as the version there and commit (or tag the commit of v$version instead), then delete the tag $GITHUB_REF_NAME and push it again."
55
+ exit 1
56
+ fi
57
+
58
+ # What Tauri needs on Linux to build the app and its installers (https://tauri.app/start/prerequisites/)
59
+ - name: The packages of the system (Linux)
60
+ if: runner.os == 'Linux'
61
+ run: |
62
+ sudo apt-get update
63
+ sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev patchelf xdg-utils
64
+
65
+ - uses: dtolnay/rust-toolchain@stable
66
+ with:
67
+ targets: ${{ matrix.target }}
68
+
69
+ - uses: Swatinem/rust-cache@v2
70
+ with:
71
+ workspaces: src-tauri
72
+ key: ${{ matrix.target }}
73
+
74
+ # The action of Tauri runs "tauri build" (it brings the Tauri CLI itself) and puts the installers into a
75
+ # draft release named after the tag. Without a tag ("Run workflow") it only builds.
76
+ - uses: tauri-apps/tauri-action@v1
77
+ env:
78
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79
+ with:
80
+ tagName: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || '' }}
81
+ releaseName: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || '' }}
82
+ releaseBody: "Download the file of your system below. macOS: the .dmg (aarch64: Apple Silicon, x64: Intel). Windows: the -setup.exe or the .msi. Linux: the .AppImage, the .deb or the .rpm."
83
+ releaseDraft: true
84
+ prerelease: false
85
+ args: --target ${{ matrix.target }}
86
+ uploadWorkflowArtifacts: ${{ !startsWith(github.ref, 'refs/tags/') }}
@@ -0,0 +1,87 @@
1
+ # Bismillah
2
+ #
3
+ # tests.yml - Tauri Starter v0.1 (OzdenUI for Tauri)
4
+ # At every push and pull request, on Linux, macOS and Windows: the code is formatted (cargo fmt), clippy finds no
5
+ # mistake, the tests pass (cargo test) and the page works in its real window (cargo run --features window-check).
6
+ #
7
+ # Started Date: November 2026
8
+ # Webpage: https://bug7a.github.io/ozdenui-tauri-template/
9
+ #
10
+ # Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
11
+ # Licensed under the Apache License, Version 2.0
12
+ # SPDX-License-Identifier: Apache-2.0
13
+
14
+ name: Tests
15
+
16
+ on:
17
+ push:
18
+ branches: [main]
19
+ # WHY: a change of the texts or of the site (docs/) can not break the app
20
+ paths-ignore: ["docs/**", "handbook/**", "**.md"]
21
+ pull_request:
22
+ workflow_dispatch:
23
+
24
+ # WHY: a newer push of a branch stops the run of the older one
25
+ concurrency:
26
+ group: tests-${{ github.ref }}
27
+ cancel-in-progress: true
28
+
29
+ permissions:
30
+ contents: read
31
+
32
+ jobs:
33
+ tests:
34
+ name: ${{ matrix.name }}
35
+ runs-on: ${{ matrix.os }}
36
+ timeout-minutes: 30
37
+ strategy:
38
+ fail-fast: false
39
+ matrix:
40
+ include:
41
+ - { name: Linux, os: ubuntu-latest }
42
+ - { name: macOS, os: macos-latest }
43
+ - { name: Windows, os: windows-latest }
44
+ defaults:
45
+ run:
46
+ working-directory: src-tauri
47
+ steps:
48
+ - uses: actions/checkout@v7
49
+
50
+ # What Tauri needs on Linux (https://tauri.app/start/prerequisites/), and xvfb: a screen for the window check
51
+ - name: The packages of the system (Linux)
52
+ if: runner.os == 'Linux'
53
+ run: |
54
+ sudo apt-get update
55
+ sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev xvfb
56
+
57
+ - uses: dtolnay/rust-toolchain@stable
58
+ with:
59
+ components: rustfmt, clippy
60
+
61
+ # WHY: the compiled crates are kept, so the next run takes a few minutes less
62
+ - uses: Swatinem/rust-cache@v2
63
+ with:
64
+ workspaces: src-tauri
65
+
66
+ - name: The code is formatted
67
+ run: cargo fmt --check
68
+
69
+ # A mistake that clippy is sure of stops the run; its warnings are only printed.
70
+ # To stop at a warning too: cargo clippy --all-targets --features window-check -- -D warnings
71
+ - name: Clippy
72
+ run: cargo clippy --all-targets --features window-check
73
+
74
+ - name: The tests
75
+ run: cargo test
76
+
77
+ - name: The window check
78
+ if: runner.os != 'Linux'
79
+ run: cargo run --features window-check
80
+
81
+ - name: The window check (Linux)
82
+ if: runner.os == 'Linux'
83
+ run: xvfb-run --auto-servernum cargo run --features window-check
84
+ env:
85
+ # WHY: the runner has no graphics card; WebKitGTK draws the page without it
86
+ WEBKIT_DISABLE_DMABUF_RENDERER: 1
87
+ LIBGL_ALWAYS_SOFTWARE: 1
@@ -0,0 +1,128 @@
1
+ # Tauri Starter: rules for an AI assistant
2
+
3
+ This project is a desktop app made with **Tauri 2**: the window is a page written with **basic.js** (plain
4
+ JavaScript, no npm, no build step for the page), and the work is done in **Rust**. Do not guess from React, Vue,
5
+ Vite or a web framework: there is no `package.json`, no bundler, no HTML markup to write and no CSS file. The page
6
+ reaches Tauri through `window.__TAURI__` (`withGlobalTauri: true`), not through `import`.
7
+
8
+ ## Where the truth is
9
+
10
+ - **The code of this project.** Read the file you change, and the one on the other side of the call: a page function
11
+ of `ui/backend.js` and its command in `src-tauri/src/`.
12
+ - **basic.js** (the objects, the groups, the events): https://bug7a.github.io/basic.js/ and its handbook
13
+ https://bug7a.github.io/basic.js-handbook/. The library is `ui/basic/basic.min.js` (v26.11.10).
14
+ - **The components** (`SmartButton`, `SmartTable`...): their sources and model pages are in
15
+ https://github.com/bug7a/js-components (folder `comp/`); the params of a component are in the header of its file.
16
+ Read it before you use a component for the first time; never invent a param.
17
+ - **The handbook of this template** (11 chapters): `handbook/` here, or
18
+ https://bug7a.github.io/ozdenui-tauri-template/handbook/
19
+ - **Tauri:** https://tauri.app/ (only version 2: the code of Tauri 1 does not work here).
20
+
21
+ ## The files
22
+
23
+ ```text
24
+ ui/index.html the page: the scripts in order (basic.js, the components, backend.js, app.js, sizes.js)
25
+ ui/backend.js the ONLY file that calls Rust; each function has a sample answer for a browser
26
+ ui/app.js the page (start() runs first); ui/sizes.js the second example
27
+ ui/basic/, ui/comp/ the library and the components (minified copies: do not edit them)
28
+ src-tauri/src/main.rs the plugins, the state, the list of the commands (generate_handler!)
29
+ src-tauri/src/files.rs example 1: a command | sizes.rs: example 2, a job that sends events
30
+ src-tauri/tauri.conf.json the window, the security policy (CSP), the bundle
31
+ src-tauri/capabilities/default.json what the page may use: "core:default" and the permission of each plugin
32
+ src-tauri/tests/project.rs the tests that read the page and the Rust side together
33
+ checks/window-check.js the page played in its real window (src-tauri/src/check.rs runs it)
34
+ ```
35
+
36
+ ## The three patterns
37
+
38
+ **1. A command: the page asks, Rust answers.** Write the function in `src-tauri/src/`, add it to
39
+ `generate_handler!` in `main.rs`, then one function in `ui/backend.js`:
40
+
41
+ ```rust
42
+ #[tauri::command]
43
+ pub fn read_note(path: String) -> Result<String, String> {
44
+ std::fs::read_to_string(&path).map_err(|error| format!("{path}: {error}"))
45
+ }
46
+ ```
47
+
48
+ ```js
49
+ Backend.readNote = function (path) {
50
+ if (!Backend.isInApp()) return Promise.resolve("A sample note");
51
+ return window.__TAURI__.core.invoke("read_note", { path: path });
52
+ };
53
+ ```
54
+
55
+ - The arguments are an object whose keys are the names of the Rust arguments in camelCase (`show_hidden` is
56
+ `showHidden`). The answer is a promise; an `Err` of Rust rejects it with its text.
57
+ - A command that may take time is `#[tauri::command(async)]`, so the window does not wait for it.
58
+ - A struct sent to the page derives `Serialize`, with `#[serde(rename_all = "camelCase")]` for names of two words.
59
+
60
+ **2. Events: a long job tells the page how it goes.** The command starts a thread and answers at once; the thread
61
+ sends `app.emit("name", payload)`; the page listens once, at the start: `Backend.listen("name", handler)`. Shared
62
+ state is a struct given to `.manage()` in `main.rs` and taken by a command as `State<MyState>`. Give every job a
63
+ number from the page and send it back in every event, so the page drops the events of an old job (`sizes.rs`).
64
+
65
+ **3. A plugin of Tauri.** In the project: `cargo tauri add <name>` (Ex: `cargo tauri add dialog`). It writes the line of
66
+ `Cargo.toml`, the `.plugin(...)` line of `main.rs` and the permission in `capabilities/default.json` itself. The page
67
+ calls it through `window.__TAURI__.<name>` in a function of `ui/backend.js` (`Backend.chooseFolder`). A plugin call
68
+ without its permission fails in the app with "... not allowed" (a debug build also names the permissions that allow
69
+ it).
70
+
71
+ ## The page (basic.js)
72
+
73
+ - `start()` runs when the page is ready; the global `page` is the window. Objects are made in code:
74
+ `Box`, `Label`, `Button`, `Input`, `Icon`, with the params object last: `Label({ text: "Hi", fontSize: 16 })`.
75
+ - `HGroup` / `VGroup` ... `endGroup()` and `startBox()` ... `endBox()`: the objects made between them go inside.
76
+ Every start needs its end. A group is 100% x 100% by default: inside another group give it `hug: 1` or a size.
77
+ - **Only a Box or a group holds objects**: never put an object into a `Label` or a button.
78
+ - **`text` is HTML.** A name of a file, a text typed by the user or anything that comes from Rust goes in with
79
+ `plainText` (`lblName.plainText = entry.name`). The window check opens a folder whose name is an HTML tag to prove it.
80
+ - After an object is made, change it with its properties (`label.text = ...`) or the `set...()` functions of a
81
+ component (`button.setLabelText("Stop")`).
82
+ - Events: `obj.on("click", fn)`, a component's `onClick` / `onChange` / `onSelect` param, `page.onResize(fn)`.
83
+ - Colors and sizes are named constants at the top of the file (`PAGE_COLOR`, `ROW_HEIGHT`).
84
+ - The components in `ui/comp/components.min.js`: `SmartButton`, `Breadcrumbs`, `CheckBox`, `SearchInput`,
85
+ `ContextMenu`, `SmartTable`, `Toast` (the list is `ui/comp/_sources.txt`). Another component: put its file from
86
+ `comp/` of js-components into `ui/comp/` and add its `<script>` after `components.min.js` in `ui/index.html`.
87
+ - `page` never scrolls: content taller than the window goes into a box with `scrollY: 1`, or a table.
88
+
89
+ ## Mistakes to avoid
90
+
91
+ 1. A command written in Rust but not added to `generate_handler!`, or called from the page with another name:
92
+ `cargo test` (the project tests) names it. Arguments in snake_case from the page (`show_hidden`) fail only when
93
+ the call runs: the window check shows it.
94
+ 2. Calling `window.__TAURI__` outside `ui/backend.js`: the page then breaks in a browser, and the sample answers of
95
+ `Backend` are lost.
96
+ 3. A text from Rust or from the user written with `text` (HTML) instead of `plainText`.
97
+ 4. A slow job in a command that is not `async` and not in a thread: the window stops.
98
+ 5. Loosening the security policy (`csp` of `tauri.conf.json`: a script from the web, `'unsafe-eval'`,
99
+ `'unsafe-inline'` for scripts) or giving the page wide permissions to make an error go away. Find the one
100
+ permission it needs.
101
+ 6. A `<script>` with code or with a web address in `ui/index.html`: the security policy lets it run (Tauri adds
102
+ its hash or a nonce when it builds the app), so `cargo test` stops it. Code goes into a `.js` file of `ui/`; a
103
+ library from the web is saved into `ui/` and loaded from there.
104
+ 7. Code of Tauri 1 (`allowlist`, `@tauri-apps/api/tauri`, `tauri::api::...`): it does not exist in Tauri 2.
105
+ 8. An `npm install` or a bundler for the page: the page has none; the files of `ui/` are served as they are.
106
+ 9. Saying the app works without running the checks below.
107
+
108
+ ## Running and checking
109
+
110
+ All in `src-tauri/` (`cargo tauri dev` and `cargo tauri build` in the root of the project):
111
+
112
+ ```sh
113
+ cargo fmt --check # the code is formatted (cargo fmt writes it)
114
+ cargo clippy --all-targets --features window-check -- -D warnings
115
+ cargo test # the Rust tests and the project tests
116
+ cargo run --features window-check # the page in its real window: PASS / FAIL lines
117
+ ```
118
+
119
+ - The window check opens the real window for a few seconds, plays the page, prints a line for every step and closes
120
+ the app; the last line is `WINDOW CHECK: ALL PASS` and the exit code is 0. A new feature gets a step in
121
+ `checks/window-check.js`: `await WindowCheck.until(() => ..., "what it waits for")`, then
122
+ `WindowCheck.expect(isTrue, "what it saw")`. A step must not open a dialog of the system: it waits for a person.
123
+ - `cargo tauri dev` opens the app and keeps it open: a person closes it. An assistant that can not see the window
124
+ runs the window check instead.
125
+ - The page can be opened in a browser through a web server (Ex: Live Server): `Backend` gives sample answers there,
126
+ so the look of the page can be checked without Rust. It is not a test of the Rust side.
127
+ - The GitHub workflows: `.github/workflows/tests.yml` runs the four checks above on Linux, macOS and Windows at every
128
+ push; `build.yml` makes a draft release from a tag that is the version of `src-tauri/Cargo.toml` (`v0.1.0`).
@@ -0,0 +1 @@
1
+ @AGENTS.md
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ Tauri Starter (OzdenUI for Tauri)
2
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
3
+
4
+ This product includes software developed by Bugra Ozden
5
+ (https://bug7a.github.io/basic.js/).
6
+
7
+ ui/basic/font/open-sans holds the Open Sans font, with its own license
8
+ (ui/basic/font/open-sans/LICENSE.txt).