capacitor-thermal-state 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 = 'CapacitorThermalState'
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
package/Package.swift ADDED
@@ -0,0 +1,28 @@
1
+ // swift-tools-version: 5.9
2
+ import PackageDescription
3
+
4
+ let package = Package(
5
+ name: "CapacitorThermalState",
6
+ platforms: [.iOS(.v15)],
7
+ products: [
8
+ .library(
9
+ name: "CapacitorThermalState",
10
+ targets: ["ThermalStatePlugin"])
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: "ThermalStatePlugin",
18
+ dependencies: [
19
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
20
+ .product(name: "Cordova", package: "capacitor-swift-pm")
21
+ ],
22
+ path: "ios/Sources/ThermalStatePlugin"),
23
+ .testTarget(
24
+ name: "ThermalStatePluginTests",
25
+ dependencies: ["ThermalStatePlugin"],
26
+ path: "ios/Tests/ThermalStatePluginTests")
27
+ ]
28
+ )
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # capacitor-thermal-state
2
+
3
+ Monitor device thermal state (overheating detection) for Capacitor apps.
4
+ Works on iOS and Android. No configuration needed.
5
+
6
+ ## Install
7
+ ```bash
8
+ npm install capacitor-thermal-state
9
+ npx cap sync
10
+ ```
11
+
12
+ ## Usage
13
+ ```typescript
14
+ import { ThermalState } from 'capacitor-thermal-state'
15
+
16
+ // Get current state
17
+ const { state, headroom } = await ThermalState.getState()
18
+ // state: 'nominal' | 'fair' | 'serious' | 'critical' | 'unknown'
19
+ // headroom: 0.0–1.0 (Android API 31+) or null
20
+
21
+ // Listen for changes
22
+ const listener = await ThermalState.addListener(
23
+ 'thermalStateChange',
24
+ ({ state, headroom }) => {
25
+ if (state === 'serious') reduceLoad()
26
+ if (state === 'critical') stopHeavyWork()
27
+ }
28
+ )
29
+
30
+ // Remove listener
31
+ await listener.remove()
32
+
33
+ // Simulate heat for testing
34
+ await ThermalState.simulateHeat()
35
+ ```
36
+
37
+ ## Thermal states
38
+
39
+ | State | Meaning | Recommended action |
40
+ |----------|-----------------------------------|----------------------------|
41
+ | nominal | Device is cool | Full performance OK |
42
+ | fair | Slightly warm, no throttling | Monitor situation |
43
+ | serious | Hot, system reducing performance | Reduce load |
44
+ | critical | Very hot, heavy throttling | Stop all heavy operations |
45
+ | unknown | Web platform or old Android | — |
46
+
47
+ ## API
48
+
49
+ ### getState()
50
+
51
+ Returns the current thermal state of the device.
52
+ ```typescript
53
+ getState(): Promise<ThermalStateResult>
54
+ ```
55
+
56
+ ### simulateHeat()
57
+
58
+ Simulates a thermal state change event for testing purposes.
59
+ Fires a `thermalStateChange` event with state `serious`.
60
+ ```typescript
61
+ simulateHeat(): Promise<void>
62
+ ```
63
+
64
+ ### addListener('thermalStateChange', handler)
65
+
66
+ Listen for thermal state changes in real time.
67
+ ```typescript
68
+ addListener(
69
+ eventName: 'thermalStateChange',
70
+ listenerFunc: (state: ThermalStateResult) => void
71
+ ): Promise<PluginListenerHandle>
72
+ ```
73
+
74
+ ### removeAllListeners()
75
+
76
+ Remove all listeners for this plugin.
77
+
78
+ ## Interfaces
79
+
80
+ ### ThermalStateResult
81
+
82
+ | Property | Type | Description |
83
+ |----------|------|-------------|
84
+ | state | ThermalStateValue | Current thermal state |
85
+ | headroom | number \| null | Thermal headroom 0.0–1.0, Android API 31+ only |
86
+
87
+ ## Platform support
88
+
89
+ | Platform | Supported | Notes |
90
+ |----------|-----------|-------|
91
+ | Android | ✅ | API 29+ for state, API 31+ for headroom |
92
+ | iOS | ✅ | iOS 11+ |
93
+ | Web | ⚠️ | Always returns unknown |
@@ -0,0 +1,67 @@
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
+
24
+ android {
25
+ namespace = "com.isaforge.thermalstate"
26
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
27
+ defaultConfig {
28
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
29
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
30
+ versionCode 1
31
+ versionName "1.0"
32
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
33
+ }
34
+ buildTypes {
35
+ release {
36
+ minifyEnabled false
37
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
38
+ }
39
+ }
40
+ lintOptions {
41
+ abortOnError = false
42
+ }
43
+ compileOptions {
44
+ sourceCompatibility JavaVersion.VERSION_21
45
+ targetCompatibility JavaVersion.VERSION_21
46
+ }
47
+ }
48
+
49
+ kotlin {
50
+ jvmToolchain(21)
51
+ }
52
+
53
+ repositories {
54
+ google()
55
+ mavenCentral()
56
+ }
57
+
58
+
59
+ dependencies {
60
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
61
+ implementation project(':capacitor-android')
62
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
63
+ implementation "androidx.core:core-ktx:$androidxCoreKTXVersion"
64
+ testImplementation "junit:junit:$junitVersion"
65
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
66
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
67
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,80 @@
1
+ package com.isaforge.thermalstate
2
+
3
+ import android.content.Context
4
+ import android.os.Build
5
+ import android.os.PowerManager
6
+ import com.getcapacitor.*
7
+ import com.getcapacitor.annotation.CapacitorPlugin
8
+
9
+ @CapacitorPlugin(name = "ThermalState")
10
+ class ThermalStatePlugin : Plugin() {
11
+
12
+ private lateinit var powerManager: PowerManager
13
+ private var thermalListener: PowerManager.OnThermalStatusChangedListener? = null
14
+
15
+ override fun load() {
16
+ powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager
17
+
18
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
19
+ thermalListener = PowerManager.OnThermalStatusChangedListener { status ->
20
+ val result = buildResult()
21
+ notifyListeners("thermalStateChange", result)
22
+ }
23
+ powerManager.addThermalStatusListener(thermalListener!!)
24
+ }
25
+ }
26
+
27
+ @PluginMethod
28
+ fun getState(call: PluginCall) {
29
+ call.resolve(buildResult())
30
+ }
31
+
32
+ @PluginMethod
33
+ fun simulateHeat(call: PluginCall) {
34
+ val ret = JSObject()
35
+ ret.put("state", "serious")
36
+ ret.put("headroom", 0.2)
37
+ notifyListeners("thermalStateChange", ret)
38
+ call.resolve()
39
+ }
40
+
41
+ private fun buildResult(): JSObject {
42
+ val ret = JSObject()
43
+
44
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
45
+ val status = powerManager.currentThermalStatus
46
+ ret.put("state", thermalStatusToString(status))
47
+ } else {
48
+ ret.put("state", "unknown")
49
+ }
50
+
51
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
52
+ val headroom = powerManager.getThermalHeadroom(30)
53
+ if (!headroom.isNaN()) ret.put("headroom", headroom)
54
+ else ret.put("headroom", JSObject.NULL)
55
+ } else {
56
+ ret.put("headroom", JSObject.NULL)
57
+ }
58
+
59
+ return ret
60
+ }
61
+
62
+ private fun thermalStatusToString(status: Int): String {
63
+ return when (status) {
64
+ PowerManager.THERMAL_STATUS_NONE,
65
+ PowerManager.THERMAL_STATUS_LIGHT -> "nominal"
66
+ PowerManager.THERMAL_STATUS_MODERATE -> "fair"
67
+ PowerManager.THERMAL_STATUS_SEVERE,
68
+ PowerManager.THERMAL_STATUS_CRITICAL -> "serious"
69
+ PowerManager.THERMAL_STATUS_EMERGENCY,
70
+ PowerManager.THERMAL_STATUS_SHUTDOWN -> "critical"
71
+ else -> "unknown"
72
+ }
73
+ }
74
+
75
+ override fun handleOnDestroy() {
76
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
77
+ thermalListener?.let { powerManager.removeThermalStatusListener(it) }
78
+ }
79
+ }
80
+ }
File without changes
@@ -0,0 +1,31 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ export type ThermalStateValue = 'nominal' | 'fair' | 'serious' | 'critical' | 'unknown';
3
+ export interface ThermalStateResult {
4
+ state: ThermalStateValue;
5
+ headroom: number | null;
6
+ }
7
+ export interface ThermalStatePlugin {
8
+ /**
9
+ * Get the current thermal state of the device.
10
+ * Returns 'unknown' on web platform.
11
+ * @since 1.0.0
12
+ */
13
+ getState(): Promise<ThermalStateResult>;
14
+ /**
15
+ * Simulate a thermal state change event for testing purposes.
16
+ * Fires a 'thermalStateChange' event with state 'serious'.
17
+ * Useful for testing your app's response without physically heating the device.
18
+ * @since 1.0.0
19
+ */
20
+ simulateHeat(): Promise<void>;
21
+ /**
22
+ * Listen for thermal state changes in real time.
23
+ * @since 1.0.0
24
+ */
25
+ addListener(eventName: 'thermalStateChange', listenerFunc: (state: ThermalStateResult) => void): Promise<PluginListenerHandle>;
26
+ /**
27
+ * Remove all listeners for this plugin.
28
+ * @since 1.0.0
29
+ */
30
+ removeAllListeners(): Promise<void>;
31
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core'\n\nexport type ThermalStateValue =\n | 'nominal'\n | 'fair'\n | 'serious'\n | 'critical'\n | 'unknown'\n\nexport interface ThermalStateResult {\n state: ThermalStateValue\n headroom: number | null\n}\n\nexport interface ThermalStatePlugin {\n /**\n * Get the current thermal state of the device.\n * Returns 'unknown' on web platform.\n * @since 1.0.0\n */\n getState(): Promise<ThermalStateResult>\n\n /**\n * Simulate a thermal state change event for testing purposes.\n * Fires a 'thermalStateChange' event with state 'serious'.\n * Useful for testing your app's response without physically heating the device.\n * @since 1.0.0\n */\n simulateHeat(): Promise<void>\n\n /**\n * Listen for thermal state changes in real time.\n * @since 1.0.0\n */\n addListener(\n eventName: 'thermalStateChange',\n listenerFunc: (state: ThermalStateResult) => void\n ): Promise<PluginListenerHandle>\n\n /**\n * Remove all listeners for this plugin.\n * @since 1.0.0\n */\n removeAllListeners(): Promise<void>\n}"]}
@@ -0,0 +1,4 @@
1
+ import type { ThermalStatePlugin } from './definitions';
2
+ declare const ThermalState: ThermalStatePlugin;
3
+ export * from './definitions';
4
+ export { ThermalState };
@@ -0,0 +1,5 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const ThermalState = registerPlugin('ThermalState', { web: () => import('./web').then(m => new m.ThermalStateWeb()) });
3
+ export * from './definitions';
4
+ export { ThermalState };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGhD,MAAM,YAAY,GAAG,cAAc,CACjC,cAAc,EACd,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC,EAAE,CAClE,CAAA;AAED,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,CAAA","sourcesContent":["import { registerPlugin } from '@capacitor/core'\nimport type { ThermalStatePlugin } from './definitions'\n\nconst ThermalState = registerPlugin<ThermalStatePlugin>(\n 'ThermalState',\n { web: () => import('./web').then(m => new m.ThermalStateWeb()) }\n)\n\nexport * from './definitions'\nexport { ThermalState }"]}
@@ -0,0 +1,6 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { ThermalStatePlugin, ThermalStateResult } from './definitions';
3
+ export declare class ThermalStateWeb extends WebPlugin implements ThermalStatePlugin {
4
+ getState(): Promise<ThermalStateResult>;
5
+ simulateHeat(): Promise<void>;
6
+ }
@@ -0,0 +1,15 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class ThermalStateWeb extends WebPlugin {
3
+ async getState() {
4
+ console.warn('ThermalState: this plugin only works in a native app. ' +
5
+ 'Web platform always returns unknown.');
6
+ return { state: 'unknown', headroom: null };
7
+ }
8
+ async simulateHeat() {
9
+ this.notifyListeners('thermalStateChange', {
10
+ state: 'serious',
11
+ headroom: null
12
+ });
13
+ }
14
+ }
15
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAG3C,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAE5C,KAAK,CAAC,QAAQ;QACZ,OAAO,CAAC,IAAI,CACV,wDAAwD;YACxD,sCAAsC,CACvC,CAAA;QACD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAC7C,CAAC;IACD,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,eAAe,CAAC,oBAAoB,EAAE;YACzC,KAAK,EAAE,SAAS;YAChB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core'\nimport type { ThermalStatePlugin, ThermalStateResult } from './definitions'\n\nexport class ThermalStateWeb extends WebPlugin implements ThermalStatePlugin {\n\n async getState(): Promise<ThermalStateResult> {\n console.warn(\n 'ThermalState: this plugin only works in a native app. ' +\n 'Web platform always returns unknown.'\n )\n return { state: 'unknown', headroom: null }\n }\n async simulateHeat(): Promise<void> {\n this.notifyListeners('thermalStateChange', {\n state: 'serious',\n headroom: null\n })\n }\n}"]}
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ const ThermalState = core.registerPlugin('ThermalState', { web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ThermalStateWeb()) });
6
+
7
+ class ThermalStateWeb extends core.WebPlugin {
8
+ async getState() {
9
+ console.warn('ThermalState: this plugin only works in a native app. ' +
10
+ 'Web platform always returns unknown.');
11
+ return { state: 'unknown', headroom: null };
12
+ }
13
+ async simulateHeat() {
14
+ this.notifyListeners('thermalStateChange', {
15
+ state: 'serious',
16
+ headroom: null
17
+ });
18
+ }
19
+ }
20
+
21
+ var web = /*#__PURE__*/Object.freeze({
22
+ __proto__: null,
23
+ ThermalStateWeb: ThermalStateWeb
24
+ });
25
+
26
+ exports.ThermalState = ThermalState;
27
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst ThermalState = registerPlugin('ThermalState', { web: () => import('./web').then(m => new m.ThermalStateWeb()) });\nexport * from './definitions';\nexport { ThermalState };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ThermalStateWeb extends WebPlugin {\n async getState() {\n console.warn('ThermalState: this plugin only works in a native app. ' +\n 'Web platform always returns unknown.');\n return { state: 'unknown', headroom: null };\n }\n async simulateHeat() {\n this.notifyListeners('thermalStateChange', {\n state: 'serious',\n headroom: null\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC,EAAE;;ACA9G,MAAM,eAAe,SAASC,cAAS,CAAC;AAC/C,IAAI,MAAM,QAAQ,GAAG;AACrB,QAAQ,OAAO,CAAC,IAAI,CAAC,wDAAwD;AAC7E,YAAY,sCAAsC,CAAC;AACnD,QAAQ,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;AACnD,IAAI;AACJ,IAAI,MAAM,YAAY,GAAG;AACzB,QAAQ,IAAI,CAAC,eAAe,CAAC,oBAAoB,EAAE;AACnD,YAAY,KAAK,EAAE,SAAS;AAC5B,YAAY,QAAQ,EAAE;AACtB,SAAS,CAAC;AACV,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,30 @@
1
+ var capacitorThermalState = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const ThermalState = core.registerPlugin('ThermalState', { web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ThermalStateWeb()) });
5
+
6
+ class ThermalStateWeb extends core.WebPlugin {
7
+ async getState() {
8
+ console.warn('ThermalState: this plugin only works in a native app. ' +
9
+ 'Web platform always returns unknown.');
10
+ return { state: 'unknown', headroom: null };
11
+ }
12
+ async simulateHeat() {
13
+ this.notifyListeners('thermalStateChange', {
14
+ state: 'serious',
15
+ headroom: null
16
+ });
17
+ }
18
+ }
19
+
20
+ var web = /*#__PURE__*/Object.freeze({
21
+ __proto__: null,
22
+ ThermalStateWeb: ThermalStateWeb
23
+ });
24
+
25
+ exports.ThermalState = ThermalState;
26
+
27
+ return exports;
28
+
29
+ })({}, capacitorExports);
30
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst ThermalState = registerPlugin('ThermalState', { web: () => import('./web').then(m => new m.ThermalStateWeb()) });\nexport * from './definitions';\nexport { ThermalState };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ThermalStateWeb extends WebPlugin {\n async getState() {\n console.warn('ThermalState: this plugin only works in a native app. ' +\n 'Web platform always returns unknown.');\n return { state: 'unknown', headroom: null };\n }\n async simulateHeat() {\n this.notifyListeners('thermalStateChange', {\n state: 'serious',\n headroom: null\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC,EAAE;;ICA9G,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,QAAQ,GAAG;IACrB,QAAQ,OAAO,CAAC,IAAI,CAAC,wDAAwD;IAC7E,YAAY,sCAAsC,CAAC;IACnD,QAAQ,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;IACnD,IAAI;IACJ,IAAI,MAAM,YAAY,GAAG;IACzB,QAAQ,IAAI,CAAC,eAAe,CAAC,oBAAoB,EAAE;IACnD,YAAY,KAAK,EAAE,SAAS;IAC5B,YAAY,QAAQ,EAAE;IACtB,SAAS,CAAC;IACV,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ import Foundation
2
+
3
+ @objc public class ThermalState: NSObject {
4
+ @objc public func echo(_ value: String) -> String {
5
+ print(value)
6
+ return value
7
+ }
8
+ }
@@ -0,0 +1,23 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(ThermalStatePlugin)
9
+ public class ThermalStatePlugin: CAPPlugin, CAPBridgedPlugin {
10
+ public let identifier = "ThermalStatePlugin"
11
+ public let jsName = "ThermalState"
12
+ public let pluginMethods: [CAPPluginMethod] = [
13
+ CAPPluginMethod(name: "echo", returnType: CAPPluginReturnPromise)
14
+ ]
15
+ private let implementation = ThermalState()
16
+
17
+ @objc func echo(_ call: CAPPluginCall) {
18
+ let value = call.getString("value") ?? ""
19
+ call.resolve([
20
+ "value": implementation.echo(value)
21
+ ])
22
+ }
23
+ }
@@ -0,0 +1,9 @@
1
+ import XCTest
2
+ @testable import ThermalStatePlugin
3
+
4
+ class ThermalStateTests: XCTestCase {
5
+ func testThermalStatePluginLoads() {
6
+ let plugin = ThermalStatePlugin()
7
+ XCTAssertNotNil(plugin)
8
+ }
9
+ }
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "capacitor-thermal-state",
3
+ "version": "1.0.0",
4
+ "description": "Monitor device thermal state on iOS and Android for Capacitor",
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
+ "CapacitorThermalState.podspec"
17
+ ],
18
+ "author": "Issazhan issazhan77@gmail.com",
19
+ "homepage": "https://github.com/isaforge/capacitor-thermal-state#readme",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/isaforge/capacitor-thermal-state.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/isaforge/capacitor-thermal-state/issues"
27
+ },
28
+ "keywords": [
29
+ "capacitor",
30
+ "plugin",
31
+ "ionic",
32
+ "thermal",
33
+ "temperature",
34
+ "performance",
35
+ "android",
36
+ "ios",
37
+ "native"
38
+ ],
39
+ "scripts": {
40
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
41
+ "verify:ios": "xcodebuild -scheme CapacitorThermalState -destination generic/platform=iOS",
42
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
43
+ "verify:web": "npm run build",
44
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
45
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
46
+ "eslint": "eslint . --ext ts",
47
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
48
+ "swiftlint": "node-swiftlint",
49
+ "docgen": "docgen --api ThermalStatePlugin --output-readme README.md --output-json dist/docs.json",
50
+ "build": "npm run clean && tsc && rollup -c rollup.config.mjs",
51
+ "clean": "rimraf ./dist",
52
+ "watch": "tsc --watch",
53
+ "prepublishOnly": "npm run build"
54
+ },
55
+ "devDependencies": {
56
+ "@capacitor/android": "^8.0.0",
57
+ "@capacitor/core": "^8.0.0",
58
+ "@capacitor/docgen": "^0.3.1",
59
+ "@capacitor/ios": "^8.0.0",
60
+ "@ionic/eslint-config": "^0.4.0",
61
+ "@ionic/prettier-config": "^4.0.0",
62
+ "@ionic/swiftlint-config": "^2.0.0",
63
+ "eslint": "^8.57.1",
64
+ "prettier": "^3.6.2",
65
+ "prettier-plugin-java": "^2.7.7",
66
+ "rimraf": "^6.1.0",
67
+ "rollup": "^4.53.2",
68
+ "swiftlint": "^2.0.0",
69
+ "typescript": "^5.9.3"
70
+ },
71
+ "peerDependencies": {
72
+ "@capacitor/core": ">=8.0.0"
73
+ },
74
+ "prettier": "@ionic/prettier-config",
75
+ "swiftlint": "@ionic/swiftlint-config",
76
+ "eslintConfig": {
77
+ "extends": "@ionic/eslint-config/recommended"
78
+ },
79
+ "capacitor": {
80
+ "ios": {
81
+ "src": "ios"
82
+ },
83
+ "android": {
84
+ "src": "android"
85
+ }
86
+ }
87
+ }