Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into remove-index-html-s…
Browse files Browse the repository at this point in the history
…upport
  • Loading branch information
caugner committed Nov 18, 2022
2 parents 1dffd21 + 5c8ce57 commit ad2891e
Show file tree
Hide file tree
Showing 37 changed files with 514 additions and 577 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ module.exports = {
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{ ignoreRestSiblings: true },
],
"n/no-missing-import": "off",
"n/no-unpublished-import": "off",
"n/shebang": "off",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ jobs:
poetry run deployer search-index ../client/build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.DEPLOYER_STAGE_AND_DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOYER_STAGE_AND_DEV_AWS_SECRET_ACCESS_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4.0.2
- uses: actions/labeler@4.1.0
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
2 changes: 1 addition & 1 deletion .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ jobs:
poetry run deployer search-index ../client/build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.DEPLOYER_PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOYER_PROD_AWS_SECRET_ACCESS_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ jobs:
poetry run deployer search-index ../client/build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.DEPLOYER_STAGE_AND_DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOYER_STAGE_AND_DEV_AWS_SECRET_ACCESS_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { VALID_LOCALES } from "../libs/constants";
import { renderHTML } from "../ssr/dist/main";
import options from "./build-options";
import { buildDocument, BuiltDocument, renderContributorsTxt } from ".";
import { DocMetadata, Flaws } from "../libs/types";
import { Flaws } from "../libs/types";
import * as bcd from "@mdn/browser-compat-data/types";
import SearchIndex from "./search-index";
import { BUILD_OUT_ROOT } from "../libs/env";
Expand Down
35 changes: 30 additions & 5 deletions build/document-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import web from "../kumascript/src/api/web";
interface SimpleSupportStatementWithReleaseDate
extends bcd.SimpleSupportStatement {
release_date?: string;
version_last?: bcd.VersionValue;
}

type SectionsAndFlaws = [Section[], string[]];
Expand Down Expand Up @@ -464,16 +465,17 @@ function _addSingleSpecialSection(
: [originalInfo];

for (const infoEntry of infos) {
const added =
typeof infoEntry.version_added === "string" &&
infoEntry.version_added.startsWith("≤")
? infoEntry.version_added.slice(1)
: infoEntry.version_added;
const added = _normalizeVersion(infoEntry.version_added);
const removed = _normalizeVersion(infoEntry.version_removed);
if (browserReleaseData.has(browser)) {
if (browserReleaseData.get(browser).has(added)) {
infoEntry.release_date = browserReleaseData
.get(browser)
.get(added).release_date;
infoEntry.version_last = _getPreviousVersion(
removed,
browsers[browser]
);
}
}
}
Expand Down Expand Up @@ -506,6 +508,29 @@ function _addSingleSpecialSection(
];
}

function _getPreviousVersion(
version: bcd.VersionValue,
browser: bcd.BrowserStatement
): bcd.VersionValue {
if (browser && typeof version === "string") {
const browserVersions = Object.keys(browser["releases"]).sort(
_compareVersions
);
const currentVersionIndex = browserVersions.indexOf(version);
if (currentVersionIndex > 0) {
return browserVersions[currentVersionIndex - 1];
}
}

return version;
}

function _normalizeVersion(version: bcd.VersionValue): bcd.VersionValue {
return typeof version === "string" && version.startsWith("≤")
? version.slice(1)
: version;
}

