capacitor-clear-cache 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 = 'CapacitorClearCache'
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/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
+ s.ios.deployment_target = '13.0'
15
+ s.dependency 'Capacitor'
16
+ s.swift_version = '5.1'
17
+ end
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # capacitor-clear-cache
2
+
3
+ Clear various app caches
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install capacitor-clear-cache
9
+ npx cap sync
10
+ ```
11
+
12
+ ## API
13
+
14
+ <docgen-index>
15
+
16
+ * [`clear()`](#clear)
17
+
18
+ </docgen-index>
19
+
20
+ <docgen-api>
21
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
22
+
23
+ ### clear()
24
+
25
+ ```typescript
26
+ clear() => Promise<void>
27
+ ```
28
+
29
+ --------------------
30
+
31
+ </docgen-api>
@@ -0,0 +1,58 @@
1
+ ext {
2
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
5
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
6
+ }
7
+
8
+ buildscript {
9
+ repositories {
10
+ google()
11
+ mavenCentral()
12
+ }
13
+ dependencies {
14
+ classpath 'com.android.tools.build:gradle:8.0.0'
15
+ }
16
+ }
17
+
18
+ apply plugin: 'com.android.library'
19
+
20
+ android {
21
+ namespace "dev.harding.plugins.clearcache"
22
+ compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
23
+ defaultConfig {
24
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
25
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
26
+ versionCode 1
27
+ versionName "1.0"
28
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29
+ }
30
+ buildTypes {
31
+ release {
32
+ minifyEnabled false
33
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34
+ }
35
+ }
36
+ lintOptions {
37
+ abortOnError false
38
+ }
39
+ compileOptions {
40
+ sourceCompatibility JavaVersion.VERSION_17
41
+ targetCompatibility JavaVersion.VERSION_17
42
+ }
43
+ }
44
+
45
+ repositories {
46
+ google()
47
+ mavenCentral()
48
+ }
49
+
50
+
51
+ dependencies {
52
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
53
+ implementation project(':capacitor-android')
54
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
55
+ testImplementation "junit:junit:$junitVersion"
56
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,16 @@
1
+ package dev.harding.plugins.clearcache;
2
+
3
+ import com.getcapacitor.JSObject;
4
+ import com.getcapacitor.Plugin;
5
+ import com.getcapacitor.PluginCall;
6
+ import com.getcapacitor.PluginMethod;
7
+ import com.getcapacitor.annotation.CapacitorPlugin;
8
+
9
+ @CapacitorPlugin(name = "ClearCache")
10
+ public class ClearCachePlugin extends Plugin {
11
+
12
+ @PluginMethod
13
+ public void clear(PluginCall call) {
14
+ call.unimplemented("Clearing cache is not implemented on Android");
15
+ }
16
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "api": {
3
+ "name": "ClearCachePlugin",
4
+ "slug": "clearcacheplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "clear",
10
+ "signature": "() => Promise<void>",
11
+ "parameters": [],
12
+ "returns": "Promise<void>",
13
+ "tags": [],
14
+ "docs": "",
15
+ "complexTypes": [],
16
+ "slug": "clear"
17
+ }
18
+ ],
19
+ "properties": []
20
+ },
21
+ "interfaces": [],
22
+ "enums": [],
23
+ "typeAliases": [],
24
+ "pluginConfigs": []
25
+ }
@@ -0,0 +1,3 @@
1
+ export interface ClearCachePlugin {
2
+ clear(): Promise<void>;
3
+ }
@@ -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":["export interface ClearCachePlugin {\n clear(): Promise<void>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ClearCachePlugin } from './definitions';
2
+ declare const ClearCache: ClearCachePlugin;
3
+ export * from './definitions';
4
+ export { ClearCache };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const ClearCache = registerPlugin('ClearCache', {
3
+ web: () => import('./web').then(m => new m.ClearCacheWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { ClearCache };
7
+ //# 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,CAAC;AAIjD,MAAM,UAAU,GAAG,cAAc,CAAmB,YAAY,EAAE;IAChE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;CAC5D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { ClearCachePlugin } from './definitions';\n\nconst ClearCache = registerPlugin<ClearCachePlugin>('ClearCache', {\n web: () => import('./web').then(m => new m.ClearCacheWeb()),\n});\n\nexport * from './definitions';\nexport { ClearCache };\n"]}
@@ -0,0 +1,5 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { ClearCachePlugin } from './definitions';
3
+ export declare class ClearCacheWeb extends WebPlugin implements ClearCachePlugin {
4
+ clear(): Promise<void>;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class ClearCacheWeb extends WebPlugin {
3
+ async clear() {
4
+ this.unavailable('Not available on web platform');
5
+ }
6
+ }
7
+ //# 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,CAAC;AAI5C,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { ClearCachePlugin } from './definitions';\n\nexport class ClearCacheWeb extends WebPlugin implements ClearCachePlugin {\n async clear(): Promise<void> {\n this.unavailable('Not available on web platform');\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ const ClearCache = core.registerPlugin('ClearCache', {
8
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ClearCacheWeb()),
9
+ });
10
+
11
+ class ClearCacheWeb extends core.WebPlugin {
12
+ async clear() {
13
+ this.unavailable('Not available on web platform');
14
+ }
15
+ }
16
+
17
+ var web = /*#__PURE__*/Object.freeze({
18
+ __proto__: null,
19
+ ClearCacheWeb: ClearCacheWeb
20
+ });
21
+
22
+ exports.ClearCache = ClearCache;
23
+ //# 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 ClearCache = registerPlugin('ClearCache', {\n web: () => import('./web').then(m => new m.ClearCacheWeb()),\n});\nexport * from './definitions';\nexport { ClearCache };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ClearCacheWeb extends WebPlugin {\n async clear() {\n this.unavailable('Not available on web platform');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;AAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;AAC/D,CAAC;;ACFM,MAAM,aAAa,SAASC,cAAS,CAAC;AAC7C,IAAI,MAAM,KAAK,GAAG;AAClB,QAAQ,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;AAC1D,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,26 @@
1
+ var capacitorClearCache = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const ClearCache = core.registerPlugin('ClearCache', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ClearCacheWeb()),
6
+ });
7
+
8
+ class ClearCacheWeb extends core.WebPlugin {
9
+ async clear() {
10
+ this.unavailable('Not available on web platform');
11
+ }
12
+ }
13
+
14
+ var web = /*#__PURE__*/Object.freeze({
15
+ __proto__: null,
16
+ ClearCacheWeb: ClearCacheWeb
17
+ });
18
+
19
+ exports.ClearCache = ClearCache;
20
+
21
+ Object.defineProperty(exports, '__esModule', { value: true });
22
+
23
+ return exports;
24
+
25
+ })({}, capacitorExports);
26
+ //# 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 ClearCache = registerPlugin('ClearCache', {\n web: () => import('./web').then(m => new m.ClearCacheWeb()),\n});\nexport * from './definitions';\nexport { ClearCache };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ClearCacheWeb extends WebPlugin {\n async clear() {\n this.unavailable('Not available on web platform');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,UAAU,GAAGA,mBAAc,CAAC,YAAY,EAAE;IAChD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;IAC/D,CAAC;;ICFM,MAAM,aAAa,SAASC,cAAS,CAAC;IAC7C,IAAI,MAAM,KAAK,GAAG;IAClB,QAAQ,IAAI,CAAC,WAAW,CAAC,+BAA+B,CAAC,CAAC;IAC1D,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,8 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(ClearCachePlugin, "ClearCache",
7
+ CAP_PLUGIN_METHOD(clear, CAPPluginReturnPromise);
8
+ )
@@ -0,0 +1,63 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import SafariServices
4
+
5
+ @objc(ClearCachePlugin)
6
+ public class ClearCachePlugin: CAPPlugin {
7
+ @objc func clear(_ call: CAPPluginCall) {
8
+ if #available(iOS 16.0, *) {
9
+ SFSafariViewController.DataStore.default.clearWebsiteData { [weak self] in
10
+ guard self != nil else { return }
11
+
12
+ HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
13
+ URLCache.shared.removeAllCachedResponses()
14
+
15
+ if #available(iOS 17.0, *) {
16
+ WKWebsiteDataStore.default().removeData(ofTypes: [
17
+ WKWebsiteDataTypeCookies,
18
+ WKWebsiteDataTypeDiskCache,
19
+ WKWebsiteDataTypeMemoryCache,
20
+ WKWebsiteDataTypeFetchCache,
21
+ WKWebsiteDataTypeSessionStorage,
22
+ WKWebsiteDataTypeServiceWorkerRegistrations,
23
+ WKWebsiteDataTypeOfflineWebApplicationCache,
24
+
25
+ WKWebsiteDataTypeFileSystem,
26
+
27
+ WKWebsiteDataTypeSearchFieldRecentSearches,
28
+ WKWebsiteDataTypeHashSalt,
29
+ WKWebsiteDataTypeMediaKeys,
30
+ ], modifiedSince: Date(timeIntervalSince1970: 0), completionHandler: {
31
+ call.resolve()
32
+ })
33
+ } else {
34
+ WKWebsiteDataStore.default().removeData(ofTypes: [
35
+ WKWebsiteDataTypeCookies,
36
+ WKWebsiteDataTypeDiskCache,
37
+ WKWebsiteDataTypeMemoryCache,
38
+ WKWebsiteDataTypeFetchCache,
39
+ WKWebsiteDataTypeSessionStorage,
40
+ WKWebsiteDataTypeServiceWorkerRegistrations,
41
+ WKWebsiteDataTypeOfflineWebApplicationCache,
42
+
43
+ WKWebsiteDataTypeFileSystem,
44
+ ], modifiedSince: Date(timeIntervalSince1970: 0), completionHandler: {
45
+ call.resolve()
46
+ })
47
+ }
48
+ }
49
+ } else {
50
+ WKWebsiteDataStore.default().removeData(ofTypes: [
51
+ WKWebsiteDataTypeCookies,
52
+ WKWebsiteDataTypeDiskCache,
53
+ WKWebsiteDataTypeMemoryCache,
54
+ WKWebsiteDataTypeFetchCache,
55
+ WKWebsiteDataTypeSessionStorage,
56
+ WKWebsiteDataTypeServiceWorkerRegistrations,
57
+ WKWebsiteDataTypeOfflineWebApplicationCache
58
+ ], modifiedSince: Date(timeIntervalSince1970: 0), completionHandler: {
59
+ call.resolve()
60
+ })
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "capacitor-clear-cache",
3
+ "version": "0.0.1",
4
+ "description": "Clear various app caches",
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/Plugin/",
14
+ "CapacitorClearCache.podspec"
15
+ ],
16
+ "author": "",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/aeharding/capacitor-clear-cache.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/aeharding/capacitor-clear-cache/issues"
24
+ },
25
+ "keywords": [
26
+ "capacitor",
27
+ "plugin",
28
+ "native"
29
+ ],
30
+ "scripts": {
31
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
32
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
33
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
34
+ "verify:web": "npm run build",
35
+ "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
36
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
37
+ "eslint": "eslint . --ext ts",
38
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
39
+ "swiftlint": "node-swiftlint",
40
+ "docgen": "docgen --api ClearCachePlugin --output-readme README.md --output-json dist/docs.json",
41
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
42
+ "clean": "rimraf ./dist",
43
+ "watch": "tsc --watch",
44
+ "prepublishOnly": "npm run build"
45
+ },
46
+ "devDependencies": {
47
+ "@capacitor/android": "^5.0.0",
48
+ "@capacitor/core": "^5.0.0",
49
+ "@capacitor/docgen": "^0.0.18",
50
+ "@capacitor/ios": "^5.0.0",
51
+ "@ionic/eslint-config": "^0.3.0",
52
+ "@ionic/prettier-config": "^1.0.1",
53
+ "@ionic/swiftlint-config": "^1.1.2",
54
+ "eslint": "^7.11.0",
55
+ "prettier": "~2.3.0",
56
+ "prettier-plugin-java": "~1.0.2",
57
+ "rimraf": "^3.0.2",
58
+ "rollup": "^2.32.0",
59
+ "swiftlint": "^1.0.1",
60
+ "typescript": "~4.1.5"
61
+ },
62
+ "peerDependencies": {
63
+ "@capacitor/core": "^5.0.0"
64
+ },
65
+ "prettier": "@ionic/prettier-config",
66
+ "swiftlint": "@ionic/swiftlint-config",
67
+ "eslintConfig": {
68
+ "extends": "@ionic/eslint-config/recommended"
69
+ },
70
+ "capacitor": {
71
+ "ios": {
72
+ "src": "ios"
73
+ },
74
+ "android": {
75
+ "src": "android"
76
+ }
77
+ }
78
+ }