@tsc-rs/typescript 0.0.0-placeholder → 0.8.0
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/LICENSE +21 -0
- package/NOTICE.txt +599 -0
- package/README.md +111 -0
- package/bin/tsc +2 -0
- package/dist/api/async/api.d.ts +1041 -0
- package/dist/api/async/api.d.ts.map +1 -0
- package/dist/api/async/api.js +3143 -0
- package/dist/api/async/api.js.map +1 -0
- package/dist/api/async/client.d.ts +52 -0
- package/dist/api/async/client.d.ts.map +1 -0
- package/dist/api/async/client.js +365 -0
- package/dist/api/async/client.js.map +1 -0
- package/dist/api/async/types.d.ts +375 -0
- package/dist/api/async/types.d.ts.map +1 -0
- package/dist/api/async/types.js +2 -0
- package/dist/api/async/types.js.map +1 -0
- package/dist/api/compilerOptions.generated.d.ts +123 -0
- package/dist/api/compilerOptions.generated.d.ts.map +1 -0
- package/dist/api/compilerOptions.generated.js +8 -0
- package/dist/api/compilerOptions.generated.js.map +1 -0
- package/dist/api/diagnosticFormatter.d.ts +9 -0
- package/dist/api/diagnosticFormatter.d.ts.map +1 -0
- package/dist/api/diagnosticFormatter.js +169 -0
- package/dist/api/diagnosticFormatter.js.map +1 -0
- package/dist/api/fs.d.ts +78 -0
- package/dist/api/fs.d.ts.map +1 -0
- package/dist/api/fs.js +70 -0
- package/dist/api/fs.js.map +1 -0
- package/dist/api/fsCallbacks.d.ts +27 -0
- package/dist/api/fsCallbacks.d.ts.map +1 -0
- package/dist/api/fsCallbacks.js +111 -0
- package/dist/api/fsCallbacks.js.map +1 -0
- package/dist/api/node/encoder.d.ts +18 -0
- package/dist/api/node/encoder.d.ts.map +1 -0
- package/dist/api/node/encoder.generated.d.ts +5 -0
- package/dist/api/node/encoder.generated.d.ts.map +1 -0
- package/dist/api/node/encoder.generated.js +74 -0
- package/dist/api/node/encoder.generated.js.map +1 -0
- package/dist/api/node/encoder.js +292 -0
- package/dist/api/node/encoder.js.map +1 -0
- package/dist/api/node/msgpack.d.ts +32 -0
- package/dist/api/node/msgpack.d.ts.map +1 -0
- package/dist/api/node/msgpack.js +212 -0
- package/dist/api/node/msgpack.js.map +1 -0
- package/dist/api/node/node.d.ts +102 -0
- package/dist/api/node/node.d.ts.map +1 -0
- package/dist/api/node/node.generated.d.ts +189 -0
- package/dist/api/node/node.generated.d.ts.map +1 -0
- package/dist/api/node/node.generated.js +884 -0
- package/dist/api/node/node.generated.js.map +1 -0
- package/dist/api/node/node.infrastructure.d.ts +64 -0
- package/dist/api/node/node.infrastructure.d.ts.map +1 -0
- package/dist/api/node/node.infrastructure.js +102 -0
- package/dist/api/node/node.infrastructure.js.map +1 -0
- package/dist/api/node/node.js +454 -0
- package/dist/api/node/node.js.map +1 -0
- package/dist/api/node/protocol.d.ts +32 -0
- package/dist/api/node/protocol.d.ts.map +1 -0
- package/dist/api/node/protocol.generated.d.ts +4 -0
- package/dist/api/node/protocol.generated.d.ts.map +1 -0
- package/dist/api/node/protocol.generated.js +241 -0
- package/dist/api/node/protocol.generated.js.map +1 -0
- package/dist/api/node/protocol.js +33 -0
- package/dist/api/node/protocol.js.map +1 -0
- package/dist/api/node/wtf8.d.ts +10 -0
- package/dist/api/node/wtf8.d.ts.map +1 -0
- package/dist/api/node/wtf8.js +130 -0
- package/dist/api/node/wtf8.js.map +1 -0
- package/dist/api/options.d.ts +41 -0
- package/dist/api/options.d.ts.map +1 -0
- package/dist/api/options.js +32 -0
- package/dist/api/options.js.map +1 -0
- package/dist/api/path.d.ts +149 -0
- package/dist/api/path.d.ts.map +1 -0
- package/dist/api/path.js +884 -0
- package/dist/api/path.js.map +1 -0
- package/dist/api/prepareCompilerOptions.generated.d.ts +5 -0
- package/dist/api/prepareCompilerOptions.generated.d.ts.map +1 -0
- package/dist/api/prepareCompilerOptions.generated.js +24 -0
- package/dist/api/prepareCompilerOptions.generated.js.map +1 -0
- package/dist/api/proto.d.ts +95 -0
- package/dist/api/proto.d.ts.map +1 -0
- package/dist/api/proto.generated.d.ts +1423 -0
- package/dist/api/proto.generated.d.ts.map +1 -0
- package/dist/api/proto.generated.js +21 -0
- package/dist/api/proto.generated.js.map +1 -0
- package/dist/api/proto.js +65 -0
- package/dist/api/proto.js.map +1 -0
- package/dist/api/sourceFileCache.d.ts +110 -0
- package/dist/api/sourceFileCache.d.ts.map +1 -0
- package/dist/api/sourceFileCache.js +300 -0
- package/dist/api/sourceFileCache.js.map +1 -0
- package/dist/api/sync/api.d.ts +1729 -0
- package/dist/api/sync/api.d.ts.map +1 -0
- package/dist/api/sync/api.js +5484 -0
- package/dist/api/sync/api.js.map +1 -0
- package/dist/api/sync/client.d.ts +34 -0
- package/dist/api/sync/client.d.ts.map +1 -0
- package/dist/api/sync/client.js +148 -0
- package/dist/api/sync/client.js.map +1 -0
- package/dist/api/sync/generatorSupport.d.ts +32 -0
- package/dist/api/sync/generatorSupport.d.ts.map +1 -0
- package/dist/api/sync/generatorSupport.js +323 -0
- package/dist/api/sync/generatorSupport.js.map +1 -0
- package/dist/api/sync/types.d.ts +502 -0
- package/dist/api/sync/types.d.ts.map +1 -0
- package/dist/api/sync/types.js +2 -0
- package/dist/api/sync/types.js.map +1 -0
- package/dist/api/syncChannel.d.ts +115 -0
- package/dist/api/syncChannel.d.ts.map +1 -0
- package/dist/api/syncChannel.js +511 -0
- package/dist/api/syncChannel.js.map +1 -0
- package/dist/api/timing.d.ts +175 -0
- package/dist/api/timing.d.ts.map +1 -0
- package/dist/api/timing.js +149 -0
- package/dist/api/timing.js.map +1 -0
- package/dist/api/typedPaths.d.ts +3 -0
- package/dist/api/typedPaths.d.ts.map +1 -0
- package/dist/api/typedPaths.js +2 -0
- package/dist/api/typedPaths.js.map +1 -0
- package/dist/api/userPreferences.generated.d.ts +195 -0
- package/dist/api/userPreferences.generated.d.ts.map +1 -0
- package/dist/api/userPreferences.generated.js +3 -0
- package/dist/api/userPreferences.generated.js.map +1 -0
- package/dist/ast/ast.d.ts +186 -0
- package/dist/ast/ast.d.ts.map +1 -0
- package/dist/ast/ast.generated.d.ts +1167 -0
- package/dist/ast/ast.generated.d.ts.map +1 -0
- package/dist/ast/ast.generated.js +4 -0
- package/dist/ast/ast.generated.js.map +1 -0
- package/dist/ast/ast.js +7 -0
- package/dist/ast/ast.js.map +1 -0
- package/dist/ast/astnav.d.ts +22 -0
- package/dist/ast/astnav.d.ts.map +1 -0
- package/dist/ast/astnav.js +741 -0
- package/dist/ast/astnav.js.map +1 -0
- package/dist/ast/clone.d.ts +16 -0
- package/dist/ast/clone.d.ts.map +1 -0
- package/dist/ast/clone.js +104 -0
- package/dist/ast/clone.js.map +1 -0
- package/dist/ast/factory.generated.d.ts +533 -0
- package/dist/ast/factory.generated.d.ts.map +1 -0
- package/dist/ast/factory.generated.js +5750 -0
- package/dist/ast/factory.generated.js.map +1 -0
- package/dist/ast/index.d.ts +25 -0
- package/dist/ast/index.d.ts.map +1 -0
- package/dist/ast/index.js +25 -0
- package/dist/ast/index.js.map +1 -0
- package/dist/ast/is.d.ts +36 -0
- package/dist/ast/is.d.ts.map +1 -0
- package/dist/ast/is.generated.d.ts +1217 -0
- package/dist/ast/is.generated.d.ts.map +1 -0
- package/dist/ast/is.generated.js +1400 -0
- package/dist/ast/is.generated.js.map +1 -0
- package/dist/ast/is.js +456 -0
- package/dist/ast/is.js.map +1 -0
- package/dist/ast/jsdoc.d.ts +12 -0
- package/dist/ast/jsdoc.d.ts.map +1 -0
- package/dist/ast/jsdoc.js +208 -0
- package/dist/ast/jsdoc.js.map +1 -0
- package/dist/ast/modifiers.d.ts +4 -0
- package/dist/ast/modifiers.d.ts.map +1 -0
- package/dist/ast/modifiers.js +41 -0
- package/dist/ast/modifiers.js.map +1 -0
- package/dist/ast/scanner.d.ts +97 -0
- package/dist/ast/scanner.d.ts.map +1 -0
- package/dist/ast/scanner.js +2231 -0
- package/dist/ast/scanner.js.map +1 -0
- package/dist/ast/spanMap.d.ts +88 -0
- package/dist/ast/spanMap.d.ts.map +1 -0
- package/dist/ast/spanMap.js +417 -0
- package/dist/ast/spanMap.js.map +1 -0
- package/dist/ast/utils.d.ts +30 -0
- package/dist/ast/utils.d.ts.map +1 -0
- package/dist/ast/utils.js +318 -0
- package/dist/ast/utils.js.map +1 -0
- package/dist/ast/visitor.d.ts +16 -0
- package/dist/ast/visitor.d.ts.map +1 -0
- package/dist/ast/visitor.generated.d.ts +50 -0
- package/dist/ast/visitor.generated.d.ts.map +1 -0
- package/dist/ast/visitor.generated.js +979 -0
- package/dist/ast/visitor.generated.js.map +1 -0
- package/dist/ast/visitor.js +87 -0
- package/dist/ast/visitor.js.map +1 -0
- package/dist/enums/caseSensitivity.d.ts +2 -0
- package/dist/enums/caseSensitivity.d.ts.map +1 -0
- package/dist/enums/caseSensitivity.enum.d.ts +5 -0
- package/dist/enums/caseSensitivity.enum.d.ts.map +1 -0
- package/dist/enums/caseSensitivity.enum.js +7 -0
- package/dist/enums/caseSensitivity.enum.js.map +1 -0
- package/dist/enums/caseSensitivity.js +7 -0
- package/dist/enums/caseSensitivity.js.map +1 -0
- package/dist/enums/characterCodes.d.ts +2 -0
- package/dist/enums/characterCodes.d.ts.map +1 -0
- package/dist/enums/characterCodes.enum.d.ts +129 -0
- package/dist/enums/characterCodes.enum.d.ts.map +1 -0
- package/dist/enums/characterCodes.enum.js +132 -0
- package/dist/enums/characterCodes.enum.js.map +1 -0
- package/dist/enums/characterCodes.js +130 -0
- package/dist/enums/characterCodes.js.map +1 -0
- package/dist/enums/checkFlags.d.ts +2 -0
- package/dist/enums/checkFlags.d.ts.map +1 -0
- package/dist/enums/checkFlags.enum.d.ts +34 -0
- package/dist/enums/checkFlags.enum.d.ts.map +1 -0
- package/dist/enums/checkFlags.enum.js +36 -0
- package/dist/enums/checkFlags.enum.js.map +1 -0
- package/dist/enums/checkFlags.js +36 -0
- package/dist/enums/checkFlags.js.map +1 -0
- package/dist/enums/commentDirectiveType.d.ts +2 -0
- package/dist/enums/commentDirectiveType.d.ts.map +1 -0
- package/dist/enums/commentDirectiveType.enum.d.ts +5 -0
- package/dist/enums/commentDirectiveType.enum.d.ts.map +1 -0
- package/dist/enums/commentDirectiveType.enum.js +6 -0
- package/dist/enums/commentDirectiveType.enum.js.map +1 -0
- package/dist/enums/commentDirectiveType.js +6 -0
- package/dist/enums/commentDirectiveType.js.map +1 -0
- package/dist/enums/completionItemKind.d.ts +2 -0
- package/dist/enums/completionItemKind.d.ts.map +1 -0
- package/dist/enums/completionItemKind.enum.d.ts +28 -0
- package/dist/enums/completionItemKind.enum.d.ts.map +1 -0
- package/dist/enums/completionItemKind.enum.js +30 -0
- package/dist/enums/completionItemKind.enum.js.map +1 -0
- package/dist/enums/completionItemKind.js +30 -0
- package/dist/enums/completionItemKind.js.map +1 -0
- package/dist/enums/diagnosticCategory.d.ts +2 -0
- package/dist/enums/diagnosticCategory.d.ts.map +1 -0
- package/dist/enums/diagnosticCategory.enum.d.ts +7 -0
- package/dist/enums/diagnosticCategory.enum.d.ts.map +1 -0
- package/dist/enums/diagnosticCategory.enum.js +9 -0
- package/dist/enums/diagnosticCategory.enum.js.map +1 -0
- package/dist/enums/diagnosticCategory.js +9 -0
- package/dist/enums/diagnosticCategory.js.map +1 -0
- package/dist/enums/diagnosticDirectivePolicy.d.ts +2 -0
- package/dist/enums/diagnosticDirectivePolicy.d.ts.map +1 -0
- package/dist/enums/diagnosticDirectivePolicy.enum.d.ts +5 -0
- package/dist/enums/diagnosticDirectivePolicy.enum.d.ts.map +1 -0
- package/dist/enums/diagnosticDirectivePolicy.enum.js +7 -0
- package/dist/enums/diagnosticDirectivePolicy.enum.js.map +1 -0
- package/dist/enums/diagnosticDirectivePolicy.js +7 -0
- package/dist/enums/diagnosticDirectivePolicy.js.map +1 -0
- package/dist/enums/elementFlags.d.ts +2 -0
- package/dist/enums/elementFlags.d.ts.map +1 -0
- package/dist/enums/elementFlags.enum.d.ts +12 -0
- package/dist/enums/elementFlags.enum.d.ts.map +1 -0
- package/dist/enums/elementFlags.enum.js +14 -0
- package/dist/enums/elementFlags.enum.js.map +1 -0
- package/dist/enums/elementFlags.js +14 -0
- package/dist/enums/elementFlags.js.map +1 -0
- package/dist/enums/emitOnly.d.ts +2 -0
- package/dist/enums/emitOnly.d.ts.map +1 -0
- package/dist/enums/emitOnly.enum.d.ts +6 -0
- package/dist/enums/emitOnly.enum.d.ts.map +1 -0
- package/dist/enums/emitOnly.enum.js +8 -0
- package/dist/enums/emitOnly.enum.js.map +1 -0
- package/dist/enums/emitOnly.js +8 -0
- package/dist/enums/emitOnly.js.map +1 -0
- package/dist/enums/indexKind.d.ts +2 -0
- package/dist/enums/indexKind.d.ts.map +1 -0
- package/dist/enums/indexKind.enum.d.ts +5 -0
- package/dist/enums/indexKind.enum.d.ts.map +1 -0
- package/dist/enums/indexKind.enum.js +7 -0
- package/dist/enums/indexKind.enum.js.map +1 -0
- package/dist/enums/indexKind.js +7 -0
- package/dist/enums/indexKind.js.map +1 -0
- package/dist/enums/internalSymbolName.d.ts +2 -0
- package/dist/enums/internalSymbolName.d.ts.map +1 -0
- package/dist/enums/internalSymbolName.enum.d.ts +23 -0
- package/dist/enums/internalSymbolName.enum.d.ts.map +1 -0
- package/dist/enums/internalSymbolName.enum.js +25 -0
- package/dist/enums/internalSymbolName.enum.js.map +1 -0
- package/dist/enums/internalSymbolName.js +25 -0
- package/dist/enums/internalSymbolName.js.map +1 -0
- package/dist/enums/jsDeclarationKind.d.ts +2 -0
- package/dist/enums/jsDeclarationKind.d.ts.map +1 -0
- package/dist/enums/jsDeclarationKind.enum.d.ts +10 -0
- package/dist/enums/jsDeclarationKind.enum.d.ts.map +1 -0
- package/dist/enums/jsDeclarationKind.enum.js +12 -0
- package/dist/enums/jsDeclarationKind.enum.js.map +1 -0
- package/dist/enums/jsDeclarationKind.js +12 -0
- package/dist/enums/jsDeclarationKind.js.map +1 -0
- package/dist/enums/jsxEmit.d.ts +2 -0
- package/dist/enums/jsxEmit.d.ts.map +1 -0
- package/dist/enums/jsxEmit.enum.d.ts +9 -0
- package/dist/enums/jsxEmit.enum.d.ts.map +1 -0
- package/dist/enums/jsxEmit.enum.js +11 -0
- package/dist/enums/jsxEmit.enum.js.map +1 -0
- package/dist/enums/jsxEmit.js +11 -0
- package/dist/enums/jsxEmit.js.map +1 -0
- package/dist/enums/languageVariant.d.ts +2 -0
- package/dist/enums/languageVariant.d.ts.map +1 -0
- package/dist/enums/languageVariant.enum.d.ts +5 -0
- package/dist/enums/languageVariant.enum.d.ts.map +1 -0
- package/dist/enums/languageVariant.enum.js +6 -0
- package/dist/enums/languageVariant.enum.js.map +1 -0
- package/dist/enums/languageVariant.js +6 -0
- package/dist/enums/languageVariant.js.map +1 -0
- package/dist/enums/modifierFlags.d.ts +2 -0
- package/dist/enums/modifierFlags.d.ts.map +1 -0
- package/dist/enums/modifierFlags.enum.d.ts +42 -0
- package/dist/enums/modifierFlags.enum.d.ts.map +1 -0
- package/dist/enums/modifierFlags.enum.js +44 -0
- package/dist/enums/modifierFlags.enum.js.map +1 -0
- package/dist/enums/modifierFlags.js +44 -0
- package/dist/enums/modifierFlags.js.map +1 -0
- package/dist/enums/moduleDetectionKind.d.ts +2 -0
- package/dist/enums/moduleDetectionKind.d.ts.map +1 -0
- package/dist/enums/moduleDetectionKind.enum.d.ts +7 -0
- package/dist/enums/moduleDetectionKind.enum.d.ts.map +1 -0
- package/dist/enums/moduleDetectionKind.enum.js +9 -0
- package/dist/enums/moduleDetectionKind.enum.js.map +1 -0
- package/dist/enums/moduleDetectionKind.js +9 -0
- package/dist/enums/moduleDetectionKind.js.map +1 -0
- package/dist/enums/moduleKind.d.ts +2 -0
- package/dist/enums/moduleKind.d.ts.map +1 -0
- package/dist/enums/moduleKind.enum.d.ts +17 -0
- package/dist/enums/moduleKind.enum.d.ts.map +1 -0
- package/dist/enums/moduleKind.enum.js +19 -0
- package/dist/enums/moduleKind.enum.js.map +1 -0
- package/dist/enums/moduleKind.js +19 -0
- package/dist/enums/moduleKind.js.map +1 -0
- package/dist/enums/moduleResolutionKind.d.ts +2 -0
- package/dist/enums/moduleResolutionKind.d.ts.map +1 -0
- package/dist/enums/moduleResolutionKind.enum.d.ts +9 -0
- package/dist/enums/moduleResolutionKind.enum.d.ts.map +1 -0
- package/dist/enums/moduleResolutionKind.enum.js +11 -0
- package/dist/enums/moduleResolutionKind.enum.js.map +1 -0
- package/dist/enums/moduleResolutionKind.js +11 -0
- package/dist/enums/moduleResolutionKind.js.map +1 -0
- package/dist/enums/newLineKind.d.ts +2 -0
- package/dist/enums/newLineKind.d.ts.map +1 -0
- package/dist/enums/newLineKind.enum.d.ts +6 -0
- package/dist/enums/newLineKind.enum.d.ts.map +1 -0
- package/dist/enums/newLineKind.enum.js +8 -0
- package/dist/enums/newLineKind.enum.js.map +1 -0
- package/dist/enums/newLineKind.js +8 -0
- package/dist/enums/newLineKind.js.map +1 -0
- package/dist/enums/nodeBuilderFlags.d.ts +2 -0
- package/dist/enums/nodeBuilderFlags.d.ts.map +1 -0
- package/dist/enums/nodeBuilderFlags.enum.d.ts +36 -0
- package/dist/enums/nodeBuilderFlags.enum.d.ts.map +1 -0
- package/dist/enums/nodeBuilderFlags.enum.js +38 -0
- package/dist/enums/nodeBuilderFlags.enum.js.map +1 -0
- package/dist/enums/nodeBuilderFlags.js +38 -0
- package/dist/enums/nodeBuilderFlags.js.map +1 -0
- package/dist/enums/nodeFlags.d.ts +2 -0
- package/dist/enums/nodeFlags.d.ts.map +1 -0
- package/dist/enums/nodeFlags.enum.d.ts +44 -0
- package/dist/enums/nodeFlags.enum.d.ts.map +1 -0
- package/dist/enums/nodeFlags.enum.js +46 -0
- package/dist/enums/nodeFlags.enum.js.map +1 -0
- package/dist/enums/nodeFlags.js +46 -0
- package/dist/enums/nodeFlags.js.map +1 -0
- package/dist/enums/objectFlags.d.ts +2 -0
- package/dist/enums/objectFlags.d.ts.map +1 -0
- package/dist/enums/objectFlags.enum.d.ts +51 -0
- package/dist/enums/objectFlags.enum.d.ts.map +1 -0
- package/dist/enums/objectFlags.enum.js +53 -0
- package/dist/enums/objectFlags.enum.js.map +1 -0
- package/dist/enums/objectFlags.js +53 -0
- package/dist/enums/objectFlags.js.map +1 -0
- package/dist/enums/outerExpressionKinds.d.ts +2 -0
- package/dist/enums/outerExpressionKinds.d.ts.map +1 -0
- package/dist/enums/outerExpressionKinds.enum.d.ts +16 -0
- package/dist/enums/outerExpressionKinds.enum.d.ts.map +1 -0
- package/dist/enums/outerExpressionKinds.enum.js +18 -0
- package/dist/enums/outerExpressionKinds.enum.js.map +1 -0
- package/dist/enums/outerExpressionKinds.js +18 -0
- package/dist/enums/outerExpressionKinds.js.map +1 -0
- package/dist/enums/regularExpressionFlags.d.ts +2 -0
- package/dist/enums/regularExpressionFlags.d.ts.map +1 -0
- package/dist/enums/regularExpressionFlags.enum.d.ts +13 -0
- package/dist/enums/regularExpressionFlags.enum.d.ts.map +1 -0
- package/dist/enums/regularExpressionFlags.enum.js +14 -0
- package/dist/enums/regularExpressionFlags.enum.js.map +1 -0
- package/dist/enums/regularExpressionFlags.js +14 -0
- package/dist/enums/regularExpressionFlags.js.map +1 -0
- package/dist/enums/scriptKind.d.ts +2 -0
- package/dist/enums/scriptKind.d.ts.map +1 -0
- package/dist/enums/scriptKind.enum.d.ts +9 -0
- package/dist/enums/scriptKind.enum.d.ts.map +1 -0
- package/dist/enums/scriptKind.enum.js +11 -0
- package/dist/enums/scriptKind.enum.js.map +1 -0
- package/dist/enums/scriptKind.js +11 -0
- package/dist/enums/scriptKind.js.map +1 -0
- package/dist/enums/scriptTarget.d.ts +2 -0
- package/dist/enums/scriptTarget.d.ts.map +1 -0
- package/dist/enums/scriptTarget.enum.d.ts +18 -0
- package/dist/enums/scriptTarget.enum.d.ts.map +1 -0
- package/dist/enums/scriptTarget.enum.js +20 -0
- package/dist/enums/scriptTarget.enum.js.map +1 -0
- package/dist/enums/scriptTarget.js +20 -0
- package/dist/enums/scriptTarget.js.map +1 -0
- package/dist/enums/signatureFlags.d.ts +2 -0
- package/dist/enums/signatureFlags.d.ts.map +1 -0
- package/dist/enums/signatureFlags.enum.d.ts +15 -0
- package/dist/enums/signatureFlags.enum.d.ts.map +1 -0
- package/dist/enums/signatureFlags.enum.js +17 -0
- package/dist/enums/signatureFlags.enum.js.map +1 -0
- package/dist/enums/signatureFlags.js +17 -0
- package/dist/enums/signatureFlags.js.map +1 -0
- package/dist/enums/signatureKind.d.ts +2 -0
- package/dist/enums/signatureKind.d.ts.map +1 -0
- package/dist/enums/signatureKind.enum.d.ts +5 -0
- package/dist/enums/signatureKind.enum.d.ts.map +1 -0
- package/dist/enums/signatureKind.enum.js +7 -0
- package/dist/enums/signatureKind.enum.js.map +1 -0
- package/dist/enums/signatureKind.js +7 -0
- package/dist/enums/signatureKind.js.map +1 -0
- package/dist/enums/spanMapFeature.d.ts +2 -0
- package/dist/enums/spanMapFeature.d.ts.map +1 -0
- package/dist/enums/spanMapFeature.enum.d.ts +25 -0
- package/dist/enums/spanMapFeature.enum.d.ts.map +1 -0
- package/dist/enums/spanMapFeature.enum.js +27 -0
- package/dist/enums/spanMapFeature.enum.js.map +1 -0
- package/dist/enums/spanMapFeature.js +27 -0
- package/dist/enums/spanMapFeature.js.map +1 -0
- package/dist/enums/spanMapFidelity.d.ts +2 -0
- package/dist/enums/spanMapFidelity.d.ts.map +1 -0
- package/dist/enums/spanMapFidelity.enum.d.ts +7 -0
- package/dist/enums/spanMapFidelity.enum.d.ts.map +1 -0
- package/dist/enums/spanMapFidelity.enum.js +9 -0
- package/dist/enums/spanMapFidelity.enum.js.map +1 -0
- package/dist/enums/spanMapFidelity.js +9 -0
- package/dist/enums/spanMapFidelity.js.map +1 -0
- package/dist/enums/spanMapKind.d.ts +2 -0
- package/dist/enums/spanMapKind.d.ts.map +1 -0
- package/dist/enums/spanMapKind.enum.d.ts +6 -0
- package/dist/enums/spanMapKind.enum.d.ts.map +1 -0
- package/dist/enums/spanMapKind.enum.js +8 -0
- package/dist/enums/spanMapKind.enum.js.map +1 -0
- package/dist/enums/spanMapKind.js +8 -0
- package/dist/enums/spanMapKind.js.map +1 -0
- package/dist/enums/symbolFlags.d.ts +2 -0
- package/dist/enums/symbolFlags.d.ts.map +1 -0
- package/dist/enums/symbolFlags.enum.d.ts +70 -0
- package/dist/enums/symbolFlags.enum.d.ts.map +1 -0
- package/dist/enums/symbolFlags.enum.js +72 -0
- package/dist/enums/symbolFlags.enum.js.map +1 -0
- package/dist/enums/symbolFlags.js +72 -0
- package/dist/enums/symbolFlags.js.map +1 -0
- package/dist/enums/symbolOwnerKind.d.ts +2 -0
- package/dist/enums/symbolOwnerKind.d.ts.map +1 -0
- package/dist/enums/symbolOwnerKind.enum.d.ts +5 -0
- package/dist/enums/symbolOwnerKind.enum.d.ts.map +1 -0
- package/dist/enums/symbolOwnerKind.enum.js +7 -0
- package/dist/enums/symbolOwnerKind.enum.js.map +1 -0
- package/dist/enums/symbolOwnerKind.js +7 -0
- package/dist/enums/symbolOwnerKind.js.map +1 -0
- package/dist/enums/syntaxKind.d.ts +2 -0
- package/dist/enums/syntaxKind.d.ts.map +1 -0
- package/dist/enums/syntaxKind.enum.d.ts +390 -0
- package/dist/enums/syntaxKind.enum.d.ts.map +1 -0
- package/dist/enums/syntaxKind.enum.js +392 -0
- package/dist/enums/syntaxKind.enum.js.map +1 -0
- package/dist/enums/syntaxKind.js +392 -0
- package/dist/enums/syntaxKind.js.map +1 -0
- package/dist/enums/tokenFlags.d.ts +2 -0
- package/dist/enums/tokenFlags.d.ts.map +1 -0
- package/dist/enums/tokenFlags.enum.d.ts +30 -0
- package/dist/enums/tokenFlags.enum.d.ts.map +1 -0
- package/dist/enums/tokenFlags.enum.js +32 -0
- package/dist/enums/tokenFlags.enum.js.map +1 -0
- package/dist/enums/tokenFlags.js +32 -0
- package/dist/enums/tokenFlags.js.map +1 -0
- package/dist/enums/typeFlags.d.ts +2 -0
- package/dist/enums/typeFlags.d.ts.map +1 -0
- package/dist/enums/typeFlags.enum.d.ts +76 -0
- package/dist/enums/typeFlags.enum.d.ts.map +1 -0
- package/dist/enums/typeFlags.enum.js +78 -0
- package/dist/enums/typeFlags.enum.js.map +1 -0
- package/dist/enums/typeFlags.js +78 -0
- package/dist/enums/typeFlags.js.map +1 -0
- package/dist/enums/typeFormatFlags.d.ts +2 -0
- package/dist/enums/typeFormatFlags.d.ts.map +1 -0
- package/dist/enums/typeFormatFlags.enum.d.ts +29 -0
- package/dist/enums/typeFormatFlags.enum.d.ts.map +1 -0
- package/dist/enums/typeFormatFlags.enum.js +31 -0
- package/dist/enums/typeFormatFlags.enum.js.map +1 -0
- package/dist/enums/typeFormatFlags.js +31 -0
- package/dist/enums/typeFormatFlags.js.map +1 -0
- package/dist/enums/typePredicateKind.d.ts +2 -0
- package/dist/enums/typePredicateKind.d.ts.map +1 -0
- package/dist/enums/typePredicateKind.enum.d.ts +7 -0
- package/dist/enums/typePredicateKind.enum.d.ts.map +1 -0
- package/dist/enums/typePredicateKind.enum.js +9 -0
- package/dist/enums/typePredicateKind.enum.js.map +1 -0
- package/dist/enums/typePredicateKind.js +9 -0
- package/dist/enums/typePredicateKind.js.map +1 -0
- package/dist/internal/utils.d.ts +23 -0
- package/dist/internal/utils.d.ts.map +1 -0
- package/dist/internal/utils.js +25 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/vscode/extensionApi.d.ts +100 -0
- package/dist/vscode/extensionApi.d.ts.map +1 -0
- package/dist/vscode/extensionApi.js +2 -0
- package/dist/vscode/extensionApi.js.map +1 -0
- package/dist/vscode/moduleLoader.d.ts +14 -0
- package/dist/vscode/moduleLoader.d.ts.map +1 -0
- package/dist/vscode/moduleLoader.js +36 -0
- package/dist/vscode/moduleLoader.js.map +1 -0
- package/dist/vscode/protocol.generated.d.ts +2886 -0
- package/dist/vscode/protocol.generated.d.ts.map +1 -0
- package/dist/vscode/protocol.generated.js +4 -0
- package/dist/vscode/protocol.generated.js.map +1 -0
- package/lib/getExePath.d.ts +2 -0
- package/lib/getExePath.js +70 -0
- package/lib/install.js +108 -0
- package/lib/tsc.js +28 -0
- package/lib/version.cjs +5 -0
- package/lib/version.d.cts +2 -0
- package/package.json +79 -6
- package/schemas/jsconfig.schema.json +2207 -0
- package/schemas/tsconfig.schema.json +2206 -0
- package/vendor/vscode-jsonrpc/License.txt +11 -0
- package/vendor/vscode-jsonrpc/README.md +54 -0
- package/vendor/vscode-jsonrpc/lib/browser/main.d.ts +17 -0
- package/vendor/vscode-jsonrpc/lib/browser/main.js +83 -0
- package/vendor/vscode-jsonrpc/lib/browser/ril.d.ts +22 -0
- package/vendor/vscode-jsonrpc/lib/browser/ril.js +210 -0
- package/vendor/vscode-jsonrpc/lib/common/api.d.ts +14 -0
- package/vendor/vscode-jsonrpc/lib/common/api.js +87 -0
- package/vendor/vscode-jsonrpc/lib/common/cancellation.d.ts +32 -0
- package/vendor/vscode-jsonrpc/lib/common/cancellation.js +132 -0
- package/vendor/vscode-jsonrpc/lib/common/connection.d.ts +367 -0
- package/vendor/vscode-jsonrpc/lib/common/connection.js +1271 -0
- package/vendor/vscode-jsonrpc/lib/common/disposable.d.ts +9 -0
- package/vendor/vscode-jsonrpc/lib/common/disposable.js +16 -0
- package/vendor/vscode-jsonrpc/lib/common/encoding.d.ts +52 -0
- package/vendor/vscode-jsonrpc/lib/common/encoding.js +70 -0
- package/vendor/vscode-jsonrpc/lib/common/events.d.ts +39 -0
- package/vendor/vscode-jsonrpc/lib/common/events.js +135 -0
- package/vendor/vscode-jsonrpc/lib/common/is.d.ts +7 -0
- package/vendor/vscode-jsonrpc/lib/common/is.js +34 -0
- package/vendor/vscode-jsonrpc/lib/common/linkedMap.d.ts +55 -0
- package/vendor/vscode-jsonrpc/lib/common/linkedMap.js +412 -0
- package/vendor/vscode-jsonrpc/lib/common/messageBuffer.d.ts +18 -0
- package/vendor/vscode-jsonrpc/lib/common/messageBuffer.js +155 -0
- package/vendor/vscode-jsonrpc/lib/common/messageReader.d.ts +77 -0
- package/vendor/vscode-jsonrpc/lib/common/messageReader.js +246 -0
- package/vendor/vscode-jsonrpc/lib/common/messageWriter.d.ts +60 -0
- package/vendor/vscode-jsonrpc/lib/common/messageWriter.js +157 -0
- package/vendor/vscode-jsonrpc/lib/common/messages.d.ts +369 -0
- package/vendor/vscode-jsonrpc/lib/common/messages.js +436 -0
- package/vendor/vscode-jsonrpc/lib/common/ral.d.ts +74 -0
- package/vendor/vscode-jsonrpc/lib/common/ral.js +23 -0
- package/vendor/vscode-jsonrpc/lib/common/semaphore.d.ts +10 -0
- package/vendor/vscode-jsonrpc/lib/common/semaphore.js +74 -0
- package/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.d.ts +15 -0
- package/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +77 -0
- package/vendor/vscode-jsonrpc/lib/node/main.d.ts +58 -0
- package/vendor/vscode-jsonrpc/lib/node/main.js +289 -0
- package/vendor/vscode-jsonrpc/lib/node/ril.d.ts +12 -0
- package/vendor/vscode-jsonrpc/lib/node/ril.js +163 -0
- package/vendor/vscode-jsonrpc/package.json +54 -0
- package/vendor/vscode-jsonrpc/typings/thenable.d.ts +5 -0
package/dist/api/path.js
ADDED
|
@@ -0,0 +1,884 @@
|
|
|
1
|
+
import { CaseSensitivity } from "#enums/caseSensitivity";
|
|
2
|
+
export { CaseSensitivity } from "#enums/caseSensitivity";
|
|
3
|
+
const CharacterCodesSlash = "/".charCodeAt(0);
|
|
4
|
+
const CharacterCodesBackslash = "\\".charCodeAt(0);
|
|
5
|
+
const CharacterCodesColon = ":".charCodeAt(0);
|
|
6
|
+
const CharacterCodesPercent = "%".charCodeAt(0);
|
|
7
|
+
const CharacterCodesCaret = "^".charCodeAt(0);
|
|
8
|
+
const CharacterCodes3 = "3".charCodeAt(0);
|
|
9
|
+
const CharacterCodesa = "a".charCodeAt(0);
|
|
10
|
+
const CharacterCodesz = "z".charCodeAt(0);
|
|
11
|
+
const CharacterCodesA = "A".charCodeAt(0);
|
|
12
|
+
const CharacterCodesZ = "Z".charCodeAt(0);
|
|
13
|
+
const CharacterCodesDot = ".".charCodeAt(0);
|
|
14
|
+
const directorySeparator = "/";
|
|
15
|
+
const altDirectorySeparator = "\\";
|
|
16
|
+
const urlSchemeSeparator = "://";
|
|
17
|
+
const backslashRegExp = /\\/g;
|
|
18
|
+
// Preserve U+0130 as case-sensitive while avoiding work for common lowercase paths.
|
|
19
|
+
const fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_. ]+/g;
|
|
20
|
+
// check path for these segments: '', '.'. '..'
|
|
21
|
+
const relativePathSegmentRegExp = /\/\/|(?:^|\/)\.\.?(?:$|\/)/;
|
|
22
|
+
/**
|
|
23
|
+
* Determines whether a charCode corresponds to `/` or `\\`.
|
|
24
|
+
*/
|
|
25
|
+
function isAnyDirectorySeparator(charCode) {
|
|
26
|
+
return charCode === CharacterCodesSlash || charCode === CharacterCodesBackslash;
|
|
27
|
+
}
|
|
28
|
+
function isVolumeCharacter(charCode) {
|
|
29
|
+
return (charCode >= CharacterCodesa && charCode <= CharacterCodesz) ||
|
|
30
|
+
(charCode >= CharacterCodesA && charCode <= CharacterCodesZ);
|
|
31
|
+
}
|
|
32
|
+
function getFileUrlVolumeSeparatorEnd(url, start) {
|
|
33
|
+
const ch0 = url.charCodeAt(start);
|
|
34
|
+
if (ch0 === CharacterCodesColon)
|
|
35
|
+
return start + 1;
|
|
36
|
+
if (ch0 === CharacterCodesPercent && url.charCodeAt(start + 1) === CharacterCodes3) {
|
|
37
|
+
const ch2 = url.charCodeAt(start + 2);
|
|
38
|
+
if (ch2 === CharacterCodesa || ch2 === CharacterCodesA)
|
|
39
|
+
return start + 3;
|
|
40
|
+
}
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
45
|
+
*
|
|
46
|
+
* For example:
|
|
47
|
+
* ```ts
|
|
48
|
+
* getRootLength("a") === 0 // ""
|
|
49
|
+
* getRootLength("/") === 1 // "/"
|
|
50
|
+
* getRootLength("c:") === 2 // "c:"
|
|
51
|
+
* getRootLength("c:d") === 0 // ""
|
|
52
|
+
* getRootLength("c:/") === 3 // "c:/"
|
|
53
|
+
* getRootLength("c:\\") === 3 // "c:\\"
|
|
54
|
+
* getRootLength("//server") === 7 // "//server"
|
|
55
|
+
* getRootLength("//server/share") === 8 // "//server/"
|
|
56
|
+
* getRootLength("\\\\server") === 7 // "\\\\server"
|
|
57
|
+
* getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
|
|
58
|
+
* getRootLength("file:///path") === 8 // "file:///"
|
|
59
|
+
* getRootLength("file:///c:") === 10 // "file:///c:"
|
|
60
|
+
* getRootLength("file:///c:d") === 8 // "file:///"
|
|
61
|
+
* getRootLength("file:///c:/path") === 11 // "file:///c:/"
|
|
62
|
+
* getRootLength("file://server") === 13 // "file://server"
|
|
63
|
+
* getRootLength("file://server/path") === 14 // "file://server/"
|
|
64
|
+
* getRootLength("http://server") === 13 // "http://server"
|
|
65
|
+
* getRootLength("http://server/path") === 14 // "http://server/"
|
|
66
|
+
* getRootLength("^/untitled/ts-nul-authority/Untitled-1") === 2 // "^/"
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export function getRootLength(path) {
|
|
72
|
+
const rootLength = getEncodedRootLength(path);
|
|
73
|
+
return rootLength < 0 ? ~rootLength : rootLength;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
77
|
+
* If the root is part of a URL, the twos-complement of the root length is returned.
|
|
78
|
+
*/
|
|
79
|
+
function getEncodedRootLength(path) {
|
|
80
|
+
if (!path)
|
|
81
|
+
return 0;
|
|
82
|
+
const ch0 = path.charCodeAt(0);
|
|
83
|
+
// POSIX or UNC
|
|
84
|
+
if (ch0 === CharacterCodesSlash || ch0 === CharacterCodesBackslash) {
|
|
85
|
+
if (path.charCodeAt(1) !== ch0)
|
|
86
|
+
return 1; // POSIX: "/" (or non-normalized "\")
|
|
87
|
+
const p1 = path.indexOf(ch0 === CharacterCodesSlash ? directorySeparator : altDirectorySeparator, 2);
|
|
88
|
+
if (p1 < 0)
|
|
89
|
+
return path.length; // UNC: "//server" or "\\server"
|
|
90
|
+
return p1 + 1; // UNC: "//server/" or "\\server\"
|
|
91
|
+
}
|
|
92
|
+
// Dynamic/virtual compiler file name.
|
|
93
|
+
if (ch0 === CharacterCodesCaret && path.charCodeAt(1) === CharacterCodesSlash) {
|
|
94
|
+
if (path.startsWith(dynamicURIFileNamePrefix)) {
|
|
95
|
+
const schemeEnd = path.indexOf(directorySeparator, dynamicURIFileNamePrefix.length);
|
|
96
|
+
if (schemeEnd !== -1) {
|
|
97
|
+
const authorityEnd = path.indexOf(directorySeparator, schemeEnd + 1);
|
|
98
|
+
if (authorityEnd !== -1) {
|
|
99
|
+
return authorityEnd + 1;
|
|
100
|
+
}
|
|
101
|
+
return ~path.length;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return 2;
|
|
105
|
+
}
|
|
106
|
+
// DOS
|
|
107
|
+
if (isVolumeCharacter(ch0) && path.charCodeAt(1) === CharacterCodesColon) {
|
|
108
|
+
const ch2 = path.charCodeAt(2);
|
|
109
|
+
if (ch2 === CharacterCodesSlash || ch2 === CharacterCodesBackslash)
|
|
110
|
+
return 3; // DOS: "c:/" or "c:\"
|
|
111
|
+
if (path.length === 2)
|
|
112
|
+
return 2; // DOS: "c:" (but not "c:d")
|
|
113
|
+
}
|
|
114
|
+
if (isDynamicFileName(path))
|
|
115
|
+
return 2;
|
|
116
|
+
// URL
|
|
117
|
+
const schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
118
|
+
if (schemeEnd !== -1) {
|
|
119
|
+
const authorityStart = schemeEnd + urlSchemeSeparator.length;
|
|
120
|
+
const authorityEnd = path.indexOf(directorySeparator, authorityStart);
|
|
121
|
+
if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
|
|
122
|
+
// For local "file" URLs, include the leading DOS volume (if present).
|
|
123
|
+
// Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
|
|
124
|
+
// special case interpreted as "the machine from which the URL is being interpreted".
|
|
125
|
+
const scheme = path.slice(0, schemeEnd);
|
|
126
|
+
const authority = path.slice(authorityStart, authorityEnd);
|
|
127
|
+
if (scheme.toLowerCase() === "file" && (authority === "" || authority.toLowerCase() === "localhost") &&
|
|
128
|
+
isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
|
|
129
|
+
const volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
|
|
130
|
+
if (volumeSeparatorEnd !== -1) {
|
|
131
|
+
if (path.charCodeAt(volumeSeparatorEnd) === CharacterCodesSlash) {
|
|
132
|
+
// URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
|
|
133
|
+
return ~(volumeSeparatorEnd + 1);
|
|
134
|
+
}
|
|
135
|
+
if (volumeSeparatorEnd === path.length) {
|
|
136
|
+
// URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
|
|
137
|
+
// but not "file:///c:d" or "file:///c%3ad"
|
|
138
|
+
return ~volumeSeparatorEnd;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
|
|
143
|
+
}
|
|
144
|
+
return ~path.length; // URL: "file://server", "http://server"
|
|
145
|
+
}
|
|
146
|
+
// relative
|
|
147
|
+
return 0;
|
|
148
|
+
}
|
|
149
|
+
export function getPathComponents(path) {
|
|
150
|
+
return pathComponents(path, getRootLength(path));
|
|
151
|
+
}
|
|
152
|
+
function pathComponents(path, rootLength) {
|
|
153
|
+
const root = path.substring(0, rootLength);
|
|
154
|
+
const rest = path.substring(rootLength).split("/");
|
|
155
|
+
if (rest.length && !lastOrUndefined(rest))
|
|
156
|
+
rest.pop();
|
|
157
|
+
return [root, ...rest];
|
|
158
|
+
}
|
|
159
|
+
function lastOrUndefined(array) {
|
|
160
|
+
return array.length ? array[array.length - 1] : undefined;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Determines whether a path has a trailing separator (`/` or `\\`).
|
|
164
|
+
*/
|
|
165
|
+
export function hasTrailingDirectorySeparator(path) {
|
|
166
|
+
return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Removes a trailing directory separator from a path, if it does not already have one.
|
|
170
|
+
*/
|
|
171
|
+
export function removeTrailingDirectorySeparator(path) {
|
|
172
|
+
if (hasTrailingDirectorySeparator(path)) {
|
|
173
|
+
return path.substr(0, path.length - 1);
|
|
174
|
+
}
|
|
175
|
+
return path;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Adds a trailing directory separator to a path, if it does not already have one.
|
|
179
|
+
*/
|
|
180
|
+
export function ensureTrailingDirectorySeparator(path) {
|
|
181
|
+
if (!hasTrailingDirectorySeparator(path)) {
|
|
182
|
+
return path + directorySeparator;
|
|
183
|
+
}
|
|
184
|
+
return path;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Normalize path separators, converting `\\` into `/`.
|
|
188
|
+
*/
|
|
189
|
+
export function normalizeSlashes(path) {
|
|
190
|
+
return path.includes("\\")
|
|
191
|
+
? path.replace(backslashRegExp, directorySeparator)
|
|
192
|
+
: path;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
|
|
196
|
+
*/
|
|
197
|
+
export function combinePaths(path, ...paths) {
|
|
198
|
+
if (path)
|
|
199
|
+
path = normalizeSlashes(path);
|
|
200
|
+
for (let relativePath of paths) {
|
|
201
|
+
if (!relativePath)
|
|
202
|
+
continue;
|
|
203
|
+
relativePath = normalizeSlashes(relativePath);
|
|
204
|
+
if (!path || getRootLength(relativePath) !== 0) {
|
|
205
|
+
path = relativePath;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
path = ensureTrailingDirectorySeparator(path) + relativePath;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return path;
|
|
212
|
+
}
|
|
213
|
+
function simpleNormalizePath(path) {
|
|
214
|
+
// Most paths don't require normalization
|
|
215
|
+
if (!relativePathSegmentRegExp.test(path)) {
|
|
216
|
+
return path;
|
|
217
|
+
}
|
|
218
|
+
// Some paths only require cleanup of `/./` or leading `./`
|
|
219
|
+
let simplified = path.replace(/\/\.\//g, "/");
|
|
220
|
+
if (simplified.startsWith("./")) {
|
|
221
|
+
simplified = simplified.slice(2);
|
|
222
|
+
}
|
|
223
|
+
if (simplified !== path) {
|
|
224
|
+
path = simplified;
|
|
225
|
+
if (!relativePathSegmentRegExp.test(path)) {
|
|
226
|
+
return path;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Returns the normalized absolute path, resolving `.` and `..` segments.
|
|
233
|
+
*/
|
|
234
|
+
export function getNormalizedAbsolutePath(path, currentDirectory) {
|
|
235
|
+
let rootLength = getRootLength(path);
|
|
236
|
+
if (rootLength === 0 && currentDirectory) {
|
|
237
|
+
path = combinePaths(currentDirectory, path);
|
|
238
|
+
rootLength = getRootLength(path);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// combinePaths normalizes slashes, so not necessary in the other branch
|
|
242
|
+
path = normalizeSlashes(path);
|
|
243
|
+
}
|
|
244
|
+
const simpleNormalized = simpleNormalizePath(path);
|
|
245
|
+
if (simpleNormalized !== undefined) {
|
|
246
|
+
return simpleNormalized.length > rootLength ? removeTrailingDirectorySeparator(simpleNormalized) : simpleNormalized;
|
|
247
|
+
}
|
|
248
|
+
const length = path.length;
|
|
249
|
+
const root = path.substring(0, rootLength);
|
|
250
|
+
// `normalized` is only initialized once `path` is determined to be non-normalized
|
|
251
|
+
let normalized;
|
|
252
|
+
let index = rootLength;
|
|
253
|
+
let segmentStart = index;
|
|
254
|
+
let normalizedUpTo = index;
|
|
255
|
+
let seenNonDotDotSegment = rootLength !== 0;
|
|
256
|
+
while (index < length) {
|
|
257
|
+
// At beginning of segment
|
|
258
|
+
segmentStart = index;
|
|
259
|
+
let ch = path.charCodeAt(index);
|
|
260
|
+
while (ch === CharacterCodesSlash && index + 1 < length) {
|
|
261
|
+
index++;
|
|
262
|
+
ch = path.charCodeAt(index);
|
|
263
|
+
}
|
|
264
|
+
if (index > segmentStart) {
|
|
265
|
+
// Seen superfluous separator
|
|
266
|
+
normalized ??= path.substring(0, segmentStart - 1);
|
|
267
|
+
segmentStart = index;
|
|
268
|
+
}
|
|
269
|
+
// Past any superfluous separators
|
|
270
|
+
let segmentEnd = path.indexOf(directorySeparator, index + 1);
|
|
271
|
+
if (segmentEnd === -1) {
|
|
272
|
+
segmentEnd = length;
|
|
273
|
+
}
|
|
274
|
+
const segmentLength = segmentEnd - segmentStart;
|
|
275
|
+
if (segmentLength === 1 && path.charCodeAt(index) === CharacterCodesDot) {
|
|
276
|
+
// "." segment (skip)
|
|
277
|
+
normalized ??= path.substring(0, normalizedUpTo);
|
|
278
|
+
}
|
|
279
|
+
else if (segmentLength === 2 && path.charCodeAt(index) === CharacterCodesDot && path.charCodeAt(index + 1) === CharacterCodesDot) {
|
|
280
|
+
// ".." segment
|
|
281
|
+
if (!seenNonDotDotSegment) {
|
|
282
|
+
if (normalized !== undefined) {
|
|
283
|
+
normalized += normalized.length === rootLength ? ".." : "/..";
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
normalizedUpTo = index + 2;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else if (normalized === undefined) {
|
|
290
|
+
if (normalizedUpTo - 2 >= 0) {
|
|
291
|
+
normalized = path.substring(0, Math.max(rootLength, path.lastIndexOf(directorySeparator, normalizedUpTo - 2)));
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
normalized = path.substring(0, normalizedUpTo);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
const lastSlash = normalized.lastIndexOf(directorySeparator);
|
|
299
|
+
if (lastSlash !== -1) {
|
|
300
|
+
normalized = normalized.substring(0, Math.max(rootLength, lastSlash));
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
normalized = root;
|
|
304
|
+
}
|
|
305
|
+
if (normalized.length === rootLength) {
|
|
306
|
+
seenNonDotDotSegment = rootLength !== 0;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
else if (normalized !== undefined) {
|
|
311
|
+
if (normalized.length !== rootLength) {
|
|
312
|
+
normalized += directorySeparator;
|
|
313
|
+
}
|
|
314
|
+
seenNonDotDotSegment = true;
|
|
315
|
+
normalized += path.substring(segmentStart, segmentEnd);
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
seenNonDotDotSegment = true;
|
|
319
|
+
normalizedUpTo = segmentEnd;
|
|
320
|
+
}
|
|
321
|
+
index = segmentEnd + 1;
|
|
322
|
+
}
|
|
323
|
+
return normalized ?? (length > rootLength ? removeTrailingDirectorySeparator(path) : path);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Normalizes a path, resolving `.` and `..` segments and converting backslashes to forward slashes.
|
|
327
|
+
*/
|
|
328
|
+
export function normalizePath(path) {
|
|
329
|
+
path = normalizeSlashes(path);
|
|
330
|
+
let normalized = simpleNormalizePath(path);
|
|
331
|
+
if (normalized !== undefined) {
|
|
332
|
+
return normalized;
|
|
333
|
+
}
|
|
334
|
+
normalized = getNormalizedAbsolutePath(path, "");
|
|
335
|
+
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Determines whether a path is an absolute disk path (e.g. starts with `/`, or a DOS path
|
|
339
|
+
* like `c:`, `c:\\` or `c:/`).
|
|
340
|
+
*/
|
|
341
|
+
export function isRootedDiskPath(path) {
|
|
342
|
+
return getEncodedRootLength(path) > 0;
|
|
343
|
+
}
|
|
344
|
+
export function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
|
|
345
|
+
if (!isRootedDiskPath(absoluteOrRelativePath)) {
|
|
346
|
+
return absoluteOrRelativePath;
|
|
347
|
+
}
|
|
348
|
+
const fromComponents = getPathComponents(getNormalizedAbsolutePath(basePath, ""));
|
|
349
|
+
const toComponents = getPathComponents(getNormalizedAbsolutePath(absoluteOrRelativePath, ""));
|
|
350
|
+
let start = 0;
|
|
351
|
+
for (; start < fromComponents.length && start < toComponents.length; start++) {
|
|
352
|
+
const fromComponent = getCanonicalFileName(fromComponents[start]);
|
|
353
|
+
const toComponent = getCanonicalFileName(toComponents[start]);
|
|
354
|
+
const equal = start === 0
|
|
355
|
+
? fromComponent.toLowerCase() === toComponent.toLowerCase()
|
|
356
|
+
: fromComponent === toComponent;
|
|
357
|
+
if (!equal) {
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (start === 0) {
|
|
362
|
+
return pathFromComponents(toComponents);
|
|
363
|
+
}
|
|
364
|
+
const relative = Array(fromComponents.length - start).fill("..");
|
|
365
|
+
return pathFromComponents(["", ...relative, ...toComponents.slice(start)]);
|
|
366
|
+
}
|
|
367
|
+
function pathFromComponents(components) {
|
|
368
|
+
if (components.length === 0) {
|
|
369
|
+
return "";
|
|
370
|
+
}
|
|
371
|
+
const root = components[0] && ensureTrailingDirectorySeparator(components[0]);
|
|
372
|
+
return root + components.slice(1).join(directorySeparator);
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Returns the canonical key for an already rooted, normalized path under
|
|
376
|
+
* caseSensitivity.
|
|
377
|
+
*/
|
|
378
|
+
export function pathKey(path, caseSensitivity) {
|
|
379
|
+
if (path.startsWith(dynamicURIFileNamePrefix)) {
|
|
380
|
+
let canonicalPath = path;
|
|
381
|
+
if (getRootLength(path) === path.length && !hasTrailingDirectorySeparator(path)) {
|
|
382
|
+
canonicalPath += directorySeparator;
|
|
383
|
+
}
|
|
384
|
+
return canonicalize(canonicalPath, CaseSensitivity.Sensitive);
|
|
385
|
+
}
|
|
386
|
+
return canonicalize(path, caseSensitivity);
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Validates a canonical path key received from a trusted producer without
|
|
390
|
+
* applying case sensitivity again.
|
|
391
|
+
*/
|
|
392
|
+
export function tryPathKeyFromCanonical(path) {
|
|
393
|
+
return tryRootedPathFromNormalized(path) === undefined ? undefined : path;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Resolves path against currentDirectory and normalizes it.
|
|
397
|
+
*/
|
|
398
|
+
export function toRootedPath(path, currentDirectory) {
|
|
399
|
+
if (path === "") {
|
|
400
|
+
throw new Error("Path must not be empty");
|
|
401
|
+
}
|
|
402
|
+
if (hasRootedURLSuffix(path)) {
|
|
403
|
+
throw new Error(`Path must not contain a URL query or fragment: ${path}`);
|
|
404
|
+
}
|
|
405
|
+
if (getEncodedRootLength(path) === 0 &&
|
|
406
|
+
currentDirectory !== undefined &&
|
|
407
|
+
hasURLRoot(currentDirectory) &&
|
|
408
|
+
/[?#]/.test(path)) {
|
|
409
|
+
throw new Error(`Relative URL path must not contain a query or fragment: ${path}`);
|
|
410
|
+
}
|
|
411
|
+
let normalized = getNormalizedAbsolutePath(path, currentDirectory);
|
|
412
|
+
if (normalized === "" ||
|
|
413
|
+
getRootLength(normalized) === 0 ||
|
|
414
|
+
hasRootedURLSuffix(normalized)) {
|
|
415
|
+
throw new Error(`Path is not rooted: ${normalized}`);
|
|
416
|
+
}
|
|
417
|
+
if (getRootLength(normalized) === normalized.length && !hasTrailingDirectorySeparator(normalized)) {
|
|
418
|
+
normalized += directorySeparator;
|
|
419
|
+
}
|
|
420
|
+
return normalized;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Validates a path that is already rooted and normalized without changing it.
|
|
424
|
+
*/
|
|
425
|
+
export function rootedPathFromNormalized(path) {
|
|
426
|
+
const result = tryRootedPathFromNormalized(path);
|
|
427
|
+
if (result === undefined) {
|
|
428
|
+
throw new Error(`Path is not rooted and normalized: ${path}`);
|
|
429
|
+
}
|
|
430
|
+
return result;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Attempts to validate a path that is already rooted and normalized without
|
|
434
|
+
* changing it.
|
|
435
|
+
*/
|
|
436
|
+
export function tryRootedPathFromNormalized(path) {
|
|
437
|
+
if (hasRootedURLSuffix(path)) {
|
|
438
|
+
return undefined;
|
|
439
|
+
}
|
|
440
|
+
const rootLength = getRootLength(path);
|
|
441
|
+
if (path === "" ||
|
|
442
|
+
rootLength === 0 ||
|
|
443
|
+
path.includes("\\") ||
|
|
444
|
+
hasRelativePathSegment(path, rootLength) ||
|
|
445
|
+
path.length === rootLength && !hasTrailingDirectorySeparator(path) ||
|
|
446
|
+
path.length > rootLength && hasTrailingDirectorySeparator(path)) {
|
|
447
|
+
return undefined;
|
|
448
|
+
}
|
|
449
|
+
return path;
|
|
450
|
+
}
|
|
451
|
+
function hasRootedURLSuffix(path) {
|
|
452
|
+
if (!hasURLRoot(path)) {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
const schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
456
|
+
const suffixStart = path.search(/[?#]/);
|
|
457
|
+
return suffixStart >= schemeEnd + urlSchemeSeparator.length;
|
|
458
|
+
}
|
|
459
|
+
function hasURLRoot(path) {
|
|
460
|
+
return getEncodedRootLength(path) < 0 && path.includes(urlSchemeSeparator);
|
|
461
|
+
}
|
|
462
|
+
function hasRelativePathSegment(path, start) {
|
|
463
|
+
if (start === path.length) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
let segmentStart = start;
|
|
467
|
+
for (let index = start; index <= path.length; index++) {
|
|
468
|
+
if (index !== path.length && path.charCodeAt(index) !== CharacterCodesSlash) {
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
const segmentLength = index - segmentStart;
|
|
472
|
+
if (segmentLength === 0 ||
|
|
473
|
+
segmentLength === 1 && path.charCodeAt(segmentStart) === CharacterCodesDot ||
|
|
474
|
+
segmentLength === 2 &&
|
|
475
|
+
path.charCodeAt(segmentStart) === CharacterCodesDot &&
|
|
476
|
+
path.charCodeAt(segmentStart + 1) === CharacterCodesDot) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
segmentStart = index + 1;
|
|
480
|
+
}
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Resolves fileName against currentDirectory, normalizes it, and gives it file
|
|
485
|
+
* intent.
|
|
486
|
+
*/
|
|
487
|
+
export function toRootedFilePath(fileName, currentDirectory) {
|
|
488
|
+
return toRootedPath(fileName, currentDirectory);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Resolves directory against currentDirectory, normalizes it, and gives it
|
|
492
|
+
* directory intent.
|
|
493
|
+
*/
|
|
494
|
+
export function toRootedDirectoryPath(directory, currentDirectory) {
|
|
495
|
+
return toRootedPath(directory, currentDirectory);
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Gives a RootedPath file intent without changing it.
|
|
499
|
+
*/
|
|
500
|
+
export function rootedFilePathFromPath(path) {
|
|
501
|
+
return path;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Gives a RootedPath directory intent without changing it.
|
|
505
|
+
*/
|
|
506
|
+
export function rootedDirectoryPathFromPath(path) {
|
|
507
|
+
return path;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Applies caseSensitivity to text used for path comparison or keys.
|
|
511
|
+
*/
|
|
512
|
+
export function canonicalize(text, caseSensitivity) {
|
|
513
|
+
return isCaseSensitive(caseSensitivity) ? text : toFileNameLowerCase(text);
|
|
514
|
+
}
|
|
515
|
+
export function isCaseSensitive(caseSensitivity) {
|
|
516
|
+
return caseSensitivity === CaseSensitivity.Sensitive;
|
|
517
|
+
}
|
|
518
|
+
export function isCaseInsensitive(caseSensitivity) {
|
|
519
|
+
return caseSensitivity === CaseSensitivity.Insensitive;
|
|
520
|
+
}
|
|
521
|
+
function toLowerCasePerCodePoint(text) {
|
|
522
|
+
let result = "";
|
|
523
|
+
for (const char of text) {
|
|
524
|
+
result += char.toLowerCase();
|
|
525
|
+
}
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
function toFileNameLowerCase(fileName) {
|
|
529
|
+
return fileNameLowerCaseRegExp.test(fileName)
|
|
530
|
+
? fileName.replace(fileNameLowerCaseRegExp, toLowerCasePerCodePoint)
|
|
531
|
+
: fileName;
|
|
532
|
+
}
|
|
533
|
+
const bundledScheme = "bundled:///";
|
|
534
|
+
const dynamicURIFileNamePrefix = "^/~ts-uri~/";
|
|
535
|
+
const dynamicURIPathSegmentEscapePrefix = "~ts-uri-escape~";
|
|
536
|
+
const dynamicURIModuleSpecifierEscapePrefix = "~ts-uri-spec~";
|
|
537
|
+
const dynamicURINoPathEscapePrefix = "~ts-uri-no-path~";
|
|
538
|
+
const dynamicURIPathSegmentEscapeRegExp = /(?:^|\/)(?:\.{1,2}(?:\/|$)|~ts-uri-escape~|~ts-uri-spec~|~ts-uri-no-path~)/;
|
|
539
|
+
/**
|
|
540
|
+
* Returns true if the path refers to a bundled library file.
|
|
541
|
+
*/
|
|
542
|
+
export function isBundled(path) {
|
|
543
|
+
return path.startsWith(bundledScheme);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Returns true if the file name represents a dynamic/virtual file
|
|
547
|
+
* that doesn't exist on disk (e.g., untitled files with paths like "^/untitled/...").
|
|
548
|
+
*/
|
|
549
|
+
export function isDynamicFileName(fileName) {
|
|
550
|
+
return fileName.startsWith("^/");
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Splits a Windows volume (e.g., "c:") from the rest of the path.
|
|
554
|
+
* Returns [volume, rest, ok] where ok is true if a volume was found.
|
|
555
|
+
*/
|
|
556
|
+
export function splitVolumePath(path) {
|
|
557
|
+
if (path.length >= 2 && isVolumeCharacter(path.charCodeAt(0)) && path.charCodeAt(1) === CharacterCodesColon) {
|
|
558
|
+
return [path.substring(0, 2).toLowerCase(), path.substring(2), true];
|
|
559
|
+
}
|
|
560
|
+
return ["", path, false];
|
|
561
|
+
}
|
|
562
|
+
function splitVolumePathPreservingCase(path) {
|
|
563
|
+
if (path.length >= 2 && isVolumeCharacter(path.charCodeAt(0)) && path.charCodeAt(1) === CharacterCodesColon) {
|
|
564
|
+
return [path.substring(0, 2), path.substring(2), true];
|
|
565
|
+
}
|
|
566
|
+
return ["", path, false];
|
|
567
|
+
}
|
|
568
|
+
// Characters that need extra escaping in URI path segments
|
|
569
|
+
// https://github.com/microsoft/vscode-uri/blob/edfdccd976efaf4bb8fdeca87e97c47257721729/src/uri.ts#L455
|
|
570
|
+
const extraEscapeChars = {
|
|
571
|
+
":": "%3A",
|
|
572
|
+
"/": "%2F",
|
|
573
|
+
"?": "%3F",
|
|
574
|
+
"#": "%23",
|
|
575
|
+
"[": "%5B",
|
|
576
|
+
"]": "%5D",
|
|
577
|
+
"@": "%40",
|
|
578
|
+
"!": "%21",
|
|
579
|
+
"$": "%24",
|
|
580
|
+
"&": "%26",
|
|
581
|
+
"'": "%27",
|
|
582
|
+
"(": "%28",
|
|
583
|
+
")": "%29",
|
|
584
|
+
"*": "%2A",
|
|
585
|
+
"+": "%2B",
|
|
586
|
+
",": "%2C",
|
|
587
|
+
";": "%3B",
|
|
588
|
+
"=": "%3D",
|
|
589
|
+
" ": "%20",
|
|
590
|
+
};
|
|
591
|
+
function extraEscape(s) {
|
|
592
|
+
let result = s;
|
|
593
|
+
for (const [char, escape] of Object.entries(extraEscapeChars)) {
|
|
594
|
+
result = result.replaceAll(char, escape);
|
|
595
|
+
}
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Converts a file name to a document URI.
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* fileNameToDocumentURI("/path/to/file.ts") === "file:///path/to/file.ts"
|
|
603
|
+
* fileNameToDocumentURI("c:/path/to/file.ts") === "file:///c%3A/path/to/file.ts"
|
|
604
|
+
* fileNameToDocumentURI("^/untitled/ts-nul-authority/Untitled-1") === "untitled:Untitled-1"
|
|
605
|
+
* fileNameToDocumentURI("^/vscode-vfs/github/microsoft/TypeScript/file.ts") === "vscode-vfs://github/microsoft/TypeScript/file.ts"
|
|
606
|
+
*/
|
|
607
|
+
export function fileNameToDocumentURI(fileName) {
|
|
608
|
+
// Bundled files are returned as-is
|
|
609
|
+
if (isBundled(fileName)) {
|
|
610
|
+
return fileName;
|
|
611
|
+
}
|
|
612
|
+
// Dynamic/virtual files (untitled, vscode-vfs, etc.) need special handling
|
|
613
|
+
if (isDynamicFileName(fileName)) {
|
|
614
|
+
const encoded = fileName.startsWith(dynamicURIFileNamePrefix);
|
|
615
|
+
const withoutPrefix = fileName.substring(encoded ? dynamicURIFileNamePrefix.length : 2);
|
|
616
|
+
const firstSlash = withoutPrefix.indexOf("/");
|
|
617
|
+
if (firstSlash === -1) {
|
|
618
|
+
throw new Error("invalid file name: " + fileName);
|
|
619
|
+
}
|
|
620
|
+
const scheme = withoutPrefix.substring(0, firstSlash);
|
|
621
|
+
const rest = withoutPrefix.substring(firstSlash + 1);
|
|
622
|
+
const secondSlash = rest.indexOf("/");
|
|
623
|
+
if (secondSlash === -1) {
|
|
624
|
+
throw new Error("invalid file name: " + fileName);
|
|
625
|
+
}
|
|
626
|
+
const encodedAuthority = rest.substring(0, secondSlash);
|
|
627
|
+
const hasAuthority = encodedAuthority !== "ts-nul-authority";
|
|
628
|
+
const authority = encoded ? decodeDynamicURIPathSegment(encodedAuthority) : encodedAuthority;
|
|
629
|
+
const encodedPath = rest.substring(secondSlash + 1);
|
|
630
|
+
if (encoded && hasAuthority) {
|
|
631
|
+
const suffix = decodeDynamicURINoPath(encodedPath);
|
|
632
|
+
if (suffix !== undefined) {
|
|
633
|
+
return scheme + "://" + authority + suffix;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
const path = encoded ? decodeDynamicURIPath(encodedPath) : encodedPath;
|
|
637
|
+
// ts-nul-authority is a placeholder for URIs without an authority
|
|
638
|
+
if (!hasAuthority) {
|
|
639
|
+
return scheme + ":" + path;
|
|
640
|
+
}
|
|
641
|
+
return scheme + "://" + authority + "/" + path;
|
|
642
|
+
}
|
|
643
|
+
// Regular file path - convert to file:// URI
|
|
644
|
+
let [volume, rest] = splitVolumePath(fileName);
|
|
645
|
+
if (volume !== "") {
|
|
646
|
+
volume = "/" + extraEscape(volume);
|
|
647
|
+
}
|
|
648
|
+
// Remove leading // for UNC paths (already handled by file://)
|
|
649
|
+
if (rest.startsWith("//")) {
|
|
650
|
+
rest = rest.substring(2);
|
|
651
|
+
}
|
|
652
|
+
const parts = rest.split("/");
|
|
653
|
+
const encodedParts = parts.map(part => extraEscape(encodeURIComponent(part)));
|
|
654
|
+
return "file://" + volume + encodedParts.join("/");
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Converts a document URI to a file name.
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* documentURIToFileName("file:///path/to/file.ts") === "/path/to/file.ts"
|
|
661
|
+
* documentURIToFileName("file:///c%3A/path/to/file.ts") === "c:/path/to/file.ts"
|
|
662
|
+
* documentURIToFileName("untitled:Untitled-1") === "^/untitled/ts-nul-authority/Untitled-1"
|
|
663
|
+
* documentURIToFileName("vscode-vfs://github/microsoft/TypeScript/file.ts") === "^/vscode-vfs/github/microsoft/TypeScript/file.ts"
|
|
664
|
+
*/
|
|
665
|
+
export function documentURIToFileName(uri) {
|
|
666
|
+
// Bundled files are returned as-is
|
|
667
|
+
if (isBundled(uri)) {
|
|
668
|
+
return uri;
|
|
669
|
+
}
|
|
670
|
+
// Handle file:// URIs
|
|
671
|
+
if (uri.startsWith("file://")) {
|
|
672
|
+
let parsed;
|
|
673
|
+
try {
|
|
674
|
+
parsed = new URL(uri);
|
|
675
|
+
}
|
|
676
|
+
catch {
|
|
677
|
+
throw new Error("invalid file URI: " + uri);
|
|
678
|
+
}
|
|
679
|
+
const path = decodeURIComponent(parsed.pathname);
|
|
680
|
+
// UNC path: file://server/share/...
|
|
681
|
+
if (parsed.host !== "") {
|
|
682
|
+
return "//" + parsed.host + path;
|
|
683
|
+
}
|
|
684
|
+
// Local file - fix Windows path by removing leading slash before volume
|
|
685
|
+
if (path.length >= 3 && path.charCodeAt(0) === CharacterCodesSlash) {
|
|
686
|
+
const [volume, rest, ok] = splitVolumePathPreservingCase(path.substring(1));
|
|
687
|
+
if (ok) {
|
|
688
|
+
return volume + rest;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return path;
|
|
692
|
+
}
|
|
693
|
+
// Leave all other URIs escaped so we can round-trip them.
|
|
694
|
+
// Convert to dynamic file name format: ^/scheme/authority/path
|
|
695
|
+
const colonIndex = uri.indexOf(":");
|
|
696
|
+
if (colonIndex === -1) {
|
|
697
|
+
throw new Error("invalid URI: " + uri);
|
|
698
|
+
}
|
|
699
|
+
const scheme = uri.substring(0, colonIndex);
|
|
700
|
+
let path = uri.substring(colonIndex + 1);
|
|
701
|
+
let suffix = "";
|
|
702
|
+
const suffixStart = path.search(/[?#]/);
|
|
703
|
+
if (suffixStart !== -1) {
|
|
704
|
+
suffix = path.substring(suffixStart);
|
|
705
|
+
path = path.substring(0, suffixStart);
|
|
706
|
+
}
|
|
707
|
+
let authority = "ts-nul-authority";
|
|
708
|
+
let hasAuthority = false;
|
|
709
|
+
let hasPath = true;
|
|
710
|
+
if (path.startsWith("//")) {
|
|
711
|
+
hasAuthority = true;
|
|
712
|
+
const rest = path.substring(2);
|
|
713
|
+
const slashIndex = rest.indexOf("/");
|
|
714
|
+
if (slashIndex === -1) {
|
|
715
|
+
authority = rest;
|
|
716
|
+
path = "";
|
|
717
|
+
hasPath = false;
|
|
718
|
+
}
|
|
719
|
+
else {
|
|
720
|
+
authority = rest.substring(0, slashIndex);
|
|
721
|
+
path = rest.substring(slashIndex + 1);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
let encodedAuthority = authority;
|
|
725
|
+
if (hasAuthority) {
|
|
726
|
+
encodedAuthority = authority === "ts-nul-authority"
|
|
727
|
+
? forceEncodeDynamicURIPathSegment(authority, false)
|
|
728
|
+
: encodeDynamicURIPath(authority);
|
|
729
|
+
}
|
|
730
|
+
const encodedPath = hasPath
|
|
731
|
+
? encodeDynamicURIPathWithSuffix(path, suffix)
|
|
732
|
+
: encodeDynamicURINoPath(suffix);
|
|
733
|
+
return dynamicURIFileNamePrefix + scheme + "/" + encodedAuthority + "/" + encodedPath;
|
|
734
|
+
}
|
|
735
|
+
function encodeDynamicURIPath(path, preserveFinalExtension = true) {
|
|
736
|
+
if (!dynamicURIPathNeedsEncoding(path)) {
|
|
737
|
+
if (!isRootedDiskPath(path)) {
|
|
738
|
+
return path;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
const segments = path.split("/");
|
|
742
|
+
for (let i = 0; i < segments.length; i++) {
|
|
743
|
+
segments[i] = encodeDynamicURIPathSegment(segments[i], preserveFinalExtension && i === segments.length - 1);
|
|
744
|
+
}
|
|
745
|
+
if (isRootedDiskPath(segments.join("/"))) {
|
|
746
|
+
segments[0] = forceEncodeDynamicURIPathSegment(segments[0], segments.length === 1 && preserveFinalExtension);
|
|
747
|
+
}
|
|
748
|
+
return segments.join("/");
|
|
749
|
+
}
|
|
750
|
+
function encodeDynamicURIPathWithSuffix(path, suffix) {
|
|
751
|
+
if (suffix === "") {
|
|
752
|
+
return encodeDynamicURIPath(path);
|
|
753
|
+
}
|
|
754
|
+
const slash = path.lastIndexOf("/");
|
|
755
|
+
const before = slash === -1 ? "" : encodeDynamicURIPath(path.substring(0, slash), false) + "/";
|
|
756
|
+
return before + forceEncodeDynamicURIPathSegmentWithSuffix(path.substring(slash + 1), suffix);
|
|
757
|
+
}
|
|
758
|
+
function dynamicURIPathNeedsEncoding(path) {
|
|
759
|
+
return path === "" ||
|
|
760
|
+
path.startsWith("/") ||
|
|
761
|
+
path.endsWith("/") ||
|
|
762
|
+
path.includes("//") ||
|
|
763
|
+
path.includes("\\") ||
|
|
764
|
+
dynamicURIPathSegmentEscapeRegExp.test(path);
|
|
765
|
+
}
|
|
766
|
+
function dynamicURIPathSegmentNeedsEncoding(segment) {
|
|
767
|
+
return segment === "" ||
|
|
768
|
+
segment === "." ||
|
|
769
|
+
segment === ".." ||
|
|
770
|
+
segment.startsWith(dynamicURIPathSegmentEscapePrefix) ||
|
|
771
|
+
segment.startsWith(dynamicURIModuleSpecifierEscapePrefix) ||
|
|
772
|
+
segment.startsWith(dynamicURINoPathEscapePrefix) ||
|
|
773
|
+
segment.includes("\\");
|
|
774
|
+
}
|
|
775
|
+
function encodeDynamicURIPathSegment(segment, preserveExtension) {
|
|
776
|
+
if (dynamicURIPathSegmentNeedsEncoding(segment)) {
|
|
777
|
+
return forceEncodeDynamicURIPathSegment(segment, preserveExtension);
|
|
778
|
+
}
|
|
779
|
+
return segment;
|
|
780
|
+
}
|
|
781
|
+
function forceEncodeDynamicURIPathSegment(segment, preserveExtension) {
|
|
782
|
+
let extension = "";
|
|
783
|
+
if (preserveExtension && segment !== "." && segment !== "..") {
|
|
784
|
+
[segment, extension] = splitDynamicURIFileExtension(segment);
|
|
785
|
+
}
|
|
786
|
+
let hex = "";
|
|
787
|
+
const encoded = encodeURIComponent(segment);
|
|
788
|
+
for (let i = 0; i < encoded.length; i++) {
|
|
789
|
+
if (encoded.charCodeAt(i) === CharacterCodesPercent) {
|
|
790
|
+
hex += encoded.slice(i + 1, i + 3).toLowerCase();
|
|
791
|
+
i += 2;
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
hex += encoded.charCodeAt(i).toString(16).padStart(2, "0");
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
return dynamicURIPathSegmentEscapePrefix + hex + "~" + extension;
|
|
798
|
+
}
|
|
799
|
+
function forceEncodeDynamicURIPathSegmentWithSuffix(segment, suffix) {
|
|
800
|
+
const [base, extension] = splitDynamicURIFileExtension(segment);
|
|
801
|
+
return forceEncodeDynamicURIPathSegment(base + "\0" + suffix, false) + extension;
|
|
802
|
+
}
|
|
803
|
+
function splitDynamicURIFileExtension(segment) {
|
|
804
|
+
const extension = getDynamicURIFileExtension(segment);
|
|
805
|
+
return extension === ""
|
|
806
|
+
? [segment, extension]
|
|
807
|
+
: [segment.substring(0, segment.length - extension.length), extension];
|
|
808
|
+
}
|
|
809
|
+
function getDynamicURIFileExtension(segment) {
|
|
810
|
+
const baseStart = segment.lastIndexOf("\\") + 1;
|
|
811
|
+
for (const extension of [".d.ts", ".d.mts", ".d.cts"]) {
|
|
812
|
+
if (segment.endsWith(extension) && segment.length - extension.length >= baseStart) {
|
|
813
|
+
return extension;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
if (segment.endsWith(".ts")) {
|
|
817
|
+
const declaration = segment.indexOf(".d.", baseStart);
|
|
818
|
+
if (declaration !== -1) {
|
|
819
|
+
return segment.substring(declaration);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
const dot = segment.lastIndexOf(".");
|
|
823
|
+
return dot > segment.lastIndexOf("\\") ? segment.substring(dot) : "";
|
|
824
|
+
}
|
|
825
|
+
function decodeDynamicURIPath(path) {
|
|
826
|
+
if (!path.includes(dynamicURIPathSegmentEscapePrefix)) {
|
|
827
|
+
return path;
|
|
828
|
+
}
|
|
829
|
+
return path.split("/").map(decodeDynamicURIPathSegment).join("/");
|
|
830
|
+
}
|
|
831
|
+
function decodeDynamicURIPathSegment(segment) {
|
|
832
|
+
if (!segment.startsWith(dynamicURIPathSegmentEscapePrefix)) {
|
|
833
|
+
return segment;
|
|
834
|
+
}
|
|
835
|
+
const separator = segment.indexOf("~", dynamicURIPathSegmentEscapePrefix.length);
|
|
836
|
+
if (separator === -1) {
|
|
837
|
+
return segment;
|
|
838
|
+
}
|
|
839
|
+
const encoded = segment.slice(dynamicURIPathSegmentEscapePrefix.length, separator);
|
|
840
|
+
const extension = segment.slice(separator + 1);
|
|
841
|
+
if (encoded.length % 2 !== 0 || !/^[0-9a-f]*$/i.test(encoded)) {
|
|
842
|
+
return segment;
|
|
843
|
+
}
|
|
844
|
+
try {
|
|
845
|
+
const decoded = decodeURIComponent(encoded.replace(/../g, value => `%${value}`));
|
|
846
|
+
const suffix = decoded.indexOf("\0");
|
|
847
|
+
return suffix === -1
|
|
848
|
+
? decoded + extension
|
|
849
|
+
: decoded.substring(0, suffix) + extension + decoded.substring(suffix + 1);
|
|
850
|
+
}
|
|
851
|
+
catch {
|
|
852
|
+
return segment;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
function encodeDynamicURINoPath(suffix) {
|
|
856
|
+
let hex = "";
|
|
857
|
+
const encoded = encodeURIComponent(suffix);
|
|
858
|
+
for (let i = 0; i < encoded.length; i++) {
|
|
859
|
+
if (encoded.charCodeAt(i) === CharacterCodesPercent) {
|
|
860
|
+
hex += encoded.substring(i + 1, i + 3).toLowerCase();
|
|
861
|
+
i += 2;
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
hex += encoded.charCodeAt(i).toString(16).padStart(2, "0");
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
return dynamicURINoPathEscapePrefix + hex + "~";
|
|
868
|
+
}
|
|
869
|
+
function decodeDynamicURINoPath(path) {
|
|
870
|
+
if (!path.startsWith(dynamicURINoPathEscapePrefix) || !path.endsWith("~")) {
|
|
871
|
+
return undefined;
|
|
872
|
+
}
|
|
873
|
+
const encoded = path.substring(dynamicURINoPathEscapePrefix.length, path.length - 1);
|
|
874
|
+
if (encoded.length % 2 !== 0 || !/^[0-9a-f]*$/i.test(encoded)) {
|
|
875
|
+
return undefined;
|
|
876
|
+
}
|
|
877
|
+
try {
|
|
878
|
+
return decodeURIComponent(encoded.replace(/../g, value => `%${value}`));
|
|
879
|
+
}
|
|
880
|
+
catch {
|
|
881
|
+
return undefined;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
//# sourceMappingURL=path.js.map
|