From f1df0a51b6417fc4b55ea084493a72e0f9c57cdb Mon Sep 17 00:00:00 2001 From: solufa Date: Wed, 10 Jul 2024 22:26:05 +0900 Subject: [PATCH] refactor: set esm to libs --- libs/ansi-parser/interfaces/ansi-action.d.ts | 2 +- libs/ansi-parser/package.json | 1 + libs/ansi-parser/src/color-index-of.ts | 2 +- libs/ansi-parser/src/controll-actions.ts | 2 +- libs/ansi-parser/src/decode-ansi-byte.ts | 10 +++++----- libs/ansi-parser/src/decode-ansi-bytes.ts | 6 +++--- libs/ansi-parser/src/decode-ansi-color-8bit.ts | 2 +- libs/ansi-parser/src/decode-ansi-string.ts | 6 +++--- libs/ansi-parser/src/default-ansi-parser.ts | 2 +- libs/ansi-parser/src/encode-ansi-action.ts | 4 ++-- libs/ansi-parser/src/index.ts | 14 +++++++------- .../test/encode-decode-is-inverse-in-ascii.spec.ts | 6 +++--- libs/ansi-parser/test/known-sequences.spec.ts | 6 +++--- .../ansi-parser/test/leading-zeros-ignored.spec.ts | 4 ++-- libs/ansi-parser/test/unknown-sequences.spec.ts | 4 ++-- libs/ansi-parser/tsconfig.json | 14 ++++---------- libs/notios-config/package.json | 1 + libs/notios-config/src/define_notios_config.ts | 2 +- libs/notios-config/src/index.ts | 2 +- libs/notios-config/src/interfaces/notios-config.ts | 2 +- libs/notios-config/tsconfig.json | 14 ++++---------- package.json | 2 +- src/constants/default_config.ts | 2 +- src/utils/error.ts | 4 ++++ 24 files changed, 54 insertions(+), 60 deletions(-) diff --git a/libs/ansi-parser/interfaces/ansi-action.d.ts b/libs/ansi-parser/interfaces/ansi-action.d.ts index fc93932..2f770c3 100644 --- a/libs/ansi-parser/interfaces/ansi-action.d.ts +++ b/libs/ansi-parser/interfaces/ansi-action.d.ts @@ -1,4 +1,4 @@ -import { AnsiActionControll } from './ansi-controll-action'; +import { AnsiActionControll } from './ansi-controll-action.d.ts'; export type AnsiAction = | AnsiActionNoop diff --git a/libs/ansi-parser/package.json b/libs/ansi-parser/package.json index ae20d38..13f5c45 100644 --- a/libs/ansi-parser/package.json +++ b/libs/ansi-parser/package.json @@ -1,6 +1,7 @@ { "name": "ansi-parser", "version": "0.0.0", + "type": "module", "description": "", "private": true, "keywords": [ diff --git a/libs/ansi-parser/src/color-index-of.ts b/libs/ansi-parser/src/color-index-of.ts index fbce0dd..a6b20f3 100644 --- a/libs/ansi-parser/src/color-index-of.ts +++ b/libs/ansi-parser/src/color-index-of.ts @@ -1,4 +1,4 @@ -import { ColorName } from '../interfaces/ansi-action'; +import { ColorName } from '../interfaces/ansi-action.js'; const colorIndexOf = (colorName: ColorName) => { switch (colorName) { diff --git a/libs/ansi-parser/src/controll-actions.ts b/libs/ansi-parser/src/controll-actions.ts index 859e5a5..9da997c 100644 --- a/libs/ansi-parser/src/controll-actions.ts +++ b/libs/ansi-parser/src/controll-actions.ts @@ -31,7 +31,7 @@ import type { AnsiActionControll1d, AnsiActionControll1e, AnsiActionControll1f, -} from '../interfaces/ansi-controll-action'; +} from '../interfaces/ansi-controll-action.js'; /** * Action for controll character NUL(0x00). diff --git a/libs/ansi-parser/src/decode-ansi-byte.ts b/libs/ansi-parser/src/decode-ansi-byte.ts index 4b3a7a9..4c42029 100644 --- a/libs/ansi-parser/src/decode-ansi-byte.ts +++ b/libs/ansi-parser/src/decode-ansi-byte.ts @@ -1,8 +1,8 @@ -import type { AnsiAction } from '../interfaces/ansi-action'; -import type { AnsiParser } from '../interfaces/ansi-parser'; -import { ansiActionControllList } from './controll-actions'; -import decodeAnsiColor8bit from './decode-ansi-color-8bit'; -import { defaultAnsiParser } from './default-ansi-parser'; +import type { AnsiAction } from '../interfaces/ansi-action.js'; +import type { AnsiParser } from '../interfaces/ansi-parser.js'; +import { ansiActionControllList } from './controll-actions.js'; +import decodeAnsiColor8bit from './decode-ansi-color-8bit.js'; +import { defaultAnsiParser } from './default-ansi-parser.js'; const lessThan256 = (n: string) => { if (n.length < 3) return true; diff --git a/libs/ansi-parser/src/decode-ansi-bytes.ts b/libs/ansi-parser/src/decode-ansi-bytes.ts index 66a2b8a..dccab9e 100644 --- a/libs/ansi-parser/src/decode-ansi-bytes.ts +++ b/libs/ansi-parser/src/decode-ansi-bytes.ts @@ -1,6 +1,6 @@ -import type { AnsiAction } from '../interfaces/ansi-action'; -import type { AnsiParser } from '../interfaces/ansi-parser'; -import decodeAnsiByte from './decode-ansi-byte'; +import type { AnsiAction } from '../interfaces/ansi-action.js'; +import type { AnsiParser } from '../interfaces/ansi-parser.js'; +import decodeAnsiByte from './decode-ansi-byte.js'; const decodeAnsiBytes = ( parser: AnsiParser, diff --git a/libs/ansi-parser/src/decode-ansi-color-8bit.ts b/libs/ansi-parser/src/decode-ansi-color-8bit.ts index c67ea37..cefdab6 100644 --- a/libs/ansi-parser/src/decode-ansi-color-8bit.ts +++ b/libs/ansi-parser/src/decode-ansi-color-8bit.ts @@ -1,4 +1,4 @@ -import { AnsiColor8bit } from '../interfaces/ansi-action'; +import { AnsiColor8bit } from '../interfaces/ansi-action.js'; const decodeAnsiColor8bit = (n: number): AnsiColor8bit => { if (n < 16) { diff --git a/libs/ansi-parser/src/decode-ansi-string.ts b/libs/ansi-parser/src/decode-ansi-string.ts index 4870e2f..d3aafff 100644 --- a/libs/ansi-parser/src/decode-ansi-string.ts +++ b/libs/ansi-parser/src/decode-ansi-string.ts @@ -1,6 +1,6 @@ -import type { AnsiAction } from '../interfaces/ansi-action'; -import type { AnsiParser } from '../interfaces/ansi-parser'; -import decodeAnsiByte from './decode-ansi-byte'; +import type { AnsiAction } from '../interfaces/ansi-action.js'; +import type { AnsiParser } from '../interfaces/ansi-parser.js'; +import decodeAnsiByte from './decode-ansi-byte.js'; const decodeAnsiString = (parser: AnsiParser, str: string): [newParser: AnsiParser, actions: readonly AnsiAction[]] => { let p = parser; diff --git a/libs/ansi-parser/src/default-ansi-parser.ts b/libs/ansi-parser/src/default-ansi-parser.ts index dcc6d7f..351851a 100644 --- a/libs/ansi-parser/src/default-ansi-parser.ts +++ b/libs/ansi-parser/src/default-ansi-parser.ts @@ -1,4 +1,4 @@ -import { AnsiParser } from '../interfaces/ansi-parser'; +import { AnsiParser } from '../interfaces/ansi-parser.js'; export const defaultAnsiParser = (): AnsiParser => { return { diff --git a/libs/ansi-parser/src/encode-ansi-action.ts b/libs/ansi-parser/src/encode-ansi-action.ts index 438e8c8..6c3c7fd 100644 --- a/libs/ansi-parser/src/encode-ansi-action.ts +++ b/libs/ansi-parser/src/encode-ansi-action.ts @@ -1,5 +1,5 @@ -import { AnsiAction } from '../interfaces/ansi-action'; -import colorIndexOf from './color-index-of'; +import { AnsiAction } from '../interfaces/ansi-action.js'; +import colorIndexOf from './color-index-of.js'; const encodeInteger = (s: string): Uint8Array => { return Uint8Array.from([...s].map((c) => c.charCodeAt(0))); diff --git a/libs/ansi-parser/src/index.ts b/libs/ansi-parser/src/index.ts index 56b3d50..af667ba 100644 --- a/libs/ansi-parser/src/index.ts +++ b/libs/ansi-parser/src/index.ts @@ -1,7 +1,7 @@ -export { default as colorIndexOf } from './color-index-of'; -export { default as decodeAnsiByte } from './decode-ansi-byte'; -export { default as decodeAnsiBytes } from './decode-ansi-bytes'; -export { default as decodeAnsiColor8bit } from './decode-ansi-color-8bit'; -export { default as decodeAnsiString } from './decode-ansi-string'; -export { default as defaultAnsiParser } from './default-ansi-parser'; -export { default as encodeAnsiAction } from './encode-ansi-action'; +export { default as colorIndexOf } from './color-index-of.js'; +export { default as decodeAnsiByte } from './decode-ansi-byte.js'; +export { default as decodeAnsiBytes } from './decode-ansi-bytes.js'; +export { default as decodeAnsiColor8bit } from './decode-ansi-color-8bit.js'; +export { default as decodeAnsiString } from './decode-ansi-string.js'; +export { default as defaultAnsiParser } from './default-ansi-parser.js'; +export { default as encodeAnsiAction } from './encode-ansi-action.js'; diff --git a/libs/ansi-parser/test/encode-decode-is-inverse-in-ascii.spec.ts b/libs/ansi-parser/test/encode-decode-is-inverse-in-ascii.spec.ts index 4ddc0f7..c940d40 100644 --- a/libs/ansi-parser/test/encode-decode-is-inverse-in-ascii.spec.ts +++ b/libs/ansi-parser/test/encode-decode-is-inverse-in-ascii.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from 'vitest'; -import decodeAnsiBytes from '../src/decode-ansi-bytes'; -import defaultAnsiParser from '../src/default-ansi-parser'; -import encodeAnsiBytes from '../src/encode-ansi-action'; +import decodeAnsiBytes from '../src/decode-ansi-bytes.js'; +import defaultAnsiParser from '../src/default-ansi-parser.js'; +import encodeAnsiBytes from '../src/encode-ansi-action.js'; type SimpleCase = { s: string; diff --git a/libs/ansi-parser/test/known-sequences.spec.ts b/libs/ansi-parser/test/known-sequences.spec.ts index d58bb89..4de26bb 100644 --- a/libs/ansi-parser/test/known-sequences.spec.ts +++ b/libs/ansi-parser/test/known-sequences.spec.ts @@ -1,7 +1,7 @@ import { expect, test } from 'vitest'; -import { AnsiAction } from '../interfaces/ansi-action'; -import decodeAnsiBytes from '../src/decode-ansi-bytes'; -import defaultAnsiParser from '../src/default-ansi-parser'; +import { AnsiAction } from '../interfaces/ansi-action.js'; +import decodeAnsiBytes from '../src/decode-ansi-bytes.js'; +import defaultAnsiParser from '../src/default-ansi-parser.js'; type Case = { s: string; diff --git a/libs/ansi-parser/test/leading-zeros-ignored.spec.ts b/libs/ansi-parser/test/leading-zeros-ignored.spec.ts index bfc8798..b2bcbdd 100644 --- a/libs/ansi-parser/test/leading-zeros-ignored.spec.ts +++ b/libs/ansi-parser/test/leading-zeros-ignored.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from 'vitest'; -import decodeAnsiBytes from '../src/decode-ansi-bytes'; -import defaultAnsiParser from '../src/default-ansi-parser'; +import decodeAnsiBytes from '../src/decode-ansi-bytes.js'; +import defaultAnsiParser from '../src/default-ansi-parser.js'; type SameCheckCase = { s: string; diff --git a/libs/ansi-parser/test/unknown-sequences.spec.ts b/libs/ansi-parser/test/unknown-sequences.spec.ts index 5dce1f7..317e60a 100644 --- a/libs/ansi-parser/test/unknown-sequences.spec.ts +++ b/libs/ansi-parser/test/unknown-sequences.spec.ts @@ -1,6 +1,6 @@ import { expect, test } from 'vitest'; -import decodeAnsiBytes from '../src/decode-ansi-bytes'; -import defaultAnsiParser from '../src/default-ansi-parser'; +import decodeAnsiBytes from '../src/decode-ansi-bytes.js'; +import defaultAnsiParser from '../src/default-ansi-parser.js'; type Case = { s: string; diff --git a/libs/ansi-parser/tsconfig.json b/libs/ansi-parser/tsconfig.json index f196f82..4e10b3a 100644 --- a/libs/ansi-parser/tsconfig.json +++ b/libs/ansi-parser/tsconfig.json @@ -1,19 +1,13 @@ { "compilerOptions": { "esModuleInterop": true, - "module": "CommonJS", - "moduleResolution": "Node", + "module": "Node16", + "moduleResolution": "Node16", "skipLibCheck": true, "strict": true, "target": "ES2015", "incremental": true }, - "exclude": [ - "node_modules", - "test" - ], - "include": [ - "**/*.ts", - "**/*.tsx" - ] + "exclude": ["node_modules", "test"], + "include": ["**/*.ts", "**/*.tsx"] } diff --git a/libs/notios-config/package.json b/libs/notios-config/package.json index 7a3bfde..36b3ca8 100644 --- a/libs/notios-config/package.json +++ b/libs/notios-config/package.json @@ -1,6 +1,7 @@ { "name": "@notios/config", "version": "0.2.0", + "type": "module", "description": "Notios configuration tools", "keywords": [ "notios", diff --git a/libs/notios-config/src/define_notios_config.ts b/libs/notios-config/src/define_notios_config.ts index cc448c0..c008a0b 100644 --- a/libs/notios-config/src/define_notios_config.ts +++ b/libs/notios-config/src/define_notios_config.ts @@ -1,4 +1,4 @@ -import { NotiosConfig } from './interfaces/notios-config'; +import { NotiosConfig } from './interfaces/notios-config.js'; export type ConfigFn = (defaultConfig: NotiosConfig) => NotiosConfig; diff --git a/libs/notios-config/src/index.ts b/libs/notios-config/src/index.ts index e6284ef..053c0f3 100644 --- a/libs/notios-config/src/index.ts +++ b/libs/notios-config/src/index.ts @@ -1 +1 @@ -export { default as defineNotiosConfig } from './define_notios_config'; +export { default as defineNotiosConfig } from './define_notios_config.js'; diff --git a/libs/notios-config/src/interfaces/notios-config.ts b/libs/notios-config/src/interfaces/notios-config.ts index aa9782a..79a3eb2 100644 --- a/libs/notios-config/src/interfaces/notios-config.ts +++ b/libs/notios-config/src/interfaces/notios-config.ts @@ -18,7 +18,7 @@ import { NotiosInspectProcAction, NotiosSelectScriptAction, NotiosTreeProcsAction, -} from '../action_definitions'; +} from '../action_definitions.js'; type NotiosConfigKeymappingSpecialNoMod = { type: 'special'; diff --git a/libs/notios-config/tsconfig.json b/libs/notios-config/tsconfig.json index f196f82..4e10b3a 100644 --- a/libs/notios-config/tsconfig.json +++ b/libs/notios-config/tsconfig.json @@ -1,19 +1,13 @@ { "compilerOptions": { "esModuleInterop": true, - "module": "CommonJS", - "moduleResolution": "Node", + "module": "Node16", + "moduleResolution": "Node16", "skipLibCheck": true, "strict": true, "target": "ES2015", "incremental": true }, - "exclude": [ - "node_modules", - "test" - ], - "include": [ - "**/*.ts", - "**/*.tsx" - ] + "exclude": ["node_modules", "test"], + "include": ["**/*.ts", "**/*.tsx"] } diff --git a/package.json b/package.json index 347b1cb..90a79c9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "notios", - "type": "module", "version": "0.4.1", + "type": "module", "description": "", "keywords": [ "notios", diff --git a/src/constants/default_config.ts b/src/constants/default_config.ts index 8c4b383..034ed34 100644 --- a/src/constants/default_config.ts +++ b/src/constants/default_config.ts @@ -450,7 +450,7 @@ const defaultConfigOriginal = { // typecheck () => - defineNotiosConfig.default((d) => ({ + defineNotiosConfig((d) => ({ ...d, ...defaultConfigOriginal, v1: { diff --git a/src/utils/error.ts b/src/utils/error.ts index 27d2c79..4c7446a 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -1,9 +1,13 @@ +import assert from 'assert'; + export const hintSymbol = Symbol('error hint'); export const tryWithHint = (f: () => T, hint: string): T => { try { return f(); } catch (e: unknown) { + assert(e instanceof Error); + throw Object.assign(e, { [hintSymbol]: hint, });