Skip to content

Commit

Permalink
refactor: set esm to libs
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jul 10, 2024
1 parent 445ac84 commit f1df0a5
Show file tree
Hide file tree
Showing 24 changed files with 54 additions and 60 deletions.
2 changes: 1 addition & 1 deletion libs/ansi-parser/interfaces/ansi-action.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnsiActionControll } from './ansi-controll-action';
import { AnsiActionControll } from './ansi-controll-action.d.ts';

export type AnsiAction =
| AnsiActionNoop
Expand Down
1 change: 1 addition & 0 deletions libs/ansi-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "ansi-parser",
"version": "0.0.0",
"type": "module",
"description": "",
"private": true,
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion libs/ansi-parser/src/color-index-of.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ColorName } from '../interfaces/ansi-action';
import { ColorName } from '../interfaces/ansi-action.js';

const colorIndexOf = (colorName: ColorName) => {
switch (colorName) {
Expand Down
2 changes: 1 addition & 1 deletion libs/ansi-parser/src/controll-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
10 changes: 5 additions & 5 deletions libs/ansi-parser/src/decode-ansi-byte.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions libs/ansi-parser/src/decode-ansi-bytes.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion libs/ansi-parser/src/decode-ansi-color-8bit.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions libs/ansi-parser/src/decode-ansi-string.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libs/ansi-parser/src/default-ansi-parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnsiParser } from '../interfaces/ansi-parser';
import { AnsiParser } from '../interfaces/ansi-parser.js';

export const defaultAnsiParser = (): AnsiParser => {
return {
Expand Down
4 changes: 2 additions & 2 deletions libs/ansi-parser/src/encode-ansi-action.ts
Original file line number Diff line number Diff line change
@@ -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)));
Expand Down
14 changes: 7 additions & 7 deletions libs/ansi-parser/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions libs/ansi-parser/test/known-sequences.spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libs/ansi-parser/test/leading-zeros-ignored.spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions libs/ansi-parser/test/unknown-sequences.spec.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
14 changes: 4 additions & 10 deletions libs/ansi-parser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
1 change: 1 addition & 0 deletions libs/notios-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@notios/config",
"version": "0.2.0",
"type": "module",
"description": "Notios configuration tools",
"keywords": [
"notios",
Expand Down
2 changes: 1 addition & 1 deletion libs/notios-config/src/define_notios_config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NotiosConfig } from './interfaces/notios-config';
import { NotiosConfig } from './interfaces/notios-config.js';

export type ConfigFn = (defaultConfig: NotiosConfig) => NotiosConfig;

Expand Down
2 changes: 1 addition & 1 deletion libs/notios-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as defineNotiosConfig } from './define_notios_config';
export { default as defineNotiosConfig } from './define_notios_config.js';
2 changes: 1 addition & 1 deletion libs/notios-config/src/interfaces/notios-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
NotiosInspectProcAction,
NotiosSelectScriptAction,
NotiosTreeProcsAction,
} from '../action_definitions';
} from '../action_definitions.js';

type NotiosConfigKeymappingSpecialNoMod = {
type: 'special';
Expand Down
14 changes: 4 additions & 10 deletions libs/notios-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "notios",
"type": "module",
"version": "0.4.1",
"type": "module",
"description": "",
"keywords": [
"notios",
Expand Down
2 changes: 1 addition & 1 deletion src/constants/default_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ const defaultConfigOriginal = {

// typecheck
() =>
defineNotiosConfig.default((d) => ({
defineNotiosConfig((d) => ({
...d,
...defaultConfigOriginal,
v1: {
Expand Down
4 changes: 4 additions & 0 deletions src/utils/error.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import assert from 'assert';

export const hintSymbol = Symbol('error hint');

export const tryWithHint = <T>(f: () => T, hint: string): T => {
try {
return f();
} catch (e: unknown) {
assert(e instanceof Error);

throw Object.assign(e, {
[hintSymbol]: hint,
});
Expand Down

0 comments on commit f1df0a5

Please sign in to comment.