22import * as vscode from 'vscode'
33import { defaultJsSupersetLangs } from '@zardoy/vscode-utils/build/langs'
44import { getActiveRegularEditor } from '@zardoy/vscode-utils'
5- import { extensionCtx , getExtensionSettingId , getExtensionCommandId } from 'vscode-framework'
5+ import { extensionCtx , getExtensionSettingId } from 'vscode-framework'
66import { pickObj } from '@zardoy/utils'
7- import { TriggerCharacterCommand } from '../typescript/src/ipcTypes'
87import { Configuration } from './configurationType'
98import webImports from './webImports'
109import { sendCommand } from './sendCommand'
1110import { registerEmmet } from './emmet'
1211import experimentalPostfixes from './experimentalPostfixes'
1312import migrateSettings from './migrateSettings'
1413import figIntegration from './figIntegration'
14+ import apiCommands from './apiCommands'
1515
1616export const activateTsPlugin = ( tsApi : { configurePlugin ; onCompletionAccepted } ) => {
1717 let webWaitingForConfigSync = false
@@ -79,23 +79,6 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
7979 }
8080 } )
8181
82- const sharedRequest = ( type : TriggerCharacterCommand , { offset, relativeOffset = 0 } : RequestOptions ) => {
83- const { activeTextEditor } = vscode . window
84- if ( ! activeTextEditor ) return
85- const { document, selection } = activeTextEditor
86- offset ??= document . offsetAt ( selection . active ) + relativeOffset
87- return sendCommand ( type , { document, position : document . positionAt ( offset ) } )
88- }
89-
90- type RequestOptions = Partial < {
91- offset : number
92- relativeOffset : number
93- } >
94- vscode . commands . registerCommand ( getExtensionCommandId ( 'getNodeAtPosition' as never ) , async ( options : RequestOptions = { } ) =>
95- sharedRequest ( 'nodeAtPosition' , options ) ,
96- )
97- vscode . commands . registerCommand ( getExtensionCommandId ( 'getNodePath' as never ) , async ( options : RequestOptions = { } ) => sharedRequest ( 'nodePath' , options ) )
98-
9982 if ( process . env . PLATFORM === 'web' ) {
10083 const possiblySyncConfig = async ( ) => {
10184 const { activeTextEditor } = vscode . window
@@ -113,6 +96,7 @@ export const activateTsPlugin = (tsApi: { configurePlugin; onCompletionAccepted
11396 experimentalPostfixes ( )
11497 void registerEmmet ( )
11598 webImports ( )
99+ apiCommands ( )
116100
117101 figIntegration ( )
118102}
0 commit comments