@cap-kit/rank 8.0.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/CapKitRank.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +28 -0
  4. package/README.md +574 -0
  5. package/android/build.gradle +110 -0
  6. package/android/src/main/AndroidManifest.xml +16 -0
  7. package/android/src/main/java/io/capkit/rank/RankConfig.kt +72 -0
  8. package/android/src/main/java/io/capkit/rank/RankError.kt +40 -0
  9. package/android/src/main/java/io/capkit/rank/RankImpl.kt +240 -0
  10. package/android/src/main/java/io/capkit/rank/RankPlugin.kt +312 -0
  11. package/android/src/main/java/io/capkit/rank/utils/RankLogger.kt +85 -0
  12. package/android/src/main/java/io/capkit/rank/utils/RankUtils.kt +14 -0
  13. package/android/src/main/res/.gitkeep +0 -0
  14. package/dist/docs.json +441 -0
  15. package/dist/esm/definitions.d.ts +330 -0
  16. package/dist/esm/definitions.js +21 -0
  17. package/dist/esm/definitions.js.map +1 -0
  18. package/dist/esm/index.d.ts +16 -0
  19. package/dist/esm/index.js +19 -0
  20. package/dist/esm/index.js.map +1 -0
  21. package/dist/esm/web.d.ts +81 -0
  22. package/dist/esm/web.js +157 -0
  23. package/dist/esm/web.js.map +1 -0
  24. package/dist/plugin.cjs.js +204 -0
  25. package/dist/plugin.cjs.js.map +1 -0
  26. package/dist/plugin.js +207 -0
  27. package/dist/plugin.js.map +1 -0
  28. package/ios/Sources/RankPlugin/RankConfig.swift +89 -0
  29. package/ios/Sources/RankPlugin/RankError.swift +49 -0
  30. package/ios/Sources/RankPlugin/RankImpl.swift +186 -0
  31. package/ios/Sources/RankPlugin/RankPlugin.swift +258 -0
  32. package/ios/Sources/RankPlugin/Utils/RankLogger.swift +69 -0
  33. package/ios/Sources/RankPlugin/Utils/RankUtils.swift +45 -0
  34. package/ios/Sources/RankPlugin/Version.swift +16 -0
  35. package/ios/Tests/RankPluginTests/RankPluginTests.swift +10 -0
  36. package/package.json +102 -0
