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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// this file is copied from https://cdn.esm.sh/v54/socket.io-client@4.2.0/build/index.d.ts
import { ManagerOptions } from "./manager.ts";
import { Socket, SocketOptions } from "./socket.ts";
import type { ManagerOptions } from "./manager.ts";
import type { Socket, SocketOptions } from "./socket.ts";
/**
* Looks up an existing `Manager` for multiplexing.
* If the user summons:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// this file is copied from https://cdn.esm.sh/v54/socket.io-client@4.2.0/build/manager.d.ts
// deno-lint-ignore-file no-explicit-any camelcase ban-types
import { Socket, SocketOptions } from "./socket.ts";
import { Packet } from "./parser.ts";
import type { Socket, SocketOptions } from "./socket.ts";
import type { Packet } from "./parser.ts";
import {
DefaultEventsMap,
EventsMap,
type DefaultEventsMap,
type EventsMap,
StrictEventEmitter,
} from "./typed-events.ts";
interface EngineOptions {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// deno-lint-ignore-file no-explicit-any camelcase
// this file is copied from https://cdn.esm.sh/v54/socket.io-client@4.2.0/build/socket.d.ts
import { Packet } from "./parser.ts";
import { Manager } from "./manager.ts";
import type { Packet } from "./parser.ts";
import type { Manager } from "./manager.ts";
import {
DefaultEventsMap,
EventNames,
EventParams,
EventsMap,
type DefaultEventsMap,
type EventNames,
type EventParams,
type EventsMap,
StrictEventEmitter,
} from "./typed-events.ts";
export interface SocketOptions {
Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/applyCommit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CommitNotification } from "../../deps/socket.ts";
import type { CommitNotification } from "./websocket-types.ts";
import type { Page } from "@cosense/types/rest";
import { getUnixTimeFromId } from "./id.ts";
type Line = Page["lines"][number];
Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/diffToChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
DeleteChange,
InsertChange,
UpdateChange,
} from "../../deps/socket.ts";
} from "./websocket-types.ts";
import { createNewLineId } from "./id.ts";

type Options = {
Expand Down
4 changes: 2 additions & 2 deletions browser/websocket/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {
type Socket,
socketIO,
wrap,
} from "../../deps/socket.ts";
} from "./wrap.ts";
import type { HTTPError } from "../../rest/responseIntoResult.ts";
import type { AbortError, NetworkError } from "../../rest/robustFetch.ts";
import { getProjectId } from "./pull.ts";
import { connect, disconnect } from "./socket.ts";
export type {
ProjectUpdatesStreamCommit,
ProjectUpdatesStreamEvent,
} from "../../deps/socket.ts";
} from "./websocket-types.ts";

export interface ListenStreamOptions {
socket?: Socket;
Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/makeChanges.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { diffToChanges } from "./diffToChanges.ts";
import type { Page } from "@cosense/types/rest";
import type { Change } from "../../deps/socket.ts";
import type { Change } from "./websocket-types.ts";
import { findMetadata, getHelpfeels } from "./findMetadata.ts";
import { isSameArray } from "./isSameArray.ts";

Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/patch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Change, DeletePageChange, PinChange } from "../../deps/socket.ts";
import type { Change, DeletePageChange, PinChange } from "./wrap.ts";
import { makeChanges } from "./makeChanges.ts";
import type { Page } from "@cosense/types/rest";
import { push, type PushError, type PushOptions } from "./push.ts";
Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/pin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Result } from "option-t/plain_result";
import type { Change, Socket } from "../../deps/socket.ts";
import type { Change, Socket } from "./wrap.ts";
import { push, type PushError, type PushOptions } from "./push.ts";

export interface PinOptions extends PushOptions {
Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
socketIO,
type TimeoutError,
wrap,
} from "../../deps/socket.ts";
} from "./wrap.ts";
import { connect, disconnect } from "./socket.ts";
import { pull } from "./pull.ts";
import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
ManagerOptions,
Socket,
SocketOptions,
} from "./types/socketIO/index.ts";
} from "./@types/socket-io/index.ts";
export type { Manager, ManagerOptions, Socket, SocketOptions };

export const socketIO = async (): Promise<Socket> => {
Expand Down
4 changes: 2 additions & 2 deletions browser/websocket/socket.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Socket, socketIO } from "../../deps/socket.ts";
export type { Socket } from "../../deps/socket.ts";
import { type Socket, socketIO } from "./socket-io.ts";
export type { Socket } from "./socket-io.ts";

/** 新しいsocketを作る */
export const makeSocket = (): Promise<Socket> => socketIO();
Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/updateCodeBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
DeleteChange,
InsertChange,
UpdateChange,
} from "../../deps/socket.ts";
} from "./websocket-types.ts";
import type { TinyCodeBlock } from "../../rest/getCodeBlocks.ts";
import { diffToChanges } from "./diffToChanges.ts";
import { isSimpleCodeFile } from "./isSimpleCodeFile.ts";
Expand Down
2 changes: 1 addition & 1 deletion browser/websocket/updateCodeFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
DeleteChange,
InsertChange,
UpdateChange,
} from "../../deps/socket.ts";
} from "./websocket-types.ts";
import { getCodeBlocks, type TinyCodeBlock } from "../../rest/getCodeBlocks.ts";
import { createNewLineId } from "./id.ts";
import { diff, toExtendedChanges } from "../../deps/onp.ts";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { Socket } from "./socket.ts";
import type { Socket } from "./socket-io.ts";
import {
DataOf,
EventMap,
FailedResOf,
type DataOf,
type EventMap,
type FailedResOf,
isPageCommitError,
ListenEventMap,
Result,
SuccessResOf,
TimeoutError,
UnexpectedError,
} from "./types.ts";
export * from "./types.ts";
export * from "./socket.ts";
type ListenEventMap,
type Result,
type SuccessResOf,
type TimeoutError,
type UnexpectedError,
} from "./websocket-types.ts";
export * from "./websocket-types.ts";
export * from "./socket-io.ts";

