create-packer 1.45.8 → 1.45.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.45.8",
3
+ "version": "1.45.10",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -8,7 +8,7 @@
8
8
  "strictNullChecks": true,
9
9
  "target": "ESNext",
10
10
  "noImplicitAny": false,
11
- "moduleResolution": "bundler",
11
+ "moduleResolution": "node",
12
12
  "sourceMap": false,
13
13
  "declaration": true,
14
14
  "outDir": "lib",
@@ -1 +1 @@
1
- export * as theme from './theme.css'
1
+ export * from './theme.css'
@@ -1,3 +1,3 @@
1
1
  import { createTheme } from '@vanilla-extract/css'
2
2
 
3
- export const [classes, vars] = createTheme({})
3
+ export const [themeClass, themeVars] = createTheme({})
@@ -1 +1 @@
1
- export * as theme from './theme.css'
1
+ export * from './theme.css'
@@ -1,3 +1,3 @@
1
1
  import { createTheme } from '@vanilla-extract/css'
2
2
 
3
- export const [classes, vars] = createTheme({})
3
+ export const [themeClass, themeVars] = createTheme({})
@@ -0,0 +1,5 @@
1
+ import { globalStyle } from '@vanilla-extract/css'
2
+ import { createGlobalStyle } from '@/shared/styles'
3
+ import { classNameSpace } from './constants'
4
+
5
+ globalStyle(classNameSpace, createGlobalStyle())
@@ -1,10 +1,11 @@
1
- import { CONTENT_MATCHES } from '@/shared/content'
1
+ import { CONTENT_MATCHES, contentMessage } from '@/shared/content'
2
2
  import { Common } from './modules'
3
3
 
4
4
  export default defineContentScript({
5
5
  runAt: 'document_idle',
6
6
  matches: CONTENT_MATCHES,
7
7
  main: () => {
8
+ contentMessage.onMessage('CONNECT', () => true)
8
9
  Common.insert()
9
10
  }
10
11
  })
@@ -1,10 +1,5 @@
1
- import { GlobalStyle } from '@/shared/styles'
2
- import { classNameSpace } from '@/entrypoints/content/constants'
1
+ import '@/entrypoints/content/global.css'
3
2
 
4
3
  export default function Home() {
5
- return (
6
- <>
7
- <GlobalStyle nameSpace={classNameSpace} />
8
- </>
9
- )
4
+ return <></>
10
5
  }
@@ -0,0 +1,4 @@
1
+ import { globalStyle } from '@vanilla-extract/css'
2
+ import { createGlobalStyle } from '@/shared/styles'
3
+
4
+ globalStyle('body', createGlobalStyle())
@@ -1,13 +1,12 @@
1
1
  import { StrictMode } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
3
  import { AppContext } from '@/shared/components'
4
- import { GlobalStyle } from '@/shared/styles'
5
4
  import Popup from './popup'
5
+ import './global.css'
6
6
 
7
7
  createRoot(document.getElementById('root') as HTMLElement).render(
8
8
  <StrictMode>
9
9
  <AppContext.Root>
10
- <GlobalStyle />
11
10
  <Popup />
12
11
  </AppContext.Root>
13
12
  </StrictMode>
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@tanstack/react-query": "5.51.15",
29
+ "@vanilla-extract/css": "1.17.4",
29
30
  "@webext-core/messaging": "2.2.0",
30
31
  "axios": "1.7.9",
31
32
  "define-zustand": "3.4.0",
@@ -34,7 +35,6 @@
34
35
  "qs": "6.11.2",
35
36
  "react": "18.3.1",
36
37
  "react-dom": "18.3.1",
37
- "styled-components": "^6.1.17",
38
38
  "type-fest": "4.33.0",
39
39
  "zustand": "5.0.3"
40
40
  },
@@ -48,9 +48,9 @@
48
48
  "@types/qs": "6.9.7",
49
49
  "@types/react": "18.3.3",
50
50
  "@types/react-dom": "18.3.0",
51
+ "@vanilla-extract/vite-plugin": "5.1.1",
51
52
  "@vitejs/plugin-react": "4.3.4",
52
53
  "autoprefixer": "10.4.14",
