tiny-essentials 1.12.0 → 1.12.2

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 (32) hide show
  1. package/dist/legacy/firebase/index.mjs +5 -5
  2. package/dist/v1/TinyBasicsEs.js +1 -1257
  3. package/dist/v1/TinyBasicsEs.min.js +1 -1
  4. package/dist/v1/TinyDragger.js +148 -43
  5. package/dist/v1/TinyDragger.min.js +1 -1
  6. package/dist/v1/TinyEssentials.js +484 -189
  7. package/dist/v1/TinyEssentials.min.js +1 -1
  8. package/dist/v1/TinyUploadClicker.js +478 -190
  9. package/dist/v1/TinyUploadClicker.min.js +1 -1
  10. package/dist/v1/basics/index.cjs +0 -23
  11. package/dist/v1/basics/index.d.mts +1 -23
  12. package/dist/v1/basics/index.mjs +1 -2
  13. package/dist/v1/fileManager/asyncFuncs.cjs +272 -0
  14. package/dist/v1/fileManager/asyncFuncs.d.mts +93 -0
  15. package/dist/v1/fileManager/asyncFuncs.mjs +236 -0
  16. package/dist/v1/fileManager/index.cjs +35 -0
  17. package/dist/v1/fileManager/index.d.mts +30 -0
  18. package/dist/v1/fileManager/index.mjs +3 -0
  19. package/dist/v1/{basics/fileManager.cjs → fileManager/normalFuncs.cjs} +10 -105
  20. package/dist/v1/{basics/fileManager.d.mts → fileManager/normalFuncs.d.mts} +3 -56
  21. package/dist/v1/{basics/fileManager.mjs → fileManager/normalFuncs.mjs} +48 -131
  22. package/dist/v1/index.cjs +30 -23
  23. package/dist/v1/index.d.mts +29 -23
  24. package/dist/v1/index.mjs +3 -2
  25. package/dist/v1/libs/TinyDragger.cjs +148 -43
  26. package/dist/v1/libs/TinyDragger.d.mts +18 -2
  27. package/dist/v1/libs/TinyDragger.mjs +132 -38
  28. package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
  29. package/docs/v1/README.md +3 -1
  30. package/docs/v1/{basics/fileManager.md → fileManager/main.md} +12 -0
  31. package/docs/v1/libs/TinyDragger.md +15 -0
  32. package/package.json +5 -1
@@ -1,13 +1,6 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 41:
5
- /***/ (() => {
6
-
7
- /* (ignored) */
8
-
9
- /***/ }),
10
-
11
4
  /***/ 251:
