driverkit 0.0.0-stage → 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/CONTROLS.md +578 -0
- package/README.md +104 -2
- package/dist/agent/backend.d.ts +69 -0
- package/dist/agent/backend.d.ts.map +1 -0
- package/dist/agent/backend.js +130 -0
- package/dist/agent/backend.js.map +1 -0
- package/dist/agent/control.d.ts +148 -0
- package/dist/agent/control.d.ts.map +1 -0
- package/dist/agent/control.js +342 -0
- package/dist/agent/control.js.map +1 -0
- package/dist/agent/index.d.ts +9 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +6 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/loop.d.ts +136 -0
- package/dist/agent/loop.d.ts.map +1 -0
- package/dist/agent/loop.js +824 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/render.d.ts +173 -0
- package/dist/agent/render.d.ts.map +1 -0
- package/dist/agent/render.js +425 -0
- package/dist/agent/render.js.map +1 -0
- package/dist/agent/tools.d.ts +138 -0
- package/dist/agent/tools.d.ts.map +1 -0
- package/dist/agent/tools.js +622 -0
- package/dist/agent/tools.js.map +1 -0
- package/dist/agent/types.d.ts +566 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +32 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/browser/budget.d.ts +92 -0
- package/dist/browser/budget.d.ts.map +1 -0
- package/dist/browser/budget.js +151 -0
- package/dist/browser/budget.js.map +1 -0
- package/dist/browser/connect.d.ts +368 -0
- package/dist/browser/connect.d.ts.map +1 -0
- package/dist/browser/connect.js +1038 -0
- package/dist/browser/connect.js.map +1 -0
- package/dist/browser/elsewhere.d.ts +89 -0
- package/dist/browser/elsewhere.d.ts.map +1 -0
- package/dist/browser/elsewhere.js +91 -0
- package/dist/browser/elsewhere.js.map +1 -0
- package/dist/browser/frames.d.ts +85 -0
- package/dist/browser/frames.d.ts.map +1 -0
- package/dist/browser/frames.js +11 -0
- package/dist/browser/frames.js.map +1 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +9 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/check/check.d.ts +171 -0
- package/dist/check/check.d.ts.map +1 -0
- package/dist/check/check.js +666 -0
- package/dist/check/check.js.map +1 -0
- package/dist/check/index.d.ts +3 -0
- package/dist/check/index.d.ts.map +1 -0
- package/dist/check/index.js +2 -0
- package/dist/check/index.js.map +1 -0
- package/dist/check/types.d.ts +149 -0
- package/dist/check/types.d.ts.map +1 -0
- package/dist/check/types.js +29 -0
- package/dist/check/types.js.map +1 -0
- package/dist/controls/controls.d.ts +198 -0
- package/dist/controls/controls.d.ts.map +1 -0
- package/dist/controls/controls.js +742 -0
- package/dist/controls/controls.js.map +1 -0
- package/dist/controls/dom.d.ts +108 -0
- package/dist/controls/dom.d.ts.map +1 -0
- package/dist/controls/dom.js +56 -0
- package/dist/controls/dom.js.map +1 -0
- package/dist/controls/index.d.ts +26 -0
- package/dist/controls/index.d.ts.map +1 -0
- package/dist/controls/index.js +23 -0
- package/dist/controls/index.js.map +1 -0
- package/dist/controls/rows.d.ts +66 -0
- package/dist/controls/rows.d.ts.map +1 -0
- package/dist/controls/rows.js +127 -0
- package/dist/controls/rows.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +15 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/registry.d.ts +192 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +2799 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/types.d.ts +2468 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +19 -0
- package/dist/core/types.js.map +1 -0
- package/dist/otel/index.d.ts +122 -0
- package/dist/otel/index.d.ts.map +1 -0
- package/dist/otel/index.js +157 -0
- package/dist/otel/index.js.map +1 -0
- package/dist/react/index.d.ts +191 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +547 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/runtime.d.ts +95 -0
- package/dist/react/runtime.d.ts.map +1 -0
- package/dist/react/runtime.js +54 -0
- package/dist/react/runtime.js.map +1 -0
- package/dist/react/store.d.ts +333 -0
- package/dist/react/store.d.ts.map +1 -0
- package/dist/react/store.js +695 -0
- package/dist/react/store.js.map +1 -0
- package/dist/relay/auth.d.ts +244 -0
- package/dist/relay/auth.d.ts.map +1 -0
- package/dist/relay/auth.js +391 -0
- package/dist/relay/auth.js.map +1 -0
- package/dist/relay/frames.d.ts +141 -0
- package/dist/relay/frames.d.ts.map +1 -0
- package/dist/relay/frames.js +20 -0
- package/dist/relay/frames.js.map +1 -0
- package/dist/relay/index.d.ts +8 -0
- package/dist/relay/index.d.ts.map +1 -0
- package/dist/relay/index.js +4 -0
- package/dist/relay/index.js.map +1 -0
- package/dist/relay/relay.d.ts +277 -0
- package/dist/relay/relay.d.ts.map +1 -0
- package/dist/relay/relay.js +1026 -0
- package/dist/relay/relay.js.map +1 -0
- package/dist/relay/serve.d.ts +33 -0
- package/dist/relay/serve.d.ts.map +1 -0
- package/dist/relay/serve.js +86 -0
- package/dist/relay/serve.js.map +1 -0
- package/dist/widget/chat.d.ts +290 -0
- package/dist/widget/chat.d.ts.map +1 -0
- package/dist/widget/chat.js +486 -0
- package/dist/widget/chat.js.map +1 -0
- package/dist/widget/css.d.ts +49 -0
- package/dist/widget/css.d.ts.map +1 -0
- package/dist/widget/css.js +532 -0
- package/dist/widget/css.js.map +1 -0
- package/dist/widget/dom.d.ts +143 -0
- package/dist/widget/dom.d.ts.map +1 -0
- package/dist/widget/dom.js +27 -0
- package/dist/widget/dom.js.map +1 -0
- package/dist/widget/highlight.d.ts +64 -0
- package/dist/widget/highlight.d.ts.map +1 -0
- package/dist/widget/highlight.js +136 -0
- package/dist/widget/highlight.js.map +1 -0
- package/dist/widget/index.d.ts +9 -0
- package/dist/widget/index.d.ts.map +1 -0
- package/dist/widget/index.js +20 -0
- package/dist/widget/index.js.map +1 -0
- package/dist/widget/position.d.ts +166 -0
- package/dist/widget/position.d.ts.map +1 -0
- package/dist/widget/position.js +497 -0
- package/dist/widget/position.js.map +1 -0
- package/dist/widget/settings.d.ts +116 -0
- package/dist/widget/settings.d.ts.map +1 -0
- package/dist/widget/settings.js +117 -0
- package/dist/widget/settings.js.map +1 -0
- package/dist/widget/widget.d.ts +442 -0
- package/dist/widget/widget.d.ts.map +1 -0
- package/dist/widget/widget.js +2005 -0
- package/dist/widget/widget.js.map +1 -0
- package/package.json +153 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.js","sourceRoot":"","sources":["../../src/widget/css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgclB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmCvB,CAAC","sourcesContent":["/**\n * The panel's stylesheet, as one string in one `<style>` inside the shadow\n * root.\n *\n * Shadow DOM is doing two jobs here and both are about trust. The host app's\n * CSS cannot reach in, so a global `* { box-sizing: border-box }` or an\n * aggressive `button { ... }` in someone's design system cannot deform the\n * panel; and these rules cannot leak out, so dropping the widget into an app\n * cannot move that app's own layout by a pixel. A library that silently\n * restyles the page it was added to does not get a second chance.\n *\n * Everything is a custom property on `:host` so the host app can retheme the\n * panel from outside — custom properties are the one thing that does cross the\n * shadow boundary, which makes them the right and only hook.\n *\n * Position is custom properties for exactly the same reason, and the panel's\n * placement is therefore something a host app can set from its own stylesheet\n * without touching JavaScript. See the comment on `--dk-x` for why the unit is\n * a fraction of the free space rather than pixels.\n *\n * `prefers-color-scheme` rather than a `theme` option: the panel sits in\n * someone else's app, and the person reading it has already told their system\n * which they want. `prefers-reduced-motion` because the panel appears over\n * what someone was looking at, and an animation they asked not to see is worse\n * than no animation.\n */\nexport const CSS = `\n:host {\n --dk-bg: #ffffff;\n --dk-fg: #15171a;\n --dk-dim: #6b7280;\n --dk-line: #e4e6eb;\n --dk-accent: #1f6feb;\n --dk-you: #f2f4f7;\n --dk-commit: #b42318;\n --dk-refused: #9a3412;\n --dk-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);\n --dk-radius: 10px;\n --dk-font: 14px/1.45 system-ui, -apple-system, \"Segoe UI\", sans-serif;\n --dk-mono: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;\n\n /* The collapsed launcher's box, and it is fixed on purpose.\n\n Content-sized, it was a different size in every app -- \"Ask Northwind CRM\"\n is twice the button \"Ask Mail\" is -- and it changed shape as the label or\n the state changed, which looks like a bug even when it is not. It also\n moved itself: the remembered position is a fraction of the FREE space and\n the free space is the viewport less the element's own measured width, so a\n launcher that grew by thirty pixels slid by thirty pixels times x. A\n constant box makes the placement arithmetic stable as well as the look.\n\n Two properties rather than one, so a host that wants a bigger target can\n say so, and the radius is derived from the height so it is always a true\n pill and never a rounded rectangle at one size and a circle at another. */\n --dk-launcher-w: 96px;\n --dk-launcher-h: 40px;\n\n /* Position. Two numbers in [0, 1]: 0 is flush with the near edge, 1 with\n the far one, 0.5 centred. The far-edge case is what the translate is for\n -- the element is pushed to the far inset and then pulled back by its own\n full width, so the arithmetic below works out to\n \\`left: gap + x * (viewport - 2*gap - width)\\`, which is on screen for every\n x in [0, 1] and every viewport at least as wide as the panel. That is why\n the unit is a fraction and not a pixel: a remembered fraction cannot\n describe an off-screen panel, and a remembered pixel offset can -- and an\n off-screen panel has no header to grab and no way back.\n\n It also means a host app can place the panel from its own stylesheet, the\n same way it can retheme it, with no JavaScript: these are ordinary custom\n properties on the host element and the outer tree outranks :host. The\n widget writes them inline only once somebody has actually moved it. */\n --dk-gap: 16px;\n --dk-x: 1;\n --dk-y: 1;\n\n all: initial;\n position: fixed;\n left: calc(var(--dk-gap) + var(--dk-x) * (100vw - var(--dk-gap) * 2));\n top: calc(var(--dk-gap) + var(--dk-y) * (100vh - var(--dk-gap) * 2));\n translate: calc(var(--dk-x) * -100%) calc(var(--dk-y) * -100%);\n z-index: 2147483000;\n font: var(--dk-font);\n color: var(--dk-fg);\n}\n\n/* Only ever on for a move the person did not make with a pointer -- a snap, a\n keypress. A transition during a drag means the panel trails the finger. */\n:host(.dk-snap) {\n transition: left 160ms ease-out, top 160ms ease-out, translate 160ms ease-out;\n}\n/* Belt as well as braces: the widget also checks this with matchMedia before\n it ever adds the class, so that a host which overrides the stylesheet still\n does not animate at somebody who asked for no animation. */\n@media (prefers-reduced-motion: reduce) {\n :host(.dk-snap) { transition: none; }\n}\n\n@media (prefers-color-scheme: dark) {\n :host {\n --dk-bg: #16181c;\n --dk-fg: #e8eaed;\n --dk-dim: #9aa0a6;\n --dk-line: #2a2d33;\n --dk-accent: #5b9dff;\n --dk-you: #22252b;\n --dk-commit: #ff8b80;\n --dk-refused: #f0a868;\n --dk-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);\n }\n}\n\nbutton { font: inherit; color: inherit; cursor: pointer; }\n:focus-visible { outline: 2px solid var(--dk-accent); outline-offset: 2px; }\n\n/* ONE RULE, AND NOTHING ELSE IN THIS STYLESHEET MAY RESIZE IT. The busy and\n open states say what they are with colour and with what they show inside\n this box; none of them touches its width, height, padding or font, because a\n control that changes shape as the state changes reads as a glitch and,\n worse, walks across the screen as it does it. If a new state needs to be\n visible out here, it gets an indicator INSIDE the pill. */\n.dk-launcher {\n /* So a host app's \\`* { box-sizing: content-box }\\` cannot turn the fixed\n width into width-plus-padding. The shadow boundary already stops their\n rules reaching in; this stops the inherited-by-default ones. */\n box-sizing: border-box;\n /* The containing block for the \"a conversation is waiting\" dot, which is\n positioned INSIDE this box. A badge hanging off the corner would be an\n element of a different size, and this element's size is the one thing\n nothing here is allowed to change. */\n position: relative;\n width: var(--dk-launcher-w);\n height: var(--dk-launcher-h);\n /* Half the height, so it is a pill at any size the host picks. */\n border-radius: calc(var(--dk-launcher-h) / 2);\n padding: 0 14px;\n background: var(--dk-bg);\n border: 1px solid var(--dk-line);\n box-shadow: var(--dk-shadow);\n /* Centre the label in a box it cannot change, and clip it if the host\n overrode the label with something long. Ellipsised rather than wrapped:\n two lines would need a taller box, which is the thing being prevented. */\n display: inline-flex;\n align-items: center;\n justify-content: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n flex: none;\n /* Draggable too: a collapsed widget sits on top of the app just as much as\n an open one, it is simply smaller. */\n touch-action: none;\n}\n.dk-open .dk-launcher { display: none; }\n\n/* \"There is a conversation behind this.\" Its own class, so no rule here\n mentions \\`.dk-launcher\\` and the one rule that sizes the pill stays the one\n rule that sizes the pill. Inside the pill, clear of the 14px label padding\n at the right end, and 8px across -- big enough to notice in the corner of an\n eye and small enough not to read as a second control. */\n.dk-dot {\n display: none;\n position: absolute;\n right: 7px;\n top: 50%;\n width: 8px;\n height: 8px;\n margin-top: -4px;\n border-radius: 50%;\n background: var(--dk-accent);\n}\n.dk-dot-on { display: block; }\n/* And it breathes while a run is in flight, because \"the agent is still\n working\" is the state somebody who minimised mid-run most needs to see.\n Opt-in to motion rather than opt-out: a person who asked for no animation\n gets a steady dot, which still says everything except the urgency. */\n@media (prefers-reduced-motion: no-preference) {\n .dk-busy .dk-dot { animation: dk-pulse 1.6s ease-in-out infinite; }\n}\n@keyframes dk-pulse { 50% { opacity: 0.3; } }\n\n.dk-panel {\n display: none;\n flex-direction: column;\n width: min(380px, calc(100vw - 32px));\n height: min(520px, calc(100vh - 32px));\n background: var(--dk-bg);\n border: 1px solid var(--dk-line);\n border-radius: var(--dk-radius);\n box-shadow: var(--dk-shadow);\n overflow: hidden;\n}\n.dk-open .dk-panel { display: flex; animation: dk-in 140ms ease-out; }\n\n@keyframes dk-in { from { opacity: 0; transform: translateY(6px); } }\n@media (prefers-reduced-motion: reduce) {\n .dk-open .dk-panel { animation: none; }\n}\n\n/* The header, which is chrome and nothing else: no \\`cursor: grab\\`, no\n \\`touch-action\\`, no drag. The grip beside the title is the handle, and a\n strip that is not a handle cannot start a drag under a press that was aimed\n at the gear and missed. \\`user-select: none\\` stays, so a double-click on the\n chrome does not leave the title highlighted. */\n.dk-head {\n display: flex;\n align-items: center;\n gap: 4px;\n padding: 10px 8px 10px 8px;\n border-bottom: 1px solid var(--dk-line);\n user-select: none;\n -webkit-user-select: none;\n}\n.dk-title { flex: 1; font-weight: 600; }\n:host(.dk-dragging) .dk-move { cursor: grabbing; }\n.dk-min, .dk-move, .dk-gear { background: none; border: 0; padding: 4px 8px; border-radius: 6px; color: var(--dk-dim); }\n.dk-min:hover, .dk-move:hover, .dk-gear:hover { background: var(--dk-you); }\n/* The grip, and the only drag surface on the panel. \\`touch-action: none\\` is\n what makes a finger drag the panel instead of scrolling the page behind it,\n and it is scoped to the handle so the transcript still scrolls by touch.\n First in the strip and therefore at the far end from the gear and the\n minimise button, which is half of why a mis-aimed press no longer drags. */\n.dk-move { cursor: grab; touch-action: none; font-size: 13px; line-height: 1; letter-spacing: 1px; }\n/* A minus, not a cross: this puts the panel away and keeps the conversation,\n and a cross is the glyph for throwing something away. The sizing matches the\n gear so the two read as one pair of controls. */\n.dk-min { font-size: 15px; line-height: 1; }\n/* A glyph and not the word \"Settings\", because the header is also the drag\n handle and three words plus a title is a strip nobody can grab. The button\n is a real button with a real label for anybody not reading the glyph. */\n.dk-gear { font-size: 15px; line-height: 1; }\n.dk-gear[aria-expanded=\"true\"] { background: var(--dk-you); color: var(--dk-fg); }\n\n/* Announcements only. Visually hidden rather than display:none, because a\n display:none live region is not announced at all -- and it lives outside the\n panel so that moving the COLLAPSED widget is announced too. */\n.dk-status {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}\n\n.dk-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }\n\n.dk-you, .dk-me { padding: 7px 10px; border-radius: 9px; max-width: 86%; white-space: pre-wrap; }\n.dk-you { background: var(--dk-you); align-self: flex-end; }\n.dk-me { align-self: flex-start; padding-left: 0; }\n.dk-note { color: var(--dk-dim); font-size: 12px; }\n\n/* The step list. A person watching an agent move their own screen needs to\n see what it did -- silent mutation is alarming even when it is correct --\n and, since the loop announces a call before it runs, what it is ABOUT to do.\n Each row is one call and moves pending -> running -> done, refused or\n skipped.\n\n The state is a class and a \\`::before\\` marker rather than text, which is\n deliberate: the row's text is the record of the call, it is what a person\n copies out of the panel, and it should read the same whether they looked at\n it while it was pending or a minute later. */\n.dk-step {\n font: var(--dk-mono);\n color: var(--dk-dim);\n border-left: 2px solid var(--dk-line);\n padding: 2px 0 2px 8px;\n /* One line each, always. Twenty steps that each wrap to three lines is not a\n list anybody can skim, and skimming is the only thing it is for. */\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n/* Consecutive steps close up into one block, so the transcript's 8px gap\n separates the CONVERSATION and not every line of a twenty-step run. */\n.dk-step + .dk-step { margin-top: -6px; }\n.dk-step::before {\n /* A fixed-width marker column, so the verb names line up down the list and\n a change of state does not shift the text sideways. */\n display: inline-block;\n width: 1.1em;\n content: \"\\\\00b7\";\n}\n.dk-step-pending { opacity: 0.75; }\n.dk-step-pending::before { content: \"\\\\25cb\"; }\n.dk-step-running { color: var(--dk-fg); border-left-color: var(--dk-accent); }\n.dk-step-running::before { content: \"\\\\25b8\"; color: var(--dk-accent); }\n.dk-step-done::before { content: \"\\\\2713\"; }\n/* Commit steps are marked three ways at once -- the word in the text, the\n colour, and a tinted band -- because this is the row somebody scrolls back\n to when they want to know what changed their data, and because the whole\n confirmation design rests on a person being able to tell a commit from a\n selection at a glance. */\n.dk-step-commit {\n color: var(--dk-commit);\n border-left: 3px solid var(--dk-commit);\n padding-left: 7px;\n font-weight: 600;\n background: color-mix(in srgb, var(--dk-commit) 8%, transparent);\n}\n.dk-step-refused { color: var(--dk-refused); border-left-color: var(--dk-refused); }\n.dk-step-refused::before { content: \"\\\\2715\"; }\n/* A call that was announced and then never ran, because the run was stopped\n during its pace wait or while it was held. Dimmed rather than coloured: it\n is not an outcome, it is the absence of one. */\n.dk-step-skipped { opacity: 0.6; text-decoration: line-through; }\n.dk-step-skipped::before { content: \"\\\\2013\"; text-decoration: none; }\n\n/* The run controls, beside the trace they control. Only while a run is in\n flight: four dead buttons in the corner of somebody's app the rest of the\n time is four buttons they learn to ignore. */\n.dk-run {\n display: none;\n align-items: center;\n gap: 6px;\n padding: 7px 10px;\n border-bottom: 1px solid var(--dk-line);\n}\n.dk-busy .dk-run { display: flex; }\n.dk-set-open .dk-run { display: none; }\n.dk-run button {\n border: 1px solid var(--dk-line);\n background: var(--dk-you);\n border-radius: 8px;\n padding: 4px 10px;\n font: var(--dk-mono);\n}\n/* Disabled rather than hidden when no controller supplied one, because the\n person should be able to see that pausing is a thing this panel does and\n that this build cannot do it -- a Pause button that silently does nothing\n while the agent keeps changing the screen is how somebody ends up closing\n the tab. */\n.dk-run button[disabled] { opacity: 0.45; cursor: default; }\n.dk-run-note { margin-left: auto; font-size: 12px; color: var(--dk-dim); }\n\n/* Settings. In the panel rather than a window of its own: it is four\n preferences, and the person is already looking here. */\n.dk-settings {\n display: none;\n flex: 1;\n flex-direction: column;\n gap: 16px;\n overflow-y: auto;\n padding: 14px 12px;\n}\n.dk-set-open .dk-settings { display: flex; }\n.dk-set-open .dk-log, .dk-set-open .dk-form { display: none; }\n.dk-set-row { display: flex; flex-direction: column; gap: 5px; }\n.dk-set-label { font-weight: 600; }\n.dk-set-why { font-size: 12px; color: var(--dk-dim); }\n/* The spend row's numbers. Full-strength text under a dimmed reason, which is\n the opposite weighting of every other row in this view -- on those the\n control is the thing and the words explain it, and on this one there is no\n control and the number IS the thing. */\n.dk-set-budget { font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 4px; }\n.dk-speeds { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }\n.dk-speed {\n border: 1px solid var(--dk-line);\n background: none;\n border-radius: 999px;\n padding: 5px 12px;\n}\n.dk-speed[aria-checked=\"true\"] {\n border-color: var(--dk-accent);\n color: var(--dk-accent);\n background: var(--dk-you);\n font-weight: 600;\n}\n.dk-toggle {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n text-align: left;\n border: 1px solid var(--dk-line);\n background: none;\n border-radius: 8px;\n padding: 8px 10px;\n}\n/* The state in the button, as well as in \\`aria-checked\\` for anybody who is\n being read it. A switch whose only difference between on and off is a shade\n of grey is a switch nobody is sure about. */\n.dk-toggle::after {\n margin-left: auto;\n content: \"Off\";\n font: var(--dk-mono);\n color: var(--dk-dim);\n}\n.dk-toggle[aria-checked=\"true\"] { border-color: var(--dk-accent); }\n.dk-toggle[aria-checked=\"true\"]::after { content: \"On\"; color: var(--dk-accent); }\n/* The destructive item, and the only red thing in the settings view. It is\n given the commit colour on purpose: that colour already means \"this changes\n something you cannot take back\" everywhere else in this panel, and a second\n vocabulary for danger would weaken the first. Not a filled button -- it is a\n thing to find when you want it, not a thing to notice while changing the\n speed. */\n.dk-clear {\n align-self: flex-start;\n border: 1px solid var(--dk-commit);\n background: none;\n color: var(--dk-commit);\n border-radius: 8px;\n padding: 7px 14px;\n font-weight: 600;\n margin-top: 2px;\n}\n.dk-clear:hover { background: color-mix(in srgb, var(--dk-commit) 10%, transparent); }\n.dk-done {\n align-self: flex-start;\n border: 1px solid var(--dk-line);\n background: var(--dk-you);\n border-radius: 8px;\n padding: 7px 14px;\n}\n\n/* The confirmation. The one place in this panel where a person is asked to\n decide something, so it is the one place that is allowed to be loud. */\n.dk-ask {\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n align-items: center;\n border: 1px solid var(--dk-commit);\n border-radius: 9px;\n padding: 9px 10px;\n}\n.dk-ask-q { flex: 1 0 100%; font-weight: 600; color: var(--dk-commit); }\n.dk-ask-why { flex: 1 0 100%; font-size: 12px; color: var(--dk-dim); }\n.dk-ask-said { flex: 1 0 100%; font-size: 12px; color: var(--dk-dim); }\n\n/* A QUESTION, which is not a confirmation and must not look like one.\n .dk-ask is bordered and coloured in the commit colour because it is the one\n place somebody is asked to allow something irreversible. A question changes\n nothing, so it borrows the layout and gives back the alarm: the border and\n the heading go to the ordinary line colour. Two dialogs that look alike are\n one dialog as far as a person's attention is concerned, which is the argument\n the reversible-commit wording is already built on. */\n.dk-q { border-color: var(--dk-line); }\n.dk-q .dk-ask-q { color: inherit; }\n.dk-ask-box {\n flex: 1 1 100%;\n border: 1px solid var(--dk-line);\n border-radius: 8px;\n padding: 7px 9px;\n font: inherit;\n color: inherit;\n background: var(--dk-you);\n}\n.dk-yes, .dk-no { border-radius: 8px; padding: 6px 12px; border: 1px solid var(--dk-line); background: var(--dk-you); }\n.dk-yes { border-color: var(--dk-commit); color: var(--dk-commit); font-weight: 600; }\n\n.dk-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--dk-line); }\n.dk-input {\n flex: 1;\n min-width: 0;\n font: inherit;\n color: inherit;\n background: var(--dk-bg);\n border: 1px solid var(--dk-line);\n border-radius: 8px;\n padding: 8px 10px;\n}\n.dk-send, .dk-stop {\n border: 1px solid var(--dk-line);\n border-radius: 8px;\n background: var(--dk-you);\n padding: 8px 12px;\n}\n.dk-send[disabled] { opacity: 0.5; cursor: default; }\n.dk-stop { display: none; }\n.dk-busy .dk-stop { display: block; }\n.dk-busy .dk-send { display: none; }\n`;\n\n/**\n * The outline over the element a verb is about to touch, as its own tiny\n * stylesheet in its own shadow root.\n *\n * Separate from `CSS` because it has to be in a separate host element: the\n * panel's `:host` carries a `translate`, a transformed ancestor is the\n * containing block for `position: fixed` descendants, and an outline drawn\n * inside the panel would therefore be offset by wherever the panel sits. See\n * `highlight.ts`.\n *\n * The host is a zero-sized fixed point at the viewport's origin and the box\n * inside it is positioned absolutely, so the numbers written in are exactly\n * the ones `getBoundingClientRect` reported -- no coordinate conversion, which\n * is the only kind of arithmetic that can be wrong here.\n *\n * `pointer-events: none` throughout, and nothing is ever written to the host\n * app's own element: a border on somebody's button reflows their layout, and a\n * panel that nudges the page sideways every time it names an element is not\n * the passive observer it claims to be.\n */\nexport const SPOT_CSS = `\n:host {\n all: initial;\n position: fixed;\n left: 0;\n top: 0;\n width: 0;\n height: 0;\n pointer-events: none;\n /* One below the panel. If the outline and the panel overlap, the panel is\n the thing that has words in it. */\n z-index: 2147482999;\n --dk-spot-color: #1f6feb;\n}\n@media (prefers-color-scheme: dark) {\n :host { --dk-spot-color: #5b9dff; }\n}\n.dk-spot {\n display: none;\n position: absolute;\n box-sizing: border-box;\n pointer-events: none;\n left: var(--dk-spot-x, 0);\n top: var(--dk-spot-y, 0);\n width: var(--dk-spot-w, 0);\n height: var(--dk-spot-h, 0);\n border: 2px solid var(--dk-spot-color);\n border-radius: 6px;\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--dk-spot-color) 25%, transparent);\n}\n.dk-spot-on { display: block; }\n@media (prefers-reduced-motion: no-preference) {\n .dk-spot-on { animation: dk-spot-in 120ms ease-out; }\n}\n@keyframes dk-spot-in { from { opacity: 0; } }\n`;\n"]}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser, as structural types.
|
|
3
|
+
*
|
|
4
|
+
* Narrow on purpose: these describe only what `mountWidget` actually touches,
|
|
5
|
+
* so the real `document` satisfies them and so does a hundred-line fake. That
|
|
6
|
+
* is a design requirement and not a testing shim, for the same reason
|
|
7
|
+
* `driverkit/browser` injects `EventSource` — a module that can only run in a
|
|
8
|
+
* browser can only be verified in a browser, which in practice means verified
|
|
9
|
+
* by hand, which means the paths nobody clicks through are the untested ones.
|
|
10
|
+
* Here those paths are "Escape while the input has focus", "unmount while a
|
|
11
|
+
* run is in flight", "a commit appears in the trace", and now "the panel was
|
|
12
|
+
* dragged to the right edge of a wide window and the window then narrowed",
|
|
13
|
+
* none of which anybody re-checks by hand after a refactor.
|
|
14
|
+
*
|
|
15
|
+
* It also keeps this package honest about having no framework and no
|
|
16
|
+
* dependencies. Importing the DOM lib types would be free at runtime but it
|
|
17
|
+
* would also let a `querySelector` or a `CSSStyleDeclaration` creep in, and
|
|
18
|
+
* every one of those is a thing the fake would have to grow.
|
|
19
|
+
*
|
|
20
|
+
* Everything added for positioning is OPTIONAL on purpose. A host that hands
|
|
21
|
+
* in a minimal element — or a browser missing `setPointerCapture` — gets a
|
|
22
|
+
* panel that still mounts and still renders in its default corner; it just
|
|
23
|
+
* cannot be moved. Dragging is worth a lot and it is not worth failing an
|
|
24
|
+
* app's boot over.
|
|
25
|
+
*/
|
|
26
|
+
/** Only the fields the handlers here read. Pointer fields included, because
|
|
27
|
+
* drag is one code path for mouse, touch and pen — three code paths is three
|
|
28
|
+
* chances to get the clamping wrong in only one of them. */
|
|
29
|
+
export interface EventLike {
|
|
30
|
+
key?: string;
|
|
31
|
+
altKey?: boolean;
|
|
32
|
+
/** The deepest node the event started on. Used to tell "pointerdown on the
|
|
33
|
+
* header" from "pointerdown on the Close button inside the header", which
|
|
34
|
+
* is the difference between a drag and a click. */
|
|
35
|
+
target?: ElementLike;
|
|
36
|
+
/** Mouse buttons, so a right-click does not start a drag. Touch and pen
|
|
37
|
+
* report 0 like a left click. */
|
|
38
|
+
button?: number;
|
|
39
|
+
pointerId?: number;
|
|
40
|
+
clientX?: number;
|
|
41
|
+
clientY?: number;
|
|
42
|
+
preventDefault?: () => void;
|
|
43
|
+
stopPropagation?: () => void;
|
|
44
|
+
}
|
|
45
|
+
export type Listener = (event: EventLike) => void;
|
|
46
|
+
export interface NodeLike {
|
|
47
|
+
appendChild(child: ElementLike): unknown;
|
|
48
|
+
addEventListener(type: string, listener: Listener): void;
|
|
49
|
+
}
|
|
50
|
+
/** `DOMRect`, as the four numbers the clamping needs. */
|
|
51
|
+
export interface RectLike {
|
|
52
|
+
readonly left: number;
|
|
53
|
+
readonly top: number;
|
|
54
|
+
readonly width: number;
|
|
55
|
+
readonly height: number;
|
|
56
|
+
}
|
|
57
|
+
/** `element.style`, as the two calls positioning needs. Positioning is written
|
|
58
|
+
* as custom properties and nothing else, so the host app can set a position
|
|
59
|
+
* from its own CSS and so there is exactly one way the panel can be placed. */
|
|
60
|
+
export interface StyleLike {
|
|
61
|
+
setProperty(name: string, value: string): void;
|
|
62
|
+
}
|
|
63
|
+
export interface ElementLike extends NodeLike {
|
|
64
|
+
className: string;
|
|
65
|
+
textContent: string | null;
|
|
66
|
+
/** On an `<input>`. Optional because every other element lacks it. */
|
|
67
|
+
value?: string;
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
/** Uppercase, as the DOM spells it. Read only to recognise a control inside
|
|
70
|
+
* the drag handle. */
|
|
71
|
+
readonly tagName?: string;
|
|
72
|
+
/** Scrolling the transcript. Both optional and both used only if present:
|
|
73
|
+
* they are a courtesy to a person watching, not part of the contract. */
|
|
74
|
+
scrollTop?: number;
|
|
75
|
+
readonly scrollHeight?: number;
|
|
76
|
+
setAttribute(name: string, value: string): void;
|
|
77
|
+
removeAttribute(name: string): void;
|
|
78
|
+
focus?: () => void;
|
|
79
|
+
remove: () => void;
|
|
80
|
+
removeEventListener?: (type: string, listener: Listener) => void;
|
|
81
|
+
/** Where positioning is written. Absent means the panel cannot be moved. */
|
|
82
|
+
style?: StyleLike;
|
|
83
|
+
/** The panel's own box, which the clamp needs: "on screen" is a statement
|
|
84
|
+
* about the far edge, not about the anchor point. */
|
|
85
|
+
getBoundingClientRect?: () => RectLike;
|
|
86
|
+
/** Pointer capture, so a drag keeps receiving moves once the pointer has
|
|
87
|
+
* left the handle — which it does immediately, because the handle is what
|
|
88
|
+
* is being moved out from under it. */
|
|
89
|
+
setPointerCapture?: (pointerId: number) => void;
|
|
90
|
+
releasePointerCapture?: (pointerId: number) => void;
|
|
91
|
+
/** Absent on a fake that does not model shadow trees, and on a browser old
|
|
92
|
+
* enough not to have them. See the fallback in `widget.ts`. */
|
|
93
|
+
attachShadow?: (init: {
|
|
94
|
+
mode: "open" | "closed";
|
|
95
|
+
}) => NodeLike;
|
|
96
|
+
}
|
|
97
|
+
export interface DocumentLike {
|
|
98
|
+
createElement(tag: string): ElementLike;
|
|
99
|
+
body: ElementLike;
|
|
100
|
+
/**
|
|
101
|
+
* Optional, and used for ONE thing: resolving a verb's presentational `at`
|
|
102
|
+
* selector so the widget can draw an outline over the element a verb is
|
|
103
|
+
* about to touch.
|
|
104
|
+
*
|
|
105
|
+
* Optional because it must degrade silently. A host that hands in a minimal
|
|
106
|
+
* document, or a fake, simply gets no outlines — which is also what every
|
|
107
|
+
* verb without an `at` gets, so the no-op path is the common one rather than
|
|
108
|
+
* an edge case.
|
|
109
|
+
*
|
|
110
|
+
* **It is never used to find anything to act on.** `at` is presentational;
|
|
111
|
+
* the widget draws on top of what it names and nothing else. Verbs are
|
|
112
|
+
* called by name, and that is the whole reason this library exists.
|
|
113
|
+
*/
|
|
114
|
+
querySelector?: (selectors: string) => ElementLike | null;
|
|
115
|
+
}
|
|
116
|
+
/** The viewport, as the four things a clamp needs: how big it is, when it
|
|
117
|
+
* changed, and whether the person asked for less animation. */
|
|
118
|
+
export interface WindowLike {
|
|
119
|
+
innerWidth?: number;
|
|
120
|
+
innerHeight?: number;
|
|
121
|
+
addEventListener?: (type: string, listener: Listener) => void;
|
|
122
|
+
removeEventListener?: (type: string, listener: Listener) => void;
|
|
123
|
+
matchMedia?: (query: string) => {
|
|
124
|
+
matches: boolean;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** `localStorage`, as the two calls a remembered position needs. Both can
|
|
128
|
+
* throw — a private window, blocked site data — so every call site here is
|
|
129
|
+
* wrapped, including the one that merely reaches for the global. */
|
|
130
|
+
export interface StorageLike {
|
|
131
|
+
getItem(key: string): string | null;
|
|
132
|
+
setItem(key: string, value: string): void;
|
|
133
|
+
}
|
|
134
|
+
/** `new AbortController()`, as a type, so a run can be cancelled without this
|
|
135
|
+
* package reaching for a global it cannot be handed in a test. */
|
|
136
|
+
export interface AbortControllerLike {
|
|
137
|
+
readonly signal: AbortSignal;
|
|
138
|
+
abort(): void;
|
|
139
|
+
}
|
|
140
|
+
export interface AbortControllerCtor {
|
|
141
|
+
new (): AbortControllerLike;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/widget/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;6DAE6D;AAC7D,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;wDAEoD;IACpD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;sCACkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,eAA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E,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED;mEACmE;AACnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,mBAAmB,CAAC;CAC7B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser, as structural types.
|
|
3
|
+
*
|
|
4
|
+
* Narrow on purpose: these describe only what `mountWidget` actually touches,
|
|
5
|
+
* so the real `document` satisfies them and so does a hundred-line fake. That
|
|
6
|
+
* is a design requirement and not a testing shim, for the same reason
|
|
7
|
+
* `driverkit/browser` injects `EventSource` — a module that can only run in a
|
|
8
|
+
* browser can only be verified in a browser, which in practice means verified
|
|
9
|
+
* by hand, which means the paths nobody clicks through are the untested ones.
|
|
10
|
+
* Here those paths are "Escape while the input has focus", "unmount while a
|
|
11
|
+
* run is in flight", "a commit appears in the trace", and now "the panel was
|
|
12
|
+
* dragged to the right edge of a wide window and the window then narrowed",
|
|
13
|
+
* none of which anybody re-checks by hand after a refactor.
|
|
14
|
+
*
|
|
15
|
+
* It also keeps this package honest about having no framework and no
|
|
16
|
+
* dependencies. Importing the DOM lib types would be free at runtime but it
|
|
17
|
+
* would also let a `querySelector` or a `CSSStyleDeclaration` creep in, and
|
|
18
|
+
* every one of those is a thing the fake would have to grow.
|
|
19
|
+
*
|
|
20
|
+
* Everything added for positioning is OPTIONAL on purpose. A host that hands
|
|
21
|
+
* in a minimal element — or a browser missing `setPointerCapture` — gets a
|
|
22
|
+
* panel that still mounts and still renders in its default corner; it just
|
|
23
|
+
* cannot be moved. Dragging is worth a lot and it is not worth failing an
|
|
24
|
+
* app's boot over.
|
|
25
|
+
*/
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=dom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../../src/widget/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG","sourcesContent":["/**\n * The browser, as structural types.\n *\n * Narrow on purpose: these describe only what `mountWidget` actually touches,\n * so the real `document` satisfies them and so does a hundred-line fake. That\n * is a design requirement and not a testing shim, for the same reason\n * `driverkit/browser` injects `EventSource` — a module that can only run in a\n * browser can only be verified in a browser, which in practice means verified\n * by hand, which means the paths nobody clicks through are the untested ones.\n * Here those paths are \"Escape while the input has focus\", \"unmount while a\n * run is in flight\", \"a commit appears in the trace\", and now \"the panel was\n * dragged to the right edge of a wide window and the window then narrowed\",\n * none of which anybody re-checks by hand after a refactor.\n *\n * It also keeps this package honest about having no framework and no\n * dependencies. Importing the DOM lib types would be free at runtime but it\n * would also let a `querySelector` or a `CSSStyleDeclaration` creep in, and\n * every one of those is a thing the fake would have to grow.\n *\n * Everything added for positioning is OPTIONAL on purpose. A host that hands\n * in a minimal element — or a browser missing `setPointerCapture` — gets a\n * panel that still mounts and still renders in its default corner; it just\n * cannot be moved. Dragging is worth a lot and it is not worth failing an\n * app's boot over.\n */\n\n/** Only the fields the handlers here read. Pointer fields included, because\n * drag is one code path for mouse, touch and pen — three code paths is three\n * chances to get the clamping wrong in only one of them. */\nexport interface EventLike {\n key?: string;\n altKey?: boolean;\n /** The deepest node the event started on. Used to tell \"pointerdown on the\n * header\" from \"pointerdown on the Close button inside the header\", which\n * is the difference between a drag and a click. */\n target?: ElementLike;\n /** Mouse buttons, so a right-click does not start a drag. Touch and pen\n * report 0 like a left click. */\n button?: number;\n pointerId?: number;\n clientX?: number;\n clientY?: number;\n preventDefault?: () => void;\n stopPropagation?: () => void;\n}\n\nexport type Listener = (event: EventLike) => void;\n\nexport interface NodeLike {\n appendChild(child: ElementLike): unknown;\n addEventListener(type: string, listener: Listener): void;\n}\n\n/** `DOMRect`, as the four numbers the clamping needs. */\nexport interface RectLike {\n readonly left: number;\n readonly top: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** `element.style`, as the two calls positioning needs. Positioning is written\n * as custom properties and nothing else, so the host app can set a position\n * from its own CSS and so there is exactly one way the panel can be placed. */\nexport interface StyleLike {\n setProperty(name: string, value: string): void;\n}\n\nexport interface ElementLike extends NodeLike {\n className: string;\n textContent: string | null;\n /** On an `<input>`. Optional because every other element lacks it. */\n value?: string;\n disabled?: boolean;\n /** Uppercase, as the DOM spells it. Read only to recognise a control inside\n * the drag handle. */\n readonly tagName?: string;\n /** Scrolling the transcript. Both optional and both used only if present:\n * they are a courtesy to a person watching, not part of the contract. */\n scrollTop?: number;\n readonly scrollHeight?: number;\n setAttribute(name: string, value: string): void;\n removeAttribute(name: string): void;\n focus?: () => void;\n remove: () => void;\n removeEventListener?: (type: string, listener: Listener) => void;\n /** Where positioning is written. Absent means the panel cannot be moved. */\n style?: StyleLike;\n /** The panel's own box, which the clamp needs: \"on screen\" is a statement\n * about the far edge, not about the anchor point. */\n getBoundingClientRect?: () => RectLike;\n /** Pointer capture, so a drag keeps receiving moves once the pointer has\n * left the handle — which it does immediately, because the handle is what\n * is being moved out from under it. */\n setPointerCapture?: (pointerId: number) => void;\n releasePointerCapture?: (pointerId: number) => void;\n /** Absent on a fake that does not model shadow trees, and on a browser old\n * enough not to have them. See the fallback in `widget.ts`. */\n attachShadow?: (init: { mode: \"open\" | \"closed\" }) => NodeLike;\n}\n\nexport interface DocumentLike {\n createElement(tag: string): ElementLike;\n body: ElementLike;\n /**\n * Optional, and used for ONE thing: resolving a verb's presentational `at`\n * selector so the widget can draw an outline over the element a verb is\n * about to touch.\n *\n * Optional because it must degrade silently. A host that hands in a minimal\n * document, or a fake, simply gets no outlines — which is also what every\n * verb without an `at` gets, so the no-op path is the common one rather than\n * an edge case.\n *\n * **It is never used to find anything to act on.** `at` is presentational;\n * the widget draws on top of what it names and nothing else. Verbs are\n * called by name, and that is the whole reason this library exists.\n */\n querySelector?: (selectors: string) => ElementLike | null;\n}\n\n/** The viewport, as the four things a clamp needs: how big it is, when it\n * changed, and whether the person asked for less animation. */\nexport interface WindowLike {\n innerWidth?: number;\n innerHeight?: number;\n addEventListener?: (type: string, listener: Listener) => void;\n removeEventListener?: (type: string, listener: Listener) => void;\n matchMedia?: (query: string) => { matches: boolean };\n}\n\n/** `localStorage`, as the two calls a remembered position needs. Both can\n * throw — a private window, blocked site data — so every call site here is\n * wrapped, including the one that merely reaches for the global. */\nexport interface StorageLike {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n}\n\n/** `new AbortController()`, as a type, so a run can be cancelled without this\n * package reaching for a global it cannot be handed in a test. */\nexport interface AbortControllerLike {\n readonly signal: AbortSignal;\n abort(): void;\n}\n\nexport interface AbortControllerCtor {\n new (): AbortControllerLike;\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The outline over the element a verb is about to touch.
|
|
3
|
+
*
|
|
4
|
+
* ## `at` is presentational, and that is the whole rule
|
|
5
|
+
*
|
|
6
|
+
* A verb may name a CSS selector, `Verb.at`, for the thing on screen it is
|
|
7
|
+
* about. The widget is allowed to draw on top of what that names and is
|
|
8
|
+
* allowed to do nothing else with it. It never queries it to decide what to
|
|
9
|
+
* call, never clicks it, never reads a value out of it, and never lets its
|
|
10
|
+
* absence change what runs. If `at` could steer a call then driverkit would
|
|
11
|
+
* have a selector in its execution path, and a library whose entire argument
|
|
12
|
+
* is "no pixels, no selectors" would have quietly grown the failure mode it
|
|
13
|
+
* exists to avoid — a rename in somebody's CSS breaking an agent.
|
|
14
|
+
*
|
|
15
|
+
* So every failure here is silent and every failure means the same thing: no
|
|
16
|
+
* outline, run unchanged. No `at` (which is most verbs), no `querySelector` on
|
|
17
|
+
* the injected document, a selector that matches nothing, a selector that is
|
|
18
|
+
* not valid CSS, an element with no measurable box, an element measuring zero
|
|
19
|
+
* — all of them return false and draw nothing.
|
|
20
|
+
*
|
|
21
|
+
* ## It is an overlay, not a border
|
|
22
|
+
*
|
|
23
|
+
* Nothing is written to the host app's element. Not a class, not a style, not
|
|
24
|
+
* an attribute. A 2px border added to somebody's button reflows their layout,
|
|
25
|
+
* and an agent that nudges the page sideways every time it names an element is
|
|
26
|
+
* not a passive observer of that page. Instead this draws a separate fixed,
|
|
27
|
+
* `pointer-events: none` box at the element's measured rectangle.
|
|
28
|
+
*
|
|
29
|
+
* Nothing is added to the host app's document until there is something to
|
|
30
|
+
* outline, either. Most verbs declare no `at`, so for most apps this file
|
|
31
|
+
* creates no element and attaches no listener at all; the overlay host appears
|
|
32
|
+
* the first time an outline is actually drawn and is removed on unmount.
|
|
33
|
+
*
|
|
34
|
+
* That box lives in its OWN host element with its own shadow root, rather than
|
|
35
|
+
* inside the panel's. The panel's `:host` carries a `translate` — see the
|
|
36
|
+
* positioning arithmetic in `css.ts` — and a transformed ancestor becomes the
|
|
37
|
+
* containing block for `position: fixed` descendants, so an outline drawn
|
|
38
|
+
* inside the panel would be offset by wherever the panel happens to sit. Two
|
|
39
|
+
* hosts is the cost of the positioning design, and it is cheap: both are
|
|
40
|
+
* removed on unmount.
|
|
41
|
+
*/
|
|
42
|
+
import type { DocumentLike, ElementLike, WindowLike } from "./dom.ts";
|
|
43
|
+
export interface SpotlightOptions {
|
|
44
|
+
document: DocumentLike;
|
|
45
|
+
/** Where the overlay host goes. The panel's container, so a host app that
|
|
46
|
+
* keeps driverkit inside one subtree keeps all of it there. */
|
|
47
|
+
container: ElementLike;
|
|
48
|
+
/** Watched for scroll and resize, so an outline follows an element that
|
|
49
|
+
* moved under it — which it will, because the verb being announced is quite
|
|
50
|
+
* often the one that scrolls the row into view. */
|
|
51
|
+
window?: WindowLike;
|
|
52
|
+
}
|
|
53
|
+
export interface Spotlight {
|
|
54
|
+
/** Draw over what `selector` names. True if an outline is now showing.
|
|
55
|
+
* Anything that did not work returns false and leaves nothing drawn. */
|
|
56
|
+
show: (selector: string | undefined) => boolean;
|
|
57
|
+
hide: () => void;
|
|
58
|
+
/** The selector currently outlined, or undefined. For tests, and for the
|
|
59
|
+
* panel's own "is anything showing" check. */
|
|
60
|
+
showing: () => string | undefined;
|
|
61
|
+
dispose: () => void;
|
|
62
|
+
}
|
|
63
|
+
export declare function spotlight(options: SpotlightOptions): Spotlight;
|
|
64
|
+
//# sourceMappingURL=highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/widget/highlight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAsB,UAAU,EAAE,MAAM,UAAU,CAAC;AAE1F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,YAAY,CAAC;IACvB;oEACgE;IAChE,SAAS,EAAE,WAAW,CAAC;IACvB;;wDAEoD;IACpD,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB;6EACyE;IACzE,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC;IAChD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;mDAC+C;IAC/C,OAAO,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAClC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CA6F9D"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The outline over the element a verb is about to touch.
|
|
3
|
+
*
|
|
4
|
+
* ## `at` is presentational, and that is the whole rule
|
|
5
|
+
*
|
|
6
|
+
* A verb may name a CSS selector, `Verb.at`, for the thing on screen it is
|
|
7
|
+
* about. The widget is allowed to draw on top of what that names and is
|
|
8
|
+
* allowed to do nothing else with it. It never queries it to decide what to
|
|
9
|
+
* call, never clicks it, never reads a value out of it, and never lets its
|
|
10
|
+
* absence change what runs. If `at` could steer a call then driverkit would
|
|
11
|
+
* have a selector in its execution path, and a library whose entire argument
|
|
12
|
+
* is "no pixels, no selectors" would have quietly grown the failure mode it
|
|
13
|
+
* exists to avoid — a rename in somebody's CSS breaking an agent.
|
|
14
|
+
*
|
|
15
|
+
* So every failure here is silent and every failure means the same thing: no
|
|
16
|
+
* outline, run unchanged. No `at` (which is most verbs), no `querySelector` on
|
|
17
|
+
* the injected document, a selector that matches nothing, a selector that is
|
|
18
|
+
* not valid CSS, an element with no measurable box, an element measuring zero
|
|
19
|
+
* — all of them return false and draw nothing.
|
|
20
|
+
*
|
|
21
|
+
* ## It is an overlay, not a border
|
|
22
|
+
*
|
|
23
|
+
* Nothing is written to the host app's element. Not a class, not a style, not
|
|
24
|
+
* an attribute. A 2px border added to somebody's button reflows their layout,
|
|
25
|
+
* and an agent that nudges the page sideways every time it names an element is
|
|
26
|
+
* not a passive observer of that page. Instead this draws a separate fixed,
|
|
27
|
+
* `pointer-events: none` box at the element's measured rectangle.
|
|
28
|
+
*
|
|
29
|
+
* Nothing is added to the host app's document until there is something to
|
|
30
|
+
* outline, either. Most verbs declare no `at`, so for most apps this file
|
|
31
|
+
* creates no element and attaches no listener at all; the overlay host appears
|
|
32
|
+
* the first time an outline is actually drawn and is removed on unmount.
|
|
33
|
+
*
|
|
34
|
+
* That box lives in its OWN host element with its own shadow root, rather than
|
|
35
|
+
* inside the panel's. The panel's `:host` carries a `translate` — see the
|
|
36
|
+
* positioning arithmetic in `css.ts` — and a transformed ancestor becomes the
|
|
37
|
+
* containing block for `position: fixed` descendants, so an outline drawn
|
|
38
|
+
* inside the panel would be offset by wherever the panel happens to sit. Two
|
|
39
|
+
* hosts is the cost of the positioning design, and it is cheap: both are
|
|
40
|
+
* removed on unmount.
|
|
41
|
+
*/
|
|
42
|
+
import { SPOT_CSS } from "./css.js";
|
|
43
|
+
export function spotlight(options) {
|
|
44
|
+
const doc = options.document;
|
|
45
|
+
const win = options.window;
|
|
46
|
+
/** The overlay, built on first use. See the header: an app whose verbs name
|
|
47
|
+
* nothing should not pay an element and two listeners for a feature it
|
|
48
|
+
* never reaches. */
|
|
49
|
+
let overlay = null;
|
|
50
|
+
let at;
|
|
51
|
+
function ensure() {
|
|
52
|
+
if (overlay)
|
|
53
|
+
return overlay;
|
|
54
|
+
const host = doc.createElement("div");
|
|
55
|
+
host.className = "dk-spot-host";
|
|
56
|
+
// Decorative, and the panel already says in words what is about to
|
|
57
|
+
// happen. An outline announced to a screen reader would be the same
|
|
58
|
+
// sentence twice.
|
|
59
|
+
host.setAttribute("aria-hidden", "true");
|
|
60
|
+
const root = host.attachShadow
|
|
61
|
+
? host.attachShadow({ mode: "open" })
|
|
62
|
+
: host;
|
|
63
|
+
const style = doc.createElement("style");
|
|
64
|
+
style.textContent = SPOT_CSS;
|
|
65
|
+
root.appendChild(style);
|
|
66
|
+
const box = doc.createElement("div");
|
|
67
|
+
box.className = "dk-spot";
|
|
68
|
+
root.appendChild(box);
|
|
69
|
+
options.container.appendChild(host);
|
|
70
|
+
win?.addEventListener?.("scroll", reflow);
|
|
71
|
+
win?.addEventListener?.("resize", reflow);
|
|
72
|
+
overlay = { host, box };
|
|
73
|
+
return overlay;
|
|
74
|
+
}
|
|
75
|
+
const reflow = () => {
|
|
76
|
+
// Only while something is showing, and re-resolved from the selector
|
|
77
|
+
// rather than from a cached element: between a scroll and now the app may
|
|
78
|
+
// have re-rendered the row entirely, and an outline anchored to a detached
|
|
79
|
+
// node is an outline in the wrong place.
|
|
80
|
+
if (at !== undefined)
|
|
81
|
+
draw(at);
|
|
82
|
+
};
|
|
83
|
+
return { show, hide, showing: () => at, dispose };
|
|
84
|
+
function show(selector) {
|
|
85
|
+
if (selector === undefined || selector === "") {
|
|
86
|
+
hide();
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const drawn = draw(selector);
|
|
90
|
+
at = drawn ? selector : undefined;
|
|
91
|
+
return drawn;
|
|
92
|
+
}
|
|
93
|
+
function draw(selector) {
|
|
94
|
+
let target = null;
|
|
95
|
+
try {
|
|
96
|
+
// A selector from a manifest is an app author's string and may be
|
|
97
|
+
// anything at all, including syntactically invalid, which throws.
|
|
98
|
+
target = doc.querySelector?.(selector) ?? null;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
target = null;
|
|
102
|
+
}
|
|
103
|
+
const rect = target?.getBoundingClientRect?.();
|
|
104
|
+
// A zero-sized box is a hidden element, a `display: none` row, or a fake
|
|
105
|
+
// without layout. Outlining it would draw a dot in the top-left corner of
|
|
106
|
+
// the screen, which looks like a bug in the panel rather than like nothing.
|
|
107
|
+
if (!rect || rect.width <= 0 || rect.height <= 0) {
|
|
108
|
+
hide();
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const { box } = ensure();
|
|
112
|
+
if (!box.style)
|
|
113
|
+
return false;
|
|
114
|
+
box.style.setProperty("--dk-spot-x", `${Math.round(rect.left)}px`);
|
|
115
|
+
box.style.setProperty("--dk-spot-y", `${Math.round(rect.top)}px`);
|
|
116
|
+
box.style.setProperty("--dk-spot-w", `${Math.round(rect.width)}px`);
|
|
117
|
+
box.style.setProperty("--dk-spot-h", `${Math.round(rect.height)}px`);
|
|
118
|
+
box.className = "dk-spot dk-spot-on";
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
function hide() {
|
|
122
|
+
at = undefined;
|
|
123
|
+
if (overlay)
|
|
124
|
+
overlay.box.className = "dk-spot";
|
|
125
|
+
}
|
|
126
|
+
function dispose() {
|
|
127
|
+
hide();
|
|
128
|
+
if (!overlay)
|
|
129
|
+
return;
|
|
130
|
+
win?.removeEventListener?.("scroll", reflow);
|
|
131
|
+
win?.removeEventListener?.("resize", reflow);
|
|
132
|
+
overlay.host.remove();
|
|
133
|
+
overlay = null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=highlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.js","sourceRoot":"","sources":["../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**\n * The outline over the element a verb is about to touch.\n *\n * ## `at` is presentational, and that is the whole rule\n *\n * A verb may name a CSS selector, `Verb.at`, for the thing on screen it is\n * about. The widget is allowed to draw on top of what that names and is\n * allowed to do nothing else with it. It never queries it to decide what to\n * call, never clicks it, never reads a value out of it, and never lets its\n * absence change what runs. If `at` could steer a call then driverkit would\n * have a selector in its execution path, and a library whose entire argument\n * is \"no pixels, no selectors\" would have quietly grown the failure mode it\n * exists to avoid — a rename in somebody's CSS breaking an agent.\n *\n * So every failure here is silent and every failure means the same thing: no\n * outline, run unchanged. No `at` (which is most verbs), no `querySelector` on\n * the injected document, a selector that matches nothing, a selector that is\n * not valid CSS, an element with no measurable box, an element measuring zero\n * — all of them return false and draw nothing.\n *\n * ## It is an overlay, not a border\n *\n * Nothing is written to the host app's element. Not a class, not a style, not\n * an attribute. A 2px border added to somebody's button reflows their layout,\n * and an agent that nudges the page sideways every time it names an element is\n * not a passive observer of that page. Instead this draws a separate fixed,\n * `pointer-events: none` box at the element's measured rectangle.\n *\n * Nothing is added to the host app's document until there is something to\n * outline, either. Most verbs declare no `at`, so for most apps this file\n * creates no element and attaches no listener at all; the overlay host appears\n * the first time an outline is actually drawn and is removed on unmount.\n *\n * That box lives in its OWN host element with its own shadow root, rather than\n * inside the panel's. The panel's `:host` carries a `translate` — see the\n * positioning arithmetic in `css.ts` — and a transformed ancestor becomes the\n * containing block for `position: fixed` descendants, so an outline drawn\n * inside the panel would be offset by wherever the panel happens to sit. Two\n * hosts is the cost of the positioning design, and it is cheap: both are\n * removed on unmount.\n */\n\nimport { SPOT_CSS } from \"./css.ts\";\nimport type { DocumentLike, ElementLike, Listener, NodeLike, WindowLike } from \"./dom.ts\";\n\nexport interface SpotlightOptions {\n document: DocumentLike;\n /** Where the overlay host goes. The panel's container, so a host app that\n * keeps driverkit inside one subtree keeps all of it there. */\n container: ElementLike;\n /** Watched for scroll and resize, so an outline follows an element that\n * moved under it — which it will, because the verb being announced is quite\n * often the one that scrolls the row into view. */\n window?: WindowLike;\n}\n\nexport interface Spotlight {\n /** Draw over what `selector` names. True if an outline is now showing.\n * Anything that did not work returns false and leaves nothing drawn. */\n show: (selector: string | undefined) => boolean;\n hide: () => void;\n /** The selector currently outlined, or undefined. For tests, and for the\n * panel's own \"is anything showing\" check. */\n showing: () => string | undefined;\n dispose: () => void;\n}\n\nexport function spotlight(options: SpotlightOptions): Spotlight {\n const doc = options.document;\n const win = options.window;\n\n /** The overlay, built on first use. See the header: an app whose verbs name\n * nothing should not pay an element and two listeners for a feature it\n * never reaches. */\n let overlay: { host: ElementLike; box: ElementLike } | null = null;\n let at: string | undefined;\n\n function ensure(): { host: ElementLike; box: ElementLike } {\n if (overlay) return overlay;\n const host = doc.createElement(\"div\");\n host.className = \"dk-spot-host\";\n // Decorative, and the panel already says in words what is about to\n // happen. An outline announced to a screen reader would be the same\n // sentence twice.\n host.setAttribute(\"aria-hidden\", \"true\");\n const root: NodeLike = host.attachShadow\n ? host.attachShadow({ mode: \"open\" })\n : (host as NodeLike);\n const style = doc.createElement(\"style\");\n style.textContent = SPOT_CSS;\n root.appendChild(style);\n const box = doc.createElement(\"div\");\n box.className = \"dk-spot\";\n root.appendChild(box);\n options.container.appendChild(host);\n win?.addEventListener?.(\"scroll\", reflow);\n win?.addEventListener?.(\"resize\", reflow);\n overlay = { host, box };\n return overlay;\n }\n\n const reflow: Listener = () => {\n // Only while something is showing, and re-resolved from the selector\n // rather than from a cached element: between a scroll and now the app may\n // have re-rendered the row entirely, and an outline anchored to a detached\n // node is an outline in the wrong place.\n if (at !== undefined) draw(at);\n };\n return { show, hide, showing: () => at, dispose };\n\n function show(selector: string | undefined): boolean {\n if (selector === undefined || selector === \"\") {\n hide();\n return false;\n }\n const drawn = draw(selector);\n at = drawn ? selector : undefined;\n return drawn;\n }\n\n function draw(selector: string): boolean {\n let target: ElementLike | null = null;\n try {\n // A selector from a manifest is an app author's string and may be\n // anything at all, including syntactically invalid, which throws.\n target = doc.querySelector?.(selector) ?? null;\n } catch {\n target = null;\n }\n const rect = target?.getBoundingClientRect?.();\n // A zero-sized box is a hidden element, a `display: none` row, or a fake\n // without layout. Outlining it would draw a dot in the top-left corner of\n // the screen, which looks like a bug in the panel rather than like nothing.\n if (!rect || rect.width <= 0 || rect.height <= 0) {\n hide();\n return false;\n }\n const { box } = ensure();\n if (!box.style) return false;\n box.style.setProperty(\"--dk-spot-x\", `${Math.round(rect.left)}px`);\n box.style.setProperty(\"--dk-spot-y\", `${Math.round(rect.top)}px`);\n box.style.setProperty(\"--dk-spot-w\", `${Math.round(rect.width)}px`);\n box.style.setProperty(\"--dk-spot-h\", `${Math.round(rect.height)}px`);\n box.className = \"dk-spot dk-spot-on\";\n return true;\n }\n\n function hide(): void {\n at = undefined;\n if (overlay) overlay.box.className = \"dk-spot\";\n }\n\n function dispose(): void {\n hide();\n if (!overlay) return;\n win?.removeEventListener?.(\"scroll\", reflow);\n win?.removeEventListener?.(\"resize\", reflow);\n overlay.host.remove();\n overlay = null;\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { COMMIT_ASK_ABOVE, PANEL_TITLE, mountWidget } from "./widget.ts";
|
|
2
|
+
export type { RunControlsFactory, Widget, WidgetOptions } from "./widget.ts";
|
|
3
|
+
export { CSS, SPOT_CSS } from "./css.ts";
|
|
4
|
+
export { SPEEDS, settingsKey } from "./settings.ts";
|
|
5
|
+
export type { Settings } from "./settings.ts";
|
|
6
|
+
export { storageKey } from "./position.ts";
|
|
7
|
+
export type { Corner, Fraction, Position } from "./position.ts";
|
|
8
|
+
export type { AbortControllerCtor, AbortControllerLike, DocumentLike, ElementLike, EventLike, Listener, NodeLike, RectLike, StorageLike, StyleLike, WindowLike, } from "./dom.ts";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/widget/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,YAAY,EAAE,kBAAkB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAKzC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAM9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,YAAY,EACV,mBAAmB,EAAE,mBAAmB,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAC9E,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,GACjE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// `COMMIT_ASK_ABOVE` as well as `mountWidget`, because a host overriding
|
|
2
|
+
// `commitAskAbove` is making a judgement about its own undo and should be able
|
|
3
|
+
// to see — and name in its own help text — the number it is replacing.
|
|
4
|
+
// `PANEL_TITLE` alongside, for a host that wants to name the default header
|
|
5
|
+
// word in its own help text or reuse it — the same reason `COMMIT_ASK_ABOVE`
|
|
6
|
+
// is out here rather than buried.
|
|
7
|
+
export { COMMIT_ASK_ABOVE, PANEL_TITLE, mountWidget } from "./widget.js";
|
|
8
|
+
export { CSS, SPOT_CSS } from "./css.js";
|
|
9
|
+
// `settingsKey` for the same reason as `storageKey`: a host app offering a
|
|
10
|
+
// "reset the panel" button needs to know what to clear, and guessing at
|
|
11
|
+
// somebody else's localStorage key is how that button goes stale. `SPEEDS` so
|
|
12
|
+
// a host can name the same speeds in its own help text.
|
|
13
|
+
export { SPEEDS, settingsKey } from "./settings.js";
|
|
14
|
+
// `storageKey` is exported because a host app that offers a "reset the panel"
|
|
15
|
+
// button needs to know what to clear, and guessing at somebody else's
|
|
16
|
+
// localStorage key is how that button goes stale. The rest of `position.ts` is
|
|
17
|
+
// internal: `describe` and `nearestCorner` are too generically named to put in
|
|
18
|
+
// a package's public surface.
|
|
19
|
+
export { storageKey } from "./position.js";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/widget/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,+EAA+E;AAC/E,uEAAuE;AACvE,4EAA4E;AAC5E,6EAA6E;AAC7E,kCAAkC;AAClC,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,2EAA2E;AAC3E,wEAAwE;AACxE,8EAA8E;AAC9E,wDAAwD;AACxD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEpD,8EAA8E;AAC9E,sEAAsE;AACtE,+EAA+E;AAC/E,+EAA+E;AAC/E,8BAA8B;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC","sourcesContent":["// `COMMIT_ASK_ABOVE` as well as `mountWidget`, because a host overriding\n// `commitAskAbove` is making a judgement about its own undo and should be able\n// to see — and name in its own help text — the number it is replacing.\n// `PANEL_TITLE` alongside, for a host that wants to name the default header\n// word in its own help text or reuse it — the same reason `COMMIT_ASK_ABOVE`\n// is out here rather than buried.\nexport { COMMIT_ASK_ABOVE, PANEL_TITLE, mountWidget } from \"./widget.ts\";\nexport type { RunControlsFactory, Widget, WidgetOptions } from \"./widget.ts\";\nexport { CSS, SPOT_CSS } from \"./css.ts\";\n// `settingsKey` for the same reason as `storageKey`: a host app offering a\n// \"reset the panel\" button needs to know what to clear, and guessing at\n// somebody else's localStorage key is how that button goes stale. `SPEEDS` so\n// a host can name the same speeds in its own help text.\nexport { SPEEDS, settingsKey } from \"./settings.ts\";\nexport type { Settings } from \"./settings.ts\";\n// `storageKey` is exported because a host app that offers a \"reset the panel\"\n// button needs to know what to clear, and guessing at somebody else's\n// localStorage key is how that button goes stale. The rest of `position.ts` is\n// internal: `describe` and `nearestCorner` are too generically named to put in\n// a package's public surface.\nexport { storageKey } from \"./position.ts\";\nexport type { Corner, Fraction, Position } from \"./position.ts\";\nexport type {\n AbortControllerCtor, AbortControllerLike, DocumentLike, ElementLike, EventLike,\n Listener, NodeLike, RectLike, StorageLike, StyleLike, WindowLike,\n} from \"./dom.ts\";\n"]}
|