@cap-kit/test-plugin 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,16 +3,24 @@
3
3
  </p>
4
4
 
5
5
  <h3 align="center">Test</h3>
6
- <p align="center"><strong><code>@cap-kit/test-plugin</code></strong></p>
7
-
8
6
  <p align="center">
9
- Test plugin for Cap-Kit.
7
+ <strong>
8
+ <code>@cap-kit/test-plugin</code>
9
+ </strong>
10
10
  </p>
11
11
 
12
+ <p align="center">Test plugin for Cap-Kit.</p>
13
+
12
14
  <p align="center">
13
- <a href="https://www.npmjs.com/package/@cap-kit/test-plugin"><img src="https://img.shields.io/npm/v/@cap-kit/test-plugin?style=flat-square" /></a>
14
- <a href="https://www.npmjs.com/package/@cap-kit/test-plugin"><img src="https://img.shields.io/npm/dm/@cap-kit/test-plugin?style=flat-square" /></a>
15
- <a href="https://www.npmjs.com/package/@cap-kit/test-plugin"><img src="https://img.shields.io/npm/l/@cap-kit/test-plugin?style=flat-square" /></a>
15
+ <a href="https://www.npmjs.com/package/@cap-kit/test-plugin">
16
+ <img src="https://img.shields.io/npm/v/@cap-kit/test-plugin?style=flat-square" />
17
+ </a>
18
+ <a href="https://www.npmjs.com/package/@cap-kit/test-plugin">
19
+ <img src="https://img.shields.io/npm/dm/@cap-kit/test-plugin?style=flat-square" />
20
+ </a>
21
+ <a href="https://www.npmjs.com/package/@cap-kit/test-plugin">
22
+ <img src="https://img.shields.io/npm/l/@cap-kit/test-plugin?style=flat-square" />
23
+ </a>
16
24
  <img src="https://img.shields.io/maintenance/yes/2026?style=flat-square" />
17
25
  </p>
18
26
 
@@ -61,7 +69,7 @@ import { CapacitorConfig } from '@capacitor/cli';
61
69
  const config: CapacitorConfig = {
62
70
  plugins: {
63
71
  Test: {
64
- customMessage: " - Hello from Config!",
72
+ customMessage: ' - Hello from Config!',
65
73
  },
66
74
  },
67
75
  };
@@ -71,13 +79,13 @@ export default config;
71
79
 
72
80
  </docgen-config>
73
81
 
74
-
75
82
  ## API
76
83
 
77
84
  <docgen-index>
78
85
 
