@bardway/trpg-media 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +10 -0
- package/NOTICE.md +1 -0
- package/README.md +23 -2
- package/dist/AudioByteCache.d.ts +8 -0
- package/dist/DisplayAudioController.d.ts +2 -0
- package/dist/MediaPreloader.d.ts +12 -0
- package/dist/RuntimeLogger.d.ts +4 -0
- package/dist/audio/HtmlAudioSessionBackend.d.ts +36 -0
- package/dist/audio/SessionAudioBackend.d.ts +19 -0
- package/dist/audio/SessionAudioEngine.d.ts +93 -0
- package/dist/audio/SessionAudioPlaybackPolicy.d.ts +8 -0
- package/dist/audio.d.ts +5 -0
- package/dist/audio.js +625 -0
- package/dist/audio.js.map +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +493 -0
- package/dist/index.js.map +7 -0
- package/dist/sessionDisplayPreload.d.ts +15 -0
- package/dist/sessionDisplayResourceRetry.d.ts +11 -0
- package/dist/tuning/SessionTuningMigration.d.ts +9 -0
- package/dist/tuning/SessionTuningResolver.d.ts +12 -0
- package/dist/tuning/SessionTuningSchema.d.ts +27 -0
- package/dist/tuning/SessionTuningStore.d.ts +31 -0
- package/dist/tuning/SessionTuningTypes.d.ts +50 -0
- package/dist/tuning.d.ts +5 -0
- package/dist/tuning.js +292 -0
- package/dist/tuning.js.map +7 -0
- package/dist/video-poster.d.ts +77 -0
- package/dist/video.js +259 -0
- package/dist/video.js.map +7 -0
- package/package.json +49 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lex
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MingriAgency TRPG Engine
|
|
2
|
+
Copyright (c) 2026 Lex
|
|
3
|
+
|
|
4
|
+
Portions extracted and adapted from MingriAgencyCOC,
|
|
5
|
+
Copyright (c) 2025 Lex, licensed under the MIT License.
|
|
6
|
+
Source: https://github.com/bardway/mingriAgency_COC
|
|
7
|
+
The complete source attribution and extraction mapping are maintained in
|
|
8
|
+
docs/architecture and docs/guidance in the Engine repository.
|
|
9
|
+
|
|
10
|
+
Third-party dependencies retain their own licenses and copyright notices.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Source: mingriAgency_COC current local checkout, web/src/features/session-display. Source remains read-only. Product rules, resources, deployments and account data are excluded. Distributed under the repository MIT license. Third-party dependencies retain their own licenses.
|
package/README.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bardway/trpg-media
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
资源重试、预取、Web 音频、视频海报和上传补偿。
|
|
4
|
+
|
|
5
|
+
初始版本 `0.1.0`,提供 ESM JavaScript 和 TypeScript 声明。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install --save-exact @bardway/trpg-media@0.1.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
按需选择 `/audio`、`/tuning`、`/video`。浏览器能力、资源地址、上传和删除端口由宿主提供。
|
|
14
|
+
|
|
15
|
+
## 公开入口
|
|
16
|
+
|
|
17
|
+
- `@bardway/trpg-media`
|
|
18
|
+
- `@bardway/trpg-media/tuning`
|
|
19
|
+
- `@bardway/trpg-media/audio`
|
|
20
|
+
- `@bardway/trpg-media/video`
|
|
21
|
+
|
|
22
|
+
完整配置、示例和平台限制见[使用说明](https://github.com/bardway/mingriAgency_TRPGEngine/blob/main/docs/guidance/package-usage.md)。
|
|
23
|
+
|
|
24
|
+
MIT。保留随包分发的 LICENSE、NOTICE 和第三方许可。
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Instance ownership allows a host to share a preload cache without sharing accounts or sessions. */
|
|
2
|
+
export declare class AudioByteCache {
|
|
3
|
+
private readonly fetchAudio;
|
|
4
|
+
private readonly records;
|
|
5
|
+
constructor(fetchAudio?: typeof fetch);
|
|
6
|
+
load(url: string): Promise<ArrayBuffer>;
|
|
7
|
+
clear(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AudioByteCache } from './AudioByteCache.js';
|
|
2
|
+
export interface SessionMediaPreloadResult {
|
|
3
|
+
readonly failedUrls: readonly string[];
|
|
4
|
+
}
|
|
5
|
+
export declare const preloadSessionAudio: (urls: readonly string[], options: {
|
|
6
|
+
readonly signal: AbortSignal;
|
|
7
|
+
readonly onProgress: (completed: number, total: number) => void;
|
|
8
|
+
readonly concurrency?: number;
|
|
9
|
+
readonly cache: AudioByteCache;
|
|
10
|
+
readonly retryCount?: number;
|
|
11
|
+
readonly retryDelayMs?: number;
|
|
12
|
+
}) => Promise<SessionMediaPreloadResult>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { SessionAudioBackend } from './SessionAudioBackend.js';
|
|
2
|
+
import type { SessionAudioBus, SessionAudioCueDefinition, SessionAudioCuePlayOptions, SessionAudioEngineState, SessionAudioPlayOptions } from './SessionAudioEngine.js';
|
|
3
|
+
/** Compatibility backend for jsdom and browsers without Web Audio. */
|
|
4
|
+
export declare class HtmlAudioSessionBackend implements SessionAudioBackend {
|
|
5
|
+
private readonly report;
|
|
6
|
+
private readonly elements;
|
|
7
|
+
private readonly activeCueGroups;
|
|
8
|
+
private readonly playbackOwners;
|
|
9
|
+
private readonly playbackCleanups;
|
|
10
|
+
private fieldElement;
|
|
11
|
+
private masterGain;
|
|
12
|
+
private readonly busGains;
|
|
13
|
+
private unlockGeneration;
|
|
14
|
+
private destroying;
|
|
15
|
+
private _state;
|
|
16
|
+
constructor(report?: (error: unknown) => void);
|
|
17
|
+
get state(): SessionAudioEngineState;
|
|
18
|
+
unlock(preloadUrls?: string[]): Promise<boolean>;
|
|
19
|
+
preload(urls: readonly string[]): Promise<void>;
|
|
20
|
+
play(url: string, options: SessionAudioPlayOptions): Promise<HTMLAudioElement | null>;
|
|
21
|
+
playCue(cue: SessionAudioCueDefinition, options?: SessionAudioCuePlayOptions): Promise<HTMLAudioElement | null>;
|
|
22
|
+
stopCueGroup(groupId: string): void;
|
|
23
|
+
playField(url: string, volume?: number): Promise<void>;
|
|
24
|
+
replaceField(url: string | null, volume?: number): Promise<void>;
|
|
25
|
+
suspendField(): void;
|
|
26
|
+
resumeField(): void;
|
|
27
|
+
stopField(): void;
|
|
28
|
+
setMasterGain(value: number): void;
|
|
29
|
+
setBusGain(bus: SessionAudioBus, value: number): void;
|
|
30
|
+
setBusMuted(bus: SessionAudioBus, muted: boolean): void;
|
|
31
|
+
solo(bus: SessionAudioBus | null): void;
|
|
32
|
+
destroy(): Promise<void>;
|
|
33
|
+
private reportSafely;
|
|
34
|
+
private getElement;
|
|
35
|
+
private releaseCueGroup;
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SessionAudioBus, SessionAudioCueDefinition, SessionAudioCuePlayOptions, SessionAudioEngineState, SessionAudioPlayOptions } from './SessionAudioEngine.js';
|
|
2
|
+
export interface SessionAudioBackend {
|
|
3
|
+
readonly state: SessionAudioEngineState;
|
|
4
|
+
unlock(preloadUrls?: string[]): Promise<boolean>;
|
|
5
|
+
preload(urls: readonly string[]): Promise<void>;
|
|
6
|
+
play(url: string, options: SessionAudioPlayOptions): Promise<unknown>;
|
|
7
|
+
playCue(cue: SessionAudioCueDefinition, options?: SessionAudioCuePlayOptions): Promise<unknown>;
|
|
8
|
+
stopCueGroup(groupId: string): void;
|
|
9
|
+
playField(url: string, volume?: number): Promise<void>;
|
|
10
|
+
replaceField(url: string | null, volume?: number): Promise<void>;
|
|
11
|
+
suspendField(): void;
|
|
12
|
+
resumeField(): void;
|
|
13
|
+
stopField(): void;
|
|
14
|
+
setMasterGain(value: number): void;
|
|
15
|
+
setBusGain(bus: SessionAudioBus, value: number, rampMs?: number): void;
|
|
16
|
+
setBusMuted(bus: SessionAudioBus, muted: boolean): void;
|
|
17
|
+
solo(bus: SessionAudioBus | null): void;
|
|
18
|
+
destroy(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type SessionAudioBus = string;
|
|
2
|
+
export type SessionAudioEngineState = 'blocked' | 'initializing' | 'ready' | 'failed';
|
|
3
|
+
export interface SessionAudioCueDefinition {
|
|
4
|
+
id: string;
|
|
5
|
+
asset: string;
|
|
6
|
+
bus: SessionAudioBus;
|
|
7
|
+
gain: number;
|
|
8
|
+
polyphony: number;
|
|
9
|
+
cooldownMs: number;
|
|
10
|
+
pitchMin?: number;
|
|
11
|
+
pitchMax?: number;
|
|
12
|
+
panMin?: number;
|
|
13
|
+
panMax?: number;
|
|
14
|
+
loop?: boolean;
|
|
15
|
+
startOffsetMs?: number;
|
|
16
|
+
fadeInMs?: number;
|
|
17
|
+
fadeOutMs?: number;
|
|
18
|
+
stealMode?: 'oldest' | 'ignoreNewest';
|
|
19
|
+
}
|
|
20
|
+
export interface SessionAudioPlayOptions {
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
bus: SessionAudioBus;
|
|
23
|
+
loop?: boolean;
|
|
24
|
+
volume?: number;
|
|
25
|
+
volumeCeiling?: number;
|
|
26
|
+
playbackRate?: number;
|
|
27
|
+
pan?: number;
|
|
28
|
+
startOffsetMs?: number;
|
|
29
|
+
fadeInMs?: number;
|
|
30
|
+
fadeOutMs?: number;
|
|
31
|
+
onEnded?: () => void;
|
|
32
|
+
}
|
|
33
|
+
export interface SessionAudioCuePlayOptions {
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
deterministicSeed?: string;
|
|
36
|
+
onEnded?: () => void;
|
|
37
|
+
volume?: number;
|
|
38
|
+
volumeCeiling?: number;
|
|
39
|
+
playbackRate?: number;
|
|
40
|
+
pan?: number;
|
|
41
|
+
voiceGroupId?: string;
|
|
42
|
+
cooldownId?: string;
|
|
43
|
+
maxVoices?: number;
|
|
44
|
+
cooldownMs?: number;
|
|
45
|
+
}
|
|
46
|
+
export declare class SessionAudioEngine {
|
|
47
|
+
private readonly createContext;
|
|
48
|
+
private readonly busIds;
|
|
49
|
+
private readonly limiterBuses;
|
|
50
|
+
private readonly report;
|
|
51
|
+
private readonly bytes;
|
|
52
|
+
private context;
|
|
53
|
+
private master;
|
|
54
|
+
private readonly buses;
|
|
55
|
+
private readonly busGains;
|
|
56
|
+
private readonly buffers;
|
|
57
|
+
private readonly activeVoices;
|
|
58
|
+
private readonly playbackCleanups;
|
|
59
|
+
private readonly lastCueTimes;
|
|
60
|
+
private readonly busMute;
|
|
61
|
+
private soloBus;
|
|
62
|
+
private masterGain;
|
|
63
|
+
private fieldSource;
|
|
64
|
+
private fieldUrl;
|
|
65
|
+
private fieldRevision;
|
|
66
|
+
private unlockGeneration;
|
|
67
|
+
private destroying;
|
|
68
|
+
private _state;
|
|
69
|
+
constructor(createContext?: () => AudioContext, fetchAudio?: typeof fetch, busIds?: readonly string[], limiterBuses?: readonly string[], report?: (error: unknown) => void);
|
|
70
|
+
get state(): SessionAudioEngineState;
|
|
71
|
+
unlock(preloadUrls?: string[]): Promise<boolean>;
|
|
72
|
+
preload(urls: readonly string[]): Promise<void>;
|
|
73
|
+
play(url: string, options: SessionAudioPlayOptions): Promise<AudioBufferSourceNode | null>;
|
|
74
|
+
playCue(cue: SessionAudioCueDefinition, options?: SessionAudioCuePlayOptions): Promise<AudioBufferSourceNode | null>;
|
|
75
|
+
playCue(cue: SessionAudioCueDefinition, deterministicSeed?: string, onEnded?: () => void): Promise<AudioBufferSourceNode | null>;
|
|
76
|
+
stopCueGroup(groupId: string): void;
|
|
77
|
+
playField(url: string, volume?: number): Promise<void>;
|
|
78
|
+
replaceField(url: string | null, volume?: number): Promise<void>;
|
|
79
|
+
suspendField(): void;
|
|
80
|
+
resumeField(): void;
|
|
81
|
+
stopField(): void;
|
|
82
|
+
private stopFieldSource;
|
|
83
|
+
setMasterGain(value: number): void;
|
|
84
|
+
setBusGain(bus: SessionAudioBus, value: number, rampMs?: number): void;
|
|
85
|
+
setBusMuted(bus: SessionAudioBus, muted: boolean): void;
|
|
86
|
+
solo(bus: SessionAudioBus | null): void;
|
|
87
|
+
destroy(): Promise<void>;
|
|
88
|
+
private reportSafely;
|
|
89
|
+
private ensureGraph;
|
|
90
|
+
private load;
|
|
91
|
+
private releaseVoice;
|
|
92
|
+
private applyBusAudibility;
|
|
93
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface SessionAudioPlaybackPolicy {
|
|
2
|
+
readonly mode: 'production' | 'preview';
|
|
3
|
+
readonly allowSemanticSideEffects: boolean;
|
|
4
|
+
readonly allowScrubAudio: boolean;
|
|
5
|
+
readonly deterministicSeed?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const productionAudioPlaybackPolicy: SessionAudioPlaybackPolicy;
|
|
8
|
+
export declare const previewAudioPlaybackPolicy: SessionAudioPlaybackPolicy;
|
package/dist/audio.d.ts
ADDED