Skip to content

Commit ed10754

Browse files
authored
fix(editor): remove ts dependency (#99)
* fix(editor): remote ts dependency * feat: preset code * feat: remove ts dependencies * feat: add vite bundle analyse * feat: ts license
1 parent 4c688ff commit ed10754

File tree

14 files changed

+233
-20
lines changed

14 files changed

+233
-20
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze-editor/code-language-typescript",
5+
"comment": "remote ts dependency",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@coze-editor/code-language-typescript",
10+
"email": "[email protected]"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze-editor/code-language-typescript",
5+
"comment": "remove ts dependencies",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@coze-editor/code-language-typescript",
10+
"email": "[email protected]"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze-editor/code-language-typescript",
5+
"comment": "ts license",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@coze-editor/code-language-typescript",
10+
"email": "[email protected]"
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@coze-editor/preset-code",
5+
"comment": "preset code",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@coze-editor/preset-code",
10+
"email": "[email protected]"
11+
}

common/config/subspaces/default/pnpm-lock.yaml

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/text-editor/code-language-typescript/src/as.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// SPDX-License-Identifier: MIT
33

44
import { CompletionItemKind } from 'vscode-languageserver-types';
5-
import { ScriptElementKind } from 'typescript';
5+
6+
import { ScriptElementKind } from './ts-enums';
67

78
/*
89
* Copyright (C) 2018 TypeFox and others.

packages/text-editor/code-language-typescript/src/service.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import {
1111
} from 'vscode-languageserver-types';
1212
import {
1313
type CompletionEntryDetails,
14-
DiagnosticCategory,
15-
displayPartsToString,
1614
type FormatCodeSettings,
1715
} from 'typescript';
1816
import mitt from 'mitt';
@@ -29,8 +27,9 @@ import type {
2927
TransactionSpec,
3028
} from '@codemirror/state';
3129

32-
import { tagToString } from './utils';
30+
import { displayPartsToString, tagToString } from './utils';
3331
import type { InitializeOptions, ITypeScriptWorker } from './types';
32+
import { DiagnosticCategory } from './ts-enums';
3433
import { asCompletionItemKind } from './as';
3534

3635
function isDiagnostic(v: unknown): v is Diagnostic {
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
16+
export enum ScriptElementKind {
17+
unknown = '',
18+
warning = 'warning',
19+
/** predefined type (void) or keyword (class) */
20+
keyword = 'keyword',
21+
/** top level script node */
22+
scriptElement = 'script',
23+
/** module foo {} */
24+
moduleElement = 'module',
25+
/** class X {} */
26+
classElement = 'class',
27+
/** var x = class X {} */
28+
localClassElement = 'local class',
29+
/** interface Y {} */
30+
interfaceElement = 'interface',
31+
/** type T = ... */
32+
typeElement = 'type',
33+
/** enum E */
34+
enumElement = 'enum',
35+
enumMemberElement = 'enum member',
36+
/**
37+
* Inside module and script only
38+
* const v = ..
39+
*/
40+
variableElement = 'var',
41+
/** Inside function */
42+
localVariableElement = 'local var',
43+
/** using foo = ... */
44+
variableUsingElement = 'using',
45+
/** await using foo = ... */
46+
variableAwaitUsingElement = 'await using',
47+
/**
48+
* Inside module and script only
49+
* function f() { }
50+
*/
51+
functionElement = 'function',
52+
/** Inside function */
53+
localFunctionElement = 'local function',
54+
/** class X { [public|private]* foo() {} } */
55+
memberFunctionElement = 'method',
56+
/** class X { [public|private]* [get|set] foo:number; } */
57+
memberGetAccessorElement = 'getter',
58+
memberSetAccessorElement = 'setter',
59+
/**
60+
* class X { [public|private]* foo:number; }
61+
* interface Y { foo:number; }
62+
*/
63+
memberVariableElement = 'property',
64+
/** class X { [public|private]* accessor foo: number; } */
65+
memberAccessorVariableElement = 'accessor',
66+
/**
67+
* class X { constructor() { } }
68+
* class X { static { } }
69+
*/
70+
constructorImplementationElement = 'constructor',
71+
/** interface Y { ():number; } */
72+
callSignatureElement = 'call',
73+
/** interface Y { []:number; } */
74+
indexSignatureElement = 'index',
75+
/** interface Y { new():Y; } */
76+
constructSignatureElement = 'construct',
77+
/** function foo(*Y*: string) */
78+
parameterElement = 'parameter',
79+
typeParameterElement = 'type parameter',
80+
primitiveType = 'primitive type',
81+
label = 'label',
82+
alias = 'alias',
83+
constElement = 'const',
84+
letElement = 'let',
85+
directory = 'directory',
86+
externalModuleName = 'external module name',
87+
/**
88+
* <JsxTagName attribute1 attribute2={0} />
89+
* @deprecated
90+
*/
91+
jsxAttribute = 'JSX attribute',
92+
/** String literal */
93+
string = 'string',
94+
/** Jsdoc @link: in `{@link C link text}`, the before and after text "{@link " and "}" */
95+
link = 'link',
96+
/** Jsdoc @link: in `{@link C link text}`, the entity name "C" */
97+
linkName = 'link name',
98+
/** Jsdoc @link: in `{@link C link text}`, the link text "link text" */
99+
linkText = 'link text',
100+
}
101+
102+
export enum DiagnosticCategory {
103+
Warning = 0,
104+
Error = 1,
105+
Suggestion = 2,
106+
Message = 3,
107+
}

packages/text-editor/code-language-typescript/src/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: MIT
33

44
import type ts from 'typescript';
5+
import { type SymbolDisplayPart } from 'typescript';
56

67
function tagToString(tag: ts.JSDocTagInfo): string {
78
let tagLabel = `*@${tag.name}*`;
@@ -19,4 +20,11 @@ function tagToString(tag: ts.JSDocTagInfo): string {
1920
return tagLabel;
2021
}
2122

22-
export { tagToString };
23+
function displayPartsToString(displayParts?: SymbolDisplayPart[]) {
24+
if (displayParts) {
25+
return displayParts.map(displayPart2 => displayPart2.text).join('');
26+
}
27+
return '';
28+
}
29+
30+
export { tagToString, displayPartsToString };

packages/text-editor/dev/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"tailwindcss": "~3.3.3",
5252
"typescript": "^5.8.2",
5353
"typescript-eslint": "^8.30.1",
54-
"vite": "^6.3.5"
54+
"vite": "^6.3.5",
55+
"vite-bundle-analyzer": "~1.2.1"
5556
}
5657
}

0 commit comments

Comments
 (0)