Skip to content

Commit f2bdc90

Browse files
committed
instead of choosing the subresources method, use both of them
1 parent 229051e commit f2bdc90

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ inputs:
3232
VALIDATE_PUBRULES:
3333
description: Validate against W3C Publication Rules
3434
default: "false"
35-
SUBRESOURCES_METHOD:
36-
description: Method to use to find subresources. Possible values - 'dom', 'network'
37-
default: "dom"
3835
GH_PAGES_BRANCH:
3936
description: Provide a branch name to deploy to GitHub pages.
4037
GH_PAGES_BUILD_OVERRIDE:

docs/options.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,6 @@ Whether or not to validate compliance with [W3C Publication Rules](https://www.w
144144

145145
**Default:** false
146146

147-
## `SUBRESOURCES_METHOD`
148-
149-
Method to use to find the subresources of the spec.
150-
151-
**Possible values:** dom, network
152-
153-
**Default:** dom
154-
155147
## `GH_PAGES_BRANCH`
156148

157149
Whether or not to deploy to GitHub pages. Set to a Falsy value to not deploy, or provide a Git branch name to push to. You would need to enable GitHub pages publish source in repository settings manually.

src/build.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { deepEqual, StaticServer } from "./utils.ts";
1010
import { PUPPETEER_ENV } from "./constants.ts";
1111

1212
import type { BasicBuildOptions as BasicBuildOptions_ } from "./prepare-build.ts";
13-
import type { Inputs, ProcessedInput } from "./prepare.ts";
13+
import type { ProcessedInput } from "./prepare.ts";
1414
type BasicBuildOptions = Omit<BasicBuildOptions_, "artifactName">;
1515
type Input = ProcessedInput["build"];
1616
type ConfigOverride = Input["configOverride"]["gh" | "w3c"];
@@ -170,7 +170,7 @@ async function copyRelevantAssets(
170170
};
171171
}
172172

173-
async function findAssetsToCopy(source: Input["source"], method: Inputs["SUBRESOURCES_METHOD"]) {
173+
async function findAssetsToCopy(source: Input["source"]) {
174174
console.groupCollapsed(`[INFO] Finding relevant assets…`);
175175
let localAssets: string[] = [];
176176
let remoteAssets: URL[] = [];
@@ -204,7 +204,12 @@ async function findAssetsToCopy(source: Input["source"], method: Inputs["SUBRESO
204204
args: ["--no-sandbox"],
205205
}
206206
};
207-
const allSubResources = method === "dom" ? domSubResources(rootUrl, options) : networkSubResources(rootUrl, options);
207+
// Merge results from both DOM- and network-based collectors
208+
// so we don't miss anything.
209+
const allSubResources = mergeAsyncIterables(
210+
domSubResources(rootUrl, options),
211+
networkSubResources(rootUrl, options),
212+
);
208213
for await (const res of allSubResources) {
209214
const url = new URL(res.url);
210215
if (isLocalAsset(url) && res.type === "link") {
@@ -311,3 +316,12 @@ function trimList(list: string[], len = 8) {
311316
function urlToPage(url: URL) {
312317
return new URL(url.pathname, url.origin).href;
313318
}
319+
320+
// merge multiple async iterables into a single async iterable.
321+
async function* mergeAsyncIterables<T>(...iters: AsyncIterable<T>[]) {
322+
for (const it of iters) {
323+
for await (const v of it) {
324+
yield v;
325+
}
326+
}
327+
}

src/prepare.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export interface Inputs {
1717
VALIDATE_MARKUP: string;
1818
VALIDATE_PUBRULES: string;
1919
VALIDATE_WEBIDL: string;
20-
SUBRESOURCES_METHOD: "dom" | "network" | string;
2120
GH_PAGES_BRANCH: string;
2221
GH_PAGES_TOKEN: string;
2322
GH_PAGES_BUILD_OVERRIDE: string;

0 commit comments

Comments
 (0)