@cap-kit/test-plugin 1.0.2 → 5.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.
@@ -3,7 +3,7 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = 'CapKitTest'
6
+ s.name = 'CapKitTestPlugin'
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
  s.license = package['license']
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Fabio Martino
3
+ Copyright (c) 2026 CapKit Team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/Package.swift CHANGED
@@ -2,12 +2,12 @@
2
2
  import PackageDescription
3
3
 
4
4
  let package = Package(
5
- name: "CapKitTest",
5
+ name: "CapKitTestPlugin",
6
6
  platforms: [.iOS(.v15)],
7
7
  products: [
8
8
  .library(
9
- name: "CapKitTest",
10
- targets: ["TestPlugin"]
9
+ name: "CapKitTestPlugin",
10
+ targets: ["CapKitTestPlugin"]
11
11
  )
12
12
  ],
13
13
  dependencies: [
@@ -15,16 +15,12 @@ let package = Package(
15
15
  ],
16
16
  targets: [
17
17
  .target(
18
- name: "TestPlugin",
18
+ name: "CapKitTestPlugin",
19
19
  dependencies: [
20
20
  .product(name: "Capacitor", package: "capacitor-swift-pm"),
21
21
  .product(name: "Cordova", package: "capacitor-swift-pm")
22
22
  ],
23
23
  path: "ios/Sources/TestPlugin"
24
- ),
25
- .testTarget(
26
- name: "TestPluginTests",
27
- dependencies: ["TestPlugin"],
28
- path: "ios/Tests/TestPluginTests")
24
+ )
29
25
  ]
30
26
  )
package/README.md CHANGED
@@ -13,21 +13,31 @@
13
13
  </strong>
14
14
  </p>
15
15
 
16
- <p align="center">Test plugin for Cap-Kit.</p>
16
+ <p align="center">
17
+ The <strong>architectural reference implementation</strong> for the Cap-Kit ecosystem.<br>
18
+ This package serves as the definitive <strong>boilerplate and validation ground</strong> for creating new Capacitor plugins.<br>
19
+ It demonstrates the enforced monorepo structure, build configuration, and native bridges (Swift/Kotlin) required by our standards.<br>
20
+ <em>Note: This is an internal reference package, primarily used for CI verification and scaffolding.</em>
21
+ </p>
17
22
 
18
23
  <p align="center">
19
24
  <a href="https://www.npmjs.com/package/@cap-kit/test-plugin">
20
- <img src="https://img.shields.io/npm/v/@cap-kit/test-plugin?style=flat-square" />
25
+ <img src="https://img.shields.io/npm/v/@cap-kit/test-plugin?color=blue&label=npm&logo=npm&style=flat-square" alt="npm version">
21
26
  </a>
22
- <a href="https://www.npmjs.com/package/@cap-kit/test-plugin">
23
- <img src="https://img.shields.io/npm/dm/@cap-kit/test-plugin?style=flat-square" />
27
+ <a href="https://github.com/cap-kit/capacitor-plugins/actions">
28
+ <img src="https://img.shields.io/github/actions/workflow/status/cap-kit/capacitor-plugins/ci.yml?branch=main&label=CI&logo=github&style=flat-square" alt="CI Status" />
29
+ </a>
30
+ <a href="https://capacitorjs.com/">
31
+ <img src="https://img.shields.io/badge/Capacitor-Plugin-blue?logo=capacitor&style=flat-square" alt="Capacitor Plugin">
24
32
  </a>
25
33
  <a href="https://www.npmjs.com/package/@cap-kit/test-plugin">
26
- <img src="https://img.shields.io/npm/l/@cap-kit/test-plugin?style=flat-square" />
34
+ <img src="https://img.shields.io/npm/dm/@cap-kit/test-plugin?style=flat-square" alt="Downloads" />
27
35
  </a>
28
- <img src="https://img.shields.io/maintenance/yes/2026?style=flat-square" />
36
+ <a href="./LICENSE">
37
+ <img src="https://img.shields.io/npm/l/@cap-kit/test-plugin?style=flat-square&logo=open-source-initiative&logoColor=white&color=green" alt="License" />
38
+ </a>
39
+ <img src="https://img.shields.io/maintenance/yes/2026?style=flat-square" alt="Maintained" />
29
40
  </p>
30
-
31
41
  <br>
32
42
 
33
43
  ## Install
@@ -219,3 +229,21 @@ Result object returned by the `getPluginVersion()` method.
219
229
  ## Contributing
220
230
 
221
231
  Contributions are welcome! Please read the [contributing guide](CONTRIBUTING.md) before submitting a pull request.
