@maplibre/maplibre-react-native 10.0.0-alpha.8 → 10.0.0-alpha.9

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 (89) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/docs/Camera.md +1 -1
  4. package/docs/MapView.md +9 -9
  5. package/docs/MarkerView.md +1 -1
  6. package/docs/NativeUserLocation.md +1 -1
  7. package/docs/PointAnnotation.md +2 -2
  8. package/docs/UserLocation.md +2 -2
  9. package/docs/docs.json +12 -12
  10. package/javascript/@types/assets.d.ts +1 -1
  11. package/javascript/MLNModule.ts +2 -2
  12. package/javascript/Maplibre.ts +37 -42
  13. package/javascript/components/BackgroundLayer.tsx +9 -9
  14. package/javascript/components/Callout.tsx +19 -19
  15. package/javascript/components/Camera.tsx +29 -29
  16. package/javascript/components/CircleLayer.tsx +9 -9
  17. package/javascript/components/FillExtrusionLayer.tsx +9 -9
  18. package/javascript/components/FillLayer.tsx +9 -9
  19. package/javascript/components/HeadingIndicator.tsx +7 -8
  20. package/javascript/components/HeatmapLayer.tsx +10 -10
  21. package/javascript/components/ImageSource.tsx +8 -8
  22. package/javascript/components/Images.tsx +19 -20
  23. package/javascript/components/Light.tsx +15 -15
  24. package/javascript/components/LineLayer.tsx +9 -9
  25. package/javascript/components/MapView.tsx +74 -70
  26. package/javascript/components/MarkerView.tsx +9 -10
  27. package/javascript/components/NativeUserLocation.tsx +4 -4
  28. package/javascript/components/PointAnnotation.tsx +17 -17
  29. package/javascript/components/RasterLayer.tsx +9 -9
  30. package/javascript/components/RasterSource.tsx +10 -10
  31. package/javascript/components/ShapeSource.tsx +63 -61
  32. package/javascript/components/Style.tsx +69 -59
  33. package/javascript/components/SymbolLayer.tsx +10 -10
  34. package/javascript/components/UserLocation.tsx +23 -23
  35. package/javascript/components/VectorSource.tsx +19 -19
  36. package/javascript/components/annotations/Annotation.tsx +16 -15
  37. package/javascript/hooks/useAbstractLayer.ts +15 -12
  38. package/javascript/hooks/useAbstractSource.ts +2 -2
  39. package/javascript/hooks/useNativeBridge.ts +7 -7
  40. package/javascript/hooks/useNativeRef.ts +2 -2
  41. package/javascript/hooks/useOnce.ts +1 -1
  42. package/javascript/index.ts +2 -2
  43. package/javascript/modules/location/locationManager.ts +4 -4
  44. package/javascript/modules/offline/OfflineCreatePackOptions.ts +5 -5
  45. package/javascript/modules/offline/OfflinePack.ts +3 -3
  46. package/javascript/modules/offline/offlineManager.ts +11 -12
  47. package/javascript/modules/snapshot/SnapshotOptions.ts +4 -4
  48. package/javascript/modules/snapshot/snapshotManager.ts +2 -2
  49. package/javascript/requestAndroidLocationPermissions.ts +3 -3
  50. package/javascript/types/OnPressEvent.ts +1 -1
  51. package/javascript/types/index.ts +6 -2
  52. package/javascript/utils/BridgeValue.ts +20 -20
  53. package/javascript/utils/Logger.ts +14 -14
  54. package/javascript/utils/MaplibreStyles.d.ts +359 -359
  55. package/javascript/utils/StyleValue.ts +12 -12
  56. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +6 -6
  57. package/javascript/utils/animated/Animated.ts +38 -16
  58. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +7 -11
  59. package/javascript/utils/animated/AnimatedExtractCoordinateFromArray.ts +3 -3
  60. package/javascript/utils/animated/AnimatedPoint.ts +7 -7
  61. package/javascript/utils/animated/AnimatedRouteCoordinatesArray.ts +16 -20
  62. package/javascript/utils/animated/AnimatedShape.ts +15 -15
  63. package/javascript/utils/deprecation.ts +6 -3
  64. package/javascript/utils/filterUtils.ts +1 -1
  65. package/javascript/utils/geoUtils.ts +8 -8
  66. package/javascript/utils/index.ts +14 -14
  67. package/javascript/utils/styleMap.ts +18 -18
  68. package/package.json +28 -15
  69. package/plugin/build/withMapLibre.d.ts +2 -2
  70. package/plugin/build/withMapLibre.js +24 -24
  71. package/scripts/autogenerate.js +1 -1
  72. package/.eslintignore +0 -3
  73. package/.eslintrc.js +0 -169
  74. package/.prettierrc.js +0 -7
  75. package/.yarn/sdks/eslint/bin/eslint.js +0 -27
  76. package/.yarn/sdks/eslint/lib/api.js +0 -27
  77. package/.yarn/sdks/eslint/lib/unsupported-api.js +0 -27
  78. package/.yarn/sdks/eslint/package.json +0 -14
  79. package/.yarn/sdks/integrations.yml +0 -5
  80. package/.yarn/sdks/prettier/bin/prettier.cjs +0 -27
  81. package/.yarn/sdks/prettier/index.cjs +0 -27
  82. package/.yarn/sdks/prettier/package.json +0 -7
  83. package/.yarn/sdks/typescript/bin/tsc +0 -27
  84. package/.yarn/sdks/typescript/bin/tsserver +0 -27
  85. package/.yarn/sdks/typescript/lib/tsc.js +0 -27
  86. package/.yarn/sdks/typescript/lib/tsserver.js +0 -239
  87. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +0 -239
  88. package/.yarn/sdks/typescript/lib/typescript.js +0 -27
  89. package/.yarn/sdks/typescript/package.json +0 -10
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const {existsSync} = require(`fs`);
4
- const {createRequire, register} = require(`module`);
5
- const {resolve} = require(`path`);
6
- const {pathToFileURL} = require(`url`);
7
-
8
- const relPnpApiPath = "../../../../.pnp.cjs";
9
-
10
- const absPnpApiPath = resolve(__dirname, relPnpApiPath);
11
- const absRequire = createRequire(absPnpApiPath);
12
-
13
- const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
14
- const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
15
-
16
- if (existsSync(absPnpApiPath)) {
17
- if (!process.versions.pnp) {
18
- // Setup the environment to be able to require typescript/bin/tsc
19
- require(absPnpApiPath).setup();
20
- if (isPnpLoaderEnabled && register) {
21
- register(pathToFileURL(absPnpLoaderPath));
22
- }
23
- }
24
- }
25
-
26
- // Defer to the real typescript/bin/tsc your application uses
27
- module.exports = absRequire(`typescript/bin/tsc`);
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const {existsSync} = require(`fs`);
4
- const {createRequire, register} = require(`module`);
5
- const {resolve} = require(`path`);
6
- const {pathToFileURL} = require(`url`);
7
-
8
- const relPnpApiPath = "../../../../.pnp.cjs";
9
-
10
- const absPnpApiPath = resolve(__dirname, relPnpApiPath);
11
- const absRequire = createRequire(absPnpApiPath);
12
-
13
- const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
14
- const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
15
-
16
- if (existsSync(absPnpApiPath)) {
17
- if (!process.versions.pnp) {
18
- // Setup the environment to be able to require typescript/bin/tsserver
19
- require(absPnpApiPath).setup();
20
- if (isPnpLoaderEnabled && register) {
21
- register(pathToFileURL(absPnpLoaderPath));
22
- }
23
- }
24
- }
25
-
26
- // Defer to the real typescript/bin/tsserver your application uses
27
- module.exports = absRequire(`typescript/bin/tsserver`);
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const {existsSync} = require(`fs`);
4
- const {createRequire, register} = require(`module`);
5
- const {resolve} = require(`path`);
6
- const {pathToFileURL} = require(`url`);
7
-
8
- const relPnpApiPath = "../../../../.pnp.cjs";
9
-
10
- const absPnpApiPath = resolve(__dirname, relPnpApiPath);
11
- const absRequire = createRequire(absPnpApiPath);
12
-
13
- const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
14
- const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
15
-
16
- if (existsSync(absPnpApiPath)) {
17
- if (!process.versions.pnp) {
18
- // Setup the environment to be able to require typescript/lib/tsc.js
19
- require(absPnpApiPath).setup();
20
- if (isPnpLoaderEnabled && register) {
21
- register(pathToFileURL(absPnpLoaderPath));
22
- }
23
- }
24
- }
25
-
26
- // Defer to the real typescript/lib/tsc.js your application uses
27
- module.exports = absRequire(`typescript/lib/tsc.js`);
@@ -1,239 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const {existsSync} = require(`fs`);
4
- const {createRequire, register} = require(`module`);
5
- const {resolve} = require(`path`);
6
- const {pathToFileURL} = require(`url`);
7
-
8
- const relPnpApiPath = "../../../../.pnp.cjs";
9
-
10
- const absPnpApiPath = resolve(__dirname, relPnpApiPath);
11
- const absRequire = createRequire(absPnpApiPath);
12
-
13
- const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
14
- const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
15
-
16
- if (existsSync(absPnpApiPath)) {
17
- if (!process.versions.pnp) {
18
- // Setup the environment to be able to require typescript/lib/tsserver.js
19
- require(absPnpApiPath).setup();
20
- if (isPnpLoaderEnabled && register) {
21
- register(pathToFileURL(absPnpLoaderPath));
22
- }
23
- }
24
- }
25
-
26
- const moduleWrapper = tsserver => {
27
- if (!process.versions.pnp) {
28
- return tsserver;
29
- }
30
-
31
- const {isAbsolute} = require(`path`);
32
- const pnpApi = require(`pnpapi`);
33
-
34
- const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
35
- const isPortal = str => str.startsWith("portal:/");
36
- const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
37
-
38
- const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
39
- return `${locator.name}@${locator.reference}`;
40
- }));
41
-
42
- // VSCode sends the zip paths to TS using the "zip://" prefix, that TS
43
- // doesn't understand. This layer makes sure to remove the protocol
44
- // before forwarding it to TS, and to add it back on all returned paths.
45
-
46
- function toEditorPath(str) {
47
- // We add the `zip:` prefix to both `.zip/` paths and virtual paths
48
- if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
49
- // We also take the opportunity to turn virtual paths into physical ones;
50
- // this makes it much easier to work with workspaces that list peer
51
- // dependencies, since otherwise Ctrl+Click would bring us to the virtual
52
- // file instances instead of the real ones.
53
- //
54
- // We only do this to modules owned by the the dependency tree roots.
55
- // This avoids breaking the resolution when jumping inside a vendor
56
- // with peer dep (otherwise jumping into react-dom would show resolution
57
- // errors on react).
58
- //
59
- const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
60
- if (resolved) {
61
- const locator = pnpApi.findPackageLocator(resolved);
62
- if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
63
- str = resolved;
64
- }
65
- }
66
-
67
- str = normalize(str);
68
-
69
- if (str.match(/\.zip\//)) {
70
- switch (hostInfo) {
71
- // Absolute VSCode `Uri.fsPath`s need to start with a slash.
72
- // VSCode only adds it automatically for supported schemes,
73
- // so we have to do it manually for the `zip` scheme.
74
- // The path needs to start with a caret otherwise VSCode doesn't handle the protocol
75
- //
76
- // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
77
- //
78
- // 2021-10-08: VSCode changed the format in 1.61.
79
- // Before | ^zip:/c:/foo/bar.zip/package.json
80
- // After | ^/zip//c:/foo/bar.zip/package.json
81
- //
82
- // 2022-04-06: VSCode changed the format in 1.66.
83
- // Before | ^/zip//c:/foo/bar.zip/package.json
84
- // After | ^/zip/c:/foo/bar.zip/package.json
85
- //
86
- // 2022-05-06: VSCode changed the format in 1.68
87
- // Before | ^/zip/c:/foo/bar.zip/package.json
88
- // After | ^/zip//c:/foo/bar.zip/package.json
89
- //
90
- case `vscode <1.61`: {
91
- str = `^zip:${str}`;
92
- } break;
93
-
94
- case `vscode <1.66`: {
95
- str = `^/zip/${str}`;
96
- } break;
97
-
98
- case `vscode <1.68`: {
99
- str = `^/zip${str}`;
100
- } break;
101
-
102
- case `vscode`: {
103
- str = `^/zip/${str}`;
104
- } break;
105
-
106
- // To make "go to definition" work,
107
- // We have to resolve the actual file system path from virtual path
108
- // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
109
- case `coc-nvim`: {
110
- str = normalize(resolved).replace(/\.zip\//, `.zip::`);
111
- str = resolve(`zipfile:${str}`);
112
- } break;
113
-
114
- // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
115
- // We have to resolve the actual file system path from virtual path,
116
- // everything else is up to neovim
117
- case `neovim`: {
118
- str = normalize(resolved).replace(/\.zip\//, `.zip::`);
119
- str = `zipfile://${str}`;
120
- } break;
121
-
122
- default: {
123
- str = `zip:${str}`;
124
- } break;
125
- }
126
- } else {
127
- str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
128
- }
129
- }
130
-
131
- return str;
132
- }
133
-
134
- function fromEditorPath(str) {
135
- switch (hostInfo) {
136
- case `coc-nvim`: {
137
- str = str.replace(/\.zip::/, `.zip/`);
138
- // The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
139
- // So in order to convert it back, we use .* to match all the thing
140
- // before `zipfile:`
141
- return process.platform === `win32`
142
- ? str.replace(/^.*zipfile:\//, ``)
143
- : str.replace(/^.*zipfile:/, ``);
144
- } break;
145
-
146
- case `neovim`: {
147
- str = str.replace(/\.zip::/, `.zip/`);
148
- // The path for neovim is in format of zipfile:///<pwd>/.yarn/...
149
- return str.replace(/^zipfile:\/\//, ``);
150
- } break;
151
-
152
- case `vscode`:
153
- default: {
154
- return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
155
- } break;
156
- }
157
- }
158
-
159
- // Force enable 'allowLocalPluginLoads'
160
- // TypeScript tries to resolve plugins using a path relative to itself
161
- // which doesn't work when using the global cache
162
- // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
163
- // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
164
- // TypeScript already does local loads and if this code is running the user trusts the workspace
165
- // https://github.com/microsoft/vscode/issues/45856
166
- const ConfiguredProject = tsserver.server.ConfiguredProject;
167
- const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
168
- ConfiguredProject.prototype.enablePluginsWithOptions = function() {
169
- this.projectService.allowLocalPluginLoads = true;
170
- return originalEnablePluginsWithOptions.apply(this, arguments);
171
- };
172
-
173
- // And here is the point where we hijack the VSCode <-> TS communications
174
- // by adding ourselves in the middle. We locate everything that looks
175
- // like an absolute path of ours and normalize it.
176
-
177
- const Session = tsserver.server.Session;
178
- const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
179
- let hostInfo = `unknown`;
180
-
181
- Object.assign(Session.prototype, {
182
- onMessage(/** @type {string | object} */ message) {
183
- const isStringMessage = typeof message === 'string';
184
- const parsedMessage = isStringMessage ? JSON.parse(message) : message;
185
-
186
- if (
187
- parsedMessage != null &&
188
- typeof parsedMessage === `object` &&
189
- parsedMessage.arguments &&
190
- typeof parsedMessage.arguments.hostInfo === `string`
191
- ) {
192
- hostInfo = parsedMessage.arguments.hostInfo;
193
- if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
194
- const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
195
- // The RegExp from https://semver.org/ but without the caret at the start
196
- /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
197
- ) ?? []).map(Number)
198
-
199
- if (major === 1) {
200
- if (minor < 61) {
201
- hostInfo += ` <1.61`;
202
- } else if (minor < 66) {
203
- hostInfo += ` <1.66`;
204
- } else if (minor < 68) {
205
- hostInfo += ` <1.68`;
206
- }
207
- }
208
- }
209
- }
210
-
211
- const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {
212
- return typeof value === 'string' ? fromEditorPath(value) : value;
213
- });
214
-
215
- return originalOnMessage.call(
216
- this,
217
- isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON)
218
- );
219
- },
220
-
221
- send(/** @type {any} */ msg) {
222
- return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
223
- return typeof value === `string` ? toEditorPath(value) : value;
224
- })));
225
- }
226
- });
227
-
228
- return tsserver;
229
- };
230
-
231
- const [major, minor] = absRequire(`typescript/package.json`).version.split(`.`, 2).map(value => parseInt(value, 10));
232
- // In TypeScript@>=5.5 the tsserver uses the public TypeScript API so that needs to be patched as well.
233
- // Ref https://github.com/microsoft/TypeScript/pull/55326
234
- if (major > 5 || (major === 5 && minor >= 5)) {
235
- moduleWrapper(absRequire(`typescript`));
236
- }
237
-
238
- // Defer to the real typescript/lib/tsserver.js your application uses
239
- module.exports = moduleWrapper(absRequire(`typescript/lib/tsserver.js`));
@@ -1,239 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const {existsSync} = require(`fs`);
4
- const {createRequire, register} = require(`module`);
5
- const {resolve} = require(`path`);
6
- const {pathToFileURL} = require(`url`);
7
-
8
- const relPnpApiPath = "../../../../.pnp.cjs";
9
-
10
- const absPnpApiPath = resolve(__dirname, relPnpApiPath);
11
- const absRequire = createRequire(absPnpApiPath);
12
-
13
- const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
14
- const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
15
-
16
- if (existsSync(absPnpApiPath)) {
17
- if (!process.versions.pnp) {
18
- // Setup the environment to be able to require typescript/lib/tsserverlibrary.js
19
- require(absPnpApiPath).setup();
20
- if (isPnpLoaderEnabled && register) {
21
- register(pathToFileURL(absPnpLoaderPath));
22
- }
23
- }
24
- }
25
-
26
- const moduleWrapper = tsserver => {
27
- if (!process.versions.pnp) {
28
- return tsserver;
29
- }
30
-
31
- const {isAbsolute} = require(`path`);
32
- const pnpApi = require(`pnpapi`);
33
-
34
- const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
35
- const isPortal = str => str.startsWith("portal:/");
36
- const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
37
-
38
- const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
39
- return `${locator.name}@${locator.reference}`;
40
- }));
41
-
42
- // VSCode sends the zip paths to TS using the "zip://" prefix, that TS
43
- // doesn't understand. This layer makes sure to remove the protocol
44
- // before forwarding it to TS, and to add it back on all returned paths.
45
-
46
- function toEditorPath(str) {
47
- // We add the `zip:` prefix to both `.zip/` paths and virtual paths
48
- if (isAbsolute(str) && !str.match(/^\^?(zip:|\/zip\/)/) && (str.match(/\.zip\//) || isVirtual(str))) {
49
- // We also take the opportunity to turn virtual paths into physical ones;
50
- // this makes it much easier to work with workspaces that list peer
51
- // dependencies, since otherwise Ctrl+Click would bring us to the virtual
52
- // file instances instead of the real ones.
53
- //
54
- // We only do this to modules owned by the the dependency tree roots.
55
- // This avoids breaking the resolution when jumping inside a vendor
56
- // with peer dep (otherwise jumping into react-dom would show resolution
57
- // errors on react).
58
- //
59
- const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
60
- if (resolved) {
61
- const locator = pnpApi.findPackageLocator(resolved);
62
- if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
63
- str = resolved;
64
- }
65
- }
66
-
67
- str = normalize(str);
68
-
69
- if (str.match(/\.zip\//)) {
70
- switch (hostInfo) {
71
- // Absolute VSCode `Uri.fsPath`s need to start with a slash.
72
- // VSCode only adds it automatically for supported schemes,
73
- // so we have to do it manually for the `zip` scheme.
74
- // The path needs to start with a caret otherwise VSCode doesn't handle the protocol
75
- //
76
- // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
77
- //
78
- // 2021-10-08: VSCode changed the format in 1.61.
79
- // Before | ^zip:/c:/foo/bar.zip/package.json
80
- // After | ^/zip//c:/foo/bar.zip/package.json
81
- //
82
- // 2022-04-06: VSCode changed the format in 1.66.
83
- // Before | ^/zip//c:/foo/bar.zip/package.json
84
- // After | ^/zip/c:/foo/bar.zip/package.json
85
- //
86
- // 2022-05-06: VSCode changed the format in 1.68
87
- // Before | ^/zip/c:/foo/bar.zip/package.json
88
- // After | ^/zip//c:/foo/bar.zip/package.json
89
- //
90
- case `vscode <1.61`: {
91
- str = `^zip:${str}`;
92
- } break;
93
-
94
- case `vscode <1.66`: {
95
- str = `^/zip/${str}`;
96
- } break;
97
-
98
- case `vscode <1.68`: {
99
- str = `^/zip${str}`;
100
- } break;
101
-
102
- case `vscode`: {
103
- str = `^/zip/${str}`;
104
- } break;
105
-
106
- // To make "go to definition" work,
107
- // We have to resolve the actual file system path from virtual path
108
- // and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
109
- case `coc-nvim`: {
110
- str = normalize(resolved).replace(/\.zip\//, `.zip::`);
111
- str = resolve(`zipfile:${str}`);
112
- } break;
113
-
114
- // Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
115
- // We have to resolve the actual file system path from virtual path,
116
- // everything else is up to neovim
117
- case `neovim`: {
118
- str = normalize(resolved).replace(/\.zip\//, `.zip::`);
119
- str = `zipfile://${str}`;
120
- } break;
121
-
122
- default: {
123
- str = `zip:${str}`;
124
- } break;
125
- }
126
- } else {
127
- str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
128
- }
129
- }
130
-
131
- return str;
132
- }
133
-
134
- function fromEditorPath(str) {
135
- switch (hostInfo) {
136
- case `coc-nvim`: {
137
- str = str.replace(/\.zip::/, `.zip/`);
138
- // The path for coc-nvim is in format of /<pwd>/zipfile:/<pwd>/.yarn/...
139
- // So in order to convert it back, we use .* to match all the thing
140
- // before `zipfile:`
141
- return process.platform === `win32`
142
- ? str.replace(/^.*zipfile:\//, ``)
143
- : str.replace(/^.*zipfile:/, ``);
144
- } break;
145
-
146
- case `neovim`: {
147
- str = str.replace(/\.zip::/, `.zip/`);
148
- // The path for neovim is in format of zipfile:///<pwd>/.yarn/...
149
- return str.replace(/^zipfile:\/\//, ``);
150
- } break;
151
-
152
- case `vscode`:
153
- default: {
154
- return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
155
- } break;
156
- }
157
- }
158
-
159
- // Force enable 'allowLocalPluginLoads'
160
- // TypeScript tries to resolve plugins using a path relative to itself
161
- // which doesn't work when using the global cache
162
- // https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
163
- // VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
164
- // TypeScript already does local loads and if this code is running the user trusts the workspace
165
- // https://github.com/microsoft/vscode/issues/45856
166
- const ConfiguredProject = tsserver.server.ConfiguredProject;
167
- const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
168
- ConfiguredProject.prototype.enablePluginsWithOptions = function() {
169
- this.projectService.allowLocalPluginLoads = true;
170
- return originalEnablePluginsWithOptions.apply(this, arguments);
171
- };
172
-
173
- // And here is the point where we hijack the VSCode <-> TS communications
174
- // by adding ourselves in the middle. We locate everything that looks
175
- // like an absolute path of ours and normalize it.
176
-
177
- const Session = tsserver.server.Session;
178
- const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
179
- let hostInfo = `unknown`;
180
-
181
- Object.assign(Session.prototype, {
182
- onMessage(/** @type {string | object} */ message) {
183
- const isStringMessage = typeof message === 'string';
184
- const parsedMessage = isStringMessage ? JSON.parse(message) : message;
185
-
186
- if (
187
- parsedMessage != null &&
188
- typeof parsedMessage === `object` &&
189
- parsedMessage.arguments &&
190
- typeof parsedMessage.arguments.hostInfo === `string`
191
- ) {
192
- hostInfo = parsedMessage.arguments.hostInfo;
193
- if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
194
- const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
195
- // The RegExp from https://semver.org/ but without the caret at the start
196
- /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
197
- ) ?? []).map(Number)
198
-
199
- if (major === 1) {
200
- if (minor < 61) {
201
- hostInfo += ` <1.61`;
202
- } else if (minor < 66) {
203
- hostInfo += ` <1.66`;
204
- } else if (minor < 68) {
205
- hostInfo += ` <1.68`;
206
- }
207
- }
208
- }
209
- }
210
-
211
- const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {
212
- return typeof value === 'string' ? fromEditorPath(value) : value;
213
- });
214
-
215
- return originalOnMessage.call(
216
- this,
217
- isStringMessage ? processedMessageJSON : JSON.parse(processedMessageJSON)
218
- );
219
- },
220
-
221
- send(/** @type {any} */ msg) {
222
- return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
223
- return typeof value === `string` ? toEditorPath(value) : value;
224
- })));
225
- }
226
- });
227
-
228
- return tsserver;
229
- };
230
-
231
- const [major, minor] = absRequire(`typescript/package.json`).version.split(`.`, 2).map(value => parseInt(value, 10));
232
- // In TypeScript@>=5.5 the tsserver uses the public TypeScript API so that needs to be patched as well.
233
- // Ref https://github.com/microsoft/TypeScript/pull/55326
234
- if (major > 5 || (major === 5 && minor >= 5)) {
235
- moduleWrapper(absRequire(`typescript`));
236
- }
237
-
238
- // Defer to the real typescript/lib/tsserverlibrary.js your application uses
239
- module.exports = moduleWrapper(absRequire(`typescript/lib/tsserverlibrary.js`));
@@ -1,27 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const {existsSync} = require(`fs`);
4
- const {createRequire, register} = require(`module`);
5
- const {resolve} = require(`path`);
6
- const {pathToFileURL} = require(`url`);
7
-
8
- const relPnpApiPath = "../../../../.pnp.cjs";
9
-
10
- const absPnpApiPath = resolve(__dirname, relPnpApiPath);
11
- const absRequire = createRequire(absPnpApiPath);
12
-
13
- const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`);
14
- const isPnpLoaderEnabled = existsSync(absPnpLoaderPath);
15
-
16
- if (existsSync(absPnpApiPath)) {
17
- if (!process.versions.pnp) {
18
- // Setup the environment to be able to require typescript
19
- require(absPnpApiPath).setup();
20
- if (isPnpLoaderEnabled && register) {
21
- register(pathToFileURL(absPnpLoaderPath));
22
- }
23
- }
24
- }
25
-
26
- // Defer to the real typescript your application uses
27
- module.exports = absRequire(`typescript`);
@@ -1,10 +0,0 @@
1
- {
2
- "name": "typescript",
3
- "version": "5.3.3-sdk",
4
- "main": "./lib/typescript.js",
5
- "type": "commonjs",
6
- "bin": {
7
- "tsc": "./bin/tsc",
8
- "tsserver": "./bin/tsserver"
9
- }
10
- }