ai 1.1.0 → 2.0.1

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 (340) hide show
  1. package/LICENSE +10 -24
  2. package/dist/ai-stream.d.ts +18 -0
  3. package/dist/ai-stream.js +132 -0
  4. package/dist/ai-stream.mjs +13 -0
  5. package/dist/anthropic-stream.d.ts +5 -0
  6. package/dist/anthropic-stream.js +133 -0
  7. package/dist/anthropic-stream.mjs +8 -0
  8. package/dist/chunk-265FSSO4.mjs +91 -0
  9. package/dist/chunk-2L3ZO4UM.mjs +45 -0
  10. package/dist/chunk-GT4HKF2X.mjs +33 -0
  11. package/dist/chunk-JGDC3BXD.mjs +22 -0
  12. package/dist/chunk-NK2CVBLI.mjs +38 -0
  13. package/dist/chunk-PEYAHBDF.mjs +43 -0
  14. package/dist/chunk-TJMME6CL.mjs +24 -0
  15. package/dist/huggingface-stream.d.ts +5 -0
  16. package/dist/huggingface-stream.js +121 -0
  17. package/dist/huggingface-stream.mjs +8 -0
  18. package/dist/index.d.ts +131 -0
  19. package/dist/index.js +278 -0
  20. package/dist/index.mjs +35 -0
  21. package/dist/index.test.d.ts +2 -0
  22. package/dist/index.test.js +12 -0
  23. package/dist/index.test.mjs +10 -0
  24. package/dist/langchain-stream.d.ts +12 -0
  25. package/dist/langchain-stream.js +102 -0
  26. package/dist/langchain-stream.mjs +8 -0
  27. package/dist/openai-stream.d.ts +5 -0
  28. package/dist/openai-stream.js +144 -0
  29. package/dist/openai-stream.mjs +8 -0
  30. package/dist/streaming-text-response.d.ts +17 -0
  31. package/dist/streaming-text-response.js +75 -0
  32. package/dist/streaming-text-response.mjs +9 -0
  33. package/package.json +78 -29
  34. package/react/dist/chunk-5PP6W52J.mjs +202 -0
  35. package/react/dist/chunk-6EH3SWMP.mjs +55 -0
  36. package/react/dist/chunk-PW6HSU2N.mjs +154 -0
  37. package/react/dist/index.d.ts +3 -0
  38. package/react/dist/index.js +424 -0
  39. package/react/dist/index.mjs +12 -0
  40. package/react/dist/types-f862f74a.d.ts +123 -0
  41. package/react/dist/use-chat.d.ts +42 -0
  42. package/react/dist/use-chat.js +276 -0
  43. package/react/dist/use-chat.mjs +8 -0
  44. package/react/dist/use-completion.d.ts +47 -0
  45. package/react/dist/use-completion.js +229 -0
  46. package/react/dist/use-completion.mjs +8 -0
  47. package/svelte/dist/chunk-6USBQIV6.mjs +177 -0
  48. package/svelte/dist/chunk-BQ64GHZ3.mjs +136 -0
  49. package/svelte/dist/chunk-CENOSGDG.mjs +493 -0
  50. package/svelte/dist/index.d.ts +4 -0
  51. package/svelte/dist/index.js +808 -0
  52. package/svelte/dist/index.mjs +11 -0
  53. package/svelte/dist/types-f862f74a.d.ts +123 -0
  54. package/svelte/dist/use-chat.d.ts +39 -0
  55. package/svelte/dist/use-chat.js +680 -0
  56. package/svelte/dist/use-chat.mjs +7 -0
  57. package/svelte/dist/use-completion.d.ts +38 -0
  58. package/svelte/dist/use-completion.js +640 -0
  59. package/svelte/dist/use-completion.mjs +7 -0
  60. package/.npmignore +0 -15
  61. package/.travis.yml +0 -4
  62. package/README.md +0 -21
  63. package/bin/ai.js +0 -22
  64. package/index.js +0 -37
  65. package/node_modules/request/.npmignore +0 -2
  66. package/node_modules/request/.travis.yml +0 -12
  67. package/node_modules/request/CHANGELOG.md +0 -954
  68. package/node_modules/request/LICENSE +0 -55
  69. package/node_modules/request/README.md +0 -421
  70. package/node_modules/request/index.js +0 -166
  71. package/node_modules/request/lib/cookies.js +0 -40
  72. package/node_modules/request/lib/copy.js +0 -8
  73. package/node_modules/request/lib/debug.js +0 -7
  74. package/node_modules/request/lib/getSafe.js +0 -34
  75. package/node_modules/request/lib/optional.js +0 -5
  76. package/node_modules/request/node_modules/aws-sign2/LICENSE +0 -55
  77. package/node_modules/request/node_modules/aws-sign2/README.md +0 -4
  78. package/node_modules/request/node_modules/aws-sign2/index.js +0 -202
  79. package/node_modules/request/node_modules/aws-sign2/package.json +0 -47
  80. package/node_modules/request/node_modules/forever-agent/LICENSE +0 -55
  81. package/node_modules/request/node_modules/forever-agent/README.md +0 -4
  82. package/node_modules/request/node_modules/forever-agent/index.js +0 -119
  83. package/node_modules/request/node_modules/forever-agent/package.json +0 -46
  84. package/node_modules/request/node_modules/form-data/License +0 -19
  85. package/node_modules/request/node_modules/form-data/Readme.md +0 -175
  86. package/node_modules/request/node_modules/form-data/lib/form_data.js +0 -351
  87. package/node_modules/request/node_modules/form-data/node_modules/async/.travis.yml +0 -3
  88. package/node_modules/request/node_modules/form-data/node_modules/async/LICENSE +0 -19
  89. package/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1646
  90. package/node_modules/request/node_modules/form-data/node_modules/async/component.json +0 -11
  91. package/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +0 -1123
  92. package/node_modules/request/node_modules/form-data/node_modules/async/package.json +0 -60
  93. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/License +0 -19
  94. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/Readme.md +0 -132
  95. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/lib/combined_stream.js +0 -186
  96. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/.npmignore +0 -2
  97. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/License +0 -19
  98. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Makefile +0 -7
  99. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/Readme.md +0 -154
  100. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/lib/delayed_stream.js +0 -99
  101. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/package.json +0 -42
  102. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/common.js +0 -6
  103. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-http-upload.js +0 -38
  104. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-auto-pause.js +0 -21
  105. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream-pause.js +0 -14
  106. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-delayed-stream.js +0 -48
  107. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-handle-source-errors.js +0 -15
  108. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-max-data-size.js +0 -18
  109. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-pipe-resumes.js +0 -13
  110. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/integration/test-proxy-readable.js +0 -13
  111. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream/test/run.js +0 -7
  112. package/node_modules/request/node_modules/form-data/node_modules/combined-stream/package.json +0 -61
  113. package/node_modules/request/node_modules/form-data/node_modules/mime/LICENSE +0 -19
  114. package/node_modules/request/node_modules/form-data/node_modules/mime/README.md +0 -66
  115. package/node_modules/request/node_modules/form-data/node_modules/mime/mime.js +0 -114
  116. package/node_modules/request/node_modules/form-data/node_modules/mime/package.json +0 -59
  117. package/node_modules/request/node_modules/form-data/node_modules/mime/test.js +0 -84
  118. package/node_modules/request/node_modules/form-data/node_modules/mime/types/mime.types +0 -1588
  119. package/node_modules/request/node_modules/form-data/node_modules/mime/types/node.types +0 -77
  120. package/node_modules/request/node_modules/form-data/package.json +0 -80
  121. package/node_modules/request/node_modules/hawk/.npmignore +0 -18
  122. package/node_modules/request/node_modules/hawk/.travis.yml +0 -5
  123. package/node_modules/request/node_modules/hawk/LICENSE +0 -24
  124. package/node_modules/request/node_modules/hawk/Makefile +0 -10
  125. package/node_modules/request/node_modules/hawk/README.md +0 -625
  126. package/node_modules/request/node_modules/hawk/example/usage.js +0 -78
  127. package/node_modules/request/node_modules/hawk/images/hawk.png +0 -0
  128. package/node_modules/request/node_modules/hawk/images/logo.png +0 -0
  129. package/node_modules/request/node_modules/hawk/index.js +0 -1
  130. package/node_modules/request/node_modules/hawk/lib/browser.js +0 -507
  131. package/node_modules/request/node_modules/hawk/lib/client.js +0 -371
  132. package/node_modules/request/node_modules/hawk/lib/crypto.js +0 -118
  133. package/node_modules/request/node_modules/hawk/lib/index.js +0 -15
  134. package/node_modules/request/node_modules/hawk/lib/server.js +0 -523
  135. package/node_modules/request/node_modules/hawk/lib/utils.js +0 -183
  136. package/node_modules/request/node_modules/hawk/node_modules/boom/.npmignore +0 -18
  137. package/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +0 -5
  138. package/node_modules/request/node_modules/hawk/node_modules/boom/LICENSE +0 -24
  139. package/node_modules/request/node_modules/hawk/node_modules/boom/Makefile +0 -11
  140. package/node_modules/request/node_modules/hawk/node_modules/boom/README.md +0 -6
  141. package/node_modules/request/node_modules/hawk/node_modules/boom/images/boom.png +0 -0
  142. package/node_modules/request/node_modules/hawk/node_modules/boom/index.js +0 -1
  143. package/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +0 -207
  144. package/node_modules/request/node_modules/hawk/node_modules/boom/package.json +0 -64
  145. package/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +0 -245
  146. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +0 -18
  147. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +0 -5
  148. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +0 -24
  149. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -11
  150. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +0 -6
  151. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
  152. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +0 -68
  153. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +0 -65
  154. package/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +0 -101
  155. package/node_modules/request/node_modules/hawk/node_modules/hoek/.npmignore +0 -18
  156. package/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +0 -5
  157. package/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -33
  158. package/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -10
  159. package/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +0 -436
  160. package/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
  161. package/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
  162. package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -132
  163. package/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +0 -585
  164. package/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +0 -70
  165. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -86
  166. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +0 -1078
  167. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -1
  168. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -1
  169. package/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -1
  170. package/node_modules/request/node_modules/hawk/node_modules/sntp/.npmignore +0 -18
  171. package/node_modules/request/node_modules/hawk/node_modules/sntp/.travis.yml +0 -5
  172. package/node_modules/request/node_modules/hawk/node_modules/sntp/LICENSE +0 -24
  173. package/node_modules/request/node_modules/hawk/node_modules/sntp/Makefile +0 -11
  174. package/node_modules/request/node_modules/hawk/node_modules/sntp/README.md +0 -68
  175. package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/offset.js +0 -16
  176. package/node_modules/request/node_modules/hawk/node_modules/sntp/examples/time.js +0 -25
  177. package/node_modules/request/node_modules/hawk/node_modules/sntp/index.js +0 -1
  178. package/node_modules/request/node_modules/hawk/node_modules/sntp/lib/index.js +0 -409
  179. package/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +0 -65
  180. package/node_modules/request/node_modules/hawk/node_modules/sntp/test/index.js +0 -359
  181. package/node_modules/request/node_modules/hawk/package.json +0 -70
  182. package/node_modules/request/node_modules/hawk/test/browser.js +0 -817
  183. package/node_modules/request/node_modules/hawk/test/client.js +0 -206
  184. package/node_modules/request/node_modules/hawk/test/crypto.js +0 -86
  185. package/node_modules/request/node_modules/hawk/test/index.js +0 -316
  186. package/node_modules/request/node_modules/hawk/test/message.js +0 -246
  187. package/node_modules/request/node_modules/hawk/test/readme.js +0 -98
  188. package/node_modules/request/node_modules/hawk/test/server.js +0 -686
  189. package/node_modules/request/node_modules/hawk/test/uri.js +0 -456
  190. package/node_modules/request/node_modules/hawk/test/utils.js +0 -120
  191. package/node_modules/request/node_modules/http-signature/.dir-locals.el +0 -6
  192. package/node_modules/request/node_modules/http-signature/.npmignore +0 -7
  193. package/node_modules/request/node_modules/http-signature/LICENSE +0 -18
  194. package/node_modules/request/node_modules/http-signature/README.md +0 -75
  195. package/node_modules/request/node_modules/http-signature/http_signing.md +0 -296
  196. package/node_modules/request/node_modules/http-signature/lib/index.js +0 -25
  197. package/node_modules/request/node_modules/http-signature/lib/parser.js +0 -304
  198. package/node_modules/request/node_modules/http-signature/lib/signer.js +0 -179
  199. package/node_modules/request/node_modules/http-signature/lib/util.js +0 -249
  200. package/node_modules/request/node_modules/http-signature/lib/verify.js +0 -42
  201. package/node_modules/request/node_modules/http-signature/node_modules/asn1/.npmignore +0 -2
  202. package/node_modules/request/node_modules/http-signature/node_modules/asn1/LICENSE +0 -19
  203. package/node_modules/request/node_modules/http-signature/node_modules/asn1/README.md +0 -50
  204. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/errors.js +0 -13
  205. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/index.js +0 -27
  206. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/reader.js +0 -267
  207. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/types.js +0 -36
  208. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/ber/writer.js +0 -317
  209. package/node_modules/request/node_modules/http-signature/node_modules/asn1/lib/index.js +0 -20
  210. package/node_modules/request/node_modules/http-signature/node_modules/asn1/package.json +0 -63
  211. package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/reader.test.js +0 -172
  212. package/node_modules/request/node_modules/http-signature/node_modules/asn1/tst/ber/writer.test.js +0 -296
  213. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/README.md +0 -126
  214. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/assert.js +0 -196
  215. package/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +0 -38
  216. package/node_modules/request/node_modules/http-signature/node_modules/ctype/CHANGELOG +0 -71
  217. package/node_modules/request/node_modules/http-signature/node_modules/ctype/LICENSE +0 -24
  218. package/node_modules/request/node_modules/http-signature/node_modules/ctype/README +0 -82
  219. package/node_modules/request/node_modules/http-signature/node_modules/ctype/README.old +0 -298
  220. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctf.js +0 -245
  221. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctio.js +0 -1485
  222. package/node_modules/request/node_modules/http-signature/node_modules/ctype/ctype.js +0 -944
  223. package/node_modules/request/node_modules/http-signature/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
  224. package/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +0 -36
  225. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsl.conf +0 -129
  226. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tools/jsstyle +0 -839
  227. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/float.json +0 -13
  228. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/int.json +0 -13
  229. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/psinfo.json +0 -104
  230. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/struct.json +0 -19
  231. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.fail.js +0 -39
  232. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.float.js +0 -14
  233. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.int.js +0 -14
  234. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.psinfo.js +0 -17
  235. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.struct.js +0 -18
  236. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/tst.typedef.js +0 -15
  237. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctf/typedef.json +0 -14
  238. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.rfloat.js +0 -767
  239. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/float/tst.wfloat.js +0 -753
  240. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.64.js +0 -638
  241. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.rint.js +0 -101
  242. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wbounds.js +0 -53
  243. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/int/tst.wint.js +0 -92
  244. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.64.js +0 -451
  245. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.roundtrip.js +0 -81
  246. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.ruint.js +0 -95
  247. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctio/uint/tst.wuint.js +0 -156
  248. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicr.js +0 -50
  249. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.basicw.js +0 -44
  250. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.char.js +0 -42
  251. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.endian.js +0 -45
  252. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.oldwrite.js +0 -28
  253. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.readSize.js +0 -128
  254. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.structw.js +0 -28
  255. package/node_modules/request/node_modules/http-signature/node_modules/ctype/tst/ctype/tst.writeStruct.js +0 -31
  256. package/node_modules/request/node_modules/http-signature/package.json +0 -54
  257. package/node_modules/request/node_modules/json-stringify-safe/LICENSE +0 -27
  258. package/node_modules/request/node_modules/json-stringify-safe/README.md +0 -49
  259. package/node_modules/request/node_modules/json-stringify-safe/package.json +0 -51
  260. package/node_modules/request/node_modules/json-stringify-safe/stringify.js +0 -39
  261. package/node_modules/request/node_modules/json-stringify-safe/test.js +0 -128
  262. package/node_modules/request/node_modules/mime-types/.npmignore +0 -14
  263. package/node_modules/request/node_modules/mime-types/.travis.yml +0 -12
  264. package/node_modules/request/node_modules/mime-types/LICENSE +0 -22
  265. package/node_modules/request/node_modules/mime-types/Makefile +0 -9
  266. package/node_modules/request/node_modules/mime-types/README.md +0 -101
  267. package/node_modules/request/node_modules/mime-types/SOURCES.md +0 -17
  268. package/node_modules/request/node_modules/mime-types/component.json +0 -16
  269. package/node_modules/request/node_modules/mime-types/lib/custom.json +0 -27
  270. package/node_modules/request/node_modules/mime-types/lib/index.js +0 -75
  271. package/node_modules/request/node_modules/mime-types/lib/mime.json +0 -3317
  272. package/node_modules/request/node_modules/mime-types/lib/node.json +0 -55
  273. package/node_modules/request/node_modules/mime-types/package.json +0 -69
  274. package/node_modules/request/node_modules/node-uuid/.npmignore +0 -2
  275. package/node_modules/request/node_modules/node-uuid/LICENSE.md +0 -2
  276. package/node_modules/request/node_modules/node-uuid/README.md +0 -207
  277. package/node_modules/request/node_modules/node-uuid/benchmark/README.md +0 -53
  278. package/node_modules/request/node_modules/node-uuid/benchmark/bench.gnu +0 -174
  279. package/node_modules/request/node_modules/node-uuid/benchmark/bench.sh +0 -34
  280. package/node_modules/request/node_modules/node-uuid/benchmark/benchmark-native.c +0 -34
  281. package/node_modules/request/node_modules/node-uuid/benchmark/benchmark.js +0 -84
  282. package/node_modules/request/node_modules/node-uuid/component.json +0 -18
  283. package/node_modules/request/node_modules/node-uuid/package.json +0 -54
  284. package/node_modules/request/node_modules/node-uuid/test/compare_v1.js +0 -63
  285. package/node_modules/request/node_modules/node-uuid/test/test.html +0 -17
  286. package/node_modules/request/node_modules/node-uuid/test/test.js +0 -228
  287. package/node_modules/request/node_modules/node-uuid/uuid.js +0 -245
  288. package/node_modules/request/node_modules/oauth-sign/LICENSE +0 -55
  289. package/node_modules/request/node_modules/oauth-sign/README.md +0 -4
  290. package/node_modules/request/node_modules/oauth-sign/index.js +0 -43
  291. package/node_modules/request/node_modules/oauth-sign/package.json +0 -49
  292. package/node_modules/request/node_modules/oauth-sign/test.js +0 -49
  293. package/node_modules/request/node_modules/qs/.jshintignore +0 -1
  294. package/node_modules/request/node_modules/qs/.jshintrc +0 -10
  295. package/node_modules/request/node_modules/qs/.npmignore +0 -18
  296. package/node_modules/request/node_modules/qs/.travis.yml +0 -4
  297. package/node_modules/request/node_modules/qs/LICENSE +0 -28
  298. package/node_modules/request/node_modules/qs/Makefile +0 -8
  299. package/node_modules/request/node_modules/qs/Readme.md +0 -120
  300. package/node_modules/request/node_modules/qs/index.js +0 -1
  301. package/node_modules/request/node_modules/qs/lib/index.js +0 -15
  302. package/node_modules/request/node_modules/qs/lib/parse.js +0 -151
  303. package/node_modules/request/node_modules/qs/lib/stringify.js +0 -52
  304. package/node_modules/request/node_modules/qs/lib/utils.js +0 -131
  305. package/node_modules/request/node_modules/qs/package.json +0 -61
  306. package/node_modules/request/node_modules/qs/test/parse.js +0 -236
  307. package/node_modules/request/node_modules/qs/test/stringify.js +0 -123
  308. package/node_modules/request/node_modules/stringstream/.npmignore +0 -15
  309. package/node_modules/request/node_modules/stringstream/.travis.yml +0 -4
  310. package/node_modules/request/node_modules/stringstream/LICENSE.txt +0 -4
  311. package/node_modules/request/node_modules/stringstream/README.md +0 -38
  312. package/node_modules/request/node_modules/stringstream/example.js +0 -27
  313. package/node_modules/request/node_modules/stringstream/package.json +0 -48
  314. package/node_modules/request/node_modules/stringstream/stringstream.js +0 -102
  315. package/node_modules/request/node_modules/tough-cookie/.jshintrc +0 -70
  316. package/node_modules/request/node_modules/tough-cookie/.npmignore +0 -3
  317. package/node_modules/request/node_modules/tough-cookie/.travis.yml +0 -8
  318. package/node_modules/request/node_modules/tough-cookie/LICENSE +0 -78
  319. package/node_modules/request/node_modules/tough-cookie/README.md +0 -412
  320. package/node_modules/request/node_modules/tough-cookie/generate-pubsuffix.js +0 -239
  321. package/node_modules/request/node_modules/tough-cookie/lib/cookie.js +0 -1107
  322. package/node_modules/request/node_modules/tough-cookie/lib/memstore.js +0 -123
  323. package/node_modules/request/node_modules/tough-cookie/lib/pubsuffix.js +0 -69
  324. package/node_modules/request/node_modules/tough-cookie/lib/store.js +0 -37
  325. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/LICENSE-MIT.txt +0 -20
  326. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/README.md +0 -176
  327. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/package.json +0 -87
  328. package/node_modules/request/node_modules/tough-cookie/node_modules/punycode/punycode.js +0 -528
  329. package/node_modules/request/node_modules/tough-cookie/package.json +0 -67
  330. package/node_modules/request/node_modules/tough-cookie/public-suffix.txt +0 -5229
  331. package/node_modules/request/node_modules/tough-cookie/test.js +0 -1625
  332. package/node_modules/request/node_modules/tunnel-agent/.jshintrc +0 -5
  333. package/node_modules/request/node_modules/tunnel-agent/LICENSE +0 -55
  334. package/node_modules/request/node_modules/tunnel-agent/README.md +0 -4
  335. package/node_modules/request/node_modules/tunnel-agent/index.js +0 -236
  336. package/node_modules/request/node_modules/tunnel-agent/package.json +0 -46
  337. package/node_modules/request/package.json +0 -77
  338. package/node_modules/request/request.js +0 -1428
  339. package/test/fixtures/github-response.json +0 -1367
  340. package/test/index.js +0 -55