53
- "babel-plugin-styled-components": "2.1.4",
54
54
  "commitizen": "4.3.0",
55
55
  "cssnano": "6.0.0",
56
56
  "eslint": "9.17.0",
@@ -1,16 +1,10 @@
1
1
  import { FunctionComponent, ReactNode } from 'react'
2
- import { ThemeProvider } from 'styled-components'
3
2
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
4
- import { theme } from '@/shared/styles'
5
3
 
6
4
  const queryClient = new QueryClient()
7
5
 
8
6
  const AppContext: FunctionComponent<{ children: ReactNode }> = props => {
9
- return (
10
- <QueryClientProvider client={queryClient}>
11
- <ThemeProvider theme={theme}>{props.children}</ThemeProvider>
12
- </QueryClientProvider>
13
- )
7
+ return <QueryClientProvider client={queryClient}>{props.children}</QueryClientProvider>
14
8
  }
15
9
 
16
10
  export default AppContext
@@ -2,28 +2,53 @@ import { defineExtensionMessaging } from '@webext-core/messaging'
2
2
  import { CONTENT_MATCHES } from './constant'
3
3
 
4
4
  export type messageType = {
5
- test: () => string
5
+ CONNECT: () => true
6
6
  }
7
7
 
8
8
  export const { sendMessage, onMessage } = defineExtensionMessaging<messageType>()
