@capacitor/clipboard 8.0.0-alpha.1 → 8.0.0-beta.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
@@ -10,7 +10,7 @@ let package = Package(
10
10
  targets: ["ClipboardPlugin"])
11
11
  ],
12
12
  dependencies: [
13
- .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
13
+ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0-beta")
14
14
  ],
15
15
  targets: [
16
16
  .target(
@@ -1,9 +1,9 @@
1
1
  ext {
2
2
  capacitorVersion = System.getenv('CAPACITOR_VERSION')
3
3
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
4
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
5
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
6
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
4
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
5
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
6
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
7
7
  }
8
8
 
9
9
  buildscript {
@@ -11,11 +11,11 @@ buildscript {
11
11
  google()
12
12
  mavenCentral()
13
13
  maven {
14
- url "https://plugins.gradle.org/m2/"
14
+ url = "https://plugins.gradle.org/m2/"
15
15
  }
16
16
  }
17
17
  dependencies {
18
- classpath 'com.android.tools.build:gradle:8.7.2'
18
+ classpath 'com.android.tools.build:gradle:8.13.0'
19
19
  if (System.getenv("CAP_PLUGIN_PUBLISH") == "true") {
20
20
  classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
21
21
  }
@@ -30,8 +30,8 @@ if (System.getenv("CAP_PLUGIN_PUBLISH") == "true") {
30
30
  }
31
31
 
32
32
  android {
33
- namespace "com.capacitorjs.plugins.clipboard"
34
- compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
33
+ namespace = "com.capacitorjs.plugins.clipboard"
34
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
35
35
  defaultConfig {
36
36
  minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
37
37
  targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
@@ -46,7 +46,7 @@ android {
46
46
  }
47
47
  }
48
48
  lintOptions {
49
- abortOnError false
49
+ abortOnError = false
50
50
  }
51
51
  compileOptions {
52
52
  sourceCompatibility JavaVersion.VERSION_21
@@ -66,9 +66,9 @@ export interface ReadResult {
66
66
  * @deprecated Use `WriteOptions`.
67
67
  * @since 1.0.0
68
68
  */
69
- export declare type ClipboardWrite = WriteOptions;
69
+ export type ClipboardWrite = WriteOptions;
70
70
  /**
71
71
  * @deprecated Use `ReadResult`.
72
72
  * @since 1.0.0
73
73
  */
74
- export declare type ClipboardReadResult = ReadResult;
74
+ export type ClipboardReadResult = ReadResult;
package/dist/esm/web.js CHANGED
@@ -50,18 +50,14 @@ export class ClipboardWeb extends WebPlugin {
50
50
  }
51
51
  }
52
52
  async readText() {
53
- if (typeof navigator === 'undefined' ||
54
- !navigator.clipboard ||
55
- !navigator.clipboard.readText) {
53
+ if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.readText) {
56
54
  throw this.unavailable('Reading from clipboard not supported in this browser');
57
55
  }
58
56
  const text = await navigator.clipboard.readText();
59
57
  return { value: text, type: 'text/plain' };
60
58
  }
61
59
  async writeText(text) {
62
- if (typeof navigator === 'undefined' ||
63
- !navigator.clipboard ||
64
- !navigator.clipboard.writeText) {
60
+ if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.writeText) {
65
61
  throw this.unavailable('Writting to clipboard not supported in this browser');
66
62
  }
67
63
  await navigator.clipboard.writeText(text);
@@ -79,7 +75,7 @@ export class ClipboardWeb extends WebPlugin {
79
75
  const r = reader.result;
80
76
  resolve(r);
81
77
  };
82
- reader.onerror = e => {
78
+ reader.onerror = (e) => {
83
79
  reject(e);
84
80
  };
85
81
  });
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAa5C,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;YAC5D,MAAM,IAAI,CAAC,WAAW,CAAC,6CAA6C,CAAC,CAAC;SACvE;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;YAChC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SACtC;aAAM,IAAI,OAAO,CAAC,GAAG,EAAE;YACtB,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SACnC;aAAM,IAAI,OAAO,CAAC,KAAK,EAAE;YACxB,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE;gBACxC,IAAI;oBACF,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;oBACvD,MAAM,kBAAkB,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;oBACpE,MAAM,SAAS,CAAC,SAAS,C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AsD,CACvD,CAAC;SACH;QAED,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAClD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAC7C,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,IAAY;QAClC,IACE,OAAO,SAAS,KAAK,WAAW;YAChC,CAAC,SAAS,CAAC,SAAS;YACpB,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,EAC9B;YACA,MAAM,IAAI,CAAC,WAAW,CACpB,qDAAqD,CACtD,CAAC;SACH;QAED,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEO,YAAY,CAAC,aAAmB,EAAE,IAAY;QACpD,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC7C,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBAC1B,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;aACrC;iBAAM;gBACL,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;aAClC;YACD,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE;gBACtB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAgB,CAAC;gBAClC,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE;gBACnB,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { ClipboardPlugin, ReadResult, WriteOptions } from './definitions';\n\ndeclare global {\n interface Clipboard {\n read(): Promise<any>;\n write(data: any[]): Promise<any>;\n }\n}\n\ndeclare let ClipboardItem: any;\n\nexport class ClipboardWeb extends WebPlugin implements ClipboardPlugin {\n async write(options: WriteOptions): Promise<void> {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n\n if (options.string !== undefined) {\n await this.writeText(options.string);\n } else if (options.url) {\n await this.writeText(options.url);\n } else if (options.image) {\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const blob = await (await fetch(options.image)).blob();\n const clipboardItemInput = new ClipboardItem({ [blob.type]: blob });\n await navigator.clipboard.write([clipboardItemInput]);\n } catch (err) {\n throw new Error('Failed to write image');\n }\n } else {\n throw this.unavailable(\n 'Writing images to the clipboard is not supported in this browser',\n );\n }\n } else {\n throw new Error('Nothing to write');\n }\n }\n\n async read(): Promise<ReadResult> {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const clipboardItems = await navigator.clipboard.read();\n const type = clipboardItems[0].types[0];\n const clipboardBlob = await clipboardItems[0].getType(type);\n const data = await this._getBlobData(clipboardBlob, type);\n return { value: data, type };\n } catch (err) {\n return this.readText();\n }\n } else {\n return this.readText();\n }\n }\n\n private async readText() {\n if (\n typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.readText\n ) {\n throw this.unavailable(\n 'Reading from clipboard not supported in this browser',\n );\n }\n\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n\n private async writeText(text: string) {\n if (\n typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.writeText\n ) {\n throw this.unavailable(\n 'Writting to clipboard not supported in this browser',\n );\n }\n\n await navigator.clipboard.writeText(text);\n }\n\n private _getBlobData(clipboardBlob: Blob, type: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n if (type.includes('image')) {\n reader.readAsDataURL(clipboardBlob);\n } else {\n reader.readAsText(clipboardBlob);\n }\n reader.onloadend = () => {\n const r = reader.result as string;\n resolve(r);\n };\n reader.onerror = e => {\n reject(e);\n };\n });\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAa5C,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;YAC7D,MAAM,IAAI,CAAC,WAAW,CAAC,6CAA6C,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;aAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,CAAC;aAAM,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YACzB,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE,CAAC;gBACzC,IAAI,CAAC;oBACH,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;oBACvD,MAAM,kBAAkB,GAAG,IAAI,aAAa,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;oBACpE,MAAM,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC;gBACxD,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;gBAC3C,CAAC;YACH,CAAC;iBAAM,CAAC;g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S,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAClD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAC7C,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,IAAY;QAClC,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;YAC/F,MAAM,IAAI,CAAC,WAAW,CAAC,qDAAqD,CAAC,CAAC;QAChF,CAAC;QAED,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEO,YAAY,CAAC,aAAmB,EAAE,IAAY;QACpD,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC7C,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;YAChC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3B,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACnC,CAAC;YACD,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE;gBACtB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAgB,CAAC;gBAClC,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC;YACF,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE;gBACrB,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type { ClipboardPlugin, ReadResult, WriteOptions } from './definitions';\n\ndeclare global {\n interface Clipboard {\n read(): Promise<any>;\n write(data: any[]): Promise<any>;\n }\n}\n\ndeclare let ClipboardItem: any;\n\nexport class ClipboardWeb extends WebPlugin implements ClipboardPlugin {\n async write(options: WriteOptions): Promise<void> {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n\n if (options.string !== undefined) {\n await this.writeText(options.string);\n } else if (options.url) {\n await this.writeText(options.url);\n } else if (options.image) {\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const blob = await (await fetch(options.image)).blob();\n const clipboardItemInput = new ClipboardItem({ [blob.type]: blob });\n await navigator.clipboard.write([clipboardItemInput]);\n } catch (err) {\n throw new Error('Failed to write image');\n }\n } else {\n throw this.unavailable('Writing images to the clipboard is not supported in this browser');\n }\n } else {\n throw new Error('Nothing to write');\n }\n }\n\n async read(): Promise<ReadResult> {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const clipboardItems = await navigator.clipboard.read();\n const type = clipboardItems[0].types[0];\n const clipboardBlob = await clipboardItems[0].getType(type);\n const data = await this._getBlobData(clipboardBlob, type);\n return { value: data, type };\n } catch (err) {\n return this.readText();\n }\n } else {\n return this.readText();\n }\n }\n\n private async readText() {\n if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.readText) {\n throw this.unavailable('Reading from clipboard not supported in this browser');\n }\n\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n\n private async writeText(text: string) {\n if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.writeText) {\n throw this.unavailable('Writting to clipboard not supported in this browser');\n }\n\n await navigator.clipboard.writeText(text);\n }\n\n private _getBlobData(clipboardBlob: Blob, type: string): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n if (type.includes('image')) {\n reader.readAsDataURL(clipboardBlob);\n } else {\n reader.readAsText(clipboardBlob);\n }\n reader.onloadend = () => {\n const r = reader.result as string;\n resolve(r);\n };\n reader.onerror = (e) => {\n reject(e);\n };\n });\n }\n}\n"]}
@@ -53,18 +53,14 @@ class ClipboardWeb extends core.WebPlugin {
53
53
  }
