@altcraft/react-native-sdk 0.0.4 → 1.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.
Files changed (53) hide show
  1. package/LICENSE +48 -20
  2. package/README.md +21 -120
  3. package/autolink.js +36 -0
  4. package/lib/commonjs/altcraft_sdk.js +297 -0
  5. package/lib/commonjs/altcraft_sdk.js.map +1 -0
  6. package/lib/commonjs/index.js +192 -0
  7. package/lib/commonjs/index.js.map +1 -0
  8. package/lib/commonjs/package.json +1 -0
  9. package/lib/module/altcraft_sdk.js +292 -0
  10. package/lib/module/altcraft_sdk.js.map +1 -0
  11. package/lib/module/index.js +13 -427
  12. package/lib/module/index.js.map +1 -1
  13. package/lib/typescript/commonjs/package.json +1 -0
  14. package/lib/typescript/commonjs/src/altcraft_sdk.d.ts +143 -0
  15. package/lib/typescript/commonjs/src/altcraft_sdk.d.ts.map +1 -0
  16. package/lib/typescript/commonjs/src/index.d.ts +24 -0
  17. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  18. package/lib/typescript/module/src/altcraft_sdk.d.ts +143 -0
  19. package/lib/typescript/module/src/altcraft_sdk.d.ts.map +1 -0
  20. package/lib/typescript/module/src/index.d.ts +24 -0
  21. package/lib/typescript/module/src/index.d.ts.map +1 -0
  22. package/package.json +49 -95
  23. package/scripts/postinstall.cjs +195 -0
  24. package/src/altcraft_sdk.ts +337 -0
  25. package/src/index.ts +91 -0
  26. package/Sdk.podspec +0 -48
  27. package/android/build.gradle +0 -77
  28. package/android/gradle.properties +0 -5
  29. package/android/src/main/AndroidManifest.xml +0 -2
  30. package/android/src/main/java/com/altcraft/sdk/SdkEventEmitter.kt +0 -50
  31. package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +0 -949
  32. package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +0 -41
  33. package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +0 -326
  34. package/android/src/main/java/com/altcraft/sdk/utilities/Extension.kt +0 -72
  35. package/ios/Converter.swift +0 -640
  36. package/ios/Sdk.h +0 -20
  37. package/ios/Sdk.mm +0 -979
  38. package/ios/SdkModule.swift +0 -778
  39. package/lib/module/NativeSdk.js +0 -48
  40. package/lib/module/NativeSdk.js.map +0 -1
  41. package/lib/module/Utilities.js +0 -178
  42. package/lib/module/Utilities.js.map +0 -1
  43. package/lib/typescript/src/NativeSdk.d.ts +0 -215
  44. package/lib/typescript/src/NativeSdk.d.ts.map +0 -1
  45. package/lib/typescript/src/Utilities.d.ts +0 -47
  46. package/lib/typescript/src/Utilities.d.ts.map +0 -1
  47. package/lib/typescript/src/index.d.ts +0 -252
  48. package/lib/typescript/src/index.d.ts.map +0 -1
  49. package/react-native.config.js +0 -10
  50. package/src/NativeSdk.ts +0 -313
  51. package/src/Utilities.ts +0 -180
  52. package/src/index.tsx +0 -570
  53. /package/lib/typescript/{package.json → module/package.json} +0 -0
