Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store original device layout was scraped with #1474

Merged
merged 26 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1c1981a
Add device parameter to element constructor
rcj-siteimprove Oct 2, 2023
ba6ed29
Replace `box` property by `boxes: Cache<Device, Rectangle>`
rcj-siteimprove Oct 2, 2023
a1ecb84
Add dependency alfa-dom -> alfa-device to package.json
rcj-siteimprove Oct 2, 2023
17a78c6
Add device to tests using box
rcj-siteimprove Oct 2, 2023
65d65e4
Extract API
github-actions[bot] Oct 9, 2023
ea9af95
Merge branch 'main' into store-original-device
rcj-siteimprove Oct 10, 2023
660d161
Add unlisted dependency
rcj-siteimprove Oct 10, 2023
e2d0f82
Merge remote-tracking branch 'refs/remotes/origin/store-original-devi…
rcj-siteimprove Oct 10, 2023
a7ce98d
Add dependency in tsconfig too
rcj-siteimprove Oct 10, 2023
a86b807
Add `OPTIONS` type parameter to `Serializable` interface
rcj-siteimprove Oct 11, 2023
bacee65
Add serialization options
rcj-siteimprove Oct 11, 2023
1085f19
Extract API
github-actions[bot] Oct 12, 2023
5765eb8
Clean up
rcj-siteimprove Oct 12, 2023
74bc4b8
Add changesets
rcj-siteimprove Oct 12, 2023
fb320f9
Merge branch 'main' into store-original-device
rcj-siteimprove Oct 12, 2023
8fb0953
Update .changeset/chilled-laws-hammer.md
rcj-siteimprove Oct 12, 2023
5e26be2
Update packages/alfa-dom/src/node.ts
rcj-siteimprove Oct 12, 2023
1582d10
Remove placeholder function
rcj-siteimprove Oct 13, 2023
4b56f2a
Removed unused imports and dependencies
rcj-siteimprove Oct 13, 2023
58705f4
Remove package the right way
rcj-siteimprove Oct 13, 2023
667486a
Extract API
github-actions[bot] Oct 13, 2023
44ff092
Merge branch 'main' into store-original-device
rcj-siteimprove Oct 18, 2023
218e0df
Update yarn.lock
rcj-siteimprove Oct 18, 2023
356d79c
Revert yarn.lock update
rcj-siteimprove Oct 18, 2023
34251ee
Revert all changes to *.api.md as something seems to have gone wrong
rcj-siteimprove Oct 18, 2023
6811b12
Extract API
github-actions[bot] Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/beige-colts-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@siteimprove/alfa-style": minor
---

**Breaking:** Function `getBoundingBox` was removed.

Use `Element#getBoundingBox` instead.
7 changes: 7 additions & 0 deletions .changeset/brave-dolphins-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@siteimprove/alfa-json": minor
---

**Added:** `Serializable` interface now optionally accepts serialization options.

When implementing the interface a type parameter can be supplied and `toJSON` can optionally take an object of that type that can be used for changing the serialization behavior.
7 changes: 7 additions & 0 deletions .changeset/chilled-laws-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@siteimprove/alfa-dom": minor
---

**Breaking:** `Element#of` now requires the device used when scraping a page in order to store a box.

This ensures that the boxes of the elements will be stored with and only be accessible for the same device instance. If no device is provided, no box is stored with the element.
7 changes: 7 additions & 0 deletions .changeset/metal-planets-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@siteimprove/alfa-tree": minor
---

**Added:** Optional serialization options type parameter added to abstract `Node` class.

This is passed to the `Serializable` interface to allow implementers to supply the serialization options type.
7 changes: 7 additions & 0 deletions .changeset/slow-moles-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@siteimprove/alfa-dom": minor
---

**Added:** `Document#toJSON` now optionally accepts serialization options containing device.

