rn-linkrunner 0.1.0 → 0.2.1

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.
@@ -3,8 +3,64 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.multiply = multiply;
7
- function multiply(a, b) {
8
- return Promise.resolve(a * b);
9
- }
6
+ exports.default = void 0;
7
+ var _reactNativeDeviceInfo = _interopRequireDefault(require("react-native-device-info"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ let projet_token;
10
+ const package_version = '0.2.1';
11
+ const app_version = _reactNativeDeviceInfo.default.getVersion();
12
+ const init = token => {
13
+ if (!token) return console.error('Linkrunner needs your project token to initialize!');
14
+ fetch('http://localhost:4000/api/client/init', {
15
+ method: 'POST',
16
+ headers: {
17
+ 'Accept': 'application/json',
18
+ 'Content-Type': 'application/json'
19
+ },
20
+ body: JSON.stringify({
21
+ token,
22
+ package_version,
23
+ app_version
24
+ })
25
+ }).then(res => res.json()).then(result => {
26
+ if (!result) throw new Error('No response obtained!');
27
+ if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
28
+ throw new Error(result === null || result === void 0 ? void 0 : result.msg);
29
+ }
30
+ projet_token = token;
31
+ console.log('Linkrunner initialised successfully 🔥');
32
+ }).catch(err => {
33
+ console.error('Error initializing linkrunner: ', err.message);
34
+ });
35
+ };
36
+ const trigger = ({
37
+ data,
38
+ user_id
39
+ }) => {
40
+ fetch('http://localhost:4000/api/client/trigger', {
41
+ method: 'POST',
42
+ headers: {
43
+ 'Accept': 'application/json',
44
+ 'Content-Type': 'application/json'
45
+ },
46
+ body: JSON.stringify({
47
+ token: projet_token,
48
+ user_id,
49
+ data
50
+ })
51
+ }).then(res => res.json()).then(result => {
52
+ if (!result) throw new Error('No response obtained!');
53
+ if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
54
+ throw new Error(result === null || result === void 0 ? void 0 : result.msg);
55
+ }
56
+ console.log('Linkrunner: Trigger called 🔥');
57
+ }).catch(err => {
58
+ console.error('Error initializing linkrunner: ', err.message);
59
+ });
60
+ };
61
+ const linkrunner = {
62
+ init,
63
+ trigger
64
+ };
65
+ var _default = exports.default = linkrunner;
10
66
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["multiply","a","b","Promise","resolve"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAO,SAASA,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAmB;EAC9D,OAAOC,OAAO,CAACC,OAAO,CAACH,CAAC,GAAGC,CAAC,CAAC;AAC/B"}
1
+ {"version":3,"names":["_reactNativeDeviceInfo","_interopRequireDefault","require","obj","__esModule","default","projet_token","package_version","app_version","DeviceInfo","getVersion","init","token","console","error","fetch","method","headers","body","JSON","stringify","then","res","json","result","Error","status","msg","log","catch","err","message","trigger","data","user_id","linkrunner","_default","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAkD,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElD,IAAIG,YAAoB;AAExB,MAAMC,eAAe,GAAG,OAAO;AAC/B,MAAMC,WAAW,GAAGC,8BAAU,CAACC,UAAU,CAAC,CAAC;AAE3C,MAAMC,IAAI,GAAIC,KAAa,IAAK;EAC9B,IAAI,CAACA,KAAK,EACR,OAAOC,OAAO,CAACC,KAAK,CAAC,oDAAoD,CAAC;EAE5EC,KAAK,CAAC,uCAAuC,EAAE;IAC7CC,MAAM,EAAE,MAAM;IACdC,OAAO,EAAE;MACP,QAAQ,EAAE,kBAAkB;MAC5B,cAAc,EAAE;IAClB,CAAC;IACDC,IAA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AAAD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,MAAK,GAAG,IAAI,CAAAF,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,MAAK,GAAG,EAAE;MACpD,MAAM,IAAID,KAAK,CAACD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEG,GAAG,CAAC;IAC9B;IAEAd,OAAO,CAACe,GAAG,CAAC,+BAA+B,CAAC;EAC9C,CAAC,CAAC,CACDC,KAAK,CAAEC,GAAG,IAAK;IACdjB,OAAO,CAACC,KAAK,CAAC,iCAAiC,EAAEgB,GAAG,CAACC,OAAO,CAAC;EAC/D,CAAC,CAAC;AACN,CAAC;AAED,MAAMI,UAAU,GAAG;EACjBxB,IAAI;EACJqB;AACF,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAhC,OAAA,GAEa8B,UAAU"}
@@ -1,4 +1,59 @@
1
- export function multiply(a, b) {
2
- return Promise.resolve(a * b);
3
- }
1
+ import DeviceInfo from 'react-native-device-info';
2
+ let projet_token;
3
+ const package_version = '0.2.1';
4
+ const app_version = DeviceInfo.getVersion();
5
+ const init = token => {
6
+ if (!token) return console.error('Linkrunner needs your project token to initialize!');
7
+ fetch('http://localhost:4000/api/client/init', {
8
+ method: 'POST',
9
+ headers: {
10
+ 'Accept': 'application/json',
11
+ 'Content-Type': 'application/json'
12
+ },
13
+ body: JSON.stringify({
14
+ token,
15
+ package_version,
16
+ app_version
17
+ })
18
+ }).then(res => res.json()).then(result => {
19
+ if (!result) throw new Error('No response obtained!');
20
+ if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
21
+ throw new Error(result === null || result === void 0 ? void 0 : result.msg);
22
+ }
23
+ projet_token = token;
24
+ console.log('Linkrunner initialised successfully 🔥');
25
+ }).catch(err => {
26
+ console.error('Error initializing linkrunner: ', err.message);
27
+ });
28
+ };
29
+ const trigger = ({
30
+ data,
31
+ user_id
32
+ }) => {
33
+ fetch('http://localhost:4000/api/client/trigger', {
34
+ method: 'POST',
35
+ headers: {
36
+ 'Accept': 'application/json',
37
+ 'Content-Type': 'application/json'
38
+ },
39
+ body: JSON.stringify({
40
+ token: projet_token,
41
+ user_id,
42
+ data
43
+ })
44
+ }).then(res => res.json()).then(result => {
45
+ if (!result) throw new Error('No response obtained!');
46
+ if ((result === null || result === void 0 ? void 0 : result.status) !== 200 && (result === null || result === void 0 ? void 0 : result.status) !== 201) {
47
+ throw new Error(result === null || result === void 0 ? void 0 : result.msg);
48
+ }
49
+ console.log('Linkrunner: Trigger called 🔥');
50
+ }).catch(err => {
51
+ console.error('Error initializing linkrunner: ', err.message);
52
+ });
53
+ };
54
+ const linkrunner = {
55
+ init,
56
+ trigger
57
+ };
58
+ export default linkrunner;
4
59
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["multiply","a","b","Promise","resolve"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,OAAO,SAASA,QAAQA,CAACC,CAAS,EAAEC,CAAS,EAAmB;EAC9D,OAAOC,OAAO,CAACC,OAAO,CAACH,CAAC,GAAGC,CAAC,CAAC;AAC/B"}
1
+ {"version":3,"names":["DeviceInfo","projet_token","package_version","app_version","getVersion","init","token","console","error","fetch","method","headers","body","JSON","stringify","then","res","json","result","Error","status","msg","log","catch","err","message","trigger","data","user_id","linkrunner"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,OAAOA,UAAU,MAAM,0BAA0B;AAEjD,IAAIC,YAAoB;AAExB,MAAMC,eAAe,GAAG,OAAO;AAC/B,MAAMC,WAAW,GAAGH,UAAU,CAACI,UAAU,CAAC,CAAC;AAE3C,MAAMC,IAAI,GAAIC,KAAa,IAAK;EAC9B,IAAI,CAACA,KAAK,EACR,OAAOC,OAAO,CAACC,KAAK,CAAC,oDAAoD,CAAC;EAE5EC,KAAK,CAAC,uCAAuC,EAAE;IAC7CC,MAAM,EAAE,MAAM;IACdC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AChB,IAAI,CAACA,MAAM,EAAE,MAAM,IAAIC,KAAK,CAAC,uBAAuB,CAAC;IAErD,IAAI,CAAAD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,MAAK,GAAG,IAAI,CAAAF,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEE,MAAM,MAAK,GAAG,EAAE;MACpD,MAAM,IAAID,KAAK,CAACD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEG,GAAG,CAAC;IAC9B;IAEAd,OAAO,CAACe,GAAG,CAAC,+BAA+B,CAAC;EAC9C,CAAC,CAAC,CACDC,KAAK,CAAEC,GAAG,IAAK;IACdjB,OAAO,CAACC,KAAK,CAAC,iCAAiC,EAAEgB,GAAG,CAACC,OAAO,CAAC;EAC/D,CAAC,CAAC;AACN,CAAC;AAED,MAAMI,UAAU,GAAG;EACjBxB,IAAI;EACJqB;AACF,CAAC;AAED,eAAeG,UAAU"}
@@ -0,0 +1,9 @@
1
+ declare const linkrunner: {
2
+ init: (token: string) => void;
3
+ trigger: ({ data, user_id, }: {
4
+ user_id: string | number;
5
+ data: any;
6
+ }) => void;
7
+ };
8
+ export default linkrunner;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAyEA,QAAA,MAAM,UAAU;kBAlEK,MAAM;;iBAoChB,MAAM,GAAG,MAAM;cAClB,GAAG;;CAgCV,CAAC;AAEF,eAAe,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "rn-linkrunner",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "React Native Package for linkrunner",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
- "types": "lib/typescript/src/index.d.ts",
7
+ "types": "lib/typescript/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "files": [
@@ -26,8 +26,6 @@
26
26
  "!**/.*"
27
27
  ],
28
28
  "scripts": {
29
- "example": "yarn workspace rn-linkrunner-example",
30
- "test": "jest",
31
29
  "typecheck": "tsc --noEmit",
32
30
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
31
  "clean": "del-cli lib",
@@ -57,15 +55,14 @@
57
55
  "@evilmartians/lefthook": "^1.5.0",
58
56
  "@react-native/eslint-config": "^0.72.2",
59
57
  "@release-it/conventional-changelog": "^5.0.0",
60
- "@types/jest": "^28.1.2",
61
58
  "@types/react": "~17.0.21",
62
59
  "@types/react-native": "0.70.0",
60
+ "babel-eslint": "^10.1.0",
63
61
  "commitlint": "^17.0.2",
64
62
  "del-cli": "^5.0.0",
65
63
  "eslint": "^8.4.1",
66
64
  "eslint-config-prettier": "^8.5.0",
67
65
  "eslint-plugin-prettier": "^4.0.0",
68
- "jest": "^28.1.1",
69
66
  "prettier": "^2.0.5",
70
67
  "react": "18.2.0",
71
68
  "react-native": "0.72.6",
@@ -80,20 +77,10 @@
80
77
  "react": "*",
81
78
  "react-native": "*"
82
79
  },
83
- "workspaces": [
84
- "example"
85
- ],
86
- "packageManager": "yarn@3.6.1",
80
+ "packageManager": "yarn@1.22.21",
87
81
  "engines": {
88
82
  "node": ">= 18.0.0"
89
83
  },
90
- "jest": {
91
- "preset": "react-native",
92
- "modulePathIgnorePatterns": [
93
- "<rootDir>/example/node_modules",
94
- "<rootDir>/lib/"
95
- ]
96
- },
97
84
  "commitlint": {
98
85
  "extends": [
99
86
  "@commitlint/config-conventional"
@@ -109,11 +96,6 @@
109
96
  },
110
97
  "github": {
111
98
  "release": true
112
- },
113
- "plugins": {
114
- "@release-it/conventional-changelog": {
115
- "preset": "angular"
116
- }
117
99
  }
118
100
  },
119
101
  "eslintConfig": {
@@ -152,15 +134,10 @@
152
134
  "targets": [
153
135
  "commonjs",
154
136
  "module",
155
- [
156
- "typescript",
157
- {
158
- "project": "tsconfig.build.json"
159
- }
160
- ]
137
+ "typescript"
161
138
  ]
162
139
  },
163
- "directories": {
164
- "example": "example"
140
+ "dependencies": {
141
+ "react-native-device-info": "^10.12.0"
165
142
  }
166
143
  }
package/src/index.ts ADDED
@@ -0,0 +1,79 @@
1
+ import DeviceInfo from 'react-native-device-info';
2
+
3
+ let projet_token: string;
4
+
5
+ const package_version = '0.2.1';
6
+ const app_version = DeviceInfo.getVersion();
7
+
8
+ const init = (token: string) => {
9
+ if (!token)
10
+ return console.error('Linkrunner needs your project token to initialize!');
11
+
12
+ fetch('http://localhost:4000/api/client/init', {
13
+ method: 'POST',
14
+ headers: {
15
+ 'Accept': 'application/json',
16
+ 'Content-Type': 'application/json',
17
+ },
18
+ body: JSON.stringify({
19
+ token,
20
+ package_version,
21
+ app_version,
22
+ }),
23
+ })
24
+ .then((res) => res.json())
25
+ .then((result) => {
26
+ if (!result) throw new Error('No response obtained!');
27
+
28
+ if (result?.status !== 200 && result?.status !== 201) {
29
+ throw new Error(result?.msg);
30
+ }
31
+
32
+ projet_token = token;
33
+ console.log('Linkrunner initialised successfully 🔥');
34
+ })
35
+ .catch((err) => {
36
+ console.error('Error initializing linkrunner: ', err.message);
37
+ });
38
+ };
39
+
40
+ const trigger = ({
41
+ data,
42
+ user_id,
43
+ }: {
44
+ user_id: string | number;
45
+ data: any;
46
+ }) => {
47
+ fetch('http://localhost:4000/api/client/trigger', {
48
+ method: 'POST',
49
+ headers: {
50
+ 'Accept': 'application/json',
51
+ 'Content-Type': 'application/json',
52
+ },
53
+ body: JSON.stringify({
54
+ token: projet_token,
55
+ user_id,
56
+ data,
57
+ }),
58
+ })
59
+ .then((res) => res.json())
60
+ .then((result) => {
61
+ if (!result) throw new Error('No response obtained!');
62
+
63
+ if (result?.status !== 200 && result?.status !== 201) {
64
+ throw new Error(result?.msg);
65
+ }
66
+
67
+ console.log('Linkrunner: Trigger called 🔥');
68
+ })
69
+ .catch((err) => {
70
+ console.error('Error initializing linkrunner: ', err.message);
71
+ });
72
+ };
73
+
74
+ const linkrunner = {
75
+ init,
76
+ trigger,
77
+ };
78
+
79
+ export default linkrunner;
@@ -1,2 +0,0 @@
1
- export declare function multiply(a: number, b: number): Promise<number>;
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9D"}
package/src/index.tsx DELETED
@@ -1,3 +0,0 @@
1
- export function multiply(a: number, b: number): Promise<number> {
2
- return Promise.resolve(a * b);
3
- }