Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ed7bb2

Browse files
committed
Patch navigator usage in packages
1 parenta1ad85e commit2ed7bb2

File tree

7 files changed

+468
-2
lines changed

7 files changed

+468
-2
lines changed

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"scripts": {
2121
"build":"webpack",
2222
"fmt":"prettier --write .",
23+
"postinstall":"patch-package",
2324
"lint":"eslint . --ext ts,md,json",
2425
"lint:fix":"yarn lint --fix",
2526
"package":"webpack --mode production --devtool hidden-source-map",
@@ -387,6 +388,7 @@
387388
"markdown-eslint-parser":"^1.2.1",
388389
"memfs":"^4.49.0",
389390
"nyc":"^17.1.0",
391+
"patch-package":"^8.0.1",
390392
"prettier":"^3.5.3",
391393
"ts-loader":"^9.5.1",
392394
"typescript":"^5.9.3",

‎patches/README.md‎

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#Package Patches
2+
3+
This directory contains patches for packages that use the`navigator` global, which triggers deprecation warnings in VS Code extensions.
4+
5+
All patches are automatically applied during`yarn install` via the`postinstall` script in package.json.
6+
7+
##How to Update Patches
8+
9+
When updating a patched package to a new version:
10+
11+
1. Update the package:`yarn upgrade package-name@x.x.x`
12+
2. Delete the old patch file:`rm patches/package-name+old.version.patch`
13+
3. Manually reapply the changes (documented below) to the new version's files
14+
4. Generate new patch:`npx patch-package package-name`
15+
5. Test:`yarn build && yarn test:ci`
16+
17+
---
18+
19+
##axios
20+
21+
**Why:** Removes`navigator` checks to avoid VS Code deprecation warnings. Axios uses`navigator` to detect browser environments, but this is unnecessary in Node.js-based VS Code extensions.
22+
23+
**What to look for:**
24+
Search for the pattern where`_navigator` is defined. This appears in multiple distribution files.
25+
26+
**Pattern to find:**
27+
```javascript
28+
const_navigator=typeofnavigator==='object'&&navigator||undefined;
29+
```
30+
31+
**Replace with:**
32+
```javascript
33+
const_navigator=undefined;// PATCHED: Removed navigator check
34+
```
35+
36+
**Files typically modified:**
37+
-`node_modules/axios/dist/node/axios.cjs`
38+
-`node_modules/axios/dist/esm/axios.js`
39+
-`node_modules/axios/lib/platform/common/utils.js`
40+
41+
**Tip:** Search for`const _navigator =` in the axios directory.
42+
43+
---
44+
45+
##zod
46+
47+
**Why:** Removes`navigator` check used for Cloudflare Workers detection. VS Code extensions run in Node.js, not Cloudflare Workers.
48+
49+
**What to look for:**
50+
Search for the`allowsEval` function that checks for Cloudflare in the user agent.
51+
52+
**Pattern to find:**
53+
```javascript
54+
if (typeofnavigator!=="undefined"&&navigator?.userAgent?.includes("Cloudflare")) {
55+
returnfalse;
56+
}
57+
```
58+
59+
**Replace with:**
60+
```javascript
61+
// PATCHED: Removed navigator check to avoid VS Code deprecation warning
62+
// We're not running in Cloudflare Workers in a VS Code extension
63+
```
64+
65+
**Files typically modified:**
66+
-`node_modules/zod/v4/core/util.js`
67+
-`node_modules/zod/v4/core/util.cjs`
68+
69+
**Tip:** Search for`allowsEval` or`Cloudflare` in the zod directory. Patch both .js and .cjs variants.
70+
71+
---
72+
73+
## openpgp
74+
75+
**Why:** Removes`navigator.hardwareConcurrency` check. Since VS Code extensions run in Node.js, we can use`os.cpus()` directly.
76+
77+
**What to look for:**
78+
Search for the`getHardwareConcurrency` function that checks for`navigator.hardwareConcurrency`.
79+
80+
**Pattern to find:**
81+
```javascript
82+
getHardwareConcurrency:function() {
83+
if (typeofnavigator!=='undefined') {
84+
returnnavigator.hardwareConcurrency||1;
85+
}
86+
constos=this.nodeRequire('os');
87+
returnos.cpus().length;
88+
}
89+
```
90+
91+
**Replace with:**
92+
```javascript
93+
getHardwareConcurrency:function() {
94+
// PATCHED: Removed navigator check to avoid VS Code deprecation warning
95+
constos=this.nodeRequire('os');
96+
returnos.cpus().length;
97+
}
98+
```
99+
100+
**Files typically modified:**
101+
-`node_modules/openpgp/dist/openpgp.js`
102+
103+
**Tip:** Search for`getHardwareConcurrency` in the openpgp directory.
104+
105+
---
106+
107+
## node-forge
108+
109+
**Why:** Removes multiple`navigator` checks used for browser detection, hardware concurrency, and entropy collection. VS Code extensions run in Node.js, so these checks are unnecessary.
110+
111+
### Patch 1: Browser detection in jsbn.js
112+
113+
**Pattern to find:**
114+
A conditional block that checks`typeof(navigator)` and sets`BigInteger.prototype.am` based on browser type (Internet Explorer, Netscape, etc.).
115+
116+
**Replace with:**
117+
```javascript
118+
// PATCHED: Removed navigator check to avoid VS Code deprecation warning
119+
BigInteger.prototype.am= am3;
120+
dbits=28;
121+
```
122+
123+
**Tip:** Search for`navigator.appName` or`BigInteger.prototype.am` in`lib/jsbn.js`.
124+
125+
---
126+
127+
### Patch 2: Entropy collection in random.js
128+
129+
**Pattern to find:**
130+
A block that iterates through`navigator` properties to collect entropy bytes.
131+
132+
```javascript
133+
if(typeof(navigator)!=='undefined') {
134+
var _navBytes='';
135+
for(var keyinnavigator) {
136+
// ... entropy collection code
137+
}
138+
}
139+
```
140+
141+
**Replace with:**
142+
```javascript
143+
// PATCHED: Removed navigator entropy collection to avoid VS Code deprecation warning
144+
```
145+
146+
**Tip:** Search for`_navBytes` or`add some entropy fromnavigator` in`lib/random.js`.
147+
148+
---
149+
150+
### Patch 3: Hardware concurrency in util.js
151+
152+
**Pattern to find:**
153+
In the`estimateCores` function, a check for`navigator.hardwareConcurrency`.
154+
155+
```javascript
156+
if(typeofnavigator!=='undefined'&&
157+
'hardwareConcurrency'innavigator&&
158+
navigator.hardwareConcurrency>0) {
159+
util.cores=navigator.hardwareConcurrency;
160+
returncallback(null,util.cores);
161+
}
162+
```
163+
164+
**Replace with:**
165+
```javascript
166+
// PATCHED: Removed navigator check to avoid VS Code deprecation warning
167+
```
168+
169+
**Tip:** Search for`estimateCores` or`hardwareConcurrency` in`lib/util.js`.
170+
171+
---
172+
173+
## Verification
174+
175+
After applying patches, verify the build succeeds and tests pass:
176+
177+
```bash
178+
yarn build
179+
yarn test:ci
180+
```
181+
182+
## Notes
183+
184+
- These patches maintain functionality while removing deprecation warnings
185+
- All patches use Node.js implementations directly, which is appropriate for VS Code extensions
186+
- The patches do not affect the security or correctness of the packages
187+
- When in doubt, search for`typeofnavigator` in the package directory to find all occurrences

‎patches/axios+1.12.2.patch‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
diff --git a/node_modules/axios/dist/esm/axios.js b/node_modules/axios/dist/esm/axios.js
2+
index 6e10897..759964e 100644
3+
--- a/node_modules/axios/dist/esm/axios.js
4+
+++ b/node_modules/axios/dist/esm/axios.js
5+
@@ -1315,7 +1315,7 @@ const platform$1 = {
6+
7+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
8+
9+
-const _navigator = typeof navigator === 'object' && navigator || undefined;
10+
+const _navigator = undefined; // PATCHED
11+
12+
/**
13+
* Determine if we're running in a standard browser environment
14+
diff --git a/node_modules/axios/dist/node/axios.cjs b/node_modules/axios/dist/node/axios.cjs
15+
index 0e8b6ac..9df7314 100644
16+
--- a/node_modules/axios/dist/node/axios.cjs
17+
+++ b/node_modules/axios/dist/node/axios.cjs
18+
@@ -1360,7 +1360,7 @@ const platform$1 = {
19+
20+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
21+
22+
-const _navigator = typeof navigator === 'object' && navigator || undefined;
23+
+const _navigator = undefined; // PATCHED
24+
25+
/**
26+
* Determine if we're running in a standard browser environment
27+
diff --git a/node_modules/axios/lib/platform/common/utils.js b/node_modules/axios/lib/platform/common/utils.js
28+
index 52a3186..6a71374 100644
29+
--- a/node_modules/axios/lib/platform/common/utils.js
30+
+++ b/node_modules/axios/lib/platform/common/utils.js
31+
@@ -1,6 +1,7 @@
32+
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
33+
34+
-const _navigator = typeof navigator === 'object' && navigator || undefined;
35+
+const _navigator = undefined; // PATCHED
36+
37+
/**
38+
* Determine if we're running in a standard browser environment

‎patches/node-forge+1.3.1.patch‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
diff --git a/node_modules/node-forge/lib/jsbn.js b/node_modules/node-forge/lib/jsbn.js
2+
index 11f965c..9e5dfdc 100644
3+
--- a/node_modules/node-forge/lib/jsbn.js
4+
+++ b/node_modules/node-forge/lib/jsbn.js
5+
@@ -116,21 +116,10 @@ function am3(i,x,w,j,c,n) {
6+
return c;
7+
}
8+
9+
-// node.js (no browser)
10+
-if(typeof(navigator) === 'undefined')
11+
-{
12+
- BigInteger.prototype.am = am3;
13+
- dbits = 28;
14+
-} else if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
15+
- BigInteger.prototype.am = am2;
16+
- dbits = 30;
17+
-} else if(j_lm && (navigator.appName != "Netscape")) {
18+
- BigInteger.prototype.am = am1;
19+
- dbits = 26;
20+
-} else { // Mozilla/Netscape seems to prefer am3
21+
- BigInteger.prototype.am = am3;
22+
- dbits = 28;
23+
-}
24+
+// PATCHED: Removed navigator check to avoid VS Code deprecation warning
25+
+// VS Code extensions run in Node.js, so use Node.js implementation directly
26+
+BigInteger.prototype.am = am3;
27+
+dbits = 28;
28+
29+
BigInteger.prototype.DB = dbits;
30+
BigInteger.prototype.DM = ((1<<dbits)-1);
31+
diff --git a/node_modules/node-forge/lib/random.js b/node_modules/node-forge/lib/random.js
32+
index d4e4bea..b0b6bb2 100644
33+
--- a/node_modules/node-forge/lib/random.js
34+
+++ b/node_modules/node-forge/lib/random.js
35+
@@ -134,26 +134,8 @@ if(forge.options.usePureJavaScript ||
36+
// get load time entropy
37+
_ctx.collectInt(+new Date(), 32);
38+
39+
- // add some entropy from navigator object
40+
- if(typeof(navigator) !== 'undefined') {
41+
- var _navBytes = '';
42+
- for(var key in navigator) {
43+
- try {
44+
- if(typeof(navigator[key]) == 'string') {
45+
- _navBytes += navigator[key];
46+
- }
47+
- } catch(e) {
48+
- /* Some navigator keys might not be accessible, e.g. the geolocation
49+
- attribute throws an exception if touched in Mozilla chrome://
50+
- context.
51+
-
52+
- Silently ignore this and just don't use this as a source of
53+
- entropy. */
54+
- }
55+
- }
56+
- _ctx.collect(_navBytes);
57+
- _navBytes = null;
58+
- }
59+
+ // PATCHED: Removed navigator entropy collection to avoid VS Code deprecation warning
60+
+ // VS Code extensions run in Node.js, not in a browser, so navigator is not available
61+
62+
// add mouse and keyboard collectors if jquery is available
63+
if(jQuery) {
64+
diff --git a/node_modules/node-forge/lib/util.js b/node_modules/node-forge/lib/util.js
65+
index aaede5a..a11ad50 100644
66+
--- a/node_modules/node-forge/lib/util.js
67+
+++ b/node_modules/node-forge/lib/util.js
68+
@@ -2555,12 +2555,8 @@ util.estimateCores = function(options, callback) {
69+
if('cores' in util && !options.update) {
70+
return callback(null, util.cores);
71+
}
72+
- if(typeof navigator !== 'undefined' &&
73+
- 'hardwareConcurrency' in navigator &&
74+
- navigator.hardwareConcurrency > 0) {
75+
- util.cores = navigator.hardwareConcurrency;
76+
- return callback(null, util.cores);
77+
- }
78+
+ // PATCHED: Removed navigator check to avoid VS Code deprecation warning
79+
+ // VS Code extensions run in Node.js, not in a browser
80+
if(typeof Worker === 'undefined') {
81+
// workers not available
82+
util.cores = 1;

‎patches/openpgp+6.2.2.patch‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/node_modules/openpgp/dist/openpgp.js b/node_modules/openpgp/dist/openpgp.js
2+
index b990fa2..1106a18 100644
3+
--- a/node_modules/openpgp/dist/openpgp.js
4+
+++ b/node_modules/openpgp/dist/openpgp.js
5+
@@ -2206,11 +2206,9 @@ var openpgp = (function (exports) {
6+
},
7+
8+
getHardwareConcurrency: function() {
9+
- if (typeof navigator !== 'undefined') {
10+
- return navigator.hardwareConcurrency || 1;
11+
- }
12+
-
13+
- const os = this.nodeRequire('os'); // Assume we're on Node.js.
14+
+ // PATCHED: Removed navigator check to avoid VS Code deprecation warning
15+
+ // VS Code extensions run in Node.js, so use os.cpus() directly
16+
+ const os = this.nodeRequire('os');
17+
return os.cpus().length;
18+
},
19+

‎patches/zod+4.1.12.patch‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/node_modules/zod/v4/core/util.cjs b/node_modules/zod/v4/core/util.cjs
2+
index 9e412dc..c0e64af 100644
3+
--- a/node_modules/zod/v4/core/util.cjs
4+
+++ b/node_modules/zod/v4/core/util.cjs
5+
@@ -195,10 +195,8 @@ function isObject(data) {
6+
return typeof data === "object" && data !== null && !Array.isArray(data);
7+
}
8+
exports.allowsEval = cached(() => {
9+
- // @ts-ignore
10+
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
11+
- return false;
12+
- }
13+
+ // PATCHED: Removed navigator check to avoid VS Code deprecation warning
14+
+ // We're not running in Cloudflare Workers in a VS Code extension
15+
try {
16+
const F = Function;
17+
new F("");
18+
diff --git a/node_modules/zod/v4/core/util.js b/node_modules/zod/v4/core/util.js
19+
index 3cf33fd..c4519fc 100644
20+
--- a/node_modules/zod/v4/core/util.js
21+
+++ b/node_modules/zod/v4/core/util.js
22+
@@ -140,10 +140,8 @@ export function isObject(data) {
23+
return typeof data === "object" && data !== null && !Array.isArray(data);
24+
}
25+
export const allowsEval = cached(() => {
26+
- // @ts-ignore
27+
- if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
28+
- return false;
29+
- }
30+
+ // PATCHED: Removed navigator check to avoid VS Code deprecation warning
31+
+ // We're not running in Cloudflare Workers in a VS Code extension
32+
try {
33+
const F = Function;
34+
new F("");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp