Skip to content

Commit c60335e

Browse files
authored
Merge branch 'main' into yoon_waitlist
2 parents 3f0d3d2 + 8db869b commit c60335e

23 files changed

Lines changed: 897 additions & 228 deletions

.github/workflows/best-practices.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Best Practices
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
check:
59
runs-on: ubuntu-latest

.github/workflows/check-types.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Type Check
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
type-check:
59
runs-on: ubuntu-latest

.github/workflows/chromatic.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: 'Chromatic'
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
chromatic:
59
runs-on: ubuntu-latest

.github/workflows/nix-flake-check.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Nix Flake Check
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
nix-flake:
59
name: Nix Flake Check

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Tests
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37
jobs:
48
test:
59
runs-on: ubuntu-latest

.storybook/chrome-mock.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="chrome" />
22
import { version } from '../package.json';
3+
import deepEqual from 'fast-deep-equal/es6';
34

45
type ListenerFunction = (
56
changes: { [key: string]: chrome.storage.StorageChange },
@@ -18,13 +19,13 @@ function createMockStorageArea(areaName: chrome.storage.AreaName) {
1819
if (Array.isArray(keys)) {
1920
return keys.reduce(
2021
(acc, key) => {
21-
acc[key] = data[key];
22+
acc[key] = structuredClone(data[key]);
2223
return acc;
2324
},
2425
{} as Record<string, any>
2526
);
2627
}
27-
if (typeof keys === 'string') return { [keys]: data[keys] };
28+
if (typeof keys === 'string') return { [keys]: structuredClone(data[keys]) };
2829
return keys;
2930
},
3031
async getBytesInUse() {
@@ -40,11 +41,20 @@ function createMockStorageArea(areaName: chrome.storage.AreaName) {
4041
}
4142
},
4243
async set(items: { [key: string]: any }) {
43-
for (const key in items) {
44+
let hasUpdates = false;
45+
const updates: Record<string, chrome.storage.StorageChange> = {};
46+
for (const [key, newValue] of Object.entries(items)) {
4447
const oldValue = data[key];
45-
data[key] = JSON.parse(JSON.stringify(items[key]));
48+
if (!deepEqual(newValue, oldValue)) {
49+
hasUpdates = true;
50+
data[key] = structuredClone(newValue);
51+
updates[key] = { oldValue, newValue };
52+
}
53+
}
54+
55+
if (hasUpdates) {
4656
for (const listener of allListeners.values()) {
47-
listener({ [key]: { oldValue, newValue: data[key] } }, areaName);
57+
listener(structuredClone(updates), areaName);
4858
}
4959
}
5060
},

.storybook/fetch-mock.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Must load before any module that calls fetch() (e.g. GitHubStatsService) evaluates.
2+
// GitHubStatsService hits the real GitHub API on mount; in Chromatic's sandboxed
3+
// browser that request hangs/fails with no network access, timing out story capture.
4+
const realFetch = globalThis.fetch;
5+
6+
const MOCKED_HOSTS = ['github.cachedapi.com', 'api.github.com'];
7+
8+
function resolveUrl(input: RequestInfo | URL): string {
9+
if (typeof input === 'string') return input;
10+
if (input instanceof URL) return input.href;
11+
return input.url;
12+
}
13+
14+
globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
15+
const url = resolveUrl(input);
16+
17+
if (MOCKED_HOSTS.some(host => url.includes(host))) {
18+
return new Response(JSON.stringify([]), {
19+
status: 200,
20+
headers: { 'Content-Type': 'application/json' },
21+
});
22+
}
23+
24+
return realFetch(input, init);
25+
};

.storybook/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { StorybookConfig } from '@storybook/react-vite';
22

33
const config: StorybookConfig = {
44
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5-
addons: ['@storybook/addon-designs', '@chromatic-com/storybook'],
5+
addons: ['@storybook/addon-docs', '@storybook/addon-designs', '@chromatic-com/storybook'],
66
framework: {
77
name: '@storybook/react-vite',
88
options: {

.storybook/preview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// Must be first importsets up globalThis.chrome before any other module evaluates
1+
// Must be first importsset up globalThis.chrome/fetch before any other module evaluates
22
import './chrome-mock';
3+
import './fetch-mock';
34

45
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';
56
import type { Preview } from '@storybook/react-vite';

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
},
6262
"devDependencies": {
6363
"@biomejs/biome": "2.4.10",
64-
"@chromatic-com/storybook": "^5.1.1",
64+
"@chromatic-com/storybook": "^5.3.0",
6565
"@commitlint/cli": "^20.5.0",
6666
"@commitlint/config-conventional": "^20.5.0",
6767
"@commitlint/types": "^20.5.0",
@@ -71,9 +71,10 @@
7171
"@iconify-json/ph": "^1.2.2",
7272
"@semantic-release/exec": "^7.1.0",
7373
"@sentry/toolbar": "1.0.0-beta.11",
74-
"@storybook/addon-designs": "^11.1.3",
75-
"@storybook/react": "^10.3.5",
76-
"@storybook/react-vite": "^10.3.5",
74+
"@storybook/addon-designs": "^11.1.4",
75+
"@storybook/addon-docs": "^10.5.8",
76+
"@storybook/react": "^10.5.8",
77+
"@storybook/react-vite": "^10.5.8",
7778
"@svgr/plugin-jsx": "^8.1.0",
7879
"@types/chrome": "^0.1.39",
7980
"@types/conventional-changelog": "^6.0.1",
@@ -97,6 +98,7 @@
9798
"chalk": "^5.6.2",
9899
"chromatic": "^16.1.0",
99100
"conventional-changelog": "^7.2.0",
101+
"fast-deep-equal": "^3.1.3",
100102
"gulp": "^5.0.1",
101103
"gulp-execa": "^8.0.1",
102104
"gulp-zip": "^6.1.0",
@@ -107,7 +109,7 @@
107109
"sass": "^1.99.0",
108110
"semantic-release": "^25.0.3",
109111
"simple-git": "^3.35.2",
110-
"storybook": "^10.3.5",
112+
"storybook": "^10.5.8",
111113
"typescript": "^6.0.2",
112114
"unocss": "^66.6.8",
113115
"unocss-preset-primitives": "0.0.2-beta.2",

0 commit comments

Comments
 (0)