core-outline 0.0.3 → 0.0.5
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/dist/index.es.js +11 -14
- package/dist/index.js +11 -14
- package/package.json +6 -1
- package/src/lib/device/device.js +1 -11
- package/src/services/session/start-session.js +7 -17
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const uuid = require('uuid');
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const {
|
|
3
|
+
io: io$2
|
|
4
|
+
} = require('socket.io-client');
|
|
5
|
+
const socket$2 = io$2('http://localhost:4000');
|
|
6
|
+
function streamData$2(data) {
|
|
7
|
+
socket$2.emit('dataEvent', data);
|
|
4
8
|
}
|
|
5
9
|
const makeRequest = async ({
|
|
6
10
|
url,
|
|
@@ -24,21 +28,10 @@ async function getSessionLocation() {
|
|
|
24
28
|
});
|
|
25
29
|
return res;
|
|
26
30
|
}
|
|
27
|
-
const {
|
|
28
|
-
userAgent
|
|
29
|
-
} = navigator;
|
|
30
|
-
let device = "mobile";
|
|
31
|
-
const setDevice = dev => {
|
|
32
|
-
device = dev;
|
|
33
|
-
};
|
|
34
|
-
userAgent.includes("Mobi") ? setDevice("mobile") : setDevice("desktop");
|
|
35
|
-
const getDeviceInfo = () => {
|
|
36
|
-
return device;
|
|
37
|
-
};
|
|
38
31
|
const startSession = async () => {
|
|
39
32
|
let loc = await getSessionLocation();
|
|
40
33
|
let session = {
|
|
41
|
-
"session_id":
|
|
34
|
+
"session_id": uuid.v4(),
|
|
42
35
|
"start_time": Date.now(),
|
|
43
36
|
"end_time": null,
|
|
44
37
|
"device": getDeviceInfo()
|
|
@@ -48,6 +41,10 @@ const startSession = async () => {
|
|
|
48
41
|
...loc
|
|
49
42
|
};
|
|
50
43
|
console.log(session);
|
|
44
|
+
streamData$2({
|
|
45
|
+
"topic": "session-data",
|
|
46
|
+
"data": session
|
|
47
|
+
});
|
|
51
48
|
return session;
|
|
52
49
|
};
|
|
53
50
|
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const uuid = require('uuid');
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const {
|
|
7
|
+
io: io$2
|
|
8
|
+
} = require('socket.io-client');
|
|
9
|
+
const socket$2 = io$2('http://localhost:4000');
|
|
10
|
+
function streamData$2(data) {
|
|
11
|
+
socket$2.emit('dataEvent', data);
|
|
8
12
|
}
|
|
9
13
|
const makeRequest = async ({
|
|
10
14
|
url,
|
|
@@ -28,21 +32,10 @@ async function getSessionLocation() {
|
|
|
28
32
|
});
|
|
29
33
|
return res;
|
|
30
34
|
}
|
|
31
|
-
const {
|
|
32
|
-
userAgent
|
|
33
|
-
} = navigator;
|
|
34
|
-
let device = "mobile";
|
|
35
|
-
const setDevice = dev => {
|
|
36
|
-
device = dev;
|
|
37
|
-
};
|
|
38
|
-
userAgent.includes("Mobi") ? setDevice("mobile") : setDevice("desktop");
|
|
39
|
-
const getDeviceInfo = () => {
|
|
40
|
-
return device;
|
|
41
|
-
};
|
|
42
35
|
const startSession = async () => {
|
|
43
36
|
let loc = await getSessionLocation();
|
|
44
37
|
let session = {
|
|
45
|
-
"session_id":
|
|
38
|
+
"session_id": uuid.v4(),
|
|
46
39
|
"start_time": Date.now(),
|
|
47
40
|
"end_time": null,
|
|
48
41
|
"device": getDeviceInfo()
|
|
@@ -52,6 +45,10 @@ const startSession = async () => {
|
|
|
52
45
|
...loc
|
|
53
46
|
};
|
|
54
47
|
console.log(session);
|
|
48
|
+
streamData$2({
|
|
49
|
+
"topic": "session-data",
|
|
50
|
+
"data": session
|
|
51
|
+
});
|
|
55
52
|
return session;
|
|
56
53
|
};
|
|
57
54
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-outline",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "NPM package for react",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
"url": "https://github.com/Core-Outline/core-outline-npm/issues"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/Core-Outline/core-outline-npm#readme",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"socket.io-client": "^4.7.5",
|
|
27
|
+
"uuid": "^9.0.1",
|
|
28
|
+
"pouchdb": "^8.0.1"
|
|
29
|
+
},
|
|
25
30
|
"devDependencies": {
|
|
26
31
|
"@babel/preset-react": "^7.24.6",
|
|
27
32
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
package/src/lib/device/device.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
const { userAgent } = navigator;
|
|
2
|
-
let device="mobile"
|
|
3
|
-
|
|
4
|
-
const setDevice=(dev)=>{
|
|
5
|
-
device=dev
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
userAgent.includes("Mobi") ? setDevice("mobile") : setDevice("desktop");
|
|
9
|
-
|
|
10
|
-
|
|
11
1
|
const getDeviceInfo=()=>{
|
|
12
|
-
|
|
2
|
+
let device = "mobile"
|
|
13
3
|
return device
|
|
14
4
|
}
|
|
15
5
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const uuid = require('uuid')
|
|
2
|
+
const { io} = require('socket.io-client');
|
|
3
|
+
const socket = io('http://localhost:4000');
|
|
2
4
|
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
return uuid.v4()
|
|
5
|
+
function streamData(data){
|
|
6
|
+
socket.emit('dataEvent', data);
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
const makeRequest = async ({
|
|
@@ -28,24 +29,11 @@ async function getSessionLocation()
|
|
|
28
29
|
return res
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
const { userAgent } = navigator;
|
|
32
|
-
let device="mobile"
|
|
33
|
-
|
|
34
|
-
const setDevice=(dev)=>{
|
|
35
|
-
device=dev
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
userAgent.includes("Mobi") ? setDevice("mobile") : setDevice("desktop");
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const getDeviceInfo=()=>{
|
|
42
|
-
return device
|
|
43
|
-
}
|
|
44
32
|
|
|
45
33
|
const startSession = async() =>{
|
|
46
34
|
let loc = await getSessionLocation()
|
|
47
35
|
let session = {
|
|
48
|
-
"session_id":
|
|
36
|
+
"session_id": uuid.v4(),
|
|
49
37
|
"start_time": Date.now(),
|
|
50
38
|
"end_time" : null,
|
|
51
39
|
"device": getDeviceInfo(),
|
|
@@ -53,6 +41,8 @@ const startSession = async() =>{
|
|
|
53
41
|
session = { ...session, ...loc}
|
|
54
42
|
console.log(session)
|
|
55
43
|
|
|
44
|
+
streamData({"topic":"session-data", "data" : session })
|
|
45
|
+
|
|
56
46
|
return session
|
|
57
47
|
}
|
|
58
48
|
|