diff --git a/CLAUDE.md b/CLAUDE.md index 7a49895..4dca9c6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -51,4 +51,4 @@ For components that accept children (layers, popups, tooltips), use the `registe ### Output -`tsc` compiles `src/` → `dist/` as individual ESM modules (`.js` + `.d.ts` + `.d.ts.map`), then `rollup -c` bundles `dist/index.js` (ESM), `dist/index.cjs` (CJS), and `dist/index.umd.js` (UMD) — each with minified variants. Leaflet is always external (never bundled). Imports within source use `.js` extensions (required for ESM `"moduleResolution": "bundler"`). +`tsc` compiles `src/` → `dist/` as individual ESM modules (`.js` + `.d.ts` + `.d.ts.map`), then `rollup -c` bundles `dist/index.js` (ESM), `dist/index.cjs` (CJS), and `dist/index.umd.js` (UMD) — each with minified variants. Leaflet is always external (never bundled). Imports within source use `.ts` extensions; `rewriteRelativeImportExtensions` in tsconfig strips them to `.js` in the tsc output (`tsconfig.json:16`). diff --git a/src/components/leaflet-circle-marker.ts b/src/components/leaflet-circle-marker.ts index c1fb349..e6b331c 100644 --- a/src/components/leaflet-circle-marker.ts +++ b/src/components/leaflet-circle-marker.ts @@ -1,10 +1,10 @@ import { CircleMarker } from 'leaflet'; -import { buildOptions, numAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, numAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import { isPathStyleAttr, updatePathStyle } from '../core/path-style.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { lat: { kind: 'num', attr: 'lat', default: 0 }, diff --git a/src/components/leaflet-circle.ts b/src/components/leaflet-circle.ts index 7ccdc29..b891d35 100644 --- a/src/components/leaflet-circle.ts +++ b/src/components/leaflet-circle.ts @@ -1,10 +1,10 @@ import { Circle } from 'leaflet'; -import { buildOptions, numAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, numAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import { isPathStyleAttr, updatePathStyle } from '../core/path-style.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { lat: { kind: 'num', attr: 'lat', default: 0 }, diff --git a/src/components/leaflet-control-attribution.ts b/src/components/leaflet-control-attribution.ts index deb849d..b21b36e 100644 --- a/src/components/leaflet-control-attribution.ts +++ b/src/components/leaflet-control-attribution.ts @@ -1,8 +1,8 @@ import { Control, ControlPosition } from 'leaflet'; -import { registerWithParent } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { registerWithParent } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import type { PropDef } from '../core/props.js'; +import type { PropDef } from '../core/props.ts'; const PROPS = { position: { kind: 'str', attr: 'position', default: 'bottomright' }, diff --git a/src/components/leaflet-control-scale.ts b/src/components/leaflet-control-scale.ts index 9ae2ceb..0fecc3c 100644 --- a/src/components/leaflet-control-scale.ts +++ b/src/components/leaflet-control-scale.ts @@ -1,8 +1,8 @@ import { Control, ControlPosition } from 'leaflet'; -import { registerWithParent } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { registerWithParent } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import type { PropDef } from '../core/props.js'; +import type { PropDef } from '../core/props.ts'; const PROPS = { position: { kind: 'str', attr: 'position', default: 'bottomleft' }, diff --git a/src/components/leaflet-control-zoom.ts b/src/components/leaflet-control-zoom.ts index 2792d04..247de6c 100644 --- a/src/components/leaflet-control-zoom.ts +++ b/src/components/leaflet-control-zoom.ts @@ -1,8 +1,8 @@ import { Control, ControlPosition } from 'leaflet'; -import { registerWithParent } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { registerWithParent } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import type { PropDef } from '../core/props.js'; +import type { PropDef } from '../core/props.ts'; const PROPS = { position: { kind: 'str', attr: 'position', default: 'topleft' }, diff --git a/src/components/leaflet-feature-group.ts b/src/components/leaflet-feature-group.ts index b6a8a32..d85df28 100644 --- a/src/components/leaflet-feature-group.ts +++ b/src/components/leaflet-feature-group.ts @@ -1,6 +1,6 @@ import { FeatureGroup, Layer } from 'leaflet'; -import { buildOptions } from '../core/utils.js'; -import { registerChildren, unregisterChildren, getChildren } from '../core/register.js'; +import { buildOptions } from '../core/utils.ts'; +import { registerChildren, unregisterChildren, getChildren } from '../core/register.ts'; export class LeafletFeatureGroup extends HTMLElement { #obj?: FeatureGroup; diff --git a/src/components/leaflet-geojson.ts b/src/components/leaflet-geojson.ts index ef344e8..1402cd6 100644 --- a/src/components/leaflet-geojson.ts +++ b/src/components/leaflet-geojson.ts @@ -1,9 +1,9 @@ import { GeoJSON, PathOptions, Layer } from 'leaflet'; -import { buildOptions } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren, getChildren } from '../core/register.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren, getChildren } from '../core/register.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { data: { kind: 'str', attr: 'data', default: '' }, diff --git a/src/components/leaflet-image-overlay.ts b/src/components/leaflet-image-overlay.ts index ea17fde..b2cc9b0 100644 --- a/src/components/leaflet-image-overlay.ts +++ b/src/components/leaflet-image-overlay.ts @@ -1,10 +1,10 @@ import { ImageOverlay, LatLngBounds, LatLngExpression } from 'leaflet'; import type { ImageOverlayOptions } from 'leaflet'; -import { buildOptions, buildAttrMap, setLayerAttr, parseBoundsAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, buildAttrMap, setLayerAttr, parseBoundsAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { url: { kind: 'str', attr: 'url', default: '' }, diff --git a/src/components/leaflet-layer-group.ts b/src/components/leaflet-layer-group.ts index 8d47c22..51ff034 100644 --- a/src/components/leaflet-layer-group.ts +++ b/src/components/leaflet-layer-group.ts @@ -1,6 +1,6 @@ import { LayerGroup, Layer } from 'leaflet'; -import { buildOptions } from '../core/utils.js'; -import { registerChildren, unregisterChildren, getChildren } from '../core/register.js'; +import { buildOptions } from '../core/utils.ts'; +import { registerChildren, unregisterChildren, getChildren } from '../core/register.ts'; export class LeafletLayerGroup extends HTMLElement { #obj?: LayerGroup; diff --git a/src/components/leaflet-map.ts b/src/components/leaflet-map.ts index 241d84b..ae1aada 100644 --- a/src/components/leaflet-map.ts +++ b/src/components/leaflet-map.ts @@ -1,5 +1,5 @@ import { Icon, Map as LMap, MapOptions } from 'leaflet'; -import { LeafletRegisterEvent } from '../core/register.js'; +import { LeafletRegisterEvent } from '../core/register.ts'; const DEFAULT_CSS_URL = 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css'; const DEFAULT_CSS_INTEGRITY = 'sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY='; diff --git a/src/components/leaflet-marker.ts b/src/components/leaflet-marker.ts index fa3ee68..7ec8cf7 100644 --- a/src/components/leaflet-marker.ts +++ b/src/components/leaflet-marker.ts @@ -1,9 +1,9 @@ import { Marker } from 'leaflet'; -import { buildOptions, numAttr, buildAttrMap, setLayerAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, numAttr, buildAttrMap, setLayerAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { lat: { kind: 'num', attr: 'lat', default: 0 }, diff --git a/src/components/leaflet-polygon.ts b/src/components/leaflet-polygon.ts index 516d31f..e3e07f6 100644 --- a/src/components/leaflet-polygon.ts +++ b/src/components/leaflet-polygon.ts @@ -1,11 +1,11 @@ import { Polygon } from 'leaflet'; -import { buildOptions } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import { isPathStyleAttr, updatePathStyle } from '../core/path-style.js'; -import type { PropDef } from '../core/props.js'; -import type { LeafletLine } from './leaflet-line.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts'; +import type { PropDef } from '../core/props.ts'; +import type { LeafletLine } from './leaflet-line.ts'; const PROPS = { color: { kind: 'str', attr: 'color', default: '#3388ff' }, diff --git a/src/components/leaflet-polyline.ts b/src/components/leaflet-polyline.ts index bc2a532..45fb4f2 100644 --- a/src/components/leaflet-polyline.ts +++ b/src/components/leaflet-polyline.ts @@ -1,11 +1,11 @@ import { Polyline } from 'leaflet'; -import { buildOptions } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import { isPathStyleAttr, updatePathStyle } from '../core/path-style.js'; -import type { PropDef } from '../core/props.js'; -import type { LeafletLine } from './leaflet-line.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts'; +import type { PropDef } from '../core/props.ts'; +import type { LeafletLine } from './leaflet-line.ts'; const PROPS = { color: { kind: 'str', attr: 'color', default: '#3388ff' }, diff --git a/src/components/leaflet-popup.ts b/src/components/leaflet-popup.ts index 1cb55dd..dba3026 100644 --- a/src/components/leaflet-popup.ts +++ b/src/components/leaflet-popup.ts @@ -1,8 +1,8 @@ import { Popup } from 'leaflet'; -import { registerWithParent, buildOptions, numAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { registerWithParent, buildOptions, numAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import type { PropDef } from '../core/props.js'; +import type { PropDef } from '../core/props.ts'; const PROPS = { lat: { kind: 'num', attr: 'lat', default: 0 }, diff --git a/src/components/leaflet-rectangle.ts b/src/components/leaflet-rectangle.ts index 526e2a4..05d350c 100644 --- a/src/components/leaflet-rectangle.ts +++ b/src/components/leaflet-rectangle.ts @@ -1,10 +1,10 @@ import { Rectangle } from 'leaflet'; -import { buildOptions, parseBoundsAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, parseBoundsAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import { isPathStyleAttr, updatePathStyle } from '../core/path-style.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import { isPathStyleAttr, updatePathStyle } from '../core/path-style.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { bounds: { kind: 'str', attr: 'bounds', default: '' }, diff --git a/src/components/leaflet-svg-overlay.ts b/src/components/leaflet-svg-overlay.ts index 138f968..a2a472c 100644 --- a/src/components/leaflet-svg-overlay.ts +++ b/src/components/leaflet-svg-overlay.ts @@ -1,10 +1,10 @@ import { SVGOverlay, LatLngBounds, LatLngExpression } from 'leaflet'; import type { ImageOverlayOptions } from 'leaflet'; -import { buildOptions, buildAttrMap, setLayerAttr, parseBoundsAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, buildAttrMap, setLayerAttr, parseBoundsAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { bounds: { kind: 'str', attr: 'bounds', default: '' }, diff --git a/src/components/leaflet-tile-layer-wms.ts b/src/components/leaflet-tile-layer-wms.ts index 2299cdd..dc624f9 100644 --- a/src/components/leaflet-tile-layer-wms.ts +++ b/src/components/leaflet-tile-layer-wms.ts @@ -1,9 +1,9 @@ import { TileLayer } from 'leaflet'; -import { buildOptions, buildAttrMap, setLayerAttr, parseAttributeValue } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, buildAttrMap, setLayerAttr, parseAttributeValue } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { url: { kind: 'str', attr: 'url', default: '' }, diff --git a/src/components/leaflet-tile-layer.ts b/src/components/leaflet-tile-layer.ts index 2264000..bc363a5 100644 --- a/src/components/leaflet-tile-layer.ts +++ b/src/components/leaflet-tile-layer.ts @@ -1,9 +1,9 @@ import { TileLayer } from 'leaflet'; -import { buildOptions, buildAttrMap, setLayerAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, buildAttrMap, setLayerAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { url: { kind: 'str', attr: 'url', default: '' }, diff --git a/src/components/leaflet-tooltip.ts b/src/components/leaflet-tooltip.ts index 4d1fb94..ce8fcd5 100644 --- a/src/components/leaflet-tooltip.ts +++ b/src/components/leaflet-tooltip.ts @@ -1,9 +1,9 @@ import { Tooltip } from 'leaflet'; import type { TooltipOptions } from 'leaflet'; -import { registerWithParent, buildOptions, numAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { registerWithParent, buildOptions, numAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import type { PropDef } from '../core/props.js'; +import type { PropDef } from '../core/props.ts'; const PROPS = { lat: { kind: 'num', attr: 'lat', default: 0 }, diff --git a/src/components/leaflet-video-overlay.ts b/src/components/leaflet-video-overlay.ts index 03425d6..88fe63a 100644 --- a/src/components/leaflet-video-overlay.ts +++ b/src/components/leaflet-video-overlay.ts @@ -1,10 +1,10 @@ import { VideoOverlay, LatLngBounds, LatLngExpression } from 'leaflet'; import type { VideoOverlayOptions } from 'leaflet'; -import { buildOptions, buildAttrMap, setLayerAttr, parseBoundsAttr } from '../core/utils.js'; -import { withProps } from '../core/with-props.js'; +import { buildOptions, buildAttrMap, setLayerAttr, parseBoundsAttr } from '../core/utils.ts'; +import { withProps } from '../core/with-props.ts'; -import { registerChildren, unregisterChildren } from '../core/register.js'; -import type { PropDef } from '../core/props.js'; +import { registerChildren, unregisterChildren } from '../core/register.ts'; +import type { PropDef } from '../core/props.ts'; const PROPS = { url: { kind: 'str', attr: 'url', default: '' }, diff --git a/src/core/path-style.ts b/src/core/path-style.ts index fe1f8cb..2e3fac9 100644 --- a/src/core/path-style.ts +++ b/src/core/path-style.ts @@ -1,5 +1,5 @@ import { Path } from 'leaflet'; -import { parseAttributeValue } from './utils.js'; +import { parseAttributeValue } from './utils.ts'; // The set of HTML attribute names that map to Leaflet Path style options. // These are handled specially because Leaflet exposes them through diff --git a/src/core/register.ts b/src/core/register.ts index b032eba..39989ed 100644 --- a/src/core/register.ts +++ b/src/core/register.ts @@ -1,5 +1,5 @@ import { Layer, LayerGroup, Popup, Tooltip } from 'leaflet'; -import { registerWithParent } from './utils.js'; +import { registerWithParent } from './utils.ts'; // Custom event type for the bubbling registration protocol. Carries the // Leaflet object and the originating element so the nearest parent can diff --git a/src/core/utils.ts b/src/core/utils.ts index 0ee7f41..a2cd70c 100644 --- a/src/core/utils.ts +++ b/src/core/utils.ts @@ -1,4 +1,4 @@ -import type { PropDef, PropTypesFromTable } from './props.js'; +import type { PropDef, PropTypesFromTable } from './props.ts'; import type { LatLngBoundsExpression } from 'leaflet'; // Parses an HTML attribute string into a typed JS value: diff --git a/src/core/with-props.ts b/src/core/with-props.ts index 23720e2..0ab482d 100644 --- a/src/core/with-props.ts +++ b/src/core/with-props.ts @@ -1,5 +1,5 @@ -import type { PropDef, PropTypesFromTable } from './props.js'; -import { definePropAccessors } from './utils.js'; +import type { PropDef, PropTypesFromTable } from './props.ts'; +import { definePropAccessors } from './utils.ts'; // eslint-disable-next-line @typescript-eslint/no-explicit-any type Ctor = new (...args: any[]) => T; diff --git a/src/index.ts b/src/index.ts index 67ce946..669fd29 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,26 +1,26 @@ -export * from './core/utils.js'; -export * from './core/with-props.js'; -export * from './core/path-style.js'; -export * from './core/register.js'; -export * from './core/props.js'; -export * from './components/leaflet-map.js'; -export * from './components/leaflet-marker.js'; -export * from './components/leaflet-circle.js'; -export * from './components/leaflet-circle-marker.js'; -export * from './components/leaflet-line.js'; -export * from './components/leaflet-polygon.js'; -export * from './components/leaflet-polyline.js'; -export * from './components/leaflet-rectangle.js'; -export * from './components/leaflet-tile-layer.js'; -export * from './components/leaflet-tile-layer-wms.js'; -export * from './components/leaflet-image-overlay.js'; -export * from './components/leaflet-video-overlay.js'; -export * from './components/leaflet-svg-overlay.js'; -export * from './components/leaflet-layer-group.js'; -export * from './components/leaflet-feature-group.js'; -export * from './components/leaflet-geojson.js'; -export * from './components/leaflet-control-zoom.js'; -export * from './components/leaflet-control-attribution.js'; -export * from './components/leaflet-control-scale.js'; -export * from './components/leaflet-popup.js'; -export * from './components/leaflet-tooltip.js'; +export * from './core/utils.ts'; +export * from './core/with-props.ts'; +export * from './core/path-style.ts'; +export * from './core/register.ts'; +export * from './core/props.ts'; +export * from './components/leaflet-map.ts'; +export * from './components/leaflet-marker.ts'; +export * from './components/leaflet-circle.ts'; +export * from './components/leaflet-circle-marker.ts'; +export * from './components/leaflet-line.ts'; +export * from './components/leaflet-polygon.ts'; +export * from './components/leaflet-polyline.ts'; +export * from './components/leaflet-rectangle.ts'; +export * from './components/leaflet-tile-layer.ts'; +export * from './components/leaflet-tile-layer-wms.ts'; +export * from './components/leaflet-image-overlay.ts'; +export * from './components/leaflet-video-overlay.ts'; +export * from './components/leaflet-svg-overlay.ts'; +export * from './components/leaflet-layer-group.ts'; +export * from './components/leaflet-feature-group.ts'; +export * from './components/leaflet-geojson.ts'; +export * from './components/leaflet-control-zoom.ts'; +export * from './components/leaflet-control-attribution.ts'; +export * from './components/leaflet-control-scale.ts'; +export * from './components/leaflet-popup.ts'; +export * from './components/leaflet-tooltip.ts'; diff --git a/tsconfig.json b/tsconfig.json index 3433f3c..cd345d0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,8 @@ "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, + "allowImportingTsExtensions": true, + "rewriteRelativeImportExtensions": true, }, "include": ["src/**/*"] }