@capacitor/background-runner 1.0.6-dev-20251124T212222.0 → 1.0.6-dev-20251209T171016.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/Package.swift CHANGED
@@ -4,42 +4,42 @@
4
4
  import PackageDescription
5
5
 
6
6
  let package = Package(
7
- name: "CapacitorBackgroundRunner",
8
- platforms: [.iOS(.v14), .macOS(.v13)],
9
- products: [
10
- // Products define the executables and libraries a package produces, making them visible to other packages.
11
- .library(
12
- name: "CapacitorBackgroundRunner",
13
- targets: ["CapacitorBackgroundRunner"]
14
- )
15
- ],
16
- dependencies: [
17
- .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
18
- ],
19
- targets: [
20
- // Targets are the basic building blocks of a package, defining a module or a test suite.
21
- // Targets can depend on other targets in this package and products from dependencies.
22
- .target(
23
- name: "CapacitorBackgroundRunner",
24
- dependencies: [
25
- .product(name: "Capacitor", package: "capacitor-swift-pm"),
26
- .product(name: "Cordova", package: "capacitor-swift-pm"),
27
- "RunnerEngine",
28
- ],
29
- path: "ios/Sources/CapacitorBackgroundRunner"
30
- ),
31
- .target(
32
- name: "RunnerEngine",
33
- dependencies: [],
34
- path: "ios/Sources/RunnerEngine"),
35
- .testTarget(
36
- name: "RunnerEngineTests",
37
- dependencies: ["RunnerEngine"],
38
- path: "ios/Tests/RunnerEngineTests"),
39
- .testTarget(
40
- name: "CapacitorBackgroundRunnerTests",
41
- dependencies: ["CapacitorBackgroundRunner"],
42
- path: "ios/Tests/CapacitorBackgroundRunnerTests"
43
- ),
44
- ]
7
+ name: "CapacitorBackgroundRunner",
8
+ platforms: [.iOS(.v14), .macOS(.v13)],
9
+ products: [
10
+ // Products define the executables and libraries a package produces, making them visible to other packages.
11
+ .library(
12
+ name: "CapacitorBackgroundRunner",
13
+ targets: ["CapacitorBackgroundRunner"]
14
+ )
15
+ ],
16
+ dependencies: [
17
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
18
+ ],
19
+ targets: [
20
+ // Targets are the basic building blocks of a package, defining a module or a test suite.
21
+ // Targets can depend on other targets in this package and products from dependencies.
22
+ .target(
23
+ name: "CapacitorBackgroundRunner",
24
+ dependencies: [
25
+ .product(name: "Capacitor", package: "capacitor-swift-pm"),
26
+ .product(name: "Cordova", package: "capacitor-swift-pm"),
27
+ "RunnerEngine"
28
+ ],
29
+ path: "ios/Sources/CapacitorBackgroundRunner"
30
+ ),
31
+ .target(
32
+ name: "RunnerEngine",
33
+ dependencies: [],
34
+ path: "ios/Sources/RunnerEngine"),
35
+ .testTarget(
36
+ name: "RunnerEngineTests",
37
+ dependencies: ["RunnerEngine"],
38
+ path: "ios/Tests/RunnerEngineTests"),
39
+ .testTarget(
40
+ name: "CapacitorBackgroundRunnerTests",
41
+ dependencies: ["CapacitorBackgroundRunner"],
42
+ path: "ios/Tests/CapacitorBackgroundRunnerTests"
43
+ )
44
+ ]
45
45
  )
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\nexport interface BackgroundRunnerConfig {\n /**\n * The name of the runner, used in logs.\n *\n * @since 1.0.0\n */\n label: string;\n /**\n * The path to the runner JavaScript file, relative to the app bundle.\n *\n * @since 1.0.0\n */\n src: string;\n /**\n * The name of the event that will be called when the OS executes the background task.\n *\n * @since 1.0.0\n */\n event: string;\n /**\n * If background task should repeat based on the interval set in `interval`.\n *\n * @since 1.0.0\n */\n repeat: boolean;\n /**\n * The number of minutes after the the app is put into the background in which the background task should begin.\n *\n * If `repeat` is true, this also specifies the number of minutes between each execution.\n *\n * @since 1.0.0\n */\n interval: number;\n /**\n * Automatically register and schedule background task on app load.\n *\n * @since 1.0.0\n */\n autoStart?: boolean;\n}\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * On load, Background Runner will automatically register a\n * background task that will be scheduled and run once your app is\n * backgrounded.\n */\n BackgroundRunner?: {\n /**\n * The name of the runner, used in logs.\n *\n * @since 1.0.0\n * @example \"com.example.background.task\"\n */\n label: string;\n /**\n * The path to the runner JavaScript file, relative to the app bundle.\n *\n * @since 1.0.0\n * @example \"runners/background.js\"\n */\n src: string;\n /**\n * The name of the event that will be called when the OS executes the background task.\n *\n * @since 1.0.0\n * @example \"myCustomEvent\"\n */\n event: string;\n /**\n * If background task should repeat based on the interval set in `interval`.\n *\n * @since 1.0.0\n * @example true\n */\n repeat: boolean;\n /**\n * The number of minutes after the the app is put into the background in which the background task should begin.\n *\n * If `repeat` is true, this also specifies the number of minutes between each execution.\n *\n * @since 1.0.0\n * @example 15\n */\n interval: number;\n /**\n * Automatically register and schedule background task on app load.\n *\n * @since 1.0.0\n * @example true\n */\n autoStart?: boolean;\n };\n }\n}\n\nexport type API = 'geolocation' | 'notifications';\n\nexport interface PermissionStatus {\n geolocation: PermissionState;\n notifications: PermissionState;\n}\n\nexport interface DispatchEventOptions {\n /**\n * The runner label to dispatch the event to\n *\n * @since 1.0.0\n */\n label: string;\n /**\n * The name of the registered event listener.\n *\n * @since 1.0.0\n */\n event: string;\n details: { [key: string]: any };\n}\n\nexport interface RequestPermissionOptions {\n apis: API[];\n}\n\nexport interface RegisterBackgroundTaskOptions {\n runner: BackgroundRunnerConfig;\n}\n\nexport interface NotificationActionEvent {\n actionTypeId: string;\n notificationId: number;\n}\n\nexport interface BackgroundRunnerPlugin {\n /**\n * Check permissions for the various Capacitor device APIs.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n /**\n * Request permission to display local notifications.\n *\n * @since 1.0.0\n */\n requestPermissions(\n options: RequestPermissionOptions,\n ): Promise<PermissionStatus>;\n /**\n * Dispatches an event to the configured runner.\n * @param options\n * @since 1.0.0\n */\n dispatchEvent<T = void>(options: DispatchEventOptions): Promise<T>;\n /**\n * Add a listener for notification actions.\n *\n * @since 2.1.1\n */\n addListener(\n eventName: 'backgroundRunnerNotificationReceived',\n listenerFunc: (event: NotificationActionEvent) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove notification action listeners for this plugin.\n *\n * @since 2.1.1\n */\n removeNotificationListeners(): Promise<void>;\n}\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n BackgroundRunner?: BackgroundRunnerConfig;\n }\n}\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAAA,wCAAwC","sourcesContent":["/// <reference types=\"@capacitor/cli\" />\n\nimport type { PermissionState, PluginListenerHandle } from '@capacitor/core';\n\nexport interface BackgroundRunnerConfig {\n /**\n * The name of the runner, used in logs.\n *\n * @since 1.0.0\n */\n label: string;\n /**\n * The path to the runner JavaScript file, relative to the app bundle.\n *\n * @since 1.0.0\n */\n src: string;\n /**\n * The name of the event that will be called when the OS executes the background task.\n *\n * @since 1.0.0\n */\n event: string;\n /**\n * If background task should repeat based on the interval set in `interval`.\n *\n * @since 1.0.0\n */\n repeat: boolean;\n /**\n * The number of minutes after the the app is put into the background in which the background task should begin.\n *\n * If `repeat` is true, this also specifies the number of minutes between each execution.\n *\n * @since 1.0.0\n */\n interval: number;\n /**\n * Automatically register and schedule background task on app load.\n *\n * @since 1.0.0\n */\n autoStart?: boolean;\n}\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n /**\n * On load, Background Runner will automatically register a\n * background task that will be scheduled and run once your app is\n * backgrounded.\n */\n BackgroundRunner?: {\n /**\n * The name of the runner, used in logs.\n *\n * @since 1.0.0\n * @example \"com.example.background.task\"\n */\n label: string;\n /**\n * The path to the runner JavaScript file, relative to the app bundle.\n *\n * @since 1.0.0\n * @example \"runners/background.js\"\n */\n src: string;\n /**\n * The name of the event that will be called when the OS executes the background task.\n *\n * @since 1.0.0\n * @example \"myCustomEvent\"\n */\n event: string;\n /**\n * If background task should repeat based on the interval set in `interval`.\n *\n * @since 1.0.0\n * @example true\n */\n repeat: boolean;\n /**\n * The number of minutes after the the app is put into the background in which the background task should begin.\n *\n * If `repeat` is true, this also specifies the number of minutes between each execution.\n *\n * @since 1.0.0\n * @example 15\n */\n interval: number;\n /**\n * Automatically register and schedule background task on app load.\n *\n * @since 1.0.0\n * @example true\n */\n autoStart?: boolean;\n };\n }\n}\n\nexport type API = 'geolocation' | 'notifications';\n\nexport interface PermissionStatus {\n geolocation: PermissionState;\n notifications: PermissionState;\n}\n\nexport interface DispatchEventOptions {\n /**\n * The runner label to dispatch the event to\n *\n * @since 1.0.0\n */\n label: string;\n /**\n * The name of the registered event listener.\n *\n * @since 1.0.0\n */\n event: string;\n details: { [key: string]: any };\n}\n\nexport interface RequestPermissionOptions {\n apis: API[];\n}\n\nexport interface RegisterBackgroundTaskOptions {\n runner: BackgroundRunnerConfig;\n}\n\nexport interface NotificationActionEvent {\n actionTypeId: string;\n notificationId: number;\n}\n\nexport interface BackgroundRunnerPlugin {\n /**\n * Check permissions for the various Capacitor device APIs.\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n /**\n * Request permission to display local notifications.\n *\n * @since 1.0.0\n */\n requestPermissions(options: RequestPermissionOptions): Promise<PermissionStatus>;\n /**\n * Dispatches an event to the configured runner.\n * @param options\n * @since 1.0.0\n */\n dispatchEvent<T = void>(options: DispatchEventOptions): Promise<T>;\n /**\n * Add a listener for notification actions.\n *\n * @since 2.1.1\n */\n addListener(\n eventName: 'backgroundRunnerNotificationReceived',\n listenerFunc: (event: NotificationActionEvent) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove notification action listeners for this plugin.\n *\n * @since 2.1.1\n */\n removeNotificationListeners(): Promise<void>;\n}\n\ndeclare module '@capacitor/cli' {\n export interface PluginsConfig {\n BackgroundRunner?: BackgroundRunnerConfig;\n }\n}\n"]}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { registerPlugin } from '@capacitor/core';
2
2
  const BackgroundRunner = registerPlugin('CapacitorBackgroundRunner', {
3
- web: () => import('./web').then(m => new m.BackgroundRunnerWeb()),
3
+ web: () => import('./web').then((m) => new m.BackgroundRunnerWeb()),
4
4
  });
