Compare commits

...

6 Commits

Author SHA1 Message Date
GitHub Actions 8771676e69 chore(release): wxt v0.19.8 2024-08-29 11:53:13 +00:00
1natsu aebbbb0685 fix: Fallback to GitHub API for listing templates when ungh is down (#944)
Co-authored-by: Aaron <aaronklinker1@gmail.com>
2024-08-29 06:48:38 -05:00
Aaron 68183b648e chore(types): Cleanup types in wxt/browser/chrome (#932) 2024-08-23 08:49:39 -05:00
Aaron Klinker 45809c0198 chore: Update lockfile 2024-08-19 23:08:40 -05:00
Aaron Klinker 13163c9ba1 chore(dev-deps): Upgrade @aklinker1/buildc from v1.0.11 to v1.1.0 2024-08-19 21:49:01 -05:00
1natsu aedbba3f3d perf: Ignore output directories for all vite.watcher (#924) 2024-08-19 21:44:27 -05:00
7 changed files with 91 additions and 55 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
"docs:preview": "pnpm -s docs:gen && vitepress preview docs"
},
"devDependencies": {
"@aklinker1/buildc": "^1.0.11",
"@aklinker1/buildc": "^1.1.0",
"@aklinker1/check": "^1.3.1",
"@types/fs-extra": "^11.0.4",
"@vitest/coverage-v8": "^2.0.4",
+20
View File
@@ -1,5 +1,25 @@
# Changelog
## v0.19.8
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.19.7...wxt-v0.19.8)
### 🔥 Performance
- Ignore output directories for all `vite.watcher` ([#924](https://github.com/wxt-dev/wxt/pull/924))
### 🩹 Fixes
- Fallback to GitHub API for listing templates when ungh is down ([#944](https://github.com/wxt-dev/wxt/pull/944))
### 🏡 Chore
- **types:** Cleanup types in wxt/browser/chrome ([#932](https://github.com/wxt-dev/wxt/pull/932))
### ❤️ Contributors
- 1natsu
## v0.19.7
[compare changes](https://github.com/wxt-dev/wxt/compare/wxt-v0.19.6...wxt-v0.19.7)
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "wxt",
"type": "module",
"version": "0.19.7",
"version": "0.19.8",
"description": "Next gen framework for developing web extensions",
"repository": {
"type": "git",
+4 -9
View File
@@ -1,9 +1,4 @@
/// <reference types="chrome" />
/**
* @module wxt/browser/chrome
*/
import type { WxtRuntime, WxtI18n } from './index';
/**
* EXPERIMENTAL
*
@@ -11,11 +6,11 @@ import type { WxtRuntime, WxtI18n } from './index';
*
* @module wxt/browser/chrome
*/
import type { WxtRuntime, WxtI18n } from './index';
export type Chrome = typeof chrome;
export type WxtBrowser = Omit<Chrome, 'runtime' | 'i18n'> & {
runtime: WxtRuntime & Omit<Chrome['runtime'], 'getURL'>;
i18n: WxtI18n & Omit<Chrome['i18n'], 'getMessage'>;
export type WxtBrowser = Omit<typeof chrome, 'runtime' | 'i18n'> & {
runtime: WxtRuntime & Omit<(typeof chrome)['runtime'], 'getURL'>;
i18n: WxtI18n & Omit<(typeof chrome)['i18n'], 'getMessage'>;
};
export const browser: WxtBrowser =
+5 -3
View File
@@ -59,6 +59,11 @@ export async function createViteBuilder(
config.build.sourcemap = 'inline';
}
config.server ??= {};
config.server.watch = {
ignored: [`${wxtConfig.outBaseDir}/**`, `${wxtConfig.wxtDir}/**`],
};
config.plugins ??= [];
config.plugins.push(
wxtPlugins.download(wxtConfig),
@@ -287,9 +292,6 @@ export async function createViteBuilder(
strictPort: true,
host: info.hostname,
origin: info.origin,
watch: {
ignored: [`${wxtConfig.outBaseDir}/**`, `${wxtConfig.wxtDir}/**`],
},
},
};
const baseConfig = await getBaseConfig();
+55 -32
View File
@@ -99,53 +99,74 @@ interface Template {
}
async function listTemplates(): Promise<Template[]> {
try {
const res = await fetch('https://ungh.cc/repos/wxt-dev/wxt/files/main');
if (res.status >= 300)
throw Error(`Request failed with status ${res.status} ${res.statusText}`);
const templates = await listTemplatesUngh().catch((err) => {
consola.debug('Failed to load templates via ungh:', err);
return listTemplatesGithub();
});
return templates.sort((l, r) => {
const lWeight = TEMPLATE_SORT_WEIGHT[l.name] ?? Number.MAX_SAFE_INTEGER;
const rWeight = TEMPLATE_SORT_WEIGHT[r.name] ?? Number.MAX_SAFE_INTEGER;
const diff = lWeight - rWeight;
if (diff !== 0) return diff;
return l.name.localeCompare(r.name);
});
}
const data = (await res.json()) as {
meta: {
sha: string;
};
files: Array<{
path: string;
mode: string;
sha: string;
size: number;
}>;
async function listTemplatesUngh(): Promise<Template[]> {
const res = await fetch('https://ungh.cc/repos/wxt-dev/wxt/files/main');
if (res.status !== 200)
throw Error(
`Request failed with status ${res.status} ${res.statusText}: ${await res.text()}`,
);
const data = (await res.json()) as {
meta: {
sha: string;
};
return data.files
.map((item) => item.path.match(/templates\/(.+)\/package\.json/)?.[1])
.filter((name) => name != null)
.map((name) => ({ name: name!, path: `templates/${name}` }))
.sort((l, r) => {
const lWeight = TEMPLATE_SORT_WEIGHT[l.name] ?? Number.MAX_SAFE_INTEGER;
const rWeight = TEMPLATE_SORT_WEIGHT[r.name] ?? Number.MAX_SAFE_INTEGER;
const diff = lWeight - rWeight;
if (diff !== 0) return diff;
return l.name.localeCompare(r.name);
});
} catch (err) {
consola.error(err);
throw Error(`Failed to load templates`);
}
files: Array<{
path: string;
mode: string;
sha: string;
size: number;
}>;
};
return data.files
.map((item) => item.path.match(/templates\/(.+)\/package\.json/)?.[1])
.filter((name) => name != null)
.map((name) => ({ name: name!, path: `templates/${name}` }));
}
async function listTemplatesGithub(): Promise<Template[]> {
const res = await fetch(
`https://api.github.com/repos/${REPO}/contents/templates`,
{ headers: { Accept: 'application/vnd.github+json' } },
);
if (res.status !== 200)
throw Error(
`Request failed with status ${res.status} ${res.statusText}: ${await res.text()}`,
);
// Schema is Example4 of https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content
return (await res.json()) as Array<{
name: string;
path: string;
sha: string;
size: number;
}>;
}
async function cloneProject({
directory,
template,
packageManager,
}: {
directory: string;
template: Template;
packageManager: string;
}) {
const { default: ora } = await import('ora');
const spinner = ora('Downloading template').start();
try {
// 1. Clone repo
await downloadTemplate(`gh:wxt-dev/wxt/${template.path}`, {
await downloadTemplate(`gh:${REPO}/${template.path}`, {
dir: directory,
force: true,
});
@@ -180,3 +201,5 @@ const TEMPLATE_SORT_WEIGHT: Record<string, number> = {
vue: 1,
react: 2,
};
const REPO = 'wxt-dev/wxt';
+5 -9
View File
@@ -9,8 +9,8 @@ importers:
.:
devDependencies:
'@aklinker1/buildc':
specifier: ^1.0.11
version: 1.0.11(typescript@5.5.4)
specifier: ^1.1.0
version: 1.1.0(typescript@5.5.4)
'@aklinker1/check':
specifier: ^1.3.1
version: 1.3.1(typescript@5.5.4)
@@ -484,8 +484,8 @@ importers:
packages:
'@aklinker1/buildc@1.0.11':
resolution: {integrity: sha512-pUdwGQxTfhozZmC4HceoJye+Iq4srLCTPGOJK/VXrta30Bsfnp0N0zvIh9yhch/c7hvHGKf3vFdDPFOthGBdqw==}
'@aklinker1/buildc@1.1.0':
resolution: {integrity: sha512-qqIulkYDiRm3S4PcKVCQU4A+y0sIBjoQA2gUA+FxzUHPgpPUHnWPHpqZa0qJVzgUls23/UrFyH2Rq2YE5HV5+Q==}
hasBin: true
peerDependencies:
typescript: ^5.0.0
@@ -2649,12 +2649,10 @@ packages:
glob@6.0.4:
resolution: {integrity: sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==}
deprecated: Glob versions prior to v9 are no longer supported
glob@8.1.0:
resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==}
engines: {node: '>=12'}
deprecated: Glob versions prior to v9 are no longer supported
global-dirs@3.0.1:
resolution: {integrity: sha512-NBcGGFbBA9s1VzD41QXDG+3++t9Mn5t1FpLdhESY6oKY4gYTFpX4wO3sqGUa0Srjtbfj3szX0RnemmrVRUdULA==}
@@ -2804,7 +2802,6 @@ packages:
inflight@1.0.6:
resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
inherits@2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
@@ -3968,7 +3965,6 @@ packages:
rimraf@2.4.5:
resolution: {integrity: sha512-J5xnxTyqaiw06JjMftq7L9ouA448dw/E7dKghkP9WpKNuwmARNNg+Gk8/u5ryb9N/Yo2+z3MCwuqFK/+qPOPfQ==}
deprecated: Rimraf versions prior to v4 are no longer supported
hasBin: true
rollup-plugin-dts@6.1.1:
@@ -4825,7 +4821,7 @@ packages:
snapshots:
'@aklinker1/buildc@1.0.11(typescript@5.5.4)':
'@aklinker1/buildc@1.1.0(typescript@5.5.4)':
dependencies:
cac: 6.7.14
consola: 3.2.3