Skip to content

Commit 30f6344

Browse files
Restructuring extension local types
1 parent 9b9cd5b commit 30f6344

File tree

11 files changed

+66
-72
lines changed

11 files changed

+66
-72
lines changed

src/dataEditor/dataEditorClient.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,8 @@ import path from 'path'
6464
import * as vscode from 'vscode'
6565
import XDGAppPaths from 'xdg-app-paths'
6666
import { extractDaffodilEvent } from '../daffodilDebugger/daffodil'
67-
import {
68-
EditByteModes,
69-
VIEWPORT_CAPACITY_MAX,
70-
} from '../svelte/src/stores/configuration'
71-
import {
72-
EditorMessage,
73-
MessageCommand,
74-
MessageLevel,
75-
} from '../svelte/src/utilities/message'
67+
import { VIEWPORT_CAPACITY_MAX } from '../svelte/src/stores/configuration'
68+
import { MessageCommand, EditByteModes } from 'ext_types'
7669
import * as editor_config from './config'
7770
import { configureOmegaEditPort, ServerInfo } from './include/server/ServerInfo'
7871
import { SvelteWebviewInitializer } from './svelteWebviewInitializer'
Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,27 @@
1515
* limitations under the License.
1616
*/
1717

18-
export enum MessageCommand {
19-
clearChanges,
20-
applyChanges,
21-
editorOnChange,
22-
fileInfo,
23-
heartbeat,
24-
profile,
25-
redoChange,
26-
replaceResults,
27-
requestEditedData,
28-
save,
29-
saveAs,
30-
saveSegment,
31-
scrollViewport,
32-
search,
33-
replace,
34-
searchResults,
35-
setUITheme,
36-
showMessage,
37-
undoChange,
38-
updateLogicalDisplay,
39-
viewportRefresh,
40-
}
18+
export type Radixes = 'Hexadecimal' | 'Decimal' | 'Octal' | 'Binary'
19+
20+
export type RadixValues = 16 | 10 | 8 | 2
4121

