create-packer 1.36.0 → 1.37.2

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.
Files changed (30) hide show
  1. package/package.json +1 -1
  2. package/template/web-extension/.wxt/eslintrc-auto-import.json +21 -0
  3. package/template/web-extension/.wxt/tsconfig.json +28 -0
  4. package/template/web-extension/.wxt/types/globals.d.ts +15 -0
  5. package/template/web-extension/.wxt/types/i18n.d.ts +81 -0
  6. package/template/web-extension/.wxt/types/imports.d.ts +21 -0
  7. package/template/web-extension/.wxt/types/paths.d.ts +15 -0
  8. package/template/web-extension/.wxt/wxt.d.ts +6 -0
  9. package/template/web-extension/entrypoints/background/index.ts +1 -0
  10. package/template/web-extension/{content_script → entrypoints/content}/domain/app/tools/insertApp.tsx +1 -1
  11. package/template/web-extension/entrypoints/content/index.tsx +12 -0
  12. package/template/web-extension/{content_script → entrypoints/content}/modules/common/common.tsx +1 -1
  13. package/template/web-extension/{content_script → entrypoints/content}/modules/common/insert.tsx +1 -1
  14. package/template/web-extension/{popup/popup.html → entrypoints/popup/index.html} +1 -1
  15. package/template/web-extension/package.json +13 -5
  16. package/template/web-extension/shared/components/app-context.tsx +1 -1
  17. package/template/web-extension/tsconfig.json +4 -16
  18. package/template/web-extension/wxt.config.ts +46 -0
  19. package/template/web-extension/background/index.ts +0 -0
  20. package/template/web-extension/content_script/index.tsx +0 -3
  21. package/template/web-extension/defineManifest.ts +0 -32
  22. package/template/web-extension/vite.config.ts +0 -46
  23. /package/template/web-extension/{content_script → entrypoints/content}/constants/base.ts +0 -0
  24. /package/template/web-extension/{content_script → entrypoints/content}/constants/index.ts +0 -0
  25. /package/template/web-extension/{content_script → entrypoints/content}/domain/app/index.ts +0 -0
  26. /package/template/web-extension/{content_script → entrypoints/content}/domain/app/tools/index.ts +0 -0
  27. /package/template/web-extension/{content_script → entrypoints/content}/modules/common/index.ts +0 -0
  28. /package/template/web-extension/{content_script → entrypoints/content}/modules/index.ts +0 -0
  29. /package/template/web-extension/{popup/index.tsx → entrypoints/popup/main.tsx} +0 -0
  30. /package/template/web-extension/{popup → entrypoints/popup}/popup.container.tsx +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.36.0",
