@opencraw/studio 0.0.32 → 0.0.34
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/dist/document-view/index.d.ts +1 -1
- package/dist/document-view/workbook-view.mapper.d.ts +17 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +221 -22
- package/dist/page-snapshot/index.d.ts +2 -0
- package/dist/page-snapshot/inline-local-images.use-case.d.ts +19 -0
- package/dist/selector-inference/selector-ranking.policy.d.ts +1 -1
- package/dist/src/document-view/index.d.ts +1 -1
- package/dist/src/document-view/workbook-view.mapper.d.ts +17 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/page-snapshot/index.d.ts +2 -0
- package/dist/src/page-snapshot/inline-local-images.use-case.d.ts +19 -0
- package/dist/src/selector-inference/selector-ranking.policy.d.ts +1 -1
- package/dist/src/studio-api/command.contract.d.ts +20 -0
- package/dist/src/studio-api/deck-view.contract.d.ts +2 -0
- package/dist/src/studio-api/grid-view.contract.d.ts +15 -0
- package/dist/src/studio-api/index.d.ts +6 -6
- package/dist/src/studio-api/infer-selector-view.contract.d.ts +72 -0
- package/dist/src/studio-server/grid-view.handler.d.ts +12 -1
- package/dist/studio-api/command.contract.d.ts +20 -0
- package/dist/studio-api/deck-view.contract.d.ts +2 -0
- package/dist/studio-api/grid-view.contract.d.ts +15 -0
- package/dist/studio-api/index.d.ts +6 -6
- package/dist/studio-api/infer-selector-view.contract.d.ts +72 -0
- package/dist/studio-server/grid-view.handler.d.ts +12 -1
- package/dist/ui/assets/index-Db6-8OgZ.js +42 -0
- package/dist/ui/assets/{pdf-DJOnIZdZ.js → pdf-rdp2xUbL.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/package.json +3 -3
- package/dist/ui/assets/index-DQ3QLedY.js +0 -42
|
@@ -8,6 +8,6 @@ export { previewDeckTable, previewGridTable, previewPdfTable } from './table-pre
|
|
|
8
8
|
export type { DeckTablePreviewMatch, DeckTablePreviewOptions, DeckTablePreviewResult, GridTablePreviewMatch, GridTablePreviewOptions, GridTablePreviewResult, TablePreviewMatch, TablePreviewOptions, TablePreviewResult } from './table-preview.use-case';
|
|
9
9
|
export { previewRegion } from './region-preview.use-case';
|
|
10
10
|
export type { RegionPreviewResult, RegionPreviewMatch } from './region-preview.use-case';
|
|
11
|
-
export { workbookDocumentView } from './workbook-view.mapper';
|
|
11
|
+
export { workbookDocumentView, workbookSheetRows } from './workbook-view.mapper';
|
|
12
12
|
export type { GridCellType, GridCellView, GridMergeView, GridSheetView, WorkbookDocumentView } from './workbook-view.mapper';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -22,7 +22,10 @@ export interface GridSheetView {
|
|
|
22
22
|
hiddenRows: number[];
|
|
23
23
|
/** The widest row's own length, ragged rows included — for the grid to size its columns. */
|
|
24
24
|
columnCount: number;
|
|
25
|
+
/** The sheet's rows; only the first window of them when `rowCount` is set (the rest are fetched with `grid-rows`). */
|
|
25
26
|
rows: GridCellView[][];
|
|
27
|
+
/** How many rows the sheet has, set only when `rows` holds just the first window of them. */
|
|
28
|
+
rowCount?: number;
|
|
26
29
|
merges: GridMergeView[];
|
|
27
30
|
/** Column widths in characters by 0-based column, as the spreadsheet stores them; absent keys are columns the file does not size. */
|
|
28
31
|
columnWidths?: Record<string, number>;
|
|
@@ -55,5 +58,18 @@ export interface WorkbookDocumentView {
|
|
|
55
58
|
* @param document - The read workbook (a spreadsheet or a CSV).
|
|
56
59
|
* @returns The view.
|
|
57
60
|
*/
|
|
58
|
-
export declare function workbookDocumentView(document: WorkbookDocument
|
|
61
|
+
export declare function workbookDocumentView(document: WorkbookDocument, options?: {
|
|
62
|
+
windowRows?: number;
|
|
63
|
+
}): WorkbookDocumentView;
|
|
64
|
+
/**
|
|
65
|
+
* A run of one sheet's rows, typed, for a grid that only holds the screens around where it is scrolled to (the rest of a big file is never
|
|
66
|
+
* sent to the browser until it is needed).
|
|
67
|
+
*
|
|
68
|
+
* @param document - The read workbook.
|
|
69
|
+
* @param sheetIndex - Which sheet, 0-based.
|
|
70
|
+
* @param from - The first row, 0-based.
|
|
71
|
+
* @param count - How many rows at most.
|
|
72
|
+
* @returns The rows (fewer at the end of the sheet, none past it).
|
|
73
|
+
*/
|
|
74
|
+
export declare function workbookSheetRows(document: WorkbookDocument, sheetIndex: number, from: number, count: number): GridCellView[][];
|
|
59
75
|
//# sourceMappingURL=workbook-view.mapper.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export { runSample, loadRecipePair } from './sample-run';
|
|
|
9
9
|
export type { RecipePair, SampleRunCallbacks, SampleRunHandle, SampleRunRecord, SampleRunRejected, SampleRunResult, SampleStepSummary, SampleStoppedBy } from './sample-run';
|
|
10
10
|
export { fetchStartPage } from './page-snapshot';
|
|
11
11
|
export type { WhyFacts, WhyStepFact } from './explain-why';
|
|
12
|
-
export { sampleBudgetSchema, openWorkspaceCommandSchema, chooseFolderCommandSchema, openPathCommandSchema, importDocumentCommandSchema, runSampleCommandSchema, stopRunCommandSchema, saveRecipeCommandSchema, fetchStartPageCommandSchema, detectUrlCommandSchema, saveOutlineCommandSchema, takeSnapshotCommandSchema, verifySelectorCommandSchema, inferSelectorCommandSchema, missingWhyTargetSchema, rejectedWhyTargetSchema, whyTargetSchema, explainWhyCommandSchema, studioCommandSchema, chooseFolderViewSchema, openPathViewSchema, importDocumentViewSchema, stoppedBySchema, fieldTraceSchema, traceLineEventSchema, recordEventSchema, recordRejectedEventSchema, runFinishedEventSchema, workspaceChangedEventSchema, studioEventSchema, loadedHooksSchema, recipeIssueSchema, recipeListingSchema, workspaceViewSchema, sampleRunRecordSchema, sampleRunViewSchema, startPageViewSchema, detectUrlViewSchema, snapshotViewSchema, verifySelectorViewSchema, fieldPickSchema, inferSelectorViewSchema, sentencePartSchema, outlineCardSchema, outlineBracketSchema, outlineNodeSchema, outlineViewSchema, whyViewSchema, inspectPageCommandSchema, responsesSeenCommandSchema, documentTreeCommandSchema, pdfViewCommandSchema, tablePreviewOptionsSchema, tablePreviewCommandSchema, regionPreviewCommandSchema, regionPreviewMatchSchema, regionPreviewViewSchema, gridViewCommandSchema, gridPreviewOptionsSchema, gridPreviewCommandSchema, deckViewCommandSchema, deckPreviewOptionsSchema, deckPreviewCommandSchema, domTreeNodeViewSchema, pageDataFindingSchema, inspectViewSchema, observedResponseSchema, responsesSeenViewSchema, documentTreeNodeViewSchema, documentTreeViewSchema, pdfCellViewSchema, pdfRowViewSchema, pdfPageViewSchema, pdfDocumentViewSchema, tablePreviewTableSchema, tablePreviewBandSchema, tablePreviewMatchSchema, tablePreviewViewSchema, gridCellViewSchema, gridMergeViewSchema, gridSheetViewSchema, workbookDocumentViewSchema, gridTablePreviewMatchSchema, gridTablePreviewViewSchema, deckShapeViewSchema, deckChartSeriesViewSchema, deckChartViewSchema, deckSlideViewSchema, deckDocumentViewSchema, deckTablePreviewMatchSchema, deckTablePreviewViewSchema, startRecordingCommandSchema, stopRecordingCommandSchema, recordingCardEventSchema, recordingNoteEventSchema, recordingStoppedEventSchema, } from './studio-api';
|
|
13
|
-
export type { SampleBudget, OpenWorkspaceCommand, ChooseFolderCommand, OpenPathCommand, ImportDocumentCommand, RunSampleCommand, StopRunCommand, SaveRecipeCommand, FetchStartPageCommand, DetectUrlCommand, SaveOutlineCommand, TakeSnapshotCommand, VerifySelectorCommand, InferSelectorCommand, MissingWhyTarget, RejectedWhyTarget, WhyTarget, ExplainWhyCommand, InspectPageCommand, ResponsesSeenCommand, DocumentTreeCommand, PdfViewCommand, TablePreviewOptions, TablePreviewCommand, RegionPreviewCommand, GridViewCommand, GridPreviewOptions, GridPreviewCommand, DeckViewCommand, DeckPreviewOptions, DeckPreviewCommand, StudioCommand, ChooseFolderView, OpenPathView, ImportDocumentView, RegionPreviewMatchView, RegionPreviewView, StoppedBy, FieldTraceView, TraceLineEvent, RecordEvent, RecordRejectedEvent, RunFinishedEvent, WorkspaceChangedEvent, StudioEvent, LoadedHooks, RecipeIssue, RecipeListing, WorkspaceView, SampleRunView, StartPageView, DetectUrlView, SnapshotView, VerifySelectorView, FieldPick, InferSelectorView, SentencePart, OutlineCard, OutlineBracket, OutlineNode, OutlineView, WhyView, DomTreeNodeView, PageDataKind, PageDataFindingView, InspectView, ObservedResponseView, ResponsesSeenView, DocumentTreeNodeView, DocumentTreeView, PdfCellView, PdfRowView, PdfPageView, PdfDocumentView, TablePreviewTableView, TablePreviewBandView, TablePreviewMatchView, TablePreviewView, GridCellView, GridMergeView, GridSheetView, WorkbookDocumentView, GridTablePreviewMatchView, GridTablePreviewView, DeckShapeView, DeckChartSeriesView, DeckChartView, DeckSlideView, DeckDocumentView, DeckTablePreviewMatchView, DeckTablePreviewView, StartRecordingCommand, StopRecordingCommand, RecordingCardEvent, RecordingNoteEvent, RecordingStoppedEvent, } from './studio-api';
|
|
12
|
+
export { sampleBudgetSchema, openWorkspaceCommandSchema, chooseFolderCommandSchema, openPathCommandSchema, importDocumentCommandSchema, runSampleCommandSchema, stopRunCommandSchema, saveRecipeCommandSchema, fetchStartPageCommandSchema, detectUrlCommandSchema, saveOutlineCommandSchema, takeSnapshotCommandSchema, verifySelectorCommandSchema, inferSelectorCommandSchema, missingWhyTargetSchema, rejectedWhyTargetSchema, whyTargetSchema, explainWhyCommandSchema, studioCommandSchema, chooseFolderViewSchema, openPathViewSchema, importDocumentViewSchema, stoppedBySchema, fieldTraceSchema, traceLineEventSchema, recordEventSchema, recordRejectedEventSchema, runFinishedEventSchema, workspaceChangedEventSchema, studioEventSchema, loadedHooksSchema, recipeIssueSchema, recipeListingSchema, workspaceViewSchema, sampleRunRecordSchema, sampleRunViewSchema, startPageViewSchema, detectUrlViewSchema, snapshotViewSchema, verifySelectorViewSchema, fieldPickSchema, inferSelectorViewSchema, selectorAlternativeSchema, sentencePartSchema, outlineCardSchema, outlineBracketSchema, outlineNodeSchema, outlineViewSchema, whyViewSchema, inspectPageCommandSchema, responsesSeenCommandSchema, documentTreeCommandSchema, pdfViewCommandSchema, tablePreviewOptionsSchema, tablePreviewCommandSchema, regionPreviewCommandSchema, regionPreviewMatchSchema, regionPreviewViewSchema, gridViewCommandSchema, gridRowsCommandSchema, gridPreviewOptionsSchema, gridPreviewCommandSchema, deckViewCommandSchema, deckPreviewOptionsSchema, deckPreviewCommandSchema, domTreeNodeViewSchema, pageDataFindingSchema, inspectViewSchema, observedResponseSchema, responsesSeenViewSchema, documentTreeNodeViewSchema, documentTreeViewSchema, pdfCellViewSchema, pdfRowViewSchema, pdfPageViewSchema, pdfDocumentViewSchema, tablePreviewTableSchema, tablePreviewBandSchema, tablePreviewMatchSchema, tablePreviewViewSchema, gridCellViewSchema, gridMergeViewSchema, gridRowsViewSchema, gridSheetViewSchema, workbookDocumentViewSchema, gridTablePreviewMatchSchema, gridTablePreviewViewSchema, deckShapeViewSchema, deckChartSeriesViewSchema, deckChartViewSchema, deckSlideViewSchema, deckDocumentViewSchema, deckTablePreviewMatchSchema, deckTablePreviewViewSchema, startRecordingCommandSchema, stopRecordingCommandSchema, recordingCardEventSchema, recordingNoteEventSchema, recordingStoppedEventSchema, } from './studio-api';
|
|
13
|
+
export type { SampleBudget, OpenWorkspaceCommand, ChooseFolderCommand, OpenPathCommand, ImportDocumentCommand, RunSampleCommand, StopRunCommand, SaveRecipeCommand, FetchStartPageCommand, DetectUrlCommand, SaveOutlineCommand, TakeSnapshotCommand, VerifySelectorCommand, InferSelectorCommand, MissingWhyTarget, RejectedWhyTarget, WhyTarget, ExplainWhyCommand, InspectPageCommand, ResponsesSeenCommand, DocumentTreeCommand, PdfViewCommand, TablePreviewOptions, TablePreviewCommand, RegionPreviewCommand, GridViewCommand, GridRowsCommand, GridPreviewOptions, GridPreviewCommand, DeckViewCommand, DeckPreviewOptions, DeckPreviewCommand, StudioCommand, ChooseFolderView, OpenPathView, ImportDocumentView, RegionPreviewMatchView, RegionPreviewView, StoppedBy, FieldTraceView, TraceLineEvent, RecordEvent, RecordRejectedEvent, RunFinishedEvent, WorkspaceChangedEvent, StudioEvent, LoadedHooks, RecipeIssue, RecipeListing, WorkspaceView, SampleRunView, StartPageView, DetectUrlView, SnapshotView, VerifySelectorView, FieldPick, InferSelectorView, SelectorAlternative, SentencePart, OutlineCard, OutlineBracket, OutlineNode, OutlineView, WhyView, DomTreeNodeView, PageDataKind, PageDataFindingView, InspectView, ObservedResponseView, ResponsesSeenView, DocumentTreeNodeView, DocumentTreeView, PdfCellView, PdfRowView, PdfPageView, PdfDocumentView, TablePreviewTableView, TablePreviewBandView, TablePreviewMatchView, TablePreviewView, GridCellView, GridMergeView, GridRowsView, GridSheetView, WorkbookDocumentView, GridTablePreviewMatchView, GridTablePreviewView, DeckShapeView, DeckChartSeriesView, DeckChartView, DeckSlideView, DeckDocumentView, DeckTablePreviewMatchView, DeckTablePreviewView, StartRecordingCommand, StopRecordingCommand, RecordingCardEvent, RecordingNoteEvent, RecordingStoppedEvent, } from './studio-api';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { join, dirname,
|
|
1
|
+
import { join, dirname, extname, relative, sep, basename, isAbsolute, resolve, normalize } from 'node:path';
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
3
|
import { promisify, stripVTControlCharacters } from 'node:util';
|
|
4
4
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
@@ -241,6 +241,18 @@ const gridViewCommandSchema = z.object({
|
|
|
241
241
|
delimiter: z.string().min(1).optional(),
|
|
242
242
|
encoding: z.string().min(1).optional()
|
|
243
243
|
});
|
|
244
|
+
/**
|
|
245
|
+
* `grid-rows`: a run of one sheet's rows of a big CSV/spreadsheet, for the grid canvas that holds only the screens around where it is
|
|
246
|
+
* scrolled to. The first window comes with `grid-view`; the rest are asked for as the person scrolls.
|
|
247
|
+
*/
|
|
248
|
+
const gridRowsCommandSchema = z.object({
|
|
249
|
+
type: z.literal('grid-rows'),
|
|
250
|
+
recipeId: z.string().min(1),
|
|
251
|
+
path: z.string().min(1),
|
|
252
|
+
sheet: z.int().min(0),
|
|
253
|
+
from: z.int().min(0),
|
|
254
|
+
count: z.int().min(1).max(1000)
|
|
255
|
+
});
|
|
244
256
|
/** A `table` extract's options for a workbook, as the studio's grid canvas picks build them — mirrors `document-view/table-preview.use-case.ts`'s `GridTablePreviewOptions`. */
|
|
245
257
|
const gridPreviewOptionsSchema = z.object({
|
|
246
258
|
sheet: z.string().min(1).optional(),
|
|
@@ -361,7 +373,7 @@ const importDocumentCommandSchema = z.object({
|
|
|
361
373
|
name: z.string().min(1),
|
|
362
374
|
bytes: z.string()
|
|
363
375
|
});
|
|
364
|
-
const studioCommandSchema = z.discriminatedUnion('type', [openWorkspaceCommandSchema, chooseFolderCommandSchema, openPathCommandSchema, importDocumentCommandSchema, runSampleCommandSchema, stopRunCommandSchema, saveRecipeCommandSchema, fetchStartPageCommandSchema, detectUrlCommandSchema, saveOutlineCommandSchema, takeSnapshotCommandSchema, verifySelectorCommandSchema, inferSelectorCommandSchema, explainWhyCommandSchema, inspectPageCommandSchema, responsesSeenCommandSchema, documentTreeCommandSchema, pdfViewCommandSchema, tablePreviewCommandSchema, regionPreviewCommandSchema, gridViewCommandSchema, gridPreviewCommandSchema, deckViewCommandSchema, deckPreviewCommandSchema, startRecordingCommandSchema, stopRecordingCommandSchema]);
|
|
376
|
+
const studioCommandSchema = z.discriminatedUnion('type', [openWorkspaceCommandSchema, chooseFolderCommandSchema, openPathCommandSchema, importDocumentCommandSchema, runSampleCommandSchema, stopRunCommandSchema, saveRecipeCommandSchema, fetchStartPageCommandSchema, detectUrlCommandSchema, saveOutlineCommandSchema, takeSnapshotCommandSchema, verifySelectorCommandSchema, inferSelectorCommandSchema, explainWhyCommandSchema, inspectPageCommandSchema, responsesSeenCommandSchema, documentTreeCommandSchema, pdfViewCommandSchema, tablePreviewCommandSchema, regionPreviewCommandSchema, gridViewCommandSchema, gridRowsCommandSchema, gridPreviewCommandSchema, deckViewCommandSchema, deckPreviewCommandSchema, startRecordingCommandSchema, stopRecordingCommandSchema]);
|
|
365
377
|
|
|
366
378
|
/**
|
|
367
379
|
* What `take-snapshot` answers with: the rewritten document ready for the
|
|
@@ -398,18 +410,29 @@ const verifySelectorViewSchema = z.object({
|
|
|
398
410
|
|
|
399
411
|
/** The candidate tiers `selector-inference`'s ranking works through, best first — see `selector-candidates.algorithm.ts`. */
|
|
400
412
|
const candidateTierSchema = z.enum(['id', 'data-attr', 'class', 'structure', 'position']);
|
|
413
|
+
/** Another selector that reaches the clicked node, verified against the snapshot, for the person to choose instead of the best one. */
|
|
414
|
+
const selectorAlternativeSchema = z.object({
|
|
415
|
+
selector: z.string(),
|
|
416
|
+
tier: candidateTierSchema,
|
|
417
|
+
matches: z.number()
|
|
418
|
+
});
|
|
401
419
|
/** One clicked node's field: the best selector found for it, verified against the snapshot. */
|
|
402
420
|
const fieldPickSchema = z.object({
|
|
403
421
|
selector: z.string(),
|
|
404
422
|
tier: candidateTierSchema,
|
|
405
423
|
take: z.string(),
|
|
406
|
-
matches: z.number()
|
|
424
|
+
matches: z.number(),
|
|
425
|
+
/** Every verified selector that reaches the node, best first (the chosen one among them), for the options the person is shown. */
|
|
426
|
+
alternatives: z.array(selectorAlternativeSchema).optional(),
|
|
427
|
+
/** The node's own id when it looks generated (so it is not used in any selector above), to tell the person why. */
|
|
428
|
+
generatedId: z.string().optional()
|
|
407
429
|
});
|
|
408
430
|
/** A list's item shape: the best selector that matches every item, verified against the snapshot. */
|
|
409
431
|
const itemPickSchema = z.object({
|
|
410
432
|
selector: z.string(),
|
|
411
433
|
tier: candidateTierSchema,
|
|
412
|
-
matches: z.number()
|
|
434
|
+
matches: z.number(),
|
|
435
|
+
alternatives: z.array(selectorAlternativeSchema).optional()
|
|
413
436
|
});
|
|
414
437
|
/**
|
|
415
438
|
* What `infer-selector` answers with (issue #91, studio plan §3.2):
|
|
@@ -766,6 +789,8 @@ const gridSheetViewSchema = z.object({
|
|
|
766
789
|
hiddenRows: z.array(z.number().int()),
|
|
767
790
|
columnCount: z.number().int(),
|
|
768
791
|
rows: z.array(z.array(gridCellViewSchema)),
|
|
792
|
+
/** How many rows the sheet has, set only when `rows` holds just the first window of them (a big file); the rest come from `grid-rows`. */
|
|
793
|
+
rowCount: z.number().int().optional(),
|
|
769
794
|
merges: z.array(gridMergeViewSchema),
|
|
770
795
|
/** Column widths in characters by 0-based column, as the spreadsheet stores them (absent for a CSV, and for a column the file does not size). */
|
|
771
796
|
columnWidths: z.record(z.string(), z.number()).optional(),
|
|
@@ -776,6 +801,10 @@ const gridSheetViewSchema = z.object({
|
|
|
776
801
|
/** The height of a row the file does not size, in points. */
|
|
777
802
|
defaultRowHeight: z.number().optional()
|
|
778
803
|
});
|
|
804
|
+
/** What `grid-rows` answers with: a run of one sheet's rows. */
|
|
805
|
+
const gridRowsViewSchema = z.object({
|
|
806
|
+
rows: z.array(z.array(gridCellViewSchema))
|
|
807
|
+
});
|
|
779
808
|
const csvFormatViewSchema = z.object({
|
|
780
809
|
encoding: z.string(),
|
|
781
810
|
delimiter: z.string()
|
|
@@ -1490,6 +1519,88 @@ function inlineAssets(html, pageUrl, assets) {
|
|
|
1490
1519
|
return $.html();
|
|
1491
1520
|
}
|
|
1492
1521
|
|
|
1522
|
+
const IMAGE_TYPES = {
|
|
1523
|
+
'.png': 'image/png',
|
|
1524
|
+
'.jpg': 'image/jpeg',
|
|
1525
|
+
'.jpeg': 'image/jpeg',
|
|
1526
|
+
'.gif': 'image/gif',
|
|
1527
|
+
'.webp': 'image/webp',
|
|
1528
|
+
'.svg': 'image/svg+xml',
|
|
1529
|
+
'.avif': 'image/avif',
|
|
1530
|
+
'.bmp': 'image/bmp'
|
|
1531
|
+
};
|
|
1532
|
+
/** The most one picture may weigh to be embedded, and the most all of a document's pictures may (bytes). */
|
|
1533
|
+
const MAX_IMAGE_BYTES = 1_500_000;
|
|
1534
|
+
const MAX_TOTAL_BYTES = 8_000_000;
|
|
1535
|
+
/** An image address made absolute against the document's own; one that cannot be read as an address is left as it is. */
|
|
1536
|
+
function absoluteAddress(source, documentUrl) {
|
|
1537
|
+
try {
|
|
1538
|
+
return new URL(source, documentUrl).href;
|
|
1539
|
+
} catch {
|
|
1540
|
+
return source;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
/** A file's bytes, or `undefined` when it cannot be read. */
|
|
1544
|
+
async function readIfThere(path) {
|
|
1545
|
+
try {
|
|
1546
|
+
return await readFile(path);
|
|
1547
|
+
} catch {
|
|
1548
|
+
return undefined;
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
/** The file a `file:` image address names, when it sits in the document's own folder or below it; `undefined` for anything else (another site, another folder). */
|
|
1552
|
+
function localPathOf(source, documentFolder) {
|
|
1553
|
+
if (!source.startsWith('file:')) return undefined;
|
|
1554
|
+
let path;
|
|
1555
|
+
try {
|
|
1556
|
+
path = fileURLToPath(source);
|
|
1557
|
+
} catch {
|
|
1558
|
+
return undefined;
|
|
1559
|
+
}
|
|
1560
|
+
const inside = relative(documentFolder, path);
|
|
1561
|
+
return inside === '' || inside.startsWith('..') || inside.split(sep).includes('..') ? undefined : path;
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* A document read from a file (a Markdown file, say) names its pictures by paths beside it, which the browser showing it cannot open. The
|
|
1565
|
+
* pictures that sit in the document's own folder are embedded in the page as data addresses, so they show; ones that are not there are counted
|
|
1566
|
+
* so the person is told. Nothing outside the document's folder is ever read.
|
|
1567
|
+
*
|
|
1568
|
+
* @param html - The document as HTML, its addresses already made absolute against `documentUrl`.
|
|
1569
|
+
* @param documentUrl - The document's own `file:` address.
|
|
1570
|
+
* @returns The page with the pictures embedded, and how many were embedded and how many could not be.
|
|
1571
|
+
*/
|
|
1572
|
+
async function inlineLocalImages(html, documentUrl) {
|
|
1573
|
+
if (!documentUrl.startsWith('file:')) return {
|
|
1574
|
+
html,
|
|
1575
|
+
inlined: 0,
|
|
1576
|
+
missing: 0
|
|
1577
|
+
};
|
|
1578
|
+
const $ = load(html);
|
|
1579
|
+
const folder = dirname(fileURLToPath(documentUrl));
|
|
1580
|
+
let inlined = 0;
|
|
1581
|
+
let missing = 0;
|
|
1582
|
+
let total = 0;
|
|
1583
|
+
for (const element of $('img[src]')) {
|
|
1584
|
+
const source = absoluteAddress($(element).attr('src') ?? '', documentUrl);
|
|
1585
|
+
if (!source.startsWith('file:')) continue;
|
|
1586
|
+
const path = localPathOf(source, folder);
|
|
1587
|
+
const type = path === undefined ? undefined : IMAGE_TYPES[extname(path).toLowerCase()];
|
|
1588
|
+
const bytes = path !== undefined && type !== undefined ? await readIfThere(path) : undefined;
|
|
1589
|
+
if (bytes === undefined || type === undefined || bytes.length > MAX_IMAGE_BYTES || total + bytes.length > MAX_TOTAL_BYTES) {
|
|
1590
|
+
missing += 1;
|
|
1591
|
+
continue;
|
|
1592
|
+
}
|
|
1593
|
+
total += bytes.length;
|
|
1594
|
+
inlined += 1;
|
|
1595
|
+
$(element).attr('src', `data:${type};base64,${bytes.toString('base64')}`);
|
|
1596
|
+
}
|
|
1597
|
+
return {
|
|
1598
|
+
html: $.html(),
|
|
1599
|
+
inlined,
|
|
1600
|
+
missing
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1493
1604
|
/** Attributes that carry a URL and are rewritten to absolute; `srcset` is handled separately (it carries several). */
|
|
1494
1605
|
const URL_ATTRIBUTES = ['href', 'src', 'action', 'poster'];
|
|
1495
1606
|
/** Schemes left untouched: they are not a location `new URL(value, base)` should resolve, or already carry their own meaning. */
|
|
@@ -1723,13 +1834,19 @@ async function snapshotApi(url, storageState, as) {
|
|
|
1723
1834
|
})
|
|
1724
1835
|
});
|
|
1725
1836
|
const text = textOf$1(response.body);
|
|
1726
|
-
|
|
1837
|
+
// A document read from a file names its pictures by paths beside it, which the browser cannot open: the ones next to the file are embedded.
|
|
1838
|
+
const pictures = await inlineLocalImages(text, url);
|
|
1839
|
+
const rewritten = rewriteDocument(pictures.html, url);
|
|
1840
|
+
const notice = pictures.missing === 0 ? undefined : `${String(pictures.missing)} picture${pictures.missing === 1 ? '' : 's'} in this document ${pictures.missing === 1 ? 'is' : 'are'} not shown: only pictures kept in the same folder as the file can be.`;
|
|
1727
1841
|
return {
|
|
1728
1842
|
...rewritten,
|
|
1729
1843
|
baseUrl: url,
|
|
1730
1844
|
rawHtml: text,
|
|
1731
1845
|
format: response.format,
|
|
1732
|
-
body: response.body
|
|
1846
|
+
body: response.body,
|
|
1847
|
+
...(notice !== undefined && {
|
|
1848
|
+
notice
|
|
1849
|
+
})
|
|
1733
1850
|
};
|
|
1734
1851
|
} finally {
|
|
1735
1852
|
await client.dispose();
|
|
@@ -1878,21 +1995,26 @@ const ISO_DATE_OR_TIME = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2})?$|^\d{2}:\d{2
|
|
|
1878
1995
|
* @param document - The read workbook (a spreadsheet or a CSV).
|
|
1879
1996
|
* @returns The view.
|
|
1880
1997
|
*/
|
|
1881
|
-
function workbookDocumentView(document) {
|
|
1998
|
+
function workbookDocumentView(document, options = {}) {
|
|
1882
1999
|
return {
|
|
1883
|
-
sheets: document.sheets.map(sheet => sheetView(sheet)),
|
|
2000
|
+
sheets: document.sheets.map(sheet => sheetView(sheet, options.windowRows)),
|
|
1884
2001
|
...(document.csv !== undefined && {
|
|
1885
2002
|
csv: document.csv
|
|
1886
2003
|
})
|
|
1887
2004
|
};
|
|
1888
2005
|
}
|
|
1889
|
-
function sheetView(sheet) {
|
|
2006
|
+
function sheetView(sheet, windowRows) {
|
|
2007
|
+
const windowed = windowRows !== undefined && sheet.rows.length > windowRows;
|
|
1890
2008
|
return {
|
|
1891
2009
|
name: sheet.name,
|
|
1892
2010
|
hidden: sheet.hidden === true,
|
|
1893
2011
|
hiddenRows: sheet.hiddenRows === undefined ? [] : [...sheet.hiddenRows],
|
|
1894
|
-
|
|
1895
|
-
|
|
2012
|
+
// Not `Math.max(...lengths)`: a spread of a few hundred thousand rows overflows the call stack.
|
|
2013
|
+
columnCount: sheet.rows.reduce((widest, row) => Math.max(widest, row.length), 0),
|
|
2014
|
+
rows: (windowed ? sheet.rows.slice(0, windowRows) : sheet.rows).map(row => row.map(cell => cellView(cell))),
|
|
2015
|
+
...(windowed && {
|
|
2016
|
+
rowCount: sheet.rows.length
|
|
2017
|
+
}),
|
|
1896
2018
|
merges: (sheet.merges ?? []).flatMap(reference => {
|
|
1897
2019
|
const range = rangeOf(reference);
|
|
1898
2020
|
return range === undefined ? [] : [{
|
|
@@ -1918,6 +2040,21 @@ function sheetView(sheet) {
|
|
|
1918
2040
|
})
|
|
1919
2041
|
};
|
|
1920
2042
|
}
|
|
2043
|
+
/**
|
|
2044
|
+
* A run of one sheet's rows, typed, for a grid that only holds the screens around where it is scrolled to (the rest of a big file is never
|
|
2045
|
+
* sent to the browser until it is needed).
|
|
2046
|
+
*
|
|
2047
|
+
* @param document - The read workbook.
|
|
2048
|
+
* @param sheetIndex - Which sheet, 0-based.
|
|
2049
|
+
* @param from - The first row, 0-based.
|
|
2050
|
+
* @param count - How many rows at most.
|
|
2051
|
+
* @returns The rows (fewer at the end of the sheet, none past it).
|
|
2052
|
+
*/
|
|
2053
|
+
function workbookSheetRows(document, sheetIndex, from, count) {
|
|
2054
|
+
const sheet = document.sheets[sheetIndex];
|
|
2055
|
+
if (sheet === undefined) return [];
|
|
2056
|
+
return sheet.rows.slice(from, from + count).map(row => row.map(cell => cellView(cell)));
|
|
2057
|
+
}
|
|
1921
2058
|
function cellView(cell) {
|
|
1922
2059
|
return {
|
|
1923
2060
|
value: cell,
|
|
@@ -3082,6 +3219,8 @@ function handleGridPreview(state, command) {
|
|
|
3082
3219
|
return previewGridTable(snapshot.body, command.options);
|
|
3083
3220
|
}
|
|
3084
3221
|
|
|
3222
|
+
/** How many rows of a sheet the first `grid-view` answer carries; a bigger sheet's other rows come from `grid-rows` as the grid is scrolled. */
|
|
3223
|
+
const GRID_WINDOW_ROWS = 200;
|
|
3085
3224
|
/**
|
|
3086
3225
|
* Handles `grid-view`: the grid canvas's sheets and cells (`document-view`'s
|
|
3087
3226
|
* `workbook-view.mapper.ts`, studio plan §3.4, issue #94's 5c), off the same
|
|
@@ -3104,7 +3243,9 @@ async function handleGridView(state, command) {
|
|
|
3104
3243
|
const overriding = command.delimiter !== undefined || command.encoding !== undefined;
|
|
3105
3244
|
if (!overriding) {
|
|
3106
3245
|
if (!isWorkbookDocument(snapshot.body)) throw new Error(`"${command.recipeId}" at "${command.path}" is not a workbook snapshot: the grid canvas only reads a read CSV/spreadsheet document`);
|
|
3107
|
-
return workbookDocumentView(snapshot.body
|
|
3246
|
+
return workbookDocumentView(snapshot.body, {
|
|
3247
|
+
windowRows: GRID_WINDOW_ROWS
|
|
3248
|
+
});
|
|
3108
3249
|
}
|
|
3109
3250
|
if (snapshot.format !== 'csv') throw new Error(`"${command.recipeId}" at "${command.path}" is not a CSV snapshot: "delimiter"/"encoding" only override a CSV reading`);
|
|
3110
3251
|
const body = await rereadCsv(snapshot.baseUrl, {
|
|
@@ -3115,7 +3256,25 @@ async function handleGridView(state, command) {
|
|
|
3115
3256
|
...snapshot,
|
|
3116
3257
|
body
|
|
3117
3258
|
});
|
|
3118
|
-
return workbookDocumentView(body
|
|
3259
|
+
return workbookDocumentView(body, {
|
|
3260
|
+
windowRows: GRID_WINDOW_ROWS
|
|
3261
|
+
});
|
|
3262
|
+
}
|
|
3263
|
+
/**
|
|
3264
|
+
* Handles `grid-rows`: a run of one sheet's rows from the cached snapshot, for the grid that holds only a few screens of a big file at a time.
|
|
3265
|
+
*
|
|
3266
|
+
* @param state - The server state.
|
|
3267
|
+
* @param command - The command; `command.path` must already have a cached snapshot.
|
|
3268
|
+
* @returns The rows (none past the end of the sheet).
|
|
3269
|
+
* @throws Error when there is no cached snapshot or it is not a workbook.
|
|
3270
|
+
*/
|
|
3271
|
+
function handleGridRows(state, command) {
|
|
3272
|
+
const snapshot = cachedSnapshot(state.snapshots, command.recipeId, command.path);
|
|
3273
|
+
if (snapshot === undefined) throw new Error(`no cached snapshot for "${command.recipeId}" at "${command.path}": call take-snapshot first`);
|
|
3274
|
+
if (!isWorkbookDocument(snapshot.body)) throw new Error(`"${command.recipeId}" at "${command.path}" is not a workbook snapshot: grid-rows only reads a CSV/spreadsheet document`);
|
|
3275
|
+
return {
|
|
3276
|
+
rows: workbookSheetRows(snapshot.body, command.sheet, command.from, command.count)
|
|
3277
|
+
};
|
|
3119
3278
|
}
|
|
3120
3279
|
|
|
3121
3280
|
/**
|
|
@@ -3970,6 +4129,12 @@ function structureCandidates(path) {
|
|
|
3970
4129
|
tier: 'structure'
|
|
3971
4130
|
});
|
|
3972
4131
|
}
|
|
4132
|
+
// The whole tree down to the node, each level named by its stable id or classes (an id or class that looks generated is left out of it).
|
|
4133
|
+
const levels = path.slice(-5);
|
|
4134
|
+
if (levels.length > 2) candidates.push({
|
|
4135
|
+
selector: levels.map(level => simpleSelector(level)).join(' > '),
|
|
4136
|
+
tier: 'structure'
|
|
4137
|
+
});
|
|
3973
4138
|
return candidates;
|
|
3974
4139
|
}
|
|
3975
4140
|
/** `parent > tag:nth-of-type(n)`, the position-only fallback; never `nth-child`, which counts every sibling tag, not just this element's own. */
|
|
@@ -4021,7 +4186,7 @@ const TIER_ORDER = {
|
|
|
4021
4186
|
* Ordering: candidates that do not match `targetNodeId` (when given) sort
|
|
4022
4187
|
* last; among the rest, best tier first, and within a tier the fewest
|
|
4023
4188
|
* matches first (the most specific selector that still hits the target).
|
|
4024
|
-
* A candidate matching nothing is dropped entirely: it is not a real option.
|
|
4189
|
+
* Equal on all that, the selector naming more ids and classes comes first. A candidate matching nothing is dropped entirely: it is not a real option.
|
|
4025
4190
|
*
|
|
4026
4191
|
* @param html - The document to verify against (the snapshot, or the live page for the second, cross-check pass).
|
|
4027
4192
|
* @param candidates - Unranked candidates, e.g. from `candidatesFor`.
|
|
@@ -4038,7 +4203,11 @@ function rankCandidates(html, candidates, targetNodeId) {
|
|
|
4038
4203
|
hitsTarget
|
|
4039
4204
|
};
|
|
4040
4205
|
});
|
|
4041
|
-
return ranked.filter(candidate => candidate.matches > 0).sort((a, b) => Number(b.hitsTarget) - Number(a.hitsTarget) || TIER_ORDER[a.tier] - TIER_ORDER[b.tier] || a.matches - b.matches);
|
|
4206
|
+
return ranked.filter(candidate => candidate.matches > 0).sort((a, b) => Number(b.hitsTarget) - Number(a.hitsTarget) || TIER_ORDER[a.tier] - TIER_ORDER[b.tier] || a.matches - b.matches || namedParts(b.selector) - namedParts(a.selector));
|
|
4207
|
+
}
|
|
4208
|
+
/** How many ids and classes a selector names: of two that tie, the one built on names keeps working better than one made only of tags. */
|
|
4209
|
+
function namedParts(selector) {
|
|
4210
|
+
return (selector.match(/[#.]/g) ?? []).length;
|
|
4042
4211
|
}
|
|
4043
4212
|
/** The single best candidate, or `undefined` when none of them matched anything. */
|
|
4044
4213
|
function bestCandidate(html, candidates, targetNodeId) {
|
|
@@ -4165,7 +4334,7 @@ function handleInferSelector(state, command) {
|
|
|
4165
4334
|
const [pathA, pathB] = paths;
|
|
4166
4335
|
if (pathB === undefined) return itemField(html, command, pathA) ?? {
|
|
4167
4336
|
kind: 'field',
|
|
4168
|
-
field: fieldPick(html, pathA)
|
|
4337
|
+
field: fieldPick(html, pathA, pathA, command.nodeIds[0])
|
|
4169
4338
|
};
|
|
4170
4339
|
try {
|
|
4171
4340
|
const result = inferList(pathA, pathB);
|
|
@@ -4173,7 +4342,8 @@ function handleInferSelector(state, command) {
|
|
|
4173
4342
|
kind: 'unsupported',
|
|
4174
4343
|
reason: 'these two picks do not belong to the same list: pick the same field on two similar items'
|
|
4175
4344
|
};
|
|
4176
|
-
const
|
|
4345
|
+
const itemOptions = rankCandidates(html, candidatesFor(result.itemPath, false));
|
|
4346
|
+
const item = itemOptions[0];
|
|
4177
4347
|
if (item === undefined) return {
|
|
4178
4348
|
kind: 'unsupported',
|
|
4179
4349
|
reason: 'no selector matches every item of this list; try picking two items closer to each other in the markup'
|
|
@@ -4184,7 +4354,8 @@ function handleInferSelector(state, command) {
|
|
|
4184
4354
|
item: {
|
|
4185
4355
|
selector: item.selector,
|
|
4186
4356
|
tier: item.tier,
|
|
4187
|
-
matches: item.matches
|
|
4357
|
+
matches: item.matches,
|
|
4358
|
+
alternatives: alternativesOf(itemOptions)
|
|
4188
4359
|
},
|
|
4189
4360
|
field
|
|
4190
4361
|
};
|
|
@@ -4217,18 +4388,42 @@ function itemField(html, command, clicked) {
|
|
|
4217
4388
|
};
|
|
4218
4389
|
}
|
|
4219
4390
|
/** The best selector for one clicked node, `take` decided from the concrete clicked element; `rankSource` (a generalised path) is used for candidate generation when given, so a per-item-unique attribute of the one node picked cannot end up in the selector. */
|
|
4220
|
-
function fieldPick(html, clicked, rankSource = clicked) {
|
|
4391
|
+
function fieldPick(html, clicked, rankSource = clicked, targetNodeId) {
|
|
4221
4392
|
const leaf = clicked.at(-1);
|
|
4222
4393
|
const take = leaf === undefined ? 'text' : takeKindFor(leaf);
|
|
4223
|
-
const
|
|
4394
|
+
const options = rankCandidates(html, candidatesFor(rankSource), targetNodeId);
|
|
4395
|
+
const best = options[0];
|
|
4224
4396
|
if (best === undefined) throw new Error('no selector matches the picked node — this should not happen, since the node came from this same document');
|
|
4397
|
+
const generatedId = leaf?.id !== undefined && !isStableId(leaf.id) ? leaf.id : undefined;
|
|
4225
4398
|
return {
|
|
4226
4399
|
selector: best.selector,
|
|
4227
4400
|
tier: best.tier,
|
|
4228
4401
|
take,
|
|
4229
|
-
matches: best.matches
|
|
4402
|
+
matches: best.matches,
|
|
4403
|
+
alternatives: alternativesOf(options),
|
|
4404
|
+
...(generatedId !== undefined && {
|
|
4405
|
+
generatedId
|
|
4406
|
+
})
|
|
4230
4407
|
};
|
|
4231
4408
|
}
|
|
4409
|
+
/** How many other selectors a person is offered at most. */
|
|
4410
|
+
const MAX_ALTERNATIVES = 6;
|
|
4411
|
+
/** The verified candidates as the options shown to the person: the ones that reach the clicked node, each selector once. */
|
|
4412
|
+
function alternativesOf(options) {
|
|
4413
|
+
const seen = new Set();
|
|
4414
|
+
const alternatives = [];
|
|
4415
|
+
for (const option of options) {
|
|
4416
|
+
if (!option.hitsTarget || seen.has(option.selector)) continue;
|
|
4417
|
+
seen.add(option.selector);
|
|
4418
|
+
alternatives.push({
|
|
4419
|
+
selector: option.selector,
|
|
4420
|
+
tier: option.tier,
|
|
4421
|
+
matches: option.matches
|
|
4422
|
+
});
|
|
4423
|
+
if (alternatives.length === MAX_ALTERNATIVES) break;
|
|
4424
|
+
}
|
|
4425
|
+
return alternatives;
|
|
4426
|
+
}
|
|
4232
4427
|
|
|
4233
4428
|
/** A leaf element's own text longer than this is cut, with an ellipsis. */
|
|
4234
4429
|
const TEXT_LIMIT = 80;
|
|
@@ -6102,6 +6297,10 @@ function dispatch(command, state) {
|
|
|
6102
6297
|
{
|
|
6103
6298
|
return handleGridView(state, command);
|
|
6104
6299
|
}
|
|
6300
|
+
case 'grid-rows':
|
|
6301
|
+
{
|
|
6302
|
+
return Promise.resolve(handleGridRows(state, command));
|
|
6303
|
+
}
|
|
6105
6304
|
case 'grid-preview':
|
|
6106
6305
|
{
|
|
6107
6306
|
return Promise.resolve(handleGridPreview(state, command));
|
|
@@ -6189,5 +6388,5 @@ async function main(argv, options = {}) {
|
|
|
6189
6388
|
process.on('SIGTERM', shutdown);
|
|
6190
6389
|
}
|
|
6191
6390
|
|
|
6192
|
-
export { chooseFolderCommandSchema, chooseFolderViewSchema, deckChartSeriesViewSchema, deckChartViewSchema, deckDocumentViewSchema, deckPreviewCommandSchema, deckPreviewOptionsSchema, deckShapeViewSchema, deckSlideViewSchema, deckTablePreviewMatchSchema, deckTablePreviewViewSchema, deckViewCommandSchema, detectUrlCommandSchema, detectUrlViewSchema, documentTreeCommandSchema, documentTreeNodeViewSchema, documentTreeViewSchema, domTreeNodeViewSchema, explainWhyCommandSchema, fetchStartPage, fetchStartPageCommandSchema, fieldPickSchema, fieldTraceSchema, gridCellViewSchema, gridMergeViewSchema, gridPreviewCommandSchema, gridPreviewOptionsSchema, gridSheetViewSchema, gridTablePreviewMatchSchema, gridTablePreviewViewSchema, gridViewCommandSchema, importDocument, importDocumentCommandSchema, importDocumentViewSchema, inferSelectorCommandSchema, inferSelectorViewSchema, inspectPageCommandSchema, inspectViewSchema, loadRecipePair, loadedHooksSchema, main, missingWhyTargetSchema, observedResponseSchema, openPathCommandSchema, openPathViewSchema, openWorkspace, openWorkspaceCommandSchema, outlineBracketSchema, outlineCardSchema, outlineNodeSchema, outlineViewSchema, pageDataFindingSchema, pdfCellViewSchema, pdfDocumentViewSchema, pdfPageViewSchema, pdfRowViewSchema, pdfViewCommandSchema, recipeIssueSchema, recipeListingSchema, recordEventSchema, recordRejectedEventSchema, recordingCardEventSchema, recordingNoteEventSchema, recordingStoppedEventSchema, regionPreviewCommandSchema, regionPreviewMatchSchema, regionPreviewViewSchema, rejectedWhyTargetSchema, responsesSeenCommandSchema, responsesSeenViewSchema, runFinishedEventSchema, runSample, runSampleCommandSchema, sampleBudgetSchema, sampleRunRecordSchema, sampleRunViewSchema, saveOutlineCommandSchema, saveRecipe, saveRecipeCommandSchema, sentencePartSchema, snapshotViewSchema, startPageViewSchema, startRecordingCommandSchema, startStudioServer, stopRecordingCommandSchema, stopRunCommandSchema, stoppedBySchema, studioCommandSchema, studioEventSchema, tablePreviewBandSchema, tablePreviewCommandSchema, tablePreviewMatchSchema, tablePreviewOptionsSchema, tablePreviewTableSchema, tablePreviewViewSchema, takeSnapshotCommandSchema, traceLineEventSchema, verifySelectorCommandSchema, verifySelectorViewSchema, whyTargetSchema, whyViewSchema, workbookDocumentViewSchema, workspaceChangedEventSchema, workspaceViewSchema };
|
|
6391
|
+
export { chooseFolderCommandSchema, chooseFolderViewSchema, deckChartSeriesViewSchema, deckChartViewSchema, deckDocumentViewSchema, deckPreviewCommandSchema, deckPreviewOptionsSchema, deckShapeViewSchema, deckSlideViewSchema, deckTablePreviewMatchSchema, deckTablePreviewViewSchema, deckViewCommandSchema, detectUrlCommandSchema, detectUrlViewSchema, documentTreeCommandSchema, documentTreeNodeViewSchema, documentTreeViewSchema, domTreeNodeViewSchema, explainWhyCommandSchema, fetchStartPage, fetchStartPageCommandSchema, fieldPickSchema, fieldTraceSchema, gridCellViewSchema, gridMergeViewSchema, gridPreviewCommandSchema, gridPreviewOptionsSchema, gridRowsCommandSchema, gridRowsViewSchema, gridSheetViewSchema, gridTablePreviewMatchSchema, gridTablePreviewViewSchema, gridViewCommandSchema, importDocument, importDocumentCommandSchema, importDocumentViewSchema, inferSelectorCommandSchema, inferSelectorViewSchema, inspectPageCommandSchema, inspectViewSchema, loadRecipePair, loadedHooksSchema, main, missingWhyTargetSchema, observedResponseSchema, openPathCommandSchema, openPathViewSchema, openWorkspace, openWorkspaceCommandSchema, outlineBracketSchema, outlineCardSchema, outlineNodeSchema, outlineViewSchema, pageDataFindingSchema, pdfCellViewSchema, pdfDocumentViewSchema, pdfPageViewSchema, pdfRowViewSchema, pdfViewCommandSchema, recipeIssueSchema, recipeListingSchema, recordEventSchema, recordRejectedEventSchema, recordingCardEventSchema, recordingNoteEventSchema, recordingStoppedEventSchema, regionPreviewCommandSchema, regionPreviewMatchSchema, regionPreviewViewSchema, rejectedWhyTargetSchema, responsesSeenCommandSchema, responsesSeenViewSchema, runFinishedEventSchema, runSample, runSampleCommandSchema, sampleBudgetSchema, sampleRunRecordSchema, sampleRunViewSchema, saveOutlineCommandSchema, saveRecipe, saveRecipeCommandSchema, selectorAlternativeSchema, sentencePartSchema, snapshotViewSchema, startPageViewSchema, startRecordingCommandSchema, startStudioServer, stopRecordingCommandSchema, stopRunCommandSchema, stoppedBySchema, studioCommandSchema, studioEventSchema, tablePreviewBandSchema, tablePreviewCommandSchema, tablePreviewMatchSchema, tablePreviewOptionsSchema, tablePreviewTableSchema, tablePreviewViewSchema, takeSnapshotCommandSchema, traceLineEventSchema, verifySelectorCommandSchema, verifySelectorViewSchema, whyTargetSchema, whyViewSchema, workbookDocumentViewSchema, workspaceChangedEventSchema, workspaceViewSchema };
|
|
6193
6392
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -3,6 +3,8 @@ export type { UrlKind } from './detect-url.use-case';
|
|
|
3
3
|
export { fetchStartPage } from './fetch-start-page.use-case';
|
|
4
4
|
export { takeSnapshot } from './take-snapshot.use-case';
|
|
5
5
|
export type { SnapshotResult } from './take-snapshot.use-case';
|
|
6
|
+
export { inlineLocalImages } from './inline-local-images.use-case';
|
|
7
|
+
export type { InlinedImages } from './inline-local-images.use-case';
|
|
6
8
|
export { rewriteDocument } from './rewrite-document.mapper';
|
|
7
9
|
export type { RewrittenDocument } from './rewrite-document.mapper';
|
|
8
10
|
export { hiddenMarksScript, HIDDEN_ATTRIBUTE } from './hidden-marks.algorithm';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** What `inlineLocalImages` made of a document. */
|
|
2
|
+
export interface InlinedImages {
|
|
3
|
+
html: string;
|
|
4
|
+
/** How many images were embedded. */
|
|
5
|
+
inlined: number;
|
|
6
|
+
/** How many pictures could not be found next to the file (or were too big), so they stay as they were. */
|
|
7
|
+
missing: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A document read from a file (a Markdown file, say) names its pictures by paths beside it, which the browser showing it cannot open. The
|
|
11
|
+
* pictures that sit in the document's own folder are embedded in the page as data addresses, so they show; ones that are not there are counted
|
|
12
|
+
* so the person is told. Nothing outside the document's folder is ever read.
|
|
13
|
+
*
|
|
14
|
+
* @param html - The document as HTML, its addresses already made absolute against `documentUrl`.
|
|
15
|
+
* @param documentUrl - The document's own `file:` address.
|
|
16
|
+
* @returns The page with the pictures embedded, and how many were embedded and how many could not be.
|
|
17
|
+
*/
|
|
18
|
+
export declare function inlineLocalImages(html: string, documentUrl: string): Promise<InlinedImages>;
|
|
19
|
+
//# sourceMappingURL=inline-local-images.use-case.d.ts.map
|
|
@@ -14,7 +14,7 @@ export interface RankedCandidate extends SelectorCandidate {
|
|
|
14
14
|
* Ordering: candidates that do not match `targetNodeId` (when given) sort
|
|
15
15
|
* last; among the rest, best tier first, and within a tier the fewest
|
|
16
16
|
* matches first (the most specific selector that still hits the target).
|
|
17
|
-
* A candidate matching nothing is dropped entirely: it is not a real option.
|
|
17
|
+
* Equal on all that, the selector naming more ids and classes comes first. A candidate matching nothing is dropped entirely: it is not a real option.
|
|
18
18
|
*
|
|
19
19
|
* @param html - The document to verify against (the snapshot, or the live page for the second, cross-check pass).
|
|
20
20
|
* @param candidates - Unranked candidates, e.g. from `candidatesFor`.
|
|
@@ -8,6 +8,6 @@ export { previewDeckTable, previewGridTable, previewPdfTable } from './table-pre
|
|
|
8
8
|
export type { DeckTablePreviewMatch, DeckTablePreviewOptions, DeckTablePreviewResult, GridTablePreviewMatch, GridTablePreviewOptions, GridTablePreviewResult, TablePreviewMatch, TablePreviewOptions, TablePreviewResult } from './table-preview.use-case.js';
|
|
9
9
|
export { previewRegion } from './region-preview.use-case.js';
|
|
10
10
|
export type { RegionPreviewResult, RegionPreviewMatch } from './region-preview.use-case.js';
|
|
11
|
-
export { workbookDocumentView } from './workbook-view.mapper.js';
|
|
11
|
+
export { workbookDocumentView, workbookSheetRows } from './workbook-view.mapper.js';
|
|
12
12
|
export type { GridCellType, GridCellView, GridMergeView, GridSheetView, WorkbookDocumentView } from './workbook-view.mapper.js';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -22,7 +22,10 @@ export interface GridSheetView {
|
|
|
22
22
|
hiddenRows: number[];
|
|
23
23
|
/** The widest row's own length, ragged rows included — for the grid to size its columns. */
|
|
24
24
|
columnCount: number;
|
|
25
|
+
/** The sheet's rows; only the first window of them when `rowCount` is set (the rest are fetched with `grid-rows`). */
|
|
25
26
|
rows: GridCellView[][];
|
|
27
|
+
/** How many rows the sheet has, set only when `rows` holds just the first window of them. */
|
|
28
|
+
rowCount?: number;
|
|
26
29
|
merges: GridMergeView[];
|
|
27
30
|
/** Column widths in characters by 0-based column, as the spreadsheet stores them; absent keys are columns the file does not size. */
|
|
28
31
|
columnWidths?: Record<string, number>;
|
|
@@ -55,5 +58,18 @@ export interface WorkbookDocumentView {
|
|
|
55
58
|
* @param document - The read workbook (a spreadsheet or a CSV).
|
|
56
59
|
* @returns The view.
|
|
57
60
|
*/
|
|
58
|
-
export declare function workbookDocumentView(document: WorkbookDocument
|
|
61
|
+
export declare function workbookDocumentView(document: WorkbookDocument, options?: {
|
|
62
|
+
windowRows?: number;
|
|
63
|
+
}): WorkbookDocumentView;
|
|
64
|
+
/**
|
|
65
|
+
* A run of one sheet's rows, typed, for a grid that only holds the screens around where it is scrolled to (the rest of a big file is never
|
|
66
|
+
* sent to the browser until it is needed).
|
|
67
|
+
*
|
|
68
|
+
* @param document - The read workbook.
|
|
69
|
+
* @param sheetIndex - Which sheet, 0-based.
|
|
70
|
+
* @param from - The first row, 0-based.
|
|
71
|
+
* @param count - How many rows at most.
|
|
72
|
+
* @returns The rows (fewer at the end of the sheet, none past it).
|
|
73
|
+
*/
|
|
74
|
+
export declare function workbookSheetRows(document: WorkbookDocument, sheetIndex: number, from: number, count: number): GridCellView[][];
|
|
59
75
|
//# sourceMappingURL=workbook-view.mapper.d.ts.map
|
package/dist/src/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export { runSample, loadRecipePair } from './sample-run/index.js';
|
|
|
9
9
|
export type { RecipePair, SampleRunCallbacks, SampleRunHandle, SampleRunRecord, SampleRunRejected, SampleRunResult, SampleStepSummary, SampleStoppedBy } from './sample-run/index.js';
|
|
10
10
|
export { fetchStartPage } from './page-snapshot/index.js';
|
|
11
11
|
export type { WhyFacts, WhyStepFact } from './explain-why/index.js';
|
|
12
|
-
export { sampleBudgetSchema, openWorkspaceCommandSchema, chooseFolderCommandSchema, openPathCommandSchema, importDocumentCommandSchema, runSampleCommandSchema, stopRunCommandSchema, saveRecipeCommandSchema, fetchStartPageCommandSchema, detectUrlCommandSchema, saveOutlineCommandSchema, takeSnapshotCommandSchema, verifySelectorCommandSchema, inferSelectorCommandSchema, missingWhyTargetSchema, rejectedWhyTargetSchema, whyTargetSchema, explainWhyCommandSchema, studioCommandSchema, chooseFolderViewSchema, openPathViewSchema, importDocumentViewSchema, stoppedBySchema, fieldTraceSchema, traceLineEventSchema, recordEventSchema, recordRejectedEventSchema, runFinishedEventSchema, workspaceChangedEventSchema, studioEventSchema, loadedHooksSchema, recipeIssueSchema, recipeListingSchema, workspaceViewSchema, sampleRunRecordSchema, sampleRunViewSchema, startPageViewSchema, detectUrlViewSchema, snapshotViewSchema, verifySelectorViewSchema, fieldPickSchema, inferSelectorViewSchema, sentencePartSchema, outlineCardSchema, outlineBracketSchema, outlineNodeSchema, outlineViewSchema, whyViewSchema, inspectPageCommandSchema, responsesSeenCommandSchema, documentTreeCommandSchema, pdfViewCommandSchema, tablePreviewOptionsSchema, tablePreviewCommandSchema, regionPreviewCommandSchema, regionPreviewMatchSchema, regionPreviewViewSchema, gridViewCommandSchema, gridPreviewOptionsSchema, gridPreviewCommandSchema, deckViewCommandSchema, deckPreviewOptionsSchema, deckPreviewCommandSchema, domTreeNodeViewSchema, pageDataFindingSchema, inspectViewSchema, observedResponseSchema, responsesSeenViewSchema, documentTreeNodeViewSchema, documentTreeViewSchema, pdfCellViewSchema, pdfRowViewSchema, pdfPageViewSchema, pdfDocumentViewSchema, tablePreviewTableSchema, tablePreviewBandSchema, tablePreviewMatchSchema, tablePreviewViewSchema, gridCellViewSchema, gridMergeViewSchema, gridSheetViewSchema, workbookDocumentViewSchema, gridTablePreviewMatchSchema, gridTablePreviewViewSchema, deckShapeViewSchema, deckChartSeriesViewSchema, deckChartViewSchema, deckSlideViewSchema, deckDocumentViewSchema, deckTablePreviewMatchSchema, deckTablePreviewViewSchema, startRecordingCommandSchema, stopRecordingCommandSchema, recordingCardEventSchema, recordingNoteEventSchema, recordingStoppedEventSchema, } from './studio-api/index.js';
|
|
13
|
-
export type { SampleBudget, OpenWorkspaceCommand, ChooseFolderCommand, OpenPathCommand, ImportDocumentCommand, RunSampleCommand, StopRunCommand, SaveRecipeCommand, FetchStartPageCommand, DetectUrlCommand, SaveOutlineCommand, TakeSnapshotCommand, VerifySelectorCommand, InferSelectorCommand, MissingWhyTarget, RejectedWhyTarget, WhyTarget, ExplainWhyCommand, InspectPageCommand, ResponsesSeenCommand, DocumentTreeCommand, PdfViewCommand, TablePreviewOptions, TablePreviewCommand, RegionPreviewCommand, GridViewCommand, GridPreviewOptions, GridPreviewCommand, DeckViewCommand, DeckPreviewOptions, DeckPreviewCommand, StudioCommand, ChooseFolderView, OpenPathView, ImportDocumentView, RegionPreviewMatchView, RegionPreviewView, StoppedBy, FieldTraceView, TraceLineEvent, RecordEvent, RecordRejectedEvent, RunFinishedEvent, WorkspaceChangedEvent, StudioEvent, LoadedHooks, RecipeIssue, RecipeListing, WorkspaceView, SampleRunView, StartPageView, DetectUrlView, SnapshotView, VerifySelectorView, FieldPick, InferSelectorView, SentencePart, OutlineCard, OutlineBracket, OutlineNode, OutlineView, WhyView, DomTreeNodeView, PageDataKind, PageDataFindingView, InspectView, ObservedResponseView, ResponsesSeenView, DocumentTreeNodeView, DocumentTreeView, PdfCellView, PdfRowView, PdfPageView, PdfDocumentView, TablePreviewTableView, TablePreviewBandView, TablePreviewMatchView, TablePreviewView, GridCellView, GridMergeView, GridSheetView, WorkbookDocumentView, GridTablePreviewMatchView, GridTablePreviewView, DeckShapeView, DeckChartSeriesView, DeckChartView, DeckSlideView, DeckDocumentView, DeckTablePreviewMatchView, DeckTablePreviewView, StartRecordingCommand, StopRecordingCommand, RecordingCardEvent, RecordingNoteEvent, RecordingStoppedEvent, } from './studio-api/index.js';
|
|
12
|
+
export { sampleBudgetSchema, openWorkspaceCommandSchema, chooseFolderCommandSchema, openPathCommandSchema, importDocumentCommandSchema, runSampleCommandSchema, stopRunCommandSchema, saveRecipeCommandSchema, fetchStartPageCommandSchema, detectUrlCommandSchema, saveOutlineCommandSchema, takeSnapshotCommandSchema, verifySelectorCommandSchema, inferSelectorCommandSchema, missingWhyTargetSchema, rejectedWhyTargetSchema, whyTargetSchema, explainWhyCommandSchema, studioCommandSchema, chooseFolderViewSchema, openPathViewSchema, importDocumentViewSchema, stoppedBySchema, fieldTraceSchema, traceLineEventSchema, recordEventSchema, recordRejectedEventSchema, runFinishedEventSchema, workspaceChangedEventSchema, studioEventSchema, loadedHooksSchema, recipeIssueSchema, recipeListingSchema, workspaceViewSchema, sampleRunRecordSchema, sampleRunViewSchema, startPageViewSchema, detectUrlViewSchema, snapshotViewSchema, verifySelectorViewSchema, fieldPickSchema, inferSelectorViewSchema, selectorAlternativeSchema, sentencePartSchema, outlineCardSchema, outlineBracketSchema, outlineNodeSchema, outlineViewSchema, whyViewSchema, inspectPageCommandSchema, responsesSeenCommandSchema, documentTreeCommandSchema, pdfViewCommandSchema, tablePreviewOptionsSchema, tablePreviewCommandSchema, regionPreviewCommandSchema, regionPreviewMatchSchema, regionPreviewViewSchema, gridViewCommandSchema, gridRowsCommandSchema, gridPreviewOptionsSchema, gridPreviewCommandSchema, deckViewCommandSchema, deckPreviewOptionsSchema, deckPreviewCommandSchema, domTreeNodeViewSchema, pageDataFindingSchema, inspectViewSchema, observedResponseSchema, responsesSeenViewSchema, documentTreeNodeViewSchema, documentTreeViewSchema, pdfCellViewSchema, pdfRowViewSchema, pdfPageViewSchema, pdfDocumentViewSchema, tablePreviewTableSchema, tablePreviewBandSchema, tablePreviewMatchSchema, tablePreviewViewSchema, gridCellViewSchema, gridMergeViewSchema, gridRowsViewSchema, gridSheetViewSchema, workbookDocumentViewSchema, gridTablePreviewMatchSchema, gridTablePreviewViewSchema, deckShapeViewSchema, deckChartSeriesViewSchema, deckChartViewSchema, deckSlideViewSchema, deckDocumentViewSchema, deckTablePreviewMatchSchema, deckTablePreviewViewSchema, startRecordingCommandSchema, stopRecordingCommandSchema, recordingCardEventSchema, recordingNoteEventSchema, recordingStoppedEventSchema, } from './studio-api/index.js';
|
|
13
|
+
export type { SampleBudget, OpenWorkspaceCommand, ChooseFolderCommand, OpenPathCommand, ImportDocumentCommand, RunSampleCommand, StopRunCommand, SaveRecipeCommand, FetchStartPageCommand, DetectUrlCommand, SaveOutlineCommand, TakeSnapshotCommand, VerifySelectorCommand, InferSelectorCommand, MissingWhyTarget, RejectedWhyTarget, WhyTarget, ExplainWhyCommand, InspectPageCommand, ResponsesSeenCommand, DocumentTreeCommand, PdfViewCommand, TablePreviewOptions, TablePreviewCommand, RegionPreviewCommand, GridViewCommand, GridRowsCommand, GridPreviewOptions, GridPreviewCommand, DeckViewCommand, DeckPreviewOptions, DeckPreviewCommand, StudioCommand, ChooseFolderView, OpenPathView, ImportDocumentView, RegionPreviewMatchView, RegionPreviewView, StoppedBy, FieldTraceView, TraceLineEvent, RecordEvent, RecordRejectedEvent, RunFinishedEvent, WorkspaceChangedEvent, StudioEvent, LoadedHooks, RecipeIssue, RecipeListing, WorkspaceView, SampleRunView, StartPageView, DetectUrlView, SnapshotView, VerifySelectorView, FieldPick, InferSelectorView, SelectorAlternative, SentencePart, OutlineCard, OutlineBracket, OutlineNode, OutlineView, WhyView, DomTreeNodeView, PageDataKind, PageDataFindingView, InspectView, ObservedResponseView, ResponsesSeenView, DocumentTreeNodeView, DocumentTreeView, PdfCellView, PdfRowView, PdfPageView, PdfDocumentView, TablePreviewTableView, TablePreviewBandView, TablePreviewMatchView, TablePreviewView, GridCellView, GridMergeView, GridRowsView, GridSheetView, WorkbookDocumentView, GridTablePreviewMatchView, GridTablePreviewView, DeckShapeView, DeckChartSeriesView, DeckChartView, DeckSlideView, DeckDocumentView, DeckTablePreviewMatchView, DeckTablePreviewView, StartRecordingCommand, StopRecordingCommand, RecordingCardEvent, RecordingNoteEvent, RecordingStoppedEvent, } from './studio-api/index.js';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,6 +3,8 @@ export type { UrlKind } from './detect-url.use-case.js';
|
|
|
3
3
|
export { fetchStartPage } from './fetch-start-page.use-case.js';
|
|
4
4
|
export { takeSnapshot } from './take-snapshot.use-case.js';
|
|
5
5
|
export type { SnapshotResult } from './take-snapshot.use-case.js';
|
|
6
|
+
export { inlineLocalImages } from './inline-local-images.use-case.js';
|
|
7
|
+
export type { InlinedImages } from './inline-local-images.use-case.js';
|
|
6
8
|
export { rewriteDocument } from './rewrite-document.mapper.js';
|
|
7
9
|
export type { RewrittenDocument } from './rewrite-document.mapper.js';
|
|
8
10
|
export { hiddenMarksScript, HIDDEN_ATTRIBUTE } from './hidden-marks.algorithm.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** What `inlineLocalImages` made of a document. */
|
|
2
|
+
export interface InlinedImages {
|
|
3
|
+
html: string;
|
|
4
|
+
/** How many images were embedded. */
|
|
5
|
+
inlined: number;
|
|
6
|
+
/** How many pictures could not be found next to the file (or were too big), so they stay as they were. */
|
|
7
|
+
missing: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A document read from a file (a Markdown file, say) names its pictures by paths beside it, which the browser showing it cannot open. The
|
|
11
|
+
* pictures that sit in the document's own folder are embedded in the page as data addresses, so they show; ones that are not there are counted
|
|
12
|
+
* so the person is told. Nothing outside the document's folder is ever read.
|
|
13
|
+
*
|
|
14
|
+
* @param html - The document as HTML, its addresses already made absolute against `documentUrl`.
|
|
15
|
+
* @param documentUrl - The document's own `file:` address.
|
|
16
|
+
* @returns The page with the pictures embedded, and how many were embedded and how many could not be.
|
|
17
|
+
*/
|
|
18
|
+
export declare function inlineLocalImages(html: string, documentUrl: string): Promise<InlinedImages>;
|
|
19
|
+
//# sourceMappingURL=inline-local-images.use-case.d.ts.map
|
|
@@ -14,7 +14,7 @@ export interface RankedCandidate extends SelectorCandidate {
|
|
|
14
14
|
* Ordering: candidates that do not match `targetNodeId` (when given) sort
|
|
15
15
|
* last; among the rest, best tier first, and within a tier the fewest
|
|
16
16
|
* matches first (the most specific selector that still hits the target).
|
|
17
|
-
* A candidate matching nothing is dropped entirely: it is not a real option.
|
|
17
|
+
* Equal on all that, the selector naming more ids and classes comes first. A candidate matching nothing is dropped entirely: it is not a real option.
|
|
18
18
|
*
|
|
19
19
|
* @param html - The document to verify against (the snapshot, or the live page for the second, cross-check pass).
|
|
20
20
|
* @param candidates - Unranked candidates, e.g. from `candidatesFor`.
|