Compare commits

..

2 Commits

Author SHA1 Message Date
Buddy
1914d5bf1d chore: prep 0.1.0 for npm + JSR publish
npm name `leaflet-components` is taken by another author, so the npm package
is renamed to `leaflet-web-components`; JSR stays `@buddy/leaflet-components`.
Adds the MIT `LICENSE` file (was declared but missing).

Entry split so JSR can publish with no slow types:

- `src/index.ts` is the shared/JSR entry and no longer carries any
  `declare global`.
- `src/core/globals.ts` (new) holds the `HTMLElementTagNameMap` /
  `HTMLElementEventMap` augmentations; imported only by the new npm entry
  `src/index.npm.ts` and by `test/setup.ts`, and listed in `jsr.json`'s
  `publish.exclude` so it never enters JSR's module graph.
- `package.json` `.`/`main`/`module`/`types` now point at `dist/index.npm.*`.

Every element file switches from `class extends WithProps({...})` to a
`const PROPS` (with an explicit type) plus
`const Base: LeafletElementConstructor<TheClass, typeof PROPS> = WithProps(PROPS)`,
which is what clears JSR's `unsupported-super-class-expr` /
`missing-explicit-type` errors. Adds a `Positional<T, Obj>` alias in
`props.ts` and explicit object types on the `shared-props.ts` fragments to
keep those annotations short. Empty group tables use `Record<never, never>`.

`npx jsr publish --dry-run` now reports "Success" with zero slow-type
errors; `npm run typecheck`, `lint`, `test` (76) and `build` all pass.

CLAUDE.md, docs/ and README.md updated for the rename, the entry split, and
the `const PROPS` / `const Base` pattern.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012QpbBzyzsMCzDu2nX1zVUx
2026-09-08 21:44:20 -07:00
Buddy
d753fd82b5 refactor: split element classes from customElements.define
Every component is now two modules sharing a basename:

- src/elements/leaflet-foo.ts -- `export default class LeafletFooElement
  extends WithProps(...)`, the class only, no customElements.define, no
  side effects. src/elements/index.ts is an order-free barrel.
- src/components/leaflet-foo.ts -- three lines: import the class, define
  the tag, re-export. Importing this (or src/index.ts) registers the tag.

Plugin authors can now import a class without triggering the built-in
define, to subclass it or register it under a different tag name. Package
subpath exports `leaflet-components/elements`,
`leaflet-components/elements/leaflet-foo.js`, and
`leaflet-components/components/leaflet-foo.js` map onto dist/; jsr.json
gains an `./elements` entry.

The load-bearing ordering moves from the export statements in src/index.ts
to its `./components/*` side-effect imports (the elements barrel carries no
define, so its order is free). Classes are renamed LeafletFoo ->
LeafletFooElement, including in the HTMLElementTagNameMap augmentation.

Docs (CLAUDE.md, docs/, README.md) updated for the new layout.
2026-09-08 20:59:45 -07:00
8 changed files with 45 additions and 127 deletions

View File

