@crxjs/vite-plugin 2.0.0-beta.26 → 2.0.0-beta.28
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/README.md +0 -0
- package/dist/index.mjs +1 -1
- package/package.json +22 -23
package/README.md
CHANGED
|
File without changes
|
package/dist/index.mjs
CHANGED
|
@@ -59,7 +59,7 @@ function isCrxPlugin(p) {
|
|
|
59
59
|
return !!p && typeof p === "object" && !(p instanceof Promise) && !Array.isArray(p) && p.name.startsWith("crx:");
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
var workerHmrClient = "const ownOrigin = `chrome-extension://${chrome.runtime.id}`;\nself.addEventListener(\"fetch\", (fetchEvent) => {\n const url = new URL(fetchEvent.request.url);\n if (url.origin === ownOrigin) {\n fetchEvent.respondWith(sendToServer(url));\n }\n});\nasync function sendToServer(url) {\n url.protocol = \"http:\";\n url.host = \"localhost\";\n url.port = __SERVER_PORT__;\n url.searchParams.set(\"t\", Date.now().toString());\n const response = await fetch(url.href.replace(/=$|=(?=&)/g, \"\"));\n return new Response(response.body, {\n headers: {\n \"Content-Type\": response.headers.get(\"Content-Type\") ?? \"text/javascript\"\n }\n });\n}\nconst ports = /* @__PURE__ */ new Set();\nchrome.runtime.onConnect.addListener((port) => {\n if (port.name === \"@crx/client\") {\n ports.add(port);\n port.onDisconnect.addListener((port2) => ports.delete(port2));\n port.onMessage.addListener((message) => {\n });\n port.postMessage({ data: JSON.stringify({ type: \"connected\" }) });\n }\n});\nfunction notifyContentScripts(payload) {\n const data = JSON.stringify(payload);\n for (const port of ports)\n port.postMessage({ data });\n}\nconsole.log(\"[vite] connecting...\");\nconst socketProtocol = __HMR_PROTOCOL__ || (location.protocol === \"https:\" ? \"wss\" : \"ws\");\nconst socketHost = `${__HMR_HOSTNAME__ || location.hostname}:${__HMR_PORT__}`;\nconst socket = new WebSocket(`${socketProtocol}://${socketHost}`, \"vite-hmr\");\nconst base = __BASE__ || \"/\";\nsocket.addEventListener(\"message\", async ({ data }) => {\n handleSocketMessage(JSON.parse(data));\n});\nfunction isCrxHmrPayload(x) {\n return x.type === \"custom\" && x.event.startsWith(\"crx:\");\n}\nfunction handleSocketMessage(payload) {\n if (isCrxHmrPayload(payload)) {\n handleCrxHmrPayload(payload);\n } else if (payload.type === \"connected\") {\n console.log(`[vite] connected.`);\n const interval = setInterval(() => socket.send(\"ping\"), __HMR_TIMEOUT__);\n socket.addEventListener(\"close\", () => clearInterval(interval));\n }\n}\nfunction handleCrxHmrPayload(payload) {\n notifyContentScripts(payload);\n switch (payload.event) {\n case \"crx:runtime-reload\":\n console.log(\"[crx] runtime reload\");\n chrome.runtime.reload();\n break;\n }\n}\nasync function waitForSuccessfulPing(ms = 1e3) {\n while (true) {\n try {\n await fetch(`${base}__vite_ping`);\n break;\n } catch (e) {\n await new Promise((resolve) => setTimeout(resolve, ms));\n }\n }\n}\nsocket.addEventListener(\"close\", async ({ wasClean }) => {\n if (wasClean)\n return;\n console.log(`[vite] server connection lost. polling for restart...`);\n await waitForSuccessfulPing();\n handleCrxHmrPayload({\n type: \"custom\",\n event: \"crx:runtime-reload\"\n });\n});\n";
|
|
62
|
+
var workerHmrClient = "const ownOrigin = `chrome-extension://${chrome.runtime.id}`;\nself.addEventListener(\"fetch\", (fetchEvent) => {\n const url = new URL(fetchEvent.request.url);\n if (url.origin === ownOrigin) {\n fetchEvent.respondWith(sendToServer(url));\n }\n});\nasync function sendToServer(url) {\n url.protocol = \"http:\";\n url.host = \"localhost\";\n url.port = __SERVER_PORT__;\n url.searchParams.set(\"t\", Date.now().toString());\n const response = await fetch(url.href.replace(/=$|=(?=&)/g, \"\"));\n return new Response(response.body, {\n headers: {\n \"Content-Type\": response.headers.get(\"Content-Type\") ?? \"text/javascript\",\n \"Cache-Control\": response.headers.get(\"Cache-Control\") ?? \"\"\n }\n });\n}\nconst ports = /* @__PURE__ */ new Set();\nchrome.runtime.onConnect.addListener((port) => {\n if (port.name === \"@crx/client\") {\n ports.add(port);\n port.onDisconnect.addListener((port2) => ports.delete(port2));\n port.onMessage.addListener((message) => {\n });\n port.postMessage({ data: JSON.stringify({ type: \"connected\" }) });\n }\n});\nfunction notifyContentScripts(payload) {\n const data = JSON.stringify(payload);\n for (const port of ports)\n port.postMessage({ data });\n}\nconsole.log(\"[vite] connecting...\");\nconst socketProtocol = __HMR_PROTOCOL__ || (location.protocol === \"https:\" ? \"wss\" : \"ws\");\nconst socketHost = `${__HMR_HOSTNAME__ || location.hostname}:${__HMR_PORT__}`;\nconst socket = new WebSocket(`${socketProtocol}://${socketHost}`, \"vite-hmr\");\nconst base = __BASE__ || \"/\";\nsocket.addEventListener(\"message\", async ({ data }) => {\n handleSocketMessage(JSON.parse(data));\n});\nfunction isCrxHmrPayload(x) {\n return x.type === \"custom\" && x.event.startsWith(\"crx:\");\n}\nfunction handleSocketMessage(payload) {\n if (isCrxHmrPayload(payload)) {\n handleCrxHmrPayload(payload);\n } else if (payload.type === \"connected\") {\n console.log(`[vite] connected.`);\n const interval = setInterval(() => socket.send(\"ping\"), __HMR_TIMEOUT__);\n socket.addEventListener(\"close\", () => clearInterval(interval));\n }\n}\nfunction handleCrxHmrPayload(payload) {\n notifyContentScripts(payload);\n switch (payload.event) {\n case \"crx:runtime-reload\":\n console.log(\"[crx] runtime reload\");\n chrome.runtime.reload();\n break;\n }\n}\nasync function waitForSuccessfulPing(ms = 1e3) {\n while (true) {\n try {\n await fetch(`${base}__vite_ping`);\n break;\n } catch (e) {\n await new Promise((resolve) => setTimeout(resolve, ms));\n }\n }\n}\nsocket.addEventListener(\"close\", async ({ wasClean }) => {\n if (wasClean)\n return;\n console.log(`[vite] server connection lost. polling for restart...`);\n await waitForSuccessfulPing();\n handleCrxHmrPayload({\n type: \"custom\",\n event: \"crx:runtime-reload\"\n });\n});\n";
|
|
63
63
|
|
|
64
64
|
const _debug = (id) => debug$3("crx").extend(id);
|
|
65
65
|
const structuredClone = (obj) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crxjs/vite-plugin",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.28",
|
|
4
4
|
"description": "Build Chrome Extensions with this Vite plugin.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rollup-plugin",
|
|
@@ -45,39 +45,21 @@
|
|
|
45
45
|
"schema",
|
|
46
46
|
"client.d.ts"
|
|
47
47
|
],
|
|
48
|
-
"scripts": {
|
|
49
|
-
"format": "prettier -w -c ../../.prettierrc.yaml",
|
|
50
|
-
"build": "run-s build:clean build:js",
|
|
51
|
-
"build:clean": "rimraf dist",
|
|
52
|
-
"build:js": "rollup -c rollup.config.ts --configPlugin esbuild",
|
|
53
|
-
"dev:js": "npm run build:js -- -w",
|
|
54
|
-
"dev:lint": "tsc --noEmit --watch",
|
|
55
|
-
"lint": "run-s lint:eslint lint:types",
|
|
56
|
-
"lint:eslint": "eslint \"{src,test}/**/*.ts\"",
|
|
57
|
-
"lint:types": "tsc --noEmit",
|
|
58
|
-
"test": "vitest --mode unit",
|
|
59
|
-
"test:e2e": "vitest --mode e2e",
|
|
60
|
-
"test:run": "run-s test:run:*",
|
|
61
|
-
"test:run:out": "vitest --run --mode out",
|
|
62
|
-
"test:run:e2e": "vitest --run --mode e2e",
|
|
63
|
-
"test:update": "run-s \"test:run:out --update\" \"test:run:e2e --update\""
|
|
64
|
-
},
|
|
65
48
|
"dependencies": {
|
|
66
49
|
"@rollup/pluginutils": "^4.1.2",
|
|
67
50
|
"@webcomponents/custom-elements": "^1.5.0",
|
|
68
51
|
"acorn-walk": "^8.2.0",
|
|
69
52
|
"cheerio": "^1.0.0-rc.10",
|
|
70
|
-
"connect-injector": "^0.4.4",
|
|
71
53
|
"convert-source-map": "^1.7.0",
|
|
72
54
|
"debug": "^4.3.3",
|
|
73
55
|
"es-module-lexer": "^0.10.0",
|
|
74
56
|
"fast-glob": "^3.2.11",
|
|
75
57
|
"fs-extra": "^10.0.1",
|
|
76
58
|
"jsesc": "^3.0.2",
|
|
77
|
-
"magic-string": "^0.
|
|
59
|
+
"magic-string": "^0.30.12",
|
|
78
60
|
"picocolors": "^1.0.0",
|
|
79
61
|
"react-refresh": "^0.13.0",
|
|
80
|
-
"rollup": "2.
|
|
62
|
+
"rollup": "2.79.2",
|
|
81
63
|
"rxjs": "7.5.7"
|
|
82
64
|
},
|
|
83
65
|
"devDependencies": {
|
|
@@ -117,9 +99,26 @@
|
|
|
117
99
|
"rollup-plugin-esbuild": "4.10.3",
|
|
118
100
|
"svelte": "^3.48.0",
|
|
119
101
|
"typescript": "^4.6.4",
|
|
120
|
-
"vite": "^3.
|
|
102
|
+
"vite": "^3.2.11",
|
|
121
103
|
"vite-plugin-inspect": "0.7.25",
|
|
122
104
|
"vitest": "0.28.5",
|
|
123
105
|
"vue": "3.2.47"
|
|
106
|
+
},
|
|
107
|
+
"scripts": {
|
|
108
|
+
"format": "prettier -w -c ../../.prettierrc.yaml",
|
|
109
|
+
"build": "run-s build:clean build:js",
|
|
110
|
+
"build:clean": "rimraf dist",
|
|
111
|
+
"build:js": "rollup -c rollup.config.ts --configPlugin esbuild",
|
|
112
|
+
"dev:js": "npm run build:js -- -w",
|
|
113
|
+
"dev:lint": "tsc --noEmit --watch",
|
|
114
|
+
"lint": "run-s lint:eslint lint:types",
|
|
115
|
+
"lint:eslint": "eslint \"{src,test}/**/*.ts\"",
|
|
116
|
+
"lint:types": "tsc --noEmit",
|
|
117
|
+
"test": "vitest --mode unit",
|
|
118
|
+
"test:e2e": "vitest --mode e2e",
|
|
119
|
+
"test:run": "run-s test:run:*",
|
|
120
|
+
"test:run:out": "vitest --run --mode out",
|
|
121
|
+
"test:run:e2e": "vitest --run --mode e2e",
|
|
122
|
+
"test:update": "run-s \"test:run:out --update\" \"test:run:e2e --update\""
|
|
124
123
|
}
|
|
125
|
-
}
|
|
124
|
+
}
|