79
86
  * [`echo(...)`](#echo)
80
87
  * [`getPluginVersion()`](#getpluginversion)
88
+ * [Interfaces](#interfaces)
81
89
 
82
90
  </docgen-index>
83
91
 
@@ -89,7 +97,7 @@ Capacitor Test plugin interface.
89
97
  ### echo(...)
90
98
 
91
99
  ```typescript
92
- echo(options: { value: string; }) => Promise<{ value: string; }>
100
+ echo(options: EchoOptions) => Promise<EchoResult>
93
101
  ```
94
102
 
95
103
  Echoes the provided value.
@@ -97,35 +105,81 @@ Echoes the provided value.
97
105
  If the plugin is configured with a `customMessage`, it will be appended
98
106
  to the response.
99
107
 
100
- | Param | Type | Description |
101
- | ------------- | ------------------------------- | ------------------------------------------------------------ |
102
- | **`options`** | <code>{ value: string; }</code> | - An object containing a `value` property to be echoed back. |
108
+ | Param | Type | Description |
109
+ | ------------- | --------------------------------------------------- | ------------------------------------------- |
110
+ | **`options`** | <code><a href="#echooptions">EchoOptions</a></code> | - The options containing the value to echo. |
103
111
 
104
- **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
112
+ **Returns:** <code>Promise&lt;<a href="#echoresult">EchoResult</a>&gt;</code>
105
113
 
106
114
  **Since:** 0.0.1
107
115
 
116
+ #### Example
117
+
118
+ ```typescript
119
+ import { Test } from '@cap-kit/test-plugin';
120
+
121
+ const result = await Test.echo({ value: 'Hello, World!' });
122
+ console.log(result.value); // Output: 'Hello, World!'
123
+ ```
124
+
108
125
  --------------------
109
126
 
110
127
 
111
128
  ### getPluginVersion()
112
129
 
113
130
  ```typescript
114
- getPluginVersion() => Promise<{ version: string; }>
131
+ getPluginVersion() => Promise<PluginVersionResult>
115
132
  ```
116
133
 
117
134
  Get the native Capacitor plugin version.
118
135
 
119
- **Returns:** <code>Promise&lt;{ version: string; }&gt;</code>
136
+ **Returns:** <code>Promise&lt;<a href="#pluginversionresult">PluginVersionResult</a>&gt;</code>
120
137
 
121
138
  **Since:** 0.0.1
122
139
 
140
+ #### Example
141
+
142
+ ```typescript
143
+ import { Test } from '@cap-kit/test-plugin';
144
+
145
+ const { version } = await Test.getPluginVersion();
146
+ console.log('Plugin version:', version); // Output: Plugin version: 0.0.1
147
+ ```
148
+
123
149
  --------------------
124
150
 
125
- </docgen-api>
126
151
 
152
+ ### Interfaces
127
153
 
128
154
 
155
+ #### EchoResult
156
+
157
+ Result returned by the echo method.
158
+
159
+ | Prop | Type | Description |
160
+ | ----------- | ------------------- | ----------------- |
161
+ | **`value`** | <code>string</code> | The echoed value. |
162
+
163
+
164
+ #### EchoOptions
165
+
166
+ Options for the echo method.
167
+
168
+ | Prop | Type | Description |
169
+ | ----------- | ------------------- | ----------------------- |
170
+ | **`value`** | <code>string</code> | The value to be echoed. |
171
+
172
+
173
+ #### PluginVersionResult
174
+
175
+ Result returned by the getPluginVersion method.
176
+
177
+ | Prop | Type | Description |
178
+ | ------------- | ------------------- | ---------------------------------------- |
179
+ | **`version`** | <code>string</code> | The native version string of the plugin. |
180
+
181
+ </docgen-api>
182
+
129
183
  ## Contributing
130
184
 
131
- Contributions are welcome! Please read the [contributing guide](CONTRIBUTING.md) before submitting a pull request.
185
+ Contributions are welcome! Please read the [contributing guide](CONTRIBUTING.md) before submitting a pull request.
@@ -1,13 +1,6 @@
1
- ext {
2
- junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
4
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
5
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
6
- androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.17.0'
7
- }
8
-
9
1
  buildscript {
10
2
  ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.2.20'
3
+
11
4
  repositories {
12
5
  google()
13
6
  mavenCentral()
@@ -18,9 +11,22 @@ buildscript {
18
11
  }
19
12
  }
20
13
 
14
+ plugins {
15
+ id "org.jlleitschuh.gradle.ktlint" version "12.1.1" apply false
16
+ }
17
+
18
+ ext {
19
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
20
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
21
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
22
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
23
+ androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.17.0'
24
+ }
25
+
21
26
  apply plugin: 'com.android.library'
22
27
  apply plugin: 'kotlin-android'
23
28
  apply plugin: 'kotlin-parcelize'
29
+ apply plugin: 'org.jlleitschuh.gradle.ktlint'
24
30
 
25
31
  import groovy.json.JsonSlurper
26
32
 
@@ -6,17 +6,20 @@ import android.util.Log
6
6
  * Utility object for logging messages with a custom prefix.
7
7
  */
8
8
  object Logger {
9
- private const val TAG = "⚡️ Test"
9
+ private const val TAG = "⚡️ Test"
10
10
 
11
- fun debug(vararg messages: String) {
12
- log(TAG, *messages)
13
- }
11
+ fun debug(vararg messages: String) {
12
+ log(TAG, *messages)
13
+ }
14
14
 
15
- fun log(tag: String, vararg messages: String) {
16
- val sb = StringBuilder()
17
- for (msg in messages) {
18
- sb.append(msg).append(" ")
19
- }
20
- Log.d(tag, sb.toString())
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(" ")
21
22
  }
23
+ Log.d(tag, sb.toString())
24
+ }
22
25
  }
@@ -1,7 +1,5 @@
1
1
  package com.capkit.test
2
2
 
3
- import com.capkit.test.Logger
4
-
5
3
  /**
6
4
  * Native implementation for the Test Capacitor plugin.
7
5
  *
@@ -9,15 +7,14 @@ import com.capkit.test.Logger
9
7
  * Capacitor plugin APIs.
10
8
  */
11
9
  class Test {
12
-
13
- /**
14
- * Returns the provided string unchanged.
15
- *
16
- * @param value Input string.
17
- * @return The same string.
18
- */
19
- fun echo(value: String): String {
20
- Logger.debug(value)
21
- return value
22
- }
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
+ }
23
20
  }
@@ -7,11 +7,10 @@ import com.getcapacitor.Plugin
7
7
  * It parses the values from capacitor.config.json
8
8
  */
9
9
  class TestConfig(plugin: Plugin) {
10
+ val customMessage: String
10
11
 
11
- val customMessage: String
12
-
13
- init {
14
- // "customMessage" must match the key in capacitor.config.ts
15
- customMessage = plugin.getConfig().getString("customMessage") ?: " (from config)"
16
- }
12
+ init {
13
+ // "customMessage" must match the key in capacitor.config.ts
14
+ customMessage = plugin.getConfig().getString("customMessage") ?: " (from config)"
15
+ }
17
16
  }
@@ -1,6 +1,5 @@
1
1
  package com.capkit.test
2
2
 
3
- import com.capkit.test.Logger
4
3
  import com.getcapacitor.JSObject
5
4
  import com.getcapacitor.Plugin
6
5
  import com.getcapacitor.PluginCall
@@ -14,48 +13,48 @@ import com.getcapacitor.annotation.CapacitorPlugin
14
13
  * and delegates all business logic to the implementation class.
15
14
  */
16
15
  @CapacitorPlugin(
17
- name = "Test")
16
+ name = "Test",
17
+ )
18
18
  class TestPlugin : Plugin() {
19
-
20
- private lateinit var config: TestConfig
21
-
22
- override fun load() {
23
- super.load()
24
- Logger.debug("Loading plugin")
25
- config = TestConfig(this)
26
- }
27
-
28
- /** Plugin version (injected by Gradle). */
29
- private val pluginVersion: String = BuildConfig.PLUGIN_VERSION
30
-
31
- /** Native implementation (business logic). */
32
- private val implementation = Test()
33
-
34
- /**
35
- * Echoes a string back to JavaScript.
36
- *
37
- * @param call Capacitor plugin call containing the `value` parameter.
38
- */
39
- @PluginMethod
40
- fun echo(call: PluginCall) {
41
- var value = call.getString("value") ?: ""
42
- Logger.debug("Echoing value: $value")
43
-
44
- // Append the custom message from the configuration
45
- value += config.customMessage
46
-
47
- val ret = JSObject()
48
- ret.put("value", implementation.echo(value))
49
- call.resolve(ret)
50
- }
51
-
52
- /**
53
- * Returns the plugin version.
54
- */
55
- @PluginMethod
56
- fun getPluginVersion(call: PluginCall) {
57
- val ret = JSObject()
58
- ret.put("version", pluginVersion)
59
- call.resolve(ret)
60
- }
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
+ }
61
60
  }