@@ -0,0 +1,143 @@
1
+ import type { AltcraftConfig, CategoryData, ResponseWithHttpCode } from '@altcraft/core';
2
+ import type { InAppAnimationConfig, InAppAnimationEasing, InAppAnimationSpec, InAppSubscribeOptions, JsonContentApi, JsonContentHandler } from '@altcraft/inapp';
3
+ import type { UpdateProfileOptions } from '@altcraft/profile';
4
+ import type { PushEventOptions, PushSubscribeOptions, TokenData } from '@altcraft/push';
5
+ import type { MobileEventOptions, Subscription, UTM } from '@altcraft/target';
6
+ import type { SdkEvent } from '@altcraft/core';
7
+ /**
8
+ * Main entry point for the Altcraft SDK.
9
+ *
10
+ * All SDK operations are accessed through this class's static methods.
11
+ * The package is a pure-JS facade: initialization is delegated to
12
+ * `AltcraftCore.initialize`, and all other operations are delegated to the
13
+ * module packages ({@link AltcraftCore}, {@link AltcraftPush},
14
+ * {@link AltcraftInApp}, {@link AltcraftTarget}, {@link AltcraftProfile}).
15
+ * There is no umbrella native module; module options are applied through
16
+ * `AltcraftConfigBuilder` extensions.
17
+ *
18
+ * ```ts
19
+ * import { AltcraftSDK } from 'altcraft';
20
+ *
21
+ * // Initialize
22
+ * await AltcraftSDK.initialize({
23
+ * apiUrl: 'https://your-api.altcraft.com',
24
+ * appInfo: { appID: 'firebase-app-id', appIID: 'firebase-instance-id', appVer: '1.0.0' },
25
+ * });
26
+ *
27
+ * // Subscribe to push
28
+ * AltcraftSDK.pushSubscribe({ sync: true });
29
+ *
30
+ * // Listen to SDK events
31
+ * AltcraftSDK.subscribeToEvents((event) => {
32
+ * console.log(`${event.function}: ${event.message}`);
33
+ * });
34
+ * ```
35
+ *
36
+ * Module-specific options are added through `AltcraftConfigBuilder` extensions
37
+ * and applied by `AltcraftCore.initialize`:
38
+ *
39
+ * ```ts
40
+ * import { AltcraftConfigBuilder, AltcraftCore } from '@altcraft/core';
41
+ * import '@altcraft/inapp';
42
+ * import '@altcraft/push';
43
+ *
44
+ * await AltcraftCore.initialize(
45
+ * new AltcraftConfigBuilder({ apiUrl: 'https://your-api.altcraft.com' })
46
+ * .pushConfig({ providerPriority: ['android-firebase'] })
47
+ * .inAppConfig({ maxPlacements: 50 })
48
+ * .build()
49
+ * );
50
+ * ```
51
+ */
52
+ export declare class AltcraftSDK {
53
+ /** Provides access to In-App placements with JSON content. */
54
+ static readonly jsonContent: JsonContentApi;
55
+ /**
56
+ * Initializes the Altcraft SDK with the given configuration.
57
+ *
58
+ * Delegates to `AltcraftCore.initialize`. For module-specific options use
59
+ * `AltcraftConfigBuilder` and the module extensions (`pushConfig`,
60
+ * `inAppConfig`).
61
+ */
62
+ static initialize(config: AltcraftConfig): Promise<void>;
63
+ /** Subscribes to push notifications. */
64
+ static pushSubscribe(options?: PushSubscribeOptions): Promise<void>;
65
+ /** Suspends push subscription. */
66
+ static pushSuspend(options?: PushSubscribeOptions): Promise<void>;
67
+ /** Unsubscribes from push notifications. */
68
+ static pushUnSubscribe(options?: PushSubscribeOptions): Promise<void>;
69
+ /** UnSuspends a previously suspended push subscription. */
70
+ static unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null>;
71
+ /** Subscribes to In-App notifications. */
72
+ static inAppSubscribe(options?: InAppSubscribeOptions): Promise<void>;
73
+ /** Unsubscribes from In-App notifications. */
74
+ static inAppUnsubscribe(options?: InAppSubscribeOptions): Promise<void>;
75
+ /** Gets the status of the latest subscription. */
76
+ static getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null>;
77
+ /** Gets the status of the current subscription. */
78
+ static getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null>;
79
+ /** Gets the status of the latest subscription for a specific provider. */
80
+ static getStatusOfLatestSubscriptionForProvider(provider?: string | null): Promise<ResponseWithHttpCode | null>;
81
+ /** Subscribes to SDK events stream. */
82
+ static subscribeToEvents(handler: (event: SdkEvent) => void): void;
83
+ /** Unsubscribes from SDK events. */
84
+ static unsubscribeFromEvents(handler: (event: SdkEvent) => void): void;
85
+ /** Sends a mobile event to the Altcraft platform. */
86
+ static sendTarget(options: MobileEventOptions): void;
87
+ /** Gets the current push token data. */
88
+ static getPushToken(): Promise<TokenData | null>;
89
+ /** Sets or clears a push token for the given provider. */
90
+ static setPushToken(provider: string, token: string | null): void;
91
+ /** Clears all SDK state. */
92
+ static clear(): Promise<void>;
93
+ /** Forwards a push payload to the SDK (Android). */
94
+ static takePush(message: Record<string, string>): void;
95
+ /** Requests notification permission (Android). Returns true if granted. */
96
+ static requestNotificationPermission(): Promise<boolean>;
97
+ /** Reports push delivery (Android). */
98
+ static deliveryEvent(options?: PushEventOptions): void;
99
+ /** Reports push open (Android). */
100
+ static openEvent(options?: PushEventOptions): void;
101
+ /**
102
+ * Stores a string value in native storage (UserDefaults on iOS,
103
+ * SharedPreferences on Android).
104
+ *
105
+ * On iOS, `suiteName` selects the App Group UserDefaults suite.
106
+ * On Android, `suiteName` is ignored.
107
+ */
108
+ static setUserDefaultsValue(suiteName: string | null, key: string, value: string | null): void;
109
+ /** Updates profile fields on the server. */
110
+ static updateProfileFields(options?: UpdateProfileOptions): void;
111
+ /** Forces a token refresh. */
112
+ static forcedTokenUpdate(): Promise<void>;
113
+ /** Deletes a device token for the given provider. */
114
+ static deleteDeviceToken(provider: string): Promise<void>;
115
+ /** Changes the push provider priority list. */
116
+ static changePushProviderPriorityList(priorityList: string[]): Promise<void>;
117
+ /** Checks if a push message is from Altcraft. */
118
+ static isAltcraftPush(message: Record<string, string>): boolean;
119
+ /** Unlocks initial operations in the current session (Android). */
120
+ static unlockInitialOperationsInThisSession(): void;
121
+ /** Sets the App Group for UserDefaults (iOS). */
122
+ static setAppGroup(groupName: string | null): void;
123
+ /** Registers a JWT provider that the native SDK calls when it needs a token. */
124
+ static setJwtProvider(provider: () => Promise<string | null>): void;
125
+ /** Starts SDK authentication. */
126
+ static authenticate(): void;
127
+ /** Logs the user out. */
128
+ static logOut(): void;
129
+ /** Returns whether the user is authenticated. */
130
+ static isAuthenticated(): Promise<boolean>;
131
+ /** Sets the current screen for In-App placement matching. */
132
+ static setScreen(screen: string): void;
133
+ /** Fires an In-App trigger by name. */
134
+ static trigger(name: string): void;
135
+ /** Requests In-App placements. */
136
+ static getPlacements(): void;
137
+ /** Sets or clears the In-App show animation configuration. */
138
+ static setAnimation(config: InAppAnimationConfig | null): void;
139
+ /** Disables the In-App show animation. */
140
+ static clearAnimation(): void;
141
+ }
142
+ export type { AltcraftConfig, CategoryData, InAppAnimationConfig, InAppAnimationEasing, InAppAnimationSpec, InAppSubscribeOptions, JsonContentApi, JsonContentHandler, MobileEventOptions, PushEventOptions, PushSubscribeOptions, ResponseWithHttpCode, SdkEvent, Subscription, TokenData, UpdateProfileOptions, UTM, };
143
+ //# sourceMappingURL=altcraft_sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"altcraft_sdk.d.ts","sourceRoot":"","sources":["../../../../src/altcraft_sdk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,kB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B,GAAG,IAAI,GAAG,IAAI;IAI9D,0CAA0C;IAC1C,MAAM,CAAC,cAAc,IAAI,IAAI;CAG9B;AAED,YAAY,EACV,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,GAAG,GACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Altcraft SDK for React Native.
3
+ *
4
+ * Umbrella package for the Altcraft push notification platform. Provides the
5
+ * full `AltcraftSDK` API as a pure-JS facade over the connected modules
6
+ * (initialization is delegated to `@altcraft/core`).
7
+ *
8
+ * For modular usage, depend on the individual module packages instead:
9
+ * `@altcraft/core`, `@altcraft/push`, `@altcraft/inapp`, `@altcraft/target`,
10
+ * `@altcraft/profile`.
11
+ */
12
+ export { AltcraftSDK } from './altcraft_sdk';
13
+ export { AltcraftCore, AltcraftCorePlatform, TurboModuleAltcraftCore, AltcraftChannels, actionField, ActionFieldBuilder, Utilities, AltcraftException, coreModuleEvents, } from '@altcraft/core';
14
+ export type { CoreModuleEvents } from '@altcraft/core';
15
+ export { AltcraftPush, AltcraftPushPlatform, TurboModuleAltcraftPush, pushModuleEvents, } from '@altcraft/push';
16
+ export type { PushSubscribeOptions, PushEventOptions, PushModuleEvents, TokenData, } from '@altcraft/push';
17
+ export { AltcraftInApp, AltcraftInAppPlatform, TurboModuleAltcraftInApp, inAppModuleEvents, } from '@altcraft/inapp';
18
+ export type { InAppAnimationConfig, InAppAnimationEasing, InAppAnimationSpec, InAppSubscribeOptions, InAppModuleEvents, JsonContentApi, JsonContentHandler, } from '@altcraft/inapp';
19
+ export { AltcraftTarget, AltcraftTargetPlatform, TurboModuleAltcraftTarget, targetModuleEvents, emailSubscription, smsSubscription, pushSubscription, ccDataSubscription, } from '@altcraft/target';
20
+ export type { MobileEventOptions, TargetModuleEvents, Subscription, EmailSubscription, SmsSubscription, PushSubscription, CcDataSubscription, UTM, } from '@altcraft/target';
21
+ export { AltcraftProfile, AltcraftProfilePlatform, TurboModuleAltcraftProfile, profileModuleEvents, } from '@altcraft/profile';
22
+ export type { UpdateProfileOptions, ProfileModuleEvents } from '@altcraft/profile';
23
+ export type { AltcraftConfig, AppInfo, CategoryData, ResponseWithHttpCode, SdkEvent, } from '@altcraft/core';
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,GAAG,GACJ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEnF,YAAY,EACV,cAAc,EACd,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,QAAQ,GACT,MAAM,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,89 +1,65 @@
1
1
  {
2
2
  "name": "@altcraft/react-native-sdk",
3
- "version": "0.0.4",
4
- "description": "Altcraft Platform SDK for React Native",
5
- "main": "./lib/module/index.js",
6
- "types": "./lib/typescript/src/index.d.ts",
3
+ "version": "1.0.0",
4
+ "description": "Altcraft React Native SDK (umbrella package with the full SDK API)",
5
+ "author": "Altcraft (https://altcraft.com)",
6
+ "homepage": "https://github.com/altcraft/react-native-sdk",
7
+ "license": "SEE LICENSE IN LICENSE",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/altcraft/react-native-sdk.git",
11
+ "directory": "packages/altcraft"
12
+ },
13
+ "source": "./src/index.ts",
14
+ "main": "./lib/commonjs/index.js",
15
+ "module": "./lib/module/index.js",
16
+ "react-native": "./src/index.ts",
17
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
7
18
  "exports": {
8
19
  ".": {
9
- "source": "./src/index.tsx",
10
- "types": "./lib/typescript/src/index.d.ts",
20
+ "source": "./src/index.ts",
21
+ "react-native": "./src/index.ts",
22
+ "import": {
23
+ "types": "./lib/typescript/module/src/index.d.ts",
24
+ "default": "./lib/module/index.js"
25
+ },
26
+ "require": {
27
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
28
+ "default": "./lib/commonjs/index.js"
29
+ },
11
30
  "default": "./lib/module/index.js"
12
31
  },
32
+ "./autolink": "./autolink.js",
13
33
  "./package.json": "./package.json"
14
34
  },
