deictic 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API.md +303 -0
- package/README.md +56 -127
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +117 -7
- package/dist/client/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/logs/client.d.ts +4 -0
- package/dist/logs/client.d.ts.map +1 -0
- package/dist/logs/client.js +16 -0
- package/dist/logs/client.js.map +1 -0
- package/dist/logs/index.d.ts +18 -0
- package/dist/logs/index.d.ts.map +1 -0
- package/dist/logs/index.js +21 -0
- package/dist/logs/index.js.map +1 -0
- package/dist/network/client.d.ts +4 -0
- package/dist/network/client.d.ts.map +1 -0
- package/dist/network/client.js +29 -0
- package/dist/network/client.js.map +1 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.js +39 -0
- package/dist/network/index.js.map +1 -0
- package/dist/recommended/index.d.ts +13 -3
- package/dist/recommended/index.d.ts.map +1 -1
- package/dist/recommended/index.js +8 -1
- package/dist/recommended/index.js.map +1 -1
- package/dist/recordings/client.d.ts +1 -1
- package/dist/recordings/client.d.ts.map +1 -1
- package/dist/recordings/client.js +175 -46
- package/dist/recordings/client.js.map +1 -1
- package/dist/recordings/index.d.ts +2 -2
- package/dist/screenshots/client.d.ts +6 -0
- package/dist/screenshots/client.d.ts.map +1 -1
- package/dist/screenshots/client.js +34 -2
- package/dist/screenshots/client.js.map +1 -1
- package/dist/screenshots/dom.d.ts.map +1 -1
- package/dist/screenshots/dom.js +1 -28
- package/dist/screenshots/dom.js.map +1 -1
- package/dist/screenshots/index.js.map +1 -1
- package/dist/screenshots/rrweb.d.ts +1 -1
- package/dist/screenshots/rrweb.js +5 -1
- package/dist/screenshots/rrweb.js.map +1 -1
- package/dist/shared/index.d.ts +14 -2
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index2.d.ts +2 -0
- package/dist/shared/index2.d.ts.map +1 -1
- package/dist/shared/index3.d.ts +29 -3
- package/dist/shared/index3.d.ts.map +1 -1
- package/dist/shared/index4.d.ts +52 -172
- package/dist/shared/index4.d.ts.map +1 -1
- package/dist/shared/index5.d.ts +208 -58
- package/dist/shared/index5.d.ts.map +1 -1
- package/dist/shared/index6.d.ts +70 -0
- package/dist/shared/index6.d.ts.map +1 -0
- package/dist/shared/marks.js +6 -1
- package/dist/shared/marks.js.map +1 -1
- package/dist/shared/mask.js +107 -0
- package/dist/shared/mask.js.map +1 -0
- package/dist/shared/playwright.js +19 -4
- package/dist/shared/playwright.js.map +1 -1
- package/dist/shared/recordings.js +219 -28
- package/dist/shared/recordings.js.map +1 -1
- package/dist/shared/tasks.js +145 -34
- package/dist/shared/tasks.js.map +1 -1
- package/dist/tailwind/client.d.ts +1 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tasks/client.d.ts +1 -1
- package/dist/tasks/client.d.ts.map +1 -1
- package/dist/tasks/client.js +271 -56
- package/dist/tasks/client.js.map +1 -1
- package/dist/tasks/index.d.ts +2 -2
- package/dist/voice/client.d.ts.map +1 -1
- package/dist/voice/client.js +35 -14
- package/dist/voice/client.js.map +1 -1
- package/dist/voice/index.d.ts +6 -1
- package/dist/voice/index.d.ts.map +1 -1
- package/dist/voice/index.js +12 -2
- package/dist/voice/index.js.map +1 -1
- package/package.json +41 -2
- package/skills/deictic/SKILL.md +20 -14
- package/skills/deictic/references/install.md +18 -11
- package/skills/deictic/references/recordings.md +29 -0
- package/skills/deictic/references/tasks.md +49 -21
- package/skills/deictic/references/watch.md +38 -11
- package/skills/deictic/scripts/lib.mjs +69 -3
- package/skills/deictic/scripts/recording.mjs +84 -4
- package/skills/deictic/scripts/task.mjs +36 -7
- package/skills/deictic/scripts/vb.mjs +12 -0
- package/skills/deictic/scripts/watch.mjs +74 -10
- package/src/client/away.ts +105 -0
- package/src/client/index.ts +40 -9
- package/src/client/style.ts +1 -0
- package/src/index.ts +14 -2
- package/src/plugins/logs/client.ts +18 -0
- package/src/plugins/logs/index.ts +55 -0
- package/src/plugins/network/client.ts +30 -0
- package/src/plugins/network/index.ts +69 -0
- package/src/plugins/network/mask.ts +133 -0
- package/src/plugins/recommended/index.ts +14 -1
- package/src/plugins/recordings/client.ts +219 -40
- package/src/plugins/recordings/index.ts +108 -23
- package/src/plugins/recordings/marks.ts +6 -0
- package/src/plugins/recordings/replay.ts +127 -4
- package/src/plugins/screenshots/client.ts +35 -0
- package/src/plugins/screenshots/dom.ts +1 -32
- package/src/plugins/screenshots/index.ts +2 -0
- package/src/plugins/screenshots/playwright.ts +15 -4
- package/src/plugins/screenshots/rrweb.ts +2 -1
- package/src/plugins/tasks/client.ts +273 -41
- package/src/plugins/tasks/index.ts +155 -39
- package/src/plugins/tasks/watchers.ts +36 -0
- package/src/plugins/voice/client.ts +33 -11
- package/src/plugins/voice/index.ts +21 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","names":[],"sources":["../../src/plugins/screenshots/dom.ts"],"sourcesContent":["/**\n * The `dom()` renderer's page half: draws the page in the page from its DOM with `modern-screenshot`\n * (imported on the first shot), so it needs no server, but text may lay out a little differently than\n * the page's. Masking changes only the copy that's drawn, never the page.\n */\nimport { boxOf, notOurs, screenshotsClient } from './client.ts';\
|
|
1
|
+
{"version":3,"file":"dom.js","names":[],"sources":["../../src/plugins/screenshots/dom.ts"],"sourcesContent":["/**\n * The `dom()` renderer's page half: draws the page in the page from its DOM with `modern-screenshot`\n * (imported on the first shot), so it needs no server, but text may lay out a little differently than\n * the page's. Masking changes only the copy that's drawn, never the page.\n */\nimport { boxOf, mask, notOurs, screenshotsClient } from './client.ts';\n\n/** Draws an SVG over the whole canvas, which is the area it was made for at the canvas's scale. */\nasync function drawOver(canvas: HTMLCanvasElement, svg: string | undefined): Promise<HTMLCanvasElement> {\n if (svg === undefined) return canvas;\n const image = new Image();\n image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n await image.decode();\n canvas.getContext('2d')?.drawImage(image, 0, 0, canvas.width, canvas.height);\n return canvas;\n}\n\nexport default screenshotsClient(async (element, { area, masking, overlay }) => {\n const { domToCanvas } = await import('modern-screenshot').catch((e: unknown) => {\n throw new Error('the dom() renderer needs modern-screenshot: add it to your devDependencies', { cause: e });\n });\n // Sharp on a high-density screen, without drawing a long page at more than twice its size.\n const scale = Math.min(devicePixelRatio, 2);\n const options = { filter: notOurs, scale, onCloneNode: (copy: Node) => mask(copy, masking) };\n const box = boxOf(element, area);\n const toPng = (canvas: HTMLCanvasElement) =>\n new Promise<Blob>((done, fail) =>\n canvas.toBlob((blob) => (blob === null ? fail(new Error('screenshots: the page drew nothing')) : done(blob)), 'image/png'),\n );\n if (area === 'element') {\n const { x, y, width, height } = element.getBoundingClientRect();\n const shot = await drawOver(await domToCanvas(element, options), overlay({ x, y, width, height }));\n return { body: await toPng(shot), type: 'image/png', box };\n }\n\n // The whole document, then the part the viewport shows: the document's box is where it scrolled to.\n const page = await domToCanvas(document.documentElement, options);\n const { clientWidth: width, clientHeight: height } = document.documentElement;\n const at = document.documentElement.getBoundingClientRect();\n const canvas = document.createElement('canvas');\n canvas.width = width * scale;\n canvas.height = height * scale;\n const ctx = canvas.getContext('2d');\n if (ctx === null) throw new Error(\"screenshots: this browser won't draw to a canvas\");\n ctx.drawImage(page, -at.left * scale, -at.top * scale, canvas.width, canvas.height, 0, 0, canvas.width, canvas.height);\n await drawOver(canvas, overlay({ x: 0, y: 0, width, height }));\n return { body: await toPng(canvas), type: 'image/png', box };\n});\n"],"mappings":";;;;;;;;AAQA,eAAe,SAAS,QAA2B,KAAqD;CACtG,IAAI,QAAQ,KAAA,GAAW,OAAO;CAC9B,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,MAAM,oCAAoC,mBAAmB,GAAG;CACtE,MAAM,MAAM,OAAO;CACnB,OAAO,WAAW,IAAI,CAAC,EAAE,UAAU,OAAO,GAAG,GAAG,OAAO,OAAO,OAAO,MAAM;CAC3E,OAAO;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,QAAQ,QAAQ;EAAE,GAAG;EAAG,GAAG;EAAG;EAAO;CAAO,CAAC,CAAC;CAC7D,OAAO;EAAE,MAAM,MAAM,MAAM,MAAM;EAAG,MAAM;EAAa;CAAI;AAC7D,CAAC"}
|
|
@@ -1 +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,2BAAA,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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,IAAI,WAAW,MAAM,IAAI,YAAY,CAAC;IACnD,IAAI,KAAK,aAAa,KAAK,OAAO,SAAS,KAAK,EAAE,SAAS,oBAAoB,MAAM,OAAO,KAAK,aAAa,GAAG,EAAE,QAAQ,IAAI,CAAC;IAChI,IAAI,SAAS,aAAa,OAAO,SAAS,KAAK,EAAE,IAAI,SAAS,IAAI,EAAE,CAAC;IACrE,IAAI,SAAS,WAAW,KAAA,KAAa,CAAC,KAAK,WAAW,kBAAkB,GACtE,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"}
|
|
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 /** A copy of an element with what a shot hides hidden in it too: for a plugin that sends its HTML somewhere. */\n masked(element: Element): Element;\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":";;;;;;;;;;;;;;;;;;;;AA0GA,MAAa,aAAuB,EAAE,QAAQ,0BAA0B;;;;;AAMxE,MAAa,SAAS,UAA0B,CAAC,OAAiB;CAChE,QAAQ;CAER,QAAQ,OAAO,WAAW,MAAM,OAAO,2BAAA,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,CAAC,SAAS,GAAG,GAAG,KA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AE,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"}
|
|
@@ -2,7 +2,7 @@ import { r as Capture } from "../shared/index2.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported on the
|
|
4
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.
|
|
5
|
+
* to show it as the page does: the viewport and the window around it, where it's scrolled to, the pixel density, the page's URL.
|
|
6
6
|
*/
|
|
7
7
|
declare const _default: import("deictic").ClientPlugin<never, never, Capture>;
|
|
8
8
|
export { _default as default };
|
|
@@ -3,7 +3,7 @@ import { boxOf, screenshotsClient } from "./client.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* The `rrweb()` renderer's page half: a snapshot of the page's DOM with `rrweb-snapshot` (imported on the
|
|
5
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.
|
|
6
|
+
* to show it as the page does: the viewport and the window around it, where it's scrolled to, the pixel density, the page's URL.
|
|
7
7
|
*/
|
|
8
8
|
/** The snapshot without deictic's overlay, which rrweb has no option to leave out. */
|
|
9
9
|
function withoutOurs(node) {
|
|
@@ -41,6 +41,10 @@ var rrweb_default = screenshotsClient(async (element, { area, masking, overlay }
|
|
|
41
41
|
snapshot: withoutOurs(taken),
|
|
42
42
|
url: location.href,
|
|
43
43
|
viewport,
|
|
44
|
+
window: {
|
|
45
|
+
width: innerWidth,
|
|
46
|
+
height: innerHeight
|
|
47
|
+
},
|
|
44
48
|
...marks === void 0 ? {} : { overlay: marks },
|
|
45
49
|
scroll: {
|
|
46
50
|
x: scrollX,
|
|
@@ -1 +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"],"mappings":";;;;;;;;AAUA,SAAS,YAAY,MAAkC;CACrD,IAAI,EAAE,gBAAgB,OAAO,OAAO;CACpC,MAAM,aAAa,KAAK,WAAW,QAAQ,MAAoB,EAAE,aAAa,KAAK,EAAE,YAAY,kBAAkB,CAAC,CAAC,IAAI,WAAW;CACpI,OAAO;EAAE,GAAG;EAAM;CAAW;AAC/B;AAEA,IAAA,gBAAe,kBAAkB,OAAO,SAAS,EAAE,MAAM,SAAS,cAAc;CAC9E,MAAM,EAAE,aAAa,MAAM,OAAO,iBAAiB,CAAC,OAAO,MAAe;EACxE,MAAM,IAAI,MAAM,6EAA6E,EAAE,OAAO,EAAE,CAAC;CAC3G,CAAC;CACD,MAAM,QAAQ,SAAS,UAAU;EAC/B,kBAAkB;EAClB,YAAY,QAAQ;EACpB,eAAe,QAAQ,iBAAiB;EACxC,eAAe,QAAQ;EACvB,kBAAkB,QAAQ,oBAAoB;EAC9C,eAAe,QAAQ;CACzB,CAAC;CACD,IAAI,UAAU,MAAM,MAAM,IAAI,MAAM,kDAAkD;CACtF,MAAM,MAAM,MAAM,SAAS,IAAI;CAC/B,MAAM,WAAW;EAAE,OAAO,SAAS,gBAAgB;EAAa,QAAQ,SAAS,gBAAgB;CAAa;CAE9G,MAAM,QAAQ,QAAQ;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;CAAS,CAAC;CACjD,MAAM,OAAiB;EACrB,UAAU,YAAY,KAAK;EAC3B,KAAK,SAAS;EACd;EACA,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,MAAM;EAChD,QAAQ;GAAE,GAAG;GAAS,GAAG;EAAQ;EACjC,OAAO,KAAK,IAAI,kBAAkB,CAAC;EAEnC,GAAI,SAAS,YAAY,EAAE,MAAM,QAAQ,sBAAsB,CAAC,CAAC,OAAO,EAAsB,IAAI,CAAC;CACrG;CACA,OAAO;EAAE,MAAM,KAAK,UAAU,IAAI;EAAG,MAAM;EAAoB;CAAI;AACrE,CAAC"}
|
|
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 and the window around it, 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 window: { width: innerWidth, height: innerHeight },\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"],"mappings":";;;;;;;;AAUA,SAAS,YAAY,MAAkC;CACrD,IAAI,EAAE,gBAAgB,OAAO,OAAO;CACpC,MAAM,aAAa,KAAK,WAAW,QAAQ,MAAoB,EAAE,aAAa,KAAK,EAAE,YAAY,kBAAkB,CAAC,CAAC,IAAI,WAAW;CACpI,OAAO;EAAE,GAAG;EAAM;CAAW;AAC/B;AAEA,IAAA,gBAAe,kBAAkB,OAAO,SAAS,EAAE,MAAM,SAAS,cAAc;CAC9E,MAAM,EAAE,aAAa,MAAM,OAAO,iBAAiB,CAAC,OAAO,MAAe;EACxE,MAAM,IAAI,MAAM,6EAA6E,EAAE,OAAO,EAAE,CAAC;CAC3G,CAAC;CACD,MAAM,QAAQ,SAAS,UAAU;EAC/B,kBAAkB;EAClB,YAAY,QAAQ;EACpB,eAAe,QAAQ,iBAAiB;EACxC,eAAe,QAAQ;EACvB,kBAAkB,QAAQ,oBAAoB;EAC9C,eAAe,QAAQ;CACzB,CAAC;CACD,IAAI,UAAU,MAAM,MAAM,IAAI,MAAM,kDAAkD;CACtF,MAAM,MAAM,MAAM,SAAS,IAAI;CAC/B,MAAM,WAAW;EAAE,OAAO,SAAS,gBAAgB;EAAa,QAAQ,SAAS,gBAAgB;CAAa;CAE9G,MAAM,QAAQ,QAAQ;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;CAAS,CAAC;CACjD,MAAM,OAAiB;EACrB,UAAU,YAAY,KAAK;EAC3B,KAAK,SAAS;EACd;EACA,QAAQ;GAAE,OAAO;GAAY,QAAQ;EAAY;EACjD,GAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS,MAAM;EAChD,QAAQ;GAAE,GAAG;GAAS,GAAG;EAAQ;EACjC,OAAO,KAAK,IAAI,kBAAkB,CAAC;EAEnC,GAAI,SAAS,YAAY,EAAE,MAAM,QAAQ,sBAAsB,CAAC,CAAC,OAAO,EAAsB,IAAI,CAAC;CACrG;CACA,OAAO;EAAE,MAAM,KAAK,UAAU,IAAI;EAAG,MAAM;EAAoB;CAAI;AACrE,CAAC"}
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -171,7 +171,11 @@ interface LightboxOptions {
|
|
|
171
171
|
from?: Element;
|
|
172
172
|
}
|
|
173
173
|
interface PanelContext<Model, Op> extends ClientContext {
|
|
174
|
-
/**
|
|
174
|
+
/**
|
|
175
|
+
* The element clicked: the one the source marked, under the pointer or around what is. Back from `away`
|
|
176
|
+
* it may be off the page (`isConnected` is false), where the page moved on without it: the element as it
|
|
177
|
+
* was left, or after a page load an empty one of its tag and mark. `elements` is then empty.
|
|
178
|
+
*/
|
|
175
179
|
element: Element;
|
|
176
180
|
/**
|
|
177
181
|
* What was under the pointer, where it isn't `element` but inside it: markup nothing marked, as a
|
|
@@ -195,7 +199,9 @@ interface PanelContext<Model, Op> extends ClientContext {
|
|
|
195
199
|
* Leaves the popup to do something on the page, then comes back: closes it, runs `task` (a recording, a
|
|
196
200
|
* pick of another element), and opens it again at this tab on this element. The next mount gets
|
|
197
201
|
* `resumed`: the `state` kept now (what was typed, what's attached), and what `task` answered, or why
|
|
198
|
-
* it failed. The state stays in the page, as it is: no need for JSON.
|
|
202
|
+
* it failed. The state stays in the page, as it is: no need for JSON. It's also kept for the tab's next
|
|
203
|
+
* page, as a structured clone, where it can be one: after a page load, the plugin's `resume` says whether
|
|
204
|
+
* the task carries on, and the popup comes back there.
|
|
199
205
|
*/
|
|
200
206
|
away: <T>(state: unknown, task: () => Promise<T>) => void;
|
|
201
207
|
/** Set when this mount is the panel coming back from `away`. */
|
|
@@ -218,6 +224,12 @@ interface ClientPlugin<Model = unknown, Op = unknown, Api = unknown> {
|
|
|
218
224
|
* plugin's API to the others in the page, at once: one that needs time keeps its promises inside it.
|
|
219
225
|
*/
|
|
220
226
|
setup?(context: ClientContext): Api;
|
|
227
|
+
/**
|
|
228
|
+
* Asked as a page starts where the page before it left this plugin's panel `away`: the task it left for,
|
|
229
|
+
* where that carries on in this page (a recording does), or nothing where it ended with the page. When it's
|
|
230
|
+
* done the popup opens at this tab with `resumed`, on the element where this page has it and without where not.
|
|
231
|
+
*/
|
|
232
|
+
resume?(context: ClientContext): Promise<unknown> | undefined;
|
|
221
233
|
/** Draws into `panel`, inside deictic's shadow root. Returns what to undo on the page when the panel closes. */
|
|
222
234
|
mount?: (panel: HTMLElement, context: PanelContext<Model, Op>) => (() => void) | void;
|
|
223
235
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/shortcut.ts","../../src/index.ts"],"mappings":";;;;;;;;;;KAUY;UAEK;;EAEf,YAAY;;EAEZ;;;UCYe;EACf;EACA;EACA;;;UAIe;EACf,KAAK;EACL;;;UAIe;EACf;EACA;EACA;EACA;;;UAIe;;EAEf;EACA;;EAEA,SAAS;;EAET,SAAS;;EAET,KAAK;;;;;;;KAQK,cAAc,SAAS,YAAY,WAAW,QAAQ;;cAGrD,gBAAgB;EAClB;;;;;;UAOM,KAAK;EACpB,MAAM;;KAGH,MAAM,KAAK,IAAI,QAAQ;;;;;UAOX;;UAIA;;KAG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;EACvB;;;;;;EAMA,UAAU,QAAQ;;;;;;;;;EASlB,OAAO,GAAG,gBAAgB,YAAY,QAAQ;;EAE9C,UAAU;;;UAIK;EACf;EACA;;EAEA;;UAGe,aAAa,iBAAiB,cAAc;;EAE3D;;EAEA;;;;;EAKA,OAAO,SAAS,gBAAgB;;;;;;EAMhC,QAAQ,SAAS,gBAAgB;;EAEjC,SAAS,OAAO,aAAa,SAAS,aAAa,OAAO;;cAG/C,qBAAsB,OAAO,IAAI,eAAa,QAAU,aAAa,OAAO,IAAI,SAAO,aAAa,OAAO,IAAI"}
|
package/dist/shared/index2.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ interface Capture {
|
|
|
26
26
|
capture(element: Element, options?: CaptureOptions): Promise<Shot>;
|
|
27
27
|
/** Keeps a PNG made of a shot (the same one with marks drawn over it, say) as a shot of its own. */
|
|
28
28
|
upload(png: Blob, of: Pick<Shot, 'box' | 'size'>): Promise<Shot>;
|
|
29
|
+
/** A copy of an element with what a shot hides hidden in it too: for a plugin that sends its HTML somewhere. */
|
|
30
|
+
masked(element: Element): Element;
|
|
29
31
|
}
|
|
30
32
|
/** The server's half, for other plugins' server halves. */
|
|
31
33
|
interface Screenshots {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/plugins/screenshots/index.ts"],"mappings":";UAqBiB;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;;EAEA,KAAK;;EAEL;IAAQ;IAAe;;;UAGR;;EAEf;;;UAIe;EACf,QAAQ,SAAS,SAAS,UAAU,iBAAiB,QAAQ;;EAE7D,OAAO,KAAK,MAAM,IAAI,KAAK,wBAAwB,QAAQ;;;
|
|
1
|
+
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/plugins/screenshots/index.ts"],"mappings":";UAqBiB;EACf;EACA;EACA;EACA;;;UAIe;EACf;EACA;;EAEA,KAAK;;EAEL;IAAQ;IAAe;;;UAGR;;EAEf;;;UAIe;EACf,QAAQ,SAAS,SAAS,UAAU,iBAAiB,QAAQ;;EAE7D,OAAO,KAAK,MAAM,IAAI,KAAK,wBAAwB,QAAQ;;EAE3D,OAAO,SAAS,UAAU;;;UAIX;;EAEf,KAAK;IAAe,MAAM,WAAW;IAAc;IAAc;;;;YAIvD;IACR,aAAa;;YAEL;IACR,aAAa;;;;;;;UAQA;;EAEf;EACA;;EAEA;EACA;;EAEA;;;KAIU,kBAAkB,SAAS,KAAK,8DAA8D;;;;;;UAOzF;EACf;;EAEA;EACA,QAAQ,iBAAiB,QAAQ;;;UAIlB;;EAEf;;EAEA;;;cAIW,WAAU;;;;;cAMV,QAAK,UAAa,mBAAsB;UAMpC,2BAA2B;;EAE1C,WAAW;;EAEX;;EAEA;;iBAOc,YAAY,UAAS,uCAAuB,kCAAA"}
|
package/dist/shared/index3.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { record } from "rrweb";
|
|
1
2
|
import { a as Masking } from "./index2.js";
|
|
2
3
|
/**
|
|
3
4
|
* The custom event's tag the marks go in: the page's annotations, as an SVG in page coordinates (`svg`),
|
|
@@ -34,11 +35,26 @@ interface VoiceClip {
|
|
|
34
35
|
interface Recorder {
|
|
35
36
|
/**
|
|
36
37
|
* Records the page, with the toolbar, until Stop: answers the recording, kept by the dev server, or
|
|
37
|
-
* nothing when it's discarded. Rejects while another is going, or when it couldn't be kept.
|
|
38
|
+
* nothing when it's discarded. Rejects while another is going, or when it couldn't be kept. A page load
|
|
39
|
+
* doesn't end it: the next page of the site carries on, and `going` there answers what this would have.
|
|
38
40
|
*/
|
|
39
41
|
record(): Promise<Recording | undefined>;
|
|
40
42
|
/** Whether one is going. */
|
|
41
43
|
recording(): boolean;
|
|
44
|
+
/** The one going, as `record` answers it: also one a page before this started, carried on here. */
|
|
45
|
+
going(): Promise<Recording | undefined> | undefined;
|
|
46
|
+
}
|
|
47
|
+
/** A plugin of rrweb's own, as its `record` takes them: what puts more than the page in a recording. */
|
|
48
|
+
type RecordPlugin = NonNullable<NonNullable<Parameters<typeof record>[0]>['plugins']>[number];
|
|
49
|
+
/**
|
|
50
|
+
* What a plugin that adds to recordings answers in the page, under its name (`logs` and `network` do): the
|
|
51
|
+
* recorder asks each it knows for its rrweb plugin as a recording starts, so nothing listens before, or after it stops.
|
|
52
|
+
*/
|
|
53
|
+
interface Recorded {
|
|
54
|
+
/** `sinceLoad`: the recording was going as this page loaded, so what the page did before now is its too. */
|
|
55
|
+
plugin(from: {
|
|
56
|
+
sinceLoad: boolean;
|
|
57
|
+
}): Promise<RecordPlugin>;
|
|
42
58
|
}
|
|
43
59
|
/** The server's half, for other plugins' server halves. */
|
|
44
60
|
interface Recordings {
|
|
@@ -49,8 +65,11 @@ interface Recordings {
|
|
|
49
65
|
type: 'application/json';
|
|
50
66
|
} | undefined;
|
|
51
67
|
}
|
|
52
|
-
/** What
|
|
68
|
+
/** What a recording says as it begins: all of a `Kept` that's known then. */
|
|
69
|
+
type Meta = Omit<Kept, 'events' | 'duration' | 'voice'>;
|
|
70
|
+
/** What's kept: rrweb's events and what they can't say. */
|
|
53
71
|
interface Kept {
|
|
72
|
+
/** The page it started on. One that went on to others has each in its events, as rrweb's own: a `Meta`, then a snapshot. */
|
|
54
73
|
page: string;
|
|
55
74
|
viewport: {
|
|
56
75
|
width: number;
|
|
@@ -80,7 +99,14 @@ interface RecordingsOptions extends Masking {
|
|
|
80
99
|
keep?: number;
|
|
81
100
|
/** Where they're kept, from the project's root: `.deictic/recordings` by default. */
|
|
82
101
|
dir?: string;
|
|
102
|
+
/**
|
|
103
|
+
* What a `<canvas>` draws (a chart, a map, WebGL), which is no part of the page's markup: a picture of each
|
|
104
|
+
* canvas that changed, `fps` times a second, 2 by default. `false` for none, and a canvas replays blank.
|
|
105
|
+
*/
|
|
106
|
+
canvas?: boolean | {
|
|
107
|
+
fps?: number;
|
|
108
|
+
};
|
|
83
109
|
}
|
|
84
110
|
declare function recordings(options?: RecordingsOptions): import("deictic").ServerPlugin<never, never, never, Recordings>;
|
|
85
|
-
export {
|
|
111
|
+
export { Recorder as a, RecordingsOptions as c, ReplaySources as d, replayPage as f, Recorded as i, VoiceClip as l, Meta as n, Recording as o, MARKS as p, RecordPlugin as r, Recordings as s, Kept as t, recordings as u };
|
|
86
112
|
//# sourceMappingURL=index3.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index3.d.ts","names":[],"sources":["../../src/plugins/recordings/marks.ts","../../src/plugins/recordings/replay.ts","../../src/plugins/recordings/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index3.d.ts","names":[],"sources":["../../src/plugins/recordings/marks.ts","../../src/plugins/recordings/replay.ts","../../src/plugins/recordings/index.ts"],"mappings":";;;;;;cAIa;;UCyBI;;EAEf;;;;;EAKA;;;cAIW,eAAU,QAAA,WAA+B;;UCXrC;EACf;EACA;EACA;;EAEA,QAAQ;;;UAIO;EACf;EACA;EACA;;;UAIe;;;;;;EAMf,UAAU,QAAQ;;EAElB;;EAEA,SAAS,QAAQ;;;KAIP,eAAe,YAAY,YAAY,kBAAkB;;;;;UAMpD;;EAEf,OAAO;IAAQ;MAAuB,QAAQ;;;UAI/B;;EAEf,KAAK;IAAe,MAAM,WAAW;IAAc;IAAc;;;;KAIvD,OAAO,KAAK;;UAGP;;EAEf;EACA;IAAY;IAAe;;;;;;EAK3B;EACA;EACA;EACA;;EAEA,QAAQ;;;YAIE;IACR,YAAY;;YAEJ;IACR,YAAY;;;UAIC,0BAA0B;;EAEzC;;EAEA;;;;;EAKA;IAAqB;;;iBAmBP,WAAW,UAAS,sCAAsB,kCAAA"}
|
package/dist/shared/index4.d.ts
CHANGED
|
@@ -1,184 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { w as Shortcut, y as Target } from "./index.js";
|
|
3
|
-
import { t as Box } from "./index2.js";
|
|
4
|
-
interface LocalOptions {
|
|
5
|
-
/**
|
|
6
|
-
* The port it listens on, on 127.0.0.1. By default 4100, or a free one where that's taken. One named here is
|
|
7
|
-
* the only one tried: taken, the board doesn't start.
|
|
8
|
-
*/
|
|
9
|
-
port?: number;
|
|
10
|
-
/** Where its log is kept, from the project's root: `.deictic/board` by default. */
|
|
11
|
-
dir?: string;
|
|
12
|
-
/** `false` for no pages of the board's own (its inspector): the panel then links its tasks nowhere. */
|
|
13
|
-
inspect?: boolean;
|
|
14
|
-
/** More arguments for `vb serve`, as it takes them: `['--tailscale', 'box.tailnet.ts.net']`. */
|
|
15
|
-
args?: string[];
|
|
16
|
-
}
|
|
17
|
-
/** What `local()` answers, for the tasks plugin's `board` option. */
|
|
18
|
-
interface LocalBoard {
|
|
19
|
-
local: LocalOptions;
|
|
20
|
-
}
|
|
1
|
+
import { i as Recorded } from "./index3.js";
|
|
21
2
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
3
|
+
* What a request is kept as: with what it carries that's a secret blanked, wherever a name says so. The
|
|
4
|
+
* names are all there is to go by, so a secret under a name that says nothing (a token in a path, a password in
|
|
5
|
+
* prose) isn't found: bodies and headers are kept only where asked for, and `ignore` leaves a request out whole.
|
|
24
6
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* `http://127.0.0.1:4100/api/board` (or the port `.deictic/board.json` says, where that one's taken), its log
|
|
33
|
-
* in `.deictic/board`. For your team's board, through `vercel login`, pass `board()`. `local()`, from here, is
|
|
34
|
-
* that board of the project's own whatever `BOARD_URL` says, with its port, its folder and the rest as options.
|
|
35
|
-
*/
|
|
36
|
-
board?: TaskBoard | LocalBoard;
|
|
37
|
-
/** The channel tasks go to: `deictic` by default. */
|
|
38
|
-
channel?: string;
|
|
39
|
-
/**
|
|
40
|
-
* The project the tasks are about, as the `deictic.project` label, to tell them apart on a board several
|
|
41
|
-
* projects share: by default the `name` in the root's `package.json`, and no label where it has none.
|
|
42
|
-
*/
|
|
43
|
-
project?: string;
|
|
44
|
-
/** Labels every task gets besides deictic's own, for whoever works them to filter by (`vb tail --label`). None by default. */
|
|
45
|
-
labels?: Record<string, string>;
|
|
46
|
-
/**
|
|
47
|
-
* Where the panel links the channel to, for a person to see its tasks, and with `task`, where it links
|
|
48
|
-
* that task's ID to. By default the board's own pages when it's one `vb serve` runs on this machine
|
|
49
|
-
* (`http://127.0.0.1:4100/c/deictic`, and `?thread=<id>` on it), and none for another board, whose pages
|
|
50
|
-
* deictic can't know.
|
|
51
|
-
*/
|
|
52
|
-
link?: (channel: string, task?: string) => string | undefined;
|
|
53
|
-
/** What opens its tab directly, beside deictic's own shortcut, which opens any: none by default. */
|
|
54
|
-
shortcut?: Shortcut;
|
|
55
|
-
}
|
|
56
|
-
interface Task {
|
|
57
|
-
id: string;
|
|
58
|
-
/** The first line of what was typed. */
|
|
59
|
-
title: string;
|
|
60
|
-
/** What was typed, whole: what an edit changes. */
|
|
61
|
-
text: string;
|
|
62
|
-
state: string;
|
|
63
|
-
/** Whether it can still be edited or deleted: no one has claimed it. */
|
|
64
|
-
open: boolean;
|
|
65
|
-
/** Its page on the board, when there's one to link to. */
|
|
66
|
-
link?: string;
|
|
7
|
+
/** A request as rrweb's network plugin has it: all this reads of one, and changes. */
|
|
8
|
+
interface Request {
|
|
9
|
+
name: string;
|
|
10
|
+
requestHeaders?: Record<string, string>;
|
|
11
|
+
responseHeaders?: Record<string, string>;
|
|
12
|
+
requestBody?: string | null;
|
|
13
|
+
responseBody?: string | null;
|
|
67
14
|
}
|
|
68
|
-
interface
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
tasks: Task[];
|
|
15
|
+
interface Masking {
|
|
16
|
+
/** More names whose values are blanked, as these are: a part of the name, in any case. */
|
|
17
|
+
mask: string[];
|
|
18
|
+
/** Requests left out: a part of the URL. */
|
|
19
|
+
ignore: string[];
|
|
74
20
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
interface Op {
|
|
87
|
-
text: string;
|
|
88
|
-
/** The page's URL. */
|
|
89
|
-
page: string;
|
|
90
|
-
viewport: {
|
|
91
|
-
width: number;
|
|
92
|
-
height: number;
|
|
93
|
-
};
|
|
94
|
-
/**
|
|
95
|
-
* What was under the pointer inside the element, where nothing marked it (a dependency's markup, or a
|
|
96
|
-
* shadow root's): its path from the element, and its HTML, cut short.
|
|
97
|
-
*/
|
|
98
|
-
pointed?: {
|
|
99
|
-
path: string;
|
|
100
|
-
html: string;
|
|
101
|
-
};
|
|
102
|
-
/** How many elements on the page come from the same place in the source. */
|
|
103
|
-
count: number;
|
|
21
|
+
/** What a blanked value reads as. */
|
|
22
|
+
declare const MASKED = "***";
|
|
23
|
+
declare const sensitive: (name: string, more?: readonly string[]) => boolean;
|
|
24
|
+
/** The URL without a name and password before its host, and with its secrets blanked: the query's, and a fragment's that reads as one. */
|
|
25
|
+
declare function maskUrl(url: string, more?: readonly string[]): string;
|
|
26
|
+
declare function maskHeaders(headers: Record<string, string>, more?: readonly string[]): Record<string, string>;
|
|
27
|
+
/** A body with its secrets blanked where it's JSON or a form's fields, cut where it's long: other text has no names to go by. */
|
|
28
|
+
declare function maskBody(body: string, more?: readonly string[]): string;
|
|
29
|
+
/** The request as it's kept, or nothing for one left out. */
|
|
30
|
+
declare function maskRequest<R extends Request>(request: R, { mask, ignore }: Masking): R | undefined;
|
|
31
|
+
interface NetworkOptions {
|
|
104
32
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
33
|
+
* What made the requests kept, as the browser names it (a resource's `initiatorType`): `['fetch',
|
|
34
|
+
* 'xmlhttprequest']` by default, the page's own calls. `'img'`, `'script'`, `'css'` and the like add what it loads.
|
|
107
35
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
marks?: Marks;
|
|
112
|
-
}[];
|
|
36
|
+
initiators?: string[];
|
|
37
|
+
/** Keeps each request's and response's headers, the secret ones blanked (`Authorization`, `Cookie`, …): not by default. */
|
|
38
|
+
headers?: boolean;
|
|
113
39
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
40
|
+
* Keeps each request's and response's body, cut at 10,000 characters, secrets blanked by name where it's JSON or a
|
|
41
|
+
* form's fields: not by default. `true` is JSON, text and forms; a list names the content types, by a part of each.
|
|
116
42
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}[];
|
|
123
|
-
/** Voice notes the voice plugin kept, to attach, where that plugin is loaded, and how long each runs. */
|
|
124
|
-
voice?: {
|
|
125
|
-
id: string;
|
|
126
|
-
duration: number;
|
|
127
|
-
}[];
|
|
128
|
-
/** The page's annotations, where that plugin is loaded and there are any: how many, and their notes' text. */
|
|
129
|
-
annotations?: Marks;
|
|
43
|
+
body?: boolean | string[];
|
|
44
|
+
/** More names whose values are blanked, in a query, a header or a body: a part of the name, in any case (`['email']`). */
|
|
45
|
+
mask?: string[];
|
|
46
|
+
/** Requests left out whole: a part of the URL (`['/analytics', 'sentry.io']`). */
|
|
47
|
+
ignore?: string[];
|
|
130
48
|
}
|
|
131
|
-
/**
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
title: string;
|
|
139
|
-
state: string;
|
|
140
|
-
channel: string;
|
|
141
|
-
/** The element: its file, line and column, and its tag. */
|
|
142
|
-
target: Target;
|
|
143
|
-
/** The page's URL. */
|
|
144
|
-
page: string;
|
|
145
|
-
/** How many of each were attached; `marks` counts those drawn on shots and on the page. */
|
|
146
|
-
attached: {
|
|
147
|
-
screenshots: number;
|
|
148
|
-
recordings: number;
|
|
149
|
-
voice: number;
|
|
150
|
-
marks: number;
|
|
151
|
-
};
|
|
49
|
+
/** The options as the page half gets them. */
|
|
50
|
+
interface Resolved {
|
|
51
|
+
initiators: string[];
|
|
52
|
+
headers: boolean;
|
|
53
|
+
body: false | string[];
|
|
54
|
+
mask: string[];
|
|
55
|
+
ignore: string[];
|
|
152
56
|
}
|
|
153
|
-
|
|
154
|
-
interface
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
interface Added {
|
|
159
|
-
channel: string;
|
|
160
|
-
id: string;
|
|
161
|
-
text: string;
|
|
162
|
-
labels: Record<string, string>;
|
|
163
|
-
/** What's attached, by the board's IDs: kept, so a redo attaches the same without uploading it again. */
|
|
164
|
-
attachments?: string[];
|
|
165
|
-
}
|
|
166
|
-
/** A task's words changed: its message's whole text before and after. */
|
|
167
|
-
interface Edited {
|
|
168
|
-
kind: 'edited';
|
|
169
|
-
id: string;
|
|
170
|
-
before: string;
|
|
171
|
-
after: string;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* A task deleted in the panel: canceled on the board, for good, as a board has it. So it's kept whole, and
|
|
175
|
-
* an undo adds it again, as a new task whose ID the record then has.
|
|
176
|
-
*/
|
|
177
|
-
interface Removed extends Added {
|
|
178
|
-
kind: 'removed';
|
|
57
|
+
declare module 'deictic' {
|
|
58
|
+
interface ClientApis {
|
|
59
|
+
network: Recorded;
|
|
60
|
+
}
|
|
179
61
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
declare function tasks(options?: TasksOptions): import("deictic").ServerPlugin<Model, Change, Kept, unknown>;
|
|
183
|
-
export { Marks as a, Removed as c, TaskBoard as d, TasksOptions as f, local as g, LocalOptions as h, Kept as i, Task as l, LocalBoard as m, Change as n, Model as o, tasks as p, Edited as r, Op as s, Added as t, TaskAdded as u };
|
|
62
|
+
declare function network(options?: NetworkOptions): import("deictic").ServerPlugin<never, never, unknown, unknown>;
|
|
63
|
+
export { maskBody as a, maskUrl as c, MASKED as i, sensitive as l, Resolved as n, maskHeaders as o, network as r, maskRequest as s, NetworkOptions as t };
|
|
184
64
|
//# sourceMappingURL=index4.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index4.d.ts","names":[],"sources":["../../src/plugins/
|
|
1
|
+
{"version":3,"file":"index4.d.ts","names":[],"sources":["../../src/plugins/network/mask.ts","../../src/plugins/network/index.ts"],"mappings":";;;;;;;UAOiB;EACf;EACA,iBAAiB;EACjB,kBAAkB;EAClB;EACA;;UAGe;;EAEf;;EAEA;;;cAIW;cA+BA,YAAS,cAAgB;;iBAgBtB,QAAQ,aAAa;iBAsBrB,YAAY,SAAS,wBAAwB,2BAA+B;;iBAW5E,SAAS,cAAc;;iBAmBvB,YAAY,UAAU,SAAS,SAAS,KAAK,MAAM,UAAU,UAAU;UCzGtE;;;;;EAKf;;EAEA;;;;;EAKA;;EAEA;;EAEA;;;UAIe;EACf;EACA;EACA;EACA;EACA;;;YAIU;IACR,SAAS;;;iBAOG,QAAQ,UAAS,mCAAmB"}
|