本文整理汇总了TypeScript中chomex.Client类的典型用法代码示例。如果您正苦于以下问题:TypeScript Client类的具体用法?TypeScript Client怎么用?TypeScript Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: OnPort
export async function OnPort(req: chrome.webRequest.WebRequestBodyDetails) {
Sortie.context().refresh();
Client.for(chrome.tabs, req.tabId, false).message("/snapshot/remove");
WindowService.getInstance().cleanDamageSnapshot();
return {status: 200};
}
示例2: WindowOpen
export async function WindowOpen(message: any) {
const ws = WindowService.getInstance();
const id = message.id;
const frame = Frame.find<Frame>(id) || Frame.latest();
let tab = await ws.find();
if (tab) {
tab = await ws.reconfigure(tab, frame);
return Client.for(chrome.tabs, tab.id).message("/reconfigured", {frame});
}
frame.update({selectedAt: Date.now()});
tab = await ws.create(frame);
return tab;
}
示例3: OnCombinedBattleResulted
export async function OnCombinedBattleResulted(req: chrome.webRequest.WebResponseCacheDetails) {
const text = Config.find<Config<boolean>>("inapp-dsnapshot-context").value ? Sortie.context().toText() : "";
// 別の画像をdrawしないように、ユニークっぽいkeyを生成しておく
const key = Date.now();
// 画面のクリックイベントに備えてもらう
Client.for(chrome.tabs, req.tabId, false).message("/snapshot/prepare", {count: 2, key, text});
// {{{ TODO: このへんのルーチンどうにかすべきかな
const d = DamageSnapshotFrame.get();
if (d.value === DamageSnapshotType.Separate) {
WindowService.getInstance().openDamageSnapshot(d, 2, key, text);
}
// }}}
return {status: 200};
}
示例4: DamageSnapshotCapture
export async function DamageSnapshotCapture(message: {after: number, key: string}) {
const ws = WindowService.getInstance();
const tab = await ws.find();
await sleep(message.after || 1000); // 艦隊の描画が止まるのを待つ
const cs = new CaptureService();
const original = await cs.base64(tab.windowId, {});
const ts = await TrimService.init(original);
const rect = Rectangle.new(ts.img.width, ts.img.height);
const trimmed = ts.trim(rect.damagesnapshot());
const key = message.key; // drawする画像を間違えないようにするためのkey
switch (DamageSnapshotFrame.get().value) {
case DamageSnapshotType.InApp:
const height = Config.find<Config<number>>("inapp-dsnapshot-size").value;
Client.for(chrome.tabs, tab.id, false).message("/snapshot/show", {uri: trimmed, height});
case DamageSnapshotType.Separate:
(new TempStorage()).store(`damagesnapshot_${key}`, trimmed);
}
return {status: 202, tabId: tab.id};
}