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,282 @@
1
+ # 6. Plugins
2
+
3
+ *Türkçe: [6. Eklentiler](turkce/06-plugins.md)*
4
+
5
+ A plugin is a feature of Tauri that is written already: Rust code with a JavaScript side for the page. This chapter
6
+ reads how the dialog plugin of the template was added and what it can do, adds a second plugin (the app remembers the
7
+ last folder and "Hidden files" between two runs), and lists the official plugins.
8
+
9
+ ## What a plugin is
10
+
11
+ - A crate named `tauri-plugin-<name>`: its Rust code, its permissions and a JavaScript file.
12
+ - With `"withGlobalTauri": true`, the JavaScript of every plugin crate in `Cargo.toml` is in the page as
13
+ `window.__TAURI__.<name>`, the name in camelCase (`clipboard-manager` is `clipboardManager`). No npm package.
14
+ - `Object.keys(window.__TAURI__)` lists only the 12 parts of Tauri itself (`core`, `event`, `window`...), not the
15
+ plugins, but `window.__TAURI__.dialog.open` is there (tried): test a plugin by its name, not by the list.
16
+ - The list of the plugins and their documents: https://tauri.app/plugin/
17
+
18
+ ## cargo tauri add: the three places
19
+
20
+ `cargo tauri add dialog`, in the root of the project, wrote three lines. `src-tauri/Cargo.toml`, the crate:
21
+
22
+ ```toml
23
+ tauri-plugin-dialog = "2"
24
+ ```
25
+
26
+ `src-tauri/src/main.rs`, the plugin in the app (its Rust side starts with the app):
27
+
28
+ ```rust
29
+ .plugin(tauri_plugin_dialog::init())
30
+ ```
31
+
32
+ `src-tauri/capabilities/default.json`, the permission (what the page may call). The command wrote
33
+ `"dialog:default"`; the template then made it narrower, to the one dialog its page opens:
34
+
35
+ ```json
36
+ "permissions": ["core:default", "dialog:allow-open"]
37
+ ```
38
+
39
+ - Tried with `cargo tauri add store` (2026-11-27, tauri-cli 2.12.4): the same three places. It put the `.plugin(...)`
40
+ line at the top of the builder, ran `cargo fmt`, and wrote `capabilities/default.json` again with one value a line.
41
+ It also runs in `src-tauri/`.
42
+ - A plugin made only for desktops (`window-state`, `updater`, `global-shortcut`, `autostart`) goes under
43
+ `[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]`, and its permission into a new
44
+ `capabilities/desktop.json` (tried).
45
+
46
+ Each place that is missing has its own error (tried on macOS with the store plugin, and with `opener` for a crate that
47
+ is not added; the `TypeError` is worded by the web view of the system):
48
+
49
+ ```text
50
+ no crate TypeError: undefined is not an object (evaluating 'window.__TAURI__.opener.openPath')
51
+ no .plugin(...) plugin store not found
52
+ no permission store.load not allowed. Permissions associated with this command: store:allow-load, store:default
53
+ ```
54
+
55
+ The message of a missing permission names the permissions that allow the call: add one of them.
56
+
57
+ ## The dialogs from the page
58
+
59
+ The dialog plugin has five functions (`tauri-plugin-dialog` 2.8.4: its JavaScript file and its Rust code):
60
+
61
+ | Function | The answer |
62
+ |---|---|
63
+ | `open(options)` | a path, a list of paths (with `multiple: true`), or `null` |
64
+ | `save(options)` | a path, or `null` |
65
+ | `message(text, options)` | `"Ok"` (or the text of `okLabel`) |
66
+ | `ask(text, options)` | `true` for Yes, `false` for No |
67
+ | `confirm(text, options)` | `true` for Ok, `false` for Cancel |
68
+
69
+ - The options of `open`: `title`, `defaultPath`, `directory`, `multiple`, `filters`, `recursive`,
70
+ `canCreateDirectories`; of `save`: `title`, `defaultPath`, `filters`, `canCreateDirectories`. `filters` is a list
71
+ of `{ name, extensions }`.
72
+ - The options of `message`, `ask` and `confirm`: `title`, `kind` (`"info"`, `"warning"` or `"error"`), `okLabel`,
73
+ and `cancelLabel` for the two that have two buttons. `null` is the answer of Cancel.
74
+
75
+ Four of them as functions of `ui/backend.js`, each with its sample answer:
76
+
77
+ ```js
78
+ // Text files to open. The answer: a list of paths, or null when the dialog is closed with Cancel.
79
+ Backend.chooseTextFiles = function (startPath) {
80
+ if (!Backend.isInApp()) return Promise.resolve([Backend.SAMPLE_HOME + "/notes.txt"]);
81
+ return window.__TAURI__.dialog.open({
82
+ defaultPath: startPath,
83
+ multiple: true,
84
+ filters: [{ name: "Text", extensions: ["txt", "md"] }],
85
+ });
86
+ };
87
+
88
+ // Where to save a file. The answer: a path, or null. WHY no file: the dialog only asks, a command of yours writes.
89
+ Backend.chooseSavePath = function (fileName) {
90
+ if (!Backend.isInApp()) return Promise.resolve(Backend.SAMPLE_HOME + "/" + fileName);
91
+ return window.__TAURI__.dialog.save({
92
+ defaultPath: fileName,
93
+ filters: [{ name: "CSV", extensions: ["csv"] }],
94
+ });
95
+ };
96
+
97
+ // A question with Yes and No. The answer: true for Yes.
98
+ Backend.askYesNo = function (text, title) {
99
+ if (!Backend.isInApp()) return Promise.resolve(true);
100
+ return window.__TAURI__.dialog.ask(text, { title: title, kind: "warning" });
101
+ };
102
+
103
+ // A message with one button. The answer: "Ok".
104
+ Backend.showMessage = function (text, title) {
105
+ if (!Backend.isInApp()) return Promise.resolve("Ok");
106
+ return window.__TAURI__.dialog.message(text, { title: title, kind: "info" });
107
+ };
108
+ ```
109
+
110
+ Ex: `Backend.askYesNo("The list is long. Measure it?", "Sizes").then(function (isYes) { if (isYes) Sizes.start(); })`.
111
+
112
+ - A dialog of the system waits for a person, so no check opens one: the five functions are in the page (tried), and
113
+ the options and the answers above are read from the code of the plugin.
114
+ - **The permission.** `dialog:default`, the line `cargo tauri add dialog` writes, allows `allow-open`, `allow-save`
115
+ and `allow-message`; `ask` and `confirm` are `message` in Rust (`dialog:allow-ask` and `dialog:allow-confirm` are
116
+ old names of it, to go in Tauri 3). The template keeps only `"dialog:allow-open"`: its page only opens folders. The
117
+ functions above need their own lines: `"dialog:allow-save"` for `save()`, `"dialog:allow-message"` for
118
+ `message()`, `ask()` and `confirm()`. Without it the call is refused (tried with `ask()`):
119
+ `dialog.message not allowed. Permissions associated with this command: dialog:allow-ask, dialog:allow-confirm,
120
+ dialog:allow-message, dialog:default` ([8. Security](08-security.md)).
121
+ - **A scope** is the list of the paths (or addresses) that a permission allows. A path the user chose in `open` or
122
+ `save` is added to the scope of the `fs` plugin when that plugin is in the app (with `recursive: true`, also the
123
+ folders inside): the page may then read that file with `fs` (seen in the Rust code of the dialog plugin; not tried).
124
+ The template reads with its own command, so it needs no `fs`.
125
+
126
+ ## A second plugin: the store
127
+
128
+ The store plugin keeps values in a JSON file of the app. Here it keeps the last folder and "Hidden files".
129
+ (`opener`, "open with the app of the system", was the other choice: its `default` permission does not open files,
130
+ `openPath` needs `opener:allow-open-path` with a scope of paths.)
131
+
132
+ **1. Add it**, in the root of the project: `cargo tauri add store`. It writes `tauri-plugin-store = "2"`,
133
+ `.plugin(tauri_plugin_store::Builder::new().build())` and `"store:default"` (all the functions of the store).
134
+
135
+ **2. The calls**, in `ui/backend.js` (in a browser the settings go to the localStorage of the browser):
136
+
137
+ ```js
138
+ // Settings kept between two runs, in a file of the store plugin (tauri-plugin-store).
139
+ // In a browser: the localStorage of the browser (basic.storage).
140
+ Backend.SETTINGS_FILE = "settings.json";
141
+ Backend.settingsStore = null; // a promise of the store, made at the first use
142
+
143
+ Backend.openSettings = function () {
144
+ if (!Backend.settingsStore) Backend.settingsStore = window.__TAURI__.store.load(Backend.SETTINGS_FILE);
145
+ return Backend.settingsStore;
146
+ };
147
+
148
+ // The value of a setting, or fallback when it was never saved
149
+ Backend.loadSetting = function (key, fallback) {
150
+ if (!Backend.isInApp()) return Promise.resolve(basic.storage.loadOr(key, fallback));
151
+ return Backend.openSettings()
152
+ .then(function (store) { return store.get(key); })
153
+ .then(function (value) { return (value === undefined) ? fallback : value; });
154
+ };
155
+
156
+ // The store writes its file by itself, a moment after a change
157
+ Backend.saveSetting = function (key, value) {
158
+ if (!Backend.isInApp()) return Promise.resolve(basic.storage.save(key, value));
159
+ return Backend.openSettings().then(function (store) { return store.set(key, value); });
160
+ };
161
+ ```
162
+
163
+ **3. The page** (`ui/app.js`). `openFolder` gets a second argument, the function for its error, so the start can fall
164
+ back to the home folder: `const openFolder = function (path, onError = showError) {`, and in its `.catch`,
165
+ `if (isLatest()) onError(error);`. Then `start()` calls `openLastFolder();` in the place of `openFolder("");`:
166
+
167
+ ```js
168
+ // The folder and the "Hidden files" choice of the last run. A folder that is not there any more (a disk
169
+ // that was taken out): the home folder.
170
+ const openLastFolder = function () {
171
+ const lastFolder = Backend.loadSetting("lastFolder", "");
172
+ const lastShowHidden = Backend.loadSetting("showHidden", false);
173
+ Promise.all([lastFolder, lastShowHidden])
174
+ .then(function (values) {
175
+ showHidden = values[1];
176
+ chkHidden.setChecked(showHidden ? 1 : 0, 1);
177
+ openFolder(values[0], openHome);
178
+ })
179
+ .catch(function (error) {
180
+ Toast.error(String(error), { titleText: "The settings could not be read" });
181
+ openHome();
182
+ });
183
+ };
184
+ ```
185
+
186
+ `setChecked(..., 1)` changes the check box without its `onChange`. The two values are saved where they change: in
187
+ the `if (isNewFolder)` block of `showFolder()`, `Backend.saveSetting("lastFolder", folder.path);`, and in
188
+ `onHiddenChange()`, `Backend.saveSetting("showHidden", showHidden);` under its first line.
189
+
190
+ **4. The window check.** The app and the check now share the settings: a check that starts with "Hidden files" on
191
+ fails at "the hidden file is not listed". In `checks/window-check.js`, before `// THE FIRST EXAMPLE`:
192
+
193
+ ```js
194
+ // The settings of the store plugin (chapter 6 of the handbook): the check starts with Hidden files off, and it
195
+ // puts the settings back at its end (they are the settings of the app on this computer)
196
+ const savedFolder = await Backend.loadSetting("lastFolder", "");
197
+ const savedShowHidden = await Backend.loadSetting("showHidden", false);
198
+ chkHidden.setChecked(0);
199
+ ```
200
+
201
+ after the step "Hidden files: the hidden file is listed too" a step of the store, and after "Up opens the folder
202
+ above" the two values back:
203
+
204
+ ```js
205
+ const keptShowHidden = await Backend.loadSetting("showHidden", false);
206
+ WindowCheck.expect(keptShowHidden === true, "the store plugin keeps the Hidden files choice");
207
+
208
+ await Backend.saveSetting("lastFolder", savedFolder);
209
+ await Backend.saveSetting("showHidden", savedShowHidden);
210
+ ```
211
+
212
+ Run `cargo tauri dev`, open a folder, tick "Hidden files", close the app and run it again: it opens there.
213
+
214
+ - The file is `settings.json` in the data folder of the app, named by the `identifier` of `tauri.conf.json`: on macOS
215
+ `~/Library/Application Support/io.github.bug7a.tauri-starter/settings.json` (tried), with
216
+ `{ "showHidden": false, "lastFolder": "/Users/me" }` in it.
217
+ - `get` of a key that was never set gives `undefined`; texts, numbers and lists come back as they went (tried).
218
+ `load` of the same file again gives the same store.
219
+ - The store writes its file 100 ms after a change, and when the app ends (its Rust code); `store.save()` writes now.
220
+
221
+ ## The official plugins
222
+
223
+ What the crates said on 2026-11-27 (after `cargo tauri add` in a copy of the template). Their pages at
224
+ https://tauri.app/plugin/ tell the rest.
225
+
226
+ | Plugin | For | `window.__TAURI__.` | Its `default` permission allows |
227
+ |---|---|---|---|
228
+ | `dialog` | the dialogs of the system | `dialog` | `open`, `save`, `message` (`ask`, `confirm`) |
229
+ | `fs` | files and folders | `fs` | to read (and make) the folders of the app; another path needs a scope |
230
+ | `store` | values in a file | `store` | every function |
231
+ | `opener` | a file or an address in its app | `opener` | web, mail and phone addresses; `revealItemInDir` |
232
+ | `notification` | notifications of the system | `notification` | every function |
233
+ | `clipboard-manager` | the clipboard | `clipboardManager` | nothing: add Ex: `clipboard-manager:allow-write-text` |
234
+ | `os` | the system, its version, the language | `os` | every function but `hostname` |
235
+ | `process` | end or start again the app | `process` | `exit`, `relaunch` |
236
+ | `shell` | run a program | `shell` | `open` of addresses (an old function: use `opener`) |
237
+ | `http` | requests made by Rust | `http` | `fetch`, but no address: each one is added as a scope |
238
+ | `window-state` | the size and the place of the windows | `windowState` | every function |
239
+ | `single-instance` | one copy of the app at a time | (none) | (no permission) |
240
+ | `updater` | updates of the app | `updater` | every function; it needs a `pubkey` and `endpoints` |
241
+ | `global-shortcut` | keys heard when the app is behind | `globalShortcut` | nothing: add the ones the page uses |
242
+ | `log` | logs in the terminal and a file | `log` | `log`: but the command did not add `log:default` |
243
+ | `autostart` | start the app at login | `autostart` | `enable`, `disable`, `isEnabled` |
244
+
245
+ - `window-state`, `updater`, `global-shortcut`, `autostart` and `single-instance` are for desktops (the `[target...]`
246
+ part of `Cargo.toml`); `single-instance` is set up in Rust only. `cargo tauri add updater` also wrote a
247
+ `plugins.updater` part into `tauri.conf.json` and said to set its `pubkey` and `endpoints` (chapter 10).
248
+ - `log` is the one plugin whose permission the command did not write: add `"log:default"` yourself.
249
+
250
+ ## Taking a plugin out
251
+
252
+ `cargo tauri remove store` (tried) takes out the line of `Cargo.toml` and the permission, then says
253
+ `Now, you must manually remove the plugin from your Rust code.`: delete the `.plugin(...)` line, and the calls of the
254
+ page in `ui/backend.js`. `cargo test` tells what is left. The dialog of the template:
255
+ [2. The project](02-the-project.md).
256
+
257
+ ## What the project test checks
258
+
259
+ `every_plugin_the_page_uses_is_added_and_has_its_permission` (`src-tauri/tests/project.rs`) looks for every
260
+ `window.__TAURI__.<name>` of `ui/*.js` that is not a part of Tauri itself, and wants its crate and a permission of it:
261
+
262
+ ```text
263
+ the page uses window.__TAURI__.store, but capabilities/ gives no "store:..." permission
264
+ ```
265
+
266
+ It looks for one permission of the plugin, not for the right one: a page that calls `store.load` with only
267
+ `"store:allow-get"` passes the test and fails in the window. The window check, or a try in the app, tells that.
268
+
269
+ ## The usual mistakes
270
+
271
+ - **`... not allowed. Permissions associated with this command: ...`**: add one of the permissions it names, the
272
+ narrowest that is enough; never a wide one to make the error go away.
273
+ - **`window.__TAURI__.<name>` is `undefined`**: the crate is not in `Cargo.toml` (`cargo tauri add <name>`), or
274
+ `withGlobalTauri` is not `true`.
275
+ - **`plugin <name> not found`**: the `.plugin(...)` line is not in `main.rs`.
276
+ - A change of `capabilities/` is in the app after the next build (`build.rs` reads the folder).
277
+ More: [11. Troubleshooting](11-troubleshooting.md).
278
+
279
+ ## Next
280
+
281
+ [7. The window and the app](07-the-window-and-the-app.md): the window from the page and from Rust, more windows, a
282
+ menu, the folders of the app.