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

New package alfa-painting-order #1756

Merged
merged 38 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
560b81d
Skaffold new package
rcj-siteimprove Jan 30, 2025
cf3ffa0
Add predicate for checking if an element creates a stacking context
rcj-siteimprove Jan 30, 2025
4d9d04d
Add function to compute the painting order of elements
rcj-siteimprove Feb 6, 2025
dd45af1
Add references to src/tsconfig.json
rcj-siteimprove Feb 6, 2025
5e2e7a6
Extract API
rcj-siteimprove Feb 6, 2025
9ae4f02
Add changeset
rcj-siteimprove Feb 6, 2025
e4a6bbf
Clean up tests
rcj-siteimprove Feb 6, 2025
0df8a24
Merge branch 'main' into alfa-painting-order
rcj-siteimprove Feb 6, 2025
3e5fa27
Add `List.some` in alfa-css
rcj-siteimprove Feb 14, 2025
ecc81e0
Add `Device.isDevice`
rcj-siteimprove Feb 14, 2025
8bcc9dd
Add `isFlexOrGridChild` predicate in alfa-style
rcj-siteimprove Feb 14, 2025
a594733
Use `isFlexOrGridChild` from alfa-style
rcj-siteimprove Feb 14, 2025
0ade434
Revert changes to the is*Container functions
rcj-siteimprove Feb 14, 2025
03b368c
Extract API
rcj-siteimprove Feb 14, 2025
7b54184
Add missing references
rcj-siteimprove Feb 14, 2025
b4ee48a
Add changesets
rcj-siteimprove Feb 14, 2025
db98af5
Add changeset for alfa-css
rcj-siteimprove Feb 14, 2025
ed6ea95
Merge branch 'main' into alfa-painting-order
rcj-siteimprove Feb 14, 2025
63ad89e
Extract API
github-actions[bot] Feb 14, 2025
8e34ce8
Use `Cache.memoize`
rcj-siteimprove Feb 17, 2025
9a1d55e
Add `PaintingOrder` class
rcj-siteimprove Feb 17, 2025
2fce533
Extract local functions
rcj-siteimprove Feb 17, 2025
ef476f9
Use alfa-style predicates
rcj-siteimprove Feb 17, 2025
57bcb80
Update references
rcj-siteimprove Feb 17, 2025
7769f27
Tag `PaintingOrder` as public
rcj-siteimprove Feb 17, 2025
36171a3
Extract API
github-actions[bot] Feb 17, 2025
0134911
Refactor function to not update array in-place
rcj-siteimprove Feb 18, 2025
7102bb3
Remove redundant code
rcj-siteimprove Feb 18, 2025
2d5832b
Add missing reference
rcj-siteimprove Feb 18, 2025
59d2752
Refactor layer painting
rcj-siteimprove Feb 18, 2025
2b2bdcc
Add test helper
rcj-siteimprove Feb 18, 2025
a3379f5
Update function description
rcj-siteimprove Feb 18, 2025
54ad974
Update packages/alfa-painting-order/src/painting-order.ts
rcj-siteimprove Feb 19, 2025
ba4c1ef
Update packages/alfa-painting-order/src/painting-order.ts
rcj-siteimprove Feb 19, 2025
0b62578
Update packages/alfa-painting-order/src/painting-order.ts
rcj-siteimprove Feb 19, 2025
bce1f29
Remove unnecessary memoization
rcj-siteimprove Feb 19, 2025
0d7a7ea
Simplify default parameter `options`
rcj-siteimprove Feb 19, 2025
38bae09
Extract API
github-actions[bot] Feb 19, 2025
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
5 changes: 5 additions & 0 deletions .changeset/eight-experts-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-css": minor
---

**Added:** `List.some` is now available.
5 changes: 5 additions & 0 deletions .changeset/five-rocks-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-style": minor
---

**Added:** A new predicate `isFlexOrGridChild` is available.
5 changes: 5 additions & 0 deletions .changeset/friendly-pots-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-device": minor
---

**Added:** `Device.isDevice` is now available.
5 changes: 5 additions & 0 deletions .changeset/proud-apples-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@siteimprove/alfa-painting-order": minor
---

