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
24 changes: 24 additions & 0 deletions notNeededPackages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,10 @@
"libraryName": "@guardian/prosemirror-invisibles",
"asOfVersion": "1.3.3"
},
"gulp-cond": {
"libraryName": "gulp-cond",
"asOfVersion": "2.0.0"
},
"gulp-pug": {
"libraryName": "gulp-pug",
"asOfVersion": "4.0.0"
Expand Down Expand Up @@ -4129,6 +4133,10 @@
"libraryName": "lru-cache",
"asOfVersion": "7.10.0"
},
"ltijs": {
"libraryName": "ltijs",
"asOfVersion": "7.0.0"
},
"lucasmogari__react-pagination": {
"libraryName": "@lucasmogari/react-pagination",
"asOfVersion": "1.1.4"
Expand Down Expand Up @@ -4413,6 +4421,10 @@
"libraryName": "meow",
"asOfVersion": "6.0.0"
},
"mercadopago": {
"libraryName": "mercadopago",
"asOfVersion": "2.0.0"
},
"merge-refs": {
"libraryName": "merge-refs",
"asOfVersion": "1.1.0"
Expand Down Expand Up @@ -5309,6 +5321,10 @@
"libraryName": "pako",
"asOfVersion": "3.0.0"
},
"pangu": {
"libraryName": "pangu",
"asOfVersion": "5.1.1"
},
"paper": {
"libraryName": "paper",
"asOfVersion": "0.12.3"
Expand Down Expand Up @@ -5643,6 +5659,10 @@
"libraryName": "postcss-nested",
"asOfVersion": "4.2.1"
},
"postcss-prefix-selector": {
"libraryName": "postcss-prefix-selector",
"asOfVersion": "2.2.1"
},
"postcss-preset-env": {
"libraryName": "postcss-preset-env",
"asOfVersion": "8.0.0"
Expand Down Expand Up @@ -7643,6 +7663,10 @@
"libraryName": "@survicate/react-native-survicate",
"asOfVersion": "4.0.0"
},
"svelte-range-slider-pips": {
"libraryName": "svelte-range-slider-pips",
"asOfVersion": "3.0.0"
},
"svg-pan-zoom": {
"libraryName": "svg-pan-zoom",
"asOfVersion": "3.4.0"
Expand Down
15 changes: 10 additions & 5 deletions types/async/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,30 @@ export interface QueueObject<T> {
* Instead of a single task, a tasks array can be submitted.
* The respective callback is used for every task in the list.
*/
push<R>(task: T | T[]): Promise<R>;
push<R>(task: T): Promise<R>;
push<R>(task: T[]): Promise<R>[] | undefined;
push<R, E = Error>(task: T | T[], callback: AsyncResultCallback<R, E>): void;

/**
* Add a new task to the front of the queue
*/
unshift<R>(task: T | T[]): Promise<R>;
unshift<R>(task: T): Promise<R>;
unshift<R>(task: T[]): Promise<R>[] | undefined;
unshift<R, E = Error>(task: T | T[], callback: AsyncResultCallback<R, E>): void;

/**
* The same as `q.push`, except this returns a promise that rejects if an error occurs.
* The `callback` arg is ignored
*/
pushAsync<R>(task: T | T[]): Promise<R>;
pushAsync<R>(task: T): Promise<R>;
pushAsync<R>(task: T[]): Promise<R>[] | undefined;

/**
* The same as `q.unshift`, except this returns a promise that rejects if an error occurs.
* The `callback` arg is ignored
*/
unshiftAsync<R>(task: T | T[]): Promise<R>;
unshiftAsync<R>(task: T): Promise<R>;
unshiftAsync<R>(task: T[]): Promise<R>[] | undefined;

/**
* Remove items from the queue that match a test function.
Expand Down Expand Up @@ -239,7 +243,8 @@ export interface QueueObject<T> {
*/
// FIXME: can not use Omit due to ts version restriction. Replace Pick with Omit, when ts 3.5+ will be allowed
export interface AsyncPriorityQueue<T> extends Pick<QueueObject<T>, Exclude<keyof QueueObject<T>, "push" | "unshift">> {
push<R>(task: T | T[], priority?: number): Promise<R>;
push<R>(task: T, priority?: number): Promise<R>;
push<R>(task: T[], priority?: number): undefined | Promise<R>[];
push<R, E = Error>(task: T | T[], priority: number, callback: AsyncResultCallback<R, E>): void;
}

Expand Down
37 changes: 33 additions & 4 deletions types/async/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,22 +371,37 @@ const q2 = async.queue<string>((task: string, callback: () => void) => {
callback();
}, 1);

// $ExpectType Promise<unknown>
q2.push("task1");
q2.push("task2", error => {
// $ExpectType Promise<unknown>[] | undefined
q2.push(["task2", "task3"]);
q2.push("task4", error => {
console.log("Finished tasks");
});
q2.push(["task3", "task4", "task5"], error => {
q2.push(["task5", "task6", "task7"], error => {
console.log("Finished tasks");
});

// $ExpectType Promise<unknown>
q2.unshift("task1");
q2.unshift("task2", error => {
// $ExpectType Promise<unknown>[] | undefined
q2.unshift(["task2", "task3"]);
q2.unshift("task4", error => {
console.log("Finished tasks");
});
q2.unshift(["task3", "task4", "task5"], error => {
q2.unshift(["task5", "task6", "task7"], error => {
console.log("Finished tasks");
});

// $ExpectType Promise<unknown>
q2.pushAsync("task1");
// $ExpectType Promise<unknown>[] | undefined
q2.pushAsync(["task2", "task3"]);
// $ExpectType Promise<unknown>
q2.unshiftAsync("task1");
// $ExpectType Promise<unknown>[] | undefined
q2.unshiftAsync(["task2", "task3"]);

const q2Length = q2.length();
q2.push("testRemovalTask");
q2.remove(x => x.data === "testTaskRemoval");
Expand Down Expand Up @@ -420,6 +435,20 @@ q3.error();

q3.push(["task1", "task2", "task3"]);

// tests for the push method of priorityQueue
const q4 = async.priorityQueue<string>((task: string, callback: () => void) => {
console.log("Task: " + task);
callback();
}, 1);

// $ExpectType Promise<unknown>
q4.push("task1");

// $ExpectType Promise<unknown>[] | undefined
q4.push(["task2", "task3"]);

q4.push("task4", 1, () => {});

// create a cargo object with payload 2
const cargo = async.cargo<{ name: string }>((tasks, callback) => {
for (const task of tasks) {
Expand Down
12 changes: 0 additions & 12 deletions types/gulp-cond/gulp-cond-tests.ts

This file was deleted.

15 changes: 0 additions & 15 deletions types/gulp-cond/index.d.ts

This file was deleted.

22 changes: 0 additions & 22 deletions types/gulp-cond/package.json

This file was deleted.

19 changes: 0 additions & 19 deletions types/gulp-cond/tsconfig.json

This file was deleted.

File renamed without changes.
36 changes: 36 additions & 0 deletions types/helpscout-beacon/helpscout-beacon-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// helpscout-beacon-tests.ts

window.Beacon("init", "1234567890");

window.Beacon("init", {
beaconId: "1234567890",
color: "#ff0000",
mode: "askFirst",
display: {
position: "left",
style: "iconAndText",
},
});

window.Beacon("identify", {
name: "Baver Bozdağ",
email: "hello@example.com",
jobTitle: "Frontend Developer",
"Custom-Attribute": "Test",
});

window.Beacon("suggest", ["article-1", "article-2"]);
window.Beacon("suggest", [
"article-1",
{ text: "Help Scout", url: "https://www.helpscout.com" },
]);

window.Beacon("on", "open", () => {
console.log("Beacon opened!");
});

window.Beacon("logout", { endActiveChat: true, clearMessages: true });

if (window.Beacon.readyQueue) {
window.Beacon.readyQueue.push({ method: "open" });
}
103 changes: 103 additions & 0 deletions types/helpscout-beacon/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
declare function Beacon(method: "init", beaconId: string): void;
declare function Beacon(method: "init", config: { beaconId: string } & Beacon.Config): void;
declare function Beacon(method: "destroy" | "open" | "close" | "toggle" | "reset"): void;
declare function Beacon(method: "search", query: string): void;
declare function Beacon(method: "ask-question", question: string): void;
declare function Beacon(method: "suggest", suggestions?: Array<string | { text: string; url: string }>): void;
declare function Beacon(method: "article", articleId: string, options?: { type: "sidebar" | "modal" }): void;
declare function Beacon(method: "navigate", route: string): void;
declare function Beacon(method: "identify", userObject: Beacon.IdentifyUser): void;
declare function Beacon(method: "prefill", formObject: Beacon.PrefillForm): void;
declare function Beacon(method: "logout", options?: { endActiveChat?: boolean; clearMessages?: boolean }): void;
declare function Beacon(method: "config", options: Beacon.Config): void;
declare function Beacon(method: "on" | "once", event: Beacon.Event, callback: (eventData?: unknown) => void): void;
declare function Beacon(method: "off", event: Beacon.Event, callback?: (eventData?: unknown) => void): void;
declare function Beacon(method: "event", eventObject: { type: "page-viewed"; url: string; title: string }): void;
declare function Beacon(method: "session-data", data: Record<string, string>): void;
declare function Beacon(method: "show-message", messageId: string, options?: { delay?: number; force?: boolean }): void;
declare function Beacon(method: "info"): unknown;

declare namespace Beacon {
interface DisplayConfig {
style?: "icon" | "text" | "iconAndText" | "manual";
text?: string;
textAlign?: "left" | "right";
iconImage?: "message" | "beacon" | "search" | "buoy" | "question";
position?: "left" | "right";
zIndex?: number;
horizontalOffset?: number;
verticalOffset?: number;
horizontalMobileOffset?: number;
verticalMobileOffset?: number;
}

interface MessagingContactFormConfig {
customFieldsEnabled?: boolean;
showName?: boolean;
showSubject?: boolean;
allowAttachments?: boolean;
showGetInTouch?: boolean;
}

interface MessagingConfig {
chatEnabled?: boolean;
contactForm?: MessagingContactFormConfig;
}

interface Config {
docsEnabled?: boolean;
messagingEnabled?: boolean;
enableFabAnimation?: boolean;
enablePreviousMessages?: boolean;
enableSounds?: boolean;
reopenBeaconWithActiveChat?: boolean;
color?: string;
mode?: "selfService" | "neutral" | "askFirst";
hideAvatars?: boolean;
hideFABOnMobile?: boolean;
hideFABLabelOnMobile?: boolean;
disableMessages?: boolean;
showPrefilledCustomFields?: boolean;
display?: DisplayConfig;
messaging?: MessagingConfig;
labels?: Record<string, string>;
}

interface IdentifyUser {
name?: string;
email?: string;
company?: string;
jobTitle?: string;
avatar?: string;
signature?: string;
companyProperties?: Record<string, string | number | boolean | null>;
[key: string]: string | number | boolean | null | undefined | Record<string, string | number | boolean | null>;
}

interface PrefillForm {
name?: string;
email?: string;
subject?: string;
text?: string;
fields?: Array<{ id: number; value: string | number }>;
attachments?: File[];
}

type Event =
| "open"
| "close"
| "ready"
| "article-viewed"
| "chat-started"
| "email-sent"
| "message-clicked"
| "message-closed"
| "message-triggered"
| "search";
}

interface Window {
Beacon: typeof Beacon & {
readyQueue?: Array<{ method: string; options?: unknown; data?: unknown }>;
};
}
Loading