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 +1 -1
- package/template/lib/workspace/tsconfig.node.json +1 -1
- package/template/web-app/react-rsbuild/shared/styles/index.ts +1 -1
- package/template/web-app/react-rsbuild/shared/styles/theme.css.ts +1 -1
- package/template/web-app/react-vite/shared/styles/index.ts +1 -1
- package/template/web-app/react-vite/shared/styles/theme.css.ts +1 -1
- package/template/web-extension/entrypoints/content/global.css.ts +5 -0
- package/template/web-extension/entrypoints/content/index.tsx +2 -1
- package/template/web-extension/entrypoints/content/modules/common/common.tsx +2 -7
- package/template/web-extension/entrypoints/popup/global.css.ts +4 -0
- package/template/web-extension/entrypoints/popup/main.tsx +1 -2
- package/template/web-extension/package.json +2 -2
- package/template/web-extension/shared/components/app-context/view.tsx +1 -7
- package/template/web-extension/shared/content/message.ts +38 -13
- package/template/web-extension/shared/styles/global.css.ts +7 -0
- package/template/web-extension/shared/styles/index.ts +2 -2
- package/template/web-extension/shared/styles/theme.css.ts +3 -0
- package/template/web-extension/vite-env.d.ts +0 -7
- package/template/web-extension/wxt.config.ts +2 -18
- package/template/web-extension/shared/popup/index.ts +0 -1
- package/template/web-extension/shared/popup/message.ts +0 -7
- package/template/web-extension/shared/styles/global-style.ts +0 -9
- package/template/web-extension/shared/styles/theme.styled.ts +0 -47
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export *
|
|
1
|
+
export * from './theme.css'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export *
|
|
1
|
+
export * from './theme.css'
|
|
@@ -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
|
|
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
|
}
|
|
@@ -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
|
-
|
|
5
|
+
CONNECT: () => true
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export const { sendMessage, onMessage } = defineExtensionMessaging<messageType>()
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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(
|
|
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
|
|
26
|
+
export async function sendToContent<A extends keyof messageType>(
|
|
23
27
|
action: A,
|
|
24
|
-
|
|
28
|
+
options: {
|
|
29
|
+
data?: Parameters<messageType[A]>[0]
|
|
30
|
+
url?: string[]
|
|
31
|
+
target: 'first' | 'last' | 'all' | 'current'
|
|
32
|
+
}
|
|
25
33
|
) {
|
|
26
|
-
|
|
27
|
-
|
|
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
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './global.css'
|
|
2
|
+
export * from './theme.css'
|
|
@@ -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,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
|