Skip to content

Commit

Permalink
Merge pull request #633 from nyaggah/feat/get-manifest-options
Browse files Browse the repository at this point in the history
feat(core): use types directly from crx
  • Loading branch information
JoeyDoey authored Dec 10, 2024
2 parents ddac0c4 + 39b25bb commit 03a968c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/lib/make/utils/write-package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function writePackageJson(response: prompts.Answers<string>): void {
},
"devDependencies": {
"@bedframe/cli": "0.0.90",
"@bedframe/core": "0.0.44",
"@bedframe/core": "0.0.45",
${
changesets
? `"@changesets/cli": "^2.27.1",
Expand Down
24 changes: 8 additions & 16 deletions packages/core/src/lib/get-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import {
lightYellow,
} from 'kolorist'
import type { PluginOption } from 'vite'
import { Browser, type BuildConfig, type BuildTarget } from './types'
import { AnyCase } from './utils'
import {
Browser,
type BuildConfig,
type BuildTarget,
type BuildOptions,
} from './types'

/**
* Given the {@link Mode} i.e. {@link Browser} target,
Expand All @@ -25,10 +29,8 @@ import { AnyCase } from './utils'
export function getManifest(
{ command, mode }: BuildConfig,
targets: BuildTarget[],
options?: CrxOptions,
// PluginOption[]
// biome-ignore lint: @typescript-eslint/no-explicit-any
): any {
options?: BuildOptions,
): ReturnType<typeof crx> {
const _mode = `${(mode as string).charAt(0).toUpperCase()}${(
mode as string
).slice(1)}`
Expand Down Expand Up @@ -76,13 +78,3 @@ export function getManifest(
...options,
})
}

interface CrxOptions {
contentScripts?: {
preambleCode?: string | false
hmrTimeout?: number
injectCss?: boolean
}
fastGlobOptions?: any // fast-glob Options
browser?: any // 'firefox' | 'chrome'
}
22 changes: 21 additions & 1 deletion packages/core/src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ManifestV3Export } from '@crxjs/vite-plugin'
import type { crx, ManifestV3Export } from '@crxjs/vite-plugin'
import { type AnyCase, createEnum } from './utils'

export const FrameworkEnum = {
Expand Down Expand Up @@ -74,6 +74,26 @@ export type BuildConfig = {
command?: 'build' | 'serve'
mode?: AnyCase<Browser> | string | undefined
}
/**
* Extract the first parameter of the `crx` function
* and Override the `browser` key to allow `any`
*
* interface CrxOptions {
* contentScripts?: {
* preambleCode?: string | false
* hmrTimeout?: number
* injectCss?: boolean
* }
* fastGlobOptions?: any // fast-glob Options
* browser?: any // 'firefox' | 'chrome'
* }
*/
export type BuildOptions = Omit<
Omit<Parameters<typeof crx>[0], 'manifest'>,
'browser'
> & {
browser?: any // 'firefox' | 'chrome' // AnyCase<Browser>
}

export interface Repository {
type: string
Expand Down

0 comments on commit 03a968c

Please sign in to comment.