repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
libro | github_2023 | weavefox | typescript | ArrayIterator.iter | iter(): IIterator<T> {
return this;
} | /**
* Get an iterator over the object's values.
*
* @returns An iterator which yields the object's values.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/iter.ts#L85-L87 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | ArrayIterator.clone | clone(): IIterator<T> {
const result = new ArrayIterator<T>(this._source);
result._index = this._index;
return result;
} | /**
* Create an independent clone of the iterator.
*
* @returns A new independent clone of the iterator.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/iter.ts#L94-L98 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | ArrayIterator.next | next(): T | undefined {
if (this._index >= this._source.length) {
return undefined;
}
return this._source[this._index++];
} | /**
* Get the next value from the iterator.
*
* @returns The next value from the iterator, or `undefined`.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/iter.ts#L105-L110 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | deepArrayEqual | function deepArrayEqual(
first: ReadonlyPartialJSONArray,
second: ReadonlyPartialJSONArray,
): boolean {
// Check referential equality first.
if (first === second) {
return true;
}
// Test the arrays for equal length.
if (first.length !== second.length) {
return false;
}
// Compare the value... | /**
* Compare two JSON arrays for deep equality.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/json.ts#L219-L242 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | deepObjectEqual | function deepObjectEqual(
first: ReadonlyPartialJSONObject,
second: ReadonlyPartialJSONObject,
): boolean {
// Check referential equality first.
if (first === second) {
return true;
}
// Check for the first object's keys in the second object.
for (const key in first) {
if (first[key] !== undefine... | /**
* Compare two JSON objects for deep equality.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/json.ts#L247-L294 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | deepArrayCopy | function deepArrayCopy(value: any): any {
const result = new Array<any>(value.length);
for (let i = 0, n = value.length; i < n; ++i) {
result[i] = deepCopy(value[i]);
}
return result;
} | /**
* Create a deep copy of a JSON array.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/json.ts#L299-L305 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | deepObjectCopy | function deepObjectCopy(value: any): any {
const result: any = {};
for (const key in value) {
// Ignore undefined values.
const subvalue = value[key];
if (subvalue === undefined) {
continue;
}
result[key] = deepCopy(subvalue);
}
return result;
} | /**
* Create a deep copy of a JSON object.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/json.ts#L310-L321 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | normalizeArray | function normalizeArray(parts: string[], allowAboveRoot: boolean) {
const res = [];
for (let i = 0; i < parts.length; i++) {
const p = parts[i];
// ignore empty parts
if (!p || p === '.') {
continue;
}
if (p === '..') {
if (res.length && res[res.length - 1] !== '..') {
res.... | // resolves . and .. elements in a path array with directory names there | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/posix.ts#L9-L31 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Sanitizer.sanitize | sanitize(dirty: string, options?: ISanitizerOptions): string {
return sanitize(dirty, { ...this._options, ...(options || {}) });
} | /**
* Sanitize an HTML string.
*
* @param dirty - The dirty text.
*
* @param options - The optional sanitization options.
*
* @returns The sanitized string.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/sanitizer.ts#L455-L457 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URL.getHostName | static getHostName(url: string): string {
return urlparse(url).hostname;
} | /**
* Parse URL and retrieve hostname
*
* @param url - The URL string to parse
*
* @returns a hostname string value
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/url.ts#L17-L19 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URL.join | static join(...parts: string[]): string {
let u = urlparse(parts[0], {});
// Schema-less URL can be only parsed as relative to a base URL
// see https://github.com/unshiftio/url-parse/issues/219#issuecomment-1002219326
const isSchemaLess = u.protocol === '' && u.slashes;
if (isSchemaLess) {
u ... | /**
* Join a sequence of url components and normalizes as in node `path.join`.
*
* @param parts - The url components.
*
* @returns the joined url.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/url.ts#L45-L62 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URL.encodeParts | static encodeParts(url: string): string {
return URL.join(...url.split('/').map(encodeURIComponent));
} | /**
* Encode the components of a multi-segment url.
*
* @param url - The url to encode.
*
* @returns the encoded url.
*
* #### Notes
* Preserves the `'/'` separators.
* Should not include the base url, since all parts are escaped.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/url.ts#L75-L77 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URL.parse | static parse(url: string): IUrl {
if (typeof document !== 'undefined' && document) {
const a = document.createElement('a');
a.href = url;
return a;
}
return urlparse(url);
} | /**
* Parse a url into a URL object.
*
* @param urlString - The URL string to parse.
*
* @returns A URL object.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/url.ts#L85-L92 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URL.isLocal | static isLocal(url: string): boolean {
const { protocol } = URL.parse(url);
return (
(!protocol || url.toLowerCase().indexOf(protocol) !== 0) && url.indexOf('/') !== 0
);
} | /**
* Test whether the url is a local url.
*
* #### Notes
* This function returns `false` for any fully qualified url, including
* `data:`, `file:`, and `//` protocol URLs.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/url.ts#L100-L106 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileTreeModel.onDidMove | protected onDidMove(event: FileOperationEvent): void {
if (!event.isOperation(FileOperation.MOVE)) {
return;
}
if (event.resource.parent.toString() === event.target.resource.parent.toString()) {
// file rename
return;
}
this.refreshAffectedNodes([event.resource, event.target.resour... | /**
* to workaround https://github.com/Axosoft/nsfw/issues/42
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/file-tree-model.ts#L109-L118 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileTreeModel.move | async move(source: TreeNode, target: TreeNode): Promise<URI | undefined> {
if (DirNode.is(target) && FileStatNode.is(source)) {
const { name } = source.fileStat;
const targetUri = URI.resolve(target.uri, name);
try {
await this.fileService.move(source.uri, targetUri);
return target... | /**
* Move the given source file or directory to the given target directory.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/file-tree-model.ts#L196-L223 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileTreeModel.shouldReplace | protected async shouldReplace(_fileName: string): Promise<boolean> {
const okDefer = new Deferred<boolean>();
// Modal.confirm({
// title: 'Replace file',
// content: `File '${fileName}' already exists in the destination folder. Do you want to replace it?`,
// onOk: () => {
// okDefer.... | // eslint-disable-next-line @typescript-eslint/no-unused-vars | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/file-tree-model.ts#L226-L239 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileTreeView.inflateFromStorage | protected override inflateFromStorage(node: any, parent?: TreeNode): TreeNode {
if (FileStatNodeData.is(node)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const fileStatNode: FileStatNode = node as any;
const resource = new URI(node.uri);
fileStatNode.uri = resource;
... | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/file-tree-view.tsx#L306-L339 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileChangesEvent.contains | contains(resource: URI, type?: FileChangeType): boolean {
if (!resource) {
return false;
}
const checkForChangeType = typeof type === 'number';
return this.changes.some((change) => {
if (checkForChangeType && change.type !== type) {
return false;
}
// For deleted also ... | /**
* Returns true if this change event contains the provided file with the given change type (if provided). In case of
* type DELETED, this method will also return true if a folder got deleted that is the parent of the
* provided file path.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/files.ts#L79-L98 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileChangesEvent.getAdded | getAdded(): FileChange[] {
return this.getOfType(FileChangeType.ADDED);
} | /**
* Returns the changes that describe added files.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/files.ts#L103-L105 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileChangesEvent.gotAdded | gotAdded(): boolean {
return this.hasType(FileChangeType.ADDED);
} | /**
* Returns if this event contains added files.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/files.ts#L110-L112 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileChangesEvent.getDeleted | getDeleted(): FileChange[] {
return this.getOfType(FileChangeType.DELETED);
} | /**
* Returns the changes that describe deleted files.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/files.ts#L117-L119 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileChangesEvent.gotDeleted | gotDeleted(): boolean {
return this.hasType(FileChangeType.DELETED);
} | /**
* Returns if this event contains deleted files.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/files.ts#L124-L126 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileChangesEvent.getUpdated | getUpdated(): FileChange[] {
return this.getOfType(FileChangeType.UPDATED);
} | /**
* Returns the changes that describe updated files.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/files.ts#L131-L133 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | FileChangesEvent.gotUpdated | gotUpdated(): boolean {
return this.hasType(FileChangeType.UPDATED);
} | /**
* Returns if this event contains updated files.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/file-tree/files.ts#L138-L140 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.initialize | initialize(): void {
const contributions = this.contributionProvider.getContributions();
for (const eventContribution of contributions) {
if (eventContribution.onDidChange) {
eventContribution.onDidChange((event: DidChangeLabelEvent) => {
this.onDidChangeEmitter.fire({
affect... | /**
* Start listening to contributions.
*
* Don't call this method directly!
* It's called by the frontend application during initialization.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L303-L314 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.fileIcon | get fileIcon(): string {
return this.getIcon(URIIconReference.create('file'));
} | /**
* Return a default file icon for the current icon theme.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L335-L337 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.folderIcon | get folderIcon(): string {
return this.getIcon(URIIconReference.create('folder'));
} | /**
* Return a default folder icon for the current icon theme.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L342-L344 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.getIcon | getIcon(element: Record<any, any>): string {
const contributions = this.findContribution(element);
for (const contribution of contributions) {
const value = contribution.getIcon && contribution.getIcon(element);
if (value === undefined) {
continue;
}
return value;
}
retur... | /**
* Get the icon class from the list of available {@link LabelProviderContribution} for the given element.
* @return the icon class
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L350-L360 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.getName | getName(element: Record<any, any>): string {
const contributions = this.findContribution(element);
for (const contribution of contributions) {
const value = contribution.getName && contribution.getName(element);
if (value === undefined) {
continue;
}
return value;
}
retur... | /**
* Get a short name from the list of available {@link LabelProviderContribution} for the given element.
* @return the short name
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L366-L376 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.getLongName | getLongName(element: Record<any, any>): string {
const contributions = this.findContribution(element);
for (const contribution of contributions) {
const value = contribution.getLongName && contribution.getLongName(element);
if (value === undefined) {
continue;
}
return value;
... | /**
* Get a long name from the list of available {@link LabelProviderContribution} for the given element.
* @return the long name
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L382-L392 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.getIconCompomponent | getIconCompomponent(element: Record<any, any>): React.ReactNode {
const contributions = this.findContribution(element);
for (const contribution of contributions) {
const value =
contribution.getIconComponent && contribution.getIconComponent(element);
if (value === undefined) {
contin... | /**
* Get a icon component from the list of available {@link LabelProviderContribution} for the given element.
* @return the icon component
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L398-L409 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.getNameComponent | getNameComponent(element: Record<any, any>): React.ReactNode {
const contributions = this.findContribution(element);
for (const contribution of contributions) {
const value =
contribution.getNameComponent && contribution.getNameComponent(element);
if (value === undefined) {
continue;... | /**
* Get a name component from the list of available {@link LabelProviderContribution} for the given element.
* @return the name component
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L415-L426 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | LabelProvider.getDescriptionComponent | getDescriptionComponent(element: Record<any, any>): React.ReactNode {
const contributions = this.findContribution(element);
for (const contribution of contributions) {
const value =
contribution.getDescriptionComponent &&
contribution.getDescriptionComponent(element);
if (value === u... | /**
* Get a description component from the list of available {@link LabelProviderContribution} for the given element.
* @return the description component
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/label/label-provider.tsx#L432-L444 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | NoopTreeDecoratorService.getDecorations | getDecorations(): Map<any, any> {
return new Map();
} | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-decorator.ts#L131-L133 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeModelImpl.selectIfAncestorOfSelected | protected selectIfAncestorOfSelected(node: Readonly<ExpandableTreeNode>): void {
if (
!node.expanded &&
[...this.selectedNodes].some((selectedNode) =>
CompositeTreeNode.isAncestor(node, selectedNode),
)
) {
if (SelectableTreeNode.isVisible(node)) {
this.selectNode(node);
... | /**
* Select the given node if it is the ancestor of a selected node.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-model.ts#L188-L199 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeModelImpl.selectedNodes | get selectedNodes() {
return this.selectionService.selectedNodes;
} | // tslint:disable-next-line:typedef | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-model.ts#L243-L245 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeModelImpl.onSelectionChanged | get onSelectionChanged() {
return this.selectionService.onSelectionChanged;
} | // tslint:disable-next-line:typedef | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-model.ts#L248-L250 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeSelectionServiceImpl.difference | protected difference<T>(left: readonly T[], right: readonly T[]): readonly T[] {
return left.filter((item) => right.indexOf(item) === -1);
} | /**
* Returns an array of the difference of two arrays. The returned array contains all elements that are contained by
* `left` and not contained by `right`. `right` may also contain elements not present in `left`: these are simply ignored.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-selection-impl.ts#L118-L120 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeSelectionServiceImpl.validateNode | protected validateNode(node: Readonly<TreeNode>): Readonly<TreeNode> | undefined {
const result = this.tree.validateNode(node);
return SelectableTreeNode.is(result) ? result : undefined;
} | /**
* Returns a reference to the argument if the node exists in the tree. Otherwise, `undefined`.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-selection-impl.ts#L125-L128 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeSelectionState.selectionRange | protected selectionRange(
selection: FocusableTreeSelection,
): Readonly<SelectableTreeNode>[] {
const fromNode = selection.focus;
const toNode = selection.node;
if (fromNode === undefined) {
return [];
}
if (toNode === fromNode) {
return [toNode];
}
const { root } = this.t... | /**
* Returns with an array of items representing the selection range. The from node is the `focus` the to node
* is the selected node itself on the tree selection. Both the `from` node and the `to` node are inclusive.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-selection-state.ts#L179-L227 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeSelectionState.checkNoDefaultSelection | protected checkNoDefaultSelection<T extends TreeSelection>(
selections: readonly T[],
): readonly T[] {
if (
selections.some(
(selection) =>
selection.type === undefined ||
selection.type === TreeSelection.SelectionType.DEFAULT,
)
) {
throw new Error(
... | /**
* Checks whether the argument contains any `DEFAULT` tree selection type. If yes, throws an error, otherwise returns with a reference the argument.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-selection-state.ts#L253-L270 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | isSelectionTypeOf | function isSelectionTypeOf(
arg: TreeSelection | SelectionType | undefined,
expected: SelectionType,
): boolean {
if (arg === undefined) {
return false;
}
const type = typeof arg === 'number' ? arg : arg.type;
return type === expected;
} | // eslint-disable-next-line no-inner-declarations | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/tree-selection.ts#L82-L91 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | hasTrailingSuffixes | const hasTrailingSuffixes = (): boolean => {
return (
treeViewDecorator
.getDecorationData(node, 'captionSuffixes')
.filter(notEmpty)
.reduce((acc, current) => acc.concat(current), []).length > 0
);
}; | /**
* Determine if the tree node contains trailing suffixes.
* @param node the tree node.
*
* @returns `true` if the tree node contains trailing suffices.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/components/tree-node-caption.tsx#L25-L32 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | decorateCaption | const decorateCaption = (
attrs: React.HTMLAttributes<HTMLElement>,
): React.Attributes & React.HTMLAttributes<HTMLElement> => {
const style = treeViewDecorator
.getDecorationData(node, 'fontData')
.filter(notEmpty)
.reverse()
.map((fontData) => treeView.applyFontStyles({}, fontData))
... | /**
* Decorate the tree caption.
* @param node the tree node.
* @param attrs the additional attributes.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/components/tree-node-caption.tsx#L38-L57 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | toReactNode | const toReactNode = (
caption: string,
highlight: CaptionHighlight,
): React.ReactNode[] => {
let style: React.CSSProperties = {};
if (highlight.color) {
style = {
...style,
color: highlight.color,
};
}
if (highlight.backgroundColor) {
style = {
...sty... | /**
* Update the node given the caption and highlight.
* @param caption the caption.
* @param highlight the tree decoration caption highlight.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/components/tree-node-caption.tsx#L64-L97 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeViewDecorator.getDecorationData | getDecorationData<K extends keyof TreeViewDecorationData>(
node: TreeNode,
key: K,
): TreeViewDecorationData[K][] {
return this.getDecorations(node)
.filter((data) => data[key] !== undefined)
.map((data) => data[key])
.filter(notEmpty);
} | /**
* Get the tree decoration data for the given key.
* @param node the tree node.
* @param key the tree decoration data key.
*
* @returns the tree decoration data at the given key.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view-decorator.ts#L67-L75 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeViewDecorator.getDecorations | protected getDecorations(node: TreeNode): TreeViewDecorationData[] {
const decorations: TreeViewDecorationData[] = [];
if (DecoratedTreeNode.is(node)) {
decorations.push(node.decorationData);
}
if (this.decorations.has(node.id)) {
decorations.push(...this.decorations.get(node.id)!);
}
... | /**
* Get the tree node decorations.
* @param node the tree node.
* @returns the list of tree decoration data.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view-decorator.ts#L81-L90 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.createNodeClassNames | protected createNodeClassNames(node: TreeNode, _props: NodeProps): string[] {
const classNames = [TREE_NODE_CLASS];
if (CompositeTreeNode.is(node)) {
classNames.push(COMPOSITE_TREE_NODE_CLASS);
}
if (this.isExpandable(node)) {
classNames.push(EXPANDABLE_TREE_NODE_CLASS);
}
if (Select... | /**
* Create the node class names.
* @param node the tree node.
* @param _props the node properties.
*
* @returns the list of tree node class names.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L367-L382 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.createNodeAttributes | createNodeAttributes(
node: TreeNode,
props: NodeProps,
): React.Attributes & React.HTMLAttributes<HTMLElement> {
const className = this.createNodeClassNames(node, props).join(' ');
const style = this.createNodeStyle(node, props);
return {
className,
style,
onClick: (event) => th... | /**
* Create node attributes for the tree node given the node properties.
* @param node the tree node.
* @param props the node properties.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L388-L400 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.createContainerAttributes | createContainerAttributes(): React.HTMLAttributes<HTMLElement> {
const classNames = [TREE_CONTAINER_CLASS, this.className];
if (!this.rows.size) {
classNames.push('empty');
}
return {
className: classNames.join(' '),
};
} | /**
* Create the container attributes for the widget.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L404-L412 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.getContainerTreeNode | getContainerTreeNode(): TreeNode | undefined {
return this.model.root;
} | /**
* Get the container tree node.
*
* @returns the tree node for the container if available.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L418-L420 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.handleContextMenuEvent | handleContextMenuEvent = (
event: React.MouseEvent<HTMLElement>,
tree: TreeView | undefined,
n: TreeNode | TreeView | undefined,
): void => {
if (TreeNode.is(n)) {
const node = n;
if (SelectableTreeNode.is(node)) {
// Keep the selection for the context menu, if the widget support m... | /**
* Handle the context menu click event.
* - The context menu click event is triggered by the right-click.
* @param node the tree node if available.
* @param event the right-click mouse event.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.doFocus | protected doFocus(): void {
if (!this.model.selectedNodes.length) {
const node = this.getNodeToFocus();
if (SelectableTreeNode.is(node)) {
this.model.selectNode(node);
}
}
// It has to be called after nodes are selected.
if (this.props.globalSelection) {
this.updateGlobal... | /**
* Actually focus the tree node.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L471-L482 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.getNodeToFocus | protected getNodeToFocus(): SelectableTreeNode | undefined {
const { root } = this.model;
if (SelectableTreeNode.isVisible(root)) {
return root;
}
return this.model.getNextSelectableNode(root);
} | /**
* Get the tree node to focus.
*
* @returns the node to focus if available.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L489-L495 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.updateScrollToRow | protected updateScrollToRow(): void {
this.scrollToRow = this.getScrollToRow();
} | /**
* Update the `scrollToRow`.
* @param updateOptions the tree widget force update options.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L505-L507 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.getScrollToRow | protected getScrollToRow(): number | undefined {
if (!this.shouldScrollToRow) {
return undefined;
}
const selected = this.model.selectedNodes;
const node: TreeNode | undefined =
selected.find(SelectableTreeNode.hasFocus) || selected[0];
const row = node && this.rows.get(node.id);
ret... | /**
* Get the `scrollToRow`.
*
* @returns the `scrollToRow` if available.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L527-L536 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.doToggle | protected doToggle(event: React.MouseEvent<HTMLElement>): void {
const nodeId = this.findNodeAttr(event.currentTarget);
if (nodeId) {
const node = this.model.getNode(nodeId);
this.handleClickEvent(node, event);
}
event.stopPropagation();
} | /**
* Actually toggle the tree node.
* @param event the mouse click event.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L568-L575 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.hasCtrlCmdMask | protected hasCtrlCmdMask(event: ModifierAwareEvent): boolean {
const { metaKey, ctrlKey } = event;
return (isOSX && metaKey) || ctrlKey;
} | /**
* Determine if the tree modifier aware event has a `ctrlcmd` mask.
* @param event the tree modifier aware event.
*
* @returns `true` if the tree modifier aware event contains the `ctrlcmd` mask.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L583-L586 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.hasShiftMask | protected hasShiftMask(event: ModifierAwareEvent): boolean {
// Ctrl/Cmd mask overrules the Shift mask.
if (this.hasCtrlCmdMask(event)) {
return false;
}
return event.shiftKey;
} | /**
* Determine if the tree modifier aware event has a `shift` mask.
* @param event the tree modifier aware event.
*
* @returns `true` if the tree modifier aware event contains the `shift` mask.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L594-L600 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.handleClickEvent | handleClickEvent(
maybeProxyNode: TreeNode | undefined,
event: React.MouseEvent<HTMLElement>,
): void {
const node = getOrigin(maybeProxyNode);
if (node) {
const shiftMask = this.hasShiftMask(event);
const ctrlCmdMask = this.hasCtrlCmdMask(event);
if (this.props.multiSelect) {
... | /**
* Handle the single-click mouse event.
* @param node the tree node if available.
* @param event the mouse single-click event.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L606-L638 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.handleDblClickEvent | handleDblClickEvent(
node: TreeNode | undefined,
event: React.MouseEvent<HTMLElement>,
): void {
this.model.openNode(node);
event.stopPropagation();
} | /**
* Handle the double-click mouse event.
* @param node the tree node if available.
* @param event the double-click mouse event.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L645-L651 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.getIconClass | getIconClass(iconName: string | string[], additionalClasses: string[] = []): string {
const iconClass =
typeof iconName === 'string'
? ['a', 'fa', `fa-${iconName}`]
: ['a'].concat(iconName);
return iconClass.concat(additionalClasses).join(' ');
} | /**
* Determine the classes to use for an icon
* - Assumes a Font Awesome name when passed a single string, otherwise uses the passed string array
* @param iconName the icon name or list of icon names.
* @param additionalClasses additional CSS classes.
*
* @returns the icon class name.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L661-L667 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.applyFontStyles | applyFontStyles(
original: React.CSSProperties,
fontData: TreeViewDecoration.FontData | undefined,
): React.CSSProperties {
if (fontData === undefined) {
return original;
}
const modified = { ...original }; // make a copy to mutate
const { color, style } = fontData;
if (color) {
... | /**
* Apply font styles to the tree.
* @param original the original css properties.
* @param fontData the optional `fontData`.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L674-L707 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.createNodeStyle | createNodeStyle(node: TreeNode, props: NodeProps): React.CSSProperties | undefined {
return this.decorateNodeStyle(node, this.getDefaultNodeStyle(node, props));
} | /**
* Create the tree node style.
* @param node the tree node.
* @param props the node properties.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L750-L752 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.decorateNodeStyle | protected decorateNodeStyle(
node: TreeNode,
style: React.CSSProperties | undefined,
): React.CSSProperties | undefined {
const backgroundColor = this.treeViewDecorator
.getDecorationData(node, 'backgroundColor')
.filter(notEmpty)
.shift();
if (backgroundColor) {
style = {
... | /**
* Decorate the node style.
* @param node the tree node.
* @param style the optional CSS properties.
*
* @returns the CSS styles if available.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L761-L776 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.getDefaultNodeStyle | protected getDefaultNodeStyle(
node: TreeNode,
props: NodeProps,
): React.CSSProperties | undefined {
const paddingLeft = `${this.getPaddingLeft(node, props)}px`;
return { paddingLeft };
} | /**
* Get the default node style.
* @param node the tree node.
* @param props the node properties.
*
* @returns the CSS properties if available.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L784-L790 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.needsExpansionTogglePadding | protected needsExpansionTogglePadding(node: TreeNode): boolean {
return !this.isExpandable(node);
} | /**
* If the node is a composite, a toggle will be rendered.
* Otherwise we need to add the width and the left, right padding => 18px
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L803-L805 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.deflateForStorage | protected deflateForStorage(node: TreeNode): object {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const copy = { ...node } as any;
if (copy.parent) {
delete copy.parent;
}
if ('previousSibling' in copy) {
delete copy.previousSibling;
}
if ('nextSibling' in copy... | /**
* Deflate the tree node for storage.
* @param node the tree node.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L811-L833 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.inflateFromStorage | protected inflateFromStorage(node: any, parent?: TreeNode): TreeNode {
if (node.selected) {
node.selected = false;
}
if (parent) {
node.parent = parent;
}
if (Array.isArray(node.children)) {
for (const child of node.children as TreeNode[]) {
this.inflateFromStorage(child, n... | // eslint-disable-next-line @typescript-eslint/no-explicit-any | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L841-L854 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.storeState | storeState(): object {
const decorations = this.decoratorService.deflateDecorators(
this.treeViewDecorator.decorations,
);
let state: object = {
decorations,
};
if (this.model.root) {
state = {
...state,
root: this.deflateForStorage(this.model.root),
model: ... | /**
* Store the tree state.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L859-L875 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | TreeView.restoreState | restoreState(oldState: object): void {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const { root, decorations, model } = oldState as any;
if (root) {
this.model.root = this.inflateFromStorage(root);
}
if (decorations) {
this.treeViewDecorator.decorations =
this.... | /**
* Restore the state.
* @param oldState the old state object.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/app/tree/view/tree-view.tsx#L881-L894 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DisposableCollection.disposed | get disposed(): boolean {
return this.disposables.length === 0;
} | /**
* Returns true if this collection is empty.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/disposable-collection.ts#L29-L31 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | DisposableCollection.pushAll | pushAll(disposables: Disposable[]): Disposable[] {
return this.push(...disposables);
} | /**
* @deprecated use push instead
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/disposable-collection.ts#L84-L86 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Emitter.event | get event(): Event<T> {
if (!this._event) {
this._event = (
listener: (e: T) => any,
thisArgs?: any,
disposables?: Disposable[],
) => {
if (!this._callbacks) {
this._callbacks = new CallbackList();
}
if (
this._options &&
this... | /**
* For the public to allow to subscribe
* to events from this Emitter
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/event.ts#L125-L168 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Emitter.fire | fire(event: T): any {
if (this._callbacks) {
this._callbacks.invoke(event);
}
} | /**
* To be kept protected to fire an event to
* subscribers
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/event.ts#L174-L178 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Emitter.sequence | async sequence(
processor: (listener: (e: T) => any) => MaybePromise<boolean>,
): Promise<void> {
if (this._callbacks) {
for (const listener of this._callbacks) {
// eslint-disable-next-line no-await-in-loop
const result = await processor(listener);
if (!result) {
break... | /**
* Process each listener one by one.
* Return `false` to stop iterating over the listeners, `true` to continue.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/event.ts#L184-L196 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Path.normalizeDrive | static normalizeDrive(path: string): string {
if (path.length > 3 && path[0] === '/' && path[2] === ':') {
const code = path.charCodeAt(1);
if (code >= 65 && code <= 90) {
path = `/${path[1].toLowerCase()}:${path.substring(3)}`;
}
return path;
}
if (path.length > 2 && path[1]... | /**
* vscode-uri always normalizes drive letters to lower case:
* https://github.com/Microsoft/vscode-uri/blob/b1d3221579f97f28a839b6f996d76fc45e9964d8/src/index.ts#L1025
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/path.ts#L12-L30 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Path.normalizePathSeparator | static normalizePathSeparator(path: string): string {
return path.split(/[\\]/).join(Path.separator);
} | /**
* Normalize path separator to use Path.separator
* @param Path candidate to normalize
* @returns Normalized string path
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/path.ts#L36-L38 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Path.constructor | constructor(raw: string) {
this.raw = Path.normalizePath(raw);
const lastIndex = this.raw.lastIndexOf(Path.separator);
this.isAbsolute = this.raw.indexOf(Path.separator) === 0;
this.base = lastIndex === -1 ? this.raw : this.raw.substring(lastIndex + 1);
this.isDrive = Path.isDrive(this.base);
th... | /**
* The raw should be normalized, meaning that only '/' is allowed as a path separator.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/path.ts#L63-L75 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Path.dir | get dir(): Path {
if (this._dir === undefined) {
this._dir = this.doGetDir();
}
return this._dir;
} | /**
* Returns the parent directory if it exists (`hasDir === true`) or `this` otherwise.
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/path.ts#L80-L85 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Path.hasDir | get hasDir(): boolean {
return !this.isRoot && this.raw.lastIndexOf(Path.separator) !== -1;
} | /**
* Returns `true` if this has a parent directory, `false` otherwise.
*
* _This implementation returns `true` if and only if this is not the root dir and
* there is a path separator in the raw path._
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/path.ts#L93-L95 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Path.resolve | static resolve(path: Path, ...paths: string[]): Path | undefined {
const segments = paths.slice().reverse(); // Don't mutate the caller's array.
segments.push(path.raw);
let result = new Path('');
for (const segment of segments) {
if (segment) {
const next = Path.join(new Path(segment), re... | /**
*
* @param paths portions of a path
* @returns a new Path if an absolute path can be computed from the segments passed in + this.raw
* If no absolute path can be computed, returns undefined.
*
* Processes the path segments passed in from right to left (reverse order) concatenating until an
* ab... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/path.ts#L163-L177 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | Path.normalize | static normalize(path: Path): Path {
const trailingSlash = path.raw.endsWith('/');
const pathArray = path.toString().split('/');
const resultArray: string[] = [];
pathArray.forEach((value) => {
if (!value || value === '.') {
return;
}
if (value === '..') {
if (resultArr... | /*
* return a normalized Path, resolving '..' and '.' segments
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/path.ts#L197-L225 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.normalizePath | normalizePath(): URI {
return URI.withPath(this, Path.normalize(this.path));
} | /**
* return a new URI replacing the current with its normalized path, resolving '..' and '.' segments
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/uri.ts#L33-L35 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.withScheme | static withScheme(uri: URI, scheme: string): URI {
const newCodeUri = Uri.from({
...uri.toJSON(),
scheme,
});
return new URI(newCodeUri);
} | /**
* return a new URI replacing the current with the given scheme
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/uri.ts#L116-L122 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.withAuthority | static withAuthority(uri: URI, authority = ''): URI {
const newCodeUri = Uri.from({
...uri.toJSON(),
authority,
});
return new URI(newCodeUri);
} | /**
* return a new URI replacing the current with the given authority
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/uri.ts#L127-L133 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.withPath | static withPath(uri: URI, path: string | Path = ''): URI {
const newCodeUri = Uri.from({
...uri.toJSON(),
path: path.toString(),
});
return new URI(newCodeUri);
} | /**
* return a new URI replacing the current with the given path
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/uri.ts#L138-L144 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.withQuery | static withQuery(uri: URI, query = ''): URI {
const newCodeUri = Uri.from({
...uri.toJSON(),
query,
});
return new URI(newCodeUri);
} | /**
* return a new URI replacing the current with the given query
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/uri.ts#L149-L155 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.withFragment | static withFragment(uri: URI, fragment = ''): URI {
const newCodeUri = Uri.from({
...uri.toJSON(),
fragment,
});
return new URI(newCodeUri);
} | /**
* return a new URI replacing the current with the given fragment
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/uri.ts#L160-L166 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | _schemeFix | function _schemeFix(scheme: string, _strict: boolean): string {
if (!scheme && !_strict) {
return 'file';
}
return scheme;
} | // for a while we allowed uris *without* schemes and this is the migration | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L54-L59 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | _referenceResolution | function _referenceResolution(scheme: string, path: string): string {
// the slash-character is our 'default base' as we don't
// support constructing URIs relative to other URIs. This
// also means that we alter and potentially break paths.
// see https://tools.ietf.org/html/rfc3986#section-5.1.4
switch (sch... | // implements a bit of https://tools.ietf.org/html/rfc3986#section-5 | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L62-L79 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.constructor | constructor(
schemeOrData: string | UriComponents,
authority?: string,
path?: string,
query?: string,
fragment?: string,
_strict = false,
options = { simpleMode: true },
) {
if (typeof schemeOrData === 'object') {
this.scheme = schemeOrData.scheme || _empty;
this.authority ... | /**
* @internal
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L172-L200 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.fsPath | get fsPath(): string {
// if (this.scheme !== 'file') {
// console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
// }
return uriToFsPath(this, false);
} | /**
* Returns a string representing the corresponding file system path of this URI.
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
* platform specific path separator.
*
* * Will *not* validate the path for invalid characters and semantics.
* * Will *not* look at the sc... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L228-L233 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.with | with(change: {
scheme?: string;
authority?: string | null;
path?: string | null;
query?: string | null;
fragment?: string | null;
}): URI {
if (!change) {
return this;
}
let { scheme, authority, path, query, fragment } = change;
if (scheme === undefined) {
scheme = thi... | // ---- modify to new ------------------------- | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L237-L286 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.parse | static parse(value: string, _strict = false, options = { simpleMode: true }): URI {
if (options.simpleMode) {
const match = _regexpSimple.exec(value);
if (!match) {
return new Uri(_empty, _empty, _empty, _empty, _empty);
}
return new Uri(
match[2] || _empty,
match[4] ... | /**
* Creates a new URI from a string, e.g. `http://www.example.com/some/path`,
* `file:///usr/home`, or `scheme:with/path`.
*
* @param value A string which represents an URI (see `URI#toString`).
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L296-L326 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.file | static file(path: string): URI {
let authority = _empty;
// normalize to fwd-slashes on windows,
// on other systems bwd-slashes are valid
// filename character, eg /f\oo/ba\r.txt
if (isWindows) {
path = path.replace(/\\/g, _slash);
}
// check for authority as used in UNC shares
... | /**
* Creates a new URI from a file system path, e.g. `c:\my\files`,
* `/usr/home`, or `\\server\share\some\path`.
*
* The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
* as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
* `URI.parse('file... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L349-L373 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | URI.toString | toString(skipEncoding = false): string {
return _asFormatted(this, skipEncoding);
} | /**
* Creates a string representation for this URI. It's guaranteed that calling
* `URI.parse` with the result of this function creates an URI which is equal
* to this URI.
*
* * The result shall *not* be used for display purposes but for externalization or transport.
* * The result will be encoded us... | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L406-L408 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | _asFormatted | function _asFormatted(uri: URI, skipEncoding: boolean): string {
const encoder = !skipEncoding ? encodeURIComponentFast : encodeURIComponentMinimal;
let res = '';
const { scheme, query, fragment, simpleMode } = uri;
let { authority, path } = uri;
if (scheme) {
res += scheme;
res += ':';
}
if (au... | /**
* Create the external version of a uri
*/ | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L647-L727 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
libro | github_2023 | weavefox | typescript | decodeURIComponentGraceful | function decodeURIComponentGraceful(str: string): string {
try {
return decodeURIComponent(str);
} catch {
if (str.length > 3) {
return str.substr(0, 3) + decodeURIComponentGraceful(str.substr(3));
} else {
return str;
}
}
} | // --- decode | https://github.com/weavefox/libro/blob/371f9fa4903254d60ed3142e335dbf3f6d8d03e4/packages/libro-common/src/common/vscode-uri/uri.ts#L731-L741 | 371f9fa4903254d60ed3142e335dbf3f6d8d03e4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.