-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bun-sh' of https://github.com/ThatOneCalculator/megalodon…
… into bun-sh
- Loading branch information
Showing
196 changed files
with
2,674 additions
and
2,646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
At first, set environment vairables | ||
|
||
``` | ||
$ export MASTODON_URL=wss://mastodon.social | ||
$ export MASTODON_ACCESS_TOKEN=foobar | ||
``` | ||
And execute | ||
|
||
``` | ||
$ yarn workspace megalodon build | ||
$ yarn workspace browser build | ||
$ yarn workspace browser start | ||
``` | ||
|
||
Let's open `http://127.0.0.1:8000`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,55 @@ | ||
import generator, { Entity, Response } from 'megalodon' | ||
import generator, { Entity } from 'megalodon' | ||
|
||
const BASE_URL: string = 'https://mastodon.social' | ||
const BASE_URL: string = process.env.MASTODON_URL! | ||
const ACCESS_TOKEN: string = process.env.MASTODON_ACCESS_TOKEN! | ||
console.log(BASE_URL) | ||
console.log('start') | ||
|
||
const client = generator('mastodon', BASE_URL) | ||
const client = generator('mastodon', BASE_URL, ACCESS_TOKEN) | ||
|
||
client.getInstance().then((res: Response<Entity.Instance>) => { | ||
console.log(res) | ||
const stream = client.localSocket() | ||
stream.on('connect', () => { | ||
console.log('connect') | ||
}) | ||
|
||
stream.on('pong', () => { | ||
console.log('pong') | ||
}) | ||
|
||
stream.on('update', (status: Entity.Status) => { | ||
console.log(status) | ||
}) | ||
|
||
stream.on('notification', (notification: Entity.Notification) => { | ||
console.log(notification) | ||
}) | ||
|
||
stream.on('delete', (id: number) => { | ||
console.log(id) | ||
}) | ||
|
||
stream.on('error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
|
||
stream.on('status_update', (status: Entity.Status) => { | ||
console.log('updated: ', status.url) | ||
}) | ||
|
||
stream.on('heartbeat', () => { | ||
console.log('thump.') | ||
}) | ||
|
||
stream.on('close', () => { | ||
console.log('close') | ||
}) | ||
|
||
stream.on('parser-error', (err: Error) => { | ||
console.error(err) | ||
}) | ||
|
||
setTimeout(() => { | ||
stream.removeAllListeners() | ||
stream.stop() | ||
console.log('closed') | ||
}, 10000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
export const NO_REDIRECT = 'urn:ietf:wg:oauth:2.0:oob' | ||
export const DEFAULT_SCOPE = ['read', 'write', 'follow'] | ||
export const DEFAULT_UA = 'megalodon' | ||
|
||
export function isBrowser() { | ||
if (typeof window !== 'undefined') { | ||
return true | ||
} else { | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
/// <reference path="emoji.ts" /> | ||
/// <reference path="source.ts" /> | ||
/// <reference path="field.ts" /> | ||
/// <reference path="role.ts" /> | ||
namespace Entity { | ||
export type Account = { | ||
id: string | ||
username: string | ||
acct: string | ||
display_name: string | ||
locked: boolean | ||
discoverable?: boolean | ||
group: boolean | null | ||
noindex: boolean | null | ||
suspended: boolean | null | ||
limited: boolean | null | ||
created_at: string | ||
followers_count: number | ||
following_count: number | ||
statuses_count: number | ||
note: string | ||
url: string | ||
avatar: string | ||
avatar_static: string | ||
header: string | ||
header_static: string | ||
emojis: Array<Emoji> | ||
moved: Account | null | ||
fields: Array<Field> | ||
bot: boolean | null | ||
source?: Source | ||
role?: Role | ||
mute_expires_at?: string | ||
} | ||
import { Emoji } from './emoji' | ||
import { Field } from './field' | ||
import { Source } from './source' | ||
import { Role } from './role' | ||
|
||
export type Account = { | ||
id: string | ||
username: string | ||
acct: string | ||
display_name: string | ||
locked: boolean | ||
discoverable?: boolean | ||
group: boolean | null | ||
noindex: boolean | null | ||
suspended: boolean | null | ||
limited: boolean | null | ||
created_at: string | ||
followers_count: number | ||
following_count: number | ||
statuses_count: number | ||
note: string | ||
url: string | ||
avatar: string | ||
avatar_static: string | ||
header: string | ||
header_static: string | ||
emojis: Array<Emoji> | ||
moved: Account | null | ||
fields: Array<Field> | ||
bot: boolean | null | ||
source?: Source | ||
role?: Role | ||
mute_expires_at?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
namespace Entity { | ||
export type Activity = { | ||
week: string | ||
statuses: string | ||
logins: string | ||
registrations: string | ||
} | ||
export type Activity = { | ||
week: string | ||
statuses: string | ||
logins: string | ||
registrations: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
/// <reference path="emoji.ts" /> | ||
import { Emoji } from './emoji' | ||
import { StatusTag } from './status' | ||
|
||
namespace Entity { | ||
export type Announcement = { | ||
id: string | ||
content: string | ||
starts_at: string | null | ||
ends_at: string | null | ||
published: boolean | ||
all_day: boolean | ||
published_at: string | ||
updated_at: string | null | ||
read: boolean | null | ||
mentions: Array<AnnouncementAccount> | ||
statuses: Array<AnnouncementStatus> | ||
tags: Array<StatusTag> | ||
emojis: Array<Emoji> | ||
reactions: Array<AnnouncementReaction> | ||
} | ||
export type Announcement = { | ||
id: string | ||
content: string | ||
starts_at: string | null | ||
ends_at: string | null | ||
published: boolean | ||
all_day: boolean | ||
published_at: string | ||
updated_at: string | null | ||
read: boolean | null | ||
mentions: Array<AnnouncementAccount> | ||
statuses: Array<AnnouncementStatus> | ||
tags: Array<StatusTag> | ||
emojis: Array<Emoji> | ||
reactions: Array<AnnouncementReaction> | ||
} | ||
|
||
export type AnnouncementAccount = { | ||
id: string | ||
username: string | ||
url: string | ||
acct: string | ||
} | ||
export type AnnouncementAccount = { | ||
id: string | ||
username: string | ||
url: string | ||
acct: string | ||
} | ||
|
||
export type AnnouncementStatus = { | ||
id: string | ||
url: string | ||
} | ||
export type AnnouncementStatus = { | ||
id: string | ||
url: string | ||
} | ||
|
||
export type AnnouncementReaction = { | ||
name: string | ||
count: number | ||
me: boolean | null | ||
url: string | null | ||
static_url: string | null | ||
} | ||
export type AnnouncementReaction = { | ||
name: string | ||
count: number | ||
me: boolean | null | ||
url: string | null | ||
static_url: string | null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
namespace Entity { | ||
export type Application = { | ||
name: string | ||
website?: string | null | ||
vapid_key?: string | null | ||
} | ||
export type Application = { | ||
name: string | ||
website?: string | null | ||
vapid_key?: string | null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
/// <reference path="attachment.ts" /> | ||
namespace Entity { | ||
export type AsyncAttachment = { | ||
id: string | ||
type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' | ||
url: string | null | ||
remote_url: string | null | ||
preview_url: string | ||
text_url: string | null | ||
meta: Meta | null | ||
description: string | null | ||
blurhash: string | null | ||
} | ||
import { Meta } from './attachment' | ||
|
||
export type AsyncAttachment = { | ||
id: string | ||
type: 'unknown' | 'image' | 'gifv' | 'video' | 'audio' | ||
url: string | null | ||
remote_url: string | null | ||
preview_url: string | ||
text_url: string | null | ||
meta: Meta | null | ||
description: string | null | ||
blurhash: string | null | ||
} |
Oops, something went wrong.