@bubble-labs/capacitor-widgetsbridge-plugin 7.0.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/CapacitorWidgetsbridgePlugin.podspec +17 -0
- package/README.md +152 -0
- package/dist/docs.json +378 -0
- package/dist/esm/definitions.d.ts +84 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/plugin.cjs.js +10 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +13 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/WidgetsBridgePlugin.h +10 -0
- package/ios/Plugin/WidgetsBridgePlugin.m +13 -0
- package/ios/Plugin/WidgetsBridgePlugin.swift +121 -0
- package/package.json +74 -0
|
@@ -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 = 'CapacitorWidgetsbridgePlugin'
|
|
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 = '12.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.swift_version = '5.1'
|
|
17
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# capacitor-widgetsbridge-plugin
|
|
2
|
+
|
|
3
|
+
Capacitor plugin to interact with ios widgetkit
|
|
4
|
+
|
|
5
|
+
## Demo
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install capacitor-widgetsbridge-plugin
|
|
13
|
+
npx cap sync
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## API
|
|
17
|
+
|
|
18
|
+
<docgen-index>
|
|
19
|
+
|
|
20
|
+
* [`getItem(...)`](#getitem)
|
|
21
|
+
* [`setItem(...)`](#setitem)
|
|
22
|
+
* [`removeItem(...)`](#removeitem)
|
|
23
|
+
* [`reloadAllTimelines()`](#reloadalltimelines)
|
|
24
|
+
* [`reloadTimelines(...)`](#reloadtimelines)
|
|
25
|
+
* [`getCurrentConfigurations()`](#getcurrentconfigurations)
|
|
26
|
+
* [Interfaces](#interfaces)
|
|
27
|
+
|
|
28
|
+
</docgen-index>
|
|
29
|
+
|
|
30
|
+
<docgen-api>
|
|
31
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
32
|
+
|
|
33
|
+
### getItem(...)
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
getItem(options: UserDefaultsOptions) => Promise<DataResults<any>>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Return the value from user’s defaults database associated with the specified key
|
|
40
|
+
|
|
41
|
+
| Param | Type |
|
|
42
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
43
|
+
| **`options`** | <code><a href="#userdefaultsoptions">UserDefaultsOptions</a></code> |
|
|
44
|
+
|
|
45
|
+
**Returns:** <code>Promise<<a href="#dataresults">DataResults</a><any>></code>
|
|
46
|
+
|
|
47
|
+
--------------------
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### setItem(...)
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
setItem(options: UserDefaultsOptions) => Promise<DataResults<boolean>>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Set the value to user’s defaults database associated with the specified key
|
|
57
|
+
|
|
58
|
+
| Param | Type |
|
|
59
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
60
|
+
| **`options`** | <code><a href="#userdefaultsoptions">UserDefaultsOptions</a></code> |
|
|
61
|
+
|
|
62
|
+
**Returns:** <code>Promise<<a href="#dataresults">DataResults</a><boolean>></code>
|
|
63
|
+
|
|
64
|
+
--------------------
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### removeItem(...)
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
removeItem(options: UserDefaultsOptions) => Promise<DataResults<boolean>>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Remove the value from user’s defaults database associated with the specified key
|
|
74
|
+
|
|
75
|
+
| Param | Type |
|
|
76
|
+
| ------------- | ------------------------------------------------------------------- |
|
|
77
|
+
| **`options`** | <code><a href="#userdefaultsoptions">UserDefaultsOptions</a></code> |
|
|
78
|
+
|
|
79
|
+
**Returns:** <code>Promise<<a href="#dataresults">DataResults</a><boolean>></code>
|
|
80
|
+
|
|
81
|
+
--------------------
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### reloadAllTimelines()
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
reloadAllTimelines() => Promise<DataResults<boolean>>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Reloads the timelines for all configured widgets belonging to the containing app
|
|
91
|
+
|
|
92
|
+
**Returns:** <code>Promise<<a href="#dataresults">DataResults</a><boolean>></code>
|
|
93
|
+
|
|
94
|
+
--------------------
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### reloadTimelines(...)
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
reloadTimelines(options: TimelinesOptions) => Promise<DataResults<boolean>>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Reloads the timelines for all widgets of a particular kind
|
|
104
|
+
|
|
105
|
+
| Param | Type |
|
|
106
|
+
| ------------- | ------------------------------------------------------------- |
|
|
107
|
+
| **`options`** | <code><a href="#timelinesoptions">TimelinesOptions</a></code> |
|
|
108
|
+
|
|
109
|
+
**Returns:** <code>Promise<<a href="#dataresults">DataResults</a><boolean>></code>
|
|
110
|
+
|
|
111
|
+
--------------------
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
### getCurrentConfigurations()
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
getCurrentConfigurations() => Promise<DataResults<any>>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Get current widget configurations
|
|
121
|
+
|
|
122
|
+
**Returns:** <code>Promise<<a href="#dataresults">DataResults</a><any>></code>
|
|
123
|
+
|
|
124
|
+
--------------------
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
### Interfaces
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
#### DataResults
|
|
131
|
+
|
|
132
|
+
| Prop | Type | Description |
|
|
133
|
+
| ------------- | -------------- | --------------------------------------- |
|
|
134
|
+
| **`results`** | <code>T</code> | Holds response results from native code |
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
#### UserDefaultsOptions
|
|
138
|
+
|
|
139
|
+
| Prop | Type | Description |
|
|
140
|
+
| ----------- | ------------------- | --------------------------------------------------------------------- |
|
|
141
|
+
| **`key`** | <code>string</code> | The key whose value to retrieve from storage. |
|
|
142
|
+
| **`group`** | <code>string</code> | User defaults database name which holds and organizes key/value pairs |
|
|
143
|
+
| **`value`** | <code>string</code> | The value to set in storage with the associated key |
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
#### TimelinesOptions
|
|
147
|
+
|
|
148
|
+
| Prop | Type | Description |
|
|
149
|
+
| ------------ | ------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
150
|
+
| **`ofKind`** | <code>string</code> | A string that identifies the widget and matches the value you used when you created the widget’s configuration |
|
|
151
|
+
|
|
152
|
+
</docgen-api>
|
package/dist/docs.json
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api": {
|
|
3
|
+
"name": "WidgetsBridgePlugin",
|
|
4
|
+
"slug": "widgetsbridgeplugin",
|
|
5
|
+
"docs": "",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"methods": [
|
|
8
|
+
{
|
|
9
|
+
"name": "getItem",
|
|
10
|
+
"signature": "(options: UserDefaultsOptions) => Promise<DataResults<any>>",
|
|
11
|
+
"parameters": [
|
|
12
|
+
{
|
|
13
|
+
"name": "options",
|
|
14
|
+
"docs": "",
|
|
15
|
+
"type": "UserDefaultsOptions"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"returns": "Promise<DataResults<any>>",
|
|
19
|
+
"tags": [
|
|
20
|
+
{
|
|
21
|
+
"name": "param",
|
|
22
|
+
"text": [
|
|
23
|
+
{
|
|
24
|
+
"text": "options",
|
|
25
|
+
"kind": "text"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "since",
|
|
31
|
+
"text": [
|
|
32
|
+
{
|
|
33
|
+
"text": "0.0.1",
|
|
34
|
+
"kind": "text"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "returns",
|
|
40
|
+
"text": [
|
|
41
|
+
{
|
|
42
|
+
"text": "Promise represents the value",
|
|
43
|
+
"kind": "text"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"docs": "Return the value from user’s defaults database associated with the specified key",
|
|
49
|
+
"complexTypes": [
|
|
50
|
+
"DataResults",
|
|
51
|
+
"UserDefaultsOptions"
|
|
52
|
+
],
|
|
53
|
+
"slug": "getitem"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "setItem",
|
|
57
|
+
"signature": "(options: UserDefaultsOptions) => Promise<DataResults<boolean>>",
|
|
58
|
+
"parameters": [
|
|
59
|
+
{
|
|
60
|
+
"name": "options",
|
|
61
|
+
"docs": "",
|
|
62
|
+
"type": "UserDefaultsOptions"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"returns": "Promise<DataResults<boolean>>",
|
|
66
|
+
"tags": [
|
|
67
|
+
{
|
|
68
|
+
"name": "param",
|
|
69
|
+
"text": [
|
|
70
|
+
{
|
|
71
|
+
"text": "options",
|
|
72
|
+
"kind": "text"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "since",
|
|
78
|
+
"text": [
|
|
79
|
+
{
|
|
80
|
+
"text": "0.0.1",
|
|
81
|
+
"kind": "text"
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "returns",
|
|
87
|
+
"text": [
|
|
88
|
+
{
|
|
89
|
+
"text": "Promise represents the operation results",
|
|
90
|
+
"kind": "text"
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"docs": "Set the value to user’s defaults database associated with the specified key",
|
|
96
|
+
"complexTypes": [
|
|
97
|
+
"DataResults",
|
|
98
|
+
"UserDefaultsOptions"
|
|
99
|
+
],
|
|
100
|
+
"slug": "setitem"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "removeItem",
|
|
104
|
+
"signature": "(options: UserDefaultsOptions) => Promise<DataResults<boolean>>",
|
|
105
|
+
"parameters": [
|
|
106
|
+
{
|
|
107
|
+
"name": "options",
|
|
108
|
+
"docs": "",
|
|
109
|
+
"type": "UserDefaultsOptions"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"returns": "Promise<DataResults<boolean>>",
|
|
113
|
+
"tags": [
|
|
114
|
+
{
|
|
115
|
+
"name": "param",
|
|
116
|
+
"text": [
|
|
117
|
+
{
|
|
118
|
+
"text": "options",
|
|
119
|
+
"kind": "text"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "since",
|
|
125
|
+
"text": [
|
|
126
|
+
{
|
|
127
|
+
"text": "0.0.1",
|
|
128
|
+
"kind": "text"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "returns",
|
|
134
|
+
"text": [
|
|
135
|
+
{
|
|
136
|
+
"text": "Promise represents the operation results",
|
|
137
|
+
"kind": "text"
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"docs": "Remove the value from user’s defaults database associated with the specified key",
|
|
143
|
+
"complexTypes": [
|
|
144
|
+
"DataResults",
|
|
145
|
+
"UserDefaultsOptions"
|
|
146
|
+
],
|
|
147
|
+
"slug": "removeitem"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "reloadAllTimelines",
|
|
151
|
+
"signature": "() => Promise<DataResults<boolean>>",
|
|
152
|
+
"parameters": [],
|
|
153
|
+
"returns": "Promise<DataResults<boolean>>",
|
|
154
|
+
"tags": [
|
|
155
|
+
{
|
|
156
|
+
"name": "since",
|
|
157
|
+
"text": [
|
|
158
|
+
{
|
|
159
|
+
"text": "0.0.1",
|
|
160
|
+
"kind": "text"
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "returns",
|
|
166
|
+
"text": [
|
|
167
|
+
{
|
|
168
|
+
"text": "Promise represents the operation results",
|
|
169
|
+
"kind": "text"
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"docs": "Reloads the timelines for all configured widgets belonging to the containing app",
|
|
175
|
+
"complexTypes": [
|
|
176
|
+
"DataResults"
|
|
177
|
+
],
|
|
178
|
+
"slug": "reloadalltimelines"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "reloadTimelines",
|
|
182
|
+
"signature": "(options: TimelinesOptions) => Promise<DataResults<boolean>>",
|
|
183
|
+
"parameters": [
|
|
184
|
+
{
|
|
185
|
+
"name": "options",
|
|
186
|
+
"docs": "",
|
|
187
|
+
"type": "TimelinesOptions"
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"returns": "Promise<DataResults<boolean>>",
|
|
191
|
+
"tags": [
|
|
192
|
+
{
|
|
193
|
+
"name": "param",
|
|
194
|
+
"text": [
|
|
195
|
+
{
|
|
196
|
+
"text": "options",
|
|
197
|
+
"kind": "text"
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"name": "since",
|
|
203
|
+
"text": [
|
|
204
|
+
{
|
|
205
|
+
"text": "0.0.1",
|
|
206
|
+
"kind": "text"
|
|
207
|
+
}
|
|
208
|
+
]
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "returns",
|
|
212
|
+
"text": [
|
|
213
|
+
{
|
|
214
|
+
"text": "Promise represents the operation results",
|
|
215
|
+
"kind": "text"
|
|
216
|
+
}
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
"docs": "Reloads the timelines for all widgets of a particular kind",
|
|
221
|
+
"complexTypes": [
|
|
222
|
+
"DataResults",
|
|
223
|
+
"TimelinesOptions"
|
|
224
|
+
],
|
|
225
|
+
"slug": "reloadtimelines"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"name": "getCurrentConfigurations",
|
|
229
|
+
"signature": "() => Promise<DataResults<any>>",
|
|
230
|
+
"parameters": [],
|
|
231
|
+
"returns": "Promise<DataResults<any>>",
|
|
232
|
+
"tags": [
|
|
233
|
+
{
|
|
234
|
+
"name": "since",
|
|
235
|
+
"text": [
|
|
236
|
+
{
|
|
237
|
+
"text": "0.0.1",
|
|
238
|
+
"kind": "text"
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "returns",
|
|
244
|
+
"text": [
|
|
245
|
+
{
|
|
246
|
+
"text": "Promise represents the operation results",
|
|
247
|
+
"kind": "text"
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
"docs": "Get current widget configurations",
|
|
253
|
+
"complexTypes": [
|
|
254
|
+
"DataResults"
|
|
255
|
+
],
|
|
256
|
+
"slug": "getcurrentconfigurations"
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
"properties": []
|
|
260
|
+
},
|
|
261
|
+
"interfaces": [
|
|
262
|
+
{
|
|
263
|
+
"name": "DataResults",
|
|
264
|
+
"slug": "dataresults",
|
|
265
|
+
"docs": "",
|
|
266
|
+
"tags": [],
|
|
267
|
+
"methods": [],
|
|
268
|
+
"properties": [
|
|
269
|
+
{
|
|
270
|
+
"name": "results",
|
|
271
|
+
"tags": [
|
|
272
|
+
{
|
|
273
|
+
"text": [
|
|
274
|
+
{
|
|
275
|
+
"text": "0.0.1",
|
|
276
|
+
"kind": "text"
|
|
277
|
+
}
|
|
278
|
+
],
|
|
279
|
+
"name": "since"
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
"docs": "Holds response results from native code",
|
|
283
|
+
"complexTypes": [
|
|
284
|
+
"T"
|
|
285
|
+
],
|
|
286
|
+
"type": "T"
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"name": "UserDefaultsOptions",
|
|
292
|
+
"slug": "userdefaultsoptions",
|
|
293
|
+
"docs": "",
|
|
294
|
+
"tags": [],
|
|
295
|
+
"methods": [],
|
|
296
|
+
"properties": [
|
|
297
|
+
{
|
|
298
|
+
"name": "key",
|
|
299
|
+
"tags": [
|
|
300
|
+
{
|
|
301
|
+
"text": [
|
|
302
|
+
{
|
|
303
|
+
"text": "0.0.1",
|
|
304
|
+
"kind": "text"
|
|
305
|
+
}
|
|
306
|
+
],
|
|
307
|
+
"name": "since"
|
|
308
|
+
}
|
|
309
|
+
],
|
|
310
|
+
"docs": "The key whose value to retrieve from storage.",
|
|
311
|
+
"complexTypes": [],
|
|
312
|
+
"type": "string"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"name": "group",
|
|
316
|
+
"tags": [
|
|
317
|
+
{
|
|
318
|
+
"text": [
|
|
319
|
+
{
|
|
320
|
+
"text": "0.0.1",
|
|
321
|
+
"kind": "text"
|
|
322
|
+
}
|
|
323
|
+
],
|
|
324
|
+
"name": "since"
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
"docs": "User defaults database name which holds and organizes key/value pairs",
|
|
328
|
+
"complexTypes": [],
|
|
329
|
+
"type": "string"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"name": "value",
|
|
333
|
+
"tags": [
|
|
334
|
+
{
|
|
335
|
+
"text": [
|
|
336
|
+
{
|
|
337
|
+
"text": "0.0.1",
|
|
338
|
+
"kind": "text"
|
|
339
|
+
}
|
|
340
|
+
],
|
|
341
|
+
"name": "since"
|
|
342
|
+
}
|
|
343
|
+
],
|
|
344
|
+
"docs": "The value to set in storage with the associated key",
|
|
345
|
+
"complexTypes": [],
|
|
346
|
+
"type": "string | undefined"
|
|
347
|
+
}
|
|
348
|
+
]
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"name": "TimelinesOptions",
|
|
352
|
+
"slug": "timelinesoptions",
|
|
353
|
+
"docs": "",
|
|
354
|
+
"tags": [],
|
|
355
|
+
"methods": [],
|
|
356
|
+
"properties": [
|
|
357
|
+
{
|
|
358
|
+
"name": "ofKind",
|
|
359
|
+
"tags": [
|
|
360
|
+
{
|
|
361
|
+
"text": [
|
|
362
|
+
{
|
|
363
|
+
"text": "0.0.1",
|
|
364
|
+
"kind": "text"
|
|
365
|
+
}
|
|
366
|
+
],
|
|
367
|
+
"name": "since"
|
|
368
|
+
}
|
|
369
|
+
],
|
|
370
|
+
"docs": "A string that identifies the widget and matches the value you used when you created the widget’s configuration",
|
|
371
|
+
"complexTypes": [],
|
|
372
|
+
"type": "string"
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
],
|
|
377
|
+
"enums": []
|
|
378
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export interface WidgetsBridgePlugin {
|
|
2
|
+
/**
|
|
3
|
+
* Return the value from user’s defaults database associated with the specified key
|
|
4
|
+
*
|
|
5
|
+
* @param {UserDefaultsOptions} options
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
* @returns {Promise<DataResults<any>>} Promise represents the value
|
|
8
|
+
*/
|
|
9
|
+
getItem(options: UserDefaultsOptions): Promise<DataResults<any>>;
|
|
10
|
+
/**
|
|
11
|
+
* Set the value to user’s defaults database associated with the specified key
|
|
12
|
+
*
|
|
13
|
+
* @param {UserDefaultsOptions} options
|
|
14
|
+
* @since 0.0.1
|
|
15
|
+
* @returns {Promise<DataResults<boolean>>} Promise represents the operation results
|
|
16
|
+
*/
|
|
17
|
+
setItem(options: UserDefaultsOptions): Promise<DataResults<boolean>>;
|
|
18
|
+
/**
|
|
19
|
+
* Remove the value from user’s defaults database associated with the specified key
|
|
20
|
+
*
|
|
21
|
+
* @param {UserDefaultsOptions} options
|
|
22
|
+
* @since 0.0.1
|
|
23
|
+
* @returns {Promise<DataResults<boolean>>} Promise represents the operation results
|
|
24
|
+
*/
|
|
25
|
+
removeItem(options: UserDefaultsOptions): Promise<DataResults<boolean>>;
|
|
26
|
+
/**
|
|
27
|
+
* Reloads the timelines for all configured widgets belonging to the containing app
|
|
28
|
+
*
|
|
29
|
+
* @since 0.0.1
|
|
30
|
+
* @returns {Promise<DataResults<boolean>>} Promise represents the operation results
|
|
31
|
+
*/
|
|
32
|
+
reloadAllTimelines(): Promise<DataResults<boolean>>;
|
|
33
|
+
/**
|
|
34
|
+
* Reloads the timelines for all widgets of a particular kind
|
|
35
|
+
*
|
|
36
|
+
* @param {TimelinesOptions} options
|
|
37
|
+
* @since 0.0.1
|
|
38
|
+
* @returns {Promise<DataResults<boolean>>} Promise represents the operation results
|
|
39
|
+
*/
|
|
40
|
+
reloadTimelines(options: TimelinesOptions): Promise<DataResults<boolean>>;
|
|
41
|
+
/**
|
|
42
|
+
* Get current widget configurations
|
|
43
|
+
*
|
|
44
|
+
* @since 0.0.1
|
|
45
|
+
* @returns {Promise<DataResults<any>>} Promise represents the operation results
|
|
46
|
+
*/
|
|
47
|
+
getCurrentConfigurations(): Promise<DataResults<any>>;
|
|
48
|
+
}
|
|
49
|
+
export interface UserDefaultsOptions {
|
|
50
|
+
/**
|
|
51
|
+
* The key whose value to retrieve from storage.
|
|
52
|
+
*
|
|
53
|
+
* @since 0.0.1
|
|
54
|
+
*/
|
|
55
|
+
key: string;
|
|
56
|
+
/**
|
|
57
|
+
* User defaults database name which holds and organizes key/value pairs
|
|
58
|
+
*
|
|
59
|
+
* @since 0.0.1
|
|
60
|
+
*/
|
|
61
|
+
group: string;
|
|
62
|
+
/**
|
|
63
|
+
* The value to set in storage with the associated key
|
|
64
|
+
*
|
|
65
|
+
* @since 0.0.1
|
|
66
|
+
*/
|
|
67
|
+
value?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface TimelinesOptions {
|
|
70
|
+
/**
|
|
71
|
+
* A string that identifies the widget and matches the value you used when you created the widget’s configuration
|
|
72
|
+
*
|
|
73
|
+
* @since 0.0.1
|
|
74
|
+
*/
|
|
75
|
+
ofKind: string;
|
|
76
|
+
}
|
|
77
|
+
export interface DataResults<T> {
|
|
78
|
+
/**
|
|
79
|
+
* Holds response results from native code
|
|
80
|
+
*
|
|
81
|
+
* @since 0.0.1
|
|
82
|
+
*/
|
|
83
|
+
results: T;
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
|
|
@@ -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,mBAAmB,GAAG,cAAc,CAAsB,qBAAqB,CAAC,CAAC;AAEvF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const WidgetsBridgePlugin = core.registerPlugin('WidgetsBridgePlugin');
|
|
8
|
+
|
|
9
|
+
exports.WidgetsBridgePlugin = WidgetsBridgePlugin;
|
|
10
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst WidgetsBridgePlugin = registerPlugin('WidgetsBridgePlugin');\nexport * from './definitions';\nexport { WidgetsBridgePlugin };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;;;;AACK,MAAC,mBAAmB,GAAGA,mBAAc,CAAC,qBAAqB;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var capacitorWidgetsBridgePlugin = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const WidgetsBridgePlugin = core.registerPlugin('WidgetsBridgePlugin');
|
|
5
|
+
|
|
6
|
+
exports.WidgetsBridgePlugin = WidgetsBridgePlugin;
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
|
+
|
|
10
|
+
return exports;
|
|
11
|
+
|
|
12
|
+
}({}, capacitorExports));
|
|
13
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst WidgetsBridgePlugin = registerPlugin('WidgetsBridgePlugin');\nexport * from './definitions';\nexport { WidgetsBridgePlugin };\n//# sourceMappingURL=index.js.map"],"names":["registerPlugin"],"mappings":";;;AACK,OAAC,mBAAmB,GAAGA,mBAAc,CAAC,qBAAqB;;;;;;;;;;;;"}
|
|
@@ -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>
|
|
@@ -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,13 @@
|
|
|
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(WidgetsBridgePlugin, "WidgetsBridgePlugin",
|
|
7
|
+
CAP_PLUGIN_METHOD(getItem, CAPPluginReturnPromise);
|
|
8
|
+
CAP_PLUGIN_METHOD(setItem, CAPPluginReturnPromise);
|
|
9
|
+
CAP_PLUGIN_METHOD(removeItem, CAPPluginReturnPromise);
|
|
10
|
+
CAP_PLUGIN_METHOD(reloadAllTimelines, CAPPluginReturnPromise);
|
|
11
|
+
CAP_PLUGIN_METHOD(reloadTimelines, CAPPluginReturnPromise);
|
|
12
|
+
CAP_PLUGIN_METHOD(getCurrentConfigurations, CAPPluginReturnPromise);
|
|
13
|
+
)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import Capacitor
|
|
3
|
+
import WidgetKit
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@objc(WidgetsBridgePlugin)
|
|
7
|
+
public class WidgetsBridgePlugin: CAPPlugin {
|
|
8
|
+
|
|
9
|
+
@objc func setItem(_ call: CAPPluginCall) {
|
|
10
|
+
guard let key = call.getString("key") else {
|
|
11
|
+
call.reject("Key must be provided")
|
|
12
|
+
return
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
guard let value = call.getString("value") else {
|
|
16
|
+
call.reject("Value must be provided")
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
guard let group = call.getString("group") else {
|
|
21
|
+
call.reject("Group must be provided")
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if let userDefaults = UserDefaults.init(suiteName: group) {
|
|
26
|
+
userDefaults.set(value, forKey: key)
|
|
27
|
+
call.resolve(["results": true])
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
call.reject("Could not set item")
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@objc func getItem(_ call: CAPPluginCall) {
|
|
35
|
+
guard let key = call.getString("key") else {
|
|
36
|
+
call.reject("Key must be provided")
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
guard let group = call.getString("group") else {
|
|
41
|
+
call.reject("Group must be provided")
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if let userDefaults = UserDefaults.init(suiteName: group) {
|
|
46
|
+
let value = userDefaults.value(forKey: key)
|
|
47
|
+
if value != nil {
|
|
48
|
+
call.resolve(["results": value!])
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
call.reject("Could not get item")
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@objc func removeItem(_ call: CAPPluginCall) {
|
|
57
|
+
guard let key = call.getString("key") else {
|
|
58
|
+
call.reject("Key must be provided")
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
guard let group = call.getString("group") else {
|
|
63
|
+
call.reject("Group must be provided")
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if let userDefaults = UserDefaults.init(suiteName: group) {
|
|
68
|
+
userDefaults.removeObject(forKey: key)
|
|
69
|
+
call.resolve(["results": true])
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
call.reject("Could not remove item")
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@objc func reloadAllTimelines(_ call: CAPPluginCall) {
|
|
77
|
+
if #available(iOS 14.0, *) {
|
|
78
|
+
WidgetCenter.shared.reloadAllTimelines()
|
|
79
|
+
call.resolve(["results": true])
|
|
80
|
+
} else {
|
|
81
|
+
call.unavailable("Not available in iOS 13 or earlier.")
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@objc func reloadTimelines(_ call: CAPPluginCall) {
|
|
86
|
+
guard let ofKind = call.getString("ofKind") else {
|
|
87
|
+
call.reject("ofKind must be provided")
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
if #available(iOS 14.0, *) {
|
|
91
|
+
WidgetCenter.shared.reloadTimelines(ofKind: ofKind)
|
|
92
|
+
call.resolve(["results": true])
|
|
93
|
+
} else {
|
|
94
|
+
call.unavailable("Not available in iOS 13 or earlier.")
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@objc func getCurrentConfigurations(_ call: CAPPluginCall) {
|
|
99
|
+
if #available(iOS 14.0, *) {
|
|
100
|
+
WidgetCenter.shared.getCurrentConfigurations { result in
|
|
101
|
+
guard case .success(let widgets) = result else {
|
|
102
|
+
call.reject("Could not get current configurations")
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
call.resolve(["results": widgets.map { widget in
|
|
107
|
+
[
|
|
108
|
+
"family": widget.family.description,
|
|
109
|
+
"kind": widget.kind,
|
|
110
|
+
"configuration": [
|
|
111
|
+
"description": widget.configuration?.description
|
|
112
|
+
]
|
|
113
|
+
]
|
|
114
|
+
}])
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
call.unavailable("Not available in iOS 13 or earlier.")
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bubble-labs/capacitor-widgetsbridge-plugin",
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"description": "Capacitor plugin to interact with iOS WidgetKit",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "dist/plugin.cjs.js",
|
|
9
|
+
"module": "dist/esm/index.js",
|
|
10
|
+
"types": "dist/esm/index.d.ts",
|
|
11
|
+
"unpkg": "dist/plugin.js",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/",
|
|
14
|
+
"ios/Plugin/",
|
|
15
|
+
"CapacitorWidgetsbridgePlugin.podspec"
|
|
16
|
+
],
|
|
17
|
+
"author": "Dale Myszewski, Mustafa (0xn33t)",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/greenygh0st/capacitor-widgetsbridge-plugin.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/greenygh0st/capacitor-widgetsbridge-plugin/issues"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"capacitor",
|
|
28
|
+
"plugin",
|
|
29
|
+
"native"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"verify": "npm run verify:ios",
|
|
33
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
|
|
34
|
+
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
35
|
+
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- autocorrect --format",
|
|
36
|
+
"eslint": "eslint . --ext ts",
|
|
37
|
+
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
38
|
+
"swiftlint": "node-swiftlint",
|
|
39
|
+
"docgen": "docgen --api WidgetsBridgePlugin --output-readme README.md --output-json dist/docs.json",
|
|
40
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
|
|
41
|
+
"clean": "rimraf ./dist",
|
|
42
|
+
"watch": "tsc --watch",
|
|
43
|
+
"prepublishOnly": "npm run build"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@capacitor/cli": "^7.0.1",
|
|
47
|
+
"@capacitor/core": "^7.0.1",
|
|
48
|
+
"@capacitor/docgen": "^0.0.10",
|
|
49
|
+
"@capacitor/ios": "^7.0.1",
|
|
50
|
+
"@ionic/eslint-config": "^0.3.0",
|
|
51
|
+
"@ionic/prettier-config": "^1.0.1",
|
|
52
|
+
"@ionic/swiftlint-config": "^1.1.2",
|
|
53
|
+
"eslint": "^7.11.0",
|
|
54
|
+
"prettier": "~2.2.0",
|
|
55
|
+
"prettier-plugin-java": "~1.0.0",
|
|
56
|
+
"rimraf": "^3.0.2",
|
|
57
|
+
"rollup": "^2.32.0",
|
|
58
|
+
"swiftlint": "^1.0.1",
|
|
59
|
+
"typescript": "~5.0.2"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@capacitor/core": "^7.0.1"
|
|
63
|
+
},
|
|
64
|
+
"prettier": "@ionic/prettier-config",
|
|
65
|
+
"swiftlint": "@ionic/swiftlint-config",
|
|
66
|
+
"eslintConfig": {
|
|
67
|
+
"extends": "@ionic/eslint-config/recommended"
|
|
68
|
+
},
|
|
69
|
+
"capacitor": {
|
|
70
|
+
"ios": {
|
|
71
|
+
"src": "ios"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|