9
- export async function sendToAllContent<A extends keyof messageType>(
10
- action: A,
11
- data?: Parameters<messageType[A]>[0]
12
- ) {
13
- const tabs = await chrome.tabs.query({ url: CONTENT_MATCHES })
14
- const result = await Promise.all(
9
+
10
+ export async function connectableTabs(tabQueryInfo?: chrome.tabs.QueryInfo) {
11
+ const tabs = await chrome.tabs.query({
12
+ ...tabQueryInfo,
13
+ url: tabQueryInfo?.url || CONTENT_MATCHES
14
+ })
15
+ const result = await Promise.allSettled(
15
16
  tabs.map(tab => {
16
- return sendMessage(action, data as never, { tabId: tab.id! })
17
+ return sendMessage('CONNECT', void 0, { tabId: tab.id! }).then(res => ({
18
+ data: res,
19
+ tab
20
+ }))
17
21
  })
18
22
  )
19
- return result
23
+ return result?.filter(o => o.status === 'fulfilled').map(o => o.value.tab)
20
24
  }
21
25
 
22
- export async function sendToCurrentContent<A extends keyof messageType>(
26
+ export async function sendToContent<A extends keyof messageType>(
23
27
  action: A,
24
- data?: Parameters<messageType[A]>[0]
28
+ options: {
29
+ data?: Parameters<messageType[A]>[0]
30
+ url?: string[]
31
+ target: 'first' | 'last' | 'all' | 'current'
32
+ }
25
33
  ) {
26
- const tabs = await chrome.tabs.query({ active: true, url: CONTENT_MATCHES })
27
- const result = await sendMessage(action, data as never, { tabId: tabs[0].id! })
34
+ let tabs = await connectableTabs({ url: options?.url })
35
+ switch (options.target) {
36
+ case 'current':
37
+ tabs = tabs.filter(tab => tab.active)
38
+ break
39
+ case 'first':
40
+ tabs = tabs.slice(0, 1)
41
+ break
42
+ case 'last':
43
+ tabs = tabs.slice(-1)
44
+ break
45
+ default:
46
+ break
47
+ }
48
+ const result = await Promise.all(
49
+ tabs.map(tab => {
50
+ return sendMessage(action, options.data as never, { tabId: tab.id! })
51
+ })
52
+ )
28
53
  return result
29
54
  }
@@ -0,0 +1,7 @@
1
+ import { GlobalStyleRule } from '@vanilla-extract/css'
2
+
3
+ export function createGlobalStyle(): GlobalStyleRule {
4
+ return {
5
+ margin: 0
6
+ }
7
+ }
@@ -1,2 +1,2 @@
1
- export * from './theme.styled'
2
- export * from './global-style'
1
+ export * from './global.css'
2
+ export * from './theme.css'
@@ -0,0 +1,3 @@
1
+ import { createTheme } from '@vanilla-extract/css'
2
+
3
+ export const [themeClass, themeVars] = createTheme({})
@@ -1,9 +1,6 @@
1
1
  /// <reference types="vite/client" />
2
2
  /// <reference types="./.wxt/wxt.d.ts" />
3
3
 
4
- import 'styled-components'
5
- import { themeType } from './shared/styles'
6
-
7
4
  declare global {
8
5
  interface ImportMetaEnv {
9
6
  readonly VITE_API_HOST: string
@@ -15,7 +12,3 @@ declare global {
15
12
  readonly env: ImportMetaEnv
16
13
  }
17
14
  }
18
-
19
- declare module 'styled-components' {
20
- export interface DefaultTheme extends themeType {}
21
- }
@@ -1,6 +1,7 @@
1
1
  import { defineConfig, UserManifestFn } from 'wxt'
2
2
  import react from '@vitejs/plugin-react'
3
3
  import svgr from 'vite-plugin-svgr'
4
+ import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'
4
5
  import pkgJson from './package.json'
5
6
 
6
7
  const manifest: UserManifestFn = () => {
@@ -29,24 +30,7 @@ export default defineConfig({
29
30
  runner: { disabled: true },
30
31
  imports: { eslintrc: { enabled: 9 } },
31
32
  vite: ({ mode }) => ({
32
- plugins: [
33
- svgr(),
34
- react({
35
- babel: {
36
- plugins: [
37
- [
38
- 'babel-plugin-styled-components',
39
- {
40
- ssr: false,
41
- displayName: false,
42
- fileName: false,
43
- transpileTemplateLiterals: false
44
- }
45
- ]
46
- ]
47
- }
48
- })
49
- ] as any,
33
+ plugins: [vanillaExtractPlugin(), svgr(), react()] as any,
50
34
  resolve: {
51
35
  alias: {
52
36
  '@': __dirname
@@ -1 +0,0 @@
1
- export * as popupMessage from './message'
@@ -1,7 +0,0 @@
1
- import { defineExtensionMessaging } from '@webext-core/messaging'
2
-
3
- export type messageType = {
4
- test: () => string
5
- }
6
-
7
- export const { sendMessage, onMessage } = defineExtensionMessaging<messageType>()
@@ -1,9 +0,0 @@
1
- import { createGlobalStyle, css } from 'styled-components'
2
-
3
- export const GlobalStyle = createGlobalStyle<{ nameSpace?: string }>(props => {
4
- return css`
5
- .${props.nameSpace || 'body'} {
6
- margin: 0;
7
- }
8
- `
9
- })
@@ -1,47 +0,0 @@
1
- import { CSSProperties } from 'react'
2
- import { isString } from 'es-toolkit'
3
-
4
- export const theme = {
5
- tools: {
6
- ellipsis: () => ({
7
- overflow: 'hidden',
8
- textOverflow: 'ellipsis',
9
- whiteSpace: 'nowrap'
10
- }),
11
- lineClamp: (n: number) => {
12
- return {
13
- WebkitLineClamp: `${n}`,
14
- WebkitBoxOrient: 'vertical',
15
- overflow: 'hidden',
16
- display: '-webkit-box'
17
- } satisfies CSSProperties
18
- },
19
- size: (s: string) => ({ width: s, height: s }),
20
- py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
21
- px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
22
- my: (s: string) => ({ marginTop: s, marginBottom: s }),
23
- mx: (s: string) => ({ marginLeft: s, marginRight: s }),
24
- flex: (
25
- align: CSSProperties['alignItems'],
26
- justify: CSSProperties['justifyContent'],
27
- vertical?: boolean
28
- ) => {
29
- return {
30
- display: 'flex',
31
- alignItems: align,
32
- justifyContent: justify,
33
- flexDirection: vertical ? 'column' : 'row'
34
- } satisfies CSSProperties
35
- },
36
- /** 数字为元素数量,字符串为对应css的值 */
37
- grid: (rows: number | string, cols: number | string, gap?: number) => {
38
- return {
39
- display: 'grid',
40
- gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
41
- gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
42
- gap: gap ? `${gap}px` : void 0
43
- } satisfies CSSProperties
44
- }
45
- }
46
- }
47
- export type themeType = typeof theme