react-native-ios-widget 0.0.6 → 0.0.7

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ios-widget",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Expo config plugin to add widgets to a React Native app",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -6,24 +6,22 @@ const withWidgetExtensionEntitlements_1 = require("./withWidgetExtensionEntitlem
6
6
  const withPodfile_1 = require("./withPodfile");
7
7
  const withConfig_1 = require("./withConfig");
8
8
  const withWidget = (config, { enabled = true, deploymentTarget = "14.0", widgetsFolder = "widgets", groupIdentifier, pods, }) => {
9
- if (!enabled) {
10
- return config;
11
- }
12
9
  const targetName = "WidgetsExtension";
13
10
  const bundleIdentifier = `${config.ios?.bundleIdentifier}.Widgets`;
14
11
  return (0, config_plugins_1.withPlugins)(config, [
15
12
  [
16
13
  withXcode_1.withXcode,
17
14
  {
15
+ enabled,
18
16
  targetName,
19
17
  bundleIdentifier,
20
18
  deploymentTarget,
21
19
  widgetsFolder,
22
20
  },
23
21
  ],
24
- [withWidgetExtensionEntitlements_1.withWidgetExtensionEntitlements, { targetName, groupIdentifier }],
25
- [withPodfile_1.withPodfile, { targetName, pods }],
26
- [withConfig_1.withConfig, { targetName, bundleIdentifier, groupIdentifier }],
22
+ [withWidgetExtensionEntitlements_1.withWidgetExtensionEntitlements, { enabled, targetName, groupIdentifier }],
23
+ [withPodfile_1.withPodfile, { enabled, targetName, pods }],
24
+ [withConfig_1.withConfig, { enabled, targetName, bundleIdentifier, groupIdentifier }],
27
25
  ]);
28
26
  };
29
27
  exports.default = withWidget;
@@ -70,6 +70,9 @@ function getWidgetFiles(widgetsPath, targetPath) {
70
70
  const source = path.join(widgetsPath, file);
71
71
  copyFileSync(source, targetPath);
72
72
  });
73
+ // Copy Module.swift and Attributes.swift
74
+ const modulePath = path.join(__dirname, "../../../ios");
75
+ copyFileSync(path.join(widgetsPath, "Module.swift"), path.join(modulePath, "Module.swift"));
73
76
  // Copy directories
