@snail-js/api 0.1.19 → 0.1.20
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/core/snailSse.d.ts +4 -4
- package/dist/snail-api.js +30 -24
- package/dist/snail-api.umd.cjs +30 -24
- package/package.json +1 -1
package/dist/core/snailSse.d.ts
CHANGED
|
@@ -9,12 +9,12 @@ export declare class SnailSse {
|
|
|
9
9
|
constructor(server: SnailServer);
|
|
10
10
|
private getSseOptions;
|
|
11
11
|
private initVersion;
|
|
12
|
-
open()
|
|
13
|
-
close()
|
|
12
|
+
open: () => void;
|
|
13
|
+
close: () => void;
|
|
14
14
|
private registerSseEvent;
|
|
15
15
|
private setEvent;
|
|
16
|
-
on(eventName: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions)
|
|
17
|
-
off(eventName: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions)
|
|
16
|
+
on: (eventName: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
|
|
17
|
+
off: (eventName: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void;
|
|
18
18
|
get url(): string;
|
|
19
19
|
get eventSource(): EventSource | null;
|
|
20
20
|
}
|
package/dist/snail-api.js
CHANGED
|
@@ -4044,7 +4044,7 @@ class SnailMethod {
|
|
|
4044
4044
|
this.propertyKey,
|
|
4045
4045
|
this.Args
|
|
4046
4046
|
);
|
|
4047
|
-
console.log("
|
|
4047
|
+
this.enableLog() && console.log("methodUrl:", this.Request.baseURL, this.Request.url);
|
|
4048
4048
|
const newUrl = replacePlaceholders(this.Url, params);
|
|
4049
4049
|
this.Request = {
|
|
4050
4050
|
...this.Request,
|
|
@@ -4157,7 +4157,7 @@ class SnailMethod {
|
|
|
4157
4157
|
this.propertyKey = propertyKey.toString();
|
|
4158
4158
|
this.Args = args ?? [];
|
|
4159
4159
|
this.init();
|
|
4160
|
-
console.log("url:", this.Url);
|
|
4160
|
+
this.enableLog() && console.log("url:", this.Url);
|
|
4161
4161
|
this.eventMap = /* @__PURE__ */ new Map();
|
|
4162
4162
|
this.onceWrapperMap = /* @__PURE__ */ new Map();
|
|
4163
4163
|
this.eventMap.set("success", /* @__PURE__ */ new Set());
|
|
@@ -4179,8 +4179,11 @@ class SnailMethod {
|
|
|
4179
4179
|
this.initVersion();
|
|
4180
4180
|
}
|
|
4181
4181
|
initUrl() {
|
|
4182
|
-
|
|
4183
|
-
|
|
4182
|
+
if (this.Path === "") {
|
|
4183
|
+
this.Url = this.apiInstance.url || "";
|
|
4184
|
+
return;
|
|
4185
|
+
}
|
|
4186
|
+
this.Url = `${this.apiInstance.url || ""}${resolveUrl(this.Path)}`;
|
|
4184
4187
|
}
|
|
4185
4188
|
initVersion() {
|
|
4186
4189
|
const version = Reflect.getMetadata(
|
|
@@ -4326,7 +4329,10 @@ class SnailMethod {
|
|
|
4326
4329
|
this.propertyKey
|
|
4327
4330
|
);
|
|
4328
4331
|
const isApiNoCache = this.apiInstance.noCache;
|
|
4332
|
+
this.enableLog() && console.log("isApiNoCache:", isApiNoCache);
|
|
4333
|
+
this.enableLog() && console.log("isMethodNoCache:", isMethodNoCache);
|
|
4329
4334
|
const noCacheFlag = isMethodNoCache ? true : isApiNoCache ? true : false;
|
|
4335
|
+
this.enableLog() && console.log("noCacheFlag:", noCacheFlag);
|
|
4330
4336
|
return flag ? noCacheFlag : true;
|
|
4331
4337
|
}
|
|
4332
4338
|
enableLog() {
|
|
@@ -4681,6 +4687,26 @@ class SnailSse {
|
|
|
4681
4687
|
__publicField(this, "_version");
|
|
4682
4688
|
__publicField(this, "_withCredentials");
|
|
4683
4689
|
__publicField(this, "_eventSource");
|
|
4690
|
+
__publicField(this, "open", () => {
|
|
4691
|
+
const url = `${this._baseUrl}${this._url}`;
|
|
4692
|
+
const eventSource = new EventSource(url, {
|
|
4693
|
+
withCredentials: this._withCredentials
|
|
4694
|
+
});
|
|
4695
|
+
this._eventSource = eventSource;
|
|
4696
|
+
this.setEvent();
|
|
4697
|
+
this.registerSseEvent();
|
|
4698
|
+
});
|
|
4699
|
+
__publicField(this, "close", () => {
|
|
4700
|
+
const eventSource = this.eventSource;
|
|
4701
|
+
if (!eventSource) return;
|
|
4702
|
+
eventSource.close();
|
|
4703
|
+
});
|
|
4704
|
+
__publicField(this, "on", (eventName, callback, options) => {
|
|
4705
|
+
this._eventSource && this._eventSource.addEventListener(eventName, callback, options);
|
|
4706
|
+
});
|
|
4707
|
+
__publicField(this, "off", (eventName, callback, options) => {
|
|
4708
|
+
this._eventSource && this._eventSource.removeEventListener(eventName, callback, options);
|
|
4709
|
+
});
|
|
4684
4710
|
this._serverInstance = server;
|
|
4685
4711
|
this._baseUrl = server.baseUrl;
|
|
4686
4712
|
const options = this.getSseOptions();
|
|
@@ -4721,20 +4747,6 @@ class SnailSse {
|
|
|
4721
4747
|
return;
|
|
4722
4748
|
}
|
|
4723
4749
|
}
|
|
4724
|
-
open() {
|
|
4725
|
-
const url = `${this._baseUrl}${this._url}`;
|
|
4726
|
-
const eventSource = new EventSource(url, {
|
|
4727
|
-
withCredentials: this._withCredentials
|
|
4728
|
-
});
|
|
4729
|
-
this._eventSource = eventSource;
|
|
4730
|
-
this.setEvent();
|
|
4731
|
-
this.registerSseEvent();
|
|
4732
|
-
}
|
|
4733
|
-
close() {
|
|
4734
|
-
const eventSource = this.eventSource;
|
|
4735
|
-
if (!eventSource) return;
|
|
4736
|
-
eventSource.close();
|
|
4737
|
-
}
|
|
4738
4750
|
registerSseEvent() {
|
|
4739
4751
|
const eventSource = this._eventSource;
|
|
4740
4752
|
if (!eventSource) return;
|
|
@@ -4762,12 +4774,6 @@ class SnailSse {
|
|
|
4762
4774
|
this._eventSource && (this._eventSource.onerror = onErrorFunc);
|
|
4763
4775
|
}
|
|
4764
4776
|
}
|
|
4765
|
-
on(eventName, callback, options) {
|
|
4766
|
-
this._eventSource && this._eventSource.addEventListener(eventName, callback, options);
|
|
4767
|
-
}
|
|
4768
|
-
off(eventName, callback, options) {
|
|
4769
|
-
this._eventSource && this._eventSource.removeEventListener(eventName, callback, options);
|
|
4770
|
-
}
|
|
4771
4777
|
get url() {
|
|
4772
4778
|
return this._url;
|
|
4773
4779
|
}
|
package/dist/snail-api.umd.cjs
CHANGED
|
@@ -4048,7 +4048,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4048
4048
|
this.propertyKey,
|
|
4049
4049
|
this.Args
|
|
4050
4050
|
);
|
|
4051
|
-
console.log("
|
|
4051
|
+
this.enableLog() && console.log("methodUrl:", this.Request.baseURL, this.Request.url);
|
|
4052
4052
|
const newUrl = replacePlaceholders(this.Url, params);
|
|
4053
4053
|
this.Request = {
|
|
4054
4054
|
...this.Request,
|
|
@@ -4161,7 +4161,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4161
4161
|
this.propertyKey = propertyKey.toString();
|
|
4162
4162
|
this.Args = args ?? [];
|
|
4163
4163
|
this.init();
|
|
4164
|
-
console.log("url:", this.Url);
|
|
4164
|
+
this.enableLog() && console.log("url:", this.Url);
|
|
4165
4165
|
this.eventMap = /* @__PURE__ */ new Map();
|
|
4166
4166
|
this.onceWrapperMap = /* @__PURE__ */ new Map();
|
|
4167
4167
|
this.eventMap.set("success", /* @__PURE__ */ new Set());
|
|
@@ -4183,8 +4183,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4183
4183
|
this.initVersion();
|
|
4184
4184
|
}
|
|
4185
4185
|
initUrl() {
|
|
4186
|
-
|
|
4187
|
-
|
|
4186
|
+
if (this.Path === "") {
|
|
4187
|
+
this.Url = this.apiInstance.url || "";
|
|
4188
|
+
return;
|
|
4189
|
+
}
|
|
4190
|
+
this.Url = `${this.apiInstance.url || ""}${resolveUrl(this.Path)}`;
|
|
4188
4191
|
}
|
|
4189
4192
|
initVersion() {
|
|
4190
4193
|
const version = Reflect.getMetadata(
|
|
@@ -4330,7 +4333,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4330
4333
|
this.propertyKey
|
|
4331
4334
|
);
|
|
4332
4335
|
const isApiNoCache = this.apiInstance.noCache;
|
|
4336
|
+
this.enableLog() && console.log("isApiNoCache:", isApiNoCache);
|
|
4337
|
+
this.enableLog() && console.log("isMethodNoCache:", isMethodNoCache);
|
|
4333
4338
|
const noCacheFlag = isMethodNoCache ? true : isApiNoCache ? true : false;
|
|
4339
|
+
this.enableLog() && console.log("noCacheFlag:", noCacheFlag);
|
|
4334
4340
|
return flag ? noCacheFlag : true;
|
|
4335
4341
|
}
|
|
4336
4342
|
enableLog() {
|
|
@@ -4685,6 +4691,26 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4685
4691
|
__publicField(this, "_version");
|
|
4686
4692
|
__publicField(this, "_withCredentials");
|
|
4687
4693
|
__publicField(this, "_eventSource");
|
|
4694
|
+
__publicField(this, "open", () => {
|
|
4695
|
+
const url = `${this._baseUrl}${this._url}`;
|
|
4696
|
+
const eventSource = new EventSource(url, {
|
|
4697
|
+
withCredentials: this._withCredentials
|
|
4698
|
+
});
|
|
4699
|
+
this._eventSource = eventSource;
|
|
4700
|
+
this.setEvent();
|
|
4701
|
+
this.registerSseEvent();
|
|
4702
|
+
});
|
|
4703
|
+
__publicField(this, "close", () => {
|
|
4704
|
+
const eventSource = this.eventSource;
|
|
4705
|
+
if (!eventSource) return;
|
|
4706
|
+
eventSource.close();
|
|
4707
|
+
});
|
|
4708
|
+
__publicField(this, "on", (eventName, callback, options) => {
|
|
4709
|
+
this._eventSource && this._eventSource.addEventListener(eventName, callback, options);
|
|
4710
|
+
});
|
|
4711
|
+
__publicField(this, "off", (eventName, callback, options) => {
|
|
4712
|
+
this._eventSource && this._eventSource.removeEventListener(eventName, callback, options);
|
|
4713
|
+
});
|
|
4688
4714
|
this._serverInstance = server;
|
|
4689
4715
|
this._baseUrl = server.baseUrl;
|
|
4690
4716
|
const options = this.getSseOptions();
|
|
@@ -4725,20 +4751,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4725
4751
|
return;
|
|
4726
4752
|
}
|
|
4727
4753
|
}
|
|
4728
|
-
open() {
|
|
4729
|
-
const url = `${this._baseUrl}${this._url}`;
|
|
4730
|
-
const eventSource = new EventSource(url, {
|
|
4731
|
-
withCredentials: this._withCredentials
|
|
4732
|
-
});
|
|
4733
|
-
this._eventSource = eventSource;
|
|
4734
|
-
this.setEvent();
|
|
4735
|
-
this.registerSseEvent();
|
|
4736
|
-
}
|
|
4737
|
-
close() {
|
|
4738
|
-
const eventSource = this.eventSource;
|
|
4739
|
-
if (!eventSource) return;
|
|
4740
|
-
eventSource.close();
|
|
4741
|
-
}
|
|
4742
4754
|
registerSseEvent() {
|
|
4743
4755
|
const eventSource = this._eventSource;
|
|
4744
4756
|
if (!eventSource) return;
|
|
@@ -4766,12 +4778,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4766
4778
|
this._eventSource && (this._eventSource.onerror = onErrorFunc);
|
|
4767
4779
|
}
|
|
4768
4780
|
}
|
|
4769
|
-
on(eventName, callback, options) {
|
|
4770
|
-
this._eventSource && this._eventSource.addEventListener(eventName, callback, options);
|
|
4771
|
-
}
|
|
4772
|
-
off(eventName, callback, options) {
|
|
4773
|
-
this._eventSource && this._eventSource.removeEventListener(eventName, callback, options);
|
|
4774
|
-
}
|
|
4775
4781
|
get url() {
|
|
4776
4782
|
return this._url;
|
|
4777
4783
|
}
|