@zlink-systems/stream-connector 0.31.0 → 0.32.0

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.
@@ -956,15 +956,15 @@ var ZlinkStreamConnectorBundle = (() => {
956
956
  }
957
957
  scan() {
958
958
  this.skipWhitespace();
959
- this.scanValue();
959
+ this.scanValue([]);
960
960
  this.skipWhitespace();
961
961
  if (this.index !== this.text.length) this.fail("trailing data");
962
962
  }
963
- scanValue() {
963
+ scanValue(path) {
964
964
  this.skipWhitespace();
965
965
  const token = this.text[this.index];
966
- if (token === "{") return this.scanObject();
967
- if (token === "[") return this.scanArray();
966
+ if (token === "{") return this.scanObject(path);
967
+ if (token === "[") return this.scanArray(path);
968
968
  if (token === '"') {
969
969
  this.scanString();
970
970
  return;
@@ -974,7 +974,7 @@ var ZlinkStreamConnectorBundle = (() => {
974
974
  if (token === "n") return this.scanLiteral("null");
975
975
  this.scanNumber();
976
976
  }
977
- scanObject() {
977
+ scanObject(path) {
978
978
  var _a, _b;
979
979
  this.index++;
980
980
  this.skipWhitespace();
@@ -988,7 +988,11 @@ var ZlinkStreamConnectorBundle = (() => {
988
988
  if (this.text[this.index] !== '"') this.fail("object property name");
989
989
  const property = this.scanString();
990
990
  if (properties.has(property)) {
991
- throw new SyntaxError(`framework-json-v1 duplicate property '${property}'.`);
991
+ if (this.options.onDuplicateProperty !== void 0) {
992
+ this.options.onDuplicateProperty(property, path);
993
+ } else {
994
+ throw new SyntaxError(`framework-json-v1 duplicate property '${property}'.`);
995
+ }
992
996
  }
993
997
  properties.add(property);
994
998
  if (((_b = (_a = this.options).rejectPropertyName) == null ? void 0 : _b.call(_a, property)) === true) {
@@ -997,14 +1001,14 @@ var ZlinkStreamConnectorBundle = (() => {
997
1001
  this.skipWhitespace();
998
1002
  if (this.text[this.index] !== ":") this.fail("':' after object property");
999
1003
  this.index++;
1000
- this.scanValue();
1004
+ this.scanValue(this.options.onDuplicateProperty === void 0 ? path : [...path, property]);
1001
1005
  this.skipWhitespace();
1002
1006
  const delimiter = this.text[this.index++];
1003
1007
  if (delimiter === "}") return;
1004
1008
  if (delimiter !== ",") this.fail("',' or '}' after object property");
1005
1009
  }
1006
1010
  }
1007
- scanArray() {
1011
+ scanArray(path) {
1008
1012
  this.index++;
1009
1013
  this.skipWhitespace();
1010
1014
  if (this.text[this.index] === "]") {
@@ -1012,7 +1016,7 @@ var ZlinkStreamConnectorBundle = (() => {
1012
1016
  return;
1013
1017
  }
1014
1018
  for (; ; ) {
1015
- this.scanValue();
1019
+ this.scanValue(this.options.onDuplicateProperty === void 0 ? path : [...path, "[]"]);
1016
1020
  this.skipWhitespace();
1017
1021
  const delimiter = this.text[this.index++];
1018
1022
  if (delimiter === "]") return;
@@ -2939,6 +2943,10 @@ var ZlinkStreamConnectorBundle = (() => {
2939
2943
  }
2940
2944
  }
2941
2945
  async dispatch(connection, header, payload, signal) {
2946
+ if (header.kind === 5 /* Control */) {
2947
+ await this.dispatchControl(connection, header, payload, signal);
2948
+ return;
2949
+ }
2942
2950
  const actor = header.actorSlot === void 0 ? void 0 : this.actors.resolve(header.actorSlot);
2943
2951
  if (header.kind === 3 /* Response */ && header.requestSeq !== void 0) {
2944
2952
  try {
@@ -2980,10 +2988,6 @@ var ZlinkStreamConnectorBundle = (() => {
2980
2988
  }
2981
2989
  return;
2982
2990
  }
2983
- if (header.kind === 5 /* Control */) {
2984
- await this.dispatchControl(connection, header, payload, signal);
2985
- return;
2986
- }
2987
2991
  if (header.kind === 1 /* Send */) {
2988
2992
  this.receivedMessages.enqueue(
2989
2993
  {
@@ -3007,16 +3011,16 @@ var ZlinkStreamConnectorBundle = (() => {
3007
3011
  await ((_a = this.serverClosing) == null ? void 0 : _a.call(this, closing.closeReason));
3008
3012
  return;
3009
3013
  }
3010
- if (payload.length !== 0) {
3011
- throw connectorError(
3012
- "frameDecodeFailed" /* FrameDecodeFailed */,
3013
- "Control packet payload must be empty."
3014
- );
3015
- }
3016
3014
  if (header.name === ZLINK_STREAM_HEARTBEAT_PING) {
3017
3015
  await this.frameSender.sendControl(connection, ZLINK_STREAM_HEARTBEAT_PONG);
3018
3016
  return;
3019
3017
  }
3018
+ if (header.name === ZLINK_STREAM_HEARTBEAT_PONG) {
3019
+ return;
3020
+ }
3021
+ if (header.name.startsWith("$zlink.")) {
3022
+ return;
3023
+ }
3020
3024
  if (header.name !== ZLINK_STREAM_HEARTBEAT_PONG) {
3021
3025
  throw connectorError("frameDecodeFailed" /* FrameDecodeFailed */, "Unknown control packet.");
3022
3026
  }
@@ -911,15 +911,15 @@ var JsonPropertyScanner = class {
911
911
  firstEscape;
912
912
  scan() {
913
913
  this.skipWhitespace();
914
- this.scanValue();
914
+ this.scanValue([]);
915
915
  this.skipWhitespace();
916
916
  if (this.index !== this.text.length) this.fail("trailing data");
917
917
  }
918
- scanValue() {
918
+ scanValue(path) {
919
919
  this.skipWhitespace();
920
920
  const token = this.text[this.index];
921
- if (token === "{") return this.scanObject();
922
- if (token === "[") return this.scanArray();
921
+ if (token === "{") return this.scanObject(path);
922
+ if (token === "[") return this.scanArray(path);
923
923
  if (token === '"') {
924
924
  this.scanString();
925
925
  return;
@@ -929,7 +929,7 @@ var JsonPropertyScanner = class {
929
929
  if (token === "n") return this.scanLiteral("null");
930
930
  this.scanNumber();
931
931
  }
932
- scanObject() {
932
+ scanObject(path) {
933
933
  this.index++;
934
934
  this.skipWhitespace();
935
935
  if (this.text[this.index] === "}") {
@@ -942,7 +942,11 @@ var JsonPropertyScanner = class {
942
942
  if (this.text[this.index] !== '"') this.fail("object property name");
943
943
  const property = this.scanString();
944
944
  if (properties.has(property)) {
945
- throw new SyntaxError(`framework-json-v1 duplicate property '${property}'.`);
945
+ if (this.options.onDuplicateProperty !== void 0) {
946
+ this.options.onDuplicateProperty(property, path);
947
+ } else {
948
+ throw new SyntaxError(`framework-json-v1 duplicate property '${property}'.`);
949
+ }
946
950
  }
947
951
  properties.add(property);
948
952
  if (this.options.rejectPropertyName?.(property) === true) {
@@ -951,14 +955,14 @@ var JsonPropertyScanner = class {
951
955
  this.skipWhitespace();
952
956
  if (this.text[this.index] !== ":") this.fail("':' after object property");
953
957
  this.index++;
954
- this.scanValue();
958
+ this.scanValue(this.options.onDuplicateProperty === void 0 ? path : [...path, property]);
955
959
  this.skipWhitespace();
956
960
  const delimiter = this.text[this.index++];
957
961
  if (delimiter === "}") return;
958
962
  if (delimiter !== ",") this.fail("',' or '}' after object property");
959
963
  }
960
964
  }
961
- scanArray() {
965
+ scanArray(path) {
962
966
  this.index++;
963
967
  this.skipWhitespace();
964
968
  if (this.text[this.index] === "]") {
@@ -966,7 +970,7 @@ var JsonPropertyScanner = class {
966
970
  return;
967
971
  }
968
972
  for (; ; ) {
969
- this.scanValue();
973
+ this.scanValue(this.options.onDuplicateProperty === void 0 ? path : [...path, "[]"]);
970
974
  this.skipWhitespace();
971
975
  const delimiter = this.text[this.index++];
972
976
  if (delimiter === "]") return;
@@ -2877,6 +2881,10 @@ var ZlinkStreamReceiveDispatcher = class {
2877
2881
  }
2878
2882
  }
2879
2883
  async dispatch(connection, header, payload, signal) {
2884
+ if (header.kind === 5 /* Control */) {
2885
+ await this.dispatchControl(connection, header, payload, signal);
2886
+ return;
2887
+ }
2880
2888
  const actor = header.actorSlot === void 0 ? void 0 : this.actors.resolve(header.actorSlot);
2881
2889
  if (header.kind === 3 /* Response */ && header.requestSeq !== void 0) {
2882
2890
  try {
@@ -2918,10 +2926,6 @@ var ZlinkStreamReceiveDispatcher = class {
2918
2926
  }
2919
2927
  return;
2920
2928
  }
2921
- if (header.kind === 5 /* Control */) {
2922
- await this.dispatchControl(connection, header, payload, signal);
2923
- return;
2924
- }
2925
2929
  if (header.kind === 1 /* Send */) {
2926
2930
  this.receivedMessages.enqueue(
2927
2931
  {
@@ -2944,16 +2948,16 @@ var ZlinkStreamReceiveDispatcher = class {
2944
2948
  await this.serverClosing?.(closing.closeReason);
2945
2949
  return;
2946
2950
  }
2947
- if (payload.length !== 0) {
2948
- throw connectorError(
2949
- "frameDecodeFailed" /* FrameDecodeFailed */,
2950
- "Control packet payload must be empty."
2951
- );
2952
- }
2953
2951
  if (header.name === ZLINK_STREAM_HEARTBEAT_PING) {
2954
2952
  await this.frameSender.sendControl(connection, ZLINK_STREAM_HEARTBEAT_PONG);
2955
2953
  return;
2956
2954
  }
2955
+ if (header.name === ZLINK_STREAM_HEARTBEAT_PONG) {
2956
+ return;
2957
+ }
2958
+ if (header.name.startsWith("$zlink.")) {
2959
+ return;
2960
+ }
2957
2961
  if (header.name !== ZLINK_STREAM_HEARTBEAT_PONG) {
2958
2962
  throw connectorError("frameDecodeFailed" /* FrameDecodeFailed */, "Unknown control packet.");
2959
2963
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zlink-systems/stream-connector",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,6 +22,6 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@zlink-systems/stream-wire": "0.31.0"
25
+ "@zlink-systems/stream-wire": "0.32.0"
26
26
  }
27
27
  }