@opencraw/studio 0.0.17 → 0.0.19

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 (115) hide show
  1. package/dist/browser-provisioning/ensure-browser-launch.use-case.d.ts +12 -0
  2. package/dist/browser-provisioning/index.d.ts +2 -0
  3. package/dist/browser-provisioning/install-chromium.use-case.d.ts +2 -0
  4. package/dist/browser-provisioning/missing-browser.policy.d.ts +3 -0
  5. package/dist/document-view/deck-view.mapper.d.ts +70 -0
  6. package/dist/document-view/index.d.ts +13 -0
  7. package/dist/document-view/pdf-view.mapper.d.ts +47 -0
  8. package/dist/document-view/region-preview.use-case.d.ts +30 -0
  9. package/dist/document-view/table-preview.use-case.d.ts +152 -0
  10. package/dist/document-view/tree-view.mapper.d.ts +47 -0
  11. package/dist/document-view/workbook-view.mapper.d.ts +51 -0
  12. package/dist/explain-why/index.d.ts +5 -0
  13. package/dist/explain-why/item-hint.algorithm.d.ts +13 -0
  14. package/dist/explain-why/why-sentence.mapper.d.ts +48 -0
  15. package/dist/explain-why/why.use-case.d.ts +26 -0
  16. package/dist/flow-recording/action-to-step.mapper.d.ts +16 -0
  17. package/dist/flow-recording/index.d.ts +13 -0
  18. package/dist/flow-recording/next-link.policy.d.ts +27 -0
  19. package/dist/flow-recording/recorded-action.contract.d.ts +114 -0
  20. package/dist/flow-recording/recorder-script.client.d.ts +48 -0
  21. package/dist/flow-recording/recorder-session.use-case.d.ts +67 -0
  22. package/dist/flow-recording/secret-field.policy.d.ts +33 -0
  23. package/dist/flow-recording/wait-insertion.policy.d.ts +26 -0
  24. package/dist/index.d.ts +14 -1
  25. package/dist/main.d.ts +18 -0
  26. package/dist/page-inspector/dom-tree.mapper.d.ts +32 -0
  27. package/dist/page-inspector/index.d.ts +7 -0
  28. package/dist/page-inspector/page-data.algorithm.d.ts +39 -0
  29. package/dist/page-inspector/responses-seen.use-case.d.ts +36 -0
  30. package/dist/page-snapshot/fetch-start-page.use-case.d.ts +20 -0
  31. package/dist/page-snapshot/hidden-marks.algorithm.d.ts +23 -0
  32. package/dist/page-snapshot/index.d.ts +13 -0
  33. package/dist/page-snapshot/invalidate-stale-snapshot.use-case.d.ts +12 -0
  34. package/dist/page-snapshot/pdf-bytes.use-case.d.ts +16 -0
  35. package/dist/page-snapshot/reread-csv.use-case.d.ts +22 -0
  36. package/dist/page-snapshot/rewrite-document.mapper.d.ts +27 -0
  37. package/dist/page-snapshot/snapshot.store.d.ts +14 -0
  38. package/dist/page-snapshot/start-point.policy.d.ts +12 -0
  39. package/dist/page-snapshot/take-snapshot.use-case.d.ts +60 -0
  40. package/dist/recipe-workspace/import-document.use-case.d.ts +22 -0
  41. package/dist/recipe-workspace/index.d.ts +5 -0
  42. package/dist/recipe-workspace/open-workspace.use-case.d.ts +15 -0
  43. package/dist/recipe-workspace/save-recipe.use-case.d.ts +21 -0
  44. package/dist/sample-run/index.d.ts +8 -0
  45. package/dist/sample-run/last-run.store.d.ts +17 -0
  46. package/dist/sample-run/load-recipe-pair.use-case.d.ts +18 -0
  47. package/dist/sample-run/run-sample.use-case.d.ts +40 -0
  48. package/dist/sample-run/sample-run-record.contract.d.ts +48 -0
  49. package/dist/scope-outline/card-sentence.mapper.d.ts +18 -0
  50. package/dist/scope-outline/index.d.ts +8 -0
  51. package/dist/scope-outline/outline-to-recipe.mapper.d.ts +17 -0
  52. package/dist/scope-outline/outline.model.d.ts +57 -0
  53. package/dist/scope-outline/recipe-to-outline.mapper.d.ts +14 -0
  54. package/dist/scope-outline/scope-at-path.algorithm.d.ts +19 -0
  55. package/dist/selector-inference/class-token.policy.d.ts +35 -0
  56. package/dist/selector-inference/dom-path.model.d.ts +73 -0
  57. package/dist/selector-inference/index.d.ts +12 -0
  58. package/dist/selector-inference/list-inference.algorithm.d.ts +43 -0
  59. package/dist/selector-inference/selector-candidates.algorithm.d.ts +22 -0
  60. package/dist/selector-inference/selector-ranking.policy.d.ts +27 -0
  61. package/dist/selector-inference/shadow-dom.error.d.ts +11 -0
  62. package/dist/selector-inference/take-kind.policy.d.ts +12 -0
  63. package/dist/studio-api/command.contract.d.ts +531 -0
  64. package/dist/studio-api/deck-preview-view.contract.d.ts +28 -0
  65. package/dist/studio-api/deck-view.contract.d.ts +127 -0
  66. package/dist/studio-api/document-tree-view.contract.d.ts +26 -0
  67. package/dist/studio-api/event.contract.d.ts +155 -0
  68. package/dist/studio-api/grid-preview-view.contract.d.ts +26 -0
  69. package/dist/studio-api/grid-view.contract.d.ts +75 -0
  70. package/dist/studio-api/import-document-view.contract.d.ts +8 -0
  71. package/dist/studio-api/index.d.ts +43 -0
  72. package/dist/studio-api/infer-selector-view.contract.d.ts +68 -0
  73. package/dist/studio-api/inspect-view.contract.d.ts +62 -0
  74. package/dist/studio-api/outline-view.contract.d.ts +37 -0
  75. package/dist/studio-api/pdf-view.contract.d.ts +66 -0
  76. package/dist/studio-api/region-preview-view.contract.d.ts +53 -0
  77. package/dist/studio-api/responses-seen-view.contract.d.ts +20 -0
  78. package/dist/studio-api/sample-run-view.contract.d.ts +28 -0
  79. package/dist/studio-api/snapshot-view.contract.d.ts +30 -0
  80. package/dist/studio-api/start-page-view.contract.d.ts +7 -0
  81. package/dist/studio-api/table-preview-view.contract.d.ts +65 -0
  82. package/dist/studio-api/verify-selector-view.contract.d.ts +18 -0
  83. package/dist/studio-api/why-view.contract.d.ts +16 -0
  84. package/dist/studio-api/workspace-view.contract.d.ts +67 -0
  85. package/dist/studio-server/access-token.policy.d.ts +26 -0
  86. package/dist/studio-server/deck-preview.handler.d.ts +17 -0
  87. package/dist/studio-server/deck-view.handler.d.ts +15 -0
  88. package/dist/studio-server/document-tree.handler.d.ts +14 -0
  89. package/dist/studio-server/explain-why.handler.d.ts +14 -0
  90. package/dist/studio-server/fetch-start-page.handler.d.ts +14 -0
  91. package/dist/studio-server/grid-preview.handler.d.ts +17 -0
  92. package/dist/studio-server/grid-view.handler.d.ts +20 -0
  93. package/dist/studio-server/import-document.handler.d.ts +14 -0
  94. package/dist/studio-server/index.d.ts +3 -0
  95. package/dist/studio-server/infer-selector.handler.d.ts +18 -0
  96. package/dist/studio-server/inspect-page.handler.d.ts +18 -0
  97. package/dist/studio-server/open-workspace.handler.d.ts +20 -0
  98. package/dist/studio-server/pdf-bytes.handler.d.ts +17 -0
  99. package/dist/studio-server/pdf-view.handler.d.ts +14 -0
  100. package/dist/studio-server/recording.handler.d.ts +36 -0
  101. package/dist/studio-server/region-preview.handler.d.ts +17 -0
  102. package/dist/studio-server/responses-seen.handler.d.ts +16 -0
  103. package/dist/studio-server/run-sample.handler.d.ts +28 -0
  104. package/dist/studio-server/save-outline.handler.d.ts +18 -0
  105. package/dist/studio-server/save-recipe.handler.d.ts +15 -0
  106. package/dist/studio-server/static-file.handler.d.ts +14 -0
  107. package/dist/studio-server/studio-http.use-case.d.ts +40 -0
  108. package/dist/studio-server/table-preview.handler.d.ts +16 -0
  109. package/dist/studio-server/take-snapshot.handler.d.ts +16 -0
  110. package/dist/studio-server/verify-selector.handler.d.ts +18 -0
  111. package/dist/studio-server/websocket.client.d.ts +22 -0
  112. package/dist/studio-server/workspace.store.d.ts +36 -0
  113. package/dist/trusted-plugins/index.d.ts +2 -0
  114. package/dist/trusted-plugins/trusted-plugins.contract.d.ts +14 -0
  115. package/package.json +3 -3