232
+
233
+ ---
234
+
235
+ ## Credits
236
+
237
+ This plugin is based on prior work from the Community and
238
+ has been refactored and modernized for **Capacitor v8** and
239
+ **Swift Package Manager** compatibility.
240
+
241
+ Original inspiration:
242
+
243
+ - [https://github.com/](https://github.com/)
244
+
245
+ ---
246
+
247
+ ## License
248
+
249
+ MIT
@@ -71,7 +71,7 @@ android {
71
71
  buildTypes {
72
72
  release {
73
73
  minifyEnabled = false
74
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
74
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
75
75
  }
76
76
  }
77
77
  lint {
@@ -32,8 +32,11 @@ class TestImpl(
32
32
  */
33
33
  fun updateConfig(newConfig: TestConfig) {
34
34
  this.config = newConfig
35
- TestLogger.verbose = this.config.verboseLogging
36
- TestLogger.debug("Configuration updated. Verbose logging: ${this.config.verboseLogging}")
35
+ TestLogger.verbose = newConfig.verboseLogging
36
+ TestLogger.debug(
37
+ "Configuration applied. Verbose logging:",
38
+ newConfig.verboseLogging.toString(),
39
+ )
37
40
  }
38
41
 
39
42
  /**
@@ -3,14 +3,11 @@ package io.capkit.test
3
3
  import android.content.Intent
4
4
  import android.net.Uri
5
5
  import android.provider.Settings
6
- import androidx.activity.result.ActivityResult
7
6
  import com.getcapacitor.JSObject
8
7
  import com.getcapacitor.Plugin
9
8
  import com.getcapacitor.PluginCall
10
9
  import com.getcapacitor.PluginMethod
11
- import com.getcapacitor.annotation.ActivityCallback
12
10
  import com.getcapacitor.annotation.CapacitorPlugin
13
- import io.capkit.test.utils.TestLogger
14
11
 
15
12
  /**
16
13
  * Capacitor bridge for the Test plugin.
@@ -51,7 +48,7 @@ class TestPlugin : Plugin() {
51
48
  implementation.updateConfig(config)
52
49
  }
53
50
 
54
- // --- ---
51
+ // --- Echo ---
55
52
 
56
53
  /**
57
54
  * Echoes a string back to JavaScript.
@@ -60,21 +57,24 @@ class TestPlugin : Plugin() {
60
57
  */
61
58
  @PluginMethod
62
59
  fun echo(call: PluginCall) {
63
- var value = call.getString("value") ?: ""
64
- TestLogger.debug("Echoing value: $value")
60
+ val jsValue = call.getString("value") ?: ""
65
61
 
66
- // Append the custom message from the configuration
67
- value += config.customMessage
62
+ val valueToEcho =
63
+ if (jsValue.isNotEmpty()) {
64
+ jsValue
65
+ } else {
66
+ config.customMessage ?: ""
67
+ }
68
68
 
69
69
  val ret = JSObject()
70
- ret.put("value", implementation.echo(value))
70
+ ret.put("value", implementation.echo(valueToEcho))
71
71
  call.resolve(ret)
72
72
  }
73
73
 
74
- // --- Version ---
74
+ // --- Version ---
75
75
 
76
76
  /**
77
- * Returns the plugin version.
77
+ * Returns the native plugin version.
78
78
  */
79
79
  @PluginMethod
80
80
  fun getPluginVersion(call: PluginCall) {
@@ -95,22 +95,30 @@ class TestPlugin : Plugin() {
95
95
  val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
96
96
  val uri = Uri.fromParts("package", context.packageName, null)
97
97
  intent.data = uri
98
- startActivityForResult(call, intent, "openSettingsResult")
98
+ context.startActivity(intent)
99
99
  call.resolve()
100
100
  } catch (e: Exception) {
101
+ // NOTE:
102
+ // On Android, PluginCall.reject(...) is fully supported and correctly used here.
103
+ // However, this plugin is designed with a cross-platform, state-based API mindset
104
+ // to remain compatible with iOS when using Swift Package Manager (SPM),
105
+ // where Promise rejection is not reliably available.
106
+ //
107
+ // For this reason:
108
+ // - JavaScript consumers SHOULD NOT rely on try/catch for this method
109
+ // - Errors should be handled by inspecting resolved result states instead
110
+ //
111
+ // This reject() call is intentionally kept on Android to:
112
+ // - preserve native correctness
113
+ // - document the platform capability
114
+ // - avoid hiding real failures during development
115
+ //
116
+ // When extending this plugin, consider mirroring error semantics across platforms
117
+ // to keep the public JS API predictable and consistent.
101
118
  call.reject(
102
119
  "Failed to open settings",
103
120
  "UNAVAILABLE",
104
121
  )
105
122
  }
106
123
  }
107
-
108
- @ActivityCallback
109
- private fun openSettingsResult(
110
- call: PluginCall,
111
- result: ActivityResult,
112
- ) {
113
- // No-op, just to satisfy the callback requirement if needed
114
- call.resolve()
115
- }
116
124
  }
@@ -5,7 +5,7 @@ import android.util.Log
5
5
  /**
6
6
  * Centralized logging utility for the Test plugin.
7
7
  *
8
- * This logger provides a single entry point for all native logs
8
+ * This logging provides a single entry point for all native logs
9
9
  * and supports runtime-controlled verbose logging.
10
10
  *
11
11
  * The goal is to avoid scattering `if (verbose)` checks across
@@ -70,11 +70,11 @@ export interface TestConfig {
70
70
  export declare enum TestErrorCode {
71
71
  /** The device does not have the requested hardware. */
72
72
  UNAVAILABLE = "UNAVAILABLE",
73
- /** The user denied the permission or the feature is disabled in settings. */
73
+ /** The user denied the permission or the feature is disabled. */
74
74
  PERMISSION_DENIED = "PERMISSION_DENIED",
75
- /** The test plugin failed to initialize (e.g., runtime error or Looper failure). */
75
+ /** The TestPlugin failed to initialize (e.g., runtime error or Looper failure). */
76
76
  INIT_FAILED = "INIT_FAILED",
77
- /** The requested test plugin type is not valid or not supported by the plugin. */
77
+ /** The requested TestPlugin type is not valid or not supported by the plugin. */
78
78
  UNKNOWN_TYPE = "UNKNOWN_TYPE"
79
79
  }
80
80
  /**
@@ -15,11 +15,11 @@ export var TestErrorCode;
15
15
  (function (TestErrorCode) {
16
16
  /** The device does not have the requested hardware. */
17
17
  TestErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
18
- /** The user denied the permission or the feature is disabled in settings. */
18
+ /** The user denied the permission or the feature is disabled. */
19
19
  TestErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
20
- /** The test plugin failed to initialize (e.g., runtime error or Looper failure). */
20
+ /** The TestPlugin failed to initialize (e.g., runtime error or Looper failure). */
21
21
  TestErrorCode["INIT_FAILED"] = "INIT_FAILED";
22
- /** The requested test plugin type is not valid or not supported by the plugin. */
22
+ /** The requested TestPlugin type is not valid or not supported by the plugin. */
23
23
  TestErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
24
24
  })(TestErrorCode || (TestErrorCode = {}));