54
54
  }
55
55
  async readText() {
56
- if (typeof navigator === 'undefined' ||
57
- !navigator.clipboard ||
58
- !navigator.clipboard.readText) {
56
+ if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.readText) {
59
57
  throw this.unavailable('Reading from clipboard not supported in this browser');
60
58
  }
61
59
  const text = await navigator.clipboard.readText();
62
60
  return { value: text, type: 'text/plain' };
63
61
  }
64
62
  async writeText(text) {
65
- if (typeof navigator === 'undefined' ||
66
- !navigator.clipboard ||
67
- !navigator.clipboard.writeText) {
63
+ if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.writeText) {
68
64
  throw this.unavailable('Writting to clipboard not supported in this browser');
69
65
  }
70
66
  await navigator.clipboard.writeText(text);
@@ -82,7 +78,7 @@ class ClipboardWeb extends core.WebPlugin {
82
78
  const r = reader.result;
83
79
  resolve(r);
84
80
  };
85
- reader.onerror = e => {
81
+ reader.onerror = (e) => {
86
82
  reject(e);
87
83
  };
88
84
  });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/web.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class ClipboardWeb extends WebPlugin {\n async write(options) {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (options.string !== undefined) {\n await this.writeText(options.string);\n }\n else if (options.url) {\n await this.writeText(options.url);\n }\n else if (options.image) {\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const blob = await (await fetch(options.image)).blob();\n const clipboardItemInput = new ClipboardItem({ [blob.type]: blob });\n await navigator.clipboard.write([clipboardItemInput]);\n }\n catch (err) {\n throw new Error('Failed to write image');\n }\n }\n else {\n throw this.unavailable('Writing images to the clipboard is not supported in this browser');\n }\n }\n else {\n throw new Error('Nothing to write');\n }\n }\n async read() {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const clipboardItems = await navigator.clipboard.read();\n const type = clipboardItems[0].types[0];\n const clipboardBlob = await clipboardItems[0].getType(type);\n const data = await this._getBlobData(clipboardBlob, type);\n return { value: data, type };\n }\n catch (err) {\n return this.readText();\n }\n }\n else {\n return this.readText();\n }\n }\n async readText() {\n if (typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.readText) {\n throw this.unavailable('Reading from clipboard not supported in this browser');\n }\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n async writeText(text) {\n if (typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.writeText) {\n throw this.unavailable('Writting to clipboard not supported in this browser');\n }\n await navigator.clipboard.writeText(text);\n }\n _getBlobData(clipboardBlob, type) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n if (type.includes('image')) {\n reader.readAsDataURL(clipboardBlob);\n }\n else {\n reader.readAsText(clipboardBlob);\n }\n reader.onloadend = () => {\n const r = reader.result;\n resolve(r);\n };\n reader.onerror = e => {\n reject(e);\n };\n });\n }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nimport { ClipboardWeb } from './web';\nconst Clipboard = registerPlugin('Clipboard', {\n web: () => new ClipboardWeb(),\n});\nexport * from './definitions';\nexport { Clipboard };\n//# sourceMappingURL=index.js.map"],"names":["WebPlugin","registerPlugin"],"mappings":";;;;AACO,MAAM,YAAY,SAASA,cAAS,CAAC;AAC5C,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;AACtE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,6CAA6C,CAAC;AACjF,QAAQ;AACR,QAAQ,IAAI,OAAO,CAAC,MAAM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S,CAAC,SAAS,CAAC,IAAI,CAAC;AACjD,IAAI;AACJ,IAAI,YAAY,CAAC,aAAa,EAAE,IAAI,EAAE;AACtC,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE;AAC3C,YAAY,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;AACxC,gBAAgB,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC;AACnD,YAAY;AACZ,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC;AAChD,YAAY;AACZ,YAAY,MAAM,CAAC,SAAS,GAAG,MAAM;AACrC,gBAAgB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM;AACvC,gBAAgB,OAAO,CAAC,CAAC,CAAC;AAC1B,YAAY,CAAC;AACb,YAAY,MAAM,CAAC,OAAO,GAAG,CAAC,IAAI;AAClC,gBAAgB,MAAM,CAAC,CAAC,CAAC;AACzB,YAAY,CAAC;AACb,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ;;ACpFK,MAAC,SAAS,GAAGC,mBAAc,CAAC,WAAW,EAAE;AAC9C,IAAI,GAAG,EAAE,MAAM,IAAI,YAAY,EAAE;AACjC,CAAC;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/web.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class ClipboardWeb extends WebPlugin {\n async write(options) {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (options.string !== undefined) {\n await this.writeText(options.string);\n }\n else if (options.url) {\n await this.writeText(options.url);\n }\n else if (options.image) {\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const blob = await (await fetch(options.image)).blob();\n const clipboardItemInput = new ClipboardItem({ [blob.type]: blob });\n await navigator.clipboard.write([clipboardItemInput]);\n }\n catch (err) {\n throw new Error('Failed to write image');\n }\n }\n else {\n throw this.unavailable('Writing images to the clipboard is not supported in this browser');\n }\n }\n else {\n throw new Error('Nothing to write');\n }\n }\n async read() {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const clipboardItems = await navigator.clipboard.read();\n const type = clipboardItems[0].types[0];\n const clipboardBlob = await clipboardItems[0].getType(type);\n const data = await this._getBlobData(clipboardBlob, type);\n return { value: data, type };\n }\n catch (err) {\n return this.readText();\n }\n }\n else {\n return this.readText();\n }\n }\n async readText() {\n if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.readText) {\n throw this.unavailable('Reading from clipboard not supported in this browser');\n }\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n async writeText(text) {\n if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.writeText) {\n throw this.unavailable('Writting to clipboard not supported in this browser');\n }\n await navigator.clipboard.writeText(text);\n }\n _getBlobData(clipboardBlob, type) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n if (type.includes('image')) {\n reader.readAsDataURL(clipboardBlob);\n }\n else {\n reader.readAsText(clipboardBlob);\n }\n reader.onloadend = () => {\n const r = reader.result;\n resolve(r);\n };\n reader.onerror = (e) => {\n reject(e);\n };\n });\n }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nimport { ClipboardWeb } from './web';\nconst Clipboard = registerPlugin('Clipboard', {\n web: () => new ClipboardWeb(),\n});\nexport * from './definitions';\nexport { Clipboard };\n//# sourceMappingURL=index.js.map"],"names":["WebPlugin","registerPlugin"],"mappings":";;;;AACO,MAAM,YAAY,SAASA,cAAS,CAAC;AAC5C,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;AACtE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AW,CAAC,qDAAqD,CAAC;AACzF,QAAQ;AACR,QAAQ,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;AACjD,IAAI;AACJ,IAAI,YAAY,CAAC,aAAa,EAAE,IAAI,EAAE;AACtC,QAAQ,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAChD,YAAY,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE;AAC3C,YAAY,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;AACxC,gBAAgB,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC;AACnD,YAAY;AACZ,iBAAiB;AACjB,gBAAgB,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC;AAChD,YAAY;AACZ,YAAY,MAAM,CAAC,SAAS,GAAG,MAAM;AACrC,gBAAgB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM;AACvC,gBAAgB,OAAO,CAAC,CAAC,CAAC;AAC1B,YAAY,CAAC;AACb,YAAY,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK;AACpC,gBAAgB,MAAM,CAAC,CAAC,CAAC;AACzB,YAAY,CAAC;AACb,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ;;AChFK,MAAC,SAAS,GAAGC,mBAAc,CAAC,WAAW,EAAE;AAC9C,IAAI,GAAG,EAAE,MAAM,IAAI,YAAY,EAAE;AACjC,CAAC;;;;"}
