react-native-notify-kit 10.3.3 → 10.4.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 (35) hide show
  1. package/README.md +102 -12
  2. package/app.plugin.js +3 -0
  3. package/cli/dist/commands/initNse.js +8 -9
  4. package/cli/dist/commands/initNse.js.map +1 -1
  5. package/cli/dist/lib/detectProject.d.ts +1 -4
  6. package/cli/dist/lib/detectProject.js +3 -32
  7. package/cli/dist/lib/detectProject.js.map +1 -1
  8. package/cli/dist/lib/initNseCore.d.ts +8 -0
  9. package/cli/dist/lib/initNseCore.js +197 -0
  10. package/cli/dist/lib/initNseCore.js.map +1 -0
  11. package/cli/dist/lib/patchPodfile.d.ts +9 -0
  12. package/cli/dist/lib/patchPodfile.js +22 -15
  13. package/cli/dist/lib/patchPodfile.js.map +1 -1
  14. package/cli/dist/lib/patchXcodeProject.d.ts +16 -0
  15. package/cli/dist/lib/patchXcodeProject.js +54 -26
  16. package/cli/dist/lib/patchXcodeProject.js.map +1 -1
  17. package/cli/dist/lib/writeTemplates.js +5 -14
  18. package/cli/dist/lib/writeTemplates.js.map +1 -1
  19. package/dist/version.d.ts +1 -1
  20. package/dist/version.js +1 -1
  21. package/ios/RNNotifee/NotifeeExtensionHelper.h +2 -2
  22. package/ios/RNNotifee/NotifeeExtensionHelper.m +1 -0
  23. package/package.json +15 -2
  24. package/plugin/build/android/withNotifyKitAndroidManifest.js +236 -0
  25. package/plugin/build/index.js +62 -0
  26. package/plugin/build/ios/withNotifyKitIosNseAppExtension.js +142 -0
  27. package/plugin/build/ios/withNotifyKitIosNseFiles.js +79 -0
  28. package/plugin/build/ios/withNotifyKitIosNsePodfile.js +130 -0
  29. package/plugin/build/ios/withNotifyKitIosNseXcodeProject.js +49 -0
  30. package/plugin/build/options.js +224 -0
  31. package/plugin/build/shared/nse/index.js +7 -0
  32. package/plugin/build/shared/nse/initNseCore.js +220 -0
  33. package/plugin/build/shared/nse/patchPodfile.js +261 -0
  34. package/plugin/build/shared/nse/patchXcodeProject.js +199 -0
  35. package/src/version.ts +1 -1
