@vvedantb/config 0.3.0 → 0.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ - New subpath `@vvedantb/config/extension` for Chrome extensions built with WXT. Like the Vite presets, it never imports WXT, Vite or a plugin; the app passes its plugin factories in. WXT is not a peer.
6
+ - `extensionHostPermissions({ hosts, devHosts, mode, connectable })` replaces the dev-only host lists the extensions kept in `wxt.config.ts` and `vite.config.ts`. `host_permissions` is `hosts`, plus `devHosts` when `mode` is `"development"`, without duplicates. `connectable` (off by default) adds `externally_connectable.matches` for those hosts, with the path set to `/*`. `true` takes every host that names one; a list picks some and throws on a pattern that is not a host.
7
+ - `defineVExtensionConfig({ app, react, tailwindcss, plugins, modules, buildTarget, hosts, devHosts, connectable, manifest })` returns WXT's `manifest` and `vite` (and `modules` when set). The manifest gets `name`, `icons` and `action.default_icon` at `icons/icon-{16,32,48,128}.png` (`EXTENSION_ICONS`, the `@vvedantb/ui` extension brand assets copied to `public/icons/`), the host keys, then the app's own keys. A test compares it with a copy of an extension's current config.
8
+ - New bin `vvedantb-clerk-allow <extension-id>`. It adds `chrome-extension://<id>` to the allowed origins of the Clerk instance whose key is in `CLERK_SECRET_KEY`: GET `/v1/instance`, add the origin, PATCH the full list. It does nothing if the origin is already there or the response has no list. The key is never printed. The root exports `runClerkAllow` and the types `ClerkAllowIo`, `ClerkAllowFetch` and `ClerkAllowResponse`; tests pass a fake `fetch`.
9
+ - No zip or release helper: `wxt zip` already covers it.
10
+ - No new dependencies or peers.
11
+
3
12
  ## 0.3.0
4
13
 
5
14
  - New Vite and Vitest presets: `defineWebViteConfig`, `defineWebVitestConfig`, `reactPlugins`, `vendorChunkBuild`, `srcAlias` and `REACT_DEDUPE`. The app passes its plugin factories in; the root does not import Vite or any plugin, and needs no new peer.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @vvedantb/config
2
2
 
3
- Shared tooling for vvedantb apps: tsconfig bases, an oxlint base, Vite, Vitest, Babel and Metro presets, pinned tool versions, a `sync` CLI and a packaged Electron `app.asar` module check (`vvedantb-check-asar`).
3
+ Shared tooling for vvedantb apps: tsconfig bases, an oxlint base, Vite, Vitest, Babel and Metro presets, a WXT preset and host-permission helper for Chrome extensions, pinned tool versions, a `sync` CLI, a packaged Electron `app.asar` module check (`vvedantb-check-asar`) and a CLI that adds an extension to Clerk's allowed origins (`vvedantb-clerk-allow`).
4
4
 
5
5
  ## Install
6
6
 
@@ -11,7 +11,7 @@ npm install -D @electron/asar # only for vvedantb-check-asar list
11
11
 
12
12
  ## Exports
13
13
 
