@capacitor-mlkit/genai-rewriting 8.1.0

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 (36) hide show
  1. package/CapacitorMlkitGenaiRewriting.podspec +17 -0
  2. package/LICENSE +201 -0
  3. package/README.md +429 -0
  4. package/android/build.gradle +60 -0
  5. package/android/src/main/AndroidManifest.xml +2 -0
  6. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/GenAiRewriting.java +159 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/GenAiRewritingPlugin.java +145 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/classes/events/DownloadProgressEvent.java +22 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/classes/events/InferenceProgressEvent.java +23 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/classes/options/FeatureOptions.java +72 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/classes/options/RewriteOptions.java +30 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/classes/results/CheckFeatureStatusResult.java +37 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/classes/results/RewriteResult.java +29 -0
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/interfaces/Callback.java +5 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/interfaces/EmptyCallback.java +5 -0
  16. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/interfaces/NonEmptyResultCallback.java +7 -0
  17. package/android/src/main/java/io/capawesome/capacitorjs/plugins/mlkit/genairewriting/interfaces/Result.java +7 -0
  18. package/android/src/main/res/.gitkeep +0 -0
  19. package/dist/docs.json +589 -0
  20. package/dist/esm/definitions.d.ts +251 -0
  21. package/dist/esm/definitions.js +107 -0
  22. package/dist/esm/definitions.js.map +1 -0
  23. package/dist/esm/index.d.ts +4 -0
  24. package/dist/esm/index.js +7 -0
  25. package/dist/esm/index.js.map +1 -0
  26. package/dist/esm/web.d.ts +8 -0
  27. package/dist/esm/web.js +16 -0
  28. package/dist/esm/web.js.map +1 -0
  29. package/dist/plugin.cjs.js +137 -0
  30. package/dist/plugin.cjs.js.map +1 -0
  31. package/dist/plugin.js +140 -0
  32. package/dist/plugin.js.map +1 -0
  33. package/ios/Plugin/GenAiRewritingPlugin.m +10 -0
  34. package/ios/Plugin/GenAiRewritingPlugin.swift +21 -0
  35. package/ios/Plugin/Info.plist +24 -0
  36. package/package.json +99 -0