5
5
  export * from './definitions';
6
6
  export * from './apis';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,gBAAgB,GAAG,cAAc,CACrC,2BAA2B,EAC3B;IACE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;CAClE,CACF,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { BackgroundRunnerPlugin } from './definitions';\n\nconst BackgroundRunner = registerPlugin<BackgroundRunnerPlugin>(\n 'CapacitorBackgroundRunner',\n {\n web: () => import('./web').then(m => new m.BackgroundRunnerWeb()),\n },\n);\n\nexport * from './definitions';\nexport * from './apis';\n\nexport { BackgroundRunner };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,gBAAgB,GAAG,cAAc,CAAyB,2BAA2B,EAAE;IAC3F,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;CACpE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { BackgroundRunnerPlugin } from './definitions';\n\nconst BackgroundRunner = registerPlugin<BackgroundRunnerPlugin>('CapacitorBackgroundRunner', {\n web: () => import('./web').then((m) => new m.BackgroundRunnerWeb()),\n});\n\nexport * from './definitions';\nexport * from './apis';\n\nexport { BackgroundRunner };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,mBACX,SAAQ,SAAS;IAGjB,gBAAgB;QACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,kBAAkB;QAChB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,sBAAsB;QACpB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa,CAAW,QAA8B;QACpD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,WAAW,CACf,UAAkD,EAClD,aAAuD;QAEvD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,2BAA2B;QAC/B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\nimport { WebPlugin } from '@capacitor/core';\n\nimport type {\n BackgroundRunnerPlugin,\n DispatchEventOptions,\n PermissionStatus,\n NotificationActionEvent,\n} from './definitions';\n\nexport class BackgroundRunnerWeb\n extends WebPlugin\n implements BackgroundRunnerPlugin\n{\n checkPermissions(): Promise<PermissionStatus> {\n throw new Error('not available on web');\n }\n\n requestPermissions(): Promise<PermissionStatus> {\n throw new Error('not available on web');\n }\n\n registerBackgroundTask(): Promise<void> {\n throw new Error('not available on web');\n }\n\n dispatchEvent<T = void>(_options: DispatchEventOptions): Promise<T> {\n throw new Error('not available on web');\n }\n\n async addListener(\n _eventName: 'backgroundRunnerNotificationReceived',\n _listenerFunc: (event: NotificationActionEvent) => void,\n ): Promise<PluginListenerHandle> {\n throw new Error('not available on web');\n }\n\n async removeNotificationListeners(): Promise<void> {\n throw new Error('not available on web');\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAS5C,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAChD,gBAAgB;QACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,kBAAkB;QAChB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,sBAAsB;QACpB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa,CAAW,QAA8B;QACpD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,WAAW,CACf,UAAkD,EAClD,aAAuD;QAEvD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,2BAA2B;QAC/B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\nimport { WebPlugin } from '@capacitor/core';\n\nimport type {\n BackgroundRunnerPlugin,\n DispatchEventOptions,\n PermissionStatus,\n NotificationActionEvent,\n} from './definitions';\n\nexport class BackgroundRunnerWeb extends WebPlugin implements BackgroundRunnerPlugin {\n checkPermissions(): Promise<PermissionStatus> {\n throw new Error('not available on web');\n }\n\n requestPermissions(): Promise<PermissionStatus> {\n throw new Error('not available on web');\n }\n\n registerBackgroundTask(): Promise<void> {\n throw new Error('not available on web');\n }\n\n dispatchEvent<T = void>(_options: DispatchEventOptions): Promise<T> {\n throw new Error('not available on web');\n }\n\n async addListener(\n _eventName: 'backgroundRunnerNotificationReceived',\n _listenerFunc: (event: NotificationActionEvent) => void,\n ): Promise<PluginListenerHandle> {\n throw new Error('not available on web');\n }\n\n async removeNotificationListeners(): Promise<void> {\n throw new Error('not available on web');\n }\n}\n"]}
@@ -1,11 +1,9 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var core = require('@capacitor/core');
6
4
 
7
5
  const BackgroundRunner = core.registerPlugin('CapacitorBackgroundRunner', {
8
- web: () => Promise.resolve().then(function () { return web; }).then(m => new m.BackgroundRunnerWeb()),
6
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.BackgroundRunnerWeb()),
9
7
  });
10
8
 
11
9
  class BackgroundRunnerWeb extends core.WebPlugin {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst BackgroundRunner = registerPlugin('CapacitorBackgroundRunner', {\n web: () => import('./web').then(m => new m.BackgroundRunnerWeb()),\n});\nexport * from './definitions';\nexport * from './apis';\nexport { BackgroundRunner };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class BackgroundRunnerWeb extends WebPlugin {\n checkPermissions() {\n throw new Error('not available on web');\n }\n requestPermissions() {\n throw new Error('not available on web');\n }\n registerBackgroundTask() {\n throw new Error('not available on web');\n }\n dispatchEvent(_options) {\n throw new Error('not available on web');\n }\n async addListener(_eventName, _listenerFunc) {\n throw new Error('not available on web');\n }\n async removeNotificationListeners() {\n throw new Error('not available on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,2BAA2B,EAAE;AACrE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACrE,CAAC;;ACFM,MAAM,mBAAmB,SAASC,cAAS,CAAC;AACnD,IAAI,gBAAgB,GAAG;AACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,kBAAkB,GAAG;AACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,sBAAsB,GAAG;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,aAAa,CAAC,QAAQ,EAAE;AAC5B,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;AACjD,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,MAAM,2BAA2B,GAAG;AACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;AAChD,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst BackgroundRunner = registerPlugin('CapacitorBackgroundRunner', {\n web: () => import('./web').then((m) => new m.BackgroundRunnerWeb()),\n});\nexport * from './definitions';\nexport * from './apis';\nexport { BackgroundRunner };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class BackgroundRunnerWeb extends WebPlugin {\n checkPermissions() {\n throw new Error('not available on web');\n }\n requestPermissions() {\n throw new Error('not available on web');\n }\n registerBackgroundTask() {\n throw new Error('not available on web');\n }\n dispatchEvent(_options) {\n throw new Error('not available on web');\n }\n async addListener(_eventName, _listenerFunc) {\n throw new Error('not available on web');\n }\n async removeNotificationListeners() {\n throw new Error('not available on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,gBAAgB,GAAGA,mBAAc,CAAC,2BAA2B,EAAE;AACrE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;AACvE,CAAC;;ACFM,MAAM,mBAAmB,SAASC,cAAS,CAAC;AACnD,IAAI,gBAAgB,GAAG;AACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;AAC/C,IAAI;AACJ,IAAI,kBAAkB,GAAG;AACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;AAC/C,IAAI;AACJ,IAAI,sBAAsB,GAAG;AAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;AAC/C,IAAI;AACJ,IAAI,aAAa,CAAC,QAAQ,EAAE;AAC5B,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;AAC/C,IAAI;AACJ,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;AACjD,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;AAC/C,IAAI;AACJ,IAAI,MAAM,2BAA2B,GAAG;AACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;AAC/C,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -2,7 +2,7 @@ var capacitorBackgroundRunner = (function (exports, core) {
2
2
  'use strict';
3
3
 
4
4
  const BackgroundRunner = core.registerPlugin('CapacitorBackgroundRunner', {
5
- web: () => Promise.resolve().then(function () { return web; }).then(m => new m.BackgroundRunnerWeb()),
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.BackgroundRunnerWeb()),
6
6
  });
7
7
 
8
8
  class BackgroundRunnerWeb extends core.WebPlugin {
@@ -33,8 +33,6 @@ var capacitorBackgroundRunner = (function (exports, core) {
33
33
 
34
34
  exports.BackgroundRunner = BackgroundRunner;
35
35
 
36
- Object.defineProperty(exports, '__esModule', { value: true });
37
-
38
36
  return exports;
39
37
 
40
38
  })({}, capacitorExports);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst BackgroundRunner = registerPlugin('CapacitorBackgroundRunner', {\n web: () => import('./web').then(m => new m.BackgroundRunnerWeb()),\n});\nexport * from './definitions';\nexport * from './apis';\nexport { BackgroundRunner };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class BackgroundRunnerWeb extends WebPlugin {\n checkPermissions() {\n throw new Error('not available on web');\n }\n requestPermissions() {\n throw new Error('not available on web');\n }\n registerBackgroundTask() {\n throw new Error('not available on web');\n }\n dispatchEvent(_options) {\n throw new Error('not available on web');\n }\n async addListener(_eventName, _listenerFunc) {\n throw new Error('not available on web');\n }\n async removeNotificationListeners() {\n throw new Error('not available on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,2BAA2B,EAAE;IACrE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACrE,CAAC;;ICFM,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,gBAAgB,GAAG;IACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChD,KAAK;IACL,IAAI,kBAAkB,GAAG;IACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChD,KAAK;IACL,IAAI,sBAAsB,GAAG;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChD,KAAK;IACL,IAAI,aAAa,CAAC,QAAQ,EAAE;IAC5B,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChD,KAAK;IACL,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;IACjD,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChD,KAAK;IACL,IAAI,MAAM,2BAA2B,GAAG;IACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAChD,KAAK;IACL;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst BackgroundRunner = registerPlugin('CapacitorBackgroundRunner', {\n web: () => import('./web').then((m) => new m.BackgroundRunnerWeb()),\n});\nexport * from './definitions';\nexport * from './apis';\nexport { BackgroundRunner };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class BackgroundRunnerWeb extends WebPlugin {\n checkPermissions() {\n throw new Error('not available on web');\n }\n requestPermissions() {\n throw new Error('not available on web');\n }\n registerBackgroundTask() {\n throw new Error('not available on web');\n }\n dispatchEvent(_options) {\n throw new Error('not available on web');\n }\n async addListener(_eventName, _listenerFunc) {\n throw new Error('not available on web');\n }\n async removeNotificationListeners() {\n throw new Error('not available on web');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,gBAAgB,GAAGA,mBAAc,CAAC,2BAA2B,EAAE;IACrE,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,mBAAmB,EAAE,CAAC;IACvE,CAAC;;ICFM,MAAM,mBAAmB,SAASC,cAAS,CAAC;IACnD,IAAI,gBAAgB,GAAG;IACvB,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;IAC/C,IAAI;IACJ,IAAI,kBAAkB,GAAG;IACzB,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;IAC/C,IAAI;IACJ,IAAI,sBAAsB,GAAG;IAC7B,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;IAC/C,IAAI;IACJ,IAAI,aAAa,CAAC,QAAQ,EAAE;IAC5B,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;IAC/C,IAAI;IACJ,IAAI,MAAM,WAAW,CAAC,UAAU,EAAE,aAAa,EAAE;IACjD,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;IAC/C,IAAI;IACJ,IAAI,MAAM,2BAA2B,GAAG;IACxC,QAAQ,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC;IAC/C,IAAI;IACJ;;;;;;;;;;;;;;;"}
@@ -4,226 +4,224 @@ import Foundation
4
4
  import JavaScriptCore
5
5
 
6
6
  #if canImport(RunnerEngine)
7
- import RunnerEngine
7
+ import RunnerEngine
8
8
  #endif
9
9
 
10
10
  public class BackgroundRunner {
11
- public static let shared = BackgroundRunner()
12
- public var config: RunnerConfig?
11
+ public static let shared = BackgroundRunner()
12
+ public var config: RunnerConfig?
13
13
 
14
- private var runner = Runner()
14
+ private var runner = Runner()
15
15
 
16
- public init() {
17
- do {
18
- config = try self.loadRunnerConfig()
19
- } catch {
20
- print("could not initialize BackgroundRunner: \(error)")
21
- }
22
- }
23
-
24
- public func scheduleBackgroundTasks() throws {
25
- guard let config = config else {
26
- throw BackgroundRunnerPluginError.noRunnerConfig
16
+ public init() {
17
+ do {
18
+ config = try self.loadRunnerConfig()
19
+ } catch {
20
+ print("could not initialize BackgroundRunner: \(error)")
21
+ }
27
22
  }
28
23
 
29
- if !config.autoSchedule {
30
- return
31
- }
24
+ public func scheduleBackgroundTasks() throws {
25
+ guard let config = config else {
26
+ throw BackgroundRunnerPluginError.noRunnerConfig
27
+ }
32
28
 
33
- guard let interval = config.interval else {
34
- throw BackgroundRunnerPluginError.invalidRunnerConfig(
35
- reason: "cannot register background task without a configured interval")
36
- }
29
+ if !config.autoSchedule {
30
+ return
31
+ }
37
32
 
38
- let request = BGAppRefreshTaskRequest(identifier: config.label)
39
- request.earliestBeginDate = Date(timeIntervalSinceNow: Double(interval) * 60)
33
+ guard let interval = config.interval else {
34
+ throw BackgroundRunnerPluginError.invalidRunnerConfig(
35
+ reason: "cannot register background task without a configured interval")
36
+ }
40
37
 
41
- print("Scheduling \(config.label)")
38
+ let request = BGAppRefreshTaskRequest(identifier: config.label)
39
+ request.earliestBeginDate = Date(timeIntervalSinceNow: Double(interval) * 60)
42
40
 
43
- try BGTaskScheduler.shared.submit(request)
44
- }
41
+ print("Scheduling \(config.label)")
45
42
 
46
- public func registerBackgroundTask() throws {
47
- guard let config = config else {
48
- throw BackgroundRunnerPluginError.noRunnerConfig
43
+ try BGTaskScheduler.shared.submit(request)
49
44
  }
50
45
 
51
- BGTaskScheduler.shared.register(forTaskWithIdentifier: config.label, using: nil) { task in
52
- do {
53
- task.expirationHandler = {
54
- print("task timed out")
46
+ public func registerBackgroundTask() throws {
47
+ guard let config = config else {
48
+ throw BackgroundRunnerPluginError.noRunnerConfig
55
49
  }
56
50
 
57
- _ = try BackgroundRunner.shared.execute(config: config)
51
+ BGTaskScheduler.shared.register(forTaskWithIdentifier: config.label, using: nil) { task in
52
+ do {
53
+ task.expirationHandler = {
54
+ print("task timed out")
55
+ }
58
56
 
59
- task.setTaskCompleted(success: true)
57
+ _ = try BackgroundRunner.shared.execute(config: config)
60
58
 
61
- if config.repeats {
62
- try self.scheduleBackgroundTasks()
59
+ task.setTaskCompleted(success: true)
60
+
61
+ if config.repeats {
62
+ try self.scheduleBackgroundTasks()
63
+ }
64
+ } catch {
65
+ print("background task error: \(error)")
66
+ task.setTaskCompleted(success: false)
67
+ }
63
68
  }
64
- } catch {
65
- print("background task error: \(error)")
66
- task.setTaskCompleted(success: false)
67
- }
68
69
  }
69
- }
70
70
 
71
- // swiftlint:disable:next cyclomatic_complexity function_body_length
72
- public func execute(
73
- config: RunnerConfig, inputArgs: [String: Any]? = nil, callbackId: String? = nil
74
- ) throws -> [String: Any]? {
75
- do {
76
- let context = try initContext(config: config, callbackId: callbackId)
71
+ // swiftlint:disable:next cyclomatic_complexity function_body_length
72
+ public func execute(
73
+ config: RunnerConfig, inputArgs: [String: Any]? = nil, callbackId: String? = nil
74
+ ) throws -> [String: Any]? {
75
+ do {
76
+ let context = try initContext(config: config, callbackId: callbackId)
77
77
 
78
- let waitGroup = DispatchGroup()
78
+ let waitGroup = DispatchGroup()
79
79
 
80
- var result: [String: Any]?
81
- var rejectionErr: JSError?
80
+ var result: [String: Any]?
81
+ var rejectionErr: JSError?
82
82
 
83
- let resolveFunc: @convention(block) (JavaScriptCore.JSValue) -> Void = { returnObj in
84
- if !returnObj.isUndefined && !returnObj.isNull {
85
- var dict: [String: Any] = [:]
83
+ let resolveFunc: @convention(block) (JavaScriptCore.JSValue) -> Void = { returnObj in
84
+ if !returnObj.isUndefined && !returnObj.isNull {
85
+ var dict: [String: Any] = [:]
86
86
 
87
- returnObj.toDictionary().forEach { key, value in
88
- dict[String(describing: key)] = value
89
- }
87
+ returnObj.toDictionary().forEach { key, value in
88
+ dict[String(describing: key)] = value
89
+ }
90
90
 
91
- result = dict
92
- }
91
+ result = dict
92
+ }
93
93
 
94
- waitGroup.leave()
95
- return
96
- }
97
-
98
- let rejectFunc: @convention(block) (JavaScriptCore.JSValue) -> Void = { rejectObj in
99
- var rejectionTitle = "Error"
100
- var rejectionMessage = ""
101
-
102
- if !rejectObj.isUndefined && !rejectObj.isNull {
103
- if let errStr = rejectObj.toString() {
104
- let split = errStr.split(separator: ":", maxSplits: 1)
105
- if split.count == 0 {
106
- rejectionMessage = String(split.first ?? "")
107
- } else {
108
- rejectionTitle = String(split.first ?? "Error")
109
- rejectionMessage = String(split.last ?? "")
94
+ waitGroup.leave()
95
+ return
110
96
  }
111
- }
112
97
 
113
- if rejectObj.isObject, let errDict = rejectObj.toDictionary() {
114
- if let errTitle = errDict["name"] as? String {
115
- rejectionTitle = errTitle
98
+ let rejectFunc: @convention(block) (JavaScriptCore.JSValue) -> Void = { rejectObj in
99
+ var rejectionTitle = "Error"
100
+ var rejectionMessage = ""
101
+
102
+ if !rejectObj.isUndefined && !rejectObj.isNull {
103
+ if let errStr = rejectObj.toString() {
104
+ let split = errStr.split(separator: ":", maxSplits: 1)
105
+ if split.count == 0 {
106
+ rejectionMessage = String(split.first ?? "")
107
+ } else {
108
+ rejectionTitle = String(split.first ?? "Error")
109
+ rejectionMessage = String(split.last ?? "")
110
+ }
111
+ }
112
+
113
+ if rejectObj.isObject, let errDict = rejectObj.toDictionary() {
114
+ if let errTitle = errDict["name"] as? String {
115
+ rejectionTitle = errTitle
116
+ }
117
+
118
+ if let errMsg = errDict["message"] as? String {
119
+ rejectionMessage = errMsg
120
+ }
121
+ }
122
+ }
123
+
124
+ rejectionErr = JSError(message: "\(rejectionTitle): \(rejectionMessage)")
125
+
126
+ waitGroup.leave()
127
+ return
116
128
  }
117
129
 
118
- if let errMsg = errDict["message"] as? String {
119
- rejectionMessage = errMsg
120
- }
121
- }
122
- }
123
-
124
- rejectionErr = JSError(message: "\(rejectionTitle): \(rejectionMessage)")
125
-
126
- waitGroup.leave()
127
- return
128
- }
129
-
130
- var args: [String: Any] = [:]
130
+ var args: [String: Any] = [:]
131
131
 
132
- var callbacks: [String: Any] = [:]
133
- callbacks["__cbr::resolve"] = resolveFunc
134
- callbacks["__cbr::reject"] = rejectFunc
132
+ var callbacks: [String: Any] = [:]
133
+ callbacks["__cbr::resolve"] = resolveFunc
134
+ callbacks["__cbr::reject"] = rejectFunc
135
135
 
136
- args["callbacks"] = callbacks
137
- args["dataArgs"] = inputArgs
136
+ args["callbacks"] = callbacks
137
+ args["dataArgs"] = inputArgs
138
138
 
139
- waitGroup.enter()
139
+ waitGroup.enter()
140
140
 
141
- try context.dispatchEvent(event: config.event, details: args)
141
+ try context.dispatchEvent(event: config.event, details: args)
142
142
 
143
- waitGroup.wait()
143
+ waitGroup.wait()
144
144
 
145
- if let rejection = rejectionErr {
146
- throw EngineError.jsException(details: rejection.toString())
147
- }
145
+ if let rejection = rejectionErr {
146
+ throw EngineError.jsException(details: rejection.toString())
147
+ }
148
148
 
149
- return result
150
- } catch {
151
- print("error executing task: \(error)")
152
- throw error
149
+ return result
150
+ } catch {
151
+ print("error executing task: \(error)")
152
+ throw error
153
+ }
153
154
  }
154
- }
155
155
 
156
- public func dispatchEvent(event: String, inputArgs: [String: Any]?, callbackId: String? = nil)
157
- throws
158
- {
159
- if let config = config {
160
- let waitGroup = DispatchGroup()
161
- waitGroup.enter()
156
+ public func dispatchEvent(event: String, inputArgs: [String: Any]?, callbackId: String? = nil)
157
+ throws {
158
+ if let config = config {
159
+ let waitGroup = DispatchGroup()
160
+ waitGroup.enter()
162
161
 
163
- var err: Error?
162
+ var err: Error?
164
163
 
165
- // swiftlint:disable:next unowned_variable_capture
166
- DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
167
- do {
168
- _ = try self.execute(config: config, inputArgs: inputArgs, callbackId: callbackId)
169
- } catch {
170
- err = error
171
- print("[\(config.label)]: \(error)")
172
- }
164
+ // swiftlint:disable:next unowned_variable_capture
165
+ DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
166
+ do {
167
+ _ = try self.execute(config: config, inputArgs: inputArgs, callbackId: callbackId)
168
+ } catch {
169
+ err = error
170
+ print("[\(config.label)]: \(error)")
171
+ }
173
172
 
174
- waitGroup.leave()
175
- }
173
+ waitGroup.leave()
174
+ }
176
175
 
177
- waitGroup.wait()
176
+ waitGroup.wait()
178
177
 
179
- if let err = err {
180
- throw err
181
- }
182
- }
183
- }
184
-
185
- private func loadRunnerConfig() throws -> RunnerConfig? {
186
- guard
187
- let capacitorConfigFileURL = Bundle.main.url(
188
- forResource: "capacitor.config.json", withExtension: nil)
189
- else {
190
- throw BackgroundRunnerPluginError.runnerError(reason: "capacitor.config.json file not found")
178
+ if let err = err {
179
+ throw err
180
+ }
181
+ }
191
182
  }
192
183
 
193
- let capacitorConfigFileData = try Data(contentsOf: capacitorConfigFileURL)
184
+ private func loadRunnerConfig() throws -> RunnerConfig? {
185
+ guard
186
+ let capacitorConfigFileURL = Bundle.main.url(
187
+ forResource: "capacitor.config.json", withExtension: nil)
188
+ else {
189
+ throw BackgroundRunnerPluginError.runnerError(reason: "capacitor.config.json file not found")
190
+ }
194
191
 
195
- if let capConfig = JSTypes.coerceDictionaryToJSObject(
196
- try JSONSerialization.jsonObject(with: capacitorConfigFileData) as? [String: Any])
197
- {
198
- if let jsonConfig = capConfig[keyPath: "plugins.BackgroundRunner"] as? JSObject {
199
- return try RunnerConfig(from: jsonConfig)
200
- }
201
- }
192
+ let capacitorConfigFileData = try Data(contentsOf: capacitorConfigFileURL)
202
193
 
203
- return nil
204
- }
194
+ if let capConfig = JSTypes.coerceDictionaryToJSObject(
195
+ try JSONSerialization.jsonObject(with: capacitorConfigFileData) as? [String: Any]) {
196
+ if let jsonConfig = capConfig[keyPath: "plugins.BackgroundRunner"] as? JSObject {
197
+ return try RunnerConfig(from: jsonConfig)
198
+ }
199
+ }
205
200
 
206
- private func initContext(config: RunnerConfig, callbackId: String?) throws -> Context {
207
- guard
208
- let srcFileURL = Bundle.main.url(
209
- forResource: config.src, withExtension: nil, subdirectory: "public")
210
- else {
211
- throw BackgroundRunnerPluginError.runnerError(reason: "source file not found")
201
+ return nil
212
202
  }
213
203
 
214
- var contextName = config.label
215
- if let callbackId = callbackId {
216
- contextName = "\(contextName)-\(callbackId)"
217
- }
204
+ private func initContext(config: RunnerConfig, callbackId: String?) throws -> Context {
205
+ guard
206
+ let srcFileURL = Bundle.main.url(
207
+ forResource: config.src, withExtension: nil, subdirectory: "public")
208
+ else {
209
+ throw BackgroundRunnerPluginError.runnerError(reason: "source file not found")
210
+ }
211
+
212
+ var contextName = config.label
213
+ if let callbackId = callbackId {
214
+ contextName = "\(contextName)-\(callbackId)"
215
+ }
218
216
 
219
- let srcFile = try String(contentsOf: srcFileURL)
217
+ let srcFile = try String(contentsOf: srcFileURL)
220
218
 
221
- let context = try runner.createContext(name: contextName)
219
+ let context = try runner.createContext(name: contextName)
222
220
 
223
- context.setupCapacitorAPI()
221
+ context.setupCapacitorAPI()
224
222
 
225
- _ = try context.execute(code: srcFile)
223
+ _ = try context.execute(code: srcFile)
226
224
 
227
- return context
228
- }
225
+ return context
226
+ }
229
227
  }
@@ -3,201 +3,200 @@ import Foundation
3
3
  import JavaScriptCore
4
4
 
5
5
  #if canImport(RunnerEngine)
6
- import RunnerEngine
6
+ import RunnerEngine
7
7
  #endif
8
8
 
9
9
  @objc protocol CapacitorGeolocationExports: JSExport {
10
- var isWatchingPosition: Bool { get }
11
- func startWatchingPosition(_ highAccuracy: Bool)
12
- func stopWatchingPosition()
13
- func getCurrentPosition() -> [String: Any]?
10
+ var isWatchingPosition: Bool { get }
11
+ func startWatchingPosition(_ highAccuracy: Bool)
12
+ func stopWatchingPosition()
13
+ func getCurrentPosition() -> [String: Any]?
14
14
  }
15
15
 
16
16
  enum CapacitorGeolocationErrors: Error, Equatable {
17
- case unauthorized
17
+ case unauthorized
18
18
  }
19
19
 
20
20
  class CapacitorGeolocation: NSObject, CapacitorGeolocationExports, CLLocationManagerDelegate {
21
- private weak var context: Context?
22
- private var pendingCurrentLocationCalls: [Int: (Result<CLLocation?, Error>) -> Void] = [:]
23
- private var isWatchingLocation: Bool = false
24
- private let locationManager: CLLocationManager
25
-
26
- private var permissionContinuation: CheckedContinuation<Void, Error>?
27
-
28
- var isWatchingPosition: Bool {
29
- return isWatchingLocation
30
- }
31
-
32
- init(context: Context? = nil) {
33
- self.locationManager = CLLocationManager()
34
- super.init()
35
-
36
- self.context = context
37
- self.locationManager.delegate = self
38
-
39
- if CLLocationManager.authorizationStatus() == .authorizedAlways {
40
- self.locationManager.allowsBackgroundLocationUpdates = true
41
- self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
42
- self.locationManager.pausesLocationUpdatesAutomatically = false
43
- }
44
-
45
-
46
- }
47
-
48
- static func getCurrentKnownLocation() -> CLLocation? {
49
- return CLLocationManager().location
50
- }
51
-
52
- static func checkPermission() -> String {
53
- if !CLLocationManager.locationServicesEnabled() {
54
- return "denied"
55
- }
21
+ private weak var context: Context?
22
+ private var pendingCurrentLocationCalls: [Int: (Result<CLLocation?, Error>) -> Void] = [:]
23
+ private var isWatchingLocation: Bool = false
24
+ private let locationManager: CLLocationManager
25
+
26
+ private var permissionContinuation: CheckedContinuation<Void, Error>?
56
27
 
57
- var permission: String = "prompt"
58
-
59
- switch CLLocationManager.authorizationStatus() {
60
- case .authorized, .authorizedWhenInUse, .authorizedAlways:
61
- permission = "granted"
62
- case .notDetermined:
63
- permission = "prompt"
64
- case .denied, .restricted:
65
- permission = "denied"
66
- default:
67
- permission = "prompt"
28
+ var isWatchingPosition: Bool {
29
+ return isWatchingLocation
68
30
  }
69
31
 
70
- return permission
71
- }
32
+ init(context: Context? = nil) {
33
+ self.locationManager = CLLocationManager()
34
+ super.init()
35
+
36
+ self.context = context
37
+ self.locationManager.delegate = self
38
+
39
+ if CLLocationManager.authorizationStatus() == .authorizedAlways {
40
+ self.locationManager.allowsBackgroundLocationUpdates = true
41
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer
42
+ self.locationManager.pausesLocationUpdatesAutomatically = false
43
+ }
72
44
 
73
- func requestPermission() async throws {
74
- if !CLLocationManager.locationServicesEnabled() {
75
- return
76
45
  }
77
46
 
78
- if CLLocationManager.authorizationStatus() != .notDetermined {
79
- return
47
+ static func getCurrentKnownLocation() -> CLLocation? {
48
+ return CLLocationManager().location
80
49
  }
81
50
 
82
- return try await withCheckedThrowingContinuation({
83
- (continuation: CheckedContinuation<Void, Error>) in
84
- permissionContinuation = continuation
85
-
86
- DispatchQueue.main.async {
87
- self.locationManager.requestAlwaysAuthorization()
88
- }
89
- })
90
- }
91
-
92
- func startWatchingPosition(_ highAccuracy: Bool) {
93
- do {
94
- if CapacitorGeolocation.checkPermission() != "granted" {
95
- throw CapacitorGeolocationErrors.unauthorized
96
- }
97
-
98
- DispatchQueue.main.sync {
99
- if highAccuracy {
100
- self.locationManager.startUpdatingLocation()
101
- } else {
102
- self.locationManager.startMonitoringSignificantLocationChanges()
51
+ static func checkPermission() -> String {
52
+ if !CLLocationManager.locationServicesEnabled() {
53
+ return "denied"
103
54
  }
104
- }
105
55
 
106
- self.isWatchingLocation = true
107
- } catch {
108
- JSContext.current().exception = JSValue(
109
- newErrorFromMessage: "\(error)", in: JSContext.current())
110
- }
111
- }
56
+ var permission: String = "prompt"
57
+
58
+ switch CLLocationManager.authorizationStatus() {
59
+ case .authorized, .authorizedWhenInUse, .authorizedAlways:
60
+ permission = "granted"
61
+ case .notDetermined:
62
+ permission = "prompt"
63
+ case .denied, .restricted:
64
+ permission = "denied"
65
+ default:
66
+ permission = "prompt"
67
+ }
112
68
 
113
- func stopWatchingPosition() {
114
- DispatchQueue.main.sync {
115
- self.locationManager.stopUpdatingLocation()
116
- self.locationManager.stopMonitoringSignificantLocationChanges()
69
+ return permission
117
70
  }
118
71
 
119
- self.isWatchingLocation = false
120
- }
121
-
122
- func getCurrentPosition() -> [String: Any]? {
123
- do {
124
- if CapacitorGeolocation.checkPermission() != "granted" {
125
- throw CapacitorGeolocationErrors.unauthorized
126
- }
72
+ func requestPermission() async throws {
73
+ if !CLLocationManager.locationServicesEnabled() {
74
+ return
75
+ }
127
76
 
128
- guard let lastLocation = self.locationManager.location else {
129
- return nil
130
- }
77
+ if CLLocationManager.authorizationStatus() != .notDetermined {
78
+ return
79
+ }
131
80
 
132
- return buildLocationDict(location: lastLocation)
133
- } catch {
134
- JSContext.current().exception = JSValue(
135
- newErrorFromMessage: "\(error)", in: JSContext.current())
81
+ return try await withCheckedThrowingContinuation({
82
+ (continuation: CheckedContinuation<Void, Error>) in
83
+ permissionContinuation = continuation
136
84
 
137
- return nil
85
+ DispatchQueue.main.async {
86
+ self.locationManager.requestAlwaysAuthorization()
87
+ }
88
+ })
138
89
  }
139
- }
140
90
 
141
- func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
142
- if let context = self.context, self.isWatchingLocation {
143
- let locations: [[String: Any]] = locations.map { location in
144
- return buildLocationDict(location: location)
145
- }
91
+ func startWatchingPosition(_ highAccuracy: Bool) {
92
+ do {
93
+ if CapacitorGeolocation.checkPermission() != "granted" {
94
+ throw CapacitorGeolocationErrors.unauthorized
95
+ }
96
+
97
+ DispatchQueue.main.sync {
98
+ if highAccuracy {
99
+ self.locationManager.startUpdatingLocation()
100
+ } else {
101
+ self.locationManager.startMonitoringSignificantLocationChanges()
102
+ }
103
+ }
104
+
105
+ self.isWatchingLocation = true
106
+ } catch {
107
+ JSContext.current().exception = JSValue(
108
+ newErrorFromMessage: "\(error)", in: JSContext.current())
109
+ }
110
+ }
146
111
 
147
- var details: [String: Any] = [:]
148
- details["locations"] = locations
112
+ func stopWatchingPosition() {
113
+ DispatchQueue.main.sync {
114
+ self.locationManager.stopUpdatingLocation()
115
+ self.locationManager.stopMonitoringSignificantLocationChanges()
116
+ }
149
117
 
150
- try? context.dispatchEvent(event: "currentLocation", details: details)
118
+ self.isWatchingLocation = false
151
119
  }
152
120
 
153
- pendingCurrentLocationCalls.forEach {
154
- (callId: Int, callback: (Result<CLLocation?, Error>) -> Void) in
155
- pendingCurrentLocationCalls.removeValue(forKey: callId)
156
- callback(.success(locations.last))
157
- }
121
+ func getCurrentPosition() -> [String: Any]? {
122
+ do {
123
+ if CapacitorGeolocation.checkPermission() != "granted" {
124
+ throw CapacitorGeolocationErrors.unauthorized
125
+ }
126
+
127
+ guard let lastLocation = self.locationManager.location else {
128
+ return nil
129
+ }
158
130
 
159
- if let location = locations.last {
160
- print("\(location.coordinate.latitude),\(location.coordinate.longitude)")
131
+ return buildLocationDict(location: lastLocation)
132
+ } catch {
133
+ JSContext.current().exception = JSValue(
134
+ newErrorFromMessage: "\(error)", in: JSContext.current())
135
+
136
+ return nil
137
+ }
161
138
  }
162
- }
163
139
 
164
- func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
165
- if let continuation = permissionContinuation {
166
- continuation.resume(throwing: error)
167
- permissionContinuation = nil
140
+ func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
141
+ if let context = self.context, self.isWatchingLocation {
142
+ let locations: [[String: Any]] = locations.map { location in
143
+ return buildLocationDict(location: location)
144
+ }
145
+
146
+ var details: [String: Any] = [:]
147
+ details["locations"] = locations
148
+
149
+ try? context.dispatchEvent(event: "currentLocation", details: details)
150
+ }
151
+
152
+ pendingCurrentLocationCalls.forEach {
153
+ (callId: Int, callback: (Result<CLLocation?, Error>) -> Void) in
154
+ pendingCurrentLocationCalls.removeValue(forKey: callId)
155
+ callback(.success(locations.last))
156
+ }
157
+
158
+ if let location = locations.last {
159
+ print("\(location.coordinate.latitude),\(location.coordinate.longitude)")
160
+ }
168
161
  }
169
162
 
170
- if let context = context, self.isWatchingLocation {
171
- var details: [String: Any] = [:]
172
- details["error"] = error
163
+ func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
164
+ if let continuation = permissionContinuation {
165
+ continuation.resume(throwing: error)
166
+ permissionContinuation = nil
167
+ }
168
+
169
+ if let context = context, self.isWatchingLocation {
170
+ var details: [String: Any] = [:]
171
+ details["error"] = error
173
172
 
174
- try? context.dispatchEvent(event: "currentLocation", details: details)
173
+ try? context.dispatchEvent(event: "currentLocation", details: details)
174
+ }
175
+
176
+ pendingCurrentLocationCalls.forEach {
177
+ (callId: Int, callback: (Result<CLLocation?, Error>) -> Void) in
178
+ pendingCurrentLocationCalls.removeValue(forKey: callId)
179
+ callback(.failure(error))
180
+ }
175
181
  }
176
182
 
177
- pendingCurrentLocationCalls.forEach {
178
- (callId: Int, callback: (Result<CLLocation?, Error>) -> Void) in
179
- pendingCurrentLocationCalls.removeValue(forKey: callId)
180
- callback(.failure(error))
183
+ func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
184
+ if let continuation = permissionContinuation {
185
+ continuation.resume()
186
+ permissionContinuation = nil
187
+ }
181
188
  }
182
- }
183
189
 
184
- func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) {
185
- if let continuation = permissionContinuation {
186
- continuation.resume()
187
- permissionContinuation = nil
190
+ private func buildLocationDict(location: CLLocation) -> [String: Any] {
191
+ var coords: [String: Any] = [:]
192
+ coords["latitude"] = location.coordinate.latitude
193
+ coords["longitude"] = location.coordinate.longitude
194
+ coords["accuracy"] = location.horizontalAccuracy
195
+ coords["altitude"] = location.altitude
196
+ coords["altitudeAccuracy"] = location.verticalAccuracy
197
+ coords["speed"] = location.speed
198
+ coords["heading"] = location.course
199
+
200
+ return coords
188
201
  }
189
- }
190
-
191
- private func buildLocationDict(location: CLLocation) -> [String: Any] {
192
- var coords: [String: Any] = [:]
193
- coords["latitude"] = location.coordinate.latitude
194
- coords["longitude"] = location.coordinate.longitude
195
- coords["accuracy"] = location.horizontalAccuracy
196
- coords["altitude"] = location.altitude
197
- coords["altitudeAccuracy"] = location.verticalAccuracy
198
- coords["speed"] = location.speed
199
- coords["heading"] = location.course
200
-
201
- return coords
202
- }
203
202
  }
@@ -137,7 +137,7 @@ class CapacitorNotifications: NSObject, CapacitorNotificationsExports {
137
137
  let content = UNMutableNotificationContent()
138
138
  content.title = NSString.localizedUserNotificationString(forKey: notificationOption.title, arguments: nil)
139
139
  content.body = NSString.localizedUserNotificationString(forKey: notificationOption.body, arguments: nil)
140
- content.userInfo = [:]
140
+ content.userInfo = ["source": "capacitor-background-runner"]
141
141
 
142
142
  if let extra = notificationOption.extra {
143
143
  content.userInfo["cap_extra"] = extra
@@ -15,7 +15,8 @@ public class BackgroundRunnerPlugin: CAPPlugin, CAPBridgedPlugin {
15
15
  CAPPluginMethod(name: "removeNotificationListeners", returnType: CAPPluginReturnPromise)
16
16
  ]
17
17
  private let impl = BackgroundRunner()
18
-
18
+ private weak var originalDelegate: UNUserNotificationCenterDelegate?
19
+
19
20
  override public func load() {
20
21
  NotificationCenter.default.addObserver(
21
22
  self,
@@ -29,7 +30,7 @@ public class BackgroundRunnerPlugin: CAPPlugin, CAPBridgedPlugin {
29
30
 
30
31
  initWatchConnectivity()
31
32
  }
32
-
33
+
33
34
  @objc override public func checkPermissions(_ call: CAPPluginCall) {
34
35
  // check geolocation permissions
35
36
  let geolocationState = CapacitorGeolocation.checkPermission()
@@ -65,7 +66,7 @@ public class BackgroundRunnerPlugin: CAPPlugin, CAPBridgedPlugin {
65
66
  }
66
67
  }
67
68
  }
68
-
69
+
69
70
  @objc func dispatchEvent(_ call: CAPPluginCall) {
70
71
  do {
71
72
  guard let runnerEvent = call.getString("event"), !runnerEvent.isEmpty else {
@@ -197,6 +198,11 @@ public class BackgroundRunnerPlugin: CAPPlugin, CAPBridgedPlugin {
197
198
  @objc func registerNotificationCategories() {
198
199
  let notificationCenter = UNUserNotificationCenter.current()
199
200
 
201
+ // Capture the original delegate if it's not self
202
+ if notificationCenter.delegate !== self {
203
+ originalDelegate = notificationCenter.delegate
204
+ }
205
+
200
206
  // Set the plugin as the notification delegate
201
207
  notificationCenter.delegate = self
202
208
  }
@@ -208,30 +214,68 @@ extension BackgroundRunnerPlugin: UNUserNotificationCenterDelegate {
208
214
  public func userNotificationCenter(_ center: UNUserNotificationCenter,
209
215
  didReceive response: UNNotificationResponse,
210
216
  withCompletionHandler completionHandler: @escaping () -> Void) {
217
+ let userInfo = response.notification.request.content.userInfo
218
+
219
+ if isBackgroundRunnerNotification(userInfo) {
220
+ handleBackgroundRunnerNotification(response, completionHandler: completionHandler)
221
+ } else {
222
+ forwardToOriginalDelegate(center, didReceive: response, withCompletionHandler: completionHandler)
223
+ }
224
+ }
225
+
226
+ // This is needed to present notifications when the app is in the foreground
227
+ public func userNotificationCenter(_ center: UNUserNotificationCenter,
228
+ willPresent notification: UNNotification,
229
+ withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
230
+ let userInfo = notification.request.content.userInfo
231
+
232
+ if isBackgroundRunnerNotification(userInfo) {
233
+ handleBackgroundRunnerPresentation(completionHandler: completionHandler)
234
+ } else {
235
+ forwardToOriginalDelegate(center, willPresent: notification, withCompletionHandler: completionHandler)
236
+ }
237
+ }
238
+
239
+ // MARK: - Helper Methods
240
+
241
+ private func isBackgroundRunnerNotification(_ userInfo: [AnyHashable: Any]) -> Bool {
242
+ return (userInfo["source"] as? String) == "capacitor-background-runner"
243
+ }
244
+
245
+ private func handleBackgroundRunnerNotification(_ response: UNNotificationResponse, completionHandler: @escaping () -> Void) {
211
246
  let actionTypeId = response.notification.request.content.categoryIdentifier
212
247
  let notificationId = Int(response.notification.request.identifier) ?? -1
213
248
 
214
- // Create event data
215
249
  let eventData: [String: Any] = [
216
250
  "actionTypeId": actionTypeId,
217
251
  "notificationId": notificationId
218
252
  ]
219
253
 
220
- // Notify listeners with the action data - the 'true' parameter is for retaining the event
221
254
  notifyListeners("backgroundRunnerNotificationReceived", data: eventData, retainUntilConsumed: true)
222
-
223
255
  completionHandler()
224
256
  }
225
257
 
226
- // This is needed to present notifications when the app is in the foreground
227
- public func userNotificationCenter(_ center: UNUserNotificationCenter,
228
- willPresent notification: UNNotification,
229
- withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
230
- // Show the notification even when the app is in foreground
258
+ private func forwardToOriginalDelegate(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
259
+ if let originalDelegate = originalDelegate, originalDelegate.responds(to: #selector(userNotificationCenter(_:didReceive:withCompletionHandler:))) {
260
+ originalDelegate.userNotificationCenter?(center, didReceive: response, withCompletionHandler: completionHandler)
261
+ } else {
262
+ completionHandler()
263
+ }
264
+ }
265
+
266
+ private func handleBackgroundRunnerPresentation(completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
231
267
  if #available(iOS 14.0, *) {
232
268
  completionHandler([.banner, .sound, .badge])
233
269
  } else {
234
270
  completionHandler([.alert, .sound, .badge])
235
271
  }
236
272
  }
273
+
274
+ private func forwardToOriginalDelegate(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
275
+ if let originalDelegate = originalDelegate, originalDelegate.responds(to: #selector(userNotificationCenter(_:willPresent:withCompletionHandler:))) {
276
+ originalDelegate.userNotificationCenter?(center, willPresent: notification, withCompletionHandler: completionHandler)
277
+ } else {
278
+ handleBackgroundRunnerPresentation(completionHandler: completionHandler)
279
+ }
280
+ }
237
281
  }
@@ -1,18 +1,18 @@
1
1
  import Foundation
2
2
 
3
3
  #if canImport(RunnerEngine)
4
- import RunnerEngine
4
+ import RunnerEngine
5
5
  #endif
6
6
 
7
7
  extension Context {
8
- public func setupCapacitorAPI() {
9
- jsContext.setObject(CapacitorKVStore.self, forKeyedSubscript: "CapacitorKV" as NSString)
10
- jsContext.setObject(
11
- CapacitorGeolocation(context: self), forKeyedSubscript: "CapacitorGeolocation" as NSString)
12
- jsContext.setObject(CapacitorWatch(), forKeyedSubscript: "CapacitorWatch" as NSString)
13
- jsContext.setObject(
14
- CapacitorNotifications.self, forKeyedSubscript: "CapacitorNotifications" as NSString)
15
- jsContext.setObject(CapacitorDevice(), forKeyedSubscript: "CapacitorDevice" as NSString)
16
- jsContext.setObject(CapacitorApp.self, forKeyedSubscript: "CapacitorApp" as NSString)
17
- }
8
+ public func setupCapacitorAPI() {
9
+ jsContext.setObject(CapacitorKVStore.self, forKeyedSubscript: "CapacitorKV" as NSString)
10
+ jsContext.setObject(
11
+ CapacitorGeolocation(context: self), forKeyedSubscript: "CapacitorGeolocation" as NSString)
12
+ jsContext.setObject(CapacitorWatch(), forKeyedSubscript: "CapacitorWatch" as NSString)
13
+ jsContext.setObject(
14
+ CapacitorNotifications.self, forKeyedSubscript: "CapacitorNotifications" as NSString)
15
+ jsContext.setObject(CapacitorDevice(), forKeyedSubscript: "CapacitorDevice" as NSString)
16
+ jsContext.setObject(CapacitorApp.self, forKeyedSubscript: "CapacitorApp" as NSString)
17
+ }
18
18
  }
@@ -41,4 +41,3 @@ extension BackgroundRunnerPlugin: WCSessionDelegate {
41
41
  try? BackgroundRunner.shared.dispatchEvent(event: "WatchConnectivity_didReceiveApplicationContext", inputArgs: args)
42
42
  }
43
43
  }
44
-
@@ -13,17 +13,17 @@ class JSCrypto: NSObject, JSCryptoExports {
13
13
  var rnd = [UInt8](repeating: 0, count: size)
14
14
  _ = SecRandomCopyBytes(kSecRandomDefault, size, &rnd)
15
15
 
16
- if arr.toArray() as? [UInt8] != nil {
16
+ if arr.toArray() is [UInt8] {
17
17
  for i in 0...(size - 1) {
18
18
  arr.setObject(rnd[i], atIndexedSubscript: i)
19
19
  }
20
20
  }
21
- if arr.toArray() as? [UInt16] != nil {
21
+ if arr.toArray() is [UInt16] {
22
22
  for i in 0...(size - 1) {
23
23
  arr.setObject(UInt16(rnd[i]), atIndexedSubscript: i)
24
24
  }
25
25
  }
26
- if arr.toArray() as? [UInt32] != nil {
26
+ if arr.toArray() is [UInt32] {
27
27
  for i in 0...(size - 1) {
28
28
  arr.setObject(UInt32(rnd[i]), forKeyedSubscript: i)
29
29
  }
@@ -16,6 +16,6 @@ import Testing
16
16
  _ = try context.execute(code: "CapacitorKV.remove('test');")
17
17
 
18
18
  let nullValue = try context.execute(code: "CapacitorKV.get('test');")
19
-
19
+
20
20
  #expect(nullValue?.isNull ?? false)
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/background-runner",
3
- "version": "1.0.6-dev-20251124T212222.0",
3
+ "version": "1.0.6-dev-20251209T171016.0",
4
4
  "description": "Capacitor Background Runner",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -38,12 +38,12 @@
38
38
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
39
39
  "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
40
40
  "eslint": "eslint . --ext ts",
41
- "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
41
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
42
42
  "swiftlint": "node-swiftlint",
43
43
  "docgen": "docgen --api BackgroundRunnerPlugin --output-readme README.md --output-json dist/docs.json",
44
44
  "docgen-api": "docgen --api CapacitorAPI --output-readme API.md --output-json dist/docs-api.json && node ./scripts/combine_docs.js",
45
45
  "build-sdk": "./scripts/build-native-sdks.sh",
46
- "build": "npm run clean && npm run docgen && npm run docgen-api && tsc && rollup -c rollup.config.js && npm run build-sdk && ./scripts/copy-native-sdks.sh && npm pack && mv ./capacitor-background-runner-*.tgz ../../ && ./scripts/copy-readme.sh",
46
+ "build": "npm run clean && npm run docgen && npm run docgen-api && tsc && rollup -c rollup.config.js --bundleConfigAsCjs && npm run build-sdk && ./scripts/copy-native-sdks.sh && npm pack && mv ./capacitor-background-runner-*.tgz ../../ && ./scripts/copy-readme.sh",
47
47
  "pack": "npm run build && ./scripts/copy-native-sdks.sh && npm pack && mv ./capacitor-background-runner-*.tgz ../../",
48
48
  "clean": "rimraf ./dist",
49
49
  "watch": "tsc --watch",
@@ -51,21 +51,21 @@
51
51
  "postinstall": "node ./scripts/install_libs.js"
52
52
  },
53
53
  "devDependencies": {
54
- "@capacitor/android": "^6.0.0",
55
- "@capacitor/cli": "^6.0.0",
56
- "@capacitor/core": "^6.0.0",
57
- "@capacitor/docgen": "^0.2.2",
58
- "@capacitor/ios": "^6.0.0",
59
- "@ionic/eslint-config": "^0.3.0",
60
- "@ionic/prettier-config": "^1.0.1",
61
- "@ionic/swiftlint-config": "^1.1.2",
62
- "eslint": "^7.32.0",
63
- "prettier": "~2.3.2",
64
- "prettier-plugin-java": "~2.1.0",
65
- "rimraf": "^3.0.2",
66
- "rollup": "^2.79.1",
67
- "swiftlint": "^1.0.2",
68
- "typescript": "^5.1.6"
54
+ "@capacitor/android": "^6.2.1",
55
+ "@capacitor/cli": "^6.2.1",
56
+ "@capacitor/core": "^6.2.1",
57
+ "@capacitor/docgen": "0.3.0",
58
+ "@capacitor/ios": "^6.2.1",
59
+ "@ionic/eslint-config": "^0.4.0",
60
+ "@ionic/prettier-config": "^4.0.0",
61
+ "@ionic/swiftlint-config": "^2.0.0",
62
+ "eslint": "^8.57.1",
63
+ "prettier": "^3.6.2",
64
+ "prettier-plugin-java": "^2.7.7",
65
+ "rimraf": "^6.1.2",
66
+ "rollup": "^4.53.3",
67
+ "swiftlint": "^2.0.0",
68
+ "typescript": "^5.9.3"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@capacitor/core": ">=6.0.0"
@@ -83,5 +83,5 @@
83
83
  "src": "android"
84
84
  }
85
85
  },
86
- "gitHead": "2579bcc2cce8722d20aff31873d9658ec6820df4"
86
+ "gitHead": "3be5e99878ad8533a4f4bfbf0ee8bdacbd7f419a"
87
87
  }
@@ -22,10 +22,8 @@ if (!fs.existsSync(androidGradlePath)) {
22
22
  return;
23
23
  }
24
24
 
25
- const searchText =
26
- "dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'";
27
- const insertText =
28
- "\n\t\tdirs '../../node_modules/@capacitor/background-runner/android/src/main/libs', 'libs'";
25
+ const searchText = "dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'";
26
+ const insertText = "\n\t\tdirs '../../node_modules/@capacitor/background-runner/android/src/main/libs', 'libs'";
29
27
 
30
28
  let gradleFile = fs.readFileSync(androidGradlePath).toString('utf-8');
31
29
  if (gradleFile.indexOf(insertText) != -1) {
@@ -33,18 +31,12 @@ if (gradleFile.indexOf(insertText) != -1) {
33
31
  }
34
32
 
35
33
  let insertIndex = gradleFile.indexOf(searchText) + searchText.length;
36
- gradleFile =
37
- gradleFile.substring(0, insertIndex) +
38
- insertText +
39
- gradleFile.substring(insertIndex);
34
+ gradleFile = gradleFile.substring(0, insertIndex) + insertText + gradleFile.substring(insertIndex);
40
35
 
41
36
  fs.writeFileSync(androidGradlePath, gradleFile);
42
37
 
43
38
  // remove old version of aar
44
- const oldReleaseAARPath = path.join(
45
- workingDir,
46
- 'android/src/main/libs/android-js-engine-release.aar',
47
- );
39
+ const oldReleaseAARPath = path.join(workingDir, 'android/src/main/libs/android-js-engine-release.aar');
48
40
  if (fs.existsSync(oldReleaseAARPath)) {
49
41
  fs.rmSync(oldReleaseAARPath);
50
42
  }