14
- The only JS entry is the root (`@vvedantb/config`). It is an ES module exported under the `default` condition, so both `import` and `require()` reach it. `require()` of an ES module needs Node 20.19+ or 22.12+, which every Expo SDK from 54 needs anyway. The JSON files below are also exported by path, because TypeScript (`extends`) and oxlint resolve them as files, not as modules:
14
+ There are two JS entries: the root (`@vvedantb/config`) and `@vvedantb/config/extension` (0.4.0, see [Chrome extensions](#chrome-extensions-wxt)). Each is an ES module exported under the `default` condition, so both `import` and `require()` reach it. `require()` of an ES module needs Node 20.19+ or 22.12+, which every Expo SDK from 54 needs anyway. The JSON files below are also exported by path, because TypeScript (`extends`) and oxlint resolve them as files, not as modules:
15
15
 
16
16
  - `@vvedantb/config/tsconfig/base.json`, `web.json`, `convex.json` and `react-native.json`
17
17
  - `@vvedantb/config/oxlint/base.json`
@@ -91,6 +91,101 @@ Keys that are not asked for are left out, so `resolve` and `build` appear only w
91
91
 
92
92
  `defineWebVitestConfig` takes `plugins`, `tsconfigPaths`, `alias`, `automaticJsx` (`esbuild: { jsx: "automatic" }`), `include` (default `["src/**/*.test.ts"]`) and `inline` (`test.server.deps.inline`). It always sets `test.environment: "node"`. Pass the result to `defineConfig` from `vitest/config`.
93
93
 
94
+ ## Chrome extensions (WXT)
95
+
96
+ `@vvedantb/config/extension` holds the shared part of an extension's `wxt.config.ts`. Like the Vite presets, it never imports WXT, Vite or a plugin: the app passes the plugin factories in. WXT is not a peer.
97
+
98
+ ```ts
99
+ import { defineConfig } from "wxt";
100
+ import react from "@vitejs/plugin-react";
101
+ import tailwindcss from "@tailwindcss/vite";
102
+ import { srcAlias } from "@vvedantb/config";
103
+ import { defineVExtensionConfig } from "@vvedantb/config/extension";
104
+
105
+ export default defineConfig({
106
+ ...defineVExtensionConfig({
107
+ app: "Example",
108
+ react: { plugin: react },
109
+ tailwindcss,
110
+ buildTarget: "chrome120",
111
+ hosts: ["https://app.example.com/*", "https://clerk.example.com/*"],
112
+ devHosts: ["https://app-git-staging.example.dev/*", "https://example-00.clerk.accounts.dev/*"],
113
+ manifest: {
114
+ description: "What the extension does",
115
+ version: "0.2.0",
116
+ permissions: ["storage", "cookies"],
117
+ content_security_policy: { extension_pages: "script-src 'self'; object-src 'self'" },
118
+ },
119
+ }),
120
+ srcDir: "src",
121
+ outDir: "dist",
122
+ imports: false,
123
+ alias: srcAlias(import.meta.dirname),
124
+ });
125
+ ```
126
+
127
+ `defineVExtensionConfig` returns `manifest` (a function of WXT's env), `vite` and, when set, `modules`:
128
+
129
+ | Option | Result |
130
+ | --- | --- |
131
+ | `app` | Manifest `name`. |
132
+ | `react: { plugin, compiler? }` | First plugin, as in `defineWebViteConfig` (`compiler: true` or `{ babel, preset }`). |
133
+ | `tailwindcss` | `tailwindcss()`, after React. |
134
+ | `plugins` | App Vite plugins, last. Falsy entries are dropped. |
135
+ | `modules` | WXT `modules`, as given, for example `["@wxt-dev/module-react"]` instead of `react`. |
136
+ | `buildTarget` | `vite.build.target`, for example `"chrome120"` so Clerk's chunks are not downlevelled. |
137
+ | `hosts`, `devHosts`, `connectable` | `host_permissions` and `externally_connectable`, from `extensionHostPermissions` with WXT's `mode`. |
138
+ | `manifest` | The app's other manifest keys, or a function of WXT's env that returns them. They win over the preset's keys, except `action`, which is merged over `{ default_icon }`. |
139
+
140
+ `icons` and `action.default_icon` point at `icons/icon-16.png`, `icon-32.png`, `icon-48.png` and `icon-128.png` in the public folder (`EXTENSION_ICONS`). Generate them with `@vvedantb/ui`'s brand-asset script and copy them there: see "Chrome extensions" in the `@vvedantb/ui` README.
141
+
142
+ Keys that are not asked for are left out. WXT's own options (`srcDir`, `outDir`, `publicDir`, `alias`, `imports`) stay in the app's `defineConfig`.
143
+
144
+ ### extensionHostPermissions
145
+
146
+ ```ts
147
+ import { extensionHostPermissions } from "@vvedantb/config/extension";
148
+
149
+ extensionHostPermissions({ hosts, devHosts, mode });
150
+ // { host_permissions: [...hosts, ...(mode === "development" ? devHosts : [])] }
151
+ ```
152
+
153
+ - `host_permissions`: `hosts`, then `devHosts` when `mode` is `"development"`, in order and without duplicates. Other modes (`production`, `staging`, ...) get `hosts` only.
154
+ - `connectable` (off by default) adds `externally_connectable.matches`: the web pages that may message the extension. Each match keeps the scheme and host and sets the path to `/*`, so `https://app.example.com/api/*` becomes `https://app.example.com/*`.
155
+ - `true` uses every host in the build that names one. `<all_urls>`, a `*` host and non-web schemes are skipped.
156
+ - A list picks patterns from `hosts` and `devHosts`; a dev host counts in development only. A pattern that is in neither list, or cannot be matched, throws.
157
+ - When no match is left, `externally_connectable` is left out. Declaring it, even empty, stops other extensions from connecting.
158
+ - Chrome also rejects wildcards on an effective top-level domain (`*.co.uk`). The helper does not check for those.
159
+
160
+ ### Zip and release
161
+
162
+ No helper: `wxt zip` already builds the store zip, and no shared logic sits on top of it.
163
+
164
+ ## clerk-allow
165
+
166
+ `vvedantb-clerk-allow` adds a Chrome extension's origin, `chrome-extension://<id>`, to a Clerk instance's allowed origins, as Clerk's Chrome extension setup asks.
167
+
168
+ ```sh
169
+ # CLERK_SECRET_KEY already set in the environment
170
+ pnpm exec vvedantb-clerk-allow abcdefghijklmnopabcdefghijklmnop
171
+
172
+ # or read it from an env file
173
+ node --env-file=.env.local node_modules/@vvedantb/config/dist/clerk-allow-cli.js abcdefghijklmnopabcdefghijklmnop
174
+ ```
175
+
176
+ Do not type the key on the command line: shell history keeps it.
177
+
178
+ 1. Reads the secret key from `CLERK_SECRET_KEY`. It must start with `sk_`.
179
+ 2. `GET https://api.clerk.com/v1/instance` and reads `allowed_origins` (`null` counts as empty).
180
+ 3. If the origin is already there, prints `... is already allowed on the <environment> instance.` and stops.
181
+ 4. Otherwise `PATCH /v1/instance` with `allowed_origins` set to the full list: the origins already allowed, then the new one.
182
+
183
+ Run it once per Clerk instance: the development key with the unpacked ID, the production key with the store ID. The ID is the 32 letters (a to p) shown in `chrome://extensions`.
184
+
185
+ The secret key is never printed. Error messages from Clerk or the network have it replaced with `[redacted]`, and a bad ID is not echoed (it could be a key pasted by mistake). If the GET response has no `allowed_origins` list, nothing is sent: a PATCH with only the new origin could drop the others.
186
+
187
+ Exit codes: 0 done (or already allowed), 1 Clerk API or network failure, 2 bad arguments or a missing or wrong `CLERK_SECRET_KEY`. `runClerkAllow(argv, io)` is exported from the root, with `fetch` in `io`, for tests.
188
+
94
189
  ## Expo presets
95
190
 
96
191
  `babel.config.js` and `metro.config.js` are CommonJS, loaded by Expo:
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { runClerkAllow } from "./clerk-allow.js";
3
+ process.exitCode = await runClerkAllow(process.argv.slice(2), {
4
+ log: (message) => console.info(message),
5
+ error: (message) => console.error(message),
6
+ env: process.env,
7
+ fetch,
8
+ });
@@ -0,0 +1,20 @@
1
+ export type ClerkAllowResponse = {
2
+ ok: boolean;
3
+ status: number;
4
+ text: () => Promise<string>;
5
+ };
6
+ /** The part of `fetch` the CLI uses. */
7
+ export type ClerkAllowFetch = (url: string, init: {
8
+ method: "GET" | "PATCH";
9
+ headers: Record<string, string>;
10
+ body?: string;
11
+ }) => Promise<ClerkAllowResponse>;
12
+ export type ClerkAllowIo = {
13
+ log: (message: string) => void;
14
+ error: (message: string) => void;
15
+ env: Readonly<Record<string, string | undefined>>;
16
+ fetch: ClerkAllowFetch;
17
+ };
18
+ export declare const CLERK_INSTANCE_URL = "https://api.clerk.com/v1/instance";
19
+ /** Run the CLI. Returns the process exit code: 0 done, 1 Clerk API failure, 2 bad arguments or environment. */
20
+ export declare function runClerkAllow(argv: readonly string[], io: ClerkAllowIo): Promise<number>;
@@ -0,0 +1,93 @@
1
+ // Adds a Chrome extension's origin to a Clerk instance's allowed origins through the Clerk
2
+ // Backend API: GET /v1/instance, add `chrome-extension://<id>` to `allowed_origins`, PATCH
3
+ // /v1/instance with the whole list. The secret key is read from the environment and never printed.
4
+ export const CLERK_INSTANCE_URL = "https://api.clerk.com/v1/instance";
5
+ /** Chrome extension IDs are 32 letters from a to p. */
6
+ const EXTENSION_ID = /^[a-p]{32}$/;
7
+ const USAGE = `Usage: vvedantb-clerk-allow <extension-id>
8
+
9
+ Adds chrome-extension://<extension-id> to the allowed origins of the Clerk
10
+ instance whose secret key is in CLERK_SECRET_KEY. Origins already allowed
11
+ are kept. Run it once per Clerk instance (development and production).
12
+ <extension-id> The 32-letter ID shown in chrome://extensions.`;
13
+ function errorDetail(body) {
14
+ try {
15
+ const { errors } = JSON.parse(body);
16
+ const messages = (errors ?? []).map((e) => e.long_message ?? e.message).filter(Boolean);
17
+ return messages.length > 0 ? `: ${messages.join("; ")}` : "";
18
+ }
19
+ catch {
20
+ return "";
21
+ }
22
+ }
23
+ function readInstance(body) {
24
+ let data;
25
+ try {
26
+ data = JSON.parse(body);
27
+ }
28
+ catch {
29
+ throw new Error("GET /v1/instance did not return JSON. Nothing was changed.");
30
+ }
31
+ const origins = data.allowed_origins === null ? [] : data.allowed_origins;
32
+ // Without the current list, a PATCH with only the new origin could drop the others.
33
+ if (!Array.isArray(origins) || !origins.every((o) => typeof o === "string")) {
34
+ throw new Error("GET /v1/instance returned no allowed_origins list. Nothing was changed.");
35
+ }
36
+ return { origins, environment: typeof data.environment_type === "string" ? data.environment_type : undefined };
37
+ }
38
+ /** Run the CLI. Returns the process exit code: 0 done, 1 Clerk API failure, 2 bad arguments or environment. */
39
+ export async function runClerkAllow(argv, io) {
40
+ if (argv[0] === "--help" || argv[0] === "-h") {
41
+ io.log(USAGE);
42
+ return 0;
43
+ }
44
+ const option = argv.find((arg) => arg.startsWith("-"));
45
+ if (option !== undefined) {
46
+ io.error(`Unknown option: ${option}\n${USAGE}`);
47
+ return 2;
48
+ }
49
+ const [id] = argv;
50
+ if (id === undefined || argv.length > 1) {
51
+ io.error(`${id === undefined ? "Missing the" : "Pass one"} extension ID.\n${USAGE}`);
52
+ return 2;
53
+ }
54
+ // The argument is not echoed: it could be a key pasted by mistake.
55
+ if (!EXTENSION_ID.test(id)) {
56
+ io.error("The extension ID must be 32 letters from a to p, as shown in chrome://extensions.");
57
+ return 2;
58
+ }
59
+ const secret = io.env.CLERK_SECRET_KEY;
60
+ if (!secret) {
61
+ io.error("CLERK_SECRET_KEY is not set.");
62
+ return 2;
63
+ }
64
+ if (!secret.startsWith("sk_")) {
65
+ io.error("CLERK_SECRET_KEY does not hold a Clerk secret key (sk_...).");
66
+ return 2;
67
+ }
68
+ const headers = { Authorization: `Bearer ${secret}`, "Content-Type": "application/json" };
69
+ const request = async (method, body) => {
70
+ const response = await io.fetch(CLERK_INSTANCE_URL, body ? { method, headers, body: JSON.stringify(body) } : { method, headers });
71
+ const text = await response.text();
72
+ if (!response.ok)
73
+ throw new Error(`${method} /v1/instance failed with HTTP ${response.status}${errorDetail(text)}`);
74
+ return text;
75
+ };
76
+ const origin = `chrome-extension://${id}`;
77
+ try {
78
+ const { origins, environment } = readInstance(await request("GET"));
79
+ const instance = environment ? `the ${environment} instance` : "the instance";
80
+ if (origins.includes(origin)) {
81
+ io.log(`${origin} is already allowed on ${instance}.`);
82
+ return 0;
83
+ }
84
+ await request("PATCH", { allowed_origins: [...origins, origin] });
85
+ io.log(`Added ${origin} to the allowed origins of ${instance} (${origins.length + 1} in total).`);
86
+ return 0;
87
+ }
88
+ catch (error) {
89
+ const message = error instanceof Error ? error.message : String(error);
90
+ io.error(`Clerk API: ${message.split(secret).join("[redacted]")}`);
91
+ return 1;
92
+ }
93
+ }
@@ -0,0 +1,85 @@
1
+ import { type ReactSetup, type VitePluginOption } from "./vite.js";
2
+ export interface ExtensionHostOptions {
3
+ /** Match patterns in every build, for example `"https://app.example.com/*"` or `"<all_urls>"`. */
4
+ hosts: readonly string[];
5
+ /** Match patterns in development builds only (`mode === "development"`), such as staging hosts. */
6
+ devHosts?: readonly string[];
7
+ /** The Vite or WXT mode. */
8
+ mode: string;
9
+ /**
10
+ * Web pages that may message the extension (`externally_connectable.matches`). Off by default.
11
+ * `true`: every host in this build that names one (not `<all_urls>` or a `*` host).
12
+ * A list: those patterns only. Each must be in `hosts` or `devHosts`; dev hosts count in development only.
13
+ */
14
+ connectable?: boolean | readonly string[];
15
+ }
16
+ export interface ExtensionHostPermissions {
17
+ host_permissions: string[];
18
+ externally_connectable?: {
19
+ matches: string[];
20
+ };
21
+ }
22
+ /**
23
+ * `host_permissions`: `hosts`, then `devHosts` when `mode` is `"development"`, without duplicates.
24
+ * With `connectable`, also `externally_connectable.matches` for those hosts, with the path set to `/*`.
25
+ * The key is left out when no match is left: declaring it stops other extensions from connecting.
26
+ */
27
+ export declare function extensionHostPermissions(options: ExtensionHostOptions): ExtensionHostPermissions;
28
+ /** Manifest icon paths, inside the public folder, for @vvedantb/ui's `extension/icon-*.png` brand assets. */
29
+ export declare const EXTENSION_ICONS: {
30
+ readonly "16": "icons/icon-16.png";
31
+ readonly "32": "icons/icon-32.png";
32
+ readonly "48": "icons/icon-48.png";
33
+ readonly "128": "icons/icon-128.png";
34
+ };
35
+ export type ExtensionIcons = Record<keyof typeof EXTENSION_ICONS, string>;
36
+ /** The part of WXT's `ConfigEnv` the preset reads. WXT passes the whole env to `manifest`. */
37
+ export interface ExtensionConfigEnv {
38
+ mode: string;
39
+ browser?: string;
40
+ }
41
+ /** Manifest keys the preset sets. */
42
+ export interface VExtensionManifest extends ExtensionHostPermissions {
43
+ name: string;
44
+ icons: ExtensionIcons;
45
+ action: {
46
+ default_icon: ExtensionIcons;
47
+ };
48
+ }
49
+ export interface VExtensionViteConfig {
50
+ plugins: VitePluginOption[];
51
+ build?: {
52
+ target: string;
53
+ };
54
+ }
55
+ export interface VExtensionOptions<Preset, Manifest extends object> extends Omit<ExtensionHostOptions, "mode"> {
56
+ /** Manifest `name`. */
57
+ app: string;
58
+ /** `@vitejs/plugin-react`, as in `defineWebViteConfig`. First plugin. */
59
+ react?: ReactSetup<Preset>;
60
+ /** `@tailwindcss/vite`. Added after React. */
61
+ tailwindcss?: () => VitePluginOption;
62
+ /** App Vite plugins, added last. Falsy entries are dropped. */
63
+ plugins?: VitePluginOption[];
64
+ /** WXT modules by package name, for example `"@wxt-dev/module-react"` instead of `react`. */
65
+ modules?: string[];
66
+ /** `vite.build.target`, for example `"chrome120"`. */
67
+ buildTarget?: string;
68
+ /**
69
+ * The app's other manifest keys (description, version, permissions, ...), or a function of
70
+ * WXT's env that returns them. They win over the preset's keys, except `action`, which is
71
+ * merged over `{ default_icon }`.
72
+ */
73
+ manifest?: Manifest | ((env: ExtensionConfigEnv) => Manifest);
74
+ }
75
+ export interface VExtensionConfig<Manifest extends object> {
76
+ modules?: string[];
77
+ manifest: (env: ExtensionConfigEnv) => VExtensionManifest & Manifest;
78
+ vite: () => VExtensionViteConfig;
79
+ }
80
+ /**
81
+ * The shared part of an extension's `wxt.config.ts`: `manifest` (name, icons, host permissions)
82
+ * and `vite` (plugins, build target). Spread it into WXT's `defineConfig` and add `srcDir`,
83
+ * `outDir`, `alias` or `imports` there.
84
+ */
85
+ export declare function defineVExtensionConfig<Preset, Manifest extends object = object>(options: VExtensionOptions<Preset, Manifest>): VExtensionConfig<Manifest>;
@@ -0,0 +1,84 @@
1
+ import { reactPlugins } from "./vite.js";
2
+ /** `<scheme>://<host>/<path>` with an http(s) or `*` scheme. */
3
+ const MATCH_PATTERN = /^(\*|https?):\/\/([^/]+)\/.*$/;
4
+ /** The `externally_connectable` form of a host pattern: same scheme and host, path `/*`. */
5
+ function connectableMatch(pattern) {
6
+ const match = MATCH_PATTERN.exec(pattern);
7
+ if (!match || match[2] === "*")
8
+ return undefined;
9
+ return `${match[1]}://${match[2]}/*`;
10
+ }
11
+ function unique(values) {
12
+ return [...new Set(values)];
13
+ }
14
+ function connectableMatches(active, options) {
15
+ if (options.connectable === true) {
16
+ return unique(active.map(connectableMatch).filter((m) => m !== undefined));
17
+ }
18
+ const known = new Set([...options.hosts, ...(options.devHosts ?? [])]);
19
+ const matches = [];
20
+ for (const pattern of options.connectable || []) {
21
+ if (!known.has(pattern))
22
+ throw new Error(`connectable pattern is not in hosts or devHosts: ${pattern}`);
23
+ const match = connectableMatch(pattern);
24
+ if (!match)
25
+ throw new Error(`connectable pattern needs an http(s) scheme and a host name: ${pattern}`);
26
+ if (active.includes(pattern))
27
+ matches.push(match);
28
+ }
29
+ return unique(matches);
30
+ }
31
+ /**
32
+ * `host_permissions`: `hosts`, then `devHosts` when `mode` is `"development"`, without duplicates.
33
+ * With `connectable`, also `externally_connectable.matches` for those hosts, with the path set to `/*`.
34
+ * The key is left out when no match is left: declaring it stops other extensions from connecting.
35
+ */
36
+ export function extensionHostPermissions(options) {
37
+ const active = unique([...options.hosts, ...(options.mode === "development" ? (options.devHosts ?? []) : [])]);
38
+ const result = { host_permissions: active };
39
+ if (options.connectable) {
40
+ const matches = connectableMatches(active, options);
41
+ if (matches.length > 0)
42
+ result.externally_connectable = { matches };
43
+ }
44
+ return result;
45
+ }
46
+ /** Manifest icon paths, inside the public folder, for @vvedantb/ui's `extension/icon-*.png` brand assets. */
47
+ export const EXTENSION_ICONS = {
48
+ "16": "icons/icon-16.png",
49
+ "32": "icons/icon-32.png",
50
+ "48": "icons/icon-48.png",
51
+ "128": "icons/icon-128.png",
52
+ };
53
+ /**
54
+ * The shared part of an extension's `wxt.config.ts`: `manifest` (name, icons, host permissions)
55
+ * and `vite` (plugins, build target). Spread it into WXT's `defineConfig` and add `srcDir`,
56
+ * `outDir`, `alias` or `imports` there.
57
+ */
58
+ export function defineVExtensionConfig(options) {
59
+ const config = {
60
+ manifest: (env) => {
61
+ const own = typeof options.manifest === "function" ? options.manifest(env) : options.manifest;
62
+ const hosts = { hosts: options.hosts, devHosts: options.devHosts, connectable: options.connectable, mode: env.mode };
63
+ return {
64
+ name: options.app,
65
+ icons: { ...EXTENSION_ICONS },
66
+ ...extensionHostPermissions(hosts),
67
+ ...own,
68
+ action: { default_icon: { ...EXTENSION_ICONS }, ...own?.action },
69
+ };
70
+ },
71
+ vite: () => {
72
+ const plugins = [];
73
+ if (options.react)
74
+ plugins.push(...reactPlugins(options.react));
75
+ if (options.tailwindcss)
76
+ plugins.push(options.tailwindcss());
77
+ plugins.push(...(options.plugins ?? []).filter(Boolean));
78
+ return options.buildTarget ? { plugins, build: { target: options.buildTarget } } : { plugins };
79
+ },
80
+ };
81
+ if (options.modules)
82
+ config.modules = options.modules;
83
+ return config;
84
+ }
package/dist/index.d.ts CHANGED
@@ -2,5 +2,6 @@ export { versions, type Versions } from "./versions.js";
2
2
  export { CLAUDE_INSTALL_SNIPPET, ENVIRONMENT_INSTALL, parseJsonc, planSync, runSync, type PlannedChange, type SyncOptions, type SyncResult, } from "./sync.js";
3
3
  export { runCli, type CliIo } from "./run.js";
4
4
  export { CHECK_ASAR_CHILD_ENV, findBareImports, findSpecifiers, packageName, runCheckAsar, type AsarCheckHook, type AsarCheckHookContext, type CheckAsarIo, } from "./check-asar.js";
5
+ export { runClerkAllow, type ClerkAllowFetch, type ClerkAllowIo, type ClerkAllowResponse, } from "./clerk-allow.js";
5
6
  export { REACT_DEDUPE, defineWebViteConfig, defineWebVitestConfig, reactPlugins, srcAlias, vendorChunkBuild, type AliasOptions, type BabelReactCompiler, type PathOptions, type ReactSetup, type ResolveConfig, type RouterPluginOptions, type VendorChunk, type VendorChunkGroup, type VitePlugin, type VitePluginOption, type WebBuildConfig, type WebViteConfig, type WebViteOptions, type WebVitestConfig, type WebVitestOptions, } from "./vite.js";
6
7
  export { defineExpoMetroConfig, expoBabelConfig, type BabelApi, type ExpoBabelConfig, type ExpoMetroOptions, type MetroConfigLike, type NativeWindMetroOptions, } from "./expo.js";
package/dist/index.js CHANGED
@@ -2,5 +2,6 @@ export { versions } from "./versions.js";
2
2
  export { CLAUDE_INSTALL_SNIPPET, ENVIRONMENT_INSTALL, parseJsonc, planSync, runSync, } from "./sync.js";
3
3
  export { runCli } from "./run.js";
4
4
  export { CHECK_ASAR_CHILD_ENV, findBareImports, findSpecifiers, packageName, runCheckAsar, } from "./check-asar.js";
5
+ export { runClerkAllow, } from "./clerk-allow.js";
5
6
  export { REACT_DEDUPE, defineWebViteConfig, defineWebVitestConfig, reactPlugins, srcAlias, vendorChunkBuild, } from "./vite.js";
6
7
  export { defineExpoMetroConfig, expoBabelConfig, } from "./expo.js";
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@vvedantb/config",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
- "description": "Shared tsconfig bases, oxlint base, Vite, Vitest, Babel and Metro presets, pinned tool versions, a sync CLI for Claude commands, CLAUDE.md, Cursor environment and Convex tsconfig, and a packaged Electron app.asar module check.",
5
+ "description": "Shared tsconfig bases, oxlint base, Vite, Vitest, Babel and Metro presets, a WXT preset and host-permission helper for Chrome extensions, pinned tool versions, a sync CLI for Claude commands, CLAUDE.md, Cursor environment and Convex tsconfig, a packaged Electron app.asar module check and a CLI that adds an extension to Clerk's allowed origins.",
6
6
  "type": "module",
7
7
  "publishConfig": {
8
8
  "access": "public"
@@ -14,13 +14,18 @@
14
14
  },
15
15
  "bin": {
16
16
  "vvedantb-config": "./dist/cli.js",
17
- "vvedantb-check-asar": "./dist/check-asar-cli.js"
17
+ "vvedantb-check-asar": "./dist/check-asar-cli.js",
18
+ "vvedantb-clerk-allow": "./dist/clerk-allow-cli.js"
18
19
  },
19
20
  "exports": {
20
21
  ".": {
21
22
  "types": "./dist/index.d.ts",
22
23
  "default": "./dist/index.js"
23
24
  },
25
+ "./extension": {
26
+ "types": "./dist/extension.d.ts",
27
+ "default": "./dist/extension.js"
28
+ },
24
29
  "./tsconfig/base.json": "./tsconfig/base.json",
25
30
  "./tsconfig/web.json": "./tsconfig/web.json",
26
31
  "./tsconfig/convex.json": "./tsconfig/convex.json",