style: many typescript v6 pending errors
This commit is contained in:
@@ -26,6 +26,7 @@ const {
|
||||
checkMacOSPermission,
|
||||
requestMacOSPermission,
|
||||
} = useElectronScreenCapture(window.electron.ipcRenderer, sourcesOptions)
|
||||
|
||||
const focused = useWindowFocus()
|
||||
|
||||
async function checkPermissions() {
|
||||
|
||||
@@ -28,10 +28,7 @@ const sourcesOptions = ref<SourcesOptions>({
|
||||
})
|
||||
|
||||
const { t } = useI18n()
|
||||
const {
|
||||
getSources,
|
||||
selectWithSource,
|
||||
} = useElectronScreenCapture(window.electron.ipcRenderer, sourcesOptions)
|
||||
const { getSources, selectWithSource } = useElectronScreenCapture(window.electron.ipcRenderer, sourcesOptions)
|
||||
|
||||
const categoryOptions = [
|
||||
{ label: 'Applications', value: 'applications', icon: 'i-solar:window-frame-line-duotone' },
|
||||
@@ -90,13 +87,16 @@ function toObjectUrl(bytes: Uint8Array, mime: string) {
|
||||
|
||||
async function startCapture(source: SerializableDesktopCapturerSource) {
|
||||
try {
|
||||
await selectWithSource(() => source.id, async () => {
|
||||
const stream = await navigator.mediaDevices.getDisplayMedia({
|
||||
video: true,
|
||||
audio: true,
|
||||
})
|
||||
activeStreams.value.push(stream)
|
||||
})
|
||||
await selectWithSource(
|
||||
() => source.id,
|
||||
async () => {
|
||||
const stream = await navigator.mediaDevices.getDisplayMedia({
|
||||
video: true,
|
||||
audio: true,
|
||||
})
|
||||
activeStreams.value.push(stream)
|
||||
},
|
||||
)
|
||||
}
|
||||
catch (err) {
|
||||
console.error('Error selecting source:', err)
|
||||
|
||||
@@ -146,6 +146,7 @@ words:
|
||||
- kirakira
|
||||
- knip
|
||||
- kwaa
|
||||
- Landmarker
|
||||
- lemonneko
|
||||
- lemonnekogh
|
||||
- lerp
|
||||
@@ -182,6 +183,7 @@ words:
|
||||
- minisearch
|
||||
- mkdist
|
||||
- mobileprovision
|
||||
- Mocap
|
||||
- modelcontextprotocol
|
||||
- modnet
|
||||
- moeru
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"strict": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitReturns": true,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ESNext"
|
||||
],
|
||||
"module": "ESNext",
|
||||
|
||||
@@ -8,7 +8,7 @@ import { defineInvoke } from '@moeru/eventa'
|
||||
import { screenCaptureCheckMacOSPermission, screenCaptureGetSources, screenCaptureRequestMacOSPermission, screenCaptureResetSource, screenCaptureSetSourceEx } from '.'
|
||||
|
||||
export interface SourceOptionsWithRequest {
|
||||
sourcesOptions?: SourcesOptions
|
||||
sourcesOptions: SourcesOptions
|
||||
request?: Omit<ScreenCaptureSetSourceRequest, 'options' | 'sourceId'>
|
||||
}
|
||||
|
||||
@@ -27,17 +27,17 @@ export function setupElectronScreenCapture(context: ReturnType<typeof createCont
|
||||
async function selectWithSource<R>(
|
||||
selectFn: (sources: SerializableDesktopCapturerSource[]) => string | Promise<string>,
|
||||
useFn: () => R | Promise<R>,
|
||||
options?: SourceOptionsWithRequest,
|
||||
options: SourceOptionsWithRequest,
|
||||
): Promise<R> {
|
||||
const sources = await getSources(options?.sourcesOptions)
|
||||
const sources = await getSources(options.sourcesOptions)
|
||||
const sourceId = await selectFn(sources)
|
||||
|
||||
let handle: string | undefined
|
||||
try {
|
||||
handle = await setSource({
|
||||
options: options?.sourcesOptions,
|
||||
options: options.sourcesOptions,
|
||||
sourceId,
|
||||
timeout: options?.request?.timeout,
|
||||
timeout: options.request?.timeout,
|
||||
})
|
||||
return await useFn()
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
export { default as wlipsyncProfile } from './profile.json' assert { type: 'json' }
|
||||
export { default as wlipsyncProfile } from './profile.json' with { type: 'json' }
|
||||
export type { Profile } from 'wlipsync'
|
||||
|
||||
@@ -9,6 +9,8 @@ import { createPushStream } from '../stream'
|
||||
export const TTS_FLUSH_INSTRUCTION = '\u200B'
|
||||
export const TTS_SPECIAL_TOKEN = '\u2063'
|
||||
|
||||
const regexpAnySingleDigit = /\d/
|
||||
|
||||
const keptPunctuations = new Set('??!!')
|
||||
const hardPunctuations = new Set('.。??!!…⋯~~\n\t\r')
|
||||
const softPunctuations = new Set(',,、–—::;;《》「」')
|
||||
@@ -83,9 +85,9 @@ export async function* chunkTtsInput(
|
||||
switch (value) {
|
||||
case '.':
|
||||
case ',': {
|
||||
if (previousValue !== undefined && /\d/.test(previousValue)) {
|
||||
if (previousValue !== undefined && regexpAnySingleDigit.test(previousValue)) {
|
||||
next = await iterator.next()
|
||||
if (!next.done && next.value && /\d/.test(next.value)) {
|
||||
if (!next.done && next.value && regexpAnySingleDigit.test(next.value)) {
|
||||
buffer += value
|
||||
current = next
|
||||
next = undefined
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ESNext"
|
||||
],
|
||||
"module": "ESNext",
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import type { createContext } from '@moeru/eventa'
|
||||
import type { EventContext } from '@moeru/eventa'
|
||||
|
||||
export type ChannelHost = ReturnType<typeof createContext>
|
||||
export type ChannelHost = EventContext<unknown, { raw?: any }>
|
||||
|
||||
@@ -633,9 +633,13 @@ export class PluginHost {
|
||||
const lifecycle = createActor(pluginLifecycleMachine)
|
||||
lifecycle.start()
|
||||
|
||||
const permissionSnapshot = this.permissions.initialize(id, manifest.permissions, {
|
||||
persisted: this.persistedPermissionGrants.get(identity.plugin.id),
|
||||
})
|
||||
const permissionSnapshot = this.permissions.initialize(
|
||||
id,
|
||||
manifest.permissions,
|
||||
{
|
||||
persisted: this.persistedPermissionGrants.get(identity.plugin.id),
|
||||
},
|
||||
)
|
||||
|
||||
const session: PluginHostSession = {
|
||||
manifest,
|
||||
|
||||
@@ -54,7 +54,7 @@ export interface ManifestV1 {
|
||||
apiVersion: 'v1'
|
||||
kind: 'manifest.plugin.airi.moeru.ai'
|
||||
name: string
|
||||
permissions?: ModulePermissionDeclaration
|
||||
permissions: ModulePermissionDeclaration
|
||||
entrypoints: {
|
||||
default?: string
|
||||
electron?: string
|
||||
@@ -76,7 +76,7 @@ export const manifestV1Schema = object({
|
||||
apiVersion: literal('v1'),
|
||||
kind: literal('manifest.plugin.airi.moeru.ai'),
|
||||
name: string(),
|
||||
permissions: optional(object({
|
||||
permissions: object({
|
||||
apis: optional(array(object({
|
||||
key: string(),
|
||||
actions: array(picklist(['invoke', 'emit'])),
|
||||
@@ -112,7 +112,7 @@ export const manifestV1Schema = object({
|
||||
label: optional(localizableSchema),
|
||||
required: optional(boolean()),
|
||||
}))),
|
||||
})),
|
||||
}),
|
||||
entrypoints: object({
|
||||
default: optional(string()),
|
||||
electron: optional(string()),
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
|
||||
@@ -49,8 +49,8 @@ export interface ClientOptions<C = undefined> {
|
||||
name: string
|
||||
token?: string
|
||||
websocketConstructor?: WebSocketLikeConstructor
|
||||
connectTimeoutMs?: number
|
||||
|
||||
connectTimeoutMs?: number
|
||||
possibleEvents?: Array<keyof WebSocketEvents<C>>
|
||||
identity?: MetadataEventSource
|
||||
dependencies?: ModuleDependency[]
|
||||
@@ -126,9 +126,9 @@ export class Client<C = undefined> {
|
||||
private readonly heartbeat: Required<ClientHeartbeatOptions>
|
||||
private readonly websocketConstructor: WebSocketLikeConstructor
|
||||
|
||||
private readonly opts: Required<Omit<ClientOptions<C>, 'token' | 'heartbeat' | 'websocketConstructor'>> & Pick<ClientOptions<C>, 'token'> & {
|
||||
heartbeat: Required<ClientHeartbeatOptions>
|
||||
}
|
||||
private readonly opts:
|
||||
& Required<Omit<ClientOptions<C>, 'token' | 'heartbeat' | 'websocketConstructor' | 'configSchema'>>
|
||||
& Pick<ClientOptions<C>, 'token' | 'heartbeat' | 'configSchema'>
|
||||
|
||||
private readonly eventListeners = new Map<
|
||||
keyof WebSocketEvents<C>,
|
||||
|
||||
@@ -3,7 +3,7 @@ export interface WebSocketMessageEventLike<T = string> {
|
||||
}
|
||||
|
||||
export interface WebSocketErrorEventLike {
|
||||
error?: Error
|
||||
error?: Error | unknown
|
||||
}
|
||||
|
||||
export interface WebSocketLike {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { WebSocketEvent } from '@proj-airi/server-shared/types'
|
||||
import type { WebSocketEvent, WebSocketEventOf } from '@proj-airi/server-shared/types'
|
||||
|
||||
import superjson from 'superjson'
|
||||
|
||||
@@ -12,18 +12,18 @@ class MockWebSocket {
|
||||
|
||||
static instances: MockWebSocket[] = []
|
||||
|
||||
readonly sent: string[] = []
|
||||
readonly sent: Array<string | ArrayBufferLike | ArrayBufferView<ArrayBufferLike>> = []
|
||||
readyState = MockWebSocket.CONNECTING
|
||||
onclose?: () => void
|
||||
onerror?: (event: { error?: Error }) => void
|
||||
onmessage?: (event: { data: string }) => void
|
||||
onerror?: (event: { error?: Error } | unknown) => void
|
||||
onmessage?: (event: { data: string | ArrayBufferLike | ArrayBufferView<ArrayBufferLike> }) => void
|
||||
onopen?: () => void
|
||||
|
||||
constructor(public readonly url: string) {
|
||||
MockWebSocket.instances.push(this)
|
||||
}
|
||||
|
||||
send(data: string) {
|
||||
send(data: string | ArrayBufferLike | ArrayBufferView<ArrayBufferLike>) {
|
||||
this.sent.push(data)
|
||||
}
|
||||
|
||||
@@ -65,8 +65,14 @@ function parseSent(socket: MockWebSocket, index = -1) {
|
||||
if (!payload) {
|
||||
throw new Error(`No sent payload at index ${index}`)
|
||||
}
|
||||
if (typeof payload === 'string') {
|
||||
return superjson.parse<WebSocketEvent>(payload)
|
||||
}
|
||||
|
||||
return superjson.parse<WebSocketEvent>(payload)
|
||||
const textDecoder = new TextDecoder()
|
||||
const decoded = textDecoder.decode(payload)
|
||||
|
||||
return superjson.parse<WebSocketEvent>(decoded)
|
||||
}
|
||||
|
||||
function emitOpen(socket: MockWebSocket) {
|
||||
@@ -114,7 +120,8 @@ describe('client', () => {
|
||||
},
|
||||
})
|
||||
|
||||
const announceEvent = parseSent(socket)
|
||||
const announceEvent = parseSent(socket) as WebSocketEventOf<'module:announced'>
|
||||
|
||||
expect(announceEvent).toMatchObject({
|
||||
type: 'module:announce',
|
||||
data: { name: 'test-plugin' },
|
||||
@@ -195,7 +202,7 @@ describe('client', () => {
|
||||
}
|
||||
|
||||
emitOpen(socket)
|
||||
const announceEvent = parseSent(socket)
|
||||
const announceEvent = parseSent(socket) as WebSocketEventOf<'module:announced'>
|
||||
|
||||
emitMessage(socket, {
|
||||
type: 'module:announced',
|
||||
@@ -229,7 +236,7 @@ describe('client', () => {
|
||||
await timedOutAssertion
|
||||
|
||||
emitOpen(socket)
|
||||
const announceEvent = parseSent(socket)
|
||||
const announceEvent = parseSent(socket) as WebSocketEventOf<'module:announced'>
|
||||
|
||||
emitMessage(socket, {
|
||||
type: 'module:announced',
|
||||
@@ -278,7 +285,8 @@ describe('client', () => {
|
||||
|
||||
emitOpen(socket)
|
||||
|
||||
const announceEvent = parseSent(socket)
|
||||
const announceEvent = parseSent(socket) as WebSocketEventOf<'module:announced'>
|
||||
|
||||
emitMessage(socket, {
|
||||
type: 'module:announced',
|
||||
data: {
|
||||
@@ -322,7 +330,8 @@ describe('client', () => {
|
||||
|
||||
const secondSocket = lastSocket()
|
||||
emitOpen(secondSocket)
|
||||
const announceEvent = parseSent(secondSocket)
|
||||
|
||||
const announceEvent = parseSent(secondSocket) as WebSocketEventOf<'module:announced'>
|
||||
|
||||
emitMessage(secondSocket, {
|
||||
type: 'module:announced',
|
||||
@@ -353,7 +362,8 @@ describe('client', () => {
|
||||
const socket = lastSocket()
|
||||
emitOpen(socket)
|
||||
|
||||
const announceEvent = parseSent(socket)
|
||||
const announceEvent = parseSent(socket) as WebSocketEventOf<'module:announced'>
|
||||
|
||||
const selfIdentity = announceEvent.data.identity
|
||||
|
||||
emitMessage(socket, {
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
"../server-shared/src/*"
|
||||
]
|
||||
},
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
"jsx": "preserve",
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ESNext",
|
||||
"DOM.AsyncIterable"
|
||||
"DOM.AsyncIterable",
|
||||
"ESNext"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
"jsx": "preserve",
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ESNext",
|
||||
"DOM.AsyncIterable"
|
||||
"DOM.AsyncIterable",
|
||||
"ESNext"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
"jsx": "preserve",
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ESNext",
|
||||
"DOM.AsyncIterable"
|
||||
"DOM.AsyncIterable",
|
||||
"ESNext"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
"jsx": "preserve",
|
||||
"lib": [
|
||||
"DOM",
|
||||
"ESNext",
|
||||
"DOM.AsyncIterable"
|
||||
"DOM.AsyncIterable",
|
||||
"ESNext"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||
"lib": [
|
||||
"DOM",
|
||||
"DOM.Iterable",
|
||||
"ESNext"
|
||||
],
|
||||
"types": []
|
||||
},
|
||||
"include": [
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
"DOM.Iterable",
|
||||
"ESNext"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM",
|
||||
"DOM.Iterable"
|
||||
"DOM.Iterable",
|
||||
"ESNext"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable e18e/prefer-static-regex */
|
||||
import type { OutputAsset } from 'rollup'
|
||||
import type { Plugin, RenderBuiltAssetUrl, ResolvedConfig } from 'vite'
|
||||
|
||||
@@ -8,6 +9,8 @@ import { rm } from 'node:fs/promises'
|
||||
import { join, resolve } from 'node:path'
|
||||
import { cwd } from 'node:process'
|
||||
|
||||
import { errorCauseFrom, errorMessageFrom, errorNameFrom, errorStackFrom } from '@moeru/std'
|
||||
|
||||
export { createS3Provider } from './providers/s3'
|
||||
export type { S3ProviderOptions } from './providers/s3'
|
||||
export type { UploadProvider } from './providers/types'
|
||||
@@ -248,9 +251,17 @@ export function WarpDrivePlugin(options: WarpDrivePluginOptions): Plugin {
|
||||
try {
|
||||
await options.provider.upload(localPath, key, contentType)
|
||||
}
|
||||
catch (error) {
|
||||
resolvedConfig.logger.error(`[${pluginName}] upload failed, file: ${fileName} -> ${key}: ${error}`, { error })
|
||||
throw error
|
||||
catch (err) {
|
||||
const error = new Error(errorMessageFrom(err))
|
||||
error.name = errorNameFrom(err) || 'UploadError'
|
||||
const stack = errorStackFrom(err)
|
||||
if (stack)
|
||||
error.stack = stack
|
||||
|
||||
error.cause = errorCauseFrom(err)
|
||||
|
||||
resolvedConfig.logger.error(`[${pluginName}] upload failed, file: ${fileName} -> ${key}: ${err}`, { error })
|
||||
throw err
|
||||
}
|
||||
|
||||
if (shouldDeleteLocalAsset) {
|
||||
|
||||
@@ -15,14 +15,14 @@ describe('s3', (test) => {
|
||||
describe('S3Provider', () => {
|
||||
it('should skip upload', async () => {
|
||||
const s3 = createS3Provider({
|
||||
endpoint: env.S3_ENDPOINT,
|
||||
accessKeyId: env.S3_ACCESS_KEY_ID,
|
||||
secretAccessKey: env.S3_SECRET_ACCESS_KEY,
|
||||
endpoint: env.S3_ENDPOINT!,
|
||||
accessKeyId: env.S3_ACCESS_KEY_ID!,
|
||||
secretAccessKey: env.S3_SECRET_ACCESS_KEY!,
|
||||
region: env.S3_REGION,
|
||||
publicBaseUrl: env.WARP_DRIVE_PUBLIC_BASE ?? env.S3_ENDPOINT,
|
||||
})
|
||||
|
||||
expect(await s3.shouldSkipUpload(join(cwd(), 'packages', 'stage-ui', 'src', 'assets', 'live2d', 'models', 'hiyori_free_zh.zip'), '/proj-airi/stage-web/assets/hiyori_free_zh-D9UJNK98.zip')).toBe(true)
|
||||
expect(await s3.shouldSkipUpload?.(join(cwd(), 'packages', 'stage-ui', 'src', 'assets', 'live2d', 'models', 'hiyori_free_zh.zip'), '/proj-airi/stage-web/assets/hiyori_free_zh-D9UJNK98.zip')).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable e18e/prefer-static-regex */
|
||||
import type { Buffer } from 'node:buffer'
|
||||
|
||||
import type { UploadProvider } from './types'
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
"moduleDetection": "force",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"isolatedModules": true,
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"strict": true,
|
||||
"strictNullChecks": true,
|
||||
"noImplicitAny": true,
|
||||
|
||||
Reference in New Issue
Block a user