mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-25 10:33:08 +02:00
Compare commits
24 commits
e00f1a5e56
...
70199a8fab
Author | SHA1 | Date | |
---|---|---|---|
|
70199a8fab | ||
|
bb7b4a8ea4 | ||
|
0690b9a429 | ||
|
e779c1e667 | ||
|
8c955fcce5 | ||
|
126248e58d | ||
|
074de82bf7 | ||
|
bd7c4f66f3 | ||
|
ecfaf7ff7a | ||
|
58bc8f2c10 | ||
|
94aed953b5 | ||
|
aa7035a35a | ||
|
45eab01fc4 | ||
|
71bcd76cc5 | ||
|
a69315a24b | ||
|
d003c3ec1f | ||
|
b918f38ec2 | ||
|
cdb82c0ade | ||
|
d991eccd3f | ||
|
0085305579 | ||
|
6826e43ad7 | ||
|
ff189b1952 | ||
|
43544a6479 | ||
|
03464cc379 |
35 changed files with 204 additions and 38 deletions
|
@ -6,8 +6,11 @@ When using a service with Sharkey, there are several important points to keep in
|
||||||
|
|
||||||
2. Even for posts made in private, there is no guarantee that the recipient's server will treat them as private in the same way. Please exercise caution when posting personal or confidential information. (Again, this applies to the internet in general.)
|
2. Even for posts made in private, there is no guarantee that the recipient's server will treat them as private in the same way. Please exercise caution when posting personal or confidential information. (Again, this applies to the internet in general.)
|
||||||
|
|
||||||
3. Account deletion can be a resource-intensive process and may take a long time. In cases with a lot of uploaded data, it may even be impossible to delete an account.
|
3. The "Drive" feature is NOT secure cloud storage. This feature exists for easier managing of your uploaded files.
|
||||||
|
Any data uploaded, whether shared via post or not, will be publicly accessible. Please use 3rd party cloud storage providers if you need to upload data with sensitive information of any kind.
|
||||||
|
|
||||||
4. Please disable ad blockers. Some servers may rely on advertising revenue to cover operating costs. Additionally, ad blockers can mistakenly block content and features unrelated to ads, potentially causing issues with the client's functionality and preventing normal use of Sharkey. Therefore, we recommend turning off ad blockers and similar features when using Sharkey.
|
4. Account deletion can be a resource-intensive process and may take a long time. In cases with a lot of uploaded data, it may even be impossible to delete an account.
|
||||||
|
|
||||||
|
5. Please disable ad blockers. Some servers may rely on advertising revenue to cover operating costs. Additionally, ad blockers can mistakenly block content and features unrelated to ads, potentially causing issues with the client's functionality and preventing normal use of Sharkey. Therefore, we recommend turning off ad blockers and similar features when using Sharkey.
|
||||||
|
|
||||||
Please understand these points and enjoy using the service.
|
Please understand these points and enjoy using the service.
|
|
@ -11,7 +11,11 @@ export default new DataSource({
|
||||||
username: config.db.user,
|
username: config.db.user,
|
||||||
password: config.db.pass,
|
password: config.db.pass,
|
||||||
database: config.db.db,
|
database: config.db.db,
|
||||||
extra: config.db.extra,
|
extra: {
|
||||||
|
...config.db.extra,
|
||||||
|
// migrations may be very slow, give them longer to run (that 10*1000 comes from postgres.ts)
|
||||||
|
statement_timeout: (config.db.extra?.statement_timeout ?? 1000 * 10) * 10,
|
||||||
|
},
|
||||||
entities: entities,
|
entities: entities,
|
||||||
migrations: ['migration/*.js'],
|
migrations: ['migration/*.js'],
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,7 @@ import type { Config } from '@/config.js';
|
||||||
import { StatusError } from '@/misc/status-error.js';
|
import { StatusError } from '@/misc/status-error.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
||||||
|
import { assertActivityMatchesUrls } from '@/core/activitypub/misc/check-against-url.js';
|
||||||
import type { IObject } from '@/core/activitypub/type.js';
|
import type { IObject } from '@/core/activitypub/type.js';
|
||||||
import type { Response } from 'node-fetch';
|
import type { Response } from 'node-fetch';
|
||||||
import type { URL } from 'node:url';
|
import type { URL } from 'node:url';
|
||||||
|
@ -125,7 +126,12 @@ export class HttpRequestService {
|
||||||
validators: [validateContentTypeSetAsActivityPub],
|
validators: [validateContentTypeSetAsActivityPub],
|
||||||
});
|
});
|
||||||
|
|
||||||
return await res.json() as IObject;
|
const finalUrl = res.url; // redirects may have been involved
|
||||||
|
const activity = await res.json() as IObject;
|
||||||
|
|
||||||
|
assertActivityMatchesUrls(activity, [url, finalUrl]);
|
||||||
|
|
||||||
|
return activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
|
@ -86,7 +86,7 @@ export class UtilityService {
|
||||||
@bindThis
|
@bindThis
|
||||||
public extractDbHost(uri: string): string {
|
public extractDbHost(uri: string): string {
|
||||||
const url = new URL(uri);
|
const url = new URL(uri);
|
||||||
return this.toPuny(url.hostname);
|
return this.toPuny(url.host);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -99,4 +99,11 @@ export class UtilityService {
|
||||||
if (host == null) return null;
|
if (host == null) return null;
|
||||||
return toASCII(host.toLowerCase());
|
return toASCII(host.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public punyHost(url: string): string {
|
||||||
|
const urlObj = new URL(url);
|
||||||
|
const host = `${this.toPuny(urlObj.hostname)}${urlObj.port.length > 0 ? ':' + urlObj.port : ''}`;
|
||||||
|
return host;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,9 @@ import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type Logger from '@/logger.js';
|
import type Logger from '@/logger.js';
|
||||||
|
import type { IObject } from './type.js';
|
||||||
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
||||||
|
import { assertActivityMatchesUrls } from '@/core/activitypub/misc/check-against-url.js';
|
||||||
|
|
||||||
type Request = {
|
type Request = {
|
||||||
url: string;
|
url: string;
|
||||||
|
@ -201,6 +203,11 @@ export class ApRequestService {
|
||||||
validators: [validateContentTypeSetAsActivityPub],
|
validators: [validateContentTypeSetAsActivityPub],
|
||||||
});
|
});
|
||||||
|
|
||||||
return await res.json();
|
const finalUrl = res.url; // redirects may have been involved
|
||||||
|
const activity = await res.json() as IObject;
|
||||||
|
|
||||||
|
assertActivityMatchesUrls(activity, [url, finalUrl]);
|
||||||
|
|
||||||
|
return activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,14 @@ export class Resolver {
|
||||||
throw new Error('invalid response');
|
throw new Error('invalid response');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HttpRequestService / ApRequestService have already checked that
|
||||||
|
// `object.id` or `object.url` matches the URL used to fetch the
|
||||||
|
// object after redirects; here we double-check that no redirects
|
||||||
|
// bounced between hosts
|
||||||
|
if (object.id && (this.utilityService.punyHost(object.id) !== this.utilityService.punyHost(value))) {
|
||||||
|
throw new Error(`invalid AP object ${value}: id ${object.id} has different host`);
|
||||||
|
}
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: dakkar and sharkey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
import type { IObject } from '../type.js';
|
||||||
|
|
||||||
|
export function assertActivityMatchesUrls(activity: IObject, urls: string[]) {
|
||||||
|
const idOk = activity.id !== undefined && urls.includes(activity.id);
|
||||||
|
|
||||||
|
// technically `activity.url` could be an `ApObject = IObject |
|
||||||
|
// string | (IObject | string)[]`, but if it's a complicated thing
|
||||||
|
// and the `activity.id` doesn't match, I think we're fine
|
||||||
|
// rejecting the activity
|
||||||
|
const urlOk = typeof(activity.url) === 'string' && urls.includes(activity.url);
|
||||||
|
|
||||||
|
if (!idOk && !urlOk) {
|
||||||
|
throw new Error(`bad Activity: neither id(${activity?.id}) nor url(${activity?.url}) match location(${urls})`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -127,12 +127,6 @@ export class ApPersonService implements OnModuleInit {
|
||||||
this.logger = this.apLoggerService.logger;
|
this.logger = this.apLoggerService.logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
private punyHost(url: string): string {
|
|
||||||
const urlObj = new URL(url);
|
|
||||||
const host = `${this.utilityService.toPuny(urlObj.hostname)}${urlObj.port.length > 0 ? ':' + urlObj.port : ''}`;
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate and convert to actor object
|
* Validate and convert to actor object
|
||||||
* @param x Fetched object
|
* @param x Fetched object
|
||||||
|
@ -140,7 +134,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
private validateActor(x: IObject, uri: string): IActor {
|
private validateActor(x: IObject, uri: string): IActor {
|
||||||
const expectHost = this.punyHost(uri);
|
const expectHost = this.utilityService.punyHost(uri);
|
||||||
|
|
||||||
if (!isActor(x)) {
|
if (!isActor(x)) {
|
||||||
throw new Error(`invalid Actor type '${x.type}'`);
|
throw new Error(`invalid Actor type '${x.type}'`);
|
||||||
|
@ -154,6 +148,19 @@ export class ApPersonService implements OnModuleInit {
|
||||||
throw new Error('invalid Actor: wrong inbox');
|
throw new Error('invalid Actor: wrong inbox');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.utilityService.punyHost(x.inbox) !== expectHost) {
|
||||||
|
throw new Error('invalid Actor: inbox has different host');
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const collection of ['outbox', 'followers', 'following'] as (keyof IActor)[]) {
|
||||||
|
const collectionUri = (x as IActor)[collection];
|
||||||
|
if (typeof collectionUri === 'string' && collectionUri.length > 0) {
|
||||||
|
if (this.utilityService.punyHost(collectionUri) !== expectHost) {
|
||||||
|
throw new Error(`invalid Actor: ${collection} has different host`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(typeof x.preferredUsername === 'string' && x.preferredUsername.length > 0 && x.preferredUsername.length <= 128 && /^\w([\w-.]*\w)?$/.test(x.preferredUsername))) {
|
if (!(typeof x.preferredUsername === 'string' && x.preferredUsername.length > 0 && x.preferredUsername.length <= 128 && /^\w([\w-.]*\w)?$/.test(x.preferredUsername))) {
|
||||||
throw new Error('invalid Actor: wrong username');
|
throw new Error('invalid Actor: wrong username');
|
||||||
}
|
}
|
||||||
|
@ -177,7 +184,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
x.summary = truncate(x.summary, summaryLength);
|
x.summary = truncate(x.summary, summaryLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
const idHost = this.punyHost(x.id);
|
const idHost = this.utilityService.punyHost(x.id);
|
||||||
if (idHost !== expectHost) {
|
if (idHost !== expectHost) {
|
||||||
throw new Error('invalid Actor: id has different host');
|
throw new Error('invalid Actor: id has different host');
|
||||||
}
|
}
|
||||||
|
@ -187,7 +194,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
throw new Error('invalid Actor: publicKey.id is not a string');
|
throw new Error('invalid Actor: publicKey.id is not a string');
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKeyIdHost = this.punyHost(x.publicKey.id);
|
const publicKeyIdHost = this.utilityService.punyHost(x.publicKey.id);
|
||||||
if (publicKeyIdHost !== expectHost) {
|
if (publicKeyIdHost !== expectHost) {
|
||||||
throw new Error('invalid Actor: publicKey.id has different host');
|
throw new Error('invalid Actor: publicKey.id has different host');
|
||||||
}
|
}
|
||||||
|
@ -286,7 +293,7 @@ export class ApPersonService implements OnModuleInit {
|
||||||
|
|
||||||
this.logger.info(`Creating the Person: ${person.id}`);
|
this.logger.info(`Creating the Person: ${person.id}`);
|
||||||
|
|
||||||
const host = this.punyHost(object.id);
|
const host = this.utilityService.punyHost(object.id);
|
||||||
|
|
||||||
const fields = this.analyzeAttachments(person.attachment ?? []);
|
const fields = this.analyzeAttachments(person.attachment ?? []);
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
@bindThis
|
@bindThis
|
||||||
private async fetchAny(uri: string, me: MiLocalUser | null | undefined): Promise<SchemaType<typeof meta['res']> | null> {
|
private async fetchAny(uri: string, me: MiLocalUser | null | undefined): Promise<SchemaType<typeof meta['res']> | null> {
|
||||||
// ブロックしてたら中断
|
// ブロックしてたら中断
|
||||||
|
const host = this.utilityService.extractDbHost(uri);
|
||||||
const fetchedMeta = await this.metaService.fetch();
|
const fetchedMeta = await this.metaService.fetch();
|
||||||
if (this.utilityService.isBlockedHost(fetchedMeta.blockedHosts, this.utilityService.extractDbHost(uri))) return null;
|
if (this.utilityService.isBlockedHost(fetchedMeta.blockedHosts, host)) return null;
|
||||||
|
|
||||||
let local = await this.mergePack(me, ...await Promise.all([
|
let local = await this.mergePack(me, ...await Promise.all([
|
||||||
this.apDbResolverService.getUserFromApId(uri),
|
this.apDbResolverService.getUserFromApId(uri),
|
||||||
|
@ -122,6 +123,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
]));
|
]));
|
||||||
if (local != null) return local;
|
if (local != null) return local;
|
||||||
|
|
||||||
|
// local object, not found in db? fail
|
||||||
|
if (this.utilityService.isSelfHost(host)) return null;
|
||||||
|
|
||||||
// リモートから一旦オブジェクトフェッチ
|
// リモートから一旦オブジェクトフェッチ
|
||||||
const resolver = this.apResolverService.createResolver();
|
const resolver = this.apResolverService.createResolver();
|
||||||
const object = await resolver.resolve(uri) as any;
|
const object = await resolver.resolve(uri) as any;
|
||||||
|
|
|
@ -279,7 +279,8 @@ export class MastoConverters {
|
||||||
emoji_reactions: status.emoji_reactions,
|
emoji_reactions: status.emoji_reactions,
|
||||||
bookmarked: false,
|
bookmarked: false,
|
||||||
quote: isQuote ? await this.convertReblog(status.reblog) : false,
|
quote: isQuote ? await this.convertReblog(status.reblog) : false,
|
||||||
edited_at: note.updatedAt?.toISOString(),
|
// optional chaining cannot be used, as it evaluates to undefined, not null
|
||||||
|
edited_at: note.updatedAt ? note.updatedAt.toISOString() : null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ html
|
||||||
link(rel='stylesheet' href='/assets/phosphor-icons/bold/style.css')
|
link(rel='stylesheet' href='/assets/phosphor-icons/bold/style.css')
|
||||||
link(rel='stylesheet' href='/static-assets/fonts/sharkey-icons/style.css')
|
link(rel='stylesheet' href='/static-assets/fonts/sharkey-icons/style.css')
|
||||||
link(rel='modulepreload' href=`/vite/${clientEntry.file}`)
|
link(rel='modulepreload' href=`/vite/${clientEntry.file}`)
|
||||||
script(src='/client-assets/libopenmpt.js')
|
|
||||||
|
|
||||||
if !config.clientManifestExists
|
if !config.clientManifestExists
|
||||||
script(type="module" src="/vite/@vite/client")
|
script(type="module" src="/vite/@vite/client")
|
||||||
|
@ -73,7 +72,6 @@ html
|
||||||
script.
|
script.
|
||||||
var VERSION = "#{version}";
|
var VERSION = "#{version}";
|
||||||
var CLIENT_ENTRY = "#{clientEntry.file}";
|
var CLIENT_ENTRY = "#{clientEntry.file}";
|
||||||
window.libopenmpt = window.Module;
|
|
||||||
|
|
||||||
script(type='application/json' id='misskey_meta' data-generated-at=now)
|
script(type='application/json' id='misskey_meta' data-generated-at=now)
|
||||||
!= metaJson
|
!= metaJson
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,7 @@ export async function signout() {
|
||||||
waiting();
|
waiting();
|
||||||
miLocalStorage.removeItem('account');
|
miLocalStorage.removeItem('account');
|
||||||
await removeAccount($i.id);
|
await removeAccount($i.id);
|
||||||
|
document.cookie = `token=; path=/; max-age=0${ location.protocol === 'https:' ? '; Secure' : ''}`;
|
||||||
const accounts = await getAccounts();
|
const accounts = await getAccounts();
|
||||||
|
|
||||||
//#region Remove service worker registration
|
//#region Remove service worker registration
|
||||||
|
@ -200,7 +201,7 @@ export async function login(token: Account['token'], redirect?: string) {
|
||||||
throw reason;
|
throw reason;
|
||||||
});
|
});
|
||||||
miLocalStorage.setItem('account', JSON.stringify(me));
|
miLocalStorage.setItem('account', JSON.stringify(me));
|
||||||
document.cookie = `token=${token}; path=/; max-age=31536000`; // bull dashboardの認証とかで使う
|
document.cookie = `token=${token}; path=/; max-age=31536000${ location.protocol === 'https:' ? '; Secure' : ''}`; // bull dashboardの認証とかで使う
|
||||||
await addAccount(me.id, token);
|
await addAccount(me.id, token);
|
||||||
|
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
|
|
|
@ -72,12 +72,16 @@ watch(() => props.lang, (to) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style module lang="scss">
|
<style module lang="scss">
|
||||||
|
.codeBlockRoot {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
.codeBlockRoot :global(.shiki) > code {
|
.codeBlockRoot :global(.shiki) > code {
|
||||||
counter-reset: step;
|
counter-reset: step;
|
||||||
counter-increment: step 0;
|
counter-increment: step 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.codeBlockRoot :global(.shiki) > code > .line::before {
|
.codeBlockRoot :global(.shiki) > code > span::before {
|
||||||
content: counter(step);
|
content: counter(step);
|
||||||
counter-increment: step;
|
counter-increment: step;
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
|
|
|
@ -55,8 +55,6 @@ import { i18n } from '@/i18n.js';
|
||||||
import { infoImageUrl } from '@/instance.js';
|
import { infoImageUrl } from '@/instance.js';
|
||||||
import { defaultStore } from '@/store.js';
|
import { defaultStore } from '@/store.js';
|
||||||
|
|
||||||
console.log(defaultStore.state.noteDesign, defaultStore.state.noteDesign === 'sharkey');
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
pagination: Paging;
|
pagination: Paging;
|
||||||
noGap?: boolean;
|
noGap?: boolean;
|
||||||
|
|
|
@ -16,9 +16,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #default="{ items }">
|
<template #default="{ items }">
|
||||||
<MkDateSeparatedList v-slot="{ item }" :items="items" :direction="'down'" :noGap="false" :ad="false">
|
<MkDateSeparatedList v-if="defaultStore.state.noteDesign === 'misskey'"
|
||||||
|
v-slot="{ item }" :items="items" :direction="'down'" :noGap="false" :ad="false">
|
||||||
<MkNote :key="item.id" :note="item.note" :class="$style.note"/>
|
<MkNote :key="item.id" :note="item.note" :class="$style.note"/>
|
||||||
</MkDateSeparatedList>
|
</MkDateSeparatedList>
|
||||||
|
<MkDateSeparatedList v-if="defaultStore.state.noteDesign === 'sharkey'"
|
||||||
|
v-slot="{ item }" :items="items" :direction="'down'" :noGap="false" :ad="false">
|
||||||
|
<SkNote :key="item.id" :note="item.note" :class="$style.note"/>
|
||||||
|
</MkDateSeparatedList>
|
||||||
</template>
|
</template>
|
||||||
</MkPagination>
|
</MkPagination>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
|
@ -28,10 +33,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import MkPagination from '@/components/MkPagination.vue';
|
import MkPagination from '@/components/MkPagination.vue';
|
||||||
import MkNote from '@/components/MkNote.vue';
|
import MkNote from '@/components/MkNote.vue';
|
||||||
|
import SkNote from '@/components/SkNote.vue';
|
||||||
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
|
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||||
import { infoImageUrl } from '@/instance.js';
|
import { infoImageUrl } from '@/instance.js';
|
||||||
|
import { defaultStore } from '@/store.js';
|
||||||
|
|
||||||
const pagination = {
|
const pagination = {
|
||||||
endpoint: 'i/favorites' as const,
|
endpoint: 'i/favorites' as const,
|
||||||
|
|
|
@ -40,7 +40,7 @@ const isScrolling = ref(false);
|
||||||
const scrollEl = shallowRef<HTMLElement>();
|
const scrollEl = shallowRef<HTMLElement>();
|
||||||
|
|
||||||
misskeyApiGet('notes/featured').then(_notes => {
|
misskeyApiGet('notes/featured').then(_notes => {
|
||||||
notes.value = _notes;
|
notes.value = _notes.filter(n => n.cw == null);
|
||||||
});
|
});
|
||||||
|
|
||||||
onUpdated(() => {
|
onUpdated(() => {
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
/* global libopenmpt UTF8ToString writeAsciiToMemory */
|
// @ts-nocheck
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
const ChiptuneAudioContext = window.AudioContext || window.webkitAudioContext;
|
const ChiptuneAudioContext = window.AudioContext || window.webkitAudioContext;
|
||||||
|
|
||||||
export function ChiptuneJsConfig (repeatCount: number, context: AudioContext) {
|
let libopenmpt
|
||||||
|
let libopenmptLoadPromise
|
||||||
|
|
||||||
|
export function ChiptuneJsConfig (repeatCount?: number, context?: AudioContext) {
|
||||||
this.repeatCount = repeatCount;
|
this.repeatCount = repeatCount;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +23,28 @@ export function ChiptuneJsPlayer (config: object) {
|
||||||
this.volume = 1;
|
this.volume = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChiptuneJsPlayer.prototype.initialize = function() {
|
||||||
|
if (libopenmptLoadPromise) return libopenmptLoadPromise;
|
||||||
|
if (libopenmpt) return Promise.resolve();
|
||||||
|
|
||||||
|
libopenmptLoadPromise = new Promise(async (resolve, reject) => {
|
||||||
|
try {
|
||||||
|
const { Module } = await import('./libopenmpt/libopenmpt.js');
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
Module['onRuntimeInitialized'] = resolve;
|
||||||
|
})
|
||||||
|
libopenmpt = Module;
|
||||||
|
resolve()
|
||||||
|
} catch (e) {
|
||||||
|
reject(e)
|
||||||
|
} finally {
|
||||||
|
libopenmptLoadPromise = undefined;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return libopenmptLoadPromise;
|
||||||
|
}
|
||||||
|
|
||||||
ChiptuneJsPlayer.prototype.constructor = ChiptuneJsPlayer;
|
ChiptuneJsPlayer.prototype.constructor = ChiptuneJsPlayer;
|
||||||
|
|
||||||
ChiptuneJsPlayer.prototype.fireEvent = function (eventName: string, response) {
|
ChiptuneJsPlayer.prototype.fireEvent = function (eventName: string, response) {
|
||||||
|
@ -61,12 +86,12 @@ ChiptuneJsPlayer.prototype.seek = function (position: number) {
|
||||||
|
|
||||||
ChiptuneJsPlayer.prototype.metadata = function () {
|
ChiptuneJsPlayer.prototype.metadata = function () {
|
||||||
const data = {};
|
const data = {};
|
||||||
const keys = UTF8ToString(libopenmpt._openmpt_module_get_metadata_keys(this.currentPlayingNode.modulePtr)).split(';');
|
const keys = libopenmpt.UTF8ToString(libopenmpt._openmpt_module_get_metadata_keys(this.currentPlayingNode.modulePtr)).split(';');
|
||||||
let keyNameBuffer = 0;
|
let keyNameBuffer = 0;
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
keyNameBuffer = libopenmpt._malloc(key.length + 1);
|
keyNameBuffer = libopenmpt._malloc(key.length + 1);
|
||||||
writeAsciiToMemory(key, keyNameBuffer);
|
libopenmpt.writeAsciiToMemory(key, keyNameBuffer);
|
||||||
data[key] = UTF8ToString(libopenmpt._openmpt_module_get_metadata(this.currentPlayingNode.modulePtr, keyNameBuffer));
|
data[key] = libopenmpt.UTF8ToString(libopenmpt._openmpt_module_get_metadata(this.currentPlayingNode.modulePtr, keyNameBuffer));
|
||||||
libopenmpt._free(keyNameBuffer);
|
libopenmpt._free(keyNameBuffer);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
@ -84,7 +109,7 @@ ChiptuneJsPlayer.prototype.unlock = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
ChiptuneJsPlayer.prototype.load = function (input) {
|
ChiptuneJsPlayer.prototype.load = function (input) {
|
||||||
return new Promise((resolve, reject) => {
|
return this.initialize().then(() => new Promise((resolve, reject) => {
|
||||||
if(this.touchLocked) {
|
if(this.touchLocked) {
|
||||||
this.unlock();
|
this.unlock();
|
||||||
}
|
}
|
||||||
|
@ -106,7 +131,7 @@ ChiptuneJsPlayer.prototype.load = function (input) {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
ChiptuneJsPlayer.prototype.play = function (buffer: ArrayBuffer) {
|
ChiptuneJsPlayer.prototype.play = function (buffer: ArrayBuffer) {
|
||||||
|
@ -180,7 +205,7 @@ ChiptuneJsPlayer.prototype.getPatternNumRows = function (pattern: number) {
|
||||||
|
|
||||||
ChiptuneJsPlayer.prototype.getPatternRowChannel = function (pattern: number, row: number, channel: number) {
|
ChiptuneJsPlayer.prototype.getPatternRowChannel = function (pattern: number, row: number, channel: number) {
|
||||||
if (this.currentPlayingNode && this.currentPlayingNode.modulePtr) {
|
if (this.currentPlayingNode && this.currentPlayingNode.modulePtr) {
|
||||||
return UTF8ToString(libopenmpt._openmpt_module_format_pattern_row_channel(this.currentPlayingNode.modulePtr, pattern, row, channel, 0, true));
|
return libopenmpt.UTF8ToString(libopenmpt._openmpt_module_format_pattern_row_channel(this.currentPlayingNode.modulePtr, pattern, row, channel, 0, true));
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
25
packages/frontend/src/scripts/libopenmpt/LICENSE
Normal file
25
packages/frontend/src/scripts/libopenmpt/LICENSE
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
Copyright (c) 2004-2024, OpenMPT Project Developers and Contributors
|
||||||
|
Copyright (c) 1997-2003, Olivier Lapicque
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the OpenMPT project nor the
|
||||||
|
names of its contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
8
packages/frontend/src/scripts/libopenmpt/libopenmpt.js
Normal file
8
packages/frontend/src/scripts/libopenmpt/libopenmpt.js
Normal file
File diff suppressed because one or more lines are too long
23
packages/frontend/src/scripts/libopenmpt/readme.md
Normal file
23
packages/frontend/src/scripts/libopenmpt/readme.md
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
modifications made to `libopenmpt.js` (can be taken from https://lib.openmpt.org/libopenmpt/download/):
|
||||||
|
|
||||||
|
at the beginning of the file:
|
||||||
|
```js
|
||||||
|
// @ts-nocheck
|
||||||
|
/* eslint-disable */
|
||||||
|
```
|
||||||
|
|
||||||
|
at the end of the file:
|
||||||
|
```js
|
||||||
|
Module.UTF8ToString = UTF8ToString;
|
||||||
|
Module.writeAsciiToMemory = writeAsciiToMemory;
|
||||||
|
export { Module }
|
||||||
|
```
|
||||||
|
|
||||||
|
replace
|
||||||
|
```
|
||||||
|
wasmBinaryFile="libopenmpt.wasm"
|
||||||
|
```
|
||||||
|
with
|
||||||
|
```
|
||||||
|
wasmBinaryFile=new URL("./libopenmpt.wasm", import.meta.url).href
|
||||||
|
```
|
|
@ -8,7 +8,7 @@ import meta from '../../package.json';
|
||||||
import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name.js';
|
import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name.js';
|
||||||
import pluginJson5 from './vite.json5.js';
|
import pluginJson5 from './vite.json5.js';
|
||||||
|
|
||||||
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue'];
|
const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue', '.wasm'];
|
||||||
|
|
||||||
const hash = (str: string, seed = 0): number => {
|
const hash = (str: string, seed = 0): number => {
|
||||||
let h1 = 0xdeadbeef ^ seed,
|
let h1 = 0xdeadbeef ^ seed,
|
||||||
|
|
|
@ -19,6 +19,7 @@ namespace Entity {
|
||||||
content: string
|
content: string
|
||||||
plain_content?: string | null
|
plain_content?: string | null
|
||||||
created_at: string
|
created_at: string
|
||||||
|
edited_at: string | null
|
||||||
emojis: Emoji[]
|
emojis: Emoji[]
|
||||||
replies_count: number
|
replies_count: number
|
||||||
reblogs_count: number
|
reblogs_count: number
|
||||||
|
|
|
@ -725,6 +725,7 @@ namespace FriendicaAPI {
|
||||||
content: s.content,
|
content: s.content,
|
||||||
plain_content: null,
|
plain_content: null,
|
||||||
created_at: s.created_at,
|
created_at: s.created_at,
|
||||||
|
edited_at: s.edited_at || null,
|
||||||
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
||||||
replies_count: s.replies_count,
|
replies_count: s.replies_count,
|
||||||
reblogs_count: s.reblogs_count,
|
reblogs_count: s.reblogs_count,
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace FriendicaEntity {
|
||||||
reblog: Status | null
|
reblog: Status | null
|
||||||
content: string
|
content: string
|
||||||
created_at: string
|
created_at: string
|
||||||
|
edited_at?: string | null
|
||||||
emojis: Emoji[]
|
emojis: Emoji[]
|
||||||
replies_count: number
|
replies_count: number
|
||||||
reblogs_count: number
|
reblogs_count: number
|
||||||
|
|
|
@ -628,6 +628,7 @@ namespace MastodonAPI {
|
||||||
content: s.content,
|
content: s.content,
|
||||||
plain_content: null,
|
plain_content: null,
|
||||||
created_at: s.created_at,
|
created_at: s.created_at,
|
||||||
|
edited_at: s.edited_at || null,
|
||||||
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
||||||
replies_count: s.replies_count,
|
replies_count: s.replies_count,
|
||||||
reblogs_count: s.reblogs_count,
|
reblogs_count: s.reblogs_count,
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace MastodonEntity {
|
||||||
reblog: Status | null
|
reblog: Status | null
|
||||||
content: string
|
content: string
|
||||||
created_at: string
|
created_at: string
|
||||||
|
edited_at?: string | null
|
||||||
emojis: Emoji[]
|
emojis: Emoji[]
|
||||||
replies_count: number
|
replies_count: number
|
||||||
reblogs_count: number
|
reblogs_count: number
|
||||||
|
|
|
@ -283,6 +283,7 @@ namespace MisskeyAPI {
|
||||||
: '',
|
: '',
|
||||||
plain_content: n.text ? n.text : null,
|
plain_content: n.text ? n.text : null,
|
||||||
created_at: n.createdAt,
|
created_at: n.createdAt,
|
||||||
|
edited_at: n.updatedAt || null,
|
||||||
emojis: mapEmojis(n.emojis).concat(mapReactionEmojis(n.reactionEmojis)),
|
emojis: mapEmojis(n.emojis).concat(mapReactionEmojis(n.reactionEmojis)),
|
||||||
replies_count: n.repliesCount,
|
replies_count: n.repliesCount,
|
||||||
reblogs_count: n.renoteCount,
|
reblogs_count: n.renoteCount,
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace MisskeyEntity {
|
||||||
export type Note = {
|
export type Note = {
|
||||||
id: string
|
id: string
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
updatedAt?: string | null
|
||||||
userId: string
|
userId: string
|
||||||
user: User
|
user: User
|
||||||
text: string | null
|
text: string | null
|
||||||
|
|
|
@ -357,6 +357,7 @@ namespace PleromaAPI {
|
||||||
content: s.content,
|
content: s.content,
|
||||||
plain_content: s.pleroma.content?.['text/plain'] ? s.pleroma.content['text/plain'] : null,
|
plain_content: s.pleroma.content?.['text/plain'] ? s.pleroma.content['text/plain'] : null,
|
||||||
created_at: s.created_at,
|
created_at: s.created_at,
|
||||||
|
edited_at: s.edited_at || null,
|
||||||
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
||||||
replies_count: s.replies_count,
|
replies_count: s.replies_count,
|
||||||
reblogs_count: s.reblogs_count,
|
reblogs_count: s.reblogs_count,
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace PleromaEntity {
|
||||||
reblog: Status | null
|
reblog: Status | null
|
||||||
content: string
|
content: string
|
||||||
created_at: string
|
created_at: string
|
||||||
|
edited_at?: string | null
|
||||||
emojis: Emoji[]
|
emojis: Emoji[]
|
||||||
replies_count: number
|
replies_count: number
|
||||||
reblogs_count: number
|
reblogs_count: number
|
||||||
|
|
|
@ -49,6 +49,7 @@ const status: Entity.Status = {
|
||||||
content: 'hoge',
|
content: 'hoge',
|
||||||
plain_content: null,
|
plain_content: null,
|
||||||
created_at: '2019-03-26T21:40:32',
|
created_at: '2019-03-26T21:40:32',
|
||||||
|
edited_at: null,
|
||||||
emojis: [],
|
emojis: [],
|
||||||
replies_count: 0,
|
replies_count: 0,
|
||||||
reblogs_count: 0,
|
reblogs_count: 0,
|
||||||
|
|
|
@ -38,6 +38,7 @@ const status: Entity.Status = {
|
||||||
content: 'hoge',
|
content: 'hoge',
|
||||||
plain_content: 'hoge',
|
plain_content: 'hoge',
|
||||||
created_at: '2019-03-26T21:40:32',
|
created_at: '2019-03-26T21:40:32',
|
||||||
|
edited_at: null,
|
||||||
emojis: [],
|
emojis: [],
|
||||||
replies_count: 0,
|
replies_count: 0,
|
||||||
reblogs_count: 0,
|
reblogs_count: 0,
|
||||||
|
|
|
@ -37,6 +37,7 @@ const status: Entity.Status = {
|
||||||
content: 'hoge',
|
content: 'hoge',
|
||||||
plain_content: 'hoge',
|
plain_content: 'hoge',
|
||||||
created_at: '2019-03-26T21:40:32',
|
created_at: '2019-03-26T21:40:32',
|
||||||
|
edited_at: null,
|
||||||
emojis: [],
|
emojis: [],
|
||||||
replies_count: 0,
|
replies_count: 0,
|
||||||
reblogs_count: 0,
|
reblogs_count: 0,
|
||||||
|
|
Loading…
Reference in a new issue