@ -12,7 +12,7 @@ stays a terse working cheat-sheet; `docs/` is the "why".
```bash ```bash
npm run build # tsc emits individual ESM modules to dist/ (no bundling) npm run build # tsc emits individual ESM modules to dist/ (no bundling)
npm run typecheck # tsc --noEmit, then tsc -p tsconfig.test.json for test/ npm run typecheck # tsc --noEmit, then tsc -p tsconfig.test.json for test/
npm run lint # oxlint over src/, test/, scripts/ npm run lint # oxlint over src/ and test/
npm run format # oxfmt formatting npm run format # oxfmt formatting
npm run test # vitest run npm run test # vitest run
npm run test:watch # vitest, watch mode npm run test:watch # vitest, watch mode
@ -45,7 +45,7 @@ Every component is split across two files with the same basename:
- **`src/elements/leaflet-foo.ts`** — a `const PROPS`, a `const Base = WithProps(PROPS)` (explicitly typed — see below), then `export default class LeafletFooElement extends Base {...}`. The class only; **no `customElements.define`**, no side effects. `src/elements/index.ts` is a barrel re-exporting all of them by name (`LeafletFooElement`), order-free because nothing here registers a tag. - **`src/elements/leaflet-foo.ts`** — a `const PROPS`, a `const Base = WithProps(PROPS)` (explicitly typed — see below), then `export default class LeafletFooElement extends Base {...}`. The class only; **no `customElements.define`**, no side effects. `src/elements/index.ts` is a barrel re-exporting all of them by name (`LeafletFooElement`), order-free because nothing here registers a tag.
- **`src/components/leaflet-foo.ts`** — three lines: `import LeafletFooElement from '../elements/leaflet-foo.ts'`, `customElements.define('leaflet-foo', LeafletFooElement)`, `export { LeafletFooElement }`. Importing this module (or `src/index.ts` / `src/index.npm.ts`) is what actually registers the tag. - **`src/components/leaflet-foo.ts`** — three lines: `import LeafletFooElement from '../elements/leaflet-foo.ts'`, `customElements.define('leaflet-foo', LeafletFooElement)`, `export { LeafletFooElement }`. Importing this module (or `src/index.ts` / `src/index.npm.ts`) is what actually registers the tag.
Most consumers just import the package root (or a `components/*` module) and get the tags defined. The `elements/*` classes exist for plugin authors who want to subclass an element or register it under a different tag name without triggering the built-in `define`. Package subpath exports (`leaflet-web-components/elements`, `.../elements/leaflet-foo.js`, `.../components/leaflet-foo.js`) map straight onto `dist/` — the per-file ones are npm-only, since JSR (`jsr.json` `exports`) has no subpath patterns and exposes just `.` and `./elements`. Most consumers just import the package root (or a `components/*` module) and get the tags defined. The `elements/*` classes exist for plugin authors who want to subclass an element or register it under a different tag name without triggering the built-in `define`. Package subpath exports (`leaflet-web-components/elements`, `.../elements/leaflet-foo.js`, `.../components/leaflet-foo.js`) map straight onto `dist/`.
### Two package entry points: `src/index.ts` vs `src/index.npm.ts` ### Two package entry points: `src/index.ts` vs `src/index.npm.ts`
@ -113,18 +113,13 @@ If you add or change what events a component fires, keep `#forwardEvents`'s `det
### Output & dual publish ### Output & dual publish
`tsc` compiles `src/` → `dist/` as individual ESM modules (`.js` + `.d.ts` + `.d.ts.map`) — no bundling step, so `dist/elements/` and `dist/components/` mirror `src/`. There is no CJS or UMD build. Imports within source use `.ts` extensions; `rewriteRelativeImportExtensions` strips them to `.js` in the emitted `.js` (the `.d.ts` keep `.ts` specifiers, which TS resolves to the sibling `.d.ts`). `tsc` compiles `src/` → `dist/` as individual ESM modules (`.js` + `.d.ts` + `.d.ts.map`) — no bundling step, so `dist/elements/` and `dist/components/` mirror `src/`. There is no CJS or UMD build. Leaflet is always external (never bundled). Imports within source use `.ts` extensions; `rewriteRelativeImportExtensions` in tsconfig strips them to `.js` in the emitted `.js` (the `.d.ts` keep `.ts` specifiers, which TS resolves to the sibling `.d.ts`).
- **`leaflet` is a `peerDependency`** (`^1.9.4`), also kept in `devDependencies` for local dev/tests — a second copy would break the `instanceof`-based nesting protocol. **`@types/leaflet` + `@types/geojson` are regular `dependencies`** (the emitted `.d.ts` reference them; `leaflet` ships no types). Two registries, different entry files (both pinned to the same version — keep them in step):
- **`files` ships `dist/` and `src/`** — the `.d.ts.map` point at `../../src/*.ts`, so source has to be there for "go to definition" (and it matches JSR).
- **`sideEffects`** is the explicit list `dist/index.js`, `dist/index.npm.js`, `dist/components/*.js` — the only modules that `customElements.define()` on import; everything else is tree-shakeable.
- **No `./dist/*` export.** The per-file `./elements/*.js` / `./components/*.js` subpaths are **npm-only** (JSR has no subpath patterns).
Two registries, different entry files. Both carry a `version`; `scripts/sync-version.mjs` (the `version` lifecycle hook, and re-run in `prepublishOnly`) copies `package.json`'s version into `jsr.json`. | Registry | Package name | Entry | Ships |
| -------- | --------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Registry | Package name | Entry | Ships | | npm | `leaflet-web-components` | `package.json` `.`/`main`/`module`/`types` → `dist/index.npm.*` | compiled `dist/` + `README.md` + `LICENSE` (`files` field); `prepublishOnly` runs `build` |
| -------- | --------------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | JSR | `@buddy/leaflet-components` | `jsr.json` `exports` → `./src/index.ts` (+ `./elements`) | TypeScript source directly, minus `jsr.json`'s `publish.exclude` (which drops `src/index.npm.ts`, `src/core/globals.ts`, `test/`, `docs/`, `dist/`, configs) |
| npm | `leaflet-web-components` | `package.json` `.`/`main`/`module`/`types` → `dist/index.npm.*` | `dist/` + `src/` + `README.md` + `LICENSE` (`files` field); `prepublishOnly` runs `sync-version` + `typecheck` + `test` + `build` |
| JSR | `@buddy/leaflet-components` | `jsr.json` `exports` → `./src/index.ts` (+ `./elements`) | TypeScript source directly, minus `jsr.json`'s `publish.exclude` (`src/index.npm.ts`, `src/core/globals.ts`, `test/`, `docs/`, `scripts/`, `dist/`, configs, `CLAUDE.md`) |
The npm entry (`src/index.npm.ts`) adds the `declare global` augmentations via `src/core/globals.ts`; the JSR entry (`src/index.ts`) can't, because JSR's "no slow types" check forbids `declare global` in its published graph. That constraint is also why every element file uses the explicitly-typed `const PROPS` / `const Base` shape (see the `WithProps` section). `npx jsr publish --dry-run` is the authoritative check; it must print "Success" with no slow-type errors. The npm entry (`src/index.npm.ts`) adds the `declare global` augmentations via `src/core/globals.ts`; the JSR entry (`src/index.ts`) can't, because JSR's "no slow types" check forbids `declare global` in its published graph. That constraint is also why every element file uses the explicitly-typed `const PROPS` / `const Base` shape (see the `WithProps` section). `npx jsr publish --dry-run` is the authoritative check; it must print "Success" with no slow-type errors.

