@capacitor-mlkit/genai-rewriting 8.2.0 → 8.2.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.
|
@@ -47,57 +47,51 @@ public class GenAiRewriting {
|
|
|
47
47
|
public void checkFeatureStatus(@NonNull FeatureOptions options, @NonNull NonEmptyResultCallback<CheckFeatureStatusResult> callback) {
|
|
48
48
|
Rewriter rewriter = getRewriter(options);
|
|
49
49
|
ListenableFuture<Integer> future = rewriter.checkFeatureStatus();
|
|
50
|
-
future.addListener(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
executor
|
|
60
|
-
);
|
|
50
|
+
future.addListener(() -> {
|
|
51
|
+
try {
|
|
52
|
+
int featureStatus = future.get();
|
|
53
|
+
callback.success(new CheckFeatureStatusResult(featureStatus));
|
|
54
|
+
} catch (Exception exception) {
|
|
55
|
+
callback.error(unwrapException(exception));
|
|
56
|
+
}
|
|
57
|
+
}, executor);
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
public void downloadFeature(@NonNull FeatureOptions options, @NonNull EmptyCallback callback) {
|
|
64
61
|
Rewriter rewriter = getRewriter(options);
|
|
65
62
|
ListenableFuture<Integer> future = rewriter.checkFeatureStatus();
|
|
66
|
-
future.addListener(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
rewriter.downloadFeature(
|
|
75
|
-
new DownloadCallback() {
|
|
76
|
-
@Override
|
|
77
|
-
public void onDownloadStarted(long bytesToDownload) {}
|
|
78
|
-
|
|
79
|
-
@Override
|
|
80
|
-
public void onDownloadProgress(long totalBytesDownloaded) {
|
|
81
|
-
plugin.notifyDownloadProgressListeners(new DownloadProgressEvent(totalBytesDownloaded));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@Override
|
|
85
|
-
public void onDownloadCompleted() {
|
|
86
|
-
callback.success();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@Override
|
|
90
|
-
public void onDownloadFailed(@NonNull GenAiException exception) {
|
|
91
|
-
callback.error(exception);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
);
|
|
95
|
-
} catch (Exception exception) {
|
|
96
|
-
callback.error(unwrapException(exception));
|
|
63
|
+
future.addListener(() -> {
|
|
64
|
+
try {
|
|
65
|
+
int featureStatus = future.get();
|
|
66
|
+
if (featureStatus == FeatureStatus.AVAILABLE) {
|
|
67
|
+
callback.success();
|
|
68
|
+
return;
|
|
97
69
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
70
|
+
rewriter.downloadFeature(
|
|
71
|
+
new DownloadCallback() {
|
|
72
|
+
@Override
|
|
73
|
+
public void onDownloadStarted(long bytesToDownload) {}
|
|
74
|
+
|
|
75
|
+
@Override
|
|
76
|
+
public void onDownloadProgress(long totalBytesDownloaded) {
|
|
77
|
+
plugin.notifyDownloadProgressListeners(new DownloadProgressEvent(totalBytesDownloaded));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Override
|
|
81
|
+
public void onDownloadCompleted() {
|
|
82
|
+
callback.success();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Override
|
|
86
|
+
public void onDownloadFailed(@NonNull GenAiException exception) {
|
|
87
|
+
callback.error(exception);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
} catch (Exception exception) {
|
|
92
|
+
callback.error(unwrapException(exception));
|
|
93
|
+
}
|
|
94
|
+
}, executor);
|
|
101
95
|
}
|
|
102
96
|
|
|
103
97
|
public void handleOnDestroy() {
|
|
@@ -110,21 +104,18 @@ public class GenAiRewriting {
|
|
|
110
104
|
ListenableFuture<RewritingResult> future = rewriter.runInference(request, additionalText ->
|
|
111
105
|
plugin.notifyInferenceProgressListeners(new InferenceProgressEvent(additionalText))
|
|
112
106
|
);
|
|
113
|
-
future.addListener(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
results.add(suggestion.getText());
|
|
120
|
-
}
|
|
121
|
-
callback.success(new RewriteResult(results));
|
|
122
|
-
} catch (Exception exception) {
|
|
123
|
-
callback.error(unwrapException(exception));
|
|
107
|
+
future.addListener(() -> {
|
|
108
|
+
try {
|
|
109
|
+
RewritingResult result = future.get();
|
|
110
|
+
List<String> results = new ArrayList<>();
|
|
111
|
+
for (RewritingSuggestion suggestion : result.getResults()) {
|
|
112
|
+
results.add(suggestion.getText());
|
|
124
113
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
callback.success(new RewriteResult(results));
|
|
115
|
+
} catch (Exception exception) {
|
|
116
|
+
callback.error(unwrapException(exception));
|
|
117
|
+
}
|
|
118
|
+
}, executor);
|
|
128
119
|
}
|
|
129
120
|
|
|
130
121
|
private void closeRewriter() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-mlkit/genai-rewriting",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.1",
|
|
4
4
|
"description": "Capacitor plugin for ML Kit GenAI Rewriting on Android.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@capacitor/android": "8.0.0",
|
|
68
|
-
"@capacitor/cli": "8.
|
|
68
|
+
"@capacitor/cli": "8.5.0",
|
|
69
69
|
"@capacitor/core": "8.0.0",
|
|
70
70
|
"@capacitor/docgen": "0.3.1",
|
|
71
71
|
"@capacitor/ios": "8.0.0",
|
|
72
72
|
"@ionic/eslint-config": "0.4.0",
|
|
73
73
|
"eslint": "8.57.0",
|
|
74
|
-
"prettier-plugin-java": "2.
|
|
74
|
+
"prettier-plugin-java": "2.9.7",
|
|
75
75
|
"rimraf": "6.1.2",
|
|
76
|
-
"rollup": "4.
|
|
76
|
+
"rollup": "4.62.3",
|
|
77
77
|
"swiftlint": "2.0.0",
|
|
78
78
|
"typescript": "5.9.3"
|
|
79
79
|
},
|