create-basicjs 0.1.4 → 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.
- package/README.md +12 -2
- package/bin/create-basicjs.js +58 -5
- package/bin/verify-package.js +1 -1
- package/package.json +2 -2
- package/payload/projects/tauri/.github/workflows/build.yml +86 -0
- package/payload/projects/tauri/.github/workflows/tests.yml +87 -0
- package/payload/projects/tauri/AGENTS.md +128 -0
- package/payload/projects/tauri/CLAUDE.md +1 -0
- package/payload/projects/tauri/LICENSE +201 -0
- package/payload/projects/tauri/NOTICE +8 -0
- package/payload/projects/tauri/README.md +269 -0
- package/payload/projects/tauri/checks/window-check.js +189 -0
- package/payload/projects/tauri/gitignore +8 -0
- package/payload/projects/tauri/handbook/01-getting-started.md +188 -0
- package/payload/projects/tauri/handbook/02-the-project.md +264 -0
- package/payload/projects/tauri/handbook/03-the-page.md +260 -0
- package/payload/projects/tauri/handbook/04-commands.md +265 -0
- package/payload/projects/tauri/handbook/05-events-and-state.md +275 -0
- package/payload/projects/tauri/handbook/06-plugins.md +282 -0
- package/payload/projects/tauri/handbook/07-the-window-and-the-app.md +431 -0
- package/payload/projects/tauri/handbook/08-security.md +374 -0
- package/payload/projects/tauri/handbook/09-tests-and-checks.md +266 -0
- package/payload/projects/tauri/handbook/10-building-and-releasing.md +238 -0
- package/payload/projects/tauri/handbook/11-troubleshooting.md +259 -0
- package/payload/projects/tauri/handbook/README.md +125 -0
- package/payload/projects/tauri/handbook/turkce/01-getting-started.md +193 -0
- package/payload/projects/tauri/handbook/turkce/02-the-project.md +272 -0
- package/payload/projects/tauri/handbook/turkce/03-the-page.md +272 -0
- package/payload/projects/tauri/handbook/turkce/04-commands.md +271 -0
- package/payload/projects/tauri/handbook/turkce/05-events-and-state.md +284 -0
- package/payload/projects/tauri/handbook/turkce/06-plugins.md +286 -0
- package/payload/projects/tauri/handbook/turkce/07-the-window-and-the-app.md +433 -0
- package/payload/projects/tauri/handbook/turkce/08-security.md +384 -0
- package/payload/projects/tauri/handbook/turkce/09-tests-and-checks.md +275 -0
- package/payload/projects/tauri/handbook/turkce/10-building-and-releasing.md +241 -0
- package/payload/projects/tauri/handbook/turkce/11-troubleshooting.md +264 -0
- package/payload/projects/tauri/handbook/turkce/README.md +128 -0
- package/payload/projects/tauri/images/app.png +0 -0
- package/payload/projects/tauri/src-tauri/Cargo.lock +4389 -0
- package/payload/projects/tauri/src-tauri/Cargo.toml +31 -0
- package/payload/projects/tauri/src-tauri/app-icon.svg +16 -0
- package/payload/projects/tauri/src-tauri/build.rs +15 -0
- package/payload/projects/tauri/src-tauri/capabilities/default.json +7 -0
- package/payload/projects/tauri/src-tauri/gitignore +5 -0
- package/payload/projects/tauri/src-tauri/icons/128x128.png +0 -0
- package/payload/projects/tauri/src-tauri/icons/128x128@2x.png +0 -0
- package/payload/projects/tauri/src-tauri/icons/32x32.png +0 -0
- package/payload/projects/tauri/src-tauri/icons/icon.icns +0 -0
- package/payload/projects/tauri/src-tauri/icons/icon.ico +0 -0
- package/payload/projects/tauri/src-tauri/src/check.rs +144 -0
- package/payload/projects/tauri/src-tauri/src/files.rs +255 -0
- package/payload/projects/tauri/src-tauri/src/main.rs +45 -0
- package/payload/projects/tauri/src-tauri/src/sizes.rs +214 -0
- package/payload/projects/tauri/src-tauri/tauri.conf.json +44 -0
- package/payload/projects/tauri/src-tauri/tests/project.rs +243 -0
- package/payload/projects/tauri/ui/app.js +459 -0
- package/payload/projects/tauri/ui/backend.js +196 -0
- package/payload/projects/tauri/ui/basic/LICENSE +14 -0
- package/payload/projects/tauri/ui/basic/basic.min.css +1 -0
- package/payload/projects/tauri/ui/basic/basic.min.js +78 -0
- package/payload/projects/tauri/ui/basic/font/open-sans/LICENSE.txt +206 -0
- package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
- package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
- package/payload/projects/tauri/ui/basic/scroll-bar.min.js +3 -0
- package/payload/projects/tauri/ui/comp/_sources.txt +9 -0
- package/payload/projects/tauri/ui/comp/components.min.js +21 -0
- package/payload/projects/tauri/ui/index.html +28 -0
- package/payload/projects/tauri/ui/sizes.js +104 -0
- package/payload/starter/AGENTS.md +11 -6
- package/payload/starter/README.md +1 -1
- package/payload/starter/_basic/VERSION +1 -1
- package/payload/starter/_basic/assets/cards/almond-blossom.png +0 -0
- package/payload/starter/_basic/assets/cards/blackberry.png +0 -0
- package/payload/starter/_basic/assets/cards/borage.png +0 -0
- package/payload/starter/_basic/assets/cards/chamomile.png +0 -0
- package/payload/starter/_basic/assets/cards/dill.png +0 -0
- package/payload/starter/_basic/assets/cards/eucalyptus.png +0 -0
- package/payload/starter/_basic/assets/cards/fennel.png +0 -0
- package/payload/starter/_basic/assets/cards/fig.png +0 -0
- package/payload/starter/_basic/assets/cards/juniper.png +0 -0
- package/payload/starter/_basic/assets/cards/lavender.png +0 -0
- package/payload/starter/_basic/assets/cards/lemon.png +0 -0
- package/payload/starter/_basic/assets/cards/olives.png +0 -0
- package/payload/starter/_basic/assets/cards/oregano.png +0 -0
- package/payload/starter/_basic/assets/cards/pepper.png +0 -0
- package/payload/starter/_basic/assets/cards/physalis.png +0 -0
- package/payload/starter/_basic/assets/cards/pomegranate.png +0 -0
- package/payload/starter/_basic/assets/cards/poppy.png +0 -0
- package/payload/starter/_basic/assets/cards/rosehip.png +0 -0
- package/payload/starter/_basic/assets/cards/saffron.png +0 -0
- package/payload/starter/_basic/assets/categories/cappuccino.png +0 -0
- package/payload/starter/_basic/assets/categories/chocolate-milk.png +0 -0
- package/payload/starter/_basic/assets/categories/coffee.png +0 -0
- package/payload/starter/_basic/assets/categories/frappe.png +0 -0
- package/payload/starter/_basic/assets/categories/iced-caffee.png +0 -0
- package/payload/starter/_basic/assets/categories/milkshake.png +0 -0
- package/payload/starter/_basic/assets/categories/orange-juice.png +0 -0
- package/payload/starter/_basic/assets/categories/tea.png +0 -0
- package/payload/starter/_basic/assets/fruids/brokoli.png +0 -0
- package/payload/starter/_basic/assets/fruids/cilek.png +0 -0
- package/payload/starter/_basic/assets/fruids/domates.png +0 -0
- package/payload/starter/_basic/assets/fruids/elma.png +0 -0
- package/payload/starter/_basic/assets/fruids/havuc.png +0 -0
- package/payload/starter/_basic/assets/fruids/karpuz.png +0 -0
- package/payload/starter/_basic/assets/fruids/limon.png +0 -0
- package/payload/starter/_basic/assets/fruids/muz.png +0 -0
- package/payload/starter/_basic/assets/fruids/nar.png +0 -0
- package/payload/starter/_basic/assets/fruids/patlican.png +0 -0
- package/payload/starter/_basic/assets/fruids/yabanmersini.png +0 -0
- package/payload/starter/_basic/assets/fruids/yesilbiber.png +0 -0
- package/payload/starter/_basic/basic/LICENSE +1 -1
- package/payload/starter/_basic/basic/basic.css +3 -6
- package/payload/starter/_basic/basic/basic.js +154 -60
- package/payload/starter/_basic/basic/basic.min.js +19 -6
- package/payload/starter/_basic/basic/scroll-bar.js +4 -2
- package/payload/starter/_basic/basic/scroll-bar.min.js +1 -0
- package/payload/starter/_basic/comp/accordion.js +659 -0
- package/payload/starter/_basic/comp/action-button.js +22 -23
- package/payload/starter/_basic/comp/action-tab-bar.js +8 -8
- package/payload/starter/_basic/comp/app-bar.js +12 -11
- package/payload/starter/_basic/comp/{badge-v2.js → badge.js} +51 -5
- package/payload/starter/_basic/comp/bottom-bar.js +62 -26
- package/payload/starter/_basic/comp/breadcrumbs.js +4 -2
- package/payload/starter/_basic/comp/canvas.js +652 -0
- package/payload/starter/_basic/comp/chat-view.js +827 -0
- package/payload/starter/_basic/comp/check-box.js +137 -21
- package/payload/starter/_basic/comp/code-editor.js +1171 -0
- package/payload/starter/_basic/comp/{select-color.js → color-picker.js} +62 -29
- package/payload/starter/_basic/comp/context-menu.js +348 -31
- package/payload/starter/_basic/comp/{currency-input-b.js → currency-field.js} +48 -29
- package/payload/starter/_basic/comp/data-table.js +114 -42
- package/payload/starter/_basic/comp/{select-date.js → date-picker.js} +104 -52
- package/payload/starter/_basic/comp/dialog.js +214 -76
- package/payload/starter/_basic/comp/email-field.js +65 -0
- package/payload/starter/_basic/comp/{select-file.js → file-picker.js} +245 -57
- package/payload/starter/_basic/comp/filters.js +374 -60
- package/payload/starter/_basic/comp/form.js +38 -26
- package/payload/starter/_basic/comp/full-screen-select.js +36 -33
- package/payload/starter/_basic/comp/gauge.js +12 -8
- package/payload/starter/_basic/comp/graph-box.js +3911 -0
- package/payload/starter/_basic/comp/grid-group.js +185 -0
- package/payload/starter/_basic/comp/hold-to-confirm-button.js +16 -7
- package/payload/starter/_basic/comp/image-view.js +598 -0
- package/payload/starter/_basic/comp/item-list.js +507 -163
- package/payload/starter/_basic/comp/json-editor.js +3221 -0
- package/payload/starter/_basic/comp/json-view.js +597 -0
- package/payload/starter/_basic/comp/label-editor.js +22 -19
- package/payload/starter/_basic/comp/left-menu.js +89 -22
- package/payload/starter/_basic/comp/line-progress-bar.js +196 -45
- package/payload/starter/_basic/comp/loading-screen.js +49 -18
- package/payload/starter/_basic/comp/log-view.js +530 -0
- package/payload/starter/_basic/comp/{login-page-v2.js → login-page.js} +205 -106
- package/payload/starter/_basic/comp/markdown-view.js +1046 -0
- package/payload/starter/_basic/comp/menu-bar.js +624 -0
- package/payload/starter/_basic/comp/mini-graph-box.js +20 -11
- package/payload/starter/_basic/comp/minimal-accent.js +208 -0
- package/payload/starter/_basic/comp/notice.js +15 -13
- package/payload/starter/_basic/comp/{number-input-b.js → number-field.js} +26 -19
- package/payload/starter/_basic/comp/numeric-keyboard.js +15 -13
- package/payload/starter/_basic/comp/page-control.js +21 -4
- package/payload/starter/_basic/comp/page-header.js +7 -6
- package/payload/starter/_basic/comp/password-field.js +192 -0
- package/payload/starter/_basic/comp/period-bar.js +8 -7
- package/payload/starter/_basic/comp/{phone-input-b.js → phone-field.js} +80 -45
- package/payload/starter/_basic/comp/progress-bar.js +401 -85
- package/payload/starter/_basic/comp/property-panel.js +1022 -123
- package/payload/starter/_basic/comp/radio-button.js +79 -19
- package/payload/starter/_basic/comp/range-slider.js +569 -0
- package/payload/starter/_basic/comp/rich-text-editor.js +33 -30
- package/payload/starter/_basic/comp/scroll-area.js +308 -0
- package/payload/starter/_basic/comp/scrolling-text.js +10 -9
- package/payload/starter/_basic/comp/search-input.js +725 -0
- package/payload/starter/_basic/comp/search-results.js +60 -24
- package/payload/starter/_basic/comp/select-box.js +229 -107
- package/payload/starter/_basic/comp/settings-row.js +20 -19
- package/payload/starter/_basic/comp/side-panel.js +53 -10
- package/payload/starter/_basic/comp/slider-field.js +264 -88
- package/payload/starter/_basic/comp/slider.js +556 -86
- package/payload/starter/_basic/comp/smart-button.js +438 -353
- package/payload/starter/_basic/comp/smart-table.js +748 -186
- package/payload/starter/_basic/comp/sortable-list.js +47 -38
- package/payload/starter/_basic/comp/spark-line-box.js +25 -16
- package/payload/starter/_basic/comp/splitter.js +411 -0
- package/payload/starter/_basic/comp/status-bar.js +408 -0
- package/payload/starter/_basic/comp/step-bar.js +345 -0
- package/payload/starter/_basic/comp/stepper.js +103 -49
- package/payload/starter/_basic/comp/tabs.js +67 -18
- package/payload/starter/_basic/comp/tag-input.js +50 -10
- package/payload/starter/_basic/comp/tap-effect.js +6 -4
- package/payload/starter/_basic/comp/text-area-field.js +233 -0
- package/payload/starter/_basic/comp/text-field.js +1006 -0
- package/payload/starter/_basic/comp/time-line.js +102 -28
- package/payload/starter/_basic/comp/{select-time.js → time-picker.js} +104 -51
- package/payload/starter/_basic/comp/tiny-select.js +79 -39
- package/payload/starter/_basic/comp/tiny-table.js +12 -8
- package/payload/starter/_basic/comp/toast.js +87 -34
- package/payload/starter/_basic/comp/toggle.js +149 -28
- package/payload/starter/_basic/comp/tool-bar.js +760 -0
- package/payload/starter/_basic/comp/tooltip.js +80 -17
- package/payload/starter/_basic/comp/tree-view.js +124 -41
- package/payload/starter/_basic/comp/ui-effects.js +17 -11
- package/payload/starter/_basic/comp/ui-standards.js +5 -4
- package/payload/starter/_basic/comp/url-field.js +190 -0
- package/payload/starter/_basic/comp/web-view.js +70 -16
- package/payload/starter/_basic/docs/basic-js-animated-rules.md +15 -9
- package/payload/starter/_basic/docs/basic-js-code-rules.md +42 -5
- package/payload/starter/_basic/docs/basic-js-components.md +12 -17
- package/payload/starter/_basic/docs/basic-js-core.md +5 -4
- package/payload/starter/_basic/docs/component-index.md +248 -107
- package/payload/starter/_basic/docs/component-template.js +28 -24
- package/payload/starter/_basic/docs/handbook/00-introduction.md +6 -2
- package/payload/starter/_basic/docs/handbook/00-what-is-new.md +21 -0
- package/payload/starter/_basic/docs/handbook/01-label.md +4 -4
- package/payload/starter/_basic/docs/handbook/02-box.md +7 -7
- package/payload/starter/_basic/docs/handbook/03-image.md +4 -4
- package/payload/starter/_basic/docs/handbook/04-common-properties.md +6 -5
- package/payload/starter/_basic/docs/handbook/05-autolayout.md +8 -7
- package/payload/starter/_basic/docs/handbook/06-button.md +3 -3
- package/payload/starter/_basic/docs/handbook/07-input.md +3 -3
- package/payload/starter/_basic/docs/handbook/08-page.md +3 -3
- package/payload/starter/_basic/docs/handbook/09-useful-examples.md +39 -58
- package/payload/starter/_basic/docs/handbook/10-motion.md +6 -6
- package/payload/starter/_basic/docs/handbook/11-other-functions.md +1 -0
- package/payload/starter/_basic/docs/handbook/13-sound.md +3 -3
- package/payload/starter/_basic/docs/handbook/14-using-components.md +180 -0
- package/payload/starter/_basic/docs/handbook/15-making-a-component.md +338 -0
- package/payload/starter/_basic/docs/what-is-new.md +106 -0
- package/payload/starter/_basic/examples/accordion.htm +174 -0
- package/payload/starter/_basic/examples/action-button.htm +74 -32
- package/payload/starter/_basic/examples/action-tab-bar.htm +5 -6
- package/payload/starter/_basic/examples/app-bar.htm +63 -41
- package/payload/starter/_basic/examples/badge.htm +96 -0
- package/payload/starter/_basic/examples/bottom-bar-2.htm +61 -48
- package/payload/starter/_basic/examples/bottom-bar.htm +74 -16
- package/payload/starter/_basic/examples/breadcrumbs.htm +160 -150
- package/payload/starter/_basic/examples/canvas.htm +190 -0
- package/payload/starter/_basic/examples/chat-view.htm +143 -0
- package/payload/starter/_basic/examples/check-box-2.htm +71 -82
- package/payload/starter/_basic/examples/check-box-3.htm +72 -83
- package/payload/starter/_basic/examples/check-box.htm +207 -0
- package/payload/starter/_basic/examples/code-editor-2.htm +259 -0
- package/payload/starter/_basic/examples/code-editor.htm +272 -0
- package/payload/starter/_basic/examples/color-picker.htm +206 -0
- package/payload/starter/_basic/examples/context-menu.htm +180 -139
- package/payload/starter/_basic/examples/currency-field.htm +105 -0
- package/payload/starter/_basic/examples/data-table-2.htm +2 -1
- package/payload/starter/_basic/examples/data-table-3.htm +1 -1
- package/payload/starter/_basic/examples/data-table-4.htm +15 -12
- package/payload/starter/_basic/examples/data-table-5.htm +11 -3
- package/payload/starter/_basic/examples/data-table.htm +90 -40
- package/payload/starter/_basic/examples/date-picker.htm +239 -0
- package/payload/starter/_basic/examples/dialog-centered.htm +394 -40
- package/payload/starter/_basic/examples/dialog.htm +267 -46
- package/payload/starter/_basic/examples/email-field.htm +102 -0
- package/payload/starter/_basic/examples/file-picker.htm +296 -0
- package/payload/starter/_basic/examples/filters.htm +33 -22
- package/payload/starter/_basic/examples/{form-1.htm → form.htm} +18 -19
- package/payload/starter/_basic/examples/full-screen-select.htm +81 -58
- package/payload/starter/_basic/examples/gallery-styled.htm +896 -0
- package/payload/starter/_basic/examples/gauge.htm +95 -81
- package/payload/starter/_basic/examples/graph-box.htm +365 -0
- package/payload/starter/_basic/examples/grid-group.htm +179 -0
- package/payload/starter/_basic/examples/hold-to-confirm-button.htm +102 -113
- package/payload/starter/_basic/examples/image-view.htm +195 -0
- package/payload/starter/_basic/examples/item-list-2.htm +138 -94
- package/payload/starter/_basic/examples/item-list.htm +191 -86
- package/payload/starter/_basic/examples/json-editor.htm +206 -0
- package/payload/starter/_basic/examples/json-view.htm +153 -0
- package/payload/starter/_basic/examples/label-editor.htm +85 -89
- package/payload/starter/_basic/examples/left-menu-2.htm +93 -0
- package/payload/starter/_basic/examples/left-menu.htm +42 -37
- package/payload/starter/_basic/examples/line-progress-bar.htm +155 -114
- package/payload/starter/_basic/examples/loading-screen.htm +149 -125
- package/payload/starter/_basic/examples/log-view.htm +175 -0
- package/payload/starter/_basic/examples/{login-page-dark-v2.htm → login-page-dark.htm} +265 -267
- package/payload/starter/_basic/examples/{login-page-v2.htm → login-page.htm} +266 -267
- package/payload/starter/_basic/examples/markdown-view.htm +220 -0
- package/payload/starter/_basic/examples/menu-bar-2.htm +225 -0
- package/payload/starter/_basic/examples/menu-bar.htm +145 -0
- package/payload/starter/_basic/examples/mini-graph-box.htm +98 -109
- package/payload/starter/_basic/examples/minimal-accent.htm +196 -0
- package/payload/starter/_basic/examples/minimal-theme.htm +432 -0
- package/payload/starter/_basic/examples/notice.htm +13 -4
- package/payload/starter/_basic/examples/number-field.htm +103 -0
- package/payload/starter/_basic/examples/numeric-keyboard.htm +44 -42
- package/payload/starter/_basic/examples/page-control.htm +181 -130
- package/payload/starter/_basic/examples/page-header.htm +57 -30
- package/payload/starter/_basic/examples/password-field.htm +117 -0
- package/payload/starter/_basic/examples/period-bar.htm +43 -29
- package/payload/starter/_basic/examples/phone-field-select-country.htm +292 -0
- package/payload/starter/_basic/examples/phone-field.htm +104 -0
- package/payload/starter/_basic/examples/progress-bar-ozden.htm +229 -92
- package/payload/starter/_basic/examples/progress-bar.htm +222 -174
- package/payload/starter/_basic/examples/property-panel.htm +152 -52
- package/payload/starter/_basic/examples/radio-button-2.htm +101 -109
- package/payload/starter/_basic/examples/radio-button-3.htm +81 -71
- package/payload/starter/_basic/examples/radio-button.htm +289 -0
- package/payload/starter/_basic/examples/range-slider.htm +171 -0
- package/payload/starter/_basic/examples/rich-text-editor.htm +115 -110
- package/payload/starter/_basic/examples/scroll-area.htm +293 -0
- package/payload/starter/_basic/examples/scrolling-text.htm +27 -6
- package/payload/starter/_basic/examples/search-input-2-light.htm +112 -0
- package/payload/starter/_basic/examples/search-input-3-dark.htm +105 -0
- package/payload/starter/_basic/examples/{search-input-v2-place.htm → search-input-place.htm} +25 -26
- package/payload/starter/_basic/examples/search-input.htm +159 -0
- package/payload/starter/_basic/examples/search-results.htm +85 -88
- package/payload/starter/_basic/examples/select-box-2-item-view.htm +304 -0
- package/payload/starter/_basic/examples/select-box-ozden-dark-text.htm +70 -0
- package/payload/starter/_basic/examples/select-box-ozden-item.htm +6 -5
- package/payload/starter/_basic/examples/select-box-ozden-text.htm +5 -3
- package/payload/starter/_basic/examples/select-box.htm +190 -159
- package/payload/starter/_basic/examples/settings-row.htm +92 -43
- package/payload/starter/_basic/examples/side-panel-2.htm +63 -25
- package/payload/starter/_basic/examples/side-panel.htm +84 -70
- package/payload/starter/_basic/examples/slider-2-split.htm +186 -0
- package/payload/starter/_basic/examples/slider-field-ozden.htm +286 -0
- package/payload/starter/_basic/examples/slider-field.htm +174 -134
- package/payload/starter/_basic/examples/slider.htm +257 -180
- package/payload/starter/_basic/examples/smart-button-3-ozden.htm +170 -257
- package/payload/starter/_basic/examples/smart-button-4-dark.htm +86 -47
- package/payload/starter/_basic/examples/smart-button-5-features.htm +130 -125
- package/payload/starter/_basic/examples/smart-button-alternatif.htm +266 -0
- package/payload/starter/_basic/examples/smart-button.htm +207 -174
- package/payload/starter/_basic/examples/smart-table-2.htm +43 -56
- package/payload/starter/_basic/examples/smart-table-3.htm +148 -113
- package/payload/starter/_basic/examples/smart-table-4.htm +37 -50
- package/payload/starter/_basic/examples/{smart-table-1.htm → smart-table-5.htm} +37 -48
- package/payload/starter/_basic/examples/smart-table.htm +183 -0
- package/payload/starter/_basic/examples/sortable-list.htm +191 -142
- package/payload/starter/_basic/examples/spark-line-box.htm +149 -161
- package/payload/starter/_basic/examples/splitter.htm +164 -0
- package/payload/starter/_basic/examples/status-bar.htm +166 -0
- package/payload/starter/_basic/examples/step-bar.htm +129 -0
- package/payload/starter/_basic/examples/stepper-2.htm +86 -58
- package/payload/starter/_basic/examples/stepper.htm +146 -135
- package/payload/starter/_basic/examples/tabs-2.htm +58 -67
- package/payload/starter/_basic/examples/tabs.htm +197 -180
- package/payload/starter/_basic/examples/tag-input.htm +150 -153
- package/payload/starter/_basic/examples/tap-effect.htm +23 -19
- package/payload/starter/_basic/examples/text-area-field.htm +104 -0
- package/payload/starter/_basic/examples/text-field-2.htm +113 -0
- package/payload/starter/_basic/examples/text-field-3-style.htm +105 -0
- package/payload/starter/_basic/examples/text-field-4-custom-unit.htm +96 -0
- package/payload/starter/_basic/examples/{input-b-ex5-warning-icon.htm → text-field-5-warning-icon.htm} +19 -19
- package/payload/starter/_basic/examples/text-field-6-modern-dark.htm +114 -0
- package/payload/starter/_basic/examples/text-field-7-modern.htm +106 -0
- package/payload/starter/_basic/examples/text-field-8-light-dark.htm +159 -0
- package/payload/starter/_basic/examples/text-field.htm +163 -0
- package/payload/starter/_basic/examples/time-line.htm +180 -116
- package/payload/starter/_basic/examples/time-picker.htm +240 -0
- package/payload/starter/_basic/examples/tiny-select.htm +118 -86
- package/payload/starter/_basic/examples/tiny-table.htm +40 -34
- package/payload/starter/_basic/examples/toast.htm +145 -147
- package/payload/starter/_basic/examples/toggle-2.htm +99 -68
- package/payload/starter/_basic/examples/toggle-3.htm +104 -101
- package/payload/starter/_basic/examples/toggle.htm +161 -93
- package/payload/starter/_basic/examples/tool-bar.htm +172 -0
- package/payload/starter/_basic/examples/tooltip-2.htm +110 -60
- package/payload/starter/_basic/examples/tooltip-3.htm +124 -65
- package/payload/starter/_basic/examples/tooltip-4.htm +218 -0
- package/payload/starter/_basic/examples/tooltip.htm +206 -124
- package/payload/starter/_basic/examples/tree-view.htm +210 -182
- package/payload/starter/_basic/examples/ui-effects.htm +207 -185
- package/payload/starter/_basic/examples/ui-standards.htm +200 -139
- package/payload/starter/_basic/examples/url-field.htm +120 -0
- package/payload/starter/_basic/examples/web-view.htm +109 -110
- package/payload/starter/_basic/min/accordion.min.js +2 -0
- package/payload/starter/_basic/min/action-button.min.js +1 -1
- package/payload/starter/_basic/min/app-bar.min.js +1 -1
- package/payload/starter/_basic/min/badge.min.js +2 -0
- package/payload/starter/_basic/min/bottom-bar.min.js +1 -1
- package/payload/starter/_basic/min/canvas.min.js +2 -0
- package/payload/starter/_basic/min/chat-view.min.js +2 -0
- package/payload/starter/_basic/min/check-box.min.js +1 -1
- package/payload/starter/_basic/min/code-editor.min.js +2 -0
- package/payload/starter/_basic/min/color-picker.min.js +2 -0
- package/payload/starter/_basic/min/context-menu.min.js +1 -1
- package/payload/starter/_basic/min/currency-field.min.js +2 -0
- package/payload/starter/_basic/min/data-table.min.js +1 -1
- package/payload/starter/_basic/min/date-picker.min.js +2 -0
- package/payload/starter/_basic/min/dialog.min.js +1 -1
- package/payload/starter/_basic/min/email-field.min.js +2 -0
- package/payload/starter/_basic/min/file-picker.min.js +2 -0
- package/payload/starter/_basic/min/filters.min.js +1 -1
- package/payload/starter/_basic/min/form.min.js +1 -1
- package/payload/starter/_basic/min/full-screen-select.min.js +1 -1
- package/payload/starter/_basic/min/gauge.min.js +1 -1
- package/payload/starter/_basic/min/graph-box.min.js +2 -0
- package/payload/starter/_basic/min/grid-group.min.js +2 -0
- package/payload/starter/_basic/min/hold-to-confirm-button.min.js +1 -1
- package/payload/starter/_basic/min/image-view.min.js +2 -0
- package/payload/starter/_basic/min/item-list.min.js +1 -1
- package/payload/starter/_basic/min/json-editor.min.js +2 -0
- package/payload/starter/_basic/min/json-view.min.js +2 -0
- package/payload/starter/_basic/min/label-editor.min.js +1 -1
- package/payload/starter/_basic/min/left-menu.min.js +1 -1
- package/payload/starter/_basic/min/line-progress-bar.min.js +1 -1
- package/payload/starter/_basic/min/loading-screen.min.js +1 -1
- package/payload/starter/_basic/min/log-view.min.js +2 -0
- package/payload/starter/_basic/min/login-page.min.js +2 -0
- package/payload/starter/_basic/min/markdown-view.min.js +2 -0
- package/payload/starter/_basic/min/menu-bar.min.js +2 -0
- package/payload/starter/_basic/min/mini-graph-box.min.js +1 -1
- package/payload/starter/_basic/min/minimal-accent.min.js +2 -0
- package/payload/starter/_basic/min/notice.min.js +1 -1
- package/payload/starter/_basic/min/number-field.min.js +2 -0
- package/payload/starter/_basic/min/numeric-keyboard.min.js +1 -1
- package/payload/starter/_basic/min/page-control.min.js +1 -1
- package/payload/starter/_basic/min/password-field.min.js +2 -0
- package/payload/starter/_basic/min/phone-field.min.js +2 -0
- package/payload/starter/_basic/min/progress-bar.min.js +1 -1
- package/payload/starter/_basic/min/property-panel.min.js +1 -1
- package/payload/starter/_basic/min/radio-button.min.js +1 -1
- package/payload/starter/_basic/min/range-slider.min.js +2 -0
- package/payload/starter/_basic/min/rich-text-editor.min.js +1 -1
- package/payload/starter/_basic/min/scroll-area.min.js +2 -0
- package/payload/starter/_basic/min/scrolling-text.min.js +1 -1
- package/payload/starter/_basic/min/search-input.min.js +2 -0
- package/payload/starter/_basic/min/search-results.min.js +1 -1
- package/payload/starter/_basic/min/select-box.min.js +1 -1
- package/payload/starter/_basic/min/settings-row.min.js +1 -1
- package/payload/starter/_basic/min/side-panel.min.js +1 -1
- package/payload/starter/_basic/min/slider-field.min.js +1 -1
- package/payload/starter/_basic/min/slider.min.js +1 -1
- package/payload/starter/_basic/min/smart-button.min.js +1 -1
- package/payload/starter/_basic/min/smart-table.min.js +1 -1
- package/payload/starter/_basic/min/sortable-list.min.js +1 -1
- package/payload/starter/_basic/min/spark-line-box.min.js +1 -1
- package/payload/starter/_basic/min/splitter.min.js +2 -0
- package/payload/starter/_basic/min/status-bar.min.js +2 -0
- package/payload/starter/_basic/min/step-bar.min.js +2 -0
- package/payload/starter/_basic/min/stepper.min.js +1 -1
- package/payload/starter/_basic/min/tabs.min.js +1 -1
- package/payload/starter/_basic/min/tag-input.min.js +1 -1
- package/payload/starter/_basic/min/text-area-field.min.js +2 -0
- package/payload/starter/_basic/min/text-field.min.js +2 -0
- package/payload/starter/_basic/min/time-line.min.js +1 -1
- package/payload/starter/_basic/min/time-picker.min.js +2 -0
- package/payload/starter/_basic/min/tiny-select.min.js +1 -1
- package/payload/starter/_basic/min/toast.min.js +1 -1
- package/payload/starter/_basic/min/toggle.min.js +1 -1
- package/payload/starter/_basic/min/tool-bar.min.js +2 -0
- package/payload/starter/_basic/min/tooltip.min.js +1 -1
- package/payload/starter/_basic/min/tree-view.min.js +1 -1
- package/payload/starter/_basic/min/ui-effects.min.js +1 -1
- package/payload/starter/_basic/min/url-field.min.js +2 -0
- package/payload/starter/_basic/min/web-view.min.js +1 -1
- package/payload/templates/booking/app/app.js +11 -8
- package/payload/templates/booking/app/settings.js +4 -4
- package/payload/templates/booking/index.htm +3 -3
- package/payload/templates/booking/pages/account.js +6 -6
- package/payload/templates/booking/pages/book.js +1 -1
- package/payload/templates/booking/pages/services.js +5 -4
- package/payload/templates/classic/app/app.js +15 -11
- package/payload/templates/classic/app/settings.js +22 -20
- package/payload/templates/classic/assets/_attribute.txt +2 -0
- package/payload/templates/classic/assets/cards/dill.png +0 -0
- package/payload/templates/classic/assets/cards/fennel.png +0 -0
- package/payload/templates/classic/assets/cards/juniper.png +0 -0
- package/payload/templates/classic/assets/cards/olives.png +0 -0
- package/payload/templates/classic/assets/cards/oregano.png +0 -0
- package/payload/templates/classic/assets/cards/pepper.png +0 -0
- package/payload/templates/classic/assets/cards/rosehip.png +0 -0
- package/payload/templates/classic/assets/categories/cappuccino.png +0 -0
- package/payload/templates/classic/assets/categories/chocolate-milk.png +0 -0
- package/payload/templates/classic/assets/categories/coffee.png +0 -0
- package/payload/templates/classic/assets/categories/frappe.png +0 -0
- package/payload/templates/classic/assets/categories/iced-caffee.png +0 -0
- package/payload/templates/classic/assets/categories/milkshake.png +0 -0
- package/payload/templates/classic/assets/categories/orange-juice.png +0 -0
- package/payload/templates/classic/assets/categories/tea.png +0 -0
- package/payload/templates/classic/index.htm +2 -2
- package/payload/templates/classic/pages/example.js +10 -10
- package/payload/templates/classic/pages/examples.js +44 -43
- package/payload/templates/classic/pages/home.js +16 -15
- package/payload/templates/classic/pages/info-pages.js +5 -5
- package/payload/templates/classic/pages/search.js +8 -7
- package/payload/templates/classic/pages/settings.js +13 -13
- package/payload/templates/classic/pages/tasks.js +1 -0
- package/payload/templates/classic/pages/template-pages.js +12 -11
- package/payload/templates/coffee-shop/app/app.js +12 -8
- package/payload/templates/coffee-shop/app/settings.js +4 -4
- package/payload/templates/coffee-shop/index.htm +3 -3
- package/payload/templates/coffee-shop/pages/drink.js +1 -1
- package/payload/templates/coffee-shop/pages/menu.js +5 -4
- package/payload/templates/forms/TEMPLATE.md +1 -1
- package/payload/templates/forms/appointment-form.htm +55 -53
- package/payload/templates/forms/contact-form-to-mail.htm +38 -37
- package/payload/templates/forms/contact-form-to-supabase.htm +47 -46
- package/payload/templates/forms/dark-contact-form.htm +43 -40
- package/payload/templates/forms/event-registration-form.htm +80 -77
- package/payload/templates/forms/feedback-form.htm +54 -54
- package/payload/templates/forms/order-form.htm +88 -84
- package/payload/templates/forms/recruitment-form.htm +60 -60
- package/payload/templates/forms/service/readme.md +9 -8
- package/payload/templates/forms/service/send-form-mail.php +38 -21
- package/payload/templates/forms/support-ticket-form.htm +67 -65
- package/payload/templates/panel/common/module-page.js +2 -2
- package/payload/templates/panel/common/theme.js +37 -10
- package/payload/templates/panel/common/top-bar.js +45 -40
- package/payload/templates/panel/index.htm +59 -60
- package/payload/templates/panel/module10/greenhouse.htm +98 -113
- package/payload/templates/panel/module11/arduino-projects.htm +47 -58
- package/payload/templates/panel/module6/energy-hub.htm +71 -103
- package/payload/templates/panel/module7/3d-printers.htm +58 -81
- package/payload/templates/panel/module8/cold-rooms.htm +58 -79
- package/payload/templates/panel/module9/elevator-fleet.htm +72 -93
- package/payload/templates/panel/pages/activity.js +134 -152
- package/payload/templates/panel/pages/contents.js +291 -308
- package/payload/templates/panel/pages/customers.js +250 -267
- package/payload/templates/panel/pages/edit-user.js +31 -30
- package/payload/templates/panel/pages/home.js +39 -70
- package/payload/templates/panel/pages/media.js +166 -183
- package/payload/templates/panel/pages/notifications.js +7 -7
- package/payload/templates/panel/pages/orders.js +200 -217
- package/payload/templates/panel/pages/products.js +259 -278
- package/payload/templates/panel/pages/reports.js +74 -123
- package/payload/templates/panel/pages/roles.js +57 -60
- package/payload/templates/panel/pages/settings.js +127 -143
- package/payload/templates/panel/pages/user-actions.js +106 -110
- package/payload/templates/panel/pages/user-list.js +221 -238
- package/payload/templates/panel/pages/users.js +14 -29
- package/payload/templates/shop/TEMPLATE.md +1 -1
- package/payload/templates/shop/app/app.js +11 -8
- package/payload/templates/shop/app/settings.js +4 -4
- package/payload/templates/shop/index.htm +3 -3
- package/payload/templates/shop/pages/account.js +7 -7
- package/payload/templates/shop/pages/cart.js +1 -1
- package/payload/templates/shop/pages/checkout.js +2 -2
- package/payload/templates/shop/pages/product.js +2 -2
- package/payload/templates/shop/pages/shop.js +6 -5
- package/payload/templates/starter/TEMPLATE.md +1 -1
- package/payload/templates/starter/app/app.js +12 -8
- package/payload/templates/starter/app/settings.js +14 -11
- package/payload/templates/starter/index.htm +3 -3
- package/payload/templates/starter/pages/about.js +1 -1
- package/payload/templates/starter/pages/home.js +2 -2
- package/payload/templates/starter/pages/product.js +1 -1
- package/payload/templates/starter/pages/products.js +5 -5
- package/payload/templates/starter/pages/settings.js +1 -1
- package/payload/templates/starter/pages/tasks.js +8 -8
- package/payload/templates/starter/pages/website.js +1 -1
- package/payload/starter/_basic/comp/chart-box/chart-4.5.1.umd.min.js +0 -13
- package/payload/starter/_basic/comp/chart-box/chart-js-LICENSE.md +0 -9
- package/payload/starter/_basic/comp/chart-box.js +0 -868
- package/payload/starter/_basic/comp/email-input-b.js +0 -57
- package/payload/starter/_basic/comp/input-b.js +0 -759
- package/payload/starter/_basic/comp/password-input-b.js +0 -164
- package/payload/starter/_basic/comp/search-input-v2.js +0 -427
- package/payload/starter/_basic/comp/textarea-b.js +0 -184
- package/payload/starter/_basic/comp/url-input-b.js +0 -145
- package/payload/starter/_basic/examples/badgeV2.htm +0 -68
- package/payload/starter/_basic/examples/chart-box.htm +0 -287
- package/payload/starter/_basic/examples/check-box-1.htm +0 -220
- package/payload/starter/_basic/examples/currency-input-b.htm +0 -71
- package/payload/starter/_basic/examples/email-input-b.htm +0 -67
- package/payload/starter/_basic/examples/input-b-ex1.htm +0 -132
- package/payload/starter/_basic/examples/input-b-ex2.htm +0 -136
- package/payload/starter/_basic/examples/input-b-ex3-style.htm +0 -113
- package/payload/starter/_basic/examples/input-b-ex4-custom-unit.htm +0 -112
- package/payload/starter/_basic/examples/input-b-ex6-dark.htm +0 -108
- package/payload/starter/_basic/examples/input-b-ex7-ozden.htm +0 -153
- package/payload/starter/_basic/examples/number-input-b.htm +0 -68
- package/payload/starter/_basic/examples/password-input-b.htm +0 -70
- package/payload/starter/_basic/examples/phone-input-b-select-country.htm +0 -298
- package/payload/starter/_basic/examples/phone-input-b.htm +0 -72
- package/payload/starter/_basic/examples/radio-button-1.htm +0 -264
- package/payload/starter/_basic/examples/search-input-v2-ozden.htm +0 -128
- package/payload/starter/_basic/examples/search-input-v2.htm +0 -65
- package/payload/starter/_basic/examples/select-color.htm +0 -215
- package/payload/starter/_basic/examples/select-date.htm +0 -244
- package/payload/starter/_basic/examples/select-file.htm +0 -268
- package/payload/starter/_basic/examples/select-time.htm +0 -249
- package/payload/starter/_basic/examples/smart-button-2.htm +0 -220
- package/payload/starter/_basic/examples/textarea-b.htm +0 -76
- package/payload/starter/_basic/examples/unfinished-login-page-dark-supabase.htm +0 -221
- package/payload/starter/_basic/examples/unfinished-login-page-supabase.htm +0 -221
- package/payload/starter/_basic/examples/url-input-b.htm +0 -85
- package/payload/starter/_basic/min/badge-v2.min.js +0 -2
- package/payload/starter/_basic/min/chart-box.min.js +0 -2
- package/payload/starter/_basic/min/currency-input-b.min.js +0 -2
- package/payload/starter/_basic/min/email-input-b.min.js +0 -2
- package/payload/starter/_basic/min/input-b.min.js +0 -2
- package/payload/starter/_basic/min/login-page-v2.min.js +0 -2
- package/payload/starter/_basic/min/number-input-b.min.js +0 -2
- package/payload/starter/_basic/min/password-input-b.min.js +0 -2
- package/payload/starter/_basic/min/phone-input-b.min.js +0 -2
- package/payload/starter/_basic/min/search-input-v2.min.js +0 -2
- package/payload/starter/_basic/min/select-color.min.js +0 -2
- package/payload/starter/_basic/min/select-date.min.js +0 -2
- package/payload/starter/_basic/min/select-file.min.js +0 -2
- package/payload/starter/_basic/min/select-time.min.js +0 -2
- package/payload/starter/_basic/min/textarea-b.min.js +0 -2
- package/payload/starter/_basic/min/url-input-b.min.js +0 -2
- package/payload/templates/panel/common/bridge.min.js +0 -0
- package/payload/templates/panel/common/full-view.min.js +0 -1
- package/payload/templates/panel/common/main-view.min.js +0 -1
- package/payload/templates/panel/common/module-page.min.js +0 -1
- package/payload/templates/panel/common/right-view.min.js +0 -1
- package/payload/templates/panel/common/start-page.min.js +0 -1
- package/payload/templates/panel/common/top-bar-v25-07-29-1.js +0 -330
- package/payload/templates/panel/common/top-bar-v25-07-29-2.js +0 -265
- package/payload/templates/panel/common/top-bar.min.js +0 -1
- package/payload/templates/panel/common/ui-standards.min.js +0 -1
- package/payload/templates/panel/managers/database.min.js +0 -1
- package/payload/templates/panel/managers/login.min.js +0 -1
- package/payload/templates/panel/pages/_page-template.min.js +0 -1
- package/payload/templates/panel/pages/contents.min.js +0 -1
- package/payload/templates/panel/pages/edit-user.min.js +0 -1
- package/payload/templates/panel/pages/edit-users-table.min.js +0 -1
- package/payload/templates/panel/pages/home.min.js +0 -1
- package/payload/templates/panel/pages/notifications.min.js +0 -1
- package/payload/templates/panel/pages/reports.min.js +0 -1
- package/payload/templates/panel/pages/settings.min.js +0 -1
- package/payload/templates/panel/pages/user-actions.min.js +0 -2
- package/payload/templates/panel/pages/users.min.js +0 -1
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/hide-btn.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/hide-btn2.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/show-btn.png +0 -0
- /package/payload/starter/_basic/comp/{password-input-b → password-field}/show-btn2.png +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/clear-round.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/clear.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/filter.png +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/filter.svg +0 -0
- /package/payload/starter/_basic/comp/{search-input-v2 → search-input}/search.svg +0 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
# 5. Events and state
|
|
2
|
+
|
|
3
|
+
*Türkçe: [5. Olaylar ve durum](turkce/05-events-and-state.md)*
|
|
4
|
+
|
|
5
|
+
A command answers once. An event is for what comes later: the steps of a long job, or a thing that happens by itself.
|
|
6
|
+
This chapter reads "Sizes", the events of the template, and the state its commands share; then it adds a watch of the
|
|
7
|
+
open folder: a file added in Finder or Explorer appears in the list by itself.
|
|
8
|
+
|
|
9
|
+
## When an answer is not enough
|
|
10
|
+
|
|
11
|
+
A long job: "Sizes" on `/usr` (68,000 files) took 1.7 s, and the page showed its progress 17 times meanwhile (the
|
|
12
|
+
release build, Apple M1 with 8 GB, 2026-11-04). A thing that happens by itself: a file appears in the open folder, and
|
|
13
|
+
nobody asked. Rust sends an event any number of times; the page listens to it:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
the page (ui/sizes.js) Rust (src-tauri/src/sizes.rs)
|
|
17
|
+
invoke("measure_folder", { path, job }) --> starts a thread, answers at once (null)
|
|
18
|
+
listen("measure-progress", ...) <-- app.emit("measure-progress", { job, files, bytes }) many times
|
|
19
|
+
listen("measure-folder", ...) <-- app.emit("measure-folder", { job, path, files, bytes })
|
|
20
|
+
listen("measure-done", ...) <-- app.emit("measure-done", { job, files, bytes, millis, stopped })
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Rust sends: app.emit
|
|
24
|
+
|
|
25
|
+
```rust
|
|
26
|
+
use tauri::{AppHandle, Emitter, State};
|
|
27
|
+
|
|
28
|
+
let _ = app.emit("measure-folder", folder_size); // folder_size: a FolderSize, a struct of sizes.rs
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- `emit` is a function of the trait `Emitter`: a trait gives a type more functions, and they are there only where the
|
|
32
|
+
trait is in `use`. Without it the compiler says ``no method named `emit` found for reference `&AppHandle` `` and,
|
|
33
|
+
under it, ``trait `Emitter` which provides `emit` is implemented but not in scope``.
|
|
34
|
+
- The payload is a struct with `#[derive(Clone, Serialize)]`: `Serialize` sends it as JSON, `Clone` is asked by
|
|
35
|
+
`emit` (without it: ``the trait bound `FolderSize: Clone` is not satisfied``). Two words in a name need
|
|
36
|
+
`#[serde(rename_all = "camelCase")]` ([4. Commands](04-commands.md)). `let _ =` drops the answer of `emit`.
|
|
37
|
+
- A name has only letters, digits, `-`, `/`, `:` and `_`. Another letter is an error of the page: ``invalid args
|
|
38
|
+
`event` for command `listen`: Event name must include only alphanumeric characters, `-`, `/`, `:` and `_`.``
|
|
39
|
+
|
|
40
|
+
## The page listens
|
|
41
|
+
|
|
42
|
+
`Backend.listen(eventName, handler)` of `ui/backend.js` calls `window.__TAURI__.event.listen(eventName, ...)` in the
|
|
43
|
+
app, and keeps the handler for `Backend.emitSample(eventName, payload)` in a browser.
|
|
44
|
+
|
|
45
|
+
- The event that `listen` gets has `event` (its name), `id` and `payload`; the handler of `Backend.listen` gets the
|
|
46
|
+
payload. Listen once, when the page starts (`Sizes.listen()`): every `listen` adds one more handler.
|
|
47
|
+
- **An event sent before the page listens is lost** (tried: 0 of 1 arrived). That is why the template listens first.
|
|
48
|
+
- `Backend.listen` listens for the whole life of the page. `listen` itself gives a promise of a function that stops
|
|
49
|
+
it (tried: a stopped handler got nothing): `const stopListening = await window.__TAURI__.event.listen(name, fn);`,
|
|
50
|
+
then `stopListening();`. `once` takes only the first event (tried: 1 of 2).
|
|
51
|
+
|
|
52
|
+
## "Sizes", step by step
|
|
53
|
+
|
|
54
|
+
**1. The page gives the job a number** and starts it (`Sizes.start()` in `ui/sizes.js`): `Sizes.lastJob++`,
|
|
55
|
+
`Sizes.job = Sizes.lastJob`, then `Backend.measureFolder(currentFolder.path, Sizes.job)`.
|
|
56
|
+
|
|
57
|
+
**2. The command starts a thread and answers** (`src-tauri/src/sizes.rs`):
|
|
58
|
+
|
|
59
|
+
```rust
|
|
60
|
+
#[tauri::command]
|
|
61
|
+
pub fn measure_folder(app: AppHandle, measure: State<Measure>, path: String, job: u32) {
|
|
62
|
+
let stop = Arc::new(AtomicBool::new(false));
|
|
63
|
+
let old_stop = measure.stop_flag.lock().unwrap().replace(stop.clone());
|
|
64
|
+
if let Some(old_stop) = old_stop {
|
|
65
|
+
old_stop.store(true, Ordering::SeqCst);
|
|
66
|
+
}
|
|
67
|
+
std::thread::spawn(move || run_job(&app, job, &PathBuf::from(path), &stop));
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- `AtomicBool` is a `true` / `false` that two threads may read and write at once. `Arc` shares one value between
|
|
72
|
+
threads: `stop.clone()` is one more handle to the same flag. The flag of the job before is set: one job at a time.
|
|
73
|
+
- `std::thread::spawn(move || ...)` runs the function in a thread of its own; `move` gives it `app`, `path` and
|
|
74
|
+
`stop`. The command ends at once, so it is a plain command ([4. Commands](04-commands.md)).
|
|
75
|
+
|
|
76
|
+
**3. The thread sends events.** `run_job` measures each folder inside, sends `measure-folder` after each one and
|
|
77
|
+
`measure-done` at the end. `measure-progress` comes at most every `PROGRESS_INTERVAL` (100 ms): a folder of a million
|
|
78
|
+
files would send a million events otherwise.
|
|
79
|
+
|
|
80
|
+
**4. The page drops what is not its job:** every handler of `ui/sizes.js` starts with
|
|
81
|
+
`if (folderSize.job != Sizes.job) return;`. WHY the page gives the number, not Rust: an event of a small folder can
|
|
82
|
+
come before the answer of `measure_folder`, so the page must know the number before it asks.
|
|
83
|
+
|
|
84
|
+
**5. Stop.** `stop_measure` sets the flag; the thread sees it at its next folder and sends `measure-done` with
|
|
85
|
+
`stopped: true`.
|
|
86
|
+
|
|
87
|
+
## State: .manage() and State<T>
|
|
88
|
+
|
|
89
|
+
```rust
|
|
90
|
+
#[derive(Default)]
|
|
91
|
+
pub struct Measure {
|
|
92
|
+
stop_flag: Mutex<Option<Arc<AtomicBool>>>, // the stop flag of the running job
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
- `.manage(sizes::Measure::default())` in `main.rs` gives Tauri one value of this type for the life of the app
|
|
97
|
+
(`#[derive(Default)]` makes `default()`: every field empty). A command takes it as `measure: State<Measure>`; a
|
|
98
|
+
place that has only the `AppHandle` (a thread) takes it with `app.state::<Measure>()` (and `use tauri::Manager`).
|
|
99
|
+
- Two commands can run at the same time on two threads. A `Mutex` lets one of them hold the value at a time:
|
|
100
|
+
`lock()` waits for its turn and gives the value; it is let go at the end of the line (or of the block).
|
|
101
|
+
`.unwrap()` stops the app only when a thread stopped while it held the lock.
|
|
102
|
+
- WHY state and not a global value: Rust allows a changing global only with care. A state is made once in `main.rs`,
|
|
103
|
+
has a type, and reaches only the commands that name it.
|
|
104
|
+
- A command whose state is not given to `.manage()` compiles, and fails when the page calls it (tried):
|
|
105
|
+
``state not managed for field `watch` on command `watch_folder`. You must call `.manage()` before using this command``
|
|
106
|
+
|
|
107
|
+
## A watch of the open folder
|
|
108
|
+
|
|
109
|
+
Rust looks at the open folder once a second. When its list changed (an entry added, deleted or renamed: then the
|
|
110
|
+
time of the folder changes), it sends `folder-changed`, and the page reads the folder again.
|
|
111
|
+
|
|
112
|
+
**1. The command and its thread:** a new file, `watch.rs` in `src-tauri/src/` (with the header of the other files):
|
|
113
|
+
|
|
114
|
+
```rust
|
|
115
|
+
use serde::Serialize;
|
|
116
|
+
use std::fs;
|
|
117
|
+
use std::path::{Path, PathBuf};
|
|
118
|
+
use std::sync::Mutex;
|
|
119
|
+
use std::time::{Duration, SystemTime};
|
|
120
|
+
use tauri::{AppHandle, Emitter, Manager, State};
|
|
121
|
+
|
|
122
|
+
// WHY: one look at the folder in a second costs nothing, and a person does not wait longer for the new list
|
|
123
|
+
const WATCH_INTERVAL: Duration = Duration::from_secs(1);
|
|
124
|
+
|
|
125
|
+
/// The number of the watch that runs (0: none): kept by Tauri (.manage() in main.rs)
|
|
126
|
+
#[derive(Default)]
|
|
127
|
+
pub struct Watch {
|
|
128
|
+
job: Mutex<u32>,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
#[derive(Clone, Serialize)]
|
|
132
|
+
struct FolderChanged {
|
|
133
|
+
job: u32,
|
|
134
|
+
path: String,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// Watches a folder until the page watches another one. It answers at once: a thread looks at the folder.
|
|
138
|
+
#[tauri::command]
|
|
139
|
+
pub fn watch_folder(app: AppHandle, watch: State<Watch>, path: String, job: u32) {
|
|
140
|
+
*watch.job.lock().unwrap() = job;
|
|
141
|
+
std::thread::spawn(move || watch_until_replaced(&app, &PathBuf::from(path), job));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
fn watch_until_replaced(app: &AppHandle, folder: &Path, job: u32) {
|
|
145
|
+
let mut last_change = changed_at(folder);
|
|
146
|
+
loop {
|
|
147
|
+
std::thread::sleep(WATCH_INTERVAL);
|
|
148
|
+
if !is_current(app, job) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
let change = changed_at(folder);
|
|
152
|
+
if change == last_change {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
last_change = change;
|
|
156
|
+
let changed = FolderChanged {
|
|
157
|
+
job,
|
|
158
|
+
path: folder.display().to_string(),
|
|
159
|
+
};
|
|
160
|
+
let _ = app.emit("folder-changed", changed);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// WHY app.state(): the thread has no State argument; the AppHandle gives the same state
|
|
165
|
+
fn is_current(app: &AppHandle, job: u32) -> bool {
|
|
166
|
+
let watch = app.state::<Watch>();
|
|
167
|
+
let current_job = *watch.job.lock().unwrap();
|
|
168
|
+
current_job == job
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/// The time of the last change of the list of a folder (an entry added, deleted or renamed). None: not readable.
|
|
172
|
+
pub fn changed_at(folder: &Path) -> Option<SystemTime> {
|
|
173
|
+
fs::metadata(folder)
|
|
174
|
+
.and_then(|metadata| metadata.modified())
|
|
175
|
+
.ok()
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- `*watch.job.lock().unwrap() = job;` writes into the value that the lock gives (`*` is "the value itself").
|
|
180
|
+
- `loop` runs until `return`; `continue` goes to its next turn. The thread of an old watch ends at its next look.
|
|
181
|
+
- A test of `changed_at`, as the one of chapter 4: a folder in the temporary folder, `changed_at` before and after a
|
|
182
|
+
new file in it (wait 50 ms between them), `assert_ne!` of the two.
|
|
183
|
+
- Tried on macOS: a new file, a rename, a deletion and a new folder change the time of the folder; a file written
|
|
184
|
+
again, or a file in a folder inside, does not. A deleted folder gives `None`: one event, and the page shows its
|
|
185
|
+
error. The system can also report changes itself (the crate `notify` does it); one look a second needs no crate.
|
|
186
|
+
|
|
187
|
+
**2. Into the app.** In `src-tauri/src/main.rs`: `mod watch;`, `.manage(watch::Watch::default())` under the
|
|
188
|
+
`.manage(...)` of `sizes.rs`, and `watch::watch_folder` at the end of the list of `generate_handler!`.
|
|
189
|
+
|
|
190
|
+
**3. The call**, in `ui/backend.js` (to try the handler in a browser, type in the console:
|
|
191
|
+
`Backend.emitSample("folder-changed", { job: watchJob, path: currentFolder.path })`):
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
// Rust watches the folder and sends "folder-changed" { job, path } when an entry is added, deleted or renamed in
|
|
195
|
+
// it. Only the last folder is watched. In a browser the sample folders do not change: no event comes.
|
|
196
|
+
Backend.watchFolder = function (path, job) {
|
|
197
|
+
if (!Backend.isInApp()) return Promise.resolve(null);
|
|
198
|
+
return window.__TAURI__.core.invoke("watch_folder", { path: path, job: job });
|
|
199
|
+
};
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**4. The page** (`ui/app.js`): a number next to `let showHidden = false;`, the listener in `start()` next to
|
|
203
|
+
`Sizes.listen();`, two lines in the `if (isNewFolder)` block of `showFolder()`, and the handler:
|
|
204
|
+
|
|
205
|
+
```js
|
|
206
|
+
let watchJob = 0; // the number of the last folder Rust watches
|
|
207
|
+
|
|
208
|
+
Backend.listen("folder-changed", onFolderChanged);
|
|
209
|
+
|
|
210
|
+
watchJob++;
|
|
211
|
+
Backend.watchFolder(folder.path, watchJob);
|
|
212
|
+
|
|
213
|
+
// Rust: an entry of the open folder was added, deleted or renamed. The folder is read again.
|
|
214
|
+
const onFolderChanged = function (changed) {
|
|
215
|
+
if (changed.job != watchJob) return;
|
|
216
|
+
openFolder(currentFolder.path);
|
|
217
|
+
};
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Run `cargo tauri dev`, open a folder, and add a file to it in Finder (or Explorer): the row is there about a second
|
|
221
|
+
later (tried on macOS: 0.7 to 1.6 s). The window check can not add a file (the page has no command for it): the test
|
|
222
|
+
of `changed_at` and this try are the proof.
|
|
223
|
+
|
|
224
|
+
## An event from the page to Rust
|
|
225
|
+
|
|
226
|
+
The page can send an event too (`ui/backend.js`), and Rust listens to it in `.setup()` of the builder
|
|
227
|
+
(`src-tauri/src/main.rs`, after the `.manage(...)` lines, with `use tauri::Listener;` at the top of the file):
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
// An event of the page to Rust (app.listen() in main.rs). In a browser nobody listens.
|
|
231
|
+
Backend.emit = function (eventName, payload) {
|
|
232
|
+
if (!Backend.isInApp()) return Promise.resolve();
|
|
233
|
+
return window.__TAURI__.event.emit(eventName, payload);
|
|
234
|
+
};
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
```rust
|
|
238
|
+
// An event of the page (Backend.emit in ui/backend.js). Its payload is a JSON text, with its quotes.
|
|
239
|
+
.setup(|app| {
|
|
240
|
+
app.listen("folder-opened", |event| {
|
|
241
|
+
println!("the page opened {}", event.payload());
|
|
242
|
+
});
|
|
243
|
+
Ok(())
|
|
244
|
+
})
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
- With `Backend.emit("folder-opened", folder.path)` in the `if (isNewFolder)` block, the terminal prints
|
|
248
|
+
`the page opened "/Users/me"` for every folder (tried); an object comes as `{"count":2,"path":"/x"}`. The window
|
|
249
|
+
check talks this way too: the page sends `check-done`, `src/check.rs` listens.
|
|
250
|
+
- Rust values from the payload: `serde_json::from_str`. `serde_json` is only for the window check in the template;
|
|
251
|
+
for the app, write `serde_json = "1"` and `window-check = []` in `Cargo.toml` (cargo refuses `dep:serde_json` for
|
|
252
|
+
a crate that is not optional).
|
|
253
|
+
- `.setup()` runs once, when the app starts: the place for what the whole app needs (a listener, a menu). `Ok(())`
|
|
254
|
+
is its answer: all went well. It runs under the window check too (tried), which is a plugin of its own.
|
|
255
|
+
- A command is better when the page wants an answer or a typed argument; an event, when it only tells.
|
|
256
|
+
|
|
257
|
+
## Events and more windows
|
|
258
|
+
|
|
259
|
+
`app.emit` goes to every window; `app.emit_to("main", "name", payload)` to the window with that label. In the page,
|
|
260
|
+
`window.__TAURI__.event.listen` hears the events of every window (tried: it got an `emit_to("main", ...)` and one to
|
|
261
|
+
a label no window has); `window.__TAURI__.webviewWindow.getCurrentWebviewWindow().listen` hears only the events of
|
|
262
|
+
its own window (tried: only the one to `"main"`). More windows:
|
|
263
|
+
[7. The window and the app](07-the-window-and-the-app.md).
|
|
264
|
+
|
|
265
|
+
## The usual mistakes
|
|
266
|
+
|
|
267
|
+
- **A name with a typo:** no error on either side; the page waits for an event that never comes. Copy the name.
|
|
268
|
+
- **Listening after Rust sent:** the event is lost. Listen in `start()`, before the first command.
|
|
269
|
+
- **An event of an old job:** it lands in the rows of another folder. Give every job a number and check it.
|
|
270
|
+
- **`listen` twice:** the handler runs twice ([11. Troubleshooting](11-troubleshooting.md)).
|
|
271
|
+
|
|
272
|
+
## Next
|
|
273
|
+
|
|
274
|
+
[6. Plugins](06-plugins.md): a feature of Tauri with no Rust to write, its permission, and a second plugin that keeps
|
|
275
|
+
the settings of the app.
|
|
@@ -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.
|