npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kartore/editor

v0.5.2

Published

The [Kartore](https://app.kartore.io) MapLibre style editor as a source-distributed Svelte 5 package. A host is a plain Vite project: the `kartore()` preset builds the editor SPA, and a small runtime entry serves the adapter APIs on **Cloudflare Workers**

Readme

@kartore/editor

The Kartore MapLibre style editor as a source-distributed Svelte 5 package. A host is a plain Vite project: the kartore() preset builds the editor SPA, and a small runtime entry serves the adapter APIs on Cloudflare Workers or Node (no SvelteKit).

Host

// vite.config.ts (Cloudflare Workers)
import { cloudflare } from '@cloudflare/vite-plugin';
import { kartore } from '@kartore/editor/vite';
import { fileAdapter } from '@kartore/file-adapter/vite';
import { defineConfig } from 'vite';

export default defineConfig({
	plugins: [kartore({ adapters: [fileAdapter()], runtime: 'cloudflare' }), cloudflare()]
});
// worker.ts
import { createCloudflareHandler } from '@kartore/editor/server/cloudflare';
export default createCloudflareHandler(); // KV binding 'KARTORE_KV' by default
// wrangler.jsonc
"main": "./worker.ts",
"assets": { "binding": "ASSETS", "not_found_handling": "none", "run_worker_first": ["/api/*"] }

Paths without a file reach the Worker, which answers index.html for the editor and adapter pages and 404 for missing build assets (/assets/…, e.g. chunks referenced by an HTML page from before a deploy). With not_found_handling: "single-page-application" those missing chunks get index.html and the page stays blank.

index.html only needs a <head> (charset, viewport, favicon, title); kartore() injects the editor entry.

Node (srvx): kartore({ adapters, runtime: 'node', nodeConfig: './kartore.node.ts', nodeServer: './server.node.ts' }). vite build then emits dist/client and dist/server/server.node.js.

// kartore.node.ts — shared by the dev middleware and the production server
import { sqliteKv } from '@kartore/editor/server/kv';
export default { kv: sqliteKv('.kartore/kv.sqlite') }; // env defaults to process.env

// server.node.ts
import { startNodeServer } from '@kartore/editor/server/node';
import config from './kartore.node.ts';
startNodeServer({ ...config, clientDir: new URL('../client/', import.meta.url) });

Behind a reverse proxy set PUBLIC_ORIGIN (used for runtime.origin, secure cookies and the CSRF check).

See playground/ for a host with both entries (pnpm dev / dev:node / build / build:node / start:node).

Sub path (base)

To share a host with another app, put Kartore under a path: kartore({ ..., base: '/studio/' }) (default '/'). The editor is served at /studio/, adapter pages at /studio/<module id>/<page path> and APIs at /studio/api/<id>/*. Vite's base is set to the same value (assets at /studio/assets/…); do not set Vite's base separately. The server core strips the base before calling an adapter, so handlers still see /api/<id>/*.

The build output is not nested: dist/client holds index.html and assets/, and the runtime maps it under the base.

// wrangler.jsonc (Cloudflare): serve dist/client under /studio/, run the worker only for the APIs
"assets": {
	"binding": "ASSETS",
	"base_path": "/studio/",
	"not_found_handling": "none", // the worker answers /studio/index.html for pages, 404 for /studio/assets/…
	"run_worker_first": ["/studio/api/*"]
}

On Node, startNodeServer serves clientDir under the base, falls back to index.html inside the base (404 for missing /studio/assets/…), redirects /studio to /studio/ and answers 404 outside it. Kartore's cookies are scoped to the base (kartore_session: /studio/); localStorage (kartore:*) and IndexedDB (kartore-drafts, kartore-fonts) are per origin, so other apps on the same origin must not use those names. The playground runs this setup with pnpm dev:studio / build:studio / dev:node:studio / build:node:studio.

Exports

| Subpath | Contents | | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | @kartore/editor/vite | kartore() preset | | @kartore/editor/types | Types only: EditorModule, EditorApi, SpriteIcons, KartoreRuntime, AdapterApiHandler, local draft types, … | | @kartore/editor/paths | Client URLs under the host base: base, withBase(path), apiPath(id, path), pagePath(id, path) | | @kartore/editor/server | handleKartoreRequest(request, createRuntime) (runtime-agnostic server core), createRuntimeBase | | @kartore/editor/server/cloudflare / /node | createCloudflareHandler() / startNodeServer() | | @kartore/editor/server/kv | memoryKv(), sqliteKv(path) (node:sqlite) | | @kartore/editor/storage | Local draft storage: createIndexedDbEditorStorage(), createDefaultEditorStorage(), listUnsavedDrafts() | | @kartore/editor/export | style.json / sprite (spritore) / glyph (glyphore) / ZIP builders and content hashes | | @kartore/editor | Editor / EditorRoot Svelte components |

Local drafts (per-style storage)

By default the editor keeps one draft (localStorage kartore:style / kartore:sprite-svgs, IndexedDB kartore-fonts). To keep one draft per style, pass kartore({ storage: './kartore.storage.ts' }):

import { createIndexedDbEditorStorage, type KartoreStorageConfig } from '@kartore/editor/storage';

export default {
	storage: createIndexedDbEditorStorage(), // style, icons, fonts and metadata per scope in IndexedDB
	scope: () => resolveScopeFromLocation() // e.g. '<env>:<user>:<org>:<style>'; may return a Promise
} satisfies KartoreStorageConfig;

With such a storage the editor asks to recover unsaved edits when a scope is opened and confirms before the page is closed. Adapters switch scopes with editor.openDraftScope(scope) and record saves with editor.markSaved().

Adapter contract v2

An adapter is a manifest ({ name, api: { kartoreAdapter: { contract: 2, clientModule, serverModule? } } }) passed to kartore({ adapters }).

  • clientModule exports adapterModules: EditorModule[] and adapterProviders
  • serverModule exports adapterApiHandlers: AdapterApiHandler[] — { id, requiredEnv?, optionalEnv?, fetch(request, runtime) }, served at <base>api/<id>/* (the handler sees /api/<id>/*). runtime is a KartoreRuntime (env strings, an <id>:-namespaced kv, waitUntil, origin, secure, base, and url(path) = origin + base + path for OAuth callbacks, links and cookie paths)
  • Adapter clients build their URLs with @kartore/editor/paths (apiPath('github', '/me') → /studio/api/github/me), never root-absolute paths
  • Adapter pages receive the current URL as the url prop. SvelteKit modules ($app/*, $env/*, @sveltejs/kit) are a build error
  • Types come from @kartore/editor/types (declare @kartore/editor as a peer dependency)

Development

pnpm install
pnpm dev          # playground (Cloudflare dev via @cloudflare/vite-plugin)
pnpm test         # vitest
pnpm check        # svelte-check
pnpm lint
pnpm build        # tsdown: dist/vite.js + dist/vite.d.ts (the kartore() preset)