diff --git a/CLAUDE.md b/CLAUDE.md index 6da21bab..21c98642 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -115,7 +115,7 @@ See `docs/benchmark.md` for full documentation. `url_github_file`, `url_npm_package`, `url_logo`, `package_is_published` (consumed by fuz_ui's `Library` and by build-time tooling) - `result.ts` - Result type pattern -- `error.ts` - error utilities (`UnreachableError`, `unreachable` assertion) +- `error.ts` - error utilities (`UnreachableError`, `unreachable` assertion, `to_error_message` thrown-value → string) - `args.ts` - CLI argument parsing with Zod validation - `types.ts` - `Flavored` (loose nominal typing, no cast needed) and `Branded` @@ -187,7 +187,7 @@ See `docs/benchmark.md` for full documentation. - explicit file extensions in imports - tab indentation, 100 character width - no re-exports - import directly from the source module (e.g., import baseline - functions from `benchmark_baseline.js`, not from `benchmark.js`) + functions from `benchmark_baseline.ts`, not from `benchmark.ts`) - no backwards compatibility preservation - breaking changes are acceptable ## Configuration diff --git a/README.md b/README.md index ef85507d..46506728 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ npm i -D @fuzdev/fuz_util Import modules at their full paths: ```ts -import {type Result, unwrap} from '@fuzdev/fuz_util/result.js'; -import {random_int} from '@fuzdev/fuz_util/random.js'; +import {type Result, unwrap} from '@fuzdev/fuz_util/result.ts'; +import {random_int} from '@fuzdev/fuz_util/random.ts'; ``` `.ts` imports also work: diff --git a/docs/benchmark.md b/docs/benchmark.md index 1b84faa3..f97b5f41 100644 --- a/docs/benchmark.md +++ b/docs/benchmark.md @@ -9,7 +9,7 @@ Comprehensive statistical analysis, percentile tracking, and rich output formatt ## Quick Start ```ts -import {Benchmark} from '@fuzdev/fuz_util/benchmark.js'; +import {Benchmark} from '@fuzdev/fuz_util/benchmark.ts'; const bench = new Benchmark({ duration_ms: 5000, // Run each task for 5 seconds @@ -641,7 +641,7 @@ import { stats_confidence_interval, stats_outliers_iqr, stats_outliers_mad, -} from '@fuzdev/fuz_util/stats.js'; +} from '@fuzdev/fuz_util/stats.ts'; // Calculate statistics on any numeric array const values = [1.2, 1.5, 1.3, 1.4, 1.6, 10.0]; // 10.0 is an outlier @@ -765,7 +765,7 @@ function benchmark_stats_compare( Use `benchmark_stats_compare()` to determine if performance differences are statistically significant: ```ts -import {benchmark_stats_compare} from '@fuzdev/fuz_util/benchmark_stats.js'; +import {benchmark_stats_compare} from '@fuzdev/fuz_util/benchmark_stats.ts'; const results = await bench.run(); const [result_a, result_b] = results; @@ -805,13 +805,13 @@ interface BenchmarkComparison { Save benchmark results to disk and compare against baselines for CI/CD regression detection: ```ts -import {Benchmark} from '@fuzdev/fuz_util/benchmark.js'; +import {Benchmark} from '@fuzdev/fuz_util/benchmark.ts'; import { benchmark_baseline_save, benchmark_baseline_compare, benchmark_baseline_format, benchmark_baseline_format_json, -} from '@fuzdev/fuz_util/benchmark_baseline.js'; +} from '@fuzdev/fuz_util/benchmark_baseline.ts'; const bench = new Benchmark(); bench.add('parse', () => parse(input)); diff --git a/package-lock.json b/package-lock.json index d2e930ae..158eb220 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "@fuzdev/fuz_code": "^0.46.1", "@fuzdev/fuz_css": "^0.63.2", "@fuzdev/fuz_ui": "^0.205.1", - "@fuzdev/gro": "^0.204.0", + "@fuzdev/gro": "^0.205.1", "@fuzdev/mdz": "^0.1.0", "@ryanatkn/eslint-config": "^0.12.1", "@sveltejs/acorn-typescript": "^1.0.9", @@ -896,9 +896,9 @@ } }, "node_modules/@fuzdev/fuz_util": { - "version": "0.65.1", - "resolved": "https://registry.npmjs.org/@fuzdev/fuz_util/-/fuz_util-0.65.1.tgz", - "integrity": "sha512-fN3WzBA0HnVe/PtgO5/89nqLC/6o8aRqMGq5TfojJmUfoxN1+u4XhFTymLsd0jJADE6+KNcbQjtKziJUJlTiXQ==", + "version": "0.65.2", + "resolved": "https://registry.npmjs.org/@fuzdev/fuz_util/-/fuz_util-0.65.2.tgz", + "integrity": "sha512-VE20HhfZTPOY3SMx4kBELaAZFSRppbskQsIsqy4SvMmGknc0LrxN6jTrnzhp0blooPt3vPparf/yKdzwPUVUCg==", "dev": true, "license": "MIT", "peer": true, @@ -939,9 +939,9 @@ } }, "node_modules/@fuzdev/gro": { - "version": "0.204.0", - "resolved": "https://registry.npmjs.org/@fuzdev/gro/-/gro-0.204.0.tgz", - "integrity": "sha512-cApVG7sVgbtXE5lXI1ej6LpWQR4ZBQB+Bt6mZHhrpFOlfgmuv2zCotFBKp58JaJ1ZsyvJEUs6WWwG8XGron+Lg==", + "version": "0.205.1", + "resolved": "https://registry.npmjs.org/@fuzdev/gro/-/gro-0.205.1.tgz", + "integrity": "sha512-o5WBXWSH/UlN1BsDnpBNIi0WHR7lj7UFGltH/JctSP7oSB2ojvmoXD5OLCEeVdRVcDaSQKl48xcXKUwHKqVSmQ==", "dev": true, "license": "MIT", "dependencies": { @@ -968,7 +968,7 @@ }, "peerDependencies": { "@fuzdev/blake3_wasm": "^0.1.0", - "@fuzdev/fuz_util": ">=0.65.1", + "@fuzdev/fuz_util": ">=0.65.2", "@sveltejs/kit": "^2", "esbuild": "^0.28.0", "svelte": "^5", diff --git a/package.json b/package.json index 3df4085a..0fd77972 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "@fuzdev/fuz_code": "^0.46.1", "@fuzdev/fuz_css": "^0.63.2", "@fuzdev/fuz_ui": "^0.205.1", - "@fuzdev/gro": "^0.204.0", + "@fuzdev/gro": "^0.205.1", "@fuzdev/mdz": "^0.1.0", "@ryanatkn/eslint-config": "^0.12.1", "@sveltejs/acorn-typescript": "^1.0.9", diff --git a/src/app.d.ts b/src/app.d.ts index ca397885..8a24f3b7 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -6,7 +6,7 @@ declare module 'virtual:fuz.css' { export default css; } declare module 'virtual:pkg.json' { - import type {PkgJson} from '@fuzdev/fuz_util/pkg_json.js'; + import type {PkgJson} from './lib/pkg_json.ts'; const pkg_json: PkgJson; export default pkg_json; } diff --git a/src/benchmarks/deep_equal.benchmark.ts b/src/benchmarks/deep_equal.benchmark.ts index 59614383..6409bbab 100644 --- a/src/benchmarks/deep_equal.benchmark.ts +++ b/src/benchmarks/deep_equal.benchmark.ts @@ -1,6 +1,6 @@ -import {Benchmark} from '$lib/benchmark.js'; -import {deep_equal} from '$lib/deep_equal.js'; -import type {BenchmarkGroup} from '$lib/benchmark_types.js'; +import {Benchmark} from '../lib/benchmark.ts'; +import {deep_equal} from '../lib/deep_equal.ts'; +import type {BenchmarkGroup} from '../lib/benchmark_types.ts'; /* eslint-disable no-console, no-new-wrappers */ diff --git a/src/benchmarks/deep_equal_comparison.benchmark.ts b/src/benchmarks/deep_equal_comparison.benchmark.ts index 34354b24..4c58637b 100644 --- a/src/benchmarks/deep_equal_comparison.benchmark.ts +++ b/src/benchmarks/deep_equal_comparison.benchmark.ts @@ -1,8 +1,8 @@ -import {Benchmark} from '$lib/benchmark.js'; +import {Benchmark} from '../lib/benchmark.ts'; import {dequal} from 'dequal'; import fastDeepEqual from 'fast-deep-equal'; -import {deep_equal} from '$lib/deep_equal.js'; +import {deep_equal} from '../lib/deep_equal.ts'; /* eslint-disable no-console */ diff --git a/src/benchmarks/random.benchmark.ts b/src/benchmarks/random.benchmark.ts index b36e5c59..3712b1c5 100644 --- a/src/benchmarks/random.benchmark.ts +++ b/src/benchmarks/random.benchmark.ts @@ -1,8 +1,8 @@ -import {Benchmark} from '$lib/benchmark.js'; -import {create_random_alea} from '$lib/random_alea.js'; -import {create_random_xoshiro} from '$lib/random_xoshiro.js'; +import {Benchmark} from '../lib/benchmark.ts'; +import {create_random_alea} from '../lib/random_alea.ts'; +import {create_random_xoshiro} from '../lib/random_xoshiro.ts'; -import {create_random_lcg, create_random_xorshift32} from '../test/random_test_helpers.js'; +import {create_random_lcg, create_random_xorshift32} from '../test/random_test_helpers.ts'; /* eslint-disable no-console */ diff --git a/src/benchmarks/random_quality.ts b/src/benchmarks/random_quality.ts index b030ddf6..85a0a94d 100644 --- a/src/benchmarks/random_quality.ts +++ b/src/benchmarks/random_quality.ts @@ -9,16 +9,16 @@ /* eslint-disable no-console */ -import {create_random_alea} from '$lib/random_alea.js'; -import {create_random_xoshiro} from '$lib/random_xoshiro.js'; -import {stats_mean, stats_variance} from '$lib/stats.js'; -import {string_display_width, pad_width} from '$lib/string.js'; +import {create_random_alea} from '../lib/random_alea.ts'; +import {create_random_xoshiro} from '../lib/random_xoshiro.ts'; +import {stats_mean, stats_variance} from '../lib/stats.ts'; +import {string_display_width, pad_width} from '../lib/string.ts'; import { type Prng, create_random_lcg, create_random_xorshift32, -} from '../test/random_test_helpers.js'; +} from '../test/random_test_helpers.ts'; const deep = process.argv.includes('--deep'); const N = deep ? 10_000_000 : 1_000_000; diff --git a/src/benchmarks/run.ts b/src/benchmarks/run.ts index 54217ac0..b0e42364 100644 --- a/src/benchmarks/run.ts +++ b/src/benchmarks/run.ts @@ -9,16 +9,16 @@ /* eslint-disable no-console */ import {readFile, writeFile} from 'node:fs/promises'; -import {format_file} from '@fuzdev/gro/format_file.js'; +import {format_file} from '@fuzdev/gro/format_file.ts'; -import {Benchmark} from '$lib/benchmark.js'; +import {Benchmark} from '../lib/benchmark.ts'; import { benchmark_baseline_save, benchmark_baseline_compare, benchmark_baseline_format, -} from '$lib/benchmark_baseline.js'; -import {slugify} from '$lib/path.js'; -import {deep_equal} from '$lib/deep_equal.js'; +} from '../lib/benchmark_baseline.ts'; +import {slugify} from '../lib/path.ts'; +import {deep_equal} from '../lib/deep_equal.ts'; const save_baseline = process.argv.includes('--save'); const BASELINE_PATH = 'src/benchmarks'; diff --git a/src/benchmarks/slugify.benchmark.ts b/src/benchmarks/slugify.benchmark.ts index cbb50308..b3c785de 100644 --- a/src/benchmarks/slugify.benchmark.ts +++ b/src/benchmarks/slugify.benchmark.ts @@ -1,5 +1,5 @@ -import {Benchmark} from '$lib/benchmark.js'; -import {slugify} from '$lib/path.js'; +import {Benchmark} from '../lib/benchmark.ts'; +import {slugify} from '../lib/path.ts'; /* eslint-disable no-console */ diff --git a/src/lib/array.ts b/src/lib/array.ts index 410c1b1b..dbedbd96 100644 --- a/src/lib/array.ts +++ b/src/lib/array.ts @@ -1,4 +1,4 @@ -import type {ArrayElement} from './types.js'; +import type {ArrayElement} from './types.ts'; // TODO try to cange to readonly again, see if upstream errors are tolerably fixed export const EMPTY_ARRAY: Array = Object.freeze([]) as any; diff --git a/src/lib/benchmark.ts b/src/lib/benchmark.ts index 3fe65f6e..91bed9a2 100644 --- a/src/lib/benchmark.ts +++ b/src/lib/benchmark.ts @@ -3,7 +3,7 @@ * * @example * ```ts - * import {Benchmark} from '@fuzdev/fuz_util/benchmark.js'; + * import {Benchmark} from '@fuzdev/fuz_util/benchmark.ts'; * * const bench = new Benchmark({ * duration_ms: 5000, @@ -21,9 +21,9 @@ * @module */ -import {is_promise, wait} from './async.js'; -import {BenchmarkStats} from './benchmark_stats.js'; -import {timer_default, time_unit_detect_best, time_format} from './time.js'; +import {is_promise, wait} from './async.ts'; +import {BenchmarkStats} from './benchmark_stats.ts'; +import {timer_default, time_unit_detect_best, time_format} from './time.ts'; import { benchmark_format_table, benchmark_format_table_grouped, @@ -32,13 +32,13 @@ import { benchmark_format_json, benchmark_format_number, type BenchmarkFormatJsonOptions, -} from './benchmark_format.js'; +} from './benchmark_format.ts'; import type { BenchmarkConfig, BenchmarkTask, BenchmarkResult, BenchmarkFormatTableOptions, -} from './benchmark_types.js'; +} from './benchmark_types.ts'; // Default configuration values const DEFAULT_DURATION_MS = 1000; diff --git a/src/lib/benchmark_baseline.ts b/src/lib/benchmark_baseline.ts index 776b69f3..2f8f4b6d 100644 --- a/src/lib/benchmark_baseline.ts +++ b/src/lib/benchmark_baseline.ts @@ -9,15 +9,15 @@ import {readFile, writeFile, mkdir, rm} from 'node:fs/promises'; import {join} from 'node:path'; import {z} from 'zod'; -import {fs_exists} from './fs.js'; -import {git_info_get} from './git.js'; -import type {BenchmarkResult} from './benchmark_types.js'; +import {fs_exists} from './fs.ts'; +import {git_info_get} from './git.ts'; +import type {BenchmarkResult} from './benchmark_types.ts'; import { benchmark_stats_compare, type BenchmarkComparison, type BenchmarkStatsComparable, -} from './benchmark_stats.js'; -import {stats_confidence_interval_from_summary, stats_cv} from './stats.js'; +} from './benchmark_stats.ts'; +import {stats_confidence_interval_from_summary, stats_cv} from './stats.ts'; // Version for forward compatibility - increment when schema changes const BASELINE_VERSION = 3; diff --git a/src/lib/benchmark_format.ts b/src/lib/benchmark_format.ts index 55d1d29f..7ea72c98 100644 --- a/src/lib/benchmark_format.ts +++ b/src/lib/benchmark_format.ts @@ -1,7 +1,7 @@ -import type {BenchmarkResult, BenchmarkGroup} from './benchmark_types.js'; -import {time_unit_detect_best, time_format, TIME_UNIT_DISPLAY} from './time.js'; -import {string_display_width, pad_width} from './string.js'; -import {format_number} from './maths.js'; +import type {BenchmarkResult, BenchmarkGroup} from './benchmark_types.ts'; +import {time_unit_detect_best, time_format, TIME_UNIT_DISPLAY} from './time.ts'; +import {string_display_width, pad_width} from './string.ts'; +import {format_number} from './maths.ts'; /** * Format results as an ASCII table with percentiles, min/max, and relative performance. diff --git a/src/lib/benchmark_stats.ts b/src/lib/benchmark_stats.ts index c0baeaae..d9ad9ffc 100644 --- a/src/lib/benchmark_stats.ts +++ b/src/lib/benchmark_stats.ts @@ -6,7 +6,7 @@ * @module */ -import {TIME_NS_PER_SEC, time_format_adaptive} from './time.js'; +import {TIME_NS_PER_SEC, time_format_adaptive} from './time.ts'; import { stats_mean, stats_median, @@ -18,7 +18,7 @@ import { stats_outliers_mad, stats_welch_t_test, stats_t_distribution_p_value, -} from './stats.js'; +} from './stats.ts'; /** * Minimal stats interface for comparison. diff --git a/src/lib/benchmark_types.ts b/src/lib/benchmark_types.ts index 02f8edf9..666344f4 100644 --- a/src/lib/benchmark_types.ts +++ b/src/lib/benchmark_types.ts @@ -1,5 +1,5 @@ -import type {BenchmarkStats} from './benchmark_stats.js'; -import type {Timer} from './time.js'; +import type {BenchmarkStats} from './benchmark_stats.ts'; +import type {Timer} from './time.ts'; /** * Configuration options for a benchmark suite. diff --git a/src/lib/colors.ts b/src/lib/colors.ts index e3ab8918..5b9177c5 100644 --- a/src/lib/colors.ts +++ b/src/lib/colors.ts @@ -1,5 +1,5 @@ -import type {Flavored} from './types.js'; -import {round} from './maths.js'; +import type {Flavored} from './types.ts'; +import {round} from './maths.ts'; // TODO for high-performance usecases, we may want to add variants for any that return a new array to reuse a single array // I've run into cases where this is a massive perceptible UX difference diff --git a/src/lib/dag.ts b/src/lib/dag.ts index 08177293..e793a165 100644 --- a/src/lib/dag.ts +++ b/src/lib/dag.ts @@ -9,8 +9,8 @@ * @module */ -import {AsyncSemaphore, create_deferred, type Deferred} from './async.js'; -import {topological_sort, type Sortable} from './sort.js'; +import {AsyncSemaphore, create_deferred, type Deferred} from './async.ts'; +import {topological_sort, type Sortable} from './sort.ts'; /** * Minimum shape for a DAG node. diff --git a/src/lib/diff.ts b/src/lib/diff.ts index c511070d..d2f331c2 100644 --- a/src/lib/diff.ts +++ b/src/lib/diff.ts @@ -4,7 +4,7 @@ * @module */ -import {string_is_binary} from './string.js'; +import {string_is_binary} from './string.ts'; /** Line diff result */ export interface DiffLine { diff --git a/src/lib/fact_hash.ts b/src/lib/fact_hash.ts index d1b0e41f..c45f6795 100644 --- a/src/lib/fact_hash.ts +++ b/src/lib/fact_hash.ts @@ -22,9 +22,9 @@ import {hash_stream} from '@fuzdev/blake3_wasm'; import {z} from 'zod'; -import {hash_blake3} from './hash_blake3.js'; -import {to_hex} from './hex.js'; -import type {Json} from './json.js'; +import {hash_blake3} from './hash_blake3.ts'; +import {to_hex} from './hex.ts'; +import type {Json} from './json.ts'; /** Algorithm prefix on every fact hash. The colon is the separator. */ export const FACT_HASH_PREFIX = 'blake3:'; diff --git a/src/lib/fact_store.ts b/src/lib/fact_store.ts index 31855b12..7eb7311f 100644 --- a/src/lib/fact_store.ts +++ b/src/lib/fact_store.ts @@ -13,7 +13,7 @@ * @module */ -import type {FactHash} from './fact_hash.js'; +import type {FactHash} from './fact_hash.ts'; /** * Optional metadata + ref declarations on a `put` / `put_ref` call. diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 65869fe9..9187af51 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -1,10 +1,10 @@ import {z} from 'zod'; -import type {Flavored} from './types.js'; -import type {Logger} from './log.js'; -import {EMPTY_OBJECT} from './object.js'; -import type {Result} from './result.js'; -import {json_stringify_deterministic} from './json.js'; +import type {Flavored} from './types.ts'; +import type {Logger} from './log.ts'; +import {EMPTY_OBJECT} from './object.ts'; +import type {Result} from './result.ts'; +import {json_stringify_deterministic} from './json.ts'; const DEFAULT_GITHUB_API_ACCEPT_HEADER = 'application/vnd.github+json'; const DEFAULT_GITHUB_API_VERSION_HEADER = '2022-11-28'; diff --git a/src/lib/fs.ts b/src/lib/fs.ts index 6b2316b1..c594bc26 100644 --- a/src/lib/fs.ts +++ b/src/lib/fs.ts @@ -2,10 +2,11 @@ import {rm, readdir, access, constants} from 'node:fs/promises'; import type {RmOptions} from 'node:fs'; import {join, isAbsolute} from 'node:path'; -import {EMPTY_OBJECT} from './object.js'; -import {to_array} from './array.js'; -import {ensure_end} from './string.js'; -import type {FileFilter, ResolvedPath, PathFilter} from './path.js'; +import {to_error_message} from './error.ts'; +import {EMPTY_OBJECT} from './object.ts'; +import {to_array} from './array.ts'; +import {ensure_end} from './string.ts'; +import type {FileFilter, ResolvedPath, PathFilter} from './path.ts'; /** * Discriminated filesystem error kinds. @@ -36,7 +37,7 @@ export type FsJsonError = FsError | {kind: 'invalid_json'; message: string}; * fall through to `io_error`. */ export const fs_classify_error = (error: unknown): FsError => { - const message = error instanceof Error ? error.message : String(error); + const message = to_error_message(error); if (error && typeof error === 'object' && 'code' in error) { switch ((error as {code: string}).code) { case 'ENOENT': diff --git a/src/lib/git.ts b/src/lib/git.ts index 072b2190..e7d24b5e 100644 --- a/src/lib/git.ts +++ b/src/lib/git.ts @@ -1,10 +1,10 @@ import type {SpawnOptions} from 'node:child_process'; import {z} from 'zod'; -import {spawn, spawn_out, spawn_result_to_message} from './process.js'; -import type {Flavored} from './types.js'; -import {to_file_path} from './path.js'; -import {fs_exists} from './fs.js'; +import {spawn, spawn_out, spawn_result_to_message} from './process.ts'; +import type {Flavored} from './types.ts'; +import {to_file_path} from './path.ts'; +import {fs_exists} from './fs.ts'; /** * Basic git repository info. diff --git a/src/lib/hash.ts b/src/lib/hash.ts index 818701a8..53d19fed 100644 --- a/src/lib/hash.ts +++ b/src/lib/hash.ts @@ -8,7 +8,7 @@ * @module */ -import {to_hex} from './hex.js'; +import {to_hex} from './hex.ts'; const encoder = new TextEncoder(); diff --git a/src/lib/hash_blake3.ts b/src/lib/hash_blake3.ts index 5e685c4c..c1a29e7f 100644 --- a/src/lib/hash_blake3.ts +++ b/src/lib/hash_blake3.ts @@ -11,8 +11,8 @@ import {z} from 'zod'; import {hash, init} from '@fuzdev/blake3_wasm'; -import {to_hex} from './hex.js'; -import {to_bytes} from './bytes.js'; +import {to_hex} from './hex.ts'; +import {to_bytes} from './bytes.ts'; /** * Resolves when the BLAKE3 WASM module is initialized and ready. diff --git a/src/lib/id.ts b/src/lib/id.ts index a2e31659..0ac7b733 100644 --- a/src/lib/id.ts +++ b/src/lib/id.ts @@ -1,6 +1,6 @@ import {z} from 'zod'; -import {create_counter} from './counter.js'; +import {create_counter} from './counter.ts'; export const create_uuid = (): Uuid => crypto.randomUUID() as Uuid; diff --git a/src/lib/library_json.ts b/src/lib/library_json.ts index f290e331..82f4909d 100644 --- a/src/lib/library_json.ts +++ b/src/lib/library_json.ts @@ -6,8 +6,8 @@ import type {ModuleJsonInput} from 'svelte-docinfo/types.js'; -import {pkg_json_from_package_json, pkg_json_keys, type PkgJson} from './pkg_json.js'; -import type {PackageJson} from './package_json.js'; +import {pkg_json_from_package_json, pkg_json_keys, type PkgJson} from './pkg_json.ts'; +import type {PackageJson} from './package_json.ts'; /** * A library's analyzed source: the module metadata produced by `svelte-docinfo`. diff --git a/src/lib/object.ts b/src/lib/object.ts index 1b17d846..a533086c 100644 --- a/src/lib/object.ts +++ b/src/lib/object.ts @@ -1,4 +1,4 @@ -import type {OmitStrict} from './types.js'; +import type {OmitStrict} from './types.ts'; /** * Returns a boolean indicating if `value` is diff --git a/src/lib/package_helpers.ts b/src/lib/package_helpers.ts index 9fc440c4..1243d427 100644 --- a/src/lib/package_helpers.ts +++ b/src/lib/package_helpers.ts @@ -20,8 +20,8 @@ * @module */ -import {ensure_end, strip_end, strip_start} from './string.js'; -import type {PackageJson} from './package_json.js'; +import {ensure_end, strip_end, strip_start} from './string.ts'; +import type {PackageJson} from './package_json.ts'; /** * Build GitHub file URL for a repository. diff --git a/src/lib/package_json.ts b/src/lib/package_json.ts index 2e9e42ab..9a697052 100644 --- a/src/lib/package_json.ts +++ b/src/lib/package_json.ts @@ -1,8 +1,8 @@ import {z} from 'zod'; -import {count_graphemes} from './string.js'; -import {transform_empty_object_to_undefined} from './object.js'; -import {Url} from './url.js'; +import {count_graphemes} from './string.ts'; +import {transform_empty_object_to_undefined} from './object.ts'; +import {Url} from './url.ts'; export const PackageJsonRepository = z.union([ z.string(), diff --git a/src/lib/path.ts b/src/lib/path.ts index d98c3f99..3b62d11e 100644 --- a/src/lib/path.ts +++ b/src/lib/path.ts @@ -1,4 +1,4 @@ -import type {Flavored} from './types.js'; +import type {Flavored} from './types.ts'; /** * An absolute path on the filesystem. Named "id" to be consistent with Rollup. diff --git a/src/lib/pkg_json.ts b/src/lib/pkg_json.ts index dfed7d9b..fefd1e14 100644 --- a/src/lib/pkg_json.ts +++ b/src/lib/pkg_json.ts @@ -13,7 +13,7 @@ * @module */ -import type {PackageJson} from './package_json.js'; +import type {PackageJson} from './package_json.ts'; /** * The keys kept when stripping `package.json` down to a `PkgJson` — package diff --git a/src/lib/print.ts b/src/lib/print.ts index fc61eeb3..b58e4625 100644 --- a/src/lib/print.ts +++ b/src/lib/print.ts @@ -1,7 +1,7 @@ import type {styleText} from 'node:util'; -import type {Timings} from './timings.js'; -import type {Logger} from './log.js'; +import type {Timings} from './timings.ts'; +import type {Logger} from './log.ts'; export let st: typeof styleText = (_, v) => v; diff --git a/src/lib/process.ts b/src/lib/process.ts index cceb0202..deae016a 100644 --- a/src/lib/process.ts +++ b/src/lib/process.ts @@ -5,9 +5,10 @@ import { } from 'node:child_process'; import {styleText as st} from 'node:util'; -import {Logger} from './log.js'; -import {print_error, print_key_value} from './print.js'; -import {noop} from './function.js'; +import {to_error_message} from './error.ts'; +import {Logger} from './log.ts'; +import {print_error, print_key_value} from './print.ts'; +import {noop} from './function.ts'; const log = new Logger('process'); @@ -580,7 +581,7 @@ export const spawn_detached = ( } catch (error) { return { kind: 'error', - message: error instanceof Error ? error.message : String(error), + message: to_error_message(error), }; } }; diff --git a/src/lib/random.ts b/src/lib/random.ts index daf58045..8878c3c4 100644 --- a/src/lib/random.ts +++ b/src/lib/random.ts @@ -8,7 +8,7 @@ * @module */ -import type {ArrayElement} from './types.js'; +import type {ArrayElement} from './types.ts'; /** * Generates a random `number` between `min` and `max`. diff --git a/src/lib/string.ts b/src/lib/string.ts index 0c46c63b..a411a289 100644 --- a/src/lib/string.ts +++ b/src/lib/string.ts @@ -1,4 +1,4 @@ -import {count_iterator} from './iterator.js'; +import {count_iterator} from './iterator.ts'; /** * Truncates a string to a maximum length, adding a suffix if needed that defaults to `...`. diff --git a/src/lib/svelte_preprocess_helpers.ts b/src/lib/svelte_preprocess_helpers.ts index e38b35f7..86f3c450 100644 --- a/src/lib/svelte_preprocess_helpers.ts +++ b/src/lib/svelte_preprocess_helpers.ts @@ -22,6 +22,8 @@ import type { } from 'estree'; import type {AST} from 'svelte/compiler'; +import {to_error_message} from './error.ts'; + /** Import metadata for a single import specifier. */ export interface PreprocessImportInfo { /** The module path to import from. */ @@ -205,7 +207,7 @@ export const try_extract_conditional_chain = ( return branches; }; -// TODO cross-import tracing: resolve `import {x} from './constants.js'` by reading +// TODO cross-import tracing: resolve `import {x} from './constants.ts'` by reading // and parsing the imported module, extracting `export const` values. Would need path // resolution ($lib, tsconfig paths), a Program-node variant of this function, and // cache invalidation when the imported file changes. Start with relative .ts/.js only. @@ -585,7 +587,7 @@ export const handle_preprocess_error = ( filename: string | undefined, on_error: 'throw' | 'log', ): void => { - const message = `${prefix} Preprocessing failed${filename ? ` in ${filename}` : ''}: ${error instanceof Error ? error.message : String(error)}`; + const message = `${prefix} Preprocessing failed${filename ? ` in ${filename}` : ''}: ${to_error_message(error)}`; if (on_error === 'throw') { throw new Error(message, {cause: error}); } diff --git a/src/lib/testing.ts b/src/lib/testing.ts index 3e6ef405..f990bf21 100644 --- a/src/lib/testing.ts +++ b/src/lib/testing.ts @@ -10,7 +10,7 @@ import {assert, vi} from 'vitest'; -import type {Logger} from './log.js'; +import type {Logger} from './log.ts'; /** * Narrows a discriminated union by a literal property value, failing the test diff --git a/src/lib/throttle.ts b/src/lib/throttle.ts index d2906d9a..bb99bef4 100644 --- a/src/lib/throttle.ts +++ b/src/lib/throttle.ts @@ -1,5 +1,5 @@ -import {create_deferred, type Deferred} from './async.js'; -import {EMPTY_OBJECT} from './object.js'; +import {create_deferred, type Deferred} from './async.ts'; +import {EMPTY_OBJECT} from './object.ts'; export interface ThrottleOptions { /** diff --git a/src/lib/time.ts b/src/lib/time.ts index 3cb0f34c..fd461f4c 100644 --- a/src/lib/time.ts +++ b/src/lib/time.ts @@ -285,7 +285,7 @@ export const time_sync = ( * await process_data(); * }, 100); * - * import {BenchmarkStats} from './benchmark_stats.js'; + * import {BenchmarkStats} from './benchmark_stats.ts'; * const stats = new BenchmarkStats(timings_ns); * console.log(`Mean: ${time_format_adaptive(stats.mean_ns)}`); * ``` diff --git a/src/lib/timings.ts b/src/lib/timings.ts index 9e9830ad..c7eaf302 100644 --- a/src/lib/timings.ts +++ b/src/lib/timings.ts @@ -1,4 +1,4 @@ -import {round} from './maths.js'; +import {round} from './maths.ts'; export type Stopwatch = (reset?: boolean) => number; diff --git a/src/lib/url.ts b/src/lib/url.ts index 11466a43..afd215c5 100644 --- a/src/lib/url.ts +++ b/src/lib/url.ts @@ -1,7 +1,7 @@ import {z} from 'zod'; -import {strip_end, strip_start} from './string.js'; -import type {Flavored} from './types.js'; +import {strip_end, strip_start} from './string.ts'; +import type {Flavored} from './types.ts'; /** * Formats a URL by removing 'https://', 'www.', and trailing slashes. diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a60f6939..092eda43 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,11 +1,11 @@ diff --git a/src/routes/docs/library/+page.svelte b/src/routes/docs/library/+page.svelte index 944504ea..18d71fe8 100644 --- a/src/routes/docs/library/+page.svelte +++ b/src/routes/docs/library/+page.svelte @@ -1,8 +1,8 @@