15
35
  "files": [
16
- "src",
17
36
  "lib",
18
- "android",
19
- "ios",
20
- "cpp",
21
- "*.podspec",
22
- "react-native.config.js",
23
- "!ios/build",
24
- "!android/build",
25
- "!android/gradle",
26
- "!android/gradlew",
27
- "!android/gradlew.bat",
28
- "!android/local.properties",
29
- "!**/__tests__",
30
- "!**/__fixtures__",
31
- "!**/__mocks__",
32
- "!**/.*"
37
+ "src",
38
+ "LICENSE",
39
+ "README.md",
40
+ "autolink.js",
41
+ "scripts"
33
42
  ],
34
43
  "scripts": {
35
- "example": "yarn workspace react-native-sdk-example",
36
- "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
37
- "prepare": "bob build",
38
- "typecheck": "tsc",
39
- "lint": "eslint \"**/*.{js,ts,tsx}\""
40
- },
41
- "keywords": [
42
- "react-native",
43
- "altcraft",
44
- "push",
45
- "sdk"
46
- ],
47
- "repository": {
48
- "type": "git",
49
- "url": "git+https://github.com/altcraft/react-native-sdk.git"
50
- },
51
- "author": "Altcraft <contact@altcraft.com> (https://altcraft.com)",
52
- "license": "MIT",
53
- "bugs": {
54
- "url": "https://github.com/altcraft/react-native-sdk/issues"
44
+ "build": "bob build",
45
+ "typecheck": "tsc --noEmit -p tsconfig.json",
46
+ "prepack": "npm run build",
47
+ "postinstall": "node ./scripts/postinstall.cjs"
55
48
  },
