wxt 0.19.7 → 0.19.8

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.
@@ -1,7 +1,3 @@
1
- /**
2
- * @module wxt/browser/chrome
3
- */
4
- import type { WxtRuntime, WxtI18n } from './index';
5
1
  /**
6
2
  * EXPERIMENTAL
7
3
  *
@@ -9,9 +5,9 @@ import type { WxtRuntime, WxtI18n } from './index';
9
5
  *
10
6
  * @module wxt/browser/chrome
11
7
  */
12
- export type Chrome = typeof chrome;
13
- export type WxtBrowser = Omit<Chrome, 'runtime' | 'i18n'> & {
14
- runtime: WxtRuntime & Omit<Chrome['runtime'], 'getURL'>;
15
- i18n: WxtI18n & Omit<Chrome['i18n'], 'getMessage'>;
8
+ import type { WxtRuntime, WxtI18n } from './index';
9
+ export type WxtBrowser = Omit<typeof chrome, 'runtime' | 'i18n'> & {
10
+ runtime: WxtRuntime & Omit<(typeof chrome)['runtime'], 'getURL'>;
11
+ i18n: WxtI18n & Omit<(typeof chrome)['i18n'], 'getMessage'>;
16
12
  };
17
13
  export declare const browser: WxtBrowser;
@@ -28,6 +28,10 @@ export async function createViteBuilder(wxtConfig, hooks, server) {
28
28
  if (config.build.sourcemap == null && wxtConfig.command === "serve") {
29
29
  config.build.sourcemap = "inline";
30
30
  }
31
+ config.server ??= {};
32
+ config.server.watch = {
33
+ ignored: [`${wxtConfig.outBaseDir}/**`, `${wxtConfig.wxtDir}/**`]
34
+ };
31
35
  config.plugins ??= [];
32
36
  config.plugins.push(
33
37
  wxtPlugins.download(wxtConfig),
@@ -227,10 +231,7 @@ export async function createViteBuilder(wxtConfig, hooks, server) {
227
231
  port: info.port,
228
232
  strictPort: true,
229
233
  host: info.hostname,
230
- origin: info.origin,
231
- watch: {
232
- ignored: [`${wxtConfig.outBaseDir}/**`, `${wxtConfig.wxtDir}/**`]
233
- }
234
+ origin: info.origin
234
235
  }
235
236
  };
236
237
  const baseConfig = await getBaseConfig();
@@ -73,32 +73,46 @@ export async function initialize(options) {
73
73
  console.log();
74
74
  }
75
75
  async function listTemplates() {
76
- try {
77
- const res = await fetch("https://ungh.cc/repos/wxt-dev/wxt/files/main");
78
- if (res.status >= 300)
79
- throw Error(`Request failed with status ${res.status} ${res.statusText}`);
80
- const data = await res.json();
81
- return data.files.map((item) => item.path.match(/templates\/(.+)\/package\.json/)?.[1]).filter((name) => name != null).map((name) => ({ name, path: `templates/${name}` })).sort((l, r) => {
82
- const lWeight = TEMPLATE_SORT_WEIGHT[l.name] ?? Number.MAX_SAFE_INTEGER;
83
- const rWeight = TEMPLATE_SORT_WEIGHT[r.name] ?? Number.MAX_SAFE_INTEGER;
84
- const diff = lWeight - rWeight;
85
- if (diff !== 0) return diff;
86
- return l.name.localeCompare(r.name);
87
- });
88
- } catch (err) {
89
- consola.error(err);
90
- throw Error(`Failed to load templates`);
91
- }
76
+ const templates = await listTemplatesUngh().catch((err) => {
77
+ consola.debug("Failed to load templates via ungh:", err);
78
+ return listTemplatesGithub();
79
+ });
80
+ return templates.sort((l, r) => {
81
+ const lWeight = TEMPLATE_SORT_WEIGHT[l.name] ?? Number.MAX_SAFE_INTEGER;
82
+ const rWeight = TEMPLATE_SORT_WEIGHT[r.name] ?? Number.MAX_SAFE_INTEGER;
83
+ const diff = lWeight - rWeight;
84
+ if (diff !== 0) return diff;
85
+ return l.name.localeCompare(r.name);
86
+ });
87
+ }
88
+ async function listTemplatesUngh() {
89
+ const res = await fetch("https://ungh.cc/repos/wxt-dev/wxt/files/main");
90
+ if (res.status !== 200)
91
+ throw Error(
92
+ `Request failed with status ${res.status} ${res.statusText}: ${await res.text()}`
93
+ );
94
+ const data = await res.json();
95
+ return data.files.map((item) => item.path.match(/templates\/(.+)\/package\.json/)?.[1]).filter((name) => name != null).map((name) => ({ name, path: `templates/${name}` }));
96
+ }
97
+ async function listTemplatesGithub() {
98
+ const res = await fetch(
99
+ `https://api.github.com/repos/${REPO}/contents/templates`,
100
+ { headers: { Accept: "application/vnd.github+json" } }
101
+ );
102
+ if (res.status !== 200)
103
+ throw Error(
104
+ `Request failed with status ${res.status} ${res.statusText}: ${await res.text()}`
105
+ );
106
+ return await res.json();
92
107
  }
93
108
  async function cloneProject({
94
109
  directory,
95
- template,
96
- packageManager
110
+ template
97
111
  }) {
98
112
  const { default: ora } = await import("ora");
99
113
  const spinner = ora("Downloading template").start();
100
114
  try {
101
- await downloadTemplate(`gh:wxt-dev/wxt/${template.path}`, {
115
+ await downloadTemplate(`gh:${REPO}/${template.path}`, {
102
116
  dir: directory,
103
117
  force: true
104
118
  });
@@ -126,3 +140,4 @@ const TEMPLATE_SORT_WEIGHT = {
126
140
  vue: 1,
127
141
  react: 2
128
142
  };
143
+ const REPO = "wxt-dev/wxt";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wxt",
3
3
  "type": "module",
4
- "version": "0.19.7",
4
+ "version": "0.19.8",
5
5
  "description": "Next gen framework for developing web extensions",
6
6
  "repository": {
7
7
  "type": "git",