3
+ "version": "1.37.2",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -0,0 +1,21 @@
1
+ {
2
+ "globals": {
3
+ "ContentScriptContext": true,
4
+ "InvalidMatchPattern": true,
5
+ "MatchPattern": true,
6
+ "browser": true,
7
+ "createIframeUi": true,
8
+ "createIntegratedUi": true,
9
+ "createShadowRootUi": true,
10
+ "defineAppConfig": true,
11
+ "defineBackground": true,
12
+ "defineConfig": true,
13
+ "defineContentScript": true,
14
+ "defineUnlistedScript": true,
15
+ "defineWxtPlugin": true,
16
+ "fakeBrowser": true,
17
+ "injectScript": true,
18
+ "storage": true,
19
+ "useAppConfig": true
20
+ }
21
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "noEmit": true,
7
+ "esModuleInterop": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "resolveJsonModule": true,
10
+ "strict": true,
11
+ "skipLibCheck": true,
12
+ "paths": {
13
+ "@": [".."],
14
+ "@/*": ["../*"],
15
+ "~": [".."],
16
+ "~/*": ["../*"],
17
+ "@@": [".."],
18
+ "@@/*": ["../*"],
19
+ "~~": [".."],
20
+ "~~/*": ["../*"]
21
+ }
22
+ },
23
+ "include": [
24
+ "../**/*",
25
+ "./wxt.d.ts"
26
+ ],
27
+ "exclude": ["../dist"]
28
+ }
@@ -0,0 +1,15 @@
1
+ // Generated by wxt
2
+ interface ImportMetaEnv {
3
+ readonly MANIFEST_VERSION: 2 | 3;
4
+ readonly BROWSER: string;
5
+ readonly CHROME: boolean;
6
+ readonly FIREFOX: boolean;
7
+ readonly SAFARI: boolean;
8
+ readonly EDGE: boolean;
9
+ readonly OPERA: boolean;
10
+ readonly COMMAND: "build" | "serve";
11
+ readonly ENTRYPOINT: string;
12
+ }
13
+ interface ImportMeta {
14
+ readonly env: ImportMetaEnv
15
+ }
@@ -0,0 +1,81 @@
1
+ // Generated by wxt
2
+ import "wxt/browser";
3
+
4
+ declare module "wxt/browser" {
5
+ /**
6
+ * See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
7
+ */
8
+ interface GetMessageOptions {
9
+ /**
10
+ * See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
11
+ */
12
+ escapeLt?: boolean
13
+ }
14
+
15
+ export interface WxtI18n extends I18n.Static {
16
+ /**
17
+ * The extension or app ID; you might use this string to construct URLs for resources inside the extension. Even unlocalized extensions can use this message.
18
+ * Note: You can't use this message in a manifest file.
19
+ *
20
+ * "<browser.runtime.id>"
21
+ */
22
+ getMessage(
23
+ messageName: "@@extension_id",
24
+ substitutions?: string | string[],
25
+ options?: GetMessageOptions,
26
+ ): string;
27
+ /**
28
+ * "<browser.i18n.getUiLocale()>"
29
+ */
30
+ getMessage(
31
+ messageName: "@@ui_locale",
32
+ substitutions?: string | string[],
33
+ options?: GetMessageOptions,
34
+ ): string;
35
+ /**
36
+ * The text direction for the current locale, either "ltr" for left-to-right languages such as English or "rtl" for right-to-left languages such as Japanese.
37
+ *
38
+ * "<ltr|rtl>"
39
+ */
40
+ getMessage(
41
+ messageName: "@@bidi_dir",
42
+ substitutions?: string | string[],
43
+ options?: GetMessageOptions,
44
+ ): string;
45
+ /**
46
+ * If the @@bidi_dir is "ltr", then this is "rtl"; otherwise, it's "ltr".
47
+ *
48
+ * "<rtl|ltr>"
49
+ */
50
+ getMessage(
51
+ messageName: "@@bidi_reversed_dir",
52
+ substitutions?: string | string[],
53
+ options?: GetMessageOptions,
54
+ ): string;
55
+ /**
56
+ * If the @@bidi_dir is "ltr", then this is "left"; otherwise, it's "right".
57
+ *
58
+ * "<left|right>"
59
+ */
60
+ getMessage(
61
+ messageName: "@@bidi_start_edge",
62
+ substitutions?: string | string[],
63
+ options?: GetMessageOptions,
64
+ ): string;
65
+ /**
66
+ * If the @@bidi_dir is "ltr", then this is "right"; otherwise, it's "left".
67
+ *
68
+ * "<right|left>"
69
+ */
70
+ getMessage(
71
+ messageName: "@@bidi_end_edge",
72
+ substitutions?: string | string[],
73
+ options?: GetMessageOptions,
74
+ ): string;
75
+ getMessage(
76
+ messageName: "@@extension_id" | "@@ui_locale" | "@@bidi_dir" | "@@bidi_reversed_dir" | "@@bidi_start_edge" | "@@bidi_end_edge",
77
+ substitutions?: string | string[],
78
+ options?: GetMessageOptions,
79
+ ): string;
80
+ }
81
+ }
@@ -0,0 +1,21 @@
1
+ // Generated by wxt
2
+ export {}
3
+ declare global {
4
+ const ContentScriptContext: typeof import('wxt/client')['ContentScriptContext']
5
+ const InvalidMatchPattern: typeof import('wxt/sandbox')['InvalidMatchPattern']
6
+ const MatchPattern: typeof import('wxt/sandbox')['MatchPattern']
7
+ const browser: typeof import('wxt/browser')['browser']
8
+ const createIframeUi: typeof import('wxt/client')['createIframeUi']
9
+ const createIntegratedUi: typeof import('wxt/client')['createIntegratedUi']
10
+ const createShadowRootUi: typeof import('wxt/client')['createShadowRootUi']
11
+ const defineAppConfig: typeof import('wxt/sandbox')['defineAppConfig']
12
+ const defineBackground: typeof import('wxt/sandbox')['defineBackground']
13
+ const defineConfig: typeof import('wxt')['defineConfig']
14
+ const defineContentScript: typeof import('wxt/sandbox')['defineContentScript']
15
+ const defineUnlistedScript: typeof import('wxt/sandbox')['defineUnlistedScript']
16
+ const defineWxtPlugin: typeof import('wxt/sandbox')['defineWxtPlugin']
17
+ const fakeBrowser: typeof import('wxt/testing')['fakeBrowser']
18
+ const injectScript: typeof import('wxt/client')['injectScript']
19
+ const storage: typeof import('wxt/storage')['storage']
20
+ const useAppConfig: typeof import('wxt/client')['useAppConfig']
21
+ }
@@ -0,0 +1,15 @@
1
+ // Generated by wxt
2
+ import "wxt/browser";
3
+
4
+ declare module "wxt/browser" {
5
+ export type PublicPath =
6
+ | "/background.js"
7
+ | "/content-scripts/content.js"
8
+ | "/popup.html"
9
+ | "/vite.svg"
10
+ type HtmlPublicPath = Extract<PublicPath, `${string}.html`>
11
+ export interface WxtRuntime {
12
+ getURL(path: PublicPath): string;
13
+ getURL(path: `${HtmlPublicPath}${string}`): string;
14
+ }
15
+ }
@@ -0,0 +1,6 @@
1
+ // Generated by wxt
2
+ /// <reference types="wxt/vite-builder-env" />
3
+ /// <reference types="./types/paths.d.ts" />
4
+ /// <reference types="./types/i18n.d.ts" />
5
+ /// <reference types="./types/globals.d.ts" />
6
+ /// <reference types="./types/imports.d.ts" />
@@ -0,0 +1 @@
1
+ export default defineBackground(() => {})
@@ -3,7 +3,7 @@ import { createRoot } from 'react-dom/client'
3
3
  import { isFunction } from 'lodash-es'
