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,260 @@
|
|
|
1
|
+
# 3. The page
|
|
2
|
+
|
|
3
|
+
*Türkçe: [3. Sayfa](turkce/03-the-page.md)*
|
|
4
|
+
|
|
5
|
+
The page of the window is an ordinary basic.js page. This chapter shows what it is made of and where things are in
|
|
6
|
+
`ui/app.js`, then adds a button, a text and a message of your own, and a component of the kit.
|
|
7
|
+
|
|
8
|
+
## An ordinary basic.js page
|
|
9
|
+
|
|
10
|
+
`ui/index.html` only loads files, with `<script src>` and `<link>` lines, in this order:
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
basic/basic.min.css, basic/basic.min.js, basic/scroll-bar.min.js the library (the font is in basic/ too)
|
|
14
|
+
comp/components.min.js the components
|
|
15
|
+
backend.js, app.js, sizes.js the app
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
basic.js makes the whole page in JavaScript: there is no HTML to write in `<body>` and no CSS file of the page. When it
|
|
19
|
+
is loaded it makes the global `page` (the whole window); when the page is ready it calls the global `start()`, which
|
|
20
|
+
is in `ui/app.js`. The files share their names in the order they load: `sizes.js` uses `lineIcon()` and
|
|
21
|
+
`currentFolder` of `app.js`, with no `import`. The template has basic.js v26.11.10 (`basic.version`); it is taught by
|
|
22
|
+
its handbook (https://bug7a.github.io/basic.js-handbook/) and its site (https://bug7a.github.io/basic.js/).
|
|
23
|
+
|
|
24
|
+
## Objects and groups
|
|
25
|
+
|
|
26
|
+
A small page to try them. Make `hello.html` in `ui/`: a copy of `index.html` whose three lines under `THE APP` are
|
|
27
|
+
one line, `<script src="hello.js" type="text/javascript" charset="utf-8"></script>`. Then `hello.js` next to it:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
"use strict";
|
|
31
|
+
|
|
32
|
+
const BAR_STEP = 20; // px: the bar grows by this much for every count
|
|
33
|
+
|
|
34
|
+
let count = 0;
|
|
35
|
+
let lblCount, barCount;
|
|
36
|
+
|
|
37
|
+
const start = function () {
|
|
38
|
+
page.color = "#F4F5F2";
|
|
39
|
+
|
|
40
|
+
// GROUP: one under the other, in the middle of the window
|
|
41
|
+
VGroup({ align: "center center", gap: 16 });
|
|
42
|
+
|
|
43
|
+
lblCount = Label({ text: "0", fontSize: 48, bold: 1 });
|
|
44
|
+
|
|
45
|
+
// BOX: a bar as long as the count
|
|
46
|
+
barCount = Box({ width: BAR_STEP, height: 8, color: "#2F6FED", round: 4 });
|
|
47
|
+
|
|
48
|
+
// GROUP: side by side, only as large as its buttons
|
|
49
|
+
HGroup({ hug: 1, gap: 8 });
|
|
50
|
+
SmartButton({ labelText: "Less", onClick: function () { changeCount(-1); } });
|
|
51
|
+
SmartButton({ labelText: "More", tone: "cyan", onClick: function () { changeCount(1); } });
|
|
52
|
+
endGroup();
|
|
53
|
+
|
|
54
|
+
endGroup();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const changeCount = function (step) {
|
|
58
|
+
count = Math.max(0, count + step);
|
|
59
|
+
lblCount.text = String(count);
|
|
60
|
+
barCount.width = BAR_STEP * (count + 1);
|
|
61
|
+
};
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Open `hello.html` through the web server of chapter 1, click More and Less. Delete the two files when you are done:
|
|
65
|
+
every file of `ui/` goes into the app.
|
|
66
|
+
|
|
67
|
+
- An object is made where it is written, with its values in one object: `Label({ text: "0", fontSize: 48 })`.
|
|
68
|
+
- `VGroup` puts its objects one under the other, `HGroup` side by side, until `endGroup()`. A group is as large as
|
|
69
|
+
its box (100% x 100%); `hug: 1` makes it as large as what it holds.
|
|
70
|
+
- After it is made, an object changes with its values (`lblCount.text = ...`, `barCount.width = ...`), a component
|
|
71
|
+
with its `set...()` functions (`btnUp.setEnabled(0)` in `app.js`).
|
|
72
|
+
- **`text` is HTML.** A text that comes from Rust or from a person (a file name, a typed text) goes in with
|
|
73
|
+
`plainText`, so it is shown as it is written.
|
|
74
|
+
|
|
75
|
+
## The components of the template
|
|
76
|
+
|
|
77
|
+
`ui/comp/components.min.js` holds seven components of the kit (https://bug7a.github.io/js-components/):
|
|
78
|
+
|
|
79
|
+
| Component | In the template |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `SmartButton` | the buttons of the top bar (Up, Home, Open..., Sizes / Stop) |
|
|
82
|
+
| `Breadcrumbs` | the path of the folder at the top |
|
|
83
|
+
| `CheckBox` | Hidden files |
|
|
84
|
+
| `SmartTable` | the table: it makes only the rows that are seen, so 100,000 rows are shown at once |
|
|
85
|
+
| `SearchInput` | the Filter box under the table (`SmartTable` makes it) |
|
|
86
|
+
| `ContextMenu` | the list of the columns of the filter (a click on "Name" in it) |
|
|
87
|
+
| `Toast` | the messages, Ex: a folder that could not be opened |
|
|
88
|
+
|
|
89
|
+
The file is minified: read the params of a component in the header of its source, in the folder `comp/` of
|
|
90
|
+
https://github.com/bug7a/js-components (Ex: `smart-button.js`). Never guess a param.
|
|
91
|
+
|
|
92
|
+
## Where things are in ui/app.js
|
|
93
|
+
|
|
94
|
+
| To change | Look at |
|
|
95
|
+
|---|---|
|
|
96
|
+
| a color, a size, a column | the constants at the top (`PAGE_COLOR`, `ROW_HEIGHT`, `COLUMNS`) |
|
|
97
|
+
| an icon | `ICONS`: SVG texts, `lineIcon()` for a button, `twoToneIcon()` for a row |
|
|
98
|
+
| the top bar | `createTopBar()` |
|
|
99
|
+
| the table and its cells | `createTable()`, `createCellView()`, `updateCellView()`, `fitColumns()` |
|
|
100
|
+
| the status bar | `createStatusBar()`, `showCounts()`, `showSpeed()` |
|
|
101
|
+
| what is done with a folder | `openFolder()`, `showFolder()`, `toRow()` |
|
|
102
|
+
| a click, a key | `onRowClick()`, `onCrumbClick()`, `onHiddenChange()`, `KEY_ACTIONS`, `onKeyDown()` |
|
|
103
|
+
| how a number, a size, a date is written | `formatSize()`, `formatDate()`, `countText()` |
|
|
104
|
+
| Sizes; a call to Rust | `ui/sizes.js`; `ui/backend.js` |
|
|
105
|
+
|
|
106
|
+
## A button of your own
|
|
107
|
+
|
|
108
|
+
A Reload button reads the folder that is shown again (Ex: after a file was added outside the app). In `ui/app.js`,
|
|
109
|
+
add an icon to `ICONS`:
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
reload: lineIcon('<path d="M19.5 12a7.5 7.5 0 1 1-2.2-5.3"/><path d="M19.5 4.5v4h-4"/>'),
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
add `btnReload` to the line of `let` under it, and the button to `createTopBar()`, after `Sizes.createButton();`:
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
btnReload = SmartButton({
|
|
119
|
+
labelText: "", iconFile: ICONS.reload, ariaLabel: "Reload", onClick: reloadFolder,
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
and its function under `// *** FOLDERS:`:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
// The folder that is shown, read again (Ex: a file was added outside the app)
|
|
127
|
+
const reloadFolder = function () {
|
|
128
|
+
if (!currentFolder) return;
|
|
129
|
+
openFolder(currentFolder.path);
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
- `labelText: ""` makes an icon button (a square of 44 x 44 px); `ariaLabel` is the name a screen reader says.
|
|
134
|
+
- The icon is an SVG text, as every icon of the page: no picture file is needed.
|
|
135
|
+
- Each button takes room from the path. In the smallest window (760 px) the path now has room for `/` only; a
|
|
136
|
+
`minWidth` of 820 in `tauri.conf.json` gives it back.
|
|
137
|
+
|
|
138
|
+
## A text in the status bar
|
|
139
|
+
|
|
140
|
+
The biggest file of the folder, between the counts and the speed. In `createStatusBar()`, after `lblCount`:
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
lblBiggest = Label({
|
|
144
|
+
fontSize: STATUS_FONT_SIZE, textColor: STATUS_TEXT_COLOR, ellipsis: 1, css: { minWidth: "0px" },
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
add `lblBiggest` to the line of `let`, call `showBiggestFile(folder);` in `showFolder()` after
|
|
149
|
+
`showCounts(folder);`, and write the function under `showCounts()`:
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
// "The biggest: report.pdf (1.2 MB)"
|
|
153
|
+
const showBiggestFile = function (folder) {
|
|
154
|
+
const files = folder.entries.filter(function (entry) { return !entry.isFolder; });
|
|
155
|
+
if (files.length == 0) {
|
|
156
|
+
lblBiggest.plainText = "";
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const biggest = files.reduce(function (big, entry) { return (entry.size > big.size) ? entry : big; });
|
|
160
|
+
lblBiggest.plainText = "The biggest: " + biggest.name + " (" + formatSize(biggest.size) + ")";
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
- The name comes from the disk, through Rust: `plainText`, never `text`. A file can be named like an HTML tag; the
|
|
165
|
+
window check opens such a folder to prove that the page shows it as a name.
|
|
166
|
+
- `ellipsis: 1` cuts a long text with "…"; `minWidth: "0px"` lets the label get narrower than its text.
|
|
167
|
+
|
|
168
|
+
## A message
|
|
169
|
+
|
|
170
|
+
`Toast` shows a message that closes itself. Rust cuts a folder of more than 100,000 entries (`MAX_ENTRIES` of
|
|
171
|
+
`src-tauri/src/files.rs`); tell it. In `showFolder()`, after `showBiggestFile(folder);`, call `warnIfCut(folder);`:
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
// A folder of more than 100,000 entries (MAX_ENTRIES of files.rs): the table has the first ones only
|
|
175
|
+
const warnIfCut = function (folder) {
|
|
176
|
+
if (folder.entries.length == folder.total) return;
|
|
177
|
+
const total = countText(folder.total, "item");
|
|
178
|
+
Toast.warning("Rust sent the first " + formatNumber(folder.entries.length) + " of " + total + ".", {
|
|
179
|
+
key: "cut-folder",
|
|
180
|
+
titleText: "A big folder",
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- With `MAX_ENTRIES` at 3 (chapter 1) every folder of more than 3 entries shows it.
|
|
186
|
+
- `Toast.success`, `Toast.info`, `Toast.warning` and `Toast.error` take the message and its options: `titleText`,
|
|
187
|
+
`duration` (ms; 0: until it is closed), `key` (a toast with the same key is changed, not added again). A toast
|
|
188
|
+
shows its texts as text, so a name from Rust is safe in it.
|
|
189
|
+
|
|
190
|
+
## Another component of the kit
|
|
191
|
+
|
|
192
|
+
The page can load any component of the kit. Ex: `Tooltip`, a hint over an object:
|
|
193
|
+
|
|
194
|
+
1. Copy `comp/tooltip.js` of https://github.com/bug7a/js-components into `ui/comp/`.
|
|
195
|
+
2. Load it in `ui/index.html`, after `components.min.js`:
|
|
196
|
+
|
|
197
|
+
```html
|
|
198
|
+
<script src="comp/tooltip.js" type="text/javascript" charset="utf-8"></script>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
3. Use it. In `createTopBar()`, after the Reload button:
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
Tooltip({ target: btnReload, hintText: "Read the folder again", hintPosition: "bottom" });
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
- `SmartTable` uses it when it is there: a name cut with "…" is shown whole in a bubble.
|
|
208
|
+
- A component that extends another one (Ex: `email-field.js` extends `text-field.js`) loads after it. One whose
|
|
209
|
+
header names files of a folder of its own name (`comp/<name>/`) needs that folder in `ui/comp/` too.
|
|
210
|
+
- A component file needs a basic.js at least as new as the one it was written for.
|
|
211
|
+
|
|
212
|
+
## The rules of the window
|
|
213
|
+
|
|
214
|
+
In the window, the page lives under the security policy of `tauri.conf.json` ([8. Security](08-security.md)):
|
|
215
|
+
|
|
216
|
+
- **Scripts only from the files of `ui/`.** A script from the web, `eval()` or `new Function()`, an `onclick="..."`
|
|
217
|
+
text in HTML and a `<script>` made by code do not run. (A `<script>` written in `ui/index.html` itself runs: Tauri
|
|
218
|
+
adds its hash to the policy when it builds the app.) Keep the code in the `.js` files: the project tests read them.
|
|
219
|
+
- **Pictures** from the files of `ui/` or from `data:` and `blob:` addresses (the icons of the page are `data:`
|
|
220
|
+
texts); not from the web. **Fonts** from the files of `ui/` or `data:`.
|
|
221
|
+
- **Calls** go to Rust only: a `fetch()` to the web is stopped. Call the web from Rust, or open the policy for that
|
|
222
|
+
one address, if that service accepts calls from other sites (chapter 8).
|
|
223
|
+
- A browser has no such policy: a thing that works through Live Server can be stopped in the window. The window
|
|
224
|
+
check is the proof ([9. Tests and checks](09-tests-and-checks.md)).
|
|
225
|
+
|
|
226
|
+
**In a browser** `Backend.isInApp()` is `false`, and every function of `Backend` gives a sample answer
|
|
227
|
+
(`Promise.resolve(...)`) instead of calling Rust. Keep it so for a function you add (chapter 4 does it for a
|
|
228
|
+
command), and call `window.__TAURI__` only in `ui/backend.js`: the page then also opens with no Rust at all.
|
|
229
|
+
|
|
230
|
+
## The size of the window
|
|
231
|
+
|
|
232
|
+
The window is 960 x 640 and never smaller than 760 x 420 (`tauri.conf.json`). The page is always the whole window,
|
|
233
|
+
and the template places its parts with `"100%"` and `calc()`, so the table grows and shrinks with it. What can not
|
|
234
|
+
follow by itself is fitted at every change of the size, in the function that `start()` gives to `page.onResize()`:
|
|
235
|
+
`fitCrumbs()` collapses the path, `fitColumns()` gives the name column the width that is left.
|
|
236
|
+
|
|
237
|
+
A third one hides the biggest file in a narrow window. Add `fitStatusBar();` to that function, and once more after
|
|
238
|
+
`createStatusBar();` in `start()` (for the first size):
|
|
239
|
+
|
|
240
|
+
```js
|
|
241
|
+
// At the top, with the other constants:
|
|
242
|
+
const WIDE_STATUS_WIDTH = 900; // px: a narrower window does not show the biggest file
|
|
243
|
+
|
|
244
|
+
// Before createStatusBar(): a narrow window keeps the counts and the speed
|
|
245
|
+
const fitStatusBar = function () {
|
|
246
|
+
lblBiggest.visible = (page.width >= WIDE_STATUS_WIDTH) ? 1 : 0;
|
|
247
|
+
};
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## No npm, no bundler
|
|
251
|
+
|
|
252
|
+
The files of `ui/` are used as they are. A library you want is one more file: its build that is one `.js` file and
|
|
253
|
+
makes a global name (often `.min.js`, a "UMD" or "browser" build), in a folder of `ui/` (Ex: `lib`; the project tests
|
|
254
|
+
read only the `.js` files directly in `ui/`), loaded with a `<script src>` line before the files that use it. A
|
|
255
|
+
`<script>` with an address of the web (a CDN) is stopped by `cargo test` (chapter 9), and a library that comes only as
|
|
256
|
+
`import` modules needs a bundler. Often a crate in Rust does the same work (chapter 4).
|
|
257
|
+
|
|
258
|
+
## Next
|
|
259
|
+
|
|
260
|
+
[4. Commands](04-commands.md): the page asks, Rust answers. A command read line by line, and a new one of your own.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# 4. Commands
|
|
2
|
+
|
|
3
|
+
*Türkçe: [4. Komutlar](turkce/04-commands.md)*
|
|
4
|
+
|
|
5
|
+
A command is a Rust function that the page calls and waits for. This chapter reads the command of the template line
|
|
6
|
+
by line, then adds one of your own: a preview of a text file, with its test and its sample answer.
|
|
7
|
+
|
|
8
|
+
## The idea
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
the page (ui/backend.js) Rust (src-tauri/src/files.rs)
|
|
12
|
+
invoke("list_folder", { path, showHidden }) --> list_folder(app, path, show_hidden)
|
|
13
|
+
.then(folder) or .catch(error) <-- Ok(Folder) or Err(String)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The page gives a name and an object of arguments. Tauri finds the command of that name, turns the arguments into Rust
|
|
17
|
+
values, runs it and sends its answer back as JSON. The page gets a promise. There is no server and no port.
|
|
18
|
+
|
|
19
|
+
## The command of the template, line by line
|
|
20
|
+
|
|
21
|
+
`src-tauri/src/files.rs`:
|
|
22
|
+
|
|
23
|
+
```rust
|
|
24
|
+
#[tauri::command(async)]
|
|
25
|
+
pub fn list_folder(
|
|
26
|
+
app: tauri::AppHandle,
|
|
27
|
+
path: String,
|
|
28
|
+
show_hidden: bool,
|
|
29
|
+
) -> Result<Folder, String> {
|
|
30
|
+
let folder = if path.is_empty() {
|
|
31
|
+
app.path().home_dir().map_err(|error| error.to_string())?
|
|
32
|
+
} else {
|
|
33
|
+
PathBuf::from(path)
|
|
34
|
+
};
|
|
35
|
+
read_folder(&folder, show_hidden)
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- `#[tauri::command(async)]` makes the function a command (`(async)`: "Which thread runs a command" below). `pub fn`
|
|
40
|
+
is a function that other files (`main.rs`) may use.
|
|
41
|
+
- Every argument has a type: `path: String` is a text, `show_hidden: bool` is `true` or `false`; the page sends them.
|
|
42
|
+
Tauri gives the others itself, wherever they stand in the list: `app: tauri::AppHandle` (the app: its folders with
|
|
43
|
+
`app.path()`, its events, its state), `state: tauri::State<T>` (a value the app keeps for its commands, chapter 5)
|
|
44
|
+
and `window: tauri::WebviewWindow` (the window that called; tried: its `label()` is `"main"`).
|
|
45
|
+
- `-> Result<Folder, String>`: the answer is `Ok(a Folder)`, or `Err(a text)`. The last line without `;` is the
|
|
46
|
+
answer of a function: here the answer of `read_folder`.
|
|
47
|
+
- A `String` is a text the function owns. `&` lends a value without giving it away (`&folder`): a lent text is a
|
|
48
|
+
`&str`, a lent path a `&Path`.
|
|
49
|
+
- `|error| error.to_string()` is a small function, as `function (error) { return String(error); }`. `map_err` turns
|
|
50
|
+
the error of `home_dir()` into a text with it; `?` gives the value of an `Ok`, or ends the command with the `Err`.
|
|
51
|
+
|
|
52
|
+
## The three places of a command
|
|
53
|
+
|
|
54
|
+
1. **The function** with `#[tauri::command]` in a file of `src-tauri/src/`. A file is a *module*: `mod files;` at the
|
|
55
|
+
top of `main.rs` makes `files.rs` a part of the app.
|
|
56
|
+
2. **Its name** in `tauri::generate_handler![...]` of `src-tauri/src/main.rs`, with its module: `files::list_folder`.
|
|
57
|
+
3. **A function of `Backend`** in `ui/backend.js`, with its sample answer for a browser:
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
Backend.listFolder = function (path, showHidden) {
|
|
61
|
+
if (!Backend.isInApp()) return Backend.listSampleFolder(path, showHidden);
|
|
62
|
+
return window.__TAURI__.core.invoke("list_folder", { path: path, showHidden: showHidden });
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**The names.** The page calls a command by the name of its function (`"list_folder"`). The keys of the arguments are
|
|
67
|
+
the names of Rust in camelCase: `show_hidden` is `showHidden`; a key written as in Rust is not read, and the call
|
|
68
|
+
fails as if it was missing. `#[tauri::command(rename_all = "snake_case")]` makes one command take the names of Rust
|
|
69
|
+
as they are (tried); the template does not use it.
|
|
70
|
+
|
|
71
|
+
## A command of your own: a preview
|
|
72
|
+
|
|
73
|
+
A click on a file shows its first characters in a message. Rust reads only the start of the file, so a file of some
|
|
74
|
+
GB costs nothing.
|
|
75
|
+
|
|
76
|
+
**1. The command:** a new file, `preview.rs` in `src-tauri/src/` (with the header of the other files):
|
|
77
|
+
|
|
78
|
+
```rust
|
|
79
|
+
use serde::Serialize;
|
|
80
|
+
use std::fs::File;
|
|
81
|
+
use std::io::Read;
|
|
82
|
+
use std::path::Path;
|
|
83
|
+
|
|
84
|
+
// WHY two limits: a file can be some GB, so only its start is read; the page shows fewer characters than that
|
|
85
|
+
const MAX_READ_BYTES: u64 = 4096;
|
|
86
|
+
const PREVIEW_LENGTH: usize = 200; // characters
|
|
87
|
+
|
|
88
|
+
#[derive(Serialize)]
|
|
89
|
+
#[serde(rename_all = "camelCase")]
|
|
90
|
+
pub struct Preview {
|
|
91
|
+
text: String, // the first PREVIEW_LENGTH characters
|
|
92
|
+
is_cut: bool, // the file has more
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// The first characters of a text file. An Err reaches JavaScript as a rejected promise with its text.
|
|
96
|
+
#[tauri::command(async)]
|
|
97
|
+
pub fn preview_file(path: String) -> Result<Preview, String> {
|
|
98
|
+
read_preview(Path::new(&path))
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// WHY without Tauri: the test below calls it
|
|
102
|
+
pub fn read_preview(path: &Path) -> Result<Preview, String> {
|
|
103
|
+
let file = File::open(path).map_err(|error| format!("{}: {}", path.display(), error))?;
|
|
104
|
+
let mut bytes = Vec::new();
|
|
105
|
+
file.take(MAX_READ_BYTES)
|
|
106
|
+
.read_to_end(&mut bytes)
|
|
107
|
+
.map_err(|error| format!("{}: {}", path.display(), error))?;
|
|
108
|
+
|
|
109
|
+
// WHY: a 0 byte is in pictures, archives and programs, not in a text
|
|
110
|
+
if bytes.contains(&0) {
|
|
111
|
+
return Err(format!("{}: not a text file", path.display()));
|
|
112
|
+
}
|
|
113
|
+
let text = String::from_utf8_lossy(&bytes);
|
|
114
|
+
Ok(Preview {
|
|
115
|
+
text: text.chars().take(PREVIEW_LENGTH).collect(),
|
|
116
|
+
is_cut: text.chars().count() > PREVIEW_LENGTH,
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- `use` brings names of crates and modules into the file (`std` is the library that comes with Rust).
|
|
122
|
+
- A `struct` is an object whose fields and types are fixed. `#[derive(Serialize)]` lets the crate serde write it as
|
|
123
|
+
JSON; `rename_all = "camelCase"` writes `is_cut` as `isCut`, the name the page reads.
|
|
124
|
+
- `u64` is a whole number from 0, `usize` a count, `f64` a number with a fraction: numbers in JavaScript. `Vec` is a
|
|
125
|
+
list (an array). `Option<String>` (Ex: `parent` in the `Folder` of `list_folder`) is `Some(a text)` or `None`;
|
|
126
|
+
`None` is `null` in the page (tried: the root `/` has `parent: null`).
|
|
127
|
+
- `let mut` may change. `file.take(MAX_READ_BYTES)` reads at most 4096 bytes; `read_to_end` puts them into `bytes`,
|
|
128
|
+
lent with the right to change it (`&mut`). `format!` makes a text, as a template string does.
|
|
129
|
+
- `String::from_utf8_lossy` reads the bytes as UTF-8 (a byte that is not UTF-8 becomes `�`). The command only calls
|
|
130
|
+
`read_preview`, a function of plain values, which can be tested without a window.
|
|
131
|
+
|
|
132
|
+
**2. Its test**, at the end of the same file:
|
|
133
|
+
|
|
134
|
+
```rust
|
|
135
|
+
#[cfg(test)]
|
|
136
|
+
mod tests {
|
|
137
|
+
use super::*;
|
|
138
|
+
use std::fs;
|
|
139
|
+
|
|
140
|
+
#[test]
|
|
141
|
+
fn a_text_file_gives_its_first_characters() {
|
|
142
|
+
let folder =
|
|
143
|
+
std::env::temp_dir().join(format!("tauri-starter-preview-{}", std::process::id()));
|
|
144
|
+
fs::create_dir_all(&folder).unwrap();
|
|
145
|
+
fs::write(folder.join("short.txt"), "hello").unwrap();
|
|
146
|
+
fs::write(folder.join("long.txt"), "a".repeat(PREVIEW_LENGTH + 1)).unwrap();
|
|
147
|
+
fs::write(folder.join("picture.png"), [137, 80, 78, 71, 0, 0]).unwrap();
|
|
148
|
+
let short = read_preview(&folder.join("short.txt")).unwrap();
|
|
149
|
+
assert_eq!(short.text, "hello");
|
|
150
|
+
assert!(!short.is_cut);
|
|
151
|
+
let long = read_preview(&folder.join("long.txt")).unwrap();
|
|
152
|
+
assert_eq!(long.text.chars().count(), PREVIEW_LENGTH);
|
|
153
|
+
assert!(long.is_cut);
|
|
154
|
+
let picture = read_preview(&folder.join("picture.png")).err().unwrap();
|
|
155
|
+
assert!(picture.ends_with("not a text file"));
|
|
156
|
+
fs::remove_dir_all(&folder).unwrap();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`cargo test` in `src-tauri/` now gives `7 passed` for `src/`. Reading and writing tests:
|
|
162
|
+
[9. Tests and checks](09-tests-and-checks.md).
|
|
163
|
+
|
|
164
|
+
**3. Into the app.** In `src-tauri/src/main.rs`: `mod preview;` under `mod files;`, and `preview::preview_file` at
|
|
165
|
+
the end of the list of `generate_handler!` (with a comma after `sizes::stop_measure`).
|
|
166
|
+
|
|
167
|
+
**4. The call**, in `ui/backend.js` after `Backend.listFolder` (and its sample text next to `SAMPLE_CHOSEN_FOLDER`):
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
// The first characters of a text file. The answer: { text, isCut }
|
|
171
|
+
Backend.previewFile = function (path) {
|
|
172
|
+
if (!Backend.isInApp()) return Promise.resolve({ text: Backend.SAMPLE_PREVIEW, isCut: false });
|
|
173
|
+
return window.__TAURI__.core.invoke("preview_file", { path: path });
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
Backend.SAMPLE_PREVIEW = "Buy milk and bread. Call the bank about the letter of Monday."; // every file in a browser
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**5. The page.** In `ui/app.js`, a click on a file did nothing (`if (!row.isFolder) return;` in `onRowClick`). Make
|
|
180
|
+
that line `if (!row.isFolder) { showPreview(row); return; }` (on four lines), and add the function:
|
|
181
|
+
|
|
182
|
+
```js
|
|
183
|
+
// A file: its first characters in a toast. WHY the key: a click on another file uses the same toast.
|
|
184
|
+
const showPreview = function (row) {
|
|
185
|
+
Backend.previewFile(row.path)
|
|
186
|
+
.then(function (preview) {
|
|
187
|
+
const text = preview.isCut ? preview.text + "…" : preview.text;
|
|
188
|
+
Toast.info(text || "An empty file", { key: "preview", titleText: row.name });
|
|
189
|
+
})
|
|
190
|
+
.catch(function (error) {
|
|
191
|
+
Toast.error(String(error), { key: "preview", titleText: "No preview" });
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Run `cargo tauri dev` and click a text file; a picture says `...: not a text file`.
|
|
197
|
+
|
|
198
|
+
- `.then` gets the value of the `Ok`; `.catch` gets the text of the `Err`, a string (not an `Error` object), Ex:
|
|
199
|
+
`/Users/me/notes.txt: No such file or directory (os error 2)`. In an `async` function: `await` in a `try`.
|
|
200
|
+
- A command with no `->` (`stop_measure`) answers `null`. `Toast` writes its texts as plain text (no HTML).
|
|
201
|
+
|
|
202
|
+
**6. A step of the window check** (`checks/window-check.js`, after "the table shows the entries"); the check prints
|
|
203
|
+
one line more, `PASS a preview gives the start of a file: hello`:
|
|
204
|
+
|
|
205
|
+
```js
|
|
206
|
+
// A command of chapter 4 of the handbook
|
|
207
|
+
const preview = await Backend.previewFile(WindowCheck.entryOf("a-file.txt").path);
|
|
208
|
+
const isPreviewRight = preview.text == "hello" && preview.isCut === false;
|
|
209
|
+
WindowCheck.expect(isPreviewRight, "a preview gives the start of a file: " + preview.text);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Which thread runs a command
|
|
213
|
+
|
|
214
|
+
- **A plain `#[tauri::command]`** runs on the main thread, the one that draws the window. Measured on an Apple M1 with
|
|
215
|
+
8 GB (2026-11-27, `cargo run`): a plain command that took 1.5 s let the page draw 1 frame (not about 90), and a
|
|
216
|
+
`list_folder` called in that time was answered after 1.4 s.
|
|
217
|
+
- **`#[tauri::command(async)]`** runs on another thread: with the same command the page drew 91 frames, and the
|
|
218
|
+
`list_folder` was answered in 5 ms. An **`async fn`** runs off the main thread too, and waits with `.await`.
|
|
219
|
+
- A command that reads the disk or the network is `(async)`, as `list_folder` and `preview_file`. `measure_folder` is
|
|
220
|
+
plain on purpose: it starts a thread and answers at once. A job of seconds with steps to tell: chapter 5.
|
|
221
|
+
|
|
222
|
+
## Big answers
|
|
223
|
+
|
|
224
|
+
An answer is one JSON text: a folder of 100,000 entries is about 15 MB, read by Rust in 226 ms and in the page after
|
|
225
|
+
302 ms (the release build, Apple M1 with 8 GB, 2026-11-04). `MAX_ENTRIES` in `files.rs` stops the list there (`total`
|
|
226
|
+
tells how many there are). For more, send it in parts: an argument for the first entry, or events (chapter 5).
|
|
227
|
+
|
|
228
|
+
## What the project tests catch
|
|
229
|
+
|
|
230
|
+
The compiler does not see a name that is only on one side, so `cargo test` reads the files
|
|
231
|
+
(`src-tauri/tests/project.rs`). Without `preview::preview_file` in `generate_handler!`:
|
|
232
|
+
|
|
233
|
+
```text
|
|
234
|
+
the page calls invoke("preview_file"), but generate_handler! of src/main.rs has no preview_file
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
The second test names the function too (`preview_file is written with #[tauri::command], but it is not in
|
|
238
|
+
generate_handler!...`), and the compiler warns that `preview_file` is never used. The tests look for `invoke("...")`
|
|
239
|
+
with the name written in it: keep the name in the call, not in a variable. All four project tests: chapter 9.
|
|
240
|
+
|
|
241
|
+
## The usual mistakes
|
|
242
|
+
|
|
243
|
+
What the page sent, and the error of its promise (tried in the window):
|
|
244
|
+
|
|
245
|
+
```text
|
|
246
|
+
invoke("list_foldr", ...)
|
|
247
|
+
Command list_foldr not found
|
|
248
|
+
{ path: "" } or { path: "", show_hidden: false }
|
|
249
|
+
invalid args `showHidden` for command `list_folder`: command list_folder missing required key showHidden
|
|
250
|
+
{ path: 5, showHidden: false }
|
|
251
|
+
invalid args `path` for command `list_folder`: invalid type: integer `5`, expected a string
|
|
252
|
+
{ path: "", showHidden: "yes" }
|
|
253
|
+
invalid args `showHidden` for command `list_folder`: invalid type: string "yes", expected a boolean
|
|
254
|
+
invoke("measure_folder", { path: "/x", job: -1 })
|
|
255
|
+
invalid args `job` for command `measure_folder`: invalid value: integer `-1`, expected u32
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
- A key that Rust does not have is no error: it is left out. An `Option<String>` argument may be left out or `null`:
|
|
259
|
+
Rust gets `None` (tried).
|
|
260
|
+
- A command whose `State` the app does not keep: chapter 5. More: [11. Troubleshooting](11-troubleshooting.md).
|
|
261
|
+
|
|
262
|
+
## Next
|
|
263
|
+
|
|
264
|
+
[5. Events and state](05-events-and-state.md): when one answer is not enough. Rust tells the page how a long job goes,
|
|
265
|
+
and the app keeps a value for its commands.
|