@snail-js/api 0.1.26 → 0.1.28
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 +1 -1
- package/dist/snail-api.js +13 -3
- package/dist/snail-api.umd.cjs +13 -3
- package/package.json +1 -1
package/dist/core/snailSse.d.ts
CHANGED
package/dist/snail-api.js
CHANGED
|
@@ -4576,6 +4576,13 @@ class SnailServer {
|
|
|
4576
4576
|
return options;
|
|
4577
4577
|
}
|
|
4578
4578
|
createSse(constructor) {
|
|
4579
|
+
const serverVersioning = Reflect.getMetadata(
|
|
4580
|
+
VERSIONING_KEY,
|
|
4581
|
+
this.constructor
|
|
4582
|
+
);
|
|
4583
|
+
if (serverVersioning) {
|
|
4584
|
+
this.Version = serverVersioning.defaultVersion || "";
|
|
4585
|
+
}
|
|
4579
4586
|
const sseInstance = new constructor(this);
|
|
4580
4587
|
return sseInstance;
|
|
4581
4588
|
}
|
|
@@ -4689,13 +4696,14 @@ const Sse = (path, options) => {
|
|
|
4689
4696
|
const EVENT_SOURCE_EVENTS_KEY = Symbol("EVENT_SOURCE_EVENTS_KEY");
|
|
4690
4697
|
const SseEvent = (eventName, options) => {
|
|
4691
4698
|
return (target, propertyKey) => {
|
|
4699
|
+
console.log("SseEvent:", target.constructor);
|
|
4692
4700
|
const events = Reflect.getMetadata(EVENT_SOURCE_EVENTS_KEY, target) || [];
|
|
4693
4701
|
events.push({
|
|
4694
4702
|
eventName: eventName ? eventName : "message",
|
|
4695
4703
|
emit: target[propertyKey],
|
|
4696
4704
|
options
|
|
4697
4705
|
});
|
|
4698
|
-
Reflect.defineMetadata(EVENT_SOURCE_EVENTS_KEY, events, target);
|
|
4706
|
+
Reflect.defineMetadata(EVENT_SOURCE_EVENTS_KEY, events, target.constructor);
|
|
4699
4707
|
};
|
|
4700
4708
|
};
|
|
4701
4709
|
const EVENT_SOURCE_OPEN_KEY = Symbol("EVENT_SOURCE_OPEN_KEY");
|
|
@@ -4730,6 +4738,7 @@ class SnailSse {
|
|
|
4730
4738
|
this._eventSource = eventSource;
|
|
4731
4739
|
this.setEvent();
|
|
4732
4740
|
this.registerSseEvent();
|
|
4741
|
+
return this._eventSource;
|
|
4733
4742
|
});
|
|
4734
4743
|
__publicField(this, "close", () => {
|
|
4735
4744
|
const eventSource = this.eventSource;
|
|
@@ -4747,7 +4756,7 @@ class SnailSse {
|
|
|
4747
4756
|
const options = this.getSseOptions();
|
|
4748
4757
|
const { path, withCredentials, version } = options;
|
|
4749
4758
|
this._url = resolveUrl(path);
|
|
4750
|
-
this._version = version;
|
|
4759
|
+
this._version = version ?? server.version;
|
|
4751
4760
|
this._withCredentials = withCredentials ? withCredentials : false;
|
|
4752
4761
|
this.initVersion();
|
|
4753
4762
|
}
|
|
@@ -4789,6 +4798,7 @@ class SnailSse {
|
|
|
4789
4798
|
EVENT_SOURCE_EVENTS_KEY,
|
|
4790
4799
|
this.constructor
|
|
4791
4800
|
);
|
|
4801
|
+
if (!events) return;
|
|
4792
4802
|
events.map((event) => {
|
|
4793
4803
|
eventSource.addEventListener(event.eventName, event.emit, event.options);
|
|
4794
4804
|
});
|
|
@@ -4810,7 +4820,7 @@ class SnailSse {
|
|
|
4810
4820
|
}
|
|
4811
4821
|
}
|
|
4812
4822
|
get url() {
|
|
4813
|
-
return this._url
|
|
4823
|
+
return `${this._baseUrl}${this._url}`;
|
|
4814
4824
|
}
|
|
4815
4825
|
get eventSource() {
|
|
4816
4826
|
return this._eventSource;
|
package/dist/snail-api.umd.cjs
CHANGED
|
@@ -4580,6 +4580,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4580
4580
|
return options;
|
|
4581
4581
|
}
|
|
4582
4582
|
createSse(constructor) {
|
|
4583
|
+
const serverVersioning = Reflect.getMetadata(
|
|
4584
|
+
VERSIONING_KEY,
|
|
4585
|
+
this.constructor
|
|
4586
|
+
);
|
|
4587
|
+
if (serverVersioning) {
|
|
4588
|
+
this.Version = serverVersioning.defaultVersion || "";
|
|
4589
|
+
}
|
|
4583
4590
|
const sseInstance = new constructor(this);
|
|
4584
4591
|
return sseInstance;
|
|
4585
4592
|
}
|
|
@@ -4693,13 +4700,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4693
4700
|
const EVENT_SOURCE_EVENTS_KEY = Symbol("EVENT_SOURCE_EVENTS_KEY");
|
|
4694
4701
|
const SseEvent = (eventName, options) => {
|
|
4695
4702
|
return (target, propertyKey) => {
|
|
4703
|
+
console.log("SseEvent:", target.constructor);
|
|
4696
4704
|
const events = Reflect.getMetadata(EVENT_SOURCE_EVENTS_KEY, target) || [];
|
|
4697
4705
|
events.push({
|
|
4698
4706
|
eventName: eventName ? eventName : "message",
|
|
4699
4707
|
emit: target[propertyKey],
|
|
4700
4708
|
options
|
|
4701
4709
|
});
|
|
4702
|
-
Reflect.defineMetadata(EVENT_SOURCE_EVENTS_KEY, events, target);
|
|
4710
|
+
Reflect.defineMetadata(EVENT_SOURCE_EVENTS_KEY, events, target.constructor);
|
|
4703
4711
|
};
|
|
4704
4712
|
};
|
|
4705
4713
|
const EVENT_SOURCE_OPEN_KEY = Symbol("EVENT_SOURCE_OPEN_KEY");
|
|
@@ -4734,6 +4742,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4734
4742
|
this._eventSource = eventSource;
|
|
4735
4743
|
this.setEvent();
|
|
4736
4744
|
this.registerSseEvent();
|
|
4745
|
+
return this._eventSource;
|
|
4737
4746
|
});
|
|
4738
4747
|
__publicField(this, "close", () => {
|
|
4739
4748
|
const eventSource = this.eventSource;
|
|
@@ -4751,7 +4760,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4751
4760
|
const options = this.getSseOptions();
|
|
4752
4761
|
const { path, withCredentials, version } = options;
|
|
4753
4762
|
this._url = resolveUrl(path);
|
|
4754
|
-
this._version = version;
|
|
4763
|
+
this._version = version ?? server.version;
|
|
4755
4764
|
this._withCredentials = withCredentials ? withCredentials : false;
|
|
4756
4765
|
this.initVersion();
|
|
4757
4766
|
}
|
|
@@ -4793,6 +4802,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4793
4802
|
EVENT_SOURCE_EVENTS_KEY,
|
|
4794
4803
|
this.constructor
|
|
4795
4804
|
);
|
|
4805
|
+
if (!events) return;
|
|
4796
4806
|
events.map((event) => {
|
|
4797
4807
|
eventSource.addEventListener(event.eventName, event.emit, event.options);
|
|
4798
4808
|
});
|
|
@@ -4814,7 +4824,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4814
4824
|
}
|
|
4815
4825
|
}
|
|
4816
4826
|
get url() {
|
|
4817
|
-
return this._url
|
|
4827
|
+
return `${this._baseUrl}${this._url}`;
|
|
4818
4828
|
}
|
|
4819
4829
|
get eventSource() {
|
|
4820
4830
|
return this._eventSource;
|