Repository navigation
Conversation
…ined file
Roadmap v3 PR 3: exportChart() turns a live <wick-chart> into ONE
self-contained .html — the library's own module sources inlined, the
chart's state and bars embedded — that opens offline in any browser and
paints the exact chart again. Only a zero-dependency, no-build library
can offer this; the constraint pays off.
How the file works: core + chart sources ride as base64 data-URL
modules; the chart module's "from './core.js'" line is rewritten onto
the core's data URL at export time, so one dynamic import() registers
the element with no network and no import map. The payload
({v, meta, state, bars}) sits in a JSON script block and is applied
via setState() then setData() (the pending-range mechanism restores the
exact view). '<' is escaped everywhere user or source text is embedded,
so neither a title nor a code comment can terminate a script block.
Surface: attachShare(chart) → exportChart()/downloadChart(); the
standalone builder + parseChartFile() are pure and exported for hosts
and tests. Module URLs are discovered via resource timing (any way the
page loaded them); bundled hosts pass urls or sources explicitly.
Ships as a plugin (3.0 KB gz, own 5 KB CI budget) — the main entry
keeps the headroom it has left. e2e proves the thesis end to end: the
exported file, opened from a blob URL with everything else blocked,
re-paints all 300 bars with the source chart's view.
…oadmap strikes The hub gains a live export playground (17 packages now), the demo toolbar gets an icon-only Share button in the view cluster, README documents the plugin, and the two Track-2 rows strike with the plugin-not-core decision recorded.
|
Superseded by #91 (merged) — closing with credit. This PR and #91 are parallel implementations of the same Track-2 rows (single-file export + open), built independently six days apart. #91 is now on main with green CI, so this branch conflicts in every shared file (README, ROADMAP, demo, docs, package.json, budget test) and would ship a second, competing exporter. What #91 kept from its own design: sources flattened into one module script (raw text — no base64's +33%), the inlining contract pinned against the real sources with What this PR had that was genuinely clever: resource-timing module discovery (finding The branch can be reopened if you'd rather salvage the data-URL embedding (e.g. for a CSP-agnostic variant) — the commits stay reachable. |
Roadmap v3 PR 3 (Track 2, the zero-dep flex): exportChart() turns a live chart into ONE self-contained .html — the library's own module sources inlined, state + bars embedded — that opens offline in any browser and paints the exact chart again. Only a zero-dependency, no-build library can offer this: there is nothing else to ship.
How the file works
from './core.js'line is rewritten onto the core's data URL at export time, so one dynamicimport()registers the element — no network, no import map.{v, meta, state, bars}) sits in a JSON script block, applied viasetState()thensetData()(the pending-range mechanism restores the exact view).<is escaped everywhere user or source text is embedded — neither a title nor a code comment can terminate a script block (unit-tested with injected</script><b>payloads).Surface
attachShare(chart)→exportChart()/downloadChart(); the standalone builder andparseChartFile()are pure and exported (hosts read a shared file back into{bars, state, meta}). Module URLs are discovered via resource timing (any way the page loaded them); bundled hosts pass URLs or sources explicitly.Ships as a plugin (3.0 KB gz, own 5 KB CI budget) — the main entry keeps the headroom it has left. The family is 17 packages.
Verification
npm test— 715/715 · e2e — 81 passed / 4 skipped.