56
- "homepage": "https://github.com/altcraft/react-native-sdk#readme",
57
- "publishConfig": {
58
- "registry": "https://registry.npmjs.org/"
59
- },
60
- "devDependencies": {
61
- "@eslint/compat": "^1.3.2",
62
- "@eslint/eslintrc": "^3.3.1",
63
- "@eslint/js": "^9.35.0",
64
- "@react-native-community/cli": "20.0.1",
65
- "@react-native/babel-preset": "0.81.1",
66
- "@react-native/eslint-config": "^0.81.1",
67
- "@types/react": "^19.1.0",
68
- "del-cli": "^6.0.0",
69
- "eslint": "^9.35.0",
70
- "eslint-config-prettier": "^10.1.8",
71
- "eslint-plugin-prettier": "^5.5.4",
72
- "prettier": "^3.0.0",
73
- "react": "19.1.0",
74
- "react-native": "0.81.1",
75
- "react-native-builder-bob": "^0.40.16",
76
- "turbo": "^2.5.6",
77
- "typescript": "^5.9.2"
49
+ "dependencies": {
50
+ "@altcraft/core": "^1.0.0",
51
+ "@altcraft/push": "^1.0.0",
52
+ "@altcraft/inapp": "^1.0.0",
53
+ "@altcraft/target": "^1.0.0",
54
+ "@altcraft/profile": "^1.0.0"
78
55
  },
79
56
  "peerDependencies": {
80
57
  "react": "*",
81
- "react-native": "*"
58
+ "react-native": ">=0.75"
59
+ },
60
+ "publishConfig": {
61
+ "access": "public"
82
62
  },
83
- "workspaces": [
84
- "example"
85
- ],
86
- "packageManager": "yarn@4.11.0",
87
63
  "react-native-builder-bob": {
88
64
  "source": "src",
89
65
  "output": "lib",
@@ -95,34 +71,12 @@
95
71
  }
96
72
  ],
