react-native-notify-kit 10.8.0 → 10.9.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.
Files changed (79) hide show
  1. package/README.md +34 -17
  2. package/android/build.gradle +50 -4
  3. package/android/src/main/AndroidManifest.xml +4 -0
  4. package/android/src/main/java/app/notifee/core/ForegroundService.java +1002 -58
  5. package/android/src/main/java/app/notifee/core/ForegroundServiceRunLimitReceiver.java +15 -0
  6. package/android/src/main/java/app/notifee/core/ForegroundServiceRunLimitScheduler.java +461 -0
  7. package/android/src/main/java/app/notifee/core/NotificationManager.java +6 -0
  8. package/android/src/main/java/app/notifee/core/event/NotificationEvent.java +6 -0
  9. package/android/src/main/java/app/notifee/core/model/NotificationAndroidModel.java +29 -0
  10. package/android/src/main/kotlin/io/invertase/notifee/NotifeeEventSubscriber.kt +3 -0
  11. package/android/src/test/java/app/notifee/core/ForegroundServiceRunLimitTest.java +2357 -0
  12. package/android/src/test/java/app/notifee/core/ForegroundServiceTest.java +3093 -21
  13. package/android/src/test/java/app/notifee/core/ShadowServiceCompatibilityTest.java +170 -0
  14. package/android/src/test/resources/robolectric.properties +4 -0
  15. package/cli/dist/cli.js +0 -1
  16. package/cli/dist/commands/initNse.js +1 -2
  17. package/cli/dist/lib/detectProject.js +1 -2
  18. package/cli/dist/lib/initNseCore.js +0 -1
  19. package/cli/dist/lib/logger.js +0 -1
  20. package/cli/dist/lib/patchPodfile.js +0 -1
  21. package/cli/dist/lib/patchXcodeProject.js +22 -3
  22. package/cli/dist/lib/writeTemplates.js +0 -1
  23. package/cli/dist/lib/xcode.js +6 -0
  24. package/cli/dist/templates/NotificationService.swift.tmpl +74 -6
  25. package/cli/package.json +1 -0
  26. package/cli/vendor/xcode/AUTHORS +6 -0
  27. package/cli/vendor/xcode/LICENSE +202 -0
  28. package/cli/vendor/xcode/NOTICE +5 -0
  29. package/cli/vendor/xcode/README.md +32 -0
  30. package/cli/vendor/xcode/UPSTREAM-SHA256.json +12 -0
  31. package/cli/vendor/xcode/index.js +18 -0
  32. package/cli/vendor/xcode/lib/parseJob.js +32 -0
  33. package/cli/vendor/xcode/lib/parser/pbxproj.js +1904 -0
  34. package/cli/vendor/xcode/lib/parser/pbxproj.pegjs +280 -0
  35. package/cli/vendor/xcode/lib/pbxFile.js +233 -0
  36. package/cli/vendor/xcode/lib/pbxProject.js +2205 -0
  37. package/cli/vendor/xcode/lib/pbxWriter.js +309 -0
  38. package/dist/NotifeeNativeModule.web.d.ts +2 -2
  39. package/dist/types/Notification.d.ts +36 -1
  40. package/dist/types/Notification.js +13 -0
  41. package/dist/types/Notification.js.map +1 -1
  42. package/dist/types/NotificationAndroid.d.ts +9 -0
  43. package/dist/types/NotificationAndroid.js.map +1 -1
  44. package/dist/validators/validateAndroidNotification.js +26 -1
  45. package/dist/validators/validateAndroidNotification.js.map +1 -1
  46. package/dist/validators/validateAndroidStyle.js +6 -0
  47. package/dist/validators/validateAndroidStyle.js.map +1 -1
  48. package/dist/validators/validateIOSAttachment.js +3 -1
  49. package/dist/validators/validateIOSAttachment.js.map +1 -1
  50. package/dist/version.d.ts +1 -1
  51. package/dist/version.js +1 -1
  52. package/package.json +8 -5
  53. package/src/NotifeeNativeModule.web.ts +2 -2
  54. package/src/types/Notification.ts +40 -0
  55. package/src/types/NotificationAndroid.ts +10 -0
  56. package/src/validators/validateAndroidNotification.ts +31 -1
  57. package/src/validators/validateAndroidStyle.ts +10 -2
  58. package/src/validators/validateIOSAttachment.ts +5 -1
  59. package/src/version.ts +1 -1
  60. package/cli/dist/cli.bundle.js +0 -20834
  61. package/cli/dist/cli.d.ts +0 -2
  62. package/cli/dist/cli.js.map +0 -1
  63. package/cli/dist/commands/initNse.d.ts +0 -12
  64. package/cli/dist/commands/initNse.js.map +0 -1
  65. package/cli/dist/lib/detectProject.d.ts +0 -12
  66. package/cli/dist/lib/detectProject.js.map +0 -1
  67. package/cli/dist/lib/initNseCore.d.ts +0 -8
  68. package/cli/dist/lib/initNseCore.js.map +0 -1
  69. package/cli/dist/lib/logger.d.ts +0 -4
  70. package/cli/dist/lib/logger.js.map +0 -1
  71. package/cli/dist/lib/patchPodfile.d.ts +0 -23
  72. package/cli/dist/lib/patchPodfile.js.map +0 -1
  73. package/cli/dist/lib/patchXcodeProject.d.ts +0 -41
  74. package/cli/dist/lib/patchXcodeProject.js.map +0 -1
  75. package/cli/dist/lib/writeTemplates.d.ts +0 -11
  76. package/cli/dist/lib/writeTemplates.js.map +0 -1
  77. package/cli/dist/templates/templates/Info.plist.tmpl +0 -29
  78. package/cli/dist/templates/templates/NotificationService.swift.tmpl +0 -100
  79. package/cli/dist/templates/templates/NotifyKitNSE.entitlements.tmpl +0 -6