function _getFirstVersion(support: bcd.SimpleSupportStatement): string {
if (typeof support.version_added === "string") {
return support.version_added;
Expand Down
8 changes: 4 additions & 4 deletions build/wrap-tables.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Wraps tables in a scrollable div to avoid overlapping with the TOC sidebar.
// Wraps tables in a scrollable figure to avoid overlapping with the TOC sidebar.
// Before: <table>...</table>
// After: <div class="table-scroll"><table>...</table></div>
// After: <figure class="table-container"><table>...</table></figure>
export function wrapTables($) {
const div = $('<div class="table-scroll"></div>');
$("table").wrap(div);
const figure = $('<figure class="table-container"></figure>');
$("table").wrap(figure);
}
4 changes: 2 additions & 2 deletions client/pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"devDependencies": {
"@types/dexie": "1.3.1",
"ts-loader": "^9.4.1",
"typescript": "^4.8.4",
"typescript": "^4.9.3",
"webpack": "^5.75.0",
"webpack-cli": "^4.10.0",
"webpack-cli": "^5.0.0",
"workers-preview": "^1.0.6"
}
}
1 change: 0 additions & 1 deletion client/pwa/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Dexie from "dexie";
export enum SwType {
PreferOnline = "PreferOnline",
PreferOffline = "PreferOffline",
ApiOnly = "ApiOnly",
}

export interface PlusSettings {
Expand Down
33 changes: 16 additions & 17 deletions client/pwa/src/service-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const UPDATES_BASE_URL = `https://updates.${
}`;

const SW_TYPE: SwType =
SwType[new URLSearchParams(location.search).get("type")] || SwType.ApiOnly;
SwType[new URLSearchParams(location.search).get("type")] ||
SwType.PreferOnline;

// export empty type because of tsc --isolatedModules flag
export type {};
Expand All @@ -36,29 +37,27 @@ var unpacking = Promise.resolve();

self.addEventListener("install", (e) => {
e.waitUntil(
SW_TYPE === SwType.ApiOnly
? self.skipWaiting()
: (async () => {
const cache = await openCache();
const { files = {} }: { files: object } =
(await (await fetch("/asset-manifest.json")).json()) || {};
const assets = [...Object.values(files)].filter(
(asset) => !(asset as string).endsWith(".map")
);
let keys = new Set(
(await cache.keys()).map((r) => r.url.replace(location.origin, ""))
);
const toCache = assets.filter((file) => !keys.has(file));
await cache.addAll(toCache as string[]);
})().then(() => self.skipWaiting())
(async () => {
const cache = await openCache();
const { files = {} }: { files: object } =
(await (await fetch("/asset-manifest.json")).json()) || {};
const assets = [...Object.values(files)].filter(
(asset) => !(asset as string).endsWith(".map")
);
let keys = new Set(
(await cache.keys()).map((r) => r.url.replace(location.origin, ""))
);
const toCache = assets.filter((file) => !keys.has(file));
await cache.addAll(toCache as string[]);
})().then(() => self.skipWaiting())
);

initOncePerRun(self);
});

self.addEventListener("fetch", async (e) => {
if (
(SW_TYPE === SwType.ApiOnly || SW_TYPE === SwType.PreferOnline) &&
SW_TYPE === SwType.PreferOnline &&
!e.request.url.includes("/api/v1/") &&
!e.request.url.includes("/users/fxa/")
) {
Expand Down
99 changes: 49 additions & 50 deletions client/pwa/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,20 @@
"@webassemblyjs/ast" "1.11.1"
"@xtuc/long" "4.2.2"

"@webpack-cli/configtest@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-1.2.0.tgz#7b20ce1c12533912c3b217ea68262365fa29a6f5"
integrity sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==
"@webpack-cli/configtest@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-2.0.0.tgz#5e1bc37064c7d00e1330641fa523f8ff85a39513"
integrity sha512-war4OU8NGjBqU3DP3bx6ciODXIh7dSXcpQq+P4K2Tqyd8L5OjZ7COx9QXx/QdCIwL2qoX09Wr4Cwf7uS4qdEng==

"@webpack-cli/info@^1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-1.5.0.tgz#6c78c13c5874852d6e2dd17f08a41f3fe4c261b1"
integrity sha512-e8tSXZpw2hPl2uMJY6fsMswaok5FdlGNRTktvFk2sD8RjH0hE2+XistawJx1vmKteh4NmGmNUrp+Tb2w+udPcQ==
dependencies:
envinfo "^7.7.3"
"@webpack-cli/info@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-2.0.0.tgz#5a58476b129ee9b462117b23393596e726bf3b80"
integrity sha512-NNxDgbo4VOkNhOlTgY0Elhz3vKpOJq4/PKeKg7r8cmYM+GQA9vDofLYyup8jS6EpUvhNmR30cHTCEIyvXpskwA==

"@webpack-cli/serve@^1.7.0":
version "1.7.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-1.7.0.tgz#e1993689ac42d2b16e9194376cfb6753f6254db1"
integrity sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==
"@webpack-cli/serve@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.0.tgz#f08ea194e01ed45379383a8886e8c85a65a5f26a"
integrity sha512-Rumq5mHvGXamnOh3O8yLk1sjx8dB30qF1OeR6VC00DIR6SLJ4bwwUGKC4pE7qBFoQyyh0H9sAg3fikYgAqVR0w==

"@xtuc/ieee754@^1.2.0":
version "1.2.0"
Expand Down Expand Up @@ -342,10 +340,10 @@ commander@^2.20.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

commander@^7.0.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==
commander@^9.4.1:
version "9.4.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.1.tgz#d1dd8f2ce6faf93147295c0df13c7c21141cfbdd"
integrity sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==

cross-spawn@^7.0.3:
version "7.0.3"
Expand Down Expand Up @@ -484,15 +482,15 @@ import-local@^3.0.2:
pkg-dir "^4.2.0"
resolve-cwd "^3.0.0"

interpret@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9"
integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==
interpret@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4"
integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==

is-core-module@^2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211"
integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==
is-core-module@^2.9.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144"
integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==
dependencies:
has "^1.0.3"

Expand Down Expand Up @@ -671,12 +669,12 @@ randombytes@^2.1.0:
dependencies:
safe-buffer "^5.1.0"

rechoir@^0.7.0:
version "0.7.1"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.7.1.tgz#9478a96a1ca135b5e88fc027f03ee92d6c645686"
integrity sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==
rechoir@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.8.0.tgz#49f866e0d32146142da3ad8f0eff352b3215ff22"
integrity sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==
dependencies:
resolve "^1.9.0"
resolve "^1.20.0"

resolve-cwd@^3.0.0:
version "3.0.0"
Expand All @@ -690,12 +688,12 @@ resolve-from@^5.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69"
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==

resolve@^1.9.0:
version "1.22.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198"
integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==
resolve@^1.20.0:
version "1.22.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177"
integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==
dependencies:
is-core-module "^2.8.1"
is-core-module "^2.9.0"
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"

Expand Down Expand Up @@ -821,10 +819,10 @@ ts-loader@^9.4.1:
micromatch "^4.0.0"
semver "^7.3.4"

typescript@^4.8.4:
version "4.8.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==
typescript@^4.9.3:
version "4.9.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db"
integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==

uri-js@^4.2.2:
version "4.4.1"
Expand All @@ -841,22 +839,23 @@ watchpack@^2.4.0:
glob-to-regexp "^0.4.1"
graceful-fs "^4.1.2"

webpack-cli@^4.10.0:
version "4.10.0"
resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-4.10.0.tgz#37c1d69c8d85214c5a65e589378f53aec64dab31"
integrity sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==
webpack-cli@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.0.0.tgz#bd380a9653e0cd1a08916c4ff1adea17201ef68f"
integrity sha512-AACDTo20yG+xn6HPW5xjbn2Be4KUzQPebWXsDMHwPPyKh9OnTOJgZN2Nc+g/FZKV3ObRTYsGvibAvc+5jAUrVA==
dependencies:
"@discoveryjs/json-ext" "^0.5.0"
"@webpack-cli/configtest" "^1.2.0"
"@webpack-cli/info" "^1.5.0"
"@webpack-cli/serve" "^1.7.0"
"@webpack-cli/configtest" "^2.0.0"
"@webpack-cli/info" "^2.0.0"
"@webpack-cli/serve" "^2.0.0"
colorette "^2.0.14"
commander "^7.0.0"
commander "^9.4.1"
cross-spawn "^7.0.3"
envinfo "^7.7.3"
fastest-levenshtein "^1.0.12"
import-local "^3.0.2"
interpret "^2.2.0"
rechoir "^0.7.0"
interpret "^3.1.1"
rechoir "^0.8.0"
webpack-merge "^5.7.3"

webpack-merge@^5.7.3:
Expand Down
Loading

0 comments on commit ad2891e

Please sign in to comment.