stage-browser 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -2
- package/build/icon.icns +0 -0
- package/build/icon.png +0 -0
- package/dist/bin/stage.js +111 -0
- package/dist/main/cli-args.js +28 -0
- package/dist/main/context-menu.js +68 -0
- package/dist/main/context.js +2 -0
- package/dist/main/extensions.js +78 -0
- package/dist/main/ipc.js +90 -0
- package/dist/main/main.js +279 -0
- package/dist/main/menu.js +140 -0
- package/dist/main/reveal.js +155 -0
- package/dist/main/selftest.js +490 -0
- package/dist/main/store.js +85 -0
- package/dist/main/suggest.js +43 -0
- package/dist/main/tabs.js +324 -0
- package/dist/main/url.js +38 -0
- package/dist/main/window.js +68 -0
- package/dist/preload/extension-compat.js +163 -0
- package/dist/preload/ui-preload.js +33 -0
- package/dist/shared/contract.js +6 -0
- package/dist/ui/app.js +653 -0
- package/dist/ui/index.html +41 -0
- package/dist/ui/mock.js +479 -0
- package/dist/ui/newtab.html +69 -0
- package/dist/ui/styles.css +410 -0
- package/node_modules/@types/chrome/LICENSE +21 -0
- package/node_modules/@types/chrome/README.md +15 -0
- package/node_modules/@types/chrome/chrome-cast/index.d.ts +1156 -0
- package/node_modules/@types/chrome/har-format/index.d.ts +6 -0
- package/node_modules/@types/chrome/index.d.ts +13786 -0
- package/node_modules/@types/chrome/package.json +99 -0
- package/node_modules/@types/filesystem/LICENSE +21 -0
- package/node_modules/@types/filesystem/README.md +15 -0
- package/node_modules/@types/filesystem/index.d.ts +564 -0
- package/node_modules/@types/filesystem/package.json +26 -0
- package/node_modules/@types/filewriter/LICENSE +21 -0
- package/node_modules/@types/filewriter/README.md +15 -0
- package/node_modules/@types/filewriter/index.d.ts +166 -0
- package/node_modules/@types/filewriter/package.json +25 -0
- package/node_modules/@types/har-format/LICENSE +21 -0
- package/node_modules/@types/har-format/README.md +15 -0
- package/node_modules/@types/har-format/index.d.ts +938 -0
- package/node_modules/@types/har-format/package.json +31 -0
- package/node_modules/adm-zip/LICENSE +21 -0
- package/node_modules/adm-zip/README.md +90 -0
- package/node_modules/adm-zip/adm-zip.js +1020 -0
- package/node_modules/adm-zip/headers/entryHeader.js +396 -0
- package/node_modules/adm-zip/headers/index.js +2 -0
- package/node_modules/adm-zip/headers/mainHeader.js +177 -0
- package/node_modules/adm-zip/methods/deflater.js +33 -0
- package/node_modules/adm-zip/methods/index.js +3 -0
- package/node_modules/adm-zip/methods/inflater.js +64 -0
- package/node_modules/adm-zip/methods/zipcrypto.js +175 -0
- package/node_modules/adm-zip/package.json +56 -0
- package/node_modules/adm-zip/types.d.ts +223 -0
- package/node_modules/adm-zip/util/constants.js +142 -0
- package/node_modules/adm-zip/util/decoder.js +5 -0
- package/node_modules/adm-zip/util/errors.js +66 -0
- package/node_modules/adm-zip/util/fattr.js +76 -0
- package/node_modules/adm-zip/util/index.js +5 -0
- package/node_modules/adm-zip/util/utils.js +481 -0
- package/node_modules/adm-zip/zipEntry.js +415 -0
- package/node_modules/adm-zip/zipFile.js +466 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/electron-chrome-web-store/README.md +143 -0
- package/node_modules/electron-chrome-web-store/dist/chrome-web-store.preload.js +299 -0
- package/node_modules/electron-chrome-web-store/dist/cjs/browser/index.js +1674 -0
- package/node_modules/electron-chrome-web-store/dist/esm/browser/index.mjs +950 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/api.d.ts +2 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/crx3.d.ts +20 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/id.d.ts +9 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/index.d.ts +62 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/installer.d.ts +29 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/loader.d.ts +18 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/types.d.ts +21 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/updater.d.ts +6 -0
- package/node_modules/electron-chrome-web-store/dist/types/browser/utils.d.ts +4 -0
- package/node_modules/electron-chrome-web-store/dist/types/common/constants.d.ts +44 -0
- package/node_modules/electron-chrome-web-store/dist/types/renderer/chrome-web-store.preload.d.ts +1 -0
- package/node_modules/electron-chrome-web-store/package.json +43 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/pbf/LICENSE +27 -0
- package/node_modules/pbf/README.md +293 -0
- package/node_modules/pbf/bin/pbf +17 -0
- package/node_modules/pbf/compile.js +441 -0
- package/node_modules/pbf/dist/pbf-dev.js +838 -0
- package/node_modules/pbf/dist/pbf.js +1 -0
- package/node_modules/pbf/index.d.ts +206 -0
- package/node_modules/pbf/index.js +830 -0
- package/node_modules/pbf/package.json +63 -0
- package/node_modules/protocol-buffers-schema/.travis.yml +7 -0
- package/node_modules/protocol-buffers-schema/LICENSE +21 -0
- package/node_modules/protocol-buffers-schema/README.md +122 -0
- package/node_modules/protocol-buffers-schema/example.js +11 -0
- package/node_modules/protocol-buffers-schema/example.proto +13 -0
- package/node_modules/protocol-buffers-schema/index.js +6 -0
- package/node_modules/protocol-buffers-schema/package.json +31 -0
- package/node_modules/protocol-buffers-schema/parse.js +769 -0
- package/node_modules/protocol-buffers-schema/stringify.js +206 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/basic.json +90 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/basic.proto +11 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/comments.json +99 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/comments.proto +19 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/complex.json +125 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/complex.proto +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/enum.json +42 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/enum.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/escaped-quotes.json +32 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/escaped-quotes.proto +3 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/extend.json +167 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/extend.proto +19 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/import.json +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/import.proto +6 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/map.json +33 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/map.proto +3 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/no-tags.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/oneof.json +41 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/oneof.proto +6 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/option.json +364 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/option.proto +72 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/options.json +47 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/options.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/pheromon-trajectories.proto +8 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/reserved.json +55 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/reserved.proto +17 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/search.json +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/search.proto +5 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/service.json +108 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/service.proto +30 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/valid-packed.proto +35 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/version.json +90 -0
- package/node_modules/protocol-buffers-schema/test/fixtures/version.proto +13 -0
- package/node_modules/protocol-buffers-schema/test/index.js +157 -0
- package/node_modules/protocol-buffers-schema/tokenize.js +56 -0
- package/node_modules/resolve-protobuf-schema/.travis.yml +3 -0
- package/node_modules/resolve-protobuf-schema/LICENSE +21 -0
- package/node_modules/resolve-protobuf-schema/README.md +49 -0
- package/node_modules/resolve-protobuf-schema/index.js +50 -0
- package/node_modules/resolve-protobuf-schema/package.json +25 -0
- package/node_modules/resolve-protobuf-schema/test/a.proto +5 -0
- package/node_modules/resolve-protobuf-schema/test/b.proto +5 -0
- package/node_modules/resolve-protobuf-schema/test/c.proto +3 -0
- package/node_modules/resolve-protobuf-schema/test/index.js +49 -0
- package/package.json +64 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: crx:">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<title>Stage</title>
|
|
8
|
+
<link rel="stylesheet" href="styles.css">
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<!-- Tab bar: a 52px strip with one floating capsule. The leftmost 84px stay free for the traffic lights. -->
|
|
12
|
+
<div id="strip">
|
|
13
|
+
<div id="capsule">
|
|
14
|
+
<div id="tabs" role="tablist" aria-label="Tabs"></div>
|
|
15
|
+
<button id="new-tab" class="icon-btn" type="button" aria-label="New tab" title="New tab (⌘T)">
|
|
16
|
+
<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M8 3.5v9M3.5 8h9" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>
|
|
17
|
+
</button>
|
|
18
|
+
<div id="controls">
|
|
19
|
+
<span class="divider" aria-hidden="true"></span>
|
|
20
|
+
<browser-action-list partition="persist:stage" alignment="bottom right"></browser-action-list>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<!-- Omnibox overlay (shown when state.overlay.type === 'omnibox'; the view is then full-window). -->
|
|
26
|
+
<div id="omni" hidden>
|
|
27
|
+
<div id="omni-backdrop"></div>
|
|
28
|
+
<div id="omni-panel" role="dialog" aria-label="Open a page or search">
|
|
29
|
+
<div id="omni-field">
|
|
30
|
+
<span id="omni-glyph" aria-hidden="true"></span>
|
|
31
|
+
<input id="omni-input" type="text" spellcheck="false" autocomplete="off" autocapitalize="off" autocorrect="off"
|
|
32
|
+
role="combobox" aria-expanded="false" aria-controls="omni-list" aria-autocomplete="list"
|
|
33
|
+
placeholder="Search or enter address" aria-label="Search or enter address">
|
|
34
|
+
</div>
|
|
35
|
+
<div id="omni-list" role="listbox" aria-label="Suggestions"></div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<script src="app.js"></script>
|
|
40
|
+
</body>
|
|
41
|
+
</html>
|
package/dist/ui/mock.js
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// A fake window.stage for previewing the UI in a plain browser. app.js loads it only when
|
|
3
|
+
// window.stage is undefined, which never happens inside Electron.
|
|
4
|
+
//
|
|
5
|
+
// URL params:
|
|
6
|
+
// scene bar | single | many | loading | pinned | omnibox | omnibox-edit | newtab
|
|
7
|
+
// theme dark | light
|
|
8
|
+
// backdrop light | dark paints a fake web page behind the transparent UI
|
|
9
|
+
// anim 0 disables transitions, for deterministic screenshots
|
|
10
|
+
// visible 0 starts with the bar hidden
|
|
11
|
+
// selfcheck main | many runs in-page interaction checks; results land in #selfcheck
|
|
12
|
+
{
|
|
13
|
+
const params = new URLSearchParams(location.search);
|
|
14
|
+
const scene = params.get('scene') ?? 'bar';
|
|
15
|
+
const root = document.documentElement;
|
|
16
|
+
const theme = params.get('theme');
|
|
17
|
+
if (theme)
|
|
18
|
+
root.dataset.theme = theme;
|
|
19
|
+
const fav = (letter, bg, shape = 'square') => {
|
|
20
|
+
const inner = shape === 'circle' ? `<circle cx="8" cy="8" r="8" fill="${bg}"/>` : `<rect width="16" height="16" rx="4" fill="${bg}"/>`;
|
|
21
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">${inner}` +
|
|
22
|
+
`<text x="8" y="11.6" font-family="-apple-system,Helvetica,Arial" font-size="10" font-weight="700" text-anchor="middle" fill="#fff">${letter}</text></svg>`;
|
|
23
|
+
return `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
|
24
|
+
};
|
|
25
|
+
const POOL = [
|
|
26
|
+
{ title: 'Workflow editor — Northwind', url: 'https://northwind.example/editor/2481', favicon: fav('N', '#2e6b5b') },
|
|
27
|
+
{ title: 'Pull request #482 · acme/stage', url: 'https://github.com/acme/stage/pull/482', favicon: fav('G', '#24292f', 'circle') },
|
|
28
|
+
{ title: 'Quarterly roadmap', url: 'https://notion.example.com/roadmap', favicon: null },
|
|
29
|
+
{ title: 'Design review — homepage v3', url: 'https://figma.example.com/file/abc', favicon: fav('F', '#7c3aed') },
|
|
30
|
+
{ title: 'Inbox (12)', url: 'https://mail.example.com/inbox', favicon: fav('M', '#2563eb') },
|
|
31
|
+
{ title: 'A very long page title that will certainly need to be truncated at the edge of the tab', url: 'https://docs.example.org/guides/long', favicon: null },
|
|
32
|
+
{ title: 'Webinar recording — lo-fi beats', url: 'https://music.example.com/live', favicon: fav('♪', '#db2777', 'circle'), audible: true },
|
|
33
|
+
{ title: 'Analytics — Overview', url: 'https://analytics.example.net/overview', favicon: null },
|
|
34
|
+
{ title: 'Customer interviews', url: 'https://sheets.example.com/d/1x', favicon: fav('S', '#16a34a') },
|
|
35
|
+
{ title: 'Staging — dashboard', url: 'https://staging.acme.dev/', favicon: null },
|
|
36
|
+
];
|
|
37
|
+
const HISTORY = [
|
|
38
|
+
{ title: 'Northwind: Onboarding, automated', url: 'https://northwind.example/', favicon: fav('N', '#2e6b5b') },
|
|
39
|
+
{ title: 'Workflows — Northwind', url: 'https://northwind.example/app/workflows', favicon: fav('N', '#2e6b5b') },
|
|
40
|
+
{ title: 'Northwind docs', url: 'https://docs.northwind.example/', favicon: fav('N', '#2e6b5b') },
|
|
41
|
+
{ title: 'Electron — Build cross-platform apps', url: 'https://www.electronjs.org/', favicon: fav('E', '#2f3241', 'circle') },
|
|
42
|
+
{ title: 'Example Domain', url: 'https://example.com/', favicon: null },
|
|
43
|
+
{ title: 'Hacker News', url: 'https://news.ycombinator.com/', favicon: fav('Y', '#f26522') },
|
|
44
|
+
{ title: 'MDN Web Docs', url: 'https://developer.mozilla.org/', favicon: fav('M', '#111827') },
|
|
45
|
+
{ title: 'Calendar — this week', url: 'https://calendar.example.com/week', favicon: fav('C', '#0ea5e9') },
|
|
46
|
+
];
|
|
47
|
+
let nextId = 100;
|
|
48
|
+
let nonce = 0;
|
|
49
|
+
const tab = (p) => ({ id: nextId++, title: p.title, url: p.url, favicon: p.favicon, loading: false, audible: !!p.audible, muted: false });
|
|
50
|
+
const blank = () => tab({ title: 'New Tab', url: '', favicon: null });
|
|
51
|
+
const pick = (n, silent) => Array.from({ length: n }, (_, i) => {
|
|
52
|
+
const p = POOL[i % POOL.length];
|
|
53
|
+
const page = i < POOL.length ? p : { title: `${p.title.slice(0, 22)} ${Math.floor(i / POOL.length) + 1}`, url: `${p.url}?p=${i}`, favicon: p.favicon };
|
|
54
|
+
const t = tab(page);
|
|
55
|
+
if (silent)
|
|
56
|
+
t.audible = false;
|
|
57
|
+
return t;
|
|
58
|
+
});
|
|
59
|
+
const at = (tabs, i) => {
|
|
60
|
+
const t = tabs[i];
|
|
61
|
+
if (!t)
|
|
62
|
+
throw new Error(`scene ${scene} has no tab ${i}`);
|
|
63
|
+
return t;
|
|
64
|
+
};
|
|
65
|
+
const sceneTabs = () => {
|
|
66
|
+
switch (scene) {
|
|
67
|
+
case 'single':
|
|
68
|
+
return { tabs: pick(1, true), active: 0 };
|
|
69
|
+
case 'newtab':
|
|
70
|
+
return { tabs: [blank()], active: 0 };
|
|
71
|
+
case 'many': {
|
|
72
|
+
const tabs = pick(18, true);
|
|
73
|
+
at(tabs, 6).audible = true;
|
|
74
|
+
return { tabs, active: 6 };
|
|
75
|
+
}
|
|
76
|
+
case 'loading': {
|
|
77
|
+
const tabs = pick(6, false);
|
|
78
|
+
Object.assign(at(tabs, 0), { loading: true, favicon: null });
|
|
79
|
+
Object.assign(at(tabs, 3), { loading: true });
|
|
80
|
+
Object.assign(at(tabs, 4), { audible: true, muted: true });
|
|
81
|
+
tabs.push(tab(POOL[6]));
|
|
82
|
+
return { tabs, active: 0 };
|
|
83
|
+
}
|
|
84
|
+
case 'pinned':
|
|
85
|
+
return { tabs: pick(5, true), active: 1 };
|
|
86
|
+
default:
|
|
87
|
+
return { tabs: [...pick(5, true), blank()], active: 1 };
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const initial = sceneTabs();
|
|
91
|
+
const st = {
|
|
92
|
+
tabs: initial.tabs,
|
|
93
|
+
activeTabId: at(initial.tabs, initial.active).id,
|
|
94
|
+
canGoBack: true,
|
|
95
|
+
canGoForward: false,
|
|
96
|
+
zoomFactor: 1,
|
|
97
|
+
bar: { visible: params.get('visible') !== '0', pinned: scene === 'pinned' },
|
|
98
|
+
hideExtensionIcons: false,
|
|
99
|
+
extensionActions: 2,
|
|
100
|
+
overlay: null,
|
|
101
|
+
barHeight: 52,
|
|
102
|
+
fullscreen: false,
|
|
103
|
+
};
|
|
104
|
+
const omnibox = (mode, text) => ({ type: 'omnibox', mode, initial: text, nonce: ++nonce });
|
|
105
|
+
if (scene === 'omnibox')
|
|
106
|
+
st.overlay = omnibox('new', 'zap');
|
|
107
|
+
if (scene === 'omnibox-edit')
|
|
108
|
+
st.overlay = omnibox('edit', at(st.tabs, 1).url);
|
|
109
|
+
let listeners = [];
|
|
110
|
+
const calls = [];
|
|
111
|
+
const record = (...call) => void calls.push(call);
|
|
112
|
+
const snapshot = () => structuredClone(st);
|
|
113
|
+
const emit = () => {
|
|
114
|
+
const s = snapshot();
|
|
115
|
+
for (const cb of listeners)
|
|
116
|
+
cb(s);
|
|
117
|
+
};
|
|
118
|
+
const indexOf = (id) => st.tabs.findIndex((t) => t.id === id);
|
|
119
|
+
const activeTab = () => st.tabs.find((t) => t.id === st.activeTabId);
|
|
120
|
+
const looksLikeUrl = (v) => !/\s/.test(v) && (/^[a-z]+:\/\//i.test(v) || /^[^\s/]+\.[a-z]{2,}(\/|$)/i.test(v));
|
|
121
|
+
const normalize = (v) => (/^[a-z]+:\/\//i.test(v) ? v : `https://${v}`);
|
|
122
|
+
const hostOf = (u) => {
|
|
123
|
+
try {
|
|
124
|
+
return new URL(u).hostname.replace(/^www\./, '');
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return u;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const makeSuggestions = (raw) => {
|
|
131
|
+
const q = raw.trim();
|
|
132
|
+
const lq = q.toLowerCase();
|
|
133
|
+
const matches = (p) => !q || p.title.toLowerCase().includes(lq) || p.url.toLowerCase().includes(lq);
|
|
134
|
+
const out = [];
|
|
135
|
+
if (q) {
|
|
136
|
+
out.push(looksLikeUrl(q)
|
|
137
|
+
? { kind: 'url', title: q, url: normalize(q), favicon: null }
|
|
138
|
+
: { kind: 'search', title: `Search Google for “${q}”`, url: `https://www.google.com/search?q=${encodeURIComponent(q)}`, favicon: null });
|
|
139
|
+
}
|
|
140
|
+
for (const t of st.tabs) {
|
|
141
|
+
if ((t.id === st.activeTabId && !q) || !t.url || !matches(t))
|
|
142
|
+
continue;
|
|
143
|
+
out.push({ kind: 'tab', title: t.title, url: t.url, tabId: t.id, favicon: t.favicon });
|
|
144
|
+
}
|
|
145
|
+
for (const h of HISTORY)
|
|
146
|
+
if (matches(h))
|
|
147
|
+
out.push({ kind: 'history', title: h.title, url: h.url, favicon: h.favicon });
|
|
148
|
+
return out.slice(0, 8);
|
|
149
|
+
};
|
|
150
|
+
const api = {
|
|
151
|
+
getState: () => Promise.resolve(snapshot()),
|
|
152
|
+
onState: (cb) => {
|
|
153
|
+
listeners.push(cb);
|
|
154
|
+
return () => {
|
|
155
|
+
listeners = listeners.filter((l) => l !== cb);
|
|
156
|
+
};
|
|
157
|
+
},
|
|
158
|
+
activateTab: (id) => {
|
|
159
|
+
record('activateTab', id);
|
|
160
|
+
st.activeTabId = id;
|
|
161
|
+
emit();
|
|
162
|
+
},
|
|
163
|
+
closeTab: (id) => {
|
|
164
|
+
record('closeTab', id);
|
|
165
|
+
const i = indexOf(id);
|
|
166
|
+
if (i < 0)
|
|
167
|
+
return;
|
|
168
|
+
st.tabs.splice(i, 1);
|
|
169
|
+
if (!st.tabs.length) {
|
|
170
|
+
const b = blank();
|
|
171
|
+
st.tabs.push(b);
|
|
172
|
+
st.activeTabId = b.id;
|
|
173
|
+
}
|
|
174
|
+
else if (st.activeTabId === id)
|
|
175
|
+
st.activeTabId = at(st.tabs, Math.min(i, st.tabs.length - 1)).id;
|
|
176
|
+
emit();
|
|
177
|
+
},
|
|
178
|
+
moveTab: (id, to) => {
|
|
179
|
+
record('moveTab', id, to);
|
|
180
|
+
const i = indexOf(id);
|
|
181
|
+
if (i < 0)
|
|
182
|
+
return;
|
|
183
|
+
st.tabs.splice(to, 0, ...st.tabs.splice(i, 1));
|
|
184
|
+
emit();
|
|
185
|
+
},
|
|
186
|
+
showTabMenu: (id) => record('showTabMenu', id),
|
|
187
|
+
openOmnibox: (mode) => {
|
|
188
|
+
record('openOmnibox', mode);
|
|
189
|
+
st.overlay = omnibox(mode, mode === 'edit' ? (activeTab()?.url ?? '') : '');
|
|
190
|
+
emit();
|
|
191
|
+
},
|
|
192
|
+
closeOverlay: () => {
|
|
193
|
+
record('closeOverlay');
|
|
194
|
+
st.overlay = null;
|
|
195
|
+
emit();
|
|
196
|
+
},
|
|
197
|
+
suggest: (q) => {
|
|
198
|
+
record('suggest', q);
|
|
199
|
+
return new Promise((resolve) => setTimeout(() => resolve(makeSuggestions(q)), q === 'sl' ? 160 : 20));
|
|
200
|
+
},
|
|
201
|
+
submitOmnibox: (text, options) => {
|
|
202
|
+
record('submitOmnibox', text, options);
|
|
203
|
+
const url = looksLikeUrl(text) ? normalize(text) : text;
|
|
204
|
+
const title = hostOf(url);
|
|
205
|
+
if (options.newTab) {
|
|
206
|
+
const t = tab({ title, url, favicon: null });
|
|
207
|
+
st.tabs.push(t);
|
|
208
|
+
st.activeTabId = t.id;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
const a = activeTab();
|
|
212
|
+
if (a)
|
|
213
|
+
Object.assign(a, { url, title, favicon: null });
|
|
214
|
+
}
|
|
215
|
+
st.overlay = null;
|
|
216
|
+
emit();
|
|
217
|
+
},
|
|
218
|
+
back: () => record('back'),
|
|
219
|
+
forward: () => record('forward'),
|
|
220
|
+
reload: () => record('reload'),
|
|
221
|
+
setBarHover: (hovering) => record('setBarHover', hovering),
|
|
222
|
+
passClick: (x, y, button, clickCount) => record('passClick', x, y, button, clickCount),
|
|
223
|
+
startWindowDrag: () => record('startWindowDrag'),
|
|
224
|
+
endWindowDrag: () => record('endWindowDrag'),
|
|
225
|
+
};
|
|
226
|
+
window.stage = api;
|
|
227
|
+
const mockCss = document.createElement('style');
|
|
228
|
+
mockCss.textContent =
|
|
229
|
+
'browser-action-list{display:flex}' +
|
|
230
|
+
'.mock-action{width:24px;height:24px;margin:0 2px;border-radius:6px;display:grid;place-items:center;-webkit-app-region:no-drag}' +
|
|
231
|
+
'.mock-action:hover{background:var(--hover)}' +
|
|
232
|
+
'.mock-action i{width:16px;height:16px;border-radius:5px;background:linear-gradient(135deg,#8b5cf6,#6366f1);display:grid;place-items:center}' +
|
|
233
|
+
'.mock-action svg{width:10px;height:10px}' +
|
|
234
|
+
'#mock-page{position:fixed;inset:0;z-index:-1;overflow:hidden;font:15px/1.5 -apple-system,system-ui,sans-serif;-webkit-user-select:none}' +
|
|
235
|
+
'#mock-page.light{background:#fff;color:#1a1a1a}#mock-page.dark{background:#0d1117;color:#e6edf3}' +
|
|
236
|
+
'#mock-page nav{height:64px;display:flex;align-items:center;gap:28px;padding:0 32px;border-bottom:1px solid rgb(128 128 128/.2)}' +
|
|
237
|
+
'#mock-page .logo{width:28px;height:28px;border-radius:8px;background:#ff4f00}' +
|
|
238
|
+
'#mock-page.dark .logo{background:#2f81f7}' +
|
|
239
|
+
'#mock-page nav b{font-weight:600}#mock-page nav span{opacity:.65;font-size:14px}' +
|
|
240
|
+
'#mock-page nav .cta{margin-left:auto;padding:8px 16px;border-radius:8px;background:#ff4f00;color:#fff;font-weight:600;font-size:14px;opacity:1}' +
|
|
241
|
+
'#mock-page.dark nav .cta{background:#238636}' +
|
|
242
|
+
'#mock-page main{max-width:880px;margin:0 auto;padding:56px 32px}' +
|
|
243
|
+
'#mock-page h1{font-size:44px;line-height:1.1;margin:0 0 16px;letter-spacing:-.03em}' +
|
|
244
|
+
'#mock-page p{margin:0 0 12px;opacity:.72;max-width:640px}' +
|
|
245
|
+
'#mock-page .cards{display:grid;grid-template-columns:repeat(3,1fr);gap:16px;margin-top:32px}' +
|
|
246
|
+
'#mock-page .card{border:1px solid rgb(128 128 128/.25);border-radius:12px;padding:16px;height:120px}' +
|
|
247
|
+
'#mock-page .card i{display:block;height:8px;border-radius:4px;background:rgb(128 128 128/.28);margin-bottom:8px}' +
|
|
248
|
+
'#mock-page pre{margin:24px 0 0;padding:16px;border-radius:10px;background:rgb(128 128 128/.12);font:13px/1.6 ui-monospace,Menlo,monospace;overflow:hidden}';
|
|
249
|
+
if (params.get('anim') === '0')
|
|
250
|
+
mockCss.textContent += '*,*::before,*::after{transition:none!important;animation:none!important}';
|
|
251
|
+
document.head.appendChild(mockCss);
|
|
252
|
+
const backdrop = params.get('backdrop');
|
|
253
|
+
if (backdrop) {
|
|
254
|
+
const page = document.createElement('div');
|
|
255
|
+
page.id = 'mock-page';
|
|
256
|
+
page.className = backdrop === 'dark' ? 'dark' : 'light';
|
|
257
|
+
page.innerHTML =
|
|
258
|
+
'<nav><div class="logo"></div><b>Acme Cloud</b><span>Products</span><span>Solutions</span><span>Docs</span><span>Pricing</span><span class="cta">Get started</span></nav>' +
|
|
259
|
+
'<main><h1>Automate the busywork,<br>keep the craft.</h1>' +
|
|
260
|
+
'<p>Connect the tools your team already uses and let workflows handle the handoffs. Start from a template or build your own in minutes.</p>' +
|
|
261
|
+
'<p>Trusted by teams who present, ship, and iterate in public every week.</p>' +
|
|
262
|
+
'<div class="cards"><div class="card"><i style="width:60%"></i><i></i><i style="width:80%"></i></div><div class="card"><i style="width:50%"></i><i></i><i style="width:70%"></i></div><div class="card"><i style="width:70%"></i><i></i><i style="width:40%"></i></div></div>' +
|
|
263
|
+
'<pre>$ npx stage-browser https://example.com\n✔ opened 3 tabs\n✔ session restored</pre></main>';
|
|
264
|
+
document.body.prepend(page);
|
|
265
|
+
}
|
|
266
|
+
const actions = document.querySelector('browser-action-list');
|
|
267
|
+
if (actions) {
|
|
268
|
+
actions.innerHTML =
|
|
269
|
+
'<span class="mock-action"><i><svg viewBox="0 0 10 10"><path d="M6 0.5L2 5.6h2.4L3.8 9.5 8 4.2H5.5z" fill="#fff"/></svg></i></span>' +
|
|
270
|
+
'<span class="mock-action"><i style="background:linear-gradient(135deg,#10b981,#059669)"><svg viewBox="0 0 10 10"><circle cx="5" cy="5" r="3" fill="none" stroke="#fff" stroke-width="1.6"/></svg></i></span>';
|
|
271
|
+
}
|
|
272
|
+
const describe = (v) => (v === undefined || v === null ? '' : typeof v === 'string' ? v : JSON.stringify(v));
|
|
273
|
+
const runSelfcheck = async (suite) => {
|
|
274
|
+
const results = [];
|
|
275
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
276
|
+
const check = (name, ok, info) => void results.push({ name, ok: !!ok, info: ok ? '' : describe(info) });
|
|
277
|
+
const q = (sel) => {
|
|
278
|
+
const n = document.querySelector(sel);
|
|
279
|
+
if (!n)
|
|
280
|
+
throw new Error(`${sel} not found`);
|
|
281
|
+
return n;
|
|
282
|
+
};
|
|
283
|
+
const qa = (sel) => Array.from(document.querySelectorAll(sel));
|
|
284
|
+
const live = () => qa('#tabs .tab:not(.closing)');
|
|
285
|
+
const rows = () => qa('#omni-list .row');
|
|
286
|
+
const nth = (items, i) => {
|
|
287
|
+
const item = i < 0 ? items[items.length + i] : items[i];
|
|
288
|
+
if (item === undefined)
|
|
289
|
+
throw new Error(`no item ${i} of ${items.length}`);
|
|
290
|
+
return item;
|
|
291
|
+
};
|
|
292
|
+
const idOf = (n) => Number(n.dataset.id);
|
|
293
|
+
const input = () => q('#omni-input');
|
|
294
|
+
const omniOpen = () => !q('#omni').hidden;
|
|
295
|
+
const lastCall = (name) => calls.findLast((c) => c[0] === name);
|
|
296
|
+
const countCalls = (name) => calls.filter((c) => c[0] === name).length;
|
|
297
|
+
const ptr = (type, target, x, y) => target.dispatchEvent(new PointerEvent(type, { bubbles: true, cancelable: true, clientX: x, clientY: y, button: 0, buttons: type === 'pointerup' ? 0 : 1, pointerId: 7, pointerType: 'mouse' }));
|
|
298
|
+
const center = (n) => {
|
|
299
|
+
const r = n.getBoundingClientRect();
|
|
300
|
+
return [r.left + r.width / 2, r.top + r.height / 2];
|
|
301
|
+
};
|
|
302
|
+
const clickTab = (n) => {
|
|
303
|
+
const [x, y] = center(n);
|
|
304
|
+
ptr('pointerdown', n, x, y);
|
|
305
|
+
ptr('pointerup', window, x, y);
|
|
306
|
+
};
|
|
307
|
+
const key = (target, k, init = {}) => target.dispatchEvent(new KeyboardEvent('keydown', { key: k, bubbles: true, cancelable: true, ...init }));
|
|
308
|
+
const type = (v) => {
|
|
309
|
+
const i = input();
|
|
310
|
+
i.value = v;
|
|
311
|
+
i.dispatchEvent(new Event('input', { bubbles: true }));
|
|
312
|
+
};
|
|
313
|
+
const submitted = () => lastCall('submitOmnibox');
|
|
314
|
+
const finish = () => {
|
|
315
|
+
const pass = results.filter((r) => r.ok).length;
|
|
316
|
+
const fail = results.length - pass;
|
|
317
|
+
const out = `SELFCHECK ${fail ? 'FAIL' : 'PASS'} ${pass}/${results.length}\n${results.map((r) => `${r.ok ? ' ok ' : ' FAIL '}${r.name}${r.info ? ` -> ${r.info}` : ''}`).join('\n')}`;
|
|
318
|
+
console.log(out);
|
|
319
|
+
const pre = document.createElement('pre');
|
|
320
|
+
pre.id = 'selfcheck';
|
|
321
|
+
pre.textContent = out;
|
|
322
|
+
pre.style.cssText = 'position:fixed;left:0;bottom:0;margin:0;font:11px monospace;background:#fff;color:#000;z-index:99;display:none';
|
|
323
|
+
document.body.appendChild(pre);
|
|
324
|
+
document.title = `selfcheck ${fail ? 'FAIL' : 'PASS'}`;
|
|
325
|
+
};
|
|
326
|
+
try {
|
|
327
|
+
await sleep(500);
|
|
328
|
+
if (suite === 'many') {
|
|
329
|
+
const tabs = q('#tabs');
|
|
330
|
+
const cap = q('#capsule').getBoundingClientRect();
|
|
331
|
+
check('many: compact class set', tabs.classList.contains('compact'));
|
|
332
|
+
check('many: tabs scroll horizontally when narrow', innerWidth > 900 || tabs.scrollWidth > tabs.clientWidth, `${tabs.scrollWidth} vs ${tabs.clientWidth}`);
|
|
333
|
+
check('many: capsule fits inside strip', cap.right <= innerWidth - 12 + 0.5 && cap.left >= 84 - 0.5, JSON.stringify(cap));
|
|
334
|
+
const inactiveWidth = nth(qa('#tabs .tab:not(.active)'), 0).getBoundingClientRect().width;
|
|
335
|
+
check('many: inactive tabs are favicon-only (36px)', Math.abs(inactiveWidth - 36) < 1, inactiveWidth);
|
|
336
|
+
const ar = q('#tabs .tab.active').getBoundingClientRect();
|
|
337
|
+
const tr = tabs.getBoundingClientRect();
|
|
338
|
+
check('many: active tab scrolled into view', ar.left >= tr.left - 1 && ar.right <= tr.right + 1, `${ar.left}..${ar.right} in ${tr.left}..${tr.right}`);
|
|
339
|
+
return finish();
|
|
340
|
+
}
|
|
341
|
+
const n0 = st.tabs.length;
|
|
342
|
+
const cap = q('#capsule');
|
|
343
|
+
check('renders one element per tab', live().length === n0, `${live().length} vs ${n0}`);
|
|
344
|
+
check('tablist/tab roles', q('#tabs').getAttribute('role') === 'tablist' && live().every((t) => t.getAttribute('role') === 'tab'));
|
|
345
|
+
check('exactly one aria-selected tab', live().filter((t) => t.getAttribute('aria-selected') === 'true').length === 1);
|
|
346
|
+
check('bar is visible', root.classList.contains('bar-visible'));
|
|
347
|
+
check('capsule leaves 84px for traffic lights', cap.getBoundingClientRect().left >= 84 - 0.5, cap.getBoundingClientRect().left);
|
|
348
|
+
check('capsule is 36px tall at top 8px', Math.abs(cap.getBoundingClientRect().height - 36) < 0.5 && cap.offsetTop === 8, JSON.stringify(cap.getBoundingClientRect()));
|
|
349
|
+
cap.dispatchEvent(new MouseEvent('mouseenter'));
|
|
350
|
+
cap.dispatchEvent(new MouseEvent('mouseleave'));
|
|
351
|
+
const hovers = calls.flatMap((c) => (c[0] === 'setBarHover' ? [c[1]] : []));
|
|
352
|
+
check('capsule hover reports setBarHover(true/false)', hovers.join() === 'true,false');
|
|
353
|
+
const t0 = nth(live(), 0);
|
|
354
|
+
t0.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true, cancelable: true, button: 2 }));
|
|
355
|
+
check('right-click calls showTabMenu', lastCall('showTabMenu')?.[1] === idOf(t0));
|
|
356
|
+
const ids = st.tabs.map((t) => t.id);
|
|
357
|
+
const els = live();
|
|
358
|
+
const [ax, ay] = center(nth(els, 0));
|
|
359
|
+
const [cx] = center(nth(els, 2));
|
|
360
|
+
ptr('pointerdown', nth(els, 0), ax, ay);
|
|
361
|
+
ptr('pointermove', window, ax + 8, ay);
|
|
362
|
+
await sleep(30);
|
|
363
|
+
ptr('pointermove', window, cx + 4, ay);
|
|
364
|
+
await sleep(200);
|
|
365
|
+
const shifted = [nth(els, 1), nth(els, 2)].map((n) => n.style.transform);
|
|
366
|
+
check('drag shifts the tabs it passes', shifted.every((t) => t.includes('translateX')), shifted.join('|'));
|
|
367
|
+
ptr('pointerup', window, cx + 4, ay);
|
|
368
|
+
await sleep(400);
|
|
369
|
+
const mv = lastCall('moveTab');
|
|
370
|
+
check('drop calls moveTab(id, 2)', mv?.[1] === ids[0] && mv?.[2] === 2, JSON.stringify(mv));
|
|
371
|
+
check('DOM order matches state after drop', live().map(idOf).join() === st.tabs.map((t) => t.id).join());
|
|
372
|
+
check('no leftover drag transforms', live().every((t) => !t.style.transform));
|
|
373
|
+
check('drag does not trigger omnibox/activation click', countCalls('openOmnibox') === 0);
|
|
374
|
+
const inactive = nth(live().filter((t) => !t.classList.contains('active')), 1);
|
|
375
|
+
clickTab(inactive);
|
|
376
|
+
await sleep(50);
|
|
377
|
+
check('click inactive tab → activateTab', lastCall('activateTab')?.[1] === idOf(inactive));
|
|
378
|
+
check('tab becomes active (aria-selected)', inactive.getAttribute('aria-selected') === 'true' && inactive.classList.contains('active'));
|
|
379
|
+
clickTab(inactive);
|
|
380
|
+
await sleep(80);
|
|
381
|
+
check('click active tab → openOmnibox("edit")', lastCall('openOmnibox')?.[1] === 'edit');
|
|
382
|
+
check('omnibox visible, input focused', omniOpen() && document.activeElement === input());
|
|
383
|
+
const inp = input();
|
|
384
|
+
check('initial value fully selected', inp.value === activeTab()?.url && inp.selectionStart === 0 && inp.selectionEnd === inp.value.length, `${inp.value} ${inp.selectionStart}-${inp.selectionEnd}`);
|
|
385
|
+
key(inp, 'Escape');
|
|
386
|
+
await sleep(30);
|
|
387
|
+
check('Esc → closeOverlay and hides', lastCall('closeOverlay') && !omniOpen());
|
|
388
|
+
q('#new-tab').click();
|
|
389
|
+
await sleep(80);
|
|
390
|
+
check('+ → openOmnibox("new") with empty field', lastCall('openOmnibox')?.[1] === 'new' && omniOpen() && input().value === '');
|
|
391
|
+
type('northwind');
|
|
392
|
+
await sleep(250);
|
|
393
|
+
const r = rows();
|
|
394
|
+
check('suggestions render (≤ 8)', r.length > 1 && r.length <= 8, r.length);
|
|
395
|
+
check('first row highlighted by default', r[0]?.classList.contains('sel'));
|
|
396
|
+
key(input(), 'ArrowDown');
|
|
397
|
+
check('ArrowDown moves highlight', nth(rows(), 1).classList.contains('sel') && !nth(rows(), 0).classList.contains('sel'));
|
|
398
|
+
key(input(), 'ArrowUp');
|
|
399
|
+
check('ArrowUp moves back', nth(rows(), 0).classList.contains('sel'));
|
|
400
|
+
key(input(), 'ArrowUp');
|
|
401
|
+
check('ArrowUp wraps to last', nth(rows(), -1).classList.contains('sel'));
|
|
402
|
+
nth(rows(), 1).dispatchEvent(new MouseEvent('mousemove', { bubbles: true }));
|
|
403
|
+
check('hover moves highlight', nth(rows(), 1).classList.contains('sel'));
|
|
404
|
+
const tabRow = rows().findIndex((x) => x.classList.contains('is-tab'));
|
|
405
|
+
check('a tab suggestion exists', tabRow >= 0);
|
|
406
|
+
if (tabRow >= 0) {
|
|
407
|
+
nth(rows(), tabRow).dispatchEvent(new MouseEvent('mousemove', { bubbles: true }));
|
|
408
|
+
check('tab row shows "Switch to tab" hint', /Switch to tab/.test(nth(rows(), tabRow).textContent ?? ''));
|
|
409
|
+
const before = countCalls('closeOverlay');
|
|
410
|
+
key(input(), 'Enter');
|
|
411
|
+
await sleep(30);
|
|
412
|
+
check('Enter on tab suggestion → activateTab + closeOverlay', lastCall('activateTab') && countCalls('closeOverlay') === before + 1 && !omniOpen());
|
|
413
|
+
}
|
|
414
|
+
q('#new-tab').click();
|
|
415
|
+
await sleep(60);
|
|
416
|
+
type('example.com');
|
|
417
|
+
await sleep(200);
|
|
418
|
+
check('url-like input shows globe glyph', !!document.querySelector('#omni-glyph svg circle') && !document.querySelector('#omni-glyph svg path[d^="M13.2"]'));
|
|
419
|
+
key(input(), 'Enter');
|
|
420
|
+
await sleep(30);
|
|
421
|
+
let sub = submitted();
|
|
422
|
+
check('mode new: Enter → submitOmnibox(url, newTab:true)', sub && /example\.com/.test(sub[1]) && sub[2].newTab, JSON.stringify(sub));
|
|
423
|
+
api.openOmnibox('edit');
|
|
424
|
+
await sleep(60);
|
|
425
|
+
type('other.org');
|
|
426
|
+
await sleep(200);
|
|
427
|
+
key(input(), 'Enter');
|
|
428
|
+
await sleep(30);
|
|
429
|
+
sub = submitted();
|
|
430
|
+
check('mode edit: Enter → newTab:false', sub && /other\.org/.test(sub[1]) && !sub[2].newTab, JSON.stringify(sub));
|
|
431
|
+
api.openOmnibox('edit');
|
|
432
|
+
await sleep(60);
|
|
433
|
+
type('third.net');
|
|
434
|
+
await sleep(200);
|
|
435
|
+
key(input(), 'Enter', { metaKey: true });
|
|
436
|
+
await sleep(30);
|
|
437
|
+
sub = submitted();
|
|
438
|
+
check('mode edit: Cmd+Enter → newTab:true', sub && /third\.net/.test(sub[1]) && sub[2].newTab, JSON.stringify(sub));
|
|
439
|
+
q('#new-tab').click();
|
|
440
|
+
await sleep(60);
|
|
441
|
+
type('sl');
|
|
442
|
+
await sleep(90);
|
|
443
|
+
type('slx');
|
|
444
|
+
await sleep(350);
|
|
445
|
+
const first = rows()[0];
|
|
446
|
+
check('stale suggest() response is dropped', first && /slx/.test(first.textContent ?? '') && !/“sl”/.test(first.textContent ?? ''), first?.textContent);
|
|
447
|
+
type('quickly typed words');
|
|
448
|
+
key(input(), 'Enter');
|
|
449
|
+
await sleep(30);
|
|
450
|
+
sub = submitted();
|
|
451
|
+
check('Enter before debounce submits raw input', sub?.[1] === 'quickly typed words', JSON.stringify(sub));
|
|
452
|
+
q('#new-tab').click();
|
|
453
|
+
await sleep(60);
|
|
454
|
+
q('#omni-backdrop').dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
|
|
455
|
+
await sleep(30);
|
|
456
|
+
check('backdrop click → closeOverlay', !omniOpen());
|
|
457
|
+
const victim = nth(live(), 0);
|
|
458
|
+
const vid = idOf(victim);
|
|
459
|
+
const before = live().length;
|
|
460
|
+
victim.dispatchEvent(new MouseEvent('auxclick', { bubbles: true, cancelable: true, button: 1 }));
|
|
461
|
+
await sleep(400);
|
|
462
|
+
check('middle-click → closeTab', lastCall('closeTab')?.[1] === vid);
|
|
463
|
+
check('closed tab leaves the DOM', live().length === before - 1 && !qa('#tabs .tab').some((t) => idOf(t) === vid), `${live().length} ${qa('#tabs .tab').length}`);
|
|
464
|
+
const v2 = nth(live(), 1);
|
|
465
|
+
const v2id = idOf(v2);
|
|
466
|
+
v2.querySelector('.close')?.click();
|
|
467
|
+
await sleep(400);
|
|
468
|
+
check('close button → closeTab', lastCall('closeTab')?.[1] === v2id);
|
|
469
|
+
finish();
|
|
470
|
+
}
|
|
471
|
+
catch (e) {
|
|
472
|
+
check('selfcheck threw', false, e instanceof Error ? e.stack : e);
|
|
473
|
+
finish();
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
const suite = params.get('selfcheck');
|
|
477
|
+
if (suite)
|
|
478
|
+
window.addEventListener('load', () => setTimeout(() => void runSelfcheck(suite), 400));
|
|
479
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
7
|
+
<title>New Tab</title>
|
|
8
|
+
<style>
|
|
9
|
+
:root {
|
|
10
|
+
color-scheme: light dark;
|
|
11
|
+
--bg: light-dark(#f6f6f7, #131316);
|
|
12
|
+
--glow: light-dark(rgb(255 255 255 / .9), rgb(255 255 255 / .06));
|
|
13
|
+
--text: light-dark(#1d1d1f, #f5f5f7);
|
|
14
|
+
--muted: light-dark(rgb(60 60 67 / .6), rgb(235 235 245 / .5));
|
|
15
|
+
--kbd-bg: light-dark(rgb(0 0 0 / .05), rgb(255 255 255 / .08));
|
|
16
|
+
--kbd-line: light-dark(rgb(0 0 0 / .09), rgb(255 255 255 / .1));
|
|
17
|
+
}
|
|
18
|
+
* { box-sizing: border-box; }
|
|
19
|
+
html, body { height: 100%; margin: 0; }
|
|
20
|
+
body {
|
|
21
|
+
display: grid;
|
|
22
|
+
place-items: center;
|
|
23
|
+
background:
|
|
24
|
+
radial-gradient(ellipse 60% 50% at 50% 38%, var(--glow), transparent 70%),
|
|
25
|
+
var(--bg);
|
|
26
|
+
color: var(--text);
|
|
27
|
+
font: 400 14px/20px -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
|
|
28
|
+
-webkit-font-smoothing: antialiased;
|
|
29
|
+
-webkit-user-select: none;
|
|
30
|
+
user-select: none;
|
|
31
|
+
cursor: default;
|
|
32
|
+
}
|
|
33
|
+
main { display: grid; justify-items: center; gap: 24px; transform: translateY(-4vh); animation: in 600ms cubic-bezier(.2,.8,.2,1) both; }
|
|
34
|
+
.mark { width: 40px; height: 40px; }
|
|
35
|
+
h1 { margin: 0; font: 600 15px/20px inherit; font-family: inherit; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
|
|
36
|
+
ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; justify-items: center; color: var(--muted); }
|
|
37
|
+
li { display: flex; align-items: center; gap: 8px; }
|
|
38
|
+
kbd {
|
|
39
|
+
font: 500 12px/20px inherit; font-family: inherit;
|
|
40
|
+
min-width: 24px; padding: 0 6px; text-align: center;
|
|
41
|
+
border-radius: 6px; background: var(--kbd-bg); box-shadow: inset 0 0 0 .5px var(--kbd-line);
|
|
42
|
+
color: var(--text);
|
|
43
|
+
}
|
|
44
|
+
@keyframes in { from { opacity: 0; transform: translateY(calc(-4vh + 6px)); } }
|
|
45
|
+
@media (prefers-reduced-motion: reduce) { main { animation: none; } }
|
|
46
|
+
</style>
|
|
47
|
+
</head>
|
|
48
|
+
<body>
|
|
49
|
+
<main>
|
|
50
|
+
<svg class="mark" viewBox="0 0 40 40" aria-hidden="true">
|
|
51
|
+
<defs>
|
|
52
|
+
<linearGradient id="beam" x1="0" y1="0" x2="0" y2="1">
|
|
53
|
+
<stop offset="0" stop-color="currentColor" stop-opacity=".0"/>
|
|
54
|
+
<stop offset="1" stop-color="currentColor" stop-opacity=".16"/>
|
|
55
|
+
</linearGradient>
|
|
56
|
+
</defs>
|
|
57
|
+
<g style="color: var(--text)">
|
|
58
|
+
<path d="M17 2h6l9 22H8z" fill="url(#beam)"/>
|
|
59
|
+
<rect x="6" y="24" width="28" height="12" rx="4" fill="none" stroke="currentColor" stroke-opacity=".7" stroke-width="2"/>
|
|
60
|
+
</g>
|
|
61
|
+
</svg>
|
|
62
|
+
<h1>Stage</h1>
|
|
63
|
+
<ul>
|
|
64
|
+
<li><kbd>⌘L</kbd> open a page</li>
|
|
65
|
+
<li>move to the top edge for tabs</li>
|
|
66
|
+
</ul>
|
|
67
|
+
</main>
|
|
68
|
+
</body>
|
|
69
|
+
</html>
|