web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

commit f5112520e24dc310df3c277199b247506b267688
parent e89ad65a605f7c3ddc4265f3a7b351fb6640ee7c
Author: triesap <triesap@radroots.dev>
Date:   Tue, 18 Nov 2025 01:32:14 +0000

geocoder: expose geocoder as dual esm and cjs package wired to shared core result and error types

Diffstat:
Mgeocoder/.gitignore | 65+++++++++++++++++++++++++++++------------------------------------
Dgeocoder/README.md | 1-
Dgeocoder/index.ts | 1-
Mgeocoder/package.json | 24+++++++++++++++---------
Mgeocoder/src/geocoder.ts | 6+++---
Mgeocoder/src/index.ts | 6+++---
Mgeocoder/src/types.ts | 15++++++++-------
Mgeocoder/src/utils.ts | 4++--
Ageocoder/tsconfig.cjs.json | 15+++++++++++++++
Ageocoder/tsconfig.esm.json | 13+++++++++++++
Mgeocoder/tsconfig.json | 28++--------------------------
Dgeocoder/tsup.config.ts | 11-----------
12 files changed, 90 insertions(+), 99 deletions(-)

diff --git a/geocoder/.gitignore b/geocoder/.gitignore @@ -1,47 +1,40 @@ -# dependencies node_modules -.pnp -.pnp.js +dist +.turbo -# testing -coverage +# Logs +logs/ +*.log -# svelte -.svelte-kit +# Env +.env +.env.* +!.env.example +!.env.test +.local* +justfile -# misc +# OS .DS_Store -*.pem - -# debug -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# turbo -.turbo - - -# Output -.output -/build -dist +Thumbs.db -# local env files -.env* -!.env.example +# Secrets +*.pem +*.crt +*.key +# Testing +test*.json -# Vite -vite.config.js.timestamp-* -vite.config.ts.timestamp-* +# Editors +.vscode/ +.idea/ +*.iml -# local -.tmp* -.backup* -.dev* -.vscode +# Notes notes*.txt notes*.md -git-diff.txt -justfile +notes*.json +tree*.txt +diff*.txt +prompt*.txt diff --git a/geocoder/README.md b/geocoder/README.md @@ -1 +0,0 @@ -# geocoder diff --git a/geocoder/index.ts b/geocoder/index.ts @@ -1 +0,0 @@ -export * from "./src"; diff --git a/geocoder/package.json b/geocoder/package.json @@ -1,21 +1,26 @@ { "name": "@radroots/geocoder", - "version": "0.0.0", + "version": "0.0.1", "private": true, "license": "GPLv3", "type": "module", - "main": "dist/index.js", - "module": "dist/index.js", - "types": "dist/index.d.ts", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/types/index.d.ts", "exports": { ".": { - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "types": "./dist/types/index.d.ts", + "import": "./dist/esm/index.js", + "require": "./dist/cjs/index.js" } }, "scripts": { - "build": "tsup", - "dev": "tsup --watch", + "build:esm": "tsc -p tsconfig.esm.json", + "build:cjs": "tsc -p tsconfig.cjs.json", + "build": "npm run clean && npm run build:esm && npm run build:cjs", + "prebuild": "npm run clean", + "clean": "rimraf dist", + "dev": "npm run watch", "watch": "tsc -w" }, "devDependencies": { @@ -27,7 +32,8 @@ "access": "public" }, "dependencies": { - "@radroots/util": "*", + "@radroots/utils": "*", + "@radroots/types-bindings": "*", "sql.js": "1.12.0" } } \ No newline at end of file diff --git a/geocoder/src/geocoder.ts b/geocoder/src/geocoder.ts @@ -1,7 +1,7 @@ -import { err_msg, type GeolocationCoordinatesPoint } from "@radroots/util"; +import { err_msg, type GeolocationCoordinatesPoint } from "@radroots/utils"; import type { Database } from "sql.js"; -import type { GeocoderReverseResult, IGeocoder, IGeocoderConnectResolve, IGeocoderCountryCenter, IGeocoderCountryCenterResolve, IGeocoderCountryListResolve, IGeocoderCountryListResult, IGeocoderCountryResolve, IGeocoderReverseOpts, IGeocoderReverseResolve } from "./types"; -import { parse_geocode_country_center_result, parse_geocode_country_list_result, parse_geocode_reverse_result } from "./utils"; +import type { GeocoderReverseResult, IGeocoder, IGeocoderConnectResolve, IGeocoderCountryCenter, IGeocoderCountryCenterResolve, IGeocoderCountryListResolve, IGeocoderCountryListResult, IGeocoderCountryResolve, IGeocoderReverseOpts, IGeocoderReverseResolve } from "./types.js"; +import { parse_geocode_country_center_result, parse_geocode_country_list_result, parse_geocode_reverse_result } from "./utils.js"; const KM_PER_DEGREE_LATITUDE = 111; diff --git a/geocoder/src/index.ts b/geocoder/src/index.ts @@ -1,4 +1,4 @@ -export { Geocoder } from "./geocoder" -export type { GeocoderDegreeOffset, GeocoderErrorMessage, GeocoderReverseResult, IGeocoder, IGeocoderCountryCenter, IGeocoderCountryListResult, IGeocoderReverseOpts } from "./types" -export { parse_geocode_country_center_result, parse_geocode_country_list_result, parse_geocode_reverse_result } from "./utils" +export { Geocoder } from "./geocoder.js" +export type { GeocoderDegreeOffset, GeocoderIError, GeocoderReverseResult, IGeocoder, IGeocoderCountryCenter, IGeocoderCountryListResult, IGeocoderReverseOpts } from "./types.js" +export { parse_geocode_country_center_result, parse_geocode_country_list_result, parse_geocode_reverse_result } from "./utils.js" diff --git a/geocoder/src/types.ts b/geocoder/src/types.ts @@ -1,6 +1,7 @@ -import type { ErrorMessage, GeolocationCoordinatesPoint, ResultObj, ResultsList } from "@radroots/util"; +import { IError } from "@radroots/types-bindings"; +import type { GeolocationCoordinatesPoint, ResultObj, ResultsList } from "@radroots/utils"; -export type GeocoderErrorMessage = +export type GeocoderIError = | `*-result` | `*-statement` | `*-db` @@ -30,11 +31,11 @@ export type IGeocoderCountryCenter = { export type IGeocoderCountryListResult = GeolocationCoordinatesPoint & { country_id: string; country: string }; -export type IGeocoderConnectResolve = true | ErrorMessage<GeocoderErrorMessage>; -export type IGeocoderReverseResolve = ResultsList<GeocoderReverseResult> | ErrorMessage<GeocoderErrorMessage>; -export type IGeocoderCountryResolve = ResultsList<GeocoderReverseResult> | ErrorMessage<GeocoderErrorMessage>; -export type IGeocoderCountryListResolve = ResultsList<IGeocoderCountryListResult> | ErrorMessage<GeocoderErrorMessage>; -export type IGeocoderCountryCenterResolve = ResultObj<GeolocationCoordinatesPoint> | ErrorMessage<GeocoderErrorMessage>; +export type IGeocoderConnectResolve = true | IError<GeocoderIError>; +export type IGeocoderReverseResolve = ResultsList<GeocoderReverseResult> | IError<GeocoderIError>; +export type IGeocoderCountryResolve = ResultsList<GeocoderReverseResult> | IError<GeocoderIError>; +export type IGeocoderCountryListResolve = ResultsList<IGeocoderCountryListResult> | IError<GeocoderIError>; +export type IGeocoderCountryCenterResolve = ResultObj<GeolocationCoordinatesPoint> | IError<GeocoderIError>; export type IGeocoder = { connect(wasm_path: string): Promise<IGeocoderConnectResolve>; diff --git a/geocoder/src/utils.ts b/geocoder/src/utils.ts @@ -1,5 +1,5 @@ -import type { GeolocationCoordinatesPoint } from "@radroots/util"; -import type { GeocoderReverseResult, IGeocoderCountryListResult } from "./types"; +import type { GeolocationCoordinatesPoint } from "@radroots/utils"; +import type { GeocoderReverseResult, IGeocoderCountryListResult } from "./types.js"; export const parse_geocode_reverse_result = (obj: any): GeocoderReverseResult | undefined => { if (typeof obj !== `object` || !obj) return undefined; diff --git a/geocoder/tsconfig.cjs.json b/geocoder/tsconfig.cjs.json @@ -0,0 +1,15 @@ +{ + "extends": "@radroots/tsconfig/tsconfig.esm.json", + "compilerOptions": { + "module": "CommonJS", + "moduleResolution": "Node", + "rootDir": "./src", + "outDir": "dist/cjs", + "declaration": false, + "declarationMap": false, + "emitDeclarationOnly": false, + "tsBuildInfoFile": "node_modules/.cache/tsc.utils-nostr.cjs.tsbuildinfo" + }, + "include": ["src"], + "exclude": ["node_modules", "dist"] +} diff --git a/geocoder/tsconfig.esm.json b/geocoder/tsconfig.esm.json @@ -0,0 +1,13 @@ +{ + "extends": "@radroots/tsconfig/tsconfig.esm.json", + "compilerOptions": { + "moduleResolution": "nodenext", + "rootDir": "./src", + "outDir": "dist/esm", + "declaration": true, + "declarationMap": true, + "declarationDir": "dist/types" + }, + "include": ["src"], + "exclude": ["node_modules", "dist"] +} diff --git a/geocoder/tsconfig.json b/geocoder/tsconfig.json @@ -1,26 +1,3 @@ { - "compilerOptions": { - "strict": true, - "target": "es2021", - "lib": [ - "es2021", - "WebWorker" - ], - "module": "ESNext", - "moduleResolution": "node", - "declaration": true, - "declarationMap": true, - "outDir": "./dist", - "esModuleInterop": true, - "skipLibCheck": true, - "baseUrl": ".", - "rootDir": "./src", - }, - "include": [ - "src" - ], - "exclude": [ - "node_modules", - "dist" - ], -} -\ No newline at end of file + "extends": "./tsconfig.esm.json" +} diff --git a/geocoder/tsup.config.ts b/geocoder/tsup.config.ts @@ -1,11 +0,0 @@ -import { defineConfig } from "tsup"; - -export default defineConfig({ - entry: ['src/index.ts'], - format: ['esm', 'cjs'], - dts: true, - outDir: 'dist', - splitting: true, - clean: true, - sourcemap: true, -});