@noya-app/noya-file-explorer 0.0.3 → 0.0.4
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/.turbo/turbo-build.log +11 -11
- package/CHANGELOG.md +12 -0
- package/dist/index.css +618 -573
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +25342 -13464
- package/dist/index.d.ts +25342 -13464
- package/dist/index.js +371 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +371 -115
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/MediaCollection.tsx +96 -16
- package/src/utils/files.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -29,7 +29,46 @@ var require_access = __commonJS({
|
|
|
29
29
|
"../../node_modules/tree-visit/lib/access.js"(exports) {
|
|
30
30
|
"use strict";
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.
|
|
32
|
+
exports.get = get;
|
|
33
|
+
exports.ancestors = ancestors;
|
|
34
|
+
exports.access = access;
|
|
35
|
+
exports.accessPath = accessPath;
|
|
36
|
+
function get(node, indexPath, options) {
|
|
37
|
+
if (options.includeTraversalContext) {
|
|
38
|
+
const accessed = _getPath(node, indexPath, options);
|
|
39
|
+
return accessed[accessed.length - 1];
|
|
40
|
+
}
|
|
41
|
+
let path4 = indexPath.slice();
|
|
42
|
+
while (path4.length > 0) {
|
|
43
|
+
let index = path4.shift();
|
|
44
|
+
const children = options.getChildren(node, path4);
|
|
45
|
+
const child = children[index];
|
|
46
|
+
if (!child) {
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
node = child;
|
|
50
|
+
}
|
|
51
|
+
return node;
|
|
52
|
+
}
|
|
53
|
+
function ancestors(node, indexPath, options) {
|
|
54
|
+
return _getPath(node, indexPath, options).slice(0, -1);
|
|
55
|
+
}
|
|
56
|
+
function _getPath(node, indexPath, options) {
|
|
57
|
+
let path4 = indexPath.slice();
|
|
58
|
+
let result = [node];
|
|
59
|
+
while (path4.length > 0) {
|
|
60
|
+
let index = path4.shift();
|
|
61
|
+
const context = options.includeTraversalContext ? makeTraversalContext(result) : void 0;
|
|
62
|
+
const children = options.getChildren(node, path4, context);
|
|
63
|
+
const child = children[index];
|
|
64
|
+
if (!child) {
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
node = child;
|
|
68
|
+
result.push(node);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
33
72
|
function access(node, indexPath, options) {
|
|
34
73
|
if (options.includeTraversalContext) {
|
|
35
74
|
const accessed = accessPath(node, indexPath, options);
|
|
@@ -42,23 +81,24 @@ var require_access = __commonJS({
|
|
|
42
81
|
}
|
|
43
82
|
return node;
|
|
44
83
|
}
|
|
45
|
-
exports.access = access;
|
|
46
84
|
function accessPath(node, indexPath, options) {
|
|
47
85
|
let path4 = indexPath.slice();
|
|
48
86
|
let result = [node];
|
|
49
87
|
while (path4.length > 0) {
|
|
50
88
|
let index = path4.shift();
|
|
51
|
-
const context = options.includeTraversalContext ?
|
|
52
|
-
getRoot: () => result[0],
|
|
53
|
-
getParent: () => result[result.length - 2],
|
|
54
|
-
getAncestors: () => result.slice(0, -1)
|
|
55
|
-
} : void 0;
|
|
89
|
+
const context = options.includeTraversalContext ? makeTraversalContext(result) : void 0;
|
|
56
90
|
node = options.getChildren(node, path4, context)[index];
|
|
57
91
|
result.push(node);
|
|
58
92
|
}
|
|
59
93
|
return result;
|
|
60
94
|
}
|
|
61
|
-
|
|
95
|
+
function makeTraversalContext(array) {
|
|
96
|
+
return {
|
|
97
|
+
getRoot: () => array[0],
|
|
98
|
+
getParent: () => array[array.length - 2],
|
|
99
|
+
getAncestors: () => array.slice(0, -1)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
62
102
|
}
|
|
63
103
|
});
|
|
64
104
|
|
|
@@ -67,7 +107,8 @@ var require_sort = __commonJS({
|
|
|
67
107
|
"../../node_modules/tree-visit/lib/sort.js"(exports) {
|
|
68
108
|
"use strict";
|
|
69
109
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
-
exports.
|
|
110
|
+
exports.comparePathsByComponent = comparePathsByComponent;
|
|
111
|
+
exports.sortPaths = sortPaths;
|
|
71
112
|
function comparePathsByComponent(a, b) {
|
|
72
113
|
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
73
114
|
if (a[i] < b[i])
|
|
@@ -77,11 +118,9 @@ var require_sort = __commonJS({
|
|
|
77
118
|
}
|
|
78
119
|
return a.length - b.length;
|
|
79
120
|
}
|
|
80
|
-
exports.comparePathsByComponent = comparePathsByComponent;
|
|
81
121
|
function sortPaths(indexPaths) {
|
|
82
122
|
return [...indexPaths].sort(comparePathsByComponent);
|
|
83
123
|
}
|
|
84
|
-
exports.sortPaths = sortPaths;
|
|
85
124
|
}
|
|
86
125
|
});
|
|
87
126
|
|
|
@@ -90,7 +129,7 @@ var require_ancestors = __commonJS({
|
|
|
90
129
|
"../../node_modules/tree-visit/lib/ancestors.js"(exports) {
|
|
91
130
|
"use strict";
|
|
92
131
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
93
|
-
exports.ancestorPaths =
|
|
132
|
+
exports.ancestorPaths = ancestorPaths2;
|
|
94
133
|
var sort_1 = require_sort();
|
|
95
134
|
function ancestorPaths2(paths, options) {
|
|
96
135
|
var _a;
|
|
@@ -108,7 +147,6 @@ var require_ancestors = __commonJS({
|
|
|
108
147
|
}
|
|
109
148
|
return Array.from(result.values());
|
|
110
149
|
}
|
|
111
|
-
exports.ancestorPaths = ancestorPaths2;
|
|
112
150
|
}
|
|
113
151
|
});
|
|
114
152
|
|
|
@@ -117,7 +155,7 @@ var require_boxDiagram = __commonJS({
|
|
|
117
155
|
"../../node_modules/tree-visit/lib/diagram/boxDiagram.js"(exports) {
|
|
118
156
|
"use strict";
|
|
119
157
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
120
|
-
exports.boxDiagram =
|
|
158
|
+
exports.boxDiagram = boxDiagram;
|
|
121
159
|
var BoxDrawing;
|
|
122
160
|
(function(BoxDrawing2) {
|
|
123
161
|
BoxDrawing2["TopLeft"] = "\u250C";
|
|
@@ -232,7 +270,6 @@ var require_boxDiagram = __commonJS({
|
|
|
232
270
|
function boxDiagram(node, options) {
|
|
233
271
|
return nodeDiagram(node, [], options).contents.join("\n");
|
|
234
272
|
}
|
|
235
|
-
exports.boxDiagram = boxDiagram;
|
|
236
273
|
function centerIndex(width) {
|
|
237
274
|
return Math.floor(width / 2);
|
|
238
275
|
}
|
|
@@ -261,7 +298,9 @@ var require_directoryDiagram = __commonJS({
|
|
|
261
298
|
"../../node_modules/tree-visit/lib/diagram/directoryDiagram.js"(exports) {
|
|
262
299
|
"use strict";
|
|
263
300
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
264
|
-
exports.
|
|
301
|
+
exports.directoryDiagram = directoryDiagram;
|
|
302
|
+
exports.isMultiline = isMultiline;
|
|
303
|
+
exports.prefixBlock = prefixBlock;
|
|
265
304
|
var LinePrefix;
|
|
266
305
|
(function(LinePrefix2) {
|
|
267
306
|
LinePrefix2["Child"] = "\u251C\u2500\u2500 ";
|
|
@@ -308,17 +347,14 @@ var require_directoryDiagram = __commonJS({
|
|
|
308
347
|
const strings = lines.map((line) => prefixBlock(line.label, line.prefix, line.multilinePrefix));
|
|
309
348
|
return strings.join("\n");
|
|
310
349
|
}
|
|
311
|
-
exports.directoryDiagram = directoryDiagram;
|
|
312
350
|
function isMultiline(line) {
|
|
313
351
|
return line.includes("\n");
|
|
314
352
|
}
|
|
315
|
-
exports.isMultiline = isMultiline;
|
|
316
353
|
function prefixBlock(block, prefix, multilinePrefix) {
|
|
317
354
|
if (!isMultiline(block))
|
|
318
355
|
return prefix + block;
|
|
319
356
|
return block.split("\n").map((line, index) => (index === 0 ? prefix : multilinePrefix) + line).join("\n");
|
|
320
357
|
}
|
|
321
|
-
exports.prefixBlock = prefixBlock;
|
|
322
358
|
}
|
|
323
359
|
});
|
|
324
360
|
|
|
@@ -327,7 +363,7 @@ var require_diagram = __commonJS({
|
|
|
327
363
|
"../../node_modules/tree-visit/lib/diagram.js"(exports) {
|
|
328
364
|
"use strict";
|
|
329
365
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
330
|
-
exports.diagram =
|
|
366
|
+
exports.diagram = diagram;
|
|
331
367
|
var boxDiagram_1 = require_boxDiagram();
|
|
332
368
|
var directoryDiagram_1 = require_directoryDiagram();
|
|
333
369
|
function diagram(node, options) {
|
|
@@ -336,7 +372,6 @@ var require_diagram = __commonJS({
|
|
|
336
372
|
}
|
|
337
373
|
return (0, directoryDiagram_1.directoryDiagram)(node, options);
|
|
338
374
|
}
|
|
339
|
-
exports.diagram = diagram;
|
|
340
375
|
}
|
|
341
376
|
});
|
|
342
377
|
|
|
@@ -345,11 +380,16 @@ var require_visit = __commonJS({
|
|
|
345
380
|
"../../node_modules/tree-visit/lib/visit.js"(exports) {
|
|
346
381
|
"use strict";
|
|
347
382
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
348
|
-
exports.
|
|
383
|
+
exports.STOP = exports.SKIP = void 0;
|
|
384
|
+
exports.visit = visit;
|
|
349
385
|
exports.SKIP = "skip";
|
|
350
386
|
exports.STOP = "stop";
|
|
351
387
|
function visit(node, options) {
|
|
352
|
-
const { onEnter, onLeave, getChildren, onDetectCycle, getIdentifier } = options;
|
|
388
|
+
const { onEnter, onLeave, getChildren: originalGetChildren, onDetectCycle, getIdentifier, direction = "forward" } = options;
|
|
389
|
+
const getChildren = (node2, indexPath2, context2) => {
|
|
390
|
+
const children = originalGetChildren(node2, indexPath2, context2);
|
|
391
|
+
return direction === "forward" ? children : children.slice().reverse();
|
|
392
|
+
};
|
|
353
393
|
let indexPath = [];
|
|
354
394
|
let stack = [{ node }];
|
|
355
395
|
const visited = onDetectCycle ? /* @__PURE__ */ new Set() : void 0;
|
|
@@ -394,7 +434,7 @@ var require_visit = __commonJS({
|
|
|
394
434
|
if (wrapper.state !== -1) {
|
|
395
435
|
if (wrapper.state < children.length) {
|
|
396
436
|
let currentIndex = wrapper.state;
|
|
397
|
-
indexPath.push(currentIndex);
|
|
437
|
+
indexPath.push(direction === "forward" ? currentIndex : children.length - currentIndex - 1);
|
|
398
438
|
stack.push({ node: children[currentIndex] });
|
|
399
439
|
wrapper.state = currentIndex + 1;
|
|
400
440
|
continue;
|
|
@@ -411,7 +451,23 @@ var require_visit = __commonJS({
|
|
|
411
451
|
stack.pop();
|
|
412
452
|
}
|
|
413
453
|
}
|
|
414
|
-
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// ../../node_modules/tree-visit/lib/entries.js
|
|
458
|
+
var require_entries = __commonJS({
|
|
459
|
+
"../../node_modules/tree-visit/lib/entries.js"(exports) {
|
|
460
|
+
"use strict";
|
|
461
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
462
|
+
exports.entries = entries;
|
|
463
|
+
var visit_1 = require_visit();
|
|
464
|
+
function entries(node, options) {
|
|
465
|
+
let result = [];
|
|
466
|
+
(0, visit_1.visit)(node, Object.assign(Object.assign({}, options), { onEnter: (item, indexPath) => {
|
|
467
|
+
result.push([indexPath, item]);
|
|
468
|
+
} }));
|
|
469
|
+
return result;
|
|
470
|
+
}
|
|
415
471
|
}
|
|
416
472
|
});
|
|
417
473
|
|
|
@@ -420,7 +476,10 @@ var require_find = __commonJS({
|
|
|
420
476
|
"../../node_modules/tree-visit/lib/find.js"(exports) {
|
|
421
477
|
"use strict";
|
|
422
478
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
423
|
-
exports.
|
|
479
|
+
exports.find = find;
|
|
480
|
+
exports.findAll = findAll;
|
|
481
|
+
exports.findPath = findPath;
|
|
482
|
+
exports.findAllPaths = findAllPaths;
|
|
424
483
|
var visit_1 = require_visit();
|
|
425
484
|
function find(node, options) {
|
|
426
485
|
let found;
|
|
@@ -432,7 +491,6 @@ var require_find = __commonJS({
|
|
|
432
491
|
} }));
|
|
433
492
|
return found;
|
|
434
493
|
}
|
|
435
|
-
exports.find = find;
|
|
436
494
|
function findAll(node, options) {
|
|
437
495
|
let found = [];
|
|
438
496
|
(0, visit_1.visit)(node, {
|
|
@@ -445,8 +503,7 @@ var require_find = __commonJS({
|
|
|
445
503
|
});
|
|
446
504
|
return found;
|
|
447
505
|
}
|
|
448
|
-
|
|
449
|
-
function findIndexPath(node, options) {
|
|
506
|
+
function findPath(node, options) {
|
|
450
507
|
let found;
|
|
451
508
|
(0, visit_1.visit)(node, {
|
|
452
509
|
onEnter: (child, indexPath) => {
|
|
@@ -459,8 +516,7 @@ var require_find = __commonJS({
|
|
|
459
516
|
});
|
|
460
517
|
return found;
|
|
461
518
|
}
|
|
462
|
-
|
|
463
|
-
function findAllIndexPaths(node, options) {
|
|
519
|
+
function findAllPaths(node, options) {
|
|
464
520
|
let found = [];
|
|
465
521
|
(0, visit_1.visit)(node, {
|
|
466
522
|
onEnter: (child, indexPath) => {
|
|
@@ -472,7 +528,6 @@ var require_find = __commonJS({
|
|
|
472
528
|
});
|
|
473
529
|
return found;
|
|
474
530
|
}
|
|
475
|
-
exports.findAllIndexPaths = findAllIndexPaths;
|
|
476
531
|
}
|
|
477
532
|
});
|
|
478
533
|
|
|
@@ -481,7 +536,7 @@ var require_reduce = __commonJS({
|
|
|
481
536
|
"../../node_modules/tree-visit/lib/reduce.js"(exports) {
|
|
482
537
|
"use strict";
|
|
483
538
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
484
|
-
exports.reduce =
|
|
539
|
+
exports.reduce = reduce;
|
|
485
540
|
var visit_1 = require_visit();
|
|
486
541
|
function reduce(node, options) {
|
|
487
542
|
let result = options.initialResult;
|
|
@@ -490,7 +545,6 @@ var require_reduce = __commonJS({
|
|
|
490
545
|
} }));
|
|
491
546
|
return result;
|
|
492
547
|
}
|
|
493
|
-
exports.reduce = reduce;
|
|
494
548
|
}
|
|
495
549
|
});
|
|
496
550
|
|
|
@@ -499,7 +553,7 @@ var require_flat = __commonJS({
|
|
|
499
553
|
"../../node_modules/tree-visit/lib/flat.js"(exports) {
|
|
500
554
|
"use strict";
|
|
501
555
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
502
|
-
exports.flat =
|
|
556
|
+
exports.flat = flat;
|
|
503
557
|
var reduce_1 = require_reduce();
|
|
504
558
|
function flat(node, options) {
|
|
505
559
|
return (0, reduce_1.reduce)(node, Object.assign(Object.assign({}, options), { initialResult: [], nextResult: (result, child) => {
|
|
@@ -507,24 +561,6 @@ var require_flat = __commonJS({
|
|
|
507
561
|
return result;
|
|
508
562
|
} }));
|
|
509
563
|
}
|
|
510
|
-
exports.flat = flat;
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
// ../../node_modules/tree-visit/lib/flatMap.js
|
|
515
|
-
var require_flatMap = __commonJS({
|
|
516
|
-
"../../node_modules/tree-visit/lib/flatMap.js"(exports) {
|
|
517
|
-
"use strict";
|
|
518
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
519
|
-
exports.flatMap = void 0;
|
|
520
|
-
var reduce_1 = require_reduce();
|
|
521
|
-
function flatMap(node, options) {
|
|
522
|
-
return (0, reduce_1.reduce)(node, Object.assign(Object.assign({}, options), { initialResult: [], nextResult: (result, child, indexPath) => {
|
|
523
|
-
result.push(...options.transform(child, indexPath));
|
|
524
|
-
return result;
|
|
525
|
-
} }));
|
|
526
|
-
}
|
|
527
|
-
exports.flatMap = flatMap;
|
|
528
564
|
}
|
|
529
565
|
});
|
|
530
566
|
|
|
@@ -533,9 +569,15 @@ var require_map = __commonJS({
|
|
|
533
569
|
"../../node_modules/tree-visit/lib/map.js"(exports) {
|
|
534
570
|
"use strict";
|
|
535
571
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
536
|
-
exports.map =
|
|
572
|
+
exports.map = map;
|
|
573
|
+
exports.flatMap = flatMap;
|
|
537
574
|
var visit_1 = require_visit();
|
|
538
575
|
function map(node, options) {
|
|
576
|
+
return flatMap(node, Object.assign(Object.assign({}, options), { transform: (node2, transformedChildren, indexPath) => [
|
|
577
|
+
options.transform(node2, transformedChildren, indexPath)
|
|
578
|
+
] }));
|
|
579
|
+
}
|
|
580
|
+
function flatMap(node, options) {
|
|
539
581
|
const childrenMap = {};
|
|
540
582
|
(0, visit_1.visit)(node, Object.assign(Object.assign({}, options), { onLeave: (child, indexPath) => {
|
|
541
583
|
var _a, _b;
|
|
@@ -544,12 +586,56 @@ var require_map = __commonJS({
|
|
|
544
586
|
const transformed = options.transform(child, (_a = childrenMap[key]) !== null && _a !== void 0 ? _a : [], indexPath);
|
|
545
587
|
const parentKey = keyIndexPath.slice(0, -1).join();
|
|
546
588
|
const parentChildren = (_b = childrenMap[parentKey]) !== null && _b !== void 0 ? _b : [];
|
|
547
|
-
parentChildren.push(transformed);
|
|
589
|
+
parentChildren.push(...transformed);
|
|
548
590
|
childrenMap[parentKey] = parentChildren;
|
|
549
591
|
} }));
|
|
550
592
|
return childrenMap[""][0];
|
|
551
593
|
}
|
|
552
|
-
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
// ../../node_modules/tree-visit/lib/transformPath.js
|
|
598
|
+
var require_transformPath = __commonJS({
|
|
599
|
+
"../../node_modules/tree-visit/lib/transformPath.js"(exports) {
|
|
600
|
+
"use strict";
|
|
601
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
602
|
+
exports.transformPath = transformPath;
|
|
603
|
+
var sort_1 = require_sort();
|
|
604
|
+
function commonAncestor(path4, otherPath) {
|
|
605
|
+
const length = Math.min(path4.length, otherPath.length);
|
|
606
|
+
for (let i = 0; i < length; i++) {
|
|
607
|
+
if (path4[i] !== otherPath[i]) {
|
|
608
|
+
return path4.slice(0, i);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return path4.slice(0, length);
|
|
612
|
+
}
|
|
613
|
+
function transformPath(path4, operation, otherPath, count = 1) {
|
|
614
|
+
if (otherPath.length > path4.length || (0, sort_1.comparePathsByComponent)(otherPath, path4) > 0) {
|
|
615
|
+
return path4;
|
|
616
|
+
}
|
|
617
|
+
if (otherPath.length === 0 && operation === "remove") {
|
|
618
|
+
return void 0;
|
|
619
|
+
}
|
|
620
|
+
const common = commonAncestor(path4, otherPath);
|
|
621
|
+
const adjustmentIndex = common.length === path4.length || common.length === otherPath.length ? common.length - 1 : common.length;
|
|
622
|
+
const pathValue = path4[adjustmentIndex];
|
|
623
|
+
const otherPathValue = otherPath[adjustmentIndex];
|
|
624
|
+
if (operation === "insert" && otherPathValue <= pathValue) {
|
|
625
|
+
const newPath = [...path4];
|
|
626
|
+
newPath[adjustmentIndex] += count;
|
|
627
|
+
return newPath;
|
|
628
|
+
} else if (operation === "remove") {
|
|
629
|
+
if (otherPathValue === pathValue) {
|
|
630
|
+
return void 0;
|
|
631
|
+
} else if (otherPathValue < pathValue) {
|
|
632
|
+
const newPath = [...path4];
|
|
633
|
+
newPath[adjustmentIndex] -= count;
|
|
634
|
+
return newPath;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
return path4;
|
|
638
|
+
}
|
|
553
639
|
}
|
|
554
640
|
});
|
|
555
641
|
|
|
@@ -558,9 +644,18 @@ var require_operation = __commonJS({
|
|
|
558
644
|
"../../node_modules/tree-visit/lib/operation.js"(exports) {
|
|
559
645
|
"use strict";
|
|
560
646
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
561
|
-
exports.
|
|
647
|
+
exports.insertOperation = insertOperation;
|
|
648
|
+
exports.removeOperation = removeOperation;
|
|
649
|
+
exports.replaceOperation = replaceOperation;
|
|
650
|
+
exports.getInsertionOperations = getInsertionOperations;
|
|
651
|
+
exports.getRemovalOperations = getRemovalOperations;
|
|
652
|
+
exports.getReplaceOperations = getReplaceOperations;
|
|
653
|
+
exports.applyOperations = applyOperations;
|
|
654
|
+
exports.arraySplice = arraySplice;
|
|
655
|
+
exports.transformPathsByOperations = transformPathsByOperations;
|
|
562
656
|
var ancestors_1 = require_ancestors();
|
|
563
657
|
var map_1 = require_map();
|
|
658
|
+
var transformPath_1 = require_transformPath();
|
|
564
659
|
function insertOperation(index, nodes) {
|
|
565
660
|
return {
|
|
566
661
|
type: "insert",
|
|
@@ -568,20 +663,17 @@ var require_operation = __commonJS({
|
|
|
568
663
|
nodes
|
|
569
664
|
};
|
|
570
665
|
}
|
|
571
|
-
exports.insertOperation = insertOperation;
|
|
572
666
|
function removeOperation(indexes) {
|
|
573
667
|
return {
|
|
574
668
|
type: "remove",
|
|
575
669
|
indexes
|
|
576
670
|
};
|
|
577
671
|
}
|
|
578
|
-
exports.removeOperation = removeOperation;
|
|
579
672
|
function replaceOperation() {
|
|
580
673
|
return {
|
|
581
674
|
type: "replace"
|
|
582
675
|
};
|
|
583
676
|
}
|
|
584
|
-
exports.replaceOperation = replaceOperation;
|
|
585
677
|
function splitIndexPath(indexPath) {
|
|
586
678
|
return [indexPath.slice(0, -1), indexPath[indexPath.length - 1]];
|
|
587
679
|
}
|
|
@@ -611,7 +703,6 @@ var require_operation = __commonJS({
|
|
|
611
703
|
}
|
|
612
704
|
return operations;
|
|
613
705
|
}
|
|
614
|
-
exports.getInsertionOperations = getInsertionOperations;
|
|
615
706
|
function getRemovalOperations(indexPaths) {
|
|
616
707
|
var _a, _b;
|
|
617
708
|
const _ancestorIndexPaths = (0, ancestors_1.ancestorPaths)(indexPaths);
|
|
@@ -635,7 +726,6 @@ var require_operation = __commonJS({
|
|
|
635
726
|
}
|
|
636
727
|
return operations;
|
|
637
728
|
}
|
|
638
|
-
exports.getRemovalOperations = getRemovalOperations;
|
|
639
729
|
function getReplaceOperations(indexPath, node) {
|
|
640
730
|
const operations = /* @__PURE__ */ new Map();
|
|
641
731
|
const [parentIndexPath, index] = splitIndexPath(indexPath);
|
|
@@ -651,7 +741,9 @@ var require_operation = __commonJS({
|
|
|
651
741
|
});
|
|
652
742
|
return operations;
|
|
653
743
|
}
|
|
654
|
-
|
|
744
|
+
function adjustInsertIndex(index, removeIndexes) {
|
|
745
|
+
return removeIndexes.reduce((index2, removedIndex) => removedIndex < index2 ? index2 - 1 : index2, index);
|
|
746
|
+
}
|
|
655
747
|
function applyOperations(node, operations, options) {
|
|
656
748
|
return (0, map_1.map)(node, Object.assign(Object.assign({}, options), {
|
|
657
749
|
// Avoid calling `getChildren` for every node in the tree.
|
|
@@ -677,10 +769,10 @@ var require_operation = __commonJS({
|
|
|
677
769
|
return options.create(node2, children.filter((_, index) => !operation.indexes.includes(index)), indexPath);
|
|
678
770
|
case "removeThenInsert":
|
|
679
771
|
const updatedChildren = children.filter((_, index) => !operation.removeIndexes.includes(index));
|
|
680
|
-
const adjustedIndex = operation.
|
|
681
|
-
return options.create(node2,
|
|
772
|
+
const adjustedIndex = adjustInsertIndex(operation.insertIndex, operation.removeIndexes);
|
|
773
|
+
return options.create(node2, arraySplice(updatedChildren, adjustedIndex, 0, ...operation.insertNodes), indexPath);
|
|
682
774
|
case "insert":
|
|
683
|
-
return options.create(node2,
|
|
775
|
+
return options.create(node2, arraySplice(children, operation.index, 0, ...operation.nodes), indexPath);
|
|
684
776
|
case "replace":
|
|
685
777
|
return options.create(node2, children, indexPath);
|
|
686
778
|
default:
|
|
@@ -689,15 +781,53 @@ var require_operation = __commonJS({
|
|
|
689
781
|
}
|
|
690
782
|
}));
|
|
691
783
|
}
|
|
692
|
-
|
|
693
|
-
function splice(array, start, deleteCount, ...items) {
|
|
784
|
+
function arraySplice(array, start, deleteCount, ...items) {
|
|
694
785
|
return [
|
|
695
786
|
...array.slice(0, start),
|
|
696
787
|
...items,
|
|
697
788
|
...array.slice(start + deleteCount)
|
|
698
789
|
];
|
|
699
790
|
}
|
|
700
|
-
|
|
791
|
+
function transformPathsByOperations(paths, operations) {
|
|
792
|
+
let transformedPaths = paths;
|
|
793
|
+
for (const [parentKey, operation] of operations.entries()) {
|
|
794
|
+
const parentPath = parentKey ? parentKey.split(",").map(Number) : [];
|
|
795
|
+
transformedPaths = transformByOperation(transformedPaths, parentPath, operation);
|
|
796
|
+
}
|
|
797
|
+
return transformedPaths;
|
|
798
|
+
}
|
|
799
|
+
function transformByOperation(transformedPaths, parentPath, operation) {
|
|
800
|
+
switch (operation.type) {
|
|
801
|
+
case "insert": {
|
|
802
|
+
const otherPath = parentPath.concat(operation.index);
|
|
803
|
+
return transformedPaths.map((path4) => path4 ? (0, transformPath_1.transformPath)(path4, "insert", otherPath, operation.nodes.length) : void 0);
|
|
804
|
+
}
|
|
805
|
+
case "remove": {
|
|
806
|
+
const otherPaths = [...operation.indexes].reverse().map((index) => parentPath.concat(index));
|
|
807
|
+
return transformedPaths.map((path4) => {
|
|
808
|
+
for (const otherPath of otherPaths) {
|
|
809
|
+
path4 = path4 ? (0, transformPath_1.transformPath)(path4, "remove", otherPath) : void 0;
|
|
810
|
+
}
|
|
811
|
+
return path4;
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
case "removeThenInsert": {
|
|
815
|
+
const result = transformByOperation(transformedPaths, parentPath, {
|
|
816
|
+
type: "remove",
|
|
817
|
+
indexes: operation.removeIndexes
|
|
818
|
+
});
|
|
819
|
+
const insertIndex = adjustInsertIndex(operation.insertIndex, operation.removeIndexes);
|
|
820
|
+
return transformByOperation(result, parentPath, {
|
|
821
|
+
type: "insert",
|
|
822
|
+
index: insertIndex,
|
|
823
|
+
nodes: operation.insertNodes
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
case "replace": {
|
|
827
|
+
return transformedPaths;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
}
|
|
701
831
|
}
|
|
702
832
|
});
|
|
703
833
|
|
|
@@ -706,17 +836,27 @@ var require_insert = __commonJS({
|
|
|
706
836
|
"../../node_modules/tree-visit/lib/insert.js"(exports) {
|
|
707
837
|
"use strict";
|
|
708
838
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
709
|
-
exports.insert =
|
|
839
|
+
exports.insert = insert;
|
|
840
|
+
exports.insertWithPathTracking = insertWithPathTracking;
|
|
710
841
|
var operation_1 = require_operation();
|
|
711
842
|
function insert(node, options) {
|
|
712
|
-
|
|
843
|
+
return _insertWithPathTracking(node, options).node;
|
|
844
|
+
}
|
|
845
|
+
function insertWithPathTracking(node, options) {
|
|
846
|
+
return _insertWithPathTracking(node, options);
|
|
847
|
+
}
|
|
848
|
+
function _insertWithPathTracking(node, options) {
|
|
849
|
+
const { nodes, path: at, track } = options;
|
|
713
850
|
if (at.length === 0) {
|
|
714
851
|
throw new Error(`Can't insert nodes at the root`);
|
|
715
852
|
}
|
|
716
853
|
const state = (0, operation_1.getInsertionOperations)(at, nodes);
|
|
717
|
-
|
|
854
|
+
const transformedPaths = track ? (0, operation_1.transformPathsByOperations)(track, state) : [];
|
|
855
|
+
return {
|
|
856
|
+
node: (0, operation_1.applyOperations)(node, state, options),
|
|
857
|
+
paths: transformedPaths
|
|
858
|
+
};
|
|
718
859
|
}
|
|
719
|
-
exports.insert = insert;
|
|
720
860
|
}
|
|
721
861
|
});
|
|
722
862
|
|
|
@@ -725,14 +865,14 @@ var require_move = __commonJS({
|
|
|
725
865
|
"../../node_modules/tree-visit/lib/move.js"(exports) {
|
|
726
866
|
"use strict";
|
|
727
867
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
728
|
-
exports.move =
|
|
868
|
+
exports.move = move;
|
|
729
869
|
var access_1 = require_access();
|
|
730
870
|
var ancestors_1 = require_ancestors();
|
|
731
871
|
var operation_1 = require_operation();
|
|
732
872
|
function move(node, options) {
|
|
733
|
-
if (options.
|
|
873
|
+
if (options.paths.length === 0)
|
|
734
874
|
return node;
|
|
735
|
-
for (const indexPath of options.
|
|
875
|
+
for (const indexPath of options.paths) {
|
|
736
876
|
if (indexPath.length === 0) {
|
|
737
877
|
throw new Error(`Can't move the root node`);
|
|
738
878
|
}
|
|
@@ -740,12 +880,11 @@ var require_move = __commonJS({
|
|
|
740
880
|
if (options.to.length === 0) {
|
|
741
881
|
throw new Error(`Can't move nodes to the root`);
|
|
742
882
|
}
|
|
743
|
-
const _ancestorIndexPaths = (0, ancestors_1.ancestorPaths)(options.
|
|
883
|
+
const _ancestorIndexPaths = (0, ancestors_1.ancestorPaths)(options.paths);
|
|
744
884
|
const nodesToInsert = _ancestorIndexPaths.map((indexPath) => (0, access_1.access)(node, indexPath, options));
|
|
745
885
|
const operations = (0, operation_1.getInsertionOperations)(options.to, nodesToInsert, (0, operation_1.getRemovalOperations)(_ancestorIndexPaths));
|
|
746
886
|
return (0, operation_1.applyOperations)(node, operations, options);
|
|
747
887
|
}
|
|
748
|
-
exports.move = move;
|
|
749
888
|
}
|
|
750
889
|
});
|
|
751
890
|
|
|
@@ -754,20 +893,24 @@ var require_remove = __commonJS({
|
|
|
754
893
|
"../../node_modules/tree-visit/lib/remove.js"(exports) {
|
|
755
894
|
"use strict";
|
|
756
895
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
757
|
-
exports.remove =
|
|
896
|
+
exports.remove = remove;
|
|
897
|
+
exports.removeWithPathTracking = removeWithPathTracking;
|
|
758
898
|
var operation_1 = require_operation();
|
|
759
899
|
function remove(node, options) {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
const operations = (0, operation_1.getRemovalOperations)(
|
|
768
|
-
|
|
900
|
+
return _removeWithPathTracking(node, options).node;
|
|
901
|
+
}
|
|
902
|
+
function removeWithPathTracking(node, options) {
|
|
903
|
+
return _removeWithPathTracking(node, options);
|
|
904
|
+
}
|
|
905
|
+
function _removeWithPathTracking(node, options) {
|
|
906
|
+
const { paths, track } = options;
|
|
907
|
+
const operations = (0, operation_1.getRemovalOperations)(paths);
|
|
908
|
+
const transformedPaths = track ? (0, operation_1.transformPathsByOperations)(track, operations) : [];
|
|
909
|
+
return {
|
|
910
|
+
node: (0, operation_1.applyOperations)(node, operations, options),
|
|
911
|
+
paths: transformedPaths
|
|
912
|
+
};
|
|
769
913
|
}
|
|
770
|
-
exports.remove = remove;
|
|
771
914
|
}
|
|
772
915
|
});
|
|
773
916
|
|
|
@@ -776,15 +919,53 @@ var require_replace = __commonJS({
|
|
|
776
919
|
"../../node_modules/tree-visit/lib/replace.js"(exports) {
|
|
777
920
|
"use strict";
|
|
778
921
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
779
|
-
exports.replace =
|
|
922
|
+
exports.replace = replace;
|
|
780
923
|
var operation_1 = require_operation();
|
|
781
924
|
function replace(node, options) {
|
|
782
|
-
if (options.
|
|
925
|
+
if (options.path.length === 0)
|
|
783
926
|
return options.node;
|
|
784
|
-
const operations = (0, operation_1.getReplaceOperations)(options.
|
|
927
|
+
const operations = (0, operation_1.getReplaceOperations)(options.path, options.node);
|
|
785
928
|
return (0, operation_1.applyOperations)(node, operations, options);
|
|
786
929
|
}
|
|
787
|
-
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
// ../../node_modules/tree-visit/lib/splice.js
|
|
934
|
+
var require_splice = __commonJS({
|
|
935
|
+
"../../node_modules/tree-visit/lib/splice.js"(exports) {
|
|
936
|
+
"use strict";
|
|
937
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
938
|
+
exports.splice = splice;
|
|
939
|
+
exports.spliceWithPathTracking = spliceWithPathTracking;
|
|
940
|
+
var operation_1 = require_operation();
|
|
941
|
+
function splice(node, options) {
|
|
942
|
+
return _spliceWithPathTracking(node, options).node;
|
|
943
|
+
}
|
|
944
|
+
function spliceWithPathTracking(node, options) {
|
|
945
|
+
return _spliceWithPathTracking(node, options);
|
|
946
|
+
}
|
|
947
|
+
function _spliceWithPathTracking(node, options) {
|
|
948
|
+
const { path: path4, deleteCount = 0, nodes, track } = options;
|
|
949
|
+
if (path4.length === 0) {
|
|
950
|
+
throw new Error(`Can't splice at the root`);
|
|
951
|
+
}
|
|
952
|
+
const pathsToRemove = getPathsToRemove(path4, deleteCount);
|
|
953
|
+
const operations = (0, operation_1.getInsertionOperations)(path4, nodes, (0, operation_1.getRemovalOperations)(pathsToRemove));
|
|
954
|
+
const transformedPaths = track ? (0, operation_1.transformPathsByOperations)(track, operations) : [];
|
|
955
|
+
return {
|
|
956
|
+
node: (0, operation_1.applyOperations)(node, operations, options),
|
|
957
|
+
paths: transformedPaths
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function getPathsToRemove(path4, deleteCount) {
|
|
961
|
+
let pathsToRemove = [];
|
|
962
|
+
let parentPath = path4.slice(0, -1);
|
|
963
|
+
let index = path4[path4.length - 1];
|
|
964
|
+
for (let i = 0; i < deleteCount; i++) {
|
|
965
|
+
pathsToRemove.push(parentPath.concat(index + i));
|
|
966
|
+
}
|
|
967
|
+
return pathsToRemove;
|
|
968
|
+
}
|
|
788
969
|
}
|
|
789
970
|
});
|
|
790
971
|
|
|
@@ -793,18 +974,19 @@ var require_defineTree = __commonJS({
|
|
|
793
974
|
"../../node_modules/tree-visit/lib/defineTree.js"(exports) {
|
|
794
975
|
"use strict";
|
|
795
976
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
796
|
-
exports.defineTree =
|
|
977
|
+
exports.defineTree = defineTree2;
|
|
797
978
|
var access_1 = require_access();
|
|
798
979
|
var diagram_1 = require_diagram();
|
|
980
|
+
var entries_1 = require_entries();
|
|
799
981
|
var find_1 = require_find();
|
|
800
982
|
var flat_1 = require_flat();
|
|
801
|
-
var flatMap_1 = require_flatMap();
|
|
802
983
|
var insert_1 = require_insert();
|
|
803
984
|
var map_1 = require_map();
|
|
804
985
|
var move_1 = require_move();
|
|
805
986
|
var reduce_1 = require_reduce();
|
|
806
987
|
var remove_1 = require_remove();
|
|
807
988
|
var replace_1 = require_replace();
|
|
989
|
+
var splice_1 = require_splice();
|
|
808
990
|
var visit_1 = require_visit();
|
|
809
991
|
var Tree = class _Tree {
|
|
810
992
|
constructor(getChildrenOrBaseOptions, appliedOptions) {
|
|
@@ -816,19 +998,26 @@ var require_defineTree = __commonJS({
|
|
|
816
998
|
this.withOptions = (newOptions) => new _Tree(this.baseOptions, Object.assign(Object.assign({}, this.appliedOptions), newOptions));
|
|
817
999
|
this.access = (node, indexPath) => (0, access_1.access)(node, indexPath, this.mergeOptions({}));
|
|
818
1000
|
this.accessPath = (node, indexPath) => (0, access_1.accessPath)(node, indexPath, this.mergeOptions({}));
|
|
1001
|
+
this.get = (node, indexPath) => (0, access_1.get)(node, indexPath, this.mergeOptions({}));
|
|
1002
|
+
this.ancestors = (node, indexPath) => (0, access_1.ancestors)(node, indexPath, this.mergeOptions({}));
|
|
819
1003
|
this.diagram = (node, options) => typeof options === "function" ? (0, diagram_1.diagram)(node, this.mergeOptions({ getLabel: options })) : (0, diagram_1.diagram)(node, this.mergeOptions(options));
|
|
820
1004
|
this.find = (node, predicateOrOptions) => typeof predicateOrOptions === "function" ? (0, find_1.find)(node, this.mergeOptions({ predicate: predicateOrOptions })) : (0, find_1.find)(node, this.mergeOptions(Object.assign({}, predicateOrOptions)));
|
|
821
1005
|
this.findAll = (node, predicateOrOptions) => typeof predicateOrOptions === "function" ? (0, find_1.findAll)(node, this.mergeOptions({ predicate: predicateOrOptions })) : (0, find_1.findAll)(node, this.mergeOptions(Object.assign({}, predicateOrOptions)));
|
|
822
|
-
this.
|
|
823
|
-
this.
|
|
1006
|
+
this.findPath = (node, predicateOrOptions) => typeof predicateOrOptions === "function" ? (0, find_1.findPath)(node, this.mergeOptions({ predicate: predicateOrOptions })) : (0, find_1.findPath)(node, this.mergeOptions(Object.assign({}, predicateOrOptions)));
|
|
1007
|
+
this.findAllPaths = (node, predicateOrOptions) => typeof predicateOrOptions === "function" ? (0, find_1.findAllPaths)(node, this.mergeOptions({ predicate: predicateOrOptions })) : (0, find_1.findAllPaths)(node, this.mergeOptions(Object.assign({}, predicateOrOptions)));
|
|
1008
|
+
this.entries = (node) => (0, entries_1.entries)(node, this.mergeOptions({}));
|
|
824
1009
|
this.flat = (node) => (0, flat_1.flat)(node, this.mergeOptions({}));
|
|
825
|
-
this.flatMap = (node, transform) => (0, flatMap_1.flatMap)(node, this.mergeOptions({ transform }));
|
|
826
1010
|
this.reduce = (node, nextResult, initialResult) => (0, reduce_1.reduce)(node, this.mergeOptions({ nextResult, initialResult }));
|
|
827
1011
|
this.map = (node, transform) => (0, map_1.map)(node, this.mergeOptions({ transform }));
|
|
1012
|
+
this.flatMap = (node, transform) => (0, map_1.flatMap)(node, this.mergeOptions({ transform }));
|
|
828
1013
|
this.visit = (node, onEnterOrOptions) => typeof onEnterOrOptions === "function" ? (0, visit_1.visit)(node, this.mergeOptions({ onEnter: onEnterOrOptions })) : (0, visit_1.visit)(node, this.mergeOptions(Object.assign({}, onEnterOrOptions)));
|
|
829
1014
|
this.insert = (node, options) => (0, insert_1.insert)(node, this.mergeOptions(options));
|
|
1015
|
+
this.insertWithPathTracking = (node, options) => (0, insert_1.insertWithPathTracking)(node, this.mergeOptions(options));
|
|
830
1016
|
this.remove = (node, options) => (0, remove_1.remove)(node, this.mergeOptions(options));
|
|
1017
|
+
this.removeWithPathTracking = (node, options) => (0, remove_1.removeWithPathTracking)(node, this.mergeOptions(options));
|
|
831
1018
|
this.move = (node, options) => (0, move_1.move)(node, this.mergeOptions(options));
|
|
1019
|
+
this.splice = (node, options) => (0, splice_1.splice)(node, this.mergeOptions(options));
|
|
1020
|
+
this.spliceWithPathTracking = (node, options) => (0, splice_1.spliceWithPathTracking)(node, this.mergeOptions(options));
|
|
832
1021
|
this.replace = (node, options) => (0, replace_1.replace)(node, this.mergeOptions(options));
|
|
833
1022
|
this.baseOptions = typeof getChildrenOrBaseOptions === "function" ? { getChildren: getChildrenOrBaseOptions } : getChildrenOrBaseOptions;
|
|
834
1023
|
this._getChildren = this.baseOptions.getChildren;
|
|
@@ -837,7 +1026,6 @@ var require_defineTree = __commonJS({
|
|
|
837
1026
|
function defineTree2(getChildren) {
|
|
838
1027
|
return new Tree(getChildren, {});
|
|
839
1028
|
}
|
|
840
|
-
exports.defineTree = defineTree2;
|
|
841
1029
|
}
|
|
842
1030
|
});
|
|
843
1031
|
|
|
@@ -874,9 +1062,13 @@ var require_lib = __commonJS({
|
|
|
874
1062
|
"use strict";
|
|
875
1063
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
876
1064
|
if (k2 === void 0) k2 = k;
|
|
877
|
-
Object.
|
|
878
|
-
|
|
879
|
-
|
|
1065
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1066
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1067
|
+
desc = { enumerable: true, get: function() {
|
|
1068
|
+
return m[k];
|
|
1069
|
+
} };
|
|
1070
|
+
}
|
|
1071
|
+
Object.defineProperty(o, k2, desc);
|
|
880
1072
|
} : function(o, m, k, k2) {
|
|
881
1073
|
if (k2 === void 0) k2 = k;
|
|
882
1074
|
o[k2] = m[k];
|
|
@@ -889,9 +1081,9 @@ var require_lib = __commonJS({
|
|
|
889
1081
|
__exportStar(require_ancestors(), exports);
|
|
890
1082
|
__exportStar(require_defineTree(), exports);
|
|
891
1083
|
__exportStar(require_diagram(), exports);
|
|
1084
|
+
__exportStar(require_entries(), exports);
|
|
892
1085
|
__exportStar(require_find(), exports);
|
|
893
1086
|
__exportStar(require_flat(), exports);
|
|
894
|
-
__exportStar(require_flatMap(), exports);
|
|
895
1087
|
__exportStar(require_indexPath(), exports);
|
|
896
1088
|
__exportStar(require_insert(), exports);
|
|
897
1089
|
__exportStar(require_map(), exports);
|
|
@@ -901,6 +1093,8 @@ var require_lib = __commonJS({
|
|
|
901
1093
|
__exportStar(require_remove(), exports);
|
|
902
1094
|
__exportStar(require_replace(), exports);
|
|
903
1095
|
__exportStar(require_sort(), exports);
|
|
1096
|
+
__exportStar(require_splice(), exports);
|
|
1097
|
+
__exportStar(require_transformPath(), exports);
|
|
904
1098
|
__exportStar(require_visit(), exports);
|
|
905
1099
|
__exportStar(require_withOptions(), exports);
|
|
906
1100
|
}
|
|
@@ -1128,7 +1322,7 @@ var moveUpAFolder = ({
|
|
|
1128
1322
|
media,
|
|
1129
1323
|
selectedIds
|
|
1130
1324
|
}) => {
|
|
1131
|
-
const indexPath = tree.
|
|
1325
|
+
const indexPath = tree.findPath(
|
|
1132
1326
|
rootMediaItem,
|
|
1133
1327
|
(item) => item.id === selectedIds[0]
|
|
1134
1328
|
);
|
|
@@ -1215,7 +1409,7 @@ var moveMediaInsideFolder = ({
|
|
|
1215
1409
|
};
|
|
1216
1410
|
var getParentDirectories = (mediaMap, folderId) => {
|
|
1217
1411
|
const tree = createMediaItemTree(mediaMap);
|
|
1218
|
-
const indexPath = tree.
|
|
1412
|
+
const indexPath = tree.findPath(
|
|
1219
1413
|
rootMediaItem,
|
|
1220
1414
|
(item) => item.id === folderId
|
|
1221
1415
|
);
|
|
@@ -1247,19 +1441,67 @@ var renameMediaItemAndDescendantPaths = ({
|
|
|
1247
1441
|
};
|
|
1248
1442
|
|
|
1249
1443
|
// src/MediaCollection.tsx
|
|
1444
|
+
var extensionToContentType = {
|
|
1445
|
+
svg: "image/svg+xml",
|
|
1446
|
+
png: "image/png",
|
|
1447
|
+
jpeg: "image/jpeg"
|
|
1448
|
+
};
|
|
1449
|
+
function encodeFileContentForThumbnail(pathProp, item) {
|
|
1450
|
+
const extension = path3.extname(pathProp).slice(1);
|
|
1451
|
+
const contentType = extensionToContentType[extension];
|
|
1452
|
+
if (contentType) {
|
|
1453
|
+
if (item.encoding === "base64") {
|
|
1454
|
+
return {
|
|
1455
|
+
contentType,
|
|
1456
|
+
url: `data:${contentType};base64,${item.content}`
|
|
1457
|
+
};
|
|
1458
|
+
} else {
|
|
1459
|
+
try {
|
|
1460
|
+
return {
|
|
1461
|
+
contentType,
|
|
1462
|
+
url: `data:${contentType},${encodeURIComponent(item.content)}`
|
|
1463
|
+
};
|
|
1464
|
+
} catch (error) {
|
|
1465
|
+
console.warn("Failed to encode content:", error);
|
|
1466
|
+
return { contentType };
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
return void 0;
|
|
1471
|
+
}
|
|
1250
1472
|
var MediaThumbnailInternal = memoGeneric(
|
|
1251
|
-
({
|
|
1473
|
+
({
|
|
1474
|
+
item,
|
|
1475
|
+
selected,
|
|
1476
|
+
size,
|
|
1477
|
+
path: pathProp
|
|
1478
|
+
}) => {
|
|
1252
1479
|
const asset = useAsset(item.kind === "asset" ? item.assetId : void 0);
|
|
1253
1480
|
const isRoot = item.id === rootMediaItem.id;
|
|
1254
1481
|
const isFolder = item.kind === "folder";
|
|
1482
|
+
const isFile = item.kind === "file";
|
|
1483
|
+
let contentType;
|
|
1484
|
+
let url;
|
|
1485
|
+
if (asset) {
|
|
1486
|
+
contentType = asset.contentType;
|
|
1487
|
+
url = asset.url;
|
|
1488
|
+
} else if (isFile && pathProp) {
|
|
1489
|
+
const encoded = encodeFileContentForThumbnail(pathProp, item);
|
|
1490
|
+
if (encoded) {
|
|
1491
|
+
contentType = encoded.contentType;
|
|
1492
|
+
url = encoded.url;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
const fileName = pathProp ? path3.basename(pathProp) : void 0;
|
|
1255
1496
|
return /* @__PURE__ */ React.createElement(
|
|
1256
1497
|
MediaThumbnail,
|
|
1257
1498
|
{
|
|
1258
|
-
contentType
|
|
1499
|
+
contentType,
|
|
1259
1500
|
iconName: isRoot ? "HomeIcon" : isFolder ? "FolderIcon" : void 0,
|
|
1260
|
-
url
|
|
1501
|
+
url,
|
|
1261
1502
|
selected,
|
|
1262
|
-
size
|
|
1503
|
+
size,
|
|
1504
|
+
fileName
|
|
1263
1505
|
}
|
|
1264
1506
|
);
|
|
1265
1507
|
}
|
|
@@ -1269,7 +1511,8 @@ var MediaCollection = memo(
|
|
|
1269
1511
|
onSelectionChange,
|
|
1270
1512
|
selectedIds: selectedIdsProp,
|
|
1271
1513
|
media,
|
|
1272
|
-
setMedia,
|
|
1514
|
+
setMedia: setMediaProp,
|
|
1515
|
+
readOnly = false,
|
|
1273
1516
|
viewType = "list",
|
|
1274
1517
|
fileKindFilter = "all",
|
|
1275
1518
|
showRootItem = false,
|
|
@@ -1289,6 +1532,12 @@ var MediaCollection = memo(
|
|
|
1289
1532
|
sortable = false,
|
|
1290
1533
|
renderEmptyState
|
|
1291
1534
|
}, ref) {
|
|
1535
|
+
const setMedia = useCallback(
|
|
1536
|
+
(...args) => {
|
|
1537
|
+
setMediaProp?.(...args);
|
|
1538
|
+
},
|
|
1539
|
+
[setMediaProp]
|
|
1540
|
+
);
|
|
1292
1541
|
const tree = useMemo(() => createMediaItemTree(media), [media]);
|
|
1293
1542
|
const [tempItem, setTempItem] = useState(
|
|
1294
1543
|
void 0
|
|
@@ -1701,7 +1950,8 @@ var MediaCollection = memo(
|
|
|
1701
1950
|
onOpenChange,
|
|
1702
1951
|
variant: viewType === "grid" ? "normal" : "bare",
|
|
1703
1952
|
style: {
|
|
1704
|
-
backgroundColor: selected ? cssVars.colors.
|
|
1953
|
+
backgroundColor: selected ? cssVars.colors.selectedListItemBackground : "transparent",
|
|
1954
|
+
color: selected ? cssVars.colors.selectedListItemText : void 0
|
|
1705
1955
|
}
|
|
1706
1956
|
}
|
|
1707
1957
|
);
|
|
@@ -1728,7 +1978,7 @@ var MediaCollection = memo(
|
|
|
1728
1978
|
FileExplorerLayout,
|
|
1729
1979
|
{
|
|
1730
1980
|
title: title ?? rootMediaItemName,
|
|
1731
|
-
right: /* @__PURE__ */ React.createElement(
|
|
1981
|
+
right: !readOnly && /* @__PURE__ */ React.createElement(
|
|
1732
1982
|
FileExplorerUploadButton,
|
|
1733
1983
|
{
|
|
1734
1984
|
showUploadButton,
|
|
@@ -1778,7 +2028,13 @@ var MediaCollection = memo(
|
|
|
1778
2028
|
onRename,
|
|
1779
2029
|
renamable,
|
|
1780
2030
|
selectedIds,
|
|
1781
|
-
renderThumbnail: (props) => /* @__PURE__ */ React.createElement(
|
|
2031
|
+
renderThumbnail: (props) => /* @__PURE__ */ React.createElement(
|
|
2032
|
+
MediaThumbnailInternal,
|
|
2033
|
+
{
|
|
2034
|
+
...props,
|
|
2035
|
+
path: tree.idToPathMap.get(props.item.id)
|
|
2036
|
+
}
|
|
2037
|
+
),
|
|
1782
2038
|
renderAction,
|
|
1783
2039
|
renderDetail: (file, selected) => {
|
|
1784
2040
|
if (file.kind !== "asset") return null;
|
|
@@ -1801,11 +2057,11 @@ var MediaCollection = memo(
|
|
|
1801
2057
|
if (position !== "inside" || targetItem.kind === "asset") {
|
|
1802
2058
|
return false;
|
|
1803
2059
|
}
|
|
1804
|
-
const sourcePath = tree.
|
|
2060
|
+
const sourcePath = tree.findPath(
|
|
1805
2061
|
rootMediaItem,
|
|
1806
2062
|
(item) => item.id === sourceItem.id
|
|
1807
2063
|
);
|
|
1808
|
-
const targetPath = tree.
|
|
2064
|
+
const targetPath = tree.findPath(
|
|
1809
2065
|
rootMediaItem,
|
|
1810
2066
|
(item) => item.id === targetItem.id
|
|
1811
2067
|
);
|