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.
Files changed (159) hide show
  1. package/CONTROLS.md +578 -0
  2. package/README.md +104 -2
  3. package/dist/agent/backend.d.ts +69 -0
  4. package/dist/agent/backend.d.ts.map +1 -0
  5. package/dist/agent/backend.js +130 -0
  6. package/dist/agent/backend.js.map +1 -0
  7. package/dist/agent/control.d.ts +148 -0
  8. package/dist/agent/control.d.ts.map +1 -0
  9. package/dist/agent/control.js +342 -0
  10. package/dist/agent/control.js.map +1 -0
  11. package/dist/agent/index.d.ts +9 -0
  12. package/dist/agent/index.d.ts.map +1 -0
  13. package/dist/agent/index.js +6 -0
  14. package/dist/agent/index.js.map +1 -0
  15. package/dist/agent/loop.d.ts +136 -0
  16. package/dist/agent/loop.d.ts.map +1 -0
  17. package/dist/agent/loop.js +824 -0
  18. package/dist/agent/loop.js.map +1 -0
  19. package/dist/agent/render.d.ts +173 -0
  20. package/dist/agent/render.d.ts.map +1 -0
  21. package/dist/agent/render.js +425 -0
  22. package/dist/agent/render.js.map +1 -0
  23. package/dist/agent/tools.d.ts +138 -0
  24. package/dist/agent/tools.d.ts.map +1 -0
  25. package/dist/agent/tools.js +622 -0
  26. package/dist/agent/tools.js.map +1 -0
  27. package/dist/agent/types.d.ts +566 -0
  28. package/dist/agent/types.d.ts.map +1 -0
  29. package/dist/agent/types.js +32 -0
  30. package/dist/agent/types.js.map +1 -0
  31. package/dist/browser/budget.d.ts +92 -0
  32. package/dist/browser/budget.d.ts.map +1 -0
  33. package/dist/browser/budget.js +151 -0
  34. package/dist/browser/budget.js.map +1 -0
  35. package/dist/browser/connect.d.ts +368 -0
  36. package/dist/browser/connect.d.ts.map +1 -0
  37. package/dist/browser/connect.js +1038 -0
  38. package/dist/browser/connect.js.map +1 -0
  39. package/dist/browser/elsewhere.d.ts +89 -0
  40. package/dist/browser/elsewhere.d.ts.map +1 -0
  41. package/dist/browser/elsewhere.js +91 -0
  42. package/dist/browser/elsewhere.js.map +1 -0
  43. package/dist/browser/frames.d.ts +85 -0
  44. package/dist/browser/frames.d.ts.map +1 -0
  45. package/dist/browser/frames.js +11 -0
  46. package/dist/browser/frames.js.map +1 -0
  47. package/dist/browser/index.d.ts +8 -0
  48. package/dist/browser/index.d.ts.map +1 -0
  49. package/dist/browser/index.js +9 -0
  50. package/dist/browser/index.js.map +1 -0
  51. package/dist/check/check.d.ts +171 -0
  52. package/dist/check/check.d.ts.map +1 -0
  53. package/dist/check/check.js +666 -0
  54. package/dist/check/check.js.map +1 -0
  55. package/dist/check/index.d.ts +3 -0
  56. package/dist/check/index.d.ts.map +1 -0
  57. package/dist/check/index.js +2 -0
  58. package/dist/check/index.js.map +1 -0
  59. package/dist/check/types.d.ts +149 -0
  60. package/dist/check/types.d.ts.map +1 -0
  61. package/dist/check/types.js +29 -0
  62. package/dist/check/types.js.map +1 -0
  63. package/dist/controls/controls.d.ts +198 -0
  64. package/dist/controls/controls.d.ts.map +1 -0
  65. package/dist/controls/controls.js +742 -0
  66. package/dist/controls/controls.js.map +1 -0
  67. package/dist/controls/dom.d.ts +108 -0
  68. package/dist/controls/dom.d.ts.map +1 -0
  69. package/dist/controls/dom.js +56 -0
  70. package/dist/controls/dom.js.map +1 -0
  71. package/dist/controls/index.d.ts +26 -0
  72. package/dist/controls/index.d.ts.map +1 -0
  73. package/dist/controls/index.js +23 -0
  74. package/dist/controls/index.js.map +1 -0
  75. package/dist/controls/rows.d.ts +66 -0
  76. package/dist/controls/rows.d.ts.map +1 -0
  77. package/dist/controls/rows.js +127 -0
  78. package/dist/controls/rows.js.map +1 -0
  79. package/dist/core/index.d.ts +3 -0
  80. package/dist/core/index.d.ts.map +1 -0
  81. package/dist/core/index.js +15 -0
  82. package/dist/core/index.js.map +1 -0
  83. package/dist/core/registry.d.ts +192 -0
  84. package/dist/core/registry.d.ts.map +1 -0
  85. package/dist/core/registry.js +2799 -0
  86. package/dist/core/registry.js.map +1 -0
  87. package/dist/core/types.d.ts +2468 -0
  88. package/dist/core/types.d.ts.map +1 -0
  89. package/dist/core/types.js +19 -0
  90. package/dist/core/types.js.map +1 -0
  91. package/dist/otel/index.d.ts +122 -0
  92. package/dist/otel/index.d.ts.map +1 -0
  93. package/dist/otel/index.js +157 -0
  94. package/dist/otel/index.js.map +1 -0
  95. package/dist/react/index.d.ts +191 -0
  96. package/dist/react/index.d.ts.map +1 -0
  97. package/dist/react/index.js +547 -0
  98. package/dist/react/index.js.map +1 -0
  99. package/dist/react/runtime.d.ts +95 -0
  100. package/dist/react/runtime.d.ts.map +1 -0
  101. package/dist/react/runtime.js +54 -0
  102. package/dist/react/runtime.js.map +1 -0
  103. package/dist/react/store.d.ts +333 -0
  104. package/dist/react/store.d.ts.map +1 -0
  105. package/dist/react/store.js +695 -0
  106. package/dist/react/store.js.map +1 -0
  107. package/dist/relay/auth.d.ts +244 -0
  108. package/dist/relay/auth.d.ts.map +1 -0
  109. package/dist/relay/auth.js +391 -0
  110. package/dist/relay/auth.js.map +1 -0
  111. package/dist/relay/frames.d.ts +141 -0
  112. package/dist/relay/frames.d.ts.map +1 -0
  113. package/dist/relay/frames.js +20 -0
  114. package/dist/relay/frames.js.map +1 -0
  115. package/dist/relay/index.d.ts +8 -0
  116. package/dist/relay/index.d.ts.map +1 -0
  117. package/dist/relay/index.js +4 -0
  118. package/dist/relay/index.js.map +1 -0
  119. package/dist/relay/relay.d.ts +277 -0
  120. package/dist/relay/relay.d.ts.map +1 -0
  121. package/dist/relay/relay.js +1026 -0
  122. package/dist/relay/relay.js.map +1 -0
  123. package/dist/relay/serve.d.ts +33 -0
  124. package/dist/relay/serve.d.ts.map +1 -0
  125. package/dist/relay/serve.js +86 -0
  126. package/dist/relay/serve.js.map +1 -0
  127. package/dist/widget/chat.d.ts +290 -0
  128. package/dist/widget/chat.d.ts.map +1 -0
  129. package/dist/widget/chat.js +486 -0
  130. package/dist/widget/chat.js.map +1 -0
  131. package/dist/widget/css.d.ts +49 -0
  132. package/dist/widget/css.d.ts.map +1 -0
  133. package/dist/widget/css.js +532 -0
  134. package/dist/widget/css.js.map +1 -0
  135. package/dist/widget/dom.d.ts +143 -0
  136. package/dist/widget/dom.d.ts.map +1 -0
  137. package/dist/widget/dom.js +27 -0
  138. package/dist/widget/dom.js.map +1 -0
  139. package/dist/widget/highlight.d.ts +64 -0
  140. package/dist/widget/highlight.d.ts.map +1 -0
  141. package/dist/widget/highlight.js +136 -0
  142. package/dist/widget/highlight.js.map +1 -0
  143. package/dist/widget/index.d.ts +9 -0
  144. package/dist/widget/index.d.ts.map +1 -0
  145. package/dist/widget/index.js +20 -0
  146. package/dist/widget/index.js.map +1 -0
  147. package/dist/widget/position.d.ts +166 -0
  148. package/dist/widget/position.d.ts.map +1 -0
  149. package/dist/widget/position.js +497 -0
  150. package/dist/widget/position.js.map +1 -0
  151. package/dist/widget/settings.d.ts +116 -0
  152. package/dist/widget/settings.d.ts.map +1 -0
  153. package/dist/widget/settings.js +117 -0
  154. package/dist/widget/settings.js.map +1 -0
  155. package/dist/widget/widget.d.ts +442 -0
  156. package/dist/widget/widget.d.ts.map +1 -0
  157. package/dist/widget/widget.js +2005 -0
  158. package/dist/widget/widget.js.map +1 -0
  159. package/package.json +153 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controls.js","sourceRoot":"","sources":["../../src/controls/controls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AAGH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA6HvC;;uEAEuE;AACvE,MAAM,OAAO,GAAG;IACd,iBAAiB;IACjB,aAAa;IACb,WAAW;IACX,mBAAmB;IACnB,YAAY;IACZ,UAAU;CACF,CAAC;AAEX;;;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AG,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * driverkit/controls — the controls layer.\n *\n * ```ts\n * const dk = controlsFromDom({ root: \"#app\", rows: \"#contacts\" });\n *\n * mount({\n * app: \"Contacts\",\n * verbs: [...myShortcuts, ...dk.verbs],\n * visible: () => dk.withControls(myVisible()),\n * });\n * ```\n *\n * ──────────────────────────────────────────────────────────────────────────\n * WHY THERE IS A SECOND LAYER AT ALL.\n *\n * Everything else in driverkit is a shortcut: somebody writes\n * `select-where(company, status?)` and an agent selects four hundred rows in\n * one call, with a count in front of the commit. That is the layer worth\n * having and it is not going anywhere.\n *\n * It is also, on its own, incomplete — and the incompleteness is structural\n * rather than a gap somebody can close by writing more verbs. A real failure:\n * a demo whose only selection verb was `select-where(company)`, asked to\n * select one named contact. The model refused, correctly, because the only\n * tool it had would have selected all four hundred and ten contacts at that\n * company in order to get one of them. It did the right thing with the wrong\n * vocabulary. You cannot enumerate your way out of that: somebody will always\n * ask for the thing nobody listed.\n *\n * So this layer is complete BY CONSTRUCTION instead of by curation. One\n * action, total coverage: whatever the person at the keyboard could press,\n * tick or type into, an agent can too.\n *\n * controls one action, total coverage press a button, type in a field\n * shortcuts one call, many rows select-where(...), accept-selected\n *\n * Neither replaces the other. A shortcut is how a thousand rows move in one\n * call with one number in front of it; a control is how the nine hundred and\n * ninety-ninth thing nobody listed gets done at all. They compose in one\n * `mount()` and an agent cannot tell which layer a verb came from.\n *\n * WHAT THIS IS NOT.\n *\n * It is not selector automation wearing a hat. The agent never sees a\n * selector, a path or a coordinate: it sees `accept` because somebody typed\n * `data-dk-control=\"accept\"` next to their own button, and that word is the\n * only way in. Nothing here searches by label text, by role, by position or by\n * similarity, and a name that is not marked on the page is a refusal and never\n * a near miss — because a near miss is how an agent presses Delete when it\n * meant Dismiss. `Verb.at` is the one selector in the library and it is\n * presentational: it exists so a watching human sees an outline, it is never\n * used to find anything, and nothing here reads it.\n *\n * WHERE THE TWO HALVES LIVE, which is the decision the rest follows from.\n *\n * static, cached, in the manifest THAT the app can press a control:\n * three verbs, three argument lists.\n * dynamic, uncached, in the snapshot WHICH controls are on this screen now:\n * `Snapshot.controls`.\n *\n * Getting that backwards is the expensive mistake and it has an obvious\n * shape — put the control names in a verb's `ArgSpec.oneOf`. It reads as a\n * kindness (the model cannot then name a control that does not exist) and it\n * drops a per-screen list into the prompt prefix, so every navigation busts\n * the cache for that user and every user's prefix differs from every other's.\n * The library's whole cost argument is that the static half is static. So the\n * control names are a plain `string` argument, validated against the page at\n * call time, and the list of them rides in the snapshot beside the rows.\n * ──────────────────────────────────────────────────────────────────────────\n */\n\nimport type { ScreenControl, Snapshot, Verb, VerbContext, VerbKind } from \"../core/index.ts\";\nimport { collapse, defaultEvent, resolveRoot } from \"./dom.ts\";\nimport type { ElementLike, EventCtor, FieldLike, QueryRootLike } from \"./dom.ts\";\nimport { rowHandles } from \"./rows.ts\";\nimport type { RowIdOptions } from \"./rows.ts\";\n\n/** Where the rows are, so a control inside one is reported once and addressed\n * by row id. A selector, an element, or a selector plus the options that\n * decide how a row's id is spelled (`rows.ts`). */\nexport type RowsSpec =\n | string\n | ElementLike\n | ({ container: string | ElementLike } & RowIdOptions);\n\nexport interface ControlsConfig {\n /**\n * The attribute that marks a control. Default `data-dk-control`.\n *\n * Deliberately NOT `data-dk`, which binds one hand-written verb to one\n * button. The two marks say different things: `data-dk` says \"a verb I wrote\n * and described clicks this\", and `data-dk-control` says \"publish this to an\n * agent as a control it may press at will\". Folding them together would\n * silently publish every button an app marked so one of its own verbs could\n * click it — including the ones whose author wrapped them in a narrower verb\n * on purpose — and publishing\n * is consent. Pass `{ attribute: \"data-dk\" }` to opt into exactly that, once\n * you have looked at the list.\n */\n attribute?: string;\n /** Where the author declares what a control does. Default `data-dk-kind`,\n * whose value is `read`, `describe` or `commit`. */\n kindAttribute?: string;\n /** The human label, when the control's own text is not it (an icon button).\n * Default `data-dk-label`, falling back to text, `aria-label`, `title`. */\n labelAttribute?: string;\n /** Force or deny \"this control takes text\". Default `data-dk-field`, read as\n * `true`/`false`. Absent means the tag decides. */\n fieldAttribute?: string;\n /**\n * The attribute that takes a control back out. Default `data-dk-human-only`.\n *\n * An element carrying it is not enumerated and cannot be pressed or typed\n * into, even though it is marked as a control. The case it exists for is the\n * one in webmachinelearning/webmcp#288: ChatGPT's in-app browser called a\n * proposal-only tool, the proposal did not execute itself, so the agent\n * clicked the page's own Approve button and the receipt recorded \"approved\n * by you\". `press` and `commit-control` over `data-dk-control` are exactly\n * that bypass — one action, total coverage, including coverage of the button\n * that exists to stop the action.\n *\n * So the Yes of a confirmation, the signature field, the \"I agree\" tick and\n * the 2FA box carry this, and an agent naming one gets `no-such-control` —\n * indistinguishable from a name that was never marked, because a different\n * refusal would tell a prober which buttons are the interesting ones.\n *\n * IT IS THE WEAKEST OF THE THREE LAYERS and it is named as such because it\n * is the one an author can forget. The core's `approval-pending` lock needs\n * nobody to remember anything — while an approval is open no call runs at\n * all — and the widget's own dialog lives inside a shadow root this\n * enumerator never walks. Use this for a gate of your own that lives in the\n * light DOM, and never as the only thing between an agent and a commit.\n *\n * THE MARK IS INHERITED. An element inside something marked human-only is\n * itself human-only, so one attribute on a `<dialog>` takes the Yes, the\n * signature field and the 2FA box inside it out together. This used to read\n * the element and nothing else, which meant the natural way to write the\n * mark — on the gate — did nothing at all, and the only way that worked was\n * to repeat it on every descendant. The walk goes all the way out, past\n * `root`, and `data-dk-human-only=\"false\"` on a descendant re-opens that one\n * control. See `humanOnly`.\n */\n humanOnlyAttribute?: string;\n\n /** Narrow every lookup. A control outside this root does not exist. */\n root?: string | QueryRootLike;\n document?: QueryRootLike;\n /** Where the rows are. Omit for a screen with no table: then every control\n * is a screen control. */\n rows?: RowsSpec;\n\n /** Declare kinds in code instead of in markup, for generated or\n * third-party markup you cannot annotate. Consulted before the attribute,\n * and returning `undefined` falls through to it. */\n kind?: (name: string, el: ElementLike) => VerbKind | undefined;\n\n /** Decide whether a control should refuse. Default: refuse on `disabled` or\n * `aria-disabled=\"true\"`, because pressing a disabled button succeeds, does\n * nothing, and reports `ok`. Return a reason slug, or null to allow. */\n refuseWhen?: (el: ElementLike, name: string) => string | null;\n\n /** Rename the three verbs, for an app that already has a verb called\n * `press`. `mount()` throws on a duplicate name, so this is the fix. */\n names?: { press?: string; type?: string; commit?: string };\n\n /** The most controls to list in one snapshot. Default 40. Over it, the list\n * is truncated and says so — see `enumerate`. */\n limit?: number;\n\n /** Also render the control list into `Snapshot.note`. Default true, and\n * transitional: see the note on `note()`. */\n inNote?: boolean;\n\n /** Put text into a field your own way. The default assigns `value` and fires\n * `input` and `change`; a React controlled input may need the native setter\n * instead. See the limits section of CONTROLS.md. */\n setValue?: (el: FieldLike, text: string) => void;\n /** `Event`, defaulting to the global. */\n Event?: EventCtor;\n\n /** Diagnostics for the app author, which an agent must never be told:\n * undeclared kinds, two controls sharing a name. Default: `console.warn`\n * once per distinct message. */\n onWarn?: (message: string) => void;\n}\n\nexport interface ControlsBinding {\n /** The three generic verbs. Spread these into `mount({ verbs })` beside\n * whatever you wrote by hand. */\n verbs: Verb<any>[];\n /** The controls on screen right now. For `Snapshot.controls`. */\n controls: () => ScreenControl[];\n /** The control list as one short line, for `Snapshot.note`. */\n note: () => string | undefined;\n /** Add both to a snapshot your app already builds. Non-destructive: an\n * existing `note` is kept and this is appended to it. */\n withControls: <S extends Snapshot>(snapshot: S) => S;\n}\n\n/** The slugs the control verbs refuse with. Declared on every one of them, so\n * the list reaches the model in the CACHED half and a well-briefed agent\n * avoids the call rather than discovering the answer by making it. */\nconst REFUSES = [\n \"no-such-control\",\n \"no-such-row\",\n \"needs-row\",\n \"not-a-row-control\",\n \"wrong-verb\",\n \"disabled\",\n] as const;\n\n/** `<input>` types that are not text. Everything else on an `input`, including\n * `date` and `number`, takes text and is a field. A checkbox is a control you\n * press, which is why this list exists at all: typing into one is nonsense and\n * pressing one is the commonest per-row action there is. */\n/**\n * How far up `data-dk-human-only` is looked for. See `humanOnly`.\n *\n * A number rather than an unbounded loop, because the only way `parentElement`\n * can fail to terminate is a fake that points an element at itself — a bug\n * worth surfacing as a wrong answer rather than as a page that stops\n * responding. 64 is deeper than any real markup's control-to-`<body>` distance\n * and the walk stops at the first element carrying the attribute anyway.\n */\nconst HUMAN_ONLY_DEPTH = 64;\n\nconst NOT_TEXT = new Set([\n \"checkbox\",\n \"radio\",\n \"button\",\n \"submit\",\n \"reset\",\n \"file\",\n \"image\",\n \"color\",\n \"range\",\n]);\n\n/**\n * Bind the controls layer over a DOM.\n *\n * Nothing is captured. Every call re-reads the page, for the reason\n * `rows.ts` gives at length: any app worth adapting re-renders, and a node\n * captured at mount is a node that has since been detached — pressing it does\n * precisely nothing, with no error, and the verb reports success.\n */\nexport function controlsFromDom(config: ControlsConfig = {}): ControlsBinding {\n const attribute = config.attribute ?? \"data-dk-control\";\n const kindAttribute = config.kindAttribute ?? \"data-dk-kind\";\n const labelAttribute = config.labelAttribute ?? \"data-dk-label\";\n const fieldAttribute = config.fieldAttribute ?? \"data-dk-field\";\n const humanOnlyAttribute = config.humanOnlyAttribute ?? \"data-dk-human-only\";\n const limit = config.limit ?? 40;\n const refuseWhen = config.refuseWhen ?? disabledCheck;\n const warn = warner(config.onWarn);\n\n const names = {\n press: config.names?.press ?? \"press\",\n type: config.names?.type ?? \"type-into\",\n commit: config.names?.commit ?? \"commit-control\",\n };\n\n // ── reading the page ──────────────────────────────────────────────────────\n\n function root(): QueryRootLike {\n return resolveRoot(config.root, config.document, \"controlsFromDom\");\n }\n\n function rowsOf(): Array<{ el: ElementLike; id: string }> {\n if (config.rows === undefined) return [];\n const spec = config.rows;\n const shared: RowIdOptions = {\n ...(config.root === undefined ? {} : { root: config.root }),\n ...(config.document === undefined ? {} : { document: config.document }),\n ...(config.onWarn === undefined ? {} : { onWarn: config.onWarn }),\n };\n if (typeof spec === \"string\") return rowHandles(spec, shared);\n if (typeof spec === \"object\" && \"container\" in spec) {\n const { container, ...rest } = spec;\n return rowHandles(container, { ...shared, ...rest });\n }\n return rowHandles(spec, shared);\n }\n\n interface Found {\n el: ElementLike;\n name: string;\n /** The row id this element sits in, or null for a screen control. */\n row: string | null;\n }\n\n /**\n * Every marked element, each told whether it is inside a row.\n *\n * The row test is a containment test and not an ancestor walk, and it stays\n * one now that `ElementLike` has an optional `parentElement` for\n * `humanOnly`: it asks \"is this element inside one of the rows the snapshot\n * is showing\", which is exactly the question and tests against a known set,\n * rather than \"does it have a `tr` somewhere above it\", which is a different\n * question and the wrong answer in a nested table. The opt-out cannot be\n * written that way — there is no set of marked wrappers to test against —\n * which is why that one walks and this one does not.\n */\n function scan(): Found[] {\n const r = root();\n const inRow = new Map<ElementLike, string>();\n for (const row of rowsOf()) {\n for (const el of row.el.querySelectorAll(`[${attribute}]`)) inRow.set(el, row.id);\n // A row element may itself be the control — a clickable `<tr>`.\n if (isMarked(row.el, attribute)) inRow.set(row.el, row.id);\n }\n\n const out: Found[] = [];\n const withheld = new Set<string>();\n for (const el of r.querySelectorAll(`[${attribute}]`)) {\n const name = collapse(el.getAttribute(attribute));\n if (!name) continue;\n // Dropped HERE, in the one function every other function in this file\n // reads the page through, so the opt-out cannot be true of the\n // enumeration and false of the three verbs. A control that is not in\n // this list does not exist to the layer at all — which is the same\n // answer an unmarked button gets, deliberately.\n if (humanOnly(el)) {\n // Said once, and only to the author. A control that vanished because\n // of a mark on a `<dialog>` three levels up is the one case of this\n // attribute that looks like a bug in the library, so the library says\n // which it was.\n if (humanOnlyAbove(el)) withheld.add(name);\n continue;\n }\n out.push({ el, name, row: inRow.get(el) ?? null });\n }\n if (withheld.size) {\n warn(\n `controls: ${withheld.size} control(s) are inside an element marked ` +\n `${humanOnlyAttribute} and are not published: ` +\n `${[...withheld].slice(0, 12).join(\", \")}. That is what the mark means — an agent is ` +\n `told nothing about them, exactly as if they were never marked as controls. Put ` +\n `${humanOnlyAttribute}=\"false\" on one to open it again.`,\n );\n }\n return out;\n }\n\n /**\n * Marked for a person only, on this element or on anything above it.\n *\n * Presence is the signal, because `data-dk-human-only` with no value is how\n * an author writes it; the one exception is the literal `false`, so a\n * templating language that always emits the attribute can still say no — and\n * a `false` on the element itself wins over a mark further up, which is the\n * only reading that lets an author open one control inside a closed region.\n *\n * THE ANCESTOR WALK, which this did not have. Marking a `<dialog>` used to\n * mark nothing: every button inside the confirmation stayed enumerable and\n * pressable, which is the opposite of what the author wrote. The mark that is\n * natural to write — one attribute on the thing that is the gate — was the\n * one that did not work, and the mark that worked had to be repeated on\n * every Yes, every signature field and every 2FA box inside it. An opt-out\n * whose correct use is the laborious one is an opt-out that will be got\n * wrong.\n *\n * It walks OUT PAST `root`, not up to it. A human-only region that contains\n * the root is a region an author marked and the enumerator is standing\n * inside; stopping at the root would silently ignore it, and that is the\n * direction in which being wrong costs something. The visible consequence is\n * that a root inside a marked region enumerates nothing at all, which is\n * loud, is what the markup says, and is warned about once.\n *\n * TWO THINGS IT DOES NOT SEE, both worth knowing before relying on it. A\n * shadow boundary: `parentElement` is null on the top node of a shadow tree,\n * so a mark on the HOST element does not reach controls inside it — mark\n * something inside the tree. And an `ElementLike` that does not implement\n * `parentElement` at all (a non-DOM renderer's adapter, an older fake) reads\n * as having no ancestors, which is the element-only behaviour this had\n * before and is the compatible answer rather than the safe one.\n *\n * `DEPTH` bounds the walk. A real DOM cannot cycle, and a hand-written\n * `ElementLike` whose `parentElement` points at itself is a bug in a fake\n * that should surface as a wrong answer rather than as a hung page.\n */\n function humanOnly(el: ElementLike): boolean {\n let node: ElementLike | null | undefined = el;\n for (let depth = 0; node && depth < HUMAN_ONLY_DEPTH; depth += 1) {\n const value = node.getAttribute(humanOnlyAttribute);\n if (value !== null && value !== undefined) {\n return collapse(value).toLowerCase() !== \"false\";\n }\n node = node.parentElement;\n }\n return false;\n }\n\n /** Was this element's mark inherited from an ancestor? Only for the author's\n * diagnostic: an agent is never told a control is being withheld, because a\n * different answer for a withheld control is an oracle over which buttons\n * are the interesting ones. */\n function humanOnlyAbove(el: ElementLike): boolean {\n const own = el.getAttribute(humanOnlyAttribute);\n return (own === null || own === undefined) && humanOnly(el);\n }\n\n function kindOf(name: string, el: ElementLike): VerbKind | undefined {\n const fromHook = config.kind?.(name, el);\n if (fromHook) return fromHook;\n const declared = collapse(el.getAttribute(kindAttribute)).toLowerCase();\n if (declared === \"read\" || declared === \"describe\" || declared === \"commit\") return declared;\n if (declared !== \"\") {\n warn(\n `controls: the control \\`${name}\\` declares ${kindAttribute}=\"${declared}\", which is not ` +\n `read, describe or commit. Treating it as undeclared, which routes it through the ` +\n `commit verb and asks the human every time.`,\n );\n }\n return undefined;\n }\n\n function isField(el: ElementLike): boolean {\n const declared = collapse(el.getAttribute(fieldAttribute)).toLowerCase();\n if (declared === \"true\") return true;\n if (declared === \"false\") return false;\n const tag = (((el as FieldLike).tagName ?? \"\") as string).toLowerCase();\n if (tag === \"textarea\") return true;\n if (tag !== \"input\") return false;\n return !NOT_TEXT.has(collapse(el.getAttribute(\"type\")).toLowerCase());\n }\n\n function labelOf(name: string, el: ElementLike): string | undefined {\n const explicit = collapse(el.getAttribute(labelAttribute));\n if (explicit) return clip(explicit);\n const text = collapse(el.textContent);\n if (text) return clip(text);\n const aria = collapse(el.getAttribute(\"aria-label\"));\n if (aria) return clip(aria);\n const title = collapse(el.getAttribute(\"title\"));\n if (title) return clip(title);\n const placeholder = collapse(el.getAttribute(\"placeholder\"));\n if (placeholder) return clip(placeholder);\n // No label is better than the name repeated as one: a model reading\n // `accept (accept)` learns nothing and pays for the second word.\n return undefined;\n }\n\n // ── the enumeration ───────────────────────────────────────────────────────\n\n /**\n * The controls on screen, one entry per NAME rather than per element.\n *\n * This is the field that keeps the snapshot small, and the brief it has to\n * meet is concrete: twenty rows with six controls each must not be a hundred\n * and twenty entries. So a control found inside a row is described once,\n * marked `per: \"row\"`, and addressed by row id — which works because the\n * markup that rendered it was one template, so the twenty copies are the same\n * control twenty times over and differ in nothing an agent needs.\n *\n * `disabled` is the one property that genuinely varies between the copies\n * (row 3's Delete greyed out, row 4's not). Collapsing cannot preserve that,\n * so it claims `disabled` only when EVERY copy is disabled, and the call-time\n * check refuses for the specific row. The snapshot is therefore not quite a\n * complete account of a row control's availability, and the alternative —\n * one entry per row per control — costs the cost argument. Said plainly in\n * CONTROLS.md rather than hidden here.\n */\n function enumerate(): { controls: ScreenControl[]; hidden: number } {\n const byName = new Map<string, { s: ScreenControl; copies: number; disabled: number }>();\n const dupes = new Set<string>();\n const undeclared: string[] = [];\n\n for (const { el, name, row } of scan()) {\n const existing = byName.get(name);\n const off = refuseWhen(el, name) !== null;\n\n if (existing) {\n existing.copies += 1;\n if (off) existing.disabled += 1;\n // Two screen controls sharing a name is an authoring bug: the verb acts\n // on whichever the page yields first, exactly like two rows sharing an\n // id. Not renamed — a suffixed name would be a name no screen shows.\n if (row === null || existing.s.per !== \"row\") dupes.add(name);\n continue;\n }\n\n const kind = kindOf(name, el);\n if (kind === undefined) undeclared.push(name);\n const label = labelOf(name, el);\n byName.set(name, {\n s: {\n name,\n ...(label === undefined ? {} : { label }),\n ...(kind === undefined ? {} : { kind }),\n ...(row === null ? {} : { per: \"row\" as const }),\n ...(isField(el) ? { field: true as const } : {}),\n },\n copies: 1,\n disabled: off ? 1 : 0,\n });\n }\n\n for (const name of dupes) {\n warn(\n `controls: two controls are both named \\`${name}\\`. A verb naming it acts on whichever ` +\n `the page yields first. Give them different ${attribute} values.`,\n );\n }\n if (undeclared.length) {\n // Worded as a decision the author owes, not as a nuisance they can\n // clear. The line this replaces ended \"and the question goes away\",\n // which is true and is also an instruction to type the cheapest value:\n // `read` silences the gate on every one of these in one pass, and\n // `read` on something that changes data is the one claim the library\n // cannot catch and will act on. So the undeclared state is named as the\n // SAFE one it is, and the declaration is named as a claim.\n warn(\n `controls: ${undeclared.length} control(s) declare no ${kindAttribute}: ` +\n `${undeclared.slice(0, 12).join(\", \")}. Each is reachable only through ` +\n `\\`${names.commit}\\`, which asks the person first — so this is safe, and it is the ` +\n `state to leave them in until somebody has read the handler. ` +\n `${kindAttribute}=\"read|describe|commit\" is a CLAIM about what the control does, and ` +\n `nothing here can check it: \\`read\\` on a button that changes data takes away the only ` +\n `thing standing in front of an agent pressing it. Declare the ones you have read.`,\n );\n }\n\n const all = [...byName.values()].map(({ s, copies, disabled }) =>\n copies > 0 && disabled === copies ? { ...s, disabled: true as const } : s,\n );\n\n // Over the limit the list is cut rather than sent. A truncated list that\n // says it is truncated costs the agent a paging step; a 200-entry list\n // costs every turn of every session, in the half that is never cached.\n if (all.length <= limit) return { controls: all, hidden: 0 };\n warn(\n `controls: ${all.length} controls on screen, over the limit of ${limit}, so ${all.length - limit} ` +\n `are not listed. Narrow \\`root\\` to the part of the page an agent should drive, or raise \\`limit\\` ` +\n `knowing it is paid for on every turn.`,\n );\n return { controls: all.slice(0, limit), hidden: all.length - limit };\n }\n\n /**\n * The control list as one line of text.\n *\n * Transitional, and default-on because without it the layer does not work:\n * `Snapshot.controls` is structured and new, and nothing that renders a\n * snapshot for a model reads it yet. `note` is rendered by every renderer\n * there is, so that is where the controls go until they do. Turn it off with\n * `inNote: false` once your renderer prints `controls`, and the duplication —\n * which is real, and in the uncached half — goes away.\n *\n * The grammar is terse on purpose and the legend is in the verbs'\n * descriptions, which are cached. Bare name means the author declared it\n * `read`; anything else is parenthesised.\n */\n function render(controls: ScreenControl[], hidden: number): string | undefined {\n if (controls.length === 0) return undefined;\n const screen = controls.filter((c) => c.per !== \"row\");\n const perRow = controls.filter((c) => c.per === \"row\");\n const parts: string[] = [];\n if (screen.length) parts.push(`controls: ${screen.map(one).join(\", \")}`);\n if (perRow.length) parts.push(`each row: ${perRow.map(one).join(\", \")}`);\n if (hidden) parts.push(`${hidden} more control(s) on this screen are not listed`);\n return parts.join(\"; \");\n }\n\n function one(c: ScreenControl): string {\n const marks: string[] = [];\n if (c.field) marks.push(\"text\");\n if (c.kind === \"describe\" || c.kind === \"commit\") marks.push(c.kind);\n if (c.kind === undefined) marks.push(\"undeclared\");\n if (c.disabled) marks.push(\"disabled\");\n const label = c.label && c.label.toLowerCase() !== c.name.toLowerCase() ? ` “${c.label}”` : \"\";\n return `${c.name}${label}${marks.length ? ` (${marks.join(\", \")})` : \"\"}`;\n }\n\n // ── acting ────────────────────────────────────────────────────────────────\n\n /**\n * Which verb a control's declared kind routes to.\n *\n * The whole safety argument of this layer is in these three lines, so there\n * is no cleverness in them. `read` and `describe` go to the safe door, where\n * the mechanism then picks between pressing and typing; `commit` and\n * **undeclared** go to the gated one, which takes both. The second half of\n * that is the load-bearing choice and CONTROLS.md argues it at length: a\n * control nobody declared is an unreviewed button, and the library cannot\n * tell a Next Page from a Delete Account by looking at either.\n */\n function routeOf(kind: VerbKind | undefined, field: boolean): string {\n if (kind === undefined || kind === \"commit\") return names.commit;\n return field ? names.type : names.press;\n }\n\n interface Resolved {\n el: ElementLike;\n kind: VerbKind | undefined;\n field: boolean;\n }\n\n /**\n * Find the element a call named, or refuse.\n *\n * Resolved from the page at call time and never from the snapshot the model\n * was shown. A control that has been re-rendered away since then is the\n * ordinary case, not an exception — the person at the keyboard has been\n * clicking the whole time the model was thinking — so it is a refusal with a\n * list of what IS there, and never a click on whatever is nearest.\n */\n function resolve(\n verb: string,\n control: string,\n row: string | undefined,\n ctx: VerbContext,\n ): Resolved | ReturnType<VerbContext[\"refuse\"]> {\n const found = scan();\n const matching = found.filter((f) => f.name === control);\n\n if (matching.length === 0) {\n const offered = [...new Set(found.map((f) => f.name))].sort();\n return ctx.refuse(\n \"no-such-control\",\n offered.length\n ? `this screen offers no control named \\`${control}\\`. It offers: ${offered.join(\", \")}. ` +\n `Read the screen's control list rather than remembering one — it changes as you navigate.`\n : `this screen offers no controls at all. Nothing on it is marked with ${attribute}, so ` +\n `there is nothing for \\`${verb}\\` to press here.`,\n );\n }\n\n const wantsRow = matching.some((f) => f.row !== null);\n\n if (row === undefined || row === \"\") {\n if (wantsRow) {\n const ids = [...new Set(rowsOf().map((r) => r.id))];\n return ctx.refuse(\n \"needs-row\",\n `\\`${control}\\` is on each row, so it needs a row id in \\`row\\`. Rows on screen: ` +\n `${ids.slice(0, 8).join(\", \")}${ids.length > 8 ? \", …\" : \"\"}.`,\n );\n }\n return describeEl(matching[0]!.el, control);\n }\n\n if (!wantsRow) {\n return ctx.refuse(\n \"not-a-row-control\",\n `\\`${control}\\` belongs to the screen, not to a row, so it cannot be pressed for row ` +\n `\\`${row}\\`. Call it without \\`row\\`.`,\n );\n }\n\n const onRow = matching.find((f) => f.row === row);\n if (!onRow) {\n const ids = rowsOf().map((r) => r.id);\n if (!ids.includes(row)) {\n return ctx.refuse(\n \"no-such-row\",\n `no row \\`${row}\\` is on screen. Rows on screen: ${ids.slice(0, 8).join(\", \")}` +\n `${ids.length > 8 ? \", …\" : \"\"}. The screen may have paged or filtered since you read ` +\n `it; read it again. Quoting \\`rev\\` turns this into a \\`stale\\` refusal instead.`,\n );\n }\n return ctx.refuse(\n \"no-such-control\",\n `row \\`${row}\\` is on screen but offers no \\`${control}\\`. Row controls are not always ` +\n `rendered on every row.`,\n );\n }\n return describeEl(onRow.el, control);\n }\n\n function describeEl(el: ElementLike, control: string): Resolved {\n return { el, kind: kindOf(control, el), field: isField(el) };\n }\n\n /**\n * The sentence a routing refusal carries.\n *\n * Four cases, and each names the verb to use instead, because a refusal that\n * only says no costs a model a turn and teaches it nothing. The undeclared\n * one is phrased as a fact about the app rather than about the control: the\n * model has not made a mistake, the markup is simply silent, and the next\n * call it should make is the gated one.\n */\n function whyWrongVerb(control: string, verb: string, route: string, resolved: Resolved): string {\n if (resolved.kind === undefined) {\n return (\n `the app has not declared what \\`${control}\\` does, so it is treated as though it changes ` +\n `data. Use \\`${route}\\`, which asks the person first.`\n );\n }\n if (route === names.commit) {\n return `\\`${control}\\` is declared \\`${resolved.kind}\\`. Use \\`${route}\\` for it.`;\n }\n if (resolved.field && verb === names.press) {\n return (\n `\\`${control}\\` is a field, not a button. Use \\`${names.type}\\` and pass the text you ` +\n `want in it.`\n );\n }\n if (!resolved.field && verb === names.type) {\n return `\\`${control}\\` is a button, not a field. Use \\`${names.press}\\` for it.`;\n }\n return `\\`${control}\\` is declared \\`${resolved.kind}\\`. Use \\`${route}\\` for it.`;\n }\n\n /** The checks every control verb makes once it has an element, in the order\n * that gives the most useful refusal: routing before availability, because a\n * model told `disabled` about a control it should not have called through\n * this verb at all will retry it here when the button enables. */\n function gate(\n verb: string,\n control: string,\n hasText: boolean,\n resolved: Resolved,\n ctx: VerbContext,\n ): ReturnType<VerbContext[\"refuse\"]> | null {\n const route = routeOf(resolved.kind, resolved.field);\n if (route !== verb) {\n return ctx.refuse(\"wrong-verb\", whyWrongVerb(control, verb, route, resolved));\n }\n\n // Only the gated verb can be ambiguous about the mechanism, because it is\n // the one verb that takes both kinds of control. The text and the control\n // must agree: assigning text to a button is nonsense, and clicking a field\n // because no text came with the call is the silent-nothing failure.\n if (verb === names.commit) {\n if (resolved.field && !hasText) {\n return ctx.refuse(\n \"wrong-verb\",\n `\\`${control}\\` is a field: it takes text. Pass \\`text\\`.`,\n );\n }\n if (!resolved.field && hasText) {\n return ctx.refuse(\n \"wrong-verb\",\n `\\`${control}\\` is a button, not a field, so there is nowhere to put text. Call ` +\n `\\`${verb}\\` again without \\`text\\`.`,\n );\n }\n }\n\n const why = refuseWhen(resolved.el, control);\n if (why) {\n return ctx.refuse(\n why,\n `the \\`${control}\\` control is on screen but not actionable right now. Something has to ` +\n `change before it will work — a selection, a required field, a permission.`,\n );\n }\n return null;\n }\n\n /**\n * Put text into a field.\n *\n * Assigning `value` is not typing, and the difference is the failure this\n * library cares most about. A framework learns about a keystroke from an\n * event; a field whose `value` was assigned and nothing else looks right on\n * screen, has told the app nothing, and is wiped by the next render — while\n * the verb reports `ok`. So this fires `input` and `change`, and when it\n * cannot (no `Event`, no `dispatchEvent`) it throws rather than doing the\n * half of the job that looks like all of it.\n */\n function putText(el: FieldLike, control: string, text: string): void {\n if (config.setValue) {\n config.setValue(el, text);\n return;\n }\n const Ev = config.Event ?? defaultEvent();\n if (!Ev || typeof el.dispatchEvent !== \"function\") {\n throw new Error(\n `driverkit: cannot type into \\`${control}\\`: no way to fire an input event ` +\n `(${!Ev ? \"no Event constructor\" : \"the element has no dispatchEvent\"}). Assigning value ` +\n `without an event would look typed and tell your app nothing. Pass options.Event, or ` +\n `options.setValue to put text in your own way.`,\n );\n }\n el.focus?.();\n el.value = text;\n el.dispatchEvent(new Ev(\"input\", { bubbles: true }));\n el.dispatchEvent(new Ev(\"change\", { bubbles: true }));\n }\n\n // ── the verbs ─────────────────────────────────────────────────────────────\n\n const CONTROL_ARG = {\n type: \"string\" as const,\n describe:\n \"the name of a control, exactly as the screen's control list spells it. Not a selector, \" +\n \"not a label, not a guess: a name the screen does not list is refused rather than matched \" +\n \"to the nearest thing.\",\n };\n const ROW_ARG = {\n type: \"string\" as const,\n describe:\n \"the id of the row to act on, for a control the screen lists under `each row`. Use an id \" +\n \"from the rows on screen. Omit it for a control that belongs to the screen itself.\",\n optional: true as const,\n };\n\n const LEGEND =\n \"The screen lists the controls it is offering right now, under `controls` (the screen's own) \" +\n \"and `each row` (one per row, named with `row`). A bare name is a control the app declared \" +\n \"harmless; `(describe)` changes what is selected or filtered; `(commit)` changes data; \" +\n \"`(undeclared)` means the app never said, so it is treated as though it changes data; \" +\n \"`(text)` takes text; `(disabled)` is on screen but not actionable. The list changes as you \" +\n \"navigate, so read it rather than remembering it.\";\n\n const press: Verb<any> = {\n name: names.press,\n kind: \"describe\",\n describe:\n \"use one of the controls the screen is offering: press a button, tick a checkbox, switch \" +\n \"tabs, follow a link. This is the verb for a control the app declared harmless — a bare name \" +\n `or \\`(describe)\\` in the list. A \\`(commit)\\` or \\`(undeclared)\\` control is refused here ` +\n `and goes through \\`${names.commit}\\`; a \\`(text)\\` control through \\`${names.type}\\`. ` +\n \"It presses exactly one control and reports no count. \" +\n LEGEND,\n refuses: [...REFUSES],\n args: { control: CONTROL_ARG, row: ROW_ARG },\n run: ({ control, row }, ctx) => {\n const resolved = resolve(names.press, control, row, ctx);\n if (\"reason\" in resolved) return resolved;\n const refused = gate(names.press, control, false, resolved, ctx);\n if (refused) return refused;\n resolved.el.click();\n },\n };\n\n const typeInto: Verb<any> = {\n name: names.type,\n kind: \"describe\",\n describe:\n \"put text into one of the fields the screen is offering — a search box, a filter, a form \" +\n \"input. Replaces whatever is in it; pass an empty string to clear it. This is the verb for \" +\n `a field the app declared harmless. A \\`(commit)\\` or \\`(undeclared)\\` field is refused ` +\n `here and goes through \\`${names.commit}\\`. ` +\n LEGEND,\n refuses: [...REFUSES],\n args: {\n control: CONTROL_ARG,\n text: {\n type: \"string\",\n describe: \"the text to put in the field. An empty string clears it.\",\n },\n row: ROW_ARG,\n },\n run: ({ control, text, row }, ctx) => {\n const resolved = resolve(names.type, control, row, ctx);\n if (\"reason\" in resolved) return resolved;\n const refused = gate(names.type, control, true, resolved, ctx);\n if (refused) return refused;\n putText(resolved.el as FieldLike, control, text);\n },\n };\n\n const commitControl: Verb<any> = {\n name: names.commit,\n kind: \"commit\",\n describe:\n \"use a control that changes data — or one whose effect the app never declared, which is \" +\n \"treated the same way. One call presses one control, so one irreversible action is one \" +\n \"question to the person watching. Pass `text` for a field. If the control is listed as \" +\n `harmless or \\`(describe)\\`, this refuses and \\`${names.press}\\` or \\`${names.type}\\` is ` +\n \"the verb for it — routing a safe press through here would ask the person a question that \" +\n \"did not need asking, and a gate that asks about everything is a gate nobody reads. \" +\n LEGEND,\n refuses: [...REFUSES],\n args: {\n control: CONTROL_ARG,\n text: {\n type: \"string\",\n describe: \"the text to put in the field, when the control is one that takes text.\",\n optional: true,\n },\n row: ROW_ARG,\n },\n run: ({ control, text, row }, ctx) => {\n const resolved = resolve(names.commit, control, row, ctx);\n if (\"reason\" in resolved) return resolved;\n const hasText = text !== undefined && text !== null;\n const refused = gate(names.commit, control, hasText, resolved, ctx);\n if (refused) return refused;\n if (hasText) putText(resolved.el as FieldLike, control, text as string);\n else resolved.el.click();\n },\n };\n\n const controls = () => enumerate().controls;\n\n const note = () => {\n if (config.inNote === false) return undefined;\n const { controls: list, hidden } = enumerate();\n return render(list, hidden);\n };\n\n return {\n verbs: [press, typeInto, commitControl],\n controls,\n note,\n withControls: <S extends Snapshot>(snapshot: S): S => {\n const { controls: list, hidden } = enumerate();\n const line = config.inNote === false ? undefined : render(list, hidden);\n return {\n ...snapshot,\n ...(list.length ? { controls: list } : {}),\n ...(line ? { note: snapshot.note ? `${snapshot.note}. ${line}` : line } : {}),\n };\n },\n };\n}\n\n/** `disabled` and `aria-disabled` only, read off the author's own markup.\n * Deliberately not a visibility or pointer-events check: those need\n * layout, layout needs a real browser, and a heuristic that is right in\n * Chrome and wrong in a test is worse than a rule the author can read off\n * their own markup. */\nfunction disabledCheck(el: ElementLike): string | null {\n if (el.getAttribute(\"disabled\") !== null) return \"disabled\";\n if (collapse(el.getAttribute(\"aria-disabled\")) === \"true\") return \"disabled\";\n return null;\n}\n\n/** Is this element itself marked? `querySelectorAll` never returns the node it\n * was called on, so a clickable row has to be checked directly. */\nfunction isMarked(el: ElementLike, attribute: string): boolean {\n return collapse(el.getAttribute(attribute)) !== \"\";\n}\n\n/** A label is for recognising a control, not for reading its contents. A cell\n * with a paragraph in it would otherwise put the paragraph in every snapshot. */\nfunction clip(text: string): string {\n return text.length <= 40 ? text : `${text.slice(0, 39)}…`;\n}\n\nconst alreadySaid = new Set<string>();\n\nfunction warner(onWarn?: (m: string) => void): (m: string) => void {\n if (onWarn) return onWarn;\n // Module-scoped: the enumeration runs on every verb call, so a per-binding\n // set would repeat the same line for the life of the page.\n const console = (globalThis as { console?: { warn?: (m: string) => void } }).console;\n return (message: string) => {\n if (alreadySaid.has(message) || !console?.warn) return;\n alreadySaid.add(message);\n console.warn(`driverkit: ${message}`);\n };\n}\n"]}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * driverkit/controls — the browser, as structural types.
