@poe-platform/safe-bash 0.1.726 → 0.1.727

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 (207) hide show
  1. package/dist/safe-bash/chunks/{chunk-6VZX7ESE.js → chunk-26N7BLXE.js} +3 -3
  2. package/dist/safe-bash/chunks/{chunk-ZZ7JQBPX.js → chunk-4A2OLEML.js} +2 -2
  3. package/dist/safe-bash/chunks/{chunk-LTREB3HX.js → chunk-54MC6XF5.js} +4 -4
  4. package/dist/safe-bash/chunks/{chunk-Z3CCN6Y2.js → chunk-6J5FUESH.js} +2 -2
  5. package/dist/safe-bash/chunks/{chunk-YR5RZBWS.js → chunk-6TBFZ5JE.js} +2 -2
  6. package/dist/safe-bash/chunks/{chunk-6HJNJ625.js → chunk-7MMYQG3P.js} +2 -2
  7. package/dist/safe-bash/chunks/{chunk-WTZZX4LV.js → chunk-A4MB2KXV.js} +2 -2
  8. package/dist/safe-bash/chunks/{chunk-EM2JW7ZH.js → chunk-ATYJKRBZ.js} +2 -2
  9. package/dist/safe-bash/chunks/{chunk-VV24PRPB.js → chunk-AZQOEGP3.js} +1050 -101
  10. package/dist/safe-bash/chunks/chunk-AZQOEGP3.js.map +7 -0
  11. package/dist/safe-bash/chunks/{chunk-EFMXWUYE.js → chunk-B6JEJ6AT.js} +2 -2
  12. package/dist/safe-bash/chunks/{chunk-JFGGQUYP.js → chunk-BFXGHT3R.js} +2 -2
  13. package/dist/safe-bash/chunks/{chunk-RP5IZOOR.js → chunk-BJYV5J65.js} +1050 -101
  14. package/dist/safe-bash/chunks/chunk-BJYV5J65.js.map +7 -0
  15. package/dist/safe-bash/chunks/{chunk-HNHOPD3P.js → chunk-DIEFWGXO.js} +46 -26
  16. package/dist/safe-bash/chunks/{chunk-HNHOPD3P.js.map → chunk-DIEFWGXO.js.map} +2 -2
  17. package/dist/safe-bash/chunks/{chunk-SME47P4B.js → chunk-DV6EZOKM.js} +46 -26
  18. package/dist/safe-bash/chunks/{chunk-SME47P4B.js.map → chunk-DV6EZOKM.js.map} +2 -2
  19. package/dist/safe-bash/chunks/{chunk-646RTREQ.js → chunk-EEDOYIPC.js} +2 -2
  20. package/dist/safe-bash/chunks/{chunk-OFAAHWL5.js → chunk-GCQ5A2T2.js} +2 -2
  21. package/dist/safe-bash/chunks/{chunk-MJW4KSKV.js → chunk-GLPJEDLY.js} +2 -2
  22. package/dist/safe-bash/chunks/{chunk-FOOJWH7J.js → chunk-GO5OKPBO.js} +4 -4
  23. package/dist/safe-bash/chunks/{chunk-5JANWFJ3.js → chunk-GWYXCCGO.js} +4 -4
  24. package/dist/safe-bash/chunks/{chunk-DPHRNHPT.js → chunk-H6KJ4L22.js} +2 -2
  25. package/dist/safe-bash/chunks/{chunk-FLX2BZBF.js → chunk-HGBYIDAK.js} +4 -4
  26. package/dist/safe-bash/chunks/{chunk-VGJIDLZM.js → chunk-KS5VSJYM.js} +15 -8
  27. package/dist/safe-bash/chunks/chunk-KS5VSJYM.js.map +7 -0
  28. package/dist/safe-bash/chunks/{chunk-PO3Z7W3A.js → chunk-MUHYGUFD.js} +4 -4
  29. package/dist/safe-bash/chunks/{chunk-5DLGYPGJ.js → chunk-PDSTXORC.js} +126 -58
  30. package/dist/safe-bash/chunks/chunk-PDSTXORC.js.map +7 -0
  31. package/dist/safe-bash/chunks/{chunk-TIHMU25L.js → chunk-PQ37GDJF.js} +3 -3
  32. package/dist/safe-bash/chunks/{chunk-OTM5RCWZ.js → chunk-QNEDWYC2.js} +15 -8
  33. package/dist/safe-bash/chunks/chunk-QNEDWYC2.js.map +7 -0
  34. package/dist/safe-bash/chunks/{chunk-LZ7FUN6K.js → chunk-RHHDOA67.js} +5 -5
  35. package/dist/safe-bash/chunks/{chunk-DSCL3VA2.js → chunk-SJ3B26XV.js} +4 -4
  36. package/dist/safe-bash/chunks/{chunk-6JBTVWHH.js → chunk-SWACYEIT.js} +5 -5
  37. package/dist/safe-bash/chunks/{chunk-7UJW7TYR.js → chunk-TD6NWAUK.js} +126 -58
  38. package/dist/safe-bash/chunks/chunk-TD6NWAUK.js.map +7 -0
  39. package/dist/safe-bash/chunks/{chunk-Q4I754TV.js → chunk-THOBFD5C.js} +2 -2
  40. package/dist/safe-bash/chunks/{chunk-XELW5O3R.js → chunk-U2STHT7S.js} +2 -2
  41. package/dist/safe-bash/chunks/{chunk-5X4SOSTT.js → chunk-UJHE5PTK.js} +2 -2
  42. package/dist/safe-bash/chunks/{chunk-B6YFFKYG.js → chunk-X4I3RHTC.js} +5 -1
  43. package/dist/safe-bash/chunks/chunk-X4I3RHTC.js.map +7 -0
  44. package/dist/safe-bash/chunks/{chunk-YOK5UHA7.js → chunk-XKXFX3RH.js} +5 -1
  45. package/dist/safe-bash/chunks/chunk-XKXFX3RH.js.map +7 -0
  46. package/dist/safe-bash/chunks/{chunk-PLCYP2E5.js → chunk-XV4K3UUF.js} +2 -2
  47. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  48. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  49. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  50. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  51. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  52. package/dist/safe-bash/commands/internal.d.ts.map +1 -1
  53. package/dist/safe-bash/commands/internal.js +4 -3
  54. package/dist/safe-bash/commands/internal.js.map +1 -1
  55. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  56. package/dist/safe-bash/commands/llm/index.browser.js +4 -4
  57. package/dist/safe-bash/commands/network/index.browser.js +4 -4
  58. package/dist/safe-bash/commands/node/index.browser.js +4 -4
  59. package/dist/safe-bash/commands/pandoc/index.js.map +1 -1
  60. package/dist/safe-bash/commands/pr/index.browser.js +3 -3
  61. package/dist/safe-bash/commands/python/index.browser.js +2 -2
  62. package/dist/safe-bash/commands/record-buffer.d.ts.map +1 -1
  63. package/dist/safe-bash/commands/record-buffer.js +12 -4
  64. package/dist/safe-bash/commands/record-buffer.js.map +1 -1
  65. package/dist/safe-bash/commands/regex-execution/bounded-provider.d.ts.map +1 -1
  66. package/dist/safe-bash/commands/regex-execution/bounded-provider.js +75 -8
  67. package/dist/safe-bash/commands/regex-execution/bounded-provider.js.map +1 -1
  68. package/dist/safe-bash/commands/regex-execution/ere/limits.d.ts +1 -1
  69. package/dist/safe-bash/commands/regex-execution/ere/limits.d.ts.map +1 -1
  70. package/dist/safe-bash/commands/regex-execution/ere/limits.js +6 -4
  71. package/dist/safe-bash/commands/regex-execution/ere/limits.js.map +1 -1
  72. package/dist/safe-bash/commands/regex-execution/portable.d.ts.map +1 -1
  73. package/dist/safe-bash/commands/regex-execution/portable.js +7 -2
  74. package/dist/safe-bash/commands/regex-execution/portable.js.map +1 -1
  75. package/dist/safe-bash/commands/regex-execution/protocol.d.ts +2 -0
  76. package/dist/safe-bash/commands/regex-execution/protocol.d.ts.map +1 -1
  77. package/dist/safe-bash/commands/regex-execution/protocol.js +26 -0
  78. package/dist/safe-bash/commands/regex-execution/protocol.js.map +1 -1
  79. package/dist/safe-bash/commands/regex-execution/utf8.d.ts +1 -1
  80. package/dist/safe-bash/commands/regex-execution/utf8.d.ts.map +1 -1
  81. package/dist/safe-bash/commands/regex-execution/utf8.js +26 -2
  82. package/dist/safe-bash/commands/regex-execution/utf8.js.map +1 -1
  83. package/dist/safe-bash/commands/search/grep.d.ts.map +1 -1
  84. package/dist/safe-bash/commands/search/grep.js +109 -15
  85. package/dist/safe-bash/commands/search/grep.js.map +1 -1
  86. package/dist/safe-bash/commands/search/matcher.d.ts +1 -1
  87. package/dist/safe-bash/commands/search/matcher.d.ts.map +1 -1
  88. package/dist/safe-bash/commands/search/matcher.js +2 -0
  89. package/dist/safe-bash/commands/search/matcher.js.map +1 -1
  90. package/dist/safe-bash/commands/search/shared.d.ts.map +1 -1
  91. package/dist/safe-bash/commands/search/shared.js +23 -12
  92. package/dist/safe-bash/commands/search/shared.js.map +1 -1
  93. package/dist/safe-bash/commands/standard.d.ts.map +1 -1
  94. package/dist/safe-bash/commands/standard.js +22 -0
  95. package/dist/safe-bash/commands/standard.js.map +1 -1
  96. package/dist/safe-bash/commands/streams.d.ts.map +1 -1
  97. package/dist/safe-bash/commands/streams.js +54 -10
  98. package/dist/safe-bash/commands/streams.js.map +1 -1
  99. package/dist/safe-bash/commands/structured/input.d.ts.map +1 -1
  100. package/dist/safe-bash/commands/structured/input.js +484 -55
  101. package/dist/safe-bash/commands/structured/input.js.map +1 -1
  102. package/dist/safe-bash/commands/structured/interpreter.d.ts +3 -0
  103. package/dist/safe-bash/commands/structured/interpreter.d.ts.map +1 -1
  104. package/dist/safe-bash/commands/structured/interpreter.js +157 -1
  105. package/dist/safe-bash/commands/structured/interpreter.js.map +1 -1
  106. package/dist/safe-bash/commands/structured/jq.d.ts.map +1 -1
  107. package/dist/safe-bash/commands/structured/jq.js +50 -24
  108. package/dist/safe-bash/commands/structured/jq.js.map +1 -1
  109. package/dist/safe-bash/commands/structured/limits.d.ts +5 -0
  110. package/dist/safe-bash/commands/structured/limits.d.ts.map +1 -1
  111. package/dist/safe-bash/commands/structured/limits.js +51 -36
  112. package/dist/safe-bash/commands/structured/limits.js.map +1 -1
  113. package/dist/safe-bash/commands/structured/numbers.d.ts +1 -0
  114. package/dist/safe-bash/commands/structured/numbers.d.ts.map +1 -1
  115. package/dist/safe-bash/commands/structured/numbers.js +32 -0
  116. package/dist/safe-bash/commands/structured/numbers.js.map +1 -1
  117. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts +1 -0
  118. package/dist/safe-bash/commands/text-programs/awk-reader.d.ts.map +1 -1
  119. package/dist/safe-bash/commands/text-programs/awk-reader.js +41 -5
  120. package/dist/safe-bash/commands/text-programs/awk-reader.js.map +1 -1
  121. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts +1 -0
  122. package/dist/safe-bash/commands/text-programs/awk-retention.d.ts.map +1 -1
  123. package/dist/safe-bash/commands/text-programs/awk-retention.js +9 -0
  124. package/dist/safe-bash/commands/text-programs/awk-retention.js.map +1 -1
  125. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts +13 -0
  126. package/dist/safe-bash/commands/text-programs/awk-runtime.d.ts.map +1 -1
  127. package/dist/safe-bash/commands/text-programs/awk-runtime.js +421 -83
  128. package/dist/safe-bash/commands/text-programs/awk-runtime.js.map +1 -1
  129. package/dist/safe-bash/commands/text-programs/awk-values.d.ts.map +1 -1
  130. package/dist/safe-bash/commands/text-programs/awk-values.js +21 -0
  131. package/dist/safe-bash/commands/text-programs/awk-values.js.map +1 -1
  132. package/dist/safe-bash/commands/text-programs/regex.d.ts +15 -2
  133. package/dist/safe-bash/commands/text-programs/regex.d.ts.map +1 -1
  134. package/dist/safe-bash/commands/text-programs/regex.js +501 -13
  135. package/dist/safe-bash/commands/text-programs/regex.js.map +1 -1
  136. package/dist/safe-bash/commands/text-programs/sed.d.ts.map +1 -1
  137. package/dist/safe-bash/commands/text-programs/sed.js +242 -102
  138. package/dist/safe-bash/commands/text-programs/sed.js.map +1 -1
  139. package/dist/safe-bash/commands/text-programs/shared.d.ts +2 -0
  140. package/dist/safe-bash/commands/text-programs/shared.d.ts.map +1 -1
  141. package/dist/safe-bash/commands/text-programs/shared.js +36 -0
  142. package/dist/safe-bash/commands/text-programs/shared.js.map +1 -1
  143. package/dist/safe-bash/commands/text.d.ts.map +1 -1
  144. package/dist/safe-bash/commands/text.js +136 -19
  145. package/dist/safe-bash/commands/text.js.map +1 -1
  146. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  147. package/dist/safe-bash/commands/xml/index.browser.js +5 -5
  148. package/dist/safe-bash/commands/yq/index.browser.js +5 -5
  149. package/dist/safe-bash/contracts/yield.d.ts +1 -0
  150. package/dist/safe-bash/contracts/yield.d.ts.map +1 -1
  151. package/dist/safe-bash/contracts/yield.js +3 -0
  152. package/dist/safe-bash/contracts/yield.js.map +1 -1
  153. package/dist/safe-bash/core.browser.js +1052 -256
  154. package/dist/safe-bash/core.browser.js.map +3 -3
  155. package/dist/safe-bash/plugins/composition.d.ts +1 -0
  156. package/dist/safe-bash/plugins/composition.d.ts.map +1 -1
  157. package/dist/safe-bash/plugins/composition.js +80 -2
  158. package/dist/safe-bash/plugins/composition.js.map +1 -1
  159. package/dist/safe-bash/plugins/index.d.ts.map +1 -1
  160. package/dist/safe-bash/plugins/index.js +2 -2
  161. package/dist/safe-bash/plugins/index.js.map +1 -1
  162. package/dist/safe-bash-command-fold/arguments.d.ts +1 -1
  163. package/dist/safe-bash-command-fold/contracts.d.ts +2 -1
  164. package/dist/safe-bash-command-fold/engine.d.ts +1 -1
  165. package/dist/safe-bash-command-fold/index.js +10 -8
  166. package/dist/safe-bash-command-fold/index.js.map +2 -2
  167. package/dist/safe-bash-command-sips/index.js +231 -67
  168. package/dist/safe-bash-command-sips/index.js.map +2 -2
  169. package/dist/safe-bash-command-unrtf/contracts.d.ts +5 -2
  170. package/dist/safe-bash-command-unrtf/index.js +6 -5
  171. package/dist/safe-bash-command-unrtf/index.js.map +2 -2
  172. package/dist/safe-playwright-cloudflare/browser-run-code.js +22 -6
  173. package/package.json +2 -2
  174. package/dist/safe-bash/chunks/chunk-5DLGYPGJ.js.map +0 -7
  175. package/dist/safe-bash/chunks/chunk-7UJW7TYR.js.map +0 -7
  176. package/dist/safe-bash/chunks/chunk-B6YFFKYG.js.map +0 -7
  177. package/dist/safe-bash/chunks/chunk-OTM5RCWZ.js.map +0 -7
  178. package/dist/safe-bash/chunks/chunk-RP5IZOOR.js.map +0 -7
  179. package/dist/safe-bash/chunks/chunk-VGJIDLZM.js.map +0 -7
  180. package/dist/safe-bash/chunks/chunk-VV24PRPB.js.map +0 -7
  181. package/dist/safe-bash/chunks/chunk-YOK5UHA7.js.map +0 -7
  182. /package/dist/safe-bash/chunks/{chunk-6VZX7ESE.js.map → chunk-26N7BLXE.js.map} +0 -0
  183. /package/dist/safe-bash/chunks/{chunk-ZZ7JQBPX.js.map → chunk-4A2OLEML.js.map} +0 -0
  184. /package/dist/safe-bash/chunks/{chunk-LTREB3HX.js.map → chunk-54MC6XF5.js.map} +0 -0
  185. /package/dist/safe-bash/chunks/{chunk-Z3CCN6Y2.js.map → chunk-6J5FUESH.js.map} +0 -0
  186. /package/dist/safe-bash/chunks/{chunk-YR5RZBWS.js.map → chunk-6TBFZ5JE.js.map} +0 -0
  187. /package/dist/safe-bash/chunks/{chunk-6HJNJ625.js.map → chunk-7MMYQG3P.js.map} +0 -0
  188. /package/dist/safe-bash/chunks/{chunk-WTZZX4LV.js.map → chunk-A4MB2KXV.js.map} +0 -0
  189. /package/dist/safe-bash/chunks/{chunk-EM2JW7ZH.js.map → chunk-ATYJKRBZ.js.map} +0 -0
  190. /package/dist/safe-bash/chunks/{chunk-EFMXWUYE.js.map → chunk-B6JEJ6AT.js.map} +0 -0
  191. /package/dist/safe-bash/chunks/{chunk-JFGGQUYP.js.map → chunk-BFXGHT3R.js.map} +0 -0
  192. /package/dist/safe-bash/chunks/{chunk-646RTREQ.js.map → chunk-EEDOYIPC.js.map} +0 -0
  193. /package/dist/safe-bash/chunks/{chunk-OFAAHWL5.js.map → chunk-GCQ5A2T2.js.map} +0 -0
  194. /package/dist/safe-bash/chunks/{chunk-MJW4KSKV.js.map → chunk-GLPJEDLY.js.map} +0 -0
  195. /package/dist/safe-bash/chunks/{chunk-FOOJWH7J.js.map → chunk-GO5OKPBO.js.map} +0 -0
  196. /package/dist/safe-bash/chunks/{chunk-5JANWFJ3.js.map → chunk-GWYXCCGO.js.map} +0 -0
  197. /package/dist/safe-bash/chunks/{chunk-DPHRNHPT.js.map → chunk-H6KJ4L22.js.map} +0 -0
  198. /package/dist/safe-bash/chunks/{chunk-FLX2BZBF.js.map → chunk-HGBYIDAK.js.map} +0 -0
  199. /package/dist/safe-bash/chunks/{chunk-PO3Z7W3A.js.map → chunk-MUHYGUFD.js.map} +0 -0
  200. /package/dist/safe-bash/chunks/{chunk-TIHMU25L.js.map → chunk-PQ37GDJF.js.map} +0 -0
  201. /package/dist/safe-bash/chunks/{chunk-LZ7FUN6K.js.map → chunk-RHHDOA67.js.map} +0 -0
  202. /package/dist/safe-bash/chunks/{chunk-DSCL3VA2.js.map → chunk-SJ3B26XV.js.map} +0 -0
  203. /package/dist/safe-bash/chunks/{chunk-6JBTVWHH.js.map → chunk-SWACYEIT.js.map} +0 -0
  204. /package/dist/safe-bash/chunks/{chunk-Q4I754TV.js.map → chunk-THOBFD5C.js.map} +0 -0
  205. /package/dist/safe-bash/chunks/{chunk-XELW5O3R.js.map → chunk-U2STHT7S.js.map} +0 -0
  206. /package/dist/safe-bash/chunks/{chunk-5X4SOSTT.js.map → chunk-UJHE5PTK.js.map} +0 -0
  207. /package/dist/safe-bash/chunks/{chunk-PLCYP2E5.js.map → chunk-XV4K3UUF.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { readBytes } from "../../contracts/index.js";
2
2
  import { Budget, JqError, JqLimitError, object, objectKeyIterator, objectSize, put, scalarJson } from "./limits.js";
3
- import { numericToken, isNumber } from "./numbers.js";
3
+ import { Decimal, numericToken, isNumber, SMALL_DECIMALS } from "./numbers.js";
4
4
  export class JqParseError extends JqError {
5
5
  detail;
6
6
  offset;
@@ -86,6 +86,232 @@ class JsonParser {
86
86
  this.line = line;
87
87
  this.column = column;
88
88
  }
89
+ isQuotedUnescaped() {
90
+ return this.quoted && !this.escaped && this.bom >= 3;
91
+ }
92
+ isUnquotedReady() {
93
+ return !this.quoted && this.bom >= 3;
94
+ }
95
+ isTopLevelIdle() {
96
+ return !this.quoted && !this.escaped && this.stack.length === 0 && this.token === "" && this.next === undefined && !this.stream;
97
+ }
98
+ tryParseFlatLine(fullText, start, end) {
99
+ const byteLen = end - start;
100
+ if (byteLen < 2 || byteLen > this.budget.limits.maxValueBytes)
101
+ return undefined;
102
+ if (fullText.charCodeAt(start) !== 123 || fullText.charCodeAt(end - 1) !== 125)
103
+ return undefined;
104
+ if (this.budget.limits.maxDepth < 1)
105
+ return undefined;
106
+ const obj = object();
107
+ let pos = start + 1;
108
+ let count = 0;
109
+ if (pos < end - 1) {
110
+ while (true) {
111
+ if (fullText.charCodeAt(pos) !== 34)
112
+ return undefined;
113
+ pos++;
114
+ const keyStart = pos;
115
+ while (pos < end - 1) {
116
+ const c = fullText.charCodeAt(pos);
117
+ if (c === 34)
118
+ break;
119
+ if (c < 32 || c >= 127 || c === 92)
120
+ return undefined;
121
+ pos++;
122
+ }
123
+ if (pos >= end - 1)
124
+ return undefined;
125
+ const key = fullText.slice(keyStart, pos);
126
+ if (Object.hasOwn(obj, key))
127
+ return undefined;
128
+ pos++;
129
+ if (fullText.charCodeAt(pos) !== 58)
130
+ return undefined;
131
+ pos++;
132
+ if (pos >= end - 1)
133
+ return undefined;
134
+ const vFirst = fullText.charCodeAt(pos);
135
+ let val;
136
+ if (vFirst === 34) {
137
+ pos++;
138
+ const vStart = pos;
139
+ while (pos < end - 1) {
140
+ const c = fullText.charCodeAt(pos);
141
+ if (c === 34)
142
+ break;
143
+ if (c < 32 || c >= 127 || c === 92)
144
+ return undefined;
145
+ pos++;
146
+ }
147
+ if (pos >= end - 1)
148
+ return undefined;
149
+ val = fullText.slice(vStart, pos);
150
+ pos++;
151
+ }
152
+ else if (vFirst === 116) {
153
+ if (fullText.charCodeAt(pos + 1) !== 114 || fullText.charCodeAt(pos + 2) !== 117 || fullText.charCodeAt(pos + 3) !== 101)
154
+ return undefined;
155
+ val = true;
156
+ pos += 4;
157
+ }
158
+ else if (vFirst === 102) {
159
+ if (fullText.charCodeAt(pos + 1) !== 97 || fullText.charCodeAt(pos + 2) !== 108 || fullText.charCodeAt(pos + 3) !== 115 || fullText.charCodeAt(pos + 4) !== 101)
160
+ return undefined;
161
+ val = false;
162
+ pos += 5;
163
+ }
164
+ else if (vFirst === 110) {
165
+ if (fullText.charCodeAt(pos + 1) !== 117 || fullText.charCodeAt(pos + 2) !== 108 || fullText.charCodeAt(pos + 3) !== 108)
166
+ return undefined;
167
+ val = null;
168
+ pos += 4;
169
+ }
170
+ else if (vFirst >= 48 && vFirst <= 57) {
171
+ const nStart = pos;
172
+ let num = vFirst - 48;
173
+ pos++;
174
+ if (vFirst === 48) {
175
+ const nextC = fullText.charCodeAt(pos);
176
+ if (nextC !== 44 && nextC !== 125)
177
+ return undefined;
178
+ val = SMALL_DECIMALS[0];
179
+ }
180
+ else {
181
+ while (pos < end - 1) {
182
+ const c = fullText.charCodeAt(pos);
183
+ if (c < 48 || c > 57)
184
+ break;
185
+ num = num * 10 + (c - 48);
186
+ pos++;
187
+ }
188
+ if (pos - nStart > 15)
189
+ return undefined;
190
+ const nextC = fullText.charCodeAt(pos);
191
+ if (nextC !== 44 && nextC !== 125)
192
+ return undefined;
193
+ if (num <= 1024)
194
+ val = SMALL_DECIMALS[num];
195
+ else {
196
+ const s = fullText.slice(nStart, pos);
197
+ val = new Decimal(s, 0, false, s, num);
198
+ }
199
+ }
200
+ }
201
+ else if (vFirst === 91) {
202
+ pos++;
203
+ const arr = [];
204
+ if (fullText.charCodeAt(pos) === 93) {
205
+ pos++;
206
+ }
207
+ else {
208
+ while (pos < end - 1) {
209
+ const eFirst = fullText.charCodeAt(pos);
210
+ let elem;
211
+ if (eFirst === 34) {
212
+ pos++;
213
+ const sStart = pos;
214
+ while (pos < end - 1) {
215
+ const c = fullText.charCodeAt(pos);
216
+ if (c === 34)
217
+ break;
218
+ if (c < 32 || c >= 127 || c === 92)
219
+ return undefined;
220
+ pos++;
221
+ }
222
+ if (pos >= end - 1)
223
+ return undefined;
224
+ elem = fullText.slice(sStart, pos);
225
+ pos++;
226
+ }
227
+ else if (eFirst >= 48 && eFirst <= 57) {
228
+ const nStart = pos;
229
+ let num = eFirst - 48;
230
+ pos++;
231
+ if (eFirst !== 48) {
232
+ while (pos < end - 1) {
233
+ const c = fullText.charCodeAt(pos);
234
+ if (c < 48 || c > 57)
235
+ break;
236
+ num = num * 10 + (c - 48);
237
+ pos++;
238
+ }
239
+ }
240
+ if (pos - nStart > 15)
241
+ return undefined;
242
+ const nextC = fullText.charCodeAt(pos);
243
+ if (nextC !== 44 && nextC !== 93)
244
+ return undefined;
245
+ if (num <= 1024)
246
+ elem = SMALL_DECIMALS[num];
247
+ else {
248
+ const s = fullText.slice(nStart, pos);
249
+ elem = new Decimal(s, 0, false, s, num);
250
+ }
251
+ }
252
+ else {
253
+ return undefined;
254
+ }
255
+ arr.push(elem);
256
+ if (arr.length > this.budget.limits.maxCollectionSize)
257
+ return undefined;
258
+ const aSep = fullText.charCodeAt(pos);
259
+ if (aSep === 44) {
260
+ pos++;
261
+ continue;
262
+ }
263
+ if (aSep === 93) {
264
+ pos++;
265
+ break;
266
+ }
267
+ return undefined;
268
+ }
269
+ }
270
+ val = arr;
271
+ }
272
+ else {
273
+ return undefined;
274
+ }
275
+ count++;
276
+ if (count > this.budget.limits.maxCollectionSize)
277
+ return undefined;
278
+ put(obj, key, val);
279
+ const sep = fullText.charCodeAt(pos);
280
+ if (sep === 44) {
281
+ pos++;
282
+ continue;
283
+ }
284
+ if (sep === 125 && pos === end - 1)
285
+ break;
286
+ return undefined;
287
+ }
288
+ }
289
+ this.bom = 3;
290
+ this.offset += byteLen + 1;
291
+ this.line++;
292
+ this.column = 0;
293
+ this.bytes = 0;
294
+ this.budget.step(count * 3 + 2);
295
+ return obj;
296
+ }
297
+ appendQuotedSpan(span) {
298
+ const len = span.length;
299
+ this.offset += len;
300
+ this.column += len;
301
+ this.bytes += len;
302
+ if (this.bytes > this.budget.limits.maxValueBytes)
303
+ throw new JqLimitError("maxValueBytes");
304
+ this.token += span;
305
+ }
306
+ appendTokenSpan(span) {
307
+ const len = span.length;
308
+ this.offset += len;
309
+ this.column += len;
310
+ this.bytes += len;
311
+ if (this.bytes > this.budget.limits.maxValueBytes)
312
+ throw new JqLimitError("maxValueBytes");
313
+ this.token += span;
314
+ }
89
315
  path() {
90
316
  const path = [];
91
317
  for (const frame of this.stack) {
@@ -411,7 +637,9 @@ export async function* readChunks(source, budget) {
411
637
  const newline = chunk.indexOf(10, offset);
412
638
  const end = Math.min(newline < 0 ? chunk.length : newline + 1, offset + 16384);
413
639
  budget.step(Math.ceil((end - offset) / 1024));
414
- await budget.tick();
640
+ const p1 = budget.tickSync();
641
+ if (p1)
642
+ await p1;
415
643
  if (newline >= 0 && end === newline + 1) {
416
644
  budget.inputLocation.line++;
417
645
  budget.inputLocation.complete = true;
@@ -447,62 +675,197 @@ export async function* jsonValues(source, budget, options = {}) {
447
675
  let line = 1;
448
676
  let column = 0;
449
677
  let nulTail;
450
- async function* scan(text, completeLine = false) {
451
- for (const character of text) {
452
- if (++scanned % 1024 === 0)
453
- await budget.tick();
454
- if (!completeLine && character === "\0" && nulTail === undefined)
455
- nulTail = "";
456
- if (nulTail !== undefined) {
457
- nulTail += character;
458
- if (nulTail.length > budget.limits.maxValueBytes)
459
- throw new JqLimitError("maxValueBytes");
460
- if (character === "\n") {
461
- const tail = nulTail;
462
- nulTail = undefined;
463
- yield* scan(tail, true);
678
+ try {
679
+ for await (const rawChunk of readBytes(source, budget.signal)) {
680
+ await budget.tick();
681
+ budget.inputBytes += rawChunk.byteLength;
682
+ if (budget.inputBytes > budget.limits.maxInputBytes)
683
+ throw new JqLimitError("maxInputBytes");
684
+ const fullText = Buffer.isBuffer(rawChunk)
685
+ ? rawChunk.toString("latin1")
686
+ : Buffer.from(rawChunk.buffer, rawChunk.byteOffset, rawChunk.byteLength).toString("latin1");
687
+ let chunkOffset = 0;
688
+ while (chunkOffset < fullText.length) {
689
+ if (budget.inputLocation.complete)
690
+ budget.inputLocation = { ...budget.inputLocation, complete: false };
691
+ const newline = fullText.indexOf("\n", chunkOffset);
692
+ const segEnd = Math.min(newline < 0 ? fullText.length : newline + 1, chunkOffset + 16384);
693
+ budget.step(Math.ceil((segEnd - chunkOffset) / 1024));
694
+ const pt = budget.tickSync();
695
+ if (pt)
696
+ await pt;
697
+ if (newline >= 0 && segEnd === newline + 1) {
698
+ budget.inputLocation.line++;
699
+ budget.inputLocation.complete = true;
700
+ if (nulTail === undefined && active && !failed && !options.sequence && !options.stream && !options.streamErrors && parser.isTopLevelIdle()) {
701
+ const fastObj = parser.tryParseFlatLine(fullText, chunkOffset, newline);
702
+ if (fastObj !== undefined) {
703
+ line++;
704
+ column = 0;
705
+ scanned += segEnd - chunkOffset;
706
+ if (scanned >= 1024) {
707
+ scanned &= 1023;
708
+ const p = budget.tickSync();
709
+ if (p)
710
+ await p;
711
+ }
712
+ yield fastObj;
713
+ chunkOffset = segEnd;
714
+ continue;
715
+ }
716
+ }
464
717
  }
465
- continue;
466
- }
467
- if (character === "\n") {
468
- line++;
469
- column = 0;
470
- }
471
- else
472
- column++;
473
- if (options.sequence && character === "\x1e") {
474
- if (active && !failed) {
475
- try {
476
- yield* values(parser.finish({ line, column, eof: false }));
718
+ for (let index = chunkOffset; index < segEnd; index++) {
719
+ if ((++scanned & 1023) === 0) {
720
+ const p = budget.tickSync();
721
+ if (p)
722
+ await p;
477
723
  }
478
- catch (error) {
479
- yield* failure(error, true);
724
+ if (nulTail === undefined && active && !failed) {
725
+ if (parser.isQuotedUnescaped()) {
726
+ let end = index;
727
+ while (end < segEnd) {
728
+ const code = fullText.charCodeAt(end);
729
+ if (code === 34 || code === 92 || code === 10 || code === 0 || code === 30)
730
+ break;
731
+ end++;
732
+ }
733
+ if (end > index) {
734
+ parser.appendQuotedSpan(fullText.slice(index, end));
735
+ column += end - index;
736
+ scanned += end - index - 1;
737
+ index = end - 1;
738
+ continue;
739
+ }
740
+ }
741
+ else if (parser.isUnquotedReady()) {
742
+ const firstCode = fullText.charCodeAt(index);
743
+ if (firstCode > 32 && firstCode !== 34 && firstCode !== 44 && firstCode !== 58 && firstCode !== 91 && firstCode !== 93 && firstCode !== 123 && firstCode !== 125 && firstCode !== 30) {
744
+ let end = index + 1;
745
+ while (end < segEnd) {
746
+ const c = fullText.charCodeAt(end);
747
+ if (c <= 32 || c === 34 || c === 44 || c === 58 || c === 91 || c === 93 || c === 123 || c === 125 || c === 30)
748
+ break;
749
+ end++;
750
+ }
751
+ if (end > index + 1) {
752
+ parser.appendTokenSpan(fullText.slice(index, end));
753
+ column += end - index;
754
+ scanned += end - index - 1;
755
+ index = end - 1;
756
+ continue;
757
+ }
758
+ }
759
+ }
760
+ }
761
+ const character = fullText[index];
762
+ if (character === "\0" && nulTail === undefined)
763
+ nulTail = "";
764
+ if (nulTail !== undefined) {
765
+ nulTail += character;
766
+ if (nulTail.length > budget.limits.maxValueBytes)
767
+ throw new JqLimitError("maxValueBytes");
768
+ if (character === "\n") {
769
+ const tail = nulTail;
770
+ nulTail = undefined;
771
+ for (let ti = 0; ti < tail.length; ti++) {
772
+ if ((++scanned & 1023) === 0) {
773
+ const p = budget.tickSync();
774
+ if (p)
775
+ await p;
776
+ }
777
+ const tc = tail[ti];
778
+ if (tc === "\n") {
779
+ line++;
780
+ column = 0;
781
+ }
782
+ else
783
+ column++;
784
+ if (options.sequence && tc === "\x1e") {
785
+ if (active && !failed) {
786
+ try {
787
+ yield* values(parser.finish({ line, column, eof: false }));
788
+ }
789
+ catch (error) {
790
+ yield* failure(error, true);
791
+ }
792
+ }
793
+ parser = new JsonParser(budget, options.stream, line, column);
794
+ active = true;
795
+ failed = false;
796
+ continue;
797
+ }
798
+ if (!active)
799
+ continue;
800
+ if (!failed) {
801
+ try {
802
+ const produced = parser.feed(tc);
803
+ if (options.stream) {
804
+ if (parser.events.length)
805
+ yield* parser.events.splice(0);
806
+ }
807
+ else if (produced !== undefined) {
808
+ yield produced;
809
+ }
810
+ }
811
+ catch (error) {
812
+ yield* failure(error);
813
+ }
814
+ }
815
+ if (failed && options.streamErrors && !options.sequence && tc === "\n") {
816
+ parser = new JsonParser(budget, true, line, column);
817
+ failed = false;
818
+ }
819
+ }
820
+ }
821
+ continue;
822
+ }
823
+ if (character === "\n") {
824
+ line++;
825
+ column = 0;
826
+ }
827
+ else
828
+ column++;
829
+ if (options.sequence && character === "\x1e") {
830
+ if (active && !failed) {
831
+ try {
832
+ yield* values(parser.finish({ line, column, eof: false }));
833
+ }
834
+ catch (error) {
835
+ yield* failure(error, true);
836
+ }
837
+ }
838
+ parser = new JsonParser(budget, options.stream, line, column);
839
+ active = true;
840
+ failed = false;
841
+ continue;
842
+ }
843
+ if (!active)
844
+ continue;
845
+ if (!failed) {
846
+ try {
847
+ const produced = parser.feed(character);
848
+ if (options.stream) {
849
+ if (parser.events.length)
850
+ yield* parser.events.splice(0);
851
+ }
852
+ else if (produced !== undefined) {
853
+ yield produced;
854
+ }
855
+ }
856
+ catch (error) {
857
+ yield* failure(error);
858
+ }
859
+ }
860
+ if (failed && options.streamErrors && !options.sequence && character === "\n") {
861
+ parser = new JsonParser(budget, true, line, column);
862
+ failed = false;
480
863
  }
481
864
  }
482
- parser = new JsonParser(budget, options.stream, line, column);
483
- active = true;
484
- failed = false;
485
- continue;
486
- }
487
- if (!active)
488
- continue;
489
- if (!failed) {
490
- try {
491
- yield* values(parser.feed(character));
492
- }
493
- catch (error) {
494
- yield* failure(error);
495
- }
496
- }
497
- if (failed && options.streamErrors && !options.sequence && character === "\n") {
498
- parser = new JsonParser(budget, true, line, column);
499
- failed = false;
865
+ chunkOffset = segEnd;
500
866
  }
501
867
  }
502
- }
503
- try {
504
- for await (const chunk of readChunks(source, budget))
505
- yield* scan(Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength).toString("latin1"));
868
+ budget.inputLocation.complete = true;
506
869
  if (active && !failed) {
507
870
  try {
508
871
  yield* values(parser.finish(options.sequence ? { line, column, eof: true } : undefined));
@@ -689,13 +1052,77 @@ export async function measureValue(value, budget, depth = 0, maxBytes = budget.l
689
1052
  return bytes;
690
1053
  }
691
1054
  export async function stringify(value, budget, format = false, maxBytes = budget.limits.maxValueBytes, limitName = "maxValueBytes", asStringValue = false) {
692
- await budget.tick(0);
1055
+ const p0 = budget.tickSync(0);
1056
+ if (p0)
1057
+ await p0;
1058
+ const isCompactPlain = !asStringValue && (format === false || (typeof format === "object" && format.indent === "" && !format.ascii && !format.color));
1059
+ if (isCompactPlain && value !== null && typeof value === "object" && !Array.isArray(value) && !isNumber(value) && budget.limits.maxDepth >= 1) {
1060
+ let fastOk = true;
1061
+ let out = "{";
1062
+ let count = 0;
1063
+ for (const key of objectKeyIterator(value)) {
1064
+ for (let i = 0; i < key.length; i++) {
1065
+ const c = key.charCodeAt(i);
1066
+ if (c < 32 || c >= 127 || c === 34 || c === 92) {
1067
+ fastOk = false;
1068
+ break;
1069
+ }
1070
+ }
1071
+ if (!fastOk)
1072
+ break;
1073
+ const v = value[key];
1074
+ let vStr;
1075
+ if (typeof v === "number" && Number.isFinite(v)) {
1076
+ vStr = Object.is(v, -0) ? "-0" : String(v);
1077
+ }
1078
+ else if (isNumber(v) && typeof v === "object" && Number.isFinite(v.double)) {
1079
+ vStr = v.text;
1080
+ }
1081
+ else if (typeof v === "boolean") {
1082
+ vStr = v ? "true" : "false";
1083
+ }
1084
+ else if (v === null) {
1085
+ vStr = "null";
1086
+ }
1087
+ else if (typeof v === "string") {
1088
+ for (let i = 0; i < v.length; i++) {
1089
+ const c = v.charCodeAt(i);
1090
+ if (c < 32 || c >= 127 || c === 34 || c === 92) {
1091
+ fastOk = false;
1092
+ break;
1093
+ }
1094
+ }
1095
+ if (!fastOk)
1096
+ break;
1097
+ vStr = `"${v}"`;
1098
+ }
1099
+ else {
1100
+ fastOk = false;
1101
+ break;
1102
+ }
1103
+ if (count++)
1104
+ out += ",";
1105
+ out += `"${key}":${vStr}`;
1106
+ budget.collection(count);
1107
+ }
1108
+ if (fastOk) {
1109
+ out += "}";
1110
+ if (out.length > maxBytes)
1111
+ throw new JqLimitError(limitName);
1112
+ const pEnd = budget.tickSync(out.length + count * 4 + 2);
1113
+ if (pEnd)
1114
+ await pEnd;
1115
+ return out;
1116
+ }
1117
+ }
693
1118
  const parts = [];
694
1119
  let bytes = 0;
695
1120
  let units = 0;
696
1121
  let stringBytes = 2;
697
1122
  for (const fragment of jsonFragments(value, budget, format)) {
698
- await budget.tick(0);
1123
+ const pf = budget.tickSync(0);
1124
+ if (pf)
1125
+ await pf;
699
1126
  bytes += fragment.bytes;
700
1127
  if (bytes > maxBytes)
701
1128
  throw new JqLimitError(limitName);
@@ -711,7 +1138,9 @@ export async function stringify(value, budget, format = false, maxBytes = budget
711
1138
  units += text.length;
712
1139
  parts.push(text);
713
1140
  }
714
- await budget.tick(units);
1141
+ const pEnd = budget.tickSync(units);
1142
+ if (pEnd)
1143
+ await pEnd;
715
1144
  return parts.join("");
716
1145
  }
717
1146
  //# sourceMappingURL=input.js.map