{"version":3,"sources":["browser/monaco-frontend-module.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAGnC,OAAO,EAAC,eAAe,EAAwB,UAAU,EAAC,MAAM,WAAW,CAAC;AA4C5E,eAAO,MAAM,oBAAoB,iBA8D/B,CAAC;AAGH,eAAO,MAAM,0BAA0B,eAAuC,CAAC;AAE/E,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CA6HvH","file":"../../src/browser/monaco-frontend-module.d.ts","sourcesContent":["import '../assets/style/index.css';\r\n// import '../assets/style/symbol-icons.css';\r\n// import '../assets/style/symbol-icons.svg';\r\nimport {ContainerModule, decorate, injectable, interfaces} from 'inversify';\r\nimport {ColorRegistry} from '@tartjs/core/lib/browser/color-registry';\r\nimport {QuickInputService} from '@tartjs/core/lib/common/quick-pick-service';\r\nimport {bindContributionProvider, CommandContribution, MenuContribution} from '@tartjs/core/lib/common';\r\nimport {MonacoColorRegistry} from './monaco-color-registry';\r\nimport {MonacoThemingService} from './monaco-theming-service';\r\nimport MonacoTextmateModuleBinder from './textmate/monaco-textmate-frontend-bindings';\r\nimport {MonacoQuickInputImplementation, MonacoQuickInputService} from './monaco-quick-input-service';\r\nimport {MonacoEditorFactory, MonacoEditorProvider} from './monaco-editor-provider';\r\nimport {MonacoEditorCommandHandlers} from './monaco-command';\r\nimport {MonacoEditorService} from './monaco-editor-service';\r\nimport {MonacoToProtocolConverter} from './monaco-to-protocol-converter';\r\nimport {\r\n  ContextKeyService,\r\n  createPreferenceProxy,\r\n  KeybindingContribution,\r\n  OVERRIDE_PROPERTY_PATTERN,\r\n  PreferenceChange,\r\n  PreferenceSchemaProvider,\r\n  PreferenceScope,\r\n  PreferenceService,\r\n  QuickAccessContribution,\r\n  QuickAccessRegistry\r\n} from '@tartjs/core';\r\nimport {MonacoKeybindingContribution} from './monaco-keybinding';\r\nimport {MonacoCommandRegistry} from './monaco-command-registry';\r\nimport {MonacoEditorModelFactory, MonacoTextModelService} from './monaco-text-model-service';\r\nimport {ProtocolToMonacoConverter} from './protocol-to-monaco-converter';\r\nimport {MonacoContextMenuService} from './monaco-context-menu';\r\nimport {MonacoEditorServices} from './monaco-editor';\r\nimport {MonacoDiffNavigatorFactory} from './monaco-diff-navigator-factory';\r\nimport {MonacoCommandService, MonacoCommandServiceFactory} from './monaco-command-service';\r\nimport {MonacoContextKeyService} from './monaco-context-key-service';\r\nimport {MonacoBulkEditService} from './monaco-bulk-edit-service';\r\nimport {MonacoQuickAccessRegistry} from './monaco-quick-access-registry';\r\nimport {MonacoLanguages} from './monaco-languages';\r\nimport {LanguageService} from '@tartjs/core/lib/browser/language-service';\r\nimport {WorkspaceSymbolCommand} from './workspace-symbol-command';\r\nimport {TextEditorProvider} from '@tartjs/editor/lib/browser/editor';\r\nimport {DiffNavigatorProvider} from '@tartjs/editor/lib/browser/diff-navigator';\r\n\r\ndecorate(injectable(), monaco.contextKeyService.ContextKeyService);\r\n\r\nMonacoThemingService.init();\r\nexport const MonacoFrontendModule = new ContainerModule((bind, unbind, isBound, rebind) => {\r\n  bind(MonacoThemingService).toSelf().inSingletonScope();\r\n\r\n  bind(MonacoContextKeyService).toSelf().inSingletonScope();\r\n  rebind(ContextKeyService).toService(MonacoContextKeyService);\r\n\r\n  bind(MonacoCommandRegistry).toSelf().inSingletonScope();\r\n\r\n  bind(MonacoConfigurationService).toDynamicValue(({container}) =>\r\n      createMonacoConfigurationService(container)\r\n  ).inSingletonScope();\r\n  bind(monaco.contextKeyService.ContextKeyService).toDynamicValue(({container}) =>\r\n      new monaco.contextKeyService.ContextKeyService(container.get(MonacoConfigurationService))\r\n  ).inSingletonScope();\r\n\r\n  bind(MonacoToProtocolConverter).toSelf().inSingletonScope();\r\n  bind(ProtocolToMonacoConverter).toSelf().inSingletonScope();\r\n\r\n  bind(MonacoLanguages).toSelf().inSingletonScope();\r\n  rebind(LanguageService).toService(MonacoLanguages);\r\n  bind(WorkspaceSymbolCommand).toSelf().inSingletonScope();\r\n  for (const identifier of [CommandContribution, KeybindingContribution, MenuContribution, QuickAccessContribution]) {\r\n    bind(identifier).toService(WorkspaceSymbolCommand);\r\n  }\r\n\r\n  bind(MonacoBulkEditService).toSelf().inSingletonScope();\r\n  bind(MonacoEditorService).toSelf().inSingletonScope();\r\n  bind(MonacoTextModelService).toSelf().inSingletonScope();\r\n  bind(MonacoContextMenuService).toSelf().inSingletonScope();\r\n  bind(MonacoEditorServices).toSelf().inSingletonScope();\r\n  bind(MonacoEditorProvider).toSelf().inSingletonScope();\r\n  bindContributionProvider(bind, MonacoEditorFactory);\r\n  bindContributionProvider(bind, MonacoEditorModelFactory);\r\n  bind(MonacoCommandService).toSelf().inTransientScope();\r\n  bind(MonacoCommandServiceFactory).toAutoFactory(MonacoCommandService);\r\n\r\n  bind(TextEditorProvider).toProvider(context =>\r\n      uri => context.container.get(MonacoEditorProvider).get(uri)\r\n  );\r\n\r\n  bind(MonacoQuickAccessRegistry).toSelf().inSingletonScope();\r\n  bind(QuickAccessRegistry).toService(MonacoQuickAccessRegistry);\r\n\r\n  bind(MonacoDiffNavigatorFactory).toSelf().inSingletonScope();\r\n  bind(DiffNavigatorProvider).toFactory(context =>\r\n      editor => context.container.get(MonacoEditorProvider).getDiffNavigator(editor)\r\n  );\r\n\r\n  bind(CommandContribution).to(MonacoEditorCommandHandlers).inSingletonScope();\r\n\r\n  bind(MonacoColorRegistry).toSelf().inSingletonScope();\r\n  rebind(ColorRegistry).toService(MonacoColorRegistry);\r\n\r\n  MonacoTextmateModuleBinder(bind, unbind, isBound, rebind);\r\n\r\n  bind(MonacoKeybindingContribution).toSelf().inSingletonScope();\r\n  bind(KeybindingContribution).toService(MonacoKeybindingContribution);\r\n\r\n  bind(MonacoQuickInputImplementation).toSelf().inSingletonScope();\r\n\r\n  bind(MonacoQuickInputService).toSelf().inSingletonScope();\r\n  bind(QuickInputService).toService(MonacoQuickInputService);\r\n});\r\n\r\n\r\nexport const MonacoConfigurationService = Symbol('MonacoConfigurationService');\r\n\r\nexport function createMonacoConfigurationService(container: interfaces.Container): monaco.services.IConfigurationService {\r\n  const preferences = container.get<PreferenceService>(PreferenceService);\r\n  const preferenceSchemaProvider = container.get<PreferenceSchemaProvider>(PreferenceSchemaProvider);\r\n  const service = monaco.services.StaticServices.configurationService.get();\r\n  const _configuration = service._configuration;\r\n\r\n  _configuration.getValue = (section, overrides) => {\r\n    const overrideIdentifier = overrides && 'overrideIdentifier' in overrides && overrides['overrideIdentifier'] as string || undefined;\r\n    const resourceUri = overrides && 'resource' in overrides && !!overrides['resource'] && overrides['resource'].toString();\r\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n    const proxy = createPreferenceProxy<{ [key: string]: any }>(preferences, preferenceSchemaProvider.getCombinedSchema(), {\r\n      resourceUri, overrideIdentifier, style: 'both'\r\n    });\r\n    if (section) {\r\n      return proxy[section];\r\n    }\r\n    return proxy;\r\n  };\r\n\r\n  const toTarget = (scope: PreferenceScope): monaco.services.ConfigurationTarget => {\r\n    switch (scope) {\r\n      case PreferenceScope.Default:\r\n        return monaco.services.ConfigurationTarget.DEFAULT;\r\n        // case PreferenceScope.User:\r\n        //     return monaco.services.ConfigurationTarget.USER;\r\n        // case PreferenceScope.Workspace:\r\n        //     return monaco.services.ConfigurationTarget.WORKSPACE;\r\n        // case PreferenceScope.Folder:\r\n        //     return monaco.services.ConfigurationTarget.WORKSPACE_FOLDER;\r\n    }\r\n  };\r\n\r\n  interface FireDidChangeConfigurationContext {\r\n    changes: PreferenceChange[];\r\n    affectedKeys: Set<string>;\r\n    keys: Set<string>;\r\n    overrides: Map<string, Set<string>>\r\n  }\r\n\r\n  const newFireDidChangeConfigurationContext = (): FireDidChangeConfigurationContext => ({\r\n    changes: [],\r\n    affectedKeys: new Set<string>(),\r\n    keys: new Set<string>(),\r\n    overrides: new Map<string, Set<string>>()\r\n  });\r\n  const fireDidChangeConfiguration = (source: monaco.services.ConfigurationTarget, context: FireDidChangeConfigurationContext): void => {\r\n    if (!context.affectedKeys.size) {\r\n      return;\r\n    }\r\n    const overrides: [string, string[]][] = [];\r\n    for (const [override, values] of context.overrides) {\r\n      overrides.push([override, [...values]]);\r\n    }\r\n    service._onDidChangeConfiguration.fire({\r\n      change: {\r\n        keys: [...context.keys],\r\n        overrides\r\n      },\r\n      affectedKeys: [...context.affectedKeys],\r\n      source,\r\n      affectsConfiguration: (prefix, options) => {\r\n        if (!context.affectedKeys.has(prefix)) {\r\n          return false;\r\n        }\r\n        for (const change of context.changes) {\r\n          const overridden = preferences.overriddenPreferenceName(change.preferenceName);\r\n          const preferenceName = overridden ? overridden.preferenceName : change.preferenceName;\r\n          if (preferenceName.startsWith(prefix)) {\r\n            if (options?.overrideIdentifier !== undefined) {\r\n              if (overridden && overridden.overrideIdentifier !== options?.overrideIdentifier) {\r\n                continue;\r\n              }\r\n            }\r\n            if (change.affects(options?.resource?.toString())) {\r\n              return true;\r\n            }\r\n          }\r\n        }\r\n        return false;\r\n      }\r\n    });\r\n  };\r\n\r\n  preferences.onPreferencesChanged(event => {\r\n    let source: monaco.services.ConfigurationTarget | undefined;\r\n    let context = newFireDidChangeConfigurationContext();\r\n    for (let key of Object.keys(event)) {\r\n      const change = event[key];\r\n      const target = toTarget(change.scope);\r\n      if (source !== undefined && target !== source) {\r\n        fireDidChangeConfiguration(source, context);\r\n        context = newFireDidChangeConfigurationContext();\r\n      }\r\n      context.changes.push(change);\r\n      source = target;\r\n\r\n      let overrideKeys: Set<string> | undefined;\r\n      if (key.startsWith('[')) {\r\n        const index = key.indexOf('.');\r\n        const override = key.substring(0, index);\r\n        const overrideIdentifier = override.match(OVERRIDE_PROPERTY_PATTERN)?.[1];\r\n        if (overrideIdentifier) {\r\n          context.keys.add(override);\r\n          context.affectedKeys.add(override);\r\n          overrideKeys = context.overrides.get(overrideIdentifier) || new Set<string>();\r\n          context.overrides.set(overrideIdentifier, overrideKeys);\r\n          key = key.substring(index + 1);\r\n        }\r\n      }\r\n      while (key) {\r\n        if (overrideKeys) {\r\n          overrideKeys.add(key);\r\n        }\r\n        context.keys.add(key);\r\n        context.affectedKeys.add(key);\r\n        const index = key.lastIndexOf('.');\r\n        key = key.substring(0, index);\r\n      }\r\n    }\r\n    if (source) {\r\n      fireDidChangeConfiguration(source, context);\r\n    }\r\n  });\r\n\r\n  return service;\r\n}\r\n"]}