The options will be passed down to all children of the document and used by `Element` to serialize the box corresponding to the device.
52 changes: 29 additions & 23 deletions docs/review/api/alfa-dom.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
```ts

import { Array as Array_2 } from '@siteimprove/alfa-array';
import { Device } from '@siteimprove/alfa-device';
import * as earl from '@siteimprove/alfa-earl';
import { Equatable } from '@siteimprove/alfa-equatable';
import { Flags } from '@siteimprove/alfa-flags';
Expand Down Expand Up @@ -227,15 +228,15 @@ export class Document extends Node<"document"> {
// (undocumented)
get style(): Iterable<Sheet>;
// (undocumented)
toJSON(): Document.JSON;
toJSON(options?: Node.SerializationOptions): Document.JSON;
// (undocumented)
toString(): string;
}

// @public (undocumented)
export namespace Document {
// @internal (undocumented)
export function fromDocument(json: JSON): Trampoline<Document>;
export function fromDocument(json: JSON, device?: Device): Trampoline<Document>;
// (undocumented)
export function isDocument(value: unknown): value is Document;
// (undocumented)
Expand All @@ -262,14 +263,14 @@ export class Element<N extends string = string> extends Node<"element"> implemen
// (undocumented)
get attributes(): Sequence<Attribute>;
// (undocumented)
get box(): Option<Rectangle>;
// (undocumented)
children(options?: Node.Traversal): Sequence<Node>;
// (undocumented)
get classes(): Sequence<string>;
// (undocumented)
get content(): Option<Document>;
// (undocumented)
getBoundingBox(device: Device): Option<Rectangle>;
// (undocumented)
get id(): Option<string>;
// @internal (undocumented)
protected _internalPath(options?: Node.Traversal): string;
Expand All @@ -280,7 +281,7 @@ export class Element<N extends string = string> extends Node<"element"> implemen
// (undocumented)
get namespace(): Option<Namespace>;
// (undocumented)
static of<N extends string = string>(namespace: Option<Namespace>, prefix: Option<string>, name: N, attributes?: Iterable_2<Attribute>, children?: Iterable_2<Node>, style?: Option<Block>, box?: Option<Rectangle>): Element<N>;
static of<N extends string = string>(namespace: Option<Namespace>, prefix: Option<string>, name: N, attributes?: Iterable_2<Attribute>, children?: Iterable_2<Node>, style?: Option<Block>, box?: Option<Rectangle>, device?: Option<Device>): Element<N>;
// (undocumented)
parent(options?: Node.Traversal): Option<Node>;
// (undocumented)
Expand All @@ -294,15 +295,15 @@ export class Element<N extends string = string> extends Node<"element"> implemen
// (undocumented)
tabIndex(): Option<number>;
// (undocumented)
toJSON(): Element.JSON<N>;
toJSON(options?: Node.SerializationOptions): Element.JSON<N>;
// (undocumented)
toString(): string;
}

// @public (undocumented)
export namespace Element {
// @internal (undocumented)
export function fromElement<N extends string = string>(json: JSON<N>): Trampoline<Element<N>>;
export function fromElement<N extends string = string>(json: JSON<N>, device?: Device): Trampoline<Element<N>>;
// (undocumented)
export function isElement(value: unknown): value is Element;
// (undocumented)
Expand Down Expand Up @@ -398,7 +399,7 @@ export class Fragment extends Node<"fragment"> {
// @public (undocumented)
export namespace Fragment {
// @internal (undocumented)
export function fromFragment(json: JSON): Trampoline<Fragment>;
export function fromFragment(json: JSON, device?: Device): Trampoline<Fragment>;
// (undocumented)
export function isFragment(value: unknown): value is Fragment;
// (undocumented)
Expand Down Expand Up @@ -442,7 +443,7 @@ export namespace GroupingRule {
}

// @public (undocumented)
export function h<N extends string = string>(name: N, attributes?: Array<Attribute> | Record<string, string | boolean>, children?: Array<Node | string>, style?: Array<Declaration> | Record<string, string>, box?: Rectangle): Element<N>;
export function h<N extends string = string>(name: N, attributes?: Array<Attribute> | Record<string, string | boolean>, children?: Array<Node | string>, style?: Array<Declaration> | Record<string, string>, box?: Rectangle, device?: Device): Element<N>;

// @public (undocumented)
export namespace h {
Expand All @@ -455,7 +456,7 @@ export namespace h {
// (undocumented)
export function document(children: Array<Node | string>, style?: Array<Sheet>): Document;
// (undocumented)
export function element<N extends string = string>(name: N, attributes?: Array<Attribute> | Record<string, string | boolean>, children?: Array<Node | string>, style?: Array<Declaration> | Record<string, string>, namespace?: Namespace, box?: Rectangle): Element<N>;
export function element<N extends string = string>(name: N, attributes?: Array<Attribute> | Record<string, string | boolean>, children?: Array<Node | string>, style?: Array<Declaration> | Record<string, string>, namespace?: Namespace, box?: Rectangle, device?: Device): Element<N>;
// (undocumented)
export function fragment(children: Array<Node | string>): Fragment;
// (undocumented)
Expand Down Expand Up @@ -494,7 +495,7 @@ function hasAttribute(predicate: Predicate<Attribute>): Predicate<Element>;
function hasAttribute(name: string, value?: Predicate<string>): Predicate<Element>;

// @public (undocumented)
function hasBox(predicate?: Predicate<Rectangle>): Predicate<Element>;
function hasBox(predicate: Predicate<Rectangle> | undefined, device: Device): Predicate<Element>;

// @public (undocumented)
function hasChild(predicate: Predicate<Node>, options?: Node.Traversal): Predicate<Node>;
Expand Down Expand Up @@ -797,7 +798,7 @@ export namespace NamespaceRule {
}

// @public (undocumented)
export abstract class Node<T extends string = string> extends tree.Node<Node.Traversal.Flag, T> implements earl.Serializable<Node.EARL>, json.Serializable<tree.Node.JSON<T>>, sarif.Serializable<sarif.Location> {
export abstract class Node<T extends string = string> extends tree.Node<Node.Traversal.Flag, T> implements earl.Serializable<Node.EARL>, json.Serializable<tree.Node.JSON<T>, Node.SerializationOptions>, sarif.Serializable<sarif.Location> {
protected constructor(children: Array<Node>, type: T);
// (undocumented)
equals(value: Node): boolean;
Expand Down Expand Up @@ -896,32 +897,37 @@ export namespace Node {
};
}
// (undocumented)
export function from(json: Element.JSON): Element;
export function from(json: Element.JSON, device?: Device): Element;
// (undocumented)
export function from(json: Attribute.JSON): Attribute;
export function from(json: Attribute.JSON, device?: Device): Attribute;
// (undocumented)
export function from(json: Text.JSON): Text;
export function from(json: Text.JSON, device?: Device): Text;
// (undocumented)
export function from(json: Comment.JSON): Comment;
export function from(json: Comment.JSON, device?: Device): Comment;
// (undocumented)
export function from(json: Document.JSON, device?: Device): Document;
const flatTree: Traversal;
const fullTree: Traversal;
const composedNested: Traversal;
// (undocumented)
export function from(json: Document.JSON): Document;
// (undocumented)
export function from(json: Type.JSON): Document;
export function from(json: Type.JSON, device?: Device): Document;
// (undocumented)
export function from(json: Fragment.JSON): Fragment;
export function from(json: Fragment.JSON, device?: Device): Fragment;
// (undocumented)
export function from(json: JSON): Node;
export function from(json: JSON, device?: Device): Node;
// @internal (undocumented)
export function fromNode(json: JSON): Trampoline<Node>;
export function fromNode(json: JSON, device?: Device): Trampoline<Node>;
// (undocumented)
export function isNode(value: unknown): value is Node;
// (undocumented)
export interface JSON<T extends string = string> extends tree.Node.JSON<T> {
}
// (undocumented)
export interface SerializationOptions {
// (undocumented)
device: Device;
}
// (undocumented)
export class Traversal extends Flags<Traversal.Flag> {
// (undocumented)
static of(...flags: Array<Traversal.Flag>): Traversal;
Expand Down Expand Up @@ -1086,7 +1092,7 @@ export class Shadow extends Node<"shadow"> {
// @public (undocumented)
export namespace Shadow {
// @internal (undocumented)
export function fromShadow(json: JSON): Trampoline<Shadow>;
export function fromShadow(json: JSON, device?: Device): Trampoline<Shadow>;
// (undocumented)
export function isShadow(value: unknown): value is Shadow;
// (undocumented)
Expand Down
8 changes: 4 additions & 4 deletions docs/review/api/alfa-json.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ namespace JSON_2 {
export { JSON_2 as JSON }

// @public (undocumented)
export interface Serializable<T extends JSON_2 = JSON_2> {
export interface Serializable<T extends JSON_2 = JSON_2, OPTIONS extends unknown = unknown> {
// (undocumented)
toJSON(): T;
toJSON(options?: OPTIONS): T;
}

// @public (undocumented)
Expand All @@ -36,9 +36,9 @@ export namespace Serializable {
// (undocumented)
export type ToJSON<T> = T extends Serializable<infer U> ? U : T extends JSON_2 ? T : JSON_2;
// (undocumented)
export function toJSON<T extends JSON_2>(value: Serializable<T>): T;
export function toJSON<T extends JSON_2, OPTIONS extends unknown = unknown>(value: Serializable<T>, options?: OPTIONS): T;
// (undocumented)
export function toJSON<T>(value: T): ToJSON<T>;
export function toJSON<T, OPTIONS extends unknown = unknown>(value: T, options?: OPTIONS): ToJSON<T>;
}

// (No @packageDocumentation comment for this package)
Expand Down
Loading
Loading