Skip to content

Commit e2a6132

Browse files
committed
merge main -> isolation
2 parents df9829c + 2d08101 commit e2a6132

File tree

16 files changed

+278
-185
lines changed

16 files changed

+278
-185
lines changed

.remarkignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Configs
2+
.vscode/
3+
4+
# Assets
5+
assets/
6+
7+
# Generated Docs
8+
_docs/
9+
_docs-dev/
10+
_docs-docs/
11+
existing-typedoc-dev/
12+
13+
# Package Manager
14+
node_modules/
15+
16+
# Build Directories
17+
dist/

.remarkrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export default {
2+
plugins: [
3+
"remark-frontmatter",
4+
"remark-mdx",
5+
[
6+
"remark-stringify",
7+
{
8+
bullet: "-",
9+
listItemIndent: "one",
10+
emphasis: "*",
11+
strong: "*",
12+
fences: true,
13+
fence: "`",
14+
rule: "-",
15+
incrementListMarker: true,
16+
},
17+
],
18+
],
19+
};

docs/contributors/Index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contributors
2+
3+
Here are the docs that haven't been published on the Typedoc.

docs/contributors/Typedoc.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Typedoc
2+
3+
Scramjet comes with a Typedoc.
4+
There is information about how to run it locally in the [README](../README.md).
5+
There are two types of Typedoc generated: user-facing (main) and developer-facing (dev).
6+
The user-facing documentation is generated at `/typedoc`, and the developer-facing documentation is generated at `/typedoc/dev`.
7+
The site is generated by the [CI here](../../.github/workflows/) under the job "pages". You can simulate that CI job with the script at `scripts/serve-static.sh`. This includes the demo and the Typedoc.
8+
9+
## How versioning works
10+
11+
Versioning is handled [this plugin](https://www.npmjs.com/package/@shipgirl/typedoc-plugin-versions).
12+
[This CI script](../../ci/download-existing-docs.sh) downloads the previous Typedoc builds from the artifacts for all Scramjet releases with the latest from the package version.

docs/dev/Typedoc.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: What is this?
3+
---
4+
5+
The current doc you are reading is generated with [typedoc-plugin-markdown](https://github.com/ElektraInitiative/typedoc-plugin-markdown).
6+
7+
Typedoc documents all of the Scramjet APIs. Specifically, you are on the developer-facing documentation, so you will see APIs documented, which aren't exposed publicly in the package.
8+
9+
[**Switch to user-facing documentation**](/typedoc) to see what you actually need if you aren't a contributor, rather an implementor or someone interested in Scramjet.

docs/user/Typedoc.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: What is this?
3+
---
4+
5+
You are currently on the user-facing documentation. This only documents APIs, which are exposed to you, so you can implement Scramjet into your site without having to worry about the internals of the library.
6+
7+
[**Switch to developer-facing documentation**](/typedoc-dev) to see all APIs used internally too.

package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"prepack": "RELEASE=1 npm run rewriter:build && npm run build:all",
1919
"pub": "npm publish --no-git-checks --access public",
2020
"format": "prettier --write .",
21+
"format:docs": "remark \"docs/**/*.{md,mdx}\" --output",
2122
"lint": "eslint ./src/",
2223
"lint:fix": "eslint ./src/ --fix",
2324
"lint:workflows": "actionlint .github/workflows/*.yml",
@@ -58,6 +59,7 @@
5859
"verbose": true
5960
},
6061
"devDependencies": {
62+
"@8hobbies/typedoc-plugin-404": "^3.2.1",
6163
"@8hobbies/typedoc-plugin-plausible": "^2.2.0",
6264
"@catppuccin/vscode": "^3.18.0",
6365
"@eslint/eslintrc": "^3.3.1",
@@ -71,6 +73,7 @@
7173
"@mercuryworkshop/wisp-js": "^0.3.3",
7274
"@nebula-services/bare-server-node": "^2.0.4",
7375
"@playwright/test": "^1.55.0",
76+
"@reside-ic/typedoc-plugin-copy-doc": "^1.1.2",
7477
"@rsdoctor/rspack-plugin": "^1.2.3",
7578
"@rslib/core": "^0.13.2",
7679
"@rspack/cli": "^1.5.3",
@@ -91,9 +94,17 @@
9194
"glob": "^11.0.3",
9295
"playwright": "^1.55.0",
9396
"prettier": "^3.6.2",
97+
"remark": "^15.0.1",
98+
"remark-cli": "^12.0.1",
99+
"remark-frontmatter": "^5.0.0",
100+
"remark-mdx": "^3.1.1",
101+
"remark-stringify": "^11.0.0",
94102
"ts-checker-rspack-plugin": "^1.1.5",
95103
"tsc-alias": "^1.8.16",
96104
"tslib": "^2.8.1",
105+
"typedoc": "^0.28.12",
106+
"typedoc-material-theme": "^1.4.0",
107+
"typedoc-plugin-frontmatter": "^1.3.0",
97108
"typedoc-plugin-include-example": "^2.1.2",
98109
"typedoc-plugin-markdown": "^4.8.1",
99110
"typedoc-plugin-mdn-links": "^5.0.9",
@@ -106,9 +117,8 @@
106117
"domutils": "^3.2.2",
107118
"htmlparser2": "10.0.0",
108119
"libcurl.js": "^0.7.2",
120+
"idb": "^8.0.3",
109121
"parse-domain": "^8.2.2",
110-
"set-cookie-parser": "^2.7.1",
111-
"typedoc": "^0.28.12",
112-
"typedoc-material-theme": "^1.4.0"
122+
"set-cookie-parser": "^2.7.1"
113123
}
114124
}

