@macify/mlx 0.0.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 (2) hide show
  1. package/build/index.cjs +55 -0
  2. package/package.json +32 -0
@@ -0,0 +1,55 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let expo_modules_core = require("expo-modules-core");
3
+
4
+ //#region src/MacifyMLXModule.ts
5
+ var MacifyMLXModule_default = (0, expo_modules_core.requireNativeModule)("MacifyMLX");
6
+
7
+ //#endregion
8
+ //#region src/index.ts
9
+ const emitter = new expo_modules_core.EventEmitter(MacifyMLXModule_default);
10
+ /**
11
+ * MLX-powered image generation for Mac Catalyst apps.
12
+ */
13
+ const mlx = {
14
+ async downloadModel(options = {}) {
15
+ let unsub;
16
+ if (options.onProgress) {
17
+ const subscription = emitter.addListener("onDownloadProgress", (event) => {
18
+ options.onProgress(event);
19
+ });
20
+ unsub = () => subscription.remove();
21
+ }
22
+ try {
23
+ await MacifyMLXModule_default.downloadModel();
24
+ } finally {
25
+ unsub?.();
26
+ }
27
+ },
28
+ async modelStatus() {
29
+ return MacifyMLXModule_default.modelStatus();
30
+ },
31
+ async deleteModel() {
32
+ return MacifyMLXModule_default.deleteModel();
33
+ },
34
+ async generateImage(options) {
35
+ const { prompt, steps = 4, seed = Math.floor(Math.random() * 1e6), autoDownload = true, keepModelLoaded = false, onProgress } = options;
36
+ let unsub;
37
+ if (onProgress) {
38
+ const subscription = emitter.addListener("onGenerationProgress", (event) => {
39
+ onProgress(event);
40
+ });
41
+ unsub = () => subscription.remove();
42
+ }
43
+ try {
44
+ return { uri: await MacifyMLXModule_default.generateImage(prompt, steps, seed, autoDownload, keepModelLoaded) };
45
+ } finally {
46
+ unsub?.();
47
+ }
48
+ },
49
+ async unloadModel() {
50
+ return MacifyMLXModule_default.unloadModel();
51
+ }
52
+ };
53
+
54
+ //#endregion
55
+ exports.mlx = mlx;
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@macify/mlx",
3
+ "version": "0.0.1",
4
+ "description": "MLX-powered image generation for Mac Catalyst Expo apps",
5
+ "main": "build/index.cjs",
6
+ "types": "build/index.d.cts",
7
+ "license": "MIT",
8
+ "scripts": {
9
+ "build": "tsdown"
10
+ },
11
+ "devDependencies": {
12
+ "@expo/config-plugins": "*",
13
+ "@macify/xcode-types": "workspace:*",
14
+ "tsdown": "*"
15
+ },
16
+ "peerDependencies": {
17
+ "expo-modules-core": "*",
18
+ "react": "*",
19
+ "react-native": "*"
20
+ },
21
+ "peerDependenciesMeta": {
22
+ "expo-modules-core": {
23
+ "optional": true
24
+ },
25
+ "react": {
26
+ "optional": true
27
+ },
28
+ "react-native": {
29
+ "optional": true
30
+ }
31
+ }
32
+ }