react-native-roku 0.0.0-stage → 0.2.0-preview.3
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 +328 -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 +368 -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,56 @@
|
|
|
1
|
+
# Standalone testing
|
|
2
|
+
|
|
3
|
+
A maintainer needs the source repository, a supported Node installation, pinned pnpm and public registry access. Hardware work additionally needs a developer-enabled Roku. Tests use package-owned screens, assets, routes, expected results and scoring code. The release archive contains the public initializer. The benchmark suite lives in the source distribution.
|
|
4
|
+
|
|
5
|
+
## Clean host and package
|
|
6
|
+
|
|
7
|
+
Run these from a fresh clone. Choose a new directory outside the checkout for each experiment.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm install --frozen-lockfile --registry=https://registry.npmjs.org
|
|
11
|
+
pnpm check:independence
|
|
12
|
+
pnpm test:navigation
|
|
13
|
+
node scripts/check-independence.mjs --coverage > /tmp/roku-coverage.json
|
|
14
|
+
pnpm check:fast
|
|
15
|
+
pnpm pack --out "$RUN/runtime.tgz"
|
|
16
|
+
node benchmarks/consumers/prepare.mjs "$RUN/runtime.tgz" "$RUN/catalog" catalog
|
|
17
|
+
node benchmarks/consumers/prepare.mjs "$RUN/runtime.tgz" "$RUN/images" images
|
|
18
|
+
node benchmarks/consumers/prepare.mjs "$RUN/runtime.tgz" "$RUN/settings" settings
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Set `RUN` to an existing, private experiment directory first. Each consumer runs the initializer from the selected archive, installs its pinned dependency graph, typechecks, and builds a ZIP. Its input receipt records the archive, ZIP, entry and lock hashes. To compare with full-title Solid, use `ROKU_SHELF_WORKLOAD=catalog node benchmarks/shelf/prepare.mjs "$RUN/runtime.tgz" "$RUN/shelf" solid-full`. The frozen 24-card React and 48-row image holdout have their own recipes in [navigation](https://github.com/react-native-roku/react-native-roku/blob/HEAD/benchmarks/navigation/README.md). Use ordinary default rendering for the primary React cohort.
|
|
22
|
+
|
|
23
|
+
The [Solid scorecard and measured example](https://github.com/react-native-roku/react-native-roku/blob/HEAD/benchmarks/navigation/README.md#reproduce-the-full-title-solid-scorecard) document the endpoint, collection design and raw-trace verification. Run `pnpm test:navigation` for offline scorer and device-protocol regressions. This entry point runs independently of storage admission for the exact-package seal.
|
|
24
|
+
|
|
25
|
+
## Physical runs
|
|
26
|
+
|
|
27
|
+
Set `ROKU_BENCHMARK_HOST` to the device address and `ROKU_LEASE_DIR` to the lock directory shared by **all** jobs using that device. Configure the public SDK developer login locally or set `ROKU_DEV_PASSWORD`. The runner requires an idle channel whose installed digest and byte count match your rollback ZIP. On a new dedicated device, install your own public starter as the rollback channel once. Supply its ZIP on subsequent runs. The runner locks the device by serial, checks the installed artifact, launches the requested fixture, restores the original, and verifies media is idle. A failed restoration retains the lock for recovery. Recheck the installed digest and idle state before clearing an abandoned lock. Keep raw receipts and credentials out of Git.
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
node benchmarks/navigation/lab.mjs images react "$RUN/images/fixture.zip" "$ROLLBACK_ZIP" "$RUN/gallery-device"
|
|
31
|
+
node benchmarks/navigation/lab.mjs settings react "$RUN/settings/fixture.zip" "$ROLLBACK_ZIP" "$RUN/settings-device"
|
|
32
|
+
node benchmarks/navigation/lab.mjs settings-storage react "$RUN/settings/fixture.zip" "$ROLLBACK_ZIP" "$RUN/settings-storage"
|
|
33
|
+
node benchmarks/navigation/lab.mjs deep-long react "$RUN/catalog/fixture.zip" "$ROLLBACK_ZIP" "$RUN/sustained" --rk "$PWD/node_modules/.bin/rk" --processor "$TRACE_PROCESSOR"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Set `TRACE_PROCESSOR` to an executable Perfetto trace processor. `--restore-dev` requests the verified rollback channel in the foreground even when the run starts on Home. `--reboot-before` requests a single SDK reboot under the same lease before fixture installation. `ROKU_STARTUP_DIAGNOSTICS=1` collects startup console diagnostics separately. The suite can also replay on a fixture installed by a different lab operator using its authenticated installer receipt. Output directories must be new.
|
|
37
|
+
|
|
38
|
+
The `settings-storage` journey reads the existing fixture preference, changes it through a focused control, waits for the storage write, terminates the dev channel, verifies that it left the foreground, and relaunches it. It requires the changed value and restored default focus. It then restores the original value and verifies it through a second cold launch. This uses the fixture's own registry namespace. Text entry and spoken accessibility remain separate checks.
|
|
39
|
+
|
|
40
|
+
Run `deep-window` for mounted row geometry, `deep-second` for rapid Down, reversal and paced control, `deep-triple` for a following Select and `deep-long` for nine directions. The sustained route checks Card 64 before Select, opens its Detail and verifies restored focus, scroll offset and mounted rows after Back. A mismatch fails the run. Use `python3 benchmarks/navigation/deep/mark-directions.py INPUT.zip MARKED.zip` for callback and field attribution, and the matching scenario with `-fields`. Use `python3 benchmarks/navigation/deep/mark-window.py` for the structural window trace. Keep marked and unmarked results separate. For saved traces use `suite.py extract deep-long RUN --processor EXECUTABLE` in a fresh copy containing the trace, then `python3 benchmarks/navigation/deep/directions.py RUN --output SCORE.json` with the corresponding replay. Use `python3 benchmarks/navigation/deep/window.py RUN --marked-zip-proof PROOF.json` or `--attribution MARKED_SCORE.json` for structural window timing.
|
|
41
|
+
|
|
42
|
+
## Coverage and acceptance
|
|
43
|
+
|
|
44
|
+
The compatibility registry maps supported APIs to contracts and checked-in tests. The coverage command expands those references per API. Scope descriptions distinguish host behavior from physical support. A test path is a way to reproduce evidence. A release claim requires a result for the selected artifact and target.
|
|
45
|
+
|
|
46
|
+
| Area | Package-owned exercises | Additional physical evidence |
|
|
47
|
+
| --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| D-pad, focus, lists and scroll | Shelf, full-title Solid, cross-row and reversal bursts, missed focus, deep routes, Back and residency soak | Capture dispatch, apply and eligible swap per key. Require the correct destination, single activation and restored offset. |
|
|
49
|
+
| Text, images and rendering | Wrapping titles, resize, image holdout, packaged gallery load, missing image, removal and remount | Score settled pixel crops, field lifetimes and clip bounds. Use the paired installer screenshot test for rounded clipping. First-visible latency is a separate display measurement. |
|
|
50
|
+
| Input, overlays and accessibility | Settings modal, editable field, preferred focus, accessible labels, dismissal and focus return, host text-input and accessibility tests | Enter and submit text with a physical keyboard/dialog and verify spoken focus separately. |
|
|
51
|
+
| Animation, surfaces, navigation, services and media | Registry-linked tests, public composed UI and SDK fixtures | Track supported device/firmware observations individually, including animation pacing, playback and speech. |
|
|
52
|
+
| Developer experience | Packed initializer, clean builds, both bundlers, reload and public compatibility checks | Cold launch, lower-tier hardware, memory, long sessions and failure recovery require their own receipts. |
|
|
53
|
+
|
|
54
|
+
Benchmark changes against the same fixture, command schedule, SDK and display configuration. Run A/A for noise and fresh launches in both A/B orders. Compare matched steps and per-launch medians, p95 and worst. Record failures and missing endpoints in the denominator. Promote an optimization only after correctness, tail latency and an independent workload agree. A completed SDK swap is a device-clock endpoint. A visible frame needs separate display evidence.
|
|
55
|
+
|
|
56
|
+
Run `pnpm check` or the manual full CI workflow for the exact six-lane seal. It requires the documented storage admission. If storage is short, point `RNR_QUALIFICATION_STORAGE_ROOT` at a sufficiently provisioned canonical store under the documented volume rules, use a clean worker with sufficient disk, or run the documented storage maintenance. Preserve failed runs and continue independent checks. Report seal status separately.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Hello Roku
|
|
2
|
+
|
|
3
|
+
A complete standalone consumer with a normal React component and
|
|
4
|
+
`roku.config.json`. It builds from its own source and configuration.
|
|
5
|
+
|
|
6
|
+
With Node 24.18.1 and pnpm 11.23.0:
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
pnpm install
|
|
10
|
+
pnpm run doctor
|
|
11
|
+
pnpm typecheck
|
|
12
|
+
pnpm dev
|
|
13
|
+
pnpm build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The browser Canvas preview watches and reloads successful changes on port 9389;
|
|
17
|
+
compile errors keep the last good app visible. This is full reload, not React
|
|
18
|
+
Fast Refresh. The finite build writes `dist/roku-app.zip`. The generated `.roku/`
|
|
19
|
+
project owns SDK Scene/Main/anchor files and native helpers; edit your component
|
|
20
|
+
or config instead. No command installs a channel or deploys to a device.
|
|
21
|
+
|
|
22
|
+
Before publication, create this template through the platform repository's
|
|
23
|
+
`react-native-roku init` command with an explicit `--package=file:/absolute/path/to/platform.tgz`.
|
|
24
|
+
See its getting-started guide. The template uses Inter; retain that dependency's
|
|
25
|
+
font license when redistributing assets. Browser/SDK checks do not qualify
|
|
26
|
+
physical Roku rendering, networking, focus, video or sustained performance.
|
|
27
|
+
|
|
28
|
+
## Browse the catalog
|
|
29
|
+
|
|
30
|
+
Set `entry` to `src/Catalog.tsx` in `roku.config.json` and run the same preview
|
|
31
|
+
or build commands. The example uses a bundled image and 72 routes in a
|
|
32
|
+
four-column virtualized list. Card 2 is disabled. Move down past the initial
|
|
33
|
+
viewport, open a route, then use Back to return to the same card and scroll
|
|
34
|
+
offset. Route information opens a modal. Dismiss it to return focus to the
|
|
35
|
+
information button.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hello-react-native-roku",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"typecheck": "tsc6 --noEmit -p tsconfig.react.json",
|
|
8
|
+
"build": "react-native-roku build",
|
|
9
|
+
"dev": "react-native-roku dev",
|
|
10
|
+
"doctor": "react-native-roku doctor"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"react-native-roku": "0.2.0-preview.3",
|
|
14
|
+
"react": "19.2.8",
|
|
15
|
+
"@roku-sdk/rsg-ts": "2.19.1",
|
|
16
|
+
"@expo-google-fonts/inter": "0.4.2"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@roku-sdk/tooling": "2.19.1",
|
|
20
|
+
"@types/react": "19.2.18",
|
|
21
|
+
"@types/node": "24.19.1",
|
|
22
|
+
"esbuild": "0.28.1",
|
|
23
|
+
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
24
|
+
"@roku-sdk/dev-tools": "2.19.1"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=24.18.1 <25",
|
|
28
|
+
"pnpm": "11.23.0"
|
|
29
|
+
},
|
|
30
|
+
"packageManager": "pnpm@11.23.0"
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "HelloRoku",
|
|
3
|
+
"displayName": "React Native Roku Hello",
|
|
4
|
+
"entry": "src/App.tsx",
|
|
5
|
+
"background": "#101014",
|
|
6
|
+
"fonts": {
|
|
7
|
+
"defaultFamily": "Inter",
|
|
8
|
+
"assets": {
|
|
9
|
+
"InterRegular": "@expo-google-fonts/inter/400Regular/Inter_400Regular.ttf",
|
|
10
|
+
"InterBold": "@expo-google-fonts/inter/700Bold/Inter_700Bold.ttf",
|
|
11
|
+
"InterItalic": "@expo-google-fonts/inter/400Regular_Italic/Inter_400Regular_Italic.ttf",
|
|
12
|
+
"InterBoldItalic": "@expo-google-fonts/inter/700Bold_Italic/Inter_700Bold_Italic.ttf"
|
|
13
|
+
},
|
|
14
|
+
"families": {
|
|
15
|
+
"Inter": {
|
|
16
|
+
"normal": { "400": "InterRegular", "700": "InterBold" },
|
|
17
|
+
"italic": { "400": "InterItalic", "700": "InterBoldItalic" }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"variants": ["tabular-nums"]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { View, Text, Pressable } from "react-native";
|
|
3
|
+
export default function App() {
|
|
4
|
+
const [count, setCount] = useState(0);
|
|
5
|
+
return (
|
|
6
|
+
<View
|
|
7
|
+
style={{
|
|
8
|
+
width: 1920,
|
|
9
|
+
height: 1080,
|
|
10
|
+
padding: 100,
|
|
11
|
+
backgroundColor: "#101014",
|
|
12
|
+
}}
|
|
13
|
+
>
|
|
14
|
+
<Text style={{ fontSize: 44, color: "white" }}>Hello, Roku</Text>
|
|
15
|
+
<Text style={{ fontSize: 32, fontWeight: "bold", color: "white" }}>Weighted 700</Text>
|
|
16
|
+
<Text
|
|
17
|
+
style={{ fontSize: 32, fontFamily: "InterRegular", fontStyle: "italic", color: "white" }}
|
|
18
|
+
>
|
|
19
|
+
Italic 400
|
|
20
|
+
</Text>
|
|
21
|
+
<Text
|
|
22
|
+
style={{
|
|
23
|
+
fontSize: 32,
|
|
24
|
+
fontFamily: "InterBoldItalic",
|
|
25
|
+
fontWeight: "400",
|
|
26
|
+
fontStyle: "italic",
|
|
27
|
+
color: "white",
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
Physical italic 700
|
|
31
|
+
</Text>
|
|
32
|
+
<Text
|
|
33
|
+
nativeID="tabular-digits"
|
|
34
|
+
style={{ fontSize: 32, color: "white", fontVariant: ["tabular-nums"] }}
|
|
35
|
+
>
|
|
36
|
+
0123456789
|
|
37
|
+
</Text>
|
|
38
|
+
<Pressable
|
|
39
|
+
nativeID="counter"
|
|
40
|
+
hasTVPreferredFocus
|
|
41
|
+
onPress={() => setCount((value) => value + 1)}
|
|
42
|
+
style={({ focused }) => ({
|
|
43
|
+
width: 600,
|
|
44
|
+
height: 100,
|
|
45
|
+
marginTop: 30,
|
|
46
|
+
padding: 20,
|
|
47
|
+
backgroundColor: focused ? "#3456c0" : "#303040",
|
|
48
|
+
})}
|
|
49
|
+
>
|
|
50
|
+
<Text style={{ fontSize: 32, color: "white" }}>Pressed {count} times</Text>
|
|
51
|
+
</Pressable>
|
|
52
|
+
</View>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { useEffect, useRef, useState, type ElementRef } from "react";
|
|
2
|
+
import { BackHandler, FlatList, Image, Modal, Pressable, Text, View } from "react-native";
|
|
3
|
+
import cover from "./catalog-cover.png";
|
|
4
|
+
|
|
5
|
+
const columns = 4;
|
|
6
|
+
const rowHeight = 200;
|
|
7
|
+
const viewportHeight = 680;
|
|
8
|
+
const longTitle =
|
|
9
|
+
"A field guide to the mountain passes, alpine lakes, and winding roads of the northern range";
|
|
10
|
+
const catalog = Array.from({ length: 72 }, (_, index) => ({
|
|
11
|
+
id: `catalog-card-${index}`,
|
|
12
|
+
index,
|
|
13
|
+
title: index % 7 === 2 ? longTitle : `Mountain route ${index + 1}`,
|
|
14
|
+
disabled: index === 1,
|
|
15
|
+
}));
|
|
16
|
+
type Card = (typeof catalog)[number];
|
|
17
|
+
type CatalogPosition = { card: Card; offset: number };
|
|
18
|
+
|
|
19
|
+
const buttonStyle = ({ focused }: { focused: boolean }) => ({
|
|
20
|
+
width: 320,
|
|
21
|
+
height: 64,
|
|
22
|
+
padding: 12,
|
|
23
|
+
backgroundColor: focused ? "#3456c0" : "#303040",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export default function Catalog() {
|
|
27
|
+
const [detail, setDetail] = useState<Card>();
|
|
28
|
+
const position = useRef<CatalogPosition>({ card: catalog[0], offset: 0 });
|
|
29
|
+
return (
|
|
30
|
+
<View style={{ width: 1920, height: 1080, padding: 80, backgroundColor: "#101014" }}>
|
|
31
|
+
{detail ? (
|
|
32
|
+
<Detail card={detail} onBack={() => setDetail(undefined)} />
|
|
33
|
+
) : (
|
|
34
|
+
<Grid
|
|
35
|
+
initial={position.current}
|
|
36
|
+
onOpen={(next) => {
|
|
37
|
+
position.current = next;
|
|
38
|
+
setDetail(next.card);
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function Grid({
|
|
47
|
+
initial,
|
|
48
|
+
onOpen,
|
|
49
|
+
}: {
|
|
50
|
+
initial: CatalogPosition;
|
|
51
|
+
onOpen: (next: CatalogPosition) => void;
|
|
52
|
+
}) {
|
|
53
|
+
const list = useRef<ElementRef<typeof FlatList<Card>>>(null);
|
|
54
|
+
const offset = useRef(initial.offset);
|
|
55
|
+
const restoring = useRef(initial.offset !== 0);
|
|
56
|
+
const [focused, setFocused] = useState(initial.card.index);
|
|
57
|
+
const [restoreFocus, setRestoreFocus] = useState(true);
|
|
58
|
+
const rowFor = (card: Card) => Math.floor(card.index / columns);
|
|
59
|
+
const moveList = (next: number) => {
|
|
60
|
+
offset.current = next;
|
|
61
|
+
list.current?.scrollToOffset({ offset: next, animated: false });
|
|
62
|
+
};
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
<Text nativeID="catalog-heading" style={{ fontSize: 44, color: "white" }}>
|
|
66
|
+
Mountain routes
|
|
67
|
+
</Text>
|
|
68
|
+
<Text nativeID="catalog-position" style={{ fontSize: 27, color: "white", height: 54 }}>
|
|
69
|
+
{focused + 1} of {catalog.length}
|
|
70
|
+
</Text>
|
|
71
|
+
<FlatList
|
|
72
|
+
ref={list}
|
|
73
|
+
nativeID="catalog-grid"
|
|
74
|
+
data={catalog}
|
|
75
|
+
numColumns={columns}
|
|
76
|
+
style={{ width: 1560, height: viewportHeight, flexGrow: 0 }}
|
|
77
|
+
initialScrollIndex={rowFor(initial.card)}
|
|
78
|
+
initialNumToRender={5}
|
|
79
|
+
windowSize={3}
|
|
80
|
+
getItemLayout={(_, index) => ({ index, length: rowHeight, offset: index * rowHeight })}
|
|
81
|
+
keyExtractor={(item) => item.id}
|
|
82
|
+
onLayout={() => {
|
|
83
|
+
if (!restoring.current) return;
|
|
84
|
+
restoring.current = false;
|
|
85
|
+
moveList(initial.offset);
|
|
86
|
+
}}
|
|
87
|
+
onScroll={(event) => {
|
|
88
|
+
if (!restoring.current) offset.current = event.nativeEvent.contentOffset.y;
|
|
89
|
+
}}
|
|
90
|
+
renderItem={({ item }) => (
|
|
91
|
+
<Pressable
|
|
92
|
+
nativeID={item.id}
|
|
93
|
+
disabled={item.disabled}
|
|
94
|
+
hasTVPreferredFocus={restoreFocus && item.id === initial.card.id}
|
|
95
|
+
accessibilityRole="button"
|
|
96
|
+
accessibilityState={{ disabled: item.disabled }}
|
|
97
|
+
onFocus={() => {
|
|
98
|
+
// The initial target can remount while the user navigates the virtual window.
|
|
99
|
+
if (restoreFocus && item.id === initial.card.id) setRestoreFocus(false);
|
|
100
|
+
setFocused(item.index);
|
|
101
|
+
if (restoring.current) return;
|
|
102
|
+
const top = rowFor(item) * rowHeight;
|
|
103
|
+
if (top < offset.current) moveList(top);
|
|
104
|
+
else if (top + rowHeight > offset.current + viewportHeight)
|
|
105
|
+
moveList(top + rowHeight - viewportHeight);
|
|
106
|
+
}}
|
|
107
|
+
onPress={() => onOpen({ card: item, offset: offset.current })}
|
|
108
|
+
style={({ focused }) => ({
|
|
109
|
+
width: 366,
|
|
110
|
+
height: rowHeight - 12,
|
|
111
|
+
marginRight: 16,
|
|
112
|
+
marginBottom: 12,
|
|
113
|
+
padding: 12,
|
|
114
|
+
backgroundColor: item.disabled ? "#202027" : focused ? "#3456c0" : "#303040",
|
|
115
|
+
})}
|
|
116
|
+
>
|
|
117
|
+
<Image source={cover} style={{ width: 342, height: 93 }} resizeMode="cover" />
|
|
118
|
+
<Text
|
|
119
|
+
nativeID={item.id + "-title"}
|
|
120
|
+
style={{ fontSize: 24, lineHeight: 29, color: "white" }}
|
|
121
|
+
numberOfLines={2}
|
|
122
|
+
>
|
|
123
|
+
{item.title}
|
|
124
|
+
</Text>
|
|
125
|
+
</Pressable>
|
|
126
|
+
)}
|
|
127
|
+
/>
|
|
128
|
+
</>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function Detail({ card, onBack }: { card: Card; onBack: () => void }) {
|
|
133
|
+
const [showInfo, setShowInfo] = useState(false);
|
|
134
|
+
const info = useRef<ElementRef<typeof Pressable>>(null);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (showInfo) return;
|
|
137
|
+
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
138
|
+
onBack();
|
|
139
|
+
return true;
|
|
140
|
+
});
|
|
141
|
+
return () => subscription.remove();
|
|
142
|
+
}, [onBack, showInfo]);
|
|
143
|
+
const dismiss = () => setShowInfo(false);
|
|
144
|
+
return (
|
|
145
|
+
<>
|
|
146
|
+
<Text nativeID="catalog-detail-title" style={{ fontSize: 44, color: "white", width: 1000 }}>
|
|
147
|
+
{card.title}
|
|
148
|
+
</Text>
|
|
149
|
+
<Image source={cover} style={{ width: 720, height: 320, marginVertical: 32 }} />
|
|
150
|
+
<Pressable
|
|
151
|
+
ref={info}
|
|
152
|
+
nativeID="catalog-info"
|
|
153
|
+
hasTVPreferredFocus
|
|
154
|
+
accessibilityRole="button"
|
|
155
|
+
onPress={() => setShowInfo(true)}
|
|
156
|
+
style={buttonStyle}
|
|
157
|
+
>
|
|
158
|
+
<Text style={{ fontSize: 28, color: "white" }}>Route information</Text>
|
|
159
|
+
</Pressable>
|
|
160
|
+
<Pressable
|
|
161
|
+
nativeID="catalog-back"
|
|
162
|
+
accessibilityRole="button"
|
|
163
|
+
onPress={onBack}
|
|
164
|
+
style={buttonStyle}
|
|
165
|
+
>
|
|
166
|
+
<Text style={{ fontSize: 28, color: "white" }}>Back to routes</Text>
|
|
167
|
+
</Pressable>
|
|
168
|
+
<Modal
|
|
169
|
+
visible={showInfo}
|
|
170
|
+
transparent
|
|
171
|
+
onRequestClose={dismiss}
|
|
172
|
+
onDismiss={() => info.current?.focus()}
|
|
173
|
+
>
|
|
174
|
+
<View
|
|
175
|
+
style={{
|
|
176
|
+
width: 700,
|
|
177
|
+
height: 260,
|
|
178
|
+
padding: 32,
|
|
179
|
+
marginTop: 260,
|
|
180
|
+
marginLeft: 420,
|
|
181
|
+
backgroundColor: "#20243b",
|
|
182
|
+
}}
|
|
183
|
+
>
|
|
184
|
+
<Text nativeID="catalog-modal-title" style={{ fontSize: 36, color: "white" }}>
|
|
185
|
+
Route {card.index + 1}
|
|
186
|
+
</Text>
|
|
187
|
+
<Pressable
|
|
188
|
+
nativeID="catalog-modal-close"
|
|
189
|
+
hasTVPreferredFocus
|
|
190
|
+
accessibilityRole="button"
|
|
191
|
+
onPress={dismiss}
|
|
192
|
+
style={buttonStyle}
|
|
193
|
+
>
|
|
194
|
+
<Text style={{ fontSize: 28, color: "white" }}>Close</Text>
|
|
195
|
+
</Pressable>
|
|
196
|
+
</View>
|
|
197
|
+
</Modal>
|
|
198
|
+
</>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare module "*.png" {
|
|
2
|
+
const source: import("react-native-roku/image").ImageSource;
|
|
3
|
+
export default source;
|
|
4
|
+
}
|
|
5
|
+
declare module "*.jpg" {
|
|
6
|
+
const source: import("react-native-roku/image").ImageSource;
|
|
7
|
+
export default source;
|
|
8
|
+
}
|
|
9
|
+
declare module "*.jpeg" {
|
|
10
|
+
const source: import("react-native-roku/image").ImageSource;
|
|
11
|
+
export default source;
|
|
12
|
+
}
|
|
13
|
+
declare module "*.webp" {
|
|
14
|
+
const source: import("react-native-roku/image").ImageSource;
|
|
15
|
+
export default source;
|
|
16
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "extends": "./tsconfig.react.json" }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "extends": "react-native-roku/tsconfig", "include": ["src"] }
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
sub onFocusSample(event as object)
|
|
2
|
+
target = m.top.focusSampleTarget
|
|
3
|
+
previous = m.top.focusSamplePrevious
|
|
4
|
+
m.top.focusSampleTarget = invalid
|
|
5
|
+
m.top.focusSamplePrevious = invalid
|
|
6
|
+
index = -1
|
|
7
|
+
if target <> invalid and target.hasFocus()
|
|
8
|
+
index = 0
|
|
9
|
+
else if previous <> invalid and previous.hasFocus()
|
|
10
|
+
index = 1
|
|
11
|
+
end if
|
|
12
|
+
m.top.focusSampleReply = FormatJson(event.getData()) + ":" + FormatJson(index)
|
|
13
|
+
end sub
|
|
14
|
+
|
|
15
|
+
sub onExitRequested()
|
|
16
|
+
if m.top.exitRequested
|
|
17
|
+
scene = m.top.getScene()
|
|
18
|
+
if scene <> invalid then scene.exitRequested = true
|
|
19
|
+
end if
|
|
20
|
+
end sub
|
|
21
|
+
|
|
22
|
+
sub init()
|
|
23
|
+
m.top.observeFieldScoped("textEntryRequest", "onTextEntryRequest")
|
|
24
|
+
end sub
|
|
25
|
+
|
|
26
|
+
sub onTextEntryRequest(event as object)
|
|
27
|
+
' Read this event's payload, not a field that another queued request changed.
|
|
28
|
+
payload = event.getData()
|
|
29
|
+
if payload = "" then return
|
|
30
|
+
m.top.textEntryRequest = ""
|
|
31
|
+
request = ParseJson(payload)
|
|
32
|
+
if type(request) <> "roAssociativeArray" then return
|
|
33
|
+
if request.version <> 2 then return
|
|
34
|
+
if request.revision = invalid then request.revision = 0
|
|
35
|
+
if request.update = true
|
|
36
|
+
if m.textEntryDialog <> invalid
|
|
37
|
+
if m.textEntryId = request.id and m.textEntryClosing = false
|
|
38
|
+
if request.revision > m.textEntryRevision
|
|
39
|
+
m.textEntryRevision = request.revision
|
|
40
|
+
m.textEntryText = request.text
|
|
41
|
+
m.textEntryDialog.text = request.text
|
|
42
|
+
publishTextEntryCaret()
|
|
43
|
+
end if
|
|
44
|
+
return
|
|
45
|
+
end if
|
|
46
|
+
end if
|
|
47
|
+
if m.textEntryNext <> invalid
|
|
48
|
+
if m.textEntryNext.id = request.id
|
|
49
|
+
if request.revision > m.textEntryNext.revision
|
|
50
|
+
m.textEntryNext.text = request.text
|
|
51
|
+
m.textEntryNext.revision = request.revision
|
|
52
|
+
end if
|
|
53
|
+
end if
|
|
54
|
+
end if
|
|
55
|
+
return
|
|
56
|
+
end if
|
|
57
|
+
if request.close = true
|
|
58
|
+
if m.textEntryNext <> invalid
|
|
59
|
+
if m.textEntryNext.id = request.id
|
|
60
|
+
m.textEntryNext = invalid
|
|
61
|
+
publishTextEntryReply(request.id, invalid, false, 0)
|
|
62
|
+
return
|
|
63
|
+
end if
|
|
64
|
+
end if
|
|
65
|
+
if m.textEntryDialog <> invalid
|
|
66
|
+
if m.textEntryId = request.id
|
|
67
|
+
requestTextEntryClose(invalid)
|
|
68
|
+
return
|
|
69
|
+
end if
|
|
70
|
+
end if
|
|
71
|
+
publishTextEntryReply(request.id, invalid, false, 0)
|
|
72
|
+
return
|
|
73
|
+
end if
|
|
74
|
+
if m.textEntryDialog <> invalid
|
|
75
|
+
' Keep one successor; canceled queued editors never became a native dialog.
|
|
76
|
+
if m.textEntryNext <> invalid then publishTextEntryReply(m.textEntryNext.id, invalid, false, 0)
|
|
77
|
+
m.textEntryNext = request
|
|
78
|
+
requestTextEntryClose(invalid)
|
|
79
|
+
return
|
|
80
|
+
end if
|
|
81
|
+
openTextEntryDialog(request)
|
|
82
|
+
end sub
|
|
83
|
+
|
|
84
|
+
sub openTextEntryDialog(request as object)
|
|
85
|
+
scene = m.top.getScene()
|
|
86
|
+
if scene = invalid
|
|
87
|
+
publishTextEntryReply(request.id, invalid, false, 0)
|
|
88
|
+
return
|
|
89
|
+
end if
|
|
90
|
+
m.textEntryId = request.id
|
|
91
|
+
m.textEntryResult = invalid
|
|
92
|
+
m.textEntryClosing = false
|
|
93
|
+
m.textEntryRevision = 0
|
|
94
|
+
m.textEntrySequence = 0
|
|
95
|
+
m.textEntryObserveChanges = (request.observeChanges = true)
|
|
96
|
+
m.textEntryObserveSelection = (request.observeSelection = true)
|
|
97
|
+
m.textEntryText = request.text
|
|
98
|
+
if request.revision <> invalid then m.textEntryRevision = request.revision
|
|
99
|
+
dialog = CreateObject("roSGNode", "StandardKeyboardDialog")
|
|
100
|
+
dialog.id = "rnr-text-entry-" + FormatJson(request.id)
|
|
101
|
+
dialog.title = request.title
|
|
102
|
+
dialog.keyboardDomain = request.domain
|
|
103
|
+
dialog.buttons = ["OK", "Cancel"]
|
|
104
|
+
dialog.textEditBox.secureMode = request.secure
|
|
105
|
+
dialog.textEditBox.maxTextLength = request.maxLength
|
|
106
|
+
dialog.text = request.text
|
|
107
|
+
dialog.observeFieldScoped("buttonSelected", "onTextEntryButton")
|
|
108
|
+
dialog.observeFieldScoped("wasClosed", "onTextEntryClosed")
|
|
109
|
+
if m.textEntryObserveChanges then dialog.observeFieldScoped("text", "onTextEntryText")
|
|
110
|
+
if m.textEntryObserveSelection
|
|
111
|
+
dialog.textEditBox.observeFieldScoped("cursorPosition", "onTextEntryCaret")
|
|
112
|
+
dialog.textEditBox.observeFieldScoped("text", "onTextEntryCaret")
|
|
113
|
+
end if
|
|
114
|
+
m.textEntryDialog = dialog
|
|
115
|
+
scene.dialog = dialog
|
|
116
|
+
publishTextEntryCaret()
|
|
117
|
+
end sub
|
|
118
|
+
|
|
119
|
+
sub onTextEntryText(event as object)
|
|
120
|
+
if m.textEntryDialog = invalid then return
|
|
121
|
+
if m.textEntryClosing = true then return
|
|
122
|
+
if event.getNode() <> m.textEntryDialog.id then return
|
|
123
|
+
value = event.getData()
|
|
124
|
+
' Reject queued observations from before a controlled update. Publish only
|
|
125
|
+
' the currently observed native draft, never a programmatic echo or clear.
|
|
126
|
+
if value <> m.textEntryDialog.text or value = m.textEntryText then return
|
|
127
|
+
m.textEntryText = value
|
|
128
|
+
m.textEntrySequence = m.textEntrySequence + 1
|
|
129
|
+
packet = { version: 2, id: m.textEntryId, draft: true, text: value, revision: m.textEntryRevision, sequence: m.textEntrySequence }
|
|
130
|
+
prefix = textEntryPrefix()
|
|
131
|
+
if prefix <> invalid then packet.prefix = prefix
|
|
132
|
+
m.top.textEntryReply = FormatJson(packet)
|
|
133
|
+
end sub
|
|
134
|
+
|
|
135
|
+
function textEntryPrefix() as dynamic
|
|
136
|
+
if m.textEntryDialog = invalid or m.textEntryClosing = true then return invalid
|
|
137
|
+
if m.textEntryObserveSelection = false then return invalid
|
|
138
|
+
editor = m.textEntryDialog.textEditBox
|
|
139
|
+
text = m.textEntryDialog.text
|
|
140
|
+
if editor.text <> text then return invalid
|
|
141
|
+
cursor = editor.cursorPosition
|
|
142
|
+
if cursor < 0 or cursor > text.Len() then return invalid
|
|
143
|
+
' Use the native string prefix so JS can compute UTF-16 offsets without
|
|
144
|
+
' assuming that SceneGraph and JavaScript count characters the same way.
|
|
145
|
+
return text.Left(cursor)
|
|
146
|
+
end function
|
|
147
|
+
|
|
148
|
+
sub publishTextEntryCaret()
|
|
149
|
+
prefix = textEntryPrefix()
|
|
150
|
+
if prefix = invalid then return
|
|
151
|
+
m.textEntrySequence = m.textEntrySequence + 1
|
|
152
|
+
m.top.textEntryReply = FormatJson({ version: 2, id: m.textEntryId, caret: true, text: m.textEntryDialog.text, prefix: prefix, revision: m.textEntryRevision, sequence: m.textEntrySequence })
|
|
153
|
+
end sub
|
|
154
|
+
|
|
155
|
+
sub onTextEntryCaret(event as object)
|
|
156
|
+
if m.textEntryDialog = invalid or m.textEntryClosing = true then return
|
|
157
|
+
editor = m.textEntryDialog.textEditBox
|
|
158
|
+
' Internal edit boxes need not have an ID. Compare actual native nodes so
|
|
159
|
+
' a queued event from a retired dialog cannot attach to its successor.
|
|
160
|
+
if not editor.isSameNode(event.getRoSGNode()) then return
|
|
161
|
+
if LCase(event.getField()) = "cursorposition"
|
|
162
|
+
if event.getData() <> editor.cursorPosition then return
|
|
163
|
+
else
|
|
164
|
+
if event.getData() <> editor.text then return
|
|
165
|
+
end if
|
|
166
|
+
publishTextEntryCaret()
|
|
167
|
+
end sub
|
|
168
|
+
|
|
169
|
+
sub onTextEntryButton(event as object)
|
|
170
|
+
if m.textEntryDialog = invalid then return
|
|
171
|
+
if event.getNode() <> m.textEntryDialog.id then return
|
|
172
|
+
value = invalid
|
|
173
|
+
if event.getData() = 0 then value = m.textEntryDialog.text
|
|
174
|
+
requestTextEntryClose(value)
|
|
175
|
+
end sub
|
|
176
|
+
|
|
177
|
+
sub requestTextEntryClose(value)
|
|
178
|
+
if m.textEntryDialog = invalid then return
|
|
179
|
+
if m.textEntryClosing = true then return
|
|
180
|
+
m.textEntryClosing = true
|
|
181
|
+
m.textEntryResult = value
|
|
182
|
+
m.textEntryText = ""
|
|
183
|
+
m.textEntryDialog.text = ""
|
|
184
|
+
' Keep the scoped close observer until native dismissal is acknowledged.
|
|
185
|
+
m.textEntryDialog.close = true
|
|
186
|
+
end sub
|
|
187
|
+
|
|
188
|
+
sub onTextEntryClosed(event as object)
|
|
189
|
+
if m.textEntryDialog = invalid then return
|
|
190
|
+
if event.getNode() <> m.textEntryDialog.id then return
|
|
191
|
+
dialog = m.textEntryDialog
|
|
192
|
+
id = m.textEntryId
|
|
193
|
+
value = m.textEntryResult
|
|
194
|
+
revision = m.textEntryRevision
|
|
195
|
+
m.textEntryDialog = invalid
|
|
196
|
+
m.textEntryId = invalid
|
|
197
|
+
m.textEntryResult = invalid
|
|
198
|
+
m.textEntryText = ""
|
|
199
|
+
m.textEntryClosing = false
|
|
200
|
+
dialog.unobserveFieldScoped("buttonSelected")
|
|
201
|
+
dialog.unobserveFieldScoped("wasClosed")
|
|
202
|
+
dialog.unobserveFieldScoped("text")
|
|
203
|
+
dialog.textEditBox.unobserveFieldScoped("cursorPosition")
|
|
204
|
+
dialog.textEditBox.unobserveFieldScoped("text")
|
|
205
|
+
dialog.text = ""
|
|
206
|
+
' Only this actual wasClosed observation may assert closed=true.
|
|
207
|
+
publishTextEntryReply(id, value, true, revision)
|
|
208
|
+
nextRequest = m.textEntryNext
|
|
209
|
+
m.textEntryNext = invalid
|
|
210
|
+
if nextRequest <> invalid then openTextEntryDialog(nextRequest)
|
|
211
|
+
end sub
|
|
212
|
+
|
|
213
|
+
sub publishTextEntryReply(id, value, observed as boolean, revision)
|
|
214
|
+
m.top.textEntryReply = FormatJson({ version: 2, id: id, text: value, closed: observed, revision: revision })
|
|
215
|
+
end sub
|