@faeyumbrea/lib-camera-api-types 1.13.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 +202 -0
- package/README.md +28 -0
- package/api.d.ts +34 -0
- package/camera-3d.d.ts +61 -0
- package/controller.d.ts +52 -0
- package/follow.d.ts +13 -0
- package/framing.d.ts +26 -0
- package/movement.d.ts +47 -0
- package/ownership.d.ts +80 -0
- package/package.json +27 -0
- package/public-api.d.ts +10 -0
- package/remote.d.ts +59 -0
- package/viewport-filter.d.ts +11 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# libCamera API types
|
|
2
|
+
|
|
3
|
+
TypeScript declarations for libCamera's public API. Foundry loads the installed
|
|
4
|
+
module at runtime; this package only supplies types for your integration.
|
|
5
|
+
|
|
6
|
+
Install the exact package version matching the libCamera release you support.
|
|
7
|
+
For example:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install --save-dev --save-exact @faeyumbrea/lib-camera-api-types@1.14.0
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import type { ModuleApi } from '@faeyumbrea/lib-camera-api-types';
|
|
15
|
+
|
|
16
|
+
const camera = game.modules.get('lib-camera')?.api as ModuleApi | undefined;
|
|
17
|
+
if (!camera || camera.apiMajor !== 1) {
|
|
18
|
+
throw new Error('This integration needs libCamera API 1.');
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Use type-only imports. There is no JavaScript entry point in this package.
|
|
23
|
+
The second version number is the Foundry generation: `1.13.x` targets Foundry 13,
|
|
24
|
+
and `1.14.x` targets Foundry 14. A module hotfix such as `1.14.0.1` maps to npm
|
|
25
|
+
version `1.14.0-hotfix.1`; pin it explicitly rather than relying on a version range.
|
|
26
|
+
|
|
27
|
+
[Developer guides and released API references](https://docs.void.monster/lib-camera/)
|
|
28
|
+
cover registration, ownership, movement, and lifecycle handling.
|
package/api.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CameraView3D } from './camera-3d.js';
|
|
2
|
+
import type { LocalConsumer } from './controller.js';
|
|
3
|
+
import type { CameraBounds, FrameOptions } from './framing.js';
|
|
4
|
+
import type { CameraPosition } from './movement.js';
|
|
5
|
+
import type { ConsumerOptions } from './ownership.js';
|
|
6
|
+
import type { RemoteCamera } from './remote.js';
|
|
7
|
+
export interface ModuleApi {
|
|
8
|
+
readonly id: 'lib-camera';
|
|
9
|
+
readonly apiMajor: 1;
|
|
10
|
+
moveRemote: RemoteCamera['move'];
|
|
11
|
+
set3DRemote: RemoteCamera['set3D'];
|
|
12
|
+
observeUser: RemoteCamera['watch'];
|
|
13
|
+
followUser: RemoteCamera['followUser'];
|
|
14
|
+
/** Compute views without taking ownership or moving the camera. */
|
|
15
|
+
frame: (bounds: readonly CameraBounds[], options?: FrameOptions) => CameraPosition | undefined;
|
|
16
|
+
frameTokens: (tokenIds: readonly string[], options?: FrameOptions) => CameraPosition | undefined;
|
|
17
|
+
sceneBounds: () => CameraBounds | undefined;
|
|
18
|
+
/** Registration is available at init; movement requires a ready canvas. */
|
|
19
|
+
register: (options: ConsumerOptions) => LocalConsumer;
|
|
20
|
+
read: () => Readonly<CameraPosition> | undefined;
|
|
21
|
+
/** Native 3D position and look-at target; absent unless 3D Canvas is active and ready. */
|
|
22
|
+
read3D: () => Readonly<CameraView3D> | undefined;
|
|
23
|
+
tokenPosition: (tokenId: string) => Readonly<{
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
}> | undefined;
|
|
27
|
+
gridPosition: (row: number, column: number) => Readonly<{
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}> | undefined;
|
|
31
|
+
/** Stop this client immediately and persist its opt-out. */
|
|
32
|
+
panic: () => Promise<void>;
|
|
33
|
+
openControls: () => void;
|
|
34
|
+
}
|
package/camera-3d.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { CameraClaim, RejectionReason } from './ownership.js';
|
|
2
|
+
/** Native 3D Canvas units: X/Z span the scene; Y is elevation. */
|
|
3
|
+
export interface Vector3D {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
z: number;
|
|
7
|
+
}
|
|
8
|
+
export interface CameraView3D {
|
|
9
|
+
position: Readonly<Vector3D>;
|
|
10
|
+
target: Readonly<Vector3D>;
|
|
11
|
+
}
|
|
12
|
+
export type CameraResult3D = {
|
|
13
|
+
status: 'completed';
|
|
14
|
+
view: Readonly<CameraView3D>;
|
|
15
|
+
} | {
|
|
16
|
+
status: 'rejected';
|
|
17
|
+
reason: RejectionReason | 'invalid-input' | 'inactive-claim' | 'unavailable' | 'unsupported-mode';
|
|
18
|
+
} | {
|
|
19
|
+
status: 'failed';
|
|
20
|
+
reason: 'adapter-error';
|
|
21
|
+
};
|
|
22
|
+
interface MutableVector extends Vector3D {
|
|
23
|
+
set: (x: number, y: number, z: number) => unknown;
|
|
24
|
+
}
|
|
25
|
+
/** Shared exposed surface of 3D Canvas 8 (Foundry 13) and 9 (Foundry 14). */
|
|
26
|
+
export interface Canvas3D {
|
|
27
|
+
_active: boolean;
|
|
28
|
+
_ready: boolean;
|
|
29
|
+
firstPersonMode: boolean;
|
|
30
|
+
_toggleCameraLockPosition?: unknown;
|
|
31
|
+
GameCamera: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
};
|
|
34
|
+
cutsceneEngine: {
|
|
35
|
+
isPlaying: boolean;
|
|
36
|
+
};
|
|
37
|
+
camera: {
|
|
38
|
+
position: MutableVector;
|
|
39
|
+
};
|
|
40
|
+
controls: {
|
|
41
|
+
target: MutableVector;
|
|
42
|
+
enableDamping: boolean;
|
|
43
|
+
autoRotate: boolean;
|
|
44
|
+
update: () => unknown;
|
|
45
|
+
};
|
|
46
|
+
stopCameraAnimation: () => void;
|
|
47
|
+
}
|
|
48
|
+
export declare function validView3D(view: CameraView3D): boolean;
|
|
49
|
+
export declare class Camera3D {
|
|
50
|
+
readonly getCanvas: () => Canvas3D | undefined;
|
|
51
|
+
constructor(getCanvas: () => Canvas3D | undefined);
|
|
52
|
+
read(): Readonly<CameraView3D> | undefined;
|
|
53
|
+
availability(): 'unavailable' | 'unsupported-mode' | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Immediate write through native orbit controls, which may constrain the result.
|
|
56
|
+
* Free-camera collision handling can later reproject the target along the viewing ray.
|
|
57
|
+
* Preserves camera mode and control settings; does not hold the view against manual input.
|
|
58
|
+
*/
|
|
59
|
+
set(claim: CameraClaim, next: CameraView3D): CameraResult3D;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
package/controller.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Camera3D, CameraResult3D, CameraView3D } from './camera-3d.js';
|
|
2
|
+
import type { CameraFollow } from './follow.js';
|
|
3
|
+
import type { CameraAdapter, CameraPosition, MovementResult, MoveOptions } from './movement.js';
|
|
4
|
+
import type { CameraClaim, ConsumerOptions, RejectionReason } from './ownership.js';
|
|
5
|
+
import { CameraCoordinator } from './ownership.js';
|
|
6
|
+
export interface CameraSession extends CameraClaim {
|
|
7
|
+
/** Replace this claim's current movement, continuing from the actual view. */
|
|
8
|
+
retarget: (options: MoveOptions, signal?: AbortSignal) => Promise<MovementResult>;
|
|
9
|
+
set3D: (view: CameraView3D) => CameraResult3D;
|
|
10
|
+
move: (options: MoveOptions, signal?: AbortSignal) => Promise<MovementResult>;
|
|
11
|
+
}
|
|
12
|
+
export type SessionResult = {
|
|
13
|
+
ok: true;
|
|
14
|
+
claim: CameraSession;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
reason: RejectionReason | 'unavailable';
|
|
18
|
+
};
|
|
19
|
+
export interface LocalConsumer {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
follow: (source: () => MoveOptions | undefined, interval?: number) => {
|
|
22
|
+
ok: true;
|
|
23
|
+
follow: CameraFollow;
|
|
24
|
+
} | {
|
|
25
|
+
ok: false;
|
|
26
|
+
reason: RejectionReason | 'unavailable';
|
|
27
|
+
};
|
|
28
|
+
/** Acquire, set the 3D view immediately, and release. */
|
|
29
|
+
set3D: (view: CameraView3D) => CameraResult3D;
|
|
30
|
+
acquire: () => SessionResult;
|
|
31
|
+
/** Acquire, move, and release, including when movement fails. */
|
|
32
|
+
move: (options: MoveOptions, signal?: AbortSignal) => Promise<MovementResult | {
|
|
33
|
+
status: 'rejected';
|
|
34
|
+
reason: RejectionReason;
|
|
35
|
+
}>;
|
|
36
|
+
unregister: () => void;
|
|
37
|
+
}
|
|
38
|
+
export declare class CameraController {
|
|
39
|
+
#private;
|
|
40
|
+
readonly adapter: CameraAdapter;
|
|
41
|
+
readonly getUserId: () => string | undefined;
|
|
42
|
+
readonly camera3D?: Camera3D | undefined;
|
|
43
|
+
readonly ownership: CameraCoordinator;
|
|
44
|
+
readonly consumers: Map<string, LocalConsumer>;
|
|
45
|
+
constructor(adapter: CameraAdapter, getUserId: () => string | undefined, camera3D?: Camera3D | undefined);
|
|
46
|
+
read(): Readonly<CameraPosition> | undefined;
|
|
47
|
+
register(options: ConsumerOptions): LocalConsumer;
|
|
48
|
+
releaseLocal(): void;
|
|
49
|
+
panic(): void;
|
|
50
|
+
resume(): void;
|
|
51
|
+
reset(): void;
|
|
52
|
+
}
|
package/follow.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CameraSession } from './controller.js';
|
|
2
|
+
import type { MovementResult, MoveOptions } from './movement.js';
|
|
3
|
+
export interface CameraFollow {
|
|
4
|
+
readonly active: boolean;
|
|
5
|
+
readonly paused: boolean;
|
|
6
|
+
/** Resolves on stop, preemption, panic, teardown or a source/movement failure. */
|
|
7
|
+
readonly done: Promise<MovementResult>;
|
|
8
|
+
pause: () => void;
|
|
9
|
+
resume: () => void;
|
|
10
|
+
stop: () => void;
|
|
11
|
+
}
|
|
12
|
+
/** Sample a consumer-selected source; tracking policy remains with the consumer. */
|
|
13
|
+
export declare function followCamera(session: CameraSession, source: () => MoveOptions | undefined, interval?: number): CameraFollow;
|
package/framing.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CameraPosition } from './movement.js';
|
|
2
|
+
export interface CameraBounds {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
export interface FrameOptions {
|
|
9
|
+
/** Margin on each side, expressed in grid tiles. */
|
|
10
|
+
margin?: number;
|
|
11
|
+
/** Minimum and maximum number of horizontal grid tiles visible. */
|
|
12
|
+
closest?: number;
|
|
13
|
+
widest?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ViewDimensions {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
gridSize: number;
|
|
19
|
+
}
|
|
20
|
+
/** Shared with OBS Utils: more visible tiles means a smaller scale. */
|
|
21
|
+
export declare function tilesToScale(tiles: number, screenWidth: number, gridSize: number): number;
|
|
22
|
+
export declare function validBounds(bounds: CameraBounds): boolean;
|
|
23
|
+
/** OBS Utils framing, with explicit inputs instead of world settings. */
|
|
24
|
+
export declare function frameBounds(bounds: readonly CameraBounds[], screen: ViewDimensions, options?: FrameOptions): CameraPosition | undefined;
|
|
25
|
+
/** Keep the viewport inside a rectangle, increasing scale when necessary (OBS Utils). */
|
|
26
|
+
export declare function clampView(position: CameraPosition, bounds: CameraBounds, screen: ViewDimensions): CameraPosition;
|
package/movement.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CameraBounds } from './framing.js';
|
|
2
|
+
import type { CameraClaim, ReleaseReason } from './ownership.js';
|
|
3
|
+
export interface CameraPosition {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
scale: number;
|
|
7
|
+
level?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MoveOptions extends Partial<CameraPosition> {
|
|
10
|
+
/** Milliseconds; zero applies the view immediately. Maximum: one minute. */
|
|
11
|
+
duration?: number;
|
|
12
|
+
easing?: 'linear' | 'cosine' | 'easeInCircle' | 'easeOutCircle' | 'easeInOutCircle' | 'easeInCosine' | 'easeOutCosine' | 'easeInOutCosine' | 'easeOutCubic' | 'easeInOutCubic';
|
|
13
|
+
/** true constrains to scene bounds; a rectangle constrains to that region. */
|
|
14
|
+
bounds?: true | CameraBounds;
|
|
15
|
+
/** Suppress manual camera input only for this operation. */
|
|
16
|
+
lockInput?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export type MovementResult = {
|
|
19
|
+
status: 'completed';
|
|
20
|
+
position: Readonly<CameraPosition>;
|
|
21
|
+
} | {
|
|
22
|
+
status: 'cancelled';
|
|
23
|
+
reason: ReleaseReason | 'cancelled' | 'interrupted' | 'retargeted';
|
|
24
|
+
} | {
|
|
25
|
+
status: 'rejected';
|
|
26
|
+
reason: 'invalid-input' | 'inactive-claim' | 'busy' | 'unavailable';
|
|
27
|
+
} | {
|
|
28
|
+
status: 'failed';
|
|
29
|
+
reason: 'adapter-error';
|
|
30
|
+
};
|
|
31
|
+
/** Boundary to Foundry. Adapters must stop writing synchronously when aborted. */
|
|
32
|
+
export interface CameraAdapter {
|
|
33
|
+
read: () => Readonly<CameraPosition> | undefined;
|
|
34
|
+
pan: (position: CameraPosition) => void;
|
|
35
|
+
animate: (position: CameraPosition, options: Required<Pick<MoveOptions, 'duration' | 'easing'>>, signal: AbortSignal) => Promise<boolean>;
|
|
36
|
+
lockInput: () => () => void;
|
|
37
|
+
prepare?: (options: MoveOptions, signal: AbortSignal) => Promise<boolean>;
|
|
38
|
+
constrain?: (position: CameraPosition, bounds: NonNullable<MoveOptions['bounds']>) => CameraPosition;
|
|
39
|
+
}
|
|
40
|
+
export declare function validMove(options: MoveOptions): boolean;
|
|
41
|
+
/** One operation per claim. Cancellation never releases a caller's longer-lived claim. */
|
|
42
|
+
export declare class CameraMovement {
|
|
43
|
+
#private;
|
|
44
|
+
readonly adapter: CameraAdapter;
|
|
45
|
+
constructor(adapter: CameraAdapter);
|
|
46
|
+
move(claim: CameraClaim, options: MoveOptions, signal?: AbortSignal): Promise<MovementResult>;
|
|
47
|
+
}
|
package/ownership.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** Why a live claim ended. Movement adapters must observe the claim signal. */
|
|
2
|
+
export type ReleaseReason = 'released' | 'superseded' | 'unregistered' | 'panic' | 'canvas-teardown' | 'disposed';
|
|
3
|
+
export type RejectionReason = 'disabled' | 'unregistered' | 'busy' | 'disposed' | 'canvas-teardown';
|
|
4
|
+
export interface ConsumerOptions {
|
|
5
|
+
/** Module ID. Registration is coordination, not an authorization boundary. */
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
priority?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ClaimSnapshot {
|
|
11
|
+
readonly consumerId: string;
|
|
12
|
+
readonly userId: string;
|
|
13
|
+
readonly priority: number;
|
|
14
|
+
}
|
|
15
|
+
export interface CameraClaim {
|
|
16
|
+
readonly consumerId: string;
|
|
17
|
+
readonly userId: string;
|
|
18
|
+
readonly active: boolean;
|
|
19
|
+
/** Aborted exactly once. signal.reason is a ReleaseReason. */
|
|
20
|
+
readonly signal: AbortSignal;
|
|
21
|
+
/** A stale claim cannot release a newer claim. */
|
|
22
|
+
release: () => void;
|
|
23
|
+
}
|
|
24
|
+
export type ClaimResult = {
|
|
25
|
+
readonly ok: true;
|
|
26
|
+
readonly claim: CameraClaim;
|
|
27
|
+
} | {
|
|
28
|
+
readonly ok: false;
|
|
29
|
+
readonly reason: RejectionReason;
|
|
30
|
+
readonly owner?: ClaimSnapshot;
|
|
31
|
+
};
|
|
32
|
+
export interface CameraConsumer {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
/** An existing claim is never silently replaced by another from the same consumer. */
|
|
35
|
+
acquire: (userId: string) => ClaimResult;
|
|
36
|
+
unregister: () => void;
|
|
37
|
+
}
|
|
38
|
+
export interface PriorityOverride {
|
|
39
|
+
consumerId: string;
|
|
40
|
+
/** Omit for a default applying to all users. */
|
|
41
|
+
userId?: string;
|
|
42
|
+
priority: number;
|
|
43
|
+
}
|
|
44
|
+
export interface ConsumerSnapshot {
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly priority: number;
|
|
48
|
+
}
|
|
49
|
+
export interface Diagnostic {
|
|
50
|
+
readonly sequence: number;
|
|
51
|
+
readonly action: 'acquired' | 'rejected' | 'ended';
|
|
52
|
+
readonly consumerId: string;
|
|
53
|
+
readonly userId: string;
|
|
54
|
+
readonly reason?: ReleaseReason | RejectionReason;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Per-user ownership arbitration for cooperative camera consumers.
|
|
58
|
+
* The integration layer authenticates remote requests and enforces input locks.
|
|
59
|
+
*/
|
|
60
|
+
export declare class CameraCoordinator {
|
|
61
|
+
#private;
|
|
62
|
+
constructor({ diagnosticLimit }?: {
|
|
63
|
+
diagnosticLimit?: number;
|
|
64
|
+
});
|
|
65
|
+
register({ id, name, priority }: ConsumerOptions): CameraConsumer;
|
|
66
|
+
/** Replace configuration atomically. New priorities apply to the next acquisition. */
|
|
67
|
+
setPriorities(overrides: readonly PriorityOverride[]): void;
|
|
68
|
+
getConsumers(userId?: string): readonly ConsumerSnapshot[];
|
|
69
|
+
getOwner(userId: string): ClaimSnapshot | undefined;
|
|
70
|
+
getClaims(): readonly ClaimSnapshot[];
|
|
71
|
+
getDiagnostics(): readonly Diagnostic[];
|
|
72
|
+
isDisabled(userId?: string): boolean;
|
|
73
|
+
/** Stop and block one user, or every user when omitted. Resume is explicit. */
|
|
74
|
+
panic(userId?: string): void;
|
|
75
|
+
/** Global resume preserves individual users' opt-outs. */
|
|
76
|
+
resume(userId?: string): void;
|
|
77
|
+
/** Release transient claims on a canvas transition; retain user configuration. */
|
|
78
|
+
reset(): void;
|
|
79
|
+
dispose(): void;
|
|
80
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@faeyumbrea/lib-camera-api-types",
|
|
3
|
+
"version": "1.13.0",
|
|
4
|
+
"description": "Public API declarations for libCamera 1.13.0 on Foundry 13.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/FaeyUmbrea/foundry-lib-camera.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://docs.void.monster/lib-camera/public/1.13.0/dev/",
|
|
11
|
+
"types": "./public-api.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./public-api.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"**/*.d.ts",
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"registry": "https://registry.npmjs.org/",
|
|
25
|
+
"tag": "foundry-13"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/public-api.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { ModuleApi } from './api.js';
|
|
2
|
+
export type { CameraResult3D, CameraView3D, Vector3D } from './camera-3d.js';
|
|
3
|
+
export type { CameraSession, LocalConsumer, SessionResult } from './controller.js';
|
|
4
|
+
export type { CameraFollow } from './follow.js';
|
|
5
|
+
export type { CameraBounds, FrameOptions, ViewDimensions } from './framing.js';
|
|
6
|
+
export type { CameraPosition, MovementResult, MoveOptions } from './movement.js';
|
|
7
|
+
export type { CameraClaim, CameraConsumer, ClaimResult, ClaimSnapshot, ConsumerOptions, ConsumerSnapshot, Diagnostic, PriorityOverride, RejectionReason, ReleaseReason, } from './ownership.js';
|
|
8
|
+
export type { CameraCoordinator } from './ownership.js';
|
|
9
|
+
export type { RemoteOptions, RemoteOutcome, RemoteUserResult, ViewportSample, ViewportSubscription } from './remote.js';
|
|
10
|
+
export type { TrackingMode } from './viewport-filter.js';
|
package/remote.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { CameraResult3D, CameraView3D } from './camera-3d.js';
|
|
2
|
+
import type { CameraController } from './controller.js';
|
|
3
|
+
import type { CameraPosition, MovementResult, MoveOptions } from './movement.js';
|
|
4
|
+
import type { TrackingMode } from './viewport-filter.js';
|
|
5
|
+
export type RemoteOutcome = MovementResult | CameraResult3D | {
|
|
6
|
+
status: 'rejected';
|
|
7
|
+
reason: 'unauthorized' | 'wrong-scene' | 'unregistered';
|
|
8
|
+
};
|
|
9
|
+
export interface RemoteUserResult {
|
|
10
|
+
userId: string;
|
|
11
|
+
/** Acknowledgements from responding sessions; this is not proof that every session responded. */
|
|
12
|
+
outcomes: RemoteOutcome[];
|
|
13
|
+
status: 'acknowledged' | 'timeout' | 'cancelled' | 'offline' | 'rejected';
|
|
14
|
+
}
|
|
15
|
+
export interface RemoteOptions {
|
|
16
|
+
timeout?: number;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}
|
|
19
|
+
export interface ViewportSample {
|
|
20
|
+
userId: string;
|
|
21
|
+
sceneId: string;
|
|
22
|
+
position: Readonly<CameraPosition>;
|
|
23
|
+
}
|
|
24
|
+
export interface ViewportSubscription {
|
|
25
|
+
stop: () => void;
|
|
26
|
+
}
|
|
27
|
+
export interface RemoteEnvironment {
|
|
28
|
+
userId: () => string | undefined;
|
|
29
|
+
users: () => readonly {
|
|
30
|
+
id: string;
|
|
31
|
+
isGM: boolean;
|
|
32
|
+
active: boolean;
|
|
33
|
+
}[];
|
|
34
|
+
sceneId: () => string | undefined;
|
|
35
|
+
read: () => Readonly<CameraPosition> | undefined;
|
|
36
|
+
emit: (packet: object, recipients: string[]) => void;
|
|
37
|
+
}
|
|
38
|
+
/** Foundry supplies sender identity as the second socket callback argument. Never read it from payloads. */
|
|
39
|
+
export declare class RemoteCamera {
|
|
40
|
+
#private;
|
|
41
|
+
readonly controller: CameraController;
|
|
42
|
+
readonly environment: RemoteEnvironment;
|
|
43
|
+
constructor(controller: CameraController, environment: RemoteEnvironment);
|
|
44
|
+
move(consumer: string, targets: string | readonly string[], options: MoveOptions, remote?: RemoteOptions): Promise<RemoteUserResult[]>;
|
|
45
|
+
set3D(consumer: string, targets: string | readonly string[], view: CameraView3D, remote?: RemoteOptions): Promise<RemoteUserResult[]>;
|
|
46
|
+
watch(userId: string, callback: (sample: ViewportSample) => void, mode?: TrackingMode): ViewportSubscription;
|
|
47
|
+
/** Follow the latest responding session of a user on this scene; all sessions remain addressable together. */
|
|
48
|
+
followUser(consumerId: string, userId: string, options?: Pick<MoveOptions, 'duration' | 'easing' | 'bounds' | 'lockInput'>, mode?: TrackingMode): {
|
|
49
|
+
ok: true;
|
|
50
|
+
follow: import("./follow.js").CameraFollow;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
reason: import("./ownership.js").RejectionReason | "unavailable";
|
|
54
|
+
};
|
|
55
|
+
/** Bound socket traffic to approximately 30 Hz, retaining the newest sample. */
|
|
56
|
+
publish(): void;
|
|
57
|
+
receive(packet: unknown, sender: unknown): Promise<void>;
|
|
58
|
+
dispose(): void;
|
|
59
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ViewportSample } from './remote.js';
|
|
2
|
+
export type TrackingMode = 'raw' | 'smooth' | 'dragRelease';
|
|
3
|
+
/** OBS Utils' five-sample smoothing and drag-release behavior, scoped to one subscription. */
|
|
4
|
+
export declare class ViewportFilter {
|
|
5
|
+
#private;
|
|
6
|
+
readonly mode: TrackingMode;
|
|
7
|
+
readonly callback: (sample: ViewportSample) => void;
|
|
8
|
+
constructor(mode: TrackingMode, callback: (sample: ViewportSample) => void);
|
|
9
|
+
push(sample: ViewportSample): void;
|
|
10
|
+
dispose(): void;
|
|
11
|
+
}
|