25
25
  //# sourceMappingURL=definitions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AA8DxC;;;;;;;;;;;GAWG;AACH,MAAM,CAAN,IAAY,aASX;AATD,WAAY,aAAa;IACvB,uDAAuD;IACvD,4CAA2B,CAAA;IAC3B,6EAA6E;IAC7E,wDAAuC,CAAA;IACvC,oFAAoF;IACpF,4CAA2B,CAAA;IAC3B,kFAAkF;IAClF,8CAA6B,CAAA;AAC/B,CAAC,EATW,aAAa,KAAb,aAAa,QASxB"}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC;AA8DxC;;;;;;;;;;;GAWG;AACH,MAAM,CAAN,IAAY,aASX;AATD,WAAY,aAAa;IACvB,uDAAuD;IACvD,4CAA2B,CAAA;IAC3B,iEAAiE;IACjE,wDAAuC,CAAA;IACvC,mFAAmF;IACnF,4CAA2B,CAAA;IAC3B,iFAAiF;IACjF,8CAA6B,CAAA;AAC/B,CAAC,EATW,aAAa,KAAb,aAAa,QASxB"}
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @file index.ts
3
- * This file exports the TestPlugin and registers it with Capacitor.
3
+ * This file exports the Test and registers it with Capacitor.
4
4
  * It acts as the main entry point for accessing the plugin's functionality
5
5
  * across different platforms, including web.
6
6
  */
7
- import type { TestPlugin } from './definitions';
7
+ import { TestPlugin } from './definitions';
8
8
  /**
9
9
  * Main entry point for the Test Capacitor plugin.
10
10
  *
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file index.ts
3
- * This file exports the TestPlugin and registers it with Capacitor.
3
+ * This file exports the Test and registers it with Capacitor.
4
4
  * It acts as the main entry point for accessing the plugin's functionality
5
5
  * across different platforms, including web.
6
6
  */
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { TestPlugin } from './definitions';
2
+ import { TestPlugin, EchoOptions, EchoResult, PluginVersionResult } from './definitions';
3
3
  /**
4
4
  * Web implementation of the Test plugin.
5
5
  *
@@ -19,11 +19,7 @@ export declare class TestWeb extends WebPlugin implements TestPlugin {
19
19
  * @param options - An object containing a `value` property to be echoed back.
20
20
  * @returns A promise resolving to an object containing the echoed `value`.
21
21
  */
22
- echo(options: {
23
- value: string;
24
- }): Promise<{
25
- value: string;
26
- }>;
22
+ echo(options: EchoOptions): Promise<EchoResult>;
27
23
  /**
28
24
  * Opens the app settings page.
29
25
  * On Web, this is not applicable.
@@ -34,9 +30,8 @@ export declare class TestWeb extends WebPlugin implements TestPlugin {
34
30
  /**
35
31
  * Returns the plugin version.
36
32
  *
37
- * @returns The current plugin version.
33
+ * On the Web, this value represents the JavaScript package version
34
+ * rather than a native implementation.
38
35
  */