package/dist/plugin.js CHANGED
@@ -52,18 +52,14 @@ var capacitorClipboard = (function (exports, core) {
52
52
  }
53
53
  }
54
54
  async readText() {
55
- if (typeof navigator === 'undefined' ||
56
- !navigator.clipboard ||
57
- !navigator.clipboard.readText) {
55
+ if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.readText) {
58
56
  throw this.unavailable('Reading from clipboard not supported in this browser');
59
57
  }
60
58
  const text = await navigator.clipboard.readText();
61
59
  return { value: text, type: 'text/plain' };
62
60
  }
63
61
  async writeText(text) {
64
- if (typeof navigator === 'undefined' ||
65
- !navigator.clipboard ||
66
- !navigator.clipboard.writeText) {
62
+ if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.writeText) {
67
63
  throw this.unavailable('Writting to clipboard not supported in this browser');
68
64
  }
69
65
  await navigator.clipboard.writeText(text);
@@ -81,7 +77,7 @@ var capacitorClipboard = (function (exports, core) {
81
77
  const r = reader.result;
82
78
  resolve(r);
83
79
  };
84
- reader.onerror = e => {
80
+ reader.onerror = (e) => {
85
81
  reject(e);
86
82
  };
87
83
  });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/web.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class ClipboardWeb extends WebPlugin {\n async write(options) {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (options.string !== undefined) {\n await this.writeText(options.string);\n }\n else if (options.url) {\n await this.writeText(options.url);\n }\n else if (options.image) {\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const blob = await (await fetch(options.image)).blob();\n const clipboardItemInput = new ClipboardItem({ [blob.type]: blob });\n await navigator.clipboard.write([clipboardItemInput]);\n }\n catch (err) {\n throw new Error('Failed to write image');\n }\n }\n else {\n throw this.unavailable('Writing images to the clipboard is not supported in this browser');\n }\n }\n else {\n throw new Error('Nothing to write');\n }\n }\n async read() {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const clipboardItems = await navigator.clipboard.read();\n const type = clipboardItems[0].types[0];\n const clipboardBlob = await clipboardItems[0].getType(type);\n const data = await this._getBlobData(clipboardBlob, type);\n return { value: data, type };\n }\n catch (err) {\n return this.readText();\n }\n }\n else {\n return this.readText();\n }\n }\n async readText() {\n if (typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.readText) {\n throw this.unavailable('Reading from clipboard not supported in this browser');\n }\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n async writeText(text) {\n if (typeof navigator === 'undefined' ||\n !navigator.clipboard ||\n !navigator.clipboard.writeText) {\n throw this.unavailable('Writting to clipboard not supported in this browser');\n }\n await navigator.clipboard.writeText(text);\n }\n _getBlobData(clipboardBlob, type) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n if (type.includes('image')) {\n reader.readAsDataURL(clipboardBlob);\n }\n else {\n reader.readAsText(clipboardBlob);\n }\n reader.onloadend = () => {\n const r = reader.result;\n resolve(r);\n };\n reader.onerror = e => {\n reject(e);\n };\n });\n }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nimport { ClipboardWeb } from './web';\nconst Clipboard = registerPlugin('Clipboard', {\n web: () => new ClipboardWeb(),\n});\nexport * from './definitions';\nexport { Clipboard };\n//# sourceMappingURL=index.js.map"],"names":["WebPlugin","registerPlugin"],"mappings":";;;IACO,MAAM,YAAY,SAASA,cAAS,CAAC;IAC5C,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;IACtE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,6CAA6C,CAAC;IACjF,QAAQ;IACR,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;IAC1C,YAAY,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;IAChD,QAAQ;IACR,aAAa,IAAI,OAAO,CAAC,GAAG,EAAE;IAC9B,YAAY,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;IAC7C,QAAQ;IACR,aAAa,IAAI,OAAO,CAAC,KAAK,EAAE;IAChC,YAAY,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE;IACtD,gBAAgB,IAAI;IACpB,oBAAoB,MAAM,IAAI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AgB,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC;IAChD,YAAY;IACZ,YAAY,MAAM,CAAC,SAAS,GAAG,MAAM;IACrC,gBAAgB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM;IACvC,gBAAgB,OAAO,CAAC,CAAC,CAAC;IAC1B,YAAY,CAAC;IACb,YAAY,MAAM,CAAC,OAAO,GAAG,CAAC,IAAI;IAClC,gBAAgB,MAAM,CAAC,CAAC,CAAC;IACzB,YAAY,CAAC;IACb,QAAQ,CAAC,CAAC;IACV,IAAI;IACJ;;ACpFK,UAAC,SAAS,GAAGC,mBAAc,CAAC,WAAW,EAAE;IAC9C,IAAI,GAAG,EAAE,MAAM,IAAI,YAAY,EAAE;IACjC,CAAC;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/web.js","esm/index.js"],"sourcesContent":["import { WebPlugin } from '@capacitor/core';\nexport class ClipboardWeb extends WebPlugin {\n async write(options) {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (options.string !== undefined) {\n await this.writeText(options.string);\n }\n else if (options.url) {\n await this.writeText(options.url);\n }\n else if (options.image) {\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const blob = await (await fetch(options.image)).blob();\n const clipboardItemInput = new ClipboardItem({ [blob.type]: blob });\n await navigator.clipboard.write([clipboardItemInput]);\n }\n catch (err) {\n throw new Error('Failed to write image');\n }\n }\n else {\n throw this.unavailable('Writing images to the clipboard is not supported in this browser');\n }\n }\n else {\n throw new Error('Nothing to write');\n }\n }\n async read() {\n if (typeof navigator === 'undefined' || !navigator.clipboard) {\n throw this.unavailable('Clipboard API not available in this browser');\n }\n if (typeof ClipboardItem !== 'undefined') {\n try {\n const clipboardItems = await navigator.clipboard.read();\n const type = clipboardItems[0].types[0];\n const clipboardBlob = await clipboardItems[0].getType(type);\n const data = await this._getBlobData(clipboardBlob, type);\n return { value: data, type };\n }\n catch (err) {\n return this.readText();\n }\n }\n else {\n return this.readText();\n }\n }\n async readText() {\n if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.readText) {\n throw this.unavailable('Reading from clipboard not supported in this browser');\n }\n const text = await navigator.clipboard.readText();\n return { value: text, type: 'text/plain' };\n }\n async writeText(text) {\n if (typeof navigator === 'undefined' || !navigator.clipboard || !navigator.clipboard.writeText) {\n throw this.unavailable('Writting to clipboard not supported in this browser');\n }\n await navigator.clipboard.writeText(text);\n }\n _getBlobData(clipboardBlob, type) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n if (type.includes('image')) {\n reader.readAsDataURL(clipboardBlob);\n }\n else {\n reader.readAsText(clipboardBlob);\n }\n reader.onloadend = () => {\n const r = reader.result;\n resolve(r);\n };\n reader.onerror = (e) => {\n reject(e);\n };\n });\n }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nimport { ClipboardWeb } from './web';\nconst Clipboard = registerPlugin('Clipboard', {\n web: () => new ClipboardWeb(),\n});\nexport * from './definitions';\nexport { Clipboard };\n//# sourceMappingURL=index.js.map"],"names":["WebPlugin","registerPlugin"],"mappings":";;;IACO,MAAM,YAAY,SAASA,cAAS,CAAC;IAC5C,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;IACtE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,6CAA6C,CAAC;IACjF,QAAQ;IACR,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;IAC1C,YAAY,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;IAChD,QAAQ;IACR,aAAa,IAAI,OAAO,CAAC,GAAG,EAAE;IAC9B,YAAY,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;IAC7C,QAAQ;IACR,aAAa,IAAI,OAAO,CAAC,KAAK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MAAM,CAAC,aAAa,CAAC,aAAa,CAAC;IACnD,YAAY;IACZ,iBAAiB;IACjB,gBAAgB,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC;IAChD,YAAY;IACZ,YAAY,MAAM,CAAC,SAAS,GAAG,MAAM;IACrC,gBAAgB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM;IACvC,gBAAgB,OAAO,CAAC,CAAC,CAAC;IAC1B,YAAY,CAAC;IACb,YAAY,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK;IACpC,gBAAgB,MAAM,CAAC,CAAC,CAAC;IACzB,YAAY,CAAC;IACb,QAAQ,CAAC,CAAC;IACV,IAAI;IACJ;;AChFK,UAAC,SAAS,GAAGC,mBAAc,CAAC,WAAW,EAAE;IAC9C,IAAI,GAAG,EAAE,MAAM,IAAI,YAAY,EAAE;IACjC,CAAC;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/clipboard",