package/dist/plugin.js ADDED
@@ -0,0 +1,140 @@
1
+ var capacitorGenAiRewriting = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * @since 8.2.0
6
+ */
7
+ exports.FeatureStatus = void 0;
8
+ (function (FeatureStatus) {
9
+ /**
10
+ * The feature is available to use.
11
+ *
12
+ * @since 8.2.0
13
+ */
14
+ FeatureStatus["Available"] = "AVAILABLE";
15
+ /**
16
+ * The feature can be downloaded using `downloadFeature(...)`.
17
+ *
18
+ * @since 8.2.0
19
+ */
20
+ FeatureStatus["Downloadable"] = "DOWNLOADABLE";
21
+ /**
22
+ * The feature is currently being downloaded.
23
+ *
24
+ * @since 8.2.0
25
+ */
26
+ FeatureStatus["Downloading"] = "DOWNLOADING";
27
+ /**
28
+ * The feature is not available on this device.
29
+ *
30
+ * @since 8.2.0
31
+ */
32
+ FeatureStatus["Unavailable"] = "UNAVAILABLE";
33
+ })(exports.FeatureStatus || (exports.FeatureStatus = {}));
34
+ /**
35
+ * @since 8.2.0
36
+ */
37
+ exports.Language = void 0;
38
+ (function (Language) {
39
+ /**
40
+ * @since 8.2.0
41
+ */
42
+ Language["English"] = "ENGLISH";
43
+ /**
44
+ * @since 8.2.0
45
+ */
46
+ Language["French"] = "FRENCH";
47
+ /**
48
+ * @since 8.2.0
49
+ */
50
+ Language["German"] = "GERMAN";
51
+ /**
52
+ * @since 8.2.0
53
+ */
54
+ Language["Italian"] = "ITALIAN";
55
+ /**
56
+ * @since 8.2.0
57
+ */
58
+ Language["Japanese"] = "JAPANESE";
59
+ /**
60
+ * @since 8.2.0
61
+ */
62
+ Language["Korean"] = "KOREAN";
63
+ /**
64
+ * @since 8.2.0
65
+ */
66
+ Language["Spanish"] = "SPANISH";
67
+ })(exports.Language || (exports.Language = {}));
68
+ /**
69
+ * @since 8.2.0
70
+ */
71
+ exports.OutputType = void 0;
72
+ (function (OutputType) {
73
+ /**
74
+ * Elaborate the input text.
75
+ *
76
+ * @since 8.2.0
77
+ */
78
+ OutputType["Elaborate"] = "ELABORATE";
79
+ /**
80
+ * Insert appropriate emojis into the input text.
81
+ *
82
+ * @since 8.2.0
83
+ */
84
+ OutputType["Emojify"] = "EMOJIFY";
85
+ /**
86
+ * Shorten the input text.
87
+ *
88
+ * @since 8.2.0
89
+ */
90
+ OutputType["Shorten"] = "SHORTEN";
91
+ /**
92
+ * Make the input text more friendly.
93
+ *
94
+ * @since 8.2.0
95
+ */
96
+ OutputType["Friendly"] = "FRIENDLY";
97
+ /**
98
+ * Make the input text more professional.
99
+ *
100
+ * @since 8.2.0
101
+ */
102
+ OutputType["Professional"] = "PROFESSIONAL";
103
+ /**
104
+ * Rephrase the input text.
105
+ *
106
+ * @since 8.2.0
107
+ */
108
+ OutputType["Rephrase"] = "REPHRASE";
109
+ })(exports.OutputType || (exports.OutputType = {}));
110
+
111
+ const GenAiRewriting = core.registerPlugin('GenAiRewriting', {
112
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.GenAiRewritingWeb()),
113
+ });
114
+
115
+ class GenAiRewritingWeb extends core.WebPlugin {
116
+ async checkFeatureStatus(_options) {
117
+ throw this.createUnimplementedException();
118
+ }
119
+ async downloadFeature(_options) {
120
+ throw this.createUnimplementedException();
121
+ }
122
+ async rewrite(_options) {
123
+ throw this.createUnimplementedException();
124
+ }
125
+ createUnimplementedException() {
126
+ return new core.CapacitorException('This plugin method is not implemented on this platform.', core.ExceptionCode.Unimplemented);
127
+ }
128
+ }
129
+
130
+ var web = /*#__PURE__*/Object.freeze({
131
+ __proto__: null,
132
+ GenAiRewritingWeb: GenAiRewritingWeb
133
+ });
134
+
135
+ exports.GenAiRewriting = GenAiRewriting;
136
+
137
+ return exports;
138
+
139
+ })({}, capacitorExports);
140
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * @since 8.2.0\n */\nexport var FeatureStatus;\n(function (FeatureStatus) {\n /**\n * The feature is available to use.\n *\n * @since 8.2.0\n */\n FeatureStatus[\"Available\"] = \"AVAILABLE\";\n /**\n * The feature can be downloaded using `downloadFeature(...)`.\n *\n * @since 8.2.0\n */\n FeatureStatus[\"Downloadable\"] = \"DOWNLOADABLE\";\n /**\n * The feature is currently being downloaded.\n *\n * @since 8.2.0\n */\n FeatureStatus[\"Downloading\"] = \"DOWNLOADING\";\n /**\n * The feature is not available on this device.\n *\n * @since 8.2.0\n */\n FeatureStatus[\"Unavailable\"] = \"UNAVAILABLE\";\n})(FeatureStatus || (FeatureStatus = {}));\n/**\n * @since 8.2.0\n */\nexport var Language;\n(function (Language) {\n /**\n * @since 8.2.0\n */\n Language[\"English\"] = \"ENGLISH\";\n /**\n * @since 8.2.0\n */\n Language[\"French\"] = \"FRENCH\";\n /**\n * @since 8.2.0\n */\n Language[\"German\"] = \"GERMAN\";\n /**\n * @since 8.2.0\n */\n Language[\"Italian\"] = \"ITALIAN\";\n /**\n * @since 8.2.0\n */\n Language[\"Japanese\"] = \"JAPANESE\";\n /**\n * @since 8.2.0\n */\n Language[\"Korean\"] = \"KOREAN\";\n /**\n * @since 8.2.0\n */\n Language[\"Spanish\"] = \"SPANISH\";\n})(Language || (Language = {}));\n/**\n * @since 8.2.0\n */\nexport var OutputType;\n(function (OutputType) {\n /**\n * Elaborate the input text.\n *\n * @since 8.2.0\n */\n OutputType[\"Elaborate\"] = \"ELABORATE\";\n /**\n * Insert appropriate emojis into the input text.\n *\n * @since 8.2.0\n */\n OutputType[\"Emojify\"] = \"EMOJIFY\";\n /**\n * Shorten the input text.\n *\n * @since 8.2.0\n */\n OutputType[\"Shorten\"] = \"SHORTEN\";\n /**\n * Make the input text more friendly.\n *\n * @since 8.2.0\n */\n OutputType[\"Friendly\"] = \"FRIENDLY\";\n /**\n * Make the input text more professional.\n *\n * @since 8.2.0\n */\n OutputType[\"Professional\"] = \"PROFESSIONAL\";\n /**\n * Rephrase the input text.\n *\n * @since 8.2.0\n */\n OutputType[\"Rephrase\"] = \"REPHRASE\";\n})(OutputType || (OutputType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst GenAiRewriting = registerPlugin('GenAiRewriting', {\n web: () => import('./web').then(m => new m.GenAiRewritingWeb()),\n});\nexport * from './definitions';\nexport { GenAiRewriting };\n//# sourceMappingURL=index.js.map","import { CapacitorException, ExceptionCode, WebPlugin } from '@capacitor/core';\nexport class GenAiRewritingWeb extends WebPlugin {\n async checkFeatureStatus(_options) {\n throw this.createUnimplementedException();\n }\n async downloadFeature(_options) {\n throw this.createUnimplementedException();\n }\n async rewrite(_options) {\n throw this.createUnimplementedException();\n }\n createUnimplementedException() {\n return new CapacitorException('This plugin method is not implemented on this platform.', ExceptionCode.Unimplemented);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["FeatureStatus","Language","OutputType","registerPlugin","WebPlugin","CapacitorException","ExceptionCode"],"mappings":";;;IAAA;IACA;IACA;AACWA;IACX,CAAC,UAAU,aAAa,EAAE;IAC1B;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,WAAW,CAAC,GAAG,WAAW;IAC5C;IACA;IACA;IACA;IACA;IACA,IAAI,aAAa,CAAC,cAAc,CAAC,GAAG,cAAc;IAClD;IACA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C,UAAU,CAAC,GAAG,UAAU;IACvC,CAAC,EAAEA,kBAAU,KAAKA,kBAAU,GAAG,EAAE,CAAC,CAAC;;ACxG9B,UAAC,cAAc,GAAGC,mBAAc,CAAC,gBAAgB,EAAE;IACxD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACnE,CAAC;;ICFM,MAAM,iBAAiB,SAASC,cAAS,CAAC;IACjD,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,4BAA4B,EAAE;IACjD,IAAI;IACJ,IAAI,MAAM,eAAe,CAAC,QAAQ,EAAE;IACpC,QAAQ,MAAM,IAAI,CAAC,4BAA4B,EAAE;IACjD,IAAI;IACJ,IAAI,MAAM,OAAO,CAAC,QAAQ,EAAE;IAC5B,QAAQ,MAAM,IAAI,CAAC,4BAA4B,EAAE;IACjD,IAAI;IACJ,IAAI,4BAA4B,GAAG;IACnC,QAAQ,OAAO,IAAIC,uBAAkB,CAAC,yDAAyD,EAAEC,kBAAa,CAAC,aAAa,CAAC;IAC7H,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,10 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(GenAiRewritingPlugin, "GenAiRewriting",
7
+ CAP_PLUGIN_METHOD(checkFeatureStatus, CAPPluginReturnPromise);
8
+ CAP_PLUGIN_METHOD(downloadFeature, CAPPluginReturnPromise);
9
+ CAP_PLUGIN_METHOD(rewrite, CAPPluginReturnPromise);
10
+ )
@@ -0,0 +1,21 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ @objc(GenAiRewritingPlugin)
5
+ public class GenAiRewritingPlugin: CAPPlugin {
6
+ @objc func checkFeatureStatus(_ call: CAPPluginCall) {
7
+ rejectCallAsUnavailable(call)
8
+ }
9
+
10
+ @objc func downloadFeature(_ call: CAPPluginCall) {
11
+ rejectCallAsUnavailable(call)
12
+ }
13
+
14
+ @objc func rewrite(_ call: CAPPluginCall) {
15
+ rejectCallAsUnavailable(call)
16
+ }
17
+
18
+ private func rejectCallAsUnavailable(_ call: CAPPluginCall) {
19
+ call.unavailable("This method is not available on this platform.")
20
+ }
21
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@capacitor-mlkit/genai-rewriting",
3
+ "version": "8.1.0",
4
+ "description": "Capacitor plugin for ML Kit GenAI Rewriting on Android.",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Plugin/",
14
+ "CapacitorMlkitGenaiRewriting.podspec"
15
+ ],
16
+ "author": "Robin Genz <mail@robingenz.dev>",
17
+ "license": "Apache-2.0",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/capawesome-team/capacitor-mlkit.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/capawesome-team/capacitor-mlkit/issues"
24
+ },
25
+ "funding": [
26
+ {
27
+ "type": "github",
28
+ "url": "https://github.com/sponsors/capawesome-team/"
29
+ },
30
+ {
31
+ "type": "opencollective",
32
+ "url": "https://opencollective.com/capawesome"
33
+ }
34
+ ],
35
+ "keywords": [
36
+ "capacitor",
37
+ "plugin",
38
+ "native",
39
+ "capacitor-plugin",
40
+ "mlkit",
41
+ "ml kit",
42
+ "genai",
43
+ "gemini nano",
44
+ "rewriting",
45
+ "rewrite",
46
+ "on-device ai"
47
+ ],
48
+ "scripts": {
49
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
50
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
51
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
52
+ "verify:web": "npm run build",
53
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
54
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
55
+ "eslint": "eslint . --ext ts",
56
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
57
+ "swiftlint": "node-swiftlint",
58
+ "docgen": "docgen --api GenAiRewritingPlugin --output-readme README.md --output-json dist/docs.json",
59
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
60
+ "clean": "rimraf ./dist",
61
+ "watch": "tsc --watch",
62
+ "ios:pod:install": "cd ios && pod install --repo-update && cd ..",
63
+ "ios:spm:install": "cd ios && swift package resolve && cd ..",
64
+ "prepublishOnly": "npm run build"
65
+ },
66
+ "devDependencies": {
67
+ "@capacitor/android": "8.0.0",
68
+ "@capacitor/cli": "8.0.0",
69
+ "@capacitor/core": "8.0.0",
70
+ "@capacitor/docgen": "0.3.1",
71
+ "@capacitor/ios": "8.0.0",
72
+ "@ionic/eslint-config": "0.4.0",
73
+ "eslint": "8.57.0",
74
+ "prettier-plugin-java": "2.6.7",
75
+ "rimraf": "6.1.2",
76
+ "rollup": "4.53.3",
77
+ "swiftlint": "2.0.0",
78
+ "typescript": "5.9.3"
79
+ },
80
+ "peerDependencies": {
81
+ "@capacitor/core": ">=8.0.0"
82
+ },
83
+ "swiftlint": "@ionic/swiftlint-config",
84
+ "eslintConfig": {
85
+ "extends": "@ionic/eslint-config/recommended"
86
+ },
87
+ "capacitor": {
88
+ "ios": {
89
+ "src": "ios"
90
+ },
91
+ "android": {
92
+ "src": "android"
93
+ }
94
+ },
95
+ "publishConfig": {
96
+ "access": "public"
97
+ },
98
+ "homepage": "https://capawesome.io/docs/sdks/capacitor/mlkit/genai-rewriting/"
99
+ }