Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
b385721
fix: improve readability of analytics package
PatrykKuniczak Dec 24, 2025
66ac94c
clean(analysis): make code more readable and fix null check for mappe…
PatrykKuniczak Dec 24, 2025
7464c9f
fix(packages/i18n): remove unnecessary staff from tests and add question
PatrykKuniczak Dec 25, 2025
e7cae21
fix(packages/i18n): improve readability of code
PatrykKuniczak Dec 25, 2025
b94b080
fix(packages/runner): remove unnecessary code
PatrykKuniczak Dec 25, 2025
554e539
fix(packages/runner): add clearingTimeout on createBidiConnection -> …
PatrykKuniczak Dec 25, 2025
26428ed
fix(packages/wxt): add missing `lang` prop for <html> for couple e2e …
PatrykKuniczak Dec 25, 2025
3a9a2f6
clean(packages/wxt): make code more readable
PatrykKuniczak Dec 25, 2025
24a8f65
fix(packages/wxt): change HtmlPublicPath from `type` to `const` for f…
PatrykKuniczak Dec 25, 2025
8e1e2dc
fix(packages/wxt): add missing `lang` to `html` on devHtmlPrerender.t…
PatrykKuniczak Dec 26, 2025
a1f8c49
clean(packages/wxt): improve readability of plugins
PatrykKuniczak Dec 26, 2025
c098b15
clean(packages/wxt): improve readability of code for core/package-man…
PatrykKuniczak Dec 26, 2025
c4d96b6
clean(packages/wxt): make code more readable and make number and stri…
PatrykKuniczak Dec 26, 2025
74c029b
clean(packages/wxt): make code more readable and make number and stri…
PatrykKuniczak Dec 26, 2025
f734f08
clean(packages/wxt-demo): make code more readable
PatrykKuniczak Feb 8, 2026
7caeb77
clean(packages/i18n): make number and string const UPPER_CASE
PatrykKuniczak Dec 27, 2025
c18cdbe
fix(packages/wxt): import of a to A, after UPPER_CASE conversion
PatrykKuniczak Dec 27, 2025
ab4fb5b
clean(packages/i18n): improve code readability
PatrykKuniczak Dec 28, 2025
f54fa33
clean(packages/analytics): improve code readability
PatrykKuniczak Dec 28, 2025
63b0464
clean(packages/module-react): improve code readability
PatrykKuniczak Dec 28, 2025
32c858f
clean(packages/module-solid): improve code readability
PatrykKuniczak Dec 28, 2025
54e359a
clean(packages/runner): improve code readability, make strings UPPER_…
PatrykKuniczak Dec 28, 2025
5be9b32
clean(packages/storage): improve code readability, remove unnecessary…
PatrykKuniczak Dec 28, 2025
551f8f2
clean(packages/unocss): improve code readability
PatrykKuniczak Dec 28, 2025
4a1ee60
clean(packages/wxt/e2e): make code more readable and remove some unne…
PatrykKuniczak Dec 28, 2025
b17d40f
clean(packages/wxt/__tests__): make code more readable and add as con…
PatrykKuniczak Dec 29, 2025
5d1e4d3
clean(packages/wxt/builtin-modules): make code more readable
PatrykKuniczak Dec 29, 2025
49d89a9
clean(packages/wxt/cli): make code more readable
PatrykKuniczak Dec 29, 2025
5e95e5f
clean(packages/wxt/core): make code more readable, remove some unnece…
PatrykKuniczak Dec 29, 2025
6ebcb40
clean(packages/wxt/utils): make code more readable and add questions
PatrykKuniczak Dec 29, 2025
98648c0
clean(packages/wxt/utils): make code more readable, add question and …
PatrykKuniczak Dec 29, 2025
245f79b
clean(packages/wxt): make code more readable
PatrykKuniczak Dec 29, 2025
0ee35d5
fix(wxt): remove question of validation.test.ts
PatrykKuniczak Feb 8, 2026
23baaad
chore(runner): add fs-extra as dep
PatrykKuniczak Feb 8, 2026
4506538
fix(module-react): add missing imports
PatrykKuniczak Feb 8, 2026
3afeed2
fix(module-react): remove unnecessary `App` import
PatrykKuniczak Feb 8, 2026
6eb779b
Revert "fix(module-react): remove unnecessary `App` import"
PatrykKuniczak Feb 8, 2026
7e225c5
Revert "fix(module-react): add missing imports"
PatrykKuniczak Feb 8, 2026
cbd98c3
fix(i18n): add missing @ts-expect-error
PatrykKuniczak Feb 8, 2026
33706f0
fix(wxt-demo): remove unused `@ts-expect-error`
PatrykKuniczak Feb 8, 2026
cd4ff8e
fix: set return type back to googleAnalytics4
PatrykKuniczak Feb 8, 2026
a656c5e
fix: back `==` null check for user properties mapping
PatrykKuniczak Feb 8, 2026
28ed1ba
Update packages/i18n/src/module.ts
PatrykKuniczak Feb 8, 2026
67b74d7
Update packages/i18n/src/utils.ts
PatrykKuniczak Feb 8, 2026
95b9836
fix(wxt): revert `HtmlPublicPath` to be `type` as before
PatrykKuniczak Feb 8, 2026
503a25d
fix: back `await`, next to `return` to content-script-isolated-world-…
PatrykKuniczak Feb 8, 2026
0890360
fix: back `await`, next to `return` to install.ts
PatrykKuniczak Feb 8, 2026
9272b89
fix: back `await`, next to `return` to content-script-main-world-entr…
PatrykKuniczak Feb 8, 2026
fd9d635
fix: back comment to reload-html.ts
PatrykKuniczak Feb 8, 2026
5be991b
Update packages/wxt/src/version.ts
PatrykKuniczak Feb 8, 2026
cd6ddb3
fix(i18n): back `await` before Promise.all
PatrykKuniczak Feb 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/analytics/modules/analytics/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ function createBackgroundAnalytics(
function createFrontendAnalytics(): Analytics {
const port = browser.runtime.connect({ name: ANALYTICS_PORT });
const sessionId = Date.now();

const getFrontendMetadata = (): AnalyticsEventMetadata => ({
sessionId,
timestamp: Date.now(),
Expand Down
1 change: 1 addition & 0 deletions packages/analytics/modules/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const analytics = createAnalytics(useAppConfig().analytics);
const hasBackground = entrypoints.find(
(entry) => entry.type === 'background',
);

if (!hasBackground) {
entrypoints.push({
type: 'background',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ export const googleAnalytics4 =
config?.debug ? '/debug/mp/collect' : '/mp/collect',
options.apiUrl ?? 'https://www.google-analytics.com',
);

if (options.apiSecret)
url.searchParams.set('api_secret', options.apiSecret);

if (options.measurementId)
url.searchParams.set('measurement_id', options.measurementId);

Expand Down
1 change: 1 addition & 0 deletions packages/analytics/modules/analytics/providers/umami.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const umami = defineAnalyticsProvider<UmamiProviderOptions>(
if (config.debug) {
console.debug('[@wxt-dev/analytics] Sending event to Umami:', payload);
}

return fetch(`${options.apiUrl}/send`, {
method: 'POST',
headers: {
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/__tests__/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('Built Tools', () => {
const messages = await parseMessagesFile(`file.yml`);
await generateChromeMessagesFile('output.json', messages);
await generateTypeFile('output.d.ts', messages);

const actualChromeMessagesFile = mockWriteFile.mock.calls[0][1];
const actualDtsFile = mockWriteFile.mock.calls[1][1];

Expand Down
6 changes: 3 additions & 3 deletions packages/i18n/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ describe('createI18n', () => {
(rawMessage, count, expected) => {
const i18n = createI18n();
getMessageMock.mockReturnValue(rawMessage);
const key = 'items';
const KEY = 'items';

const actual = i18n.t(key, count);
const actual = i18n.t(KEY, count);

expect(actual).toBe(expected);
expect(getMessageMock).toBeCalledTimes(1);
expect(getMessageMock).toBeCalledWith(key, [String(count)]);
expect(getMessageMock).toBeCalledWith(KEY, [String(count)]);
},
);

Expand Down
34 changes: 18 additions & 16 deletions packages/i18n/src/__tests__/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { browser } from '@wxt-dev/browser';

vi.mock('@wxt-dev/browser', async () => {
const { vi } = await import('vitest');

return {
browser: {
i18n: {
Expand All @@ -14,7 +15,7 @@ vi.mock('@wxt-dev/browser', async () => {
});
const getMessageMock = vi.mocked(browser.i18n.getMessage);

const n: number = 1;
const N = 1;

describe('I18n Types', () => {
beforeEach(() => {
Expand All @@ -29,7 +30,7 @@ describe('I18n Types', () => {
i18n.t('any');
i18n.t('any', ['one']);
i18n.t('any', ['one', 'two']);
i18n.t('any', n, ['one', 'two']);
i18n.t('any', N, ['one', 'two']);
});
});
});
Expand All @@ -52,7 +53,7 @@ describe('I18n Types', () => {
// @ts-expect-error
i18n.t('simple', ['one']);
// @ts-expect-error
i18n.t('simple', n);
i18n.t('simple', N);

i18n.t('simpleSub1', ['one']);
// @ts-expect-error
Expand All @@ -62,7 +63,7 @@ describe('I18n Types', () => {
// @ts-expect-error
i18n.t('simpleSub1', ['one', 'two']);
// @ts-expect-error
i18n.t('simpleSub1', n);
i18n.t('simpleSub1', N);

i18n.t('simpleSub2', ['one', 'two']);
// @ts-expect-error
Expand All @@ -72,41 +73,42 @@ describe('I18n Types', () => {
// @ts-expect-error
i18n.t('simpleSub2', ['one', 'two', 'three']);
// @ts-expect-error
i18n.t('simpleSub2', n);
i18n.t('simpleSub2', N);

i18n.t('plural', n);
i18n.t('plural', N);
// @ts-expect-error
i18n.t('plural');
// @ts-expect-error
i18n.t('plural', []);
// @ts-expect-error
i18n.t('plural', ['one']);
// @ts-expect-error
i18n.t('plural', n, ['sub']);
i18n.t('plural', N, ['sub']);

i18n.t('pluralSub1', N);
i18n.t('pluralSub1', N, undefined);
i18n.t('pluralSub1', N, ['one']);

i18n.t('pluralSub1', n);
i18n.t('pluralSub1', n, undefined);
i18n.t('pluralSub1', n, ['one']);
// @ts-expect-error
i18n.t('pluralSub1');
// @ts-expect-error
i18n.t('pluralSub1', ['one']);
// @ts-expect-error
i18n.t('pluralSub1', n, []);
i18n.t('pluralSub1', N, []);
// @ts-expect-error
i18n.t('pluralSub1', n, ['one', 'two']);
i18n.t('pluralSub1', N, ['one', 'two']);

i18n.t('pluralSub2', n, ['one', 'two']);
i18n.t('pluralSub2', N, ['one', 'two']);
// @ts-expect-error
i18n.t('pluralSub2');
// @ts-expect-error
i18n.t('pluralSub2', ['one', 'two']);
// @ts-expect-error
i18n.t('pluralSub2', n, ['one']);
i18n.t('pluralSub2', N, ['one']);
// @ts-expect-error
i18n.t('pluralSub2', n, ['one', 'two', 'three']);
i18n.t('pluralSub2', N, ['one', 'two', 'three']);
// @ts-expect-error
i18n.t('pluralSub2', n);
i18n.t('pluralSub2', N);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/i18n/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect } from 'vitest';
import { describe, expect, it } from 'vitest';
import { ChromeMessage } from '../build';
import {
applyChromeMessagePlaceholders,
Expand Down
4 changes: 3 additions & 1 deletion packages/i18n/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { mkdir, readFile, writeFile } from 'node:fs/promises';
import { parseYAML, parseJSON5, parseTOML } from 'confbox';
import { parseJSON5, parseTOML, parseYAML } from 'confbox';
import { dirname, extname } from 'node:path';
import { applyChromeMessagePlaceholders, getSubstitutionCount } from './utils';

Expand Down Expand Up @@ -191,6 +191,7 @@ function _parseMessagesObject(
if (isPluralMessage(object)) {
const message = Object.values(object).join('|');
const substitutions = getSubstitutionCount(message);

return [
{
type: 'plural',
Expand All @@ -204,6 +205,7 @@ function _parseMessagesObject(
if (depth === 1 && isChromeMessage(object)) {
const message = applyChromeMessagePlaceholders(object);
const substitutions = getSubstitutionCount(message);

return [
{
type: 'chrome',
Expand Down
6 changes: 5 additions & 1 deletion packages/i18n/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @module @wxt-dev/i18n */
import {
I18nStructure,
DefaultI18nStructure,
I18n,
I18nStructure,
Substitution,
} from './types';
import { browser } from '@wxt-dev/browser';
Expand All @@ -14,6 +14,7 @@ export function createI18n<
// Resolve args
let sub: Substitution[] | undefined;
let count: number | undefined;

args.forEach((arg, i) => {
if (arg == null) {
// ignore nullish args
Expand All @@ -35,16 +36,19 @@ export function createI18n<

// Load the localization
let message: string;

if (sub?.length) {
// Convert all substitutions to strings
const stringSubs = sub?.map((sub) => String(sub));
message = browser.i18n.getMessage(key.replaceAll('.', '_'), stringSubs);
} else {
message = browser.i18n.getMessage(key.replaceAll('.', '_'));
}

if (!message) {
console.warn(`[i18n] Message not found: "${key}"`);
}

if (count == null) return message;

// Apply pluralization
Expand Down
10 changes: 8 additions & 2 deletions packages/i18n/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import 'wxt';
import { addAlias, defineWxtModule } from 'wxt/modules';
import {
generateChromeMessagesText,
parseMessagesFile,
generateTypeText,
parseMessagesFile,
SUPPORTED_LOCALES,
} from './build';
import { glob } from 'tinyglobby';
Expand All @@ -36,6 +36,7 @@ export default defineWxtModule<I18nOptions>({
);
return;
}

wxt.logger.info(
'`[i18n]` Default locale: ' + wxt.config.manifest.default_locale,
);
Expand All @@ -55,7 +56,9 @@ export default defineWxtModule<I18nOptions>({
const res = files.map((file) => {
const rawLocale = basename(file).replace(extname(file), '');
const locale = standardizeLocale(rawLocale);

if (!SUPPORTED_LOCALES.has(locale)) unsupportedLocales.push(locale);

return { file, locale };
});

Expand All @@ -71,6 +74,7 @@ export default defineWxtModule<I18nOptions>({
GeneratedPublicFile[]
> => {
const files = await getLocalizationFiles();

return await Promise.all(
files.map(async ({ file, locale }) => {
const messages = await parseMessagesFile(file);
Expand All @@ -87,13 +91,15 @@ export default defineWxtModule<I18nOptions>({
const defaultLocaleFile = files.find(
({ locale }) => locale === wxt.config.manifest.default_locale,
)!;

if (defaultLocaleFile == null) {
throw Error(
`\`[i18n]\` Required localization file does not exist: \`<localesDir>/${wxt.config.manifest.default_locale}.{json|json5|jsonc|yml|yaml|toml}\``,
);
}

const messages = await parseMessagesFile(defaultLocaleFile.file);

return {
path: typesPath,
text: generateTypeText(messages),
Expand Down Expand Up @@ -153,7 +159,7 @@ export { type GeneratedI18nStructure }

addAlias(wxt, '#i18n', sourcePath);

// Generate separate declaration file containing types - this prevents
// Generate a separate declaration file containing types - this prevents
// firing the dev server's default file watcher when updating the types,
// which would cause a full rebuild and reload of the extension.

Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function standardizeLocale(locale: string): string {

const [is_match, prefix, suffix] =
locale.match(/^([a-z]{2})[-_]([a-z]{2,3})$/i) ?? [];

if (is_match) {
return `${prefix.toLowerCase()}_${suffix.toUpperCase()}`;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/module-react/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export default function () {
const [count, setCount] = useState(0);

const increment = () => setCount((count) => count + 1);

return <button onClick={increment}>Count: {count}</button>;
}
1 change: 1 addition & 0 deletions packages/module-react/entrypoints/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function createUi(ctx: ContentScriptContext) {
append: 'first',
onMount(container) {
const root = ReactDOM.createRoot(container);

root.render(
<React.StrictMode>
<App />
Expand Down
2 changes: 2 additions & 0 deletions packages/module-solid/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Component } from 'solid-js';

export const App: Component = () => {
const [count, setCount] = createSignal(0);

const increment = () => setCount((count) => count + 1);

return <button onClick={increment}>Count: {count()}</button>;
};
3 changes: 3 additions & 0 deletions packages/runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
},
"license": "MIT",
"funding": "https://github.com/sponsors/wxt-dev",
"dependencies": {
"fs-extra": "^11.2.0"
},
"scripts": {
"check": "bun run build && check",
"test": "buildc --deps-only -- vitest",
Expand Down
Loading
Loading