3
- "version": "8.0.0-alpha.1",
3
+ "version": "8.0.0-beta.0",
4
4
  "description": "The Clipboard API enables copy and pasting to/from the system clipboard.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -37,7 +37,7 @@
37
37
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
38
38
  "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
39
39
  "eslint": "eslint . --ext ts",
40
- "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
40
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
41
41
  "swiftlint": "node-swiftlint",
42
42
  "docgen": "docgen --api ClipboardPlugin --output-readme README.md --output-json dist/docs.json",
43
43
  "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
@@ -49,18 +49,18 @@
49
49
  "devDependencies": {
50
50
  "@capacitor/android": "next",
51
51
  "@capacitor/core": "next",
52
- "@capacitor/docgen": "0.2.2",
52
+ "@capacitor/docgen": "0.3.0",
53
53
  "@capacitor/ios": "next",
54
54
  "@ionic/eslint-config": "^0.4.0",
55
- "@ionic/prettier-config": "~1.0.1",
56
- "@ionic/swiftlint-config": "^1.1.2",
57
- "eslint": "^8.57.0",
58
- "prettier": "~2.3.0",
59
- "prettier-plugin-java": "~1.0.2",
60
- "rimraf": "^6.0.1",
61
- "rollup": "^4.26.0",
62
- "swiftlint": "^1.0.1",
63
- "typescript": "~4.1.5"
55
+ "@ionic/prettier-config": "^4.0.0",
56
+ "@ionic/swiftlint-config": "^2.0.0",
57
+ "eslint": "^8.57.1",
58
+ "prettier": "^3.6.2",
59
+ "prettier-plugin-java": "^2.7.7",
60
+ "rimraf": "^6.1.0",
61
+ "rollup": "^4.53.2",
62
+ "swiftlint": "^2.0.0",
63
+ "typescript": "^5.9.3"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@capacitor/core": "next"
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "4c2f39a8fc78578c919a81ba410d6a37e70152d0"
84
+ "gitHead": "06921fb53dc712720523c13836a92ba371054dcb"
85
85
  }