@capawesome/capacitor-screen-reader 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.
Files changed (41) hide show
  1. package/CapawesomeCapacitorScreenReader.podspec +17 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +28 -0
  4. package/README.md +245 -0
  5. package/android/build.gradle +58 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/ScreenReader.java +93 -0
  8. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/ScreenReaderPlugin.java +122 -0
  9. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/classes/CustomException.java +20 -0
  10. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/classes/CustomExceptions.java +6 -0
  11. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/classes/events/StateChangeEvent.java +22 -0
  12. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/classes/options/AnnounceOptions.java +34 -0
  13. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/classes/results/IsEnabledResult.java +22 -0
  14. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/interfaces/Callback.java +5 -0
  15. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/interfaces/EmptyCallback.java +5 -0
  16. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/interfaces/NonEmptyResultCallback.java +7 -0
  17. package/android/src/main/java/io/capawesome/capacitorjs/plugins/screenreader/interfaces/Result.java +7 -0
  18. package/android/src/main/res/.gitkeep +0 -0
  19. package/dist/docs.json +222 -0
  20. package/dist/esm/definitions.d.ts +92 -0
  21. package/dist/esm/definitions.js +2 -0
  22. package/dist/esm/definitions.js.map +1 -0
  23. package/dist/esm/index.d.ts +4 -0
  24. package/dist/esm/index.js +7 -0
  25. package/dist/esm/index.js.map +1 -0
  26. package/dist/esm/web.d.ts +11 -0
  27. package/dist/esm/web.js +42 -0
  28. package/dist/esm/web.js.map +1 -0
  29. package/dist/plugin.cjs.js +56 -0
  30. package/dist/plugin.cjs.js.map +1 -0
  31. package/dist/plugin.js +59 -0
  32. package/dist/plugin.js.map +1 -0
  33. package/ios/Plugin/Classes/Events/StateChangeEvent.swift +16 -0
  34. package/ios/Plugin/Classes/Options/AnnounceOptions.swift +15 -0
  35. package/ios/Plugin/Classes/Results/IsEnabledResult.swift +16 -0
  36. package/ios/Plugin/Enums/CustomError.swift +21 -0
  37. package/ios/Plugin/Info.plist +24 -0
  38. package/ios/Plugin/Protocols/Result.swift +5 -0
  39. package/ios/Plugin/ScreenReader.swift +71 -0
  40. package/ios/Plugin/ScreenReaderPlugin.swift +86 -0
  41. package/package.json +95 -0
