Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions types/chrome-remote-interface/chrome-remote-interface-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import CDP = require('chrome-remote-interface');
import Protocol from 'devtools-protocol';

function assertType<T>(value: T): T {
return value;
}

(async () => {
let client: CDP.Client | undefined;
Expand Down Expand Up @@ -41,6 +46,17 @@ import CDP = require('chrome-remote-interface');
await CDP.Close({ ...cdpPort, id: target.id });
}
}

assertType<Promise<void>>(client.send('Network.enable'));
assertType<Promise<Protocol.Page.NavigateResponse>>(client.send('Page.navigate', {url: 'https://github.com'}));
assertType<Promise<Protocol.Page.NavigateResponse>>(client.send('Page.navigate', {url: 'https://github.com'}, 'sessionId'));
client.send('Page.navigate', (error: boolean | Error, response: Protocol.Page.NavigateResponse | CDP.SendError | undefined) => {});
client.send('Page.navigate', {url: 'https://github.com'}, (error: boolean | Error, response: Protocol.Page.NavigateResponse | CDP.SendError | undefined) => {});
client.send('Page.navigate', {url: 'https://github.com'}, 'sessionId', (error: boolean | Error, response: Protocol.Page.NavigateResponse | CDP.SendError | undefined) => {});
// @ts-expect-error
client.send('Page.navigate', (error: boolean, response: CDP.SendError) => {});
// @ts-expect-error
client.send('Page.navigate', (error: boolean, response: Protocol.Page.NavigateResponse) => {});
} finally {
if (client) {
await client.close();
Expand Down
61 changes: 56 additions & 5 deletions types/chrome-remote-interface/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Definitions by: Khairul Azhar Kasmiran <https://github.com/kazarmy>
// Seth Westphal <https://github.com/westy92>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.8
// Minimum TypeScript Version: 3.9

import type ProtocolProxyApi from 'devtools-protocol/types/protocol-proxy-api';
import type ProtocolMappingApi from 'devtools-protocol/types/protocol-mapping';
Expand Down Expand Up @@ -45,6 +45,18 @@ declare namespace CDP {
sessionId?: string | undefined;
}

interface SendError {
code: number;
message: string;
data?: string | undefined;
}

interface SendCallback<T extends keyof ProtocolMappingApi.Commands> {
(error: true, response: SendError): void;
(error: false, response: ProtocolMappingApi.Commands[T]['returnType']): void;
(error: Error, response: undefined): void;
}

interface Target {
description: string;
devtoolsFrontendUrl: string;
Expand All @@ -65,9 +77,9 @@ declare namespace CDP {
}

/////////////////////////////////////////////////
// Generated from https://app.quicktype.io/,
// TypeEnum simplified.
// Source: https://github.com/cyrus-and/chrome-remote-interface/blob/v0.30.1/lib/protocol.json
// Generated with https://app.quicktype.io/, Name: Protocol, Language: TypeScript, Interfaces only.
// Manually done: TypeEnum simplified, add " | undefined" for optional properties.
// Source: https://github.com/ChromeDevTools/devtools-protocol/blob/master/json/ (merge JSON objects)
/////////////////////////////////////////////////
interface Protocol {
version: Version;
Expand Down Expand Up @@ -149,6 +161,12 @@ declare namespace CDP {
on<T extends keyof ProtocolMappingApi.Events>(event: T, callback: (params: ProtocolMappingApi.Events[T][0], sessionId?: string) => void): void;
// '<domain>.<method>.<sessionId>' i.e. Network.requestWillBeSent.abc123
on(event: string, callback: (params: object, sessionId?: string) => void): void;
// client.send(method, [params], [sessionId], [callback])
send<T extends keyof ProtocolMappingApi.Commands>(event: T, callback: SendCallback<T>): void;
send<T extends keyof ProtocolMappingApi.Commands>(event: T, params: ProtocolMappingApi.Commands[T]['paramsType'][0], callback: SendCallback<T>): void;
send<T extends keyof ProtocolMappingApi.Commands>(event: T, params: ProtocolMappingApi.Commands[T]['paramsType'][0], sessionId: string, callback: SendCallback<T>): void;
send<T extends keyof ProtocolMappingApi.Commands>(event: T, params?: ProtocolMappingApi.Commands[T]['paramsType'][0], sessionId?: string):
Promise<ProtocolMappingApi.Commands[T]['returnType']>;

// stable domains
Browser: ProtocolProxyApi.BrowserApi;
Expand All @@ -166,36 +184,69 @@ declare namespace CDP {
Runtime: ProtocolProxyApi.RuntimeApi;
Security: ProtocolProxyApi.SecurityApi;
Target: ProtocolProxyApi.TargetApi;
// unstable domains

// deprecated domains
/** @deprecated This domain is deprecated - use Runtime or Log instead. */
Console: ProtocolProxyApi.ConsoleApi;
/** @deprecated This domain is deprecated. */
Schema: ProtocolProxyApi.SchemaApi;

// experimental domains
/** @deprecated this API is experimental. */
Accessibility: ProtocolProxyApi.AccessibilityApi;
/** @deprecated this API is experimental. */
Animation: ProtocolProxyApi.AnimationApi;
/** @deprecated this API is experimental. */
ApplicationCache: ProtocolProxyApi.ApplicationCacheApi;
/** @deprecated this API is experimental. */
Audits: ProtocolProxyApi.AuditsApi;
/** @deprecated this API is experimental. */
BackgroundService: ProtocolProxyApi.BackgroundServiceApi;
/** @deprecated this API is experimental. */
CacheStorage: ProtocolProxyApi.CacheStorageApi;
/** @deprecated this API is experimental. */
Cast: ProtocolProxyApi.CastApi;
/** @deprecated this API is experimental. */
CSS: ProtocolProxyApi.CSSApi;
/** @deprecated this API is experimental. */
Database: ProtocolProxyApi.DatabaseApi;
/** @deprecated this API is experimental. */
DeviceOrientation: ProtocolProxyApi.DeviceOrientationApi;
/** @deprecated this API is experimental. */
DOMSnapshot: ProtocolProxyApi.DOMSnapshotApi;
/** @deprecated this API is experimental. */
DOMStorage: ProtocolProxyApi.DOMStorageApi;
/** @deprecated this API is experimental. */
Fetch: ProtocolProxyApi.FetchApi;
/** @deprecated this API is experimental. */
HeadlessExperimental: ProtocolProxyApi.HeadlessExperimentalApi;
/** @deprecated this API is experimental. */
HeapProfiler: ProtocolProxyApi.HeapProfilerApi;
/** @deprecated this API is experimental. */
IndexedDB: ProtocolProxyApi.IndexedDBApi;
/** @deprecated this API is experimental. */
Inspector: ProtocolProxyApi.InspectorApi;
/** @deprecated this API is experimental. */
LayerTree: ProtocolProxyApi.LayerTreeApi;
/** @deprecated this API is experimental. */
Media: ProtocolProxyApi.MediaApi;
/** @deprecated this API is experimental. */
Memory: ProtocolProxyApi.MemoryApi;
/** @deprecated this API is experimental. */
Overlay: ProtocolProxyApi.OverlayApi;
/** @deprecated this API is experimental. */
ServiceWorker: ProtocolProxyApi.ServiceWorkerApi;
/** @deprecated this API is experimental. */
Storage: ProtocolProxyApi.StorageApi;
/** @deprecated this API is experimental. */
SystemInfo: ProtocolProxyApi.SystemInfoApi;
/** @deprecated this API is experimental. */
Tethering: ProtocolProxyApi.TetheringApi;
/** @deprecated this API is experimental. */
Tracing: ProtocolProxyApi.TracingApi;
/** @deprecated this API is experimental. */
WebAudio: ProtocolProxyApi.WebAudioApi;
/** @deprecated this API is experimental. */
WebAuthn: ProtocolProxyApi.WebAuthnApi;
} & EventPromises<ProtocolMappingApi.Events> & EventCallbacks<ProtocolMappingApi.Events>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import Autosave from "@ckeditor/ckeditor5-autosave";
import { AutosaveAdapter, AutosaveConfig } from "@ckeditor/ckeditor5-autosave/src/autosave";
import { Editor } from "@ckeditor/ckeditor5-core";
import { Autosave } from '@ckeditor/ckeditor5-autosave';
import { AutosaveAdapter, AutosaveConfig } from '@ckeditor/ckeditor5-autosave/src/autosave';
import { Editor } from '@ckeditor/ckeditor5-core';

class MyEditor extends Editor {}
const plugin = new Autosave.Autosave(new MyEditor());
plugin.once("click", () => {});
const isContext: boolean = Autosave.Autosave.isContextPlugin;
const state: "synchronized" | "waiting" | "saving" = plugin.state;
plugin.adapter.save(new MyEditor());
const myEditor = new MyEditor();
const plugin = new Autosave(myEditor);
plugin.once('click', () => {});
// $ExpectType boolean
Autosave.isContextPlugin;
const state: 'synchronized' | 'waiting' | 'saving' = 'saving';
plugin.state === state;
plugin.adapter.save(myEditor);

const adapter: AutosaveAdapter = {
save(editor: Editor) {
Expand All @@ -16,7 +19,7 @@ const adapter: AutosaveAdapter = {
};

let config: AutosaveConfig = {
save(editor: Editor) {
save(editor) {
return Promise.reject(editor);
},
};
Expand All @@ -29,3 +32,6 @@ config = {
},
waitingTime: 0,
};

new MyEditor({ autosave: config });
new MyEditor({ autosave: adapter });
9 changes: 2 additions & 7 deletions types/ckeditor__ckeditor5-autosave/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// Type definitions for @ckeditor/ckeditor5-autosave 27.1
// Type definitions for @ckeditor/ckeditor5-autosave 29.0
// Project: https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-autosave
// Definitions by: Federico Panico <https://github.com/fedemp>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 4.3
import Autosave from './src/autosave';

declare const _default: {
Autosave: typeof Autosave;
};

export default _default;
export { default as Autosave } from './src/autosave';
4 changes: 2 additions & 2 deletions types/ckeditor__ckeditor5-autosave/src/autosave.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export default class AutoSave extends Plugin {
}

export interface AutosaveAdapter {
save(editor: Editor): Promise<any>;
save(editor: Editor): Promise<unknown>;
}

export interface AutosaveConfig {
waitingTime?: number | undefined;
save?(editor: Editor): Promise<any>;
save?(editor: Editor): Promise<unknown>;
}
1 change: 0 additions & 1 deletion types/ckeditor__ckeditor5-autosave/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"es6",
"dom"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Autosave from "@ckeditor/ckeditor5-autosave";
import { AutosaveAdapter, AutosaveConfig } from "@ckeditor/ckeditor5-autosave/src/autosave";
import { Editor } from "@ckeditor/ckeditor5-core";

class MyEditor extends Editor {}
const plugin = new Autosave.Autosave(new MyEditor());
plugin.once("click", () => {});
const isContext: boolean = Autosave.Autosave.isContextPlugin;
const state: "synchronized" | "waiting" | "saving" = plugin.state;
plugin.adapter.save(new MyEditor());

const adapter: AutosaveAdapter = {
save(editor: Editor) {
return Promise.resolve(editor);
},
};

let config: AutosaveConfig = {
save(editor: Editor) {
return Promise.reject(editor);
},
};
config = {
waitingTime: 0,
};
config = {
save(editor: Editor) {
return Promise.reject(editor);
},
waitingTime: 0,
};
12 changes: 12 additions & 0 deletions types/ckeditor__ckeditor5-autosave/v27/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Type definitions for @ckeditor/ckeditor5-autosave 27.1
// Project: https://github.com/ckeditor/ckeditor5/tree/master/packages/ckeditor5-autosave
// Definitions by: Federico Panico <https://github.com/fedemp>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 4.3
import Autosave from './src/autosave';

declare const _default: {
Autosave: typeof Autosave;
};

export default _default;
22 changes: 22 additions & 0 deletions types/ckeditor__ckeditor5-autosave/v27/src/autosave.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Editor, Plugin } from "@ckeditor/ckeditor5-core";
import PendingActions from "@ckeditor/ckeditor5-core/src/pendingactions";

export default class AutoSave extends Plugin {
adapter: AutosaveAdapter;
state: "synchronized" | "waiting" | "saving";

static pluginName: "Autosave";
static requires: [typeof PendingActions];

init(): void;
destroy(): void;
}

export interface AutosaveAdapter {
save(editor: Editor): Promise<unknown>;
}

export interface AutosaveConfig {
waitingTime?: number | undefined;
save?(editor: Editor): Promise<unknown>;
}
35 changes: 35 additions & 0 deletions types/ckeditor__ckeditor5-autosave/v27/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@ckeditor/ckeditor5-autosave/*": [
"ckeditor__ckeditor5-autosave/v27/*"
],
"@ckeditor/ckeditor5-autosave": [
"ckeditor__ckeditor5-autosave/v27"
],
"@ckeditor/*": [
"ckeditor__*"
]
}
},
"files": [
"index.d.ts",
"ckeditor__ckeditor5-autosave-tests.ts"
]
}
3 changes: 3 additions & 0 deletions types/ckeditor__ckeditor5-autosave/v27/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
14 changes: 10 additions & 4 deletions types/ckeditor__ckeditor5-build-inline/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for @ckeditor/ckeditor5-build-inline 28.0
// Type definitions for @ckeditor/ckeditor5-build-inline 29.0
// Project: https://ckeditor.com/docs/ckeditor5/latest/builds/index.html
// Definitions by: Federico Panico <https://github.com/fedemp>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand Down Expand Up @@ -80,12 +80,18 @@ export default class InlineEditor extends InlineEditorBase {
];
};
image: {
toolbar: ['imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative'];
toolbar: [
'imageStyle:inline',
'imageStyle:block',
'imageStyle:side',
'|',
'toggleImageCaption',
'imageTextAlternative',
];
};
table: {
contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells'];
};
// This value must be kept in sync with the language defined in webpack.config.js.
language: 'en';
language: string;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import BuildInline from '@ckeditor/ckeditor5-build-inline';
import { Editor } from '@ckeditor/ckeditor5-core';

class MyEditor extends Editor {}
const editor = new MyEditor();

BuildInline.create('', BuildInline.defaultConfig);
BuildInline.builtinPlugins.forEach(Plugin => new Plugin(editor));

const el = document.querySelector('#editor');
if (el instanceof HTMLElement) {
BuildInline.create(el)
.then(editor => {
editor.locale.t('').startsWith('');
})
.catch(error => {
console.error(error);
});
}
Loading