@noya-app/noya-multiplayer-react 0.1.54 → 0.1.56
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 -22
- package/CHANGELOG.md +19 -0
- package/dist/index.bundle.js +24 -13
- package/dist/index.d.mts +18 -9
- package/dist/index.d.ts +18 -9
- package/dist/index.js +363 -154
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +364 -155
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/NoyaStateContext.tsx +4 -0
- package/src/components/UserPointersOverlay.tsx +16 -7
- package/src/hooks.ts +8 -5
- package/src/inspector/StateInspector.tsx +45 -35
package/dist/index.mjs
CHANGED
|
@@ -33,7 +33,46 @@ var require_access = __commonJS({
|
|
|
33
33
|
"../../node_modules/tree-visit/lib/access.js"(exports) {
|
|
34
34
|
"use strict";
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.get = get;
|
|
37
|
+
exports.ancestors = ancestors;
|
|
38
|
+
exports.access = access;
|
|
39
|
+
exports.accessPath = accessPath;
|
|
40
|
+
function get(node, indexPath, options) {
|
|
41
|
+
if (options.includeTraversalContext) {
|
|
42
|
+
const accessed = _getPath(node, indexPath, options);
|
|
43
|
+
return accessed[accessed.length - 1];
|
|
44
|
+
}
|
|
45
|
+
let path = indexPath.slice();
|
|
46
|
+
while (path.length > 0) {
|
|
47
|
+
let index = path.shift();
|
|
48
|
+
const children = options.getChildren(node, path);
|
|
49
|
+
const child = children[index];
|
|
50
|
+
if (!child) {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
node = child;
|
|
54
|
+
}
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
function ancestors(node, indexPath, options) {
|
|
58
|
+
return _getPath(node, indexPath, options).slice(0, -1);
|
|
59
|
+
}
|
|
60
|
+
function _getPath(node, indexPath, options) {
|
|
61
|
+
let path = indexPath.slice();
|
|
62
|
+
let result = [node];
|
|
63
|
+
while (path.length > 0) {
|
|
64
|
+
let index = path.shift();
|
|
65
|
+
const context = options.includeTraversalContext ? makeTraversalContext(result) : void 0;
|
|
66
|
+
const children = options.getChildren(node, path, context);
|
|
67
|
+
const child = children[index];
|
|
68
|
+
if (!child) {
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
node = child;
|
|
72
|
+
result.push(node);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
37
76
|
function access(node, indexPath, options) {
|
|
38
77
|
if (options.includeTraversalContext) {
|
|
39
78
|
const accessed = accessPath(node, indexPath, options);
|
|
@@ -46,23 +85,24 @@ var require_access = __commonJS({
|
|
|
46
85
|
}
|
|
47
86
|
return node;
|
|
48
87
|
}
|
|
49
|
-
exports.access = access;
|
|
50
88
|
function accessPath(node, indexPath, options) {
|
|
51
89
|
let path = indexPath.slice();
|
|
52
90
|
let result = [node];
|
|
53
91
|
while (path.length > 0) {
|
|
54
92
|
let index = path.shift();
|
|
55
|
-
const context = options.includeTraversalContext ?
|
|
56
|
-
getRoot: () => result[0],
|
|
57
|
-
getParent: () => result[result.length - 2],
|
|
58
|
-
getAncestors: () => result.slice(0, -1)
|
|
59
|
-
} : void 0;
|
|
93
|
+
const context = options.includeTraversalContext ? makeTraversalContext(result) : void 0;
|
|
60
94
|
node = options.getChildren(node, path, context)[index];
|
|
61
95
|
result.push(node);
|
|
62
96
|
}
|
|
63
97
|
return result;
|
|
64
98
|
}
|
|
65
|
-
|
|
99
|
+
function makeTraversalContext(array) {
|
|
100
|
+
return {
|
|
101
|
+
getRoot: () => array[0],
|
|
102
|
+
getParent: () => array[array.length - 2],
|
|
103
|
+
getAncestors: () => array.slice(0, -1)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
66
106
|
}
|
|
67
107
|
});
|
|
68
108
|
|
|
@@ -71,7 +111,8 @@ var require_sort = __commonJS({
|
|
|
71
111
|
"../../node_modules/tree-visit/lib/sort.js"(exports) {
|
|
72
112
|
"use strict";
|
|
73
113
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
|
-
exports.
|
|
114
|
+
exports.comparePathsByComponent = comparePathsByComponent;
|
|
115
|
+
exports.sortPaths = sortPaths;
|
|
75
116
|
function comparePathsByComponent(a, b) {
|
|
76
117
|
for (let i = 0; i < Math.min(a.length, b.length); i++) {
|
|
77
118
|
if (a[i] < b[i])
|
|
@@ -81,11 +122,9 @@ var require_sort = __commonJS({
|
|
|
81
122
|
}
|
|
82
123
|
return a.length - b.length;
|
|
83
124
|
}
|
|
84
|
-
exports.comparePathsByComponent = comparePathsByComponent;
|
|
85
125
|
function sortPaths(indexPaths) {
|
|
86
126
|
return [...indexPaths].sort(comparePathsByComponent);
|
|
87
127
|
}
|
|
88
|
-
exports.sortPaths = sortPaths;
|
|
89
128
|
}
|
|
90
129
|
});
|
|
91
130
|
|
|
@@ -94,7 +133,7 @@ var require_ancestors = __commonJS({
|
|
|
94
133
|
"../../node_modules/tree-visit/lib/ancestors.js"(exports) {
|
|
95
134
|
"use strict";
|
|
96
135
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
97
|
-
exports.ancestorPaths =
|
|
136
|
+
exports.ancestorPaths = ancestorPaths;
|
|
98
137
|
var sort_1 = require_sort();
|
|
99
138
|
function ancestorPaths(paths, options) {
|
|
100
139
|
var _a;
|
|
@@ -112,7 +151,6 @@ var require_ancestors = __commonJS({
|
|
|
112
151
|
}
|
|
113
152
|
return Array.from(result.values());
|
|
114
153
|
}
|
|
115
|
-
exports.ancestorPaths = ancestorPaths;
|
|
116
154
|
}
|
|
117
155
|
});
|
|
118
156
|
|
|
@@ -121,7 +159,7 @@ var require_boxDiagram = __commonJS({
|
|
|
121
159
|
"../../node_modules/tree-visit/lib/diagram/boxDiagram.js"(exports) {
|
|
122
160
|
"use strict";
|
|
123
161
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
124
|
-
exports.boxDiagram =
|
|
162
|
+
exports.boxDiagram = boxDiagram;
|
|
125
163
|
var BoxDrawing;
|
|
126
164
|
(function(BoxDrawing2) {
|
|
127
165
|
BoxDrawing2["TopLeft"] = "\u250C";
|
|
@@ -236,7 +274,6 @@ var require_boxDiagram = __commonJS({
|
|
|
236
274
|
function boxDiagram(node, options) {
|
|
237
275
|
return nodeDiagram(node, [], options).contents.join("\n");
|
|
238
276
|
}
|
|
239
|
-
exports.boxDiagram = boxDiagram;
|
|
240
277
|
function centerIndex(width) {
|
|
241
278
|
return Math.floor(width / 2);
|
|
242
279
|
}
|
|
@@ -265,7 +302,9 @@ var require_directoryDiagram = __commonJS({
|
|
|
265
302
|
"../../node_modules/tree-visit/lib/diagram/directoryDiagram.js"(exports) {
|
|
266
303
|
"use strict";
|
|
267
304
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
268
|
-
exports.
|
|
305
|
+
exports.directoryDiagram = directoryDiagram;
|
|
306
|
+
exports.isMultiline = isMultiline;
|
|
307
|
+
exports.prefixBlock = prefixBlock;
|
|
269
308
|
var LinePrefix;
|
|
270
309
|
(function(LinePrefix2) {
|
|
271
310
|
LinePrefix2["Child"] = "\u251C\u2500\u2500 ";
|
|
@@ -312,17 +351,14 @@ var require_directoryDiagram = __commonJS({
|
|
|
312
351
|
const strings = lines.map((line) => prefixBlock(line.label, line.prefix, line.multilinePrefix));
|
|
313
352
|
return strings.join("\n");
|
|
314
353
|
}
|
|
315
|
-
exports.directoryDiagram = directoryDiagram;
|
|
316
354
|
function isMultiline(line) {
|
|
317
355
|
return line.includes("\n");
|
|
318
356
|
}
|
|
319
|
-
exports.isMultiline = isMultiline;
|
|
320
357
|
function prefixBlock(block, prefix, multilinePrefix) {
|
|
321
358
|
if (!isMultiline(block))
|
|
322
359
|
return prefix + block;
|
|
323
360
|
return block.split("\n").map((line, index) => (index === 0 ? prefix : multilinePrefix) + line).join("\n");
|
|
324
361
|
}
|
|
325
|
-
exports.prefixBlock = prefixBlock;
|
|
326
362
|
}
|
|
327
363
|
});
|
|
328
364
|
|
|
@@ -331,7 +367,7 @@ var require_diagram = __commonJS({
|
|
|
331
367
|
"../../node_modules/tree-visit/lib/diagram.js"(exports) {
|
|
332
368
|
"use strict";
|
|
333
369
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
334
|
-
exports.diagram =
|
|
370
|
+
exports.diagram = diagram;
|
|
335
371
|
var boxDiagram_1 = require_boxDiagram();
|
|
336
372
|
var directoryDiagram_1 = require_directoryDiagram();
|
|
337
373
|
function diagram(node, options) {
|
|
@@ -340,7 +376,6 @@ var require_diagram = __commonJS({
|
|
|
340
376
|
}
|
|
341
377
|
return (0, directoryDiagram_1.directoryDiagram)(node, options);
|
|
342
378
|
}
|
|
343
|
-
exports.diagram = diagram;
|
|
344
379
|
}
|
|
345
380
|
});
|
|
346
381
|
|
|
@@ -349,11 +384,16 @@ var require_visit = __commonJS({
|
|
|
349
384
|
"../../node_modules/tree-visit/lib/visit.js"(exports) {
|
|
350
385
|
"use strict";
|
|
351
386
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
352
|
-
exports.
|
|
387
|
+
exports.STOP = exports.SKIP = void 0;
|
|
388
|
+
exports.visit = visit;
|
|
353
389
|
exports.SKIP = "skip";
|
|
354
390
|
exports.STOP = "stop";
|
|
355
391
|
function visit(node, options) {
|
|
356
|
-
const { onEnter, onLeave, getChildren, onDetectCycle, getIdentifier } = options;
|
|
392
|
+
const { onEnter, onLeave, getChildren: originalGetChildren, onDetectCycle, getIdentifier, direction = "forward" } = options;
|
|
393
|
+
const getChildren = (node2, indexPath2, context2) => {
|
|
394
|
+
const children = originalGetChildren(node2, indexPath2, context2);
|
|
395
|
+
return direction === "forward" ? children : children.slice().reverse();
|
|
396
|
+
};
|
|
357
397
|
let indexPath = [];
|
|
358
398
|
let stack = [{ node }];
|
|
359
399
|
const visited = onDetectCycle ? /* @__PURE__ */ new Set() : void 0;
|
|
@@ -398,7 +438,7 @@ var require_visit = __commonJS({
|
|
|
398
438
|
if (wrapper.state !== -1) {
|
|
399
439
|
if (wrapper.state < children.length) {
|
|
400
440
|
let currentIndex = wrapper.state;
|
|
401
|
-
indexPath.push(currentIndex);
|
|
441
|
+
indexPath.push(direction === "forward" ? currentIndex : children.length - currentIndex - 1);
|
|
402
442
|
stack.push({ node: children[currentIndex] });
|
|
403
443
|
wrapper.state = currentIndex + 1;
|
|
404
444
|
continue;
|
|
@@ -415,7 +455,23 @@ var require_visit = __commonJS({
|
|
|
415
455
|
stack.pop();
|
|
416
456
|
}
|
|
417
457
|
}
|
|
418
|
-
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
// ../../node_modules/tree-visit/lib/entries.js
|
|
462
|
+
var require_entries = __commonJS({
|
|
463
|
+
"../../node_modules/tree-visit/lib/entries.js"(exports) {
|
|
464
|
+
"use strict";
|
|
465
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
466
|
+
exports.entries = entries;
|
|
467
|
+
var visit_1 = require_visit();
|
|
468
|
+
function entries(node, options) {
|
|
469
|
+
let result = [];
|
|
470
|
+
(0, visit_1.visit)(node, Object.assign(Object.assign({}, options), { onEnter: (item, indexPath) => {
|
|
471
|
+
result.push([indexPath, item]);
|
|
472
|
+
} }));
|
|
473
|
+
return result;
|
|
474
|
+
}
|
|
419
475
|
}
|
|
420
476
|
});
|
|
421
477
|
|
|
@@ -424,7 +480,10 @@ var require_find = __commonJS({
|
|
|
424
480
|
"../../node_modules/tree-visit/lib/find.js"(exports) {
|
|
425
481
|
"use strict";
|
|
426
482
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
427
|
-
exports.
|
|
483
|
+
exports.find = find;
|
|
484
|
+
exports.findAll = findAll;
|
|
485
|
+
exports.findPath = findPath;
|
|
486
|
+
exports.findAllPaths = findAllPaths;
|
|
428
487
|
var visit_1 = require_visit();
|
|
429
488
|
function find(node, options) {
|
|
430
489
|
let found;
|
|
@@ -436,7 +495,6 @@ var require_find = __commonJS({
|
|
|
436
495
|
} }));
|
|
437
496
|
return found;
|
|
438
497
|
}
|
|
439
|
-
exports.find = find;
|
|
440
498
|
function findAll(node, options) {
|
|
441
499
|
let found = [];
|
|
442
500
|
(0, visit_1.visit)(node, {
|
|
@@ -449,8 +507,7 @@ var require_find = __commonJS({
|
|
|
449
507
|
});
|
|
450
508
|
return found;
|
|
451
509
|
}
|
|
452
|
-
|
|
453
|
-
function findIndexPath(node, options) {
|
|
510
|
+
function findPath(node, options) {
|
|
454
511
|
let found;
|
|
455
512
|
(0, visit_1.visit)(node, {
|
|
456
513
|
onEnter: (child, indexPath) => {
|
|
@@ -463,8 +520,7 @@ var require_find = __commonJS({
|
|
|
463
520
|
});
|
|
464
521
|
return found;
|
|
465
522
|
}
|
|
466
|
-
|
|
467
|
-
function findAllIndexPaths(node, options) {
|
|
523
|
+
function findAllPaths(node, options) {
|
|
468
524
|
let found = [];
|
|
469
525
|
(0, visit_1.visit)(node, {
|
|
470
526
|
onEnter: (child, indexPath) => {
|
|
@@ -476,7 +532,6 @@ var require_find = __commonJS({
|
|
|
476
532
|
});
|
|
477
533
|
return found;
|
|
478
534
|
}
|
|
479
|
-
exports.findAllIndexPaths = findAllIndexPaths;
|
|
480
535
|
}
|
|
481
536
|
});
|
|
482
537
|
|
|
@@ -485,7 +540,7 @@ var require_reduce = __commonJS({
|
|
|
485
540
|
"../../node_modules/tree-visit/lib/reduce.js"(exports) {
|
|
486
541
|
"use strict";
|
|
487
542
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
488
|
-
exports.reduce =
|
|
543
|
+
exports.reduce = reduce;
|
|
489
544
|
var visit_1 = require_visit();
|
|
490
545
|
function reduce(node, options) {
|
|
491
546
|
let result = options.initialResult;
|
|
@@ -494,7 +549,6 @@ var require_reduce = __commonJS({
|
|
|
494
549
|
} }));
|
|
495
550
|
return result;
|
|
496
551
|
}
|
|
497
|
-
exports.reduce = reduce;
|
|
498
552
|
}
|
|
499
553
|
});
|
|
500
554
|
|
|
@@ -503,7 +557,7 @@ var require_flat = __commonJS({
|
|
|
503
557
|
"../../node_modules/tree-visit/lib/flat.js"(exports) {
|
|
504
558
|
"use strict";
|
|
505
559
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
506
|
-
exports.flat =
|
|
560
|
+
exports.flat = flat;
|
|
507
561
|
var reduce_1 = require_reduce();
|
|
508
562
|
function flat(node, options) {
|
|
509
563
|
return (0, reduce_1.reduce)(node, Object.assign(Object.assign({}, options), { initialResult: [], nextResult: (result, child) => {
|
|
@@ -511,24 +565,6 @@ var require_flat = __commonJS({
|
|
|
511
565
|
return result;
|
|
512
566
|
} }));
|
|
513
567
|
}
|
|
514
|
-
exports.flat = flat;
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
|
|
518
|
-
// ../../node_modules/tree-visit/lib/flatMap.js
|
|
519
|
-
var require_flatMap = __commonJS({
|
|
520
|
-
"../../node_modules/tree-visit/lib/flatMap.js"(exports) {
|
|
521
|
-
"use strict";
|
|
522
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
523
|
-
exports.flatMap = void 0;
|
|
524
|
-
var reduce_1 = require_reduce();
|
|
525
|
-
function flatMap(node, options) {
|
|
526
|
-
return (0, reduce_1.reduce)(node, Object.assign(Object.assign({}, options), { initialResult: [], nextResult: (result, child, indexPath) => {
|
|
527
|
-
result.push(...options.transform(child, indexPath));
|
|
528
|
-
return result;
|
|
529
|
-
} }));
|
|
530
|
-
}
|
|
531
|
-
exports.flatMap = flatMap;
|
|
532
568
|
}
|
|
533
569
|
});
|
|
534
570
|
|
|
@@ -537,9 +573,15 @@ var require_map = __commonJS({
|
|
|
537
573
|
"../../node_modules/tree-visit/lib/map.js"(exports) {
|
|
538
574
|
"use strict";
|
|
539
575
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
540
|
-
exports.map =
|
|
576
|
+
exports.map = map3;
|
|
577
|
+
exports.flatMap = flatMap;
|
|
541
578
|
var visit_1 = require_visit();
|
|
542
579
|
function map3(node, options) {
|
|
580
|
+
return flatMap(node, Object.assign(Object.assign({}, options), { transform: (node2, transformedChildren, indexPath) => [
|
|
581
|
+
options.transform(node2, transformedChildren, indexPath)
|
|
582
|
+
] }));
|
|
583
|
+
}
|
|
584
|
+
function flatMap(node, options) {
|
|
543
585
|
const childrenMap = {};
|
|
544
586
|
(0, visit_1.visit)(node, Object.assign(Object.assign({}, options), { onLeave: (child, indexPath) => {
|
|
545
587
|
var _a, _b;
|
|
@@ -548,12 +590,56 @@ var require_map = __commonJS({
|
|
|
548
590
|
const transformed = options.transform(child, (_a = childrenMap[key]) !== null && _a !== void 0 ? _a : [], indexPath);
|
|
549
591
|
const parentKey = keyIndexPath.slice(0, -1).join();
|
|
550
592
|
const parentChildren = (_b = childrenMap[parentKey]) !== null && _b !== void 0 ? _b : [];
|
|
551
|
-
parentChildren.push(transformed);
|
|
593
|
+
parentChildren.push(...transformed);
|
|
552
594
|
childrenMap[parentKey] = parentChildren;
|
|
553
595
|
} }));
|
|
554
596
|
return childrenMap[""][0];
|
|
555
597
|
}
|
|
556
|
-
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// ../../node_modules/tree-visit/lib/transformPath.js
|
|
602
|
+
var require_transformPath = __commonJS({
|
|
603
|
+
"../../node_modules/tree-visit/lib/transformPath.js"(exports) {
|
|
604
|
+
"use strict";
|
|
605
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
606
|
+
exports.transformPath = transformPath;
|
|
607
|
+
var sort_1 = require_sort();
|
|
608
|
+
function commonAncestor(path, otherPath) {
|
|
609
|
+
const length = Math.min(path.length, otherPath.length);
|
|
610
|
+
for (let i = 0; i < length; i++) {
|
|
611
|
+
if (path[i] !== otherPath[i]) {
|
|
612
|
+
return path.slice(0, i);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return path.slice(0, length);
|
|
616
|
+
}
|
|
617
|
+
function transformPath(path, operation, otherPath, count = 1) {
|
|
618
|
+
if (otherPath.length > path.length || (0, sort_1.comparePathsByComponent)(otherPath, path) > 0) {
|
|
619
|
+
return path;
|
|
620
|
+
}
|
|
621
|
+
if (otherPath.length === 0 && operation === "remove") {
|
|
622
|
+
return void 0;
|
|
623
|
+
}
|
|
624
|
+
const common = commonAncestor(path, otherPath);
|
|
625
|
+
const adjustmentIndex = common.length === path.length || common.length === otherPath.length ? common.length - 1 : common.length;
|
|
626
|
+
const pathValue = path[adjustmentIndex];
|
|
627
|
+
const otherPathValue = otherPath[adjustmentIndex];
|
|
628
|
+
if (operation === "insert" && otherPathValue <= pathValue) {
|
|
629
|
+
const newPath = [...path];
|
|
630
|
+
newPath[adjustmentIndex] += count;
|
|
631
|
+
return newPath;
|
|
632
|
+
} else if (operation === "remove") {
|
|
633
|
+
if (otherPathValue === pathValue) {
|
|
634
|
+
return void 0;
|
|
635
|
+
} else if (otherPathValue < pathValue) {
|
|
636
|
+
const newPath = [...path];
|
|
637
|
+
newPath[adjustmentIndex] -= count;
|
|
638
|
+
return newPath;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return path;
|
|
642
|
+
}
|
|
557
643
|
}
|
|
558
644
|
});
|
|
559
645
|
|
|
@@ -562,9 +648,18 @@ var require_operation = __commonJS({
|
|
|
562
648
|
"../../node_modules/tree-visit/lib/operation.js"(exports) {
|
|
563
649
|
"use strict";
|
|
564
650
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
565
|
-
exports.
|
|
651
|
+
exports.insertOperation = insertOperation;
|
|
652
|
+
exports.removeOperation = removeOperation;
|
|
653
|
+
exports.replaceOperation = replaceOperation;
|
|
654
|
+
exports.getInsertionOperations = getInsertionOperations;
|
|
655
|
+
exports.getRemovalOperations = getRemovalOperations;
|
|
656
|
+
exports.getReplaceOperations = getReplaceOperations;
|
|
657
|
+
exports.applyOperations = applyOperations;
|
|
658
|
+
exports.arraySplice = arraySplice;
|
|
659
|
+
exports.transformPathsByOperations = transformPathsByOperations;
|
|
566
660
|
var ancestors_1 = require_ancestors();
|
|
567
661
|
var map_1 = require_map();
|
|
662
|
+
var transformPath_1 = require_transformPath();
|
|
568
663
|
function insertOperation(index, nodes) {
|
|
569
664
|
return {
|
|
570
665
|
type: "insert",
|
|
@@ -572,20 +667,17 @@ var require_operation = __commonJS({
|
|
|
572
667
|
nodes
|
|
573
668
|
};
|
|
574
669
|
}
|
|
575
|
-
exports.insertOperation = insertOperation;
|
|
576
670
|
function removeOperation(indexes) {
|
|
577
671
|
return {
|
|
578
672
|
type: "remove",
|
|
579
673
|
indexes
|
|
580
674
|
};
|
|
581
675
|
}
|
|
582
|
-
exports.removeOperation = removeOperation;
|
|
583
676
|
function replaceOperation() {
|
|
584
677
|
return {
|
|
585
678
|
type: "replace"
|
|
586
679
|
};
|
|
587
680
|
}
|
|
588
|
-
exports.replaceOperation = replaceOperation;
|
|
589
681
|
function splitIndexPath(indexPath) {
|
|
590
682
|
return [indexPath.slice(0, -1), indexPath[indexPath.length - 1]];
|
|
591
683
|
}
|
|
@@ -615,7 +707,6 @@ var require_operation = __commonJS({
|
|
|
615
707
|
}
|
|
616
708
|
return operations;
|
|
617
709
|
}
|
|
618
|
-
exports.getInsertionOperations = getInsertionOperations;
|
|
619
710
|
function getRemovalOperations(indexPaths) {
|
|
620
711
|
var _a, _b;
|
|
621
712
|
const _ancestorIndexPaths = (0, ancestors_1.ancestorPaths)(indexPaths);
|
|
@@ -639,7 +730,6 @@ var require_operation = __commonJS({
|
|
|
639
730
|
}
|
|
640
731
|
return operations;
|
|
641
732
|
}
|
|
642
|
-
exports.getRemovalOperations = getRemovalOperations;
|
|
643
733
|
function getReplaceOperations(indexPath, node) {
|
|
644
734
|
const operations = /* @__PURE__ */ new Map();
|
|
645
735
|
const [parentIndexPath, index] = splitIndexPath(indexPath);
|
|
@@ -655,7 +745,9 @@ var require_operation = __commonJS({
|
|
|
655
745
|
});
|
|
656
746
|
return operations;
|
|
657
747
|
}
|
|
658
|
-
|
|
748
|
+
function adjustInsertIndex(index, removeIndexes) {
|
|
749
|
+
return removeIndexes.reduce((index2, removedIndex) => removedIndex < index2 ? index2 - 1 : index2, index);
|
|
750
|
+
}
|
|
659
751
|
function applyOperations(node, operations, options) {
|
|
660
752
|
return (0, map_1.map)(node, Object.assign(Object.assign({}, options), {
|
|
661
753
|
// Avoid calling `getChildren` for every node in the tree.
|
|
@@ -681,10 +773,10 @@ var require_operation = __commonJS({
|
|
|
681
773
|
return options.create(node2, children.filter((_, index) => !operation.indexes.includes(index)), indexPath);
|
|
682
774
|
case "removeThenInsert":
|
|
683
775
|
const updatedChildren = children.filter((_, index) => !operation.removeIndexes.includes(index));
|
|
684
|
-
const adjustedIndex = operation.
|
|
685
|
-
return options.create(node2,
|
|
776
|
+
const adjustedIndex = adjustInsertIndex(operation.insertIndex, operation.removeIndexes);
|
|
777
|
+
return options.create(node2, arraySplice(updatedChildren, adjustedIndex, 0, ...operation.insertNodes), indexPath);
|
|
686
778
|
case "insert":
|
|
687
|
-
return options.create(node2,
|
|
779
|
+
return options.create(node2, arraySplice(children, operation.index, 0, ...operation.nodes), indexPath);
|
|
688
780
|
case "replace":
|
|
689
781
|
return options.create(node2, children, indexPath);
|
|
690
782
|
default:
|
|
@@ -693,15 +785,53 @@ var require_operation = __commonJS({
|
|
|
693
785
|
}
|
|
694
786
|
}));
|
|
695
787
|
}
|
|
696
|
-
|
|
697
|
-
function splice(array, start, deleteCount, ...items) {
|
|
788
|
+
function arraySplice(array, start, deleteCount, ...items) {
|
|
698
789
|
return [
|
|
699
790
|
...array.slice(0, start),
|
|
700
791
|
...items,
|
|
701
792
|
...array.slice(start + deleteCount)
|
|
702
793
|
];
|
|
703
794
|
}
|
|
704
|
-
|
|
795
|
+
function transformPathsByOperations(paths, operations) {
|
|
796
|
+
let transformedPaths = paths;
|
|
797
|
+
for (const [parentKey, operation] of operations.entries()) {
|
|
798
|
+
const parentPath = parentKey ? parentKey.split(",").map(Number) : [];
|
|
799
|
+
transformedPaths = transformByOperation(transformedPaths, parentPath, operation);
|
|
800
|
+
}
|
|
801
|
+
return transformedPaths;
|
|
802
|
+
}
|
|
803
|
+
function transformByOperation(transformedPaths, parentPath, operation) {
|
|
804
|
+
switch (operation.type) {
|
|
805
|
+
case "insert": {
|
|
806
|
+
const otherPath = parentPath.concat(operation.index);
|
|
807
|
+
return transformedPaths.map((path) => path ? (0, transformPath_1.transformPath)(path, "insert", otherPath, operation.nodes.length) : void 0);
|
|
808
|
+
}
|
|
809
|
+
case "remove": {
|
|
810
|
+
const otherPaths = [...operation.indexes].reverse().map((index) => parentPath.concat(index));
|
|
811
|
+
return transformedPaths.map((path) => {
|
|
812
|
+
for (const otherPath of otherPaths) {
|
|
813
|
+
path = path ? (0, transformPath_1.transformPath)(path, "remove", otherPath) : void 0;
|
|
814
|
+
}
|
|
815
|
+
return path;
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
case "removeThenInsert": {
|
|
819
|
+
const result = transformByOperation(transformedPaths, parentPath, {
|
|
820
|
+
type: "remove",
|
|
821
|
+
indexes: operation.removeIndexes
|
|
822
|
+
});
|
|
823
|
+
const insertIndex = adjustInsertIndex(operation.insertIndex, operation.removeIndexes);
|
|
824
|
+
return transformByOperation(result, parentPath, {
|
|
825
|
+
type: "insert",
|
|
826
|
+
index: insertIndex,
|
|
827
|
+
nodes: operation.insertNodes
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
case "replace": {
|
|
831
|
+
return transformedPaths;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
705
835
|
}
|
|
706
836
|
});
|
|
707
837
|
|
|
@@ -710,17 +840,27 @@ var require_insert = __commonJS({
|
|
|
710
840
|
"../../node_modules/tree-visit/lib/insert.js"(exports) {
|
|
711
841
|
"use strict";
|
|
712
842
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
713
|
-
exports.insert =
|
|
843
|
+
exports.insert = insert;
|
|
844
|
+
exports.insertWithPathTracking = insertWithPathTracking;
|
|
714
845
|
var operation_1 = require_operation();
|
|
715
846
|
function insert(node, options) {
|
|
716
|
-
|
|
847
|
+
return _insertWithPathTracking(node, options).node;
|
|
848
|
+
}
|
|
849
|
+
function insertWithPathTracking(node, options) {
|
|
850
|
+
return _insertWithPathTracking(node, options);
|
|
851
|
+
}
|
|
852
|
+
function _insertWithPathTracking(node, options) {
|
|
853
|
+
const { nodes, path: at, track } = options;
|
|
717
854
|
if (at.length === 0) {
|
|
718
855
|
throw new Error(`Can't insert nodes at the root`);
|
|
719
856
|
}
|
|
720
857
|
const state = (0, operation_1.getInsertionOperations)(at, nodes);
|
|
721
|
-
|
|
858
|
+
const transformedPaths = track ? (0, operation_1.transformPathsByOperations)(track, state) : [];
|
|
859
|
+
return {
|
|
860
|
+
node: (0, operation_1.applyOperations)(node, state, options),
|
|
861
|
+
paths: transformedPaths
|
|
862
|
+
};
|
|
722
863
|
}
|
|
723
|
-
exports.insert = insert;
|
|
724
864
|
}
|
|
725
865
|
});
|
|
726
866
|
|
|
@@ -729,14 +869,14 @@ var require_move = __commonJS({
|
|
|
729
869
|
"../../node_modules/tree-visit/lib/move.js"(exports) {
|
|
730
870
|
"use strict";
|
|
731
871
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
732
|
-
exports.move =
|
|
872
|
+
exports.move = move;
|
|
733
873
|
var access_1 = require_access();
|
|
734
874
|
var ancestors_1 = require_ancestors();
|
|
735
875
|
var operation_1 = require_operation();
|
|
736
876
|
function move(node, options) {
|
|
737
|
-
if (options.
|
|
877
|
+
if (options.paths.length === 0)
|
|
738
878
|
return node;
|
|
739
|
-
for (const indexPath of options.
|
|
879
|
+
for (const indexPath of options.paths) {
|
|
740
880
|
if (indexPath.length === 0) {
|
|
741
881
|
throw new Error(`Can't move the root node`);
|
|
742
882
|
}
|
|
@@ -744,12 +884,11 @@ var require_move = __commonJS({
|
|
|
744
884
|
if (options.to.length === 0) {
|
|
745
885
|
throw new Error(`Can't move nodes to the root`);
|
|
746
886
|
}
|
|
747
|
-
const _ancestorIndexPaths = (0, ancestors_1.ancestorPaths)(options.
|
|
887
|
+
const _ancestorIndexPaths = (0, ancestors_1.ancestorPaths)(options.paths);
|
|
748
888
|
const nodesToInsert = _ancestorIndexPaths.map((indexPath) => (0, access_1.access)(node, indexPath, options));
|
|
749
889
|
const operations = (0, operation_1.getInsertionOperations)(options.to, nodesToInsert, (0, operation_1.getRemovalOperations)(_ancestorIndexPaths));
|
|
750
890
|
return (0, operation_1.applyOperations)(node, operations, options);
|
|
751
891
|
}
|
|
752
|
-
exports.move = move;
|
|
753
892
|
}
|
|
754
893
|
});
|
|
755
894
|
|
|
@@ -758,20 +897,24 @@ var require_remove = __commonJS({
|
|
|
758
897
|
"../../node_modules/tree-visit/lib/remove.js"(exports) {
|
|
759
898
|
"use strict";
|
|
760
899
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
761
|
-
exports.remove =
|
|
900
|
+
exports.remove = remove;
|
|
901
|
+
exports.removeWithPathTracking = removeWithPathTracking;
|
|
762
902
|
var operation_1 = require_operation();
|
|
763
903
|
function remove(node, options) {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}
|
|
771
|
-
const operations = (0, operation_1.getRemovalOperations)(
|
|
772
|
-
|
|
904
|
+
return _removeWithPathTracking(node, options).node;
|
|
905
|
+
}
|
|
906
|
+
function removeWithPathTracking(node, options) {
|
|
907
|
+
return _removeWithPathTracking(node, options);
|
|
908
|
+
}
|
|
909
|
+
function _removeWithPathTracking(node, options) {
|
|
910
|
+
const { paths, track } = options;
|
|
911
|
+
const operations = (0, operation_1.getRemovalOperations)(paths);
|
|
912
|
+
const transformedPaths = track ? (0, operation_1.transformPathsByOperations)(track, operations) : [];
|
|
913
|
+
return {
|
|
914
|
+
node: (0, operation_1.applyOperations)(node, operations, options),
|
|
915
|
+
paths: transformedPaths
|
|
916
|
+
};
|
|
773
917
|
}
|
|
774
|
-
exports.remove = remove;
|
|
775
918
|
}
|
|
776
919
|
});
|
|
777
920
|
|
|
@@ -780,15 +923,53 @@ var require_replace = __commonJS({
|
|
|
780
923
|
"../../node_modules/tree-visit/lib/replace.js"(exports) {
|
|
781
924
|
"use strict";
|
|
782
925
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
783
|
-
exports.replace =
|
|
926
|
+
exports.replace = replace;
|
|
784
927
|
var operation_1 = require_operation();
|
|
785
928
|
function replace(node, options) {
|
|
786
|
-
if (options.
|
|
929
|
+
if (options.path.length === 0)
|
|
787
930
|
return options.node;
|
|
788
|
-
const operations = (0, operation_1.getReplaceOperations)(options.
|
|
931
|
+
const operations = (0, operation_1.getReplaceOperations)(options.path, options.node);
|
|
789
932
|
return (0, operation_1.applyOperations)(node, operations, options);
|
|
790
933
|
}
|
|
791
|
-
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
// ../../node_modules/tree-visit/lib/splice.js
|
|
938
|
+
var require_splice = __commonJS({
|
|
939
|
+
"../../node_modules/tree-visit/lib/splice.js"(exports) {
|
|
940
|
+
"use strict";
|
|
941
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
942
|
+
exports.splice = splice;
|
|
943
|
+
exports.spliceWithPathTracking = spliceWithPathTracking;
|
|
944
|
+
var operation_1 = require_operation();
|
|
945
|
+
function splice(node, options) {
|
|
946
|
+
return _spliceWithPathTracking(node, options).node;
|
|
947
|
+
}
|
|
948
|
+
function spliceWithPathTracking(node, options) {
|
|
949
|
+
return _spliceWithPathTracking(node, options);
|
|
950
|
+
}
|
|
951
|
+
function _spliceWithPathTracking(node, options) {
|
|
952
|
+
const { path, deleteCount = 0, nodes, track } = options;
|
|
953
|
+
if (path.length === 0) {
|
|
954
|
+
throw new Error(`Can't splice at the root`);
|
|
955
|
+
}
|
|
956
|
+
const pathsToRemove = getPathsToRemove(path, deleteCount);
|
|
957
|
+
const operations = (0, operation_1.getInsertionOperations)(path, nodes, (0, operation_1.getRemovalOperations)(pathsToRemove));
|
|
958
|
+
const transformedPaths = track ? (0, operation_1.transformPathsByOperations)(track, operations) : [];
|
|
959
|
+
return {
|
|
960
|
+
node: (0, operation_1.applyOperations)(node, operations, options),
|
|
961
|
+
paths: transformedPaths
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function getPathsToRemove(path, deleteCount) {
|
|
965
|
+
let pathsToRemove = [];
|
|
966
|
+
let parentPath = path.slice(0, -1);
|
|
967
|
+
let index = path[path.length - 1];
|
|
968
|
+
for (let i = 0; i < deleteCount; i++) {
|
|
969
|
+
pathsToRemove.push(parentPath.concat(index + i));
|
|
970
|
+
}
|
|
971
|
+
return pathsToRemove;
|
|
972
|
+
}
|
|
792
973
|
}
|
|
793
974
|
});
|
|
794
975
|
|
|
@@ -797,18 +978,19 @@ var require_defineTree = __commonJS({
|
|
|
797
978
|
"../../node_modules/tree-visit/lib/defineTree.js"(exports) {
|
|
798
979
|
"use strict";
|
|
799
980
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
800
|
-
exports.defineTree =
|
|
981
|
+
exports.defineTree = defineTree2;
|
|
801
982
|
var access_1 = require_access();
|
|
802
983
|
var diagram_1 = require_diagram();
|
|
984
|
+
var entries_1 = require_entries();
|
|
803
985
|
var find_1 = require_find();
|
|
804
986
|
var flat_1 = require_flat();
|
|
805
|
-
var flatMap_1 = require_flatMap();
|
|
806
987
|
var insert_1 = require_insert();
|
|
807
988
|
var map_1 = require_map();
|
|
808
989
|
var move_1 = require_move();
|
|
809
990
|
var reduce_1 = require_reduce();
|
|
810
991
|
var remove_1 = require_remove();
|
|
811
992
|
var replace_1 = require_replace();
|
|
993
|
+
var splice_1 = require_splice();
|
|
812
994
|
var visit_1 = require_visit();
|
|
813
995
|
var Tree = class _Tree {
|
|
814
996
|
constructor(getChildrenOrBaseOptions, appliedOptions) {
|
|
@@ -820,19 +1002,26 @@ var require_defineTree = __commonJS({
|
|
|
820
1002
|
this.withOptions = (newOptions) => new _Tree(this.baseOptions, Object.assign(Object.assign({}, this.appliedOptions), newOptions));
|
|
821
1003
|
this.access = (node, indexPath) => (0, access_1.access)(node, indexPath, this.mergeOptions({}));
|
|
822
1004
|
this.accessPath = (node, indexPath) => (0, access_1.accessPath)(node, indexPath, this.mergeOptions({}));
|
|
1005
|
+
this.get = (node, indexPath) => (0, access_1.get)(node, indexPath, this.mergeOptions({}));
|
|
1006
|
+
this.ancestors = (node, indexPath) => (0, access_1.ancestors)(node, indexPath, this.mergeOptions({}));
|
|
823
1007
|
this.diagram = (node, options) => typeof options === "function" ? (0, diagram_1.diagram)(node, this.mergeOptions({ getLabel: options })) : (0, diagram_1.diagram)(node, this.mergeOptions(options));
|
|
824
1008
|
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)));
|
|
825
1009
|
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)));
|
|
826
|
-
this.
|
|
827
|
-
this.
|
|
1010
|
+
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)));
|
|
1011
|
+
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)));
|
|
1012
|
+
this.entries = (node) => (0, entries_1.entries)(node, this.mergeOptions({}));
|
|
828
1013
|
this.flat = (node) => (0, flat_1.flat)(node, this.mergeOptions({}));
|
|
829
|
-
this.flatMap = (node, transform) => (0, flatMap_1.flatMap)(node, this.mergeOptions({ transform }));
|
|
830
1014
|
this.reduce = (node, nextResult, initialResult) => (0, reduce_1.reduce)(node, this.mergeOptions({ nextResult, initialResult }));
|
|
831
1015
|
this.map = (node, transform) => (0, map_1.map)(node, this.mergeOptions({ transform }));
|
|
1016
|
+
this.flatMap = (node, transform) => (0, map_1.flatMap)(node, this.mergeOptions({ transform }));
|
|
832
1017
|
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)));
|
|
833
1018
|
this.insert = (node, options) => (0, insert_1.insert)(node, this.mergeOptions(options));
|
|
1019
|
+
this.insertWithPathTracking = (node, options) => (0, insert_1.insertWithPathTracking)(node, this.mergeOptions(options));
|
|
834
1020
|
this.remove = (node, options) => (0, remove_1.remove)(node, this.mergeOptions(options));
|
|
1021
|
+
this.removeWithPathTracking = (node, options) => (0, remove_1.removeWithPathTracking)(node, this.mergeOptions(options));
|
|
835
1022
|
this.move = (node, options) => (0, move_1.move)(node, this.mergeOptions(options));
|
|
1023
|
+
this.splice = (node, options) => (0, splice_1.splice)(node, this.mergeOptions(options));
|
|
1024
|
+
this.spliceWithPathTracking = (node, options) => (0, splice_1.spliceWithPathTracking)(node, this.mergeOptions(options));
|
|
836
1025
|
this.replace = (node, options) => (0, replace_1.replace)(node, this.mergeOptions(options));
|
|
837
1026
|
this.baseOptions = typeof getChildrenOrBaseOptions === "function" ? { getChildren: getChildrenOrBaseOptions } : getChildrenOrBaseOptions;
|
|
838
1027
|
this._getChildren = this.baseOptions.getChildren;
|
|
@@ -841,7 +1030,6 @@ var require_defineTree = __commonJS({
|
|
|
841
1030
|
function defineTree2(getChildren) {
|
|
842
1031
|
return new Tree(getChildren, {});
|
|
843
1032
|
}
|
|
844
|
-
exports.defineTree = defineTree2;
|
|
845
1033
|
}
|
|
846
1034
|
});
|
|
847
1035
|
|
|
@@ -878,9 +1066,13 @@ var require_lib = __commonJS({
|
|
|
878
1066
|
"use strict";
|
|
879
1067
|
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
880
1068
|
if (k2 === void 0) k2 = k;
|
|
881
|
-
Object.
|
|
882
|
-
|
|
883
|
-
|
|
1069
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
1070
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
1071
|
+
desc = { enumerable: true, get: function() {
|
|
1072
|
+
return m[k];
|
|
1073
|
+
} };
|
|
1074
|
+
}
|
|
1075
|
+
Object.defineProperty(o, k2, desc);
|
|
884
1076
|
} : function(o, m, k, k2) {
|
|
885
1077
|
if (k2 === void 0) k2 = k;
|
|
886
1078
|
o[k2] = m[k];
|
|
@@ -893,9 +1085,9 @@ var require_lib = __commonJS({
|
|
|
893
1085
|
__exportStar(require_ancestors(), exports);
|
|
894
1086
|
__exportStar(require_defineTree(), exports);
|
|
895
1087
|
__exportStar(require_diagram(), exports);
|
|
1088
|
+
__exportStar(require_entries(), exports);
|
|
896
1089
|
__exportStar(require_find(), exports);
|
|
897
1090
|
__exportStar(require_flat(), exports);
|
|
898
|
-
__exportStar(require_flatMap(), exports);
|
|
899
1091
|
__exportStar(require_indexPath(), exports);
|
|
900
1092
|
__exportStar(require_insert(), exports);
|
|
901
1093
|
__exportStar(require_map(), exports);
|
|
@@ -905,6 +1097,8 @@ var require_lib = __commonJS({
|
|
|
905
1097
|
__exportStar(require_remove(), exports);
|
|
906
1098
|
__exportStar(require_replace(), exports);
|
|
907
1099
|
__exportStar(require_sort(), exports);
|
|
1100
|
+
__exportStar(require_splice(), exports);
|
|
1101
|
+
__exportStar(require_transformPath(), exports);
|
|
908
1102
|
__exportStar(require_visit(), exports);
|
|
909
1103
|
__exportStar(require_withOptions(), exports);
|
|
910
1104
|
}
|
|
@@ -3443,10 +3637,11 @@ var jsonSchema = Type.Recursive(
|
|
|
3443
3637
|
|
|
3444
3638
|
// ../noya-schemas/src/input.ts
|
|
3445
3639
|
function Nullable(type) {
|
|
3446
|
-
return Type.Union([type, Type.Null()]);
|
|
3640
|
+
return Type.Union([type, Type.Null()], { default: null });
|
|
3447
3641
|
}
|
|
3448
3642
|
var inputSchemaBase = {
|
|
3449
3643
|
id: Type.String({ format: "uuid", default: "" }),
|
|
3644
|
+
stableId: Type.String({ format: "uuid", default: "" }),
|
|
3450
3645
|
name: Type.String(),
|
|
3451
3646
|
description: Nullable(Type.String()),
|
|
3452
3647
|
required: Type.Boolean({ default: false })
|
|
@@ -3463,7 +3658,13 @@ var dataInputSchema = Type.Object({
|
|
|
3463
3658
|
});
|
|
3464
3659
|
var secretInputSchema = Type.Object({
|
|
3465
3660
|
...inputSchemaBase,
|
|
3466
|
-
kind: Type.Literal("secret")
|
|
3661
|
+
kind: Type.Literal("secret"),
|
|
3662
|
+
authProvider: Type.Optional(
|
|
3663
|
+
Type.Union([Type.Null(), Type.Literal("github"), Type.Literal("figma")], {
|
|
3664
|
+
default: null
|
|
3665
|
+
})
|
|
3666
|
+
),
|
|
3667
|
+
authScope: Type.Optional(Nullable(Type.String()))
|
|
3467
3668
|
});
|
|
3468
3669
|
var inputSchema = Type.Union(
|
|
3469
3670
|
[fileInputSchema, dataInputSchema, secretInputSchema],
|
|
@@ -3473,6 +3674,7 @@ var inputSchema = Type.Union(
|
|
|
3473
3674
|
);
|
|
3474
3675
|
var outputTransformSchemaBase = {
|
|
3475
3676
|
id: Type.String({ format: "uuid", default: "" }),
|
|
3677
|
+
stableId: Type.String({ format: "uuid", default: "" }),
|
|
3476
3678
|
order: Type.Number()
|
|
3477
3679
|
};
|
|
3478
3680
|
var scriptOutputTransformSchema = Type.Object({
|
|
@@ -3691,7 +3893,7 @@ var SchemaTree = (0, import_tree_visit.defineTree)((schema) => {
|
|
|
3691
3893
|
});
|
|
3692
3894
|
function findAllDefs(schema) {
|
|
3693
3895
|
if (!schema) return [];
|
|
3694
|
-
return SchemaTree.
|
|
3896
|
+
return SchemaTree.flat(schema).flatMap((node) => {
|
|
3695
3897
|
return node.$id ? [node] : [];
|
|
3696
3898
|
});
|
|
3697
3899
|
}
|
|
@@ -3903,6 +4105,45 @@ function ToggleButton({
|
|
|
3903
4105
|
theme,
|
|
3904
4106
|
anchor
|
|
3905
4107
|
}) {
|
|
4108
|
+
const isRightAnchor = anchor === "right";
|
|
4109
|
+
const rightIcon = /* @__PURE__ */ React3.createElement(
|
|
4110
|
+
"svg",
|
|
4111
|
+
{
|
|
4112
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4113
|
+
fill: "none",
|
|
4114
|
+
viewBox: "0 0 24 24",
|
|
4115
|
+
strokeWidth: 1.5,
|
|
4116
|
+
stroke: "currentColor",
|
|
4117
|
+
className: "size-6"
|
|
4118
|
+
},
|
|
4119
|
+
/* @__PURE__ */ React3.createElement(
|
|
4120
|
+
"path",
|
|
4121
|
+
{
|
|
4122
|
+
strokeLinecap: "round",
|
|
4123
|
+
strokeLinejoin: "round",
|
|
4124
|
+
d: "m5.25 4.5 7.5 7.5-7.5 7.5m6-15 7.5 7.5-7.5 7.5"
|
|
4125
|
+
}
|
|
4126
|
+
)
|
|
4127
|
+
);
|
|
4128
|
+
const leftIcon = /* @__PURE__ */ React3.createElement(
|
|
4129
|
+
"svg",
|
|
4130
|
+
{
|
|
4131
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4132
|
+
fill: "none",
|
|
4133
|
+
viewBox: "0 0 24 24",
|
|
4134
|
+
strokeWidth: 1.5,
|
|
4135
|
+
stroke: "currentColor",
|
|
4136
|
+
className: "size-6"
|
|
4137
|
+
},
|
|
4138
|
+
/* @__PURE__ */ React3.createElement(
|
|
4139
|
+
"path",
|
|
4140
|
+
{
|
|
4141
|
+
strokeLinecap: "round",
|
|
4142
|
+
strokeLinejoin: "round",
|
|
4143
|
+
d: "m18.75 4.5-7.5 7.5 7.5 7.5m-6-15L5.25 12l7.5 7.5"
|
|
4144
|
+
}
|
|
4145
|
+
)
|
|
4146
|
+
);
|
|
3906
4147
|
return /* @__PURE__ */ React3.createElement(
|
|
3907
4148
|
"span",
|
|
3908
4149
|
{
|
|
@@ -3924,43 +4165,7 @@ function ToggleButton({
|
|
|
3924
4165
|
setShowInspector(!showInspector);
|
|
3925
4166
|
}
|
|
3926
4167
|
},
|
|
3927
|
-
/* @__PURE__ */ React3.createElement("span", { style: { width: "12px", height: "12px" } },
|
|
3928
|
-
"svg",
|
|
3929
|
-
{
|
|
3930
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3931
|
-
fill: "none",
|
|
3932
|
-
viewBox: "0 0 24 24",
|
|
3933
|
-
strokeWidth: 1.5,
|
|
3934
|
-
stroke: "currentColor",
|
|
3935
|
-
className: "size-6"
|
|
3936
|
-
},
|
|
3937
|
-
/* @__PURE__ */ React3.createElement(
|
|
3938
|
-
"path",
|
|
3939
|
-
{
|
|
3940
|
-
strokeLinecap: "round",
|
|
3941
|
-
strokeLinejoin: "round",
|
|
3942
|
-
d: "m5.25 4.5 7.5 7.5-7.5 7.5m6-15 7.5 7.5-7.5 7.5"
|
|
3943
|
-
}
|
|
3944
|
-
)
|
|
3945
|
-
) : /* @__PURE__ */ React3.createElement(
|
|
3946
|
-
"svg",
|
|
3947
|
-
{
|
|
3948
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3949
|
-
fill: "none",
|
|
3950
|
-
viewBox: "0 0 24 24",
|
|
3951
|
-
strokeWidth: 1.5,
|
|
3952
|
-
stroke: "currentColor",
|
|
3953
|
-
className: "size-6"
|
|
3954
|
-
},
|
|
3955
|
-
/* @__PURE__ */ React3.createElement(
|
|
3956
|
-
"path",
|
|
3957
|
-
{
|
|
3958
|
-
strokeLinecap: "round",
|
|
3959
|
-
strokeLinejoin: "round",
|
|
3960
|
-
d: "m18.75 4.5-7.5 7.5 7.5 7.5m-6-15L5.25 12l7.5 7.5"
|
|
3961
|
-
}
|
|
3962
|
-
)
|
|
3963
|
-
))
|
|
4168
|
+
showInspector ? "Hide Inspector" : /* @__PURE__ */ React3.createElement("span", { style: { width: "12px", height: "12px" } }, isRightAnchor ? rightIcon : leftIcon)
|
|
3964
4169
|
);
|
|
3965
4170
|
}
|
|
3966
4171
|
function DisclosureSection({
|
|
@@ -4538,7 +4743,7 @@ var StateInspector = memoGeneric(function StateInspector2({
|
|
|
4538
4743
|
if (!name) return;
|
|
4539
4744
|
const value = prompt("Enter secret value");
|
|
4540
4745
|
if (!value) return;
|
|
4541
|
-
secretManager.createSecret(name, value);
|
|
4746
|
+
secretManager.createSecret(null, name, value);
|
|
4542
4747
|
}
|
|
4543
4748
|
},
|
|
4544
4749
|
"Create"
|
|
@@ -4548,7 +4753,7 @@ var StateInspector = memoGeneric(function StateInspector2({
|
|
|
4548
4753
|
SmallButton,
|
|
4549
4754
|
{
|
|
4550
4755
|
theme,
|
|
4551
|
-
onClick: () => secretManager.deleteSecret(secret.
|
|
4756
|
+
onClick: () => secretManager.deleteSecret(secret.id)
|
|
4552
4757
|
},
|
|
4553
4758
|
"Delete"
|
|
4554
4759
|
))))
|
|
@@ -4931,10 +5136,9 @@ function useManagedHistory(stateManager) {
|
|
|
4931
5136
|
stateManager.getHistorySnapshot
|
|
4932
5137
|
);
|
|
4933
5138
|
}
|
|
4934
|
-
var defaultStubSync = stubSync();
|
|
4935
5139
|
function useMultiplayerState(initialState, options) {
|
|
4936
5140
|
const {
|
|
4937
|
-
sync =
|
|
5141
|
+
sync = stubSync(),
|
|
4938
5142
|
inspector,
|
|
4939
5143
|
...rest
|
|
4940
5144
|
} = options ?? {};
|
|
@@ -5188,7 +5392,8 @@ function createNoyaContext({
|
|
|
5188
5392
|
schema,
|
|
5189
5393
|
mergeHistoryEntries,
|
|
5190
5394
|
outputTransforms,
|
|
5191
|
-
inputs
|
|
5395
|
+
inputs,
|
|
5396
|
+
safeEval
|
|
5192
5397
|
}) {
|
|
5193
5398
|
const NoyaStateContext = AnyNoyaStateContext;
|
|
5194
5399
|
const EphemeralUserDataManagerContext = AnyEphemeralUserDataManagerContext;
|
|
@@ -5204,6 +5409,7 @@ function createNoyaContext({
|
|
|
5204
5409
|
mergeHistoryEntries,
|
|
5205
5410
|
outputTransforms,
|
|
5206
5411
|
inputs,
|
|
5412
|
+
safeEval,
|
|
5207
5413
|
...options
|
|
5208
5414
|
}
|
|
5209
5415
|
);
|
|
@@ -5354,8 +5560,9 @@ function useCallableAITools() {
|
|
|
5354
5560
|
}
|
|
5355
5561
|
|
|
5356
5562
|
// src/components/UserPointersOverlay.tsx
|
|
5563
|
+
import { Observable as Observable2 } from "@noya-app/observable";
|
|
5357
5564
|
import { memoGeneric as memoGeneric2 } from "@noya-app/react-utils";
|
|
5358
|
-
import React6, { useEffect as useEffect5, useState as useState3 } from "react";
|
|
5565
|
+
import React6, { useEffect as useEffect5, useMemo as useMemo5, useState as useState3 } from "react";
|
|
5359
5566
|
function shouldShow(hideAfter, updatedAt) {
|
|
5360
5567
|
return !!updatedAt && Date.now() - updatedAt < hideAfter;
|
|
5361
5568
|
}
|
|
@@ -5365,12 +5572,14 @@ var UserPointerInternal = memoGeneric2(function UserPointerInternal2({
|
|
|
5365
5572
|
hideAfter = 5e3,
|
|
5366
5573
|
renderUserPointer
|
|
5367
5574
|
}) {
|
|
5368
|
-
const
|
|
5369
|
-
user.id
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5575
|
+
const observable = useMemo5(() => {
|
|
5576
|
+
const metadata$ = ephemeralUserDataManager.metadata$.observePath([user.id]).throttle(50);
|
|
5577
|
+
const data$ = ephemeralUserDataManager.data$.observePath([user.id]).throttle(50);
|
|
5578
|
+
return Observable2.combine([metadata$, data$], ([metadata2, data2]) => {
|
|
5579
|
+
return { metadata: metadata2, data: data2 };
|
|
5580
|
+
});
|
|
5581
|
+
}, [ephemeralUserDataManager, user.id]);
|
|
5582
|
+
const { metadata, data } = useObservable(observable);
|
|
5374
5583
|
const [, setForceUpdate] = useState3(0);
|
|
5375
5584
|
const updatedAt = metadata?.updatedAt ?? 0;
|
|
5376
5585
|
const show = shouldShow(hideAfter, updatedAt);
|