mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-25 06:33:09 +02:00
Compare commits
70 commits
70199a8fab
...
e00f1a5e56
Author | SHA1 | Date | |
---|---|---|---|
|
e00f1a5e56 | ||
|
e0afeff248 | ||
|
cfc8081cec | ||
|
011ccd3a9a | ||
|
28065fc1d1 | ||
|
960f4fcff7 | ||
|
92eec2178f | ||
|
56dca6dbf5 | ||
|
bb7b4a8ea4 | ||
|
0690b9a429 | ||
|
e779c1e667 | ||
|
8c955fcce5 | ||
|
2a634e0309 | ||
|
e6970a0e7c | ||
|
571272a564 | ||
|
30bb0f60a2 | ||
|
328546c4cd | ||
|
126248e58d | ||
|
074de82bf7 | ||
|
bd7c4f66f3 | ||
|
f4e89f2e6b | ||
|
ecfaf7ff7a | ||
|
58bc8f2c10 | ||
|
94aed953b5 | ||
|
aa7035a35a | ||
|
45eab01fc4 | ||
|
71bcd76cc5 | ||
|
a69315a24b | ||
|
d003c3ec1f | ||
|
b918f38ec2 | ||
|
cdb82c0ade | ||
|
d991eccd3f | ||
|
0085305579 | ||
|
6826e43ad7 | ||
|
ff189b1952 | ||
|
43544a6479 | ||
|
03464cc379 | ||
|
2cad97c1ab | ||
|
6ecfe7c7c3 | ||
|
23f476dbf3 | ||
|
7a1251423f | ||
|
7f5492a395 | ||
|
11d9fd9199 | ||
|
6132bc3b3e | ||
|
fef7a7b99a | ||
|
1948ca9aa8 | ||
|
848e1f9a56 | ||
|
9c4353ee79 | ||
|
a6e257f502 | ||
|
310e1a1262 | ||
|
15f3c046d1 | ||
|
01d695428a | ||
|
acf3e3460f | ||
|
4c8116859c | ||
|
0e13397db7 | ||
|
ad8818508f | ||
|
d444ee662f | ||
|
4c354fff2d | ||
|
b81448edf6 | ||
|
134d2895f0 | ||
|
7ba8fde9b9 | ||
|
1022280465 | ||
|
021d3924e6 | ||
|
b6d50d781f | ||
|
1d411bb885 | ||
|
f7afd1ae4a | ||
|
1ef1f2a03c | ||
|
829ce4f86a | ||
|
6d5d863150 | ||
|
fc7d4bc420 |
42 changed files with 228 additions and 47 deletions
|
@ -11,7 +11,7 @@ testCommit:
|
|||
variables:
|
||||
POSTGRES_PASSWORD: ci
|
||||
script:
|
||||
- apt-get update && apt-get install -y git wget curl build-essential python3
|
||||
- apt-get update && apt-get install -y git wget curl build-essential python3
|
||||
- cp .config/ci.yml .config/default.yml
|
||||
- corepack enable
|
||||
- corepack prepare pnpm@latest --activate
|
||||
|
@ -55,6 +55,8 @@ getImageTag:
|
|||
only:
|
||||
- stable
|
||||
- develop
|
||||
- tags
|
||||
|
||||
buildDocker:
|
||||
stage: deploy
|
||||
needs:
|
||||
|
@ -78,6 +80,8 @@ buildDocker:
|
|||
only:
|
||||
- stable
|
||||
- develop
|
||||
- tags
|
||||
|
||||
mergeManifests:
|
||||
stage: deploy
|
||||
needs:
|
||||
|
@ -103,3 +107,4 @@ mergeManifests:
|
|||
only:
|
||||
- stable
|
||||
- develop
|
||||
- tags
|
||||
|
|
|
@ -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.)
|
||||
|
||||
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.
|
||||
|
||||
Please understand these points and enjoy using the service.
|
||||
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.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "sharkey",
|
||||
"version": "2024.3.1",
|
||||
"version": "2024.3.2-devel",
|
||||
"codename": "shonk",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -11,7 +11,11 @@ export default new DataSource({
|
|||
username: config.db.user,
|
||||
password: config.db.pass,
|
||||
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,
|
||||
migrations: ['migration/*.js'],
|
||||
});
|
||||
|
|
|
@ -172,7 +172,7 @@
|
|||
"stringz": "2.1.0",
|
||||
"systeminformation": "5.22.0",
|
||||
"tinycolor2": "1.6.0",
|
||||
"tmp": "0.2.2",
|
||||
"tmp": "0.2.3",
|
||||
"tsc-alias": "1.8.8",
|
||||
"tsconfig-paths": "4.2.0",
|
||||
"typeorm": "0.3.20",
|
||||
|
|
|
@ -15,6 +15,7 @@ import type { Config } from '@/config.js';
|
|||
import { StatusError } from '@/misc/status-error.js';
|
||||
import { bindThis } from '@/decorators.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 { Response } from 'node-fetch';
|
||||
import type { URL } from 'node:url';
|
||||
|
@ -125,7 +126,12 @@ export class HttpRequestService {
|
|||
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
|
||||
|
|
|
@ -86,7 +86,7 @@ export class UtilityService {
|
|||
@bindThis
|
||||
public extractDbHost(uri: string): string {
|
||||
const url = new URL(uri);
|
||||
return this.toPuny(url.hostname);
|
||||
return this.toPuny(url.host);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
@ -99,4 +99,11 @@ export class UtilityService {
|
|||
if (host == null) return null;
|
||||
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 { bindThis } from '@/decorators.js';
|
||||
import type Logger from '@/logger.js';
|
||||
import type { IObject } from './type.js';
|
||||
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
|
||||
import { assertActivityMatchesUrls } from '@/core/activitypub/misc/check-against-url.js';
|
||||
|
||||
type Request = {
|
||||
url: string;
|
||||
|
@ -201,6 +203,11 @@ export class ApRequestService {
|
|||
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');
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
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
|
||||
* @param x Fetched object
|
||||
|
@ -140,7 +134,7 @@ export class ApPersonService implements OnModuleInit {
|
|||
*/
|
||||
@bindThis
|
||||
private validateActor(x: IObject, uri: string): IActor {
|
||||
const expectHost = this.punyHost(uri);
|
||||
const expectHost = this.utilityService.punyHost(uri);
|
||||
|
||||
if (!isActor(x)) {
|
||||
throw new Error(`invalid Actor type '${x.type}'`);
|
||||
|
@ -154,6 +148,19 @@ export class ApPersonService implements OnModuleInit {
|
|||
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))) {
|
||||
throw new Error('invalid Actor: wrong username');
|
||||
}
|
||||
|
@ -177,7 +184,7 @@ export class ApPersonService implements OnModuleInit {
|
|||
x.summary = truncate(x.summary, summaryLength);
|
||||
}
|
||||
|
||||
const idHost = this.punyHost(x.id);
|
||||
const idHost = this.utilityService.punyHost(x.id);
|
||||
if (idHost !== expectHost) {
|
||||
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');
|
||||
}
|
||||
|
||||
const publicKeyIdHost = this.punyHost(x.publicKey.id);
|
||||
const publicKeyIdHost = this.utilityService.punyHost(x.publicKey.id);
|
||||
if (publicKeyIdHost !== expectHost) {
|
||||
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}`);
|
||||
|
||||
const host = this.punyHost(object.id);
|
||||
const host = this.utilityService.punyHost(object.id);
|
||||
|
||||
const fields = this.analyzeAttachments(person.attachment ?? []);
|
||||
|
||||
|
|
|
@ -421,7 +421,7 @@ export class ImportNotesProcessorService {
|
|||
if (file.name) {
|
||||
this.driveService.updateFile(exists, { comment: file.name }, user);
|
||||
}
|
||||
|
||||
|
||||
files.push(exists);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,6 +192,7 @@ export class FileServerService {
|
|||
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||
reply.header('Accept-Ranges', 'bytes');
|
||||
reply.header('Content-Length', chunksize);
|
||||
reply.code(206);
|
||||
} else {
|
||||
image = {
|
||||
data: fs.createReadStream(file.path),
|
||||
|
@ -261,7 +262,6 @@ export class FileServerService {
|
|||
const parts = range.replace(/bytes=/, '').split('-');
|
||||
const start = parseInt(parts[0], 10);
|
||||
let end = parts[1] ? parseInt(parts[1], 10) : file.file.size - 1;
|
||||
console.log(end);
|
||||
if (end > file.file.size) {
|
||||
end = file.file.size - 1;
|
||||
}
|
||||
|
@ -431,6 +431,7 @@ export class FileServerService {
|
|||
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||
reply.header('Accept-Ranges', 'bytes');
|
||||
reply.header('Content-Length', chunksize);
|
||||
reply.code(206);
|
||||
} else {
|
||||
image = {
|
||||
data: fs.createReadStream(file.path),
|
||||
|
@ -527,6 +528,9 @@ export class FileServerService {
|
|||
if (!file.storedInternal) {
|
||||
if (!(file.isLink && file.uri)) return '204';
|
||||
const result = await this.downloadAndDetectTypeFromUrl(file.uri);
|
||||
if (!file.size) {
|
||||
file.size = (await fs.promises.stat(result.path)).size;
|
||||
}
|
||||
return {
|
||||
...result,
|
||||
url: file.uri,
|
||||
|
|
|
@ -113,8 +113,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
@bindThis
|
||||
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();
|
||||
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([
|
||||
this.apDbResolverService.getUserFromApId(uri),
|
||||
|
@ -122,6 +123,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
]));
|
||||
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 object = await resolver.resolve(uri) as any;
|
||||
|
|
|
@ -83,7 +83,7 @@ export class MastoConverters {
|
|||
}
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
|
||||
public encodeFile(f: any): Entity.Attachment {
|
||||
return {
|
||||
id: f.id,
|
||||
|
@ -279,7 +279,8 @@ export class MastoConverters {
|
|||
emoji_reactions: status.emoji_reactions,
|
||||
bookmarked: 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='/static-assets/fonts/sharkey-icons/style.css')
|
||||
link(rel='modulepreload' href=`/vite/${clientEntry.file}`)
|
||||
script(src='/client-assets/libopenmpt.js')
|
||||
|
||||
if !config.clientManifestExists
|
||||
script(type="module" src="/vite/@vite/client")
|
||||
|
@ -73,7 +72,6 @@ html
|
|||
script.
|
||||
var VERSION = "#{version}";
|
||||
var CLIENT_ENTRY = "#{clientEntry.file}";
|
||||
window.libopenmpt = window.Module;
|
||||
|
||||
script(type='application/json' id='misskey_meta' data-generated-at=now)
|
||||
!= metaJson
|
||||
|
|
|
@ -5,8 +5,8 @@ block vars
|
|||
- const title = user.name ? `${user.name} (@${user.username})` : `@${user.username}`;
|
||||
- const url = `${config.url}/notes/${note.id}`;
|
||||
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
|
||||
- const images = (note.files || []).filter(file => file.type.startsWith('image/') && !file.isSensitive)
|
||||
- const videos = (note.files || []).filter(file => file.type.startsWith('video/') && !file.isSensitive)
|
||||
- const images = note.cw ? [] : (note.files || []).filter(file => file.type.startsWith('image/') && !file.isSensitive)
|
||||
- const videos = note.cw ? [] : (note.files || []).filter(file => file.type.startsWith('video/') && !file.isSensitive)
|
||||
|
||||
block title
|
||||
= `${title} | ${instanceName}`
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -43,6 +43,7 @@ export async function signout() {
|
|||
waiting();
|
||||
miLocalStorage.removeItem('account');
|
||||
await removeAccount($i.id);
|
||||
document.cookie = `token=; path=/; max-age=0${ location.protocol === 'https:' ? '; Secure' : ''}`;
|
||||
const accounts = await getAccounts();
|
||||
|
||||
//#region Remove service worker registration
|
||||
|
@ -200,7 +201,7 @@ export async function login(token: Account['token'], redirect?: string) {
|
|||
throw reason;
|
||||
});
|
||||
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);
|
||||
|
||||
if (redirect) {
|
||||
|
|
|
@ -72,12 +72,16 @@ watch(() => props.lang, (to) => {
|
|||
</script>
|
||||
|
||||
<style module lang="scss">
|
||||
.codeBlockRoot {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.codeBlockRoot :global(.shiki) > code {
|
||||
counter-reset: step;
|
||||
counter-increment: step 0;
|
||||
}
|
||||
|
||||
.codeBlockRoot :global(.shiki) > code > .line::before {
|
||||
.codeBlockRoot :global(.shiki) > code > span::before {
|
||||
content: counter(step);
|
||||
counter-increment: step;
|
||||
width: 1rem;
|
||||
|
|
|
@ -55,8 +55,6 @@ import { i18n } from '@/i18n.js';
|
|||
import { infoImageUrl } from '@/instance.js';
|
||||
import { defaultStore } from '@/store.js';
|
||||
|
||||
console.log(defaultStore.state.noteDesign, defaultStore.state.noteDesign === 'sharkey');
|
||||
|
||||
const props = defineProps<{
|
||||
pagination: Paging;
|
||||
noGap?: boolean;
|
||||
|
|
|
@ -16,9 +16,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<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"/>
|
||||
</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>
|
||||
</MkPagination>
|
||||
</MkSpacer>
|
||||
|
@ -28,10 +33,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<script lang="ts" setup>
|
||||
import MkPagination from '@/components/MkPagination.vue';
|
||||
import MkNote from '@/components/MkNote.vue';
|
||||
import SkNote from '@/components/SkNote.vue';
|
||||
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import { infoImageUrl } from '@/instance.js';
|
||||
import { defaultStore } from '@/store.js';
|
||||
|
||||
const pagination = {
|
||||
endpoint: 'i/favorites' as const,
|
||||
|
|
|
@ -40,7 +40,7 @@ const isScrolling = ref(false);
|
|||
const scrollEl = shallowRef<HTMLElement>();
|
||||
|
||||
misskeyApiGet('notes/featured').then(_notes => {
|
||||
notes.value = _notes;
|
||||
notes.value = _notes.filter(n => n.cw == null);
|
||||
});
|
||||
|
||||
onUpdated(() => {
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
/* global libopenmpt UTF8ToString writeAsciiToMemory */
|
||||
// @ts-nocheck
|
||||
/* eslint-disable */
|
||||
|
||||
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.context = context;
|
||||
}
|
||||
|
@ -20,6 +23,28 @@ export function ChiptuneJsPlayer (config: object) {
|
|||
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.fireEvent = function (eventName: string, response) {
|
||||
|
@ -61,12 +86,12 @@ ChiptuneJsPlayer.prototype.seek = function (position: number) {
|
|||
|
||||
ChiptuneJsPlayer.prototype.metadata = function () {
|
||||
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;
|
||||
for (const key of keys) {
|
||||
keyNameBuffer = libopenmpt._malloc(key.length + 1);
|
||||
writeAsciiToMemory(key, keyNameBuffer);
|
||||
data[key] = UTF8ToString(libopenmpt._openmpt_module_get_metadata(this.currentPlayingNode.modulePtr, keyNameBuffer));
|
||||
libopenmpt.writeAsciiToMemory(key, keyNameBuffer);
|
||||
data[key] = libopenmpt.UTF8ToString(libopenmpt._openmpt_module_get_metadata(this.currentPlayingNode.modulePtr, keyNameBuffer));
|
||||
libopenmpt._free(keyNameBuffer);
|
||||
}
|
||||
return data;
|
||||
|
@ -84,7 +109,7 @@ ChiptuneJsPlayer.prototype.unlock = function () {
|
|||
};
|
||||
|
||||
ChiptuneJsPlayer.prototype.load = function (input) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return this.initialize().then(() => new Promise((resolve, reject) => {
|
||||
if(this.touchLocked) {
|
||||
this.unlock();
|
||||
}
|
||||
|
@ -106,7 +131,7 @@ ChiptuneJsPlayer.prototype.load = function (input) {
|
|||
reject(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
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) {
|
||||
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 '';
|
||||
};
|
||||
|
|
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 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 => {
|
||||
let h1 = 0xdeadbeef ^ seed,
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace Entity {
|
|||
content: string
|
||||
plain_content?: string | null
|
||||
created_at: string
|
||||
edited_at: string | null
|
||||
emojis: Emoji[]
|
||||
replies_count: number
|
||||
reblogs_count: number
|
||||
|
|
|
@ -725,6 +725,7 @@ namespace FriendicaAPI {
|
|||
content: s.content,
|
||||
plain_content: null,
|
||||
created_at: s.created_at,
|
||||
edited_at: s.edited_at || null,
|
||||
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
||||
replies_count: s.replies_count,
|
||||
reblogs_count: s.reblogs_count,
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace FriendicaEntity {
|
|||
reblog: Status | null
|
||||
content: string
|
||||
created_at: string
|
||||
edited_at?: string | null
|
||||
emojis: Emoji[]
|
||||
replies_count: number
|
||||
reblogs_count: number
|
||||
|
|
|
@ -628,6 +628,7 @@ namespace MastodonAPI {
|
|||
content: s.content,
|
||||
plain_content: null,
|
||||
created_at: s.created_at,
|
||||
edited_at: s.edited_at || null,
|
||||
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
||||
replies_count: s.replies_count,
|
||||
reblogs_count: s.reblogs_count,
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace MastodonEntity {
|
|||
reblog: Status | null
|
||||
content: string
|
||||
created_at: string
|
||||
edited_at?: string | null
|
||||
emojis: Emoji[]
|
||||
replies_count: number
|
||||
reblogs_count: number
|
||||
|
|
|
@ -283,6 +283,7 @@ namespace MisskeyAPI {
|
|||
: '',
|
||||
plain_content: n.text ? n.text : null,
|
||||
created_at: n.createdAt,
|
||||
edited_at: n.updatedAt || null,
|
||||
emojis: mapEmojis(n.emojis).concat(mapReactionEmojis(n.reactionEmojis)),
|
||||
replies_count: n.repliesCount,
|
||||
reblogs_count: n.renoteCount,
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace MisskeyEntity {
|
|||
export type Note = {
|
||||
id: string
|
||||
createdAt: string
|
||||
updatedAt?: string | null
|
||||
userId: string
|
||||
user: User
|
||||
text: string | null
|
||||
|
|
|
@ -357,6 +357,7 @@ namespace PleromaAPI {
|
|||
content: s.content,
|
||||
plain_content: s.pleroma.content?.['text/plain'] ? s.pleroma.content['text/plain'] : null,
|
||||
created_at: s.created_at,
|
||||
edited_at: s.edited_at || null,
|
||||
emojis: Array.isArray(s.emojis) ? s.emojis.map(e => emoji(e)) : [],
|
||||
replies_count: s.replies_count,
|
||||
reblogs_count: s.reblogs_count,
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace PleromaEntity {
|
|||
reblog: Status | null
|
||||
content: string
|
||||
created_at: string
|
||||
edited_at?: string | null
|
||||
emojis: Emoji[]
|
||||
replies_count: number
|
||||
reblogs_count: number
|
||||
|
|
|
@ -49,6 +49,7 @@ const status: Entity.Status = {
|
|||
content: 'hoge',
|
||||
plain_content: null,
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
edited_at: null,
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
|
|
|
@ -38,6 +38,7 @@ const status: Entity.Status = {
|
|||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
edited_at: null,
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
|
|
|
@ -37,6 +37,7 @@ const status: Entity.Status = {
|
|||
content: 'hoge',
|
||||
plain_content: 'hoge',
|
||||
created_at: '2019-03-26T21:40:32',
|
||||
edited_at: null,
|
||||
emojis: [],
|
||||
replies_count: 0,
|
||||
reblogs_count: 0,
|
||||
|
|
|
@ -392,8 +392,8 @@ importers:
|
|||
specifier: 1.6.0
|
||||
version: 1.6.0
|
||||
tmp:
|
||||
specifier: 0.2.2
|
||||
version: 0.2.2
|
||||
specifier: 0.2.3
|
||||
version: 0.2.3
|
||||
tsc-alias:
|
||||
specifier: 1.8.8
|
||||
version: 1.8.8
|
||||
|
@ -18813,6 +18813,12 @@ packages:
|
|||
engines: {node: '>=14'}
|
||||
dependencies:
|
||||
rimraf: 5.0.5
|
||||
dev: true
|
||||
|
||||
/tmp@0.2.3:
|
||||
resolution: {integrity: sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==}
|
||||
engines: {node: '>=14.14'}
|
||||
dev: false
|
||||
|
||||
/tmpl@1.0.5:
|
||||
resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}
|
||||
|
|
Loading…
Reference in a new issue