@@ -0,0 +1,204 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ /// <reference types="@capacitor/cli" />
6
+ /**
7
+ * Standardized error codes used by the Rank plugin.
8
+ *
9
+ * These codes are returned as part of structured error objects
10
+ * and allow consumers to implement programmatic error handling.
11
+ *
12
+ * @since 8.0.0
13
+ */
14
+ exports.RankErrorCode = void 0;
15
+ (function (RankErrorCode) {
16
+ /** The device does not have the requested hardware or the API is unavailable. */
17
+ RankErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
18
+ /** The user denied a required permission or the feature is disabled. */
19
+ RankErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
20
+ /** The Rank plugin failed to initialize (e.g., native SDK error). */
21
+ RankErrorCode["INIT_FAILED"] = "INIT_FAILED";
22
+ /** The requested operation or type is not valid or supported. */
23
+ RankErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
24
+ })(exports.RankErrorCode || (exports.RankErrorCode = {}));
25
+
26
+ /**
27
+ * @file index.ts
28
+ * This file exports the Rank and registers it with Capacitor.
29
+ * It acts as the main entry point for accessing the plugin's functionality
30
+ * across different platforms, including web.
31
+ */
32
+ /**
33
+ * Main entry point for the Rank Capacitor plugin.
34
+ *
35
+ * This file registers the plugin with Capacitor and exports
36
+ * both the runtime instance and the public TypeScript types.
37
+ */
38
+ const Rank = core.registerPlugin('Rank', {
39
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.RankWeb()),
40
+ });
41
+
42
+ /**
43
+ * Web implementation of the Rank plugin.
44
+ *
45
+ * This implementation exists primarily to satisfy Capacitor's
46
+ * multi-platform contract and to allow usage in browser-based
47
+ * environments.
48
+ *
49
+ * Native-only features like the In-App Review prompt are unavailable on Web.
50
+ */
51
+ class RankWeb extends core.WebPlugin {
52
+ constructor() {
53
+ super();
54
+ }
55
+ // --- Availability ---
56
+ /**
57
+ * On Web, native In-App Review is never available.
58
+ */
59
+ async isAvailable() {
60
+ return { value: false };
61
+ }
62
+ /**
63
+ * On Web, the review environment is not available, so this method returns a default result.
64
+ */
65
+ async checkReviewEnvironment() {
66
+ return {
67
+ canRequestReview: false,
68
+ };
69
+ }
70
+ // --- In-App Review ---
71
+ /**
72
+ * Requests the display of the native review popup.
73
+ *
74
+ * On Web, this feature is not available.
75
+ */
76
+ async requestReview() {
77
+ throw this.unimplemented('In-App Review is not available on Web.');
78
+ }
79
+ // --- Product Page Navigation ---
80
+ /**
81
+ * On Web, redirects to the store URL as an internal overlay is not possible.
82
+ */
83
+ async presentProductPage(options) {
84
+ return this.openStore(options);
85
+ }
86
+ // --- Store Navigation ---
87
+ /**
88
+ * Opens the app's page in the App Store or Play Store via URL redirect.
89
+ * @description Detects the user's platform to provide the correct store link.
90
+ * @param options Store identification overrides including appId for iOS or packageName for Android.
91
+ */
92
+ async openStore(options) {
93
+ if (!(options === null || options === void 0 ? void 0 : options.appId) && !(options === null || options === void 0 ? void 0 : options.packageName)) {
94
+ console.warn('Rank: No App ID or Package Name provided. Store redirect skipped.');
95
+ return;
96
+ }
97
+ const url = this.getStoreUrl(options);
98
+ if (!url) {
99
+ // URL construction failed due to missing or invalid identifiers
100
+ return;
101
+ }
102
+ window.open(url, '_blank');
103
+ }
104
+ /**
105
+ * Opens the App Store listing page for a specific app via URL redirect.
106
+ * @param options Store identification options.
107
+ */
108
+ async openStoreListing(options) {
109
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
110
+ if (isIOS && (options === null || options === void 0 ? void 0 : options.appId)) {
111
+ window.open(RankStoreUtils.appStoreUrl(options.appId), '_blank');
112
+ }
113
+ else {
114
+ console.warn('Rank: openStoreListing is primarily intended for iOS identifiers on Web.');
115
+ }
116
+ }
117
+ /**
118
+ * Redirects to the developer's page in the store.
119
+ * @param options.devId The developer ID to navigate to.
120
+ */
121
+ async openDevPage(options) {
122
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
123
+ const url = isIOS
124
+ ? RankStoreUtils.appStoreSearchUrl(options.devId) // iOS uses search for dev pages often
125
+ : RankStoreUtils.playStoreDevUrl(options.devId);
126
+ window.open(url, '_blank');
127
+ }
128
+ /**
129
+ * On Web, collection navigation is not supported, so this method logs a warning.
130
+ * @param options Collection identification (not used on Web).
131
+ * @description This method is a no-op on Web and serves as a placeholder for potential future functionality.
132
+ */
133
+ async openCollection() {
134
+ console.warn('Rank: openCollection is not available on Web.');
135
+ }
136
+ /**
137
+ * On Web, search navigation is not supported, so this method logs a warning and opens a generic search URL.
138
+ * @param options Search terms for finding the app in the store (not used on Web).
139
+ * @description Redirects to a generic search page on the respective store as a fallback.
140
+ */
141
+ async search(options) {
142
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
143
+ const url = isIOS
144
+ ? RankStoreUtils.appStoreSearchUrl(options.terms)
145
+ : RankStoreUtils.playStoreSearchUrl(options.terms);
146
+ window.open(url, '_blank');
147
+ }
148
+ // --- Internal Helpers ---
149
+ /**
150
+ * Generates the appropriate store URL based on user agent and provided options.
151
+ * * @param options Store options containing identifiers.
152
+ * @returns A string representing the full store URL.
153
+ */
154
+ getStoreUrl(options) {
155
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
156
+ if (isIOS && options.appId) {
157
+ return RankStoreUtils.appStoreUrl(options.appId);
158
+ }
159
+ return RankStoreUtils.playStoreUrl(options.packageName);
160
+ }
161
+ // --- Plugin Info ---
162
+ /**
163
+ * Returns the plugin version.
164
+ *
165
+ * On the Web, this value represents the JavaScript package version
166
+ * rather than a native implementation.
167
+ */
168
+ async getPluginVersion() {
169
+ return { version: 'web' };
170
+ }
171
+ }
172
+ /**
173
+ * Internal utility helpers for Store URL construction.
174
+ * Not part of the public API.
175
+ */
176
+ class RankStoreUtils {
177
+ static appStoreUrl(appId) {
178
+ return `https://apps.apple.com/app/id${appId}`;
179
+ }
180
+ static appStoreSearchUrl(terms) {
181
+ return `https://apps.apple.com/search?term=${encodeURIComponent(terms)}`;
182
+ }
183
+ static playStoreUrl(packageName) {
184
+ if (!packageName || packageName.trim().length === 0) {
185
+ console.warn('Rank: Missing Android packageName. Cannot construct Play Store URL.');
186
+ return '';
187
+ }
188
+ return `https://play.google.com/store/apps/details?id=${packageName}`;
189
+ }
190
+ static playStoreDevUrl(devId) {
191
+ return `https://play.google.com/store/apps/dev?id=${devId}`;
192
+ }
193
+ static playStoreSearchUrl(terms) {
194
+ return `https://play.google.com/store/search?q=${encodeURIComponent(terms)}&c=apps`;
195
+ }
196
+ }
197
+
198
+ var web = /*#__PURE__*/Object.freeze({
199
+ __proto__: null,
200
+ RankWeb: RankWeb
201
+ });
202
+
203
+ exports.Rank = Rank;
204
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n/**\n * Standardized error codes used by the Rank plugin.\n *\n * These codes are returned as part of structured error objects\n * and allow consumers to implement programmatic error handling.\n *\n * @since 8.0.0\n */\nexport var RankErrorCode;\n(function (RankErrorCode) {\n /** The device does not have the requested hardware or the API is unavailable. */\n RankErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied a required permission or the feature is disabled. */\n RankErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The Rank plugin failed to initialize (e.g., native SDK error). */\n RankErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** The requested operation or type is not valid or supported. */\n RankErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(RankErrorCode || (RankErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * @file index.ts\n * This file exports the Rank and registers it with Capacitor.\n * It acts as the main entry point for accessing the plugin's functionality\n * across different platforms, including web.\n */\nimport { registerPlugin } from '@capacitor/core';\n/**\n * Main entry point for the Rank Capacitor plugin.\n *\n * This file registers the plugin with Capacitor and exports\n * both the runtime instance and the public TypeScript types.\n */\nconst Rank = registerPlugin('Rank', {\n web: () => import('./web').then((m) => new m.RankWeb()),\n});\nexport * from './definitions';\nexport { Rank };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the Rank plugin.\n *\n * This implementation exists primarily to satisfy Capacitor's\n * multi-platform contract and to allow usage in browser-based\n * environments.\n *\n * Native-only features like the In-App Review prompt are unavailable on Web.\n */\nexport class RankWeb extends WebPlugin {\n constructor() {\n super();\n }\n // --- Availability ---\n /**\n * On Web, native In-App Review is never available.\n */\n async isAvailable() {\n return { value: false };\n }\n /**\n * On Web, the review environment is not available, so this method returns a default result.\n */\n async checkReviewEnvironment() {\n return {\n canRequestReview: false,\n };\n }\n // --- In-App Review ---\n /**\n * Requests the display of the native review popup.\n *\n * On Web, this feature is not available.\n */\n async requestReview() {\n throw this.unimplemented('In-App Review is not available on Web.');\n }\n // --- Product Page Navigation ---\n /**\n * On Web, redirects to the store URL as an internal overlay is not possible.\n */\n async presentProductPage(options) {\n return this.openStore(options);\n }\n // --- Store Navigation ---\n /**\n * Opens the app's page in the App Store or Play Store via URL redirect.\n * @description Detects the user's platform to provide the correct store link.\n * @param options Store identification overrides including appId for iOS or packageName for Android.\n */\n async openStore(options) {\n if (!(options === null || options === void 0 ? void 0 : options.appId) && !(options === null || options === void 0 ? void 0 : options.packageName)) {\n console.warn('Rank: No App ID or Package Name provided. Store redirect skipped.');\n return;\n }\n const url = this.getStoreUrl(options);\n if (!url) {\n // URL construction failed due to missing or invalid identifiers\n return;\n }\n window.open(url, '_blank');\n }\n /**\n * Opens the App Store listing page for a specific app via URL redirect.\n * @param options Store identification options.\n */\n async openStoreListing(options) {\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);\n if (isIOS && (options === null || options === void 0 ? void 0 : options.appId)) {\n window.open(RankStoreUtils.appStoreUrl(options.appId), '_blank');\n }\n else {\n console.warn('Rank: openStoreListing is primarily intended for iOS identifiers on Web.');\n }\n }\n /**\n * Redirects to the developer's page in the store.\n * @param options.devId The developer ID to navigate to.\n */\n async openDevPage(options) {\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);\n const url = isIOS\n ? RankStoreUtils.appStoreSearchUrl(options.devId) // iOS uses search for dev pages often\n : RankStoreUtils.playStoreDevUrl(options.devId);\n window.open(url, '_blank');\n }\n /**\n * On Web, collection navigation is not supported, so this method logs a warning.\n * @param options Collection identification (not used on Web).\n * @description This method is a no-op on Web and serves as a placeholder for potential future functionality.\n */\n async openCollection() {\n console.warn('Rank: openCollection is not available on Web.');\n }\n /**\n * On Web, search navigation is not supported, so this method logs a warning and opens a generic search URL.\n * @param options Search terms for finding the app in the store (not used on Web).\n * @description Redirects to a generic search page on the respective store as a fallback.\n */\n async search(options) {\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);\n const url = isIOS\n ? RankStoreUtils.appStoreSearchUrl(options.terms)\n : RankStoreUtils.playStoreSearchUrl(options.terms);\n window.open(url, '_blank');\n }\n // --- Internal Helpers ---\n /**\n * Generates the appropriate store URL based on user agent and provided options.\n * * @param options Store options containing identifiers.\n * @returns A string representing the full store URL.\n */\n getStoreUrl(options) {\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);\n if (isIOS && options.appId) {\n return RankStoreUtils.appStoreUrl(options.appId);\n }\n return RankStoreUtils.playStoreUrl(options.packageName);\n }\n // --- Plugin Info ---\n /**\n * Returns the plugin version.\n *\n * On the Web, this value represents the JavaScript package version\n * rather than a native implementation.\n */\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n/**\n * Internal utility helpers for Store URL construction.\n * Not part of the public API.\n */\nclass RankStoreUtils {\n static appStoreUrl(appId) {\n return `https://apps.apple.com/app/id${appId}`;\n }\n static appStoreSearchUrl(terms) {\n return `https://apps.apple.com/search?term=${encodeURIComponent(terms)}`;\n }\n static playStoreUrl(packageName) {\n if (!packageName || packageName.trim().length === 0) {\n console.warn('Rank: Missing Android packageName. Cannot construct Play Store URL.');\n return '';\n }\n return `https://play.google.com/store/apps/details?id=${packageName}`;\n }\n static playStoreDevUrl(devId) {\n return `https://play.google.com/store/apps/dev?id=${devId}`;\n }\n static playStoreSearchUrl(terms) {\n return `https://play.google.com/store/search?q=${encodeURIComponent(terms)}&c=apps`;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["RankErrorCode","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACWA;AACX,CAAC,UAAU,aAAa,EAAE;AAC1B;AACA,IAAI,aAAa,CAAC,aAAa,CAAC,GAAG,aAAa;AAChD;AACA,IAAI,aAAa,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;AAC5D;AACA,IAAI,aAAa,CAAC,aAAa,CAAC,GAAG,aAAa;AAChD;AACA,IAAI,aAAa,CAAC,cAAc,CAAC,GAAG,cAAc;AAClD,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;;ACnBzC;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACK,MAAC,IAAI,GAAGC,mBAAc,CAAC,MAAM,EAAE;AACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AAC3D,CAAC;;ACdD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,OAAO,SAASC,cAAS,CAAC;AACvC,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,EAAE;AACf,IAAI;AACJ;AACA;AACA;AACA;AACA,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;AAC/B,IAAI;AACJ;AACA;AACA;AACA,IAAI,MAAM,sBAAsB,GAAG;AACnC,QAAQ,OAAO;AACf,YAAY,gBAAgB,EAAE,KAAK;AACnC,SAAS;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;AACR,QAAQ,OAAO,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC;AAC/D,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA,MAAM,cAAc,CAAC;AACrB,IAAI,OAAO,WAAW,CAAC,KAAK,EAAE;AAC9B,QAAQ,OAAO,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;AACtD,IAAI;AACJ,IAAI,OAAO,iBAAiB,CAAC,KAAK,EAAE;AACpC,QAAQ,OAAO,CAAC,mCAAmC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF,IAAI;AACJ,IAAI,OAAO,YAAY,CAAC,WAAW,EAAE;AACrC,QAAQ,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7D,YAAY,OAAO,CAAC,IAAI,CAAC,qEAAqE,CAAC;AAC/F,YAAY,OAAO,EAAE;AACrB,QAAQ;AACR,QAAQ,OAAO,CAAC,8CAA8C,EAAE,WAAW,CAAC,CAAC;AAC7E,IAAI;AACJ,IAAI,OAAO,eAAe,CAAC,KAAK,EAAE;AAClC,QAAQ,OAAO,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;AACnE,IAAI;AACJ,IAAI,OAAO,kBAAkB,CAAC,KAAK,EAAE;AACrC,QAAQ,OAAO,CAAC,uCAAuC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC3F,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,207 @@
1
+ var capacitorRank = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /// <reference types="@capacitor/cli" />
5
+ /**
6
+ * Standardized error codes used by the Rank plugin.
7
+ *
8
+ * These codes are returned as part of structured error objects
9
+ * and allow consumers to implement programmatic error handling.
10
+ *
11
+ * @since 8.0.0
12
+ */
13
+ exports.RankErrorCode = void 0;
14
+ (function (RankErrorCode) {
15
+ /** The device does not have the requested hardware or the API is unavailable. */
16
+ RankErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
17
+ /** The user denied a required permission or the feature is disabled. */
18
+ RankErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
19
+ /** The Rank plugin failed to initialize (e.g., native SDK error). */
20
+ RankErrorCode["INIT_FAILED"] = "INIT_FAILED";
21
+ /** The requested operation or type is not valid or supported. */
22
+ RankErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
23
+ })(exports.RankErrorCode || (exports.RankErrorCode = {}));
24
+
25
+ /**
26
+ * @file index.ts
27
+ * This file exports the Rank and registers it with Capacitor.
28
+ * It acts as the main entry point for accessing the plugin's functionality
29
+ * across different platforms, including web.
30
+ */
31
+ /**
32
+ * Main entry point for the Rank Capacitor plugin.
33
+ *
34
+ * This file registers the plugin with Capacitor and exports
35
+ * both the runtime instance and the public TypeScript types.
36
+ */
37
+ const Rank = core.registerPlugin('Rank', {
38
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.RankWeb()),
39
+ });
40
+
41
+ /**
42
+ * Web implementation of the Rank plugin.
43
+ *
44
+ * This implementation exists primarily to satisfy Capacitor's
45
+ * multi-platform contract and to allow usage in browser-based
46
+ * environments.
47
+ *
48
+ * Native-only features like the In-App Review prompt are unavailable on Web.
49
+ */
50
+ class RankWeb extends core.WebPlugin {
51
+ constructor() {
52
+ super();
53
+ }
54
+ // --- Availability ---
55
+ /**
56
+ * On Web, native In-App Review is never available.
57
+ */
58
+ async isAvailable() {
59
+ return { value: false };
60
+ }
61
+ /**
62
+ * On Web, the review environment is not available, so this method returns a default result.
63
+ */
64
+ async checkReviewEnvironment() {
65
+ return {
66
+ canRequestReview: false,
67
+ };
68
+ }
69
+ // --- In-App Review ---
70
+ /**
71
+ * Requests the display of the native review popup.
72
+ *
73
+ * On Web, this feature is not available.
74
+ */
75
+ async requestReview() {
76
+ throw this.unimplemented('In-App Review is not available on Web.');
77
+ }
78
+ // --- Product Page Navigation ---
79
+ /**
80
+ * On Web, redirects to the store URL as an internal overlay is not possible.
81
+ */
82
+ async presentProductPage(options) {
83
+ return this.openStore(options);
84
+ }
85
+ // --- Store Navigation ---
86
+ /**
87
+ * Opens the app's page in the App Store or Play Store via URL redirect.
88
+ * @description Detects the user's platform to provide the correct store link.
89
+ * @param options Store identification overrides including appId for iOS or packageName for Android.
90
+ */
91
+ async openStore(options) {
92
+ if (!(options === null || options === void 0 ? void 0 : options.appId) && !(options === null || options === void 0 ? void 0 : options.packageName)) {
93
+ console.warn('Rank: No App ID or Package Name provided. Store redirect skipped.');
94
+ return;
95
+ }
96
+ const url = this.getStoreUrl(options);
97
+ if (!url) {
98
+ // URL construction failed due to missing or invalid identifiers
99
+ return;
100
+ }
101
+ window.open(url, '_blank');
102
+ }
103
+ /**
104
+ * Opens the App Store listing page for a specific app via URL redirect.
105
+ * @param options Store identification options.
106
+ */
107
+ async openStoreListing(options) {
108
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
109
+ if (isIOS && (options === null || options === void 0 ? void 0 : options.appId)) {
110
+ window.open(RankStoreUtils.appStoreUrl(options.appId), '_blank');
111
+ }
112
+ else {
113
+ console.warn('Rank: openStoreListing is primarily intended for iOS identifiers on Web.');
114
+ }
115
+ }
116
+ /**
117
+ * Redirects to the developer's page in the store.
118
+ * @param options.devId The developer ID to navigate to.
119
+ */
120
+ async openDevPage(options) {
121
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
122
+ const url = isIOS
123
+ ? RankStoreUtils.appStoreSearchUrl(options.devId) // iOS uses search for dev pages often
124
+ : RankStoreUtils.playStoreDevUrl(options.devId);
125
+ window.open(url, '_blank');
126
+ }
127
+ /**
128
+ * On Web, collection navigation is not supported, so this method logs a warning.
129
+ * @param options Collection identification (not used on Web).
130
+ * @description This method is a no-op on Web and serves as a placeholder for potential future functionality.
131
+ */
132
+ async openCollection() {
133
+ console.warn('Rank: openCollection is not available on Web.');
134
+ }
135
+ /**
136
+ * On Web, search navigation is not supported, so this method logs a warning and opens a generic search URL.
137
+ * @param options Search terms for finding the app in the store (not used on Web).
138
+ * @description Redirects to a generic search page on the respective store as a fallback.
139
+ */
140
+ async search(options) {
141
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
142
+ const url = isIOS
143
+ ? RankStoreUtils.appStoreSearchUrl(options.terms)
144
+ : RankStoreUtils.playStoreSearchUrl(options.terms);
145
+ window.open(url, '_blank');
146
+ }
147
+ // --- Internal Helpers ---
148
+ /**
149
+ * Generates the appropriate store URL based on user agent and provided options.
150
+ * * @param options Store options containing identifiers.
151
+ * @returns A string representing the full store URL.
152
+ */
153
+ getStoreUrl(options) {
154
+ const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
155
+ if (isIOS && options.appId) {
156
+ return RankStoreUtils.appStoreUrl(options.appId);
157
+ }
158
+ return RankStoreUtils.playStoreUrl(options.packageName);
159
+ }
160
+ // --- Plugin Info ---
161
+ /**
162
+ * Returns the plugin version.
163
+ *
164
+ * On the Web, this value represents the JavaScript package version
165
+ * rather than a native implementation.
166
+ */
167
+ async getPluginVersion() {
168
+ return { version: 'web' };
169
+ }
170
+ }
171
+ /**
172
+ * Internal utility helpers for Store URL construction.
173
+ * Not part of the public API.
174
+ */
175
+ class RankStoreUtils {
176
+ static appStoreUrl(appId) {
177
+ return `https://apps.apple.com/app/id${appId}`;
178
+ }
179
+ static appStoreSearchUrl(terms) {
180
+ return `https://apps.apple.com/search?term=${encodeURIComponent(terms)}`;
181
+ }
182
+ static playStoreUrl(packageName) {
183
+ if (!packageName || packageName.trim().length === 0) {
184
+ console.warn('Rank: Missing Android packageName. Cannot construct Play Store URL.');
185
+ return '';
186
+ }
187
+ return `https://play.google.com/store/apps/details?id=${packageName}`;
188
+ }
189
+ static playStoreDevUrl(devId) {
190
+ return `https://play.google.com/store/apps/dev?id=${devId}`;
191
+ }
192
+ static playStoreSearchUrl(terms) {
193
+ return `https://play.google.com/store/search?q=${encodeURIComponent(terms)}&c=apps`;
194
+ }
195
+ }
196
+
197
+ var web = /*#__PURE__*/Object.freeze({
198
+ __proto__: null,
199
+ RankWeb: RankWeb
200
+ });
201
+
202
+ exports.Rank = Rank;
203
+
204
+ return exports;
205
+
206
+ })({}, capacitorExports);
207
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n/**\n * Standardized error codes used by the Rank plugin.\n *\n * These codes are returned as part of structured error objects\n * and allow consumers to implement programmatic error handling.\n *\n * @since 8.0.0\n */\nexport var RankErrorCode;\n(function (RankErrorCode) {\n /** The device does not have the requested hardware or the API is unavailable. */\n RankErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied a required permission or the feature is disabled. */\n RankErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The Rank plugin failed to initialize (e.g., native SDK error). */\n RankErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** The requested operation or type is not valid or supported. */\n RankErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(RankErrorCode || (RankErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * @file index.ts\n * This file exports the Rank and registers it with Capacitor.\n * It acts as the main entry point for accessing the plugin's functionality\n * across different platforms, including web.\n */\nimport { registerPlugin } from '@capacitor/core';\n/**\n * Main entry point for the Rank Capacitor plugin.\n *\n * This file registers the plugin with Capacitor and exports\n * both the runtime instance and the public TypeScript types.\n */\nconst Rank = registerPlugin('Rank', {\n web: () => import('./web').then((m) => new m.RankWeb()),\n});\nexport * from './definitions';\nexport { Rank };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the Rank plugin.\n *\n * This implementation exists primarily to satisfy Capacitor's\n * multi-platform contract and to allow usage in browser-based\n * environments.\n *\n * Native-only features like the In-App Review prompt are unavailable on Web.\n */\nexport class RankWeb extends WebPlugin {\n constructor() {\n super();\n }\n // --- Availability ---\n /**\n * On Web, native In-App Review is never available.\n */\n async isAvailable() {\n return { value: false };\n }\n /**\n * On Web, the review environment is not available, so this method returns a default result.\n */\n async checkReviewEnvironment() {\n return {\n canRequestReview: false,\n };\n }\n // --- In-App Review ---\n /**\n * Requests the display of the native review popup.\n *\n * On Web, this feature is not available.\n */\n async requestReview() {\n throw this.unimplemented('In-App Review is not available on Web.');\n }\n // --- Product Page Navigation ---\n /**\n * On Web, redirects to the store URL as an internal overlay is not possible.\n */\n async presentProductPage(options) {\n return this.openStore(options);\n }\n // --- Store Navigation ---\n /**\n * Opens the app's page in the App Store or Play Store via URL redirect.\n * @description Detects the user's platform to provide the correct store link.\n * @param options Store identification overrides including appId for iOS or packageName for Android.\n */\n async openStore(options) {\n if (!(options === null || options === void 0 ? void 0 : options.appId) && !(options === null || options === void 0 ? void 0 : options.packageName)) {\n console.warn('Rank: No App ID or Package Name provided. Store redirect skipped.');\n return;\n }\n const url = this.getStoreUrl(options);\n if (!url) {\n // URL construction failed due to missing or invalid identifiers\n return;\n }\n window.open(url, '_blank');\n }\n /**\n * Opens the App Store listing page for a specific app via URL redirect.\n * @param options Store identification options.\n */\n async openStoreListing(options) {\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);\n if (isIOS && (options === null || options === void 0 ? void 0 : options.appId)) {\n window.open(RankStoreUtils.appStoreUrl(options.appId), '_blank');\n }\n else {\n console.warn('Rank: openStoreListing is primarily intended for iOS identifiers on Web.');\n }\n }\n /**\n * Redirects to the developer's page in the store.\n * @param options.devId The developer ID to navigate to.\n */\n async openDevPage(options) {\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);\n const url = isIOS\n ? RankStoreUtils.appStoreSearchUrl(options.devId) // iOS uses search for dev pages often\n : RankStoreUtils.playStoreDevUrl(options.devId);\n window.open(url, '_blank');\n }\n /**\n * On Web, collection navigation is not supported, so this method logs a warning.\n * @param options Collection identification (not used on Web).\n * @description This method is a no-op on Web and serves as a placeholder for potential future functionality.\n */\n async openCollection() {\n console.warn('Rank: openCollection is not available on Web.');\n }\n /**\n * On Web, search navigation is not supported, so this method logs a warning and opens a generic search URL.\n * @param options Search terms for finding the app in the store (not used on Web).\n * @description Redirects to a generic search page on the respective store as a fallback.\n */\n async search(options) {\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);\n const url = isIOS\n ? RankStoreUtils.appStoreSearchUrl(options.terms)\n : RankStoreUtils.playStoreSearchUrl(options.terms);\n window.open(url, '_blank');\n }\n // --- Internal Helpers ---\n /**\n * Generates the appropriate store URL based on user agent and provided options.\n * * @param options Store options containing identifiers.\n * @returns A string representing the full store URL.\n */\n getStoreUrl(options) {\n const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);\n if (isIOS && options.appId) {\n return RankStoreUtils.appStoreUrl(options.appId);\n }\n return RankStoreUtils.playStoreUrl(options.packageName);\n }\n // --- Plugin Info ---\n /**\n * Returns the plugin version.\n *\n * On the Web, this value represents the JavaScript package version\n * rather than a native implementation.\n */\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n/**\n * Internal utility helpers for Store URL construction.\n * Not part of the public API.\n */\nclass RankStoreUtils {\n static appStoreUrl(appId) {\n return `https://apps.apple.com/app/id${appId}`;\n }\n static appStoreSearchUrl(terms) {\n return `https://apps.apple.com/search?term=${encodeURIComponent(terms)}`;\n }\n static playStoreUrl(packageName) {\n if (!packageName || packageName.trim().length === 0) {\n console.warn('Rank: Missing Android packageName. Cannot construct Play Store URL.');\n return '';\n }\n return `https://play.google.com/store/apps/details?id=${packageName}`;\n }\n static playStoreDevUrl(devId) {\n return `https://play.google.com/store/apps/dev?id=${devId}`;\n }\n static playStoreSearchUrl(terms) {\n return `https://play.google.com/store/search?q=${encodeURIComponent(terms)}&c=apps`;\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["RankErrorCode","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AACWA;IACX,CAAC,UAAU,aAAa,EAAE;IAC1B;IACA,IAAI,aAAa,CAAC,aAAa,CAAC,GAAG,aAAa;IAChD;IACA,IAAI,aAAa,CAAC,mBAAmB,CAAC,GAAG,mBAAmB;IAC5D;IACA,IAAI,aAAa,CAAC,aAAa,CAAC,GAAG,aAAa;IAChD;IACA,IAAI,aAAa,CAAC,cAAc,CAAC,GAAG,cAAc;IAClD,CAAC,EAAEA,qBAAa,KAAKA,qBAAa,GAAG,EAAE,CAAC,CAAC;;ICnBzC;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;AACK,UAAC,IAAI,GAAGC,mBAAc,CAAC,MAAM,EAAE;IACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3D,CAAC;;ICdD;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACO,MAAM,OAAO,SAASC,cAAS,CAAC;IACvC,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,EAAE;IACf,IAAI;IACJ;IACA;IACA;IACA;IACA,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE;IAC/B,IAAI;IACJ;IACA;IACA;IACA,IAAI,MAAM,sBAAsB,GAAG;IACnC,QAAQ,OAAO;IACf,YAAY,gBAAgB,EAAE,KAAK;IACnC,SAAS;IACT,IAAI;IACJ;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,aAAa,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,wCAAwC,CAAC;IAC1E,IA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gB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;IACA;IACA;IACA;IACA;IACA,MAAM,cAAc,CAAC;IACrB,IAAI,OAAO,WAAW,CAAC,KAAK,EAAE;IAC9B,QAAQ,OAAO,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;IACtD,IAAI;IACJ,IAAI,OAAO,iBAAiB,CAAC,KAAK,EAAE;IACpC,QAAQ,OAAO,CAAC,mCAAmC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;IAChF,IAAI;IACJ,IAAI,OAAO,YAAY,CAAC,WAAW,EAAE;IACrC,QAAQ,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;IAC7D,YAAY,OAAO,CAAC,IAAI,CAAC,qEAAqE,CAAC;IAC/F,YAAY,OAAO,EAAE;IACrB,QAAQ;IACR,QAAQ,OAAO,CAAC,8CAA8C,EAAE,WAAW,CAAC,CAAC;IAC7E,IAAI;IACJ,IAAI,OAAO,eAAe,CAAC,KAAK,EAAE;IAClC,QAAQ,OAAO,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;IACnE,IAAI;IACJ,IAAI,OAAO,kBAAkB,CAAC,KAAK,EAAE;IACrC,QAAQ,OAAO,CAAC,uCAAuC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;IAC3F,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,89 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Plugin configuration container for the Rank plugin.
6
+ *
7
+ * This struct is responsible for reading and exposing static configuration
8
+ * values defined under the `Rank` key in `capacitor.config.ts`.
9
+ *
10
+ * Architectural rules:
11
+ * - Read once during plugin initialization (`load()`).
12
+ * - Treated as immutable runtime input.
13
+ * - Consumed only by native code (never by JavaScript).
14
+ */
15
+ public struct RankConfig {
16
+
17
+ // MARK: - Configuration Keys
18
+
19
+ /**
20
+ * Internal structure to maintain consistent configuration keys.
21
+ */
22
+ private struct Keys {
23
+ static let verboseLogging = "verboseLogging"
24
+ static let appleAppId = "appleAppId"
25
+ static let fireAndForget = "fireAndForget"
26
+ }
27
+
28
+ // MARK: - Public Properties
29
+
30
+ /**
31
+ * Enables verbose native logging via RankLogger.
32
+ *
33
+ * When enabled, additional debug information is printed to the Xcode console.
34
+ * Default: false
35
+ */
36
+ public let verboseLogging: Bool
37
+
38
+ /**
39
+ * Optional Apple App ID for App Store redirection.
40
+ *
41
+ * If provided, the plugin uses this ID to direct users to the specific review page.
42
+ * Default: nil
43
+ */
44
+ let appleAppId: String?
45
+
46
+ /**
47
+ * Global policy for review request resolution.
48
+ *
49
+ * If true, the plugin resolves promises immediately without awaiting OS feedback.
50
+ * Note: On iOS, this is the default behavior as StoreKit provides no completion callback.
51
+ * Default: false
52
+ */
53
+ let fireAndForget: Bool
54
+
55
+ // MARK: - Private Defaults
56
+
57
+ private static let defaultVerboseLogging: Bool = false
58
+ private static let defaultAppleAppId: String? = nil
59
+ private static let defaultFireAndForget: Bool = false
60
+
61
+ // MARK: - Initialization
62
+
63
+ /**
64
+ * Initializes the configuration by reading values from the Capacitor bridge.
65
+ *
66
+ * - Parameter plugin: The CAPPlugin instance used to access typed configuration via `getConfig()`.
67
+ */
68
+ init(plugin: CAPPlugin) {
69
+ let config = plugin.getConfig()
70
+
71
+ // Extract verboseLogging with fallback to default
72
+ self.verboseLogging = config.getBoolean(
73
+ Keys.verboseLogging,
74
+ Self.defaultVerboseLogging
75
+ )
76
+
77
+ // Extract optional appleAppId string
78
+ self.appleAppId = config.getString(
79
+ Keys.appleAppId,
80
+ Self.defaultAppleAppId
81
+ )
82
+
83
+ // Extract fireAndForget with fallback to default
84
+ self.fireAndForget = config.getBoolean(
85
+ Keys.fireAndForget,
86
+ Self.defaultFireAndForget
87
+ )
88
+ }
89
+ }
@@ -0,0 +1,49 @@
1
+ import Foundation
2
+
3
+ /**
4
+ Native error model for the Rank plugin (iOS).
5
+
6
+ This enum represents all error categories that can be
7
+ produced by the native implementation layer.
8
+
9
+ Architectural rules:
10
+ - Must NOT reference Capacitor
11
+ - Must NOT reference JavaScript
12
+ - Must be throwable from the Impl layer
13
+ - Mapping to JS-facing error codes happens ONLY in the Plugin layer
14
+ */
15
+ enum RankError: Error {
16
+
17
+ /// Feature or capability is not available on this device or configuration
18
+ case unavailable(String)
19
+
20
+ /// Required permission was denied or not granted
21
+ case permissionDenied(String)
22
+
23
+ /// Plugin failed to initialize or perform a required operation
24
+ case initFailed(String)
25
+
26
+ /// Invalid or unsupported input was provided
27
+ case unknownType(String)
28
+
29
+ // MARK: - Human-readable message
30
+
31
+ /**
32
+ Human-readable error message.
33
+
34
+ This message is intended to be passed verbatim
35
+ to JavaScript via `call.reject(message, code)`.
36
+ */
37
+ var message: String {
38
+ switch self {
39
+ case .unavailable(let message):
40
+ return message
41
+ case .permissionDenied(let message):
42
+ return message
43
+ case .initFailed(let message):
44
+ return message
45
+ case .unknownType(let message):
46
+ return message
47
+ }
48
+ }
49
+ }