hanbiro-react16-sdk 1.0.31 → 1.0.33

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.
@@ -1,6 +1,7 @@
1
1
  interface apiGetOptions {
2
2
  headers: any;
3
3
  }
4
+ export declare const getSigner: () => any;
4
5
  export declare const apiGet: (url: string, opts?: apiGetOptions) => Promise<{
5
6
  data: any;
6
7
  code: number;
package/dist/utils/api.js CHANGED
@@ -35,12 +35,24 @@ var __async = (__this, __arguments, generator) => {
35
35
  });
36
36
  };
37
37
  import { getBaseUrl } from "./url.js";
38
+ import { ClientSigner as W } from "../node_modules/@hanbiro/signer-core/dist/index.js";
39
+ const getSigner = () => {
40
+ const existed = window == null ? void 0 : window.HanSigCommon;
41
+ if (existed) {
42
+ return existed;
43
+ } else {
44
+ return new W({ baseUrl: getBaseUrl() });
45
+ }
46
+ };
38
47
  const apiGet = (url, opts) => __async(void 0, null, function* () {
48
+ var _a;
49
+ const sigConfig = { method: "POST", baseURL: getBaseUrl(), url };
50
+ const sigHeaders = yield (_a = getSigner()) == null ? void 0 : _a.generateHeaders(sigConfig);
39
51
  const response = yield fetch(getBaseUrl() + url, {
40
- headers: __spreadValues({
52
+ headers: __spreadValues(__spreadValues({
41
53
  Accept: "application/json, text/plain, */*",
42
54
  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
43
- }, opts == null ? void 0 : opts.headers)
55
+ }, opts == null ? void 0 : opts.headers), sigHeaders)
44
56
  });
45
57
  let data = null;
46
58
  if (response.ok) {
@@ -51,5 +63,6 @@ const apiGet = (url, opts) => __async(void 0, null, function* () {
51
63
  return { data, code: response.status, ok: response.ok };
52
64
  });
53
65
  export {
54
- apiGet
66
+ apiGet,
67
+ getSigner
55
68
  };
@@ -1 +1 @@
1
- export { initHanbiroReactSDK, setLibLang } from './url';
1
+ export { getAppVersion } from './url';
@@ -1 +1 @@
1
- export declare const getCurrentLang: () => string;
1
+ export declare const CURRENT_LANG: string;
@@ -25,6 +25,7 @@ function getBrowserLang(shortCode = true) {
25
25
  const getCurrentLang = () => {
26
26
  return localStorageService.get(LOCAL_STORAGE_KEY.LANG_CODE) || getBrowserLang(true);
27
27
  };
28
+ const CURRENT_LANG = getCurrentLang();
28
29
  export {
29
- getCurrentLang
30
+ CURRENT_LANG
30
31
  };
@@ -1,13 +1,5 @@
1
- interface SDKConfig {
2
- baseUrl: string;
3
- signer: any | null;
4
- lang?: string;
5
- }
6
- export declare const SDKConfig: SDKConfig;
7
1
  export declare const getAppVersion: () => "v2" | "v3";
8
- export declare const initHanbiroReactSDK: ({ baseUrl, signer }: SDKConfig) => void;
9
- export declare const setLibLang: (lang: string) => void;
2
+ export declare const applyVersionAttribute: () => void;
10
3
  export declare const isDevelopment: boolean;
11
4
  export declare const getBaseUrl: () => string;
12
5
  export declare const getGroupwareUrl: () => string;
13
- export {};
package/dist/utils/url.js CHANGED
@@ -1,9 +1,3 @@
1
- import { getCurrentLang } from "./lang.js";
2
- const SDKConfig = {
3
- baseUrl: "V3",
4
- signer: null,
5
- lang: getCurrentLang()
6
- };
7
1
  const getAppVersion = () => {
8
2
  let locationInfo = window.location;
9
3
  if (window.location !== window.parent.location) {
@@ -15,17 +9,13 @@ const getAppVersion = () => {
15
9
  }
16
10
  return locationInfo.pathname.includes("/ngw/app") ? "v2" : "v3";
17
11
  };
18
- const initHanbiroReactSDK = ({ baseUrl, signer }) => {
19
- SDKConfig.baseUrl = baseUrl;
20
- SDKConfig.signer = signer;
12
+ const applyVersionAttribute = () => {
13
+ if (typeof document === "undefined") return;
21
14
  document.documentElement.setAttribute(
22
15
  "data-hanbiro-sdk-version",
23
16
  getAppVersion()
24
17
  );
25
18
  };
26
- const setLibLang = (lang) => {
27
- if (lang) SDKConfig.lang = lang;
28
- };
29
19
  const checkDevelopment = () => {
30
20
  const locationInfo = window.location;
31
21
  const { hostname } = locationInfo;
@@ -37,16 +27,10 @@ const checkDevelopment = () => {
37
27
  };
38
28
  const isDevelopment = checkDevelopment();
39
29
  const getBaseUrl = () => {
40
- var _a;
41
30
  let locationInfo = window.location;
42
31
  const { host } = locationInfo;
43
32
  if (isDevelopment) {
44
- const baseUrlArr = (_a = SDKConfig.baseUrl) == null ? void 0 : _a.split("/");
45
- if (baseUrlArr) {
46
- return "https://" + (baseUrlArr == null ? void 0 : baseUrlArr[2]);
47
- } else {
48
- return "https://vndev.hanbiro.com";
49
- }
33
+ return "https://vndev.hanbiro.com";
50
34
  } else {
51
35
  const data = localStorage.getItem("host") || host;
52
36
  const dataArr = data == null ? void 0 : data.split("/");
@@ -54,10 +38,8 @@ const getBaseUrl = () => {
54
38
  }
55
39
  };
56
40
  export {
57
- SDKConfig,
41
+ applyVersionAttribute,
58
42
  getAppVersion,
59
43
  getBaseUrl,
60
- initHanbiroReactSDK,
61
- isDevelopment,
62
- setLibLang
44
+ isDevelopment
63
45
  };
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "hanbiro-react16-sdk",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "React 16.2.0 compatible UI components for Hanbiro",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/hanbiro-react16-sdk.umd.js",
7
7
  "module": "./dist/index.js",
8
8
  "sideEffects": [
9
- "**/*.css"
9
+ "**/*.css",
10
+ "./dist/index.js"
10
11
  ],
11
12
  "exports": {
12
13
  ".": {
@@ -74,7 +75,8 @@
74
75
  "sass-embedded": "^1.98.0",
75
76
  "typescript": "^5.5.0",
76
77
  "vite": "^5.4.0",
77
- "vite-plugin-dts": "^3.9.1"
78
+ "vite-plugin-dts": "^3.9.1",
79
+ "@hanbiro/signer-core": "git+ssh://git@git.hanbiro.com:2222/dev/groupware.client-api-sdk.git#main"
78
80
  },
79
81
  "dependencies": {
80
82
  "@tinymce/tinymce-react": "^4.3.0",