export interface SocketOperator {
request: <EventName extends keyof EventMap>(
Expand Down
4 changes: 2 additions & 2 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"@progfay/scrapbox-parser": "jsr:@progfay/scrapbox-parser@9",
"@std/assert": "jsr:@std/assert@1",
"@std/async": "jsr:@std/async@1",
"@std/hash": "./vendor/deno.land/std@0.160.0/hash/md5.ts",
"@std/encoding": "jsr:@std/encoding@1",
"@takker/md5": "jsr:@takker/md5@0.1",
"@std/testing/snapshot": "jsr:@std/testing@0/snapshot",
"@takker/onp": "./vendor/raw.githubusercontent.com/takker99/onp/0.0.1/mod.ts",
"@takker/scrapbox-userscript-websocket": "./vendor/raw.githubusercontent.com/takker99/scrapbox-userscript-websocket/0.2.4/mod.ts",
"option-t": "npm:option-t@^49.1.0"
},
"exports": {
Expand Down
10 changes: 10 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion deps/socket.ts

This file was deleted.

9 changes: 5 additions & 4 deletions rest/uploadToGCS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
setDefaults,
} from "./options.ts";
import type { ErrorLike, NotFoundError } from "@cosense/types/rest";
import { Md5 } from "@std/hash";
import { md5 } from "@takker/md5";
import { encodeHex } from "@std/encoding/hex";
import {
createOk,
isErr,
Expand Down Expand Up @@ -46,14 +47,14 @@ export const uploadToGCS = async (
projectId: string,
options?: ExtendedOptions,
): Promise<Result<GCSFile, UploadGCSError | FetchError>> => {
const md5 = `${new Md5().update(await file.arrayBuffer())}`;
const res = await uploadRequest(file, projectId, md5, options);
const md5Hash = `${encodeHex(md5(await file.arrayBuffer()))}`;
const res = await uploadRequest(file, projectId, md5Hash, options);
if (isErr(res)) return res;
const fileOrRequest = unwrapOk(res);
if ("embedUrl" in fileOrRequest) return createOk(fileOrRequest);
const result = await upload(fileOrRequest.signedUrl, file, options);
if (isErr(result)) return result;
return verify(projectId, fileOrRequest.fileId, md5, options);
return verify(projectId, fileOrRequest.fileId, md5Hash, options);
};

/** 容量を使い切ったときに発生するerror */
Expand Down
67 changes: 0 additions & 67 deletions vendor/deno.land/std@0.160.0/encoding/hex.ts

This file was deleted.

Loading