deictic 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 (172) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +143 -2
  3. package/dist/annotations/client.d.ts +4 -0
  4. package/dist/annotations/client.d.ts.map +1 -0
  5. package/dist/annotations/client.js +497 -0
  6. package/dist/annotations/client.js.map +1 -0
  7. package/dist/annotations/index.d.ts +110 -0
  8. package/dist/annotations/index.d.ts.map +1 -0
  9. package/dist/annotations/index.js +22 -0
  10. package/dist/annotations/index.js.map +1 -0
  11. package/dist/astro.d.ts +29 -0
  12. package/dist/astro.d.ts.map +1 -0
  13. package/dist/astro.js +24 -0
  14. package/dist/astro.js.map +1 -0
  15. package/dist/bun.d.ts +12 -0
  16. package/dist/bun.d.ts.map +1 -0
  17. package/dist/bun.js +67 -0
  18. package/dist/bun.js.map +1 -0
  19. package/dist/client/index.d.ts +93 -0
  20. package/dist/client/index.d.ts.map +1 -0
  21. package/dist/client/index.js +1329 -0
  22. package/dist/client/index.js.map +1 -0
  23. package/dist/endpoints.js +354 -0
  24. package/dist/endpoints.js.map +1 -0
  25. package/dist/index.d.ts +220 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +10 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/index2.d.ts +23 -0
  30. package/dist/index3.d.ts +98 -0
  31. package/dist/index3.d.ts.map +1 -0
  32. package/dist/index4.d.ts +74 -0
  33. package/dist/index4.d.ts.map +1 -0
  34. package/dist/index5.d.ts +70 -0
  35. package/dist/index5.d.ts.map +1 -0
  36. package/dist/integration.d.ts +19 -0
  37. package/dist/integration.d.ts.map +1 -0
  38. package/dist/integration.js +277 -0
  39. package/dist/integration.js.map +1 -0
  40. package/dist/kept.js +23 -0
  41. package/dist/kept.js.map +1 -0
  42. package/dist/loader.d.ts +15 -0
  43. package/dist/loader.d.ts.map +1 -0
  44. package/dist/loader.js +17 -0
  45. package/dist/loader.js.map +1 -0
  46. package/dist/marks.js +14 -0
  47. package/dist/marks.js.map +1 -0
  48. package/dist/next.d.ts +17 -0
  49. package/dist/next.d.ts.map +1 -0
  50. package/dist/next.js +150 -0
  51. package/dist/next.js.map +1 -0
  52. package/dist/playwright.js +105 -0
  53. package/dist/playwright.js.map +1 -0
  54. package/dist/recommended/index.d.ts +25 -0
  55. package/dist/recommended/index.d.ts.map +1 -0
  56. package/dist/recommended/index.js +19 -0
  57. package/dist/recommended/index.js.map +1 -0
  58. package/dist/recordings/client.d.ts +4 -0
  59. package/dist/recordings/client.d.ts.map +1 -0
  60. package/dist/recordings/client.js +376 -0
  61. package/dist/recordings/client.js.map +1 -0
  62. package/dist/recordings/index.d.ts +2 -0
  63. package/dist/recordings/index.js +3 -0
  64. package/dist/recordings.js +235 -0
  65. package/dist/recordings.js.map +1 -0
  66. package/dist/screenshots/client.d.ts +23 -0
  67. package/dist/screenshots/client.d.ts.map +1 -0
  68. package/dist/screenshots/client.js +76 -0
  69. package/dist/screenshots/client.js.map +1 -0
  70. package/dist/screenshots/dom.d.ts +4 -0
  71. package/dist/screenshots/dom.d.ts.map +1 -0
  72. package/dist/screenshots/dom.js +92 -0
  73. package/dist/screenshots/dom.js.map +1 -0
  74. package/dist/screenshots/index.d.ts +2 -0
  75. package/dist/screenshots/index.js +98 -0
  76. package/dist/screenshots/index.js.map +1 -0
  77. package/dist/screenshots/rrweb.d.ts +9 -0
  78. package/dist/screenshots/rrweb.d.ts.map +1 -0
  79. package/dist/screenshots/rrweb.js +60 -0
  80. package/dist/screenshots/rrweb.js.map +1 -0
  81. package/dist/shortcut.js +63 -0
  82. package/dist/shortcut.js.map +1 -0
  83. package/dist/tailwind/client.d.ts +4 -0
  84. package/dist/tailwind/client.d.ts.map +1 -0
  85. package/dist/tailwind/client.js +613 -0
  86. package/dist/tailwind/client.js.map +1 -0
  87. package/dist/tailwind/index.d.ts +2 -0
  88. package/dist/tailwind/index.js +557 -0
  89. package/dist/tailwind/index.js.map +1 -0
  90. package/dist/tasks/client.d.ts +6 -0
  91. package/dist/tasks/client.d.ts.map +1 -0
  92. package/dist/tasks/client.js +642 -0
  93. package/dist/tasks/client.js.map +1 -0
  94. package/dist/tasks/index.d.ts +159 -0
  95. package/dist/tasks/index.d.ts.map +1 -0
  96. package/dist/tasks/index.js +348 -0
  97. package/dist/tasks/index.js.map +1 -0
  98. package/dist/vite.d.ts +17 -0
  99. package/dist/vite.d.ts.map +1 -0
  100. package/dist/vite.js +44 -0
  101. package/dist/vite.js.map +1 -0
  102. package/dist/voice/client.d.ts +4 -0
  103. package/dist/voice/client.d.ts.map +1 -0
  104. package/dist/voice/client.js +66 -0
  105. package/dist/voice/client.js.map +1 -0
  106. package/dist/voice/index.d.ts +47 -0
  107. package/dist/voice/index.d.ts.map +1 -0
  108. package/dist/voice/index.js +74 -0
  109. package/dist/voice/index.js.map +1 -0
  110. package/dist/waveform.js +93 -0
  111. package/dist/waveform.js.map +1 -0
  112. package/dist/webpack.d.ts +50 -0
  113. package/dist/webpack.d.ts.map +1 -0
  114. package/dist/webpack.js +78 -0
  115. package/dist/webpack.js.map +1 -0
  116. package/package.json +313 -4
  117. package/skills/deictic/SKILL.md +47 -0
  118. package/skills/deictic/references/install.md +81 -0
  119. package/skills/deictic/references/recordings.md +83 -0
  120. package/skills/deictic/references/tasks.md +79 -0
  121. package/skills/deictic/references/watch.md +43 -0
  122. package/skills/deictic/scripts/frame.mjs +62 -0
  123. package/skills/deictic/scripts/lib.mjs +193 -0
  124. package/skills/deictic/scripts/recording.mjs +186 -0
  125. package/skills/deictic/scripts/task.mjs +84 -0
  126. package/skills/deictic/scripts/transcribe.mjs +93 -0
  127. package/skills/deictic/scripts/voice.mjs +50 -0
  128. package/skills/deictic/scripts/watch.mjs +51 -0
  129. package/src/astro.ts +34 -0
  130. package/src/bun.ts +79 -0
  131. package/src/client/index.ts +833 -0
  132. package/src/client/lightbox.ts +256 -0
  133. package/src/client/style.ts +243 -0
  134. package/src/client/tooltip.ts +78 -0
  135. package/src/client/waveform.ts +98 -0
  136. package/src/index.ts +240 -0
  137. package/src/loader.ts +28 -0
  138. package/src/next.ts +133 -0
  139. package/src/plugins/annotations/client.ts +301 -0
  140. package/src/plugins/annotations/draw.ts +169 -0
  141. package/src/plugins/annotations/index.ts +105 -0
  142. package/src/plugins/annotations/svg.ts +61 -0
  143. package/src/plugins/recommended/index.ts +35 -0
  144. package/src/plugins/recordings/client.ts +315 -0
  145. package/src/plugins/recordings/index.ts +174 -0
  146. package/src/plugins/recordings/marks.ts +11 -0
  147. package/src/plugins/recordings/ours.ts +70 -0
  148. package/src/plugins/recordings/replay.ts +139 -0
  149. package/src/plugins/screenshots/client.ts +63 -0
  150. package/src/plugins/screenshots/dom.ts +79 -0
  151. package/src/plugins/screenshots/index.ts +194 -0
  152. package/src/plugins/screenshots/playwright.ts +119 -0
  153. package/src/plugins/screenshots/rrweb.ts +45 -0
  154. package/src/plugins/tailwind/catalog.ts +396 -0
  155. package/src/plugins/tailwind/client.ts +669 -0
  156. package/src/plugins/tailwind/index.ts +267 -0
  157. package/src/plugins/tasks/client.ts +622 -0
  158. package/src/plugins/tasks/index.ts +513 -0
  159. package/src/plugins/voice/client.ts +57 -0
  160. package/src/plugins/voice/index.ts +114 -0
  161. package/src/shortcut.ts +83 -0
  162. package/src/tools/astro.ts +81 -0
  163. package/src/tools/editor.ts +22 -0
  164. package/src/tools/endpoints.ts +163 -0
  165. package/src/tools/history.ts +203 -0
  166. package/src/tools/integration.ts +106 -0
  167. package/src/tools/kept.ts +21 -0
  168. package/src/tools/locate.ts +94 -0
  169. package/src/tools/plugins.ts +41 -0
  170. package/src/tools/source.ts +72 -0
  171. package/src/vite.ts +62 -0
  172. package/src/webpack.ts +107 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/plugins/screenshots/index.ts"],"sourcesContent":["/**\n * `deictic/screenshots`: a plugin with no panel, for others to build on. In the page,\n * `use('screenshots').capture(element)` takes what the viewport shows (or the element alone), with\n * nothing of deictic's in it, and says where the element is; on the server, `use('screenshots').read(id)`\n * hands the PNG to another plugin, which the tasks plugin attaches to a task.\n *\n * How a shot is made is its renderer's: `rrweb()` by default, which snapshots the page's DOM and renders it\n * in a browser beside the dev server, so text lays out as the page's does; or `dom()`, which draws the page\n * in the page itself, for a target with no server to render on. A renderer is a page module and, where it\n * renders elsewhere, a `render` here (`Renderer`): another may take pixels from screen sharing or devtools.\n *\n * Shots are kept under `.deictic/screenshots`, the latest `keep` of them, so they outlive a\n * restart of the dev server and stay out of git.\n */\nimport { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\n\nimport { definePlugin } from '#src/index.ts';\nimport { keptIn } from '#src/tools/kept.ts';\n\n/** A rectangle in CSS pixels, from the shot's top left. */\nexport interface Box {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** A shot as the page knows it: its ID, where the dev server serves its PNG, and where the element is in it. */\nexport interface Shot {\n id: string;\n url: string;\n /** The element, in the shot: nothing marks it there, as nothing of deictic's is drawn. */\n box: Box;\n /** The shot's size in CSS pixels; its PNG may have more, on a high-density screen. */\n size: { width: number; height: number };\n}\n\nexport interface CaptureOptions {\n /** `viewport`, what the page shows, by default; or `element`, the element alone. */\n area?: 'viewport' | 'element';\n}\n\n/** The page's half, for other plugins' page halves. */\nexport interface Capture {\n capture(element: Element, options?: CaptureOptions): Promise<Shot>;\n /** Keeps a PNG made of a shot (the same one with marks drawn over it, say) as a shot of its own. */\n upload(png: Blob, of: Pick<Shot, 'box' | 'size'>): Promise<Shot>;\n}\n\n/** The server's half, for other plugins' server halves. */\nexport interface Screenshots {\n /** A shot's PNG, or nothing for one not kept (any more). */\n read(id: string): { data: Uint8Array<ArrayBuffer>; name: string; type: 'image/png' } | undefined;\n}\n\ndeclare module 'deictic' {\n interface ServerApis {\n screenshots: Screenshots;\n }\n interface ClientApis {\n screenshots: Capture;\n }\n}\n\n/**\n * What a shot hides, as rrweb names it and by its defaults, so one marking in the app hides the same\n * things from a screenshot as from an rrweb recording or snapshot.\n */\nexport interface Masking {\n /** Elements drawn as a blank box their size: `rr-block` by default. */\n blockClass?: string;\n blockSelector?: string;\n /** Elements whose text is drawn as `*`: `rr-mask` by default. */\n maskTextClass?: string;\n maskTextSelector?: string;\n /** Every field's value as `*`, not only passwords': false by default. */\n maskAllInputs?: boolean;\n}\n\n/** Masking with its defaults, as a renderer's page half gets it. */\nexport type ResolvedMasking = Required<Pick<Masking, 'blockClass' | 'maskTextClass' | 'maskAllInputs'>> & Masking;\n\n/**\n * How shots are made. `client` is the page module that captures, default-exporting `screenshotsClient(…)`\n * from `deictic/screenshots/client`. A page half that sends a PNG needs nothing here; one that sends\n * something else, as JSON (a DOM snapshot), needs `render` to make the PNG of it.\n */\nexport interface Renderer {\n client: string;\n /** What the page half gets, besides the masking. */\n clientOptions?: unknown;\n render?(input: unknown): Promise<Uint8Array>;\n}\n\n/** Where `rrweb()` finds a browser: any Chromium renders the snapshot as the page's own would. */\nexport interface BrowserOptions {\n /** A Chromium-based browser's executable. */\n executablePath?: string;\n /** An installed browser by Playwright's name: `chrome`, `msedge`. By default Playwright's own Chromium, then Chrome, then Edge. */\n channel?: string;\n}\n\n/** Draws the page in the page, from its DOM (`modern-screenshot`): no server needed, but text may lay out a little differently. */\nexport const dom = (): Renderer => ({ client: 'deictic/screenshots/dom' });\n\n/**\n * Snapshots the page's DOM in the page (`rrweb-snapshot`, masking as rrweb does) and renders it in a\n * browser beside the dev server (`playwright-core`), so text lays out as the page's does.\n */\nexport const rrweb = (options: BrowserOptions = {}): Renderer => ({\n client: 'deictic/screenshots/rrweb',\n // Loaded on the first shot, so a project rendering in the page needn't install Playwright.\n render: async (input) => (await import('./playwright.ts')).render(input, options),\n});\n\nexport interface ScreenshotsOptions extends Masking {\n /** How shots are made: `rrweb()` by default, or `dom()` where there's no server to render on. */\n renderer?: Renderer;\n /** How many shots to keep, the latest: 100 by default. */\n keep?: number;\n /** Where they're kept, from the project's root: `.deictic/screenshots` by default. */\n dir?: string;\n}\n\nconst ID = /^[a-z0-9]+-[a-z0-9]+$/;\n/** What one PNG, or one snapshot to render, may weigh: a viewport at twice its pixels is a few MB. */\nconst MAX = 20 * 1024 * 1024;\n\nexport function screenshots(options: ScreenshotsOptions = {}) {\n const renderer = options.renderer ?? rrweb();\n const keep = options.keep ?? 100;\n let dir = '';\n let taken = 0;\n const pathOf = (id: string) => join(dir, `${id}.png`);\n const read: Screenshots['read'] = (id) => {\n if (!ID.test(id) || !existsSync(pathOf(id))) return undefined;\n return { data: new Uint8Array(readFileSync(pathOf(id))), name: `${id}.png`, type: 'image/png' };\n };\n const keepShot = (data: Uint8Array) => {\n // Sorts by when it was taken, which is what pruning keeps by: the count orders two in one millisecond.\n const id = `${Date.now().toString(36).padStart(9, '0')}${(taken++ % 1296).toString(36).padStart(2, '0')}-${crypto.randomUUID().slice(0, 8)}`;\n mkdirSync(dir, { recursive: true });\n writeFileSync(pathOf(id), data);\n const kept = readdirSync(dir)\n .filter((f) => f.endsWith('.png'))\n .toSorted();\n for (const old of kept.slice(0, Math.max(0, kept.length - keep))) rmSync(join(dir, old));\n return id;\n };\n\n return definePlugin<never, never, never, Screenshots>({\n name: 'screenshots',\n client: renderer.client,\n clientOptions: {\n masking: {\n blockClass: options.blockClass ?? 'rr-block',\n blockSelector: options.blockSelector,\n maskTextClass: options.maskTextClass ?? 'rr-mask',\n maskTextSelector: options.maskTextSelector,\n maskAllInputs: options.maskAllInputs ?? false,\n } satisfies ResolvedMasking,\n renderer: renderer.clientOptions,\n },\n setup: ({ root }) => {\n dir = options.dir === undefined ? keptIn(root, 'screenshots') : resolve(root, options.dir);\n return { read };\n },\n routes: {\n // A PNG the page made, or what the renderer makes one of.\n add: async (req) => {\n const type = req.headers.get('content-type') ?? '';\n const body = new Uint8Array(await req.arrayBuffer());\n if (body.byteLength > MAX) return Response.json({ problem: `a shot may weigh ${MAX / 1024 / 1024} MB at most` }, { status: 413 });\n if (type === 'image/png') return Response.json({ id: keepShot(body) });\n if (renderer.render === undefined || !type.startsWith('application/json'))\n return Response.json({ problem: 'send the shot as image/png' }, { status: 415 });\n try {\n return Response.json({ id: keepShot(await renderer.render(JSON.parse(new TextDecoder().decode(body)))) });\n } catch (e) {\n return Response.json({ problem: e instanceof Error ? e.message : String(e) }, { status: 500 });\n }\n },\n // `shot/<id>`: the PNG, for a panel to show.\n shot: (req) => {\n const shot = read(new URL(req.url).pathname.split('/').at(-1) ?? '');\n if (shot === undefined) return new Response('no such shot, or not kept any more', { status: 404 });\n return new Response(shot.data, { headers: { 'content-type': shot.type, 'cache-control': 'no-store' } });\n },\n },\n });\n}\n\nexport default screenshots;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwGA,MAAa,aAAuB,EAAE,QAAQ,0BAA0B;;;;;AAMxE,MAAa,SAAS,UAA0B,CAAC,OAAiB;CAChE,QAAQ;CAER,QAAQ,OAAO,WAAW,MAAM,OAAO,oBAAA,CAAoB,OAAO,OAAO,OAAO;AAClF;AAWA,MAAM,KAAK;;AAEX,MAAM,MAAM;AAEZ,SAAgB,YAAY,UAA8B,CAAC,GAAG;CAC5D,MAAM,WAAW,QAAQ,YAAY,MAAM;CAC3C,MAAM,OAAO,QAAQ,QAAQ;CAC7B,IAAI,MAAM;CACV,IAAI,QAAQ;CACZ,MAAM,UAAU,OAAe,KAAK,KAAK,GAAG,GAAG,KAAK;CACpD,MAAM,QAA6B,OAAO;EACxC,IAAI,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,WAAW,OAAO,EAAE,CAAC,GAAG,OAAO,KAAA;EACpD,OAAO;GAAE,MAAM,IAAI,WAAW,aAAa,OAAO,EAAE,CAAC,CAAC;GAAG,MAAM,GAAG,GAAG;GAAO,MAAM;EAAY;CAChG;CACA,MAAM,YAAY,SAAqB;EAErC,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CA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tE,OAAO,SAAS,KAAK,EAAE,SAAS,6BAA6B,GAAG,EAAE,QAAQ,IAAI,CAAC;IACjF,IAAI;KACF,OAAO,SAAS,KAAK,EAAE,IAAI,SAAS,MAAM,SAAS,OAAO,KAAK,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1G,SAAS,GAAG;KACV,OAAO,SAAS,KAAK,EAAE,SAAS,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,EAAE,GAAG,EAAE,QAAQ,IAAI,CAAC;IAC/F;GACF;GAEA,OAAO,QAAQ;IACb,MAAM,OAAO,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE;IACnE,IAAI,SAAS,KAAA,GAAW,OAAO,IAAI,SAAS,sCAAsC,EAAE,QAAQ,IAAI,CAAC;IACjG,OAAO,IAAI,SAAS,KAAK,MAAM,EAAE,SAAS;KAAE,gBAAgB,KAAK;KAAM,iBAAiB;IAAW,EAAE,CAAC;GACxG;EACF;CACF,CAAC;AACH"}
@@ -0,0 +1,9 @@
1
+ import { r as Capture } from "../index3.js";
2
+ /**
3
+ * The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported on the
4
+ * first shot), masked as rrweb masks, without deictic's overlay, sent with what the server's browser needs
5
+ * to show it as the page does: the viewport, where it's scrolled to, the pixel density, the page's URL.
6
+ */
7
+ declare const _default: import("deictic").ClientPlugin<never, never, Capture>;
8
+ export { _default as default };
9
+ //# sourceMappingURL=rrweb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rrweb.d.ts","names":["_$__index_ts0.Capture"],"sources":["../../src/plugins/screenshots/rrweb.ts"],"mappings":";;;;;;cAgBA,4B,2BAAAA"}
@@ -0,0 +1,60 @@
1
+ import { boxOf, screenshotsClient } from "./client.js";
2
+ // src/plugins/screenshots/rrweb.ts
3
+ /**
4
+ * The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported on the
5
+ * first shot), masked as rrweb masks, without deictic's overlay, sent with what the server's browser needs
6
+ * to show it as the page does: the viewport, where it's scrolled to, the pixel density, the page's URL.
7
+ */
8
+ /** The snapshot without deictic's overlay, which rrweb has no option to leave out. */
9
+ function withoutOurs(node) {
10
+ if (!("childNodes" in node)) return node;
11
+ const childNodes = node.childNodes.filter((c) => !("tagName" in c && c.tagName === "deictic-overlay")).map(withoutOurs);
12
+ return {
13
+ ...node,
14
+ childNodes
15
+ };
16
+ }
17
+ var rrweb_default = screenshotsClient(async (element, { area, masking, overlay }) => {
18
+ const { snapshot } = await import("rrweb-snapshot").catch((e) => {
19
+ throw new Error("the rrweb() renderer needs rrweb-snapshot: add it to your devDependencies", { cause: e });
20
+ });
21
+ const taken = snapshot(document, {
22
+ inlineStylesheet: true,
23
+ blockClass: masking.blockClass,
24
+ blockSelector: masking.blockSelector ?? null,
25
+ maskTextClass: masking.maskTextClass,
26
+ maskTextSelector: masking.maskTextSelector ?? null,
27
+ maskAllInputs: masking.maskAllInputs
28
+ });
29
+ if (taken === null) throw new Error("screenshots: rrweb took no snapshot of this page");
30
+ const box = boxOf(element, area);
31
+ const viewport = {
32
+ width: document.documentElement.clientWidth,
33
+ height: document.documentElement.clientHeight
34
+ };
35
+ const marks = overlay({
36
+ x: 0,
37
+ y: 0,
38
+ ...viewport
39
+ });
40
+ const body = {
41
+ snapshot: withoutOurs(taken),
42
+ url: location.href,
43
+ viewport,
44
+ ...marks === void 0 ? {} : { overlay: marks },
45
+ scroll: {
46
+ x: scrollX,
47
+ y: scrollY
48
+ },
49
+ scale: Math.min(devicePixelRatio, 2),
50
+ ...area === "element" ? { clip: element.getBoundingClientRect().toJSON() } : {}
51
+ };
52
+ return {
53
+ body: JSON.stringify(body),
54
+ type: "application/json",
55
+ box
56
+ };
57
+ });
58
+ export { rrweb_default as default };
59
+
60
+ //# sourceMappingURL=rrweb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rrweb.js","names":[],"sources":["../../src/plugins/screenshots/rrweb.ts"],"sourcesContent":["/**\n * The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported on the\n * first shot), masked as rrweb masks, without deictic's overlay, sent with what the server's browser needs\n * to show it as the page does: the viewport, where it's scrolled to, the pixel density, the page's URL.\n */\n\nimport { boxOf, screenshotsClient } from './client.ts';\nimport type { Snapshot, SnapshotNode } from './playwright.ts';\n\n/** The snapshot without deictic's overlay, which rrweb has no option to leave out. */\nfunction withoutOurs(node: SnapshotNode): SnapshotNode {\n if (!('childNodes' in node)) return node;\n const childNodes = node.childNodes.filter((c: SnapshotNode) => !('tagName' in c && c.tagName === 'deictic-overlay')).map(withoutOurs);\n return { ...node, childNodes };\n}\n\nexport default screenshotsClient(async (element, { area, masking, overlay }) => {\n const { snapshot } = await import('rrweb-snapshot').catch((e: unknown) => {\n throw new Error('the rrweb() renderer needs rrweb-snapshot: add it to your devDependencies', { cause: e });\n });\n const taken = snapshot(document, {\n inlineStylesheet: true,\n blockClass: masking.blockClass,\n blockSelector: masking.blockSelector ?? null,\n maskTextClass: masking.maskTextClass,\n maskTextSelector: masking.maskTextSelector ?? null,\n maskAllInputs: masking.maskAllInputs,\n });\n if (taken === null) throw new Error('screenshots: rrweb took no snapshot of this page');\n const box = boxOf(element, area);\n const viewport = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };\n // Over the viewport, which the server renders before cutting out an element's part.\n const marks = overlay({ x: 0, y: 0, ...viewport });\n const body: Snapshot = {\n snapshot: withoutOurs(taken),\n url: location.href,\n viewport,\n ...(marks === undefined ? {} : { overlay: marks }),\n scroll: { x: scrollX, y: scrollY },\n scale: Math.min(devicePixelRatio, 2),\n // A shot of the element alone is the part of the viewport it fills.\n ...(area === 'element' ? { clip: element.getBoundingClientRect().toJSON() as Snapshot['clip'] } : {}),\n };\n return { body: JSON.stringify(body), type: 'application/json', box };\n});\n"],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-0,0 +1,63 @@
1
+ // src/shortcut.ts
2
+ const FLAGS = {
3
+ Alt: "altKey",
4
+ Control: "ctrlKey",
5
+ Meta: "metaKey",
6
+ Shift: "shiftKey"
7
+ };
8
+ const BUTTONS = {
9
+ left: 0,
10
+ middle: 1,
11
+ right: 2
12
+ };
13
+ /** deictic's own shortcut, unless `deictic({ shortcut })` names another or `false`. */
14
+ const MASTER = {
15
+ modifiers: ["Alt"],
16
+ button: "left"
17
+ };
18
+ /** The name deictic's own shortcut goes by in a problem. */
19
+ const OWN = "deictic";
20
+ /** deictic's own shortcut as given, with its default, before it's checked. */
21
+ const ownShortcut = (given) => given === false ? void 0 : given ?? MASTER;
22
+ /** The shortcut with its button's default and its modifiers in one order, or an error saying what to write instead. */
23
+ function checkShortcut(plugin, shortcut) {
24
+ const { modifiers = [], button = "left" } = shortcut;
25
+ const named = Object.keys(FLAGS).join("', '");
26
+ if (!Array.isArray(modifiers) || modifiers.length === 0) throw new Error(`deictic: ${plugin}'s shortcut.modifiers is empty: hold at least one of '${named}', or every click would open the popup`);
27
+ for (const m of modifiers) if (!Object.hasOwn(FLAGS, m)) throw new Error(`deictic: ${plugin}'s shortcut.modifiers has '${m}': name one of '${named}'`);
28
+ if (!Object.hasOwn(BUTTONS, button)) throw new Error(`deictic: ${plugin}'s shortcut.button is '${button}': name one of '${Object.keys(BUTTONS).join("', '")}'`);
29
+ const order = Object.keys(FLAGS);
30
+ return {
31
+ modifiers: [...new Set(modifiers)].toSorted((a, b) => order.indexOf(a) - order.indexOf(b)),
32
+ button
33
+ };
34
+ }
35
+ /**
36
+ * Each shortcut checked, in order, or nothing where there's none: none may be another's, or only the
37
+ * first would ever open. deictic's own goes first, named `OWN`.
38
+ */
39
+ function checkShortcuts(plugins) {
40
+ const taken = /* @__PURE__ */ new Map();
41
+ return plugins.map(({ name, shortcut }) => {
42
+ if (shortcut === void 0) return void 0;
43
+ const checked = checkShortcut(name, shortcut);
44
+ const key = nameOf(checked);
45
+ const other = taken.get(key);
46
+ if (other !== void 0) throw new Error(`deictic: ${name} and ${other} both open on ${key}: give one of them another \`shortcut\``);
47
+ taken.set(key, name);
48
+ return checked;
49
+ });
50
+ }
51
+ /** How a shortcut reads, for a problem or a label: `Alt+Shift`, `Control+right-click`. */
52
+ const nameOf = ({ modifiers = [], button = "left" }) => [...modifiers, ...button === "left" ? [] : [`${button}-click`]].join("+");
53
+ function gestureOf(shortcut) {
54
+ const on = new Set(shortcut.modifiers);
55
+ const flags = Object.entries(FLAGS);
56
+ return {
57
+ held: (e) => flags.every(([key, flag]) => e[flag] === on.has(key)),
58
+ button: BUTTONS[shortcut.button]
59
+ };
60
+ }
61
+ export { ownShortcut as i, checkShortcuts as n, gestureOf as r, OWN as t };
62
+
63
+ //# sourceMappingURL=shortcut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcut.js","names":[],"sources":["../src/shortcut.ts"],"sourcesContent":["/**\n * A gesture: the keys held to outline the element under the pointer, and the button that, with them\n * held, opens the popup there. deictic's own (`MASTER` by default) opens the tab used last; a\n * plugin's, which it takes as its `shortcut` option and has none by default, opens its tab. The\n * bundler's plugin checks them all as it starts, so a wrong one, or two alike, fails the dev server,\n * not the page. Both halves import it: it must\n * stay dependency-free.\n */\n\n/** A modifier key, as `KeyboardEvent.key` names it. */\nexport type Modifier = 'Alt' | 'Control' | 'Meta' | 'Shift';\n\nexport interface Shortcut {\n /** Held, and no other, to outline elements. */\n modifiers?: Modifier[];\n /** Pressed with them to open the panel. `'left'` unset. */\n button?: 'left' | 'middle' | 'right';\n}\n\nconst FLAGS = { Alt: 'altKey', Control: 'ctrlKey', Meta: 'metaKey', Shift: 'shiftKey' } as const;\nconst BUTTONS = { left: 0, middle: 1, right: 2 } as const;\n\n/** deictic's own shortcut, unless `deictic({ shortcut })` names another or `false`. */\nexport const MASTER: Required<Shortcut> = { modifiers: ['Alt'], button: 'left' };\n\n/** The name deictic's own shortcut goes by in a problem. */\nexport const OWN = 'deictic';\n\n/** deictic's own shortcut as given, with its default, before it's checked. */\nexport const ownShortcut = (given: Shortcut | false | undefined) => (given === false ? undefined : (given ?? MASTER));\n\n/** The shortcut with its button's default and its modifiers in one order, or an error saying what to write instead. */\nexport function checkShortcut(plugin: string, shortcut: Shortcut): Required<Shortcut> {\n const { modifiers = [], button = 'left' } = shortcut;\n const named = Object.keys(FLAGS).join(\"', '\");\n if (!Array.isArray(modifiers) || modifiers.length === 0) {\n throw new Error(\n `deictic: ${plugin}'s shortcut.modifiers is empty: hold at least one of '${named}', or every click would open the popup`,\n );\n }\n for (const m of modifiers)\n if (!Object.hasOwn(FLAGS, m)) throw new Error(`deictic: ${plugin}'s shortcut.modifiers has '${m}': name one of '${named}'`);\n\n if (!Object.hasOwn(BUTTONS, button))\n throw new Error(`deictic: ${plugin}'s shortcut.button is '${button}': name one of '${Object.keys(BUTTONS).join(\"', '\")}'`);\n\n const order = Object.keys(FLAGS);\n return { modifiers: [...new Set(modifiers)].toSorted((a, b) => order.indexOf(a) - order.indexOf(b)), button };\n}\n\n/**\n * Each shortcut checked, in order, or nothing where there's none: none may be another's, or only the\n * first would ever open. deictic's own goes first, named `OWN`.\n */\nexport function checkShortcuts(plugins: readonly { name: string; shortcut?: Shortcut }[]): (Required<Shortcut> | undefined)[] {\n const taken = new Map<string, string>();\n return plugins.map(({ name, shortcut }) => {\n if (shortcut === undefined) return undefined;\n const checked = checkShortcut(name, shortcut);\n const key = nameOf(checked);\n const other = taken.get(key);\n if (other !== undefined) throw new Error(`deictic: ${name} and ${other} both open on ${key}: give one of them another \\`shortcut\\``);\n taken.set(key, name);\n return checked;\n });\n}\n\n/** How a shortcut reads, for a problem or a label: `Alt+Shift`, `Control+right-click`. */\nexport const nameOf = ({ modifiers = [], button = 'left' }: Shortcut) =>\n [...modifiers, ...(button === 'left' ? [] : [`${button}-click`])].join('+');\n\nexport interface Gesture {\n /** Whether exactly the shortcut's modifiers are down: AltGr, which is Control and Alt, isn't Alt. */\n held: (e: MouseEvent | KeyboardEvent) => boolean;\n /** The shortcut's button, as `MouseEvent.button` numbers it. */\n button: number;\n}\n\nexport function gestureOf(shortcut: Required<Shortcut>): Gesture {\n const on = new Set<string>(shortcut.modifiers);\n const flags = Object.entries(FLAGS);\n return { held: (e) => flags.every(([key, flag]) => e[flag] === on.has(key)), button: BUTTONS[shortcut.button] };\n}\n"],"mappings":";AAmBA,MAAM,QAAQ;CAAE,KAAK;CAAU,SAAS;CAAW,MAAM;CAAW,OAAO;AAAW;AACtF,MAAM,UAAU;CAAE,MAAM;CAAG,QAAQ;CAAG,OAAO;AAAE;;AAG/C,MAAa,SAA6B;CAAE,WAAW,CAAC,KAAK;CAAG,QAAQ;AAAO;;AAG/E,MAAa,MAAM;;AAGnB,MAAa,eAAe,UAAyC,UAAU,QAAQ,KAAA,IAAa,SAAS;;AAG7G,SAAgB,cAAc,QAAgB,UAAwC;CACpF,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,WAAW;CAC5C,MAAM,QAAQ,OAAO,KAAK,KAAK,CAAC,CAAC,KAAK,MAAM;CAC5C,IAAI,CAAC,MAAM,QAAQ,SAAS,KAAK,UAAU,WAAW,GACpD,MAAM,IAAI,MACR,YAAY,OAAO,wDAAwD,MAAM,uCACnF;CAEF,KAAK,MAAM,KAAK,WACd,IAAI,CAAC,OAAO,OAAO,OAAO,CAAC,GAAG,MAAM,IAAI,MAAM,YAAY,OAAO,6BAA6B,EAAE,kBAAkB,MAAM,EAAE;CAE5H,IAAI,CAAC,OAAO,OAAO,SAAS,MAAM,GAChC,MAAM,IAAI,MAAM,YAAY,OAAO,yBAAyB,OAAO,kBAAkB,OAAO,KAAK,OAAO,CAAC,CAAC,KAAK,MAAM,EAAE,EAAE;CAE3H,MAAM,QAAQ,OAAO,KAAK,KAAK;CAC/B,OAAO;EAAE,WAAW,CAAC,GAAG,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG,MAAM,MAAM,QAAQ,CAAC,IAAI,MAAM,QAAQ,CAAC,CAAC;EAAG;CAAO;AAC9G;;;;;AAMA,SAAgB,eAAe,SAA+F;CAC5H,MAAM,wBAAQ,IAAI,IAAoB;CACtC,OAAO,QAAQ,KAAK,EAAE,MAAM,eAAe;EACzC,IAAI,aAAa,KAAA,GAAW,OAAO,KAAA;EACnC,MAAM,UAAU,cAAc,MAAM,QAAQ;EAC5C,MAAM,MAAM,OAAO,OAAO;EAC1B,MAAM,QAAQ,MAAM,IAAI,GAAG;EAC3B,IAAI,UAAU,KAAA,GAAW,MAAM,IAAI,MAAM,YAAY,KAAK,OAAO,MAAM,gBAAgB,IAAI,wCAAwC;EACnI,MAAM,IAAI,KAAK,IAAI;EACnB,OAAO;CACT,CAAC;AACH;;AAGA,MAAa,UAAU,EAAE,YAAY,CAAC,GAAG,SAAS,aAChD,CAAC,GAAG,WAAW,GAAI,WAAW,SAAS,CAAC,IAAI,CAAC,GAAG,OAAO,OAAO,CAAE,CAAC,CAAC,KAAK,GAAG;AAS5E,SAAgB,UAAU,UAAuC;CAC/D,MAAM,KAAK,IAAI,IAAY,SAAS,SAAS;CAC7C,MAAM,QAAQ,OAAO,QAAQ,KAAK;CAClC,OAAO;EAAE,OAAO,MAAM,MAAM,OAAO,CAAC,KAAK,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,CAAC;EAAG,QAAQ,QAAQ,SAAS;CAAQ;AAChH"}
@@ -0,0 +1,4 @@
1
+ import { n as Model, r as Op } from "../index5.js";
2
+ declare const _default: import("deictic").ClientPlugin<Model, Op, unknown>;
3
+ export { _default as default };
4
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/plugins/tailwind/client.ts"],"mappings":";cA+HA,4B"}