first commit
This commit is contained in:
21
web-app/node_modules/@volar/source-map/LICENSE
generated
vendored
Normal file
21
web-app/node_modules/@volar/source-map/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-present Johnson Chu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
53
web-app/node_modules/@volar/source-map/README.md
generated
vendored
Normal file
53
web-app/node_modules/@volar/source-map/README.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# @volar/source-map
|
||||
|
||||
Provides functionality related to source maps.
|
||||
|
||||
## API
|
||||
|
||||
### This package exports a `SourceMap` class with the following methods:
|
||||
|
||||
Params:
|
||||
|
||||
- `fallbackToAnyMatch`(default: false): allow the start and end offsets to come from different mappings.
|
||||
- `filter?: (data: Data) => boolean)`(default: undefined): according to mapping: Mapping<MyDataType>.data, filter out offsets that do not meet the custom conditions.
|
||||
|
||||
Methods:
|
||||
|
||||
- `toSourceRange(generatedStart: number, generatedEnd: number, fallbackToAnyMatch: boolean, filter?: (data: Data) => boolean)`: Returns all source start and end offsets for the given generated start and end offsets.
|
||||
|
||||
- `toGeneratedRange(sourceStart: number, sourceEnd: number, fallbackToAnyMatch: boolean, filter?: (data: Data) => boolean) `: Returns all generated start and end offsets for the given source start and end offsets.
|
||||
|
||||
- `toSourceLocation(generatedOffset: number, filter?: (data: Data) => boolean)`: Returns all source offsets for a given generated offset.
|
||||
|
||||
- `toGeneratedLocation(sourceOffset: number, filter?: (data: Data) => boolean)`: Returns all generated offsets for a given source offset.
|
||||
|
||||
## Data Structures
|
||||
|
||||
### `Mapping`
|
||||
|
||||
The `Mapping` is a tuple that represents a mapping in the source map. It consists of the following elements:
|
||||
|
||||
- `source`: A string representing the source file. This can be `undefined`.
|
||||
- `sourceOffsets`: Offsets in the source code.
|
||||
- `generatedOffsets`: Offsets in the generated code.
|
||||
- `data`: The data associated with this mapping. The type of this data is generic and can be specified when creating a `SourceMap` instance.
|
||||
|
||||
Here is an example of a `Mapping`:
|
||||
|
||||
```ts
|
||||
let mapping: Mapping<MyDataType> = {
|
||||
source: '.../sourceFile.ts',
|
||||
sourceOffsets: [10],
|
||||
generatedOffsets: [30],
|
||||
lengths: [10],
|
||||
data: myData,
|
||||
};
|
||||
```
|
||||
|
||||
In this example, `myData` is of type `MyDataType`, which is the type specified for the SourceMap instance.
|
||||
|
||||
Remember to replace `MyDataType` and `myData` with actual types and data that are relevant to your project.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
|
||||
2
web-app/node_modules/@volar/source-map/index.d.ts
generated
vendored
Normal file
2
web-app/node_modules/@volar/source-map/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './lib/sourceMap';
|
||||
export * from './lib/translateOffset';
|
||||
19
web-app/node_modules/@volar/source-map/index.js
generated
vendored
Normal file
19
web-app/node_modules/@volar/source-map/index.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (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("./lib/sourceMap"), exports);
|
||||
__exportStar(require("./lib/translateOffset"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
5
web-app/node_modules/@volar/source-map/lib/binarySearch.d.ts
generated
vendored
Normal file
5
web-app/node_modules/@volar/source-map/lib/binarySearch.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare function binarySearch(values: number[], searchValue: number): {
|
||||
low: number;
|
||||
high: number;
|
||||
match: number | undefined;
|
||||
};
|
||||
28
web-app/node_modules/@volar/source-map/lib/binarySearch.js
generated
vendored
Normal file
28
web-app/node_modules/@volar/source-map/lib/binarySearch.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.binarySearch = binarySearch;
|
||||
function binarySearch(values, searchValue) {
|
||||
let low = 0;
|
||||
let high = values.length - 1;
|
||||
let match;
|
||||
while (low <= high) {
|
||||
const mid = Math.floor((low + high) / 2);
|
||||
const midValue = values[mid];
|
||||
if (midValue < searchValue) {
|
||||
low = mid + 1;
|
||||
}
|
||||
else if (midValue > searchValue) {
|
||||
high = mid - 1;
|
||||
}
|
||||
else {
|
||||
low = mid;
|
||||
high = mid;
|
||||
match = mid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const finalLow = Math.max(Math.min(low, high, values.length - 1), 0);
|
||||
const finalHigh = Math.min(Math.max(low, high, 0), values.length - 1);
|
||||
return { low: finalLow, high: finalHigh, match };
|
||||
}
|
||||
//# sourceMappingURL=binarySearch.js.map
|
||||
23
web-app/node_modules/@volar/source-map/lib/sourceMap.d.ts
generated
vendored
Normal file
23
web-app/node_modules/@volar/source-map/lib/sourceMap.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
type CodeRangeKey = 'sourceOffsets' | 'generatedOffsets';
|
||||
export interface Mapping<Data = unknown> {
|
||||
sourceOffsets: number[];
|
||||
generatedOffsets: number[];
|
||||
lengths: number[];
|
||||
generatedLengths?: number[];
|
||||
data: Data;
|
||||
}
|
||||
export declare class SourceMap<Data = unknown> {
|
||||
readonly mappings: Mapping<Data>[];
|
||||
private sourceCodeOffsetsMemo;
|
||||
private generatedCodeOffsetsMemo;
|
||||
constructor(mappings: Mapping<Data>[]);
|
||||
toSourceRange(generatedStart: number, generatedEnd: number, fallbackToAnyMatch: boolean, filter?: (data: Data) => boolean): Generator<[mappedStart: number, mappedEnd: number, startMapping: Mapping<Data>, endMapping: Mapping<Data>], any, unknown>;
|
||||
toGeneratedRange(sourceStart: number, sourceEnd: number, fallbackToAnyMatch: boolean, filter?: (data: Data) => boolean): Generator<[mappedStart: number, mappedEnd: number, startMapping: Mapping<Data>, endMapping: Mapping<Data>], any, unknown>;
|
||||
toSourceLocation(generatedOffset: number, filter?: (data: Data) => boolean): Generator<readonly [number, Mapping<Data>], void, unknown>;
|
||||
toGeneratedLocation(sourceOffset: number, filter?: (data: Data) => boolean): Generator<readonly [number, Mapping<Data>], void, unknown>;
|
||||
findMatchingOffsets(offset: number, fromRange: CodeRangeKey, filter?: (data: Data) => boolean): Generator<readonly [number, Mapping<Data>], void, unknown>;
|
||||
findMatchingStartEnd(start: number, end: number, fallbackToAnyMatch: boolean, fromRange: CodeRangeKey, filter?: (data: Data) => boolean): Generator<[mappedStart: number, mappedEnd: number, startMapping: Mapping<Data>, endMapping: Mapping<Data>]>;
|
||||
private getMemoBasedOnRange;
|
||||
private createMemo;
|
||||
}
|
||||
export {};
|
||||
105
web-app/node_modules/@volar/source-map/lib/sourceMap.js
generated
vendored
Normal file
105
web-app/node_modules/@volar/source-map/lib/sourceMap.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SourceMap = void 0;
|
||||
const binarySearch_1 = require("./binarySearch");
|
||||
const translateOffset_1 = require("./translateOffset");
|
||||
class SourceMap {
|
||||
constructor(mappings) {
|
||||
this.mappings = mappings;
|
||||
}
|
||||
toSourceRange(generatedStart, generatedEnd, fallbackToAnyMatch, filter) {
|
||||
return this.findMatchingStartEnd(generatedStart, generatedEnd, fallbackToAnyMatch, 'generatedOffsets', filter);
|
||||
}
|
||||
toGeneratedRange(sourceStart, sourceEnd, fallbackToAnyMatch, filter) {
|
||||
return this.findMatchingStartEnd(sourceStart, sourceEnd, fallbackToAnyMatch, 'sourceOffsets', filter);
|
||||
}
|
||||
toSourceLocation(generatedOffset, filter) {
|
||||
return this.findMatchingOffsets(generatedOffset, 'generatedOffsets', filter);
|
||||
}
|
||||
toGeneratedLocation(sourceOffset, filter) {
|
||||
return this.findMatchingOffsets(sourceOffset, 'sourceOffsets', filter);
|
||||
}
|
||||
*findMatchingOffsets(offset, fromRange, filter) {
|
||||
const memo = this.getMemoBasedOnRange(fromRange);
|
||||
if (memo.offsets.length === 0) {
|
||||
return;
|
||||
}
|
||||
const { low: start, high: end } = (0, binarySearch_1.binarySearch)(memo.offsets, offset);
|
||||
const skip = new Set();
|
||||
const toRange = fromRange == 'sourceOffsets' ? 'generatedOffsets' : 'sourceOffsets';
|
||||
for (let i = start; i <= end; i++) {
|
||||
for (const mapping of memo.mappings[i]) {
|
||||
if (skip.has(mapping)) {
|
||||
continue;
|
||||
}
|
||||
skip.add(mapping);
|
||||
if (filter && !filter(mapping.data)) {
|
||||
continue;
|
||||
}
|
||||
const mapped = (0, translateOffset_1.translateOffset)(offset, mapping[fromRange], mapping[toRange], getLengths(mapping, fromRange), getLengths(mapping, toRange));
|
||||
if (mapped !== undefined) {
|
||||
yield [mapped, mapping];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*findMatchingStartEnd(start, end, fallbackToAnyMatch, fromRange, filter) {
|
||||
const toRange = fromRange == 'sourceOffsets' ? 'generatedOffsets' : 'sourceOffsets';
|
||||
const mappedStarts = [];
|
||||
let hadMatch = false;
|
||||
for (const [mappedStart, mapping] of this.findMatchingOffsets(start, fromRange)) {
|
||||
if (filter && !filter(mapping.data)) {
|
||||
continue;
|
||||
}
|
||||
mappedStarts.push([mappedStart, mapping]);
|
||||
const mappedEnd = (0, translateOffset_1.translateOffset)(end, mapping[fromRange], mapping[toRange], getLengths(mapping, fromRange), getLengths(mapping, toRange));
|
||||
if (mappedEnd !== undefined) {
|
||||
hadMatch = true;
|
||||
yield [mappedStart, mappedEnd, mapping, mapping];
|
||||
}
|
||||
}
|
||||
if (!hadMatch && fallbackToAnyMatch) {
|
||||
for (const [mappedStart, mappingStart] of mappedStarts) {
|
||||
for (const [mappedEnd, mappingEnd] of this.findMatchingOffsets(end, fromRange)) {
|
||||
if (filter && !filter(mappingEnd.data) || mappedEnd < mappedStart) {
|
||||
continue;
|
||||
}
|
||||
yield [mappedStart, mappedEnd, mappingStart, mappingEnd];
|
||||
break;
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
getMemoBasedOnRange(fromRange) {
|
||||
return fromRange === 'sourceOffsets'
|
||||
? this.sourceCodeOffsetsMemo ??= this.createMemo('sourceOffsets')
|
||||
: this.generatedCodeOffsetsMemo ??= this.createMemo('generatedOffsets');
|
||||
}
|
||||
createMemo(key) {
|
||||
const offsetsSet = new Set();
|
||||
for (const mapping of this.mappings) {
|
||||
for (let i = 0; i < mapping[key].length; i++) {
|
||||
offsetsSet.add(mapping[key][i]);
|
||||
offsetsSet.add(mapping[key][i] + getLengths(mapping, key)[i]);
|
||||
}
|
||||
}
|
||||
const offsets = [...offsetsSet].sort((a, b) => a - b);
|
||||
const mappings = offsets.map(() => new Set());
|
||||
for (const mapping of this.mappings) {
|
||||
for (let i = 0; i < mapping[key].length; i++) {
|
||||
const startIndex = (0, binarySearch_1.binarySearch)(offsets, mapping[key][i]).match;
|
||||
const endIndex = (0, binarySearch_1.binarySearch)(offsets, mapping[key][i] + getLengths(mapping, key)[i]).match;
|
||||
for (let i = startIndex; i <= endIndex; i++) {
|
||||
mappings[i].add(mapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
return { offsets, mappings };
|
||||
}
|
||||
}
|
||||
exports.SourceMap = SourceMap;
|
||||
function getLengths(mapping, key) {
|
||||
return key == 'sourceOffsets' ? mapping.lengths : mapping.generatedLengths ?? mapping.lengths;
|
||||
}
|
||||
//# sourceMappingURL=sourceMap.js.map
|
||||
1
web-app/node_modules/@volar/source-map/lib/translateOffset.d.ts
generated
vendored
Normal file
1
web-app/node_modules/@volar/source-map/lib/translateOffset.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function translateOffset(start: number, fromOffsets: number[], toOffsets: number[], fromLengths: number[], toLengths?: number[]): number | undefined;
|
||||
43
web-app/node_modules/@volar/source-map/lib/translateOffset.js
generated
vendored
Normal file
43
web-app/node_modules/@volar/source-map/lib/translateOffset.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.translateOffset = translateOffset;
|
||||
let warned = false;
|
||||
function translateOffset(start, fromOffsets, toOffsets, fromLengths, toLengths = fromLengths) {
|
||||
const isSorted = fromOffsets.every((value, index) => index === 0 || fromOffsets[index - 1] <= value);
|
||||
if (!isSorted) {
|
||||
for (let i = 0; i < fromOffsets.length; i++) {
|
||||
const fromOffset = fromOffsets[i];
|
||||
const fromLength = fromLengths[i];
|
||||
if (start >= fromOffset && start <= fromOffset + fromLength) {
|
||||
const toLength = toLengths[i];
|
||||
const toOffset = toOffsets[i];
|
||||
let rangeOffset = Math.min(start - fromOffset, toLength);
|
||||
return toOffset + rangeOffset;
|
||||
}
|
||||
}
|
||||
if (!warned) {
|
||||
warned = true;
|
||||
console.warn('fromOffsets should be sorted in ascending order');
|
||||
}
|
||||
}
|
||||
let low = 0;
|
||||
let high = fromOffsets.length - 1;
|
||||
while (low <= high) {
|
||||
const mid = Math.floor((low + high) / 2);
|
||||
const fromOffset = fromOffsets[mid];
|
||||
const fromLength = fromLengths[mid];
|
||||
if (start >= fromOffset && start <= fromOffset + fromLength) {
|
||||
const toLength = toLengths[mid];
|
||||
const toOffset = toOffsets[mid];
|
||||
let rangeOffset = Math.min(start - fromOffset, toLength);
|
||||
return toOffset + rangeOffset;
|
||||
}
|
||||
else if (start < fromOffset) {
|
||||
high = mid - 1;
|
||||
}
|
||||
else {
|
||||
low = mid + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=translateOffset.js.map
|
||||
15
web-app/node_modules/@volar/source-map/package.json
generated
vendored
Normal file
15
web-app/node_modules/@volar/source-map/package.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "@volar/source-map",
|
||||
"version": "2.4.15",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"**/*.js",
|
||||
"**/*.d.ts"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/volarjs/volar.js.git",
|
||||
"directory": "packages/source-map"
|
||||
},
|
||||
"gitHead": "adcdcbc801b284cce3239fec231c7f4cebfd8688"
|
||||
}
|
||||
Reference in New Issue
Block a user