Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

aspen-core

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aspen-core - npm Package Compare versions

Comparing version
0.0.1-alpha.0
to
0.0.1-alpha.1
+0
-14
dist/Branch.js

@@ -6,16 +6,2 @@ "use strict";

class Branch extends Leaf_1.Leaf {
nodes;
/**
* A flag indicating the "intended" expansion status of this branch. If this is `true`, the branch
* is either already expanded OR is about to be expanded. Explained below.
*
* This value represents the "intended" expansion state not the "actual" expansion state. When
* `Tree#expand` is called, the value of this will be immediately become `true`, however because
* the child nodes of the branch in question might need to be loaded, the actual expansion won't
* take effect until the children are loaded. So in that interim time while children are loading,
* the branch isn't truly expanded even if the value is `true`.
*
* Depending on your use case you might want to rely on `Tree#isTrulyExpanded` for a "real-time" status.
*/
expanded;
constructor(id, parent, data, expanded) {

@@ -22,0 +8,0 @@ super(id, parent, data);

+1
-1

@@ -1,1 +0,1 @@

{"version":3,"file":"Branch.js","sourceRoot":"","sources":["../src/Branch.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAG9B,MAAa,MAAkC,SAAQ,WAAe;IACpD,KAAK,CAAqC;IAC1D;;;;;;;;;;;OAWG;IACa,QAAQ,CAAU;IAElC,YAAY,EAAU,EAAE,MAAyB,EAAE,IAAe,EAAE,QAAkB;QACpF,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AApBD,wBAoBC"}
{"version":3,"file":"Branch.js","sourceRoot":"","sources":["../src/Branch.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAG9B,MAAa,MAAkC,SAAQ,WAAe;IAgBpE,YAAY,EAAU,EAAE,MAAyB,EAAE,IAAe,EAAE,QAAkB;QACpF,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AApBD,wBAoBC"}

@@ -5,6 +5,6 @@ "use strict";

class FlatViewMap extends Map {
onDidSetKey;
set(key, value) {
var _a;
super.set(key, value);
this.onDidSetKey?.(key, value);
(_a = this.onDidSetKey) === null || _a === void 0 ? void 0 : _a.call(this, key, value);
return this;

@@ -11,0 +11,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"FlatViewMap.js","sourceRoot":"","sources":["../src/FlatViewMap.ts"],"names":[],"mappings":";;;AAGA,MAAa,WAAY,SAAQ,GAAS;IACjC,WAAW,CAA6B;IAE/C,GAAG,CAAC,GAAM,EAAE,KAAQ;QAClB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AARD,kCAQC"}
{"version":3,"file":"FlatViewMap.js","sourceRoot":"","sources":["../src/FlatViewMap.ts"],"names":[],"mappings":";;;AAGA,MAAa,WAAY,SAAQ,GAAS;IAGxC,GAAG,CAAC,GAAM,EAAE,KAAQ;;QAClB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtB,MAAA,IAAI,CAAC,WAAW,+CAAhB,IAAI,EAAe,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AARD,kCAQC"}

@@ -5,5 +5,2 @@ "use strict";

class Leaf {
id;
parent;
data;
constructor(id, parent, data) {

@@ -10,0 +7,0 @@ this.id = id;

@@ -1,1 +0,1 @@

{"version":3,"file":"Leaf.js","sourceRoot":"","sources":["../src/Leaf.ts"],"names":[],"mappings":";;;AAEA,MAAa,IAAI;IAEG;IACA;IACT;IAHT,YACkB,EAAU,EACV,MAAiB,EAC1B,IAAO;QAFE,OAAE,GAAF,EAAE,CAAQ;QACV,WAAM,GAAN,MAAM,CAAW;QAC1B,SAAI,GAAJ,IAAI,CAAG;IACZ,CAAC;IAEL,IAAI,KAAK;QACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,OAAO,CAAC,CAAC;SACV;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF;AAdD,oBAcC"}
{"version":3,"file":"Leaf.js","sourceRoot":"","sources":["../src/Leaf.ts"],"names":[],"mappings":";;;AAEA,MAAa,IAAI;IACf,YACkB,EAAU,EACV,MAAiB,EAC1B,IAAO;QAFE,OAAE,GAAF,EAAE,CAAQ;QACV,WAAM,GAAN,MAAM,CAAW;QAC1B,SAAI,GAAJ,IAAI,CAAG;IACZ,CAAC;IAEL,IAAI,KAAK;QACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,OAAO,CAAC,CAAC;SACV;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF;AAdD,oBAcC"}
+118
-108
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -9,14 +18,97 @@ exports.Tree = void 0;

class Tree {
source;
rootBranch;
flatViewMap = new FlatViewMap_1.FlatViewMap();
treeNodeMap = new Map();
pendingLoadChildrenRequests = new Map();
onVisibleNodesChangeCallback = () => void 0;
static isLeaf = (treeNode) => treeNode.constructor === Leaf_1.Leaf;
static isBranch = (treeNode) => treeNode.constructor === Branch_1.Branch;
constructor(source, rootBranchData) {
this.source = source;
this.flatViewMap = new FlatViewMap_1.FlatViewMap();
this.treeNodeMap = new Map();
this.pendingLoadChildrenRequests = new Map();
this.onVisibleNodesChangeCallback = () => void 0;
this.getTreeNodeById = (id) => this.treeNodeMap.get(id);
/**
* Ensures that the children of any given branch have been loaded and ready to be worked with.
*
* Call this method without any arguments to check if the root branch is loaded.
*
* ⚠ "Loaded" doesn't mean expanded, it just means the contents are "ready". Except when no arguments are given, the
* branch being checked is root, and root is always expanded.
*/
this.ensureLoaded = (branch = this.rootBranch) => __awaiter(this, void 0, void 0, function* () {
if (!branch.nodes) {
return this.loadNodes(branch);
}
});
this.expand = (branch, ensureVisible = false, recursive = false) => __awaiter(this, void 0, void 0, function* () {
const isVisibilitySkipable = !ensureVisible || (ensureVisible && this.isVisible(branch));
if (!recursive && this.isTrulyExpanded(branch) && isVisibilitySkipable) {
return;
}
branch.expanded = true;
yield this.ensureLoaded(branch);
// check again as collapse might have been called in the meantime
if (branch.expanded) {
this.connectBranchToClosestFlatView(branch, ensureVisible);
if (recursive) {
yield Promise.all(branch.nodes.map(node => Tree.isBranch(node)
? this.expand(node, ensureVisible, recursive)
: null));
}
}
});
this.collapse = (branch) => {
if (branch.expanded) {
this.disconnectBranchFromClosestFlatView(branch);
}
};
this.amend = (branch, amendFn) => {
let modified = false;
let draftNodes = branch.nodes.slice();
const factory = this.getTreeNodeFactory(branch);
const insertNode = (node, insertionIndex) => {
modified = true;
draftNodes.splice(insertionIndex !== null && insertionIndex !== void 0 ? insertionIndex : Infinity, 0, node);
return node;
};
amendFn({
draftNodes,
insertBranch: (data, insertionIndex) => insertNode(factory.createBranch(data), insertionIndex),
insertLeaf: (data, insertionIndex) => insertNode(factory.createLeaf(data), insertionIndex),
sort: (comparatorFn) => {
modified = true;
draftNodes.sort(comparatorFn);
},
revertChanges: () => {
modified = false;
draftNodes = branch.nodes.slice();
}
});
if (modified) {
this.setNodes(branch, draftNodes);
}
};
this.removeNode = (node) => {
const teardown = (childNode) => {
var _a;
// TODO: dispatch remove event
this.removeNodeFromFlatView(childNode);
this.treeNodeMap.delete(childNode.id);
if (Tree.isBranch(childNode)) {
(_a = childNode.nodes) === null || _a === void 0 ? void 0 : _a.forEach(teardown);
}
};
teardown(node);
const { parent } = node;
parent.nodes = parent.nodes.filter(n => n !== node);
};
this.moveNode = (node, to) => {
};
/**
* A more accurate and real-time representation of whether a branch is expanded.
*
* `Branch#expanded` represents the "intended" expansion state of the branch in question not the actual
* status, because the child nodes might still need to be loaded before the change can be seen in the tree.
*/
this.isTrulyExpanded = (branch) => branch.nodes && branch.expanded && !this.flatViewMap.has(branch.id);
this.isVisible = (node) => !this.findClosestDisconnectedParent(node);
this.nextId = ((genesis = 0) => (() => genesis++))();
this.rootBranch = new Branch_1.Branch(this.nextId(), null, rootBranchData);
this.flatViewMap.onDidSetKey = (key) => key === this.rootBranch.id && this.onVisibleNodesChangeCallback?.();
this.flatViewMap.onDidSetKey = (key) => { var _a; return key === this.rootBranch.id && ((_a = this.onVisibleNodesChangeCallback) === null || _a === void 0 ? void 0 : _a.call(this)); };
this.expand(this.rootBranch);

@@ -33,103 +125,19 @@ }

}
getTreeNodeById = (id) => this.treeNodeMap.get(id);
/**
* Ensures that the children of any given branch have been loaded and ready to be worked with.
*
* Call this method without any arguments to check if the root branch is loaded.
*
* ⚠ "Loaded" doesn't mean expanded, it just means the contents are "ready". Except when no arguments are given, the
* branch being checked is root, and root is always expanded.
*/
ensureLoaded = async (branch = this.rootBranch) => {
if (!branch.nodes) {
return this.loadNodes(branch);
}
};
expand = async (branch, ensureVisible = false, recursive = false) => {
const isVisibilitySkipable = !ensureVisible || (ensureVisible && this.isVisible(branch));
if (!recursive && this.isTrulyExpanded(branch) && isVisibilitySkipable) {
return;
}
branch.expanded = true;
await this.ensureLoaded(branch);
// check again as collapse might have been called in the meantime
if (branch.expanded) {
this.connectBranchToClosestFlatView(branch, ensureVisible);
if (recursive) {
await Promise.all(branch.nodes.map(node => Tree.isBranch(node)
? this.expand(node, ensureVisible, recursive)
: null));
loadNodes(parent) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.pendingLoadChildrenRequests.has(parent)) {
const promise = (() => __awaiter(this, void 0, void 0, function* () {
const nodes = yield this.source.getNodes(parent === this.rootBranch ? null : parent, this.getTreeNodeFactory(parent));
this.setNodes(parent, nodes);
for (const node of nodes) {
if (Tree.isBranch(node) && node.expanded) {
this.expand(node);
}
}
}))();
promise.finally(() => this.pendingLoadChildrenRequests.delete(parent));
this.pendingLoadChildrenRequests.set(parent, promise);
}
}
};
collapse = (branch) => {
if (branch.expanded) {
this.disconnectBranchFromClosestFlatView(branch);
}
};
amend = (branch, amendFn) => {
let modified = false;
let draftNodes = branch.nodes.slice();
const factory = this.getTreeNodeFactory(branch);
const insertNode = (node, insertionIndex) => {
modified = true;
draftNodes.splice(insertionIndex ?? Infinity, 0, node);
return node;
};
amendFn({
draftNodes,
insertBranch: (data, insertionIndex) => insertNode(factory.createBranch(data), insertionIndex),
insertLeaf: (data, insertionIndex) => insertNode(factory.createLeaf(data), insertionIndex),
sort: (comparatorFn) => {
modified = true;
draftNodes.sort(comparatorFn);
},
revertChanges: () => {
modified = false;
draftNodes = branch.nodes.slice();
}
return this.pendingLoadChildrenRequests.get(parent);
});
if (modified) {
this.setNodes(branch, draftNodes);
}
};
removeNode = (node) => {
const teardown = (childNode) => {
// TODO: dispatch remove event
this.removeNodeFromFlatView(childNode);
this.treeNodeMap.delete(childNode.id);
if (Tree.isBranch(childNode)) {
childNode.nodes?.forEach(teardown);
}
};
teardown(node);
const { parent } = node;
parent.nodes = parent.nodes.filter(n => n !== node);
};
moveNode = (node, to) => {
};
/**
* A more accurate and real-time representation of whether a branch is expanded.
*
* `Branch#expanded` represents the "intended" expansion state of the branch in question not the actual
* status, because the child nodes might still need to be loaded before the change can be seen in the tree.
*/
isTrulyExpanded = (branch) => branch.nodes && branch.expanded && !this.flatViewMap.has(branch.id);
isVisible = (node) => !this.findClosestDisconnectedParent(node);
nextId = ((genesis = 0) => (() => genesis++))();
async loadNodes(parent) {
if (!this.pendingLoadChildrenRequests.has(parent)) {
const promise = (async () => {
const nodes = await this.source.getNodes(parent === this.rootBranch ? null : parent, this.getTreeNodeFactory(parent));
this.setNodes(parent, nodes);
for (const node of nodes) {
if (Tree.isBranch(node) && node.expanded) {
this.expand(node);
}
}
})();
promise.finally(() => this.pendingLoadChildrenRequests.delete(parent));
this.pendingLoadChildrenRequests.set(parent, promise);
}
return this.pendingLoadChildrenRequests.get(parent);
}

@@ -245,2 +253,4 @@ setNodes(branch, nodes) {

exports.Tree = Tree;
Tree.isLeaf = (treeNode) => treeNode.constructor === Leaf_1.Leaf;
Tree.isBranch = (treeNode) => treeNode.constructor === Branch_1.Branch;
//# sourceMappingURL=Tree.js.map

@@ -1,1 +0,1 @@

{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../src/Tree.ts"],"names":[],"mappings":";;;AACA,qCAAkC;AAClC,iCAA8B;AAC9B,mCAAiD;AAEjD,+CAA4C;AAG5C,MAAa,IAAI;IAUK;IATZ,UAAU,CAAoB;IAC9B,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;IAChC,WAAW,GAAG,IAAI,GAAG,EAA+B,CAAC;IACrD,2BAA2B,GAAG,IAAI,GAAG,EAAyB,CAAC;IAC/D,4BAA4B,GAAe,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IAEzD,MAAM,CAAC,MAAM,GAAG,CAAC,QAAkB,EAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,KAAK,WAAI,CAAC;IAC/E,MAAM,CAAC,QAAQ,GAAG,CAAC,QAAkB,EAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,KAAK,eAAM,CAAC;IAE1F,YAAoB,MAA6B,EAAE,cAA0B;QAAzD,WAAM,GAAN,MAAM,CAAuB;QAC/C,IAAI,CAAC,UAAU,GAAG,IAAI,eA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AC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAElE,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAElD,OAAO;YACL,KAAK,EAAE,UAAU;YACjB,GAAG,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC;SACtD,CAAC;IACJ,CAAC;;AAtSH,oBAuSC;AAhSe,WAAM,GAAG,CAAC,QAAkB,EAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,KAAK,WAAI,CAAC;AACxE,aAAQ,GAAG,CAAC,QAAkB,EAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,KAAK,eAAM,CAAC"}
{
"name": "aspen-core",
"description": "The most performant virtualized tree driver",
"version": "0.0.1-alpha.0",
"version": "0.0.1-alpha.1",
"keywords": [

@@ -28,3 +28,3 @@ "TODO"

},
"gitHead": "9a0c6b4a24edb08ac32d08bab4f5deaf4da97357"
"gitHead": "8b5ea2d55b4fd68983e27d5988cb90d5269c991d"
}

@@ -6,3 +6,6 @@ {

"declarationDir": "dist/typings"
}
},
"include": [
"src/*"
]
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const dom_1 = require("@testing-library/dom");
const src_1 = require("../src");
const treeData_1 = require("./treeData");
afterEach(() => jest.clearAllMocks());
const assertTree = (tree, items) => () => {
const levels = tree.visibleTreeNodes.reduce((acc, nodeId) => {
const treeNode = tree.getTreeNodeById(nodeId);
return [...acc, '-'.repeat(treeNode.depth) + treeNode.data.name];
}, []);
const expected = items.join('\n');
const actual = levels.join('\n');
if (expected !== actual) {
throw new Error(`\nTree expected:\n${expected}\n\nGot:\n${actual}`);
}
};
describe('Tree', () => {
it('starts off with only first level nodes expanded and represented by a typed array', () => __awaiter(void 0, void 0, void 0, function* () {
jest.spyOn(treeData_1.treeSource, 'getNodes');
const tree = new src_1.Tree(treeData_1.treeSource);
// here `ensureLoaded` is NOT being called to prove a point that root will be booted up without any manual intervention
yield (0, dom_1.waitFor)(() => expect(Array.from(tree.visibleTreeNodes)).toEqual(expect.arrayContaining([1, 2, 3])));
expect(tree.visibleTreeNodes.constructor).toBe(Uint32Array);
// the numbers in the array map to tree nodes
expect(tree.getTreeNodeById(1).data.name).toBe('archives');
expect(tree.getTreeNodeById(2).data.name).toBe('files');
expect(tree.getTreeNodeById(3).data.name).toBe('reports');
// here's how it'd look
expect(assertTree(tree, [
'-archives',
'-files',
'-reports'
])).not.toThrow();
// getNodes should be called dynamically as the tree is expanded
expect(treeData_1.treeSource.getNodes).toHaveBeenCalledTimes(1);
}));
it('expands the branches and updates the flat projection on-the-fly', () => __awaiter(void 0, void 0, void 0, function* () {
jest.spyOn(treeData_1.treeSource, 'getNodes');
const tree = new src_1.Tree(treeData_1.treeSource);
yield tree.ensureLoaded();
const archivesBranch = yield (0, treeData_1.findTreeNodeByARN)('arn:aws:s3:::archives', tree);
yield tree.expand(archivesBranch);
expect(assertTree(tree, [
'-archives',
'--users',
'--logs',
'-files',
'-reports'
])).not.toThrow();
expect(treeData_1.treeSource.getNodes).toHaveBeenCalledTimes(2);
const logsBranch = yield (0, treeData_1.findTreeNodeByARN)('arn:aws:s3:::archives/logs', tree);
yield tree.expand(logsBranch);
expect(assertTree(tree, [
'-archives',
'--users',
'--logs',
'---pgp.bat',
'---applications',
'-files',
'-reports'
])).not.toThrow();
expect(treeData_1.treeSource.getNodes).toHaveBeenCalledTimes(3);
}));
it('expands all parents when a branch is expanded with ensureVisible set to true', () => __awaiter(void 0, void 0, void 0, function* () {
jest.spyOn(treeData_1.treeSource, 'getNodes');
const tree = new src_1.Tree(treeData_1.treeSource);
yield tree.ensureLoaded();
// start-off with just the first level visible
expect(assertTree(tree, [
'-archives',
'-files',
'-reports'
])).not.toThrow();
const subjectBranch = yield (0, treeData_1.findTreeNodeByARN)('arn:aws:s3:::archives/logs/applications/approved', tree);
yield tree.expand(subjectBranch);
// even after calling expand, the visible tree nodes should be unchanged as parents are still collapsed
expect(assertTree(tree, [
'-archives',
'-files',
'-reports'
])).not.toThrow();
expect(treeData_1.treeSource.getNodes).toHaveBeenCalledTimes(5);
// call it again, except this time ask it to reflect at the top
yield tree.expand(subjectBranch, true);
expect(assertTree(tree, [
'-archives',
'--users',
'--logs',
'---pgp.bat',
'---applications',
'----approved',
'-----passport.pdf',
'-----visa.pdf',
'-files',
'-reports'
])).not.toThrow();
// the children had already been loaded earlier, so no new calls to getNodes
expect(treeData_1.treeSource.getNodes).toHaveBeenCalledTimes(5);
}));
it('disconnects the entire branch from flattened projection when the said branch is collapsed', () => __awaiter(void 0, void 0, void 0, function* () {
jest.spyOn(treeData_1.treeSource, 'getNodes');
const tree = new src_1.Tree(treeData_1.treeSource);
yield tree.ensureLoaded();
const subjectBranch = yield (0, treeData_1.findTreeNodeByARN)('arn:aws:s3:::archives/logs/applications/approved', tree);
// expand one of the very deep branches
yield tree.expand(subjectBranch, true);
expect(assertTree(tree, [
'-archives',
'--users',
'--logs',
'---pgp.bat',
'---applications',
'----approved',
'-----passport.pdf',
'-----visa.pdf',
'-files',
'-reports'
])).not.toThrow();
// now collapse one of its parents
const parentBranch = yield (0, treeData_1.findTreeNodeByARN)('arn:aws:s3:::archives/logs', tree);
tree.collapse(parentBranch);
// the entire branch should be disconnected from the visible tree
expect(assertTree(tree, [
'-archives',
'--users',
'--logs',
'-files',
'-reports'
])).not.toThrow();
// expanding it again should restore the state as it was before collapsing
yield tree.expand(parentBranch);
expect(assertTree(tree, [
'-archives',
'--users',
'--logs',
'---pgp.bat',
'---applications',
'----approved',
'-----passport.pdf',
'-----visa.pdf',
'-files',
'-reports'
])).not.toThrow();
// collapse the top level parent
const topLevelBranch = yield (0, treeData_1.findTreeNodeByARN)('arn:aws:s3:::archives', tree);
tree.collapse(topLevelBranch);
expect(assertTree(tree, [
'-archives',
'-files',
'-reports'
])).not.toThrow();
// now collapse one of the deeper child of already collapsed parent
const deepBranch = yield (0, treeData_1.findTreeNodeByARN)('arn:aws:s3:::archives/logs/applications', tree);
tree.collapse(deepBranch);
// no visible effect, since one of the parent is collapsed anyway
expect(assertTree(tree, [
'-archives',
'-files',
'-reports'
])).not.toThrow();
// however the effect will be apparant once the said parent is opened up again
yield tree.expand(topLevelBranch);
expect(assertTree(tree, [
'-archives',
'--users',
'--logs',
'---pgp.bat',
// this was originally expanded but was closed when the top level parent was in closed state
'---applications',
'-files',
'-reports'
])).not.toThrow();
}));
});
//# sourceMappingURL=index.test.js.map
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../__tests__/index.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,8CAA+C;AAC/C,gCAAsC;AACtC,yCAAqE;AAGrE,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;AAEtC,MAAM,UAAU,GAAG,CAAC,IAAoB,EAAE,KAAe,EAAgB,EAAE,CAAC,GAAS,EAAE;IACrF,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAC9C,OAAO,CAAC,GA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R,UAAU;SACX,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAElB,gCAAgC;QAChC,MAAM,cAAc,GAAG,MAAM,IAAA,4BAAiB,EAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;QAC9E,IAAI,CAAC,QAAQ,CAAC,cAAkC,CAAC,CAAC;QAClD,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;YACtB,WAAW;YACX,QAAQ;YACR,UAAU;SACX,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAElB,mEAAmE;QACnE,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAiB,EAAC,yCAAyC,EAAE,IAAI,CAAC,CAAC;QAC5F,IAAI,CAAC,QAAQ,CAAC,UAA8B,CAAC,CAAC;QAE9C,iEAAiE;QACjE,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;YACtB,WAAW;YACX,QAAQ;YACR,UAAU;SACX,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QAElB,8EAA8E;QAC9E,MAAM,IAAI,CAAC,MAAM,CAAC,cAAkC,CAAC,CAAC;QACtD,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;YACtB,WAAW;YACX,SAAS;YACT,QAAQ;YACR,YAAY;YACZ,4FAA4F;YAC5F,iBAAiB;YACjB,QAAQ;YACR,UAAU;SACX,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findTreeNodeByARN = exports.treeSource = void 0;
const src_1 = require("../src");
const rawData = [
{
name: 'archives',
arn: 'arn:aws:s3:::archives',
children: [
{
name: 'users',
arn: 'arn:aws:s3:::archives/users',
children: [
{
name: 'trevor.txt',
arn: 'arn:aws:s3:::archives/users/trevor.txt'
},
{
name: 'melinda.txt',
arn: 'arn:aws:s3:::archives/users/melinda.txt'
},
]
},
{
name: 'logs',
arn: 'arn:aws:s3:::archives/logs',
children: [
{
name: 'pgp.bat',
arn: 'arn:aws:s3:::archives/logs/pgp.bat'
},
{
name: 'applications',
arn: 'arn:aws:s3:::archives/logs/applications',
children: [
{
name: 'approved',
arn: 'arn:aws:s3:::archives/logs/applications/approved',
children: [
{
name: 'passport.pdf',
arn: 'arn:aws:s3:::archives/logs/applications/approved/passport.pdf'
},
{
name: 'visa.pdf',
arn: 'arn:aws:s3:::archives/logs/applications/approved/visa.pdf'
},
]
}
]
},
]
},
]
},
{
name: 'files',
arn: 'arn:aws:s3:::files',
children: []
},
{
name: 'reports',
arn: 'arn:aws:s3:::reports',
children: [
{
name: 'expenses.xlsx',
arn: 'arn:aws:s3:::reports/expenses.xlsx'
}
]
},
];
exports.treeSource = {
getNodes: (branch, factory) => {
const findItem = (arn, scope) => {
for (const item of scope) {
if (item.arn === arn) {
return item;
}
if (item.children) {
const res = findItem(arn, item.children);
if (res) {
return res;
}
}
}
};
const children = !branch ? rawData : findItem(branch.data.arn, rawData).children;
return (children || []).map(item => (item.children
? factory.createBranch(item)
: factory.createLeaf(item)));
}
};
const findTreeNodeByARN = (arn, tree) => {
const search = (branch) => __awaiter(void 0, void 0, void 0, function* () {
yield tree.ensureLoaded(branch);
for (const node of branch.nodes) {
if (arn === node.data.arn) {
return node;
}
if (arn.includes(node.data.arn) && src_1.Tree.isBranch(node)) {
return search(node);
}
}
});
return search(tree.root);
};
exports.findTreeNodeByARN = findTreeNodeByARN;
//# sourceMappingURL=treeData.js.map
{"version":3,"file":"treeData.js","sourceRoot":"","sources":["../../__tests__/treeData.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gCAA4D;AAQ5D,MAAM,OAAO,GAAe;IAC1B;QACE,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,uBAAuB;QAC5B,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,OAAO;gBACb,GAAG,EAAE,6BAA6B;gBAClC,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,YAAY;wBAClB,GAAG,EAAE,wCAAwC;qBAC9C;oBACD;wBACE,IAAI,EAAE,aAAa;wBACnB,GAAG,EAAE,yCAAyC;qBAC/C;iBACF;aACF;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,GAAG,EAAE,4BAA4B;gBACjC,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,SAAS;wBACf,GAAG,EAAE,oCAAoC;qBAC1C;oBACD;wBACE,IAAI,EAAE,cAAc;wBACpB,GAAG,EAAE,yCAAyC;wBAC9C,QAAQ,EAAE;4BACR;gCACE,IAAI,EAAE,UAAU;gCAChB,GAAG,EAAE,kDAAkD;gCACvD,QAAQ,EAAE;oCACR;wCACE,IAAI,EAAE,cAAc;wCACpB,GAAG,EAAE,+DAA+D;qCACrE;oCACD;wCACE,IAAI,EAAE,UAAU;wCAChB,GAAG,EAAE,2DAA2D;qCACjE;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SAEF;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,oBAAoB;QACzB,QAAQ,EAAE,EAAE;KACb;IACD;QACE,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,sBAAsB;QAC3B,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,eAAe;gBACrB,GAAG,EAAE,oCAAoC;aAC1C;SACF;KACF;CACF,CAAC;AAEW,QAAA,UAAU,GAAyB;IAC9C,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAwB,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AAC,IAAI,CAAC,EAAE;gBACtD,OAAO,MAAM,CAAC,IAAwB,CAAC,CAAC;aACzC;SACF;IACH,CAAC,CAAA,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC,CAAC;AAfW,QAAA,iBAAiB,qBAe5B"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Branch = void 0;
const Leaf_1 = require("./Leaf");
class Branch extends Leaf_1.Leaf {
constructor(id, parent, data, expanded) {
super(id, parent, data);
this.expanded = expanded;
}
}
exports.Branch = Branch;
//# sourceMappingURL=Branch.js.map
{"version":3,"file":"Branch.js","sourceRoot":"","sources":["../../src/Branch.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAG9B,MAAa,MAAkC,SAAQ,WAAe;IAgBpE,YAAY,EAAU,EAAE,MAAyB,EAAE,IAAe,EAAE,QAAkB;QACpF,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AApBD,wBAoBC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlatViewMap = void 0;
class FlatViewMap extends Map {
set(key, value) {
var _a;
super.set(key, value);
(_a = this.onDidSetKey) === null || _a === void 0 ? void 0 : _a.call(this, key, value);
return this;
}
}
exports.FlatViewMap = FlatViewMap;
//# sourceMappingURL=FlatViewMap.js.map
{"version":3,"file":"FlatViewMap.js","sourceRoot":"","sources":["../../src/FlatViewMap.ts"],"names":[],"mappings":";;;AAGA,MAAa,WAAY,SAAQ,GAAS;IAGxC,GAAG,CAAC,GAAM,EAAE,KAAQ;;QAClB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtB,MAAA,IAAI,CAAC,WAAW,+CAAhB,IAAI,EAAe,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AARD,kCAQC"}
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./types"), exports);
__exportStar(require("./Tree"), exports);
__exportStar(require("./Branch"), exports);
__exportStar(require("./Leaf"), exports);
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,yCAAuB;AACvB,2CAAyB;AACzB,yCAAuB"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Leaf = void 0;
class Leaf {
constructor(id, parent, data) {
this.id = id;
this.parent = parent;
this.data = data;
}
get depth() {
if (!this.parent) {
return 0;
}
return this.parent.depth + 1;
}
}
exports.Leaf = Leaf;
//# sourceMappingURL=Leaf.js.map
{"version":3,"file":"Leaf.js","sourceRoot":"","sources":["../../src/Leaf.ts"],"names":[],"mappings":";;;AAEA,MAAa,IAAI;IACf,YACkB,EAAU,EACV,MAAiB,EAC1B,IAAO;QAFE,OAAE,GAAF,EAAE,CAAQ;QACV,WAAM,GAAN,MAAM,CAAW;QAC1B,SAAI,GAAJ,IAAI,CAAG;IACZ,CAAC;IAEL,IAAI,KAAK;QACP,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,OAAO,CAAC,CAAC;SACV;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF;AAdD,oBAcC"}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tree = void 0;
const Branch_1 = require("./Branch");
const Leaf_1 = require("./Leaf");
const utils_1 = require("./utils");
const FlatViewMap_1 = require("./FlatViewMap");
class Tree {
constructor(source, rootBranchData) {
this.source = source;
this.flatViewMap = new FlatViewMap_1.FlatViewMap();
this.treeNodeMap = new Map();
this.pendingLoadChildrenRequests = new Map();
this.onVisibleNodesChangeCallback = () => void 0;
this.getTreeNodeById = (id) => this.treeNodeMap.get(id);
/**
* Ensures that the children of any given branch have been loaded and ready to be worked with.
*
* Call this method without any arguments to check if the root branch is loaded.
*
* ⚠ "Loaded" doesn't mean expanded, it just means the contents are "ready". Except when no arguments are given, the
* branch being checked is root, and root is always expanded.
*/
this.ensureLoaded = (branch = this.rootBranch) => __awaiter(this, void 0, void 0, function* () {
if (!branch.nodes) {
return this.loadNodes(branch);
}
});
this.expand = (branch, ensureVisible = false, recursive = false) => __awaiter(this, void 0, void 0, function* () {
const isVisibilitySkipable = !ensureVisible || (ensureVisible && this.isVisible(branch));
if (!recursive && this.isTrulyExpanded(branch) && isVisibilitySkipable) {
return;
}
branch.expanded = true;
yield this.ensureLoaded(branch);
// check again as collapse might have been called in the meantime
if (branch.expanded) {
this.connectBranchToClosestFlatView(branch, ensureVisible);
if (recursive) {
yield Promise.all(branch.nodes.map(node => Tree.isBranch(node)
? this.expand(node, ensureVisible, recursive)
: null));
}
}
});
this.collapse = (branch) => {
if (branch.expanded) {
this.disconnectBranchFromClosestFlatView(branch);
}
};
this.amend = (branch, amendFn) => {
let modified = false;
let draftNodes = branch.nodes.slice();
const factory = this.getTreeNodeFactory(branch);
const insertNode = (node, insertionIndex) => {
modified = true;
draftNodes.splice(insertionIndex !== null && insertionIndex !== void 0 ? insertionIndex : Infinity, 0, node);
return node;
};
amendFn({
draftNodes,
insertBranch: (data, insertionIndex) => insertNode(factory.createBranch(data), insertionIndex),
insertLeaf: (data, insertionIndex) => insertNode(factory.createLeaf(data), insertionIndex),
sort: (comparatorFn) => {
modified = true;
draftNodes.sort(comparatorFn);
},
revertChanges: () => {
modified = false;
draftNodes = branch.nodes.slice();
}
});
if (modified) {
this.setNodes(branch, draftNodes);
}
};
this.removeNode = (node) => {
const teardown = (childNode) => {
var _a;
// TODO: dispatch remove event
this.removeNodeFromFlatView(childNode);
this.treeNodeMap.delete(childNode.id);
if (Tree.isBranch(childNode)) {
(_a = childNode.nodes) === null || _a === void 0 ? void 0 : _a.forEach(teardown);
}
};
teardown(node);
const { parent } = node;
parent.nodes = parent.nodes.filter(n => n !== node);
};
this.moveNode = (node, to) => {
};
/**
* A more accurate and real-time representation of whether a branch is expanded.
*
* `Branch#expanded` represents the "intended" expansion state of the branch in question not the actual
* status, because the child nodes might still need to be loaded before the change can be seen in the tree.
*/
this.isTrulyExpanded = (branch) => branch.nodes && branch.expanded && !this.flatViewMap.has(branch.id);
this.isVisible = (node) => !this.findClosestDisconnectedParent(node);
this.nextId = ((genesis = 0) => (() => genesis++))();
this.rootBranch = new Branch_1.Branch(this.nextId(), null, rootBranchData);
this.flatViewMap.onDidSetKey = (key) => { var _a; return key === this.rootBranch.id && ((_a = this.onVisibleNodesChangeCallback) === null || _a === void 0 ? void 0 : _a.call(this)); };
this.expand(this.rootBranch);
}
onDidChangeVisibleTreeNodes(cb) {
this.onVisibleNodesChangeCallback = cb;
}
get root() {
return this.rootBranch;
}
get visibleTreeNodes() {
return this.flatViewMap.get(this.rootBranch.id);
}
loadNodes(parent) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.pendingLoadChildrenRequests.has(parent)) {
const promise = (() => __awaiter(this, void 0, void 0, function* () {
const nodes = yield this.source.getNodes(parent === this.rootBranch ? null : parent, this.getTreeNodeFactory(parent));
this.setNodes(parent, nodes);
for (const node of nodes) {
if (Tree.isBranch(node) && node.expanded) {
this.expand(node);
}
}
}))();
promise.finally(() => this.pendingLoadChildrenRequests.delete(parent));
this.pendingLoadChildrenRequests.set(parent, promise);
}
return this.pendingLoadChildrenRequests.get(parent);
});
}
setNodes(branch, nodes) {
const restoreExpansionQueue = [];
if (branch.nodes) {
if (branch.expanded) {
this.disconnectBranchFromClosestFlatView(branch);
restoreExpansionQueue.unshift(branch);
}
for (const node of branch.nodes) {
if (!nodes.includes(node)) {
throw new Error('Fatal: Missing node in new nodes array. This is a bug in `aspen-core` please file an issue along with repro steps');
}
// if a child branch is expanded, we must disconnect it (will be reconnected later)
if (Tree.isBranch(node) && node.expanded) {
this.disconnectBranchFromClosestFlatView(node);
restoreExpansionQueue.unshift(node);
}
}
}
branch.nodes = nodes;
const flatView = new Uint32Array(branch.nodes.length);
for (let i = 0; i < branch.nodes.length; i++) {
const child = branch.nodes[i];
flatView[i] = child.id;
this.treeNodeMap.set(child.id, child);
}
// save the updated flat projection
this.flatViewMap.set(branch.id, flatView);
for (const node of restoreExpansionQueue) {
this.connectBranchToClosestFlatView(node);
}
}
getTreeNodeFactory(branch) {
return {
createBranch: (data, expanded) => new Branch_1.Branch(this.nextId(), branch, data, expanded),
createLeaf: (data) => new Leaf_1.Leaf(this.nextId(), branch, data)
};
}
removeNodeFromFlatView(node) {
// if the node (branch) was in a disconnected state, remove its records
if (this.flatViewMap.has(node.id)) {
this.flatViewMap.delete(node.id);
}
// proceed with the complete removal from the shadow parent
const shadowParent = this.findClosestDisconnectedParent(node) || this.rootBranch;
const parentFlatView = this.flatViewMap.get(shadowParent.id);
const { start, end } = this.getNodeProjectionRangeWithinFlatView(parentFlatView, node);
const { spliced } = (0, utils_1.spliceTypedArray)(parentFlatView, start, end - start);
if (Tree.isBranch(node)) {
node.expanded = false;
}
this.flatViewMap.set(shadowParent.id, spliced);
}
disconnectBranchFromClosestFlatView(branch) {
// if is NOT root branch, and is connected to a shadow parent
if (!this.isRootBranch(branch) && !this.flatViewMap.has(branch.id)) {
const shadowParent = this.findClosestDisconnectedParent(branch) || this.rootBranch;
const parentFlatView = this.flatViewMap.get(shadowParent.id);
const { start, end } = this.getNodeProjectionRangeWithinFlatView(parentFlatView, branch);
const { spliced, deleted } = (0, utils_1.spliceTypedArray)(parentFlatView, start + 1, end - start);
branch.expanded = false;
this.flatViewMap.set(shadowParent.id, spliced);
this.flatViewMap.set(branch.id, deleted);
}
}
connectBranchToClosestFlatView(branch, liftToRoot = false) {
const shadowParent = this.findClosestDisconnectedParent(branch) || this.rootBranch;
// if is NOT root branch, and is disconnected from its shadow parent
if (!this.isRootBranch(branch) && this.flatViewMap.has(branch.id)) {
const parentFlatView = this.flatViewMap.get(shadowParent.id);
const fromIdx = parentFlatView.indexOf(branch.id) + 1;
const selfFlatView = this.flatViewMap.get(branch.id);
const { spliced } = (0, utils_1.spliceTypedArray)(parentFlatView, fromIdx, 0, selfFlatView);
branch.expanded = true;
this.flatViewMap.set(shadowParent.id, spliced);
this.flatViewMap.delete(branch.id);
}
if (liftToRoot && !this.isRootBranch(shadowParent)) {
this.connectBranchToClosestFlatView(shadowParent, true);
}
}
isRootBranch(branch) {
return branch === this.rootBranch;
}
findClosestDisconnectedParent(node) {
let p = node.parent;
while (p) {
if (!p.expanded) {
return p;
}
p = p.parent;
}
}
getNodeProjectionRangeWithinFlatView(flatView, node) {
let b = node;
// keep walking up until we find a branch that is NOT the last child of its parent
while ((0, utils_1.last)(b.parent.nodes) === b) {
b = b.parent;
}
// once we have that, just return the immediate next sibling node
const nextSibling = b.parent.nodes[b.parent.nodes.indexOf(b) + 1];
const startIndex = flatView.indexOf(node.id);
const endIndex = flatView.indexOf(nextSibling.id);
return {
start: startIndex,
end: (endIndex > -1 ? endIndex : flatView.length) - 1
};
}
}
exports.Tree = Tree;
Tree.isLeaf = (treeNode) => treeNode.constructor === Leaf_1.Leaf;
Tree.isBranch = (treeNode) => treeNode.constructor === Branch_1.Branch;
//# sourceMappingURL=Tree.js.map
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../src/Tree.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAkC;AAClC,iCAA8B;AAC9B,mCAAiD;AAEjD,+CAA4C;AAG5C,MAAa,IAAI;IAUf,YAAoB,MAA6B,EAAE,cAA0B;QAAzD,WAAM,GAAN,MAAM,CAAuB;QARzC,gBAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;QAChC,gBAAW,GAAG,IAAI,GAAG,EAA+B,CAAC;QACrD,gCAA2B,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC/D,iCAA4B,GAAe,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;QAuBhE,oBAAe,GAAG,CAAC,EAAU,EAAuB,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEhF;;;;;;;WAOG;QACH,iBAAY,GAAG,CAAO,SAA4B,IAAI,CAAC,UAAU,EAAiB,EAAE;YAClF,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;gBACjB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aAC/B;QACH,CAAC,CAAA,CAAC;QAEF,WAAM,GAAG,CAAO,MAAyB,EAAE,aAAa,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,EAAiB,EAAE;YACpG,MAAM,oBAAoB,GAAG,CAAC,aAAa,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;YAEzF,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,oBAAoB,EAAE;gBACtE,OAAO;aACR;YAEA,MAAM,CAAC,QAAoB,GAAG,IAAI,CAAC;YAEpC,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,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,GAAG,CAAC,QAAkB,EAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,KAAK,WAAI,CAAC;AACxE,aAAQ,GAAG,CAAC,QAAkB,EAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,KAAK,eAAM,CAAC"}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.last = exports.spliceTypedArray = void 0;
/**
* Like Array.prototype.splice except this method won't throw
* RangeError when given too many items (with spread operator as `...items`)
*
* Also items are concated straight up without having to use the spread operator
*
* Performance is more or less same as Array.prototype.splice
*
* @param arr Array to splice
* @param start Start index where splicing should begin
* @param deleteCount Items to delete (optionally replace with given items)
* @param items Items to insert (when deleteCount is same as items.length, it becomes a replace)
*/
const spliceTypedArray = (arr, start, deleteCount = 0, items) => {
const deleted = new Uint32Array(deleteCount);
const spliced = new Uint32Array((arr.length - deleteCount) + (items ? items.length : 0));
deleted.set(arr.subarray(start, start + deleteCount));
spliced.set(arr.subarray(0, start));
if (items) {
spliced.set(items, start);
}
spliced.set(arr.subarray(start + deleteCount, arr.length), (start + (items ? items.length : 0)));
return { spliced, deleted };
};
exports.spliceTypedArray = spliceTypedArray;
const last = (arr) => arr[arr.length - 1];
exports.last = last;
//# sourceMappingURL=utils.js.map
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACI,MAAM,gBAAgB,GAAG,CAAC,GAAgB,EAAE,KAAa,EAAE,WAAW,GAAG,CAAC,EAAE,KAAmB,EAAmD,EAAE;IACzJ,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACpC,IAAI,KAAK,EAAE;QACT,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KAC3B;IACD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,GAAG,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC,CAAC;AAVW,QAAA,gBAAgB,oBAU3B;AAEK,MAAM,IAAI,GAAG,CAAI,GAAqB,EAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAA5D,QAAA,IAAI,QAAwD"}
import { Tree, TreeNode, TreeSource } from '../src';
export declare type ItemData = {
name: string;
arn: string;
children?: ItemData[];
};
export declare const treeSource: TreeSource<ItemData>;
export declare const findTreeNodeByARN: (arn: string, tree: Tree<ItemData>) => Promise<TreeNode<ItemData>>;
import { Leaf } from './Leaf';
import { TreeNode } from './types';
export declare class Branch<NodeDataT extends {} = {}> extends Leaf<NodeDataT> {
readonly nodes: ReadonlyArray<TreeNode<NodeDataT>>;
/**
* A flag indicating the "intended" expansion status of this branch. If this is `true`, the branch
* is either already expanded OR is about to be expanded. Explained below.
*
* This value represents the "intended" expansion state not the "actual" expansion state. When
* `Tree#expand` is called, the value of this will be immediately become `true`, however because
* the child nodes of the branch in question might need to be loaded, the actual expansion won't
* take effect until the children are loaded. So in that interim time while children are loading,
* the branch isn't truly expanded even if the value is `true`.
*
* Depending on your use case you might want to rely on `Tree#isTrulyExpanded` for a "real-time" status.
*/
readonly expanded: boolean;
constructor(id: number, parent: Branch<NodeDataT>, data: NodeDataT, expanded?: boolean);
}
declare type K = number;
declare type V = Uint32Array;
export declare class FlatViewMap extends Map<K, V> {
onDidSetKey: (key: K, value: V) => void;
set(key: K, value: V): this;
}
export {};
export * from './types';
export * from './Tree';
export * from './Branch';
export * from './Leaf';
import { Branch } from './Branch';
export declare class Leaf<T extends {} = {}> {
readonly id: number;
readonly parent: Branch<T>;
data: T;
constructor(id: number, parent: Branch<T>, data: T);
get depth(): number;
}
import { TreeNode, TreeSource } from './types';
import { Branch } from './Branch';
import { BranchAmendContext } from '.';
export declare class Tree<NodeDataT extends {} = {}> {
private source;
private rootBranch;
private flatViewMap;
private treeNodeMap;
private pendingLoadChildrenRequests;
private onVisibleNodesChangeCallback;
static isLeaf: (treeNode: TreeNode) => boolean;
static isBranch: (treeNode: TreeNode) => boolean;
constructor(source: TreeSource<NodeDataT>, rootBranchData?: NodeDataT);
onDidChangeVisibleTreeNodes(cb: () => void): void;
get root(): Branch<NodeDataT>;
get visibleTreeNodes(): Uint32Array;
getTreeNodeById: (id: number) => TreeNode<NodeDataT>;
/**
* Ensures that the children of any given branch have been loaded and ready to be worked with.
*
* Call this method without any arguments to check if the root branch is loaded.
*
* ⚠ "Loaded" doesn't mean expanded, it just means the contents are "ready". Except when no arguments are given, the
* branch being checked is root, and root is always expanded.
*/
ensureLoaded: (branch?: Branch<NodeDataT>) => Promise<void>;
expand: (branch: Branch<NodeDataT>, ensureVisible?: boolean, recursive?: boolean) => Promise<void>;
collapse: (branch: Branch<NodeDataT>) => void;
amend: (branch: Branch<NodeDataT>, amendFn: (ctx: BranchAmendContext<NodeDataT>) => void) => void;
removeNode: (node: TreeNode<NodeDataT>) => void;
moveNode: (node: TreeNode<NodeDataT>, to: Branch<NodeDataT>) => void;
/**
* A more accurate and real-time representation of whether a branch is expanded.
*
* `Branch#expanded` represents the "intended" expansion state of the branch in question not the actual
* status, because the child nodes might still need to be loaded before the change can be seen in the tree.
*/
isTrulyExpanded: (branch: Branch<NodeDataT>) => boolean;
isVisible: (node: TreeNode<NodeDataT>) => boolean;
private nextId;
private loadNodes;
private setNodes;
private getTreeNodeFactory;
private removeNodeFromFlatView;
private disconnectBranchFromClosestFlatView;
private connectBranchToClosestFlatView;
private isRootBranch;
private findClosestDisconnectedParent;
private getNodeProjectionRangeWithinFlatView;
}
import { Branch } from './Branch';
import { Leaf } from './Leaf';
export declare type TreeNode<NodeDataT extends {} = {}> = (Leaf<NodeDataT> | Branch<NodeDataT>);
export declare type TreeNodeFactory<NodeDataT extends {} = {}> = {
createBranch: (data: NodeDataT, expanded?: boolean) => Branch<NodeDataT>;
createLeaf: (data: NodeDataT) => Leaf<NodeDataT>;
};
export declare type TreeSource<NodeDataT extends {} = {}> = {
getNodes: (parent: Branch<NodeDataT>, factory: TreeNodeFactory<NodeDataT>) => TreeNode<NodeDataT>[] | Promise<TreeNode<NodeDataT>[]>;
};
export declare type TreeNodeComparator<NodeDataT extends {}> = (a: TreeNode<NodeDataT>, b: TreeNode<NodeDataT>) => number;
export declare type BranchAmendContext<NodeDataT extends {}> = {
/**
* Realtime representation of nodes of the target branch. This is a readonly copy that updates after any operation is performed.
*
* It starts of with the current child nodes of the branch, and mutates as you run operation on it. The mutations will be commited
* to the actual tree after the amend function returns. Calling `revertChanges` will reset the copy back to how it was and no changes
* will be saved.
*/
draftNodes: ReadonlyArray<TreeNode<NodeDataT>>;
insertLeaf: (data: NodeDataT, insertionIndex?: number) => Leaf<NodeDataT>;
insertBranch: (data: NodeDataT, insertionIndex?: number) => Branch<NodeDataT>;
sort: (comparatorFn: TreeNodeComparator<NodeDataT>) => void;
revertChanges: () => void;
};
/**
* Like Array.prototype.splice except this method won't throw
* RangeError when given too many items (with spread operator as `...items`)
*
* Also items are concated straight up without having to use the spread operator
*
* Performance is more or less same as Array.prototype.splice
*
* @param arr Array to splice
* @param start Start index where splicing should begin
* @param deleteCount Items to delete (optionally replace with given items)
* @param items Items to insert (when deleteCount is same as items.length, it becomes a replace)
*/
export declare const spliceTypedArray: (arr: Uint32Array, start: number, deleteCount?: number, items?: Uint32Array) => {
deleted: Uint32Array;
spliced: Uint32Array;
};
export declare const last: <T>(arr: readonly T[]) => T;