**Added:** A new package has been added for computing the painting order of HTML elements.
2 changes: 2 additions & 0 deletions docs/review/api/alfa-css.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,8 @@ export class List<V extends Value> extends Value<"list", Value.HasCalculation<[V
// (undocumented)
get size(): number;
// (undocumented)
some(predicate: Predicate<V, [index: number]>): boolean;
// (undocumented)
toJSON(): List.JSON<V>;
// (undocumented)
toString(): string;
Expand Down
2 changes: 2 additions & 0 deletions docs/review/api/alfa-device.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ export namespace Device {
// (undocumented)
export function from(json: JSON): Device;
// (undocumented)
export function isDevice(value: unknown): value is Device;
// (undocumented)
export interface JSON {
// (undocumented)
[key: string]: json.JSON;
Expand Down
47 changes: 47 additions & 0 deletions docs/review/api/alfa-painting-order.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## API Report File for "@siteimprove/alfa-painting-order"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import { Array as Array_2 } from '@siteimprove/alfa-array';
import type { Device } from '@siteimprove/alfa-device';
import { Element } from '@siteimprove/alfa-dom';
import type { Equatable } from '@siteimprove/alfa-equatable';
import type { Hash } from '@siteimprove/alfa-hash';
import type { Hashable } from '@siteimprove/alfa-hash';
import { Iterable as Iterable_2 } from '@siteimprove/alfa-iterable';
import * as json from '@siteimprove/alfa-json';
import type { Serializable } from '@siteimprove/alfa-json';

// @public (undocumented)
export class PaintingOrder implements Equatable, Hashable, Serializable<PaintingOrder.JSON> {
protected constructor(elements: Array_2<Element>);
// (undocumented)
equals(value: this): boolean;
// (undocumented)
equals(value: unknown): value is this;
// (undocumented)
hash(hash: Hash): void;
// (undocumented)
static of(elements: Iterable_2<Element>): PaintingOrder;
// (undocumented)
toJSON(options?: Serializable.Options): PaintingOrder.JSON;
}

// @public (undocumented)
export namespace PaintingOrder {
// (undocumented)
export function isPaintingOrder(value: unknown): value is PaintingOrder;
// (undocumented)
export type JSON = {
[key: string]: json.JSON;
type: "painting-order";
elements: Array_2<Element.JSON>;
};
const from: (this: unknown, root: Element<string>, device: Device) => PaintingOrder;
}

// (No @packageDocumentation comment for this package)

```
4 changes: 3 additions & 1 deletion docs/review/api/alfa-style.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export namespace Shorthands {
readonly border: Shorthand<"border-bottom-color" | "border-bottom-style" | "border-bottom-width" | "border-left-color" | "border-left-style" | "border-left-width" | "border-right-color" | "border-right-style" | "border-right-width" | "border-top-color" | "border-top-style" | "border-top-width">;
readonly "border-width": Shorthand<"border-bottom-width" | "border-left-width" | "border-right-width" | "border-top-width">;
readonly "flex-flow": Shorthand<"flex-direction" | "flex-wrap">;
readonly font: Shorthand<"font-family" | "font-size" | "font-stretch" | "font-style" | "font-variant-caps" | "font-variant-east-asian" | "font-variant-ligatures" | "font-variant-numeric" | "font-variant-position" | "font-weight" | "line-height">;
readonly font: Shorthand<"font-size" | "font-family" | "font-stretch" | "font-style" | "font-variant-caps" | "font-variant-east-asian" | "font-variant-ligatures" | "font-variant-numeric" | "font-variant-position" | "font-weight" | "line-height">;
readonly "font-variant": Shorthand<"font-variant-caps" | "font-variant-east-asian" | "font-variant-ligatures" | "font-variant-numeric">;
readonly "inset-block": Shorthand<"inset-block-end" | "inset-block-start">;
readonly "inset-inline": Shorthand<"inset-inline-end" | "inset-inline-start">;
Expand Down Expand Up @@ -440,12 +440,14 @@ export namespace Style {
hasBoxShadow: typeof element.hasBoxShadow, // (undocumented)
hasCascadedStyle: typeof element.hasCascadedStyle, // (undocumented)
hasComputedStyle: typeof element.hasComputedStyle, // (undocumented)
hasInitialComputedStyle: typeof element.hasInitialComputedStyle, // (undocumented)
hasPositioningParent: typeof element.hasPositioningParent, // (undocumented)
hasOutline: typeof element.hasOutline, // (undocumented)
hasSpecifiedStyle: typeof element.hasSpecifiedStyle, // (undocumented)
hasTextDecoration: typeof element.hasTextDecoration, // (undocumented)
hasTransparentBackground: typeof element.hasTransparentBackground, // (undocumented)
hasUsedStyle: typeof element.hasUsedStyle, // (undocumented)
isFlexOrGridChild: typeof element.isFlexOrGridChild, // (undocumented)
isFocusable: typeof element.isFocusable, // (undocumented)
isImportant: typeof element.isImportant, // (undocumented)
isInert: typeof element.isInert, // (undocumented)
Expand Down
7 changes: 6 additions & 1 deletion packages/alfa-css/src/value/collection/list.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Hash } from "@siteimprove/alfa-hash";
import type { Iterable } from "@siteimprove/alfa-iterable";
import { Iterable } from "@siteimprove/alfa-iterable";
import type { Serializable } from "@siteimprove/alfa-json";
import type { Mapper } from "@siteimprove/alfa-mapper";
import { Parser } from "@siteimprove/alfa-parser";
import type { Predicate } from "@siteimprove/alfa-predicate";

import { type Parser as CSSParser, Token } from "../../syntax/index.js";

Expand Down Expand Up @@ -48,6 +49,10 @@ export class List<V extends Value>
return this._values.length;
}

public some(predicate: Predicate<V, [index: number]>) {
return Iterable.some(this._values, predicate);
}

public resolve(
resolver?: Resolvable.Resolver<V>,
): List<Resolvable.Resolved<V>> {
Expand Down
4 changes: 4 additions & 0 deletions packages/alfa-device/src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,8 @@ export namespace Device {
export function standard(): Device {
return Device.of(Type.Screen, Viewport.standard(), Display.standard());
}

export function isDevice(value: unknown): value is Device {
return value instanceof Device;
}
}
Empty file.
3 changes: 3 additions & 0 deletions packages/alfa-painting-order/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Alfa painting order

Support for computing painting order of elements.
5 changes: 5 additions & 0 deletions packages/alfa-painting-order/config/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../config/api-extractor.json",
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts"
}
47 changes: 47 additions & 0 deletions packages/alfa-painting-order/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "http://json.schemastore.org/package",
"name": "@siteimprove/alfa-painting-order",
"homepage": "https://alfa.siteimprove.com",
"version": "0.97.0",
"license": "MIT",
"description": "Support for computing painting order of elements.",
"repository": {
"type": "git",
"url": "github:Siteimprove/alfa",
"directory": "packages/alfa-painting-order"
},
"bugs": "https://github.com/siteimprove/alfa/issues",
"engines": {
"node": ">=20.0.0"
},
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist/**/*.js",
"dist/**/*.d.ts"
],
"dependencies": {
"@siteimprove/alfa-array": "workspace:^",
"@siteimprove/alfa-cache": "workspace:^",
"@siteimprove/alfa-comparable": "workspace:^",
"@siteimprove/alfa-css": "workspace:^",
"@siteimprove/alfa-device": "workspace:^",
"@siteimprove/alfa-dom": "workspace:^",
"@siteimprove/alfa-equatable": "workspace:^",
"@siteimprove/alfa-hash": "workspace:^",
"@siteimprove/alfa-iterable": "workspace:^",
"@siteimprove/alfa-json": "workspace:^",
"@siteimprove/alfa-predicate": "workspace:^",
"@siteimprove/alfa-refinement": "workspace:^",
"@siteimprove/alfa-sequence": "workspace:^",
"@siteimprove/alfa-style": "workspace:^"
},
"devDependencies": {
"@siteimprove/alfa-test": "workspace:^"
},
"publishConfig": {
"access": "public",
"registry": "https://npm.pkg.github.com/"
}
}
1 change: 1 addition & 0 deletions packages/alfa-painting-order/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./painting-order.js";
Loading
Loading