create-basicjs 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +12 -0
  2. package/bin/create-basicjs.js +49 -4
  3. package/package.json +1 -1
  4. package/payload/projects/tauri/.github/workflows/build.yml +86 -0
  5. package/payload/projects/tauri/.github/workflows/tests.yml +87 -0
  6. package/payload/projects/tauri/AGENTS.md +128 -0
  7. package/payload/projects/tauri/CLAUDE.md +1 -0
  8. package/payload/projects/tauri/LICENSE +201 -0
  9. package/payload/projects/tauri/NOTICE +8 -0
  10. package/payload/projects/tauri/README.md +269 -0
  11. package/payload/projects/tauri/checks/window-check.js +189 -0
  12. package/payload/projects/tauri/gitignore +8 -0
  13. package/payload/projects/tauri/handbook/01-getting-started.md +188 -0
  14. package/payload/projects/tauri/handbook/02-the-project.md +264 -0
  15. package/payload/projects/tauri/handbook/03-the-page.md +260 -0
  16. package/payload/projects/tauri/handbook/04-commands.md +265 -0
  17. package/payload/projects/tauri/handbook/05-events-and-state.md +275 -0
  18. package/payload/projects/tauri/handbook/06-plugins.md +282 -0
  19. package/payload/projects/tauri/handbook/07-the-window-and-the-app.md +431 -0
  20. package/payload/projects/tauri/handbook/08-security.md +374 -0
  21. package/payload/projects/tauri/handbook/09-tests-and-checks.md +266 -0
  22. package/payload/projects/tauri/handbook/10-building-and-releasing.md +238 -0
  23. package/payload/projects/tauri/handbook/11-troubleshooting.md +259 -0
  24. package/payload/projects/tauri/handbook/README.md +125 -0
  25. package/payload/projects/tauri/handbook/turkce/01-getting-started.md +193 -0
  26. package/payload/projects/tauri/handbook/turkce/02-the-project.md +272 -0
  27. package/payload/projects/tauri/handbook/turkce/03-the-page.md +272 -0
  28. package/payload/projects/tauri/handbook/turkce/04-commands.md +271 -0
  29. package/payload/projects/tauri/handbook/turkce/05-events-and-state.md +284 -0
  30. package/payload/projects/tauri/handbook/turkce/06-plugins.md +286 -0
  31. package/payload/projects/tauri/handbook/turkce/07-the-window-and-the-app.md +433 -0
  32. package/payload/projects/tauri/handbook/turkce/08-security.md +384 -0
  33. package/payload/projects/tauri/handbook/turkce/09-tests-and-checks.md +275 -0
  34. package/payload/projects/tauri/handbook/turkce/10-building-and-releasing.md +241 -0
  35. package/payload/projects/tauri/handbook/turkce/11-troubleshooting.md +264 -0
  36. package/payload/projects/tauri/handbook/turkce/README.md +128 -0
  37. package/payload/projects/tauri/images/app.png +0 -0
  38. package/payload/projects/tauri/src-tauri/Cargo.lock +4389 -0
  39. package/payload/projects/tauri/src-tauri/Cargo.toml +31 -0
  40. package/payload/projects/tauri/src-tauri/app-icon.svg +16 -0
  41. package/payload/projects/tauri/src-tauri/build.rs +15 -0
  42. package/payload/projects/tauri/src-tauri/capabilities/default.json +7 -0
  43. package/payload/projects/tauri/src-tauri/gitignore +5 -0
  44. package/payload/projects/tauri/src-tauri/icons/128x128.png +0 -0
  45. package/payload/projects/tauri/src-tauri/icons/128x128@2x.png +0 -0
  46. package/payload/projects/tauri/src-tauri/icons/32x32.png +0 -0
  47. package/payload/projects/tauri/src-tauri/icons/icon.icns +0 -0
  48. package/payload/projects/tauri/src-tauri/icons/icon.ico +0 -0
  49. package/payload/projects/tauri/src-tauri/src/check.rs +144 -0
  50. package/payload/projects/tauri/src-tauri/src/files.rs +255 -0
  51. package/payload/projects/tauri/src-tauri/src/main.rs +45 -0
  52. package/payload/projects/tauri/src-tauri/src/sizes.rs +214 -0
  53. package/payload/projects/tauri/src-tauri/tauri.conf.json +44 -0
  54. package/payload/projects/tauri/src-tauri/tests/project.rs +243 -0
  55. package/payload/projects/tauri/ui/app.js +459 -0
  56. package/payload/projects/tauri/ui/backend.js +196 -0
  57. package/payload/projects/tauri/ui/basic/LICENSE +14 -0
  58. package/payload/projects/tauri/ui/basic/basic.min.css +1 -0
  59. package/payload/projects/tauri/ui/basic/basic.min.js +78 -0
  60. package/payload/projects/tauri/ui/basic/font/open-sans/LICENSE.txt +206 -0
  61. package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
  62. package/payload/projects/tauri/ui/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
  63. package/payload/projects/tauri/ui/basic/scroll-bar.min.js +3 -0
  64. package/payload/projects/tauri/ui/comp/_sources.txt +9 -0
  65. package/payload/projects/tauri/ui/comp/components.min.js +21 -0
  66. package/payload/projects/tauri/ui/index.html +28 -0
  67. package/payload/projects/tauri/ui/sizes.js +104 -0
  68. package/payload/starter/_basic/VERSION +1 -1
  69. package/payload/starter/_basic/comp/bottom-bar.js +31 -3
  70. package/payload/starter/_basic/comp/code-editor.js +219 -1
  71. package/payload/starter/_basic/comp/context-menu.js +6 -1
  72. package/payload/starter/_basic/comp/markdown-view.js +4 -2
  73. package/payload/starter/_basic/comp/phone-field.js +13 -5
  74. package/payload/starter/_basic/comp/property-panel.js +1 -1
  75. package/payload/starter/_basic/comp/slider.js +27 -12
  76. package/payload/starter/_basic/comp/smart-button.js +5 -1
  77. package/payload/starter/_basic/comp/smart-table.js +8 -1
  78. package/payload/starter/_basic/comp/stepper.js +29 -3
  79. package/payload/starter/_basic/comp/toggle.js +2 -1
  80. package/payload/starter/_basic/docs/component-index.md +53 -53
  81. package/payload/starter/_basic/examples/code-editor.htm +48 -1
  82. package/payload/starter/_basic/examples/gallery-styled.htm +896 -0
  83. package/payload/starter/_basic/examples/search-input.htm +1 -1
  84. package/payload/starter/_basic/examples/select-box-2-item-view.htm +304 -0
  85. package/payload/starter/_basic/examples/{slider-2-classic.htm → slider-2-split.htm} +36 -2
  86. package/payload/starter/_basic/examples/stepper-2.htm +22 -6
  87. package/payload/starter/_basic/min/bottom-bar.min.js +1 -1
  88. package/payload/starter/_basic/min/code-editor.min.js +1 -1
  89. package/payload/starter/_basic/min/context-menu.min.js +1 -1
  90. package/payload/starter/_basic/min/markdown-view.min.js +1 -1
  91. package/payload/starter/_basic/min/phone-field.min.js +1 -1
  92. package/payload/starter/_basic/min/slider.min.js +1 -1
  93. package/payload/starter/_basic/min/smart-button.min.js +1 -1
  94. package/payload/starter/_basic/min/smart-table.min.js +1 -1
  95. package/payload/starter/_basic/min/stepper.min.js +1 -1
  96. package/payload/starter/_basic/min/toggle.min.js +1 -1
  97. package/payload/starter/_basic/tools/check.js +13 -2
