u8-mqtt 0.6.4 → 0.6.5

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.
Files changed (95) hide show
  1. package/cjs/basic-v4.cjs +1 -1
  2. package/cjs/basic-v5.cjs +1 -1
  3. package/cjs/full-v4.cjs +30 -23
  4. package/cjs/full-v4.cjs.map +1 -1
  5. package/cjs/full-v5.cjs +30 -23
  6. package/cjs/full-v5.cjs.map +1 -1
  7. package/cjs/index.cjs +30 -23
  8. package/cjs/index.cjs.map +1 -1
  9. package/cjs/v4.cjs +30 -23
  10. package/cjs/v4.cjs.map +1 -1
  11. package/cjs/v5.cjs +30 -23
  12. package/cjs/v5.cjs.map +1 -1
  13. package/code/router_path.jsy +19 -16
  14. package/esm/basic-v4.js +1 -1
  15. package/esm/basic-v5.js +1 -1
  16. package/esm/deno/basic-v4.js +1 -1
  17. package/esm/deno/basic-v5.js +1 -1
  18. package/esm/deno/full-v4.js +30 -23
  19. package/esm/deno/full-v4.js.map +1 -1
  20. package/esm/deno/full-v5.js +30 -23
  21. package/esm/deno/full-v5.js.map +1 -1
  22. package/esm/deno/index.js +30 -23
  23. package/esm/deno/index.js.map +1 -1
  24. package/esm/deno/v4.js +30 -23
  25. package/esm/deno/v4.js.map +1 -1
  26. package/esm/deno/v5.js +30 -23
  27. package/esm/deno/v5.js.map +1 -1
  28. package/esm/full-v4.js +30 -23
  29. package/esm/full-v4.js.map +1 -1
  30. package/esm/full-v5.js +30 -23
  31. package/esm/full-v5.js.map +1 -1
  32. package/esm/index.js +30 -23
  33. package/esm/index.js.map +1 -1
  34. package/esm/node/basic-v4.js +1 -1
  35. package/esm/node/basic-v4.mjs +1 -1
  36. package/esm/node/basic-v5.js +1 -1
  37. package/esm/node/basic-v5.mjs +1 -1
  38. package/esm/node/full-v4.js +30 -23
  39. package/esm/node/full-v4.js.map +1 -1
  40. package/esm/node/full-v4.mjs +30 -23
  41. package/esm/node/full-v4.mjs.map +1 -1
  42. package/esm/node/full-v5.js +30 -23
  43. package/esm/node/full-v5.js.map +1 -1
  44. package/esm/node/full-v5.mjs +30 -23
  45. package/esm/node/full-v5.mjs.map +1 -1
  46. package/esm/node/index.js +30 -23
  47. package/esm/node/index.js.map +1 -1
  48. package/esm/node/index.mjs +30 -23
  49. package/esm/node/index.mjs.map +1 -1
  50. package/esm/node/v4.js +30 -23
  51. package/esm/node/v4.js.map +1 -1
  52. package/esm/node/v4.mjs +30 -23
  53. package/esm/node/v4.mjs.map +1 -1
  54. package/esm/node/v5.js +30 -23
  55. package/esm/node/v5.js.map +1 -1
  56. package/esm/node/v5.mjs +30 -23
  57. package/esm/node/v5.mjs.map +1 -1
  58. package/esm/v4.js +30 -23
  59. package/esm/v4.js.map +1 -1
  60. package/esm/v5.js +30 -23
  61. package/esm/v5.js.map +1 -1
  62. package/esm/web/basic-v4.js +1 -1
  63. package/esm/web/basic-v4.min.js +1 -1
  64. package/esm/web/basic-v4.min.js.br +0 -0
  65. package/esm/web/basic-v4.min.js.gz +0 -0
  66. package/esm/web/basic-v5.js +1 -1
  67. package/esm/web/basic-v5.min.js +1 -1
  68. package/esm/web/basic-v5.min.js.br +0 -0
  69. package/esm/web/basic-v5.min.js.gz +0 -0
  70. package/esm/web/full-v4.js +30 -23
  71. package/esm/web/full-v4.js.map +1 -1
  72. package/esm/web/full-v4.min.js +1 -1
  73. package/esm/web/full-v4.min.js.br +0 -0
  74. package/esm/web/full-v4.min.js.gz +0 -0
  75. package/esm/web/full-v5.js +30 -23
  76. package/esm/web/full-v5.js.map +1 -1
  77. package/esm/web/full-v5.min.js +1 -1
  78. package/esm/web/full-v5.min.js.br +0 -0
  79. package/esm/web/full-v5.min.js.gz +0 -0
  80. package/esm/web/index.js +30 -23
  81. package/esm/web/index.js.map +1 -1
  82. package/esm/web/index.min.js +1 -1
  83. package/esm/web/index.min.js.br +0 -0
  84. package/esm/web/index.min.js.gz +0 -0
  85. package/esm/web/v4.js +30 -23
  86. package/esm/web/v4.js.map +1 -1
  87. package/esm/web/v4.min.js +1 -1
  88. package/esm/web/v4.min.js.br +0 -0
  89. package/esm/web/v4.min.js.gz +0 -0
  90. package/esm/web/v5.js +30 -23
  91. package/esm/web/v5.js.map +1 -1
  92. package/esm/web/v5.min.js +1 -1
  93. package/esm/web/v5.min.js.br +0 -0
  94. package/esm/web/v5.min.js.gz +0 -0
  95. package/package.json +2 -2