View File

@ -8,16 +8,11 @@
npm install leaflet-web-components leaflet npm install leaflet-web-components leaflet
``` ```
`leaflet` is a **peer dependency** — you install it, and only one copy must be Also published to JSR as [`@buddy/leaflet-components`](https://jsr.io/@buddy/leaflet-components) (`deno add jsr:@buddy/leaflet-components`). `leaflet` is always a peer dependency you install yourself; there is no CommonJS or UMD build. The examples below use the npm name — substitute `@buddy/leaflet-components` if you pull from JSR.
present (the nesting protocol relies on `instanceof` against Leaflet's own
classes). The Leaflet type definitions (`@types/leaflet`, `@types/geojson`)
ship as regular dependencies, so TypeScript consumers need nothing extra.
Also published to JSR as [`@buddy/leaflet-components`](https://jsr.io/@buddy/leaflet-components) (`deno add jsr:@buddy/leaflet-components`). There is no CommonJS or UMD build. The examples below use the npm name — substitute `@buddy/leaflet-components` if you pull from JSR.
## Import options ## Import options
The package is ESM-only — `tsc` emits `dist/` as individual modules, one per component, with no bundling step. Deep imports let you register only what you use. The package is ESM-only — `tsc` emits `dist/` as individual modules, one per component, with no bundling step. Deep imports work for registering only what you use.
```js ```js
// Registers all components // Registers all components
@ -27,8 +22,6 @@ import 'leaflet-web-components';
import 'leaflet-web-components/components/leaflet-marker.js'; import 'leaflet-web-components/components/leaflet-marker.js';
``` ```
Per-component deep imports (`./components/*.js`, `./elements/*.js`) are an **npm-only** convenience — JSR doesn't support subpath patterns, so from JSR the entry points are just the root and `@buddy/leaflet-components/elements` (the class barrel). JSR consumers who want selective registration import the class and call `customElements.define()` themselves.
Each component is two modules with the same basename: `components/leaflet-marker.js` is the side-effecting one that calls `customElements.define()`, and `elements/leaflet-marker.js` is just the class (`default` export, **no** `define`). Import from `elements/` when you want to subclass a component or register it under a different tag name: Each component is two modules with the same basename: `components/leaflet-marker.js` is the side-effecting one that calls `customElements.define()`, and `elements/leaflet-marker.js` is just the class (`default` export, **no** `define`). Import from `elements/` when you want to subclass a component or register it under a different tag name:
```js ```js

View File

@ -33,8 +33,7 @@ extends Base` (where `const Base = WithProps(PROPS)`) — the class alone, no
`package.json` maps `leaflet-web-components/elements`, `package.json` maps `leaflet-web-components/elements`,
`.../elements/leaflet-foo.js` and `.../components/leaflet-foo.js` onto the `.../elements/leaflet-foo.js` and `.../components/leaflet-foo.js` onto the
matching `dist/` files. The per-file subpaths are npm-only — `jsr.json` matching `dist/` files.
exposes just `.` and `./elements` (JSR has no subpath patterns).
### Two package entry points ### Two package entry points

View File

@ -2,14 +2,13 @@
## Scripts ## Scripts
| `npm run …` | Does | | `npm run …` | Does |
| --------------------- | ---------------------------------------------------------------------------- | | --------------------- | ----------------------------------------------------------------------- |
| `build` | `rm -rf dist && tsc --outDir dist` | | `build` | `rm -rf dist && tsc --outDir dist` |
| `typecheck` | `tsc --noEmit`, then `tsc -p tsconfig.test.json` | | `typecheck` | `tsc --noEmit`, then `tsc -p tsconfig.test.json` |
| `lint` | `oxlint src test scripts` | | `lint` | `oxlint src test` |
| `format` | `oxfmt` over `*.md`, `docs/`, `src/`, `test/`, `scripts/` | | `format` | `oxfmt '*.md' 'docs/**/*.md' 'src/**/*.{ts,js,json,md}' 'test/**/*.ts'` |
| `test` / `test:watch` | `vitest run` / `vitest` | | `test` / `test:watch` | `vitest run` / `vitest` |
| `sync-version` | copy `package.json` version → `jsr.json` (also the `version` lifecycle hook) |
## TypeScript 7 ## TypeScript 7
@ -110,45 +109,26 @@ export default defineConfig({
`src/index.ts` on JSR — see "Publishing" below) or any single module `src/index.ts` on JSR — see "Publishing" below) or any single module
directly. directly.
- **No CJS, no UMD** build. - **No CJS, no UMD** build.
- The npm tarball ships **`src/` as well as `dist/`** (`files` field) — the - **Leaflet is always external** — never bundled. It's a `dependencies` entry
`.d.ts.map` files reference `../../src/*.ts`, so shipping the source is what and a bare `import` in the output.
makes "go to definition" land on real code, and it matches what JSR
publishes.
- **Leaflet is always external** — never bundled, a bare `import` in the
output. It's a **`peerDependency`** (`^1.9.4`), not a regular dependency:
the nesting protocol keys off `instanceof` against Leaflet's own `Layer` /
`Popup` / `Tooltip`, so a second copy under our own `node_modules` would
silently break it. Kept in `devDependencies` too, for local dev and tests.
The Leaflet **type** packages (`@types/leaflet`, `@types/geojson`) are
regular `dependencies` — the emitted `.d.ts` reference them directly, and
`leaflet` ships no types of its own.
- `package.json` `exports`: `.` → `dist/index.npm.js` (+ types — this is the - `package.json` `exports`: `.` → `dist/index.npm.js` (+ types — this is the
npm entry, `src/index.npm.ts` compiled; see below); npm entry, `src/index.npm.ts` compiled; see below);
`./elements` → `dist/elements/index.js` (the class barrel, no `define`); `./elements` → `dist/elements/index.js` (the class barrel, no `define`);
`./elements/*.js` and `./components/*.js` → the matching `dist/` module. `./elements/*.js` and `./components/*.js` → the matching `dist/` module;
There is deliberately **no `./dist/*`** wildcard — `core/*` is not a stable `./dist/*` still there for deep imports.
contract, and the root export already surfaces the toolkit. The per-file - `sideEffects: true` — the `components/*` modules (and both `index*.js`
`./elements/*.js` / `./components/*.js` patterns are **npm-only**: JSR has entries) call `customElements.define()` at import time, so a bundler must
no subpath-pattern support, so `jsr.json` `exports` is just `.` + not tree-shake them away. The `elements/*` modules have no side effect.
`./elements`.
- `sideEffects` is an explicit allowlist — `dist/index.js`,
`dist/index.npm.js`, `dist/components/*.js` — the only modules that run
`customElements.define()` at import. Everything else (`elements/*`,
`core/*`, and `core/globals.js`, whose augmentation is type-only) is
side-effect-free, so a bundler may drop it when unused.
## Publishing to two registries ## Publishing to two registries
| Registry | Package name | Entry | Ships | | Registry | Package name | Entry | Ships |
| -------- | --------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | | -------- | --------------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| npm | `leaflet-web-components` | `package.json` `.`/`main`/`module`/`types` → `dist/index.npm.*` | `dist/` + `src/` + `README.md` + `LICENSE` (`files` field); `prepublishOnly` runs `sync-version` + `typecheck` + `test` + `build` | | npm | `leaflet-web-components` | `package.json` `.`/`main`/`module`/`types` → `dist/index.npm.*` | compiled `dist/` + `README.md` + `LICENSE` (`files` field); `prepublishOnly` runs `build` |
| JSR | `@buddy/leaflet-components` | `jsr.json` `exports` → `./src/index.ts` (+ `./elements`) | TypeScript source directly (JSR compiles per-consumer), minus `jsr.json`'s `publish.exclude` | | JSR | `@buddy/leaflet-components` | `jsr.json` `exports` → `./src/index.ts` (+ `./elements`) | TypeScript source directly (JSR compiles per-consumer), minus `jsr.json`'s `publish.exclude` |
Both carry a `version` and must stay in step. `scripts/sync-version.mjs` Both are pinned to the same version; keep them in step. JSR publishes `src/`
copies `package.json`'s version into `jsr.json`; it's wired into the `version` with its `.ts` import extensions intact, which JSR supports natively.
npm lifecycle script (so `npm version <bump>` updates and stages both) and
run again from `prepublishOnly`. JSR publishes `src/` with its `.ts` import
extensions intact, which JSR supports natively.
### The npm/JSR entry split ### The npm/JSR entry split

View File

@ -14,11 +14,9 @@
"docs/", "docs/",
"demos/", "demos/",
"dist/", "dist/",
"scripts/",
"index.html", "index.html",
"*.config.ts", "*.config.ts",
"tsconfig*.json", "tsconfig*.json",
"CLAUDE.md",
".idea/", ".idea/",
".claude/" ".claude/"
] ]

15
package-lock.json generated
View File

@ -1,27 +1,23 @@
{ {
"name": "leaflet-web-components", "name": "leaflet-components",
"version": "0.1.0", "version": "0.1.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "leaflet-web-components", "name": "leaflet-components",
"version": "0.1.0", "version": "0.1.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/geojson": "^7946.0.16", "leaflet": "^1.9.4"
"@types/leaflet": "^1.9.21"
}, },
"devDependencies": { "devDependencies": {
"@types/leaflet": "^1.9.21",
"jsdom": "^30.0.1", "jsdom": "^30.0.1",
"leaflet": "^1.9.4",
"oxfmt": "^0.66.0", "oxfmt": "^0.66.0",
"oxlint": "^1.79.0", "oxlint": "^1.79.0",
"typescript": "^7.0.2", "typescript": "^7.0.2",
"vitest": "^4.1.11" "vitest": "^4.1.11"
},
"peerDependencies": {
"leaflet": "^1.9.4"
} }
}, },
"node_modules/@asamuzakjp/css-color": { "node_modules/@asamuzakjp/css-color": {
@ -1255,12 +1251,14 @@
"version": "7946.0.16", "version": "7946.0.16",
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz",
"integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==",
"dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/leaflet": { "node_modules/@types/leaflet": {
"version": "1.9.22", "version": "1.9.22",
"resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.22.tgz", "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.22.tgz",
"integrity": "sha512-h3lhECYEKDasG7LFHu+GiHqAvsgLuQvlJvVZzJDGONo3sEL+wUOqSFLnwkZlK0qVxnxbuGFW8iBlJNYs5wgndA==", "integrity": "sha512-h3lhECYEKDasG7LFHu+GiHqAvsgLuQvlJvVZzJDGONo3sEL+wUOqSFLnwkZlK0qVxnxbuGFW8iBlJNYs5wgndA==",
"dev": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@types/geojson": "*" "@types/geojson": "*"
@ -1954,7 +1952,6 @@
"version": "1.9.4", "version": "1.9.4",
"resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz", "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.9.4.tgz",
"integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==", "integrity": "sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==",
"dev": true,
"license": "BSD-2-Clause" "license": "BSD-2-Clause"
}, },
"node_modules/lightningcss": { "node_modules/lightningcss": {

View File

@ -22,60 +22,38 @@
"types": "./dist/components/*.d.ts", "types": "./dist/components/*.d.ts",
"import": "./dist/components/*.js" "import": "./dist/components/*.js"
}, },
"./dist/*": "./dist/*",
"./package.json": "./package.json" "./package.json": "./package.json"
}, },
"sideEffects": [ "sideEffects": true,
"./dist/index.js",
"./dist/index.npm.js",
"./dist/components/*.js"
],
"files": [ "files": [
"dist", "dist",
"src",
"README.md", "README.md",
"LICENSE" "LICENSE"
], ],
"scripts": { "scripts": {
"build": "rm -rf dist && tsc --outDir dist", "build": "rm -rf dist && tsc --outDir dist",
"typecheck": "tsc --noEmit && tsc -p tsconfig.test.json", "typecheck": "tsc --noEmit && tsc -p tsconfig.test.json",
"lint": "oxlint src test scripts", "lint": "oxlint src test",
"format": "oxfmt '*.md' 'docs/**/*.md' 'src/**/*.{ts,js,json,md}' 'test/**/*.ts' 'scripts/**/*.mjs'", "format": "oxfmt '*.md' 'docs/**/*.md' 'src/**/*.{ts,js,json,md}' 'test/**/*.ts'",
"test": "vitest run", "test": "vitest run",
"test:watch": "vitest", "test:watch": "vitest",
"sync-version": "node scripts/sync-version.mjs", "prepublishOnly": "npm run build"
"version": "npm run sync-version && git add jsr.json",
"prepublishOnly": "npm run sync-version && npm run typecheck && npm run test && npm run build"
}, },
"keywords": [ "keywords": [
"leaflet", "leaflet",
"leafletjs",
"web-components", "web-components",
"custom-elements", "maps"
"webcomponents",
"maps",
"map"
], ],
"author": "Buddy Sandidge", "author": "buddy",
"license": "MIT", "license": "MIT",
"repository": {
"type": "git",
"url": "git+https://git.buddy.wtf/lib/leaflet-components.git"
},
"bugs": {
"url": "https://git.buddy.wtf/lib/leaflet-components/issues"
},
"homepage": "https://git.buddy.wtf/lib/leaflet-components#readme",
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@types/geojson": "^7946.0.16",
"@types/leaflet": "^1.9.21"
},
"peerDependencies": {
"leaflet": "^1.9.4" "leaflet": "^1.9.4"
}, },
"devDependencies": { "devDependencies": {
"@types/leaflet": "^1.9.21",
"jsdom": "^30.0.1", "jsdom": "^30.0.1",
"leaflet": "^1.9.4",
"oxfmt": "^0.66.0", "oxfmt": "^0.66.0",
"oxlint": "^1.79.0", "oxlint": "^1.79.0",
"typescript": "^7.0.2", "typescript": "^7.0.2",

View File

@ -1,22 +0,0 @@
// Keeps `jsr.json`'s version in step with `package.json`.
//
// Wired into the `version` npm lifecycle script, so `npm version <bump>`
// updates both files and stages `jsr.json` into the same commit/tag. Also
// runs from `prepublishOnly` as a guard, and can be run by hand
// (`npm run sync-version`). Exits non-zero only on a real filesystem error;
// a no-op when the versions already match.
import { readFileSync, writeFileSync } from 'node:fs';
const pkgUrl = new URL('../package.json', import.meta.url);
const jsrUrl = new URL('../jsr.json', import.meta.url);
const pkg = JSON.parse(readFileSync(pkgUrl, 'utf8'));
const jsr = JSON.parse(readFileSync(jsrUrl, 'utf8'));
if (jsr.version === pkg.version) {
process.exit(0);
}
jsr.version = pkg.version;
writeFileSync(jsrUrl, `${JSON.stringify(jsr, null, 2)}\n`);
console.log(`sync-version: jsr.json ${jsr.version} (from package.json)`);