javascript 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #------------------------------------------------------------------------------
  2. # $File: javascript,v 1.7 2024/11/10 14:48:55 christos Exp $
  3. # javascript: magic for javascript and node.js scripts.
  4. #
  5. 0 string/tw #!/bin/node Node.js script executable
  6. !:mime application/javascript
  7. 0 string/tw #!/usr/bin/node Node.js script executable
  8. !:mime application/javascript
  9. 0 string/tw #!/bin/nodejs Node.js script executable
  10. !:mime application/javascript
  11. 0 string/tw #!/usr/bin/nodejs Node.js script executable
  12. !:mime application/javascript
  13. 0 string/t #!/usr/bin/env\ node Node.js script executable
  14. !:mime application/javascript
  15. 0 string/t #!/usr/bin/env\ nodejs Node.js script executable
  16. !:mime application/javascript
  17. # JavaScript
  18. # The strength is increased to beat the C++ but lose to HTML rules,
  19. # because javascript is embedded in hmtl files typically
  20. 0 search "use\x20strict" JavaScript source
  21. !:strength +20
  22. !:mime application/javascript
  23. !:ext js
  24. 0 search 'use\x20strict' JavaScript source
  25. !:strength +20
  26. !:mime application/javascript
  27. !:ext js
  28. 0 regex module(\\.|\\[["'])exports.*= JavaScript source
  29. !:strength +20
  30. !:mime application/javascript
  31. !:ext js
  32. 0 regex \^(const|var|let).*=.*require\\( JavaScript source
  33. !:strength +20
  34. !:mime application/javascript
  35. !:ext js
  36. 0 regex \^export\x20(function|class|default|const|var|let|async)\x20 JavaScript source
  37. !:strength +20
  38. !:mime application/javascript
  39. !:ext js
  40. 0 regex \\((async\x20)?function[(\x20] JavaScript source
  41. !:strength +20
  42. !:mime application/javascript
  43. !:ext js
  44. 0 regex \^(import|export).*\x20from\x20 JavaScript source
  45. !:strength +20
  46. !:mime application/javascript
  47. !:ext js
  48. 0 regex \^(import|export)\x20["']\\./ JavaScript source
  49. !:strength +20
  50. !:mime application/javascript
  51. !:ext js
  52. 0 regex typeof.*[!=]== JavaScript source
  53. !:strength +20
  54. !:mime application/javascript
  55. !:ext js
  56. # React Native minified JavaScript
  57. 0 search/128 __BUNDLE_START_TIME__= React Native minified JavaScript
  58. !:strength +20
  59. !:mime application/javascript
  60. !:ext bundle/jsbundle
  61. # Hermes by Facebook https://hermesengine.dev/
  62. # https://github.com/facebook/hermes/blob/master/include/hermes/\
  63. # BCGen/HBC/BytecodeFileFormat.h#L24
  64. 0 lequad 0x1F1903C103BC1FC6 Hermes JavaScript bytecode
  65. >8 lelong x \b, version %d
  66. # v8 JavaScript engine bytecode
  67. # From: Alexandre Iooss <erdnaxe@crans.org>
  68. # URL: https://v8.dev/docs/ignition
  69. # Note: used in bytenode and NW.js protected source code
  70. # V8 bytecode extraction was added in NodeJS v5.7.0 (V8 4.6.85.31).
  71. # Version information is provided for some v8 versions found in NodeJS releases.
  72. 2 uleshort =0xC0DE
  73. >0 ulelong^0xC0DE0000 >0
  74. # Reservation table starts at 40
  75. >>40 ulelong&0xFFFFFF00 =0x80000000
  76. # Stub keys present
  77. >>>24 ulelong >0
  78. >>>>0 ulelong^0xC0DE0000 x v8 bytecode, external reference table size: %u bytes,
  79. >>>>4 ulelong =0xEE4BF478 version 5.1.281.111,
  80. >>>>4 ulelong =0xC4A0100C version 5.5.372.43,
  81. >>>>8 ulelong x source size: %u bytes,
  82. >>>>12 ulelong x cpu features: %#08X,
  83. >>>>16 ulelong x flag hash: %#08X,
  84. >>>>20 ulelong x %u reservations,
  85. >>>>28 ulelong x payload size: %u bytes,
  86. >>>>32 ulelong x checksum1: %#08X,
  87. >>>>36 ulelong x checksum2: %#08X
  88. # No stub keys
  89. >>>24 ulelong =0
  90. >>>>0 ulelong^0xC0DE0000 x v8 bytecode, external reference table size: %u bytes,
  91. >>>>4 ulelong =0x54F0AD81 version 6.2.414.46,
  92. >>>>4 ulelong =0X7D1BF182 version 6.2.414.54,
  93. >>>>4 ulelong =0x35BA122E version 6.2.414.77,
  94. >>>>4 ulelong =0X9319F9C2 version 6.2.414.78,
  95. >>>>4 ulelong =0xB1240060 version 6.6.346.32,
  96. >>>>4 ulelong =0x2B757060 version 6.7.288.46,
  97. >>>>4 ulelong =0x09D147AA version 6.7.288.49,
  98. >>>>4 ulelong =0xF4D4F48A version 6.8.275.32,
  99. >>>>4 ulelong =0xD3961326 version 7.0.276.38,
  100. >>>>8 ulelong x source size: %u bytes,
  101. >>>>12 ulelong x cpu features: %#08X,
  102. >>>>16 ulelong x flag hash: %#08X,
  103. >>>>20 ulelong x %u reservations,
  104. >>>>28 ulelong x payload size: %u bytes,
  105. >>>>32 ulelong x checksum1: %#08X,
  106. >>>>36 ulelong x checksum2: %#08X
  107. # Reservation table starts at 32
  108. >>32 ulelong&0xFFFFFF00 =0x80000000
  109. # Second checksum present
  110. >>>28 ulelong >0
  111. >>>>0 ulelong^0xC0DE0000 x v8 bytecode, external reference table size: %u bytes,
  112. >>>>4 ulelong =0x21DDF627 version 7.4.288.21,
  113. >>>>4 ulelong =0x1FC9FE84 version 7.4.288.27,
  114. >>>>4 ulelong =0x60A99E8B version 7.5.288.22,
  115. >>>>4 ulelong =0x4F665E90 version 7.6.303.29,
  116. >>>>4 ulelong =0xC7ACFCDE version 7.7.299.11,
  117. >>>>4 ulelong =0x7F641D8F version 7.7.299.13,
  118. >>>>4 ulelong =0xFD9A4F2E version 7.8.279.17,
  119. >>>>4 ulelong =0x3A845324 version 7.8.279.23,
  120. >>>>4 ulelong =0xFF52FEAF version 7.9.317.25,
  121. >>>>8 ulelong x source size: %u bytes,
  122. >>>>12 ulelong x flag hash: %#08X,
  123. >>>>16 ulelong x %u reservations,
  124. >>>>20 ulelong x payload size: %u bytes,
  125. >>>>24 ulelong x checksum1: %#08X,
  126. >>>>28 ulelong x checksum2: %#08X
  127. # No second checksum
  128. >>>28 ulelong =0
  129. >>>>0 ulelong^0xC0DE0000 x v8 bytecode, external reference table size: %u bytes,
  130. >>>>4 ulelong =0x8725E0F8 version 8.1.307.30,
  131. >>>>4 ulelong =0x09ED1289 version 8.1.307.31,
  132. >>>>4 ulelong =0xA5728C87 version 8.3.110.9,
  133. >>>>4 ulelong =0xB45C5D30 version 8.4.371.23,
  134. >>>>4 ulelong =0xED9C278B version 8.4.371.19,
  135. >>>>4 ulelong =0xD27BFF42 version 8.6.395.16,
  136. >>>>8 ulelong x source size: %u bytes,
  137. >>>>12 ulelong x flag hash: %#08X,
  138. >>>>16 ulelong x %u reservations,
  139. >>>>20 ulelong x payload size: %u bytes,
  140. >>>>24 ulelong x payload checksum: %#08X
  141. # No reservation table and code starts at 24
  142. >>32 ulelong =0
  143. >>>0 ulelong^0xC0DE0000 x v8 bytecode, external reference table size: %u bytes,
  144. >>>4 ulelong =0x9A6F0B0F version 9.0.257.17,
  145. >>>4 ulelong =0x271D5D1E version 9.0.257.24,
  146. >>>4 ulelong =0x4EEA75DF version 9.0.257.25,
  147. >>>4 ulelong =0x80809479 version 9.1.269.36,
  148. >>>4 ulelong =0x55C46F65 version 9.1.269.38,
  149. >>>4 ulelong =0x8A9C758A version 9.2.230.21,
  150. >>>4 ulelong =0x9712F0E1 version 9.3.345.16,
  151. >>>4 ulelong =0x29593715 version 9.4.146.19,
  152. >>>4 ulelong =0xCD991825 version 9.4.146.24,
  153. >>>4 ulelong =0xACDD64EE version 9.4.146.26,
  154. >>>4 ulelong =0xC96B4CD5 version 9.5.172.21,
  155. >>>4 ulelong =0xBCCE4578 version 9.5.172.25,
  156. >>>4 ulelong =0xA2EEA077 version 9.6.180.15,
  157. >>>4 ulelong =0xFD350011 version 10.1.124.8,
  158. >>>4 ulelong =0xBEF4028F version 10.2.154.13,
  159. >>>4 ulelong =0xAF632352 version 10.2.154.4,
  160. >>>8 ulelong x source size: %u bytes,
  161. >>>12 ulelong x flag hash: %#08X,
  162. >>>16 ulelong x payload size: %u bytes,
  163. >>>20 ulelong x payload checksum: %#08X