Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
21
Frontend-Learner/node_modules/@dxup/unimport/LICENSE
generated
vendored
Normal file
21
Frontend-Learner/node_modules/@dxup/unimport/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2025-present KazariEX
|
||||
|
||||
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.
|
||||
33
Frontend-Learner/node_modules/@dxup/unimport/README.md
generated
vendored
Normal file
33
Frontend-Learner/node_modules/@dxup/unimport/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# @dxup/unimport
|
||||
|
||||
[](https://www.npmjs.com/package/@dxup/unimport)
|
||||
[](https://www.npmjs.com/package/@dxup/unimport)
|
||||
[](/LICENSE)
|
||||
|
||||
This is a TypeScript plugin that reduces user friction when using navigation features on auto imported variables generated by `unimport`. It aims to make the generated declaration files transparent to users.
|
||||
|
||||
## Features
|
||||
|
||||
- [x] Go to Definition
|
||||
- [x] Go to References
|
||||
- [x] Rename Symbol
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pnpm i -D @dxup/unimport
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Add the following to your `tsconfig.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"plugins": [
|
||||
{ "name": "@dxup/unimport" }
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
144
Frontend-Learner/node_modules/@dxup/unimport/dist/index.cjs
generated
vendored
Normal file
144
Frontend-Learner/node_modules/@dxup/unimport/dist/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
|
||||
//#region ../shared/src/index.ts
|
||||
function* forEachTouchingNode(ts, sourceFile, position) {
|
||||
yield* binaryVisit(ts, sourceFile, sourceFile, position);
|
||||
}
|
||||
function* binaryVisit(ts, sourceFile, node, position) {
|
||||
const nodes = [];
|
||||
ts.forEachChild(node, (child) => {
|
||||
nodes.push(child);
|
||||
});
|
||||
let left = 0;
|
||||
let right = nodes.length - 1;
|
||||
while (left <= right) {
|
||||
const mid = Math.floor((left + right) / 2);
|
||||
const node$1 = nodes[mid];
|
||||
if (position > node$1.getEnd()) left = mid + 1;
|
||||
else if (position < node$1.getStart(sourceFile)) right = mid - 1;
|
||||
else {
|
||||
yield node$1;
|
||||
yield* binaryVisit(ts, sourceFile, node$1, position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
function isTextSpanWithin(node, textSpan, sourceFile) {
|
||||
return textSpan.start + textSpan.length <= node.getEnd() && textSpan.start >= node.getStart(sourceFile);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/index.ts
|
||||
const plugin = (module$1) => {
|
||||
const { typescript: ts } = module$1;
|
||||
return { create(info) {
|
||||
for (const [key, method] of [
|
||||
["findRenameLocations", findRenameLocations],
|
||||
["findReferences", findReferences],
|
||||
["getDefinitionAndBoundSpan", getDefinitionAndBoundSpan]
|
||||
]) {
|
||||
const original = info.languageService[key];
|
||||
info.languageService[key] = method(ts, info, original);
|
||||
}
|
||||
return info.languageService;
|
||||
} };
|
||||
};
|
||||
var src_default = plugin;
|
||||
const declarationRE = /\.d\.(?:c|m)?ts$/;
|
||||
function createVisitor(getter) {
|
||||
return (ts, textSpan, sourceFile) => {
|
||||
for (const node of forEachTouchingNode(ts, sourceFile, textSpan.start)) if (ts.isPropertySignature(node) && node.type || ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.type) {
|
||||
const target = getter(ts, node.name, node.type, textSpan, sourceFile);
|
||||
if (target) return target;
|
||||
}
|
||||
};
|
||||
}
|
||||
const visitForwardImports = createVisitor((ts, name, type, textSpan, sourceFile) => {
|
||||
if (!isTextSpanWithin(name, textSpan, sourceFile)) return;
|
||||
while (ts.isTypeReferenceNode(type) && type.typeArguments?.length) type = type.typeArguments[0];
|
||||
if (ts.isIndexedAccessTypeNode(type)) return type.indexType;
|
||||
else if (ts.isImportTypeNode(type)) return type.qualifier ?? type.argument;
|
||||
});
|
||||
const visitBackwardImports = createVisitor((ts, name, type, textSpan, sourceFile) => {
|
||||
while (ts.isTypeReferenceNode(type) && type.typeArguments?.length) type = type.typeArguments[0];
|
||||
let target;
|
||||
if (ts.isIndexedAccessTypeNode(type)) target = type.indexType;
|
||||
else if (ts.isImportTypeNode(type)) target = type.qualifier ?? type.argument;
|
||||
else return;
|
||||
if (isTextSpanWithin(target, textSpan, sourceFile)) return name;
|
||||
});
|
||||
function findRenameLocations(ts, info, findRenameLocations$1) {
|
||||
return (...args) => {
|
||||
const result = findRenameLocations$1(...args);
|
||||
if (!result?.length) return result;
|
||||
const program = info.languageService.getProgram();
|
||||
const preferences = typeof args[4] === "object" ? args[4] : {};
|
||||
const locations = [...result];
|
||||
for (const location of result) {
|
||||
const sourceFile = program.getSourceFile(location.fileName);
|
||||
if (!sourceFile) continue;
|
||||
if (!declarationRE.test(location.fileName)) continue;
|
||||
const args$1 = [
|
||||
ts,
|
||||
location.textSpan,
|
||||
sourceFile
|
||||
];
|
||||
const node = visitForwardImports(...args$1) ?? visitBackwardImports(...args$1);
|
||||
if (!node) continue;
|
||||
const position = node.getStart(sourceFile);
|
||||
const res = findRenameLocations$1(location.fileName, position, false, false, preferences);
|
||||
if (res?.length) locations.push(...res);
|
||||
}
|
||||
return locations;
|
||||
};
|
||||
}
|
||||
function findReferences(ts, info, findReferences$1) {
|
||||
return (...args) => {
|
||||
const result = findReferences$1(...args);
|
||||
if (!result?.length) return result;
|
||||
const program = info.languageService.getProgram();
|
||||
for (const symbol of result) {
|
||||
const references = new Set(symbol.references);
|
||||
for (const reference of symbol.references) {
|
||||
const sourceFile = program.getSourceFile(reference.fileName);
|
||||
if (!sourceFile) continue;
|
||||
if (!declarationRE.test(reference.fileName)) continue;
|
||||
const node = visitBackwardImports(ts, reference.textSpan, sourceFile);
|
||||
if (!node) continue;
|
||||
const position = node.getStart(sourceFile) + 1;
|
||||
const res = info.languageService.getReferencesAtPosition(reference.fileName, position)?.filter((entry) => entry.fileName !== reference.fileName || position < entry.textSpan.start || position > entry.textSpan.start + entry.textSpan.length);
|
||||
references.delete(reference);
|
||||
for (const reference$1 of res ?? []) references.add(reference$1);
|
||||
}
|
||||
symbol.references = [...references];
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
function getDefinitionAndBoundSpan(ts, info, getDefinitionAndBoundSpan$1) {
|
||||
return (...args) => {
|
||||
const result = getDefinitionAndBoundSpan$1(...args);
|
||||
if (!result?.definitions?.length) return result;
|
||||
const program = info.languageService.getProgram();
|
||||
const definitions = new Set(result.definitions);
|
||||
for (const definition of result.definitions) {
|
||||
const sourceFile = program.getSourceFile(definition.fileName);
|
||||
if (!sourceFile) continue;
|
||||
if (!declarationRE.test(definition.fileName)) continue;
|
||||
const node = visitForwardImports(ts, definition.textSpan, sourceFile);
|
||||
if (!node) continue;
|
||||
const position = node.getStart(sourceFile);
|
||||
const res = getDefinitionAndBoundSpan$1(definition.fileName, position);
|
||||
if (res?.definitions?.length) {
|
||||
definitions.delete(definition);
|
||||
for (const definition$1 of res.definitions) definitions.add(definition$1);
|
||||
}
|
||||
}
|
||||
return {
|
||||
definitions: [...definitions],
|
||||
textSpan: result.textSpan
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
module.exports = src_default;
|
||||
5
Frontend-Learner/node_modules/@dxup/unimport/dist/index.d.cts
generated
vendored
Normal file
5
Frontend-Learner/node_modules/@dxup/unimport/dist/index.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import ts from "typescript";
|
||||
|
||||
//#region src/index.d.ts
|
||||
declare const plugin: ts.server.PluginModuleFactory;
|
||||
export = plugin;
|
||||
27
Frontend-Learner/node_modules/@dxup/unimport/package.json
generated
vendored
Normal file
27
Frontend-Learner/node_modules/@dxup/unimport/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "@dxup/unimport",
|
||||
"type": "module",
|
||||
"version": "0.1.2",
|
||||
"description": "TypeScript plugin for unimport",
|
||||
"author": "KazariEX",
|
||||
"license": "MIT",
|
||||
"repository": "KazariEX/dxup",
|
||||
"exports": {
|
||||
".": "./dist/index.cjs",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"types": "./dist/index.d.cts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@dxup/shared": "",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsdown",
|
||||
"dev": "tsdown -w --sourcemap",
|
||||
"release": "node ../../scripts/release.ts"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue