@nika-js/onlymap 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/onlymap.code-snippets +173 -0
- package/LICENSE.md +133 -0
- package/README.md +188 -0
- package/bin/onlymapjs.mjs +182 -0
- package/dist/Arrow.dom-7AXne1TU.js +5233 -0
- package/dist/actions.d.ts +30 -0
- package/dist/attribute-resolution.d.ts +73 -0
- package/dist/basemap-D95W0IIA.js +25203 -0
- package/dist/basemap.d.ts +72 -0
- package/dist/convert-arrow-schema-CvZ3cT5m.js +94 -0
- package/dist/csp-sandbox.d.ts +20 -0
- package/dist/ctx.d.ts +49 -0
- package/dist/d3-bundle.d.ts +218 -0
- package/dist/data-emit.d.ts +10 -0
- package/dist/data-layer.d.ts +150 -0
- package/dist/declarative-filter.d.ts +12 -0
- package/dist/dev-error-panel.d.ts +15 -0
- package/dist/draw-controller.d.ts +51 -0
- package/dist/draw.d.ts +102 -0
- package/dist/effects.d.ts +39 -0
- package/dist/elements/om-behavior.d.ts +13 -0
- package/dist/elements/om-layer.d.ts +11 -0
- package/dist/elements/om-map.d.ts +168 -0
- package/dist/elements/om-overlay.d.ts +82 -0
- package/dist/elements/om-step.d.ts +12 -0
- package/dist/elements/om-story.d.ts +67 -0
- package/dist/elements/om-widget.d.ts +29 -0
- package/dist/env.d.ts +41 -0
- package/dist/expr/cache.d.ts +28 -0
- package/dist/expr/compile.d.ts +27 -0
- package/dist/expr/errors.d.ts +10 -0
- package/dist/expr/full-js-block.d.ts +17 -0
- package/dist/expr/index.d.ts +12 -0
- package/dist/expr/output-type.d.ts +12 -0
- package/dist/expr/scale.d.ts +13 -0
- package/dist/expr/script-block.d.ts +16 -0
- package/dist/expr/whitelist.d.ts +28 -0
- package/dist/field-access.d.ts +24 -0
- package/dist/html-data.d.ts +25 -0
- package/dist/index-2v2NXF_n.js +435 -0
- package/dist/index-BFjXVHly.js +605 -0
- package/dist/index-C9w78NS9.js +4883 -0
- package/dist/index-CU-iOTdr.js +75292 -0
- package/dist/index-D74olQ9w.js +3907 -0
- package/dist/index-Do7hmHwi.js +1457 -0
- package/dist/index.d.ts +76 -0
- package/dist/ir-snapshot.d.ts +54 -0
- package/dist/ir.d.ts +66 -0
- package/dist/layer-registry.d.ts +27 -0
- package/dist/layers/popup-layer.d.ts +65 -0
- package/dist/onlymapjs.css +1 -0
- package/dist/onlymapjs.js +30 -0
- package/dist/onlymapjs.umd.cjs +8618 -0
- package/dist/parse-manifest.d.ts +19 -0
- package/dist/recordbatch-HRu0SMKp.js +4742 -0
- package/dist/runtime-core.d.ts +170 -0
- package/dist/selection.d.ts +31 -0
- package/dist/stats.d.ts +29 -0
- package/dist/table-accessors-DBjWgN0C.js +204 -0
- package/dist/template-interpolation.d.ts +6 -0
- package/dist/testing.d.ts +90 -0
- package/dist/timeline.d.ts +37 -0
- package/dist/validation.d.ts +22 -0
- package/dist/vega-loader.d.ts +22 -0
- package/dist/viewport-filter.d.ts +25 -0
- package/dist/widget-registry.d.ts +23 -0
- package/dist/widget-script.d.ts +1 -0
- package/dist/widgets/built-in.d.ts +1 -0
- package/dist/widgets/dom-utils.d.ts +4 -0
- package/llms.txt +43 -0
- package/onlymapjs.html-data.json +1688 -0
- package/package.json +111 -0
- package/skills/onlymapjs/SKILL.md +61 -0
- package/skills/onlymapjs/agents/openai.yaml +4 -0
- package/skills/onlymapjs/references/patterns.md +213 -0
- package/skills/onlymapjs/references/syntax.md +342 -0
- package/skills/onlymapjs/references/testing.md +126 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Small shared helpers for built-in widget rendering. */
|
|
2
|
+
export declare function escapeHtml(s: string): string;
|
|
3
|
+
/** Injects a <style> into the shadow root at most once per widget instance. */
|
|
4
|
+
export declare function ensureStyles(root: ShadowRoot, css: string): void;
|
package/llms.txt
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# OnlyMapJS
|
|
2
|
+
|
|
3
|
+
> Agent-first map library: a declarative HTML manifest drives deck.gl. You write `<om-map>` / `<om-layer>` / `<om-widget>` / `<om-overlay>` / `<om-behavior>` elements; the library owns reconciliation, accessor compilation, basemap/view sync, overlays, and validation. No build step, no imperative deck.gl code.
|
|
4
|
+
|
|
5
|
+
OnlyMapJS is NOT raw deck.gl and NOT generic HTML/JSX. The rules below are the delta from what you already assume — following them produces correct manifests on the first pass. Validate with `OmMap.validate(htmlString)` (structured errors, each with a `fix` instruction) and inspect resolved output with `OmMap.snapshotIR(htmlString)` before finalizing.
|
|
6
|
+
|
|
7
|
+
## Rules that differ from your training priors
|
|
8
|
+
|
|
9
|
+
- Always write explicit closing tags: `<om-layer ...></om-layer>`. NEVER self-close (`<om-layer ... />`) — HTML5 ignores the slash on custom elements and every following sibling silently becomes a child.
|
|
10
|
+
- Attributes are kebab-case, not camelCase: `get-fill-color`, `radius-units`, `line-width-min-pixels`. Every hyphenated attribute maps to the camelCase deck.gl prop.
|
|
11
|
+
- Accessors are expressions in attributes, not JS functions: `get-position="[$lon, $lat]"`, `get-radius="$population * 0.001"`. `$field` reads a datum field; the library resolves flat vs. GeoJSON shape for you — never write `d.properties.x`.
|
|
12
|
+
- Inline event handlers (`onclick="..."`) are rejected. Use `data-emit` attributes (`<span data-emit="hide-overlay" data-target="popup1">`) or `addEventListener` inside a `<script type="om/widget">` block where `ctx` is in scope.
|
|
13
|
+
- `scale()` requires an explicit `domain=`: `get-fill-color="scale($depth, sequential, ['#ffffcc','#800026'], domain=[0,700])"`. A missing domain is a validation error.
|
|
14
|
+
- `id` is required on every `<om-layer>`. `label` and `color` feed the legend; an explicit `get-fill-color` overrides `color` for rendering (both together is valid and common).
|
|
15
|
+
- Full JavaScript in accessor blocks needs the `js` attribute on the layer (`<om-layer js>` + `<script type="om/accessors">`). Without it, blocks are restricted to `export const name = d => <expression>` — no statements, no loops, no nested functions.
|
|
16
|
+
|
|
17
|
+
## Element vocabulary
|
|
18
|
+
|
|
19
|
+
- `<om-map center="[lng, lat]" zoom="11" pitch="55" bearing="20" basemap="maplibre">` — the root. `basemap` accepts `maplibre` (default style, no token), a style URL, or `none` (standalone canvas). `pitch`/`bearing` tilt the initial camera (use for 3D content). `validate` attribute enables live validation + on-page error panel.
|
|
20
|
+
- `<om-layer id="..." type="ScatterplotLayer" data="./points.json">` — any deck.gl layer class by `type` (all 33 bundled), plus `PopupLayer` (WebGL badges/labels at scale: `layout="badge|pin-label|card"`, `min-zoom`/`max-zoom`). Data: `data` URL (JSON, GeoJSON, CSV/TSV `.csv` — parsed to typed columns — Shapefile `.shp` (+`.dbf` attributes) and KML `.kml` as GeoJSON features, or Arrow IPC `.arrow`/`.feather` — large point datasets stay columnar, GeoArrow line/polygon geometry becomes GeoJSON features, zstd-compressed IPC is handled; other formats plug in via `OmMap.registerFormat({match, parse})`), inline `<script type="application/json">` (row arrays or column-oriented `{"columns": {"lon": [...], "lat": [...]}}`), or `wss://` streaming (`key="mmsi"` upserts entities in place, `flush="250ms"` coalesces bursts, `source="name"` selects a `OmMap.registerSource` decoder plugin), or a polled REST snapshot (`refresh="5s"` re-fetches and replaces — for live endpoints that return the full current state). Authenticated endpoints: call `OmMap.configureData({ headers: {...} })` in a script — never put tokens in attributes. `$field` accessors work identically on all of them — never write column-index code yourself. One columnar restriction: the `js` full-JS opt-in is not allowed on Arrow/columnar layers (validation will tell you; use `$field` accessors instead). For 3D models use `type="ScenegraphLayer"` with `scenegraph="./model.glb"` (required) and `get-orientation="[0, $heading, 90]"` — the roll of 90 stands Y-up glTF models upright; see docs/3d-assets.md.
|
|
21
|
+
- `<om-widget type="legend|layer-switcher|zoom-controls|scale-bar|attribution|filter|vega-lite" position="bottom-right">` — static UI panels. No `type` + HTML + `<script type="om/widget">` = custom widget with `ctx` (`ctx.layers`, `ctx.data(id)`, `ctx.dataInViewport(id)`, `ctx.stats(id, field)`, `ctx.viewport`, `ctx.selection`, `ctx.emit(action, payload)`), `this.watch = ['data:<layerId>', 'viewport', 'selection', 'layers']`, `this.$(sel)`, `vegaEmbed`/`d3` as globals.
|
|
22
|
+
- `<om-overlay id="..." anchor-from="selection">` — rich geo-anchored HTML (≤ ~20 per map). Anchors: `anchor="[lng, lat]"` (static), `anchor-from="selection"` (follows picks), or `anchor-layer="regions" anchor-feature-id="mission"` (anchored to a feature's own geometry — bbox center — no coordinates in markup; `{{field}}` interpolates that feature's attributes). `{{field}}` interpolates the picked feature HTML-escaped; `{{{field}}}` is raw (avoid). For labels on many features use `PopupLayer`, not overlays.
|
|
23
|
+
- `<om-behavior on="click|hover|drag|load|data-loaded" layer="..." action="...">` — declarative interaction. Built-in actions: `show-overlay`, `hide-overlay`, `show-tooltip`, `hide-tooltip`, `toggle-layer`, `filter-layer`, `highlight-feature`, `zoom-to-feature`. One payload contract everywhere: `{ layer, target, feature, featureId, coordinate }`.
|
|
24
|
+
- Animation: `transition="get-fill-color 800ms, get-radius 400ms"` on a layer GPU-animates prop changes (also smooths streaming updates via `get-position`). Camera: the `fly-to` action takes `center`/`zoom`/`pitch`/`bearing`/`duration` (e.g. `duration="2s"`) — use it in behaviors or `data-emit` buttons; `zoom-to-feature` also accepts `duration`.
|
|
25
|
+
- `<om-story id="tour" autoplay loop interrupt="pause|ignore">` — a storyboard of `<om-step>` children. Each step: `action="..."` + payload attributes (same kebab-case rule as behaviors) + `duration`/`delay`/`parallel` timing. Steps REFERENCE layers/overlays by id (`layer=`/`target=`) — a step must NEVER contain elements (validation error). Control: `<om-widget type="player" story="tour">`, the story-play/story-pause/story-seek actions, or `storyEl.play()/pause()/seek(ms)`. Seeking restores initial state then applies steps before T; use declarative payloads (e.g. `action="toggle-layer" visible="true"`, not bare toggles) so scrubbing is deterministic. Effect verbs as bare step attributes: `<om-step fade layer="regions" duration="1s">` (opacity reveal — start the layer at `opacity="0"`), `pulse` (attention flash), `trace` (progressive draw — whole-layer needs a TripsLayer; add `feature-id="..."` to make ONE polygon/line draw itself on inside any layer, or use it from a click behavior for click-to-trace), `populate` (rows drop in one by one — ordered by the authored filter-field, a payload `field`, or data order).
|
|
26
|
+
- Filtering: `filter-field="magnitude" filter-range="[4, 10]"` on a layer (GPU-side, live-updatable via the `filter-layer` action); pair with `<om-widget type="filter" layer="..." field="...">`.
|
|
27
|
+
|
|
28
|
+
## Decision rule for annotations
|
|
29
|
+
|
|
30
|
+
UI panel (legend, chart, stats) → `<om-widget>`. Rich HTML at one map location (click popup) → `<om-overlay>`. Labels/badges on many features → `<om-layer type="PopupLayer">`.
|
|
31
|
+
|
|
32
|
+
## Docs
|
|
33
|
+
|
|
34
|
+
- [README](README.md): thesis, authoring overview, build/run commands
|
|
35
|
+
- [Docs](docs/): consumer guides for testing, live data, stories, and 3D assets
|
|
36
|
+
- [Examples](examples/index.html): complete reviewed manifests covering widgets, overlays, basemaps, columnar data, drawing, 3D, stories, and live-data patterns
|
|
37
|
+
|
|
38
|
+
## Verification loop
|
|
39
|
+
|
|
40
|
+
1. Write the manifest (or edit the live DOM — changes reconcile automatically).
|
|
41
|
+
2. `OmMap.validate(html)` → `{ valid, errors: [{ severity, element, attribute, message, fix }] }`. Apply each `fix` verbatim; it is an instruction, not a diagnosis.
|
|
42
|
+
3. `OmMap.snapshotIR(html)` → resolved layer descriptors (JSON-safe; accessors appear as behavioural fingerprints) — diff against intent, assert in tests (works headless in jsdom/happy-dom, no WebGL needed).
|
|
43
|
+
4. For interaction tests: `mountForTest(html)` mounts the page headlessly (no WebGL) — `await h.pick({ layer, featureId })` then assert overlay/widget DOM via `el.shadowRoot`. Full guide: [docs/testing.md](docs/testing.md).
|