@@ -0,0 +1,36 @@
1
+ import type { StartRecordingCommand, StopRecordingCommand } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `start-recording`: opens the studio's own headed browser window
5
+ * on the named recipe's start point (issue #95, phase 6) and streams
6
+ * `recording-card`/`recording-note` events as the person drives it. One
7
+ * recording at a time, like one sample run at a time: a second
8
+ * `start-recording` stops whatever was already open first.
9
+ *
10
+ * @param state - The server state: `folder` must already be set, `recorderProfileDir` names the studio's own recorder profile (never a crawl's own, never the person's default browser).
11
+ * @param command - The command.
12
+ * @returns `{ started: true }` once the window is open.
13
+ * @throws Error when no workspace is open, or the recipe cannot be found or loaded.
14
+ */
15
+ export declare function handleStartRecording(state: StudioState, command: StartRecordingCommand): Promise<{
16
+ started: true;
17
+ }>;
18
+ /**
19
+ * Handles `stop-recording`: closes the recording window, if one is open,
20
+ * and answers with every step recorded, in order — enough for the caller to
21
+ * build "make this the login" (`session.bootstrap`) or "keep as steps"
22
+ * without asking the server again. Also broadcasts `recording-stopped`, so
23
+ * every connected client (not only the one that asked) knows the window
24
+ * closed, even when nothing was open (a UI waiting on it would stay stuck).
25
+ * A stop that arrives while the window is still opening waits for it.
26
+ *
27
+ * @param state - The server state holding the active recording, if any.
28
+ * @param _command - The command (carries nothing beyond its type).
29
+ * @returns Every step recorded, in order; empty when nothing was recording.
30
+ */
31
+ export declare function handleStopRecording(state: StudioState, _command: StopRecordingCommand): Promise<{
32
+ steps: Record<string, unknown>[];
33
+ }>;
34
+ /** Closes the recording in progress, waiting first for one still opening (issue #174). */
35
+ export declare function settleRecording(state: StudioState): Promise<void>;
36
+ //# sourceMappingURL=recording.handler.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { RegionPreviewCommand, RegionPreviewView } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `region-preview`: the PDF and deck canvases' live preview of a
5
+ * `region` extract's selector (`document-view`'s
6
+ * `region-preview.use-case.ts`, issues #121 and #122), off the same cached
7
+ * snapshot `take-snapshot` already captured — a pure computation over it,
8
+ * so this answers instantly on every change of the box, no re-fetch or
9
+ * re-parse (mirrors `table-preview.handler.ts`).
10
+ *
11
+ * @param state - The server state.
12
+ * @param command - The command; `command.path` must already have a cached snapshot (call `take-snapshot` first).
13
+ * @returns The matches, or `error` when the selector does not parse or does not fit the document.
14
+ * @throws Error when `command.path` has no cached snapshot yet, or the snapshot is neither a PDF nor a deck.
15
+ */
16
+ export declare function handleRegionPreview(state: StudioState, command: RegionPreviewCommand): RegionPreviewView;
17
+ //# sourceMappingURL=region-preview.handler.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { ResponsesSeenCommand, ResponsesSeenView } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `responses-seen`: the JSON responses observed while a recipe's
5
+ * start page rendered (`page-inspector`'s `responses-seen.use-case.ts`,
6
+ * issue #93), for the Inspect panel's "responses seen" list — picking one
7
+ * is the seam the UI uses to switch the recipe to api mode (issue #93's
8
+ * acceptance; the JSON tree canvas that follows is phase 5's).
9
+ *
10
+ * @param state - The server state: `folder` must already be set.
11
+ * @param command - The command.
12
+ * @returns The observed responses.
13
+ * @throws Error when no workspace is open, or the recipe cannot be found or loaded.
14
+ */
15
+ export declare function handleResponsesSeen(state: StudioState, command: ResponsesSeenCommand): Promise<ResponsesSeenView>;
16
+ //# sourceMappingURL=responses-seen.handler.d.ts.map
@@ -0,0 +1,28 @@
1
+ import type { RunSampleCommand, StopRunCommand } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `run-sample`: stops whatever sample was still running (one run at
5
+ * a time), starts the new one, and returns once it has started, not once it
6
+ * finishes: `trace-line` and `record` stream over the WebSocket as the run
7
+ * proceeds, and `run-finished` closes it out.
8
+ *
9
+ * @param state - The server state: `folder` must already be set (`open-workspace` first).
10
+ * @param command - The command.
11
+ * @returns `{ started: true }` once the run has begun.
12
+ * @throws Error when no workspace is open, or the recipe cannot be loaded or bound.
13
+ */
14
+ export declare function handleRunSample(state: StudioState, command: RunSampleCommand): Promise<{
15
+ started: true;
16
+ }>;
17
+ /**
18
+ * Handles `stop-run`: closes the crawler of the run in progress, if any.
19
+ * `run-finished` still follows once the interrupted run's promise settles.
20
+ *
21
+ * @param state - The server state holding the active run, if any.
22
+ * @param _command - The command (carries nothing beyond its type).
23
+ * @returns Whether a run was actually in progress to stop.
24
+ */
25
+ export declare function handleStopRun(state: StudioState, _command: StopRunCommand): Promise<{
26
+ stopped: boolean;
27
+ }>;
28
+ //# sourceMappingURL=run-sample.handler.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { SaveOutlineCommand } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `save-outline`: the Steps tab's edits, as the outline it holds
5
+ * locally, converted back to the recipe's JSON (`scope-outline`'s
6
+ * `outlineToRecipe`, so the conversion runs here rather than in the
7
+ * browser) and written the same way `save-recipe` writes the JSON tab's
8
+ * edits. Every connected client, including the sender, is told the
9
+ * workspace changed, so both tabs re-fetch it and stay in sync.
10
+ *
11
+ * @param state - The server state holding the connected sockets.
12
+ * @param command - The command: the file path and the edited outline.
13
+ * @returns `{ saved: true }` once the write has completed.
14
+ */
15
+ export declare function handleSaveOutline(state: StudioState, command: SaveOutlineCommand): Promise<{
16
+ saved: true;
17
+ }>;
18
+ //# sourceMappingURL=save-outline.handler.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { SaveRecipeCommand } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `save-recipe`: writes the file (see `recipe-workspace/save-recipe.use-case.ts`
5
+ * for the pretty-printing and its round-trip guarantee), then tells every
6
+ * connected client the workspace changed, so the UI can re-fetch it.
7
+ *
8
+ * @param state - The server state holding the connected sockets.
9
+ * @param command - The command: the file path and the whole recipe object.
10
+ * @returns `{ saved: true }` once the write has completed.
11
+ */
12
+ export declare function handleSaveRecipe(state: StudioState, command: SaveRecipeCommand): Promise<{
13
+ saved: true;
14
+ }>;
15
+ //# sourceMappingURL=save-recipe.handler.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { ServerResponse } from 'node:http';
2
+ /**
3
+ * Serves the built UI from `root` (`packages/studio/dist/ui`, `apps/studio-ui`'s
4
+ * build output): the requested path if it exists as a file, `index.html`
5
+ * otherwise, so a client-side route (or the bare `/`) always gets the SPA's
6
+ * shell. `root` not existing at all (the UI has not been built) answers 404
7
+ * with a hint rather than a stack trace.
8
+ *
9
+ * @param root - The built UI's folder.
10
+ * @param pathname - The request's URL path.
11
+ * @param response - The response to write to.
12
+ */
13
+ export declare function serveStatic(root: string, pathname: string, response: ServerResponse): void;
14
+ //# sourceMappingURL=static-file.handler.d.ts.map
@@ -0,0 +1,40 @@
1
+ import type { BrowserSessionConfig } from '@opencraw/core';
2
+ import type { TrustedPlugins } from '../trusted-plugins';
3
+ export interface StudioServerOptions {
4
+ /** Where the built UI lives; default: `dist/ui` next to the running server code. */
5
+ uiRoot?: string;
6
+ /** A fixed port; default: an OS-assigned free port. */
7
+ port?: number;
8
+ /**
9
+ * The folder `opencraw-studio` was started with, if any: set as the
10
+ * server's current workspace right away, so `run-sample`, `save-recipe`
11
+ * and `fetch-start-page` work immediately, before the UI's own
12
+ * `open-workspace` call (which it still makes, to get the recipe listing;
13
+ * the folder reaches it through the URL's `folder` query param).
14
+ */
15
+ initialFolder?: string;
16
+ /** Browser launch settings every web-mode command shares (`take-snapshot`, `verify-selector`, `run-sample`, `start-recording`); an executable path override (e.g. `OPENCRAW_CHROMIUM`, read by the caller — the server itself has no opinion on env vars) for a sandbox with no full Playwright install. Default: Playwright's own bundled browser. `start-recording` always forces `headless: false` regardless of what this sets. */
17
+ browser?: BrowserSessionConfig;
18
+ /** Hooks, access plugins and captcha solvers to run recipes with, loaded by the caller from a file the person named at launch (`opencraw studio --hooks`, issue #150). The server never loads code itself and no request can set this. Default: none. */
19
+ plugins?: TrustedPlugins;
20
+ /** Where the studio's own recorder profile lives (issue #95); default: a fixed directory under the OS temp folder, never a crawl's own profile directory, never the person's default browser. */
21
+ recorderProfileDir?: string;
22
+ }
23
+ /** The running server: its URL (token included, ready to open), the token alone, and how to stop it. */
24
+ export interface StudioServer {
25
+ url: string;
26
+ token: string;
27
+ close: () => Promise<void>;
28
+ }
29
+ /**
30
+ * Starts the studio's HTTP server: one `POST /api/command` for every
31
+ * command `studio-api` defines, `GET /ws` for the event stream, and the
32
+ * built UI for everything else. Binds `127.0.0.1` only; every request needs
33
+ * the token (`access-token.policy.ts`) — as a header, a query param, or the
34
+ * cookie the server sets once a document request proves the query param.
35
+ *
36
+ * @param options - The UI root and the port; both default sensibly.
37
+ * @returns The running server.
38
+ */
39
+ export declare function startStudioServer(options?: StudioServerOptions): Promise<StudioServer>;
40
+ //# sourceMappingURL=studio-http.use-case.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { TablePreviewCommand, TablePreviewView } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `table-preview`: the PDF canvas's live preview of a `table`
5
+ * extract's options (`document-view`'s `table-preview.use-case.ts`, studio
6
+ * plan §3.4, issue #94's 5b), off the same cached snapshot `take-snapshot`
7
+ * already captured — a pure computation over it, so this answers instantly
8
+ * on every option change, no re-fetch or re-parse.
9
+ *
10
+ * @param state - The server state.
11
+ * @param command - The command; `command.path` must already have a cached snapshot (call `take-snapshot` first).
12
+ * @returns The matches, or `error` when an option's pattern does not compile.
13
+ * @throws Error when no workspace is open, or `command.path` has no cached snapshot yet.
14
+ */
15
+ export declare function handleTablePreview(state: StudioState, command: TablePreviewCommand): TablePreviewView;
16
+ //# sourceMappingURL=table-preview.handler.d.ts.map
@@ -0,0 +1,16 @@
1
+ import type { SnapshotView, TakeSnapshotCommand } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `take-snapshot`: loads the named input recipe, captures its
5
+ * snapshot at `command.path` (only `"start"` is captured for now — see
6
+ * `page-snapshot`'s `take-snapshot.use-case.ts`), and caches it so a later
7
+ * `verify-selector`/`infer-selector` against the same recipe and path, or
8
+ * the UI reselecting the same step, does not recapture it.
9
+ *
10
+ * @param state - The server state: `folder` must already be set.
11
+ * @param command - The command.
12
+ * @returns The rewritten snapshot.
13
+ * @throws Error when no workspace is open, or the recipe cannot be found or loaded.
14
+ */
15
+ export declare function handleTakeSnapshot(state: StudioState, command: TakeSnapshotCommand): Promise<SnapshotView>;
16
+ //# sourceMappingURL=take-snapshot.handler.d.ts.map
@@ -0,0 +1,18 @@
1
+ import type { VerifySelectorCommand, VerifySelectorView } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `verify-selector`: runs a candidate through the engine's own
5
+ * selection (`@opencraw/core`'s `countMatches`) against the cached
6
+ * snapshot, and, best-effort, against the live page too — issue #91's "flag
7
+ * a selector that matches the snapshot but not the live page". The live
8
+ * page is fetched raw (`page-snapshot`'s `fetchStartPage`, the same reach
9
+ * `take-snapshot` has: only `"start"` today), not through the rewritten
10
+ * snapshot, so its match count is the site's own, not the studio's.
11
+ *
12
+ * @param state - The server state.
13
+ * @param command - The command; `command.path` must already have a cached snapshot (call `take-snapshot` first).
14
+ * @returns The match counts.
15
+ * @throws Error when no workspace is open, the recipe cannot be found, or `command.path` has no cached snapshot yet.
16
+ */
17
+ export declare function handleVerifySelector(state: StudioState, command: VerifySelectorCommand): Promise<VerifySelectorView>;
18
+ //# sourceMappingURL=verify-selector.handler.d.ts.map
@@ -0,0 +1,22 @@
1
+ import type { IncomingMessage } from 'node:http';
2
+ import type { Duplex } from 'node:stream';
3
+ /** One accepted WebSocket connection: text frames only, no compression, no fragmentation. */
4
+ export interface WsConnection {
5
+ send: (text: string) => void;
6
+ close: () => void;
7
+ onMessage: (handler: (text: string) => void) => void;
8
+ onClose: (handler: () => void) => void;
9
+ }
10
+ /**
11
+ * Accepts one WebSocket upgrade on the raw socket `node:http` hands an
12
+ * `upgrade` listener, implementing just enough of RFC 6455 for the studio's
13
+ * own one-directional event stream: the server sends small JSON text
14
+ * frames, the client sends none (commands go over `POST /api/command`). No
15
+ * `ws` dependency: this is deliberately small rather than general-purpose.
16
+ *
17
+ * @param request - The upgrade request (its `Sec-WebSocket-Key` header).
18
+ * @param socket - The raw, already-connected socket.
19
+ * @returns The connection: `send`, `close`, and where messages and the close go.
20
+ */
21
+ export declare function acceptWebSocket(request: IncomingMessage, socket: Duplex): WsConnection;
22
+ //# sourceMappingURL=websocket.client.d.ts.map
@@ -0,0 +1,36 @@
1
+ import type { BrowserSessionConfig } from '@opencraw/core';
2
+ import type { RecorderSessionHandle } from '../flow-recording';
3
+ import type { SnapshotCache } from '../page-snapshot';
4
+ import type { LastRunCache, SampleRunHandle } from '../sample-run';
5
+ import type { StudioEvent } from '../studio-api';
6
+ import type { TrustedPlugins } from '../trusted-plugins';
7
+ import type { WsConnection } from './websocket.client';
8
+ /** The server's mutable state: the opened folder, the run in progress (if any), the recording in progress (if any, issue #95), the connected event sockets, the per-recipe snapshot cache `take-snapshot`/`verify-selector`/`infer-selector` share, each recipe's last finished sample run (`explain-why`, issue #92), the browser launch settings every web-mode command (`take-snapshot`, `verify-selector`, `run-sample`, `start-recording`) shares, and where the studio's own recorder profile lives. */
9
+ export interface StudioState {
10
+ folder?: string;
11
+ activeRun?: SampleRunHandle;
12
+ activeRecording?: RecorderSessionHandle;
13
+ /** A `start-recording` still opening its window: `stop-recording` and the server's own close wait for it, so a window is never left open behind them (issue #174). */
14
+ openingRecording?: Promise<unknown>;
15
+ sockets: Set<WsConnection>;
16
+ snapshots: SnapshotCache;
17
+ lastRuns: LastRunCache;
18
+ /** Set once at server start (`StudioServerOptions.browser`); every web-mode command reads it from here rather than each accepting its own. */
19
+ browser?: BrowserSessionConfig;
20
+ /** Set once at server start (`StudioServerOptions.plugins`): the hooks and plugins the person started Studio with (issue #150). Never set by a request. */
21
+ plugins?: TrustedPlugins;
22
+ /** Set once at server start (`StudioServerOptions.recorderProfileDir`), else `defaultRecorderProfileDir()`. */
23
+ recorderProfileDir: string;
24
+ }
25
+ /** @returns Fresh state for a new server instance: no workspace open, no run, no recording, no sockets, an empty snapshot cache, no last runs, Playwright's own default browser, the default recorder profile directory. */
26
+ export declare function createStudioState(): StudioState;
27
+ /**
28
+ * Sends one event to every connected client. A socket that errors while
29
+ * sending (gone away without a clean close yet reaching us) is dropped
30
+ * rather than left to fail every later broadcast too.
31
+ *
32
+ * @param state - The server state holding the connected sockets.
33
+ * @param event - The event to send.
34
+ */
35
+ export declare function broadcast(state: StudioState, event: StudioEvent): void;
36
+ //# sourceMappingURL=workspace.store.d.ts.map
@@ -0,0 +1,2 @@
1
+ export type { TrustedPlugins } from './trusted-plugins.contract';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { AccessPlugin, CaptchaSolver, HookMap } from '@opencraw/core';
2
+ /**
3
+ * Code the person who started Studio chose to run (`opencraw studio --hooks <file>`, issue #150): the
4
+ * hooks, access plugins and captcha solvers a recipe names. It is loaded once at launch, never at a
5
+ * recipe's or a browser request's say-so, so it has the trust of the command line it came from.
6
+ */
7
+ export interface TrustedPlugins {
8
+ /** The file it was loaded from, shown to the person in the UI and in errors. */
9
+ source: string;
10
+ hooks: HookMap;
11
+ accessPlugins?: AccessPlugin[];
12
+ captchaSolvers?: CaptchaSolver[];
13
+ }
14
+ //# sourceMappingURL=trusted-plugins.contract.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencraw/studio",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "main": "./dist/index.esm.js",
6
6
  "module": "./dist/index.esm.js",
@@ -24,8 +24,8 @@
24
24
  "!**/*.js.map"
25
25
  ],
26
26
  "dependencies": {
27
- "@opencraw/core": "^0.1.27",
28
- "@opencraw/probe": "^0.0.10",
27
+ "@opencraw/core": "^0.1.29",
28
+ "@opencraw/probe": "^0.0.12",
29
29
  "cheerio": "^1.2.0",
30
30
  "playwright": "^1.63.0",
31
31
  "zod": "^4.6.5",