@@ -0,0 +1,280 @@
1
+ /**
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ 'License'); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+ Unless required by applicable law or agreed to in writing,
11
+ software distributed under the License is distributed on an
12
+ 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13
+ KIND, either express or implied. See the License for the
14
+ specific language governing permissions and limitations
15
+ under the License.
16
+ */
17
+
18
+ {
19
+ function merge_obj(obj, secondObj) {
20
+ if (!obj)
21
+ return secondObj;
22
+
23
+ for(var i in secondObj)
24
+ obj[i] = merge_obj(obj[i], secondObj[i]);
25
+
26
+ return obj;
27
+ }
28
+ }
29
+
30
+ /*
31
+ * Project: point of entry from pbxproj file
32
+ */
33
+ Project
34
+ = headComment:SingleLineComment? InlineComment? _ obj:Object NewLine _
35
+ {
36
+ var proj = Object.create(null)
37
+ proj.project = obj
38
+
39
+ if (headComment) {
40
+ proj.headComment = headComment
41
+ }
42
+
43
+ return proj;
44
+ }
45
+
46
+ /*
47
+ * Object: basic hash data structure with Assignments
48
+ */
49
+ Object
50
+ = "{" obj:(AssignmentList / EmptyBody) "}"
51
+ { return obj }
52
+
53
+ EmptyBody
54
+ = _
55
+ { return Object.create(null) }
56
+
57
+ AssignmentList
58
+ = _ list:((a:Assignment / d:DelimitedSection) _)+
59
+ {
60
+ var returnObject = list[0][0];
61
+ for(var i = 1; i < list.length; i++){
62
+ var another = list[i][0];
63
+ returnObject = merge_obj(returnObject, another);
64
+ }
65
+ return returnObject;
66
+ }
67
+
68
+ /*
69
+ * Assignments
70
+ * can be simple "key = value"
71
+ * or commented "key /* real key * / = value"
72
+ */
73
+ Assignment
74
+ = SimpleAssignment / CommentedAssignment
75
+
76
+ SimpleAssignment
77
+ = id:Identifier _ "=" _ val:Value ";"
78
+ {
79
+ var result = Object.create(null);
80
+ result[id] = val
81
+ return result
82
+ }
83
+
84
+ CommentedAssignment
85
+ = commentedId:CommentedIdentifier _ "=" _ val:Value ";"
86
+ {
87
+ var result = Object.create(null),
88
+ commentKey = commentedId.id + '_comment';
89
+
90
+ result[commentedId.id] = val;
91
+ result[commentKey] = commentedId[commentKey];
92
+ return result;
93
+
94
+ }
95
+ /
96
+ id:Identifier _ "=" _ commentedVal:CommentedValue ";"
97
+ {
98
+ var result = Object.create(null);
99
+ result[id] = commentedVal.value;
100
+ result[id + "_comment"] = commentedVal.comment;
101
+ return result;
102
+ }
103
+
104
+ CommentedIdentifier
105
+ = id:Identifier _ comment:InlineComment
106
+ {
107
+ var result = Object.create(null);
108
+ result.id = id;
109
+ result[id + "_comment"] = comment.trim();
110
+ return result
111
+ }
112
+
113
+ CommentedValue
114
+ = literal:Value _ comment:InlineComment
115
+ {
116
+ var result = Object.create(null)
117
+ result.comment = comment.trim();
118
+ result.value = literal.trim();
119
+ return result;
120
+ }
121
+
122
+ InlineComment
123
+ = InlineCommentOpen body:[^*]+ InlineCommentClose
124
+ { return body.join('') }
125
+
126
+ InlineCommentOpen
127
+ = "/*"
128
+
129
+ InlineCommentClose
130
+ = "*/"
131
+
132
+ /*
133
+ * DelimitedSection - ad hoc project structure pbxproj files use
134
+ */
135
+ DelimitedSection
136
+ = begin:DelimitedSectionBegin _ fields:(AssignmentList / EmptyBody) _ DelimitedSectionEnd
137
+ {
138
+ var section = Object.create(null);
139
+ section[begin.name] = fields
140
+
141
+ return section
142
+ }
143
+
144
+ DelimitedSectionBegin
145
+ = "/* Begin " sectionName:Identifier " section */" NewLine
146
+ { return { name: sectionName } }
147
+
148
+ DelimitedSectionEnd
149
+ = "/* End " sectionName:Identifier " section */" NewLine
150
+ { return { name: sectionName } }
151
+
152
+ /*
153
+ * Arrays: lists of values, possible wth comments
154
+ */
155
+ Array
156
+ = "(" arr:(ArrayBody / EmptyArray ) ")" { return arr }
157
+
158
+ EmptyArray
159
+ = _ { return [] }
160
+
161
+ ArrayBody
162
+ = _ head:ArrayEntry _ tail:ArrayBody? _
163
+ {
164
+ if (tail) {
165
+ tail.unshift(head);
166
+ return tail;
167
+ } else {
168
+ return [head];
169
+ }
170
+ }
171
+
172
+ ArrayEntry
173
+ = SimpleArrayEntry / CommentedArrayEntry
174
+
175
+ SimpleArrayEntry
176
+ = val:Value EndArrayEntry { return val }
177
+
178
+ CommentedArrayEntry
179
+ = val:Value _ comment:InlineComment EndArrayEntry
180
+ {
181
+ var result = Object.create(null);
182
+ result.value = val.trim();
183
+ result.comment = comment.trim();
184
+ return result;
185
+ }
186
+
187
+ EndArrayEntry
188
+ = "," / _ &")"
189
+
190
+ /*
191
+ * Identifiers and Values
192
+ */
193
+ Identifier
194
+ = id:[A-Za-z0-9_.]+ { return id.join('') }
195
+ / QuotedString
196
+
197
+ Value
198
+ = Object / Array / NumberValue / StringValue
199
+
200
+ NumberValue
201
+ = DecimalValue / IntegerValue
202
+
203
+ DecimalValue
204
+ = decimal:(IntegerValue "." IntegerValue)
205
+ {
206
+ // store decimals as strings
207
+ // as JS doesn't differentiate bw strings and numbers
208
+ return decimal.join('')
209
+ }
210
+
211
+ IntegerValue
212
+ = !Alpha number:Digit+ !NonTerminator
213
+ { return parseInt(number.join(''), 10) }
214
+
215
+ StringValue
216
+ = QuotedString / LiteralString
217
+
218
+ QuotedString
219
+ = DoubleQuote str:QuotedBody DoubleQuote { return '"' + str + '"' }
220
+
221
+ QuotedBody
222
+ = str:NonQuote+ { return str.join('') }
223
+
224
+ NonQuote
225
+ = EscapedQuote / !DoubleQuote char:. { return char }
226
+
227
+ EscapedQuote
228
+ = "\\" DoubleQuote { return '\\"' }
229
+
230
+ LiteralString
231
+ = literal:LiteralChar+ { return literal.join('') }
232
+
233
+ LiteralChar
234
+ = !InlineCommentOpen !LineTerminator char:NonTerminator
235
+ { return char }
236
+
237
+ NonTerminator
238
+ = [^;,\n]
239
+
240
+ /*
241
+ * SingleLineComment - used for the encoding comment
242
+ */
243
+ SingleLineComment
244
+ = "//" _ contents:OneLineString NewLine
245
+ { return contents }
246
+
247
+ OneLineString
248
+ = contents:NonLine*
249
+ { return contents.join('') }
250
+
251
+ /*
252
+ * Simple character checking rules
253
+ */
254
+ Digit
255
+ = [0-9]
256
+
257
+ Alpha
258
+ = [A-Za-z]
259
+
260
+ DoubleQuote
261
+ = '"'
262
+
263
+ _ "whitespace"
264
+ = whitespace*
265
+
266
+ whitespace
267
+ = NewLine / [\t ]
268
+
269
+ NonLine
270
+ = !NewLine char:Char
271
+ { return char }
272
+
273
+ LineTerminator
274
+ = NewLine / ";"
275
+
276
+ NewLine
277
+ = [\n\r]
278
+
279
+ Char
280
+ = .
@@ -0,0 +1,233 @@
1
+ /**
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ 'License'); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+ Unless required by applicable law or agreed to in writing,
11
+ software distributed under the License is distributed on an
12
+ 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13
+ KIND, either express or implied. See the License for the
14
+ specific language governing permissions and limitations
15
+ under the License.
16
+ */
17
+
18
+ var path = require('path'),
19
+ util = require('util');
20
+
21
+ var DEFAULT_SOURCETREE = '"<group>"',
22
+ DEFAULT_PRODUCT_SOURCETREE = 'BUILT_PRODUCTS_DIR',
23
+ DEFAULT_FILEENCODING = 4,
24
+ DEFAULT_GROUP = 'Resources',
25
+ DEFAULT_FILETYPE = 'unknown';
26
+
27
+ var FILETYPE_BY_EXTENSION = {
28
+ a: 'archive.ar',
29
+ app: 'wrapper.application',
30
+ appex: 'wrapper.app-extension',
31
+ bundle: 'wrapper.plug-in',
32
+ dylib: 'compiled.mach-o.dylib',
33
+ framework: 'wrapper.framework',
34
+ h: 'sourcecode.c.h',
35
+ m: 'sourcecode.c.objc',
36
+ markdown: 'text',
37
+ mdimporter: 'wrapper.cfbundle',
38
+ octest: 'wrapper.cfbundle',
39
+ pch: 'sourcecode.c.h',
40
+ plist: 'text.plist.xml',
41
+ sh: 'text.script.sh',
42
+ swift: 'sourcecode.swift',
43
+ tbd: 'sourcecode.text-based-dylib-definition',
44
+ xcassets: 'folder.assetcatalog',
45
+ xcconfig: 'text.xcconfig',
46
+ xcdatamodel: 'wrapper.xcdatamodel',
47
+ xcodeproj: 'wrapper.pb-project',
48
+ xctest: 'wrapper.cfbundle',
49
+ xib: 'file.xib',
50
+ strings: 'text.plist.strings'
51
+ },
52
+ GROUP_BY_FILETYPE = {
53
+ 'archive.ar': 'Frameworks',
54
+ 'compiled.mach-o.dylib': 'Frameworks',
55
+ 'sourcecode.text-based-dylib-definition': 'Frameworks',
56
+ 'wrapper.framework': 'Frameworks',
57
+ 'embedded.framework': 'Embed Frameworks',
58
+ 'sourcecode.c.h': 'Resources',
59
+ 'sourcecode.c.objc': 'Sources',
60
+ 'sourcecode.swift': 'Sources'
61
+ },
62
+ PATH_BY_FILETYPE = {
63
+ 'compiled.mach-o.dylib': 'usr/lib/',
64
+ 'sourcecode.text-based-dylib-definition': 'usr/lib/',
65
+ 'wrapper.framework': 'System/Library/Frameworks/'
66
+ },
67
+ SOURCETREE_BY_FILETYPE = {
68
+ 'compiled.mach-o.dylib': 'SDKROOT',
69
+ 'sourcecode.text-based-dylib-definition': 'SDKROOT',
70
+ 'wrapper.framework': 'SDKROOT'
71
+ },
72
+ ENCODING_BY_FILETYPE = {
73
+ 'sourcecode.c.h': 4,
74
+ 'sourcecode.c.h': 4,
75
+ 'sourcecode.c.objc': 4,
76
+ 'sourcecode.swift': 4,
77
+ 'text': 4,
78
+ 'text.plist.xml': 4,
79
+ 'text.script.sh': 4,
80
+ 'text.xcconfig': 4,
81
+ 'text.plist.strings': 4
82
+ };
83
+
84
+
85
+ function unquoted(text){
86
+ return text == null ? '' : text.replace (/(^")|("$)/g, '')
87
+ }
88
+
89
+ function detectType(filePath) {
90
+ var extension = path.extname(filePath).substring(1),
91
+ filetype = FILETYPE_BY_EXTENSION[unquoted(extension)];
92
+
93
+ if (!filetype) {
94
+ return DEFAULT_FILETYPE;
95
+ }
96
+
97
+ return filetype;
98
+ }
99
+
100
+ function defaultExtension(fileRef) {
101
+ var filetype = fileRef.lastKnownFileType && fileRef.lastKnownFileType != DEFAULT_FILETYPE ?
102
+ fileRef.lastKnownFileType : fileRef.explicitFileType;
103
+
104
+ for(var extension in FILETYPE_BY_EXTENSION) {
105
+ if(FILETYPE_BY_EXTENSION.hasOwnProperty(unquoted(extension)) ) {
106
+ if(FILETYPE_BY_EXTENSION[unquoted(extension)] === unquoted(filetype) )
107
+ return extension;
108
+ }
109
+ }
110
+ }
111
+
112
+ function defaultEncoding(fileRef) {
113
+ var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
114
+ encoding = ENCODING_BY_FILETYPE[unquoted(filetype)];
115
+
116
+ if (encoding) {
117
+ return encoding;
118
+ }
119
+ }
120
+
121
+ function detectGroup(fileRef, opt) {
122
+ var extension = path.extname(fileRef.basename).substring(1),
123
+ filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
124
+ groupName = GROUP_BY_FILETYPE[unquoted(filetype)];
125
+
126
+ if (extension === 'xcdatamodeld') {
127
+ return 'Sources';
128
+ }
129
+
130
+ if (opt.customFramework && opt.embed) {
131
+ return GROUP_BY_FILETYPE['embedded.framework'];
132
+ }
133
+
134
+ if (!groupName) {
135
+ return DEFAULT_GROUP;
136
+ }
137
+
138
+ return groupName;
139
+ }
140
+
141
+ function detectSourcetree(fileRef) {
142
+
143
+ var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
144
+ sourcetree = SOURCETREE_BY_FILETYPE[unquoted(filetype)];
145
+
146
+ if (fileRef.explicitFileType) {
147
+ return DEFAULT_PRODUCT_SOURCETREE;
148
+ }
149
+
150
+ if (fileRef.customFramework) {
151
+ return DEFAULT_SOURCETREE;
152
+ }
153
+
154
+ if (!sourcetree) {
155
+ return DEFAULT_SOURCETREE;
156
+ }
157
+
158
+ return sourcetree;
159
+ }
160
+
161
+ function defaultPath(fileRef, filePath) {
162
+ var filetype = fileRef.lastKnownFileType || fileRef.explicitFileType,
163
+ defaultPath = PATH_BY_FILETYPE[unquoted(filetype)];
164
+
165
+ if (fileRef.customFramework) {
166
+ return filePath;
167
+ }
168
+
169
+ if (defaultPath) {
170
+ return path.join(defaultPath, path.basename(filePath));
171
+ }
172
+
173
+ return filePath;
174
+ }
175
+
176
+ function defaultGroup(fileRef) {
177
+ var groupName = GROUP_BY_FILETYPE[fileRef.lastKnownFileType];
178
+
179
+ if (!groupName) {
180
+ return DEFAULT_GROUP;
181
+ }
182
+
183
+ return defaultGroup;
184
+ }
185
+
186
+ function pbxFile(filepath, opt) {
187
+ var opt = opt || {};
188
+
189
+ this.basename = path.basename(filepath);
190
+ this.lastKnownFileType = opt.lastKnownFileType || detectType(filepath);
191
+ this.group = detectGroup(this, opt);
192
+
193
+ // for custom frameworks
194
+ if (opt.customFramework == true) {
195
+ this.customFramework = true;
196
+ this.dirname = path.dirname(filepath).replace(/\\/g, '/');
197
+ }
198
+
199
+ this.path = defaultPath(this, filepath).replace(/\\/g, '/');
200
+ this.fileEncoding = this.defaultEncoding = opt.defaultEncoding || defaultEncoding(this);
201
+
202
+ // When referencing products / build output files
203
+ if (opt.explicitFileType) {
204
+ this.explicitFileType = opt.explicitFileType;
205
+ this.basename = this.basename + '.' + defaultExtension(this);
206
+ delete this.path;
207
+ delete this.lastKnownFileType;
208
+ delete this.group;
209
+ delete this.defaultEncoding;
210
+ }
211
+
212
+ this.sourceTree = opt.sourceTree || detectSourcetree(this);
213
+ this.includeInIndex = 0;
214
+
215
+ if (opt.weak && opt.weak === true)
216
+ this.settings = { ATTRIBUTES: ['Weak'] };
217
+
218
+ if (opt.compilerFlags) {
219
+ if (!this.settings)
220
+ this.settings = {};
221
+ this.settings.COMPILER_FLAGS = util.format('"%s"', opt.compilerFlags);
222
+ }
223
+
224
+ if (opt.embed && opt.sign) {
225
+ if (!this.settings)
226
+ this.settings = {};
227
+ if (!this.settings.ATTRIBUTES)
228
+ this.settings.ATTRIBUTES = [];
229
+ this.settings.ATTRIBUTES.push('CodeSignOnCopy');
230
+ }
231
+ }
232
+
233
+ module.exports = pbxFile;