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
package/build/assets.cjs
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
const { createHash, randomUUID } = require("node:crypto");
|
|
2
|
+
const { createRequire } = require("node:module");
|
|
3
|
+
const {
|
|
4
|
+
existsSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
readdirSync,
|
|
8
|
+
renameSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
writeFileSync,
|
|
11
|
+
} = require("node:fs");
|
|
12
|
+
const { dirname, relative, resolve, sep } = require("node:path");
|
|
13
|
+
|
|
14
|
+
const sha = (value) => createHash("sha256").update(value).digest("hex");
|
|
15
|
+
const slash = (path) => path.split(sep).join("/");
|
|
16
|
+
function write(path, contents) {
|
|
17
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
18
|
+
const temporary = `${path}.${randomUUID()}.tmp`;
|
|
19
|
+
try {
|
|
20
|
+
writeFileSync(temporary, contents);
|
|
21
|
+
renameSync(temporary, path);
|
|
22
|
+
} finally {
|
|
23
|
+
rmSync(temporary, { force: true });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function settings(options) {
|
|
27
|
+
if (typeof options?.generatedDirectory !== "string" || !options.generatedDirectory)
|
|
28
|
+
throw Error("Roku image assets require an owned generatedDirectory");
|
|
29
|
+
const root = resolve(options.root ?? process.cwd());
|
|
30
|
+
const scale = options.scale ?? 1;
|
|
31
|
+
if (!(Number.isFinite(scale) && scale > 0)) throw Error("Roku image scale must be positive");
|
|
32
|
+
return { root, generatedDirectory: resolve(root, options.generatedDirectory), scale };
|
|
33
|
+
}
|
|
34
|
+
function recordImage(generatedDirectory, record) {
|
|
35
|
+
write(
|
|
36
|
+
resolve(
|
|
37
|
+
generatedDirectory,
|
|
38
|
+
"asset-metadata",
|
|
39
|
+
`${record.name}-${sha(record.source).slice(0, 24)}.json`,
|
|
40
|
+
),
|
|
41
|
+
JSON.stringify(record) + "\n",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Shared raster preparation for esbuild, Metro workers and cache-hit builds. */
|
|
46
|
+
exports.createRokuImageAssets = function createRokuImageAssets(options) {
|
|
47
|
+
const { root, generatedDirectory, scale } = settings(options);
|
|
48
|
+
let sharp;
|
|
49
|
+
const metadataDirectory = resolve(generatedDirectory, "asset-metadata");
|
|
50
|
+
if (options.reset) rmSync(metadataDirectory, { recursive: true, force: true });
|
|
51
|
+
function rasterTool() {
|
|
52
|
+
return (sharp ??= createRequire(resolve(root, "node_modules/@roku-sdk/tooling/package.json"))(
|
|
53
|
+
"sharp",
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
async function packageImage(content, source, extension) {
|
|
57
|
+
extension = extension.toLowerCase();
|
|
58
|
+
if (!["png", "jpg", "jpeg", "webp"].includes(extension))
|
|
59
|
+
throw Error(`Unsupported Roku raster asset: ${source}`);
|
|
60
|
+
if (typeof source !== "string" || !source)
|
|
61
|
+
throw Error("Roku raster assets require source identity");
|
|
62
|
+
const originalMetadata = await rasterTool()(content).metadata();
|
|
63
|
+
if ((originalMetadata.pages ?? 1) !== 1)
|
|
64
|
+
throw Error(`Roku raster needs a single static image: ${source}`);
|
|
65
|
+
const raster = extension === "webp" ? await rasterTool()(content).png().toBuffer() : content;
|
|
66
|
+
const suffix = extension === "webp" ? "png" : extension === "jpeg" ? "jpg" : extension;
|
|
67
|
+
const name = `asset-${sha(raster).slice(0, 24)}.${suffix}`;
|
|
68
|
+
const { width, height, pages } = await rasterTool()(raster).metadata();
|
|
69
|
+
if (!(width > 0 && height > 0) || (pages ?? 1) !== 1)
|
|
70
|
+
throw Error(`Roku raster needs a single static image with dimensions: ${source}`);
|
|
71
|
+
const output = resolve(generatedDirectory, "assets", name);
|
|
72
|
+
if (!existsSync(output) || !readFileSync(output).equals(raster)) write(output, raster);
|
|
73
|
+
recordImage(generatedDirectory, { name, source, width, height });
|
|
74
|
+
return { uri: `pkg:/images/${name}`, width, height };
|
|
75
|
+
}
|
|
76
|
+
async function prepareEmbeddedSource(path, original, { inline = false } = {}) {
|
|
77
|
+
if (resolve(root, path).startsWith(resolve(generatedDirectory, "embedded-images") + sep))
|
|
78
|
+
return original;
|
|
79
|
+
if (!original.includes("data:image/")) return original;
|
|
80
|
+
const ts = require("typescript");
|
|
81
|
+
const parsed = ts.createSourceFile(
|
|
82
|
+
path,
|
|
83
|
+
original,
|
|
84
|
+
ts.ScriptTarget.Latest,
|
|
85
|
+
true,
|
|
86
|
+
/\.[jt]sx$/.test(path) ? ts.ScriptKind.TSX : ts.ScriptKind.TS,
|
|
87
|
+
);
|
|
88
|
+
const literals = new Set();
|
|
89
|
+
const occurrences = [];
|
|
90
|
+
function visit(node) {
|
|
91
|
+
if (ts.isTypeNode(node) || ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node))
|
|
92
|
+
return;
|
|
93
|
+
if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
|
|
94
|
+
const parent = node.parent;
|
|
95
|
+
if (
|
|
96
|
+
ts.isTaggedTemplateExpression(parent) ||
|
|
97
|
+
(ts.isExpressionStatement(parent) && parent.expression === node) ||
|
|
98
|
+
((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) &&
|
|
99
|
+
parent.moduleSpecifier === node)
|
|
100
|
+
)
|
|
101
|
+
return;
|
|
102
|
+
// Libraries may concatenate a MIME prefix with a runtime payload.
|
|
103
|
+
// Only complete literals can become packaged build-time images.
|
|
104
|
+
if (/^data:image\/[^,]+,[\s\S]+$/.test(node.text)) {
|
|
105
|
+
literals.add(node.text);
|
|
106
|
+
occurrences.push(node);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
ts.forEachChild(node, visit);
|
|
110
|
+
}
|
|
111
|
+
visit(parsed);
|
|
112
|
+
const registrations = [];
|
|
113
|
+
const dependencies = new Map();
|
|
114
|
+
let alias = "__rokuRegisterPackagedImage";
|
|
115
|
+
while (original.includes(alias)) alias += "_";
|
|
116
|
+
for (const literal of literals) {
|
|
117
|
+
const match = /^data:image\/(png|jpe?g|webp);base64,([A-Za-z0-9+/]+={0,2})$/.exec(literal);
|
|
118
|
+
if (!match) throw Error(`Unsupported embedded Roku raster in ${path}`);
|
|
119
|
+
const content = Buffer.from(match[2], "base64");
|
|
120
|
+
if (content.toString("base64").replace(/=+$/, "") !== match[2].replace(/=+$/, ""))
|
|
121
|
+
throw Error(`Invalid embedded Roku raster in ${path}`);
|
|
122
|
+
const asset = await packageImage(
|
|
123
|
+
content,
|
|
124
|
+
`${slash(relative(root, path))}#embedded`,
|
|
125
|
+
match[1],
|
|
126
|
+
);
|
|
127
|
+
registrations.push(`${alias}(${JSON.stringify(literal)},${JSON.stringify(asset.uri)});`);
|
|
128
|
+
if (!inline) {
|
|
129
|
+
const dependency = resolve(
|
|
130
|
+
generatedDirectory,
|
|
131
|
+
"embedded-images",
|
|
132
|
+
`${asset.uri.split("/").at(-1)}-${sha(literal).slice(0, 24)}.mjs`,
|
|
133
|
+
);
|
|
134
|
+
write(
|
|
135
|
+
dependency,
|
|
136
|
+
`import {registerPackagedImage} from "react-native-roku/image";\nexport const source=registerPackagedImage(${JSON.stringify(literal)},${JSON.stringify(asset.uri)});\n`,
|
|
137
|
+
);
|
|
138
|
+
dependencies.set(literal, dependency);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Preserve every authored value, including schema-validated strings and
|
|
142
|
+
// JSX attributes. Static imports register the mapping before evaluation.
|
|
143
|
+
if (!registrations.length) return original;
|
|
144
|
+
if (!inline) {
|
|
145
|
+
let result = original;
|
|
146
|
+
for (const node of occurrences.sort((a, b) => b.getStart(parsed) - a.getStart(parsed))) {
|
|
147
|
+
let replacement = `require(${JSON.stringify(dependencies.get(node.text))}).source`;
|
|
148
|
+
if (ts.isJsxAttribute(node.parent)) replacement = `{${replacement}}`;
|
|
149
|
+
else if (node.parent.name === node) replacement = `[${replacement}]`;
|
|
150
|
+
result = result.slice(0, node.getStart(parsed)) + replacement + result.slice(node.end);
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
let insert = original.startsWith("#!") ? original.indexOf("\n") + 1 : 0;
|
|
155
|
+
for (const statement of parsed.statements) {
|
|
156
|
+
if (!ts.isExpressionStatement(statement) || !ts.isStringLiteral(statement.expression)) break;
|
|
157
|
+
insert = statement.end;
|
|
158
|
+
}
|
|
159
|
+
const prefix =
|
|
160
|
+
`\nimport {registerPackagedImage as ${alias}} from "react-native-roku/image";\n` +
|
|
161
|
+
registrations.join("\n") +
|
|
162
|
+
"\n";
|
|
163
|
+
return original.slice(0, insert) + prefix + original.slice(insert);
|
|
164
|
+
}
|
|
165
|
+
function inventory(used) {
|
|
166
|
+
const assets = new Map();
|
|
167
|
+
if (!existsSync(metadataDirectory)) return assets;
|
|
168
|
+
for (const name of readdirSync(metadataDirectory).sort()) {
|
|
169
|
+
if (!name.endsWith(".json")) continue;
|
|
170
|
+
const record = JSON.parse(readFileSync(resolve(metadataDirectory, name)));
|
|
171
|
+
if (used && !used.has(record.source.replace(/#embedded$/, ""))) continue;
|
|
172
|
+
const old = assets.get(record.name);
|
|
173
|
+
if (!old || record.source < old.source)
|
|
174
|
+
assets.set(record.name, {
|
|
175
|
+
source: record.source,
|
|
176
|
+
width: record.width,
|
|
177
|
+
height: record.height,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return new Map([...assets].sort(([a], [b]) => a.localeCompare(b)));
|
|
181
|
+
}
|
|
182
|
+
async function restoreMetroAssets(descriptors) {
|
|
183
|
+
if (!Array.isArray(descriptors))
|
|
184
|
+
throw Error("Roku image preparation needs Metro asset descriptors");
|
|
185
|
+
for (const descriptor of descriptors) {
|
|
186
|
+
const prepared = await exports.packageRokuMetroAsset(descriptor, {
|
|
187
|
+
root,
|
|
188
|
+
generatedDirectory,
|
|
189
|
+
scale,
|
|
190
|
+
});
|
|
191
|
+
if (
|
|
192
|
+
descriptor.rokuSource &&
|
|
193
|
+
JSON.stringify(descriptor.rokuSource) !== JSON.stringify(prepared.rokuSource)
|
|
194
|
+
)
|
|
195
|
+
throw Error(`Cached Roku raster changed during preparation: ${descriptor.name}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function metroConfiguration() {
|
|
199
|
+
const plugin = resolve(generatedDirectory, "image-asset-plugin.cjs");
|
|
200
|
+
const registry = resolve(generatedDirectory, "image-asset-registry.mjs");
|
|
201
|
+
write(
|
|
202
|
+
plugin,
|
|
203
|
+
`module.exports=data=>require(${JSON.stringify(__filename)}).packageRokuMetroAsset(data,${JSON.stringify({ root, generatedDirectory, scale })});\n`,
|
|
204
|
+
);
|
|
205
|
+
write(
|
|
206
|
+
registry,
|
|
207
|
+
'export function registerAsset(data){const source=data.rokuSource;if(!source||!/^pkg:\\/images\\/asset-[a-f0-9]{24}\\.(png|jpe?g)$/.test(source.uri))throw Error("Unprepared Roku raster asset");return source;}\n',
|
|
208
|
+
);
|
|
209
|
+
return { assetPlugins: [plugin], assetRegistryPath: registry };
|
|
210
|
+
}
|
|
211
|
+
function writeSdkModule(path, used) {
|
|
212
|
+
const assets = inventory(used);
|
|
213
|
+
write(
|
|
214
|
+
path,
|
|
215
|
+
[...assets.keys()]
|
|
216
|
+
.map((name, i) => {
|
|
217
|
+
const specifier = slash(
|
|
218
|
+
relative(dirname(path), resolve(generatedDirectory, "assets", name)),
|
|
219
|
+
);
|
|
220
|
+
return `import * as image${i} from ${JSON.stringify(specifier.startsWith(".") ? specifier : "./" + specifier)};`;
|
|
221
|
+
})
|
|
222
|
+
.join("\n") +
|
|
223
|
+
`\nexport const staticAssets:readonly {readonly uri:string}[]=[${[...assets.keys()].map((_, i) => `image${i}`).join(",")}];\n`,
|
|
224
|
+
);
|
|
225
|
+
return assets;
|
|
226
|
+
}
|
|
227
|
+
function esbuildPlugin() {
|
|
228
|
+
return {
|
|
229
|
+
name: "react-native-roku-images",
|
|
230
|
+
setup(builder) {
|
|
231
|
+
builder.onResolve({ filter: /.*/ }, (args) => {
|
|
232
|
+
const embedded = resolve(generatedDirectory, "embedded-images") + sep;
|
|
233
|
+
if (args.path.startsWith(embedded)) return { path: args.path };
|
|
234
|
+
if (args.importer.startsWith(embedded) && args.path === "react-native-roku/image")
|
|
235
|
+
return { path: createRequire(resolve(root, "package.json")).resolve(args.path) };
|
|
236
|
+
});
|
|
237
|
+
builder.onLoad({ filter: /\.(png|jpe?g|webp)$/i }, async ({ path }) => ({
|
|
238
|
+
loader: "json",
|
|
239
|
+
contents: JSON.stringify(
|
|
240
|
+
await packageImage(
|
|
241
|
+
readFileSync(path),
|
|
242
|
+
slash(relative(root, path)),
|
|
243
|
+
path.split(".").at(-1),
|
|
244
|
+
),
|
|
245
|
+
),
|
|
246
|
+
}));
|
|
247
|
+
builder.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, async ({ path }) => {
|
|
248
|
+
const original = readFileSync(path, "utf8");
|
|
249
|
+
if (!original.includes("data:image/")) return undefined;
|
|
250
|
+
const contents = await prepareEmbeddedSource(path, original);
|
|
251
|
+
if (contents === original) return undefined;
|
|
252
|
+
return {
|
|
253
|
+
contents,
|
|
254
|
+
loader: /\.tsx?$/.test(path) ? (path.endsWith("x") ? "tsx" : "ts") : "jsx",
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
packageImage,
|
|
262
|
+
prepareEmbeddedSource,
|
|
263
|
+
inventory,
|
|
264
|
+
restoreMetroAssets,
|
|
265
|
+
metroConfiguration,
|
|
266
|
+
writeSdkModule,
|
|
267
|
+
esbuildPlugin,
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/** Metro assetPlugin: choose the first adequate density, or the largest. */
|
|
272
|
+
exports.packageRokuMetroAsset = async function packageRokuMetroAsset(data, options) {
|
|
273
|
+
const normalized = settings(options);
|
|
274
|
+
if (
|
|
275
|
+
!Array.isArray(data.files) ||
|
|
276
|
+
!data.files.length ||
|
|
277
|
+
!Array.isArray(data.scales) ||
|
|
278
|
+
data.files.length !== data.scales.length ||
|
|
279
|
+
data.files.some((path) => typeof path !== "string") ||
|
|
280
|
+
data.scales.some((value) => !Number.isFinite(value) || value <= 0) ||
|
|
281
|
+
new Set(data.scales).size !== data.scales.length
|
|
282
|
+
)
|
|
283
|
+
throw Error("Review the Metro raster descriptor");
|
|
284
|
+
const ordered = data.scales.map((value, i) => ({ value, i })).sort((a, b) => a.value - b.value);
|
|
285
|
+
const selected = ordered.find((value) => value.value >= normalized.scale) ?? ordered.at(-1);
|
|
286
|
+
const compiler = exports.createRokuImageAssets(normalized);
|
|
287
|
+
const source = await compiler.packageImage(
|
|
288
|
+
readFileSync(data.files[selected.i]),
|
|
289
|
+
slash(relative(normalized.root, data.files[0])),
|
|
290
|
+
data.type,
|
|
291
|
+
);
|
|
292
|
+
const width = data.width ?? source.width / selected.value;
|
|
293
|
+
const height = data.height ?? source.height / selected.value;
|
|
294
|
+
if (
|
|
295
|
+
!(Number.isFinite(width) && width > 0 && Number.isFinite(height) && height > 0) ||
|
|
296
|
+
Math.abs(width - source.width / selected.value) > 1e-6 ||
|
|
297
|
+
Math.abs(height - source.height / selected.value) > 1e-6
|
|
298
|
+
)
|
|
299
|
+
throw Error(`Inconsistent Metro raster dimensions: ${data.name ?? data.files[0]}`);
|
|
300
|
+
// Metro can identify an asset group by any resolved density file. Associate
|
|
301
|
+
// the selected packaged raster with every physical member so SDK emission
|
|
302
|
+
// filtering retains the group even when no 1x source exists.
|
|
303
|
+
for (const path of data.files)
|
|
304
|
+
recordImage(normalized.generatedDirectory, {
|
|
305
|
+
name: source.uri.split("/").at(-1),
|
|
306
|
+
source: slash(relative(normalized.root, path)),
|
|
307
|
+
width: source.width,
|
|
308
|
+
height: source.height,
|
|
309
|
+
});
|
|
310
|
+
return { ...data, rokuSource: { ...source, width, height } };
|
|
311
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Plugin } from "esbuild";
|
|
2
|
+
|
|
3
|
+
export interface RokuImageAssetsOptions {
|
|
4
|
+
root?: string;
|
|
5
|
+
generatedDirectory: string;
|
|
6
|
+
/** Target raster density. The current logical-pixel host defaults to 1. */
|
|
7
|
+
scale?: number;
|
|
8
|
+
/** Clear owned metadata before a new build. Physical assets remain reusable. */
|
|
9
|
+
reset?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface RokuPackagedImage {
|
|
12
|
+
uri: string;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
16
|
+
export interface RokuImageAssetRecord {
|
|
17
|
+
source: string;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}
|
|
21
|
+
export interface RokuMetroRasterAsset {
|
|
22
|
+
files: readonly string[];
|
|
23
|
+
scales: readonly number[];
|
|
24
|
+
type: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
width?: number;
|
|
27
|
+
height?: number;
|
|
28
|
+
rokuSource?: RokuPackagedImage;
|
|
29
|
+
}
|
|
30
|
+
export declare function createRokuImageAssets(options: RokuImageAssetsOptions): {
|
|
31
|
+
packageImage(content: Uint8Array, source: string, extension: string): Promise<RokuPackagedImage>;
|
|
32
|
+
prepareEmbeddedSource(
|
|
33
|
+
path: string,
|
|
34
|
+
source: string,
|
|
35
|
+
options?: { inline?: boolean },
|
|
36
|
+
): Promise<string>;
|
|
37
|
+
inventory(usedSources?: ReadonlySet<string>): Map<string, RokuImageAssetRecord>;
|
|
38
|
+
restoreMetroAssets(descriptors: readonly RokuMetroRasterAsset[]): Promise<void>;
|
|
39
|
+
metroConfiguration(): { assetPlugins: string[]; assetRegistryPath: string };
|
|
40
|
+
writeSdkModule(
|
|
41
|
+
path: string,
|
|
42
|
+
usedSources?: ReadonlySet<string>,
|
|
43
|
+
): Map<string, RokuImageAssetRecord>;
|
|
44
|
+
/** Standalone esbuild compilation. Custom Babel owners call prepareEmbeddedSource themselves. */
|
|
45
|
+
esbuildPlugin(): Plugin;
|
|
46
|
+
};
|
|
47
|
+
export declare function packageRokuMetroAsset<T extends RokuMetroRasterAsset>(
|
|
48
|
+
descriptor: T,
|
|
49
|
+
options: RokuImageAssetsOptions,
|
|
50
|
+
): Promise<T & { rokuSource: RokuPackagedImage }>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface CompatibilityApi {
|
|
2
|
+
status: string;
|
|
3
|
+
members: string[];
|
|
4
|
+
props: string[];
|
|
5
|
+
openProps: boolean;
|
|
6
|
+
limitations?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CompatibilityModule {
|
|
9
|
+
adapter: string;
|
|
10
|
+
source: string;
|
|
11
|
+
version: string;
|
|
12
|
+
limitations: string;
|
|
13
|
+
contracts: string[];
|
|
14
|
+
device: string;
|
|
15
|
+
exports: Record<string, CompatibilityApi>;
|
|
16
|
+
}
|
|
17
|
+
export declare const compatibility: {
|
|
18
|
+
schema: string;
|
|
19
|
+
modules: Record<string, CompatibilityModule>;
|
|
20
|
+
contracts: Record<string, { tests: string[]; scope: string }>;
|
|
21
|
+
};
|
|
22
|
+
export declare function discoverAdapterSurface(
|
|
23
|
+
root: string,
|
|
24
|
+
modules?: Record<string, CompatibilityModule>,
|
|
25
|
+
): Record<string, Record<string, { members: string[]; props: string[]; openProps: boolean }>>;
|
|
26
|
+
export declare function auditCompatibility(options: {
|
|
27
|
+
root: string;
|
|
28
|
+
files: string[];
|
|
29
|
+
libraries?: Record<string, unknown>;
|
|
30
|
+
sourceOnly?: boolean;
|
|
31
|
+
workspacePrefixes?: string[];
|
|
32
|
+
}): {
|
|
33
|
+
schema: string;
|
|
34
|
+
status: string;
|
|
35
|
+
deviceQualified: boolean;
|
|
36
|
+
imports: Array<{ module: string }>;
|
|
37
|
+
dynamic: unknown[];
|
|
38
|
+
violations: Array<{ id: string; file: string; line: number; message: string; context: string }>;
|
|
39
|
+
limitations: string[];
|
|
40
|
+
};
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
2
|
+
import { resolve, relative } from "node:path";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
|
|
6
|
+
export const compatibility = JSON.parse(
|
|
7
|
+
readFileSync(new URL("../compatibility/registry.json", import.meta.url)),
|
|
8
|
+
);
|
|
9
|
+
export function discoverAdapterSurface(root, modules = compatibility.modules) {
|
|
10
|
+
const entries = Object.values(modules).map((module) => resolve(root, module.source));
|
|
11
|
+
const program = ts.createProgram(entries, {
|
|
12
|
+
target: ts.ScriptTarget.ES2022,
|
|
13
|
+
module: ts.ModuleKind.ESNext,
|
|
14
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
15
|
+
jsx: ts.JsxEmit.ReactJSX,
|
|
16
|
+
skipLibCheck: true,
|
|
17
|
+
esModuleInterop: true,
|
|
18
|
+
noEmit: true,
|
|
19
|
+
});
|
|
20
|
+
const checker = program.getTypeChecker(),
|
|
21
|
+
result = {};
|
|
22
|
+
for (const [name, module] of Object.entries(modules)) {
|
|
23
|
+
const source = program.getSourceFile(resolve(root, module.source));
|
|
24
|
+
const symbol = source && checker.getSymbolAtLocation(source);
|
|
25
|
+
if (!symbol) throw Error(`Cannot inspect adapter ${name}`);
|
|
26
|
+
const exports = {};
|
|
27
|
+
for (let item of checker.getExportsOfModule(symbol)) {
|
|
28
|
+
const exportName = item.name;
|
|
29
|
+
if (item.flags & ts.SymbolFlags.Alias) item = checker.getAliasedSymbol(item);
|
|
30
|
+
if (!(item.flags & ts.SymbolFlags.Value)) continue;
|
|
31
|
+
const declaration = item.valueDeclaration ?? item.declarations?.[0] ?? source;
|
|
32
|
+
const type = checker.getTypeOfSymbolAtLocation(item, declaration);
|
|
33
|
+
const members = checker
|
|
34
|
+
.getPropertiesOfType(type)
|
|
35
|
+
.map((member) => member.name)
|
|
36
|
+
.filter(
|
|
37
|
+
(value) =>
|
|
38
|
+
!value.startsWith("__") &&
|
|
39
|
+
!["prototype", "displayName", "defaultProps", "propTypes", "$$typeof"].includes(value),
|
|
40
|
+
)
|
|
41
|
+
.sort();
|
|
42
|
+
const props = new Set();
|
|
43
|
+
let openProps = false;
|
|
44
|
+
if (/^[A-Z]/.test(exportName))
|
|
45
|
+
for (const signature of type.getCallSignatures()) {
|
|
46
|
+
const parameter = signature.parameters[0];
|
|
47
|
+
if (parameter) {
|
|
48
|
+
const propsType = checker.getTypeOfSymbolAtLocation(parameter, declaration);
|
|
49
|
+
openProps ||= Boolean(propsType.getStringIndexType());
|
|
50
|
+
for (const prop of checker.getPropertiesOfType(propsType)) props.add(prop.name);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports[exportName] = { members, props: [...props].sort(), openProps };
|
|
54
|
+
}
|
|
55
|
+
result[name] = Object.fromEntries(
|
|
56
|
+
Object.entries(exports).sort(([a], [b]) => a.localeCompare(b)),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
/** Inventory the actual bundled source graph. Spreads/dynamic access remain explicit review evidence. */
|
|
62
|
+
export function auditCompatibility({
|
|
63
|
+
root,
|
|
64
|
+
files,
|
|
65
|
+
libraries = {},
|
|
66
|
+
sourceOnly = true,
|
|
67
|
+
workspacePrefixes = [],
|
|
68
|
+
}) {
|
|
69
|
+
const violations = [],
|
|
70
|
+
imports = [],
|
|
71
|
+
dynamic = [],
|
|
72
|
+
namespaces = new Map();
|
|
73
|
+
const known = compatibility.modules;
|
|
74
|
+
const issue = (file, line, message, suppliedContext) => {
|
|
75
|
+
const path = relative(root, file),
|
|
76
|
+
context = suppliedContext ?? readFileSync(file, "utf8").split("\n")[line - 1]?.trim() ?? "";
|
|
77
|
+
violations.push({
|
|
78
|
+
id: createHash("sha256").update([path, message, context].join("\n")).digest("hex"),
|
|
79
|
+
file: path,
|
|
80
|
+
line,
|
|
81
|
+
message,
|
|
82
|
+
context,
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
for (const path of files) {
|
|
86
|
+
const file = resolve(root, path);
|
|
87
|
+
if (
|
|
88
|
+
!/\.[cm]?[jt]sx?$/.test(file) ||
|
|
89
|
+
!existsSync(file) ||
|
|
90
|
+
(sourceOnly && file.split(/[\\/]/).includes("node_modules"))
|
|
91
|
+
)
|
|
92
|
+
continue;
|
|
93
|
+
const source = ts.createSourceFile(
|
|
94
|
+
file,
|
|
95
|
+
readFileSync(file, "utf8"),
|
|
96
|
+
ts.ScriptTarget.Latest,
|
|
97
|
+
true,
|
|
98
|
+
);
|
|
99
|
+
const bindings = new Map();
|
|
100
|
+
namespaces.clear();
|
|
101
|
+
const record = (specifier, names, line) => {
|
|
102
|
+
const module = known[specifier];
|
|
103
|
+
if (!module) {
|
|
104
|
+
if (
|
|
105
|
+
specifier.startsWith(".") ||
|
|
106
|
+
specifier.startsWith("/") ||
|
|
107
|
+
workspacePrefixes.some((prefix) => specifier.startsWith(prefix)) ||
|
|
108
|
+
specifier === "react-native-roku" ||
|
|
109
|
+
specifier.startsWith("react-native-roku/")
|
|
110
|
+
)
|
|
111
|
+
return;
|
|
112
|
+
const packageName = specifier.startsWith("@")
|
|
113
|
+
? specifier.split("/").slice(0, 2).join("/")
|
|
114
|
+
: specifier.split("/")[0];
|
|
115
|
+
if (!libraries[specifier] && !libraries[packageName])
|
|
116
|
+
issue(file, line, `Unreviewed library ${specifier}; add a versioned consumer contract`);
|
|
117
|
+
const library = libraries[specifier] ?? libraries[packageName];
|
|
118
|
+
if (library?.imports)
|
|
119
|
+
for (const name of names)
|
|
120
|
+
if (!library.imports.includes(name))
|
|
121
|
+
issue(file, line, `Unreviewed library API ${specifier}.${name}`);
|
|
122
|
+
imports.push({
|
|
123
|
+
file: relative(root, file),
|
|
124
|
+
line,
|
|
125
|
+
module: specifier,
|
|
126
|
+
names,
|
|
127
|
+
kind: "library",
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
imports.push({ file: relative(root, file), line, module: specifier, names, kind: "adapter" });
|
|
132
|
+
for (const name of names) {
|
|
133
|
+
if (name === "*") continue;
|
|
134
|
+
const api = module.exports[name];
|
|
135
|
+
if (!api) issue(file, line, `${specifier}.${name} has no registered Roku contract`);
|
|
136
|
+
else if (["unsupported", "review-required"].includes(api.status))
|
|
137
|
+
issue(
|
|
138
|
+
file,
|
|
139
|
+
line,
|
|
140
|
+
`${specifier}.${name} is ${api.status}: ${api.limitations ?? module.limitations}`,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
for (const node of source.statements) {
|
|
145
|
+
if (
|
|
146
|
+
!ts.isImportDeclaration(node) ||
|
|
147
|
+
!ts.isStringLiteralLike(node.moduleSpecifier) ||
|
|
148
|
+
node.importClause?.isTypeOnly
|
|
149
|
+
)
|
|
150
|
+
continue;
|
|
151
|
+
const specifier = node.moduleSpecifier.text,
|
|
152
|
+
clause = node.importClause,
|
|
153
|
+
names = [];
|
|
154
|
+
if (clause?.name) {
|
|
155
|
+
names.push("default");
|
|
156
|
+
bindings.set(clause.name.text, { specifier, name: "default" });
|
|
157
|
+
}
|
|
158
|
+
if (clause?.namedBindings) {
|
|
159
|
+
if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
160
|
+
names.push("*");
|
|
161
|
+
namespaces.set(clause.namedBindings.name.text, specifier);
|
|
162
|
+
} else
|
|
163
|
+
for (const item of clause.namedBindings.elements)
|
|
164
|
+
if (!item.isTypeOnly) {
|
|
165
|
+
const name = item.propertyName?.text ?? item.name.text;
|
|
166
|
+
names.push(name);
|
|
167
|
+
bindings.set(item.name.text, { specifier, name });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
record(specifier, names, source.getLineAndCharacterOfPosition(node.getStart()).line + 1);
|
|
171
|
+
}
|
|
172
|
+
const visit = (node) => {
|
|
173
|
+
const line = source.getLineAndCharacterOfPosition(node.getStart()).line + 1;
|
|
174
|
+
if (
|
|
175
|
+
ts.isExportDeclaration(node) &&
|
|
176
|
+
!node.isTypeOnly &&
|
|
177
|
+
node.moduleSpecifier &&
|
|
178
|
+
ts.isStringLiteralLike(node.moduleSpecifier)
|
|
179
|
+
) {
|
|
180
|
+
const names =
|
|
181
|
+
node.exportClause && ts.isNamedExports(node.exportClause)
|
|
182
|
+
? node.exportClause.elements
|
|
183
|
+
.filter((item) => !item.isTypeOnly)
|
|
184
|
+
.map((item) => item.propertyName?.text ?? item.name.text)
|
|
185
|
+
: ["*"];
|
|
186
|
+
record(node.moduleSpecifier.text, names, line);
|
|
187
|
+
}
|
|
188
|
+
if (
|
|
189
|
+
ts.isCallExpression(node) &&
|
|
190
|
+
(node.expression.kind === ts.SyntaxKind.ImportKeyword ||
|
|
191
|
+
(ts.isIdentifier(node.expression) && node.expression.text === "require"))
|
|
192
|
+
) {
|
|
193
|
+
const value = node.arguments[0];
|
|
194
|
+
if (value && ts.isStringLiteralLike(value)) {
|
|
195
|
+
const parent = node.parent;
|
|
196
|
+
const names =
|
|
197
|
+
ts.isVariableDeclaration(parent) && ts.isObjectBindingPattern(parent.name)
|
|
198
|
+
? parent.name.elements.map((item) => {
|
|
199
|
+
const name = item.propertyName?.getText(source) ?? item.name.getText(source);
|
|
200
|
+
bindings.set(item.name.getText(source), { specifier: value.text, name });
|
|
201
|
+
return name;
|
|
202
|
+
})
|
|
203
|
+
: ["*"];
|
|
204
|
+
if (ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name))
|
|
205
|
+
namespaces.set(parent.name.text, value.text);
|
|
206
|
+
record(value.text, names, line);
|
|
207
|
+
} else dynamic.push({ file: relative(root, file), line, kind: "nonliteral-module" });
|
|
208
|
+
}
|
|
209
|
+
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {
|
|
210
|
+
const namespace = namespaces.get(node.expression.text);
|
|
211
|
+
if (namespace) record(namespace, [node.name.text], line);
|
|
212
|
+
const binding = bindings.get(node.expression.text),
|
|
213
|
+
api = binding && known[binding.specifier]?.exports[binding.name];
|
|
214
|
+
if (api?.members.length && !api.members.includes(node.name.text))
|
|
215
|
+
issue(
|
|
216
|
+
file,
|
|
217
|
+
line,
|
|
218
|
+
`${binding.specifier}.${binding.name}.${node.name.text} has no registered member contract`,
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
222
|
+
const binding = bindings.get(node.tagName.getText(source));
|
|
223
|
+
const api = binding && known[binding.specifier]?.exports[binding.name];
|
|
224
|
+
if (api?.props.length)
|
|
225
|
+
for (const attribute of node.attributes.properties) {
|
|
226
|
+
if (ts.isJsxSpreadAttribute(attribute))
|
|
227
|
+
dynamic.push({
|
|
228
|
+
file: relative(root, file),
|
|
229
|
+
line,
|
|
230
|
+
kind: "spread-props",
|
|
231
|
+
api: binding.name,
|
|
232
|
+
});
|
|
233
|
+
else if (
|
|
234
|
+
!api.openProps &&
|
|
235
|
+
!["key", "ref"].includes(attribute.name.text) &&
|
|
236
|
+
!api.props.includes(attribute.name.text)
|
|
237
|
+
)
|
|
238
|
+
issue(
|
|
239
|
+
file,
|
|
240
|
+
line,
|
|
241
|
+
`${binding.specifier}.${binding.name} prop ${attribute.name.text} has no registered contract`,
|
|
242
|
+
attribute.getText(source).replace(/\s+/g, " "),
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (
|
|
247
|
+
ts.isElementAccessExpression(node) &&
|
|
248
|
+
ts.isIdentifier(node.expression) &&
|
|
249
|
+
(bindings.has(node.expression.text) || namespaces.has(node.expression.text))
|
|
250
|
+
) {
|
|
251
|
+
const namespace = namespaces.get(node.expression.text);
|
|
252
|
+
if (namespace && ts.isStringLiteralLike(node.argumentExpression))
|
|
253
|
+
record(namespace, [node.argumentExpression.text], line);
|
|
254
|
+
else dynamic.push({ file: relative(root, file), line, kind: "computed-api-access" });
|
|
255
|
+
}
|
|
256
|
+
ts.forEachChild(node, visit);
|
|
257
|
+
};
|
|
258
|
+
visit(source);
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
schema: "react-native-roku-import-audit/v1",
|
|
262
|
+
status: violations.length ? "failed" : "passed",
|
|
263
|
+
deviceQualified: false,
|
|
264
|
+
imports,
|
|
265
|
+
dynamic,
|
|
266
|
+
violations,
|
|
267
|
+
limitations: [
|
|
268
|
+
"Literal import/member/JSX checks; computed access and spread props require behavioral contracts",
|
|
269
|
+
"An exported type surface does not establish that every prop or method is implemented",
|
|
270
|
+
],
|
|
271
|
+
};
|
|
272
|
+
}
|