74
77
  widgetFiles.assetDirectories.forEach((directory) => {
75
78
  const imagesXcassetsSource = path.join(widgetsPath, directory);
@@ -1,5 +1,6 @@
1
1
  import { ConfigPlugin } from "expo/config-plugins";
2
2
  export declare const withConfig: ConfigPlugin<{
3
+ enabled: boolean;
3
4
  bundleIdentifier: string;
4
5
  targetName: string;
5
6
  groupIdentifier?: string;
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withConfig = void 0;
4
4
  const getWidgetExtensionEntitlements_1 = require("./lib/getWidgetExtensionEntitlements");
5
- const withConfig = (config, { bundleIdentifier, targetName, groupIdentifier }) => {
5
+ const withConfig = (config, { enabled, bundleIdentifier, targetName, groupIdentifier }) => {
6
+ if (!enabled) {
7
+ return config;
8
+ }
6
9
  let configIndex = null;
7
10
  config.extra?.eas?.build?.experimental?.ios?.appExtensions?.forEach((ext, index) => {
8
11
  if (ext.targetName === targetName) {
@@ -1,5 +1,6 @@
1
1
  import { ConfigPlugin } from "expo/config-plugins";
2
2
  export declare const withPodfile: ConfigPlugin<{
3
+ enabled: boolean;
3
4
  targetName: string;
4
5
  pods?: string[];
5
6
  }>;
@@ -28,7 +28,10 @@ const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
28
28
  const config_plugins_1 = require("expo/config-plugins");
29
29
  const fs = __importStar(require("fs"));
30
30
  const path = __importStar(require("path"));
31
- const withPodfile = (config, { targetName, pods = [] }) => {
31
+ const withPodfile = (config, { enabled, targetName, pods = [] }) => {
32
+ if (!enabled) {
33
+ return config;
34
+ }
32
35
  return (0, config_plugins_1.withDangerousMod)(config, [
33
36
  "ios",
34
37
  (config) => {
@@ -1,5 +1,6 @@
1
1
  import { ConfigPlugin } from "expo/config-plugins";
2
2
  export declare const withWidgetExtensionEntitlements: ConfigPlugin<{
3
+ enabled: boolean;
3
4
  targetName: string;
4
5
  targetPath: string;
5
6
  groupIdentifier: string;
@@ -32,7 +32,10 @@ const config_plugins_1 = require("expo/config-plugins");
32
32
  const fs = __importStar(require("fs"));
33
33
  const path = __importStar(require("path"));
34
34
  const getWidgetExtensionEntitlements_1 = require("./lib/getWidgetExtensionEntitlements");
35
- const withWidgetExtensionEntitlements = (config, { targetName, groupIdentifier }) => {
35
+ const withWidgetExtensionEntitlements = (config, { enabled, targetName, groupIdentifier }) => {
36
+ if (!enabled) {
37
+ return config;
38
+ }
36
39
  return (0, config_plugins_1.withInfoPlist)(config, (config) => {
37
40
  const targetPath = path.join(config.modRequest.platformProjectRoot, targetName);
38
41
  const filePath = path.join(targetPath, `${targetName}.entitlements`);
@@ -1,5 +1,6 @@
1
1
  import { ConfigPlugin } from "expo/config-plugins";
2
2
  export declare const withXcode: ConfigPlugin<{
3
+ enabled: boolean;
3
4
  targetName: string;
4
5
  bundleIdentifier: string;
5
6
  deploymentTarget: string;
@@ -34,7 +34,16 @@ const addTargetDependency_1 = require("./xcode/addTargetDependency");
34
34
  const addPbxGroup_1 = require("./xcode/addPbxGroup");
35
35
  const addBuildPhases_1 = require("./xcode/addBuildPhases");
36
36
  const getWidgetFiles_1 = require("./lib/getWidgetFiles");
37
- const withXcode = (config, { targetName, bundleIdentifier, deploymentTarget, widgetsFolder }) => {
37
+ const withXcode = (config, { enabled, targetName, bundleIdentifier, deploymentTarget, widgetsFolder }) => {
38
+ if (!enabled) {
39
+ return (0, config_plugins_1.withXcodeProject)(config, (config) => {
40
+ const widgetsPath = path.join(config.modRequest.projectRoot, widgetsFolder);
41
+ const { platformProjectRoot } = config.modRequest;
42
+ const targetPath = path.join(platformProjectRoot, targetName);
43
+ (0, getWidgetFiles_1.getWidgetFiles)(widgetsPath, targetPath);
44
+ return config;
45
+ });
46
+ }
38
47
  return (0, config_plugins_1.withXcodeProject)(config, (config) => {
39
48
  const xcodeProject = config.modResults;
40
49
  const widgetsPath = path.join(config.modRequest.projectRoot, widgetsFolder);
@@ -21,10 +21,6 @@ const withWidget: ConfigPlugin<{
21
21
  pods,
22
22
  }
23
23
  ) => {
24
- if (!enabled) {
25
- return config;
26
- }
27
-
28
24
  const targetName = "WidgetsExtension";
29
25
  const bundleIdentifier = `${config.ios?.bundleIdentifier}.Widgets`;
30
26
 
@@ -32,15 +28,16 @@ const withWidget: ConfigPlugin<{
32
28
  [
33
29
  withXcode,
34
30
  {
31
+ enabled,
35
32
  targetName,
36
33
  bundleIdentifier,
37
34
  deploymentTarget,
38
35
  widgetsFolder,
39
36
  },
40
37
  ],
41
- [withWidgetExtensionEntitlements, { targetName, groupIdentifier }],
42
- [withPodfile, { targetName, pods }],
43
- [withConfig, { targetName, bundleIdentifier, groupIdentifier }],
38
+ [withWidgetExtensionEntitlements, { enabled, targetName, groupIdentifier }],
39
+ [withPodfile, { enabled, targetName, pods }],
40
+ [withConfig, { enabled, targetName, bundleIdentifier, groupIdentifier }],
44
41
  ]);
45
42
  };
46
43
 
@@ -55,6 +55,13 @@ export function getWidgetFiles(widgetsPath: string, targetPath: string) {
55
55
  copyFileSync(source, targetPath);
56
56
  });
57
57
 
58
+ // Copy Module.swift and Attributes.swift
59
+ const modulePath = path.join(__dirname, "../../../ios");
60
+ copyFileSync(
61
+ path.join(widgetsPath, "Module.swift"),
62
+ path.join(modulePath, "Module.swift")
63
+ );
64
+
58
65
  // Copy directories
59
66
  widgetFiles.assetDirectories.forEach((directory) => {
60
67
  const imagesXcassetsSource = path.join(widgetsPath, directory);
@@ -5,10 +5,15 @@ import {
5
5
  } from "./lib/getWidgetExtensionEntitlements";
6
6
 
7
7
  export const withConfig: ConfigPlugin<{
8
+ enabled: boolean;
8
9
  bundleIdentifier: string;
9
10
  targetName: string;
10
11
  groupIdentifier?: string;
11
- }> = (config, { bundleIdentifier, targetName, groupIdentifier }) => {
12
+ }> = (config, { enabled, bundleIdentifier, targetName, groupIdentifier }) => {
13
+ if (!enabled) {
14
+ return config;
15
+ }
16
+
12
17
  let configIndex: null | number = null;
13
18
  config.extra?.eas?.build?.experimental?.ios?.appExtensions?.forEach(
14
19
  (ext: any, index: number) => {
@@ -4,9 +4,14 @@ import * as fs from "fs";
4
4
  import * as path from "path";
5
5
 
6
6
  export const withPodfile: ConfigPlugin<{
7
+ enabled: boolean;
7
8
  targetName: string;
8
9
  pods?: string[];
9
- }> = (config, { targetName, pods = [] }) => {
10
+ }> = (config, { enabled, targetName, pods = [] }) => {
11
+ if (!enabled) {
12
+ return config;
13
+ }
14
+
10
15
  return withDangerousMod(config, [
11
16
  "ios",
12
17
  (config) => {
@@ -6,11 +6,16 @@ import * as path from "path";
6
6
  import { getWidgetExtensionEntitlements } from "./lib/getWidgetExtensionEntitlements";
7
7
 
8
8
  export const withWidgetExtensionEntitlements: ConfigPlugin<{
9
+ enabled: boolean;
9
10
  targetName: string;
10
11
  targetPath: string;
11
12
  groupIdentifier: string;
12
13
  appleSignin: boolean;
13
- }> = (config, { targetName, groupIdentifier }) => {
14
+ }> = (config, { enabled, targetName, groupIdentifier }) => {
15
+ if (!enabled) {
16
+ return config;
17
+ }
18
+
14
19
  return withInfoPlist(config, (config) => {
15
20
  const targetPath = path.join(
16
21
  config.modRequest.platformProjectRoot,
@@ -11,14 +11,28 @@ import { addBuildPhases } from "./xcode/addBuildPhases";
11
11
  import { getWidgetFiles } from "./lib/getWidgetFiles";
12
12
 
13
13
  export const withXcode: ConfigPlugin<{
14
+ enabled: boolean;
14
15
  targetName: string;
15
16
  bundleIdentifier: string;
16
17
  deploymentTarget: string;
17
18
  widgetsFolder: string;
18
19
  }> = (
19
20
  config,
20
- { targetName, bundleIdentifier, deploymentTarget, widgetsFolder }
21
+ { enabled, targetName, bundleIdentifier, deploymentTarget, widgetsFolder }
21
22
  ) => {
23
+ if (!enabled) {
24
+ return withXcodeProject(config, (config) => {
25
+ const widgetsPath = path.join(
26
+ config.modRequest.projectRoot,
27
+ widgetsFolder
28
+ );
29
+ const { platformProjectRoot } = config.modRequest;
30
+ const targetPath = path.join(platformProjectRoot, targetName);
31
+ getWidgetFiles(widgetsPath, targetPath);
32
+ return config;
33
+ });
34
+ }
35
+
22
36
  return withXcodeProject(config, (config) => {
23
37
  const xcodeProject = config.modResults;
24
38
  const widgetsPath = path.join(config.modRequest.projectRoot, widgetsFolder);