@@ -0,0 +1,22 @@
1
+ package io.capawesome.capacitorjs.plugins.screenreader.classes.results;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import com.getcapacitor.JSObject;
5
+ import io.capawesome.capacitorjs.plugins.screenreader.interfaces.Result;
6
+
7
+ public class IsEnabledResult implements Result {
8
+
9
+ private final boolean enabled;
10
+
11
+ public IsEnabledResult(boolean enabled) {
12
+ this.enabled = enabled;
13
+ }
14
+
15
+ @Override
16
+ @NonNull
17
+ public JSObject toJSObject() {
18
+ JSObject result = new JSObject();
19
+ result.put("enabled", enabled);
20
+ return result;
21
+ }
22
+ }
@@ -0,0 +1,5 @@
1
+ package io.capawesome.capacitorjs.plugins.screenreader.interfaces;
2
+
3
+ public interface Callback {
4
+ void error(Exception exception);
5
+ }
@@ -0,0 +1,5 @@
1
+ package io.capawesome.capacitorjs.plugins.screenreader.interfaces;
2
+
3
+ public interface EmptyCallback extends Callback {
4
+ void success();
5
+ }
@@ -0,0 +1,7 @@
1
+ package io.capawesome.capacitorjs.plugins.screenreader.interfaces;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ public interface NonEmptyResultCallback<T extends Result> extends Callback {
6
+ void success(@NonNull T result);
7
+ }
@@ -0,0 +1,7 @@
1
+ package io.capawesome.capacitorjs.plugins.screenreader.interfaces;
2
+
3
+ import com.getcapacitor.JSObject;
4
+
5
+ public interface Result {
6
+ JSObject toJSObject();
7
+ }
File without changes
package/dist/docs.json ADDED
@@ -0,0 +1,222 @@
1
+ {
2
+ "api": {
3
+ "name": "ScreenReaderPlugin",
4
+ "slug": "screenreaderplugin",
5
+ "docs": "",
6
+ "tags": [],
7
+ "methods": [
8
+ {
9
+ "name": "announce",
10
+ "signature": "(options: AnnounceOptions) => Promise<void>",
11
+ "parameters": [
12
+ {
13
+ "name": "options",
14
+ "docs": "",
15
+ "type": "AnnounceOptions"
16
+ }
17
+ ],
18
+ "returns": "Promise<void>",
19
+ "tags": [
20
+ {
21
+ "name": "since",
22
+ "text": "0.1.0"
23
+ }
24
+ ],
25
+ "docs": "Post an accessibility announcement to the active screen reader.\n\nThis does **not** perform text-to-speech. It posts an announcement that is\nread out by the screen reader (VoiceOver/TalkBack) if one is active. For\nreal text-to-speech, use the [Speech Synthesis](https://capawesome.io/docs/sdks/capacitor/speech-synthesis/)\nplugin instead.\n\nOn the web, the announcement is made through a visually hidden\n`aria-live` region, so it is only read out if the user has a screen reader\nrunning.",
26
+ "complexTypes": [
27
+ "AnnounceOptions"
28
+ ],
29
+ "slug": "announce"
30
+ },
31
+ {
32
+ "name": "isEnabled",
33
+ "signature": "() => Promise<IsEnabledResult>",
34
+ "parameters": [],
35
+ "returns": "Promise<IsEnabledResult>",
36
+ "tags": [
37
+ {
38
+ "name": "since",
39
+ "text": "0.1.0"
40
+ }
41
+ ],
42
+ "docs": "Check whether a screen reader is currently enabled.\n\nOn Android, this refers to whether touch exploration (TalkBack) is enabled.\nOn iOS, this refers to whether VoiceOver is running.\n\nOnly available on Android and iOS.",
43
+ "complexTypes": [
44
+ "IsEnabledResult"
45
+ ],
46
+ "slug": "isenabled"
47
+ },
48
+ {
49
+ "name": "addListener",
50
+ "signature": "(eventName: 'stateChange', listenerFunc: (event: StateChangeEvent) => void) => Promise<PluginListenerHandle>",
51
+ "parameters": [
52
+ {
53
+ "name": "eventName",
54
+ "docs": "",
55
+ "type": "'stateChange'"
56
+ },
57
+ {
58
+ "name": "listenerFunc",
59
+ "docs": "",
60
+ "type": "(event: StateChangeEvent) => void"
61
+ }
62
+ ],
63
+ "returns": "Promise<PluginListenerHandle>",
64
+ "tags": [
65
+ {
66
+ "name": "since",
67
+ "text": "0.1.0"
68
+ }
69
+ ],
70
+ "docs": "Listen for changes to the enabled state of the screen reader.\n\nThe device is only observed while at least one listener is attached.\n\nOnly available on Android and iOS.",
71
+ "complexTypes": [
72
+ "PluginListenerHandle",
73
+ "StateChangeEvent"
74
+ ],
75
+ "slug": "addlistenerstatechange-"
76
+ },
77
+ {
78
+ "name": "removeAllListeners",
79
+ "signature": "() => Promise<void>",
80
+ "parameters": [],
81
+ "returns": "Promise<void>",
82
+ "tags": [
83
+ {
84
+ "name": "since",
85
+ "text": "0.1.0"
86
+ }
87
+ ],
88
+ "docs": "Remove all listeners for this plugin.",
89
+ "complexTypes": [],
90
+ "slug": "removealllisteners"
91
+ }
92
+ ],
93
+ "properties": []
94
+ },
95
+ "interfaces": [
96
+ {
97
+ "name": "AnnounceOptions",
98
+ "slug": "announceoptions",
99
+ "docs": "",
100
+ "tags": [
101
+ {
102
+ "text": "0.1.0",
103
+ "name": "since"
104
+ }
105
+ ],
106
+ "methods": [],
107
+ "properties": [
108
+ {
109
+ "name": "value",
110
+ "tags": [
111
+ {
112
+ "text": "'The item was added to your cart.'",
113
+ "name": "example"
114
+ },
115
+ {
116
+ "text": "0.1.0",
117
+ "name": "since"
118
+ }
119
+ ],
120
+ "docs": "The message to announce.",
121
+ "complexTypes": [],
122
+ "type": "string"
123
+ },
124
+ {
125
+ "name": "language",
126
+ "tags": [
127
+ {
128
+ "text": "'en'",
129
+ "name": "example"
130
+ },
131
+ {
132
+ "text": "0.1.0",
133
+ "name": "since"
134
+ }
135
+ ],
136
+ "docs": "The language of the message as a BCP 47 language tag.\n\nThis helps the screen reader pronounce the message correctly.\n\nOnly available on Android.",
137
+ "complexTypes": [],
138
+ "type": "string | undefined"
139
+ }
140
+ ]
141
+ },
142
+ {
143
+ "name": "IsEnabledResult",
144
+ "slug": "isenabledresult",
145
+ "docs": "",
146
+ "tags": [
147
+ {
148
+ "text": "0.1.0",
149
+ "name": "since"
150
+ }
151
+ ],
152
+ "methods": [],
153
+ "properties": [
154
+ {
155
+ "name": "enabled",
156
+ "tags": [
157
+ {
158
+ "text": "true",
159
+ "name": "example"
160
+ },
161
+ {
162
+ "text": "0.1.0",
163
+ "name": "since"
164
+ }
165
+ ],
166
+ "docs": "Whether a screen reader is currently enabled.",
167
+ "complexTypes": [],
168
+ "type": "boolean"
169
+ }
170
+ ]
171
+ },
172
+ {
173
+ "name": "PluginListenerHandle",
174
+ "slug": "pluginlistenerhandle",
175
+ "docs": "",
176
+ "tags": [],
177
+ "methods": [],
178
+ "properties": [
179
+ {
180
+ "name": "remove",
181
+ "tags": [],
182
+ "docs": "",
183
+ "complexTypes": [],
184
+ "type": "() => Promise<void>"
185
+ }
186
+ ]
187
+ },
188
+ {
189
+ "name": "StateChangeEvent",
190
+ "slug": "statechangeevent",
191
+ "docs": "",
192
+ "tags": [
193
+ {
194
+ "text": "0.1.0",
195
+ "name": "since"
196
+ }
197
+ ],
198
+ "methods": [],
199
+ "properties": [
200
+ {
201
+ "name": "enabled",
202
+ "tags": [
203
+ {
204
+ "text": "true",
205
+ "name": "example"
206
+ },
207
+ {
208
+ "text": "0.1.0",
209
+ "name": "since"
210
+ }
211
+ ],
212
+ "docs": "Whether a screen reader is currently enabled.",
213
+ "complexTypes": [],
214
+ "type": "boolean"
215
+ }
216
+ ]
217
+ }
218
+ ],
219
+ "enums": [],
220
+ "typeAliases": [],
221
+ "pluginConfigs": []
222
+ }
@@ -0,0 +1,92 @@
1
+ import type { PluginListenerHandle } from '@capacitor/core';
2
+ export interface ScreenReaderPlugin {
3
+ /**
4
+ * Post an accessibility announcement to the active screen reader.
5
+ *
6
+ * This does **not** perform text-to-speech. It posts an announcement that is
7
+ * read out by the screen reader (VoiceOver/TalkBack) if one is active. For
8
+ * real text-to-speech, use the [Speech Synthesis](https://capawesome.io/docs/sdks/capacitor/speech-synthesis/)
9
+ * plugin instead.
10
+ *
11
+ * On the web, the announcement is made through a visually hidden
12
+ * `aria-live` region, so it is only read out if the user has a screen reader
13
+ * running.
14
+ *
15
+ * @since 0.1.0
16
+ */
17
+ announce(options: AnnounceOptions): Promise<void>;
18
+ /**
19
+ * Check whether a screen reader is currently enabled.
20
+ *
21
+ * On Android, this refers to whether touch exploration (TalkBack) is enabled.
22
+ * On iOS, this refers to whether VoiceOver is running.
23
+ *
24
+ * Only available on Android and iOS.
25
+ *
26
+ * @since 0.1.0
27
+ */
28
+ isEnabled(): Promise<IsEnabledResult>;
29
+ /**
30
+ * Listen for changes to the enabled state of the screen reader.
31
+ *
32
+ * The device is only observed while at least one listener is attached.
33
+ *
34
+ * Only available on Android and iOS.
35
+ *
36
+ * @since 0.1.0
37
+ */
38
+ addListener(eventName: 'stateChange', listenerFunc: (event: StateChangeEvent) => void): Promise<PluginListenerHandle>;
39
+ /**
40
+ * Remove all listeners for this plugin.
41
+ *
42
+ * @since 0.1.0
43
+ */
44
+ removeAllListeners(): Promise<void>;
45
+ }
46
+ /**
47
+ * @since 0.1.0
48
+ */
49
+ export interface AnnounceOptions {
50
+ /**
51
+ * The message to announce.
52
+ *
53
+ * @example 'The item was added to your cart.'
54
+ * @since 0.1.0
55
+ */
56
+ value: string;
57
+ /**
58
+ * The language of the message as a BCP 47 language tag.
59
+ *
60
+ * This helps the screen reader pronounce the message correctly.
61
+ *
62
+ * Only available on Android.
63
+ *
64
+ * @example 'en'
65
+ * @since 0.1.0
66
+ */
67
+ language?: string;
68
+ }
69
+ /**
70
+ * @since 0.1.0
71
+ */
72
+ export interface IsEnabledResult {
73
+ /**
74
+ * Whether a screen reader is currently enabled.
75
+ *
76
+ * @example true
77
+ * @since 0.1.0
78
+ */
79
+ enabled: boolean;
80
+ }
81
+ /**
82
+ * @since 0.1.0
83
+ */
84
+ export interface StateChangeEvent {
85
+ /**
86
+ * Whether a screen reader is currently enabled.
87
+ *
88
+ * @example true
89
+ * @since 0.1.0
90
+ */
91
+ enabled: boolean;
92
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["import type { PluginListenerHandle } from '@capacitor/core';\n\nexport interface ScreenReaderPlugin {\n /**\n * Post an accessibility announcement to the active screen reader.\n *\n * This does **not** perform text-to-speech. It posts an announcement that is\n * read out by the screen reader (VoiceOver/TalkBack) if one is active. For\n * real text-to-speech, use the [Speech Synthesis](https://capawesome.io/docs/sdks/capacitor/speech-synthesis/)\n * plugin instead.\n *\n * On the web, the announcement is made through a visually hidden\n * `aria-live` region, so it is only read out if the user has a screen reader\n * running.\n *\n * @since 0.1.0\n */\n announce(options: AnnounceOptions): Promise<void>;\n /**\n * Check whether a screen reader is currently enabled.\n *\n * On Android, this refers to whether touch exploration (TalkBack) is enabled.\n * On iOS, this refers to whether VoiceOver is running.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n isEnabled(): Promise<IsEnabledResult>;\n /**\n * Listen for changes to the enabled state of the screen reader.\n *\n * The device is only observed while at least one listener is attached.\n *\n * Only available on Android and iOS.\n *\n * @since 0.1.0\n */\n addListener(\n eventName: 'stateChange',\n listenerFunc: (event: StateChangeEvent) => void,\n ): Promise<PluginListenerHandle>;\n /**\n * Remove all listeners for this plugin.\n *\n * @since 0.1.0\n */\n removeAllListeners(): Promise<void>;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface AnnounceOptions {\n /**\n * The message to announce.\n *\n * @example 'The item was added to your cart.'\n * @since 0.1.0\n */\n value: string;\n /**\n * The language of the message as a BCP 47 language tag.\n *\n * This helps the screen reader pronounce the message correctly.\n *\n * Only available on Android.\n *\n * @example 'en'\n * @since 0.1.0\n */\n language?: string;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface IsEnabledResult {\n /**\n * Whether a screen reader is currently enabled.\n *\n * @example true\n * @since 0.1.0\n */\n enabled: boolean;\n}\n\n/**\n * @since 0.1.0\n */\nexport interface StateChangeEvent {\n /**\n * Whether a screen reader is currently enabled.\n *\n * @example true\n * @since 0.1.0\n */\n enabled: boolean;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ScreenReaderPlugin } from './definitions';
2
+ declare const ScreenReader: ScreenReaderPlugin;
3
+ export * from './definitions';
4
+ export { ScreenReader };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const ScreenReader = registerPlugin('ScreenReader', {
3
+ web: () => import('./web').then(m => new m.ScreenReaderWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { ScreenReader };
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,YAAY,GAAG,cAAc,CAAqB,cAAc,EAAE;IACtE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;CAC9D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { ScreenReaderPlugin } from './definitions';\n\nconst ScreenReader = registerPlugin<ScreenReaderPlugin>('ScreenReader', {\n web: () => import('./web').then(m => new m.ScreenReaderWeb()),\n});\n\nexport * from './definitions';\nexport { ScreenReader };\n"]}
@@ -0,0 +1,11 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { PluginListenerHandle } from '@capacitor/core';
3
+ import type { AnnounceOptions, IsEnabledResult, ScreenReaderPlugin } from './definitions';
4
+ export declare class ScreenReaderWeb extends WebPlugin implements ScreenReaderPlugin {
5
+ private static readonly errorValueMissing;
6
+ private liveRegion;
7
+ announce(options: AnnounceOptions): Promise<void>;
8
+ isEnabled(): Promise<IsEnabledResult>;
9
+ addListener(): Promise<PluginListenerHandle>;
10
+ private getLiveRegion;
11
+ }
@@ -0,0 +1,42 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class ScreenReaderWeb extends WebPlugin {
3
+ async announce(options) {
4
+ if (!options.value) {
5
+ throw new Error(ScreenReaderWeb.errorValueMissing);
6
+ }
7
+ const liveRegion = this.getLiveRegion();
8
+ // Clear first so that repeating the same message is announced again.
9
+ liveRegion.textContent = '';
10
+ window.setTimeout(() => {
11
+ liveRegion.textContent = options.value;
12
+ }, 100);
13
+ }
14
+ async isEnabled() {
15
+ throw this.unimplemented('Not implemented on web.');
16
+ }
17
+ async addListener() {
18
+ throw this.unimplemented('Not implemented on web.');
19
+ }
20
+ getLiveRegion() {
21
+ if (!this.liveRegion) {
22
+ const liveRegion = document.createElement('div');
23
+ liveRegion.setAttribute('aria-live', 'polite');
24
+ liveRegion.setAttribute('aria-atomic', 'true');
25
+ liveRegion.setAttribute('role', 'status');
26
+ liveRegion.style.position = 'absolute';
27
+ liveRegion.style.width = '1px';
28
+ liveRegion.style.height = '1px';
29
+ liveRegion.style.margin = '-1px';
30
+ liveRegion.style.padding = '0';
31
+ liveRegion.style.border = '0';
32
+ liveRegion.style.overflow = 'hidden';
33
+ liveRegion.style.clip = 'rect(0, 0, 0, 0)';
34
+ liveRegion.style.whiteSpace = 'nowrap';
35
+ document.body.appendChild(liveRegion);
36
+ this.liveRegion = liveRegion;
37
+ }
38
+ return this.liveRegion;
39
+ }
40
+ }
41
+ ScreenReaderWeb.errorValueMissing = 'value must be provided.';
42
+ //# sourceMappingURL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AM,GAAG,KAAK,CAAC;YAChC,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;YACjC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;YAC/B,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;YAC9B,UAAU,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACrC,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,kBAAkB,CAAC;YAC3C,UAAU,CAAC,KAAK,CAAC,UAAU,GAAG,QAAQ,CAAC;YACvC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YACtC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;;AA3CuB,iCAAiB,GAAG,yBAAyB,CAAC","sourcesContent":["import { WebPlugin } from '@capacitor/core';\nimport type { PluginListenerHandle } from '@capacitor/core';\n\nimport type {\n AnnounceOptions,\n IsEnabledResult,\n ScreenReaderPlugin,\n} from './definitions';\n\nexport class ScreenReaderWeb extends WebPlugin implements ScreenReaderPlugin {\n private static readonly errorValueMissing = 'value must be provided.';\n\n private liveRegion: HTMLElement | undefined;\n\n async announce(options: AnnounceOptions): Promise<void> {\n if (!options.value) {\n throw new Error(ScreenReaderWeb.errorValueMissing);\n }\n const liveRegion = this.getLiveRegion();\n // Clear first so that repeating the same message is announced again.\n liveRegion.textContent = '';\n window.setTimeout(() => {\n liveRegion.textContent = options.value;\n }, 100);\n }\n\n async isEnabled(): Promise<IsEnabledResult> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async addListener(): Promise<PluginListenerHandle> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n private getLiveRegion(): HTMLElement {\n if (!this.liveRegion) {\n const liveRegion = document.createElement('div');\n liveRegion.setAttribute('aria-live', 'polite');\n liveRegion.setAttribute('aria-atomic', 'true');\n liveRegion.setAttribute('role', 'status');\n liveRegion.style.position = 'absolute';\n liveRegion.style.width = '1px';\n liveRegion.style.height = '1px';\n liveRegion.style.margin = '-1px';\n liveRegion.style.padding = '0';\n liveRegion.style.border = '0';\n liveRegion.style.overflow = 'hidden';\n liveRegion.style.clip = 'rect(0, 0, 0, 0)';\n liveRegion.style.whiteSpace = 'nowrap';\n document.body.appendChild(liveRegion);\n this.liveRegion = liveRegion;\n }\n return this.liveRegion;\n }\n}\n"]}
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ const ScreenReader = core.registerPlugin('ScreenReader', {
6
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ScreenReaderWeb()),
7
+ });
8
+
9
+ class ScreenReaderWeb extends core.WebPlugin {
10
+ async announce(options) {
11
+ if (!options.value) {
12
+ throw new Error(ScreenReaderWeb.errorValueMissing);
13
+ }
14
+ const liveRegion = this.getLiveRegion();
15
+ // Clear first so that repeating the same message is announced again.
16
+ liveRegion.textContent = '';
17
+ window.setTimeout(() => {
18
+ liveRegion.textContent = options.value;
19
+ }, 100);
20
+ }
21
+ async isEnabled() {
22
+ throw this.unimplemented('Not implemented on web.');
23
+ }
24
+ async addListener() {
25
+ throw this.unimplemented('Not implemented on web.');
26
+ }
27
+ getLiveRegion() {
28
+ if (!this.liveRegion) {
29
+ const liveRegion = document.createElement('div');
30
+ liveRegion.setAttribute('aria-live', 'polite');
31
+ liveRegion.setAttribute('aria-atomic', 'true');
32
+ liveRegion.setAttribute('role', 'status');
33
+ liveRegion.style.position = 'absolute';
34
+ liveRegion.style.width = '1px';
35
+ liveRegion.style.height = '1px';
36
+ liveRegion.style.margin = '-1px';
37
+ liveRegion.style.padding = '0';
38
+ liveRegion.style.border = '0';
39
+ liveRegion.style.overflow = 'hidden';
40
+ liveRegion.style.clip = 'rect(0, 0, 0, 0)';
41
+ liveRegion.style.whiteSpace = 'nowrap';
42
+ document.body.appendChild(liveRegion);
43
+ this.liveRegion = liveRegion;
44
+ }
45
+ return this.liveRegion;
46
+ }
47
+ }
48
+ ScreenReaderWeb.errorValueMissing = 'value must be provided.';
49
+
50
+ var web = /*#__PURE__*/Object.freeze({
51
+ __proto__: null,
52
+ ScreenReaderWeb: ScreenReaderWeb
53
+ });
54
+
55
+ exports.ScreenReader = ScreenReader;
56
+ //# 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 ScreenReader = registerPlugin('ScreenReader', {\n web: () => import('./web').then(m => new m.ScreenReaderWeb()),\n});\nexport * from './definitions';\nexport { ScreenReader };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ScreenReaderWeb extends WebPlugin {\n async announce(options) {\n if (!options.value) {\n throw new Error(ScreenReaderWeb.errorValueMissing);\n }\n const liveRegion = this.getLiveRegion();\n // Clear first so that repeating the same message is announced again.\n liveRegion.textContent = '';\n window.setTimeout(() => {\n liveRegion.textContent = options.value;\n }, 100);\n }\n async isEnabled() {\n throw this.unimplemented('Not implemented on web.');\n }\n async addListener() {\n throw this.unimplemented('Not implemented on web.');\n }\n getLiveRegion() {\n if (!this.liveRegion) {\n const liveRegion = document.createElement('div');\n liveRegion.setAttribute('aria-live', 'polite');\n liveRegion.setAttribute('aria-atomic', 'true');\n liveRegion.setAttribute('role', 'status');\n liveRegion.style.position = 'absolute';\n liveRegion.style.width = '1px';\n liveRegion.style.height = '1px';\n liveRegion.style.margin = '-1px';\n liveRegion.style.padding = '0';\n liveRegion.style.border = '0';\n liveRegion.style.overflow = 'hidden';\n liveRegion.style.clip = 'rect(0, 0, 0, 0)';\n liveRegion.style.whiteSpace = 'nowrap';\n document.body.appendChild(liveRegion);\n this.liveRegion = liveRegion;\n }\n return this.liveRegion;\n }\n}\nScreenReaderWeb.errorValueMissing = 'value must be provided.';\n//# sourceMappingURL=web.js.map"],"names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AG,UAAU;AAClD,YAAY,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK;AAC1C,YAAY,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK;AAC3C,YAAY,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM;AAC5C,YAAY,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG;AAC1C,YAAY,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG;AACzC,YAAY,UAAU,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ;AAChD,YAAY,UAAU,CAAC,KAAK,CAAC,IAAI,GAAG,kBAAkB;AACtD,YAAY,UAAU,CAAC,KAAK,CAAC,UAAU,GAAG,QAAQ;AAClD,YAAY,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;AACjD,YAAY,IAAI,CAAC,UAAU,GAAG,UAAU;AACxC,QAAQ;AACR,QAAQ,OAAO,IAAI,CAAC,UAAU;AAC9B,IAAI;AACJ;AACA,eAAe,CAAC,iBAAiB,GAAG,yBAAyB;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,59 @@
1
+ var capacitorScreenReader = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const ScreenReader = core.registerPlugin('ScreenReader', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.ScreenReaderWeb()),
6
+ });
7
+
8
+ class ScreenReaderWeb extends core.WebPlugin {
9
+ async announce(options) {
10
+ if (!options.value) {
11
+ throw new Error(ScreenReaderWeb.errorValueMissing);
12
+ }
13
+ const liveRegion = this.getLiveRegion();
14
+ // Clear first so that repeating the same message is announced again.
15
+ liveRegion.textContent = '';
16
+ window.setTimeout(() => {
17
+ liveRegion.textContent = options.value;
18
+ }, 100);
19
+ }
20
+ async isEnabled() {
21
+ throw this.unimplemented('Not implemented on web.');
22
+ }
23
+ async addListener() {
24
+ throw this.unimplemented('Not implemented on web.');
25
+ }
26
+ getLiveRegion() {
27
+ if (!this.liveRegion) {
28
+ const liveRegion = document.createElement('div');
29
+ liveRegion.setAttribute('aria-live', 'polite');
30
+ liveRegion.setAttribute('aria-atomic', 'true');
31
+ liveRegion.setAttribute('role', 'status');
32
+ liveRegion.style.position = 'absolute';
33
+ liveRegion.style.width = '1px';
34
+ liveRegion.style.height = '1px';
35
+ liveRegion.style.margin = '-1px';
36
+ liveRegion.style.padding = '0';
37
+ liveRegion.style.border = '0';
38
+ liveRegion.style.overflow = 'hidden';
39
+ liveRegion.style.clip = 'rect(0, 0, 0, 0)';
40
+ liveRegion.style.whiteSpace = 'nowrap';
41
+ document.body.appendChild(liveRegion);
42
+ this.liveRegion = liveRegion;
43
+ }
44
+ return this.liveRegion;
45
+ }
46
+ }
47
+ ScreenReaderWeb.errorValueMissing = 'value must be provided.';
48
+
49
+ var web = /*#__PURE__*/Object.freeze({
50
+ __proto__: null,
51
+ ScreenReaderWeb: ScreenReaderWeb
52
+ });
53
+
54
+ exports.ScreenReader = ScreenReader;
55
+
56
+ return exports;
57
+
58
+ })({}, capacitorExports);
59
+ //# 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 ScreenReader = registerPlugin('ScreenReader', {\n web: () => import('./web').then(m => new m.ScreenReaderWeb()),\n});\nexport * from './definitions';\nexport { ScreenReader };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class ScreenReaderWeb extends WebPlugin {\n async announce(options) {\n if (!options.value) {\n throw new Error(ScreenReaderWeb.errorValueMissing);\n }\n const liveRegion = this.getLiveRegion();\n // Clear first so that repeating the same message is announced again.\n liveRegion.textContent = '';\n window.setTimeout(() => {\n liveRegion.textContent = options.value;\n }, 100);\n }\n async isEnabled() {\n throw this.unimplemented('Not implemented on web.');\n }\n async addListener() {\n throw this.unimplemented('Not implemented on web.');\n }\n getLiveRegion() {\n if (!this.liveRegion) {\n const liveRegion = document.createElement('div');\n liveRegion.setAttribute('aria-live', 'polite');\n liveRegion.setAttribute('aria-atomic', 'true');\n liveRegion.setAttribute('role', 'status');\n liveRegion.style.position = 'absolute';\n liveRegion.style.width = '1px';\n liveRegion.style.height = '1px';\n liveRegion.style.margin = '-1px';\n liveRegion.style.padding = '0';\n liveRegion.style.border = '0';\n liveRegion.style.overflow = 'hidden';\n liveRegion.style.clip = 'rect(0, 0, 0, 0)';\n liveRegion.style.whiteSpace = 'nowrap';\n document.body.appendChild(liveRegion);\n this.liveRegion = liveRegion;\n }\n return this.liveRegion;\n }\n}\nScreenReaderWeb.errorValueMissing = 'value must be provided.';\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,YAAY,GAAGA,mBAAc,CAAC,cAAc,EAAE;IACpD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACjE,CAAC;;ICFM,MAAM,eAAe,SAASC,cAAS,CAAC;IAC/C,IAAI,MAAM,QAAQ,CAAC,OAAO,EAAE;IAC5B,QAAQ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;IAC5B,YAAY,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,iBAAiB,CAAC;IAC9D,QAAQ;IACR,QAAQ,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE;IAC/C;IACA,QAAQ,UAAU,CAAC,WAAW,GAAG,EAAE;IACnC,QAAQ,MAAM,CAAC,UAAU,CAAC,MAAM;IAChC,YAAY,UAAU,CAAC,WAAW,GAAG,OAAO,CAAC,KAAK;IAClD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI;IACJ,IAAI,MAAM,SAAS,GAAG;IACtB,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D,IAAI;IACJ,IAAI,MAAM,WAAW,GAAG;IACxB,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init(enabled: Bool) {
8
+ self.enabled = enabled
9
+ }
10
+
11
+ @objc public func toJSObject() -> AnyObject {
12
+ var result = JSObject()
13
+ result["enabled"] = enabled
14
+ return result as AnyObject
15
+ }
16
+ }
@@ -0,0 +1,15 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ @objc public class AnnounceOptions: NSObject {
5
+ let value: String
6
+ let language: String?
7
+
8
+ init(_ call: CAPPluginCall) throws {
9
+ guard let value = call.getString("value") else {
10
+ throw CustomError.valueMissing
11
+ }
12
+ self.value = value
13
+ self.language = call.getString("language")
14
+ }
15
+ }
@@ -0,0 +1,16 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ @objc public class IsEnabledResult: NSObject, Result {
5
+ let enabled: Bool
6
+
7
+ init(enabled: Bool) {
8
+ self.enabled = enabled
9
+ }
10
+
11
+ @objc public func toJSObject() -> AnyObject {
12
+ var result = JSObject()
13
+ result["enabled"] = enabled
14
+ return result as AnyObject
15
+ }
16
+ }