@cap-kit/test-plugin 0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fabio Martino
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/Package.swift ADDED
@@ -0,0 +1,27 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "TestPlugin",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "TestPlugin",
10
+ targets: ["TestPlugin"])
11
+ ],
12
+ dependencies: [
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0")
14
+ ],
15
+ targets: [
16
+ .target(
17
+ name: "TestPlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm") ],
21
+ path: "ios/Sources/TestPlugin" ),
22
+ .testTarget(
23
+ name: "TestPluginTests",
24
+ dependencies: ["TestPlugin"],
25
+ path: "ios/Tests/TestPluginTests")
26
+ ]
27
+ )
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ <p align="center">
2
+ <img src="./logo.svg" alt="Capacitor Logo" width="128" height="128" />
3
+ </p>
4
+
5
+ <h3 align="center">Test</h3>
6
+ <p align="center"><strong><code>@cap-kit/test-plugin</code></strong></p>
7
+
8
+ <p align="center">
9
+ Test plugin for Cap-Kit.
10
+ </p>
11
+
12
+ <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>
16
+ <img src="https://img.shields.io/maintenance/yes/2026?style=flat-square" />
17
+ </p>
18
+
19
+ <br>
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pnpm add @cap-kit/test-plugin
25
+ npx cap sync
26
+
27
+ ```
28
+
29
+ ## Configuration
30
+
31
+ <docgen-config>
32
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
33
+
34
+ Configuration options for the Test plugin.
35
+
36
+ | Prop | Type | Description | Default | Since |
37
+ | ------------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | ----- |
38
+ | **`customMessage`** | <code>string</code> | A custom message to append to the echo response. This demonstrates how to pass data from `capacitor.config.ts` to the plugin. | <code>" (from config)"</code> | 0.0.1 |
39
+
40
+ ### Examples
41
+
42
+ In `capacitor.config.json`:
43
+
44
+ ```json
45
+ {
46
+ "plugins": {
47
+ "Test": {
48
+ "customMessage": " - Hello from Config!"
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ In `capacitor.config.ts`:
55
+
56
+ ```ts
57
+ /// <reference types="@cap-kit/test-plugin" />
58
+
59
+ import { CapacitorConfig } from '@capacitor/cli';
60
+
61
+ const config: CapacitorConfig = {
62
+ plugins: {
63
+ Test: {
64
+ customMessage: " - Hello from Config!",
65
+ },
66
+ },
67
+ };
68
+
69
+ export default config;
70
+ ```
71
+
72
+ </docgen-config>
73
+
74
+
75
+ ## API
76
+
77
+ <docgen-index>
78
+
79
+ * [`echo(...)`](#echo)
80
+ * [`getPluginVersion()`](#getpluginversion)
81
+
82
+ </docgen-index>
83
+
84
+ <docgen-api>
85
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
86
+
87
+ Capacitor Test plugin interface.
88
+
89
+ ### echo(...)
90
+
91
+ ```typescript
92
+ echo(options: { value: string; }) => Promise<{ value: string; }>
93
+ ```
94
+
95
+ Echoes the provided value.
96
+
97
+ If the plugin is configured with a `customMessage`, it will be appended
98
+ to the response.
99
+
100
+ | Param | Type | Description |
101
+ | ------------- | ------------------------------- | ------------------------------------------------------------ |
102
+ | **`options`** | <code>{ value: string; }</code> | - An object containing a `value` property to be echoed back. |
103
+
104
+ **Returns:** <code>Promise&lt;{ value: string; }&gt;</code>
105
+
106
+ **Since:** 0.0.1
107
+
108
+ --------------------
109
+
110
+
111
+ ### getPluginVersion()
112
+
113
+ ```typescript
114
+ getPluginVersion() => Promise<{ version: string; }>
115
+ ```
116
+
117
+ Get the native Capacitor plugin version.
118
+
119
+ **Returns:** <code>Promise&lt;{ version: string; }&gt;</code>
120
+
121
+ **Since:** 0.0.1
122
+
123
+ --------------------
124
+
125
+ </docgen-api>
126
+
127
+
128
+
129
+ ## Contributing
130
+
131
+ Contributions are welcome! Please read the [contributing guide](CONTRIBUTING.md) before submitting a pull request.
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'TestPlugin'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.license = package['license']
10
+ s.homepage = package['repository']['url']
11
+ s.author = package['author']
12
+ s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
13
+ s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '15.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
@@ -0,0 +1,98 @@
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
+ buildscript {
10
+ ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.2.20'
11
+ repositories {
12
+ google()
13
+ mavenCentral()
14
+ }
15
+ dependencies {
16
+ classpath 'com.android.tools.build:gradle:8.13.0'
17
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
18
+ }
19
+ }
20
+
21
+ apply plugin: 'com.android.library'
22
+ apply plugin: 'kotlin-android'
23
+ apply plugin: 'kotlin-parcelize'
24
+
25
+ import groovy.json.JsonSlurper
26
+
27
+ def getPluginVersion() {
28
+ try {
29
+ def packageJsonFile = file('../package.json')
30
+ if (packageJsonFile.exists()) {
31
+ def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
32
+ return packageJson.version
33
+ }
34
+ } catch (Exception e) {
35
+ // Ignore errors and fallback
36
+ }
37
+ return "0.0.1"
38
+ }
39
+
40
+ def pluginVersion = getPluginVersion()
41
+
42
+ android {
43
+ namespace = "com.capkit.test"
44
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion as Integer : 36
45
+
46
+ // AGP 8.0+ disables BuildConfig by default for libraries.
47
+ // We need to enable it to inject the plugin version.
48
+ buildFeatures {
49
+ buildConfig = true
50
+ }
51
+
52
+ defaultConfig {
53
+ minSdkVersion = project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion as Integer : 24
54
+ targetSdkVersion = project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion as Integer : 36
55
+ versionCode = 1
56
+
57
+ // Dynamic versioning (feature enabled)
58
+ versionName = pluginVersion
59
+
60
+ // Injects the version into the BuildConfig class ONLY if feature is enabled
61
+ buildConfigField "String", "PLUGIN_VERSION", "\"${pluginVersion}\""
62
+
63
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
64
+ }
65
+ buildTypes {
66
+ release {
67
+ minifyEnabled = false
68
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
69
+ }
70
+ }
71
+ lint {
72
+ abortOnError = false
73
+ }
74
+ compileOptions {
75
+ sourceCompatibility = JavaVersion.VERSION_21
76
+ targetCompatibility = JavaVersion.VERSION_21
77
+ }
78
+ kotlinOptions {
79
+ jvmTarget = JavaVersion.VERSION_21
80
+ }
81
+ }
82
+
83
+ repositories {
84
+ google()
85
+ mavenCentral()
86
+ }
87
+
88
+ dependencies {
89
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
90
+ implementation project(':capacitor-android')
91
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
92
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
93
+ implementation "androidx.core:core-ktx:$androidxCoreKTXVersion"
94
+
95
+ testImplementation "junit:junit:$junitVersion"
96
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
97
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
98
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,22 @@
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(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())
21
+ }
22
+ }
@@ -0,0 +1,23 @@
1
+ package com.capkit.test
2
+
3
+ import com.capkit.test.Logger
4
+
5
+ /**
6
+ * Native implementation for the Test Capacitor plugin.
7
+ *
8
+ * This class contains platform logic only and does not depend on
9
+ * Capacitor plugin APIs.
10
+ */
11
+ 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
+ }
23
+ }
@@ -0,0 +1,17 @@
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
+
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
+ }
17
+ }
@@ -0,0 +1,61 @@
1
+ package com.capkit.test
2
+
3
+ import com.capkit.test.Logger
4
+ import com.getcapacitor.JSObject
5
+ import com.getcapacitor.Plugin
6
+ import com.getcapacitor.PluginCall
7
+ import com.getcapacitor.PluginMethod
8
+ import com.getcapacitor.annotation.CapacitorPlugin
9
+
10
+ /**
11
+ * Capacitor bridge for the Test plugin.
12
+ *
13
+ * This class exposes native Android functionality to JavaScript
14
+ * and delegates all business logic to the implementation class.
15
+ */
16
+ @CapacitorPlugin(
17
+ name = "Test")
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
+ }
61
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "api": {
3
+ "name": "TestPlugin",
4
+ "slug": "testplugin",
5
+ "docs": "Capacitor Test plugin interface.",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "echo",
10
+ "signature": "(options: { value: string; }) => Promise<{ value: string; }>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "- An object containing a `value` property to be echoed back.",
15
+ "type": "{ value: string; }"
16
+ }
17
+ ],
18
+ "returns": "Promise<{ value: string; }>",
19
+ "tags": [
20
+ {
21
+ "name": "param",
22
+ "text": "options - An object containing a `value` property to be echoed back."
23
+ },
24
+ {
25
+ "name": "returns",
26
+ "text": "A promise resolving to an object containing the echoed `value`."
27
+ },
28
+ {
29
+ "name": "example",
30
+ "text": "```typescript\nimport { Test } from '@cap-kit/test-plugin';\n\nconst result = await Test.echo({ value: 'Hello, World!' });\nconsole.log(result.value); // Output: 'Hello, World!'\n```"
31
+ },
32
+ {
33
+ "name": "since",
34
+ "text": "0.0.1"
35
+ }
36
+ ],
37
+ "docs": "Echoes the provided value.\n\nIf the plugin is configured with a `customMessage`, it will be appended\nto the response.",
38
+ "complexTypes": [],
39
+ "slug": "echo"
40
+ },
41
+ {
42
+ "name": "getPluginVersion",
43
+ "signature": "() => Promise<{ version: string; }>",
44
+ "parameters": [],
45
+ "returns": "Promise<{ version: string; }>",
46
+ "tags": [
47
+ {
48
+ "name": "returns",
49
+ "text": "Promise that resolves with the plugin version"
50
+ },
51
+ {
52
+ "name": "throws",
53
+ "text": "Error if getting the version fails"
54
+ },
55
+ {
56
+ "name": "example",
57
+ "text": "```typescript\nimport { Test } from '@cap-kit/test-plugin';\n\nconst { version } = await Test.getPluginVersion();\nconsole.log('Plugin version:', version); // Output: Plugin version: 0.0.1\n```"
58
+ },
59
+ {
60
+ "name": "since",
61
+ "text": "0.0.1"
62
+ }
63
+ ],
64
+ "docs": "Get the native Capacitor plugin version.",
65
+ "complexTypes": [],
66
+ "slug": "getpluginversion"
67
+ }
68
+ ],
69
+ "properties": []
70
+ },
71
+ "interfaces": [],
72
+ "enums": [],
73
+ "typeAliases": [],
74
+ "pluginConfigs": [
75
+ {
76
+ "name": "Test",
77
+ "slug": "test",
78
+ "properties": [
79
+ {
80
+ "name": "customMessage",
81
+ "tags": [
82
+ {
83
+ "text": "\" (from config)\"",
84
+ "name": "default"
85
+ },
86
+ {
87
+ "text": "\" - Hello from Config!\"",
88
+ "name": "example"
89
+ },
90
+ {
91
+ "text": "0.0.1",
92
+ "name": "since"
93
+ }
94
+ ],
95
+ "docs": "A custom message to append to the echo response.\nThis demonstrates how to pass data from `capacitor.config.ts` to the plugin.",
96
+ "complexTypes": [],
97
+ "type": "string | undefined"
98
+ }
99
+ ],
100
+ "docs": "Configuration options for the Test plugin."
101
+ }
102
+ ]
103
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Extend the PluginsConfig interface to include configuration options for the Test plugin.
3
+ */
4
+ declare module '@capacitor/cli' {
5
+ interface PluginsConfig {
6
+ /**
7
+ * Configuration options for the Test plugin.
8
+ */
9
+ Test?: {
10
+ /**
11
+ * A custom message to append to the echo response.
12
+ * This demonstrates how to pass data from `capacitor.config.ts` to the plugin.
13
+ *
14
+ * @default " (from config)"
15
+ * @example " - Hello from Config!"
16
+ * @since 0.0.1
17
+ */
18
+ customMessage?: string;
19
+ };
20
+ }
21
+ }
22
+ /**
23
+ * Capacitor Test plugin interface.
24
+ */
25
+ export interface TestPlugin {
26
+ /**
27
+ * Echoes the provided value.
28
+ *
29
+ * If the plugin is configured with a `customMessage`, it will be appended
30
+ * to the response.
31
+ *
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`.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import { Test } from '@cap-kit/test-plugin';
38
+ *
39
+ * const result = await Test.echo({ value: 'Hello, World!' });
40
+ * console.log(result.value); // Output: 'Hello, World!'
41
+ * ```
42
+ *
43
+ * @since 0.0.1
44
+ */
45
+ echo(options: {
46
+ value: string;
47
+ }): Promise<{
48
+ value: string;
49
+ }>;
50
+ /**
51
+ * Get the native Capacitor plugin version.
52
+ *
53
+ * @returns Promise that resolves with the plugin version
54
+ * @throws Error if getting the version fails
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * import { Test } from '@cap-kit/test-plugin';
59
+ *
60
+ * const { version } = await Test.getPluginVersion();
61
+ * console.log('Plugin version:', version); // Output: Plugin version: 0.0.1
62
+ * ```
63
+ *
64
+ * @since 0.0.1
65
+ */
66
+ getPluginVersion(): Promise<{
67
+ version: string;
68
+ }>;
69
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="@capacitor/cli" />
2
+ export {};
3
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file index.ts
3
+ * This file exports the TestPlugin and registers it with Capacitor.
4
+ * It acts as the main entry point for accessing the plugin's functionality
5
+ * across different platforms, including web.
6
+ */
7
+ import type { TestPlugin } from './definitions';
8
+ /**
9
+ * Test Capacitor plugin instance.
10
+ * This instance is registered with Capacitor using the `registerPlugin` function,
11
+ * making it accessible through the Capacitor runtime. It dynamically loads the
12
+ * web implementation when needed.
13
+ */
14
+ declare const Test: TestPlugin;
15
+ export * from './definitions';
16
+ export { Test };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file index.ts
3
+ * This file exports the TestPlugin and registers it with Capacitor.
4
+ * It acts as the main entry point for accessing the plugin's functionality
5
+ * across different platforms, including web.
6
+ */
7
+ import { registerPlugin } from '@capacitor/core';
8
+ /**
9
+ * Test Capacitor plugin instance.
10
+ * This instance is registered with Capacitor using the `registerPlugin` function,
11
+ * making it accessible through the Capacitor runtime. It dynamically loads the
12
+ * web implementation when needed.
13
+ */
14
+ const Test = registerPlugin('Test', {
15
+ /**
16
+ * Dynamically imports the web implementation of the plugin.
17
+ * The `web` option provides a fallback for web environments,
18
+ * ensuring platform-specific implementations can be used seamlessly.
19
+ *
20
+ * @returns A promise resolving to the web implementation of the plugin.
21
+ */
22
+ web: () => import('./web').then((m) => new m.TestWeb()),
23
+ });
24
+ // Export the definitions from 'definitions.ts' for external use.
25
+ // These exports allow users to directly use the types and interfaces
26
+ // defined for the TestPlugin.
27
+ export * from './definitions';
28
+ // Export the registered TestPlugin instance.
29
+ // This makes the plugin instance available for import in other modules.
30
+ export { Test };
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @file web.ts
3
+ * This file contains the web implementation of the TestPlugin.
4
+ * It defines a class that extends the WebPlugin class and implements the
5
+ * TestPlugin interface, providing the required functionality for web platforms.
6
+ */
7
+ import { WebPlugin } from '@capacitor/core';
8
+ import type { TestPlugin } from './definitions';
9
+ /**
10
+ * Class representing the web implementation of the TestPlugin.
11
+ * This class extends the WebPlugin class and implements the TestPlugin interface.
12
+ * It provides a base implementation for web-based functionality of the plugin.
13
+ */
14
+ export declare class TestWeb extends WebPlugin implements TestPlugin {
15
+ /**
16
+ * Echoes a value back for the web platform.
17
+ * This method is a basic implementation example, primarily for testing
18
+ * or validating communication with the plugin.
19
+ *
20
+ * @param options - An object containing a `value` property to be echoed back.
21
+ * @returns A promise resolving to an object containing the echoed `value`.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * import { Test } from '@cap-kit/test-plugin';
26
+ *
27
+ * const result = await Test.echo({ value: 'Hello, World!' });
28
+ * console.log(result.value); // Output: 'Hello, World!'
29
+ * ```
30
+ */
31
+ echo(options: {
32
+ value: string;
33
+ }): Promise<{
34
+ value: string;
35
+ }>;
36
+ /**
37
+ * Get the native Capacitor plugin version.
38
+ *
39
+ * @returns Promise that resolves with the plugin version
40
+ * @throws Error if getting the version fails
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * import { Test } from '@cap-kit/test-plugin';
45
+ *
46
+ * const version = await Test.getPluginVersion();
47
+ * console.log(version.version); // Output: 'web'
48
+ * ```
49
+ */
50
+ getPluginVersion(): Promise<{
51
+ version: string;
52
+ }>;
53
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @file web.ts
3
+ * This file contains the web implementation of the TestPlugin.
4
+ * It defines a class that extends the WebPlugin class and implements the
5
+ * TestPlugin interface, providing the required functionality for web platforms.
6
+ */
7
+ import { WebPlugin } from '@capacitor/core';
8
+ /**
9
+ * Class representing the web implementation of the TestPlugin.
10
+ * This class extends the WebPlugin class and implements the TestPlugin interface.
11
+ * It provides a base implementation for web-based functionality of the plugin.
12
+ */
13
+ export class TestWeb extends WebPlugin {
14
+ /**
15
+ * Echoes a value back for the web platform.
16
+ * This method is a basic implementation example, primarily for testing
17
+ * or validating communication with the plugin.
18
+ *
19
+ * @param options - An object containing a `value` property to be echoed back.
20
+ * @returns A promise resolving to an object containing the echoed `value`.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * import { Test } from '@cap-kit/test-plugin';
25
+ *
26
+ * const result = await Test.echo({ value: 'Hello, World!' });
27
+ * console.log(result.value); // Output: 'Hello, World!'
28
+ * ```
29
+ */
30
+ async echo(options) {
31
+ console.log('ECHO', options);
32
+ // Note: On the web, reading 'capacitor.config.ts' requires specific build setups.
33
+ // We pass the value through as-is for parity, or you can implement logic to read
34
+ // from a global config object if your app exposes one.
35
+ return options;
36
+ }
37
+ /**
38
+ * Get the native Capacitor plugin version.
39
+ *
40
+ * @returns Promise that resolves with the plugin version
41
+ * @throws Error if getting the version fails
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * import { Test } from '@cap-kit/test-plugin';
46
+ *
47
+ * const version = await Test.getPluginVersion();
48
+ * console.log(version.version); // Output: 'web'
49
+ * ```
50
+ */
51
+ async getPluginVersion() {
52
+ return { version: 'web' };
53
+ }
54
+ }
55
+ //# sourceMappingURL=web.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ /**
6
+ * @file index.ts
7
+ * This file exports the TestPlugin and registers it with Capacitor.
8
+ * It acts as the main entry point for accessing the plugin's functionality
9
+ * across different platforms, including web.
10
+ */
11
+ /**
12
+ * Test Capacitor plugin instance.
13
+ * This instance is registered with Capacitor using the `registerPlugin` function,
14
+ * making it accessible through the Capacitor runtime. It dynamically loads the
15
+ * web implementation when needed.
16
+ */
17
+ const Test = core.registerPlugin('Test', {
18
+ /**
19
+ * Dynamically imports the web implementation of the plugin.
20
+ * The `web` option provides a fallback for web environments,
21
+ * ensuring platform-specific implementations can be used seamlessly.
22
+ *
23
+ * @returns A promise resolving to the web implementation of the plugin.
24
+ */
25
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TestWeb()),
26
+ });
27
+
28
+ /**
29
+ * @file web.ts
30
+ * This file contains the web implementation of the TestPlugin.
31
+ * It defines a class that extends the WebPlugin class and implements the
32
+ * TestPlugin interface, providing the required functionality for web platforms.
33
+ */
34
+ /**
35
+ * Class representing the web implementation of the TestPlugin.
36
+ * This class extends the WebPlugin class and implements the TestPlugin interface.
37
+ * It provides a base implementation for web-based functionality of the plugin.
38
+ */
39
+ class TestWeb extends core.WebPlugin {
40
+ /**
41
+ * Echoes a value back for the web platform.
42
+ * This method is a basic implementation example, primarily for testing
43
+ * or validating communication with the plugin.
44
+ *
45
+ * @param options - An object containing a `value` property to be echoed back.
46
+ * @returns A promise resolving to an object containing the echoed `value`.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import { Test } from '@cap-kit/test-plugin';
51
+ *
52
+ * const result = await Test.echo({ value: 'Hello, World!' });
53
+ * console.log(result.value); // Output: 'Hello, World!'
54
+ * ```
55
+ */
56
+ async echo(options) {
57
+ console.log('ECHO', options);
58
+ // Note: On the web, reading 'capacitor.config.ts' requires specific build setups.
59
+ // We pass the value through as-is for parity, or you can implement logic to read
60
+ // from a global config object if your app exposes one.
61
+ return options;
62
+ }
63
+ /**
64
+ * Get the native Capacitor plugin version.
65
+ *
66
+ * @returns Promise that resolves with the plugin version
67
+ * @throws Error if getting the version fails
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * import { Test } from '@cap-kit/test-plugin';
72
+ *
73
+ * const version = await Test.getPluginVersion();
74
+ * console.log(version.version); // Output: 'web'
75
+ * ```
76
+ */
77
+ async getPluginVersion() {
78
+ return { version: 'web' };
79
+ }
80
+ }
81
+
82
+ var web = /*#__PURE__*/Object.freeze({
83
+ __proto__: null,
84
+ TestWeb: TestWeb
85
+ });
86
+
87
+ exports.Test = Test;
88
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"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 */\nimport { registerPlugin } from '@capacitor/core';\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('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// 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// Export the registered TestPlugin instance.\n// This makes the plugin instance available for import in other modules.\nexport { Test };\n//# sourceMappingURL=index.js.map","/**\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/**\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 {\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) {\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 * 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() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACK,MAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AAC3D,CAAC;;ACtBD;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACO,MAAM,OAAO,SAASC,cAAS,CAAC;AACvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;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 ADDED
@@ -0,0 +1,91 @@
1
+ var capacitorTest = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * @file index.ts
6
+ * This file exports the TestPlugin and registers it with Capacitor.
7
+ * It acts as the main entry point for accessing the plugin's functionality
8
+ * across different platforms, including web.
9
+ */
10
+ /**
11
+ * Test Capacitor plugin instance.
12
+ * This instance is registered with Capacitor using the `registerPlugin` function,
13
+ * making it accessible through the Capacitor runtime. It dynamically loads the
14
+ * web implementation when needed.
15
+ */
16
+ const Test = core.registerPlugin('Test', {
17
+ /**
18
+ * Dynamically imports the web implementation of the plugin.
19
+ * The `web` option provides a fallback for web environments,
20
+ * ensuring platform-specific implementations can be used seamlessly.
21
+ *
22
+ * @returns A promise resolving to the web implementation of the plugin.
23
+ */
24
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.TestWeb()),
25
+ });
26
+
27
+ /**
28
+ * @file web.ts
29
+ * This file contains the web implementation of the TestPlugin.
30
+ * It defines a class that extends the WebPlugin class and implements the
31
+ * TestPlugin interface, providing the required functionality for web platforms.
32
+ */
33
+ /**
34
+ * Class representing the web implementation of the TestPlugin.
35
+ * This class extends the WebPlugin class and implements the TestPlugin interface.
36
+ * It provides a base implementation for web-based functionality of the plugin.
37
+ */
38
+ class TestWeb extends core.WebPlugin {
39
+ /**
40
+ * Echoes a value back for the web platform.
41
+ * This method is a basic implementation example, primarily for testing
42
+ * or validating communication with the plugin.
43
+ *
44
+ * @param options - An object containing a `value` property to be echoed back.
45
+ * @returns A promise resolving to an object containing the echoed `value`.
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * import { Test } from '@cap-kit/test-plugin';
50
+ *
51
+ * const result = await Test.echo({ value: 'Hello, World!' });
52
+ * console.log(result.value); // Output: 'Hello, World!'
53
+ * ```
54
+ */
55
+ async echo(options) {
56
+ console.log('ECHO', options);
57
+ // Note: On the web, reading 'capacitor.config.ts' requires specific build setups.
58
+ // We pass the value through as-is for parity, or you can implement logic to read
59
+ // from a global config object if your app exposes one.
60
+ return options;
61
+ }
62
+ /**
63
+ * Get the native Capacitor plugin version.
64
+ *
65
+ * @returns Promise that resolves with the plugin version
66
+ * @throws Error if getting the version fails
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * import { Test } from '@cap-kit/test-plugin';
71
+ *
72
+ * const version = await Test.getPluginVersion();
73
+ * console.log(version.version); // Output: 'web'
74
+ * ```
75
+ */
76
+ async getPluginVersion() {
77
+ return { version: 'web' };
78
+ }
79
+ }
80
+
81
+ var web = /*#__PURE__*/Object.freeze({
82
+ __proto__: null,
83
+ TestWeb: TestWeb
84
+ });
85
+
86
+ exports.Test = Test;
87
+
88
+ return exports;
89
+
90
+ })({}, capacitorExports);
91
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"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 */\nimport { registerPlugin } from '@capacitor/core';\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('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// 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// Export the registered TestPlugin instance.\n// This makes the plugin instance available for import in other modules.\nexport { Test };\n//# sourceMappingURL=index.js.map","/**\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/**\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 {\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) {\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 * 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() {\n return { version: 'web' };\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;AACK,UAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;IACpC;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3D,CAAC;;ICtBD;IACA;IACA;IACA;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACO,MAAM,OAAO,SAASC,cAAS,CAAC;IACvC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;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;IACA;IACA;IACA;IACA;IACA;IACA;IACA,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,32 @@
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 - A variadic parameter accepting a list of items to log. Each item will be converted to a string and logged sequentially.
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
+ * - If multiple items are logged, they will be separated by the specified `separator` and terminated by the `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
+ }
@@ -0,0 +1,19 @@
1
+ import Foundation
2
+
3
+ /**
4
+ * Native implementation for the Test Capacitor plugin.
5
+ *
6
+ * This class contains platform logic only and does not depend on Capacitor APIs.
7
+ */
8
+ @objc public class Test: NSObject {
9
+ /**
10
+ * Returns the provided string unchanged.
11
+ *
12
+ * @param value Input string.
13
+ * @return The same string.
14
+ */
15
+ @objc public func echo(_ value: String) -> String {
16
+ log(value)
17
+ return value
18
+ }
19
+ }
@@ -0,0 +1,29 @@
1
+ import Foundation
2
+
3
+ /**
4
+ * Helper struct to manage the plugin configuration.
5
+ * It parses the values from capacitor.config.json
6
+ */
7
+ public struct TestConfig {
8
+
9
+ // Define configuration keys for consistency
10
+ private struct Keys {
11
+ static let customMessage = "customMessage"
12
+ }
13
+
14
+ // Default values
15
+ private let defaultCustomMessage = " (from config)"
16
+
17
+ // Public accessible properties
18
+ public var customMessage: String
19
+
20
+ /**
21
+ * Initialize with the config dictionary from the plugin.
22
+ */
23
+ init(config: [AnyHashable: Any]?) {
24
+ let config = config ?? [:]
25
+
26
+ // Parse customMessage with a default fallback
27
+ self.customMessage = config[Keys.customMessage] as? String ?? defaultCustomMessage
28
+ }
29
+ }
@@ -0,0 +1,77 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * This file defines the Capacitor bridge for the Test plugin.
6
+ *
7
+ * Documentation reference:
8
+ * https://capacitorjs.com/docs/plugins/ios
9
+ */
10
+
11
+ @objc(TestPlugin)
12
+ public class TestPlugin: CAPPlugin, CAPBridgedPlugin {
13
+
14
+ // Configuration instance
15
+ private var config: TestConfig?
16
+
17
+ /**
18
+ * Called when the plugin is loaded.
19
+ */
20
+ override public func load() {
21
+ log("Loading plugin")
22
+ self.config = TestConfig(
23
+ config: self.getConfig() as? [String: Any] ?? [:]
24
+ )
25
+ }
26
+
27
+ /// Plugin version (Dynamic read from the Bundle Info.plist)
28
+ private var pluginVersion: String {
29
+ let bundle = Bundle(for: type(of: self))
30
+ return bundle.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0.1"
31
+ }
32
+
33
+ /// The unique identifier for the plugin.
34
+ public let identifier = "TestPlugin"
35
+
36
+ /// The name used to reference this plugin in JavaScript.
37
+ public let jsName = "Test"
38
+
39
+ /**
40
+ * A list of methods exposed by this plugin. These methods can be called from the JavaScript side.
41
+ * - `echo`: A method that accepts a string and returns the same string.
42
+ * - `getPluginVersion`: A method that returns the version of the plugin.
43
+ */
44
+ public let pluginMethods: [CAPPluginMethod] = [
45
+ CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise),
46
+ CAPPluginMethod(name: "getPluginVersion", returnType: CAPPluginReturnPromise)
47
+ ]
48
+
49
+ /// An instance of the implementation class that contains the plugin's core functionality.
50
+ private let implementation = Test()
51
+
52
+ /**
53
+ * Echoes a string back to JavaScript.
54
+ *
55
+ * @param call Capacitor plugin call containing the `value` parameter.
56
+ */
57
+ @objc func echo(_ call: CAPPluginCall) {
58
+ var value = call.getString("value", "")
59
+ log("Echoing value: \(value)")
60
+
61
+ // Append the custom message from the configuration
62
+ if let configMessage = config?.customMessage {
63
+ value = value + configMessage
64
+ }
65
+
66
+ call.resolve([
67
+ "value": implementation.echo(value)
68
+ ])
69
+ }
70
+
71
+ /**
72
+ * Returns the plugin version.
73
+ */
74
+ @objc func getPluginVersion(_ call: CAPPluginCall) {
75
+ call.resolve(["version": self.pluginVersion])
76
+ }
77
+ }
@@ -0,0 +1,15 @@
1
+ import XCTest
2
+ @testable import TestPlugin
3
+
4
+ class TestTests: XCTestCase {
5
+ func testEcho() {
6
+ // This is an example of a functional test case for a plugin.
7
+ // Use XCTAssert and related functions to verify your tests produce the correct results.
8
+
9
+ let implementation = Test()
10
+ let value = "Hello, World!"
11
+ let result = implementation.echo(value)
12
+
13
+ XCTAssertEqual(value, result)
14
+ }
15
+ }
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@cap-kit/test-plugin",
3
+ "version": "0.0.1",
4
+ "description": "Test plugin for Cap-Kit.",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/",
13
+ "ios/Sources",
14
+ "ios/Tests",
15
+ "Package.swift",
16
+ "TestPlugin.podspec",
17
+ "LICENSE"
18
+ ],
19
+ "author": "Fabio Martino",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/cap-kit/plugins.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/cap-kit/plugins/issues"
27
+ },
28
+ "keywords": [
29
+ "capacitor",
30
+ "plugin",
31
+ "native"
32
+ ],
33
+ "devDependencies": {
34
+ "@capacitor/cli": "^8.0.0",
35
+ "@capacitor/android": "^8.0.0",
36
+ "@capacitor/core": "^8.0.0",
37
+ "@capacitor/docgen": "^0.3.1",
38
+ "@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
+ "rimraf": "^6.1.2",
46
+ "rollup": "^4.53.5",
47
+ "swiftlint": "^2.0.0",
48
+ "typescript": "^5.9.3"
49
+ },
50
+ "peerDependencies": {
51
+ "@capacitor/core": ">=8.0.0"
52
+ },
53
+ "prettier": "@ionic/prettier-config",
54
+ "swiftlint": "@ionic/swiftlint-config",
55
+ "eslintConfig": {
56
+ "extends": "@ionic/eslint-config/recommended"
57
+ },
58
+ "capacitor": {
59
+ "ios": {
60
+ "src": "ios"
61
+ },
62
+ "android": {
63
+ "src": "android"
64
+ }
65
+ },
66
+ "scripts": {
67
+ "verify": "pnpm run verify:ios && pnpm run verify:android && pnpm run verify:web",
68
+ "verify:ios": "xcodebuild -scheme TestPlugin -destination generic/platform=iOS",
69
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
70
+ "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",
73
+ "eslint": "eslint",
74
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
75
+ "swiftlint": "node-swiftlint",
76
+ "docgen": "docgen --api TestPlugin --output-readme README.md --output-json dist/docs.json",
77
+ "build": "pnpm run clean && pnpm run docgen && tsc && rollup -c rollup.config.mjs",
78
+ "clean": "rimraf ./dist",
79
+ "watch": "tsc --watch"
80
+ }
81
+ }