package/dist/docs.json CHANGED
@@ -7,23 +7,23 @@
7
7
  "methods": [
8
8
  {
9
9
  "name": "echo",
10
- "signature": "(options: { value: string; }) => Promise<{ value: string; }>",
10
+ "signature": "(options: EchoOptions) => Promise<EchoResult>",
11
11
  "parameters": [
12
12
  {
13
13
  "name": "options",
14
- "docs": "- An object containing a `value` property to be echoed back.",
15
- "type": "{ value: string; }"
14
+ "docs": "- The options containing the value to echo.",
15
+ "type": "EchoOptions"
16
16
  }
17
17
  ],
18
- "returns": "Promise<{ value: string; }>",
18
+ "returns": "Promise<EchoResult>",
19
19
  "tags": [
20
20
  {
21
21
  "name": "param",
22
- "text": "options - An object containing a `value` property to be echoed back."
22
+ "text": "options - The options containing the value to echo."
23
23
  },
24
24
  {
25
25
  "name": "returns",
26
- "text": "A promise resolving to an object containing the echoed `value`."
26
+ "text": "A promise resolving to the echo result."
27
27
  },
28
28
  {
29
29
  "name": "example",
@@ -35,22 +35,25 @@
35
35
  }
36
36
  ],
37
37
  "docs": "Echoes the provided value.\n\nIf the plugin is configured with a `customMessage`, it will be appended\nto the response.",
38
- "complexTypes": [],
38
+ "complexTypes": [
39
+ "EchoResult",
40
+ "EchoOptions"
41
+ ],
39
42
  "slug": "echo"
40
43
  },
41
44
  {
42
45
  "name": "getPluginVersion",
43
- "signature": "() => Promise<{ version: string; }>",
46
+ "signature": "() => Promise<PluginVersionResult>",
44
47
  "parameters": [],
45
- "returns": "Promise<{ version: string; }>",
48
+ "returns": "Promise<PluginVersionResult>",
46
49
  "tags": [
47
50
  {
48
51
  "name": "returns",
49
- "text": "Promise that resolves with the plugin version"
52
+ "text": "A promise resolving to an object containing the version string."
50
53
  },
51
54
  {
52
55
  "name": "throws",
53
- "text": "Error if getting the version fails"
56
+ "text": "Error if getting the version fails."
54
57
  },
55
58
  {
56
59
  "name": "example",
@@ -62,13 +65,64 @@
62
65
  }
63
66
  ],
64
67
  "docs": "Get the native Capacitor plugin version.",
65
- "complexTypes": [],
68
+ "complexTypes": [
69
+ "PluginVersionResult"
70
+ ],
66
71
  "slug": "getpluginversion"
67
72
  }
68
73
  ],
