capacitor-timer-notification
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -14,3 +14,3 @@ { | ||
"name": "options", | ||
"docs": "", | ||
"docs": "Duration in seconds.", | ||
"type": "{ duration: number; }" | ||
@@ -20,4 +20,9 @@ } | ||
"returns": "Promise<void>", | ||
"tags": [], | ||
"docs": "", | ||
"tags": [ | ||
{ | ||
"name": "param", | ||
"text": "options Duration in seconds." | ||
} | ||
], | ||
"docs": "Starts the timer with a specified duration.", | ||
"complexTypes": [], | ||
@@ -32,3 +37,3 @@ "slug": "starttimer" | ||
"tags": [], | ||
"docs": "", | ||
"docs": "Stops the currently running timer.", | ||
"complexTypes": [], | ||
@@ -42,6 +47,47 @@ "slug": "stoptimer" | ||
"returns": "Promise<{ remainingTime: number; }>", | ||
"tags": [], | ||
"docs": "", | ||
"tags": [ | ||
{ | ||
"name": "returns", | ||
"text": "Remaining time in seconds." | ||
} | ||
], | ||
"docs": "Gets the remaining time of the running timer.", | ||
"complexTypes": [], | ||
"slug": "getremainingtime" | ||
}, | ||
{ | ||
"name": "addListener", | ||
"signature": "(eventName: \"remainingTimeUpdate\", listenerFn: (data: { remainingTime: number; }) => void) => Promise<PluginListenerHandle>", | ||
"parameters": [ | ||
{ | ||
"name": "eventName", | ||
"docs": "Name of the event ('remainingTimeUpdate').", | ||
"type": "'remainingTimeUpdate'" | ||
}, | ||
{ | ||
"name": "listenerFn", | ||
"docs": "Callback function with the remaining time.", | ||
"type": "(data: { remainingTime: number; }) => void" | ||
} | ||
], | ||
"returns": "Promise<PluginListenerHandle>", | ||
"tags": [ | ||
{ | ||
"name": "param", | ||
"text": "eventName Name of the event ('remainingTimeUpdate')." | ||
}, | ||
{ | ||
"name": "param", | ||
"text": "listenerFn Callback function with the remaining time." | ||
}, | ||
{ | ||
"name": "returns", | ||
"text": "A handle to remove the listener." | ||
} | ||
], | ||
"docs": "Listens for updates on the remaining time.", | ||
"complexTypes": [ | ||
"PluginListenerHandle" | ||
], | ||
"slug": "addlistenerremainingtimeupdate-" | ||
} | ||
@@ -51,3 +97,20 @@ ], | ||
}, | ||
"interfaces": [], | ||
"interfaces": [ | ||
{ | ||
"name": "PluginListenerHandle", | ||
"slug": "pluginlistenerhandle", | ||
"docs": "", | ||
"tags": [], | ||
"methods": [], | ||
"properties": [ | ||
{ | ||
"name": "remove", | ||
"tags": [], | ||
"docs": "", | ||
"complexTypes": [], | ||
"type": "() => Promise<void>" | ||
} | ||
] | ||
} | ||
], | ||
"enums": [], | ||
@@ -54,0 +117,0 @@ "typeAliases": [], |
@@ -0,9 +1,30 @@ | ||
import { PluginListenerHandle } from "@capacitor/core"; | ||
export interface TimerNotificationPlugin { | ||
/** | ||
* Starts the timer with a specified duration. | ||
* @param options Duration in seconds. | ||
*/ | ||
startTimer(options: { | ||
duration: number; | ||
}): Promise<void>; | ||
/** | ||
* Stops the currently running timer. | ||
*/ | ||
stopTimer(): Promise<void>; | ||
/** | ||
* Gets the remaining time of the running timer. | ||
* @returns Remaining time in seconds. | ||
*/ | ||
getRemainingTime(): Promise<{ | ||
remainingTime: number; | ||
}>; | ||
/** | ||
* Listens for updates on the remaining time. | ||
* @param eventName Name of the event ('remainingTimeUpdate'). | ||
* @param listenerFn Callback function with the remaining time. | ||
* @returns A handle to remove the listener. | ||
*/ | ||
addListener(eventName: "remainingTimeUpdate", listenerFn: (data: { | ||
remainingTime: number; | ||
}) => void): Promise<PluginListenerHandle>; | ||
} |
@@ -1,5 +0,6 @@ | ||
import { WebPlugin } from '@capacitor/core'; | ||
import { TimerNotificationPlugin } from './definitions'; | ||
import { WebPlugin } from "@capacitor/core"; | ||
import type { TimerNotificationPlugin } from "./definitions"; | ||
export declare class TimerNotificationWeb extends WebPlugin implements TimerNotificationPlugin { | ||
constructor(); | ||
private remainingTime; | ||
private intervalId; | ||
startTimer(options: { | ||
@@ -6,0 +7,0 @@ duration: number; |
@@ -1,20 +0,36 @@ | ||
import { WebPlugin } from '@capacitor/core'; | ||
import { WebPlugin } from "@capacitor/core"; | ||
export class TimerNotificationWeb extends WebPlugin { | ||
constructor() { | ||
super({ | ||
name: 'TimerNotification', | ||
platforms: ['web'], | ||
}); | ||
super(...arguments); | ||
this.remainingTime = 0; | ||
} | ||
async startTimer(options) { | ||
console.log(`Timer started for ${options.duration} seconds on Web`); | ||
this.remainingTime = options.duration; | ||
if (this.intervalId) | ||
clearInterval(this.intervalId); | ||
this.intervalId = setInterval(() => { | ||
if (this.remainingTime > 0) { | ||
this.remainingTime -= 1; | ||
this.notifyListeners("remainingTimeUpdate", { | ||
remainingTime: this.remainingTime, | ||
}); | ||
} | ||
else { | ||
clearInterval(this.intervalId); | ||
} | ||
}, 1000); | ||
} | ||
async stopTimer() { | ||
console.log('Timer stopped on Web'); | ||
if (this.intervalId) { | ||
clearInterval(this.intervalId); | ||
} | ||
this.remainingTime = 0; | ||
this.notifyListeners("remainingTimeUpdate", { | ||
remainingTime: this.remainingTime, | ||
}); | ||
} | ||
async getRemainingTime() { | ||
console.log('Returning remaining time on Web'); | ||
return { remainingTime: 0 }; // Web doesn't support actual timers | ||
return { remainingTime: this.remainingTime }; | ||
} | ||
} | ||
//# sourceMappingURL=web.js.map |
@@ -9,16 +9,32 @@ 'use strict'; | ||
constructor() { | ||
super({ | ||
name: 'TimerNotification', | ||
platforms: ['web'], | ||
}); | ||
super(...arguments); | ||
this.remainingTime = 0; | ||
} | ||
async startTimer(options) { | ||
console.log(`Timer started for ${options.duration} seconds on Web`); | ||
this.remainingTime = options.duration; | ||
if (this.intervalId) | ||
clearInterval(this.intervalId); | ||
this.intervalId = setInterval(() => { | ||
if (this.remainingTime > 0) { | ||
this.remainingTime -= 1; | ||
this.notifyListeners("remainingTimeUpdate", { | ||
remainingTime: this.remainingTime, | ||
}); | ||
} | ||
else { | ||
clearInterval(this.intervalId); | ||
} | ||
}, 1000); | ||
} | ||
async stopTimer() { | ||
console.log('Timer stopped on Web'); | ||
if (this.intervalId) { | ||
clearInterval(this.intervalId); | ||
} | ||
this.remainingTime = 0; | ||
this.notifyListeners("remainingTimeUpdate", { | ||
remainingTime: this.remainingTime, | ||
}); | ||
} | ||
async getRemainingTime() { | ||
console.log('Returning remaining time on Web'); | ||
return { remainingTime: 0 }; // Web doesn't support actual timers | ||
return { remainingTime: this.remainingTime }; | ||
} | ||
@@ -25,0 +41,0 @@ } |
@@ -6,16 +6,32 @@ var capacitorTimerNotification = (function (exports, core) { | ||
constructor() { | ||
super({ | ||
name: 'TimerNotification', | ||
platforms: ['web'], | ||
}); | ||
super(...arguments); | ||
this.remainingTime = 0; | ||
} | ||
async startTimer(options) { | ||
console.log(`Timer started for ${options.duration} seconds on Web`); | ||
this.remainingTime = options.duration; | ||
if (this.intervalId) | ||
clearInterval(this.intervalId); | ||
this.intervalId = setInterval(() => { | ||
if (this.remainingTime > 0) { | ||
this.remainingTime -= 1; | ||
this.notifyListeners("remainingTimeUpdate", { | ||
remainingTime: this.remainingTime, | ||
}); | ||
} | ||
else { | ||
clearInterval(this.intervalId); | ||
} | ||
}, 1000); | ||
} | ||
async stopTimer() { | ||
console.log('Timer stopped on Web'); | ||
if (this.intervalId) { | ||
clearInterval(this.intervalId); | ||
} | ||
this.remainingTime = 0; | ||
this.notifyListeners("remainingTimeUpdate", { | ||
remainingTime: this.remainingTime, | ||
}); | ||
} | ||
async getRemainingTime() { | ||
console.log('Returning remaining time on Web'); | ||
return { remainingTime: 0 }; // Web doesn't support actual timers | ||
return { remainingTime: this.remainingTime }; | ||
} | ||
@@ -22,0 +38,0 @@ } |
{ | ||
"name": "capacitor-timer-notification", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "timer notifcation", | ||
@@ -5,0 +5,0 @@ "main": "dist/plugin.cjs.js", |
@@ -5,2 +5,4 @@ ## capacitor-timer-notification | ||
Stable Version is 0.24!! | ||
## Usage | ||
@@ -37,2 +39,4 @@ | ||
* [`getRemainingTime()`](#getremainingtime) | ||
* [`addListener('remainingTimeUpdate', ...)`](#addlistenerremainingtimeupdate-) | ||
* [Interfaces](#interfaces) | ||
@@ -50,6 +54,8 @@ </docgen-index> | ||
| Param | Type | | ||
| ------------- | ---------------------------------- | | ||
| **`options`** | <code>{ duration: number; }</code> | | ||
Starts the timer with a specified duration. | ||
| Param | Type | Description | | ||
| ------------- | ---------------------------------- | -------------------- | | ||
| **`options`** | <code>{ duration: number; }</code> | Duration in seconds. | | ||
-------------------- | ||
@@ -64,2 +70,4 @@ | ||
Stops the currently running timer. | ||
-------------------- | ||
@@ -74,2 +82,4 @@ | ||
Gets the remaining time of the running timer. | ||
**Returns:** <code>Promise<{ remainingTime: number; }></code> | ||
@@ -79,2 +89,30 @@ | ||
### addListener('remainingTimeUpdate', ...) | ||
```typescript | ||
addListener(eventName: "remainingTimeUpdate", listenerFn: (data: { remainingTime: number; }) => void) => Promise<PluginListenerHandle> | ||
``` | ||
Listens for updates on the remaining time. | ||
| Param | Type | Description | | ||
| ---------------- | ---------------------------------------------------------- | ------------------------------------------ | | ||
| **`eventName`** | <code>'remainingTimeUpdate'</code> | Name of the event ('remainingTimeUpdate'). | | ||
| **`listenerFn`** | <code>(data: { remainingTime: number; }) => void</code> | Callback function with the remaining time. | | ||
**Returns:** <code>Promise<<a href="#pluginlistenerhandle">PluginListenerHandle</a>></code> | ||
-------------------- | ||
### Interfaces | ||
#### PluginListenerHandle | ||
| Prop | Type | | ||
| ------------ | ----------------------------------------- | | ||
| **`remove`** | <code>() => Promise<void></code> | | ||
</docgen-api> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
289
113
0
36061
26