@pickleball/expo-sdk 0.1.1 → 1.0.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/CHANGELOG.md +65 -0
- package/README.md +163 -40
- package/dist/advanced-DcbHBCGb.d.ts +300 -0
- package/dist/advanced-DeQwg7MK.d.cts +300 -0
- package/dist/advanced.cjs +47 -0
- package/dist/advanced.d.cts +3 -0
- package/dist/advanced.d.ts +3 -0
- package/dist/advanced.js +47 -0
- package/dist/camera-controls-By8tHigY.d.cts +97 -0
- package/dist/camera-controls-rCBUGGPC.d.ts +97 -0
- package/dist/chunk-2JHULJZ7.js +265 -0
- package/dist/chunk-62YV3PCD.cjs +139 -0
- package/dist/chunk-6F3HN6US.js +50 -0
- package/dist/chunk-6YE5BL3A.cjs +50 -0
- package/dist/chunk-7OX2DSKI.cjs +33 -0
- package/dist/chunk-7Z7TN5N3.js +318 -0
- package/dist/chunk-DHDX3ZOO.js +800 -0
- package/dist/chunk-GXQYMPHE.cjs +9 -0
- package/dist/chunk-IUIRVKJI.cjs +2290 -0
- package/dist/chunk-KFQGP6VL.js +33 -0
- package/dist/chunk-LCWGNGEN.cjs +265 -0
- package/dist/chunk-TBUEXRFQ.cjs +318 -0
- package/dist/chunk-XGP2MN5R.js +2290 -0
- package/dist/chunk-XL4CISVQ.js +9 -0
- package/dist/chunk-YGSQ25UA.cjs +800 -0
- package/dist/chunk-ZSKSXOCZ.js +139 -0
- package/dist/convex-command-subscription-Cabh9tND.d.ts +41 -0
- package/dist/convex-command-subscription-DUgpu75l.d.cts +41 -0
- package/dist/device-agent/index.cjs +1427 -0
- package/dist/device-agent/index.d.cts +493 -0
- package/dist/device-agent/index.d.ts +493 -0
- package/dist/device-agent/index.js +1427 -0
- package/dist/engine-BSvSdCSE.d.cts +741 -0
- package/dist/engine-BSvSdCSE.d.ts +741 -0
- package/dist/index.cjs +426 -6174
- package/dist/index.d.cts +299 -1400
- package/dist/index.d.ts +299 -1400
- package/dist/index.js +413 -6063
- package/dist/match/index.cjs +2456 -0
- package/dist/match/index.d.cts +253 -0
- package/dist/match/index.d.ts +253 -0
- package/dist/match/index.js +2456 -0
- package/dist/match/remote/index.cjs +21 -0
- package/dist/match/remote/index.d.cts +67 -0
- package/dist/match/remote/index.d.ts +67 -0
- package/dist/match/remote/index.js +21 -0
- package/dist/match/voice/index.cjs +23 -0
- package/dist/match/voice/index.d.cts +114 -0
- package/dist/match/voice/index.d.ts +114 -0
- package/dist/match/voice/index.js +23 -0
- package/dist/plugin.cjs +52 -71
- package/dist/plugin.d.cts +28 -1
- package/dist/plugin.d.ts +28 -1
- package/dist/plugin.js +26 -23
- package/dist/realtime/index.cjs +31 -0
- package/dist/realtime/index.d.cts +15 -0
- package/dist/realtime/index.d.ts +15 -0
- package/dist/realtime/index.js +31 -0
- package/dist/types-CrmcX408.d.cts +176 -0
- package/dist/types-CrmcX408.d.ts +176 -0
- package/dist/types-DiKWjwvN.d.cts +96 -0
- package/dist/types-DiKWjwvN.d.ts +96 -0
- package/dist/ui/index.cjs +1297 -0
- package/dist/ui/index.d.cts +493 -0
- package/dist/ui/index.d.ts +493 -0
- package/dist/ui/index.js +1297 -0
- package/dist/version.cjs +4 -32
- package/dist/version.js +2 -1
- package/package.json +95 -15
- package/src/advanced.ts +49 -0
- package/src/auto-resume.tsx +259 -0
- package/src/camera-controls.ts +99 -0
- package/src/camera-grant-provider.ts +392 -0
- package/src/camera-settings.ts +133 -0
- package/src/contracts.ts +73 -0
- package/src/device-agent/agent.ts +696 -0
- package/src/device-agent/beat-policy.ts +46 -0
- package/src/device-agent/component.tsx +60 -0
- package/src/device-agent/convex-beat-transport.ts +140 -0
- package/src/device-agent/convex-command-subscription.ts +101 -0
- package/src/device-agent/convex-control-channel.ts +88 -0
- package/src/device-agent/http-transport.ts +164 -0
- package/src/device-agent/index.ts +26 -0
- package/src/device-agent/mqtt-channel.ts +379 -0
- package/src/device-agent/mqtt-codec.ts +347 -0
- package/src/device-agent/tournament.ts +352 -0
- package/src/engine.ts +601 -20
- package/src/errors.ts +16 -0
- package/src/http-session-provider.ts +21 -183
- package/src/index.ts +117 -14
- package/src/local-video-quality.ts +43 -0
- package/src/match/index.ts +29 -0
- package/src/match/provider.tsx +4 -2
- package/src/match/remote/hid-gesture.ts +10 -2
- package/src/match/remote/types.ts +6 -4
- package/src/match/voice/scheduler.ts +6 -1
- package/src/match/voice/service.ts +16 -4
- package/src/native-runtime.ts +283 -77
- package/src/plugin.ts +54 -20
- package/src/provider.tsx +129 -22
- package/src/realtime/index.ts +56 -0
- package/src/resume-policy.ts +85 -0
- package/src/resume.ts +132 -0
- package/src/rtmp-room-adapter.ts +348 -0
- package/src/session-grant.ts +256 -0
- package/src/ui/camera-screen.tsx +484 -0
- package/src/ui/controls-sheet.tsx +445 -0
- package/src/ui/copy.ts +326 -0
- package/src/ui/helpers.ts +105 -0
- package/src/ui/hooks.ts +59 -0
- package/src/ui/index.ts +42 -0
- package/src/ui/preview-view.tsx +39 -0
- package/src/ui/primitives.tsx +304 -0
- package/src/uplink-check.ts +173 -0
- package/dist/chunk-VHLUJQG5.js +0 -17
- package/src/livekit-room-adapter.ts +0 -353
- package/src/livestream-screen.tsx +0 -980
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
+
}) : x)(function(x) {
|
|
8
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
+
});
|
|
11
|
+
var __esm = (fn, res) => function __init() {
|
|
12
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
|
+
};
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
__require,
|
|
30
|
+
__esm,
|
|
31
|
+
__export,
|
|
32
|
+
__toCommonJS
|
|
33
|
+
};
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4;// src/match/remote/deduplicator.ts
|
|
2
|
+
var BTHomeRemoteDeduplicator = (_class = class {
|
|
3
|
+
__init() {this.devices = /* @__PURE__ */ new Map()}
|
|
4
|
+
|
|
5
|
+
constructor(options = {}) {;_class.prototype.__init.call(this);
|
|
6
|
+
this.fingerprintWindowMs = _nullishCoalesce(options.fingerprintWindowMs, () => ( 300));
|
|
7
|
+
}
|
|
8
|
+
get trackedDeviceCount() {
|
|
9
|
+
return this.devices.size;
|
|
10
|
+
}
|
|
11
|
+
accept(deviceId, key, now = Date.now()) {
|
|
12
|
+
const previous = this.devices.get(deviceId);
|
|
13
|
+
if (key.packetId !== void 0) {
|
|
14
|
+
if (_optionalChain([previous, 'optionalAccess', _ => _.packetId]) === key.packetId) return false;
|
|
15
|
+
this.devices.set(deviceId, { packetId: key.packetId });
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (_optionalChain([previous, 'optionalAccess', _2 => _2.fingerprint]) === key.fingerprint && previous.fingerprintSeenAt !== void 0 && now - previous.fingerprintSeenAt <= this.fingerprintWindowMs) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
this.devices.set(deviceId, { fingerprint: key.fingerprint, fingerprintSeenAt: now });
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
forget(deviceId) {
|
|
25
|
+
this.devices.delete(deviceId);
|
|
26
|
+
}
|
|
27
|
+
clear() {
|
|
28
|
+
this.devices.clear();
|
|
29
|
+
}
|
|
30
|
+
}, _class);
|
|
31
|
+
|
|
32
|
+
// src/match/remote/encoding.ts
|
|
33
|
+
function decodeBase64Bytes(value) {
|
|
34
|
+
if (typeof globalThis.atob !== "function") {
|
|
35
|
+
throw new Error("Base64 decoding is unavailable in this runtime");
|
|
36
|
+
}
|
|
37
|
+
const binary = globalThis.atob(value);
|
|
38
|
+
const bytes = new Uint8Array(binary.length);
|
|
39
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
40
|
+
bytes[index] = binary.charCodeAt(index);
|
|
41
|
+
}
|
|
42
|
+
return bytes;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/match/remote/hid-gesture.ts
|
|
46
|
+
var HidVolumeGestureRecognizer = (_class2 = class {
|
|
47
|
+
constructor(options) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
|
|
48
|
+
this.options = options;
|
|
49
|
+
}
|
|
50
|
+
__init2() {this.count = 0}
|
|
51
|
+
__init3() {this.resolved = false}
|
|
52
|
+
__init4() {this.lastTimestamp = null}
|
|
53
|
+
__init5() {this.timer = null}
|
|
54
|
+
push(event) {
|
|
55
|
+
if (this.options.direction !== "any" && event.direction !== this.options.direction) return;
|
|
56
|
+
if (this.lastTimestamp !== null && event.timestamp - this.lastTimestamp > this.options.settleMs) {
|
|
57
|
+
this.finishBurst();
|
|
58
|
+
}
|
|
59
|
+
this.lastTimestamp = event.timestamp;
|
|
60
|
+
this.clearTimer();
|
|
61
|
+
if (!this.resolved) {
|
|
62
|
+
this.count += 1;
|
|
63
|
+
if (event.longPress || this.count >= this.options.holdEventCount) {
|
|
64
|
+
this.resolved = true;
|
|
65
|
+
this.options.onGesture("hold");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this.timer = setTimeout(() => this.finishBurst(), this.options.settleMs);
|
|
69
|
+
}
|
|
70
|
+
dispose() {
|
|
71
|
+
this.clearTimer();
|
|
72
|
+
this.reset();
|
|
73
|
+
}
|
|
74
|
+
finishBurst() {
|
|
75
|
+
this.clearTimer();
|
|
76
|
+
if (!this.resolved && this.count > 0) {
|
|
77
|
+
this.options.onGesture(
|
|
78
|
+
this.count === 1 ? "single" : this.count === 2 ? "double" : this.count === 3 ? "triple" : "quadruple"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
this.reset();
|
|
82
|
+
}
|
|
83
|
+
clearTimer() {
|
|
84
|
+
if (this.timer) clearTimeout(this.timer);
|
|
85
|
+
this.timer = null;
|
|
86
|
+
}
|
|
87
|
+
reset() {
|
|
88
|
+
this.count = 0;
|
|
89
|
+
this.resolved = false;
|
|
90
|
+
this.lastTimestamp = null;
|
|
91
|
+
}
|
|
92
|
+
}, _class2);
|
|
93
|
+
|
|
94
|
+
// src/match/remote/types.ts
|
|
95
|
+
var BTHOME_SERVICE_UUID = "FCD2";
|
|
96
|
+
var DEFAULT_REMOTE_ACTION_MAPPING = {
|
|
97
|
+
volumeUp: "left",
|
|
98
|
+
volumeDown: "right",
|
|
99
|
+
longPress: "undo"
|
|
100
|
+
};
|
|
101
|
+
var RemoteError = (_class3 = class extends Error {
|
|
102
|
+
constructor(code, message, options) {
|
|
103
|
+
super(message, options);_class3.prototype.__init6.call(this);;
|
|
104
|
+
this.code = code;
|
|
105
|
+
}
|
|
106
|
+
__init6() {this.name = "RemoteError"}
|
|
107
|
+
}, _class3);
|
|
108
|
+
|
|
109
|
+
// src/match/remote/parser.ts
|
|
110
|
+
var BTHomeRemoteParseError = (_class4 = class extends Error {
|
|
111
|
+
constructor(code, message) {
|
|
112
|
+
super(message);_class4.prototype.__init7.call(this);;
|
|
113
|
+
this.code = code;
|
|
114
|
+
}
|
|
115
|
+
__init7() {this.name = "BTHomeRemoteParseError"}
|
|
116
|
+
}, _class4);
|
|
117
|
+
var OBJECT_LENGTHS = Object.freeze({
|
|
118
|
+
0: 1,
|
|
119
|
+
1: 1,
|
|
120
|
+
2: 2,
|
|
121
|
+
3: 2,
|
|
122
|
+
4: 3,
|
|
123
|
+
5: 3,
|
|
124
|
+
6: 2,
|
|
125
|
+
7: 2,
|
|
126
|
+
8: 2,
|
|
127
|
+
9: 1,
|
|
128
|
+
10: 3,
|
|
129
|
+
11: 3,
|
|
130
|
+
12: 2,
|
|
131
|
+
13: 2,
|
|
132
|
+
14: 2,
|
|
133
|
+
15: 1,
|
|
134
|
+
16: 1,
|
|
135
|
+
17: 1,
|
|
136
|
+
18: 2,
|
|
137
|
+
19: 2,
|
|
138
|
+
20: 2,
|
|
139
|
+
21: 1,
|
|
140
|
+
22: 1,
|
|
141
|
+
23: 1,
|
|
142
|
+
24: 1,
|
|
143
|
+
25: 1,
|
|
144
|
+
26: 1,
|
|
145
|
+
27: 1,
|
|
146
|
+
28: 1,
|
|
147
|
+
29: 1,
|
|
148
|
+
30: 1,
|
|
149
|
+
31: 1,
|
|
150
|
+
32: 1,
|
|
151
|
+
33: 1,
|
|
152
|
+
34: 1,
|
|
153
|
+
35: 1,
|
|
154
|
+
36: 1,
|
|
155
|
+
37: 1,
|
|
156
|
+
38: 1,
|
|
157
|
+
39: 1,
|
|
158
|
+
40: 1,
|
|
159
|
+
41: 1,
|
|
160
|
+
42: 1,
|
|
161
|
+
43: 1,
|
|
162
|
+
44: 1,
|
|
163
|
+
45: 1,
|
|
164
|
+
46: 1,
|
|
165
|
+
47: 1,
|
|
166
|
+
58: 1,
|
|
167
|
+
60: 2,
|
|
168
|
+
61: 2,
|
|
169
|
+
62: 4,
|
|
170
|
+
63: 2,
|
|
171
|
+
64: 1,
|
|
172
|
+
65: 1,
|
|
173
|
+
66: 1,
|
|
174
|
+
67: 1,
|
|
175
|
+
68: 2,
|
|
176
|
+
69: 2,
|
|
177
|
+
70: 4,
|
|
178
|
+
71: 4,
|
|
179
|
+
72: 4,
|
|
180
|
+
73: 2,
|
|
181
|
+
74: 2,
|
|
182
|
+
75: 2,
|
|
183
|
+
76: 4,
|
|
184
|
+
77: 4,
|
|
185
|
+
78: 4,
|
|
186
|
+
79: 4
|
|
187
|
+
});
|
|
188
|
+
function isBTHomeUuid(uuid) {
|
|
189
|
+
const normalized = uuid.toLowerCase().replaceAll("-", "");
|
|
190
|
+
return normalized === "fcd2" || normalized === "0000fcd200001000800000805f9b34fb";
|
|
191
|
+
}
|
|
192
|
+
function fingerprint(bytes) {
|
|
193
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
194
|
+
}
|
|
195
|
+
function mapButtonEvent(value) {
|
|
196
|
+
if (value === 1) return "single";
|
|
197
|
+
if (value === 2) return "double";
|
|
198
|
+
if (value === 4 || value === 128) return "long";
|
|
199
|
+
if (value === 0 || value === 3 || value === 5 || value === 6) return null;
|
|
200
|
+
return void 0;
|
|
201
|
+
}
|
|
202
|
+
function parseBTHomeV2Advertisement(input) {
|
|
203
|
+
if (!isBTHomeUuid(input.serviceUuid)) {
|
|
204
|
+
throw new BTHomeRemoteParseError("wrong_uuid", `Expected ${BTHOME_SERVICE_UUID} service data`);
|
|
205
|
+
}
|
|
206
|
+
if (input.serviceData.length < 1) {
|
|
207
|
+
throw new BTHomeRemoteParseError("truncated", "BTHome device-info byte is missing");
|
|
208
|
+
}
|
|
209
|
+
const info = input.serviceData[0];
|
|
210
|
+
const version = info >> 5 & 7;
|
|
211
|
+
if (version !== 2) {
|
|
212
|
+
throw new BTHomeRemoteParseError("unsupported_version", `Unsupported BTHome version ${version}`);
|
|
213
|
+
}
|
|
214
|
+
if ((info & 1) !== 0) {
|
|
215
|
+
throw new BTHomeRemoteParseError("encrypted", "Encrypted BTHome advertisements are unsupported");
|
|
216
|
+
}
|
|
217
|
+
let offset = 1;
|
|
218
|
+
let objectIndex = 0;
|
|
219
|
+
let packetId;
|
|
220
|
+
let button;
|
|
221
|
+
while (offset < input.serviceData.length) {
|
|
222
|
+
const objectId = input.serviceData[offset++];
|
|
223
|
+
const length = OBJECT_LENGTHS[objectId];
|
|
224
|
+
if (length === void 0) {
|
|
225
|
+
throw new BTHomeRemoteParseError("unknown_object", `Unknown BTHome object 0x${objectId.toString(16)}`);
|
|
226
|
+
}
|
|
227
|
+
if (offset + length > input.serviceData.length) {
|
|
228
|
+
throw new BTHomeRemoteParseError("truncated", `BTHome object 0x${objectId.toString(16)} is truncated`);
|
|
229
|
+
}
|
|
230
|
+
if (objectId === 0 && packetId === void 0) packetId = input.serviceData[offset];
|
|
231
|
+
if (objectId === 58 && !button) {
|
|
232
|
+
const rawEvent = input.serviceData[offset];
|
|
233
|
+
const action = mapButtonEvent(rawEvent);
|
|
234
|
+
if (action === void 0) {
|
|
235
|
+
throw new BTHomeRemoteParseError("invalid_button_event", `Reserved button event 0x${rawEvent.toString(16)}`);
|
|
236
|
+
}
|
|
237
|
+
if (action) button = { action, objectIndex, rawEvent };
|
|
238
|
+
}
|
|
239
|
+
offset += length;
|
|
240
|
+
objectIndex += 1;
|
|
241
|
+
}
|
|
242
|
+
if (!button) {
|
|
243
|
+
throw new BTHomeRemoteParseError("no_button", "No actionable BTHome button event was found");
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
deviceId: input.deviceId,
|
|
247
|
+
version: 2,
|
|
248
|
+
encrypted: false,
|
|
249
|
+
triggerBased: (info & 4) !== 0,
|
|
250
|
+
packetId,
|
|
251
|
+
button,
|
|
252
|
+
fingerprint: fingerprint(input.serviceData)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
exports.BTHomeRemoteDeduplicator = BTHomeRemoteDeduplicator; exports.decodeBase64Bytes = decodeBase64Bytes; exports.HidVolumeGestureRecognizer = HidVolumeGestureRecognizer; exports.BTHOME_SERVICE_UUID = BTHOME_SERVICE_UUID; exports.DEFAULT_REMOTE_ACTION_MAPPING = DEFAULT_REMOTE_ACTION_MAPPING; exports.RemoteError = RemoteError; exports.BTHomeRemoteParseError = BTHomeRemoteParseError; exports.parseBTHomeV2Advertisement = parseBTHomeV2Advertisement;
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkIUIRVKJIcjs = require('./chunk-IUIRVKJI.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunk7OX2DSKIcjs = require('./chunk-7OX2DSKI.cjs');
|
|
10
|
+
|
|
11
|
+
// src/resume-policy.ts
|
|
12
|
+
function classifyResumeStatus(status) {
|
|
13
|
+
if (status === 404 || status === 409 || status === 410) return "gone";
|
|
14
|
+
if (status >= 200 && status < 300) return "ok";
|
|
15
|
+
return "retry";
|
|
16
|
+
}
|
|
17
|
+
var RESUME_RETRY_DELAYS_MS = [1e3, 2e3, 4e3, 8e3, 15e3];
|
|
18
|
+
function resumeRetryDelayMs(attempt) {
|
|
19
|
+
const index = Math.min(Math.max(attempt, 0), RESUME_RETRY_DELAYS_MS.length - 1);
|
|
20
|
+
return RESUME_RETRY_DELAYS_MS[index];
|
|
21
|
+
}
|
|
22
|
+
function resumeBlocksArm(input) {
|
|
23
|
+
if (input.engineSessionId !== null) return false;
|
|
24
|
+
return input.adoptableSessionId !== null || input.serverSessionId !== null;
|
|
25
|
+
}
|
|
26
|
+
function resumeExternalSessionId(sessionId) {
|
|
27
|
+
return `resume-${sessionId}`;
|
|
28
|
+
}
|
|
29
|
+
function resumeGrantMatches(externalSessionId, grantSessionId) {
|
|
30
|
+
return externalSessionId === resumeExternalSessionId(grantSessionId);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/auto-resume.tsx
|
|
34
|
+
var _react = require('react');
|
|
35
|
+
function useLatest(value) {
|
|
36
|
+
const ref = _react.useRef.call(void 0, value);
|
|
37
|
+
ref.current = value;
|
|
38
|
+
return ref;
|
|
39
|
+
}
|
|
40
|
+
function PickleballAutoResume(props) {
|
|
41
|
+
const {
|
|
42
|
+
provider,
|
|
43
|
+
resumeInput,
|
|
44
|
+
enabled = true,
|
|
45
|
+
sessionIdHint = null,
|
|
46
|
+
retryDelayMs = resumeRetryDelayMs,
|
|
47
|
+
onAttempt
|
|
48
|
+
} = props;
|
|
49
|
+
const live = _chunkIUIRVKJIcjs.useLivestream.call(void 0, );
|
|
50
|
+
const { engine } = _chunkIUIRVKJIcjs.useLivestreamHost.call(void 0, );
|
|
51
|
+
const goneRef = _react.useRef.call(void 0, null);
|
|
52
|
+
const attemptRef = _react.useRef.call(void 0, 0);
|
|
53
|
+
const [retryTick, setRetryTick] = _react.useState.call(void 0, 0);
|
|
54
|
+
const { state, sessionId, adoptableSessionId } = live;
|
|
55
|
+
const resumeId = _nullishCoalesce(adoptableSessionId, () => ( sessionIdHint));
|
|
56
|
+
const liveRef = useLatest(live);
|
|
57
|
+
const onAttemptRef = useLatest(onAttempt);
|
|
58
|
+
const resumeInputRef = useLatest(resumeInput);
|
|
59
|
+
const retryDelayRef = useLatest(retryDelayMs);
|
|
60
|
+
_react.useEffect.call(void 0, () => {
|
|
61
|
+
if (!enabled) return;
|
|
62
|
+
if (!resumeId || sessionId !== null || state !== "preview") return;
|
|
63
|
+
if (goneRef.current === resumeId) return;
|
|
64
|
+
let cancelled = false;
|
|
65
|
+
let timer;
|
|
66
|
+
const scheduleRetry = () => {
|
|
67
|
+
const delay = retryDelayRef.current(attemptRef.current);
|
|
68
|
+
attemptRef.current += 1;
|
|
69
|
+
timer = setTimeout(() => {
|
|
70
|
+
if (!cancelled) setRetryTick((tick) => tick + 1);
|
|
71
|
+
}, delay);
|
|
72
|
+
};
|
|
73
|
+
void (async () => {
|
|
74
|
+
const result = await provider.resume(resumeId);
|
|
75
|
+
if (cancelled) return;
|
|
76
|
+
_optionalChain([onAttemptRef, 'access', _ => _.current, 'optionalCall', _2 => _2(resumeId, result.kind)]);
|
|
77
|
+
if (result.kind === "gone") {
|
|
78
|
+
goneRef.current = resumeId;
|
|
79
|
+
attemptRef.current = 0;
|
|
80
|
+
void engine.abandonAdoptableSession(resumeId).catch(() => void 0);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (result.kind === "retry") {
|
|
84
|
+
scheduleRetry();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
attemptRef.current = 0;
|
|
88
|
+
provider.adoptResumeGrant(result.grant);
|
|
89
|
+
const resumeInput2 = resumeInputRef.current;
|
|
90
|
+
await liveRef.current.start(
|
|
91
|
+
{
|
|
92
|
+
externalSessionId: resumeExternalSessionId(resumeId),
|
|
93
|
+
title: _nullishCoalesce(_optionalChain([resumeInput2, 'access', _3 => _3.titleFor, 'optionalCall', _4 => _4(resumeId)]), () => ( "Phi\xEAn \u0111ang kh\xF4i ph\u1EE5c")),
|
|
94
|
+
consentVersion: resumeInput2.consentVersion,
|
|
95
|
+
visibility: _nullishCoalesce(resumeInput2.visibility, () => ( "public")),
|
|
96
|
+
...resumeInput2.metadata ? { metadata: resumeInput2.metadata } : {}
|
|
97
|
+
},
|
|
98
|
+
// Trạng thái lấy từ chính phản hồi refresh, KHÔNG đoán: gán cứng "live" là
|
|
99
|
+
// camera tự lên sóng khi chủ nó chỉ đang trực sân (18/08/2026).
|
|
100
|
+
{ autoPublish: result.live }
|
|
101
|
+
).catch(() => {
|
|
102
|
+
_optionalChain([onAttemptRef, 'access', _5 => _5.current, 'optionalCall', _6 => _6(resumeId, "start_failed")]);
|
|
103
|
+
if (!cancelled) scheduleRetry();
|
|
104
|
+
});
|
|
105
|
+
})();
|
|
106
|
+
return () => {
|
|
107
|
+
cancelled = true;
|
|
108
|
+
if (timer) clearTimeout(timer);
|
|
109
|
+
};
|
|
110
|
+
}, [enabled, provider, resumeId, sessionId, state, retryTick, engine, liveRef, onAttemptRef, resumeInputRef, retryDelayRef]);
|
|
111
|
+
_react.useEffect.call(void 0, () => {
|
|
112
|
+
if (!enabled || state !== "error" || sessionId === null) return;
|
|
113
|
+
const timer = setTimeout(() => {
|
|
114
|
+
_optionalChain([onAttemptRef, 'access', _7 => _7.current, 'optionalCall', _8 => _8(sessionId, "publish_retry")]);
|
|
115
|
+
void liveRef.current.retry().catch(() => void 0);
|
|
116
|
+
}, retryDelayRef.current(attemptRef.current++));
|
|
117
|
+
return () => clearTimeout(timer);
|
|
118
|
+
}, [enabled, state, sessionId, liveRef, onAttemptRef, retryDelayRef]);
|
|
119
|
+
_react.useEffect.call(void 0, () => {
|
|
120
|
+
if (!enabled || state !== "error" || sessionId !== null || !adoptableSessionId) return;
|
|
121
|
+
const timer = setTimeout(() => {
|
|
122
|
+
_optionalChain([onAttemptRef, 'access', _9 => _9.current, 'optionalCall', _10 => _10(adoptableSessionId, "reprepare")]);
|
|
123
|
+
void liveRef.current.prepare().catch(() => void 0);
|
|
124
|
+
}, 2e3);
|
|
125
|
+
return () => clearTimeout(timer);
|
|
126
|
+
}, [enabled, state, sessionId, adoptableSessionId, liveRef, onAttemptRef]);
|
|
127
|
+
_react.useEffect.call(void 0, () => {
|
|
128
|
+
if (state === "live" || state === "standby") attemptRef.current = 0;
|
|
129
|
+
}, [state]);
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
function PickleballAutoPrepare(props) {
|
|
133
|
+
const { enabled = true, captureOrientation } = props;
|
|
134
|
+
const live = _chunkIUIRVKJIcjs.useLivestream.call(void 0, );
|
|
135
|
+
const { state } = live;
|
|
136
|
+
const liveRef = useLatest(live);
|
|
137
|
+
const orientedRef = _react.useRef.call(void 0, false);
|
|
138
|
+
_react.useEffect.call(void 0, () => {
|
|
139
|
+
if (!enabled || !captureOrientation || orientedRef.current) return;
|
|
140
|
+
orientedRef.current = true;
|
|
141
|
+
void liveRef.current.setCaptureOrientation(captureOrientation).catch(() => void 0);
|
|
142
|
+
}, [enabled, captureOrientation, liveRef]);
|
|
143
|
+
_react.useEffect.call(void 0, () => {
|
|
144
|
+
if (!enabled) return;
|
|
145
|
+
if (state !== "idle" && state !== "ended") return;
|
|
146
|
+
void liveRef.current.prepare().catch(() => void 0);
|
|
147
|
+
}, [enabled, state, liveRef]);
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
function useStandbySession(options) {
|
|
151
|
+
const { input, enabled = true, resumeSessionId = null } = options;
|
|
152
|
+
const live = _chunkIUIRVKJIcjs.useLivestream.call(void 0, );
|
|
153
|
+
const { state, sessionId, adoptableSessionId } = live;
|
|
154
|
+
const liveRef = useLatest(live);
|
|
155
|
+
const armedForRef = _react.useRef.call(void 0, null);
|
|
156
|
+
const inputRef = useLatest(input);
|
|
157
|
+
const externalSessionId = input.externalSessionId;
|
|
158
|
+
const armed = sessionId !== null && armedForRef.current === externalSessionId;
|
|
159
|
+
_react.useEffect.call(void 0, () => {
|
|
160
|
+
if (!enabled) return;
|
|
161
|
+
if (state !== "preview" || sessionId !== null) return;
|
|
162
|
+
if (armedForRef.current === externalSessionId) return;
|
|
163
|
+
if (resumeBlocksArm({
|
|
164
|
+
adoptableSessionId,
|
|
165
|
+
serverSessionId: resumeSessionId,
|
|
166
|
+
engineSessionId: sessionId
|
|
167
|
+
})) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
armedForRef.current = externalSessionId;
|
|
171
|
+
void liveRef.current.start(inputRef.current, { autoPublish: false }).catch(() => {
|
|
172
|
+
armedForRef.current = null;
|
|
173
|
+
});
|
|
174
|
+
}, [enabled, state, sessionId, adoptableSessionId, resumeSessionId, externalSessionId, liveRef, inputRef]);
|
|
175
|
+
return { armed };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/camera-settings.ts
|
|
179
|
+
|
|
180
|
+
var CAMERA_SETTINGS_STORAGE_KEY = "@pickleball/expo-sdk/camera-settings";
|
|
181
|
+
var DEFAULT_CAMERA_SETTINGS = Object.freeze({
|
|
182
|
+
resolution: 720,
|
|
183
|
+
fps: 30,
|
|
184
|
+
antiFlicker: "50hz",
|
|
185
|
+
cameraId: null
|
|
186
|
+
});
|
|
187
|
+
function parseCameraSettings(raw, defaults = DEFAULT_CAMERA_SETTINGS) {
|
|
188
|
+
if (!raw) return { ...defaults };
|
|
189
|
+
try {
|
|
190
|
+
const parsed = JSON.parse(raw);
|
|
191
|
+
if (parsed === null || typeof parsed !== "object") return { ...defaults };
|
|
192
|
+
return {
|
|
193
|
+
resolution: parsed.resolution === 1080 ? 1080 : parsed.resolution === 720 ? 720 : defaults.resolution,
|
|
194
|
+
fps: parsed.fps === 24 || parsed.fps === 30 || parsed.fps === 60 ? parsed.fps : defaults.fps,
|
|
195
|
+
antiFlicker: parsed.antiFlicker === "auto" || parsed.antiFlicker === "60hz" || parsed.antiFlicker === "50hz" ? parsed.antiFlicker : defaults.antiFlicker,
|
|
196
|
+
cameraId: typeof parsed.cameraId === "string" ? parsed.cameraId : null
|
|
197
|
+
};
|
|
198
|
+
} catch (e) {
|
|
199
|
+
return { ...defaults };
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function createCameraSettingsStore(options = {}) {
|
|
203
|
+
const storage = _nullishCoalesce(options.storage, () => ( _chunkIUIRVKJIcjs.createDefaultStorage.call(void 0, )));
|
|
204
|
+
const key = _nullishCoalesce(options.key, () => ( CAMERA_SETTINGS_STORAGE_KEY));
|
|
205
|
+
const defaults = { ...DEFAULT_CAMERA_SETTINGS, ...options.defaults };
|
|
206
|
+
let settings = { ...defaults };
|
|
207
|
+
let restored = false;
|
|
208
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
209
|
+
const emit = () => {
|
|
210
|
+
for (const listener of listeners) listener();
|
|
211
|
+
};
|
|
212
|
+
return {
|
|
213
|
+
key,
|
|
214
|
+
get: () => settings,
|
|
215
|
+
set(patch) {
|
|
216
|
+
settings = { ...settings, ...patch };
|
|
217
|
+
void storage.setItem(key, JSON.stringify(settings)).catch(() => void 0);
|
|
218
|
+
emit();
|
|
219
|
+
},
|
|
220
|
+
subscribe(listener) {
|
|
221
|
+
listeners.add(listener);
|
|
222
|
+
return () => {
|
|
223
|
+
listeners.delete(listener);
|
|
224
|
+
};
|
|
225
|
+
},
|
|
226
|
+
async restore() {
|
|
227
|
+
const raw = await storage.getItem(key).catch(() => null);
|
|
228
|
+
settings = parseCameraSettings(raw, defaults);
|
|
229
|
+
restored = true;
|
|
230
|
+
emit();
|
|
231
|
+
},
|
|
232
|
+
isRestored: () => restored
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function useCameraSettings(store) {
|
|
236
|
+
return _react.useSyncExternalStore.call(void 0, store.subscribe, store.get, store.get);
|
|
237
|
+
}
|
|
238
|
+
function cameraSettingsKey(settings) {
|
|
239
|
+
return `${settings.resolution}:${settings.fps}:${_nullishCoalesce(settings.cameraId, () => ( "default"))}`;
|
|
240
|
+
}
|
|
241
|
+
function rtmpRoomFactoryFor(settings) {
|
|
242
|
+
return _chunkIUIRVKJIcjs.createRtmpRoomFactory.call(void 0, {
|
|
243
|
+
frameRate: settings.fps,
|
|
244
|
+
...settings.cameraId ? { cameraId: settings.cameraId } : {}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// src/camera-controls.ts
|
|
249
|
+
function nativeModule() {
|
|
250
|
+
try {
|
|
251
|
+
const loaded = _chunk7OX2DSKIcjs.__require.call(void 0, "@pickleball/rtmp-native");
|
|
252
|
+
const candidate = _nullishCoalesce(_optionalChain([loaded, 'optionalAccess', _11 => _11.default]), () => ( loaded));
|
|
253
|
+
return candidate && typeof candidate === "object" ? candidate : null;
|
|
254
|
+
} catch (e2) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function callOptional(name, invoke, fallback) {
|
|
259
|
+
const native = nativeModule();
|
|
260
|
+
if (!native || typeof native[name] !== "function") return fallback;
|
|
261
|
+
try {
|
|
262
|
+
const result = await invoke(native);
|
|
263
|
+
return result === void 0 ? fallback : result;
|
|
264
|
+
} catch (e3) {
|
|
265
|
+
return fallback;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function getCameraCapabilities() {
|
|
269
|
+
return callOptional("getCameraCapabilities", (n) => _optionalChain([n, 'access', _12 => _12.getCameraCapabilities, 'optionalCall', _13 => _13()]), null);
|
|
270
|
+
}
|
|
271
|
+
function setZoom(factor) {
|
|
272
|
+
return callOptional("setZoom", (n) => _optionalChain([n, 'access', _14 => _14.setZoom, 'optionalCall', _15 => _15(factor)]), void 0);
|
|
273
|
+
}
|
|
274
|
+
function setExposureBias(ev) {
|
|
275
|
+
return callOptional("setExposureBias", (n) => _optionalChain([n, 'access', _16 => _16.setExposureBias, 'optionalCall', _17 => _17(ev)]), void 0);
|
|
276
|
+
}
|
|
277
|
+
function setFocusLocked(locked) {
|
|
278
|
+
return callOptional("setFocusLocked", (n) => _optionalChain([n, 'access', _18 => _18.setFocusLocked, 'optionalCall', _19 => _19(locked)]), void 0);
|
|
279
|
+
}
|
|
280
|
+
function setExposureLocked(locked) {
|
|
281
|
+
return callOptional("setExposureLocked", (n) => _optionalChain([n, 'access', _20 => _20.setExposureLocked, 'optionalCall', _21 => _21(locked)]), void 0);
|
|
282
|
+
}
|
|
283
|
+
function setTorch(enabled) {
|
|
284
|
+
return callOptional("setTorch", (n) => _optionalChain([n, 'access', _22 => _22.setTorch, 'optionalCall', _23 => _23(enabled)]), void 0);
|
|
285
|
+
}
|
|
286
|
+
function applyAntiFlicker(mode) {
|
|
287
|
+
return callOptional("setAntiFlicker", (n) => _optionalChain([n, 'access', _24 => _24.setAntiFlicker, 'optionalCall', _25 => _25(mode)]), void 0);
|
|
288
|
+
}
|
|
289
|
+
function requestNativePermissions() {
|
|
290
|
+
return callOptional("requestPermissions", (n) => _optionalChain([n, 'access', _26 => _26.requestPermissions, 'optionalCall', _27 => _27()]), null);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
exports.classifyResumeStatus = classifyResumeStatus; exports.RESUME_RETRY_DELAYS_MS = RESUME_RETRY_DELAYS_MS; exports.resumeRetryDelayMs = resumeRetryDelayMs; exports.resumeBlocksArm = resumeBlocksArm; exports.resumeExternalSessionId = resumeExternalSessionId; exports.resumeGrantMatches = resumeGrantMatches; exports.PickleballAutoResume = PickleballAutoResume; exports.PickleballAutoPrepare = PickleballAutoPrepare; exports.useStandbySession = useStandbySession; exports.CAMERA_SETTINGS_STORAGE_KEY = CAMERA_SETTINGS_STORAGE_KEY; exports.DEFAULT_CAMERA_SETTINGS = DEFAULT_CAMERA_SETTINGS; exports.parseCameraSettings = parseCameraSettings; exports.createCameraSettingsStore = createCameraSettingsStore; exports.useCameraSettings = useCameraSettings; exports.cameraSettingsKey = cameraSettingsKey; exports.rtmpRoomFactoryFor = rtmpRoomFactoryFor; exports.getCameraCapabilities = getCameraCapabilities; exports.setZoom = setZoom; exports.setExposureBias = setExposureBias; exports.setFocusLocked = setFocusLocked; exports.setExposureLocked = setExposureLocked; exports.setTorch = setTorch; exports.applyAntiFlicker = applyAntiFlicker; exports.requestNativePermissions = requestNativePermissions;
|