@akanjs/language 0.0.0-stage → 3.1.2-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +42 -0
- package/README.md +41 -2
- package/akanIndex.d.ts +41 -0
- package/ast.d.ts +16 -0
- package/index.cjs +1076 -0
- package/index.d.ts +4 -0
- package/index.js +1034 -0
- package/moduleFacts.d.ts +68 -0
- package/nameTable.d.ts +28 -0
- package/package.json +35 -4
package/README.ko.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @akanjs/language
|
|
2
|
+
|
|
3
|
+
[English](https://github.com/akan-team/akanjs/blob/main/pkgs/@akanjs/language/README.md) | [문서](https://akanjs.com/docs) | [npm](https://www.npmjs.com/package/@akanjs/language) | [런타임](https://www.npmjs.com/package/akanjs)
|
|
4
|
+
|
|
5
|
+
Akan.js 에디터 지원 밑에 있는, 에디터와 무관한 색인입니다.
|
|
6
|
+
|
|
7
|
+
Akan.js는 원본 키 하나에서 여러 이름을 만듭니다. `memo`의 slice 키 `inPublic`은 `fetch.initMemoInPublic`과
|
|
8
|
+
`st.use.memoListInPublic`이 되고, 필드 `name`은 `st.do.setNameOnMemo`, Filter 쿼리 키 `byName`은 `listByName`이
|
|
9
|
+
됩니다. TypeScript는 이런 이름의 선언을 남기지 않습니다. `@akanjs/language`는 워크스페이스의 constant, document,
|
|
10
|
+
service, signal, store 파일을 문법만으로 읽고, 합성된 이름마다 원본 키를 찾아 줍니다.
|
|
11
|
+
|
|
12
|
+
에디터 연동용 패키지이며, 앱 코드에서는 import하지 않습니다.
|
|
13
|
+
|
|
14
|
+
## 설치
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bun add -d @akanjs/language typescript
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 사용 예시
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { AkanIndex } from "@akanjs/language";
|
|
24
|
+
import ts from "typescript";
|
|
25
|
+
|
|
26
|
+
const index = new AkanIndex({ ts, root: "/path/to/workspace" });
|
|
27
|
+
index.setFile(fileName, text);
|
|
28
|
+
|
|
29
|
+
index.definitionAt(fileName, text, offset);
|
|
30
|
+
index.hoverAt(fileName, text, offset);
|
|
31
|
+
index.referencesAt(fileName, offset, readText);
|
|
32
|
+
index.sourceKeysOf(fileName);
|
|
33
|
+
index.renameAt(fileName, offset, "inFeed", readText);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
호스트가 쓰는 `typescript`를 넘기세요. 이 패키지는 TypeScript를 번들하지 않으며, 사본이 둘이면 `SyntaxKind` 숫자가
|
|
37
|
+
어긋납니다. `apps/**`와 `libs/**`의 TypeScript 파일을 모두 `setFile`로 넣고, 파일이 바뀌면 `setFile`을 다시 부르거나
|
|
38
|
+
`removeFile`을 부르세요. 파일 이름의 구분자는 `\`와 `/` 어느 쪽이든 되고, `readText`에 넘기는 이름과 span의 이름은 `/`를
|
|
39
|
+
씁니다. 이름은 자기 앱과 모든 lib 안에서만 풀리고, 다른 앱으로는 가지 않습니다. `renameAt`은 slice 키나 쿼리 키를, 그
|
|
40
|
+
키에서 만들어진 이름 전부와 모듈 dictionary의 키와 함께 바꾸는 편집을 돌려줍니다.
|
|
41
|
+
|
|
42
|
+
ES module과 CommonJS로 배포하며, 런타임 의존성은 없습니다.
|
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @akanjs/language
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[한국어](https://github.com/akan-team/akanjs/blob/main/pkgs/@akanjs/language/README.ko.md) | [Docs](https://akanjs.com/docs) | [npm](https://www.npmjs.com/package/@akanjs/language) | [Runtime](https://www.npmjs.com/package/akanjs)
|
|
4
|
+
|
|
5
|
+
The editor-neutral index behind Akan.js editor support.
|
|
6
|
+
|
|
7
|
+
Akan.js builds many names from one source key: the slice key `inPublic` on `memo` becomes `fetch.initMemoInPublic`
|
|
8
|
+
and `st.use.memoListInPublic`, a field `name` becomes `st.do.setNameOnMemo`, and a Filter query key `byName` becomes
|
|
9
|
+
`listByName`. TypeScript keeps no declaration for such names. `@akanjs/language` reads a workspace's constant,
|
|
10
|
+
document, service, signal and store files by syntax alone and maps each derived name back to its source key.
|
|
11
|
+
|
|
12
|
+
It is for editor integrations. Apps never import it.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bun add -d @akanjs/language typescript
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { AkanIndex } from "@akanjs/language";
|
|
24
|
+
import ts from "typescript";
|
|
25
|
+
|
|
26
|
+
const index = new AkanIndex({ ts, root: "/path/to/workspace" });
|
|
27
|
+
index.setFile(fileName, text);
|
|
28
|
+
|
|
29
|
+
index.definitionAt(fileName, text, offset);
|
|
30
|
+
index.hoverAt(fileName, text, offset);
|
|
31
|
+
index.referencesAt(fileName, offset, readText);
|
|
32
|
+
index.sourceKeysOf(fileName);
|
|
33
|
+
index.renameAt(fileName, offset, "inFeed", readText);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Pass the host's own `typescript`: the package bundles none, and two copies would disagree on `SyntaxKind` numbers.
|
|
37
|
+
Feed every `apps/**` and `libs/**` TypeScript file to `setFile`, then call `setFile` again or `removeFile` as files
|
|
38
|
+
change. File names may use either separator; `readText` is called with, and every span carries, forward slashes. A
|
|
39
|
+
name resolves within its own app and every lib, never another app. `renameAt` returns the edits that rename a slice or
|
|
40
|
+
query key together with every name derived from it and its key in the module dictionary.
|
|
41
|
+
|
|
42
|
+
The package ships as an ES module and as CommonJS, with no runtime dependency.
|
package/akanIndex.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Ts } from "./ast";
|
|
2
|
+
import { type AkanSpan } from "./moduleFacts";
|
|
3
|
+
import { type AkanFamily, type AkanTarget } from "./nameTable";
|
|
4
|
+
export interface AkanIndexOptions {
|
|
5
|
+
ts: Ts;
|
|
6
|
+
root: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AkanHover {
|
|
9
|
+
name: string;
|
|
10
|
+
targets: AkanTarget[];
|
|
11
|
+
}
|
|
12
|
+
export interface AkanRenameEdit {
|
|
13
|
+
span: AkanSpan;
|
|
14
|
+
newText: string;
|
|
15
|
+
}
|
|
16
|
+
export interface AkanSourceKey {
|
|
17
|
+
family: AkanFamily;
|
|
18
|
+
sourceKey: string;
|
|
19
|
+
label: string;
|
|
20
|
+
detail: string[];
|
|
21
|
+
span: AkanSpan;
|
|
22
|
+
}
|
|
23
|
+
export declare class AkanIndex {
|
|
24
|
+
#private;
|
|
25
|
+
constructor({ ts, root }: AkanIndexOptions);
|
|
26
|
+
static isSourcePath(fileName: string): boolean;
|
|
27
|
+
get fileCount(): number;
|
|
28
|
+
setFile(givenName: string, text: string): void;
|
|
29
|
+
removeFile(givenName: string): void;
|
|
30
|
+
definitionAt(givenName: string, text: string, offset: number): AkanTarget[];
|
|
31
|
+
hoverAt(givenName: string, text: string, offset: number): AkanHover | null;
|
|
32
|
+
sourceKeysOf(givenName: string): AkanSourceKey[];
|
|
33
|
+
sourceKeyAt(givenName: string, offset: number): AkanSourceKey | null;
|
|
34
|
+
referencesAt(givenName: string, offset: number, readText: (fileName: string) => string | undefined): AkanSpan[];
|
|
35
|
+
renameTargetAt(givenName: string, offset: number): {
|
|
36
|
+
family: AkanFamily;
|
|
37
|
+
sourceKey: string;
|
|
38
|
+
span: AkanSpan;
|
|
39
|
+
} | null;
|
|
40
|
+
renameAt(givenName: string, offset: number, newKey: string, readText: (fileName: string) => string | undefined): AkanRenameEdit[] | null;
|
|
41
|
+
}
|
package/ast.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type * as TS from "typescript";
|
|
2
|
+
export type Ts = typeof TS;
|
|
3
|
+
export declare const createAst: (ts: Ts) => {
|
|
4
|
+
sourceFileFor: (fileName: string, content: string, scriptKind?: TS.ScriptKind) => TS.SourceFile;
|
|
5
|
+
nodeName: (node: TS.PropertyName | TS.BindingName | undefined) => string | null;
|
|
6
|
+
propertyName: (node: TS.ObjectLiteralElementLike) => string | null;
|
|
7
|
+
expressionName: (expression: TS.Expression) => string | null;
|
|
8
|
+
callExpressionName: (node: TS.CallExpression) => string | null;
|
|
9
|
+
firstObjectReturnedByArrow: (node: TS.Node) => TS.ObjectLiteralExpression | null;
|
|
10
|
+
heritageCallNamed: (node: TS.ClassDeclaration, names: ReadonlySet<string>) => {
|
|
11
|
+
callee: string;
|
|
12
|
+
call: TS.CallExpression;
|
|
13
|
+
} | null;
|
|
14
|
+
heritageCall: (node: TS.ClassDeclaration) => TS.CallExpression | null;
|
|
15
|
+
};
|
|
16
|
+
export type AkanAst = ReturnType<typeof createAst>;
|