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.
Files changed (200) hide show
  1. package/CHANGELOG.md +318 -0
  2. package/CONTRIBUTING.md +34 -0
  3. package/LICENSE +21 -0
  4. package/NOTICE.md +10 -0
  5. package/README.md +66 -2
  6. package/bin/react-native-roku.mjs +91 -0
  7. package/build/assets.cjs +311 -0
  8. package/build/assets.d.cts +50 -0
  9. package/build/compatibility.d.mts +40 -0
  10. package/build/compatibility.mjs +272 -0
  11. package/build/dev.d.mts +34 -0
  12. package/build/dev.mjs +297 -0
  13. package/build/devWorkspace.d.mts +11 -0
  14. package/build/devWorkspace.mjs +86 -0
  15. package/build/device.d.mts +47 -0
  16. package/build/device.mjs +310 -0
  17. package/build/environment.d.mts +29 -0
  18. package/build/environment.mjs +144 -0
  19. package/build/esbuild.d.mts +5 -0
  20. package/build/esbuild.mjs +118 -0
  21. package/build/fontVariants.d.mts +27 -0
  22. package/build/fontVariants.mjs +424 -0
  23. package/build/frontend.d.mts +52 -0
  24. package/build/frontend.mjs +75 -0
  25. package/build/identity.mjs +45 -0
  26. package/build/index.d.mts +22 -0
  27. package/build/index.mjs +87 -0
  28. package/build/intl.mjs +121 -0
  29. package/build/metro.cjs +38 -0
  30. package/build/metro.d.cts +37 -0
  31. package/build/metroFrontend.mjs +222 -0
  32. package/build/metroMetadata.mjs +119 -0
  33. package/build/metroModules.mjs +397 -0
  34. package/build/metroRefresh.d.mts +64 -0
  35. package/build/metroRefresh.mjs +346 -0
  36. package/build/metroTransformer.cjs +146 -0
  37. package/build/nativeTextMemo.mjs +296 -0
  38. package/build/nativewind.d.mts +9 -0
  39. package/build/nativewind.mjs +92 -0
  40. package/build/project.d.mts +111 -0
  41. package/build/project.mjs +615 -0
  42. package/build/reactCompiler.mjs +113 -0
  43. package/build/reactProfile.cjs +35 -0
  44. package/build/refreshRuntime.mjs +187 -0
  45. package/build/refreshSourceMap.mjs +53 -0
  46. package/build/release.mjs +99 -0
  47. package/build/resolution.d.mts +3 -0
  48. package/build/resolution.mjs +25 -0
  49. package/build/surfaces.d.mts +1 -0
  50. package/build/surfaces.mjs +42 -0
  51. package/build/testing/node.d.mts +29 -0
  52. package/build/testing/node.mjs +106 -0
  53. package/build/yoga.d.mts +8 -0
  54. package/build/yoga.mjs +186 -0
  55. package/compatibility/public-api.json +327 -0
  56. package/compatibility/registry.json +2258 -0
  57. package/config/release.json +15 -0
  58. package/config/toolchain.json +34 -0
  59. package/docs/compatibility.md +813 -0
  60. package/docs/getting-started.md +460 -0
  61. package/docs/maintenance.md +362 -0
  62. package/docs/qualification.md +241 -0
  63. package/docs/standalone-testing.md +56 -0
  64. package/examples/hello-roku/README.md +35 -0
  65. package/examples/hello-roku/package.template.json +31 -0
  66. package/examples/hello-roku/pnpm-workspace.yaml +11 -0
  67. package/examples/hello-roku/roku.config.json +22 -0
  68. package/examples/hello-roku/src/App.tsx +54 -0
  69. package/examples/hello-roku/src/Catalog.tsx +200 -0
  70. package/examples/hello-roku/src/assets.d.ts +16 -0
  71. package/examples/hello-roku/src/catalog-cover.png +0 -0
  72. package/examples/hello-roku/tsconfig.json +1 -0
  73. package/examples/hello-roku/tsconfig.react.json +1 -0
  74. package/native/components/RNRAppControl.brs +215 -0
  75. package/native/components/RNRAppControl.xml +13 -0
  76. package/native/components/RNRDeviceFacts.brs +19 -0
  77. package/native/components/RNRDeviceFacts.xml +9 -0
  78. package/native/components/RNRDeviceFactsTask.brs +74 -0
  79. package/native/components/RNRDeviceFactsTask.xml +9 -0
  80. package/native/components/RNRTextRaster.brs +15 -0
  81. package/native/components/RNRTextRaster.xml +9 -0
  82. package/native/components/RNRTextRasterTask.brs +77 -0
  83. package/native/components/RNRTextRasterTask.xml +9 -0
  84. package/native/manifest.json +7 -0
  85. package/package.json +183 -3
  86. package/src/animation/clock.ts +10 -0
  87. package/src/animation/derivedValue.ts +163 -0
  88. package/src/animation/legacyAnimated.ts +255 -0
  89. package/src/animation/reanimated.ts +243 -0
  90. package/src/animation/sharedValue.ts +285 -0
  91. package/src/animation/worklets.ts +23 -0
  92. package/src/application/AppRegistry.ts +31 -0
  93. package/src/application/mountApplication.ts +136 -0
  94. package/src/graphics/BitmapLayer.tsx +68 -0
  95. package/src/graphics/RoundedBorder.tsx +116 -0
  96. package/src/graphics/TextRasterCache.ts +259 -0
  97. package/src/graphics/gradient.ts +37 -0
  98. package/src/graphics/inlineRaster.ts +85 -0
  99. package/src/graphics/png.ts +77 -0
  100. package/src/graphics/rasterPixels.ts +89 -0
  101. package/src/graphics/surfaces.ts +105 -0
  102. package/src/graphics/textRaster.types.ts +60 -0
  103. package/src/graphics/textRasterGeometry.ts +116 -0
  104. package/src/host/host.types.ts +57 -0
  105. package/src/index.ts +22 -0
  106. package/src/interop/nativewind.ts +2 -0
  107. package/src/layout/FontResources.ts +252 -0
  108. package/src/layout/affine.ts +89 -0
  109. package/src/layout/flexLayout.ts +398 -0
  110. package/src/layout/fontFaces.d.mts +19 -0
  111. package/src/layout/fontFaces.mjs +85 -0
  112. package/src/layout/fontVariants.d.mts +2 -0
  113. package/src/layout/fontVariants.mjs +8 -0
  114. package/src/layout/inlineParagraph.ts +158 -0
  115. package/src/layout/inlineText.ts +68 -0
  116. package/src/layout/layoutReuse.ts +117 -0
  117. package/src/layout/nativeNodeFields.ts +179 -0
  118. package/src/layout/preparedFields.ts +78 -0
  119. package/src/layout/textLayout.ts +138 -0
  120. package/src/layout/transform.ts +113 -0
  121. package/src/media/SceneGraphAudio.ts +161 -0
  122. package/src/media/SceneGraphVideo.ts +167 -0
  123. package/src/media/audioSession.ts +84 -0
  124. package/src/media/index.ts +2 -0
  125. package/src/media/videoErrorDetails.ts +40 -0
  126. package/src/media/videoSession.ts +136 -0
  127. package/src/navigation/RouterStore.ts +244 -0
  128. package/src/navigation/expoRouter.ts +115 -0
  129. package/src/react-native/NativeInput.ts +494 -0
  130. package/src/react-native/NativeSystemState.ts +95 -0
  131. package/src/react-native/accessibility.ts +265 -0
  132. package/src/react-native/activityIndicator.ts +72 -0
  133. package/src/react-native/compilerPressable.ts +26 -0
  134. package/src/react-native/createNativeRoot.ts +2126 -0
  135. package/src/react-native/directionalFocus.ts +55 -0
  136. package/src/react-native/environment.ts +275 -0
  137. package/src/react-native/flatList.ts +1001 -0
  138. package/src/react-native/flatListViewability.ts +231 -0
  139. package/src/react-native/focusEvents.ts +85 -0
  140. package/src/react-native/image.ts +247 -0
  141. package/src/react-native/index.ts +54 -0
  142. package/src/react-native/interactionManager.ts +76 -0
  143. package/src/react-native/keyboard.ts +60 -0
  144. package/src/react-native/linearGradient.ts +94 -0
  145. package/src/react-native/modal.tsx +148 -0
  146. package/src/react-native/nativeHostContext.ts +80 -0
  147. package/src/react-native/nativeModules.ts +86 -0
  148. package/src/react-native/nativeRoot.types.ts +22 -0
  149. package/src/react-native/nativeViewHandle.ts +191 -0
  150. package/src/react-native/nativewindPressable.ts +38 -0
  151. package/src/react-native/panResponder.ts +73 -0
  152. package/src/react-native/primitives.ts +685 -0
  153. package/src/react-native/safeArea.ts +76 -0
  154. package/src/react-native/scrollView.ts +289 -0
  155. package/src/react-native/styleInterop.ts +8 -0
  156. package/src/react-native/styleSheet.ts +54 -0
  157. package/src/react-native/textInput.ts +334 -0
  158. package/src/react-native/unsupported.ts +25 -0
  159. package/src/renderer/SceneRoot.ts +1006 -0
  160. package/src/scene/SdkDeviceFacts.ts +151 -0
  161. package/src/scene/SdkDeviceServices.ts +72 -0
  162. package/src/scene/SdkSceneGraph.ts +124 -0
  163. package/src/scene/SdkTextEntry.ts +321 -0
  164. package/src/scene/SdkTextMetrics.ts +136 -0
  165. package/src/scene/SdkTextRasterTransport.ts +191 -0
  166. package/src/scene/SdkWebTransport.ts +122 -0
  167. package/src/scene/createRokuHost.ts +213 -0
  168. package/src/scene/sceneGraph.types.ts +38 -0
  169. package/src/services/DeviceServices.ts +53 -0
  170. package/src/services/RegistryStorage.ts +85 -0
  171. package/src/services/RokuKeySession.ts +29 -0
  172. package/src/services/asyncStorage.ts +23 -0
  173. package/src/services/base64.ts +52 -0
  174. package/src/services/crypto.ts +18 -0
  175. package/src/services/expoConstants.ts +11 -0
  176. package/src/services/expoLinking.ts +12 -0
  177. package/src/services/expoStatusBar.ts +4 -0
  178. package/src/services/installWebRuntime.ts +105 -0
  179. package/src/services/intlEnglish.ts +54 -0
  180. package/src/services/languageRuntime.ts +65 -0
  181. package/src/services/nativeTimers.ts +96 -0
  182. package/src/services/secureStore.ts +23 -0
  183. package/src/services/textEntryRequest.ts +22 -0
  184. package/src/services/utf8.ts +57 -0
  185. package/src/services/webRuntime.ts +346 -0
  186. package/src/testing/CanvasResources.ts +141 -0
  187. package/src/testing/CanvasSceneGraph.ts +496 -0
  188. package/src/testing/CanvasTextEntry.ts +237 -0
  189. package/src/testing/PreviewTextObservations.ts +82 -0
  190. package/src/testing/RecordingSceneGraph.ts +136 -0
  191. package/src/types/normalize-colors.d.ts +4 -0
  192. package/src/vector/dynamicSvg.tsx +226 -0
  193. package/src/vector/svg.ts +222 -0
  194. package/src/vector/svg.types.ts +4 -0
  195. package/src/vector/svgElements.ts +58 -0
  196. package/src/vector/svgKey.d.mts +4 -0
  197. package/src/vector/svgKey.mjs +16 -0
  198. package/src/vector/svgPath.ts +157 -0
  199. package/src/vector/svgPixels.ts +133 -0
  200. package/tsconfig.consumer.json +29 -0