12
5
  /***/ ((__unused_webpack_module, exports) => {
13
6
 
@@ -2082,735 +2075,6 @@ function fromByteArray (uint8) {
2082
2075
  }
2083
2076
 
2084
2077
 
2085
- /***/ }),
2086
-
2087
- /***/ 606:
2088
- /***/ ((module) => {
2089
-
2090
- // shim for using process in browser
2091
- var process = module.exports = {};
2092
-
2093
- // cached from whatever global is present so that test runners that stub it
2094
- // don't break things. But we need to wrap it in a try catch in case it is
2095
- // wrapped in strict mode code which doesn't define any globals. It's inside a
2096
- // function because try/catches deoptimize in certain engines.
2097
-
2098
- var cachedSetTimeout;
2099
- var cachedClearTimeout;
2100
-
2101
- function defaultSetTimout() {
2102
- throw new Error('setTimeout has not been defined');
2103
- }
2104
- function defaultClearTimeout () {
2105
- throw new Error('clearTimeout has not been defined');
2106
- }
2107
- (function () {
2108
- try {
2109
- if (typeof setTimeout === 'function') {
2110
- cachedSetTimeout = setTimeout;
2111
- } else {
2112
- cachedSetTimeout = defaultSetTimout;
2113
- }
2114
- } catch (e) {
2115
- cachedSetTimeout = defaultSetTimout;
2116
- }
2117
- try {
2118
- if (typeof clearTimeout === 'function') {
2119
- cachedClearTimeout = clearTimeout;
2120
- } else {
2121
- cachedClearTimeout = defaultClearTimeout;
2122
- }
2123
- } catch (e) {
2124
- cachedClearTimeout = defaultClearTimeout;
2125
- }
2126
- } ())
2127
- function runTimeout(fun) {
2128
- if (cachedSetTimeout === setTimeout) {
2129
- //normal enviroments in sane situations
2130
- return setTimeout(fun, 0);
2131
- }
2132
- // if setTimeout wasn't available but was latter defined
2133
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
2134
- cachedSetTimeout = setTimeout;
2135
- return setTimeout(fun, 0);
2136
- }
2137
- try {
2138
- // when when somebody has screwed with setTimeout but no I.E. maddness
2139
- return cachedSetTimeout(fun, 0);
2140
- } catch(e){
2141
- try {
2142
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
2143
- return cachedSetTimeout.call(null, fun, 0);
2144
- } catch(e){
2145
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
2146
- return cachedSetTimeout.call(this, fun, 0);
2147
- }
2148
- }
2149
-
2150
-
2151
- }
2152
- function runClearTimeout(marker) {
2153
- if (cachedClearTimeout === clearTimeout) {
2154
- //normal enviroments in sane situations
2155
- return clearTimeout(marker);
2156
- }
2157
- // if clearTimeout wasn't available but was latter defined
2158
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
2159
- cachedClearTimeout = clearTimeout;
2160
- return clearTimeout(marker);
2161
- }
2162
- try {
2163
- // when when somebody has screwed with setTimeout but no I.E. maddness
2164
- return cachedClearTimeout(marker);
2165
- } catch (e){
2166
- try {
2167
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
2168
- return cachedClearTimeout.call(null, marker);
2169
- } catch (e){
2170
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
2171
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
2172
- return cachedClearTimeout.call(this, marker);
2173
- }
2174
- }
2175
-
2176
-
2177
-
2178
- }
2179
- var queue = [];
2180
- var draining = false;
2181
- var currentQueue;
2182
- var queueIndex = -1;
2183
-
2184
- function cleanUpNextTick() {
2185
- if (!draining || !currentQueue) {
2186
- return;
2187
- }
2188
- draining = false;
2189
- if (currentQueue.length) {
2190
- queue = currentQueue.concat(queue);
2191
- } else {
2192
- queueIndex = -1;
2193
- }
2194
- if (queue.length) {
2195
- drainQueue();
2196
- }
2197
- }
2198
-
2199
- function drainQueue() {
2200
- if (draining) {
2201
- return;
2202
- }
2203
- var timeout = runTimeout(cleanUpNextTick);
2204
- draining = true;
2205
-
2206
- var len = queue.length;
2207
- while(len) {
2208
- currentQueue = queue;
2209
- queue = [];
2210
- while (++queueIndex < len) {
2211
- if (currentQueue) {
2212
- currentQueue[queueIndex].run();
2213
- }
2214
- }
2215
- queueIndex = -1;
2216
- len = queue.length;
2217
- }
2218
- currentQueue = null;
2219
- draining = false;
2220
- runClearTimeout(timeout);
2221
- }
2222
-
2223
- process.nextTick = function (fun) {
2224
- var args = new Array(arguments.length - 1);
2225
- if (arguments.length > 1) {
2226
- for (var i = 1; i < arguments.length; i++) {
2227
- args[i - 1] = arguments[i];
2228
- }
2229
- }
2230
- queue.push(new Item(fun, args));
2231
- if (queue.length === 1 && !draining) {
2232
- runTimeout(drainQueue);
2233
- }
2234
- };
2235
-
2236
- // v8 likes predictible objects
2237
- function Item(fun, array) {
2238
- this.fun = fun;
2239
- this.array = array;
2240
- }
2241
- Item.prototype.run = function () {
2242
- this.fun.apply(null, this.array);
2243
- };
2244
- process.title = 'browser';
2245
- process.browser = true;
2246
- process.env = {};
2247
- process.argv = [];
2248
- process.version = ''; // empty string to avoid regexp issues
2249
- process.versions = {};
2250
-
2251
- function noop() {}
2252
-
2253
- process.on = noop;
2254
- process.addListener = noop;
2255
- process.once = noop;
2256
- process.off = noop;
2257
- process.removeListener = noop;
2258
- process.removeAllListeners = noop;
2259
- process.emit = noop;
2260
- process.prependListener = noop;
2261
- process.prependOnceListener = noop;
2262
-
2263
- process.listeners = function (name) { return [] }
2264
-
2265
- process.binding = function (name) {
2266
- throw new Error('process.binding is not supported');
2267
- };
2268
-
2269
- process.cwd = function () { return '/' };
2270
- process.chdir = function (dir) {
2271
- throw new Error('process.chdir is not supported');
2272
- };
2273
- process.umask = function() { return 0; };
2274
-
2275
-
2276
- /***/ }),
2277
-
2278
- /***/ 975:
2279
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2280
-
2281
- "use strict";
2282
- /* provided dependency */ var process = __webpack_require__(606);
2283
- // 'path' module extracted from Node.js v8.11.1 (only the posix part)
2284
- // transplited with Babel
2285
-
2286
- // Copyright Joyent, Inc. and other Node contributors.
2287
- //
2288
- // Permission is hereby granted, free of charge, to any person obtaining a
2289
- // copy of this software and associated documentation files (the
2290
- // "Software"), to deal in the Software without restriction, including
2291
- // without limitation the rights to use, copy, modify, merge, publish,
2292
- // distribute, sublicense, and/or sell copies of the Software, and to permit
2293
- // persons to whom the Software is furnished to do so, subject to the
2294
- // following conditions:
2295
- //
2296
- // The above copyright notice and this permission notice shall be included
2297
- // in all copies or substantial portions of the Software.
2298
- //
2299
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2300
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2301
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2302
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2303
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2304
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2305
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
2306
-
2307
-
2308
-
2309
- function assertPath(path) {
2310
- if (typeof path !== 'string') {
2311
- throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
2312
- }
2313
- }
2314
-
2315
- // Resolves . and .. elements in a path with directory names
2316
- function normalizeStringPosix(path, allowAboveRoot) {
2317
- var res = '';
2318
- var lastSegmentLength = 0;
2319
- var lastSlash = -1;
2320
- var dots = 0;
2321
- var code;
2322
- for (var i = 0; i <= path.length; ++i) {
2323
- if (i < path.length)
2324
- code = path.charCodeAt(i);
2325
- else if (code === 47 /*/*/)
2326
- break;
2327
- else
2328
- code = 47 /*/*/;
2329
- if (code === 47 /*/*/) {
2330
- if (lastSlash === i - 1 || dots === 1) {
2331
- // NOOP
2332
- } else if (lastSlash !== i - 1 && dots === 2) {
2333
- if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
2334
- if (res.length > 2) {
2335
- var lastSlashIndex = res.lastIndexOf('/');
2336
- if (lastSlashIndex !== res.length - 1) {
2337
- if (lastSlashIndex === -1) {
2338
- res = '';
2339
- lastSegmentLength = 0;
2340
- } else {
2341
- res = res.slice(0, lastSlashIndex);
2342
- lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
2343
- }
2344
- lastSlash = i;
2345
- dots = 0;
2346
- continue;
2347
- }
2348
- } else if (res.length === 2 || res.length === 1) {
2349
- res = '';
2350
- lastSegmentLength = 0;
2351
- lastSlash = i;
2352
- dots = 0;
2353
- continue;
2354
- }
2355
- }
2356
- if (allowAboveRoot) {
2357
- if (res.length > 0)
2358
- res += '/..';
2359
- else
2360
- res = '..';
2361
- lastSegmentLength = 2;
2362
- }
2363
- } else {
2364
- if (res.length > 0)
2365
- res += '/' + path.slice(lastSlash + 1, i);
2366
- else
2367
- res = path.slice(lastSlash + 1, i);
2368
- lastSegmentLength = i - lastSlash - 1;
2369
- }
2370
- lastSlash = i;
2371
- dots = 0;
2372
- } else if (code === 46 /*.*/ && dots !== -1) {
2373
- ++dots;
2374
- } else {
2375
- dots = -1;
2376
- }
2377
- }
2378
- return res;
2379
- }
2380
-
2381
- function _format(sep, pathObject) {
2382
- var dir = pathObject.dir || pathObject.root;
2383
- var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
2384
- if (!dir) {
2385
- return base;
2386
- }
2387
- if (dir === pathObject.root) {
2388
- return dir + base;
2389
- }
2390
- return dir + sep + base;
2391
- }
2392
-
2393
- var posix = {
2394
- // path.resolve([from ...], to)
2395
- resolve: function resolve() {
2396
- var resolvedPath = '';
2397
- var resolvedAbsolute = false;
2398
- var cwd;
2399
-
2400
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
2401
- var path;
2402
- if (i >= 0)
2403
- path = arguments[i];
2404
- else {
2405
- if (cwd === undefined)
2406
- cwd = process.cwd();
2407
- path = cwd;
2408
- }
2409
-
2410
- assertPath(path);
2411
-
2412
- // Skip empty entries
2413
- if (path.length === 0) {
2414
- continue;
2415
- }
2416
-
2417
- resolvedPath = path + '/' + resolvedPath;
2418
- resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
2419
- }
2420
-
2421
- // At this point the path should be resolved to a full absolute path, but
2422
- // handle relative paths to be safe (might happen when process.cwd() fails)
2423
-
2424
- // Normalize the path
2425
- resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
2426
-
2427
- if (resolvedAbsolute) {
2428
- if (resolvedPath.length > 0)
2429
- return '/' + resolvedPath;
2430
- else
2431
- return '/';
2432
- } else if (resolvedPath.length > 0) {
2433
- return resolvedPath;
2434
- } else {
2435
- return '.';
2436
- }
2437
- },
2438
-
2439
- normalize: function normalize(path) {
2440
- assertPath(path);
2441
-
2442
- if (path.length === 0) return '.';
2443
-
2444
- var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
2445
- var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
2446
-
2447
- // Normalize the path
2448
- path = normalizeStringPosix(path, !isAbsolute);
2449
-
2450
- if (path.length === 0 && !isAbsolute) path = '.';
2451
- if (path.length > 0 && trailingSeparator) path += '/';
2452
-
2453
- if (isAbsolute) return '/' + path;
2454
- return path;
2455
- },
2456
-
2457
- isAbsolute: function isAbsolute(path) {
2458
- assertPath(path);
2459
- return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
2460
- },
2461
-
2462
- join: function join() {
2463
- if (arguments.length === 0)
2464
- return '.';
2465
- var joined;
2466
- for (var i = 0; i < arguments.length; ++i) {
2467
- var arg = arguments[i];
2468
- assertPath(arg);
2469
- if (arg.length > 0) {
2470
- if (joined === undefined)
2471
- joined = arg;
2472
- else
2473
- joined += '/' + arg;
2474
- }
2475
- }
2476
- if (joined === undefined)
2477
- return '.';
2478
- return posix.normalize(joined);
2479
- },
2480
-
2481
- relative: function relative(from, to) {
2482
- assertPath(from);
2483
- assertPath(to);
2484
-
2485
- if (from === to) return '';
2486
-
2487
- from = posix.resolve(from);
2488
- to = posix.resolve(to);
2489
-
2490
- if (from === to) return '';
2491
-
2492
- // Trim any leading backslashes
2493
- var fromStart = 1;
2494
- for (; fromStart < from.length; ++fromStart) {
2495
- if (from.charCodeAt(fromStart) !== 47 /*/*/)
2496
- break;
2497
- }
2498
- var fromEnd = from.length;
2499
- var fromLen = fromEnd - fromStart;
2500
-
2501
- // Trim any leading backslashes
2502
- var toStart = 1;
2503
- for (; toStart < to.length; ++toStart) {
2504
- if (to.charCodeAt(toStart) !== 47 /*/*/)
2505
- break;
2506
- }
2507
- var toEnd = to.length;
2508
- var toLen = toEnd - toStart;
2509
-
2510
- // Compare paths to find the longest common path from root
2511
- var length = fromLen < toLen ? fromLen : toLen;
2512
- var lastCommonSep = -1;
2513
- var i = 0;
2514
- for (; i <= length; ++i) {
2515
- if (i === length) {
2516
- if (toLen > length) {
2517
- if (to.charCodeAt(toStart + i) === 47 /*/*/) {
2518
- // We get here if `from` is the exact base path for `to`.
2519
- // For example: from='/foo/bar'; to='/foo/bar/baz'
2520
- return to.slice(toStart + i + 1);
2521
- } else if (i === 0) {
2522
- // We get here if `from` is the root
2523
- // For example: from='/'; to='/foo'
2524
- return to.slice(toStart + i);
2525
- }
2526
- } else if (fromLen > length) {
2527
- if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
2528
- // We get here if `to` is the exact base path for `from`.
2529
- // For example: from='/foo/bar/baz'; to='/foo/bar'
2530
- lastCommonSep = i;
2531
- } else if (i === 0) {
2532
- // We get here if `to` is the root.
2533
- // For example: from='/foo'; to='/'
2534
- lastCommonSep = 0;
2535
- }
2536
- }
2537
- break;
2538
- }
2539
- var fromCode = from.charCodeAt(fromStart + i);
2540
- var toCode = to.charCodeAt(toStart + i);
2541
- if (fromCode !== toCode)
2542
- break;
2543
- else if (fromCode === 47 /*/*/)
2544
- lastCommonSep = i;
2545
- }
2546
-
2547
- var out = '';
2548
- // Generate the relative path based on the path difference between `to`
2549
- // and `from`
2550
- for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
2551
- if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
2552
- if (out.length === 0)
2553
- out += '..';
2554
- else
2555
- out += '/..';
2556
- }
2557
- }
2558
-
2559
- // Lastly, append the rest of the destination (`to`) path that comes after
2560
- // the common path parts
2561
- if (out.length > 0)
2562
- return out + to.slice(toStart + lastCommonSep);
2563
- else {
2564
- toStart += lastCommonSep;
2565
- if (to.charCodeAt(toStart) === 47 /*/*/)
2566
- ++toStart;
2567
- return to.slice(toStart);
2568
- }
2569
- },
2570
-
2571
- _makeLong: function _makeLong(path) {
2572
- return path;
2573
- },
2574
-
2575
- dirname: function dirname(path) {
2576
- assertPath(path);
2577
- if (path.length === 0) return '.';
2578
- var code = path.charCodeAt(0);
2579
- var hasRoot = code === 47 /*/*/;
2580
- var end = -1;
2581
- var matchedSlash = true;
2582
- for (var i = path.length - 1; i >= 1; --i) {
2583
- code = path.charCodeAt(i);
2584
- if (code === 47 /*/*/) {
2585
- if (!matchedSlash) {
2586
- end = i;
2587
- break;
2588
- }
2589
- } else {
2590
- // We saw the first non-path separator
2591
- matchedSlash = false;
2592
- }
2593
- }
2594
-
2595
- if (end === -1) return hasRoot ? '/' : '.';
2596
- if (hasRoot && end === 1) return '//';
2597
- return path.slice(0, end);
2598
- },
2599
-
2600
- basename: function basename(path, ext) {
2601
- if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
2602
- assertPath(path);
2603
-
2604
- var start = 0;
2605
- var end = -1;
2606
- var matchedSlash = true;
2607
- var i;
2608
-
2609
- if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
2610
- if (ext.length === path.length && ext === path) return '';
2611
- var extIdx = ext.length - 1;
2612
- var firstNonSlashEnd = -1;
2613
- for (i = path.length - 1; i >= 0; --i) {
2614
- var code = path.charCodeAt(i);
2615
- if (code === 47 /*/*/) {
2616
- // If we reached a path separator that was not part of a set of path
2617
- // separators at the end of the string, stop now
2618
- if (!matchedSlash) {
2619
- start = i + 1;
2620
- break;
2621
- }
2622
- } else {
2623
- if (firstNonSlashEnd === -1) {
2624
- // We saw the first non-path separator, remember this index in case
2625
- // we need it if the extension ends up not matching
2626
- matchedSlash = false;
2627
- firstNonSlashEnd = i + 1;
2628
- }
2629
- if (extIdx >= 0) {
2630
- // Try to match the explicit extension
2631
- if (code === ext.charCodeAt(extIdx)) {
2632
- if (--extIdx === -1) {
2633
- // We matched the extension, so mark this as the end of our path
2634
- // component
2635
- end = i;
2636
- }
2637
- } else {
2638
- // Extension does not match, so our result is the entire path
2639
- // component
2640
- extIdx = -1;
2641
- end = firstNonSlashEnd;
2642
- }
2643
- }
2644
- }
2645
- }
2646
-
2647
- if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
2648
- return path.slice(start, end);
2649
- } else {
2650
- for (i = path.length - 1; i >= 0; --i) {
2651
- if (path.charCodeAt(i) === 47 /*/*/) {
2652
- // If we reached a path separator that was not part of a set of path
2653
- // separators at the end of the string, stop now
2654
- if (!matchedSlash) {
2655
- start = i + 1;
2656
- break;
2657
- }
2658
- } else if (end === -1) {
2659
- // We saw the first non-path separator, mark this as the end of our
2660
- // path component
2661
- matchedSlash = false;
2662
- end = i + 1;
2663
- }
2664
- }
2665
-
2666
- if (end === -1) return '';
2667
- return path.slice(start, end);
2668
- }
2669
- },
2670
-
2671
- extname: function extname(path) {
2672
- assertPath(path);
2673
- var startDot = -1;
2674
- var startPart = 0;
2675
- var end = -1;
2676
- var matchedSlash = true;
2677
- // Track the state of characters (if any) we see before our first dot and
2678
- // after any path separator we find
2679
- var preDotState = 0;
2680
- for (var i = path.length - 1; i >= 0; --i) {
2681
- var code = path.charCodeAt(i);
2682
- if (code === 47 /*/*/) {
2683
- // If we reached a path separator that was not part of a set of path
2684
- // separators at the end of the string, stop now
2685
- if (!matchedSlash) {
2686
- startPart = i + 1;
2687
- break;
2688
- }
2689
- continue;
2690
- }
2691
- if (end === -1) {
2692
- // We saw the first non-path separator, mark this as the end of our
2693
- // extension
2694
- matchedSlash = false;
2695
- end = i + 1;
2696
- }
2697
- if (code === 46 /*.*/) {
2698
- // If this is our first dot, mark it as the start of our extension
2699
- if (startDot === -1)
2700
- startDot = i;
2701
- else if (preDotState !== 1)
2702
- preDotState = 1;
2703
- } else if (startDot !== -1) {
2704
- // We saw a non-dot and non-path separator before our dot, so we should
2705
- // have a good chance at having a non-empty extension
2706
- preDotState = -1;
2707
- }
2708
- }
2709
-
2710
- if (startDot === -1 || end === -1 ||
2711
- // We saw a non-dot character immediately before the dot
2712
- preDotState === 0 ||
2713
- // The (right-most) trimmed path component is exactly '..'
2714
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
2715
- return '';
2716
- }
2717
- return path.slice(startDot, end);
2718
- },
2719
-
2720
- format: function format(pathObject) {
2721
- if (pathObject === null || typeof pathObject !== 'object') {
2722
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
2723
- }
2724
- return _format('/', pathObject);
2725
- },
2726
-
2727
- parse: function parse(path) {
2728
- assertPath(path);
2729
-
2730
- var ret = { root: '', dir: '', base: '', ext: '', name: '' };
2731
- if (path.length === 0) return ret;
2732
- var code = path.charCodeAt(0);
2733
- var isAbsolute = code === 47 /*/*/;
2734
- var start;
2735
- if (isAbsolute) {
2736
- ret.root = '/';
2737
- start = 1;
2738
- } else {
2739
- start = 0;
2740
- }
2741
- var startDot = -1;
2742
- var startPart = 0;
2743
- var end = -1;
2744
- var matchedSlash = true;
2745
- var i = path.length - 1;
2746
-
2747
- // Track the state of characters (if any) we see before our first dot and
2748
- // after any path separator we find
2749
- var preDotState = 0;
2750
-
2751
- // Get non-dir info
2752
- for (; i >= start; --i) {
2753
- code = path.charCodeAt(i);
2754
- if (code === 47 /*/*/) {
2755
- // If we reached a path separator that was not part of a set of path
2756
- // separators at the end of the string, stop now
2757
- if (!matchedSlash) {
2758
- startPart = i + 1;
2759
- break;
2760
- }
2761
- continue;
2762
- }
2763
- if (end === -1) {
2764
- // We saw the first non-path separator, mark this as the end of our
2765
- // extension
2766
- matchedSlash = false;
2767
- end = i + 1;
2768
- }
2769
- if (code === 46 /*.*/) {
2770
- // If this is our first dot, mark it as the start of our extension
2771
- if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
2772
- } else if (startDot !== -1) {
2773
- // We saw a non-dot and non-path separator before our dot, so we should
2774
- // have a good chance at having a non-empty extension
2775
- preDotState = -1;
2776
- }
2777
- }
2778
-
2779
- if (startDot === -1 || end === -1 ||
2780
- // We saw a non-dot character immediately before the dot
2781
- preDotState === 0 ||
2782
- // The (right-most) trimmed path component is exactly '..'
2783
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
2784
- if (end !== -1) {
2785
- if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
2786
- }
2787
- } else {
2788
- if (startPart === 0 && isAbsolute) {
2789
- ret.name = path.slice(1, startDot);
2790
- ret.base = path.slice(1, end);
2791
- } else {
2792
- ret.name = path.slice(startPart, startDot);
2793
- ret.base = path.slice(startPart, end);
2794
- }
2795
- ret.ext = path.slice(startDot, end);
2796
- }
2797
-
2798
- if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
2799
-
2800
- return ret;
2801
- },
2802
-
2803
- sep: '/',
2804
- delimiter: ':',
2805
- win32: null,
2806
- posix: null
2807
- };
2808
-
2809
- posix.posix = posix;
2810
-
2811
- module.exports = posix;
2812
-
2813
-
2814
2078
  /***/ })
