mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-22 21:13:09 +02:00
Compare commits
15 commits
eaccbe11d8
...
a133ff0d9b
Author | SHA1 | Date | |
---|---|---|---|
|
a133ff0d9b | ||
|
bb7b4a8ea4 | ||
|
0690b9a429 | ||
|
e779c1e667 | ||
|
7730472c77 | ||
|
de80727cfc | ||
|
459e684117 | ||
|
ccf5659ac3 | ||
|
8f300cf460 | ||
|
395ea9ab9f | ||
|
a0c63c8cc4 | ||
|
ecfaf7ff7a | ||
|
a69315a24b | ||
|
d991eccd3f | ||
|
0085305579 |
29 changed files with 202 additions and 15 deletions
|
@ -688,6 +688,7 @@ channel: "Channels"
|
|||
create: "Create"
|
||||
notificationSetting: "Notification settings"
|
||||
notificationSettingDesc: "Select the types of notification to display."
|
||||
enableFaviconNotificationDot: "Enable favicon notification dot"
|
||||
useGlobalSetting: "Use global settings"
|
||||
useGlobalSettingDesc: "If turned on, your account's notification settings will be used. If turned off, individual configurations can be made."
|
||||
other: "Other"
|
||||
|
|
4
locales/index.d.ts
vendored
4
locales/index.d.ts
vendored
|
@ -2764,6 +2764,10 @@ export interface Locale extends ILocale {
|
|||
* 表示する通知の種別を選択してください。
|
||||
*/
|
||||
"notificationSettingDesc": string;
|
||||
/**
|
||||
* ファビコン通知ドットを有効にする
|
||||
*/
|
||||
"enableFaviconNotificationDot": string;
|
||||
/**
|
||||
* グローバル設定を使う
|
||||
*/
|
||||
|
|
|
@ -687,6 +687,7 @@ channel: "チャンネル"
|
|||
create: "作成"
|
||||
notificationSetting: "通知設定"
|
||||
notificationSettingDesc: "表示する通知の種別を選択してください。"
|
||||
enableFaviconNotificationDot: "ファビコン通知ドットを有効にする"
|
||||
useGlobalSetting: "グローバル設定を使う"
|
||||
useGlobalSettingDesc: "オンにすると、アカウントの通知設定が使用されます。オフにすると、個別に設定できるようになります。"
|
||||
other: "その他"
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -112,6 +112,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<div class="_gaps_m">
|
||||
<MkSwitch v-model="useGroupedNotifications">{{ i18n.ts.useGroupedNotifications }}</MkSwitch>
|
||||
|
||||
<MkSwitch v-model="enableFaviconNotificationDot">{{ i18n.ts.enableFaviconNotificationDot }}</MkSwitch>
|
||||
|
||||
<MkRadios v-model="notificationPosition">
|
||||
<template #label>{{ i18n.ts.position }}</template>
|
||||
<option value="leftTop"><i class="ph-arrow-up-left ph-bold ph-lg"></i> {{ i18n.ts.leftTop }}</option>
|
||||
|
@ -337,6 +339,7 @@ const oneko = computed(defaultStore.makeGetterSetter('oneko'));
|
|||
const loadRawImages = computed(defaultStore.makeGetterSetter('loadRawImages'));
|
||||
const highlightSensitiveMedia = computed(defaultStore.makeGetterSetter('highlightSensitiveMedia'));
|
||||
const imageNewTab = computed(defaultStore.makeGetterSetter('imageNewTab'));
|
||||
const enableFaviconNotificationDot = computed(defaultStore.makeGetterSetter('enableFaviconNotificationDot'));
|
||||
const warnMissingAltText = computed(defaultStore.makeGetterSetter('warnMissingAltText'));
|
||||
const nsfw = computed(defaultStore.makeGetterSetter('nsfw'));
|
||||
const showFixedPostForm = computed(defaultStore.makeGetterSetter('showFixedPostForm'));
|
||||
|
|
|
@ -72,6 +72,7 @@ const defaultStoreSaveKeys: (keyof typeof defaultStore['state'])[] = [
|
|||
'advancedMfm',
|
||||
'loadRawImages',
|
||||
'warnMissingAltText',
|
||||
'enableFaviconNotificationDot',
|
||||
'imageNewTab',
|
||||
'dataSaver',
|
||||
'disableShowingAnimatedImages',
|
||||
|
|
|
@ -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 '';
|
||||
};
|
||||
|
|
75
packages/frontend/src/scripts/favicon-dot.ts
Normal file
75
packages/frontend/src/scripts/favicon-dot.ts
Normal file
|
@ -0,0 +1,75 @@
|
|||
class FavIconDot {
|
||||
canvas : HTMLCanvasElement;
|
||||
src : string | null = null;
|
||||
ctx : CanvasRenderingContext2D | null = null;
|
||||
favconImage : HTMLImageElement | null = null;
|
||||
faviconEL : HTMLLinkElement;
|
||||
hasLoaded : Promise<void>;
|
||||
|
||||
constructor() {
|
||||
this.canvas = document.createElement('canvas');
|
||||
this.faviconEL = document.querySelector<HTMLLinkElement>('link[rel$=icon]') ?? this._createFaviconElem();
|
||||
|
||||
this.src = this.faviconEL.getAttribute('href');
|
||||
this.ctx = this.canvas.getContext('2d');
|
||||
|
||||
this.favconImage = document.createElement('img');
|
||||
this.hasLoaded = new Promise((resolve, _reject) => {
|
||||
if (this.favconImage != null) {
|
||||
this.favconImage.onload = () => {
|
||||
this.canvas.width = (this.favconImage as HTMLImageElement).width;
|
||||
this.canvas.height = (this.favconImage as HTMLImageElement).height;
|
||||
// resolve();
|
||||
setTimeout(() => resolve(), 200);
|
||||
};
|
||||
}
|
||||
});
|
||||
this.favconImage.src = this.faviconEL.href;
|
||||
}
|
||||
|
||||
private _createFaviconElem() {
|
||||
const newLink = document.createElement('link');
|
||||
newLink.rel = 'icon';
|
||||
newLink.href = '/favicon.ico';
|
||||
document.head.appendChild(newLink);
|
||||
return newLink;
|
||||
}
|
||||
|
||||
private _drawIcon() {
|
||||
if (!this.ctx || !this.favconImage) return;
|
||||
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
this.ctx.drawImage(this.favconImage, 0, 0, this.favconImage.width, this.favconImage.height);
|
||||
}
|
||||
|
||||
private _drawDot() {
|
||||
if (!this.ctx || !this.favconImage) return;
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(this.favconImage.width - 10, 10, 10, 0, 2 * Math.PI);
|
||||
this.ctx.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--navIndicator');
|
||||
this.ctx.strokeStyle = 'white';
|
||||
this.ctx.fill();
|
||||
this.ctx.stroke();
|
||||
}
|
||||
|
||||
private _setFavicon() {
|
||||
this.faviconEL.href = this.canvas.toDataURL('image/png');
|
||||
}
|
||||
|
||||
async setVisible(isVisible : boolean) {
|
||||
//Wait for it to have loaded the icon
|
||||
await this.hasLoaded;
|
||||
console.log(this.hasLoaded);
|
||||
this._drawIcon();
|
||||
if (isVisible) this._drawDot();
|
||||
this._setFavicon();
|
||||
}
|
||||
}
|
||||
|
||||
let icon: FavIconDot = new FavIconDot();
|
||||
|
||||
export function setFavIconDot(visible: boolean) {
|
||||
if (!icon) {
|
||||
icon = new FavIconDot();
|
||||
}
|
||||
icon.setVisible(visible);
|
||||
}
|
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
|
||||
```
|
|
@ -268,6 +268,10 @@ export const defaultStore = markRaw(new Storage('base', {
|
|||
where: 'device',
|
||||
default: true,
|
||||
},
|
||||
enableFaviconNotificationDot: {
|
||||
where: 'device',
|
||||
default: true,
|
||||
},
|
||||
imageNewTab: {
|
||||
where: 'device',
|
||||
default: false,
|
||||
|
|
|
@ -47,8 +47,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { defineAsyncComponent, ref } from 'vue';
|
||||
import { defineAsyncComponent, ref, watch } from 'vue';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { setFavIconDot } from '../../scripts/favicon-dot';
|
||||
import { swInject } from './sw-inject.js';
|
||||
import XNotification from './notification.vue';
|
||||
import { popups } from '@/os.js';
|
||||
|
@ -93,6 +94,12 @@ function onNotification(notification: Misskey.entities.Notification, isClient =
|
|||
if ($i) {
|
||||
const connection = useStream().useChannel('main', null, 'UI');
|
||||
connection.on('notification', onNotification);
|
||||
|
||||
//For the favicon notification dot
|
||||
watch(() => $i?.hasUnreadNotification, (hasAny) => setFavIconDot((defaultStore.state.enableFaviconNotificationDot ? hasAny : false) ?? false));
|
||||
|
||||
if ($i.hasUnreadNotification && defaultStore.state.enableFaviconNotificationDot) setFavIconDot(true);
|
||||
|
||||
globalEvents.on('clientNotification', notification => onNotification(notification, true));
|
||||
|
||||
//#region Listen message from SW
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue