@huawei-ide/codearts 1.0.34 → 1.0.36

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 (3) hide show
  1. package/index.js +25 -4
  2. package/package.json +1 -1
  3. package/util.js +13 -0
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { EventEmitter } from './util'
1
+ import { EventEmitter, getOS } from './util'
2
2
 
3
3
  let hcOrigin = '';
4
4
  if (window.location.origin.endsWith('.net')) {
@@ -8,8 +8,9 @@ if (window.location.origin.endsWith('.net')) {
8
8
  }
9
9
  const iframe = document.createElement('iframe');
10
10
  iframe.id = 'codeartside';
11
- iframe.src = hcOrigin + '/codearts-core-web-static/1.0.55/resources/server/gitcode.html';
11
+ iframe.src = hcOrigin + '/codearts-core-web-static/1.0.58/resources/server/gitcode.html';
12
12
 
13
+ const OS = getOS();
13
14
  const ON_DID_CHANGE = 'onDidChange';
14
15
  const eventEmitter = new EventEmitter();
15
16
 
@@ -65,13 +66,13 @@ export function preload() {
65
66
 
66
67
  // style: { width: string, height: string }
67
68
  export function show(id, style) {
68
- var targetNode = document.getElementById(id);
69
- targetNode.appendChild(iframe);
70
69
  const { width, height } = style;
71
70
  iframe.width = width;
72
71
  iframe.height = height;
73
72
  iframe.style.opacity = 1;
74
73
  iframe.style.zIndex = 1;
74
+ var targetNode = document.getElementById(id);
75
+ targetNode.appendChild(iframe);
75
76
  return ideLoading();
76
77
  }
77
78
 
@@ -107,6 +108,26 @@ export function getContent() {
107
108
  }
108
109
 
109
110
  export function setUserId(domainId, userId) {
111
+ const url = 'https://cloudide.cn-north-4.myhuaweicloud.com/v1/ca/behavior/codearts-record';
112
+ const body = JSON.stringify({
113
+ 'scope': 'gitcode-repo',
114
+ 'action': 'setUserId',
115
+ 'data': null,
116
+ 'platform': 'websdk.3.0.0',
117
+ 'machine_code': 'codearts0machinecodearts0machinecodearts0machinecodearts0machine',
118
+ 'scenario': 'WEBSDK',
119
+ 'os': OS,
120
+ 'arch': 'webide',
121
+ 'domain_id': domainId,
122
+ 'user_id': userId,
123
+ 'identifier': 'ide'
124
+ });
125
+ fetch(url, {
126
+ method: 'PUT',
127
+ headers: { 'Content-Type': 'application/json', 'Content-Length': body.length },
128
+ body,
129
+ });
130
+
110
131
  const message = {
111
132
  type: 'setUserId',
112
133
  data: { domainId, userId }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huawei-ide/codearts",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/util.js CHANGED
@@ -27,4 +27,17 @@ export class EventEmitter {
27
27
  clear() {
28
28
  this.events = {};
29
29
  }
30
+ }
31
+
32
+ export function getOS() {
33
+ const userAgent = navigator.userAgent.toLowerCase();
34
+ if (userAgent.indexOf('windows') !== -1) {
35
+ return 'win';
36
+ } else if (userAgent.indexOf('mac') !== -1) {
37
+ return 'darwin';
38
+ } else if (userAgent.indexOf('linux') !== -1) {
39
+ return 'linux';
40
+ } else {
41
+ return 'unknown';
42
+ }
30
43
  }