42-
export enum MessageLevel {
43-
Error,
44-
Info,
45-
Warn,
22+
export type BytesPerRow = 16 | 8 | 24
23+
24+
export enum EditByteModes {
25+
Single = 'single',
26+
Multiple = 'multiple',
4627
}
28+
export type AvailableStrEncodings =
29+
| 'hex'
30+
| 'binary'
31+
| 'ascii'
32+
| 'latin1'
33+
| 'utf-8'
34+
| 'utf-16'
4735

48-
export type EditorMessage = {
49-
command: MessageCommand
50-
data: Record<string, any>
36+
export enum EditActionRestrictions {
37+
None,
38+
OverwriteOnly,
5139
}
40+
41+
export type EditAction = { name: string; value: EditActionRestrictions }

src/ext_types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './formattypes'
2+
export * from './messages'

src/ext_types/messages.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export enum MessageCommand {
2+
clearChanges,
3+
applyChanges,
4+
editorOnChange,
5+
fileInfo,
6+
heartbeat,
7+
profile,
8+
redoChange,
9+
replaceResults,
10+
requestEditedData,
11+
save,
12+
saveAs,
13+
saveSegment,
14+
scrollViewport,
15+
search,
16+
replace,
17+
searchResults,
18+
setUITheme,
19+
showMessage,
20+
undoChange,
21+
updateLogicalDisplay,
22+
viewportRefresh,
23+
}

src/svelte/src/App.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ limitations under the License.
4444
UIThemeCSSClass,
4545
darkUITheme,
4646
} from './utilities/colorScheme'
47-
import { MessageCommand } from './utilities/message'
47+
import { MessageCommand } from 'ext_types'
4848
import { vscode } from './utilities/vscode'
4949
import Header from './components/Header/Header.svelte'
5050
import Main from './Main.svelte'

src/svelte/src/stores/configuration.ts

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18-
export type Radixes = 'Hexadecimal' | 'Decimal' | 'Octal' | 'Binary'
19-
20-
export type RadixValues = 16 | 10 | 8 | 2
21-
22-
export type BytesPerRow = 16 | 8 | 24
23-
24-
export enum EditByteModes {
25-
Single = 'single',
26-
Multiple = 'multiple',
27-
}
18+
import type {
19+
Radixes,
20+
RadixValues,
21+
EditAction,
22+
AvailableStrEncodings,
23+
BytesPerRow,
24+
} from 'ext_types'
25+
import { EditActionRestrictions } from 'ext_types'
2826

27+
export type StrEncodingByteWidths = { [k in AvailableStrEncodings]: number }
2928
export const RADIX_OPTIONS: Record<Radixes, RadixValues> = {
3029
Hexadecimal: 16,
3130
Decimal: 10,
@@ -57,15 +56,6 @@ export const ENCODING_GROUPS = [
5756
},
5857
]
5958

60-
export type AvailableStrEncodings =
61-
| 'hex'
62-
| 'binary'
63-
| 'ascii'
64-
| 'latin1'
65-
| 'utf-8'
66-
| 'utf-16'
67-
68-
export type StrEncodingByteWidths = { [k in AvailableStrEncodings]: number }
6959
export const StrEncodingByteWidths: StrEncodingByteWidths = {
7060
hex: 1,
7161
binary: 1,
@@ -75,12 +65,6 @@ export const StrEncodingByteWidths: StrEncodingByteWidths = {
7565
'utf-16': 2 | 4,
7666
}
7767

78-
export enum EditActionRestrictions {
79-
None,
80-
OverwriteOnly,
81-
}
82-
83-
export type EditAction = { name: string; value: EditActionRestrictions }
8468
export const EDIT_ACTIONS: EditAction[] = [
8569
{ name: 'Delete, Insert, and Overwrite', value: EditActionRestrictions.None },
8670
{ name: 'Overwrite Only', value: EditActionRestrictions.OverwriteOnly },

src/svelte/tsconfig.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
{
19-
"extends": "@tsconfig/svelte/tsconfig.json",
19+
"extends": "../../tsconfig.json",
2020
"compilerOptions": {
2121
"allowImportingTsExtensions": true,
2222
"noEmit": true,
@@ -26,19 +26,17 @@
2626
"utilities": ["utilities"],
2727
"layout/*": ["components/layouts/*"],
2828
"HTMLWrappers/*": ["components/html/*"],
29-
"editor_components/*": ["components/sections/*"]
29+
"editor_components/*": ["components/sections/*"],
30+
"ext_types": ["../../ext_types"]
3031
},
31-
// "allowImportingTsExtensions": true,
32-
"target": "ES6",
3332
"useDefineForClassFields": true,
34-
"module": "commonjs",
3533
"resolveJsonModule": true,
3634
"allowJs": true,
3735
"checkJs": true,
3836
"isolatedModules": true,
3937
"outDir": "tsout",
4038
"esModuleInterop": true,
41-
"verbatimModuleSyntax": true
39+
// "verbatimModuleSyntax": true
4240
},
4341
"include": ["src/**/*.ts", "src/**/*.svelte", "src/tests/**/*.test.ts"],
4442
"exclude": ["node_modules/*"],

src/svelte/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717

1818
/// <reference types="svelte" />
1919
/// <reference types="vite/client" />
20+
/// <reference types="../dfdl-types" />

src/svelte/vite.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default defineConfig(({ mode }) => {
4646
layout: path.resolve(__dirname, 'src/components/layouts'),
4747
HTMLWrappers: path.resolve(__dirname, 'src/components/html'),
4848
editor_components: path.resolve(__dirname, 'src/components/sections'),
49+
ext_types: path.resolve('../../ext_types'),
4950
},
5051
},
5152
plugins: [

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"dataEditor": ["dataEditor"],
5050
"language":["language"],
5151
"launchWizard": ["launchWizard/launchWizard"],
52-
"infoset":["infoset"]
52+
"infoset":["infoset"],
53+
"ext_types": ["ext_types"]
5354
}
5455
},
5556
"include": ["src/**/*"],

0 commit comments

Comments
 (0)