@cap-kit/test-plugin 0.1.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +63 -31
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/io/capkit/test/Test.kt +61 -0
  4. package/android/src/main/java/io/capkit/test/TestConfig.kt +51 -0
  5. package/android/src/main/java/io/capkit/test/TestPlugin.kt +116 -0
  6. package/android/src/main/java/io/capkit/test/utils/Logger.kt +85 -0
  7. package/android/src/main/java/io/capkit/test/utils/TestUtils.kt +14 -0
  8. package/dist/docs.json +57 -21
  9. package/dist/esm/definitions.d.ts +137 -35
  10. package/dist/esm/definitions.js +23 -1
  11. package/dist/esm/definitions.js.map +1 -1
  12. package/dist/esm/index.d.ts +4 -4
  13. package/dist/esm/index.js +4 -16
  14. package/dist/esm/index.js.map +1 -1
  15. package/dist/esm/web.d.ts +16 -27
  16. package/dist/esm/web.js +25 -28
  17. package/dist/esm/web.js.map +1 -1
  18. package/dist/plugin.cjs.js +54 -39
  19. package/dist/plugin.cjs.js.map +1 -1
  20. package/dist/plugin.js +54 -39
  21. package/dist/plugin.js.map +1 -1
  22. package/ios/Sources/TestPlugin/Test.swift +40 -8
  23. package/ios/Sources/TestPlugin/TestConfig.swift +52 -9
  24. package/ios/Sources/TestPlugin/TestPlugin.swift +83 -34
  25. package/ios/Sources/TestPlugin/Utils/Logging.swift +57 -0
  26. package/ios/Sources/TestPlugin/Utils/TestUtils.swift +12 -0
  27. package/package.json +9 -9
  28. package/android/src/main/java/com/capkit/test/Logger.kt +0 -25
  29. package/android/src/main/java/com/capkit/test/Test.kt +0 -20
  30. package/android/src/main/java/com/capkit/test/TestConfig.kt +0 -16
  31. package/android/src/main/java/com/capkit/test/TestPlugin.kt +0 -60
  32. package/ios/Sources/TestPlugin/Logging.swift +0 -32
@@ -0,0 +1,57 @@
1
+ import Capacitor
2
+
3
+ /**
4
+ Centralized logger for the Test plugin.
5
+
6
+ This logger mirrors the Android Logger pattern and provides:
7
+ - a single logging entry point
8
+ - runtime-controlled verbose logging
9
+ - consistent log formatting
10
+
11
+ Business logic MUST NOT perform configuration checks directly.
12
+ */
13
+ enum TestLogger {
14
+
15
+ /**
16
+ Controls whether debug logs are printed.
17
+
18
+ This value is set once during plugin load
19
+ based on configuration values.
20
+ */
21
+ static var verbose: Bool = false
22
+
23
+ /**
24
+ Prints a verbose / debug log message.
25
+
26
+ This method is intended for development-time diagnostics
27
+ and is automatically silenced when verbose logging is disabled.
28
+ */
29
+ static func debug(_ items: Any...) {
30
+ guard verbose else { return }
31
+ log(items)
32
+ }
33
+
34
+ /**
35
+ Prints an error log message.
36
+
37
+ Error logs are always printed regardless of verbosity.
38
+ */
39
+ static func error(_ items: Any...) {
40
+ log(items)
41
+ }
42
+ }
43
+
44
+ /**
45
+ Low-level log printer with a consistent prefix.
46
+
47
+ This function should not be used directly outside this file.
48
+ */
49
+ private func log(_ items: Any..., separator: String = " ", terminator: String = "\n") {
50
+ CAPLog.print("⚡️ Test -", terminator: separator)
51
+ for (itemIndex, item) in items.enumerated() {
52
+ CAPLog.print(
53
+ item,
54
+ terminator: itemIndex == items.count - 1 ? terminator : separator
55
+ )
56
+ }
57
+ }
@@ -0,0 +1,12 @@
1
+ import Foundation
2
+
3
+ /**
4
+ Utility helpers for the Test plugin.
5
+
6
+ This type is intentionally empty and serves as a placeholder
7
+ for future shared helper functions.
8
+
9
+ Keeping a dedicated utilities file helps maintain a clean
10
+ separation between core logic and helper code.
11
+ */
12
+ struct TestUtils {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-kit/test-plugin",
3
- "version": "0.1.2",
3
+ "version": "1.0.1",
4
4
  "description": "Test plugin for Cap-Kit.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -37,26 +37,26 @@
37
37
  "access": "public"
38
38
  },
39
39
  "devDependencies": {
40
- "@capacitor/cli": "^8.0.0",
41
- "@capacitor/android": "^8.0.0",
42
- "@capacitor/core": "^8.0.0",
40
+ "@capacitor/cli": "^8.0.1",
41
+ "@capacitor/android": "^8.0.1",
42
+ "@capacitor/core": "^8.0.1",
43
43
  "@capacitor/docgen": "^0.3.1",
44
- "@capacitor/ios": "^8.0.0",
44
+ "@capacitor/ios": "^8.0.1",
45
45
  "@eslint/eslintrc": "^3.3.3",
46
46
  "@eslint/js": "^9.39.2",
47
47
  "eslint": "^9.39.2",
48
48
  "eslint-plugin-import": "^2.32.0",
49
49
  "globals": "^17.0.0",
50
- "prettier": "^3.7.4",
50
+ "prettier": "^3.8.0",
51
51
  "prettier-plugin-java": "^2.8.1",
52
52
  "rimraf": "^6.1.2",
53
- "rollup": "^4.55.1",
53
+ "rollup": "^4.55.2",
54
54
  "swiftlint": "^2.0.0",
55
55
  "typescript": "^5.9.3",
56
- "typescript-eslint": "^8.52.0"
56
+ "typescript-eslint": "^8.53.1"
57
57
  },