@@ -1,839 +0,0 @@
1
- #!/usr/bin/env perl
2
- #
3
- # CDDL HEADER START
4
- #
5
- # The contents of this file are subject to the terms of the
6
- # Common Development and Distribution License (the "License").
7
- # You may not use this file except in compliance with the License.
8
- #
9
- # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10
- # or http://www.opensolaris.org/os/licensing.
11
- # See the License for the specific language governing permissions
12
- # and limitations under the License.
13
- #
14
- # When distributing Covered Code, include this CDDL HEADER in each
15
- # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16
- # If applicable, add the following below this CDDL HEADER, with the
17
- # fields enclosed by brackets "[]" replaced with your own identifying
18
- # information: Portions Copyright [yyyy] [name of copyright owner]
19
- #
20
- # CDDL HEADER END
21
- #
22
- #
23
- # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24
- # Use is subject to license terms.
25
- #
26
- # Copyright 2011 Joyent, Inc. All rights reserved.
27
- #
28
- # jsstyle - check for some common stylistic errors.
29
- #
30
- # jsstyle is a sort of "lint" for Javascript coding style. This tool is
31
- # derived from the cstyle tool, used to check for the style used in the
32
- # Solaris kernel, sometimes known as "Bill Joy Normal Form".
33
- #
34
- # There's a lot this can't check for, like proper indentation of code
35
- # blocks. There's also a lot more this could check for.
36
- #
37
- # A note to the non perl literate:
38
- #
39
- # perl regular expressions are pretty much like egrep
40
- # regular expressions, with the following special symbols
41
- #
42
- # \s any space character
43
- # \S any non-space character
44
- # \w any "word" character [a-zA-Z0-9_]
45
- # \W any non-word character
46
- # \d a digit [0-9]
47
- # \D a non-digit
48
- # \b word boundary (between \w and \W)
49
- # \B non-word boundary
50
- #
51
-
52
- require 5.0;
53
- use IO::File;
54
- use Getopt::Std;
55
- use strict;
56
-
57
- my $usage =
58
- "usage: jsstyle [-chvC] [-o constructs] file ...
59
- -c check continuation indentation inside functions
60
- -h perform heuristic checks that are sometimes wrong
61
- -v verbose
62
- -C don't check anything in header block comments
63
- -o constructs
64
- allow a comma-seperated list of optional constructs:
65
- doxygen allow doxygen-style block comments (/** /*!)
66
- splint allow splint-style lint comments (/*@ ... @*/)
67
- ";
68
-
69
- my %opts;
70
-
71
- if (!getopts("cho:vC", \%opts)) {
72
- print $usage;
73
- exit 2;
74
- }
75
-
76
- my $check_continuation = $opts{'c'};
77
- my $heuristic = $opts{'h'};
78
- my $verbose = $opts{'v'};
79
- my $ignore_hdr_comment = $opts{'C'};
80
-
81
- my $doxygen_comments = 0;
82
- my $splint_comments = 0;
83
-
84
- if (defined($opts{'o'})) {
85
- for my $x (split /,/, $opts{'o'}) {
86
- if ($x eq "doxygen") {
87
- $doxygen_comments = 1;
88
- } elsif ($x eq "splint") {
89
- $splint_comments = 1;
90
- } else {
91
- print "jsstyle: unrecognized construct \"$x\"\n";
92
- print $usage;
93
- exit 2;
94
- }
95
- }
96
- }
97
-
98
- my ($filename, $line, $prev); # shared globals
99
-
100
- my $fmt;
101
- my $hdr_comment_start;
102
-
103
- if ($verbose) {
104
- $fmt = "%s: %d: %s\n%s\n";
105
- } else {
106
- $fmt = "%s: %d: %s\n";
107
- }
108
-
109
- if ($doxygen_comments) {
110
- # doxygen comments look like "/*!" or "/**"; allow them.
111
- $hdr_comment_start = qr/^\s*\/\*[\!\*]?$/;
112
- } else {
113
- $hdr_comment_start = qr/^\s*\/\*$/;
114
- }
115
-
116
- # Note, following must be in single quotes so that \s and \w work right.
117
- my $lint_re = qr/\/\*(?:
118
- jsl:\w+?|ARGSUSED[0-9]*|NOTREACHED|LINTLIBRARY|VARARGS[0-9]*|
119
- CONSTCOND|CONSTANTCOND|CONSTANTCONDITION|EMPTY|
120
- FALLTHRU|FALLTHROUGH|LINTED.*?|PRINTFLIKE[0-9]*|
121
- PROTOLIB[0-9]*|SCANFLIKE[0-9]*|JSSTYLED.*?
122
- )\*\//x;
123
-
124
- my $splint_re = qr/\/\*@.*?@\*\//x;
125
-
126
- my $err_stat = 0; # exit status
127
-
128
- if ($#ARGV >= 0) {
129
- foreach my $arg (@ARGV) {
130
- my $fh = new IO::File $arg, "r";
131
- if (!defined($fh)) {
132
- printf "%s: cannot open\n", $arg;
133
- } else {
134
- &jsstyle($arg, $fh);
135
- close $fh;
136
- }
137
- }
138
- } else {
139
- &jsstyle("<stdin>", *STDIN);
140
- }
141
- exit $err_stat;
142
-
143
- my $no_errs = 0; # set for JSSTYLED-protected lines
144
-
145
- sub err($) {
146
- my ($error) = @_;
147
- unless ($no_errs) {
148
- printf $fmt, $filename, $., $error, $line;
149
- $err_stat = 1;
150
- }
151
- }
152
-
153
- sub err_prefix($$) {
154
- my ($prevline, $error) = @_;
155
- my $out = $prevline."\n".$line;
156
- unless ($no_errs) {
157
- printf $fmt, $filename, $., $error, $out;
158
- $err_stat = 1;
159
- }
160
- }
161
-
162
- sub err_prev($) {
163
- my ($error) = @_;
164
- unless ($no_errs) {
165
- printf $fmt, $filename, $. - 1, $error, $prev;
166
- $err_stat = 1;
167
- }
168
- }
169
-
170
- sub jsstyle($$) {
171
-
172
- my ($fn, $filehandle) = @_;
173
- $filename = $fn; # share it globally
174
-
175
- my $in_cpp = 0;
176
- my $next_in_cpp = 0;
177
-
178
- my $in_comment = 0;
179
- my $in_header_comment = 0;
180
- my $comment_done = 0;
181
- my $in_function = 0;
182
- my $in_function_header = 0;
183
- my $in_declaration = 0;
184
- my $note_level = 0;
185
- my $nextok = 0;
186
- my $nocheck = 0;
187
-
188
- my $in_string = 0;
189
-
190
- my ($okmsg, $comment_prefix);
191
-
192
- $line = '';
193
- $prev = '';
194
- reset_indent();
195
-
196
- line: while (<$filehandle>) {
197
- s/\r?\n$//; # strip return and newline
198
-
199
- # save the original line, then remove all text from within
200
- # double or single quotes, we do not want to check such text.
201
-
202
- $line = $_;
203
-
204
- #
205
- # C allows strings to be continued with a backslash at the end of
206
- # the line. We translate that into a quoted string on the previous
207
- # line followed by an initial quote on the next line.
208
- #
209
- # (we assume that no-one will use backslash-continuation with character
210
- # constants)
211
- #
212
- $_ = '"' . $_ if ($in_string && !$nocheck && !$in_comment);
213
-
214
- #
215
- # normal strings and characters
216
- #
217
- s/'([^\\']|\\.)*'/\'\'/g;
218
- s/"([^\\"]|\\.)*"/\"\"/g;
219
-
220
- #
221
- # detect string continuation
222
- #
223
- if ($nocheck || $in_comment) {
224
- $in_string = 0;
225
- } else {
226
- #
227
- # Now that all full strings are replaced with "", we check
228
- # for unfinished strings continuing onto the next line.
229
- #
230
- $in_string =
231
- (s/([^"](?:"")*)"([^\\"]|\\.)*\\$/$1""/ ||
232
- s/^("")*"([^\\"]|\\.)*\\$/""/);
233
- }
234
-
235
- #
236
- # figure out if we are in a cpp directive
237
- #
238
- $in_cpp = $next_in_cpp || /^\s*#/; # continued or started
239
- $next_in_cpp = $in_cpp && /\\$/; # only if continued
240
-
241
- # strip off trailing backslashes, which appear in long macros
242
- s/\s*\\$//;
243
-
244
- # an /* END JSSTYLED */ comment ends a no-check block.
245
- if ($nocheck) {
246
- if (/\/\* *END *JSSTYLED *\*\//) {
247
- $nocheck = 0;
248
- } else {
249
- reset_indent();
250
- next line;
251
- }
252
- }
253
-
254
- # a /*JSSTYLED*/ comment indicates that the next line is ok.
255
- if ($nextok) {
256
- if ($okmsg) {
257
- err($okmsg);
258
- }
259
- $nextok = 0;
260
- $okmsg = 0;
261
- if (/\/\* *JSSTYLED.*\*\//) {
262
- /^.*\/\* *JSSTYLED *(.*) *\*\/.*$/;
263
- $okmsg = $1;
264
- $nextok = 1;
265
- }
266
- $no_errs = 1;
267
- } elsif ($no_errs) {
268
- $no_errs = 0;
269
- }
270
-
271
- # check length of line.
272
- # first, a quick check to see if there is any chance of being too long.
273
- if (($line =~ tr/\t/\t/) * 7 + length($line) > 80) {
274
- # yes, there is a chance.
275
- # replace tabs with spaces and check again.
276
- my $eline = $line;
277
- 1 while $eline =~
278
- s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
279
- if (length($eline) > 80) {
280
- err("line > 80 characters");
281
- }
282
- }
283
-
284
- # ignore NOTE(...) annotations (assumes NOTE is on lines by itself).
285
- if ($note_level || /\b_?NOTE\s*\(/) { # if in NOTE or this is NOTE
286
- s/[^()]//g; # eliminate all non-parens
287
- $note_level += s/\(//g - length; # update paren nest level
288
- next;
289
- }
290
-
291
- # a /* BEGIN JSSTYLED */ comment starts a no-check block.
292
- if (/\/\* *BEGIN *JSSTYLED *\*\//) {
293
- $nocheck = 1;
294
- }
295
-
296
- # a /*JSSTYLED*/ comment indicates that the next line is ok.
297
- if (/\/\* *JSSTYLED.*\*\//) {
298
- /^.*\/\* *JSSTYLED *(.*) *\*\/.*$/;
299
- $okmsg = $1;
300
- $nextok = 1;
301
- }
302
- if (/\/\/ *JSSTYLED/) {
303
- /^.*\/\/ *JSSTYLED *(.*)$/;
304
- $okmsg = $1;
305
- $nextok = 1;
306
- }
307
-
308
- # universal checks; apply to everything
309
- if (/\t +\t/) {
310
- err("spaces between tabs");
311
- }
312
- if (/ \t+ /) {
313
- err("tabs between spaces");
314
- }
315
- if (/\s$/) {
316
- err("space or tab at end of line");
317
- }
318
- if (/[^ \t(]\/\*/ && !/\w\(\/\*.*\*\/\);/) {
319
- err("comment preceded by non-blank");
320
- }
321
-
322
- # is this the beginning or ending of a function?
323
- # (not if "struct foo\n{\n")
324
- if (/^{$/ && $prev =~ /\)\s*(const\s*)?(\/\*.*\*\/\s*)?\\?$/) {
325
- $in_function = 1;
326
- $in_declaration = 1;
327
- $in_function_header = 0;
328
- $prev = $line;
329
- next line;
330
- }
331
- if (/^}\s*(\/\*.*\*\/\s*)*$/) {
332
- if ($prev =~ /^\s*return\s*;/) {
333
- err_prev("unneeded return at end of function");
334
- }
335
- $in_function = 0;
336
- reset_indent(); # we don't check between functions
337
- $prev = $line;
338
- next line;
339
- }
340
- if (/^\w*\($/) {
341
- $in_function_header = 1;
342
- }
343
-
344
- # a blank line terminates the declarations within a function.
345
- # XXX - but still a problem in sub-blocks.
346
- if ($in_declaration && /^$/) {
347
- $in_declaration = 0;
348
- }
349
-
350
- if ($comment_done) {
351
- $in_comment = 0;
352
- $in_header_comment = 0;
353
- $comment_done = 0;
354
- }
355
- # does this looks like the start of a block comment?
356
- if (/$hdr_comment_start/) {
357
- if (!/^\t*\/\*/) {
358
- err("block comment not indented by tabs");
359
- }
360
- $in_comment = 1;
361
- /^(\s*)\//;
362
- $comment_prefix = $1;
363
- if ($comment_prefix eq "") {
364
- $in_header_comment = 1;
365
- }
366
- $prev = $line;
367
- next line;
368
- }
369
- # are we still in the block comment?
370
- if ($in_comment) {
371
- if (/^$comment_prefix \*\/$/) {
372
- $comment_done = 1;
373
- } elsif (/\*\//) {
374
- $comment_done = 1;
375
- err("improper block comment close")
376
- unless ($ignore_hdr_comment && $in_header_comment);
377
- } elsif (!/^$comment_prefix \*[ \t]/ &&
378
- !/^$comment_prefix \*$/) {
379
- err("improper block comment")
380
- unless ($ignore_hdr_comment && $in_header_comment);
381
- }
382
- }
383
-
384
- if ($in_header_comment && $ignore_hdr_comment) {
385
- $prev = $line;
386
- next line;
387
- }
388
-
389
- # check for errors that might occur in comments and in code.
390
-
391
- # allow spaces to be used to draw pictures in header comments.
392
- #if (/[^ ] / && !/".* .*"/ && !$in_header_comment) {
393
- # err("spaces instead of tabs");
394
- #}
395
- #if (/^ / && !/^ \*[ \t\/]/ && !/^ \*$/ &&
396
- # (!/^ \w/ || $in_function != 0)) {
397
- # err("indent by spaces instead of tabs");
398
- #}
399
- if (/^ {2,}/ && !/^ [^ ]/) {
400
- err("indent by spaces instead of tabs");
401
- }
402
- if (/^\t+ [^ \t\*]/ || /^\t+ \S/ || /^\t+ \S/) {
403
- err("continuation line not indented by 4 spaces");
404
- }
405
-
406
- if (/^\s*\/\*./ && !/^\s*\/\*.*\*\// && !/$hdr_comment_start/) {
407
- err("improper first line of block comment");
408
- }
409
-
410
- if ($in_comment) { # still in comment, don't do further checks
411
- $prev = $line;
412
- next line;
413
- }
414
-
415
- if ((/[^(]\/\*\S/ || /^\/\*\S/) &&
416
- !(/$lint_re/ || ($splint_comments && /$splint_re/))) {
417
- err("missing blank after open comment");
418
- }
419
- if (/\S\*\/[^)]|\S\*\/$/ &&
420
- !(/$lint_re/ || ($splint_comments && /$splint_re/))) {
421
- err("missing blank before close comment");
422
- }
423
- if (/\/\/\S/) { # C++ comments
424
- err("missing blank after start comment");
425
- }
426
- # check for unterminated single line comments, but allow them when
427
- # they are used to comment out the argument list of a function
428
- # declaration.
429
- if (/\S.*\/\*/ && !/\S.*\/\*.*\*\// && !/\(\/\*/) {
430
- err("unterminated single line comment");
431
- }
432
-
433
- if (/^(#else|#endif|#include)(.*)$/) {
434
- $prev = $line;
435
- next line;
436
- }
437
-
438
- #
439
- # delete any comments and check everything else. Note that
440
- # ".*?" is a non-greedy match, so that we don't get confused by
441
- # multiple comments on the same line.
442
- #
443
- s/\/\*.*?\*\///g;
444
- s/\/\/.*$//; # C++ comments
445
-
446
- # delete any trailing whitespace; we have already checked for that.
447
- s/\s*$//;
448
-
449
- # following checks do not apply to text in comments.
450
- if (/"/) {
451
- err("literal string using double-quote instead of single");
452
- }
453
-
454
- if (/[^=!<>\s][!<>=]=/ || /[^<>!=][!<>=]==?[^\s,=]/ ||
455
- (/[^->]>[^,=>\s]/ && !/[^->]>$/) ||
456
- (/[^<]<[^,=<\s]/ && !/[^<]<$/) ||
457
- /[^<\s]<[^<]/ || /[^->\s]>[^>]/) {
458
- err("missing space around relational operator");
459
- }
460
- if (/\S>>=/ || /\S<<=/ || />>=\S/ || /<<=\S/ || /\S[-+*\/&|^%]=/ ||
461
- (/[^-+*\/&|^%!<>=\s]=[^=]/ && !/[^-+*\/&|^%!<>=\s]=$/) ||
462
- (/[^!<>=]=[^=\s]/ && !/[^!<>=]=$/)) {
463
- # XXX - should only check this for C++ code
464
- # XXX - there are probably other forms that should be allowed
465
- if (!/\soperator=/) {
466
- err("missing space around assignment operator");
467
- }
468
- }
469
- if (/[,;]\S/ && !/\bfor \(;;\)/) {
470
- err("comma or semicolon followed by non-blank");
471
- }
472
- # allow "for" statements to have empty "while" clauses
473
- if (/\s[,;]/ && !/^[\t]+;$/ && !/^\s*for \([^;]*; ;[^;]*\)/) {
474
- err("comma or semicolon preceded by blank");
475
- }
476
- if (/^\s*(&&|\|\|)/) {
477
- err("improper boolean continuation");
478
- }
479
- if (/\S *(&&|\|\|)/ || /(&&|\|\|) *\S/) {
480
- err("more than one space around boolean operator");
481
- }
482
- if (/\b(delete|typeof|instanceOf|throw|with|catch|new|function|in|for|if|while|switch|return|case)\(/) {
483
- err("missing space between keyword and paren");
484
- }
485
- if (/(\b(catch|for|if|with|while|switch|return)\b.*){2,}/) {
486
- # multiple "case" and "sizeof" allowed
487
- err("more than one keyword on line");
488
- }
489
- if (/\b(delete|typeof|instanceOf|with|throw|catch|new|function|in|for|if|while|switch|return|case)\s\s+\(/ &&
490
- !/^#if\s+\(/) {
491
- err("extra space between keyword and paren");
492
- }
493
- # try to detect "func (x)" but not "if (x)" or
494
- # "#define foo (x)" or "int (*func)();"
495
- if (/\w\s\(/) {
496
- my $s = $_;
497
- # strip off all keywords on the line
498
- s/\b(delete|typeof|instanceOf|throw|with|catch|new|function|in|for|if|while|switch|return|case)\s\(/XXX(/g;
499
- s/#elif\s\(/XXX(/g;
500
- s/^#define\s+\w+\s+\(/XXX(/;
501
- # do not match things like "void (*f)();"
502
- # or "typedef void (func_t)();"
503
- s/\w\s\(+\*/XXX(*/g;
504
- s/\b(void)\s+\(+/XXX(/og;
505
- if (/\w\s\(/) {
506
- err("extra space between function name and left paren");
507
- }
508
- $_ = $s;
509
- }
510
-
511
- if (/^\s*return\W[^;]*;/ && !/^\s*return\s*\(.*\);/) {
512
- err("unparenthesized return expression");
513
- }
514
- if (/\btypeof\b/ && !/\btypeof\s*\(.*\)/) {
515
- err("unparenthesized typeof expression");
516
- }
517
- if (/\(\s/) {
518
- err("whitespace after left paren");
519
- }
520
- # allow "for" statements to have empty "continue" clauses
521
- if (/\s\)/ && !/^\s*for \([^;]*;[^;]*; \)/) {
522
- err("whitespace before right paren");
523
- }
524
- if (/^\s*\(void\)[^ ]/) {
525
- err("missing space after (void) cast");
526
- }
527
- if (/\S{/ && !/({|\(){/) {
528
- err("missing space before left brace");
529
- }
530
- if ($in_function && /^\s+{/ &&
531
- ($prev =~ /\)\s*$/ || $prev =~ /\bstruct\s+\w+$/)) {
532
- err("left brace starting a line");
533
- }
534
- if (/}(else|while)/) {
535
- err("missing space after right brace");
536
- }
537
- if (/}\s\s+(else|while)/) {
538
- err("extra space after right brace");
539
- }
540
- if (/^\s+#/) {
541
- err("preprocessor statement not in column 1");
542
- }
543
- if (/^#\s/) {
544
- err("blank after preprocessor #");
545
- }
546
-
547
- #
548
- # We completely ignore, for purposes of indentation:
549
- # * lines outside of functions
550
- # * preprocessor lines
551
- #
552
- if ($check_continuation && $in_function && !$in_cpp) {
553
- process_indent($_);
554
- }
555
-
556
- if ($heuristic) {
557
- # cannot check this everywhere due to "struct {\n...\n} foo;"
558
- if ($in_function && !$in_declaration &&
559
- /}./ && !/}\s+=/ && !/{.*}[;,]$/ && !/}(\s|)*$/ &&
560
- !/} (else|while)/ && !/}}/) {
561
- err("possible bad text following right brace");
562
- }
563
- # cannot check this because sub-blocks in
564
- # the middle of code are ok
565
- if ($in_function && /^\s+{/) {
566
- err("possible left brace starting a line");
567
- }
568
- }
569
- if (/^\s*else\W/) {
570
- if ($prev =~ /^\s*}$/) {
571
- err_prefix($prev,
572
- "else and right brace should be on same line");
573
- }
574
- }
575
- $prev = $line;
576
- }
577
-
578
- if ($prev eq "") {
579
- err("last line in file is blank");
580
- }
581
-
582
- }
583
-
584
- #
585
- # Continuation-line checking
586
- #
587
- # The rest of this file contains the code for the continuation checking
588
- # engine. It's a pretty simple state machine which tracks the expression
589
- # depth (unmatched '('s and '['s).
590
- #
591
- # Keep in mind that the argument to process_indent() has already been heavily
592
- # processed; all comments have been replaced by control-A, and the contents of
593
- # strings and character constants have been elided.
594
- #
595
-
596
- my $cont_in; # currently inside of a continuation
597
- my $cont_off; # skipping an initializer or definition
598
- my $cont_noerr; # suppress cascading errors
599
- my $cont_start; # the line being continued
600
- my $cont_base; # the base indentation
601
- my $cont_first; # this is the first line of a statement
602
- my $cont_multiseg; # this continuation has multiple segments
603
-
604
- my $cont_special; # this is a C statement (if, for, etc.)
605
- my $cont_macro; # this is a macro
606
- my $cont_case; # this is a multi-line case
607
-
608
- my @cont_paren; # the stack of unmatched ( and [s we've seen
609
-
610
- sub
611
- reset_indent()
612
- {
613
- $cont_in = 0;
614
- $cont_off = 0;
615
- }
616
-
617
- sub
618
- delabel($)
619
- {
620
- #
621
- # replace labels with tabs. Note that there may be multiple
622
- # labels on a line.
623
- #
624
- local $_ = $_[0];
625
-
626
- while (/^(\t*)( *(?:(?:\w+\s*)|(?:case\b[^:]*)): *)(.*)$/) {
627
- my ($pre_tabs, $label, $rest) = ($1, $2, $3);
628
- $_ = $pre_tabs;
629
- while ($label =~ s/^([^\t]*)(\t+)//) {
630
- $_ .= "\t" x (length($2) + length($1) / 8);
631
- }
632
- $_ .= ("\t" x (length($label) / 8)).$rest;
633
- }
634
-
635
- return ($_);
636
- }
637
-
638
- sub
639
- process_indent($)
640
- {
641
- require strict;
642
- local $_ = $_[0]; # preserve the global $_
643
-
644
- s///g; # No comments
645
- s/\s+$//; # Strip trailing whitespace
646
-
647
- return if (/^$/); # skip empty lines
648
-
649
- # regexps used below; keywords taking (), macros, and continued cases
650
- my $special = '(?:(?:\}\s*)?else\s+)?(?:if|for|while|switch)\b';
651
- my $macro = '[A-Z_][A-Z_0-9]*\(';
652
- my $case = 'case\b[^:]*$';
653
-
654
- # skip over enumerations, array definitions, initializers, etc.
655
- if ($cont_off <= 0 && !/^\s*$special/ &&
656
- (/(?:(?:\b(?:enum|struct|union)\s*[^\{]*)|(?:\s+=\s*)){/ ||
657
- (/^\s*{/ && $prev =~ /=\s*(?:\/\*.*\*\/\s*)*$/))) {
658
- $cont_in = 0;
659
- $cont_off = tr/{/{/ - tr/}/}/;
660
- return;
661
- }
662
- if ($cont_off) {
663
- $cont_off += tr/{/{/ - tr/}/}/;
664
- return;
665
- }
666
-
667
- if (!$cont_in) {
668
- $cont_start = $line;
669
-
670
- if (/^\t* /) {
671
- err("non-continuation indented 4 spaces");
672
- $cont_noerr = 1; # stop reporting
673
- }
674
- $_ = delabel($_); # replace labels with tabs
675
-
676
- # check if the statement is complete
677
- return if (/^\s*\}?$/);
678
- return if (/^\s*\}?\s*else\s*\{?$/);
679
- return if (/^\s*do\s*\{?$/);
680
- return if (/{$/);
681
- return if (/}[,;]?$/);
682
-
683
- # Allow macros on their own lines
684
- return if (/^\s*[A-Z_][A-Z_0-9]*$/);
685
-
686
- # cases we don't deal with, generally non-kosher
687
- if (/{/) {
688
- err("stuff after {");
689
- return;
690
- }
691
-
692
- # Get the base line, and set up the state machine
693
- /^(\t*)/;
694
- $cont_base = $1;
695
- $cont_in = 1;
696
- @cont_paren = ();
697
- $cont_first = 1;
698
- $cont_multiseg = 0;
699
-
700
- # certain things need special processing
701
- $cont_special = /^\s*$special/? 1 : 0;
702
- $cont_macro = /^\s*$macro/? 1 : 0;
703
- $cont_case = /^\s*$case/? 1 : 0;
704
- } else {
705
- $cont_first = 0;
706
-
707
- # Strings may be pulled back to an earlier (half-)tabstop
708
- unless ($cont_noerr || /^$cont_base / ||
709
- (/^\t*(?: )?(?:gettext\()?\"/ && !/^$cont_base\t/)) {
710
- err_prefix($cont_start,
711
- "continuation should be indented 4 spaces");
712
- }
713
- }
714
-
715
- my $rest = $_; # keeps the remainder of the line
716
-
717
- #
718
- # The split matches 0 characters, so that each 'special' character
719
- # is processed separately. Parens and brackets are pushed and
720
- # popped off the @cont_paren stack. For normal processing, we wait
721
- # until a ; or { terminates the statement. "special" processing
722
- # (if/for/while/switch) is allowed to stop when the stack empties,
723
- # as is macro processing. Case statements are terminated with a :
724
- # and an empty paren stack.
725
- #
726
- foreach $_ (split /[^\(\)\[\]\{\}\;\:]*/) {
727
- next if (length($_) == 0);
728
-
729
- # rest contains the remainder of the line
730
- my $rxp = "[^\Q$_\E]*\Q$_\E";
731
- $rest =~ s/^$rxp//;
732
-
733
- if (/\(/ || /\[/) {
734
- push @cont_paren, $_;
735
- } elsif (/\)/ || /\]/) {
736
- my $cur = $_;
737
- tr/\)\]/\(\[/;
738
-
739
- my $old = (pop @cont_paren);
740
- if (!defined($old)) {
741
- err("unexpected '$cur'");
742
- $cont_in = 0;
743
- last;
744
- } elsif ($old ne $_) {
745
- err("'$cur' mismatched with '$old'");
746
- $cont_in = 0;
747
- last;
748
- }
749
-
750
- #
751
- # If the stack is now empty, do special processing
752
- # for if/for/while/switch and macro statements.
753
- #
754
- next if (@cont_paren != 0);
755
- if ($cont_special) {
756
- if ($rest =~ /^\s*{?$/) {
757
- $cont_in = 0;
758
- last;
759
- }
760
- if ($rest =~ /^\s*;$/) {
761
- err("empty if/for/while body ".
762
- "not on its own line");
763
- $cont_in = 0;
764
- last;
765
- }
766
- if (!$cont_first && $cont_multiseg == 1) {
767
- err_prefix($cont_start,
768
- "multiple statements continued ".
769
- "over multiple lines");
770
- $cont_multiseg = 2;
771
- } elsif ($cont_multiseg == 0) {
772
- $cont_multiseg = 1;
773
- }
774
- # We've finished this section, start
775
- # processing the next.
776
- goto section_ended;
777
- }
778
- if ($cont_macro) {
779
- if ($rest =~ /^$/) {
780
- $cont_in = 0;
781
- last;
782
- }
783
- }
784
- } elsif (/\;/) {
785
- if ($cont_case) {
786
- err("unexpected ;");
787
- } elsif (!$cont_special) {
788
- err("unexpected ;") if (@cont_paren != 0);
789
- if (!$cont_first && $cont_multiseg == 1) {
790
- err_prefix($cont_start,
791
- "multiple statements continued ".
792
- "over multiple lines");
793
- $cont_multiseg = 2;
794
- } elsif ($cont_multiseg == 0) {
795
- $cont_multiseg = 1;
796
- }
797
- if ($rest =~ /^$/) {
798
- $cont_in = 0;
799
- last;
800
- }
801
- if ($rest =~ /^\s*special/) {
802
- err("if/for/while/switch not started ".
803
- "on its own line");
804
- }
805
- goto section_ended;
806
- }
807
- } elsif (/\{/) {
808
- err("{ while in parens/brackets") if (@cont_paren != 0);
809
- err("stuff after {") if ($rest =~ /[^\s}]/);
810
- $cont_in = 0;
811
- last;
812
- } elsif (/\}/) {
813
- err("} while in parens/brackets") if (@cont_paren != 0);
814
- if (!$cont_special && $rest !~ /^\s*(while|else)\b/) {
815
- if ($rest =~ /^$/) {
816
- err("unexpected }");
817
- } else {
818
- err("stuff after }");
819
- }
820
- $cont_in = 0;
821
- last;
822
- }
823
- } elsif (/\:/ && $cont_case && @cont_paren == 0) {
824
- err("stuff after multi-line case") if ($rest !~ /$^/);
825
- $cont_in = 0;
826
- last;
827
- }
828
- next;
829
- section_ended:
830
- # End of a statement or if/while/for loop. Reset
831
- # cont_special and cont_macro based on the rest of the
832
- # line.
833
- $cont_special = ($rest =~ /^\s*$special/)? 1 : 0;
834
- $cont_macro = ($rest =~ /^\s*$macro/)? 1 : 0;
835
- $cont_case = 0;
836
- next;
837
- }
838
- $cont_noerr = 0 if (!$cont_in);
839
- }