@blocklet/js-sdk 1.16.32-beta-f35ca4b8 → 1.16.32-beta-76103be3
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +13 -9
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -188,7 +188,7 @@ declare class UserSessionService {
|
|
|
188
188
|
|
|
189
189
|
declare class ComponentService {
|
|
190
190
|
private blocklet;
|
|
191
|
-
constructor({ blocklet }
|
|
191
|
+
constructor({ blocklet }?: {
|
|
192
192
|
blocklet?: Blocklet;
|
|
193
193
|
});
|
|
194
194
|
getComponent(name: string): _blocklet_meta_lib_blocklet.TComponentInternalInfo;
|
package/dist/index.d.ts
CHANGED
|
@@ -188,7 +188,7 @@ declare class UserSessionService {
|
|
|
188
188
|
|
|
189
189
|
declare class ComponentService {
|
|
190
190
|
private blocklet;
|
|
191
|
-
constructor({ blocklet }
|
|
191
|
+
constructor({ blocklet }?: {
|
|
192
192
|
blocklet?: Blocklet;
|
|
193
193
|
});
|
|
194
194
|
getComponent(name: string): _blocklet_meta_lib_blocklet.TComponentInternalInfo;
|
package/dist/index.mjs
CHANGED
|
@@ -182,7 +182,7 @@ var __publicField$1 = (obj, key, value) => {
|
|
|
182
182
|
return value;
|
|
183
183
|
};
|
|
184
184
|
class ComponentService {
|
|
185
|
-
constructor({ blocklet = window.blocklet }) {
|
|
185
|
+
constructor({ blocklet = window.blocklet } = {}) {
|
|
186
186
|
__publicField$1(this, "blocklet");
|
|
187
187
|
this.blocklet = blocklet;
|
|
188
188
|
}
|
|
@@ -236,6 +236,7 @@ const createAxios$1 = (options, requestParams) => {
|
|
|
236
236
|
...options?.headers,
|
|
237
237
|
"x-blocklet-js-sdk-version": version
|
|
238
238
|
};
|
|
239
|
+
const componentService = new ComponentService();
|
|
239
240
|
const visitorId = getVisitorId();
|
|
240
241
|
if (![void 0, null].includes(visitorId)) {
|
|
241
242
|
headers["x-blocklet-visitor-id"] = visitorId;
|
|
@@ -266,9 +267,9 @@ const createAxios$1 = (options, requestParams) => {
|
|
|
266
267
|
instance.interceptors.request.use(
|
|
267
268
|
(config) => {
|
|
268
269
|
const componentDid = requestParams?.componentDid ?? window.blocklet?.componentId?.split("/").pop();
|
|
269
|
-
config.baseURL =
|
|
270
|
+
config.baseURL = config.baseURL || componentService.getComponentMountPoint(componentDid);
|
|
271
|
+
config.timeout = config.timeout || 20 * 1e3;
|
|
270
272
|
config.headers["x-csrf-token"] = getCSRFToken();
|
|
271
|
-
config.timeout = 20 * 1e3;
|
|
272
273
|
return config;
|
|
273
274
|
},
|
|
274
275
|
(error) => Promise.reject(error)
|
|
@@ -417,16 +418,19 @@ function createRequest({
|
|
|
417
418
|
}, requestOptions, requestParams) {
|
|
418
419
|
let refreshingTokenRequest = null;
|
|
419
420
|
const service = createFetch$1(requestOptions, requestParams);
|
|
421
|
+
const componentService = new ComponentService();
|
|
420
422
|
return async (input, options) => {
|
|
421
423
|
let authorization;
|
|
422
424
|
let finalUrl = input;
|
|
423
425
|
if (typeof input === "string") {
|
|
424
|
-
if (
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
426
|
+
if (!isUrl(input)) {
|
|
427
|
+
if (baseURL) {
|
|
428
|
+
finalUrl = joinURL(baseURL, input);
|
|
429
|
+
} else {
|
|
430
|
+
const componentDid = requestParams?.componentDid ?? window.blocklet?.componentId?.split("/").pop();
|
|
431
|
+
const mountPoint = componentService.getComponentMountPoint(componentDid);
|
|
432
|
+
finalUrl = joinURL(mountPoint, input);
|
|
433
|
+
}
|
|
430
434
|
}
|
|
431
435
|
}
|
|
432
436
|
if (!Cookie.get(SESSION_TOKEN_STORAGE_KEY)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/js-sdk",
|
|
3
|
-
"version": "1.16.32-beta-
|
|
3
|
+
"version": "1.16.32-beta-76103be3",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"watch": "nodemon -w src -e ts -x 'npm run build'"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@abtnode/constant": "1.16.32-beta-
|
|
36
|
-
"@blocklet/meta": "1.16.32-beta-
|
|
35
|
+
"@abtnode/constant": "1.16.32-beta-76103be3",
|
|
36
|
+
"@blocklet/meta": "1.16.32-beta-76103be3",
|
|
37
37
|
"axios": "^1.7.5",
|
|
38
38
|
"is-url": "^1.2.4",
|
|
39
39
|
"js-cookie": "^3.0.5",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"unbuild": "^2.0.0",
|
|
46
46
|
"vitest": "^2.0.5"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "6d7afe107a349b1267b29e7f2216db9997085015"
|
|
49
49
|
}
|