<commit_before>/*-----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/

import {
  ILayoutRestorer,
  IRouter,
  JupyterFrontEnd,
  JupyterFrontEndPlugin
} from '@jupyterlab/application';

import {
  Dialog,
  ICommandPalette,
  ISplashScreen,
  IWindowResolver,
  WindowResolver,
  Printing
} from '@jupyterlab/apputils';

import {
  Debouncer,
  IRateLimiter,
  ISettingRegistry,
  IStateDB,
  SettingRegistry,
  StateDB,
  Throttler,
  URLExt
} from '@jupyterlab/coreutils';

import { defaultIconRegistry } from '@jupyterlab/ui-components';

import { PromiseDelegate } from '@phosphor/coreutils';

import { DisposableDelegate } from '@phosphor/disposable';

import { Palette } from './palette';

import { themesPlugin, themesPaletteMenuPlugin } from './themeplugins';

/**
 * The interval in milliseconds before recover options appear during splash.
 */
const SPLASH_RECOVER_TIMEOUT = 12000;

/**
 * The command IDs used by the apputils plugin.
 */
namespace CommandIDs {
  export const loadState = 'apputils:load-statedb';

  export const print = 'apputils:print';

  export const reset = 'apputils:reset';

  export const resetOnLoad = 'apputils:reset-on-load';
}

/**
 * The default command palette extension.
 */
const palette: JupyterFrontEndPlugin<ICommandPalette> = {
  activate: Palette.activate,
  id: '@jupyterlab/apputils-extension:palette',
  provides: ICommandPalette,
  autoStart: true
};

/**
 * The default command palette's restoration extension.
 *
 * #### Notes
 * The command palette's restoration logic is handled separately from the
 * command palette provider extension because the layout restorer dependency
 * causes the command palette to be unavailable to other extensions earlier
 * in the application load cycle.
 */
const paletteRestorer: JupyterFrontEndPlugin<void> = {
  activate: Palette.restore,
  id: '@jupyterlab/apputils-extension:palette-restorer',
  requires: [ILayoutRestorer],
  autoStart: true
};

/**
 * The default setting registry provider.
 */
const settings: JupyterFrontEndPlugin<ISettingRegistry> = {
  id: '@jupyterlab/apputils-extension:settings',
  activate: async (app: JupyterFrontEnd): Promise<ISettingRegistry> => {
    const connector = app.serviceManager.settings;
    const plugins = (await connector.list()).values;

    return new SettingRegistry({ connector, plugins });
  },
  autoStart: true,
  provides: ISettingRegistry
};

/**
 * The default window name resolver provider.
 */
const resolver: JupyterFrontEndPlugin<IWindowResolver> = {
  id: '@jupyterlab/apputils-extension:resolver',
  autoStart: true,<commit_msg>Handle setting plugin filtering at the setting registry plugin level instead of filtering via the service manager.<commit_after>/*-----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/

import {
  ILayoutRestorer,
  IRouter,
  JupyterFrontEnd,
  JupyterFrontEndPlugin
} from '@jupyterlab/application';

import {
  Dialog,
  ICommandPalette,
  ISplashScreen,
  IWindowResolver,
  WindowResolver,
  Printing
} from '@jupyterlab/apputils';

import {
  DataConnector,
  Debouncer,
  IRateLimiter,
  ISettingRegistry,
  IStateDB,
  PageConfig,
  SettingRegistry,
  StateDB,
  Throttler,
  URLExt
} from '@jupyterlab/coreutils';

import { defaultIconRegistry } from '@jupyterlab/ui-components';

import { PromiseDelegate } from '@phosphor/coreutils';

import { DisposableDelegate } from '@phosphor/disposable';

import { Palette } from './palette';

import { themesPlugin, themesPaletteMenuPlugin } from './themeplugins';

/**
 * The interval in milliseconds before recover options appear during splash.
 */
const SPLASH_RECOVER_TIMEOUT = 12000;

/**
 * The command IDs used by the apputils plugin.
 */
namespace CommandIDs {
  export const loadState = 'apputils:load-statedb';

  export const print = 'apputils:print';

  export const reset = 'apputils:reset';

  export const resetOnLoad = 'apputils:reset-on-load';
}

/**
 * The default command palette extension.
 */
const palette: JupyterFrontEndPlugin<ICommandPalette> = {
  activate: Palette.activate,
  id: '@jupyterlab/apputils-extension:palette',
  provides: ICommandPalette,
  autoStart: true
};

/**
 * The default command palette's restoration extension.
 *
 * #### Notes
 * The command palette's restoration logic is handled separately from the
 * command palette provider extension because the layout restorer dependency
 * causes the command palette to be unavailable to other extensions earlier
 * in the application load cycle.
 */
const paletteRestorer: JupyterFrontEndPlugin<void> = {
  activate: Palette.restore,
  id: '@jupyterlab/apputils-extension:palette-restorer',
  requires: [ILayoutRestorer],
  autoStart: true
};

/**
 * The default setting registry provider.
 */
const settings: JupyterFrontEndPlugin<ISettingRegistry> = {
  id: '@jupyterlab/apputils-extension:settings',
  activate: async (app: JupyterFrontEnd): Promise<ISettingRegistry> => {
    const connector = new (class SettingConnector extends DataConnector<
      ISettingRegistry.IPlugin,
      string
    > {
      fetch(id: string): Promise<ISettingRegistry.IPlugin> {
        return app.serviceManager.settings.fetch(id);
      }

      async list(): Promise<{
        ids: string[];
        values: ISettingRegistry.IPlugin[];
      }> {
        const { ids, values } = await app.serviceManager.settings.list();
        const filtered = {
          ids: ids.filter(id => !PageConfig.Extension.isDisabled(id)),
          values: values.filter(
            ({ id }) => !PageConfig.Extension.isDisabled(id)
          )
        };
        return filtered;
      }
    })();
    const plugins = (await connector.list()).values;

    return new SettingRegistry({ connector, plugins });
  },
  autoStart: true,
  provides: ISettingRegistry
};

/**
 * The default window name resolver provider.
 */
const resolver: JupyterFrontEndPlugin<IWindowResolver> = {
  id: '@jupyterlab/apputils-extension:resolver',
  autoStart: true,
{'fraction_non_alphanumeric': 0.14895292079987404, 'fraction_numerical': 0.001574555188159345, 'mean_word_length': 3.359643102264928, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '810276', 'n_tokens_mistral': 1868, 'n_tokens_neox': 1801, 'n_words': 481}