package/cjs/full-v5.cjs CHANGED
@@ -848,16 +848,20 @@ const mqtt_opts_v5 =
848
848
  encode_fns: mqtt_encode_v5,
849
849
  mqtt_writer: mqtt_writer_v5, };
850
850
 
851
- function parse(str, loose) {
852
- if (str instanceof RegExp) return { keys:false, pattern:str };
853
- var c, o, tmp, ext, keys=[], pattern='', arr = str.split('/');
851
+ /**
852
+ * @param {string|RegExp} input The route pattern
853
+ * @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
854
+ */
855
+ function parse(input, loose) {
856
+ if (input instanceof RegExp) return { keys:false, pattern:input };
857
+ var c, o, tmp, ext, keys=[], pattern='', arr = input.split('/');
854
858
  arr[0] || arr.shift();
855
859
 
856
860
  while (tmp = arr.shift()) {
857
861
  c = tmp[0];
858
862
  if (c === '*') {
859
- keys.push('wild');
860
- pattern += '/(.*)';
863
+ keys.push(c);
864
+ pattern += tmp[1] === '?' ? '(?:/(.*))?' : '/(.*)';
861
865
  } else if (c === ':') {
862
866
  o = tmp.indexOf('?', 1);
863
867
  ext = tmp.indexOf('.', 1);
@@ -1027,18 +1031,23 @@ function mqtt_topic_path_router() {
1027
1031
  await ctx.mqtt.puback(pkt);} } } }
1028
1032
 
1029
1033
 
1034
+ const _regexparam ={
1035
+ get wild() {return this['*']}
1036
+ , set wild(v) {return this['*']=wild} };
1037
+
1030
1038
  function * _routes_iter(all_route_lists, topic) {
1031
1039
  topic = topic.replace(/^[\/]*/, '/'); // ensure '/' prefix for regexparam library
1032
- for (let route_list of all_route_lists) {
1033
- for (let route of route_list) {
1034
- let match = route.pattern.exec(topic);
1035
- if (match) {
1036
- let params = route.keys
1037
- ? route.keys.reduce(
1038
- (o, k, i) => (o[k] = match[1+i], o)
1039
- , {})
1040
- : match.groups ?? match;
1041
- yield [route.tgt, params, route];} } } }
1040
+ for (let route of all_route_lists.flat()) {
1041
+ let match = route?.pattern.exec(topic);
1042
+ if (match) {
1043
+ let keys = route.keys;
1044
+ if (keys) {
1045
+ let k, i=0, params={__proto__:_regexparam};
1046
+ for (k of keys) {
1047
+ params[k] = match[++i];}
1048
+ yield [route.tgt, params, route];}
1049
+ else {
1050
+ yield [route.tgt, match.groups ?? match, route];} } } }
1042
1051
 
1043
1052
 
1044
1053
  function _route_remove(all_route_lists, query) {
@@ -1047,16 +1056,14 @@ function _route_remove(all_route_lists, query) {
1047
1056
  let idx_tip = 0;
1048
1057
  for (let route of lst) {
1049
1058
  // skip matching routes to remove from compacted list
1050
- if (route === query) continue
1051
- if (route.topic === query.topic) {
1052
- if (null == query.tgt) continue
1053
- if (route.tgt === query.tgt) continue}
1059
+ let skip = route === query;
1060
+ if (!skip && route.topic === query.topic)
1061
+ skip = (null == query.tgt) || (route.tgt === query.tgt);
1054
1062
 
1055
- lst[idx_tip++] = route;}
1063
+ if (!skip) lst[idx_tip++] = route;}
1056
1064
 
1057
1065
  // truncate remaining list
1058
- if (lst.splice(idx_tip).length)
1059
- ans = true;}
1066
+ lst.length = idx_tip;}
1060
1067
 
1061
1068
  return ans}
1062
1069
 
@@ -1673,7 +1680,7 @@ class MQTTCore extends MQTTBase {
1673
1680
 
1674
1681
  return this} }
1675
1682
 
1676
- const version = '0.6.4-node';
1683
+ const version = '0.6.5-node';
1677
1684
 
1678
1685
  const MQTTClient_v4 = /* #__PURE__ */
1679
1686
  with_topic_path_router(