39
- getPluginVersion(): Promise<{
40
- version: string;
41
- }>;
36
+ getPluginVersion(): Promise<PluginVersionResult>;
42
37
  }
package/dist/esm/web.js CHANGED
@@ -37,16 +37,18 @@ export class TestWeb extends WebPlugin {
37
37
  */
38
38
  async openAppSettings() {
39
39
  console.warn('Test: openAppSettings is not available on Web.');
40
+ // Rule: Unsupported methods MUST call this.unimplemented()
40
41
  return this.unimplemented('Not implemented on Web.');
41
42
  }
42
43
  // --- Plugin Info ---
43
44
  /**
44
45
  * Returns the plugin version.
45
46
  *
46
- * @returns The current plugin version.
47
+ * On the Web, this value represents the JavaScript package version
48
+ * rather than a native implementation.
47
49
  */
48
50
  async getPluginVersion() {
49
- return { version: 'web-1.0.0' };
51
+ return { version: 'web' };
50
52
  }
51
53
  }
52
54
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C;;;;;;;;GAQG;AACH,MAAM,OAAO,OAAQ,SAAQ,SAAS;IACpC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,sBAAsB;IAEtB;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,OAA0B;QACnC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,kFAAkF;QAClF,iFAAiF;QACjF,uDAAuD;QACvD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,uBAAuB;IAEvB;;;;;OAKG;IACH,KAAK,CAAC,eAAe;QACnB,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAU,CAAC;IAChE,CAAC;IAED,sBAAsB;IAEtB;;;;OAIG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAClC,CAAC;CACF"}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C;;;;;;;;GAQG;AACH,MAAM,OAAO,OAAQ,SAAQ,SAAS;IACpC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED,sBAAsB;IAEtB;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC7B,kFAAkF;QAClF,iFAAiF;QACjF,uDAAuD;QACvD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,uBAAuB;IAEvB;;;;;OAKG;IACH,KAAK,CAAC,eAAe;QACnB,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAC/D,2DAA2D;QAC3D,OAAO,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAU,CAAC;IAChE,CAAC;IAED,sBAAsB;IAEtB;;;;;OAKG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -19,17 +19,17 @@ exports.TestErrorCode = void 0;
19
19
  (function (TestErrorCode) {
20
20
  /** The device does not have the requested hardware. */
21
21
  TestErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
22
- /** The user denied the permission or the feature is disabled in settings. */
22
+ /** The user denied the permission or the feature is disabled. */
23
23
  TestErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
24
- /** The test plugin failed to initialize (e.g., runtime error or Looper failure). */
24
+ /** The TestPlugin failed to initialize (e.g., runtime error or Looper failure). */
25
25
  TestErrorCode["INIT_FAILED"] = "INIT_FAILED";
26
- /** The requested test plugin type is not valid or not supported by the plugin. */
26
+ /** The requested TestPlugin type is not valid or not supported by the plugin. */
27
27
  TestErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
28
28
  })(exports.TestErrorCode || (exports.TestErrorCode = {}));
29
29
 
30
30
  /**
31
31
  * @file index.ts
32
- * This file exports the TestPlugin and registers it with Capacitor.
32
+ * This file exports the Test and registers it with Capacitor.
33
33
  * It acts as the main entry point for accessing the plugin's functionality
34
34
  * across different platforms, including web.
35
35
  */
@@ -81,16 +81,18 @@ class TestWeb extends core.WebPlugin {
81
81
  */
82
82
  async openAppSettings() {
83
83
  console.warn('Test: openAppSettings is not available on Web.');
84
+ // Rule: Unsupported methods MUST call this.unimplemented()
84
85
  return this.unimplemented('Not implemented on Web.');
85
86
  }
86
87
  // --- Plugin Info ---
87
88
  /**
88
89
  * Returns the plugin version.
89
90
  *
90
- * @returns The current plugin version.
91
+ * On the Web, this value represents the JavaScript package version
92
+ * rather than a native implementation.
91
93
  */
92
94
  async getPluginVersion() {
93
- return { version: 'web-1.0.0' };
95
+ return { version: 'web' };
94
96
  }
95
97
  }
96
98
 
