UNPKG

2.77 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.VirtualResolver = void 0;
4class VirtualResolver {
5 static isVirtualDescriptor(descriptor) {
6 if (!descriptor.range.startsWith(VirtualResolver.protocol))
7 return false;
8 return true;
9 }
10 static isVirtualLocator(locator) {
11 if (!locator.reference.startsWith(VirtualResolver.protocol))
12 return false;
13 return true;
14 }
15 supportsDescriptor(descriptor, opts) {
16 return VirtualResolver.isVirtualDescriptor(descriptor);
17 }
18 supportsLocator(locator, opts) {
19 return VirtualResolver.isVirtualLocator(locator);
20 }
21 shouldPersistResolution(locator, opts) {
22 return false;
23 }
24 bindDescriptor(descriptor, locator, opts) {
25 // It's unsupported because packages inside the dependency tree should
26 // only become virtual AFTER they have all been resolved, by which point
27 // you shouldn't need to call `bindDescriptor` anymore.
28 throw new Error(`Assertion failed: calling "bindDescriptor" on a virtual descriptor is unsupported`);
29 }
30 getResolutionDependencies(descriptor, opts) {
31 // It's unsupported because packages inside the dependency tree should
32 // only become virtual AFTER they have all been resolved, by which point
33 // you shouldn't need to call `bindDescriptor` anymore.
34 throw new Error(`Assertion failed: calling "getResolutionDependencies" on a virtual descriptor is unsupported`);
35 }
36 async getCandidates(descriptor, dependencies, opts) {
37 // It's unsupported because packages inside the dependency tree should
38 // only become virtual AFTER they have all been resolved, by which point
39 // you shouldn't need to call `getCandidates` anymore.
40 throw new Error(`Assertion failed: calling "getCandidates" on a virtual descriptor is unsupported`);
41 }
42 async getSatisfying(descriptor, candidates, opts) {
43 // It's unsupported because packages inside the dependency tree should
44 // only become virtual AFTER they have all been resolved, by which point
45 // you shouldn't need to call `getSatisfying` anymore.
46 throw new Error(`Assertion failed: calling "getSatisfying" on a virtual descriptor is unsupported`);
47 }
48 async resolve(locator, opts) {
49 // It's unsupported because packages inside the dependency tree should
50 // only become virtual AFTER they have all been resolved, by which point
51 // you shouldn't need to call `resolve` anymore.
52 throw new Error(`Assertion failed: calling "resolve" on a virtual locator is unsupported`);
53 }
54}
55exports.VirtualResolver = VirtualResolver;
56VirtualResolver.protocol = `virtual:`;