4
4
  import { Nullable } from '1k-types'
5
5
  import { AppContext } from '@/shared/components'
6
- import { classNameSpace } from '@/content_script/constants'
6
+ import { classNameSpace } from '@/entrypoints/content/constants'
7
7
 
8
8
  export enum insertAppStatus {
9
9
  success,
@@ -0,0 +1,12 @@
1
+ import { Common } from './modules'
2
+
3
+ export default defineContentScript({
4
+ run_at: 'document_start',
5
+ matches: [
6
+ 'https://developer.chrome.com/docs/extensions/*',
7
+ 'https://developer.chrome.com/docs/webstore/*'
8
+ ],
9
+ main: () => {
10
+ Common.insert()
11
+ }
12
+ })
@@ -1,5 +1,5 @@
1
1
  import { GlobalStyle } from '@/shared/styles'
2
- import { classNameSpace } from '@/content_script/constants'
2
+ import { classNameSpace } from '@/entrypoints/content/constants'
3
3
 
4
4
  export default function Home() {
5
5
  return (
@@ -1,4 +1,4 @@
1
- import { insertApp } from '@/content_script/domain/app'
1
+ import { insertApp } from '@/entrypoints/content/domain/app'
2
2
  import Common from './common'
3
3
 
4
4
  export function insert() {
@@ -8,6 +8,6 @@
8
8
  </head>
9
9
  <body>
10
10
  <div id="root"></div>
11
- <script type="module" src="./index.tsx"></script>
11
+ <script type="module" src="./main.tsx"></script>
12
12
  </body>
13
13
  </html>
@@ -5,9 +5,17 @@
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "prepare": "husky install",
8
- "dev": "vite",
9
- "build": "tsc --noEmit && vite build",
10
- "preview": "vite preview",
8
+ "dev": "wxt",
9
+ "dev:firefox": "wxt -b firefox",
10
+ "build": "wxt build",
11
+ "build_dev": "wxt build --mode dev",
12
+ "build:firefox": "wxt build -b firefox",
13
+ "build_dev:firefox": "wxt build -b firefox --mode dev",
14
+ "zip": "wxt zip",
15
+ "zip_dev": "wxt zip --mode dev",
16
+ "zip:firefox": "wxt zip -b firefox",
17
+ "zip_dev:firefox": "wxt zip -b firefox --mode dev",
18
+ "postinstall": "wxt prepare",
11
19
  "up:vite": "pnpm up vite @vitejs/* -L",
12
20
  "format": "biome format --write",
13
21
  "lint": "tsc --noEmit && eslint **/*.{tsx,ts} && stylelint **/*.{css,scss,less}",
@@ -34,7 +42,6 @@
34
42
  "@commitlint/cli": "17.6.1",
35
43
  "@commitlint/config-conventional": "17.6.1",
36
44
  "@commitlint/cz-commitlint": "17.5.0",
37
- "@crxjs/vite-plugin": "2.0.0-beta.22",
38
45
  "@rollup/plugin-eslint": "9.0.5",
39
46
  "@types/chrome": "0.0.254",
40
47
  "@types/lodash-es": "4.17.7",
@@ -68,7 +75,8 @@
68
75
  "typescript": "5.5.2",
69
76
  "vite": "5.3.3",
70
77
  "vite-plugin-stylelint": "5.3.1",
71
- "vite-plugin-svgr": "4.2.0"
78
+ "vite-plugin-svgr": "4.2.0",
79
+ "wxt": "0.19.11"
72
80
  },
73
81
  "config": {
74
82
  "commitizen": {
@@ -1,7 +1,7 @@
1
1
  import { FunctionComponent, ReactNode } from 'react'
2
2
  import { ThemeProvider } from 'styled-components'
3
3
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
4
- import { theme } from 'shared/styles'
4
+ import { theme } from '@/shared/styles'
5
5
 
6
6
  const queryClient = new QueryClient()
7
7
 
@@ -3,11 +3,7 @@
3
3
  "baseUrl": ".",
4
4
  "target": "ESNext",
5
5
  "useDefineForClassFields": true,
6
- "lib": [
7
- "DOM",
8
- "DOM.Iterable",
9
- "ESNext"
10
- ],
6
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
11
7
  "allowJs": false,
12
8
  "skipLibCheck": true,
13
9
  "esModuleInterop": false,
@@ -23,19 +19,11 @@
23
19
  "noEmit": true,
24
20
  "jsx": "react-jsx",
25
21
  "paths": {
26
- "@/*": [
27
- "./*"
28
- ]
22
+ "@/*": ["./*"]
29
23
  }
30
24
  },
31
- "include": [
32
- "**/*.ts",
33
- "**/*.tsx"
34
- ],
35
- "exclude": [
36
- "scripts",
37
- "vite.config.ts"
38
- ],
25
+ "include": ["**/*.ts", "**/*.tsx", ".wxt/wxt.d.ts"],
26
+ "exclude": ["scripts"],
39
27
  "references": [
40
28
  {
41
29
  "path": "./tsconfig.node.json"
@@ -0,0 +1,46 @@
1
+ import { defineConfig, UserManifestFn } from 'wxt'
2
+ import react from '@vitejs/plugin-react'
3
+ import stylelint from 'vite-plugin-stylelint'
4
+ import eslint from '@rollup/plugin-eslint'
5
+ import svgr from 'vite-plugin-svgr'
6
+ import pkgJson from './package.json'
7
+
8
+ const manifest: UserManifestFn = () => {
9
+ const host_permissions: string[] = []
10
+
11
+ return {
12
+ manifest_version: 3,
13
+ name: 'Hello Extensions',
14
+ description: 'Base Level Extension',
15
+ version: pkgJson.version,
16
+ action: {
17
+ default_icon: 'vite.svg'
18
+ },
19
+ host_permissions
20
+ }
21
+ }
22
+
23
+ export default defineConfig({
24
+ outDir: 'dist',
25
+ zip: {
26
+ name: 'webExtension',
27
+ artifactTemplate: '{{name}}@{{version}}-{{mode}}-{{browser}}.zip'
28
+ },
29
+ manifest,
30
+ vite: ({ mode }) => ({
31
+ plugins: [
32
+ svgr(),
33
+ stylelint({ cache: false, include: ['**/*.{css,scss,sass,less,styl,vue,svelte}'] }),
34
+ eslint({ include: ['**/*.{ts,tsx,js,jsx}'] }),
35
+ react()
36
+ ] as any,
37
+ resolve: {
38
+ alias: {
39
+ '@': __dirname
40
+ }
41
+ },
42
+ esbuild: {
43
+ drop: mode === 'production' ? ['console', 'debugger'] : []
44
+ }
45
+ })
46
+ })
File without changes
@@ -1,3 +0,0 @@
1
- import { Common } from './modules'
2
-
3
- Common.insert()
@@ -1,32 +0,0 @@
1
- import { defineManifest } from '@crxjs/vite-plugin'
2
- import pkgJson from './package.json'
3
-
4
- interface argType {
5
- mode: string
6
- }
7
- export default function ({ mode }: argType) {
8
- const host_permissions: string[] = []
9
- return defineManifest({
10
- manifest_version: 3,
11
- name: 'Hello Extensions',
12
- description: 'Base Level Extension',
13
- version: pkgJson.version,
14
- action: {
15
- default_popup: 'popup/popup.html',
16
- default_icon: 'vite.svg'
17
- },
18
- host_permissions,
19
- content_scripts: [
20
- {
21
- js: ['content_script/index.tsx'],
22
- matches: [
23
- 'https://developer.chrome.com/docs/extensions/*',
24
- 'https://developer.chrome.com/docs/webstore/*'
25
- ]
26
- }
27
- ],
28
- background: {
29
- service_worker: 'background/index.ts'
30
- }
31
- })
32
- }
@@ -1,46 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react'
3
- import stylelint from 'vite-plugin-stylelint'
4
- import eslint from '@rollup/plugin-eslint'
5
- import { crx } from '@crxjs/vite-plugin'
6
- import svgr from 'vite-plugin-svgr'
7
- import defineManifest from './defineManifest'
8
-
9
- // https://vitejs.dev/config/
10
- export default defineConfig(({ mode }) => {
11
- return {
12
- plugins: [
13
- svgr(),
14
- stylelint({ cache: false, include: ['**/*.{css,scss,sass,less,styl,ts,tsx}'] }),
15
- eslint({ include: ['**/*.{ts,tsx,js,jsx}'] }),
16
- react({
17
- babel: {
18
- plugins: [
19
- [
20
- 'babel-plugin-styled-components',
21
- {
22
- ssr: false,
23
- displayName: false,
24
- fileName: false,
25
- transpileTemplateLiterals: false
26
- }
27
- ]
28
- ]
29
- }
30
- }),
31
- crx({ manifest: defineManifest({ mode }) })
32
- ],
33
- resolve: {
34
- alias: {
35
- '@': __dirname
36
- }
37
- },
38
- esbuild: {
39
- drop: mode === 'production' ? ['console', 'debugger'] : []
40
- },
41
- server: {
42
- host: '0.0.0.0',
43
- port: 30001
44
- }
45
- }
46
- })