@@ -1 +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 Test plugin.\n *\n * These codes are returned as part of structured error objects\n * and allow consumers to implement programmatic error handling.\n *\n * Note:\n * On iOS (Swift Package Manager), errors are returned as data\n * objects rather than rejected Promises.\n *\n * @since 1.0.0\n */\nexport var TestErrorCode;\n(function (TestErrorCode) {\n /** The device does not have the requested hardware. */\n TestErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied the permission or the feature is disabled in settings. */\n TestErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The test plugin failed to initialize (e.g., runtime error or Looper failure). */\n TestErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** The requested test plugin type is not valid or not supported by the plugin. */\n TestErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(TestErrorCode || (TestErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * @file index.ts\n * This file exports the TestPlugin 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 Test 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 Test = registerPlugin('Test', {\n web: () => import('./web').then((m) => new m.TestWeb()),\n});\nexport * from './definitions';\nexport { Test };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the Test 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 may be unavailable on Web.\n */\nexport class TestWeb extends WebPlugin {\n constructor() {\n super();\n }\n // --- Echo Method ---\n /**\n * Echoes a value back for the web platform.\n * This method is a basic implementation example, primarily for testing\n * or validating communication with the plugin.\n *\n * @param options - An object containing a `value` property to be echoed back.\n * @returns A promise resolving to an object containing the echoed `value`.\n */\n async echo(options) {\n console.log('ECHO', options);\n // Note: On the web, reading 'capacitor.config.ts' requires specific build setups.\n // We pass the value through as-is for parity, or you can implement logic to read\n // from a global config object if your app exposes one.\n return options;\n }\n // --- App Settings ---\n /**\n * Opens the app settings page.\n * On Web, this is not applicable.\n *\n * @returns A promise that resolves when the operation is complete.\n */\n async openAppSettings() {\n console.warn('Test: openAppSettings is not available on Web.');\n return this.unimplemented('Not implemented on Web.');\n }\n // --- Plugin Info ---\n /**\n * Returns the plugin version.\n *\n * @returns The current plugin version.\n */\n async getPluginVersion() {\n return { version: 'web-1.0.0' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["TestErrorCode","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;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;;ACvBzC;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;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;AACpC;AACA;AACA;AACA,QAAQ,OAAO,OAAO;AACtB,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC;AACtE,QAAQ,OAAO,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC5D,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE;AACvC,IAAI;AACJ;;;;;;;;;"}
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 Test plugin.\n *\n * These codes are returned as part of structured error objects\n * and allow consumers to implement programmatic error handling.\n *\n * Note:\n * On iOS (Swift Package Manager), errors are returned as data\n * objects rather than rejected Promises.\n *\n * @since 1.0.0\n */\nexport var TestErrorCode;\n(function (TestErrorCode) {\n /** The device does not have the requested hardware. */\n TestErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied the permission or the feature is disabled. */\n TestErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The TestPlugin failed to initialize (e.g., runtime error or Looper failure). */\n TestErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** The requested TestPlugin type is not valid or not supported by the plugin. */\n TestErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(TestErrorCode || (TestErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * @file index.ts\n * This file exports the Test 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 Test 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 Test = registerPlugin('Test', {\n web: () => import('./web').then((m) => new m.TestWeb()),\n});\nexport * from './definitions';\nexport { Test };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the Test 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 may be unavailable on Web.\n */\nexport class TestWeb extends WebPlugin {\n constructor() {\n super();\n }\n // --- Echo Method ---\n /**\n * Echoes a value back for the web platform.\n * This method is a basic implementation example, primarily for testing\n * or validating communication with the plugin.\n *\n * @param options - An object containing a `value` property to be echoed back.\n * @returns A promise resolving to an object containing the echoed `value`.\n */\n async echo(options) {\n console.log('ECHO', options);\n // Note: On the web, reading 'capacitor.config.ts' requires specific build setups.\n // We pass the value through as-is for parity, or you can implement logic to read\n // from a global config object if your app exposes one.\n return options;\n }\n // --- App Settings ---\n /**\n * Opens the app settings page.\n * On Web, this is not applicable.\n *\n * @returns A promise that resolves when the operation is complete.\n */\n async openAppSettings() {\n console.warn('Test: openAppSettings is not available on Web.');\n // Rule: Unsupported methods MUST call this.unimplemented()\n return this.unimplemented('Not implemented on Web.');\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//# sourceMappingURL=web.js.map"],"names":["TestErrorCode","registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;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;;ACvBzC;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;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;AACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;AACpC;AACA;AACA;AACA,QAAQ,OAAO,OAAO;AACtB,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC;AACtE;AACA,QAAQ,OAAO,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC5D,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -18,17 +18,17 @@ var capacitorTest = (function (exports, core) {
18
18
  (function (TestErrorCode) {
19
19
  /** The device does not have the requested hardware. */
20
20
  TestErrorCode["UNAVAILABLE"] = "UNAVAILABLE";
21
- /** The user denied the permission or the feature is disabled in settings. */
21
+ /** The user denied the permission or the feature is disabled. */
22
22
  TestErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
23
- /** The test plugin failed to initialize (e.g., runtime error or Looper failure). */
23
+ /** The TestPlugin failed to initialize (e.g., runtime error or Looper failure). */
24
24
  TestErrorCode["INIT_FAILED"] = "INIT_FAILED";
25
- /** The requested test plugin type is not valid or not supported by the plugin. */
25
+ /** The requested TestPlugin type is not valid or not supported by the plugin. */
26
26
  TestErrorCode["UNKNOWN_TYPE"] = "UNKNOWN_TYPE";
27
27
  })(exports.TestErrorCode || (exports.TestErrorCode = {}));
28
28
 
29
29
  /**
30
30
  * @file index.ts
31
- * This file exports the TestPlugin and registers it with Capacitor.
31
+ * This file exports the Test and registers it with Capacitor.
32
32
  * It acts as the main entry point for accessing the plugin's functionality
33
33
  * across different platforms, including web.
34
34
  */
@@ -80,16 +80,18 @@ var capacitorTest = (function (exports, core) {
80
80
  */
81
81
  async openAppSettings() {
82
82
  console.warn('Test: openAppSettings is not available on Web.');
83
+ // Rule: Unsupported methods MUST call this.unimplemented()
83
84
  return this.unimplemented('Not implemented on Web.');
84
85
  }
85
86
  // --- Plugin Info ---
86
87
  /**
87
88
  * Returns the plugin version.
88
89
  *
89
- * @returns The current plugin version.
90
+ * On the Web, this value represents the JavaScript package version
91
+ * rather than a native implementation.
90
92
  */
91
93
  async getPluginVersion() {
92
- return { version: 'web-1.0.0' };
94
+ return { version: 'web' };
93
95
  }
94
96
  }
95
97
 
@@ -1 +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 Test plugin.\n *\n * These codes are returned as part of structured error objects\n * and allow consumers to implement programmatic error handling.\n *\n * Note:\n * On iOS (Swift Package Manager), errors are returned as data\n * objects rather than rejected Promises.\n *\n * @since 1.0.0\n */\nexport var TestErrorCode;\n(function (TestErrorCode) {\n /** The device does not have the requested hardware. */\n TestErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied the permission or the feature is disabled in settings. */\n TestErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The test plugin failed to initialize (e.g., runtime error or Looper failure). */\n TestErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** The requested test plugin type is not valid or not supported by the plugin. */\n TestErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(TestErrorCode || (TestErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * @file index.ts\n * This file exports the TestPlugin 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 Test 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 Test = registerPlugin('Test', {\n web: () => import('./web').then((m) => new m.TestWeb()),\n});\nexport * from './definitions';\nexport { Test };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the Test 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 may be unavailable on Web.\n */\nexport class TestWeb extends WebPlugin {\n constructor() {\n super();\n }\n // --- Echo Method ---\n /**\n * Echoes a value back for the web platform.\n * This method is a basic implementation example, primarily for testing\n * or validating communication with the plugin.\n *\n * @param options - An object containing a `value` property to be echoed back.\n * @returns A promise resolving to an object containing the echoed `value`.\n */\n async echo(options) {\n console.log('ECHO', options);\n // Note: On the web, reading 'capacitor.config.ts' requires specific build setups.\n // We pass the value through as-is for parity, or you can implement logic to read\n // from a global config object if your app exposes one.\n return options;\n }\n // --- App Settings ---\n /**\n * Opens the app settings page.\n * On Web, this is not applicable.\n *\n * @returns A promise that resolves when the operation is complete.\n */\n async openAppSettings() {\n console.warn('Test: openAppSettings is not available on Web.');\n return this.unimplemented('Not implemented on Web.');\n }\n // --- Plugin Info ---\n /**\n * Returns the plugin version.\n *\n * @returns The current plugin version.\n */\n async getPluginVersion() {\n return { version: 'web-1.0.0' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["TestErrorCode","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;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;;ICvBzC;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;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IACpC;IACA;IACA;IACA,QAAQ,OAAO,OAAO;IACtB,IAAI;IACJ;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,eAAe,GAAG;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC;IACtE,QAAQ,OAAO,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC5D,IAAI;IACJ;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE;IACvC,IAAI;IACJ;;;;;;;;;;;;;;;"}
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 Test plugin.\n *\n * These codes are returned as part of structured error objects\n * and allow consumers to implement programmatic error handling.\n *\n * Note:\n * On iOS (Swift Package Manager), errors are returned as data\n * objects rather than rejected Promises.\n *\n * @since 1.0.0\n */\nexport var TestErrorCode;\n(function (TestErrorCode) {\n /** The device does not have the requested hardware. */\n TestErrorCode[\"UNAVAILABLE\"] = \"UNAVAILABLE\";\n /** The user denied the permission or the feature is disabled. */\n TestErrorCode[\"PERMISSION_DENIED\"] = \"PERMISSION_DENIED\";\n /** The TestPlugin failed to initialize (e.g., runtime error or Looper failure). */\n TestErrorCode[\"INIT_FAILED\"] = \"INIT_FAILED\";\n /** The requested TestPlugin type is not valid or not supported by the plugin. */\n TestErrorCode[\"UNKNOWN_TYPE\"] = \"UNKNOWN_TYPE\";\n})(TestErrorCode || (TestErrorCode = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * @file index.ts\n * This file exports the Test 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 Test 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 Test = registerPlugin('Test', {\n web: () => import('./web').then((m) => new m.TestWeb()),\n});\nexport * from './definitions';\nexport { Test };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation of the Test 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 may be unavailable on Web.\n */\nexport class TestWeb extends WebPlugin {\n constructor() {\n super();\n }\n // --- Echo Method ---\n /**\n * Echoes a value back for the web platform.\n * This method is a basic implementation example, primarily for testing\n * or validating communication with the plugin.\n *\n * @param options - An object containing a `value` property to be echoed back.\n * @returns A promise resolving to an object containing the echoed `value`.\n */\n async echo(options) {\n console.log('ECHO', options);\n // Note: On the web, reading 'capacitor.config.ts' requires specific build setups.\n // We pass the value through as-is for parity, or you can implement logic to read\n // from a global config object if your app exposes one.\n return options;\n }\n // --- App Settings ---\n /**\n * Opens the app settings page.\n * On Web, this is not applicable.\n *\n * @returns A promise that resolves when the operation is complete.\n */\n async openAppSettings() {\n console.warn('Test: openAppSettings is not available on Web.');\n // Rule: Unsupported methods MUST call this.unimplemented()\n return this.unimplemented('Not implemented on Web.');\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//# sourceMappingURL=web.js.map"],"names":["TestErrorCode","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;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;;ICvBzC;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;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE;IACxB,QAAQ,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IACpC;IACA;IACA;IACA,QAAQ,OAAO,OAAO;IACtB,IAAI;IACJ;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,eAAe,GAAG;IAC5B,QAAQ,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC;IACtE;IACA,QAAQ,OAAO,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC5D,IAAI;IACJ;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -59,14 +59,12 @@ public struct TestConfig {
59
59
  - Parameter plugin: The CAPPlugin instance used to access typed configuration.
60
60
  */
61
61
  init(plugin: CAPPlugin) {
62
- let config = plugin.getConfig()
62
+ let pluginId = plugin.pluginId
63
63
 
64
64
  // Bool
65
- verboseLogging =
66
- (config.value(forKey: Keys.verboseLogging) as? Bool) ?? defaultVerboseLogging
65
+ verboseLogging = plugin.getConfigValue(Keys.verboseLogging) as? Bool ?? defaultVerboseLogging
67
66
 
68
67
  // String
69
- customMessage =
70
- (config.value(forKey: Keys.customMessage) as? String) ?? defaultCustomMessage
68
+ customMessage = plugin.getConfigValue(Keys.customMessage) as? String ?? defaultCustomMessage
71
69
  }
72
70
  }
@@ -1,17 +1,14 @@
1
1
  import Foundation
2
- import Capacitor
3
2
 
4
3
  /**
5
- Native implementation for the Test Capacitor plugin.
4
+ Native iOS implementation for the Test plugin.
6
5
 
7
- This class contains platform-specific logic only and MUST NOT:
6
+ This class contains ONLY platform logic and must not:
8
7
  - access CAPPluginCall
9
- - interact directly with the Capacitor bridge
10
- - depend on JavaScript concepts
11
-
12
- The Capacitor plugin class is responsible for delegating work to this class.
8
+ - depend on Capacitor
9
+ - perform mapping logic
13
10
  */
14
- @objc public class TestImpl: NSObject {
11
+ @objc public final class TestImpl: NSObject {
15
12
 
16
13
  // Properties
17
14
  private var config: TestConfig?
@@ -33,7 +30,7 @@ import Capacitor
33
30
  func applyConfig(_ config: TestConfig) {
34
31
  self.config = config
35
32
  TestLogger.verbose = config.verboseLogging
36
- TestLogger.debug("Configuration applied. Verbose logging enabled.")
33
+ TestLogger.debug("Configuration applied. Verbose logging:", "\(config.verboseLogging)")
37
34
  }
38
35
 
39
36
  // MARK: - Echo Method
@@ -4,14 +4,13 @@ import Capacitor
4
4
  /**
5
5
  Capacitor bridge for the Test plugin.
6
6
 
7
- This class represents the boundary between JavaScript and native iOS code.
8
- Responsibilities include:
9
- - reading plugin configuration
10
- - handling CAPPluginCall objects
11
- - delegating logic to the native implementation
7
+ This file MUST:
8
+ - read input from CAPPluginCall
9
+ - delegate logic to TestImpl
10
+ - resolve calls using state-based results
12
11
  */
13
12
  @objc(TestPlugin)
14
- public class TestPlugin: CAPPlugin, CAPBridgedPlugin {
13
+ public final class TestPlugin: CAPPlugin, CAPBridgedPlugin {
15
14
 
16
15
  // Configuration instance
17
16
  private var config: TestConfig?
@@ -65,18 +64,20 @@ public class TestPlugin: CAPPlugin, CAPBridgedPlugin {
65
64
  and delegates the core logic to the native implementation.
66
65
  */
67
66
  @objc func echo(_ call: CAPPluginCall) {
68
- var value = call.getString("value", "")
67
+ let jsValue = call.getString("value", "")
69
68
 
70
- // Log input only if verbose logging is enabled
71
- TestLogger.debug("Echoing value:", value)
72
-
73
- // Append the custom message from the configuration
74
- if let configMessage = config?.customMessage {
75
- value += configMessage
69
+ let valueToEcho: String
70
+ if !jsValue.isEmpty {
71
+ valueToEcho = jsValue
72
+ } else {
73
+ valueToEcho = config?.customMessage ?? ""
76
74
  }
77
75
 
76
+ // Log input only if verbose logging is enabled
77
+ TestLogger.debug("Echoing value:", valueToEcho)
78
+
78
79
  call.resolve([
79
- "value": implementation.echo(value)
80
+ "value": implementation.echo(valueToEcho)
80
81
  ])
81
82
  }
82
83
 
@@ -94,32 +95,21 @@ public class TestPlugin: CAPPlugin, CAPBridgedPlugin {
94
95
  @objc func openAppSettings(_ call: CAPPluginCall) {
95
96
  DispatchQueue.main.async(execute: DispatchWorkItem {
96
97
  guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else {
97
- call.resolve([
98
- "success": false,
99
- "error": "Cannot open settings URL",
100
- "code": "UNAVAILABLE"
101
- ])
98
+ TestLogger.error("Cannot create settings URL")
99
+ call.resolve()
102
100
  return
103
101
  }
104
102
 
105
103
  if UIApplication.shared.canOpenURL(settingsUrl) {
106
104
  UIApplication.shared.open(settingsUrl, options: [:]) { success in
107
- if success {
108
- call.resolve()
109
- } else {
110
- call.resolve([
111
- "success": false,
112
- "error": "Failed to open settings",
113
- "code": "UNAVAILABLE"
114
- ])
105
+ if !success {
106
+ TestLogger.error("Failed to open app settings")
115
107
  }
108
+ call.resolve()
116
109
  }
117
110
  } else {
118
- call.resolve([
119
- "success": false,
120
- "error": "Cannot open settings URL",
121
- "code": "UNAVAILABLE"
122
- ])
111
+ TestLogger.error("Cannot open settings URL")
112
+ call.resolve()
123
113
  }
124
114
  })
125
115
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cap-kit/test-plugin",
3
- "version": "1.0.2",
4
- "description": "Test plugin for Cap-Kit.",
3
+ "version": "5.0.0",
4
+ "description": "Architectural reference and boilerplate for Cap-Kit plugins.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/esm/index.d.ts",
@@ -13,10 +13,10 @@
13
13
  "ios/Sources",
14
14
  "ios/Tests",
15
15
  "Package.swift",
16
- "CapKitTest.podspec",
16
+ "CapKitTestPlugin.podspec",
17
17
  "LICENSE"
18
18
  ],
19
- "author": "Fabio Martino",
19
+ "author": "CapKit Team",
20
20
  "license": "MIT",
21
21
  "repository": {
22
22
  "type": "git",
@@ -46,11 +46,11 @@
46
46
  "@eslint/js": "^9.39.2",
47
47
  "eslint": "^9.39.2",
48
48
  "eslint-plugin-import": "^2.32.0",
49
- "globals": "^17.0.0",
50
- "prettier": "^3.8.0",
49
+ "globals": "^17.1.0",
50
+ "prettier": "^3.8.1",
51
51
  "prettier-plugin-java": "^2.8.1",
52
52
  "rimraf": "^6.1.2",
53
- "rollup": "^4.55.2",
53
+ "rollup": "^4.56.0",
54
54
  "swiftlint": "^2.0.0",
55
55
  "typescript": "^5.9.3",
56
56
  "typescript-eslint": "^8.53.1"
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "scripts": {
70
70
  "verify": "pnpm run verify:ios && pnpm run verify:android && pnpm run verify:web",
71
- "verify:ios": "xcodebuild -scheme CapKitTest -destination generic/platform=iOS",
71
+ "verify:ios": "xcodebuild -scheme CapKitTestPlugin -destination generic/platform=iOS",
72
72
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
73
73
  "verify:web": "pnpm run build",
74
74
  "lint:android": "cd android && ./gradlew ktlintCheck",
@@ -1,21 +0,0 @@
1
- import XCTest
2
- @testable import TestPlugin
3
-
4
- /**
5
- Basic functional tests for the Test plugin native implementation.
6
-
7
- These tests validate the core behavior of the implementation
8
- independently from the Capacitor bridge.
9
- */
10
- class TestTests: XCTestCase {
11
- func testEcho() {
12
- // This is an example of a functional test case for a plugin.
13
- // Use XCTAssert and related functions to verify your tests produce the correct results.
14
-
15
- let implementation = TestImpl()
16
- let value = "Hello, World!"
17
- let result = implementation.echo(value)
18
-
19
- XCTAssertEqual(value, result)
20
- }
21
- }