react-native-ios-widget 0.0.13-beta.3 → 0.0.13-beta.4
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.json
CHANGED
package/plugin/build/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const withXcode_1 = require("./withXcode");
|
|
|
5
5
|
const withWidgetExtensionEntitlements_1 = require("./withWidgetExtensionEntitlements");
|
|
6
6
|
const withPodfile_1 = require("./withPodfile");
|
|
7
7
|
const withConfig_1 = require("./withConfig");
|
|
8
|
-
const withWidgetModuleConfig_1 = require("./withWidgetModuleConfig");
|
|
9
8
|
const withWidget = (config, { enabled = true, deploymentTarget = "14.0", widgetsFolder = "widgets", groupIdentifier, pods = [], targetName = "WidgetsExtension", bundleIdentifier = `${config.ios?.bundleIdentifier}.Widgets`, }) => {
|
|
10
9
|
const widget = {
|
|
11
10
|
enabled,
|
|
@@ -21,7 +20,6 @@ const withWidget = (config, { enabled = true, deploymentTarget = "14.0", widgets
|
|
|
21
20
|
[withWidgetExtensionEntitlements_1.withWidgetExtensionEntitlements, widget],
|
|
22
21
|
[withPodfile_1.withPodfile, widget],
|
|
23
22
|
[withConfig_1.withConfig, widget],
|
|
24
|
-
[withWidgetModuleConfig_1.withWidgetModuleConfig, widget],
|
|
25
23
|
]);
|
|
26
24
|
};
|
|
27
25
|
exports.default = withWidget;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/types.ts","../src/withconfig.ts","../src/withpodfile.ts","../src/withwidgetextensionentitlements.ts","../src/
|
|
1
|
+
{"root":["../src/index.ts","../src/types.ts","../src/withconfig.ts","../src/withpodfile.ts","../src/withwidgetextensionentitlements.ts","../src/withxcode.ts","../src/lib/getwidgetextensionentitlements.ts","../src/lib/getwidgetfiles.ts","../src/xcode/addbuildphases.ts","../src/xcode/addpbxgroup.ts","../src/xcode/addproductfile.ts","../src/xcode/addtargetdependency.ts","../src/xcode/addtopbxnativetargetsection.ts","../src/xcode/addtopbxprojectsection.ts","../src/xcode/addxcconfigurationlist.ts"],"version":"5.9.3"}
|
|
@@ -46,87 +46,78 @@ const addPbxGroup_1 = require("./xcode/addPbxGroup");
|
|
|
46
46
|
const addBuildPhases_1 = require("./xcode/addBuildPhases");
|
|
47
47
|
const getWidgetFiles_1 = require("./lib/getWidgetFiles");
|
|
48
48
|
const withXcode = (config, { enabled, targetName, bundleIdentifier, deploymentTarget, widgetsFolder }) => {
|
|
49
|
-
return (0, config_plugins_1.
|
|
50
|
-
|
|
51
|
-
(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!enabled) {
|
|
56
|
-
ensureModuleSwift(widgetsPath, moduleRoot);
|
|
57
|
-
return config;
|
|
58
|
-
}
|
|
59
|
-
const targetPath = path.join(platformProjectRoot, targetName);
|
|
60
|
-
const widgetFiles = (0, getWidgetFiles_1.getWidgetFiles)(widgetsPath, targetPath, moduleRoot);
|
|
61
|
-
const xcodeProject = config.modResults;
|
|
62
|
-
const marketingVersion = config.version;
|
|
63
|
-
const xCConfigurationList = (0, addXCConfigurationList_1.addXCConfigurationList)(xcodeProject, {
|
|
64
|
-
targetName,
|
|
65
|
-
currentProjectVersion: config.ios.buildNumber || "1",
|
|
66
|
-
bundleIdentifier,
|
|
67
|
-
deploymentTarget,
|
|
68
|
-
marketingVersion,
|
|
69
|
-
});
|
|
70
|
-
const groupName = "Embed Foundation Extensions";
|
|
71
|
-
const productFile = (0, addProductFile_1.addProductFile)(xcodeProject, {
|
|
72
|
-
targetName,
|
|
73
|
-
groupName,
|
|
74
|
-
});
|
|
75
|
-
const targetUuid = xcodeProject.generateUuid();
|
|
76
|
-
const target = (0, addToPbxNativeTargetSection_1.addToPbxNativeTargetSection)(xcodeProject, {
|
|
77
|
-
targetName,
|
|
78
|
-
targetUuid,
|
|
79
|
-
productFile,
|
|
80
|
-
xCConfigurationList,
|
|
81
|
-
});
|
|
82
|
-
(0, addToPbxProjectSection_1.addToPbxProjectSection)(xcodeProject, target);
|
|
83
|
-
(0, addTargetDependency_1.addTargetDependency)(xcodeProject, target);
|
|
84
|
-
(0, addBuildPhases_1.addBuildPhases)(xcodeProject, {
|
|
85
|
-
targetUuid,
|
|
86
|
-
groupName,
|
|
87
|
-
productFile,
|
|
88
|
-
widgetFiles,
|
|
89
|
-
});
|
|
90
|
-
(0, addPbxGroup_1.addPbxGroup)(xcodeProject, {
|
|
91
|
-
targetName,
|
|
92
|
-
widgetFiles,
|
|
93
|
-
});
|
|
49
|
+
return (0, config_plugins_1.withXcodeProject)(config, (config) => {
|
|
50
|
+
const { platformProjectRoot, projectRoot } = config.modRequest;
|
|
51
|
+
const widgetsPath = path.join(projectRoot, widgetsFolder);
|
|
52
|
+
const moduleRoot = path.join(projectRoot, "node_modules", "react-native-ios-widget", "ios");
|
|
53
|
+
if (!enabled) {
|
|
54
|
+
ensureModuleSwift(widgetsPath, moduleRoot);
|
|
94
55
|
return config;
|
|
95
56
|
}
|
|
96
|
-
|
|
57
|
+
const targetPath = path.join(platformProjectRoot, targetName);
|
|
58
|
+
const widgetFiles = (0, getWidgetFiles_1.getWidgetFiles)(widgetsPath, targetPath, moduleRoot);
|
|
59
|
+
const xcodeProject = config.modResults;
|
|
60
|
+
const marketingVersion = config.version;
|
|
61
|
+
const xCConfigurationList = (0, addXCConfigurationList_1.addXCConfigurationList)(xcodeProject, {
|
|
62
|
+
targetName,
|
|
63
|
+
currentProjectVersion: config.ios.buildNumber || "1",
|
|
64
|
+
bundleIdentifier,
|
|
65
|
+
deploymentTarget,
|
|
66
|
+
marketingVersion,
|
|
67
|
+
});
|
|
68
|
+
const groupName = "Embed Foundation Extensions";
|
|
69
|
+
const productFile = (0, addProductFile_1.addProductFile)(xcodeProject, {
|
|
70
|
+
targetName,
|
|
71
|
+
groupName,
|
|
72
|
+
});
|
|
73
|
+
const targetUuid = xcodeProject.generateUuid();
|
|
74
|
+
const target = (0, addToPbxNativeTargetSection_1.addToPbxNativeTargetSection)(xcodeProject, {
|
|
75
|
+
targetName,
|
|
76
|
+
targetUuid,
|
|
77
|
+
productFile,
|
|
78
|
+
xCConfigurationList,
|
|
79
|
+
});
|
|
80
|
+
(0, addToPbxProjectSection_1.addToPbxProjectSection)(xcodeProject, target);
|
|
81
|
+
(0, addTargetDependency_1.addTargetDependency)(xcodeProject, target);
|
|
82
|
+
(0, addBuildPhases_1.addBuildPhases)(xcodeProject, {
|
|
83
|
+
targetUuid,
|
|
84
|
+
groupName,
|
|
85
|
+
productFile,
|
|
86
|
+
widgetFiles,
|
|
87
|
+
});
|
|
88
|
+
(0, addPbxGroup_1.addPbxGroup)(xcodeProject, {
|
|
89
|
+
targetName,
|
|
90
|
+
widgetFiles,
|
|
91
|
+
});
|
|
92
|
+
return config;
|
|
93
|
+
});
|
|
97
94
|
};
|
|
98
95
|
exports.withXcode = withXcode;
|
|
99
96
|
const ensureModuleSwift = (widgetsPath, moduleRoot) => {
|
|
100
|
-
// Ensure pod source dir exists for Module.swift.
|
|
97
|
+
// Ensure the pod source dir exists for Module.swift.
|
|
101
98
|
if (!fs.existsSync(moduleRoot)) {
|
|
102
99
|
fs.mkdirSync(moduleRoot, { recursive: true });
|
|
103
100
|
}
|
|
104
|
-
//
|
|
105
|
-
// When widgets are enabled, ensure module config exists and declares ReactNativeWidgetExtensionModule.
|
|
106
|
-
// When disabled, remove or write empty config to exclude module from Expo autolinking.
|
|
107
|
-
const moduleConfigPath = path.join(moduleRoot, "expo-module.config.json");
|
|
101
|
+
// Prefer the real Module.swift from widgets if it exists.
|
|
108
102
|
const moduleSwiftPath = path.join(widgetsPath, "Module.swift");
|
|
109
103
|
const targetPath = path.join(moduleRoot, "Module.swift");
|
|
110
104
|
if (fs.existsSync(moduleSwiftPath)) {
|
|
111
|
-
// Widgets enabled: copy real Module.swift for CocoaPods
|
|
112
105
|
fs.copyFileSync(moduleSwiftPath, targetPath);
|
|
113
|
-
|
|
114
|
-
const moduleConfig = {
|
|
115
|
-
platforms: ["ios"],
|
|
116
|
-
ios: {
|
|
117
|
-
modules: ["ReactNativeWidgetExtensionModule"],
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
if (!fs.existsSync(moduleConfigPath)) {
|
|
121
|
-
fs.writeFileSync(moduleConfigPath, JSON.stringify(moduleConfig, null, 2));
|
|
122
|
-
}
|
|
106
|
+
return;
|
|
123
107
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
108
|
+
// If widgets are disabled and no real Module.swift exists, write a stub
|
|
109
|
+
// so CocoaPods still builds a Swift module and avoids import errors.
|
|
110
|
+
if (!fs.existsSync(targetPath)) {
|
|
111
|
+
const stubModule = [
|
|
112
|
+
"import ExpoModulesCore",
|
|
113
|
+
"",
|
|
114
|
+
"public class ReactNativeWidgetExtensionModule: Module {",
|
|
115
|
+
" public func definition() -> ModuleDefinition {",
|
|
116
|
+
' Name("ReactNativeWidgetExtension")',
|
|
117
|
+
" }",
|
|
118
|
+
"}",
|
|
119
|
+
"",
|
|
120
|
+
].join("\n");
|
|
121
|
+
fs.writeFileSync(targetPath, stubModule);
|
|
131
122
|
}
|
|
132
123
|
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.withWidgetModuleConfig = void 0;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const withWidgetModuleConfig = (config, { enabled, targetName, widgetsFolder }) => {
|
|
40
|
-
const { platformProjectRoot, projectRoot } = config.modRequest;
|
|
41
|
-
const widgetsPath = path.join(projectRoot, widgetsFolder);
|
|
42
|
-
const moduleRoot = path.join(projectRoot, "node_modules", "react-native-ios-widget", "ios");
|
|
43
|
-
if (!enabled) {
|
|
44
|
-
// When disabled, ensure no module config exists (remove if present)
|
|
45
|
-
const moduleConfigPath = path.join(moduleRoot, "expo-module.config.json");
|
|
46
|
-
if (fs.existsSync(moduleConfigPath)) {
|
|
47
|
-
fs.unlinkSync(moduleConfigPath);
|
|
48
|
-
}
|
|
49
|
-
// Optionally write empty config to explicitly exclude module
|
|
50
|
-
// fs.writeFileSync(
|
|
51
|
-
// moduleConfigPath,
|
|
52
|
-
// JSON.stringify({ platforms: ["ios"], ios: {} }, null, 2)
|
|
53
|
-
// );
|
|
54
|
-
}
|
|
55
|
-
// Conditionally manage expo-module.config.json based on widget enabled state.
|
|
56
|
-
// When widgets are enabled, ensure module config exists and declares ReactNativeWidgetExtensionModule.
|
|
57
|
-
// When disabled, remove or write empty config to exclude module from Expo autolinking.
|
|
58
|
-
const moduleConfigPath = path.join(moduleRoot, "expo-module.config.json");
|
|
59
|
-
const moduleSwiftPath = path.join(widgetsPath, "Module.swift");
|
|
60
|
-
const targetPath = path.join(moduleRoot, "Module.swift");
|
|
61
|
-
if (fs.existsSync(moduleSwiftPath)) {
|
|
62
|
-
// Widgets enabled: copy real Module.swift for CocoaPods
|
|
63
|
-
fs.copyFileSync(moduleSwiftPath, targetPath);
|
|
64
|
-
// Write module config to enable Expo autolinking
|
|
65
|
-
const moduleConfig = {
|
|
66
|
-
platforms: ["ios"],
|
|
67
|
-
ios: {
|
|
68
|
-
modules: ["ReactNativeWidgetExtensionModule"],
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
if (!fs.existsSync(moduleConfigPath)) {
|
|
72
|
-
fs.writeFileSync(moduleConfigPath, JSON.stringify(moduleConfig, null, 2));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
// Widgets disabled: ensure no module config exists (remove empty config if present)
|
|
77
|
-
if (fs.existsSync(moduleConfigPath)) {
|
|
78
|
-
fs.unlinkSync(moduleConfigPath);
|
|
79
|
-
}
|
|
80
|
-
// Write empty config to exclude module from Expo autolinking
|
|
81
|
-
fs.writeFileSync(moduleConfigPath, JSON.stringify({ platforms: ["ios"], ios: {} }, null, 2));
|
|
82
|
-
}
|
|
83
|
-
return config;
|
|
84
|
-
};
|
|
85
|
-
exports.withWidgetModuleConfig = withWidgetModuleConfig;
|