react-native-roku 0.0.0-stage → 0.2.0-preview.1
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 +318 -0
- package/CONTRIBUTING.md +34 -0
- package/LICENSE +21 -0
- package/NOTICE.md +10 -0
- package/README.md +66 -2
- package/bin/react-native-roku.mjs +91 -0
- package/build/assets.cjs +311 -0
- package/build/assets.d.cts +50 -0
- package/build/compatibility.d.mts +40 -0
- package/build/compatibility.mjs +272 -0
- package/build/dev.d.mts +34 -0
- package/build/dev.mjs +297 -0
- package/build/devWorkspace.d.mts +11 -0
- package/build/devWorkspace.mjs +86 -0
- package/build/device.d.mts +47 -0
- package/build/device.mjs +310 -0
- package/build/environment.d.mts +29 -0
- package/build/environment.mjs +144 -0
- package/build/esbuild.d.mts +5 -0
- package/build/esbuild.mjs +118 -0
- package/build/fontVariants.d.mts +27 -0
- package/build/fontVariants.mjs +424 -0
- package/build/frontend.d.mts +52 -0
- package/build/frontend.mjs +75 -0
- package/build/identity.mjs +45 -0
- package/build/index.d.mts +22 -0
- package/build/index.mjs +87 -0
- package/build/intl.mjs +121 -0
- package/build/metro.cjs +38 -0
- package/build/metro.d.cts +37 -0
- package/build/metroFrontend.mjs +222 -0
- package/build/metroMetadata.mjs +119 -0
- package/build/metroModules.mjs +397 -0
- package/build/metroRefresh.d.mts +64 -0
- package/build/metroRefresh.mjs +346 -0
- package/build/metroTransformer.cjs +146 -0
- package/build/nativeTextMemo.mjs +296 -0
- package/build/nativewind.d.mts +9 -0
- package/build/nativewind.mjs +92 -0
- package/build/project.d.mts +111 -0
- package/build/project.mjs +615 -0
- package/build/reactCompiler.mjs +113 -0
- package/build/reactProfile.cjs +35 -0
- package/build/refreshRuntime.mjs +187 -0
- package/build/refreshSourceMap.mjs +53 -0
- package/build/release.mjs +99 -0
- package/build/resolution.d.mts +3 -0
- package/build/resolution.mjs +25 -0
- package/build/surfaces.d.mts +1 -0
- package/build/surfaces.mjs +42 -0
- package/build/testing/node.d.mts +29 -0
- package/build/testing/node.mjs +106 -0
- package/build/yoga.d.mts +8 -0
- package/build/yoga.mjs +186 -0
- package/compatibility/public-api.json +327 -0
- package/compatibility/registry.json +2258 -0
- package/config/release.json +15 -0
- package/config/toolchain.json +34 -0
- package/docs/compatibility.md +813 -0
- package/docs/getting-started.md +460 -0
- package/docs/maintenance.md +362 -0
- package/docs/qualification.md +241 -0
- package/docs/standalone-testing.md +56 -0
- package/examples/hello-roku/README.md +35 -0
- package/examples/hello-roku/package.template.json +31 -0
- package/examples/hello-roku/pnpm-workspace.yaml +11 -0
- package/examples/hello-roku/roku.config.json +22 -0
- package/examples/hello-roku/src/App.tsx +54 -0
- package/examples/hello-roku/src/Catalog.tsx +200 -0
- package/examples/hello-roku/src/assets.d.ts +16 -0
- package/examples/hello-roku/src/catalog-cover.png +0 -0
- package/examples/hello-roku/tsconfig.json +1 -0
- package/examples/hello-roku/tsconfig.react.json +1 -0
- package/native/components/RNRAppControl.brs +215 -0
- package/native/components/RNRAppControl.xml +13 -0
- package/native/components/RNRDeviceFacts.brs +19 -0
- package/native/components/RNRDeviceFacts.xml +9 -0
- package/native/components/RNRDeviceFactsTask.brs +74 -0
- package/native/components/RNRDeviceFactsTask.xml +9 -0
- package/native/components/RNRTextRaster.brs +15 -0
- package/native/components/RNRTextRaster.xml +9 -0
- package/native/components/RNRTextRasterTask.brs +77 -0
- package/native/components/RNRTextRasterTask.xml +9 -0
- package/native/manifest.json +7 -0
- package/package.json +183 -3
- package/src/animation/clock.ts +10 -0
- package/src/animation/derivedValue.ts +163 -0
- package/src/animation/legacyAnimated.ts +255 -0
- package/src/animation/reanimated.ts +243 -0
- package/src/animation/sharedValue.ts +285 -0
- package/src/animation/worklets.ts +23 -0
- package/src/application/AppRegistry.ts +31 -0
- package/src/application/mountApplication.ts +136 -0
- package/src/graphics/BitmapLayer.tsx +68 -0
- package/src/graphics/RoundedBorder.tsx +116 -0
- package/src/graphics/TextRasterCache.ts +259 -0
- package/src/graphics/gradient.ts +37 -0
- package/src/graphics/inlineRaster.ts +85 -0
- package/src/graphics/png.ts +77 -0
- package/src/graphics/rasterPixels.ts +89 -0
- package/src/graphics/surfaces.ts +105 -0
- package/src/graphics/textRaster.types.ts +60 -0
- package/src/graphics/textRasterGeometry.ts +116 -0
- package/src/host/host.types.ts +57 -0
- package/src/index.ts +22 -0
- package/src/interop/nativewind.ts +2 -0
- package/src/layout/FontResources.ts +252 -0
- package/src/layout/affine.ts +89 -0
- package/src/layout/flexLayout.ts +398 -0
- package/src/layout/fontFaces.d.mts +19 -0
- package/src/layout/fontFaces.mjs +85 -0
- package/src/layout/fontVariants.d.mts +2 -0
- package/src/layout/fontVariants.mjs +8 -0
- package/src/layout/inlineParagraph.ts +158 -0
- package/src/layout/inlineText.ts +68 -0
- package/src/layout/layoutReuse.ts +117 -0
- package/src/layout/nativeNodeFields.ts +179 -0
- package/src/layout/preparedFields.ts +78 -0
- package/src/layout/textLayout.ts +138 -0
- package/src/layout/transform.ts +113 -0
- package/src/media/SceneGraphAudio.ts +161 -0
- package/src/media/SceneGraphVideo.ts +167 -0
- package/src/media/audioSession.ts +84 -0
- package/src/media/index.ts +2 -0
- package/src/media/videoErrorDetails.ts +40 -0
- package/src/media/videoSession.ts +136 -0
- package/src/navigation/RouterStore.ts +244 -0
- package/src/navigation/expoRouter.ts +115 -0
- package/src/react-native/NativeInput.ts +494 -0
- package/src/react-native/NativeSystemState.ts +95 -0
- package/src/react-native/accessibility.ts +265 -0
- package/src/react-native/activityIndicator.ts +72 -0
- package/src/react-native/compilerPressable.ts +26 -0
- package/src/react-native/createNativeRoot.ts +2126 -0
- package/src/react-native/directionalFocus.ts +55 -0
- package/src/react-native/environment.ts +275 -0
- package/src/react-native/flatList.ts +1001 -0
- package/src/react-native/flatListViewability.ts +231 -0
- package/src/react-native/focusEvents.ts +85 -0
- package/src/react-native/image.ts +247 -0
- package/src/react-native/index.ts +54 -0
- package/src/react-native/interactionManager.ts +76 -0
- package/src/react-native/keyboard.ts +60 -0
- package/src/react-native/linearGradient.ts +94 -0
- package/src/react-native/modal.tsx +148 -0
- package/src/react-native/nativeHostContext.ts +80 -0
- package/src/react-native/nativeModules.ts +86 -0
- package/src/react-native/nativeRoot.types.ts +22 -0
- package/src/react-native/nativeViewHandle.ts +191 -0
- package/src/react-native/nativewindPressable.ts +38 -0
- package/src/react-native/panResponder.ts +73 -0
- package/src/react-native/primitives.ts +685 -0
- package/src/react-native/safeArea.ts +76 -0
- package/src/react-native/scrollView.ts +289 -0
- package/src/react-native/styleInterop.ts +8 -0
- package/src/react-native/styleSheet.ts +54 -0
- package/src/react-native/textInput.ts +334 -0
- package/src/react-native/unsupported.ts +25 -0
- package/src/renderer/SceneRoot.ts +1006 -0
- package/src/scene/SdkDeviceFacts.ts +151 -0
- package/src/scene/SdkDeviceServices.ts +72 -0
- package/src/scene/SdkSceneGraph.ts +124 -0
- package/src/scene/SdkTextEntry.ts +321 -0
- package/src/scene/SdkTextMetrics.ts +136 -0
- package/src/scene/SdkTextRasterTransport.ts +191 -0
- package/src/scene/SdkWebTransport.ts +122 -0
- package/src/scene/createRokuHost.ts +213 -0
- package/src/scene/sceneGraph.types.ts +38 -0
- package/src/services/DeviceServices.ts +53 -0
- package/src/services/RegistryStorage.ts +85 -0
- package/src/services/RokuKeySession.ts +29 -0
- package/src/services/asyncStorage.ts +23 -0
- package/src/services/base64.ts +52 -0
- package/src/services/crypto.ts +18 -0
- package/src/services/expoConstants.ts +11 -0
- package/src/services/expoLinking.ts +12 -0
- package/src/services/expoStatusBar.ts +4 -0
- package/src/services/installWebRuntime.ts +105 -0
- package/src/services/intlEnglish.ts +54 -0
- package/src/services/languageRuntime.ts +65 -0
- package/src/services/nativeTimers.ts +96 -0
- package/src/services/secureStore.ts +23 -0
- package/src/services/textEntryRequest.ts +22 -0
- package/src/services/utf8.ts +57 -0
- package/src/services/webRuntime.ts +346 -0
- package/src/testing/CanvasResources.ts +141 -0
- package/src/testing/CanvasSceneGraph.ts +496 -0
- package/src/testing/CanvasTextEntry.ts +237 -0
- package/src/testing/PreviewTextObservations.ts +82 -0
- package/src/testing/RecordingSceneGraph.ts +136 -0
- package/src/types/normalize-colors.d.ts +4 -0
- package/src/vector/dynamicSvg.tsx +226 -0
- package/src/vector/svg.ts +222 -0
- package/src/vector/svg.types.ts +4 -0
- package/src/vector/svgElements.ts +58 -0
- package/src/vector/svgKey.d.mts +4 -0
- package/src/vector/svgKey.mjs +16 -0
- package/src/vector/svgPath.ts +157 -0
- package/src/vector/svgPixels.ts +133 -0
- package/tsconfig.consumer.json +29 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/** One normalization owner for the RN/ARIA aliases used by all host primitives.
|
|
2
|
+
* These are host semantics, never invented SceneGraph node fields. */
|
|
3
|
+
export interface AccessibilityProps {
|
|
4
|
+
readonly role?: string;
|
|
5
|
+
readonly accessible?: boolean;
|
|
6
|
+
readonly accessibilityRole?: string;
|
|
7
|
+
readonly accessibilityLabel?: string;
|
|
8
|
+
readonly accessibilityHint?: string;
|
|
9
|
+
readonly accessibilityLabelledBy?: string | readonly string[];
|
|
10
|
+
readonly accessibilityState?: {
|
|
11
|
+
readonly disabled?: boolean;
|
|
12
|
+
readonly selected?: boolean;
|
|
13
|
+
readonly checked?: boolean | "mixed";
|
|
14
|
+
readonly busy?: boolean;
|
|
15
|
+
readonly expanded?: boolean;
|
|
16
|
+
};
|
|
17
|
+
readonly accessibilityValue?: {
|
|
18
|
+
readonly min?: number;
|
|
19
|
+
readonly max?: number;
|
|
20
|
+
readonly now?: number;
|
|
21
|
+
readonly text?: string;
|
|
22
|
+
};
|
|
23
|
+
readonly accessibilityLiveRegion?: "none" | "polite" | "assertive";
|
|
24
|
+
readonly accessibilityViewIsModal?: boolean;
|
|
25
|
+
readonly accessibilityElementsHidden?: boolean;
|
|
26
|
+
readonly importantForAccessibility?: string;
|
|
27
|
+
readonly "aria-label"?: string;
|
|
28
|
+
readonly "aria-labelledby"?: string;
|
|
29
|
+
readonly "aria-describedby"?: string;
|
|
30
|
+
readonly "aria-hidden"?: boolean;
|
|
31
|
+
readonly "aria-modal"?: boolean;
|
|
32
|
+
readonly "aria-live"?: "off" | "polite" | "assertive";
|
|
33
|
+
readonly "aria-disabled"?: boolean;
|
|
34
|
+
readonly "aria-selected"?: boolean;
|
|
35
|
+
readonly "aria-checked"?: boolean | "mixed";
|
|
36
|
+
readonly "aria-pressed"?: boolean | "mixed";
|
|
37
|
+
readonly "aria-busy"?: boolean;
|
|
38
|
+
readonly "aria-expanded"?: boolean;
|
|
39
|
+
readonly "aria-valuemin"?: number;
|
|
40
|
+
readonly "aria-valuemax"?: number;
|
|
41
|
+
readonly "aria-valuenow"?: number;
|
|
42
|
+
readonly "aria-valuetext"?: string;
|
|
43
|
+
readonly "aria-current"?: boolean | string;
|
|
44
|
+
readonly "aria-invalid"?: boolean | string;
|
|
45
|
+
readonly "aria-haspopup"?: boolean | string;
|
|
46
|
+
readonly "aria-roledescription"?: string;
|
|
47
|
+
readonly "aria-level"?: number;
|
|
48
|
+
readonly "aria-orientation"?: "horizontal" | "vertical";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type CurrentKind = "page" | "step" | "location" | "date" | "time";
|
|
52
|
+
type PopupKind = "menu" | "listbox" | "tree" | "grid" | "dialog";
|
|
53
|
+
const currentKinds = new Set<string>(["page", "step", "location", "date", "time"]);
|
|
54
|
+
const popupKinds = new Set<string>(["menu", "listbox", "tree", "grid", "dialog"]);
|
|
55
|
+
// Concrete RN/ARIA roles admitted by this host. A description changes speech,
|
|
56
|
+
// never the underlying role or the control's focus/input behavior.
|
|
57
|
+
const describedRoles = new Set(
|
|
58
|
+
`alert alertdialog application article banner blockquote button caption cell checkbox code
|
|
59
|
+
columnheader combobox complementary contentinfo definition deletion dialog directory document
|
|
60
|
+
emphasis feed figure form grid gridcell group heading img insertion link list listbox listitem
|
|
61
|
+
log main marquee math menu menubar menuitem menuitemcheckbox menuitemradio meter navigation note
|
|
62
|
+
option paragraph progressbar radio radiogroup region row rowgroup rowheader scrollbar search
|
|
63
|
+
searchbox separator slider spinbutton status strong subscript superscript switch tab table
|
|
64
|
+
tablist tabpanel term time timer toolbar tooltip tree treegrid treeitem
|
|
65
|
+
adjustable dropdownlist header image imagebutton keyboardkey summary tabbar text togglebutton`.split(
|
|
66
|
+
/\s+/,
|
|
67
|
+
),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
function currentState(value: unknown): boolean | CurrentKind | undefined {
|
|
71
|
+
if (typeof value === "boolean") return value;
|
|
72
|
+
if (typeof value !== "string") return undefined;
|
|
73
|
+
if (value === "" || value === "false") return false;
|
|
74
|
+
return currentKinds.has(value) ? (value as CurrentKind) : true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function invalidState(value: unknown): boolean | "grammar" | "spelling" | undefined {
|
|
78
|
+
if (typeof value === "boolean") return value;
|
|
79
|
+
if (typeof value !== "string") return undefined;
|
|
80
|
+
if (value === "" || value === "false") return false;
|
|
81
|
+
return value === "grammar" || value === "spelling" ? value : true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function popupKind(value: unknown): PopupKind | false | undefined {
|
|
85
|
+
if (value == null) return undefined;
|
|
86
|
+
if (value === true || value === "true") return "menu";
|
|
87
|
+
return typeof value === "string" && popupKinds.has(value) ? (value as PopupKind) : false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface AccessibilitySemantics {
|
|
91
|
+
readonly role?: string;
|
|
92
|
+
readonly roleDescription?: string;
|
|
93
|
+
readonly level?: number;
|
|
94
|
+
readonly orientation?: "horizontal" | "vertical";
|
|
95
|
+
readonly popup?: PopupKind | false;
|
|
96
|
+
readonly label?: string;
|
|
97
|
+
readonly hint?: string;
|
|
98
|
+
readonly labelledBy: readonly string[];
|
|
99
|
+
readonly describedBy: readonly string[];
|
|
100
|
+
readonly state: NonNullable<AccessibilityProps["accessibilityState"]> & {
|
|
101
|
+
readonly pressed?: boolean | "mixed";
|
|
102
|
+
readonly current?: boolean | CurrentKind;
|
|
103
|
+
readonly invalid?: boolean | "grammar" | "spelling";
|
|
104
|
+
};
|
|
105
|
+
readonly value: NonNullable<AccessibilityProps["accessibilityValue"]>;
|
|
106
|
+
readonly live: "none" | "polite" | "assertive";
|
|
107
|
+
readonly modal: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const emptyReferences: readonly string[] = Object.freeze([]);
|
|
111
|
+
const emptyState: AccessibilitySemantics["state"] = Object.freeze({
|
|
112
|
+
busy: undefined,
|
|
113
|
+
checked: undefined,
|
|
114
|
+
disabled: undefined,
|
|
115
|
+
expanded: undefined,
|
|
116
|
+
selected: undefined,
|
|
117
|
+
pressed: undefined,
|
|
118
|
+
current: undefined,
|
|
119
|
+
invalid: undefined,
|
|
120
|
+
});
|
|
121
|
+
const emptyValue: AccessibilitySemantics["value"] = Object.freeze({
|
|
122
|
+
min: undefined,
|
|
123
|
+
max: undefined,
|
|
124
|
+
now: undefined,
|
|
125
|
+
text: undefined,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export function normalizeAccessibility(
|
|
129
|
+
props: AccessibilityProps,
|
|
130
|
+
disabled?: boolean,
|
|
131
|
+
): AccessibilitySemantics {
|
|
132
|
+
const role = props.role ?? props.accessibilityRole;
|
|
133
|
+
// ARIA IDREF lists use HTML whitespace, not commas. The RN alias supplies
|
|
134
|
+
// explicit native identities (a string is one ID); never tokenize that alias.
|
|
135
|
+
const labelledBy =
|
|
136
|
+
props["aria-labelledby"]?.split(/[\t\n\f\r ]+/).filter(Boolean) ??
|
|
137
|
+
props.accessibilityLabelledBy;
|
|
138
|
+
const live = props["aria-live"];
|
|
139
|
+
const description = props["aria-roledescription"];
|
|
140
|
+
const level = props["aria-level"];
|
|
141
|
+
const orientation = props["aria-orientation"];
|
|
142
|
+
const state = props.accessibilityState;
|
|
143
|
+
const busy = props["aria-busy"] ?? state?.busy;
|
|
144
|
+
const checked = props["aria-checked"] ?? state?.checked;
|
|
145
|
+
const inactive = disabled ?? props["aria-disabled"] ?? state?.disabled;
|
|
146
|
+
const expanded = props["aria-expanded"] ?? state?.expanded;
|
|
147
|
+
const selected = props["aria-selected"] ?? state?.selected;
|
|
148
|
+
const pressed = props["aria-pressed"];
|
|
149
|
+
const current = currentState(props["aria-current"]);
|
|
150
|
+
const invalid = invalidState(props["aria-invalid"]);
|
|
151
|
+
const value = props.accessibilityValue;
|
|
152
|
+
const min = props["aria-valuemin"] ?? value?.min;
|
|
153
|
+
const max = props["aria-valuemax"] ?? value?.max;
|
|
154
|
+
const now = props["aria-valuenow"] ?? value?.now;
|
|
155
|
+
const text = props["aria-valuetext"] ?? value?.text;
|
|
156
|
+
return Object.freeze({
|
|
157
|
+
role,
|
|
158
|
+
roleDescription:
|
|
159
|
+
role && describedRoles.has(role) && typeof description === "string"
|
|
160
|
+
? description.trim() || undefined
|
|
161
|
+
: undefined,
|
|
162
|
+
level:
|
|
163
|
+
typeof level === "number" && Number.isSafeInteger(level) && level > 0 ? level : undefined,
|
|
164
|
+
orientation:
|
|
165
|
+
orientation === "horizontal" || orientation === "vertical" ? orientation : undefined,
|
|
166
|
+
popup: popupKind(props["aria-haspopup"]),
|
|
167
|
+
label: props["aria-label"] ?? props.accessibilityLabel,
|
|
168
|
+
hint: props.accessibilityHint,
|
|
169
|
+
labelledBy:
|
|
170
|
+
labelledBy == null
|
|
171
|
+
? emptyReferences
|
|
172
|
+
: Object.freeze(typeof labelledBy === "string" ? [labelledBy] : [...labelledBy]),
|
|
173
|
+
describedBy:
|
|
174
|
+
props["aria-describedby"] == null
|
|
175
|
+
? emptyReferences
|
|
176
|
+
: Object.freeze(props["aria-describedby"].split(/[\t\n\f\r ]+/).filter(Boolean)),
|
|
177
|
+
state:
|
|
178
|
+
busy === undefined &&
|
|
179
|
+
checked === undefined &&
|
|
180
|
+
inactive === undefined &&
|
|
181
|
+
expanded === undefined &&
|
|
182
|
+
selected === undefined &&
|
|
183
|
+
pressed === undefined &&
|
|
184
|
+
current === undefined &&
|
|
185
|
+
invalid === undefined
|
|
186
|
+
? emptyState
|
|
187
|
+
: Object.freeze({
|
|
188
|
+
busy,
|
|
189
|
+
checked,
|
|
190
|
+
disabled: inactive,
|
|
191
|
+
expanded,
|
|
192
|
+
selected,
|
|
193
|
+
pressed,
|
|
194
|
+
current,
|
|
195
|
+
invalid,
|
|
196
|
+
}),
|
|
197
|
+
value:
|
|
198
|
+
min === undefined && max === undefined && now === undefined && text === undefined
|
|
199
|
+
? emptyValue
|
|
200
|
+
: Object.freeze({ min, max, now, text }),
|
|
201
|
+
live:
|
|
202
|
+
live === "off"
|
|
203
|
+
? "none"
|
|
204
|
+
: (live ??
|
|
205
|
+
props.accessibilityLiveRegion ??
|
|
206
|
+
(role === "alert" ? "assertive" : role === "status" ? "polite" : "none")),
|
|
207
|
+
modal: props["aria-modal"] ?? props.accessibilityViewIsModal ?? false,
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** English speech profile over the documented Audio Guide service. Structural
|
|
212
|
+
* roles remain in the committed semantics; firmware speech needs device review. */
|
|
213
|
+
export function accessibilitySpeech(semantics: AccessibilitySemantics, fallbackLabel = ""): string {
|
|
214
|
+
const { role, state, value } = semantics;
|
|
215
|
+
if (role === "none" || role === "presentation") return "";
|
|
216
|
+
const words = [semantics.label ?? fallbackLabel];
|
|
217
|
+
if (role)
|
|
218
|
+
words.push(
|
|
219
|
+
semantics.roleDescription ??
|
|
220
|
+
(
|
|
221
|
+
{
|
|
222
|
+
img: "image",
|
|
223
|
+
header: "heading",
|
|
224
|
+
adjustable: "slider",
|
|
225
|
+
progressbar: "progress",
|
|
226
|
+
combobox: "combo box",
|
|
227
|
+
} as Record<string, string>
|
|
228
|
+
)[role] ??
|
|
229
|
+
role,
|
|
230
|
+
);
|
|
231
|
+
if (semantics.level !== undefined) words.push(`level ${semantics.level}`);
|
|
232
|
+
if (semantics.orientation) words.push(semantics.orientation);
|
|
233
|
+
if (state.checked !== undefined)
|
|
234
|
+
words.push(state.checked === "mixed" ? "mixed" : state.checked ? "checked" : "not checked");
|
|
235
|
+
if (state.pressed !== undefined)
|
|
236
|
+
words.push(state.pressed === "mixed" ? "mixed" : state.pressed ? "pressed" : "not pressed");
|
|
237
|
+
if (state.selected) words.push("selected");
|
|
238
|
+
if (state.expanded !== undefined) words.push(state.expanded ? "expanded" : "collapsed");
|
|
239
|
+
if (state.disabled) words.push("disabled");
|
|
240
|
+
if (state.busy) words.push("busy");
|
|
241
|
+
if (state.current) words.push(state.current === true ? "current" : `current ${state.current}`);
|
|
242
|
+
if (state.invalid)
|
|
243
|
+
words.push(
|
|
244
|
+
state.invalid === "grammar"
|
|
245
|
+
? "grammatical error"
|
|
246
|
+
: state.invalid === "spelling"
|
|
247
|
+
? "spelling error"
|
|
248
|
+
: "invalid entry",
|
|
249
|
+
);
|
|
250
|
+
if (semantics.popup)
|
|
251
|
+
words.push(`has popup ${semantics.popup === "listbox" ? "list box" : semantics.popup}`);
|
|
252
|
+
if (value.text !== undefined) words.push(value.text);
|
|
253
|
+
else if (value.now !== undefined && Number.isFinite(value.now)) {
|
|
254
|
+
words.push(String(value.now));
|
|
255
|
+
if (
|
|
256
|
+
value.min !== undefined &&
|
|
257
|
+
value.max !== undefined &&
|
|
258
|
+
Number.isFinite(value.min) &&
|
|
259
|
+
Number.isFinite(value.max)
|
|
260
|
+
)
|
|
261
|
+
words.push(`range ${value.min} to ${value.max}`);
|
|
262
|
+
}
|
|
263
|
+
if (semantics.hint) words.push(semantics.hint);
|
|
264
|
+
return words.filter((word) => word.trim().length > 0).join(", ");
|
|
265
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createElement, useLayoutEffect } from "react";
|
|
2
|
+
import { View, type NativeElementProps } from "./primitives";
|
|
3
|
+
import Animated, {
|
|
4
|
+
Easing,
|
|
5
|
+
useAnimatedStyle,
|
|
6
|
+
useSharedValue,
|
|
7
|
+
withRepeat,
|
|
8
|
+
withTiming,
|
|
9
|
+
} from "../animation/reanimated";
|
|
10
|
+
import { RokuHostError } from "../scene/sceneGraph.types";
|
|
11
|
+
import { styleComponent } from "./styleInterop";
|
|
12
|
+
export interface ActivityIndicatorProps extends NativeElementProps {
|
|
13
|
+
readonly animating?: boolean;
|
|
14
|
+
readonly hidesWhenStopped?: boolean;
|
|
15
|
+
readonly color?: string;
|
|
16
|
+
readonly size?: "small" | "large" | number;
|
|
17
|
+
}
|
|
18
|
+
/** Timed JS spinner with one owned animation; no decoder or native-thread progress claim. */
|
|
19
|
+
export function ActivityIndicator({
|
|
20
|
+
animating = true,
|
|
21
|
+
hidesWhenStopped = true,
|
|
22
|
+
color = "#999999",
|
|
23
|
+
size = "small",
|
|
24
|
+
style,
|
|
25
|
+
...props
|
|
26
|
+
}: ActivityIndicatorProps) {
|
|
27
|
+
const extent = typeof size === "number" ? size : size === "large" ? 36 : 20;
|
|
28
|
+
if (!Number.isFinite(extent) || extent <= 0 || extent > 512)
|
|
29
|
+
throw new RokuHostError("C03_SPINNER_SIZE", "ActivityIndicator size must be within (0,512]");
|
|
30
|
+
const phase = useSharedValue(0);
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
if (animating)
|
|
33
|
+
phase.value = withRepeat(withTiming(360, { duration: 900, easing: Easing.linear }), -1);
|
|
34
|
+
else phase.value = 0;
|
|
35
|
+
return () => phase.cancel();
|
|
36
|
+
}, [animating, phase]);
|
|
37
|
+
const rotation = useAnimatedStyle(() => ({
|
|
38
|
+
width: extent,
|
|
39
|
+
height: extent,
|
|
40
|
+
transform: [{ rotate: `${phase.value}deg` }],
|
|
41
|
+
}));
|
|
42
|
+
return createElement(
|
|
43
|
+
styleComponent(View),
|
|
44
|
+
{
|
|
45
|
+
...props,
|
|
46
|
+
style: [{ alignItems: "center", justifyContent: "center" }, style],
|
|
47
|
+
},
|
|
48
|
+
animating || !hidesWhenStopped
|
|
49
|
+
? createElement(
|
|
50
|
+
Animated.View,
|
|
51
|
+
{ style: rotation },
|
|
52
|
+
...Array.from({ length: 12 }, (_, index) => {
|
|
53
|
+
const angle = (index * Math.PI) / 6,
|
|
54
|
+
radius = extent * 0.34;
|
|
55
|
+
return createElement(View, {
|
|
56
|
+
key: index,
|
|
57
|
+
style: {
|
|
58
|
+
position: "absolute",
|
|
59
|
+
width: extent / 12,
|
|
60
|
+
height: extent / 4,
|
|
61
|
+
left: extent / 2 + Math.sin(angle) * radius - extent / 24,
|
|
62
|
+
top: extent / 2 - Math.cos(angle) * radius - extent / 8,
|
|
63
|
+
backgroundColor: color,
|
|
64
|
+
opacity: (index + 1) / 12,
|
|
65
|
+
transform: [{ rotate: `${index * 30}deg` }],
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}),
|
|
69
|
+
)
|
|
70
|
+
: null,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { LayoutStyle } from "../layout/flexLayout";
|
|
3
|
+
import type { NativePressableProps } from "./primitives";
|
|
4
|
+
|
|
5
|
+
const compilerStyles = new WeakSet<LayoutStyle>();
|
|
6
|
+
export type CompiledPressableKeys = readonly (keyof NativePressableProps)[];
|
|
7
|
+
const compilerProps = new WeakMap<object, CompiledPressableKeys>();
|
|
8
|
+
|
|
9
|
+
export function markPressableElement<T extends ReactElement>(
|
|
10
|
+
element: T,
|
|
11
|
+
keys: CompiledPressableKeys,
|
|
12
|
+
): T {
|
|
13
|
+
compilerProps.set(element.props as object, keys);
|
|
14
|
+
return element;
|
|
15
|
+
}
|
|
16
|
+
export function markPressableStyle<T extends LayoutStyle>(style: T): T {
|
|
17
|
+
Object.freeze(style);
|
|
18
|
+
compilerStyles.add(style);
|
|
19
|
+
return style;
|
|
20
|
+
}
|
|
21
|
+
export function scalarPressableKeyOrder(props: object): CompiledPressableKeys | undefined {
|
|
22
|
+
return compilerProps.get(props);
|
|
23
|
+
}
|
|
24
|
+
export function usesScalarPressableStyle(style: LayoutStyle): boolean {
|
|
25
|
+
return compilerStyles.has(style);
|
|
26
|
+
}
|