@getuserfeedback/react-native 4.0.31 → 5.0.7
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/README.md +12 -150
- package/dist/client.d.ts +64 -0
- package/dist/client.js +1 -0
- package/dist/core-webview-host.d.ts +0 -1
- package/dist/core-webview-host.js +2 -12
- package/dist/native-core-command-channel.d.ts +1 -0
- package/dist/native-core-command-channel.js +20 -4
- package/dist/native-provider-client-controller.d.ts +11 -0
- package/dist/native-provider-client-controller.js +38 -0
- package/dist/native-provider-client.d.ts +3 -17
- package/dist/native-provider-command-controller.d.ts +19 -0
- package/dist/native-provider-command-controller.js +79 -0
- package/dist/native-provider-flow-registry.d.ts +7 -0
- package/dist/native-provider-flow-registry.js +70 -0
- package/dist/native-provider.d.ts +32 -0
- package/dist/native-provider.js +88 -0
- package/dist/native-runtime-root.d.ts +2 -4
- package/dist/native-runtime-root.js +6 -3
- package/dist/native-view-host-projection.d.ts +1 -2
- package/dist/native-view-host-projection.js +22 -6
- package/dist/native-view-presentation-surface.js +6 -1
- package/dist/native-view-record-controller.d.ts +9 -3
- package/dist/native-view-record-controller.js +276 -50
- package/dist/native-widget-corner-radii.d.ts +1 -2
- package/dist/native-widget-corner-radii.js +1 -1
- package/dist/provider-command-helpers.d.ts +1 -11
- package/dist/provider-command-helpers.js +1 -38
- package/dist/public-api.d.ts +2 -1
- package/dist/public-api.js +2 -1
- package/dist/runtime-endpoints.d.ts +2 -0
- package/dist/runtime-endpoints.js +2 -0
- package/dist/version.js +1 -1
- package/dist/view-orchestration-runtime.js +11 -43
- package/dist/view-webview-host-controller.d.ts +1 -0
- package/dist/view-webview-host-controller.js +1 -0
- package/dist/view-webview-host.d.ts +1 -1
- package/dist/view-webview-host.js +3 -7
- package/dist/webview-document-host.d.ts +2 -3
- package/dist/webview-document-host.js +21 -33
- package/package.json +3 -3
- package/dist/host-viewport.d.ts +0 -3
- package/dist/host-viewport.js +0 -69
- package/dist/index.d.ts +0 -91
- package/dist/index.js +0 -613
- package/dist/provider-command-transport.d.ts +0 -52
- package/dist/provider-command-transport.js +0 -150
- package/dist/provider-message-queue.d.ts +0 -11
- package/dist/provider-message-queue.js +0 -23
- package/dist/provider-pending-commands.d.ts +0 -34
- package/dist/provider-pending-commands.js +0 -58
- package/dist/provider-widget-border-radius.d.ts +0 -11
- package/dist/provider-widget-border-radius.js +0 -102
- package/dist/provider-widget-frame-appearance.d.ts +0 -17
- package/dist/provider-widget-frame-appearance.js +0 -43
- package/dist/provider-widget-host-lifecycle.d.ts +0 -46
- package/dist/provider-widget-host-lifecycle.js +0 -138
- package/dist/provider-widget-host-overlay.d.ts +0 -58
- package/dist/provider-widget-host-overlay.js +0 -616
- package/dist/use-native-direct-command-session-controller.d.ts +0 -2
- package/dist/use-native-direct-command-session-controller.js +0 -21
- package/dist/webview-bridge-script.d.ts +0 -16
- package/dist/webview-bridge-script.js +0 -283
- package/dist/widget-host-lifecycle-machine.d.ts +0 -35
- package/dist/widget-host-lifecycle-machine.js +0 -37
- package/dist/widget-host.d.ts +0 -38
- package/dist/widget-host.js +0 -327
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { useCallback, useRef, useState } from "react";
|
|
2
|
-
import { enqueueProviderNativeMessage, removeProviderNativeMessageId, removeProviderNativeMessageIds, replaceProviderNativeMessages, } from "./provider-message-queue.js";
|
|
3
|
-
import { cancelProviderStartupCommands, clearProviderPendingCommands, createProviderPendingCommandRegistry, getProviderPendingCommand, getProviderPendingCommandEntries, getProviderPendingCommands, hasDeliveredProviderPendingCommands, isProviderPendingMessageStartup, registerProviderPendingCommand, reissueProviderPendingCommand, takeProviderPendingCommand, } from "./provider-pending-commands.js";
|
|
4
|
-
export function useProviderCommandTransport({ commandTimeoutMs, createTimeoutError, getCurrentHostEpoch, }) {
|
|
5
|
-
const [nativeMessages, setNativeMessages] = useState([]);
|
|
6
|
-
const nativeMessagesRef = useRef([]);
|
|
7
|
-
const pendingCommandsRef = useRef(createProviderPendingCommandRegistry());
|
|
8
|
-
const startupQueuedKeyRef = useRef(null);
|
|
9
|
-
nativeMessagesRef.current = nativeMessages;
|
|
10
|
-
const removeNativeMessageId = useCallback((messageId) => {
|
|
11
|
-
setNativeMessages((messages) => removeProviderNativeMessageId(messages, messageId));
|
|
12
|
-
}, []);
|
|
13
|
-
const removeNativeMessageIds = useCallback((messageIds) => {
|
|
14
|
-
setNativeMessages((messages) => removeProviderNativeMessageIds(messages, messageIds));
|
|
15
|
-
}, []);
|
|
16
|
-
const rejectPendingCommand = useCallback((requestId, pendingCommand, error) => {
|
|
17
|
-
takeProviderPendingCommand(pendingCommandsRef.current, requestId);
|
|
18
|
-
if (pendingCommand.timeout) {
|
|
19
|
-
clearTimeout(pendingCommand.timeout);
|
|
20
|
-
pendingCommand.timeout = null;
|
|
21
|
-
}
|
|
22
|
-
if (pendingCommand.isStartup) {
|
|
23
|
-
startupQueuedKeyRef.current = null;
|
|
24
|
-
}
|
|
25
|
-
removeNativeMessageId(pendingCommand.messageId);
|
|
26
|
-
pendingCommand.reject(error);
|
|
27
|
-
}, [removeNativeMessageId]);
|
|
28
|
-
const startPendingCommandTimeout = useCallback((requestId, pendingCommand) => {
|
|
29
|
-
pendingCommand.hostEpoch = getCurrentHostEpoch();
|
|
30
|
-
if (commandTimeoutMs <= 0) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (pendingCommand.timeout) {
|
|
34
|
-
clearTimeout(pendingCommand.timeout);
|
|
35
|
-
}
|
|
36
|
-
pendingCommand.timeout = setTimeout(() => {
|
|
37
|
-
rejectPendingCommand(requestId, pendingCommand, createTimeoutError(requestId));
|
|
38
|
-
}, commandTimeoutMs);
|
|
39
|
-
}, [
|
|
40
|
-
commandTimeoutMs,
|
|
41
|
-
createTimeoutError,
|
|
42
|
-
getCurrentHostEpoch,
|
|
43
|
-
rejectPendingCommand,
|
|
44
|
-
]);
|
|
45
|
-
const startPendingCommandTimeouts = useCallback(() => {
|
|
46
|
-
for (const [requestId, pendingCommand] of getProviderPendingCommandEntries(pendingCommandsRef.current)) {
|
|
47
|
-
startPendingCommandTimeout(requestId, pendingCommand);
|
|
48
|
-
}
|
|
49
|
-
}, [startPendingCommandTimeout]);
|
|
50
|
-
const pausePendingCommandTimeouts = useCallback(() => {
|
|
51
|
-
for (const pendingCommand of getProviderPendingCommands(pendingCommandsRef.current)) {
|
|
52
|
-
if (!pendingCommand.timeout) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
clearTimeout(pendingCommand.timeout);
|
|
56
|
-
pendingCommand.timeout = null;
|
|
57
|
-
}
|
|
58
|
-
}, []);
|
|
59
|
-
const createPendingCommandPromise = useCallback(({ isStartup, message, requestId, result, }) => new Promise((resolve, reject) => {
|
|
60
|
-
const pendingCommand = {
|
|
61
|
-
hostEpoch: null,
|
|
62
|
-
isStartup,
|
|
63
|
-
messageId: message.id,
|
|
64
|
-
reject,
|
|
65
|
-
resolve,
|
|
66
|
-
result,
|
|
67
|
-
timeout: null,
|
|
68
|
-
};
|
|
69
|
-
registerProviderPendingCommand(pendingCommandsRef.current, requestId, pendingCommand);
|
|
70
|
-
if (getCurrentHostEpoch() !== null) {
|
|
71
|
-
startPendingCommandTimeout(requestId, pendingCommand);
|
|
72
|
-
}
|
|
73
|
-
}), [getCurrentHostEpoch, startPendingCommandTimeout]);
|
|
74
|
-
const registerNativeMessage = useCallback((message, options) => {
|
|
75
|
-
setNativeMessages((messages) => enqueueProviderNativeMessage(messages, Object.assign(Object.assign({}, options), { isStartupMessage: (entry) => isProviderPendingMessageStartup(pendingCommandsRef.current, entry.envelope.requestId), message })));
|
|
76
|
-
}, []);
|
|
77
|
-
const replaceNativeMessages = useCallback((replacements) => {
|
|
78
|
-
setNativeMessages((messages) => replaceProviderNativeMessages(messages, replacements));
|
|
79
|
-
}, []);
|
|
80
|
-
const reissuePendingCommand = useCallback(({ nextMessage, nextRequestId, nextResult, requestId, }) => {
|
|
81
|
-
const reissuedCommand = reissueProviderPendingCommand(pendingCommandsRef.current, {
|
|
82
|
-
nextMessageId: nextMessage.id,
|
|
83
|
-
nextRequestId,
|
|
84
|
-
nextResult,
|
|
85
|
-
requestId,
|
|
86
|
-
});
|
|
87
|
-
return reissuedCommand
|
|
88
|
-
? { previousMessageId: reissuedCommand.previousMessageId }
|
|
89
|
-
: null;
|
|
90
|
-
}, []);
|
|
91
|
-
const cancelStartupCommands = useCallback((error) => {
|
|
92
|
-
const canceled = cancelProviderStartupCommands(pendingCommandsRef.current);
|
|
93
|
-
for (const pendingCommand of canceled.commands) {
|
|
94
|
-
if (pendingCommand.timeout) {
|
|
95
|
-
clearTimeout(pendingCommand.timeout);
|
|
96
|
-
}
|
|
97
|
-
pendingCommand.reject(error);
|
|
98
|
-
}
|
|
99
|
-
if (canceled.messageIds.size > 0) {
|
|
100
|
-
removeNativeMessageIds(canceled.messageIds);
|
|
101
|
-
}
|
|
102
|
-
}, [removeNativeMessageIds]);
|
|
103
|
-
const dispose = useCallback((error) => {
|
|
104
|
-
for (const pendingCommand of getProviderPendingCommands(pendingCommandsRef.current)) {
|
|
105
|
-
if (pendingCommand.timeout) {
|
|
106
|
-
clearTimeout(pendingCommand.timeout);
|
|
107
|
-
}
|
|
108
|
-
pendingCommand.reject(error);
|
|
109
|
-
}
|
|
110
|
-
clearProviderPendingCommands(pendingCommandsRef.current);
|
|
111
|
-
startupQueuedKeyRef.current = null;
|
|
112
|
-
}, []);
|
|
113
|
-
const clearStartupQueuedKey = useCallback(() => {
|
|
114
|
-
startupQueuedKeyRef.current = null;
|
|
115
|
-
}, []);
|
|
116
|
-
const getPendingCommand = useCallback((requestId) => getProviderPendingCommand(pendingCommandsRef.current, requestId), []);
|
|
117
|
-
const getPendingCommandEntries = useCallback(() => getProviderPendingCommandEntries(pendingCommandsRef.current), []);
|
|
118
|
-
const hasDeliveredPendingCommands = useCallback(() => hasDeliveredProviderPendingCommands(pendingCommandsRef.current), []);
|
|
119
|
-
const isStartupQueuedKey = useCallback((key) => startupQueuedKeyRef.current === key, []);
|
|
120
|
-
const resetStartupQueuedKeyIfChanged = useCallback((key) => {
|
|
121
|
-
if (startupQueuedKeyRef.current !== key) {
|
|
122
|
-
startupQueuedKeyRef.current = null;
|
|
123
|
-
}
|
|
124
|
-
}, []);
|
|
125
|
-
const setStartupQueuedKey = useCallback((key) => {
|
|
126
|
-
startupQueuedKeyRef.current = key;
|
|
127
|
-
}, []);
|
|
128
|
-
const takePendingCommand = useCallback((requestId) => takeProviderPendingCommand(pendingCommandsRef.current, requestId), []);
|
|
129
|
-
return {
|
|
130
|
-
cancelStartupCommands,
|
|
131
|
-
clearStartupQueuedKey,
|
|
132
|
-
createPendingCommandPromise,
|
|
133
|
-
dispose,
|
|
134
|
-
getPendingCommand,
|
|
135
|
-
getPendingCommandEntries,
|
|
136
|
-
hasDeliveredPendingCommands,
|
|
137
|
-
isStartupQueuedKey,
|
|
138
|
-
nativeMessages,
|
|
139
|
-
nativeMessagesRef,
|
|
140
|
-
pausePendingCommandTimeouts,
|
|
141
|
-
registerNativeMessage,
|
|
142
|
-
reissuePendingCommand,
|
|
143
|
-
removeNativeMessageId,
|
|
144
|
-
replaceNativeMessages,
|
|
145
|
-
resetStartupQueuedKeyIfChanged,
|
|
146
|
-
setStartupQueuedKey,
|
|
147
|
-
startPendingCommandTimeouts,
|
|
148
|
-
takePendingCommand,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { WebViewTransportNativeMessage } from "@getuserfeedback/protocol/webview-transport";
|
|
2
|
-
export type ProviderNativeMessageQueue = readonly WebViewTransportNativeMessage[];
|
|
3
|
-
export declare function enqueueProviderNativeMessage(messages: ProviderNativeMessageQueue, { isStartup, isStartupMessage, message, prioritizeStartup, }: {
|
|
4
|
-
isStartup: boolean;
|
|
5
|
-
isStartupMessage: (message: WebViewTransportNativeMessage) => boolean;
|
|
6
|
-
message: WebViewTransportNativeMessage;
|
|
7
|
-
prioritizeStartup: boolean;
|
|
8
|
-
}): WebViewTransportNativeMessage[];
|
|
9
|
-
export declare function removeProviderNativeMessageIds(messages: ProviderNativeMessageQueue, messageIds: ReadonlySet<string>): WebViewTransportNativeMessage[];
|
|
10
|
-
export declare function removeProviderNativeMessageId(messages: ProviderNativeMessageQueue, messageId: string): WebViewTransportNativeMessage[];
|
|
11
|
-
export declare function replaceProviderNativeMessages(messages: ProviderNativeMessageQueue, replacementsByMessageId: ReadonlyMap<string, WebViewTransportNativeMessage>): WebViewTransportNativeMessage[];
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export function enqueueProviderNativeMessage(messages, { isStartup, isStartupMessage, message, prioritizeStartup, }) {
|
|
2
|
-
if (!(isStartup && prioritizeStartup)) {
|
|
3
|
-
return [...messages, message];
|
|
4
|
-
}
|
|
5
|
-
const firstActionIndex = messages.findIndex((entry) => !isStartupMessage(entry));
|
|
6
|
-
if (firstActionIndex === -1) {
|
|
7
|
-
return [...messages, message];
|
|
8
|
-
}
|
|
9
|
-
return [
|
|
10
|
-
...messages.slice(0, firstActionIndex),
|
|
11
|
-
message,
|
|
12
|
-
...messages.slice(firstActionIndex),
|
|
13
|
-
];
|
|
14
|
-
}
|
|
15
|
-
export function removeProviderNativeMessageIds(messages, messageIds) {
|
|
16
|
-
return messages.filter((entry) => !messageIds.has(entry.id));
|
|
17
|
-
}
|
|
18
|
-
export function removeProviderNativeMessageId(messages, messageId) {
|
|
19
|
-
return removeProviderNativeMessageIds(messages, new Set([messageId]));
|
|
20
|
-
}
|
|
21
|
-
export function replaceProviderNativeMessages(messages, replacementsByMessageId) {
|
|
22
|
-
return messages.map((message) => { var _a; return (_a = replacementsByMessageId.get(message.id)) !== null && _a !== void 0 ? _a : message; });
|
|
23
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export type ProviderPendingCommand<Result> = {
|
|
2
|
-
hostEpoch: number | null;
|
|
3
|
-
isStartup: boolean;
|
|
4
|
-
messageId: string;
|
|
5
|
-
reject: (error: Error) => void;
|
|
6
|
-
resolve: (result: Result) => void;
|
|
7
|
-
result: Result;
|
|
8
|
-
timeout: ReturnType<typeof setTimeout> | null;
|
|
9
|
-
};
|
|
10
|
-
export type ProviderPendingCommandRegistry<Result> = Map<string, ProviderPendingCommand<Result>>;
|
|
11
|
-
export type ProviderCanceledStartupCommands<Result> = {
|
|
12
|
-
commands: ProviderPendingCommand<Result>[];
|
|
13
|
-
messageIds: Set<string>;
|
|
14
|
-
};
|
|
15
|
-
export type ProviderReissuedPendingCommand<Result> = {
|
|
16
|
-
command: ProviderPendingCommand<Result>;
|
|
17
|
-
previousMessageId: string;
|
|
18
|
-
};
|
|
19
|
-
export declare function createProviderPendingCommandRegistry<Result>(): ProviderPendingCommandRegistry<Result>;
|
|
20
|
-
export declare function registerProviderPendingCommand<Result>(registry: ProviderPendingCommandRegistry<Result>, requestId: string, command: ProviderPendingCommand<Result>): void;
|
|
21
|
-
export declare function getProviderPendingCommand<Result>(registry: ProviderPendingCommandRegistry<Result>, requestId: string): ProviderPendingCommand<Result> | undefined;
|
|
22
|
-
export declare function takeProviderPendingCommand<Result>(registry: ProviderPendingCommandRegistry<Result>, requestId: string): ProviderPendingCommand<Result> | undefined;
|
|
23
|
-
export declare function hasDeliveredProviderPendingCommands<Result>(registry: ProviderPendingCommandRegistry<Result>): boolean;
|
|
24
|
-
export declare function isProviderPendingMessageStartup<Result>(registry: ProviderPendingCommandRegistry<Result>, requestId: string): boolean;
|
|
25
|
-
export declare function getProviderPendingCommandEntries<Result>(registry: ProviderPendingCommandRegistry<Result>): Array<[string, ProviderPendingCommand<Result>]>;
|
|
26
|
-
export declare function getProviderPendingCommands<Result>(registry: ProviderPendingCommandRegistry<Result>): ProviderPendingCommand<Result>[];
|
|
27
|
-
export declare function cancelProviderStartupCommands<Result>(registry: ProviderPendingCommandRegistry<Result>): ProviderCanceledStartupCommands<Result>;
|
|
28
|
-
export declare function reissueProviderPendingCommand<Result>(registry: ProviderPendingCommandRegistry<Result>, { nextMessageId, nextRequestId, nextResult, requestId, }: {
|
|
29
|
-
nextMessageId: string;
|
|
30
|
-
nextRequestId: string;
|
|
31
|
-
nextResult: Result;
|
|
32
|
-
requestId: string;
|
|
33
|
-
}): ProviderReissuedPendingCommand<Result> | null;
|
|
34
|
-
export declare function clearProviderPendingCommands<Result>(registry: ProviderPendingCommandRegistry<Result>): void;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export function createProviderPendingCommandRegistry() {
|
|
2
|
-
return new Map();
|
|
3
|
-
}
|
|
4
|
-
export function registerProviderPendingCommand(registry, requestId, command) {
|
|
5
|
-
registry.set(requestId, command);
|
|
6
|
-
}
|
|
7
|
-
export function getProviderPendingCommand(registry, requestId) {
|
|
8
|
-
return registry.get(requestId);
|
|
9
|
-
}
|
|
10
|
-
export function takeProviderPendingCommand(registry, requestId) {
|
|
11
|
-
const command = registry.get(requestId);
|
|
12
|
-
if (command) {
|
|
13
|
-
registry.delete(requestId);
|
|
14
|
-
}
|
|
15
|
-
return command;
|
|
16
|
-
}
|
|
17
|
-
export function hasDeliveredProviderPendingCommands(registry) {
|
|
18
|
-
return [...registry.values()].some((command) => command.hostEpoch !== null);
|
|
19
|
-
}
|
|
20
|
-
export function isProviderPendingMessageStartup(registry, requestId) {
|
|
21
|
-
var _a;
|
|
22
|
-
return ((_a = registry.get(requestId)) === null || _a === void 0 ? void 0 : _a.isStartup) === true;
|
|
23
|
-
}
|
|
24
|
-
export function getProviderPendingCommandEntries(registry) {
|
|
25
|
-
return [...registry.entries()];
|
|
26
|
-
}
|
|
27
|
-
export function getProviderPendingCommands(registry) {
|
|
28
|
-
return [...registry.values()];
|
|
29
|
-
}
|
|
30
|
-
export function cancelProviderStartupCommands(registry) {
|
|
31
|
-
const commands = [];
|
|
32
|
-
const messageIds = new Set();
|
|
33
|
-
for (const [requestId, command] of registry) {
|
|
34
|
-
if (!command.isStartup) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
registry.delete(requestId);
|
|
38
|
-
commands.push(command);
|
|
39
|
-
messageIds.add(command.messageId);
|
|
40
|
-
}
|
|
41
|
-
return { commands, messageIds };
|
|
42
|
-
}
|
|
43
|
-
export function reissueProviderPendingCommand(registry, { nextMessageId, nextRequestId, nextResult, requestId, }) {
|
|
44
|
-
const command = registry.get(requestId);
|
|
45
|
-
if (!command || command.isStartup || command.hostEpoch === null) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
registry.delete(requestId);
|
|
49
|
-
const previousMessageId = command.messageId;
|
|
50
|
-
command.hostEpoch = null;
|
|
51
|
-
command.messageId = nextMessageId;
|
|
52
|
-
command.result = nextResult;
|
|
53
|
-
registry.set(nextRequestId, command);
|
|
54
|
-
return { command, previousMessageId };
|
|
55
|
-
}
|
|
56
|
-
export function clearProviderPendingCommands(registry) {
|
|
57
|
-
registry.clear();
|
|
58
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { WidgetFrameResolvedBorderRadius } from "@getuserfeedback/protocol/host";
|
|
2
|
-
type ProviderWidgetFrameSize = {
|
|
3
|
-
height: number;
|
|
4
|
-
width: number;
|
|
5
|
-
};
|
|
6
|
-
export declare function safeParseProviderWidgetCanonicalTopRadii(value: string): {
|
|
7
|
-
topLeft: number;
|
|
8
|
-
topRight: number;
|
|
9
|
-
} | undefined;
|
|
10
|
-
export declare function resolveProviderWidgetCanonicalBorderRadius(value: string, frameSize: ProviderWidgetFrameSize): WidgetFrameResolvedBorderRadius | undefined;
|
|
11
|
-
export {};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { safeParseNativeWidgetCanonicalRadii } from "./native-widget-corner-radii.js";
|
|
2
|
-
const CANONICAL_RADIUS_COMPONENT_PATTERN = /^((?:\d+(?:\.\d+)?|\.\d+))(px|%)$/;
|
|
3
|
-
export function safeParseProviderWidgetCanonicalTopRadii(value) {
|
|
4
|
-
if (value !== value.trim()) {
|
|
5
|
-
return undefined;
|
|
6
|
-
}
|
|
7
|
-
const radii = safeParseNativeWidgetCanonicalRadii(value);
|
|
8
|
-
return radii === undefined
|
|
9
|
-
? undefined
|
|
10
|
-
: { topLeft: radii.topLeft, topRight: radii.topRight };
|
|
11
|
-
}
|
|
12
|
-
const parseCanonicalRadiusComponent = (value) => {
|
|
13
|
-
var _a;
|
|
14
|
-
const match = CANONICAL_RADIUS_COMPONENT_PATTERN.exec(value);
|
|
15
|
-
if (match === null) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
const parsed = Number.parseFloat((_a = match[1]) !== null && _a !== void 0 ? _a : "");
|
|
19
|
-
const unit = match[2];
|
|
20
|
-
return Number.isFinite(parsed) && (unit === "px" || unit === "%")
|
|
21
|
-
? { unit, value: parsed }
|
|
22
|
-
: undefined;
|
|
23
|
-
};
|
|
24
|
-
const expandRadiusComponents = (values) => {
|
|
25
|
-
const [topLeft, topRight, bottomRight, bottomLeft] = values;
|
|
26
|
-
if (topLeft === undefined || values.length > 4) {
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
if (values.length === 1) {
|
|
30
|
-
return [topLeft, topLeft, topLeft, topLeft];
|
|
31
|
-
}
|
|
32
|
-
if (topRight === undefined) {
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
if (values.length === 2) {
|
|
36
|
-
return [topLeft, topRight, topLeft, topRight];
|
|
37
|
-
}
|
|
38
|
-
if (bottomRight === undefined) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
if (values.length === 3) {
|
|
42
|
-
return [topLeft, topRight, bottomRight, topRight];
|
|
43
|
-
}
|
|
44
|
-
return bottomLeft === undefined
|
|
45
|
-
? undefined
|
|
46
|
-
: [topLeft, topRight, bottomRight, bottomLeft];
|
|
47
|
-
};
|
|
48
|
-
const parseCanonicalRadiusComponents = (value) => {
|
|
49
|
-
const components = value
|
|
50
|
-
.trim()
|
|
51
|
-
.split(/\s+/)
|
|
52
|
-
.map(parseCanonicalRadiusComponent);
|
|
53
|
-
return components.some((component) => component === undefined)
|
|
54
|
-
? undefined
|
|
55
|
-
: expandRadiusComponents(components);
|
|
56
|
-
};
|
|
57
|
-
const resolveCanonicalRadiusComponent = (component, basis) => component.unit === "%" ? (component.value / 100) * basis : component.value;
|
|
58
|
-
const toRadiusOverlapRatio = (limit, first, second) => {
|
|
59
|
-
const max = Math.max(first, second);
|
|
60
|
-
return max === 0 ? 1 : limit / max / (first / max + second / max);
|
|
61
|
-
};
|
|
62
|
-
export function resolveProviderWidgetCanonicalBorderRadius(value, frameSize) {
|
|
63
|
-
var _a, _b, _c;
|
|
64
|
-
if (!Number.isFinite(frameSize.width) ||
|
|
65
|
-
frameSize.width < 0 ||
|
|
66
|
-
!Number.isFinite(frameSize.height) ||
|
|
67
|
-
frameSize.height < 0) {
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
const axes = value.split("/");
|
|
71
|
-
if (axes.length > 2) {
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
const horizontal = parseCanonicalRadiusComponents((_a = axes[0]) !== null && _a !== void 0 ? _a : "");
|
|
75
|
-
const vertical = parseCanonicalRadiusComponents((_c = (_b = axes[1]) !== null && _b !== void 0 ? _b : axes[0]) !== null && _c !== void 0 ? _c : "");
|
|
76
|
-
if (horizontal === undefined || vertical === undefined) {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
const resolveCorner = (index) => ({
|
|
80
|
-
horizontalPx: resolveCanonicalRadiusComponent(horizontal[index], frameSize.width),
|
|
81
|
-
verticalPx: resolveCanonicalRadiusComponent(vertical[index], frameSize.height),
|
|
82
|
-
});
|
|
83
|
-
const topLeft = resolveCorner(0);
|
|
84
|
-
const topRight = resolveCorner(1);
|
|
85
|
-
const bottomRight = resolveCorner(2);
|
|
86
|
-
const bottomLeft = resolveCorner(3);
|
|
87
|
-
if ([topLeft, topRight, bottomRight, bottomLeft].some((corner) => !Number.isFinite(corner.horizontalPx) ||
|
|
88
|
-
!Number.isFinite(corner.verticalPx))) {
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
const overlapScale = Math.min(1, toRadiusOverlapRatio(frameSize.width, topLeft.horizontalPx, topRight.horizontalPx), toRadiusOverlapRatio(frameSize.width, bottomLeft.horizontalPx, bottomRight.horizontalPx), toRadiusOverlapRatio(frameSize.height, topLeft.verticalPx, bottomLeft.verticalPx), toRadiusOverlapRatio(frameSize.height, topRight.verticalPx, bottomRight.verticalPx));
|
|
92
|
-
const scaleCorner = (corner) => ({
|
|
93
|
-
horizontalPx: corner.horizontalPx * overlapScale,
|
|
94
|
-
verticalPx: corner.verticalPx * overlapScale,
|
|
95
|
-
});
|
|
96
|
-
return {
|
|
97
|
-
topLeft: scaleCorner(topLeft),
|
|
98
|
-
topRight: scaleCorner(topRight),
|
|
99
|
-
bottomRight: scaleCorner(bottomRight),
|
|
100
|
-
bottomLeft: scaleCorner(bottomLeft),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { WidgetFrameAppearance } from "@getuserfeedback/protocol/host";
|
|
2
|
-
import { type NativeWidgetFrameBorderStyle } from "./native-widget-frame-border.js";
|
|
3
|
-
import { type NativeWidgetFrameShadowProjection } from "./native-widget-frame-shadow.js";
|
|
4
|
-
type ProviderWidgetFrameShadowProjection = NativeWidgetFrameShadowProjection | {
|
|
5
|
-
kind: "legacy";
|
|
6
|
-
};
|
|
7
|
-
export type ProviderWidgetFrameAppearanceProjection = {
|
|
8
|
-
borderStyle?: NativeWidgetFrameBorderStyle;
|
|
9
|
-
shadow: ProviderWidgetFrameShadowProjection;
|
|
10
|
-
topLeftRadius: number;
|
|
11
|
-
topRightRadius: number;
|
|
12
|
-
};
|
|
13
|
-
export declare function toProviderWidgetFrameAppearance(appearance?: WidgetFrameAppearance, nativeSheetSize?: {
|
|
14
|
-
height: number;
|
|
15
|
-
width: number;
|
|
16
|
-
}): ProviderWidgetFrameAppearanceProjection;
|
|
17
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { toNativeWidgetConservativeResolvedCornerRadii } from "./native-widget-corner-radii.js";
|
|
2
|
-
import { toNativeWidgetResolvedBorderStyle, } from "./native-widget-frame-border.js";
|
|
3
|
-
import { toNativeWidgetFrameShadow, } from "./native-widget-frame-shadow.js";
|
|
4
|
-
import { resolveProviderWidgetCanonicalBorderRadius, safeParseProviderWidgetCanonicalTopRadii, } from "./provider-widget-border-radius.js";
|
|
5
|
-
const LEGACY_WIDGET_SHEET_RADIUS = 24;
|
|
6
|
-
const toProviderWidgetConservativeResolvedTopRadii = (radius) => {
|
|
7
|
-
const resolved = toNativeWidgetConservativeResolvedCornerRadii(radius);
|
|
8
|
-
return { topLeft: resolved.topLeft, topRight: resolved.topRight };
|
|
9
|
-
};
|
|
10
|
-
export function toProviderWidgetFrameAppearance(appearance, nativeSheetSize) {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
if (appearance === undefined) {
|
|
13
|
-
return {
|
|
14
|
-
shadow: { kind: "legacy" },
|
|
15
|
-
topLeftRadius: LEGACY_WIDGET_SHEET_RADIUS,
|
|
16
|
-
topRightRadius: LEGACY_WIDGET_SHEET_RADIUS,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
if (appearance.kind === "none") {
|
|
20
|
-
return {
|
|
21
|
-
borderStyle: toNativeWidgetResolvedBorderStyle(),
|
|
22
|
-
shadow: toNativeWidgetFrameShadow(),
|
|
23
|
-
topLeftRadius: 0,
|
|
24
|
-
topRightRadius: 0,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
// Percentage radii depend on the host-owned sheet box, which can differ from
|
|
28
|
-
// the view's reported plan. Browser-only expressions keep the structured fallback.
|
|
29
|
-
const nativeResolvedRadius = nativeSheetSize === undefined || !appearance.borderRadius.includes("%")
|
|
30
|
-
? undefined
|
|
31
|
-
: resolveProviderWidgetCanonicalBorderRadius(appearance.borderRadius, nativeSheetSize);
|
|
32
|
-
const radius = nativeResolvedRadius !== undefined
|
|
33
|
-
? toProviderWidgetConservativeResolvedTopRadii(nativeResolvedRadius)
|
|
34
|
-
: appearance.resolvedBorderRadius === undefined
|
|
35
|
-
? safeParseProviderWidgetCanonicalTopRadii(appearance.borderRadius)
|
|
36
|
-
: toProviderWidgetConservativeResolvedTopRadii(appearance.resolvedBorderRadius);
|
|
37
|
-
return {
|
|
38
|
-
borderStyle: toNativeWidgetResolvedBorderStyle(appearance.resolvedBorder),
|
|
39
|
-
shadow: toNativeWidgetFrameShadow(appearance.resolvedBoxShadow),
|
|
40
|
-
topLeftRadius: (_a = radius === null || radius === void 0 ? void 0 : radius.topLeft) !== null && _a !== void 0 ? _a : 0,
|
|
41
|
-
topRightRadius: (_b = radius === null || radius === void 0 ? void 0 : radius.topRight) !== null && _b !== void 0 ? _b : 0,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { type InstanceViewHostSnapshotsChangedDetail, type ViewHostSnapshot, type WidgetFrameAppearance, type WidgetLayoutTransitionPolicy, type WidgetLayoutTransitionSchedule } from "@getuserfeedback/protocol/host";
|
|
2
|
-
type ProviderWidgetHostReadyState = {
|
|
3
|
-
hostEpoch: number;
|
|
4
|
-
readySequence: number;
|
|
5
|
-
sourceKey: string;
|
|
6
|
-
};
|
|
7
|
-
export type ProviderWidgetHostVisibility = {
|
|
8
|
-
frameAppearance?: WidgetFrameAppearance;
|
|
9
|
-
flowHeight?: number;
|
|
10
|
-
flowHandleId?: string;
|
|
11
|
-
hostSourceVersion: number | null;
|
|
12
|
-
isVisible: boolean;
|
|
13
|
-
readySequence: number | null;
|
|
14
|
-
sourceKey: string | null;
|
|
15
|
-
transitionPolicy?: WidgetLayoutTransitionPolicy;
|
|
16
|
-
transitionSchedule?: WidgetLayoutTransitionSchedule;
|
|
17
|
-
transitionPolicySequence?: number;
|
|
18
|
-
};
|
|
19
|
-
export declare const HIDDEN_PROVIDER_WIDGET_HOST_VISIBILITY: ProviderWidgetHostVisibility;
|
|
20
|
-
export type ProviderWidgetHostLifecycleController = {
|
|
21
|
-
clearFlowHandleFromVisibility: (visibility: ProviderWidgetHostVisibility, flowHandleId: string) => ProviderWidgetHostVisibility;
|
|
22
|
-
getCurrentHostEpoch: () => number | null;
|
|
23
|
-
getViewHostSnapshots: () => readonly ViewHostSnapshot[];
|
|
24
|
-
isWidgetHostVisible: (visibility: ProviderWidgetHostVisibility, hasSheetHostViewport: boolean) => boolean;
|
|
25
|
-
markNotReady: () => {
|
|
26
|
-
wasReady: boolean;
|
|
27
|
-
};
|
|
28
|
-
markReady: (event: {
|
|
29
|
-
readySequence: number;
|
|
30
|
-
sourceKey: string;
|
|
31
|
-
}, options: {
|
|
32
|
-
hasDeliveredPendingCommands: boolean;
|
|
33
|
-
}) => {
|
|
34
|
-
alreadySeen: boolean;
|
|
35
|
-
didResetHostEpoch: boolean;
|
|
36
|
-
previousReady: ProviderWidgetHostReadyState | null;
|
|
37
|
-
};
|
|
38
|
-
replaceViewHostSnapshots: (detail: InstanceViewHostSnapshotsChangedDetail, instanceId: string) => ProviderWidgetHostVisibility | null;
|
|
39
|
-
syncHostSourceKey: (hostSourceKey: string) => boolean;
|
|
40
|
-
toReadyVisibility: (visibility: ProviderWidgetHostVisibility, event: {
|
|
41
|
-
readySequence: number;
|
|
42
|
-
sourceKey: string;
|
|
43
|
-
}) => ProviderWidgetHostVisibility;
|
|
44
|
-
};
|
|
45
|
-
export declare function createProviderWidgetHostLifecycleController(initialHostSourceKey: string): ProviderWidgetHostLifecycleController;
|
|
46
|
-
export {};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { areViewHostSnapshotsEqual, } from "@getuserfeedback/protocol/host";
|
|
2
|
-
import { createActiveViewSnapshotListController } from "./view-orchestration-runtime.js";
|
|
3
|
-
export const HIDDEN_PROVIDER_WIDGET_HOST_VISIBILITY = {
|
|
4
|
-
hostSourceVersion: null,
|
|
5
|
-
isVisible: false,
|
|
6
|
-
readySequence: null,
|
|
7
|
-
sourceKey: null,
|
|
8
|
-
};
|
|
9
|
-
export function createProviderWidgetHostLifecycleController(initialHostSourceKey) {
|
|
10
|
-
let hostEpoch = 0;
|
|
11
|
-
let hostSourceKey = initialHostSourceKey;
|
|
12
|
-
let hostSourceVersion = 0;
|
|
13
|
-
let lastReady = null;
|
|
14
|
-
let transitionPolicySequence = 0;
|
|
15
|
-
let lastTransitionScheduleSequence;
|
|
16
|
-
const viewHostSnapshots = createActiveViewSnapshotListController();
|
|
17
|
-
let selectedViewHostSnapshot;
|
|
18
|
-
const toVisibility = (snapshot) => {
|
|
19
|
-
var _a;
|
|
20
|
-
if (lastReady === null) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
let nextTransitionPolicySequence;
|
|
24
|
-
const hasNewTransitionSchedule = snapshot.transitionSchedule !== undefined &&
|
|
25
|
-
(lastTransitionScheduleSequence === undefined ||
|
|
26
|
-
snapshot.transitionSchedule.sequence > lastTransitionScheduleSequence);
|
|
27
|
-
if (snapshot.transitionPolicy !== undefined &&
|
|
28
|
-
(snapshot.transitionSchedule === undefined || hasNewTransitionSchedule)) {
|
|
29
|
-
transitionPolicySequence += 1;
|
|
30
|
-
nextTransitionPolicySequence = transitionPolicySequence;
|
|
31
|
-
}
|
|
32
|
-
if (hasNewTransitionSchedule) {
|
|
33
|
-
lastTransitionScheduleSequence = (_a = snapshot.transitionSchedule) === null || _a === void 0 ? void 0 : _a.sequence;
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
frameAppearance: snapshot.frameAppearance,
|
|
37
|
-
flowHeight: snapshot.height,
|
|
38
|
-
flowHandleId: snapshot.flowHandleId,
|
|
39
|
-
hostSourceVersion,
|
|
40
|
-
isVisible: snapshot.shouldRender,
|
|
41
|
-
readySequence: lastReady.readySequence,
|
|
42
|
-
sourceKey: lastReady.sourceKey,
|
|
43
|
-
transitionPolicy: nextTransitionPolicySequence === undefined
|
|
44
|
-
? undefined
|
|
45
|
-
: snapshot.transitionPolicy,
|
|
46
|
-
transitionSchedule: hasNewTransitionSchedule
|
|
47
|
-
? snapshot.transitionSchedule
|
|
48
|
-
: undefined,
|
|
49
|
-
transitionPolicySequence: nextTransitionPolicySequence,
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
clearFlowHandleFromVisibility: (visibility, flowHandleId) => visibility.flowHandleId === flowHandleId
|
|
54
|
-
? Object.assign(Object.assign({}, visibility), { flowHandleId: undefined }) : visibility,
|
|
55
|
-
getCurrentHostEpoch: () => { var _a; return (_a = lastReady === null || lastReady === void 0 ? void 0 : lastReady.hostEpoch) !== null && _a !== void 0 ? _a : null; },
|
|
56
|
-
getViewHostSnapshots: () => viewHostSnapshots.getSnapshots(),
|
|
57
|
-
isWidgetHostVisible: (visibility, hasSheetHostViewport) => visibility.isVisible &&
|
|
58
|
-
hasSheetHostViewport &&
|
|
59
|
-
visibility.hostSourceVersion === hostSourceVersion &&
|
|
60
|
-
visibility.sourceKey === (lastReady === null || lastReady === void 0 ? void 0 : lastReady.sourceKey) &&
|
|
61
|
-
visibility.readySequence === (lastReady === null || lastReady === void 0 ? void 0 : lastReady.readySequence),
|
|
62
|
-
markNotReady: () => {
|
|
63
|
-
const wasReady = lastReady !== null;
|
|
64
|
-
if (wasReady) {
|
|
65
|
-
hostEpoch += 1;
|
|
66
|
-
}
|
|
67
|
-
lastReady = null;
|
|
68
|
-
viewHostSnapshots.clear();
|
|
69
|
-
selectedViewHostSnapshot = undefined;
|
|
70
|
-
lastTransitionScheduleSequence = undefined;
|
|
71
|
-
return { wasReady };
|
|
72
|
-
},
|
|
73
|
-
markReady: (event, { hasDeliveredPendingCommands }) => {
|
|
74
|
-
const previousReady = lastReady;
|
|
75
|
-
const alreadySeen = (previousReady === null || previousReady === void 0 ? void 0 : previousReady.sourceKey) === event.sourceKey &&
|
|
76
|
-
previousReady.readySequence === event.readySequence;
|
|
77
|
-
if (alreadySeen) {
|
|
78
|
-
return {
|
|
79
|
-
alreadySeen: true,
|
|
80
|
-
didResetHostEpoch: false,
|
|
81
|
-
previousReady,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
const didResetHostEpoch = previousReady !== null || hasDeliveredPendingCommands;
|
|
85
|
-
if (didResetHostEpoch) {
|
|
86
|
-
hostEpoch += 1;
|
|
87
|
-
viewHostSnapshots.clear();
|
|
88
|
-
selectedViewHostSnapshot = undefined;
|
|
89
|
-
lastTransitionScheduleSequence = undefined;
|
|
90
|
-
}
|
|
91
|
-
lastReady = Object.assign(Object.assign({}, event), { hostEpoch });
|
|
92
|
-
return {
|
|
93
|
-
alreadySeen: false,
|
|
94
|
-
didResetHostEpoch,
|
|
95
|
-
previousReady,
|
|
96
|
-
};
|
|
97
|
-
},
|
|
98
|
-
replaceViewHostSnapshots: (detail, instanceId) => {
|
|
99
|
-
if (detail.instanceId !== instanceId || lastReady === null) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
viewHostSnapshots.replace(detail.snapshots);
|
|
103
|
-
const nextSelectedSnapshot = viewHostSnapshots.getSnapshots()[0];
|
|
104
|
-
if (areViewHostSnapshotsEqual(selectedViewHostSnapshot, nextSelectedSnapshot)) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
selectedViewHostSnapshot = nextSelectedSnapshot;
|
|
108
|
-
if (!nextSelectedSnapshot) {
|
|
109
|
-
return toVisibility({
|
|
110
|
-
isLoading: false,
|
|
111
|
-
isOpen: false,
|
|
112
|
-
shouldRender: false,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return toVisibility(Object.assign(Object.assign({}, nextSelectedSnapshot), { shouldRender: true }));
|
|
116
|
-
},
|
|
117
|
-
syncHostSourceKey: (nextHostSourceKey) => {
|
|
118
|
-
if (hostSourceKey === nextHostSourceKey) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
hostSourceKey = nextHostSourceKey;
|
|
122
|
-
hostSourceVersion += 1;
|
|
123
|
-
lastReady = null;
|
|
124
|
-
viewHostSnapshots.clear();
|
|
125
|
-
selectedViewHostSnapshot = undefined;
|
|
126
|
-
lastTransitionScheduleSequence = undefined;
|
|
127
|
-
return true;
|
|
128
|
-
},
|
|
129
|
-
toReadyVisibility: (visibility, event) => {
|
|
130
|
-
if (!visibility.isVisible ||
|
|
131
|
-
visibility.sourceKey !== event.sourceKey ||
|
|
132
|
-
visibility.hostSourceVersion !== hostSourceVersion) {
|
|
133
|
-
return visibility;
|
|
134
|
-
}
|
|
135
|
-
return Object.assign(Object.assign({}, visibility), { readySequence: event.readySequence });
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
}
|