Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/react-native-executorch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-executorch",
"version": "0.7.1",
"version": "0.7.2",
"description": "An easy way to run AI models in React Native with ExecuTorch",
"source": "./src/index.ts",
"main": "./lib/module/index.js",
Expand Down Expand Up @@ -67,8 +67,8 @@
},
"peerDependencies": {
"expo": ">=54.0.0",
"expo-asset": "^12.0.0",
"expo-file-system": "^19.0.0",
"expo-asset": ">=12.0.0",
"expo-file-system": ">=19.0.0",
"react": "*",
"react-native": "*"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ResourceFetcher } from '../../utils/ResourceFetcher';
import { ResourceSource } from '../../types/common';
import { BaseModule } from '../BaseModule';
import { Buffer } from 'buffer';

import { PNG } from 'pngjs/browser';
import { RnExecutorchErrorCode } from '../../errors/ErrorCodes';
import { RnExecutorchError } from '../../errors/errorUtils';
Expand Down Expand Up @@ -115,10 +115,15 @@ export class TextToImageModule extends BaseModule {
return '';
}
const png = new PNG({ width: imageSize, height: imageSize });
png.data = Buffer.from(outputArray);
png.data = outputArray as unknown as Buffer;
const pngBuffer = PNG.sync.write(png, { colorType: 6 });
const pngString = pngBuffer.toString('base64');
return pngString;
const pngArray = new Uint8Array(pngBuffer as unknown as ArrayBufferLike);
let binary = '';
const chunkSize = 8192;
for (let i = 0; i < pngArray.length; i += chunkSize) {
binary += String.fromCharCode(...pngArray.subarray(i, i + chunkSize));
}
return btoa(binary);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12966,8 +12966,8 @@ __metadata:
zod: "npm:^3.25.0"
peerDependencies:
expo: ">=54.0.0"
expo-asset: ^12.0.0
expo-file-system: ^19.0.0
expo-asset: ">=12.0.0"
expo-file-system: ">=19.0.0"
react: "*"
react-native: "*"
languageName: unknown
Expand Down
Loading