@@ -0,0 +1,459 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ app.js - Tauri Starter v0.1 (OzdenUI for Tauri)
6
+
7
+ THE PAGE OF THE APP: a small file browser in three examples. backend.js is the bridge to Rust.
8
+ 1. Folders (this file): the page asks Rust for a folder (src-tauri/src/files.rs) and shows it in a SmartTable.
9
+ 2. Sizes (sizes.js): Rust measures the folders inside in a thread and tells the page how it goes, with events.
10
+ 3. Open... (this file): the folder dialog of the system, from a plugin of Tauri (no Rust code of the app).
11
+
12
+ TRY: click a folder, a part of the path at the top, Up (or Cmd / Ctrl + Up), Open..., Filter, Hidden files, Sizes.
13
+ The keys: click a row, then ↑ ↓ Page Up / Page Down Home End, Enter opens a folder, Cmd / Ctrl + ↑ goes up,
14
+ Cmd / Ctrl + O opens the folder dialog.
15
+
16
+ YOUR OWN APP: keep backend.js as the one place that calls Rust, and write your page here (start() runs first).
17
+
18
+ Started Date: November 2026
19
+ Webpage: https://bug7a.github.io/ozdenui-tauri-template/
20
+
21
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
22
+ Licensed under the Apache License, Version 2.0
23
+ SPDX-License-Identifier: Apache-2.0
24
+
25
+ */
26
+
27
+ "use strict";
28
+
29
+ // *** VARIABLES:
30
+
31
+ const PAGE_COLOR = "#F4F5F2";
32
+ const LINE_COLOR = Black(0.08);
33
+ const STATUS_TEXT_COLOR = Black(0.55);
34
+ const SPACE = 16;
35
+ const BUTTON_GAP = 8;
36
+ const TOP_BAR_HEIGHT = 72;
37
+ const STATUS_BAR_HEIGHT = 40;
38
+ const STATUS_SIDE_SPACE = 20; // px: the texts of the status bar from the sides of the window
39
+ const STATUS_FONT_SIZE = 13;
40
+ const MAX_CRUMBS = 5; // a deeper path shows "…" in its middle
41
+ // A narrow window shows fewer parts of the path (fitCrumbs): "/ › … › Documents › Invoices", then "/ › … › Invoices"
42
+ const CRUMB_STEPS = [
43
+ { maxItems: MAX_CRUMBS, itemsAfterCollapse: 2 },
44
+ { maxItems: 1, itemsAfterCollapse: 2 }, // WHY 1: every path that has parts to hide is collapsed
45
+ { maxItems: 1, itemsAfterCollapse: 1 },
46
+ ];
47
+ const PIXEL_TOLERANCE = 0.5; // px: the widths of texts are fractions
48
+ const SIZE_UNIT = 1000; // WHY 1000: the sizes of Finder (1 KB = 1000 bytes)
49
+ const SIZE_NAMES = ["bytes", "KB", "MB", "GB", "TB"];
50
+ const NO_SIZE = -1; // the size of a folder that is not measured yet (sizes.js measures it)
51
+
52
+ // THE TABLE: SmartTable makes only the rows that are seen, so a folder of 100 000 files is shown at once.
53
+ // fitLineCount: its rows are about ROW_HEIGHT px high; their count follows the height of the window.
54
+ const ROW_HEIGHT = 40;
55
+ const TABLE_TITLE_HEIGHT = 48;
56
+ const TABLE_INFO_HEIGHT = 52; // the line under the rows: the filter and "1 - 12 / 932"
57
+ const ROW_ICON_SIZE = 22;
58
+ const MIN_NAME_WIDTH = 160;
59
+ const COLUMN = { icon: 0, name: 1, kind: 2, size: 3, modified: 4 };
60
+ const COLUMNS = [ // the name takes the width that is left (fitColumns)
61
+ { name: "", dataTitle: "icon", dataType: "string", width: 48, sortable: 0 },
62
+ { name: "Name", dataTitle: "name", dataType: "string", width: MIN_NAME_WIDTH, sortable: 1 },
63
+ { name: "Kind", dataTitle: "kind", dataType: "string", width: 110, sortable: 1 },
64
+ { name: "Size", dataTitle: "size", dataType: "integer", width: 110, sortable: 1 },
65
+ { name: "Modified", dataTitle: "modified", dataType: "integer", width: 170, sortable: 1 },
66
+ ];
67
+ // The look of the table is the light look of the kit; the page gives only its size (the box around it)
68
+ const TABLE_STYLE = { width: "100%", height: "100%" };
69
+
70
+ // The icons (24 x 24). The buttons: line icons, as on the model page of SmartButton.
71
+ const ICON_COLOR = "#1F1F1F";
72
+ const svgIcon = function (attributes, body) {
73
+ return "data:image/svg+xml;utf8," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"' + attributes + ">" + body + "<\/svg>");
74
+ };
75
+ const lineIcon = function (paths) {
76
+ return svgIcon(' fill="none" stroke="' + ICON_COLOR + '" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"', paths);
77
+ };
78
+ // The rows: two-tone icons (a light shape and a strong detail on it)
79
+ const twoToneIcon = function (body, lightColor, strongColor) {
80
+ return svgIcon("", body.split("LIGHT").join(lightColor).split("STRONG").join(strongColor));
81
+ };
82
+ const ICONS = {
83
+ up: lineIcon('<path d="M12 19V5M6 11l6-6 6 6"/>'),
84
+ home: lineIcon('<path d="M4 10.5L12 4l8 6.5V20h-5v-6H9v6H4z"/>'),
85
+ open: lineIcon('<path d="M3 19V6a1.5 1.5 0 0 1 1.5-1.5h4.2l2.2 2.5h6.6A1.5 1.5 0 0 1 19 8.5V10"/><path d="M3 19l2.6-7.9A1.5 1.5 0 0 1 7 10h13.4a1 1 0 0 1 .95 1.3L19 19z"/>'),
86
+ folder: twoToneIcon('<path d="M2.5 18V5.5a2 2 0 0 1 2-2h4.6a2 2 0 0 1 1.5.7l1.4 1.8h7.5a2 2 0 0 1 2 2V18z" fill="STRONG"/><rect x="2.5" y="8" width="19" height="12.5" rx="2.5" fill="LIGHT"/>', "#93B7F7", "#2F6FED"),
87
+ file: twoToneIcon('<rect x="4" y="2.5" width="16" height="19" rx="3" fill="LIGHT"/><path d="M8 8h8M8 12h8M8 16h5" fill="none" stroke="STRONG" stroke-width="2" stroke-linecap="round"/>', "#C4C5C9", "#6E6F74"),
88
+ };
89
+
90
+ let currentFolder = null; // the last answer of Backend.listFolder() that is shown
91
+ let rowsByPath = new Map(); // path -> the row of the table (sizes.js changes the size of a folder row)
92
+ let lastRequestNumber = 0;
93
+ let showHidden = false;
94
+ let topRow, btnUp, crumbs, chkHidden, table, lblCount, lblSpeed;
95
+
96
+ // *** START:
97
+
98
+ const start = function () {
99
+
100
+ page.color = PAGE_COLOR;
101
+ Toast.setOptions({ theme: "light", offsetTop: TOP_BAR_HEIGHT + SPACE });
102
+
103
+ createTopBar();
104
+ createTable();
105
+ createStatusBar();
106
+
107
+ window.addEventListener("keydown", onKeyDown);
108
+ page.onResize(function () {
109
+ fitCrumbs();
110
+ fitColumns();
111
+ });
112
+ Sizes.listen();
113
+ openFolder("");
114
+
115
+ };
116
+
117
+ // *** VIEW:
118
+
119
+ const createTopBar = function () {
120
+
121
+ // BOX: Top bar
122
+ startBox(0, 0, "100%", TOP_BAR_HEIGHT, { color: "white", css: { borderBottom: "1px solid " + LINE_COLOR } });
123
+
124
+ // GROUP: The buttons, the path and the options in a row
125
+ topRow = HGroup({ width: "100%", height: "100%", align: "left center", gap: SPACE, padding: [SPACE, 0], clipContent: 0 });
126
+
127
+ // GROUP: Buttons
128
+ HGroup({ hug: 1, gap: BUTTON_GAP, shrink: 0, clipContent: 0 });
129
+ btnUp = SmartButton({ labelText: "Up", iconFile: ICONS.up, onClick: openParent });
130
+ SmartButton({ labelText: "Home", iconFile: ICONS.home, onClick: openHome });
131
+ SmartButton({ labelText: "Open...", iconFile: ICONS.open, onClick: chooseFolder });
132
+ Sizes.createButton();
133
+ endGroup();
134
+
135
+ crumbs = Breadcrumbs({ maxItems: MAX_CRUMBS, onClick: onCrumbClick });
136
+ crumbs.css = { minWidth: "0px" };
137
+ crumbs.shrink = 1;
138
+
139
+ // BOX: The free room (pushes the check box to the right)
140
+ Box({ width: 1, height: 1, color: "transparent", grow: 1 });
141
+
142
+ chkHidden = CheckBox({ labelText: "Hidden files", onChange: onHiddenChange });
143
+ chkHidden.shrink = 0;
144
+
145
+ endGroup();
146
+
147
+ endBox();
148
+
149
+ };
150
+
151
+ const createTable = function () {
152
+
153
+ // BOX: The place of the table
154
+ startBox(SPACE, TOP_BAR_HEIGHT + SPACE, "calc(100% - " + (SPACE * 2) + "px)", "calc(100% - " + (TOP_BAR_HEIGHT + SPACE + STATUS_BAR_HEIGHT) + "px)", { color: "transparent" });
155
+
156
+ // TABLE: The entries of the folder
157
+ // WHY left / top: an object in a Box (not in a group) is made at -1000, -1000 by basic.js until it is placed
158
+ table = SmartTable({
159
+ left: 0,
160
+ top: 0,
161
+ titleDataList: COLUMNS,
162
+ itemDataList: [],
163
+ fitLineCount: 1,
164
+ itemHeight: ROW_HEIGHT,
165
+ titleHeight: TABLE_TITLE_HEIGHT,
166
+ infoHeight: TABLE_INFO_HEIGHT,
167
+ sortByTitleIndex: -1, // WHY -1: the order of Rust (the folders first) until a title is clicked
168
+ searchTitleIndex: COLUMN.name, // the filter looks at the names
169
+ wheelScroll: 1, // the mouse wheel scrolls the rows
170
+ noDataFoundAlert: "Nothing here",
171
+ createCellView: createCellView,
172
+ updateCellView: updateCellView,
173
+ onSelect: onRowClick,
174
+ style: TABLE_STYLE,
175
+ });
176
+ fitColumns();
177
+
178
+ endBox();
179
+
180
+ };
181
+
182
+ // The cells of a column that are not only a text (once for every cell, when it is made)
183
+ const createCellView = function (cell, columnIndex) {
184
+
185
+ if (columnIndex == COLUMN.icon) {
186
+ cell.label.visible = 0;
187
+ // ICON: Folder or file
188
+ cell.icon = Icon({ width: ROW_ICON_SIZE, height: ROW_ICON_SIZE });
189
+ cell.add(cell.icon);
190
+ }
191
+
192
+ // WHY css: a group gets its align when it is made; the numbers of the sizes stand at the right
193
+ if (columnIndex == COLUMN.size) cell.css = { justifyContent: "flex-end" };
194
+
195
+ return cell;
196
+
197
+ };
198
+
199
+ // A cell shows the value of another entry (SmartTable fills only the rows that are seen)
200
+ const updateCellView = function (cell, columnIndex, value) {
201
+
202
+ if (columnIndex == COLUMN.icon && cell.iconName != value) {
203
+ cell.iconName = value;
204
+ cell.icon.load(ICONS[value]);
205
+ }
206
+
207
+ if (columnIndex == COLUMN.size) cell.label.plainText = (value == NO_SIZE) ? "–" : formatSize(value);
208
+ if (columnIndex == COLUMN.modified) cell.label.plainText = formatDate(value);
209
+
210
+ };
211
+
212
+ // The name takes the width that is left (the columns of SmartTable have fixed widths)
213
+ const fitColumns = function () {
214
+ const otherWidths = COLUMNS.reduce(function (sum, column, index) {
215
+ return (index == COLUMN.name) ? sum : sum + column.width;
216
+ }, 0);
217
+ table.setTitleCellWidth(COLUMN.name, Math.max(MIN_NAME_WIDTH, table.width - otherWidths));
218
+ };
219
+
220
+ const createStatusBar = function () {
221
+
222
+ // GROUP: Status bar: the counts on the left, what Rust did on the right
223
+ HGroup({ left: 0, bottom: 0, width: "100%", height: STATUS_BAR_HEIGHT, align: "left center", gap: SPACE, padding: [STATUS_SIDE_SPACE, 0], position: "absolute" });
224
+
225
+ lblCount = Label({ fontSize: STATUS_FONT_SIZE, textColor: STATUS_TEXT_COLOR, ellipsis: 1, css: { minWidth: "0px" } });
226
+ Box({ width: 1, height: 1, color: "transparent", grow: 1 });
227
+ lblSpeed = Label({ fontSize: STATUS_FONT_SIZE, textColor: STATUS_TEXT_COLOR });
228
+ lblSpeed.shrink = 0;
229
+
230
+ endGroup();
231
+
232
+ };
233
+
234
+ // *** FOLDERS:
235
+
236
+ // The page asks Rust (backend.js) and shows the answer. USAGE: openFolder("") opens the home folder
237
+ const openFolder = function (path) {
238
+
239
+ lastRequestNumber++;
240
+ const requestNumber = lastRequestNumber;
241
+ // WHY: an answer that comes after a newer click is not shown (a slow folder, a network drive)
242
+ const isLatest = function () {
243
+ return requestNumber == lastRequestNumber;
244
+ };
245
+
246
+ Backend.listFolder(path, showHidden)
247
+ .then(function (folder) {
248
+ if (isLatest()) showFolder(folder);
249
+ })
250
+ .catch(function (error) {
251
+ if (isLatest()) showError(error);
252
+ });
253
+
254
+ };
255
+
256
+ const openHome = function () {
257
+ openFolder("");
258
+ };
259
+
260
+ // THE THIRD EXAMPLE: a plugin of Tauri. The folder dialog of the system opens at the folder that is shown.
261
+ const chooseFolder = function () {
262
+ const startPath = currentFolder ? currentFolder.path : "";
263
+ Backend.chooseFolder(startPath)
264
+ .then(function (path) {
265
+ // WHY: null is the answer of a dialog closed with Cancel
266
+ if (path) openFolder(path);
267
+ })
268
+ .catch(showError);
269
+ };
270
+
271
+ const openParent = function () {
272
+ if (!currentFolder || !currentFolder.parent) return;
273
+ openFolder(currentFolder.parent);
274
+ };
275
+
276
+ const showFolder = function (folder) {
277
+
278
+ const isNewFolder = !currentFolder || currentFolder.path != folder.path;
279
+ const oldFolder = currentFolder;
280
+ currentFolder = folder;
281
+
282
+ // WHY: a new folder starts with no filter (Hidden files keeps it), and a measure of the old folder stops
283
+ if (isNewFolder) {
284
+ clearFilter();
285
+ Sizes.stop();
286
+ }
287
+
288
+ const rows = folder.entries.map(toRow);
289
+ rowsByPath = new Map(rows.map(function (row) { return [row.path, row]; }));
290
+ table.setItemDataList(rows);
291
+ // WHY: going up (Up, Cmd + Up, the path), the folder we come from is selected, so the keys go on from it
292
+ if (oldFolder) table.selectItem(rowsByPath.get(childPathOf(oldFolder, folder)));
293
+
294
+ crumbs.setItems(folder.crumbs.map(toCrumbItem), 1);
295
+ fitCrumbs();
296
+ btnUp.setEnabled(folder.parent ? 1 : 0);
297
+ showCounts(folder);
298
+ showSpeed(folder);
299
+
300
+ };
301
+
302
+ // The folder inside "folder" on the path of "oldFolder" (oldFolder: /a/b/c, folder: /a -> /a/b), or ""
303
+ const childPathOf = function (oldFolder, folder) {
304
+ const index = oldFolder.crumbs.findIndex(function (crumb) { return crumb.path == folder.path; });
305
+ if (index == -1 || index == oldFolder.crumbs.length - 1) return "";
306
+ return oldFolder.crumbs[index + 1].path;
307
+ };
308
+
309
+ const clearFilter = function () {
310
+ table.searchKeyword = "";
311
+ table.searchInput.setValue("", 1);
312
+ };
313
+
314
+ // A row of the table: the entry of Rust with the values of the columns (the size of a measured folder: sizes.js)
315
+ const toRow = function (entry) {
316
+ return {
317
+ icon: entry.isFolder ? "folder" : "file",
318
+ name: entry.name,
319
+ kind: kindOf(entry),
320
+ size: entry.isFolder ? Sizes.sizeOf(entry.path) : entry.size,
321
+ modified: entry.modified,
322
+ path: entry.path,
323
+ isFolder: entry.isFolder,
324
+ };
325
+ };
326
+
327
+ // sizes.js: a folder is measured. Only the rows that are seen are drawn again.
328
+ const setRowSize = function (path, bytes) {
329
+ const row = rowsByPath.get(path);
330
+ if (!row) return;
331
+ row.size = bytes;
332
+ table.refreshData();
333
+ };
334
+
335
+ const toCrumbItem = function (crumb) {
336
+ return { text: crumb.name, key: crumb.path };
337
+ };
338
+
339
+ // The path fits the top bar: the first step of CRUMB_STEPS that leaves room for the check box
340
+ const fitCrumbs = function () {
341
+ // WHY shrink 0: the path keeps its whole width while the top bar is measured
342
+ crumbs.shrink = 0;
343
+ CRUMB_STEPS.some(function (step) {
344
+ crumbs.itemsAfterCollapse = step.itemsAfterCollapse;
345
+ crumbs.setMaxItems(step.maxItems);
346
+ return !isTopRowFull();
347
+ });
348
+ // WHY shrink 1: a path that is still too long is cut with "…", and the check box stays in the window
349
+ crumbs.shrink = 1;
350
+ };
351
+
352
+ // WHY the check box: it is the last object of the row; it goes over the padding of the row when the row is full
353
+ const isTopRowFull = function () {
354
+ const rowRight = topRow.elem.getBoundingClientRect().right - SPACE;
355
+ return chkHidden.elem.getBoundingClientRect().right > rowRight + PIXEL_TOLERANCE;
356
+ };
357
+
358
+ const showError = function (error) {
359
+ Toast.error(String(error), { titleText: "The folder could not be opened" });
360
+ };
361
+
362
+ // "24 items: 6 folders, 18 files (12.4 MB)". A big folder: "The first 100,000 of 150,000 items: ..."
363
+ const showCounts = function (folder) {
364
+
365
+ const folderCount = folder.entries.filter(function (entry) { return entry.isFolder; }).length;
366
+ const fileCount = folder.entries.length - folderCount;
367
+ const fileSize = folder.entries.reduce(function (sum, entry) { return sum + entry.size; }, 0);
368
+
369
+ let text = countText(folder.total, "item");
370
+ if (folder.entries.length < folder.total) text = "The first " + formatNumber(folder.entries.length) + " of " + text;
371
+ text += ": " + countText(folderCount, "folder") + ", " + countText(fileCount, "file");
372
+ if (fileCount > 0) text += " (" + formatSize(fileSize) + ")";
373
+ lblCount.plainText = text;
374
+
375
+ };
376
+
377
+ // "Read by Rust in 0.4 ms". In a browser: the sample data.
378
+ const showSpeed = function (folder) {
379
+ if (!Backend.isInApp()) {
380
+ lblSpeed.plainText = "Sample data: run the app with cargo tauri dev";
381
+ return;
382
+ }
383
+ lblSpeed.plainText = "Read by Rust in " + formatMillis(folder.millis);
384
+ };
385
+
386
+ // *** EVENTS:
387
+
388
+ const onRowClick = function (self, row) {
389
+ if (!row.isFolder) return;
390
+ openFolder(row.path);
391
+ };
392
+
393
+ const onCrumbClick = function (self, item) {
394
+ openFolder(item.key);
395
+ };
396
+
397
+ const onHiddenChange = function (self) {
398
+ showHidden = basic.isOn(self.checked);
399
+ if (currentFolder) openFolder(currentFolder.path);
400
+ };
401
+
402
+ // Cmd + Up (Ctrl + Up): the folder above, as in Finder. Cmd + O (Ctrl + O): the folder dialog.
403
+ const KEY_ACTIONS = { ArrowUp: openParent, o: chooseFolder };
404
+
405
+ const onKeyDown = function (event) {
406
+ const isCommandKey = event.metaKey || event.ctrlKey;
407
+ if (!isCommandKey) return;
408
+ const action = KEY_ACTIONS[event.key];
409
+ if (!action) return;
410
+ event.preventDefault();
411
+ action();
412
+ };
413
+
414
+ // *** TEXTS:
415
+
416
+ // "Folder", the extension of a file ("PDF"), or "File"
417
+ const kindOf = function (entry) {
418
+ if (entry.isFolder) return "Folder";
419
+ const dot = entry.name.lastIndexOf(".");
420
+ // WHY dot > 0: ".zshrc" is a name, not an extension
421
+ if (dot > 0 && dot < entry.name.length - 1) return entry.name.slice(dot + 1).toUpperCase();
422
+ return "File";
423
+ };
424
+
425
+ // 1243500 -> "1.2 MB"
426
+ const formatSize = function (bytes) {
427
+ let size = bytes;
428
+ let unit = 0;
429
+ while (size >= SIZE_UNIT && unit < SIZE_NAMES.length - 1) {
430
+ size = size / SIZE_UNIT;
431
+ unit++;
432
+ }
433
+ if (unit == 0) return countText(bytes, "byte");
434
+ return size.toFixed(size < 10 ? 1 : 0) + " " + SIZE_NAMES[unit];
435
+ };
436
+
437
+ // "2026-11-04 14:05" (local time)
438
+ const formatDate = function (millis) {
439
+ if (!millis) return "";
440
+ const date = new Date(millis);
441
+ const day = date.getFullYear() + "-" + basic.twoDigitFormat(date.getMonth() + 1) + "-" + basic.twoDigitFormat(date.getDate());
442
+ return day + " " + basic.twoDigitFormat(date.getHours()) + ":" + basic.twoDigitFormat(date.getMinutes());
443
+ };
444
+
445
+ const formatMillis = function (millis) {
446
+ if (millis < 10) return millis.toFixed(1) + " ms";
447
+ if (millis < 1000) return Math.round(millis) + " ms";
448
+ return (millis / 1000).toFixed(1) + " s";
449
+ };
450
+
451
+ // 100000 -> "100,000"
452
+ const formatNumber = function (number) {
453
+ return number.toLocaleString("en-US");
454
+ };
455
+
456
+ // countText(1, "file") -> "1 file", countText(3000, "file") -> "3,000 files"
457
+ const countText = function (count, name) {
458
+ return formatNumber(count) + " " + name + (count == 1 ? "" : "s");
459
+ };
@@ -0,0 +1,196 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ backend.js - Tauri Starter v0.1 (OzdenUI for Tauri)
6
+
7
+ BACKEND: the bridge between the page and the Rust side of the app.
8
+
9
+ - In the app (cargo tauri dev, or the built app): window.__TAURI__.core.invoke() runs a command of
10
+ src-tauri/src/ (a #[tauri::command]) and gives a promise of its answer. An Err of Rust rejects the promise.
11
+ window.__TAURI__.event.listen() gets the events that Rust sends (app.emit() in Rust): Backend.listen().
12
+ - In a browser (a web server, as Live Server of VS Code): sample folders and a sample measure, so the page can be drawn and
13
+ tried without Rust. Backend.isInApp() tells which one.
14
+
15
+ A NEW COMMAND: write it in Rust (src-tauri/src/), add it to generate_handler! in main.rs, then add a function here:
16
+ Backend.readNote = function (path) {
17
+ return window.__TAURI__.core.invoke("read_note", { path: path });
18
+ };
19
+ A name of two words is written in two ways: show_hidden in Rust is showHidden in the page (Tauri changes it).
20
+
21
+ Started Date: November 2026
22
+ Webpage: https://bug7a.github.io/ozdenui-tauri-template/
23
+
24
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
25
+ Licensed under the Apache License, Version 2.0
26
+ SPDX-License-Identifier: Apache-2.0
27
+
28
+ */
29
+
30
+ "use strict";
31
+
32
+ const Backend = {};
33
+
34
+ Backend.isInApp = function () {
35
+ return Boolean(window.__TAURI__);
36
+ };
37
+
38
+ // The entries of a folder (path "": the home folder). The answer:
39
+ // { path, parent, crumbs: [{ name, path }], entries: [{ name, path, isFolder, size, modified }], total, millis }
40
+ Backend.listFolder = function (path, showHidden) {
41
+ if (!Backend.isInApp()) return Backend.listSampleFolder(path, showHidden);
42
+ return window.__TAURI__.core.invoke("list_folder", { path: path, showHidden: showHidden });
43
+ };
44
+ // USAGE: Backend.listFolder("", false).then(showFolder).catch(showError)
45
+
46
+ // handler(payload) runs for every event of this name that Rust sends. USAGE: Backend.listen("measure-done", showDone)
47
+ Backend.listen = function (eventName, handler) {
48
+ if (!Backend.isInApp()) {
49
+ Backend.sampleListeners[eventName] = handler;
50
+ return;
51
+ }
52
+ window.__TAURI__.event.listen(eventName, function (event) {
53
+ handler(event.payload);
54
+ });
55
+ };
56
+
57
+ // THE SECOND EXAMPLE (sizes.js): starts to measure the folders inside a folder. The answer comes at once, the
58
+ // sizes come as events (job: a number of the page, it comes back in every event of the job).
59
+ Backend.measureFolder = function (path, job) {
60
+ if (!Backend.isInApp()) return Backend.measureSampleFolders(path, job);
61
+ return window.__TAURI__.core.invoke("measure_folder", { path: path, job: job });
62
+ };
63
+
64
+ Backend.stopMeasure = function () {
65
+ if (!Backend.isInApp()) return Backend.stopSampleMeasure();
66
+ return window.__TAURI__.core.invoke("stop_measure");
67
+ };
68
+
69
+ // THE THIRD EXAMPLE: a plugin of Tauri (tauri-plugin-dialog). The folder dialog of the system, opened at startPath.
70
+ // The answer: the path of the chosen folder, or null when the dialog is closed with Cancel.
71
+ // WHY no command of ours: the plugin brings its own Rust code and its own JavaScript (window.__TAURI__.dialog).
72
+ // It was added with "cargo tauri add dialog" in src-tauri/ (Cargo.toml, main.rs, capabilities/default.json).
73
+ Backend.chooseFolder = function (startPath) {
74
+ if (!Backend.isInApp()) return Promise.resolve(Backend.SAMPLE_CHOSEN_FOLDER);
75
+ return window.__TAURI__.dialog.open({ directory: true, defaultPath: startPath });
76
+ };
77
+
78
+ // *** SAMPLE FOLDERS (in a browser): the same answer as Rust, made from the list below
79
+
80
+ Backend.SAMPLE_HOME = "/Users/you";
81
+ Backend.SAMPLE_CHOSEN_FOLDER = "/Users/you/Documents/Invoices"; // the answer of the folder dialog in a browser
82
+ Backend.SAMPLE_TIME = new Date(2026, 10, 2, 9, 30).getTime(); // the "modified" time of the first entry
83
+ Backend.SAMPLE_TIME_STEP = 26 * 60 * 60 * 1000; // ms: each next entry is a day and two hours older
84
+
85
+ // path -> its entries: [name, isFolder, size]. A folder that is not here is empty.
86
+ Backend.SAMPLE_FOLDERS = {
87
+ "/": [["Applications", 1], ["Library", 1], ["System", 1], ["Users", 1]],
88
+ "/Users": [["Shared", 1], ["you", 1]],
89
+ "/Users/you": [["Desktop", 1], ["Documents", 1], ["Downloads", 1], ["Pictures", 1], [".zshrc", 0, 1180], ["notes.txt", 0, 2410], ["todo.md", 0, 860]],
90
+ "/Users/you/Documents": [["Invoices", 1], ["budget-2026.xlsx", 0, 48210], ["letter.docx", 0, 18840], ["report.pdf", 0, 1243500]],
91
+ "/Users/you/Documents/Invoices": [["invoice-001.pdf", 0, 84200], ["invoice-002.pdf", 0, 91350]],
92
+ "/Users/you/Pictures": [["holiday.jpg", 0, 3420800], ["sunset.png", 0, 2104300]],
93
+ };
94
+
95
+ Backend.listSampleFolder = function (path, showHidden) {
96
+
97
+ const folderPath = path || Backend.SAMPLE_HOME;
98
+ const sampleEntries = Backend.SAMPLE_FOLDERS[folderPath] || [];
99
+
100
+ const entries = sampleEntries
101
+ .filter(function (item) { return showHidden || !item[0].startsWith("."); })
102
+ .map(function (item, index) {
103
+ return {
104
+ name: item[0],
105
+ path: Backend.joinPath(folderPath, item[0]),
106
+ isFolder: Boolean(item[1]),
107
+ size: item[2] || 0,
108
+ modified: Backend.SAMPLE_TIME - index * Backend.SAMPLE_TIME_STEP,
109
+ };
110
+ });
111
+
112
+ return Promise.resolve({
113
+ path: folderPath,
114
+ parent: Backend.parentOf(folderPath),
115
+ crumbs: Backend.crumbsOf(folderPath),
116
+ entries: entries,
117
+ total: entries.length,
118
+ millis: 0,
119
+ });
120
+
121
+ };
122
+
123
+ Backend.joinPath = function (folderPath, name) {
124
+ if (folderPath == "/") return "/" + name;
125
+ return folderPath + "/" + name;
126
+ };
127
+
128
+ // "/Users/you" -> "/Users"; the root has no parent
129
+ Backend.parentOf = function (folderPath) {
130
+ if (folderPath == "/") return null;
131
+ return folderPath.slice(0, folderPath.lastIndexOf("/")) || "/";
132
+ };
133
+
134
+ // "/Users/you" -> [{ name: "/", path: "/" }, { name: "Users", path: "/Users" }, { name: "you", path: "/Users/you" }]
135
+ Backend.crumbsOf = function (folderPath) {
136
+ const crumbs = [{ name: "/", path: "/" }];
137
+ folderPath.split("/").filter(Boolean).forEach(function (name) {
138
+ const parentPath = crumbs[crumbs.length - 1].path;
139
+ crumbs.push({ name: name, path: Backend.joinPath(parentPath, name) });
140
+ });
141
+ return crumbs;
142
+ };
143
+
144
+ // *** A SAMPLE MEASURE (in a browser): the events of sizes.rs, a folder every SAMPLE_MEASURE_STEP ms
145
+
146
+ Backend.SAMPLE_MEASURE_STEP = 400; // ms
147
+ Backend.SAMPLE_FILE_SIZE = 180000; // bytes: the size of a sample file
148
+ Backend.sampleListeners = {}; // event name -> handler
149
+ Backend.sampleMeasure = null; // { job, files, bytes, timer, steps }
150
+
151
+ Backend.emitSample = function (eventName, payload) {
152
+ const handler = Backend.sampleListeners[eventName];
153
+ if (handler) handler(payload);
154
+ };
155
+
156
+ Backend.measureSampleFolders = function (path, job) {
157
+
158
+ Backend.stopSampleMeasure();
159
+ const folderPaths = (Backend.SAMPLE_FOLDERS[path] || [])
160
+ .filter(function (item) { return item[1]; })
161
+ .map(function (item) { return Backend.joinPath(path, item[0]); });
162
+ const measure = { job: job, files: 0, bytes: 0, timer: null, steps: 0 };
163
+ Backend.sampleMeasure = measure;
164
+
165
+ const measureNext = function () {
166
+ if (measure.steps == folderPaths.length) {
167
+ Backend.endSampleMeasure(false);
168
+ return;
169
+ }
170
+ const files = 40 + measure.steps * 25;
171
+ const bytes = files * Backend.SAMPLE_FILE_SIZE;
172
+ measure.files += files;
173
+ measure.bytes += bytes;
174
+ Backend.emitSample("measure-progress", { job: job, files: measure.files, bytes: measure.bytes });
175
+ Backend.emitSample("measure-folder", { job: job, path: folderPaths[measure.steps], files: files, bytes: bytes });
176
+ measure.steps++;
177
+ measure.timer = setTimeout(measureNext, Backend.SAMPLE_MEASURE_STEP);
178
+ };
179
+
180
+ measure.timer = setTimeout(measureNext, Backend.SAMPLE_MEASURE_STEP);
181
+ return Promise.resolve(null);
182
+
183
+ };
184
+
185
+ Backend.stopSampleMeasure = function () {
186
+ if (Backend.sampleMeasure) Backend.endSampleMeasure(true);
187
+ return Promise.resolve(null);
188
+ };
189
+
190
+ Backend.endSampleMeasure = function (isStopped) {
191
+ const measure = Backend.sampleMeasure;
192
+ clearTimeout(measure.timer);
193
+ Backend.sampleMeasure = null;
194
+ const millis = measure.steps * Backend.SAMPLE_MEASURE_STEP;
195
+ Backend.emitSample("measure-done", { job: measure.job, files: measure.files, bytes: measure.bytes, millis: millis, stopped: isStopped });
196
+ };
@@ -0,0 +1,14 @@
1
+
2
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
@@ -0,0 +1 @@
1
+ @font-face{font-family:opensans;src:url(font/open-sans/OpenSans-Regular.ttf);font-display:block}@font-face{font-family:opensans-bold;src:url(font/open-sans/OpenSans-Bold.ttf);font-display:block}body{margin:0;padding:0;font-family:opensans;overflow:hidden}.basic_box,.basic_label,.basic_button,.basic_textbox-main,.basic_image{-webkit-tap-highlight-color:rgba(0,0,0,0);touch-action:manipulation;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-touch-callout:none;-webkit-text-size-adjust:auto;user-select:none;-webkit-user-select:none}.basic_box{position:absolute;display:block;overflow-x:hidden;overflow-y:hidden;background-color:whitesmoke;border-radius:0;border:0 solid rgba(0,0,0,.6);font-family:opensans;font-size:16px;text-align:left;color:rgba(0,0,0,.8);padding:0;margin:0;box-sizing:border-box;pointer-events:none}.basic_label{position:absolute;display:block;overflow:hidden;font-family:opensans;font-size:20px;text-align:left;color:rgba(0,0,0,.8);background-color:transparent;border:0 solid rgba(0,0,0,.6);padding:0;box-sizing:border-box;pointer-events:none}.basic_button{position:absolute;display:block;overflow:hidden;font-family:opensans;font-size:20px;text-align:center;color:rgba(0,0,0,.65);border:1px solid rgba(0,0,0,.40);box-shadow:inset 0px -2px 0 0 rgba(0,0,0,.40);margin:0;box-sizing:border-box;border-radius:4px;background-color:#689BD2;background-image:linear-gradient(to bottom,rgba(0,0,0,0),rgba(0,0,0,.02) 60%,rgba(0,0,0,.055));background-position:left top;background-repeat:no-repeat;background-size:100% 100%;pointer-events:auto;cursor:pointer}.basic_button.minimal{border:0 solid rgba(0,0,0,.40);box-shadow:none;background-image:none}.basic_button:focus{outline:none}.basic_button:disabled{opacity:.6!important;cursor:default}.basic_textbox-main{position:absolute;display:block}.basic_textbox{position:absolute;font-family:opensans;font-size:20px;text-align:left;color:#4A4A4A;background-color:#FFFFFF;left:0;right:0;border:1px solid #4A4A4A;width:270px;height:50px;padding:12px 15px;margin:0;box-sizing:border-box;border-radius:4px;background-image:linear-gradient(to top,rgba(0,0,0,0),rgba(0,0,0,.02) 60%,rgba(0,0,0,.055));background-position:left top;background-repeat:no-repeat;background-size:100% 100%;pointer-events:auto}.basic_textbox.minimal{border:0 solid #4A4A4A;background-image:none}.basic_textbox:focus{outline:none;padding:12px 14px;background-color:#FFFFFF;border:2px solid #689BD2}.basic_textbox.minimal:focus{outline:none;padding:12px 15px;border:0 solid steelblue}.basic_textbox:disabled{opacity:.6!important}.basic_textbox-title{position:absolute;background-color:transparent;font-family:opensans;font-size:16px;text-align:left;color:#4A4A4A;height:28px;top:-28px;left:0;padding:2px;padding-left:0;border:0;border-top-left-radius:6px;border-top-right-radius:6px;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:none}.basic_image{position:absolute;display:block;overflow:hidden;background-color:transparent;border:0 solid rgba(0,0,0,.6);padding:0;margin:0;box-sizing:border-box;border-radius:0;pointer-events:none}.basic_box::-webkit-scrollbar{width:0;height:0}.basic_box::-webkit-scrollbar-thumb{background:rgba(0,0,0,.15);border-radius:6px;border:2px solid rgba(0,0,0,0);background-clip:padding-box}.basic_box::-webkit-scrollbar-thumb:hover{background:rgba(0,0,0,.2);border-radius:6px;border:2px solid rgba(0,0,0,0);background-clip:padding-box}.basic_box::-webkit-scrollbar-thumb:active{background:rgba(0,0,0,.25);border-radius:6px;border:2px solid rgba(0,0,0,0);background-clip:padding-box}.basic_box::-webkit-scrollbar-track{background:transparent;border-radius:0;background-clip:padding-box}.basic_box::-webkit-scrollbar-corner{background-color:transparent}