@@ -0,0 +1,199 @@
1
+ 'use strict';
2
+
3
+ const crypto = require('crypto');
4
+
5
+ function patchXcodeProjectForNotifyKitNse(proj, options) {
6
+ const { targetName, bundleIdentifier, parentTargetName, deploymentTarget = '15.1' } = options;
7
+ const warnings = [];
8
+
9
+ if (targetExists(proj, targetName)) {
10
+ return { didChange: false, warnings };
11
+ }
12
+
13
+ const target = proj.addTarget(targetName, 'app_extension', targetName);
14
+
15
+ if (!target || !target.uuid) {
16
+ throw new Error(`xcode library failed to create target '${targetName}'`);
17
+ }
18
+
19
+ const targetUuid = target.uuid;
20
+ const productUuid = getTargetProductUuid(target);
21
+
22
+ fixProductFileReference(proj, targetName);
23
+
24
+ proj.addBuildPhase([], 'PBXSourcesBuildPhase', 'Sources', targetUuid);
25
+ proj.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', targetUuid);
26
+ proj.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', targetUuid);
27
+
28
+ const group = proj.addPbxGroup([], targetName, targetName);
29
+ proj.addSourceFile(
30
+ `${targetName}/NotificationService.swift`,
31
+ {
32
+ target: targetUuid,
33
+ },
34
+ group.uuid,
35
+ );
36
+
37
+ const hostUuid = findHostTarget(proj, parentTargetName);
38
+ if (hostUuid) {
39
+ addTargetDependencyManual(proj, hostUuid, targetUuid, targetName);
40
+ stripRnfbInfoPlistInputPath(proj, hostUuid);
41
+ }
42
+
43
+ setBuildSettings(proj, targetName, bundleIdentifier, deploymentTarget);
44
+
45
+ return {
46
+ didChange: true,
47
+ targetUuid,
48
+ productUuid,
49
+ hostTargetUuid: hostUuid ?? undefined,
50
+ warnings,
51
+ };
52
+ }
53
+
54
+ function findHostTarget(proj, parentTargetName) {
55
+ if (parentTargetName) {
56
+ return findTargetByName(proj, parentTargetName);
57
+ }
58
+
59
+ const targets = proj.pbxNativeTargetSection();
60
+ for (const [key, value] of Object.entries(targets)) {
61
+ if (typeof value !== 'object' || key.endsWith('_comment')) continue;
62
+ const target = value;
63
+ const productType = String(target.productType ?? '');
64
+ if (productType.includes('application')) {
65
+ return key;
66
+ }
67
+ }
68
+ return null;
69
+ }
70
+
71
+ function findTargetByName(proj, name) {
72
+ const targets = proj.pbxNativeTargetSection();
73
+ for (const [key, value] of Object.entries(targets)) {
74
+ if (typeof value !== 'object') continue;
75
+ const target = value;
76
+ const targetName = String(target.name ?? '').replace(/"/g, '');
77
+ if (targetName === name) {
78
+ return key;
79
+ }
80
+ }
81
+ return null;
82
+ }
83
+
84
+ function targetExists(proj, name) {
85
+ return findTargetByName(proj, name) !== null;
86
+ }
87
+
88
+ function getTargetProductUuid(target) {
89
+ const productReference = target.pbxNativeTarget && target.pbxNativeTarget.productReference;
90
+ return typeof productReference === 'string' ? productReference : undefined;
91
+ }
92
+
93
+ function setBuildSettings(proj, targetName, bundleId, deploymentTarget) {
94
+ const configs = proj.pbxXCBuildConfigurationSection();
95
+
96
+ for (const [, value] of Object.entries(configs)) {
97
+ if (typeof value !== 'object') continue;
98
+ const config = value;
99
+ const settings = config.buildSettings;
100
+
101
+ if (!settings) continue;
102
+ if (settings.PRODUCT_NAME !== `"${targetName}"`) continue;
103
+
104
+ settings.INFOPLIST_FILE = `"${targetName}/Info.plist"`;
105
+ settings.PRODUCT_BUNDLE_IDENTIFIER = `"${bundleId}"`;
106
+ settings.TARGETED_DEVICE_FAMILY = `"1,2"`;
107
+ settings.IPHONEOS_DEPLOYMENT_TARGET = deploymentTarget;
108
+ settings.SWIFT_VERSION = '5.0';
109
+ settings.CODE_SIGN_ENTITLEMENTS = `"${targetName}/${targetName}.entitlements"`;
110
+ settings.GENERATE_INFOPLIST_FILE = 'NO';
111
+ }
112
+ }
113
+
114
+ function fixProductFileReference(proj, targetName) {
115
+ const fileRefs = proj.hash.project.objects.PBXFileReference;
116
+ if (!fileRefs) return;
117
+ for (const [, value] of Object.entries(fileRefs)) {
118
+ if (typeof value !== 'object') continue;
119
+ const ref = value;
120
+ if (String(ref.name ?? '').replace(/"/g, '') === `${targetName}.appex`) {
121
+ delete ref.fileEncoding;
122
+ delete ref.lastKnownFileType;
123
+ }
124
+ }
125
+ }
126
+
127
+ function genUuid() {
128
+ return crypto.randomBytes(12).toString('hex').toUpperCase().slice(0, 24);
129
+ }
130
+
131
+ function addTargetDependencyManual(proj, hostUuid, extensionUuid, extensionName) {
132
+ const proxyUuid = genUuid();
133
+ const depUuid = genUuid();
134
+
135
+ const objects = proj.hash.project.objects;
136
+
137
+ const rootObject = proj.hash.project.rootObject;
138
+
139
+ if (!objects.PBXContainerItemProxy) objects.PBXContainerItemProxy = {};
140
+ objects.PBXContainerItemProxy[proxyUuid] = {
141
+ isa: 'PBXContainerItemProxy',
142
+ containerPortal: rootObject,
143
+ proxyType: 1,
144
+ remoteGlobalIDString: extensionUuid,
145
+ remoteInfo: `"${extensionName}"`,
146
+ };
147
+ objects.PBXContainerItemProxy[`${proxyUuid}_comment`] = 'PBXContainerItemProxy';
148
+
149
+ if (!objects.PBXTargetDependency) objects.PBXTargetDependency = {};
150
+ objects.PBXTargetDependency[depUuid] = {
151
+ isa: 'PBXTargetDependency',
152
+ target: extensionUuid,
153
+ targetProxy: proxyUuid,
154
+ };
155
+ objects.PBXTargetDependency[`${depUuid}_comment`] = 'PBXTargetDependency';
156
+
157
+ const hostTarget = objects.PBXNativeTarget[hostUuid];
158
+ if (hostTarget && Array.isArray(hostTarget.dependencies)) {
159
+ hostTarget.dependencies.push({ value: depUuid, comment: 'PBXTargetDependency' });
160
+ }
161
+ }
162
+
163
+ function stripRnfbInfoPlistInputPath(proj, hostUuid) {
164
+ const objects = proj.hash.project.objects;
165
+ const hostTarget = objects.PBXNativeTarget?.[hostUuid];
166
+ const shellPhases = objects.PBXShellScriptBuildPhase;
167
+
168
+ if (!hostTarget || !Array.isArray(hostTarget.buildPhases) || !shellPhases) {
169
+ return;
170
+ }
171
+
172
+ for (const phaseRef of hostTarget.buildPhases) {
173
+ const phaseUuid = phaseRef?.value;
174
+ if (!phaseUuid) continue;
175
+
176
+ const phase = shellPhases[phaseUuid];
177
+ if (!phase) continue;
178
+
179
+ const phaseName = String(phase.name ?? '').replace(/"/g, '');
180
+ if (phaseName !== '[CP-User] [RNFB] Core Configuration') {
181
+ continue;
182
+ }
183
+
184
+ const inputPaths = Array.isArray(phase.inputPaths) ? phase.inputPaths : [];
185
+ const filteredInputPaths = inputPaths.filter(
186
+ entry => String(entry) !== '"$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)"',
187
+ );
188
+
189
+ if (filteredInputPaths.length > 0) {
190
+ phase.inputPaths = filteredInputPaths;
191
+ } else {
192
+ delete phase.inputPaths;
193
+ }
194
+ }
195
+ }
196
+
197
+ module.exports = {
198
+ patchXcodeProjectForNotifyKitNse,
199
+ };
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '10.3.3';
2
+ export const version = '10.4.0';