58
58
  "peerDependencies": {
59
- "@capacitor/core": ">=8.0.0"
59
+ "@capacitor/core": ">=8.0.1"
60
60
  },
61
61
  "capacitor": {
62
62
  "ios": {
@@ -1,25 +0,0 @@
1
- package com.capkit.test
2
-
3
- import android.util.Log
4
-
5
- /**
6
- * Utility object for logging messages with a custom prefix.
7
- */
8
- object Logger {
9
- private const val TAG = "⚡️ Test"
10
-
11
- fun debug(vararg messages: String) {
12
- log(TAG, *messages)
13
- }
14
-
15
- fun log(
16
- tag: String,
17
- vararg messages: String,
18
- ) {
19
- val sb = StringBuilder()
20
- for (msg in messages) {
21
- sb.append(msg).append(" ")
22
- }
23
- Log.d(tag, sb.toString())
24
- }
25
- }
@@ -1,20 +0,0 @@
1
- package com.capkit.test
2
-
3
- /**
4
- * Native implementation for the Test Capacitor plugin.
5
- *
6
- * This class contains platform logic only and does not depend on
7
- * Capacitor plugin APIs.
8
- */
9
- class Test {
10
- /**
11
- * Returns the provided string unchanged.
12
- *
13
- * @param value Input string.
14
- * @return The same string.
15
- */
16
- fun echo(value: String): String {
17
- Logger.debug(value)
18
- return value
19
- }
20
- }
@@ -1,16 +0,0 @@
1
- package com.capkit.test
2
-
3
- import com.getcapacitor.Plugin
4
-
5
- /**
6
- * Helper class to manage the plugin configuration.
7
- * It parses the values from capacitor.config.json
8
- */
9
- class TestConfig(plugin: Plugin) {
10
- val customMessage: String
11
-
12
- init {
13
- // "customMessage" must match the key in capacitor.config.ts
14
- customMessage = plugin.getConfig().getString("customMessage") ?: " (from config)"
15
- }
16
- }
@@ -1,60 +0,0 @@
1
- package com.capkit.test
2
-
3
- import com.getcapacitor.JSObject
4
- import com.getcapacitor.Plugin
5
- import com.getcapacitor.PluginCall
6
- import com.getcapacitor.PluginMethod
7
- import com.getcapacitor.annotation.CapacitorPlugin
8
-
9
- /**
10
- * Capacitor bridge for the Test plugin.
11
- *
12
- * This class exposes native Android functionality to JavaScript
13
- * and delegates all business logic to the implementation class.
14
- */
15
- @CapacitorPlugin(
16
- name = "Test",
17
- )
18
- class TestPlugin : Plugin() {
19
- private lateinit var config: TestConfig
20
-
21
- override fun load() {
22
- super.load()
23
- Logger.debug("Loading plugin")
24
- config = TestConfig(this)
25
- }
26
-
27
- /** Plugin version (injected by Gradle). */
28
- private val pluginVersion: String = BuildConfig.PLUGIN_VERSION
29
-
30
- /** Native implementation (business logic). */
31
- private val implementation = Test()
32
-
33
- /**
34
- * Echoes a string back to JavaScript.
35
- *
36
- * @param call Capacitor plugin call containing the `value` parameter.
37
- */
38
- @PluginMethod
39
- fun echo(call: PluginCall) {
40
- var value = call.getString("value") ?: ""
41
- Logger.debug("Echoing value: $value")
42
-
43
- // Append the custom message from the configuration
44
- value += config.customMessage
45
-
46
- val ret = JSObject()
47
- ret.put("value", implementation.echo(value))
48
- call.resolve(ret)
49
- }
50
-
51
- /**
52
- * Returns the plugin version.
53
- */
54
- @PluginMethod
55
- fun getPluginVersion(call: PluginCall) {
56
- val ret = JSObject()
57
- ret.put("version", pluginVersion)
58
- call.resolve(ret)
59
- }
60
- }
@@ -1,32 +0,0 @@
1
- import Capacitor
2
-
3
- /**
4
- * Utility function for logging messages with a custom prefix.
5
- *
6
- * This function is designed to format log messages for the Test plugin. It prepends the log output
7
- * with a custom prefix (`⚡️ Test -`) to easily identify logs associated with this plugin.
8
- *
9
- * @param items - Items to log, stringified and logged in order.
10
- * @param separator - A string used to separate the logged items. Defaults to a single space (`" "`).
11
- * @param terminator - A string appended to the end of the log message. Defaults to a newline (`"\n"`).
12
- *
13
- * Example Usage:
14
- * ```
15
- * log("This is a message", "with multiple parts", separator: ", ")
16
- * // Output: ⚡️ Test - This is a message, with multiple parts
17
- * ```
18
- *
19
- * Note:
20
- * - This function uses Capacitor's `CAPLog.print` for outputting log messages.
21
- * - Multiple items use `separator` and end with `terminator`.
22
- */
23
- func log(_ items: Any..., separator: String = " ", terminator: String = "\n") {
24
- // Prefix the log with "⚡️ Test -"
25
- CAPLog.print("⚡️ Test -", terminator: separator)
26
-
27
- // Iterate over the provided items and print each one
28
- for (itemIndex, item) in items.enumerated() {
29
- // Use the specified separator between items, and the terminator for the final item
30
- CAPLog.print(item, terminator: itemIndex == items.count - 1 ? terminator : separator)
31
- }
32
- }