97
73
  [
98
- "typescript",
74
+ "commonjs",
99
75
  {
100
- "project": "tsconfig.build.json"
76
+ "esm": true
101
77
  }
102
- ]
78
+ ],
79
+ "typescript"
103
80
  ]
104
- },
105
- "codegenConfig": {
106
- "name": "Sdk",
107
- "type": "modules",
108
- "jsSrcsDir": "src",
109
- "android": {
110
- "javaPackageName": "com.altcraft.sdk"
111
- }
112
- },
113
- "prettier": {
114
- "quoteProps": "consistent",
115
- "singleQuote": true,
116
- "tabWidth": 2,
117
- "trailingComma": "es5",
118
- "useTabs": false
119
- },
120
- "create-react-native-library": {
121
- "languages": "kotlin-objc",
122
- "type": "turbo-module",
123
- "tools": [
124
- "eslint"
125
- ],
126
- "version": "0.55.1"
127
81
  }
128
82
  }
@@ -0,0 +1,195 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const MARKER = '/* @altcraft-autolink:start */';
7
+ const CONFIG_SEARCH = [
8
+ 'react-native.config.js',
9
+ 'react-native.config.cjs',
10
+ 'react-native.config.ts',
11
+ 'react-native.config.mjs',
12
+ ];
13
+
14
+ const CONFIG_BLOCK = `${MARKER}
15
+ try {
16
+ const { dependencies } = require('@altcraft/react-native-sdk/autolink');
17
+ if (module.exports && typeof module.exports === 'object') {
18
+ module.exports.dependencies = Object.assign(
19
+ {},
20
+ dependencies,
21
+ module.exports.dependencies
22
+ );
23
+ } else {
24
+ console.warn(
25
+ '[altcraft] react-native.config.js does not export an object; native autolinking was not configured.'
26
+ );
27
+ }
28
+ } catch (error) {
29
+ console.warn(
30
+ '[altcraft] Failed to configure native autolinking:',
31
+ error && error.message ? error.message : error
32
+ );
33
+ }
34
+ /* @altcraft-autolink:end */`;
35
+
36
+ const CONFIG_TEMPLATE = `'use strict';
37
+
38
+ let dependencies = {};
39
+ try {
40
+ ({ dependencies } = require('@altcraft/react-native-sdk/autolink'));
41
+ } catch (error) {
42
+ console.warn(
43
+ '[altcraft] Failed to configure native autolinking:',
44
+ error && error.message ? error.message : error
45
+ );
46
+ }
47
+
48
+ module.exports = {
49
+ dependencies,
50
+ };
51
+ `;
52
+
53
+ function log(message) {
54
+ console.log(`[altcraft] ${message}`);
55
+ }
56
+
57
+ function warn(message) {
58
+ console.warn(`[altcraft] ${message}`);
59
+ }
60
+
61
+ function findConfig(appRoot) {
62
+ for (const name of CONFIG_SEARCH) {
63
+ const filepath = path.join(appRoot, name);
64
+ if (fs.existsSync(filepath)) {
65
+ return { filepath, name };
66
+ }
67
+ }
68
+
69
+ return null;
70
+ }
71
+
72
+ function hasEsmSyntax(content) {
73
+ return /^\s*export\s/m.test(content);
74
+ }
75
+
76
+ function writeNewConfig(appRoot) {
77
+ const filepath = path.join(appRoot, 'react-native.config.js');
78
+ fs.writeFileSync(filepath, CONFIG_TEMPLATE);
79
+ log('created react-native.config.js for native module autolinking');
80
+ }
81
+
82
+ function appendToConfig(filepath) {
83
+ const content = fs.readFileSync(filepath, 'utf8');
84
+
85
+ if (content.includes(MARKER)) {
86
+ return false;
87
+ }
88
+
89
+ if (hasEsmSyntax(content)) {
90
+ warn(
91
+ `${path.basename(filepath)} uses ESM syntax; add the @altcraft autolink block manually.`
92
+ );
93
+ return false;
94
+ }
95
+
96
+ const separator = content.endsWith('\n') ? '\n' : '\n\n';
97
+ fs.writeFileSync(filepath, `${content}${separator}${CONFIG_BLOCK}\n`);
98
+ log(`updated ${path.basename(filepath)} for native module autolinking`);
99
+ return true;
100
+ }
101
+
102
+ function writeCjsWrapper(appRoot, cjsPath) {
103
+ const wrapperPath = path.join(appRoot, 'react-native.config.js');
104
+ const content = `'use strict';
105
+
106
+ const base = require('./${path.basename(cjsPath)}');
107
+ let dependencies = {};
108
+ try {
109
+ ({ dependencies } = require('@altcraft/react-native-sdk/autolink'));
110
+ } catch (error) {
111
+ console.warn(
112
+ '[altcraft] Failed to configure native autolinking:',
113
+ error && error.message ? error.message : error
114
+ );
115
+ }
116
+
117
+ module.exports = {
118
+ ...base,
119
+ dependencies: Object.assign({}, dependencies, base && base.dependencies),
120
+ };
121
+ `;
122
+
123
+ fs.writeFileSync(wrapperPath, content);
124
+ log('created react-native.config.js wrapper for Codegen and autolinking');
125
+ }
126
+
127
+ function main() {
128
+ if (process.env.ALTCRAFT_SKIP_AUTOLINK === '1') {
129
+ return;
130
+ }
131
+
132
+ const appRoot = process.env.INIT_CWD || process.env.npm_config_local_prefix;
133
+
134
+ if (!appRoot) {
135
+ return;
136
+ }
137
+
138
+ const packageRoot = path.resolve(__dirname, '..');
139
+ const repoRoot = path.resolve(packageRoot, '..', '..');
140
+
141
+ if (path.resolve(appRoot) === repoRoot) {
142
+ return;
143
+ }
144
+
145
+ const appPackagePath = path.join(appRoot, 'package.json');
146
+ if (!fs.existsSync(appPackagePath)) {
147
+ return;
148
+ }
149
+
150
+ const appPackage = JSON.parse(fs.readFileSync(appPackagePath, 'utf8'));
151
+ const appDependencies = {
152
+ ...appPackage.dependencies,
153
+ ...appPackage.devDependencies,
154
+ };
155
+
156
+ if (!appDependencies['@altcraft/react-native-sdk']) {
157
+ return;
158
+ }
159
+
160
+ const modulePackages = require('../autolink').packages;
161
+ if (modulePackages.every((name) => appDependencies[name])) {
162
+ return;
163
+ }
164
+
165
+ const config = findConfig(appRoot);
166
+
167
+ if (!config) {
168
+ writeNewConfig(appRoot);
169
+ return;
170
+ }
171
+
172
+ if (config.name === 'react-native.config.js') {
173
+ appendToConfig(config.filepath);
174
+ return;
175
+ }
176
+
177
+ if (config.name === 'react-native.config.cjs') {
178
+ writeCjsWrapper(appRoot, config.filepath);
179
+ return;
180
+ }
181
+
182
+ warn(
183
+ `${config.name} is not supported for automatic autolinking. Add the @altcraft autolink block manually.`
184
+ );
185
+ }
186
+
187
+ try {
188
+ main();
189
+ } catch (error) {
190
+ warn(
191
+ `postinstall autolinking setup failed: ${
192
+ error && error.message ? error.message : error
193
+ }`
194
+ );
195
+ }