3
+ *
4
+ * The controls layer takes its browser globals as options and defaults them to
5
+ * the real ones. That is a design requirement, not a testing convenience, and
6
+ * it is the same argument the page side makes in `driverkit/browser`: code
7
+ * that can only run inside a browser can only be verified inside a browser,
8
+ * which in practice means verified by hand, by someone clicking through the
9
+ * happy path. The parts of this layer that actually bite -- a control that was
10
+ * on screen when the snapshot was taken and gone by the time of the call, a
11
+ * disabled button that accepts a click and does nothing, a confirm button an
12
+ * agent must not reach -- are the parts nobody clicks through.
13
+ *
14
+ * These interfaces describe ONLY what this layer touches. A real `Element`
15
+ * satisfies them; so does the hundred-line fake in `test/fake-dom.ts`. Keeping
16
+ * them this narrow is what makes that second thing possible.
17
+ */
18
+ /** Anything you can run a selector against: a `Document`, an `Element`, or a
19
+ * `DocumentFragment`. Named for what it is used for rather than what it is,
20
+ * because the controls layer does not care which one it was handed. */
21
+ export interface QueryRootLike {
22
+ querySelector(selectors: string): ElementLike | null;
23
+ querySelectorAll(selectors: string): ArrayLike<ElementLike> & Iterable<ElementLike>;
24
+ }
25
+ /**
26
+ * One node.
27
+ *
28
+ * `dataset` is declared and deliberately unused. The controls layer reads
29
+ * `data-dk-*` through `getAttribute` instead, for two reasons: it is one
30
+ * code path rather than two, and `data-dk-col` is the spelling the app author
31
+ * types into their markup. `dataset.dkCol` is a second spelling of the same
32
+ * thing and therefore a second thing to get wrong in a bug report. It stays in
33
+ * the type because a caller writing an `idFrom`/`cellValue` hook gets the
34
+ * element and may reasonably want it.
35
+ */
36
+ export interface ElementLike extends QueryRootLike {
37
+ readonly textContent: string | null;
38
+ getAttribute(name: string): string | null;
39
+ click(): void;
40
+ readonly dataset?: Record<string, string | undefined>;
41
+ /**
42
+ * This element's parent, for the one question that genuinely needs one:
43
+ * is this control inside something marked `data-dk-human-only`?
44
+ *
45
+ * OPTIONAL, AND THAT IS THE WHOLE DESIGN. A real `Element` has it, so a real
46
+ * page gets the ancestor check for free. A fake that does not implement it
47
+ * reads as "no parent", which is exactly the behaviour this package had
48
+ * before the field existed: the element's own attribute and nothing above
49
+ * it. So no existing fake, and no hand-rolled `ElementLike`, is broken by
50
+ * this being here — it only gains.
51
+ *
52
+ * It is deliberately the ONLY upward link in these types, and
53
+ * `controls.ts`'s row test still does not use it. "Is this element inside
54
+ * one of the rows the snapshot is showing" is a containment question with a
55
+ * known set to test against, and answering it by walking up and matching
56
+ * `tr` is a different question that a nested table answers wrongly. An
57
+ * opt-out is the other shape: there is no set to test against, because what
58
+ * carried the mark is whatever the author wrapped around their dialog.
59
+ */
60
+ readonly parentElement?: ElementLike | null;
61
+ }
62
+ /**
63
+ * An element you can put text into.
64
+ *
65
+ * Every member is optional, and that is the honest shape rather than a
66
+ * convenience: the controls layer finds its elements by an attribute the author
67
+ * marked, so it cannot know it was handed an `<input>` until it looks. A real
68
+ * `HTMLInputElement` satisfies this; so does a `<div contenteditable>`, badly,
69
+ * which is why `controls.ts` checks what it got and refuses rather than
70
+ * assuming.
71
+ *
72
+ * `dispatchEvent` is here because setting `value` is not typing. A framework
73
+ * learns about a keystroke from an event, so an adapter that assigns `value`
74
+ * and stops has changed what the screen looks like and told the app nothing —
75
+ * the user's own re-render then wipes it, and the verb reported success.
76
+ */
77
+ export interface FieldLike extends ElementLike {
78
+ value?: string;
79
+ readonly tagName?: string;
80
+ focus?(): void;
81
+ blur?(): void;
82
+ dispatchEvent?(event: unknown): boolean;
83
+ }
84
+ /** `Event`, injectable like every other global here. Only the two-argument
85
+ * constructor is used: `new Event("input", { bubbles: true })`. */
86
+ export interface EventCtor {
87
+ new (type: string, init?: {
88
+ bubbles?: boolean;
89
+ }): unknown;
90
+ }
91
+ /** The default `Event`, or null when there is not one. */
92
+ export declare function defaultEvent(): EventCtor | null;
93
+ /** Collapse every run of whitespace to one space and trim.
94
+ *
95
+ * Exported because it is the normalisation the whole layer applies to text,
96
+ * and a caller writing an `idFrom` hook should be able to apply the same one
97
+ * rather than a near-miss of it. Rendered HTML is full of newlines and indent
98
+ * that are invisible to the person at the keyboard, and a row whose id is
99
+ * `"\n INV-1\n "` matches nothing an agent types back.
100
+ */
101
+ export declare function collapse(text: string | null | undefined): string;
102
+ /** The default document, or null when there is not one. Null rather than a
103
+ * throw: each caller throws its own message naming its own option, which is
104
+ * more use than a shared "no document" from three call sites. */
105
+ export declare function defaultDocument(): QueryRootLike | null;
106
+ /** Resolve a root that may be a selector, an element, or absent. */
107
+ export declare function resolveRoot(root: string | QueryRootLike | undefined, doc: QueryRootLike | undefined, who: string): QueryRootLike;
108
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/controls/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH;;wEAEwE;AACxE,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IACrD,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;CACrF;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC1C,KAAK,IAAI,IAAI,CAAC;IACd,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACtD;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7C;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,IAAI,IAAI,CAAC;IACf,IAAI,CAAC,IAAI,IAAI,CAAC;IACd,aAAa,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CACzC;AAED;oEACoE;AACpE,MAAM,WAAW,SAAS;IACxB,KAAK,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC;CAC3D;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAE/C;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAEhE;AAED;;kEAEkE;AAClE,wBAAgB,eAAe,IAAI,aAAa,GAAG,IAAI,CAEtD;AAED,oEAAoE;AACpE,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,EACxC,GAAG,EAAE,aAAa,GAAG,SAAS,EAC9B,GAAG,EAAE,MAAM,GACV,aAAa,CAWf"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * driverkit/controls — the browser, as structural types.
3
+ *
4
+ * The controls layer takes its browser globals as options and defaults them to
5
+ * the real ones. That is a design requirement, not a testing convenience, and
6
+ * it is the same argument the page side makes in `driverkit/browser`: code
7
+ * that can only run inside a browser can only be verified inside a browser,
8
+ * which in practice means verified by hand, by someone clicking through the
9
+ * happy path. The parts of this layer that actually bite -- a control that was
10
+ * on screen when the snapshot was taken and gone by the time of the call, a
11
+ * disabled button that accepts a click and does nothing, a confirm button an
12
+ * agent must not reach -- are the parts nobody clicks through.
13
+ *
14
+ * These interfaces describe ONLY what this layer touches. A real `Element`
15
+ * satisfies them; so does the hundred-line fake in `test/fake-dom.ts`. Keeping
16
+ * them this narrow is what makes that second thing possible.
17
+ */
18
+ /** The default `Event`, or null when there is not one. */
19
+ export function defaultEvent() {
20
+ return globalThis.Event ?? null;
21
+ }
22
+ /** Collapse every run of whitespace to one space and trim.
23
+ *
24
+ * Exported because it is the normalisation the whole layer applies to text,
25
+ * and a caller writing an `idFrom` hook should be able to apply the same one
26
+ * rather than a near-miss of it. Rendered HTML is full of newlines and indent
27
+ * that are invisible to the person at the keyboard, and a row whose id is
28
+ * `"\n INV-1\n "` matches nothing an agent types back.
29
+ */
30
+ export function collapse(text) {
31
+ return (text ?? "").replace(/\s+/g, " ").trim();
32
+ }
33
+ /** The default document, or null when there is not one. Null rather than a
34
+ * throw: each caller throws its own message naming its own option, which is
35
+ * more use than a shared "no document" from three call sites. */
36
+ export function defaultDocument() {
37
+ return globalThis.document ?? null;
38
+ }
39
+ /** Resolve a root that may be a selector, an element, or absent. */
40
+ export function resolveRoot(root, doc, who) {
41
+ const document = doc ?? defaultDocument();
42
+ if (root === undefined) {
43
+ if (!document)
44
+ throw new Error(`driverkit: ${who} has no document. Pass options.document.`);
45
+ return document;
46
+ }
47
+ if (typeof root !== "string")
48
+ return root;
49
+ if (!document)
50
+ throw new Error(`driverkit: ${who} has no document. Pass options.document.`);
51
+ const found = document.querySelector(root);
52
+ if (!found)
53
+ throw new Error(`driverkit: ${who} found no element matching \`${root}\`.`);
54
+ return found;
55
+ }
56
+ //# sourceMappingURL=dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.js","sourceRoot":"","sources":["../../src/controls/dom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA6EH,0DAA0D;AAC1D,MAAM,UAAU,YAAY;IAC1B,OAAQ,UAAoC,CAAC,KAAK,IAAI,IAAI,CAAC;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,IAA+B;IACtD,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAClD,CAAC;AAED;;kEAEkE;AAClE,MAAM,UAAU,eAAe;IAC7B,OAAQ,UAA2C,CAAC,QAAQ,IAAI,IAAI,CAAC;AACvE,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,WAAW,CACzB,IAAwC,EACxC,GAA8B,EAC9B,GAAW;IAEX,MAAM,QAAQ,GAAG,GAAG,IAAI,eAAe,EAAE,CAAC;IAC1C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,0CAA0C,CAAC,CAAC;QAC5F,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,0CAA0C,CAAC,CAAC;IAC5F,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,GAAG,gCAAgC,IAAI,KAAK,CAAC,CAAC;IACxF,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * driverkit/controls — the browser, as structural types.\n *\n * The controls layer takes its browser globals as options and defaults them to\n * the real ones. That is a design requirement, not a testing convenience, and\n * it is the same argument the page side makes in `driverkit/browser`: code\n * that can only run inside a browser can only be verified inside a browser,\n * which in practice means verified by hand, by someone clicking through the\n * happy path. The parts of this layer that actually bite -- a control that was\n * on screen when the snapshot was taken and gone by the time of the call, a\n * disabled button that accepts a click and does nothing, a confirm button an\n * agent must not reach -- are the parts nobody clicks through.\n *\n * These interfaces describe ONLY what this layer touches. A real `Element`\n * satisfies them; so does the hundred-line fake in `test/fake-dom.ts`. Keeping\n * them this narrow is what makes that second thing possible.\n */\n\n/** Anything you can run a selector against: a `Document`, an `Element`, or a\n * `DocumentFragment`. Named for what it is used for rather than what it is,\n * because the controls layer does not care which one it was handed. */\nexport interface QueryRootLike {\n querySelector(selectors: string): ElementLike | null;\n querySelectorAll(selectors: string): ArrayLike<ElementLike> & Iterable<ElementLike>;\n}\n\n/**\n * One node.\n *\n * `dataset` is declared and deliberately unused. The controls layer reads\n * `data-dk-*` through `getAttribute` instead, for two reasons: it is one\n * code path rather than two, and `data-dk-col` is the spelling the app author\n * types into their markup. `dataset.dkCol` is a second spelling of the same\n * thing and therefore a second thing to get wrong in a bug report. It stays in\n * the type because a caller writing an `idFrom`/`cellValue` hook gets the\n * element and may reasonably want it.\n */\nexport interface ElementLike extends QueryRootLike {\n readonly textContent: string | null;\n getAttribute(name: string): string | null;\n click(): void;\n readonly dataset?: Record<string, string | undefined>;\n /**\n * This element's parent, for the one question that genuinely needs one:\n * is this control inside something marked `data-dk-human-only`?\n *\n * OPTIONAL, AND THAT IS THE WHOLE DESIGN. A real `Element` has it, so a real\n * page gets the ancestor check for free. A fake that does not implement it\n * reads as \"no parent\", which is exactly the behaviour this package had\n * before the field existed: the element's own attribute and nothing above\n * it. So no existing fake, and no hand-rolled `ElementLike`, is broken by\n * this being here — it only gains.\n *\n * It is deliberately the ONLY upward link in these types, and\n * `controls.ts`'s row test still does not use it. \"Is this element inside\n * one of the rows the snapshot is showing\" is a containment question with a\n * known set to test against, and answering it by walking up and matching\n * `tr` is a different question that a nested table answers wrongly. An\n * opt-out is the other shape: there is no set to test against, because what\n * carried the mark is whatever the author wrapped around their dialog.\n */\n readonly parentElement?: ElementLike | null;\n}\n\n/**\n * An element you can put text into.\n *\n * Every member is optional, and that is the honest shape rather than a\n * convenience: the controls layer finds its elements by an attribute the author\n * marked, so it cannot know it was handed an `<input>` until it looks. A real\n * `HTMLInputElement` satisfies this; so does a `<div contenteditable>`, badly,\n * which is why `controls.ts` checks what it got and refuses rather than\n * assuming.\n *\n * `dispatchEvent` is here because setting `value` is not typing. A framework\n * learns about a keystroke from an event, so an adapter that assigns `value`\n * and stops has changed what the screen looks like and told the app nothing —\n * the user's own re-render then wipes it, and the verb reported success.\n */\nexport interface FieldLike extends ElementLike {\n value?: string;\n readonly tagName?: string;\n focus?(): void;\n blur?(): void;\n dispatchEvent?(event: unknown): boolean;\n}\n\n/** `Event`, injectable like every other global here. Only the two-argument\n * constructor is used: `new Event(\"input\", { bubbles: true })`. */\nexport interface EventCtor {\n new (type: string, init?: { bubbles?: boolean }): unknown;\n}\n\n/** The default `Event`, or null when there is not one. */\nexport function defaultEvent(): EventCtor | null {\n return (globalThis as { Event?: EventCtor }).Event ?? null;\n}\n\n/** Collapse every run of whitespace to one space and trim.\n *\n * Exported because it is the normalisation the whole layer applies to text,\n * and a caller writing an `idFrom` hook should be able to apply the same one\n * rather than a near-miss of it. Rendered HTML is full of newlines and indent\n * that are invisible to the person at the keyboard, and a row whose id is\n * `\"\\n INV-1\\n \"` matches nothing an agent types back.\n */\nexport function collapse(text: string | null | undefined): string {\n return (text ?? \"\").replace(/\\s+/g, \" \").trim();\n}\n\n/** The default document, or null when there is not one. Null rather than a\n * throw: each caller throws its own message naming its own option, which is\n * more use than a shared \"no document\" from three call sites. */\nexport function defaultDocument(): QueryRootLike | null {\n return (globalThis as { document?: QueryRootLike }).document ?? null;\n}\n\n/** Resolve a root that may be a selector, an element, or absent. */\nexport function resolveRoot(\n root: string | QueryRootLike | undefined,\n doc: QueryRootLike | undefined,\n who: string,\n): QueryRootLike {\n const document = doc ?? defaultDocument();\n if (root === undefined) {\n if (!document) throw new Error(`driverkit: ${who} has no document. Pass options.document.`);\n return document;\n }\n if (typeof root !== \"string\") return root;\n if (!document) throw new Error(`driverkit: ${who} has no document. Pass options.document.`);\n const found = document.querySelector(root);\n if (!found) throw new Error(`driverkit: ${who} found no element matching \\`${root}\\`.`);\n return found;\n}\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * driverkit/controls — the second layer: whatever is on the screen.
3
+ *
4
+ * A verb list is a set of shortcuts, and shortcuts are incomplete by
5
+ * construction: somebody will always ask for the thing nobody listed. This
6
+ * gives an agent three generic verbs over the elements the app's author marked
7
+ * `data-dk-control`, so that request gets done at all.
8
+ *
9
+ * It is a separate entry point because it is a choice, not a default:
10
+ * importing it is how an app says "publish my marked controls to an agent".
11
+ * An app that only wants its own verbs never resolves this module.
12
+ *
13
+ * See `CONTROLS.md` for the design, the refusals and the honest limits — in
14
+ * particular what `data-dk-kind` claims, what nothing here can check, and the
15
+ * three layers that stop an agent pressing the app's own confirm button.
16
+ */
17
+ export { controlsFromDom } from "./controls.ts";
18
+ export type { ControlsBinding, ControlsConfig, RowsSpec } from "./controls.ts";
19
+ export type { RowIdOptions } from "./rows.ts";
20
+ /** The whitespace normalisation this layer applies to every label and id.
21
+ * Exported so an `idFrom` hook can apply the same one rather than a near-miss
22
+ * of it: rendered HTML is full of indent nobody at the keyboard sees, and a
23
+ * row id of `"\n c-0184\n"` matches nothing an agent types back. */
24
+ export { collapse } from "./dom.ts";
25
+ export type { ElementLike, EventCtor, FieldLike, QueryRootLike } from "./dom.ts";
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/controls/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC/E,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C;;;sEAGsE;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * driverkit/controls — the second layer: whatever is on the screen.
3
+ *
4
+ * A verb list is a set of shortcuts, and shortcuts are incomplete by
5
+ * construction: somebody will always ask for the thing nobody listed. This
6
+ * gives an agent three generic verbs over the elements the app's author marked
7
+ * `data-dk-control`, so that request gets done at all.
8
+ *
9
+ * It is a separate entry point because it is a choice, not a default:
10
+ * importing it is how an app says "publish my marked controls to an agent".
11
+ * An app that only wants its own verbs never resolves this module.
12
+ *
13
+ * See `CONTROLS.md` for the design, the refusals and the honest limits — in
14
+ * particular what `data-dk-kind` claims, what nothing here can check, and the
15
+ * three layers that stop an agent pressing the app's own confirm button.
16
+ */
17
+ export { controlsFromDom } from "./controls.js";
18
+ /** The whitespace normalisation this layer applies to every label and id.
19
+ * Exported so an `idFrom` hook can apply the same one rather than a near-miss
20
+ * of it: rendered HTML is full of indent nobody at the keyboard sees, and a
21
+ * row id of `"\n c-0184\n"` matches nothing an agent types back. */
22
+ export { collapse } from "./dom.js";
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/controls/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD;;;sEAGsE;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC","sourcesContent":["/**\n * driverkit/controls — the second layer: whatever is on the screen.\n *\n * A verb list is a set of shortcuts, and shortcuts are incomplete by\n * construction: somebody will always ask for the thing nobody listed. This\n * gives an agent three generic verbs over the elements the app's author marked\n * `data-dk-control`, so that request gets done at all.\n *\n * It is a separate entry point because it is a choice, not a default:\n * importing it is how an app says \"publish my marked controls to an agent\".\n * An app that only wants its own verbs never resolves this module.\n *\n * See `CONTROLS.md` for the design, the refusals and the honest limits — in\n * particular what `data-dk-kind` claims, what nothing here can check, and the\n * three layers that stop an agent pressing the app's own confirm button.\n */\nexport { controlsFromDom } from \"./controls.ts\";\nexport type { ControlsBinding, ControlsConfig, RowsSpec } from \"./controls.ts\";\nexport type { RowIdOptions } from \"./rows.ts\";\n/** The whitespace normalisation this layer applies to every label and id.\n * Exported so an `idFrom` hook can apply the same one rather than a near-miss\n * of it: rendered HTML is full of indent nobody at the keyboard sees, and a\n * row id of `\"\\n c-0184\\n\"` matches nothing an agent types back. */\nexport { collapse } from \"./dom.ts\";\nexport type { ElementLike, EventCtor, FieldLike, QueryRootLike } from \"./dom.ts\";\n"]}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * driverkit/controls — which rows are on screen, and what each one is called.
3
+ *
4
+ * This is NOT a reader. It produces no `Row`, no cell values, no `page` and
5
+ * nothing that reaches `visible()`; it answers the one question the controls
6
+ * layer cannot avoid asking. A per-row control is addressed by row id, and the
7
+ * id an agent passes back is one it read out of `Snapshot.rows` — so this file
8
+ * has to spell a row's id the way the app's own `visible()` spells it, or a
9
+ * control refuses for a row that is plainly on screen.
10
+ *
11
+ * It is deliberately smaller than the reader that used to answer this.
12
+ * `rowsFromTable` had to guess a whole data shape out of markup — column keys,
13
+ * header slugs, totals, window position — and every one of those was a shape
14
+ * somebody's app did differently. None of it is needed to name a row, so none
15
+ * of it is here. What remains is the id precedence and nothing else:
16
+ *
17
+ * 1. `data-dk-id` on the row element.
18
+ * 2. `data-dk-id` on any cell inside it.
19
+ * 3. `idFrom(row, index)`, for markup you cannot annotate.
20
+ * 4. The first cell's text.
21
+ * 5. `row<n>`, positionally, with a warning.
22
+ *
23
+ * If your rows carry the ids your snapshot reports — and they should, because
24
+ * that is the id an agent will pass back — put them in `data-dk-id` and
25
+ * nothing below step 1 ever runs.
26
+ */
27
+ import type { ElementLike, QueryRootLike } from "./dom.ts";
28
+ /** How a row's id is spelled. Every field is optional, and the defaults suit a
29
+ * plain `<table>`; a row carrying `data-dk-id` needs none of them. */
30
+ export interface RowIdOptions {
31
+ /** Where to look. Defaults to the real `document`; see `dom.ts` on why this
32
+ * is an option at all. */
33
+ document?: QueryRootLike;
34
+ /** Narrow the search before the container selector runs. */
35
+ root?: string | QueryRootLike;
36
+ /** Rows within the container. Default: `tbody tr`, falling back to `tr`
37
+ * minus any row containing a `th`, so a `<tbody>`-less table does not
38
+ * report its own header row as a row. */
39
+ rowSelector?: string;
40
+ /** Cells within a row. Default `td`, falling back to `th, td` for markup
41
+ * that puts the id in a `<th scope="row">`. */
42
+ cellSelector?: string;
43
+ /** Attribute holding a row's id, on the row or on any cell in it.
44
+ * Default `data-dk-id`. */
45
+ idAttribute?: string;
46
+ /** Last resort before positional ids, for generated or third-party markup
47
+ * you cannot add an attribute to. */
48
+ idFrom?: (row: ElementLike, index: number) => string | null;
49
+ /** Diagnostics an app author should see and an agent must never be told.
50
+ * Default: `console.warn` once per distinct message, if there is a console. */
51
+ onWarn?: (message: string) => void;
52
+ }
53
+ /**
54
+ * The row elements of a container, each paired with the id a control accepts
55
+ * for it.
56
+ *
57
+ * Returns `[]` for a container that is not there rather than throwing. Zero
58
+ * row-controls is a claim about this screen's controls, which the screen-level
59
+ * ones answer anyway; it is not a claim about the records, which is the claim
60
+ * that must never be made by accident.
61
+ */
62
+ export declare function rowHandles(selector: string | ElementLike, opts?: RowIdOptions): Array<{
63
+ el: ElementLike;
64
+ id: string;
65
+ }>;
66
+ //# sourceMappingURL=rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/controls/rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3D;uEACuE;AACvE,MAAM,WAAW,YAAY;IAC3B;+BAC2B;IAC3B,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IAC9B;;8CAE0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;oDACgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;gCAC4B;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;0CACsC;IACtC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC5D;oFACgF;IAChF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,MAAM,GAAG,WAAW,EAC9B,IAAI,GAAE,YAAiB,GACtB,KAAK,CAAC;IAAE,EAAE,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAmCxC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * driverkit/controls — which rows are on screen, and what each one is called.
3
+ *
4
+ * This is NOT a reader. It produces no `Row`, no cell values, no `page` and
5
+ * nothing that reaches `visible()`; it answers the one question the controls
6
+ * layer cannot avoid asking. A per-row control is addressed by row id, and the
7
+ * id an agent passes back is one it read out of `Snapshot.rows` — so this file
8
+ * has to spell a row's id the way the app's own `visible()` spells it, or a
9
+ * control refuses for a row that is plainly on screen.
10
+ *
11
+ * It is deliberately smaller than the reader that used to answer this.
12
+ * `rowsFromTable` had to guess a whole data shape out of markup — column keys,
13
+ * header slugs, totals, window position — and every one of those was a shape
14
+ * somebody's app did differently. None of it is needed to name a row, so none
15
+ * of it is here. What remains is the id precedence and nothing else:
16
+ *
17
+ * 1. `data-dk-id` on the row element.
18
+ * 2. `data-dk-id` on any cell inside it.
19
+ * 3. `idFrom(row, index)`, for markup you cannot annotate.
20
+ * 4. The first cell's text.
21
+ * 5. `row<n>`, positionally, with a warning.
22
+ *
23
+ * If your rows carry the ids your snapshot reports — and they should, because
24
+ * that is the id an agent will pass back — put them in `data-dk-id` and
25
+ * nothing below step 1 ever runs.
26
+ */
27
+ import { collapse, resolveRoot } from "./dom.js";
28
+ /**
29
+ * The row elements of a container, each paired with the id a control accepts
30
+ * for it.
31
+ *
32
+ * Returns `[]` for a container that is not there rather than throwing. Zero
33
+ * row-controls is a claim about this screen's controls, which the screen-level
34
+ * ones answer anyway; it is not a claim about the records, which is the claim
35
+ * that must never be made by accident.
36
+ */
37
+ export function rowHandles(selector, opts = {}) {
38
+ const container = find(selector, opts);
39
+ if (!container)
40
+ return [];
41
+ const warn = warner(opts.onWarn);
42
+ const idAttribute = opts.idAttribute ?? "data-dk-id";
43
+ const cellSelector = opts.cellSelector ?? "td";
44
+ const out = [];
45
+ const seen = new Map();
46
+ rowsOf(container, opts.rowSelector).forEach((rowEl, rowIndex) => {
47
+ let cells = [...rowEl.querySelectorAll(cellSelector)];
48
+ if (cells.length === 0 && !opts.cellSelector)
49
+ cells = [...rowEl.querySelectorAll("th, td")];
50
+ if (cells.length === 0)
51
+ return; // a spacer row, or a row of one colspan
52
+ const id = idOf(rowEl, cells, rowIndex, idAttribute, opts, warn);
53
+ const at = seen.get(id);
54
+ if (at !== undefined) {
55
+ // Not renamed. A suffixed id (`c-0184#2`) would be an id no verb in the
56
+ // app accepts, traded for one that at least round-trips. Reported
57
+ // instead: two rows sharing an id means every "that one" acts on
58
+ // whichever is found first, and only the app author can fix it.
59
+ warn(`controls: rows ${at} and ${rowIndex} both have id \`${id}\`. ` +
60
+ `A per-row control named with that id will act on whichever is found first. ` +
61
+ `Set ${idAttribute} on each row.`);
62
+ }
63
+ else {
64
+ seen.set(id, rowIndex);
65
+ }
66
+ out.push({ el: rowEl, id });
67
+ });
68
+ return out;
69
+ }
70
+ function find(selector, opts) {
71
+ if (typeof selector !== "string")
72
+ return selector;
73
+ const root = resolveRoot(opts.root, opts.document, "the controls row scan");
74
+ return root.querySelector(selector);
75
+ }
76
+ /** Rows, with the fallback that keeps a `<tbody>`-less table from reporting its
77
+ * own header row as a row. */
78
+ function rowsOf(container, rowSelector) {
79
+ if (rowSelector)
80
+ return [...container.querySelectorAll(rowSelector)];
81
+ const inBody = [...container.querySelectorAll("tbody tr")];
82
+ if (inBody.length)
83
+ return inBody;
84
+ return [...container.querySelectorAll("tr")].filter((tr) => tr.querySelectorAll("th").length === 0);
85
+ }
86
+ function idOf(rowEl, cells, rowIndex, idAttribute, opts, warn) {
87
+ const onRow = collapse(rowEl.getAttribute(idAttribute));
88
+ if (onRow)
89
+ return onRow;
90
+ for (const cell of cells) {
91
+ const onCell = collapse(cell.getAttribute(idAttribute));
92
+ if (onCell)
93
+ return onCell;
94
+ }
95
+ if (opts.idFrom) {
96
+ const custom = opts.idFrom(rowEl, rowIndex);
97
+ if (custom)
98
+ return custom;
99
+ }
100
+ const first = collapse(cells[0]?.textContent);
101
+ if (first !== "")
102
+ return first;
103
+ // Positional, and loudly. An id that is really a row number is stable only
104
+ // until somebody sorts the table, and a control called with `row3` after a
105
+ // sort acts on a row the agent never saw — the exact failure `rev` exists to
106
+ // prevent, reintroduced one layer down where `rev` cannot see it.
107
+ warn(`controls: row ${rowIndex} has no id, so it is addressed as \`row${rowIndex}\`. ` +
108
+ `Positional ids move when the table is sorted or scrolled. Set ${idAttribute} on the row.`);
109
+ return `row${rowIndex}`;
110
+ }
111
+ /** Default warnings go to the console once each. `visible()` runs on every
112
+ * verb call, so a per-call set would repeat the same line for the life of the
113
+ * page, and a warning that scrolls is a warning nobody reads. */
114
+ const alreadySaid = new Set();
115
+ function warner(onWarn) {
116
+ if (onWarn)
117
+ return onWarn;
118
+ const said = alreadySaid;
119
+ const console = globalThis.console;
120
+ return (message) => {
121
+ if (said.has(message) || !console?.warn)
122
+ return;
123
+ said.add(message);
124
+ console.warn(`driverkit: ${message}`);
125
+ };
126
+ }
127
+ //# sourceMappingURL=rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rows.js","sourceRoot":"","sources":["../../src/controls/rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AA6BjD;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACxB,QAA8B,EAC9B,OAAqB,EAAE;IAEvB,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC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AAQ,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;QACxD,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;IAC5B,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC5C,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;IAC5B,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAC9C,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IAE/B,2EAA2E;IAC3E,2EAA2E;IAC3E,6EAA6E;IAC7E,kEAAkE;IAClE,IAAI,CACF,iBAAiB,QAAQ,0CAA0C,QAAQ,MAAM;QAC/E,iEAAiE,WAAW,cAAc,CAC7F,CAAC;IACF,OAAO,MAAM,QAAQ,EAAE,CAAC;AAC1B,CAAC;AAED;;kEAEkE;AAClE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;AAEtC,SAAS,MAAM,CAAC,MAA4B;IAC1C,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,IAAI,GAAG,WAAW,CAAC;IACzB,MAAM,OAAO,GAAI,UAA2D,CAAC,OAAO,CAAC;IACrF,OAAO,CAAC,OAAe,EAAE,EAAE;QACzB,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI;YAAE,OAAO;QAChD,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClB,OAAO,CAAC,IAAI,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * driverkit/controls — which rows are on screen, and what each one is called.\n *\n * This is NOT a reader. It produces no `Row`, no cell values, no `page` and\n * nothing that reaches `visible()`; it answers the one question the controls\n * layer cannot avoid asking. A per-row control is addressed by row id, and the\n * id an agent passes back is one it read out of `Snapshot.rows` — so this file\n * has to spell a row's id the way the app's own `visible()` spells it, or a\n * control refuses for a row that is plainly on screen.\n *\n * It is deliberately smaller than the reader that used to answer this.\n * `rowsFromTable` had to guess a whole data shape out of markup — column keys,\n * header slugs, totals, window position — and every one of those was a shape\n * somebody's app did differently. None of it is needed to name a row, so none\n * of it is here. What remains is the id precedence and nothing else:\n *\n * 1. `data-dk-id` on the row element.\n * 2. `data-dk-id` on any cell inside it.\n * 3. `idFrom(row, index)`, for markup you cannot annotate.\n * 4. The first cell's text.\n * 5. `row<n>`, positionally, with a warning.\n *\n * If your rows carry the ids your snapshot reports — and they should, because\n * that is the id an agent will pass back — put them in `data-dk-id` and\n * nothing below step 1 ever runs.\n */\n\nimport { collapse, resolveRoot } from \"./dom.ts\";\nimport type { ElementLike, QueryRootLike } from \"./dom.ts\";\n\n/** How a row's id is spelled. Every field is optional, and the defaults suit a\n * plain `<table>`; a row carrying `data-dk-id` needs none of them. */\nexport interface RowIdOptions {\n /** Where to look. Defaults to the real `document`; see `dom.ts` on why this\n * is an option at all. */\n document?: QueryRootLike;\n /** Narrow the search before the container selector runs. */\n root?: string | QueryRootLike;\n /** Rows within the container. Default: `tbody tr`, falling back to `tr`\n * minus any row containing a `th`, so a `<tbody>`-less table does not\n * report its own header row as a row. */\n rowSelector?: string;\n /** Cells within a row. Default `td`, falling back to `th, td` for markup\n * that puts the id in a `<th scope=\"row\">`. */\n cellSelector?: string;\n /** Attribute holding a row's id, on the row or on any cell in it.\n * Default `data-dk-id`. */\n idAttribute?: string;\n /** Last resort before positional ids, for generated or third-party markup\n * you cannot add an attribute to. */\n idFrom?: (row: ElementLike, index: number) => string | null;\n /** Diagnostics an app author should see and an agent must never be told.\n * Default: `console.warn` once per distinct message, if there is a console. */\n onWarn?: (message: string) => void;\n}\n\n/**\n * The row elements of a container, each paired with the id a control accepts\n * for it.\n *\n * Returns `[]` for a container that is not there rather than throwing. Zero\n * row-controls is a claim about this screen's controls, which the screen-level\n * ones answer anyway; it is not a claim about the records, which is the claim\n * that must never be made by accident.\n */\nexport function rowHandles(\n selector: string | ElementLike,\n opts: RowIdOptions = {},\n): Array<{ el: ElementLike; id: string }> {\n const container = find(selector, opts);\n if (!container) return [];\n\n const warn = warner(opts.onWarn);\n const idAttribute = opts.idAttribute ?? \"data-dk-id\";\n const cellSelector = opts.cellSelector ?? \"td\";\n\n const out: Array<{ el: ElementLike; id: string }> = [];\n const seen = new Map<string, number>();\n\n rowsOf(container, opts.rowSelector).forEach((rowEl, rowIndex) => {\n let cells = [...rowEl.querySelectorAll(cellSelector)];\n if (cells.length === 0 && !opts.cellSelector) cells = [...rowEl.querySelectorAll(\"th, td\")];\n if (cells.length === 0) return; // a spacer row, or a row of one colspan\n\n const id = idOf(rowEl, cells, rowIndex, idAttribute, opts, warn);\n const at = seen.get(id);\n if (at !== undefined) {\n // Not renamed. A suffixed id (`c-0184#2`) would be an id no verb in the\n // app accepts, traded for one that at least round-trips. Reported\n // instead: two rows sharing an id means every \"that one\" acts on\n // whichever is found first, and only the app author can fix it.\n warn(\n `controls: rows ${at} and ${rowIndex} both have id \\`${id}\\`. ` +\n `A per-row control named with that id will act on whichever is found first. ` +\n `Set ${idAttribute} on each row.`,\n );\n } else {\n seen.set(id, rowIndex);\n }\n out.push({ el: rowEl, id });\n });\n\n return out;\n}\n\nfunction find(selector: string | ElementLike, opts: RowIdOptions): ElementLike | null {\n if (typeof selector !== \"string\") return selector;\n const root = resolveRoot(opts.root, opts.document, \"the controls row scan\");\n return root.querySelector(selector);\n}\n\n/** Rows, with the fallback that keeps a `<tbody>`-less table from reporting its\n * own header row as a row. */\nfunction rowsOf(container: ElementLike, rowSelector: string | undefined): ElementLike[] {\n if (rowSelector) return [...container.querySelectorAll(rowSelector)];\n const inBody = [...container.querySelectorAll(\"tbody tr\")];\n if (inBody.length) return inBody;\n return [...container.querySelectorAll(\"tr\")].filter(\n (tr) => tr.querySelectorAll(\"th\").length === 0,\n );\n}\n\nfunction idOf(\n rowEl: ElementLike,\n cells: ElementLike[],\n rowIndex: number,\n idAttribute: string,\n opts: RowIdOptions,\n warn: (m: string) => void,\n): string {\n const onRow = collapse(rowEl.getAttribute(idAttribute));\n if (onRow) return onRow;\n for (const cell of cells) {\n const onCell = collapse(cell.getAttribute(idAttribute));\n if (onCell) return onCell;\n }\n if (opts.idFrom) {\n const custom = opts.idFrom(rowEl, rowIndex);\n if (custom) return custom;\n }\n const first = collapse(cells[0]?.textContent);\n if (first !== \"\") return first;\n\n // Positional, and loudly. An id that is really a row number is stable only\n // until somebody sorts the table, and a control called with `row3` after a\n // sort acts on a row the agent never saw — the exact failure `rev` exists to\n // prevent, reintroduced one layer down where `rev` cannot see it.\n warn(\n `controls: row ${rowIndex} has no id, so it is addressed as \\`row${rowIndex}\\`. ` +\n `Positional ids move when the table is sorted or scrolled. Set ${idAttribute} on the row.`,\n );\n return `row${rowIndex}`;\n}\n\n/** Default warnings go to the console once each. `visible()` runs on every\n * verb call, so a per-call set would repeat the same line for the life of the\n * page, and a warning that scrolls is a warning nobody reads. */\nconst alreadySaid = new Set<string>();\n\nfunction warner(onWarn?: (m: string) => void): (m: string) => void {\n if (onWarn) return onWarn;\n const said = alreadySaid;\n const console = (globalThis as { console?: { warn?: (m: string) => void } }).console;\n return (message: string) => {\n if (said.has(message) || !console?.warn) return;\n said.add(message);\n console.warn(`driverkit: ${message}`);\n };\n}\n"]}