rspack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ const moduleConfig = defineConfig({
162162
libraryTarget: "module",
163163
iife: false,
164164
},
165+
performance: {
166+
hints: false,
167+
},
165168
plugins: [
166169
new TsCheckerRspackPlugin(),
167170
new rspack.ProvidePlugin({

src/controller/controller.ts

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import {
55
loadCodecs,
66
setConfig,
77
} from "@/shared/index";
8-
import { ScramjetConfig, ScramjetInitConfig } from "@/types";
8+
import { ScramjetConfig, ScramjetInitConfig, ScramjetDB } from "@/types";
99
import { ScramjetFrame } from "@/controller/frame";
1010
import { MessageW2C } from "@/worker";
11+
import { openDB, IDBPDatabase } from "idb";
1112
import {
1213
ScramjetEvents,
1314
ScramjetGlobalDownloadEvent,
@@ -16,7 +17,7 @@ import {
1617
} from "@client/events";
1718

1819
export class ScramjetController extends EventTarget {
19-
private db: IDBDatabase;
20+
private db: IDBPDatabase<ScramjetDB>;
2021

2122
constructor(config: Partial<ScramjetInitConfig>) {
2223
super();
@@ -137,35 +138,30 @@ export class ScramjetController extends EventTarget {
137138
return codecDecode(url.slice(prefixed.length));
138139
}
139140

140-
async openIDB(): Promise<IDBDatabase> {
141-
const db = indexedDB.open("$scramjet", 1);
142-
143-
return new Promise<IDBDatabase>((resolve, reject) => {
144-
db.onsuccess = async () => {
145-
this.db = db.result;
146-
await this.#saveConfig();
147-
resolve(db.result);
148-
};
149-
db.onupgradeneeded = () => {
150-
const res = db.result;
151-
if (!res.objectStoreNames.contains("config")) {
152-
res.createObjectStore("config");
141+
async openIDB(): Promise<IDBPDatabase<ScramjetDB>> {
142+
const db = await openDB<ScramjetDB>("$scramjet", 1, {
143+
upgrade(db) {
144+
if (!db.objectStoreNames.contains("config")) {
145+
db.createObjectStore("config");
153146
}
154-
if (!res.objectStoreNames.contains("cookies")) {
155-
res.createObjectStore("cookies");
147+
if (!db.objectStoreNames.contains("cookies")) {
148+
db.createObjectStore("cookies");
156149
}
157-
if (!res.objectStoreNames.contains("redirectTrackers")) {
158-
res.createObjectStore("redirectTrackers");
150+
if (!db.objectStoreNames.contains("redirectTrackers")) {
151+
db.createObjectStore("redirectTrackers");
159152
}
160-
if (!res.objectStoreNames.contains("referrerPolicies")) {
161-
res.createObjectStore("referrerPolicies");
153+
if (!db.objectStoreNames.contains("referrerPolicies")) {
154+
db.createObjectStore("referrerPolicies");
162155
}
163-
if (!res.objectStoreNames.contains("publicSuffixList")) {
164-
res.createObjectStore("publicSuffixList");
156+
if (!db.objectStoreNames.contains("publicSuffixList")) {
157+
db.createObjectStore("publicSuffixList");
165158
}
166-
};
167-
db.onerror = () => reject(db.error);
159+
},
168160
});
161+
162+
this.db = db;
163+
await this.#saveConfig();
164+
return db;
169165
}
170166

171167
async #saveConfig() {
@@ -174,14 +170,7 @@ export class ScramjetController extends EventTarget {
174170

175171
return;
176172
}
177-
const tx = this.db.transaction("config", "readwrite");
178-
const store = tx.objectStore("config");
179-
const req = store.put(config, "config");
180-
181-
return new Promise((resolve, reject) => {
182-
req.onsuccess = resolve;
183-
req.onerror = reject;
184-
});
173+
await this.db.put("config", config, "config");
185174
}
186175

187176
async modifyConfig(newconfig: Partial<ScramjetInitConfig>) {

src/entry.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,81 @@ declare const COMMITHASH: string;
1111
*/
1212
declare const VERSION: string;
1313

14+
/**
15+
* @category Window Context
16+
*/
17+
export type { ScramjetFlags } from "./types";
18+
19+
/**
20+
* @category Window Context
21+
*/
22+
export type { ScramjetInitConfig } from "./types";
23+
24+
/**
25+
* @category Window Context
26+
*/
27+
export type { ScramjetGlobalEvent } from "./client/events";
28+
29+
/**
30+
* @category Window Context
31+
*/
32+
export type { ScramjetGlobalDownloadEvent } from "./client/events";
33+
34+
/**
35+
* @category Window Context
36+
*/
37+
export type { ScramjetGlobalEvents } from "./client/events";
38+
39+
/**
40+
* @category Window Context
41+
*/
42+
export type { ScramjetDownload } from "./client/events";
43+
44+
/**
45+
* @category Window Context
46+
*/
47+
export type { ScramjetEvent } from "./client/events";
48+
49+
/**
50+
* @category Window Context
51+
*/
52+
export type { ScramjetEvents } from "./client/events";
53+
54+
/**
55+
* @category Window Context
56+
*/
57+
export type { NavigateEvent } from "./client/events";
58+
59+
/**
60+
* @category Window Context
61+
*/
62+
export type { UrlChangeEvent } from "./client/events";
63+
64+
/**
65+
* @category Window Context
66+
*/
67+
export type { ScramjetContextEvent } from "./client/events";
68+
69+
/**
70+
* @category Window Context
71+
*/
72+
export type { ScramjetController } from "./controller";
73+
74+
/**
75+
* @category Window Context
76+
*/
77+
export type { ScramjetFrame } from "./controller/frame";
78+
79+
/**
80+
* @category Window Context
81+
*/
82+
export type { ScramjetClient } from "./client";
83+
84+
/**
85+
* @category Service Worker Context
86+
*/
87+
export type { ScramjetServiceWorker } from "./worker";
88+
1489
/**
1590
* @fileoverview Scramjet Entry Point. This module contain global constants and factory functions to load the APIs in the bundle.
1691
*

0 commit comments

Comments
 (0)