69
74
  "properties": []
70
75
  },
71
- "interfaces": [],
76
+ "interfaces": [
77
+ {
78
+ "name": "EchoResult",
79
+ "slug": "echoresult",
80
+ "docs": "Result returned by the echo method.",
81
+ "tags": [],
82
+ "methods": [],
83
+ "properties": [
84
+ {
85
+ "name": "value",
86
+ "tags": [],
87
+ "docs": "The echoed value.",
88
+ "complexTypes": [],
89
+ "type": "string"
90
+ }
91
+ ]
92
+ },
93
+ {
94
+ "name": "EchoOptions",
95
+ "slug": "echooptions",
96
+ "docs": "Options for the echo method.",
97
+ "tags": [],
98
+ "methods": [],
99
+ "properties": [
100
+ {
101
+ "name": "value",
102
+ "tags": [],
103
+ "docs": "The value to be echoed.",
104
+ "complexTypes": [],
105
+ "type": "string"
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ "name": "PluginVersionResult",
111
+ "slug": "pluginversionresult",
112
+ "docs": "Result returned by the getPluginVersion method.",
113
+ "tags": [],
114
+ "methods": [],
115
+ "properties": [
116
+ {
117
+ "name": "version",
118
+ "tags": [],
119
+ "docs": "The native version string of the plugin.",
120
+ "complexTypes": [],
121
+ "type": "string"
122
+ }
123
+ ]
124
+ }
125
+ ],
72
126
  "enums": [],
73
127
  "typeAliases": [],
74
128
  "pluginConfigs": [
@@ -19,6 +19,33 @@ declare module '@capacitor/cli' {
19
19
  };
20
20
  }
21
21
  }
22
+ /**
23
+ * Options for the echo method.
24
+ */
25
+ export interface EchoOptions {
26
+ /**
27
+ * The value to be echoed.
28
+ */
29
+ value: string;
30
+ }
31
+ /**
32
+ * Result returned by the echo method.
33
+ */
34
+ export interface EchoResult {
35
+ /**
36
+ * The echoed value.
37
+ */
38
+ value: string;
39
+ }
40
+ /**
41
+ * Result returned by the getPluginVersion method.
42
+ */
43
+ export interface PluginVersionResult {
44
+ /**
45
+ * The native version string of the plugin.
46
+ */
47
+ version: string;
48
+ }
22
49
  /**
23
50
  * Capacitor Test plugin interface.
24
51
  */
@@ -29,8 +56,8 @@ export interface TestPlugin {
29
56
  * If the plugin is configured with a `customMessage`, it will be appended
30
57
  * to the response.
31
58
  *
32
- * @param options - An object containing a `value` property to be echoed back.
33
- * @returns A promise resolving to an object containing the echoed `value`.
59
+ * @param options - The options containing the value to echo.
60
+ * @returns A promise resolving to the echo result.
34
61
  *
35
62
  * @example
36
63
  * ```typescript
@@ -42,16 +69,12 @@ export interface TestPlugin {
42
69
  *
43
70
  * @since 0.0.1
44
71
  */
45
- echo(options: {
46
- value: string;
47
- }): Promise<{
48
- value: string;
49
- }>;
72
+ echo(options: EchoOptions): Promise<EchoResult>;
50
73
  /**
51
74
  * Get the native Capacitor plugin version.
52
75
  *
53
- * @returns Promise that resolves with the plugin version
54
- * @throws Error if getting the version fails
76
+ * @returns A promise resolving to an object containing the version string.
77
+ * @throws Error if getting the version fails.
55
78
  *
56
79
  * @example
57
80
  * ```typescript
@@ -63,7 +86,5 @@ export interface TestPlugin {
63
86
  *
64
87
  * @since 0.0.1
65
88
  */
66
- getPluginVersion(): Promise<{
67
- version: string;
68
- }>;
89
+ getPluginVersion(): Promise<PluginVersionResult>;
69
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\n/**\n * Extend the PluginsConfig interface to include configuration options for the Test plugin.\n */\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * Configuration options for the Test plugin.\n */\n Test?: {\n /**\n * A custom message to append to the echo response.\n * This demonstrates how to pass data from `capacitor.config.ts` to the plugin.\n *\n * @default \" (from config)\"\n * @example \" - Hello from Config!\"\n * @since 0.0.1\n */\n customMessage?: string;\n };\n }\n}\n\n/**\n * Capacitor Test plugin interface.\n */\nexport interface TestPlugin {\n /**\n * Echoes the provided value.\n *\n * If the plugin is configured with a `customMessage`, it will be appended\n * to the response.\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 * @example\n * ```typescript\n * import { Test } from '@cap-kit/test-plugin';\n *\n * const result = await Test.echo({ value: 'Hello, World!' });\n * console.log(result.value); // Output: 'Hello, World!'\n * ```\n *\n * @since 0.0.1\n */\n echo(options: { value: string }): Promise<{ value: string }>;\n\n /**\n * Get the native Capacitor plugin version.\n *\n * @returns Promise that resolves with the plugin version\n * @throws Error if getting the version fails\n *\n * @example\n * ```typescript\n * import { Test } from '@cap-kit/test-plugin';\n *\n * const { version } = await Test.getPluginVersion();\n * console.log('Plugin version:', version); // Output: Plugin version: 0.0.1\n * ```\n *\n * @since 0.0.1\n */\n getPluginVersion(): Promise<{ version: string }>;\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD;;;;;GAKG;AACH,MAAM,IAAI,GAAG,cAAc,CAAa,MAAM,EAAE;IAC9C;;;;;;OAMG;IACH,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;CACxD,CAAC,CAAC;AAEH,iEAAiE;AACjE,qEAAqE;AACrE,8BAA8B;AAC9B,cAAc,eAAe,CAAC;AAE9B,6CAA6C;AAC7C,wEAAwE;AACxE,OAAO,EAAE,IAAI,EAAE,CAAC","sourcesContent":["/**\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 */\n\nimport { registerPlugin } from '@capacitor/core';\n\nimport type { TestPlugin } from './definitions';\n\n/**\n * Test Capacitor plugin instance.\n * This instance is registered with Capacitor using the `registerPlugin` function,\n * making it accessible through the Capacitor runtime. It dynamically loads the\n * web implementation when needed.\n */\nconst Test = registerPlugin<TestPlugin>('Test', {\n /**\n * Dynamically imports the web implementation of the plugin.\n * The `web` option provides a fallback for web environments,\n * ensuring platform-specific implementations can be used seamlessly.\n *\n * @returns A promise resolving to the web implementation of the plugin.\n */\n web: () => import('./web').then((m) => new m.TestWeb()),\n});\n\n// Export the definitions from 'definitions.ts' for external use.\n// These exports allow users to directly use the types and interfaces\n// defined for the TestPlugin.\nexport * from './definitions';\n\n// Export the registered TestPlugin instance.\n// This makes the plugin instance available for import in other modules.\nexport { Test };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD;;;;;GAKG;AACH,MAAM,IAAI,GAAG,cAAc,CAAa,MAAM,EAAE;IAC9C;;;;;;OAMG;IACH,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;CACxD,CAAC,CAAC;AAEH,iEAAiE;AACjE,qEAAqE;AACrE,8BAA8B;AAC9B,cAAc,eAAe,CAAC;AAE9B,6CAA6C;AAC7C,wEAAwE;AACxE,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C;;;;GAIG;AACH,MAAM,OAAO,OAAQ,SAAQ,SAAS;IACpC;;;;;;;;;;;;;;;OAeG;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;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * @file web.ts\n * This file contains the web implementation of the TestPlugin.\n * It defines a class that extends the WebPlugin class and implements the\n * TestPlugin interface, providing the required functionality for web platforms.\n */\nimport { WebPlugin } from '@capacitor/core';\n\nimport type { TestPlugin } from './definitions';\n\n/**\n * Class representing the web implementation of the TestPlugin.\n * This class extends the WebPlugin class and implements the TestPlugin interface.\n * It provides a base implementation for web-based functionality of the plugin.\n */\nexport class TestWeb extends WebPlugin implements TestPlugin {\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 * @example\n * ```typescript\n * import { Test } from '@cap-kit/test-plugin';\n *\n * const result = await Test.echo({ value: 'Hello, World!' });\n * console.log(result.value); // Output: 'Hello, World!'\n * ```\n */\n async echo(options: { value: string }): Promise<{ value: string }> {\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\n /**\n * Get the native Capacitor plugin version.\n *\n * @returns Promise that resolves with the plugin version\n * @throws Error if getting the version fails\n *\n * @example\n * ```typescript\n * import { Test } from '@cap-kit/test-plugin';\n *\n * const version = await Test.getPluginVersion();\n * console.log(version.version); // Output: 'web'\n * ```\n */\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C;;;;GAIG;AACH,MAAM,OAAO,OAAQ,SAAQ,SAAS;IACpC;;;;;;;;;;;;;;;OAeG;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;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -6,7 +6,7 @@ import Capacitor
6
6
  * This function is designed to format log messages for the Test plugin. It prepends the log output
7
7
  * with a custom prefix (`⚡️ Test -`) to easily identify logs associated with this plugin.
8
8
  *
9
- * @param items - A variadic parameter accepting a list of items to log. Each item will be converted to a string and logged sequentially.
9
+ * @param items - Items to log, stringified and logged in order.
10
10
  * @param separator - A string used to separate the logged items. Defaults to a single space (`" "`).
11
11
  * @param terminator - A string appended to the end of the log message. Defaults to a newline (`"\n"`).
12
12
  *
@@ -18,7 +18,7 @@ import Capacitor
18
18
  *
19
19
  * Note:
20
20
  * - This function uses Capacitor's `CAPLog.print` for outputting log messages.
21
- * - If multiple items are logged, they will be separated by the specified `separator` and terminated by the `terminator`.
21
+ * - Multiple items use `separator` and end with `terminator`.
22
22
  */
23
23
  func log(_ items: Any..., separator: String = " ", terminator: String = "\n") {
24
24
  // Prefix the log with "⚡️ Test -"
@@ -60,7 +60,7 @@ public class TestPlugin: CAPPlugin, CAPBridgedPlugin {
60
60
 
61
61
  // Append the custom message from the configuration
62
62
  if let configMessage = config?.customMessage {
63
- value = value + configMessage
63
+ value += configMessage
64
64
  }
65
65
 
66
66
  call.resolve([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-kit/test-plugin",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Test plugin for Cap-Kit.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -20,41 +20,44 @@
20
20
  "license": "MIT",
21
21
  "repository": {
22
22
  "type": "git",
23
- "url": "git+https://github.com/cap-kit/plugins.git"
23
+ "url": "git+https://github.com/cap-kit/capacitor-plugins.git",
24
+ "directory": "packages/test-plugin"
24
25
  },
25
26
  "bugs": {
26
- "url": "https://github.com/cap-kit/plugins/issues"
27
+ "url": "https://github.com/cap-kit/capacitor-plugins/issues"
27
28
  },
29
+ "homepage": "https://github.com/cap-kit/capacitor-plugins/tree/main/packages/test-plugin#readme",
28
30
  "keywords": [
29
31
  "capacitor",
30
- "plugin",
32
+ "capacitor-plugin",
33
+ "ionic",
31
34
  "native"
32
35
  ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
33
39
  "devDependencies": {
34
40
  "@capacitor/cli": "^8.0.0",
35
41
  "@capacitor/android": "^8.0.0",
36
42
  "@capacitor/core": "^8.0.0",
37
43
  "@capacitor/docgen": "^0.3.1",
38
44
  "@capacitor/ios": "^8.0.0",
39
- "@ionic/eslint-config": "^0.4.0",
40
- "@ionic/prettier-config": "^4.0.0",
41
- "@ionic/swiftlint-config": "^2.0.0",
42
- "eslint": "^8.57.1",
43
- "prettier": "^3.6.2",
44
- "prettier-plugin-java": "^2.7.7",
45
+ "@eslint/eslintrc": "^3.3.3",
46
+ "@eslint/js": "^9.39.2",
47
+ "eslint": "^9.39.2",
48
+ "eslint-plugin-import": "^2.32.0",
49
+ "globals": "^17.0.0",
50
+ "prettier": "^3.7.4",
51
+ "prettier-plugin-java": "^2.8.1",
45
52
  "rimraf": "^6.1.2",
46
- "rollup": "^4.53.5",
53
+ "rollup": "^4.55.1",
47
54
  "swiftlint": "^2.0.0",
48
- "typescript": "^5.9.3"
55
+ "typescript": "^5.9.3",
56
+ "typescript-eslint": "^8.52.0"
49
57
  },
50
58
  "peerDependencies": {
51
59
  "@capacitor/core": ">=8.0.0"
52
60
  },
53
- "prettier": "@ionic/prettier-config",
54
- "swiftlint": "@ionic/swiftlint-config",
55
- "eslintConfig": {
56
- "extends": "@ionic/eslint-config/recommended"
57
- },
58
61
  "capacitor": {
59
62
  "ios": {
60
63
  "src": "ios"
@@ -68,14 +71,20 @@
68
71
  "verify:ios": "xcodebuild -scheme TestPlugin -destination generic/platform=iOS",
69
72
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
70
73
  "verify:web": "pnpm run build",
71
- "lint": "pnpm run eslint --ext ts . && pnpm run prettier --check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java && pnpm run swiftlint lint --strict",
72
- "fmt": "pnpm run eslint --fix --ext ts . && pnpm run prettier --write \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java && pnpm run swiftlint --fix --format",
74
+ "lint:android": "cd android && ./gradlew ktlintCheck",
75
+ "fmt:android": "cd android && ./gradlew ktlintFormat",
76
+ "lint": "pnpm run eslint . && pnpm run swiftlint lint --strict || true && pnpm run lint:android || true",
77
+ "format:check": "prettier --check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
78
+ "format": "eslint --fix . && prettier --write \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java && pnpm run swiftlint --fix --format && pnpm run fmt:android",
73
79
  "eslint": "eslint",
74
80
  "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
75
- "swiftlint": "node-swiftlint",
81
+ "swiftlint": "node-swiftlint lint ios/Sources",
76
82
  "docgen": "docgen --api TestPlugin --output-readme README.md --output-json dist/docs.json",
77
83
  "build": "pnpm run clean && pnpm run docgen && tsc && rollup -c rollup.config.mjs",
78
84
  "clean": "rimraf ./dist",
79
- "watch": "tsc --watch"
85
+ "watch": "tsc --watch",
86
+ "test": "pnpm run verify",
87
+ "removePacked": "rimraf -g cap-kit-test-plugin-*.tgz",
88
+ "publish:locally": "pnpm run removePacked && pnpm run build && pnpm pack"
80
89
  }
81
90
  }