2815
2079
 
2816
2080
  /******/ });
@@ -2882,20 +2146,12 @@ __webpack_require__.d(__webpack_exports__, {
2882
2146
  areHtmlElsColliding: () => (/* reexport */ areHtmlElsColliding),
2883
2147
  arraySortPositions: () => (/* reexport */ arraySortPositions),
2884
2148
  asyncReplace: () => (/* reexport */ asyncReplace),
2885
- backupFile: () => (/* reexport */ backupFile),
2886
- clearDirectory: () => (/* reexport */ clearDirectory),
2887
2149
  cloneObjTypeOrder: () => (/* reexport */ cloneObjTypeOrder),
2888
2150
  countObj: () => (/* reexport */ countObj),
2889
- dirExists: () => (/* reexport */ dirExists),
2890
- dirSize: () => (/* reexport */ dirSize),
2891
2151
  documentIsFullScreen: () => (/* reexport */ documentIsFullScreen),
2892
- ensureCopyFile: () => (/* reexport */ ensureCopyFile),
2893
- ensureDirectory: () => (/* reexport */ ensureDirectory),
2894
2152
  exitFullScreen: () => (/* reexport */ exitFullScreen),
2895
2153
  extendObjType: () => (/* reexport */ extendObjType),
2896
2154
  fetchJson: () => (/* reexport */ fetchJson),
2897
- fileExists: () => (/* reexport */ fileExists),
2898
- fileSize: () => (/* reexport */ fileSize),
2899
2155
  formatBytes: () => (/* reexport */ formatBytes),
2900
2156
  formatCustomTimer: () => (/* reexport */ formatCustomTimer),
2901
2157
  formatDayTimer: () => (/* reexport */ formatDayTimer),
@@ -2905,36 +2161,22 @@ __webpack_require__.d(__webpack_exports__, {
2905
2161
  getHtmlElBordersWidth: () => (/* reexport */ getHtmlElBordersWidth),
2906
2162
  getHtmlElMargin: () => (/* reexport */ getHtmlElMargin),
2907
2163
  getHtmlElPadding: () => (/* reexport */ getHtmlElPadding),
2908
- getLatestBackupPath: () => (/* reexport */ getLatestBackupPath),
2909
2164
  getSimplePerc: () => (/* reexport */ getSimplePerc),
2910
2165
  getTimeDuration: () => (/* reexport */ getTimeDuration),
2911
- isDirEmpty: () => (/* reexport */ isDirEmpty),
2912
2166
  isFullScreenMode: () => (/* reexport */ isFullScreenMode),
2913
2167
  isJsonObject: () => (/* reexport */ isJsonObject),
2914
2168
  isScreenFilled: () => (/* reexport */ isScreenFilled),
2915
- listDirs: () => (/* reexport */ listDirs),
2916
- listFiles: () => (/* reexport */ listFiles),
2917
2169
  objType: () => (/* reexport */ objType),
2918
2170
  offFullScreenChange: () => (/* reexport */ offFullScreenChange),
2919
2171
  onFullScreenChange: () => (/* reexport */ onFullScreenChange),
2920
2172
  readJsonBlob: () => (/* reexport */ readJsonBlob),
2921
- readJsonFile: () => (/* reexport */ readJsonFile),
2922
- renameFileAddPrefixSuffix: () => (/* reexport */ renameFileAddPrefixSuffix),
2923
- renameFileBatch: () => (/* reexport */ renameFileBatch),
2924
- renameFileNormalizeCase: () => (/* reexport */ renameFileNormalizeCase),
2925
- renameFilePadNumbers: () => (/* reexport */ renameFilePadNumbers),
2926
- renameFileRegex: () => (/* reexport */ renameFileRegex),
2927
2173
  reorderObjTypeOrder: () => (/* reexport */ reorderObjTypeOrder),
2928
2174
  requestFullScreen: () => (/* reexport */ requestFullScreen),
2929
- restoreLatestBackup: () => (/* reexport */ restoreLatestBackup),
2930
2175
  ruleOfThree: () => (/* reexport */ ruleOfThree),
2931
2176
  saveJsonFile: () => (/* reexport */ saveJsonFile),
2932
2177
  shuffleArray: () => (/* reexport */ shuffleArray),
2933
2178
  toTitleCase: () => (/* reexport */ toTitleCase),
2934
- toTitleCaseLowerFirst: () => (/* reexport */ toTitleCaseLowerFirst),
2935
- tryDeleteFile: () => (/* reexport */ tryDeleteFile),
2936
- writeJsonFile: () => (/* reexport */ writeJsonFile),
2937
- writeTextFile: () => (/* reexport */ writeTextFile)
2179
+ toTitleCaseLowerFirst: () => (/* reexport */ toTitleCaseLowerFirst)
2938
2180
  });
2939
2181
 
2940
2182
  ;// ./src/legacy/libs/arraySortPositions.mjs
@@ -4199,503 +3441,6 @@ function KeyPressHandler() {
4199
3441
  export default KeyPressHandler;
4200
3442
  */
4201
3443
 
4202
- // EXTERNAL MODULE: fs (ignored)
4203
- var fs_ignored_ = __webpack_require__(41);
4204
- // EXTERNAL MODULE: ./node_modules/path-browserify/index.js
4205
- var path_browserify = __webpack_require__(975);
4206
- ;// ./src/v1/basics/fileManager.mjs
4207
-
4208
-
4209
-
4210
-
4211
- /*========================*
4212
- * JSON Operations
4213
- *========================*/
4214
-
4215
- /**
4216
- * Reads and parses a JSON file.
4217
- * Throws an error if the file content is not valid JSON.
4218
- * @param {string} filePath
4219
- * @returns {any}
4220
- */
4221
- function readJsonFile(filePath) {
4222
- if (!fs_ignored_.existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
4223
- const content = fs_ignored_.readFileSync(filePath, 'utf-8');
4224
- return JSON.parse(content);
4225
- }
4226
-
4227
- /**
4228
- * Saves an object as JSON to a file.
4229
- * Automatically creates the directory if it does not exist.
4230
- * @param {string} filePath
4231
- * @param {any} data
4232
- * @param {number} [spaces=2]
4233
- */
4234
- function writeJsonFile(filePath, data, spaces = 2) {
4235
- const json = JSON.stringify(data, null, spaces);
4236
- fs_ignored_.writeFileSync(filePath, json, 'utf-8');
4237
- }
4238
-
4239
- /**
4240
- * Reads and parses a JSON file.
4241
- * Throws an error if the file content is not valid JSON.
4242
- * @param {string} filePath
4243
- * @returns {Promise<any>}
4244
- */
4245
- async function readJsonFileAsync(filePath) {
4246
- if (!fs.existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
4247
- const content = await fs.promises.readFile(filePath, 'utf-8');
4248
- return JSON.parse(content);
4249
- }
4250
-
4251
- /**
4252
- * Saves an object as JSON to a file.
4253
- * Automatically creates the directory if it does not exist.
4254
- * @param {string} filePath
4255
- * @param {any} data
4256
- * @param {number} [spaces=2]
4257
- * @returns {Promise<void>}
4258
- */
4259
- function writeJsonFileAsync(filePath, data, spaces = 2) {
4260
- const json = JSON.stringify(data, null, spaces);
4261
- return fs.promises.writeFile(filePath, json, 'utf-8');
4262
- }
4263
-
4264
- /*========================*
4265
- * Directory Management
4266
- *========================*/
4267
-
4268
- /**
4269
- * Ensures that the directory exists, creating it recursively if needed.
4270
- * @param {string} dirPath
4271
- */
4272
- function ensureDirectory(dirPath) {
4273
- if (!fs_ignored_.existsSync(dirPath)) {
4274
- fs_ignored_.mkdirSync(dirPath, { recursive: true });
4275
- }
4276
- }
4277
-
4278
- /**
4279
- * Clears all contents inside a directory but keeps the directory.
4280
- * @param {string} dirPath
4281
- */
4282
- function clearDirectory(dirPath) {
4283
- if (!fs_ignored_.existsSync(dirPath)) return;
4284
- const files = fs_ignored_.readdirSync(dirPath);
4285
- for (const file of files) {
4286
- const fullPath = path_browserify.join(dirPath, file);
4287
- const stat = fs_ignored_.lstatSync(fullPath);
4288
- if (stat.isDirectory()) {
4289
- fs_ignored_.rmSync(fullPath, { recursive: true, force: true });
4290
- } else {
4291
- fs_ignored_.unlinkSync(fullPath);
4292
- }
4293
- }
4294
- }
4295
-
4296
- /*========================*
4297
- * File Checks
4298
- *========================*/
4299
-
4300
- /**
4301
- * Checks whether a file exists.
4302
- * @param {string} filePath
4303
- * @returns {boolean}
4304
- */
4305
- function fileExists(filePath) {
4306
- return fs_ignored_.existsSync(filePath) && fs_ignored_.lstatSync(filePath).isFile();
4307
- }
4308
-
4309
- /**
4310
- * Checks whether a directory exists.
4311
- * @param {string} dirPath
4312
- * @returns {boolean}
4313
- */
4314
- function dirExists(dirPath) {
4315
- return fs_ignored_.existsSync(dirPath) && fs_ignored_.lstatSync(dirPath).isDirectory();
4316
- }
4317
-
4318
- /**
4319
- * Checks whether a directory is empty.
4320
- * @param {string} dirPath
4321
- * @returns {boolean}
4322
- */
4323
- function isDirEmpty(dirPath) {
4324
- return fs_ignored_.existsSync(dirPath) && fs_ignored_.readdirSync(dirPath).length === 0;
4325
- }
4326
-
4327
- /*========================*
4328
- * File Operations
4329
- *========================*/
4330
-
4331
- /**
4332
- * Copies a file to a destination.
4333
- * @param {string} src
4334
- * @param {string} dest
4335
- * @param {number} [mode]
4336
- */
4337
- function ensureCopyFile(src, dest, mode) {
4338
- ensureDirectory(path_browserify.dirname(dest));
4339
- fs_ignored_.copyFileSync(src, dest, mode);
4340
- }
4341
-
4342
- /**
4343
- * Deletes a file (If the file exists).
4344
- * @param {string} filePath
4345
- * @returns {boolean}
4346
- */
4347
- function tryDeleteFile(filePath) {
4348
- if (fileExists(filePath)) {
4349
- fs_ignored_.unlinkSync(filePath);
4350
- return true;
4351
- }
4352
- return false;
4353
- }
4354
-
4355
- /**
4356
- * Copies a file to a destination.
4357
- * @param {string} src
4358
- * @param {string} dest
4359
- * @param {number} [mode]
4360
- * @returns {Promise<void>}
4361
- */
4362
- function ensureCopyFileAsync(src, dest, mode) {
4363
- ensureDirectory(path.dirname(dest));
4364
- return fs.promises.copyFile(src, dest, mode);
4365
- }
4366
-
4367
- /**
4368
- * Deletes a file (If the file exists).
4369
- * @param {string} filePath
4370
- * @returns {Promise<boolean>}
4371
- */
4372
- async function tryDeleteFileAsync(filePath) {
4373
- if (fileExists(filePath)) {
4374
- await fs.promises.unlink(filePath);
4375
- return true;
4376
- }
4377
- return false;
4378
- }
4379
-
4380
- /*========================*
4381
- * Text Operations
4382
- *========================*/
4383
-
4384
- /**
4385
- * Writes text to a file (Ensures that the directory exists, creating it recursively if needed).
4386
- * @param {string} filePath
4387
- * @param {string} content
4388
- * @param {fs.WriteFileOptions} [ops='utf-8']
4389
- */
4390
- function writeTextFile(filePath, content, ops = 'utf-8') {
4391
- const dir = path_browserify.dirname(filePath);
4392
- ensureDirectory(dir);
4393
- fs_ignored_.writeFileSync(filePath, content, ops);
4394
- }
4395
-
4396
- /**
4397
- * Writes text to a file (Ensures that the directory exists, creating it recursively if needed).
4398
- * @param {string} filePath
4399
- * @param {string} content
4400
- * @param {fs.WriteFileOptions} [ops='utf-8']
4401
- * @returns {Promise<void>}
4402
- */
4403
- function writeTextFileAsync(filePath, content, ops = 'utf-8') {
4404
- const dir = path.dirname(filePath);
4405
- ensureDirectory(dir);
4406
- return fs.promises.writeFile(filePath, content, ops);
4407
- }
4408
-
4409
- /*========================*
4410
- * Directory Listings
4411
- *========================*/
4412
-
4413
- /**
4414
- * Lists all files and dirs in a directory (optionally recursive).
4415
- * @param {string} dirPath
4416
- * @param {boolean} [recursive=false]
4417
- * @returns {{ files: string[]; dirs: string[] }}
4418
- */
4419
- function listFiles(dirPath, recursive = false) {
4420
- /** @type {{ files: string[]; dirs: string[] }} */
4421
- const results = { files: [], dirs: [] };
4422
- if (!dirExists(dirPath)) return results;
4423
-
4424
- const entries = fs_ignored_.readdirSync(dirPath);
4425
- for (const entry of entries) {
4426
- const fullPath = path_browserify.join(dirPath, entry);
4427
- const stat = fs_ignored_.lstatSync(fullPath);
4428
- if (stat.isDirectory()) {
4429
- results.dirs.push(fullPath);
4430
- if (recursive) {
4431
- const results2 = listFiles(fullPath, true);
4432
- results.files.push(...results2.files);
4433
- results.dirs.push(...results2.dirs);
4434
- }
4435
- } else {
4436
- results.files.push(fullPath);
4437
- }
4438
- }
4439
- return results;
4440
- }
4441
-
4442
- /**
4443
- * Lists all directories in a directory (optionally recursive).
4444
- * @param {string} dirPath
4445
- * @param {boolean} [recursive=false]
4446
- * @returns {string[]}
4447
- */
4448
- function listDirs(dirPath, recursive = false) {
4449
- /** @type {string[]} */
4450
- const results = [];
4451
- if (!dirExists(dirPath)) return results;
4452
-
4453
- const entries = fs_ignored_.readdirSync(dirPath);
4454
- for (const entry of entries) {
4455
- const fullPath = path_browserify.join(dirPath, entry);
4456
- const stat = fs_ignored_.lstatSync(fullPath);
4457
- if (stat.isDirectory()) {
4458
- results.push(fullPath);
4459
- if (recursive) {
4460
- results.push(...listDirs(fullPath, true));
4461
- }
4462
- }
4463
- }
4464
- return results;
4465
- }
4466
-
4467
- /*========================*
4468
- * File Info
4469
- *========================*/
4470
-
4471
- /**
4472
- * Returns the size of a file in bytes.
4473
- * @param {string} filePath
4474
- * @returns {number}
4475
- */
4476
- function fileSize(filePath) {
4477
- if (!fileExists(filePath)) return 0;
4478
- const stats = fs_ignored_.statSync(filePath);
4479
- return stats.size;
4480
- }
4481
-
4482
- /**
4483
- * Returns the total size of a directory in bytes.
4484
- * @param {string} dirPath
4485
- * @returns {number}
4486
- */
4487
- function dirSize(dirPath) {
4488
- let total = 0;
4489
- const files = listFiles(dirPath, true).files;
4490
- for (const file of files) {
4491
- total += fileSize(file);
4492
- }
4493
- return total;
4494
- }
4495
-
4496
- /*========================*
4497
- * Backup Utilities
4498
- *========================*/
4499
-
4500
- /**
4501
- * Creates a backup copy of a file with .bak timestamp suffix.
4502
- * @param {string} filePath
4503
- * @param {string} [ext='bak']
4504
- */
4505
- function backupFile(filePath, ext = 'bak') {
4506
- if (!fileExists(filePath)) return;
4507
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
4508
- const backupPath = `${filePath}.${ext}.${timestamp}`;
4509
- ensureCopyFile(filePath, backupPath);
4510
- }
4511
-
4512
- /**
4513
- * Returns the most recent backup file path for a given file.
4514
- * @param {string} filePath
4515
- * @param {string} [ext='bak']
4516
- * @returns {string} Full path to the most recent backup
4517
- */
4518
- function getLatestBackupPath(filePath, ext = 'bak') {
4519
- const dir = path_browserify.dirname(filePath);
4520
- const baseName = path_browserify.basename(filePath);
4521
- const backups = fs_ignored_.readdirSync(dir)
4522
- .filter((name) => name.startsWith(`${baseName}.${ext}.`))
4523
- .sort()
4524
- .reverse();
4525
-
4526
- if (backups.length === 0) throw new Error(`No backups found for ${filePath}`);
4527
-
4528
- return path_browserify.join(dir, backups[0]);
4529
- }
4530
-
4531
- /**
4532
- * Restores the most recent backup of a file.
4533
- * @param {string} filePath
4534
- * @param {string} [ext='bak']
4535
- */
4536
- function restoreLatestBackup(filePath, ext = 'bak') {
4537
- const latestBackup = getLatestBackupPath(filePath, ext);
4538
- ensureCopyFile(latestBackup, filePath);
4539
- }
4540
-
4541
- /**
4542
- * Restores the most recent backup of a file.
4543
- * @param {string} filePath
4544
- * @param {string} [ext='bak']
4545
- * @returns {Promise<void>}
4546
- */
4547
- function restoreLatestBackupAsync(filePath, ext = 'bak') {
4548
- const latestBackup = getLatestBackupPath(filePath, ext);
4549
- return ensureCopyFileAsync(latestBackup, filePath);
4550
- }
4551
-
4552
- /**
4553
- * Creates a backup copy of a file with .bak timestamp suffix.
4554
- * @param {string} filePath
4555
- * @param {string} [ext='bak']
4556
- * @returns {Promise<void>}
4557
- */
4558
- async function backupFileAsync(filePath, ext = 'bak') {
4559
- if (!fileExists(filePath)) return;
4560
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
4561
- const backupPath = `${filePath}.${ext}.${timestamp}`;
4562
- return ensureCopyFileAsync(filePath, backupPath);
4563
- }
4564
-
4565
- /*========================*
4566
- * Rename Utilities
4567
- *========================*/
4568
-
4569
- /**
4570
- * Renames multiple files in a directory using a rename function.
4571
- * @param {string} dirPath - The target directory.
4572
- * @param {(original: string, index: number) => string} renameFn - Function that returns new filename.
4573
- * @param {string[]} [extensions] - Optional: Only rename files with these extensions.
4574
- *
4575
- * @throws {TypeError} If any argument has an invalid type.
4576
- * @throws {Error} If the directory does not exist or contains invalid files.
4577
- */
4578
- function renameFileBatch(dirPath, renameFn, extensions = []) {
4579
- // Validate types
4580
- if (typeof dirPath !== 'string') throw new TypeError('dirPath must be a string');
4581
- if (typeof renameFn !== 'function') throw new TypeError('renameFn must be a function');
4582
- if (!Array.isArray(extensions)) throw new TypeError('extensions must be an array of strings');
4583
- if (!fs_ignored_.existsSync(dirPath) || !fs_ignored_.statSync(dirPath).isDirectory())
4584
- throw new Error(`Directory not found or invalid: ${dirPath}`);
4585
- for (const ext of extensions) {
4586
- if (typeof ext !== 'string' || !ext.startsWith('.'))
4587
- throw new TypeError(`Invalid extension: ${ext}`);
4588
- }
4589
-
4590
- const files = listFiles(dirPath).files;
4591
- let index = 0;
4592
-
4593
- for (const file of files) {
4594
- const ext = path_browserify.extname(file);
4595
- if (extensions.length && !extensions.includes(ext)) continue;
4596
-
4597
- const originalName = path_browserify.basename(file);
4598
- const newName = renameFn(originalName, index++);
4599
- const newPath = path_browserify.join(dirPath, newName);
4600
-
4601
- if (originalName === newName) continue;
4602
-
4603
- fs_ignored_.renameSync(file, newPath);
4604
- }
4605
- }
4606
-
4607
- /**
4608
- * Renames files using regex replacement.
4609
- * @param {string} dirPath
4610
- * @param {RegExp} pattern - Regex to match in the filename.
4611
- * @param {string} replacement - Replacement string.
4612
- * @param {string[]} [extensions]
4613
- */
4614
- function renameFileRegex(dirPath, pattern, replacement, extensions = []) {
4615
- renameFileBatch(
4616
- dirPath,
4617
- (filename) => {
4618
- const ext = path_browserify.extname(filename);
4619
- const name = path_browserify.basename(filename, ext).replace(pattern, replacement);
4620
- return `${name}${ext}`;
4621
- },
4622
- extensions,
4623
- );
4624
- }
4625
-
4626
- /**
4627
- * Adds a prefix or suffix to filenames.
4628
- * @param {string} dirPath
4629
- * @param {{ prefix?: string, suffix?: string }} options
4630
- * @param {string[]} [extensions]
4631
- */
4632
- function renameFileAddPrefixSuffix(dirPath, { prefix = '', suffix = '' }, extensions = []) {
4633
- renameFileBatch(
4634
- dirPath,
4635
- (filename) => {
4636
- const ext = path_browserify.extname(filename);
4637
- const name = path_browserify.basename(filename, ext);
4638
- return `${prefix}${name}${suffix}${ext}`;
4639
- },
4640
- extensions,
4641
- );
4642
- }
4643
-
4644
- /**
4645
- * Normalizes all filenames to lowercase (or uppercase).
4646
- * @param {string} dirPath
4647
- * @param {'lower' | 'upper' | 'title'} mode
4648
- * @param {string[]} [extensions]
4649
- * @param {boolean} [normalizeExt=false] - Whether to apply case change to file extensions too.
4650
- * @throws {Error} If mode is invalid.
4651
- */
4652
- function renameFileNormalizeCase(
4653
- dirPath,
4654
- mode = 'lower',
4655
- extensions = [],
4656
- normalizeExt = false,
4657
- ) {
4658
- if (typeof mode !== 'string' || !['lower', 'upper', 'title'].includes(mode))
4659
- throw new Error(`Invalid mode "${mode}". Must be 'lower', 'upper' or 'title'.`);
4660
- renameFileBatch(
4661
- dirPath,
4662
- (filename) => {
4663
- /**
4664
- * @param {string} text
4665
- * @returns {string}
4666
- */
4667
- const changeToMode = (text) => {
4668
- if (mode === 'lower') return text.toLowerCase();
4669
- else if (mode === 'upper') return text.toUpperCase();
4670
- else if (mode === 'title') return toTitleCase(text);
4671
- else return text;
4672
- };
4673
-
4674
- const rawExt = path_browserify.extname(filename);
4675
- const ext = normalizeExt ? changeToMode(rawExt) : rawExt;
4676
- const name = changeToMode(path_browserify.basename(filename, rawExt));
4677
- return `${name}${ext}`;
4678
- },
4679
- extensions,
4680
- );
4681
- }
4682
-
4683
- /**
4684
- * Pads numbers in filenames (e.g., "img1.jpg" -> "img001.jpg").
4685
- * @param {string} dirPath
4686
- * @param {number} totalDigits
4687
- * @param {string[]} [extensions]
4688
- */
4689
- function renameFilePadNumbers(dirPath, totalDigits = 3, extensions = []) {
4690
- renameFileBatch(
4691
- dirPath,
4692
- (filename) => {
4693
- return filename.replace(/\d+/, (match) => match.padStart(totalDigits, '0'));
4694
- },
4695
- extensions,
4696
- );
4697
- }
4698
-
4699
3444
  ;// ./src/v1/basics/index.mjs
4700
3445
 
4701
3446
 
@@ -4709,7 +3454,6 @@ function renameFilePadNumbers(dirPath, totalDigits = 3, extensions = []) {
4709
3454
 
4710
3455
 
4711
3456
 
4712
-
4713
3457
  })();
4714
3458
 
4715
3459
  window.TinyBasicsEs = __webpack_exports__;