@@ -0,0 +1,296 @@
1
+ // A literal style object created inside this JSX expression has no application
2
+ // owner. Sharing the element is safe when its input is primitive, it has no
3
+ // attached ref, and both the text and every style value still agree.
4
+ export function nativeTextMemo(babel, selected) {
5
+ const { types: t, template } = babel;
6
+ const helpers = [];
7
+ const emitted = new WeakSet();
8
+ const scalarChildren = new WeakSet();
9
+ const scalarProps = new Set([
10
+ "nativeID",
11
+ "testID",
12
+ "disabled",
13
+ "focusable",
14
+ "accessible",
15
+ "accessibilityRole",
16
+ "accessibilityLabel",
17
+ "pointerEvents",
18
+ "importantForAccessibility",
19
+ "accessibilityElementsHidden",
20
+ ]);
21
+ const admitted = new Set([
22
+ "key",
23
+ "ref",
24
+ "style",
25
+ "children",
26
+ "onFocus",
27
+ "onFocusCapture",
28
+ "onBlur",
29
+ "onBlurCapture",
30
+ "onPress",
31
+ "onPressIn",
32
+ "onPressOut",
33
+ "onLongPress",
34
+ "delayLongPress",
35
+ "hasTVPreferredFocus",
36
+ ...scalarProps,
37
+ ]);
38
+ const nonWhitespace = (child) =>
39
+ !t.isJSXText(child) || child.value.trim() || !/[\r\n]/.test(child.value);
40
+ let markStyle, markElement;
41
+
42
+ const optsOut = (node) => node.directives?.some(({ value }) => value.value === "use no memo");
43
+ const fromNative = (path, name, names) => {
44
+ if (!t.isJSXIdentifier(name)) return false;
45
+ const binding = path.scope.getBinding(name.name)?.path;
46
+ return Boolean(
47
+ binding?.isImportSpecifier() &&
48
+ names.includes(binding.node.imported.name) &&
49
+ binding.parent.source.value === "react-native",
50
+ );
51
+ };
52
+
53
+ const retainPressableStyle = (path, program) => {
54
+ const element = path.node.openingElement;
55
+ if (
56
+ !fromNative(path, element.name, ["Pressable"]) ||
57
+ !element.attributes.every(
58
+ (attr) =>
59
+ t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name) && admitted.has(attr.name.name),
60
+ )
61
+ )
62
+ return false;
63
+ const attribute = element.attributes.find(
64
+ (attribute) => t.isJSXAttribute(attribute) && attribute.name.name === "style",
65
+ );
66
+ if (!t.isJSXExpressionContainer(attribute?.value)) return false;
67
+ const callback = attribute.value.expression;
68
+ if (!t.isArrowFunctionExpression(callback) || callback.async) return false;
69
+ const returned = t.isBlockStatement(callback.body) ? callback.body.body.at(-1) : undefined;
70
+ const literal = t.isReturnStatement(returned) ? returned.argument : callback.body;
71
+ if (!t.isObjectExpression(literal)) return false;
72
+ const properties = literal.properties;
73
+ if (
74
+ properties.length < 2 ||
75
+ properties.length > 12 ||
76
+ properties.some(
77
+ (property) =>
78
+ !t.isObjectProperty(property) ||
79
+ property.computed ||
80
+ (!t.isIdentifier(property.key) && !t.isStringLiteral(property.key)) ||
81
+ (property.key.name ?? property.key.value) === "__proto__",
82
+ )
83
+ )
84
+ return false;
85
+ if (
86
+ optsOut(program.path.node) ||
87
+ path.findParent((ancestor) => ancestor.isFunction() && optsOut(ancestor.node.body)) ||
88
+ program.hasBinding("Map", { noGlobals: true }) ||
89
+ program.hasBinding("Object", { noGlobals: true })
90
+ )
91
+ return false;
92
+
93
+ const candidates = properties.filter(({ value }) => !t.isLiteral(value));
94
+ if (candidates.length < 2) return false;
95
+ const keys = candidates.slice(0, 2).map((property) => properties.indexOf(property));
96
+ markStyle ??= program.generateUidIdentifier("markPressableStyle");
97
+ markElement ??= program.generateUidIdentifier("markPressableElement");
98
+ const helper = program.generateUidIdentifier("renderPressableStyle");
99
+ const storage = program.generateUidIdentifier("pressableStyles");
100
+ const size = program.generateUidIdentifier("pressableStyleCount");
101
+ const styles = properties.map(() => program.generateUidIdentifier("style"));
102
+ const [keyA, keyB] = keys.map((key) => styles[key].name);
103
+ const object = t.objectExpression(
104
+ properties.map(({ key }, index) =>
105
+ t.objectProperty(t.cloneNode(key), t.cloneNode(styles[index])),
106
+ ),
107
+ );
108
+ const same = styles
109
+ .map(({ name }, index) => `Object.is(previous[${index + 1}], ${name})`)
110
+ .join(" && ");
111
+ const cacheable = styles
112
+ .map(
113
+ ({ name }) =>
114
+ `(${name} === null || typeof ${name} === "undefined" || typeof ${name} === "number" || typeof ${name} === "boolean" || (typeof ${name} === "string" && ${name}.length <= 256))`,
115
+ )
116
+ .join(" && ");
117
+ const declaration = template.statement(`
118
+ function ${helper.name}() {
119
+ const cache = ${storage.name} ??= new Map();
120
+ let bucket = cache.get(${keyA});
121
+ const previous = bucket?.get(${keyB});
122
+ if (previous && ${same}) return previous[0];
123
+ const style = %%OBJECT%%;
124
+ if ((previous || ${size.name} < 64) && (${cacheable})) {
125
+ if (!bucket) cache.set(${keyA}, bucket = new Map());
126
+ if (!previous) ${size.name}++;
127
+ bucket.set(${keyB}, [${markStyle.name}(style), ${styles.map(({ name }) => name).join(", ")}]);
128
+ }
129
+ return style;
130
+ }
131
+ `)({ OBJECT: object });
132
+ declaration.params = styles;
133
+ helpers.push(
134
+ t.variableDeclaration("var", [
135
+ t.variableDeclarator(storage),
136
+ t.variableDeclarator(size, t.numericLiteral(0)),
137
+ ]),
138
+ declaration,
139
+ );
140
+ const cached = t.callExpression(
141
+ helper,
142
+ properties.map(({ value }) => value),
143
+ );
144
+ if (t.isReturnStatement(returned)) returned.argument = cached;
145
+ else callback.body = cached;
146
+ selected();
147
+ return true;
148
+ };
149
+ return {
150
+ visitor: {
151
+ JSXElement: {
152
+ enter(path, state) {
153
+ if (state.hasCustomJsxRuntime) return;
154
+ if (!path.getFunctionParent() || emitted.has(path.node)) return;
155
+ const program = path.scope.getProgramParent();
156
+ const node = path.node;
157
+ const { name, attributes } = node.openingElement;
158
+ if (!fromNative(path, name, ["Text"]) || attributes.length !== 1) return;
159
+ const parent = path.parentPath;
160
+ if (
161
+ !parent.isJSXElement() ||
162
+ !fromNative(parent, parent.node.openingElement.name, ["View", "Pressable"])
163
+ )
164
+ return;
165
+
166
+ const attr = attributes[0];
167
+ if (
168
+ !t.isJSXAttribute(attr) ||
169
+ attr.name.name !== "style" ||
170
+ !t.isJSXExpressionContainer(attr.value) ||
171
+ !t.isObjectExpression(attr.value.expression)
172
+ )
173
+ return;
174
+ const style = attr.value.expression.properties;
175
+ if (
176
+ !style.length ||
177
+ style.length > 12 ||
178
+ style.some(
179
+ (item) =>
180
+ !t.isObjectProperty(item) ||
181
+ item.computed ||
182
+ (!t.isIdentifier(item.key) && !t.isStringLiteral(item.key)) ||
183
+ (item.key.name ?? item.key.value) === "__proto__",
184
+ )
185
+ )
186
+ return;
187
+ const children = node.children.filter(nonWhitespace);
188
+ if (
189
+ children.length !== 1 ||
190
+ !t.isJSXExpressionContainer(children[0]) ||
191
+ t.isJSXEmptyExpression(children[0].expression)
192
+ )
193
+ return;
194
+
195
+ if (
196
+ optsOut(program.path.node) ||
197
+ path.findParent((ancestor) => ancestor.isFunction() && optsOut(ancestor.node.body)) ||
198
+ program.hasBinding("Map", { noGlobals: true }) ||
199
+ program.hasBinding("Object", { noGlobals: true })
200
+ )
201
+ return;
202
+ const helper = program.generateUidIdentifier("renderNativeText");
203
+ const storage = program.generateUidIdentifier("nativeTextCache");
204
+ const cache = program.generateUidIdentifier("cache");
205
+ const previous = program.generateUidIdentifier("previous");
206
+ const result = program.generateUidIdentifier("element");
207
+ const styles = style.map(() => program.generateUidIdentifier("style"));
208
+ const content = program.generateUidIdentifier("content");
209
+ const element = t.cloneNode(node);
210
+ element.openingElement.attributes[0].value.expression.properties = style.map(
211
+ (item, index) => t.objectProperty(t.cloneNode(item.key), t.cloneNode(styles[index])),
212
+ );
213
+ element.children = [t.jsxExpressionContainer(t.cloneNode(content))];
214
+ const sameValues = styles
215
+ .map(
216
+ (parameter, index) => `Object.is(${previous.name}[${index + 2}], ${parameter.name})`,
217
+ )
218
+ .join(" && ");
219
+ const primitiveStyles = styles
220
+ .map(
221
+ ({ name }) =>
222
+ `(${name} === null || typeof ${name} === "undefined" || (typeof ${name} === "string" && ${name}.length <= 256) || typeof ${name} === "number" || typeof ${name} === "boolean")`,
223
+ )
224
+ .join(" && ");
225
+ const declaration = template.statement(`
226
+ function ${helper.name}() {
227
+ const ${cache.name} = ${storage.name} ??= new Map();
228
+ const ${previous.name} = ${cache.name}.get(${content.name});
229
+ if (${previous.name} && Object.is(${previous.name}[1], ${content.name}) && ${sameValues})
230
+ return ${previous.name}[0];
231
+ const ${result.name} = %%ELEMENT%%;
232
+ if ((typeof ${content.name} === "number" || (typeof ${content.name} === "string" && ${content.name}.length <= 512))
233
+ && ${primitiveStyles} && (${previous.name} || ${cache.name}.size < 32))
234
+ ${cache.name}.set(${content.name}, [${[result, content, ...styles].map(({ name }) => name).join(", ")}]);
235
+ return ${result.name};
236
+ }
237
+ `)({ ELEMENT: element });
238
+ declaration.params = [...styles, content];
239
+ emitted.add(element);
240
+ helpers.push(t.variableDeclaration("var", [t.variableDeclarator(storage)]), declaration);
241
+ const scalar = t.jsxExpressionContainer(
242
+ t.callExpression(helper, [...style.map((item) => item.value), children[0].expression]),
243
+ );
244
+ scalarChildren.add(scalar);
245
+ path.replaceWith(scalar);
246
+ path.skip();
247
+ selected();
248
+ },
249
+ exit(path, state) {
250
+ if (state.hasCustomJsxRuntime || emitted.has(path.node) || !path.getFunctionParent())
251
+ return;
252
+ const contents = path.node.children.filter(nonWhitespace);
253
+ if (contents.length !== 1 || !scalarChildren.has(contents[0])) return;
254
+ const program = path.scope.getProgramParent();
255
+ if (!retainPressableStyle(path, program)) return;
256
+ const rawKeys = path.node.openingElement.attributes
257
+ .map(({ name }) => name.name)
258
+ .filter((name) => scalarProps.has(name));
259
+ const keys = program.generateUidIdentifier("pressableKeys");
260
+ helpers.push(t.variableDeclaration("var", [t.variableDeclarator(keys)]));
261
+ const storedKeys = t.assignmentExpression(
262
+ "??=",
263
+ keys,
264
+ t.arrayExpression(rawKeys.map((name) => t.stringLiteral(name))),
265
+ );
266
+ const needsContainer = path.listKey === "children" || path.parentPath.isJSXAttribute();
267
+ const node = t.cloneNode(path.node);
268
+ emitted.add(node);
269
+ const call = t.callExpression(markElement, [node, storedKeys]);
270
+ path.replaceWith(needsContainer ? t.jsxExpressionContainer(call) : call);
271
+ path.skip();
272
+ },
273
+ },
274
+ Program: {
275
+ enter(_path, state) {
276
+ state.hasCustomJsxRuntime = /@jsx(?:ImportSource|Runtime|Frag)?\b/.test(state.file.code);
277
+ },
278
+ exit(path) {
279
+ if (markStyle) {
280
+ path.unshiftContainer(
281
+ "body",
282
+ t.importDeclaration(
283
+ [
284
+ t.importSpecifier(markStyle, t.identifier("markPressableStyle")),
285
+ t.importSpecifier(markElement, t.identifier("markPressableElement")),
286
+ ],
287
+ t.stringLiteral("roku-compiler:pressable"),
288
+ ),
289
+ );
290
+ }
291
+ if (helpers.length) path.pushContainer("body", helpers);
292
+ },
293
+ },
294
+ },
295
+ };
296
+ }
@@ -0,0 +1,9 @@
1
+ import type { createRequire } from "node:module";
2
+ export declare function nativewindLeaf(
3
+ specifier: string,
4
+ importer: string,
5
+ require: ReturnType<typeof createRequire>,
6
+ ): string | null;
7
+ export declare function retainNativewindHookLifetimes(source: string): string;
8
+ export declare function prepareNativewindInterop(source: string, interopModule?: string): string;
9
+ export declare function prepareNativewindPreferences(source: string): string;
@@ -0,0 +1,92 @@
1
+ import { dirname, extname, resolve } from "node:path";
2
+
3
+ /** The pinned 0.2.6 standalone observable hooks subscribe during render but
4
+ * omit unmount cleanup. Keep this correction target-scoped and reject drift. */
5
+ export function retainNativewindHookLifetimes(source) {
6
+ const colorNeedle =
7
+ " (0, observable_1.cleanupEffect)(effect);\n return {\n colorScheme:";
8
+ const variableNeedle = " let value = (0, styles_1.getVariable)(name, context, effect);";
9
+ if (source.split(colorNeedle).length !== 2 || source.split(variableNeedle).length !== 2)
10
+ throw Error(
11
+ "Review the pinned NativeWind observable-hook lifetimes before updating the Roku adapter",
12
+ );
13
+ return source
14
+ .replace(
15
+ colorNeedle,
16
+ ` (0, react_1.useEffect)(() => {\n appearance_observables_1.colorScheme.get(effect);\n return () => (0, observable_1.cleanupEffect)(effect);\n }, [effect]);\n${colorNeedle}`,
17
+ )
18
+ .replace(
19
+ variableNeedle,
20
+ ` (0, react_1.useEffect)(() => {\n const current = (0, styles_1.getVariable)(name, context, effect);\n if (current && typeof current === "object" && "get" in current) current.get(effect);\n return () => (0, observable_1.cleanupEffect)(effect);\n }, [effect, name, context]);\n${variableNeedle}`,
21
+ );
22
+ }
23
+
24
+ /** Resolve only the approved portable NativeWind engine's native-style leaves. */
25
+ export function nativewindLeaf(specifier, importer, require) {
26
+ if (
27
+ !specifier.startsWith(".") ||
28
+ !/[\\/]node_modules[\\/](?:nativewind|react-native-css-interop)[\\/]/.test(importer)
29
+ )
30
+ return null;
31
+ const base = resolve(dirname(importer), specifier),
32
+ extension = extname(base);
33
+ const candidates = extension
34
+ ? [base.slice(0, -extension.length) + ".native" + extension]
35
+ : [base + ".native.js", resolve(base, "index.native.js")];
36
+ for (const path of candidates) {
37
+ try {
38
+ return require.resolve(path);
39
+ } catch {}
40
+ }
41
+ return null;
42
+ }
43
+
44
+ /** Pinned NativeWind registration interop; consumer-specific CSS stays outside. */
45
+ export function prepareNativewindInterop(
46
+ source,
47
+ interopModule = "react-native-roku/interop/nativewind",
48
+ ) {
49
+ const needle = "exports.interopComponents.set(baseComponent, component);";
50
+ const registration = "exports.interopComponents = new Map();";
51
+ for (const value of [needle, registration])
52
+ if (source.split(value).length !== 2)
53
+ throw Error(
54
+ "Review the pinned NativeWind component registry before updating the Roku adapter",
55
+ );
56
+ return retainNativewindHookLifetimes(source)
57
+ .replace(
58
+ needle,
59
+ `if (baseComponent === require("react-native").Pressable) component = require(${JSON.stringify(interopModule)}).withPressableStyleCallbacks(component);\n${needle}`,
60
+ )
61
+ .replace(
62
+ registration,
63
+ `${registration}\nrequire(${JSON.stringify(interopModule)}).installStyleInterop(component => exports.interopComponents.get(component) || component);`,
64
+ );
65
+ }
66
+
67
+ export function prepareNativewindPreferences(source) {
68
+ const needle = ".isReduceMotionEnabled()?.then(exports.isReduceMotionEnabled.set);";
69
+ if (source.split(needle).length !== 2)
70
+ throw Error("Review the pinned NativeWind preference probe before updating the Roku adapter");
71
+ return source.replace(
72
+ needle,
73
+ '.isReduceMotionEnabled()?.then(exports.isReduceMotionEnabled.set, error => { if (error?.code !== "C25_PREFERENCE_PENDING") throw error; console.warn("ROKU_PREFERENCE_PENDING", error.message); });',
74
+ );
75
+ }
76
+
77
+ /** TextInput already owns focus events. A synthetic no-op press for its focus
78
+ * styles must not turn the adapter's internal text display into pressable text.
79
+ * Keep authored press props explicit, and preserve the other component paths. */
80
+ export function prepareNativewindInputState(source) {
81
+ const needle = ` handlers.onPress = (event) => {
82
+ sharedState.originalProps?.onPress?.(event);
83
+ };`;
84
+ if (source.split(needle).length !== 2)
85
+ throw Error("Review the pinned NativeWind state-event bridge before updating the Roku adapter");
86
+ return source.replace(
87
+ needle,
88
+ ` if (component !== react_native_1.TextInput || sharedState.originalProps?.onPress) {
89
+ ${needle}
90
+ }`,
91
+ );
92
+ }
@@ -0,0 +1,111 @@
1
+ import type { FontFamilyGroups } from "../src/layout/fontFaces.mjs";
2
+ import type { RokuBuildProfile } from "./environment.mjs";
3
+ export interface RokuProjectConfig {
4
+ name: string;
5
+ entry: string;
6
+ displayName?: string;
7
+ entryMode?: "component" | "registry" | "mount";
8
+ bundler?: "esbuild" | "metro";
9
+ reactCompiler?: boolean;
10
+ storageNamespace?: string;
11
+ mountOptions?: Record<string, unknown>;
12
+ background?: string;
13
+ fonts?: {
14
+ defaultFamily: string;
15
+ assets: Record<string, string>;
16
+ families?: FontFamilyGroups;
17
+ variants?: readonly "tabular-nums"[];
18
+ };
19
+ viewport?: { width: number; height: number };
20
+ dev?: { port: number };
21
+ }
22
+ export declare function readRokuConfig(root?: string): RokuProjectConfig & {
23
+ fonts: NonNullable<RokuProjectConfig["fonts"]>;
24
+ viewport: { width: number; height: number };
25
+ background: string;
26
+ displayName: string;
27
+ bundler: "esbuild" | "metro";
28
+ };
29
+ export declare function resolveProjectFont(root: string, specifier: string): string;
30
+ export declare function generateSdkEntry(options: {
31
+ directory: string;
32
+ name?: string;
33
+ displayName?: string;
34
+ mountModule?: string;
35
+ mountExport?: string;
36
+ mountOptions?: Record<string, unknown>;
37
+ fontsModule?: string;
38
+ defaultFamily?: string;
39
+ fontFamilies?: FontFamilyGroups;
40
+ componentsModule?: string;
41
+ viewport?: { width: number; height: number };
42
+ background?: string;
43
+ storageNamespace?: string;
44
+ svgAtlasModule?: string;
45
+ cornerMasksModule?: string;
46
+ staticAssetsModule?: string;
47
+ buildIdentity?: {
48
+ inputFingerprint?: string;
49
+ runtimeSha256?: string;
50
+ frontendGraphSha256?: string;
51
+ };
52
+ }): { anchor: string; scene: string; entry: string; mainSource: string };
53
+ export declare function prepareRokuProject(
54
+ root?: string,
55
+ options?: {
56
+ outputDirectory?: string;
57
+ frontend?: boolean;
58
+ profile?: RokuBuildProfile;
59
+ refresh?: import("./metroRefresh.mjs").RokuMetroRefreshContext;
60
+ },
61
+ ): Promise<{
62
+ config: ReturnType<typeof readRokuConfig>;
63
+ directory: string;
64
+ generated: string;
65
+ profile: RokuBuildProfile;
66
+ fonts: ReturnType<typeof import("./fontVariants.mjs").prepareRokuFontAssets>;
67
+ imageAssets: Record<string, import("./assets.cjs").RokuImageAssetRecord>;
68
+ imageDirectory: string;
69
+ refreshGraph?: import("./metroRefresh.mjs").RokuMetroRefreshGraph;
70
+ native: { anchor: string; scene: string; entry: string; mainSource: string };
71
+ }>;
72
+ export declare function buildRokuProject(
73
+ root?: string,
74
+ options?: { profile?: RokuBuildProfile },
75
+ ): Promise<{ bundle: string; zip: string; profile: RokuBuildProfile }>;
76
+ export declare function doctorRokuProject(root?: string): {
77
+ status: string;
78
+ checks: Array<{ name: string; status: string; message?: string }>;
79
+ deviceQualified: boolean;
80
+ qualification: string;
81
+ };
82
+ export declare function buildRokuPreview(
83
+ root?: string,
84
+ options?: {
85
+ outputDirectory?: string;
86
+ profile?: RokuBuildProfile;
87
+ refresh?: import("./metroRefresh.mjs").RokuMetroRefreshContext;
88
+ },
89
+ ): Promise<string>;
90
+ export declare function devRokuProject(
91
+ root?: string,
92
+ options?: { profile?: RokuBuildProfile },
93
+ ): Promise<void>;
94
+ export declare function createRokuProjectDevServer(
95
+ root?: string,
96
+ options?: {
97
+ profile?: RokuBuildProfile;
98
+ port?: number;
99
+ onBuild?: (state: import("./dev.mjs").DevState) => void;
100
+ },
101
+ ): Promise<
102
+ Awaited<ReturnType<typeof import("./dev.mjs").createRokuDevServer>> & {
103
+ workspaceDirectory: string;
104
+ }
105
+ >;
106
+ export { prepareRokuFontAssets } from "./fontVariants.mjs";
107
+
108
+ export declare function createRokuSdkConfiguration(
109
+ root: string,
110
+ preBuild: () => Promise<void>,
111
+ ): import("@roku-sdk/rsg-ts/roku-config").RokuConfig;